@yuriai/web 0.3.5 → 0.3.6-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AgentAvatar-CNOu_vy0.js → AgentAvatar-Ce3xIokt.js} +1 -1
- package/dist/assets/{AgentSelector-K5JSbXv3.js → AgentSelector-CMGO3rt5.js} +1 -1
- package/dist/assets/ArchivedSessionsDialog-7SxXt_dN.js +1 -0
- package/dist/assets/{AssistantConversationSurface-u3ndSmZP.js → AssistantConversationSurface-DN_0TqBx.js} +3 -3
- package/dist/assets/AssistantSessionCard-CpXxEZ9s.js +2 -0
- package/dist/assets/{AssistantUnreadBadge-opyLZlZd.js → AssistantUnreadBadge-DMz3nOHJ.js} +1 -1
- package/dist/assets/{AssistantView-CDPTtrUZ.js → AssistantView-hrY8xNCO.js} +1 -1
- package/dist/assets/{AssistantWorkingAvatar-Vghb8xlt.js → AssistantWorkingAvatar-D8BEeeXa.js} +1 -1
- package/dist/assets/{AssistantsSettingsPage-Dt4OP3J-.js → AssistantsSettingsPage-6dBzudvs.js} +1 -1
- package/dist/assets/BinaryFileFallback-Ck_aBVmU.js +1 -0
- package/dist/assets/{BtwPanel-DnMW6R43.js → BtwPanel-CXo0GBAo.js} +3 -3
- package/dist/assets/{BusyDots-FXSlMe2F.js → BusyDots-CWyfTnAt.js} +3 -3
- package/dist/assets/ChatContainer-C0aZYA_a.js +65 -0
- package/dist/assets/{ChatView-AFUNEBdD.js → ChatView-tz6gA9q_.js} +3 -3
- package/dist/assets/{DiagramView-j7aFp44v.js → DiagramView-CzXoWMbU.js} +1 -1
- package/dist/assets/{DiffView-DZ_gKyTO.js → DiffView-CC2W_84v.js} +1 -1
- package/dist/assets/{DiffViewToggle-DkxhEUhV.js → DiffViewToggle-CI88C8kG.js} +1 -1
- package/dist/assets/{ErrorBoundary-CCH4LiRY.js → ErrorBoundary-DBZXhhMA.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DO9PZrJL.js → FadeInOnReveal-Crw10nRn.js} +1 -1
- package/dist/assets/{GuiPluginMount-BCqt2pmM.js → GuiPluginMount-wQ9DWE6I.js} +1 -1
- package/dist/assets/{GuiPluginPage-BSjWEmIu.js → GuiPluginPage-CqHPTVP4.js} +1 -1
- package/dist/assets/{GuiPluginSurface-B8QjacMd.js → GuiPluginSurface-sDPisFX3.js} +1 -1
- package/dist/assets/{GuiPluginTitlebarItems-DfHugxsx.js → GuiPluginTitlebarItems-Dx5pTQiP.js} +1 -1
- package/dist/assets/{GuiPluginWindow-CDycMqzT.js → GuiPluginWindow-BP8DRUZz.js} +1 -1
- package/dist/assets/{Icon-B-w2YKpn.js → Icon-DrO1MlqW.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-DsgRtfYG.js → ImageLoadingPlaceholder-Brhbk0iP.js} +1 -1
- package/dist/assets/{LoadingImage-B3IL7hnv.js → LoadingImage-k1x9Kvl1.js} +1 -1
- package/dist/assets/MarkdownRenderer-BHnonkuY.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CPgpkd9b.js → MarkdownRendererImpl-CnPzG_rJ.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BzK1BO80.js → MarkstreamRendererImpl-CBGT2iHG.js} +1 -1
- package/dist/assets/{MobileAssistantSettingsPage-DVpE3b24.js → MobileAssistantSettingsPage-C3BxNP1l.js} +1 -1
- package/dist/assets/{MobileAssistantTab-BbccE67x.js → MobileAssistantTab-BRkzsLvg.js} +1 -1
- package/dist/assets/{MobileBtwPage-BRN1gAmR.js → MobileBtwPage-BjuxFp6a.js} +1 -1
- package/dist/assets/{MobileChangesSurface-BwmSTxeh.js → MobileChangesSurface-B2flw1Ap.js} +1 -1
- package/dist/assets/{MobileChatScreen-Bf42GrQ8.js → MobileChatScreen-D9fpOOvH.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DKWnQoSh.js → MobileDetailNavigation-BVA0JCsG.js} +1 -1
- package/dist/assets/MobileFilesSurface-CMBH785S.js +2 -0
- package/dist/assets/{MobileHtmlNetworkBoundary-BKSYPR9N.js → MobileHtmlNetworkBoundary-BJj2vivL.js} +2 -2
- package/dist/assets/{MobileOverlayPanel-DcRWQlmf.js → MobileOverlayPanel-DPgcB7AO.js} +1 -1
- package/dist/assets/{MobileResizableSheet-CF3Pbot4.js → MobileResizableSheet-D5HcC4ME.js} +1 -1
- package/dist/assets/{MobileSettingsTab-of6zpTsr.js → MobileSettingsTab-B0-1WZRt.js} +1 -1
- package/dist/assets/{MobileShareBridge-CRq9F1rn.js → MobileShareBridge-8X_vdmZN.js} +1 -1
- package/dist/assets/{MobileSurface-DGNomvlu.js → MobileSurface-41iI-7Zd.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-0aJFe3_x.js → MobileTabPageHeader-CPz8P10R.js} +1 -1
- package/dist/assets/{ModelLogo-D27dq-si.js → ModelLogo-D4aymugJ.js} +1 -1
- package/dist/assets/{ModelSelector-Dg__8QLh.js → ModelSelector-BUSeXkcU.js} +1 -1
- package/dist/assets/{MultiRunWindow-COqSg1Nk.js → MultiRunWindow-BbYMumwu.js} +1 -1
- package/dist/assets/{OnboardingScreen-DUNyDwc6.js → OnboardingScreen-DMLpMUuF.js} +1 -1
- package/dist/assets/{OverlayScrollbar-DS6XJ1HA.js → OverlayScrollbar-B0O9-JfD.js} +1 -1
- package/dist/assets/{PierreDiffViewer-BHwj_6j8.js → PierreDiffViewer-DFDVqbNq.js} +1 -1
- package/dist/assets/{ProviderLogo-Cm9RNV_U.js → ProviderLogo-CBoJS4Di.js} +1 -1
- package/dist/assets/{RemoteAssistantSessionCard-DAjHRUrC.js → RemoteAssistantSessionCard-1MEZ6Wc_.js} +1 -1
- package/dist/assets/{RemoteDesktopPanel-Bays6pHh.js → RemoteDesktopPanel-CkwyCtui.js} +1 -1
- package/dist/assets/{ScheduledTasksDialog-DnwBC7cj.js → ScheduledTasksDialog-Cb_as8Cv.js} +1 -1
- package/dist/assets/{ScrollableOverlay-CkX-buJm.js → ScrollableOverlay-Cuq3KKRE.js} +1 -1
- package/dist/assets/{SettingsGroup-kZ_faXwL.js → SettingsGroup-BE-0Ya_e.js} +1 -1
- package/dist/assets/{SettingsView-C62JngPE.js → SettingsView-Q23asKrK.js} +15 -15
- package/dist/assets/{SettingsWindow-Cm8apHAR.js → SettingsWindow-C5quZoiL.js} +1 -1
- package/dist/assets/{SetupTourDialog-W_UeWH-i.js → SetupTourDialog-nJgPu0Kk.js} +1 -1
- package/dist/assets/{SyncActions-Blnq08ks.js → SyncActions-DddhcMDs.js} +1 -1
- package/dist/assets/{TerminalView-CMugifkh.js → TerminalView-DUwwOkqI.js} +1 -1
- package/dist/assets/{TextSelectionMenu-B2fIBlD3.js → TextSelectionMenu-Cd9EOoKM.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DdSUE2kP.js → ToolOutputDialog-DjekF5-2.js} +1 -1
- package/dist/assets/{YuriLogo-Ceon25sC.js → YuriLogo-CnV3RxpE.js} +1 -1
- package/dist/assets/{YuriWordmark-CW53XKgV.js → YuriWordmark-Bn5KdqMC.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-eNT2QtmP.js → assistant-attachment-cache-Y7yhlQcv.js} +1 -1
- package/dist/assets/{assistantMessagePreview-C7YAFen1.js → assistantMessagePreview-CR3sWqIa.js} +1 -1
- package/dist/assets/{assistantQueries-DxvTFlpL.js → assistantQueries-wJSqumUZ.js} +1 -1
- package/dist/assets/{auto-read-context-Ce0o43YI.js → auto-read-context-0SET_04C.js} +1 -1
- package/dist/assets/{capgoAdapter-DQwUA-Nt.js → capgoAdapter-DgVdXFZa.js} +1 -1
- package/dist/assets/{card-D44sTpdY.js → card-Br81AS-C.js} +1 -1
- package/dist/assets/{chatUpwardIntent-CnS7WWRL.js → chatUpwardIntent-D8gCJWE9.js} +1 -1
- package/dist/assets/{checkbox-DaKe0Tlq.js → checkbox-Cs7zimcx.js} +1 -1
- package/dist/assets/{client-ITylDDCS.js → client-QcYZg8_d.js} +3 -3
- package/dist/assets/{collapsible-CL3SPnOf.js → collapsible-BqnGY5G1.js} +1 -1
- package/dist/assets/{connection-hint-SMNZFDAe.js → connection-hint--2YSFO6b.js} +1 -1
- package/dist/assets/{context-menu-DZunhC8o.js → context-menu-C6YvSFUQ.js} +1 -1
- package/dist/assets/{desktopHosts-BsTrBVja.js → desktopHosts-DFa3lf0i.js} +1 -1
- package/dist/assets/{desktopRelayRestore-BxbRKak_.js → desktopRelayRestore-CGq-Ylgq.js} +1 -1
- package/dist/assets/{device-EIfSfSWk.js → device-CtdJ8KBJ.js} +1 -1
- package/dist/assets/{diagram-DFXqN638.js → diagram-IShCLLT-.js} +1 -1
- package/dist/assets/dialog-B6B8FIrL.css +1 -0
- package/dist/assets/{dialog-CmjXOKMz.js → dialog-C67GCo29.js} +1 -1
- package/dist/assets/{dropdown-menu-BT_66BFT.js → dropdown-menu-B6hbejyF.js} +1 -1
- package/dist/assets/{es-DqYZgeC6.js → es-BelVk9R_.js} +3 -3
- package/dist/assets/{fileMentionTouchSelection-B_62hIQI.js → fileMentionTouchSelection-SC-2eaMJ.js} +1 -1
- package/dist/assets/{fileReferenceActions-TmbrIHBI.js → fileReferenceActions-DEUhs_7h.js} +1 -1
- package/dist/assets/{fr-BHaun7Zq.js → fr-DtUzwB6h.js} +3 -3
- package/dist/assets/{gitApi-CBfYFgtd.js → gitApi-BZ4ZoWbQ.js} +1 -1
- package/dist/assets/gitApiHttp-C8AU1uiY.js +3 -0
- package/dist/assets/{githubAuthQueries-C5RxUNL2.js → githubAuthQueries-IJPWBo0B.js} +1 -1
- package/dist/assets/{historyImportQueries-CZsECryv.js → historyImportQueries-B3QBdaKo.js} +1 -1
- package/dist/assets/host-DchPrZpw.js +1 -0
- package/dist/assets/{i18n-Dojvs57M.js → i18n-BU8XOKjS.js} +1 -1
- package/dist/assets/{icons-D_vRtitD.js → icons-YECUJPe2.js} +1 -1
- package/dist/assets/{imageSource-Cq_p4gAe.js → imageSource-B39pFDdo.js} +1 -1
- package/dist/assets/{input-BllFKOjo.js → input-B2oH-nQc.js} +1 -1
- package/dist/assets/{input-store-dLjM4aiu.js → input-store-PqhVEhUI.js} +1 -1
- package/dist/assets/{insertionBoundaries-Br0Bdl9R.js → insertionBoundaries-B2RO01sd.js} +1 -1
- package/dist/assets/{ja-BGNugvrx.js → ja-CWta3CAu.js} +3 -3
- package/dist/assets/{kbd-CwkasrzN.js → kbd-B7_YRVny.js} +1 -1
- package/dist/assets/{ko-CGbNBfDe.js → ko-CJFoAZPE.js} +3 -3
- package/dist/assets/main-DCJxCPr0.js +2 -0
- package/dist/assets/main-DM5FeSEG.js +169 -0
- package/dist/assets/{markdownHeightCache-RX04MAqu.js → markdownHeightCache-BO7vbFmt.js} +1 -1
- package/dist/assets/{mcpQueries-qRW-HQMx.js → mcpQueries-CojZBAVK.js} +1 -1
- package/dist/assets/miniChat-VubQ-eH-.js +2 -0
- package/dist/assets/mobile-IXaFJ00O.js +2 -0
- package/dist/assets/{mobileBackNavigation-DsDUTnFY.js → mobileBackNavigation-CJq7EFq0.js} +1 -1
- package/dist/assets/mobileConnections--cUobzs-.js +2 -0
- package/dist/assets/{multirun-C2RRF2Q3.js → multirun-CphZu9f5.js} +1 -1
- package/dist/assets/{native-config-Czc142JT.js → native-config-Bes4FTeA.js} +1 -1
- package/dist/assets/{nativeComposerCover-DzEGSyOO.js → nativeComposerCover-C6VDH0H0.js} +1 -1
- package/dist/assets/navigation-DRRQnuzD.js +2 -0
- package/dist/assets/{openRemoteProjectSession-C5z2Juv7.js → openRemoteProjectSession-B4_B76XM.js} +1 -1
- package/dist/assets/openSessionFromDeepLink-DnoNsjzY.js +2 -0
- package/dist/assets/pathNormalization-ewtPqJWn.js +1 -0
- package/dist/assets/{pl-k8-4URiE.js → pl-BwZ6CWJm.js} +3 -3
- package/dist/assets/platform-CNdx57HN.js +1 -0
- package/dist/assets/{pluginPresentation-p_0sXPMT.js → pluginPresentation-DxjMvNYM.js} +1 -1
- package/dist/assets/{project-preview-BcLPKzwg.js → project-preview-CIkGbBPZ.js} +1 -1
- package/dist/assets/{projectActions-BPmI9_mW.js → projectActions-D84EVh3q.js} +1 -1
- package/dist/assets/{prompt-attachment-upload-BGppTOgV.js → prompt-attachment-upload-D1c308Ba.js} +1 -1
- package/dist/assets/{pt-BR-DdwCzXBH.js → pt-BR-DPAcgEDe.js} +3 -3
- package/dist/assets/pwa-Duem_qqG.js +2 -0
- package/dist/assets/queue-abort-optimistic-BX5gCxYj.js +1 -0
- package/dist/assets/{quota-2PwXAoIg.js → quota-BEyQ6n-w.js} +1 -1
- package/dist/assets/{reference-history-BwtzPAmA.js → reference-history-DV-P9xV1.js} +1 -1
- package/dist/assets/{remote-input-store-DdjKfpxS.js → remote-input-store-CquhCIoR.js} +1 -1
- package/dist/assets/remoteProjectQueries-BunVM5PM.js +1 -0
- package/dist/assets/remoteSessionReference-C2q6a218.js +1 -0
- package/dist/assets/{renderElectronMiniChatApp-BekZAu-s.js → renderElectronMiniChatApp-CdLIP8ke.js} +2 -2
- package/dist/assets/{renderMobileApp-C5U2cyeq.js → renderMobileApp-YszxdkcG.js} +5 -5
- package/dist/assets/{runtime-file-download-1s2Al1t3.js → runtime-file-download-wMVtKk2v.js} +1 -1
- package/dist/assets/runtime-file-resource-DKJJoOOc.js +6 -0
- package/dist/assets/{runtimeConfig-DzYIc49M.js → runtimeConfig-CMNPCJna.js} +1 -1
- package/dist/assets/runtimeEndpointReset-DUTNA8O6.js +4 -0
- package/dist/assets/{scheduledTaskNavigation-VVTOq9n2.js → scheduledTaskNavigation-DpfZSGu8.js} +1 -1
- package/dist/assets/{select-BOtGs1FV.js → select-DU75Zpg-.js} +1 -1
- package/dist/assets/sessionChangeSummary-BCF9VwAA.js +1 -0
- package/dist/assets/sessionLookup-D-QJrAW9.js +1 -0
- package/dist/assets/sessionOwnership-WB9z_776.js +2 -0
- package/dist/assets/{shortcuts-Cu4ioDvH.js → shortcuts-CDljO5Z0.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DACGW9sB.js → sortable-tabs-strip-D_QG6WdD.js} +1 -1
- package/dist/assets/{speechSettingsQueries-BU-4Axb5.js → speechSettingsQueries-Ccs4XLfn.js} +1 -1
- package/dist/assets/src-Dv9gb-Yy.css +2 -0
- package/dist/assets/{store-DRUKTpV5.js → store-DWS9gJPW.js} +4 -4
- package/dist/assets/summaries-BQMyJaaw.js +1 -0
- package/dist/assets/{switch-DaUn0G3u.js → switch-CYejZ7B8.js} +1 -1
- package/dist/assets/{terminalApi-ClNhXBA8.js → terminalApi-D2ECmoAo.js} +1 -1
- package/dist/assets/{textarea-IhQHekYx.js → textarea-D-k4tYDG.js} +1 -1
- package/dist/assets/{timeFormat-BsuUDWLs.js → timeFormat-CUbYRR40.js} +1 -1
- package/dist/assets/{tooltip-Dw3DApa-.js → tooltip-DxtaOQnv.js} +1 -1
- package/dist/assets/{truncated-path-KHrfQ66P.js → truncated-path-DDDJbtPi.js} +1 -1
- package/dist/assets/types-BXjMc92F.js +2 -0
- package/dist/assets/ui-DLZtbTLJ.js +13 -0
- package/dist/assets/{uk-DU-7fAP4.js → uk-Dw75NtHH.js} +3 -3
- package/dist/assets/useAppFontEffects-DpMTXkXR.js +7 -0
- package/dist/assets/{useAssistantUIStore-CpJZ4Rqs.js → useAssistantUIStore-DEiMjSqf.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-3qd6LXL-.js +1 -0
- package/dist/assets/{useDictation-sdgDfATy.js → useDictation-CUADIj-o.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-DZqC-2HE.js → useEffectiveDirectory-CXt-KLYT.js} +1 -1
- package/dist/assets/{useFontPreferences-Bb-bxdL8.js → useFontPreferences-BY0TXvWI.js} +1 -1
- package/dist/assets/{useGitStore-Bbmai549.js → useGitStore-CAj3309H.js} +1 -1
- package/dist/assets/{useInlineCommentDraftStore-DrC99u6A.js → useInlineCommentDraftStore-DEzJN8u2.js} +1 -1
- package/dist/assets/{useMcpConfigStore-ZsZxSrCt.js → useMcpConfigStore-CCsT0TQj.js} +1 -1
- package/dist/assets/{useMobileSwipeActions-fUp7Bkbn.js → useMobileSwipeActions-BnJa2tLR.js} +1 -1
- package/dist/assets/{useMobileTranscriptSyncHint-B4izCfqe.js → useMobileTranscriptSyncHint-DwBUhnBr.js} +2 -2
- package/dist/assets/{useModelLists-B0qSYDby.js → useModelLists-Bd8KjZ16.js} +1 -1
- package/dist/assets/{useOpenCodeReadiness-B9d-wLZB.js → useOpenCodeReadiness-BodiUrhs.js} +1 -1
- package/dist/assets/{usePluginsStore-BLncdNj-.js → usePluginsStore-BLP01bCp.js} +1 -1
- package/dist/assets/{useProjectGitActions-CHMe1ku4.js → useProjectGitActions-iY0OP_M-.js} +1 -1
- package/dist/assets/{useProjectGitStore-Lz9AV32V.js → useProjectGitStore-aVtBQPmn.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-D51dVo-V.js → useProjectRuntimeAPIs-ACsFy7es.js} +1 -1
- package/dist/assets/{useQuotaStore-mZs9LTwx.js → useQuotaStore-CZU1NU_Z.js} +1 -1
- package/dist/assets/{useSessionBtwStore-CYaTDkvT.js → useSessionBtwStore-DwgrTiCi.js} +2 -2
- package/dist/assets/{useStreamingTextThrottle-ul6e3dUd.js → useStreamingTextThrottle-aFrPa42L.js} +1 -1
- package/dist/assets/{useUIStore-C3ewjGgP.js → useUIStore-P32bzAJc.js} +1 -1
- package/dist/assets/{worktreeManager-V6hoSVxH.js → worktreeManager-B1qB2-Pa.js} +1 -1
- package/dist/assets/{worktreeSourceBranchPreference-MQFPkOZy.js → worktreeSourceBranchPreference-DOyD0AQN.js} +1 -1
- package/dist/assets/{zh-CN-DOHH7nht.js → zh-CN-D5Jwengx.js} +3 -3
- package/dist/assets/{zh-TW-t1qlXGOg.js → zh-TW-CbbaPcxZ.js} +3 -3
- package/dist/index.html +18 -16
- package/dist/mini-chat.html +18 -16
- package/dist/mobile.html +2 -2
- package/package.json +1 -1
- package/server/lib/assistants/builtin-skills.js +1 -1
- package/server/lib/assistants/builtin-skills.test.js +1 -0
- package/server/lib/gui-customization/DOCUMENTATION.md +15 -0
- package/server/lib/gui-customization/session-skill.js +2 -2
- package/server/lib/gui-customization/session-skill.test.js +14 -1
- package/server/lib/gui-customization/skill/SKILL.md +3 -1
- package/server/lib/gui-customization/skill/references/deep-links.md +43 -0
- package/server/lib/gui-customization/skill/references/gui-api.md +50 -1
- package/server/lib/gui-customization/skill/references/projects.md +19 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -0
- package/server/lib/opencode/custom-provider.test.js +41 -0
- package/server/lib/opencode/settings-helpers.js +9 -0
- package/server/lib/opencode/settings-helpers.test.js +10 -0
- package/dist/assets/ArchivedSessionsDialog-CU9RXl8K.js +0 -1
- package/dist/assets/AssistantSessionCard-MYBAni6A.js +0 -2
- package/dist/assets/BinaryFileFallback-CJqnlBzh.js +0 -1
- package/dist/assets/ChatContainer-Dg9uDBjk.js +0 -65
- package/dist/assets/MarkdownRenderer-CsEylQVj.js +0 -2
- package/dist/assets/MobileFilesSurface-qkfC06Oh.js +0 -2
- package/dist/assets/dialog-D9CkSNCA.css +0 -1
- package/dist/assets/gitApiHttp-Bswf6gnl.js +0 -3
- package/dist/assets/host-C7jHgymK.js +0 -1
- package/dist/assets/main-B7wAfq9F.js +0 -2
- package/dist/assets/main-DVmi0I-y.js +0 -169
- package/dist/assets/miniChat-D7-JQ1hw.js +0 -2
- package/dist/assets/mobile-BFQBDlo9.js +0 -2
- package/dist/assets/mobileConnections-PVy2SsQ_.js +0 -2
- package/dist/assets/navigation-C1v9hIAT.js +0 -2
- package/dist/assets/platform-CiUKDeXd.js +0 -1
- package/dist/assets/pwa-Br2HZksc.js +0 -2
- package/dist/assets/queue-abort-optimistic-DciJN9X1.js +0 -1
- package/dist/assets/remoteProjectQueries-BXrXdLjN.js +0 -1
- package/dist/assets/remoteSessionReference-XfJOxItc.js +0 -1
- package/dist/assets/runtime-file-resource-C5kmYlLv.js +0 -6
- package/dist/assets/runtimeEndpointReset-BKLVdNhJ.js +0 -4
- package/dist/assets/sessionLookup-BTQ_AtWh.js +0 -1
- package/dist/assets/sessionOwnership-BPfk1qCS.js +0 -2
- package/dist/assets/src-Dj147H4m.css +0 -2
- package/dist/assets/types-BBBwzIOU.js +0 -2
- package/dist/assets/ui-CHdferA1.js +0 -13
- package/dist/assets/useAppFontEffects-Dw6o6XbA.js +0 -7
- package/dist/assets/useDesktopWindowControlsLayout-DAkTdcAP.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-input-store-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{d as r}from"./platform-CiUKDeXd.js";import{a as i}from"./vendor-zustand-CTekDqaS.js";import{ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{St as s}from"./gitApiHttp-Bswf6gnl.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{Jt as c,R as l,Wt as u,Xt as d,at as f,dr as p,en as m,it as h,n as g,nr as _,on as v,rt as y,tn as b,tr as x}from"./client-ITylDDCS.js";import{n as S}from"./vendor-react-BkccXcWz.js";import{o as C,s as w}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{A as T,E as ee,V as E,k as D,q as O,z as k}from"./runtime-file-resource-C5kmYlLv.js";import{r as te}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as A}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as j}from"./useUIStore-C3ewjGgP.js";import{s as M}from"./spacedFileMention-Ds4GtgiF.js";import{An as N,Ba as P,Bn as F,Fa as ne,Gi as I,Ir as L,Ji as R,Ki as re,Lr as ie,Pr as ae,Rn as oe,Rr as z,Tt as se,U as B,Ua as V,V as ce,Vn as le,W as ue,Yi as de,Yn as H,Yt as fe,_i as pe,_t as me,dn as he,f as U,ft as ge,gi as _e,gt as ve,hi as ye,ht as be,ir as xe,j as Se,kn as Ce,mi as we,mn as W,mt as Te,ni as Ee,no as G,oi as De,pt as Oe,ri as ke,t as K,ta as Ae,ti as je,ur as Me,ut as Ne,vi as q,vr as J,xt as Pe,zn as Fe}from"./ui-CHdferA1.js";import{n as Y}from"./Icon-B-w2YKpn.js";import{i as Ie,m as Le,n as Re}from"./remoteProjectQueries-BXrXdLjN.js";import{t as ze}from"./i18n-Dojvs57M.js";import{t as Be}from"./toolHelpers-iEHVHQ9p.js";import{t as Ve}from"./ScrollableOverlay-CkX-buJm.js";import{t as He}from"./MobileResizableSheet-CF3Pbot4.js";import{a as Ue,i as We,n as Ge,o as Ke,t as qe}from"./dialog-CmjXOKMz.js";import{i as Je,n as Ye,t as Xe}from"./tooltip-Dw3DApa-.js";import{c as Ze,n as Qe,t as $e}from"./dropdown-menu-BT_66BFT.js";import{n as et}from"./useProjectRuntimeAPIs-D51dVo-V.js";import{b as tt,p as nt,t as rt,v as it}from"./gitApi-CBfYFgtd.js";import{o as at,t as ot}from"./useProjectGitStore-Lz9AV32V.js";import{t as st}from"./input-BllFKOjo.js";import{t as ct}from"./useDebouncedValue-BHlMPqY8.js";import{t as lt}from"./checkbox-DaKe0Tlq.js";import{t as ut}from"./MobileOverlayPanel-DcRWQlmf.js";import{t as dt}from"./githubAuthQueries-C5RxUNL2.js";import{a as ft,i as pt,s as mt,t as ht}from"./worktreeManager-V6hoSVxH.js";import{a as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./worktreeSourceBranchPreference-MQFPkOZy.js";import{s as St}from"./remote-input-store-DdjKfpxS.js";import{t as Ct}from"./vendor-cmdk-BDWoZLve.js";import{t as wt}from"./sortable-tabs-strip-DACGW9sB.js";import{f as Tt,m as Et}from"./auto-read-context-Ce0o43YI.js";var Dt=2e3,Ot=i((e,t)=>({pending:!1,expiresAt:null,arm:(t=Dt)=>{let n=Date.now()+t;return e({pending:!0,expiresAt:n}),n},clear:()=>{!t().pending&&t().expiresAt===null||e({pending:!1,expiresAt:null})}})),X=e(o(),1),kt=new class{inFlightByScope=new WeakMap;generationByScope=new WeakMap;run(e){let t=this.inFlightByScope.get(e.scope);t||(t=new Map,this.inFlightByScope.set(e.scope,t));let n=t.get(e.key);if(n)return n;let r=this.generationByScope.get(e.scope);r||(r=new Map,this.generationByScope.set(e.scope,r));let i=(r.get(e.key)??0)+1;r.set(e.key,i);let a=e.request(()=>r?.get(e.key)!==i);return t.set(e.key,a),a.finally(()=>{t?.get(e.key)===a&&t.delete(e.key)}).catch(()=>{}),a}},At=e=>C({queryKey:[e.transport,`sessionChildren`,e.generation,r(e.directory),e.sessionID],queryFn:({signal:t})=>e.request(t),staleTime:0,gcTime:6e4,retry:!1}),jt=e=>O.fetchQuery(At(e)),Mt=(e,t)=>e.id<t.id?-1:+(e.id>t.id),Nt=(e,t,n)=>{let r=new Set(e.map(e=>e.id)),i=t.filter(e=>!e?.id||r.has(e.id)||e.parentID!==n?!1:(r.add(e.id),!0));return i.length===0?e:[...e,...i].sort(Mt)},Pt=30,Ft=new Map;function It(e,t=!1){return{limit:e.loadedTurns,cursor:e.kind===`has-more`?e.cursor:void 0,complete:e.kind===`exhausted`,loading:t}}function Lt(e,t){let n=d();if(!n)return!1;let r=n.getTranscript(v(e,t));return r.messageOrder.length!==0&&r.messageOrder.length>z()}function Rt(e){return!!e.force||!e.hasSession||e.shouldLoadMessages}function zt(e,t,n){let r=[...e.getState().session],i=le.search(r,t,e=>e.id);i.found?r[i.index]=n:r.splice(i.index,0,n),e.setState({session:r})}function Bt(){let e=Pe(),r=B(),i=ce(),a=(0,X.useCallback)((t,n=e)=>`${n}\n${t}`,[e]),o=(0,X.useCallback)((t,n=e)=>{let r=d();if(!r||!t)return It({kind:`unknown`,loadedTurns:0},!1);let i=v(n,t),a=r.getPagination(i),o=r.getRequestState?.(i);return It(a.boundary,o?.status===`loading`)},[e]),s=(0,X.useCallback)((e,t)=>{if(t.length===0)return;let n=i.getChild(e);if(!n)return;let r=n.getState(),a={session_status:{...r.session_status},session_status_observed_at:{...r.session_status_observed_at},session_error_at:{...r.session_error_at},session_diff:{...r.session_diff},todo:{...r.todo},permission:{...r.permission},question:{...r.question}};oe(a,t),Se(n,t),n.setState(a);for(let n of t)m(e,n)},[i]),l=(0,X.useCallback)((t=e)=>{let n=Ft.get(t);if(n)return Ft.delete(t),Ft.set(t,n),n;let r=new Set;for(Ft.set(t,r);Ft.size>Pt;){let e=Ft.keys().next().value;if(!e)break;let t=[...Ft.get(e)??[]];Ft.delete(e),s(e,t)}return r},[e,s]),f=(0,X.useCallback)((t,n=e)=>{let a=n===e?r:i.ensureChild(n,{bootstrap:!1}),o=l(n),c=Fe(a.getState()),u=L(),f=F({seen:o,keep:t,limit:u,preserve:c});if(s(n,f),ie()){let e=new Set([t,...o,...c]),r=(d()?.getCacheBudget?.().listCanonical({directory:n})??[]).map(e=>e.scope.sessionID),i=(r.length>0?r:Array.from(o)).filter(r=>r===t||e.has(r)?!1:Lt(n,r));if(i.length>0){for(let e of i)o.delete(e);s(n,i)}}},[i,e,l,s,r]),h=(0,X.useCallback)(async(t,n)=>{let a=n?.directory??e;if(!t||!a||a===`global`)return;let o=a===e?r:i.ensureChild(a,{bootstrap:!1}),s=o.getState(),l=s.session_status?.[t],u=s.session_status_observed_at?.[t];try{n?.purpose===`prepend`||n?.before?await c(a,t):await b(a,t,{background:!0})}catch{return}if(n?.isStale?.())return;let f=d()?.getTranscript(v(a,t));W({directory:a,sessionID:t,store:o,transcript:f,isStale:n?.isStale}),await J({directory:a,sessionID:t,store:o,statusBeforePull:l,statusObservedAtBeforePull:u,hasMessages:(f?.messageOrder.length??0)>0,isTailPage:!n?.before,isStale:n?.isStale})},[i,r,e]),_=(0,X.useCallback)(async(t,n)=>{await se();let r=typeof n==`boolean`?n:n?.force,o=typeof n==`object`?n.directory??e:e,s=i.ensureChild(o,{bootstrap:!1}),c=g.getScopedSdkClient(o);f(t,o);let l=a(t,o);return kt.run({scope:s,key:l,request:async e=>{let n=s.getState(),i=d(),a=v(o,t),l=i?.hasSession?.(a)??(i?.getTranscript(a).messageOrder.length??0)>0,u=i?.getPagination(a)?.boundary??{kind:`unknown`,loadedTurns:0},f=le.search(n.session,t,e=>e.id).found,m=i?.getRequestState?.(a);if(!r&&l&&u.kind!==`unknown`&&m?.status!==`error`&&f&&ae(o,t)){W({directory:o,sessionID:t,store:s,isStale:e});return}let g=!!(r||!l||f),_=Rt({hasSession:f,shouldLoadMessages:g,force:!!r});await Promise.all([_?(async()=>{try{let n=await re(async()=>c.session.get({sessionID:t}));if(n&&!e()){let r=I(p(n));e()||zt(s,t,r)}}catch(e){console.error(`[sync] failed to fetch session`,t,e)}})():Promise.resolve(),g?h(t,{isStale:e,directory:o}):Promise.resolve()])}})},[i,a,f,h,e]),y=te(async(r,a)=>{let o=a||e;if(!r||!o)return;let s=i.ensureChild(o,{bootstrap:!1}),c=g.getScopedSdkClient(o),l=n(),u=t(),d=()=>l!==n()||u!==t()||i.getChild(o)!==s,f=await jt({transport:u,generation:l,directory:o,sessionID:r,request:async e=>{let i=[],a=new Set,s;do{if(e.throwIfAborted(),l!==n()||u!==t())throw new DOMException(`Session children runtime changed`,`AbortError`);let d=await c.session.list(s?{cursor:s,limit:50}:{directory:o,parentID:r,limit:50},{signal:e});if(!Array.isArray(d?.data))throw Error(`session.list children returned no data`);if(i.push(...d.data.map(p)),d.data.length<50)break;if(s=d.cursor?.next??void 0,!s||a.has(s))throw Error(`session.list children pagination did not advance`);a.add(s)}while(s);return i}}).catch(e=>{if(d())return null;throw e});!f||d()||s.setState(e=>{let t=Nt(e.session,f,r);return t===e.session?e:{session:t,limit:Math.max(e.limit,t.length)}})}),x=(0,X.useCallback)((t,n)=>{let r=o(t,n?.directory??e);return!r.complete&&!!r.cursor},[e,o]),S=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).loading,[e,o]),C=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).complete,[e,o]),w=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-add`,message:t.message,parts:t.parts})},[e]),T=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-remove`,messageID:t.messageID})},[e]),ee=(0,X.useCallback)(t=>{let n=t.directory||e;u(v(n,t.sessionID),{type:`optimistic-confirm`,messageID:t.messageID})},[e]),E=te(async(r,a)=>{if(!r)return;await se();let o=a?.directory??e;if(!o||o===`global`)return;let s=i.ensureChild(o,{bootstrap:!1}),c=n(),l=t(),u=()=>c!==n()||l!==t()||i.ensureChild(o,{bootstrap:!1})!==s,f=s.getState();try{if(await b(o,r),u())return;W({directory:o,sessionID:r,store:s}),await J({directory:o,sessionID:r,store:s,statusBeforePull:f.session_status?.[r],statusObservedAtBeforePull:f.session_status_observed_at?.[r],hasMessages:(d()?.getTranscript(v(o,r)).messageOrder.length??0)>0,isStale:u})}catch{throw Error(`refresh transcript failed`)}});return(0,X.useMemo)(()=>({ensureSessionRenderable:_,syncSession:_,loadChildren:y,hasMore:x,isLoading:S,isComplete:C,refreshSessionTranscript:E,optimistic:{add:w,remove:T,confirm:ee}}),[_,y,x,S,C,E,w,T,ee])}var Z=S(),Q=a(),Vt=(e,t)=>{if(!e)return t;let n=e.ready&&!e.loading;return{modelsReady:!e.error&&(e.modelsReady??n),agentsReady:!e.error&&(e.agentsReady??n)}},Ht=e=>{let t=e?.variants;if(!t)return[];if(Array.isArray(t)){let e=[],n=new Set;for(let r of t){let t=typeof r==`string`?r:r&&typeof r==`object`&&!Array.isArray(r)&&typeof r.id==`string`?r.id:``;!t||n.has(t)||(n.add(t),e.push(t))}return e}return typeof t==`object`?Object.keys(t):[]},Ut=(e,t,n,r)=>{if(e.providerID!==n||e.modelID!==r||t?.variantsReady===!1)return[];if(t?.variants)return[...t.variants];let i=(t?.providers?.find(e=>e.id===n))?.models?.find(e=>e.id===r);return Ht(i)},Wt=()=>!0,Gt=(e,t)=>(e.commandPolicy??Wt)(t),Kt=X.createContext(null),qt=()=>X.useContext(Kt),Jt=e=>e,Yt=(e,t)=>t??e,Xt=e=>{if(e.kind!==`primary`&&(!e.sessionID||!e.directory||!e.draftKey||!e.transportIdentity||!Number.isSafeInteger(e.runtimeGeneration)||!e.resources||typeof e.resources.busy!=`boolean`||!e.activity||!e.commands||!e.shortcuts))throw Error(`chat-input-secondary-surface-incomplete`)},Zt=(e,t)=>e.kind===`secondary`?e.resources?.busy??!1:t,Qt=e=>!e.sessionID||!e.directory?null:{deliveryTarget:e.deliveryTarget,sessionID:e.queueSessionID??e.sessionID,directory:e.directory,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration},$t=(e,t,n)=>{if(e.kind===`secondary`){if(!e.commands)throw Error(`chat-input-secondary-commands-incomplete`);return e.commands}return e.commands?e.commands:{sessionID:e.sessionID,hasMessages:t,hasNewDraft:n}},en={phase:`idle`,isWorking:!1,isBusy:!1,isCooldown:!1},tn=e=>e.hasPendingAssistant?e.messages.some(e=>e.role===`assistant`&&typeof e.time?.completed==`number`):!1;function nn(e,t){let n=(0,Z.c)(6),r=be(e??``,t),i=ve(e??``,t),a=Ne(e??``,t),o=Oe(e??``,t),s=Te(e??``,t),c=me(t),l;bb0:{if(!e){l=en;break bb0}if(o.length>0||s.length>0){l=en;break bb0}let t=r?.type??`idle`,u=a[a.length-1],d=!!(u&&u.role===`assistant`&&typeof u.time?.completed!=`number`),f=a,p;n[0]!==d||n[1]!==f?(p=tn({messages:f,hasPendingAssistant:d}),n[0]=d,n[1]=f,n[2]=p):p=n[2];let m=p,h=u?.time?.created,g=!!(m&&typeof c==`number`&&typeof h==`number`&&h<=c),_=r!==void 0,v=_&&t!==`idle`,y=v||m&&!g;if(_&&!v&&(!m||_&&!v&&typeof i==`number`&&typeof h==`number`&&h<=i)){l=en;break bb0}if(!y){l=en;break bb0}let b=v?t:`busy`,x=t===`busy`||!v&&m,S;n[3]!==b||n[4]!==x?(S={phase:b,isWorking:!0,isBusy:x,isCooldown:!1},n[3]=b,n[4]=x,n[5]=S):S=n[5],l=S}return l}var rn=`data-mobile-overlay-active`,an=e=>Array.from(e).some(e=>e.getAttribute(rn)!==`false`),on=`artful.bionic.cosmic.disco.focal.groovy.jammy.kinetic.lunar.noble.bold.brave.calm.eager.gentle.happy.keen.lively.merry.swift.warm.wise.bright.clever.daring.agile.crisp.fresh.lucid.quick.sharp.vivid.zealous`.split(`.`),sn=`aardvark.beaver.chipmunk.dolphin.falcon.gopher.hedgehog.jackal.koala.lemur.mongoose.narwhal.otter.pangolin.quokka.raccoon.salamander.toucan.walrus.yak.zebra.badger.condor.dingo.egret.ferret.gecko.heron.iguana`.split(`.`);function cn(){return`${on[Math.floor(Math.random()*on.length)]}-${sn[Math.floor(Math.random()*sn.length)]}`}function ln(e){let t=cn();return e&&e.trim()?`${e.trim().replace(/\/+$/,``)}/${t}`:t}async function un(e,t,n){if(!e.hostId||!e.hubId)throw Error(`Remote Project Host scope is unavailable`);let i=V.getState().remoteSession,a=k(),o=await Re();if(a.assertCurrent(),!o.supported||o.hubId!==e.hubId||!o.projects.some(t=>t.id===e.id&&t.hostId===e.hostId&&t.path===e.path))throw Error(`Remote Project is not referenced by the current Hub`);let s=Ie(o);await s.connectHost(e.hostId);let c=s.resolve({hubId:e.hubId,hostId:e.hostId,directory:e.path}),l=k(c),u=xe(c);if(!await u.checkIsGitRepository(e.path))throw Error(`Worktrees can only be created in Git repositories`);let d=await Ee(e,c),p=d.commands,m=Array.isArray(p)?p.filter(e=>typeof e==`string`&&!!e.trim()).map(t=>De(t.trim(),{rootWorktreePath:e.path})).join(` && `):void 0,g=await u.getGitStatus(e.path),_=await u.getGitBranches(e.path),v=await u.listGitWorktrees(e.path),b=r(e.path),x=v.map(e=>r(e.path)).filter(e=>b===e||b.startsWith(`${e}/`)).sort((e,t)=>t.length-e.length)[0],S=x?b.slice(x.length):``,C=(_.branches?.[g.current]?.tracking||g.tracking)?.replace(/^remotes\//,``).split(`/`)[0],w=t.branchName||t.existingBranch?.replace(/^remotes\//,``),T={...t,...m?{startCommand:m}:{},...C&&w?{setUpstream:t.setUpstream??!0,upstreamRemote:t.upstreamRemote||C,upstreamBranch:t.upstreamBranch||w}:{},returnAfterDirectoryCreated:!1},ee=await u.previewGitWorktree(e.path,T);if(!ee.path)throw Error(`Remote worktree preview missing path`);let E=ye();q(E).catch(()=>void 0);let D=S?`${ee.path.replace(/[\\/]+$/,``)}${S}`:ee.path,O={...c.location,directory:D},te={title:n.title,initialPrompt:n.initialPrompt,bootstrapWaitEnabled:d.wait,defaultModel:e.defaultModel??void 0,pendingWorktreeRequestId:E,bootstrapPendingDirectory:D,preserveDirectoryOverride:!0,bootstrapStatus:{status:`pending`,error:null,updatedAt:Date.now()}};try{n.initialPrompt&&await St(O,n.initialPrompt),l.assertCurrent()}catch(e){throw _e(E,e instanceof Error?e:Error(String(e))),e}n.isSelected()&&V.getState().remoteSession===i&&V.getState().openRemoteSession(e,O,null,te);let j=V.getState().remoteSession,M=j?.draft?.pendingWorktreeRequestId===E,N=()=>{if(!n.isSelected()||!M)return!1;let t=V.getState().remoteSession;return t?.sessionId===null&&t.projectId===e.id&&t.location.hubId===e.hubId&&t.location.hostId===e.hostId&&t.draft?.pendingWorktreeRequestId===E?(j=t,!0):t===j};try{let r=await u.createGitWorktree(e.path,T);if(!r.path||!r.name)throw Error(`Remote worktree create missing name/path`);let i=r.bootstrapStatus,a=Date.now()+12e4;for(;i?.status===`pending`&&d.wait;){if(Date.now()>=a)throw Error(`Remote worktree setup timed out; the existing draft was retained`);await new Promise(e=>setTimeout(e,500)),l.assertCurrent(),i=await u.getGitWorktreeBootstrapStatus(r.path)}if(i?.status===`failed`)throw Error(i.error||`Remote worktree setup failed`);l.assertCurrent();let o=S?`${r.path.replace(/[\\/]+$/,``)}${S}`:r.path,p={...c.location,directory:o},m={pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,worktreeMetadata:{name:r.name,path:o,worktreeRoot:r.path,projectDirectory:e.path,relativePath:S.replace(/^\//,``)||void 0,branch:r.branch,label:r.branch||r.name,source:`sdk`,worktreeSource:`created-for-session`,headState:r.branch?`branch`:`unborn`,worktreeStatus:i?.status===`pending`?`pending`:`ready`,createdFromBranch:n.createdFromBranch||g.current||t.startRef,kind:n.kind??`standard`},bootstrapStatus:d.wait?i??{status:`ready`,error:null,updatedAt:Date.now()}:void 0};if(o!==D){let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await A(async()=>{let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await import(`./remote-input-store-DdjKfpxS.js`).then(e=>e.a);return{getRemoteInputStore:e,remoteSessionDraftKey:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25])),n=e(p),r=t(O,null),i=n.getState().getDraft(r),a=await n.getState().moveDraftWithAttachments(r,t(p,null),i?.revision);if(i&&!a)throw Error(`Remote draft changed while the worktree target was being finalized; the original draft was retained`);l.assertCurrent()}!n.createSession&&N()&&j&&(V.getState().updateRemoteDraft(j,m,p),j=V.getState().remoteSession),n.createSession||pe(E,o);let _;if(n.createSession)try{let t=s.resolve(p).service(),r=N()?j?.draft?.title??n.title:n.title,i=await t.createSession({title:r},o);_=i.id,l.assertCurrent();let a=await t.getConfig(o).catch(()=>void 0);l.assertCurrent();let c=e.defaultModel||a?.model,u=typeof c==`string`?c:void 0,d=u?.indexOf(`/`)??-1,m=d>0?u.slice(0,d):h(i),g=d>0?u.slice(d+1):y(i),v=a?.default_agent||i.agent,b=typeof v==`string`?v:void 0,x=Ae.getState();m&&g&&x.saveSessionModelSelection(i.id,m,g,p),b&&x.saveSessionAgentSelection(i.id,b,p),b&&m&&g&&(x.saveAgentModelForSession(i.id,b,m,g,p),x.saveAgentModelVariantForSession(i.id,b,m,g,f(i),p))}catch(t){throw await u.deleteGitWorktree(e.path,{directory:r.path,deleteLocalBranch:!0}).catch(()=>void 0),t}return l.assertCurrent(),n.createSession&&N()&&V.getState().openRemoteSession(e,p,_??null,{...j?.draft,...m}),n.createSession&&pe(E,o),{path:o,branch:r.branch,..._?{id:_}:{}}}catch(e){let t=e instanceof Error?e:Error(String(e));throw N()&&j&&V.getState().updateRemoteDraft(j,{pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,bootstrapStatus:{status:`failed`,error:t.message,updatedAt:Date.now()}}),_e(E,t),e}}var dn=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||e,fn=e=>()=>{let t=P.getState().getActiveProject();return t?.id===e.id&&t?.hostId===e.hostId&&t?.hubId===e.hubId&&t?.path===e.path},pn=e=>({agentName:e.currentAgentName,providerId:e.currentProviderId,modelId:e.currentModelId,variant:e.currentVariant}),mn=(e,t,n)=>{let r=t.agentName?.trim()||void 0,i=t.providerId?.trim()||void 0,a=t.modelId?.trim()||void 0;!r||!i||!a||(n.saveSessionAgentSelection(e,r),n.saveSessionModelSelection(e,i,a),n.saveAgentModelForSession(e,r,i,a),n.saveAgentModelVariantForSession(e,r,i,a,t.variant))},hn=async(e,t)=>{await ke(e)&&await we(t)},gn=e=>{let t=dn(e),n=P.getState().projects;if(n.length===0)return null;let r=n.filter(e=>{if(e.hostId)return!1;let n=dn(e.path);return t===n||t.startsWith(`${n}/`)}).sort((e,t)=>dn(t.path).length-dn(e.path).length)[0];return r?{id:r.id,path:r.path}:null},_n=!1,vn=async(e,t)=>{try{let n=P.getState().projects.find(e=>e.id===t.id)??P.getState().projects.find(e=>dn(e.path)===dn(t.path)),r=R(t.path);await de.getState().activateDirectory(t.path,{source:`worktreeSessionCreator`});let i=de.getState();if(i.activeDirectoryKey!==r||i.providers.length===0||i.agents.length===0)return;i.applyDefaultModelAgentSelection({projectDefaultModel:n?.defaultModel??void 0}),mn(e,pn(de.getState()),Ae.getState())}catch{}},yn=async(e,t,n)=>{let r=U.getState(),i=de.getState();r.initializeNewYuriSession(e,i.agents),r.setSessionDirectory(e,t.path),r.setWorktreeMetadata(e,t),await vn(e,n),s.getState().setDirectory(t.path,{showOverlay:!1})},bn=e=>e.trim().replace(/^remotes\//,``).replace(/[^A-Za-z0-9._/-]+/g,`-`).replace(/\/+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`worktree`,xn=async e=>{if(_n)return null;let t=P.getState().getActiveProject();if(t?.hostId){_n=!0;let n=fn(t);try{let r=e?.existingBranch?.trim().replace(/^remotes\//,``),i=r?bn(r):ln();return(await un(t,{mode:r?`existing`:`new`,worktreeName:i,...r?{existingBranch:r}:{branchName:i}},{...e,isSelected:n})).path}catch(e){return K.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}finally{_n=!1}}let n=e?.projectDirectory?.trim()||t?.path;if(!n)return K.error(`No active project`,{description:`Please select a project first.`}),null;let r=gn(n)??(t?.path?{id:t.id,path:t.path}:null);if(!r)return K.error(`No active project`,{description:`Please select a project first.`}),null;let i=!1;try{i=await rt(r.path)}catch{}if(!i)return K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;_n=!0;try{let t=ye(),n=e?.existingBranch?.trim().replace(/^remotes\//,``)||``,i=n?bn(n):ln(),a=n?`existing`:`new`,o=U.getState();o.newSessionDraft?.open?o.overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:o.newSessionDraft.directoryOverride??r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}):o.openNewSessionDraft({selectedProjectId:r.id,directoryOverride:r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt});let c=await nt(r.path,{mode:a,...a===`new`?{branchName:i,worktreeName:i}:{existingBranch:n,worktreeName:i}}).catch(()=>null);c?.path&&(U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:c.path,pendingWorktreeRequestId:t,bootstrapPendingDirectory:c.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),s.getState().setDirectory(c.path,{showOverlay:!1}));let l=await je(r),u=await _t(r,{preferredName:i,mode:a,worktreeName:i,setupCommands:l,returnAfterDirectoryCreated:!0,...a===`new`?{branchName:i}:{existingBranch:n}});return pe(t,u.path),U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:u.path,pendingWorktreeRequestId:null,bootstrapPendingDirectory:u.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),s.getState().setDirectory(u.path,{showOverlay:!1}),u.path}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree`,n=U.getState().newSessionDraft.pendingWorktreeRequestId;return n&&(_e(n,e instanceof Error?e:Error(t)),U.getState().resolvePendingDraftWorktreeTarget(n,null)),U.getState().setDraftBootstrapPendingDirectory(null),K.error(`Failed to create worktree`,{description:t}),null}finally{_n=!1}};async function Sn(){return xn()}async function Cn(e){let t=e.branch?.trim();return t?xn({existingBranch:t,projectDirectory:e.projectDirectory,initialPrompt:e.initialPrompt,title:e.title}):null}async function wn(e,t,n,r){if(_n)return null;_n=!0;try{let i=P.getState().getActiveProject();if(i?.hostId){let e=fn(i);try{if(!t.trim())throw Error(`Branch name is required`);let a=await un(i,{mode:`new`,branchName:t.trim(),worktreeName:r?.worktreeName||t.trim(),startRef:n?.trim()||`HEAD`,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl},{createSession:!0,isSelected:e,kind:r?.kind,createdFromBranch:r?.createdFromBranch});if(!a.id)throw Error(`Could not create a remote session for the worktree`);return{id:a.id,branch:a.branch,path:a.path}}catch(e){return K.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}}let a=n?.trim()||`HEAD`,o=t?.trim();if(!o)throw Error(`Branch name is required`);let s=r?.kind??`standard`,c=gn(e);if(!c)throw Error(`Project is not registered in Yuri`);let l=!1;try{l=await rt(c.path)}catch{}if(!l)return K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;let u=await je(c),d=await mt(c.path);try{let e=await _t(c,{preferredName:o,mode:`new`,branchName:o,worktreeName:r?.worktreeName||o,startRef:a,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl,setupCommands:u,returnAfterDirectoryCreated:r?.returnAfterDirectoryCreated}),t={...e,createdFromBranch:r?.createdFromBranch||d||a,kind:s};await hn(c,e.worktreeRoot??e.path);let n=await U.getState().createSession(void 0,e.path);if(!n)throw await pt(c,e,{deleteLocalBranch:!0}).catch(()=>void 0),Error(`Could not create a session for the worktree.`);return await yn(n.id,t,c),{id:n.id,branch:e.branch||o,path:e.path}}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree session`;return K.error(`Failed to create worktree`,{description:t}),null}}finally{_n=!1}}function Tn(e){let t=(0,Z.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,style:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a={color:`var(--surface-elevated-foreground)`,...i},t[4]=i,t[5]=a);let o;t[6]===n?o=t[7]:(o=G(`flex h-full w-full flex-col overflow-hidden rounded-xl`,n),t[6]=n,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Q.jsx)(Ct,{"data-slot":`command`,style:a,className:o,...r}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var En=X.forwardRef((e,t)=>{let n=(0,Z.c)(16),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=(a===void 0?`default`:a)===`mobileGlass`?`yuri-mobile-glass-control rounded-full`:`bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,s;n[4]===o?s=n[5]:(s=G(`flex h-8 items-center gap-2 rounded-lg px-3`,o),n[4]=o,n[5]=s);let c;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Y,{name:`search`,className:`size-4 shrink-0 opacity-50`}),n[6]=c):c=n[6];let l;n[7]===r?l=n[8]:(l=G(`placeholder:text-muted-foreground flex h-8 w-full bg-transparent typography-meta outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,r),n[7]=r,n[8]=l);let u;n[9]!==i||n[10]!==t||n[11]!==l?(u=(0,Q.jsx)(Ct.Input,{ref:t,"data-slot":`command-input`,className:l,...i}),n[9]=i,n[10]=t,n[11]=l,n[12]=u):u=n[12];let d;return n[13]!==s||n[14]!==u?(d=(0,Q.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1.5 pb-1`,children:(0,Q.jsxs)(`div`,{"data-slot":`command-input-field`,className:s,children:[c,u]})}),n[13]=s,n[14]=u,n[15]=d):d=n[15],d});En.displayName=`CommandInput`;function Dn(e){let t=(0,Z.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,scrollbarClassName:o,disableHorizontal:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=G(`scroll-py-1 overflow-x-hidden h-full min-h-0`,r),t[6]=r,t[7]=s);let c=o??`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,l=i??!0,u;return t[8]!==n||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Q.jsx)(Ve,{as:Ct.List,"data-slot":`command-list`,outerClassName:`max-h-[min(600px,calc(100vh-10rem))] overflow-x-hidden p-0 w-full h-full min-h-0`,className:s,scrollbarClassName:c,disableHorizontal:l,...a,children:n}),t[8]=n,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function On(e){let t=(0,Z.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Ct.Empty,{"data-slot":`command-empty`,className:`py-6 text-center typography-ui-label`,...n}),t[2]=n,t[3]=r),r}function kn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:typography-meta [&_[cmdk-group-heading]]:font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`bg-border -mx-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Separator,{"data-slot":`command-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`data-[selected=true]:bg-interactive-selection data-[selected=true]:text-interactive-selection-foreground data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 typography-meta outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,Z.c)(27),{branches:n,search:r,local:i,currentBranch:a,branchInfo:o,onCheckout:s}=e,{t:c}=ze(),l;if(t[0]!==n||t[1]!==r){let e=r.trim();l=e?M(n,e,Pn).map(Nn):n,t[0]=n,t[1]=r,t[2]=l}else l=t[2];let u=l,d=i?`gitView.branch.localBranches`:`gitView.branch.remoteBranches`,f;t[3]!==c||t[4]!==d?(f=c(d),t[3]=c,t[4]=d,t[5]=f):f=t[5];let p;if(t[6]!==o||t[7]!==a||t[8]!==u||t[9]!==i||t[10]!==s||t[11]!==c){let e;t[13]!==o||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==c?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>s(e),children:[i?(0,Q.jsxs)(`span`,{className:`flex flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),(o?.[e]?.ahead||o?.[e]?.behind)&&(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[o[e].ahead||0,` ahead ·`,` `,o[e].behind||0,` behind`]})]}):(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),i&&a===e&&(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:c(`gitView.branch.currentBadge`)})]},`${i?`local`:`remote`}-${e}`),t[13]=o,t[14]=a,t[15]=i,t[16]=s,t[17]=c,t[18]=e):e=t[18],p=u.map(e),t[6]=o,t[7]=a,t[8]=u,t[9]=i,t[10]=s,t[11]=c,t[12]=p}else p=t[12];let m;t[19]!==u.length||t[20]!==i||t[21]!==c?(m=u.length===0&&(0,Q.jsx)(jn,{disabled:!0,className:`justify-center`,children:(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(i?`gitView.branch.noLocalBranches`:`gitView.branch.noRemoteBranches`)})}),t[19]=u.length,t[20]=i,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Q.jsxs)(kn,{heading:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Nn(e){return e.item}function Pn(e){return e}function Fn(e){let t=(0,Z.c)(9),{options:n,selectedDirectory:r,onSelect:i}=e,{t:a}=ze(),o;if(t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>i(e.value),children:[(0,Q.jsxs)(`span`,{className:`truncate typography-ui-label text-foreground`,children:[e.pending?`⏳ `:``,e.label]}),r===e.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:a(`gitView.branch.currentBadge`)}):null]},`worktree-${e.value}`),t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else o=t[4];return o}var In=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),Ln=({currentBranch:e,localBranches:t,remoteBranches:n,branchInfo:r,onCheckout:i,onCreate:a,remotes:o=[],disabled:s=!1,iconOnly:c=!1,trigger:l,triggerLabel:u,contentAlign:d,hideTooltip:f=!1,projectRootOption:p=null,worktreeOptions:m=[],selectedDirectory:h=null,onSelectDirectory:g,onCreateWorktree:_,worktreesLabel:v,worktreeNewLabel:y,projectRootLabel:b,onOpenChange:x,open:S,presentation:C=`dropdown`})=>{let{t:w}=ze(),[T,ee]=X.useState(!1),[E,D]=X.useState(``),[O,k]=X.useState(!1),[te,A]=X.useState(!1),[j,N]=X.useState(``),[P,F]=X.useState(!1),ne=X.useRef(null),I=X.useId(),L=S??T,R=e=>{S===void 0&&ee(e),x?.(e)},re=X.useCallback(e=>{e.stopPropagation()},[]),ie=o.length>1,ae=!!(g||_),oe=X.useMemo(()=>In(j),[j]),z=X.useMemo(()=>{let e=E.trim();return e?M(m,e,e=>e.label).map(e=>e.item):m},[E,m]),se=X.useMemo(()=>{if(!p)return!1;let e=E.trim();return!e||M([p],e,e=>[e.label,b??``]).length>0},[b,p,E]),B=t=>{if(t===e){R(!1);return}i(t),R(!1),D(``)},V=e=>{g?.(e),R(!1),D(``)},ce=()=>{k(!0),setTimeout(()=>ne.current?.focus(),50)},le=async()=>{if(!(!oe||P)){if(ie){A(!0);return}F(!0);try{await a(oe,o[0]),N(``),k(!1),R(!1)}finally{F(!1)}}},ue=async e=>{if(!(!oe||P)){F(!0);try{await a(oe,e),N(``),k(!1),A(!1),R(!1)}finally{F(!1)}}},de=()=>{A(!1)},fe=()=>{N(``),k(!1),A(!1)};X.useEffect(()=>{L||(D(``),k(!1),A(!1),N(``))},[L]);let pe=u||e||w(`gitView.branch.detachedHead`),me=d??(c?`end`:`start`),he=v??w(`chat.chatInput.worktrees`),U=y??w(`chat.chatInput.worktreeNew`),ge=b??w(`chat.chatInput.projectRoot`),_e=c?(0,Q.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,disabled:s,"aria-label":pe,children:(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5`})}):(0,Q.jsxs)(H,{variant:`ghost`,size:`xs`,className:`h-6 min-w-0 max-w-full justify-start gap-1 px-0 hover:bg-transparent`,disabled:s,"aria-label":pe,children:[(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate typography-ui-label font-semibold text-left text-foreground`,children:pe}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),ve=(0,Q.jsx)(Ze,{asChild:!0,disabled:s,children:l??_e}),ye=(0,Q.jsxs)(Tn,{className:`h-full min-h-0`,children:[(0,Q.jsx)(`div`,{"data-mobile-sheet-no-dismiss":C===`mobile-sheet`?``:void 0,children:(0,Q.jsx)(En,{placeholder:w(`gitView.branch.searchPlaceholder`),value:E,onValueChange:D,onKeyDown:re})}),(0,Q.jsxs)(Dn,{scrollbarClassName:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,disableHorizontal:!0,children:[(0,Q.jsx)(On,{children:w(`gitView.branch.empty`)}),(0,Q.jsx)(kn,{children:te?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:de,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`arrow-left`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[w(`gitView.branch.pushToPrefix`),` `,(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:oe}),` `,w(`gitView.branch.pushToSuffix`)]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ue(e),disabled:P,className:`flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[P?(0,Q.jsx)(Y,{name:`loader-4`,className:`inline size-3 mr-1.5 animate-spin`}):null,e.name]}),(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground truncate max-w-full`,children:e.pushUrl})]},e.name))})]}):O?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg`,children:[(0,Q.jsx)(`input`,{ref:ne,placeholder:w(`gitView.branch.newBranchPlaceholder`),value:j,onChange:e=>N(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{re(e),e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),fe())},className:`flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`}),(0,Q.jsx)(`button`,{type:`button`,onClick:le,disabled:!oe||P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:P?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`add`,className:`size-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:fe,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`close`,className:`size-4`})})]}):(0,Q.jsxs)(jn,{onSelect:ce,children:[(0,Q.jsx)(Y,{name:`add`,className:`size-4`}),(0,Q.jsx)(`span`,{children:w(`gitView.branch.create`)})]})}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:t,search:E,local:!0,currentBranch:e,branchInfo:r,onCheckout:B}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:n,search:E,onCheckout:B}),ae?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{}),(0,Q.jsxs)(kn,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground typography-meta`,children:he}),_?(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer text-muted-foreground typography-meta hover:text-foreground`,onPointerDown:e=>{e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),R(!1),_()},children:U}):null]}),p&&se?(0,Q.jsxs)(jn,{onSelect:()=>V(p.value),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ge}),(0,Q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:p.label})]}),h===p.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:w(`gitView.branch.currentBadge`)}):null]}):null,(0,Q.jsx)(Fn,{options:z,selectedDirectory:h,onSelect:V})]})]}):null]})]});if(C===`mobile-sheet`){let e=X.cloneElement(l??_e,{onClick:()=>R(!0),"data-popup-open":L?``:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[e,(0,Q.jsx)(He,{id:`mobile-draft-branch-picker-sheet-${I}`,open:L,onOpenChange:R,ariaLabel:w(`gitView.branch.selectBranch`),closeAriaLabel:w(`mobile.surface.closeAria`),resizeAriaLabel:w(`mobile.sessions.sheet.resizeAria`),children:ye})]})}return(0,Q.jsxs)($e,{open:L,onOpenChange:R,children:[f||l?ve:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:ve}),(0,Q.jsx)(Ye,{sideOffset:8,children:c?pe:w(`gitView.branch.currentBranchTooltip`)})]}),(0,Q.jsx)(Qe,{align:me,className:`w-72 p-0 max-h-[60vh] flex flex-col`,children:ye})]})};function Rn(e){let{localBranches:t,remoteBranches:n,query:r}=e,i=r.trim();if(!i)return{matching:[],otherLocal:t,otherRemote:n};let a=M(t,i,e=>e),o=M(n,i,e=>e),s=new Set(a.map(e=>e.item)),c=new Set(o.map(e=>e.item));return{matching:[...a.map(e=>({label:e.item,value:e.item,source:`local`,score:e.score})),...o.map(e=>({label:e.item,value:`remotes/${e.item}`,source:`remote`,score:e.score}))].sort((e,t)=>e.score===t.score?e.source===t.source?e.label.length===t.label.length?e.label.localeCompare(t.label,void 0,{sensitivity:`accent`}):e.label.length-t.label.length:e.source===`local`?-1:1:e.score-t.score).map(({label:e,value:t,source:n})=>({label:e,value:t,source:n})),otherLocal:t.filter(e=>!s.has(e)),otherRemote:n.filter(e=>!c.has(e))}}function zn(e){let t=k(e),n=(e,n={})=>t.json(`/api/github/${e}`,{query:n}),r=e=>e?{owner:e.owner,repo:e.repo}:{};return{authStatus:()=>n(`auth/status`),issuesList:(e,t)=>n(`issues/list`,{directory:e,page:t?.page,query:t?.query}),prsList:(e,t)=>n(`pulls/list`,{directory:e,page:t?.page,query:t?.query}),issueGet:(e,t,i)=>n(`issues/get`,{directory:e,number:t,...r(i?.sourceRepo)}),issueComments:(e,t,i)=>n(`issues/comments`,{directory:e,number:t,...r(i?.sourceRepo)}),prContext:(e,t,i)=>n(`pulls/context`,{directory:e,number:t,...r(i?.sourceRepo),diff:i?.includeDiff?`1`:void 0,checkDetails:i?.includeCheckDetails?`1`:void 0})}}var Bn=e=>({queryKey:[...e.queryScope,`worktree-dialog`,`github-auth`],queryFn:({signal:t})=>k(e).json(`/api/github/auth/status`,{signal:t}),staleTime:3e4,gcTime:1/0});function Vn(e,t){let n=(0,Z.c)(12),r=E(),i=e?void 0:r.github,a;n[0]!==e||n[1]!==i?(a=e?zn(e):i,n[0]=e,n[1]=i,n[2]=a):a=n[2];let o=a,s;n[3]!==e||n[4]!==r?(s=e?Bn(e):dt(r.github),n[3]=e,n[4]=r,n[5]=s):s=n[5];let c;n[6]!==t||n[7]!==s?(c={...s,enabled:t},n[6]=t,n[7]=s,n[8]=c):c=n[8];let l=w(c,O),u;return n[9]!==l||n[10]!==o?(u={github:o,auth:l},n[9]=l,n[10]=o,n[11]=u):u=n[11],u}async function Hn(e,t,n={}){let r=await k(e).json(`/api/magic-prompts`);return(typeof r.overrides?.[t]==`string`?r.overrides[t]:it(t)).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]??``:``)}async function Un(e,t,n,r,i,a){let o=zn(t),s=i.issue,c=i.pr;if(!s&&!c)return;let u=s?`issue`:`pr`,d=s?.number??c.number,f=await Hn(t,`github.${u}.review.visible`,{[`${u}_number`]:String(d)}),p=await Hn(t,`github.${u}.review.instructions`),m;if(s){let e=await o.issueGet(t.location.directory,d,{sourceRepo:s.sourceRepo}),n=await o.issueComments(t.location.directory,d,{sourceRepo:s.sourceRepo});if(e.connected===!1||!e.issue||n.connected===!1)throw Error(a);m=`GitHub issue context (JSON)\n${JSON.stringify({repo:e.repo??null,issue:e.issue,comments:n.comments??[]},null,2)}`}else{let e=await o.prContext(t.location.directory,d,{sourceRepo:c.sourceRepo,includeDiff:i.includeDiff,includeCheckDetails:!1});if(e.connected===!1||!e.pr)throw Error(a);m=`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`}t.sdk();let h=e.resolve({...t.location,directory:n});await Me(e,h).state.send({sessionID:r,messageID:l(`msg`),text:[f,p,m].join(`
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/remote-input-store-CquhCIoR.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-switch-DEPKHgdL.js","assets/runtime-auth-DA-qfGHk.js","assets/platform-CNdx57HN.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-zustand-CTekDqaS.js","assets/vendor-base-ui-wXsskyKm.js","assets/prompt-attachment-upload-D1c308Ba.js","assets/runtime-fetch-V-iMWR8t.js","assets/reasoning-projection-client-BEhVknv9.js","assets/runtime-file-resource-DKJJoOOc.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/vendor-tanstack-react-query-DIb_ItL-.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/input-store-PqhVEhUI.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/uuid-D-SDZijH.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{a as r}from"./vendor-zustand-CTekDqaS.js";import{ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{St as o}from"./gitApiHttp-C8AU1uiY.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{Jt as s,R as c,Wt as l,Xt as u,at as d,dr as f,en as p,it as m,n as h,nr as g,on as _,rt as v,tn as y,tr as b}from"./client-QcYZg8_d.js";import{t as x}from"./pathNormalization-ewtPqJWn.js";import{n as S}from"./vendor-react-BkccXcWz.js";import{o as C,s as w}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{A as T,E as ee,I as E,R as D,W as O,k}from"./runtime-file-resource-DKJJoOOc.js";import{r as te}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as A}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as j}from"./useUIStore-P32bzAJc.js";import{s as M}from"./spacedFileMention-Ds4GtgiF.js";import{An as N,Ba as P,Bn as F,Fa as ne,Gi as I,Ir as L,Ji as R,Ki as re,Lr as ie,Pr as ae,Rn as oe,Rr as z,Tt as se,U as B,Ua as V,V as ce,Vn as le,W as ue,Yi as de,Yn as H,Yt as fe,_i as pe,_t as me,dn as he,f as U,ft as ge,gi as _e,gt as ve,hi as ye,ht as be,ir as xe,j as Se,kn as Ce,mi as we,mn as W,mt as Te,ni as Ee,no as G,oi as De,pt as Oe,ri as ke,t as K,ta as Ae,ti as je,ur as Me,ut as Ne,vi as q,vr as J,xt as Pe,zn as Fe}from"./ui-DLZtbTLJ.js";import{n as Y}from"./Icon-DrO1MlqW.js";import{i as Ie,m as Le,n as Re}from"./remoteProjectQueries-BunVM5PM.js";import{t as ze}from"./i18n-BU8XOKjS.js";import{t as Be}from"./toolHelpers-iEHVHQ9p.js";import{t as Ve}from"./ScrollableOverlay-Cuq3KKRE.js";import{t as He}from"./MobileResizableSheet-D5HcC4ME.js";import{a as Ue,i as We,n as Ge,o as Ke,t as qe}from"./dialog-C67GCo29.js";import{i as Je,n as Ye,t as Xe}from"./tooltip-DxtaOQnv.js";import{c as Ze,n as Qe,t as $e}from"./dropdown-menu-B6hbejyF.js";import{n as et}from"./useProjectRuntimeAPIs-ACsFy7es.js";import{b as tt,p as nt,t as rt,v as it}from"./gitApi-BZ4ZoWbQ.js";import{o as at,t as ot}from"./useProjectGitStore-aVtBQPmn.js";import{t as st}from"./input-B2oH-nQc.js";import{t as ct}from"./useDebouncedValue-BHlMPqY8.js";import{t as lt}from"./checkbox-Cs7zimcx.js";import{t as ut}from"./MobileOverlayPanel-DPgcB7AO.js";import{t as dt}from"./githubAuthQueries-IJPWBo0B.js";import{a as ft,i as pt,s as mt,t as ht}from"./worktreeManager-B1qB2-Pa.js";import{a as gt,i as _t,n as vt,o as yt,r as bt,t as xt}from"./worktreeSourceBranchPreference-DOyD0AQN.js";import{s as St}from"./remote-input-store-CquhCIoR.js";import{t as Ct}from"./vendor-cmdk-BDWoZLve.js";import{t as wt}from"./sortable-tabs-strip-D_QG6WdD.js";import{f as Tt,m as Et}from"./auto-read-context-0SET_04C.js";var Dt=2e3,Ot=r((e,t)=>({pending:!1,expiresAt:null,arm:(t=Dt)=>{let n=Date.now()+t;return e({pending:!0,expiresAt:n}),n},clear:()=>{!t().pending&&t().expiresAt===null||e({pending:!1,expiresAt:null})}})),X=e(a(),1),kt=new class{inFlightByScope=new WeakMap;generationByScope=new WeakMap;run(e){let t=this.inFlightByScope.get(e.scope);t||(t=new Map,this.inFlightByScope.set(e.scope,t));let n=t.get(e.key);if(n)return n;let r=this.generationByScope.get(e.scope);r||(r=new Map,this.generationByScope.set(e.scope,r));let i=(r.get(e.key)??0)+1;r.set(e.key,i);let a=e.request(()=>r?.get(e.key)!==i);return t.set(e.key,a),a.finally(()=>{t?.get(e.key)===a&&t.delete(e.key)}).catch(()=>{}),a}},At=e=>C({queryKey:[e.transport,`sessionChildren`,e.generation,x(e.directory),e.sessionID],queryFn:({signal:t})=>e.request(t),staleTime:0,gcTime:6e4,retry:!1}),jt=e=>O.fetchQuery(At(e)),Mt=(e,t)=>e.id<t.id?-1:+(e.id>t.id),Nt=(e,t,n)=>{let r=new Set(e.map(e=>e.id)),i=t.filter(e=>!e?.id||r.has(e.id)||e.parentID!==n?!1:(r.add(e.id),!0));return i.length===0?e:[...e,...i].sort(Mt)},Pt=30,Ft=new Map;function It(e,t=!1){return{limit:e.loadedTurns,cursor:e.kind===`has-more`?e.cursor:void 0,complete:e.kind===`exhausted`,loading:t}}function Lt(e,t){let n=u();if(!n)return!1;let r=n.getTranscript(_(e,t));return r.messageOrder.length!==0&&r.messageOrder.length>z()}function Rt(e){return!!e.force||!e.hasSession||e.shouldLoadMessages}function zt(e,t,n){let r=[...e.getState().session],i=le.search(r,t,e=>e.id);i.found?r[i.index]=n:r.splice(i.index,0,n),e.setState({session:r})}function Bt(){let e=Pe(),r=B(),i=ce(),a=(0,X.useCallback)((t,n=e)=>`${n}\n${t}`,[e]),o=(0,X.useCallback)((t,n=e)=>{let r=u();if(!r||!t)return It({kind:`unknown`,loadedTurns:0},!1);let i=_(n,t),a=r.getPagination(i),o=r.getRequestState?.(i);return It(a.boundary,o?.status===`loading`)},[e]),c=(0,X.useCallback)((e,t)=>{if(t.length===0)return;let n=i.getChild(e);if(!n)return;let r=n.getState(),a={session_status:{...r.session_status},session_status_observed_at:{...r.session_status_observed_at},session_error_at:{...r.session_error_at},session_diff:{...r.session_diff},todo:{...r.todo},permission:{...r.permission},question:{...r.question}};oe(a,t),Se(n,t),n.setState(a);for(let n of t)p(e,n)},[i]),d=(0,X.useCallback)((t=e)=>{let n=Ft.get(t);if(n)return Ft.delete(t),Ft.set(t,n),n;let r=new Set;for(Ft.set(t,r);Ft.size>Pt;){let e=Ft.keys().next().value;if(!e)break;let t=[...Ft.get(e)??[]];Ft.delete(e),c(e,t)}return r},[e,c]),m=(0,X.useCallback)((t,n=e)=>{let a=n===e?r:i.ensureChild(n,{bootstrap:!1}),o=d(n),s=Fe(a.getState()),l=L(),f=F({seen:o,keep:t,limit:l,preserve:s});if(c(n,f),ie()){let e=new Set([t,...o,...s]),r=(u()?.getCacheBudget?.().listCanonical({directory:n})??[]).map(e=>e.scope.sessionID),i=(r.length>0?r:Array.from(o)).filter(r=>r===t||e.has(r)?!1:Lt(n,r));if(i.length>0){for(let e of i)o.delete(e);c(n,i)}}},[i,e,d,c,r]),g=(0,X.useCallback)(async(t,n)=>{let a=n?.directory??e;if(!t||!a||a===`global`)return;let o=a===e?r:i.ensureChild(a,{bootstrap:!1}),c=o.getState(),l=c.session_status?.[t],d=c.session_status_observed_at?.[t];try{n?.purpose===`prepend`||n?.before?await s(a,t):await y(a,t,{background:!0})}catch{return}if(n?.isStale?.())return;let f=u()?.getTranscript(_(a,t));W({directory:a,sessionID:t,store:o,transcript:f,isStale:n?.isStale}),await J({directory:a,sessionID:t,store:o,statusBeforePull:l,statusObservedAtBeforePull:d,hasMessages:(f?.messageOrder.length??0)>0,isTailPage:!n?.before,isStale:n?.isStale})},[i,r,e]),v=(0,X.useCallback)(async(t,n)=>{await se();let r=typeof n==`boolean`?n:n?.force,o=typeof n==`object`?n.directory??e:e,s=i.ensureChild(o,{bootstrap:!1}),c=h.getScopedSdkClient(o);m(t,o);let l=a(t,o);return kt.run({scope:s,key:l,request:async e=>{let n=s.getState(),i=u(),a=_(o,t),l=i?.hasSession?.(a)??(i?.getTranscript(a).messageOrder.length??0)>0,d=i?.getPagination(a)?.boundary??{kind:`unknown`,loadedTurns:0},p=le.search(n.session,t,e=>e.id).found,m=i?.getRequestState?.(a);if(!r&&l&&d.kind!==`unknown`&&m?.status!==`error`&&p&&ae(o,t)){W({directory:o,sessionID:t,store:s,isStale:e});return}let h=!!(r||!l||p),v=Rt({hasSession:p,shouldLoadMessages:h,force:!!r});await Promise.all([v?(async()=>{try{let n=await re(async()=>c.session.get({sessionID:t}));if(n&&!e()){let r=I(f(n));e()||zt(s,t,r)}}catch(e){console.error(`[sync] failed to fetch session`,t,e)}})():Promise.resolve(),h?g(t,{isStale:e,directory:o}):Promise.resolve()])}})},[i,a,m,g,e]),b=te(async(r,a)=>{let o=a||e;if(!r||!o)return;let s=i.ensureChild(o,{bootstrap:!1}),c=h.getScopedSdkClient(o),l=n(),u=t(),d=()=>l!==n()||u!==t()||i.getChild(o)!==s,p=await jt({transport:u,generation:l,directory:o,sessionID:r,request:async e=>{let i=[],a=new Set,s;do{if(e.throwIfAborted(),l!==n()||u!==t())throw new DOMException(`Session children runtime changed`,`AbortError`);let d=await c.session.list(s?{cursor:s,limit:50}:{directory:o,parentID:r,limit:50},{signal:e});if(!Array.isArray(d?.data))throw Error(`session.list children returned no data`);if(i.push(...d.data.map(f)),d.data.length<50)break;if(s=d.cursor?.next??void 0,!s||a.has(s))throw Error(`session.list children pagination did not advance`);a.add(s)}while(s);return i}}).catch(e=>{if(d())return null;throw e});!p||d()||s.setState(e=>{let t=Nt(e.session,p,r);return t===e.session?e:{session:t,limit:Math.max(e.limit,t.length)}})}),x=(0,X.useCallback)((t,n)=>{let r=o(t,n?.directory??e);return!r.complete&&!!r.cursor},[e,o]),S=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).loading,[e,o]),C=(0,X.useCallback)((t,n)=>o(t,n?.directory??e).complete,[e,o]),w=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-add`,message:t.message,parts:t.parts})},[e]),T=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-remove`,messageID:t.messageID})},[e]),ee=(0,X.useCallback)(t=>{let n=t.directory||e;l(_(n,t.sessionID),{type:`optimistic-confirm`,messageID:t.messageID})},[e]),E=te(async(r,a)=>{if(!r)return;await se();let o=a?.directory??e;if(!o||o===`global`)return;let s=i.ensureChild(o,{bootstrap:!1}),c=n(),l=t(),d=()=>c!==n()||l!==t()||i.ensureChild(o,{bootstrap:!1})!==s,f=s.getState();try{if(await y(o,r),d())return;W({directory:o,sessionID:r,store:s}),await J({directory:o,sessionID:r,store:s,statusBeforePull:f.session_status?.[r],statusObservedAtBeforePull:f.session_status_observed_at?.[r],hasMessages:(u()?.getTranscript(_(o,r)).messageOrder.length??0)>0,isStale:d})}catch{throw Error(`refresh transcript failed`)}});return(0,X.useMemo)(()=>({ensureSessionRenderable:v,syncSession:v,loadChildren:b,hasMore:x,isLoading:S,isComplete:C,refreshSessionTranscript:E,optimistic:{add:w,remove:T,confirm:ee}}),[v,b,x,S,C,E,w,T,ee])}var Z=S(),Q=i(),Vt=(e,t)=>{if(!e)return t;let n=e.ready&&!e.loading;return{modelsReady:!e.error&&(e.modelsReady??n),agentsReady:!e.error&&(e.agentsReady??n)}},Ht=e=>{let t=e?.variants;if(!t)return[];if(Array.isArray(t)){let e=[],n=new Set;for(let r of t){let t=typeof r==`string`?r:r&&typeof r==`object`&&!Array.isArray(r)&&typeof r.id==`string`?r.id:``;!t||n.has(t)||(n.add(t),e.push(t))}return e}return typeof t==`object`?Object.keys(t):[]},Ut=(e,t,n,r)=>{if(e.providerID!==n||e.modelID!==r||t?.variantsReady===!1)return[];if(t?.variants)return[...t.variants];let i=(t?.providers?.find(e=>e.id===n))?.models?.find(e=>e.id===r);return Ht(i)},Wt=()=>!0,Gt=(e,t)=>(e.commandPolicy??Wt)(t),Kt=X.createContext(null),qt=()=>X.useContext(Kt),Jt=e=>e,Yt=(e,t)=>t??e,Xt=e=>{if(e.kind!==`primary`&&(!e.sessionID||!e.directory||!e.draftKey||!e.transportIdentity||!Number.isSafeInteger(e.runtimeGeneration)||!e.resources||typeof e.resources.busy!=`boolean`||!e.activity||!e.commands||!e.shortcuts))throw Error(`chat-input-secondary-surface-incomplete`)},Zt=(e,t)=>e.kind===`secondary`?e.resources?.busy??!1:t,Qt=e=>!e.sessionID||!e.directory?null:{deliveryTarget:e.deliveryTarget,sessionID:e.queueSessionID??e.sessionID,directory:e.directory,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration},$t=(e,t,n)=>{if(e.kind===`secondary`){if(!e.commands)throw Error(`chat-input-secondary-commands-incomplete`);return e.commands}return e.commands?e.commands:{sessionID:e.sessionID,hasMessages:t,hasNewDraft:n}},en={phase:`idle`,isWorking:!1,isBusy:!1,isCooldown:!1},tn=e=>e.hasPendingAssistant?e.messages.some(e=>e.role===`assistant`&&typeof e.time?.completed==`number`):!1;function nn(e,t){let n=(0,Z.c)(6),r=be(e??``,t),i=ve(e??``,t),a=Ne(e??``,t),o=Oe(e??``,t),s=Te(e??``,t),c=me(t),l;bb0:{if(!e){l=en;break bb0}if(o.length>0||s.length>0){l=en;break bb0}let t=r?.type??`idle`,u=a[a.length-1],d=!!(u&&u.role===`assistant`&&typeof u.time?.completed!=`number`),f=a,p;n[0]!==d||n[1]!==f?(p=tn({messages:f,hasPendingAssistant:d}),n[0]=d,n[1]=f,n[2]=p):p=n[2];let m=p,h=u?.time?.created,g=!!(m&&typeof c==`number`&&typeof h==`number`&&h<=c),_=r!==void 0,v=_&&t!==`idle`,y=v||m&&!g;if(_&&!v&&(!m||_&&!v&&typeof i==`number`&&typeof h==`number`&&h<=i)){l=en;break bb0}if(!y){l=en;break bb0}let b=v?t:`busy`,x=t===`busy`||!v&&m,S;n[3]!==b||n[4]!==x?(S={phase:b,isWorking:!0,isBusy:x,isCooldown:!1},n[3]=b,n[4]=x,n[5]=S):S=n[5],l=S}return l}var rn=`data-mobile-overlay-active`,an=e=>Array.from(e).some(e=>e.getAttribute(rn)!==`false`),on=`artful.bionic.cosmic.disco.focal.groovy.jammy.kinetic.lunar.noble.bold.brave.calm.eager.gentle.happy.keen.lively.merry.swift.warm.wise.bright.clever.daring.agile.crisp.fresh.lucid.quick.sharp.vivid.zealous`.split(`.`),sn=`aardvark.beaver.chipmunk.dolphin.falcon.gopher.hedgehog.jackal.koala.lemur.mongoose.narwhal.otter.pangolin.quokka.raccoon.salamander.toucan.walrus.yak.zebra.badger.condor.dingo.egret.ferret.gecko.heron.iguana`.split(`.`);function cn(){return`${on[Math.floor(Math.random()*on.length)]}-${sn[Math.floor(Math.random()*sn.length)]}`}function ln(e){let t=cn();return e&&e.trim()?`${e.trim().replace(/\/+$/,``)}/${t}`:t}async function un(e,t,n){if(!e.hostId||!e.hubId)throw Error(`Remote Project Host scope is unavailable`);let r=V.getState().remoteSession,i=E(),a=await Re();if(i.assertCurrent(),!a.supported||a.hubId!==e.hubId||!a.projects.some(t=>t.id===e.id&&t.hostId===e.hostId&&t.path===e.path))throw Error(`Remote Project is not referenced by the current Hub`);let o=Ie(a);await o.connectHost(e.hostId);let s=o.resolve({hubId:e.hubId,hostId:e.hostId,directory:e.path}),c=E(s),l=xe(s);if(!await l.checkIsGitRepository(e.path))throw Error(`Worktrees can only be created in Git repositories`);let u=await Ee(e,s),f=u.commands,p=Array.isArray(f)?f.filter(e=>typeof e==`string`&&!!e.trim()).map(t=>De(t.trim(),{rootWorktreePath:e.path})).join(` && `):void 0,h=await l.getGitStatus(e.path),g=await l.getGitBranches(e.path),_=await l.listGitWorktrees(e.path),y=x(e.path),b=_.map(e=>x(e.path)).filter(e=>y===e||y.startsWith(`${e}/`)).sort((e,t)=>t.length-e.length)[0],S=b?y.slice(b.length):``,C=(g.branches?.[h.current]?.tracking||h.tracking)?.replace(/^remotes\//,``).split(`/`)[0],w=t.branchName||t.existingBranch?.replace(/^remotes\//,``),T={...t,...p?{startCommand:p}:{},...C&&w?{setUpstream:t.setUpstream??!0,upstreamRemote:t.upstreamRemote||C,upstreamBranch:t.upstreamBranch||w}:{},returnAfterDirectoryCreated:!1},ee=await l.previewGitWorktree(e.path,T);if(!ee.path)throw Error(`Remote worktree preview missing path`);let D=ye();q(D).catch(()=>void 0);let O=S?`${ee.path.replace(/[\\/]+$/,``)}${S}`:ee.path,k={...s.location,directory:O},te={title:n.title,initialPrompt:n.initialPrompt,bootstrapWaitEnabled:u.wait,defaultModel:e.defaultModel??void 0,pendingWorktreeRequestId:D,bootstrapPendingDirectory:O,preserveDirectoryOverride:!0,bootstrapStatus:{status:`pending`,error:null,updatedAt:Date.now()}};try{n.initialPrompt&&await St(k,n.initialPrompt),c.assertCurrent()}catch(e){throw _e(D,e instanceof Error?e:Error(String(e))),e}n.isSelected()&&V.getState().remoteSession===r&&V.getState().openRemoteSession(e,k,null,te);let j=V.getState().remoteSession,M=j?.draft?.pendingWorktreeRequestId===D,N=()=>{if(!n.isSelected()||!M)return!1;let t=V.getState().remoteSession;return t?.sessionId===null&&t.projectId===e.id&&t.location.hubId===e.hubId&&t.location.hostId===e.hostId&&t.draft?.pendingWorktreeRequestId===D?(j=t,!0):t===j};try{let r=await l.createGitWorktree(e.path,T);if(!r.path||!r.name)throw Error(`Remote worktree create missing name/path`);let i=r.bootstrapStatus,a=Date.now()+12e4;for(;i?.status===`pending`&&u.wait;){if(Date.now()>=a)throw Error(`Remote worktree setup timed out; the existing draft was retained`);await new Promise(e=>setTimeout(e,500)),c.assertCurrent(),i=await l.getGitWorktreeBootstrapStatus(r.path)}if(i?.status===`failed`)throw Error(i.error||`Remote worktree setup failed`);c.assertCurrent();let f=S?`${r.path.replace(/[\\/]+$/,``)}${S}`:r.path,p={...s.location,directory:f},g={pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,worktreeMetadata:{name:r.name,path:f,worktreeRoot:r.path,projectDirectory:e.path,relativePath:S.replace(/^\//,``)||void 0,branch:r.branch,label:r.branch||r.name,source:`sdk`,worktreeSource:`created-for-session`,headState:r.branch?`branch`:`unborn`,worktreeStatus:i?.status===`pending`?`pending`:`ready`,createdFromBranch:n.createdFromBranch||h.current||t.startRef,kind:n.kind??`standard`},bootstrapStatus:u.wait?i??{status:`ready`,error:null,updatedAt:Date.now()}:void 0};if(f!==O){let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await A(async()=>{let{getRemoteInputStore:e,remoteSessionDraftKey:t}=await import(`./remote-input-store-CquhCIoR.js`).then(e=>e.a);return{getRemoteInputStore:e,remoteSessionDraftKey:t}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27])),n=e(p),r=t(k,null),i=n.getState().getDraft(r),a=await n.getState().moveDraftWithAttachments(r,t(p,null),i?.revision);if(i&&!a)throw Error(`Remote draft changed while the worktree target was being finalized; the original draft was retained`);c.assertCurrent()}!n.createSession&&N()&&j&&(V.getState().updateRemoteDraft(j,g,p),j=V.getState().remoteSession),n.createSession||pe(D,f);let _;if(n.createSession)try{let t=o.resolve(p).service(),r=N()?j?.draft?.title??n.title:n.title,i=await t.createSession({title:r},f);_=i.id,c.assertCurrent();let a=await t.getConfig(f).catch(()=>void 0);c.assertCurrent();let s=e.defaultModel||a?.model,l=typeof s==`string`?s:void 0,u=l?.indexOf(`/`)??-1,h=u>0?l.slice(0,u):m(i),g=u>0?l.slice(u+1):v(i),y=a?.default_agent||i.agent,b=typeof y==`string`?y:void 0,x=Ae.getState();h&&g&&x.saveSessionModelSelection(i.id,h,g,p),b&&x.saveSessionAgentSelection(i.id,b,p),b&&h&&g&&(x.saveAgentModelForSession(i.id,b,h,g,p),x.saveAgentModelVariantForSession(i.id,b,h,g,d(i),p))}catch(t){throw await l.deleteGitWorktree(e.path,{directory:r.path,deleteLocalBranch:!0}).catch(()=>void 0),t}return c.assertCurrent(),n.createSession&&N()&&V.getState().openRemoteSession(e,p,_??null,{...j?.draft,...g}),n.createSession&&pe(D,f),{path:f,branch:r.branch,..._?{id:_}:{}}}catch(e){let t=e instanceof Error?e:Error(String(e));throw N()&&j&&V.getState().updateRemoteDraft(j,{pendingWorktreeRequestId:null,bootstrapPendingDirectory:null,bootstrapStatus:{status:`failed`,error:t.message,updatedAt:Date.now()}}),_e(D,t),e}}var dn=e=>e.replace(/\\/g,`/`).replace(/\/+$/,``)||e,fn=e=>()=>{let t=P.getState().getActiveProject();return t?.id===e.id&&t?.hostId===e.hostId&&t?.hubId===e.hubId&&t?.path===e.path},pn=e=>({agentName:e.currentAgentName,providerId:e.currentProviderId,modelId:e.currentModelId,variant:e.currentVariant}),mn=(e,t,n)=>{let r=t.agentName?.trim()||void 0,i=t.providerId?.trim()||void 0,a=t.modelId?.trim()||void 0;!r||!i||!a||(n.saveSessionAgentSelection(e,r),n.saveSessionModelSelection(e,i,a),n.saveAgentModelForSession(e,r,i,a),n.saveAgentModelVariantForSession(e,r,i,a,t.variant))},hn=async(e,t)=>{await ke(e)&&await we(t)},gn=e=>{let t=dn(e),n=P.getState().projects;if(n.length===0)return null;let r=n.filter(e=>{if(e.hostId)return!1;let n=dn(e.path);return t===n||t.startsWith(`${n}/`)}).sort((e,t)=>dn(t.path).length-dn(e.path).length)[0];return r?{id:r.id,path:r.path}:null},_n=!1,vn=async(e,t)=>{try{let n=P.getState().projects.find(e=>e.id===t.id)??P.getState().projects.find(e=>dn(e.path)===dn(t.path)),r=R(t.path);await de.getState().activateDirectory(t.path,{source:`worktreeSessionCreator`});let i=de.getState();if(i.activeDirectoryKey!==r||i.providers.length===0||i.agents.length===0)return;i.applyDefaultModelAgentSelection({projectDefaultModel:n?.defaultModel??void 0}),mn(e,pn(de.getState()),Ae.getState())}catch{}},yn=async(e,t,n)=>{let r=U.getState(),i=de.getState();r.initializeNewYuriSession(e,i.agents),r.setSessionDirectory(e,t.path),r.setWorktreeMetadata(e,t),await vn(e,n),o.getState().setDirectory(t.path,{showOverlay:!1})},bn=e=>e.trim().replace(/^remotes\//,``).replace(/[^A-Za-z0-9._/-]+/g,`-`).replace(/\/+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`worktree`,xn=async e=>{if(_n)return null;let t=P.getState().getActiveProject();if(t?.hostId){_n=!0;let n=fn(t);try{let r=e?.existingBranch?.trim().replace(/^remotes\//,``),i=r?bn(r):ln();return(await un(t,{mode:r?`existing`:`new`,worktreeName:i,...r?{existingBranch:r}:{branchName:i}},{...e,isSelected:n})).path}catch(e){return K.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}finally{_n=!1}}let n=e?.projectDirectory?.trim()||t?.path;if(!n)return K.error(`No active project`,{description:`Please select a project first.`}),null;let r=gn(n)??(t?.path?{id:t.id,path:t.path}:null);if(!r)return K.error(`No active project`,{description:`Please select a project first.`}),null;let i=!1;try{i=await rt(r.path)}catch{}if(!i)return K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;_n=!0;try{let t=ye(),n=e?.existingBranch?.trim().replace(/^remotes\//,``)||``,i=n?bn(n):ln(),a=n?`existing`:`new`,s=U.getState();s.newSessionDraft?.open?s.overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:s.newSessionDraft.directoryOverride??r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}):s.openNewSessionDraft({selectedProjectId:r.id,directoryOverride:r.path,pendingWorktreeRequestId:t,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt});let c=await nt(r.path,{mode:a,...a===`new`?{branchName:i,worktreeName:i}:{existingBranch:n,worktreeName:i}}).catch(()=>null);c?.path&&(U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:c.path,pendingWorktreeRequestId:t,bootstrapPendingDirectory:c.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),o.getState().setDirectory(c.path,{showOverlay:!1}));let l=await je(r),u=await _t(r,{preferredName:i,mode:a,worktreeName:i,setupCommands:l,returnAfterDirectoryCreated:!0,...a===`new`?{branchName:i}:{existingBranch:n}});return pe(t,u.path),U.getState().overrideNewSessionDraftTarget({projectId:r.id,directoryOverride:u.path,pendingWorktreeRequestId:null,bootstrapPendingDirectory:u.path,preserveDirectoryOverride:!0,title:e?.title,initialPrompt:e?.initialPrompt}),o.getState().setDirectory(u.path,{showOverlay:!1}),u.path}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree`,n=U.getState().newSessionDraft.pendingWorktreeRequestId;return n&&(_e(n,e instanceof Error?e:Error(t)),U.getState().resolvePendingDraftWorktreeTarget(n,null)),U.getState().setDraftBootstrapPendingDirectory(null),K.error(`Failed to create worktree`,{description:t}),null}finally{_n=!1}};async function Sn(){return xn()}async function Cn(e){let t=e.branch?.trim();return t?xn({existingBranch:t,projectDirectory:e.projectDirectory,initialPrompt:e.initialPrompt,title:e.title}):null}async function wn(e,t,n,r){if(_n)return null;_n=!0;try{let i=P.getState().getActiveProject();if(i?.hostId){let e=fn(i);try{if(!t.trim())throw Error(`Branch name is required`);let a=await un(i,{mode:`new`,branchName:t.trim(),worktreeName:r?.worktreeName||t.trim(),startRef:n?.trim()||`HEAD`,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl},{createSession:!0,isSelected:e,kind:r?.kind,createdFromBranch:r?.createdFromBranch});if(!a.id)throw Error(`Could not create a remote session for the worktree`);return{id:a.id,branch:a.branch,path:a.path}}catch(e){return K.error(`Failed to create worktree`,{description:e instanceof Error?e.message:String(e)}),null}}let a=n?.trim()||`HEAD`,o=t?.trim();if(!o)throw Error(`Branch name is required`);let s=r?.kind??`standard`,c=gn(e);if(!c)throw Error(`Project is not registered in Yuri`);let l=!1;try{l=await rt(c.path)}catch{}if(!l)return K.error(`Not a Git repository`,{description:`Worktrees can only be created in Git repositories.`}),null;let u=await je(c),d=await mt(c.path);try{let e=await _t(c,{preferredName:o,mode:`new`,branchName:o,worktreeName:r?.worktreeName||o,startRef:a,setUpstream:r?.setUpstream,upstreamRemote:r?.upstreamRemote,upstreamBranch:r?.upstreamBranch,ensureRemoteName:r?.ensureRemoteName,ensureRemoteUrl:r?.ensureRemoteUrl,setupCommands:u,returnAfterDirectoryCreated:r?.returnAfterDirectoryCreated}),t={...e,createdFromBranch:r?.createdFromBranch||d||a,kind:s};await hn(c,e.worktreeRoot??e.path);let n=await U.getState().createSession(void 0,e.path);if(!n)throw await pt(c,e,{deleteLocalBranch:!0}).catch(()=>void 0),Error(`Could not create a session for the worktree.`);return await yn(n.id,t,c),{id:n.id,branch:e.branch||o,path:e.path}}catch(e){let t=e instanceof Error?e.message:`Failed to create worktree session`;return K.error(`Failed to create worktree`,{description:t}),null}}finally{_n=!1}}function Tn(e){let t=(0,Z.c)(12),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,style:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===i?a=t[5]:(a={color:`var(--surface-elevated-foreground)`,...i},t[4]=i,t[5]=a);let o;t[6]===n?o=t[7]:(o=G(`flex h-full w-full flex-col overflow-hidden rounded-xl`,n),t[6]=n,t[7]=o);let s;return t[8]!==r||t[9]!==a||t[10]!==o?(s=(0,Q.jsx)(Ct,{"data-slot":`command`,style:a,className:o,...r}),t[8]=r,t[9]=a,t[10]=o,t[11]=s):s=t[11],s}var En=X.forwardRef((e,t)=>{let n=(0,Z.c)(16),r,i,a;n[0]===e?(r=n[1],i=n[2],a=n[3]):({className:r,variant:a,...i}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a);let o=(a===void 0?`default`:a)===`mobileGlass`?`yuri-mobile-glass-control rounded-full`:`bg-[var(--surface-elevated)] ring-1 ring-inset ring-border/60 transition duration-200 ease-out hover:[&:not(:focus-within)]:bg-[var(--surface-subtle)] hover:[&:not(:focus-within)]:ring-transparent focus-within:ring-2 focus-within:ring-[var(--interactive-focus-ring)]`,s;n[4]===o?s=n[5]:(s=G(`flex h-8 items-center gap-2 rounded-lg px-3`,o),n[4]=o,n[5]=s);let c;n[6]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(Y,{name:`search`,className:`size-4 shrink-0 opacity-50`}),n[6]=c):c=n[6];let l;n[7]===r?l=n[8]:(l=G(`placeholder:text-muted-foreground flex h-8 w-full bg-transparent typography-meta outline-none focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50`,r),n[7]=r,n[8]=l);let u;n[9]!==i||n[10]!==t||n[11]!==l?(u=(0,Q.jsx)(Ct.Input,{ref:t,"data-slot":`command-input`,className:l,...i}),n[9]=i,n[10]=t,n[11]=l,n[12]=u):u=n[12];let d;return n[13]!==s||n[14]!==u?(d=(0,Q.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1.5 pb-1`,children:(0,Q.jsxs)(`div`,{"data-slot":`command-input-field`,className:s,children:[c,u]})}),n[13]=s,n[14]=u,n[15]=d):d=n[15],d});En.displayName=`CommandInput`;function Dn(e){let t=(0,Z.c)(14),n,r,i,a,o;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4],o=t[5]):({className:r,children:n,scrollbarClassName:o,disableHorizontal:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a,t[5]=o);let s;t[6]===r?s=t[7]:(s=G(`scroll-py-1 overflow-x-hidden h-full min-h-0`,r),t[6]=r,t[7]=s);let c=o??`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,l=i??!0,u;return t[8]!==n||t[9]!==a||t[10]!==s||t[11]!==c||t[12]!==l?(u=(0,Q.jsx)(Ve,{as:Ct.List,"data-slot":`command-list`,outerClassName:`max-h-[min(600px,calc(100vh-10rem))] overflow-x-hidden p-0 w-full h-full min-h-0`,className:s,scrollbarClassName:c,disableHorizontal:l,...a,children:n}),t[8]=n,t[9]=a,t[10]=s,t[11]=c,t[12]=l,t[13]=u):u=t[13],u}function On(e){let t=(0,Z.c)(4),n;t[0]===e?n=t[1]:({...n}=e,t[0]=e,t[1]=n);let r;return t[2]===n?r=t[3]:(r=(0,Q.jsx)(Ct.Empty,{"data-slot":`command-empty`,className:`py-6 text-center typography-ui-label`,...n}),t[2]=n,t[3]=r),r}function kn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`text-foreground [&_[cmdk-group-heading]]:text-muted-foreground overflow-hidden p-1 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:typography-meta [&_[cmdk-group-heading]]:font-medium`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Group,{"data-slot":`command-group`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function An(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`bg-border -mx-1 h-px`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Separator,{"data-slot":`command-separator`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function jn(e){let t=(0,Z.c)(8),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===n?i=t[4]:(i=G(`data-[selected=true]:bg-interactive-selection data-[selected=true]:text-interactive-selection-foreground data-[highlighted]:bg-interactive-hover hover:bg-interactive-hover [&_svg:not([class*='text-'])]:text-muted-foreground relative flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 typography-meta outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,n),t[3]=n,t[4]=i);let a;return t[5]!==r||t[6]!==i?(a=(0,Q.jsx)(Ct.Item,{"data-slot":`command-item`,className:i,...r}),t[5]=r,t[6]=i,t[7]=a):a=t[7],a}function Mn(e){let t=(0,Z.c)(27),{branches:n,search:r,local:i,currentBranch:a,branchInfo:o,onCheckout:s}=e,{t:c}=ze(),l;if(t[0]!==n||t[1]!==r){let e=r.trim();l=e?M(n,e,Pn).map(Nn):n,t[0]=n,t[1]=r,t[2]=l}else l=t[2];let u=l,d=i?`gitView.branch.localBranches`:`gitView.branch.remoteBranches`,f;t[3]!==c||t[4]!==d?(f=c(d),t[3]=c,t[4]=d,t[5]=f):f=t[5];let p;if(t[6]!==o||t[7]!==a||t[8]!==u||t[9]!==i||t[10]!==s||t[11]!==c){let e;t[13]!==o||t[14]!==a||t[15]!==i||t[16]!==s||t[17]!==c?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>s(e),children:[i?(0,Q.jsxs)(`span`,{className:`flex flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),(o?.[e]?.ahead||o?.[e]?.behind)&&(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[o[e].ahead||0,` ahead ·`,` `,o[e].behind||0,` behind`]})]}):(0,Q.jsx)(`span`,{className:`typography-ui-label text-foreground`,children:e}),i&&a===e&&(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:c(`gitView.branch.currentBadge`)})]},`${i?`local`:`remote`}-${e}`),t[13]=o,t[14]=a,t[15]=i,t[16]=s,t[17]=c,t[18]=e):e=t[18],p=u.map(e),t[6]=o,t[7]=a,t[8]=u,t[9]=i,t[10]=s,t[11]=c,t[12]=p}else p=t[12];let m;t[19]!==u.length||t[20]!==i||t[21]!==c?(m=u.length===0&&(0,Q.jsx)(jn,{disabled:!0,className:`justify-center`,children:(0,Q.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:c(i?`gitView.branch.noLocalBranches`:`gitView.branch.noRemoteBranches`)})}),t[19]=u.length,t[20]=i,t[21]=c,t[22]=m):m=t[22];let h;return t[23]!==f||t[24]!==p||t[25]!==m?(h=(0,Q.jsxs)(kn,{heading:f,children:[p,m]}),t[23]=f,t[24]=p,t[25]=m,t[26]=h):h=t[26],h}function Nn(e){return e.item}function Pn(e){return e}function Fn(e){let t=(0,Z.c)(9),{options:n,selectedDirectory:r,onSelect:i}=e,{t:a}=ze(),o;if(t[0]!==i||t[1]!==n||t[2]!==r||t[3]!==a){let e;t[5]!==i||t[6]!==r||t[7]!==a?(e=e=>(0,Q.jsxs)(jn,{onSelect:()=>i(e.value),children:[(0,Q.jsxs)(`span`,{className:`truncate typography-ui-label text-foreground`,children:[e.pending?`⏳ `:``,e.label]}),r===e.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:a(`gitView.branch.currentBadge`)}):null]},`worktree-${e.value}`),t[5]=i,t[6]=r,t[7]=a,t[8]=e):e=t[8],o=n.map(e),t[0]=i,t[1]=n,t[2]=r,t[3]=a,t[4]=o}else o=t[4];return o}var In=e=>e.trim().replace(/\s+/g,`-`).replace(/[^A-Za-z0-9._/-]/g,`-`).replace(/-+/g,`-`).replace(/\/{2,}/g,`/`).replace(/\/-+/g,`/`).replace(/-+\//g,`/`).replace(/^[-/]+/,``).replace(/[-/]+$/,``),Ln=({currentBranch:e,localBranches:t,remoteBranches:n,branchInfo:r,onCheckout:i,onCreate:a,remotes:o=[],disabled:s=!1,iconOnly:c=!1,trigger:l,triggerLabel:u,contentAlign:d,hideTooltip:f=!1,projectRootOption:p=null,worktreeOptions:m=[],selectedDirectory:h=null,onSelectDirectory:g,onCreateWorktree:_,worktreesLabel:v,worktreeNewLabel:y,projectRootLabel:b,onOpenChange:x,open:S,presentation:C=`dropdown`})=>{let{t:w}=ze(),[T,ee]=X.useState(!1),[E,D]=X.useState(``),[O,k]=X.useState(!1),[te,A]=X.useState(!1),[j,N]=X.useState(``),[P,F]=X.useState(!1),ne=X.useRef(null),I=X.useId(),L=S??T,R=e=>{S===void 0&&ee(e),x?.(e)},re=X.useCallback(e=>{e.stopPropagation()},[]),ie=o.length>1,ae=!!(g||_),oe=X.useMemo(()=>In(j),[j]),z=X.useMemo(()=>{let e=E.trim();return e?M(m,e,e=>e.label).map(e=>e.item):m},[E,m]),se=X.useMemo(()=>{if(!p)return!1;let e=E.trim();return!e||M([p],e,e=>[e.label,b??``]).length>0},[b,p,E]),B=t=>{if(t===e){R(!1);return}i(t),R(!1),D(``)},V=e=>{g?.(e),R(!1),D(``)},ce=()=>{k(!0),setTimeout(()=>ne.current?.focus(),50)},le=async()=>{if(!(!oe||P)){if(ie){A(!0);return}F(!0);try{await a(oe,o[0]),N(``),k(!1),R(!1)}finally{F(!1)}}},ue=async e=>{if(!(!oe||P)){F(!0);try{await a(oe,e),N(``),k(!1),A(!1),R(!1)}finally{F(!1)}}},de=()=>{A(!1)},fe=()=>{N(``),k(!1),A(!1)};X.useEffect(()=>{L||(D(``),k(!1),A(!1),N(``))},[L]);let pe=u||e||w(`gitView.branch.detachedHead`),me=d??(c?`end`:`start`),he=v??w(`chat.chatInput.worktrees`),U=y??w(`chat.chatInput.worktreeNew`),ge=b??w(`chat.chatInput.projectRoot`),_e=c?(0,Q.jsx)(`button`,{type:`button`,className:`flex size-6 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] disabled:cursor-not-allowed disabled:opacity-50`,disabled:s,"aria-label":pe,children:(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5`})}):(0,Q.jsxs)(H,{variant:`ghost`,size:`xs`,className:`h-6 min-w-0 max-w-full justify-start gap-1 px-0 hover:bg-transparent`,disabled:s,"aria-label":pe,children:[(0,Q.jsx)(Y,{name:`git-branch`,className:`size-3.5 text-primary`}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate typography-ui-label font-semibold text-left text-foreground`,children:pe}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`size-3 shrink-0 text-muted-foreground`})]}),ve=(0,Q.jsx)(Ze,{asChild:!0,disabled:s,children:l??_e}),ye=(0,Q.jsxs)(Tn,{className:`h-full min-h-0`,children:[(0,Q.jsx)(`div`,{"data-mobile-sheet-no-dismiss":C===`mobile-sheet`?``:void 0,children:(0,Q.jsx)(En,{placeholder:w(`gitView.branch.searchPlaceholder`),value:E,onValueChange:D,onKeyDown:re})}),(0,Q.jsxs)(Dn,{scrollbarClassName:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`,disableHorizontal:!0,children:[(0,Q.jsx)(On,{children:w(`gitView.branch.empty`)}),(0,Q.jsx)(kn,{children:te?(0,Q.jsxs)(`div`,{className:`px-2 py-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Q.jsx)(`button`,{type:`button`,onClick:de,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`arrow-left`,className:`size-4`})}),(0,Q.jsxs)(`span`,{className:`typography-meta text-muted-foreground`,children:[w(`gitView.branch.pushToPrefix`),` `,(0,Q.jsx)(`span`,{className:`text-foreground font-medium`,children:oe}),` `,w(`gitView.branch.pushToSuffix`)]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:o.map(e=>(0,Q.jsxs)(`button`,{type:`button`,onClick:()=>ue(e),disabled:P,className:`flex flex-col items-start gap-0.5 px-2 py-1.5 rounded-md text-left hover:bg-accent disabled:opacity-50`,children:[(0,Q.jsxs)(`span`,{className:`typography-ui-label text-foreground`,children:[P?(0,Q.jsx)(Y,{name:`loader-4`,className:`inline size-3 mr-1.5 animate-spin`}):null,e.name]}),(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground truncate max-w-full`,children:e.pushUrl})]},e.name))})]}):O?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-lg`,children:[(0,Q.jsx)(`input`,{ref:ne,placeholder:w(`gitView.branch.newBranchPlaceholder`),value:j,onChange:e=>N(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:e=>{re(e),e.key===`Enter`?(e.preventDefault(),le()):e.key===`Escape`&&(e.preventDefault(),fe())},className:`flex-1 min-w-0 bg-transparent typography-meta outline-none placeholder:text-muted-foreground`}),(0,Q.jsx)(`button`,{type:`button`,onClick:le,disabled:!oe||P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:P?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`add`,className:`size-4`})}),(0,Q.jsx)(`button`,{type:`button`,onClick:fe,disabled:P,className:`shrink-0 text-muted-foreground hover:text-foreground disabled:opacity-50`,children:(0,Q.jsx)(Y,{name:`close`,className:`size-4`})})]}):(0,Q.jsxs)(jn,{onSelect:ce,children:[(0,Q.jsx)(Y,{name:`add`,className:`size-4`}),(0,Q.jsx)(`span`,{children:w(`gitView.branch.create`)})]})}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:t,search:E,local:!0,currentBranch:e,branchInfo:r,onCheckout:B}),(0,Q.jsx)(An,{}),(0,Q.jsx)(Mn,{branches:n,search:E,onCheckout:B}),ae?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(An,{}),(0,Q.jsxs)(kn,{children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between px-2 py-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-muted-foreground typography-meta`,children:he}),_?(0,Q.jsx)(`button`,{type:`button`,className:`cursor-pointer text-muted-foreground typography-meta hover:text-foreground`,onPointerDown:e=>{e.stopPropagation()},onClick:e=>{e.preventDefault(),e.stopPropagation(),R(!1),_()},children:U}):null]}),p&&se?(0,Q.jsxs)(jn,{onSelect:()=>V(p.value),children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:ge}),(0,Q.jsx)(`span`,{className:`truncate typography-ui-label text-foreground`,children:p.label})]}),h===p.value?(0,Q.jsx)(`span`,{className:`typography-micro text-primary`,children:w(`gitView.branch.currentBadge`)}):null]}):null,(0,Q.jsx)(Fn,{options:z,selectedDirectory:h,onSelect:V})]})]}):null]})]});if(C===`mobile-sheet`){let e=X.cloneElement(l??_e,{onClick:()=>R(!0),"data-popup-open":L?``:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[e,(0,Q.jsx)(He,{id:`mobile-draft-branch-picker-sheet-${I}`,open:L,onOpenChange:R,ariaLabel:w(`gitView.branch.selectBranch`),closeAriaLabel:w(`mobile.surface.closeAria`),resizeAriaLabel:w(`mobile.sessions.sheet.resizeAria`),children:ye})]})}return(0,Q.jsxs)($e,{open:L,onOpenChange:R,children:[f||l?ve:(0,Q.jsxs)(Xe,{children:[(0,Q.jsx)(Je,{asChild:!0,children:ve}),(0,Q.jsx)(Ye,{sideOffset:8,children:c?pe:w(`gitView.branch.currentBranchTooltip`)})]}),(0,Q.jsx)(Qe,{align:me,className:`w-72 p-0 max-h-[60vh] flex flex-col`,children:ye})]})};function Rn(e){let{localBranches:t,remoteBranches:n,query:r}=e,i=r.trim();if(!i)return{matching:[],otherLocal:t,otherRemote:n};let a=M(t,i,e=>e),o=M(n,i,e=>e),s=new Set(a.map(e=>e.item)),c=new Set(o.map(e=>e.item));return{matching:[...a.map(e=>({label:e.item,value:e.item,source:`local`,score:e.score})),...o.map(e=>({label:e.item,value:`remotes/${e.item}`,source:`remote`,score:e.score}))].sort((e,t)=>e.score===t.score?e.source===t.source?e.label.length===t.label.length?e.label.localeCompare(t.label,void 0,{sensitivity:`accent`}):e.label.length-t.label.length:e.source===`local`?-1:1:e.score-t.score).map(({label:e,value:t,source:n})=>({label:e,value:t,source:n})),otherLocal:t.filter(e=>!s.has(e)),otherRemote:n.filter(e=>!c.has(e))}}function zn(e){let t=E(e),n=(e,n={})=>t.json(`/api/github/${e}`,{query:n}),r=e=>e?{owner:e.owner,repo:e.repo}:{};return{authStatus:()=>n(`auth/status`),issuesList:(e,t)=>n(`issues/list`,{directory:e,page:t?.page,query:t?.query}),prsList:(e,t)=>n(`pulls/list`,{directory:e,page:t?.page,query:t?.query}),issueGet:(e,t,i)=>n(`issues/get`,{directory:e,number:t,...r(i?.sourceRepo)}),issueComments:(e,t,i)=>n(`issues/comments`,{directory:e,number:t,...r(i?.sourceRepo)}),prContext:(e,t,i)=>n(`pulls/context`,{directory:e,number:t,...r(i?.sourceRepo),diff:i?.includeDiff?`1`:void 0,checkDetails:i?.includeCheckDetails?`1`:void 0})}}var Bn=e=>({queryKey:[...e.queryScope,`worktree-dialog`,`github-auth`],queryFn:({signal:t})=>E(e).json(`/api/github/auth/status`,{signal:t}),staleTime:3e4,gcTime:1/0});function Vn(e,t){let n=(0,Z.c)(12),r=D(),i=e?void 0:r.github,a;n[0]!==e||n[1]!==i?(a=e?zn(e):i,n[0]=e,n[1]=i,n[2]=a):a=n[2];let o=a,s;n[3]!==e||n[4]!==r?(s=e?Bn(e):dt(r.github),n[3]=e,n[4]=r,n[5]=s):s=n[5];let c;n[6]!==t||n[7]!==s?(c={...s,enabled:t},n[6]=t,n[7]=s,n[8]=c):c=n[8];let l=w(c,O),u;return n[9]!==l||n[10]!==o?(u={github:o,auth:l},n[9]=l,n[10]=o,n[11]=u):u=n[11],u}async function Hn(e,t,n={}){let r=await E(e).json(`/api/magic-prompts`);return(typeof r.overrides?.[t]==`string`?r.overrides[t]:it(t)).replace(/\{\{\s*([a-zA-Z0-9_]+)\s*\}\}/g,(e,t)=>Object.prototype.hasOwnProperty.call(n,t)?n[t]??``:``)}async function Un(e,t,n,r,i,a){let o=zn(t),s=i.issue,l=i.pr;if(!s&&!l)return;let u=s?`issue`:`pr`,d=s?.number??l.number,f=await Hn(t,`github.${u}.review.visible`,{[`${u}_number`]:String(d)}),p=await Hn(t,`github.${u}.review.instructions`),m;if(s){let e=await o.issueGet(t.location.directory,d,{sourceRepo:s.sourceRepo}),n=await o.issueComments(t.location.directory,d,{sourceRepo:s.sourceRepo});if(e.connected===!1||!e.issue||n.connected===!1)throw Error(a);m=`GitHub issue context (JSON)\n${JSON.stringify({repo:e.repo??null,issue:e.issue,comments:n.comments??[]},null,2)}`}else{let e=await o.prContext(t.location.directory,d,{sourceRepo:l.sourceRepo,includeDiff:i.includeDiff,includeCheckDetails:!1});if(e.connected===!1||!e.pr)throw Error(a);m=`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`}t.sdk();let h=e.resolve({...t.location,directory:n});await Me(e,h).state.send({sessionID:r,messageID:c(`msg`),text:[f,p,m].join(`
|
|
3
3
|
|
|
4
|
-
`)})}function Wn(e){let t=(0,Z.c)(41),{project:n,open:r,onClose:i,children:a}=e,o=ee(),s=n?.hostId&&o&&o.entry.location.hubId===n.hubId&&o.entry.location.hostId===n.hostId&&o.entry.location.directory===n.path,c=Le(!!(r&&n?.hostId&&!s)),{t:l}=ze();if(!n?.hostId){let e;return t[0]===a?e=t[1]:(e=(0,Q.jsx)(T.Provider,{value:null,children:a}),t[0]=a,t[1]=e),e}if(s)return a;if(!r)return null;if(!c.registry||c.registry.hubId!==n.hubId){let e;t[2]===i?e=t[3]:(e=e=>{e||i()},t[2]=i,t[3]=e);let n;t[4]===l?n=t[5]:(n=l(`session.newWorktree.title`),t[4]=l,t[5]=n);let r;t[6]===n?r=t[7]:(r=(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:n})}),t[6]=n,t[7]=r);let a=c.isPending?`status`:`alert`,o;t[8]!==c.error?.message||t[9]!==c.isPending||t[10]!==l?(o=c.isPending?l(`remoteProjects.running`):c.error?.message||l(`remoteProjects.host-unavailable`),t[8]=c.error?.message,t[9]=c.isPending,t[10]=l,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,Q.jsx)(`p`,{role:a,children:o}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let u;t[15]===l?u=t[16]:(u=l(`session.newWorktree.actions.cancel`),t[15]=l,t[16]=u);let d;t[17]!==i||t[18]!==u?(d=(0,Q.jsx)(H,{onClick:i,children:u}),t[17]=i,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==c.isPending||t[21]!==l?(f=c.isPending?null:(0,Q.jsx)(H,{onClick:Gn,children:l(`remoteProjects.retry`)}),t[20]=c.isPending,t[21]=l,t[22]=f):f=t[22];let p;t[23]!==d||t[24]!==f?(p=(0,Q.jsxs)(We,{children:[d,f]}),t[23]=d,t[24]=f,t[25]=p):p=t[25];let m;t[26]!==p||t[27]!==r||t[28]!==s?(m=(0,Q.jsxs)(Ge,{children:[r,s,p]}),t[26]=p,t[27]=r,t[28]=s,t[29]=m):m=t[29];let h;return t[30]!==e||t[31]!==m?(h=(0,Q.jsx)(qe,{open:!0,onOpenChange:e,children:m}),t[30]=e,t[31]=m,t[32]=h):h=t[32],h}let u;t[33]!==n.hostId||t[34]!==n.hubId||t[35]!==n.path?(u={hubId:n.hubId,hostId:n.hostId,directory:n.path},t[33]=n.hostId,t[34]=n.hubId,t[35]=n.path,t[36]=u):u=t[36];let d;return t[37]!==a||t[38]!==c.registry||t[39]!==u?(d=(0,Q.jsx)(D,{registry:c.registry,location:u,children:a}),t[37]=a,t[38]=c.registry,t[39]=u,t[40]=d):d=t[40],d}function Gn(){Re().catch(Kn)}function Kn(){}var qn=(e,t,n)=>{let r=n??t;return r?e.find(e=>e.id===r)??null:null};function Jn(e,t){return`${e}\0${t}`}function Yn(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=P(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(Xn,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Xn({open:e,onOpenChange:t,onSelect:n,projectId:r}){let{t:i}=ze(),a=j(e=>e.isMobile),o=ee(),s=o?.entry.location.hostId?o.entry:void 0,{git:c}=et(),{github:l,auth:u}=Vn(s,e),d=u.data??null,f=u.isFetched,p=j(e=>e.setSettingsDialogOpen),m=j(e=>e.setSettingsPage),h=P(e=>qn(e.projects,e.activeProjectId,r)),g=h?.id??null,_=h?.path??null,v=X.useMemo(()=>_&&g?{id:g,path:_,hostId:h?.hostId,hubId:h?.hubId}:null,[g,_,h?.hostId,h?.hubId]),[y,b]=X.useState(`issues`),[x,S]=X.useState(``),[C,w]=X.useState([]),[T,E]=X.useState([]),[D,O]=X.useState(!1),[k,A]=X.useState(!1),[M,N]=X.useState(null),[F,ne]=X.useState(null),[I,L]=X.useState(null),[R,re]=X.useState(!1),[ie,ae]=X.useState(new Map),[oe,z]=X.useState(1),[se,B]=X.useState(!1),V=X.useRef(0),ce=ct(x,350),le=te(async e=>{if(!(!_||!l)&&!(f&&d?.connected===!1)){O(!0),N(null),z(1),B(!1);try{if(y===`issues`&&l.issuesList){let t=await l.issuesList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(t.issues??[]),z(t.page??1),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=await l.prsList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(t.prs??[]),z(t.page??1),B(!!t.hasMore))}}catch(e){N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}finally{O(!1)}}});X.useEffect(()=>{if(!e||!_||f&&d?.connected===!1||!l)return;if(!ce.trim()){le();return}let t=new AbortController;O(!0),N(null),z(1),B(!1);let n=y===`issues`&&l.issuesList?l.issuesList(_,{page:1,query:ce.trim()}):y===`prs`&&l.prsList?l.prsList(_,{page:1,query:ce.trim()}):null;if(!n){O(!1);return}return n.then(e=>{t.signal.aborted||(`issues`in e?e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(e.issues??[]),z(e.page??1),B(!!e.hasMore)):`prs`in e&&(e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(e.prs??[]),z(e.page??1),B(!!e.hasMore))))}).catch(e=>{t.signal.aborted||N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}).finally(()=>{t.signal.aborted||O(!1)}),()=>t.abort()},[e,_,l,f,d,y,ce,le,i]);let ue=te(async()=>{if(!(!_||!l)&&!(D||k)&&se){A(!0);try{let e=oe+1;if(y===`issues`&&l.issuesList){let t=ce.trim()?await l.issuesList(_,{page:e,query:ce.trim()}):await l.issuesList(_,{page:e});t.connected!==!1&&(w(e=>[...e,...t.issues??[]]),z(t.page??e),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=ce.trim()?await l.prsList(_,{page:e,query:ce.trim()}):await l.prsList(_,{page:e});t.connected!==!1&&(E(e=>[...e,...t.prs??[]]),z(t.page??e),B(!!t.hasMore))}}catch{}finally{A(!1)}}});X.useEffect(()=>{if(!e){b(`issues`),S(``),w([]),E([]),ne(null),L(null),re(!1),N(null),ae(new Map),z(1),B(!1);return}le()},[e,le]),X.useEffect(()=>{V.current+=1,ae(new Map)},[_,v]);let de=te(async e=>{if(!v||!e)return;let t=Jn(v.path,e);if(ie.has(t))return;let n=V.current;try{let r={mode:`new`,branchName:e,worktreeName:e},a=s?await c.validateGitWorktree(v.path,r):await ft(v,r);if(n!==V.current)return;let o=a.errors.find(e=>e.code===`branch_in_use`);ae(e=>new Map(e).set(t,{isValid:!o,error:o?i(o.code===`branch_exists`?`session.githubIntegration.validation.branchAlreadyExists`:`session.githubIntegration.validation.branchAlreadyCheckedOut`):null}))}catch{if(n!==V.current)return;ae(e=>new Map(e).set(t,{isValid:!1,error:i(`session.githubIntegration.validation.failed`)}))}});X.useEffect(()=>{!e||y!==`prs`||T.forEach(e=>{e.head&&de(e.head)})},[e,y,T,_,v,de]);let fe=f&&d?.connected===!0,pe=()=>{if(s){K.info(i(`remoteProjects.configurationReadOnly`));return}m(`github`),p(!0)},me=e=>{ne(e),L(null)},he=e=>{L(e),ne(null)},U=()=>{F?n({type:`issue`,item:F}):I&&n({type:`pr`,item:I,includeDiff:R}),t(!1)},ge=()=>{ne(null),L(null),re(!1)},_e=F||(I?.head&&_?ie.get(Jn(_,I.head))?.isValid!==!1:!1),ve=e=>!e.head||(_?ie.get(Jn(_,e.head)):void 0)?.isValid===!1,ye=(0,Q.jsxs)(Q.Fragment,{children:[s&&u.error?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-small text-destructive`,children:[u.error.message,(0,Q.jsx)(H,{variant:`ghost`,size:`xs`,onClick:()=>{u.refetch()},children:i(`remoteProjects.retry`)})]}):null,fe?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,Q.jsx)(Y,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(st,{value:x,onChange:e=>S(e.target.value),placeholder:i(y===`issues`?`session.githubIntegration.search.issuesPlaceholder`:`session.githubIntegration.search.prsPlaceholder`),className:`h-8 pl-9`})]}),(0,Q.jsx)(`div`,{className:`yuri-picker-list mt-2 h-[300px] overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[D&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-5 w-5 animate-spin text-muted-foreground`})}),M&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive`,children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-small`,children:M})]})}),!D&&!M&&y===`issues`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[C.length>0?C.map(e=>(0,Q.jsx)(`button`,{onClick:()=>me(e),className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,F?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-2`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noIssuesFound`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]}),!D&&!M&&y===`prs`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[T.length>0?T.map(e=>{let t=ve(e),n=e.head&&_?ie.get(Jn(_,e.head)):void 0;return(0,Q.jsx)(`button`,{onClick:()=>!t&&he(e),disabled:t,className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,I?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:t?`opacity-50 cursor-not-allowed`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-1`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[e.head,` → `,e.base]}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null,t&&n?.error&&(0,Q.jsx)(`span`,{className:`typography-micro text-destructive`,children:n.error})]})]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noPullRequestsFound`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 gap-4`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-12 w-12 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:i(`session.githubIntegration.connect.title`)}),(0,Q.jsx)(`p`,{className:`typography-small text-muted-foreground mt-1`,children:i(`session.githubIntegration.connect.description`)})]}),(0,Q.jsx)(H,{onClick:pe,size:`sm`,children:i(`session.githubIntegration.connect.action`)})]})]}),be=(0,Q.jsxs)(`div`,{className:G(`w-full`,a?`flex flex-col gap-2`:`flex flex-row items-center`),children:[(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-4`,a?`w-full justify-center order-1`:`flex-1`),children:[!a&&(F||I)&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate max-w-[150px]`,children:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y===`prs`&&I&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer h-8`,children:[(0,Q.jsx)(lt,{checked:R,onChange:e=>re(e),ariaLabel:i(`session.githubIntegration.includeDiffAria`)}),(0,Q.jsx)(`span`,{className:`typography-small text-foreground`,children:i(`session.githubIntegration.includeDiff`)})]})]}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,a?`w-full order-2`:`justify-end`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.cancel`)}),(0,Q.jsx)(H,{size:`sm`,onClick:U,disabled:!_e,className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.select`)})]})]});return(0,Q.jsx)(Q.Fragment,{children:a?(0,Q.jsx)(ut,{open:e,title:i(`session.githubIntegration.title`),onClose:()=>t(!1),footer:fe?be:void 0,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 border-b border-border/40`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:i(`session.githubIntegration.title`)}),e]}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})}),(F||I)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate flex-1`,children:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),children:ye}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{presentation:`picker`,children:[(0,Q.jsx)(Ue,{className:`yuri-picker-header`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Q.jsx)(Ke,{className:`yuri-picker-title`,children:i(`session.githubIntegration.title`)}),(0,Q.jsx)(`div`,{className:`w-[220px]`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})})]})}),ye,(0,Q.jsx)(We,{className:`yuri-picker-footer`,children:be})]})})})}var Zn=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``),$=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``).split(`/`).join(`-`).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80),Qn=e=>String(e||``).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`pr-head`,$n=(e,t,n)=>{let r=Zn(e.head||``);if(!r)throw Error(`PR head branch is missing`);if(t.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};let i=n.find(e=>{let t=e.indexOf(`/`);return t<=0||t>=e.length-1?!1:e.slice(t+1)===r});if(i){let e=i.indexOf(`/`),t=i.slice(0,e);return{existingBranch:`remotes/${i}`,setUpstream:!0,upstreamRemote:t,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${t}/${r}`}}let a=String(e.headLabel||``).split(`:`)[0]?.trim(),o=`pr-${Qn(e.headRepo?.owner||a||`pr-head`)}`,s=e.headRepo?.sshUrl||e.headRepo?.cloneUrl||``;if(!s)throw Error(`PR head repository URL is unavailable`);return{existingBranch:`remotes/${o}/${r}`,setUpstream:!0,upstreamRemote:o,upstreamBranch:r,ensureRemoteName:o,ensureRemoteUrl:s,sourceLabel:`${o}/${r}`}},er=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`},tr=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function nr(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=P(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(rr,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function rr({open:e,onOpenChange:t,onWorktreeCreated:n,projectId:r}){let{t:i}=ze(),{git:a}=et(),o=ee(),s=o?.entry.location.hostId?o.entry:void 0,{github:c,auth:l}=Vn(s,e),u=j(e=>e.isMobile),d=X.useId(),f=l.data??null,p=l.isFetched,m=P(e=>qn(e.projects,e.activeProjectId,r)),h=m?.path??null,g=X.useMemo(()=>h&&m?{id:m.id,path:h,hostId:m.hostId,hubId:m.hubId}:null,[m,h]),[_,v]=X.useState(`new-branch`),[y,b]=X.useState({branchName:``,worktreeName:``,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,S]=X.useState({selectedBranch:``,worktreeName:``}),C=ot(h),T=at(e=>h?e.directories.get(h)?.isLoadingBranches??!1:!1),E=at(e=>e.fetchBranches),D=X.useMemo(()=>C?.all?C.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[C]),k=X.useMemo(()=>C?.all?C.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[C]),te=U(e=>e.availableWorktreesByProject),A=w({queryKey:[...s?.queryScope??[`local`],`worktree-dialog`,`worktrees`],enabled:!!(s&&e&&h),queryFn:()=>a.listGitWorktrees(h),staleTime:3e4,gcTime:1/0},O),M=X.useMemo(()=>{if(!h)return new Set;let e=s?A.data??[]:te.get(h)??[];return new Set(e.map(e=>e.name))},[te,h,s,A.data]),N=X.useCallback((e=10)=>{for(let t=0;t<e;t++){let e=cn();if(!M.has(e))return e}return`${cn()}-${Date.now().toString(36).slice(-4)}`},[M]),[F,I]=X.useState(!1),[L,R]=X.useState(!1),[re,ie]=X.useState(!1),[ae,oe]=X.useState(!1),[z,se]=X.useState(!1),[B,ce]=X.useState(``),[le,ue]=X.useState(``),pe=X.useRef(null),me=X.useRef(null),ge=X.useRef(null),_e=X.useRef(null),ve=X.useCallback(e=>{e.stopPropagation()},[]),ye=X.useCallback(e=>{let t=e;for(;t&&t!==document.body;){let{overflowY:e}=window.getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null},[]),be=X.useCallback(e=>{e&&(e.scrollTop=0)},[]),xe=X.useCallback(e=>{let t=e.current?.querySelector(`[data-slot="command-list"]`)??null;be(t)},[be]),Se=X.useCallback(e=>{let t=ye(e.current);be(t)},[ye,be]),Ce=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:B}),[D,k,B]),W=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:le}),[D,k,le]),Te=B.trim().length>0,Ee=le.trim().length>0,De=Ce.matching.length>0,Oe=W.matching.length>0,Me=!!(h&&a),Ne=X.useCallback(()=>{!h||!a||E(h,a)},[h,a,E]);X.useEffect(()=>{!e||!h||!a||C?.all||E(h,a)},[e,h,a,C?.all,E]),X.useEffect(()=>{!L&&!ae&&ce(``)},[L,ae]),X.useEffect(()=>{!re&&!z&&ue(``)},[re,z]),X.useEffect(()=>{L&&xe(pe),ae&&Se(ge)},[L,ae,B,xe,Se]),X.useEffect(()=>{re&&xe(me),z&&Se(_e)},[re,z,le,xe,Se]);let[q,J]=X.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Pe,Fe]=X.useState(!1),[Ie,Le]=X.useState(null),Re=X.useCallback(()=>{let e=de.getState(),t=e.getVisibleAgents();if(e.settingsDefaultAgent){let n=t.find(t=>t.name===e.settingsDefaultAgent);if(n)return n.name}return t.find(e=>e.name===`build`)?.name||t[0]?.name},[]),Be=X.useCallback(()=>{let e=de.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=ne(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),Je=X.useCallback((e,t)=>{let n=de.getState(),r=ne(n.settingsDefaultModel??n.opencodeDefaultModel),i=r?.providerId===e&&r.modelId===t?r.variant??n.settingsDefaultVariant:void 0,a=n.currentProviderId===e&&n.currentModelId===t?n.currentVariant:void 0;return i??a},[]),Ye=X.useCallback(async e=>{if(!h||!c)return;let t=de.getState(),n=Ae.getState().lastUsedProvider,r=Be(),a=r?.providerID||t.currentProviderId||n?.providerID,o=r?.modelID||t.currentModelId||n?.modelID,s=Re()||t.currentAgentName||void 0;if(!a||!o){K.error(i(`session.newWorktree.error.noModelSelected`));return}let l=Je(a,o);if(e.issue){if(!c.issueGet||!c.issueComments)return;let t=await c.issueGet(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(t.connected===!1||!t.repo||!t.issue)throw Error(`Failed to load issue context`);let n=await c.issueComments(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(n.connected===!1)throw Error(`Failed to load issue comments`);let r=await tt(`github.issue.review.visible`,{issue_number:String(e.issue.number)}),u=await tt(`github.issue.review.instructions`),d=er({repo:t.repo,issue:t.issue,comments:n.comments??[]});await U.getState().sendMessage(r,a,o,s,void 0,void 0,[{text:u,synthetic:!0},{text:d,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.success(i(`session.newWorktree.toast.sessionFromIssue`));return}if(e.pr){if(!c.prContext)return;let t=await c.prContext(h,e.pr.number,{sourceRepo:e.pr.sourceRepo??null,includeDiff:e.includeDiff,includeCheckDetails:!1});if(t.connected===!1||!t.repo||!t.pr)throw Error(`Failed to load PR context`);let n=await tt(`github.pr.review.visible`,{pr_number:String(e.pr.number)}),r=await tt(`github.pr.review.instructions`),u=tr(t);await U.getState().sendMessage(n,a,o,s,void 0,void 0,[{text:r,synthetic:!0},{text:u,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.success(i(`session.newWorktree.toast.sessionFromPr`))}},[c,h,Re,Be,Je,i]),Xe=_===`new-branch`?y:x;X.useEffect(()=>{if(!e||!C?.all||!h||y.sourceBranch)return;let t=y.sourceBranch,n=!1;return(async()=>{try{let e=s?(await a.getGitStatus(h)).current:await mt(h).catch(()=>null);if(n)return;let r=localStorage.getItem(xt),{sourceBranch:i,shouldClearSavedSourceBranch:o}=vt({branches:C.all,savedSourceBranch:r,rootBranch:e});if(o&&localStorage.removeItem(xt),n||t)return;i&&b(e=>({...e,sourceBranch:i}))}catch{}})(),()=>{n=!0}},[e,C?.all,h,y.sourceBranch,s,a]),X.useLayoutEffect(()=>{if(!e)return;v(`new-branch`),S({selectedBranch:``,worktreeName:``}),R(!1),ie(!1),oe(!1),se(!1),ce(``),ue(``),J({isValidating:!1,branchError:null,worktreeError:null,touched:!1});let t=N();b({branchName:t,worktreeName:t,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1})},[e,N]),X.useEffect(()=>{if(_!==`new-branch`||!y.isSyncingWorktreeName)return;let e=$(Zn(y.branchName));b(t=>({...t,worktreeName:e}))},[_,y.branchName,y.isSyncingWorktreeName]);let nt=X.useCallback(async()=>{if(!g||!q.touched||Pe)return;Ie&&Ie.abort();let e=new AbortController;Le(e),J(e=>({...e,isValidating:!0}));try{let t=_===`new-branch`?y.branchName:x.selectedBranch,n=Xe.worktreeName,r=Zn(t),o=$(n),c=null,l=null;if(r||(c=i(`session.newWorktree.error.branchNameRequired`)),o||(l=i(`session.newWorktree.error.worktreeDirectoryRequired`)),r&&o){let t=_===`new-branch`?y.linkedPr:null,n=t?$n(t,D,k):null,i={mode:_===`existing-branch`||n?`existing`:`new`,branchName:r,worktreeName:o,existingBranch:n?.existingBranch??(_===`existing-branch`?r:void 0),...n?.ensureRemoteName?{ensureRemoteName:n.ensureRemoteName}:{},...n?.ensureRemoteUrl?{ensureRemoteUrl:n.ensureRemoteUrl}:{}},u=s?await a.validateGitWorktree(h,i):await ft(g,i);if(e.signal.aborted)return;u.ok||u.errors.forEach(e=>{if(e.code===`worktree_exists`){l??=e.message;return}e.code.startsWith(`branch_`)&&(c??=e.message)})}e.signal.aborted||J(e=>({...e,isValidating:!1,branchError:c,worktreeError:l}))}catch{e.signal.aborted||J(e=>({...e,isValidating:!1}))}},[s,a,h,g,_,y.branchName,y.linkedPr,x.selectedBranch,Xe.worktreeName,D,k,q.touched,Ie,Pe,i]),rt=_===`new-branch`?y.branchName:x.selectedBranch;X.useEffect(()=>{if(!e||!g||!q.touched||Pe)return;let t=setTimeout(()=>{nt()},300);return()=>clearTimeout(t)},[Xe.worktreeName,rt,e,g,nt,q.touched,Pe]);let it=async()=>{if(!g||!h){K.error(i(`session.newWorktree.error.noActiveProject`));return}J(e=>({...e,touched:!0}));let e=_===`new-branch`?y.branchName:x.selectedBranch,r=Xe.worktreeName,a=Zn(e),c=$(r);if(!a){K.error(i(`session.newWorktree.error.branchNameRequired`));return}if(!c){K.error(i(`session.newWorktree.error.worktreeDirectoryRequired`));return}Ie&&(Ie.abort(),Le(null)),J(e=>({...e,isValidating:!1,branchError:null,worktreeError:null})),Fe(!0);try{let e=_===`new-branch`?y.linkedPr:null,r=_===`new-branch`?y.linkedIssue:null,l=_===`new-branch`?y.linkedPr:null,u=_===`new-branch`&&y.includePrDiff,d=!!(r||l);if(s&&o&&m?.hostId){let l=m;P.getState().setActiveProjectIdOnly(l.id);let f=e?$n(e,D,k):null,p=r?`#${r.number} ${r.title}`.trim():e?`#${e.number} ${e.title}`.trim():void 0,h=await un(l,{mode:f||_===`existing-branch`?`existing`:`new`,worktreeName:c,branchName:_===`new-branch`?a:void 0,existingBranch:f?.existingBranch??(_===`existing-branch`?a:void 0),..._===`new-branch`&&!f&&y.sourceBranch?{startRef:y.sourceBranch}:{},...f?{setUpstream:f.setUpstream,upstreamRemote:f.upstreamRemote,upstreamBranch:f.upstreamBranch,...f.ensureRemoteName?{ensureRemoteName:f.ensureRemoteName}:{},...f.ensureRemoteUrl?{ensureRemoteUrl:f.ensureRemoteUrl}:{}}:{}},{title:p,createSession:d,kind:e?`pr`:`standard`,createdFromBranch:f?.sourceLabel??y.sourceBranch,isSelected:()=>P.getState().activeProjectId===l.id});s.sdk();let g=V.getState().remoteSession;g?.projectId===l.id&&g.location.hubId===s.location.hubId&&g.location.hostId===s.location.hostId&&g.location.directory===h.path&&g.sessionId===(h.id??null)&&n?.(h.path,{...h.id?{sessionId:h.id}:{},remote:!0}),t(!1),K.success(i(`session.newWorktree.toast.worktreeCreated`)),h.id&&d&&Un(o.registry,s,h.path,h.id,{issue:r,pr:e,includeDiff:u},i(`session.newWorktree.error.sendGitHubContextFailed`)).catch(e=>{K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:e instanceof Error?e.message:String(e)})});return}let[f,p]=await Promise.all([je(g),gt(h)]),v=y.sourceBranch,b=``,S=(()=>{if(e){let t=$n(e,D,k);return b=t.sourceLabel,{preferredName:a||c,mode:`existing`,branchName:a,worktreeName:c,existingBranch:t.existingBranch,setupCommands:f,setUpstream:t.setUpstream,upstreamRemote:t.upstreamRemote,upstreamBranch:t.upstreamBranch,returnAfterDirectoryCreated:!0,...t.ensureRemoteName?{ensureRemoteName:t.ensureRemoteName}:{},...t.ensureRemoteUrl?{ensureRemoteUrl:t.ensureRemoteUrl}:{}}}return b=_===`new-branch`?v:``,{preferredName:a||c,mode:_===`existing-branch`?`existing`:`new`,branchName:_===`existing-branch`?void 0:a,worktreeName:c,existingBranch:_===`existing-branch`?a:void 0,setupCommands:f,returnAfterDirectoryCreated:!0,...v&&_===`new-branch`?{startRef:v}:{}}})(),C=await yt(h,S,{resolvedRootTrackingRemote:p}),w=await ht(g,C),T=null;if(d){await ke(g)&&await we(w.worktreeRoot??w.path);let e=r?`#${r.number} ${r.title}`.trim():l?`#${l.number} ${l.title}`.trim():i(`session.newWorktree.newSessionTitle`),a=await fe(e,w.path,null);if(!a?.id)throw Error(`Failed to create session`);T=a.id,n?.(w.path,{sessionId:T}),t(!1),Fe(!1),he(a.id,e).catch(()=>void 0);try{U.getState().initializeNewYuriSession(a.id,de.getState().agents)}catch{}}else t(!1),Fe(!1);let ee=bt({mode:_,sourceBranch:y.sourceBranch,linkedPr:!!y.linkedPr,selectedBranch:x.selectedBranch});ee&&localStorage.setItem(xt,ee),K.success(i(`session.newWorktree.toast.worktreeCreated`),{description:i(`session.newWorktree.toast.worktreeCreatedDescription`,{target:`${w.branch||w.name}${b?` ${i(`session.newWorktree.fromSource`,{source:b})}`:``}`})}),T?Ye({sessionId:T,directory:w.path,issue:r,pr:l,includeDiff:u}).catch(e=>{let t=e instanceof Error?e.message:i(`session.newWorktree.error.sendGitHubContextFailed`);K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:t})}):n?.(w.path)}catch(e){let t=e instanceof Error?e.message:i(`session.newWorktree.error.createWorktreeFailed`);K.error(i(`session.newWorktree.error.createWorktreeFailed`),{description:t})}finally{Fe(!1)}},ct=e=>{v(e),J(e=>({...e,touched:!1,branchError:null,worktreeError:null}))},lt=e=>{if(!e){b(e=>({...e,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:``}));return}if(e.type===`issue`){let t=e.item,n=`issue-${t.number}-${cn()}`;b(e=>({...e,linkedIssue:t,linkedPr:null,includePrDiff:!1,branchName:n,worktreeName:$(n),isSyncingWorktreeName:!0}))}else if(e.type===`pr`){let t=e.item;b(n=>({...n,linkedPr:t,linkedIssue:null,includePrDiff:e.includeDiff??!1,branchName:t.head,worktreeName:$(t.head),isSyncingWorktreeName:!0}))}},dt=p&&f?.connected===!0,pt=(_===`existing-branch`?!!x.selectedBranch&&!!x.worktreeName&&!q.branchError&&!q.worktreeError:!!Zn(y.branchName)&&!!y.worktreeName&&!q.branchError&&!q.worktreeError)&&!Pe,_t=()=>{b(e=>({...e,linkedIssue:null,linkedPr:null,branchName:``,includePrDiff:!1,isSyncingWorktreeName:!0}))},St=s&&(A.error||l.error)?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-micro text-destructive`,children:[(A.error||l.error)?.message,(0,Q.jsx)(H,{size:`xs`,variant:`ghost`,onClick:()=>{A.refetch(),l.refetch()},children:i(`remoteProjects.retry`)})]}):null,Ct=(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u?`flex-col w-full`:`flex-row items-center`),children:[St,(0,Q.jsx)(`div`,{className:G(`flex items-center gap-1.5 text-destructive`,u?`w-full justify-center order-first`:`mr-auto`),children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u&&`w-full`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,className:G(u&&`flex-1`),children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:G(`gap-1.5`,u&&`flex-1`),children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(He,{id:`new-worktree-sheet-${d}`,open:e,onOpenChange:t,title:(0,Q.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`session.newWorktree.title`)}),ariaLabel:i(`session.newWorktree.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(Ve,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`overscroll-contain px-4 pb-4 pt-2`,children:[(0,Q.jsx)(`div`,{className:`w-full mb-4`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>oe(!0),className:`flex-1 justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:x.selectedBranch?`text-foreground`:`text-muted-foreground`,children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]}),(0,Q.jsx)(ut,{open:ae,title:i(`session.newWorktree.selectBranch`),onClose:()=>oe(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:ge,children:[(0,Q.jsx)(st,{value:B,onChange:e=>ce(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Te&&De&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:G(`h-8`,q.touched&&q.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:G(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(Y,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:G(`h-8`,q.touched&&q.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>se(!0),className:`w-full justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:y.sourceBranch?`text-foreground`:`text-muted-foreground`,children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})}),(0,Q.jsx)(ut,{open:z,title:i(`session.newWorktree.selectSourceBranch`),onClose:()=>se(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:_e,children:[(0,Q.jsx)(st,{value:le,onChange:e=>ue(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Ee&&Oe&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e.value})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Y,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-3 pt-2`,children:Ct})]})}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{className:`max-w-lg max-h-[80vh] flex flex-col`,children:[(0,Q.jsx)(Ue,{className:`flex flex-row items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(Ke,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(Y,{name:`git-branch`,className:`h-5 w-5`}),i(`session.newWorktree.title`)]}),(0,Q.jsx)(`div`,{className:`w-[280px] shrink-0`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto mt-2 space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)($e,{open:L,onOpenChange:R,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,x.selectedBranch?`text-foreground`:`text-muted-foreground`),children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,sideOffset:6,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:pe,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:B,onValueChange:ce,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Te&&De&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Ce.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Te&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Ce.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Ce.otherLocal.length>0||Te)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Ce.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:G(`h-8`,q.touched&&q.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:G(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(Y,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:G(`h-8`,q.touched&&q.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)($e,{open:re,onOpenChange:ie,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,y.sourceBranch?`text-foreground`:`text-muted-foreground`),children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:me,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:le,onValueChange:ue,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Ee&&Oe&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:W.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{b(t=>({...t,sourceBranch:e.value})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Ee&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:W.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{b(t=>({...t,sourceBranch:e})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(W.otherLocal.length>0||Ee)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:W.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Y,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]}),(0,Q.jsxs)(We,{className:`mt-1 flex items-center justify-between`,children:[St,(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 text-destructive`,children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:`gap-1.5`,children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]})]})}),(0,Q.jsx)(Yn,{projectId:m?.id,open:F,onOpenChange:I,onSelect:lt})]})}var ir=null,ar=new Set,or=()=>{for(let e of ar)e()},sr=e=>e===`chat`||e===`assistant`,cr=()=>ir,lr=e=>{ir!==e&&(ir=e,or())},ur=e=>{ir&&(e&&ir.surfaceID!==e||(ir=null,or()))},dr=(e,t)=>{if(e.transportIdentity!==t.transportIdentity||e.runtimeGeneration!==t.runtimeGeneration)throw Error(`chat-input-delivery-runtime-stale`)},fr=e=>{let t=e.options?.delivery===`steer`?`steer`:e.options?.delivery===`queue`?`queue`:void 0,n={...t?{delivery:t}:{},...e.options?.commitStagedMessageEdit===void 0?{}:{commitStagedMessageEdit:e.options.commitStagedMessageEdit},...e.options?.messageID?{messageID:e.options.messageID}:{},...e.options?.ticket?{ticket:e.options.ticket}:{}},r=e.options?.sessionId??e.sessionID??void 0;if(!r)return n;let i=e.options?.directoryHint===void 0?e.directory||null:e.options.directoryHint;return{...n,sessionId:r,directoryHint:i}},pr=(e,t,n={})=>({operation:t,surfaceID:e.surfaceID,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration,sessionID:e.sessionID,directory:e.directory??``,draftKey:e.draftKey,deliveryTarget:e.deliveryTarget,...n}),mr=e=>{if(!e.active||!e.draftKey||!e.directory)return null;let t=e.activity?.phase??`idle`,n=e.activity?.canAbort??(t===`busy`||t===`retry`);return{send:async t=>{let n=pr(e,`send`,t);return await e.selection.flush(),e.kind===`secondary`&&await e.shortcuts.submit(),e.backend.send(n)},sendQueued:async(t,n={})=>{let{manual:r,...i}=n,a=pr(e,`send`,i),o=Qt(e);if(await e.selection.flush(),!o)throw Error(`chat-input-queue-scope-incomplete`);return e.backend.sendQueued({...a,queueItemID:t,manual:r,queueScope:o})},create:async()=>{let t=pr(e,`create`);return await e.selection.flush(),e.backend.create(t)},compact:async t=>{let n=pr(e,`compact`,t);return await e.selection.flush(),e.backend.compact(n)},abort:async()=>{let t=pr(e,`abort`);return await e.selection.flush(),e.backend.abort(t)},queueScope:Qt(e),canAbort:n,canQueue:t===`busy`||t===`retry`,allowsCommand:t=>Gt(e,{name:t,source:`yuri`}),shortcut:async(t,n=1)=>{if(e.kind===`secondary`){t===`cycle`?await e.shortcuts.cycle(n):t===`new`?await e.shortcuts.new():t===`abort`?await e.shortcuts.abort():await e.shortcuts.submit();return}if(t===`abort`){let t=pr(e,`abort`);await e.selection.flush(),await e.backend.abort(t);return}if(t===`new`){let t=pr(e,`create`);await e.selection.flush(),await e.backend.create(t);return}t!==`submit`&&await e.shortcuts?.cycle(n)},resources:e.resources??null}},hr=e=>e.type===`tool`&&e.metadata?.providerExecuted===!0,gr=e=>{if(e.type!==`tool`)return!1;let t=e.state;return t?.status===`error`&&t.metadata?.interrupted===!0},_r=e=>e.type!==`tool`||hr(e)?!1:!gr(e),vr=e=>{let t=0;for(let n of e)_r(n)&&(t+=1);return t},yr=(e,t)=>e===`stop`&&vr(t)===0,br=e=>{if(e.type!==`text`||e.synthetic===!0)return!1;let t=e.text;return typeof t==`string`&&Tt(t)},xr=e=>{if(vr(e)!==0)return-1;for(let t=e.length-1;t>=0;--t){let n=e[t];if(br(n))return t;if(n.type===`tool`||n.type===`reasoning`||n.type===`file`||n.type===`agent`||n.type===`subtask`)break}return-1},Sr=(e,t,n)=>{if(n||!yr(e,t))return!1;for(let e of t)if(br(e))return!0;return!1},Cr=e=>e===`streaming`||e===`cooldown`,wr=e=>e.parts.some(br),Tr=e=>Cr(e.streamPhase)?wr(e):!1,Er=e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``},Dr=e=>{let t=e?.type;return t===`compaction`?!_(e):t===`text`&&Er(e).trim()===`/compact`},Or=e=>e?e.some(e=>Dr(e)):!1,kr=e=>Or(e.parts),Ar=e=>e?Or(e.sourceParts)||Or(e.parts):!1,jr=e=>{if(!kr(e))return e;let t=!1,n=e.parts.map(e=>e?.type!==`compaction`||_(e)?e:(t=!0,{type:`text`,text:`/compact`})),r=e.info.clientRole!==`user`;return!t&&!r?e:{...e,info:r?{...e.info,clientRole:`user`}:e.info,parts:t?n:e.parts}},Mr=e=>{let t=Et(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},Nr=new WeakMap,Pr=e=>{let t=Nr.get(e);if(t)return t;let n=jr(Mr(e)),r=n.parts,i=Ce(r),a=i===r?n:{...n,parts:i,sourceParts:r};return Nr.set(e,a),a},Fr={activity:`idle`,hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:null,turnStartedAt:void 0},Ir=[],Lr=`\0`,Rr=new Set([`edit`,`write`,`apply_patch`]),zr={read:`chat.assistantStatus.readingFile`,write:`chat.assistantStatus.writingFile`,edit:`chat.assistantStatus.editingFile`,apply_patch:`chat.assistantStatus.applyingPatch`,bash:`chat.assistantStatus.runningCommand`,grep:`chat.assistantStatus.searchingContent`,glob:`chat.assistantStatus.findingFiles`,list:`chat.assistantStatus.listingDirectory`,task:`chat.assistantStatus.delegatingTask`,webfetch:`chat.assistantStatus.fetchingUrl`,websearch:`chat.assistantStatus.searchingWeb`,codesearch:`chat.assistantStatus.webCodeSearch`,todowrite:`chat.assistantStatus.updatingTodos`,todoread:`chat.assistantStatus.readingTodos`,skill:`chat.assistantStatus.learningSkill`,question:`chat.assistantStatus.askingQuestion`,execute:`chat.assistantStatus.executing`,session_rename:`chat.assistantStatus.renamingSession`,session_move:`chat.assistantStatus.movingSession`,browser:`chat.assistantStatus.usingBrowser`},Br=[`chat.assistantStatus.working`,`chat.assistantStatus.processing`,`chat.assistantStatus.preparing`,`chat.assistantStatus.warmingUp`,`chat.assistantStatus.gearsTurning`,`chat.assistantStatus.computing`,`chat.assistantStatus.calculating`,`chat.assistantStatus.analyzing`,`chat.assistantStatus.wheelsSpinning`,`chat.assistantStatus.calibrating`,`chat.assistantStatus.synthesizing`,`chat.assistantStatus.connectingDots`,`chat.assistantStatus.inspectingLogic`,`chat.assistantStatus.weighingOptions`],Vr=(e,t)=>{let n=zr[Be(e)];return n?t(n):t(`chat.assistantStatus.usingTool`,{tool:e})},Hr=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},Ur=(e,t)=>t(Br[Hr(e)%Br.length]??`chat.assistantStatus.working`),Wr=(e,t,n)=>{let r,i;if(!N(e))for(let t=e.length-1;t>=0;--t){let n=e[t];if(n)switch(n.type){case`reasoning`:{let e=n.time??Xr(n);(!e||e.end===void 0)&&!r&&(r=`reasoning`);break}case`tool`:{let e=n.state?.status;if((e===`running`||e===`pending`)&&!r){let e=Be(Zr(n));Rr.has(e)?(r=`editing`,i=e):(r=`tool`,i=e)}break}case`text`:{let e=Yr(n)??``;if(typeof e==`string`&&e.trim().length>0){let e=Xr(n);(!e||e.end===void 0)&&!r&&(r=`text`)}break}}}let a=r===void 0,o=r===`editing`?n(`chat.assistantStatus.editingFile`):r===`tool`&&i?Vr(i,n):r===`reasoning`?n(`chat.assistantStatus.thinking`):r===`text`?n(`chat.assistantStatus.composing`):Ur(t,n);return{activePartType:r,activeToolName:i,statusText:o,isGenericStatus:a}},Gr=e=>[e.activePartType??``,e.activeToolName??``,e.statusText,e.isGenericStatus?`1`:`0`].join(Lr),Kr=e=>{let[t,n,r=`working`,i]=e.split(Lr);return{activePartType:t===`text`||t===`tool`||t===`reasoning`||t===`editing`?t:void 0,activeToolName:n||void 0,statusText:r,isGenericStatus:i===`1`}},qr=e=>e.type===`reasoning`,Jr=e=>e.type===`text`,Yr=e=>{if(Jr(e))return e.text;let t=e;if(typeof t.text==`string`)return t.text;if(typeof t.content==`string`)return t.content;if(typeof t.value==`string`)return t.value},Xr=e=>(Jr(e)||qr(e),e.time),Zr=e=>{if(e.tool)return e.tool;let t=e;return typeof t.name==`string`?t.name:`tool`};function Qr(e,t){let{t:n}=ze(),r=U(e=>e.currentSessionId),i=U(e=>e.currentSessionDirectory),a=e??r,o=t??i,s=ue(e=>!!(a&&e.session_execution_recovery[a]),o??void 0),c=X.useMemo(()=>e=>a?e.pendingSendMessageIDs.get(a)??null:null,[a]),l=U(c),u=Ne(a??``,o??void 0),d=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`assistant`)return{id:t.id,index:e,finish:t.finish,error:t.error,isCompaction:t.clientRole===`compaction`,startedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,finish:void 0,error:void 0,isCompaction:!1,startedAt:void 0}},[u]),f=d.id,p=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`user`&&!x(t))return{id:t.id,index:e,turnStartedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,turnStartedAt:void 0}},[u]),m=p.id,h=ge(f??``,o??void 0,a??void 0),g=ge(m??``,o??void 0,a??void 0),_=!!m&&Or(g),v=d.isCompaction&&d.index>p.index?h.find(e=>e.type===`compaction`):void 0,y=v?.reason===`manual`?d.startedAt:p.turnStartedAt,b=!!(f&&d.index>p.index&&(v?v.status===`failed`||v.reason===`manual`&&v.status===`completed`:Sr(d.finish,h,d.error))),S=X.useMemo(()=>{let e=`${a??``}:${f??``}`;return Gr(Wr(f&&!d.error&&d.index>p.index?h:Ir,e,n))},[a,f,d.error,d.index,p.index,h,n]),C=Oe(a??``,o??void 0),w=Te(a??``,o??void 0),T=X.useMemo(()=>e=>a?e.sessionAbortFlags?.get(a)??null:null,[a]),ee=U(T),{phase:E,isWorking:D}=nn(a,o??void 0),O=!!(d.error&&d.index>p.index),k=be(a??``,o??void 0),te=k?.type===`retry`?k.attempt:void 0,A=k?.type===`retry`?k.next:void 0,j=X.useMemo(()=>Kr(S),[S]),M=X.useMemo(()=>{let e=!!(ee&&!ee.acknowledged);return{wasAborted:e,abortActive:e}},[ee]),N=X.useMemo(()=>{if(s)return{...Fr,isRecovering:!0,canAbort:D};if(O&&E!==`retry`)return{...Fr,isTurnSettled:!0,canAbort:D};if(M.wasAborted)return{...Fr,wasAborted:!0,abortActive:M.abortActive,activity:`idle`,hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};if(b)return{...Fr,isComplete:v?.status!==`failed`,isTurnSettled:!0,turnStartedAt:y};let e=D,t=E===`busy`,r=E===`retry`,i=e&&(_||v?.status===`running`),a=`idle`;e&&(a=!i&&(j.activePartType===`tool`||j.activePartType===`editing`)?`tooling`:`streaming`);let o=r?{attempt:te,next:A,message:k?.type===`retry`?k.message:void 0}:null;return{activity:a,hasWorkingContext:e,hasActiveTools:!i&&(j.activePartType===`tool`||j.activePartType===`editing`),isWorking:e,isStreaming:t,isCooldown:!1,lifecyclePhase:t?`streaming`:null,statusText:e?i?n(`chat.assistantStatus.compacting`):j.statusText:null,isGenericStatus:!e||!i&&j.isGenericStatus,isWaitingForPermission:!1,canAbort:e,compactionDeadline:null,activePartType:e&&!i?j.activePartType:void 0,activeToolName:e&&!i?j.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:o,turnStartedAt:y}},[s,O,E,D,b,_,v?.status,y,j,M,te,A,k,n]);return{forming:X.useMemo(()=>({isActive:!s&&!O&&D&&j.activePartType===`text`,characterCount:0}),[s,O,D,j.activePartType]),working:X.useMemo(()=>{if(s||N.wasAborted||N.abortActive)return N;if(l)return{...N,activity:`streaming`,hasWorkingContext:!0,isWorking:!0,isStreaming:!0,isCooldown:!1,lifecyclePhase:`streaming`,statusText:n(`chat.assistantStatus.sendingMessage`),isGenericStatus:!1,isWaitingForPermission:!1,canAbort:!0,activePartType:void 0,activeToolName:void 0,isComplete:!1,isTurnSettled:!1,retryInfo:null};let e=C.length>0,t=w.length>0;return!e&&!t?N:t?{...N,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...N,statusText:n(`chat.assistantStatus.waitingForPermission`),isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[s,N,l,C,w,n])}}var $r=`--yuri-mobile-header-collapse`,ei=e=>e.closest(`.mobile-chat-screen`)?.querySelector(`:scope > [data-yuri-collapsible-header="true"]`)??null,ti=e=>{e.style.removeProperty($r),delete e.dataset.yuriHeaderCollapsePhase,delete e.dataset.yuriHeaderCollapseRest},ni=(e,t,n)=>{let r=String(t.progress),i=t.phase,a=t.rest===`compact`?`collapsed`:`expanded`;return n?.phase!==i&&(e.dataset.yuriHeaderCollapsePhase=i,i===`snapping`&&n&&n.phase!==`snapping`&&e.offsetWidth),n?.progress!==r&&e.style.setProperty($r,r),n?.rest!==a&&(e.dataset.yuriHeaderCollapseRest=a),{progress:r,phase:i,rest:a}},ri=e=>{let t=e.startsWith(`#`)?e.slice(1):e;if(!t)return null;let n=t.match(/^turn-(.+)$/);if(n?.[1])return{kind:`turn`,id:n[1]};let r=t.match(/^message-(.+)$/);return r?.[1]?{kind:`message`,id:r[1]}:null},ii=(e,t,n)=>{if(n===0||e.length===0)return{kind:`noop`};let r=t?e.indexOf(t):e.length-1,i=(r>=0?r:e.length-1)+n;if(i>=e.length)return{kind:`resume`};let a=e[Math.max(0,i)];return a?{kind:`turn`,turnId:a}:{kind:`noop`}},ai=e=>{if(typeof window>`u`)return;let t=e?`#${e}`:``,n=`${window.location.pathname}${window.location.search}${t}`;window.history.replaceState(window.history.state,``,n),e&&window.dispatchEvent(new HashChangeEvent(`hashchange`))},oi=e=>{e&&ai(`message-${e}`)},si=e=>{let t=(0,Z.c)(29),{sessionId:n,turnIds:r,activeTurnId:i,scrollToTurn:a,scrollToMessage:o,resumeToBottom:s}=e,c=X.useRef(r),l=X.useRef(i),u,d;t[0]===r?(u=t[1],d=t[2]):(u=()=>{c.current=r},d=[r],t[0]=r,t[1]=u,t[2]=d),X.useEffect(u,d);let f,p;t[3]===i?(f=t[4],p=t[5]):(f=()=>{l.current=i},p=[i],t[3]=i,t[4]=f,t[5]=p),X.useEffect(f,p);let m;t[6]===a?m=t[7]:(m=async(e,t)=>e?(t?.updateHash!==!1&&ai(`turn-${e}`),a(e,{behavior:t?.behavior})):!1,t[6]=a,t[7]=m);let h=m,g;t[8]===o?g=t[9]:(g=async(e,t)=>e?(t?.updateHash!==!1&&ai(`message-${e}`),o(e,{behavior:t?.behavior})):!1,t[8]=o,t[9]=g);let _=g,v;t[10]!==s||t[11]!==h?(v=async(e,t)=>{let n=c.current,r=ii(n,l.current,e);if(r.kind===`noop`)return e===0;if(r.kind===`resume`){if(t?.resumePastEnd===!1){let e=n[n.length-1];return e?h(e,{behavior:`auto`}):!1}return ai(null),s(),!0}return h(r.turnId,{behavior:`auto`})},t[10]=s,t[11]=h,t[12]=v):v=t[12];let y=v,b;t[13]===s?b=t[14]:(b=()=>{ai(null),s()},t[13]=s,t[14]=b);let x=b,S;t[15]!==_||t[16]!==h||t[17]!==n?(S=()=>{if(!n||typeof window>`u`)return;let e=()=>{let e=ri(window.location.hash);if(e){if(e.kind===`turn`){h(e.id,{behavior:`auto`,updateHash:!1});return}_(e.id,{behavior:`auto`,updateHash:!1})}};return e(),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`hashchange`,e)}},t[15]=_,t[16]=h,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==_||t[20]!==h||t[21]!==n||t[22]!==r.length?(C=[n,_,h,r.length],t[19]=_,t[20]=h,t[21]=n,t[22]=r.length,t[23]=C):C=t[23],X.useEffect(S,C);let w;return t[24]!==x||t[25]!==y||t[26]!==_||t[27]!==h?(w={scrollToTurnId:h,scrollToMessageId:_,scrollByTurnOffset:y,resumeToLatest:x},t[24]=x,t[25]=y,t[26]=_,t[27]=h,t[28]=w):w=t[28],w},ci=[0,200,400],li=e=>{let t=(0,Z.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=G(`inline-flex`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=ci.map(ui),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Q.jsxs)(Q.Fragment,{children:[`\xA0`,(0,Q.jsx)(`span`,{className:r,"aria-hidden":`true`,children:i})]}),t[3]=r,t[4]=a),a};function ui(e){return(0,Q.jsx)(`span`,{className:`animate-busy-pulse`,style:{animationDelay:`${e}ms`},children:`.`},e)}export{En as A,Xt as B,sr as C,Tn as D,Ln as E,wn as F,Ut as G,Vt as H,cn as I,qt as J,Yt as K,rn as L,Dn as M,Cn as N,On as O,Sn as P,Ot as Q,an as R,cr as S,nr as T,$t as U,Gt as V,Zt as W,Bt as X,Jt as Y,Dt as Z,Tr as _,ti as a,fr as b,Qr as c,wr as d,vr as f,br as g,yr as h,$r as i,jn as j,kn as k,Pr as l,Sr as m,oi as n,ni as o,xr as p,Ht as q,si as r,ei as s,li as t,Ar as u,dr as v,lr as w,ur as x,mr as y,nn as z};
|
|
4
|
+
`)})}function Wn(e){let t=(0,Z.c)(41),{project:n,open:r,onClose:i,children:a}=e,o=ee(),s=n?.hostId&&o&&o.entry.location.hubId===n.hubId&&o.entry.location.hostId===n.hostId&&o.entry.location.directory===n.path,c=Le(!!(r&&n?.hostId&&!s)),{t:l}=ze();if(!n?.hostId){let e;return t[0]===a?e=t[1]:(e=(0,Q.jsx)(T.Provider,{value:null,children:a}),t[0]=a,t[1]=e),e}if(s)return a;if(!r)return null;if(!c.registry||c.registry.hubId!==n.hubId){let e;t[2]===i?e=t[3]:(e=e=>{e||i()},t[2]=i,t[3]=e);let n;t[4]===l?n=t[5]:(n=l(`session.newWorktree.title`),t[4]=l,t[5]=n);let r;t[6]===n?r=t[7]:(r=(0,Q.jsx)(Ue,{children:(0,Q.jsx)(Ke,{children:n})}),t[6]=n,t[7]=r);let a=c.isPending?`status`:`alert`,o;t[8]!==c.error?.message||t[9]!==c.isPending||t[10]!==l?(o=c.isPending?l(`remoteProjects.running`):c.error?.message||l(`remoteProjects.host-unavailable`),t[8]=c.error?.message,t[9]=c.isPending,t[10]=l,t[11]=o):o=t[11];let s;t[12]!==a||t[13]!==o?(s=(0,Q.jsx)(`p`,{role:a,children:o}),t[12]=a,t[13]=o,t[14]=s):s=t[14];let u;t[15]===l?u=t[16]:(u=l(`session.newWorktree.actions.cancel`),t[15]=l,t[16]=u);let d;t[17]!==i||t[18]!==u?(d=(0,Q.jsx)(H,{onClick:i,children:u}),t[17]=i,t[18]=u,t[19]=d):d=t[19];let f;t[20]!==c.isPending||t[21]!==l?(f=c.isPending?null:(0,Q.jsx)(H,{onClick:Gn,children:l(`remoteProjects.retry`)}),t[20]=c.isPending,t[21]=l,t[22]=f):f=t[22];let p;t[23]!==d||t[24]!==f?(p=(0,Q.jsxs)(We,{children:[d,f]}),t[23]=d,t[24]=f,t[25]=p):p=t[25];let m;t[26]!==p||t[27]!==r||t[28]!==s?(m=(0,Q.jsxs)(Ge,{children:[r,s,p]}),t[26]=p,t[27]=r,t[28]=s,t[29]=m):m=t[29];let h;return t[30]!==e||t[31]!==m?(h=(0,Q.jsx)(qe,{open:!0,onOpenChange:e,children:m}),t[30]=e,t[31]=m,t[32]=h):h=t[32],h}let u;t[33]!==n.hostId||t[34]!==n.hubId||t[35]!==n.path?(u={hubId:n.hubId,hostId:n.hostId,directory:n.path},t[33]=n.hostId,t[34]=n.hubId,t[35]=n.path,t[36]=u):u=t[36];let d;return t[37]!==a||t[38]!==c.registry||t[39]!==u?(d=(0,Q.jsx)(k,{registry:c.registry,location:u,children:a}),t[37]=a,t[38]=c.registry,t[39]=u,t[40]=d):d=t[40],d}function Gn(){Re().catch(Kn)}function Kn(){}var qn=(e,t,n)=>{let r=n??t;return r?e.find(e=>e.id===r)??null:null};function Jn(e,t){return`${e}\0${t}`}function Yn(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=P(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(Xn,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function Xn({open:e,onOpenChange:t,onSelect:n,projectId:r}){let{t:i}=ze(),a=j(e=>e.isMobile),o=ee(),s=o?.entry.location.hostId?o.entry:void 0,{git:c}=et(),{github:l,auth:u}=Vn(s,e),d=u.data??null,f=u.isFetched,p=j(e=>e.setSettingsDialogOpen),m=j(e=>e.setSettingsPage),h=P(e=>qn(e.projects,e.activeProjectId,r)),g=h?.id??null,_=h?.path??null,v=X.useMemo(()=>_&&g?{id:g,path:_,hostId:h?.hostId,hubId:h?.hubId}:null,[g,_,h?.hostId,h?.hubId]),[y,b]=X.useState(`issues`),[x,S]=X.useState(``),[C,w]=X.useState([]),[T,E]=X.useState([]),[D,O]=X.useState(!1),[k,A]=X.useState(!1),[M,N]=X.useState(null),[F,ne]=X.useState(null),[I,L]=X.useState(null),[R,re]=X.useState(!1),[ie,ae]=X.useState(new Map),[oe,z]=X.useState(1),[se,B]=X.useState(!1),V=X.useRef(0),ce=ct(x,350),le=te(async e=>{if(!(!_||!l)&&!(f&&d?.connected===!1)){O(!0),N(null),z(1),B(!1);try{if(y===`issues`&&l.issuesList){let t=await l.issuesList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(t.issues??[]),z(t.page??1),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=await l.prsList(_,{page:1,query:e});t.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(t.prs??[]),z(t.page??1),B(!!t.hasMore))}}catch(e){N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}finally{O(!1)}}});X.useEffect(()=>{if(!e||!_||f&&d?.connected===!1||!l)return;if(!ce.trim()){le();return}let t=new AbortController;O(!0),N(null),z(1),B(!1);let n=y===`issues`&&l.issuesList?l.issuesList(_,{page:1,query:ce.trim()}):y===`prs`&&l.prsList?l.prsList(_,{page:1,query:ce.trim()}):null;if(!n){O(!1);return}return n.then(e=>{t.signal.aborted||(`issues`in e?e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),w([])):(w(e.issues??[]),z(e.page??1),B(!!e.hasMore)):`prs`in e&&(e.connected===!1?(N(i(`session.githubIntegration.error.notConnected`)),E([])):(E(e.prs??[]),z(e.page??1),B(!!e.hasMore))))}).catch(e=>{t.signal.aborted||N(e instanceof Error?e.message:i(`session.githubIntegration.error.loadDataFailed`))}).finally(()=>{t.signal.aborted||O(!1)}),()=>t.abort()},[e,_,l,f,d,y,ce,le,i]);let ue=te(async()=>{if(!(!_||!l)&&!(D||k)&&se){A(!0);try{let e=oe+1;if(y===`issues`&&l.issuesList){let t=ce.trim()?await l.issuesList(_,{page:e,query:ce.trim()}):await l.issuesList(_,{page:e});t.connected!==!1&&(w(e=>[...e,...t.issues??[]]),z(t.page??e),B(!!t.hasMore))}else if(y===`prs`&&l.prsList){let t=ce.trim()?await l.prsList(_,{page:e,query:ce.trim()}):await l.prsList(_,{page:e});t.connected!==!1&&(E(e=>[...e,...t.prs??[]]),z(t.page??e),B(!!t.hasMore))}}catch{}finally{A(!1)}}});X.useEffect(()=>{if(!e){b(`issues`),S(``),w([]),E([]),ne(null),L(null),re(!1),N(null),ae(new Map),z(1),B(!1);return}le()},[e,le]),X.useEffect(()=>{V.current+=1,ae(new Map)},[_,v]);let de=te(async e=>{if(!v||!e)return;let t=Jn(v.path,e);if(ie.has(t))return;let n=V.current;try{let r={mode:`new`,branchName:e,worktreeName:e},a=s?await c.validateGitWorktree(v.path,r):await ft(v,r);if(n!==V.current)return;let o=a.errors.find(e=>e.code===`branch_in_use`);ae(e=>new Map(e).set(t,{isValid:!o,error:o?i(o.code===`branch_exists`?`session.githubIntegration.validation.branchAlreadyExists`:`session.githubIntegration.validation.branchAlreadyCheckedOut`):null}))}catch{if(n!==V.current)return;ae(e=>new Map(e).set(t,{isValid:!1,error:i(`session.githubIntegration.validation.failed`)}))}});X.useEffect(()=>{!e||y!==`prs`||T.forEach(e=>{e.head&&de(e.head)})},[e,y,T,_,v,de]);let fe=f&&d?.connected===!0,pe=()=>{if(s){K.info(i(`remoteProjects.configurationReadOnly`));return}m(`github`),p(!0)},me=e=>{ne(e),L(null)},he=e=>{L(e),ne(null)},U=()=>{F?n({type:`issue`,item:F}):I&&n({type:`pr`,item:I,includeDiff:R}),t(!1)},ge=()=>{ne(null),L(null),re(!1)},_e=F||(I?.head&&_?ie.get(Jn(_,I.head))?.isValid!==!1:!1),ve=e=>!e.head||(_?ie.get(Jn(_,e.head)):void 0)?.isValid===!1,ye=(0,Q.jsxs)(Q.Fragment,{children:[s&&u.error?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-small text-destructive`,children:[u.error.message,(0,Q.jsx)(H,{variant:`ghost`,size:`xs`,onClick:()=>{u.refetch()},children:i(`remoteProjects.retry`)})]}):null,fe?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,Q.jsx)(Y,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,Q.jsx)(st,{value:x,onChange:e=>S(e.target.value),placeholder:i(y===`issues`?`session.githubIntegration.search.issuesPlaceholder`:`session.githubIntegration.search.prsPlaceholder`),className:`h-8 pl-9`})]}),(0,Q.jsx)(`div`,{className:`yuri-picker-list mt-2 h-[300px] overflow-hidden`,children:(0,Q.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[D&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-5 w-5 animate-spin text-muted-foreground`})}),M&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 p-2 rounded-md bg-destructive/10 text-destructive`,children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-4 w-4`}),(0,Q.jsx)(`span`,{className:`typography-small`,children:M})]})}),!D&&!M&&y===`issues`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[C.length>0?C.map(e=>(0,Q.jsx)(`button`,{onClick:()=>me(e),className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,F?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-2`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info mt-0.5 inline-block`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noIssuesFound`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]}),!D&&!M&&y===`prs`&&(0,Q.jsxs)(`div`,{className:`space-y-0.5 min-h-full`,children:[T.length>0?T.map(e=>{let t=ve(e),n=e.head&&_?ie.get(Jn(_,e.head)):void 0;return(0,Q.jsx)(`button`,{onClick:()=>!t&&he(e),disabled:t,className:G(`yuri-picker-row w-full text-left px-2 py-1.5 rounded transition-colors`,I?.number===e.number?`bg-interactive-selection text-interactive-selection-foreground`:t?`opacity-50 cursor-not-allowed`:`hover:bg-interactive-hover`),children:(0,Q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Q.jsxs)(`span`,{className:`text-muted-foreground shrink-0 typography-micro`,children:[`#`,e.number]}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`span`,{className:`yuri-picker-label typography-small line-clamp-1`,children:e.title}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[e.head,` → `,e.base]}),e.sourceRepo?.source===`upstream`?(0,Q.jsxs)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-info/10 text-status-info`,children:[e.sourceRepo.owner,`/`,e.sourceRepo.repo]}):null,t&&n?.error&&(0,Q.jsx)(`span`,{className:`typography-micro text-destructive`,children:n.error})]})]})]})},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)}):(0,Q.jsx)(`div`,{className:`flex items-center justify-center h-[300px] text-center typography-small text-muted-foreground`,children:i(`session.githubIntegration.empty.noPullRequestsFound`)}),se&&!k&&(0,Q.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,onClick:()=>void ue(),className:`h-7 text-xs`,children:i(`session.githubIntegration.actions.loadMore`)})}),k&&(0,Q.jsx)(`div`,{className:`flex items-center justify-center py-2`,children:(0,Q.jsx)(Y,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`})})]})]})})]}):(0,Q.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center p-8 gap-4`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-12 w-12 text-muted-foreground`}),(0,Q.jsxs)(`div`,{className:`text-center`,children:[(0,Q.jsx)(`p`,{className:`typography-ui-label text-foreground`,children:i(`session.githubIntegration.connect.title`)}),(0,Q.jsx)(`p`,{className:`typography-small text-muted-foreground mt-1`,children:i(`session.githubIntegration.connect.description`)})]}),(0,Q.jsx)(H,{onClick:pe,size:`sm`,children:i(`session.githubIntegration.connect.action`)})]})]}),be=(0,Q.jsxs)(`div`,{className:G(`w-full`,a?`flex flex-col gap-2`:`flex flex-row items-center`),children:[(0,Q.jsxs)(`div`,{className:G(`flex items-center gap-4`,a?`w-full justify-center order-1`:`flex-1`),children:[!a&&(F||I)&&(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate max-w-[150px]`,children:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y===`prs`&&I&&(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 cursor-pointer h-8`,children:[(0,Q.jsx)(lt,{checked:R,onChange:e=>re(e),ariaLabel:i(`session.githubIntegration.includeDiffAria`)}),(0,Q.jsx)(`span`,{className:`typography-small text-foreground`,children:i(`session.githubIntegration.includeDiff`)})]})]}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,a?`w-full order-2`:`justify-end`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.cancel`)}),(0,Q.jsx)(H,{size:`sm`,onClick:U,disabled:!_e,className:G(a&&`flex-1`),children:i(`session.githubIntegration.actions.select`)})]})]});return(0,Q.jsx)(Q.Fragment,{children:a?(0,Q.jsx)(ut,{open:e,title:i(`session.githubIntegration.title`),onClose:()=>t(!1),footer:fe?be:void 0,renderHeader:e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 px-3 py-2 border-b border-border/40`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:i(`session.githubIntegration.title`)}),e]}),(0,Q.jsx)(`div`,{className:`w-full`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})}),(F||I)&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1 rounded-md bg-muted/50 border border-border/50`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),(0,Q.jsx)(`span`,{className:`typography-small truncate flex-1`,children:F?i(`session.githubIntegration.selected.issueNumber`,{number:F.number}):i(`session.githubIntegration.selected.prNumber`,{number:I?.number??``})}),(0,Q.jsx)(`button`,{onClick:ge,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]})]}),children:ye}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{presentation:`picker`,children:[(0,Q.jsx)(Ue,{className:`yuri-picker-header`,children:(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-3`,children:[(0,Q.jsx)(Ke,{className:`yuri-picker-title`,children:i(`session.githubIntegration.title`)}),(0,Q.jsx)(`div`,{className:`w-[220px]`,children:(0,Q.jsx)(wt,{items:[{id:`issues`,label:i(`session.githubIntegration.tabs.issues`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`prs`,label:i(`session.githubIntegration.tabs.pullRequests`),icon:(0,Q.jsx)(Y,{name:`git-pull-request`,className:`h-3.5 w-3.5`})}],activeId:y,onSelect:e=>{b(e),S(``)},variant:`active-pill`,layoutMode:`fit`})})]})}),ye,(0,Q.jsx)(We,{className:`yuri-picker-footer`,children:be})]})})})}var Zn=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``),$=e=>e.trim().replace(/^refs\/heads\//,``).replace(/^heads\//,``).replace(/\s+/g,`-`).replace(/^\/+|\/+$/g,``).split(`/`).join(`-`).replace(/[^A-Za-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``).slice(0,80),Qn=e=>String(e||``).trim().toLowerCase().replace(/[^a-z0-9._-]+/g,`-`).replace(/-+/g,`-`).replace(/^-+|-+$/g,``)||`pr-head`,$n=(e,t,n)=>{let r=Zn(e.head||``);if(!r)throw Error(`PR head branch is missing`);if(t.includes(r))return{existingBranch:r,setUpstream:void 0,upstreamRemote:void 0,upstreamBranch:void 0,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:r};let i=n.find(e=>{let t=e.indexOf(`/`);return t<=0||t>=e.length-1?!1:e.slice(t+1)===r});if(i){let e=i.indexOf(`/`),t=i.slice(0,e);return{existingBranch:`remotes/${i}`,setUpstream:!0,upstreamRemote:t,upstreamBranch:r,ensureRemoteName:void 0,ensureRemoteUrl:void 0,sourceLabel:`${t}/${r}`}}let a=String(e.headLabel||``).split(`:`)[0]?.trim(),o=`pr-${Qn(e.headRepo?.owner||a||`pr-head`)}`,s=e.headRepo?.sshUrl||e.headRepo?.cloneUrl||``;if(!s)throw Error(`PR head repository URL is unavailable`);return{existingBranch:`remotes/${o}/${r}`,setUpstream:!0,upstreamRemote:o,upstreamBranch:r,ensureRemoteName:o,ensureRemoteUrl:s,sourceLabel:`${o}/${r}`}},er=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`},tr=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function nr(e){let t=(0,Z.c)(12),n;t[0]===e.projectId?n=t[1]:(n=t=>qn(t.projects,t.activeProjectId,e.projectId),t[0]=e.projectId,t[1]=n);let r=P(n),i;t[2]===e?i=t[3]:(i=()=>e.onOpenChange(!1),t[2]=e,t[3]=i);let a=r?.id,o;t[4]!==e||t[5]!==a?(o=(0,Q.jsx)(rr,{...e},a),t[4]=e,t[5]=a,t[6]=o):o=t[6];let s;return t[7]!==r||t[8]!==e.open||t[9]!==i||t[10]!==o?(s=(0,Q.jsx)(Wn,{project:r,open:e.open,onClose:i,children:o}),t[7]=r,t[8]=e.open,t[9]=i,t[10]=o,t[11]=s):s=t[11],s}function rr({open:e,onOpenChange:t,onWorktreeCreated:n,projectId:r}){let{t:i}=ze(),{git:a}=et(),o=ee(),s=o?.entry.location.hostId?o.entry:void 0,{github:c,auth:l}=Vn(s,e),u=j(e=>e.isMobile),d=X.useId(),f=l.data??null,p=l.isFetched,m=P(e=>qn(e.projects,e.activeProjectId,r)),h=m?.path??null,g=X.useMemo(()=>h&&m?{id:m.id,path:h,hostId:m.hostId,hubId:m.hubId}:null,[m,h]),[_,v]=X.useState(`new-branch`),[y,b]=X.useState({branchName:``,worktreeName:``,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1}),[x,S]=X.useState({selectedBranch:``,worktreeName:``}),C=ot(h),T=at(e=>h?e.directories.get(h)?.isLoadingBranches??!1:!1),E=at(e=>e.fetchBranches),D=X.useMemo(()=>C?.all?C.all.filter(e=>!e.startsWith(`remotes/`)).sort():[],[C]),k=X.useMemo(()=>C?.all?C.all.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort():[],[C]),te=U(e=>e.availableWorktreesByProject),A=w({queryKey:[...s?.queryScope??[`local`],`worktree-dialog`,`worktrees`],enabled:!!(s&&e&&h),queryFn:()=>a.listGitWorktrees(h),staleTime:3e4,gcTime:1/0},O),M=X.useMemo(()=>{if(!h)return new Set;let e=s?A.data??[]:te.get(h)??[];return new Set(e.map(e=>e.name))},[te,h,s,A.data]),N=X.useCallback((e=10)=>{for(let t=0;t<e;t++){let e=cn();if(!M.has(e))return e}return`${cn()}-${Date.now().toString(36).slice(-4)}`},[M]),[F,I]=X.useState(!1),[L,R]=X.useState(!1),[re,ie]=X.useState(!1),[ae,oe]=X.useState(!1),[z,se]=X.useState(!1),[B,ce]=X.useState(``),[le,ue]=X.useState(``),pe=X.useRef(null),me=X.useRef(null),ge=X.useRef(null),_e=X.useRef(null),ve=X.useCallback(e=>{e.stopPropagation()},[]),ye=X.useCallback(e=>{let t=e;for(;t&&t!==document.body;){let{overflowY:e}=window.getComputedStyle(t);if((e===`auto`||e===`scroll`)&&t.scrollHeight>t.clientHeight)return t;t=t.parentElement}return null},[]),be=X.useCallback(e=>{e&&(e.scrollTop=0)},[]),xe=X.useCallback(e=>{let t=e.current?.querySelector(`[data-slot="command-list"]`)??null;be(t)},[be]),Se=X.useCallback(e=>{let t=ye(e.current);be(t)},[ye,be]),Ce=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:B}),[D,k,B]),W=X.useMemo(()=>Rn({localBranches:D,remoteBranches:k,query:le}),[D,k,le]),Te=B.trim().length>0,Ee=le.trim().length>0,De=Ce.matching.length>0,Oe=W.matching.length>0,Me=!!(h&&a),Ne=X.useCallback(()=>{!h||!a||E(h,a)},[h,a,E]);X.useEffect(()=>{!e||!h||!a||C?.all||E(h,a)},[e,h,a,C?.all,E]),X.useEffect(()=>{!L&&!ae&&ce(``)},[L,ae]),X.useEffect(()=>{!re&&!z&&ue(``)},[re,z]),X.useEffect(()=>{L&&xe(pe),ae&&Se(ge)},[L,ae,B,xe,Se]),X.useEffect(()=>{re&&xe(me),z&&Se(_e)},[re,z,le,xe,Se]);let[q,J]=X.useState({isValidating:!1,branchError:null,worktreeError:null,touched:!1}),[Pe,Fe]=X.useState(!1),[Ie,Le]=X.useState(null),Re=X.useCallback(()=>{let e=de.getState(),t=e.getVisibleAgents();if(e.settingsDefaultAgent){let n=t.find(t=>t.name===e.settingsDefaultAgent);if(n)return n.name}return t.find(e=>e.name===`build`)?.name||t[0]?.name},[]),Be=X.useCallback(()=>{let e=de.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=ne(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),Je=X.useCallback((e,t)=>{let n=de.getState(),r=ne(n.settingsDefaultModel??n.opencodeDefaultModel),i=r?.providerId===e&&r.modelId===t?r.variant??n.settingsDefaultVariant:void 0,a=n.currentProviderId===e&&n.currentModelId===t?n.currentVariant:void 0;return i??a},[]),Ye=X.useCallback(async e=>{if(!h||!c)return;let t=de.getState(),n=Ae.getState().lastUsedProvider,r=Be(),a=r?.providerID||t.currentProviderId||n?.providerID,o=r?.modelID||t.currentModelId||n?.modelID,s=Re()||t.currentAgentName||void 0;if(!a||!o){K.error(i(`session.newWorktree.error.noModelSelected`));return}let l=Je(a,o);if(e.issue){if(!c.issueGet||!c.issueComments)return;let t=await c.issueGet(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(t.connected===!1||!t.repo||!t.issue)throw Error(`Failed to load issue context`);let n=await c.issueComments(h,e.issue.number,{sourceRepo:e.issue.sourceRepo??null});if(n.connected===!1)throw Error(`Failed to load issue comments`);let r=await tt(`github.issue.review.visible`,{issue_number:String(e.issue.number)}),u=await tt(`github.issue.review.instructions`),d=er({repo:t.repo,issue:t.issue,comments:n.comments??[]});await U.getState().sendMessage(r,a,o,s,void 0,void 0,[{text:u,synthetic:!0},{text:d,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.success(i(`session.newWorktree.toast.sessionFromIssue`));return}if(e.pr){if(!c.prContext)return;let t=await c.prContext(h,e.pr.number,{sourceRepo:e.pr.sourceRepo??null,includeDiff:e.includeDiff,includeCheckDetails:!1});if(t.connected===!1||!t.repo||!t.pr)throw Error(`Failed to load PR context`);let n=await tt(`github.pr.review.visible`,{pr_number:String(e.pr.number)}),r=await tt(`github.pr.review.instructions`),u=tr(t);await U.getState().sendMessage(n,a,o,s,void 0,void 0,[{text:r,synthetic:!0},{text:u,synthetic:!0}],l,void 0,{sessionId:e.sessionId}),K.success(i(`session.newWorktree.toast.sessionFromPr`))}},[c,h,Re,Be,Je,i]),Xe=_===`new-branch`?y:x;X.useEffect(()=>{if(!e||!C?.all||!h||y.sourceBranch)return;let t=y.sourceBranch,n=!1;return(async()=>{try{let e=s?(await a.getGitStatus(h)).current:await mt(h).catch(()=>null);if(n)return;let r=localStorage.getItem(xt),{sourceBranch:i,shouldClearSavedSourceBranch:o}=vt({branches:C.all,savedSourceBranch:r,rootBranch:e});if(o&&localStorage.removeItem(xt),n||t)return;i&&b(e=>({...e,sourceBranch:i}))}catch{}})(),()=>{n=!0}},[e,C?.all,h,y.sourceBranch,s,a]),X.useLayoutEffect(()=>{if(!e)return;v(`new-branch`),S({selectedBranch:``,worktreeName:``}),R(!1),ie(!1),oe(!1),se(!1),ce(``),ue(``),J({isValidating:!1,branchError:null,worktreeError:null,touched:!1});let t=N();b({branchName:t,worktreeName:t,isSyncingWorktreeName:!0,sourceBranch:``,linkedIssue:null,linkedPr:null,includePrDiff:!1})},[e,N]),X.useEffect(()=>{if(_!==`new-branch`||!y.isSyncingWorktreeName)return;let e=$(Zn(y.branchName));b(t=>({...t,worktreeName:e}))},[_,y.branchName,y.isSyncingWorktreeName]);let nt=X.useCallback(async()=>{if(!g||!q.touched||Pe)return;Ie&&Ie.abort();let e=new AbortController;Le(e),J(e=>({...e,isValidating:!0}));try{let t=_===`new-branch`?y.branchName:x.selectedBranch,n=Xe.worktreeName,r=Zn(t),o=$(n),c=null,l=null;if(r||(c=i(`session.newWorktree.error.branchNameRequired`)),o||(l=i(`session.newWorktree.error.worktreeDirectoryRequired`)),r&&o){let t=_===`new-branch`?y.linkedPr:null,n=t?$n(t,D,k):null,i={mode:_===`existing-branch`||n?`existing`:`new`,branchName:r,worktreeName:o,existingBranch:n?.existingBranch??(_===`existing-branch`?r:void 0),...n?.ensureRemoteName?{ensureRemoteName:n.ensureRemoteName}:{},...n?.ensureRemoteUrl?{ensureRemoteUrl:n.ensureRemoteUrl}:{}},u=s?await a.validateGitWorktree(h,i):await ft(g,i);if(e.signal.aborted)return;u.ok||u.errors.forEach(e=>{if(e.code===`worktree_exists`){l??=e.message;return}e.code.startsWith(`branch_`)&&(c??=e.message)})}e.signal.aborted||J(e=>({...e,isValidating:!1,branchError:c,worktreeError:l}))}catch{e.signal.aborted||J(e=>({...e,isValidating:!1}))}},[s,a,h,g,_,y.branchName,y.linkedPr,x.selectedBranch,Xe.worktreeName,D,k,q.touched,Ie,Pe,i]),rt=_===`new-branch`?y.branchName:x.selectedBranch;X.useEffect(()=>{if(!e||!g||!q.touched||Pe)return;let t=setTimeout(()=>{nt()},300);return()=>clearTimeout(t)},[Xe.worktreeName,rt,e,g,nt,q.touched,Pe]);let it=async()=>{if(!g||!h){K.error(i(`session.newWorktree.error.noActiveProject`));return}J(e=>({...e,touched:!0}));let e=_===`new-branch`?y.branchName:x.selectedBranch,r=Xe.worktreeName,a=Zn(e),c=$(r);if(!a){K.error(i(`session.newWorktree.error.branchNameRequired`));return}if(!c){K.error(i(`session.newWorktree.error.worktreeDirectoryRequired`));return}Ie&&(Ie.abort(),Le(null)),J(e=>({...e,isValidating:!1,branchError:null,worktreeError:null})),Fe(!0);try{let e=_===`new-branch`?y.linkedPr:null,r=_===`new-branch`?y.linkedIssue:null,l=_===`new-branch`?y.linkedPr:null,u=_===`new-branch`&&y.includePrDiff,d=!!(r||l);if(s&&o&&m?.hostId){let l=m;P.getState().setActiveProjectIdOnly(l.id);let f=e?$n(e,D,k):null,p=r?`#${r.number} ${r.title}`.trim():e?`#${e.number} ${e.title}`.trim():void 0,h=await un(l,{mode:f||_===`existing-branch`?`existing`:`new`,worktreeName:c,branchName:_===`new-branch`?a:void 0,existingBranch:f?.existingBranch??(_===`existing-branch`?a:void 0),..._===`new-branch`&&!f&&y.sourceBranch?{startRef:y.sourceBranch}:{},...f?{setUpstream:f.setUpstream,upstreamRemote:f.upstreamRemote,upstreamBranch:f.upstreamBranch,...f.ensureRemoteName?{ensureRemoteName:f.ensureRemoteName}:{},...f.ensureRemoteUrl?{ensureRemoteUrl:f.ensureRemoteUrl}:{}}:{}},{title:p,createSession:d,kind:e?`pr`:`standard`,createdFromBranch:f?.sourceLabel??y.sourceBranch,isSelected:()=>P.getState().activeProjectId===l.id});s.sdk();let g=V.getState().remoteSession;g?.projectId===l.id&&g.location.hubId===s.location.hubId&&g.location.hostId===s.location.hostId&&g.location.directory===h.path&&g.sessionId===(h.id??null)&&n?.(h.path,{...h.id?{sessionId:h.id}:{},remote:!0}),t(!1),K.success(i(`session.newWorktree.toast.worktreeCreated`)),h.id&&d&&Un(o.registry,s,h.path,h.id,{issue:r,pr:e,includeDiff:u},i(`session.newWorktree.error.sendGitHubContextFailed`)).catch(e=>{K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:e instanceof Error?e.message:String(e)})});return}let[f,p]=await Promise.all([je(g),gt(h)]),v=y.sourceBranch,b=``,S=(()=>{if(e){let t=$n(e,D,k);return b=t.sourceLabel,{preferredName:a||c,mode:`existing`,branchName:a,worktreeName:c,existingBranch:t.existingBranch,setupCommands:f,setUpstream:t.setUpstream,upstreamRemote:t.upstreamRemote,upstreamBranch:t.upstreamBranch,returnAfterDirectoryCreated:!0,...t.ensureRemoteName?{ensureRemoteName:t.ensureRemoteName}:{},...t.ensureRemoteUrl?{ensureRemoteUrl:t.ensureRemoteUrl}:{}}}return b=_===`new-branch`?v:``,{preferredName:a||c,mode:_===`existing-branch`?`existing`:`new`,branchName:_===`existing-branch`?void 0:a,worktreeName:c,existingBranch:_===`existing-branch`?a:void 0,setupCommands:f,returnAfterDirectoryCreated:!0,...v&&_===`new-branch`?{startRef:v}:{}}})(),C=await yt(h,S,{resolvedRootTrackingRemote:p}),w=await ht(g,C),T=null;if(d){await ke(g)&&await we(w.worktreeRoot??w.path);let e=r?`#${r.number} ${r.title}`.trim():l?`#${l.number} ${l.title}`.trim():i(`session.newWorktree.newSessionTitle`),a=await fe(e,w.path,null);if(!a?.id)throw Error(`Failed to create session`);T=a.id,n?.(w.path,{sessionId:T}),t(!1),Fe(!1),he(a.id,e).catch(()=>void 0);try{U.getState().initializeNewYuriSession(a.id,de.getState().agents)}catch{}}else t(!1),Fe(!1);let ee=bt({mode:_,sourceBranch:y.sourceBranch,linkedPr:!!y.linkedPr,selectedBranch:x.selectedBranch});ee&&localStorage.setItem(xt,ee),K.success(i(`session.newWorktree.toast.worktreeCreated`),{description:i(`session.newWorktree.toast.worktreeCreatedDescription`,{target:`${w.branch||w.name}${b?` ${i(`session.newWorktree.fromSource`,{source:b})}`:``}`})}),T?Ye({sessionId:T,directory:w.path,issue:r,pr:l,includeDiff:u}).catch(e=>{let t=e instanceof Error?e.message:i(`session.newWorktree.error.sendGitHubContextFailed`);K.error(i(`session.newWorktree.error.sendGitHubContextFailed`),{description:t})}):n?.(w.path)}catch(e){let t=e instanceof Error?e.message:i(`session.newWorktree.error.createWorktreeFailed`);K.error(i(`session.newWorktree.error.createWorktreeFailed`),{description:t})}finally{Fe(!1)}},ct=e=>{v(e),J(e=>({...e,touched:!1,branchError:null,worktreeError:null}))},lt=e=>{if(!e){b(e=>({...e,linkedIssue:null,linkedPr:null,includePrDiff:!1,branchName:``}));return}if(e.type===`issue`){let t=e.item,n=`issue-${t.number}-${cn()}`;b(e=>({...e,linkedIssue:t,linkedPr:null,includePrDiff:!1,branchName:n,worktreeName:$(n),isSyncingWorktreeName:!0}))}else if(e.type===`pr`){let t=e.item;b(n=>({...n,linkedPr:t,linkedIssue:null,includePrDiff:e.includeDiff??!1,branchName:t.head,worktreeName:$(t.head),isSyncingWorktreeName:!0}))}},dt=p&&f?.connected===!0,pt=(_===`existing-branch`?!!x.selectedBranch&&!!x.worktreeName&&!q.branchError&&!q.worktreeError:!!Zn(y.branchName)&&!!y.worktreeName&&!q.branchError&&!q.worktreeError)&&!Pe,_t=()=>{b(e=>({...e,linkedIssue:null,linkedPr:null,branchName:``,includePrDiff:!1,isSyncingWorktreeName:!0}))},St=s&&(A.error||l.error)?(0,Q.jsxs)(`div`,{role:`alert`,className:`typography-micro text-destructive`,children:[(A.error||l.error)?.message,(0,Q.jsx)(H,{size:`xs`,variant:`ghost`,onClick:()=>{A.refetch(),l.refetch()},children:i(`remoteProjects.retry`)})]}):null,Ct=(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u?`flex-col w-full`:`flex-row items-center`),children:[St,(0,Q.jsx)(`div`,{className:G(`flex items-center gap-1.5 text-destructive`,u?`w-full justify-center order-first`:`mr-auto`),children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:G(`flex gap-2`,u&&`w-full`),children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,className:G(u&&`flex-1`),children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:G(`gap-1.5`,u&&`flex-1`),children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]});return(0,Q.jsxs)(Q.Fragment,{children:[u?(0,Q.jsx)(He,{id:`new-worktree-sheet-${d}`,open:e,onOpenChange:t,title:(0,Q.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold text-foreground`,children:i(`session.newWorktree.title`)}),ariaLabel:i(`session.newWorktree.title`),closeAriaLabel:i(`mobile.surface.closeAria`),resizeAriaLabel:i(`mobile.sessions.sheet.resizeAria`),children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,Q.jsxs)(Ve,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`overscroll-contain px-4 pb-4 pt-2`,children:[(0,Q.jsx)(`div`,{className:`w-full mb-4`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})}),(0,Q.jsxs)(`div`,{className:`space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>oe(!0),className:`flex-1 justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:x.selectedBranch?`text-foreground`:`text-muted-foreground`,children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]}),(0,Q.jsx)(ut,{open:ae,title:i(`session.newWorktree.selectBranch`),onClose:()=>oe(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:ge,children:[(0,Q.jsx)(st,{value:B,onChange:e=>ce(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Te&&De&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:Ce.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),oe(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,x.selectedBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col items-start gap-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:G(`h-8`,q.touched&&q.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:G(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(Y,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:G(`h-8`,q.touched&&q.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>se(!0),className:`w-full justify-between h-9`,children:[(0,Q.jsx)(`span`,{className:y.sourceBranch?`text-foreground`:`text-muted-foreground`,children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{name:`git-branch`,className:`h-4 w-4 text-muted-foreground`})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})}),(0,Q.jsx)(ut,{open:z,title:i(`session.newWorktree.selectSourceBranch`),onClose:()=>se(!1),children:(0,Q.jsxs)(`div`,{className:`space-y-4`,ref:_e,children:[(0,Q.jsx)(st,{value:le,onChange:e=>ue(e.target.value),placeholder:i(`session.newWorktree.searchBranches`),className:`h-8`}),T?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(`div`,{className:`px-2 py-8 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[Ee&&Oe&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(`session.newWorktree.matchingBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.matching.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e.value})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e.value?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))})]}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherLocal.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:e})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===e?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},e))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[(0,Q.jsx)(`div`,{className:`typography-small font-semibold text-foreground px-2`,children:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`)}),(0,Q.jsx)(`div`,{className:`space-y-1`,children:W.otherRemote.map(e=>(0,Q.jsx)(`button`,{onClick:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),se(!1)},className:G(`w-full text-left px-3 py-2.5 rounded-md transition-colors`,y.sourceBranch===`remotes/${e}`?`bg-interactive-selection text-interactive-selection-foreground`:`hover:bg-interactive-hover`),children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remotes/${e}`))})]})]})]})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Y,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]})]}),(0,Q.jsx)(`div`,{className:`shrink-0 border-t border-border/50 px-4 pb-3 pt-2`,children:Ct})]})}):(0,Q.jsx)(qe,{open:e,onOpenChange:t,children:(0,Q.jsxs)(Ge,{className:`max-w-lg max-h-[80vh] flex flex-col`,children:[(0,Q.jsx)(Ue,{className:`flex flex-row items-center justify-between`,children:(0,Q.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Q.jsxs)(Ke,{className:`flex items-center gap-2 shrink-0`,children:[(0,Q.jsx)(Y,{name:`git-branch`,className:`h-5 w-5`}),i(`session.newWorktree.title`)]}),(0,Q.jsx)(`div`,{className:`w-[280px] shrink-0`,children:(0,Q.jsx)(wt,{items:[{id:`new-branch`,label:i(`session.newWorktree.mode.newBranch`),icon:(0,Q.jsx)(Y,{name:`git-branch`,className:`h-3.5 w-3.5`})},{id:`existing-branch`,label:i(`session.newWorktree.mode.existingBranch`),icon:(0,Q.jsx)(Y,{name:`git-repository`,className:`h-3.5 w-3.5`})}],activeId:_,onSelect:e=>ct(e),variant:`active-pill`,layoutMode:`fit`,className:`w-full`})})]})}),(0,Q.jsxs)(`div`,{className:`flex-1 overflow-y-auto mt-2 space-y-6`,children:[_===`existing-branch`?(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.selectBranch`)}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)($e,{open:L,onOpenChange:R,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,x.selectedBranch?`text-foreground`:`text-muted-foreground`),children:x.selectedBranch||i(`session.newWorktree.chooseBranch`)}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,sideOffset:6,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:pe,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:B,onValueChange:ce,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Te&&De&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:Ce.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{S(t=>({...t,selectedBranch:e.value,worktreeName:$(e.label)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Te&&!De&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),Ce.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Te&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:Ce.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{S(t=>({...t,selectedBranch:e,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),Ce.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(Ce.otherLocal.length>0||Te)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Te?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:Ce.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{S(t=>({...t,selectedBranch:`remotes/${e}`,worktreeName:$(e)})),J(e=>({...e,touched:!0})),R(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),(0,Q.jsx)(H,{variant:`ghost`,size:`sm`,className:`h-8 w-8 px-0 shrink-0`,onClick:Ne,disabled:!Me||T,title:i(`session.newWorktree.fetchBranches`),children:T?(0,Q.jsx)(Y,{name:`loader-4`,className:`size-4 animate-spin`}):(0,Q.jsx)(Y,{name:`refresh`,className:`size-4`})})]})]}):(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.branchName`)}),_===`new-branch`&&dt&&(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,onClick:()=>I(!0),className:`gap-1.5 h-7`,children:[(0,Q.jsx)(Y,{name:`github`,className:`size-4 text-status-success`}),y.linkedIssue||y.linkedPr?i(`session.newWorktree.actions.change`):i(`session.newWorktree.actions.startFromGitHubIssuePr`)]})]}),(0,Q.jsx)(st,{value:y.branchName,onChange:e=>{b(t=>({...t,branchName:e.target.value,isSyncingWorktreeName:!0,linkedIssue:null,linkedPr:null}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.branchNamePlaceholder`),disabled:!!y.linkedPr,className:G(`h-8`,q.touched&&q.branchError&&`border-destructive`,y.linkedPr&&`bg-muted text-muted-foreground`)}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.usingPrBranch`,{branch:y.linkedPr.head})})]}),y.linkedIssue&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,Q.jsx)(Y,{name:`check`,className:`h-3.5 w-3.5 text-status-success`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:i(`session.newWorktree.fromIssue`,{number:y.linkedIssue.number,title:y.linkedIssue.title})})]})]}),(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground font-semibold`,children:i(`session.newWorktree.worktreeDirectory`)}),_!==`existing-branch`&&(0,Q.jsxs)(`button`,{onClick:()=>{let e=$(_===`new-branch`?y.branchName:``);b(t=>({...t,worktreeName:e,isSyncingWorktreeName:!0}))},disabled:!y.branchName||y.worktreeName===$(y.branchName),className:G(`flex items-center gap-1 typography-micro transition-colors px-1.5 py-0.5 rounded`,y.worktreeName===$(y.branchName)||!y.branchName?`text-muted-foreground/40 cursor-not-allowed`:`text-muted-foreground hover:text-foreground hover:bg-muted`),title:i(`session.newWorktree.resetToMatchBranchName`),children:[(0,Q.jsx)(Y,{name:`refresh`,className:`h-3 w-3`}),(0,Q.jsx)(`span`,{children:i(`session.newWorktree.actions.reset`)})]})]}),(0,Q.jsx)(st,{value:Xe.worktreeName,onChange:e=>{_===`new-branch`?b(t=>({...t,worktreeName:e.target.value,isSyncingWorktreeName:!1})):S(t=>({...t,worktreeName:e.target.value}))},onBlur:()=>J(e=>({...e,touched:!0})),placeholder:i(`session.newWorktree.worktreeDirectoryPlaceholder`),className:G(`h-8`,q.touched&&q.worktreeError&&`border-destructive`)})]}),_===`new-branch`&&!y.linkedPr&&(0,Q.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Q.jsx)(`label`,{className:`typography-ui-label text-foreground block font-semibold`,children:i(`session.newWorktree.sourceBranch`)}),(0,Q.jsxs)($e,{open:re,onOpenChange:ie,children:[(0,Q.jsx)(Ze,{asChild:!0,children:(0,Q.jsxs)(H,{variant:`outline`,size:`sm`,className:`h-9 min-w-[220px] max-w-full justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:G(`truncate`,y.sourceBranch?`text-foreground`:`text-muted-foreground`),children:y.sourceBranch||i(`session.newWorktree.selectSourceBranchPlaceholder`)}),(0,Q.jsx)(Y,{name:`arrow-down-s`,className:`h-4 w-4 shrink-0 text-muted-foreground`})]})}),(0,Q.jsx)(Qe,{align:`start`,portalToBody:!0,className:`w-[min(42rem,calc(100vw-2rem))] p-0 max-h-[min(var(--available-height),24rem)] flex flex-col overflow-hidden`,ref:me,children:(0,Q.jsxs)(Tn,{shouldFilter:!1,children:[(0,Q.jsx)(En,{placeholder:i(`session.newWorktree.searchBranches`),value:le,onValueChange:ue,onKeyDown:ve}),(0,Q.jsx)(Dn,{disableHorizontal:!0,children:T?(0,Q.jsx)(`div`,{className:`px-2 py-4 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.loadingBranches`)}):D.length===0&&k.length===0?(0,Q.jsx)(On,{children:i(`session.newWorktree.noBranchesFound`)}):(0,Q.jsxs)(Q.Fragment,{children:[Ee&&Oe&&(0,Q.jsx)(kn,{heading:i(`session.newWorktree.matchingBranches`),children:W.matching.map(e=>(0,Q.jsx)(jn,{value:e.value,onSelect:()=>{b(t=>({...t,sourceBranch:e.value})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e.label})},`${e.source}-${e.value}`))}),Ee&&!Oe&&(0,Q.jsx)(`div`,{className:`px-2 py-1 text-center typography-small text-muted-foreground`,children:i(`session.newWorktree.noMatchingBranches`)}),W.otherLocal.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[Ee&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherLocalBranches`:`session.newWorktree.localBranches`),children:W.otherLocal.map(e=>(0,Q.jsx)(jn,{value:e,onSelect:()=>{b(t=>({...t,sourceBranch:e})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`local-${e}`))})]}),W.otherRemote.length>0&&(0,Q.jsxs)(Q.Fragment,{children:[(W.otherLocal.length>0||Ee)&&(0,Q.jsx)(An,{}),(0,Q.jsx)(kn,{heading:i(Ee?`session.newWorktree.otherRemoteBranches`:`session.newWorktree.remoteBranches`),children:W.otherRemote.map(e=>(0,Q.jsx)(jn,{value:`remotes/${e}`,onSelect:()=>{b(t=>({...t,sourceBranch:`remotes/${e}`})),ie(!1)},children:(0,Q.jsx)(`span`,{className:`typography-small break-all`,children:e})},`remote-${e}`))})]})]})})]})})]}),y.sourceBranch&&(0,Q.jsx)(`div`,{className:`typography-micro text-muted-foreground`,children:i(`session.newWorktree.newBranchFromSource`,{source:y.sourceBranch})})]}),(y.linkedIssue||y.linkedPr)&&_===`new-branch`&&(0,Q.jsxs)(`div`,{className:`mt-2 px-2 py-1.5 rounded bg-muted/30`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Y,{name:`github`,className:`h-3.5 w-3.5 text-status-success shrink-0`}),y.linkedIssue&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.issueNumber`,{number:y.linkedIssue.number})}),y.linkedPr&&(0,Q.jsx)(`span`,{className:`typography-micro text-muted-foreground shrink-0`,children:i(`session.newWorktree.prNumber`,{number:y.linkedPr.number})}),(0,Q.jsx)(`span`,{className:`typography-micro text-foreground truncate flex-1`,children:y.linkedIssue?.title||y.linkedPr?.title}),(0,Q.jsx)(`a`,{href:y.linkedIssue?.url||y.linkedPr?.url,target:`_blank`,rel:`noopener noreferrer`,className:`text-muted-foreground hover:text-foreground shrink-0`,onClick:e=>e.stopPropagation(),children:(0,Q.jsx)(Y,{name:`external-link`,className:`h-3 w-3`})}),(0,Q.jsx)(`button`,{onClick:_t,className:`text-muted-foreground hover:text-foreground shrink-0 p-0.5 rounded hover:bg-muted transition-colors`,children:(0,Q.jsx)(Y,{name:`close`,className:`h-3.5 w-3.5`})})]}),y.linkedPr&&(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5 pl-5`,children:[(0,Q.jsxs)(`span`,{className:`typography-micro text-muted-foreground`,children:[y.linkedPr.head,` → `,y.linkedPr.base]}),y.includePrDiff&&(0,Q.jsx)(`span`,{className:`typography-micro px-1 py-0.5 rounded bg-status-success/10 text-status-success`,children:i(`session.newWorktree.includeDiffBadge`)})]})]})]}),(0,Q.jsxs)(We,{className:`mt-1 flex items-center justify-between`,children:[St,(0,Q.jsx)(`div`,{className:`flex items-center gap-1.5 text-destructive`,children:q.touched&&(q.branchError||q.worktreeError)&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{name:`error-warning`,className:`h-3.5 w-3.5`}),(0,Q.jsx)(`span`,{className:`typography-micro`,children:q.branchError||q.worktreeError})]})}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(H,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:Pe,children:i(`session.newWorktree.actions.cancel`)}),(0,Q.jsxs)(H,{size:`sm`,onClick:it,disabled:!pt||Pe,className:`gap-1.5`,children:[Pe&&(0,Q.jsx)(Y,{name:`loader-4`,className:`h-3.5 w-3.5 animate-spin`}),i(Pe?`session.newWorktree.actions.creating`:`session.newWorktree.actions.createWorktree`)]})]})]})]})}),(0,Q.jsx)(Yn,{projectId:m?.id,open:F,onOpenChange:I,onSelect:lt})]})}var ir=null,ar=new Set,or=()=>{for(let e of ar)e()},sr=e=>e===`chat`||e===`assistant`,cr=()=>ir,lr=e=>{ir!==e&&(ir=e,or())},ur=e=>{ir&&(e&&ir.surfaceID!==e||(ir=null,or()))},dr=(e,t)=>{if(e.transportIdentity!==t.transportIdentity||e.runtimeGeneration!==t.runtimeGeneration)throw Error(`chat-input-delivery-runtime-stale`)},fr=e=>{let t=e.options?.delivery===`steer`?`steer`:e.options?.delivery===`queue`?`queue`:void 0,n={...t?{delivery:t}:{},...e.options?.commitStagedMessageEdit===void 0?{}:{commitStagedMessageEdit:e.options.commitStagedMessageEdit},...e.options?.messageID?{messageID:e.options.messageID}:{},...e.options?.ticket?{ticket:e.options.ticket}:{}},r=e.options?.sessionId??e.sessionID??void 0;if(!r)return n;let i=e.options?.directoryHint===void 0?e.directory||null:e.options.directoryHint;return{...n,sessionId:r,directoryHint:i}},pr=(e,t,n={})=>({operation:t,surfaceID:e.surfaceID,transportIdentity:e.transportIdentity,runtimeGeneration:e.runtimeGeneration,sessionID:e.sessionID,directory:e.directory??``,draftKey:e.draftKey,deliveryTarget:e.deliveryTarget,...n}),mr=e=>{if(!e.active||!e.draftKey||!e.directory)return null;let t=e.activity?.phase??`idle`,n=e.activity?.canAbort??(t===`busy`||t===`retry`);return{send:async t=>{let n=pr(e,`send`,t);return await e.selection.flush(),e.kind===`secondary`&&await e.shortcuts.submit(),e.backend.send(n)},sendQueued:async(t,n={})=>{let{manual:r,...i}=n,a=pr(e,`send`,i),o=Qt(e);if(await e.selection.flush(),!o)throw Error(`chat-input-queue-scope-incomplete`);return e.backend.sendQueued({...a,queueItemID:t,manual:r,queueScope:o})},create:async()=>{let t=pr(e,`create`);return await e.selection.flush(),e.backend.create(t)},compact:async t=>{let n=pr(e,`compact`,t);return await e.selection.flush(),e.backend.compact(n)},abort:async()=>{let t=pr(e,`abort`);return await e.selection.flush(),e.backend.abort(t)},queueScope:Qt(e),canAbort:n,canQueue:t===`busy`||t===`retry`,allowsCommand:t=>Gt(e,{name:t,source:`yuri`}),shortcut:async(t,n=1)=>{if(e.kind===`secondary`){t===`cycle`?await e.shortcuts.cycle(n):t===`new`?await e.shortcuts.new():t===`abort`?await e.shortcuts.abort():await e.shortcuts.submit();return}if(t===`abort`){let t=pr(e,`abort`);await e.selection.flush(),await e.backend.abort(t);return}if(t===`new`){let t=pr(e,`create`);await e.selection.flush(),await e.backend.create(t);return}t!==`submit`&&await e.shortcuts?.cycle(n)},resources:e.resources??null}},hr=e=>e.type===`tool`&&e.metadata?.providerExecuted===!0,gr=e=>{if(e.type!==`tool`)return!1;let t=e.state;return t?.status===`error`&&t.metadata?.interrupted===!0},_r=e=>e.type!==`tool`||hr(e)?!1:!gr(e),vr=e=>{let t=0;for(let n of e)_r(n)&&(t+=1);return t},yr=(e,t)=>e===`stop`&&vr(t)===0,br=e=>{if(e.type!==`text`||e.synthetic===!0)return!1;let t=e.text;return typeof t==`string`&&Tt(t)},xr=e=>{if(vr(e)!==0)return-1;for(let t=e.length-1;t>=0;--t){let n=e[t];if(br(n))return t;if(n.type===`tool`||n.type===`reasoning`||n.type===`file`||n.type===`agent`||n.type===`subtask`)break}return-1},Sr=(e,t,n)=>{if(n||!yr(e,t))return!1;for(let e of t)if(br(e))return!0;return!1},Cr=e=>e===`streaming`||e===`cooldown`,wr=e=>e.parts.some(br),Tr=e=>Cr(e.streamPhase)?wr(e):!1,Er=e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``},Dr=e=>{let t=e?.type;return t===`compaction`?!g(e):t===`text`&&Er(e).trim()===`/compact`},Or=e=>e?e.some(e=>Dr(e)):!1,kr=e=>Or(e.parts),Ar=e=>e?Or(e.sourceParts)||Or(e.parts):!1,jr=e=>{if(!kr(e))return e;let t=!1,n=e.parts.map(e=>e?.type!==`compaction`||g(e)?e:(t=!0,{type:`text`,text:`/compact`})),r=e.info.clientRole!==`user`;return!t&&!r?e:{...e,info:r?{...e.info,clientRole:`user`}:e.info,parts:t?n:e.parts}},Mr=e=>{let t=Et(e.parts);return t.length===e.parts.length?e:{...e,parts:t}},Nr=new WeakMap,Pr=e=>{let t=Nr.get(e);if(t)return t;let n=jr(Mr(e)),r=n.parts,i=Ce(r),a=i===r?n:{...n,parts:i,sourceParts:r};return Nr.set(e,a),a},Fr={activity:`idle`,hasWorkingContext:!1,hasActiveTools:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,lifecyclePhase:null,statusText:null,isGenericStatus:!0,isWaitingForPermission:!1,canAbort:!1,compactionDeadline:null,activePartType:void 0,activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:null,turnStartedAt:void 0},Ir=[],Lr=`\0`,Rr=new Set([`edit`,`write`,`apply_patch`]),zr={read:`chat.assistantStatus.readingFile`,write:`chat.assistantStatus.writingFile`,edit:`chat.assistantStatus.editingFile`,apply_patch:`chat.assistantStatus.applyingPatch`,bash:`chat.assistantStatus.runningCommand`,grep:`chat.assistantStatus.searchingContent`,glob:`chat.assistantStatus.findingFiles`,list:`chat.assistantStatus.listingDirectory`,task:`chat.assistantStatus.delegatingTask`,webfetch:`chat.assistantStatus.fetchingUrl`,websearch:`chat.assistantStatus.searchingWeb`,codesearch:`chat.assistantStatus.webCodeSearch`,todowrite:`chat.assistantStatus.updatingTodos`,todoread:`chat.assistantStatus.readingTodos`,skill:`chat.assistantStatus.learningSkill`,question:`chat.assistantStatus.askingQuestion`,execute:`chat.assistantStatus.executing`,session_rename:`chat.assistantStatus.renamingSession`,session_move:`chat.assistantStatus.movingSession`,browser:`chat.assistantStatus.usingBrowser`},Br=[`chat.assistantStatus.working`,`chat.assistantStatus.processing`,`chat.assistantStatus.preparing`,`chat.assistantStatus.warmingUp`,`chat.assistantStatus.gearsTurning`,`chat.assistantStatus.computing`,`chat.assistantStatus.calculating`,`chat.assistantStatus.analyzing`,`chat.assistantStatus.wheelsSpinning`,`chat.assistantStatus.calibrating`,`chat.assistantStatus.synthesizing`,`chat.assistantStatus.connectingDots`,`chat.assistantStatus.inspectingLogic`,`chat.assistantStatus.weighingOptions`],Vr=(e,t)=>{let n=zr[Be(e)];return n?t(n):t(`chat.assistantStatus.usingTool`,{tool:e})},Hr=e=>{let t=0;for(let n=0;n<e.length;n+=1)t=(t<<5)-t+e.charCodeAt(n)|0;return Math.abs(t)},Ur=(e,t)=>t(Br[Hr(e)%Br.length]??`chat.assistantStatus.working`),Wr=(e,t,n)=>{let r,i;if(!N(e))for(let t=e.length-1;t>=0;--t){let n=e[t];if(n)switch(n.type){case`reasoning`:{let e=n.time??Xr(n);(!e||e.end===void 0)&&!r&&(r=`reasoning`);break}case`tool`:{let e=n.state?.status;if((e===`running`||e===`pending`)&&!r){let e=Be(Zr(n));Rr.has(e)?(r=`editing`,i=e):(r=`tool`,i=e)}break}case`text`:{let e=Yr(n)??``;if(typeof e==`string`&&e.trim().length>0){let e=Xr(n);(!e||e.end===void 0)&&!r&&(r=`text`)}break}}}let a=r===void 0,o=r===`editing`?n(`chat.assistantStatus.editingFile`):r===`tool`&&i?Vr(i,n):r===`reasoning`?n(`chat.assistantStatus.thinking`):r===`text`?n(`chat.assistantStatus.composing`):Ur(t,n);return{activePartType:r,activeToolName:i,statusText:o,isGenericStatus:a}},Gr=e=>[e.activePartType??``,e.activeToolName??``,e.statusText,e.isGenericStatus?`1`:`0`].join(Lr),Kr=e=>{let[t,n,r=`working`,i]=e.split(Lr);return{activePartType:t===`text`||t===`tool`||t===`reasoning`||t===`editing`?t:void 0,activeToolName:n||void 0,statusText:r,isGenericStatus:i===`1`}},qr=e=>e.type===`reasoning`,Jr=e=>e.type===`text`,Yr=e=>{if(Jr(e))return e.text;let t=e;if(typeof t.text==`string`)return t.text;if(typeof t.content==`string`)return t.content;if(typeof t.value==`string`)return t.value},Xr=e=>(Jr(e)||qr(e),e.time),Zr=e=>{if(e.tool)return e.tool;let t=e;return typeof t.name==`string`?t.name:`tool`};function Qr(e,t){let{t:n}=ze(),r=U(e=>e.currentSessionId),i=U(e=>e.currentSessionDirectory),a=e??r,o=t??i,s=ue(e=>!!(a&&e.session_execution_recovery[a]),o??void 0),c=X.useMemo(()=>e=>a?e.pendingSendMessageIDs.get(a)??null:null,[a]),l=U(c),u=Ne(a??``,o??void 0),d=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`assistant`)return{id:t.id,index:e,finish:t.finish,error:t.error,isCompaction:t.clientRole===`compaction`,startedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,finish:void 0,error:void 0,isCompaction:!1,startedAt:void 0}},[u]),f=d.id,p=X.useMemo(()=>{for(let e=u.length-1;e>=0;e--){let t=u[e];if(t.role===`user`&&!b(t))return{id:t.id,index:e,turnStartedAt:Number.isFinite(t.time.created)?t.time.created:void 0}}return{id:null,index:-1,turnStartedAt:void 0}},[u]),m=p.id,h=ge(f??``,o??void 0,a??void 0),g=ge(m??``,o??void 0,a??void 0),_=!!m&&Or(g),v=d.isCompaction&&d.index>p.index?h.find(e=>e.type===`compaction`):void 0,y=v?.reason===`manual`?d.startedAt:p.turnStartedAt,x=!!(f&&d.index>p.index&&(v?v.status===`failed`||v.reason===`manual`&&v.status===`completed`:Sr(d.finish,h,d.error))),S=X.useMemo(()=>{let e=`${a??``}:${f??``}`;return Gr(Wr(f&&!d.error&&d.index>p.index?h:Ir,e,n))},[a,f,d.error,d.index,p.index,h,n]),C=Oe(a??``,o??void 0),w=Te(a??``,o??void 0),T=X.useMemo(()=>e=>a?e.sessionAbortFlags?.get(a)??null:null,[a]),ee=U(T),{phase:E,isWorking:D}=nn(a,o??void 0),O=!!(d.error&&d.index>p.index),k=be(a??``,o??void 0),te=k?.type===`retry`?k.attempt:void 0,A=k?.type===`retry`?k.next:void 0,j=X.useMemo(()=>Kr(S),[S]),M=X.useMemo(()=>{let e=!!(ee&&!ee.acknowledged);return{wasAborted:e,abortActive:e}},[ee]),N=X.useMemo(()=>{if(s)return{...Fr,isRecovering:!0,canAbort:D};if(O&&E!==`retry`)return{...Fr,isTurnSettled:!0,canAbort:D};if(M.wasAborted)return{...Fr,wasAborted:!0,abortActive:M.abortActive,activity:`idle`,hasWorkingContext:!1,isWorking:!1,isStreaming:!1,isCooldown:!1,statusText:null,canAbort:!1,retryInfo:null};if(x)return{...Fr,isComplete:v?.status!==`failed`,isTurnSettled:!0,turnStartedAt:y};let e=D,t=E===`busy`,r=E===`retry`,i=e&&(_||v?.status===`running`),a=`idle`;e&&(a=!i&&(j.activePartType===`tool`||j.activePartType===`editing`)?`tooling`:`streaming`);let o=r?{attempt:te,next:A,message:k?.type===`retry`?k.message:void 0}:null;return{activity:a,hasWorkingContext:e,hasActiveTools:!i&&(j.activePartType===`tool`||j.activePartType===`editing`),isWorking:e,isStreaming:t,isCooldown:!1,lifecyclePhase:t?`streaming`:null,statusText:e?i?n(`chat.assistantStatus.compacting`):j.statusText:null,isGenericStatus:!e||!i&&j.isGenericStatus,isWaitingForPermission:!1,canAbort:e,compactionDeadline:null,activePartType:e&&!i?j.activePartType:void 0,activeToolName:e&&!i?j.activeToolName:void 0,wasAborted:!1,abortActive:!1,lastCompletionId:null,isComplete:!1,isTurnSettled:!1,retryInfo:o,turnStartedAt:y}},[s,O,E,D,x,_,v?.status,y,j,M,te,A,k,n]);return{forming:X.useMemo(()=>({isActive:!s&&!O&&D&&j.activePartType===`text`,characterCount:0}),[s,O,D,j.activePartType]),working:X.useMemo(()=>{if(s||N.wasAborted||N.abortActive)return N;if(l)return{...N,activity:`streaming`,hasWorkingContext:!0,isWorking:!0,isStreaming:!0,isCooldown:!1,lifecyclePhase:`streaming`,statusText:n(`chat.assistantStatus.sendingMessage`),isGenericStatus:!1,isWaitingForPermission:!1,canAbort:!0,activePartType:void 0,activeToolName:void 0,isComplete:!1,isTurnSettled:!1,retryInfo:null};let e=C.length>0,t=w.length>0;return!e&&!t?N:t?{...N,statusText:null,isWorking:!1,hasWorkingContext:!1,hasActiveTools:!1,canAbort:!1,activePartType:void 0,activeToolName:void 0,retryInfo:null}:{...N,statusText:n(`chat.assistantStatus.waitingForPermission`),isWaitingForPermission:!0,canAbort:!1,retryInfo:null}},[s,N,l,C,w,n])}}var $r=`--yuri-mobile-header-collapse`,ei=e=>e.closest(`.mobile-chat-screen`)?.querySelector(`:scope > [data-yuri-collapsible-header="true"]`)??null,ti=e=>{e.style.removeProperty($r),delete e.dataset.yuriHeaderCollapsePhase,delete e.dataset.yuriHeaderCollapseRest},ni=(e,t,n)=>{let r=String(t.progress),i=t.phase,a=t.rest===`compact`?`collapsed`:`expanded`;return n?.phase!==i&&(e.dataset.yuriHeaderCollapsePhase=i,i===`snapping`&&n&&n.phase!==`snapping`&&e.offsetWidth),n?.progress!==r&&e.style.setProperty($r,r),n?.rest!==a&&(e.dataset.yuriHeaderCollapseRest=a),{progress:r,phase:i,rest:a}},ri=e=>{let t=e.startsWith(`#`)?e.slice(1):e;if(!t)return null;let n=t.match(/^turn-(.+)$/);if(n?.[1])return{kind:`turn`,id:n[1]};let r=t.match(/^message-(.+)$/);return r?.[1]?{kind:`message`,id:r[1]}:null},ii=(e,t,n)=>{if(n===0||e.length===0)return{kind:`noop`};let r=t?e.indexOf(t):e.length-1,i=(r>=0?r:e.length-1)+n;if(i>=e.length)return{kind:`resume`};let a=e[Math.max(0,i)];return a?{kind:`turn`,turnId:a}:{kind:`noop`}},ai=e=>{if(typeof window>`u`)return;let t=e?`#${e}`:``,n=`${window.location.pathname}${window.location.search}${t}`;window.history.replaceState(window.history.state,``,n),e&&window.dispatchEvent(new HashChangeEvent(`hashchange`))},oi=e=>{e&&ai(`message-${e}`)},si=e=>{let t=(0,Z.c)(29),{sessionId:n,turnIds:r,activeTurnId:i,scrollToTurn:a,scrollToMessage:o,resumeToBottom:s}=e,c=X.useRef(r),l=X.useRef(i),u,d;t[0]===r?(u=t[1],d=t[2]):(u=()=>{c.current=r},d=[r],t[0]=r,t[1]=u,t[2]=d),X.useEffect(u,d);let f,p;t[3]===i?(f=t[4],p=t[5]):(f=()=>{l.current=i},p=[i],t[3]=i,t[4]=f,t[5]=p),X.useEffect(f,p);let m;t[6]===a?m=t[7]:(m=async(e,t)=>e?(t?.updateHash!==!1&&ai(`turn-${e}`),a(e,{behavior:t?.behavior})):!1,t[6]=a,t[7]=m);let h=m,g;t[8]===o?g=t[9]:(g=async(e,t)=>e?(t?.updateHash!==!1&&ai(`message-${e}`),o(e,{behavior:t?.behavior})):!1,t[8]=o,t[9]=g);let _=g,v;t[10]!==s||t[11]!==h?(v=async(e,t)=>{let n=c.current,r=ii(n,l.current,e);if(r.kind===`noop`)return e===0;if(r.kind===`resume`){if(t?.resumePastEnd===!1){let e=n[n.length-1];return e?h(e,{behavior:`auto`}):!1}return ai(null),s(),!0}return h(r.turnId,{behavior:`auto`})},t[10]=s,t[11]=h,t[12]=v):v=t[12];let y=v,b;t[13]===s?b=t[14]:(b=()=>{ai(null),s()},t[13]=s,t[14]=b);let x=b,S;t[15]!==_||t[16]!==h||t[17]!==n?(S=()=>{if(!n||typeof window>`u`)return;let e=()=>{let e=ri(window.location.hash);if(e){if(e.kind===`turn`){h(e.id,{behavior:`auto`,updateHash:!1});return}_(e.id,{behavior:`auto`,updateHash:!1})}};return e(),window.addEventListener(`hashchange`,e),()=>{window.removeEventListener(`hashchange`,e)}},t[15]=_,t[16]=h,t[17]=n,t[18]=S):S=t[18];let C;t[19]!==_||t[20]!==h||t[21]!==n||t[22]!==r.length?(C=[n,_,h,r.length],t[19]=_,t[20]=h,t[21]=n,t[22]=r.length,t[23]=C):C=t[23],X.useEffect(S,C);let w;return t[24]!==x||t[25]!==y||t[26]!==_||t[27]!==h?(w={scrollToTurnId:h,scrollToMessageId:_,scrollByTurnOffset:y,resumeToLatest:x},t[24]=x,t[25]=y,t[26]=_,t[27]=h,t[28]=w):w=t[28],w},ci=[0,200,400],li=e=>{let t=(0,Z.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=G(`inline-flex`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=ci.map(ui),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Q.jsxs)(Q.Fragment,{children:[`\xA0`,(0,Q.jsx)(`span`,{className:r,"aria-hidden":`true`,children:i})]}),t[3]=r,t[4]=a),a};function ui(e){return(0,Q.jsx)(`span`,{className:`animate-busy-pulse`,style:{animationDelay:`${e}ms`},children:`.`},e)}export{En as A,Xt as B,sr as C,Tn as D,Ln as E,wn as F,Ut as G,Vt as H,cn as I,qt as J,Yt as K,rn as L,Dn as M,Cn as N,On as O,Sn as P,Ot as Q,an as R,cr as S,nr as T,$t as U,Gt as V,Zt as W,Bt as X,Jt as Y,Dt as Z,Tr as _,ti as a,fr as b,Qr as c,wr as d,vr as f,br as g,yr as h,$r as i,jn as j,kn as k,Pr as l,Sr as m,oi as n,ni as o,xr as p,Ht as q,si as r,ei as s,li as t,Ar as u,dr as v,lr as w,ur as x,mr as y,nn as z};
|