@yuriai/web 0.3.8-beta.13 → 0.3.8-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/bin/cli.test.js +41 -4
  2. package/bin/lib/DOCUMENTATION.md +3 -2
  3. package/bin/lib/cli-args.js +1 -1
  4. package/bin/lib/commands-connect-url.js +2 -23
  5. package/bin/lib/commands-lifecycle.js +1 -0
  6. package/bin/lib/commands-serve.js +28 -23
  7. package/bin/lib/commands-update.js +1 -0
  8. package/bin/lib/commands-update.test.js +23 -3
  9. package/dist/assets/{AgentAvatar-BY1Uar-W.js → AgentAvatar-BSBHv-65.js} +1 -1
  10. package/dist/assets/{AgentSelector-BTHcN1FV.js → AgentSelector-DaT_IvwI.js} +1 -1
  11. package/dist/assets/{ArchivedSessionsDialog-DSnawUO5.js → ArchivedSessionsDialog-C3Yn2T92.js} +1 -1
  12. package/dist/assets/{AssistantConversationSurface-Cfeh2vaU.js → AssistantConversationSurface-BnoGpvaw.js} +3 -3
  13. package/dist/assets/{AssistantSessionCard-DEw5qpOl.js → AssistantSessionCard-D4cDykNE.js} +2 -2
  14. package/dist/assets/{AssistantUnreadBadge-eHop7KFr.js → AssistantUnreadBadge-kuD0NRB3.js} +1 -1
  15. package/dist/assets/{AssistantView-BCzhUUR8.js → AssistantView-C-UaXYpz.js} +1 -1
  16. package/dist/assets/{AssistantWorkingAvatar-lw3h_DYH.js → AssistantWorkingAvatar-VQGkgNuo.js} +1 -1
  17. package/dist/assets/{AssistantsSettingsPage-DngM9eGO.js → AssistantsSettingsPage-D01452ix.js} +1 -1
  18. package/dist/assets/{BinaryFileFallback-CtqRJVb8.js → BinaryFileFallback-Darn77R4.js} +1 -1
  19. package/dist/assets/{BtwPanel-DbifCGwT.js → BtwPanel-CgSxuUbP.js} +1 -1
  20. package/dist/assets/{BusyDots-Bk6p5cua.js → BusyDots-CTw2sYb1.js} +1 -1
  21. package/dist/assets/{ChatContainer-CRupjnre.js → ChatContainer-DQ2aAjYQ.js} +4 -4
  22. package/dist/assets/{ChatView-B5ahnMA6.js → ChatView-BfrJ1ZTv.js} +1 -1
  23. package/dist/assets/{DiagramView-CyXHjgFa.js → DiagramView-BcD_t3y-.js} +1 -1
  24. package/dist/assets/{DiffView-DFujkn2g.js → DiffView-DyYip1lP.js} +1 -1
  25. package/dist/assets/{DiffViewToggle-XA_EBPXw.js → DiffViewToggle-Da3vQFP9.js} +1 -1
  26. package/dist/assets/{ErrorBoundary-DeatD_L5.js → ErrorBoundary-D6SF_urL.js} +1 -1
  27. package/dist/assets/{FadeInOnReveal-iCjNPFx8.js → FadeInOnReveal-DJrSq3fM.js} +1 -1
  28. package/dist/assets/{GuiPluginMount-qoJ1nHjE.js → GuiPluginMount-BD0R2vTk.js} +1 -1
  29. package/dist/assets/{GuiPluginPage-BslRq2f5.js → GuiPluginPage-DGysjIM8.js} +1 -1
  30. package/dist/assets/{GuiPluginSurface-TGUasA-U.js → GuiPluginSurface-CIbn8VvC.js} +1 -1
  31. package/dist/assets/{GuiPluginTitlebarItems-BUf_4msf.js → GuiPluginTitlebarItems-BYCWC7Ia.js} +1 -1
  32. package/dist/assets/{GuiPluginWindow-Dt4kKaAD.js → GuiPluginWindow-cCmvyMMm.js} +1 -1
  33. package/dist/assets/{Icon-BJy61Jon.js → Icon-DrsaL1yC.js} +1 -1
  34. package/dist/assets/{ImageLoadingPlaceholder-trHWUJt-.js → ImageLoadingPlaceholder-Br3hw4E6.js} +1 -1
  35. package/dist/assets/{LoadingImage-xhLZPhd9.js → LoadingImage-BBQSz8J1.js} +1 -1
  36. package/dist/assets/{MarkdownRenderer-DwwztSrL.js → MarkdownRenderer-CGgHX4n3.js} +2 -2
  37. package/dist/assets/{MarkdownRendererImpl-BbwqJp63.js → MarkdownRendererImpl-CiuncbTc.js} +1 -1
  38. package/dist/assets/{MarkstreamRendererImpl-Bsvs0yhW.js → MarkstreamRendererImpl-DT9tgQ6L.js} +1 -1
  39. package/dist/assets/{MobileAssistantSettingsPage-NZI62Ey6.js → MobileAssistantSettingsPage-DIilwadN.js} +1 -1
  40. package/dist/assets/{MobileAssistantTab-DIrHBsL_.js → MobileAssistantTab-CTyT31et.js} +1 -1
  41. package/dist/assets/{MobileBtwPage-H1GyfL02.js → MobileBtwPage-Buz1Kf7W.js} +1 -1
  42. package/dist/assets/{MobileChangesSurface-DiZ9RsZk.js → MobileChangesSurface-DsnPRa6f.js} +1 -1
  43. package/dist/assets/{MobileChatScreen-BKtbId56.js → MobileChatScreen-DRNBeviQ.js} +1 -1
  44. package/dist/assets/{MobileDetailNavigation-BWWiAn9H.js → MobileDetailNavigation-_0qkfML1.js} +1 -1
  45. package/dist/assets/{MobileFilesSurface-DSX2LTmx.js → MobileFilesSurface-CKHljNp8.js} +2 -2
  46. package/dist/assets/{MobileHtmlNetworkBoundary-DJy9Q8VV.js → MobileHtmlNetworkBoundary-BMTmOSuT.js} +2 -2
  47. package/dist/assets/{MobileOverlayPanel-XqAYxe55.js → MobileOverlayPanel-cwgcgCxI.js} +1 -1
  48. package/dist/assets/{MobileResizableSheet-G0ftF_2y.js → MobileResizableSheet-DKpNzqfc.js} +1 -1
  49. package/dist/assets/{MobileSettingsTab-gKqFXYC4.js → MobileSettingsTab-BQnzgATX.js} +1 -1
  50. package/dist/assets/{MobileShareBridge-C0xW2_n0.js → MobileShareBridge-1O5JUriq.js} +1 -1
  51. package/dist/assets/{MobileSurface-DZnaMpfo.js → MobileSurface-nz7712mA.js} +1 -1
  52. package/dist/assets/{MobileTabPageHeader-CsmuqMP6.js → MobileTabPageHeader-B0_vB3Tg.js} +1 -1
  53. package/dist/assets/{ModelLogo-B50mkTPp.js → ModelLogo-CwKqpjSR.js} +1 -1
  54. package/dist/assets/{ModelSelector-CdBPSXZ2.js → ModelSelector-C0LV5Vo7.js} +1 -1
  55. package/dist/assets/{MultiRunWindow-CmbU5iWH.js → MultiRunWindow-C0muk8Ec.js} +1 -1
  56. package/dist/assets/{OnboardingScreen-DjVB5jqP.js → OnboardingScreen-T4NAO5Nc.js} +1 -1
  57. package/dist/assets/{OverlayScrollbar-CLu72YSm.js → OverlayScrollbar-CZ86VwiO.js} +1 -1
  58. package/dist/assets/{PierreDiffViewer-CIwYEUv3.js → PierreDiffViewer-0MHiuNI_.js} +1 -1
  59. package/dist/assets/{ProviderLogo-DxffoDzo.js → ProviderLogo-BRhDuhtX.js} +1 -1
  60. package/dist/assets/{RemoteAssistantSessionCard-CrVXWVNC.js → RemoteAssistantSessionCard-BAbf5uBX.js} +1 -1
  61. package/dist/assets/{RemoteDesktopPanel-CW3VO7kH.js → RemoteDesktopPanel-vKqD4HzW.js} +1 -1
  62. package/dist/assets/{ScheduledTasksDialog-CH-yxh54.js → ScheduledTasksDialog-BMoHLXYW.js} +1 -1
  63. package/dist/assets/{ScrollableOverlay-_-c4eChV.js → ScrollableOverlay-CFjKY4OJ.js} +1 -1
  64. package/dist/assets/{SettingsGroup-BEuuCHe_.js → SettingsGroup-5yNRBDTj.js} +1 -1
  65. package/dist/assets/{SettingsView-DTzFUwvv.js → SettingsView-4rxkTHGv.js} +1 -1
  66. package/dist/assets/{SettingsWindow-I98QE5aS.js → SettingsWindow-D5JUctj6.js} +1 -1
  67. package/dist/assets/{SetupTourDialog-3ejWHEJz.js → SetupTourDialog-Bp8wlcPT.js} +1 -1
  68. package/dist/assets/{SyncActions-BJmY7x7G.js → SyncActions-DiGfo7cp.js} +1 -1
  69. package/dist/assets/{TerminalView-B2I_vByC.js → TerminalView-BwradFZm.js} +1 -1
  70. package/dist/assets/{TextSelectionMenu-BvRgpSxU.js → TextSelectionMenu-DcQCHZnp.js} +1 -1
  71. package/dist/assets/{ToolOutputDialog-DSfZp0SO.js → ToolOutputDialog-D_Kl-Bc5.js} +1 -1
  72. package/dist/assets/{assistantMessagePreview-gyTcahWF.js → assistantMessagePreview-a6gzdseQ.js} +1 -1
  73. package/dist/assets/{assistantQueries-DDeccc-m.js → assistantQueries-6GJP0jCO.js} +1 -1
  74. package/dist/assets/{auto-read-context-D2UX6oXY.js → auto-read-context-Dov0luVf.js} +1 -1
  75. package/dist/assets/{capgoAdapter-BucnEwMn.js → capgoAdapter-CVPNGTnk.js} +1 -1
  76. package/dist/assets/{card-C39FDK7q.js → card-DjqjGN8X.js} +1 -1
  77. package/dist/assets/{chatUpwardIntent-uv8XbV0r.js → chatUpwardIntent-uWd0ddoK.js} +1 -1
  78. package/dist/assets/{checkbox-C3kPdnVf.js → checkbox-BIU2MT0K.js} +1 -1
  79. package/dist/assets/{collapsible-BYAyt7tx.js → collapsible-B2X0QDoQ.js} +1 -1
  80. package/dist/assets/{connection-hint-zKPzQOm-.js → connection-hint-Ca1b_CjA.js} +1 -1
  81. package/dist/assets/{context-menu-D7tWqAhJ.js → context-menu-C-FLHb_6.js} +1 -1
  82. package/dist/assets/{diagram-qoeZRJBj.js → diagram-CJeSxjCC.js} +1 -1
  83. package/dist/assets/{dialog-B9djOKHd.js → dialog-DnZWrDDM.js} +1 -1
  84. package/dist/assets/{dropdown-menu-Bg9fqXHM.js → dropdown-menu-CZWYeFpO.js} +1 -1
  85. package/dist/assets/{fileMentionTouchSelection-DBohWG86.js → fileMentionTouchSelection-Bwr_ZfU3.js} +1 -1
  86. package/dist/assets/{gitApi-D7UHXMTh.js → gitApi-CT9_Fyh4.js} +1 -1
  87. package/dist/assets/{icons-BJ-yKguF.js → icons-B6gke_oc.js} +1 -1
  88. package/dist/assets/{input-DgT2vL85.js → input-DSY3Mg4G.js} +1 -1
  89. package/dist/assets/{insertionBoundaries-CNdm9xws.js → insertionBoundaries-C1ACCndo.js} +1 -1
  90. package/dist/assets/{kbd-DTXNf7DP.js → kbd-U9NdVaVr.js} +1 -1
  91. package/dist/assets/{main-BYm7jJf7.js → main-Bd77IVQE.js} +2 -2
  92. package/dist/assets/{main-CKpcvsKp.js → main-HeMyVqAF.js} +4 -4
  93. package/dist/assets/{markdownHeightCache-BthXvgH2.js → markdownHeightCache-BhpqKZQB.js} +1 -1
  94. package/dist/assets/{mcpQueries-yp0LLKop.js → mcpQueries-BInByFPg.js} +1 -1
  95. package/dist/assets/{miniChat-CsVxurBz.js → miniChat-Brvg2KsE.js} +2 -2
  96. package/dist/assets/{mobile-Bnn1Av6s.js → mobile-BOuoV895.js} +2 -2
  97. package/dist/assets/{mobileBackNavigation-Dc2Ms_yz.js → mobileBackNavigation-CUoYXnE0.js} +1 -1
  98. package/dist/assets/mobileConnections-DDPYhrR6.js +2 -0
  99. package/dist/assets/{multirun-YneUyzFb.js → multirun-h_L8IaS5.js} +1 -1
  100. package/dist/assets/{native-config-CHbBpTtL.js → native-config-DJLqkXGY.js} +1 -1
  101. package/dist/assets/{nativeComposerCover-BvxREQD3.js → nativeComposerCover-Cnky140u.js} +1 -1
  102. package/dist/assets/{navigation-BcMxWKOy.js → navigation-b6ZJiTeF.js} +1 -1
  103. package/dist/assets/{openRemoteProjectSession-Bj1JqTJL.js → openRemoteProjectSession-C85euMiR.js} +1 -1
  104. package/dist/assets/{openSessionFromDeepLink-RIdfYNVc.js → openSessionFromDeepLink-CDs-skAS.js} +2 -2
  105. package/dist/assets/{pluginPresentation-TcpIXFdR.js → pluginPresentation-upXqjrId.js} +1 -1
  106. package/dist/assets/{pwa-B0DzO_Wm.js → pwa-BSv0q2V7.js} +1 -1
  107. package/dist/assets/{queue-abort-optimistic-9kcDZ3sO.js → queue-abort-optimistic-CkmS8yTs.js} +1 -1
  108. package/dist/assets/{reference-history-Bpfp7nl-.js → reference-history-BfwrDjks.js} +1 -1
  109. package/dist/assets/{remoteSessionReference-CzFqDMfO.js → remoteSessionReference-DRv5U8a9.js} +1 -1
  110. package/dist/assets/{renderElectronMiniChatApp-BMxJmIaf.js → renderElectronMiniChatApp-YbsPMg7E.js} +2 -2
  111. package/dist/assets/{renderMobileApp-g6VIdksz.js → renderMobileApp-QD_41cfk.js} +4 -4
  112. package/dist/assets/{runtimeConfig-CQuMlWSU.js → runtimeConfig-BT-o1J3r.js} +1 -1
  113. package/dist/assets/{runtimeEndpointReset-wwLirdka.js → runtimeEndpointReset-CltKCEAq.js} +2 -2
  114. package/dist/assets/{select-B0A2UPYI.js → select-DNrc5_kl.js} +1 -1
  115. package/dist/assets/{sessionLookup-CDS-3lqX.js → sessionLookup-DNi6Sfyx.js} +1 -1
  116. package/dist/assets/{sessionOwnership-C6kEL9vi.js → sessionOwnership-B4NyrdiS.js} +1 -1
  117. package/dist/assets/{shortcuts-DQjWb6-B.js → shortcuts-B0XmqH9X.js} +1 -1
  118. package/dist/assets/{sortable-tabs-strip-CIJ_GrzH.js → sortable-tabs-strip-DqPiLPN2.js} +1 -1
  119. package/dist/assets/{speechSettingsQueries-BdZipozF.js → speechSettingsQueries-CVATB1QU.js} +1 -1
  120. package/dist/assets/{switch-BTd4fb-u.js → switch-COh9mZOL.js} +1 -1
  121. package/dist/assets/{textarea-BMLYkY1C.js → textarea-DnOdSgZM.js} +1 -1
  122. package/dist/assets/{tooltip-C7bh8-oj.js → tooltip-wFf92wqJ.js} +1 -1
  123. package/dist/assets/{truncated-path-D4zPMNfI.js → truncated-path-CNuLLJYq.js} +1 -1
  124. package/dist/assets/{types-CAv5YLRJ.js → types-C4KUivVG.js} +1 -1
  125. package/dist/assets/{ui-C93TriAS.js → ui-BPOP32rM.js} +4 -4
  126. package/dist/assets/{useAppFontEffects-C__2VHhM.js → useAppFontEffects-BxzLAPb0.js} +2 -2
  127. package/dist/assets/{useDesktopWindowControlsLayout-BFZelO28.js → useDesktopWindowControlsLayout-DJTBs9Ai.js} +1 -1
  128. package/dist/assets/{useEffectiveDirectory-ClRxkgy2.js → useEffectiveDirectory-DleT4CpD.js} +1 -1
  129. package/dist/assets/{useGitStore-DDE7AUsk.js → useGitStore-DTlP-L0a.js} +1 -1
  130. package/dist/assets/{useInlineCommentDraftStore-oj1WmZIi.js → useInlineCommentDraftStore-Wde2bT5p.js} +1 -1
  131. package/dist/assets/{useMcpConfigStore-DbltISt3.js → useMcpConfigStore-CQCdt0vJ.js} +1 -1
  132. package/dist/assets/{useMobileSwipeActions-qeExRIFa.js → useMobileSwipeActions-k7KGPpqM.js} +1 -1
  133. package/dist/assets/{useMobileTranscriptSyncHint-CLHeiwxO.js → useMobileTranscriptSyncHint-BLI4fy8Q.js} +1 -1
  134. package/dist/assets/{useModelLists-DUUovEwL.js → useModelLists-DUsn2kaq.js} +1 -1
  135. package/dist/assets/{useOpenCodeReadiness-DRZyVsuu.js → useOpenCodeReadiness-Bxz72dNZ.js} +1 -1
  136. package/dist/assets/{usePluginsStore-W-iNVsmP.js → usePluginsStore-DzweL9M8.js} +1 -1
  137. package/dist/assets/{useProjectGitActions-BBbZCQTk.js → useProjectGitActions-BPlLnhmx.js} +1 -1
  138. package/dist/assets/{useProjectGitStore-DB_eyTwc.js → useProjectGitStore-EZRP6D6M.js} +1 -1
  139. package/dist/assets/{useProjectRuntimeAPIs-CR9pISBy.js → useProjectRuntimeAPIs-Cbt-c1SP.js} +1 -1
  140. package/dist/assets/{useSessionBtwStore-CXgbHj8n.js → useSessionBtwStore-DjwWijyt.js} +1 -1
  141. package/dist/assets/{useStreamingTextThrottle-B5HUK2ar.js → useStreamingTextThrottle-B8aWuwgs.js} +1 -1
  142. package/dist/assets/{worktreeManager-7PwfaVcz.js → worktreeManager-BbQ4inHD.js} +1 -1
  143. package/dist/assets/{worktreeSourceBranchPreference-CL4vcrug.js → worktreeSourceBranchPreference-7Id37MxY.js} +1 -1
  144. package/dist/index.html +5 -5
  145. package/dist/mini-chat.html +5 -5
  146. package/dist/mobile.html +1 -1
  147. package/package.json +1 -1
  148. package/server/lib/host-update/DOCUMENTATION.md +5 -2
  149. package/server/lib/notifications/apns-runtime.test.js +3 -3
  150. package/server/lib/opencode/DOCUMENTATION.md +1 -1
  151. package/server/lib/relay/DOCUMENTATION.md +1 -1
  152. package/server/lib/relay/service.js +7 -18
  153. package/server/lib/relay/service.test.js +19 -14
  154. package/dist/assets/mobileConnections-CPcUZA0K.js +0 -2
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-DSfZp0SO.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-CyWl56mL.js","assets/runtime-switch-CSXCC6XM.js","assets/runtime-fetch-ykYB0sSi.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-BQipzOYw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-DDGMqGyv.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CxX_u4P7.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-ChIGW-4e.js","assets/runtime-file-download-Cb3-EjAg.js","assets/vendor-pierre-diffs-B0OmIhMO.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/ui-C93TriAS.js","assets/client-DfhjGjVo.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-CiOFao2o.js","assets/gitApiHttp-Cx9rEFyN.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-DFbTE2e2.js","assets/i18n-BZ_vx76q.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-1zpYqZEm.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-CW2R7gKr.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-jd_I1qR9.js","assets/Icon-BJy61Jon.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-B9djOKHd.js","assets/dialog-B6B8FIrL.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-ClRxkgy2.js","assets/mobileBackNavigation-Dc2Ms_yz.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-trHWUJt-.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-DwwztSrL.js","assets/markdownHeightCache-BthXvgH2.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-q3O_Nkg5.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-XA_EBPXw.js","assets/touch-gestures-DOoBxhz5.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./runtime-auth-CyWl56mL.js";import{c as n,i as r,n as i,r as a}from"./runtime-switch-CSXCC6XM.js";import{n as o}from"./runtime-fetch-ykYB0sSi.js";import{O as s,c,n as l,s as u,z as d}from"./platform-BQipzOYw.js";import{$ as f,$n as p,$t as m,A as h,B as g,D as _,E as v,I as y,J as b,Jn as x,Jt as S,K as C,L as w,M as T,Q as E,R as D,T as O,W as k,Wn as A,X as j,Xt as M,Yn as N,Yt as P,Z as F,Zn as I,a as L,at as R,et as ee,fr as z,g as B,h as V,in as H,it as U,j as te,k as ne,kt as re,lt as W,m as ie,mt as ae,n as oe,nr as se,on as ce,or as le,p as ue,pr as de,q as fe,qt as pe,rr as me,rt as he,tn as ge,v as _e,vt as ve,w as ye,x as be,y as xe}from"./client-DfhjGjVo.js";import{a as Se,i as Ce,o as we,r as Te,s as Ee,t as De}from"./vendor-zustand-CTekDqaS.js";import{C as Oe,S as ke,b as Ae,it as je,ot as Me,st as Ne,x as Pe,y as Fe}from"./vendor-base-ui-wXsskyKm.js";import{$t as Ie,An as Le,At as Re,Cn as ze,Dn as Be,En as Ve,Ft as He,On as Ue,Ot as We,Qt as Ge,Sn as Ke,St as qe,Tn as Je,Xt as Ye,Yt as Xe,Zt as Ze,cn as Qe,en as $e,gn as et,hn as tt,kt as nt,ln as rt,pn as it,rn as at,tn as ot,un as st,vn as ct,wn as lt,yn as ut}from"./gitApiHttp-Cx9rEFyN.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{t as dt}from"./safeStorage-DTOhKN0V.js";import{E as ft,F as pt,N as mt,P as ht,_ as gt,a as _t,b as vt,d as yt,f as bt,h as xt,i as St,n as Ct,o as wt,t as Tt,u as Et,y as Dt,z as Ot}from"./prompt-attachment-upload-CiOFao2o.js";import{n as kt,t as At}from"./pathNormalization-ewtPqJWn.js";import{n as jt}from"./vendor-react-BkccXcWz.js";import{i as Mt,n as Nt,s as Pt,t as Ft,u as It}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{D as Lt,E as Rt,G as zt,L as Bt,R as Vt,W as Ht,k as Ut,z as Wt}from"./runtime-file-resource-DDGMqGyv.js";import{a as Gt,i as Kt,n as qt,o as Jt,t as Yt}from"./path-utils-jGozTg9d.js";import{a as Xt,d as Zt,f as Qt,g as $t,h as en,i as tn,m as nn,o as rn,r as G,s as an}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as on}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as sn,o as cn,r as ln,x as un}from"./useUIStore-CxX_u4P7.js";import{n as dn,o as fn,r as pn}from"./useMobileHtmlPreviewStore-ChIGW-4e.js";import{t as mn}from"./uuid-D-SDZijH.js";import{d as hn,t as gn}from"./vendor-pierre-diffs-B0OmIhMO.js";import{r as _n}from"./vendor-sonner-DX3nfJx4.js";import{s as vn}from"./spacedFileMention-Ds4GtgiF.js";import{$a as yn,$i as bn,$n as xn,B as Sn,Br as Cn,Bt as wn,C as Tn,Ca as En,Cn as Dn,Ct as On,D as kn,Dn as An,Dr as jn,E as Mn,En as Nn,Er as Pn,Fa as Fn,Fn as In,G as K,Ga as Ln,Gn as Rn,H as zn,Ha as Bn,Ia as Vn,Ir as q,It as Hn,J as Un,Jn as Wn,Jt as Gn,K as Kn,Kn as qn,Kt as Jn,La as Yn,Lt as Xn,M as Zn,Mn as Qn,Mr as $n,N as er,Nn as tr,Nr as nr,Nt as rr,O as ir,Or as ar,P as or,Pr as sr,Qn as cr,Qt as lr,Rn as ur,Rt as dr,Sn as fr,St as pr,T as mr,U as hr,Un as gr,V as _r,Va as vr,Vt as yr,W as br,Wn as xr,Wr as Sr,X as Cr,Xi as wr,Xn as Tr,Xt as Er,Yn as Dr,Z as Or,Zi as kr,Zt as Ar,_r as jr,_t as Mr,aa as Nr,ai as Pr,ao as Fr,ar as Ir,ba as Lr,bi as Rr,bn as zr,bt as Br,c as Vr,ca as Hr,cn as Ur,ct as Wr,da as Gr,dr as Kr,dt as qr,eo as Jr,et as Yr,f as Xr,fa as Zr,fn as Qr,fr as $r,g as ei,ga as ti,gn as ni,gr as ri,gt as ii,hr as ai,ia as oi,io as J,ir as si,it as ci,jn as li,jr as ui,jt as di,kr as fi,la as pi,lr as mi,lt as Y,m as hi,nn as gi,no as _i,nr as vi,oa as yi,on as bi,or as xi,ot as Si,pn as Ci,pr as wi,pt as Ti,qn as Ei,r as Di,ra as Oi,ro as ki,rr as Ai,s as ji,sa as Mi,sn as Ni,st as Pi,t as Fi,ti as Ii,tn as Li,to as Ri,ua as zi,ur as Bi,ut as Vi,vn as Hi,vt as Ui,w as Wi,wn as Gi,xi as Ki,xn as qi,xt as Ji,ya as Yi,yn as Xi,yt as Zi,zt as Qi}from"./ui-C93TriAS.js";import{n as X}from"./Icon-BJy61Jon.js";import{d as $i,f as ea,i as ta}from"./remoteProjectQueries-DFbTE2e2.js";import{t as na}from"./i18n-BZ_vx76q.js";import"./vendor-opencode-schema-DWT45VBX.js";import{n as ra}from"./input-store-CW2R7gKr.js";import{a as ia,o as aa,u as oa}from"./toolHelpers-iEHVHQ9p.js";import{n as sa,t as ca}from"./ScrollableOverlay-_-c4eChV.js";import{C as la,S as ua,_ as da,t as fa}from"./MobileResizableSheet-G0ftF_2y.js";import{a as pa,o as ma,t as ha}from"./vendor-framer-motion-D5NyyC73.js";import{n as ga}from"./mobileAppContext-BQgdTp5T.js";import{n as _a,r as va,t as ya}from"./vendor-tanstack-react-virtual-qsd3nvZb.js";import{a as ba,i as xa,n as Sa,o as Ca,r as wa,s as Ta,t as Ea}from"./dialog-B9djOKHd.js";import{t as Da}from"./OverlayScrollbar-CLu72YSm.js";import{i as Oa,n as ka,t as Aa}from"./tooltip-C7bh8-oj.js";import{n as ja,t as Ma}from"./useInlineCommentDraftStore-oj1WmZIi.js";import{n as Na,t as Pa}from"./useThemeSystem-BIXghnHj.js";import{t as Fa}from"./truncated-path-D4zPMNfI.js";import{r as Ia}from"./device-5-ZkrAmh.js";import{c as La,n as Ra,r as za,t as Ba}from"./dropdown-menu-Bg9fqXHM.js";import{n as Va,t as Ha}from"./kbd-DTXNf7DP.js";import{t as Ua}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Wa}from"./themes-BgDJcxRc.js";import{n as Ga}from"./useEffectiveDirectory-ClRxkgy2.js";import{b as Ka}from"./gitApi-D7UHXMTh.js";import{c as qa,n as Ja,s as Ya,t as Xa}from"./useGitStore-DDE7AUsk.js";import{o as Za,s as Qa}from"./useProjectGitStore-DB_eyTwc.js";import{t as $a}from"./agentColors-DWSbQXy2.js";import{C as eo,D as to,E as no,O as ro,S as io,T as ao,_ as oo,a as so,b as co,c as lo,d as uo,f as fo,g as po,h as mo,i as ho,j as go,l as _o,m as vo,p as yo,u as bo,v as xo,w as So,x as Co,y as wo}from"./mobileBackNavigation-Dc2Ms_yz.js";import{t as To}from"./ImageLoadingPlaceholder-trHWUJt-.js";import{t as Eo}from"./LoadingImage-xhLZPhd9.js";import{t as Do}from"./input-DgT2vL85.js";import{i as Oo,n as ko,o as Ao,r as jo,t as Mo}from"./MarkdownRenderer-DwwztSrL.js";import{a as No}from"./markdownHeightCache-BthXvgH2.js";import{t as Po}from"./dualLimitLru-D8Sphgua.js";import{c as Fo,n as Io,o as Lo,r as Ro}from"./imageSource-q3O_Nkg5.js";import{_ as zo,i as Bo,n as Vo,s as Ho}from"./shortcuts-DQjWb6-B.js";import{a as Uo,d as Wo,f as Go,i as Ko,n as qo,o as Jo,r as Yo,s as Xo,t as Zo,u as Qo}from"./SessionSurfaceContext-BP4NCKp6.js";import{i as $o,n as es,r as ts,t as ns}from"./TextSelectionMenu-BvRgpSxU.js";import{o as rs}from"./useSessionBtwStore-CXgbHj8n.js";import{t as is}from"./useDebouncedValue-BHlMPqY8.js";import{a as as,i as os,r as ss,t as cs}from"./AgentAvatar-BY1Uar-W.js";import{t as ls}from"./checkbox-C3kPdnVf.js";import{t as us}from"./YuriLogo-CcVNX93s.js";import{i as ds,o as fs}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{a as ps,r as ms,t as hs}from"./connection-hint-zKPzQOm-.js";import{a as gs,c as _s,d as vs,i as ys,l as bs,o as xs,s as Ss,u as Cs}from"./chatUpwardIntent-uv8XbV0r.js";import{a as ws,i as Ts,o as Es,s as Ds,u as Os}from"./fileMentionTouchSelection-DBohWG86.js";import{l as ks,n as As,t as js}from"./fileMentionAutocompleteState-B9411b4o.js";import{a as Ms,c as Ns,d as Ps,f as Fs,i as Is,l as Ls,n as Rs,o as zs,p as Bs,r as Vs,s as Hs,t as Us}from"./insertionBoundaries-CNdm9xws.js";import{n as Ws,t as Gs}from"./ModelLogo-B50mkTPp.js";import{n as Ks,t as qs}from"./useDictation-Dw4cPz-9.js";import{A as Js,D as Ys,E as Xs,F as Zs,I as Qs,L as $s,N as ec,O as tc,P as nc,R as rc,S as ic,T as ac,_ as oc,a as sc,b as cc,c as lc,d as uc,f as dc,g as fc,h as pc,i as mc,j as hc,k as gc,l as _c,m as vc,o as yc,p as bc,r as xc,s as Sc,t as Cc,u as wc,v as Tc,w as Ec,x as Dc,y as Oc}from"./BtwPanel-DbifCGwT.js";import{a as kc,c as Ac,d as jc,f as Mc,i as Nc,l as Pc,m as Fc,n as Ic,o as Lc,p as Rc,r as zc,s as Bc,t as Vc,u as Hc}from"./reference-history-Bpfp7nl-.js";import{A as Uc,B as Wc,D as Gc,E as Kc,F as qc,G as Jc,H as Yc,I as Xc,J as Zc,K as Qc,L as $c,M as el,N as tl,O as nl,Q as rl,R as il,T as al,U as ol,V as sl,W as cl,X as ll,Y as ul,_ as dl,a as fl,b as pl,c as ml,d as hl,f as gl,g as _l,h as vl,j as yl,k as bl,l as xl,m as Sl,o as Cl,p as wl,q as Tl,r as El,s as Dl,t as Ol,u as kl,v as Al,w as jl,x as Ml,y as Nl,z as Pl}from"./BusyDots-Bk6p5cua.js";import{A as Fl,C as Il,D as Ll,E as Rl,N as zl,O as Bl,P as Vl,S as Hl,T as Ul,_ as Wl,a as Gl,b as Kl,c as ql,d as Jl,g as Yl,h as Xl,m as Zl,n as Ql,p as $l,r as eu,s as tu,t as nu,v as ru,w as iu,x as au,y as ou}from"./queue-abort-optimistic-9kcDZ3sO.js";import{_ as su,a as cu,c as lu,g as uu,l as du,o as fu,t as pu,v as mu,y as hu}from"./vendor-dnd-kit-core-qy5stxu5.js";import{i as gu,n as _u,o as vu,s as yu,t as bu}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as xu}from"./MobileOverlayPanel-XqAYxe55.js";import{c as Su,d as Cu,f as wu,n as Tu,o as Eu,p as Du,s as Ou,t as ku,u as Au}from"./useModelLists-DUUovEwL.js";import{n as ju,t as Mu}from"./useOpenCodeReadiness-DRZyVsuu.js";import{a as Nu,c as Pu,d as Fu,f as Iu,h as Lu,i as Ru,l as zu,m as Bu,o as Vu,p as Hu,r as Uu,s as Wu,t as Gu,u as Ku}from"./ToolOutputDialog-DSfZp0SO.js";import{t as qu}from"./vendor-motion-vLNN8EMu.js";import{c as Ju,i as Yu,n as Xu,o as Zu,s as Qu,t as $u}from"./select-B0A2UPYI.js";import{a as ed}from"./githubAuthQueries-DJcn8yuA.js";import{c as td,i as nd,l as rd,n as id,o as ad,r as od,t as sd}from"./remote-input-store-BPnodmVx.js";import{a as cd,i as ld,n as ud}from"./projectMeta-S7fUN1Zp.js";import{a as dd,c as fd,d as pd,f as md,l as hd,m as gd,o as _d,p as vd,r as yd,s as bd,u as xd}from"./auto-read-context-D2UX6oXY.js";import{n as Sd}from"./permission-rules-DoQUXKll.js";import{n as Cd}from"./markdownTheme-D84XyNiT.js";import"./DiffViewToggle-XA_EBPXw.js";import{i as wd,n as Td,t as Ed}from"./FadeInOnReveal-iCjNPFx8.js";import{t as Dd}from"./useStreamingTextThrottle-B5HUK2ar.js";var Z=jt(),Q=e(Ne(),1),Od=new Po({maxEntries:128,maxBytes:1048576}),kd=(e,t,n)=>`${+!!t}:${n}:${e.map(e=>`${e.id}\0${e.title}\0${e.subtitle??``}\0${e.badge??``}\0${e.iconName}\0${e.agentName??``}`).join(`|`)}`,Ad=async e=>{let t=no(`--surface-foreground`);return Promise.all(e.slice(0,40).map(async e=>{let n=e.agentName===void 0?void 0:as($a(e.agentName).var,no),r=JSON.stringify([e.iconName,t,e.agentName,n?.background]),i=Od.get(r);return i===void 0&&(i=await(e.agentName===void 0?Os(e.iconName,t):So(os(`agent`,e.agentName,!1,n)))??``,i&&Od.set(r,i,(r.length+i.length)*2)),{id:e.id,title:e.title,subtitle:e.subtitle??``,badge:e.badge??``,iconBase64:i}}))},jd=[],Md=e=>void 0,Nd=()=>void 0;function Pd(e){let t=go()&&e.enabled&&yo(e.isMobile),n=(0,Q.useRef)(Symbol(`native-composer-owner`)).current,r=(0,Q.useRef)(null),i=(0,Q.useRef)(e.text),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(-1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(``),l=(0,Q.useRef)(``),u=ss(e.agentName),d=Pa()?.currentTheme,f=(0,Q.useRef)([]),p=(0,Q.useRef)(vo()),m=G(e.onText),h=G(e.onSend),g=G(e.onAbort),_=G(e.onAttach),v=G(e.onFiles),y=G(e.onRemoveAttachment),b=G(e.onOpenModel),x=G(e.onCycleAgent),S=G(e.onOpenAgent),C=G(e.onScrollToBottom),w=G(e.onAutocompleteAccept??Md),T=G(e.onAutocompleteDismiss??Nd),E={onText:(e,t,r)=>{so.owns(n)&&(ro({incoming:e,replacedText:s.current})||(s.current=null,i.current=e,a.current=!0,m(e,t,r)))},onSend:e=>{so.owns(n)&&(i.current=e,h(e,()=>so.owns(n)))},onAbort:g,onAttach:_,onFiles:v,onRemoveAttachment:y,onOpenModel:b,onCycleAgent:x,onOpenAgent:S,onHeight:G(e=>{typeof document>`u`||_o(document.documentElement,e)}),onScrollToBottom:C,onAutocompleteAccept:e=>{a.current=!1,w(e)},onAutocompleteDismiss:T},D=()=>({text:e.text,placeholder:e.placeholder,modelLabel:e.modelLabel,modelVariantLabel:e.modelVariantLabel,modelIcon:c.current,canSend:e.canSend,canAbort:e.canAbort,attachmentCount:e.attachmentCount,attachmentPreviews:f.current,citationRanges:_t(e.text,e.attachments.map(e=>e.filename)),chipRanges:uo(xo(e.text,e.chipHighlights),no(`--primary`)),appearance:typeof document>`u`?`dark`:Co(document.documentElement),attachAria:e.attachAria,attachTitle:e.attachTitle,attachPhotosLabel:e.attachPhotosLabel,attachFilesLabel:e.attachFilesLabel,attachCancelLabel:e.attachCancelLabel,sendAria:e.sendAria,queueAria:e.queueAria,stopAria:e.stopAria,modelAria:e.modelAria,agentAria:e.agentAria,agentLabel:e.agentLabel,agentColor:co(e.agentName||void 0),agentIdenticon:io(e.agentName||void 0),agentIcon:l.current,suppressed:e.suppressed,showScrollToBottom:e.showScrollToBottom,scrollAria:e.scrollAria,autocomplete:p.current}),O=G(e=>{let t=D();r.current=t,i.current=t.text,so.claim(n,e,t,E)});(0,Q.useLayoutEffect)(()=>{if(!t||typeof document>`u`)return;let e=document.documentElement;O(e);let i=ho({conceal:()=>{so.owns(n)&&so.conceal()},reveal:()=>{so.owns(n)&&so.reveal()}});return()=>{r.current=null,i(),so.releaseOwner(n,e)}},[t,n,O]),(0,Q.useEffect)(()=>{if(!t)return;let i=!1,a=e=>{l.current=e,r.current&&={...r.current,agentIcon:e},so.updateOwner(n,{agentIcon:e})};return a(``),So(os(`agent`,e.agentName||void 0,!1,u)).then(e=>{i||a(e??``)}),()=>{i=!0}},[t,n,e.agentName,u]),(0,Q.useEffect)(()=>{if(!t)return;let i=!1,a=Ws(e.modelId,e.providerId),o={modelIcon:``,modelLabel:e.modelLabel,modelVariantLabel:e.modelVariantLabel};if(c.current=``,r.current&&={...r.current,...o},so.updateOwner(n,o),a)return So(a).then(t=>{if(i)return;let a=t??``;c.current=a;let o={modelIcon:a,modelLabel:e.modelLabel,modelVariantLabel:e.modelVariantLabel};r.current&&={...r.current,...o},so.updateOwner(n,o)}),()=>{i=!0}},[t,n,e.modelId,e.providerId,e.modelLabel,e.modelVariantLabel]);let k=bo(e.attachments);(0,Q.useEffect)(()=>{if(!t)return;let i=!1,a=e.attachments;if(a.length===0){f.current=[],r.current&&={...r.current,attachmentPreviews:[]},so.updateOwner(n,{attachmentPreviews:[]});return}return Promise.all(a.map(async t=>{let n=t.mimeType.startsWith(`image/`)&&t.dataUrl?await eo(t.dataUrl):``;return{id:t.id,filename:t.filename,mime:t.mimeType,thumbnailBase64:n??``,removeAria:e.removeAttachmentNamedAria(t.filename)}})).then(e=>{i||(f.current=e,r.current&&={...r.current,attachmentPreviews:e},so.updateOwner(n,{attachmentPreviews:e}))}),()=>{i=!0}},[t,n,k]);let A=e.autocompleteRows??jd,j=e.autocompleteOpen===!0,M=e.autocompleteHighlightedIndex??0,N=e.autocompleteQuery??``,P=`${kd(A,j,M)}\0${N}`;(0,Q.useEffect)(()=>{if(!t)return;let e=!1;if(!(j&&A.length>0)){let e=vo();oo(p.current,e)||(p.current=e,r.current&&={...r.current,autocomplete:e},so.updateOwner(n,{autocomplete:e}));return}return Ad(A).then(t=>{if(e)return;let i={open:t.length>0,highlightedIndex:Math.max(0,Math.min(M,Math.max(t.length-1,0))),query:N,highlightColor:no(`--primary-base`)||no(`--primary`),rows:t};oo(p.current,i)||(p.current=i,r.current&&={...r.current,autocomplete:i},so.updateOwner(n,{autocomplete:i}))}),()=>{e=!0}},[t,n,P,d]);let F=t?xo(e.text,e.chipHighlights).map(e=>`${e.start}:${e.end}:${e.triggerLength}`).join(`|`):``;return(0,Q.useEffect)(()=>{if(!t)return;let c=D(),l=r.current;if(l&&wo(l,c)){a.current=!1,o.current=e.textPresetEpoch;return}r.current=c;let u=e.textPresetEpoch!==o.current;o.current=e.textPresetEpoch;let d=to({nextText:c.text,nativeOwnedText:i.current,echoingNative:a.current,preset:u});a.current=!1,!d.omitText&&d.forceText&&(s.current=i.current),d.omitText||(i.current=c.text);let f=fo(l,c,d,{caret:e.caret});f&&so.updateOwner(n,f)},[t,n,e.text,e.textPresetEpoch,e.placeholder,e.modelLabel,e.modelVariantLabel,e.modelId,e.providerId,e.canSend,e.canAbort,e.attachmentCount,k,e.suppressed,e.attachAria,e.attachTitle,e.attachPhotosLabel,e.attachFilesLabel,e.attachCancelLabel,e.sendAria,e.queueAria,e.stopAria,e.modelAria,e.agentName,e.agentLabel,e.agentAria,e.showScrollToBottom,e.scrollAria,F]),t}function Fd(e){return Pd(e),null}var Id=new WeakMap;function Ld({draftKey:e,text:t,textareaRef:n,enabled:r,store:i=ra}){let a=e?.transportIdentity,o=e?.owner.kind,s=e?.owner.ownerID,c=(0,Q.useMemo)(()=>a&&o&&s?{transportIdentity:a,owner:{kind:o,ownerID:s}}:null,[a,o,s]),l=(0,Q.useRef)(null),u=c?i.getState().getDraft(c):void 0;return(0,Q.useLayoutEffect)(()=>{let e=n.current;if(!r||!c||!e)return;let t=Id.get(i);t||(t=new WeakMap,Id.set(i,t));let a=i.getState().getDraft(c),o=a?t.get(a)?.selection:void 0,s={},u={node:e,owner:s,record:a,text:e.value,pending:a&&o?{record:a,selection:o}:void 0};return l.current=u,a&&t.set(a,{owner:s}),()=>{let n=i.getState().getDraft(c);n&&n===u.record&&t.get(n)?.owner===s&&e.value===u.text&&t.set(n,{owner:s,selection:{text:e.value,start:e.selectionStart,end:e.selectionEnd,direction:e.selectionDirection}}),l.current===u&&(l.current=null)}},[r,c,i,n]),(0,Q.useLayoutEffect)(()=>{let e=l.current;if(!e)return;let n=Id.get(i);u&&u!==e.record&&n.set(u,{owner:e.owner}),e.record=u,e.text=t;let r=e.pending;if(r){if(u!==r.record){e.pending=void 0;return}t===r.selection.text&&e.node.value===t&&(e.pending=void 0,e.node.setSelectionRange(r.selection.start,r.selection.end,r.selection.direction))}},[r,c,u,i,t]),G(()=>{l.current&&(l.current.pending=void 0)})}var $=Me(),Rd=e=>{let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`},zd=e=>{let t=(0,Z.c)(4),{volume:n}=e,{currentTheme:r}=Na(),i=Math.min(1,Math.max(0,n)),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=[.45,.7,1,.7,.45],t[0]=a):a=t[0];let o=a,s;return t[1]!==r||t[2]!==i?(s=(0,$.jsx)(`div`,{className:`flex h-6 w-10 flex-shrink-0 items-center justify-center gap-1`,"aria-hidden":`true`,children:o.map((e,t)=>(0,$.jsx)(`span`,{className:`h-full w-1 rounded-full transition-transform duration-75 ease-out motion-reduce:transition-none`,style:{backgroundColor:r.colors.primary.base,transform:`scaleY(${.25+i*e*.75})`}},t))}),t[1]=r,t[2]=i,t[3]=s):s=t[3],s},Bd=e=>{let t=kr(e=>e.sttLocalModel),[n,r]=Q.useState(null);return Q.useEffect(()=>{if(!e){r(null);return}let n=!1,i=async()=>{try{let e=await o(`/api/dictation/status`,{query:{provider:`local`,localModel:t}});if(!e.ok||n)return;let i=await e.json(),a=Array.isArray(i?.models)?i.models.find(e=>e.id===t):null;n||r(typeof a?.downloadProgress==`number`?a.downloadProgress:null)}catch{}};i();let a=setInterval(()=>{i()},2e3);return()=>{n=!0,clearInterval(a)}},[e,t]),e?n:null},Vd=e=>{let t=(0,Z.c)(89),{radius:n,isMobile:r,footerIconButtonClass:i,footerPaddingClass:a,iconSizeClass:o,sendIconSizeClass:s,disabled:c,onInsert:l,onInsertAndSend:u,onActiveChange:d,onContentHeightChange:f,renderTrigger:p,topAccessory:m}=e,h=p===void 0||p,{t:g}=na(),{currentTheme:_}=Na(),v=kr(Hd),y=ln(Ud),b;t[0]===y?b=t[1]:(b=Bo(Ho(`toggle_dictation`,y)),t[0]=y,t[1]=b);let x=b,[S]=Q.useState(Wd),C=Q.useRef(null),w=Q.useRef(l),T=Q.useRef(u),E,D;t[2]!==l||t[3]!==u?(E=()=>{w.current=l,T.current=u},D=[l,u],t[2]=l,t[3]=u,t[4]=E,t[5]=D):(E=t[4],D=t[5]),Q.useEffect(E,D);let O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O={onTranscript:e=>{let t=C.current;C.current=null,t===`send`?T.current(e):w.current(e)}},t[6]=O):O=t[6];let{status:k,partialTranscript:A,volume:j,duration:M,error:N,errorReason:P,startDictation:F,confirmDictation:I,cancelDictation:L,retryFailedDictation:R,acceptPartialTranscript:ee,discardFailedDictation:z}=qs(O),B=k===`recording`&&P===`model_download_in_progress`,V=Bd(B),H=Q.useRef(k),U,te;t[7]===k?(U=t[8],te=t[9]):(U=()=>{H.current=k},te=[k],t[7]=k,t[8]=U,t[9]=te),Q.useEffect(U,te);let ne,re;t[10]!==d||t[11]!==k?(ne=()=>(d?.(k!==`idle`),()=>d?.(!1)),re=[k,d],t[10]=d,t[11]=k,t[12]=ne,t[13]=re):(ne=t[12],re=t[13]),Q.useLayoutEffect(ne,re);let W,ie;t[14]!==I||t[15]!==v||t[16]!==c||t[17]!==F||t[18]!==S?(W=()=>{if(!S||!v||c)return;let e=()=>{H.current===`idle`?F():H.current===`recording`&&(C.current=`insert`,I())};return window.addEventListener(`yuri:dictation-toggle`,e),()=>window.removeEventListener(`yuri:dictation-toggle`,e)},ie=[S,v,c,F,I],t[14]=I,t[15]=v,t[16]=c,t[17]=F,t[18]=S,t[19]=W,t[20]=ie):(W=t[19],ie=t[20]),Q.useEffect(W,ie);let ae,oe;t[21]!==L||t[22]!==I||t[23]!==k?(ae=()=>{if(k!==`recording`)return;let e=e=>{if(!e.isComposing){if(e.key===`Enter`&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault(),e.stopPropagation(),C.current=`insert`,I();return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),L())}};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},oe=[k,I,L],t[21]=L,t[22]=I,t[23]=k,t[24]=ae,t[25]=oe):(ae=t[24],oe=t[25]),Q.useEffect(ae,oe);let se=Q.useRef(null),ce=Q.useRef(null),le=Q.useRef(null),[ue,de]=Q.useState(null),fe=k!==`idle`,pe=Q.useRef(f),me,he;t[26]===f?(me=t[27],he=t[28]):(me=()=>{pe.current=f},he=[f],t[26]=f,t[27]=me,t[28]=he),Q.useEffect(me,he);let ge=Q.useRef(!1),_e;t[29]===fe?_e=t[30]:(_e=()=>{if(!fe){ge.current&&(ge.current=!1,pe.current?.(null));return}let e=ce.current,t=le.current;if(!e||!t)return;let n=window.getComputedStyle(e),r=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0);ge.current=!0,pe.current?.(t.offsetHeight+r),e.scrollTop=e.scrollHeight},t[29]=fe,t[30]=_e);let ve;t[31]!==N||t[32]!==fe||t[33]!==A||t[34]!==k?(ve=[fe,A,k,N],t[31]=N,t[32]=fe,t[33]=A,t[34]=k,t[35]=ve):ve=t[35],Q.useLayoutEffect(_e,ve);let ye,be;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>()=>{ge.current&&(ge.current=!1,pe.current?.(null))},be=[],t[36]=ye,t[37]=be):(ye=t[36],be=t[37]),Q.useEffect(ye,be);let xe,Se;if(t[38]===fe?(xe=t[39],Se=t[40]):(xe=()=>{if(!fe)return;let e=se.current?.closest(`[data-chat-input-footer="true"]`);e&&e.offsetHeight>0&&de(e.offsetHeight)},Se=[fe],t[38]=fe,t[39]=xe,t[40]=Se),Q.useLayoutEffect(xe,Se),!S||!v)return null;let Ce=k!==`idle`,we;t[41]===I?we=t[42]:(we=e=>{C.current=e,I()},t[41]=I,t[42]=we);let Te=we,Ee;t[43]===R?Ee=t[44]:(Ee=()=>{C.current=`insert`,R()},t[43]=R,t[44]=Ee);let De=Ee,Oe;bb0:{if(k===`failed`){Oe=``;break bb0}if(k===`uploading`){let e;t[45]===g?e=t[46]:(e=g(`chat.dictation.processing`),t[45]=g,t[46]=e),Oe=e;break bb0}if(B){let e;t[47]!==V||t[48]!==g?(e=V===null?g(`chat.dictation.downloadingModel`):g(`chat.dictation.downloadingModelProgress`,{percent:String(V)}),t[47]=V,t[48]=g,t[49]=e):e=t[49],Oe=e;break bb0}let e;t[50]===g?e=t[51]:(e=g(`chat.dictation.listening`),t[50]=g,t[51]=e),Oe=e}let ke=Oe,Ae;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={onMouseDown:Gd,onPointerDownCapture:Kd},t[52]=Ae):Ae=t[52];let je=Ae,Me;t[53]!==x||t[54]!==c||t[55]!==i||t[56]!==o||t[57]!==Ce||t[58]!==h||t[59]!==F||t[60]!==g?(Me=h?(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:()=>{F()},disabled:c||Ce,title:x?`${g(`chat.dictation.start`)} (${x})`:g(`chat.dictation.start`),"aria-label":g(`chat.dictation.start`),children:(0,$.jsx)(X,{name:`mic`,className:J(o,`text-current`)})}):null,t[53]=x,t[54]=c,t[55]=i,t[56]=o,t[57]=Ce,t[58]=h,t[59]=F,t[60]=g,t[61]=Me):Me=t[61];let Ne;t[62]!==ee||t[63]!==L||t[64]!==Te||t[65]!==_||t[66]!==z||t[67]!==M||t[68]!==N||t[69]!==ue||t[70]!==i||t[71]!==a||t[72]!==o||t[73]!==Ce||t[74]!==r||t[75]!==B||t[76]!==A||t[77]!==ke||t[78]!==n||t[79]!==De||t[80]!==s||t[81]!==k||t[82]!==g||t[83]!==m||t[84]!==j?(Ne=Ce?(0,$.jsxs)(`div`,{ref:se,className:J(`absolute inset-0 z-50 flex flex-col overflow-x-hidden overflow-y-hidden`,r&&`yuri-composer-morph-content-fade`),style:{borderRadius:n,backgroundColor:_.colors.surface.subtle},role:`dialog`,"aria-label":g(`chat.dictation.overlayAria`),children:[m,(0,$.jsx)(`div`,{ref:ce,className:J(`scrollbar-none flex-1 min-h-0 overflow-y-auto px-3`,r?`pt-3.5 pb-2.5`:`pt-5 pb-2`),children:(0,$.jsxs)(`div`,{ref:le,className:J(!A&&`translate-y-1.5`),children:[A?(0,$.jsx)(`p`,{className:`typography-markdown md:typography-ui-label whitespace-pre-wrap`,style:{color:_.colors.surface.foreground},children:A}):k===`recording`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,style:{color:_.colors.surface.mutedForeground},children:[(0,$.jsx)(zd,{volume:j}),(0,$.jsx)(`p`,{className:`typography-markdown md:typography-ui-label`,children:ke})]}):(0,$.jsx)(`p`,{className:`typography-markdown md:typography-ui-label`,style:{color:_.colors.surface.mutedForeground},children:ke}),k===`failed`?(0,$.jsx)(`p`,{className:`typography-meta mt-1`,style:{color:_.colors.status.error},children:N||g(`chat.dictation.failed`)}):null,k===`recording`&&N&&!B?(0,$.jsx)(`p`,{className:`typography-meta mt-1`,style:{color:_.colors.status.warning},children:N}):null]})}),(0,$.jsxs)(`div`,{className:J(`flex flex-shrink-0 items-center gap-x-3`,a),style:ue?{height:ue}:void 0,children:[k===`recording`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`relative ml-1 flex h-2 w-2 flex-shrink-0`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-60`,style:{backgroundColor:_.colors.status.error}}),(0,$.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full`,style:{backgroundColor:_.colors.status.error}})]}),(0,$.jsx)(zd,{volume:j}),(0,$.jsx)(`span`,{className:`typography-meta tabular-nums`,style:{color:_.colors.surface.mutedForeground},children:Rd(M)})]}):k===`uploading`?(0,$.jsx)(X,{name:`loader-4`,className:`ml-1 h-4 w-4 animate-spin`,style:{color:_.colors.surface.mutedForeground}}):null,(0,$.jsx)(`div`,{className:J(`ml-auto flex items-center`,r?`gap-x-1`:`gap-x-1.5 md:gap-x-3`),children:k===`recording`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-muted-foreground hover:text-foreground`),onClick:()=>{L()},title:g(`chat.dictation.cancel`),"aria-label":g(`chat.dictation.cancel`),children:(0,$.jsx)(X,{name:`close`,className:o})}),(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:()=>Te(`insert`),title:g(`chat.dictation.insert`),"aria-label":g(`chat.dictation.insert`),children:(0,$.jsx)(X,{name:`check`,className:o})}),(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-primary hover:text-primary`),onClick:()=>Te(`send`),title:g(`chat.dictation.insertAndSend`),"aria-label":g(`chat.dictation.insertAndSend`),children:(0,$.jsx)(X,{name:`send-plane-2`,className:s})})]}):k===`uploading`?(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-muted-foreground hover:text-foreground`),onClick:()=>{L()},title:g(`chat.dictation.cancel`),"aria-label":g(`chat.dictation.cancel`),children:(0,$.jsx)(X,{name:`close`,className:o})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-muted-foreground hover:text-foreground`),onClick:z,title:g(`chat.dictation.discard`),"aria-label":g(`chat.dictation.discard`),children:(0,$.jsx)(X,{name:`close`,className:o})}),(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:De,title:g(`chat.dictation.retry`),"aria-label":g(`chat.dictation.retry`),children:(0,$.jsx)(X,{name:`refresh`,className:o})}),A.trim()?(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:()=>{C.current=`insert`,ee()},title:g(`chat.dictation.insert`),"aria-label":g(`chat.dictation.insert`),children:(0,$.jsx)(X,{name:`check`,className:o})}):null]})})]})]}):null,t[62]=ee,t[63]=L,t[64]=Te,t[65]=_,t[66]=z,t[67]=M,t[68]=N,t[69]=ue,t[70]=i,t[71]=a,t[72]=o,t[73]=Ce,t[74]=r,t[75]=B,t[76]=A,t[77]=ke,t[78]=n,t[79]=De,t[80]=s,t[81]=k,t[82]=g,t[83]=m,t[84]=j,t[85]=Ne):Ne=t[85];let Pe;return t[86]!==Me||t[87]!==Ne?(Pe=(0,$.jsxs)($.Fragment,{children:[Me,Ne]}),t[86]=Me,t[87]=Ne,t[88]=Pe):Pe=t[88],Pe};function Hd(e){return e.dictationEnabled}function Ud(e){return e.shortcutOverrides}function Wd(){return!d()&&Ks()}function Gd(e){return e.preventDefault()}function Kd(e){e.pointerType===`touch`&&e.preventDefault()}var qd=e(je(),1);function Jd({onInsert:e,onPartial:t,onStart:n,onCancel:r,className:i,iconClassName:a,inputRef:o,onRecordingChange:s,onActiveChange:c,interactionMode:l=`desktop`,disabled:u=!1}){let{t:d}=na(),f=ln(e=>e.shortcutOverrides),p=Bo(Ho(`toggle_dictation`,f)),m=qs({onTranscript:e,onPartialTranscript:t}),h=(0,Q.useRef)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),b=g||m.isStarting,x=m.status===`recording`,S=m.status===`uploading`,C=l===`mobile`,w=b||v||S,T=x||w,E=G(e=>c?.(e));(0,Q.useEffect)(()=>(E(T),()=>E(!1)),[T,E]);let D=(0,Q.useRef)(null),O=(0,Q.useRef)(null),k=(0,Q.useRef)(null),A=(0,Q.useRef)(null),j=(0,Q.useRef)({x:0,y:0}),M=G(e=>s?.(e));(0,Q.useEffect)(()=>(M(x&&(C||!w)),()=>M(!1)),[x,w,C,M]);let N=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{N.current+=1},[]);let P=G(async(e=!1)=>{if(v)return;let t=o?.current,n=N.current;h.current=!1,y(!0);try{await m.confirmDictation()}finally{y(!1),e&&!C&&n===N.current&&t?.isConnected&&o?.current===t&&!t.disabled&&!t.readOnly&&!document.hidden&&document.hasFocus()&&(document.activeElement===document.body||document.activeElement===t||k.current?.contains(document.activeElement))&&(t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}}),F=G(()=>{D.current=null,x&&(h.current=!1,P())}),I=G(async()=>{if(!(v||S)){if(x){F();return}if(!(S||b||u)){m.status===`failed`&&(r(),m.discardFailedDictation()),h.current=!1,n(),_(!0);try{await m.startDictation(),h.current=!0}finally{_(!1)}}}}),[,L,R]=en(()=>{let e=O.current;O.current=null;let t=o?.current;!e||!t||t.disabled||t.readOnly||u||T||t.selectionStart!==t.selectionEnd||(D.current=e.id,k.current?.setPointerCapture?.(e.id),t.blur(),t.setSelectionRange(t.value.length,t.value.length),I())},500,{immediate:!1}),ee=G(()=>{O.current&&(O.current=null,R())});tn(`pointerdown`,e=>{if(C)return;let t=o?.current;!t||e.target!==t||t.disabled||t.readOnly||e.pointerType!==`mouse`||e.button!==0||e.detail>1||u||T||D.current!==null||(O.current={id:e.pointerId,x:e.clientX,y:e.clientY},j.current={x:e.clientX,y:e.clientY},L())},window,{capture:!0}),tn(`pointermove`,e=>{let t=O.current;t?.id===e.pointerId&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>6&&ee(),D.current===e.pointerId&&(e.preventDefault(),j.current={x:e.clientX,y:e.clientY},A.current&&(A.current.style.transform=`translate(${e.clientX}px, ${e.clientY}px)`))},window,{capture:!0}),tn(`selectstart`,e=>{D.current!==null&&e.preventDefault()},document,{capture:!0}),tn(`mousemove`,e=>{D.current!==null&&e.preventDefault()},window,{capture:!0}),tn(`selectionchange`,()=>{if(D.current===null)return;let e=o?.current;e&&e.selectionStart!==e.selectionEnd&&e.setSelectionRange(e.selectionEnd,e.selectionEnd);let t=document.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()},document),tn(`pointerup`,e=>{O.current?.id===e.pointerId&&ee(),D.current===e.pointerId&&e.button===0&&(D.current=null,h.current=!1,P(!0))},window,{capture:!0}),tn(`pointercancel`,e=>{O.current?.id===e.pointerId&&ee(),D.current===e.pointerId&&(D.current=null,h.current=!1,r(),m.cancelDictation())},window,{capture:!0});let z=G(()=>{D.current!==null&&(D.current=null,h.current=!1,P())});tn(`blur`,()=>{C||(ee(),D.current===null?h.current&&F():z())},window),tn(`visibilitychange`,()=>{C||document.hidden&&(ee(),D.current===null?h.current&&F():z())},document),tn(C?`yuri:mobile-dictation-toggle`:`yuri:dictation-toggle`,()=>{I()},window),tn(`keydown`,e=>{if(!C&&(ee(),!(e.isComposing||e.keyCode===229))){if(e.key===`Enter`&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(x||S)){e.preventDefault(),e.stopPropagation(),e.repeat||F();return}e.key!==`Escape`||!x&&!S&&m.status!==`failed`||(e.preventDefault(),e.stopPropagation(),h.current=!1,D.current=null,r(),m.status===`failed`?m.discardFailedDictation():m.cancelDictation())}},window,{capture:!0});let B=d(x?`settings.voice.volcengine.finishRecording`:S?`chat.dictation.processing`:`chat.dictation.start`);return(0,$.jsxs)(`div`,{ref:k,"data-dictation-control":!0,className:`relative flex shrink-0 items-center gap-1.5`,children:[!C&&(x||b)&&D.current!==null&&(0,qd.createPortal)((0,$.jsxs)(`span`,{ref:A,"data-listening-cursor":!0,"aria-hidden":`true`,className:`pointer-events-none fixed left-0 top-0 z-[100]`,style:{transform:`translate(${j.current.x}px, ${j.current.y}px)`},children:[(0,$.jsx)(`style`,{children:`html, html * { cursor: none !important; user-select: none !important; -webkit-user-select: none !important; } @keyframes yuri-listening-cursor { from { transform: scaleY(0.35); } to { transform: scaleY(1); } }`}),(0,$.jsx)(`span`,{className:`absolute -left-5 -top-5 flex size-10 items-center justify-center gap-1`,children:b?(0,$.jsx)(Fc,{decorative:!0}):[0,1,2].map(e=>(0,$.jsx)(`span`,{className:`h-6 w-[3px] rounded-full bg-[var(--voice-active-fill)] motion-safe:animate-[yuri-listening-cursor_450ms_ease-in-out_infinite_alternate]`,style:{animationDelay:`${e*-150}ms`}},e))})]}),document.body),(0,$.jsxs)(Aa,{delayDuration:0,children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{variant:`ghost`,size:`icon`,className:J(`shadow-none`,i),"aria-label":B,"aria-pressed":x,"aria-busy":w,disabled:S||v||u&&!x,onClick:()=>{I()},onBlur:C?void 0:F,children:w?(0,$.jsx)(Fc,{decorative:!0}):(0,$.jsx)(rc,{kind:`mic`,active:x&&!m.error,className:J(a??`size-5`,m.error&&`text-[var(--status-error)]`)})})}),(0,$.jsx)(ka,{side:`top`,sideOffset:8,className:`yuri-composer-tooltip max-w-64 break-words`,children:m.error||(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:B}),!C&&p&&(0,$.jsx)(`kbd`,{className:`font-sans text-[10px] opacity-70`,children:p})]})})]}),!C&&x&&!w&&(0,$.jsx)(`span`,{className:`pointer-events-none select-none whitespace-nowrap text-[10px] leading-none text-muted-foreground`,children:d(D.current===null?`chat.dictation.keyboardHint`:`chat.dictation.releaseConfirm`)})]})}function Yd(e){let{fileLabel:t,startLine:n,endLine:r,side:i,language:a,code:o,text:s}=e;return e.source===`diff`&&i?`Comment on \`${t}\` lines ${n}-${r} (${i}):\n\`\`\`${a}\n${o}\n\`\`\`\n\n${s}`:e.source===`preview-console`?`Attached preview context from \`${t}\`:\n\`\`\`${a}\n${o}\n\`\`\`\n\n${s}`:e.source===`preview-annotation`?s?`${o}\n\n${s}`:o:`Comment on \`${t}\` lines ${n}-${r}:\n\`\`\`${a}\n${o}\n\`\`\`\n\n${s}`}function Xd(e){return e.length===0?``:e.every(e=>e.source===`preview-annotation`)?e.map(Yd).join(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-D_Kl-Bc5.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-CyWl56mL.js","assets/runtime-switch-CSXCC6XM.js","assets/runtime-fetch-ykYB0sSi.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-BQipzOYw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-wXsskyKm.js","assets/vendor-react-BkccXcWz.js","assets/vendor-tanstack-react-query-DIb_ItL-.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-DDGMqGyv.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-DjKFMfz7.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/summaries-BQMyJaaw.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-CxX_u4P7.js","assets/vendor-zustand-CTekDqaS.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-ChIGW-4e.js","assets/runtime-file-download-Cb3-EjAg.js","assets/vendor-pierre-diffs-B0OmIhMO.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/ui-BPOP32rM.js","assets/client-DfhjGjVo.js","assets/vendor-opencode-client-BM2r1f0o.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-CiOFao2o.js","assets/gitApiHttp-Cx9rEFyN.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-DX3nfJx4.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/remoteProjectQueries-DFbTE2e2.js","assets/i18n-BZ_vx76q.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-1zpYqZEm.js","assets/tour-CMXP3Kif.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/input-store-CW2R7gKr.js","assets/toolHelpers-iEHVHQ9p.js","assets/useAssistantUIStore-jd_I1qR9.js","assets/Icon-DrsaL1yC.js","assets/vendor-framer-motion-D5NyyC73.js","assets/MobileWindowStack-DGLdgoGr.js","assets/vendor-tanstack-react-virtual-qsd3nvZb.js","assets/dialog-DnZWrDDM.js","assets/dialog-B6B8FIrL.css","assets/tap-LkQum5bB.js","assets/useThemeSystem-BIXghnHj.js","assets/appThemeRegistry-BdjrGBQ4.js","assets/themes-BgDJcxRc.js","assets/useEffectiveDirectory-DleT4CpD.js","assets/mobileBackNavigation-CUoYXnE0.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/ImageLoadingPlaceholder-Br3hw4E6.js","assets/image-loading-DA9JEHD8.css","assets/MarkdownRenderer-CGgHX4n3.js","assets/markdownHeightCache-BhpqKZQB.js","assets/dualLimitLru-D8Sphgua.js","assets/imageSource-q3O_Nkg5.js","assets/markdownTheme-D84XyNiT.js","assets/markdown-worker-oBGEB9Eg.js","assets/DiffViewToggle-Da3vQFP9.js","assets/touch-gestures-DOoBxhz5.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./runtime-auth-CyWl56mL.js";import{c as n,i as r,n as i,r as a}from"./runtime-switch-CSXCC6XM.js";import{n as o}from"./runtime-fetch-ykYB0sSi.js";import{O as s,c,n as l,s as u,z as d}from"./platform-BQipzOYw.js";import{$ as f,$n as p,$t as m,A as h,B as g,D as _,E as v,I as y,J as b,Jn as x,Jt as S,K as C,L as w,M as T,Q as E,R as D,T as O,W as k,Wn as A,X as j,Xt as M,Yn as N,Yt as P,Z as F,Zn as I,a as L,at as R,et as ee,fr as z,g as B,h as V,in as H,it as U,j as te,k as ne,kt as re,lt as W,m as ie,mt as ae,n as oe,nr as se,on as ce,or as le,p as ue,pr as de,q as fe,qt as pe,rr as me,rt as he,tn as ge,v as _e,vt as ve,w as ye,x as be,y as xe}from"./client-DfhjGjVo.js";import{a as Se,i as Ce,o as we,r as Te,s as Ee,t as De}from"./vendor-zustand-CTekDqaS.js";import{C as Oe,S as ke,b as Ae,it as je,ot as Me,st as Ne,x as Pe,y as Fe}from"./vendor-base-ui-wXsskyKm.js";import{$t as Ie,An as Le,At as Re,Cn as ze,Dn as Be,En as Ve,Ft as He,On as Ue,Ot as We,Qt as Ge,Sn as Ke,St as qe,Tn as Je,Xt as Ye,Yt as Xe,Zt as Ze,cn as Qe,en as $e,gn as et,hn as tt,kt as nt,ln as rt,pn as it,rn as at,tn as ot,un as st,vn as ct,wn as lt,yn as ut}from"./gitApiHttp-Cx9rEFyN.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{t as dt}from"./safeStorage-DTOhKN0V.js";import{E as ft,F as pt,N as mt,P as ht,_ as gt,a as _t,b as vt,d as yt,f as bt,h as xt,i as St,n as Ct,o as wt,t as Tt,u as Et,y as Dt,z as Ot}from"./prompt-attachment-upload-CiOFao2o.js";import{n as kt,t as At}from"./pathNormalization-ewtPqJWn.js";import{n as jt}from"./vendor-react-BkccXcWz.js";import{i as Mt,n as Nt,s as Pt,t as Ft,u as It}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{D as Lt,E as Rt,G as zt,L as Bt,R as Vt,W as Ht,k as Ut,z as Wt}from"./runtime-file-resource-DDGMqGyv.js";import{a as Gt,i as Kt,n as qt,o as Jt,t as Yt}from"./path-utils-jGozTg9d.js";import{a as Xt,d as Zt,f as Qt,g as $t,h as en,i as tn,m as nn,o as rn,r as G,s as an}from"./vendor-reactuses-core-DjKFMfz7.js";import{o as on}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{a as sn,o as cn,r as ln,x as un}from"./useUIStore-CxX_u4P7.js";import{n as dn,o as fn,r as pn}from"./useMobileHtmlPreviewStore-ChIGW-4e.js";import{t as mn}from"./uuid-D-SDZijH.js";import{d as hn,t as gn}from"./vendor-pierre-diffs-B0OmIhMO.js";import{r as _n}from"./vendor-sonner-DX3nfJx4.js";import{s as vn}from"./spacedFileMention-Ds4GtgiF.js";import{$a as yn,$i as bn,$n as xn,B as Sn,Br as Cn,Bt as wn,C as Tn,Ca as En,Cn as Dn,Ct as On,D as kn,Dn as An,Dr as jn,E as Mn,En as Nn,Er as Pn,Fa as Fn,Fn as In,G as K,Ga as Ln,Gn as Rn,H as zn,Ha as Bn,Ia as Vn,Ir as q,It as Hn,J as Un,Jn as Wn,Jt as Gn,K as Kn,Kn as qn,Kt as Jn,La as Yn,Lt as Xn,M as Zn,Mn as Qn,Mr as $n,N as er,Nn as tr,Nr as nr,Nt as rr,O as ir,Or as ar,P as or,Pr as sr,Qn as cr,Qt as lr,Rn as ur,Rt as dr,Sn as fr,St as pr,T as mr,U as hr,Un as gr,V as _r,Va as vr,Vt as yr,W as br,Wn as xr,Wr as Sr,X as Cr,Xi as wr,Xn as Tr,Xt as Er,Yn as Dr,Z as Or,Zi as kr,Zt as Ar,_r as jr,_t as Mr,aa as Nr,ai as Pr,ao as Fr,ar as Ir,ba as Lr,bi as Rr,bn as zr,bt as Br,c as Vr,ca as Hr,cn as Ur,ct as Wr,da as Gr,dr as Kr,dt as qr,eo as Jr,et as Yr,f as Xr,fa as Zr,fn as Qr,fr as $r,g as ei,ga as ti,gn as ni,gr as ri,gt as ii,hr as ai,ia as oi,io as J,ir as si,it as ci,jn as li,jr as ui,jt as di,kr as fi,la as pi,lr as mi,lt as Y,m as hi,nn as gi,no as _i,nr as vi,oa as yi,on as bi,or as xi,ot as Si,pn as Ci,pr as wi,pt as Ti,qn as Ei,r as Di,ra as Oi,ro as ki,rr as Ai,s as ji,sa as Mi,sn as Ni,st as Pi,t as Fi,ti as Ii,tn as Li,to as Ri,ua as zi,ur as Bi,ut as Vi,vn as Hi,vt as Ui,w as Wi,wn as Gi,xi as Ki,xn as qi,xt as Ji,ya as Yi,yn as Xi,yt as Zi,zt as Qi}from"./ui-BPOP32rM.js";import{n as X}from"./Icon-DrsaL1yC.js";import{d as $i,f as ea,i as ta}from"./remoteProjectQueries-DFbTE2e2.js";import{t as na}from"./i18n-BZ_vx76q.js";import"./vendor-opencode-schema-DWT45VBX.js";import{n as ra}from"./input-store-CW2R7gKr.js";import{a as ia,o as aa,u as oa}from"./toolHelpers-iEHVHQ9p.js";import{n as sa,t as ca}from"./ScrollableOverlay-CFjKY4OJ.js";import{C as la,S as ua,_ as da,t as fa}from"./MobileResizableSheet-DKpNzqfc.js";import{a as pa,o as ma,t as ha}from"./vendor-framer-motion-D5NyyC73.js";import{n as ga}from"./mobileAppContext-BQgdTp5T.js";import{n as _a,r as va,t as ya}from"./vendor-tanstack-react-virtual-qsd3nvZb.js";import{a as ba,i as xa,n as Sa,o as Ca,r as wa,s as Ta,t as Ea}from"./dialog-DnZWrDDM.js";import{t as Da}from"./OverlayScrollbar-CZ86VwiO.js";import{i as Oa,n as ka,t as Aa}from"./tooltip-wFf92wqJ.js";import{n as ja,t as Ma}from"./useInlineCommentDraftStore-Wde2bT5p.js";import{n as Na,t as Pa}from"./useThemeSystem-BIXghnHj.js";import{t as Fa}from"./truncated-path-CNuLLJYq.js";import{r as Ia}from"./device-5-ZkrAmh.js";import{c as La,n as Ra,r as za,t as Ba}from"./dropdown-menu-CZWYeFpO.js";import{n as Va,t as Ha}from"./kbd-U9NdVaVr.js";import{t as Ua}from"./appThemeRegistry-BdjrGBQ4.js";import{r as Wa}from"./themes-BgDJcxRc.js";import{n as Ga}from"./useEffectiveDirectory-DleT4CpD.js";import{b as Ka}from"./gitApi-CT9_Fyh4.js";import{c as qa,n as Ja,s as Ya,t as Xa}from"./useGitStore-DTlP-L0a.js";import{o as Za,s as Qa}from"./useProjectGitStore-EZRP6D6M.js";import{t as $a}from"./agentColors-DWSbQXy2.js";import{C as eo,D as to,E as no,O as ro,S as io,T as ao,_ as oo,a as so,b as co,c as lo,d as uo,f as fo,g as po,h as mo,i as ho,j as go,l as _o,m as vo,p as yo,u as bo,v as xo,w as So,x as Co,y as wo}from"./mobileBackNavigation-CUoYXnE0.js";import{t as To}from"./ImageLoadingPlaceholder-Br3hw4E6.js";import{t as Eo}from"./LoadingImage-BBQSz8J1.js";import{t as Do}from"./input-DSY3Mg4G.js";import{i as Oo,n as ko,o as Ao,r as jo,t as Mo}from"./MarkdownRenderer-CGgHX4n3.js";import{a as No}from"./markdownHeightCache-BhpqKZQB.js";import{t as Po}from"./dualLimitLru-D8Sphgua.js";import{c as Fo,n as Io,o as Lo,r as Ro}from"./imageSource-q3O_Nkg5.js";import{_ as zo,i as Bo,n as Vo,s as Ho}from"./shortcuts-B0XmqH9X.js";import{a as Uo,d as Wo,f as Go,i as Ko,n as qo,o as Jo,r as Yo,s as Xo,t as Zo,u as Qo}from"./SessionSurfaceContext-BP4NCKp6.js";import{i as $o,n as es,r as ts,t as ns}from"./TextSelectionMenu-DcQCHZnp.js";import{o as rs}from"./useSessionBtwStore-DjwWijyt.js";import{t as is}from"./useDebouncedValue-BHlMPqY8.js";import{a as as,i as os,r as ss,t as cs}from"./AgentAvatar-BSBHv-65.js";import{t as ls}from"./checkbox-BIU2MT0K.js";import{t as us}from"./YuriLogo-CcVNX93s.js";import{i as ds,o as fs}from"./contextPanelEmbeddedChat-Dm5R_b5X.js";import{a as ps,r as ms,t as hs}from"./connection-hint-Ca1b_CjA.js";import{a as gs,c as _s,d as vs,i as ys,l as bs,o as xs,s as Ss,u as Cs}from"./chatUpwardIntent-uWd0ddoK.js";import{a as ws,i as Ts,o as Es,s as Ds,u as Os}from"./fileMentionTouchSelection-Bwr_ZfU3.js";import{l as ks,n as As,t as js}from"./fileMentionAutocompleteState-B9411b4o.js";import{a as Ms,c as Ns,d as Ps,f as Fs,i as Is,l as Ls,n as Rs,o as zs,p as Bs,r as Vs,s as Hs,t as Us}from"./insertionBoundaries-C1ACCndo.js";import{n as Ws,t as Gs}from"./ModelLogo-CwKqpjSR.js";import{n as Ks,t as qs}from"./useDictation-Dw4cPz-9.js";import{A as Js,D as Ys,E as Xs,F as Zs,I as Qs,L as $s,N as ec,O as tc,P as nc,R as rc,S as ic,T as ac,_ as oc,a as sc,b as cc,c as lc,d as uc,f as dc,g as fc,h as pc,i as mc,j as hc,k as gc,l as _c,m as vc,o as yc,p as bc,r as xc,s as Sc,t as Cc,u as wc,v as Tc,w as Ec,x as Dc,y as Oc}from"./BtwPanel-CgSxuUbP.js";import{a as kc,c as Ac,d as jc,f as Mc,i as Nc,l as Pc,m as Fc,n as Ic,o as Lc,p as Rc,r as zc,s as Bc,t as Vc,u as Hc}from"./reference-history-BfwrDjks.js";import{A as Uc,B as Wc,D as Gc,E as Kc,F as qc,G as Jc,H as Yc,I as Xc,J as Zc,K as Qc,L as $c,M as el,N as tl,O as nl,Q as rl,R as il,T as al,U as ol,V as sl,W as cl,X as ll,Y as ul,_ as dl,a as fl,b as pl,c as ml,d as hl,f as gl,g as _l,h as vl,j as yl,k as bl,l as xl,m as Sl,o as Cl,p as wl,q as Tl,r as El,s as Dl,t as Ol,u as kl,v as Al,w as jl,x as Ml,y as Nl,z as Pl}from"./BusyDots-CTw2sYb1.js";import{A as Fl,C as Il,D as Ll,E as Rl,N as zl,O as Bl,P as Vl,S as Hl,T as Ul,_ as Wl,a as Gl,b as Kl,c as ql,d as Jl,g as Yl,h as Xl,m as Zl,n as Ql,p as $l,r as eu,s as tu,t as nu,v as ru,w as iu,x as au,y as ou}from"./queue-abort-optimistic-CkmS8yTs.js";import{_ as su,a as cu,c as lu,g as uu,l as du,o as fu,t as pu,v as mu,y as hu}from"./vendor-dnd-kit-core-qy5stxu5.js";import{i as gu,n as _u,o as vu,s as yu,t as bu}from"./vendor-dnd-kit-sortable-CiTIuX4o.js";import{t as xu}from"./MobileOverlayPanel-cwgcgCxI.js";import{c as Su,d as Cu,f as wu,n as Tu,o as Eu,p as Du,s as Ou,t as ku,u as Au}from"./useModelLists-DUsn2kaq.js";import{n as ju,t as Mu}from"./useOpenCodeReadiness-Bxz72dNZ.js";import{a as Nu,c as Pu,d as Fu,f as Iu,h as Lu,i as Ru,l as zu,m as Bu,o as Vu,p as Hu,r as Uu,s as Wu,t as Gu,u as Ku}from"./ToolOutputDialog-D_Kl-Bc5.js";import{t as qu}from"./vendor-motion-vLNN8EMu.js";import{c as Ju,i as Yu,n as Xu,o as Zu,s as Qu,t as $u}from"./select-DNrc5_kl.js";import{a as ed}from"./githubAuthQueries-DJcn8yuA.js";import{c as td,i as nd,l as rd,n as id,o as ad,r as od,t as sd}from"./remote-input-store-BPnodmVx.js";import{a as cd,i as ld,n as ud}from"./projectMeta-S7fUN1Zp.js";import{a as dd,c as fd,d as pd,f as md,l as hd,m as gd,o as _d,p as vd,r as yd,s as bd,u as xd}from"./auto-read-context-Dov0luVf.js";import{n as Sd}from"./permission-rules-DoQUXKll.js";import{n as Cd}from"./markdownTheme-D84XyNiT.js";import"./DiffViewToggle-Da3vQFP9.js";import{i as wd,n as Td,t as Ed}from"./FadeInOnReveal-DJrSq3fM.js";import{t as Dd}from"./useStreamingTextThrottle-B8aWuwgs.js";var Z=jt(),Q=e(Ne(),1),Od=new Po({maxEntries:128,maxBytes:1048576}),kd=(e,t,n)=>`${+!!t}:${n}:${e.map(e=>`${e.id}\0${e.title}\0${e.subtitle??``}\0${e.badge??``}\0${e.iconName}\0${e.agentName??``}`).join(`|`)}`,Ad=async e=>{let t=no(`--surface-foreground`);return Promise.all(e.slice(0,40).map(async e=>{let n=e.agentName===void 0?void 0:as($a(e.agentName).var,no),r=JSON.stringify([e.iconName,t,e.agentName,n?.background]),i=Od.get(r);return i===void 0&&(i=await(e.agentName===void 0?Os(e.iconName,t):So(os(`agent`,e.agentName,!1,n)))??``,i&&Od.set(r,i,(r.length+i.length)*2)),{id:e.id,title:e.title,subtitle:e.subtitle??``,badge:e.badge??``,iconBase64:i}}))},jd=[],Md=e=>void 0,Nd=()=>void 0;function Pd(e){let t=go()&&e.enabled&&yo(e.isMobile),n=(0,Q.useRef)(Symbol(`native-composer-owner`)).current,r=(0,Q.useRef)(null),i=(0,Q.useRef)(e.text),a=(0,Q.useRef)(!1),o=(0,Q.useRef)(-1),s=(0,Q.useRef)(null),c=(0,Q.useRef)(``),l=(0,Q.useRef)(``),u=ss(e.agentName),d=Pa()?.currentTheme,f=(0,Q.useRef)([]),p=(0,Q.useRef)(vo()),m=G(e.onText),h=G(e.onSend),g=G(e.onAbort),_=G(e.onAttach),v=G(e.onFiles),y=G(e.onRemoveAttachment),b=G(e.onOpenModel),x=G(e.onCycleAgent),S=G(e.onOpenAgent),C=G(e.onScrollToBottom),w=G(e.onAutocompleteAccept??Md),T=G(e.onAutocompleteDismiss??Nd),E={onText:(e,t,r)=>{so.owns(n)&&(ro({incoming:e,replacedText:s.current})||(s.current=null,i.current=e,a.current=!0,m(e,t,r)))},onSend:e=>{so.owns(n)&&(i.current=e,h(e,()=>so.owns(n)))},onAbort:g,onAttach:_,onFiles:v,onRemoveAttachment:y,onOpenModel:b,onCycleAgent:x,onOpenAgent:S,onHeight:G(e=>{typeof document>`u`||_o(document.documentElement,e)}),onScrollToBottom:C,onAutocompleteAccept:e=>{a.current=!1,w(e)},onAutocompleteDismiss:T},D=()=>({text:e.text,placeholder:e.placeholder,modelLabel:e.modelLabel,modelVariantLabel:e.modelVariantLabel,modelIcon:c.current,canSend:e.canSend,canAbort:e.canAbort,attachmentCount:e.attachmentCount,attachmentPreviews:f.current,citationRanges:_t(e.text,e.attachments.map(e=>e.filename)),chipRanges:uo(xo(e.text,e.chipHighlights),no(`--primary`)),appearance:typeof document>`u`?`dark`:Co(document.documentElement),attachAria:e.attachAria,attachTitle:e.attachTitle,attachPhotosLabel:e.attachPhotosLabel,attachFilesLabel:e.attachFilesLabel,attachCancelLabel:e.attachCancelLabel,sendAria:e.sendAria,queueAria:e.queueAria,stopAria:e.stopAria,modelAria:e.modelAria,agentAria:e.agentAria,agentLabel:e.agentLabel,agentColor:co(e.agentName||void 0),agentIdenticon:io(e.agentName||void 0),agentIcon:l.current,suppressed:e.suppressed,showScrollToBottom:e.showScrollToBottom,scrollAria:e.scrollAria,autocomplete:p.current}),O=G(e=>{let t=D();r.current=t,i.current=t.text,so.claim(n,e,t,E)});(0,Q.useLayoutEffect)(()=>{if(!t||typeof document>`u`)return;let e=document.documentElement;O(e);let i=ho({conceal:()=>{so.owns(n)&&so.conceal()},reveal:()=>{so.owns(n)&&so.reveal()}});return()=>{r.current=null,i(),so.releaseOwner(n,e)}},[t,n,O]),(0,Q.useEffect)(()=>{if(!t)return;let i=!1,a=e=>{l.current=e,r.current&&={...r.current,agentIcon:e},so.updateOwner(n,{agentIcon:e})};return a(``),So(os(`agent`,e.agentName||void 0,!1,u)).then(e=>{i||a(e??``)}),()=>{i=!0}},[t,n,e.agentName,u]),(0,Q.useEffect)(()=>{if(!t)return;let i=!1,a=Ws(e.modelId,e.providerId),o={modelIcon:``,modelLabel:e.modelLabel,modelVariantLabel:e.modelVariantLabel};if(c.current=``,r.current&&={...r.current,...o},so.updateOwner(n,o),a)return So(a).then(t=>{if(i)return;let a=t??``;c.current=a;let o={modelIcon:a,modelLabel:e.modelLabel,modelVariantLabel:e.modelVariantLabel};r.current&&={...r.current,...o},so.updateOwner(n,o)}),()=>{i=!0}},[t,n,e.modelId,e.providerId,e.modelLabel,e.modelVariantLabel]);let k=bo(e.attachments);(0,Q.useEffect)(()=>{if(!t)return;let i=!1,a=e.attachments;if(a.length===0){f.current=[],r.current&&={...r.current,attachmentPreviews:[]},so.updateOwner(n,{attachmentPreviews:[]});return}return Promise.all(a.map(async t=>{let n=t.mimeType.startsWith(`image/`)&&t.dataUrl?await eo(t.dataUrl):``;return{id:t.id,filename:t.filename,mime:t.mimeType,thumbnailBase64:n??``,removeAria:e.removeAttachmentNamedAria(t.filename)}})).then(e=>{i||(f.current=e,r.current&&={...r.current,attachmentPreviews:e},so.updateOwner(n,{attachmentPreviews:e}))}),()=>{i=!0}},[t,n,k]);let A=e.autocompleteRows??jd,j=e.autocompleteOpen===!0,M=e.autocompleteHighlightedIndex??0,N=e.autocompleteQuery??``,P=`${kd(A,j,M)}\0${N}`;(0,Q.useEffect)(()=>{if(!t)return;let e=!1;if(!(j&&A.length>0)){let e=vo();oo(p.current,e)||(p.current=e,r.current&&={...r.current,autocomplete:e},so.updateOwner(n,{autocomplete:e}));return}return Ad(A).then(t=>{if(e)return;let i={open:t.length>0,highlightedIndex:Math.max(0,Math.min(M,Math.max(t.length-1,0))),query:N,highlightColor:no(`--primary-base`)||no(`--primary`),rows:t};oo(p.current,i)||(p.current=i,r.current&&={...r.current,autocomplete:i},so.updateOwner(n,{autocomplete:i}))}),()=>{e=!0}},[t,n,P,d]);let F=t?xo(e.text,e.chipHighlights).map(e=>`${e.start}:${e.end}:${e.triggerLength}`).join(`|`):``;return(0,Q.useEffect)(()=>{if(!t)return;let c=D(),l=r.current;if(l&&wo(l,c)){a.current=!1,o.current=e.textPresetEpoch;return}r.current=c;let u=e.textPresetEpoch!==o.current;o.current=e.textPresetEpoch;let d=to({nextText:c.text,nativeOwnedText:i.current,echoingNative:a.current,preset:u});a.current=!1,!d.omitText&&d.forceText&&(s.current=i.current),d.omitText||(i.current=c.text);let f=fo(l,c,d,{caret:e.caret});f&&so.updateOwner(n,f)},[t,n,e.text,e.textPresetEpoch,e.placeholder,e.modelLabel,e.modelVariantLabel,e.modelId,e.providerId,e.canSend,e.canAbort,e.attachmentCount,k,e.suppressed,e.attachAria,e.attachTitle,e.attachPhotosLabel,e.attachFilesLabel,e.attachCancelLabel,e.sendAria,e.queueAria,e.stopAria,e.modelAria,e.agentName,e.agentLabel,e.agentAria,e.showScrollToBottom,e.scrollAria,F]),t}function Fd(e){return Pd(e),null}var Id=new WeakMap;function Ld({draftKey:e,text:t,textareaRef:n,enabled:r,store:i=ra}){let a=e?.transportIdentity,o=e?.owner.kind,s=e?.owner.ownerID,c=(0,Q.useMemo)(()=>a&&o&&s?{transportIdentity:a,owner:{kind:o,ownerID:s}}:null,[a,o,s]),l=(0,Q.useRef)(null),u=c?i.getState().getDraft(c):void 0;return(0,Q.useLayoutEffect)(()=>{let e=n.current;if(!r||!c||!e)return;let t=Id.get(i);t||(t=new WeakMap,Id.set(i,t));let a=i.getState().getDraft(c),o=a?t.get(a)?.selection:void 0,s={},u={node:e,owner:s,record:a,text:e.value,pending:a&&o?{record:a,selection:o}:void 0};return l.current=u,a&&t.set(a,{owner:s}),()=>{let n=i.getState().getDraft(c);n&&n===u.record&&t.get(n)?.owner===s&&e.value===u.text&&t.set(n,{owner:s,selection:{text:e.value,start:e.selectionStart,end:e.selectionEnd,direction:e.selectionDirection}}),l.current===u&&(l.current=null)}},[r,c,i,n]),(0,Q.useLayoutEffect)(()=>{let e=l.current;if(!e)return;let n=Id.get(i);u&&u!==e.record&&n.set(u,{owner:e.owner}),e.record=u,e.text=t;let r=e.pending;if(r){if(u!==r.record){e.pending=void 0;return}t===r.selection.text&&e.node.value===t&&(e.pending=void 0,e.node.setSelectionRange(r.selection.start,r.selection.end,r.selection.direction))}},[r,c,u,i,t]),G(()=>{l.current&&(l.current.pending=void 0)})}var $=Me(),Rd=e=>{let t=Math.floor(e/60),n=e%60;return`${t}:${String(n).padStart(2,`0`)}`},zd=e=>{let t=(0,Z.c)(4),{volume:n}=e,{currentTheme:r}=Na(),i=Math.min(1,Math.max(0,n)),a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=[.45,.7,1,.7,.45],t[0]=a):a=t[0];let o=a,s;return t[1]!==r||t[2]!==i?(s=(0,$.jsx)(`div`,{className:`flex h-6 w-10 flex-shrink-0 items-center justify-center gap-1`,"aria-hidden":`true`,children:o.map((e,t)=>(0,$.jsx)(`span`,{className:`h-full w-1 rounded-full transition-transform duration-75 ease-out motion-reduce:transition-none`,style:{backgroundColor:r.colors.primary.base,transform:`scaleY(${.25+i*e*.75})`}},t))}),t[1]=r,t[2]=i,t[3]=s):s=t[3],s},Bd=e=>{let t=kr(e=>e.sttLocalModel),[n,r]=Q.useState(null);return Q.useEffect(()=>{if(!e){r(null);return}let n=!1,i=async()=>{try{let e=await o(`/api/dictation/status`,{query:{provider:`local`,localModel:t}});if(!e.ok||n)return;let i=await e.json(),a=Array.isArray(i?.models)?i.models.find(e=>e.id===t):null;n||r(typeof a?.downloadProgress==`number`?a.downloadProgress:null)}catch{}};i();let a=setInterval(()=>{i()},2e3);return()=>{n=!0,clearInterval(a)}},[e,t]),e?n:null},Vd=e=>{let t=(0,Z.c)(89),{radius:n,isMobile:r,footerIconButtonClass:i,footerPaddingClass:a,iconSizeClass:o,sendIconSizeClass:s,disabled:c,onInsert:l,onInsertAndSend:u,onActiveChange:d,onContentHeightChange:f,renderTrigger:p,topAccessory:m}=e,h=p===void 0||p,{t:g}=na(),{currentTheme:_}=Na(),v=kr(Hd),y=ln(Ud),b;t[0]===y?b=t[1]:(b=Bo(Ho(`toggle_dictation`,y)),t[0]=y,t[1]=b);let x=b,[S]=Q.useState(Wd),C=Q.useRef(null),w=Q.useRef(l),T=Q.useRef(u),E,D;t[2]!==l||t[3]!==u?(E=()=>{w.current=l,T.current=u},D=[l,u],t[2]=l,t[3]=u,t[4]=E,t[5]=D):(E=t[4],D=t[5]),Q.useEffect(E,D);let O;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(O={onTranscript:e=>{let t=C.current;C.current=null,t===`send`?T.current(e):w.current(e)}},t[6]=O):O=t[6];let{status:k,partialTranscript:A,volume:j,duration:M,error:N,errorReason:P,startDictation:F,confirmDictation:I,cancelDictation:L,retryFailedDictation:R,acceptPartialTranscript:ee,discardFailedDictation:z}=qs(O),B=k===`recording`&&P===`model_download_in_progress`,V=Bd(B),H=Q.useRef(k),U,te;t[7]===k?(U=t[8],te=t[9]):(U=()=>{H.current=k},te=[k],t[7]=k,t[8]=U,t[9]=te),Q.useEffect(U,te);let ne,re;t[10]!==d||t[11]!==k?(ne=()=>(d?.(k!==`idle`),()=>d?.(!1)),re=[k,d],t[10]=d,t[11]=k,t[12]=ne,t[13]=re):(ne=t[12],re=t[13]),Q.useLayoutEffect(ne,re);let W,ie;t[14]!==I||t[15]!==v||t[16]!==c||t[17]!==F||t[18]!==S?(W=()=>{if(!S||!v||c)return;let e=()=>{H.current===`idle`?F():H.current===`recording`&&(C.current=`insert`,I())};return window.addEventListener(`yuri:dictation-toggle`,e),()=>window.removeEventListener(`yuri:dictation-toggle`,e)},ie=[S,v,c,F,I],t[14]=I,t[15]=v,t[16]=c,t[17]=F,t[18]=S,t[19]=W,t[20]=ie):(W=t[19],ie=t[20]),Q.useEffect(W,ie);let ae,oe;t[21]!==L||t[22]!==I||t[23]!==k?(ae=()=>{if(k!==`recording`)return;let e=e=>{if(!e.isComposing){if(e.key===`Enter`&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey){e.preventDefault(),e.stopPropagation(),C.current=`insert`,I();return}e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),L())}};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},oe=[k,I,L],t[21]=L,t[22]=I,t[23]=k,t[24]=ae,t[25]=oe):(ae=t[24],oe=t[25]),Q.useEffect(ae,oe);let se=Q.useRef(null),ce=Q.useRef(null),le=Q.useRef(null),[ue,de]=Q.useState(null),fe=k!==`idle`,pe=Q.useRef(f),me,he;t[26]===f?(me=t[27],he=t[28]):(me=()=>{pe.current=f},he=[f],t[26]=f,t[27]=me,t[28]=he),Q.useEffect(me,he);let ge=Q.useRef(!1),_e;t[29]===fe?_e=t[30]:(_e=()=>{if(!fe){ge.current&&(ge.current=!1,pe.current?.(null));return}let e=ce.current,t=le.current;if(!e||!t)return;let n=window.getComputedStyle(e),r=(parseFloat(n.paddingTop)||0)+(parseFloat(n.paddingBottom)||0);ge.current=!0,pe.current?.(t.offsetHeight+r),e.scrollTop=e.scrollHeight},t[29]=fe,t[30]=_e);let ve;t[31]!==N||t[32]!==fe||t[33]!==A||t[34]!==k?(ve=[fe,A,k,N],t[31]=N,t[32]=fe,t[33]=A,t[34]=k,t[35]=ve):ve=t[35],Q.useLayoutEffect(_e,ve);let ye,be;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(ye=()=>()=>{ge.current&&(ge.current=!1,pe.current?.(null))},be=[],t[36]=ye,t[37]=be):(ye=t[36],be=t[37]),Q.useEffect(ye,be);let xe,Se;if(t[38]===fe?(xe=t[39],Se=t[40]):(xe=()=>{if(!fe)return;let e=se.current?.closest(`[data-chat-input-footer="true"]`);e&&e.offsetHeight>0&&de(e.offsetHeight)},Se=[fe],t[38]=fe,t[39]=xe,t[40]=Se),Q.useLayoutEffect(xe,Se),!S||!v)return null;let Ce=k!==`idle`,we;t[41]===I?we=t[42]:(we=e=>{C.current=e,I()},t[41]=I,t[42]=we);let Te=we,Ee;t[43]===R?Ee=t[44]:(Ee=()=>{C.current=`insert`,R()},t[43]=R,t[44]=Ee);let De=Ee,Oe;bb0:{if(k===`failed`){Oe=``;break bb0}if(k===`uploading`){let e;t[45]===g?e=t[46]:(e=g(`chat.dictation.processing`),t[45]=g,t[46]=e),Oe=e;break bb0}if(B){let e;t[47]!==V||t[48]!==g?(e=V===null?g(`chat.dictation.downloadingModel`):g(`chat.dictation.downloadingModelProgress`,{percent:String(V)}),t[47]=V,t[48]=g,t[49]=e):e=t[49],Oe=e;break bb0}let e;t[50]===g?e=t[51]:(e=g(`chat.dictation.listening`),t[50]=g,t[51]=e),Oe=e}let ke=Oe,Ae;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={onMouseDown:Gd,onPointerDownCapture:Kd},t[52]=Ae):Ae=t[52];let je=Ae,Me;t[53]!==x||t[54]!==c||t[55]!==i||t[56]!==o||t[57]!==Ce||t[58]!==h||t[59]!==F||t[60]!==g?(Me=h?(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:()=>{F()},disabled:c||Ce,title:x?`${g(`chat.dictation.start`)} (${x})`:g(`chat.dictation.start`),"aria-label":g(`chat.dictation.start`),children:(0,$.jsx)(X,{name:`mic`,className:J(o,`text-current`)})}):null,t[53]=x,t[54]=c,t[55]=i,t[56]=o,t[57]=Ce,t[58]=h,t[59]=F,t[60]=g,t[61]=Me):Me=t[61];let Ne;t[62]!==ee||t[63]!==L||t[64]!==Te||t[65]!==_||t[66]!==z||t[67]!==M||t[68]!==N||t[69]!==ue||t[70]!==i||t[71]!==a||t[72]!==o||t[73]!==Ce||t[74]!==r||t[75]!==B||t[76]!==A||t[77]!==ke||t[78]!==n||t[79]!==De||t[80]!==s||t[81]!==k||t[82]!==g||t[83]!==m||t[84]!==j?(Ne=Ce?(0,$.jsxs)(`div`,{ref:se,className:J(`absolute inset-0 z-50 flex flex-col overflow-x-hidden overflow-y-hidden`,r&&`yuri-composer-morph-content-fade`),style:{borderRadius:n,backgroundColor:_.colors.surface.subtle},role:`dialog`,"aria-label":g(`chat.dictation.overlayAria`),children:[m,(0,$.jsx)(`div`,{ref:ce,className:J(`scrollbar-none flex-1 min-h-0 overflow-y-auto px-3`,r?`pt-3.5 pb-2.5`:`pt-5 pb-2`),children:(0,$.jsxs)(`div`,{ref:le,className:J(!A&&`translate-y-1.5`),children:[A?(0,$.jsx)(`p`,{className:`typography-markdown md:typography-ui-label whitespace-pre-wrap`,style:{color:_.colors.surface.foreground},children:A}):k===`recording`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,style:{color:_.colors.surface.mutedForeground},children:[(0,$.jsx)(zd,{volume:j}),(0,$.jsx)(`p`,{className:`typography-markdown md:typography-ui-label`,children:ke})]}):(0,$.jsx)(`p`,{className:`typography-markdown md:typography-ui-label`,style:{color:_.colors.surface.mutedForeground},children:ke}),k===`failed`?(0,$.jsx)(`p`,{className:`typography-meta mt-1`,style:{color:_.colors.status.error},children:N||g(`chat.dictation.failed`)}):null,k===`recording`&&N&&!B?(0,$.jsx)(`p`,{className:`typography-meta mt-1`,style:{color:_.colors.status.warning},children:N}):null]})}),(0,$.jsxs)(`div`,{className:J(`flex flex-shrink-0 items-center gap-x-3`,a),style:ue?{height:ue}:void 0,children:[k===`recording`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`span`,{className:`relative ml-1 flex h-2 w-2 flex-shrink-0`,"aria-hidden":`true`,children:[(0,$.jsx)(`span`,{className:`absolute inline-flex h-full w-full animate-ping rounded-full opacity-60`,style:{backgroundColor:_.colors.status.error}}),(0,$.jsx)(`span`,{className:`relative inline-flex h-2 w-2 rounded-full`,style:{backgroundColor:_.colors.status.error}})]}),(0,$.jsx)(zd,{volume:j}),(0,$.jsx)(`span`,{className:`typography-meta tabular-nums`,style:{color:_.colors.surface.mutedForeground},children:Rd(M)})]}):k===`uploading`?(0,$.jsx)(X,{name:`loader-4`,className:`ml-1 h-4 w-4 animate-spin`,style:{color:_.colors.surface.mutedForeground}}):null,(0,$.jsx)(`div`,{className:J(`ml-auto flex items-center`,r?`gap-x-1`:`gap-x-1.5 md:gap-x-3`),children:k===`recording`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-muted-foreground hover:text-foreground`),onClick:()=>{L()},title:g(`chat.dictation.cancel`),"aria-label":g(`chat.dictation.cancel`),children:(0,$.jsx)(X,{name:`close`,className:o})}),(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:()=>Te(`insert`),title:g(`chat.dictation.insert`),"aria-label":g(`chat.dictation.insert`),children:(0,$.jsx)(X,{name:`check`,className:o})}),(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-primary hover:text-primary`),onClick:()=>Te(`send`),title:g(`chat.dictation.insertAndSend`),"aria-label":g(`chat.dictation.insertAndSend`),children:(0,$.jsx)(X,{name:`send-plane-2`,className:s})})]}):k===`uploading`?(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-muted-foreground hover:text-foreground`),onClick:()=>{L()},title:g(`chat.dictation.cancel`),"aria-label":g(`chat.dictation.cancel`),children:(0,$.jsx)(X,{name:`close`,className:o})}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`button`,{type:`button`,...je,className:J(i,`text-muted-foreground hover:text-foreground`),onClick:z,title:g(`chat.dictation.discard`),"aria-label":g(`chat.dictation.discard`),children:(0,$.jsx)(X,{name:`close`,className:o})}),(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:De,title:g(`chat.dictation.retry`),"aria-label":g(`chat.dictation.retry`),children:(0,$.jsx)(X,{name:`refresh`,className:o})}),A.trim()?(0,$.jsx)(`button`,{type:`button`,...je,className:i,onClick:()=>{C.current=`insert`,ee()},title:g(`chat.dictation.insert`),"aria-label":g(`chat.dictation.insert`),children:(0,$.jsx)(X,{name:`check`,className:o})}):null]})})]})]}):null,t[62]=ee,t[63]=L,t[64]=Te,t[65]=_,t[66]=z,t[67]=M,t[68]=N,t[69]=ue,t[70]=i,t[71]=a,t[72]=o,t[73]=Ce,t[74]=r,t[75]=B,t[76]=A,t[77]=ke,t[78]=n,t[79]=De,t[80]=s,t[81]=k,t[82]=g,t[83]=m,t[84]=j,t[85]=Ne):Ne=t[85];let Pe;return t[86]!==Me||t[87]!==Ne?(Pe=(0,$.jsxs)($.Fragment,{children:[Me,Ne]}),t[86]=Me,t[87]=Ne,t[88]=Pe):Pe=t[88],Pe};function Hd(e){return e.dictationEnabled}function Ud(e){return e.shortcutOverrides}function Wd(){return!d()&&Ks()}function Gd(e){return e.preventDefault()}function Kd(e){e.pointerType===`touch`&&e.preventDefault()}var qd=e(je(),1);function Jd({onInsert:e,onPartial:t,onStart:n,onCancel:r,className:i,iconClassName:a,inputRef:o,onRecordingChange:s,onActiveChange:c,interactionMode:l=`desktop`,disabled:u=!1}){let{t:d}=na(),f=ln(e=>e.shortcutOverrides),p=Bo(Ho(`toggle_dictation`,f)),m=qs({onTranscript:e,onPartialTranscript:t}),h=(0,Q.useRef)(!1),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(!1),b=g||m.isStarting,x=m.status===`recording`,S=m.status===`uploading`,C=l===`mobile`,w=b||v||S,T=x||w,E=G(e=>c?.(e));(0,Q.useEffect)(()=>(E(T),()=>E(!1)),[T,E]);let D=(0,Q.useRef)(null),O=(0,Q.useRef)(null),k=(0,Q.useRef)(null),A=(0,Q.useRef)(null),j=(0,Q.useRef)({x:0,y:0}),M=G(e=>s?.(e));(0,Q.useEffect)(()=>(M(x&&(C||!w)),()=>M(!1)),[x,w,C,M]);let N=(0,Q.useRef)(0);(0,Q.useEffect)(()=>()=>{N.current+=1},[]);let P=G(async(e=!1)=>{if(v)return;let t=o?.current,n=N.current;h.current=!1,y(!0);try{await m.confirmDictation()}finally{y(!1),e&&!C&&n===N.current&&t?.isConnected&&o?.current===t&&!t.disabled&&!t.readOnly&&!document.hidden&&document.hasFocus()&&(document.activeElement===document.body||document.activeElement===t||k.current?.contains(document.activeElement))&&(t.focus({preventScroll:!0}),t.setSelectionRange(t.value.length,t.value.length))}}),F=G(()=>{D.current=null,x&&(h.current=!1,P())}),I=G(async()=>{if(!(v||S)){if(x){F();return}if(!(S||b||u)){m.status===`failed`&&(r(),m.discardFailedDictation()),h.current=!1,n(),_(!0);try{await m.startDictation(),h.current=!0}finally{_(!1)}}}}),[,L,R]=en(()=>{let e=O.current;O.current=null;let t=o?.current;!e||!t||t.disabled||t.readOnly||u||T||t.selectionStart!==t.selectionEnd||(D.current=e.id,k.current?.setPointerCapture?.(e.id),t.blur(),t.setSelectionRange(t.value.length,t.value.length),I())},500,{immediate:!1}),ee=G(()=>{O.current&&(O.current=null,R())});tn(`pointerdown`,e=>{if(C)return;let t=o?.current;!t||e.target!==t||t.disabled||t.readOnly||e.pointerType!==`mouse`||e.button!==0||e.detail>1||u||T||D.current!==null||(O.current={id:e.pointerId,x:e.clientX,y:e.clientY},j.current={x:e.clientX,y:e.clientY},L())},window,{capture:!0}),tn(`pointermove`,e=>{let t=O.current;t?.id===e.pointerId&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>6&&ee(),D.current===e.pointerId&&(e.preventDefault(),j.current={x:e.clientX,y:e.clientY},A.current&&(A.current.style.transform=`translate(${e.clientX}px, ${e.clientY}px)`))},window,{capture:!0}),tn(`selectstart`,e=>{D.current!==null&&e.preventDefault()},document,{capture:!0}),tn(`mousemove`,e=>{D.current!==null&&e.preventDefault()},window,{capture:!0}),tn(`selectionchange`,()=>{if(D.current===null)return;let e=o?.current;e&&e.selectionStart!==e.selectionEnd&&e.setSelectionRange(e.selectionEnd,e.selectionEnd);let t=document.getSelection();t&&!t.isCollapsed&&t.removeAllRanges()},document),tn(`pointerup`,e=>{O.current?.id===e.pointerId&&ee(),D.current===e.pointerId&&e.button===0&&(D.current=null,h.current=!1,P(!0))},window,{capture:!0}),tn(`pointercancel`,e=>{O.current?.id===e.pointerId&&ee(),D.current===e.pointerId&&(D.current=null,h.current=!1,r(),m.cancelDictation())},window,{capture:!0});let z=G(()=>{D.current!==null&&(D.current=null,h.current=!1,P())});tn(`blur`,()=>{C||(ee(),D.current===null?h.current&&F():z())},window),tn(`visibilitychange`,()=>{C||document.hidden&&(ee(),D.current===null?h.current&&F():z())},document),tn(C?`yuri:mobile-dictation-toggle`:`yuri:dictation-toggle`,()=>{I()},window),tn(`keydown`,e=>{if(!C&&(ee(),!(e.isComposing||e.keyCode===229))){if(e.key===`Enter`&&!e.shiftKey&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(x||S)){e.preventDefault(),e.stopPropagation(),e.repeat||F();return}e.key!==`Escape`||!x&&!S&&m.status!==`failed`||(e.preventDefault(),e.stopPropagation(),h.current=!1,D.current=null,r(),m.status===`failed`?m.discardFailedDictation():m.cancelDictation())}},window,{capture:!0});let B=d(x?`settings.voice.volcengine.finishRecording`:S?`chat.dictation.processing`:`chat.dictation.start`);return(0,$.jsxs)(`div`,{ref:k,"data-dictation-control":!0,className:`relative flex shrink-0 items-center gap-1.5`,children:[!C&&(x||b)&&D.current!==null&&(0,qd.createPortal)((0,$.jsxs)(`span`,{ref:A,"data-listening-cursor":!0,"aria-hidden":`true`,className:`pointer-events-none fixed left-0 top-0 z-[100]`,style:{transform:`translate(${j.current.x}px, ${j.current.y}px)`},children:[(0,$.jsx)(`style`,{children:`html, html * { cursor: none !important; user-select: none !important; -webkit-user-select: none !important; } @keyframes yuri-listening-cursor { from { transform: scaleY(0.35); } to { transform: scaleY(1); } }`}),(0,$.jsx)(`span`,{className:`absolute -left-5 -top-5 flex size-10 items-center justify-center gap-1`,children:b?(0,$.jsx)(Fc,{decorative:!0}):[0,1,2].map(e=>(0,$.jsx)(`span`,{className:`h-6 w-[3px] rounded-full bg-[var(--voice-active-fill)] motion-safe:animate-[yuri-listening-cursor_450ms_ease-in-out_infinite_alternate]`,style:{animationDelay:`${e*-150}ms`}},e))})]}),document.body),(0,$.jsxs)(Aa,{delayDuration:0,children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{variant:`ghost`,size:`icon`,className:J(`shadow-none`,i),"aria-label":B,"aria-pressed":x,"aria-busy":w,disabled:S||v||u&&!x,onClick:()=>{I()},onBlur:C?void 0:F,children:w?(0,$.jsx)(Fc,{decorative:!0}):(0,$.jsx)(rc,{kind:`mic`,active:x&&!m.error,className:J(a??`size-5`,m.error&&`text-[var(--status-error)]`)})})}),(0,$.jsx)(ka,{side:`top`,sideOffset:8,className:`yuri-composer-tooltip max-w-64 break-words`,children:m.error||(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(`span`,{children:B}),!C&&p&&(0,$.jsx)(`kbd`,{className:`font-sans text-[10px] opacity-70`,children:p})]})})]}),!C&&x&&!w&&(0,$.jsx)(`span`,{className:`pointer-events-none select-none whitespace-nowrap text-[10px] leading-none text-muted-foreground`,children:d(D.current===null?`chat.dictation.keyboardHint`:`chat.dictation.releaseConfirm`)})]})}function Yd(e){let{fileLabel:t,startLine:n,endLine:r,side:i,language:a,code:o,text:s}=e;return e.source===`diff`&&i?`Comment on \`${t}\` lines ${n}-${r} (${i}):\n\`\`\`${a}\n${o}\n\`\`\`\n\n${s}`:e.source===`preview-console`?`Attached preview context from \`${t}\`:\n\`\`\`${a}\n${o}\n\`\`\`\n\n${s}`:e.source===`preview-annotation`?s?`${o}\n\n${s}`:o:`Comment on \`${t}\` lines ${n}-${r}:\n\`\`\`${a}\n${o}\n\`\`\`\n\n${s}`}function Xd(e){return e.length===0?``:e.every(e=>e.source===`preview-annotation`)?e.map(Yd).join(`
3
3
 
4
4
  ---
5
5
 
@@ -9,7 +9,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./runtime-
9
9
  `);Fi.error(e(`chat.fileAttachment.toast.someFilesSkipped`,{summary:t}))}let a=n.map(t=>{if(!t?.dataUrl)return null;try{let[n,r]=t.dataUrl.split(`,`),i=t.mimeType||n?.match(/data:(.*);base64/)?.[1]||`application/octet-stream`;if(!r)return null;let a=atob(r),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=new Blob([o],{type:i});return new File([s],t.name||e(`chat.fileAttachment.fileFallback`),{type:i})}catch(e){return console.error(`Failed to decode VS Code picked file`,e),null}}).filter(Boolean);a.length>0&&await c(a)}catch(t){console.error(`VS Code file pick failed`,t),Fi.error(t instanceof Error?t.message:e(`chat.fileAttachment.toast.vscodePickFailed`))}}:()=>t.current?.click(),className:J(`flex items-center justify-center rounded-lg transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,`hover:bg-muted text-muted-foreground`,o),"aria-label":e(`chat.fileAttachment.actions.attachAria`),children:(0,$.jsx)(X,{name:`attachment-2`,className:s})})}),(0,$.jsx)(ka,{side:`top`,children:(0,$.jsx)(`p`,{children:e(`chat.fileAttachment.actions.attach`)})})]})]})});lf.displayName=`FileAttachmentButton`;var uf=(0,Q.memo)(e=>{let t=(0,Z.c)(61),{file:n,onRemove:r,onShowPopup:i,gallery:a,index:o}=e,s=o===void 0?0:o,{t:c}=na(),{isMobile:l,isTablet:u}=Ia(),d=l||u,f=n.source!==`server`&&n.mimeType.startsWith(`image/`)&&typeof n.dataUrl==`string`&&n.dataUrl.startsWith(`data:image/`)?n.dataUrl:n.serverPath||``,p=Ga()??``,m=Lo(f,p),h=m.source,g=If,_=Lf,v;t[0]===n.filename?v=t[1]:(v=g(n.filename),t[0]=n.filename,t[1]=v);let y=v,b;t[2]===n.filename?b=t[3]:(b=_(n.filename),t[2]=n.filename,t[3]=b);let x=b,S;t[4]!==y||t[5]!==p||t[6]!==n.mimeType||t[7]!==n.size||t[8]!==a||t[9]!==f||t[10]!==s||t[11]!==i?(S=e=>{!i||!f||i({open:!0,title:y||`Image`,content:``,previewSource:e.currentTarget.querySelector(`img`)??void 0,metadata:{tool:`image-preview`,filename:y,mime:n.mimeType,size:n.size},image:{url:f,directory:p,mimeType:n.mimeType,filename:y,size:n.size,gallery:a,index:s}})},t[4]=y,t[5]=p,t[6]=n.mimeType,t[7]=n.size,t[8]=a,t[9]=f,t[10]=s,t[11]=i,t[12]=S):S=t[12];let C=G(S);if(!f){let e;t[13]!==x||t[14]!==n.filename?(e=(0,$.jsx)(ja,{filePath:n.filename,extension:x,className:`h-4 w-4`}),t[13]=x,t[14]=n.filename,t[15]=e):e=t[15];let i;t[16]===y?i=t[17]:(i=(0,$.jsx)(`span`,{className:`text-foreground truncate max-w-[12.5rem]`,children:y}),t[16]=y,t[17]=i);let a;t[18]===r?a=t[19]:(a=e=>{e.stopPropagation(),r()},t[18]=r,t[19]=a);let o;t[20]!==y||t[21]!==c?(o=c(`chat.fileAttachment.actions.removeNamed`,{name:y}),t[20]=y,t[21]=c,t[22]=o):o=t[22];let s;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[23]=s):s=t[23];let l;t[24]!==a||t[25]!==o?(l=(0,$.jsx)(`span`,{onClick:a,className:`flex items-center justify-center h-5 w-5 flex-shrink-0 hover:bg-[var(--interactive-hover)] rounded-full transition-colors cursor-pointer`,"aria-label":o,children:s}),t[24]=a,t[25]=o,t[26]=l):l=t[26];let u;return t[27]!==l||t[28]!==e||t[29]!==i?(u=(0,$.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 text-sm hover:opacity-80 transition-opacity text-left h-5`,children:[e,i,l]}),t[27]=l,t[28]=e,t[29]=i,t[30]=u):u=t[30],u}let w=i?`button`:void 0,T=i?0:void 0,E;t[31]!==C||t[32]!==i?(E=e=>{i&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),C(e))},t[31]=C,t[32]=i,t[33]=E):E=t[33];let D=h||void 0,O;t[34]!==y||t[35]!==m.error||t[36]!==D?(O=(0,$.jsx)(Eo,{fill:!0,resourceError:m.error,src:D,alt:y,className:`h-full w-full object-cover transition-transform duration-200 ease-out hover:scale-110 motion-reduce:transform-none motion-reduce:transition-none`,loading:`lazy`,draggable:!1}),t[34]=y,t[35]=m.error,t[36]=D,t[37]=O):O=t[37];let k;t[38]===r?k=t[39]:(k=e=>{e.stopPropagation(),r()},t[38]=r,t[39]=k);let A=d?`opacity-100`:`opacity-0 group-hover:opacity-100`,j;t[40]===A?j=t[41]:(j=J(`group/remove absolute top-0.5 right-0.5 h-4 w-4 rounded-full bg-transparent text-foreground cursor-pointer flex items-center justify-center transition-opacity duration-200 ease-out motion-reduce:transition-none focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring`,A),t[40]=A,t[41]=j);let M;t[42]===c?M=t[43]:(M=c(`chat.fileAttachment.actions.removeImage`),t[42]=c,t[43]=M);let N;t[44]!==y||t[45]!==c?(N=c(`chat.fileAttachment.actions.removeNamed`,{name:y}),t[44]=y,t[45]=c,t[46]=N):N=t[46];let P;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(X,{name:`close`,className:`h-2.5 w-2.5 transition-[width,height] duration-200 ease-out group-hover/remove:h-3 group-hover/remove:w-3 motion-reduce:transition-none`}),t[47]=P):P=t[47];let F;t[48]!==k||t[49]!==j||t[50]!==M||t[51]!==N?(F=(0,$.jsx)(`button`,{onClick:k,className:j,title:M,"aria-label":N,children:P}),t[48]=k,t[49]=j,t[50]=M,t[51]=N,t[52]=F):F=t[52];let I;return t[53]!==y||t[54]!==C||t[55]!==F||t[56]!==w||t[57]!==T||t[58]!==E||t[59]!==O?(I=(0,$.jsxs)(`div`,{role:w,tabIndex:T,onClick:C,onKeyDown:E,onContextMenu:Rf,"data-attachment-preview":`true`,className:`relative h-10 w-10 rounded-lg border border-border/40 bg-muted/10 overflow-hidden flex-shrink-0 group cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,"aria-label":y,children:[O,F]}),t[53]=y,t[54]=C,t[55]=F,t[56]=w,t[57]=T,t[58]=E,t[59]=O,t[60]=I):I=t[60],I});uf.displayName=`ImagePreview`;var df=e=>({displayName:(e=>{let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e})(e.filename),fileSize:(e=>!Number.isFinite(e)||e<=0?``:e<1024?e+` B`:e<1048576?(e/1024).toFixed(1)+` KB`:(e/1048576).toFixed(1)+` MB`)(e.size),extension:(e=>{let t=e.split(`.`);return t.length>1?t[t.length-1].toLowerCase():``})(e.filename)}),ff=(0,Q.memo)(e=>{let t=(0,Z.c)(25),{file:n,onRemove:r}=e,{t:i}=na(),{displayName:a,extension:o}=df(n),s=/:\d+(?:-\d+)?$/.test(a),c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={borderColor:`var(--syntax-punctuation)`},t[0]=c):c=t[0];let l=n.vscodePath,u;t[1]===r?u=t[2]:(u=e=>{e.stopPropagation(),r()},t[1]=r,t[2]=u);let d;t[3]===i?d=t[4]:(d=i(`chat.fileAttachment.activeEditor.remove`),t[3]=i,t[4]=d);let f;t[5]===i?f=t[6]:(f=i(`chat.fileAttachment.activeEditor.remove`),t[5]=i,t[6]=f);let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(X,{name:`close`,className:`h-4 w-4 text-muted-foreground`}),t[7]=p):p=t[7];let m;t[8]!==u||t[9]!==d||t[10]!==f?(m=(0,$.jsx)(`span`,{"data-remove-button":!0,onClick:u,className:`flex items-center justify-center h-5 w-5 flex-shrink-0 hover:bg-[var(--interactive-hover)] rounded-full transition-colors cursor-pointer`,"aria-label":d,title:f,children:p}),t[8]=u,t[9]=d,t[10]=f,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n.filename?(h=(0,$.jsx)(ja,{filePath:n.filename,extension:o,className:`h-4 w-4`}),t[12]=o,t[13]=n.filename,t[14]=h):h=t[14];let g=s?`whitespace-nowrap`:`truncate max-w-[12.5rem]`,_;t[15]===g?_=t[16]:(_=J(`text-foreground`,g),t[15]=g,t[16]=_);let v;t[17]!==a||t[18]!==_?(v=(0,$.jsx)(`span`,{className:_,children:a}),t[17]=a,t[18]=_,t[19]=v):v=t[19];let y;return t[20]!==n.vscodePath||t[21]!==v||t[22]!==m||t[23]!==h?(y=(0,$.jsxs)(`button`,{type:`button`,onClick:zf,className:`inline-flex items-center gap-1 text-xs pr-1 rounded-sm border border-solid bg-transparent text-foreground not-italic hover:opacity-90 transition-colors text-left`,style:c,title:l,children:[m,h,v]}),t[20]=n.vscodePath,t[21]=v,t[22]=m,t[23]=h,t[24]=y):y=t[24],y});ff.displayName=`VSCodeFileChip`;var pf=(0,Q.memo)(e=>{let t=(0,Z.c)(13),{attachments:n,onShowPopup:r,onRemoveAttachedFile:i}=e,a=n,o,s,c,l;if(t[0]!==a||t[1]!==i||t[2]!==r){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.filter(Bf);if(e.length===0){l=null;break bb0}let n=e.filter(Vf),u=e.filter(Hf),d=n.map(Uf).filter(Wf);o=`flex items-center gap-2 flex-wrap`,s=n.map((e,t)=>(0,$.jsx)(uf,{file:e,onRemove:()=>i(e),onShowPopup:r,gallery:d,index:t},e.id));let f;t[7]===i?f=t[8]:(f=e=>(0,$.jsx)(ff,{file:e,onRemove:()=>i(e)},e.id),t[7]=i,t[8]=f),c=u.map(f)}t[0]=a,t[1]=i,t[2]=r,t[3]=o,t[4]=s,t[5]=c,t[6]=l}else o=t[3],s=t[4],c=t[5],l=t[6];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;return t[9]!==o||t[10]!==s||t[11]!==c?(u=(0,$.jsxs)(`div`,{className:o,children:[s,c]}),t[9]=o,t[10]=s,t[11]=c,t[12]=u):u=t[12],u});pf.displayName=`AttachedVSCodeFileChips`;var mf=(0,Q.memo)(e=>{let t=(0,Z.c)(13),{attachments:n,onShowPopup:r,onRemoveAttachedFile:i}=e,a=n,o,s,c,l;if(t[0]!==a||t[1]!==i||t[2]!==r){l=Symbol.for(`react.early_return_sentinel`);bb0:{let e=a.filter(Gf);if(e.length===0){l=null;break bb0}let t=e.map(Kf).filter(qf);c=`pb-4 w-full px-1`,o=`flex items-center gap-1.5 flex-wrap`,s=e.map((e,n)=>(0,$.jsx)(uf,{file:e,onRemove:()=>i(e),onShowPopup:r,gallery:t,index:n},e.id))}t[0]=a,t[1]=i,t[2]=r,t[3]=o,t[4]=s,t[5]=c,t[6]=l}else o=t[3],s=t[4],c=t[5],l=t[6];if(l!==Symbol.for(`react.early_return_sentinel`))return l;let u;t[7]!==o||t[8]!==s?(u=(0,$.jsx)(`div`,{className:o,children:s}),t[7]=o,t[8]=s,t[9]=u):u=t[9];let d;return t[10]!==c||t[11]!==u?(d=(0,$.jsx)(`div`,{className:c,children:u}),t[10]=c,t[11]=u,t[12]=d):d=t[12],d});mf.displayName=`AttachedFilesList`;var hf=(e,t)=>e.some(e=>e.source===`vscode`&&e.vscodeSource===`file`&&(e.vscodePath||``)===t),gf=(e,t,n)=>!!n&&e.some(e=>e.source===`vscode`&&e.vscodeSource===`selection`&&e.filename===n&&e.vscodePath===t),_f=(0,Q.memo)(e=>{let t=(0,Z.c)(41),{attachedFiles:n,onAddVSCodeFile:r,onAddVSCodeSelection:i}=e,{t:a}=na(),o=ra(Jf),s=ra(Yf);if(!Vt().runtime.isVSCode||!o)return null;let{filePath:c,fileName:l,relativePath:u,selection:d,fileSize:f}=o,p;t[0]!==n||t[1]!==c?(p=hf(n,c),t[0]=n,t[1]=c,t[2]=p):p=t[2];let m=p,h=``;d&&(h=d.startLine===d.endLine?`${d.startLine}`:`${d.startLine}-${d.endLine}`);let g=d?`${u}:${h}`:``,_;t[3]!==n||t[4]!==c||t[5]!==g?(_=gf(n,c,g),t[3]=n,t[4]=c,t[5]=g,t[6]=_):_=t[6];let v=_;if(m&&(!d||v))return null;let y;t[7]===l?y=t[8]:(y=l.split(`.`).pop()||``,t[7]=l,t[8]=y);let b=y,x=l,S;t[9]!==l||t[10]!==c||t[11]!==f||t[12]!==r||t[13]!==s?(S=()=>{r(c,l,f),s(yt(l),`append-inline`)},t[9]=l,t[10]=c,t[11]=f,t[12]=r,t[13]=s,t[14]=S):S=t[14];let C=S,w;t[15]!==c||t[16]!==i||t[17]!==d||t[18]!==g||t[19]!==s?(w=async()=>{if(!d)return;let e=new Blob([d.text],{type:`text/plain`}),t=new File([e],g,{type:`text/plain`});await i(c,t),s(yt(g),`append-inline`)},t[15]=c,t[16]=i,t[17]=d,t[18]=g,t[19]=s,t[20]=w):w=t[20];let T=w,E=!!d&&!v,D=!E&&!m;if(!E&&!D)return null;let O;t[21]!==x||t[22]!==b||t[23]!==l||t[24]!==T||t[25]!==u||t[26]!==h||t[27]!==E||t[28]!==a?(O=E&&(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 text-xs pr-1 rounded-sm italic text-muted-foreground border border-dashed bg-transparent`,style:{borderColor:`var(--syntax-punctuation)`},title:u,children:[(0,$.jsx)(`button`,{type:`button`,title:a(`chat.fileAttachment.activeEditor.pinSelection`),"aria-label":a(`chat.fileAttachment.activeEditor.pinSelection`),onClick:()=>{T()},className:`flex items-center justify-center h-5 w-5 flex-shrink-0 hover:bg-[var(--interactive-hover)] rounded-full transition-colors cursor-pointer`,children:(0,$.jsx)(X,{name:`pushpin-2`,className:`h-4 w-4`})}),(0,$.jsx)(ja,{filePath:l,extension:b,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs whitespace-nowrap`,children:`${x}:${h}`})]}),t[21]=x,t[22]=b,t[23]=l,t[24]=T,t[25]=u,t[26]=h,t[27]=E,t[28]=a,t[29]=O):O=t[29];let k;t[30]!==x||t[31]!==b||t[32]!==l||t[33]!==C||t[34]!==u||t[35]!==D||t[36]!==a?(k=D&&(0,$.jsxs)(`div`,{className:`inline-flex items-center gap-1 text-xs pr-1 rounded-sm italic text-muted-foreground border border-dashed bg-transparent`,style:{borderColor:`var(--syntax-punctuation)`},title:u,children:[(0,$.jsx)(`button`,{type:`button`,title:a(`chat.fileAttachment.activeEditor.addFile`,{name:x}),"aria-label":a(`chat.fileAttachment.activeEditor.addFile`,{name:x}),onClick:C,className:`flex items-center justify-center h-5 w-5 flex-shrink-0 hover:bg-[var(--interactive-hover)] rounded-full transition-colors cursor-pointer`,children:(0,$.jsx)(X,{name:`add`,className:`h-4 w-4`})}),(0,$.jsx)(ja,{filePath:l,extension:b,className:`h-4 w-4 flex-shrink-0`}),(0,$.jsx)(`span`,{className:`text-xs truncate max-w-[13.75rem]`,children:x})]}),t[30]=x,t[31]=b,t[32]=l,t[33]=C,t[34]=u,t[35]=D,t[36]=a,t[37]=k):k=t[37];let A;return t[38]!==O||t[39]!==k?(A=(0,$.jsxs)(`div`,{className:`inline-flex items-center`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40],A});_f.displayName=`ActiveEditorFileSuggestion`;var vf=`application/vnd.github.issue-link`,yf=`application/vnd.github.pull-request-link`,bf=e=>e.mime===vf?`issue`:e.mime===yf?`pr`:null,xf=e=>{let t=typeof e.id==`string`?e.id.trim():``;if(t)return`part:${t}`;let n=typeof e.filename==`string`?e.filename.trim().toLowerCase():``,r=typeof e.mime==`string`?e.mime.trim().toLowerCase():``;if(r.startsWith(`image/`)&&n)return`image:${n}|${r}`;let i=typeof e.url==`string`?e.url.trim():``;return i?`url:${i}`:`meta:${n}|${r}|${e.size??``}`},Sf=e=>{let t=new Map,n=[];for(let r of e){if(r.type!==`file`||!(r.mime||r.url)||j(r))continue;let e=xf(r),i=t.get(e);if(i===void 0){t.set(e,n.length),n.push(r);continue}n[i]?.slim===!0&&r.slim!==!0&&(n[i]=r)}return n},Cf=(e,t)=>{let n=new Map,r=new Map;for(let e of t){if(e.type!==`file`||e.slim===!0||typeof e.url!=`string`||!e.url)continue;let t=e;typeof e.id==`string`&&e.id&&n.set(e.id,t),typeof e.filename==`string`&&e.filename&&r.set(e.filename,t)}return n.size===0&&r.size===0?Sf(e):Sf(e.map(e=>e.type!==`file`||typeof e.url==`string`&&e.url&&e.slim!==!0?e:e.id&&n.has(e.id)?n.get(e.id)??e:e.filename&&r.has(e.filename)?r.get(e.filename)??e:e))},wf=e=>e.failed||e.repositoryStatus===`error`?`error`:e.flightActive||e.repositoryStatus===`loading`?`loading`:e.hasSlimImage&&e.repositoryStatus===`ready`?`idle`:e.repositoryStatus,Tf=e=>/^(?:data|blob|https?):/i.test(e),Ef=e=>{for(let t of[e.byteSize,e.size])if(typeof t==`number`&&Number.isFinite(t)&&t>0)return t},Df=(e,t)=>t.some(t=>t.type===`file`&&t.mime?.startsWith(`image/`)===!0&&t.slim===!0&&!t.url&&Io(e,Ef(t))),Of=(e,t)=>t.type!==`file`||t.mime?.startsWith(`image/`)!==!0||typeof t.url!=`string`||!t.url||Tf(t.url)?!1:Io(e,Ef(t)),kf=e=>J(`grid gap-2`,e===1?`grid-cols-1 max-w-24`:`grid-cols-[repeat(auto-fill,6rem)]`),Af=e=>{let t=(0,Z.c)(10),{source:n,filename:r,sizeText:i,onOpen:a,materializationStatus:o,onRetry:s}=e,c=o===void 0?`ready`:o,{t:l}=na(),u=Ga()??``,d=Lo(n??``,u),f=d.source,p;return t[0]!==f||t[1]!==r||t[2]!==d.error||t[3]!==c||t[4]!==a||t[5]!==s||t[6]!==i||t[7]!==n||t[8]!==l?(p=(0,$.jsx)(`div`,{className:`relative aspect-square min-w-0 overflow-hidden w-24 max-w-full rounded-lg border border-border/40 bg-muted/10`,"data-message-image-slot":`true`,children:n?(0,$.jsxs)(`button`,{type:`button`,onClick:e=>a?.(e.currentTarget.querySelector(`img`)??void 0),className:`group/message-image absolute inset-0 cursor-pointer text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-[var(--interactive-focus-ring)]`,"aria-label":r,children:[(0,$.jsx)(Eo,{fill:!0,resourceError:d.error,src:f||void 0,alt:r,className:`h-full w-full object-cover`,loading:`lazy`}),(0,$.jsxs)(`div`,{className:`pointer-events-none absolute inset-x-2 bottom-2 flex translate-y-1 items-center gap-2 rounded-xl border border-border/40 bg-[color-mix(in_srgb,var(--surface-elevated)_85%,transparent)] px-3 py-2 text-foreground opacity-0 shadow-sm backdrop-blur-md transition-[opacity,transform] duration-150 ease-out group-hover/message-image:translate-y-0 group-hover/message-image:opacity-100 group-focus-visible/message-image:translate-y-0 group-focus-visible/message-image:opacity-100 motion-reduce:transform-none motion-reduce:transition-none`,children:[(0,$.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:r}),i&&(0,$.jsx)(`p`,{className:`shrink-0 text-[10px] tabular-nums text-muted-foreground`,children:i})]})]}):c===`loading`?(0,$.jsx)(To,{className:`absolute inset-0 rounded-lg`}):(0,$.jsxs)(`div`,{className:J(`absolute inset-0 flex flex-col items-center justify-center gap-2 p-4 text-center typography-meta text-muted-foreground`,c===`error`&&`text-[var(--status-error)]`),role:c===`error`?`alert`:`status`,"aria-label":r,children:[(0,$.jsx)(X,{name:c===`error`?`error-warning`:`file-image`,className:`size-5`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:c===`error`?l(`chat.fileAttachment.image.loadFailed`):r}),c===`error`&&s?(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:l(`chat.fileAttachment.image.retry`)}):null]})}),t[0]=f,t[1]=r,t[2]=d.error,t[3]=c,t[4]=a,t[5]=s,t[6]=i,t[7]=n,t[8]=l,t[9]=p):p=t[9],p},jf=e=>{let t=(0,Z.c)(11),{images:n,onLoad:r}=e,{t:i}=na(),a;t[0]===i?a=t[1]:(a=i(`chat.fileAttachment.image.loadManually`),t[0]=i,t[1]=a);let o=a,s;if(t[2]!==o||t[3]!==n||t[4]!==r){let e;t[6]!==o||t[7]!==r?(e=e=>(0,$.jsxs)(Tr,{type:`button`,variant:`secondary`,size:`sm`,onClick:()=>r(e.key),"aria-label":o,className:`group h-auto min-h-8 min-w-0 justify-start gap-2 whitespace-normal border border-border/30 bg-muted/60 px-2 py-1.5 text-left hover:bg-[var(--interactive-hover)]`,"data-manual-image-load-item":e.key,children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md border border-border/40 bg-background/70 text-muted-foreground transition-colors group-hover:text-foreground`,children:(0,$.jsx)(X,{name:`file-image`,className:`size-4`,"aria-hidden":`true`})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate typography-meta text-foreground`,children:e.filename}),e.sizeText&&(0,$.jsx)(`span`,{className:`block text-xs leading-tight text-muted-foreground`,children:e.sizeText})]})]},e.key),t[6]=o,t[7]=r,t[8]=e):e=t[8],s=n.map(e),t[2]=o,t[3]=n,t[4]=r,t[5]=s}else s=t[5];let c;return t[9]===s?c=t[10]:(c=(0,$.jsx)(`div`,{className:`col-span-full flex flex-col gap-1.5`,"data-manual-image-load-group":`true`,children:s}),t[9]=s,t[10]=c),c},Mf={threshold:.01},Nf=new Set,Pf=(0,Q.memo)(({files:e,messageID:t,sessionID:n,onShowPopup:r,compact:i=!1})=>{let{t:a}=na(),o=Ga()??``,s=n||e.find(e=>typeof e.sessionID==`string`&&e.sessionID)?.sessionID||``,c=Ti(t,o,s||void 0),[l,u]=Q.useState(()=>q(t)??[]),d=Q.useRef(null),f=Q.useRef(!1),p=Q.useRef(null),h=Q.useRef(!1),g=Q.useRef(new Set),_=Q.useRef(``),[,v]=Q.useReducer(e=>e+1,0),y=`${o}\n${s}\n${t}`;_.current!==y&&(_.current=y,f.current=!1,p.current=null,h.current=!1,g.current=new Set,u(q(t)??[]));for(let t of e)t.type===`file`&&t.slim===!0&&t.mime?.startsWith(`image/`)&&g.current.add(xf(t));let b=e=>{if(!e)return`Unnamed file`;let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e},x=Q.useMemo(()=>e=>bf(e)!==null&&typeof e.filename==`string`&&e.filename.trim().length>0?e.filename.trim():b(e.filename||e.url)||a(`chat.fileAttachment.fileFallback`),[a]),S=e=>!e||!Number.isFinite(e)||e<=0?``:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`,C=Q.useMemo(()=>Cf(e,[...c,...l]),[l,e,c]),w=Fo(),T=Q.useMemo(()=>Df(w,C),[C,w]),[D,O]=Q.useState({scope:``,keys:Nf}),k=D.scope===y?D.keys:Nf,A=Q.useMemo(()=>{if(!Ro(w))return Nf;let e=new Set;for(let t of C){let n=xf(t);k.has(n)||Of(w,t)&&e.add(n)}return e},[k,C,w]),j=C.filter(e=>e.mime?.startsWith(`image/`)),M=j.filter(e=>!!e.url),N=C.filter(e=>!e.mime?.startsWith(`image/`)),I=j.some(e=>e.slim===!0),L=T&&j.some(e=>e.slim===!0&&!k.has(xf(e))),R=j.filter(e=>{let t=xf(e);return k.has(t)?!1:e.slim===!0?T:A.has(t)}),ee=new Set(R.map(xf)),z=j.filter(e=>{let t=xf(e);return!ee.has(t)&&(g.current.has(t)||!!e.url)}),B=R.map(e=>({key:xf(e),filename:x(e),sizeText:S(Ef(e))})),V=G((e=!1)=>{if(!I||!o||!s||!t||!e&&f.current||p.current)return;f.current=!0,h.current=!1;let n=m(o,s,t).then(()=>{let e=q(t);e&&e.length>0&&u(e)}).catch(()=>{let e=q(t);if(e&&e.length>0){u(e);return}h.current=!0}).finally(()=>{p.current=null,v()});p.current=n,v()}),H=G(e=>{O(t=>{let n=t.scope===y?new Set(t.keys):new Set;return n.add(e),{scope:y,keys:n}}),I&&V(!0)});Xt(I&&!L?d:null,e=>{e.some(e=>e.isIntersecting)&&V(!1)},Mf),Q.useEffect(()=>{if(!I||L)return;let e=d.current;if(!e)return;let t=e.closest(`[data-scrollbar="chat"]`);if(!t||typeof IntersectionObserver>`u`){V(!1);return}let n=e.getBoundingClientRect(),r=t.getBoundingClientRect();n.bottom>r.top&&n.top<r.bottom&&V(!1)},[o,I,t,s,L]);let U=I&&o&&s?P(o,s,t).status:`ready`,te=C.some(e=>e.mime?.startsWith(`image/`)===!0&&typeof e.url==`string`&&e.url.length>0&&e.slim!==!0)?`ready`:wf({hasSlimImage:I,flightActive:!!p.current,failed:h.current,repositoryStatus:U}),ne=Q.useMemo(()=>M.flatMap(e=>{if(!e.url)return[];let t=x(e)||`Image`;return[{url:e.url,mimeType:e.mime,filename:t,size:e.size}]}),[M,x]),re=G((e,t)=>{if(!r)return;let n=M.findIndex(t=>xf(t)===xf(e)),i=ne[n];if(!i?.url)return;let a=i.filename||`Image`;r({open:!0,title:a,content:``,previewSource:t,metadata:{tool:`image-preview`,filename:a,mime:i.mimeType,size:i.size},image:{url:i.url,directory:o,mimeType:i.mimeType,filename:a,size:i.size,gallery:ne,index:n}})});return C.length===0?null:i?(0,$.jsxs)(`div`,{ref:d,className:`space-y-1.5 mt-1.5`,"data-message-files":t,children:[N.length>0&&(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:N.map(e=>{let t=x(e),n=t.split(`.`).pop()||``,i=S(e.size),a=bf(e),s=F(e.mime)||E(e.filename)||E(e.url);return(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:e.url&&jo(e.url,e.mime)?(0,$.jsx)(Tr,{variant:`secondary`,size:`sm`,onClick:()=>r?.({open:!0,title:t,content:``,video:{url:e.url,mimeType:e.mime,filename:t,directory:o}}),children:t}):a&&e.url?(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{fn(e.url||``)},className:`inline-flex items-center bg-muted/30 border border-border/30 typography-meta gap-1 px-2 py-0.5 rounded-lg text-foreground hover:text-primary transition-colors`,children:[a===`pr`?(0,$.jsx)(X,{name:`git-pull-request`,className:`text-muted-foreground h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`github`,className:`text-muted-foreground h-3.5 w-3.5`}),(0,$.jsx)(`div`,{className:`overflow-hidden max-w-[13.75rem]`,children:(0,$.jsx)(`span`,{className:`truncate block`,title:t,children:t})})]}):(0,$.jsxs)(`div`,{className:`inline-flex items-center bg-muted/30 border border-border/30 typography-meta gap-1 px-2 py-0.5 rounded-lg`,children:[e.mime?.includes(`pdf`)?(0,$.jsx)(X,{name:`file-pdf`,className:`text-muted-foreground h-3.5 w-3.5`}):(0,$.jsx)(ja,{filePath:t,extension:n,isDirectory:s,className:`text-muted-foreground h-3.5 w-3.5`}),(0,$.jsx)(`div`,{className:`overflow-hidden max-w-[8.75rem]`,children:(0,$.jsx)(`span`,{className:`truncate block`,title:t,children:t})})]})}),(0,$.jsx)(ka,{children:(0,$.jsxs)(`p`,{children:[t,i?` (${i})`:``]})})]},`file-${xf(e)}`)})}),B.length>0?(0,$.jsx)(jf,{images:B,onLoad:H}):null,z.length>0?(0,$.jsx)(`div`,{className:kf(z.length),children:z.map(e=>{let t=x(e);return(0,$.jsx)(Af,{source:e.url,filename:t,sizeText:S(Ef(e)),materializationStatus:e.url?`ready`:te,onRetry:()=>V(!0),onOpen:e.url?t=>re(e,t):void 0},xf(e))})}):null]}):(0,$.jsxs)(`div`,{ref:d,"data-message-files":t,className:J(`grid gap-2`,i?`grid-cols-1`:`grid-cols-1 sm:grid-cols-2`),children:[B.length>0?(0,$.jsx)(jf,{images:B,onLoad:H}):null,C.map(e=>{let t=x(e),n=e.mime?.startsWith(`image/`),s=S(e.size),c=bf(e);if(ee.has(xf(e)))return null;if(n&&e.url)return(0,$.jsx)(Af,{source:e.url,filename:t,sizeText:s,onOpen:t=>re(e,t)},xf(e));if(n)return(0,$.jsx)(Af,{filename:t,sizeText:s,materializationStatus:te,onRetry:()=>V(!0)},xf(e));if(c&&e.url)return(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{fn(e.url||``)},className:J(`flex items-center gap-2 p-2 rounded-lg border border-border/40 bg-muted/10 hover:bg-muted/20 transition-colors text-left`,i?`text-xs`:`text-sm`),children:[(0,$.jsx)(`div`,{className:`flex-shrink-0`,children:c===`pr`?(0,$.jsx)(X,{name:`git-pull-request`,className:J(`text-muted-foreground`,i?`h-3.5 w-3.5`:`h-4 w-4`)}):(0,$.jsx)(X,{name:`github`,className:J(`text-muted-foreground`,i?`h-3.5 w-3.5`:`h-4 w-4`)})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`font-medium truncate`,children:t}),s&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s})]})]})}),(0,$.jsx)(ka,{children:(0,$.jsxs)(`p`,{children:[t,s?` (${s})`:``]})})]},xf(e));let l=e.source,u=typeof l?.type==`string`?l.type:void 0,d=l&&typeof l.path==`string`?l.path:void 0,f=u===`file`&&d?d:e.url||``;return f&&aa(f)?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{ln.getState().navigateToDiagram(f)},className:J(`flex items-center gap-2 p-2 rounded-lg border border-border/40 bg-muted/10 hover:bg-muted/20 transition-colors text-left cursor-pointer`,i?`text-xs`:`text-sm`),children:[(0,$.jsx)(X,{name:`file`,className:J(`text-muted-foreground shrink-0`,i?`h-3.5 w-3.5`:`h-4 w-4`)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`font-medium truncate`,children:t}),(0,$.jsx)(`p`,{className:`text-xs text-status-info`,children:a(`chat.fileAttachment.openInDiagram`)})]}),(0,$.jsx)(X,{name:`external-link`,className:J(`text-muted-foreground shrink-0`,i?`h-3 w-3`:`h-3.5 w-3.5`)})]})}),(0,$.jsx)(ka,{children:(0,$.jsx)(`p`,{children:a(`chat.fileAttachment.openInDiagram`)})})]},xf(e)):(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{r&&e.url&&r({open:!0,title:t,content:``,image:{url:e.url,directory:o,mimeType:e.mime,filename:t}})},className:J(`flex items-center gap-2 p-2 rounded-lg border border-border/40 bg-muted/10 hover:bg-muted/20 transition-colors text-left`,i?`text-xs`:`text-sm`),children:[(0,$.jsx)(`div`,{className:`flex-shrink-0`,children:e.mime?.startsWith(`image/`)?(0,$.jsx)(X,{name:`file-image`,className:J(`text-muted-foreground`,i?`h-3.5 w-3.5`:`h-4 w-4`)}):F(e.mime)||E(e.filename)||E(e.url)?(0,$.jsx)(ja,{filePath:t,isDirectory:!0,className:J(`text-muted-foreground`,i?`h-3.5 w-3.5`:`h-4 w-4`)}):e.mime?.includes(`pdf`)?(0,$.jsx)(X,{name:`file-pdf`,className:J(`text-muted-foreground`,i?`h-3.5 w-3.5`:`h-4 w-4`)}):(0,$.jsx)(X,{name:`file`,className:J(`text-muted-foreground`,i?`h-3.5 w-3.5`:`h-4 w-4`)})}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsx)(`p`,{className:`font-medium truncate`,children:t}),s&&(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s})]})]})}),(0,$.jsx)(ka,{children:(0,$.jsxs)(`p`,{children:[t,s?` (${s})`:``]})})]},xf(e))})]})});Pf.displayName=`MessageFilesDisplay`;var Ff=(0,Q.memo)(e=>{let t=(0,Z.c)(14),{urls:n,caption:r,onShowPopup:i}=e;if(n.length===0)return null;let a;t[0]===n.length?a=t[1]:(a=kf(n.length),t[0]=n.length,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=n.map((e,t)=>(0,$.jsxs)(`button`,{type:`button`,onClick:a=>i?.({open:!0,title:r||`Image ${t+1} of ${n.length}`,content:``,previewSource:a.currentTarget.querySelector(`img`)??void 0,image:{url:e,gallery:n.map(Xf),index:t}}),className:`relative aspect-square rounded-lg border border-border/40 bg-muted/10 overflow-hidden group`,children:[(0,$.jsx)(Eo,{fill:!0,src:e,alt:r||`Image ${t+1}`,className:`h-full w-full object-cover transition-transform group-hover:scale-105`,loading:`lazy`}),(0,$.jsx)(`div`,{className:`absolute inset-0 bg-black/0 group-hover:bg-black/10 transition-colors`})]},e)),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{className:a,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;t[9]===r?c=t[10]:(c=r&&(0,$.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:r}),t[9]=r,t[10]=c);let l;return t[11]!==s||t[12]!==c?(l=(0,$.jsxs)(`div`,{className:`space-y-2`,children:[s,c]}),t[11]=s,t[12]=c,t[13]=l):l=t[13],l});Ff.displayName=`ImageGallery`;function If(e){let t=e.replace(/\\/g,`/`).split(`/`);return t[t.length-1]||e}function Lf(e){let t=e.split(`.`);return t.length>1?t[t.length-1].toLowerCase():``}function Rf(e){e.preventDefault(),e.stopPropagation()}function zf(e){e.target.closest(`[data-remove-button]`)}function Bf(e){return e.source===`vscode`&&e.vscodeSource===`file`}function Vf(e){return e.mimeType.startsWith(`image/`)}function Hf(e){return!e.mimeType.startsWith(`image/`)}function Uf(e){return{url:e.dataUrl||e.serverPath||``,mimeType:e.mimeType,filename:e.filename,size:e.size}}function Wf(e){return e.url}function Gf(e){return e.source!==`server`&&e.source!==`vscode`&&e.mimeType.startsWith(`image/`)}function Kf(e){return{url:e.dataUrl||e.serverPath||``,mimeType:e.mimeType,filename:e.filename,size:e.size}}function qf(e){return e.url}function Jf(e){return e.activeEditorFile}function Yf(e){return e.setPendingInputText}function Xf(e){return{url:e}}async function Zf(e){let t=_(),n=e.inputStore?.getState()??ra.getState(),r=n.captureDraftRuntime(),i=()=>{if(!te(t)||!e.isCurrent())return!1;try{return e.scope?.sdk(),!0}catch{return!1}};if(!i()||e.targetKey.transportIdentity!==r.transportIdentity||e.runtimeGeneration!==t.generation)return!1;let a=await be(e);if(!i()||!a.current)return!1;let o=a.items.find(t=>t.id===e.inboxID);if(!o||o.delivery!==`queue`)throw Error(`inbox-edit-no-longer-queued`);let s=[],l=o.payload.text,u=e=>{if(e===void 0)return[];if(!Array.isArray(e)||e.some(e=>!e||typeof e!=`object`))throw Error(`inbox-edit-invalid-payload`);return e};for(let e of u(o.payload.skills)){if(!mt(e.id))throw Error(`inbox-edit-invalid-skill`);z(l).some(t=>t.id===e.id)||(l+=`\n[skill:${e.id}]`)}s.push({type:`text`,text:l});for(let e of u(o.payload.files)){let t=typeof e.mime==`string`&&e.mime?e.mime:`application/octet-stream`,n=e.source&&typeof e.source==`object`&&`type`in e.source&&e.source.type===`uri`&&`uri`in e.source?e.source.uri:void 0,r=typeof e.data==`string`&&e.data?`data:${t};base64,${e.data}`:typeof e.uri==`string`&&e.uri?e.uri:n;if(typeof r!=`string`||!r)throw Error(`inbox-edit-invalid-file`);s.push({type:`file`,url:r,filename:e.name,mime:t})}for(let e of u(o.payload.agents)){if(typeof e.name!=`string`||!e.name)throw Error(`inbox-edit-invalid-agent`);s.push({type:`agent`,name:e.name})}let d=await fr(s,{directory:e.directory});if(!i())return!1;let f=await Xi({key:e.targetKey,expectedRevision:e.expectedRevision,payload:d,runtime:r,input:n});if(f.status!==`committed`||!f.current||!f.durable)throw Error(`inbox-edit-draft-not-committed`);let p=async()=>{f.previous&&f.result?.record&&await zr({key:e.targetKey,restoredRevision:f.result.record.revision,previous:f.previous,runtime:r,input:n})};if(!i())return await p(),!1;try{await _e(e)}catch(e){let t=e&&typeof e==`object`&&`status`in e?e.status:void 0;throw typeof t==`number`&&t>=400&&t<500&&await p(),e}return te(t)?(ne(e.scope?c(e.scope.location,e.sessionID):e.sessionID,e.inboxID,`cancelled`),i()):!1}var Qf=e=>e!==`frozen`,$f=(e,t)=>e.length===0?t:t.length===0?e:[...e,...t],ep=e=>e.status===`committed`&&e.current===!0,tp=e=>{let t=e.failure?.recovery;return{content:t?.content??e.content,attachments:t?.attachments??e.attachments,composerDocument:t?.composerDocument??e.composerDocument,composerMentions:t?.composerMentions??e.composerMentions}},np=(e,t)=>{let n=e.status??`queued`;return!t&&(n===`queued`||n===`retrying`||n===`failed`||n===`unresolved`)},rp=(e,t,n)=>Fl(e)||t||e.manualDispatchRequested===!0&&!n?.allowManualDispatchRetry?!1:[`queued`,`retrying`,`failed`,`unresolved`].includes(e.status),ip=(e,t)=>!t.frozen&&!Fl(e),ap=(e,t)=>!(t.frozen||Fl(e)),op=e=>e.status===`sending`||e.status===`reconciling`,sp=e=>e.status===`sending`||e.status===`reconciling`,cp=e=>e.manualDispatchRequested===!0||e.status===`sending`||e.status===`reconciling`,lp=e=>e.status===`sending`||e.status===`reconciling`,up=8e3,dp=(e,t)=>e.transportIdentity===t.transportIdentity&&e.runtimeGeneration===t.runtimeGeneration&&At(e.directory)===At(t.directory)&&e.sessionID===t.sessionID&&e.scopeID===t.scopeID,fp=(e,t)=>e.filter(e=>dp(e,t)),pp=(e,t,n)=>e.filter(e=>dp(e,t)&&Number.isSafeInteger(e.committedRevision)&&e.committedRevision>0&&(n===void 0||n<e.committedRevision)),mp=(e,t)=>{if(t.kind===`send`)return e;if(t.kind===`edit`||t.kind===`remove`){let n=e.findIndex(e=>!Fl(e)&&e.queueItemID===t.queueItemID);return n<0?e:[...e.slice(0,n),...e.slice(n+1)]}if(t.kind===`reorder`){let n=t.queueItemIDs;if(!n)return e;let r=new Map,i=[],a=[];for(let t of e){if(Fl(t)){a.push(t);continue}i.push(t),r.set(t.queueItemID,t)}let o=[],s=new Set;for(let e of n){let t=r.get(e);t&&!s.has(e)&&(o.push(t),s.add(e))}let c=i.filter(e=>!s.has(e.queueItemID)),l=[...o,...c,...a];return l.every((t,n)=>t===e[n])?e:l}return e},hp=(e,t)=>t.reduce(mp,e),gp=(e,t)=>{let n=hp(e,t),r=n.filter(e=>Fl(e)||!lp(e));return r.length===n.length?n:r},_p=(e,t,n)=>({requestID:n,scopeID:e.scopeID,revision:e.revision,item:t}),vp=(e,t,n,r)=>({scopeID:e.scopeID,scopeRevision:e.revision,item:t,targetKey:n,expectedRevision:r}),yp=(e,t,n,r,i=e.items)=>{let a=i.filter(e=>!Fl(e)).map(e=>e.queueItemID),o=a.indexOf(t),s=a.indexOf(n);if(o<0||s<0||o===s)return null;let[c]=a.splice(o,1);if(!c)return null;a.splice(s,0,c);let l=new Set(a),u=0,d=e.items.map(e=>l.has(e.queueItemID)?a[u++]??e.queueItemID:e.queueItemID);return{requestID:r,scopeID:e.scopeID,revision:e.revision,queueItemIDs:d}},bp=e=>{let t=e.failure?.recovery,n=t?.composerDocument?.text??e.composerDocument?.text;return typeof n==`string`&&n.length>0?n:t?.content??e.content},xp=e=>{let t=new Map;for(let n of e??[]){let e=typeof n.filename==`string`?n.filename.trim():``;if(!e)continue;let r=e.toLowerCase();if(n.mimeType?.startsWith(`image/`)){t.set(r,`image`);continue}wt({source:n.source??`local`,vscodeSource:n.vscodeSource,mimeType:n.mimeType})&&t.set(r,`attachment`)}return t},Sp=e=>{let t=[];for(let n of e?.references??[]){if(n.kind!==`session`||typeof n.sessionId!=`string`)continue;let e=(typeof n.display==`string`?n.display:``).replace(/^@\u2003?/,``).trim()||n.sessionId;t.push({sessionId:n.sessionId,sessionLabel:e})}return t},Cp=e=>{let t=new Set,n=new Set;for(let r of e?.references??[]){if(r.kind===`skill`&&typeof r.skillName==`string`&&r.skillName){t.add(r.skillName);continue}r.kind===`command`&&typeof r.commandName==`string`&&r.commandName&&n.add(r.commandName)}return{skillNames:t.size>0?t:void 0,commandNames:n.size>0?n:void 0}},wp=e=>(e.split(`
10
10
  `)[0]??``)+(e.includes(`
11
11
  `)?`...`:``),Tp=(e,t={})=>{let n=wp(e);if(!n)return null;let r=Cp(t.composerDocument);return Zs(n,{citationIcons:xp(t.attachments),sessionMentions:Sp(t.composerDocument),skillNames:r.skillNames,commandNames:r.commandNames,allowPathHeuristics:!0})},Ep=e=>{if(!e||typeof e!=`object`)return!1;let t=e;return(t.kind===`edit`||t.kind===`send`||t.kind===`remove`||t.kind===`reorder`)&&typeof t.transportIdentity==`string`&&typeof t.runtimeGeneration==`number`&&Number.isSafeInteger(t.runtimeGeneration)&&t.runtimeGeneration>=0&&typeof t.directory==`string`&&typeof t.sessionID==`string`&&typeof t.scopeID==`string`&&typeof t.queueItemID==`string`&&(t.queueItemIDs===void 0||Array.isArray(t.queueItemIDs)&&t.queueItemIDs.every(e=>typeof e==`string`))},Dp=(0,Q.memo)(e=>{let t=(0,Z.c)(151),{message:n,server:r,frozen:i,hasDispatchLock:a,pendingOperationKinds:o,sendPendingTimedOut:s,abortSendPending:c,steering:l,isMobile:u,inboxEditable:d,onEdit:f,onSend:p,onRemove:m,compactionBarrier:h}=e,g=h!==void 0&&h,{t:_}=na(),v;t[0]===n?v=t[1]:(v=T(n),t[0]=n,t[1]=v);let y=v,b;t[2]!==n||t[3]!==p?(b={mutationFn:async()=>{await p(n)}},t[2]=n,t[3]=p,t[4]=b):b=t[4];let x=Nt(b),S;t[5]!==n||t[6]!==f?(S={mutationFn:async()=>{await f(n)}},t[5]=n,t[6]=f,t[7]=S):S=t[7];let C=Nt(S),w;t[8]===n?w=t[9]:(w=Fl(n),t[8]=n,t[9]=w);let E=w,D=n.queueItemID||n.id,O;t[10]!==C.isPending||t[11]!==o||t[12]!==r?(O=C.isPending||r&&o.has(`edit`),t[10]=C.isPending,t[11]=o,t[12]=r,t[13]=O):O=t[13];let k=O,A;t[14]!==o||t[15]!==r?(A=r&&o.has(`remove`),t[14]=o,t[15]=r,t[16]=A):A=t[16];let j=A,M;t[17]!==o||t[18]!==r?(M=r&&o.has(`reorder`),t[17]=o,t[18]=r,t[19]=M):M=t[19];let N=M,P=r||E?void 0:n,F;t[20]!==n||t[21]!==E||t[22]!==r?(F=r&&!E&&cp(n),t[20]=n,t[21]=E,t[22]=r,t[23]=F):F=t[23];let I=F,L;t[24]===P?L=t[25]:(L=P&&sp(P),t[24]=P,t[25]=L);let R=!!L,ee;t[26]!==n||t[27]!==E||t[28]!==r?(ee=r&&!E&&op(n),t[26]=n,t[27]=E,t[28]=r,t[29]=ee):ee=t[29];let z=ee,B;t[30]!==I||t[31]!==R||t[32]!==o||t[33]!==r?(B=r&&o.has(`send`)||I||R,t[30]=I,t[31]=R,t[32]=o,t[33]=r,t[34]=B):B=t[34];let V=B,H=l||y&&(x.isPending||n.delivery===`steer`)||c||V&&!s,U=i||E,te;t[35]!==k||t[36]!==i||t[37]!==y||t[38]!==d||t[39]!==n||t[40]!==H?(te=y?d&&!i&&!k&&!H&&n.delivery===`queue`:ip(n,{frozen:i}),t[35]=k,t[36]=i,t[37]=y,t[38]=d,t[39]=n,t[40]=H,t[41]=te):te=t[41];let ne=te,re;t[42]!==k||t[43]!==i||t[44]!==y||t[45]!==n?(re=y?!i&&!k:ap(n,{frozen:i}),t[42]=k,t[43]=i,t[44]=y,t[45]=n,t[46]=re):re=t[46];let W=re,ie=y||P?.owner?.state===`unbound-legacy`||U||z,ae=y&&g,oe;t[47]!==U||t[48]!==k||t[49]!==i||t[50]!==a||t[51]!==y||t[52]!==n||t[53]!==H||t[54]!==s||t[55]!==r||t[56]!==ae?(oe=y?!i&&!k&&!H&&n.delivery===`queue`&&!ae:!U&&!H&&(r?rp(n,a,{allowManualDispatchRetry:s}):np(n,a)),t[47]=U,t[48]=k,t[49]=i,t[50]=a,t[51]=y,t[52]=n,t[53]=H,t[54]=s,t[55]=r,t[56]=ae,t[57]=oe):oe=t[57];let se=oe,ce=P?.failure?.recovery,le;t[58]===n?le=t[59]:(le=bp(n),t[58]=n,t[59]=le);let ue=le,de=E||y?void 0:ce?.attachments??(`attachments`in n?n.attachments:void 0),fe=ce?.composerDocument??(`composerDocument`in n?n.composerDocument:void 0),pe;t[60]!==ie||t[61]!==D?(pe={id:D,disabled:ie},t[60]=ie,t[61]=D,t[62]=pe):pe=t[62];let{attributes:me,listeners:he,setNodeRef:ge,transform:_e,transition:ve,isDragging:ye}=vu(pe),be;t[63]===ue?be=t[64]:(be=wp(ue),t[63]=ue,t[64]=be);let xe=be,Se;t[65]!==de||t[66]!==fe||t[67]!==ue?(Se=Tp(ue,{attachments:de,composerDocument:fe}),t[65]=de,t[66]=fe,t[67]=ue,t[68]=Se):Se=t[68];let Ce=Se,we;t[69]!==n||t[70]!==m?(we=()=>m(n),t[69]=n,t[70]=m,t[71]=we):we=t[71];let Te=!W,Ee=j||void 0,De=u?`h-7 w-3`:`size-6`,Oe;t[72]===De?Oe=t[73]:(Oe=J(`inline-flex shrink-0 items-center justify-center bg-transparent text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,De),t[72]=De,t[73]=Oe);let ke;t[74]===_?ke=t[75]:(ke=_(`chat.queuedMessage.removeAria`),t[74]=_,t[75]=ke);let Ae=j?`loader-4`:`delete-bin`,je=u?`size-3`:`size-3.5`,Me=j&&`animate-spin`,Ne;t[76]!==je||t[77]!==Me?(Ne=J(je,Me),t[76]=je,t[77]=Me,t[78]=Ne):Ne=t[78];let Pe;t[79]!==Ae||t[80]!==Ne?(Pe=(0,$.jsx)(X,{name:Ae,weight:`medium`,className:Ne,"aria-hidden":`true`}),t[79]=Ae,t[80]=Ne,t[81]=Pe):Pe=t[81];let Fe;t[82]!==we||t[83]!==Te||t[84]!==Ee||t[85]!==Oe||t[86]!==ke||t[87]!==Pe?(Fe=(0,$.jsx)(`button`,{type:`button`,onClick:we,disabled:Te,"aria-busy":Ee,className:Oe,"aria-label":ke,children:Pe}),t[82]=we,t[83]=Te,t[84]=Ee,t[85]=Oe,t[86]=ke,t[87]=Pe,t[88]=Fe):Fe=t[88];let Ie=Fe,Le;t[89]===_e?Le=t[90]:(Le=hu.Translate.toString(_e),t[89]=_e,t[90]=Le);let Re;t[91]!==Le||t[92]!==ve?(Re={transform:Le,transition:ve},t[91]=Le,t[92]=ve,t[93]=Re):Re=t[93];let ze=u?`gap-1 py-0.5`:`flex gap-1.5 py-px md:gap-2`,Be=ye&&`z-10 opacity-60`,Ve;t[94]!==ze||t[95]!==Be?(Ve=J(`flex min-w-0 items-center`,ze,Be),t[94]=ze,t[95]=Be,t[96]=Ve):Ve=t[96];let He=N||void 0,Ue=u?`h-7 w-3`:`size-auto`,We=ie?`cursor-default opacity-50`:`cursor-grab hover:text-foreground active:cursor-grabbing`,Ge;t[97]!==Ue||t[98]!==We?(Ge=J(`flex flex-shrink-0 touch-none select-none items-center justify-center text-muted-foreground`,Ue,`transition-colors`,We),t[97]=Ue,t[98]=We,t[99]=Ge):Ge=t[99];let Ke;t[100]===_?Ke=t[101]:(Ke=_(`chat.queuedMessage.reorderAria`),t[100]=_,t[101]=Ke);let qe=N?`loader-4`:`draggable`,Je=u?`size-3`:`size-3.5`,Ye=N&&`animate-spin`,Xe;t[102]!==Je||t[103]!==Ye?(Xe=J(Je,Ye),t[102]=Je,t[103]=Ye,t[104]=Xe):Xe=t[104];let Ze;t[105]!==qe||t[106]!==Xe?(Ze=(0,$.jsx)(X,{name:qe,className:Xe,"aria-hidden":`true`}),t[105]=qe,t[106]=Xe,t[107]=Ze):Ze=t[107];let Qe;t[108]!==me||t[109]!==ie||t[110]!==he||t[111]!==He||t[112]!==Ge||t[113]!==Ke||t[114]!==Ze?(Qe=(0,$.jsx)(`button`,{type:`button`,...me,...he,disabled:ie,"data-mobile-press-feedback":`none`,"aria-busy":He,className:Ge,"aria-label":Ke,children:Ze}),t[108]=me,t[109]=ie,t[110]=he,t[111]=He,t[112]=Ge,t[113]=Ke,t[114]=Ze,t[115]=Qe):Qe=t[115];let $e=u?Ie:null,et=u?`text-xs leading-5`:`typography-ui-label leading-5`,tt;t[116]===et?tt=t[117]:(tt=J(`flex min-w-0 flex-1 items-baseline overflow-hidden whitespace-nowrap text-foreground [&>[data-message-reference-kind]]:min-w-0 [&>[data-message-reference-kind]]:truncate`,et),t[116]=et,t[117]=tt);let nt;t[118]!==xe||t[119]!==Ce||t[120]!==_?(nt=Ce?Ce.map(Hp):xe||_(`chat.queuedMessage.empty`),t[118]=xe,t[119]=Ce,t[120]=_,t[121]=nt):nt=t[121];let rt;t[122]!==tt||t[123]!==nt?(rt=(0,$.jsx)(`span`,{className:tt,children:nt}),t[122]=tt,t[123]=nt,t[124]=rt):rt=t[124];let it;t[125]!==ne||t[126]!==se||t[127]!==k||t[128]!==y||t[129]!==C||t[130]!==x||t[131]!==u||t[132]!==n||t[133]!==f||t[134]!==p||t[135]!==E||t[136]!==H||t[137]!==_||t[138]!==ae?(it=H&&!ae?(0,$.jsxs)(`span`,{className:J(`inline-flex items-center gap-1 text-muted-foreground`,u?`h-7 text-[11px] font-medium leading-none`:`h-6 font-normal text-[length:calc(var(--text-ui-label)-1px)]`),"aria-live":`polite`,"aria-label":_(`chat.queuedMessage.sendingAria`),children:[(0,$.jsx)(X,{name:`loader-4`,className:J(u?`size-3`:`size-3.5`,`animate-spin`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:_(`chat.queuedMessage.sending`)})]}):E?(0,$.jsxs)(`span`,{className:J(`inline-flex items-center gap-1 text-muted-foreground`,u?`h-7 text-[11px] font-medium leading-none`:`h-6 font-normal text-[length:calc(var(--text-ui-label)-1px)]`),"aria-live":`polite`,"aria-label":_(`chat.queuedMessage.queuingAria`),children:[(0,$.jsx)(X,{name:`loader-4`,className:J(u?`size-3`:`size-3.5`,`animate-spin`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:_(`chat.queuedMessage.queuing`)})]}):ae?(0,$.jsxs)(`span`,{className:J(`inline-flex items-center gap-1 text-muted-foreground`,u?`h-7 text-[11px] font-medium leading-none`:`h-6 font-normal text-[length:calc(var(--text-ui-label)-1px)]`),"aria-live":`polite`,"aria-label":_(`chat.queuedMessage.waitingForCompactionAria`),children:[(0,$.jsx)(X,{name:`loader-4`,className:J(u?`size-3`:`size-3.5`,`animate-spin`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:_(`chat.queuedMessage.waitingForCompaction`)})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{y?C.mutate():f(n)},disabled:!ne,"aria-busy":k||void 0,"aria-label":_(`chat.queuedMessage.edit`),className:J(`inline-flex items-center bg-transparent text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,u?`h-7 gap-1.5 px-0 text-[11px]`:`h-6 gap-1 px-0.5`),children:[(0,$.jsx)(X,{name:k?`loader-4`:`pencil`,className:J(u?`size-3`:`size-3.5`,k&&`animate-spin`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:J(`capitalize`,u?`font-medium leading-none`:`font-normal text-[length:calc(var(--text-ui-label)-1px)]`),children:_(`chat.queuedMessage.edit`)})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>{H||(y?x.mutate():p(n))},disabled:!se||H,"aria-busy":H||void 0,"aria-label":_(`chat.queuedMessage.send`),className:J(`inline-flex items-center bg-transparent text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,u?`h-7 gap-1.5 px-0 text-[11px]`:`h-6 gap-1 px-0.5`),children:[(0,$.jsx)(X,{name:`corner-down-left`,weight:`medium`,className:J(u?`size-3`:`size-3.5`),"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:J(`capitalize`,u?`font-medium leading-none`:`font-normal text-[length:calc(var(--text-ui-label)-1px)]`),children:_(`chat.queuedMessage.send`)})]})]}),t[125]=ne,t[126]=se,t[127]=k,t[128]=y,t[129]=C,t[130]=x,t[131]=u,t[132]=n,t[133]=f,t[134]=p,t[135]=E,t[136]=H,t[137]=_,t[138]=ae,t[139]=it):it=t[139];let at=!u&&!E?Ie:null,ot;t[140]!==it||t[141]!==at?(ot=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-muted-foreground`,children:[it,at]}),t[140]=it,t[141]=at,t[142]=ot):ot=t[142];let st;return t[143]!==ge||t[144]!==Re||t[145]!==Ve||t[146]!==Qe||t[147]!==$e||t[148]!==rt||t[149]!==ot?(st=(0,$.jsxs)(`div`,{ref:ge,role:`group`,style:Re,className:Ve,children:[Qe,$e,rt,ot]}),t[143]=ge,t[144]=Re,t[145]=Ve,t[146]=Qe,t[147]=$e,t[148]=rt,t[149]=ot,t[150]=st):st=t[150],st});Dp.displayName=`QueuedMessageChip`;var Op=[],kp=[],Ap=[],jp=new Set,Mp=new Set;function Np(e){let t=(0,Z.c)(18),{isMobile:n,children:r}=e,i=n?`px-2`:`px-4`,a;t[0]===i?a=t[1]:(a=J(`yuri-composer-queue relative z-0 -mb-5 w-full`,i),t[0]=i,t[1]=a);let o=n?`rounded-[1.25rem]`:`rounded-3xl`,s;t[2]===o?s=t[3]:(s=J(`overflow-hidden border border-[color-mix(in_srgb,var(--interactive-border)_50%,transparent)] bg-[var(--surface-background)] text-foreground dark:border-transparent dark:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_4%)]`,o),t[2]=o,t[3]=s);let c=n?`px-1.5 py-1`:`gap-0.5 px-3 py-1`,l;t[4]===c?l=t[5]:(l=J(`flex flex-col`,c),t[4]=c,t[5]=l);let u;t[6]!==r||t[7]!==l?(u=(0,$.jsx)(`div`,{"data-yuri-queue-card-body":``,className:l,children:r}),t[6]=r,t[7]=l,t[8]=u):u=t[8];let d=n?`h-4`:`h-5`,f;t[9]===d?f=t[10]:(f=(0,$.jsx)(`div`,{"data-yuri-queue-composer-overlap":``,"aria-hidden":`true`,className:d}),t[9]=d,t[10]=f);let p;t[11]!==s||t[12]!==u||t[13]!==f?(p=(0,$.jsxs)(`div`,{"data-yuri-queue-card":``,className:s,children:[u,f]}),t[11]=s,t[12]=u,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==p||t[16]!==a?(m=(0,$.jsx)(`div`,{className:a,children:p}),t[15]=p,t[16]=a,t[17]=m):m=t[17],m}var Pp=(0,Q.memo)(e=>{let t=(0,Z.c)(19),{items:n,readOnly:r,onAction:i,onShowPopup:a}=e,o=r!==void 0&&r,s=ln(Up);if(!n.length)return null;let c;t[0]===n?c=t[1]:(c=n.map(Wp),t[0]=n,t[1]=c);let l;if(t[2]!==s||t[3]!==n||t[4]!==i||t[5]!==a||t[6]!==o){let e;t[8]!==s||t[9]!==i||t[10]!==a||t[11]!==o?(e=e=>(0,$.jsx)(Fp,{item:e,readOnly:o,isMobile:s,onAction:i,onShowPopup:a},e.id),t[8]=s,t[9]=i,t[10]=a,t[11]=o,t[12]=e):e=t[12],l=n.map(e),t[2]=s,t[3]=n,t[4]=i,t[5]=a,t[6]=o,t[7]=l}else l=t[7];let u;t[13]!==c||t[14]!==l?(u=(0,$.jsx)(pu,{children:(0,$.jsx)(bu,{items:c,strategy:yu,children:l})}),t[13]=c,t[14]=l,t[15]=u):u=t[15];let d;return t[16]!==s||t[17]!==u?(d=(0,$.jsx)(Np,{isMobile:s,children:u}),t[16]=s,t[17]=u,t[18]=d):d=t[18],d});function Fp(e){let t=(0,Z.c)(41),{item:n,readOnly:r,isMobile:i,onAction:a,onShowPopup:o}=e,{t:s}=na(),c;t[0]!==n.id||t[1]!==a?(c=e=>a(e,n.id),t[0]=n.id,t[1]=a,t[2]=c):c=t[2];let l;t[3]===s?l=t[4]:(l=e=>Fi.error(s(`chat.chatInput.toast.messageSendFailed`),{description:e instanceof Error?e.message:String(e)}),t[3]=s,t[4]=l);let u;t[5]!==c||t[6]!==l?(u={mutationFn:c,onError:l},t[5]=c,t[6]=l,t[7]=u):u=t[7];let d=Nt(u),f;t[8]!==n.id||t[9]!==n.payload.files||t[10]!==n.sessionID?(f=Array.isArray(n.payload.files)?n.payload.files.flatMap((e,t)=>{if(!e||typeof e!=`object`)return[];let r=e,i=typeof r.mime==`string`?r.mime:`application/octet-stream`,a=r.source&&typeof r.source==`object`?r.source:void 0,o=typeof r.data==`string`?`data:${i};base64,${r.data}`:typeof r.uri==`string`?r.uri:typeof a?.uri==`string`?a.uri:void 0;return o?[{id:`${n.id}:file:${t}`,type:`file`,sessionID:n.sessionID,messageID:n.id,mime:i,url:o,...typeof r.name==`string`?{filename:r.name}:{}}]:[]}):[],t[8]=n.id,t[9]=n.payload.files,t[10]=n.sessionID,t[11]=f):f=t[11];let p=f,m;t[12]!==n.payload.agents||t[13]!==n.payload.skills?(m=[...Array.isArray(n.payload.agents)?n.payload.agents.flatMap(Lp):[],...Array.isArray(n.payload.skills)?n.payload.skills.flatMap(Ip):[]],t[12]=n.payload.agents,t[13]=n.payload.skills,t[14]=m):m=t[14];let h=m,g=n.id,_;t[15]===n?_=t[16]:(_=y(n),t[15]=n,t[16]=_);let v=r||d.isPending,b=!r,x,S,C;t[17]===d?(x=t[18],S=t[19],C=t[20]):(x=async()=>{await d.mutateAsync(`edit`)},S=async()=>{await d.mutateAsync(`steer`)},C=()=>d.mutate(`cancel`),t[17]=d,t[18]=x,t[19]=S,t[20]=C);let w;t[21]!==i||t[22]!==x||t[23]!==S||t[24]!==C||t[25]!==_||t[26]!==v||t[27]!==b?(w=(0,$.jsx)(Dp,{message:_,server:!1,frozen:v,hasDispatchLock:!1,pendingOperationKinds:jp,sendPendingTimedOut:!1,abortSendPending:!1,steering:!1,isMobile:i,inboxEditable:b,onEdit:x,onSend:S,onRemove:C}),t[21]=i,t[22]=x,t[23]=S,t[24]=C,t[25]=_,t[26]=v,t[27]=b,t[28]=w):w=t[28];let T;t[29]===h?T=t[30]:(T=h.length?(0,$.jsx)(`div`,{className:`px-6 typography-meta text-muted-foreground`,children:h.join(` `)}):null,t[29]=h,t[30]=T);let E;t[31]!==p||t[32]!==n.id||t[33]!==n.sessionID||t[34]!==o?(E=p.length?(0,$.jsx)(`div`,{className:`px-6 pb-1`,children:(0,$.jsx)(Pf,{files:p,messageID:n.id,sessionID:n.sessionID,compact:!0,onShowPopup:o})}):null,t[31]=p,t[32]=n.id,t[33]=n.sessionID,t[34]=o,t[35]=E):E=t[35];let D;return t[36]!==n.id||t[37]!==w||t[38]!==T||t[39]!==E?(D=(0,$.jsxs)(`div`,{"data-native-inbox-id":g,children:[w,T,E]}),t[36]=n.id,t[37]=w,t[38]=T,t[39]=E,t[40]=D):D=t[40],D}function Ip(e){return e&&typeof e.id==`string`?[`[skill:${e.id}]`]:[]}function Lp(e){return e&&typeof e.name==`string`?[`@${e.name}`]:[]}var Rp=(e,t)=>t?$f(rt(e,st(t.sessionID)),rt(e,t)):Op,zp=(e,t)=>{if(!t)return kp;let n=Rp(e,t),r=[...Qe(e,st(t.sessionID)),...Qe(e,t)];return r.length===0?n:[...n,...r]},Bp=(e,t)=>{let n=e.owner;return n?n.state===`unbound-legacy`?n.sessionID===t.sessionID?st(t.sessionID):null:it(n)===it(t)?t:null:null},Vp=(0,Q.memo)(e=>{let t=(0,Z.c)(155),{onEditMessage:n,onSendMessage:r,onEditCommitted:i,draftKey:a,scope:o,draftTarget:s,clientPendingItems:c,onRemoveClientPending:l,onSteerClientPending:u,compactionBarrier:d,steeringMessageIDs:f,trailing:p}=e,m=c===void 0?Ap:c,h=d!==void 0&&d,g=f===void 0?Mp:f,{t:_}=na(),v=ln(Gp),y=o?.transportIdentity??``,b=o?.directory??``,x=o?.sessionID??``,S;t[0]!==y||t[1]!==b||t[2]!==x?(S={transportIdentity:y,directory:b,sessionID:x},t[0]=y,t[1]=b,t[2]=x,t[3]=S):S=t[3];let C=cf(S),w;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(w=new Map,t[4]=w):w=t[4];let E=Q.useRef(w);o?.runtimeGeneration,o?.transportIdentity;let D=o?.transportIdentity??``,O=o?.runtimeGeneration??-1,k;t[5]!==O||t[6]!==D?(k=[D,`messageQueue`,`scopeMutation`,O],t[5]=O,t[6]=D,t[7]=k):k=t[7];let A=k,j;t[8]===C.actions?j=t[9]:(j=e=>ou(E,`${e.transportIdentity}\u0000${e.runtimeGeneration}\u0000${e.directory}\u0000${e.sessionID}\u0000${e.scopeID}`,()=>{if(e.transportIdentity!==e.runtime.transportIdentity||e.runtimeGeneration!==e.runtime.generation)return Promise.resolve({status:`stale`});let t=C.actions.captureRuntime();if(t.transportIdentity!==e.runtime.transportIdentity||t.generation!==e.runtime.generation)return Promise.resolve({status:`stale`});switch(e.kind){case`edit`:return C.actions.editIntoDraft(e.input);case`send`:return C.actions.manualSend(e.input);case`remove`:return C.actions.remove(e.input);case`reorder`:return C.actions.reorder(e.input)}throw Error(`Unsupported server queue operation`)}),t[8]=C.actions,t[9]=j);let M,N;t[10]!==C.actions||t[11]!==_?(M=(e,t)=>{let n=C.actions.captureRuntime();n.transportIdentity===t.runtime.transportIdentity&&n.generation===t.runtime.generation&&e.status!==`stale`&&t.kind===`edit`&&e.status!==`committed`&&Fi.error(_(`chat.chatInput.toast.queueOperationFailed`))},N=(e,t)=>{let n=C.actions.captureRuntime();n.transportIdentity===t.runtime.transportIdentity&&n.generation===t.runtime.generation&&Fi.error(_(e instanceof zl&&e.code===`unavailable`?`chat.chatInput.toast.queueOperationStatusUnknown`:`chat.chatInput.toast.queueOperationFailed`))},t[10]=C.actions,t[11]=_,t[12]=M,t[13]=N):(M=t[12],N=t[13]);let P;t[14]!==A||t[15]!==j||t[16]!==M||t[17]!==N?(P={mutationKey:A,mutationFn:j,onSuccess:M,onError:N},t[14]=A,t[15]=j,t[16]=M,t[17]=N,t[18]=P):P=t[18];let F=Nt(P),I;t[19]===A?I=t[20]:(I={filters:{mutationKey:A,exact:!0,status:`pending`},select:Kp},t[19]=A,t[20]=I);let L=Mt(I),R;t[21]===A?R=t[22]:(R={filters:{mutationKey:A,exact:!0,status:`success`},select:qp},t[21]=A,t[22]=R);let ee=Mt(R),z;bb0:{if(!o||!C.scope){z=null;break bb0}let e=o.runtimeGeneration??C.runtimeCapture.generation,n;t[23]!==o.directory||t[24]!==o.sessionID||t[25]!==o.transportIdentity||t[26]!==C.scope.scopeID||t[27]!==e?(n={transportIdentity:o.transportIdentity,directory:o.directory,sessionID:o.sessionID,scopeID:C.scope.scopeID,runtimeGeneration:e},t[23]=o.directory,t[24]=o.sessionID,t[25]=o.transportIdentity,t[26]=C.scope.scopeID,t[27]=e,t[28]=n):n=t[28],z=n}let B=z,V;bb1:{if(!B){let e;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[29]=e):e=t[29],V=e;break bb1}let e;if(t[30]!==B||t[31]!==L){let n;t[33]===B?n=t[34]:(n=e=>Ep(e)&&e.scopeID===B.scopeID,t[33]=B,t[34]=n),e=fp(L.filter(n),B),t[30]=B,t[31]=L,t[32]=e}else e=t[32];V=e}let H=V,U;t[35]!==B||t[36]!==C.scope?.revision||t[37]!==ee?(U=()=>B?pp(ee.filter(Jp),B,C.scope?.revision):[],t[35]=B,t[36]=C.scope?.revision,t[37]=ee,t[38]=U):U=t[38],C.scope?.revision;let te;t[39]===U?te=t[40]:(te=U(),t[39]=U,t[40]=te);let ne=te,re;t[41]!==ne||t[42]!==H?(re=[...H,...ne],t[41]=ne,t[42]=H,t[43]=re):re=t[43];let W=re,ie;t[44]===o?ie=t[45]:(ie=e=>zp(e,o),t[44]=o,t[45]=ie);let ae=tt(ie);Q.useSyncExternalStore(Gl,nu,nu);let oe;t[46]!==W||t[47]!==ae||t[48]!==C.items||t[49]!==C.mode?(oe=C.mode===`server`?gp(C.items,W):ae,t[46]=W,t[47]=ae,t[48]=C.items,t[49]=C.mode,t[50]=oe):oe=t[50];let se=oe,ce;t[51]!==se||t[52]!==m?(ce=m.length===0?se:[...se,...m],t[51]=se,t[52]=m,t[53]=ce):ce=t[53];let le=ce,ue;t[54]!==o?.sessionID||t[55]!==le?(ue=()=>{let e=o?.sessionID,t=new Set;if(!e)return t;for(let n of le){let r=n.queueItemID||n.id;r&&Ql(e,r)&&t.add(r)}return t},t[54]=o?.sessionID,t[55]=le,t[56]=ue):ue=t[56],o?.sessionID;let de;t[57]===ue?de=t[58]:(de=ue(),t[57]=ue,t[58]=de);let fe=de,pe;if(t[59]!==W){pe=new Map;for(let e of W){let t=pe.get(e.queueItemID)??new Set;t.add(e.kind),pe.set(e.queueItemID,t)}t[59]=W,t[60]=pe}else pe=t[60];let me=pe,he;if(t[61]!==W||t[62]!==le||t[63]!==C.mode){bb2:{let e=new Set;if(C.mode===`server`){for(let t of W)t.kind===`send`&&e.add(t.queueItemID);for(let t of le){if(Fl(t))continue;let n=t.queueItemID;n&&cp(t)&&e.add(n)}he=e;break bb2}for(let t of le){if(Fl(t))continue;let n=t;sp(n)&&e.add(n.queueItemID||n.id)}he=e}t[61]=W,t[62]=le,t[63]=C.mode,t[64]=he}else he=t[64];let ge=he,[_e,ve]=Q.useState(Yp),ye;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(ye=new Map,t[65]=ye):ye=t[65];let be=Q.useRef(ye),xe,Se;t[66]!==ge||t[67]!==_e?(xe=()=>{let e=be.current,t=Date.now();for(let t of[...e.keys()])ge.has(t)||e.delete(t);ve(e=>{let t=!1,n=new Set;for(let r of e)ge.has(r)?n.add(r):t=!0;return t?n:e});let n=[];for(let r of ge){if(e.has(r)||(e.set(r,t),ve(e=>{if(!e.has(r))return e;let t=new Set(e);return t.delete(r),t})),_e.has(r))continue;let i=up-(t-(e.get(r)??t));if(i<=0){ve(e=>{if(e.has(r))return e;let t=new Set(e);return t.add(r),t});continue}n.push(setTimeout(()=>{be.current.has(r)&&ve(e=>{if(e.has(r))return e;let t=new Set(e);return t.add(r),t})},i))}return()=>{for(let e of n)clearTimeout(e)}},Se=[ge,_e],t[66]=ge,t[67]=_e,t[68]=xe,t[69]=Se):(xe=t[68],Se=t[69]),Q.useEffect(xe,Se);let Ce;t[70]===C.mode?Ce=t[71]:(Ce=Qf(C.mode),t[70]=C.mode,t[71]=Ce);let we=!Ce,Te=Jl(o),Ee;t[72]!==Te||t[73]!==le||t[74]!==C.mode?(Ee=C.mode===`server`?!1:Te||le.some(Xp),t[72]=Te,t[73]=le,t[74]=C.mode,t[75]=Ee):Ee=t[75];let De=Ee,Oe=tt(Zp),ke;t[76]===Symbol.for(`react.memo_cache_sentinel`)?(ke={activationConstraint:{distance:8}},t[76]=ke):ke=t[76];let Ae;t[77]===Symbol.for(`react.memo_cache_sentinel`)?(Ae={activationConstraint:{delay:200,tolerance:6}},t[77]=Ae):Ae=t[77];let je=mu(su(fu,ke),su(lu,Ae)),Me=G(Qp),Ne;t[78]!==we||t[79]!==o||t[80]!==le||t[81]!==Oe||t[82]!==F||t[83]!==C.actions||t[84]!==C.mode||t[85]!==C.scope?(Ne=e=>{if(Di(`light`,{bypassCadence:!0}),we)return;let{active:t,over:n}=e;if(!n||t.id===n.id)return;if(C.mode===`server`){if(!o||!C.scope)return;let e=le,r=e.find(e=>e.queueItemID===t.id),i=e.find(e=>e.queueItemID===n.id);if(!r||!i||Fl(r)||Fl(i)||op(r)||op(i))return;let a=C.scope,s=C.actions.captureRuntime();if(s.transportIdentity!==o.transportIdentity||s.generation!==o.runtimeGeneration)return;let c=mn(),l=yp(a,String(t.id),String(n.id),c,e);if(!l)return;F.mutateAsync({kind:`reorder`,transportIdentity:s.transportIdentity,directory:a.directory,sessionID:a.sessionID,scopeID:a.scopeID,queueItemID:String(t.id),queueItemIDs:l.queueItemIDs,requestID:c,runtime:s,runtimeGeneration:s.generation,input:l}).catch($p);return}let r=le.filter(em),i=r.find(e=>(e.queueItemID??e.id)===t.id),a=r.find(e=>(e.queueItemID??e.id)===n.id);if(!i||!a||!o)return;let s=Bp(i,o),c=Bp(a,o);!s||!c||it(s)!==it(c)||Oe(s,String(t.id),String(n.id),i.operationID)},t[78]=we,t[79]=o,t[80]=le,t[81]=Oe,t[82]=F,t[83]=C.actions,t[84]=C.mode,t[85]=C.scope,t[86]=Ne):Ne=t[86];let Pe=G(Ne),Fe=Q.useRef(!0),Ie,Le;t[87]===Symbol.for(`react.memo_cache_sentinel`)?(Ie=()=>(Fe.current=!0,()=>{Fe.current=!1}),Le=[],t[87]=Ie,t[88]=Le):(Ie=t[87],Le=t[88]),Q.useEffect(Ie,Le);let Re;t[89]!==s||t[90]!==we||t[91]!==o?.directory||t[92]!==o?.runtimeGeneration||t[93]!==o?.sessionID||t[94]!==o?.transportIdentity?(Re=(e,t)=>Fe.current&&!we&&o?.transportIdentity===e.transportIdentity&&o?.runtimeGeneration===e.runtimeGeneration&&o?.sessionID===e.sessionID&&o?.directory===e.directory&&!!(s&&ft(s.key)===ft(t)),t[89]=s,t[90]=we,t[91]=o?.directory,t[92]=o?.runtimeGeneration,t[93]=o?.sessionID,t[94]=o?.transportIdentity,t[95]=Re):Re=t[95];let ze=G(Re),Be;t[96]!==a||t[97]!==s||t[98]!==we||t[99]!==ze||t[100]!==i||t[101]!==n||t[102]!==o||t[103]!==F||t[104]!==C.actions||t[105]!==C.mode||t[106]!==C.scope||t[107]!==_?(Be=e=>{if(we||Fl(e))return;if(T(e)){if(!o||!s||e.delivery!==`queue`)return;let t=o,n=s.key;return Zf({sessionID:t.sessionID,inboxID:e.queueItemID,directory:t.directory,targetKey:n,expectedRevision:s.expectedRevision(),runtimeGeneration:t.runtimeGeneration,isCurrent:()=>ze(t,n)}).then(e=>{e&&ze(t,n)&&i?.()}).catch(()=>{Fi.error(_(`chat.chatInput.toast.messageSendFailed`))})}if(C.mode===`server`){if(!o||!C.scope||!a||!s)return;let t=e,n=s.expectedRevision(),r=C.scope,c=C.actions.captureRuntime();if(c.transportIdentity!==o.transportIdentity||c.generation!==o.runtimeGeneration)return;F.mutateAsync({kind:`edit`,transportIdentity:c.transportIdentity,directory:r.directory,sessionID:r.sessionID,scopeID:r.scopeID,queueItemID:t.queueItemID,requestID:mn(),runtime:c,runtimeGeneration:c.generation,input:vp(r,t,s.key,n)}).then(e=>{(e.status===`committed`||`draftDurable`in e&&e.draftDurable)&&i?.()}).catch(tm);return}if(!o)return;let t=e,r=Bp(t,o);if(!r)return;let c=t.queueItemID??t.id,l=t.operationID,u=tp(t);(async()=>{let e;try{e=await Promise.resolve(n(u.content,u.attachments,u.composerDocument,u.composerMentions))}catch{e=!1}e&&(i?.(),tt.getState().removeFromQueue(r,c,l))})()},t[96]=a,t[97]=s,t[98]=we,t[99]=ze,t[100]=i,t[101]=n,t[102]=o,t[103]=F,t[104]=C.actions,t[105]=C.mode,t[106]=C.scope,t[107]=_,t[108]=Be):Be=t[108];let Ve=G(Be),He;t[109]!==h||t[110]!==we||t[111]!==r||t[112]!==u||t[113]!==o||t[114]!==F||t[115]!==C.actions||t[116]!==C.mode||t[117]!==C.scope?(He=e=>{if(T(e))return h?void 0:u?.(e.queueItemID);if(we||Fl(e))return;if(C.mode===`server`){if(!o||!C.scope)return;let t=e,n=C.scope,r=C.actions.captureRuntime();if(r.transportIdentity!==o.transportIdentity||r.generation!==o.runtimeGeneration)return;let i=t.queueItemID;be.current.delete(i),ve(e=>{if(!e.has(i))return e;let t=new Set(e);return t.delete(i),t});let a=mn();F.mutateAsync({kind:`send`,transportIdentity:r.transportIdentity,directory:n.directory,sessionID:n.sessionID,scopeID:n.scopeID,queueItemID:t.queueItemID,requestID:a,runtime:r,runtimeGeneration:r.generation,input:_p(n,t,a)}).catch(nm);return}if(!o)return;let t=e;if(!Bp(t,o))return;let n=t.queueItemID??t.id;be.current.delete(n),ve(e=>{if(!e.has(n))return e;let t=new Set(e);return t.delete(n),t}),r(n)},t[109]=h,t[110]=we,t[111]=r,t[112]=u,t[113]=o,t[114]=F,t[115]=C.actions,t[116]=C.mode,t[117]=C.scope,t[118]=He):He=t[118];let Ue=G(He),We;t[119]!==m||t[120]!==we||t[121]!==l||t[122]!==o||t[123]!==F||t[124]!==C.actions||t[125]!==C.mode||t[126]!==C.scope?(We=e=>{if(T(e)){l?.(e.requestID);return}if(Fl(e)){m.some(t=>t.requestID===e.requestID)&&l?.(e.requestID);return}if(we)return;if(C.mode===`server`){if(!o||!C.scope)return;let t=e,n=C.scope,r=C.actions.captureRuntime();if(r.transportIdentity!==o.transportIdentity||r.generation!==o.runtimeGeneration)return;let i=mn();F.mutateAsync({kind:`remove`,transportIdentity:r.transportIdentity,directory:n.directory,sessionID:n.sessionID,scopeID:n.scopeID,queueItemID:t.queueItemID,requestID:i,runtime:r,runtimeGeneration:r.generation,input:_p(n,t,i)}).catch(rm);return}if(!o)return;let t=e,n=Bp(t,o);n&&tt.getState().removeFromQueue(n,t.queueItemID??t.id,t.operationID)},t[119]=m,t[120]=we,t[121]=l,t[122]=o,t[123]=F,t[124]=C.actions,t[125]=C.mode,t[126]=C.scope,t[127]=We):We=t[127];let Ge=G(We),Ke=le.length>0&&(o||m.length>0);if(!Ke&&!p)return null;let qe;t[128]!==fe||t[129]!==h||t[130]!==s||t[131]!==we||t[132]!==Pe||t[133]!==Me||t[134]!==Ve||t[135]!==Ge||t[136]!==Ue||t[137]!==De||t[138]!==Ke||t[139]!==v||t[140]!==me||t[141]!==o||t[142]!==le||t[143]!==_e||t[144]!==je||t[145]!==C.mode||t[146]!==g?(qe=Ke?(0,$.jsx)(pu,{sensors:je,collisionDetection:du,onDragStart:Me,onDragEnd:Pe,children:(0,$.jsx)(bu,{items:le.map(im),strategy:yu,children:le.map(e=>{let t=e.queueItemID||e.id;return(0,$.jsx)(Dp,{message:e,server:C.mode===`server`,frozen:we,hasDispatchLock:De,pendingOperationKinds:me.get(t)??jp,sendPendingTimedOut:_e.has(t),abortSendPending:fe.has(t),steering:g.has(t)||!!(e.messageID&&g.has(e.messageID)),isMobile:v,inboxEditable:!!(o&&s),onEdit:Ve,onSend:Ue,onRemove:Ge,compactionBarrier:h},t)})})}):null,t[128]=fe,t[129]=h,t[130]=s,t[131]=we,t[132]=Pe,t[133]=Me,t[134]=Ve,t[135]=Ge,t[136]=Ue,t[137]=De,t[138]=Ke,t[139]=v,t[140]=me,t[141]=o,t[142]=le,t[143]=_e,t[144]=je,t[145]=C.mode,t[146]=g,t[147]=qe):qe=t[147];let Je;t[148]!==Ke||t[149]!==p?(Je=p?(0,$.jsxs)($.Fragment,{children:[Ke?(0,$.jsx)(`div`,{"aria-hidden":`true`,className:`my-0.5 border-t border-border/40`}):null,p]}):null,t[148]=Ke,t[149]=p,t[150]=Je):Je=t[150];let Ye;return t[151]!==v||t[152]!==qe||t[153]!==Je?(Ye=(0,$.jsxs)(Np,{isMobile:v,children:[qe,Je]}),t[151]=v,t[152]=qe,t[153]=Je,t[154]=Ye):Ye=t[154],Ye});Vp.displayName=`QueuedMessageChips`;function Hp(e,t){return e.type===`text`?(0,$.jsx)(`span`,{className:`min-w-0 truncate whitespace-pre`,children:e.text},`text-${t}`):(0,$.jsx)(ec,{decoration:e.decoration,interactive:!1},`ref-${t}-${e.span.start}`)}function Up(e){return e.isMobile}function Wp(e){return e.id}function Gp(e){return e.isMobile}function Kp(e){return e.state.variables}function qp(e){let t=e.state.variables;if(!Ep(t)||t.kind!==`send`)return;let n=e.state.data;if(!n||n.status!==`committed`)return;let r=`committedRevision`in n&&typeof n.committedRevision==`number`&&Number.isSafeInteger(n.committedRevision)?n.committedRevision:void 0,i=`scope`in n&&n.scope&&typeof n.scope.revision==`number`&&Number.isSafeInteger(n.scope.revision)?n.scope.revision:void 0,a=r??i;if(!(a===void 0||a<=0))return{...t,kind:`send`,committedRevision:a}}function Jp(e){return e!==void 0}function Yp(){return new Set}function Xp(e){return!Fl(e)&&(e.status===`sending`||e.status===`reconciling`)}function Zp(e){return e.reorderQueue}function Qp(){Di(`light`,{bypassCadence:!0})}function $p(){}function em(e){return!Fl(e)}function tm(){}function nm(){}function rm(){}function im(e){return e.queueItemID||e.id}function am(e){let t=(0,Z.c)(21),{presentation:n}=e,{text:r,icon:i,variant:a,rawMessage:o,detail:s}=n,c=a===`error`?`alert`:`status`,l;t[0]===i?l=t[1]:(l=(0,$.jsx)(`span`,{className:`inline-flex h-5 shrink-0 items-center`,"aria-hidden":`true`,children:(0,$.jsx)(X,{name:i,className:`size-3.5`})}),t[0]=i,t[1]=l);let u;t[2]!==s||t[3]!==o||t[4]!==r?(u=[r,s,o].filter(Boolean),t[2]=s,t[3]=o,t[4]=r,t[5]=u):u=t[5];let d=u.join(` · `),f;t[6]===s?f=t[7]:(f=s?(0,$.jsx)(`span`,{className:`ml-1.5 text-muted-foreground/60`,children:s}):null,t[6]=s,t[7]=f);let p;t[8]!==o||t[9]!==r?(p=o&&o!==r?(0,$.jsx)(`span`,{className:`ml-1.5 text-muted-foreground/80`,children:o}):null,t[8]=o,t[9]=r,t[10]=p):p=t[10];let m;t[11]!==d||t[12]!==f||t[13]!==p||t[14]!==r?(m=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:d,children:[r,f,p]}),t[11]=d,t[12]=f,t[13]=p,t[14]=r,t[15]=m):m=t[15];let h;return t[16]!==c||t[17]!==l||t[18]!==m||t[19]!==a?(h=(0,$.jsxs)(`div`,{role:c,"data-response-status":a,className:`flex w-full min-w-0 items-start gap-1.5 typography-meta leading-5 text-muted-foreground`,children:[l,m]}),t[16]=c,t[17]=l,t[18]=m,t[19]=a,t[20]=h):h=t[20],h}function om(e){let t=(0,Z.c)(7),{sessionId:n,directory:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={bootstrap:!1},t[0]=i):i=t[0];let a=hr(r,i),o;t[1]===n?o=t[2]:(o=e=>e.session_execution_recovery[n]?.reason===`shutdown`,t[1]=n,t[2]=o);let s=we(a,o),{t:c}=na();if(!s)return null;let l;t[3]===c?l=t[4]:(l=c(`chat.sessionRecovery.awaitingConfirmation`),t[3]=c,t[4]=l);let u;return t[5]===l?u=t[6]:(u=(0,$.jsx)(`div`,{className:`px-4 py-1.5`,"aria-live":`polite`,children:(0,$.jsx)(am,{presentation:{text:l,icon:`restart`,variant:`info`}})}),t[5]=l,t[6]=u),u}var sm=e=>e===`full`||e===`allow`?{text:`var(--status-info)`,border:`color-mix(in srgb, var(--status-info) 25%, transparent)`,background:`color-mix(in srgb, var(--status-info) 4%, transparent)`,borderWidth:1.5}:null,cm=1e3,lm=e=>{let t=(0,Z.c)(27),{name:n,label:r,revealed:i,avatarSize:a,slotClassName:o,labelGapClassName:s,colorVar:c}=e,l=s===void 0?`pl-1.5 pr-0.5`:s,u;t[0]===o?u=t[1]:(u=J(`inline-flex shrink-0 items-center justify-center`,o),t[0]=o,t[1]=u);let d=i?void 0:r,f;t[2]!==a||t[3]!==n||t[4]!==d?(f=(0,$.jsx)(cs,{name:n,size:a,label:d}),t[2]=a,t[3]=n,t[4]=d,t[5]=f):f=t[5];let p;t[6]!==u||t[7]!==f?(p=(0,$.jsx)(`span`,{className:u,children:f}),t[6]=u,t[7]=f,t[8]=p):p=t[8];let m=i?`grid-cols-[1fr] opacity-100`:`grid-cols-[0fr] opacity-0`,h;t[9]===m?h=t[10]:(h=J(`grid min-w-0 items-center ease-in-out`,m),t[9]=m,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g={transitionProperty:`grid-template-columns, opacity`,transitionDuration:`280ms`,transitionTimingFunction:`ease-in-out`},t[11]=g):g=t[11];let _=!i,v;t[12]===l?v=t[13]:(v=J(`inline-block whitespace-nowrap typography-micro leading-none font-medium`,l),t[12]=l,t[13]=v);let y;t[14]===c?y=t[15]:(y=c?{color:`var(${c})`}:void 0,t[14]=c,t[15]=y);let b;t[16]!==r||t[17]!==v||t[18]!==y?(b=(0,$.jsx)(`span`,{className:`flex min-w-0 items-center overflow-hidden`,children:(0,$.jsx)(`span`,{className:v,style:y,children:r})}),t[16]=r,t[17]=v,t[18]=y,t[19]=b):b=t[19];let x;t[20]!==b||t[21]!==h||t[22]!==_?(x=(0,$.jsx)(`span`,{className:h,style:g,"aria-hidden":_,children:b}),t[20]=b,t[21]=h,t[22]=_,t[23]=x):x=t[23];let S;return t[24]!==x||t[25]!==p?(S=(0,$.jsxs)($.Fragment,{children:[p,x]}),t[24]=x,t[25]=p,t[26]=S):S=t[26],S};function um(e){let t=(0,Z.c)(5),[n,r]=Q.useState(!1),i=Q.useRef(void 0),a=Q.useRef(!1),o=Q.useRef(null),s,c;t[0]===e?(s=t[1],c=t[2]):(s=()=>{if(!a.current){a.current=!0,i.current=e;return}if(e===i.current)return;let t=i.current;if(i.current=e,!t||!e){r(!1);return}return r(!0),o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{r(!1),o.current=null},cm),()=>{o.current&&=(clearTimeout(o.current),null)}},c=[e],t[0]=e,t[1]=s,t[2]=c),Q.useEffect(s,c);let l,u;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>()=>{o.current&&clearTimeout(o.current)},u=[],t[3]=l,t[4]=u):(l=t[3],u=t[4]),Q.useEffect(l,u),n}var dm=`yuri-tool-row -mx-2 rounded-lg px-2 py-0.5 cursor-pointer`,fm=e=>`flow-root ${e?`py-1`:`py-1.5`}`,pm=e=>`relative ml-2 flex flex-col pl-3 ${e?`gap-1 pt-1`:`gap-1.5 pt-1.5`}`,mm=`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)]`,hm=`${dm} ${mm}`,gm=`hover:!bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] data-[popup-open]:!bg-[color-mix(in_srgb,var(--surface-foreground)_10%,transparent)] data-[state=open]:!bg-[color-mix(in_srgb,var(--surface-foreground)_10%,transparent)]`,_m=`inline-flex items-center gap-1.5 rounded-lg px-2.5 py-1 ${gm}`,vm=`rounded-md ${gm}`,ym=()=>{if(!(typeof window>`u`))return window.__zustand_config_store__},bm=e=>{if(e)try{let t=ym();if(t?.getState)return t.getState().agents?.find?.(t=>t.name===e)}catch{}},xm=(e,t)=>{if(!e||e.length===0)return`ask`;for(let n=e.length-1;n>=0;--n){let r=e[n];if(r.permission===t&&r.pattern===`*`)return r.action}for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.permission===`*`&&n.pattern===`*`)return n.action}return`ask`},Sm=e=>{let t=bm(e);return t?xm(t.permission,`edit`):`ask`},Cm=e=>{if(!e||typeof e!=`object`)return 0;let t=e.input??0,n=e.output??0,r=e.reasoning??0,i=e.cache&&typeof e.cache==`object`?e.cache.read??0:0,a=e.cache&&typeof e.cache==`object`?e.cache.write??0:0;return t+n+r+i+a},wm=e=>{let t=e.info.tokens;if(typeof t==`number`)return t;if(t&&typeof t==`object`)return Cm(t);let n=e.parts.find(e=>e.tokens!==void 0);return!n||n.tokens===void 0?0:typeof n.tokens==`number`?n.tokens:Cm(n.tokens)},Tm=e=>{if(!e||typeof e!=`object`)return{percent:0,hasInput:!1};let t=e.input??0,n=e.cache&&typeof e.cache==`object`?e.cache.read??0:0,r=e.cache&&typeof e.cache==`object`?e.cache.write??0:0,i=t+n+r;return i<=0?{percent:0,hasInput:!1}:{percent:Math.min(100,Math.max(0,Math.max(0,n)/i*100)),hasInput:!0}},Em=(e,t,n)=>{let r=Number.isFinite(t)?Math.max(t,0):0,i=Number.isFinite(n)&&n>0,a=i?Math.max(n,0):0,o=Math.min(Math.min(i?a:32e3,32e3),r),s=r>0?Math.max(r-o,1):0,c=s>0?e/s*100:0;return{percentage:Math.min(c,100),contextLimit:r,outputLimit:a,thresholdLimit:s||1,normalizedOutput:o}},Dm=[`ask`,`allow`,`full`],Om=`__global__`,km=Se()(Te(Ce((e,t)=>({sessionModelSelections:new Map,sessionAgentSelections:new Map,sessionAgentModelSelections:new Map,sessionAgentModelVariantSelections:new Map,currentAgentContext:new Map,sessionContextUsage:new Map,sessionAgentEditModes:new Map,hasHydrated:typeof window>`u`,saveSessionModelSelection:(t,n,r)=>{e(e=>{let i=new Map(e.sessionModelSelections);return i.set(t,{providerId:n,modelId:r}),{sessionModelSelections:i}})},getSessionModelSelection:e=>{let{sessionModelSelections:n}=t();return n.get(e)||null},saveSessionAgentSelection:(t,n)=>{e(e=>{let r=new Map(e.sessionAgentSelections);r.set(t,n);let i=new Map(e.currentAgentContext);return i.set(t,n),{sessionAgentSelections:r,currentAgentContext:i}})},getSessionAgentSelection:e=>{let{sessionAgentSelections:n}=t();return n.get(e)||null},saveAgentModelForSession:(t,n,r,i)=>{e(e=>{let a=new Map(e.sessionAgentModelSelections),o=a.get(t);return o=o?new Map(o):new Map,o.set(n,{providerId:r,modelId:i}),a.set(t,o),{sessionAgentModelSelections:a}})},getAgentModelForSession:(e,n)=>{let{sessionAgentModelSelections:r}=t(),i=r.get(e);return i&&i.get(n)||null},saveAgentModelVariantForSession:(t,n,r,i,a)=>{e(e=>{let o=new Map(e.sessionAgentModelVariantSelections),s=o.get(t);s=s?new Map(s):new Map;let c=s.get(n);c=c?new Map(c):new Map;let l=`${r}/${i}`;return a===void 0?(c.delete(l),c.size===0?(s.delete(n),s.size===0?o.delete(t):o.set(t,s)):(s.set(n,c),o.set(t,s))):(c.set(l,a),s.set(n,c),o.set(t,s)),{sessionAgentModelVariantSelections:o}})},getAgentModelVariantForSession:(e,n,r,i)=>{let{sessionAgentModelVariantSelections:a}=t(),o=a.get(e);if(!o)return;let s=o.get(n);if(s)return s.get(`${r}/${i}`)},getContextUsage:(n,r,i,a)=>{if(!n)return null;let o=Em(0,r,i),s=o.contextLimit,c=o.normalizedOutput??0,l=o.thresholdLimit;if(s===0||l===0)return null;let u=(a.get(n)||[]).filter(e=>e.info.role===`assistant`);if(u.length===0)return null;let d=u[u.length-1],f=d.info.id,p=t=>{let r=()=>{e(e=>{let r=e.sessionContextUsage.get(n);if(r&&r.totalTokens===t.totalTokens&&r.percentage===t.percentage&&r.contextLimit===t.contextLimit&&(r.outputLimit??0)===(t.outputLimit??0)&&(r.normalizedOutput??0)===(t.normalizedOutput??0)&&r.thresholdLimit===t.thresholdLimit&&r.lastMessageId===t.lastMessageId)return e;let i=new Map(e.sessionContextUsage);return i.set(n,t),{sessionContextUsage:i}})};typeof queueMicrotask==`function`?queueMicrotask(r):typeof window<`u`?window.setTimeout(r,0):setTimeout(r,0)},m=t().sessionContextUsage.get(n);if(m&&m.lastMessageId===f){let e=m.normalizedOutput??m.outputLimit??0,t=m.contextLimit!==s||e!==c||m.thresholdLimit!==l;if(t&&m.totalTokens>0){let e=m.totalTokens/l*100,t={totalTokens:m.totalTokens,percentage:Math.min(e,100),contextLimit:s,outputLimit:o.outputLimit,normalizedOutput:c,thresholdLimit:l,lastMessageId:f};return p(t),t}if(!t&&m.totalTokens>0)return m}let h=wm(d);if(h===0)return m||null;let g=Em(h,r,i),_={totalTokens:h,percentage:g.percentage,contextLimit:g.contextLimit,outputLimit:g.outputLimit,normalizedOutput:g.normalizedOutput,thresholdLimit:g.thresholdLimit,lastMessageId:f};return p(_),_},updateSessionContextUsage:(t,n,r,i)=>{let a=(i.get(t)||[]).filter(e=>e.info.role===`assistant`);if(a.length===0)return;let o=a[a.length-1],s=wm(o);if(s===0)return;let c=Em(s,n,r);e(e=>{let n=new Map(e.sessionContextUsage);return n.set(t,{totalTokens:s,percentage:c.percentage,contextLimit:c.contextLimit,outputLimit:c.outputLimit,normalizedOutput:c.normalizedOutput,thresholdLimit:c.thresholdLimit,lastMessageId:o.info.id}),{sessionContextUsage:n}})},initializeSessionContextUsage:(e,n,r,i)=>{let a=t().sessionContextUsage.get(e);(!a||a.totalTokens===0)&&t().updateSessionContextUsage(e,n,r,i)},pollForTokenUpdates:(e,n,r,i=10)=>{let a=0,o=()=>{a++;let s=(r.get(e)||[]).find(e=>e.info.id===n);if(s&&s.info.role===`assistant`&&wm(s)>0){t().updateSessionContextUsage(e,0,0,r);return}a<i&&setTimeout(o,1e3)};setTimeout(o,2e3)},getCurrentAgent:e=>{let{currentAgentContext:n}=t();return n.get(e)},getSessionAgentEditMode:(e,n,r=Sm(n))=>{if(!e||!n)return r;let i=t().sessionAgentEditModes.get(e)?.get(n);if(i!==void 0)return i;if(e!==Om){let e=t().sessionAgentEditModes.get(Om)?.get(n);if(e!==void 0)return e}return r},setSessionAgentEditMode:(t,n,r,i=Sm(n))=>{if(!t||!n)return;let a=i??`ask`;a!==`deny`&&r!==`deny`&&Dm.includes(r)&&e(e=>{let i=new Map(e.sessionAgentEditModes),o=new Map(i.get(t)??new Map);return r===a?(o.delete(n),o.size===0?i.delete(t):i.set(t,o)):(o.set(n,r),i.set(t,o)),{sessionAgentEditModes:i}})},toggleSessionAgentEditMode:(e,n,r=Sm(n))=>{if(!e||!n)return;let i=r??`ask`;if(i===`deny`)return;let a=t().getSessionAgentEditMode(e,n,i),o=Dm.indexOf(a),s=Dm.indexOf(i),c=Dm[((o>=0?o:s>=0?s:0)+1)%Dm.length];t().setSessionAgentEditMode(e,n,c,i)}}),{name:`context-store`,storage:dt(),partialize:e=>({sessionModelSelections:Array.from(e.sessionModelSelections.entries()),sessionAgentSelections:Array.from(e.sessionAgentSelections.entries()),sessionAgentModelSelections:Array.from(e.sessionAgentModelSelections.entries()).map(([e,t])=>[e,Array.from(t.entries())]),sessionAgentModelVariantSelections:Array.from(e.sessionAgentModelVariantSelections.entries()).map(([e,t])=>[e,Array.from(t.entries()).map(([e,t])=>[e,Array.from(t.entries())])]),currentAgentContext:Array.from(e.currentAgentContext.entries()),sessionContextUsage:Array.from(e.sessionContextUsage.entries()),sessionAgentEditModes:Array.from(e.sessionAgentEditModes.entries()).map(([e,t])=>[e,Array.from(t.entries())])}),merge:(e,t)=>{let n=new Map;e?.sessionAgentModelSelections&&e.sessionAgentModelSelections.forEach(([e,t])=>{n.set(e,new Map(t))});let r=new Map;e?.sessionAgentModelVariantSelections&&e.sessionAgentModelVariantSelections.forEach(([e,t])=>{let n=new Map;t.forEach(([e,t])=>{n.set(e,new Map(t))}),r.set(e,n)});let i=new Map;return e?.sessionAgentEditModes&&e.sessionAgentEditModes.forEach(([e,t])=>{i.set(e,new Map(t))}),{...t,...e,sessionModelSelections:new Map(e?.sessionModelSelections||[]),sessionAgentSelections:new Map(e?.sessionAgentSelections||[]),sessionAgentModelSelections:n,sessionAgentModelVariantSelections:r,currentAgentContext:new Map(e?.currentAgentContext||[]),sessionContextUsage:new Map(e?.sessionContextUsage||[]),sessionAgentEditModes:i,hasHydrated:!0}}}),{name:`context-store`})),Am=e=>Zr([...e??[]]);function jm(e,t){return!e&&t===`trigger-hover`}var Mm=(e,t)=>{let n=e.target;n instanceof Element&&e.currentTarget.contains(n)&&(n.closest(`textarea[data-chat-input="true"]`)||n.closest(`[data-chat-prompt-attachments="true"]`)||n.closest(`button, [role="button"], a, label, input, select, [data-composer-action="true"], [data-chat-input-footer="true"]`)&&(t(),e.preventDefault()))},Nm=e=>{let t=e.current;return!t||!t.isConnected||t.disabled?null:t},Pm=e=>{let t=Nm(e);return t?(t.focus({preventScroll:!0}),!0):!1},Fm=(e,t)=>e&&!t,Im=(e,t)=>`${e}:${t}`,Lm=`transition-none animate-none data-[starting-style]:!opacity-100 data-[starting-style]:!scale-100 data-[ending-style]:!opacity-100 data-[ending-style]:!scale-100`,Rm=e=>{if(!Array.isArray(e))return null;let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;typeof e.permission==`string`&&typeof e.pattern==`string`&&typeof e.action==`string`&&(e.action===`allow`||e.action===`ask`||e.action===`deny`)&&t.push({permission:e.permission,pattern:e.pattern,action:e.action})}return t},zm=(e,t)=>{let n=Rm(e);if(!(!n||n.length===0)){for(let e=n.length-1;e>=0;--e){let r=n[e];if(r.permission===t&&r.pattern===`*`)return r.action}for(let e=n.length-1;e>=0;--e){let t=n[e];if(t.permission===`*`&&t.pattern===`*`)return t.action}}},Bm=[{key:`tool_call`,icon:`tools`,label:`Tool calling`,isActive:e=>e?.tool_call===!0},{key:`reasoning`,icon:`brain-ai-3`,label:`Reasoning`,isActive:e=>e?.reasoning===!0}],Vm={text:{icon:`text`,label:`Text`},image:{icon:`file-image`,label:`Image`},video:{icon:`file-video`,label:`Video`},audio:{icon:`file-music`,label:`Audio`},pdf:{icon:`file-pdf`,label:`PDF`}},Hm=e=>e.trim().toLowerCase(),Um=(e,t)=>{let n=t===`input`?e?.modalities?.input:e?.modalities?.output;if(!Array.isArray(n)||n.length===0)return[];let r=Array.from(new Set(n.map(e=>Hm(e)))),i=[];for(let e of r){let t=Vm[e];t&&i.push({key:e,icon:t.icon,label:t.label})}return i},Wm=e=>Su(e),Gm=e=>Du(e),Km=e=>Au(e),qm=`__add_provider__`,Jm=e=>{let t=(0,Z.c)(5),{iconName:n,label:r}=e,i;t[0]===n?i=t[1]:(i=(0,$.jsx)(X,{name:n,className:`size-3.5`}),t[0]=n,t[1]=i);let a;return t[2]!==r||t[3]!==i?(a=(0,$.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-xl bg-muted/60 text-muted-foreground`,title:r,"aria-label":r,role:`img`,children:i}),t[2]=r,t[3]=i,t[4]=a):a=t[4],a},Ym=e=>{let t=(0,Z.c)(18),{mode:n,className:r}=e,i;t[0]===r?i=t[1]:(i=J(r,`flex-shrink-0`),t[0]=r,t[1]=i);let a=i,o;t[2]===n?o=t[3]:(o=sm(n),t[2]=n,t[3]=o);let s=o,c=s?s.text:`var(--foreground)`,l;t[4]===c?l=t[5]:(l={color:c},t[4]=c,t[5]=l);let u=l;if(n===`full`){let e;return t[6]!==a||t[7]!==u?(e=(0,$.jsx)(X,{name:`pencil-ai`,className:a,style:u}),t[6]=a,t[7]=u,t[8]=e):e=t[8],e}if(n===`allow`){let e;return t[9]!==a||t[10]!==u?(e=(0,$.jsx)(X,{name:`checkbox-circle`,className:a,style:u}),t[9]=a,t[10]=u,t[11]=e):e=t[11],e}if(n===`deny`){let e;return t[12]!==a||t[13]!==u?(e=(0,$.jsx)(X,{name:`close-circle`,className:a,style:u}),t[12]=a,t[13]=u,t[14]=e):e=t[14],e}let d;return t[15]!==a||t[16]!==u?(d=(0,$.jsx)(X,{name:`question`,className:a,style:u}),t[15]=a,t[16]=u,t[17]=d):d=t[17],d},Xm=e=>{if(typeof e!=`number`||Number.isNaN(e))return`—`;if(e===0)return`0`;let t=Wm(e);return t.endsWith(`.0`)?t.slice(0,-2):t},Zm=e=>typeof e!=`number`||!Number.isFinite(e)?`—`:Gm(e),Qm=e=>{let t=[];for(let n of Bm)n.isActive(e)&&t.push({key:n.key,icon:n.icon,label:n.label});return t},$m=e=>{if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?e:Km(t)},eh=({className:e,composerTextareaRef:t,mobilePanel:n,onMobilePanelChange:r,selectionAdapter:i})=>{let{t:a}=na(),o=Q.useId(),{isReady:s,isUnavailable:c}=Mu(),l=c||i?.catalog?.error?a(`common.unavailable`):a(`common.loading`),u=kr(e=>e.providerConfigLoadingByDirectory[e.activeDirectoryKey]===!0),d=kr(e=>e.agentConfigLoadingByDirectory[e.activeDirectoryKey]===!0),f=i?.catalog,p=Yc(f,{modelsReady:!u,agentsReady:!d}),m=(!!i?.requestCatalog||s&&p.modelsReady)&&!i?.disabled,h=(!!i?.requestCatalog||s&&p.agentsReady)&&!i?.disabled,_=m&&h,v=kr(e=>e.providers),y=f?.providers??v,b=kr(e=>e.currentProviderId),x=kr(e=>e.currentModelId),S=i?.selection.providerID??b,C=i?.selection.modelID??x,w=kr(e=>e.currentVariant),T=i?i.selection.variant:w,E=kr(e=>e.currentAgentName),D=i?i.selection.agent??void 0:E,O=kr(e=>e.settingsDefaultVariant),k=kr(e=>e.settingsDefaultAgent),A=kr(e=>e.setProvider),j=kr(e=>e.setSelectedProvider),M=kr(e=>e.setModel),N=kr(e=>e.setCurrentVariant),P=kr(e=>e.getCurrentModelVariants),F=kr(e=>e.setAgent),I=kr(e=>e.getCurrentProvider),L=kr(e=>e.getModelMetadata),R=kr(e=>e.getCurrentAgent),ee=kr(e=>e.getVisibleAgents),z=Am(f?.agents??ee()),B=Q.useMemo(()=>z.filter(e=>e.mode===`primary`),[z]),V=Q.useRef(!1);Q.useEffect(()=>{V.current||!_||(V.current=!0,g(`ModelControls:ready`,{providers:y.length,agents:z.length,currentProviderId:S,currentModelId:C,currentAgentName:D}))},[z.length,_,D,C,S,y.length]);let H=Xr(e=>i?null:e.currentSessionId),U=Xr(e=>e.getDirectoryForSession),te=ll(),ne=Oi(e=>e.getSessionModelSelection),re=Oi(e=>e.saveSessionModelSelection),W=Oi(e=>e.saveSessionAgentSelection),ie=Oi(e=>e.saveAgentModelForSession),ae=Oi(e=>e.getAgentModelForSession),oe=Oi(e=>e.saveAgentModelVariantForSession),se=Oi(e=>e.getAgentModelVariantForSession),ce=km(e=>e.hasHydrated),le=Oi(e=>H?e.sessionAgentSelections.get(H)??null:null),ue=Q.useRef(null);Q.useEffect(()=>{if(!H){ue.current=null;return}le&&(ue.current=le)},[H,le]);let fe=H?ue.current:null,pe=i?i.selection.agent??void 0:H&&(le||fe)||D,me=ln(e=>e.toggleFavoriteModel),he=ln(e=>e.reorderFavoriteModel),ge=ln(e=>e.providerOrder),_e=ln(e=>e.setProviderOrder),ve=ln(e=>e.isFavoriteModel),ye=ln(e=>e.addRecentModel),be=ln(e=>e.addRecentAgent),xe=ln(e=>e.addRecentEffort),Se=ln(e=>e.isModelSelectorOpen),Ce=ln(e=>e.setModelSelectorOpen),we=ln(e=>e.isAgentSelectorOpen),Te=ln(e=>e.setAgentSelectorOpen),Ee=ln(e=>e.isModelSelectorInstant),De=ln(e=>e.isAgentSelectorInstant),Oe=ln(e=>e.setSettingsDialogOpen),ke=ln(e=>e.setSettingsPage),Ae=ln(e=>e.hiddenModels),je=ln(e=>e.recentModels),Me=ln(e=>e.shortcutOverrides.cycle_agent),Ne=Q.useMemo(()=>Ho(`cycle_agent`,Me?{cycle_agent:Me}:void 0),[Me]),{favoriteModelsList:Pe,recentModelsList:Fe}=ku({currentProviderID:S,currentModelID:C}),{isMobile:Ie}=Ia(),Le=ln(e=>e.isMobile),Re=Ie||Le,ze=Bt(),Be=Re,[Ve,He]=Q.useState(null),Ue=n!==void 0&&typeof r==`function`,We=Ue?n:Ve,Ge=i?.requestCatalog;Q.useEffect(()=>{Ge?.(!!We||Se||we)},[We,Se,we,Ge]);let Ke=Ue?r:He,qe=G(e=>{Ke(e),i?.requestCatalog?i.requestCatalog(!!e):kr.getState().refreshCatalogsOnPickerOpen({source:`modelControls:mobilePanel`})}),Je=G((e,t)=>{if(jm(e,t?.reason)){t?.cancel?.();return}Te(e),i?.requestCatalog?.(e),e&&!i?.requestCatalog&&kr.getState().refreshCatalogsOnPickerOpen({source:`modelControls:desktopAgentMenu`})}),[Ye,Xe]=Q.useState(null),Ze=Q.useRef(!1),Qe=Q.useCallback(()=>Ke(null),[Ke]),$e=Q.useCallback(()=>Xe(null),[]),et=Q.useRef(void 0),tt=Se,nt=Ce,rt=Q.useCallback(()=>{j(qm),ke(`providers`),Oe(!0),nt(!1),Qe()},[j,ke,Oe,nt,Qe]),[it,at]=Q.useState(``),[ot,st]=Q.useState(null),[ct,lt]=Q.useState(!1),ut=Q.useRef(0),dt=G((e,t)=>{if(jm(e,t?.reason)){t?.cancel?.();return}lt(!1),e||(ut.current=performance.now()+200,st(null),at(``)),nt(e),i?.requestCatalog?.(e),e&&!i?.requestCatalog&&kr.getState().refreshCatalogsOnPickerOpen({source:`modelControls:desktopModelMenu`})}),ft=Q.useRef(!1),pt=Q.useRef(null),mt=Q.useRef(void 0),[ht,gt]=Q.useState(new Map),[_t,vt]=Q.useState(new Set),[yt,bt]=Q.useState(0),xt=Q.useCallback(()=>{let e=()=>{let e=ln.getState();!e.isModelSelectorOpen&&!e.isAgentSelectorOpen&&Pm(t)};window.setTimeout(()=>{requestAnimationFrame(()=>{e(),requestAnimationFrame(e)})},0)},[t]),St=Q.useCallback(e=>{let t=ln.getState();(e===`model`?t.isModelSelectorOpen:t.isAgentSelectorOpen)||(ln.setState(e===`model`?{isModelSelectorInstant:!1}:{isAgentSelectorInstant:!1}),!ln.getState().isMobile&&xt())},[xt]),Ct=Q.useCallback(()=>{let e=ln.getState();return e.isModelSelectorOpen||e.isAgentSelectorOpen?!1:Nm(t)},[t]),wt=Q.useRef(Se);Q.useEffect(()=>{let e=wt.current;wt.current=Se,Se||(st(null),at(``),ft.current=!1,pt.current=null,gt(e=>e.size?new Map:e),vt(e=>e.size?new Set:e),e&&!Be&&(lt(!1),ut.current=performance.now()+200))},[Se,Be]);let[Tt,Et]=Q.useState(``);Q.useEffect(()=>{we||Et(``)},[we]);let Dt=!!(We||Ye||ct);Q.useLayoutEffect(()=>{if(!Dt)return;let e=()=>{Ke(null),Xe(null),lt(!1)},t=cn(e);return()=>{t(),e()}},[Dt,Ke]);let Ot=Q.useMemo(()=>z.filter(e=>Hr(e.mode)),[z]),kt=Q.useMemo(()=>Tt.trim()?vn(Ot,Tt.trim(),e=>[e.name,de(e),e.description??``]).map(e=>e.item):[...Ot].sort((e,t)=>e.name.localeCompare(t.name)),[Ot,Tt]),At=Q.useMemo(()=>{if(k){let e=Ot.find(e=>e.name===k);if(e)return e.name}let e=Ot.find(e=>e.name===`build`);return e?e.name:Ot[0]?.name},[k,Ot]),jt=Q.useMemo(()=>pe?z.find(e=>e.name===pe):R?.(),[z,R,pe]),Mt=Re?`mobile`:ze?`vscode`:`default`,Nt=Mt===`mobile`?`size-5`:`size-4`,Pt=Be?`typography-micro`:`typography-meta`,Ft=Mt===`mobile`?`gap-x-0.5`:Mt===`vscode`?`gap-x-2`:`gap-x-1.5`,It=Mt===`mobile`?`h-8 w-7`:`h-6 w-6`,Lt=Mt===`mobile`?24:20,Rt=Mt===`mobile`?`pl-1 pr-0.5`:`pl-1.5 pr-0.5`,zt=um(pe),Vt=i?y.find(e=>e.id===S):I(),Ht=Array.isArray(Vt?.models)?Vt.models:[],Ut=C?Ht.find(e=>e.id===C):void 0,Wt=S&&C&&Ut?Ou(S,Ut,L(S,C)):S&&C?L(S,C):void 0,Gt=Q.useCallback(e=>e===`Tool calling`?a(`chat.modelControls.capability.toolCalling`):e===`Reasoning`?a(`chat.modelControls.capability.reasoning`):e===`Text`?a(`chat.modelControls.modality.text`):e===`Image`?a(`chat.modelControls.modality.image`):e===`Video`?a(`chat.modelControls.modality.video`):e===`Audio`?a(`chat.modelControls.modality.audio`):e===`PDF`?a(`chat.modelControls.modality.pdf`):e,[a]),Kt=Q.useMemo(()=>Qm(Wt).map(e=>({...e,label:Gt(e.label)})),[Wt,Gt]),qt=Q.useMemo(()=>Um(Wt,`input`).map(e=>({...e,label:Gt(e.label)})),[Wt,Gt]),Jt=Q.useMemo(()=>Um(Wt,`output`).map(e=>({...e,label:Gt(e.label)})),[Wt,Gt]),Yt=Q.useMemo(()=>{if(f?.variantsReady===!1)return[];if(f?.variants)return[...f.variants];if(S&&C){let e=y.find(e=>e.id===S)?.models?.find(e=>e.id===C);return Tl(e)}return i?[]:P()},[C,S,P,y,i,f?.variants,f?.variantsReady]),Xt=Yt.length>0,Zt=[{label:`Input`,value:Zm(Wt?.cost?.input)},{label:`Output`,value:Zm(Wt?.cost?.output)},{label:`Cache read`,value:Zm(Wt?.cost?.cache_read)},{label:`Cache write`,value:Zm(Wt?.cost?.cache_write)}],Qt=[{label:`Context`,value:Xm(Wt?.limit?.context)},{label:`Output`,value:Xm(Wt?.limit?.output)}],$t=Q.useRef(void 0),en=Q.useRef(null),tn=Q.useRef(null),nn=H?U(H):void 0,rn=Pi(H??``,nn??void 0).renderable,an=qr(H??``,nn??void 0),on=Q.useMemo(()=>{for(let e=an.length-1;e>=0;--e){let t=an[e];if(t.role!==`user`)continue;let n=typeof t.model?.providerID==`string`&&t.model.providerID.trim().length>0?t.model.providerID:void 0,r=typeof t.model?.modelID==`string`&&t.model.modelID.trim().length>0?t.model.modelID:void 0,i=typeof t.agent==`string`&&t.agent.trim().length>0?t.agent:typeof t.mode==`string`&&t.mode.trim().length>0?t.mode:void 0,a=t.model?.variant??t.variant,o=typeof a==`string`&&a.trim().length>0?a:void 0;return{id:t.id,agent:i,providerID:n,modelID:r,variant:o}}return null},[an]),un=Q.useCallback((e,t,n)=>{if(!e||!t)return`model-missing`;let r=y.find(t=>t.id===e);return r?(Array.isArray(r.models)?r.models:[]).find(e=>e.id===t)?S===e&&C===t?`applied`:(A(e),M(t),H&&(re(H,e,t),n&&ie(H,n,e,t)),`applied`):`model-missing`:`provider-missing`},[y,S,C,A,M,H,ie,re]),dn=Q.useCallback((e,t)=>{if(i&&i.selection.providerID===e&&i.selection.modelID===t)return Jc(i.selection,i.catalog,e,t);let n=y.find(t=>t.id===e)?.models?.find(e=>e.id===t);return Tl(n)},[y,i,i?.selection.providerID,i?.selection.modelID,f?.variants,f?.variantsReady]),fn=Q.useCallback((e,t)=>{let n=i?Jc(i.selection,i.catalog,e,t):[],r=n.length>0?n:dn(e,t);if(r.length===0)return;if(i){let n=i.selection.variant;if(i.selection.providerID===e&&i.selection.modelID===t&&n&&r.includes(n))return n}let a=pe||D;if(H&&a){let n=se(H,a,e,t);if(n&&r.includes(n))return n}if(S===e&&C===t&&T&&r.includes(T))return T;if(!H&&O&&r.includes(O))return O},[D,C,S,H,T,se,dn,i,O,pe]),pn=Q.useCallback(()=>{if(i)return i.selection.agent??void 0;let e=kr.getState().currentAgentName;return H?Oi.getState().getSessionAgentSelection(H)||ue.current||e||D:e||D},[D,H,i]),mn=Q.useCallback((e,t,n,r)=>{if(i){i.onChange({...i.selection,providerID:e,modelID:t,variant:n}).catch(()=>void 0);return}if(dn(e,t).length===0){Ze.current=!1,N(void 0);return}Ze.current=!0,N(n),xe(e,t,n);let a=r??pn();H&&a&&oe(H,a,e,t,n)},[xe,H,dn,pn,oe,i,N]),hn=Q.useCallback((e,t,n,r)=>{let a=r??pn()??void 0,o=un(e,t,a);if(o!==`applied`)return o;mn(e,t,n,a);let s=i?n:kr.getState().currentVariant;return ye(e,t,s),`applied`},[ye,mn,pn,i,un]);Q.useEffect(()=>{if(i)return;if(!H){tn.current=null;return}if(!ce||y.length===0||!rn||!on?.providerID||!on.modelID)return;let e=[H,on.id,on.agent??``,on.providerID,on.modelID,on.variant??``].join(`|`);if(tn.current===e)return;on.agent&&D!==on.agent&&F(on.agent);let t=on.variant&&dn(on.providerID,on.modelID).includes(on.variant)?on.variant:void 0;hn(on.providerID,on.modelID,t,on.agent||D||void 0)===`applied`&&(on.agent&&(W(H,on.agent),oe(H,on.agent,on.providerID,on.modelID,t)),re(H,on.providerID,on.modelID),tn.current=e)},[i,H,D,ce,y,rn,on,F,hn,dn,W,oe,re]),Q.useEffect(()=>{if(i)return;if(!H){tn.current=null;return}if(!ce||y.length===0||z.length===0)return;let e=()=>{let e=ne(H),t=H?Oi.getState().getSessionAgentSelection(H):null;if(t){D!==t&&F(t);let e=ae(H,t);if(e){let n=un(e.providerId,e.modelId,t);if(n===`applied`)return`resolved`;if(n===`provider-missing`)return`waiting`}}if(e){let n=un(e.providerId,e.modelId,t||D||void 0);if(n===`applied`)return`resolved`;if(n===`provider-missing`)return`waiting`}for(let e of z){let t=ae(H,e.name);if(!t)continue;D!==e.name&&F(e.name),Oi.getState().getSessionAgentSelection(H)||ue.current||W(H,e.name);let n=un(t.providerId,t.modelId,e.name);if(n===`applied`)return`resolved`;if(n===`provider-missing`)return`waiting`}return`continue`},t=()=>{if(z.length===0)return;let e=H?Oi.getState().getSessionAgentSelection(H)||ue.current:null,t=(H?Oi.getState().getSessionAgentSelection(H)||ue.current:null)||D;if(t&&z.some(e=>e.name===t)){D!==t&&F(t);return}let n=z.find(e=>e.name===`build`)||B[0]||z[0];n&&(e||W(H,n.name),D!==n.name&&F(n.name),n.model?.providerID&&n.model?.modelID&&un(n.model.providerID,n.model.modelID,n.name))},n=e();if(n!==`resolved`&&n!==`waiting`){if(!rn){te.isLoading(H)||te.ensureSessionRenderable(H);return}on||t()}},[i,H,rn,on,z,B,D,ne,ae,F,un,W,ce,y,te]),Q.useEffect(()=>{if(i||!ce)return;let e=new AbortController;return(async()=>{try{if(D!==$t.current&&($t.current=D,D&&H)){let t=en.current===D;if(en.current=null,await new Promise(t=>{let n=setTimeout(t,50);e.signal.addEventListener(`abort`,()=>{clearTimeout(n),t()})}),e.signal.aborted)return;let n=ae(H,D);if(n){let e=un(n.providerId,n.modelId,D);if(e===`applied`||e===`provider-missing`)return}let r=kr.getState().getAgentModelSelection(D);if(r){let e=un(r.providerId,r.modelId,D);if(e===`applied`||e===`provider-missing`){e===`applied`&&(re(H,r.providerId,r.modelId),ie(H,D,r.providerId,r.modelId),r.variant!==void 0&&(oe(H,D,r.providerId,r.modelId,r.variant),N(r.variant)));return}}let i=t?z.find(e=>e.name===D):void 0;if(i?.model?.providerID&&i.model.modelID){let e=un(i.model.providerID,i.model.modelID,D);if(e===`applied`||e===`provider-missing`){e===`applied`&&(re(H,i.model.providerID,i.model.modelID),ie(H,D,i.model.providerID,i.model.modelID));return}}}}catch(e){console.error(`[ModelControls] Agent change error:`,e)}})(),()=>{e.abort()}},[i,z,D,H,ae,ie,oe,re,N,un,ce]),Q.useEffect(()=>{if(i)return;if(!ce||!D){Ze.current=!1,N(void 0);return}if(!S||!C){Ze.current=!1,N(void 0);return}if(Yt.length===0){Ze.current=!1,N(void 0);return}if(T&&!Yt.includes(T)){N(void 0);return}if(!H){if(!T&&!Ze.current){let e=O&&Yt.includes(O)?O:void 0;N(e)}return}let e=se(H,D,S,C),t=e&&Yt.includes(e)?e:O&&Yt.includes(O)?O:void 0;N(t),Ze.current=!1},[i,Yt,ce,H,D,S,C,T,se,N,O]),Q.useEffect(()=>{Ze.current=!1},[S,C]);let gn=Q.useCallback((e,t)=>{if(i){let n=pi(i.selection,e,z,y),r=n.providerID===i.selection.providerID&&n.modelID===i.selection.modelID;Be&&Qe(),i.onChange({...n,variant:r?i.selection.variant:void 0}).then(()=>{be(e),(t?.closeModelSelector??!0)&&nt(!1)}).catch(()=>void 0);return}try{en.current=e,F(e),be(e),(t?.closeModelSelector??!0)&&nt(!1),H&&W(H,e),Be&&Qe()}catch(e){console.error(`[ModelControls] Handle agent change error:`,e)}},[be,z,Qe,H,Be,y,W,i,F,nt]),_n=Q.useCallback(e=>{let t=yi(z,D,e);t&&gn(t,{closeModelSelector:!1})},[z,D,gn]),yn=Q.useCallback(e=>{let t=Ne&&!Ne.includes(`shift`)?zo(`shift+${Ne}`):``;return t&&Vo(e,t)?-1:Vo(e,Ne)?1:null},[Ne]),bn=Q.useCallback(e=>{let t=yn(e);t&&(e.preventDefault(),e.stopPropagation(),_n(t))},[yn,_n]),xn=Q.useCallback((e,t,n,r)=>{!e||!t||!n||kr.getState().saveAgentModelSelection(e,t,n,r)},[]),Sn=(e,t,n)=>{let r=()=>{nt(!1,n?.closeInstant?{instant:!0}:void 0)};if(i){Be&&Qe();let a=n?.applyVariant?n.variant:fn(e,t);i.onChange({providerID:e,modelID:t,agent:n?.agentName??i.selection.agent,variant:a}).then(()=>{ye(e,t,a),r()}).catch(()=>void 0);return}try{let i=n?.agentName??pn()??void 0,a=n?.applyVariant?hn(e,t,n.variant,i):un(e,t,i);if(a!==`applied`){a===`provider-missing`?console.error(`[ModelControls] Provider not available for selection:`,e):a===`model-missing`&&console.error(`[ModelControls] Model not available for selection:`,{providerId:e,modelId:t});return}xn(i,e,t,n?.applyVariant?n.variant:kr.getState().currentVariant),n?.applyVariant||ye(e,t,kr.getState().currentVariant),r(),Be&&Qe()}catch(e){console.error(`[ModelControls] Handle model change error:`,e)}},Cn=(e,t)=>zi(e,t,{maxLength:40}),wn=()=>y.find(e=>e.id===S)?.name||S,Tn=()=>{if(!C)return a(`chat.modelControls.selectModel`);let e=Ht.find(e=>e.id===C);return Cn(e,C)||a(`chat.modelControls.selectModel`)},En=Tn(),Dn=()=>{if(!pe){let e=B.find(e=>e.name===`build`)||B[0];return e?On(de(e)):a(`chat.modelControls.selectAgent`)}let e=z.find(e=>e.name===pe);return On(e?de(e):pe)},On=e=>e.charAt(0).toUpperCase()+e.slice(1),kn=Q.useCallback(e=>{et.current&&clearTimeout(et.current);let t=sn();et.current=setTimeout(()=>{sn()===t&&Xe(e)},500)},[]),An=Q.useCallback(()=>{et.current&&clearTimeout(et.current)},[]);Q.useEffect(()=>()=>{et.current&&clearTimeout(et.current)},[]);let jn=()=>!Be||Ye!==`model`?null:(0,$.jsx)(xu,{open:!0,onClose:$e,title:Wt?.name||Tn(),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-0.5`,children:a(`chat.modelControls.provider`)}),(0,$.jsx)(`div`,{className:`typography-meta text-foreground font-medium`,children:wn()})]}),Kt.length>0&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-1`,children:a(`chat.modelControls.capabilities`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:Kt.map(({key:e,icon:t,label:n})=>(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Jm,{iconName:t,label:n},`cap-${e}`),(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:n})]},e))})]}),(qt.length>0||Jt.length>0)&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-1`,children:a(`chat.modelControls.modalities`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[qt.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80 w-12`,children:a(`chat.modelControls.input`)}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:qt.map(({key:e,icon:t,label:n})=>(0,$.jsx)(Jm,{iconName:t,label:`${n} input`},`input-${e}`))})]}),Jt.length>0&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80 w-12`,children:a(`chat.modelControls.output`)}),(0,$.jsx)(`div`,{className:`flex gap-1`,children:Jt.map(({key:e,icon:t,label:n})=>(0,$.jsx)(Jm,{iconName:t,label:`${n} output`},`output-${e}`))})]})]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-1`,children:a(`chat.modelControls.limits`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.context`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:Xm(Wt?.limit?.context)})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.output`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:Xm(Wt?.limit?.output)})]})]})]}),Wt?.release_date?(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-1`,children:a(`chat.modelControls.metadata`)}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.release`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:$m(Wt.release_date)})]})})]}):null]})}),Mn=()=>{if(!Be||Ye!==`agent`||!jt)return null;let e=!!(jt.prompt&&jt.prompt.trim().length>0),t=jt.model?.providerID&&jt.model?.modelID,n=jt.temperature!==void 0||jt.topP!==void 0,r=e=>{let t=Rm(jt.permission)??[],n=t.some(t=>t.permission===e&&t.pattern!==`*`),r=zm(t,e)??`ask`;return n?{mode:`ask`,label:a(`chat.modelControls.permissionLabel.custom`)}:r===`allow`?{mode:`allow`,label:a(`chat.modelControls.permissionLabel.allow`)}:r===`deny`?{mode:`deny`,label:a(`chat.modelControls.permissionLabel.deny`)}:{mode:`ask`,label:a(`chat.modelControls.permissionLabel.ask`)}},i=r(`edit`),o=r(`bash`),s=r(`webfetch`);return(0,$.jsx)(xu,{open:!0,onClose:$e,title:On(jt.name),children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[jt.description&&(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:(0,$.jsx)(`div`,{className:`typography-meta text-foreground`,children:jt.description})}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-0.5`,children:a(`chat.modelControls.mode`)}),(0,$.jsx)(`div`,{className:`typography-meta text-foreground font-medium`,children:jt.mode===`primary`?a(`chat.modelControls.modeValue.primary`):jt.mode===`subagent`?a(`chat.modelControls.modeValue.subagent`):jt.mode===`all`?a(`chat.modelControls.modeValue.all`):a(`chat.modelControls.modeValue.none`)})]}),(t||n)&&(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-1`,children:a(`chat.modelControls.model`)}),t&&(0,$.jsxs)(`div`,{className:`typography-meta text-foreground font-medium mb-1`,children:[jt.model.providerID,` / `,jt.model.modelID]}),n&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[jt.temperature!==void 0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.temperature`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:jt.temperature})]}),jt.topP!==void 0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.topP`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:jt.topP})]})]})]}),(0,$.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:[(0,$.jsx)(`div`,{className:`typography-micro text-muted-foreground mb-1`,children:a(`chat.modelControls.permissions`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.edit`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ym,{mode:i.mode,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:i.label})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.bash`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ym,{mode:o.mode,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:o.label})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.webFetch`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ym,{mode:s.mode,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:s.label})]})]})]})]}),e&&(0,$.jsx)(`div`,{className:`rounded-xl border border-border/40 bg-sidebar/30 px-2 py-1.5`,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.customPrompt`)}),(0,$.jsx)(X,{name:`checkbox-circle`,className:`size-4 text-foreground`})]})})]})})},Nn=()=>Be?(0,$.jsx)(ju,{open:We===`model`||We===`variant`,view:We===`variant`?`variant`:`model`,onViewChange:e=>Ke(e),onClose:Qe,selectedProviderID:S||``,selectedModelID:C||``,resolveSelectedVariant:fn,onSelect:(e,t,n)=>{if(i){Qe(),i.onChange({providerID:e,modelID:t,agent:i.selection.agent,variant:n}).then(()=>{ye(e,t,n)}).catch(()=>void 0);return}let r=hn(e,t,n);if(r!==`applied`){r===`provider-missing`?console.error(`[ModelControls] Provider not available for selection:`,e):r===`model-missing`&&console.error(`[ModelControls] Model not available for selection:`,{providerId:e,modelId:t});return}xn(pn(),e,t,n),Qe()},providers:y,favoriteModels:Pe,recentModels:Fe,recencyOrder:je,hiddenModels:Ae,providerOrder:ge,isFavorite:ve,onToggleFavorite:(e,t)=>me(e,t,e===S&&t===C?T:Pe.find(n=>n.providerID===e&&n.modelID===t)?.variant??Fe.find(n=>n.providerID===e&&n.modelID===t)?.variant),getMetadata:L}):null,Pn=()=>Be?(0,$.jsx)(fa,{id:`mobile-agent-picker-sheet-${o}`,open:We===`agent`,onOpenChange:e=>{e||Qe()},ariaLabel:a(`chat.modelControls.selectAgent`),closeAriaLabel:a(`mobile.surface.closeAria`),resizeAriaLabel:a(`mobile.sessions.sheet.resizeAria`),bodyClassName:`px-2`,children:(0,$.jsx)(ca,{useScrollShadow:!0,disableHorizontal:!0,preventOverscroll:!0,outerClassName:`min-h-0 flex-1`,className:`flex flex-col gap-2 overscroll-contain`,children:Ot.map(e=>{let t=e.name===pe,n=$a(e.name);return(0,$.jsx)(`button`,{type:`button`,className:J(`flex w-full flex-col gap-1.5 rounded-xl border px-3 py-2.5 text-left`,`focus:outline-none focus-visible:ring-2 focus-visible:ring-primary`,`touch-manipulation cursor-pointer transition-colors`,`active:bg-interactive-hover`,t?`border-primary/50 bg-interactive-selection/20`:`border-border/40 hover:bg-interactive-hover/50`),onClick:()=>gn(e.name),children:(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[1.125rem_minmax(0,1fr)_auto] items-start gap-x-2`,children:[(0,$.jsx)(cs,{name:e.name,size:18}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block typography-ui-label font-semibold`,style:t?{color:`var(${n.var})`}:void 0,children:On(de(e))}),e.description&&(0,$.jsx)(`span`,{className:`mt-1 block min-w-0 whitespace-normal break-words typography-micro text-muted-foreground`,children:e.description})]}),t&&(0,$.jsx)(X,{name:`check`,className:`size-4 shrink-0 text-primary`})]})},e.name)})})}):null,Fn=()=>(0,$.jsx)(ka,{align:`start`,sideOffset:8,className:`max-w-[320px]`,children:Wt?(0,$.jsxs)(`div`,{className:`flex min-w-[240px] flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold text-foreground`,children:Wt.name||Tn()}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:wn()})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.capabilities`)}),(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:Kt.length>0?Kt.map(({key:e,icon:t,label:n})=>(0,$.jsx)(Jm,{iconName:t,label:n},`cap-${e}`)):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`chat.modelControls.modeValue.none`)})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.modalities`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground/80`,children:a(`chat.modelControls.input`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:qt.length>0?qt.map(({key:e,icon:t,label:n})=>(0,$.jsx)(Jm,{iconName:t,label:`${n} input`},`input-${e}`)):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:`-`})})]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground/80`,children:a(`chat.modelControls.output`)}),(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,children:Jt.length>0?Jt.map(({key:e,icon:t,label:n})=>(0,$.jsx)(Jm,{iconName:t,label:`${n} output`},`output-${e}`)):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:`-`})})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.costPerMillion`)}),Zt.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground/80`,children:e.label}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e.value})]},e.label))]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.limits`)}),Qt.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground/80`,children:e.label}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:e.value})]},e.label))]}),Wt.release_date?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.metadata`)}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-medium text-muted-foreground/80`,children:a(`chat.modelControls.release`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:$m(Wt.release_date)})]})]}):null]}):(0,$.jsx)(`div`,{className:`min-w-[200px] typography-meta text-muted-foreground`,children:a(`chat.modelControls.metadataUnavailable`)})}),In=()=>{let e=(e,t)=>{if(ft.current=!0,e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return!1;let{providerID:n,modelID:r}=t,i=dn(n,r);if(i.length===0)return!1;e.preventDefault(),e.stopPropagation();let a=Im(n,r),o=ht.has(a),s=ht.get(a),c=o?s:S===n&&C===r?T:void 0,l=[void 0,...i],u=l.indexOf(c),d=l[((u>=0?u:0)+(e.key===`ArrowRight`?1:-1)+l.length)%l.length];return gt(e=>{let t=new Map(e);return t.set(a,d),t}),vt(e=>{let t=new Set(e);return t.add(a),t}),bt(e=>e+1),!0},t=(t,n)=>{let r=yn(t);if(r){t.preventDefault(),_n(r);return}n&&e(t,n)},n=e=>{let t=Im(e.providerID,e.modelID),n=ht.get(t),r=_t.has(t),i=pn();if(r){Sn(e.providerID,e.modelID,{applyVariant:!0,variant:n,agentName:i});return}let a=dn(e.providerID,e.modelID),o=e.variant!==void 0&&a.includes(e.variant)?e.variant:void 0;if(o!==void 0){Sn(e.providerID,e.modelID,{applyVariant:!0,variant:o,agentName:i});return}Sn(e.providerID,e.modelID,{agentName:i})},r=e=>{let t=yn(e);t&&(e.preventDefault(),e.stopPropagation(),ft.current=!0,_n(t))},i=e=>e?.trim()?oi(e):a(`chat.modelControls.default`),o=(e,t)=>{let n=pn();Sn(e.providerID,e.modelID,{applyVariant:!0,variant:t,agentName:n,closeInstant:!0})},s=e=>{e&&(tt||performance.now()<ut.current)||lt(e)},c={searchPlaceholder:a(`chat.modelControls.searchModels`),noResults:a(`chat.modelControls.noModelsFound`),favorites:a(`chat.modelControls.favorites`),recent:a(`chat.modelControls.recent`),keyboardHint:a(`chat.modelControls.keyboardHintNavigate`),all:a(`chat.modelControls.modeValue.all`),favorite:a(`chat.modelControls.favoriteAria`),unfavorite:a(`chat.modelControls.unfavoriteAria`),provider:a(`chat.modelControls.provider`),capabilities:a(`chat.modelControls.capabilities`),capabilityToolCalling:a(`chat.modelControls.capability.toolCalling`),capabilityReasoning:a(`chat.modelControls.capability.reasoning`),modalityImage:a(`chat.modelControls.modality.image`),modalityVideo:a(`chat.modelControls.modality.video`),modalityAudio:a(`chat.modelControls.modality.audio`),costPerMillion:a(`chat.modelControls.costPerMillion`),costInput:a(`chat.modelControls.costInput`),costOutput:a(`chat.modelControls.costOutput`)},u=(e,{isSelected:t})=>{let n=dn(e.providerID,e.modelID);if(n.length===0)return null;let r=Im(e.providerID,e.modelID),o=ht.has(r),s=ht.get(r),c=e.variant!==void 0&&n.includes(e.variant)?e.variant:void 0,l=o?s:t?T:c,u=_t.has(r);return(0,$.jsxs)(`button`,{type:`button`,className:J(`model-picker-thinking group/thinking flex shrink-0 items-center gap-0.5 rounded-md px-1.5 py-0.5 typography-micro font-medium transition-colors`,u||l?`text-foreground/80`:`text-muted-foreground`,`hover:bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] hover:text-foreground`),onClick:t=>{t.preventDefault(),t.stopPropagation(),st(e)},"aria-label":a(`chat.modelControls.showThinkingModes`),children:[(0,$.jsx)(X,{name:`brain-ai-3`,className:`size-3 opacity-70`}),(0,$.jsx)(`span`,{className:`max-w-20 truncate`,children:i(l)}),(0,$.jsx)(X,{name:`arrow-right-s`,className:`size-3 opacity-60 transition-transform group-hover/thinking:translate-x-px`})]})},d=()=>{if(!ot)return null;let e=dn(ot.providerID,ot.modelID),t=Im(ot.providerID,ot.modelID),n=ht.has(t),r=ht.get(t),s=ot.providerID===S&&ot.modelID===C,c=ot.variant!==void 0&&e.includes(ot.variant)?ot.variant:void 0,l=n?r:s?T:c,u=zi(ot.model,ot.modelID,{maxLength:40});return(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,onKeyDownCapture:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),st(null))},children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/40 px-1.5 py-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-interactive-hover hover:text-foreground`,onClick:()=>st(null),"aria-label":a(`header.actions.backAria`),children:(0,$.jsx)(X,{name:`arrow-left`,className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5`,children:[(0,$.jsx)(Gs,{modelId:ot.modelID,providerId:ot.providerID,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`truncate typography-meta font-medium text-foreground`,children:u}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-border`,children:`·`}),(0,$.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 typography-micro text-muted-foreground`,children:[(0,$.jsx)(X,{name:`brain-ai-3`,className:`size-3 opacity-70`}),a(`chat.modelControls.thinking`)]})]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-0.5 p-1`,role:`listbox`,"aria-label":a(`chat.modelControls.thinking`),children:[void 0,...e].map(e=>{let t=e===l||!e&&!l;return(0,$.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":t,className:J(`flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-left typography-meta transition-colors`,t?`bg-interactive-selection text-interactive-selection-foreground`:`text-foreground hover:bg-interactive-hover/50`),onClick:()=>o(ot,e),children:[(0,$.jsx)(`span`,{className:J(`truncate font-medium`,!e&&!t&&`text-muted-foreground`),children:i(e)}),t?(0,$.jsx)(X,{name:`check`,className:`size-3.5 shrink-0 text-primary`}):(0,$.jsx)(`span`,{className:`size-3.5 shrink-0`,"aria-hidden":`true`})]},e??`__default`)})}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 border-t border-border/40 px-2 py-1.5 typography-micro text-muted-foreground`,children:[(0,$.jsx)(Ha,{className:`h-4 min-w-4 rounded-[3px] px-1 text-[10px] font-medium tracking-tight shadow-none`,children:`Esc`}),(0,$.jsx)(`span`,{children:a(`header.actions.backAria`)}),(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`text-border`,children:`·`}),(0,$.jsx)(`span`,{children:a(`chat.modelControls.keyboardHintThinking`)})]})]})},f=T&&Xt?oi(T):null;return(0,$.jsxs)(Aa,{open:!tt&&ct,onOpenChange:s,delayDuration:200,children:[Be?(0,$.jsx)(`button`,{type:`button`,onClick:m?()=>qe(`model`):void 0,onTouchStart:m?()=>kn(`model`):void 0,onTouchEnd:m?An:void 0,onTouchCancel:m?An:void 0,disabled:!m,className:J(`model-controls__model-trigger min-w-0 focus:outline-none`,m?J(`cursor-pointer`,_m):`opacity-60 cursor-not-allowed`),children:m?(0,$.jsxs)($.Fragment,{children:[S||C?(0,$.jsx)(Gs,{modelId:C,providerId:S,className:J(Nt,`flex-shrink-0`)}):(0,$.jsx)(X,{name:`pencil-ai`,className:J(Nt,`text-muted-foreground`)}),(0,$.jsx)(`span`,{className:J(`model-controls__model-label typography-micro font-medium overflow-hidden min-w-0`,Re?`max-w-[120px]`:`max-w-[220px]`),children:(0,$.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:En}),f?(0,$.jsx)(`span`,{className:`shrink-0 font-normal text-muted-foreground`,children:f}):null]})})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:J(Nt,`animate-spin text-muted-foreground flex-shrink-0`)}),(0,$.jsx)(`span`,{className:`typography-micro font-medium text-muted-foreground min-w-0`,children:l})]})}):(0,$.jsxs)(Ba,{open:m&&tt,onOpenChange:m?dt:void 0,onOpenChangeComplete:e=>{e||St(`model`)},children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(La,{asChild:!0,children:(0,$.jsxs)(`div`,{className:J(`model-controls__model-trigger cursor-pointer min-w-0`,_m),children:[m?S?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Gs,{modelId:C,providerId:S,className:J(Nt,`flex-shrink-0`)}),(0,$.jsx)(X,{name:`pencil-ai`,className:J(Nt,`text-primary/60 hidden`)})]}):(0,$.jsx)(X,{name:`pencil-ai`,className:J(Nt,`text-muted-foreground`)}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:J(Nt,`animate-spin text-muted-foreground flex-shrink-0`)}),(0,$.jsx)(`span`,{className:J(`model-controls__model-label`,Pt,`font-medium whitespace-nowrap text-muted-foreground min-w-0`),children:l})]}),m&&(0,$.jsx)(`span`,{className:J(`model-controls__model-label overflow-hidden`,Pt,`font-medium whitespace-nowrap text-foreground min-w-0`,`max-w-[260px]`),children:(0,$.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`truncate`,children:En}),f?(0,$.jsx)(`span`,{className:`shrink-0 font-normal text-muted-foreground`,children:f}):null]})},`${S}-${C}-${T??``}`)]})})}),(0,$.jsx)(Ra,{className:J(`yuri-composer-picker yuri-composer-model-picker w-[min(400px,calc(100vw-2rem))] p-0 flex flex-col`,Ee&&Lm),align:`end`,alignOffset:-40,onKeyDownCapture:r,finalFocus:Ct,children:ot?d():(0,$.jsx)($.Fragment,{children:(0,$.jsx)(Tu,{providers:y,favoriteModels:Pe,recentModels:Fe,getMetadata:L,searchQuery:it,onSearchQueryChange:at,onSelect:n,labels:c,stickyHeaders:!0,virtualize:!0,stairs:!0,recencyOrder:je,selectedModel:S&&C?{providerID:S,modelID:C}:null,hiddenModels:Ae,onActiveKeyDown:t,onActiveEntryChange:e=>{mt.current=e},onVariantKey:e,isFavorite:e=>ve(e.providerID,e.modelID),onToggleFavorite:e=>me(e.providerID,e.modelID,e.providerID===S&&e.modelID===C?T:e.variant),renderRowEnd:u,renderVersion:yt,onReorderFavorite:(e,t)=>he(e.providerID,e.modelID,t.providerID,t.modelID),reorderFavoriteAriaLabel:a(`chat.modelControls.reorderFavoriteAria`),reorderFavoriteTitle:a(`chat.modelControls.reorderFavoriteTitle`),providerOrder:ge,onReorderProvider:_e,reorderProviderTitle:a(`chat.modelControls.reorderProviderTitle`),footerContent:e=>{let t=e?dn(e.providerID,e.modelID).length>0:!1;return(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsxs)(Ha,{variant:`hint`,children:[(0,$.jsx)(X,{name:`arrow-up`,className:`size-2.5`}),(0,$.jsx)(X,{name:`arrow-down`,className:`size-2.5`})]}),a(`directoryExplorerDialog.footer.navigate`)]}),(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(Ha,{variant:`hint`,children:`Tab`}),a(`chat.modelControls.keyboardHintSwitchAgentLabel`)]}),t?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsxs)(Ha,{variant:`hint`,children:[(0,$.jsx)(X,{name:`arrow-left`,className:`size-2.5`}),(0,$.jsx)(X,{name:`arrow-right`,className:`size-2.5`})]}),a(`chat.modelControls.thinking`)]}):null]}),(0,$.jsx)(Tr,{variant:`ghost`,size:`xs`,"aria-label":a(`chat.modelControls.addNewProvider`),title:a(`chat.modelControls.addNewProvider`),onClick:rt,children:(0,$.jsx)(X,{name:`add`,className:`size-3.5`})})]})},tooltipsEnabled:tt&&!ot,onEscape:()=>{if(ot){st(null);return}nt(!1)}})})})]}),Fn()]})},K=()=>{if(!jt)return(0,$.jsx)(ka,{align:`start`,sideOffset:8,className:`max-w-[320px]`,children:(0,$.jsx)(`div`,{className:`min-w-[200px] typography-meta text-muted-foreground`,children:a(`chat.modelControls.noAgentSelected`)})});let e=!!(jt.prompt&&jt.prompt.trim().length>0),t=jt.model?.providerID&&jt.model?.modelID,n=jt.temperature!==void 0||jt.topP!==void 0,r=e=>{let t=Rm(jt.permission)??[],n=t.some(t=>t.permission===e&&t.pattern!==`*`),r=zm(t,e)??`ask`;return n?{mode:`ask`,label:a(`chat.modelControls.permissionLabel.custom`)}:r===`allow`?{mode:`allow`,label:a(`chat.modelControls.permissionLabel.allow`)}:r===`deny`?{mode:`deny`,label:a(`chat.modelControls.permissionLabel.deny`)}:{mode:`ask`,label:a(`chat.modelControls.permissionLabel.ask`)}},i=r(`edit`),o=r(`bash`),s=r(`webfetch`);return(0,$.jsx)(ka,{align:`start`,sideOffset:8,className:`max-w-[280px]`,children:(0,$.jsxs)(`div`,{className:`flex min-w-[200px] flex-col gap-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,$.jsx)(`span`,{className:`typography-micro font-semibold text-foreground`,children:On(jt.name)}),jt.description&&(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:jt.description})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.mode`)}),(0,$.jsx)(`span`,{className:`typography-meta text-foreground`,children:jt.mode===`primary`?a(`chat.modelControls.modeValue.primary`):jt.mode===`subagent`?a(`chat.modelControls.modeValue.subagent`):jt.mode===`all`?a(`chat.modelControls.modeValue.all`):a(`chat.modelControls.modeValue.none`)})]}),(t||n)&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.model`)}),t?(0,$.jsxs)(`span`,{className:`typography-meta text-foreground`,children:[jt.model.providerID,` / `,jt.model.modelID]}):(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:a(`chat.modelControls.modeValue.none`)}),n&&(0,$.jsxs)(`div`,{className:`flex flex-col gap-0.5 mt-0.5`,children:[jt.temperature!==void 0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.temperature`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:jt.temperature})]}),jt.topP!==void 0&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.topP`)}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground`,children:jt.topP})]})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(`span`,{className:`typography-meta font-semibold uppercase tracking-wide text-muted-foreground/90`,children:a(`chat.modelControls.permissions`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80 w-16`,children:a(`chat.modelControls.edit`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ym,{mode:i.mode,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground w-12`,children:i.label})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80 w-16`,children:a(`chat.modelControls.bash`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ym,{mode:o.mode,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground w-12`,children:o.label})]})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80 w-16`,children:a(`chat.modelControls.webFetch`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(Ym,{mode:s.mode,className:`size-3.5`}),(0,$.jsx)(`span`,{className:`typography-meta font-medium text-foreground w-12`,children:s.label})]})]})]}),e&&(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground/80`,children:a(`chat.modelControls.customPrompt`)}),(0,$.jsx)(X,{name:`checkbox-circle`,className:`size-4 text-foreground`})]})]})})},Ln=()=>{let e=Dn(),t=pe?$a(pe):null;return Be?(0,$.jsx)(`button`,{type:`button`,onClick:h?()=>qe(`agent`):void 0,onTouchStart:h?()=>kn(`agent`):void 0,onTouchEnd:h?An:void 0,onTouchCancel:h?An:void 0,disabled:!h,className:J(`model-controls__agent-trigger inline-flex items-center flex-shrink-0 min-w-0 focus:outline-none`,vm,h?`cursor-pointer`:`opacity-60 cursor-not-allowed`),children:h?(0,$.jsx)(lm,{name:pe,label:e,revealed:zt,avatarSize:Lt,slotClassName:It,labelGapClassName:Rt,colorVar:t?.var}):(0,$.jsx)(`span`,{className:J(`inline-flex items-center justify-center`,It),children:(0,$.jsx)(X,{name:`loader-4`,className:J(Nt,`flex-shrink-0 animate-spin text-muted-foreground`)})})}):(0,$.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,$.jsxs)(Aa,{delayDuration:600,children:[(0,$.jsxs)(Ba,{open:h&&we,onOpenChange:h?Je:void 0,onOpenChangeComplete:e=>{e||St(`agent`)},children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(La,{asChild:!0,children:(0,$.jsx)(`div`,{className:J(`inline-flex cursor-pointer items-center flex-shrink-0 min-w-0`,vm),children:h?(0,$.jsx)(lm,{name:pe,label:e,revealed:zt,avatarSize:Lt,slotClassName:It,labelGapClassName:Rt,colorVar:t?.var}):(0,$.jsx)(`span`,{className:J(`inline-flex items-center justify-center`,It),children:(0,$.jsx)(X,{name:`loader-4`,className:J(Nt,`flex-shrink-0 animate-spin text-muted-foreground`)})})})})}),(0,$.jsxs)(Ra,{align:`end`,alignOffset:-40,className:J(`yuri-composer-picker yuri-composer-agent-picker w-[min(320px,calc(100vw-2rem))] p-0 flex flex-col`,De&&Lm),onKeyDownCapture:bn,finalFocus:Ct,children:[(0,$.jsx)(`div`,{className:`model-picker-search-area p-1.5 pb-1`,children:(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-3.5 text-muted-foreground`}),(0,$.jsx)(Do,{type:`text`,placeholder:a(`chat.modelControls.searchAgents`),value:Tt,onChange:e=>Et(e.target.value),onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),Te(!1);return}e.stopPropagation()},className:`model-picker-search pl-8 h-8 typography-meta`})]})}),(0,$.jsx)(ca,{outerClassName:`max-h-[min(400px,calc(100dvh-12rem))] flex-1`,children:(0,$.jsx)(`div`,{className:`composer-agent-list`,children:kt.length===0?(0,$.jsx)(`div`,{className:`px-2 py-4 text-center typography-meta text-muted-foreground`,children:a(`chat.agentMentionAutocomplete.empty`)}):kt.map(e=>(0,$.jsx)(za,{className:`composer-agent-row typography-meta`,onSelect:()=>gn(e.name),children:(0,$.jsxs)(`div`,{className:`flex w-full min-w-0 items-start gap-2.5`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,$.jsx)(cs,{name:e.name,size:20})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`composer-agent-name block truncate font-medium`,children:On(de(e))}),e.description&&(0,$.jsx)(`span`,{className:`composer-agent-description mt-1 block text-muted-foreground break-words`,title:e.description,children:e.description})]}),(0,$.jsx)(`span`,{className:`mt-0.5 size-4 shrink-0`,children:e.name===pe?(0,$.jsx)(X,{name:`check`,className:`size-4 text-primary`}):null})]})},e.name))})}),!Tt.trim()&&At&&(0,$.jsx)(`div`,{className:`composer-picker-actions`,children:(0,$.jsxs)(za,{onSelect:()=>gn(At),children:[(0,$.jsx)(X,{name:`arrow-go-back`,className:`size-3.5`}),(0,$.jsx)(`span`,{children:a(`chat.modelControls.resetToDefault`)})]})}),(0,$.jsxs)(`div`,{className:`composer-picker-footer flex items-center gap-1.5 text-muted-foreground`,children:[(0,$.jsx)(Ha,{variant:`hint`,children:`Tab`}),(0,$.jsx)(`span`,{children:a(`chat.modelControls.keyboardHintSwitchAgentLabel`)})]})]})]}),K()]})})},Rn=J(`@container/model-controls flex items-center min-w-0`,Re&&`w-full`,e),zn=Ln();return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:Rn,children:(0,$.jsxs)(`div`,{className:J(`flex items-center min-w-0 flex-1 justify-end`,Ft,Re&&`overflow-hidden`),children:[zn,In()]})}),Nn(),Pn(),jn(),Mn()]})},th=[{key:`M`,labelKey:`chat.leaderKey.action.model`},{key:`A`,labelKey:`chat.leaderKey.action.agent`},{key:`N`,labelKey:`chat.leaderKey.action.newSession`},{key:`C`,labelKey:`chat.leaderKey.action.compact`}],nh=e=>{let t=(0,Z.c)(16),{className:n}=e,{t:r}=na(),i=rl(rh),a=ln(ih),o;t[0]===a?o=t[1]:(o=Bo(Ho(`leader_key`,a)||`ctrl+x`),t[0]=a,t[1]=o);let s=o;if(!i)return null;let c;t[2]===r?c=t[3]:(c=r(`chat.leaderKey.pendingAria`),t[2]=r,t[3]=c);let l;t[4]===n?l=t[5]:(l=J(`pointer-events-none absolute left-1/2 top-0 z-20 -translate-x-1/2 -translate-y-[calc(100%+0.4rem)]`,`inline-flex max-w-[calc(100cqw-1rem)] items-center gap-2 overflow-x-auto rounded-lg border px-2.5 py-1.5`,`border-[var(--interactive-border)] bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)]`,`shadow-sm animate-in fade-in-0 zoom-in-95 duration-150 whitespace-nowrap`,n),t[4]=n,t[5]=l);let u;t[6]===s?u=t[7]:(u=(0,$.jsx)(Va,{shortcut:s,className:`opacity-[0.35] [&_[data-slot=kbd]]:rounded-md [&_[data-slot=kbd]]:border-0 [&_[data-slot=kbd]]:bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] [&_[data-slot=kbd]]:text-muted-foreground/65 [&_[data-slot=kbd]]:shadow-none`}),t[6]=s,t[7]=u);let d;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(`span`,{className:`typography-micro text-[var(--surface-muted-foreground)]`,children:`·`}),t[8]=d):d=t[8];let f;t[9]===r?f=t[10]:(f=th.map((e,t)=>(0,$.jsxs)(Q.Fragment,{children:[t>0?(0,$.jsx)(`span`,{className:`typography-micro text-[var(--surface-muted-foreground)]`,children:`·`}):null,(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 typography-micro`,children:[(0,$.jsx)(Ha,{className:`rounded-md border-0 bg-[color-mix(in_srgb,var(--surface-foreground)_6%,transparent)] text-muted-foreground/65 shadow-none`,children:e.key}),(0,$.jsx)(`span`,{className:`text-[var(--surface-muted-foreground)]`,children:r(e.labelKey)})]})]},e.key)),t[9]=r,t[10]=f);let p;return t[11]!==c||t[12]!==l||t[13]!==u||t[14]!==f?(p=(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":c,className:l,children:[u,d,f]}),t[11]=c,t[12]=l,t[13]=u,t[14]=f,t[15]=p):p=t[15],p};function rh(e){return e.pending}function ih(e){return e.shortcutOverrides}var ah=new Set([`edit`,`multiedit`,`write`,`apply_patch`,`create`,`file_write`]),oh=e=>`insertions`in e,sh=e=>{if(typeof e==`number`&&Number.isFinite(e))return Math.max(0,Math.trunc(e))},ch=e=>{let t=0,n=0;for(let r of e.split(`
12
- `))r.startsWith(`+`)&&!r.startsWith(`+++`)&&t++,r.startsWith(`-`)&&!r.startsWith(`---`)&&n++;return{added:t,removed:n}},lh=e=>{let t=[],n=new Set;for(let r of e){if(r.type!==`tool`||!ah.has(r.tool))continue;let e=r.state;if(e.status&&e.status!==`completed`)continue;let i=t.length,a=e.metadata,o=Array.isArray(a?.files)?a.files:[];for(let e of o){if(!e||typeof e!=`object`)continue;let i=e,a=i.relativePath||i.filePath||``;!a||n.has(a)||(n.add(a),t.push({path:a,tool:r.tool,partId:r.id,messageID:r.messageID,additions:sh(i.additions)??void 0,deletions:sh(i.deletions)??void 0,patch:typeof i.patch==`string`?i.patch:void 0}))}if(o.length===0&&a?.filediff&&typeof a.filediff==`object`){let e=a.filediff,i=typeof e.file==`string`?e.file:``;i&&!n.has(i)&&(n.add(i),t.push({path:i,tool:r.tool,partId:r.id,messageID:r.messageID,additions:sh(e.additions)??void 0,deletions:sh(e.deletions)??void 0,patch:typeof e.patch==`string`?e.patch:void 0}))}if(o.length===0&&Array.isArray(a?.results))for(let e of a.results){if(!e||typeof e!=`object`)continue;let i=e.filediff;if(!i||typeof i!=`object`)continue;let a=typeof i.file==`string`?i.file:``;!a||n.has(a)||(n.add(a),t.push({path:a,tool:r.tool,partId:r.id,messageID:r.messageID,additions:sh(i.additions)??void 0,deletions:sh(i.deletions)??void 0,patch:typeof i.patch==`string`?i.patch:void 0}))}if(t.length===i){let i=e.input,a=typeof i?.filePath==`string`?i.filePath:typeof i?.file_path==`string`?i.file_path:typeof i?.path==`string`?i.path:void 0;a&&!n.has(a)&&(n.add(a),t.push({path:a,tool:r.tool,partId:r.id,messageID:r.messageID}))}if(t.length===i){let e=typeof a?.patch==`string`?a.patch.trim():typeof a?.diff==`string`?a.diff.trim():``;if(e&&!n.has(`Diff`)){n.add(`Diff`);let i=ch(e);t.push({path:`Diff`,tool:r.tool,partId:r.id,messageID:r.messageID,additions:i.added,deletions:i.removed})}}}return t},uh=(e,t,n)=>{let r=[];for(let i of e){let e=i.index?.trim()??``,a=i.working_dir?.trim()??``,o=!!(e&&e!==`?`),s=!!(a||e===`?`),c=a||e;if(!c||c===`!`)continue;let l=t?.[i.path];r.push({path:Jt(n,i.path),relativePath:i.path,insertions:l?.insertions??0,deletions:l?.deletions??0,status:c,hasStagedChanges:o,hasWorkingChanges:s})}return r},dh=(e,t)=>{let n=0,r=0,i=0;for(let a of e){let e=a.index?.trim()??``,o=(a.working_dir?.trim()??``)||e;if(!o||o===`!`)continue;n+=1;let s=t?.[a.path];s&&(r+=s.insertions,i+=s.deletions)}return{count:n,insertions:r,deletions:i}},fh=e=>{for(let t of e){let e=t.index?.trim()??``,n=(t.working_dir?.trim()??``)||e;if(!(!n||n===`!`))return!0}return!1},ph=(e,t)=>qt(e,t),mh=(e,t)=>{let n=oh(e)&&e.relativePath?e.relativePath:ph(e.path,t);return{fileName:n.split(`/`).pop()??n,dirPart:n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):``}},hh=e=>oh(e)?{additions:e.insertions,deletions:e.deletions}:{additions:e.additions??0,deletions:e.deletions??0},gh=`yuri-mobile-overlay-surface yuri-popup-surface`,_h=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl ${gh}`,vh={maxWidth:`min(28rem, calc(100cqw - 4ch))`,color:`var(--surface-elevated-foreground)`},yh={...vh,width:`100%`,minWidth:0,maxWidth:`100%`},bh=`flex items-center justify-between gap-3 border-b-[length:var(--yuri-popup-divider-width)] border-[var(--yuri-popup-divider)] px-3 py-2.5`,xh=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,Sh=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,Ch=`m-0 list-none p-0`,wh=`${Ch} divide-y-[length:var(--yuri-popup-divider-width)] divide-[var(--yuri-popup-divider)] max-h-[min(22rem,50vh)] overflow-y-auto`,Th=`${Ch} divide-y divide-[var(--surface-subtle)] w-full`,Eh={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},Dh=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,Oh=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,kh=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,Ah=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,jh=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,Mh=200,Nh=32,Ph=352,Fh=e=>{let t=(0,Z.c)(26),{file:n,currentDirectory:r,onOpenFile:i}=e,{t:a}=na(),o;t[0]!==r||t[1]!==n?(o=mh(n,r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let{fileName:s,dirPart:c}=o,l;t[3]===n?l=t[4]:(l=hh(n),t[3]=n,t[4]=l);let u=l,d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=J(`relative flex w-full cursor-pointer items-center gap-2.5 outline-hidden select-none text-left hover:bg-interactive-hover`,Dh),t[5]=d):d=t[5];let f;t[6]!==n.path||t[7]!==a?(f=a(`chat.changedFiles.actions.openFileTitle`,{path:n.path}),t[6]=n.path,t[7]=a,t[8]=f):f=t[8];let p;t[9]!==n||t[10]!==i?(p=()=>i(n),t[9]=n,t[10]=i,t[11]=p):p=t[11];let m;t[12]===n.path?m=t[13]:(m=(0,$.jsx)(ja,{filePath:n.path,className:`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`}),t[12]=n.path,t[13]=m);let h=c?`${c}/${s}`:s,g;t[14]!==n.path||t[15]!==h?(g=(0,$.jsx)(Fa,{path:h,title:n.path,className:`min-w-0 flex-1`}),t[14]=n.path,t[15]=h,t[16]=g):g=t[16];let _;t[17]!==u.additions||t[18]!==u.deletions?(_=u.additions>0||u.deletions>0?(0,$.jsxs)(`span`,{className:`flex-shrink-0 inline-flex items-baseline gap-1 text-xs tabular-nums leading-4 md:text-[0.8125rem] md:leading-5`,children:[u.additions>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,u.additions]}):null,u.deletions>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,u.deletions]}):null]}):null,t[17]=u.additions,t[18]=u.deletions,t[19]=_):_=t[19];let v;return t[20]!==f||t[21]!==p||t[22]!==m||t[23]!==g||t[24]!==_?(v=(0,$.jsxs)(`button`,{type:`button`,className:d,title:f,onClick:p,children:[m,g,_]}),t[20]=f,t[21]=p,t[22]=m,t[23]=g,t[24]=_,t[25]=v):v=t[25],v},Ih=({files:e,currentDirectory:t,onOpenFile:n})=>{let r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(Nh),s=Q.useMemo(()=>t=>e[t]?.path??t,[e]),c=ya({count:e.length,getScrollElement:()=>r.current,estimateSize:()=>a,initialRect:{width:0,height:Ph},overscan:8,getItemKey:s});Q.useLayoutEffect(()=>{let e=i.current?.offsetHeight??0;e>0&&e!==a&&o(e)},[a]),Q.useLayoutEffect(()=>{c.measure()},[a,c]);let l=c.getVirtualItems(),u=l[0]?.index;return(0,$.jsx)(`div`,{ref:r,className:wh,children:(0,$.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(r=>{let a=e[r.index];return a?(0,$.jsx)(`div`,{"data-index":r.index,ref:r.index===u?i:void 0,className:J(r.index>0&&`shadow-[inset_0_var(--yuri-popup-divider-width)_0_0_var(--yuri-popup-divider)]`),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${r.start}px)`},children:(0,$.jsx)(Fh,{file:a,currentDirectory:t,onOpenFile:n})},r.key):null})})})},Lh=e=>{let t=(0,Z.c)(16),{files:n,currentDirectory:r,onOpenFile:i}=e,{t:a}=na(),o;t[0]===a?o=t[1]:(o=a(`chat.changedFiles.title`),t[0]=a,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`span`,{className:xh,children:o}),t[2]=o,t[3]=s);let c;t[4]===n.length?c=t[5]:(c=(0,$.jsx)(`span`,{className:Sh,children:n.length}),t[4]=n.length,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:bh,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n||t[11]!==i?(u=n.length>Mh?(0,$.jsx)(Ih,{files:n,currentDirectory:r,onOpenFile:i}):(0,$.jsx)(`div`,{className:wh,children:n.map((e,t)=>(0,$.jsx)(Fh,{file:e,currentDirectory:r,onOpenFile:i},`${e.path}:${t}`))}),t[9]=r,t[10]=n,t[11]=i,t[12]=u):u=t[12];let d;return t[13]!==l||t[14]!==u?(d=(0,$.jsxs)($.Fragment,{children:[l,u]}),t[13]=l,t[14]=u,t[15]=d):d=t[15],d},Rh=`${_h} origin-[var(--transform-origin)]`,zh=vh,Bh=Q.memo(e=>{let t=(0,Z.c)(66),{isExpanded:n,onExpandedChange:r}=e,{t:i}=na(),a=ln(Vh),o=Ga()??null,s=Q.useContext(Wt),c=Rt(),l=c?.entry.location.hostId?c.entry:void 0;s?.git;let u;t[0]!==l||t[1]!==s?.git?(u=l?Ir(l):s?.git,t[0]=l,t[1]=s?.git,t[2]=u):u=t[2];let d=u,f=Qa(o),p;t[3]===o?p=t[4]:(p=e=>o?e.directories.get(o)?.status??null:null,t[3]=o,t[4]=p);let m=Za(p),h=Za(Hh),g=ga(),_=!!(o&&f===!0&&m&&!m.isClean),v;bb0:{if(!_||!m){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e={count:0,insertions:0,deletions:0},t[5]=e):e=t[5],v=e;break bb0}let e;t[6]!==m.diffStats||t[7]!==m.files?(e=dh(m.files,m.diffStats),t[6]=m.diffStats,t[7]=m.files,t[8]=e):e=t[8],v=e}let y=v,b;bb1:{if(!n||!_||!m||!o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],b=e;break bb1}let e;t[10]!==o||t[11]!==m.diffStats||t[12]!==m.files?(e=uh(m.files,m.diffStats,o),t[10]=o,t[11]=m.diffStats,t[12]=m.files,t[13]=e):e=t[13],b=e}let x=b,S=y.insertions,C=y.deletions;if(!o||f!==!0||y.count===0)return null;let w;t[14]!==o||t[15]!==l||t[16]!==g||t[17]!==r||t[18]!==s?.editor?(w=e=>{if(!o||!oh(e))return;r(!1);let t=e.path;if(g){g.openChanges({diffPath:e.relativePath,staged:e.hasStagedChanges&&!e.hasWorkingChanges});return}let n=s?.editor;if(!l&&n){n.openFile(t);return}let i=ln.getState(),a=e.hasStagedChanges&&!e.hasWorkingChanges;if(!i.isMobile){i.openContextDiff(l?.key??o,e.relativePath,a);return}i.navigateToDiff(e.relativePath,a),i.setRightSidebarOpen(!1)},t[14]=o,t[15]=l,t[16]=g,t[17]=r,t[18]=s?.editor,t[19]=w):w=t[19];let T=w,E=y.count,D;t[20]!==E||t[21]!==i?(D=i(E===1?`chat.pendingChanges.fileCountSingle`:`chat.pendingChanges.fileCountPlural`,{count:E}),t[20]=E,t[21]=i,t[22]=D):D=t[22];let O=D,k;t[23]!==o||t[24]!==h||t[25]!==n||t[26]!==r||t[27]!==d?(k=()=>{let e=!n;r(e),!(!e||!o||!d)&&h(o,d,{silent:!0})},t[23]=o,t[24]=h,t[25]=n,t[26]=r,t[27]=d,t[28]=k):k=t[28];let A=k,j=a?`contents`:`relative`,M;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=J(Oh,`yuri-pending-changes-trigger max-w-full text-left`),t[29]=M):M=t[29];let N,P;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(X,{name:`file-edit`,className:jh}),P=J(kh,`shrink-0`),t[30]=N,t[31]=P):(N=t[30],P=t[31]);let F;t[32]===O?F=t[33]:(F=(0,$.jsx)(`span`,{className:P,children:O}),t[32]=O,t[33]=F);let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=J(`status-row__changed-label`,kh),t[34]=I):I=t[34];let L;t[35]===i?L=t[36]:(L=i(`chat.pendingChanges.changedInWorkspace`),t[35]=i,t[36]=L);let R;t[37]===L?R=t[38]:(R=(0,$.jsx)(`span`,{className:I,children:L}),t[37]=L,t[38]=R);let ee;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ee=J(Ah,`items-baseline gap-0.5`),t[39]=ee):ee=t[39];let z;t[40]===S?z=t[41]:(z=S>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,S]}):null,t[40]=S,t[41]=z);let B;t[42]===C?B=t[43]:(B=C>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,C]}):null,t[42]=C,t[43]=B);let V;t[44]!==z||t[45]!==B?(V=(0,$.jsxs)(`span`,{className:ee,children:[z,B]}),t[44]=z,t[45]=B,t[46]=V):V=t[46];let H;t[47]===n?H=t[48]:(H=n?(0,$.jsx)(X,{name:`arrow-up-s`,className:jh}):(0,$.jsx)(X,{name:`arrow-down-s`,className:jh}),t[47]=n,t[48]=H);let U;t[49]!==A||t[50]!==n||t[51]!==F||t[52]!==R||t[53]!==V||t[54]!==H?(U=(0,$.jsxs)(`button`,{type:`button`,className:M,onClick:A,"aria-expanded":n,children:[N,F,R,V,H]}),t[49]=A,t[50]=n,t[51]=F,t[52]=R,t[53]=V,t[54]=H,t[55]=U):U=t[55];let te;t[56]!==o||t[57]!==x||t[58]!==T||t[59]!==n||t[60]!==a?(te=n&&(0,$.jsx)(`div`,{style:a?yh:zh,className:J(Rh,`absolute left-0 bottom-full mb-1 z-50`,`animate-in fade-in-0 zoom-in-95 slide-in-from-bottom-2`,`duration-150`),children:(0,$.jsx)(Lh,{files:x,currentDirectory:o,onOpenFile:T})}),t[56]=o,t[57]=x,t[58]=T,t[59]=n,t[60]=a,t[61]=te):te=t[61];let ne;return t[62]!==U||t[63]!==te||t[64]!==j?(ne=(0,$.jsxs)(`div`,{className:j,children:[U,te]}),t[62]=U,t[63]=te,t[64]=j,t[65]=ne):ne=t[65],ne});Bh.displayName=`PendingChangesBar`;function Vh(e){return e.isMobile}function Hh(e){return e.fetchStatus}function Uh(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${t%60?`${t%60}s`:``}`:`${Math.floor(n/60)}h${n%60?`${n%60}m`:``}`}var Wh=28,Gh=8,Kh=10.5,qh=Math.PI/2,Jh=e=>Array.from({length:Gh},(t,n)=>{let r=n/Gh*Math.PI*2-Math.PI/2+e;return[Math.cos(r)*Kh,Math.sin(r)*Kh]}),Yh=[Jh(0),Jh(qh),Jh(Math.PI),Jh(Math.PI*1.5)],Xh=([e,t])=>`${e.toFixed(1)}px, ${t.toFixed(1)}px`,Zh=e=>{let t=(0,Z.c)(9),{size:n,isMobile:r,className:i}=e,a=n??(r!==void 0&&r?12:14),o;t[0]===i?o=t[1]:(o=J(`yuri-morph-orb-glyph shrink-0`,i),t[0]=i,t[1]=o);let s=a/Wh,c;t[2]!==a||t[3]!==s?(c={width:a,height:a,"--orb-k":s},t[2]=a,t[3]=s,t[4]=c):c=t[4];let l=c,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{className:`yuri-morph-orb-stage`,children:Yh[0].map(Qh)}),t[5]=u):u=t[5];let d;return t[6]!==o||t[7]!==l?(d=(0,$.jsx)(`span`,{className:o,style:l,"aria-hidden":`true`,children:u}),t[6]=o,t[7]=l,t[8]=d):d=t[8],d};function Qh(e,t){return(0,$.jsx)(`span`,{className:`yuri-morph-orb-dot`,style:{"--m-1":Xh(Yh[0][t]),"--m-2":Xh(Yh[1][t]),"--m-3":Xh(Yh[2][t]),"--m-4":Xh(Yh[3][t])}},t)}var $h=1200,eg=600;function tg({text:e,elapsed:t,reducedMotion:n}){let r=Q.useRef(null),i=Q.useRef(null),a=Q.useRef(e),o=Q.useRef(e),s=Q.useRef(null);return Q.useLayoutEffect(()=>{let t=r.current,a=i.current;if(!t||!a)return;if(o.current=e,n){s.current?.cancel(),s.current=null,a.textContent=e,t.style.opacity=`1`;return}let c=()=>{if(s.current||a.textContent===o.current)return;let e=pa(t,{opacity:[1,0]},{duration:.25,ease:`easeIn`});s.current=e,e.then(()=>{if(s.current!==e)return;a.textContent=o.current;let n=pa(t,{opacity:[0,1]},{duration:.35,ease:`easeOut`});s.current=n,n.then(()=>{s.current===n&&(s.current=null,c())})})};c()},[e,n]),Q.useLayoutEffect(()=>()=>{s.current?.cancel(),s.current=null},[]),(0,$.jsxs)(`span`,{ref:r,className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{ref:i,className:`animate-text-shimmer min-w-0 truncate whitespace-nowrap`,children:a.current}),t?(0,$.jsx)(`span`,{className:`typography-meta shrink-0 font-light text-muted-foreground/70 tabular-nums`,"aria-hidden":`true`,children:t.replace(/m(?=\d)/u,`m `)}):null]})}function ng({isWorking:e,isMobile:t,statusText:n,isGenericStatus:r,isWaitingForPermission:i,retryInfo:a,turnStartedAt:o,isTurnSettled:s=!1}){let{locale:c,t:l}=na(),u=ha(),[d,f]=Q.useState(null),[p,m]=Q.useState(!1),h=Q.useRef(d),g=Q.useRef(p),_=Q.useRef(!1);h.current=d,g.current=p;let v=Q.useRef(0),y=Q.useRef(null),b=Q.useRef(null),x=Q.useRef(null),[S,C]=Q.useState(null),[w,T]=Q.useState(()=>Date.now());Q.useEffect(()=>{if(!e||typeof o!=`number`||a)return;T(Date.now());let t=window.setInterval(()=>T(Date.now()),1e3);return()=>window.clearInterval(t)},[e,o,a]),Q.useEffect(()=>{let e=a?.next;if(!e||e<=0){C(null);return}let t=e,n=()=>{let e=Math.max(0,t-Date.now());C(Math.ceil(e/1e3))};n();let r=setInterval(n,500);return()=>clearInterval(r)},[a?.next,a?.attempt]);let E=G(()=>{b.current&&=(clearTimeout(b.current),null),x.current&&=(clearTimeout(x.current),null)}),D=G((e,t,n=!1)=>{E(),y.current=null,f(e),m(t),_.current=n,v.current=Date.now()}),O=G(()=>{if(b.current)return;let e=Date.now()-v.current,t=Math.max(0,$h-e);b.current=setTimeout(()=>{b.current=null;let e=y.current;e&&D(e.text,e.permission,e.generic)},t)});if(Q.useEffect(()=>{if(s){E(),y.current=null,h.current&&(f(null),m(!1),_.current=!1);return}if(!e){if(b.current&&=(clearTimeout(b.current),null),y.current=null,!h.current||x.current)return;x.current=setTimeout(()=>{x.current=null,f(null),m(!1),_.current=!1},eg);return}if(x.current&&=(clearTimeout(x.current),null),a){E(),y.current=null;return}let t=i?l(`chat.assistantStatus.waitingForPermission`):n,o=!!i,c=!!r&&!o;if(t){if(!h.current){D(t,o,c);return}if((t!==h.current||o!==g.current)&&!(c&&_.current)){if(c){y.current={text:t,permission:o,generic:c},O();return}D(t,o,c)}}},[e,s,n,r,i,a,l]),Q.useEffect(()=>()=>E(),[]),s||!e&&!d)return null;if(a&&e){let e=S!==null&&S>0?new Intl.RelativeTimeFormat(c,{numeric:`always`,style:`short`}).format(S,`second`):null,n=e?a.attempt&&a.attempt>0?l(`chat.assistantStatus.retryingInAttempt`,{duration:e,attempt:a.attempt}):l(`chat.assistantStatus.retryingIn`,{duration:e}):a.attempt&&a.attempt>0?l(`chat.assistantStatus.retryingAttempt`,{attempt:a.attempt}):l(`chat.assistantStatus.retrying`),r=a.message?`${n} · ${a.message}`:n;return(0,$.jsx)(`div`,{className:`flex h-full items-center text-muted-foreground`,role:`status`,"aria-live":`polite`,"aria-label":r,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 ${t?`typography-meta !text-[length:var(--text-meta)]`:`typography-ui-header`}`,children:[(0,$.jsx)(`span`,{className:`inline-flex flex-none items-center justify-center ${t?`h-5 w-4`:`h-6 w-3.5`}`,children:(0,$.jsx)(Zh,{isMobile:t})}),(0,$.jsx)(`span`,{className:`animate-text-shimmer min-w-0 whitespace-normal break-words`,children:r})]})})}if(!d)return null;let k=d,A=typeof o==`number`&&e?Uh(Math.max(0,w-o)):null;return(0,$.jsx)(`div`,{className:`flex h-full w-full min-w-0 items-center text-muted-foreground`,role:`status`,"aria-live":p?`assertive`:`polite`,"aria-label":k,"data-waiting":p?`true`:void 0,children:(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 ${t?`typography-meta !text-[length:var(--text-meta)]`:`typography-ui-header`}`,children:[(0,$.jsx)(`span`,{className:`inline-flex flex-none items-center justify-center ${t?`h-5 w-4`:`h-6 w-3.5`}`,children:(0,$.jsx)(Zh,{isMobile:t})}),(0,$.jsx)(tg,{text:k,elapsed:A,reducedMotion:u})]})})}var rg={containerType:`inline-size`,containerName:`status-row`},ig=[],ag=e=>{let t=(0,Z.c)(113),{isWorking:n,statusText:r,isGenericStatus:i,isWaitingForPermission:a,wasAborted:o,abortActive:s,retryInfo:c,turnStartedAt:l,isTurnSettled:u,showAbortStatus:f,showAbortPrompt:p,showAssistantStatus:m,showTodos:h,agentName:g,showPendingChanges:_,insideInputColumn:v,className:y}=e,b=n!==void 0&&n,x=r===void 0?null:r,S=u!==void 0&&u,C=p!==void 0&&p,w=m===void 0||m,T=h===void 0||h,E=_!==void 0&&_,D=v!==void 0&&v,{t:O}=na(),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k={todos:!1,changes:!1},t[0]=k):k=t[0];let[A,j]=Q.useState(k),M=A.todos,N=Xo(),P=Xr(og),F=N.sessionId??P,I;t[1]!==F||t[2]!==T?(I=e=>!T||!F?ig:e.todo[F]??ig,t[1]=F,t[2]=T,t[3]=I):I=t[3];let L=br(I,N.directory??void 0),R;t[4]!==F||t[5]!==T?(R=e=>T&&F?e.sessions[F]?.todos:void 0,t[4]=F,t[5]=T,t[6]=R):R=t[6];let ee=ni(R),z=Si(T&&F?F:``,N.directory??void 0),B;bb0:{if(!F){B=ig;break bb0}if(z){B=z;break bb0}if(L.length>0){B=L;break bb0}B=ee??ig}let V=B,H=ln(sg),U;t[7]===H?U=t[8]:(U=H||d(),t[7]=H,t[8]=U);let te=U,ne=A.changes&&(!H||!M),re;t[9]===V?re=t[10]:(re=V.filter(cg),t[9]=V,t[10]=re);let W=re,ie;t[11]===W?ie=t[12]:(ie=W.find(lg)||W.find(ug)||null,t[11]=W,t[12]=ie);let ae=ie,oe;t[13]===V?oe=t[14]:(oe=V.filter(dg),t[13]=V,t[14]=oe);let se=oe.length,ce;t[15]===V?ce=t[16]:(ce=V.filter(fg),t[15]=V,t[16]=ce);let le=ce.length,ue;t[17]!==le||t[18]!==se?(ue={completed:le,total:se},t[17]=le,t[18]=se,t[19]=ue):ue=t[19];let de=ue,fe;t[20]===W?fe=t[21]:(fe=W.filter(pg),t[20]=W,t[21]=fe);let pe=fe.length,me;t[22]===W?me=t[23]:(me=W.filter(mg),t[22]=W,t[23]=me);let he=me.length,ge;t[24]!==pe||t[25]!==he?(ge={active:pe,left:he},t[24]=pe,t[25]=he,t[26]=ge):ge=t[26];let _e=ge,ve=T&&_e.left>0,ye=!!C,[be,xe]=Q.useState(!1),Se,Ce;t[27]!==be||t[28]!==S||t[29]!==b?(Se=()=>{if(S){xe(!1);return}if(b){xe(!0);return}if(!be)return;let e=window.setTimeout(()=>xe(!1),600);return()=>window.clearTimeout(e)},Ce=[b,be,S],t[27]=be,t[28]=S,t[29]=b,t[30]=Se,t[31]=Ce):(Se=t[30],Ce=t[31]),Q.useEffect(Se,Ce);let we=w&&(!S&&(b||be)||!!o||!!f),Te=E||D,Ee=!f&&!ye&&(o||!s),De=ye||we||ve||E,Oe=Q.useRef(null),ke=Q.useRef(null),Ae=Q.useRef(null),je=Q.useRef(null),Me,Ne;t[32]===M?(Me=t[33],Ne=t[34]):(Me=()=>{let e=je.current,t=e?.querySelector(`[aria-current="step"]`)??null;if(!M||!e||!t)return;let n=t.offsetTop-e.offsetTop-(e.clientHeight-t.offsetHeight)/2,r=e.scrollHeight-e.clientHeight;e.scrollTop=Math.min(r,Math.max(0,n))},Ne=[M],t[32]=M,t[33]=Me,t[34]=Ne),Q.useLayoutEffect(Me,Ne);let Pe,Fe;t[35]!==ne||t[36]!==M||t[37]!==H?(Pe=()=>{if(!M&&!ne)return;let e=e=>{let t=e.target;if(H){Oe.current&&!Oe.current.contains(t)&&j({todos:!1,changes:!1});return}let n=M&&ke.current&&!ke.current.contains(t),r=ne&&Ae.current&&!Ae.current.contains(t);!n&&!r||j(e=>({todos:!n&&e.todos,changes:!r&&e.changes}))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},Fe=[M,ne,H],t[35]=ne,t[36]=M,t[37]=H,t[38]=Pe,t[39]=Fe):(Pe=t[38],Fe=t[39]),Q.useEffect(Pe,Fe);let Ie;t[40]===H?Ie=t[41]:(Ie=()=>j(e=>({todos:!e.todos,changes:H&&!e.todos?!1:e.changes})),t[40]=H,t[41]=Ie);let Le=G(Ie),Re;t[42]===H?Re=t[43]:(Re=e=>j(t=>({todos:H&&e?!1:t.todos,changes:e})),t[42]=H,t[43]=Re);let ze=G(Re),Be;t[44]!==_e.active||t[45]!==_e.left||t[46]!==O?(Be=O(`chat.statusRow.summary.activeLeft`,{active:_e.active,left:_e.left}),t[44]=_e.active,t[45]=_e.left,t[46]=O,t[47]=Be):Be=t[47];let Ve=Be,He;t[48]!==ae||t[49]!==ve||t[50]!==te||t[51]!==M||t[52]!==b||t[53]!==de||t[54]!==_e.left||t[55]!==O||t[56]!==Ve||t[57]!==Le?(He=ve?(0,$.jsxs)(`button`,{type:`button`,onClick:Le,className:J(Oh,`yuri-status-row-trigger shrink-0`),"aria-label":Ve,title:Ve,"aria-expanded":M,children:[_e.left===0?(0,$.jsx)(Iu,{}):(0,$.jsx)(Lu,{done:de.completed,total:de.total,spinning:b}),!te&&ae?(0,$.jsx)(`span`,{className:J(`status-row__active-todo max-w-[200px]`,kh),children:ae.content}):(0,$.jsx)(`span`,{className:J(kh,`text-muted-foreground`),children:O(`chat.statusRow.tasksTitle`)}),(0,$.jsx)(Hu,{done:de.completed,total:de.total,className:Ah,animate:!1}),M?(0,$.jsx)(X,{name:`arrow-up-s`,className:jh}):(0,$.jsx)(X,{name:`arrow-down-s`,className:jh})]}):null,t[48]=ae,t[49]=ve,t[50]=te,t[51]=M,t[52]=b,t[53]=de,t[54]=_e.left,t[55]=O,t[56]=Ve,t[57]=Le,t[58]=He):He=t[58];let Ue=He;if(!De)return null;let We=H&&`relative`,Ge=!Te&&`chat-column -mt-2`,Ke;t[59]!==y||t[60]!==Te||t[61]!==H||t[62]!==We||t[63]!==Ge?(Ke=J(`mb-1`,We,Ge,!Te&&fm(H),!Te&&`pb-3.5`,y),t[59]=y,t[60]=Te,t[61]=H,t[62]=We,t[63]=Ge,t[64]=Ke):Ke=t[64];let qe=Te&&`px-3`,Je;t[65]===qe?Je=t[66]:(Je=J(`flex items-center justify-between py-0.5 gap-2`,qe),t[65]=qe,t[66]=Je);let Ye=!Te&&`overflow-x-hidden`,Xe;t[67]===Ye?Xe=t[68]:(Xe=J(`flex-1 flex items-center min-w-0 gap-2`,Ye),t[67]=Ye,t[68]=Xe);let Ze;t[69]!==g||t[70]!==ne||t[71]!==F||t[72]!==ze||t[73]!==ye||t[74]!==i||t[75]!==H||t[76]!==S||t[77]!==a||t[78]!==b||t[79]!==c||t[80]!==Ee||t[81]!==f||t[82]!==w||t[83]!==E||t[84]!==x||t[85]!==O||t[86]!==l?(Ze=ye?(0,$.jsx)(`div`,{className:`flex min-w-0 items-center text-muted-foreground`,role:`status`,"aria-live":`polite`,"aria-label":O(`chat.statusRow.abortPrompt`),children:(0,$.jsxs)(`span`,{className:J(`flex min-w-0 items-center typography-ui-label`,H?`gap-1`:`gap-1.5`),children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center`,H?`h-5 w-4`:`h-6 w-3.5`),children:(0,$.jsx)(X,{name:`error-warning`,className:`size-3.5`,"aria-hidden":`true`})}),(0,$.jsx)(`span`,{className:`animate-text-shimmer truncate whitespace-nowrap`,children:O(`chat.statusRow.abortPrompt`)})]})}):w&&f?(0,$.jsx)(`div`,{className:`flex h-full items-center text-[var(--status-error)]`,children:(0,$.jsxs)(`span`,{className:J(`flex items-center typography-ui-label`,H?`gap-1`:`gap-1.5`),children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center`,H?`h-5 w-4`:`h-6 w-3.5`),children:(0,$.jsx)(X,{name:`close-circle`,className:`size-3.5`,"aria-hidden":`true`})}),O(`chat.statusRow.aborted`)]})}):w&&Ee?(0,$.jsx)(ng,{isWorking:b,isMobile:H,statusText:x,isGenericStatus:i,isWaitingForPermission:a,retryInfo:c,turnStartedAt:l,isTurnSettled:S,agentName:g},F??`no-session`):E?(0,$.jsx)(Bh,{isExpanded:ne,onExpandedChange:ze}):null,t[69]=g,t[70]=ne,t[71]=F,t[72]=ze,t[73]=ye,t[74]=i,t[75]=H,t[76]=S,t[77]=a,t[78]=b,t[79]=c,t[80]=Ee,t[81]=f,t[82]=w,t[83]=E,t[84]=x,t[85]=O,t[86]=l,t[87]=Ze):Ze=t[87];let Qe;t[88]!==Xe||t[89]!==Ze?(Qe=(0,$.jsx)(`div`,{ref:Ae,className:Xe,children:Ze}),t[88]=Xe,t[89]=Ze,t[90]=Qe):Qe=t[90];let $e=!H&&`relative`,et=!Te&&`-mr-3`,tt;t[91]!==$e||t[92]!==et?(tt=J(`flex items-center gap-2 flex-shrink-0`,$e,et),t[91]=$e,t[92]=et,t[93]=tt):tt=t[93];let nt;t[94]!==ve||t[95]!==M||t[96]!==H||t[97]!==b||t[98]!==de||t[99]!==O||t[100]!==W?(nt=M&&ve&&(0,$.jsxs)(`div`,{style:H?yh:vh,className:J(_h,`absolute right-0 bottom-full mb-1 z-50`,`animate-in fade-in-0 zoom-in-95 slide-in-from-bottom-2`,`duration-150 p-[0.5em] pb-[0.875em]`,H?`text-xs leading-4 md:text-[0.8125rem] md:leading-5`:`text-base`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-[0.6em] px-[0.5em] pt-[0.25em] pb-[0.5em]`,children:[de.completed===de.total?(0,$.jsx)(Iu,{}):(0,$.jsx)(Lu,{done:de.completed,total:de.total,spinning:b}),(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate leading-[1.5] text-foreground`,!H&&`text-[0.88em]`),children:O(`chat.workStatus.todos.title`)}),(0,$.jsx)(Hu,{done:de.completed,total:de.total,className:J(`text-muted-foreground`,!H&&`text-[0.88em]`)})]}),(0,$.jsx)(Bu,{todos:W,isWorking:b,animate:!0,listRef:je,className:J(`max-h-[min(22rem,50vh)] overflow-y-auto text-inherit`,H&&`[&_[dir=auto]]:text-[1em]`),rowClassName:`gap-[0.6em] px-[0.5em] py-[0.4em]`})]}),t[94]=ve,t[95]=M,t[96]=H,t[97]=b,t[98]=de,t[99]=O,t[100]=W,t[101]=nt):nt=t[101];let rt;t[102]!==tt||t[103]!==nt||t[104]!==Ue?(rt=(0,$.jsxs)(`div`,{ref:ke,className:tt,children:[Ue,nt]}),t[102]=tt,t[103]=nt,t[104]=Ue,t[105]=rt):rt=t[105];let it;t[106]!==Je||t[107]!==Qe||t[108]!==rt?(it=(0,$.jsxs)(`div`,{className:Je,children:[Qe,rt]}),t[106]=Je,t[107]=Qe,t[108]=rt,t[109]=it):it=t[109];let at;return t[110]!==Ke||t[111]!==it?(at=(0,$.jsx)(`div`,{ref:Oe,className:Ke,style:rg,children:it}),t[110]=Ke,t[111]=it,t[112]=at):at=t[112],at};function og(e){return e.currentSessionId}function sg(e){return e.isMobile}function cg(e){return e.status!==`cancelled`}function lg(e){return e.status===`in_progress`}function ug(e){return e.status===`pending`}function dg(e){return e.status!==`cancelled`}function fg(e){return e.status===`completed`}function pg(e){return e.status===`in_progress`}function mg(e){return e.status===`in_progress`||e.status===`pending`}var hg=Q.memo(function(e){let t=(0,Z.c)(11),{registry:n,hostId:r}=e,i=Lt(n,r),{t:a}=na(),o,s,c,l;if(t[0]!==i||t[1]!==a){let e=hs(i);o=`status`,s=`polite`,c=`pointer-events-none absolute inset-x-0 bottom-full mb-1 flex min-w-0 items-center gap-1.5 px-3 typography-meta text-muted-foreground`,l=e?(0,$.jsxs)($.Fragment,{children:[e.pending?(0,$.jsx)(X,{name:`loader-4`,"aria-hidden":`true`,className:`size-3 shrink-0 animate-spin motion-reduce:animate-none`}):null,(0,$.jsx)(`span`,{className:`truncate`,children:a(e.key)})]}):null,t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l}else o=t[2],s=t[3],c=t[4],l=t[5];let u;return t[6]!==o||t[7]!==s||t[8]!==c||t[9]!==l?(u=(0,$.jsx)(`div`,{role:o,"aria-live":s,className:c,children:l}),t[6]=o,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10],u}),gg=Q.memo(e=>{let t=(0,Z.c)(22),{visible:n,onClick:r,placement:i}=e,a=i===void 0?`default`:i,{t:o}=na(),s=a===`compact`;if(s&&!n)return null;let c=a==="default"&&`absolute left-1/2 bottom-full mb-2 -translate-x-1/2`,l=a===`expanded`&&`absolute left-1/2 -translate-x-1/2 yuri-scroll-to-bottom--expanded mb-2`,u=a===`compact`&&`yuri-scroll-to-bottom--compact relative shrink-0`,d;t[0]!==a||t[1]!==c||t[2]!==l||t[3]!==u||t[4]!==n?(d=J(c,l,u,n?J(`pointer-events-auto`,a==="default"&&`opacity-100`):J(`opacity-0 pointer-events-none`,a===`expanded`&&`yuri-scroll-to-bottom--hidden`)),t[0]=a,t[1]=c,t[2]=l,t[3]=u,t[4]=n,t[5]=d):d=t[5];let f=s?`ghost`:`outline`,p=s?`composer-mobile-actions h-8 w-8 rounded-none bg-transparent hover:bg-transparent text-foreground`:`size-8 rounded-full [corner-shape:round] bg-background/95 hover:bg-interactive-hover`,m;t[6]===p?m=t[7]:(m=J(`p-0 shadow-none`,p),t[6]=p,t[7]=m);let h;t[8]===o?h=t[9]:(h=o(`chat.scrollToBottom.aria`),t[8]=o,t[9]=h);let g=s?`size-5`:`size-4`,_=s?`medium`:`regular`,v;t[10]!==g||t[11]!==_?(v=(0,$.jsx)(X,{name:`arrow-down`,className:g,weight:_}),t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==r||t[14]!==v||t[15]!==f||t[16]!==m||t[17]!==h?(y=(0,$.jsx)(Tr,{variant:f,size:`sm`,onClick:r,className:m,"aria-label":h,children:v}),t[13]=r,t[14]=v,t[15]=f,t[16]=m,t[17]=h,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==d?(b=(0,$.jsx)(`div`,{className:d,children:y}),t[19]=y,t[20]=d,t[21]=b):b=t[21],b}),_g=e=>{let t=(0,Z.c)(31),{onCycleAgent:n,onOpenAgentPanel:r,className:i,agentName:a,agents:o,disabled:s}=e,c;t[0]===o?c=t[1]:(c=o===void 0?[]:o,t[0]=o,t[1]=c);let l=c,u=s!==void 0&&s,d=a??void 0,f;t[2]!==l||t[3]!==d?(f=Nr(l,d),t[2]=l,t[3]=d,t[4]=f):f=t[4];let p=f,m=um(d),h;t[5]===d?h=t[6]:(h=$a(d),t[5]=d,t[6]=h);let g=h,_=Q.useRef(null),v=Q.useRef(!1),y;t[7]!==u||t[8]!==r?(y=e=>{e.preventDefault(),!u&&(v.current=!1,_.current=setTimeout(()=>{v.current=!0,r()},500))},t[7]=u,t[8]=r,t[9]=y):y=t[9];let b=y,x;t[10]!==u||t[11]!==n?(x=()=>{_.current&&=(clearTimeout(_.current),null),!u&&!v.current&&n()},t[10]=u,t[11]=n,t[12]=x):x=t[12];let S=x,C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{_.current&&=(clearTimeout(_.current),null)},t[13]=C):C=t[13];let w=C,T,E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>()=>{_.current&&clearTimeout(_.current)},T=[],t[14]=T,t[15]=E):(T=t[14],E=t[15]),Q.useEffect(E,T);let D;t[16]===i?D=t[17]:(D=J(`inline-flex flex-shrink-0 items-center select-none focus:outline-none touch-none disabled:cursor-not-allowed disabled:opacity-40`,vm,i),t[16]=i,t[17]=D);let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O={height:`26px`,maxHeight:`26px`,minHeight:`26px`},t[18]=O):O=t[18];let k;t[19]!==g.var||t[20]!==p||t[21]!==d||t[22]!==m?(k=(0,$.jsx)(lm,{name:d,label:p,revealed:m,avatarSize:16,slotClassName:`h-[26px] w-6`,labelGapClassName:`pl-1 pr-0.5`,colorVar:g.var}),t[19]=g.var,t[20]=p,t[21]=d,t[22]=m,t[23]=k):k=t[23];let A;return t[24]!==p||t[25]!==u||t[26]!==b||t[27]!==S||t[28]!==D||t[29]!==k?(A=(0,$.jsx)(`button`,{type:`button`,disabled:u,onPointerDown:b,onPointerUp:S,onPointerLeave:w,onContextMenu:vg,onMouseDown:yg,className:D,style:O,title:p,"aria-label":p,children:k}),t[24]=p,t[25]=u,t[26]=b,t[27]=S,t[28]=D,t[29]=k,t[30]=A):A=t[30],A};function vg(e){return e.preventDefault()}function yg(e){return e.preventDefault()}var bg=e=>{let t=(0,Z.c)(28),{onOpenModel:n,className:r,providerID:i,modelID:a,provider:o,variant:s,disabled:c}=e,l=c!==void 0&&c,{t:u}=na(),d;t[0]!==a||t[1]!==o||t[2]!==u?(d=Mi(o,a,u(`chat.modelControls.selectModel`)),t[0]=a,t[1]=o,t[2]=u,t[3]=d):d=t[3];let f=d,p;t[4]===s?p=t[5]:(p=s?.trim()?oi(s):null,t[4]=s,t[5]=p);let m=p,h=m?`${f} ${m}`:f,g;t[6]===r?g=t[7]:(g=J(`inline-flex min-w-0 max-w-36 items-stretch`,`rounded-lg`,`focus:outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,r),t[6]=r,t[7]=g);let _;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_={height:`26px`,maxHeight:`26px`,minHeight:`26px`},t[8]=_):_=t[8];let v;t[9]!==a||t[10]!==i?(v=a||i?(0,$.jsx)(Gs,{modelId:a,providerId:i,className:`size-4 flex-shrink-0`}):null,t[9]=a,t[10]=i,t[11]=v):v=t[11];let y;t[12]===f?y=t[13]:(y=(0,$.jsx)(`span`,{className:`truncate text-[11px] leading-none font-medium text-foreground/80`,children:f}),t[12]=f,t[13]=y);let b;t[14]===m?b=t[15]:(b=m?(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] leading-none font-normal text-muted-foreground`,children:m}):null,t[14]=m,t[15]=b);let x;t[16]!==y||t[17]!==b?(x=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[y,b]}),t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==v||t[20]!==x?(S=(0,$.jsxs)(`span`,{className:`flex h-full w-full min-w-0 items-center gap-1`,children:[v,x]}),t[19]=v,t[20]=x,t[21]=S):S=t[21];let C;return t[22]!==h||t[23]!==l||t[24]!==n||t[25]!==S||t[26]!==g?(C=(0,$.jsx)(`button`,{type:`button`,disabled:l,onClick:n,onMouseDown:xg,onPointerDownCapture:Sg,className:g,style:_,title:h,"aria-label":h,children:S}),t[22]=h,t[23]=l,t[24]=n,t[25]=S,t[26]=g,t[27]=C):C=t[27],C};function xg(e){return e.preventDefault()}function Sg(e){e.preventDefault()}var Cg=e=>!(!e.sessionId||e.composerSurfaceKind===`secondary`||e.hasSessionEntity||e.hasRenderableSessionSnapshot),wg=e=>{let t=e.isSubagentSession&&!e.allowPromptingSubagentSessions;return{showReadOnlyBanner:e.isSubagentSession&&(e.readOnly||t),blockSubmission:e.sessionIdentityPending}},Tg=(e,t)=>({agentName:t.agentName??e?.agentName,providerId:t.providerId??e?.providerId,modelId:t.modelId??e?.modelId}),Eg=(e,t)=>e.id===t.id&&e.directory===t.directory,Dg=(e,t)=>e.agentName===t.agentName&&e.providerId===t.providerId&&e.modelId===t.modelId,Og=(e,t,n,r)=>{if(!t)return null;let i=n??(e?.viewKey===t?e.parentTarget:null);if(!i)return null;let a=Tg(e?.viewKey===t?e.execution:void 0,r);return e&&e.viewKey===t&&Eg(e.parentTarget,i)&&Dg(e.execution,a)?e:{viewKey:t,parentTarget:i,execution:a}},kg=e=>{let{inFlight:t,establishing:n}=e.sendPhase,r=!n&&(e.draftSubmitting||t);return{sendDisabled:!e.canSend||!e.hasSessionTarget||e.submissionBlocked||r,queueDisabled:!e.hasSessionTarget||e.submissionBlocked||!n&&t||e.queueFrozen&&!e.queueFallbackAvailable,disabledClass:`opacity-30 pointer-events-none`}},Ag=e=>{let t=e.trim();if(!t)return null;let n=t.match(/\/issues\/(\d+)(?:\b|\/|$)/i);if(n){let e=Number(n[1]);return Number.isFinite(e)&&e>0?e:null}let r=t.match(/^#?(\d+)$/);if(r){let e=Number(r[1]);return Number.isFinite(e)&&e>0?e:null}return null},jg=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`};function Mg({open:e,onOpenChange:t,mode:n=`createSession`,onSelect:r}){let{t:i}=na(),{github:a}=Vt(),o=ed(),s=o.data??null,c=o.isFetched,l=ln(e=>e.setSettingsDialogOpen),u=ln(e=>e.setSettingsPage),d=ln(e=>e.isMobile),{isTablet:f}=Ia(),p=d||f,m=Bn(e=>e.getActiveProject()),h=qe(e=>e.currentDirectory),g=Q.useMemo(()=>m?.path?.trim()||h?.trim()||null,[m?.path,h]),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),[x,S]=Q.useState(null),C=Q.useRef(0),w=Q.useMemo(()=>Ag(_),[_]),T=is(_,350),E=w?``:T.trim(),D=!!w||_===T,O=e&&D&&!!g&&!!a?.issuesList&&!(c&&s?.connected===!1),k=Ft({queryKey:zt.scoped(`github-issues`,g,E),enabled:O,initialPageParam:1,refetchOnMount:`always`,queryFn:({pageParam:e})=>a.issuesList(g,{page:e,...E?{query:E}:{}}),getNextPageParam:e=>e.hasMore?(e.page??1)+1:void 0}),A=D?k.data?.pages.at(-1)??null:null,j=D?k.data?.pages.flatMap(e=>e.issues??[])??[]:[],M=D&&k.hasNextPage,N=!w&&!D||k.isLoading,P=D&&k.isFetchingNextPage,F=D&&k.error?k.error instanceof Error?k.error.message:String(k.error):null,I=Q.useCallback(()=>k.refetch(),[k]),L=Q.useCallback(async()=>{try{await k.fetchNextPage()}catch(e){let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.loadMoreFailed`),{description:t})}},[k,i]);Q.useEffect(()=>{e||(++C.current,v(``),b(!1),S(null))},[e]),Q.useEffect(()=>{++C.current},[e,g]);let R=!c||s?.connected!==!1&&A?.connected!==!1,ee=A?.repo?.url??null,z=Q.useCallback(()=>{u(`github`),l(!0)},[l,u]),B=Q.useCallback(()=>{let e=kr.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},[]),V=Q.useCallback(()=>{let e=kr.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=Yn(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),H=Q.useCallback((e,t)=>{let n=kr.getState(),r=Yn(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},[]),U=Q.useCallback(async(e,o)=>{let s=++C.current,c=()=>C.current===s;if(n===`select`){if(!g){Fi.error(i(`session.githubIssuePicker.error.noActiveProject`));return}if(!a?.issueGet||!a?.issueComments){Fi.error(i(`session.githubIssuePicker.error.runtimeUnavailable`));return}if(x)return;S(e);try{let n=await a.issueGet(g,e,{sourceRepo:o});if(!c())return;if(n.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}if(!n.repo){Fi.error(i(`session.githubIssuePicker.error.repoNotResolvable`),{description:i(`session.githubIssuePicker.error.repoMustBeGithub`)});return}let s=n.issue;if(!s){Fi.error(i(`session.githubIssuePicker.error.issueNotFound`));return}let l=await a.issueComments(g,e,{sourceRepo:o});if(!c())return;if(l.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}let u=l.comments??[],d=jg({repo:n.repo,issue:s,comments:u});r&&r({number:s.number,title:s.title,url:s.url,contextText:d,author:s.author?{login:s.author.login,avatarUrl:s.author.avatarUrl}:void 0}),t(!1)}catch(e){if(!c())return;let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.loadIssueDetailsFailed`),{description:t})}finally{c()&&S(null)}return}if(!g){Fi.error(i(`session.githubIssuePicker.error.noActiveProject`));return}if(!a?.issueGet||!a?.issueComments){Fi.error(i(`session.githubIssuePicker.error.runtimeUnavailable`));return}if(!x){S(e);try{let n=await a.issueGet(g,e,{sourceRepo:o});if(!c())return;if(n.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}if(!n.repo){Fi.error(i(`session.githubIssuePicker.error.repoNotResolvable`),{description:i(`session.githubIssuePicker.error.repoMustBeGithub`)});return}let r=n.issue;if(!r){Fi.error(i(`session.githubIssuePicker.error.issueNotFound`));return}let s=await a.issueComments(g,e,{sourceRepo:o});if(!c())return;if(s.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}let l=s.comments??[],u=`#${r.number} ${r.title}`.trim(),{sessionId:d}=await(async()=>{if(y){let e=`issue-${r.number}-${Xc()}`,t=await qc(g,e,void 0,{returnAfterDirectoryCreated:!0});if(!t?.id)throw Error(`Failed to create worktree session`);return{sessionId:t.id,sessionDirectory:t.path}}let e=await Er(u,g,null);if(!e?.id)throw Error(`Failed to create session`);return{sessionId:e.id,sessionDirectory:e.directory??g}})();if(!c())return;Qr(d,u).catch(()=>void 0);try{Xr.getState().initializeNewYuriSession(d,kr.getState().agents)}catch{}t(!1);let f=kr.getState(),p=Oi.getState().lastUsedProvider,m=V(),h=m?.providerID||f.currentProviderId||p?.providerID,_=m?.modelID||f.currentModelId||p?.modelID,v=B()||f.currentAgentName||void 0;if(!h||!_){Fi.error(i(`session.githubIssuePicker.error.noModelSelected`));return}let b=H(h,_),x=await Ka(`github.issue.review.visible`,{issue_number:String(r.number)});if(!c())return;let S=await Ka(`github.issue.review.instructions`);if(!c())return;let C=jg({repo:n.repo,issue:r,comments:l});Xr.getState().sendMessage(x,h,_,v,void 0,void 0,[{text:S,synthetic:!0},{text:C,synthetic:!0}],b,void 0,{sessionId:d}).catch(e=>{let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.sendContextFailed`),{description:t})}),Fi.success(i(`session.githubIssuePicker.toast.sessionCreated`))}catch(e){if(!c())return;let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.startSessionFailed`),{description:t})}finally{c()&&S(null)}}},[y,a,n,t,r,g,B,V,H,x,i]),te=i(n===`select`?`session.githubIssuePicker.title.select`:`session.githubIssuePicker.title.createSession`),ne=i(n===`select`?`session.githubIssuePicker.description.select`:`session.githubIssuePicker.description.createSession`),re=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(Do,{placeholder:i(`session.githubIssuePicker.searchPlaceholder`),value:_,onChange:e=>{v(e.target.value)},className:`pl-9 w-full`})]}),(0,$.jsxs)(`div`,{className:J(`yuri-picker-list`,d?`min-h-0 mt-2`:`flex-1 overflow-y-auto mt-2`),children:[g?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:i(`session.githubIssuePicker.empty.noActiveProject`)}),a?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:i(`session.githubIssuePicker.empty.runtimeUnavailable`)}),N?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 flex items-center justify-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),i(`session.githubIssuePicker.loading.issues`)]}):null,R===!1?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 space-y-3`,children:[(0,$.jsx)(`div`,{children:i(`session.githubIssuePicker.empty.notConnected`)}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,onClick:z,children:i(`session.githubIssuePicker.actions.openSettings`)})})]}):null,F?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8 break-words`,children:F}):null,w&&g&&a&&R?(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,x===w&&`bg-interactive-selection/30`),onClick:()=>void U(w),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground w-5 text-right flex-shrink-0`,children:`#`}),(0,$.jsx)(`p`,{className:`flex-1 min-w-0 typography-small text-foreground truncate ml-0.5`,children:i(`session.githubIssuePicker.actions.useIssue`,{number:w})}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:x===w?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):null})]}):null,j.length===0&&!N&&!F&&R&&a&&g?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:T.trim()?i(`session.githubIssuePicker.empty.noIssuesFound`):i(`session.githubIssuePicker.empty.noOpenIssuesFound`)}):null,j.map(e=>(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,x===e.number&&`bg-interactive-selection/30`),onClick:()=>void U(e.number,e.sourceRepo),children:[(0,$.jsxs)(`span`,{className:`typography-meta text-muted-foreground w-12 text-right flex-shrink-0`,children:[`#`,e.number]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 ml-0.5`,children:[(0,$.jsx)(`p`,{className:`yuri-picker-label typography-small text-foreground truncate`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,$.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]}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:x===e.number?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:J(`h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors`,p?`flex`:`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),"aria-label":i(`session.githubIssuePicker.actions.openInGitHubAria`),children:(0,$.jsx)(X,{name:`external-link`,className:`h-4 w-4`})})})]},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)),M&&R&&g&&a?(0,$.jsx)(`div`,{className:`py-2 flex justify-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void L(),disabled:P||!!x,className:J(`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4`,(P||!!x)&&`opacity-50 cursor-not-allowed hover:text-muted-foreground`),children:P?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),i(`session.githubIssuePicker.loading.more`)]}):i(`session.githubIssuePicker.actions.loadMore`)})}):null]}),n!==`select`&&(0,$.jsx)(`div`,{className:d?`mt-4 p-3 bg-muted/30 rounded-lg`:`yuri-picker-footer`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(e=>!e),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(e=>!e))},children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),b(e=>!e)},"aria-label":i(`session.githubIssuePicker.actions.toggleWorktreeAria`),className:`flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:y?(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`})}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i(`session.githubIssuePicker.actions.createInWorktree`)})]}),(0,$.jsx)(`div`,{className:`hidden sm:block sm:flex-1`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ee?(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,asChild:!0,children:(0,$.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(X,{name:`external-link`,className:`size-4`}),i(`session.githubIssuePicker.actions.openRepo`)]})}):null,(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,onClick:I,disabled:N||!!x,children:i(`session.githubIssuePicker.actions.refresh`)})]})]})})]});return d?(0,$.jsx)(xu,{open:e,title:te,onClose:()=>t(!1),renderHeader:e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-3 py-2 border-b border-border/40`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:te}),e]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:ne})]}),children:re}):(0,$.jsx)(Ea,{open:e,onOpenChange:t,children:(0,$.jsxs)(Sa,{presentation:`picker`,children:[(0,$.jsx)(ba,{className:`yuri-picker-header`,children:(0,$.jsx)(Ca,{className:`yuri-picker-title`,children:te})}),re]})})}var Ng=e=>{let t=e.trim();if(!t)return null;let n=t.match(/\/pull\/(\d+)(?:\b|\/|$)/i);if(n){let e=Number(n[1]);return Number.isFinite(e)&&e>0?e:null}let r=t.match(/^#?(\d+)$/);if(r){let e=Number(r[1]);return Number.isFinite(e)&&e>0?e:null}return null},Pg=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function Fg({open:e,onOpenChange:t,onSelect:n}){let{t:r}=na(),{github:i}=Vt(),a=ed(),o=a.data??null,s=a.isFetched,c=ln(e=>e.setSettingsDialogOpen),l=ln(e=>e.setSettingsPage),u=ln(e=>e.isMobile),{isTablet:d}=Ia(),f=u||d,p=Bn(e=>e.getActiveProject())?.path??null,[m,h]=Q.useState(``),[g,_]=Q.useState(!1),[v,y]=Q.useState(null),b=Q.useRef(0),x=Q.useMemo(()=>Ng(m),[m]),S=is(m,350),C=x?``:S.trim(),w=!!x||m===S,T=e&&w&&!!p&&!!i?.prsList&&!(s&&o?.connected===!1),E=Ft({queryKey:zt.scoped(`github-prs`,p,C),enabled:T,initialPageParam:1,refetchOnMount:`always`,queryFn:({pageParam:e})=>i.prsList(p,{page:e,...C?{query:C}:{}}),getNextPageParam:e=>e.hasMore?(e.page??1)+1:void 0}),D=w?E.data?.pages.at(-1)??null:null,O=w?E.data?.pages.flatMap(e=>e.prs??[])??[]:[],k=w&&E.hasNextPage,A=!x&&!w||E.isLoading,j=w&&E.isFetchingNextPage,M=w&&E.error?E.error instanceof Error?E.error.message:String(E.error):null,N=G(async()=>{try{await E.fetchNextPage()}catch(e){let t=e instanceof Error?e.message:String(e);Fi.error(r(`session.githubPrPicker.toast.loadMoreFailed`),{description:t})}});Q.useEffect(()=>{e||(++b.current,h(``),_(!1),y(null))},[e]),Q.useEffect(()=>{++b.current},[e,p]);let P=!s||o?.connected!==!1&&D?.connected!==!1,F=G(()=>{l(`github`),c(!0)}),I=G(async(e,a)=>{if(!p){Fi.error(r(`session.githubPrPicker.error.noActiveProject`));return}if(!i?.prContext){Fi.error(r(`session.githubPrPicker.error.runtimeUnavailable`));return}if(v)return;let o=++b.current,s=()=>b.current===o;y(e);try{let o=await i.prContext(p,e,{includeDiff:g,includeCheckDetails:!1,sourceRepo:a});if(!s())return;if(o.connected===!1){Fi.error(r(`session.githubPrPicker.error.notConnected`));return}if(!o.pr){Fi.error(r(`session.githubPrPicker.error.prNotFound`));return}if(!o.repo){Fi.error(r(`session.githubPrPicker.error.repoNotResolvable`),{description:r(`session.githubPrPicker.error.repoMustBeGithub`)});return}if(n){let e=await Ka(`github.pr.review.instructions`);if(!s())return;n({number:o.pr.number,title:o.pr.title,url:o.pr.url,head:o.pr.head,base:o.pr.base,includeDiff:g,instructionsText:e,contextText:Pg(o),author:o.pr.author?{login:o.pr.author.login,avatarUrl:o.pr.author.avatarUrl}:void 0})}t(!1)}catch(e){if(!s())return;let t=e instanceof Error?e.message:String(e);Fi.error(r(`session.githubPrPicker.toast.loadDetailsFailed`),{description:t})}finally{s()&&y(null)}}),L=r(`session.githubPrPicker.title`),R=r(`session.githubPrPicker.description`),ee=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-picker-search mt-2 flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(Do,{placeholder:r(`session.githubPrPicker.searchPlaceholder`),value:m,onChange:e=>{h(e.target.value)},className:`pl-9 w-full`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`h-9 shrink-0 flex items-center gap-2 text-left`,"aria-pressed":g,"aria-label":r(`session.githubPrPicker.includeDiffAria`),children:[(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ls,{checked:g,onChange:e=>_(e),ariaLabel:r(`session.githubPrPicker.includeDiffAria`)})}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground whitespace-nowrap`,children:r(`session.githubPrPicker.includeDiff`)})]})]}),(0,$.jsxs)(`div`,{className:J(`yuri-picker-list`,u?`min-h-0`:`flex-1 overflow-y-auto`),children:[p?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:r(`session.githubPrPicker.empty.noActiveProject`)}),i?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:r(`session.githubPrPicker.empty.runtimeUnavailable`)}),A?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 flex items-center justify-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),r(`session.githubPrPicker.loading.pullRequests`)]}):null,P===!1?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 space-y-3`,children:[(0,$.jsx)(`div`,{children:r(`session.githubPrPicker.empty.notConnected`)}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,onClick:F,children:r(`session.githubPrPicker.actions.openSettings`)})})]}):null,M?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8 break-words`,children:M}):null,x&&p&&i&&P?(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,v===x&&`bg-interactive-selection/30`),onClick:()=>void I(x),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground w-5 text-right flex-shrink-0`,children:`#`}),(0,$.jsx)(`p`,{className:`flex-1 min-w-0 typography-small text-foreground truncate ml-0.5`,children:r(`session.githubPrPicker.actions.usePullRequest`,{number:x})}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:v===x?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):null})]}):null,O.length===0&&!A&&!M&&P&&i&&p?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:S.trim()?r(`session.githubPrPicker.empty.noPullRequestsFound`):r(`session.githubPrPicker.empty.noOpenPullRequestsFound`)}):null,O.map(e=>(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,v===e.number&&`bg-interactive-selection/30`),onClick:()=>void I(e.number,e.sourceRepo),children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 ml-0.5`,children:[(0,$.jsxs)(`p`,{className:`yuri-picker-label typography-small text-foreground truncate`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground mr-1`,children:[`#`,e.number]}),e.title]}),e.sourceRepo?.source===`upstream`?(0,$.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,(0,$.jsxs)(`p`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:[e.head,` → `,e.base]})]}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:v===e.number?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:J(`h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors`,f?`flex`:`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),"aria-label":r(`session.githubPrPicker.actions.openInGitHubAria`),children:(0,$.jsx)(X,{name:`external-link`,className:`h-4 w-4`})})})]},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)),k&&P&&p&&i?(0,$.jsx)(`div`,{className:`py-2 flex justify-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:j||!!v,className:J(`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4`,(j||!!v)&&`opacity-50 cursor-not-allowed hover:text-muted-foreground`),children:j?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),r(`session.githubPrPicker.loading.more`)]}):r(`session.githubPrPicker.actions.loadMore`)})}):null]})]});return u?(0,$.jsx)(xu,{open:e,title:L,onClose:()=>t(!1),renderHeader:e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-3 py-2 border-b border-border/40`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:L}),e]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:R})]}),children:ee}):(0,$.jsx)(Ea,{open:e,onOpenChange:t,children:(0,$.jsxs)(Sa,{presentation:`picker`,children:[(0,$.jsx)(ba,{className:`yuri-picker-header`,children:(0,$.jsx)(Ca,{className:`yuri-picker-title`,children:L})}),ee]})})}var Ig=(e,t)=>`${e}:${at(t)}`,Lg=e=>e.type===`skill`||!Ie(e.name);function Rg(e){let{t}=na(),n=Q.useMemo(()=>d(),[]),r=ln(e=>e.globalDraftStarters),i=Bn(e=>e.activeProjectId),a=Bn(e=>e.projects),o=Q.useMemo(()=>{if(!i)return null;let e=a.find(e=>e.id===i);return e?.path?{id:e.id,path:e.path}:null},[i,a]),[s,c]=Q.useState([]),l=Q.useMemo(()=>r??Ze,[r]),u=l.some(Lg)||s.some(Lg),f=vr({directory:e,enabled:u}),p=Q.useMemo(()=>f.data??[],[f.data]),{refetch:m}=f,h=En({directory:e,enabled:u}),g=Q.useMemo(()=>h.data??[],[h.data]),{refetch:_}=h;Q.useEffect(()=>{let e=!1;if(!o){c([]);return}return Ii(o).then(t=>{e||c(t)}).catch(()=>{e||c([])}),()=>{e=!0}},[o?.id]);let v=Q.useCallback(()=>{m(),_()},[m,_]),y=Q.useMemo(()=>new Set(p.map(e=>e.name)),[p]),b=Q.useMemo(()=>new Set(g.map(e=>e.name)),[g]),x=Q.useCallback((e,r)=>{if(n&&e.type===`command`&&e.name===`craft-goal`)return null;if(e.type===`command`){let n=Ie(e.name);return n?{id:Ig(r,e),ref:e,group:r,label:t(n.labelKey),icon:n.icon,submitText:n.command}:y.has(e.name)?{id:Ig(r,e),ref:e,group:r,label:$e(e.name),icon:Ye,submitText:`/${e.name}`}:null}return b.has(e.name)?{id:Ig(r,e),ref:e,group:r,label:$e(e.name),icon:Ge,submitText:`@${e.name}`}:null},[t,y,b,n]),S=Q.useMemo(()=>l.map(e=>x(e,`global`)).filter(e=>e!==null),[l,x]),C=Q.useMemo(()=>s.map(e=>x(e,`project`)).filter(e=>e!==null),[s,x]),w=Q.useMemo(()=>{let e=new Set;for(let t of l)e.add(at(t));for(let t of s)e.add(at(t));return e},[l,s]),T=Q.useMemo(()=>{let e=[];for(let r of Xe)n&&r.name===`craft-goal`||e.push({type:`command`,name:r.name,label:t(r.labelKey),icon:r.icon,section:`built-in`,scope:`user`});for(let t of p)t.isBuiltIn||t.source===`skill`||Ie(t.name)||e.push({type:`command`,name:t.name,label:$e(t.name),icon:Ye,section:`command`,scope:t.scope===`project`?`project`:`user`});for(let t of g)e.push({type:`skill`,name:t.name,label:$e(t.name),icon:Ge,section:`skill`,scope:t.scope===`project`?`project`:`user`});return e.filter(e=>!w.has(`${e.type}:${e.name}`))},[t,p,g,w,n]),E=Q.useCallback(e=>{ln.getState().setGlobalDraftStarters(e),He({draftStarters:e})},[]),D=Q.useCallback(e=>{c(e),o&&Pr(o,e)},[o]),O=Q.useCallback(e=>{let t={type:e.type,name:e.name};if(e.scope===`project`){if(!o||s.some(e=>ot(e,t)))return;D([...s,t])}else{let e=r??Ze;if(e.some(e=>ot(e,t)))return;E([...e,t])}},[o,s,r,D,E]),k=Q.useCallback((e,t)=>{e===`project`?D(s.filter(e=>!ot(e,t))):E((r??Ze).filter(e=>!ot(e,t)))},[s,r,D,E]),A=Q.useCallback((e,t,n)=>{let i=e===`project`?s:r??Ze,a=i.findIndex(n=>Ig(e,n)===t),o=i.findIndex(t=>Ig(e,t)===n);if(a<0||o<0||a===o)return;let c=_u([...i],a,o);e===`project`?D(c):E(c)},[s,r,D,E]);return{global:S,project:C,pinnable:T,hasProject:!!o,ensureLoaded:v,addStarter:O,removeStarter:k,reorder:A}}var zg=`__draft-starter-trash__`,Bg=`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-foreground`,Vg=`max-h-7`,Hg=[{key:`built-in`,headingKey:`chat.draftStarters.sectionBuiltIn`},{key:`command`,headingKey:`chat.draftStarters.sectionCommands`},{key:`skill`,headingKey:`chat.draftStarters.sectionSkills`}],Ug=e=>{let t=(0,Z.c)(35),{item:n,onSubmit:r,onRemove:i,hideRemove:a}=e,{t:o}=na(),s;t[0]===n.id?s=t[1]:(s={id:n.id},t[0]=n.id,t[1]=s);let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:p}=vu(s),m;t[2]===d?m=t[3]:(m=hu.Translate.toString(d),t[2]=d,t[3]=m);let h;t[4]!==m||t[5]!==f?(h={transform:m,transition:f},t[4]=m,t[5]=f,t[6]=h):h=t[6];let g=p&&`z-10 opacity-60`,_;t[7]===g?_=t[8]:(_=J(`group/chip relative`,g),t[7]=g,t[8]=_);let v;t[9]!==n.submitText||t[10]!==r?(v=()=>r(n.submitText),t[9]=n.submitText,t[10]=r,t[11]=v):v=t[11];let y=!a&&`pr-5`,b;t[12]===y?b=t[13]:(b=J(`group inline-flex touch-none select-none items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors`,`hover:bg-[var(--interactive-hover)] hover:text-foreground`,y),t[12]=y,t[13]=b);let x;t[14]===n.icon?x=t[15]:(x=(0,$.jsx)(X,{name:n.icon,className:`h-3 w-3 shrink-0 opacity-60 transition-opacity group-hover:opacity-100`}),t[14]=n.icon,t[15]=x);let S;t[16]===n.label?S=t[17]:(S=(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:n.label}),t[16]=n.label,t[17]=S);let C;t[18]!==c||t[19]!==l||t[20]!==S||t[21]!==v||t[22]!==b||t[23]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,...c,...l,onClick:v,className:b,children:[x,S]}),t[18]=c,t[19]=l,t[20]=S,t[21]=v,t[22]=b,t[23]=x,t[24]=C):C=t[24];let w;t[25]!==a||t[26]!==i||t[27]!==o?(w=a?null:(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},"aria-label":o(`chat.draftStarters.remove`),title:o(`chat.draftStarters.remove`),className:`absolute right-0.5 top-1/2 hidden h-4 w-4 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:text-foreground group-hover/chip:flex`,children:(0,$.jsx)(X,{name:`close`,className:`h-2.5 w-2.5`})}),t[25]=a,t[26]=i,t[27]=o,t[28]=w):w=t[28];let T;return t[29]!==u||t[30]!==C||t[31]!==w||t[32]!==h||t[33]!==_?(T=(0,$.jsxs)(`div`,{ref:u,style:h,className:_,children:[C,w]}),t[29]=u,t[30]=C,t[31]=w,t[32]=h,t[33]=_,t[34]=T):T=t[34],T},Wg=e=>{let t=(0,Z.c)(14),{items:n,onSubmit:r,onRemove:i,hideRemove:a}=e,o;t[0]===n?o=t[1]:(o=n.map(Yg),t[0]=n,t[1]=o);let s;if(t[2]!==a||t[3]!==n||t[4]!==i||t[5]!==r){let e;t[7]!==a||t[8]!==i||t[9]!==r?(e=e=>(0,$.jsx)(Ug,{item:e,onSubmit:r,onRemove:()=>i(e),hideRemove:a},e.id),t[7]=a,t[8]=i,t[9]=r,t[10]=e):e=t[10],s=n.map(e),t[2]=a,t[3]=n,t[4]=i,t[5]=r,t[6]=s}else s=t[6];let c;return t[11]!==o||t[12]!==s?(c=(0,$.jsx)(bu,{items:o,strategy:gu,children:s}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c},Gg=()=>{let e=(0,Z.c)(13),{t}=na(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={id:zg},e[0]=n):n=e[0];let{setNodeRef:r,isOver:i}=uu(n),a;e[1]===t?a=e[2]:(a=t(`chat.draftStarters.remove`),e[1]=t,e[2]=a);let o;e[3]===t?o=e[4]:(o=t(`chat.draftStarters.remove`),e[3]=t,e[4]=o);let s=i&&`text-destructive hover:text-destructive`,c;e[5]===s?c=e[6]:(c=J(Bg,s),e[5]=s,e[6]=c);let l;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e[7]=l):l=e[7];let u;return e[8]!==r||e[9]!==a||e[10]!==o||e[11]!==c?(u=(0,$.jsx)(`button`,{type:`button`,ref:r,"aria-label":a,title:o,className:c,children:l}),e[8]=r,e[9]=a,e[10]=o,e[11]=c,e[12]=u):u=e[12],u},Kg=e=>{let t=(0,Z.c)(21),{pinnable:n,onPick:r,className:i}=e,{t:a}=na(),o;t[0]===i?o=t[1]:(o=J(`min-h-0`,i),t[0]=i,t[1]=o);let s;t[2]===a?s=t[3]:(s=a(`chat.draftStarters.searchPlaceholder`),t[2]=a,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,$.jsx)(Uc,{placeholder:s}),t[4]=s,t[5]=c);let l;t[6]===a?l=t[7]:(l=a(`chat.draftStarters.empty`),t[6]=a,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,$.jsx)(nl,{children:l}),t[8]=l,t[9]=u);let d;t[10]!==r||t[11]!==n||t[12]!==a?(d=Hg.map(e=>{let t=n.filter(t=>t.section===e.key);return t.length===0?null:(0,$.jsx)(bl,{heading:a(e.headingKey),children:t.map(e=>(0,$.jsx)(yl,{value:`${e.section} ${e.label} ${e.name}`,onSelect:()=>r(e),children:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})},`${e.type}:${e.name}`))},e.key)}),t[10]=r,t[11]=n,t[12]=a,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,$.jsxs)(el,{children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;return t[17]!==o||t[18]!==c||t[19]!==f?(p=(0,$.jsxs)(Gc,{className:o,children:[c,f]}),t[17]=o,t[18]=c,t[19]=f,t[20]=p):p=t[20],p},qg=e=>{let t=(0,Z.c)(27),{pinnable:n,onOpen:r,onAdd:i}=e,{t:a}=na(),[o,s]=Q.useState(!1),c;t[0]===r?c=t[1]:(c=e=>{s(e),e&&r()},t[0]=r,t[1]=c);let l;t[2]===a?l=t[3]:(l=a(`chat.draftStarters.add`),t[2]=a,t[3]=l);let u;t[4]===a?u=t[5]:(u=a(`chat.draftStarters.add`),t[4]=a,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t[6]=d):d=t[6];let f;t[7]!==l||t[8]!==u?(f=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:u,className:Bg,children:d})}),t[7]=l,t[8]=u,t[9]=f):f=t[9];let p;t[10]===a?p=t[11]:(p=a(`chat.draftStarters.add`),t[10]=a,t[11]=p);let m;t[12]===p?m=t[13]:(m=(0,$.jsx)(ba,{className:`px-4 pb-2 pt-4 text-left`,children:(0,$.jsx)(Ca,{children:p})}),t[12]=p,t[13]=m);let h;t[14]===i?h=t[15]:(h=e=>{i(e),s(!1)},t[14]=i,t[15]=h);let g;t[16]!==n||t[17]!==h?(g=(0,$.jsx)(Kg,{pinnable:n,onPick:h,className:`flex max-h-[60vh] flex-col`}),t[16]=n,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==m||t[20]!==g?(_=(0,$.jsxs)(Sa,{className:`gap-0 overflow-hidden p-0 sm:max-w-sm`,children:[m,g]}),t[19]=m,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==o||t[23]!==c||t[24]!==_||t[25]!==f?(v=(0,$.jsxs)(Ea,{open:o,onOpenChange:c,children:[f,_]}),t[22]=o,t[23]=c,t[24]=_,t[25]=f,t[26]=v):v=t[26],v},Jg=e=>{let t=(0,Z.c)(63),{onSubmit:n,className:r}=e,{t:i}=na(),{global:a,project:o,pinnable:s,ensureLoaded:c,addStarter:l,removeStarter:u,reorder:d}=Rg(Ga()),{isMobile:f}=Ia(),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),y=Q.useRef(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b={activationConstraint:{distance:8}},t[0]=b):b=t[0];let x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={activationConstraint:{delay:200,tolerance:6}},t[1]=x):x=t[1];let S=mu(su(fu,b),su(lu,x)),C;t[2]!==a||t[3]!==o?(C=e=>a.find(t=>t.id===e)??o.find(t=>t.id===e),t[2]=a,t[3]=o,t[4]=C):C=t[4];let w=C,T=a.length+o.length,E;t[5]===T?E=t[6]:(E=()=>{let e=y.current;if(!e||T===0){v(!1);return}let t=()=>{let t=e.firstElementChild?.offsetHeight??28;v(e.scrollHeight>t+4)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[5]=T,t[6]=E);let D;t[7]!==h||t[8]!==a||t[9]!==o||t[10]!==T?(D=[T,h,a,o],t[7]=h,t[8]=a,t[9]=o,t[10]=T,t[11]=D):D=t[11],Q.useLayoutEffect(E,D);let O,k;t[12]!==_||t[13]!==h?(O=()=>{!_&&h&&g(!1)},k=[_,h],t[12]=_,t[13]=h,t[14]=O,t[15]=k):(O=t[14],k=t[15]),Q.useEffect(O,k);let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>m(!0),t[16]=A):A=t[16];let j=A,M;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>m(!1),t[17]=M):M=t[17];let N=M,P;t[18]!==w||t[19]!==u||t[20]!==d?(P=e=>{m(!1);let{active:t,over:n}=e;if(!n)return;let r=String(t.id),i=w(r);if(!i)return;if(String(n.id)===zg){u(i.group,i.ref);return}let a=String(n.id);if(r===a)return;let o=w(a);o&&o.group===i.group&&d(i.group,r,a)},t[18]=w,t[19]=u,t[20]=d,t[21]=P):P=t[21];let F=P,I=_||h,L;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(L={droppable:{strategy:cu.Always}},t[22]=L):L=t[22];let R;t[23]===r?R=t[24]:(R=J(`flex min-w-0 max-w-full items-start justify-center gap-0.5`,r),t[23]=r,t[24]=R);let ee=!h&&Vg,z=!h&&`overflow-clip`,B;t[25]!==ee||t[26]!==z?(B=J(`flex min-w-0 flex-1 flex-wrap items-center justify-center gap-x-0.5 gap-y-0.5`,ee,z),t[25]=ee,t[26]=z,t[27]=B):B=t[27];let V;t[28]!==a||t[29]!==f||t[30]!==n||t[31]!==u?(V=a.length>0?(0,$.jsx)(Wg,{items:a,onSubmit:n,onRemove:e=>u(`global`,e.ref),hideRemove:f}):null,t[28]=a,t[29]=f,t[30]=n,t[31]=u,t[32]=V):V=t[32];let H;t[33]!==f||t[34]!==n||t[35]!==o||t[36]!==u?(H=o.length>0?(0,$.jsx)(Wg,{items:o,onSubmit:n,onRemove:e=>u(`project`,e.ref),hideRemove:f}):null,t[33]=f,t[34]=n,t[35]=o,t[36]=u,t[37]=H):H=t[37];let U;t[38]!==B||t[39]!==V||t[40]!==H?(U=(0,$.jsxs)(`div`,{ref:y,className:B,children:[V,H]}),t[38]=B,t[39]=V,t[40]=H,t[41]=U):U=t[41];let te;t[42]!==h||t[43]!==I||t[44]!==i?(te=I?(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(Xg),"aria-expanded":h,"aria-label":i(h?`chat.draftStarters.collapse`:`chat.draftStarters.expand`),title:i(h?`chat.draftStarters.collapse`:`chat.draftStarters.expand`),className:Bg,children:(0,$.jsx)(X,{name:h?`arrow-up-s`:`arrow-down-s`,className:`h-3.5 w-3.5`})}):null,t[42]=h,t[43]=I,t[44]=i,t[45]=te):te=t[45];let ne;t[46]!==l||t[47]!==c||t[48]!==p||t[49]!==f||t[50]!==s?(ne=f&&p?(0,$.jsx)(Gg,{}):(0,$.jsx)(qg,{pinnable:s,onOpen:c,onAdd:l}),t[46]=l,t[47]=c,t[48]=p,t[49]=f,t[50]=s,t[51]=ne):ne=t[51];let re;t[52]!==te||t[53]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 self-start`,children:[te,ne]}),t[52]=te,t[53]=ne,t[54]=re):re=t[54];let W;t[55]!==R||t[56]!==U||t[57]!==re?(W=(0,$.jsxs)(`div`,{className:R,children:[U,re]}),t[55]=R,t[56]=U,t[57]=re,t[58]=W):W=t[58];let ie;return t[59]!==F||t[60]!==S||t[61]!==W?(ie=(0,$.jsx)(pu,{sensors:S,collisionDetection:du,measuring:L,onDragStart:j,onDragCancel:N,onDragEnd:F,children:W}),t[59]=F,t[60]=S,t[61]=W,t[62]=ie):ie=t[62],ie};function Yg(e){return e.id}function Xg(e){return!e}function Zg(e){let t=e.selectedDirectory??e.projectRootOption?.value??e.worktreeOptions[0]?.value??null;return t?e.projectRootOption?.value===t?e.projectRootOption.label?.trim()||null:e.worktreeOptions.find(e=>e.value===t)?.label?.trim()||null:null}function Qg(e,t){if(!e||!t)return!1;let n=t.replace(/\\/g,`/`).replace(/\/+$/,``);if(!n)return!1;let r=n===`/`?`/`:n.split(`/`).pop()||``;return!!r&&e===r}var $g=(e,t)=>e??t??null,e_=(e,t)=>!!e&&t!==!1,t_=e=>e?.length?{localBranches:e.filter(e=>!e.startsWith(`remotes/`)).sort(),remoteBranches:e.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort()}:{localBranches:[],remoteBranches:[]},n_=e=>e.replace(/^remotes\//,``).trim(),r_=e=>{let t=n_(e),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},i_=({directory:e,projectDirectory:t,label:n,projectRootOption:r,worktreeOptions:i,onSelectDirectory:a,className:o,maxWidthClassName:s=`max-w-[48vw] sm:max-w-[20rem]`,presentation:c=`dropdown`})=>{let{t:l}=na(),{git:u}=Vt(),d=$g(t,e),f=e,p=qa(d),m=qa(f),h=e_(d,p),g=f!==d&&e_(f,m),_=Ai(d,u,h),v=Ai(f,u,g),y=_.data,b=f===d?y:v.data,x=Ya(e=>e.fetchStatus),S=Ya(e=>f&&e.directories.get(f)?.status?.current?.trim()||null),[C,w]=Q.useState(!1),T=si(d,u,h&&C).data??[],[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(!1),M=Bn(e=>e.projects),N=Bn(e=>e.activeProjectId);Q.useEffect(()=>{u&&(d&&p===null&&x(d,u,{silent:!0}),f&&f!==d&&m===null&&x(f,u,{silent:!0}))},[x,u,p,m,d,f]);let P=Q.useMemo(()=>{let e=kt(t);if(e){let t=M.find(t=>kt(t.path)===e);if(t)return t.id}return N},[N,t,M]),{localBranches:F,remoteBranches:I}=Q.useMemo(()=>t_(y?.all),[y]),L=b?.current?.trim()||S||null,R=!Qg(n,e)&&n||L||n||l(`chat.chatInput.branch`),ee=G(async()=>{if(!u)return;let e=new Set;d&&e.add(d),f&&e.add(f),await Promise.all([...e].map(async e=>{await vi(e,u),await x(e,u,{silent:!0})}))}),z=G(e=>{let t=n_(e),n=r_(t);return i.find(e=>{let r=e.label.trim();return r===t||r===n})??null}),B=G(async e=>{if(!f||!u)return;let t=n_(e);if(L!==t&&L!==r_(t))try{await u.checkoutBranch(f,t),Fi.success(l(`gitView.toast.checkedOut`,{name:t})),await ee()}catch(e){let n=e instanceof Error?e.message:l(`gitView.toast.checkoutFailed`,{name:t});Fi.error(n)}}),V=G(e=>{let t=n_(e);if(!t||L===t||L===r_(t))return;let n=z(t);if(n){a(n.value);return}D(t)}),H=G(async()=>{if(!(!E||O)){k(!0);try{await B(E),D(null)}finally{k(!1)}}}),U=G(async()=>{if(!(!E||O)){k(!0);try{await tl({branch:E,projectDirectory:t??void 0})&&D(null)}finally{k(!1)}}}),te=G(async(e,t)=>{if(!f||!u)return;let n=t?.name??`origin`;try{await u.createBranch(f,e,L??`HEAD`),Fi.success(l(`gitView.toast.createdBranch`,{name:e})),D(e),u.gitPush(f,{remote:n,branch:e,options:[`--set-upstream`]}).then(async()=>{await ee(),Fi.success(l(`gitView.toast.upstreamSet`,{branch:e,remote:n}))}).catch(async e=>{let t=e instanceof Error?e.message:l(`gitView.toast.branchCreatedLocally`);Fi.warning(l(`gitView.toast.branchCreatedLocally`),{description:(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:t})}),await ee()})}catch(e){let t=e instanceof Error?e.message:l(`gitView.toast.createBranchFailed`);throw Fi.error(t),e}}),ne=G(()=>{let e=Bn.getState(),n=kt(t),r=n?e.projects.find(e=>kt(e.path)===n)??null:null;r&&e.activeProjectId!==r.id&&e.setActiveProjectIdOnly(r.id),j(!0)}),re=G((e,n)=>{if(j(!1),n?.sessionId){Xr.getState().setCurrentSession(n.sessionId,e);return}let r=Bn.getState(),i=kt(t),a=(i?r.projects.find(e=>kt(e.path)===i)??null:null)?.id??r.activeProjectId??null,o=Xr.getState();if(o.newSessionDraft?.open){o.overrideNewSessionDraftTarget({...a?{selectedProjectId:a}:{},directoryOverride:e,bootstrapPendingDirectory:e,preserveDirectoryOverride:!0}),qe.getState().setDirectory(e,{showOverlay:!1});return}o.openNewSessionDraft({...a?{selectedProjectId:a}:{},directoryOverride:e,preserveDirectoryOverride:!0})}),W=(0,$.jsxs)(`button`,{type:`button`,className:J(`group relative inline-flex min-w-0 w-fit items-center gap-1.5 rounded-lg !border-0 px-1.5 font-medium text-foreground/80`,c===`mobile-sheet`?`h-[26px] text-[11px] leading-none`:`h-6 py-1 pr-1.5 typography-micro transition-[padding] hover:pr-5 focus-visible:pr-5 data-[popup-open]:pr-5`,s,gm,o),"aria-label":R,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:R}),c===`dropdown`?(0,$.jsx)(X,{name:`arrow-down-s`,className:`pointer-events-none absolute right-1 size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[popup-open]:opacity-100`,"aria-hidden":`true`}):null]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kc,{currentBranch:L,localBranches:F,remoteBranches:I,branchInfo:y?.branches,onCheckout:V,onCreate:te,remotes:T,trigger:W,triggerLabel:R,hideTooltip:!0,projectRootOption:r,worktreeOptions:i,selectedDirectory:e,onSelectDirectory:a,onCreateWorktree:ne,open:C,presentation:c,onOpenChange:w}),A?(0,$.jsx)(al,{open:!0,projectId:P,onOpenChange:j,onWorktreeCreated:re}):null,(0,$.jsx)(Ea,{open:!!E,onOpenChange:e=>{!e&&!O&&D(null)},children:(0,$.jsxs)(Sa,{showCloseButton:!1,className:`max-w-sm gap-4`,children:[(0,$.jsxs)(ba,{children:[(0,$.jsx)(Ca,{children:l(`chat.chatInput.branchSwitch.title`,{branch:E??``})}),(0,$.jsx)(wa,{children:l(`chat.chatInput.branchSwitch.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:O,onClick:()=>{H()},className:`flex w-full flex-col items-start gap-0.5 rounded-lg border border-border px-3 py-2.5 text-left hover:bg-interactive-hover disabled:opacity-50`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-ui-label font-medium text-foreground`,children:[O?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`arrow-left-right`,className:`size-3.5 text-muted-foreground`}),l(`chat.chatInput.branchSwitch.checkoutHere`)]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l(`chat.chatInput.branchSwitch.checkoutHereDescription`)})]}),(0,$.jsxs)(`button`,{type:`button`,disabled:O,onClick:()=>{U()},className:`flex w-full flex-col items-start gap-0.5 rounded-lg border border-border px-3 py-2.5 text-left hover:bg-interactive-hover disabled:opacity-50`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-ui-label font-medium text-foreground`,children:[O?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 text-muted-foreground`}),l(`chat.chatInput.branchSwitch.createWorktree`)]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l(`chat.chatInput.branchSwitch.createWorktreeDescription`)})]})]}),(0,$.jsx)(xa,{children:(0,$.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>D(null),className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 disabled:opacity-50`,children:l(`chat.chatInput.branchSwitch.cancel`)})})]})})]})},a_=[],o_=[],s_={revertMessageID:void 0,records:o_},c_=e=>e.role===`user`,l_=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.message!==t[n]?.message||e[n]?.parts!==t[n]?.parts)return!1;return!0},u_=(e,t,n=s_)=>{if(!t)return s_;let r=(`session`in e?e.session:[]).find(e=>e.id===t)?.revert?.messageID;if(!r)return s_;let i=`messages`in e?e.messages:e.message[t]??[],a=`partsByMessageID`in e?e.partsByMessageID:e.part,o=[];for(let e of i)!c_(e)||!le(i,e.id,r)||o.push({message:e,parts:a[e.id]??a_});let s=o.length===0?o_:o;return n.revertMessageID===r&&l_(n.records,s)?n:{revertMessageID:r,records:s}},d_=[`CodeFiles`,`codefiles`,`application/vnd.code.tree`,`application/vnd.code.tree.explorer`,`text/uri-list`,`text/plain`],f_=e=>e.startsWith(`/`)||e.startsWith(`//`)||e.startsWith(`\\\\`)||/^[A-Za-z]:[\\/]/.test(e),p_=e=>{if(/[\r\n]/.test(e)||!/\s/.test(e))return!1;let t=e.replace(/\\/g,`/`);if(!(t.startsWith(`//`)?t.replace(/^\/+/,``).includes(`/`):/^[A-Za-z]:\//.test(t)?t.slice(3).includes(`/`):t.startsWith(`/`)&&t.slice(1).includes(`/`)))return!1;if(t.endsWith(`/`))return!0;let n=t.split(`/`).filter(Boolean).pop()??``;return/\.[A-Za-z0-9]{1,8}$/.test(n)},m_=e=>{if(!f_(e))return!1;if(/\s/.test(e))return p_(e);if(e.startsWith(`//`)||e.startsWith(`\\\\`)){let t=e.replace(/^[\\/]+/,``);return/[\\/]/.test(t)}if(/^[A-Za-z]:[\\/]/.test(e)){let t=e.slice(3);return t.includes(`\\`)||t.includes(`/`)||t.includes(`.`)}return e.replace(/^\/+/,``).includes(`/`)},h_=(e,{fromPlainText:t=!1}={})=>{let n=e.trim().replace(/^['"]+|['"]+$/g,``);return!n||n===`/>`||/[\r\n]/.test(n)?null:n.toLowerCase().startsWith(`file://`)||(t?m_(n):f_(n))?n:null},g_=(e,t,n=0)=>{if(!(n>6||e==null)){if(typeof e==`string`){t.add(e);return}if(Array.isArray(e)){for(let r of e)g_(r,t,n+1);return}if(typeof e==`object`)for(let r of Object.values(e))g_(r,t,n+1)}},__=(e,{allowMultipleLines:t=!0,allowStructuredPayload:n=!0,fromPlainText:r=!1}={})=>{let i=new Set,a=e=>{let n=h_(e,{fromPlainText:r});if(n){i.add(n);return}if(t)for(let t of e.split(/\r?\n/)){let e=h_(t,{fromPlainText:r});e&&i.add(e)}};if(a(e),n)try{let t=JSON.parse(e),n=new Set;g_(t,n);for(let e of n)a(e)}catch{}return Array.from(i)},v_=e=>{if(!e||typeof e.getData!=`function`)return[];let t=new Set;for(let n of d_){let r=``;try{r=e.getData(n)}catch{continue}let i=n===`text/plain`?{allowMultipleLines:!1,allowStructuredPayload:!1,fromPlainText:!0}:n===`text/uri-list`?{allowStructuredPayload:!1}:void 0;for(let e of __(r,i))t.add(e)}return Array.from(t)},y_=e=>{let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return t;try{let e=new URL(t),n=decodeURIComponent(e.pathname||``);return e.hostname&&e.hostname!==`localhost`&&(n=`//${e.hostname}${n}`),/^\/[A-Za-z]:\//.test(n)&&(n=n.slice(1)),n||t}catch{let e=t.replace(/^file:\/\//i,``);try{return decodeURIComponent(e)}catch{return e}}},b_=e=>f_(e);function x_(e,t){let n=(0,Z.c)(4),r=xn(e,t),i=ln(S_),a=r.data??null,o;return n[0]!==i||n[1]!==r.error||n[2]!==a?(o={goal:a,enabled:i,error:r.error},n[0]=i,n[1]=r.error,n[2]=a,n[3]=o):o=n[3],o}function S_(e){return e.sessionGoalEnabled}var C_={active:`var(--status-info)`,paused:`var(--surface-muted-foreground)`,complete:`var(--status-success)`},w_={active:`chat.goal.status.active`,paused:`chat.goal.status.paused`,complete:`chat.goal.status.complete`};async function T_(e,t,n){let a=r(),o=i();await(t?oe.getScopedSdkClient(t):oe.getSdkClient()).session.command({sessionID:e,name:`goal`,text:n}),a===r()&&o===i()&&await cr(e,t)}var E_=(e,t,n)=>T_(e,t,n===`active`?`resume`:`pause`),D_=(e,t)=>T_(e,t,`clear`);function O_({open:e,onOpenChange:t,sessionId:n,directory:r}){let{t:i}=na(),a=ln(e=>e.isMobile),{goal:o,error:s}=x_(n,r),[c,l]=Q.useState(!1),u=G(async e=>{if(!c){l(!0);try{await e(),t(!1)}catch{Fi.error(i(`chat.goal.toast.actionFailed`))}finally{l(!1)}}}),d=i(`chat.goal.dialog.titleManage`),f=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[s&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:i(`chat.goal.toast.actionFailed`)}),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`max-h-48 overflow-y-auto whitespace-pre-wrap break-words typography-ui-label`,children:o.objective}),(0,$.jsxs)(`p`,{className:`typography-meta text-muted-foreground`,children:[i(w_[o.status]),` · `,o.rounds,`/`,o.maxRounds]}),o.reason&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o.reason}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[o.status!==`complete`&&(0,$.jsx)(Tr,{size:`sm`,disabled:c,onClick:()=>void u(()=>E_(n,r,o.status===`active`?`paused`:`active`)),children:i(o.status===`active`?`chat.goal.action.pause`:`chat.goal.action.resume`)}),(0,$.jsx)(Tr,{variant:`destructive`,size:`sm`,disabled:c,onClick:()=>void u(()=>D_(n,r)),children:i(`chat.goal.action.clear`)})]})]})]});return a?(0,$.jsx)(xu,{open:e,title:d,onClose:()=>t(!1),children:f}):(0,$.jsx)(Ea,{open:e,onOpenChange:t,children:(0,$.jsxs)(Sa,{className:`max-w-lg`,children:[(0,$.jsx)(ba,{children:(0,$.jsx)(Ca,{children:d})}),f]})})}var k_=Q.memo(({sessionId:e,directory:t,className:n})=>{let{t:r}=na(),{goal:i,enabled:a}=x_(e??``,t),[o,s]=Q.useState(!1),[c,l]=Q.useState(!1),u=G(async()=>{if(!(!e||!i||o||i.status===`complete`)){s(!0);try{await E_(e,t,i.status===`active`?`paused`:`active`)}catch{Fi.error(r(`chat.goal.toast.actionFailed`))}finally{s(!1)}}});return!e||!i||!a?null:(0,$.jsxs)(`div`,{className:J(`flex w-full min-w-0 items-center gap-1.5 py-0.5`,n),"aria-label":r(`chat.goal.row.aria`),children:[(0,$.jsx)(X,{name:`target`,className:`size-3.5 shrink-0`,style:{color:C_[i.status]},"aria-hidden":`true`}),(0,$.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left typography-ui-label`,onClick:()=>l(!0),title:i.objective,children:i.objective}),(0,$.jsx)(`span`,{className:`shrink-0 typography-meta text-muted-foreground`,children:r(w_[i.status])}),(0,$.jsxs)(`span`,{className:`shrink-0 typography-meta tabular-nums text-muted-foreground`,children:[i.rounds,`/`,i.maxRounds]}),i.status!==`complete`&&(0,$.jsxs)(Tr,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>void u(),children:[(0,$.jsx)(X,{name:i.status===`active`?`pause`:`play`,className:`size-3.5`,"aria-hidden":`true`}),r(i.status===`active`?`chat.goal.action.pause`:`chat.goal.action.resume`)]}),(0,$.jsx)(O_,{open:c,onOpenChange:l,sessionId:e,directory:t})]})});k_.displayName=`SessionGoalRow`;var A_=4e3,j_=Q.memo(({sessionId:e,directory:t,draftOpen:n=!1})=>{let{t:r}=na(),{goal:i,enabled:a}=x_(e??``,t),o=Tn(e=>e.armed),s=Tn(e=>e.setArmed),[c,l]=Q.useState(!1);if(!a||!e&&!n||!o&&!i)return null;let u=i?.status===`complete`?`text-[var(--status-success)]`:o||i?.status===`active`||i?.status===`paused`?`text-[var(--status-info)]`:``,d=async()=>{if(o){s(!1);return}if(!(!e||c)){l(!0);try{await D_(e,t)}catch(e){console.warn(`[session-goal] clear failed:`,e),Fi.error(r(`chat.goal.toast.actionFailed`))}finally{l(!1)}}};return(0,$.jsxs)(`span`,{className:J(`inline-flex h-7 items-center gap-1 rounded-full bg-[var(--surface-muted)] py-1 pl-2 pr-1 typography-ui-label`,u),children:[(0,$.jsx)(X,{name:`target`,className:`h-4 w-4`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:r(`chat.goal.chip.label`)}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-5 w-5 items-center justify-center rounded-full text-current hover:bg-[var(--interactive-hover)] disabled:opacity-50`,onClick:()=>void d(),disabled:c,"aria-label":r(o?`chat.goal.button.disarmAria`:`chat.goal.action.clear`),title:r(o?`chat.goal.button.disarmAria`:`chat.goal.action.clear`),children:(0,$.jsx)(X,{name:`close`,className:`h-3 w-3`,"aria-hidden":`true`})})]})});j_.displayName=`SessionGoalButton`;var M_=Q.memo(e=>{let t=(0,Z.c)(11),{length:n}=e,{t:r}=na();if(!Tn(N_)||n===0)return null;let i=n>4e3?`text-[var(--status-error)]`:`text-muted-foreground/70`,a;t[0]===i?a=t[1]:(a=J(`flex-shrink-0 self-center typography-micro tabular-nums`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=r(`chat.goal.counter.aria`),t[2]=r,t[3]=o);let s;t[4]===r?s=t[5]:(s=r(`chat.goal.counter.aria`),t[4]=r,t[5]=s);let c;return t[6]!==n||t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,$.jsxs)(`span`,{className:a,"aria-label":o,title:s,children:[n,`/`,A_]}),t[6]=n,t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c});M_.displayName=`SessionGoalObjectiveCounter`;function N_(e){return e.armed}var P_=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`timeline`,`model`,`summary`,`workspace-review`,`craft-goal`,`catch-up`,`debug`,`weigh`,`explore`,`btw`]),F_=new Set([`new`,`compact`,`reload`,`fork`,`undo`,`redo`]),I_=/^\/\u2003?([^\s]+)/i,L_=e=>e?.reloadEnabled??d(),R_=(e,t,n)=>{if(t!==`normal`)return null;let r=e.trimStart().match(I_)?.[1]?.toLowerCase();return!r||!P_.has(r)||r===`reload`&&!L_(n)?null:r},z_=(e,t,n)=>R_(e,t,n)!==null,B_=(e,t,n)=>{let r=R_(e,t,n);return r!==null&&F_.has(r)};function V_(e){if(R_(e.text,e.inputMode)!==`btw`)return!1;if(!e.allowed)return!0;if(!e.scope?.sessionId)return e.notify(`sessionRequired`),!0;if(e.hasReferences)return e.notify(`plainTextRequired`),!0;let t=e.text.trimStart().replace(/^\/\u2003?btw(?:\s|$)/i,``).trim();return t&&e.ask(e.scope,t),e.clearText(),e.open(),!0}var H_=({currentSessionId:e,messageRef:t,replacePlainDocument:n})=>{let r=e;return t.current=``,n(``),r},U_=async({command:e,consumeCommandText:t,forkSession:n,waitForConnection:r,getDirectoryForSession:i,summarizeSession:a,onCompactError:o,onForkError:s})=>{if(t(),e===`fork`){try{await n()}catch(e){s(e)}return}try{await r();let e=i();if(!e){o();return}await a(e)}catch{o()}},W_=e=>!e.queuedOnly&&!e.resourcePolicy&&e.rootAttachmentCount>0,G_=e=>e.surfaceKind===`primary`&&!!e.currentSessionId&&!e.queuedOnly&&e.delivery!==`queue`&&!e.resourcePolicy&&e.inputMode!==`shell`&&!e.localCommand&&!e.nativeGoal,K_=e=>e.surfaceKind!==`primary`||!e.stagedSessionId||!e.stagedMessageId||e.stagedMessageId!==e.blurredMessageId||e.submitInFlight||e.focusHeld||e.overlayOpen||e.focusInsideComposer?{action:`keep`}:{action:`disarm`,sessionId:e.stagedSessionId},q_=e=>({state:`bound`,transportIdentity:e.transportIdentity,directory:e.directory,sessionID:e.sessionID,deliveryTarget:{kind:`primary`},runtimeGeneration:e.runtimeGeneration}),J_=(e,t)=>{let n=tt.getState();return n.bindLegacyQueue(st(e.sessionID),e),n.stageAdmission(e,{requestID:t.requestID,queueItemID:t.queueItemID,operationID:t.operationID,messageID:t.messageID,content:t.content,createdAt:t.createdAt,attachmentCount:t.attachments.length,...t.composerDocument?{composerDocument:t.composerDocument}:{},...t.composerMentions?{composerMentions:t.composerMentions}:{}}),n.confirmAdmission(e,{requestID:t.requestID,sendConfig:t.sendConfig,attachments:t.attachments}).ok},Y_=async e=>{let t=ir.getState().takeEstablishingPending(e.draftID);if(t.length===0)return{drained:0,failed:0};let n=q_(e),r=0,i=0;for(let a of t)try{if(e.admitServer&&(await e.admitServer(a)).status===`committed`){r+=1;continue}J_(n,a)?r+=1:i+=1}catch{try{J_(n,a)?r+=1:i+=1}catch{i+=1}}return{drained:r,failed:i}},X_=(e,t)=>Promise.resolve().then(()=>e()).catch(()=>{t()}),Z_=e=>{let t=e.ctrlEnter&&e.canQueue&&e.primary&&e.sessionIsRunning;return e.followUpBehavior===`queue`?t?{kind:`submit`,steerAfterAdmit:!0}:e.ctrlEnter||!e.canQueue?{kind:`submit`}:e.primary?{kind:`submit`,delivery:`queue`}:e.queueUsable?{kind:`queue`}:{kind:`submit`,delivery:`steer`}:t?{kind:`submit`,steerAfterAdmit:!0}:e.ctrlEnter||!e.canQueue?{kind:`submit`}:{kind:`submit`,delivery:`steer`}},Q_=e=>Object.prototype.hasOwnProperty.call(e,`permissions`)?e.permissions:e.permission,$_=e=>{let t=Sd(e);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n){if(n.action===`*`&&n.resource===`*`)return n.effect===`ask`;if(n.effect===`ask`)return!0}}return!0},ev=(e,t)=>{let n=t?.trim();if(!n)return e.length===0||e.some(e=>$_(Q_(e)));let r=e.find(e=>e?.name===n);return!r||$_(Q_(r))},tv=e=>{let{permissionScopeSessionId:t,newSessionDraftOpen:n,draftPermissionAutoAcceptEnabled:r,permissionAutoAcceptEnabled:i,setDraftPermissionAutoAcceptEnabled:a,setSessionAutoAccept:o,onOpenSessionFirst:s,onToggleFailed:c}=e;if(!t){if(!n){s();return}a(!r);return}o(t,!i).catch(c)},nv=(e,t,n)=>{let r=e.agent;r&&r!==t.currentAgentName&&t.setAgent(r),e.providerID&&t.setProvider(e.providerID),e.modelID&&t.setModel(e.modelID),t.setCurrentVariant(e.variant);let i=r??t.currentAgentName;i&&e.providerID&&e.modelID&&t.saveAgentModelSelection(i,e.providerID,e.modelID,e.variant);let a=n?.sessionId,o=n?.memory;!a||!o||!e.providerID||!e.modelID||(o.saveSessionModelSelection(a,e.providerID,e.modelID),i&&o.saveSessionAgentSelection&&o.saveSessionAgentSelection(a,i),i&&(o.saveAgentModelForSession(a,i,e.providerID,e.modelID),o.saveAgentModelVariantForSession(a,i,e.providerID,e.modelID,e.variant)))},rv=(e,t,n)=>{let r=e.providers.find(e=>e.id===t);return r?(Array.isArray(r.models)?r.models:[]).some(e=>e.id===n):!1},iv=(e,t)=>e.agents.some(e=>e.name===t),av=(e,t,n,r)=>{if(!r)return!0;let i=e.providers.find(e=>e.id===t)?.models?.find(e=>e.id===n)?.variants;return i?Array.isArray(i)?i.includes(r):typeof i==`object`&&Object.prototype.hasOwnProperty.call(i,r):!1},ov=e=>{let{catalog:t,providerID:n,modelID:r,historyVariant:i,memoryVariant:a}=e;if(i)return av(t,n,r,i)?i:void 0;if(a&&av(t,n,r,a))return a},sv=e=>{let{sessionId:t,choice:n,catalog:r,memory:i,fallbackAgentName:a,source:o}=e;if(!n.providerID||!n.modelID||!rv(r,n.providerID,n.modelID))return null;let s=n.agent&&iv(r,n.agent)?n.agent:i?.getSessionAgentSelection?.(t)&&iv(r,i.getSessionAgentSelection(t))?i.getSessionAgentSelection(t):a&&iv(r,a)?a:void 0,c=s?i?.getAgentModelVariantForSession?.(t,s,n.providerID,n.modelID):void 0,l=ov({catalog:r,providerID:n.providerID,modelID:n.modelID,historyVariant:n.variant,memoryVariant:c});return{agent:s,providerID:n.providerID,modelID:n.modelID,variant:l,source:o,messageId:n.id}},cv=e=>{let{sessionId:t,latestUserChoice:n,latestExecution:r,catalog:i,memory:a,sessionEntity:o,fallbackAgentName:s,transcriptReady:c=!0}=e;if(c&&r){let e=sv({sessionId:t,choice:r,catalog:i,memory:a,fallbackAgentName:s,source:`execution`});if(e)return e}if(c&&n){let e=sv({sessionId:t,choice:n,catalog:i,memory:a,fallbackAgentName:s,source:`history`});if(e)return e}if(c&&a){let e=a.getSessionAgentSelection?.(t)??null,n=e&&iv(i,e)?e:s&&iv(i,s)?s:void 0;if(n){let e=a.getAgentModelForSession?.(t,n);if(e&&rv(i,e.providerId,e.modelId)){let r=a.getAgentModelVariantForSession?.(t,n,e.providerId,e.modelId),o=r&&av(i,e.providerId,e.modelId,r)?r:void 0;return{agent:n,providerID:e.providerId,modelID:e.modelId,variant:o,source:`session-memory`}}}let r=a.getSessionModelSelection?.(t);if(r&&rv(i,r.providerId,r.modelId)){let e=n?a.getAgentModelVariantForSession?.(t,n,r.providerId,r.modelId):void 0,o=e&&av(i,r.providerId,r.modelId,e)?e:void 0;return{agent:n,providerID:r.providerId,modelID:r.modelId,variant:o,source:`session-memory`}}}let l=o?.model;if(l&&rv(i,l.providerID,l.id)){let e=a?.getSessionAgentSelection?.(t)??null,n=(o?.agent&&iv(i,o.agent)?o.agent:void 0)??(e&&iv(i,e)?e:s&&iv(i,s)?s:void 0),r=l.variant,c=r&&av(i,l.providerID,l.id,r)?r:void 0;return{agent:n,providerID:l.providerID,modelID:l.id,variant:c,source:`session-entity`}}return null},lv=(e,t,n)=>{let r=e.agent;r&&r!==t.currentAgentName&&t.setAgent(r),e.providerID&&t.setProvider(e.providerID),e.modelID&&t.setModel(e.modelID),t.setCurrentVariant(e.variant);let{sessionId:i,memory:a}=n;a.saveSessionModelSelection(i,e.providerID,e.modelID);let o=r??t.currentAgentName;o&&a.saveSessionAgentSelection&&a.saveSessionAgentSelection(i,o),o&&(a.saveAgentModelForSession(i,o,e.providerID,e.modelID),a.saveAgentModelVariantForSession(i,o,e.providerID,e.modelID,e.variant))},uv=(e,t)=>{if((t?.expectedConfigKey===void 0||t.activeDirectoryKey===t.expectedConfigKey)&&!(!e.currentProviderId||!e.currentModelId))return{providerID:e.currentProviderId,modelID:e.currentModelId,agent:e.currentAgentName,variant:e.currentVariant}},dv=e=>e.editRevision<=0?!1:e.pinnedHistoryMessageId==null||e.latestHistoryMessageId==null||e.latestHistoryMessageId===e.pinnedHistoryMessageId,fv=e=>{if(e.captured?.providerID&&e.captured?.modelID)return e.captured;let t=e.surfaceSelection;if(!(!t?.providerID||!t?.modelID))return{providerID:t.providerID,modelID:t.modelID,...t.agent?{agent:t.agent}:{},...t.variant?{variant:t.variant}:{}}},pv=e=>typeof e==`string`&&e.trim().length>0?e:void 0,mv=e=>pv(e.agent)??pv(e.mode),hv=e=>pv(typeof e.model==`object`?e.model?.variant:void 0)??pv(e.variant),gv=e=>{let t=typeof e.model==`object`?e.model:void 0,n=pv(e.providerID)??pv(t?.providerID),r=pv(e.modelID)??pv(t?.modelID)??pv(t?.id);return!n||!r?null:{providerID:n,modelID:r}},_v=e=>gv(e),vv=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`||n.nativeType===`synthetic`||n.type===`synthetic`)continue;let r=gv(n);return{id:typeof n.id==`string`?n.id:void 0,agent:mv(n),providerID:r?.providerID,modelID:r?.modelID,variant:hv(n)}}return null},yv=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.nativeType===`synthetic`||n.type===`synthetic`)continue;if(n.role===`user`){if(gv(n))return null;continue}if(n.role!==`assistant`)continue;let r=_v(n);if(r)return{id:typeof n.id==`string`?n.id:void 0,agent:mv(n),providerID:r.providerID,modelID:r.modelID,variant:hv(n)}}return null},bv=500,xv=e=>Array.from(e).length,Sv=e=>{let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return(t>>>0).toString(36)},Cv=e=>xv(e)>=bv,wv=e=>{let t=Be(e.text,e.references).document.references,n=t.reduce((e,t)=>{let n=t.kind===`paste`?t.index:0;return typeof n==`number`&&Number.isSafeInteger(n)&&n>=1?Math.max(e,n):e},0);if(n<2**53-1)return n+1;let r=new Set(t.flatMap(e=>e.kind===`paste`&&typeof e.index==`number`&&Number.isSafeInteger(e.index)&&e.index>=1?[e.index]:[]));for(let e=1;e<=t.length+1;e+=1)if(!r.has(e))return e;return 1},Tv=(e,t)=>{let n=t??e;return typeof n!=`string`||!Cv(n)?!1:et(typeof e==`string`?{text:``,references:[]}:e,n)},Ev=(e,t,n,r,i=1)=>{let a=xv(e),o=new Set(n.map(e=>e.token));for(let n=i;n<2**53-1;n+=1){let i=`[${r({index:n,count:a})}]`;if(!(t.includes(i)||o.has(i)))return{id:`pasted-text-${n}-${Sv(e)}`,token:i,text:e,characterCount:a,index:n}}throw Error(`Unable to create a unique pasted text reference`)},Dv=e=>({text:e?.text??``,references:e?.composerReferences??[]}),Ov=e=>({text:e.text,references:e.references.map(e=>({...e}))}),kv=e=>({transportIdentity:e.transportIdentity,owner:{...e.owner}}),Av=e=>JSON.stringify([e.text,e.references]),jv=(e,t)=>e!==null&&t!==null&&ft(e)===t,Mv=(e,t,n)=>{let r=e?kv(e):null,i=r?n(r):void 0;return{document:ut(Dv(i),t),mentions:i?.mentions??[],revision:i?.revision??0,key:r,keyID:r?ft(r):null}},Nv=(e,t,n,r)=>{if(!t||ft(t.key)!==r.keyID||t.revision<r.appliedRevision)return`ignore`;let i=Av(Dv(t));return n?.keyID===r.keyID&&n.revision===t.revision&&n.fingerprint===i?`local-echo`:t.revision===r.appliedRevision?`ignore`:i===Av(e)?`same-document-metadata`:`external-document`},Pv=(e,t,n)=>{let r=n.newEnd-n.oldEnd;return e.flatMap(e=>{if(e.range.start<n.oldEnd&&e.range.end>n.oldStart)return[];let i=e.range.start>=n.oldEnd?{start:e.range.start+r,end:e.range.end+r}:e.range;return t.text.slice(i.start,i.end)===`@${e.value}`?[{...e,range:i}]:[]})},Fv=e=>e.map((e,t)=>({mention:e,index:t})).sort((e,t)=>e.mention.range.start-t.mention.range.start||e.mention.range.end-t.mention.range.end||e.index-t.index).map(({mention:e})=>e),Iv=(e,t,n,r,i=r)=>{let a=lt(e,n,r,i);return{document:a.document,mentions:Pv(t,a.document,a.edit),requiresTextCorrection:a.requiresTextCorrection,selectionStart:a.selectionStart,selectionEnd:a.selectionEnd,removedReferences:a.removedReferences}},Lv=(e,t,n)=>({preview:{real:Ov(e),realMentions:[...t]},document:{text:n.text,references:[]},mentions:[]}),Rv=e=>({document:e.real,mentions:e.realMentions}),zv=(e,t,n,r)=>{let i=[...e,...t.map(e=>({...e,range:{start:e.range.start+r,end:e.range.end+r}}))],a=new Set;return i.filter(e=>{let t=`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return a.has(t)||n.text.slice(e.range.start,e.range.end)!==`@${e.value}`?!1:(a.add(t),!0)})},Bv=(e,t)=>{let n=Dv(t),r=Ke(e.document,n),i=e.document.text===n.text&&JSON.stringify(e.document.references)===JSON.stringify(n.references)?0:e.document.text.length+2;return{document:r,mentions:zv(e.mentions,t?.mentions??[],r,i)}},Vv=({draftKey:e,sessionTitles:t,persistenceEnabled:n,onResourcesChanged:r,store:i=ra})=>{let a=e?ft(e):null,o=(0,Q.useSyncExternalStore)(i.subscribe,()=>a?i.getState().drafts[a]:void 0,()=>void 0),s=(0,Q.useSyncExternalStore)(i.subscribe,()=>a?i.getState().draftHydration[a]??`idle`:`idle`,()=>`idle`),c=(0,Q.useSyncExternalStore)(i.subscribe,()=>a?i.getState().draftPersistence[a]:void 0,()=>void 0),[l,u]=(0,Q.useState)(()=>Mv(e,t,i.getState().getDraft).document),[d,f]=(0,Q.useState)(()=>Mv(e,t,i.getState().getDraft).mentions),[p,m]=(0,Q.useState)(`compose`),[h,g]=(0,Q.useState)(0),_=(0,Q.useRef)(l),v=(0,Q.useRef)(d),y=(0,Q.useRef)(t),b=(0,Q.useRef)(r),x=(0,Q.useRef)(e),S=(0,Q.useRef)(e?kv(e):null),C=(0,Q.useRef)(a),w=(0,Q.useRef)(a),T=(0,Q.useRef)(0),E=(0,Q.useRef)(o?.revision??0),D=(0,Q.useRef)(void 0),O=(0,Q.useRef)(void 0),k=(0,Q.useRef)(Ic());_.current=l,v.current=d,y.current=t,b.current=r,x.current=e,C.current=a;let A=(0,Q.useCallback)((e,t)=>{_.current=e,v.current=t,u(e),f(t)},[]),j=(0,Q.useCallback)((e,t)=>{let n=Le(e,t);b.current?.(n)},[]);(0,Q.useEffect)(()=>{i.getState().setDraftPersistenceEnabled(n)},[n,i]),(0,Q.useLayoutEffect)(()=>{T.current+=1;let e=T.current;w.current=a;let t=Mv(x.current,y.current,i.getState().getDraft),n=t.key;if(S.current=t.key,D.current=void 0,O.current=void 0,k.current=Ic(),m(`compose`),E.current=t.revision,A(t.document,t.mentions),g(e=>e+1),n?.owner.kind===`draft`){let r=t.revision;i.getState().claimLegacyNewDraft(n).then(t=>{let o=i.getState().getDraft(n);!t||!jv(S.current,a)||w.current!==a||C.current!==a||T.current!==e||E.current!==r||o?.revision!==t.revision||(E.current=t.revision,A(ut(Dv(t),y.current),t.mentions))})}},[a,A,i]),(0,Q.useEffect)(()=>{if(!a||w.current!==a||O.current)return;let e=Nv(_.current,o,D.current,{keyID:a,epoch:T.current,appliedRevision:E.current});if(e!==`ignore`){if(o&&(E.current=o.revision),e===`local-echo`||e===`same-document-metadata`){o&&f(o.mentions);return}e===`external-document`&&o&&(D.current=void 0,A(ut(Dv(o),y.current),o.mentions),m(`compose`),g(e=>e+1))}},[a,A,o]);let M=(0,Q.useCallback)((e,t)=>{let n=S.current;if(!jv(n,C.current)||O.current)return;let r=_.current,a=i.getState().setDraftComposerState(n,{document:e,mentions:Fv(t)});if(!a)return;let o=Dv(a);return D.current={keyID:ft(n),revision:a.revision,fingerprint:Av(o)},E.current=a.revision,A(o,a.mentions),j(r,o),a},[i,A,j]),N=(0,Q.useCallback)((e,t,n,r,i,a)=>{k.current=zc(k.current,{before:Vc(e,t,n),after:Vc(r,i,a)})},[]),P=(0,Q.useCallback)(()=>O.current?(O.current=void 0,m(`compose`),!0):!1,[]),F=(0,Q.useCallback)(e=>(P(),M({text:e,references:[]},[])),[M,P]),I=(0,Q.useCallback)((e,t=[])=>{P();let n=pt(e.text,e.references);return n?M(ut(n,y.current),t):void 0},[M,P]),L=(0,Q.useCallback)((e,t,n=t,r)=>{let i=P(),a=Ov(_.current),o=i?[]:v.current,s=Iv(a,o,e,t,n),c=r?r(s.mentions,s.document):s.mentions;return M(s.document,c),s.removedReferences.length>0&&N(a,o,{start:s.selectionStart,end:s.selectionEnd},s.document,c,{start:s.selectionStart,end:s.selectionEnd}),{start:s.selectionStart,end:s.selectionEnd,requiresTextCorrection:s.requiresTextCorrection}},[M,P,N]),R=(0,Q.useCallback)((e,t)=>{let n=_.current,r=Math.max(0,Math.min(e.start,n.text.length)),i=Math.max(r,Math.min(e.end,n.text.length)),a=P(),o=lt(n,`${n.text.slice(0,r)}${e.text}${n.text.slice(i)}`,r+e.text.length),s=Pv(a?[]:v.current,o.document,o.edit);return M(o.document,t?t(s,o.document):s),{start:o.selectionStart,end:o.selectionEnd}},[M,P]),ee=(0,Q.useCallback)((e,t)=>{let n=_.current;return R({start:0,end:n.text.length,text:e},t)},[R]),z=(0,Q.useCallback)((e,t,n,r)=>{let i=P(),a=ct(_.current,e,t,n,r);return M(a.document,Pv(i?[]:v.current,a.document,a.edit)),{start:a.caret,end:a.caret,caret:a.caret,document:a.document}},[M,P]),B=(0,Q.useCallback)(e=>{let t=Ov(_.current),n=Je(t,e);if(!n)return null;let r=P()?[]:v.current,i=Pv(r,n.document,n.edit),a=ze(n.document.text,n.caret),o=lt(n.document,a.text,a.caret),s=Pv(i,o.document,o.edit);return M(o.document,s),N(t,r,{start:e.selectionStart,end:e.selectionEnd},o.document,s,{start:o.selectionStart,end:o.selectionEnd}),{start:o.selectionStart,end:o.selectionEnd}},[M,P,N]),V=(0,Q.useCallback)(e=>{if(O.current)return null;let t=e===`undo`?kc(k.current,_.current):Nc(k.current,_.current);return!t||!M(t.snapshot.document,t.snapshot.mentions)?null:(k.current=t.history,t.snapshot.selection)},[M]),H=(0,Q.useCallback)(e=>M(_.current,e),[M]),U=(0,Q.useCallback)(e=>{let t=O.current?{document:{text:e.text,references:[]},mentions:[]}:Lv(_.current,v.current,e);`preview`in t&&(O.current=t.preview),m(`history-preview`),A(t.document,t.mentions),g(e=>e+1)},[A]),te=(0,Q.useCallback)(()=>{let e=O.current;if(!e)return;O.current=void 0,m(`compose`);let t=Rv(e);A(t.document,t.mentions),g(e=>e+1)},[A]),ne=(0,Q.useCallback)(()=>{let e=S.current;if(!jv(e,C.current))return null;let t=i.getState().getDraft(e);return{key:kv(e),keyID:ft(e),revision:t?.revision??0,document:Ov(_.current),mentions:v.current.map(e=>({...e,range:{...e.range}})),epoch:T.current,runtime:i.getState().captureDraftRuntime()}},[i]),re=(0,Q.useCallback)(e=>{let t=Bv(e,i.getState().getDraft(e.key)),n=Dv(i.getState().getDraft(e.key)),r=Be(n.text,n.references).document,a=i.getState().setDraftComposerState(e.key,{...t,mentions:Fv(t.mentions)});if(a){let e=Dv(a);j(r,e)}return a},[j,i]),W=(0,Q.useCallback)(()=>_.current,[]);return(0,Q.useMemo)(()=>({document:l,mentions:d,confirmedFileMentions:d.filter(e=>e.kind===`file`||e.kind===`directory`),inputMode:p,hydration:s,persistence:c,textPresetEpoch:h,getDocument:W,replacePlainDocument:F,replaceMaterializedDocument:I,applyBrowserEdit:L,applyProgrammaticEdit:R,replaceProgrammaticText:ee,insertReference:z,deleteReference:B,restoreReferenceHistory:V,commitMentions:H,enterHistoryPreview:U,exitHistoryPreview:te,captureSubmission:ne,recoverSubmission:re}),[L,R,ne,H,B,l,U,te,W,s,p,z,d,c,re,I,F,ee,V,h])};function Hv(e){let t=e.maxLines??8,n=e.lineHeight*t+e.paddingTotal,r=Math.max(e.scrollHeight,e.dictationHeight);return{height:Math.min(r,n),maxHeight:n,overflowY:r>n?`auto`:`hidden`}}function Uv(e){let t=(0,Z.c)(22),{inputRef:n,message:r,expanded:i,isMobile:a,dictationHeight:o,manualHeight:s}=e,c=s!==void 0&&s,[l,u]=(0,Q.useState)(null),d=(0,Q.useRef)(null),f;t[0]!==o||t[1]!==i||t[2]!==n||t[3]!==c?(f=e=>{let t=n.current;if(!t||c)return;let r=t.scrollTop;if(i){t.style.height=`100%`,t.style.maxHeight=`none`,t.style.overflowY=`auto`,u(null),t.scrollTop!==r&&(t.scrollTop=r);return}t.style.overflow=`hidden`,t.style.overflowX=`hidden`,t.style.overflowY=`hidden`,(e?.allowShrink??!0)&&(t.style.height=`auto`);let a=t.ownerDocument?.defaultView,s=a?a.getComputedStyle(t):null,l=s?parseFloat(s.lineHeight):NaN,d=s?parseFloat(s.paddingTop):NaN,f=s?parseFloat(s.paddingBottom):NaN,p=Number.isNaN(d)||Number.isNaN(f)?16:d+f,m=Hv({scrollHeight:t.scrollHeight||t.offsetHeight,dictationHeight:o??0,lineHeight:Number.isNaN(l)?22:l,paddingTotal:p});t.style.height=`${m.height}px`,t.style.maxHeight=`${m.maxHeight}px`,t.style.overflowY=m.overflowY,t.scrollTop!==r&&(t.scrollTop=r),u(e=>e?.height===m.height&&e.maxHeight===m.maxHeight?e:{height:m.height,maxHeight:m.maxHeight})},t[0]=o,t[1]=i,t[2]=n,t[3]=c,t[4]=f):f=t[4];let p=G(f),m=c?null:r,h;t[5]!==m?.length||t[6]!==o||t[7]!==i||t[8]!==c||t[9]!==p?(h=()=>{let e=d.current,t=m?.length??0,n=!e||e.manualHeight||t<e.length||i!==e.expanded||e.dictationHeight!==null&&o===null;d.current={length:t,expanded:i,dictationHeight:o,manualHeight:c},p({allowShrink:n})},t[5]=m?.length,t[6]=o,t[7]=i,t[8]=c,t[9]=p,t[10]=h):h=t[10];let g;t[11]!==m||t[12]!==o||t[13]!==i||t[14]!==n||t[15]!==a||t[16]!==c||t[17]!==p?(g=[m,i,a,o,c,n,p],t[11]=m,t[12]=o,t[13]=i,t[14]=n,t[15]=a,t[16]=c,t[17]=p,t[18]=g):g=t[18],(0,Q.useLayoutEffect)(h,g);let _;return t[19]!==p||t[20]!==l?(_={size:l,resize:p},t[19]=p,t[20]=l,t[21]=_):_=t[21],_}var Wv=()=>{let e=document.documentElement.classList;return e.contains(`yuri-native-ime`)&&!e.contains(`yuri-platform-android`)},Gv=()=>parseFloat(document.documentElement.style.getPropertyValue(`--yuri-native-ime-lift`))||0;function Kv(e){let t=(0,Z.c)(26),{enabled:n,hasContent:r,draftID:i,inputRef:a}=e,o=n&&r,s;t[0]===a?s=t[1]:(s=()=>{let e=a.current;if(!e)return[];let t=e.closest(`[data-mobile-composer-surface]`)??e,n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=getComputedStyle(e),o=parseFloat(i.lineHeight)||22,s=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0),c=Math.max(parseFloat(i.minHeight)||0,o+s),l=window.visualViewport,u=Wv(),d=u?Gv():0,f=u?d:l?.offsetTop??0;for(let e=t.parentElement;e;e=e.parentElement){let t=e.querySelector(`.yuri-mobile-detail-navigation, [data-mobile-chat-header]`);if(t){f=Math.max(f,t.getBoundingClientRect().bottom+d);break}}let p=u?r.bottom:Math.min(r.bottom,(l?.offsetTop??0)+(l?.height??window.innerHeight)),m=r.height-n.height,h=Math.max(c,p-f-m),g=e.style.height,_=e.scrollTop;e.style.height=`0px`;let v=Hv({scrollHeight:e.scrollHeight,dictationHeight:0,lineHeight:o,paddingTotal:s}).height;return e.style.height=g,e.scrollTop=_,[{id:`auto`,height:Math.min(h,Math.max(c,v))},{id:`min`,height:c},{id:`full`,height:h}]},t[0]=a,t[1]=s);let c;t[2]!==a||t[3]!==s?(c={surfaceRef:a,initialPoint:`auto`,getPoints:s},t[2]=a,t[3]=s,t[4]=c):c=t[4];let l=ua(c),{reset:u}=l,d;t[5]===u?d=t[6]:(d=()=>{u()},t[5]=u,t[6]=d);let f;t[7]!==o||t[8]!==i||t[9]!==u?(f=[o,i,u],t[7]=o,t[8]=i,t[9]=u,t[10]=f):f=t[10],(0,Q.useLayoutEffect)(d,f);let p;t[11]!==o||t[12]!==l?(p=()=>{o&&l.snapPoint===`full`&&l.settleAt(`full`,void 0,!1)},t[11]=o,t[12]=l,t[13]=p):p=t[13];let m=G(p),h;t[14]===o?h=t[15]:(h=()=>o?window:null,t[14]=o,t[15]=h),tn(`resize`,m,h);let g;t[16]===o?g=t[17]:(g=()=>o?window:null,t[16]=o,t[17]=g),tn(`yuri:keyboard-settled`,m,g);let _;t[18]===o?_=t[19]:(_=()=>o?window.visualViewport:null,t[18]=o,t[19]=_),tn(`resize`,m,_);let v;t[20]===o?v=t[21]:(v=()=>o?window.visualViewport:null,t[20]=o,t[21]=v),tn(`scroll`,m,v);let y=o&&(l.dragging||l.settling||l.snapPoint!==`auto`),b;return t[22]!==o||t[23]!==l||t[24]!==y?(b={...l,visible:o,manualHeight:y},t[22]=o,t[23]=l,t[24]=y,t[25]=b):b=t[25],b}var qv=(0,Q.memo)(function(e){let t=(0,Z.c)(23),{inputRef:n,draftID:r,ariaLabel:i,onManualHeightChange:a}=e,o=(0,Q.useRef)(null),s;t[0]!==r||t[1]!==n?(s={enabled:!0,hasContent:!0,draftID:r,inputRef:n},t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=Kv(s),{snapPoint:l,manualHeight:u,dragging:d,settling:f}=c,p,m;t[3]!==d||t[4]!==u||t[5]!==a||t[6]!==f||t[7]!==l?(p=()=>{let e=o.current?.closest(`[data-mobile-composer-surface]`);e&&(e.dataset.composerHeightSnap=l,e.toggleAttribute(`data-composer-height-manual`,u),d||f?e.dataset.mobileComposerResizing=`true`:delete e.dataset.mobileComposerResizing),a(u)},m=[l,u,d,f,a],t[3]=d,t[4]=u,t[5]=a,t[6]=f,t[7]=l,t[8]=p,t[9]=m):(p=t[8],m=t[9]),(0,Q.useLayoutEffect)(p,m);let h,g;t[10]===a?(h=t[11],g=t[12]):(h=()=>{let e=o.current?.closest(`[data-mobile-composer-surface]`);return()=>{e?.removeAttribute(`data-composer-height-snap`),e?.removeAttribute(`data-composer-height-manual`),e?.removeAttribute(`data-mobile-composer-resizing`),a(!1)}},g=[a],t[10]=a,t[11]=h,t[12]=g),(0,Q.useLayoutEffect)(h,g);let _=l===`min`?0:l===`auto`?1:2,v;return t[13]!==i||t[14]!==c.handleClick||t[15]!==c.handleKeyDown||t[16]!==c.handleLostPointerCapture||t[17]!==c.handlePointerCancel||t[18]!==c.handlePointerDown||t[19]!==c.handlePointerMove||t[20]!==c.handlePointerUp||t[21]!==_?(v=(0,$.jsx)(la,{ref:o,"data-mobile-composer-snap-handle":!0,"aria-label":i,"aria-valuemin":0,"aria-valuemax":2,"aria-valuenow":_,className:`absolute top-1 left-1/2 z-40 h-2.5 w-20 -translate-x-1/2 items-center`,onPointerDown:c.handlePointerDown,onPointerMove:c.handlePointerMove,onPointerUp:c.handlePointerUp,onPointerCancel:c.handlePointerCancel,onLostPointerCapture:c.handleLostPointerCapture,onClick:c.handleClick,onKeyDown:c.handleKeyDown}),t[13]=i,t[14]=c.handleClick,t[15]=c.handleKeyDown,t[16]=c.handleLostPointerCapture,t[17]=c.handlePointerCancel,t[18]=c.handlePointerDown,t[19]=c.handlePointerMove,t[20]=c.handlePointerUp,t[21]=_,t[22]=v):v=t[22],v}),Jv=.5,Yv=`--yuri-mobile-composer-swap`,Xv=`--yuri-native-composer-dock`,Zv=()=>({phase:`rest`,rest:`expanded`,progress:0,pinned:!1}),Qv=(e,t,n)=>Math.min(n,Math.max(t,e)),$v=(e,t)=>e.phase===t.phase&&e.rest===t.rest&&e.progress===t.progress&&e.pinned===t.pinned,ey=(e,t)=>{let n={phase:t.phase,rest:t.rest,progress:t.progress,pinned:t.pinned??e.pinned};return $v(e,n)?e:n},ty=(e,t)=>t?ey(e,{phase:`rest`,rest:`expanded`,progress:0,pinned:!0}):e.pinned?ey(e,{phase:`rest`,rest:`expanded`,progress:0,pinned:!1}):e,ny=(e,t)=>{if(e.pinned&&t===`compact`)return e;let n=+(t===`compact`);return e.phase===`rest`&&e.rest===t&&e.progress===n?e:ey(e,{phase:`snapping`,rest:t,progress:n})},ry=e=>Math.round(Qv(e,0,1)*1e3)/1e3,iy=(e,t,n)=>{let r=n-t;if(r>=0)return ry(e+r/80);if(n<=2)return 0;if(n>=120)return e;let i=e+r/80,a=n/t*e;return ry(Math.min(i,a))},ay=(e,t)=>e>=1?`compact`:e<=0?`expanded`:t,oy=(e,t,n={})=>{if(e.pinned||n.userDriven===!1)return e;let r=Math.max(0,t),i=n.previousDistance==null?r:Math.max(0,n.previousDistance),a=e.phase===`snapping`?ey(e,{phase:`rest`,rest:e.rest,progress:+(e.rest===`compact`)}):e;if(r<=2)return ey(a,{phase:`rest`,rest:`expanded`,progress:0});if(n.suppressReturn&&a.rest===`compact`&&r<i)return ey(a,{phase:`rest`,rest:`compact`,progress:1});let o=iy(a.progress,i,r);return e.phase===`snapping`&&o===a.progress?e:o===a.progress?a:Math.abs(o-a.progress)>=Jv&&(o>=1||o<=0)?ey(a,{phase:`snapping`,rest:o>=1?`compact`:`expanded`,progress:o}):o>=1||o<=0?ey(a,{phase:`rest`,rest:ay(o,a.rest),progress:o}):ey(a,{phase:`tracking`,rest:a.rest,progress:o})},sy=(e,t=null)=>e.pinned?`expanded`:t||(e.progress>=.5?`compact`:`expanded`),cy=(e,t=null)=>{if(e.pinned)return ey(e,{phase:`rest`,rest:`expanded`,progress:0,pinned:!0});if(e.phase===`snapping`)return e;let n=sy(e,t),r=+(n===`compact`);return e.phase===`rest`&&e.rest===n&&e.progress===r?e:ey(e,{phase:`snapping`,rest:n,progress:r})},ly=e=>e.phase===`snapping`?ey(e,{phase:`rest`,rest:e.rest,progress:+(e.rest===`compact`)}):e,uy=e=>Qv(Math.max(0,e)/80,0,1),dy=(e,t=`away`)=>{let n=Math.max(0,e);return n<=2?{progress:0,rest:`bottom`}:t===`away`||n>=40?{progress:1,rest:`away`}:{progress:uy(n),rest:`bottom`}},fy=`--yuri-mobile-composer-occupancy`,py=(e,t)=>{if(!(t>0))return null;let n=`${Math.round(t)}px`;return e.style.getPropertyValue(`--yuri-mobile-composer-occupancy`)!==n&&e.style.setProperty(fy,n),n},my=(e,t)=>{t!==null&&e.style.getPropertyValue(`--yuri-mobile-composer-occupancy`)===t&&e.style.removeProperty(fy)},hy=e=>{for(let t of e.children)if(t instanceof HTMLElement&&t.classList.contains(`yuri-mobile-composer-foot--overlay`)&&!t.classList.contains(`invisible`))return t;return e},gy=(e,t=e)=>{for(let n of new Set([e,t]))n.style.removeProperty(Yv),n.style.removeProperty(Xv);delete e.dataset.yuriComposerSwapPhase,delete e.dataset.yuriComposerSwapRest,delete e.dataset.yuriNativeComposerDock},_y=(e,t,n,r=e)=>{let i=dy(t,n?.rest===`bottom`?`bottom`:`away`),a=String(i.progress),o=i.rest;return n?.progress!==a&&r.style.setProperty(Xv,a),n?.rest!==o&&(e.dataset.yuriNativeComposerDock=o),{progress:a,rest:o}},vy=(e,t,n,r=e)=>{let i=String(t.progress),a=t.phase,o=t.rest;return n?.phase!==a&&(e.dataset.yuriComposerSwapPhase=a,a===`snapping`&&n&&n.phase!==`snapping`&&r.offsetWidth),n?.progress!==i&&r.style.setProperty(Yv,i),n?.rest!==o&&(e.dataset.yuriComposerSwapRest=o),{progress:i,phase:a,rest:o}},yy=`box-border w-full whitespace-pre-wrap break-words px-3 typography-markdown [font-family:inherit] [font-style:inherit] [font-weight:inherit] leading-[inherit] tracking-[inherit] md:typography-ui-label`,by=Ao(()=>on(()=>import(`./ToolOutputDialog-DSfZp0SO.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),xy=[],Sy=[],Cy=[],wy=/^@[^\s]+$/,Ty=({inputMode:e,message:t,showCommandAutocomplete:n})=>e!==`shell`&&(n||/(^|\s)\/[A-Za-z0-9_-]*/.test(t)),Ey=/^(https?:\/\/|mailto:)\S+$/i,Dy=(e,t)=>e.name===t?e:new File([e],t,{type:e.type,lastModified:e.lastModified}),Oy=(e,t)=>{if(e===t)return``;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let r=e.length,i=t.length;for(;r>n&&i>n&&e[r-1]===t[i-1];)--r,--i;return t.slice(n,i)},ky=e=>e.includes(`@`)?`paste`:`manual`,Ay=(e,t)=>{let n=t,r=t;for(;n>0&&/\s/.test(e[n-1]);)--n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let i=n>0&&r<e.length?` `:``;return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,caret:n+i.length}},jy=(e,t)=>ae(e,t).some(e=>e.role===`user`),My=(e,t)=>{let n=e.filter(e=>e.type===`text`&&!Qn(e)).map(e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``}).join(`
12
+ `))r.startsWith(`+`)&&!r.startsWith(`+++`)&&t++,r.startsWith(`-`)&&!r.startsWith(`---`)&&n++;return{added:t,removed:n}},lh=e=>{let t=[],n=new Set;for(let r of e){if(r.type!==`tool`||!ah.has(r.tool))continue;let e=r.state;if(e.status&&e.status!==`completed`)continue;let i=t.length,a=e.metadata,o=Array.isArray(a?.files)?a.files:[];for(let e of o){if(!e||typeof e!=`object`)continue;let i=e,a=i.relativePath||i.filePath||``;!a||n.has(a)||(n.add(a),t.push({path:a,tool:r.tool,partId:r.id,messageID:r.messageID,additions:sh(i.additions)??void 0,deletions:sh(i.deletions)??void 0,patch:typeof i.patch==`string`?i.patch:void 0}))}if(o.length===0&&a?.filediff&&typeof a.filediff==`object`){let e=a.filediff,i=typeof e.file==`string`?e.file:``;i&&!n.has(i)&&(n.add(i),t.push({path:i,tool:r.tool,partId:r.id,messageID:r.messageID,additions:sh(e.additions)??void 0,deletions:sh(e.deletions)??void 0,patch:typeof e.patch==`string`?e.patch:void 0}))}if(o.length===0&&Array.isArray(a?.results))for(let e of a.results){if(!e||typeof e!=`object`)continue;let i=e.filediff;if(!i||typeof i!=`object`)continue;let a=typeof i.file==`string`?i.file:``;!a||n.has(a)||(n.add(a),t.push({path:a,tool:r.tool,partId:r.id,messageID:r.messageID,additions:sh(i.additions)??void 0,deletions:sh(i.deletions)??void 0,patch:typeof i.patch==`string`?i.patch:void 0}))}if(t.length===i){let i=e.input,a=typeof i?.filePath==`string`?i.filePath:typeof i?.file_path==`string`?i.file_path:typeof i?.path==`string`?i.path:void 0;a&&!n.has(a)&&(n.add(a),t.push({path:a,tool:r.tool,partId:r.id,messageID:r.messageID}))}if(t.length===i){let e=typeof a?.patch==`string`?a.patch.trim():typeof a?.diff==`string`?a.diff.trim():``;if(e&&!n.has(`Diff`)){n.add(`Diff`);let i=ch(e);t.push({path:`Diff`,tool:r.tool,partId:r.id,messageID:r.messageID,additions:i.added,deletions:i.removed})}}}return t},uh=(e,t,n)=>{let r=[];for(let i of e){let e=i.index?.trim()??``,a=i.working_dir?.trim()??``,o=!!(e&&e!==`?`),s=!!(a||e===`?`),c=a||e;if(!c||c===`!`)continue;let l=t?.[i.path];r.push({path:Jt(n,i.path),relativePath:i.path,insertions:l?.insertions??0,deletions:l?.deletions??0,status:c,hasStagedChanges:o,hasWorkingChanges:s})}return r},dh=(e,t)=>{let n=0,r=0,i=0;for(let a of e){let e=a.index?.trim()??``,o=(a.working_dir?.trim()??``)||e;if(!o||o===`!`)continue;n+=1;let s=t?.[a.path];s&&(r+=s.insertions,i+=s.deletions)}return{count:n,insertions:r,deletions:i}},fh=e=>{for(let t of e){let e=t.index?.trim()??``,n=(t.working_dir?.trim()??``)||e;if(!(!n||n===`!`))return!0}return!1},ph=(e,t)=>qt(e,t),mh=(e,t)=>{let n=oh(e)&&e.relativePath?e.relativePath:ph(e.path,t);return{fileName:n.split(`/`).pop()??n,dirPart:n.includes(`/`)?n.slice(0,n.lastIndexOf(`/`)):``}},hh=e=>oh(e)?{additions:e.insertions,deletions:e.deletions}:{additions:e.additions??0,deletions:e.deletions??0},gh=`yuri-mobile-overlay-surface yuri-popup-surface`,_h=`w-[min(30rem,calc(100cqw-1rem))] min-w-[280px] max-w-full overflow-hidden rounded-xl ${gh}`,vh={maxWidth:`min(28rem, calc(100cqw - 4ch))`,color:`var(--surface-elevated-foreground)`},yh={...vh,width:`100%`,minWidth:0,maxWidth:`100%`},bh=`flex items-center justify-between gap-3 border-b-[length:var(--yuri-popup-divider-width)] border-[var(--yuri-popup-divider)] px-3 py-2.5`,xh=`text-xs font-medium leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,Sh=`text-xs tabular-nums leading-4 text-muted-foreground md:text-[0.8125rem] md:leading-5`,Ch=`m-0 list-none p-0`,wh=`${Ch} divide-y-[length:var(--yuri-popup-divider-width)] divide-[var(--yuri-popup-divider)] max-h-[min(22rem,50vh)] overflow-y-auto`,Th=`${Ch} divide-y divide-[var(--surface-subtle)] w-full`,Eh={className:`p-0 rounded-none`,maxHeightClass:`max-h-[46vh]`,disableHorizontal:!0},Dh=`px-2.5 py-1.5 text-xs leading-4 md:py-2 md:text-[0.8125rem] md:leading-5`,Oh=`flex min-w-0 items-center gap-1 text-xs leading-4 text-muted-foreground md:gap-1.5 md:text-[0.8125rem] md:leading-5`,kh=`min-w-0 truncate text-xs leading-4 text-foreground md:text-[0.8125rem] md:leading-5`,Ah=`inline-flex shrink-0 items-center gap-1 text-xs leading-4 tabular-nums text-muted-foreground md:text-[0.8125rem] md:leading-5`,jh=`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`,Mh=200,Nh=32,Ph=352,Fh=e=>{let t=(0,Z.c)(26),{file:n,currentDirectory:r,onOpenFile:i}=e,{t:a}=na(),o;t[0]!==r||t[1]!==n?(o=mh(n,r),t[0]=r,t[1]=n,t[2]=o):o=t[2];let{fileName:s,dirPart:c}=o,l;t[3]===n?l=t[4]:(l=hh(n),t[3]=n,t[4]=l);let u=l,d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=J(`relative flex w-full cursor-pointer items-center gap-2.5 outline-hidden select-none text-left hover:bg-interactive-hover`,Dh),t[5]=d):d=t[5];let f;t[6]!==n.path||t[7]!==a?(f=a(`chat.changedFiles.actions.openFileTitle`,{path:n.path}),t[6]=n.path,t[7]=a,t[8]=f):f=t[8];let p;t[9]!==n||t[10]!==i?(p=()=>i(n),t[9]=n,t[10]=i,t[11]=p):p=t[11];let m;t[12]===n.path?m=t[13]:(m=(0,$.jsx)(ja,{filePath:n.path,className:`h-3 w-3 shrink-0 md:h-3.5 md:w-3.5`}),t[12]=n.path,t[13]=m);let h=c?`${c}/${s}`:s,g;t[14]!==n.path||t[15]!==h?(g=(0,$.jsx)(Fa,{path:h,title:n.path,className:`min-w-0 flex-1`}),t[14]=n.path,t[15]=h,t[16]=g):g=t[16];let _;t[17]!==u.additions||t[18]!==u.deletions?(_=u.additions>0||u.deletions>0?(0,$.jsxs)(`span`,{className:`flex-shrink-0 inline-flex items-baseline gap-1 text-xs tabular-nums leading-4 md:text-[0.8125rem] md:leading-5`,children:[u.additions>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,u.additions]}):null,u.deletions>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,u.deletions]}):null]}):null,t[17]=u.additions,t[18]=u.deletions,t[19]=_):_=t[19];let v;return t[20]!==f||t[21]!==p||t[22]!==m||t[23]!==g||t[24]!==_?(v=(0,$.jsxs)(`button`,{type:`button`,className:d,title:f,onClick:p,children:[m,g,_]}),t[20]=f,t[21]=p,t[22]=m,t[23]=g,t[24]=_,t[25]=v):v=t[25],v},Ih=({files:e,currentDirectory:t,onOpenFile:n})=>{let r=Q.useRef(null),i=Q.useRef(null),[a,o]=Q.useState(Nh),s=Q.useMemo(()=>t=>e[t]?.path??t,[e]),c=ya({count:e.length,getScrollElement:()=>r.current,estimateSize:()=>a,initialRect:{width:0,height:Ph},overscan:8,getItemKey:s});Q.useLayoutEffect(()=>{let e=i.current?.offsetHeight??0;e>0&&e!==a&&o(e)},[a]),Q.useLayoutEffect(()=>{c.measure()},[a,c]);let l=c.getVirtualItems(),u=l[0]?.index;return(0,$.jsx)(`div`,{ref:r,className:wh,children:(0,$.jsx)(`div`,{style:{height:c.getTotalSize(),position:`relative`},children:l.map(r=>{let a=e[r.index];return a?(0,$.jsx)(`div`,{"data-index":r.index,ref:r.index===u?i:void 0,className:J(r.index>0&&`shadow-[inset_0_var(--yuri-popup-divider-width)_0_0_var(--yuri-popup-divider)]`),style:{position:`absolute`,top:0,left:0,width:`100%`,transform:`translateY(${r.start}px)`},children:(0,$.jsx)(Fh,{file:a,currentDirectory:t,onOpenFile:n})},r.key):null})})})},Lh=e=>{let t=(0,Z.c)(16),{files:n,currentDirectory:r,onOpenFile:i}=e,{t:a}=na(),o;t[0]===a?o=t[1]:(o=a(`chat.changedFiles.title`),t[0]=a,t[1]=o);let s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`span`,{className:xh,children:o}),t[2]=o,t[3]=s);let c;t[4]===n.length?c=t[5]:(c=(0,$.jsx)(`span`,{className:Sh,children:n.length}),t[4]=n.length,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:bh,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==r||t[10]!==n||t[11]!==i?(u=n.length>Mh?(0,$.jsx)(Ih,{files:n,currentDirectory:r,onOpenFile:i}):(0,$.jsx)(`div`,{className:wh,children:n.map((e,t)=>(0,$.jsx)(Fh,{file:e,currentDirectory:r,onOpenFile:i},`${e.path}:${t}`))}),t[9]=r,t[10]=n,t[11]=i,t[12]=u):u=t[12];let d;return t[13]!==l||t[14]!==u?(d=(0,$.jsxs)($.Fragment,{children:[l,u]}),t[13]=l,t[14]=u,t[15]=d):d=t[15],d},Rh=`${_h} origin-[var(--transform-origin)]`,zh=vh,Bh=Q.memo(e=>{let t=(0,Z.c)(66),{isExpanded:n,onExpandedChange:r}=e,{t:i}=na(),a=ln(Vh),o=Ga()??null,s=Q.useContext(Wt),c=Rt(),l=c?.entry.location.hostId?c.entry:void 0;s?.git;let u;t[0]!==l||t[1]!==s?.git?(u=l?Ir(l):s?.git,t[0]=l,t[1]=s?.git,t[2]=u):u=t[2];let d=u,f=Qa(o),p;t[3]===o?p=t[4]:(p=e=>o?e.directories.get(o)?.status??null:null,t[3]=o,t[4]=p);let m=Za(p),h=Za(Hh),g=ga(),_=!!(o&&f===!0&&m&&!m.isClean),v;bb0:{if(!_||!m){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e={count:0,insertions:0,deletions:0},t[5]=e):e=t[5],v=e;break bb0}let e;t[6]!==m.diffStats||t[7]!==m.files?(e=dh(m.files,m.diffStats),t[6]=m.diffStats,t[7]=m.files,t[8]=e):e=t[8],v=e}let y=v,b;bb1:{if(!n||!_||!m||!o){let e;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[9]=e):e=t[9],b=e;break bb1}let e;t[10]!==o||t[11]!==m.diffStats||t[12]!==m.files?(e=uh(m.files,m.diffStats,o),t[10]=o,t[11]=m.diffStats,t[12]=m.files,t[13]=e):e=t[13],b=e}let x=b,S=y.insertions,C=y.deletions;if(!o||f!==!0||y.count===0)return null;let w;t[14]!==o||t[15]!==l||t[16]!==g||t[17]!==r||t[18]!==s?.editor?(w=e=>{if(!o||!oh(e))return;r(!1);let t=e.path;if(g){g.openChanges({diffPath:e.relativePath,staged:e.hasStagedChanges&&!e.hasWorkingChanges});return}let n=s?.editor;if(!l&&n){n.openFile(t);return}let i=ln.getState(),a=e.hasStagedChanges&&!e.hasWorkingChanges;if(!i.isMobile){i.openContextDiff(l?.key??o,e.relativePath,a);return}i.navigateToDiff(e.relativePath,a),i.setRightSidebarOpen(!1)},t[14]=o,t[15]=l,t[16]=g,t[17]=r,t[18]=s?.editor,t[19]=w):w=t[19];let T=w,E=y.count,D;t[20]!==E||t[21]!==i?(D=i(E===1?`chat.pendingChanges.fileCountSingle`:`chat.pendingChanges.fileCountPlural`,{count:E}),t[20]=E,t[21]=i,t[22]=D):D=t[22];let O=D,k;t[23]!==o||t[24]!==h||t[25]!==n||t[26]!==r||t[27]!==d?(k=()=>{let e=!n;r(e),!(!e||!o||!d)&&h(o,d,{silent:!0})},t[23]=o,t[24]=h,t[25]=n,t[26]=r,t[27]=d,t[28]=k):k=t[28];let A=k,j=a?`contents`:`relative`,M;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(M=J(Oh,`yuri-pending-changes-trigger max-w-full text-left`),t[29]=M):M=t[29];let N,P;t[30]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(X,{name:`file-edit`,className:jh}),P=J(kh,`shrink-0`),t[30]=N,t[31]=P):(N=t[30],P=t[31]);let F;t[32]===O?F=t[33]:(F=(0,$.jsx)(`span`,{className:P,children:O}),t[32]=O,t[33]=F);let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=J(`status-row__changed-label`,kh),t[34]=I):I=t[34];let L;t[35]===i?L=t[36]:(L=i(`chat.pendingChanges.changedInWorkspace`),t[35]=i,t[36]=L);let R;t[37]===L?R=t[38]:(R=(0,$.jsx)(`span`,{className:I,children:L}),t[37]=L,t[38]=R);let ee;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ee=J(Ah,`items-baseline gap-0.5`),t[39]=ee):ee=t[39];let z;t[40]===S?z=t[41]:(z=S>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,S]}):null,t[40]=S,t[41]=z);let B;t[42]===C?B=t[43]:(B=C>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,C]}):null,t[42]=C,t[43]=B);let V;t[44]!==z||t[45]!==B?(V=(0,$.jsxs)(`span`,{className:ee,children:[z,B]}),t[44]=z,t[45]=B,t[46]=V):V=t[46];let H;t[47]===n?H=t[48]:(H=n?(0,$.jsx)(X,{name:`arrow-up-s`,className:jh}):(0,$.jsx)(X,{name:`arrow-down-s`,className:jh}),t[47]=n,t[48]=H);let U;t[49]!==A||t[50]!==n||t[51]!==F||t[52]!==R||t[53]!==V||t[54]!==H?(U=(0,$.jsxs)(`button`,{type:`button`,className:M,onClick:A,"aria-expanded":n,children:[N,F,R,V,H]}),t[49]=A,t[50]=n,t[51]=F,t[52]=R,t[53]=V,t[54]=H,t[55]=U):U=t[55];let te;t[56]!==o||t[57]!==x||t[58]!==T||t[59]!==n||t[60]!==a?(te=n&&(0,$.jsx)(`div`,{style:a?yh:zh,className:J(Rh,`absolute left-0 bottom-full mb-1 z-50`,`animate-in fade-in-0 zoom-in-95 slide-in-from-bottom-2`,`duration-150`),children:(0,$.jsx)(Lh,{files:x,currentDirectory:o,onOpenFile:T})}),t[56]=o,t[57]=x,t[58]=T,t[59]=n,t[60]=a,t[61]=te):te=t[61];let ne;return t[62]!==U||t[63]!==te||t[64]!==j?(ne=(0,$.jsxs)(`div`,{className:j,children:[U,te]}),t[62]=U,t[63]=te,t[64]=j,t[65]=ne):ne=t[65],ne});Bh.displayName=`PendingChangesBar`;function Vh(e){return e.isMobile}function Hh(e){return e.fetchStatus}function Uh(e){if(!Number.isFinite(e)||e<0)return`0s`;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m${t%60?`${t%60}s`:``}`:`${Math.floor(n/60)}h${n%60?`${n%60}m`:``}`}var Wh=28,Gh=8,Kh=10.5,qh=Math.PI/2,Jh=e=>Array.from({length:Gh},(t,n)=>{let r=n/Gh*Math.PI*2-Math.PI/2+e;return[Math.cos(r)*Kh,Math.sin(r)*Kh]}),Yh=[Jh(0),Jh(qh),Jh(Math.PI),Jh(Math.PI*1.5)],Xh=([e,t])=>`${e.toFixed(1)}px, ${t.toFixed(1)}px`,Zh=e=>{let t=(0,Z.c)(9),{size:n,isMobile:r,className:i}=e,a=n??(r!==void 0&&r?12:14),o;t[0]===i?o=t[1]:(o=J(`yuri-morph-orb-glyph shrink-0`,i),t[0]=i,t[1]=o);let s=a/Wh,c;t[2]!==a||t[3]!==s?(c={width:a,height:a,"--orb-k":s},t[2]=a,t[3]=s,t[4]=c):c=t[4];let l=c,u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,$.jsx)(`span`,{className:`yuri-morph-orb-stage`,children:Yh[0].map(Qh)}),t[5]=u):u=t[5];let d;return t[6]!==o||t[7]!==l?(d=(0,$.jsx)(`span`,{className:o,style:l,"aria-hidden":`true`,children:u}),t[6]=o,t[7]=l,t[8]=d):d=t[8],d};function Qh(e,t){return(0,$.jsx)(`span`,{className:`yuri-morph-orb-dot`,style:{"--m-1":Xh(Yh[0][t]),"--m-2":Xh(Yh[1][t]),"--m-3":Xh(Yh[2][t]),"--m-4":Xh(Yh[3][t])}},t)}var $h=1200,eg=600;function tg({text:e,elapsed:t,reducedMotion:n}){let r=Q.useRef(null),i=Q.useRef(null),a=Q.useRef(e),o=Q.useRef(e),s=Q.useRef(null);return Q.useLayoutEffect(()=>{let t=r.current,a=i.current;if(!t||!a)return;if(o.current=e,n){s.current?.cancel(),s.current=null,a.textContent=e,t.style.opacity=`1`;return}let c=()=>{if(s.current||a.textContent===o.current)return;let e=pa(t,{opacity:[1,0]},{duration:.25,ease:`easeIn`});s.current=e,e.then(()=>{if(s.current!==e)return;a.textContent=o.current;let n=pa(t,{opacity:[0,1]},{duration:.35,ease:`easeOut`});s.current=n,n.then(()=>{s.current===n&&(s.current=null,c())})})};c()},[e,n]),Q.useLayoutEffect(()=>()=>{s.current?.cancel(),s.current=null},[]),(0,$.jsxs)(`span`,{ref:r,className:`flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{ref:i,className:`animate-text-shimmer min-w-0 truncate whitespace-nowrap`,children:a.current}),t?(0,$.jsx)(`span`,{className:`typography-meta shrink-0 font-light text-muted-foreground/70 tabular-nums`,"aria-hidden":`true`,children:t.replace(/m(?=\d)/u,`m `)}):null]})}function ng({isWorking:e,isMobile:t,statusText:n,isGenericStatus:r,isWaitingForPermission:i,retryInfo:a,turnStartedAt:o,isTurnSettled:s=!1}){let{locale:c,t:l}=na(),u=ha(),[d,f]=Q.useState(null),[p,m]=Q.useState(!1),h=Q.useRef(d),g=Q.useRef(p),_=Q.useRef(!1);h.current=d,g.current=p;let v=Q.useRef(0),y=Q.useRef(null),b=Q.useRef(null),x=Q.useRef(null),[S,C]=Q.useState(null),[w,T]=Q.useState(()=>Date.now());Q.useEffect(()=>{if(!e||typeof o!=`number`||a)return;T(Date.now());let t=window.setInterval(()=>T(Date.now()),1e3);return()=>window.clearInterval(t)},[e,o,a]),Q.useEffect(()=>{let e=a?.next;if(!e||e<=0){C(null);return}let t=e,n=()=>{let e=Math.max(0,t-Date.now());C(Math.ceil(e/1e3))};n();let r=setInterval(n,500);return()=>clearInterval(r)},[a?.next,a?.attempt]);let E=G(()=>{b.current&&=(clearTimeout(b.current),null),x.current&&=(clearTimeout(x.current),null)}),D=G((e,t,n=!1)=>{E(),y.current=null,f(e),m(t),_.current=n,v.current=Date.now()}),O=G(()=>{if(b.current)return;let e=Date.now()-v.current,t=Math.max(0,$h-e);b.current=setTimeout(()=>{b.current=null;let e=y.current;e&&D(e.text,e.permission,e.generic)},t)});if(Q.useEffect(()=>{if(s){E(),y.current=null,h.current&&(f(null),m(!1),_.current=!1);return}if(!e){if(b.current&&=(clearTimeout(b.current),null),y.current=null,!h.current||x.current)return;x.current=setTimeout(()=>{x.current=null,f(null),m(!1),_.current=!1},eg);return}if(x.current&&=(clearTimeout(x.current),null),a){E(),y.current=null;return}let t=i?l(`chat.assistantStatus.waitingForPermission`):n,o=!!i,c=!!r&&!o;if(t){if(!h.current){D(t,o,c);return}if((t!==h.current||o!==g.current)&&!(c&&_.current)){if(c){y.current={text:t,permission:o,generic:c},O();return}D(t,o,c)}}},[e,s,n,r,i,a,l]),Q.useEffect(()=>()=>E(),[]),s||!e&&!d)return null;if(a&&e){let e=S!==null&&S>0?new Intl.RelativeTimeFormat(c,{numeric:`always`,style:`short`}).format(S,`second`):null,n=e?a.attempt&&a.attempt>0?l(`chat.assistantStatus.retryingInAttempt`,{duration:e,attempt:a.attempt}):l(`chat.assistantStatus.retryingIn`,{duration:e}):a.attempt&&a.attempt>0?l(`chat.assistantStatus.retryingAttempt`,{attempt:a.attempt}):l(`chat.assistantStatus.retrying`),r=a.message?`${n} · ${a.message}`:n;return(0,$.jsx)(`div`,{className:`flex h-full items-center text-muted-foreground`,role:`status`,"aria-live":`polite`,"aria-label":r,children:(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 ${t?`typography-meta !text-[length:var(--text-meta)]`:`typography-ui-header`}`,children:[(0,$.jsx)(`span`,{className:`inline-flex flex-none items-center justify-center ${t?`h-5 w-4`:`h-6 w-3.5`}`,children:(0,$.jsx)(Zh,{isMobile:t})}),(0,$.jsx)(`span`,{className:`animate-text-shimmer min-w-0 whitespace-normal break-words`,children:r})]})})}if(!d)return null;let k=d,A=typeof o==`number`&&e?Uh(Math.max(0,w-o)):null;return(0,$.jsx)(`div`,{className:`flex h-full w-full min-w-0 items-center text-muted-foreground`,role:`status`,"aria-live":p?`assertive`:`polite`,"aria-label":k,"data-waiting":p?`true`:void 0,children:(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-center gap-1.5 ${t?`typography-meta !text-[length:var(--text-meta)]`:`typography-ui-header`}`,children:[(0,$.jsx)(`span`,{className:`inline-flex flex-none items-center justify-center ${t?`h-5 w-4`:`h-6 w-3.5`}`,children:(0,$.jsx)(Zh,{isMobile:t})}),(0,$.jsx)(tg,{text:k,elapsed:A,reducedMotion:u})]})})}var rg={containerType:`inline-size`,containerName:`status-row`},ig=[],ag=e=>{let t=(0,Z.c)(113),{isWorking:n,statusText:r,isGenericStatus:i,isWaitingForPermission:a,wasAborted:o,abortActive:s,retryInfo:c,turnStartedAt:l,isTurnSettled:u,showAbortStatus:f,showAbortPrompt:p,showAssistantStatus:m,showTodos:h,agentName:g,showPendingChanges:_,insideInputColumn:v,className:y}=e,b=n!==void 0&&n,x=r===void 0?null:r,S=u!==void 0&&u,C=p!==void 0&&p,w=m===void 0||m,T=h===void 0||h,E=_!==void 0&&_,D=v!==void 0&&v,{t:O}=na(),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k={todos:!1,changes:!1},t[0]=k):k=t[0];let[A,j]=Q.useState(k),M=A.todos,N=Xo(),P=Xr(og),F=N.sessionId??P,I;t[1]!==F||t[2]!==T?(I=e=>!T||!F?ig:e.todo[F]??ig,t[1]=F,t[2]=T,t[3]=I):I=t[3];let L=br(I,N.directory??void 0),R;t[4]!==F||t[5]!==T?(R=e=>T&&F?e.sessions[F]?.todos:void 0,t[4]=F,t[5]=T,t[6]=R):R=t[6];let ee=ni(R),z=Si(T&&F?F:``,N.directory??void 0),B;bb0:{if(!F){B=ig;break bb0}if(z){B=z;break bb0}if(L.length>0){B=L;break bb0}B=ee??ig}let V=B,H=ln(sg),U;t[7]===H?U=t[8]:(U=H||d(),t[7]=H,t[8]=U);let te=U,ne=A.changes&&(!H||!M),re;t[9]===V?re=t[10]:(re=V.filter(cg),t[9]=V,t[10]=re);let W=re,ie;t[11]===W?ie=t[12]:(ie=W.find(lg)||W.find(ug)||null,t[11]=W,t[12]=ie);let ae=ie,oe;t[13]===V?oe=t[14]:(oe=V.filter(dg),t[13]=V,t[14]=oe);let se=oe.length,ce;t[15]===V?ce=t[16]:(ce=V.filter(fg),t[15]=V,t[16]=ce);let le=ce.length,ue;t[17]!==le||t[18]!==se?(ue={completed:le,total:se},t[17]=le,t[18]=se,t[19]=ue):ue=t[19];let de=ue,fe;t[20]===W?fe=t[21]:(fe=W.filter(pg),t[20]=W,t[21]=fe);let pe=fe.length,me;t[22]===W?me=t[23]:(me=W.filter(mg),t[22]=W,t[23]=me);let he=me.length,ge;t[24]!==pe||t[25]!==he?(ge={active:pe,left:he},t[24]=pe,t[25]=he,t[26]=ge):ge=t[26];let _e=ge,ve=T&&_e.left>0,ye=!!C,[be,xe]=Q.useState(!1),Se,Ce;t[27]!==be||t[28]!==S||t[29]!==b?(Se=()=>{if(S){xe(!1);return}if(b){xe(!0);return}if(!be)return;let e=window.setTimeout(()=>xe(!1),600);return()=>window.clearTimeout(e)},Ce=[b,be,S],t[27]=be,t[28]=S,t[29]=b,t[30]=Se,t[31]=Ce):(Se=t[30],Ce=t[31]),Q.useEffect(Se,Ce);let we=w&&(!S&&(b||be)||!!o||!!f),Te=E||D,Ee=!f&&!ye&&(o||!s),De=ye||we||ve||E,Oe=Q.useRef(null),ke=Q.useRef(null),Ae=Q.useRef(null),je=Q.useRef(null),Me,Ne;t[32]===M?(Me=t[33],Ne=t[34]):(Me=()=>{let e=je.current,t=e?.querySelector(`[aria-current="step"]`)??null;if(!M||!e||!t)return;let n=t.offsetTop-e.offsetTop-(e.clientHeight-t.offsetHeight)/2,r=e.scrollHeight-e.clientHeight;e.scrollTop=Math.min(r,Math.max(0,n))},Ne=[M],t[32]=M,t[33]=Me,t[34]=Ne),Q.useLayoutEffect(Me,Ne);let Pe,Fe;t[35]!==ne||t[36]!==M||t[37]!==H?(Pe=()=>{if(!M&&!ne)return;let e=e=>{let t=e.target;if(H){Oe.current&&!Oe.current.contains(t)&&j({todos:!1,changes:!1});return}let n=M&&ke.current&&!ke.current.contains(t),r=ne&&Ae.current&&!Ae.current.contains(t);!n&&!r||j(e=>({todos:!n&&e.todos,changes:!r&&e.changes}))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},Fe=[M,ne,H],t[35]=ne,t[36]=M,t[37]=H,t[38]=Pe,t[39]=Fe):(Pe=t[38],Fe=t[39]),Q.useEffect(Pe,Fe);let Ie;t[40]===H?Ie=t[41]:(Ie=()=>j(e=>({todos:!e.todos,changes:H&&!e.todos?!1:e.changes})),t[40]=H,t[41]=Ie);let Le=G(Ie),Re;t[42]===H?Re=t[43]:(Re=e=>j(t=>({todos:H&&e?!1:t.todos,changes:e})),t[42]=H,t[43]=Re);let ze=G(Re),Be;t[44]!==_e.active||t[45]!==_e.left||t[46]!==O?(Be=O(`chat.statusRow.summary.activeLeft`,{active:_e.active,left:_e.left}),t[44]=_e.active,t[45]=_e.left,t[46]=O,t[47]=Be):Be=t[47];let Ve=Be,He;t[48]!==ae||t[49]!==ve||t[50]!==te||t[51]!==M||t[52]!==b||t[53]!==de||t[54]!==_e.left||t[55]!==O||t[56]!==Ve||t[57]!==Le?(He=ve?(0,$.jsxs)(`button`,{type:`button`,onClick:Le,className:J(Oh,`yuri-status-row-trigger shrink-0`),"aria-label":Ve,title:Ve,"aria-expanded":M,children:[_e.left===0?(0,$.jsx)(Iu,{}):(0,$.jsx)(Lu,{done:de.completed,total:de.total,spinning:b}),!te&&ae?(0,$.jsx)(`span`,{className:J(`status-row__active-todo max-w-[200px]`,kh),children:ae.content}):(0,$.jsx)(`span`,{className:J(kh,`text-muted-foreground`),children:O(`chat.statusRow.tasksTitle`)}),(0,$.jsx)(Hu,{done:de.completed,total:de.total,className:Ah,animate:!1}),M?(0,$.jsx)(X,{name:`arrow-up-s`,className:jh}):(0,$.jsx)(X,{name:`arrow-down-s`,className:jh})]}):null,t[48]=ae,t[49]=ve,t[50]=te,t[51]=M,t[52]=b,t[53]=de,t[54]=_e.left,t[55]=O,t[56]=Ve,t[57]=Le,t[58]=He):He=t[58];let Ue=He;if(!De)return null;let We=H&&`relative`,Ge=!Te&&`chat-column -mt-2`,Ke;t[59]!==y||t[60]!==Te||t[61]!==H||t[62]!==We||t[63]!==Ge?(Ke=J(`mb-1`,We,Ge,!Te&&fm(H),!Te&&`pb-3.5`,y),t[59]=y,t[60]=Te,t[61]=H,t[62]=We,t[63]=Ge,t[64]=Ke):Ke=t[64];let qe=Te&&`px-3`,Je;t[65]===qe?Je=t[66]:(Je=J(`flex items-center justify-between py-0.5 gap-2`,qe),t[65]=qe,t[66]=Je);let Ye=!Te&&`overflow-x-hidden`,Xe;t[67]===Ye?Xe=t[68]:(Xe=J(`flex-1 flex items-center min-w-0 gap-2`,Ye),t[67]=Ye,t[68]=Xe);let Ze;t[69]!==g||t[70]!==ne||t[71]!==F||t[72]!==ze||t[73]!==ye||t[74]!==i||t[75]!==H||t[76]!==S||t[77]!==a||t[78]!==b||t[79]!==c||t[80]!==Ee||t[81]!==f||t[82]!==w||t[83]!==E||t[84]!==x||t[85]!==O||t[86]!==l?(Ze=ye?(0,$.jsx)(`div`,{className:`flex min-w-0 items-center text-muted-foreground`,role:`status`,"aria-live":`polite`,"aria-label":O(`chat.statusRow.abortPrompt`),children:(0,$.jsxs)(`span`,{className:J(`flex min-w-0 items-center typography-ui-label`,H?`gap-1`:`gap-1.5`),children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center`,H?`h-5 w-4`:`h-6 w-3.5`),children:(0,$.jsx)(X,{name:`error-warning`,className:`size-3.5`,"aria-hidden":`true`})}),(0,$.jsx)(`span`,{className:`animate-text-shimmer truncate whitespace-nowrap`,children:O(`chat.statusRow.abortPrompt`)})]})}):w&&f?(0,$.jsx)(`div`,{className:`flex h-full items-center text-[var(--status-error)]`,children:(0,$.jsxs)(`span`,{className:J(`flex items-center typography-ui-label`,H?`gap-1`:`gap-1.5`),children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center`,H?`h-5 w-4`:`h-6 w-3.5`),children:(0,$.jsx)(X,{name:`close-circle`,className:`size-3.5`,"aria-hidden":`true`})}),O(`chat.statusRow.aborted`)]})}):w&&Ee?(0,$.jsx)(ng,{isWorking:b,isMobile:H,statusText:x,isGenericStatus:i,isWaitingForPermission:a,retryInfo:c,turnStartedAt:l,isTurnSettled:S,agentName:g},F??`no-session`):E?(0,$.jsx)(Bh,{isExpanded:ne,onExpandedChange:ze}):null,t[69]=g,t[70]=ne,t[71]=F,t[72]=ze,t[73]=ye,t[74]=i,t[75]=H,t[76]=S,t[77]=a,t[78]=b,t[79]=c,t[80]=Ee,t[81]=f,t[82]=w,t[83]=E,t[84]=x,t[85]=O,t[86]=l,t[87]=Ze):Ze=t[87];let Qe;t[88]!==Xe||t[89]!==Ze?(Qe=(0,$.jsx)(`div`,{ref:Ae,className:Xe,children:Ze}),t[88]=Xe,t[89]=Ze,t[90]=Qe):Qe=t[90];let $e=!H&&`relative`,et=!Te&&`-mr-3`,tt;t[91]!==$e||t[92]!==et?(tt=J(`flex items-center gap-2 flex-shrink-0`,$e,et),t[91]=$e,t[92]=et,t[93]=tt):tt=t[93];let nt;t[94]!==ve||t[95]!==M||t[96]!==H||t[97]!==b||t[98]!==de||t[99]!==O||t[100]!==W?(nt=M&&ve&&(0,$.jsxs)(`div`,{style:H?yh:vh,className:J(_h,`absolute right-0 bottom-full mb-1 z-50`,`animate-in fade-in-0 zoom-in-95 slide-in-from-bottom-2`,`duration-150 p-[0.5em] pb-[0.875em]`,H?`text-xs leading-4 md:text-[0.8125rem] md:leading-5`:`text-base`),children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-[0.6em] px-[0.5em] pt-[0.25em] pb-[0.5em]`,children:[de.completed===de.total?(0,$.jsx)(Iu,{}):(0,$.jsx)(Lu,{done:de.completed,total:de.total,spinning:b}),(0,$.jsx)(`span`,{className:J(`min-w-0 flex-1 truncate leading-[1.5] text-foreground`,!H&&`text-[0.88em]`),children:O(`chat.workStatus.todos.title`)}),(0,$.jsx)(Hu,{done:de.completed,total:de.total,className:J(`text-muted-foreground`,!H&&`text-[0.88em]`)})]}),(0,$.jsx)(Bu,{todos:W,isWorking:b,animate:!0,listRef:je,className:J(`max-h-[min(22rem,50vh)] overflow-y-auto text-inherit`,H&&`[&_[dir=auto]]:text-[1em]`),rowClassName:`gap-[0.6em] px-[0.5em] py-[0.4em]`})]}),t[94]=ve,t[95]=M,t[96]=H,t[97]=b,t[98]=de,t[99]=O,t[100]=W,t[101]=nt):nt=t[101];let rt;t[102]!==tt||t[103]!==nt||t[104]!==Ue?(rt=(0,$.jsxs)(`div`,{ref:ke,className:tt,children:[Ue,nt]}),t[102]=tt,t[103]=nt,t[104]=Ue,t[105]=rt):rt=t[105];let it;t[106]!==Je||t[107]!==Qe||t[108]!==rt?(it=(0,$.jsxs)(`div`,{className:Je,children:[Qe,rt]}),t[106]=Je,t[107]=Qe,t[108]=rt,t[109]=it):it=t[109];let at;return t[110]!==Ke||t[111]!==it?(at=(0,$.jsx)(`div`,{ref:Oe,className:Ke,style:rg,children:it}),t[110]=Ke,t[111]=it,t[112]=at):at=t[112],at};function og(e){return e.currentSessionId}function sg(e){return e.isMobile}function cg(e){return e.status!==`cancelled`}function lg(e){return e.status===`in_progress`}function ug(e){return e.status===`pending`}function dg(e){return e.status!==`cancelled`}function fg(e){return e.status===`completed`}function pg(e){return e.status===`in_progress`}function mg(e){return e.status===`in_progress`||e.status===`pending`}var hg=Q.memo(function(e){let t=(0,Z.c)(11),{registry:n,hostId:r}=e,i=Lt(n,r),{t:a}=na(),o,s,c,l;if(t[0]!==i||t[1]!==a){let e=hs(i);o=`status`,s=`polite`,c=`pointer-events-none absolute inset-x-0 bottom-full mb-1 flex min-w-0 items-center gap-1.5 px-3 typography-meta text-muted-foreground`,l=e?(0,$.jsxs)($.Fragment,{children:[e.pending?(0,$.jsx)(X,{name:`loader-4`,"aria-hidden":`true`,className:`size-3 shrink-0 animate-spin motion-reduce:animate-none`}):null,(0,$.jsx)(`span`,{className:`truncate`,children:a(e.key)})]}):null,t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c,t[5]=l}else o=t[2],s=t[3],c=t[4],l=t[5];let u;return t[6]!==o||t[7]!==s||t[8]!==c||t[9]!==l?(u=(0,$.jsx)(`div`,{role:o,"aria-live":s,className:c,children:l}),t[6]=o,t[7]=s,t[8]=c,t[9]=l,t[10]=u):u=t[10],u}),gg=Q.memo(e=>{let t=(0,Z.c)(22),{visible:n,onClick:r,placement:i}=e,a=i===void 0?`default`:i,{t:o}=na(),s=a===`compact`;if(s&&!n)return null;let c=a==="default"&&`absolute left-1/2 bottom-full mb-2 -translate-x-1/2`,l=a===`expanded`&&`absolute left-1/2 -translate-x-1/2 yuri-scroll-to-bottom--expanded mb-2`,u=a===`compact`&&`yuri-scroll-to-bottom--compact relative shrink-0`,d;t[0]!==a||t[1]!==c||t[2]!==l||t[3]!==u||t[4]!==n?(d=J(c,l,u,n?J(`pointer-events-auto`,a==="default"&&`opacity-100`):J(`opacity-0 pointer-events-none`,a===`expanded`&&`yuri-scroll-to-bottom--hidden`)),t[0]=a,t[1]=c,t[2]=l,t[3]=u,t[4]=n,t[5]=d):d=t[5];let f=s?`ghost`:`outline`,p=s?`composer-mobile-actions h-8 w-8 rounded-none bg-transparent hover:bg-transparent text-foreground`:`size-8 rounded-full [corner-shape:round] bg-background/95 hover:bg-interactive-hover`,m;t[6]===p?m=t[7]:(m=J(`p-0 shadow-none`,p),t[6]=p,t[7]=m);let h;t[8]===o?h=t[9]:(h=o(`chat.scrollToBottom.aria`),t[8]=o,t[9]=h);let g=s?`size-5`:`size-4`,_=s?`medium`:`regular`,v;t[10]!==g||t[11]!==_?(v=(0,$.jsx)(X,{name:`arrow-down`,className:g,weight:_}),t[10]=g,t[11]=_,t[12]=v):v=t[12];let y;t[13]!==r||t[14]!==v||t[15]!==f||t[16]!==m||t[17]!==h?(y=(0,$.jsx)(Tr,{variant:f,size:`sm`,onClick:r,className:m,"aria-label":h,children:v}),t[13]=r,t[14]=v,t[15]=f,t[16]=m,t[17]=h,t[18]=y):y=t[18];let b;return t[19]!==y||t[20]!==d?(b=(0,$.jsx)(`div`,{className:d,children:y}),t[19]=y,t[20]=d,t[21]=b):b=t[21],b}),_g=e=>{let t=(0,Z.c)(31),{onCycleAgent:n,onOpenAgentPanel:r,className:i,agentName:a,agents:o,disabled:s}=e,c;t[0]===o?c=t[1]:(c=o===void 0?[]:o,t[0]=o,t[1]=c);let l=c,u=s!==void 0&&s,d=a??void 0,f;t[2]!==l||t[3]!==d?(f=Nr(l,d),t[2]=l,t[3]=d,t[4]=f):f=t[4];let p=f,m=um(d),h;t[5]===d?h=t[6]:(h=$a(d),t[5]=d,t[6]=h);let g=h,_=Q.useRef(null),v=Q.useRef(!1),y;t[7]!==u||t[8]!==r?(y=e=>{e.preventDefault(),!u&&(v.current=!1,_.current=setTimeout(()=>{v.current=!0,r()},500))},t[7]=u,t[8]=r,t[9]=y):y=t[9];let b=y,x;t[10]!==u||t[11]!==n?(x=()=>{_.current&&=(clearTimeout(_.current),null),!u&&!v.current&&n()},t[10]=u,t[11]=n,t[12]=x):x=t[12];let S=x,C;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(C=()=>{_.current&&=(clearTimeout(_.current),null)},t[13]=C):C=t[13];let w=C,T,E;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>()=>{_.current&&clearTimeout(_.current)},T=[],t[14]=T,t[15]=E):(T=t[14],E=t[15]),Q.useEffect(E,T);let D;t[16]===i?D=t[17]:(D=J(`inline-flex flex-shrink-0 items-center select-none focus:outline-none touch-none disabled:cursor-not-allowed disabled:opacity-40`,vm,i),t[16]=i,t[17]=D);let O;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(O={height:`26px`,maxHeight:`26px`,minHeight:`26px`},t[18]=O):O=t[18];let k;t[19]!==g.var||t[20]!==p||t[21]!==d||t[22]!==m?(k=(0,$.jsx)(lm,{name:d,label:p,revealed:m,avatarSize:16,slotClassName:`h-[26px] w-6`,labelGapClassName:`pl-1 pr-0.5`,colorVar:g.var}),t[19]=g.var,t[20]=p,t[21]=d,t[22]=m,t[23]=k):k=t[23];let A;return t[24]!==p||t[25]!==u||t[26]!==b||t[27]!==S||t[28]!==D||t[29]!==k?(A=(0,$.jsx)(`button`,{type:`button`,disabled:u,onPointerDown:b,onPointerUp:S,onPointerLeave:w,onContextMenu:vg,onMouseDown:yg,className:D,style:O,title:p,"aria-label":p,children:k}),t[24]=p,t[25]=u,t[26]=b,t[27]=S,t[28]=D,t[29]=k,t[30]=A):A=t[30],A};function vg(e){return e.preventDefault()}function yg(e){return e.preventDefault()}var bg=e=>{let t=(0,Z.c)(28),{onOpenModel:n,className:r,providerID:i,modelID:a,provider:o,variant:s,disabled:c}=e,l=c!==void 0&&c,{t:u}=na(),d;t[0]!==a||t[1]!==o||t[2]!==u?(d=Mi(o,a,u(`chat.modelControls.selectModel`)),t[0]=a,t[1]=o,t[2]=u,t[3]=d):d=t[3];let f=d,p;t[4]===s?p=t[5]:(p=s?.trim()?oi(s):null,t[4]=s,t[5]=p);let m=p,h=m?`${f} ${m}`:f,g;t[6]===r?g=t[7]:(g=J(`inline-flex min-w-0 max-w-36 items-stretch`,`rounded-lg`,`focus:outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,r),t[6]=r,t[7]=g);let _;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(_={height:`26px`,maxHeight:`26px`,minHeight:`26px`},t[8]=_):_=t[8];let v;t[9]!==a||t[10]!==i?(v=a||i?(0,$.jsx)(Gs,{modelId:a,providerId:i,className:`size-4 flex-shrink-0`}):null,t[9]=a,t[10]=i,t[11]=v):v=t[11];let y;t[12]===f?y=t[13]:(y=(0,$.jsx)(`span`,{className:`truncate text-[11px] leading-none font-medium text-foreground/80`,children:f}),t[12]=f,t[13]=y);let b;t[14]===m?b=t[15]:(b=m?(0,$.jsx)(`span`,{className:`shrink-0 text-[11px] leading-none font-normal text-muted-foreground`,children:m}):null,t[14]=m,t[15]=b);let x;t[16]!==y||t[17]!==b?(x=(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1`,children:[y,b]}),t[16]=y,t[17]=b,t[18]=x):x=t[18];let S;t[19]!==v||t[20]!==x?(S=(0,$.jsxs)(`span`,{className:`flex h-full w-full min-w-0 items-center gap-1`,children:[v,x]}),t[19]=v,t[20]=x,t[21]=S):S=t[21];let C;return t[22]!==h||t[23]!==l||t[24]!==n||t[25]!==S||t[26]!==g?(C=(0,$.jsx)(`button`,{type:`button`,disabled:l,onClick:n,onMouseDown:xg,onPointerDownCapture:Sg,className:g,style:_,title:h,"aria-label":h,children:S}),t[22]=h,t[23]=l,t[24]=n,t[25]=S,t[26]=g,t[27]=C):C=t[27],C};function xg(e){return e.preventDefault()}function Sg(e){e.preventDefault()}var Cg=e=>!(!e.sessionId||e.composerSurfaceKind===`secondary`||e.hasSessionEntity||e.hasRenderableSessionSnapshot),wg=e=>{let t=e.isSubagentSession&&!e.allowPromptingSubagentSessions;return{showReadOnlyBanner:e.isSubagentSession&&(e.readOnly||t),blockSubmission:e.sessionIdentityPending}},Tg=(e,t)=>({agentName:t.agentName??e?.agentName,providerId:t.providerId??e?.providerId,modelId:t.modelId??e?.modelId}),Eg=(e,t)=>e.id===t.id&&e.directory===t.directory,Dg=(e,t)=>e.agentName===t.agentName&&e.providerId===t.providerId&&e.modelId===t.modelId,Og=(e,t,n,r)=>{if(!t)return null;let i=n??(e?.viewKey===t?e.parentTarget:null);if(!i)return null;let a=Tg(e?.viewKey===t?e.execution:void 0,r);return e&&e.viewKey===t&&Eg(e.parentTarget,i)&&Dg(e.execution,a)?e:{viewKey:t,parentTarget:i,execution:a}},kg=e=>{let{inFlight:t,establishing:n}=e.sendPhase,r=!n&&(e.draftSubmitting||t);return{sendDisabled:!e.canSend||!e.hasSessionTarget||e.submissionBlocked||r,queueDisabled:!e.hasSessionTarget||e.submissionBlocked||!n&&t||e.queueFrozen&&!e.queueFallbackAvailable,disabledClass:`opacity-30 pointer-events-none`}},Ag=e=>{let t=e.trim();if(!t)return null;let n=t.match(/\/issues\/(\d+)(?:\b|\/|$)/i);if(n){let e=Number(n[1]);return Number.isFinite(e)&&e>0?e:null}let r=t.match(/^#?(\d+)$/);if(r){let e=Number(r[1]);return Number.isFinite(e)&&e>0?e:null}return null},jg=e=>{let t={repo:e.repo??null,issue:e.issue,comments:e.comments};return`GitHub issue context (JSON)\n${JSON.stringify(t,null,2)}`};function Mg({open:e,onOpenChange:t,mode:n=`createSession`,onSelect:r}){let{t:i}=na(),{github:a}=Vt(),o=ed(),s=o.data??null,c=o.isFetched,l=ln(e=>e.setSettingsDialogOpen),u=ln(e=>e.setSettingsPage),d=ln(e=>e.isMobile),{isTablet:f}=Ia(),p=d||f,m=Bn(e=>e.getActiveProject()),h=qe(e=>e.currentDirectory),g=Q.useMemo(()=>m?.path?.trim()||h?.trim()||null,[m?.path,h]),[_,v]=Q.useState(``),[y,b]=Q.useState(!1),[x,S]=Q.useState(null),C=Q.useRef(0),w=Q.useMemo(()=>Ag(_),[_]),T=is(_,350),E=w?``:T.trim(),D=!!w||_===T,O=e&&D&&!!g&&!!a?.issuesList&&!(c&&s?.connected===!1),k=Ft({queryKey:zt.scoped(`github-issues`,g,E),enabled:O,initialPageParam:1,refetchOnMount:`always`,queryFn:({pageParam:e})=>a.issuesList(g,{page:e,...E?{query:E}:{}}),getNextPageParam:e=>e.hasMore?(e.page??1)+1:void 0}),A=D?k.data?.pages.at(-1)??null:null,j=D?k.data?.pages.flatMap(e=>e.issues??[])??[]:[],M=D&&k.hasNextPage,N=!w&&!D||k.isLoading,P=D&&k.isFetchingNextPage,F=D&&k.error?k.error instanceof Error?k.error.message:String(k.error):null,I=Q.useCallback(()=>k.refetch(),[k]),L=Q.useCallback(async()=>{try{await k.fetchNextPage()}catch(e){let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.loadMoreFailed`),{description:t})}},[k,i]);Q.useEffect(()=>{e||(++C.current,v(``),b(!1),S(null))},[e]),Q.useEffect(()=>{++C.current},[e,g]);let R=!c||s?.connected!==!1&&A?.connected!==!1,ee=A?.repo?.url??null,z=Q.useCallback(()=>{u(`github`),l(!0)},[l,u]),B=Q.useCallback(()=>{let e=kr.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},[]),V=Q.useCallback(()=>{let e=kr.getState(),t=e.settingsDefaultModel??(e.currentModelId?void 0:e.opencodeDefaultModel);if(!t)return null;let n=Yn(t);if(!n)return null;let{providerId:r,modelId:i}=n;return{providerID:r,modelID:i}},[]),H=Q.useCallback((e,t)=>{let n=kr.getState(),r=Yn(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},[]),U=Q.useCallback(async(e,o)=>{let s=++C.current,c=()=>C.current===s;if(n===`select`){if(!g){Fi.error(i(`session.githubIssuePicker.error.noActiveProject`));return}if(!a?.issueGet||!a?.issueComments){Fi.error(i(`session.githubIssuePicker.error.runtimeUnavailable`));return}if(x)return;S(e);try{let n=await a.issueGet(g,e,{sourceRepo:o});if(!c())return;if(n.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}if(!n.repo){Fi.error(i(`session.githubIssuePicker.error.repoNotResolvable`),{description:i(`session.githubIssuePicker.error.repoMustBeGithub`)});return}let s=n.issue;if(!s){Fi.error(i(`session.githubIssuePicker.error.issueNotFound`));return}let l=await a.issueComments(g,e,{sourceRepo:o});if(!c())return;if(l.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}let u=l.comments??[],d=jg({repo:n.repo,issue:s,comments:u});r&&r({number:s.number,title:s.title,url:s.url,contextText:d,author:s.author?{login:s.author.login,avatarUrl:s.author.avatarUrl}:void 0}),t(!1)}catch(e){if(!c())return;let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.loadIssueDetailsFailed`),{description:t})}finally{c()&&S(null)}return}if(!g){Fi.error(i(`session.githubIssuePicker.error.noActiveProject`));return}if(!a?.issueGet||!a?.issueComments){Fi.error(i(`session.githubIssuePicker.error.runtimeUnavailable`));return}if(!x){S(e);try{let n=await a.issueGet(g,e,{sourceRepo:o});if(!c())return;if(n.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}if(!n.repo){Fi.error(i(`session.githubIssuePicker.error.repoNotResolvable`),{description:i(`session.githubIssuePicker.error.repoMustBeGithub`)});return}let r=n.issue;if(!r){Fi.error(i(`session.githubIssuePicker.error.issueNotFound`));return}let s=await a.issueComments(g,e,{sourceRepo:o});if(!c())return;if(s.connected===!1){Fi.error(i(`session.githubIssuePicker.error.notConnected`));return}let l=s.comments??[],u=`#${r.number} ${r.title}`.trim(),{sessionId:d}=await(async()=>{if(y){let e=`issue-${r.number}-${Xc()}`,t=await qc(g,e,void 0,{returnAfterDirectoryCreated:!0});if(!t?.id)throw Error(`Failed to create worktree session`);return{sessionId:t.id,sessionDirectory:t.path}}let e=await Er(u,g,null);if(!e?.id)throw Error(`Failed to create session`);return{sessionId:e.id,sessionDirectory:e.directory??g}})();if(!c())return;Qr(d,u).catch(()=>void 0);try{Xr.getState().initializeNewYuriSession(d,kr.getState().agents)}catch{}t(!1);let f=kr.getState(),p=Oi.getState().lastUsedProvider,m=V(),h=m?.providerID||f.currentProviderId||p?.providerID,_=m?.modelID||f.currentModelId||p?.modelID,v=B()||f.currentAgentName||void 0;if(!h||!_){Fi.error(i(`session.githubIssuePicker.error.noModelSelected`));return}let b=H(h,_),x=await Ka(`github.issue.review.visible`,{issue_number:String(r.number)});if(!c())return;let S=await Ka(`github.issue.review.instructions`);if(!c())return;let C=jg({repo:n.repo,issue:r,comments:l});Xr.getState().sendMessage(x,h,_,v,void 0,void 0,[{text:S,synthetic:!0},{text:C,synthetic:!0}],b,void 0,{sessionId:d}).catch(e=>{let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.sendContextFailed`),{description:t})}),Fi.success(i(`session.githubIssuePicker.toast.sessionCreated`))}catch(e){if(!c())return;let t=e instanceof Error?e.message:String(e);Fi.error(i(`session.githubIssuePicker.toast.startSessionFailed`),{description:t})}finally{c()&&S(null)}}},[y,a,n,t,r,g,B,V,H,x,i]),te=i(n===`select`?`session.githubIssuePicker.title.select`:`session.githubIssuePicker.title.createSession`),ne=i(n===`select`?`session.githubIssuePicker.description.select`:`session.githubIssuePicker.description.createSession`),re=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-picker-search relative mt-2`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(Do,{placeholder:i(`session.githubIssuePicker.searchPlaceholder`),value:_,onChange:e=>{v(e.target.value)},className:`pl-9 w-full`})]}),(0,$.jsxs)(`div`,{className:J(`yuri-picker-list`,d?`min-h-0 mt-2`:`flex-1 overflow-y-auto mt-2`),children:[g?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:i(`session.githubIssuePicker.empty.noActiveProject`)}),a?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:i(`session.githubIssuePicker.empty.runtimeUnavailable`)}),N?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 flex items-center justify-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),i(`session.githubIssuePicker.loading.issues`)]}):null,R===!1?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 space-y-3`,children:[(0,$.jsx)(`div`,{children:i(`session.githubIssuePicker.empty.notConnected`)}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,onClick:z,children:i(`session.githubIssuePicker.actions.openSettings`)})})]}):null,F?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8 break-words`,children:F}):null,w&&g&&a&&R?(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,x===w&&`bg-interactive-selection/30`),onClick:()=>void U(w),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground w-5 text-right flex-shrink-0`,children:`#`}),(0,$.jsx)(`p`,{className:`flex-1 min-w-0 typography-small text-foreground truncate ml-0.5`,children:i(`session.githubIssuePicker.actions.useIssue`,{number:w})}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:x===w?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):null})]}):null,j.length===0&&!N&&!F&&R&&a&&g?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:T.trim()?i(`session.githubIssuePicker.empty.noIssuesFound`):i(`session.githubIssuePicker.empty.noOpenIssuesFound`)}):null,j.map(e=>(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,x===e.number&&`bg-interactive-selection/30`),onClick:()=>void U(e.number,e.sourceRepo),children:[(0,$.jsxs)(`span`,{className:`typography-meta text-muted-foreground w-12 text-right flex-shrink-0`,children:[`#`,e.number]}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 ml-0.5`,children:[(0,$.jsx)(`p`,{className:`yuri-picker-label typography-small text-foreground truncate`,children:e.title}),e.sourceRepo?.source===`upstream`?(0,$.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]}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:x===e.number?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:J(`h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors`,p?`flex`:`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),"aria-label":i(`session.githubIssuePicker.actions.openInGitHubAria`),children:(0,$.jsx)(X,{name:`external-link`,className:`h-4 w-4`})})})]},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)),M&&R&&g&&a?(0,$.jsx)(`div`,{className:`py-2 flex justify-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void L(),disabled:P||!!x,className:J(`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4`,(P||!!x)&&`opacity-50 cursor-not-allowed hover:text-muted-foreground`),children:P?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),i(`session.githubIssuePicker.loading.more`)]}):i(`session.githubIssuePicker.actions.loadMore`)})}):null]}),n!==`select`&&(0,$.jsx)(`div`,{className:d?`mt-4 p-3 bg-muted/30 rounded-lg`:`yuri-picker-footer`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 cursor-pointer`,role:`button`,tabIndex:0,"aria-pressed":y,onClick:()=>b(e=>!e),onKeyDown:e=>{(e.key===` `||e.key===`Enter`)&&(e.preventDefault(),b(e=>!e))},children:[(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.preventDefault(),e.stopPropagation(),b(e=>!e)},"aria-label":i(`session.githubIssuePicker.actions.toggleWorktreeAria`),className:`flex h-5 w-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:y?(0,$.jsx)(X,{name:`checkbox`,className:`h-4 w-4 text-primary`}):(0,$.jsx)(X,{name:`checkbox-blank`,className:`h-4 w-4`})}),(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground`,children:i(`session.githubIssuePicker.actions.createInWorktree`)})]}),(0,$.jsx)(`div`,{className:`hidden sm:block sm:flex-1`}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[ee?(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,asChild:!0,children:(0,$.jsxs)(`a`,{href:ee,target:`_blank`,rel:`noopener noreferrer`,children:[(0,$.jsx)(X,{name:`external-link`,className:`size-4`}),i(`session.githubIssuePicker.actions.openRepo`)]})}):null,(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,onClick:I,disabled:N||!!x,children:i(`session.githubIssuePicker.actions.refresh`)})]})]})})]});return d?(0,$.jsx)(xu,{open:e,title:te,onClose:()=>t(!1),renderHeader:e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-3 py-2 border-b border-border/40`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:te}),e]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:ne})]}),children:re}):(0,$.jsx)(Ea,{open:e,onOpenChange:t,children:(0,$.jsxs)(Sa,{presentation:`picker`,children:[(0,$.jsx)(ba,{className:`yuri-picker-header`,children:(0,$.jsx)(Ca,{className:`yuri-picker-title`,children:te})}),re]})})}var Ng=e=>{let t=e.trim();if(!t)return null;let n=t.match(/\/pull\/(\d+)(?:\b|\/|$)/i);if(n){let e=Number(n[1]);return Number.isFinite(e)&&e>0?e:null}let r=t.match(/^#?(\d+)$/);if(r){let e=Number(r[1]);return Number.isFinite(e)&&e>0?e:null}return null},Pg=e=>`GitHub pull request context (JSON)\n${JSON.stringify(e,null,2)}`;function Fg({open:e,onOpenChange:t,onSelect:n}){let{t:r}=na(),{github:i}=Vt(),a=ed(),o=a.data??null,s=a.isFetched,c=ln(e=>e.setSettingsDialogOpen),l=ln(e=>e.setSettingsPage),u=ln(e=>e.isMobile),{isTablet:d}=Ia(),f=u||d,p=Bn(e=>e.getActiveProject())?.path??null,[m,h]=Q.useState(``),[g,_]=Q.useState(!1),[v,y]=Q.useState(null),b=Q.useRef(0),x=Q.useMemo(()=>Ng(m),[m]),S=is(m,350),C=x?``:S.trim(),w=!!x||m===S,T=e&&w&&!!p&&!!i?.prsList&&!(s&&o?.connected===!1),E=Ft({queryKey:zt.scoped(`github-prs`,p,C),enabled:T,initialPageParam:1,refetchOnMount:`always`,queryFn:({pageParam:e})=>i.prsList(p,{page:e,...C?{query:C}:{}}),getNextPageParam:e=>e.hasMore?(e.page??1)+1:void 0}),D=w?E.data?.pages.at(-1)??null:null,O=w?E.data?.pages.flatMap(e=>e.prs??[])??[]:[],k=w&&E.hasNextPage,A=!x&&!w||E.isLoading,j=w&&E.isFetchingNextPage,M=w&&E.error?E.error instanceof Error?E.error.message:String(E.error):null,N=G(async()=>{try{await E.fetchNextPage()}catch(e){let t=e instanceof Error?e.message:String(e);Fi.error(r(`session.githubPrPicker.toast.loadMoreFailed`),{description:t})}});Q.useEffect(()=>{e||(++b.current,h(``),_(!1),y(null))},[e]),Q.useEffect(()=>{++b.current},[e,p]);let P=!s||o?.connected!==!1&&D?.connected!==!1,F=G(()=>{l(`github`),c(!0)}),I=G(async(e,a)=>{if(!p){Fi.error(r(`session.githubPrPicker.error.noActiveProject`));return}if(!i?.prContext){Fi.error(r(`session.githubPrPicker.error.runtimeUnavailable`));return}if(v)return;let o=++b.current,s=()=>b.current===o;y(e);try{let o=await i.prContext(p,e,{includeDiff:g,includeCheckDetails:!1,sourceRepo:a});if(!s())return;if(o.connected===!1){Fi.error(r(`session.githubPrPicker.error.notConnected`));return}if(!o.pr){Fi.error(r(`session.githubPrPicker.error.prNotFound`));return}if(!o.repo){Fi.error(r(`session.githubPrPicker.error.repoNotResolvable`),{description:r(`session.githubPrPicker.error.repoMustBeGithub`)});return}if(n){let e=await Ka(`github.pr.review.instructions`);if(!s())return;n({number:o.pr.number,title:o.pr.title,url:o.pr.url,head:o.pr.head,base:o.pr.base,includeDiff:g,instructionsText:e,contextText:Pg(o),author:o.pr.author?{login:o.pr.author.login,avatarUrl:o.pr.author.avatarUrl}:void 0})}t(!1)}catch(e){if(!s())return;let t=e instanceof Error?e.message:String(e);Fi.error(r(`session.githubPrPicker.toast.loadDetailsFailed`),{description:t})}finally{s()&&y(null)}}),L=r(`session.githubPrPicker.title`),R=r(`session.githubPrPicker.description`),ee=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`yuri-picker-search mt-2 flex flex-wrap items-center gap-3`,children:[(0,$.jsxs)(`div`,{className:`relative flex-1 min-w-0`,children:[(0,$.jsx)(X,{name:`search`,className:`absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground`}),(0,$.jsx)(Do,{placeholder:r(`session.githubPrPicker.searchPlaceholder`),value:m,onChange:e=>{h(e.target.value)},className:`pl-9 w-full`})]}),(0,$.jsxs)(`button`,{type:`button`,onClick:()=>_(e=>!e),className:`h-9 shrink-0 flex items-center gap-2 text-left`,"aria-pressed":g,"aria-label":r(`session.githubPrPicker.includeDiffAria`),children:[(0,$.jsx)(`span`,{onClick:e=>e.stopPropagation(),children:(0,$.jsx)(ls,{checked:g,onChange:e=>_(e),ariaLabel:r(`session.githubPrPicker.includeDiffAria`)})}),(0,$.jsx)(`span`,{className:`typography-small text-muted-foreground whitespace-nowrap`,children:r(`session.githubPrPicker.includeDiff`)})]})]}),(0,$.jsxs)(`div`,{className:J(`yuri-picker-list`,u?`min-h-0`:`flex-1 overflow-y-auto`),children:[p?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:r(`session.githubPrPicker.empty.noActiveProject`)}),i?null:(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:r(`session.githubPrPicker.empty.runtimeUnavailable`)}),A?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 flex items-center justify-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),r(`session.githubPrPicker.loading.pullRequests`)]}):null,P===!1?(0,$.jsxs)(`div`,{className:`text-center text-muted-foreground py-8 space-y-3`,children:[(0,$.jsx)(`div`,{children:r(`session.githubPrPicker.empty.notConnected`)}),(0,$.jsx)(`div`,{className:`flex justify-center`,children:(0,$.jsx)(Tr,{variant:`outline`,size:`sm`,onClick:F,children:r(`session.githubPrPicker.actions.openSettings`)})})]}):null,M?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8 break-words`,children:M}):null,x&&p&&i&&P?(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,v===x&&`bg-interactive-selection/30`),onClick:()=>void I(x),children:[(0,$.jsx)(`span`,{className:`typography-meta text-muted-foreground w-5 text-right flex-shrink-0`,children:`#`}),(0,$.jsx)(`p`,{className:`flex-1 min-w-0 typography-small text-foreground truncate ml-0.5`,children:r(`session.githubPrPicker.actions.usePullRequest`,{number:x})}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:v===x?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):null})]}):null,O.length===0&&!A&&!M&&P&&i&&p?(0,$.jsx)(`div`,{className:`text-center text-muted-foreground py-8`,children:S.trim()?r(`session.githubPrPicker.empty.noPullRequestsFound`):r(`session.githubPrPicker.empty.noOpenPullRequestsFound`)}):null,O.map(e=>(0,$.jsxs)(`div`,{className:J(`yuri-picker-row group flex items-center gap-2 py-1.5 hover:bg-interactive-hover/30 rounded transition-colors cursor-pointer`,v===e.number&&`bg-interactive-selection/30`),onClick:()=>void I(e.number,e.sourceRepo),children:[(0,$.jsxs)(`div`,{className:`flex-1 min-w-0 ml-0.5`,children:[(0,$.jsxs)(`p`,{className:`yuri-picker-label typography-small text-foreground truncate`,children:[(0,$.jsxs)(`span`,{className:`text-muted-foreground mr-1`,children:[`#`,e.number]}),e.title]}),e.sourceRepo?.source===`upstream`?(0,$.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,(0,$.jsxs)(`p`,{className:`yuri-picker-meta typography-meta text-muted-foreground truncate`,children:[e.head,` → `,e.base]})]}),(0,$.jsx)(`div`,{className:`flex-shrink-0 h-5 flex items-center mr-2`,children:v===e.number?(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin text-muted-foreground`}):(0,$.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:J(`h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground transition-colors`,f?`flex`:`hidden group-hover:flex`),onClick:e=>e.stopPropagation(),"aria-label":r(`session.githubPrPicker.actions.openInGitHubAria`),children:(0,$.jsx)(X,{name:`external-link`,className:`h-4 w-4`})})})]},`${e.sourceRepo?.owner??``}-${e.sourceRepo?.repo??``}-${e.number}`)),k&&P&&p&&i?(0,$.jsx)(`div`,{className:`py-2 flex justify-center`,children:(0,$.jsx)(`button`,{type:`button`,onClick:()=>void N(),disabled:j||!!v,className:J(`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-4`,(j||!!v)&&`opacity-50 cursor-not-allowed hover:text-muted-foreground`),children:j?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,$.jsx)(X,{name:`loader-4`,className:`h-4 w-4 animate-spin`}),r(`session.githubPrPicker.loading.more`)]}):r(`session.githubPrPicker.actions.loadMore`)})}):null]})]});return u?(0,$.jsx)(xu,{open:e,title:L,onClose:()=>t(!1),renderHeader:e=>(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-3 py-2 border-b border-border/40`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h2`,{className:`typography-ui-label font-semibold text-foreground`,children:L}),e]}),(0,$.jsx)(`p`,{className:`typography-small text-muted-foreground`,children:R})]}),children:ee}):(0,$.jsx)(Ea,{open:e,onOpenChange:t,children:(0,$.jsxs)(Sa,{presentation:`picker`,children:[(0,$.jsx)(ba,{className:`yuri-picker-header`,children:(0,$.jsx)(Ca,{className:`yuri-picker-title`,children:L})}),ee]})})}var Ig=(e,t)=>`${e}:${at(t)}`,Lg=e=>e.type===`skill`||!Ie(e.name);function Rg(e){let{t}=na(),n=Q.useMemo(()=>d(),[]),r=ln(e=>e.globalDraftStarters),i=Bn(e=>e.activeProjectId),a=Bn(e=>e.projects),o=Q.useMemo(()=>{if(!i)return null;let e=a.find(e=>e.id===i);return e?.path?{id:e.id,path:e.path}:null},[i,a]),[s,c]=Q.useState([]),l=Q.useMemo(()=>r??Ze,[r]),u=l.some(Lg)||s.some(Lg),f=vr({directory:e,enabled:u}),p=Q.useMemo(()=>f.data??[],[f.data]),{refetch:m}=f,h=En({directory:e,enabled:u}),g=Q.useMemo(()=>h.data??[],[h.data]),{refetch:_}=h;Q.useEffect(()=>{let e=!1;if(!o){c([]);return}return Ii(o).then(t=>{e||c(t)}).catch(()=>{e||c([])}),()=>{e=!0}},[o?.id]);let v=Q.useCallback(()=>{m(),_()},[m,_]),y=Q.useMemo(()=>new Set(p.map(e=>e.name)),[p]),b=Q.useMemo(()=>new Set(g.map(e=>e.name)),[g]),x=Q.useCallback((e,r)=>{if(n&&e.type===`command`&&e.name===`craft-goal`)return null;if(e.type===`command`){let n=Ie(e.name);return n?{id:Ig(r,e),ref:e,group:r,label:t(n.labelKey),icon:n.icon,submitText:n.command}:y.has(e.name)?{id:Ig(r,e),ref:e,group:r,label:$e(e.name),icon:Ye,submitText:`/${e.name}`}:null}return b.has(e.name)?{id:Ig(r,e),ref:e,group:r,label:$e(e.name),icon:Ge,submitText:`@${e.name}`}:null},[t,y,b,n]),S=Q.useMemo(()=>l.map(e=>x(e,`global`)).filter(e=>e!==null),[l,x]),C=Q.useMemo(()=>s.map(e=>x(e,`project`)).filter(e=>e!==null),[s,x]),w=Q.useMemo(()=>{let e=new Set;for(let t of l)e.add(at(t));for(let t of s)e.add(at(t));return e},[l,s]),T=Q.useMemo(()=>{let e=[];for(let r of Xe)n&&r.name===`craft-goal`||e.push({type:`command`,name:r.name,label:t(r.labelKey),icon:r.icon,section:`built-in`,scope:`user`});for(let t of p)t.isBuiltIn||t.source===`skill`||Ie(t.name)||e.push({type:`command`,name:t.name,label:$e(t.name),icon:Ye,section:`command`,scope:t.scope===`project`?`project`:`user`});for(let t of g)e.push({type:`skill`,name:t.name,label:$e(t.name),icon:Ge,section:`skill`,scope:t.scope===`project`?`project`:`user`});return e.filter(e=>!w.has(`${e.type}:${e.name}`))},[t,p,g,w,n]),E=Q.useCallback(e=>{ln.getState().setGlobalDraftStarters(e),He({draftStarters:e})},[]),D=Q.useCallback(e=>{c(e),o&&Pr(o,e)},[o]),O=Q.useCallback(e=>{let t={type:e.type,name:e.name};if(e.scope===`project`){if(!o||s.some(e=>ot(e,t)))return;D([...s,t])}else{let e=r??Ze;if(e.some(e=>ot(e,t)))return;E([...e,t])}},[o,s,r,D,E]),k=Q.useCallback((e,t)=>{e===`project`?D(s.filter(e=>!ot(e,t))):E((r??Ze).filter(e=>!ot(e,t)))},[s,r,D,E]),A=Q.useCallback((e,t,n)=>{let i=e===`project`?s:r??Ze,a=i.findIndex(n=>Ig(e,n)===t),o=i.findIndex(t=>Ig(e,t)===n);if(a<0||o<0||a===o)return;let c=_u([...i],a,o);e===`project`?D(c):E(c)},[s,r,D,E]);return{global:S,project:C,pinnable:T,hasProject:!!o,ensureLoaded:v,addStarter:O,removeStarter:k,reorder:A}}var zg=`__draft-starter-trash__`,Bg=`inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-[var(--interactive-hover)] hover:text-foreground`,Vg=`max-h-7`,Hg=[{key:`built-in`,headingKey:`chat.draftStarters.sectionBuiltIn`},{key:`command`,headingKey:`chat.draftStarters.sectionCommands`},{key:`skill`,headingKey:`chat.draftStarters.sectionSkills`}],Ug=e=>{let t=(0,Z.c)(35),{item:n,onSubmit:r,onRemove:i,hideRemove:a}=e,{t:o}=na(),s;t[0]===n.id?s=t[1]:(s={id:n.id},t[0]=n.id,t[1]=s);let{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:f,isDragging:p}=vu(s),m;t[2]===d?m=t[3]:(m=hu.Translate.toString(d),t[2]=d,t[3]=m);let h;t[4]!==m||t[5]!==f?(h={transform:m,transition:f},t[4]=m,t[5]=f,t[6]=h):h=t[6];let g=p&&`z-10 opacity-60`,_;t[7]===g?_=t[8]:(_=J(`group/chip relative`,g),t[7]=g,t[8]=_);let v;t[9]!==n.submitText||t[10]!==r?(v=()=>r(n.submitText),t[9]=n.submitText,t[10]=r,t[11]=v):v=t[11];let y=!a&&`pr-5`,b;t[12]===y?b=t[13]:(b=J(`group inline-flex touch-none select-none items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground transition-colors`,`hover:bg-[var(--interactive-hover)] hover:text-foreground`,y),t[12]=y,t[13]=b);let x;t[14]===n.icon?x=t[15]:(x=(0,$.jsx)(X,{name:n.icon,className:`h-3 w-3 shrink-0 opacity-60 transition-opacity group-hover:opacity-100`}),t[14]=n.icon,t[15]=x);let S;t[16]===n.label?S=t[17]:(S=(0,$.jsx)(`span`,{className:`whitespace-nowrap`,children:n.label}),t[16]=n.label,t[17]=S);let C;t[18]!==c||t[19]!==l||t[20]!==S||t[21]!==v||t[22]!==b||t[23]!==x?(C=(0,$.jsxs)(`button`,{type:`button`,...c,...l,onClick:v,className:b,children:[x,S]}),t[18]=c,t[19]=l,t[20]=S,t[21]=v,t[22]=b,t[23]=x,t[24]=C):C=t[24];let w;t[25]!==a||t[26]!==i||t[27]!==o?(w=a?null:(0,$.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),i()},"aria-label":o(`chat.draftStarters.remove`),title:o(`chat.draftStarters.remove`),className:`absolute right-0.5 top-1/2 hidden h-4 w-4 -translate-y-1/2 items-center justify-center rounded text-muted-foreground hover:text-foreground group-hover/chip:flex`,children:(0,$.jsx)(X,{name:`close`,className:`h-2.5 w-2.5`})}),t[25]=a,t[26]=i,t[27]=o,t[28]=w):w=t[28];let T;return t[29]!==u||t[30]!==C||t[31]!==w||t[32]!==h||t[33]!==_?(T=(0,$.jsxs)(`div`,{ref:u,style:h,className:_,children:[C,w]}),t[29]=u,t[30]=C,t[31]=w,t[32]=h,t[33]=_,t[34]=T):T=t[34],T},Wg=e=>{let t=(0,Z.c)(14),{items:n,onSubmit:r,onRemove:i,hideRemove:a}=e,o;t[0]===n?o=t[1]:(o=n.map(Yg),t[0]=n,t[1]=o);let s;if(t[2]!==a||t[3]!==n||t[4]!==i||t[5]!==r){let e;t[7]!==a||t[8]!==i||t[9]!==r?(e=e=>(0,$.jsx)(Ug,{item:e,onSubmit:r,onRemove:()=>i(e),hideRemove:a},e.id),t[7]=a,t[8]=i,t[9]=r,t[10]=e):e=t[10],s=n.map(e),t[2]=a,t[3]=n,t[4]=i,t[5]=r,t[6]=s}else s=t[6];let c;return t[11]!==o||t[12]!==s?(c=(0,$.jsx)(bu,{items:o,strategy:gu,children:s}),t[11]=o,t[12]=s,t[13]=c):c=t[13],c},Gg=()=>{let e=(0,Z.c)(13),{t}=na(),n;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(n={id:zg},e[0]=n):n=e[0];let{setNodeRef:r,isOver:i}=uu(n),a;e[1]===t?a=e[2]:(a=t(`chat.draftStarters.remove`),e[1]=t,e[2]=a);let o;e[3]===t?o=e[4]:(o=t(`chat.draftStarters.remove`),e[3]=t,e[4]=o);let s=i&&`text-destructive hover:text-destructive`,c;e[5]===s?c=e[6]:(c=J(Bg,s),e[5]=s,e[6]=c);let l;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(X,{name:`delete-bin`,className:`h-3.5 w-3.5`}),e[7]=l):l=e[7];let u;return e[8]!==r||e[9]!==a||e[10]!==o||e[11]!==c?(u=(0,$.jsx)(`button`,{type:`button`,ref:r,"aria-label":a,title:o,className:c,children:l}),e[8]=r,e[9]=a,e[10]=o,e[11]=c,e[12]=u):u=e[12],u},Kg=e=>{let t=(0,Z.c)(21),{pinnable:n,onPick:r,className:i}=e,{t:a}=na(),o;t[0]===i?o=t[1]:(o=J(`min-h-0`,i),t[0]=i,t[1]=o);let s;t[2]===a?s=t[3]:(s=a(`chat.draftStarters.searchPlaceholder`),t[2]=a,t[3]=s);let c;t[4]===s?c=t[5]:(c=(0,$.jsx)(Uc,{placeholder:s}),t[4]=s,t[5]=c);let l;t[6]===a?l=t[7]:(l=a(`chat.draftStarters.empty`),t[6]=a,t[7]=l);let u;t[8]===l?u=t[9]:(u=(0,$.jsx)(nl,{children:l}),t[8]=l,t[9]=u);let d;t[10]!==r||t[11]!==n||t[12]!==a?(d=Hg.map(e=>{let t=n.filter(t=>t.section===e.key);return t.length===0?null:(0,$.jsx)(bl,{heading:a(e.headingKey),children:t.map(e=>(0,$.jsx)(yl,{value:`${e.section} ${e.label} ${e.name}`,onSelect:()=>r(e),children:(0,$.jsx)(`span`,{className:`truncate`,children:e.label})},`${e.type}:${e.name}`))},e.key)}),t[10]=r,t[11]=n,t[12]=a,t[13]=d):d=t[13];let f;t[14]!==u||t[15]!==d?(f=(0,$.jsxs)(el,{children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;return t[17]!==o||t[18]!==c||t[19]!==f?(p=(0,$.jsxs)(Gc,{className:o,children:[c,f]}),t[17]=o,t[18]=c,t[19]=f,t[20]=p):p=t[20],p},qg=e=>{let t=(0,Z.c)(27),{pinnable:n,onOpen:r,onAdd:i}=e,{t:a}=na(),[o,s]=Q.useState(!1),c;t[0]===r?c=t[1]:(c=e=>{s(e),e&&r()},t[0]=r,t[1]=c);let l;t[2]===a?l=t[3]:(l=a(`chat.draftStarters.add`),t[2]=a,t[3]=l);let u;t[4]===a?u=t[5]:(u=a(`chat.draftStarters.add`),t[4]=a,t[5]=u);let d;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(X,{name:`add`,className:`h-3.5 w-3.5`}),t[6]=d):d=t[6];let f;t[7]!==l||t[8]!==u?(f=(0,$.jsx)(Ta,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,"aria-label":l,title:u,className:Bg,children:d})}),t[7]=l,t[8]=u,t[9]=f):f=t[9];let p;t[10]===a?p=t[11]:(p=a(`chat.draftStarters.add`),t[10]=a,t[11]=p);let m;t[12]===p?m=t[13]:(m=(0,$.jsx)(ba,{className:`px-4 pb-2 pt-4 text-left`,children:(0,$.jsx)(Ca,{children:p})}),t[12]=p,t[13]=m);let h;t[14]===i?h=t[15]:(h=e=>{i(e),s(!1)},t[14]=i,t[15]=h);let g;t[16]!==n||t[17]!==h?(g=(0,$.jsx)(Kg,{pinnable:n,onPick:h,className:`flex max-h-[60vh] flex-col`}),t[16]=n,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==m||t[20]!==g?(_=(0,$.jsxs)(Sa,{className:`gap-0 overflow-hidden p-0 sm:max-w-sm`,children:[m,g]}),t[19]=m,t[20]=g,t[21]=_):_=t[21];let v;return t[22]!==o||t[23]!==c||t[24]!==_||t[25]!==f?(v=(0,$.jsxs)(Ea,{open:o,onOpenChange:c,children:[f,_]}),t[22]=o,t[23]=c,t[24]=_,t[25]=f,t[26]=v):v=t[26],v},Jg=e=>{let t=(0,Z.c)(63),{onSubmit:n,className:r}=e,{t:i}=na(),{global:a,project:o,pinnable:s,ensureLoaded:c,addStarter:l,removeStarter:u,reorder:d}=Rg(Ga()),{isMobile:f}=Ia(),[p,m]=Q.useState(!1),[h,g]=Q.useState(!1),[_,v]=Q.useState(!1),y=Q.useRef(null),b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b={activationConstraint:{distance:8}},t[0]=b):b=t[0];let x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x={activationConstraint:{delay:200,tolerance:6}},t[1]=x):x=t[1];let S=mu(su(fu,b),su(lu,x)),C;t[2]!==a||t[3]!==o?(C=e=>a.find(t=>t.id===e)??o.find(t=>t.id===e),t[2]=a,t[3]=o,t[4]=C):C=t[4];let w=C,T=a.length+o.length,E;t[5]===T?E=t[6]:(E=()=>{let e=y.current;if(!e||T===0){v(!1);return}let t=()=>{let t=e.firstElementChild?.offsetHeight??28;v(e.scrollHeight>t+4)};t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},t[5]=T,t[6]=E);let D;t[7]!==h||t[8]!==a||t[9]!==o||t[10]!==T?(D=[T,h,a,o],t[7]=h,t[8]=a,t[9]=o,t[10]=T,t[11]=D):D=t[11],Q.useLayoutEffect(E,D);let O,k;t[12]!==_||t[13]!==h?(O=()=>{!_&&h&&g(!1)},k=[_,h],t[12]=_,t[13]=h,t[14]=O,t[15]=k):(O=t[14],k=t[15]),Q.useEffect(O,k);let A;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(A=()=>m(!0),t[16]=A):A=t[16];let j=A,M;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>m(!1),t[17]=M):M=t[17];let N=M,P;t[18]!==w||t[19]!==u||t[20]!==d?(P=e=>{m(!1);let{active:t,over:n}=e;if(!n)return;let r=String(t.id),i=w(r);if(!i)return;if(String(n.id)===zg){u(i.group,i.ref);return}let a=String(n.id);if(r===a)return;let o=w(a);o&&o.group===i.group&&d(i.group,r,a)},t[18]=w,t[19]=u,t[20]=d,t[21]=P):P=t[21];let F=P,I=_||h,L;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(L={droppable:{strategy:cu.Always}},t[22]=L):L=t[22];let R;t[23]===r?R=t[24]:(R=J(`flex min-w-0 max-w-full items-start justify-center gap-0.5`,r),t[23]=r,t[24]=R);let ee=!h&&Vg,z=!h&&`overflow-clip`,B;t[25]!==ee||t[26]!==z?(B=J(`flex min-w-0 flex-1 flex-wrap items-center justify-center gap-x-0.5 gap-y-0.5`,ee,z),t[25]=ee,t[26]=z,t[27]=B):B=t[27];let V;t[28]!==a||t[29]!==f||t[30]!==n||t[31]!==u?(V=a.length>0?(0,$.jsx)(Wg,{items:a,onSubmit:n,onRemove:e=>u(`global`,e.ref),hideRemove:f}):null,t[28]=a,t[29]=f,t[30]=n,t[31]=u,t[32]=V):V=t[32];let H;t[33]!==f||t[34]!==n||t[35]!==o||t[36]!==u?(H=o.length>0?(0,$.jsx)(Wg,{items:o,onSubmit:n,onRemove:e=>u(`project`,e.ref),hideRemove:f}):null,t[33]=f,t[34]=n,t[35]=o,t[36]=u,t[37]=H):H=t[37];let U;t[38]!==B||t[39]!==V||t[40]!==H?(U=(0,$.jsxs)(`div`,{ref:y,className:B,children:[V,H]}),t[38]=B,t[39]=V,t[40]=H,t[41]=U):U=t[41];let te;t[42]!==h||t[43]!==I||t[44]!==i?(te=I?(0,$.jsx)(`button`,{type:`button`,onClick:()=>g(Xg),"aria-expanded":h,"aria-label":i(h?`chat.draftStarters.collapse`:`chat.draftStarters.expand`),title:i(h?`chat.draftStarters.collapse`:`chat.draftStarters.expand`),className:Bg,children:(0,$.jsx)(X,{name:h?`arrow-up-s`:`arrow-down-s`,className:`h-3.5 w-3.5`})}):null,t[42]=h,t[43]=I,t[44]=i,t[45]=te):te=t[45];let ne;t[46]!==l||t[47]!==c||t[48]!==p||t[49]!==f||t[50]!==s?(ne=f&&p?(0,$.jsx)(Gg,{}):(0,$.jsx)(qg,{pinnable:s,onOpen:c,onAdd:l}),t[46]=l,t[47]=c,t[48]=p,t[49]=f,t[50]=s,t[51]=ne):ne=t[51];let re;t[52]!==te||t[53]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5 self-start`,children:[te,ne]}),t[52]=te,t[53]=ne,t[54]=re):re=t[54];let W;t[55]!==R||t[56]!==U||t[57]!==re?(W=(0,$.jsxs)(`div`,{className:R,children:[U,re]}),t[55]=R,t[56]=U,t[57]=re,t[58]=W):W=t[58];let ie;return t[59]!==F||t[60]!==S||t[61]!==W?(ie=(0,$.jsx)(pu,{sensors:S,collisionDetection:du,measuring:L,onDragStart:j,onDragCancel:N,onDragEnd:F,children:W}),t[59]=F,t[60]=S,t[61]=W,t[62]=ie):ie=t[62],ie};function Yg(e){return e.id}function Xg(e){return!e}function Zg(e){let t=e.selectedDirectory??e.projectRootOption?.value??e.worktreeOptions[0]?.value??null;return t?e.projectRootOption?.value===t?e.projectRootOption.label?.trim()||null:e.worktreeOptions.find(e=>e.value===t)?.label?.trim()||null:null}function Qg(e,t){if(!e||!t)return!1;let n=t.replace(/\\/g,`/`).replace(/\/+$/,``);if(!n)return!1;let r=n===`/`?`/`:n.split(`/`).pop()||``;return!!r&&e===r}var $g=(e,t)=>e??t??null,e_=(e,t)=>!!e&&t!==!1,t_=e=>e?.length?{localBranches:e.filter(e=>!e.startsWith(`remotes/`)).sort(),remoteBranches:e.filter(e=>e.startsWith(`remotes/`)).map(e=>e.replace(/^remotes\//,``)).sort()}:{localBranches:[],remoteBranches:[]},n_=e=>e.replace(/^remotes\//,``).trim(),r_=e=>{let t=n_(e),n=t.lastIndexOf(`/`);return n>=0?t.slice(n+1):t},i_=({directory:e,projectDirectory:t,label:n,projectRootOption:r,worktreeOptions:i,onSelectDirectory:a,className:o,maxWidthClassName:s=`max-w-[48vw] sm:max-w-[20rem]`,presentation:c=`dropdown`})=>{let{t:l}=na(),{git:u}=Vt(),d=$g(t,e),f=e,p=qa(d),m=qa(f),h=e_(d,p),g=f!==d&&e_(f,m),_=Ai(d,u,h),v=Ai(f,u,g),y=_.data,b=f===d?y:v.data,x=Ya(e=>e.fetchStatus),S=Ya(e=>f&&e.directories.get(f)?.status?.current?.trim()||null),[C,w]=Q.useState(!1),T=si(d,u,h&&C).data??[],[E,D]=Q.useState(null),[O,k]=Q.useState(!1),[A,j]=Q.useState(!1),M=Bn(e=>e.projects),N=Bn(e=>e.activeProjectId);Q.useEffect(()=>{u&&(d&&p===null&&x(d,u,{silent:!0}),f&&f!==d&&m===null&&x(f,u,{silent:!0}))},[x,u,p,m,d,f]);let P=Q.useMemo(()=>{let e=kt(t);if(e){let t=M.find(t=>kt(t.path)===e);if(t)return t.id}return N},[N,t,M]),{localBranches:F,remoteBranches:I}=Q.useMemo(()=>t_(y?.all),[y]),L=b?.current?.trim()||S||null,R=!Qg(n,e)&&n||L||n||l(`chat.chatInput.branch`),ee=G(async()=>{if(!u)return;let e=new Set;d&&e.add(d),f&&e.add(f),await Promise.all([...e].map(async e=>{await vi(e,u),await x(e,u,{silent:!0})}))}),z=G(e=>{let t=n_(e),n=r_(t);return i.find(e=>{let r=e.label.trim();return r===t||r===n})??null}),B=G(async e=>{if(!f||!u)return;let t=n_(e);if(L!==t&&L!==r_(t))try{await u.checkoutBranch(f,t),Fi.success(l(`gitView.toast.checkedOut`,{name:t})),await ee()}catch(e){let n=e instanceof Error?e.message:l(`gitView.toast.checkoutFailed`,{name:t});Fi.error(n)}}),V=G(e=>{let t=n_(e);if(!t||L===t||L===r_(t))return;let n=z(t);if(n){a(n.value);return}D(t)}),H=G(async()=>{if(!(!E||O)){k(!0);try{await B(E),D(null)}finally{k(!1)}}}),U=G(async()=>{if(!(!E||O)){k(!0);try{await tl({branch:E,projectDirectory:t??void 0})&&D(null)}finally{k(!1)}}}),te=G(async(e,t)=>{if(!f||!u)return;let n=t?.name??`origin`;try{await u.createBranch(f,e,L??`HEAD`),Fi.success(l(`gitView.toast.createdBranch`,{name:e})),D(e),u.gitPush(f,{remote:n,branch:e,options:[`--set-upstream`]}).then(async()=>{await ee(),Fi.success(l(`gitView.toast.upstreamSet`,{branch:e,remote:n}))}).catch(async e=>{let t=e instanceof Error?e.message:l(`gitView.toast.branchCreatedLocally`);Fi.warning(l(`gitView.toast.branchCreatedLocally`),{description:(0,$.jsx)(`span`,{className:`text-foreground/80 dark:text-foreground/70`,children:t})}),await ee()})}catch(e){let t=e instanceof Error?e.message:l(`gitView.toast.createBranchFailed`);throw Fi.error(t),e}}),ne=G(()=>{let e=Bn.getState(),n=kt(t),r=n?e.projects.find(e=>kt(e.path)===n)??null:null;r&&e.activeProjectId!==r.id&&e.setActiveProjectIdOnly(r.id),j(!0)}),re=G((e,n)=>{if(j(!1),n?.sessionId){Xr.getState().setCurrentSession(n.sessionId,e);return}let r=Bn.getState(),i=kt(t),a=(i?r.projects.find(e=>kt(e.path)===i)??null:null)?.id??r.activeProjectId??null,o=Xr.getState();if(o.newSessionDraft?.open){o.overrideNewSessionDraftTarget({...a?{selectedProjectId:a}:{},directoryOverride:e,bootstrapPendingDirectory:e,preserveDirectoryOverride:!0}),qe.getState().setDirectory(e,{showOverlay:!1});return}o.openNewSessionDraft({...a?{selectedProjectId:a}:{},directoryOverride:e,preserveDirectoryOverride:!0})}),W=(0,$.jsxs)(`button`,{type:`button`,className:J(`group relative inline-flex min-w-0 w-fit items-center gap-1.5 rounded-lg !border-0 px-1.5 font-medium text-foreground/80`,c===`mobile-sheet`?`h-[26px] text-[11px] leading-none`:`h-6 py-1 pr-1.5 typography-micro transition-[padding] hover:pr-5 focus-visible:pr-5 data-[popup-open]:pr-5`,s,gm,o),"aria-label":R,children:[(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:R}),c===`dropdown`?(0,$.jsx)(X,{name:`arrow-down-s`,className:`pointer-events-none absolute right-1 size-3.5 shrink-0 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 group-focus-visible:opacity-100 group-data-[popup-open]:opacity-100`,"aria-hidden":`true`}):null]});return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Kc,{currentBranch:L,localBranches:F,remoteBranches:I,branchInfo:y?.branches,onCheckout:V,onCreate:te,remotes:T,trigger:W,triggerLabel:R,hideTooltip:!0,projectRootOption:r,worktreeOptions:i,selectedDirectory:e,onSelectDirectory:a,onCreateWorktree:ne,open:C,presentation:c,onOpenChange:w}),A?(0,$.jsx)(al,{open:!0,projectId:P,onOpenChange:j,onWorktreeCreated:re}):null,(0,$.jsx)(Ea,{open:!!E,onOpenChange:e=>{!e&&!O&&D(null)},children:(0,$.jsxs)(Sa,{showCloseButton:!1,className:`max-w-sm gap-4`,children:[(0,$.jsxs)(ba,{children:[(0,$.jsx)(Ca,{children:l(`chat.chatInput.branchSwitch.title`,{branch:E??``})}),(0,$.jsx)(wa,{children:l(`chat.chatInput.branchSwitch.description`)})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,$.jsxs)(`button`,{type:`button`,disabled:O,onClick:()=>{H()},className:`flex w-full flex-col items-start gap-0.5 rounded-lg border border-border px-3 py-2.5 text-left hover:bg-interactive-hover disabled:opacity-50`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-ui-label font-medium text-foreground`,children:[O?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`arrow-left-right`,className:`size-3.5 text-muted-foreground`}),l(`chat.chatInput.branchSwitch.checkoutHere`)]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l(`chat.chatInput.branchSwitch.checkoutHereDescription`)})]}),(0,$.jsxs)(`button`,{type:`button`,disabled:O,onClick:()=>{U()},className:`flex w-full flex-col items-start gap-0.5 rounded-lg border border-border px-3 py-2.5 text-left hover:bg-interactive-hover disabled:opacity-50`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 typography-ui-label font-medium text-foreground`,children:[O?(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 animate-spin`}):(0,$.jsx)(X,{name:`git-branch`,className:`size-3.5 text-muted-foreground`}),l(`chat.chatInput.branchSwitch.createWorktree`)]}),(0,$.jsx)(`span`,{className:`typography-micro text-muted-foreground`,children:l(`chat.chatInput.branchSwitch.createWorktreeDescription`)})]})]}),(0,$.jsx)(xa,{children:(0,$.jsx)(`button`,{type:`button`,disabled:O,onClick:()=>D(null),className:`inline-flex h-8 items-center justify-center rounded-md border border-border px-3 typography-ui-label text-foreground hover:bg-interactive-hover/50 disabled:opacity-50`,children:l(`chat.chatInput.branchSwitch.cancel`)})})]})})]})},a_=[],o_=[],s_={revertMessageID:void 0,records:o_},c_=e=>e.role===`user`,l_=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1)if(e[n]?.message!==t[n]?.message||e[n]?.parts!==t[n]?.parts)return!1;return!0},u_=(e,t,n=s_)=>{if(!t)return s_;let r=(`session`in e?e.session:[]).find(e=>e.id===t)?.revert?.messageID;if(!r)return s_;let i=`messages`in e?e.messages:e.message[t]??[],a=`partsByMessageID`in e?e.partsByMessageID:e.part,o=[];for(let e of i)!c_(e)||!le(i,e.id,r)||o.push({message:e,parts:a[e.id]??a_});let s=o.length===0?o_:o;return n.revertMessageID===r&&l_(n.records,s)?n:{revertMessageID:r,records:s}},d_=[`CodeFiles`,`codefiles`,`application/vnd.code.tree`,`application/vnd.code.tree.explorer`,`text/uri-list`,`text/plain`],f_=e=>e.startsWith(`/`)||e.startsWith(`//`)||e.startsWith(`\\\\`)||/^[A-Za-z]:[\\/]/.test(e),p_=e=>{if(/[\r\n]/.test(e)||!/\s/.test(e))return!1;let t=e.replace(/\\/g,`/`);if(!(t.startsWith(`//`)?t.replace(/^\/+/,``).includes(`/`):/^[A-Za-z]:\//.test(t)?t.slice(3).includes(`/`):t.startsWith(`/`)&&t.slice(1).includes(`/`)))return!1;if(t.endsWith(`/`))return!0;let n=t.split(`/`).filter(Boolean).pop()??``;return/\.[A-Za-z0-9]{1,8}$/.test(n)},m_=e=>{if(!f_(e))return!1;if(/\s/.test(e))return p_(e);if(e.startsWith(`//`)||e.startsWith(`\\\\`)){let t=e.replace(/^[\\/]+/,``);return/[\\/]/.test(t)}if(/^[A-Za-z]:[\\/]/.test(e)){let t=e.slice(3);return t.includes(`\\`)||t.includes(`/`)||t.includes(`.`)}return e.replace(/^\/+/,``).includes(`/`)},h_=(e,{fromPlainText:t=!1}={})=>{let n=e.trim().replace(/^['"]+|['"]+$/g,``);return!n||n===`/>`||/[\r\n]/.test(n)?null:n.toLowerCase().startsWith(`file://`)||(t?m_(n):f_(n))?n:null},g_=(e,t,n=0)=>{if(!(n>6||e==null)){if(typeof e==`string`){t.add(e);return}if(Array.isArray(e)){for(let r of e)g_(r,t,n+1);return}if(typeof e==`object`)for(let r of Object.values(e))g_(r,t,n+1)}},__=(e,{allowMultipleLines:t=!0,allowStructuredPayload:n=!0,fromPlainText:r=!1}={})=>{let i=new Set,a=e=>{let n=h_(e,{fromPlainText:r});if(n){i.add(n);return}if(t)for(let t of e.split(/\r?\n/)){let e=h_(t,{fromPlainText:r});e&&i.add(e)}};if(a(e),n)try{let t=JSON.parse(e),n=new Set;g_(t,n);for(let e of n)a(e)}catch{}return Array.from(i)},v_=e=>{if(!e||typeof e.getData!=`function`)return[];let t=new Set;for(let n of d_){let r=``;try{r=e.getData(n)}catch{continue}let i=n===`text/plain`?{allowMultipleLines:!1,allowStructuredPayload:!1,fromPlainText:!0}:n===`text/uri-list`?{allowStructuredPayload:!1}:void 0;for(let e of __(r,i))t.add(e)}return Array.from(t)},y_=e=>{let t=e.trim();if(!t.toLowerCase().startsWith(`file://`))return t;try{let e=new URL(t),n=decodeURIComponent(e.pathname||``);return e.hostname&&e.hostname!==`localhost`&&(n=`//${e.hostname}${n}`),/^\/[A-Za-z]:\//.test(n)&&(n=n.slice(1)),n||t}catch{let e=t.replace(/^file:\/\//i,``);try{return decodeURIComponent(e)}catch{return e}}},b_=e=>f_(e);function x_(e,t){let n=(0,Z.c)(4),r=xn(e,t),i=ln(S_),a=r.data??null,o;return n[0]!==i||n[1]!==r.error||n[2]!==a?(o={goal:a,enabled:i,error:r.error},n[0]=i,n[1]=r.error,n[2]=a,n[3]=o):o=n[3],o}function S_(e){return e.sessionGoalEnabled}var C_={active:`var(--status-info)`,paused:`var(--surface-muted-foreground)`,complete:`var(--status-success)`},w_={active:`chat.goal.status.active`,paused:`chat.goal.status.paused`,complete:`chat.goal.status.complete`};async function T_(e,t,n){let a=r(),o=i();await(t?oe.getScopedSdkClient(t):oe.getSdkClient()).session.command({sessionID:e,name:`goal`,text:n}),a===r()&&o===i()&&await cr(e,t)}var E_=(e,t,n)=>T_(e,t,n===`active`?`resume`:`pause`),D_=(e,t)=>T_(e,t,`clear`);function O_({open:e,onOpenChange:t,sessionId:n,directory:r}){let{t:i}=na(),a=ln(e=>e.isMobile),{goal:o,error:s}=x_(n,r),[c,l]=Q.useState(!1),u=G(async e=>{if(!c){l(!0);try{await e(),t(!1)}catch{Fi.error(i(`chat.goal.toast.actionFailed`))}finally{l(!1)}}}),d=i(`chat.goal.dialog.titleManage`),f=(0,$.jsxs)(`div`,{className:`space-y-3`,children:[s&&(0,$.jsx)(`p`,{role:`alert`,className:`typography-meta text-muted-foreground`,children:i(`chat.goal.toast.actionFailed`)}),o&&(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`max-h-48 overflow-y-auto whitespace-pre-wrap break-words typography-ui-label`,children:o.objective}),(0,$.jsxs)(`p`,{className:`typography-meta text-muted-foreground`,children:[i(w_[o.status]),` · `,o.rounds,`/`,o.maxRounds]}),o.reason&&(0,$.jsx)(`p`,{className:`typography-meta text-muted-foreground`,children:o.reason}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[o.status!==`complete`&&(0,$.jsx)(Tr,{size:`sm`,disabled:c,onClick:()=>void u(()=>E_(n,r,o.status===`active`?`paused`:`active`)),children:i(o.status===`active`?`chat.goal.action.pause`:`chat.goal.action.resume`)}),(0,$.jsx)(Tr,{variant:`destructive`,size:`sm`,disabled:c,onClick:()=>void u(()=>D_(n,r)),children:i(`chat.goal.action.clear`)})]})]})]});return a?(0,$.jsx)(xu,{open:e,title:d,onClose:()=>t(!1),children:f}):(0,$.jsx)(Ea,{open:e,onOpenChange:t,children:(0,$.jsxs)(Sa,{className:`max-w-lg`,children:[(0,$.jsx)(ba,{children:(0,$.jsx)(Ca,{children:d})}),f]})})}var k_=Q.memo(({sessionId:e,directory:t,className:n})=>{let{t:r}=na(),{goal:i,enabled:a}=x_(e??``,t),[o,s]=Q.useState(!1),[c,l]=Q.useState(!1),u=G(async()=>{if(!(!e||!i||o||i.status===`complete`)){s(!0);try{await E_(e,t,i.status===`active`?`paused`:`active`)}catch{Fi.error(r(`chat.goal.toast.actionFailed`))}finally{s(!1)}}});return!e||!i||!a?null:(0,$.jsxs)(`div`,{className:J(`flex w-full min-w-0 items-center gap-1.5 py-0.5`,n),"aria-label":r(`chat.goal.row.aria`),children:[(0,$.jsx)(X,{name:`target`,className:`size-3.5 shrink-0`,style:{color:C_[i.status]},"aria-hidden":`true`}),(0,$.jsx)(`button`,{type:`button`,className:`min-w-0 flex-1 truncate text-left typography-ui-label`,onClick:()=>l(!0),title:i.objective,children:i.objective}),(0,$.jsx)(`span`,{className:`shrink-0 typography-meta text-muted-foreground`,children:r(w_[i.status])}),(0,$.jsxs)(`span`,{className:`shrink-0 typography-meta tabular-nums text-muted-foreground`,children:[i.rounds,`/`,i.maxRounds]}),i.status!==`complete`&&(0,$.jsxs)(Tr,{variant:`ghost`,size:`sm`,disabled:o,onClick:()=>void u(),children:[(0,$.jsx)(X,{name:i.status===`active`?`pause`:`play`,className:`size-3.5`,"aria-hidden":`true`}),r(i.status===`active`?`chat.goal.action.pause`:`chat.goal.action.resume`)]}),(0,$.jsx)(O_,{open:c,onOpenChange:l,sessionId:e,directory:t})]})});k_.displayName=`SessionGoalRow`;var A_=4e3,j_=Q.memo(({sessionId:e,directory:t,draftOpen:n=!1})=>{let{t:r}=na(),{goal:i,enabled:a}=x_(e??``,t),o=Tn(e=>e.armed),s=Tn(e=>e.setArmed),[c,l]=Q.useState(!1);if(!a||!e&&!n||!o&&!i)return null;let u=i?.status===`complete`?`text-[var(--status-success)]`:o||i?.status===`active`||i?.status===`paused`?`text-[var(--status-info)]`:``,d=async()=>{if(o){s(!1);return}if(!(!e||c)){l(!0);try{await D_(e,t)}catch(e){console.warn(`[session-goal] clear failed:`,e),Fi.error(r(`chat.goal.toast.actionFailed`))}finally{l(!1)}}};return(0,$.jsxs)(`span`,{className:J(`inline-flex h-7 items-center gap-1 rounded-full bg-[var(--surface-muted)] py-1 pl-2 pr-1 typography-ui-label`,u),children:[(0,$.jsx)(X,{name:`target`,className:`h-4 w-4`,"aria-hidden":`true`}),(0,$.jsx)(`span`,{children:r(`chat.goal.chip.label`)}),(0,$.jsx)(`button`,{type:`button`,className:`flex h-5 w-5 items-center justify-center rounded-full text-current hover:bg-[var(--interactive-hover)] disabled:opacity-50`,onClick:()=>void d(),disabled:c,"aria-label":r(o?`chat.goal.button.disarmAria`:`chat.goal.action.clear`),title:r(o?`chat.goal.button.disarmAria`:`chat.goal.action.clear`),children:(0,$.jsx)(X,{name:`close`,className:`h-3 w-3`,"aria-hidden":`true`})})]})});j_.displayName=`SessionGoalButton`;var M_=Q.memo(e=>{let t=(0,Z.c)(11),{length:n}=e,{t:r}=na();if(!Tn(N_)||n===0)return null;let i=n>4e3?`text-[var(--status-error)]`:`text-muted-foreground/70`,a;t[0]===i?a=t[1]:(a=J(`flex-shrink-0 self-center typography-micro tabular-nums`,i),t[0]=i,t[1]=a);let o;t[2]===r?o=t[3]:(o=r(`chat.goal.counter.aria`),t[2]=r,t[3]=o);let s;t[4]===r?s=t[5]:(s=r(`chat.goal.counter.aria`),t[4]=r,t[5]=s);let c;return t[6]!==n||t[7]!==a||t[8]!==o||t[9]!==s?(c=(0,$.jsxs)(`span`,{className:a,"aria-label":o,title:s,children:[n,`/`,A_]}),t[6]=n,t[7]=a,t[8]=o,t[9]=s,t[10]=c):c=t[10],c});M_.displayName=`SessionGoalObjectiveCounter`;function N_(e){return e.armed}var P_=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`timeline`,`model`,`summary`,`workspace-review`,`craft-goal`,`catch-up`,`debug`,`weigh`,`explore`,`btw`]),F_=new Set([`new`,`compact`,`reload`,`fork`,`undo`,`redo`]),I_=/^\/\u2003?([^\s]+)/i,L_=e=>e?.reloadEnabled??d(),R_=(e,t,n)=>{if(t!==`normal`)return null;let r=e.trimStart().match(I_)?.[1]?.toLowerCase();return!r||!P_.has(r)||r===`reload`&&!L_(n)?null:r},z_=(e,t,n)=>R_(e,t,n)!==null,B_=(e,t,n)=>{let r=R_(e,t,n);return r!==null&&F_.has(r)};function V_(e){if(R_(e.text,e.inputMode)!==`btw`)return!1;if(!e.allowed)return!0;if(!e.scope?.sessionId)return e.notify(`sessionRequired`),!0;if(e.hasReferences)return e.notify(`plainTextRequired`),!0;let t=e.text.trimStart().replace(/^\/\u2003?btw(?:\s|$)/i,``).trim();return t&&e.ask(e.scope,t),e.clearText(),e.open(),!0}var H_=({currentSessionId:e,messageRef:t,replacePlainDocument:n})=>{let r=e;return t.current=``,n(``),r},U_=async({command:e,consumeCommandText:t,forkSession:n,waitForConnection:r,getDirectoryForSession:i,summarizeSession:a,onCompactError:o,onForkError:s})=>{if(t(),e===`fork`){try{await n()}catch(e){s(e)}return}try{await r();let e=i();if(!e){o();return}await a(e)}catch{o()}},W_=e=>!e.queuedOnly&&!e.resourcePolicy&&e.rootAttachmentCount>0,G_=e=>e.surfaceKind===`primary`&&!!e.currentSessionId&&!e.queuedOnly&&e.delivery!==`queue`&&!e.resourcePolicy&&e.inputMode!==`shell`&&!e.localCommand&&!e.nativeGoal,K_=e=>e.surfaceKind!==`primary`||!e.stagedSessionId||!e.stagedMessageId||e.stagedMessageId!==e.blurredMessageId||e.submitInFlight||e.focusHeld||e.overlayOpen||e.focusInsideComposer?{action:`keep`}:{action:`disarm`,sessionId:e.stagedSessionId},q_=e=>({state:`bound`,transportIdentity:e.transportIdentity,directory:e.directory,sessionID:e.sessionID,deliveryTarget:{kind:`primary`},runtimeGeneration:e.runtimeGeneration}),J_=(e,t)=>{let n=tt.getState();return n.bindLegacyQueue(st(e.sessionID),e),n.stageAdmission(e,{requestID:t.requestID,queueItemID:t.queueItemID,operationID:t.operationID,messageID:t.messageID,content:t.content,createdAt:t.createdAt,attachmentCount:t.attachments.length,...t.composerDocument?{composerDocument:t.composerDocument}:{},...t.composerMentions?{composerMentions:t.composerMentions}:{}}),n.confirmAdmission(e,{requestID:t.requestID,sendConfig:t.sendConfig,attachments:t.attachments}).ok},Y_=async e=>{let t=ir.getState().takeEstablishingPending(e.draftID);if(t.length===0)return{drained:0,failed:0};let n=q_(e),r=0,i=0;for(let a of t)try{if(e.admitServer&&(await e.admitServer(a)).status===`committed`){r+=1;continue}J_(n,a)?r+=1:i+=1}catch{try{J_(n,a)?r+=1:i+=1}catch{i+=1}}return{drained:r,failed:i}},X_=(e,t)=>Promise.resolve().then(()=>e()).catch(()=>{t()}),Z_=e=>{let t=e.ctrlEnter&&e.canQueue&&e.primary&&e.sessionIsRunning;return e.followUpBehavior===`queue`?t?{kind:`submit`,steerAfterAdmit:!0}:e.ctrlEnter||!e.canQueue?{kind:`submit`}:e.primary?{kind:`submit`,delivery:`queue`}:e.queueUsable?{kind:`queue`}:{kind:`submit`,delivery:`steer`}:t?{kind:`submit`,steerAfterAdmit:!0}:e.ctrlEnter||!e.canQueue?{kind:`submit`}:{kind:`submit`,delivery:`steer`}},Q_=e=>Object.prototype.hasOwnProperty.call(e,`permissions`)?e.permissions:e.permission,$_=e=>{let t=Sd(e);for(let e=t.length-1;e>=0;--e){let n=t[e];if(n){if(n.action===`*`&&n.resource===`*`)return n.effect===`ask`;if(n.effect===`ask`)return!0}}return!0},ev=(e,t)=>{let n=t?.trim();if(!n)return e.length===0||e.some(e=>$_(Q_(e)));let r=e.find(e=>e?.name===n);return!r||$_(Q_(r))},tv=e=>{let{permissionScopeSessionId:t,newSessionDraftOpen:n,draftPermissionAutoAcceptEnabled:r,permissionAutoAcceptEnabled:i,setDraftPermissionAutoAcceptEnabled:a,setSessionAutoAccept:o,onOpenSessionFirst:s,onToggleFailed:c}=e;if(!t){if(!n){s();return}a(!r);return}o(t,!i).catch(c)},nv=(e,t,n)=>{let r=e.agent;r&&r!==t.currentAgentName&&t.setAgent(r),e.providerID&&t.setProvider(e.providerID),e.modelID&&t.setModel(e.modelID),t.setCurrentVariant(e.variant);let i=r??t.currentAgentName;i&&e.providerID&&e.modelID&&t.saveAgentModelSelection(i,e.providerID,e.modelID,e.variant);let a=n?.sessionId,o=n?.memory;!a||!o||!e.providerID||!e.modelID||(o.saveSessionModelSelection(a,e.providerID,e.modelID),i&&o.saveSessionAgentSelection&&o.saveSessionAgentSelection(a,i),i&&(o.saveAgentModelForSession(a,i,e.providerID,e.modelID),o.saveAgentModelVariantForSession(a,i,e.providerID,e.modelID,e.variant)))},rv=(e,t,n)=>{let r=e.providers.find(e=>e.id===t);return r?(Array.isArray(r.models)?r.models:[]).some(e=>e.id===n):!1},iv=(e,t)=>e.agents.some(e=>e.name===t),av=(e,t,n,r)=>{if(!r)return!0;let i=e.providers.find(e=>e.id===t)?.models?.find(e=>e.id===n)?.variants;return i?Array.isArray(i)?i.includes(r):typeof i==`object`&&Object.prototype.hasOwnProperty.call(i,r):!1},ov=e=>{let{catalog:t,providerID:n,modelID:r,historyVariant:i,memoryVariant:a}=e;if(i)return av(t,n,r,i)?i:void 0;if(a&&av(t,n,r,a))return a},sv=e=>{let{sessionId:t,choice:n,catalog:r,memory:i,fallbackAgentName:a,source:o}=e;if(!n.providerID||!n.modelID||!rv(r,n.providerID,n.modelID))return null;let s=n.agent&&iv(r,n.agent)?n.agent:i?.getSessionAgentSelection?.(t)&&iv(r,i.getSessionAgentSelection(t))?i.getSessionAgentSelection(t):a&&iv(r,a)?a:void 0,c=s?i?.getAgentModelVariantForSession?.(t,s,n.providerID,n.modelID):void 0,l=ov({catalog:r,providerID:n.providerID,modelID:n.modelID,historyVariant:n.variant,memoryVariant:c});return{agent:s,providerID:n.providerID,modelID:n.modelID,variant:l,source:o,messageId:n.id}},cv=e=>{let{sessionId:t,latestUserChoice:n,latestExecution:r,catalog:i,memory:a,sessionEntity:o,fallbackAgentName:s,transcriptReady:c=!0}=e;if(c&&r){let e=sv({sessionId:t,choice:r,catalog:i,memory:a,fallbackAgentName:s,source:`execution`});if(e)return e}if(c&&n){let e=sv({sessionId:t,choice:n,catalog:i,memory:a,fallbackAgentName:s,source:`history`});if(e)return e}if(c&&a){let e=a.getSessionAgentSelection?.(t)??null,n=e&&iv(i,e)?e:s&&iv(i,s)?s:void 0;if(n){let e=a.getAgentModelForSession?.(t,n);if(e&&rv(i,e.providerId,e.modelId)){let r=a.getAgentModelVariantForSession?.(t,n,e.providerId,e.modelId),o=r&&av(i,e.providerId,e.modelId,r)?r:void 0;return{agent:n,providerID:e.providerId,modelID:e.modelId,variant:o,source:`session-memory`}}}let r=a.getSessionModelSelection?.(t);if(r&&rv(i,r.providerId,r.modelId)){let e=n?a.getAgentModelVariantForSession?.(t,n,r.providerId,r.modelId):void 0,o=e&&av(i,r.providerId,r.modelId,e)?e:void 0;return{agent:n,providerID:r.providerId,modelID:r.modelId,variant:o,source:`session-memory`}}}let l=o?.model;if(l&&rv(i,l.providerID,l.id)){let e=a?.getSessionAgentSelection?.(t)??null,n=(o?.agent&&iv(i,o.agent)?o.agent:void 0)??(e&&iv(i,e)?e:s&&iv(i,s)?s:void 0),r=l.variant,c=r&&av(i,l.providerID,l.id,r)?r:void 0;return{agent:n,providerID:l.providerID,modelID:l.id,variant:c,source:`session-entity`}}return null},lv=(e,t,n)=>{let r=e.agent;r&&r!==t.currentAgentName&&t.setAgent(r),e.providerID&&t.setProvider(e.providerID),e.modelID&&t.setModel(e.modelID),t.setCurrentVariant(e.variant);let{sessionId:i,memory:a}=n;a.saveSessionModelSelection(i,e.providerID,e.modelID);let o=r??t.currentAgentName;o&&a.saveSessionAgentSelection&&a.saveSessionAgentSelection(i,o),o&&(a.saveAgentModelForSession(i,o,e.providerID,e.modelID),a.saveAgentModelVariantForSession(i,o,e.providerID,e.modelID,e.variant))},uv=(e,t)=>{if((t?.expectedConfigKey===void 0||t.activeDirectoryKey===t.expectedConfigKey)&&!(!e.currentProviderId||!e.currentModelId))return{providerID:e.currentProviderId,modelID:e.currentModelId,agent:e.currentAgentName,variant:e.currentVariant}},dv=e=>e.editRevision<=0?!1:e.pinnedHistoryMessageId==null||e.latestHistoryMessageId==null||e.latestHistoryMessageId===e.pinnedHistoryMessageId,fv=e=>{if(e.captured?.providerID&&e.captured?.modelID)return e.captured;let t=e.surfaceSelection;if(!(!t?.providerID||!t?.modelID))return{providerID:t.providerID,modelID:t.modelID,...t.agent?{agent:t.agent}:{},...t.variant?{variant:t.variant}:{}}},pv=e=>typeof e==`string`&&e.trim().length>0?e:void 0,mv=e=>pv(e.agent)??pv(e.mode),hv=e=>pv(typeof e.model==`object`?e.model?.variant:void 0)??pv(e.variant),gv=e=>{let t=typeof e.model==`object`?e.model:void 0,n=pv(e.providerID)??pv(t?.providerID),r=pv(e.modelID)??pv(t?.modelID)??pv(t?.id);return!n||!r?null:{providerID:n,modelID:r}},_v=e=>gv(e),vv=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.role!==`user`||n.nativeType===`synthetic`||n.type===`synthetic`)continue;let r=gv(n);return{id:typeof n.id==`string`?n.id:void 0,agent:mv(n),providerID:r?.providerID,modelID:r?.modelID,variant:hv(n)}}return null},yv=e=>{for(let t=e.length-1;t>=0;--t){let n=e[t];if(n.nativeType===`synthetic`||n.type===`synthetic`)continue;if(n.role===`user`){if(gv(n))return null;continue}if(n.role!==`assistant`)continue;let r=_v(n);if(r)return{id:typeof n.id==`string`?n.id:void 0,agent:mv(n),providerID:r.providerID,modelID:r.modelID,variant:hv(n)}}return null},bv=500,xv=e=>Array.from(e).length,Sv=e=>{let t=2166136261;for(let n of e)t^=n.codePointAt(0)??0,t=Math.imul(t,16777619);return(t>>>0).toString(36)},Cv=e=>xv(e)>=bv,wv=e=>{let t=Be(e.text,e.references).document.references,n=t.reduce((e,t)=>{let n=t.kind===`paste`?t.index:0;return typeof n==`number`&&Number.isSafeInteger(n)&&n>=1?Math.max(e,n):e},0);if(n<2**53-1)return n+1;let r=new Set(t.flatMap(e=>e.kind===`paste`&&typeof e.index==`number`&&Number.isSafeInteger(e.index)&&e.index>=1?[e.index]:[]));for(let e=1;e<=t.length+1;e+=1)if(!r.has(e))return e;return 1},Tv=(e,t)=>{let n=t??e;return typeof n!=`string`||!Cv(n)?!1:et(typeof e==`string`?{text:``,references:[]}:e,n)},Ev=(e,t,n,r,i=1)=>{let a=xv(e),o=new Set(n.map(e=>e.token));for(let n=i;n<2**53-1;n+=1){let i=`[${r({index:n,count:a})}]`;if(!(t.includes(i)||o.has(i)))return{id:`pasted-text-${n}-${Sv(e)}`,token:i,text:e,characterCount:a,index:n}}throw Error(`Unable to create a unique pasted text reference`)},Dv=e=>({text:e?.text??``,references:e?.composerReferences??[]}),Ov=e=>({text:e.text,references:e.references.map(e=>({...e}))}),kv=e=>({transportIdentity:e.transportIdentity,owner:{...e.owner}}),Av=e=>JSON.stringify([e.text,e.references]),jv=(e,t)=>e!==null&&t!==null&&ft(e)===t,Mv=(e,t,n)=>{let r=e?kv(e):null,i=r?n(r):void 0;return{document:ut(Dv(i),t),mentions:i?.mentions??[],revision:i?.revision??0,key:r,keyID:r?ft(r):null}},Nv=(e,t,n,r)=>{if(!t||ft(t.key)!==r.keyID||t.revision<r.appliedRevision)return`ignore`;let i=Av(Dv(t));return n?.keyID===r.keyID&&n.revision===t.revision&&n.fingerprint===i?`local-echo`:t.revision===r.appliedRevision?`ignore`:i===Av(e)?`same-document-metadata`:`external-document`},Pv=(e,t,n)=>{let r=n.newEnd-n.oldEnd;return e.flatMap(e=>{if(e.range.start<n.oldEnd&&e.range.end>n.oldStart)return[];let i=e.range.start>=n.oldEnd?{start:e.range.start+r,end:e.range.end+r}:e.range;return t.text.slice(i.start,i.end)===`@${e.value}`?[{...e,range:i}]:[]})},Fv=e=>e.map((e,t)=>({mention:e,index:t})).sort((e,t)=>e.mention.range.start-t.mention.range.start||e.mention.range.end-t.mention.range.end||e.index-t.index).map(({mention:e})=>e),Iv=(e,t,n,r,i=r)=>{let a=lt(e,n,r,i);return{document:a.document,mentions:Pv(t,a.document,a.edit),requiresTextCorrection:a.requiresTextCorrection,selectionStart:a.selectionStart,selectionEnd:a.selectionEnd,removedReferences:a.removedReferences}},Lv=(e,t,n)=>({preview:{real:Ov(e),realMentions:[...t]},document:{text:n.text,references:[]},mentions:[]}),Rv=e=>({document:e.real,mentions:e.realMentions}),zv=(e,t,n,r)=>{let i=[...e,...t.map(e=>({...e,range:{start:e.range.start+r,end:e.range.end+r}}))],a=new Set;return i.filter(e=>{let t=`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return a.has(t)||n.text.slice(e.range.start,e.range.end)!==`@${e.value}`?!1:(a.add(t),!0)})},Bv=(e,t)=>{let n=Dv(t),r=Ke(e.document,n),i=e.document.text===n.text&&JSON.stringify(e.document.references)===JSON.stringify(n.references)?0:e.document.text.length+2;return{document:r,mentions:zv(e.mentions,t?.mentions??[],r,i)}},Vv=({draftKey:e,sessionTitles:t,persistenceEnabled:n,onResourcesChanged:r,store:i=ra})=>{let a=e?ft(e):null,o=(0,Q.useSyncExternalStore)(i.subscribe,()=>a?i.getState().drafts[a]:void 0,()=>void 0),s=(0,Q.useSyncExternalStore)(i.subscribe,()=>a?i.getState().draftHydration[a]??`idle`:`idle`,()=>`idle`),c=(0,Q.useSyncExternalStore)(i.subscribe,()=>a?i.getState().draftPersistence[a]:void 0,()=>void 0),[l,u]=(0,Q.useState)(()=>Mv(e,t,i.getState().getDraft).document),[d,f]=(0,Q.useState)(()=>Mv(e,t,i.getState().getDraft).mentions),[p,m]=(0,Q.useState)(`compose`),[h,g]=(0,Q.useState)(0),_=(0,Q.useRef)(l),v=(0,Q.useRef)(d),y=(0,Q.useRef)(t),b=(0,Q.useRef)(r),x=(0,Q.useRef)(e),S=(0,Q.useRef)(e?kv(e):null),C=(0,Q.useRef)(a),w=(0,Q.useRef)(a),T=(0,Q.useRef)(0),E=(0,Q.useRef)(o?.revision??0),D=(0,Q.useRef)(void 0),O=(0,Q.useRef)(void 0),k=(0,Q.useRef)(Ic());_.current=l,v.current=d,y.current=t,b.current=r,x.current=e,C.current=a;let A=(0,Q.useCallback)((e,t)=>{_.current=e,v.current=t,u(e),f(t)},[]),j=(0,Q.useCallback)((e,t)=>{let n=Le(e,t);b.current?.(n)},[]);(0,Q.useEffect)(()=>{i.getState().setDraftPersistenceEnabled(n)},[n,i]),(0,Q.useLayoutEffect)(()=>{T.current+=1;let e=T.current;w.current=a;let t=Mv(x.current,y.current,i.getState().getDraft),n=t.key;if(S.current=t.key,D.current=void 0,O.current=void 0,k.current=Ic(),m(`compose`),E.current=t.revision,A(t.document,t.mentions),g(e=>e+1),n?.owner.kind===`draft`){let r=t.revision;i.getState().claimLegacyNewDraft(n).then(t=>{let o=i.getState().getDraft(n);!t||!jv(S.current,a)||w.current!==a||C.current!==a||T.current!==e||E.current!==r||o?.revision!==t.revision||(E.current=t.revision,A(ut(Dv(t),y.current),t.mentions))})}},[a,A,i]),(0,Q.useEffect)(()=>{if(!a||w.current!==a||O.current)return;let e=Nv(_.current,o,D.current,{keyID:a,epoch:T.current,appliedRevision:E.current});if(e!==`ignore`){if(o&&(E.current=o.revision),e===`local-echo`||e===`same-document-metadata`){o&&f(o.mentions);return}e===`external-document`&&o&&(D.current=void 0,A(ut(Dv(o),y.current),o.mentions),m(`compose`),g(e=>e+1))}},[a,A,o]);let M=(0,Q.useCallback)((e,t)=>{let n=S.current;if(!jv(n,C.current)||O.current)return;let r=_.current,a=i.getState().setDraftComposerState(n,{document:e,mentions:Fv(t)});if(!a)return;let o=Dv(a);return D.current={keyID:ft(n),revision:a.revision,fingerprint:Av(o)},E.current=a.revision,A(o,a.mentions),j(r,o),a},[i,A,j]),N=(0,Q.useCallback)((e,t,n,r,i,a)=>{k.current=zc(k.current,{before:Vc(e,t,n),after:Vc(r,i,a)})},[]),P=(0,Q.useCallback)(()=>O.current?(O.current=void 0,m(`compose`),!0):!1,[]),F=(0,Q.useCallback)(e=>(P(),M({text:e,references:[]},[])),[M,P]),I=(0,Q.useCallback)((e,t=[])=>{P();let n=pt(e.text,e.references);return n?M(ut(n,y.current),t):void 0},[M,P]),L=(0,Q.useCallback)((e,t,n=t,r)=>{let i=P(),a=Ov(_.current),o=i?[]:v.current,s=Iv(a,o,e,t,n),c=r?r(s.mentions,s.document):s.mentions;return M(s.document,c),s.removedReferences.length>0&&N(a,o,{start:s.selectionStart,end:s.selectionEnd},s.document,c,{start:s.selectionStart,end:s.selectionEnd}),{start:s.selectionStart,end:s.selectionEnd,requiresTextCorrection:s.requiresTextCorrection}},[M,P,N]),R=(0,Q.useCallback)((e,t)=>{let n=_.current,r=Math.max(0,Math.min(e.start,n.text.length)),i=Math.max(r,Math.min(e.end,n.text.length)),a=P(),o=lt(n,`${n.text.slice(0,r)}${e.text}${n.text.slice(i)}`,r+e.text.length),s=Pv(a?[]:v.current,o.document,o.edit);return M(o.document,t?t(s,o.document):s),{start:o.selectionStart,end:o.selectionEnd}},[M,P]),ee=(0,Q.useCallback)((e,t)=>{let n=_.current;return R({start:0,end:n.text.length,text:e},t)},[R]),z=(0,Q.useCallback)((e,t,n,r)=>{let i=P(),a=ct(_.current,e,t,n,r);return M(a.document,Pv(i?[]:v.current,a.document,a.edit)),{start:a.caret,end:a.caret,caret:a.caret,document:a.document}},[M,P]),B=(0,Q.useCallback)(e=>{let t=Ov(_.current),n=Je(t,e);if(!n)return null;let r=P()?[]:v.current,i=Pv(r,n.document,n.edit),a=ze(n.document.text,n.caret),o=lt(n.document,a.text,a.caret),s=Pv(i,o.document,o.edit);return M(o.document,s),N(t,r,{start:e.selectionStart,end:e.selectionEnd},o.document,s,{start:o.selectionStart,end:o.selectionEnd}),{start:o.selectionStart,end:o.selectionEnd}},[M,P,N]),V=(0,Q.useCallback)(e=>{if(O.current)return null;let t=e===`undo`?kc(k.current,_.current):Nc(k.current,_.current);return!t||!M(t.snapshot.document,t.snapshot.mentions)?null:(k.current=t.history,t.snapshot.selection)},[M]),H=(0,Q.useCallback)(e=>M(_.current,e),[M]),U=(0,Q.useCallback)(e=>{let t=O.current?{document:{text:e.text,references:[]},mentions:[]}:Lv(_.current,v.current,e);`preview`in t&&(O.current=t.preview),m(`history-preview`),A(t.document,t.mentions),g(e=>e+1)},[A]),te=(0,Q.useCallback)(()=>{let e=O.current;if(!e)return;O.current=void 0,m(`compose`);let t=Rv(e);A(t.document,t.mentions),g(e=>e+1)},[A]),ne=(0,Q.useCallback)(()=>{let e=S.current;if(!jv(e,C.current))return null;let t=i.getState().getDraft(e);return{key:kv(e),keyID:ft(e),revision:t?.revision??0,document:Ov(_.current),mentions:v.current.map(e=>({...e,range:{...e.range}})),epoch:T.current,runtime:i.getState().captureDraftRuntime()}},[i]),re=(0,Q.useCallback)(e=>{let t=Bv(e,i.getState().getDraft(e.key)),n=Dv(i.getState().getDraft(e.key)),r=Be(n.text,n.references).document,a=i.getState().setDraftComposerState(e.key,{...t,mentions:Fv(t.mentions)});if(a){let e=Dv(a);j(r,e)}return a},[j,i]),W=(0,Q.useCallback)(()=>_.current,[]);return(0,Q.useMemo)(()=>({document:l,mentions:d,confirmedFileMentions:d.filter(e=>e.kind===`file`||e.kind===`directory`),inputMode:p,hydration:s,persistence:c,textPresetEpoch:h,getDocument:W,replacePlainDocument:F,replaceMaterializedDocument:I,applyBrowserEdit:L,applyProgrammaticEdit:R,replaceProgrammaticText:ee,insertReference:z,deleteReference:B,restoreReferenceHistory:V,commitMentions:H,enterHistoryPreview:U,exitHistoryPreview:te,captureSubmission:ne,recoverSubmission:re}),[L,R,ne,H,B,l,U,te,W,s,p,z,d,c,re,I,F,ee,V,h])};function Hv(e){let t=e.maxLines??8,n=e.lineHeight*t+e.paddingTotal,r=Math.max(e.scrollHeight,e.dictationHeight);return{height:Math.min(r,n),maxHeight:n,overflowY:r>n?`auto`:`hidden`}}function Uv(e){let t=(0,Z.c)(22),{inputRef:n,message:r,expanded:i,isMobile:a,dictationHeight:o,manualHeight:s}=e,c=s!==void 0&&s,[l,u]=(0,Q.useState)(null),d=(0,Q.useRef)(null),f;t[0]!==o||t[1]!==i||t[2]!==n||t[3]!==c?(f=e=>{let t=n.current;if(!t||c)return;let r=t.scrollTop;if(i){t.style.height=`100%`,t.style.maxHeight=`none`,t.style.overflowY=`auto`,u(null),t.scrollTop!==r&&(t.scrollTop=r);return}t.style.overflow=`hidden`,t.style.overflowX=`hidden`,t.style.overflowY=`hidden`,(e?.allowShrink??!0)&&(t.style.height=`auto`);let a=t.ownerDocument?.defaultView,s=a?a.getComputedStyle(t):null,l=s?parseFloat(s.lineHeight):NaN,d=s?parseFloat(s.paddingTop):NaN,f=s?parseFloat(s.paddingBottom):NaN,p=Number.isNaN(d)||Number.isNaN(f)?16:d+f,m=Hv({scrollHeight:t.scrollHeight||t.offsetHeight,dictationHeight:o??0,lineHeight:Number.isNaN(l)?22:l,paddingTotal:p});t.style.height=`${m.height}px`,t.style.maxHeight=`${m.maxHeight}px`,t.style.overflowY=m.overflowY,t.scrollTop!==r&&(t.scrollTop=r),u(e=>e?.height===m.height&&e.maxHeight===m.maxHeight?e:{height:m.height,maxHeight:m.maxHeight})},t[0]=o,t[1]=i,t[2]=n,t[3]=c,t[4]=f):f=t[4];let p=G(f),m=c?null:r,h;t[5]!==m?.length||t[6]!==o||t[7]!==i||t[8]!==c||t[9]!==p?(h=()=>{let e=d.current,t=m?.length??0,n=!e||e.manualHeight||t<e.length||i!==e.expanded||e.dictationHeight!==null&&o===null;d.current={length:t,expanded:i,dictationHeight:o,manualHeight:c},p({allowShrink:n})},t[5]=m?.length,t[6]=o,t[7]=i,t[8]=c,t[9]=p,t[10]=h):h=t[10];let g;t[11]!==m||t[12]!==o||t[13]!==i||t[14]!==n||t[15]!==a||t[16]!==c||t[17]!==p?(g=[m,i,a,o,c,n,p],t[11]=m,t[12]=o,t[13]=i,t[14]=n,t[15]=a,t[16]=c,t[17]=p,t[18]=g):g=t[18],(0,Q.useLayoutEffect)(h,g);let _;return t[19]!==p||t[20]!==l?(_={size:l,resize:p},t[19]=p,t[20]=l,t[21]=_):_=t[21],_}var Wv=()=>{let e=document.documentElement.classList;return e.contains(`yuri-native-ime`)&&!e.contains(`yuri-platform-android`)},Gv=()=>parseFloat(document.documentElement.style.getPropertyValue(`--yuri-native-ime-lift`))||0;function Kv(e){let t=(0,Z.c)(26),{enabled:n,hasContent:r,draftID:i,inputRef:a}=e,o=n&&r,s;t[0]===a?s=t[1]:(s=()=>{let e=a.current;if(!e)return[];let t=e.closest(`[data-mobile-composer-surface]`)??e,n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=getComputedStyle(e),o=parseFloat(i.lineHeight)||22,s=(parseFloat(i.paddingTop)||0)+(parseFloat(i.paddingBottom)||0),c=Math.max(parseFloat(i.minHeight)||0,o+s),l=window.visualViewport,u=Wv(),d=u?Gv():0,f=u?d:l?.offsetTop??0;for(let e=t.parentElement;e;e=e.parentElement){let t=e.querySelector(`.yuri-mobile-detail-navigation, [data-mobile-chat-header]`);if(t){f=Math.max(f,t.getBoundingClientRect().bottom+d);break}}let p=u?r.bottom:Math.min(r.bottom,(l?.offsetTop??0)+(l?.height??window.innerHeight)),m=r.height-n.height,h=Math.max(c,p-f-m),g=e.style.height,_=e.scrollTop;e.style.height=`0px`;let v=Hv({scrollHeight:e.scrollHeight,dictationHeight:0,lineHeight:o,paddingTotal:s}).height;return e.style.height=g,e.scrollTop=_,[{id:`auto`,height:Math.min(h,Math.max(c,v))},{id:`min`,height:c},{id:`full`,height:h}]},t[0]=a,t[1]=s);let c;t[2]!==a||t[3]!==s?(c={surfaceRef:a,initialPoint:`auto`,getPoints:s},t[2]=a,t[3]=s,t[4]=c):c=t[4];let l=ua(c),{reset:u}=l,d;t[5]===u?d=t[6]:(d=()=>{u()},t[5]=u,t[6]=d);let f;t[7]!==o||t[8]!==i||t[9]!==u?(f=[o,i,u],t[7]=o,t[8]=i,t[9]=u,t[10]=f):f=t[10],(0,Q.useLayoutEffect)(d,f);let p;t[11]!==o||t[12]!==l?(p=()=>{o&&l.snapPoint===`full`&&l.settleAt(`full`,void 0,!1)},t[11]=o,t[12]=l,t[13]=p):p=t[13];let m=G(p),h;t[14]===o?h=t[15]:(h=()=>o?window:null,t[14]=o,t[15]=h),tn(`resize`,m,h);let g;t[16]===o?g=t[17]:(g=()=>o?window:null,t[16]=o,t[17]=g),tn(`yuri:keyboard-settled`,m,g);let _;t[18]===o?_=t[19]:(_=()=>o?window.visualViewport:null,t[18]=o,t[19]=_),tn(`resize`,m,_);let v;t[20]===o?v=t[21]:(v=()=>o?window.visualViewport:null,t[20]=o,t[21]=v),tn(`scroll`,m,v);let y=o&&(l.dragging||l.settling||l.snapPoint!==`auto`),b;return t[22]!==o||t[23]!==l||t[24]!==y?(b={...l,visible:o,manualHeight:y},t[22]=o,t[23]=l,t[24]=y,t[25]=b):b=t[25],b}var qv=(0,Q.memo)(function(e){let t=(0,Z.c)(23),{inputRef:n,draftID:r,ariaLabel:i,onManualHeightChange:a}=e,o=(0,Q.useRef)(null),s;t[0]!==r||t[1]!==n?(s={enabled:!0,hasContent:!0,draftID:r,inputRef:n},t[0]=r,t[1]=n,t[2]=s):s=t[2];let c=Kv(s),{snapPoint:l,manualHeight:u,dragging:d,settling:f}=c,p,m;t[3]!==d||t[4]!==u||t[5]!==a||t[6]!==f||t[7]!==l?(p=()=>{let e=o.current?.closest(`[data-mobile-composer-surface]`);e&&(e.dataset.composerHeightSnap=l,e.toggleAttribute(`data-composer-height-manual`,u),d||f?e.dataset.mobileComposerResizing=`true`:delete e.dataset.mobileComposerResizing),a(u)},m=[l,u,d,f,a],t[3]=d,t[4]=u,t[5]=a,t[6]=f,t[7]=l,t[8]=p,t[9]=m):(p=t[8],m=t[9]),(0,Q.useLayoutEffect)(p,m);let h,g;t[10]===a?(h=t[11],g=t[12]):(h=()=>{let e=o.current?.closest(`[data-mobile-composer-surface]`);return()=>{e?.removeAttribute(`data-composer-height-snap`),e?.removeAttribute(`data-composer-height-manual`),e?.removeAttribute(`data-mobile-composer-resizing`),a(!1)}},g=[a],t[10]=a,t[11]=h,t[12]=g),(0,Q.useLayoutEffect)(h,g);let _=l===`min`?0:l===`auto`?1:2,v;return t[13]!==i||t[14]!==c.handleClick||t[15]!==c.handleKeyDown||t[16]!==c.handleLostPointerCapture||t[17]!==c.handlePointerCancel||t[18]!==c.handlePointerDown||t[19]!==c.handlePointerMove||t[20]!==c.handlePointerUp||t[21]!==_?(v=(0,$.jsx)(la,{ref:o,"data-mobile-composer-snap-handle":!0,"aria-label":i,"aria-valuemin":0,"aria-valuemax":2,"aria-valuenow":_,className:`absolute top-1 left-1/2 z-40 h-2.5 w-20 -translate-x-1/2 items-center`,onPointerDown:c.handlePointerDown,onPointerMove:c.handlePointerMove,onPointerUp:c.handlePointerUp,onPointerCancel:c.handlePointerCancel,onLostPointerCapture:c.handleLostPointerCapture,onClick:c.handleClick,onKeyDown:c.handleKeyDown}),t[13]=i,t[14]=c.handleClick,t[15]=c.handleKeyDown,t[16]=c.handleLostPointerCapture,t[17]=c.handlePointerCancel,t[18]=c.handlePointerDown,t[19]=c.handlePointerMove,t[20]=c.handlePointerUp,t[21]=_,t[22]=v):v=t[22],v}),Jv=.5,Yv=`--yuri-mobile-composer-swap`,Xv=`--yuri-native-composer-dock`,Zv=()=>({phase:`rest`,rest:`expanded`,progress:0,pinned:!1}),Qv=(e,t,n)=>Math.min(n,Math.max(t,e)),$v=(e,t)=>e.phase===t.phase&&e.rest===t.rest&&e.progress===t.progress&&e.pinned===t.pinned,ey=(e,t)=>{let n={phase:t.phase,rest:t.rest,progress:t.progress,pinned:t.pinned??e.pinned};return $v(e,n)?e:n},ty=(e,t)=>t?ey(e,{phase:`rest`,rest:`expanded`,progress:0,pinned:!0}):e.pinned?ey(e,{phase:`rest`,rest:`expanded`,progress:0,pinned:!1}):e,ny=(e,t)=>{if(e.pinned&&t===`compact`)return e;let n=+(t===`compact`);return e.phase===`rest`&&e.rest===t&&e.progress===n?e:ey(e,{phase:`snapping`,rest:t,progress:n})},ry=e=>Math.round(Qv(e,0,1)*1e3)/1e3,iy=(e,t,n)=>{let r=n-t;if(r>=0)return ry(e+r/80);if(n<=2)return 0;if(n>=120)return e;let i=e+r/80,a=n/t*e;return ry(Math.min(i,a))},ay=(e,t)=>e>=1?`compact`:e<=0?`expanded`:t,oy=(e,t,n={})=>{if(e.pinned||n.userDriven===!1)return e;let r=Math.max(0,t),i=n.previousDistance==null?r:Math.max(0,n.previousDistance),a=e.phase===`snapping`?ey(e,{phase:`rest`,rest:e.rest,progress:+(e.rest===`compact`)}):e;if(r<=2)return ey(a,{phase:`rest`,rest:`expanded`,progress:0});if(n.suppressReturn&&a.rest===`compact`&&r<i)return ey(a,{phase:`rest`,rest:`compact`,progress:1});let o=iy(a.progress,i,r);return e.phase===`snapping`&&o===a.progress?e:o===a.progress?a:Math.abs(o-a.progress)>=Jv&&(o>=1||o<=0)?ey(a,{phase:`snapping`,rest:o>=1?`compact`:`expanded`,progress:o}):o>=1||o<=0?ey(a,{phase:`rest`,rest:ay(o,a.rest),progress:o}):ey(a,{phase:`tracking`,rest:a.rest,progress:o})},sy=(e,t=null)=>e.pinned?`expanded`:t||(e.progress>=.5?`compact`:`expanded`),cy=(e,t=null)=>{if(e.pinned)return ey(e,{phase:`rest`,rest:`expanded`,progress:0,pinned:!0});if(e.phase===`snapping`)return e;let n=sy(e,t),r=+(n===`compact`);return e.phase===`rest`&&e.rest===n&&e.progress===r?e:ey(e,{phase:`snapping`,rest:n,progress:r})},ly=e=>e.phase===`snapping`?ey(e,{phase:`rest`,rest:e.rest,progress:+(e.rest===`compact`)}):e,uy=e=>Qv(Math.max(0,e)/80,0,1),dy=(e,t=`away`)=>{let n=Math.max(0,e);return n<=2?{progress:0,rest:`bottom`}:t===`away`||n>=40?{progress:1,rest:`away`}:{progress:uy(n),rest:`bottom`}},fy=`--yuri-mobile-composer-occupancy`,py=(e,t)=>{if(!(t>0))return null;let n=`${Math.round(t)}px`;return e.style.getPropertyValue(`--yuri-mobile-composer-occupancy`)!==n&&e.style.setProperty(fy,n),n},my=(e,t)=>{t!==null&&e.style.getPropertyValue(`--yuri-mobile-composer-occupancy`)===t&&e.style.removeProperty(fy)},hy=e=>{for(let t of e.children)if(t instanceof HTMLElement&&t.classList.contains(`yuri-mobile-composer-foot--overlay`)&&!t.classList.contains(`invisible`))return t;return e},gy=(e,t=e)=>{for(let n of new Set([e,t]))n.style.removeProperty(Yv),n.style.removeProperty(Xv);delete e.dataset.yuriComposerSwapPhase,delete e.dataset.yuriComposerSwapRest,delete e.dataset.yuriNativeComposerDock},_y=(e,t,n,r=e)=>{let i=dy(t,n?.rest===`bottom`?`bottom`:`away`),a=String(i.progress),o=i.rest;return n?.progress!==a&&r.style.setProperty(Xv,a),n?.rest!==o&&(e.dataset.yuriNativeComposerDock=o),{progress:a,rest:o}},vy=(e,t,n,r=e)=>{let i=String(t.progress),a=t.phase,o=t.rest;return n?.phase!==a&&(e.dataset.yuriComposerSwapPhase=a,a===`snapping`&&n&&n.phase!==`snapping`&&r.offsetWidth),n?.progress!==i&&r.style.setProperty(Yv,i),n?.rest!==o&&(e.dataset.yuriComposerSwapRest=o),{progress:i,phase:a,rest:o}},yy=`box-border w-full whitespace-pre-wrap break-words px-3 typography-markdown [font-family:inherit] [font-style:inherit] [font-weight:inherit] leading-[inherit] tracking-[inherit] md:typography-ui-label`,by=Ao(()=>on(()=>import(`./ToolOutputDialog-D_Kl-Bc5.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),xy=[],Sy=[],Cy=[],wy=/^@[^\s]+$/,Ty=({inputMode:e,message:t,showCommandAutocomplete:n})=>e!==`shell`&&(n||/(^|\s)\/[A-Za-z0-9_-]*/.test(t)),Ey=/^(https?:\/\/|mailto:)\S+$/i,Dy=(e,t)=>e.name===t?e:new File([e],t,{type:e.type,lastModified:e.lastModified}),Oy=(e,t)=>{if(e===t)return``;let n=0;for(;n<e.length&&n<t.length&&e[n]===t[n];)n+=1;let r=e.length,i=t.length;for(;r>n&&i>n&&e[r-1]===t[i-1];)--r,--i;return t.slice(n,i)},ky=e=>e.includes(`@`)?`paste`:`manual`,Ay=(e,t)=>{let n=t,r=t;for(;n>0&&/\s/.test(e[n-1]);)--n;for(;r<e.length&&/\s/.test(e[r]);)r+=1;let i=n>0&&r<e.length?` `:``;return{text:`${e.slice(0,n)}${i}${e.slice(r)}`,caret:n+i.length}},jy=(e,t)=>ae(e,t).some(e=>e.role===`user`),My=(e,t)=>{let n=e.filter(e=>e.type===`text`&&!Qn(e)).map(e=>{let t=e;return typeof t.text==`string`?t.text:typeof t.content==`string`?t.content:``}).join(`
13
13
  `).replace(/\s+/g,` `).trim();if(n)return n;let r=e.find(e=>e.type===`file`);return r?.filename?`[${r.filename}]`:t},Ny=`file://`,Py=e=>{let t=e.replace(/\\/g,`/`);return/^[A-Za-z]:/.test(t)&&(t=`/${t}`),t.split(`/`).map((e,t)=>t===1&&/^[A-Za-z]:$/.test(e)?e:encodeURIComponent(e)).join(`/`)},Fy=e=>{let t=e.replace(/\\/g,`/`).trim();return t.toLowerCase().startsWith(Ny)?t:`file://${Py(t)}`},Iy=e=>{if(!e)return[];let t=[...v_(e).map(y_),...Array.from(e.files||[]).map(e=>s(e)).filter(e=>!!e)];return Array.from(new Set(t.filter(b_)))},Ly=e=>{if(typeof e!=`string`)return null;let t=e.trim();if(!t)return null;let n=t.replace(/\\/g,`/`);return n===`/`?`/`:n.length>1?n.replace(/\/+$/,``):n},Ry=e=>Fr(e.path),zy=(e,t)=>{if(!t)return e;let n=e.indexOf(t);return n===-1?e:(0,$.jsxs)($.Fragment,{children:[e.slice(0,n),(0,$.jsx)(`span`,{className:`font-medium`,children:t}),e.slice(n+t.length)]})},By=e=>(e??[]).map(e=>({...e,dataUrl:e.source===`server`&&e.serverPath?Fy(e.serverPath):e.dataUrl})),Vy=(e,t)=>{let n=e.ownerDocument,r=n.defaultView;if(!r)return null;let i=r.getComputedStyle(e),a=n.createElement(`div`),o=a.style;o.position=`absolute`,o.visibility=`hidden`,o.pointerEvents=`none`,o.whiteSpace=`pre-wrap`,o.wordWrap=`break-word`,o.overflow=`hidden`,o.left=`-9999px`,o.top=`0`,o.width=`${e.clientWidth}px`,o.font=i.font,o.fontSize=i.fontSize,o.fontFamily=i.fontFamily,o.fontWeight=i.fontWeight,o.fontStyle=i.fontStyle,o.fontVariant=i.fontVariant,o.letterSpacing=i.letterSpacing,o.textTransform=i.textTransform,o.textIndent=i.textIndent,o.padding=i.padding,o.border=i.border,o.boxSizing=i.boxSizing,o.lineHeight=i.lineHeight,o.tabSize=i.tabSize,a.textContent=e.value.slice(0,t);let s=n.createElement(`span`);s.textContent=e.value.slice(t,t+1)||` `,a.appendChild(s),n.body.appendChild(a);let c=s.offsetTop,l=s.offsetLeft;return n.body.removeChild(a),{top:c,left:l}},Hy=e=>{if(!e)return!1;if(e.files&&e.files.length>0)return!0;if(e.types){let t=Array.from(e.types).map(e=>e.toLowerCase());if(t.includes(`files`)||t.includes(`text/uri-list`)||t.includes(`codefiles`)||t.includes(`application/x-yuri-file-path`)||t.some(e=>e.includes(`vnd.code.tree`)))return!0}return v_(e).length>0},Uy=e=>{if(!e)return[];let t=Array.from(e.files||[]);return t.length>0?t:Array.from(e.items||[]).filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>!!e)},Wy=e=>{let t=e.icon?ld[e.icon]:null,n=e.color?ud[e.color]:void 0,r=(0,$.jsx)(X,{name:t??`folder`,className:`h-3.5 w-3.5`,style:n?{color:n}:void 0});return(0,$.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`relative top-px flex h-4 w-4 shrink-0 items-center justify-center overflow-hidden text-muted-foreground`,children:e.iconImage?(0,$.jsx)(cd,{project:e,className:`size-full object-contain`,fallback:r}):r}),(0,$.jsx)(`span`,{className:`truncate`,children:Ry(e)})]})},Gy=Q.memo(eh),Ky=Q.memo(Vd),qy=(0,$.jsx)(`span`,{"data-yuri-composer-dictation-active":`true`,className:`hidden`,"aria-hidden":`true`}),Jy=Q.memo(Jd),Yy=Q.memo(_g),Xy=Q.memo(bg),Zy=Q.memo(ag),Qy=Q.memo(({sessionId:e,directory:t})=>{let{t:n}=na(),r=ln(e=>e.isMobile),i=Xr(e=>e.revertToMessage),a=Xr(e=>e.forkFromMessage),o=Xr(e=>e.handleSlashRedo),[s,c]=Q.useState(null),[l,u]=Q.useState(null),[d,f]=Q.useState(!0),p=Q.useRef(s_),m=pr(),h=t||m,g=hr(h),_=re(e??``,h,g),v=br(e=>e.session,h),y=Q.useMemo(()=>{let t=_.messageOrder.map(e=>_.messagesByID[e]).filter(e=>!!e),n=u_({session:v,messages:t,partsByMessageID:_.partsByMessageID},e,p.current);return p.current=n,n},[e,v,_]),b=y.revertMessageID,x=Q.useMemo(()=>{let t=v.find(t=>t.id===e);return B(t?.revert)},[e,v]),S=Q.useMemo(()=>y.records.map(e=>e.message),[y]),C=n(`chat.revertPopover.noTextContent`),w=Q.useMemo(()=>b?y.records.map(e=>({id:e.message.id,text:My(e.parts,C)})):[],[C,b,y]),T=w[0]?.id;Q.useEffect(()=>{f(!0)},[b,T]);let E=G(async t=>{if(!(!e||s)){c(t);try{let n=S.find(e=>e.id>t);n?await i(e,n.id,{skipRedoPush:!0}):await o(e,{fullUnrevert:!0})}finally{c(null)}}}),D=G(async t=>{if(!(!e||l)){u(t);try{await a(e,t)}finally{u(null)}}});return!e||w.length===0?null:(0,$.jsx)(`div`,{className:J(`w-full px-1`,r?`pb-1 text-xs`:`pb-2`),children:(0,$.jsxs)(`div`,{className:J(`border border-border/60 bg-[var(--surface-elevated)] text-[var(--surface-elevated-foreground)] shadow-sm dark:shadow-none overflow-hidden`,r?`rounded-lg`:`rounded-xl`),children:[(0,$.jsxs)(`button`,{type:`button`,className:J(`flex w-full items-center text-left hover:bg-[var(--interactive-hover)] transition-colors`,r?`gap-1.5 px-2 py-1`:`gap-2 px-3 py-2`),onClick:()=>f(e=>!e),"aria-expanded":!d,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-medium text-foreground flex-shrink-0`,children:[n(`chat.revertPopover.title`),` messages `,w.length]}),x.length>0&&(0,$.jsxs)(`span`,{className:`min-w-0 truncate typography-ui-label text-muted-foreground`,children:[n(`chat.revertPopover.files`),`: `,x.join(`, `)]}),(0,$.jsx)(X,{name:`arrow-down-s`,className:J(`ml-auto text-muted-foreground transition-transform`,r?`size-3.5`:`size-4`,!d&&`rotate-180`),"aria-hidden":`true`})]}),!d&&(0,$.jsx)(`div`,{className:J(`flex flex-col overflow-y-auto`,r?`max-h-[8rem] gap-1 px-2 pb-1.5`:`max-h-[10.5rem] gap-1.5 px-3 pb-3`),children:w.map(e=>(0,$.jsxs)(`div`,{className:J(`flex min-w-0 items-center`,r?`gap-1.5`:`gap-2 py-1`),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate typography-ui-label text-foreground`,children:e.text}),(0,$.jsxs)(Tr,{type:`button`,variant:`secondary`,size:`xs`,disabled:!!(s||l),onClick:()=>{D(e.id)},children:[l===e.id?(0,$.jsx)(X,{name:`loader-4`,className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):(0,$.jsx)(X,{name:`git-branch`,className:`h-3 w-3`,"aria-hidden":`true`}),n(`chat.revertPopover.fork`)]}),(0,$.jsxs)(Tr,{type:`button`,variant:`secondary`,size:`xs`,disabled:!!(s||l),onClick:()=>{E(e.id)},children:[s===e.id?(0,$.jsx)(X,{name:`loader-4`,className:`h-3 w-3 animate-spin`,"aria-hidden":`true`}):(0,$.jsx)(X,{name:`arrow-go-forward`,className:`h-3 w-3`,"aria-hidden":`true`}),n(`chat.revertPopover.restore`)]})]},e.id))})]})})});Qy.displayName=`RevertedMessageDock`;function $y({projects:e,query:t,renderLabel:n,onSelect:r,selectedId:i}){return e.filter(e=>Eu(Ry(e),t)||Eu(e.path,t)).map(e=>r?(0,$.jsxs)(`button`,{type:`button`,className:`flex w-full cursor-pointer items-center gap-2 rounded-lg px-2 py-2.5 text-left typography-ui-label hover:bg-[var(--interactive-hover)]`,onClick:()=>r(e.id),children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:n(e)}),e.id===i?(0,$.jsx)(X,{name:`check`,className:`h-4 w-4 flex-shrink-0 text-muted-foreground`}):null]},e.id):(0,$.jsx)(Yu,{value:e.id,className:`max-w-[24rem] truncate`,children:n(e)},e.id))}var eb=Q.memo(function(e){let t=(0,Z.c)(42),{t:n}=na(),{isVSCode:r,footerIconButtonClass:i,iconSizeClass:a,handlePickLocalFiles:o,openIssuePicker:s,openPrPicker:c,onOpenSettings:l,withTooltip:u}=e,d=u!==void 0&&u,f=!!e.onOpenMobileSheet,p;t[0]===n?p=t[1]:(p=n(`chat.chatInput.actions.attachFiles`),t[0]=n,t[1]=p);let m=p,h=o,g;t[2]!==h||t[3]!==e?(g=()=>e.onOpenAndroidPickSheet?e.onOpenAndroidPickSheet():h(),t[2]=h,t[3]=e,t[4]=g):g=t[4];let _=f?fb:void 0,v=f?pb:void 0,y=d?void 0:m,b;t[5]===a?b=t[6]:(b=J(a,`text-current`),t[5]=a,t[6]=b);let x;t[7]===b?x=t[8]:(x=(0,$.jsx)(X,{name:`attachment-2`,className:b}),t[7]=b,t[8]=x);let S;t[9]!==m||t[10]!==i||t[11]!==g||t[12]!==_||t[13]!==v||t[14]!==y||t[15]!==x?(S=(0,$.jsx)(`button`,{type:`button`,className:i,onClick:g,onMouseDown:_,onPointerDownCapture:v,title:y,"aria-label":m,children:x}),t[9]=m,t[10]=i,t[11]=g,t[12]=_,t[13]=v,t[14]=y,t[15]=x,t[16]=S):S=t[16];let C=S,w;t[17]!==C||t[18]!==m||t[19]!==d?(w=d?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:C}),(0,$.jsx)(ka,{side:`top`,sideOffset:8,className:`yuri-composer-tooltip`,children:m})]}):C,t[17]=C,t[18]=m,t[19]=d,t[20]=w):w=t[20];let T;t[21]!==i||t[22]!==o||t[23]!==a||t[24]!==r||t[25]!==s||t[26]!==c||t[27]!==e.onMenuOpenChange||t[28]!==e.onOpenMobileSheet||t[29]!==n?(T=null,t[21]=i,t[22]=o,t[23]=a,t[24]=r,t[25]=s,t[26]=c,t[27]=e.onMenuOpenChange,t[28]=e.onOpenMobileSheet,t[29]=n,t[30]=T):T=t[30];let E;t[31]!==T||t[32]!==w?(E=(0,$.jsxs)(`div`,{className:`relative inline-flex`,children:[w,T]}),t[31]=T,t[32]=w,t[33]=E):E=t[33];let D;t[34]!==i||t[35]!==a||t[36]!==l||t[37]!==n?(D=l?(0,$.jsx)(`button`,{type:`button`,onClick:l,className:i,title:n(`chat.chatInput.actions.modelAgentSettings`),"aria-label":n(`chat.chatInput.actions.modelAgentSettings`),children:(0,$.jsx)(X,{name:`ai-agent`,className:J(a,`text-current`)})}):null,t[34]=i,t[35]=a,t[36]=l,t[37]=n,t[38]=D):D=t[38];let O;return t[39]!==E||t[40]!==D?(O=(0,$.jsxs)(`div`,{className:`flex items-center gap-x-1.5`,children:[E,D]}),t[39]=E,t[40]=D,t[41]=O):O=t[41],O},(e,t)=>e.isVSCode===t.isVSCode&&e.footerIconButtonClass===t.footerIconButtonClass&&e.iconSizeClass===t.iconSizeClass&&e.onOpenSettings===t.onOpenSettings&&e.onMenuOpenChange===t.onMenuOpenChange&&e.onOpenMobileSheet===t.onOpenMobileSheet&&e.onOpenAndroidPickSheet===t.onOpenAndroidPickSheet&&e.withTooltip===t.withTooltip),tb=Q.memo(function(e){let t=(0,Z.c)(29),{t:n}=na(),r=e.enabled?`chat.chatInput.permissionAutoAccept.disable`:`chat.chatInput.permissionAutoAccept.enable`,i;t[0]!==n||t[1]!==r?(i=n(r),t[0]=n,t[1]=r,t[2]=i):i=t[2];let a=i,o=e.saving,s=e.enabled,c=e.footerIconButtonClass,l;t[3]!==e.draftEnabled||t[4]!==e.draftOpen||t[5]!==e.enabled||t[6]!==e.onOpenSessionFirst||t[7]!==e.onSetDraftEnabled||t[8]!==e.onSetSessionEnabled||t[9]!==e.onToggleFailed||t[10]!==e.sessionId?(l=()=>tv({permissionScopeSessionId:e.sessionId,newSessionDraftOpen:e.draftOpen,draftPermissionAutoAcceptEnabled:e.draftEnabled,permissionAutoAcceptEnabled:e.enabled,setDraftPermissionAutoAcceptEnabled:e.onSetDraftEnabled,setSessionAutoAccept:e.onSetSessionEnabled,onOpenSessionFirst:e.onOpenSessionFirst,onToggleFailed:e.onToggleFailed}),t[3]=e.draftEnabled,t[4]=e.draftOpen,t[5]=e.enabled,t[6]=e.onOpenSessionFirst,t[7]=e.onSetDraftEnabled,t[8]=e.onSetSessionEnabled,t[9]=e.onToggleFailed,t[10]=e.sessionId,t[11]=l):l=t[11];let u=e.enabled?`shield-check`:`shield`,d;t[12]===e.iconSizeClass?d=t[13]:(d=J(e.iconSizeClass,`text-current`),t[12]=e.iconSizeClass,t[13]=d);let f;t[14]!==u||t[15]!==d?(f=(0,$.jsx)(X,{name:u,className:d}),t[14]=u,t[15]=d,t[16]=f):f=t[16];let p;t[17]!==a||t[18]!==e.enabled||t[19]!==e.footerIconButtonClass||t[20]!==e.saving||t[21]!==l||t[22]!==f?(p=(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:o,"aria-pressed":s,"aria-label":a,className:c,onClick:l,onMouseDown:mb,onPointerDownCapture:hb,children:f})}),t[17]=a,t[18]=e.enabled,t[19]=e.footerIconButtonClass,t[20]=e.saving,t[21]=l,t[22]=f,t[23]=p):p=t[23];let m;t[24]===a?m=t[25]:(m=(0,$.jsx)(ka,{side:`top`,sideOffset:8,className:`yuri-composer-tooltip`,children:a}),t[24]=a,t[25]=m);let h;return t[26]!==m||t[27]!==p?(h=(0,$.jsxs)(Aa,{children:[p,m]}),t[26]=m,t[27]=p,t[28]=h):h=t[28],h}),nb=Q.memo(function(e){let t=(0,Z.c)(66),{isMobile:n,compact:r,footerIconButtonClass:i,stopFooterIconButtonClass:a,compactCircleButtonClass:o,stopIconSizeClass:s,canSend:c,canAbort:l,abortPending:u,hasContent:d,currentSessionId:f,newSessionDraftOpen:p,draftSubmitting:m,submissionBlocked:h,sendPhase:g,queueFrozen:_,queueFallbackAvailable:v,onPrimaryAction:y,onAbort:b}=e,x=r!==void 0&&r,{t:S}=na(),C=l,w=!!(f||p),T=!!m,E;t[0]!==c||t[1]!==v||t[2]!==_||t[3]!==g||t[4]!==h||t[5]!==w||t[6]!==T?(E=kg({canSend:c,hasSessionTarget:w,draftSubmitting:T,submissionBlocked:h,sendPhase:g,queueFrozen:_,queueFallbackAvailable:v}),t[0]=c,t[1]=v,t[2]=_,t[3]=g,t[4]=h,t[5]=w,t[6]=T,t[7]=E):E=t[7];let D=E,O;t[8]===n?O=t[9]:(O=n?{onMouseDown:gb,onPointerDownCapture:_b}:{},t[8]=n,t[9]=O);let k=O,A=g.inFlight,j=A&&g.flightKind===`queue`,M=A&&g.flightKind!==`queue`,N;t[10]!==j||t[11]!==M||t[12]!==S?(N=S(j?`chat.chatInput.actions.queuingMessageAria`:M?`chat.chatInput.actions.sendingMessageAria`:`chat.chatInput.actions.sendMessageAria`),t[10]=j,t[11]=M,t[12]=S,t[13]=N):N=t[13];let P=N,F=x?o??a??i:a??i,I=s,L=C&&(!n||!d),R=n?`button`:`submit`,ee=D.sendDisabled,z=A||void 0,B;t[14]!==n||t[15]!==y?(B=e=>{n&&(e.preventDefault(),y())},t[14]=n,t[15]=y,t[16]=B):B=t[16];let V;t[17]===F?V=t[18]:(V=J(F,`disabled:opacity-50`),t[17]=F,t[18]=V);let H;t[19]!==A||t[20]!==j||t[21]!==M||t[22]!==L||t[23]!==S?(H=S(M||!L&&A?j?`chat.chatInput.actions.queuingMessageAria`:`chat.chatInput.actions.sendingMessageAria`:`chat.chatInput.actions.sendMessageAria`),t[19]=A,t[20]=j,t[21]=M,t[22]=L,t[23]=S,t[24]=H):H=t[24];let U=!!(A&&!L),te;t[25]!==I||t[26]!==U?(te=(0,$.jsx)(gs,{className:I,spinning:U}),t[25]=I,t[26]=U,t[27]=te):te=t[27];let ne;t[28]!==D.sendDisabled||t[29]!==k||t[30]!==V||t[31]!==H||t[32]!==te||t[33]!==R||t[34]!==z||t[35]!==B?(ne=(0,$.jsx)(`button`,{type:R,"data-composer-send":`true`,"data-composer-circle":`true`,disabled:ee,"aria-busy":z,...k,onClick:B,className:V,"aria-label":H,children:te}),t[28]=D.sendDisabled,t[29]=k,t[30]=V,t[31]=H,t[32]=te,t[33]=R,t[34]=z,t[35]=B,t[36]=ne):ne=t[36];let re=ne;if(!L)return re;let W=!n&&!x&&(d||j),ie=x&&`h-full`,ae;t[37]===ie?ae=t[38]:(ae=J(`relative z-30 overflow-visible`,ie),t[37]=ie,t[38]=ae);let oe;t[39]!==D.sendDisabled||t[40]!==F||t[41]!==I||t[42]!==k||t[43]!==y||t[44]!==P||t[45]!==j||t[46]!==W?(oe=W?(0,$.jsx)(`button`,{type:`button`,"data-composer-send":`true`,"data-composer-circle":`true`,disabled:D.sendDisabled||j,"aria-busy":j||void 0,...k,onClick:e=>{e.preventDefault(),!j&&y()},className:J(F,`absolute z-30 bottom-full left-1/2 -translate-x-1/2 mb-1 disabled:opacity-50`),"aria-label":P,children:(0,$.jsx)(gs,{className:I,spinning:j})}):null,t[39]=D.sendDisabled,t[40]=F,t[41]=I,t[42]=k,t[43]=y,t[44]=P,t[45]=j,t[46]=W,t[47]=oe):oe=t[47];let se=u||void 0,ce;t[48]===F?ce=t[49]:(ce=J(F,`relative z-30`),t[48]=F,t[49]=ce);let le;t[50]===S?le=t[51]:(le=S(`chat.chatInput.actions.stopGeneratingAria`),t[50]=S,t[51]=le);let ue;t[52]!==u||t[53]!==I?(ue=u?(0,$.jsx)(gs,{className:I,spinning:!0}):(0,$.jsx)(xs,{className:J(I)}),t[52]=u,t[53]=I,t[54]=ue):ue=t[54];let de;t[55]!==u||t[56]!==b||t[57]!==se||t[58]!==ce||t[59]!==le||t[60]!==ue?(de=(0,$.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,onClick:b,disabled:u,"aria-busy":se,className:ce,"aria-label":le,children:ue}),t[55]=u,t[56]=b,t[57]=se,t[58]=ce,t[59]=le,t[60]=ue,t[61]=de):de=t[61];let fe;return t[62]!==ae||t[63]!==oe||t[64]!==de?(fe=(0,$.jsxs)(`div`,{className:ae,children:[oe,de]}),t[62]=ae,t[63]=oe,t[64]=de,t[65]=fe):fe=t[65],fe},(e,t)=>e.isMobile===t.isMobile&&e.compact===t.compact&&e.footerIconButtonClass===t.footerIconButtonClass&&e.stopFooterIconButtonClass===t.stopFooterIconButtonClass&&e.compactCircleButtonClass===t.compactCircleButtonClass&&e.stopIconSizeClass===t.stopIconSizeClass&&e.canSend===t.canSend&&e.canAbort===t.canAbort&&e.abortPending===t.abortPending&&e.hasContent===t.hasContent&&e.currentSessionId===t.currentSessionId&&e.newSessionDraftOpen===t.newSessionDraftOpen&&e.draftSubmitting===t.draftSubmitting&&e.submissionBlocked===t.submissionBlocked&&e.sendPhase===t.sendPhase&&e.queueFrozen===t.queueFrozen&&e.queueFallbackAvailable===t.queueFallbackAvailable&&e.onPrimaryAction===t.onPrimaryAction&&e.onAbort===t.onAbort),rb=(e,t)=>`${e}${e?e.endsWith(`
14
14
 
15
15
  `)?``:e.endsWith(`
@@ -50,7 +50,7 @@ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t}from"./runtime-
50
50
  `).map(e=>e.replace(/^>\s?/,``).trimEnd()).filter(e=>e.trim().length>0).join(`
51
51
  `).trim(),Yw=80,Xw=200,Zw={duration:.2,ease:`easeOut`},Qw=e=>e.replace(/<!--\s*-->/g,``).replace(/```[\w]*\n?([\s\S]*?)```/g,(e,t)=>t.trim()).replace(/`([^`]+)`/g,`$1`).replace(/\*{1,3}([^*]+)\*{1,3}/g,`$1`).replace(/_{1,3}([^_]+)_{1,3}/g,`$1`).replace(/^#{1,6}\s+/gm,``).replace(/\[([^\]]+)\]\([^)]*\)/g,`$1`).replace(/^>\s?/gm,``).replace(/^[-*_]{3,}\s*$/gm,``).trim(),$w=e=>{if(!e)return``;let t=Qw(e).replace(/\s+/g,` `).trim();if(t.length<=Yw)return t;let n=t.lastIndexOf(` `,Yw),r=n>0?n:Yw;return`${t.substring(0,r).trimEnd()}…`},eT=({text:e,variant:t,onContentChange:n,blockId:r,time:i,isStreaming:a=!1,actions:o,defaultExpanded:s})=>{let{t:c}=na(),l=ln(e=>e.isMobile),u=typeof i?.end==`number`,d=a&&!u,[f,p]=Q.useState(()=>s===!0?{expanded:!0,source:`user`}:{expanded:d,source:`auto`}),m=f.expanded,[h,g]=Q.useState(s===!0||d),_=Q.useId(),v=Q.useRef(null),y=Q.useRef(null),b=Q.useRef(!1),x=Q.useRef(n);x.current=n;let S=Q.useMemo(()=>$w(e),[e]),C=c(m?`chat.reasoningTrace.collapseAria`:`chat.reasoningTrace.expandAria`),w=G(()=>{g(!0),p({expanded:!m,source:`user`}),n?.(`structural`)}),T=G(e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),w())});if(Q.useLayoutEffect(()=>{p(e=>e.source===`user`||e.expanded||!d?e:{expanded:!0,source:`auto`})},[d]),Q.useEffect(()=>{e.trim().length!==0&&n?.(`structural`)},[n,e]),Q.useEffect(()=>{if(m||a){g(!0);return}if(!h)return;if(typeof window>`u`){g(!1);return}let e=window.setTimeout(()=>{g(!1)},Xw);return()=>{window.clearTimeout(e)}},[m,a,h]),Q.useLayoutEffect(()=>{let e=v.current;if(!e)return;if(y.current?.stop(),!b.current){if(b.current=!0,!m){e.style.height=`0px`,e.style.overflow=`hidden`;return}e.style.height=`0px`,e.style.overflow=`hidden`;let t=ma(e,{height:`auto`},Zw);return y.current=t,t.finished.then(()=>{y.current===t&&(y.current=null,e.style.overflow=`visible`,e.style.height=`auto`)}).catch(()=>void 0),()=>{t.stop(),y.current===t&&(y.current=null)}}e.style.overflow=`hidden`,m?e.style.height=`0px`:(e.style.height=`${e.scrollHeight}px`,x.current?.(`animation`));let t=ma(e,{height:m?`auto`:`0px`},Zw);return y.current=t,t.finished.then(()=>{y.current===t&&(y.current=null,m?(e.style.overflow=`visible`,e.style.height=`auto`):e.style.overflow=`hidden`)}).catch(()=>void 0),()=>{t.stop(),y.current===t&&(y.current=null)}},[m]),Q.useEffect(()=>()=>{y.current?.stop(),y.current=null},[]),!e||e.trim().length===0)return null;let E=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{"data-message-text-export-source":`true`,children:(0,$.jsx)(Mo,{content:e,messageId:r,isAnimated:!1,isStreaming:a,variant:`reasoning`})}),o?(0,$.jsx)(`div`,{className:`mt-2 mb-1 flex items-center justify-start gap-1.5`,"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,"data-message-action-group":`true`,children:o})}):null]});return(0,$.jsxs)(`div`,{"data-reasoning-block-id":r,"data-message-text-export-root":`true`,children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":m,"aria-controls":_,"aria-label":C,"data-mobile-press-feedback":`soft`,className:J(`group/tool flex gap-1.5 cursor-pointer items-center`,hm),onClick:w,onKeyDown:T,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 flex-shrink-0`,children:[(0,$.jsxs)(`div`,{className:`relative h-3.5 w-3.5 flex-shrink-0 cursor-pointer`,children:[(0,$.jsx)(`div`,{className:J(`absolute inset-0 transition-opacity`,m&&`opacity-0`,!m&&`group-hover/tool:opacity-0`),style:{color:`var(--tools-icon)`},children:(0,$.jsx)(X,{name:`brain-ai-3`,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`div`,{className:J(`absolute inset-0 transition-opacity flex items-center justify-center`,m&&`opacity-100`,!m&&`opacity-0 group-hover/tool:opacity-100`),style:{color:`var(--tools-icon)`},children:m?(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`arrow-right-s`,className:`h-3.5 w-3.5`})})]}),a?(0,$.jsxs)(`span`,{className:J(`flex items-center gap-1`,Kw),style:{color:`var(--tools-title)`},children:[(0,$.jsx)(`span`,{className:`animate-text-shimmer`,style:{"--yuri-text-shimmer-base":`var(--tools-title)`},children:c(t===`justification`?`chat.reasoningTrace.justification`:`chat.reasoningTrace.thinking`)}),(0,$.jsx)(rC,{isMobile:l,className:`block text-[var(--tools-icon)]`})]}):m?(0,$.jsx)(`span`,{className:Kw,style:{color:`var(--tools-title)`},children:c(t===`justification`?`chat.reasoningTrace.justification`:`chat.reasoningTrace.thinking`)}):(0,$.jsx)(`span`,{className:Kw,style:{color:`var(--tools-title)`},children:c(t===`justification`?`chat.reasoningTrace.justification`:`chat.reasoningTrace.thought`)})]}),(0,$.jsx)(`div`,{className:J(`flex items-center gap-1 flex-1 min-w-0`,qw),style:{color:`var(--tools-description)`},children:!a&&!m&&S?(0,$.jsx)(`span`,{className:J(`min-w-0 truncate`,qw),style:{color:`var(--tools-description)`,opacity:.8},title:S,children:S}):(0,$.jsx)(`span`,{className:`min-w-0 flex-1`})})]}),h?(0,$.jsx)(`div`,{ref:v,id:_,"aria-hidden":!m,style:{height:m?`auto`:`0px`,overflow:m?`visible`:`hidden`,overflowAnchor:`none`},children:(0,$.jsxs)(`div`,{className:`relative ml-2 pl-3 pb-1 pt-0.5`,style:{opacity:+!!m,transform:m?`translateY(0)`:`translateY(-4px)`,transition:`opacity 180ms ease-out, transform 180ms ease-out`},children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-0 top-0 bottom-0 w-px opacity-40`,style:{backgroundColor:`var(--tools-border)`}}),a?(0,$.jsx)(`div`,{className:`p-0`,children:E}):(0,$.jsx)(ca,{as:`div`,outerClassName:`max-h-80`,className:`p-0`,useScrollShadow:!0,scrollShadowSize:36,userIntentOnly:!0,children:E})]})}):null]})},tT=Q.memo(e=>{let t=(0,Z.c)(20),{part:n,onContentChange:r,messageId:i,streamPhase:a}=e,o=ln(nT),s=n,c=s.text||s.content||``,l;t[0]===c?l=t[1]:(l=Jw(c),t[0]=c,t[1]=l);let u=l,d=s.time,f=a===void 0||a!==`completed`,p=o===`live`&&f&&typeof d?.end!=`number`,m=`${i}:${n.id??`reasoning`}`,h;t[2]!==p||t[3]!==m||t[4]!==u?(h={text:u,isStreaming:p,identityKey:m},t[2]=p,t[3]=m,t[4]=u,t[5]=h):h=t[5];let g=Dd(h),_=`${i}:${n.id??`reasoning`}`,v=Q.useRef(null),y=n.sessionID,b=f&&typeof d?.end!=`number`,x,S;if(t[6]!==_||t[7]!==b||t[8]!==i||t[9]!==n.id||t[10]!==y||t[11]!==g?(x=()=>{if(!Ri())return;let e=Jr(v.current,{identity:_,content:g,isActive:b,mode:`appearance`});v.current=e.nextState,!(!e.shouldEmit||!y)&&yn({sessionID:y,messageID:i,partID:n.id,kind:`thinking`})},S=[_,b,i,n.id,y,g],t[6]=_,t[7]=b,t[8]=i,t[9]=n.id,t[10]=y,t[11]=g,t[12]=x,t[13]=S):(x=t[12],S=t[13]),Q.useEffect(x,S),!g||g.trim().length===0)return null;let C=n.id||`${i}-reasoning`,w;return t[14]!==p||t[15]!==r||t[16]!==C||t[17]!==g||t[18]!==d?(w=(0,$.jsx)(eT,{text:g,variant:`thinking`,onContentChange:r,blockId:C,time:d,isStreaming:p}),t[14]=p,t[15]=r,t[16]=C,t[17]=g,t[18]=d,t[19]=w):w=t[19],w});function nT(e){return e.chatRenderMode}var rT=(e,t)=>{let n=Jt(e,t)||Gt(t);return n?Kt(n,e)?{kind:`diff`,path:qt(n,e)||t}:{kind:`file`,path:n,notice:`turn-diff-outside-workspace`}:{kind:`diff`,path:t}},iT=e=>{let t=ln.getState();e.scope?.sdk();let n=e.scope?.key??e.directory,r=rT(e.directory,e.filePath);if(r.kind===`file`){let i=()=>{t.openContextFile(n,r.path,{fileNotice:r.notice}),e.mobile&&t.setRightSidebarOpen(!1)};e.scope?i():ic(r.path,e.directory).then(i);return}if(e.mobile){t.navigateToDiff(r.path,!1,`turn`),t.setRightSidebarOpen(!1);return}t.openContextDiff(n,r.path,!1,`turn`,void 0,e.turnMessageId,e.sessionId)},aT=Q.memo(e=>{let t=(0,Z.c)(36),{activityParts:n}=e,[r,i]=Q.useState(!1),[a,o]=Q.useState(null),s=Q.useRef(null),c=Xo(),l=Rt(),u=qe(oT),d=c.directory||u,f=Qa(d),p;if(t[0]!==n||t[1]!==f){bb0:{if(f!==!1){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[3]=e):e=t[3],p=e;break bb0}if(!n||n.length===0){let e;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[4]=e):e=t[4],p=e;break bb0}let e=[];for(let t of n){let n=t.part;n.type===`tool`&&ah.has(n.tool)&&e.push(n)}if(e.length===0){let e;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[5]=e):e=t[5],p=e;break bb0}p=lh(e)}t[0]=n,t[1]=f,t[2]=p}else p=t[2];let m=p;if(m.length===0)return null;let h;t[6]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>{let e=s.current?.closest(`[data-slot="dialog-content"], [role="dialog"]`);o(e||null)},t[6]=h):h=t[6];let g=h,_;t[7]!==d||t[8]!==l||t[9]!==c?(_=e=>{if(!d)return;let t=ln.getState();iT({scope:l?.entry.location.hostId?l.entry:void 0,directory:d,filePath:e.path,sessionId:c.sessionId,mobile:t.isMobile}),i(!1)},t[7]=d,t[8]=l,t[9]=c,t[10]=_):_=t[10];let v=_,y=m.length,b=`${y} file${y===1?``:`s`}`,x=`${b} changed in this turn`,S;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(X,{name:`file-edit`,className:`h-3.5 w-3.5`}),t[11]=S):S=t[11];let C;t[12]===b?C=t[13]:(C=(0,$.jsx)(`span`,{className:`message-footer__label`,children:b}),t[12]=b,t[13]=C);let w;t[14]===r?w=t[15]:(w=r?(0,$.jsx)(X,{name:`arrow-up-s`,className:`h-3.5 w-3.5`}):(0,$.jsx)(X,{name:`arrow-down-s`,className:`h-3.5 w-3.5`}),t[14]=r,t[15]=w);let T;t[16]!==x||t[17]!==C||t[18]!==w?(T=(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(ke,{render:(0,$.jsxs)(`button`,{ref:s,type:`button`,className:`flex items-center gap-1 text-sm text-muted-foreground/60 hover:text-muted-foreground tabular-nums`,"aria-label":x,onPointerDownCapture:g,onFocusCapture:g,children:[S,C,w]})})}),t[16]=x,t[17]=C,t[18]=w,t[19]=T):T=t[19];let E;t[20]===b?E=t[21]:(E=(0,$.jsxs)(ka,{children:[b,` changed in this turn`]}),t[20]=b,t[21]=E);let D;t[22]!==T||t[23]!==E?(D=(0,$.jsxs)(Aa,{children:[T,E]}),t[22]=T,t[23]=E,t[24]=D):D=t[24];let O=a||void 0,k;t[25]!==m||t[26]!==d||t[27]!==v?(k=(0,$.jsx)(Ae,{side:`top`,align:`start`,sideOffset:4,collisionPadding:8,children:(0,$.jsx)(Fe,{style:zh,className:`${Rh} transition-all duration-150 ease-out data-[starting-style]:opacity-0 data-[starting-style]:scale-95 data-[ending-style]:opacity-0 data-[ending-style]:scale-95`,children:(0,$.jsx)(Lh,{files:m,currentDirectory:d,onOpenFile:v})})}),t[25]=m,t[26]=d,t[27]=v,t[28]=k):k=t[28];let A;t[29]!==O||t[30]!==k?(A=(0,$.jsx)(Pe,{container:O,children:k}),t[29]=O,t[30]=k,t[31]=A):A=t[31];let j;return t[32]!==r||t[33]!==D||t[34]!==A?(j=(0,$.jsxs)(Oe,{open:r,onOpenChange:i,children:[D,A]}),t[32]=r,t[33]=D,t[34]=A,t[35]=j):j=t[35],j});aT.displayName=`TurnChangedFilesDropdown`;function oT(e){return e.currentDirectory}var sT=e=>e.filter(e=>e?.type===`text`).map(e=>(e.text||e.content||``).trim()).filter(e=>e.length>0).join(`
52
52
  `).replace(/\n\s*\n+/g,`
53
- `),cT=e=>typeof e!=`number`||!Number.isFinite(e)||e<0?0:e,lT=e=>{let t=0,n=0,r=!0;return e.map(e=>{if(typeof e.createdAt==`number`&&Number.isFinite(e.createdAt)&&typeof e.streamedAt==`number`&&Number.isFinite(e.streamedAt)?n+=Math.max(0,e.streamedAt-e.createdAt):r=!1,t+=cT(e.outputTokens)+cT(e.reasoningTokens),!r||t<=0||n<=0)return null;let i=t/(n/1e3);return Number.isFinite(i)&&i>0?i:null})},uT=e=>{let t=lT(e);return t[t.length-1]??null},dT=e=>e.completionDisposition!==`active`&&typeof e.tps==`number`&&Number.isFinite(e.tps)&&e.tps>0,fT=e=>!Number.isFinite(e)||e<=0?``:`${e.toFixed(1)} tok/s`,pT=e=>{let t=(0,Z.c)(5),{sessionId:n,scope:r}=e,{t:i}=na(),a=Sn(n,r);if(a===0)return null;let o;t[0]!==a||t[1]!==i?(o=i(`chat.sessionBackground.tasksRunning`,{count:a}),t[0]=a,t[1]=i,t[2]=o):o=t[2];let s;return t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`inline-flex h-3.5 shrink-0 items-center whitespace-nowrap text-[11px] leading-none font-normal text-muted-foreground`,"data-background-activity":`true`,children:(0,$.jsx)(`span`,{className:`animate-text-shimmer`,children:o})}),t[3]=o,t[4]=s),s},mT=Q.memo(e=>{let t=(0,Z.c)(5),{sessionId:n,activityParts:r}=e,i;t[0]===r?i=t[1]:(i=Bx((r??[]).map(hT)),t[0]=r,t[1]=i);let a=i;if(a.childSessionIDs.size===0&&a.shellIDs.size===0)return null;let o;return t[2]!==a||t[3]!==n?(o=(0,$.jsx)(pT,{sessionId:n,scope:a}),t[2]=a,t[3]=n,t[4]=o):o=t[4],o});mT.displayName=`BackgroundActivityHint`;function hT(e){return e.part}var gT=e=>{let t=(0,Z.c)(20),{text:n,active:r,className:i}=e,a=Q.useRef(n),[o,s]=Q.useState(n),[c,l]=Q.useState(null),u,d;t[0]!==r||t[1]!==n?(u=()=>{if(n===a.current)return;let e=a.current;if(a.current=n,!r||e.length===0){l(null),s(n);return}l(e),s(n)},d=[r,n],t[0]=r,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),Q.useEffect(u,d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{l(null)},t[4]=f):f=t[4];let p=G(f),m;t[5]===i?m=t[6]:(m=J(`yuri-summary-flip-viewport relative block h-5 min-h-0 w-full min-w-0 max-w-full overflow-clip sm:h-6`,i),t[5]=i,t[6]=m);let h=c&&`invisible`,g;t[7]===h?g=t[8]:(g=J(`block h-full min-w-0 truncate leading-5 sm:leading-6`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,$.jsx)(`span`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;t[12]!==o||t[13]!==p||t[14]!==c?(v=c?(0,$.jsxs)(`span`,{className:`yuri-summary-flip-stage absolute inset-0 block overflow-clip`,children:[(0,$.jsx)(`span`,{className:`yuri-summary-flip-out absolute inset-x-0 top-0 block h-full truncate`,"aria-hidden":`true`,children:c}),(0,$.jsx)(`span`,{className:`yuri-summary-flip-in absolute inset-x-0 top-0 block h-full truncate`,onAnimationEnd:p,children:o})]}):null,t[12]=o,t[13]=p,t[14]=c,t[15]=v):v=t[15];let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,$.jsxs)(`span`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},_T=[`search`,`read`,`list`];function vT(e){let t=xC(e);return t===`read`?`read`:t===`glob`||t===`grep`?`search`:t===`list`?`list`:null}function yT(e){let t={read:0,search:0,list:0};for(let n of e){let e=vT(n);e&&(t[e]+=1)}return t}var bT=[`edit`,`command`,`other`],xT=new Set([`edit`,`multiedit`,`write`,`create`,`file_write`,`apply_patch`,`patch`]),ST=new Set([`bash`,`shell`,`cmd`,`command`,`exec`,`terminal`]);function CT(e){if(!_C(e))return null;let t=xC(e);return xT.has(t)?`edit`:ST.has(t)?`command`:`other`}function wT(e){let t={edit:0,command:0,other:0};for(let n of e){let e=CT(n);e&&(t[e]+=1)}return t}function TT(e){return WS(e)}var ET=[..._T,...bT];function DT(e){return{...yT(e),...wT(e)}}function OT(e){return bC(e)}function kT(e){return e.kind===`reasoning`||e.type===`reasoning`?!1:e.kind===`justification`||e.type===`text`?!0:e.kind===`tool`||e.type===`tool`?!vC(e.toolName):e.kind!=null||e.type!=null}function AT(e,t,n){for(let r=t;r<e.length;r+=1)if(kT(n(e[r])))return!0;return!1}function jT(e){return`parts`in e?e.parts.some(e=>OT(e))?!0:!e.hasFollowingOtherType&&e.isTurnLive:e.some(e=>OT(e))}function MT(e,t,n){let r=[],i=t;for(;i<e.length&&vC(n(e[i]));)r.push(e[i]),i+=1;return{items:r,end:i}}var NT=`!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal`,PT=e=>{let t=(0,Z.c)(12),{added:n,removed:r}=e;if(n<=0&&r<=0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=J(`inline-flex flex-none items-center gap-0.5 tabular-nums`,NT),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=n>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,n]}):null,t[1]=n,t[2]=a);let o;t[3]!==n||t[4]!==r?(o=n>0&&r>0?(0,$.jsx)(`span`,{style:{color:`var(--tools-description)`},children:`/`}):null,t[3]=n,t[4]=r,t[5]=o):o=t[5];let s;t[6]===r?s=t[7]:(s=r>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,r]}):null,t[6]=r,t[7]=s);let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,$.jsxs)(`span`,{className:i,children:[a,o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c},FT=({activities:e,isMobile:t,isTurnLive:n=!1,hasFollowingOtherType:r=!1,exploring:i,children:a})=>{let{t:o}=na(),[s,c]=Q.useState(!1),l=Q.useId(),u=e.map(e=>e.part),d=i??jT({parts:u,hasFollowingOtherType:r,isTurnLive:n}),f=DT(u.map(e=>e.tool)),p=TT(u),m=ET.filter(e=>f[e]>0).map(e=>{let t=f[e];return o(e===`search`?t===1?`chat.contextGroup.searchSingle`:`chat.contextGroup.searchPlural`:e===`read`?t===1?`chat.contextGroup.readSingle`:`chat.contextGroup.readPlural`:e===`list`?t===1?`chat.contextGroup.listSingle`:`chat.contextGroup.listPlural`:e===`edit`?t===1?`chat.usedGroup.editSingle`:`chat.usedGroup.editPlural`:e===`command`?t===1?`chat.usedGroup.commandSingle`:`chat.usedGroup.commandPlural`:t===1?`chat.usedGroup.otherSingle`:`chat.usedGroup.otherPlural`,{count:t})}).join(`, `),h=G(()=>{c(e=>!e)}),g=G(e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),h())}),_=o(s?`chat.usedGroup.collapseAria`:`chat.usedGroup.expandAria`),v=o(d?`chat.usedGroup.running`:`chat.usedGroup.used`),y=t?`h-5`:`h-6`;return(0,$.jsxs)(`div`,{"data-component":`context-tool-group`,className:fm(t),children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":s,"aria-controls":l,"aria-label":_,"data-mobile-press-feedback":`soft`,className:J(`flex min-h-0 min-w-0 items-center gap-1.5 overflow-clip`,hm),onClick:h,onKeyDown:g,children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center self-center`,y,t?`w-4`:`w-3.5`),style:{color:`var(--tools-icon)`},children:d?(0,$.jsx)(rC,{isMobile:t,label:o(`chat.usedGroup.running`),className:`block`}):(0,$.jsx)(X,{name:`search`,className:`block h-[13px] w-[13px]`})}),(0,$.jsx)(`span`,{className:J(`typography-meta inline-flex flex-none items-center self-center font-medium`,y,NT,d&&`animate-text-shimmer`),style:{color:`var(--tools-title)`,...d?{"--yuri-text-shimmer-base":`var(--tools-title)`}:{}},children:v}),m?(0,$.jsx)(`span`,{className:J(`typography-meta inline-flex min-h-0 w-0 min-w-0 max-w-full flex-1 items-center self-center overflow-clip`,y,NT),style:{color:`var(--tools-description)`},children:(0,$.jsx)(gT,{text:m,active:d,className:t?`!h-5 sm:!h-5`:`!h-6 sm:!h-6`})}):null,(0,$.jsx)(PT,{added:p.added,removed:p.removed}),(0,$.jsx)(X,{name:s?`arrow-down-s`:`arrow-right-s`,className:`ml-auto size-3.5 flex-none self-center text-muted-foreground opacity-70`})]}),s&&a?(0,$.jsxs)(`div`,{id:l,className:pm(t),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0 left-0 top-0 w-px opacity-40`,style:{backgroundColor:`var(--tools-border)`}}),a]}):null]})};function IT(e,t,n){let r=[],i=t;for(;i<e.length&&gC(n(e[i]));)r.push(e[i]),i+=1;return{items:r,end:i}}var LT=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};function RT(e){if(!e||typeof e!=`object`)return null;let t=e.state;if(!t||typeof t!=`object`)return null;let n=t;if(n.metadata&&typeof n.metadata==`object`){let e=LT(n.metadata.name);if(e)return e}if(n.input&&typeof n.input==`object`){let e=n.input,t=LT(e.name);if(t)return t;let r=LT(e.id);if(r)return r}if(n.output&&typeof n.output==`object`){let e=LT(n.output.name);if(e)return e}return null}function zT(e){let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}let n=t.slice(0,3);return{visibleNames:n,hiddenCount:Math.max(0,t.length-n.length),joinedVisible:n.join(`, `)}}var BT=`!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal`,VT=({activities:e,isMobile:t,children:n})=>{let{t:r}=na(),[i,a]=Q.useState(!1),o=Q.useId(),s=e.map(e=>e.part),c=s.some(e=>bC(e)),{joinedVisible:l,hiddenCount:u}=zT(s.map(RT)),d=u>0?r(`chat.skillGroup.summaryOverflow`,{names:l,count:u}):l,f=G(()=>{a(e=>!e)}),p=G(e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())}),m=r(i?`chat.skillGroup.collapseAria`:`chat.skillGroup.expandAria`),h=r(`chat.tools.display.skill`);return(0,$.jsxs)(`div`,{"data-component":`skill-tool-group`,className:fm(t),children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,"aria-controls":o,"aria-label":m,"data-mobile-press-feedback":`soft`,className:J(`flex min-h-0 min-w-0 items-center gap-1.5 overflow-clip`,hm),onClick:f,onKeyDown:p,children:[(0,$.jsx)(`span`,{className:J(`flex flex-none items-center justify-center`,t?`size-4`:`size-3.5`),style:{color:`var(--tools-icon)`},children:c?(0,$.jsx)(rC,{isMobile:t,label:h,className:`block`}):(0,$.jsx)(X,{name:`book`,className:`h-[13px] w-[13px]`})}),(0,$.jsx)(`span`,{className:J(`typography-meta flex-none font-medium`,BT,c&&`animate-text-shimmer`),style:{color:`var(--tools-title)`,...c?{"--yuri-text-shimmer-base":`var(--tools-title)`}:{}},children:h}),d?(0,$.jsx)(`span`,{className:J(`typography-meta h-5 min-h-0 w-0 min-w-0 max-w-full flex-1 overflow-clip sm:h-6`,BT),style:{color:`var(--tools-description)`},children:(0,$.jsx)(gT,{text:d,active:c})}):null,(0,$.jsx)(X,{name:i?`arrow-down-s`:`arrow-right-s`,className:`ml-auto size-3.5 flex-none text-muted-foreground opacity-70`})]}),i&&n?(0,$.jsxs)(`div`,{id:o,className:pm(t),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0 left-0 top-0 w-px opacity-40`,style:{backgroundColor:`var(--tools-border)`}}),n]}):null]})},HT=Q.memo(e=>{let t=(0,Z.c)(18),{part:n,messageId:r,onContentChange:i,actions:a,streamPhase:o,onShowPopup:s}=e,c=ln(UT),l=n,u=typeof l.text==`string`?l.text:``,d=typeof l.content==`string`?l.content:``,f=d.length>u.length?d:u,p=l.time,m=n.sessionID,h=o===void 0||o!==`completed`,g,_;if(t[0]!==i||t[1]!==f?(g=()=>{f.trim().length!==0&&i?.(`structural`)},_=[i,f],t[0]=i,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Q.useEffect(g,_),!f||f.trim().length===0)return null;let v=o??`streaming`,y=h&&typeof p?.end!=`number`,b;t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==s||t[8]!==n||t[9]!==m||t[10]!==v||t[11]!==y?(b=(0,$.jsx)(`div`,{"data-message-text-export-source":`true`,children:(0,$.jsx)(Uw,{part:n,sessionId:m,messageId:r,streamPhase:v,chatRenderMode:c,hasStreamingHapticLifecycle:y,onContentChange:i,onShowPopup:s})}),t[4]=c,t[5]=r,t[6]=i,t[7]=s,t[8]=n,t[9]=m,t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===a?x=t[14]:(x=a?(0,$.jsx)(`div`,{className:`mt-2 mb-1 flex items-center justify-start gap-1.5`,"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,"data-message-action-group":`true`,children:a})}):null,t[13]=a,t[14]=x);let S;return t[15]!==b||t[16]!==x?(S=(0,$.jsxs)(`div`,{"data-message-text-export-root":`true`,children:[b,x]}),t[15]=b,t[16]=x,t[17]=S):S=t[17],S});function UT(e){return e.chatRenderMode}var WT=e=>{let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`},GT=`!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal`,KT=J(`typography-meta font-medium`,GT),qT=J(`typography-meta`,GT),JT=[],YT=e=>{let t=e.part;return t.slim===!0&&(t.type===`tool`||t.type===`reasoning`||t.type===`file`)},XT=e=>{let t=new Set;for(let n of e)YT(n)&&n.messageId&&t.add(n.messageId);return[...t]},ZT=(e,t)=>e.some(e=>{if(!t.has(e.messageId))return!1;let n=e.part;if(n.slim===!0)return!1;if(n.type===`reasoning`)return typeof n.text==`string`&&n.text.trim().length>0;if(n.type===`file`)return typeof n.url==`string`&&n.url.trim().length>0;if(n.type===`tool`){let e=n.state?.output,t=n.state?.error;return(typeof e==`string`?e.trim().length>0:e!=null)||(typeof t==`string`?t.trim().length>0:t!=null)}return!1}),QT=e=>{let t=(0,Z.c)(5),{href:n}=e,[r,i]=Q.useState(!1),a;t[0]===n?a=t[1]:(a=pn(n),t[0]=n,t[1]=a);let o=a;if(!o||r)return null;let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>i(!0),t[2]=s):s=t[2];let c;return t[3]===o?c=t[4]:(c=(0,$.jsx)(`span`,{className:`inline-flex size-[18px] flex-shrink-0 items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)]`,children:(0,$.jsx)(`img`,{src:o,alt:``,"aria-hidden":`true`,loading:`lazy`,decoding:`async`,className:`size-3.5 rounded-sm`,onError:s})}),t[3]=o,t[4]=c),c},$T=e=>e,eE=e=>{let t=e.part.state,n=t?.input,r=t?.metadata,i=n?.filePath||n?.file_path||n?.path||r?.filePath||r?.file_path||r?.path;if(typeof i==`string`&&i.trim().length>0){let e=i.lastIndexOf(`/`);return e>=0?i.slice(e+1):i}return null},tE=e=>{let t=e.part.state,n=t?.input,r=t?.metadata,i=n?.filePath||n?.file_path||n?.path||r?.filePath||r?.file_path||r?.path;return typeof i==`string`&&i.trim().length>0?i:null},nE=e=>{let t=e.part.state?.metadata?.dir;return typeof t==`string`&&t.trim().length>0?t:null},rE=e=>{if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`pending`?`pending`:t===`in_progress`||t===`in progress`||t===`inprogress`?`in_progress`:t===`completed`||t===`done`?`completed`:t===`cancelled`||t===`canceled`?`cancelled`:null},iE=e=>{if(e.length===0)return`0 tasks`;let t=0,n=0;for(let r of e){if(!r||typeof r!=`object`)continue;let e=rE(r.status);e&&(e===`pending`&&(t+=1),e===`in_progress`&&(n+=1))}let r=t+n;return r===0?`0 tasks`:`${r} ${r===1?`task`:`tasks`}`},aE=e=>{let t=e.part.state,n=t?.input,r=t?.output;if(Array.isArray(n?.todos)){let e=iE(n.todos);if(e)return e}if(Array.isArray(r)){let e=iE(r);if(e)return e}if(r&&typeof r==`object`&&Array.isArray(r.todos)){let e=iE(r.todos);if(e)return e}if(typeof r==`string`&&r.trim().length>0)try{let e=JSON.parse(r);if(Array.isArray(e)){let t=iE(e);if(t)return t}if(e&&typeof e==`object`&&Array.isArray(e.todos)){let t=iE(e.todos);if(t)return t}}catch{}return null},oE=e=>{let t=e.part.state,n=t?.input,r=t?.metadata,i=(typeof n?.offset==`number`&&Number.isFinite(n.offset)?n.offset:void 0)??(typeof n?.line==`number`&&Number.isFinite(n.line)?n.line:void 0)??(typeof r?.offset==`number`&&Number.isFinite(r.offset)?r.offset:void 0)??(typeof r?.line==`number`&&Number.isFinite(r.line)?r.line:void 0);if(!(typeof i!=`number`||i<=0))return Math.floor(i)},sE=(e,t=!0)=>{let n=e.lastIndexOf(`/`);if(n===-1)return(0,$.jsx)(Ib,{variant:t?`generate-effect`:`static`,className:J(`min-w-0 flex-1 truncate whitespace-nowrap`,qT),style:{color:`var(--tools-description)`},title:e,children:e});let r=e.slice(0,n),i=e.slice(n+1),a=r.startsWith(`/`),o=a?r.slice(1):r;return(0,$.jsxs)(`span`,{className:J(`min-w-0 inline-flex max-w-full flex-1 items-baseline overflow-hidden`,qT),title:e,children:[a?(0,$.jsx)(`span`,{className:`flex-shrink-0`,style:{color:`var(--tools-description)`},children:`/`}):null,(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate whitespace-nowrap`,style:{color:`var(--tools-description)`,direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},children:o}),(0,$.jsx)(`span`,{className:`flex-shrink-0`,style:{color:`var(--tools-description)`},children:`/`}),(0,$.jsx)(Ib,{variant:t?`generate-effect`:`static`,className:`flex-shrink-0`,style:{color:`var(--tools-description)`},children:i})]})},cE=e=>{let t=Gt(e);return t?t.toLowerCase().endsWith(`/skill.md`)?t:`${t}/SKILL.md`:``},lE=e=>{let t=e.part,n=t.tool?.toLowerCase()??``,r=t.state,i=r?.input,a=r?.metadata;if(n===`grep`||n===`search`||n===`find`||n===`ripgrep`){let e=i?.pattern;if(typeof e==`string`&&e.trim().length>0)return e.length>40?e.slice(0,40)+`...`:e}if(n===`glob`){let e=i?.pattern;if(typeof e==`string`&&e.trim().length>0)return e.length>40?e.slice(0,40)+`...`:e}if(n===`websearch`||n===`web-search`||n===`search_web`||n===`codesearch`||n===`perplexity`){let e=i?.query;if(typeof e==`string`&&e.trim().length>0)return e.length>50?e.slice(0,50)+`...`:e}if(n===`skill`)return RT(t);if(n===`webfetch`||n===`fetch`||n===`curl`||n===`wget`){let e=typeof i?.url==`string`&&i.url||typeof i?.URL==`string`&&i.URL||typeof a?.url==`string`&&a.url||typeof a?.URL==`string`&&a.URL||``;if(typeof e==`string`&&e.trim().length>0)return e.trim()}return n===`todowrite`||n===`todoread`?aE(e):eE(e)},uE=e=>{let t=new Set,n=new Set;for(let r of e){if(r.kind!==`tool`)continue;let e=r.part;if(!Zb(e.tool))continue;let i=typeof e.id==`string`?e.id.trim():``;if(!i)continue;let a=e.state;if(!a||typeof a!=`object`)continue;let o=a,s=ax(e)||i;n.add(s),(o.status===`pending`||o.status===`running`)&&t.add(s)}return{active:[...t],all:[...n]}},dE=Q.memo(e=>{let t=(0,Z.c)(16),{activity:n,isExpanded:r,isMobile:i,onToggleTool:a,onShowPopup:o,onContentChange:s}=e,c;t[0]!==n.id||t[1]!==a?(c=()=>{a(n.id)},t[0]=n.id,t[1]=a,t[2]=c):c=t[2];let l=G(c),u;t[3]===i?u=t[4]:(u=fm(i),t[3]=i,t[4]=u);let d=n.part,f;t[5]!==n.messageId||t[6]!==l||t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o||t[11]!==d?(f=(0,$.jsx)(kw,{part:d,messageId:n.messageId,isExpanded:r,onToggle:l,isMobile:i,onContentChange:s,onShowPopup:o,animateTailText:!1}),t[5]=n.messageId,t[6]=l,t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==u||t[14]!==f?(p=(0,$.jsx)(`div`,{className:u,children:f}),t[13]=u,t[14]=f,t[15]=p):p=t[15],p},(e,t)=>e.isExpanded===t.isExpanded&&e.isMobile===t.isMobile&&e.onToggleTool===t.onToggleTool&&e.onShowPopup===t.onShowPopup&&e.onContentChange===t.onContentChange&&e.activity.id===t.activity.id&&e.activity.messageId===t.activity.messageId&&e.activity.kind===t.activity.kind&&e.activity.endedAt===t.activity.endedAt&&eS([e.activity.part],[t.activity.part])),fE=Q.memo(e=>{let t=(0,Z.c)(9),{toolName:n,activities:r,isMobile:i}=e,a;t[0]===i?a=t[1]:(a=fm(i),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=(0,$.jsx)(hE,{toolName:n,activities:r,isMobile:i,animateTailText:!1}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{className:a,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s},(e,t)=>e.toolName===t.toolName&&e.isMobile===t.isMobile&&mE(e.activities,t.activities)),pE=e=>{let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.kind===`reasoning`){if(!xd(r.part).trim()){n++;continue}t.push({type:`reasoning`,activity:r}),n++;continue}if(r.kind===`justification`){t.push({type:`justification`,activity:r}),n++;continue}let i=r.part.tool?.toLowerCase()??``;if(vC(i)){let r=MT(e,n,e=>e.part.tool);t.push({type:`tool-context-group`,activities:r.items,hasFollowingOtherType:AT(e,r.end,e=>({kind:e.kind,toolName:e.part.tool}))}),n=r.end;continue}if(gC(i)){let r=IT(e,n,e=>e.part.tool);if(r.items.length>0){t.push({type:`tool-skill-group`,activities:r.items}),n=r.end;continue}}if(pC(i)){t.push({type:`tool-expandable`,activity:r}),n++;continue}if(fC(i)){t.push({type:`tool-expandable`,activity:r}),n++;continue}if(mC(i)){t.push({type:`tool-static-group`,toolName:i,activities:[r]}),n++;continue}t.push({type:`tool-fallback`,activity:r}),n++}return t},mE=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.id!==i.id||r.kind!==i.kind||r.endedAt!==i.endedAt||!eS([r.part],[i.part]))return!1}return!0},hE=Q.memo(e=>{let t=(0,Z.c)(108),{toolName:n,activities:r,isMobile:i,animateTailText:a}=e,{t:o}=na(),s=ln(yE),c=oa(n,o),l;t[0]===n?l=t[1]:(l=Bb(n),t[0]=n,t[1]=l);let u=l,d;t[2]===n?d=t[3]:(d=n.toLowerCase(),t[2]=n,t[3]=d);let f=d===`read`,p=Q.useContext(Wt),m=Rt(),h=m?.entry.location.hostId?m.entry:void 0,g=ga(),_=qe(bE),v=Xo(),y=v.kind===`embedded`?v.directory:_,b;t[4]===n?b=t[5]:(b=n.toLowerCase(),t[4]=n,t[5]=b);let x=b===`skill`,S;t[6]===x?S=t[7]:(S={enabled:x},t[6]=x,t[7]=S);let C=En(S),w;t[8]===C.data?w=t[9]:(w=C.data??[],t[8]=C.data,t[9]=w);let T=w,E;t[10]===T?E=t[11]:(E=new Map(T.map(xE)),t[10]=T,t[11]=E);let D=E,O=r[0]??null,k=!O||bC(O.part),A;t[12]===O?A=t[13]:(A=O?lE(O):null,t[12]=O,t[13]=A);let j=A,M;if(t[14]!==j||t[15]!==O||t[16]!==D||t[17]!==n){bb0:{if(n.toLowerCase()!==`skill`||!O||!j){M=null;break bb0}let e=D.get(j)?.path||nE(O);if(!e||e===`<built-in>`){M=null;break bb0}let r=cE(e);if(!r){M=null;break bb0}let i;t[19]!==j||t[20]!==r?(i={name:j,path:r},t[19]=j,t[20]=r,t[21]=i):i=t[21],M=i}t[14]=j,t[15]=O,t[16]=D,t[17]=n,t[18]=M}else M=t[18];let N=M,P;if(t[22]!==y||t[23]!==f||t[24]!==O){bb1:{if(!f||!O){P=null;break bb1}let e=tE(O);if(!e){P=null;break bb1}let n=qt(e,y);if(!n){P=null;break bb1}let r;t[26]===O?r=t[27]:(r=oE(O),t[26]=O,t[27]=r);let i;t[28]!==n||t[29]!==e||t[30]!==r?(i={path:e,displayPath:n,offset:r},t[28]=n,t[29]=e,t[30]=r,t[31]=i):i=t[31],P=i}t[22]=y,t[23]=f,t[24]=O,t[25]=P}else P=t[25];let F=P,I;t[32]!==y||t[33]!==h||t[34]!==g||t[35]!==p?(I=(e,t)=>{if(!y)return;let n=Jt(y,e);if(!n)return;if(g){g.openFile({path:n,targetLine:t&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):void 0});return}if(!h&&p?.editor){p.editor.openFile(n,t);return}if(!h&&!Kt(n,y)){ic(n,y).then(()=>{let e=ln.getState(),r=y||Yt(y,n);if(t&&Number.isFinite(t)){e.openContextFileAtLine(r,n,Math.max(1,Math.trunc(t)),1);return}e.openContextFile(r,n)});return}let r=ln.getState(),i=h?.key??Yt(y,n);if(t&&Number.isFinite(t)){r.openContextFileAtLine(i,n,Math.max(1,Math.trunc(t)),1);return}r.openContextFile(i,n)},t[32]=y,t[33]=h,t[34]=g,t[35]=p,t[36]=I):I=t[36];let L=G(I),R;t[37]!==y||t[38]!==h||t[39]!==g?(R=e=>{let t=Gt(e);if(!t)return;let n=()=>{if(g){g.openFile({path:t});return}let e=ln.getState(),n=h?.key??(y||Yt(``,t));e.openContextFile(n,t)};if(!h&&y&&!Kt(t,y)){ic(t,y).then(n);return}n()},t[37]=y,t[38]=h,t[39]=g,t[40]=R):R=t[40];let ee=G(R),z;t[41]===n?z=t[42]:(z=n.toLowerCase(),t[41]=n,t[42]=z);let B=z,V=B===`grep`||B===`search`||B===`find`||B===`ripgrep`||B===`glob`,H=B===`webfetch`||B===`fetch`||B===`curl`||B===`wget`,U=B===`skill`,te=!!(F||N),ne=!!(F&&y||N),re;t[43]!==ne||t[44]!==L||t[45]!==ee||t[46]!==te||t[47]!==F||t[48]!==N?(re=()=>{if(!(!te||!ne)){if(F){L(F.path,F.offset);return}N&&ee(N.path)}},t[43]=ne,t[44]=L,t[45]=ee,t[46]=te,t[47]=F,t[48]=N,t[49]=re):re=t[49];let W=G(re),ie;t[50]===W?ie=t[51]:(ie=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),W())},t[50]=W,t[51]=ie);let ae=G(ie),oe=te&&ne&&`cursor-pointer`,se=te&&!ne&&`cursor-default opacity-70`,ce;t[52]!==oe||t[53]!==se?(ce=J(`flex w-full items-center gap-x-1.5 min-w-0`,hm,oe,se),t[52]=oe,t[53]=se,t[54]=ce):ce=t[54];let le=te?`soft`:void 0,ue=te?W:void 0,de=te?ae:void 0,fe=te?`button`:void 0,pe=te&&ne?0:void 0,me=te&&!ne?!0:void 0,he=i?`size-4`:`size-3.5`,ge;t[55]===he?ge=t[56]:(ge=J(`inline-flex items-center justify-center flex-shrink-0`,he),t[55]=he,t[56]=ge);let _e;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(_e={color:`var(--tools-icon)`},t[57]=_e):_e=t[57];let ve=k?(0,$.jsx)(rC,{isMobile:i,label:o(`chat.assistantStatus.usingTool`,{tool:c})}):u,ye;t[58]!==ge||t[59]!==_e||t[60]!==ve?(ye=(0,$.jsx)(`div`,{className:ge,style:_e,children:ve}),t[58]=ge,t[59]=_e,t[60]=ve,t[61]=ye):ye=t[61];let be,xe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(be=J(KT,`inline-flex items-center flex-shrink-0 opacity-85`),xe={color:`var(--tools-title)`},t[62]=be,t[63]=xe):(be=t[62],xe=t[63]);let Se;t[64]===c?Se=t[65]:(Se=(0,$.jsx)(`span`,{className:be,style:xe,title:c,children:c}),t[64]=c,t[65]=Se);let Ce;t[66]!==a||t[67]!==f||t[68]!==F||t[69]!==s?(Ce=f&&F?(0,$.jsxs)(`span`,{className:J(`inline-flex !min-h-0 items-center justify-start gap-1 min-w-0 flex-1 text-left`,qT),style:{color:`var(--tools-description)`},title:F.offset?`${F.displayPath}:${F.offset}`:F.displayPath,children:[s?(0,$.jsx)(ja,{filePath:F.path,className:`h-3.5 w-3.5`}):null,sE(F.displayPath,a)]}):null,t[66]=a,t[67]=f,t[68]=F,t[69]=s,t[70]=Ce):Ce=t[70];let we;t[71]!==a||t[72]!==j||t[73]!==V?(we=V&&j?(0,$.jsx)(`span`,{className:`inline-flex min-w-0 flex-1`,children:(0,$.jsxs)(Ib,{variant:a?`generate-effect`:`static`,className:J(`min-w-0 flex-1 truncate whitespace-nowrap`,qT),style:{color:`var(--tools-description)`},title:j,children:[`"`,j,`"`]})}):null,t[71]=a,t[72]=j,t[73]=V,t[74]=we):we=t[74];let Te;t[75]!==j||t[76]!==H?(Te=H&&j?(0,$.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,onClick:SE,className:J(`min-w-0 flex-1 inline-flex items-center gap-1.5 underline decoration-[color:var(--status-info)] underline-offset-2 hover:opacity-90`,`truncate whitespace-nowrap`,qT),style:{color:`var(--status-info)`},title:j,children:[(0,$.jsx)(QT,{href:j}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:j})]}):null,t[75]=j,t[76]=H,t[77]=Te):Te=t[77];let Ee;t[78]!==U||t[79]!==N?(Ee=U&&N?(0,$.jsx)(`span`,{className:J(`!min-h-0 min-w-0 flex-1 truncate whitespace-nowrap text-left`,qT),style:{color:`var(--tools-description)`},title:N.path,children:N.name}):null,t[78]=U,t[79]=N,t[80]=Ee):Ee=t[80];let De;t[81]!==j||t[82]!==U||t[83]!==N?(De=U&&!N&&j?(0,$.jsx)(`span`,{className:J(`!min-h-0 min-w-0 flex-1 truncate whitespace-nowrap text-left`,qT),style:{color:`var(--tools-description)`},title:j,children:j}):null,t[81]=j,t[82]=U,t[83]=N,t[84]=De):De=t[84];let Oe;t[85]!==a||t[86]!==j||t[87]!==H||t[88]!==f||t[89]!==V||t[90]!==U?(Oe=!f&&!V&&!H&&!U&&j?(0,$.jsx)(Ib,{variant:a?`generate-effect`:`static`,className:J(`min-w-0 flex-1 truncate whitespace-nowrap`,qT),style:{color:`var(--tools-description)`},children:j}):null,t[85]=a,t[86]=j,t[87]=H,t[88]=f,t[89]=V,t[90]=U,t[91]=Oe):Oe=t[91];let ke;return t[92]!==ce||t[93]!==le||t[94]!==ue||t[95]!==de||t[96]!==fe||t[97]!==pe||t[98]!==me||t[99]!==ye||t[100]!==Se||t[101]!==Ce||t[102]!==we||t[103]!==Te||t[104]!==Ee||t[105]!==De||t[106]!==Oe?(ke=(0,$.jsxs)(`div`,{className:ce,"data-mobile-press-feedback":le,onClick:ue,onKeyDown:de,role:fe,tabIndex:pe,"aria-disabled":me,children:[ye,Se,Ce,we,Te,Ee,De,Oe]}),t[92]=ce,t[93]=le,t[94]=ue,t[95]=de,t[96]=fe,t[97]=pe,t[98]=me,t[99]=ye,t[100]=Se,t[101]=Ce,t[102]=we,t[103]=Te,t[104]=Ee,t[105]=De,t[106]=Oe,t[107]=ke):ke=t[107],ke},(e,t)=>e.toolName===t.toolName&&e.isMobile===t.isMobile&&e.animateTailText===t.animateTailText&&mE(e.activities,t.activities)),gE=Q.memo(e=>{let t=(0,Z.c)(5),{activity:n,onContentChange:r,streamPhase:i}=e,a;return t[0]!==n.messageId||t[1]!==n.part||t[2]!==r||t[3]!==i?(a=(0,$.jsx)(tT,{part:n.part,messageId:n.messageId,streamPhase:i,onContentChange:r}),t[0]=n.messageId,t[1]=n.part,t[2]=r,t[3]=i,t[4]=a):a=t[4],a}),_E=Q.memo(e=>{let t=(0,Z.c)(7),{activity:n,onContentChange:r,onShowPopup:i,actions:a,streamPhase:o}=e,s;return t[0]!==a||t[1]!==n.messageId||t[2]!==n.part||t[3]!==r||t[4]!==i||t[5]!==o?(s=(0,$.jsx)(HT,{part:n.part,messageId:n.messageId,onContentChange:r,onShowPopup:i,actions:a,streamPhase:o}),t[0]=a,t[1]=n.messageId,t[2]=n.part,t[3]=r,t[4]=i,t[5]=o,t[6]=s):s=t[6],s}),vE=Q.memo(({parts:e,materializationParts:t=e,isExpanded:n,collapsedPreviewCount:r=0,completionDisposition:i,activityPresentationKind:a=`default`,durationMs:o,onToggle:s,isMobile:c,expandedTools:l,onToggleTool:u,onShowPopup:d,onContentChange:f,streamPhase:p,showHeader:h,renderJustificationActions:g})=>{let{t:_}=na(),v=Ga()??``,y=Q.useMemo(()=>XT(t),[t]),b=Q.useRef(new Set),x=Q.useRef(new Map),S=Q.useRef(new Set),[,C]=Q.useState(0),w=Q.useRef(null),T=Q.useRef(null),E=i===`active`,D=!E&&(i===`normal`||i===`abnormal`)&&typeof o==`number`&&Number.isFinite(o)&&o>=0?WT(o):null,O=i===`normal`||i===`abnormal`,k=a===`compaction`,A=O&&!k,j=k?`fold-vertical`:`stack`,M=_(i===void 0?`chat.activity.title`:E?k?`chat.activity.compacting`:`chat.activity.active`:O?k?`chat.activity.compactionCompleted`:`chat.activity.completedStatus`:`chat.activity.title`),N=Q.useMemo(()=>{let t=[];for(let n of e)n.kind===`tool`&&t.push(n.part);return WS(t)},[e]),F=N.added>0||N.removed>0,I=Q.useMemo(()=>uE(e),[e]),L=E?I.active:I.all,R=L.slice(0,c?2:3),ee=G((e=!1,n=!1)=>{if(!(!v||!y.length)){for(let r of y){let i=t.find(e=>e.messageId===r)?.part.sessionID;if(!i)continue;let a=P(v,i,r);if(a.status===`ready`||n&&a.status===`error`||e&&a.status!==`error`&&!S.current.has(r)||(b.current.add(r),S.current.delete(r),x.current.has(r)))continue;let o=m(v,i,r,{priority:n?`background`:`user`}).catch(()=>{S.current.add(r)}).finally(()=>{x.current.delete(r),C(e=>e+1)});x.current.set(r,o)}C(e=>e+1)}}),z=G(e=>{e.stopPropagation(),ee(!0)}),B=E,V=B||n,H=G(()=>{if(B)return;let e=w.current;T.current=e?{top:e.getBoundingClientRect().top,scrollContainer:e.closest(`[data-scrollbar="chat"]`)}:null,V||ee(),s()});Q.useEffect(()=>{E||!V||ee(!1,!0)},[E,V]),Q.useLayoutEffect(()=>{let e=T.current,t=w.current;if(!e||!t)return;let n=()=>{if(!t.isConnected)return;let n=t.getBoundingClientRect().top-e.top;if(!(Math.abs(n)<.5)){if(e.scrollContainer?.isConnected){e.scrollContainer.scrollTop+=n;return}window.scrollBy(0,n)}};if(n(),typeof window>`u`||typeof window.requestAnimationFrame!=`function`){T.current=null;return}let r=window.requestAnimationFrame(()=>{n(),T.current=null});return()=>window.cancelAnimationFrame(r)},[V]);let U=h&&!V?Math.max(0,Math.floor(r)):0,te=!h||V||U>0,ne=b.current,re=[...ne].map(e=>{if(x.current.has(e))return`loading`;if(S.current.has(e))return`error`;let n=t.find(t=>t.messageId===e)?.part.sessionID??``;return P(v,n,e).status}),W=re.includes(`loading`),ie=re.includes(`error`),ae=re.length>0&&re.every(e=>e===`ready`),oe=t.some(e=>ne.has(e.messageId)&&YT(e)),se=ae&&!oe&&!ZT(t,ne),ce=Q.useMemo(()=>te?$T(e):JT,[e,te]),le=Q.useMemo(()=>te?pE(ce.filter(e=>e.kind!==`reasoning`||xd(e.part).trim().length>0)):[],[te,ce]),ue=Q.useMemo(()=>V||U===0?0:Math.max(0,le.length-U),[V,U,le.length]),de=Q.useMemo(()=>V||U===0?le:le.slice(-U),[V,U,le]),fe=!!h&&!(E&&!k);if((!fe||B&&!k)&&le.length===0)return null;let pe=(e,t)=>{let n=(0,$.jsx)(`div`,{className:fm(c),children:t});return(0,$.jsx)(Q.Fragment,{children:n},e)},me=te?de.map((e,t)=>{switch(e.type){case`reasoning`:return pe(e.activity.id,(0,$.jsx)($.Fragment,{children:(0,$.jsx)(gE,{activity:e.activity,streamPhase:p,onContentChange:f})}));case`justification`:return pe(e.activity.id,(0,$.jsx)($.Fragment,{children:(0,$.jsx)(_E,{activity:e.activity,onContentChange:f,onShowPopup:d,actions:g?.(e.activity),streamPhase:p})}));case`tool-expandable`:return(0,$.jsx)(dE,{activity:e.activity,isExpanded:l.has(e.activity.id),isMobile:c,onToggleTool:u,onShowPopup:d,onContentChange:f},e.activity.id);case`tool-static-group`:return(0,$.jsx)(fE,{toolName:e.toolName,activities:e.activities,isMobile:c},e.activities[0]?.id??`static-${e.toolName}-${t}`);case`tool-context-group`:return(0,$.jsx)(FT,{activities:e.activities,isMobile:c,isTurnLive:E,hasFollowingOtherType:e.hasFollowingOtherType,children:e.activities.map(e=>{let t=e.part,n=t.tool?.toLowerCase()??``;return hC(n)?(0,$.jsx)(hE,{toolName:n,activities:[e],isMobile:c,animateTailText:!1},e.id):(0,$.jsx)(kw,{part:t,messageId:e.messageId,isExpanded:l.has(e.id),onToggle:u,isMobile:c,onContentChange:f,onShowPopup:d,animateTailText:!1},e.id)})},e.activities[0]?.id??`context-${t}`);case`tool-skill-group`:return(0,$.jsx)(VT,{activities:e.activities,isMobile:c,children:e.activities.map(e=>{let t=e.part;return(0,$.jsx)(hE,{toolName:t.tool?.toLowerCase()??``,activities:[e],isMobile:c,animateTailText:!1},e.id)})},e.activities[0]?.id??`skill-${t}`);case`tool-fallback`:return(0,$.jsx)(dE,{activity:e.activity,isExpanded:l.has(e.activity.id),isMobile:c,onToggleTool:u,onShowPopup:d,onContentChange:f},e.activity.id);default:return null}}):null,he=de.length>0;return(0,$.jsxs)(`div`,{className:fe?fm(c):`flow-root`,children:[fe?(0,$.jsxs)(`button`,{ref:w,type:`button`,className:J(`group/tool flex w-[calc(100%+1rem)] min-w-0 flex-nowrap items-center text-left`,c?`gap-x-1`:`gap-x-2`,!B&&hm,B&&`yuri-tool-row -mx-2 rounded-lg px-2 py-0.5 cursor-default`,c&&(A?`pr-2`:`pr-0`)),"data-mobile-press-feedback":B?void 0:`soft`,onClick:B?void 0:H,"aria-expanded":V,"aria-disabled":B||void 0,"aria-label":B?M:_(V?`chat.activity.collapseAria`:`chat.activity.expandAria`),children:[(0,$.jsx)(`span`,{className:J(`inline-flex min-w-0 items-center overflow-clip`,c?`gap-x-1`:`gap-x-1.5`),children:A?(0,$.jsxs)(`span`,{className:J(`typography-meta inline-flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground`,c?`h-5`:`h-6`),children:[D?_(`chat.activity.completed`,{duration:D}):M,(0,$.jsx)(X,{name:V?`arrow-down-s`:`arrow-right-s`,className:`size-3.5 shrink-0 opacity-70`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center`,c?`h-5 w-4`:`h-6 w-3.5`),style:{color:`var(--tools-icon)`},children:E&&!k?(0,$.jsx)(rC,{isMobile:c,label:M,className:`block`}):(0,$.jsx)(X,{name:j,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:J(`inline-flex flex-shrink-0 items-center`,c?`typography-meta h-5`:`typography-ui-label h-5 font-semibold`,E?`animate-text-shimmer text-[var(--status-info)] [--yuri-text-shimmer-base:var(--status-info)]`:`text-foreground/85`),children:M}),D?(0,$.jsx)(`span`,{className:`typography-meta shrink-0 tabular-nums text-muted-foreground`,children:D}):null]})}),(0,$.jsxs)(`span`,{className:J(`ml-auto inline-flex max-w-[min(14rem,55%)] shrink-0 items-center`,c?`gap-0.5`:`gap-1`),children:[L.length>0?(0,$.jsxs)(`span`,{className:J(`inline-flex min-w-0 items-center text-muted-foreground`,c?`gap-1`:`gap-1.5`),children:[(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5`,"aria-hidden":`true`,children:R.map((e,t)=>(0,$.jsx)(cs,{name:e,size:c?12:14,className:J(`flex-none`,c?`size-3 min-h-3 min-w-3 max-h-3 max-w-3`:`size-3.5 min-h-3.5 min-w-3.5 max-h-3.5 max-w-3.5`)},`${e}-${t}`))}),(0,$.jsx)(`span`,{className:`typography-meta min-w-0 truncate`,children:_(E?`chat.activity.agentsWorking`:`chat.activity.agentsInvolved`,{count:L.length})})]}):null,F?(0,$.jsx)(`span`,{"data-activity-diff-totals":``,className:`inline-flex shrink-0`,children:(0,$.jsx)(PT,{added:N.added,removed:N.removed})}):null,!B&&!A?(0,$.jsx)(X,{name:V?`arrow-down-s`:`arrow-right-s`,className:J(`flex-shrink-0 text-muted-foreground opacity-70`,c&&`-mr-0.5`,c?`size-3`:`size-3.5`)}):null]})]}):null,he?(0,$.jsxs)(`div`,{children:[ue>0?(0,$.jsxs)(`button`,{type:`button`,onClick:H,className:`typography-meta leading-4 px-2 py-1 text-muted-foreground/45 hover:text-muted-foreground/65 text-left`,children:[`+`,ue,` more...`]}):null,(0,$.jsx)(`div`,{className:`flow-root`,children:me})]}):null,V&&(W||ie||se)?(0,$.jsx)(`div`,{className:J(`typography-meta flex min-h-9 items-center gap-2 px-2 text-muted-foreground`,ie&&`text-[var(--status-error)]`),role:ie?`alert`:`status`,children:W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{children:_(`chat.activity.outputLoading`)})]}):ie?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`error-warning`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:_(`chat.activity.outputLoadFailed`)}),(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`xs`,onClick:z,children:_(`chat.activity.outputRetry`)})]}):(0,$.jsx)(`span`,{children:_(`chat.toolOutputDialog.noOutputProduced`)})}):null]})});function yE(e){return e.showToolFileIcons}function bE(e){return e.currentDirectory}function xE(e){return[e.name,e]}function SE(e){e.stopPropagation()}var CE=Q.memo(e=>{let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(vE,{...e}),t[0]=e,t[1]=n),n});function wE(e){let t=(0,Z.c)(9),{presentation:n,sessionId:r,messageId:i,directory:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={bootstrap:!1},t[0]=o):o=t[0];let s=hr(a,o),c;t[1]===r?c=t[2]:(c=e=>!!e.session_execution_recovery[r],t[1]=r,t[2]=c);let l=we(s,c),u;t[3]===r?u=t[4]:(u=e=>e.session_status[r]?.type===`retry`,t[3]=r,t[4]=u);let d=we(s,u),f=qr(r,a);if(!l&&!d){let e;return t[5]===n?e=t[6]:(e=(0,$.jsx)(am,{presentation:n}),t[5]=n,t[6]=e),e}let p;for(let e=f.length-1;e>=0;--e)if(f[e].role===`assistant`){p=f[e].id;break}if(p===i&&(d||l&&n.detail===`aborted`&&n.icon===`pause-circle`))return null;let m;return t[7]===n?m=t[8]:(m=(0,$.jsx)(am,{presentation:n}),t[7]=n,t[8]=m),m}function TE(e){let t=(0,Z.c)(5),n=Xo();if(!e.sessionId||!n.active||!n.capabilities.compose){let n;return t[0]===e.presentation?n=t[1]:(n=(0,$.jsx)(am,{presentation:e.presentation}),t[0]=e.presentation,t[1]=n),n}let r=n.directory??e.directory,i;return t[2]!==e||t[3]!==r?(i=(0,$.jsx)(wE,{...e,sessionId:e.sessionId,directory:r}),t[2]=e,t[3]=r,t[4]=i):i=t[4],i}var EE={contain:`layout`},DE=`mt-1.5 mb-0.5 flex items-center justify-start gap-1.5`,OE=`mt-3 mb-0.5 flex items-center justify-start gap-1.5`,kE=e=>e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1)??e,AE=`w-full min-w-0 justify-start rounded-[var(--radius-md)] bg-transparent px-1 hover:!bg-interactive-hover focus-visible:!bg-interactive-hover active:!bg-interactive-active supports-[corner-shape:squircle]:rounded-[var(--radius-md)]`,jE=`h-7 gap-1.5`,ME=`h-6 gap-1`,NE=`text-[11px] leading-none`,PE=`size-3.5`,FE=`size-3`,IE=5,LE=Q.memo(e=>{let t=(0,Z.c)(30),{file:n,isMobile:r}=e,i=r?`gap-1 text-[11px]`:`gap-1.5 text-xs`,a;t[0]===i?a=t[1]:(a=J(`flex min-w-0 flex-1 items-center leading-none text-muted-foreground`,i),t[0]=i,t[1]=a);let o=n.file,s=r?`h-3 w-3`:`h-3.5 w-3.5`,c;t[2]===s?c=t[3]:(c=J(`flex-shrink-0`,s),t[2]=s,t[3]=c);let l;t[4]!==n.file||t[5]!==c?(l=(0,$.jsx)(ja,{filePath:o,className:c}),t[4]=n.file,t[5]=c,t[6]=l):l=t[6];let u=n.file,d;t[7]===n.file?d=t[8]:(d=kE(n.file),t[7]=n.file,t[8]=d);let f;t[9]!==n.file||t[10]!==d?(f=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-foreground/80`,title:u,children:d}),t[9]=n.file,t[10]=d,t[11]=f):f=t[11];let p=r?`text-[11px]`:`typography-meta`,m;t[12]===p?m=t[13]:(m=J(`inline-flex flex-shrink-0 items-center gap-0 leading-none tabular-nums`,p),t[12]=p,t[13]=m);let h;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h={color:`var(--status-success)`},t[14]=h):h=t[14];let g;t[15]===n.additions?g=t[16]:(g=(0,$.jsxs)(`span`,{style:h,children:[`+`,n.additions]}),t[15]=n.additions,t[16]=g);let _,v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:`/`}),v={color:`var(--status-error)`},t[17]=_,t[18]=v):(_=t[17],v=t[18]);let y;t[19]===n.deletions?y=t[20]:(y=(0,$.jsxs)(`span`,{style:v,children:[`-`,n.deletions]}),t[19]=n.deletions,t[20]=y);let b;t[21]!==m||t[22]!==g||t[23]!==y?(b=(0,$.jsxs)(`span`,{className:m,children:[g,_,y]}),t[21]=m,t[22]=g,t[23]=y,t[24]=b):b=t[24];let x;return t[25]!==b||t[26]!==a||t[27]!==l||t[28]!==f?(x=(0,$.jsxs)(`span`,{className:a,children:[l,f,b]}),t[25]=b,t[26]=a,t[27]=l,t[28]=f,t[29]=x):x=t[29],x}),RE=Q.memo(e=>{let t=(0,Z.c)(18),{file:n,canOpen:r,isMobile:i,onOpen:a}=e,{t:o}=na(),s;t[0]!==n.file||t[1]!==a?(s=()=>{a(n.file)},t[0]=n.file,t[1]=a,t[2]=s):s=t[2];let c=G(s),l=!r,u=i?ME:jE,d;t[3]===u?d=t[4]:(d=J(AE,u),t[3]=u,t[4]=d);let f;t[5]!==n.file||t[6]!==o?(f=o(`chat.changedFiles.actions.openFileTitle`,{path:n.file}),t[5]=n.file,t[6]=o,t[7]=f):f=t[7];let p;t[8]!==n||t[9]!==i?(p=(0,$.jsx)(LE,{file:n,isMobile:i}),t[8]=n,t[9]=i,t[10]=p):p=t[10];let m;return t[11]!==n.file||t[12]!==c||t[13]!==l||t[14]!==d||t[15]!==f||t[16]!==p?(m=(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`xs`,disabled:l,"data-turn-change-file":`true`,className:d,"aria-label":f,title:n.file,onClick:c,children:p}),t[11]=n.file,t[12]=c,t[13]=l,t[14]=d,t[15]=f,t[16]=p,t[17]=m):m=t[17],m}),zE=Q.memo(e=>{let t=(0,Z.c)(55),{fileCount:n,changedFiles:r,turnId:i,isLatestTurn:a,isMobile:o}=e,{t:s}=na(),c=Ga(),l=Rt(),u=l?.entry.location.hostId?l.entry:void 0,d=Xo(),f=d.directory||c,p=d.sessionId,m=ga(),h=ln(XE),g;t[0]===r?g=t[1]:(g=r??[],t[0]=r,t[1]=g);let _=g,v;t[2]===_?v=t[3]:(v=_.slice(0,IE),t[2]=_,t[3]=v);let y=v,b=Math.max(0,_.length-y.length),x=_.length>0?_.length:n,S=!!(m||!o&&f||o&&a),C;t[4]!==x||t[5]!==s?(C=s(x===1?`chat.pendingChanges.fileCountSingle`:`chat.pendingChanges.fileCountPlural`,{count:x}),t[4]=x,t[5]=s,t[6]=C):C=t[6];let w=C,T;t[7]!==b||t[8]!==s?(T=s(b===1?`chat.pendingChanges.fileCountSingle`:`chat.pendingChanges.fileCountPlural`,{count:b}),t[7]=b,t[8]=s,t[9]=T):T=t[9];let E=T,D=J(AE,o?ME:jE),O=o?FE:PE,k;t[10]===o?k=t[11]:(k=o?J(NE,`font-semibold text-foreground/85`):`typography-meta font-semibold text-foreground/85`,t[10]=o,t[11]=k);let A=k,j;t[12]===o?j=t[13]:(j=o?J(NE,`text-muted-foreground`):`typography-meta text-muted-foreground`,t[12]=o,t[13]=j);let M=j,N;t[14]===o?N=t[15]:(N=o?J(NE,`font-medium`):`typography-meta font-medium`,t[14]=o,t[15]=N);let P=N,F;t[16]!==f||t[17]!==p||t[18]!==u||t[19]!==a||t[20]!==o||t[21]!==m||t[22]!==i?(F=e=>{if(m){m.openTurnDiff(i,p,e);return}if(!o&&f){iT({scope:u,directory:f,filePath:e,turnMessageId:i,sessionId:p});return}o&&a&&f&&iT({scope:u,directory:f,filePath:e,turnMessageId:i,sessionId:p,mobile:!0})},t[16]=f,t[17]=p,t[18]=u,t[19]=a,t[20]=o,t[21]=m,t[22]=i,t[23]=F):F=t[23];let I=G(F),L;t[24]!==f||t[25]!==p||t[26]!==u||t[27]!==a||t[28]!==o||t[29]!==m||t[30]!==h||t[31]!==i||t[32]!==y[0]?.file?(L=()=>{if(m){m.openTurnDiff(i,p);return}if(!o&&f){h(u?.key??f,{mode:`diff`,dedupeKey:`turn-diff:${p||`session`}:${i}`,targetPath:null,diffScope:`turn`,diffTurnMessageId:i,diffSessionId:p});return}let e=y[0]?.file;e&&o&&a&&f&&iT({scope:u,directory:f,filePath:e,turnMessageId:i,sessionId:p,mobile:!0})},t[24]=f,t[25]=p,t[26]=u,t[27]=a,t[28]=o,t[29]=m,t[30]=h,t[31]=i,t[32]=y[0]?.file,t[33]=L):L=t[33];let R=G(L),ee=o?`gap-0 border-foreground/15 p-1`:`gap-0.5 border-border/50 p-1.5`,z;t[34]===ee?z=t[35]:(z=J(`mt-4 flex min-w-0 flex-col rounded-[var(--radius-lg)] border bg-muted/20`,ee),t[34]=ee,t[35]=z);let B=J(D,`max-w-full text-muted-foreground hover:text-foreground`),V;t[36]===s?V=t[37]:(V=s(`chat.changedFiles.title`),t[36]=s,t[37]=V);let H;t[38]===s?H=t[39]:(H=s(`chat.changedFiles.title`),t[38]=s,t[39]=H);let U;t[40]===O?U=t[41]:(U=(0,$.jsx)(X,{name:`file-edit`,className:O}),t[40]=O,t[41]=U);let te=`turn-changes-${i}`,ne;t[42]===s?ne=t[43]:(ne=s(`chat.changedFiles.title`),t[42]=s,t[43]=ne);let re;t[44]!==te||t[45]!==ne||t[46]!==A?(re=(0,$.jsx)(`span`,{id:te,className:A,children:ne}),t[44]=te,t[45]=ne,t[46]=A,t[47]=re):re=t[47];let W;t[48]!==w||t[49]!==M?(W=(0,$.jsx)(`span`,{className:M,children:w}),t[48]=w,t[49]=M,t[50]=W):W=t[50];let ie;t[51]===O?ie=t[52]:(ie=J(O,`opacity-60`),t[51]=O,t[52]=ie);let ae;return t[53]===ie?ae=t[54]:(ae=(0,$.jsx)(X,{name:`arrow-right-s`,className:ie}),t[53]=ie,t[54]=ae),(0,$.jsxs)(`section`,{className:z,"data-turn-changes-preview":`true`,"data-message-action-group":`true`,"aria-labelledby":`turn-changes-${i}`,children:[(0,$.jsxs)(Tr,{type:`button`,variant:`ghost`,size:`xs`,disabled:!S,onClick:R,className:B,"aria-label":V,title:H,children:[U,re,W,ae]}),y.length>0?(0,$.jsxs)(`div`,{className:J(`flex min-w-0 flex-col`,o?`gap-0`:`gap-0.5`),children:[y.map(e=>(0,$.jsx)(RE,{file:e,canOpen:S,isMobile:o,onOpen:I},e.file)),b>0?(0,$.jsxs)(Tr,{type:`button`,variant:`ghost`,size:`xs`,disabled:!S,className:J(D,`text-muted-foreground hover:text-foreground`),onClick:R,"aria-label":s(`chat.changedFiles.title`),title:s(`chat.changedFiles.title`),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(O,`flex-shrink-0`)}),(0,$.jsxs)(`span`,{className:P,children:[`+`,E]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:O})]}):null]}):null]})}),BE=e=>e.type===`subtask`,VE=e=>{let t=e;return t.type===`text`&&typeof t.shellAction==`object`&&t.shellAction!==null},HE=e=>{if(!e||typeof e!=`object`)return null;let t=typeof e.providerID==`string`?e.providerID.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():``;return!t||!n?null:`${t}/${n}`},UE=e=>{let t=(0,Z.c)(49),{part:n}=e,[r,i]=Q.useState(!1),a=Ga(),{isMobile:o}=Ia(),s=Xr(ZE),c=ln(QE),l=Xo(),{t:u}=na(),f;t[0]===n.description?f=t[1]:(f=typeof n.description==`string`?n.description.trim():``,t[0]=n.description,t[1]=f);let p=f,m;t[2]===n.command?m=t[3]:(m=typeof n.command==`string`?n.command.trim():``,t[2]=n.command,t[3]=m);let h=m,g;t[4]===n.agent?g=t[5]:(g=typeof n.agent==`string`?n.agent.trim():``,t[4]=n.agent,t[5]=g);let _=g,v;t[6]===n.prompt?v=t[7]:(v=typeof n.prompt==`string`?n.prompt.trim():``,t[6]=n.prompt,t[7]=v);let y=v,b;t[8]===n.taskSessionID?b=t[9]:(b=typeof n.taskSessionID==`string`?n.taskSessionID.trim():``,t[8]=n.taskSessionID,t[9]=b);let x=b,S;t[10]===n.model?S=t[11]:(S=HE(n.model),t[10]=n.model,t[11]=S);let C=S,w=!!y&&!(o&&l.kind===`primary`),T;t[12]===u?T=t[13]:(T=u(`chat.messageBody.subtask.title`),t[12]=u,t[13]=T);let E;t[14]===T?E=t[15]:(E=(0,$.jsx)(`span`,{className:`typography-meta font-semibold text-foreground`,children:T}),t[14]=T,t[15]=E);let D;t[16]===h?D=t[17]:(D=h?(0,$.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none bg-foreground/5 text-muted-foreground`,children:[`/`,h]}):null,t[16]=h,t[17]=D);let O;t[18]===_?O=t[19]:(O=_?(0,$.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none bg-foreground/5 text-muted-foreground`,children:[`@`,_]}):null,t[18]=_,t[19]=O);let k;t[20]===C?k=t[21]:(k=C?(0,$.jsx)(`span`,{className:`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none bg-foreground/5 text-muted-foreground`,children:C}):null,t[20]=C,t[21]=k);let A;t[22]!==O||t[23]!==k||t[24]!==E||t[25]!==D?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[E,D,O,k]}),t[22]=O,t[23]=k,t[24]=E,t[25]=D,t[26]=A):A=t[26];let j;t[27]===p?j=t[28]:(j=p?(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground/90 mt-1.5`,children:p}):null,t[27]=p,t[28]=j);let M;t[29]!==r||t[30]!==y||t[31]!==w||t[32]!==u?(M=w?(0,$.jsxs)(`div`,{className:`mt-2 border-t border-border/60 pt-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2`,onClick:()=>i($E),children:u(r?`chat.messageBody.subtask.hidePrompt`:`chat.messageBody.subtask.showPrompt`)}),r?(0,$.jsx)(`pre`,{className:`typography-meta mt-1.5 overflow-x-auto whitespace-pre-wrap break-words text-foreground/85`,children:y}):null]}):null,t[29]=r,t[30]=y,t[31]=w,t[32]=u,t[33]=M):M=t[33];let N;t[34]!==_||t[35]!==p||t[36]!==a||t[37]!==o||t[38]!==c||t[39]!==l||t[40]!==s||t[41]!==u||t[42]!==x?(N=x&&l.capabilities.navigateNestedSession?(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(`button`,{type:`button`,className:`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2`,onClick:()=>{let e=l.directory||a;e&&Jo(l,x,e,()=>{if(!rr({sessionId:x,directory:e})){if(fs()||o||d()){s(x,e);return}c(e,{mode:`chat`,dedupeKey:`session:${x}`,label:p||_||u(`contextPanel.mode.chat`),readOnly:!0})}})},children:u(`chat.messageBody.subtask.openSession`)})}):null,t[34]=_,t[35]=p,t[36]=a,t[37]=o,t[38]=c,t[39]=l,t[40]=s,t[41]=u,t[42]=x,t[43]=N):N=t[43];let P;return t[44]!==A||t[45]!==j||t[46]!==M||t[47]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2`,children:[A,j,M,N]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N,t[48]=P):P=t[48],P},WE=e=>{let t=(0,Z.c)(34),{notification:n}=e,r=Ga(),i=ln(eD),{isMobile:a}=Ia(),{t:o}=na(),s;t[0]!==r||t[1]!==a?(s=r&&!a&&!d(),t[0]=r,t[1]=a,t[2]=s):s=t[2];let c=!!s,l;t[3]!==n.state||t[4]!==o?(l=n.state===`running`?o(`chat.usedGroup.running`):n.state===`completed`?o(`chat.messageBody.subagent.completed`):n.state===`error`?o(`chat.messageBody.subagent.error`):o(`chat.messageBody.subagent.cancelled`),t[3]=n.state,t[4]=o,t[5]=l):l=t[5];let u=l,f=n.state===`running`?o(`chat.messageBody.subtask.title`):n.state===`completed`?o(`chat.messageBody.subagent.completedDescription`):n.state===`error`?o(`chat.messageBody.subagent.errorDescription`):o(`chat.messageBody.subagent.cancelledDescription`),p=n.description||f,m=G(()=>{!c||!r||i(r,{mode:`chat`,dedupeKey:`session:${n.sessionID}`,label:p,readOnly:!0})}),h;t[6]===m?h=t[7]:(h=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m())},t[6]=m,t[7]=h);let g=G(h),_=c&&`cursor-pointer hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,v;t[8]===_?v=t[9]:(v=J(`mt-2 flex min-w-0 gap-2.5 rounded-[var(--radius-lg)] border border-border/60 bg-muted/20 px-3 py-2.5`,_),t[8]=_,t[9]=v);let y=c?`button`:void 0,b=c?0:void 0,x=c?o(`chat.messageBody.subagent.openSession`,{label:p}):void 0,S=c?m:void 0,C=c?g:void 0,w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-6 flex-shrink-0 items-center justify-center rounded-md bg-foreground/5 text-muted-foreground`,children:(0,$.jsx)(X,{name:`robot-2`,className:`size-3.5`})}),t[10]=w):w=t[10];let T;t[11]===p?T=t[12]:(T=(0,$.jsx)(`span`,{className:`typography-meta min-w-0 flex-1 truncate font-semibold text-foreground/90`,children:p}),t[11]=p,t[12]=T);let E=n.state===`completed`?`bg-[var(--status-success-background)] text-[var(--status-success)]`:n.state===`error`?`bg-[var(--status-error-background)] text-[var(--status-error)]`:`bg-foreground/5 text-muted-foreground`,D;t[13]===E?D=t[14]:(D=J(`inline-flex h-5 flex-shrink-0 items-center rounded px-1.5 text-[11px] leading-none`,E),t[13]=E,t[14]=D);let O;t[15]!==u||t[16]!==D?(O=(0,$.jsx)(`span`,{className:D,children:u}),t[15]=u,t[16]=D,t[17]=O):O=t[17];let k;t[18]!==T||t[19]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[T,O]}),t[18]=T,t[19]=O,t[20]=k):k=t[20];let A;t[21]===n.body?A=t[22]:(A=n.body?(0,$.jsx)(`div`,{className:`typography-meta mt-1 max-h-16 overflow-clip text-muted-foreground [&_.markdown-content>*:first-child]:mt-0 [&_.markdown-content>*:last-child]:mb-0`,children:(0,$.jsx)(ko,{content:n.body,variant:`tool`,enableFileReferences:!1})}):null,t[21]=n.body,t[22]=A);let j;t[23]!==k||t[24]!==A?(j=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[k,A]}),t[23]=k,t[24]=A,t[25]=j):j=t[25];let M;return t[26]!==C||t[27]!==j||t[28]!==v||t[29]!==y||t[30]!==b||t[31]!==x||t[32]!==S?(M=(0,$.jsxs)(`div`,{className:v,role:y,tabIndex:b,"aria-label":x,onClick:S,onKeyDown:C,children:[w,j]}),t[26]=C,t[27]=j,t[28]=v,t[29]=y,t[30]=b,t[31]=x,t[32]=S,t[33]=M):M=t[33],M},GE={background:`transparent`,backgroundColor:`transparent`},KE=e=>{let t=(0,Z.c)(37),{part:n}=e,[r,i]=Q.useState(!1),a=Q.useRef(null),{t:o}=na(),s;t[0]===n.shellAction?s=t[1]:(s=typeof n.shellAction?.command==`string`?n.shellAction.command.trim():``,t[0]=n.shellAction,t[1]=s);let c=s,l=typeof n.shellAction?.output==`string`?n.shellAction.output:``,u;t[2]===n.shellAction?u=t[3]:(u=typeof n.shellAction?.status==`string`?n.shellAction.status.trim().toLowerCase():``,t[2]=n.shellAction,t[3]=u);let d=u,f=l.length>0,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{a.current!==null&&typeof window<`u`&&(window.clearTimeout(a.current),a.current=null)},t[4]=p):p=t[4];let m=G(p),h,g;t[5]===m?(h=t[6],g=t[7]):(h=()=>()=>{m()},g=[m],t[5]=m,t[6]=h,t[7]=g),Q.useEffect(h,g);let _;t[8]!==m||t[9]!==f||t[10]!==l?(_=async()=>{f&&(await ki(l)).ok&&(m(),i(!0),typeof window<`u`&&(a.current=window.setTimeout(()=>{i(!1),a.current=null},2e3)))},t[8]=m,t[9]=f,t[10]=l,t[11]=_):_=t[11];let v=G(_),y;t[12]===o?y=t[13]:(y=o(`chat.messageBody.shellCommand.title`),t[12]=o,t[13]=y);let b;t[14]===y?b=t[15]:(b=(0,$.jsx)(`span`,{className:`typography-meta font-semibold text-foreground`,children:y}),t[14]=y,t[15]=b);let x;t[16]!==d||t[17]!==o?(x=d&&d!==`completed`?(0,$.jsx)(`span`,{className:J(`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none`,d===`error`?`bg-[var(--status-error-background)] text-[var(--status-error)]`:`bg-foreground/5 text-muted-foreground`),role:d===`error`?`alert`:`status`,children:d===`running`?o(`chat.assistantStatus.runningCommand`):d===`pending`?o(`chat.statusRow.todo.status.pending`):d===`error`?o(`chat.toolPart.error`):d}):null,t[16]=d,t[17]=o,t[18]=x):x=t[18];let S;t[19]!==r||t[20]!==v||t[21]!==f||t[22]!==o?(S=f?(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`xs`,className:`ml-auto text-muted-foreground`,onClick:()=>{v()},"aria-label":o(r?`chat.messageBody.shellCommand.copied`:`chat.messageBody.shellCommand.copyOutput`),title:o(r?`chat.messageBody.shellCommand.copied`:`chat.messageBody.shellCommand.copyOutput`),children:(0,$.jsx)(X,{name:r?`check`:`file-copy`,className:`h-3.5 w-3.5`})}):null,t[19]=r,t[20]=v,t[21]=f,t[22]=o,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==b||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[b,x,S]}),t[24]=S,t[25]=b,t[26]=x,t[27]=C):C=t[27];let w;t[28]===c?w=t[29]:(w=c?(0,$.jsx)(`div`,{className:`typography-meta mt-1.5 overflow-x-auto font-mono`,children:(0,$.jsx)(Fu,{language:`bash`,code:c,codeStyle:GE,wrap:!0})}):null,t[28]=c,t[29]=w);let T;t[30]!==f||t[31]!==l?(T=f?(0,$.jsx)(`div`,{className:`mt-2 border-t border-border/60 pt-1.5`,children:(0,$.jsx)(`pre`,{className:`typography-meta max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-foreground/85`,tabIndex:0,children:l})}):null,t[30]=f,t[31]=l,t[32]=T):T=t[32];let E;return t[33]!==C||t[34]!==w||t[35]!==T?(E=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-3 py-2`,children:[C,w,T]}),t[33]=C,t[34]=w,t[35]=T,t[36]=E):E=t[36],E},qE=Q.memo(({sessionId:e,messageId:t,parts:n,sourceParts:r,messageCreatedAt:i,isMobile:a,alwaysShowActions:o=a,hasTouchInput:s,hasTextContent:c,onCopyMessage:l,copiedMessage:u,onShowPopup:d,agentMention:f,onEdit:p,onRevert:m,onFork:h,pendingMessageAction:g,editing:_,editStaged:v,onCancelEdit:y,userActionsMode:b=`inline`,stickyUserHeaderEnabled:x=!0})=>{let{locale:S,t:C}=na(),w=hc(),T=Xo(),E=Uo(T),D=ln(e=>e.timeFormatPreference),[O,k]=Q.useState(!1),A=Q.useRef(null),j=Q.useMemo(()=>n.filter(e=>e.type===`text`?!vd(e):!!(BE(e)||VE(e))),[n]),M=Q.useMemo(()=>j.map(e=>Qn(e)?mi(xd(e)):void 0),[j]),N=f?.token,P=!1,F=!!l,I=!!u,L=!!(s??a),R=!!c,ee=b!==`external-actions`,z=b!==`external-content`,B=x&&b===`inline`,V=G(()=>{A.current!==null&&typeof window<`u`&&(window.clearTimeout(A.current),A.current=null)}),H=G(()=>{!L||!F||!R||typeof window>`u`||(V(),k(!0),A.current=window.setTimeout(()=>{k(!1),A.current=null},1800))});Q.useEffect(()=>{R||(k(!1),V())},[V,R]);let U=G(e=>{!l||!R||(e.stopPropagation(),e.preventDefault(),l(),L&&H())}),te=w===`mini-chat`||!E.fork?void 0:h,ne=Q.useMemo(()=>{if(typeof i!=`number`||i<=0)return null;let e=_c(i,D);return e.length>0?e:null},[S,i,D]),re=J(`yuri-user-actions-hover-scope`,a?b===`inline`?`flex items-center justify-end pt-2 pb-3`:x?`flex h-9 items-start justify-end pt-0`:`flex h-11 items-start justify-end pt-0`:b===`inline`?`absolute top-full left-0 right-0 z-10 pt-5`:`flex h-8 items-start justify-end pt-2`),W=!_&&v&&z?(0,$.jsx)(`div`,{className:re,...Sc,children:(0,$.jsxs)(`div`,{className:J(bc,`justify-end`,!a&&b===`inline`&&`translate-x-5`,`pointer-events-auto opacity-100`),"data-message-action-group":`true`,children:[(0,$.jsxs)(`span`,{className:J(oc,`text-primary`),"aria-live":`polite`,children:[(0,$.jsx)(X,{weight:fc,name:`edit`,className:Tc}),(0,$.jsx)(`span`,{className:`message-footer__label`,children:C(`chat.messageBody.actions.editStaged`)})]}),y?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:vc,"aria-label":C(`chat.messageBody.actions.cancelEdit`),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),y()},children:(0,$.jsx)(X,{weight:fc,name:`close`,className:pc})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.cancelEdit`)})]}):null]})}):null,ie=(_&&z?(0,$.jsx)(`div`,{className:re,...Sc,children:(0,$.jsx)(`div`,{className:J(`flex items-center gap-2`,`justify-end`,!a&&b===`inline`&&`translate-x-5`,`pointer-events-none opacity-100`),children:(0,$.jsx)(`span`,{className:J(oc,`animate-text-shimmer`),"aria-live":`polite`,children:C(`chat.messageBody.actions.editing`)})})}):null)??W??((F&&R||p||m||te)&&z?(0,$.jsx)(`div`,{className:re,...Sc,children:(0,$.jsxs)(`div`,{className:J(`flex items-center gap-2`,`justify-end`,!a&&b===`inline`&&`translate-x-5`,o?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0 transition-opacity duration-150 yuri-message-hover-actions`),"data-message-action-group":`true`,children:[ne?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsxs)(`span`,{className:J(oc,`mr-1`),"aria-label":`Message time: ${ne}`,children:[(0,$.jsx)(X,{weight:`medium`,name:`time`,className:`size-3.5!`}),(0,$.jsx)(`span`,{className:`message-footer__label`,children:ne})]})}),(0,$.jsx)(ka,{children:ne})]}):null,m&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.revertAria`),"aria-busy":g===`revert`,disabled:!!g,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),m()},children:(0,$.jsx)(X,{weight:`medium`,name:g===`revert`?`loader-4`:`arrow-go-back`,className:J(`size-3.5!`,g===`revert`&&`animate-spin`)})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.revert`)})]}),p&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.editAria`),disabled:!!g,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),p()},children:(0,$.jsx)(X,{weight:`medium`,name:`edit`,className:`size-3.5!`})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.edit`)})]}),te&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.forkAria`),"aria-busy":g===`fork`,disabled:!!g,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),te()},children:(0,$.jsx)(X,{weight:`medium`,name:g===`fork`?`loader-4`:`git-branch`,className:J(`size-3.5!`,g===`fork`&&`animate-spin`)})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.fork`)})]}),F&&R&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,"data-visible":O||I?`true`:void 0,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.copyMessageAria`),onPointerDown:e=>e.stopPropagation(),onClick:U,onFocus:()=>k(!0),onBlur:()=>{I||k(!1)},children:I?(0,$.jsx)(X,{weight:`medium`,name:`check`,className:J(`size-3.5!`,`text-[color:var(--status-success)]`)}):(0,$.jsx)(X,{weight:`medium`,name:`file-copy`,className:`size-3.5!`})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.copyMessage`)})]})]})}):null);return ee?(0,$.jsxs)(`div`,{className:`relative w-full yuri-message-hover-scope`,...Sc,"data-user-message-body":`true`,style:EE,onTouchStart:L&&F&&R?H:void 0,children:[(0,$.jsx)(`div`,{className:J(`leading-relaxed text-foreground/90 text-base overflow-x-hidden`,B?`overflow-y-auto overscroll-contain scrollbar-none`:`overflow-y-hidden`),style:B?{maxHeight:`calc(var(--chat-scroll-height, 100dvh) * 0.4)`}:void 0,children:j.map((e,i)=>{if(BE(e))return(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(UE,{part:e})},e.id??`user-subtask-${i}`);if(VE(e))return(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(KE,{part:e})},e.id??`user-shell-${i}`);let o=M[i];if(o)return(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(WE,{notification:o})},e.id??`subagent-notification-${i}`);let s;return f&&N&&!P&&xd(e).includes(N)&&(s=f,P=!0),(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(Dc,{part:e,messageId:t,isMobile:a,agentMention:s,messageParts:r??n})},e.id??`user-text-${i}`)})}),(0,$.jsx)(Pf,{files:n,messageID:t,sessionID:e,onShowPopup:d,compact:!0}),ie]}):(0,$.jsx)($.Fragment,{children:ie})}),JE=Q.memo(({sessionId:e,messageId:t,parts:n,sourceParts:r,isMessageCompleted:i,messageFinish:a,messageCompletedAt:o,messageCreatedAt:s,isMobile:c,alwaysShowActions:l,hasTouchInput:u,expandedTools:f,onToggleTool:p,onShowPopup:m,streamPhase:h,allowAnimation:g,onContentChange:_,hasTextContent:v=!1,onCopyMessage:y,onAuxiliaryContentComplete:b,showReasoningTraces:x=!1,shouldShowHeader:S=!1,turnGroupingContext:C,errorPresentation:w})=>{let T=w?.text,{t:E}=na(),D=hc(),O=Xo(),k=Uo(O),A=h,j=Q.useRef(null),M=Q.useRef(null),N=h===`streaming`||h===`cooldown`,P=Q.useRef({messageId:t,experiencedStreamingOrCooldown:N});P.current.messageId===t?N&&(P.current.experiencedStreamingOrCooldown=!0):P.current={messageId:t,experiencedStreamingOrCooldown:N};let F=!!(u??c),I=!!(l??c),L=!i,R=Q.useMemo(()=>n.filter(e=>!vd(e)).filter(e=>e.type!==`reasoning`||x&&xd(e).trim().length>0).filter(e=>e.type!==`compaction`),[n,x]),ee=Q.useMemo(()=>R.filter(e=>e.type===`tool`),[R]),z=Q.useMemo(()=>R.filter(e=>e.type===`text`),[R]),B=Q.useMemo(()=>sT(z),[z]),V=ln(e=>e.openContextPreview),H=Rt(),U=d(),te=D===`mini-chat`,ne=Q.useMemo(()=>{if(U||c||te)return null;for(let e of z){let t=e.text;if(typeof t!=`string`||t.length===0)continue;let n=dn(t)[0];if(n)return n.includes(`0.0.0.0`)?n.replace(`0.0.0.0`,`127.0.0.1`):n}for(let e of ee){let t=e.state,n=t&&typeof t.output==`string`?t.output:null;if(!n)continue;let r=dn(n.replace(/\x1b\[[0-9;]*m/g,``))[0];if(r)return r.includes(`0.0.0.0`)?r.replace(`0.0.0.0`,`127.0.0.1`):r}return null},[z,c,te,U,ee]),re=Xr(e=>e.forkFromMessage),W=Xr(e=>e.forkTransition),ie=Xr(e=>e.currentSessionId),ae=Xr(e=>e.getDirectoryForSession),oe=Ga(),[se,ce]=Q.useState(!1),le=ln(e=>e.chatRenderMode),ue=C?le:`live`,de=ln(e=>e.collapsibleThinkingBlocks),fe=ln(e=>e.showSplitAssistantMessageActions),pe=ln(e=>e.showAssistantTps),me=ue===`sorted`,he=C?.isLastAssistantInTurn??!1,ge=a===`stop`,_e=(ge||i||!!T)&&(C?.isTurnSettled??!0),ve=ge?`completed`:A,ye=ee.length>0,be=Q.useMemo(()=>ee.some(e=>bC(e)),[ee]),xe=bC,Se=yC,Ce=P.current.experiencedStreamingOrCooldown,we=Q.useRef({messageId:t,initialized:!1,observedPartIds:new Set});Q.useEffect(()=>{if(we.current.messageId!==t&&(we.current={messageId:t,initialized:!1,observedPartIds:new Set}),!Ce||!Ri())return;let n=we.current,r=!n.initialized;n.initialized=!0;for(let i of ee){if(n.observedPartIds.has(i.id))continue;if(!_i(r,xe(i))){n.observedPartIds.add(i.id);continue}let a=e??i.sessionID;a&&(n.observedPartIds.add(i.id),yn({sessionID:a,messageID:t,partID:i.id,kind:`tool`}))}},[Ce,xe,t,e,ee]);let Te=Q.useMemo(()=>ee.length===0||!be&&ee.every(e=>Se(e)),[ee,be,Se]),Ee=Q.useMemo(()=>R.filter(e=>e.type===`reasoning`),[R]),De=Q.useMemo(()=>Ee.length===0||Ee.every(e=>typeof e.time?.end==`number`),[Ee]),Oe=typeof a!=`string`,ke=Ee.length>0&&ye&&(be||Oe||!Te),Ae=L||ye&&(be||Oe||!Te),je=L||ke,Me=ye||Ee.length>0,Ne=z.length===0,Pe=Me&&Ne&&!Ae&&!je&&Te&&De,Fe=Q.useRef(!1),Ie=Q.useRef(!1);Q.useEffect(()=>{Ie.current=!1},[t]),Q.useEffect(()=>{if(!Pe){Fe.current=!1;return}Fe.current||(Fe.current=!0,b?.())},[Pe,b]),Q.useEffect(()=>{if(L){Ie.current=!1;return}if(ye){Ie.current=!1;return}Ee.length!==0&&(je||!De||Ie.current||(Ie.current=!0,_?.(`structural`)))},[L,ye,_,De,Ee.length,je]);let Le=G(async n=>{if(n.stopPropagation(),n.preventDefault(),!(!e||!t||se||W)){ce(!0);try{O.onForkMessage?await O.onForkMessage(t):await re(e,t)}finally{ce(!1)}}}),Re=Q.useMemo(()=>{let e=C?.activityParts;return!me||!e?[]:e},[me,C?.activityParts]),ze=Q.useMemo(()=>{let e=C?.activityGroupSegments;return!me||!e?[]:e.filter(e=>e.anchorMessageId===t)},[me,t,C?.activityGroupSegments]),Be=ze.length>0,Ve=Q.useMemo(()=>{let e=new Map,t=new Map;return Re.forEach(n=>{e.set(n.part,n);let r=n.part.id;typeof r==`string`&&r.length>0&&t.set(r,n)}),{get:n=>{let r=e.get(n);if(r)return r;let i=n.id;if(typeof i==`string`&&i.length>0)return t.get(i)}}},[Re]),He=C?.toggleGroup,Ue=C?.activityPresentationKind===`compaction`,We=C?.isGroupExpanded===!0,Ge=me&&Ue&&!We,Ke=me?C?.activityOwnerMessageId===t||Be:!C?.activityOwnerMessageId||C.activityOwnerMessageId===t||Be,qe=me&&Ke&&(Be||Ue)&&!!He,Je=vl(a,R),Ye={finish:a,parts:R,streamPhase:ve,error:T,isLastAssistantInTurn:he},Xe=hl(Ye),Ze=kr(e=>e.ttsInputMode),Qe=Q.useMemo(()=>{if(!he||Ue||!_e||!Xe)return``;let e=r??n,t=wl(e);return t<0?``:xd(e[t])},[he,Ue,_e,Xe,r,n]),$e=Ze===`final`?Qe:B;yd({sessionId:e??``,messageId:t,created:s??0,text:$e,targetRef:j,streaming:c&&O.active&&(A===`streaming`||A===`cooldown`),completed:c&&O.active&&i&&A!==`streaming`&&A!==`cooldown`&&!T});let et=me&&dl(Ye),tt=me&&!Xe&&!(Ue&&We),nt=Q.useMemo(()=>{if(!pe||!he||w?.variant===`error`)return null;let e=C?.assistantTps;if(!dT({completionDisposition:C?.completionDisposition,tps:e}))return null;let t=fT(e??0);return t.length>0?t:null},[pe,w?.variant,he,C?.assistantTps,C?.completionDisposition]),rt=he&&w?.variant!==`error`&&!Ge&&(_e&&(v||!!T||i)||!!nt),it=rt?wl(r??n)>=0:!!v&&!L,at=it,ot=C?.diffStats?.hasDiffs===!0,st=!!C?.activityParts?.length&&e&&O.active&&!te,ct=!te&&he&&Je&&_e&&!Ge&&C?.diffStats?.hasDiffs===!0,lt=fe&&at&&!rt&&!me,ut=Q.useMemo(()=>(0,$.jsx)(uc,{messageId:t,hasCopyableText:it,isTouchContext:F,onCopyMessage:y,ttsText:$e,sessionId:e}),[$e,it,F,y,e,t]),dt=Q.useMemo(()=>e=>{if(!fe||!me)return null;let t=xd(e.part).trim();return t?(0,$.jsx)(uc,{hasCopyableText:!0,isTouchContext:F,onCopyMessage:async()=>(await ki(t)).ok,ttsText:Ze===`final`?``:t}):null},[me,F,fe,Ze]),ft=Q.useMemo(()=>{if(!lt)return-1;let e=-1;for(let t=0;t<R.length;t+=1){let n=R[t];!n||n.type!==`text`||tt||Ve.get(n)?.kind!==`justification`&&(e=t)}return e},[Ve,tt,lt,R]),pt=lt&&ft<0,mt=Q.useMemo(()=>{let n=[];if(qe&&He&&C){let e=(e,t,r=t)=>{n.push((0,$.jsx)(`div`,{children:(0,$.jsx)(CE,{parts:t,materializationParts:r,isExpanded:C.isGroupExpanded===!0,collapsedPreviewCount:0,completionDisposition:C.completionDisposition,activityPresentationKind:C.activityPresentationKind,durationMs:C.durationMs,startedAt:C.userMessageCreatedAt,onToggle:He,isMobile:c,expandedTools:f,onToggleTool:p,onShowPopup:m,onContentChange:_,streamPhase:ve,showHeader:!0,diffStats:C.diffStats,renderJustificationActions:dt})},`progressive-group-${e}`))};ze.length>0?ze.forEach(t=>{let n=x?t.parts:t.parts.filter(e=>e.kind!==`reasoning`);e(t.id,n,t.parts)}):Ue&&e(`${t}:compaction-status`,[])}let r=0;for(;r<R.length;){let i=R[r];if(i.type===`text`){let a=Ve.get(i);if(tt){r+=1;continue}if(Ge){r+=1;continue}if(a?.kind===`justification`){r+=1;continue}n.push((0,$.jsx)(`div`,{ref:M,"data-message-text-export-source":`true`,children:(0,$.jsx)(Uw,{part:i,sessionId:e,messageId:t,streamPhase:ve,chatRenderMode:ue,allowSortedFinalStreaming:et,hasStreamingHapticLifecycle:Ce,onContentChange:_,onShowPopup:m})},`assistant-text-${t}-${i.id??r}`)),lt&&r===ft&&n.push((0,$.jsx)(`div`,{className:c?OE:DE,"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:bc,"data-message-action-group":`true`,children:ut})},`message-actions-${t}`)),r++;continue}if(i.type===`reasoning`){if(Ve.get(i)?.kind===`reasoning`){r+=1;continue}if(!xd(i).trim()){r+=1;continue}x&&(de?n.push((0,$.jsx)(`div`,{className:fm(c),children:(0,$.jsx)(tT,{part:i,messageId:t,streamPhase:ve,onContentChange:_})},`reasoning-${t}-${i.id??r}`)):n.push((0,$.jsx)(Uw,{part:i,sessionId:e,messageId:t,streamPhase:ve,chatRenderMode:ue,hasStreamingHapticLifecycle:Ce,onContentChange:_,onShowPopup:m},`reasoning-${t}-${i.id??r}`))),r++;continue}if(i.type===`tool`){let e=i,a=e.tool?.toLowerCase()??``;if(me&&!Ke){r+=1;continue}if(Ve.get(i)?.kind===`tool`){r+=1;continue}if(me&&vC(a)){let e=MT(R,r,e=>e.type!==`tool`||Ve.get(e)?.kind===`tool`?``:e.tool);if(e.items.length>0){let i=e.items.map((e,n)=>{let i=e;return{id:i.id,turnId:``,messageId:t,partIndex:r+n,part:i,kind:`tool`}});n.push((0,$.jsx)(FT,{activities:i,isMobile:c,isTurnLive:ve!==`completed`,hasFollowingOtherType:AT(R,e.end,e=>({type:e.type,toolName:e.type===`tool`?e.tool:void 0})),children:i.map(e=>{let n=e.part.tool?.toLowerCase()??``;return hC(n)?(0,$.jsx)(hE,{toolName:n,activities:[e],isMobile:c,animateTailText:!1},e.id):(0,$.jsx)(kw,{part:e.part,messageId:t,isExpanded:f.has(e.part.id),onToggle:p,isMobile:c,alwaysShowActions:I,onContentChange:_,onShowPopup:m,animateTailText:!1},e.id)})},`context-tools-${i[0].id}`)),r=e.end;continue}}if(gC(a)){let e=IT(R,r,e=>e.type!==`tool`||Ve.get(e)?.kind===`tool`?``:e.tool);if(e.items.length>0){let i=e.items.map((e,n)=>{let i=e;return{id:i.id,turnId:``,messageId:t,partIndex:r+n,part:i,kind:`tool`}});n.push((0,$.jsx)(VT,{activities:i,isMobile:c,children:i.map(e=>(0,$.jsx)(hE,{toolName:e.part.tool?.toLowerCase()??``,activities:[e],isMobile:c,animateTailText:!1},e.id))},`skill-tools-${i[0].id}`)),r=e.end;continue}}if(fC(a)){n.push((0,$.jsx)(`div`,{className:fm(c),children:(0,$.jsx)(kw,{part:e,messageId:t,isExpanded:f.has(e.id),onToggle:p,isMobile:c,alwaysShowActions:I,onContentChange:_,onShowPopup:m,animateTailText:!1})},`tool-${e.id}`)),r++;continue}n.push((0,$.jsx)(`div`,{className:fm(c),children:(0,$.jsx)(hE,{toolName:a,activities:[{id:e.id,turnId:``,messageId:t,partIndex:r,part:e,kind:`tool`}],isMobile:c,animateTailText:!1})},`static-tools-${e.id}`)),r++;continue}r++}let i=n.at(-1);if(Q.isValidElement(i)&&i.props[`data-message-text-export-source`]===`true`&&ve!==`completed`&&!_e&&!w&&(!C||C.isLastAssistantInTurn)){let e=i;n[n.length-1]=Q.cloneElement(e,{className:J(typeof e.props.className==`string`?e.props.className:void 0,c?`pb-1`:`pb-1.5`),"data-live-status-text-gap":``})}return n},[Ve,ze,I,ue,de,0,f,Ge,Ue,c,Ke,me,ft,t,ut,dt,e,_,m,p,qe,lt,ve,w,Ce,_e,x,tt,et,He,C,R]),ht=Q.useMemo(()=>{if(!he||!_e)return;let e=C?.durationMs;if(!(typeof e!=`number`||e<=0))return wc(e)},[he,_e,C?.durationMs]),gt=Q.useMemo(()=>{let e=typeof o==`number`&&o>0?o:typeof s==`number`&&s>0?s:null;if(e===null)return null;let t=lc(e);return t.length>0?t:null},[o,s]),_t=(0,$.jsxs)($.Fragment,{children:[!te&&!c&&!U&&ne?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:vc,"aria-label":E(`chat.messageBody.actions.openPreviewAria`),onPointerDown:e=>e.stopPropagation(),onClick:()=>{let e=oe??(ie?ae(ie):null);e&&V(H?.entry.location.hostId?H.entry.key:e,ne)},children:(0,$.jsx)(X,{weight:fc,name:`global`,className:pc})})}),(0,$.jsx)(ka,{sideOffset:6,children:E(`chat.messageBody.actions.openPreview`)})]}):null,!te&&k.fork?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,size:`icon`,variant:`ghost`,className:vc,"aria-label":E(`chat.messageBody.actions.forkAria`),"aria-busy":se,disabled:se||!!W,onPointerDown:e=>e.stopPropagation(),onClick:e=>{Le(e)},children:(0,$.jsx)(X,{weight:fc,name:se?`loader-4`:`git-branch`,className:J(pc,se&&`animate-spin`)})})}),(0,$.jsx)(ka,{sideOffset:6,children:E(`chat.messageBody.actions.fork`)})]}):null]});return(0,$.jsxs)(`div`,{ref:j,"data-message-text-export-root":`true`,"data-speech-identity":e?`${e}:${t}`:void 0,...Sc,className:J(`relative w-full yuri-message-hover-scope`),style:EE,children:[(0,$.jsx)(ns,{containerRef:j}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:J(`message-content-text leading-relaxed text-foreground/90 [&_p:last-child]:mb-0 [&_ul:last-child]:mb-0 [&_ol:last-child]:mb-0`,(S||C?.headerMessageId===t)&&(c?`[&>[data-message-text-export-source]:first-child]:pt-1.5`:`[&>[data-message-text-export-source]:first-child]:pt-2`)),children:[mt,w&&(0,$.jsx)(Td,{children:(0,$.jsx)(`div`,{className:`my-1.5`,"data-assistant-error":w.variant,children:(0,$.jsx)(TE,{presentation:w,sessionId:e,messageId:t,directory:oe??void 0})})},`assistant-error`)]}),ct&&C?.diffStats?(0,$.jsx)(zE,{fileCount:C.diffStats.files,changedFiles:C.changedFiles,turnId:C.turnId,isLatestTurn:C.isLatestTurn,isMobile:c}):null,(0,$.jsx)(Pf,{files:n,messageID:t,sessionID:e,onShowPopup:m}),pt&&(0,$.jsx)(`div`,{className:J(c?OE:DE),"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,"data-message-action-group":`true`,children:ut})}),rt&&(0,$.jsx)(dc,{messageId:t,isMobile:c,animateReveal:Ce,actions:(0,$.jsxs)($.Fragment,{children:[ut,_t]}),tps:nt,duration:ht,timestamp:gt,activity:st&&e?(0,$.jsx)(mT,{sessionId:e,activityParts:C?.activityParts}):null,trailing:!te&&he&&ge&&!ot?(0,$.jsx)(aT,{activityParts:C?.activityParts}):null})]})]})}),YE=Q.memo(e=>{let t=(0,Z.c)(28),n,r;if(t[0]===e?(n=t[1],r=t[2]):({isUser:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n){let e;return t[3]!==r.agentMention||t[4]!==r.alwaysShowActions||t[5]!==r.copiedMessage||t[6]!==r.editStaged||t[7]!==r.editing||t[8]!==r.hasTextContent||t[9]!==r.hasTouchInput||t[10]!==r.isMobile||t[11]!==r.messageCreatedAt||t[12]!==r.messageId||t[13]!==r.onCancelEdit||t[14]!==r.onCopyMessage||t[15]!==r.onEdit||t[16]!==r.onFork||t[17]!==r.onRevert||t[18]!==r.onShowPopup||t[19]!==r.parts||t[20]!==r.pendingMessageAction||t[21]!==r.sessionId||t[22]!==r.sourceParts||t[23]!==r.stickyUserHeaderEnabled||t[24]!==r.userActionsMode?(e=(0,$.jsx)(qE,{sessionId:r.sessionId,messageId:r.messageId,parts:r.parts,sourceParts:r.sourceParts,messageCreatedAt:r.messageCreatedAt,isMobile:r.isMobile,alwaysShowActions:r.alwaysShowActions,hasTouchInput:r.hasTouchInput,hasTextContent:r.hasTextContent,onCopyMessage:r.onCopyMessage,copiedMessage:r.copiedMessage,onShowPopup:r.onShowPopup,agentMention:r.agentMention,onEdit:r.onEdit,onRevert:r.onRevert,onFork:r.onFork,pendingMessageAction:r.pendingMessageAction,editing:r.editing,editStaged:r.editStaged,onCancelEdit:r.onCancelEdit,userActionsMode:r.userActionsMode,stickyUserHeaderEnabled:r.stickyUserHeaderEnabled}),t[3]=r.agentMention,t[4]=r.alwaysShowActions,t[5]=r.copiedMessage,t[6]=r.editStaged,t[7]=r.editing,t[8]=r.hasTextContent,t[9]=r.hasTouchInput,t[10]=r.isMobile,t[11]=r.messageCreatedAt,t[12]=r.messageId,t[13]=r.onCancelEdit,t[14]=r.onCopyMessage,t[15]=r.onEdit,t[16]=r.onFork,t[17]=r.onRevert,t[18]=r.onShowPopup,t[19]=r.parts,t[20]=r.pendingMessageAction,t[21]=r.sessionId,t[22]=r.sourceParts,t[23]=r.stickyUserHeaderEnabled,t[24]=r.userActionsMode,t[25]=e):e=t[25],e}let i;return t[26]===r?i=t[27]:(i=(0,$.jsx)(JE,{...r}),t[26]=r,t[27]=i),i});function XE(e){return e.openContextPanelTab}function ZE(e){return e.setCurrentSession}function QE(e){return e.openContextPanelTab}function $E(e){return!e}function eD(e){return e.openContextPanelTab}var tD=e=>{let t=e,n=t?.clientRole,r=t?.role;return t?.userMessageMarker===!0||n===`user`||r===`user`||t?.origin===`user`||t?.source===`user`?{role:`user`,isUser:!0}:{role:n||r||`assistant`,isUser:!1}},nD=e=>{if(typeof e!=`string`)return!1;let t=e.toLowerCase().trim();if(!t)return!1;if(t.includes(`token refresh failed`)||t.includes(`unauthorized`)||t.includes(`invalid token`)||t.includes(`expired token`))return!0;let n=t.includes(`oauth`),r=t.includes(`failed`)||t.includes(`invalid`)||t.includes(`expired`);if(n&&r)return!0;let i=/\b401\b/.test(t),a=t.includes(`auth`)||t.includes(`token`)||t.includes(`unauthorized`);return i&&a},rD={"provider.rate-limit":`chat.response.rateLimit`,"provider.auth":`chat.response.auth`,"provider.quota":`chat.response.quota`,"provider.content-filter":`chat.response.contentFilter`,"provider.transport":`chat.response.transport`,"provider.internal":`chat.response.internal`,"provider.invalid-output":`chat.response.invalidOutput`,"provider.invalid-request":`chat.response.invalidRequest`,"provider.unsupported-operation":`chat.response.unsupportedOperation`,"provider.no-route":`chat.response.noRoute`,"provider.unknown":`chat.response.providerUnknown`,"provider.timeout":`chat.response.timeout`,"permission.rejected":`chat.response.permissionRejected`,"tool.execution":`chat.response.toolExecution`,"compaction.failed":`chat.response.compactionFailed`,"compaction.unavailable":`chat.response.compactionUnavailable`,"compaction.interrupted":`chat.response.compactionInterrupted`},iD={icon:`pause-circle`,variant:`muted`};function aD(e,t){if(!e||typeof e!=`object`)return;let n=e,r=typeof n.data?.message==`string`?n.data.message:typeof n.message==`string`?n.message:void 0,i=typeof n.name==`string`?n.name:void 0,a=typeof n.type==`string`?n.type.trim():void 0,o=typeof n.status==`number`&&Number.isInteger(n.status)&&n.status>=100&&n.status<=599?n.status:void 0;if(!r&&!a&&!i&&o===void 0)return;let s=[a&&a!==`unknown`&&a!==`error`?a:void 0,o].filter(e=>e!==void 0).join(` · `)||void 0,c=(e,n,i=`error`,a=!1)=>({text:t(e),icon:n,variant:i,...r&&!a?{rawMessage:r}:{},...s?{detail:s}:{}});if(i===`SessionRetry`)return c(`chat.response.retrying`,`refresh`,`info`);if(a===`aborted`)return r===`Execution was interrupted repeatedly and will not be resumed automatically.`?c(`chat.response.resumeExhausted`,`error-warning`,`error`,!0):r===`Session interrupted by user`?c(`chat.response.stopped`,`stop-circle`,`muted`,!0):r===`Compaction cancelled`?c(`chat.response.compactionCancelled`,`stop-circle`,`muted`,!0):r===`Tool execution interrupted`?c(`chat.response.toolInterrupted`,iD.icon,iD.variant,!0):c(`chat.response.interrupted`,iD.icon,iD.variant,r===`Step interrupted`);if(i===`MessageAbortedError`||!a&&r?.trim().toLowerCase()===`aborted`)return c(`chat.response.stopped`,`stop-circle`,`muted`,!0);if(a&&Object.hasOwn(rD,a)){if(a===`compaction.interrupted`)return c(rD[a],iD.icon,iD.variant,r===`Compaction was interrupted`);if(a===`compaction.unavailable`)return c(rD[a],`information`,`info`,r===`Nothing to compact yet`);let e=a===`provider.auth`||a===`permission.rejected`?`lock`:a===`provider.timeout`?`time`:`error-warning`;return c(rD[a],e)}return(!a||a===`unknown`||a===`error`)&&nD(r)?c(`chat.response.auth`,`lock`):{...c(`chat.response.failed`,`error-warning`),...!r&&i?{rawMessage:i}:{}}}function oD(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.nativeType===`synthetic`&&t.description===`Continuing after restart`}function sD(e,t){if(oD(e))return{text:t(`chat.response.continuingAfterRestart`),icon:`restart`,variant:`info`}}function cD(e){return!e}function lD(e){let t=(0,Z.c)(60),{part:n,isMobile:r}=e,i=r!==void 0&&r,{t:a}=na(),o;t[0]!==n.id||t[1]!==n.messageID||t[2]!==n.sessionID?(o=JSON.stringify([n.sessionID,n.messageID,n.id]),t[0]=n.id,t[1]=n.messageID,t[2]=n.sessionID,t[3]=o):o=t[3];let s=o,{expanded:c,toggle:l}=jb(s),u=(0,Q.useId)(),d;t[4]!==s||t[5]!==l?(d=()=>l(s),t[4]=s,t[5]=l,t[6]=d):d=t[6];let f=G(d),p=n.status===`running`,m=n.status===`failed`,h;t[7]!==m||t[8]!==p||t[9]!==a?(h=a(p?`chat.activity.compacting`:m?`chat.activity.compactionFailed`:`chat.activity.compactionCompleted`),t[7]=m,t[8]=p,t[9]=a,t[10]=h):h=t[10];let g=h,_;t[11]!==m||t[12]!==n.error||t[13]!==a?(_=m?aD(n.error,a):void 0,t[11]=m,t[12]=n.error,t[13]=a,t[14]=_):_=t[14];let v=_,y;t[15]!==m||t[16]!==n.summary?(y=m?``:n.summary?.trim()??``,t[15]=m,t[16]=n.summary,t[17]=y):y=t[17];let b=y,x,S,C,w,T,E,D,O,k;if(t[18]!==u||t[19]!==c||t[20]!==v?.text||t[21]!==m||t[22]!==i||t[23]!==p||t[24]!==n.status||t[25]!==b||t[26]!==g||t[27]!==f){let e=J(`shrink-0 typography-meta`,m?`text-[var(--status-error)]/85`:`text-muted-foreground`);E=`w-full min-w-0`,D=``,O=n.status;let r=i?`min-h-7`:`min-h-8`;t[37]===r?k=t[38]:(k=J(`flex w-full items-center gap-3`,r),t[37]=r,t[38]=k),x=`separator`,S=p?`polite`:void 0,C=v?.text??g,t[39]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 border-t`,"aria-hidden":`true`}),t[39]=w):w=t[39],T=b?(0,$.jsxs)(Tr,{variant:`ghost`,size:`sm`,className:J(e,mm),"aria-expanded":c,"aria-controls":u,onClick:f,children:[g,(0,$.jsx)(X,{name:`arrow-down-s`,className:J(`size-4 transition-transform`,c&&`rotate-180`)})]}):(0,$.jsx)(`span`,{className:e,children:g}),t[18]=u,t[19]=c,t[20]=v?.text,t[21]=m,t[22]=i,t[23]=p,t[24]=n.status,t[25]=b,t[26]=g,t[27]=f,t[28]=x,t[29]=S,t[30]=C,t[31]=w,t[32]=T,t[33]=E,t[34]=D,t[35]=O,t[36]=k}else x=t[28],S=t[29],C=t[30],w=t[31],T=t[32],E=t[33],D=t[34],O=t[35],k=t[36];let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 border-t`,"aria-hidden":`true`}),t[40]=A):A=t[40];let j;t[41]!==x||t[42]!==S||t[43]!==C||t[44]!==w||t[45]!==T||t[46]!==D||t[47]!==O||t[48]!==k?(j=(0,$.jsxs)(`div`,{"data-compaction-card":D,"data-compaction-status":O,className:k,role:x,"aria-live":S,"aria-label":C,children:[w,T,A]}),t[41]=x,t[42]=S,t[43]=C,t[44]=w,t[45]=T,t[46]=D,t[47]=O,t[48]=k,t[49]=j):j=t[49];let M;t[50]!==u||t[51]!==c||t[52]!==p||t[53]!==n.messageID||t[54]!==b?(M=b&&c?(0,$.jsx)(`div`,{id:u,className:`py-2`,children:(0,$.jsx)(Mo,{content:b,messageId:n.messageID,isStreaming:p})}):null,t[50]=u,t[51]=c,t[52]=p,t[53]=n.messageID,t[54]=b,t[55]=M):M=t[55];let N;return t[56]!==E||t[57]!==j||t[58]!==M?(N=(0,$.jsxs)(`div`,{className:E,children:[j,M]}),t[56]=E,t[57]=j,t[58]=M,t[59]=N):N=t[59],N}var uD=e=>{if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0},dD=e=>{if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.model==`object`&&t.model!==null?t.model:void 0,r=typeof t.metadata==`object`&&t.metadata!==null?t.metadata:void 0,i=typeof r?.model==`object`&&r.model!==null?r.model:void 0,a=uD(t.mode)??uD(t.agent)??uD(r?.agent),o=uD(t.providerID)??uD(n?.providerID)??uD(i?.providerID),s=uD(t.modelID)??uD(n?.modelID)??uD(n?.id)??uD(i?.modelID)??uD(i?.id),c=uD(n?.variant)??uD(i?.variant)??uD(t.variant)??uD(r?.variant);return!a&&!o&&!s&&!c?null:{agentName:a,providerId:o,modelId:s,variant:c}},fD=e=>{let t=e?.providerId?.trim(),n=e?.modelId?.trim();return!t||!n?null:{providerId:t,modelId:n}},pD=e=>fD(e.assistantIdentity)??fD(e.userIdentity)??(e.allowComposerFallback?fD(e.composerSelection):null)??fD(e.sessionSelection),mD=e=>{let t=e?.modelId??null;return{providerID:e?.providerId??null,modelID:t,agentName:e?.agentName,modelName:Gr(void 0,t)||void 0,variant:e?.variant}},hD=e=>!(!e.isLastTurn||!e.sessionIsWorking||e.hasAssistantMessages||e.activityPresentationKind===`compaction`||e.hasActiveStreamingMessage),gD=(e,t,n)=>e===`active`||n?.isLastTurn&&n.hasConfirmedFinalBody!==!0?!0:t===`summary`,_D=e=>!e,vD=e=>e.completionDisposition===`active`?e.isLastTurn&&e.sessionIsWorking?{completionDisposition:`active`,durationMs:e.durationMs}:{completionDisposition:`abnormal`,durationMs:e.durationMs}:{completionDisposition:e.completionDisposition,durationMs:e.durationMs},yD=e=>!(e.completionDisposition===`active`||e.isLastTurn&&e.sessionIsWorking&&!e.hasConfirmedSettledAssistant),bD=e=>e.isWorking?!0:e.isInActiveTurn?e.headerCompletionDisposition!==`normal`&&e.headerCompletionDisposition!==`abnormal`:!1,xD=e=>e.turnCompletionDisposition===`active`&&(e.isLastTurn||e.hasAssistantMessages)?`active`:e.headerPresentationDisposition,SD=e=>{let t=e.info;return(typeof t.clientRole==`string`?t.clientRole:null)??(typeof t.role==`string`?t.role:null)??null},CD=e=>{let t=e.info;return typeof t.parentID==`string`&&t.parentID.length>0?t.parentID:null},wD=e=>!e||SD(e)!==`user`?!1:e.parts.some(e=>{if(e?.type!==`text`)return!1;let t=e.text;return e.synthetic===!0&&typeof t==`string`&&t.trim().startsWith(`The following tool was executed by the user`)}),TD=e=>SD(e)===`user`?wD(e)||e.parts.some(e=>{let t=e.shellAction;return e.type===`text`&&typeof t==`object`&&!!t}):!1,ED=(e,t)=>{if(SD(e)!==`assistant`||t&&CD(e)!==t||e.parts.length!==1)return{hide:!1,details:null};let n=e.parts[0];return n?.type!==`tool`||(typeof n.tool==`string`?n.tool.toLowerCase():``)!==`bash`?{hide:!1,details:null}:{hide:!0,details:{command:typeof n.state?.input?.command==`string`?n.state.input.command:void 0,output:(typeof n.state?.output==`string`?n.state.output:void 0)??(typeof n.state?.metadata?.output==`string`?n.state.metadata.output:void 0),status:typeof n.state?.status==`string`?n.state.status:void 0}}},DD=(e,t)=>{let n=e[t];if(!n)return null;let r=n.info.id;for(let n=t+1;n<e.length;n+=1){let t=e[n];if(SD(t)===`user`)break;let{hide:i,details:a}=ED(t,r);if(i){let e=typeof a?.command==`string`?a.command.trim():``;return e.length>0?e:null}}return null},OD=Ao(()=>on(()=>import(`./ToolOutputDialog-DSfZp0SO.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),kD=4e3,AD=new Map,jD=new Map,MD=new Set([`bash`,`shell`,`cmd`,`terminal`]),ND=e=>{if(typeof e!=`string`)return``;let t=e.trim().toLowerCase();if(!t)return``;let n=t.replace(/:\d+$/,``);if(!n.includes(`.`))return n;let r=n.split(`.`).filter(Boolean);return r[r.length-1]??n},PD=e=>{let t=AD.get(e);return t?new Set(t):new Set},FD=(e,t)=>{if(AD.size>=kD&&!AD.has(e)){let e=AD.keys().next().value;typeof e==`string`&&AD.delete(e)}AD.set(e,new Set(t))},ID=e=>{let t=jD.get(e);return t?new Set(t):new Set},LD=(e,t)=>{if(jD.size>=kD&&!jD.has(e)){let e=jD.keys().next().value;typeof e==`string`&&jD.delete(e)}jD.set(e,new Set(t))},RD=200,zD=new Map,BD=e=>zD.get(e),VD=(e,t)=>{if(!t.agent&&!t.provider&&!t.model)return;let n=zD.get(e);if(!(n&&n.agent===t.agent&&n.provider===t.provider&&n.model===t.model)){if(zD.size>=RD&&!zD.has(e)){let e=zD.keys().next().value;typeof e==`string`&&zD.delete(e)}zD.set(e,t)}};function HD(e){let t=(0,Z.c)(3),[n,r]=Q.useState(e),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{e!=null&&r(e)},a=[e],t[0]=e,t[1]=i,t[2]=a),Q.useEffect(i,a),e??n}var UD=(e,t)=>{if(typeof e==`object`&&e)return e[t]},WD=Q.memo(({message:e,previousMessage:t,nextMessage:n,onContentChange:r,animationHandlers:i,turnGroupingContext:a,assistantHeaderMessageId:o,turnOwnsAssistantHeader:s=!1,isInActiveTurn:c=!1,activeStreamingPhase:l=null,animateUserOnMount:u=!1,onUserAnimationConsumed:d})=>{let{t:f}=na(),{isMobile:m,isTablet:h,hasTouchInput:g}=Ia(),_=Xo(),v=Uo(_),y=m||h,b=Q.useRef(null),x=Q.useRef(null),S=G(t=>{b.current=t,x.current?.(),x.current=null,t&&m&&(x.current=Oc(t,e.info.id))});Q.useEffect(()=>{let t=b.current;return x.current?.(),x.current=null,t&&m&&(x.current=Oc(t,e.info.id)),()=>{x.current?.(),x.current=null}},[m,e.info.id]);let C=Xr(e=>e.currentSessionId),w=Xr(e=>e.revertToMessage),T=Xr(e=>e.editMessagePreservingChanges),E=Xr(e=>e.forkFromMessage),D=Xr(t=>t.messageEditCommitting?.messageId===e.info.id&&t.messageEditCommitting?.sessionId===e.info.sessionID),O=Xr(t=>t.stagedMessageEdit?.messageId===e.info.id&&t.stagedMessageEdit?.sessionId===e.info.sessionID),k=Xr(e=>e.clearStagedMessageEdit);We(`ui.chat_message.render`),c&&We(`ui.chat_message.render.streaming`);let A=kr(e=>e.providers),{showReasoningTraces:j,stickyUserHeader:M,chatRenderMode:N,showExpandedBashTools:P}=ln(De(e=>({showReasoningTraces:e.showReasoningTraces,stickyUserHeader:e.stickyUserHeader,chatRenderMode:e.chatRenderMode,showExpandedBashTools:e.showExpandedBashTools})));Q.useEffect(()=>{C&&yc.getInstance().recordSessionStart(C)},[C]);let[F,I]=Q.useState(null),[L,R]=Q.useState(!1),[ee,z]=Q.useState(null),B=Q.useRef(null),[V,H]=Q.useState(()=>PD(e.info.id)),[U,te]=Q.useState(()=>ID(e.info.id)),[ne,re]=Q.useState({open:!1,title:``,content:``});Q.useEffect(()=>{H(PD(e.info.id)),te(ID(e.info.id))},[e.info.id]);let W=Q.useMemo(()=>tD(e.info),[e.info]).isUser,ie=Q.useMemo(()=>p(e.parts),[e.parts]),ae=W&&(m||!M),oe=W&&!m&&M&&!ae,se=e.info.sessionID,{currentContextAgent:ce,savedSessionAgentSelection:le}=km(De(e=>({currentContextAgent:c&&se?e.currentAgentContext.get(se):void 0,savedSessionAgentSelection:c&&se?e.sessionAgentSelections.get(se):void 0}))),ue=Q.useMemo(()=>gd(e.sourceParts??e.parts),[e.parts,e.sourceParts]),de=Q.useMemo(()=>W?gc(ue):gd(e.parts),[W,e.parts,ue]),fe=Q.useMemo(()=>{if(W||!t)return null;let e=UD(t.info,`clientRole`),n=UD(t.info,`role`);return(typeof e==`string`?e:typeof n==`string`?n:void 0)===`user`&&dD(t.info)||null},[W,t]),pe=Q.useMemo(()=>{if(W)return;let t=UD(e.info,`mode`);if(typeof t==`string`&&t.trim().length>0)return t;let n=UD(e.info,`agent`);if(typeof n==`string`&&n.trim().length>0)return n;if(fe?.agentName)return fe.agentName;if(se)return ce||(le??void 0)},[W,e.info,fe,se,ce,le]),me=W?null:dD(e.info),he=me?.providerId??null,ge=me?.modelId??null,_e=Oi(De(e=>{if(W||!se)return null;if(fe?.providerId&&fe?.modelId)return{providerId:fe.providerId,modelId:fe.modelId};if(pe){let t=e.getAgentModelForSession(se,pe);if(t?.providerId&&t?.modelId)return t}let t=e.getSessionModelSelection(se);return t?.providerId&&t?.modelId?t:null})),ve=Q.useMemo(()=>W?null:typeof he==`string`&&he.trim().length>0?he:_e?.providerId??null,[W,he,_e]),ye=Q.useMemo(()=>W?null:typeof ge==`string`&&ge.trim().length>0?ge:_e?.modelId??null,[W,ge,_e]),be=e.info.id?BD(e.info.id):void 0;W||VD(e.info.id,{agent:pe,provider:ve??void 0,model:ye??void 0});let xe=pe??be?.agent,Se=ve??be?.provider??null,Ce=ye??be?.model??null,we=Q.useMemo(()=>{if(W)return;let e=Se&&A.length>0?A.find(e=>e.id===Se):void 0;return Gr(e,Ce)||void 0},[W,Se,Ce,A]),Te=HD(xe),Ee=HD(Se??void 0),Oe=HD(Ce??void 0),ke=HD(we),Ae=Te??void 0,je=Ee??null,Me=Oe??null,Ne=ke??void 0,Pe=Q.useMemo(()=>{let t=e.info.time;return typeof t?.completed==`number`?t.completed:null},[e.info.time]),Fe=Q.useMemo(()=>{let t=e.info.time;return typeof t?.created==`number`?t.created:null},[e.info.time]),Ie=Q.useMemo(()=>W?!0:!!(Pe&&Pe>0),[W,Pe]),Le=Q.useMemo(()=>{let t=e.info.finish;return typeof t==`string`?t:void 0},[e.info]),Re=Q.useMemo(()=>pd(de,{includeReasoning:j}),[de,j]),ze=Q.useMemo(()=>W?Re:!Ie&&N===`sorted`?[]:Re,[N,Ie,W,Re]),Be=Q.useMemo(()=>W?[]:Re.filter(e=>e.type===`text`),[W,Re]),Ve=Q.useMemo(()=>W?[]:Re.filter(e=>e.type===`tool`),[W,Re]),He=Q.useMemo(()=>{if(!P)return new Set;let e=new Set;for(let t of Ve){let n=typeof t?.id==`string`?t.id:``;if(!n)continue;let r=ND(t.tool);!r||!MD.has(r)||e.add(n)}for(let t of a?.activityParts??[]){if(t.kind!==`tool`)continue;let n=ND(t.part.tool);!n||!MD.has(n)||e.add(t.id)}return e},[P,Ve,a?.activityParts]),Ue=Q.useMemo(()=>{if(He.size===0&&U.size===0)return V;let e=new Set(V);return He.forEach(t=>{U.has(t)||e.add(t)}),U.forEach(t=>{e.delete(t)}),e},[U,He,V]),Ge=Q.useMemo(()=>{if(!W)return;let e=de.find(e=>e.type===`agent`);if(!e)return;let t=e,n=typeof t.name==`string`?t.name:void 0;if(n)return{name:n,token:t.source&&typeof t.source.value==`string`&&t.source.value.trim().length>0?t.source.value:`@${n}`}},[W,de]),Ke=W&&!tc(ze),qe=typeof Le!=`string`,Je=Q.useMemo(()=>W?!1:Be.length===0||Ve.length===0?qe:!0,[Be.length,Ve.length,qe,W]),Ye=Q.useMemo(()=>!W&&yc.getInstance().shouldAnimateMessage(e.info,C||e.info.sessionID),[e.info,C,W]),[Xe,Ze]=Q.useState(!1),Qe=Q.useMemo(()=>n?tD(n.info):null,[n]),$e=!!a,et=a?.isLastAssistantInTurn??!1,tt=bD({isWorking:a?.isWorking===!0,isInActiveTurn:c,headerCompletionDisposition:a?.completionDisposition}),nt=Q.useMemo(()=>W?!1:$e?!et:Qe?!Qe.isUser&&Qe.role===`assistant`:!1,[$e,et,W,Qe]),rt=Q.useMemo(()=>Ie?`completed`:c?l??`streaming`:`completed`,[l,c,Ie]);Q.useEffect(()=>{!W||!u||d?.(e.info.id)},[u,W,e.info.id,d]),Q.useEffect(()=>{Ze(!1)},[e.info.id]),Q.useEffect(()=>{let t=o??a?.headerMessageId;W||!t||t!==e.info.id||(rt===`streaming`||rt===`cooldown`)&&Ze(!0)},[o,W,e.info.id,rt,a?.headerMessageId]);let it=Q.useMemo(()=>{if(W)return!0;if(s)return!1;let t=o??a?.headerMessageId;return t?e.info.id===t?rt===`completed`||Xe||rt===`streaming`||rt===`cooldown`:!1:!0},[o,Xe,W,a,rt,e.info.id,s]),at=Q.useCallback(e=>{ki(e).then(t=>{t.ok&&(I(e),setTimeout(()=>I(null),2e3))})},[]),ot=W?void 0:me?.variant??a?.userMessageVariant??fe?.variant,st=!W&&typeof ot==`string`&&ot.trim().length>0?ot:void 0,ct=Q.useMemo(()=>{if(!W&&!cD($e?et:!nt))return aD(e.info?.error,f)},[$e,nt,et,W,e.info,f]),lt=ct?.text,ut=Q.useMemo(()=>{if(W){let e=ze.filter(e=>e.type===`text`).map(e=>{let t=e.shellAction?.output;return typeof t==`string`?t.trim():``}).filter(e=>e.length>0);if(e.length>0)return e.join(`
53
+ `),cT=e=>typeof e!=`number`||!Number.isFinite(e)||e<0?0:e,lT=e=>{let t=0,n=0,r=!0;return e.map(e=>{if(typeof e.createdAt==`number`&&Number.isFinite(e.createdAt)&&typeof e.streamedAt==`number`&&Number.isFinite(e.streamedAt)?n+=Math.max(0,e.streamedAt-e.createdAt):r=!1,t+=cT(e.outputTokens)+cT(e.reasoningTokens),!r||t<=0||n<=0)return null;let i=t/(n/1e3);return Number.isFinite(i)&&i>0?i:null})},uT=e=>{let t=lT(e);return t[t.length-1]??null},dT=e=>e.completionDisposition!==`active`&&typeof e.tps==`number`&&Number.isFinite(e.tps)&&e.tps>0,fT=e=>!Number.isFinite(e)||e<=0?``:`${e.toFixed(1)} tok/s`,pT=e=>{let t=(0,Z.c)(5),{sessionId:n,scope:r}=e,{t:i}=na(),a=Sn(n,r);if(a===0)return null;let o;t[0]!==a||t[1]!==i?(o=i(`chat.sessionBackground.tasksRunning`,{count:a}),t[0]=a,t[1]=i,t[2]=o):o=t[2];let s;return t[3]===o?s=t[4]:(s=(0,$.jsx)(`span`,{className:`inline-flex h-3.5 shrink-0 items-center whitespace-nowrap text-[11px] leading-none font-normal text-muted-foreground`,"data-background-activity":`true`,children:(0,$.jsx)(`span`,{className:`animate-text-shimmer`,children:o})}),t[3]=o,t[4]=s),s},mT=Q.memo(e=>{let t=(0,Z.c)(5),{sessionId:n,activityParts:r}=e,i;t[0]===r?i=t[1]:(i=Bx((r??[]).map(hT)),t[0]=r,t[1]=i);let a=i;if(a.childSessionIDs.size===0&&a.shellIDs.size===0)return null;let o;return t[2]!==a||t[3]!==n?(o=(0,$.jsx)(pT,{sessionId:n,scope:a}),t[2]=a,t[3]=n,t[4]=o):o=t[4],o});mT.displayName=`BackgroundActivityHint`;function hT(e){return e.part}var gT=e=>{let t=(0,Z.c)(20),{text:n,active:r,className:i}=e,a=Q.useRef(n),[o,s]=Q.useState(n),[c,l]=Q.useState(null),u,d;t[0]!==r||t[1]!==n?(u=()=>{if(n===a.current)return;let e=a.current;if(a.current=n,!r||e.length===0){l(null),s(n);return}l(e),s(n)},d=[r,n],t[0]=r,t[1]=n,t[2]=u,t[3]=d):(u=t[2],d=t[3]),Q.useEffect(u,d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{l(null)},t[4]=f):f=t[4];let p=G(f),m;t[5]===i?m=t[6]:(m=J(`yuri-summary-flip-viewport relative block h-5 min-h-0 w-full min-w-0 max-w-full overflow-clip sm:h-6`,i),t[5]=i,t[6]=m);let h=c&&`invisible`,g;t[7]===h?g=t[8]:(g=J(`block h-full min-w-0 truncate leading-5 sm:leading-6`,h),t[7]=h,t[8]=g);let _;t[9]!==o||t[10]!==g?(_=(0,$.jsx)(`span`,{className:g,children:o}),t[9]=o,t[10]=g,t[11]=_):_=t[11];let v;t[12]!==o||t[13]!==p||t[14]!==c?(v=c?(0,$.jsxs)(`span`,{className:`yuri-summary-flip-stage absolute inset-0 block overflow-clip`,children:[(0,$.jsx)(`span`,{className:`yuri-summary-flip-out absolute inset-x-0 top-0 block h-full truncate`,"aria-hidden":`true`,children:c}),(0,$.jsx)(`span`,{className:`yuri-summary-flip-in absolute inset-x-0 top-0 block h-full truncate`,onAnimationEnd:p,children:o})]}):null,t[12]=o,t[13]=p,t[14]=c,t[15]=v):v=t[15];let y;return t[16]!==m||t[17]!==_||t[18]!==v?(y=(0,$.jsxs)(`span`,{className:m,children:[_,v]}),t[16]=m,t[17]=_,t[18]=v,t[19]=y):y=t[19],y},_T=[`search`,`read`,`list`];function vT(e){let t=xC(e);return t===`read`?`read`:t===`glob`||t===`grep`?`search`:t===`list`?`list`:null}function yT(e){let t={read:0,search:0,list:0};for(let n of e){let e=vT(n);e&&(t[e]+=1)}return t}var bT=[`edit`,`command`,`other`],xT=new Set([`edit`,`multiedit`,`write`,`create`,`file_write`,`apply_patch`,`patch`]),ST=new Set([`bash`,`shell`,`cmd`,`command`,`exec`,`terminal`]);function CT(e){if(!_C(e))return null;let t=xC(e);return xT.has(t)?`edit`:ST.has(t)?`command`:`other`}function wT(e){let t={edit:0,command:0,other:0};for(let n of e){let e=CT(n);e&&(t[e]+=1)}return t}function TT(e){return WS(e)}var ET=[..._T,...bT];function DT(e){return{...yT(e),...wT(e)}}function OT(e){return bC(e)}function kT(e){return e.kind===`reasoning`||e.type===`reasoning`?!1:e.kind===`justification`||e.type===`text`?!0:e.kind===`tool`||e.type===`tool`?!vC(e.toolName):e.kind!=null||e.type!=null}function AT(e,t,n){for(let r=t;r<e.length;r+=1)if(kT(n(e[r])))return!0;return!1}function jT(e){return`parts`in e?e.parts.some(e=>OT(e))?!0:!e.hasFollowingOtherType&&e.isTurnLive:e.some(e=>OT(e))}function MT(e,t,n){let r=[],i=t;for(;i<e.length&&vC(n(e[i]));)r.push(e[i]),i+=1;return{items:r,end:i}}var NT=`!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal`,PT=e=>{let t=(0,Z.c)(12),{added:n,removed:r}=e;if(n<=0&&r<=0)return null;let i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=J(`inline-flex flex-none items-center gap-0.5 tabular-nums`,NT),t[0]=i):i=t[0];let a;t[1]===n?a=t[2]:(a=n>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-success)`},children:[`+`,n]}):null,t[1]=n,t[2]=a);let o;t[3]!==n||t[4]!==r?(o=n>0&&r>0?(0,$.jsx)(`span`,{style:{color:`var(--tools-description)`},children:`/`}):null,t[3]=n,t[4]=r,t[5]=o):o=t[5];let s;t[6]===r?s=t[7]:(s=r>0?(0,$.jsxs)(`span`,{style:{color:`var(--status-error)`},children:[`-`,r]}):null,t[6]=r,t[7]=s);let c;return t[8]!==a||t[9]!==o||t[10]!==s?(c=(0,$.jsxs)(`span`,{className:i,children:[a,o,s]}),t[8]=a,t[9]=o,t[10]=s,t[11]=c):c=t[11],c},FT=({activities:e,isMobile:t,isTurnLive:n=!1,hasFollowingOtherType:r=!1,exploring:i,children:a})=>{let{t:o}=na(),[s,c]=Q.useState(!1),l=Q.useId(),u=e.map(e=>e.part),d=i??jT({parts:u,hasFollowingOtherType:r,isTurnLive:n}),f=DT(u.map(e=>e.tool)),p=TT(u),m=ET.filter(e=>f[e]>0).map(e=>{let t=f[e];return o(e===`search`?t===1?`chat.contextGroup.searchSingle`:`chat.contextGroup.searchPlural`:e===`read`?t===1?`chat.contextGroup.readSingle`:`chat.contextGroup.readPlural`:e===`list`?t===1?`chat.contextGroup.listSingle`:`chat.contextGroup.listPlural`:e===`edit`?t===1?`chat.usedGroup.editSingle`:`chat.usedGroup.editPlural`:e===`command`?t===1?`chat.usedGroup.commandSingle`:`chat.usedGroup.commandPlural`:t===1?`chat.usedGroup.otherSingle`:`chat.usedGroup.otherPlural`,{count:t})}).join(`, `),h=G(()=>{c(e=>!e)}),g=G(e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),h())}),_=o(s?`chat.usedGroup.collapseAria`:`chat.usedGroup.expandAria`),v=o(d?`chat.usedGroup.running`:`chat.usedGroup.used`),y=t?`h-5`:`h-6`;return(0,$.jsxs)(`div`,{"data-component":`context-tool-group`,className:fm(t),children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":s,"aria-controls":l,"aria-label":_,"data-mobile-press-feedback":`soft`,className:J(`flex min-h-0 min-w-0 items-center gap-1.5 overflow-clip`,hm),onClick:h,onKeyDown:g,children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center self-center`,y,t?`w-4`:`w-3.5`),style:{color:`var(--tools-icon)`},children:d?(0,$.jsx)(rC,{isMobile:t,label:o(`chat.usedGroup.running`),className:`block`}):(0,$.jsx)(X,{name:`search`,className:`block h-[13px] w-[13px]`})}),(0,$.jsx)(`span`,{className:J(`typography-meta inline-flex flex-none items-center self-center font-medium`,y,NT,d&&`animate-text-shimmer`),style:{color:`var(--tools-title)`,...d?{"--yuri-text-shimmer-base":`var(--tools-title)`}:{}},children:v}),m?(0,$.jsx)(`span`,{className:J(`typography-meta inline-flex min-h-0 w-0 min-w-0 max-w-full flex-1 items-center self-center overflow-clip`,y,NT),style:{color:`var(--tools-description)`},children:(0,$.jsx)(gT,{text:m,active:d,className:t?`!h-5 sm:!h-5`:`!h-6 sm:!h-6`})}):null,(0,$.jsx)(PT,{added:p.added,removed:p.removed}),(0,$.jsx)(X,{name:s?`arrow-down-s`:`arrow-right-s`,className:`ml-auto size-3.5 flex-none self-center text-muted-foreground opacity-70`})]}),s&&a?(0,$.jsxs)(`div`,{id:l,className:pm(t),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0 left-0 top-0 w-px opacity-40`,style:{backgroundColor:`var(--tools-border)`}}),a]}):null]})};function IT(e,t,n){let r=[],i=t;for(;i<e.length&&gC(n(e[i]));)r.push(e[i]),i+=1;return{items:r,end:i}}var LT=e=>{if(typeof e!=`string`)return null;let t=e.trim();return t.length>0?t:null};function RT(e){if(!e||typeof e!=`object`)return null;let t=e.state;if(!t||typeof t!=`object`)return null;let n=t;if(n.metadata&&typeof n.metadata==`object`){let e=LT(n.metadata.name);if(e)return e}if(n.input&&typeof n.input==`object`){let e=n.input,t=LT(e.name);if(t)return t;let r=LT(e.id);if(r)return r}if(n.output&&typeof n.output==`object`){let e=LT(n.output.name);if(e)return e}return null}function zT(e){let t=[];for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();e&&t.push(e)}let n=t.slice(0,3);return{visibleNames:n,hiddenCount:Math.max(0,t.length-n.length),joinedVisible:n.join(`, `)}}var BT=`!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal`,VT=({activities:e,isMobile:t,children:n})=>{let{t:r}=na(),[i,a]=Q.useState(!1),o=Q.useId(),s=e.map(e=>e.part),c=s.some(e=>bC(e)),{joinedVisible:l,hiddenCount:u}=zT(s.map(RT)),d=u>0?r(`chat.skillGroup.summaryOverflow`,{names:l,count:u}):l,f=G(()=>{a(e=>!e)}),p=G(e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f())}),m=r(i?`chat.skillGroup.collapseAria`:`chat.skillGroup.expandAria`),h=r(`chat.tools.display.skill`);return(0,$.jsxs)(`div`,{"data-component":`skill-tool-group`,className:fm(t),children:[(0,$.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,"aria-controls":o,"aria-label":m,"data-mobile-press-feedback":`soft`,className:J(`flex min-h-0 min-w-0 items-center gap-1.5 overflow-clip`,hm),onClick:f,onKeyDown:p,children:[(0,$.jsx)(`span`,{className:J(`flex flex-none items-center justify-center`,t?`size-4`:`size-3.5`),style:{color:`var(--tools-icon)`},children:c?(0,$.jsx)(rC,{isMobile:t,label:h,className:`block`}):(0,$.jsx)(X,{name:`book`,className:`h-[13px] w-[13px]`})}),(0,$.jsx)(`span`,{className:J(`typography-meta flex-none font-medium`,BT,c&&`animate-text-shimmer`),style:{color:`var(--tools-title)`,...c?{"--yuri-text-shimmer-base":`var(--tools-title)`}:{}},children:h}),d?(0,$.jsx)(`span`,{className:J(`typography-meta h-5 min-h-0 w-0 min-w-0 max-w-full flex-1 overflow-clip sm:h-6`,BT),style:{color:`var(--tools-description)`},children:(0,$.jsx)(gT,{text:d,active:c})}):null,(0,$.jsx)(X,{name:i?`arrow-down-s`:`arrow-right-s`,className:`ml-auto size-3.5 flex-none text-muted-foreground opacity-70`})]}),i&&n?(0,$.jsxs)(`div`,{id:o,className:pm(t),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`pointer-events-none absolute bottom-0 left-0 top-0 w-px opacity-40`,style:{backgroundColor:`var(--tools-border)`}}),n]}):null]})},HT=Q.memo(e=>{let t=(0,Z.c)(18),{part:n,messageId:r,onContentChange:i,actions:a,streamPhase:o,onShowPopup:s}=e,c=ln(UT),l=n,u=typeof l.text==`string`?l.text:``,d=typeof l.content==`string`?l.content:``,f=d.length>u.length?d:u,p=l.time,m=n.sessionID,h=o===void 0||o!==`completed`,g,_;if(t[0]!==i||t[1]!==f?(g=()=>{f.trim().length!==0&&i?.(`structural`)},_=[i,f],t[0]=i,t[1]=f,t[2]=g,t[3]=_):(g=t[2],_=t[3]),Q.useEffect(g,_),!f||f.trim().length===0)return null;let v=o??`streaming`,y=h&&typeof p?.end!=`number`,b;t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==s||t[8]!==n||t[9]!==m||t[10]!==v||t[11]!==y?(b=(0,$.jsx)(`div`,{"data-message-text-export-source":`true`,children:(0,$.jsx)(Uw,{part:n,sessionId:m,messageId:r,streamPhase:v,chatRenderMode:c,hasStreamingHapticLifecycle:y,onContentChange:i,onShowPopup:s})}),t[4]=c,t[5]=r,t[6]=i,t[7]=s,t[8]=n,t[9]=m,t[10]=v,t[11]=y,t[12]=b):b=t[12];let x;t[13]===a?x=t[14]:(x=a?(0,$.jsx)(`div`,{className:`mt-2 mb-1 flex items-center justify-start gap-1.5`,"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-1.5`,"data-message-action-group":`true`,children:a})}):null,t[13]=a,t[14]=x);let S;return t[15]!==b||t[16]!==x?(S=(0,$.jsxs)(`div`,{"data-message-text-export-root":`true`,children:[b,x]}),t[15]=b,t[16]=x,t[17]=S):S=t[17],S});function UT(e){return e.chatRenderMode}var WT=e=>{let t=Math.max(0,Math.round(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`},GT=`!text-[length:var(--text-meta)] !leading-5 sm:!leading-6 tracking-normal`,KT=J(`typography-meta font-medium`,GT),qT=J(`typography-meta`,GT),JT=[],YT=e=>{let t=e.part;return t.slim===!0&&(t.type===`tool`||t.type===`reasoning`||t.type===`file`)},XT=e=>{let t=new Set;for(let n of e)YT(n)&&n.messageId&&t.add(n.messageId);return[...t]},ZT=(e,t)=>e.some(e=>{if(!t.has(e.messageId))return!1;let n=e.part;if(n.slim===!0)return!1;if(n.type===`reasoning`)return typeof n.text==`string`&&n.text.trim().length>0;if(n.type===`file`)return typeof n.url==`string`&&n.url.trim().length>0;if(n.type===`tool`){let e=n.state?.output,t=n.state?.error;return(typeof e==`string`?e.trim().length>0:e!=null)||(typeof t==`string`?t.trim().length>0:t!=null)}return!1}),QT=e=>{let t=(0,Z.c)(5),{href:n}=e,[r,i]=Q.useState(!1),a;t[0]===n?a=t[1]:(a=pn(n),t[0]=n,t[1]=a);let o=a;if(!o||r)return null;let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>i(!0),t[2]=s):s=t[2];let c;return t[3]===o?c=t[4]:(c=(0,$.jsx)(`span`,{className:`inline-flex size-[18px] flex-shrink-0 items-center justify-center rounded border border-[var(--border)] bg-[var(--interactive-hover)]`,children:(0,$.jsx)(`img`,{src:o,alt:``,"aria-hidden":`true`,loading:`lazy`,decoding:`async`,className:`size-3.5 rounded-sm`,onError:s})}),t[3]=o,t[4]=c),c},$T=e=>e,eE=e=>{let t=e.part.state,n=t?.input,r=t?.metadata,i=n?.filePath||n?.file_path||n?.path||r?.filePath||r?.file_path||r?.path;if(typeof i==`string`&&i.trim().length>0){let e=i.lastIndexOf(`/`);return e>=0?i.slice(e+1):i}return null},tE=e=>{let t=e.part.state,n=t?.input,r=t?.metadata,i=n?.filePath||n?.file_path||n?.path||r?.filePath||r?.file_path||r?.path;return typeof i==`string`&&i.trim().length>0?i:null},nE=e=>{let t=e.part.state?.metadata?.dir;return typeof t==`string`&&t.trim().length>0?t:null},rE=e=>{if(typeof e!=`string`)return null;let t=e.trim().toLowerCase();return t===`pending`?`pending`:t===`in_progress`||t===`in progress`||t===`inprogress`?`in_progress`:t===`completed`||t===`done`?`completed`:t===`cancelled`||t===`canceled`?`cancelled`:null},iE=e=>{if(e.length===0)return`0 tasks`;let t=0,n=0;for(let r of e){if(!r||typeof r!=`object`)continue;let e=rE(r.status);e&&(e===`pending`&&(t+=1),e===`in_progress`&&(n+=1))}let r=t+n;return r===0?`0 tasks`:`${r} ${r===1?`task`:`tasks`}`},aE=e=>{let t=e.part.state,n=t?.input,r=t?.output;if(Array.isArray(n?.todos)){let e=iE(n.todos);if(e)return e}if(Array.isArray(r)){let e=iE(r);if(e)return e}if(r&&typeof r==`object`&&Array.isArray(r.todos)){let e=iE(r.todos);if(e)return e}if(typeof r==`string`&&r.trim().length>0)try{let e=JSON.parse(r);if(Array.isArray(e)){let t=iE(e);if(t)return t}if(e&&typeof e==`object`&&Array.isArray(e.todos)){let t=iE(e.todos);if(t)return t}}catch{}return null},oE=e=>{let t=e.part.state,n=t?.input,r=t?.metadata,i=(typeof n?.offset==`number`&&Number.isFinite(n.offset)?n.offset:void 0)??(typeof n?.line==`number`&&Number.isFinite(n.line)?n.line:void 0)??(typeof r?.offset==`number`&&Number.isFinite(r.offset)?r.offset:void 0)??(typeof r?.line==`number`&&Number.isFinite(r.line)?r.line:void 0);if(!(typeof i!=`number`||i<=0))return Math.floor(i)},sE=(e,t=!0)=>{let n=e.lastIndexOf(`/`);if(n===-1)return(0,$.jsx)(Ib,{variant:t?`generate-effect`:`static`,className:J(`min-w-0 flex-1 truncate whitespace-nowrap`,qT),style:{color:`var(--tools-description)`},title:e,children:e});let r=e.slice(0,n),i=e.slice(n+1),a=r.startsWith(`/`),o=a?r.slice(1):r;return(0,$.jsxs)(`span`,{className:J(`min-w-0 inline-flex max-w-full flex-1 items-baseline overflow-hidden`,qT),title:e,children:[a?(0,$.jsx)(`span`,{className:`flex-shrink-0`,style:{color:`var(--tools-description)`},children:`/`}):null,(0,$.jsx)(`span`,{className:`min-w-0 shrink truncate whitespace-nowrap`,style:{color:`var(--tools-description)`,direction:`rtl`,textAlign:`left`,unicodeBidi:`plaintext`},children:o}),(0,$.jsx)(`span`,{className:`flex-shrink-0`,style:{color:`var(--tools-description)`},children:`/`}),(0,$.jsx)(Ib,{variant:t?`generate-effect`:`static`,className:`flex-shrink-0`,style:{color:`var(--tools-description)`},children:i})]})},cE=e=>{let t=Gt(e);return t?t.toLowerCase().endsWith(`/skill.md`)?t:`${t}/SKILL.md`:``},lE=e=>{let t=e.part,n=t.tool?.toLowerCase()??``,r=t.state,i=r?.input,a=r?.metadata;if(n===`grep`||n===`search`||n===`find`||n===`ripgrep`){let e=i?.pattern;if(typeof e==`string`&&e.trim().length>0)return e.length>40?e.slice(0,40)+`...`:e}if(n===`glob`){let e=i?.pattern;if(typeof e==`string`&&e.trim().length>0)return e.length>40?e.slice(0,40)+`...`:e}if(n===`websearch`||n===`web-search`||n===`search_web`||n===`codesearch`||n===`perplexity`){let e=i?.query;if(typeof e==`string`&&e.trim().length>0)return e.length>50?e.slice(0,50)+`...`:e}if(n===`skill`)return RT(t);if(n===`webfetch`||n===`fetch`||n===`curl`||n===`wget`){let e=typeof i?.url==`string`&&i.url||typeof i?.URL==`string`&&i.URL||typeof a?.url==`string`&&a.url||typeof a?.URL==`string`&&a.URL||``;if(typeof e==`string`&&e.trim().length>0)return e.trim()}return n===`todowrite`||n===`todoread`?aE(e):eE(e)},uE=e=>{let t=new Set,n=new Set;for(let r of e){if(r.kind!==`tool`)continue;let e=r.part;if(!Zb(e.tool))continue;let i=typeof e.id==`string`?e.id.trim():``;if(!i)continue;let a=e.state;if(!a||typeof a!=`object`)continue;let o=a,s=ax(e)||i;n.add(s),(o.status===`pending`||o.status===`running`)&&t.add(s)}return{active:[...t],all:[...n]}},dE=Q.memo(e=>{let t=(0,Z.c)(16),{activity:n,isExpanded:r,isMobile:i,onToggleTool:a,onShowPopup:o,onContentChange:s}=e,c;t[0]!==n.id||t[1]!==a?(c=()=>{a(n.id)},t[0]=n.id,t[1]=a,t[2]=c):c=t[2];let l=G(c),u;t[3]===i?u=t[4]:(u=fm(i),t[3]=i,t[4]=u);let d=n.part,f;t[5]!==n.messageId||t[6]!==l||t[7]!==r||t[8]!==i||t[9]!==s||t[10]!==o||t[11]!==d?(f=(0,$.jsx)(kw,{part:d,messageId:n.messageId,isExpanded:r,onToggle:l,isMobile:i,onContentChange:s,onShowPopup:o,animateTailText:!1}),t[5]=n.messageId,t[6]=l,t[7]=r,t[8]=i,t[9]=s,t[10]=o,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==u||t[14]!==f?(p=(0,$.jsx)(`div`,{className:u,children:f}),t[13]=u,t[14]=f,t[15]=p):p=t[15],p},(e,t)=>e.isExpanded===t.isExpanded&&e.isMobile===t.isMobile&&e.onToggleTool===t.onToggleTool&&e.onShowPopup===t.onShowPopup&&e.onContentChange===t.onContentChange&&e.activity.id===t.activity.id&&e.activity.messageId===t.activity.messageId&&e.activity.kind===t.activity.kind&&e.activity.endedAt===t.activity.endedAt&&eS([e.activity.part],[t.activity.part])),fE=Q.memo(e=>{let t=(0,Z.c)(9),{toolName:n,activities:r,isMobile:i}=e,a;t[0]===i?a=t[1]:(a=fm(i),t[0]=i,t[1]=a);let o;t[2]!==r||t[3]!==i||t[4]!==n?(o=(0,$.jsx)(hE,{toolName:n,activities:r,isMobile:i,animateTailText:!1}),t[2]=r,t[3]=i,t[4]=n,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,$.jsx)(`div`,{className:a,children:o}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s},(e,t)=>e.toolName===t.toolName&&e.isMobile===t.isMobile&&mE(e.activities,t.activities)),pE=e=>{let t=[],n=0;for(;n<e.length;){let r=e[n];if(r.kind===`reasoning`){if(!xd(r.part).trim()){n++;continue}t.push({type:`reasoning`,activity:r}),n++;continue}if(r.kind===`justification`){t.push({type:`justification`,activity:r}),n++;continue}let i=r.part.tool?.toLowerCase()??``;if(vC(i)){let r=MT(e,n,e=>e.part.tool);t.push({type:`tool-context-group`,activities:r.items,hasFollowingOtherType:AT(e,r.end,e=>({kind:e.kind,toolName:e.part.tool}))}),n=r.end;continue}if(gC(i)){let r=IT(e,n,e=>e.part.tool);if(r.items.length>0){t.push({type:`tool-skill-group`,activities:r.items}),n=r.end;continue}}if(pC(i)){t.push({type:`tool-expandable`,activity:r}),n++;continue}if(fC(i)){t.push({type:`tool-expandable`,activity:r}),n++;continue}if(mC(i)){t.push({type:`tool-static-group`,toolName:i,activities:[r]}),n++;continue}t.push({type:`tool-fallback`,activity:r}),n++}return t},mE=(e,t)=>{if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.id!==i.id||r.kind!==i.kind||r.endedAt!==i.endedAt||!eS([r.part],[i.part]))return!1}return!0},hE=Q.memo(e=>{let t=(0,Z.c)(108),{toolName:n,activities:r,isMobile:i,animateTailText:a}=e,{t:o}=na(),s=ln(yE),c=oa(n,o),l;t[0]===n?l=t[1]:(l=Bb(n),t[0]=n,t[1]=l);let u=l,d;t[2]===n?d=t[3]:(d=n.toLowerCase(),t[2]=n,t[3]=d);let f=d===`read`,p=Q.useContext(Wt),m=Rt(),h=m?.entry.location.hostId?m.entry:void 0,g=ga(),_=qe(bE),v=Xo(),y=v.kind===`embedded`?v.directory:_,b;t[4]===n?b=t[5]:(b=n.toLowerCase(),t[4]=n,t[5]=b);let x=b===`skill`,S;t[6]===x?S=t[7]:(S={enabled:x},t[6]=x,t[7]=S);let C=En(S),w;t[8]===C.data?w=t[9]:(w=C.data??[],t[8]=C.data,t[9]=w);let T=w,E;t[10]===T?E=t[11]:(E=new Map(T.map(xE)),t[10]=T,t[11]=E);let D=E,O=r[0]??null,k=!O||bC(O.part),A;t[12]===O?A=t[13]:(A=O?lE(O):null,t[12]=O,t[13]=A);let j=A,M;if(t[14]!==j||t[15]!==O||t[16]!==D||t[17]!==n){bb0:{if(n.toLowerCase()!==`skill`||!O||!j){M=null;break bb0}let e=D.get(j)?.path||nE(O);if(!e||e===`<built-in>`){M=null;break bb0}let r=cE(e);if(!r){M=null;break bb0}let i;t[19]!==j||t[20]!==r?(i={name:j,path:r},t[19]=j,t[20]=r,t[21]=i):i=t[21],M=i}t[14]=j,t[15]=O,t[16]=D,t[17]=n,t[18]=M}else M=t[18];let N=M,P;if(t[22]!==y||t[23]!==f||t[24]!==O){bb1:{if(!f||!O){P=null;break bb1}let e=tE(O);if(!e){P=null;break bb1}let n=qt(e,y);if(!n){P=null;break bb1}let r;t[26]===O?r=t[27]:(r=oE(O),t[26]=O,t[27]=r);let i;t[28]!==n||t[29]!==e||t[30]!==r?(i={path:e,displayPath:n,offset:r},t[28]=n,t[29]=e,t[30]=r,t[31]=i):i=t[31],P=i}t[22]=y,t[23]=f,t[24]=O,t[25]=P}else P=t[25];let F=P,I;t[32]!==y||t[33]!==h||t[34]!==g||t[35]!==p?(I=(e,t)=>{if(!y)return;let n=Jt(y,e);if(!n)return;if(g){g.openFile({path:n,targetLine:t&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):void 0});return}if(!h&&p?.editor){p.editor.openFile(n,t);return}if(!h&&!Kt(n,y)){ic(n,y).then(()=>{let e=ln.getState(),r=y||Yt(y,n);if(t&&Number.isFinite(t)){e.openContextFileAtLine(r,n,Math.max(1,Math.trunc(t)),1);return}e.openContextFile(r,n)});return}let r=ln.getState(),i=h?.key??Yt(y,n);if(t&&Number.isFinite(t)){r.openContextFileAtLine(i,n,Math.max(1,Math.trunc(t)),1);return}r.openContextFile(i,n)},t[32]=y,t[33]=h,t[34]=g,t[35]=p,t[36]=I):I=t[36];let L=G(I),R;t[37]!==y||t[38]!==h||t[39]!==g?(R=e=>{let t=Gt(e);if(!t)return;let n=()=>{if(g){g.openFile({path:t});return}let e=ln.getState(),n=h?.key??(y||Yt(``,t));e.openContextFile(n,t)};if(!h&&y&&!Kt(t,y)){ic(t,y).then(n);return}n()},t[37]=y,t[38]=h,t[39]=g,t[40]=R):R=t[40];let ee=G(R),z;t[41]===n?z=t[42]:(z=n.toLowerCase(),t[41]=n,t[42]=z);let B=z,V=B===`grep`||B===`search`||B===`find`||B===`ripgrep`||B===`glob`,H=B===`webfetch`||B===`fetch`||B===`curl`||B===`wget`,U=B===`skill`,te=!!(F||N),ne=!!(F&&y||N),re;t[43]!==ne||t[44]!==L||t[45]!==ee||t[46]!==te||t[47]!==F||t[48]!==N?(re=()=>{if(!(!te||!ne)){if(F){L(F.path,F.offset);return}N&&ee(N.path)}},t[43]=ne,t[44]=L,t[45]=ee,t[46]=te,t[47]=F,t[48]=N,t[49]=re):re=t[49];let W=G(re),ie;t[50]===W?ie=t[51]:(ie=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),W())},t[50]=W,t[51]=ie);let ae=G(ie),oe=te&&ne&&`cursor-pointer`,se=te&&!ne&&`cursor-default opacity-70`,ce;t[52]!==oe||t[53]!==se?(ce=J(`flex w-full items-center gap-x-1.5 min-w-0`,hm,oe,se),t[52]=oe,t[53]=se,t[54]=ce):ce=t[54];let le=te?`soft`:void 0,ue=te?W:void 0,de=te?ae:void 0,fe=te?`button`:void 0,pe=te&&ne?0:void 0,me=te&&!ne?!0:void 0,he=i?`size-4`:`size-3.5`,ge;t[55]===he?ge=t[56]:(ge=J(`inline-flex items-center justify-center flex-shrink-0`,he),t[55]=he,t[56]=ge);let _e;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(_e={color:`var(--tools-icon)`},t[57]=_e):_e=t[57];let ve=k?(0,$.jsx)(rC,{isMobile:i,label:o(`chat.assistantStatus.usingTool`,{tool:c})}):u,ye;t[58]!==ge||t[59]!==_e||t[60]!==ve?(ye=(0,$.jsx)(`div`,{className:ge,style:_e,children:ve}),t[58]=ge,t[59]=_e,t[60]=ve,t[61]=ye):ye=t[61];let be,xe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(be=J(KT,`inline-flex items-center flex-shrink-0 opacity-85`),xe={color:`var(--tools-title)`},t[62]=be,t[63]=xe):(be=t[62],xe=t[63]);let Se;t[64]===c?Se=t[65]:(Se=(0,$.jsx)(`span`,{className:be,style:xe,title:c,children:c}),t[64]=c,t[65]=Se);let Ce;t[66]!==a||t[67]!==f||t[68]!==F||t[69]!==s?(Ce=f&&F?(0,$.jsxs)(`span`,{className:J(`inline-flex !min-h-0 items-center justify-start gap-1 min-w-0 flex-1 text-left`,qT),style:{color:`var(--tools-description)`},title:F.offset?`${F.displayPath}:${F.offset}`:F.displayPath,children:[s?(0,$.jsx)(ja,{filePath:F.path,className:`h-3.5 w-3.5`}):null,sE(F.displayPath,a)]}):null,t[66]=a,t[67]=f,t[68]=F,t[69]=s,t[70]=Ce):Ce=t[70];let we;t[71]!==a||t[72]!==j||t[73]!==V?(we=V&&j?(0,$.jsx)(`span`,{className:`inline-flex min-w-0 flex-1`,children:(0,$.jsxs)(Ib,{variant:a?`generate-effect`:`static`,className:J(`min-w-0 flex-1 truncate whitespace-nowrap`,qT),style:{color:`var(--tools-description)`},title:j,children:[`"`,j,`"`]})}):null,t[71]=a,t[72]=j,t[73]=V,t[74]=we):we=t[74];let Te;t[75]!==j||t[76]!==H?(Te=H&&j?(0,$.jsxs)(`a`,{href:j,target:`_blank`,rel:`noopener noreferrer`,onClick:SE,className:J(`min-w-0 flex-1 inline-flex items-center gap-1.5 underline decoration-[color:var(--status-info)] underline-offset-2 hover:opacity-90`,`truncate whitespace-nowrap`,qT),style:{color:`var(--status-info)`},title:j,children:[(0,$.jsx)(QT,{href:j}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:j})]}):null,t[75]=j,t[76]=H,t[77]=Te):Te=t[77];let Ee;t[78]!==U||t[79]!==N?(Ee=U&&N?(0,$.jsx)(`span`,{className:J(`!min-h-0 min-w-0 flex-1 truncate whitespace-nowrap text-left`,qT),style:{color:`var(--tools-description)`},title:N.path,children:N.name}):null,t[78]=U,t[79]=N,t[80]=Ee):Ee=t[80];let De;t[81]!==j||t[82]!==U||t[83]!==N?(De=U&&!N&&j?(0,$.jsx)(`span`,{className:J(`!min-h-0 min-w-0 flex-1 truncate whitespace-nowrap text-left`,qT),style:{color:`var(--tools-description)`},title:j,children:j}):null,t[81]=j,t[82]=U,t[83]=N,t[84]=De):De=t[84];let Oe;t[85]!==a||t[86]!==j||t[87]!==H||t[88]!==f||t[89]!==V||t[90]!==U?(Oe=!f&&!V&&!H&&!U&&j?(0,$.jsx)(Ib,{variant:a?`generate-effect`:`static`,className:J(`min-w-0 flex-1 truncate whitespace-nowrap`,qT),style:{color:`var(--tools-description)`},children:j}):null,t[85]=a,t[86]=j,t[87]=H,t[88]=f,t[89]=V,t[90]=U,t[91]=Oe):Oe=t[91];let ke;return t[92]!==ce||t[93]!==le||t[94]!==ue||t[95]!==de||t[96]!==fe||t[97]!==pe||t[98]!==me||t[99]!==ye||t[100]!==Se||t[101]!==Ce||t[102]!==we||t[103]!==Te||t[104]!==Ee||t[105]!==De||t[106]!==Oe?(ke=(0,$.jsxs)(`div`,{className:ce,"data-mobile-press-feedback":le,onClick:ue,onKeyDown:de,role:fe,tabIndex:pe,"aria-disabled":me,children:[ye,Se,Ce,we,Te,Ee,De,Oe]}),t[92]=ce,t[93]=le,t[94]=ue,t[95]=de,t[96]=fe,t[97]=pe,t[98]=me,t[99]=ye,t[100]=Se,t[101]=Ce,t[102]=we,t[103]=Te,t[104]=Ee,t[105]=De,t[106]=Oe,t[107]=ke):ke=t[107],ke},(e,t)=>e.toolName===t.toolName&&e.isMobile===t.isMobile&&e.animateTailText===t.animateTailText&&mE(e.activities,t.activities)),gE=Q.memo(e=>{let t=(0,Z.c)(5),{activity:n,onContentChange:r,streamPhase:i}=e,a;return t[0]!==n.messageId||t[1]!==n.part||t[2]!==r||t[3]!==i?(a=(0,$.jsx)(tT,{part:n.part,messageId:n.messageId,streamPhase:i,onContentChange:r}),t[0]=n.messageId,t[1]=n.part,t[2]=r,t[3]=i,t[4]=a):a=t[4],a}),_E=Q.memo(e=>{let t=(0,Z.c)(7),{activity:n,onContentChange:r,onShowPopup:i,actions:a,streamPhase:o}=e,s;return t[0]!==a||t[1]!==n.messageId||t[2]!==n.part||t[3]!==r||t[4]!==i||t[5]!==o?(s=(0,$.jsx)(HT,{part:n.part,messageId:n.messageId,onContentChange:r,onShowPopup:i,actions:a,streamPhase:o}),t[0]=a,t[1]=n.messageId,t[2]=n.part,t[3]=r,t[4]=i,t[5]=o,t[6]=s):s=t[6],s}),vE=Q.memo(({parts:e,materializationParts:t=e,isExpanded:n,collapsedPreviewCount:r=0,completionDisposition:i,activityPresentationKind:a=`default`,durationMs:o,onToggle:s,isMobile:c,expandedTools:l,onToggleTool:u,onShowPopup:d,onContentChange:f,streamPhase:p,showHeader:h,renderJustificationActions:g})=>{let{t:_}=na(),v=Ga()??``,y=Q.useMemo(()=>XT(t),[t]),b=Q.useRef(new Set),x=Q.useRef(new Map),S=Q.useRef(new Set),[,C]=Q.useState(0),w=Q.useRef(null),T=Q.useRef(null),E=i===`active`,D=!E&&(i===`normal`||i===`abnormal`)&&typeof o==`number`&&Number.isFinite(o)&&o>=0?WT(o):null,O=i===`normal`||i===`abnormal`,k=a===`compaction`,A=O&&!k,j=k?`fold-vertical`:`stack`,M=_(i===void 0?`chat.activity.title`:E?k?`chat.activity.compacting`:`chat.activity.active`:O?k?`chat.activity.compactionCompleted`:`chat.activity.completedStatus`:`chat.activity.title`),N=Q.useMemo(()=>{let t=[];for(let n of e)n.kind===`tool`&&t.push(n.part);return WS(t)},[e]),F=N.added>0||N.removed>0,I=Q.useMemo(()=>uE(e),[e]),L=E?I.active:I.all,R=L.slice(0,c?2:3),ee=G((e=!1,n=!1)=>{if(!(!v||!y.length)){for(let r of y){let i=t.find(e=>e.messageId===r)?.part.sessionID;if(!i)continue;let a=P(v,i,r);if(a.status===`ready`||n&&a.status===`error`||e&&a.status!==`error`&&!S.current.has(r)||(b.current.add(r),S.current.delete(r),x.current.has(r)))continue;let o=m(v,i,r,{priority:n?`background`:`user`}).catch(()=>{S.current.add(r)}).finally(()=>{x.current.delete(r),C(e=>e+1)});x.current.set(r,o)}C(e=>e+1)}}),z=G(e=>{e.stopPropagation(),ee(!0)}),B=E,V=B||n,H=G(()=>{if(B)return;let e=w.current;T.current=e?{top:e.getBoundingClientRect().top,scrollContainer:e.closest(`[data-scrollbar="chat"]`)}:null,V||ee(),s()});Q.useEffect(()=>{E||!V||ee(!1,!0)},[E,V]),Q.useLayoutEffect(()=>{let e=T.current,t=w.current;if(!e||!t)return;let n=()=>{if(!t.isConnected)return;let n=t.getBoundingClientRect().top-e.top;if(!(Math.abs(n)<.5)){if(e.scrollContainer?.isConnected){e.scrollContainer.scrollTop+=n;return}window.scrollBy(0,n)}};if(n(),typeof window>`u`||typeof window.requestAnimationFrame!=`function`){T.current=null;return}let r=window.requestAnimationFrame(()=>{n(),T.current=null});return()=>window.cancelAnimationFrame(r)},[V]);let U=h&&!V?Math.max(0,Math.floor(r)):0,te=!h||V||U>0,ne=b.current,re=[...ne].map(e=>{if(x.current.has(e))return`loading`;if(S.current.has(e))return`error`;let n=t.find(t=>t.messageId===e)?.part.sessionID??``;return P(v,n,e).status}),W=re.includes(`loading`),ie=re.includes(`error`),ae=re.length>0&&re.every(e=>e===`ready`),oe=t.some(e=>ne.has(e.messageId)&&YT(e)),se=ae&&!oe&&!ZT(t,ne),ce=Q.useMemo(()=>te?$T(e):JT,[e,te]),le=Q.useMemo(()=>te?pE(ce.filter(e=>e.kind!==`reasoning`||xd(e.part).trim().length>0)):[],[te,ce]),ue=Q.useMemo(()=>V||U===0?0:Math.max(0,le.length-U),[V,U,le.length]),de=Q.useMemo(()=>V||U===0?le:le.slice(-U),[V,U,le]),fe=!!h&&!(E&&!k);if((!fe||B&&!k)&&le.length===0)return null;let pe=(e,t)=>{let n=(0,$.jsx)(`div`,{className:fm(c),children:t});return(0,$.jsx)(Q.Fragment,{children:n},e)},me=te?de.map((e,t)=>{switch(e.type){case`reasoning`:return pe(e.activity.id,(0,$.jsx)($.Fragment,{children:(0,$.jsx)(gE,{activity:e.activity,streamPhase:p,onContentChange:f})}));case`justification`:return pe(e.activity.id,(0,$.jsx)($.Fragment,{children:(0,$.jsx)(_E,{activity:e.activity,onContentChange:f,onShowPopup:d,actions:g?.(e.activity),streamPhase:p})}));case`tool-expandable`:return(0,$.jsx)(dE,{activity:e.activity,isExpanded:l.has(e.activity.id),isMobile:c,onToggleTool:u,onShowPopup:d,onContentChange:f},e.activity.id);case`tool-static-group`:return(0,$.jsx)(fE,{toolName:e.toolName,activities:e.activities,isMobile:c},e.activities[0]?.id??`static-${e.toolName}-${t}`);case`tool-context-group`:return(0,$.jsx)(FT,{activities:e.activities,isMobile:c,isTurnLive:E,hasFollowingOtherType:e.hasFollowingOtherType,children:e.activities.map(e=>{let t=e.part,n=t.tool?.toLowerCase()??``;return hC(n)?(0,$.jsx)(hE,{toolName:n,activities:[e],isMobile:c,animateTailText:!1},e.id):(0,$.jsx)(kw,{part:t,messageId:e.messageId,isExpanded:l.has(e.id),onToggle:u,isMobile:c,onContentChange:f,onShowPopup:d,animateTailText:!1},e.id)})},e.activities[0]?.id??`context-${t}`);case`tool-skill-group`:return(0,$.jsx)(VT,{activities:e.activities,isMobile:c,children:e.activities.map(e=>{let t=e.part;return(0,$.jsx)(hE,{toolName:t.tool?.toLowerCase()??``,activities:[e],isMobile:c,animateTailText:!1},e.id)})},e.activities[0]?.id??`skill-${t}`);case`tool-fallback`:return(0,$.jsx)(dE,{activity:e.activity,isExpanded:l.has(e.activity.id),isMobile:c,onToggleTool:u,onShowPopup:d,onContentChange:f},e.activity.id);default:return null}}):null,he=de.length>0;return(0,$.jsxs)(`div`,{className:fe?fm(c):`flow-root`,children:[fe?(0,$.jsxs)(`button`,{ref:w,type:`button`,className:J(`group/tool flex w-[calc(100%+1rem)] min-w-0 flex-nowrap items-center text-left`,c?`gap-x-1`:`gap-x-2`,!B&&hm,B&&`yuri-tool-row -mx-2 rounded-lg px-2 py-0.5 cursor-default`,c&&(A?`pr-2`:`pr-0`)),"data-mobile-press-feedback":B?void 0:`soft`,onClick:B?void 0:H,"aria-expanded":V,"aria-disabled":B||void 0,"aria-label":B?M:_(V?`chat.activity.collapseAria`:`chat.activity.expandAria`),children:[(0,$.jsx)(`span`,{className:J(`inline-flex min-w-0 items-center overflow-clip`,c?`gap-x-1`:`gap-x-1.5`),children:A?(0,$.jsxs)(`span`,{className:J(`typography-meta inline-flex shrink-0 items-center gap-1.5 tabular-nums text-muted-foreground`,c?`h-5`:`h-6`),children:[D?_(`chat.activity.completed`,{duration:D}):M,(0,$.jsx)(X,{name:V?`arrow-down-s`:`arrow-right-s`,className:`size-3.5 shrink-0 opacity-70`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{className:J(`inline-flex flex-none items-center justify-center`,c?`h-5 w-4`:`h-6 w-3.5`),style:{color:`var(--tools-icon)`},children:E&&!k?(0,$.jsx)(rC,{isMobile:c,label:M,className:`block`}):(0,$.jsx)(X,{name:j,className:`h-3.5 w-3.5`})}),(0,$.jsx)(`span`,{className:J(`inline-flex flex-shrink-0 items-center`,c?`typography-meta h-5`:`typography-ui-label h-5 font-semibold`,E?`animate-text-shimmer text-[var(--status-info)] [--yuri-text-shimmer-base:var(--status-info)]`:`text-foreground/85`),children:M}),D?(0,$.jsx)(`span`,{className:`typography-meta shrink-0 tabular-nums text-muted-foreground`,children:D}):null]})}),(0,$.jsxs)(`span`,{className:J(`ml-auto inline-flex max-w-[min(14rem,55%)] shrink-0 items-center`,c?`gap-0.5`:`gap-1`),children:[L.length>0?(0,$.jsxs)(`span`,{className:J(`inline-flex min-w-0 items-center text-muted-foreground`,c?`gap-1`:`gap-1.5`),children:[(0,$.jsx)(`span`,{className:`inline-flex shrink-0 items-center gap-0.5`,"aria-hidden":`true`,children:R.map((e,t)=>(0,$.jsx)(cs,{name:e,size:c?12:14,className:J(`flex-none`,c?`size-3 min-h-3 min-w-3 max-h-3 max-w-3`:`size-3.5 min-h-3.5 min-w-3.5 max-h-3.5 max-w-3.5`)},`${e}-${t}`))}),(0,$.jsx)(`span`,{className:`typography-meta min-w-0 truncate`,children:_(E?`chat.activity.agentsWorking`:`chat.activity.agentsInvolved`,{count:L.length})})]}):null,F?(0,$.jsx)(`span`,{"data-activity-diff-totals":``,className:`inline-flex shrink-0`,children:(0,$.jsx)(PT,{added:N.added,removed:N.removed})}):null,!B&&!A?(0,$.jsx)(X,{name:V?`arrow-down-s`:`arrow-right-s`,className:J(`flex-shrink-0 text-muted-foreground opacity-70`,c&&`-mr-0.5`,c?`size-3`:`size-3.5`)}):null]})]}):null,he?(0,$.jsxs)(`div`,{children:[ue>0?(0,$.jsxs)(`button`,{type:`button`,onClick:H,className:`typography-meta leading-4 px-2 py-1 text-muted-foreground/45 hover:text-muted-foreground/65 text-left`,children:[`+`,ue,` more...`]}):null,(0,$.jsx)(`div`,{className:`flow-root`,children:me})]}):null,V&&(W||ie||se)?(0,$.jsx)(`div`,{className:J(`typography-meta flex min-h-9 items-center gap-2 px-2 text-muted-foreground`,ie&&`text-[var(--status-error)]`),role:ie?`alert`:`status`,children:W?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`loader-4`,className:`size-3.5 shrink-0 animate-spin`}),(0,$.jsx)(`span`,{children:_(`chat.activity.outputLoading`)})]}):ie?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{name:`error-warning`,className:`size-3.5 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 flex-1`,children:_(`chat.activity.outputLoadFailed`)}),(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`xs`,onClick:z,children:_(`chat.activity.outputRetry`)})]}):(0,$.jsx)(`span`,{children:_(`chat.toolOutputDialog.noOutputProduced`)})}):null]})});function yE(e){return e.showToolFileIcons}function bE(e){return e.currentDirectory}function xE(e){return[e.name,e]}function SE(e){e.stopPropagation()}var CE=Q.memo(e=>{let t=(0,Z.c)(2),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(vE,{...e}),t[0]=e,t[1]=n),n});function wE(e){let t=(0,Z.c)(9),{presentation:n,sessionId:r,messageId:i,directory:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={bootstrap:!1},t[0]=o):o=t[0];let s=hr(a,o),c;t[1]===r?c=t[2]:(c=e=>!!e.session_execution_recovery[r],t[1]=r,t[2]=c);let l=we(s,c),u;t[3]===r?u=t[4]:(u=e=>e.session_status[r]?.type===`retry`,t[3]=r,t[4]=u);let d=we(s,u),f=qr(r,a);if(!l&&!d){let e;return t[5]===n?e=t[6]:(e=(0,$.jsx)(am,{presentation:n}),t[5]=n,t[6]=e),e}let p;for(let e=f.length-1;e>=0;--e)if(f[e].role===`assistant`){p=f[e].id;break}if(p===i&&(d||l&&n.detail===`aborted`&&n.icon===`pause-circle`))return null;let m;return t[7]===n?m=t[8]:(m=(0,$.jsx)(am,{presentation:n}),t[7]=n,t[8]=m),m}function TE(e){let t=(0,Z.c)(5),n=Xo();if(!e.sessionId||!n.active||!n.capabilities.compose){let n;return t[0]===e.presentation?n=t[1]:(n=(0,$.jsx)(am,{presentation:e.presentation}),t[0]=e.presentation,t[1]=n),n}let r=n.directory??e.directory,i;return t[2]!==e||t[3]!==r?(i=(0,$.jsx)(wE,{...e,sessionId:e.sessionId,directory:r}),t[2]=e,t[3]=r,t[4]=i):i=t[4],i}var EE={contain:`layout`},DE=`mt-1.5 mb-0.5 flex items-center justify-start gap-1.5`,OE=`mt-3 mb-0.5 flex items-center justify-start gap-1.5`,kE=e=>e.replace(/\\/g,`/`).split(`/`).filter(Boolean).at(-1)??e,AE=`w-full min-w-0 justify-start rounded-[var(--radius-md)] bg-transparent px-1 hover:!bg-interactive-hover focus-visible:!bg-interactive-hover active:!bg-interactive-active supports-[corner-shape:squircle]:rounded-[var(--radius-md)]`,jE=`h-7 gap-1.5`,ME=`h-6 gap-1`,NE=`text-[11px] leading-none`,PE=`size-3.5`,FE=`size-3`,IE=5,LE=Q.memo(e=>{let t=(0,Z.c)(30),{file:n,isMobile:r}=e,i=r?`gap-1 text-[11px]`:`gap-1.5 text-xs`,a;t[0]===i?a=t[1]:(a=J(`flex min-w-0 flex-1 items-center leading-none text-muted-foreground`,i),t[0]=i,t[1]=a);let o=n.file,s=r?`h-3 w-3`:`h-3.5 w-3.5`,c;t[2]===s?c=t[3]:(c=J(`flex-shrink-0`,s),t[2]=s,t[3]=c);let l;t[4]!==n.file||t[5]!==c?(l=(0,$.jsx)(ja,{filePath:o,className:c}),t[4]=n.file,t[5]=c,t[6]=l):l=t[6];let u=n.file,d;t[7]===n.file?d=t[8]:(d=kE(n.file),t[7]=n.file,t[8]=d);let f;t[9]!==n.file||t[10]!==d?(f=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left text-foreground/80`,title:u,children:d}),t[9]=n.file,t[10]=d,t[11]=f):f=t[11];let p=r?`text-[11px]`:`typography-meta`,m;t[12]===p?m=t[13]:(m=J(`inline-flex flex-shrink-0 items-center gap-0 leading-none tabular-nums`,p),t[12]=p,t[13]=m);let h;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(h={color:`var(--status-success)`},t[14]=h):h=t[14];let g;t[15]===n.additions?g=t[16]:(g=(0,$.jsxs)(`span`,{style:h,children:[`+`,n.additions]}),t[15]=n.additions,t[16]=g);let _,v;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`text-muted-foreground/70`,children:`/`}),v={color:`var(--status-error)`},t[17]=_,t[18]=v):(_=t[17],v=t[18]);let y;t[19]===n.deletions?y=t[20]:(y=(0,$.jsxs)(`span`,{style:v,children:[`-`,n.deletions]}),t[19]=n.deletions,t[20]=y);let b;t[21]!==m||t[22]!==g||t[23]!==y?(b=(0,$.jsxs)(`span`,{className:m,children:[g,_,y]}),t[21]=m,t[22]=g,t[23]=y,t[24]=b):b=t[24];let x;return t[25]!==b||t[26]!==a||t[27]!==l||t[28]!==f?(x=(0,$.jsxs)(`span`,{className:a,children:[l,f,b]}),t[25]=b,t[26]=a,t[27]=l,t[28]=f,t[29]=x):x=t[29],x}),RE=Q.memo(e=>{let t=(0,Z.c)(18),{file:n,canOpen:r,isMobile:i,onOpen:a}=e,{t:o}=na(),s;t[0]!==n.file||t[1]!==a?(s=()=>{a(n.file)},t[0]=n.file,t[1]=a,t[2]=s):s=t[2];let c=G(s),l=!r,u=i?ME:jE,d;t[3]===u?d=t[4]:(d=J(AE,u),t[3]=u,t[4]=d);let f;t[5]!==n.file||t[6]!==o?(f=o(`chat.changedFiles.actions.openFileTitle`,{path:n.file}),t[5]=n.file,t[6]=o,t[7]=f):f=t[7];let p;t[8]!==n||t[9]!==i?(p=(0,$.jsx)(LE,{file:n,isMobile:i}),t[8]=n,t[9]=i,t[10]=p):p=t[10];let m;return t[11]!==n.file||t[12]!==c||t[13]!==l||t[14]!==d||t[15]!==f||t[16]!==p?(m=(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`xs`,disabled:l,"data-turn-change-file":`true`,className:d,"aria-label":f,title:n.file,onClick:c,children:p}),t[11]=n.file,t[12]=c,t[13]=l,t[14]=d,t[15]=f,t[16]=p,t[17]=m):m=t[17],m}),zE=Q.memo(e=>{let t=(0,Z.c)(55),{fileCount:n,changedFiles:r,turnId:i,isLatestTurn:a,isMobile:o}=e,{t:s}=na(),c=Ga(),l=Rt(),u=l?.entry.location.hostId?l.entry:void 0,d=Xo(),f=d.directory||c,p=d.sessionId,m=ga(),h=ln(XE),g;t[0]===r?g=t[1]:(g=r??[],t[0]=r,t[1]=g);let _=g,v;t[2]===_?v=t[3]:(v=_.slice(0,IE),t[2]=_,t[3]=v);let y=v,b=Math.max(0,_.length-y.length),x=_.length>0?_.length:n,S=!!(m||!o&&f||o&&a),C;t[4]!==x||t[5]!==s?(C=s(x===1?`chat.pendingChanges.fileCountSingle`:`chat.pendingChanges.fileCountPlural`,{count:x}),t[4]=x,t[5]=s,t[6]=C):C=t[6];let w=C,T;t[7]!==b||t[8]!==s?(T=s(b===1?`chat.pendingChanges.fileCountSingle`:`chat.pendingChanges.fileCountPlural`,{count:b}),t[7]=b,t[8]=s,t[9]=T):T=t[9];let E=T,D=J(AE,o?ME:jE),O=o?FE:PE,k;t[10]===o?k=t[11]:(k=o?J(NE,`font-semibold text-foreground/85`):`typography-meta font-semibold text-foreground/85`,t[10]=o,t[11]=k);let A=k,j;t[12]===o?j=t[13]:(j=o?J(NE,`text-muted-foreground`):`typography-meta text-muted-foreground`,t[12]=o,t[13]=j);let M=j,N;t[14]===o?N=t[15]:(N=o?J(NE,`font-medium`):`typography-meta font-medium`,t[14]=o,t[15]=N);let P=N,F;t[16]!==f||t[17]!==p||t[18]!==u||t[19]!==a||t[20]!==o||t[21]!==m||t[22]!==i?(F=e=>{if(m){m.openTurnDiff(i,p,e);return}if(!o&&f){iT({scope:u,directory:f,filePath:e,turnMessageId:i,sessionId:p});return}o&&a&&f&&iT({scope:u,directory:f,filePath:e,turnMessageId:i,sessionId:p,mobile:!0})},t[16]=f,t[17]=p,t[18]=u,t[19]=a,t[20]=o,t[21]=m,t[22]=i,t[23]=F):F=t[23];let I=G(F),L;t[24]!==f||t[25]!==p||t[26]!==u||t[27]!==a||t[28]!==o||t[29]!==m||t[30]!==h||t[31]!==i||t[32]!==y[0]?.file?(L=()=>{if(m){m.openTurnDiff(i,p);return}if(!o&&f){h(u?.key??f,{mode:`diff`,dedupeKey:`turn-diff:${p||`session`}:${i}`,targetPath:null,diffScope:`turn`,diffTurnMessageId:i,diffSessionId:p});return}let e=y[0]?.file;e&&o&&a&&f&&iT({scope:u,directory:f,filePath:e,turnMessageId:i,sessionId:p,mobile:!0})},t[24]=f,t[25]=p,t[26]=u,t[27]=a,t[28]=o,t[29]=m,t[30]=h,t[31]=i,t[32]=y[0]?.file,t[33]=L):L=t[33];let R=G(L),ee=o?`gap-0 border-foreground/15 p-1`:`gap-0.5 border-border/50 p-1.5`,z;t[34]===ee?z=t[35]:(z=J(`mt-4 flex min-w-0 flex-col rounded-[var(--radius-lg)] border bg-muted/20`,ee),t[34]=ee,t[35]=z);let B=J(D,`max-w-full text-muted-foreground hover:text-foreground`),V;t[36]===s?V=t[37]:(V=s(`chat.changedFiles.title`),t[36]=s,t[37]=V);let H;t[38]===s?H=t[39]:(H=s(`chat.changedFiles.title`),t[38]=s,t[39]=H);let U;t[40]===O?U=t[41]:(U=(0,$.jsx)(X,{name:`file-edit`,className:O}),t[40]=O,t[41]=U);let te=`turn-changes-${i}`,ne;t[42]===s?ne=t[43]:(ne=s(`chat.changedFiles.title`),t[42]=s,t[43]=ne);let re;t[44]!==te||t[45]!==ne||t[46]!==A?(re=(0,$.jsx)(`span`,{id:te,className:A,children:ne}),t[44]=te,t[45]=ne,t[46]=A,t[47]=re):re=t[47];let W;t[48]!==w||t[49]!==M?(W=(0,$.jsx)(`span`,{className:M,children:w}),t[48]=w,t[49]=M,t[50]=W):W=t[50];let ie;t[51]===O?ie=t[52]:(ie=J(O,`opacity-60`),t[51]=O,t[52]=ie);let ae;return t[53]===ie?ae=t[54]:(ae=(0,$.jsx)(X,{name:`arrow-right-s`,className:ie}),t[53]=ie,t[54]=ae),(0,$.jsxs)(`section`,{className:z,"data-turn-changes-preview":`true`,"data-message-action-group":`true`,"aria-labelledby":`turn-changes-${i}`,children:[(0,$.jsxs)(Tr,{type:`button`,variant:`ghost`,size:`xs`,disabled:!S,onClick:R,className:B,"aria-label":V,title:H,children:[U,re,W,ae]}),y.length>0?(0,$.jsxs)(`div`,{className:J(`flex min-w-0 flex-col`,o?`gap-0`:`gap-0.5`),children:[y.map(e=>(0,$.jsx)(RE,{file:e,canOpen:S,isMobile:o,onOpen:I},e.file)),b>0?(0,$.jsxs)(Tr,{type:`button`,variant:`ghost`,size:`xs`,disabled:!S,className:J(D,`text-muted-foreground hover:text-foreground`),onClick:R,"aria-label":s(`chat.changedFiles.title`),title:s(`chat.changedFiles.title`),children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:J(O,`flex-shrink-0`)}),(0,$.jsxs)(`span`,{className:P,children:[`+`,E]}),(0,$.jsx)(X,{name:`arrow-right-s`,className:O})]}):null]}):null]})}),BE=e=>e.type===`subtask`,VE=e=>{let t=e;return t.type===`text`&&typeof t.shellAction==`object`&&t.shellAction!==null},HE=e=>{if(!e||typeof e!=`object`)return null;let t=typeof e.providerID==`string`?e.providerID.trim():``,n=typeof e.modelID==`string`?e.modelID.trim():``;return!t||!n?null:`${t}/${n}`},UE=e=>{let t=(0,Z.c)(49),{part:n}=e,[r,i]=Q.useState(!1),a=Ga(),{isMobile:o}=Ia(),s=Xr(ZE),c=ln(QE),l=Xo(),{t:u}=na(),f;t[0]===n.description?f=t[1]:(f=typeof n.description==`string`?n.description.trim():``,t[0]=n.description,t[1]=f);let p=f,m;t[2]===n.command?m=t[3]:(m=typeof n.command==`string`?n.command.trim():``,t[2]=n.command,t[3]=m);let h=m,g;t[4]===n.agent?g=t[5]:(g=typeof n.agent==`string`?n.agent.trim():``,t[4]=n.agent,t[5]=g);let _=g,v;t[6]===n.prompt?v=t[7]:(v=typeof n.prompt==`string`?n.prompt.trim():``,t[6]=n.prompt,t[7]=v);let y=v,b;t[8]===n.taskSessionID?b=t[9]:(b=typeof n.taskSessionID==`string`?n.taskSessionID.trim():``,t[8]=n.taskSessionID,t[9]=b);let x=b,S;t[10]===n.model?S=t[11]:(S=HE(n.model),t[10]=n.model,t[11]=S);let C=S,w=!!y&&!(o&&l.kind===`primary`),T;t[12]===u?T=t[13]:(T=u(`chat.messageBody.subtask.title`),t[12]=u,t[13]=T);let E;t[14]===T?E=t[15]:(E=(0,$.jsx)(`span`,{className:`typography-meta font-semibold text-foreground`,children:T}),t[14]=T,t[15]=E);let D;t[16]===h?D=t[17]:(D=h?(0,$.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none bg-foreground/5 text-muted-foreground`,children:[`/`,h]}):null,t[16]=h,t[17]=D);let O;t[18]===_?O=t[19]:(O=_?(0,$.jsxs)(`span`,{className:`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none bg-foreground/5 text-muted-foreground`,children:[`@`,_]}):null,t[18]=_,t[19]=O);let k;t[20]===C?k=t[21]:(k=C?(0,$.jsx)(`span`,{className:`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none bg-foreground/5 text-muted-foreground`,children:C}):null,t[20]=C,t[21]=k);let A;t[22]!==O||t[23]!==k||t[24]!==E||t[25]!==D?(A=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[E,D,O,k]}),t[22]=O,t[23]=k,t[24]=E,t[25]=D,t[26]=A):A=t[26];let j;t[27]===p?j=t[28]:(j=p?(0,$.jsx)(`div`,{className:`typography-ui-label text-foreground/90 mt-1.5`,children:p}):null,t[27]=p,t[28]=j);let M;t[29]!==r||t[30]!==y||t[31]!==w||t[32]!==u?(M=w?(0,$.jsxs)(`div`,{className:`mt-2 border-t border-border/60 pt-1.5`,children:[(0,$.jsx)(`button`,{type:`button`,className:`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2`,onClick:()=>i($E),children:u(r?`chat.messageBody.subtask.hidePrompt`:`chat.messageBody.subtask.showPrompt`)}),r?(0,$.jsx)(`pre`,{className:`typography-meta mt-1.5 overflow-x-auto whitespace-pre-wrap break-words text-foreground/85`,children:y}):null]}):null,t[29]=r,t[30]=y,t[31]=w,t[32]=u,t[33]=M):M=t[33];let N;t[34]!==_||t[35]!==p||t[36]!==a||t[37]!==o||t[38]!==c||t[39]!==l||t[40]!==s||t[41]!==u||t[42]!==x?(N=x&&l.capabilities.navigateNestedSession?(0,$.jsx)(`div`,{className:`mt-1.5`,children:(0,$.jsx)(`button`,{type:`button`,className:`typography-meta text-muted-foreground hover:text-foreground transition-colors underline underline-offset-2`,onClick:()=>{let e=l.directory||a;e&&Jo(l,x,e,()=>{if(!rr({sessionId:x,directory:e})){if(fs()||o||d()){s(x,e);return}c(e,{mode:`chat`,dedupeKey:`session:${x}`,label:p||_||u(`contextPanel.mode.chat`),readOnly:!0})}})},children:u(`chat.messageBody.subtask.openSession`)})}):null,t[34]=_,t[35]=p,t[36]=a,t[37]=o,t[38]=c,t[39]=l,t[40]=s,t[41]=u,t[42]=x,t[43]=N):N=t[43];let P;return t[44]!==A||t[45]!==j||t[46]!==M||t[47]!==N?(P=(0,$.jsxs)(`div`,{className:`mt-2`,children:[A,j,M,N]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N,t[48]=P):P=t[48],P},WE=e=>{let t=(0,Z.c)(34),{notification:n}=e,r=Ga(),i=ln(eD),{isMobile:a}=Ia(),{t:o}=na(),s;t[0]!==r||t[1]!==a?(s=r&&!a&&!d(),t[0]=r,t[1]=a,t[2]=s):s=t[2];let c=!!s,l;t[3]!==n.state||t[4]!==o?(l=n.state===`running`?o(`chat.usedGroup.running`):n.state===`completed`?o(`chat.messageBody.subagent.completed`):n.state===`error`?o(`chat.messageBody.subagent.error`):o(`chat.messageBody.subagent.cancelled`),t[3]=n.state,t[4]=o,t[5]=l):l=t[5];let u=l,f=n.state===`running`?o(`chat.messageBody.subtask.title`):n.state===`completed`?o(`chat.messageBody.subagent.completedDescription`):n.state===`error`?o(`chat.messageBody.subagent.errorDescription`):o(`chat.messageBody.subagent.cancelledDescription`),p=n.description||f,m=G(()=>{!c||!r||i(r,{mode:`chat`,dedupeKey:`session:${n.sessionID}`,label:p,readOnly:!0})}),h;t[6]===m?h=t[7]:(h=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),m())},t[6]=m,t[7]=h);let g=G(h),_=c&&`cursor-pointer hover:bg-interactive-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`,v;t[8]===_?v=t[9]:(v=J(`mt-2 flex min-w-0 gap-2.5 rounded-[var(--radius-lg)] border border-border/60 bg-muted/20 px-3 py-2.5`,_),t[8]=_,t[9]=v);let y=c?`button`:void 0,b=c?0:void 0,x=c?o(`chat.messageBody.subagent.openSession`,{label:p}):void 0,S=c?m:void 0,C=c?g:void 0,w;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`mt-0.5 flex size-6 flex-shrink-0 items-center justify-center rounded-md bg-foreground/5 text-muted-foreground`,children:(0,$.jsx)(X,{name:`robot-2`,className:`size-3.5`})}),t[10]=w):w=t[10];let T;t[11]===p?T=t[12]:(T=(0,$.jsx)(`span`,{className:`typography-meta min-w-0 flex-1 truncate font-semibold text-foreground/90`,children:p}),t[11]=p,t[12]=T);let E=n.state===`completed`?`bg-[var(--status-success-background)] text-[var(--status-success)]`:n.state===`error`?`bg-[var(--status-error-background)] text-[var(--status-error)]`:`bg-foreground/5 text-muted-foreground`,D;t[13]===E?D=t[14]:(D=J(`inline-flex h-5 flex-shrink-0 items-center rounded px-1.5 text-[11px] leading-none`,E),t[13]=E,t[14]=D);let O;t[15]!==u||t[16]!==D?(O=(0,$.jsx)(`span`,{className:D,children:u}),t[15]=u,t[16]=D,t[17]=O):O=t[17];let k;t[18]!==T||t[19]!==O?(k=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[T,O]}),t[18]=T,t[19]=O,t[20]=k):k=t[20];let A;t[21]===n.body?A=t[22]:(A=n.body?(0,$.jsx)(`div`,{className:`typography-meta mt-1 max-h-16 overflow-clip text-muted-foreground [&_.markdown-content>*:first-child]:mt-0 [&_.markdown-content>*:last-child]:mb-0`,children:(0,$.jsx)(ko,{content:n.body,variant:`tool`,enableFileReferences:!1})}):null,t[21]=n.body,t[22]=A);let j;t[23]!==k||t[24]!==A?(j=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[k,A]}),t[23]=k,t[24]=A,t[25]=j):j=t[25];let M;return t[26]!==C||t[27]!==j||t[28]!==v||t[29]!==y||t[30]!==b||t[31]!==x||t[32]!==S?(M=(0,$.jsxs)(`div`,{className:v,role:y,tabIndex:b,"aria-label":x,onClick:S,onKeyDown:C,children:[w,j]}),t[26]=C,t[27]=j,t[28]=v,t[29]=y,t[30]=b,t[31]=x,t[32]=S,t[33]=M):M=t[33],M},GE={background:`transparent`,backgroundColor:`transparent`},KE=e=>{let t=(0,Z.c)(37),{part:n}=e,[r,i]=Q.useState(!1),a=Q.useRef(null),{t:o}=na(),s;t[0]===n.shellAction?s=t[1]:(s=typeof n.shellAction?.command==`string`?n.shellAction.command.trim():``,t[0]=n.shellAction,t[1]=s);let c=s,l=typeof n.shellAction?.output==`string`?n.shellAction.output:``,u;t[2]===n.shellAction?u=t[3]:(u=typeof n.shellAction?.status==`string`?n.shellAction.status.trim().toLowerCase():``,t[2]=n.shellAction,t[3]=u);let d=u,f=l.length>0,p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p=()=>{a.current!==null&&typeof window<`u`&&(window.clearTimeout(a.current),a.current=null)},t[4]=p):p=t[4];let m=G(p),h,g;t[5]===m?(h=t[6],g=t[7]):(h=()=>()=>{m()},g=[m],t[5]=m,t[6]=h,t[7]=g),Q.useEffect(h,g);let _;t[8]!==m||t[9]!==f||t[10]!==l?(_=async()=>{f&&(await ki(l)).ok&&(m(),i(!0),typeof window<`u`&&(a.current=window.setTimeout(()=>{i(!1),a.current=null},2e3)))},t[8]=m,t[9]=f,t[10]=l,t[11]=_):_=t[11];let v=G(_),y;t[12]===o?y=t[13]:(y=o(`chat.messageBody.shellCommand.title`),t[12]=o,t[13]=y);let b;t[14]===y?b=t[15]:(b=(0,$.jsx)(`span`,{className:`typography-meta font-semibold text-foreground`,children:y}),t[14]=y,t[15]=b);let x;t[16]!==d||t[17]!==o?(x=d&&d!==`completed`?(0,$.jsx)(`span`,{className:J(`inline-flex h-5 items-center rounded px-1.5 text-[11px] leading-none`,d===`error`?`bg-[var(--status-error-background)] text-[var(--status-error)]`:`bg-foreground/5 text-muted-foreground`),role:d===`error`?`alert`:`status`,children:d===`running`?o(`chat.assistantStatus.runningCommand`):d===`pending`?o(`chat.statusRow.todo.status.pending`):d===`error`?o(`chat.toolPart.error`):d}):null,t[16]=d,t[17]=o,t[18]=x):x=t[18];let S;t[19]!==r||t[20]!==v||t[21]!==f||t[22]!==o?(S=f?(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`xs`,className:`ml-auto text-muted-foreground`,onClick:()=>{v()},"aria-label":o(r?`chat.messageBody.shellCommand.copied`:`chat.messageBody.shellCommand.copyOutput`),title:o(r?`chat.messageBody.shellCommand.copied`:`chat.messageBody.shellCommand.copyOutput`),children:(0,$.jsx)(X,{name:r?`check`:`file-copy`,className:`h-3.5 w-3.5`})}):null,t[19]=r,t[20]=v,t[21]=f,t[22]=o,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==b||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[b,x,S]}),t[24]=S,t[25]=b,t[26]=x,t[27]=C):C=t[27];let w;t[28]===c?w=t[29]:(w=c?(0,$.jsx)(`div`,{className:`typography-meta mt-1.5 overflow-x-auto font-mono`,children:(0,$.jsx)(Fu,{language:`bash`,code:c,codeStyle:GE,wrap:!0})}):null,t[28]=c,t[29]=w);let T;t[30]!==f||t[31]!==l?(T=f?(0,$.jsx)(`div`,{className:`mt-2 border-t border-border/60 pt-1.5`,children:(0,$.jsx)(`pre`,{className:`typography-meta max-h-56 overflow-auto whitespace-pre-wrap break-words font-mono text-foreground/85`,tabIndex:0,children:l})}):null,t[30]=f,t[31]=l,t[32]=T):T=t[32];let E;return t[33]!==C||t[34]!==w||t[35]!==T?(E=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-border/60 bg-[var(--surface-elevated)] px-3 py-2`,children:[C,w,T]}),t[33]=C,t[34]=w,t[35]=T,t[36]=E):E=t[36],E},qE=Q.memo(({sessionId:e,messageId:t,parts:n,sourceParts:r,messageCreatedAt:i,isMobile:a,alwaysShowActions:o=a,hasTouchInput:s,hasTextContent:c,onCopyMessage:l,copiedMessage:u,onShowPopup:d,agentMention:f,onEdit:p,onRevert:m,onFork:h,pendingMessageAction:g,editing:_,editStaged:v,onCancelEdit:y,userActionsMode:b=`inline`,stickyUserHeaderEnabled:x=!0})=>{let{locale:S,t:C}=na(),w=hc(),T=Xo(),E=Uo(T),D=ln(e=>e.timeFormatPreference),[O,k]=Q.useState(!1),A=Q.useRef(null),j=Q.useMemo(()=>n.filter(e=>e.type===`text`?!vd(e):!!(BE(e)||VE(e))),[n]),M=Q.useMemo(()=>j.map(e=>Qn(e)?mi(xd(e)):void 0),[j]),N=f?.token,P=!1,F=!!l,I=!!u,L=!!(s??a),R=!!c,ee=b!==`external-actions`,z=b!==`external-content`,B=x&&b===`inline`,V=G(()=>{A.current!==null&&typeof window<`u`&&(window.clearTimeout(A.current),A.current=null)}),H=G(()=>{!L||!F||!R||typeof window>`u`||(V(),k(!0),A.current=window.setTimeout(()=>{k(!1),A.current=null},1800))});Q.useEffect(()=>{R||(k(!1),V())},[V,R]);let U=G(e=>{!l||!R||(e.stopPropagation(),e.preventDefault(),l(),L&&H())}),te=w===`mini-chat`||!E.fork?void 0:h,ne=Q.useMemo(()=>{if(typeof i!=`number`||i<=0)return null;let e=_c(i,D);return e.length>0?e:null},[S,i,D]),re=J(`yuri-user-actions-hover-scope`,a?b===`inline`?`flex items-center justify-end pt-2 pb-3`:x?`flex h-9 items-start justify-end pt-0`:`flex h-11 items-start justify-end pt-0`:b===`inline`?`absolute top-full left-0 right-0 z-10 pt-5`:`flex h-8 items-start justify-end pt-2`),W=!_&&v&&z?(0,$.jsx)(`div`,{className:re,...Sc,children:(0,$.jsxs)(`div`,{className:J(bc,`justify-end`,!a&&b===`inline`&&`translate-x-5`,`pointer-events-auto opacity-100`),"data-message-action-group":`true`,children:[(0,$.jsxs)(`span`,{className:J(oc,`text-primary`),"aria-live":`polite`,children:[(0,$.jsx)(X,{weight:fc,name:`edit`,className:Tc}),(0,$.jsx)(`span`,{className:`message-footer__label`,children:C(`chat.messageBody.actions.editStaged`)})]}),y?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:vc,"aria-label":C(`chat.messageBody.actions.cancelEdit`),onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),y()},children:(0,$.jsx)(X,{weight:fc,name:`close`,className:pc})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.cancelEdit`)})]}):null]})}):null,ie=(_&&z?(0,$.jsx)(`div`,{className:re,...Sc,children:(0,$.jsx)(`div`,{className:J(`flex items-center gap-2`,`justify-end`,!a&&b===`inline`&&`translate-x-5`,`pointer-events-none opacity-100`),children:(0,$.jsx)(`span`,{className:J(oc,`animate-text-shimmer`),"aria-live":`polite`,children:C(`chat.messageBody.actions.editing`)})})}):null)??W??((F&&R||p||m||te)&&z?(0,$.jsx)(`div`,{className:re,...Sc,children:(0,$.jsxs)(`div`,{className:J(`flex items-center gap-2`,`justify-end`,!a&&b===`inline`&&`translate-x-5`,o?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0 transition-opacity duration-150 yuri-message-hover-actions`),"data-message-action-group":`true`,children:[ne?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsxs)(`span`,{className:J(oc,`mr-1`),"aria-label":`Message time: ${ne}`,children:[(0,$.jsx)(X,{weight:`medium`,name:`time`,className:`size-3.5!`}),(0,$.jsx)(`span`,{className:`message-footer__label`,children:ne})]})}),(0,$.jsx)(ka,{children:ne})]}):null,m&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.revertAria`),"aria-busy":g===`revert`,disabled:!!g,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),m()},children:(0,$.jsx)(X,{weight:`medium`,name:g===`revert`?`loader-4`:`arrow-go-back`,className:J(`size-3.5!`,g===`revert`&&`animate-spin`)})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.revert`)})]}),p&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.editAria`),disabled:!!g,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),p()},children:(0,$.jsx)(X,{weight:`medium`,name:`edit`,className:`size-3.5!`})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.edit`)})]}),te&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.forkAria`),"aria-busy":g===`fork`,disabled:!!g,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),te()},children:(0,$.jsx)(X,{weight:`medium`,name:g===`fork`?`loader-4`:`git-branch`,className:J(`size-3.5!`,g===`fork`&&`animate-spin`)})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.fork`)})]}),F&&R&&(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,"data-visible":O||I?`true`:void 0,className:`size-6! p-0 text-muted-foreground bg-transparent hover:text-foreground hover:!bg-transparent active:!bg-transparent focus-visible:!bg-transparent focus-visible:ring-2 focus-visible:ring-primary/50`,"aria-label":C(`chat.messageBody.actions.copyMessageAria`),onPointerDown:e=>e.stopPropagation(),onClick:U,onFocus:()=>k(!0),onBlur:()=>{I||k(!1)},children:I?(0,$.jsx)(X,{weight:`medium`,name:`check`,className:J(`size-3.5!`,`text-[color:var(--status-success)]`)}):(0,$.jsx)(X,{weight:`medium`,name:`file-copy`,className:`size-3.5!`})})}),(0,$.jsx)(ka,{sideOffset:6,children:C(`chat.messageBody.actions.copyMessage`)})]})]})}):null);return ee?(0,$.jsxs)(`div`,{className:`relative w-full yuri-message-hover-scope`,...Sc,"data-user-message-body":`true`,style:EE,onTouchStart:L&&F&&R?H:void 0,children:[(0,$.jsx)(`div`,{className:J(`leading-relaxed text-foreground/90 text-base overflow-x-hidden`,B?`overflow-y-auto overscroll-contain scrollbar-none`:`overflow-y-hidden`),style:B?{maxHeight:`calc(var(--chat-scroll-height, 100dvh) * 0.4)`}:void 0,children:j.map((e,i)=>{if(BE(e))return(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(UE,{part:e})},e.id??`user-subtask-${i}`);if(VE(e))return(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(KE,{part:e})},e.id??`user-shell-${i}`);let o=M[i];if(o)return(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(WE,{notification:o})},e.id??`subagent-notification-${i}`);let s;return f&&N&&!P&&xd(e).includes(N)&&(s=f,P=!0),(0,$.jsx)(Q.Fragment,{children:(0,$.jsx)(Dc,{part:e,messageId:t,isMobile:a,agentMention:s,messageParts:r??n})},e.id??`user-text-${i}`)})}),(0,$.jsx)(Pf,{files:n,messageID:t,sessionID:e,onShowPopup:d,compact:!0}),ie]}):(0,$.jsx)($.Fragment,{children:ie})}),JE=Q.memo(({sessionId:e,messageId:t,parts:n,sourceParts:r,isMessageCompleted:i,messageFinish:a,messageCompletedAt:o,messageCreatedAt:s,isMobile:c,alwaysShowActions:l,hasTouchInput:u,expandedTools:f,onToggleTool:p,onShowPopup:m,streamPhase:h,allowAnimation:g,onContentChange:_,hasTextContent:v=!1,onCopyMessage:y,onAuxiliaryContentComplete:b,showReasoningTraces:x=!1,shouldShowHeader:S=!1,turnGroupingContext:C,errorPresentation:w})=>{let T=w?.text,{t:E}=na(),D=hc(),O=Xo(),k=Uo(O),A=h,j=Q.useRef(null),M=Q.useRef(null),N=h===`streaming`||h===`cooldown`,P=Q.useRef({messageId:t,experiencedStreamingOrCooldown:N});P.current.messageId===t?N&&(P.current.experiencedStreamingOrCooldown=!0):P.current={messageId:t,experiencedStreamingOrCooldown:N};let F=!!(u??c),I=!!(l??c),L=!i,R=Q.useMemo(()=>n.filter(e=>!vd(e)).filter(e=>e.type!==`reasoning`||x&&xd(e).trim().length>0).filter(e=>e.type!==`compaction`),[n,x]),ee=Q.useMemo(()=>R.filter(e=>e.type===`tool`),[R]),z=Q.useMemo(()=>R.filter(e=>e.type===`text`),[R]),B=Q.useMemo(()=>sT(z),[z]),V=ln(e=>e.openContextPreview),H=Rt(),U=d(),te=D===`mini-chat`,ne=Q.useMemo(()=>{if(U||c||te)return null;for(let e of z){let t=e.text;if(typeof t!=`string`||t.length===0)continue;let n=dn(t)[0];if(n)return n.includes(`0.0.0.0`)?n.replace(`0.0.0.0`,`127.0.0.1`):n}for(let e of ee){let t=e.state,n=t&&typeof t.output==`string`?t.output:null;if(!n)continue;let r=dn(n.replace(/\x1b\[[0-9;]*m/g,``))[0];if(r)return r.includes(`0.0.0.0`)?r.replace(`0.0.0.0`,`127.0.0.1`):r}return null},[z,c,te,U,ee]),re=Xr(e=>e.forkFromMessage),W=Xr(e=>e.forkTransition),ie=Xr(e=>e.currentSessionId),ae=Xr(e=>e.getDirectoryForSession),oe=Ga(),[se,ce]=Q.useState(!1),le=ln(e=>e.chatRenderMode),ue=C?le:`live`,de=ln(e=>e.collapsibleThinkingBlocks),fe=ln(e=>e.showSplitAssistantMessageActions),pe=ln(e=>e.showAssistantTps),me=ue===`sorted`,he=C?.isLastAssistantInTurn??!1,ge=a===`stop`,_e=(ge||i||!!T)&&(C?.isTurnSettled??!0),ve=ge?`completed`:A,ye=ee.length>0,be=Q.useMemo(()=>ee.some(e=>bC(e)),[ee]),xe=bC,Se=yC,Ce=P.current.experiencedStreamingOrCooldown,we=Q.useRef({messageId:t,initialized:!1,observedPartIds:new Set});Q.useEffect(()=>{if(we.current.messageId!==t&&(we.current={messageId:t,initialized:!1,observedPartIds:new Set}),!Ce||!Ri())return;let n=we.current,r=!n.initialized;n.initialized=!0;for(let i of ee){if(n.observedPartIds.has(i.id))continue;if(!_i(r,xe(i))){n.observedPartIds.add(i.id);continue}let a=e??i.sessionID;a&&(n.observedPartIds.add(i.id),yn({sessionID:a,messageID:t,partID:i.id,kind:`tool`}))}},[Ce,xe,t,e,ee]);let Te=Q.useMemo(()=>ee.length===0||!be&&ee.every(e=>Se(e)),[ee,be,Se]),Ee=Q.useMemo(()=>R.filter(e=>e.type===`reasoning`),[R]),De=Q.useMemo(()=>Ee.length===0||Ee.every(e=>typeof e.time?.end==`number`),[Ee]),Oe=typeof a!=`string`,ke=Ee.length>0&&ye&&(be||Oe||!Te),Ae=L||ye&&(be||Oe||!Te),je=L||ke,Me=ye||Ee.length>0,Ne=z.length===0,Pe=Me&&Ne&&!Ae&&!je&&Te&&De,Fe=Q.useRef(!1),Ie=Q.useRef(!1);Q.useEffect(()=>{Ie.current=!1},[t]),Q.useEffect(()=>{if(!Pe){Fe.current=!1;return}Fe.current||(Fe.current=!0,b?.())},[Pe,b]),Q.useEffect(()=>{if(L){Ie.current=!1;return}if(ye){Ie.current=!1;return}Ee.length!==0&&(je||!De||Ie.current||(Ie.current=!0,_?.(`structural`)))},[L,ye,_,De,Ee.length,je]);let Le=G(async n=>{if(n.stopPropagation(),n.preventDefault(),!(!e||!t||se||W)){ce(!0);try{O.onForkMessage?await O.onForkMessage(t):await re(e,t)}finally{ce(!1)}}}),Re=Q.useMemo(()=>{let e=C?.activityParts;return!me||!e?[]:e},[me,C?.activityParts]),ze=Q.useMemo(()=>{let e=C?.activityGroupSegments;return!me||!e?[]:e.filter(e=>e.anchorMessageId===t)},[me,t,C?.activityGroupSegments]),Be=ze.length>0,Ve=Q.useMemo(()=>{let e=new Map,t=new Map;return Re.forEach(n=>{e.set(n.part,n);let r=n.part.id;typeof r==`string`&&r.length>0&&t.set(r,n)}),{get:n=>{let r=e.get(n);if(r)return r;let i=n.id;if(typeof i==`string`&&i.length>0)return t.get(i)}}},[Re]),He=C?.toggleGroup,Ue=C?.activityPresentationKind===`compaction`,We=C?.isGroupExpanded===!0,Ge=me&&Ue&&!We,Ke=me?C?.activityOwnerMessageId===t||Be:!C?.activityOwnerMessageId||C.activityOwnerMessageId===t||Be,qe=me&&Ke&&(Be||Ue)&&!!He,Je=vl(a,R),Ye={finish:a,parts:R,streamPhase:ve,error:T,isLastAssistantInTurn:he},Xe=hl(Ye),Ze=kr(e=>e.ttsInputMode),Qe=Q.useMemo(()=>{if(!he||Ue||!_e||!Xe)return``;let e=r??n,t=wl(e);return t<0?``:xd(e[t])},[he,Ue,_e,Xe,r,n]),$e=Ze===`final`?Qe:B;yd({sessionId:e??``,messageId:t,created:s??0,text:$e,targetRef:j,streaming:c&&O.active&&(A===`streaming`||A===`cooldown`),completed:c&&O.active&&i&&A!==`streaming`&&A!==`cooldown`&&!T});let et=me&&dl(Ye),tt=me&&!Xe&&!(Ue&&We),nt=Q.useMemo(()=>{if(!pe||!he||w?.variant===`error`)return null;let e=C?.assistantTps;if(!dT({completionDisposition:C?.completionDisposition,tps:e}))return null;let t=fT(e??0);return t.length>0?t:null},[pe,w?.variant,he,C?.assistantTps,C?.completionDisposition]),rt=he&&w?.variant!==`error`&&!Ge&&(_e&&(v||!!T||i)||!!nt),it=rt?wl(r??n)>=0:!!v&&!L,at=it,ot=C?.diffStats?.hasDiffs===!0,st=!!C?.activityParts?.length&&e&&O.active&&!te,ct=!te&&he&&Je&&_e&&!Ge&&C?.diffStats?.hasDiffs===!0,lt=fe&&at&&!rt&&!me,ut=Q.useMemo(()=>(0,$.jsx)(uc,{messageId:t,hasCopyableText:it,isTouchContext:F,onCopyMessage:y,ttsText:$e,sessionId:e}),[$e,it,F,y,e,t]),dt=Q.useMemo(()=>e=>{if(!fe||!me)return null;let t=xd(e.part).trim();return t?(0,$.jsx)(uc,{hasCopyableText:!0,isTouchContext:F,onCopyMessage:async()=>(await ki(t)).ok,ttsText:Ze===`final`?``:t}):null},[me,F,fe,Ze]),ft=Q.useMemo(()=>{if(!lt)return-1;let e=-1;for(let t=0;t<R.length;t+=1){let n=R[t];!n||n.type!==`text`||tt||Ve.get(n)?.kind!==`justification`&&(e=t)}return e},[Ve,tt,lt,R]),pt=lt&&ft<0,mt=Q.useMemo(()=>{let n=[];if(qe&&He&&C){let e=(e,t,r=t)=>{n.push((0,$.jsx)(`div`,{children:(0,$.jsx)(CE,{parts:t,materializationParts:r,isExpanded:C.isGroupExpanded===!0,collapsedPreviewCount:0,completionDisposition:C.completionDisposition,activityPresentationKind:C.activityPresentationKind,durationMs:C.durationMs,startedAt:C.userMessageCreatedAt,onToggle:He,isMobile:c,expandedTools:f,onToggleTool:p,onShowPopup:m,onContentChange:_,streamPhase:ve,showHeader:!0,diffStats:C.diffStats,renderJustificationActions:dt})},`progressive-group-${e}`))};ze.length>0?ze.forEach(t=>{let n=x?t.parts:t.parts.filter(e=>e.kind!==`reasoning`);e(t.id,n,t.parts)}):Ue&&e(`${t}:compaction-status`,[])}let r=0;for(;r<R.length;){let i=R[r];if(i.type===`text`){let a=Ve.get(i);if(tt){r+=1;continue}if(Ge){r+=1;continue}if(a?.kind===`justification`){r+=1;continue}n.push((0,$.jsx)(`div`,{ref:M,"data-message-text-export-source":`true`,children:(0,$.jsx)(Uw,{part:i,sessionId:e,messageId:t,streamPhase:ve,chatRenderMode:ue,allowSortedFinalStreaming:et,hasStreamingHapticLifecycle:Ce,onContentChange:_,onShowPopup:m})},`assistant-text-${t}-${i.id??r}`)),lt&&r===ft&&n.push((0,$.jsx)(`div`,{className:c?OE:DE,"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:bc,"data-message-action-group":`true`,children:ut})},`message-actions-${t}`)),r++;continue}if(i.type===`reasoning`){if(Ve.get(i)?.kind===`reasoning`){r+=1;continue}if(!xd(i).trim()){r+=1;continue}x&&(de?n.push((0,$.jsx)(`div`,{className:fm(c),children:(0,$.jsx)(tT,{part:i,messageId:t,streamPhase:ve,onContentChange:_})},`reasoning-${t}-${i.id??r}`)):n.push((0,$.jsx)(Uw,{part:i,sessionId:e,messageId:t,streamPhase:ve,chatRenderMode:ue,hasStreamingHapticLifecycle:Ce,onContentChange:_,onShowPopup:m},`reasoning-${t}-${i.id??r}`))),r++;continue}if(i.type===`tool`){let e=i,a=e.tool?.toLowerCase()??``;if(me&&!Ke){r+=1;continue}if(Ve.get(i)?.kind===`tool`){r+=1;continue}if(me&&vC(a)){let e=MT(R,r,e=>e.type!==`tool`||Ve.get(e)?.kind===`tool`?``:e.tool);if(e.items.length>0){let i=e.items.map((e,n)=>{let i=e;return{id:i.id,turnId:``,messageId:t,partIndex:r+n,part:i,kind:`tool`}});n.push((0,$.jsx)(FT,{activities:i,isMobile:c,isTurnLive:ve!==`completed`,hasFollowingOtherType:AT(R,e.end,e=>({type:e.type,toolName:e.type===`tool`?e.tool:void 0})),children:i.map(e=>{let n=e.part.tool?.toLowerCase()??``;return hC(n)?(0,$.jsx)(hE,{toolName:n,activities:[e],isMobile:c,animateTailText:!1},e.id):(0,$.jsx)(kw,{part:e.part,messageId:t,isExpanded:f.has(e.part.id),onToggle:p,isMobile:c,alwaysShowActions:I,onContentChange:_,onShowPopup:m,animateTailText:!1},e.id)})},`context-tools-${i[0].id}`)),r=e.end;continue}}if(gC(a)){let e=IT(R,r,e=>e.type!==`tool`||Ve.get(e)?.kind===`tool`?``:e.tool);if(e.items.length>0){let i=e.items.map((e,n)=>{let i=e;return{id:i.id,turnId:``,messageId:t,partIndex:r+n,part:i,kind:`tool`}});n.push((0,$.jsx)(VT,{activities:i,isMobile:c,children:i.map(e=>(0,$.jsx)(hE,{toolName:e.part.tool?.toLowerCase()??``,activities:[e],isMobile:c,animateTailText:!1},e.id))},`skill-tools-${i[0].id}`)),r=e.end;continue}}if(fC(a)){n.push((0,$.jsx)(`div`,{className:fm(c),children:(0,$.jsx)(kw,{part:e,messageId:t,isExpanded:f.has(e.id),onToggle:p,isMobile:c,alwaysShowActions:I,onContentChange:_,onShowPopup:m,animateTailText:!1})},`tool-${e.id}`)),r++;continue}n.push((0,$.jsx)(`div`,{className:fm(c),children:(0,$.jsx)(hE,{toolName:a,activities:[{id:e.id,turnId:``,messageId:t,partIndex:r,part:e,kind:`tool`}],isMobile:c,animateTailText:!1})},`static-tools-${e.id}`)),r++;continue}r++}let i=n.at(-1);if(Q.isValidElement(i)&&i.props[`data-message-text-export-source`]===`true`&&ve!==`completed`&&!_e&&!w&&(!C||C.isLastAssistantInTurn)){let e=i;n[n.length-1]=Q.cloneElement(e,{className:J(typeof e.props.className==`string`?e.props.className:void 0,c?`pb-1`:`pb-1.5`),"data-live-status-text-gap":``})}return n},[Ve,ze,I,ue,de,0,f,Ge,Ue,c,Ke,me,ft,t,ut,dt,e,_,m,p,qe,lt,ve,w,Ce,_e,x,tt,et,He,C,R]),ht=Q.useMemo(()=>{if(!he||!_e)return;let e=C?.durationMs;if(!(typeof e!=`number`||e<=0))return wc(e)},[he,_e,C?.durationMs]),gt=Q.useMemo(()=>{let e=typeof o==`number`&&o>0?o:typeof s==`number`&&s>0?s:null;if(e===null)return null;let t=lc(e);return t.length>0?t:null},[o,s]),_t=(0,$.jsxs)($.Fragment,{children:[!te&&!c&&!U&&ne?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,variant:`ghost`,size:`icon`,className:vc,"aria-label":E(`chat.messageBody.actions.openPreviewAria`),onPointerDown:e=>e.stopPropagation(),onClick:()=>{let e=oe??(ie?ae(ie):null);e&&V(H?.entry.location.hostId?H.entry.key:e,ne)},children:(0,$.jsx)(X,{weight:fc,name:`global`,className:pc})})}),(0,$.jsx)(ka,{sideOffset:6,children:E(`chat.messageBody.actions.openPreview`)})]}):null,!te&&k.fork?(0,$.jsxs)(Aa,{children:[(0,$.jsx)(Oa,{asChild:!0,children:(0,$.jsx)(Tr,{type:`button`,size:`icon`,variant:`ghost`,className:vc,"aria-label":E(`chat.messageBody.actions.forkAria`),"aria-busy":se,disabled:se||!!W,onPointerDown:e=>e.stopPropagation(),onClick:e=>{Le(e)},children:(0,$.jsx)(X,{weight:fc,name:se?`loader-4`:`git-branch`,className:J(pc,se&&`animate-spin`)})})}),(0,$.jsx)(ka,{sideOffset:6,children:E(`chat.messageBody.actions.fork`)})]}):null]});return(0,$.jsxs)(`div`,{ref:j,"data-message-text-export-root":`true`,"data-speech-identity":e?`${e}:${t}`:void 0,...Sc,className:J(`relative w-full yuri-message-hover-scope`),style:EE,children:[(0,$.jsx)(ns,{containerRef:j}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:J(`message-content-text leading-relaxed text-foreground/90 [&_p:last-child]:mb-0 [&_ul:last-child]:mb-0 [&_ol:last-child]:mb-0`,(S||C?.headerMessageId===t)&&(c?`[&>[data-message-text-export-source]:first-child]:pt-1.5`:`[&>[data-message-text-export-source]:first-child]:pt-2`)),children:[mt,w&&(0,$.jsx)(Td,{children:(0,$.jsx)(`div`,{className:`my-1.5`,"data-assistant-error":w.variant,children:(0,$.jsx)(TE,{presentation:w,sessionId:e,messageId:t,directory:oe??void 0})})},`assistant-error`)]}),ct&&C?.diffStats?(0,$.jsx)(zE,{fileCount:C.diffStats.files,changedFiles:C.changedFiles,turnId:C.turnId,isLatestTurn:C.isLatestTurn,isMobile:c}):null,(0,$.jsx)(Pf,{files:n,messageID:t,sessionID:e,onShowPopup:m}),pt&&(0,$.jsx)(`div`,{className:J(c?OE:DE),"data-message-actions":`true`,children:(0,$.jsx)(`div`,{className:`flex items-center gap-2`,"data-message-action-group":`true`,children:ut})}),rt&&(0,$.jsx)(dc,{messageId:t,isMobile:c,animateReveal:Ce,actions:(0,$.jsxs)($.Fragment,{children:[ut,_t]}),tps:nt,duration:ht,timestamp:gt,activity:st&&e?(0,$.jsx)(mT,{sessionId:e,activityParts:C?.activityParts}):null,trailing:!te&&he&&ge&&!ot?(0,$.jsx)(aT,{activityParts:C?.activityParts}):null})]})]})}),YE=Q.memo(e=>{let t=(0,Z.c)(28),n,r;if(t[0]===e?(n=t[1],r=t[2]):({isUser:n,...r}=e,t[0]=e,t[1]=n,t[2]=r),n){let e;return t[3]!==r.agentMention||t[4]!==r.alwaysShowActions||t[5]!==r.copiedMessage||t[6]!==r.editStaged||t[7]!==r.editing||t[8]!==r.hasTextContent||t[9]!==r.hasTouchInput||t[10]!==r.isMobile||t[11]!==r.messageCreatedAt||t[12]!==r.messageId||t[13]!==r.onCancelEdit||t[14]!==r.onCopyMessage||t[15]!==r.onEdit||t[16]!==r.onFork||t[17]!==r.onRevert||t[18]!==r.onShowPopup||t[19]!==r.parts||t[20]!==r.pendingMessageAction||t[21]!==r.sessionId||t[22]!==r.sourceParts||t[23]!==r.stickyUserHeaderEnabled||t[24]!==r.userActionsMode?(e=(0,$.jsx)(qE,{sessionId:r.sessionId,messageId:r.messageId,parts:r.parts,sourceParts:r.sourceParts,messageCreatedAt:r.messageCreatedAt,isMobile:r.isMobile,alwaysShowActions:r.alwaysShowActions,hasTouchInput:r.hasTouchInput,hasTextContent:r.hasTextContent,onCopyMessage:r.onCopyMessage,copiedMessage:r.copiedMessage,onShowPopup:r.onShowPopup,agentMention:r.agentMention,onEdit:r.onEdit,onRevert:r.onRevert,onFork:r.onFork,pendingMessageAction:r.pendingMessageAction,editing:r.editing,editStaged:r.editStaged,onCancelEdit:r.onCancelEdit,userActionsMode:r.userActionsMode,stickyUserHeaderEnabled:r.stickyUserHeaderEnabled}),t[3]=r.agentMention,t[4]=r.alwaysShowActions,t[5]=r.copiedMessage,t[6]=r.editStaged,t[7]=r.editing,t[8]=r.hasTextContent,t[9]=r.hasTouchInput,t[10]=r.isMobile,t[11]=r.messageCreatedAt,t[12]=r.messageId,t[13]=r.onCancelEdit,t[14]=r.onCopyMessage,t[15]=r.onEdit,t[16]=r.onFork,t[17]=r.onRevert,t[18]=r.onShowPopup,t[19]=r.parts,t[20]=r.pendingMessageAction,t[21]=r.sessionId,t[22]=r.sourceParts,t[23]=r.stickyUserHeaderEnabled,t[24]=r.userActionsMode,t[25]=e):e=t[25],e}let i;return t[26]===r?i=t[27]:(i=(0,$.jsx)(JE,{...r}),t[26]=r,t[27]=i),i});function XE(e){return e.openContextPanelTab}function ZE(e){return e.setCurrentSession}function QE(e){return e.openContextPanelTab}function $E(e){return!e}function eD(e){return e.openContextPanelTab}var tD=e=>{let t=e,n=t?.clientRole,r=t?.role;return t?.userMessageMarker===!0||n===`user`||r===`user`||t?.origin===`user`||t?.source===`user`?{role:`user`,isUser:!0}:{role:n||r||`assistant`,isUser:!1}},nD=e=>{if(typeof e!=`string`)return!1;let t=e.toLowerCase().trim();if(!t)return!1;if(t.includes(`token refresh failed`)||t.includes(`unauthorized`)||t.includes(`invalid token`)||t.includes(`expired token`))return!0;let n=t.includes(`oauth`),r=t.includes(`failed`)||t.includes(`invalid`)||t.includes(`expired`);if(n&&r)return!0;let i=/\b401\b/.test(t),a=t.includes(`auth`)||t.includes(`token`)||t.includes(`unauthorized`);return i&&a},rD={"provider.rate-limit":`chat.response.rateLimit`,"provider.auth":`chat.response.auth`,"provider.quota":`chat.response.quota`,"provider.content-filter":`chat.response.contentFilter`,"provider.transport":`chat.response.transport`,"provider.internal":`chat.response.internal`,"provider.invalid-output":`chat.response.invalidOutput`,"provider.invalid-request":`chat.response.invalidRequest`,"provider.unsupported-operation":`chat.response.unsupportedOperation`,"provider.no-route":`chat.response.noRoute`,"provider.unknown":`chat.response.providerUnknown`,"provider.timeout":`chat.response.timeout`,"permission.rejected":`chat.response.permissionRejected`,"tool.execution":`chat.response.toolExecution`,"compaction.failed":`chat.response.compactionFailed`,"compaction.unavailable":`chat.response.compactionUnavailable`,"compaction.interrupted":`chat.response.compactionInterrupted`},iD={icon:`pause-circle`,variant:`muted`};function aD(e,t){if(!e||typeof e!=`object`)return;let n=e,r=typeof n.data?.message==`string`?n.data.message:typeof n.message==`string`?n.message:void 0,i=typeof n.name==`string`?n.name:void 0,a=typeof n.type==`string`?n.type.trim():void 0,o=typeof n.status==`number`&&Number.isInteger(n.status)&&n.status>=100&&n.status<=599?n.status:void 0;if(!r&&!a&&!i&&o===void 0)return;let s=[a&&a!==`unknown`&&a!==`error`?a:void 0,o].filter(e=>e!==void 0).join(` · `)||void 0,c=(e,n,i=`error`,a=!1)=>({text:t(e),icon:n,variant:i,...r&&!a?{rawMessage:r}:{},...s?{detail:s}:{}});if(i===`SessionRetry`)return c(`chat.response.retrying`,`refresh`,`info`);if(a===`aborted`)return r===`Execution was interrupted repeatedly and will not be resumed automatically.`?c(`chat.response.resumeExhausted`,`error-warning`,`error`,!0):r===`Session interrupted by user`?c(`chat.response.stopped`,`stop-circle`,`muted`,!0):r===`Compaction cancelled`?c(`chat.response.compactionCancelled`,`stop-circle`,`muted`,!0):r===`Tool execution interrupted`?c(`chat.response.toolInterrupted`,iD.icon,iD.variant,!0):c(`chat.response.interrupted`,iD.icon,iD.variant,r===`Step interrupted`);if(i===`MessageAbortedError`||!a&&r?.trim().toLowerCase()===`aborted`)return c(`chat.response.stopped`,`stop-circle`,`muted`,!0);if(a&&Object.hasOwn(rD,a)){if(a===`compaction.interrupted`)return c(rD[a],iD.icon,iD.variant,r===`Compaction was interrupted`);if(a===`compaction.unavailable`)return c(rD[a],`information`,`info`,r===`Nothing to compact yet`);let e=a===`provider.auth`||a===`permission.rejected`?`lock`:a===`provider.timeout`?`time`:`error-warning`;return c(rD[a],e)}return(!a||a===`unknown`||a===`error`)&&nD(r)?c(`chat.response.auth`,`lock`):{...c(`chat.response.failed`,`error-warning`),...!r&&i?{rawMessage:i}:{}}}function oD(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.nativeType===`synthetic`&&t.description===`Continuing after restart`}function sD(e,t){if(oD(e))return{text:t(`chat.response.continuingAfterRestart`),icon:`restart`,variant:`info`}}function cD(e){return!e}function lD(e){let t=(0,Z.c)(60),{part:n,isMobile:r}=e,i=r!==void 0&&r,{t:a}=na(),o;t[0]!==n.id||t[1]!==n.messageID||t[2]!==n.sessionID?(o=JSON.stringify([n.sessionID,n.messageID,n.id]),t[0]=n.id,t[1]=n.messageID,t[2]=n.sessionID,t[3]=o):o=t[3];let s=o,{expanded:c,toggle:l}=jb(s),u=(0,Q.useId)(),d;t[4]!==s||t[5]!==l?(d=()=>l(s),t[4]=s,t[5]=l,t[6]=d):d=t[6];let f=G(d),p=n.status===`running`,m=n.status===`failed`,h;t[7]!==m||t[8]!==p||t[9]!==a?(h=a(p?`chat.activity.compacting`:m?`chat.activity.compactionFailed`:`chat.activity.compactionCompleted`),t[7]=m,t[8]=p,t[9]=a,t[10]=h):h=t[10];let g=h,_;t[11]!==m||t[12]!==n.error||t[13]!==a?(_=m?aD(n.error,a):void 0,t[11]=m,t[12]=n.error,t[13]=a,t[14]=_):_=t[14];let v=_,y;t[15]!==m||t[16]!==n.summary?(y=m?``:n.summary?.trim()??``,t[15]=m,t[16]=n.summary,t[17]=y):y=t[17];let b=y,x,S,C,w,T,E,D,O,k;if(t[18]!==u||t[19]!==c||t[20]!==v?.text||t[21]!==m||t[22]!==i||t[23]!==p||t[24]!==n.status||t[25]!==b||t[26]!==g||t[27]!==f){let e=J(`shrink-0 typography-meta`,m?`text-[var(--status-error)]/85`:`text-muted-foreground`);E=`w-full min-w-0`,D=``,O=n.status;let r=i?`min-h-7`:`min-h-8`;t[37]===r?k=t[38]:(k=J(`flex w-full items-center gap-3`,r),t[37]=r,t[38]=k),x=`separator`,S=p?`polite`:void 0,C=v?.text??g,t[39]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 border-t`,"aria-hidden":`true`}),t[39]=w):w=t[39],T=b?(0,$.jsxs)(Tr,{variant:`ghost`,size:`sm`,className:J(e,mm),"aria-expanded":c,"aria-controls":u,onClick:f,children:[g,(0,$.jsx)(X,{name:`arrow-down-s`,className:J(`size-4 transition-transform`,c&&`rotate-180`)})]}):(0,$.jsx)(`span`,{className:e,children:g}),t[18]=u,t[19]=c,t[20]=v?.text,t[21]=m,t[22]=i,t[23]=p,t[24]=n.status,t[25]=b,t[26]=g,t[27]=f,t[28]=x,t[29]=S,t[30]=C,t[31]=w,t[32]=T,t[33]=E,t[34]=D,t[35]=O,t[36]=k}else x=t[28],S=t[29],C=t[30],w=t[31],T=t[32],E=t[33],D=t[34],O=t[35],k=t[36];let A;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(`span`,{className:`min-w-0 flex-1 border-t`,"aria-hidden":`true`}),t[40]=A):A=t[40];let j;t[41]!==x||t[42]!==S||t[43]!==C||t[44]!==w||t[45]!==T||t[46]!==D||t[47]!==O||t[48]!==k?(j=(0,$.jsxs)(`div`,{"data-compaction-card":D,"data-compaction-status":O,className:k,role:x,"aria-live":S,"aria-label":C,children:[w,T,A]}),t[41]=x,t[42]=S,t[43]=C,t[44]=w,t[45]=T,t[46]=D,t[47]=O,t[48]=k,t[49]=j):j=t[49];let M;t[50]!==u||t[51]!==c||t[52]!==p||t[53]!==n.messageID||t[54]!==b?(M=b&&c?(0,$.jsx)(`div`,{id:u,className:`py-2`,children:(0,$.jsx)(Mo,{content:b,messageId:n.messageID,isStreaming:p})}):null,t[50]=u,t[51]=c,t[52]=p,t[53]=n.messageID,t[54]=b,t[55]=M):M=t[55];let N;return t[56]!==E||t[57]!==j||t[58]!==M?(N=(0,$.jsxs)(`div`,{className:E,children:[j,M]}),t[56]=E,t[57]=j,t[58]=M,t[59]=N):N=t[59],N}var uD=e=>{if(typeof e!=`string`)return;let t=e.trim();return t.length>0?t:void 0},dD=e=>{if(typeof e!=`object`||!e)return null;let t=e,n=typeof t.model==`object`&&t.model!==null?t.model:void 0,r=typeof t.metadata==`object`&&t.metadata!==null?t.metadata:void 0,i=typeof r?.model==`object`&&r.model!==null?r.model:void 0,a=uD(t.mode)??uD(t.agent)??uD(r?.agent),o=uD(t.providerID)??uD(n?.providerID)??uD(i?.providerID),s=uD(t.modelID)??uD(n?.modelID)??uD(n?.id)??uD(i?.modelID)??uD(i?.id),c=uD(n?.variant)??uD(i?.variant)??uD(t.variant)??uD(r?.variant);return!a&&!o&&!s&&!c?null:{agentName:a,providerId:o,modelId:s,variant:c}},fD=e=>{let t=e?.providerId?.trim(),n=e?.modelId?.trim();return!t||!n?null:{providerId:t,modelId:n}},pD=e=>fD(e.assistantIdentity)??fD(e.userIdentity)??(e.allowComposerFallback?fD(e.composerSelection):null)??fD(e.sessionSelection),mD=e=>{let t=e?.modelId??null;return{providerID:e?.providerId??null,modelID:t,agentName:e?.agentName,modelName:Gr(void 0,t)||void 0,variant:e?.variant}},hD=e=>!(!e.isLastTurn||!e.sessionIsWorking||e.hasAssistantMessages||e.activityPresentationKind===`compaction`||e.hasActiveStreamingMessage),gD=(e,t,n)=>e===`active`||n?.isLastTurn&&n.hasConfirmedFinalBody!==!0?!0:t===`summary`,_D=e=>!e,vD=e=>e.completionDisposition===`active`?e.isLastTurn&&e.sessionIsWorking?{completionDisposition:`active`,durationMs:e.durationMs}:{completionDisposition:`abnormal`,durationMs:e.durationMs}:{completionDisposition:e.completionDisposition,durationMs:e.durationMs},yD=e=>!(e.completionDisposition===`active`||e.isLastTurn&&e.sessionIsWorking&&!e.hasConfirmedSettledAssistant),bD=e=>e.isWorking?!0:e.isInActiveTurn?e.headerCompletionDisposition!==`normal`&&e.headerCompletionDisposition!==`abnormal`:!1,xD=e=>e.turnCompletionDisposition===`active`&&(e.isLastTurn||e.hasAssistantMessages)?`active`:e.headerPresentationDisposition,SD=e=>{let t=e.info;return(typeof t.clientRole==`string`?t.clientRole:null)??(typeof t.role==`string`?t.role:null)??null},CD=e=>{let t=e.info;return typeof t.parentID==`string`&&t.parentID.length>0?t.parentID:null},wD=e=>!e||SD(e)!==`user`?!1:e.parts.some(e=>{if(e?.type!==`text`)return!1;let t=e.text;return e.synthetic===!0&&typeof t==`string`&&t.trim().startsWith(`The following tool was executed by the user`)}),TD=e=>SD(e)===`user`?wD(e)||e.parts.some(e=>{let t=e.shellAction;return e.type===`text`&&typeof t==`object`&&!!t}):!1,ED=(e,t)=>{if(SD(e)!==`assistant`||t&&CD(e)!==t||e.parts.length!==1)return{hide:!1,details:null};let n=e.parts[0];return n?.type!==`tool`||(typeof n.tool==`string`?n.tool.toLowerCase():``)!==`bash`?{hide:!1,details:null}:{hide:!0,details:{command:typeof n.state?.input?.command==`string`?n.state.input.command:void 0,output:(typeof n.state?.output==`string`?n.state.output:void 0)??(typeof n.state?.metadata?.output==`string`?n.state.metadata.output:void 0),status:typeof n.state?.status==`string`?n.state.status:void 0}}},DD=(e,t)=>{let n=e[t];if(!n)return null;let r=n.info.id;for(let n=t+1;n<e.length;n+=1){let t=e[n];if(SD(t)===`user`)break;let{hide:i,details:a}=ED(t,r);if(i){let e=typeof a?.command==`string`?a.command.trim():``;return e.length>0?e:null}}return null},OD=Ao(()=>on(()=>import(`./ToolOutputDialog-D_Kl-Bc5.js`).then(e=>e.n),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83]))),kD=4e3,AD=new Map,jD=new Map,MD=new Set([`bash`,`shell`,`cmd`,`terminal`]),ND=e=>{if(typeof e!=`string`)return``;let t=e.trim().toLowerCase();if(!t)return``;let n=t.replace(/:\d+$/,``);if(!n.includes(`.`))return n;let r=n.split(`.`).filter(Boolean);return r[r.length-1]??n},PD=e=>{let t=AD.get(e);return t?new Set(t):new Set},FD=(e,t)=>{if(AD.size>=kD&&!AD.has(e)){let e=AD.keys().next().value;typeof e==`string`&&AD.delete(e)}AD.set(e,new Set(t))},ID=e=>{let t=jD.get(e);return t?new Set(t):new Set},LD=(e,t)=>{if(jD.size>=kD&&!jD.has(e)){let e=jD.keys().next().value;typeof e==`string`&&jD.delete(e)}jD.set(e,new Set(t))},RD=200,zD=new Map,BD=e=>zD.get(e),VD=(e,t)=>{if(!t.agent&&!t.provider&&!t.model)return;let n=zD.get(e);if(!(n&&n.agent===t.agent&&n.provider===t.provider&&n.model===t.model)){if(zD.size>=RD&&!zD.has(e)){let e=zD.keys().next().value;typeof e==`string`&&zD.delete(e)}zD.set(e,t)}};function HD(e){let t=(0,Z.c)(3),[n,r]=Q.useState(e),i,a;return t[0]===e?(i=t[1],a=t[2]):(i=()=>{e!=null&&r(e)},a=[e],t[0]=e,t[1]=i,t[2]=a),Q.useEffect(i,a),e??n}var UD=(e,t)=>{if(typeof e==`object`&&e)return e[t]},WD=Q.memo(({message:e,previousMessage:t,nextMessage:n,onContentChange:r,animationHandlers:i,turnGroupingContext:a,assistantHeaderMessageId:o,turnOwnsAssistantHeader:s=!1,isInActiveTurn:c=!1,activeStreamingPhase:l=null,animateUserOnMount:u=!1,onUserAnimationConsumed:d})=>{let{t:f}=na(),{isMobile:m,isTablet:h,hasTouchInput:g}=Ia(),_=Xo(),v=Uo(_),y=m||h,b=Q.useRef(null),x=Q.useRef(null),S=G(t=>{b.current=t,x.current?.(),x.current=null,t&&m&&(x.current=Oc(t,e.info.id))});Q.useEffect(()=>{let t=b.current;return x.current?.(),x.current=null,t&&m&&(x.current=Oc(t,e.info.id)),()=>{x.current?.(),x.current=null}},[m,e.info.id]);let C=Xr(e=>e.currentSessionId),w=Xr(e=>e.revertToMessage),T=Xr(e=>e.editMessagePreservingChanges),E=Xr(e=>e.forkFromMessage),D=Xr(t=>t.messageEditCommitting?.messageId===e.info.id&&t.messageEditCommitting?.sessionId===e.info.sessionID),O=Xr(t=>t.stagedMessageEdit?.messageId===e.info.id&&t.stagedMessageEdit?.sessionId===e.info.sessionID),k=Xr(e=>e.clearStagedMessageEdit);We(`ui.chat_message.render`),c&&We(`ui.chat_message.render.streaming`);let A=kr(e=>e.providers),{showReasoningTraces:j,stickyUserHeader:M,chatRenderMode:N,showExpandedBashTools:P}=ln(De(e=>({showReasoningTraces:e.showReasoningTraces,stickyUserHeader:e.stickyUserHeader,chatRenderMode:e.chatRenderMode,showExpandedBashTools:e.showExpandedBashTools})));Q.useEffect(()=>{C&&yc.getInstance().recordSessionStart(C)},[C]);let[F,I]=Q.useState(null),[L,R]=Q.useState(!1),[ee,z]=Q.useState(null),B=Q.useRef(null),[V,H]=Q.useState(()=>PD(e.info.id)),[U,te]=Q.useState(()=>ID(e.info.id)),[ne,re]=Q.useState({open:!1,title:``,content:``});Q.useEffect(()=>{H(PD(e.info.id)),te(ID(e.info.id))},[e.info.id]);let W=Q.useMemo(()=>tD(e.info),[e.info]).isUser,ie=Q.useMemo(()=>p(e.parts),[e.parts]),ae=W&&(m||!M),oe=W&&!m&&M&&!ae,se=e.info.sessionID,{currentContextAgent:ce,savedSessionAgentSelection:le}=km(De(e=>({currentContextAgent:c&&se?e.currentAgentContext.get(se):void 0,savedSessionAgentSelection:c&&se?e.sessionAgentSelections.get(se):void 0}))),ue=Q.useMemo(()=>gd(e.sourceParts??e.parts),[e.parts,e.sourceParts]),de=Q.useMemo(()=>W?gc(ue):gd(e.parts),[W,e.parts,ue]),fe=Q.useMemo(()=>{if(W||!t)return null;let e=UD(t.info,`clientRole`),n=UD(t.info,`role`);return(typeof e==`string`?e:typeof n==`string`?n:void 0)===`user`&&dD(t.info)||null},[W,t]),pe=Q.useMemo(()=>{if(W)return;let t=UD(e.info,`mode`);if(typeof t==`string`&&t.trim().length>0)return t;let n=UD(e.info,`agent`);if(typeof n==`string`&&n.trim().length>0)return n;if(fe?.agentName)return fe.agentName;if(se)return ce||(le??void 0)},[W,e.info,fe,se,ce,le]),me=W?null:dD(e.info),he=me?.providerId??null,ge=me?.modelId??null,_e=Oi(De(e=>{if(W||!se)return null;if(fe?.providerId&&fe?.modelId)return{providerId:fe.providerId,modelId:fe.modelId};if(pe){let t=e.getAgentModelForSession(se,pe);if(t?.providerId&&t?.modelId)return t}let t=e.getSessionModelSelection(se);return t?.providerId&&t?.modelId?t:null})),ve=Q.useMemo(()=>W?null:typeof he==`string`&&he.trim().length>0?he:_e?.providerId??null,[W,he,_e]),ye=Q.useMemo(()=>W?null:typeof ge==`string`&&ge.trim().length>0?ge:_e?.modelId??null,[W,ge,_e]),be=e.info.id?BD(e.info.id):void 0;W||VD(e.info.id,{agent:pe,provider:ve??void 0,model:ye??void 0});let xe=pe??be?.agent,Se=ve??be?.provider??null,Ce=ye??be?.model??null,we=Q.useMemo(()=>{if(W)return;let e=Se&&A.length>0?A.find(e=>e.id===Se):void 0;return Gr(e,Ce)||void 0},[W,Se,Ce,A]),Te=HD(xe),Ee=HD(Se??void 0),Oe=HD(Ce??void 0),ke=HD(we),Ae=Te??void 0,je=Ee??null,Me=Oe??null,Ne=ke??void 0,Pe=Q.useMemo(()=>{let t=e.info.time;return typeof t?.completed==`number`?t.completed:null},[e.info.time]),Fe=Q.useMemo(()=>{let t=e.info.time;return typeof t?.created==`number`?t.created:null},[e.info.time]),Ie=Q.useMemo(()=>W?!0:!!(Pe&&Pe>0),[W,Pe]),Le=Q.useMemo(()=>{let t=e.info.finish;return typeof t==`string`?t:void 0},[e.info]),Re=Q.useMemo(()=>pd(de,{includeReasoning:j}),[de,j]),ze=Q.useMemo(()=>W?Re:!Ie&&N===`sorted`?[]:Re,[N,Ie,W,Re]),Be=Q.useMemo(()=>W?[]:Re.filter(e=>e.type===`text`),[W,Re]),Ve=Q.useMemo(()=>W?[]:Re.filter(e=>e.type===`tool`),[W,Re]),He=Q.useMemo(()=>{if(!P)return new Set;let e=new Set;for(let t of Ve){let n=typeof t?.id==`string`?t.id:``;if(!n)continue;let r=ND(t.tool);!r||!MD.has(r)||e.add(n)}for(let t of a?.activityParts??[]){if(t.kind!==`tool`)continue;let n=ND(t.part.tool);!n||!MD.has(n)||e.add(t.id)}return e},[P,Ve,a?.activityParts]),Ue=Q.useMemo(()=>{if(He.size===0&&U.size===0)return V;let e=new Set(V);return He.forEach(t=>{U.has(t)||e.add(t)}),U.forEach(t=>{e.delete(t)}),e},[U,He,V]),Ge=Q.useMemo(()=>{if(!W)return;let e=de.find(e=>e.type===`agent`);if(!e)return;let t=e,n=typeof t.name==`string`?t.name:void 0;if(n)return{name:n,token:t.source&&typeof t.source.value==`string`&&t.source.value.trim().length>0?t.source.value:`@${n}`}},[W,de]),Ke=W&&!tc(ze),qe=typeof Le!=`string`,Je=Q.useMemo(()=>W?!1:Be.length===0||Ve.length===0?qe:!0,[Be.length,Ve.length,qe,W]),Ye=Q.useMemo(()=>!W&&yc.getInstance().shouldAnimateMessage(e.info,C||e.info.sessionID),[e.info,C,W]),[Xe,Ze]=Q.useState(!1),Qe=Q.useMemo(()=>n?tD(n.info):null,[n]),$e=!!a,et=a?.isLastAssistantInTurn??!1,tt=bD({isWorking:a?.isWorking===!0,isInActiveTurn:c,headerCompletionDisposition:a?.completionDisposition}),nt=Q.useMemo(()=>W?!1:$e?!et:Qe?!Qe.isUser&&Qe.role===`assistant`:!1,[$e,et,W,Qe]),rt=Q.useMemo(()=>Ie?`completed`:c?l??`streaming`:`completed`,[l,c,Ie]);Q.useEffect(()=>{!W||!u||d?.(e.info.id)},[u,W,e.info.id,d]),Q.useEffect(()=>{Ze(!1)},[e.info.id]),Q.useEffect(()=>{let t=o??a?.headerMessageId;W||!t||t!==e.info.id||(rt===`streaming`||rt===`cooldown`)&&Ze(!0)},[o,W,e.info.id,rt,a?.headerMessageId]);let it=Q.useMemo(()=>{if(W)return!0;if(s)return!1;let t=o??a?.headerMessageId;return t?e.info.id===t?rt===`completed`||Xe||rt===`streaming`||rt===`cooldown`:!1:!0},[o,Xe,W,a,rt,e.info.id,s]),at=Q.useCallback(e=>{ki(e).then(t=>{t.ok&&(I(e),setTimeout(()=>I(null),2e3))})},[]),ot=W?void 0:me?.variant??a?.userMessageVariant??fe?.variant,st=!W&&typeof ot==`string`&&ot.trim().length>0?ot:void 0,ct=Q.useMemo(()=>{if(!W&&!cD($e?et:!nt))return aD(e.info?.error,f)},[$e,nt,et,W,e.info,f]),lt=ct?.text,ut=Q.useMemo(()=>{if(W){let e=ze.filter(e=>e.type===`text`).map(e=>{let t=e.shellAction?.output;return typeof t==`string`?t.trim():``}).filter(e=>e.length>0);if(e.length>0)return e.join(`
54
54
 
55
55
  `);let t=ze.filter(e=>e.type===`text`).map(e=>{let t=e.shellAction?.command;return typeof t==`string`?t.trim():``}).filter(e=>e.length>0);return t.length>0?t.join(`
56
56
  `):ze.filter(e=>e.type===`text`).map(e=>(e.text||e.content||``).trim()).filter(e=>e.length>0).join(`