@yuriai/web 0.2.40-beta.5 → 0.2.40-beta.7

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 (176) hide show
  1. package/dist/assets/{AgentAvatar-B7KbxN8Y.js → AgentAvatar-BTLQDhXH.js} +1 -1
  2. package/dist/assets/AssistantConversationSurface-B59k-lXE.css +1 -0
  3. package/dist/assets/AssistantConversationSurface-CMMUXPIG.js +3 -0
  4. package/dist/assets/AssistantSessionCard-CZWiX3PR.js +2 -0
  5. package/dist/assets/{AssistantUnreadBadge-vu4ZhTft.js → AssistantUnreadBadge-B5I8avUG.js} +1 -1
  6. package/dist/assets/{AssistantView-CEfEWUIr.js → AssistantView-COHkH9qm.js} +1 -1
  7. package/dist/assets/{DiagramView-Dlzr08J_.js → DiagramView-DiwpnazQ.js} +1 -1
  8. package/dist/assets/{FadeInOnReveal-DMRmNsau.js → FadeInOnReveal-BxelcK76.js} +1 -1
  9. package/dist/assets/{GuiPluginPage-DVug4z_p.js → GuiPluginPage-CLD3qMom.js} +1 -1
  10. package/dist/assets/{GuiPluginSurface-L43o6Xv8.js → GuiPluginSurface-Cra2RdI2.js} +1 -1
  11. package/dist/assets/{GuiPluginWindow-tHXkS18H.js → GuiPluginWindow-CX4PYIEy.js} +1 -1
  12. package/dist/assets/{Icon-DizeYahT.js → Icon-BN1Zz-it.js} +1 -1
  13. package/dist/assets/{ImageLoadingPlaceholder-BZC5m_km.js → ImageLoadingPlaceholder-CZFYt1Xf.js} +1 -1
  14. package/dist/assets/{LoadingImage-Csw4L-Dr.js → LoadingImage-BCMztEsC.js} +1 -1
  15. package/dist/assets/{MarkdownRenderer-D_0iKhQN.js → MarkdownRenderer-194nc-0S.js} +2 -2
  16. package/dist/assets/{MarkdownRendererImpl-BZ0XgjS0.js → MarkdownRendererImpl-0-mJL1TL.js} +1 -1
  17. package/dist/assets/{MarkstreamRendererImpl-DBd6Glg9.js → MarkstreamRendererImpl-DaTyfTOH.js} +1 -1
  18. package/dist/assets/MobileDetailNavigation-CXAtNLak.js +1 -0
  19. package/dist/assets/{MobileResizableSheet-CQQ7O-2X.js → MobileResizableSheet-BvwMTE7L.js} +1 -1
  20. package/dist/assets/{MobileShareBridge-IO45gM2G.js → MobileShareBridge-BpO-ZEFG.js} +1 -1
  21. package/dist/assets/MobileSurface-DIhzZpb9.js +2 -0
  22. package/dist/assets/{MultiRunWindow-fJ3XfntS.js → MultiRunWindow-ErbLasVC.js} +1 -1
  23. package/dist/assets/{OnboardingScreen-MJS5T5rL.js → OnboardingScreen-C_rigW9c.js} +1 -1
  24. package/dist/assets/{OverlayScrollbar-jtMYTn1y.js → OverlayScrollbar-BopzmDhe.js} +1 -1
  25. package/dist/assets/RemoteAssistantSessionCard-6ktwRL7R.js +1 -0
  26. package/dist/assets/{SettingsView-ZWFLpPSI.js → SettingsView--qdcJENp.js} +10 -10
  27. package/dist/assets/{SettingsWindow-DGRmrIWz.js → SettingsWindow-BbJoqFSB.js} +1 -1
  28. package/dist/assets/{SetupTourDialog-BYbAubwA.js → SetupTourDialog-CT3NmpEw.js} +1 -1
  29. package/dist/assets/{TerminalView-CoJ6_9P1.js → TerminalView-Cw-p34fv.js} +1 -1
  30. package/dist/assets/{ToolOutputDialog-5xBwOJ6a.js → ToolOutputDialog-Bph7Tjg_.js} +1 -1
  31. package/dist/assets/{VoiceSettings-CN33koSc.js → VoiceSettings-B8jYVsYS.js} +2 -2
  32. package/dist/assets/{YuriLogo-CvyJy_R9.js → YuriLogo-VXtP1vhh.js} +1 -1
  33. package/dist/assets/{YuriWordmark-DnFAS-Ko.js → YuriWordmark-B7lmpLRB.js} +1 -1
  34. package/dist/assets/{capgoAdapter-CCLtBZL1.js → capgoAdapter-BQCbf31K.js} +1 -1
  35. package/dist/assets/{checkbox-rOV6DjeG.js → checkbox-q45nTdJl.js} +1 -1
  36. package/dist/assets/{client-uz8O6TPX.js → client-1Fk5IbQR.js} +3 -3
  37. package/dist/assets/{collapsible-CKswuqAw.js → collapsible-GtMRfwfw.js} +1 -1
  38. package/dist/assets/{context-menu-B4njwT_M.js → context-menu-efudajQ5.js} +1 -1
  39. package/dist/assets/{diagram-BppQ_USn.js → diagram-D39tZKkF.js} +1 -1
  40. package/dist/assets/{dialog-Bg8MJnOV.js → dialog-BtnUw5J1.js} +1 -1
  41. package/dist/assets/{es-Ba3NUCtE.js → es-DuTK1iYh.js} +1 -1
  42. package/dist/assets/{fileMentionTouchSelection-D-AdTJVr.js → fileMentionTouchSelection-CJ78x95X.js} +1 -1
  43. package/dist/assets/{fr-CRhp3hyT.js → fr-C_XToFWm.js} +1 -1
  44. package/dist/assets/{gitApi-DVx_V1x6.js → gitApi-CBnJOeVr.js} +1 -1
  45. package/dist/assets/gitApiHttp-B0FJaIhU.js +3 -0
  46. package/dist/assets/{gui-DN2sVP96.js → gui-BMN3-WPc.js} +1 -1
  47. package/dist/assets/{host-DrGjjO6K.js → host-D9EDWNmx.js} +1 -1
  48. package/dist/assets/{i18n-RH7UieOS.js → i18n-qHllte6P.js} +1 -1
  49. package/dist/assets/{input-DRjuZMeA.js → input-KETIwVja.js} +1 -1
  50. package/dist/assets/{input-store-CjUOfpyA.js → input-store-CsY-uaSj.js} +1 -1
  51. package/dist/assets/insertionBoundaries-CodoJFbE.js +1 -0
  52. package/dist/assets/{ja-D-UPjDY2.js → ja-D0pDybpB.js} +1 -1
  53. package/dist/assets/{ko-x-z9J5z7.js → ko-CAzlaaDJ.js} +1 -1
  54. package/dist/assets/main-Cgg4eDdr.js +2 -0
  55. package/dist/assets/{main-D2s9J_jN.js → main-D4t2Tw1D.js} +14 -14
  56. package/dist/assets/{markdownHeightCache-BL99DlhC.js → markdownHeightCache-BCzMmJds.js} +1 -1
  57. package/dist/assets/{mcpQueries-HzYMEVWd.js → mcpQueries-BIvH9V8j.js} +1 -1
  58. package/dist/assets/miniChat-CKw0itTX.js +2 -0
  59. package/dist/assets/mobile-w1JspRFK.js +2 -0
  60. package/dist/assets/{mobileBackNavigation--ZdrI-Yj.js → mobileBackNavigation-qI9CYpqm.js} +1 -1
  61. package/dist/assets/{mobileConnections-C3eGEOPy.js → mobileConnections-Cbt8y7gt.js} +2 -2
  62. package/dist/assets/{multirun-CDYNyLBH.js → multirun-DOmwPpvA.js} +1 -1
  63. package/dist/assets/{native-DsqzO52u.js → native-CDqNKjmz.js} +1 -1
  64. package/dist/assets/{native-config-DOawZfln.js → native-config-BIePc5av.js} +1 -1
  65. package/dist/assets/{navigation-Ibk_Pw-q.js → navigation-CxKtO3Tu.js} +2 -2
  66. package/dist/assets/openRemoteProjectSession-DbQYpcai.js +1 -0
  67. package/dist/assets/{pl-Cqo1FJwM.js → pl-BvjbUcJV.js} +1 -1
  68. package/dist/assets/{projectMeta-D1Ytss9U.js → projectMeta-AxnyOG6N.js} +1 -1
  69. package/dist/assets/prompt-attachment-upload-9fjmgafL.js +1 -0
  70. package/dist/assets/{pt-BR-C930XU1k.js → pt-BR-D71qrP91.js} +1 -1
  71. package/dist/assets/{pwa-CXupOTsD.js → pwa-BGo_AGpg.js} +1 -1
  72. package/dist/assets/{queue-abort-optimistic-CQXpIlq6.js → queue-abort-optimistic-CZ3DN-Qo.js} +1 -1
  73. package/dist/assets/{react-CgRToPwO.js → react-CTU-HLp4.js} +1 -1
  74. package/dist/assets/{readiness-BfuZm6Yw.js → readiness-Bu7mTG2d.js} +2 -2
  75. package/dist/assets/reference-history-n4Bw_yN2.js +1 -0
  76. package/dist/assets/{remote-input-store-BOdCWpQY.js → remote-input-store-84i8uDyM.js} +1 -1
  77. package/dist/assets/remoteProjectQueries-BZjiHj-6.js +1 -0
  78. package/dist/assets/remoteSessionReference-CQ0m6LgV.js +1 -0
  79. package/dist/assets/renderElectronMiniChatApp-B8nOPC1J.js +2 -0
  80. package/dist/assets/renderMobileApp-BvamjumJ.js +29 -0
  81. package/dist/assets/{runtimeConfig-tHm7o_0I.js → runtimeConfig-CbHzjd7l.js} +1 -1
  82. package/dist/assets/runtimeEndpointReset-CMyx_9Vr.js +151 -0
  83. package/dist/assets/scheduledTaskNavigation-y5g8D2ee.js +1 -0
  84. package/dist/assets/{select-B1On-Y4Z.js → select-Df_svQ9u.js} +1 -1
  85. package/dist/assets/sessionLookup-BN82Y0hu.js +1 -0
  86. package/dist/assets/{sortable-tabs-strip-nD1Me06z.js → sortable-tabs-strip-ByO3KYNT.js} +1 -1
  87. package/dist/assets/{speechSettingsQueries-BYhNpzDJ.js → speechSettingsQueries-DRAueMIJ.js} +1 -1
  88. package/dist/assets/src-INJJ62RE.css +2 -0
  89. package/dist/assets/{store-DunGyOfe.js → store-BOD3jjMl.js} +3 -3
  90. package/dist/assets/{terminalApi-madXrfqA.js → terminalApi-Cq0vjFe1.js} +1 -1
  91. package/dist/assets/{textarea-Qt06OhhX.js → textarea-BYUo-pZK.js} +1 -1
  92. package/dist/assets/{tooltip-D382RCy1.js → tooltip-CBCE3mxe.js} +1 -1
  93. package/dist/assets/tour-CMXP3Kif.js +1 -0
  94. package/dist/assets/{types-CHszLAS3.js → types-Bj4r_-Qe.js} +1 -1
  95. package/dist/assets/{uk-OXQSdzuT.js → uk-C7c1Zece.js} +1 -1
  96. package/dist/assets/{useAppFontEffects-CqXrCJVt.js → useAppFontEffects-DxY0a-0K.js} +61 -61
  97. package/dist/assets/useDesktopWindowControlsLayout-I02la7LE.js +1 -0
  98. package/dist/assets/{useDictation-Bs7TWO9r.js → useDictation-De8WB_Z7.js} +1 -1
  99. package/dist/assets/{useEffectiveDirectory-CCKRdyK9.js → useEffectiveDirectory-CYzFju6z.js} +1 -1
  100. package/dist/assets/{useFontPreferences-CPrl1_3z.js → useFontPreferences-CO-L-Gd7.js} +1 -1
  101. package/dist/assets/{useMobileNavigationStore-BNtVrnSw.js → useMobileNavigationStore-7nhBtrXS.js} +9 -9
  102. package/dist/assets/{usePluginsStore-bMuGciUE.js → usePluginsStore-1D6-GAgq.js} +1 -1
  103. package/dist/assets/{useProjectRuntimeAPIs-BFCXBu2J.js → useProjectRuntimeAPIs-CNOqSvoZ.js} +1 -1
  104. package/dist/assets/{useStreamingTextThrottle-C8xAqcgP.js → useStreamingTextThrottle-BsaiiBxk.js} +1 -1
  105. package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js} +3 -3
  106. package/dist/assets/{vendor-opencode-plugin-BmdTE4Te.js → vendor-opencode-plugin-ZhpPgHCL.js} +1 -1
  107. package/dist/assets/{vendor-solid-js-D98iXT7C.js → vendor-solid-js-BBVUd3Hw.js} +1 -1
  108. package/dist/assets/{zh-CN-B5X8yCZV.js → zh-CN-D2ENuI1-.js} +1 -1
  109. package/dist/assets/{zh-TW-CF6zr1fk.js → zh-TW-C40BXFhK.js} +1 -1
  110. package/dist/index.html +11 -11
  111. package/dist/mini-chat.html +11 -11
  112. package/dist/mobile.html +2 -2
  113. package/package.json +1 -1
  114. package/server/index.js +1 -0
  115. package/server/lib/assistants/DOCUMENTATION.md +87 -0
  116. package/server/lib/assistants/assign.js +10 -7
  117. package/server/lib/assistants/builtin-skills.js +1 -0
  118. package/server/lib/assistants/builtin-skills.test.js +1 -1
  119. package/server/lib/assistants/cards.js +6 -1
  120. package/server/lib/assistants/contact-store.js +22 -5
  121. package/server/lib/assistants/contact-tools.js +46 -26
  122. package/server/lib/assistants/execution-target.js +136 -0
  123. package/server/lib/assistants/opencode-tools.js +22 -9
  124. package/server/lib/assistants/remote-execution.test.js +378 -0
  125. package/server/lib/assistants/remote-watch-reconciler.js +43 -0
  126. package/server/lib/assistants/remote-watch-reconciler.test.js +88 -0
  127. package/server/lib/assistants/routes.js +1 -0
  128. package/server/lib/assistants/service.js +302 -99
  129. package/server/lib/assistants/yuri-project.http.test.js +2 -2
  130. package/server/lib/gui-customization/DOCUMENTATION.md +8 -2
  131. package/server/lib/gui-customization/projects-client.mjs +10 -8
  132. package/server/lib/gui-customization/projects-remote.js +101 -0
  133. package/server/lib/gui-customization/projects-remote.test.js +125 -0
  134. package/server/lib/gui-customization/projects.js +30 -6
  135. package/server/lib/gui-customization/projects.test.js +66 -1
  136. package/server/lib/gui-customization/session-skill.js +2 -2
  137. package/server/lib/gui-customization/session-skill.test.js +4 -0
  138. package/server/lib/gui-customization/skill/SKILL.md +3 -1
  139. package/server/lib/gui-customization/skill/references/projects.md +30 -3
  140. package/server/lib/gui-customization/skill/references/remote-connections.md +2 -0
  141. package/server/lib/opencode/DOCUMENTATION.md +6 -0
  142. package/server/lib/opencode/feature-routes-runtime.js +2 -0
  143. package/server/lib/opencode/v2-client.js +9 -4
  144. package/server/lib/remote-hosts/DOCUMENTATION.md +58 -0
  145. package/server/lib/remote-hosts/gateway.js +149 -40
  146. package/server/lib/remote-hosts/json-lifecycle.test.js +35 -0
  147. package/server/lib/remote-hosts/routes.js +10 -13
  148. package/server/lib/remote-hosts/routes.test.js +302 -1
  149. package/server/lib/remote-hosts/store.js +17 -3
  150. package/server/lib/remote-hosts/store.test.js +19 -0
  151. package/server/lib/remote-hosts/task-client.js +25 -0
  152. package/server/lib/remote-hosts/task-client.test.js +60 -0
  153. package/server/lib/remote-hosts/transport.js +7 -2
  154. package/server/lib/request-cors.js +1 -1
  155. package/server/lib/request-cors.test.js +1 -0
  156. package/server/lib/scheduled-tasks/session-skill.test.js +33 -2
  157. package/dist/assets/AssistantConversationSurface-BnK_KTBO.js +0 -3
  158. package/dist/assets/AssistantConversationSurface-n9w_Av0k.css +0 -1
  159. package/dist/assets/MobileDetailNavigation-xgwvsQuR.js +0 -1
  160. package/dist/assets/MobileSurface-DmYgZONB.js +0 -2
  161. package/dist/assets/gitApiHttp-DvTBxvX8.js +0 -3
  162. package/dist/assets/insertionBoundaries-DZtQt2Ah.js +0 -1
  163. package/dist/assets/main-BMFY9mtb.js +0 -2
  164. package/dist/assets/miniChat-BbJ0GKpk.js +0 -2
  165. package/dist/assets/mobile-_zUth69Z.js +0 -2
  166. package/dist/assets/prompt-attachment-upload-BNhDXymd.js +0 -1
  167. package/dist/assets/remoteProjectQueries-CkxdZNw4.js +0 -1
  168. package/dist/assets/renderElectronMiniChatApp-pJ59iC34.js +0 -2
  169. package/dist/assets/renderMobileApp-BQFC-gOA.js +0 -29
  170. package/dist/assets/runtimeEndpointReset-BhHWFNvo.js +0 -150
  171. package/dist/assets/scheduledTaskNavigation-BIDtQ4wN.js +0 -1
  172. package/dist/assets/sessionLookup-RcyTTDOy.js +0 -1
  173. package/dist/assets/src-BZCFf9_1.css +0 -2
  174. package/dist/assets/tour-CQMBn8gJ.js +0 -1
  175. package/dist/assets/useDesktopWindowControlsLayout-KH4UP7Gj.js +0 -1
  176. /package/dist/assets/{sessionLookup-8C8nv-EP.css → reference-history-8C8nv-EP.css} +0 -0
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-5xBwOJ6a.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-mjIpsk3N.js","assets/runtime-switch-BMjl5Y5W.js","assets/runtime-fetch-DKZOpfzo.js","assets/reasoning-projection-client-BEhVknv9.js","assets/platform-wF65ZFgV.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-base-ui-z2M4boRm.js","assets/vendor-react-P8wFrkcT.js","assets/vendor-tanstack-react-query-B-KblYBV.js","assets/vendor-tanstack-query-core-BSjXNgF_.js","assets/runtime-file-resource-CuLP3xp7.js","assets/path-utils-jGozTg9d.js","assets/vendor-reactuses-core-Dyjw5sZR.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-store-BVRgEtI-.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/useUIStore-Cfmg-aDQ.js","assets/vendor-zustand-Cwko4FG1.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/safeStorage-DTOhKN0V.js","assets/useMobileHtmlPreviewStore-EOAzZiAy.js","assets/runtime-file-download-D11Nnedg.js","assets/vendor-pierre-diffs-tqo4Z3TC.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/i18n-RH7UieOS.js","assets/runtime-ead7P81A.js","assets/bootstrap-eLlfzqAI.js","assets/store-DunGyOfe.js","assets/tour-CQMBn8gJ.js","assets/useMobileNavigationStore-BNtVrnSw.js","assets/gitApiHttp-DvTBxvX8.js","assets/client-uz8O6TPX.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/prompt-attachment-upload-BNhDXymd.js","assets/uuid-D-SDZijH.js","assets/vendor-sonner-B5HgJenP.js","assets/useAssistantUIStore-jOKVcBK8.js","assets/input-store-CjUOfpyA.js","assets/remoteProjectQueries-CkxdZNw4.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-C57Z9mV2.js","assets/vendor-framer-motion-CF9BQLta.js","assets/Icon-DizeYahT.js","assets/dialog-Bg8MJnOV.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MarkdownRenderer-D_0iKhQN.js","assets/useEffectiveDirectory-CCKRdyK9.js","assets/markdownHeightCache-BL99DlhC.js","assets/dualLimitLru-D8Sphgua.js","assets/MobileWindowStack-DGLdgoGr.js","assets/mobileBackNavigation--ZdrI-Yj.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-DBqnxgDH.js","assets/image-loading-DA9JEHD8.css","assets/ImageLoadingPlaceholder-BZC5m_km.js","assets/vendor-tanstack-react-virtual-BkuqzrEV.js","assets/markdownTheme-DFDWa8Gh.js","assets/markdown-worker-oBGEB9Eg.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-BMjl5Y5W.js";import{n as r,r as i}from"./platform-wF65ZFgV.js";import{a}from"./vendor-zustand-Cwko4FG1.js";import{d as o,f as s,g as c,h as l,m as u,ot as d,p as f,st as p,u as m}from"./vendor-base-ui-z2M4boRm.js";import{En as h,On as g,Tn as _,_n as v,vn as y,wn as b,xn as x}from"./gitApiHttp-DvTBxvX8.js";import{f as S}from"./prompt-attachment-upload-BNhDXymd.js";import{n as C}from"./vendor-react-P8wFrkcT.js";import{s as w}from"./vendor-tanstack-react-query-B-KblYBV.js";import{L as T}from"./runtime-file-resource-CuLP3xp7.js";import{a as E,i as D,m as O,o as k,p as A,r as j}from"./vendor-reactuses-core-Dyjw5sZR.js";import{o as M}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as N}from"./useUIStore-Cfmg-aDQ.js";import{t as ee}from"./uuid-D-SDZijH.js";import{t as P}from"./i18n-RH7UieOS.js";import{N as F,_ as I,f as te,g as ne,h as L,j as re,r as ie,u as R,v as ae,w as oe}from"./MobileDetailNavigation-xgwvsQuR.js";import{Ct as z,In as B,K as se,Rn as V,Zn as H,s as U,vi as W,yi as G}from"./useMobileNavigationStore-BNtVrnSw.js";import{n as K}from"./useAssistantUIStore-jOKVcBK8.js";import{a as ce,r as le}from"./MobileShareBridge-IO45gM2G.js";import{a as q}from"./fileMentionAutocompleteState-BZJqfgae.js";import{o as ue,p as de,t as fe}from"./AgentAvatar-B7KbxN8Y.js";import{d as pe,o as me,t as he}from"./vendor-framer-motion-CF9BQLta.js";import{n as J}from"./Icon-DizeYahT.js";import{t as ge}from"./scheduledTaskNavigation-BIDtQ4wN.js";import{a as _e,i as ve,t as ye}from"./MarkdownRenderer-D_0iKhQN.js";import{D as be,E as Y,O as xe,a as Se,c as Ce,d as we,f as Te,g as Ee,h as De,l as Oe,m as ke,o as Ae,s as je,t as Me,u as Ne,w as Pe,x as Fe}from"./sessionLookup-RcyTTDOy.js";import{a as Ie,n as Le,r as Re,t as ze}from"./fileMentionTouchSelection-D-AdTJVr.js";import{c as Be,s as Ve}from"./image-loading-DBqnxgDH.js";import{t as X}from"./ImageLoadingPlaceholder-BZC5m_km.js";import{t as He}from"./LoadingImage-Csw4L-Dr.js";import{n as Ue}from"./textarea-Qt06OhhX.js";import{t as We}from"./vendor-motion-Dv27UnOI.js";import{i as Ge,n as Ke,r as qe}from"./assistant-attachment-cache-D-LmCflm.js";var Z=C(),Q=e(p(),1),$=d();function Je(e){let i=(0,Z.c)(12),{assistantID:a,position:o}=e,s=Q.useRef(null),c=Q.useRef(!1),l;i[0]===Symbol.for(`react.memo_cache_sentinel`)?(l={busy:!1,done:!1,retryAt:0},i[0]=l):l=i[0];let u=Q.useRef(l),[d]=Q.useState(et),f;i[1]!==a||i[2]!==o||i[3]!==d?(f=()=>{let e=s.current;if(!e||!c.current||u.current.busy||u.current.done||Date.now()<u.current.retryAt||d.transport!==t()||d.generation!==n()||document.visibilityState!==`visible`||(r()?!document.documentElement.classList.contains(`yuri-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let i=e.closest(`[data-assistant-contact-transcript]`);if(!i||i.scrollHeight-i.scrollTop-i.clientHeight>2)return;let l=e.getBoundingClientRect(),f=i.getBoundingClientRect(),p=window.visualViewport,m=p?.offsetTop??0,h=m+(p?.height??window.innerHeight);l.height<=0||l.width<=0||l.bottom>Math.min(f.bottom,h)||l.top<Math.max(f.top,m)||l.right<=Math.max(f.left,0)||l.left>=Math.min(f.right,window.innerWidth)||(u.current.busy=!0,R(a,o).then(()=>{u.current.done=!0}).catch(()=>{u.current.retryAt=Date.now()+15e3}).finally(()=>{u.current.busy=!1}))},i[1]=a,i[2]=o,i[3]=d,i[4]=f):f=i[4];let p=j(f),m;i[5]===p?m=i[6]:(m=e=>{c.current=e.some($e),p()},i[5]=p,i[6]=m);let h;i[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={threshold:1},i[7]=h):h=i[7],E(s,j(m),h),D(`visibilitychange`,p,Qe),D(`focus`,p,Ze),D(`resize`,p,Xe);let g,_;i[8]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>s.current?.closest(`[data-assistant-contact-transcript]`),_={passive:!0},i[8]=g,i[9]=_):(g=i[8],_=i[9]),D(`scroll`,p,g,_);let v;i[10]===Symbol.for(`react.memo_cache_sentinel`)?(v={attributes:!0,attributeFilter:[`class`]},i[10]=v):v=i[10],A(p,Ye,v),k(p,15e3);let y;return i[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{ref:s,"aria-hidden":`true`,className:`absolute bottom-0 left-0 block h-px w-px`,"data-assistant-read-marker":``}),i[11]=y):y=i[11],y}function Ye(){return document.documentElement}function Xe(){return window.visualViewport}function Ze(){return window}function Qe(){return document}function $e(e){return e.isIntersecting&&e.intersectionRatio===1}function et(){return{transport:t(),generation:n()}}var tt=()=>{},nt=Q.memo(xe),rt=e=>e?.directories.flatMap(({directory:e,sessions:t})=>e?t.filter(e=>!e.time.archived).map(t=>({...t,directory:e||t.location?.directory||t.directory||``})).filter(e=>e.directory.length>0):[])??null,it=Q.forwardRef(({query:e,isMobile:t,listId:n,onHighlightChange:r,onSelect:i,onClose:a},o)=>{let{t:s}=P(),c=Be(),l=w({...G(c),select:rt}),u=Q.useMemo(()=>q({sessions:l.data??[],currentSessionId:null,searchQuery:e,limit:e.trim()?10:3}),[l.data,e]),[d,f]=Q.useState({query:e,index:0}),p=Math.min(d.query===e?d.index:0,Math.max(0,u.length-1)),m=Q.useRef(null),h=Q.useRef([]),g=Q.useMemo(ze,[]);D(`pointerdown`,e=>{e.target instanceof Node&&!m.current?.contains(e.target)&&a()},void 0,{capture:!0}),Q.useLayoutEffect(()=>{h.current[p]?.scrollIntoView?.({block:`nearest`})},[p]),Q.useLayoutEffect(()=>{r(u.length?`${n}-${p}`:void 0)},[p,n,u.length,r]);let _=j(t=>{if(t===`Escape`){a();return}u.length&&(t===`ArrowDown`&&f({query:e,index:(p+1)%u.length}),t===`ArrowUp`&&f({query:e,index:(p-1+u.length)%u.length}),(t===`Enter`||t===`Tab`)&&i(u[p]))});return Q.useImperativeHandle(o,()=>({keyDown:_}),[_]),(0,$.jsxs)(Le,{ref:m,isMobile:t,className:`max-w-[640px] max-h-64`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 px-3 py-1`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`assistants.contact.sessionMention.scope`)}),(0,$.jsx)(B,{type:`button`,size:`xs`,variant:`ghost`,"aria-label":s(`dialog.common.actions.close`),onClick:a,children:(0,$.jsx)(J,{name:`close`,className:`size-4`})})]}),l.isPending?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(`common.loading`)}):null,l.isError?(0,$.jsxs)(`div`,{role:`alert`,className:`px-3 py-2 typography-meta text-[var(--status-error)]`,children:[s(`assistants.contact.sessionMention.loadFailed`),(0,$.jsx)(B,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>void l.refetch(),children:s(`chat.history.retry`)})]}):null,l.isSuccess&&!u.length?(0,$.jsx)(`p`,{role:`status`,className:`px-3 py-2 typography-meta text-muted-foreground`,children:s(l.data===null?`common.unavailable`:`sessions.sidebar.empty.noMatches.title`)}):null,(0,$.jsx)(Ue,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsx)(`div`,{id:n,role:`listbox`,"aria-label":s(`chat.fileMentionAutocomplete.groups.sessions`),className:`p-1.5`,children:u.map((r,a)=>(0,$.jsxs)(`div`,{id:`${n}-${a}`,role:`option`,"aria-selected":a===p,ref:e=>{h.current[a]=e},className:V(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,Re(t,a===p)),onMouseDown:e=>e.preventDefault(),onMouseMove:()=>f({query:e,index:a}),onPointerDown:e=>{e.pointerType===`touch`&&g.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&g.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&g.pointerUp(()=>i(r))&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>g.pointerCancel(),onClick:()=>g.click(()=>i(r)),children:[(0,$.jsx)(J,{name:`chat-thread`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`div`,{className:`truncate font-medium leading-5`,title:r.title,children:r.title||s(`chat.fileMentionAutocomplete.untitledSession`)}),(0,$.jsx)(`div`,{className:`truncate text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,title:r.directory,children:r.directory})]})]},`${r.directory}:${r.id}`))})}),t?null:(0,$.jsx)(`div`,{className:`mx-1.5 shrink-0 border-t px-1.5 py-1 text-[length:calc(var(--text-meta)*0.875)] leading-4 text-muted-foreground`,children:s(`chat.autocomplete.keyboardHint`)})]})}),at=e=>{let t=(0,Z.c)(122),n,r,i,a;t[0]===e?(n=t[1],r=t[2],i=t[3],a=t[4]):({active:n,onChange:r,onVoiceSend:i,...a}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i,t[4]=a);let{t:o}=P(),s=Q.useRef(null),c=n&&!!a.isMobile&&!!i,l;t[5]===c?l=t[6]:(l={available:c},t[5]=c,t[6]=l);let{enabled:u,hint:d,onHintChange:f}=be(l),p;t[7]!==d||t[8]!==a.placeholder||t[9]!==o?(p=d===null?a.placeholder:o(d===`recording`?`chat.dictation.releaseSend`:d===`cancelling`?`chat.dictation.releaseCancel`:d===`editing`?`chat.dictation.releaseEdit`:`chat.dictation.processing`),t[7]=d,t[8]=a.placeholder,t[9]=o,t[10]=p):p=t[10];let m=p,g;t[11]===a.value?g=t[12]:(g=()=>({canonical:a.value,document:x(a.value,new Map)}),t[11]=a.value,t[12]=g);let[C,w]=Q.useState(g),T;t[13]!==C.canonical||t[14]!==C.document||t[15]!==a.value?(T=C.canonical===a.value?C.document:x(a.value,new Map),t[13]=C.canonical,t[14]=C.document,t[15]=a.value,t[16]=T):T=t[16];let E=T,[D,O]=Q.useState(0),[k,A]=Q.useState(!0),[M,N]=Q.useState(!1),[ee,F]=Q.useState(),I=Q.useRef(null),te=Q.useRef(null),ne=Q.useRef(null),L=Q.useRef(null),re;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(re=Ce(),t[17]=re):re=t[17];let ie=Q.useRef(re),R=Q.useId(),ae;t[18]!==n||t[19]!==M||t[20]!==D||t[21]!==k||t[22]!==E.text||t[23]!==a.disabled||t[24]!==a.pending?(ae=n&&!a.pending&&!a.disabled&&!k&&!M?Ie({text:E.text,cursor:D}):null,t[18]=n,t[19]=M,t[20]=D,t[21]=k,t[22]=E.text,t[23]=a.disabled,t[24]=a.pending,t[25]=ae):ae=t[25];let oe=ae,z=oe?.kind===`mention`?oe:null,B;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>{L.current!==null&&(I.current?.focus({preventScroll:!0}),I.current?.setSelectionRange(L.current,L.current),L.current=null)},t[26]=B):B=t[26];let se;t[27]===E?se=t[28]:(se=[E],t[27]=E,t[28]=se),Q.useLayoutEffect(B,se);let H;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(H=()=>A(!0),t[29]=H):H=t[29];let U=j(H),W;t[30]!==M||t[31]!==D||t[32]!==E||t[33]!==r?(W=(e,t,n)=>{let i=n===void 0||n,a=h(e);a.ok&&(i&&(ie.current=Oe(ie.current,{before:je(E,[],{start:I.current?.selectionStart??D,end:I.current?.selectionEnd??D}),after:je(e,[],{start:t,end:t})})),M||(L.current=t),O(t),w({canonical:a.text,document:e}),r(a.text))},t[30]=M,t[31]=D,t[32]=E,t[33]=r,t[34]=W):W=t[34];let G=j(W),K;t[35]!==G||t[36]!==E||t[37]!==z||t[38]!==o?(K=e=>{if(!z)return;let t=e.title||o(`chat.fileMentionAutocomplete.untitledSession`),n=y(E,z.tokenStart,z.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,display:S({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);A(!0),G(n.document,r)},t[35]=G,t[36]=E,t[37]=z,t[38]=o,t[39]=K):K=t[39];let ce=j(K),le;t[40]!==n||t[41]!==G||t[42]!==E||t[43]!==a.disabled||t[44]!==a.pending?(le=e=>{if(!n||a.pending||a.disabled||!e.trim())return;let t=E.text?`${E.text} ${e}`:e,r=b(E,t,t.length,t.length);G(r.document,r.caret),A(!0)},t[40]=n,t[41]=G,t[42]=E,t[43]=a.disabled,t[44]=a.pending,t[45]=le):le=t[45];let q=j(le),ue;t[46]!==n||t[47]!==E.text||t[48]!==q||t[49]!==r||t[50]!==i||t[51]!==a.disabled||t[52]!==a.pending?(ue=e=>{if(!(!n||a.pending||a.disabled||!e.trim())){if(E.text){q(e);return}r(e),i?.(e)}},t[46]=n,t[47]=E.text,t[48]=q,t[49]=r,t[50]=i,t[51]=a.disabled,t[52]=a.pending,t[53]=ue):ue=t[53];let de=j(ue),fe;t[54]!==G||t[55]!==E?(fe=(e,t)=>{let n=e.currentTarget;if(n.selectionStart===n.selectionEnd||!e.clipboardData||!E.references.some(e=>e.start<n.selectionEnd&&e.end>n.selectionStart))return;let r=v(n.selectionStart,n.selectionEnd,E.references)??{start:n.selectionStart,end:n.selectionEnd},i=h({text:E.text.slice(r.start,r.end),references:E.references.filter(e=>e.start>=r.start&&e.end<=r.end).map(e=>({...e,start:e.start-r.start,end:e.end-r.start}))});if(i.ok&&(e.preventDefault(),e.clipboardData.setData(`text/plain`,i.text),t)){let e=b(E,E.text.slice(0,r.start)+E.text.slice(r.end),r.start,r.start);G(e.document,e.caret)}},t[54]=G,t[55]=E,t[56]=fe):fe=t[56];let pe=j(fe),me;t[57]!==E.references||t[58]!==E.text?(me=Ee(E.text,E.references.map(ot))?.map(st),t[57]=E.references,t[58]=E.text,t[59]=me):me=t[59];let he=me,J=u&&E.text.length===0?`true`:void 0,ge;t[60]!==u||t[61]!==q||t[62]!==a.disabled||t[63]!==a.pending||t[64]!==de||t[65]!==f?(ge=u&&(0,$.jsx)(nt,{containerRef:s,disabled:!!(a.pending||a.disabled),onInsert:q,onSend:de,onRelease:tt,onHintChange:f}),t[60]=u,t[61]=q,t[62]=a.disabled,t[63]=a.pending,t[64]=de,t[65]=f,t[66]=ge):ge=t[66];let _e=E.text,ve=a.pending,ye=n&&a.layout===`inline`,Y;t[67]===a?Y=t[68]:(Y=()=>{a.pending||a.onSubmit()},t[67]=a,t[68]=Y);let xe=a.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,Se=a.layout===`inline`&&a.isMobile&&`pl-2`,Te;t[69]!==a.textLayoutClassName||t[70]!==xe||t[71]!==Se?(Te=V(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,xe,Se,a.textLayoutClassName),t[69]=a.textLayoutClassName,t[70]=xe,t[71]=Se,t[72]=Te):Te=t[72];let De;t[73]!==G||t[74]!==E?(De=(e,t)=>{let n=b(E,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);G(n.document,n.caret),A(t?.nativeEvent?.inputType===`insertFromPaste`)},t[73]=G,t[74]=E,t[75]=De):De=t[75];let ke=z?R:void 0,Ae=z?ee:void 0,Me;t[76]===a.textareaProps?Me=t[77]:(Me=e=>{a.textareaProps?.onScroll?.(e),te.current&&(te.current.scrollTop=e.currentTarget.scrollTop,te.current.scrollLeft=e.currentTarget.scrollLeft)},t[76]=a.textareaProps,t[77]=Me);let Le,Re;t[78]!==pe||t[79]!==a.textareaProps?(Le=e=>{a.textareaProps?.onCopy?.(e),e.defaultPrevented||pe(e,!1)},Re=e=>{a.textareaProps?.onCut?.(e),e.defaultPrevented||pe(e,!0)},t[78]=pe,t[79]=a.textareaProps,t[80]=Le,t[81]=Re):(Le=t[80],Re=t[81]);let ze;t[82]===a.textareaProps?ze=t[83]:(ze=e=>{O(e.currentTarget.selectionStart),a.textareaProps?.onSelect?.(e)},t[82]=a.textareaProps,t[83]=ze);let Be,Ve;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Be=()=>{N(!0)},Ve=e=>{N(!1),O(e.currentTarget.selectionStart)},t[84]=Be,t[85]=Ve):(Be=t[84],Ve=t[85]);let X;t[86]!==G||t[87]!==M||t[88]!==E||t[89]!==z||t[90]!==a.textareaProps?(X=e=>{if(a.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||Pe(e))){if(M){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?Ne(ie.current,E):we(ie.current,E);t&&(e.preventDefault(),ie.current=t.history,G(t.snapshot.document,t.snapshot.selection.end,!1),A(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=_(E,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),G(t.document,t.caret),A(!0);return}}z&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),ne.current?.keyDown(e.key))}},t[86]=G,t[87]=M,t[88]=E,t[89]=z,t[90]=a.textareaProps,t[91]=X):X=t[91];let He;t[92]!==a.textareaProps||t[93]!==ke||t[94]!==Ae||t[95]!==Me||t[96]!==Le||t[97]!==Re||t[98]!==ze||t[99]!==X?(He={...a.textareaProps,"aria-controls":ke,"aria-activedescendant":Ae,"aria-autocomplete":`list`,onScroll:Me,onCopy:Le,onCut:Re,onSelect:ze,onCompositionStart:Be,onCompositionEnd:Ve,onKeyDown:X},t[92]=a.textareaProps,t[93]=ke,t[94]=Ae,t[95]=Me,t[96]=Le,t[97]=Re,t[98]=ze,t[99]=X,t[100]=He):He=t[100];let Ue;t[101]!==U||t[102]!==R||t[103]!==z||t[104]!==a.isMobile||t[105]!==ce?(Ue=z?(0,$.jsx)(it,{ref:ne,query:z.query,isMobile:a.isMobile??!1,listId:R,onHighlightChange:F,onSelect:ce,onClose:U}):null,t[101]=U,t[102]=R,t[103]=z,t[104]=a.isMobile,t[105]=ce,t[106]=Ue):Ue=t[106];let We;t[107]!==E.text||t[108]!==he||t[109]!==m||t[110]!==a||t[111]!==ye||t[112]!==Y||t[113]!==Te||t[114]!==De||t[115]!==He||t[116]!==Ue?(We=(0,$.jsx)(Fe,{...a,value:_e,pending:ve,animateResize:ye,placeholder:m,disableInputWhilePending:!1,inputRef:I,onSubmit:Y,highlightedContent:he,highlightRef:te,textLayoutClassName:Te,onChange:De,textareaProps:He,children:Ue}),t[107]=E.text,t[108]=he,t[109]=m,t[110]=a,t[111]=ye,t[112]=Y,t[113]=Te,t[114]=De,t[115]=He,t[116]=Ue,t[117]=We):We=t[117];let Ge;return t[118]!==J||t[119]!==ge||t[120]!==We?(Ge=(0,$.jsxs)(`div`,{ref:s,className:`yuri-hold-to-talk-container`,"data-hold-to-talk-empty":J,children:[ge,We]}),t[118]=J,t[119]=ge,t[120]=We,t[121]=Ge):Ge=t[121],Ge};function ot(e){return{start:e.start,end:e.end,priority:103,...g(e)}}function st(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(De,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var ct=`rounded-[var(--contact-bubble-radius,1.125rem)] border border-border/40 cursor-zoom-in`;function lt({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=P(),i=Be(),{attachmentID:a,sha256:o,size:s,mime:c,filename:l}=t,u=Q.useMemo(()=>({type:`file`,attachmentID:a,sha256:o,size:s,mime:c,filename:l}),[a,o,s,c,l]),d=c.startsWith(`image/`),f=ve(l??``,c),[p,m]=Q.useState(0),[h,g]=Q.useState(``),[_,v]=Q.useState(!1),[y,b]=Q.useState(!1),x=Q.useRef(null),S=Q.useRef([]);Q.useEffect(()=>{g(``),v(!1);let t=new AbortController,n;return d&&qe(e,u,{signal:t.signal}).then(e=>{if(t.signal.aborted){e.release();return}n=e.release,g(e.url)}).catch(()=>{t.signal.aborted||v(!0)}),()=>{t.abort(),n?.()}},[e,u,i,d,p]),Q.useEffect(()=>()=>{x.current?.abort(),S.current.forEach(e=>URL.revokeObjectURL(e)),S.current=[]},[e,u,i]);let C=j(async(t=!1)=>{if(x.current)return;let i=new AbortController;x.current=i,b(!0),v(!1);try{let a=await Ke(e,u,{signal:i.signal});if(i.signal.aborted)return;S.current.forEach(e=>URL.revokeObjectURL(e));let o=URL.createObjectURL(a);if(S.current=[o],t&&n){n({open:!0,title:l||r(`assistants.contact.attachment.file`),content:``,video:{url:o,mimeType:c,filename:l}});return}let s=document.createElement(`a`);s.href=o,s.download=l||r(`assistants.contact.attachment.file`),document.body.appendChild(s),s.click(),s.remove()}catch{i.signal.aborted||v(!0)}finally{x.current===i&&(x.current=null),i.signal.aborted||b(!1)}}),w=l||r(d?`assistants.contact.attachment.image`:`assistants.contact.attachment.file`),T=j(e=>{!n||!h||n({open:!0,title:w,content:``,metadata:{tool:`image-preview`,filename:w,mime:c},previewSource:e.currentTarget,image:{url:h,mimeType:c,filename:w,size:s,gallery:[{url:h,mimeType:c,filename:w,size:s}],index:0}})});return d&&h&&!_?(0,$.jsx)(He,{src:h,alt:w,contentFrame:!0,className:ct,onError:()=>v(!0),onClick:T,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),T(e))},role:`button`,tabIndex:0,"data-assistant-contact-image":``}):d&&!_?(0,$.jsx)(X,{className:`h-[var(--yuri-content-image-height)] w-[min(20rem,100%)] rounded-[var(--contact-bubble-radius,1.125rem)]`}):(0,$.jsxs)(`div`,{className:`flex max-w-full flex-col gap-1 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5 ring-1 ring-inset ring-[var(--surface-subtle)]`,"data-assistant-contact-file":``,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,$.jsx)(J,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:w})]}),_?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:r(`assistants.contact.attachment.loadFailed`)}):null,d&&!_||y?(0,$.jsx)(`span`,{role:`status`,className:`typography-micro text-muted-foreground`,children:r(`common.loading`)}):(0,$.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,onClick:d?()=>m(e=>e+1):()=>void C(f&&!!n),children:r(_?`chat.history.retry`:f&&n?`contextPanel.mode.preview`:`assistants.contact.attachment.download`)})]})}function ut(e){let t=(0,Z.c)(39),{part:n,onShowPopup:r}=e,{t:i}=P(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=Ve(a,``),[s,c]=Q.useState(!1),l;t[0]!==n.filename||t[1]!==i?(l=n.filename||i(`assistants.contact.attachment.image`),t[0]=n.filename,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]!==u||t[4]!==r||t[5]!==o?(d=e=>{!r||!o||r({open:!0,title:u,content:``,metadata:{tool:`image-preview`,filename:u},previewSource:e.currentTarget,image:{url:o,filename:u,gallery:[{url:o,filename:u}],index:0}})},t[3]=u,t[4]=r,t[5]=o,t[6]=d):d=t[6];let f=j(d);if(ve(a,n.mime)&&a&&r){let e;t[7]!==r||t[8]!==n.filename||t[9]!==n.mime||t[10]!==a||t[11]!==i?(e=()=>r({open:!0,title:n.filename||i(`assistants.contact.attachment.file`),content:``,video:{url:a,filename:n.filename,mimeType:n.mime}}),t[7]=r,t[8]=n.filename,t[9]=n.mime,t[10]=a,t[11]=i,t[12]=e):e=t[12];let o;t[13]!==n.filename||t[14]!==i?(o=n.filename||i(`contextPanel.mode.preview`),t[13]=n.filename,t[14]=i,t[15]=o):o=t[15];let s;return t[16]!==e||t[17]!==o?(s=(0,$.jsx)(B,{variant:`secondary`,size:`sm`,onClick:e,children:o}),t[16]=e,t[17]=o,t[18]=s):s=t[18],s}if(n.mime.startsWith(`image/`)&&o&&!s){let e;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(e=()=>c(!0),t[19]=e):e=t[19];let n;t[20]===f?n=t[21]:(n=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),f(e))},t[20]=f,t[21]=n);let r;return t[22]!==u||t[23]!==f||t[24]!==o||t[25]!==n?(r=(0,$.jsx)(He,{src:o,alt:u,contentFrame:!0,className:ct,onError:e,onClick:f,onKeyDown:n,role:`button`,tabIndex:0,"data-assistant-contact-image":``}),t[22]=u,t[23]=f,t[24]=o,t[25]=n,t[26]=r):r=t[26],r}let p;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(J,{name:`file-text`,className:`size-4 shrink-0 text-muted-foreground`}),t[27]=p):p=t[27];let m;t[28]!==n.filename||t[29]!==i?(m=n.filename||i(`assistants.contact.attachment.file`),t[28]=n.filename,t[29]=i,t[30]=m):m=t[30];let h;t[31]===m?h=t[32]:(h=(0,$.jsx)(`span`,{className:`truncate typography-ui`,children:m}),t[31]=m,t[32]=h);let g;t[33]!==s||t[34]!==i?(g=s?(0,$.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>c(!1),children:i(`chat.history.retry`)}):null,t[33]=s,t[34]=i,t[35]=g):g=t[35];let _;return t[36]!==h||t[37]!==g?(_=(0,$.jsxs)(`div`,{className:`flex max-w-full items-center gap-2.5 rounded-[1.25rem] bg-[var(--surface-muted)] px-3.5 py-2.5`,"data-assistant-contact-file":``,children:[p,h,g]}),t[36]=h,t[37]=g,t[38]=_):_=t[38],_}function dt(e){let t=(0,Z.c)(5),{assistantID:n,part:r,onShowPopup:i}=e,a=Be(),o;return t[0]!==n||t[1]!==i||t[2]!==r||t[3]!==a?(o=`attachmentID`in r?(0,$.jsx)(lt,{assistantID:n,descriptor:r,onShowPopup:i},`${a}:${n}:${r.attachmentID}:${r.sha256}`):(0,$.jsx)(ut,{part:r,onShowPopup:i},`${a}:${r.url}`),t[0]=n,t[1]=i,t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var ft=Q.memo(e=>{let t=(0,Z.c)(32),{turn:n,retryDisabled:r,onRetry:i}=e,{t:a}=P(),d;t[0]===a?d=t[1]:(d=a(`assistants.contact.sendError.viewDetails`),t[0]=a,t[1]=d);let p;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(J,{name:`exclamation-fill`,className:`size-[18px] text-[var(--status-error)]`,"data-assistant-contact-error-dot":``}),t[2]=p):p=t[2];let h;t[3]===d?h=t[4]:(h=(0,$.jsx)(l,{type:`button`,"aria-label":d,"data-assistant-contact-send-error":``,className:`absolute right-full top-1/2 mr-1.5 flex size-9 -translate-y-1/2 cursor-pointer items-center justify-center rounded-md border-0 bg-transparent p-0 shadow-none outline-none focus-visible:opacity-70`,children:p}),t[3]=d,t[4]=h);let g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g={side:`flip`,align:`shift`,fallbackAxisSide:`end`},t[5]=g):g=t[5];let _;t[6]===a?_=t[7]:(_=a(`assistants.contact.sendError.title`),t[6]=a,t[7]=_);let v;t[8]===_?v=t[9]:(v=(0,$.jsx)(o,{className:`typography-ui-label font-medium`,children:_}),t[8]=_,t[9]=v);let y;t[10]!==a||t[11]!==n.error?(y=n.error||a(`assistants.contact.sendFailed`),t[10]=a,t[11]=n.error,t[12]=y):y=t[12];let b;t[13]===y?b=t[14]:(b=(0,$.jsx)(m,{role:`alert`,className:`mt-2 max-h-48 overflow-y-auto whitespace-pre-wrap typography-meta leading-relaxed [overflow-wrap:anywhere]`,children:y}),t[13]=y,t[14]=b);let x;t[15]!==i||t[16]!==n.messageID?(x=()=>i(n.messageID),t[15]=i,t[16]=n.messageID,t[17]=x):x=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(J,{name:`refresh`,className:`size-3`}),t[18]=S):S=t[18];let C;t[19]===a?C=t[20]:(C=a(`chat.history.retry`),t[19]=a,t[20]=C);let w;t[21]!==r||t[22]!==C||t[23]!==x?(w=(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(B,{type:`button`,size:`xs`,disabled:r,onClick:x,children:[S,C]})}),t[21]=r,t[22]=C,t[23]=x,t[24]=w):w=t[24];let T;t[25]!==w||t[26]!==v||t[27]!==b?(T=(0,$.jsx)(u,{children:(0,$.jsx)(f,{side:`left`,align:`center`,sideOffset:6,collisionPadding:12,collisionAvoidance:g,className:`z-50`,children:(0,$.jsxs)(s,{className:`yuri-mobile-overlay-surface w-72 max-w-[calc(100vw-2rem)] rounded-xl p-4 text-foreground outline-none`,"data-assistant-contact-send-error-popup":``,children:[v,b,w]})})}),t[25]=w,t[26]=v,t[27]=b,t[28]=T):T=t[28];let E;return t[29]!==T||t[30]!==h?(E=(0,$.jsxs)(c,{children:[h,T]}),t[29]=T,t[30]=h,t[31]=E):E=t[31],E});function pt(e){let t=(0,Z.c)(7),{children:n,failedTurn:r,retryDisabled:i,onRetry:a}=e,o;t[0]!==r||t[1]!==a||t[2]!==i?(o=r?.status===`failed`?(0,$.jsx)(ft,{turn:r,retryDisabled:i,onRetry:a}):null,t[0]=r,t[1]=a,t[2]=i,t[3]=o):o=t[3];let s;return t[4]!==n||t[5]!==o?(s=(0,$.jsxs)(`div`,{className:`relative min-w-0 max-w-full`,"data-assistant-contact-user-part":``,children:[n,o]}),t[4]=n,t[5]=o,t[6]=s):s=t[6],s}function mt(e){let t=(0,Z.c)(38),{children:n,outgoing:r,joinedBefore:i,joinedAfter:a,createdAt:o,time:s,media:c,mobile:l,hidden:u,colors:d,label:f}=e,p=Q.useRef(null),m=Q.useRef(null),h=Q.useRef(null),g;t[0]!==a||t[1]!==c||t[2]!==r?(g=()=>{let e=p.current,t=m.current,n=h.current;if(!e||!t||!n||c)return;let{width:i,height:o}=e.getBoundingClientRect();if(!i||!o)return;let s=window.getComputedStyle(e),l=e=>Math.min(Number.parseFloat(e)||0,i/2,o/2),u=l(s.borderTopLeftRadius),d=l(s.borderTopRightRadius),f=l(s.borderBottomLeftRadius),g=l(s.borderBottomRightRadius),_=8+i,v=r&&!a?`V ${o-10} C ${_} ${o-5} ${_+3} ${o-1} ${_+8} ${o}`:`V ${o-g} A ${g} ${g} 0 0 1 ${_-g} ${o}`,y=!r&&!a?`H 0 C 5 ${o-1} 8 ${o-5} 8 ${o-10}`:`H ${8+f} A ${f} ${f} 0 0 1 8 ${o-f}`;t.setAttribute(`viewBox`,`0 0 ${i+16} ${o}`),n.setAttribute(`d`,`M ${8+u} 0 H ${_-d} A ${d} ${d} 0 0 1 ${_} ${d} ${v} ${y} V ${u} A ${u} ${u} 0 0 1 ${8+u} 0 Z`)},t[0]=a,t[1]=c,t[2]=r,t[3]=g):g=t[3];let _=j(g),v;t[4]===_?v=t[5]:(v=()=>{_()},t[4]=_,t[5]=v);let y;t[6]!==_||t[7]!==a||t[8]!==i||t[9]!==c||t[10]!==l||t[11]!==r?(y=[r,i,a,l,c,_],t[6]=_,t[7]=a,t[8]=i,t[9]=c,t[10]=l,t[11]=r,t[12]=y):y=t[12],Q.useLayoutEffect(v,y),O(typeof ResizeObserver<`u`&&!c?p:null,_);let b=c||void 0,x=r?`outgoing`:`incoming`,S=i||void 0,C=a||void 0,w=l&&!c&&`touch-manipulation [-webkit-user-select:all] [user-select:all]`,T;t[13]===w?T=t[14]:(T=V(`yuri-contact-bubble min-w-0 max-w-full [overflow-wrap:anywhere]`,w),t[13]=w,t[14]=T);let E=d?.background,D=d?.foreground,k=u?`hidden`:void 0,A;t[15]!==E||t[16]!==D||t[17]!==k?(A={"--contact-bubble-fill":E,color:D,visibility:k},t[15]=E,t[16]=D,t[17]=k,t[18]=A):A=t[18];let M=A,N;t[19]===c?N=t[20]:(N=c?null:(0,$.jsx)(`svg`,{ref:m,className:`yuri-contact-bubble-outline`,"aria-hidden":`true`,preserveAspectRatio:`none`,children:(0,$.jsx)(`path`,{ref:h})}),t[19]=c,t[20]=N);let ee;t[21]===n?ee=t[22]:(ee=(0,$.jsx)(`div`,{className:`yuri-contact-bubble-body`,"data-assistant-contact-body":``,children:n}),t[21]=n,t[22]=ee);let P;t[23]!==o||t[24]!==c||t[25]!==s?(P=c?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`yuri-contact-bubble-time-space`,children:s}),(0,$.jsx)(`time`,{className:`yuri-contact-bubble-time`,dateTime:new Date(o).toISOString(),children:s})]}),t[23]=o,t[24]=c,t[25]=s,t[26]=P):P=t[26];let F;return t[27]!==f||t[28]!==M||t[29]!==N||t[30]!==ee||t[31]!==P||t[32]!==b||t[33]!==x||t[34]!==S||t[35]!==C||t[36]!==T?(F=(0,$.jsxs)(`div`,{ref:p,"aria-label":f,"data-assistant-contact-text":``,"data-assistant-contact-media":b,"data-contact-bubble-direction":x,"data-contact-bubble-joined-before":S,"data-contact-bubble-joined-after":C,className:T,style:M,children:[N,ee,P]}),t[27]=f,t[28]=M,t[29]=N,t[30]=ee,t[31]=P,t[32]=b,t[33]=x,t[34]=S,t[35]=C,t[36]=T,t[37]=F):F=t[37],F}var ht=[],gt=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
3
- `),_t=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),vt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},yt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},bt=(e,t,n,r)=>({messageID:t?`${e.turnID}:preview:${t.bubbleIndex}`:`${e.turnID}:preview:${r}`,assistantID:e.assistantID,role:`assistant`,turnID:e.turnID,bubbleIndex:t?.bubbleIndex??0,createdAt:t?.occurredAt??e.occurredAt,ordinal:n,status:r,fromAssistantID:null,fromAssistantName:null,parts:t?[{type:`text`,text:t.text}]:[],text:t?.text??``,cards:[]}),xt=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>bt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,bt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,bt(e,null,n+r.length,`admitted`)]:r},St=(e,t,n,r=[])=>{let i=new Set(e.map(e=>e.messageID)),a=t.flatMap((t,r)=>t.assistantID!==n||i.has(t.messageID)?[]:[{messageID:t.messageID,assistantID:n,role:`user`,turnID:t.messageID,bubbleIndex:0,createdAt:t.createdAt,ordinal:e.length+r,status:t.status,fromAssistantID:null,fromAssistantName:null,parts:[...t.parts],text:gt(t.parts),cards:[]}]),o=a.length===0?e:[...e,...a],s=r.filter(e=>e.assistantID===n);if(s.length===0)return o;let c=new Map,l=new Map;o.forEach((e,t)=>{if(c.set(e.turnID,t),e.role!==`assistant`||e.messageID.includes(`:preview:`))return;let n=l.get(e.turnID)??new Set;n.add(e.bubbleIndex),l.set(e.turnID,n)});let u=new Map,d=[];for(let e of s){let t=xt(e,l.get(e.turnID)??new Set,o.length+d.length);if(t.length===0)continue;let n=c.get(e.turnID);if(n===void 0){if(e.status===`failed`&&o.some(t=>t.turnID!==e.turnID))continue;d.push(...t);continue}let r=u.get(n)??[];r.push(...t),u.set(n,r)}return u.size===0&&d.length===0?o:o.flatMap((e,t)=>[e,...u.get(t)??[]]).concat(d)},Ct=(e,t)=>{let n=new Set(t.map(e=>e.messageID)),r=e.filter(e=>!n.has(e.messageID));return r.length===e.length?e:r},wt=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),Tt=(e,t,n,r=Date.now())=>{let i=e.filter(e=>e.assistantID!==t||e.status!==`failed`||e.turnID===n);return i.some(e=>e.assistantID===t&&e.turnID===n)?i.length===e.length?e:i:[...i,{assistantID:t,turnID:n,status:`admitted`,bubbles:[],occurredAt:r}]},Et=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:Tt(e,t.assistantID,t.turnID,t.admittedAt),Dt=(e,t)=>{let n=t.assistantID,r=t.pendingSendTurnIDs??new Set,i=t.settledTurnIDs??new Set,a=typeof t.snapshotRevision==`number`&&Number.isFinite(t.snapshotRevision)?t.snapshotRevision:null,o=t.admissionRevisionByTurnID instanceof Map?t.admissionRevisionByTurnID:new Map(Object.entries(t.admissionRevisionByTurnID??{}).map(([e,t])=>[e,Number(t)])),s=t.occurredAt??Date.now(),c=t.activeContactTurn&&t.activeContactTurn.turnID?t.activeContactTurn:null,l=!!(t.serverWorking||c),u=Et(e,c?{assistantID:n,turnID:c.turnID,admittedAt:c.admittedAt}:null,i),d=Array.isArray(t.messages)?t.messages:[];for(let e of d)e.role===`assistant`&&e.status===`error`&&(r.has(e.turnID)||i.has(e.turnID)||(u=kt(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=At(u,d),l){let t=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID)||c&&e.turnID===c.turnID)return!0;let t=o.get(e.turnID);return typeof t==`number`&&a!=null&&a<t?!0:typeof t==`number`&&a!=null&&a>=t&&e.turnID!==c?.turnID?!1:!c||e.turnID===c.turnID});return t.length===e.length&&t.every((t,n)=>t===e[n])?e:t}if(a==null)return u.length===e.length&&u.every((t,n)=>t===e[n])?e:u;let f=u.filter(e=>{if(e.assistantID!==n||e.status!==`admitted`&&e.status!==`streaming`||r.has(e.turnID))return!0;if(i.has(e.turnID))return!1;let t=o.get(e.turnID);return typeof t==`number`&&a<t});return f.length===e.length&&f.every((t,n)=>t===e[n])?e:f.length===u.length?u:f},Ot=(e,t)=>Tt(e,t.assistantID,t.turnID,t.occurredAt).map(e=>{if(e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`failed`||e.status===`complete`)return e;let n=e.bubbles.find(e=>e.bubbleIndex===t.bubbleIndex);if(n?.done)return e;let r=n?{...n,text:`${n.text}${t.delta}`,done:t.done,occurredAt:t.occurredAt}:{bubbleIndex:t.bubbleIndex,text:t.delta,done:t.done,occurredAt:t.occurredAt},i=n?e.bubbles.map(e=>e.bubbleIndex===t.bubbleIndex?r:e):[...e.bubbles,r].sort((e,t)=>e.bubbleIndex-t.bubbleIndex);return{...e,status:`streaming`,bubbles:i}}),kt=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:Tt(e,t.assistantID,t.turnID,t.occurredAt).map(e=>e.assistantID!==t.assistantID||e.turnID!==t.turnID||e.status===`complete`||e.status===`failed`?e:{...e,status:t.status===`error`?`failed`:`complete`,...t.error?{error:t.error}:{}}),At=(e,t)=>{let n=new Set(t.map(e=>e.turnID).filter(Boolean)),r=t.length>0?t[t.length-1]?.turnID??null:null,i=[...e].reverse().find(e=>e.status===`admitted`||e.status===`streaming`)?.turnID??r,a=new Set(t.flatMap(e=>e.role===`assistant`?[e.turnID]:[])),o=e.filter(e=>e.status===`admitted`||e.status===`streaming`||!(e.status===`complete`&&a.has(e.turnID)||!n.has(e.turnID)||e.status===`failed`&&(i&&i!==e.turnID||r&&r!==e.turnID)));return o.length===e.length?e:o},jt=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),Mt=(e,t)=>e instanceof re?e.code===`no_provider`?t.noProvider:e.code===`admission_timeout`||e.code===`generate_timeout`?t.timedOut:e.message&&e.message!==e.code?e.message:`${t.sendFailed}\n\n${e.code} (HTTP ${e.status})`:F(e)?t.timedOut:e instanceof Error&&e.message.trim()?e.message:t.sendFailed,Nt=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},Pt=e=>{let t=e.text.trim();if(e.sending||!t&&e.attachments.length===0||!e.gate.tryAcquire())return{ok:!1};let n=[...t?[{type:`text`,text:t}]:[],...e.attachments.map(e=>({type:`file`,mime:e.mime,url:e.url,filename:e.name}))],r=e.createMessageID();return{ok:!0,messageID:r,parts:n,turn:_t(e.assistantID,r,n,e.createdAt)}},Ft=e=>e.some(e=>e.status===`sending`),It=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),Lt=a(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),Rt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,zt=(e,t)=>{let n=(0,Z.c)(5),r=t!==void 0&&t,i;n[0]===e?i=n[1]:(i=t=>!!t.workingByID[e],n[0]=e,n[1]=i);let a=Lt(i),o;return n[2]!==a||n[3]!==r?(o=Rt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o},Bt=e=>{let t=(0,Z.c)(25),{name:n,avatarSeed:r,size:i,label:a,working:o,showWorkingDot:s,className:c,hoverTarget:l,followPointer:u,blinkOnMount:d}=e,f=i===void 0?24:i,p=s===void 0||s,m=d===void 0||d,{t:h}=P(),g;t[0]!==n||t[1]!==o?(g=e=>o!==void 0&&!!e.workingByID[n],t[0]=n,t[1]=o,t[2]=g):g=t[2];let _=Lt(g),v=!!(o||_),y=`calc(${f}px * var(--dpt-n, 1))`,b;t[3]===c?b=t[4]:(b=V(`relative inline-block shrink-0 align-middle leading-none`,c),t[3]=c,t[4]=b);let x;t[5]===y?x=t[6]:(x={width:y,minWidth:y,maxWidth:y,height:y,minHeight:y,maxHeight:y},t[5]=y,t[6]=x);let S=o===void 0?void 0:v?`working`:`idle`,C=r??n,w;t[7]!==m||t[8]!==u||t[9]!==l||t[10]!==a||t[11]!==n||t[12]!==f||t[13]!==S||t[14]!==C?(w=(0,$.jsx)(fe,{kind:`assistant`,motion:S,name:C,size:f,label:a,hoverTarget:l,followPointer:u,animationKey:n,blinkOnMount:m}),t[7]=m,t[8]=u,t[9]=l,t[10]=a,t[11]=n,t[12]=f,t[13]=S,t[14]=C,t[15]=w):w=t[15];let T;t[16]!==p||t[17]!==h||t[18]!==o?(T=o&&p?(0,$.jsx)(`span`,{className:`pointer-events-none absolute right-0 bottom-0 size-2.5 translate-x-0.5 translate-y-0.5 rounded-full bg-[var(--status-success)] ring-2 ring-background`,"data-assistant-working-dot":``,"aria-label":h(`assistants.contact.working`)}):null,t[16]=p,t[17]=h,t[18]=o,t[19]=T):T=t[19];let E;return t[20]!==T||t[21]!==b||t[22]!==x||t[23]!==w?(E=(0,$.jsxs)(`span`,{className:b,style:x,"data-assistant-working-avatar":``,children:[w,T]}),t[20]=T,t[21]=b,t[22]=x,t[23]=w,t[24]=E):E=t[24],E};function Vt(e){let t=(0,Z.c)(6),{value:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(J,{name:`brain`,weight:`medium`,className:`size-3.5 shrink-0`}),t[0]=r):r=t[0];let i;t[1]===n?i=t[2]:(i=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:n}),t[1]=n,t[2]=i);let a;return t[3]!==i||t[4]!==n?(a=(0,$.jsxs)(`p`,{"data-contact-card-model":``,className:`flex min-w-0 flex-1 items-center gap-1.5 text-[0.75em] leading-4 text-muted-foreground`,title:n,children:[r,i]}),t[3]=i,t[4]=n,t[5]=a):a=t[5],a}var Ht=Q.createContext(null),Ut=[`grid h-[calc(148px*var(--padding-scale,1))] w-[19rem] min-w-0 max-w-full shrink-0 grid-rows-[calc(40px*var(--padding-scale,1))_calc(20px*var(--padding-scale,1))_calc(20px*var(--padding-scale,1))_calc(48px*var(--padding-scale,1))] content-start cursor-pointer rounded-[var(--contact-bubble-radius,1.125rem)] bg-[var(--assistant-panel-background,var(--surface-muted))]`,`px-4 py-2.5 text-left typography-ui-label transition-colors duration-150 motion-reduce:transition-none`,`hover:bg-[color-mix(in_srgb,var(--assistant-panel-background,var(--surface-muted))_94%,black)]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),Wt=Ut,Gt=Ut,Kt=`row-start-1 mb-2 flex h-8 min-w-0 items-center gap-2`,qt=`row-start-2 min-w-0 self-start truncate font-medium leading-5 text-foreground`,Jt=`row-start-4 flex h-12 min-w-0 flex-col justify-center`;function Yt(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Xt=e=>{let t=(0,Z.c)(36),{card:n,assistant:r,active:a}=e,o=a===void 0||a,{t:s}=P(),c=Y(),l;t[0]===c?l=t[1]:(l=c&&!i(),t[0]=c,t[1]=l);let u=!!l,d=n.name,f=`${n.providerID}/${n.modelID}`,p=Q.useContext(Ht),m;t[2]!==n.assistantID||t[3]!==u||t[4]!==p?(m=()=>{if(p)return p({assistantID:n.assistantID});if(u){U.getState().openAssistant(n.assistantID);return}K(n.assistantID)},t[2]=n.assistantID,t[3]=u,t[4]=p,t[5]=m):m=t[5];let h=j(m),g;t[6]===h?g=t[7]:(g=e=>{Yt(e,h)},t[6]=h,t[7]=g);let _=j(g),v;t[8]!==s||t[9]!==d?(v=s(`assistants.contact.card.assistant.aria`,{name:d}),t[8]=s,t[9]=d,t[10]=v):v=t[10];let y=r?.avatarSeed,b=o?!!(r?.working||r?.activeContactTurn):void 0,x;t[11]!==n.assistantID||t[12]!==y||t[13]!==b?(x=(0,$.jsx)(`span`,{className:`relative inline-block shrink-0 leading-none`,"aria-hidden":!0,children:(0,$.jsx)(Bt,{name:n.assistantID,avatarSeed:y,size:32,working:b,showWorkingDot:!1,followPointer:!1})}),t[11]=n.assistantID,t[12]=y,t[13]=b,t[14]=x):x=t[14];let S;t[15]===s?S=t[16]:(S=s(`assistants.contact.card.assistant.label`),t[15]=s,t[16]=S);let C;t[17]===S?C=t[18]:(C=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,children:S}),t[17]=S,t[18]=C);let w;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(J,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[19]=w):w=t[19];let T;t[20]!==C||t[21]!==x?(T=(0,$.jsxs)(`div`,{className:Kt,children:[x,C,w]}),t[20]=C,t[21]=x,t[22]=T):T=t[22];let E;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(E=V(qt,`row-span-2 self-center`),t[23]=E):E=t[23];let D;t[24]===d?D=t[25]:(D=(0,$.jsx)(`h3`,{className:E,title:d,children:d}),t[24]=d,t[25]=D);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=V(Jt,`justify-end pb-1`),t[26]=O):O=t[26];let k;t[27]===f?k=t[28]:(k=(0,$.jsx)(`div`,{className:O,children:(0,$.jsx)(`div`,{className:`flex h-4 min-w-0 items-center`,children:(0,$.jsx)(Vt,{value:f})})}),t[27]=f,t[28]=k);let A;return t[29]!==_||t[30]!==h||t[31]!==T||t[32]!==D||t[33]!==k||t[34]!==v?(A=(0,$.jsxs)(`article`,{className:Wt,role:`button`,tabIndex:0,"aria-label":v,"data-assistant-contact-card":`assistant`,onClick:h,onKeyDown:_,children:[T,D,k]}),t[29]=_,t[30]=h,t[31]=T,t[32]=D,t[33]=k,t[34]=v,t[35]=A):A=t[35],A},Zt=e=>!!(e&&typeof e==`object`&&!Array.isArray(e)),Qt=e=>typeof e==`string`&&/^([01]\d|2[0-3]):[0-5]\d$/.test(e),$t=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6,en=e=>e.kind===`cron`?e.cron===void 0:e.kind===`once`?e.date===void 0:e.kind===`weekly`?e.times===void 0||e.weekdays===void 0:e.kind===`daily`&&e.times===void 0,tn=e=>{if(!Zt(e)||e.timezone!==void 0&&typeof e.timezone!=`string`)return!1;if(e.kind===`cron`)return typeof e.cron==`string`&&!!e.cron.trim();if(e.kind===`once`)return typeof e.date==`string`&&/^\d{4}-\d{2}-\d{2}$/.test(e.date)&&Qt(e.time);let t=Array.isArray(e.times)&&e.times.length>0&&e.times.every(Qt);return e.kind===`daily`?t||Qt(e.time):e.kind===`weekly`&&(t||Qt(e.time))&&Array.isArray(e.weekdays)&&e.weekdays.length>0&&e.weekdays.every($t)},nn=(e,t)=>{if(!en(e)||!tn(t?.schedule))return e;let n=t.schedule;return{...e,kind:n.kind,time:n.time??n.times?.[0]??null,timezone:n.timezone??e.timezone,cron:n.cron??null,date:n.date??null,times:n.times??null,weekdays:n.weekdays??null}},rn=(e,t)=>{let n=e.kind===`daily`||e.kind===`weekly`||e.kind===`once`||e.kind===`cron`?t(`sessions.scheduledTasks.editor.scheduleType.${e.kind}`):e.kind||``,r=[...new Set((e.times?.length?e.times:e.time?[e.time]:[]).filter(Qt))].sort(),i=r.join(`, `),a=n,o=r.length===1;if(e.kind===`cron`)i=e.cron?.trim()||n,a=e.cron?.trim()?n:``,o=!1;else if(e.kind===`once`)i=[e.date?.trim(),i].filter(Boolean).join(` `),o=!1;else if(e.kind===`weekly`&&e.weekdays?.length){let n=[`sun`,`mon`,`tue`,`wed`,`thu`,`fri`,`sat`];a=[...new Set(e.weekdays.filter($t))].sort((e,t)=>e-t).map(e=>t(`sessions.scheduledTasks.dialog.schedule.weekdayShort.${n[e]}`)).join(`, `)}return{value:i||t(`assistants.contact.card.schedule.timeUnavailable`),cadence:a,clock:o,timezone:e.timezone}},an=e=>{let t=(0,Z.c)(44),{card:n,task:r}=e,{t:i}=P(),a=n.name,o;t[0]!==n||t[1]!==i||t[2]!==r?(o=rn(nn(n,r),i),t[0]=n,t[1]=i,t[2]=r,t[3]=o):o=t[3];let s=o,c;t[4]===n.prompt?c=t[5]:(c=n.prompt?.trim(),t[4]=n.prompt,t[5]=c);let l=c,u=Q.useContext(Ht),d;t[6]!==n.projectID||t[7]!==n.taskID||t[8]!==u?(d=()=>{if(u)return u({projectID:n.projectID,taskID:n.taskID});ge(n.projectID,n.taskID)},t[6]=n.projectID,t[7]=n.taskID,t[8]=u,t[9]=d):d=t[9];let f=j(d),p;t[10]===f?p=t[11]:(p=e=>{Yt(e,f)},t[10]=f,t[11]=p);let m=j(p),h;t[12]!==i||t[13]!==a?(h=i(`assistants.contact.card.schedule.aria`,{name:a}),t[12]=i,t[13]=a,t[14]=h):h=t[14];let g;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(J,{name:`calendar`,weight:`medium`,className:`size-4 shrink-0`}),t[15]=g):g=t[15];let _;t[16]===i?_=t[17]:(_=i(`assistants.contact.card.schedule.label`),t[16]=i,t[17]=_);let v;t[18]===_?v=t[19]:(v=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[g,(0,$.jsx)(`span`,{className:`truncate`,children:_})]}),t[18]=_,t[19]=v);let y;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(J,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[20]=y):y=t[20];let b;t[21]===v?b=t[22]:(b=(0,$.jsxs)(`div`,{className:Kt,children:[v,y]}),t[21]=v,t[22]=b);let x;t[23]===a?x=t[24]:(x=(0,$.jsx)(`h3`,{className:qt,title:a,children:a}),t[23]=a,t[24]=x);let S;t[25]===l?S=t[26]:(S=l?(0,$.jsx)(`p`,{className:`row-start-3 mt-1 min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,title:l,children:l}):null,t[25]=l,t[26]=S);let C;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(C=V(Jt,`justify-end`),t[27]=C):C=t[27];let w;t[28]===s.cadence?w=t[29]:(w=s.cadence?(0,$.jsx)(`span`,{"data-contact-schedule-cadence":``,className:`min-w-0 max-w-[36%] flex-[0_1_auto] truncate text-[0.75em] leading-4 text-muted-foreground`,title:s.cadence,children:s.cadence}):null,t[28]=s.cadence,t[29]=w);let T=`min-w-0 flex-[0_1_auto] truncate leading-[22px] text-foreground tabular-nums ${s.clock?`text-[1.25em] font-normal tracking-[-0.3px]`:`text-[0.85em]`}`,E;t[30]!==s.value||t[31]!==T?(E=(0,$.jsx)(`p`,{className:T,title:s.value,children:s.value}),t[30]=s.value,t[31]=T,t[32]=E):E=t[32];let D;t[33]!==w||t[34]!==E?(D=(0,$.jsx)(`div`,{className:C,children:(0,$.jsxs)(`div`,{"data-contact-schedule-time":``,className:`flex min-w-0 flex-none items-baseline gap-1.5`,children:[w,E]})}),t[33]=w,t[34]=E,t[35]=D):D=t[35];let O;return t[36]!==m||t[37]!==f||t[38]!==b||t[39]!==x||t[40]!==S||t[41]!==D||t[42]!==h?(O=(0,$.jsxs)(`article`,{className:Wt,role:`button`,tabIndex:0,"aria-label":h,"data-assistant-contact-card":`schedule`,onClick:f,onKeyDown:m,children:[b,x,S,D]}),t[36]=m,t[37]=f,t[38]=b,t[39]=x,t[40]=S,t[41]=D,t[42]=h,t[43]=O):O=t[43],O},on=(e,t)=>t===`cancelled`?t:e===`busy`||e===`retry`?e:t===`error`||t===`question`||t===`complete`||t===`busy`||t===`retry`?t:e===`idle`?`complete`:t===`idle`?t:t||`busy`,sn=e=>e===`cancelled`?`assistants.contact.card.session.status.cancelled`:e===`busy`?`assistants.contact.card.session.status.busy`:e===`retry`?`assistants.contact.card.session.status.retry`:e===`idle`?`assistants.contact.card.session.status.idle`:e===`complete`?`assistants.contact.card.session.status.complete`:e===`error`?`assistants.contact.card.session.status.error`:e===`question`?`assistants.contact.card.session.status.question`:null,cn=e=>e===`busy`?`text-[var(--status-info)]`:e===`retry`||e===`question`?`text-[var(--status-warning)]`:e===`error`?`text-[var(--status-error)]`:e===`idle`||e===`complete`?`text-[var(--status-success)]`:`text-muted-foreground`,ln=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,un=e=>{let t=(0,Z.c)(57),{card:n}=e,{t:r}=P(),a=Y(),o;t[0]===a?o=t[1]:(o=a&&!i(),t[0]=a,t[1]=o);let s=!!o,c;t[2]===n.sessionID?c=t[3]:(c=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=c);let l=W(c),u=se(n.sessionID),d=(typeof l?.title==`string`&&l.title.trim()?l.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),f=on(u?.type,n.status),p=sn(f),m;t[4]!==n.directory||t[5]!==l?(m=typeof l?.directory==`string`&&l.directory.trim()?l.directory.trim():n.directory,t[4]=n.directory,t[5]=l,t[6]=m):m=t[6];let h=m,g;t[7]===h?g=t[8]:(g=ln(h),t[7]=h,t[8]=g);let _=g,v=H(h).data?.current?.trim()||null,y;t[9]===l?y=t[10]:(y=Ae(l),t[9]=l,t[10]=y);let b=y,x=f===`complete`||f===`idle`?Se(l):null,S=Q.useContext(Ht),C;t[11]!==n.directory||t[12]!==n.sessionID||t[13]!==s||t[14]!==S?(C=()=>{let e=Me(n.sessionID)?.directory||n.directory;if(S)return S({sessionId:n.sessionID,directory:e});z(n.sessionID,e,{phoneShell:s,switchToChat:!0}),s||N.getState().setActiveMainTab(`chat`)},t[11]=n.directory,t[12]=n.sessionID,t[13]=s,t[14]=S,t[15]=C):C=t[15];let w=j(C),T;t[16]===w?T=t[17]:(T=e=>{Yt(e,w)},t[16]=w,t[17]=T);let E=j(T),D=Gt,O=r(`assistants.contact.card.session.aria`,{title:d}),k;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(J,{name:`chat-thread`,weight:`medium`,className:`size-4 shrink-0`}),t[18]=k):k=t[18];let A;t[19]===r?A=t[20]:(A=r(`assistants.contact.card.session.label`),t[19]=r,t[20]=A);let M;t[21]===A?M=t[22]:(M=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[k,(0,$.jsx)(`span`,{className:`truncate`,children:A})]}),t[21]=A,t[22]=M);let ee=p?(0,$.jsxs)(`span`,{"data-assistant-session-status":``,className:V(`ml-auto inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[0.75em] leading-4`,cn(f)),children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}),r(p)]}):null,F;t[23]!==M||t[24]!==ee?(F=(0,$.jsxs)(`div`,{className:Kt,children:[M,ee]}),t[23]=M,t[24]=ee,t[25]=F):F=t[25];let I;t[26]===d?I=t[27]:(I=(0,$.jsx)(`h3`,{className:qt,title:d,children:d}),t[26]=d,t[27]=I);let te=V(`flex min-w-0 items-center gap-1.5 text-foreground`,v&&`max-w-[45%] shrink-0`),ne;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(ne=(0,$.jsx)(J,{name:`folder`,weight:`medium`,className:`size-3.5 shrink-0 text-muted-foreground`}),t[28]=ne):ne=t[28];let L;t[29]===_?L=t[30]:(L=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),t[29]=_,t[30]=L);let re;t[31]!==h||t[32]!==te||t[33]!==L?(re=(0,$.jsxs)(`p`,{className:te,title:h,children:[ne,L]}),t[31]=h,t[32]=te,t[33]=L,t[34]=re):re=t[34];let ie;t[35]===v?ie=t[36]:(ie=v?(0,$.jsxs)(`p`,{"data-contact-session-branch":``,className:`flex min-w-0 items-center gap-1 text-muted-foreground`,title:v,children:[(0,$.jsx)(J,{name:`git-branch`,weight:`medium`,className:`size-3 shrink-0`}),(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:v})]}):null,t[35]=v,t[36]=ie);let R;t[37]!==re||t[38]!==ie?(R=(0,$.jsxs)(`div`,{"data-contact-session-project":``,className:`flex h-4 min-w-0 flex-none items-center gap-2 text-[0.8em] leading-4`,children:[re,ie]}),t[37]=re,t[38]=ie,t[39]=R):R=t[39];let ae=x?(0,$.jsxs)(`p`,{"data-contact-session-changes":``,className:`flex h-4 min-w-0 flex-none items-center gap-1.5 overflow-hidden whitespace-nowrap text-[0.8em] leading-4 text-muted-foreground tabular-nums`,children:[(0,$.jsx)(J,{name:`code`,weight:`medium`,className:`size-3.5 shrink-0`}),x.additions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-success)]`,children:[`+`,x.additions]}),x.deletions===void 0?null:(0,$.jsxs)(`span`,{className:`text-[var(--status-error)]`,children:[`−`,x.deletions]}),x.files===void 0?null:(0,$.jsx)(`span`,{className:`text-muted-foreground`,children:x.files===1?r(`assistants.contact.card.session.changes.filesSingle`,{count:x.files}):r(`assistants.contact.card.session.changes.filesPlural`,{count:x.files})})]}):null,oe;t[40]===b?oe=t[41]:(oe=b?(0,$.jsx)(Vt,{value:b}):null,t[40]=b,t[41]=oe);let B;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(J,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[42]=B):B=t[42];let U;t[43]===oe?U=t[44]:(U=(0,$.jsxs)(`div`,{"data-contact-session-bottom":``,className:`mt-auto flex h-4 min-w-0 flex-none items-center gap-2`,children:[oe,B]}),t[43]=oe,t[44]=U);let G;t[45]!==R||t[46]!==ae||t[47]!==U?(G=(0,$.jsxs)(`div`,{"data-contact-session-details":``,className:`row-start-3 row-end-5 flex min-w-0 flex-col gap-1.5 py-1`,children:[R,ae,U]}),t[45]=R,t[46]=ae,t[47]=U,t[48]=G):G=t[48];let K;return t[49]!==E||t[50]!==w||t[51]!==O||t[52]!==F||t[53]!==I||t[54]!==G||t[55]!==D?(K=(0,$.jsxs)(`article`,{className:D,role:`button`,tabIndex:0,"aria-label":O,"data-assistant-contact-card":`session`,onClick:w,onKeyDown:E,children:[F,I,G]}),t[49]=E,t[50]=w,t[51]=O,t[52]=F,t[53]=I,t[54]=G,t[55]=D,t[56]=K):K=t[56],K},dn=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate();function fn(e){let t=new Map,n=null;for(let r of e){if(!(r.status===`error`||r.status===`failed`||r.parts.some(e=>e.type!==`text`||e.text.trim()&&!e.text.trim().startsWith(`yuri.settle.`)&&!e.text.trim().startsWith(`oc.settle.`))))continue;let e=new Date(r.createdAt);Number.isFinite(e.getTime())&&((!n||!dn(n,e))&&t.set(r.messageID,r.createdAt),n=e)}return t}function pn(e,t,n,r){let i=new Date(r);i.setDate(i.getDate()-1);let a=new Intl.DateTimeFormat(e,{month:`long`,day:`numeric`}),o=new Intl.DateTimeFormat(e,{year:`numeric`,month:`long`,day:`numeric`});return e=>{let s=new Date(e);return dn(s,r)?t:dn(s,i)?n:(s.getFullYear()===r.getFullYear()?a:o).format(s)}}function mn(e,t,n){let r=new Intl.DateTimeFormat(e,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),i=new Intl.DateTimeFormat(e,{month:`long`,day:`numeric`}),a=new Intl.DateTimeFormat(e,{year:`numeric`,month:`long`,day:`numeric`});return e=>{let o=new Date(e);return`${dn(o,n)?t:(o.getFullYear()===n.getFullYear()?i:a).format(o)} ${r.format(o)}`}}var hn=2,gn=1500,_n=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),vn=e=>e.scrollHeight-e.scrollTop-e.clientHeight,yn=e=>vn(e)<=hn,bn=(e,t)=>{let n=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;n&&n!==e;){if(n instanceof HTMLElement&&n.scrollHeight>n.clientHeight+1&&n.scrollTop+n.clientHeight<n.scrollHeight-1)return!0;n=n.parentElement}return!1},xn=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,Sn=({active:e,assistantID:t,contentRevision:n,onLoadEarlier:r,overlayComposerRef:i})=>{let a=Q.useRef(null),[o,s]=Q.useState(null),[c,l]=Q.useState(null),u=Q.useRef(!0),d=Q.useRef(null),f=Q.useRef(null),p=Q.useRef(null),m=Q.useRef(0),h=Q.useRef(null),g=Q.useRef(null),_=Q.useRef(e);_.current=e;let v=he(),y=Q.useRef(!1),b=Q.useRef(null),x=Q.useRef(null),S=Q.useRef(0),C=Q.useRef(null),w=j(e=>{let t=C.current;C.current=null,t?.(e)}),T=j(()=>{S.current+=1,b.current?.stop(),b.current=null,x.current=null}),E=Q.useMemo(()=>e=>{a.current=e,s(t=>t===e?t:e)},[]),k=Q.useMemo(()=>e=>{l(t=>t===e?t:e)},[]),A=j(()=>{let e=a.current,t=e?.parentElement;if(!e||!t||!_.current)return;let n=`${Math.max(0,e.offsetWidth-e.clientWidth)}px`;t.style.getPropertyValue(`--contact-scrollbar-width`)!==n&&t.style.setProperty(`--contact-scrollbar-width`,n)});Q.useLayoutEffect(()=>{A()},[e,o,A]);let M=j(()=>{let e=a.current;if(!e||!_.current||u.current)return;let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.getBoundingClientRect().bottom>t);d.current=n?{id:n.dataset.messageId,offset:n.getBoundingClientRect().top-t,scrollTop:e.scrollTop}:null}),N=j(()=>{let e=a.current,t=d.current;if(!e||!_.current||u.current)return;if(!t){M();return}let n=e.scrollTop-t.scrollTop;if(Math.abs(n)>.5&&h.current){m.current=e.scrollTop,M();return}let r=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===t.id);if(!r){M();return}let i=r.getBoundingClientRect().top-e.getBoundingClientRect().top-(t.offset-n);Math.abs(i)>.5&&(e.scrollTop+=i),m.current=e.scrollTop,d.current={id:t.id,offset:r.getBoundingClientRect().top-e.getBoundingClientRect().top,scrollTop:e.scrollTop}}),ee=j(()=>{T(),w(!1),u.current=!1,m.current=a.current?.scrollTop??0,M()}),P=Q.useRef(null),F=j((e,t)=>{let n=a.current;if(!_.current||!n){t?.(!1);return}T(),w(!1);let r=!yn(_n(n));C.current=r?t??null:null,P.current=r&&t?null:e??null,u.current=!0,d.current=null,g.current=null,m.current=n.scrollTop,r||t?.(!0)}),I=j(()=>{if(!_.current||!u.current)return!1;let e=a.current;if(!e)return!1;let t=_n(e),n=Math.min(m.current,Math.max(0,t.scrollHeight-t.clientHeight));if(t.scrollTop<n-.5)return T(),u.current=!1,m.current=t.scrollTop,M(),w(!1),!1;let r=!y.current;if(r&&e.querySelector(`[data-message-id]`)&&(y.current=!0),yn(t))return T(),m.current=t.scrollTop,w(!0),!1;let i=Math.max(0,t.scrollHeight-t.clientHeight);if(!r&&!v){if(x.current===i)return!1;T(),x.current=i;let t=S.current,n=P.current;return P.current=null,b.current=me(e.scrollTop,i,{duration:n?.duration??.22,ease:n?[...n.ease]:`easeOut`,onUpdate:n=>{if(S.current!==t||!_.current||!u.current||a.current!==e)return;let r=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop<Math.min(m.current,r)-.5){u.current=!1,T(),m.current=e.scrollTop,M(),w(!1);return}e.scrollTop=Math.min(Math.max(e.scrollTop,n),r),m.current=e.scrollTop},onComplete:()=>{S.current===t&&(b.current=null,x.current=null,I())}}),!0}return T(),e.scrollTop=i,m.current=e.scrollTop,w(!0),!0}),te=j(e=>{g.current={direction:e,expiresAt:performance.now()+gn}}),ne=j(()=>{let e=g.current;return e?performance.now()>e.expiresAt?(g.current=null,null):e.direction:null}),L=j(()=>{T(),w(!1),P.current=null,u.current=!1,M()}),re=j(()=>{if(!_.current)return;let e=a.current;if(!e)return;let t=_n(e),n=t.scrollTop>m.current,i=Math.min(m.current,Math.max(0,t.scrollHeight-t.clientHeight));if(m.current=t.scrollTop,u.current){t.scrollTop<i-.5&&L();return}let o=ne();N(),t.scrollTop<=80&&o===`up`&&r?.(),n&&yn(t)&&(o===`down`||o===`scrollbar`)&&(u.current=!0)}),ie=j(e=>{let t=a.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(ke(t,e.target))return;te(`up`),L(),t.scrollTop<=80&&r?.();return}bn(t,e.target)||te(`down`)}}),R=j(e=>{g.current=null;let t=e.touches.item(0);h.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),ae=j(e=>{let t=a.current,n=e.touches.item(0);if(!t||!n){h.current=null;return}let i=h.current;if(!i)return;let o=n.clientY-i.y,s=o*i.deltaY<0,c=(s?0:i.deltaX)+n.clientX-i.x,l=(s?0:i.deltaY)+o;if(h.current={x:n.clientX,y:n.clientY,deltaX:c,deltaY:l},!(Math.abs(c)>=Math.abs(l))){if(l>0&&ke(t,e.target)||l<0&&bn(t,e.target)){h.current.deltaX=0,h.current.deltaY=0;return}te(l>0?`up`:`down`),l>2&&(L(),t.scrollTop<=80&&r?.())}}),oe=j(()=>{h.current=null}),z=j(e=>{if(Te(e)){te(`up`),L(),(a.current?.scrollTop??1/0)<=80&&r?.();return}xn(e)&&te(`down`)}),B=j(e=>{let t=a.current;e.pointerType===`mouse`&&e.target===t&&te(`scrollbar`)}),se=j(()=>{let e=a.current?.parentElement;if(!e||!_.current)return!1;let t=`${i?.current?.offsetHeight??0}px`;return e.style.getPropertyValue(`--contact-composer-height`)!==t&&(e.style.setProperty(`--contact-composer-height`,t),!0)});Q.useLayoutEffect(()=>{se()},[e,o,i,se]),Q.useLayoutEffect(()=>{let n=e?t:null,r=a.current;(f.current!==n||p.current!==r)&&(T(),w(!1),P.current=null,y.current=!1,f.current=n,p.current=r,u.current=!0,d.current=null,g.current=null,h.current=null,m.current=r?.scrollTop??0),e&&(I(),N())},[e,t,n,o,v,i]),Q.useLayoutEffect(()=>()=>{T(),w(!1)},[e,t,o,T,w]);let V=Q.useMemo(()=>()=>void 0,[]),H=e&&o?o:V,U=Q.useMemo(()=>({passive:!0}),[]);D(`scroll`,re,H,U),D(`wheel`,ie,H,U),D(`touchstart`,R,H,U),D(`touchmove`,ae,H,U),D(`touchend`,oe,H,U),D(`touchcancel`,oe,H,U),D(`keydown`,z,H),D(`pointerdown`,B,H,U);let W=Q.useRef(null),G=j(()=>{let e=a.current;W.current=e&&_.current?{element:e,top:e.scrollTop,height:e.clientHeight}:null}),K=j(()=>{A();let e=a.current,t=W.current;!e||t?.element!==e||t.height===e.clientHeight||(W.current=null,T(),e.scrollTop=Math.max(0,t.top+t.height-e.clientHeight),m.current=e.scrollTop,u.current?I():M())});D(`yuri:keyboard-native-layout`,G,e&&typeof window<`u`?window:V);let ce=j(()=>{I(),N()}),le=j(()=>{se()&&ce()}),q=typeof ResizeObserver<`u`;return O(q&&e?c:null,ce),O(q&&e?o:null,K),O(q&&e&&i?i:null,le,{box:`border-box`}),{scrollRef:E,contentRef:k,preparePrepend:ee,followLatest:F}},Cn=.3,wn=[.19919472913616398,.010644531250000006,.27920937042459737,.91025390625],Tn=[.23,1,.32,1],En=pe(...wn),Dn=pe(...Tn),On=.15,kn=.1,An=.08,jn=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),Mn=e=>Number.parseFloat(e)||0,Nn=(e,t,n)=>e+(t-e)*n,Pn=e=>[e.borderTopLeftRadius,e.borderTopRightRadius,e.borderBottomRightRadius,e.borderBottomLeftRadius],Fn=e=>{let t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=t.left+Mn(n.borderLeftWidth)+Mn(n.paddingLeft),i=t.top+Mn(n.borderTopWidth)+Mn(n.paddingTop);return{left:r,top:i,width:t.right-Mn(n.borderRightWidth)-Mn(n.paddingRight)-r,height:t.bottom-Mn(n.borderBottomWidth)-Mn(n.paddingBottom)-i}},In=e=>({color:e.color,fontFamily:e.fontFamily,fontSize:e.fontSize,fontWeight:e.fontWeight,fontFeatureSettings:e.fontFeatureSettings,letterSpacing:e.letterSpacing,lineHeight:e.lineHeight,whiteSpace:`pre-wrap`,overflowWrap:`anywhere`}),Ln=(e,t,n=!1)=>{if(!t.value.trim())return null;let r=e.querySelector(`[data-composer-material]`)??e,i=window.getComputedStyle(r),a=Fn(t),o=t.parentElement?.querySelector(`[data-composer-highlight]`),s=In(window.getComputedStyle(t));return o&&(s.color=window.getComputedStyle(o).color),{compact:n,background:jn(r.getBoundingClientRect()),backgroundColor:i.backgroundColor,radii:Pn(i),text:t.value,textBox:{...a,top:a.top-t.scrollTop},textStyle:s}},Rn=e=>{let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,pointerEvents:`none`,margin:`0px`,...e}),t},zn=(e,t,n,r)=>(e.style.opacity=String(t),me(e,{opacity:[t,n]},{duration:r,ease:`linear`})),Bn=(e,t,n=t,r)=>{let i=window.getComputedStyle(t),a=t.querySelector(`.yuri-contact-bubble-outline path`),o=a?window.getComputedStyle(a).fill:i.backgroundColor,s=Pn(i),c=jn(t.getBoundingClientRect()),l=Fn(t),u=e.compact?{...e.background,left:e.textBox.left-Mn(i.paddingLeft),width:Math.min(e.background.width,Math.max(120,c.width+32))}:e.background,d={left:u.left,top:u.top+u.height-c.height},f={x:e.textBox.left-d.left-(l.left-c.left),y:e.textBox.top-d.top-(l.top-c.top)},p=Rn({position:`fixed`,left:`0px`,top:`0px`,overflow:`hidden`,zIndex:`60`,willChange:`transform, width, height`});p.setAttribute(`aria-hidden`,`true`),p.setAttribute(`data-assistant-contact-send-flight`,``),p.style.backgroundColor=e.backgroundColor;let m=Rn({...e.textStyle,left:`0px`,top:`0px`,width:`${e.textBox.width}px`});m.textContent=e.text;let h=Rn({...In(i),left:`0px`,top:`0px`,width:`${l.width}px`});h.textContent=(t.querySelector(`[data-assistant-contact-body]`)??t).textContent??``,p.append(m,h);let g=n=>{let r=En(n),i=Dn(n),a=jn(t.getBoundingClientRect()),o=u,g=Nn(o.left,a.left,i),_=Nn(o.left+o.width,a.left+a.width,i),v=Nn(o.top+o.height,a.top+a.height,r),y=Nn(o.height,a.height,r),b=v-y;p.style.transform=`translate3d(${g}px, ${b}px, 0)`,p.style.width=`${_-g}px`,p.style.height=`${y}px`,p.style.borderRadius=s.map((t,n)=>`${Nn(Mn(e.radii[n]),Mn(t),r)}px`).join(` `);let x=a.left+(d.left-c.left)*(1-i),S=a.top+(d.top-c.top)*(1-r),C=`translate3d(${x+(l.left-c.left)+f.x*(1-r)-g}px, ${S+(l.top-c.top)+f.y*(1-r)-b}px, 0)`;m.style.transform=C,h.style.transform=C},_=!1,v=[],y=()=>{_||(_=!0,v.forEach(e=>e.stop()),p.remove(),n.style.visibility=``,r?.())};return n.style.visibility=`hidden`,g(0),document.body.appendChild(p),v.push(me(p,{backgroundColor:[e.backgroundColor,o]},{duration:On,ease:`linear`}),zn(m,1,0,kn),zn(h,0,1,An),me(0,1,{duration:Cn,ease:`linear`,onUpdate:g,onComplete:y})),y},Vn=64,Hn=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 instanceof File)},Un=e=>Array.from(e?.files||[]),Wn=async(e,t=ee)=>{let n=[],r=0;for(let i of Array.from(e||[])){if(!i||i.size<=0)continue;if(i.size>26214400){r+=1;continue}let e=URL.createObjectURL(i);n.push({id:t(),url:e,name:i.name.trim()||`attachment`,mime:i.type.trim()||`application/octet-stream`,file:i})}return{attachments:n,skippedTooLarge:r}},Gn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(Vn))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,Vn)},Kn=_e(()=>M(()=>import(`./ToolOutputDialog-5xBwOJ6a.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]))),qn=e=>e.trim().startsWith(`yuri.settle.`)||e.trim().startsWith(`oc.settle.`),Jn=e=>e.status===`error`||e.status===`failed`&&e.messageID.endsWith(`:preview:failed`),Yn=e=>e.role===`assistant`&&e.status!==`error`&&e.parts.some(e=>e.type===`text`)?`${e.turnID}:assistant:${e.bubbleIndex}`:e.messageID,Xn=({assistant:e,warning:t,active:n,overlayHeader:r=!1,overlayComposer:i=!1})=>{let{t:a,locale:o}=P(),s=Be(),c=N(e=>e.isMobile),l=L(),u=ae(),d=ne(e.id,n),f=N(e=>e.isSettingsDialogOpen),p=n&&!f&&!d.hasMessageGap?oe(e,d.data):null,m=ce(e.name).displayName||e.name,h=ue(de(e.avatarSeed??e.id).color),g=(e,t)=>{let n=e?u.data?.assistants.find(t=>t.id===e):void 0;return n?ce(n.name).displayName||n.name:t||a(`assistants.contact.peer.unknown`)},[_,v]=Q.useState(``),[y,b]=Q.useState([]),x=Q.useRef(new Map),S=Q.useRef(new Map),C=Q.useRef(new AbortController);Q.useEffect(()=>{let e=new AbortController;return C.current=e,()=>e.abort()},[e.id,s]);let w=Q.useRef(new Set),[E,D]=Q.useState([]);Q.useEffect(()=>{let e=new Set(y.map(e=>e.url));for(let t of x.current.values())for(let n of t.attachments)e.add(n.url);for(let t of w.current)e.has(t)||URL.revokeObjectURL(t);w.current=e},[y,E]),Q.useEffect(()=>()=>{for(let e of w.current)URL.revokeObjectURL(e)},[]);let[O,k]=Q.useState([]),[A,M]=Q.useState(null),[F,R]=Q.useState({open:!1,title:``,content:``}),z=N(e=>e.setImagePreviewOpen),se=j(e=>{(e.image||e.mermaid||e.video)&&(R(e),z(!0))}),H=j(e=>{R(t=>({...t,open:e})),z(e)});Q.useEffect(()=>()=>{z(!1)},[z]),Q.useEffect(()=>{S.current.clear(),x.current.clear(),D([]),k([]),M(null)},[s]);let U=Q.useMemo(()=>Nt(),[]),W=Q.useRef(new Set),G=Q.useRef(new Map),K=Lt(e=>e.setWorking),q=d.data?.messages??ht,fe=Q.useMemo(()=>q.some(e=>e.parts.some(e=>e.type===`card`&&e.cardType===`schedule`&&en(e))),[q]),pe=I(e.id,n&&fe),me=Q.useMemo(()=>{let e=new Map;for(let t of pe.data?.tasks??[]){if(!t.task)continue;let n=e.get(t.projectID);n||(n=new Map,e.set(t.projectID,n)),n.set(t.taskID,t.task)}return e},[pe.data]),ge=vt(E,e.id),_e=yt(O,e.id),ve=St(q,ge,e.id,_e).filter(e=>{if(e.status===`admitted`&&e.messageID.endsWith(`:preview:admitted`))return!1;let t=Array.isArray(e.parts)?e.parts:[];return t.length===0||t.some(e=>!(e.type===`text`&&qn(e.text)))}),be=ve.length-1;for(;be>=0&&Jn(ve[be]);)--be;let Y=ve.filter((e,t)=>!Jn(e)||t>be),xe=fn(Y),Se=`${s}:${e.id}`,Ce=Q.useRef(null),we=Ce.current?.scope===Se?Ce.current.keys:null,Te=[],Ee=new Set,De=new Map;for(let[e,t]of Y.entries()){let n=Te.at(-1),r=n?.rows.at(-1)?.message,i=Yn(t);if(n&&r&&t.role!==`user`&&t.role===r.role&&t.turnID===r.turnID&&t.fromAssistantID===r.fromAssistantID&&!Jn(t)&&!Jn(r))n.rows.push({message:t,index:e});else{let n=we?.get(i),r=n&&!Ee.has(n)?n:i;Te.push({key:r,rows:[{message:t,index:e}]}),Ee.add(r)}De.set(i,Te.at(-1).key)}for(let e of Te){if(e.rows.some(({message:t})=>we?.get(Yn(t))===e.key))continue;let t=e.rows.map(({message:e})=>we?.get(Yn(e))).find(e=>e&&!Ee.has(e));if(t){Ee.delete(e.key),e.key=t,Ee.add(t);for(let{message:n}of e.rows)De.set(Yn(n),t)}}Q.useLayoutEffect(()=>{Ce.current={scope:Se,keys:De}});let Oe=he(),ke=`${s}:${e.id}`,Ae=Q.useRef(null),je=Ae.current,Me=je?.lastID?Y.findIndex(e=>Yn(e)===je.lastID):-1,Ne=n&&!Oe&&je?.scope===ke&&je.ready&&(je.lastID===null||Me>=0);Q.useLayoutEffect(()=>{let e=Y.at(-1);Ae.current={scope:ke,ready:n&&d.isSuccess,lastID:e?Yn(e):null}});let Pe=new Date().toDateString(),Fe=a(`common.date.today`),Ie=a(`common.date.yesterday`),Le=Q.useMemo(()=>pn(o,Fe,Ie,new Date(Pe)),[o,Fe,Ie,Pe]),Re=Q.useMemo(()=>new Intl.DateTimeFormat(o,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),[o]),ze=Ft(ge),Ve=It(_e),X=!!(e.working||e.activeContactTurn),He=u.data?.revision??null,Ue=_e.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),Ke=new Map(_e.map(e=>[e.turnID,e])),qe=Q.useRef(!1),Z=j(async(e=!1)=>{if(!(!n||qe.current||d.isFetchingPreviousPage||d.isFillingMessageGap)&&!(e&&d.previousPageError)&&!(!d.hasPreviousPage&&!d.hasMessageGap)){qe.current=!0,Qe();try{d.hasMessageGap?await d.retryMessageGap():await d.fetchPreviousPage()}catch{}finally{qe.current=!1}}}),Ye=Q.useRef(null),{scrollRef:Xe,contentRef:Ze,preparePrepend:Qe,followLatest:$e}=Sn({active:n,assistantID:e.id,contentRevision:`${Y[0]?.messageID}:${Y.length}:${Ue}:${d.isFetchingPreviousPage}:${d.hasPreviousPage}:${d.isFillingMessageGap}`,onLoadEarlier:()=>{Z(!0)},overlayComposerRef:i?Ye:void 0}),et=Q.useRef(null),tt=Q.useRef(null),nt=Q.useRef(null),rt=Q.useRef(null),[it,ot]=Q.useState(null),st=()=>{let e=Ye.current?.querySelector(`[data-assistant-contact-composer-surface]`),t=e?.querySelector(`textarea`);return e&&t?Ln(e,t,!c):null};Q.useLayoutEffect(()=>{let e=tt.current;if(!e?.ready||!n)return;tt.current=null;let t=Array.from(et.current?.querySelectorAll(`[data-message-id]`)??[]).find(t=>t.dataset.messageId===e.messageID)?.querySelector(`[data-assistant-contact-text]`),r=()=>ot(t=>t?.messageID===e.messageID?null:t);if(!t){r();return}rt.current?.(),rt.current=Bn(e.source,t,t,r)}),Q.useEffect(()=>()=>{tt.current=null,rt.current?.(),rt.current=null},[n,e.id,s]),Q.useEffect(()=>{M(null),x.current.clear(),S.current.clear(),W.current.clear(),G.current=new Map,D(t=>vt(t,e.id)),k(t=>yt(t,e.id)),R({open:!1,title:``,content:``}),z(!1)},[e.id,z]),Q.useEffect(()=>{for(let e of q){let t=x.current.get(e.messageID);if(t){for(let e of t.attachments)S.current.delete(`${t.assistantID}:${e.id}`);x.current.delete(e.messageID)}}D(e=>Ct(e,q))},[q]),Q.useEffect(()=>{let t=new Set(ge.filter(e=>e.status===`sending`).map(e=>e.messageID));k(n=>Dt(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:X,snapshotRevision:He,admissionRevisionByTurnID:G.current,pendingSendTurnIDs:t,messages:q,settledTurnIDs:W.current}))},[e.activeContactTurn,e.id,q,ge,X,He]),Q.useEffect(()=>{K(e.id,ze||Ve||X)},[e.id,Ve,ze,X,K]),Q.useEffect(()=>{let t=e.id;return()=>{K(t,!1)}},[e.id,K]);let ct=j(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){W.current.delete(t.turnID),k(e=>Tt(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(W.current.has(t.turnID))return;k(e=>Ot(e,t));return}t.type===`contact-turn-end`&&(W.current.add(t.turnID),k(e=>At(kt(e,t,{requireExisting:!0}),q)))}});Q.useEffect(()=>{if(n)return T(ct)},[n,e.id]);let lt=j(async e=>{if(ze)return;let t=C.current,n=await Wn(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&M(a(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>Gn(e,n.attachments))}),ut=j(e=>{let t=Hn(e.clipboardData);t.length!==0&&(e.preventDefault(),lt(t))}),ft=j(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),gt=j(e=>{let t=Un(e.dataTransfer);t.length!==0&&(e.preventDefault(),lt(t))}),_t=j(async(t,r)=>{let i=C.current,o=e.id,s=r?x.current.get(r):void 0;if(r&&(!s||s.assistantID!==o))return;let c=s?.text??t??_,u=s?.attachments??y,d=Pt({gate:U,sending:Ft(ge),text:c,attachments:u,assistantID:o,createMessageID:()=>r||`yuri_contact_${ee()}`});if(!d.ok)return;K(o,!0),x.current.set(d.messageID,{assistantID:o,text:c,attachments:u});let f=u.length===0&&t===void 0&&!r&&n&&!Oe?st():null;rt.current?.(),rt.current=null;let p=f?{messageID:d.messageID,source:f,ready:!1}:null;tt.current=p,ot(f?{scope:ke,messageID:d.messageID,phase:`scrolling`}:null),nt.current=f?d.messageID:nt.current,r||($e(f?{duration:Cn,ease:wn}:void 0,p?e=>{tt.current===p&&(e?p.ready=!0:tt.current=null,ot(t=>t?.messageID===d.messageID?e?{...t,phase:`flying`}:null:t))}:void 0),v(e=>e===c?``:e),b(e=>e.filter(e=>!u.includes(e)))),D(e=>e.some(e=>e.messageID===d.messageID)?e.map(e=>e.messageID===d.messageID?{...d.turn,createdAt:e.createdAt}:e):[...e,d.turn]),M(null);let h=()=>{u.forEach(e=>S.current.delete(`${o}:${e.id}`)),x.current.delete(d.messageID)};try{let t=[];for(let e of u){let n=`${o}:${e.id}`,r=S.current.get(n);if(!r){if(r=await Ge(o,e.file,e.id,i.signal),i.signal.aborted)return;S.current.set(n,r)}t.push(r)}if(i.signal.aborted)return;let n=[...d.parts.filter(e=>e.type===`text`),...t];D(e=>e.map(e=>e.messageID===d.messageID?{...e,parts:n}:e));let r=await te(o,d.messageID,{parts:n});if(i.signal.aborted)return;h(),typeof r.revision==`number`&&G.current.set(d.messageID,r.revision),D(e=>wt(e,d.messageID)),W.current.has(d.messageID)||k(e=>Tt(e,o,d.messageID)),l.data?.serverInstanceID&&le({serverInstanceID:l.data.serverInstanceID,assistantID:o,name:m,avatarSeed:e.avatarSeed??o}).catch(()=>void 0)}catch(e){if(i.signal.aborted)return;if(e instanceof re&&e.code===`admission_timeout`)try{let e=await ie(o,d.messageID);if(i.signal.aborted)return;if(e){h(),typeof e.revision==`number`&&G.current.set(d.messageID,e.revision),D(e=>wt(e,d.messageID)),W.current.has(d.messageID)||k(e=>Tt(e,o,d.messageID));return}}catch{}let t=Mt(e,{noProvider:a(`assistants.contact.noProvider`),sendFailed:a(`assistants.contact.sendFailed`),timedOut:a(`assistants.contact.timedOut`)});D(e=>jt(e,d.messageID,t))}finally{U.release()}}),bt=j(e=>{_t(void 0,e)}),xt=d.isError&&Y.length===0,Et=d.isSuccess&&Y.length===0,Rt=new Map(ge.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{ref:et,className:`yuri-contact-conversation flex min-h-0 flex-1 flex-col bg-transparent`,"data-contact-layout":c?`mobile`:`desktop`,"data-composer-overlay":i||void 0,children:[(0,$.jsxs)(`div`,{ref:Xe,className:V(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 sm:px-8`,c&&`pb-11`,r?`pt-[calc(max(0.625rem,var(--yuri-safe-area-top,0px))+var(--yuri-mobile-detail-navigation-height)+1.25rem)]`:`pt-5 sm:pt-7`),style:{overflowAnchor:`none`,overscrollBehavior:`contain`,overscrollBehaviorY:`contain`},"data-assistant-contact-transcript":``,children:[t?(0,$.jsx)(`p`,{className:`mb-3 typography-micro text-[var(--status-warning)]`,children:t}):null,xt?(0,$.jsxs)(`div`,{ref:Ze,className:`mx-auto flex h-full min-h-56 max-w-xs flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-error":``,children:[(0,$.jsxs)(`div`,{className:`relative`,children:[(0,$.jsx)(Bt,{name:e.id,avatarSeed:e.avatarSeed,size:44,label:m,working:n?X:void 0,showWorkingDot:!1,followPointer:!1}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`absolute -right-1 -bottom-1 flex size-5 items-center justify-center rounded-full bg-[var(--surface-elevated)] text-[var(--status-error)] ring-2 ring-background`,children:(0,$.jsx)(J,{name:`error-warning`,className:`size-3`})})]}),(0,$.jsx)(`p`,{className:`mt-4 typography-ui-label font-medium text-foreground`,children:m}),(0,$.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:a(`assistants.contact.loadFailed`)}),(0,$.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void d.refetch(),children:a(`chat.history.retry`)})]}):Et?(0,$.jsxs)(`div`,{ref:Ze,className:`mx-auto flex h-full min-h-56 max-w-sm flex-col items-center justify-center pb-16 text-center`,"data-assistant-contact-empty":``,children:[(0,$.jsx)(Bt,{name:e.id,avatarSeed:e.avatarSeed,size:48,label:m,className:`opacity-90`,working:n?X:void 0,showWorkingDot:!1,followPointer:!1}),(0,$.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:a(`assistants.conversation.emptyTitle`,{name:m})}),(0,$.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:a(`assistants.contact.empty`)})]}):(0,$.jsxs)(`div`,{ref:Ze,className:`relative mx-auto flex w-full flex-col pb-12`,"data-assistant-contact-content":``,children:[d.isPending?(0,$.jsx)(`p`,{role:`status`,className:`py-3 text-center typography-micro text-muted-foreground`,children:a(`common.loading`)}):null,d.hasPreviousPage||d.hasMessageGap?(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col items-center gap-1`,"data-assistant-contact-pagination":``,"aria-busy":d.isFetchingPreviousPage||d.isFillingMessageGap,children:[d.previousPageError?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:a(`chat.history.loadOlderFailed`)}):null,d.hasMessageGap?(0,$.jsx)(`p`,{role:`status`,className:`typography-micro text-muted-foreground`,children:a(`assistants.contact.history.gap`)}):null,(0,$.jsx)(B,{type:`button`,size:`sm`,variant:`ghost`,disabled:d.isFetchingPreviousPage||d.isFillingMessageGap,onClick:()=>void Z(),children:a(d.isFetchingPreviousPage||d.isFillingMessageGap?`chat.history.loadingMore`:d.previousPageError||d.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,Te.map(t=>{let r=t.rows[0].message,i=r.role!==`user`&&!Jn(r),o=r.role===`peer`&&r.fromAssistantID?u.data?.assistants.find(e=>e.id===r.fromAssistantID):e,l=r.role===`peer`?g(r.fromAssistantID,r.fromAssistantName):m;return(0,$.jsxs)(`div`,{className:V(`relative flex w-full`,!xe.has(r.messageID)&&(i?`mt-4 first:mt-0`:`mt-6 first:mt-0`)),"data-assistant-contact-group":``,children:[i?(0,$.jsx)(`div`,{className:V(`sticky bottom-2 flex shrink-0 self-end justify-center pb-0.5`,c?`mr-2.5 w-9`:`mr-2 w-6`),"data-assistant-contact-avatar-rail":``,children:(0,$.jsx)(Bt,{name:o?.id||r.fromAssistantID||e.id,avatarSeed:o?.avatarSeed??(r.fromAssistantID?void 0:e.avatarSeed),size:c?32:24,label:l,working:n?!!(o?.working||o?.activeContactTurn):void 0,showWorkingDot:!1,followPointer:!1})}):null,(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:t.rows.map(({message:t,index:r})=>{let i=`${ke}:${Yn(t)}`,o=r>0?Y[r-1]:null,l=Y[r+1],d=xe.get(t.messageID),f=d!==void 0,_=f?(0,$.jsx)(`div`,{className:`flex w-full justify-center px-4 py-4`,"data-assistant-contact-time":``,children:(0,$.jsx)(`time`,{dateTime:new Date(d).toISOString(),className:`text-[11px] font-normal leading-4 tabular-nums text-muted-foreground/70`,children:Le(d)})}):null,v=t.role===`user`,y=t.role===`peer`,b=e=>e&&!Jn(e)&&e.role===t.role&&e.turnID===t.turnID&&e.fromAssistantID===t.fromAssistantID,x=!!(!f&&b(o)),S=!!(l&&!xe.has(l.messageID)&&b(l)),C=t.role===`assistant`&&!f&&o?.role===`assistant`&&o.turnID===t.turnID,w=y?g(t.fromAssistantID,t.fromAssistantName):m,T=Rt.get(t.messageID),E=Ke.get(t.turnID),D=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`),O=(e,t)=>v?(0,$.jsx)(pt,{failedTurn:n?T:void 0,retryDisabled:ze,onRetry:bt,children:e},t):e;return t.status===`error`||D?(0,$.jsxs)(Q.Fragment,{children:[_,(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:V(`relative px-1`,!f&&`mt-3`),children:[(0,$.jsx)(`p`,{role:`alert`,className:`whitespace-pre-wrap text-center text-[11px] font-normal leading-4 text-muted-foreground [overflow-wrap:anywhere]`,children:t.text||E?.error||a(`assistants.contact.sendFailed`)}),p?.messageID===t.messageID?(0,$.jsx)(Je,{assistantID:e.id,position:p},`${s}:${e.id}:${p.generation}:${p.ordinal}`):null]})]},i):(0,$.jsxs)(Q.Fragment,{children:[_,(0,$.jsx)(We.div,{"data-message-id":t.messageID,initial:Ne&&r>Me&&t.messageID!==nt.current?{opacity:0,y:4}:!1,animate:{opacity:1,y:0},transition:{duration:Oe?0:.18,ease:`easeOut`},className:V(`flex w-full`,v?`justify-end`:`justify-start`,f?`mt-0`:x?`mt-2`:`mt-4 first:mt-0`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":T?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!C?``:void 0,children:(0,$.jsxs)(`div`,{className:V(`relative flex min-w-0 flex-col gap-2`,v?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[y?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:a(`assistants.contact.peer.from`,{name:w})}):null,t.parts.map((r,o)=>{if(r.type===`card`&&r.cardType===`session`)return(0,$.jsx)(un,{card:r},`${i}:card:${o}`);if(r.type===`card`&&r.cardType===`assistant`)return(0,$.jsx)(Xt,{card:r,assistant:u.data?.assistants.find(e=>e.id===r.assistantID),active:n},`${i}:card:${o}`);if(r.type===`card`&&r.cardType===`schedule`)return(0,$.jsx)(an,{card:r,task:me.get(r.projectID)?.get(r.taskID)},`${i}:card:${o}`);if(r.type===`file`)return O((0,$.jsx)(dt,{assistantID:e.id,part:r,onShowPopup:se},`${i}:file:${o}`),`${i}:file:${o}`);if(r.type===`text`&&qn(r.text))return null;if(r.type===`text`&&(r.text.trim()||t.status===`streaming`)){let e=!v,s=e&&/^!\[(?:\\.|[^\]\\\n])*\]\(\s*(?:<[^>\n]+>|[^\s()]+)(?:\s+"[^"\n]*")?\s*\)$/.test(r.text.trim());return O((0,$.jsx)(mt,{label:y?a(`assistants.contact.peer.aria`,{name:w}):void 0,outgoing:v,joinedBefore:x,joinedAfter:S,createdAt:t.createdAt,time:Re.format(t.createdAt),mobile:c,media:s,colors:v?h:void 0,hidden:n&&it?.scope===ke&&it.messageID===t.messageID,children:e?(0,$.jsx)(ye,{content:r.text,messageId:i,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:se,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):r.text},`${i}:text:${o}`),`${i}:text:${o}`)}return null}),p?.messageID===t.messageID?(0,$.jsx)(Je,{assistantID:e.id,position:p},`${s}:${e.id}:${p.generation}:${p.ordinal}`):null]})})]},i)})})]},`${ke}:${t.key}`)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 left-[var(--contact-avatar-gutter)] flex h-10 items-center`,"data-assistant-contact-status-slot":``,children:!ze&&it?.scope!==ke&&(Ve||X)?(0,$.jsxs)(We.div,{role:`status`,"aria-label":a(`assistants.contact.processing`),initial:!Oe&&{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:Oe?0:.18,ease:`easeOut`},className:`relative inline-flex h-9 origin-bottom-left items-center gap-1 rounded-[1.35rem] bg-[var(--surface-muted)] px-4 text-muted-foreground/70`,"data-assistant-contact-processing":``,children:[(0,$.jsx)(`div`,{className:V(`absolute -left-[var(--contact-avatar-gutter)] top-0.5 flex justify-center`,c?`w-9`:`w-6`),"data-assistant-contact-processing-avatar":``,children:(0,$.jsx)(Bt,{name:e.id,avatarSeed:e.avatarSeed,size:c?32:24,label:m,working:n?X:void 0,showWorkingDot:!1,followPointer:!1})}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.45s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-delay:-0.22s] [animation-duration:1.4s] motion-reduce:animate-none`}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`size-1.5 animate-pulse rounded-full bg-current [animation-duration:1.4s] motion-reduce:animate-none`})]}):null})]})]}),(0,$.jsxs)(`footer`,{ref:Ye,className:`relative z-10 shrink-0 bg-transparent pt-1`,"data-assistant-contact-composer":``,children:[A?(0,$.jsx)(`div`,{className:`chat-input-column mb-2`,children:(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:A})}):null,(0,$.jsx)(`form`,{className:V(`relative w-full pt-1.5 pb-4`,c&&`bottom-safe-area yuri-mobile-composer`),onSubmit:e=>{e.preventDefault(),_t()},onDragOver:ft,onDrop:gt,children:(0,$.jsx)(`div`,{className:`relative overflow-visible`,"data-contact-composer-column":``,children:(0,$.jsx)(at,{active:n,layout:`inline`,value:_,attachments:y,pending:ze,isMobile:c,placeholder:a(`assistants.contact.placeholder`,{name:m}),sendLabel:a(`assistants.contact.send`),addFilesLabel:a(`assistants.contact.addFiles`),removeAttachmentLabel:a(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>v(e),onVoiceSend:e=>{_t(e)},onSubmit:()=>{_t()},onAddFiles:e=>{lt(e)},onRemoveAttachment:t=>{ze||(S.current.delete(`${e.id}:${t}`),b(e=>e.filter(e=>e.id!==t)))},onPaste:ut,onDragOver:ft,onDrop:gt,className:V(`relative z-10`,c&&`yuri-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":a(`assistants.contact.placeholder`,{name:m})}},`${s}:${e.id}`)})})]}),F.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Kn,{popup:F,onOpenChange:H,isMobile:c})}):null]})};export{zt as a,Bt as i,mn as n,Ht as r,Xn as t};
@@ -1 +0,0 @@
1
- .yuri-contact-conversation{--contact-column-width:42rem;--contact-body-size:var(--text-markdown);--contact-body-leading:1.65;--contact-avatar-gutter:2.875rem;--contact-bubble-radius:1.125rem;--contact-bubble-join-radius:.375rem;--contact-time-size:.6875rem}.yuri-contact-conversation[data-contact-layout=desktop]{--contact-column-width:45.5rem;--contact-body-size:var(--text-ui-label);--contact-avatar-gutter:2.125rem;--contact-bubble-radius:1rem;--contact-time-size:.625rem}.yuri-contact-conversation [data-assistant-contact-content]{max-width:var(--contact-column-width)}.yuri-contact-conversation [data-contact-composer-column]{width:100%;max-width:var(--contact-column-width);margin-inline:auto}.yuri-contact-conversation[data-composer-overlay]{position:relative}.yuri-contact-conversation[data-composer-overlay] [data-assistant-contact-transcript]{padding-bottom:var(--contact-composer-height,0px);scroll-padding-bottom:var(--contact-composer-height,0px)}.yuri-contact-conversation[data-composer-overlay] [data-assistant-contact-composer]{pointer-events:none;position:absolute;inset:auto 0 0}.yuri-contact-conversation[data-composer-overlay] [data-contact-composer-column]{pointer-events:auto}.yuri-contact-conversation[data-composer-overlay] [data-assistant-contact-avatar-rail]{bottom:calc(var(--contact-composer-height,0px) + .5rem)}.yuri-contact-conversation[data-composer-overlay][data-contact-layout=mobile] [data-assistant-contact-avatar-rail]{bottom:.5rem}.yuri-contact-conversation[data-contact-layout=desktop] [data-assistant-contact-composer]{padding-left:calc(2rem * var(--padding-scale,1));padding-right:calc(2rem + var(--contact-scrollbar-width,0px))}.yuri-contact-conversation[data-contact-layout=mobile] [data-assistant-contact-composer]{padding-left:calc(1rem * var(--padding-scale,1));padding-right:calc(1rem + var(--contact-scrollbar-width,0px))}.yuri-contact-conversation[data-contact-layout=desktop] :is([data-composer-layout=inline],[data-composer-input-shell]){min-height:calc(2.5rem * var(--padding-scale,1))}.yuri-contact-conversation[data-contact-layout=desktop] :is([data-composer-inline-attach],[data-composer-inline-send]){height:calc(2.5rem * var(--padding-scale,1))}.yuri-contact-conversation[data-contact-layout=desktop] [data-assistant-contact-composer-surface] :is(textarea,[data-composer-highlight]){min-height:calc(2.5rem * var(--padding-scale,1));padding-block:calc(.625rem * var(--padding-scale,1));font-size:var(--contact-body-size);line-height:calc(20 * var(--dpt))}.yuri-contact-conversation[data-contact-layout=desktop] [data-composer-send]{width:calc(1.75rem * var(--padding-scale,1));height:calc(1.75rem * var(--padding-scale,1))}.yuri-contact-conversation [data-composer-animated-resize] [data-composer-content]{align-items:flex-end}.yuri-contact-bubble{isolation:isolate;padding:calc(.3125rem * var(--padding-scale,1)) calc(.625rem * var(--padding-scale,1)) calc(.375rem * var(--padding-scale,1));border-radius:var(--contact-bubble-radius,1.125rem);--contact-bubble-fill:var(--surface-muted);--markdown-body-line-height:var(--contact-body-leading,1.65);--markdown-list-line-height:1.5;--markdown-paragraph-spacing:.5em;color:var(--surface-foreground);font-size:var(--contact-body-size,var(--text-markdown));line-height:var(--contact-body-leading,1.65);position:relative}.yuri-contact-bubble[data-contact-bubble-direction=outgoing][data-contact-bubble-joined-before]{border-top-right-radius:var(--contact-bubble-join-radius,.375rem)}.yuri-contact-bubble[data-contact-bubble-direction=incoming][data-contact-bubble-joined-before]{border-top-left-radius:var(--contact-bubble-join-radius,.375rem)}.yuri-contact-bubble[data-contact-bubble-direction=outgoing]{border-bottom-right-radius:var(--contact-bubble-join-radius,.375rem)}.yuri-contact-bubble[data-contact-bubble-direction=incoming]{border-bottom-left-radius:var(--contact-bubble-join-radius,.375rem)}.yuri-contact-bubble-outline{z-index:-1;width:calc(100% + 16px);height:100%;fill:var(--contact-bubble-fill);pointer-events:none;position:absolute;top:0;left:-8px;overflow:visible}.yuri-contact-bubble-body{white-space:pre-wrap;display:contents}@media (width<=639px){.yuri-contact-conversation[data-contact-layout=desktop] [data-assistant-contact-composer]{padding-left:calc(1rem * var(--padding-scale,1));padding-right:calc(1rem + var(--contact-scrollbar-width,0px))}}.yuri-contact-bubble-time-space,.yuri-contact-bubble-time{font-size:var(--contact-time-size,.6875rem);line-height:calc(16 * var(--dpt));font-variant-numeric:tabular-nums;white-space:nowrap;-webkit-user-select:none;user-select:none}.yuri-contact-bubble-time-space{margin-left:calc(.5rem * var(--padding-scale,1));visibility:hidden;display:inline-block}.yuri-contact-bubble-time{opacity:.55;position:absolute;bottom:.1875rem;right:.625rem}.yuri-contact-bubble .markdown-content,.yuri-contact-bubble .markdown-renderer,.yuri-contact-bubble .markdown-renderer>.node-slot,.yuri-contact-bubble .node-slot>.node-content{font-size:inherit;line-height:inherit;white-space:normal;display:contents}.yuri-contact-bubble .markdown-content>p:last-child,.yuri-contact-bubble .markdown-renderer>.node-slot:last-of-type[data-node-type=paragraph]>.node-content>p{font-size:inherit;line-height:inherit;margin-bottom:0;display:inline}@layer base{.yuri-contact-conversation .yuri-contact-bubble .markdown-content :is(ul,ol){margin-block:.35em!important}.yuri-contact-conversation .yuri-contact-bubble .markdown-content>[data-md-block]:last-child :is(ul,ol):last-child,.yuri-contact-conversation .yuri-contact-bubble .markdown-renderer>.node-slot:last-of-type :is(ul,ol):last-child{margin-bottom:0!important}}.yuri-contact-conversation .yuri-contact-bubble .markdown-content li{line-height:var(--markdown-list-line-height);margin-block:.15em}.yuri-contact-conversation .yuri-contact-bubble .markdown-content li>:is(p,.paragraph-node){line-height:inherit;margin-block:0}.yuri-contact-bubble[data-assistant-contact-media]{background:0 0;padding:0}
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-BMjl5Y5W.js";import{n as r}from"./runtime-fetch-DKZOpfzo.js";import{ot as i,st as a}from"./vendor-base-ui-z2M4boRm.js";import{n as o}from"./vendor-react-P8wFrkcT.js";import{s}from"./vendor-tanstack-react-query-B-KblYBV.js";import{L as c,q as l}from"./runtime-file-resource-CuLP3xp7.js";import{i as u}from"./store-DunGyOfe.js";import{$a as d,In as f,Rn as p}from"./useMobileNavigationStore-BNtVrnSw.js";import{n as m}from"./Icon-DizeYahT.js";var h=e(a(),1),g=o(),_=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},v=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},y=class extends _{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},b=(e,t=200)=>{throw new _(`invalid_${e}_response`,t,e)},x=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:b(t),S=(e,t)=>typeof e==`string`?e:b(t),C=(e,t)=>e===null||typeof e==`string`?e:b(t),w=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:b(t),T=(e,t)=>e===null?null:w(e,t),E=(e,t)=>typeof e==`boolean`?e:b(t),D=(e,t,n)=>t.includes(e)?e:b(n),O=e=>{let t=x(e,`capability`);return{supported:E(t.supported,`capability`),enabled:E(t.enabled,`capability`),revision:w(t.revision,`capability`),serverInstanceID:C(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&E(t.sharingAvailable,`capability`)}},k=e=>{if(e==null)return null;let t=x(e,`assistant`);return{turnID:S(t.turnID,`assistant`),messageID:S(t.messageID,`assistant`),status:D(t.status,[`queued`,`running`],`assistant`),admittedAt:w(t.admittedAt,`assistant`)}},A=e=>{if(e==null)return null;let t=x(e,`assistant_preview`),n=w(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?b(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:w(t.createdAt,`assistant_preview`)},messageID:S(t.messageID,`assistant_preview`),ordinal:n,role:D(t.role,[`user`,`assistant`],`assistant_preview`),text:S(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:D(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},j=e=>{let t=w(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:b(`assistant_read`)},M=e=>{let t=x(e,`assistant_read`);return{generation:j(t.generation),ordinal:j(t.ordinal),messageID:S(t.messageID,`assistant_read`)}},N=e=>({unreadCount:e.unreadCount===void 0?0:j(e.unreadCount),readWatermark:e.readWatermark==null?null:M(e.readWatermark),readTip:e.readTip==null?null:M(e.readTip)}),P=e=>{let t=x(e,`assistant_read`);return{assistantID:S(t.assistantID,`assistant_read`),changed:E(t.changed,`assistant_read`),unreadCount:j(t.unreadCount),readWatermark:M(t.readWatermark),readTip:M(t.readTip),revision:j(t.revision)}},F=e=>{let t=x(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>S(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:w(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return b(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>S(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:k(t.activeContactTurn),o=t.working===void 0?a!=null:E(t.working,`assistant`);return{...N(t),pinnedAt:t.pinnedAt===void 0?void 0:T(t.pinnedAt,`assistant`),latestMessagePreview:A(t.latestMessagePreview),id:S(t.id,`assistant`),avatarSeed:S(t.avatarSeed??t.id,`assistant`),revision:w(t.revision,`assistant`),enabled:E(t.enabled,`assistant`),name:S(t.name,`assistant`),defaultPrompt:S(t.defaultPrompt,`assistant`),workspacePath:C(t.workspacePath,`assistant`),effectiveWorkspacePath:S(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:C(t.managedWorkspacePath??null,`assistant`),providerID:S(t.providerID,`assistant`),modelID:S(t.modelID,`assistant`),agent:C(t.agent,`assistant`),variant:C(t.variant??null,`assistant`),mode:D(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:C(t.sessionID,`assistant`),sessionGeneration:w(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:T(t.createdAt,`assistant`),updatedAt:w(t.updatedAt,`assistant`),tombstoneAt:T(t.tombstoneAt,`assistant`)}},I=e=>{let t=x(e,`snapshot`);return{revision:w(t.revision,`snapshot`),enabled:E(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(F):b(`snapshot`)}},L=e=>{let t=x(e,`binding`);return{sessionID:C(t.sessionID,`binding`),directory:S(t.directory,`binding`),sessionGeneration:w(t.sessionGeneration,`binding`)}},R=e=>{let t=x(e,`message_admission`);if(t.admitted!==!0)return b(`message_admission`);let n=t.revision===void 0||t.revision===null?null:w(t.revision,`message_admission`);return{binding:L(t.binding),messageID:S(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},z=e=>{let t=x(e,`share_operation`);return{operationID:S(t.operationID,`share_operation`),assistantID:S(t.assistantID,`share_operation`),sessionID:C(t.sessionID,`share_operation`),messageID:C(t.messageID,`share_operation`),state:D(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:S(t.phase,`share_operation`),attempt:w(t.attempt,`share_operation`),leaseExpiresAt:T(t.leaseExpiresAt,`share_operation`),errorCode:C(t.errorCode,`share_operation`)}},B=e=>{let t=x(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:S(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:S(t.filename,`assistant_contact_part`),n=S(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return b(`assistant_contact_part`);if(i){let r=w(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?b(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:S(t.attachmentID,`assistant_contact_part`),sha256:S(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:S(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:b(`assistant_contact_part`)}if(t.type===`card`){let e=D(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);return e===`session`?{type:`card`,cardType:`session`,sessionID:S(t.sessionID,`assistant_contact_part`),directory:S(t.directory,`assistant_contact_part`),title:C(t.title??null,`assistant_contact_part`),status:C(t.status??null,`assistant_contact_part`),branch:C(t.branch??null,`assistant_contact_part`)}:e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:S(t.assistantID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),providerID:S(t.providerID,`assistant_contact_part`),modelID:S(t.modelID,`assistant_contact_part`),mode:D(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:S(t.taskID,`assistant_contact_part`),projectID:S(t.projectID,`assistant_contact_part`),name:S(t.name,`assistant_contact_part`),kind:C(t.kind??null,`assistant_contact_part`),time:C(t.time??null,`assistant_contact_part`),timezone:C(t.timezone??null,`assistant_contact_part`),prompt:C(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:C(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:C(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>S(e,`assistant_contact_part`)):b(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=w(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:b(`assistant_contact_part`)}):b(`assistant_contact_part`)}}}return b(`assistant_contact_part`)},V=e=>{let t=x(e,`assistant_contact`),n=C(t.nextCursor,`assistant_contact`),r=E(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return b(`assistant_contact`);let i=w(t.generation,`assistant_contact`),a=w(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?b(`assistant_contact`):{messages:t.messages.map(e=>{let t=x(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return b(`assistant_contact_message`);let n=t.parts.map(B);return{messageID:S(t.messageID,`assistant_contact_message`),assistantID:S(t.assistantID,`assistant_contact_message`),role:D(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:S(t.turnID,`assistant_contact_message`),bubbleIndex:w(t.bubbleIndex,`assistant_contact_message`),createdAt:w(t.createdAt,`assistant_contact_message`),ordinal:w(t.ordinal,`assistant_contact_message`),status:S(t.status,`assistant_contact_message`),fromAssistantID:C(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:C(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},ee=e=>{let t=x(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=x(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:x(t.task,`assistant_scheduled_task_live`);return{assistantID:S(t.assistantID,`assistant_scheduled_task`),projectID:S(t.projectID,`assistant_scheduled_task`),taskID:S(t.taskID,`assistant_scheduled_task`),createdAt:w(t.createdAt,`assistant_scheduled_task`),projectPath:C(t.projectPath??null,`assistant_scheduled_task`),projectLabel:C(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:b(`assistant_scheduled_tasks`)},H=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},U=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},te=e=>e===null||typeof e==`string`,ne=e=>e===null||typeof e==`number`&&Number.isFinite(e),re=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ie=e=>e===null||re(e),ae=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&te(t.sessionId)&&te(t.directory)&&te(t.error)&&re(t.startedAt)&&ie(t.finishedAt)&&ne(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},oe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(ae)||!te(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},se=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await H(a,`Failed to load scheduled task history`));return oe(await a.json().catch(()=>null))},ce=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await H(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},le=async(e,t)=>{let n=U(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await H(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ue=async(e,t)=>{let n=U(e),i=U(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await H(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},de=async(e,t)=>{let n=U(e),i=U(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await H(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},fe=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,pe=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},me=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(pe)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&fe({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},he=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),ge=e=>!!(e&&e.generation>=0),_e=(e,t)=>fe({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),W=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(_e)},ve=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},ye=e=>e.map(e=>e.messageID),be=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},xe=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),we=e=>({ordinal:e.ordinal,messageID:e.messageID}),Te=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>fe(we(e),we(r))<0),...t]},Ee=(e,t)=>{let n=e??he(),r=ge(n),i=[...t.messages].sort(_e),a=ye(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=Te(n.messages,i,t.complete);else{let e=ve(i);c=W(n.messages.filter(t=>t.ordinal<e),W(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=xe(a),d=l.length>0&&be(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},De=(e,t)=>{if(!ge(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=W(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},Oe=(e,t,n)=>{if(!ge(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=W(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=ye(t.messages),c=e.gapTargetIDs??[],l=xe(c);return c.length>0&&be(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},G={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},K=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new _(e,n.status,void 0,t)}return i},q=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),J=(e,r)=>{if(t()!==e||n()!==r)throw new _(`runtime_stale`,409)},ke=(e,t,r)=>{l.setQueryData(G.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),l.invalidateQueries({queryKey:G.snapshot(r)}),l.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},Ae=(e,t)=>{l.setQueryData(G.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),l.invalidateQueries({queryKey:G.snapshot(t)})},je=2500,Me=15e3,Ne=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Pe=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?je:Me}return Ne(e)?je:Me},Y=(e=t())=>({queryKey:G.snapshot(e),queryFn:async({signal:e})=>I(await K(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Pe(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),X=new Map,Fe=e=>{let r=X.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,s=()=>!i&&t()===e&&n()===r,u=async()=>{if(o=!0,!a){a=!0;try{do o=!1,l.getQueryCache().find({queryKey:G.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await l.invalidateQueries({queryKey:G.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&s())}finally{a=!1}}},d=c(t=>{if(!s())return;let n=l.getQueryData(G.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&u()});X.set(e,{count:1,dispose:()=>{i=!0,d()}})}return()=>{let t=X.get(e);t&&--t.count===0&&(t.dispose(),X.delete(e))}},Ie=e=>{let n=(0,g.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=s,r=Y(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let o;n[3]===e?o=n[4]:(o={...r,select:e},n[3]=e,n[4]=o);let c=i(o),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>Fe(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),h.useEffect(l,u),c},Le=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Re=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??0},ze=e=>e.enabled&&Ne(e),Be=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Y(i),select:ze},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>Fe(i),c=[i],e[3]=o,e[4]=c):(o=e[3],c=e[4]),h.useEffect(o,c),a.data??!1},Ve=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},He=async(e,t,n)=>V(await K(Ve(e,t),n?{signal:n}:{})),Ue=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,Z=new Map,We=new Map,Q=e=>e.join(``),Ge=async(e,t,n,r,i)=>{let a=Q(t),o=We.get(a);if(o)return o;let s=(async()=>{let a=l.getQueryData(t)??n,o=0,s=!1,c=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){J(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await He(e,{limit:20,before:n},i);J(r.transport,r.runtimeGeneration);let c=l.getQueryData(t)??a;if(o.generation!==c.generation){a=c;break}let f=!u||!!(c.hasMessageGap&&c.gapRequestIDs&&c.gapRequestIDs.length===u.length&&c.gapRequestIDs.every((e,t)=>e===u[t]));if(a=Oe(c,o,u?{requestIDs:u,cursor:d}:void 0),l.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||v(e))break;c=!0,a=l.getQueryData(t)??a;break}}return{view:l.getQueryData(t)??a,failed:c,progressed:s}})();We.set(a,s);try{return await s}finally{We.get(a)===s&&We.delete(a)}},Ke=(e,r=t(),i=n(),a={})=>({queryKey:G.contact(e,r,i),queryFn:async({signal:t})=>{J(r,i),await d(),J(r,i);let n=G.contact(e,r,i),a=l.getQueryData(n),o=await He(e,{limit:20},t);J(r,i);let s=Ee(l.getQueryData(n)??a??null,o);l.setQueryData(n,s);let c=Q(n);if(s.hasMessageGap&&s.gapCursor){Z.delete(c);let a=await Ge(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&Z.set(c,a.view.gapCursor)}else Z.delete(c);J(r,i);let u=l.getQueryData(n)??s;return a&&Ue(a,u)?a:u},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Pe(l.getQueryData(G.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),qe=(e,r=!0)=>{let i=t(),a=n(),[o,u]=h.useState(!1),[d,f]=h.useState(null),[p,m]=h.useState(!1),g=h.useRef(null),_=h.useRef(null),y=h.useRef(null),b=h.useRef(null),x=h.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=s({...Ke(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});h.useEffect(()=>{!r||!e||l.invalidateQueries({queryKey:G.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),h.useEffect(()=>c(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||l.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}))}),[e,a,i]),h.useEffect(()=>{let t=Q(G.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,g.current=null,_.current=null,Z.delete(t)}},[e,i,a,r]);let C=S.data,w=G.contact(e,i,a),T=async()=>{if(!e||!r)return;if(g.current)return g.current;let t=l.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;f(null),u(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{J(o.transport,o.runtimeGeneration);let e=await He(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(J(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=l.getQueryData(w)??t;if(e.generation!==r.generation)return;l.setQueryData(w,De(r,e))}catch(e){if(n.signal.aborted||v(e))return;let t=e instanceof Error?e:Error(String(e));throw f(t),t}finally{b.current===n&&(b.current=null),u(!1),g.current=null}})();return g.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(_.current)return _.current;let n=l.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&Z.get(o)===n.gapCursor)return;t===`explicit`&&Z.delete(o),m(!0);let s=new AbortController;y.current?.abort(),y.current=s;let c={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{J(c.transport,c.runtimeGeneration);let e=await Ge(c.assistantID,w,n,{transport:c.transport,runtimeGeneration:c.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(J(c.transport,c.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&Z.set(o,e.view.gapCursor);return}e.view.hasMessageGap||Z.delete(o)}catch(e){if(s.signal.aborted||v(e))return;throw Z.set(o,c.cursor),e}finally{y.current===s&&(y.current=null),m(!1),_.current=null}})();return _.current=u,u};return h.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||p)return;let t=Q(w);Z.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,p,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:o,previousPageError:d,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:p,retryMessageGap:()=>E(`explicit`)}},Je=async(e,r)=>{let i=t(),a=n();await d(),J(i,a);let o=await He(e,{messageID:r,limit:1});if(J(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;l.invalidateQueries({queryKey:G.contact(e,i,a),exact:!0}),l.invalidateQueries({queryKey:G.snapshot(i),exact:!0});let s=l.getQueryData(G.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ye=(e,r=t(),i=n())=>({queryKey:G.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{J(r,i);let n=ee(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return J(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof _&&t.status===404)&&e<2}),Xe=(e,r)=>{let i=(0,g.c)(6),a=r===void 0||r,o,c;if(i[0]!==e){let r=t(),a=n();c=s,o=Ye(e,r,a),i[0]=e,i[1]=o,i[2]=c}else o=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==o||i[4]!==l?(u={...o,enabled:l},i[3]=o,i[4]=l,i[5]=u):u=i[5],c(u)},Ze=(e=t())=>({queryKey:G.globalScheduledTasks(e),queryFn:ce,refetchOnMount:`always`}),Qe=e=>{let t=(0,g.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Ze(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),s(i)},$e=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),et=()=>{let e=(0,g.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=s,r={...Ze(i),select:$e,staleTime:0,refetchInterval:yt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),o,u;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(o=()=>c(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&l.invalidateQueries({queryKey:Ze(i).queryKey,exact:!0})}),u=[i],e[3]=o,e[4]=u):(o=e[3],u=e[4]),h.useEffect(o,u),a.data===!0},tt=(e,r=t())=>{l.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},nt=(e=t())=>({queryKey:G.capability(e),queryFn:()=>gt(),retry:!1}),rt=()=>{let e=(0,g.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=nt(),e[0]=t):t=e[0],s(t)},it=(e=l,n=t())=>e.getQueryData(G.snapshot(n)),at=(e=l,n=t())=>e.fetchQuery(Y(n)),ot=async(e=l)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:G.snapshot(r),exact:!0}),J(r,i);let a=await e.fetchQuery(Y(r));return J(r,i),a},st=15e3,ct=e=>{throw e instanceof _?e:v(e)?new _(`admission_timeout`,408):e},lt=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(st);try{let t=R(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...q(`POST`,{messageID:r,parts:s,language:u.getState().locale}),signal:c}));return J(a,o),ke(e,t.binding,a),tt(e,a),t}catch(e){return ct(e)}},ut=async(e,r,i,a,o)=>{let s=t(),c=n(),l=z(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,q(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return J(s,c),l},dt=async(e,r=t(),i=n())=>{J(r,i);let a=z(await K(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return J(r,i),a},ft=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)J(r,i),await new Promise(e=>setTimeout(e,750)),a=await dt(a.operationID,r,i);if(J(r,i),a.state===`completed`)return a;throw a.state===`failed`?new y(a.errorCode??`share_failed`,400,a):new y(`share_unresolved`,408,a)},pt=async e=>{let n=t(),r=F(await K(`/api/yuri/assistants`,q(`POST`,{...e,language:u.getState().locale})));return Ae(r,n),r},mt=async(e,r)=>{let i=t(),a=n(),o=F(await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`PATCH`,{...r,expectedRevision:e.revision})));return J(i,a),r.pinned===void 0?Ae(o,i):(await l.cancelQueries({queryKey:G.snapshot(i),exact:!0}),J(i,a),await l.fetchQuery(Y(i)),J(i,a)),o},ht=async e=>{await K(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,q(`DELETE`,{expectedRevision:e.revision})),await l.invalidateQueries({queryKey:G.snapshot(t())})},gt=async()=>O(await K(`/api/yuri/assistants/capability`)),_t=async(e,r)=>{let i=t(),a=n(),o=M(r);try{let t=P(await K(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...q(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(J(i,a),t.assistantID!==e)throw new _(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&l.invalidateQueries({queryKey:G.snapshot(i),exact:!0})}},vt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(J(i,a),_t(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function yt(e){return e.state.data&&$e(e.state.data)?2500:15e3}var $=i();function bt(e){let t=(0,g.c)(34),{title:n,className:r,subtitle:i,backAriaLabel:a,onBack:o,backDisabled:s,actions:c,trailing:l,sticky:u,overlay:d,elevated:h,collapsible:_}=e,v=s!==void 0&&s,y;t[0]===c?y=t[1]:(y=c===void 0?[]:c,t[0]=c,t[1]=y);let b=y,x=u!==void 0&&u,S=d!==void 0&&d,C=h!==void 0&&h,w=_!==void 0&&_,T=Array.isArray(l)?l.filter(Boolean).length:+!!l,E=C||b.some(St),D=w?`true`:void 0,O=x&&`yuri-mobile-detail-navigation-sticky`,k=S&&`absolute inset-x-0 top-0`,A=E?`z-[60]`:S?`z-30`:void 0,j;t[2]!==r||t[3]!==k||t[4]!==A||t[5]!==O?(j=p(`yuri-mobile-detail-navigation relative shrink-0 pt-[max(0.25rem,var(--yuri-safe-area-top,0px))]`,O,k,A,r),t[2]=r,t[3]=k,t[4]=A,t[5]=O,t[6]=j):j=t[6];let M=b.length+T>1?`grid-cols-[2.75rem_minmax(0,1fr)_auto]`:`grid-cols-[2.75rem_minmax(0,1fr)_2.75rem]`,N;t[7]===M?N=t[8]:(N=p(`yuri-mobile-detail-navigation-content grid items-center gap-1 px-4`,M),t[7]=M,t[8]=N);let P;t[9]!==a||t[10]!==v||t[11]!==o?(P=o?(0,$.jsx)(f,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:`justify-self-start`,onClick:o,disabled:v,"aria-label":a,children:(0,$.jsx)(m,{name:`arrow-left-s`,className:`size-5`})}):(0,$.jsx)(`span`,{"aria-hidden":`true`}),t[9]=a,t[10]=v,t[11]=o,t[12]=P):P=t[12];let F;t[13]===n?F=t[14]:(F=(0,$.jsx)(`div`,{className:`yuri-mobile-detail-title w-full truncate typography-ui-label font-medium text-foreground`,children:n}),t[13]=n,t[14]=F);let I;t[15]===i?I=t[16]:(I=i?(0,$.jsx)(`div`,{className:`yuri-mobile-detail-subtitle w-full truncate text-muted-foreground`,"aria-live":`polite`,children:i}):null,t[15]=i,t[16]=I);let L;t[17]!==F||t[18]!==I?(L=(0,$.jsxs)(`div`,{className:`flex w-full max-w-72 min-w-0 flex-col items-center justify-center justify-self-center px-1`,children:[F,I]}),t[17]=F,t[18]=I,t[19]=L):L=t[19];let R;t[20]===b?R=t[21]:(R=b.map(xt),t[20]=b,t[21]=R);let z;t[22]!==R||t[23]!==l?(z=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2`,children:[l,R]}),t[22]=R,t[23]=l,t[24]=z):z=t[24];let B;t[25]!==N||t[26]!==P||t[27]!==L||t[28]!==z?(B=(0,$.jsxs)(`div`,{className:N,children:[P,L,z]}),t[25]=N,t[26]=P,t[27]=L,t[28]=z,t[29]=B):B=t[29];let V;return t[30]!==j||t[31]!==B||t[32]!==D?(V=(0,$.jsx)(`header`,{"data-yuri-collapsible-header":D,className:j,children:B}),t[30]=j,t[31]=B,t[32]=D,t[33]=V):V=t[33],V}function xt(e,t){return(0,$.jsx)(f,{type:`button`,variant:`mobileGlass`,size:`mobileIcon`,className:p(e.elevated&&`relative z-[60]`),onClick:e.onClick,disabled:e.disabled,"aria-label":e.ariaLabel,"aria-expanded":e.pressed,title:e.title,children:(0,$.jsx)(m,{name:e.icon,className:`size-5`})},`${e.icon}:${t}`)}function St(e){return e.elevated}export{le as A,ft as C,ce as D,ue as E,y as M,v as N,se as O,et as S,pe as T,Xe as _,ht as a,Be as b,ot as c,it as d,lt as f,qe as g,rt as h,pt as i,_ as j,de as k,vt as l,mt as m,Ke as n,at as o,ut as p,Je as r,gt as s,bt as t,_t as u,Ie as v,me as w,Qe as x,Re as y};