@yuriai/web 0.2.29-beta.6 → 0.2.29-beta.9

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 (145) hide show
  1. package/dist/assets/{AgentAvatar-GVufO03R.js → AgentAvatar-BtFNGIgH.js} +1 -1
  2. package/dist/assets/AssistantContactStatus-CxBF6Ay6.js +3 -0
  3. package/dist/assets/{AssistantUnreadBadge-DTMRKZCr.js → AssistantUnreadBadge--5NJVTuh.js} +1 -1
  4. package/dist/assets/{AssistantView-uufzeb1u.js → AssistantView-BmpLCQuw.js} +1 -1
  5. package/dist/assets/{DiagramView-IJ0lkLlX.js → DiagramView-CRam7PmL.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-8NiBU75a.js → FadeInOnReveal-CuOJu25b.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-D_2lOySl.js → GuiPluginSurface-Cf4hIlkP.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-CW0-Tapi.js → GuiPluginWindow-CIVNyw4s.js} +1 -1
  9. package/dist/assets/Icon-BQczEnxm.js +1 -0
  10. package/dist/assets/{ImageLoadingPlaceholder-DTWzB26a.js → ImageLoadingPlaceholder-KksxJaKp.js} +1 -1
  11. package/dist/assets/{LoadingImage-B89ghYMH.js → LoadingImage-Ch5MyA20.js} +1 -1
  12. package/dist/assets/MarkdownRenderer-D3744fNd.js +2 -0
  13. package/dist/assets/{MarkdownRendererImpl-eHz56xHD.js → MarkdownRendererImpl-DShGc2YZ.js} +1 -1
  14. package/dist/assets/{MarkstreamRendererImpl-DchZmgl0.js → MarkstreamRendererImpl-DYmFf07T.js} +1 -1
  15. package/dist/assets/{MobileDetailNavigation-1eLMIXsT.js → MobileDetailNavigation-CjoghpoB.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-CAj4YGtu.js → MobileResizableSheet-Bk3z4g6T.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-gZSJfJFe.js → MobileShareBridge-Bii25Pjf.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-C6AI58D-.js +2 -0
  19. package/dist/assets/{MultiRunWindow-DawaRhCU.js → MultiRunWindow-xrwgbnRZ.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-BdU6Tyax.js → OnboardingScreen-CgQGvlEs.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-CzQC0JQI.js → OverlayScrollbar-C9Ac564a.js} +1 -1
  22. package/dist/assets/SettingsView-BHBG7CFA.js +29 -0
  23. package/dist/assets/{SettingsWindow-DcOkFGsW.js → SettingsWindow-D8hn7Jjd.js} +1 -1
  24. package/dist/assets/SetupTourDialog-B2crxm_w.js +1 -0
  25. package/dist/assets/SetupTourDialog-CUzqT2sw.css +1 -0
  26. package/dist/assets/{TerminalView-Cy-KXoO8.js → TerminalView-5ki5iNXt.js} +1 -1
  27. package/dist/assets/{ToolOutputDialog-CMYmDCR4.js → ToolOutputDialog-CMhix20T.js} +1 -1
  28. package/dist/assets/VoiceSettings-DawvV46L.js +2 -0
  29. package/dist/assets/{YuriLogo-BZC0ckt0.js → YuriLogo-CpccdHvS.js} +1 -1
  30. package/dist/assets/YuriWordmark-hZ6K7Smk.js +1 -0
  31. package/dist/assets/{appThemeRegistry-DeWACE9-.js → appThemeRegistry-D25YM694.js} +1 -1
  32. package/dist/assets/{assistant-attachment-cache-DMw2Smc8.js → assistant-attachment-cache-oatc8F4t.js} +1 -1
  33. package/dist/assets/{button-BF2cNEuq.js → button-Cjciq1yh.js} +1 -1
  34. package/dist/assets/{capgoAdapter-7QGwb_Ft.js → capgoAdapter-Bas1D6ds.js} +1 -1
  35. package/dist/assets/{collapsible-CS5qCQRU.js → collapsible-BzCn4-sd.js} +1 -1
  36. package/dist/assets/{context-menu-C6l4ycZG.js → context-menu-BIjCIXOg.js} +1 -1
  37. package/dist/assets/{diagram-D9-jif9d.js → diagram--zTR0vWJ.js} +1 -1
  38. package/dist/assets/{dialog-r7RRePv5.js → dialog-rVkj8VgE.js} +1 -1
  39. package/dist/assets/dropdown-menu.styles-BDla58Rm.js +1 -0
  40. package/dist/assets/{es-C8kGYKZo.js → es-B8dNq0Lv.js} +3 -3
  41. package/dist/assets/{fileMentionTouchSelection-dpFpcetU.js → fileMentionTouchSelection-CmdNi_d0.js} +1 -1
  42. package/dist/assets/{fileQueries-DWj9yB2g.js → fileQueries-C2Rs6TPz.js} +1 -1
  43. package/dist/assets/{fileReferenceActions-BBLYnGEx.js → fileReferenceActions-CvDFcgBH.js} +1 -1
  44. package/dist/assets/{fr-BV_9HcN9.js → fr-DbzWoYOD.js} +3 -3
  45. package/dist/assets/{gitApi-7_CLu286.js → gitApi-Cs08jIjA.js} +3 -3
  46. package/dist/assets/{gitApiHttp-DGAlAuET.js → gitApiHttp-Ddik7PM_.js} +1 -1
  47. package/dist/assets/{host-DB6QzbOw.js → host-D776RHTx.js} +1 -1
  48. package/dist/assets/{image-loading-BUouaouB.js → image-loading-DKQOYtti.js} +1 -1
  49. package/dist/assets/{input-DvF_mp0Y.js → input-GVRUiwuQ.js} +1 -1
  50. package/dist/assets/insertionBoundaries-BoEG12_x.js +1 -0
  51. package/dist/assets/{ja-CIMpz4Z2.js → ja-BGk5BIrz.js} +3 -3
  52. package/dist/assets/{ko-DPUsuWV1.js → ko-Broo5A8H.js} +3 -3
  53. package/dist/assets/main-BGYY-hd1.js +2 -0
  54. package/dist/assets/main-D00Zz44O.js +169 -0
  55. package/dist/assets/{markdownHeightCache-D02GlOiy.js → markdownHeightCache-C7UOJdkN.js} +1 -1
  56. package/dist/assets/{mcpQueries-ZP9RYRpN.js → mcpQueries-4__hFxuf.js} +1 -1
  57. package/dist/assets/miniChat-DJrq4mIe.js +2 -0
  58. package/dist/assets/mobile-BOrcaJMH.js +2 -0
  59. package/dist/assets/{mobileBackNavigation-DFGZEe-t.js → mobileBackNavigation-DfKlarxw.js} +1 -1
  60. package/dist/assets/multirun-D35HrOK1.js +3 -0
  61. package/dist/assets/native-DsqzO52u.js +1 -0
  62. package/dist/assets/{native-config-DPpUUZUE.js → native-config-DF7bq4tk.js} +1 -1
  63. package/dist/assets/{persistence-Dta0OwIa.js → persistence-D-rnhgr4.js} +2 -2
  64. package/dist/assets/{pl-ChxP5OZm.js → pl-not4wEra.js} +3 -3
  65. package/dist/assets/projectMeta-Bu5flvhx.js +1 -0
  66. package/dist/assets/{pt-BR-9N8nJVqC.js → pt-BR-3OzFQDGv.js} +3 -3
  67. package/dist/assets/pwa-CWEsl2Ow.js +2 -0
  68. package/dist/assets/{queryRuntime-CTcigFdj.js → queryRuntime-2dx7jbt9.js} +1 -1
  69. package/dist/assets/{queue-abort-optimistic-mL8MaoCr.js → queue-abort-optimistic-DZc2cRj7.js} +1 -1
  70. package/dist/assets/{readiness-ZMfy8K84.js → readiness-Dl790DNB.js} +1 -1
  71. package/dist/assets/renderElectronMiniChatApp-MI4k81uX.js +2 -0
  72. package/dist/assets/renderMobileApp-ClCiFay4.js +28 -0
  73. package/dist/assets/{runtime-file-download-o29morT6.js → runtime-file-download-D6bwc3Kj.js} +1 -1
  74. package/dist/assets/{runtime-file-resource-qB_oVdE6.js → runtime-file-resource-BP4P52ry.js} +1 -1
  75. package/dist/assets/{runtimeConfig-pLw4gnz5.js → runtimeConfig-BuChFCqQ.js} +1 -1
  76. package/dist/assets/runtimeEndpointReset-BHOxCpwZ.js +149 -0
  77. package/dist/assets/{scheduledTaskNavigation-BqkeRfVc.js → scheduledTaskNavigation-Bp5rGr3m.js} +1 -1
  78. package/dist/assets/select-DeP9bukP.js +1 -0
  79. package/dist/assets/sessionLookup-K6ZLigY7.js +1 -0
  80. package/dist/assets/{sortable-tabs-strip-Dc4Jr4ml.js → sortable-tabs-strip-BloEQRck.js} +1 -1
  81. package/dist/assets/speechSettingsQueries-DusLRL2i.js +3 -0
  82. package/dist/assets/{src-DME3XM8W.css → src-EZMbcCtg.css} +1 -1
  83. package/dist/assets/{store-BPYoxYhv.js → store-CKIMMlXR.js} +4 -3
  84. package/dist/assets/{terminalApi-CPVNQ5DH.js → terminalApi-ChZhb60_.js} +1 -1
  85. package/dist/assets/{textarea-CIhiRPB2.js → textarea-B4mWtnN5.js} +1 -1
  86. package/dist/assets/{tooltip-BoAbDVNP.js → tooltip-BuZ86ipm.js} +1 -1
  87. package/dist/assets/tour-Db44qwfs.js +1 -0
  88. package/dist/assets/{types-YPHToBnK.js → types-O8iYyCQi.js} +1 -1
  89. package/dist/assets/{uk-C-aeGNQI.js → uk-DyZ2SwUJ.js} +3 -3
  90. package/dist/assets/{useAppFontEffects-B1m1Chi0.js → useAppFontEffects-BTwyFf_W.js} +31 -31
  91. package/dist/assets/{useAssistantUIStore-CYyXdd5c.js → useAssistantUIStore-BI_dAUjx.js} +1 -1
  92. package/dist/assets/useDesktopWindowControlsLayout-GQRvPTBq.js +1 -0
  93. package/dist/assets/{dropdown-menu.styles-CX8oXdks.js → useDictation-CwX05CAo.js} +1 -1
  94. package/dist/assets/{useEffectiveDirectory-Yn0r_C4_.js → useEffectiveDirectory-n0L_esHA.js} +1 -1
  95. package/dist/assets/{useFontPreferences-UzjDmx4b.js → useFontPreferences-EsJ4FlIp.js} +1 -1
  96. package/dist/assets/{useMobileNavigationStore-BA7xNhOy.js → useMobileNavigationStore-CN9JDH7h.js} +14 -14
  97. package/dist/assets/usePluginsStore-D96HwGZy.js +1 -0
  98. package/dist/assets/useUIStore-CoWJ3ROq.js +1 -0
  99. package/dist/assets/{useWorkerHighlightedLines-CmzpUaxp.js → useWorkerHighlightedLines-Bs1Z-yjv.js} +1 -1
  100. package/dist/assets/vendor-tanstack-query-core-Y_YoRHtC.js +1 -0
  101. package/dist/assets/vendor-tanstack-react-query-B-Wpqq5J.js +1 -0
  102. package/dist/assets/{zh-CN-DOchDQti.js → zh-CN-aNIWxYun.js} +3 -3
  103. package/dist/assets/{zh-TW-Dtigv2CE.js → zh-TW-B1IdCz5g.js} +3 -3
  104. package/dist/index.html +16 -16
  105. package/dist/mini-chat.html +16 -16
  106. package/dist/mobile.html +16 -16
  107. package/package.json +1 -1
  108. package/server/lib/gui-customization/DOCUMENTATION.md +13 -2
  109. package/server/lib/gui-customization/session-skill.js +2 -2
  110. package/server/lib/gui-customization/session-skill.test.js +1 -1
  111. package/server/lib/gui-customization/skill/SKILL.md +8 -3
  112. package/server/lib/gui-customization/skill/references/appearance.md +6 -6
  113. package/server/lib/gui-customization/skill/references/file-previews.md +1 -1
  114. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  115. package/server/lib/gui-customization/skill/references/ui-surfaces.md +228 -0
  116. package/server/lib/gui-customization/skill/references/workflow.md +31 -32
  117. package/server/lib/opencode/DOCUMENTATION.md +7 -0
  118. package/server/lib/opencode/npm-registry.js +9 -2
  119. package/server/lib/opencode/npm-registry.test.js +22 -1
  120. package/server/lib/opencode/plugin-routes.js +1 -0
  121. package/server/lib/opencode/settings-helpers.js +0 -3
  122. package/server/lib/opencode/settings-helpers.test.js +8 -0
  123. package/dist/assets/AssistantContactStatus-CgOdvIWb.js +0 -3
  124. package/dist/assets/Icon-CLLDJn-P.js +0 -1
  125. package/dist/assets/MarkdownRenderer-BG5J2mhU.js +0 -2
  126. package/dist/assets/MobileTabPageHeader-DiMMm7-i.js +0 -2
  127. package/dist/assets/SettingsView-iZoHP7ZH.js +0 -30
  128. package/dist/assets/insertionBoundaries-MbOUMCNs.js +0 -1
  129. package/dist/assets/main-CDhqjr2O.js +0 -169
  130. package/dist/assets/main-DIWLptmb.js +0 -2
  131. package/dist/assets/miniChat-CUOtrJxd.js +0 -2
  132. package/dist/assets/mobile-BTUerqBN.js +0 -2
  133. package/dist/assets/multirun-Bm50cLcf.js +0 -3
  134. package/dist/assets/native-CILcYDJz.js +0 -1
  135. package/dist/assets/projectMeta-BJmwM0K0.js +0 -1
  136. package/dist/assets/renderElectronMiniChatApp-1hIEJ9QD.js +0 -2
  137. package/dist/assets/renderMobileApp-DtZxMBPw.js +0 -28
  138. package/dist/assets/runtimeEndpointReset-5JI5Tj-e.js +0 -149
  139. package/dist/assets/sessionLookup-8R_5W-vC.js +0 -1
  140. package/dist/assets/speechSettingsQueries-HRIksqYz.js +0 -4
  141. package/dist/assets/useDesktopWindowControlsLayout-BTfHr7J0.js +0 -1
  142. package/dist/assets/useUIStore-BDZCXouA.js +0 -1
  143. package/dist/assets/vendor-tanstack-query-core-BWz0ose6.js +0 -1
  144. package/dist/assets/vendor-tanstack-react-query-B2psfNaU.js +0 -1
  145. /package/dist/assets/{SettingsView-C0HSdVvS.css → VoiceSettings-C0HSdVvS.css} +0 -0
@@ -1,8 +1,8 @@
1
- # Package, build, install, verify
1
+ # Package, install, update
2
2
 
3
3
  ## Complete minimal appearance plugin
4
4
 
5
- Use a separate plugin directory, not Yuri's source tree. These three files illustrate a complete theme + logo + CSS package. For pages, file viewers or other capabilities, keep the package/build structure and use the matching reference's GUI entry. A Dock contribution is needed only when requested.
5
+ Default to a directly authored CommonJS file in a separate plugin directory. These two files are a complete theme + logo + CSS plugin: no dependency installation, compiler or dev server is needed. Include only the contributions requested by the user.
6
6
 
7
7
  `package.json`:
8
8
 
@@ -11,37 +11,20 @@ Use a separate plugin directory, not Yuri's source tree. These three files illus
11
11
  "name": "yuri-studio-skin",
12
12
  "version": "0.1.0",
13
13
  "private": true,
14
- "type": "module",
15
- "exports": { "./gui-experimental": "./dist/gui-experimental.cjs" },
16
- "files": ["dist"],
17
- "scripts": { "build": "vite build", "dev": "vite build --watch" },
18
- "dependencies": { "@opencode/plugin": "2.2.0" },
19
- "devDependencies": { "vite": "^7.0.0", "vite-plugin-solid": "^2.11.0", "solid-js": "^1.9.0" }
14
+ "exports": { "./gui-experimental": "./gui-experimental.cjs" },
15
+ "files": ["gui-experimental.cjs"]
20
16
  }
21
17
  ```
22
18
 
23
- `vite.config.ts`:
19
+ `gui-experimental.cjs`:
24
20
 
25
- ```ts
26
- import { defineConfig } from 'vite'
27
- import { gui } from '@opencode/plugin/gui/vite'
28
- export default defineConfig({ plugins: [gui()] })
29
- ```
21
+ ```js
22
+ const { Plugin, Registry, Style } = require('@opencode/plugin/gui')
30
23
 
31
- `src/gui.tsx`:
24
+ const Theme = Registry.define('yuri.theme')
25
+ const Branding = Registry.define('yuri.branding')
32
26
 
33
- ```tsx
34
- import { Plugin, Registry, Style } from '@opencode/plugin/gui'
35
-
36
- const Theme = Registry.define<{
37
- id: string; title: string; variant: 'dark' | 'light';
38
- colors?: { primary?: { base?: string }; surface?: { background?: string } }
39
- }>('yuri.theme')
40
- const Branding = Registry.define<{
41
- id: string; title: string; logo?: { svg: string; lightSvg?: string }
42
- }>('yuri.branding')
43
-
44
- export default Plugin.define({
27
+ module.exports = Plugin.define({
45
28
  setup(ctx) {
46
29
  ctx.add(Theme, {
47
30
  id: 'studio-dark', title: 'Studio Dark', variant: 'dark',
@@ -59,23 +42,39 @@ export default Plugin.define({
59
42
  })
60
43
  ```
61
44
 
62
- This package has no server entry and no `main`; its package name becomes its plugin ID. For a mixed server/GUI plugin, use the server part's `Plugin.define` ID consistently. No separate Yuri entrypoint is needed. The official Vite preset compiles Solid, inlines dynamic imports/dependencies, and emits one CJS file. Shared SDK/Solid/Effect modules must remain host-provided, not bundled duplicates.
45
+ This package has no server entry and no `main`; its package name becomes its plugin ID. For a mixed server/GUI plugin, use the server part's `Plugin.define` ID consistently. The host supplies the SDK through `require`; a standalone Node `require` is not the plugin runtime. Use `node --check gui-experimental.cjs` for a quick syntax check.
46
+
47
+ Keep CSS/SVG as strings and Dock PNGs as data URLs in this file. Window DOM APIs and host-provided Solid helpers work without JSX. The host resolves only its shared modules, not relative `require('./style.css')`, sibling source files, or arbitrary installed dependencies. TypeScript snippets in other references describe contracts; direct CJS uses plain JavaScript, `require` and `module.exports` without type annotations.
63
48
 
64
49
  ## Installation and updates
65
50
 
66
- 1. Ask permission before installing dependencies or changing config. Use the user's selected package manager to install this standalone package's declared dependencies and run `build`. Verify `dist/gui-experimental.cjs` exists and exports a definition; do not point the host at TSX or an ES module.
51
+ 1. Write the two files above and syntax-check the `.cjs`. Installation follows the user's requested scope; a direct-CJS plugin needs no package-manager step. The GUI entry is executable CommonJS JavaScript, not TS/TSX or ESM source.
67
52
  2. Inspect the user's **global** `opencode.json(c)` and preserve unrelated configuration/comments. Add the absolute plugin directory to `plugins`, or use the documented OpenCode plugin installation command after checking that CLI's current help/docs. Do not invent CLI flags. For example:
68
53
 
69
54
  ```jsonc
70
55
  { "plugins": ["/absolute/path/to/yuri-studio-skin"] }
71
56
  ```
72
57
 
73
- 3. Yuri loads GUI entries from the connected service's global inventory. A project-only plugin entry will not supply a window GUI. Local path changes rebuilt by Vite are revision updates, not new npm versions. Confirm the plugin appears active in plugin settings; explicit refresh can retry a failed instance. The GUI enable switch is separate from server plugin loading.
58
+ 3. Yuri loads GUI entries from the connected service's global inventory. A project-only plugin entry will not supply a window GUI. Save changes directly to the exported `.cjs`; the local-file watcher updates the GUI revision and reloads the plugin. No build, version bump or application restart is needed for this edit loop. Confirm the plugin appears active in plugin settings; explicit refresh can retry a failed instance. The GUI enable switch is separate from server plugin loading.
74
59
  4. Verify appearance contributions apply when the GUI is enabled, using [appearance](appearance.md) for priority and fallback. For other capabilities, verify their registered entry points.
75
- 5. For publication, remove `private` only when requested, build first, and publish the package with its CJS artifact. Use a new npm version for updates. No publishing is implied by a local customization request.
60
+ 5. For publication, remove `private` only when requested and include the exported CJS file in the package. Use a new npm version for published updates. No publishing is implied by a local customization request.
61
+
62
+ ## Optional: compiled source
63
+
64
+ Use a build only when the implementation needs TS/TSX, JSX, bundled dependencies or split source/assets, or when maintaining an existing compiled plugin. The GUI host still receives one CommonJS file; OpenCode's ability to load server-side TypeScript does not extend to the GUI entry.
65
+
66
+ For this branch, put the source in `src/gui.tsx`, point `./gui-experimental` at `./dist/gui-experimental.cjs`, and include `dist` in `files`. Use `@opencode/plugin` 2.2.0 with compatible `vite`, `vite-plugin-solid` and `solid-js` development dependencies and these scripts: `build: vite build`, `dev: vite build --watch`. Install dependencies only within the authorized plugin scope.
67
+
68
+ ```ts
69
+ import { defineConfig } from 'vite'
70
+ import { gui } from '@opencode/plugin/gui/vite'
71
+ export default defineConfig({ plugins: [gui()] })
72
+ ```
73
+
74
+ The official preset compiles Solid JSX and emits one CJS file, inlining dynamic imports and non-shared dependencies. SDK/Solid/Effect shared modules remain host-provided. Here, saving source requires a rebuild (or `vite build --watch`) before the exported file changes and reloads.
76
75
 
77
76
  ## Verification and rollback
78
77
 
79
- Verify each implemented capability in the target client, not only the bundler. Check its normal, failed and unavailable states, cleanup on disable/rebuild, and isolation from unrelated plugins. Capability-specific checks belong to the matching reference. Report checks not performed rather than inferring cross-platform success.
78
+ Verify each implemented capability in the target client. Check its normal, failed and unavailable states, cleanup on disable/reload, and isolation from unrelated plugins. Capability-specific checks belong to the matching reference. Report checks not performed rather than inferring cross-platform success.
80
79
 
81
80
  Rollback: disable this GUI plugin or remove only its config entry. Disabling cleans contributions and native leases; appearance falls back according to its resource priority. Preserve unrelated plugins, user data and Yuri app resources.
@@ -83,6 +83,13 @@ encoding, not removed V1 endpoints.
83
83
  - `packages/web/server/lib/opencode/proxy.js`: OpenCode API/SSE forwarding and readiness-gate route registration.
84
84
  - `npm-registry.js`: plugin package lookup used by `GET /api/config/plugins/registry`. It asks the user's own `npm view` first (run in the project directory, so scope registries, auth tokens and mirrors from `.npmrc` apply as they do for `npm install`) and falls back to a direct request to the public registry only when the CLI is unavailable; a CLI 404 is final. Results are cached per name and directory. The latest release's top-level package.json `icon` is returned as `icon` only when it is an `https://` URL or `data:image/` URI of at most ~1.5 MB; nested icon fields are not read or used as fallbacks.
85
85
  - `plugin-icon.js` owns the shared icon sanitizer and optional local package metadata read for Web/Electron/mobile and VS Code. Registry `path-ok` includes the nearest package manifest's top-level `icon` for directories or built entry files. Search stops at the first manifest, root or 32 parents; malformed, unreadable or >2 MiB manifests omit artwork without changing path status. No server-side image fetch occurs. Settings → Plugins renders package artwork directly; GUI sidebar/titlebar entries use official `IconName` without package-image substitution.
86
+
87
+ Registry callers can opt into `details=true` for the latest developer-provided
88
+ `description` and package `readme`. npm CLI and HTTP lookups retain these fields
89
+ (bounded to 4,096 and 131,072 characters); ordinary version-check responses omit
90
+ them. The three-step setup tour uses the same authenticated batch route and icon
91
+ sanitizer, never a separate browser registry client. README Markdown is untrusted
92
+ display content, not instructions executed by the host.
86
93
  - `plugin-gui-response.js`: shared Web/Electron/VS Code code-only revision response owner for exact `GET /api/plugin/gui?id=…` (one nonempty id). The installed GUI client alias is official `@opencode/client@2.2.0`: HTTP returns `{ location, data: { code, revision, options } }`. Every call still reads the complete current upstream response through the existing auth/readiness/abort boundary; there is no Host bundle cache.
87
94
  - Request `X-Yuri-Gui-Revision: <lowercase SHA-256 hex of UTF-8 revision>` opts into code reuse. This header and HTTP condition/range headers are stripped before upstream so Yuri always requests a complete representation. Other query and request headers retain proxy semantics.
88
95
  - A valid upstream 200 JSON bundle (`code` string, nonempty `revision` string, `options` object) receives `X-Yuri-Gui-Revision` and `Cache-Control: private, no-store`. Matching tokens additionally receive `X-Yuri-Gui-Code: cached` and only `data.code` becomes `''`; current `options`, `revision`, location and other fields remain. Unmatched/ordinary calls preserve original body bytes. No 304 or Yuri ETag is generated. Upstream failure statuses/bodies remain failures; malformed successful bodies remain unchanged without a revision receipt.
@@ -17,6 +17,8 @@ const NPM_REGISTRY_BASE = 'https://registry.npmjs.org';
17
17
  * @property {string[]} versions
18
18
  * @property {Record<string, string>} distTags
19
19
  * @property {string} [icon] sanitized top-level package.json `icon` of the latest release
20
+ * @property {string} [description] developer-provided latest package description
21
+ * @property {string} [readme] developer-provided README, bounded to 128 KiB characters
20
22
  *
21
23
  * @typedef {Object} NpmLookupError
22
24
  * @property {false} ok
@@ -104,7 +106,7 @@ function lookupViaNpmCli(name, cwd) {
104
106
  return new Promise((resolve) => {
105
107
  execFile(
106
108
  process.platform === 'win32' ? 'npm.cmd' : 'npm',
107
- ['view', name, 'dist-tags', 'versions', 'icon', '--json'],
109
+ ['view', name, 'dist-tags', 'versions', 'icon', 'description', 'readme', '--json'],
108
110
  {
109
111
  cwd: cwd || undefined,
110
112
  timeout: NPM_CLI_TIMEOUT_MS,
@@ -129,7 +131,10 @@ function lookupViaNpmCli(name, cwd) {
129
131
  ? data.versions.filter((version) => typeof version === 'string')
130
132
  : typeof data?.versions === 'string' ? [data.versions] : [];
131
133
  const icon = sanitizePluginIcon(data?.icon);
132
- resolve({ ok: true, latest: distTags.latest ?? null, versions, distTags, ...(icon ? { icon } : {}) });
134
+ resolve({ ok: true, latest: distTags.latest ?? null, versions, distTags, ...(icon ? { icon } : {}),
135
+ ...(typeof data.description === 'string' ? { description: data.description.slice(0, 4096) } : {}),
136
+ ...(typeof data.readme === 'string' ? { readme: data.readme.slice(0, 131072) } : {}),
137
+ });
133
138
  } catch {
134
139
  resolve(null);
135
140
  }
@@ -182,6 +187,8 @@ async function lookupNpmPackageOverHttp(name) {
182
187
  versions: parseVersions(data?.versions),
183
188
  distTags,
184
189
  ...(icon ? { icon } : {}),
190
+ ...(typeof data?.versions?.[latest]?.description === 'string' ? { description: data.versions[latest].description.slice(0, 4096) } : {}),
191
+ ...(typeof data.readme === 'string' ? { readme: data.readme.slice(0, 131072) } : {}),
185
192
  };
186
193
  }
187
194
 
@@ -92,6 +92,27 @@ describe('npm registry client', () => {
92
92
  expect(result).toEqual({ ok: true, latest: null, versions: [], distTags: {} });
93
93
  });
94
94
 
95
+ test('exposes bounded developer description and README from HTTP and npm CLI without substituting content', async () => {
96
+ const description = 'Developer description';
97
+ const readme = '# Developer README\n\nInstallation and usage.';
98
+ fetchMock.mockImplementation(() => jsonResponse({
99
+ 'dist-tags': { latest: '1.2.0' }, versions: { '1.2.0': { description } }, readme,
100
+ }));
101
+ expect(await npm.lookupNpmPackage('tour-plugin')).toMatchObject({ description, readme });
102
+ npm.npmCli.lookup = originalCliLookup;
103
+ execFileMock.mockImplementation((_command, _args, _options, callback) => callback(null, JSON.stringify({
104
+ 'dist-tags': { latest: '1.2.0' }, versions: ['1.2.0'], description, readme,
105
+ }), ''));
106
+ expect(await npm.lookupNpmPackage('tour-plugin')).toMatchObject({ description, readme });
107
+ npm.npmCli.lookup = async () => null;
108
+ fetchMock.mockImplementation(() => jsonResponse({
109
+ 'dist-tags': { latest: '1.2.0' }, versions: { '1.2.0': { description: 'x'.repeat(5000) } }, readme: 'y'.repeat(150000),
110
+ }));
111
+ const bounded = await npm.lookupNpmPackage('large-plugin');
112
+ expect(bounded.description).toHaveLength(4096);
113
+ expect(bounded.readme).toHaveLength(131072);
114
+ });
115
+
95
116
  test('404 returns package not found', async () => {
96
117
  fetchMock.mockImplementation(() => jsonResponse({}, 404));
97
118
 
@@ -228,7 +249,7 @@ describe('npm registry client', () => {
228
249
  const result = await npm.getNpmInfo('@scope/pkg', { cwd: '/proj' });
229
250
 
230
251
  expect(result.icon).toBe('https://cdn.example/a.png');
231
- expect(execFileMock).toHaveBeenCalledWith(expect.any(String), ['view', '@scope/pkg', 'dist-tags', 'versions', 'icon', '--json'],
252
+ expect(execFileMock).toHaveBeenCalledWith(expect.any(String), ['view', '@scope/pkg', 'dist-tags', 'versions', 'icon', 'description', 'readme', '--json'],
232
253
  expect.objectContaining({ cwd: '/proj' }), expect.any(Function));
233
254
  expect(fetchMock).not.toHaveBeenCalled();
234
255
  });
@@ -214,6 +214,7 @@ export const registerPluginRoutes = (app, dependencies) => {
214
214
  versions: info.versions,
215
215
  hasUpdate: currentVersion !== null && isExactSemver(currentVersion) && currentVersion !== info.latest,
216
216
  ...(info.icon ? { icon: info.icon } : {}),
217
+ ...(req.query.details === 'true' ? { description: info.description ?? '', readme: info.readme ?? '' } : {}),
217
218
  });
218
219
  }
219
220
 
@@ -605,9 +605,6 @@ export const createSettingsHelpers = (dependencies) => {
605
605
  if (typeof candidate.promptNavigatorEnabled === 'boolean') {
606
606
  result.promptNavigatorEnabled = candidate.promptNavigatorEnabled;
607
607
  }
608
- if (typeof candidate.expandedEditorToolbar === 'boolean') {
609
- result.expandedEditorToolbar = candidate.expandedEditorToolbar;
610
- }
611
608
  if (typeof candidate.showSplitAssistantMessageActions === 'boolean') {
612
609
  result.showSplitAssistantMessageActions = candidate.showSplitAssistantMessageActions;
613
610
  }
@@ -39,6 +39,14 @@ const createTestHelpersWithRealSanitizers = () => {
39
39
  };
40
40
 
41
41
  describe('settings helpers', () => {
42
+ it('ignores retired editor toolbar preferences in updates and stored settings', () => {
43
+ const helpers = createTestHelpers();
44
+ for (const expandedEditorToolbar of [true, false, null, {}, 'invalid']) {
45
+ expect(helpers.sanitizeSettingsUpdate({ expandedEditorToolbar, userMessageRenderingMode: 'plain' }))
46
+ .toEqual({ userMessageRenderingMode: 'plain' });
47
+ expect(helpers.formatSettingsResponse({ expandedEditorToolbar })).not.toHaveProperty('expandedEditorToolbar');
48
+ }
49
+ });
42
50
  it('round-trips the Volcengine dictation provider without accepting speech credentials', () => {
43
51
  const helpers = createTestHelpers();
44
52
  const normalized = helpers.sanitizeSettingsUpdate({ sttProvider: 'volcengine', volcengineApiKey: 'credential-sentinel' });
@@ -1,3 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/ToolOutputDialog-CMYmDCR4.js","assets/rolldown-runtime-hePW80VL.js","assets/runtime-auth-DBn9yahL.js","assets/runtime-switch-DEZ1K7qW.js","assets/runtime-fetch-D0YWp3FJ.js","assets/desktop-JwYqThiw.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/vendor-base-ui-CzHs0bHY.js","assets/useUIStore-BDZCXouA.js","assets/vendor-zustand-vDaAPGfl.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-DlzBev0S.js","assets/vendor-tanstack-react-query-B2psfNaU.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/runtime-file-resource-qB_oVdE6.js","assets/queryRuntime-CTcigFdj.js","assets/fileQueries-DWj9yB2g.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/runtime-file-download-o29morT6.js","assets/platform-DFJEtBlo.js","assets/vendor-pierre-diffs-BFiZ3IhI.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/vendor-reactuses-core-DWo5Wn6R.js","assets/vendor-lodash-es-BS45jPoZ.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-BF2cNEuq.js","assets/store-BPYoxYhv.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useThemeSystem-CNzUUkFn.js","assets/vendor-framer-motion-DDMKlXiP.js","assets/Icon-CLLDJn-P.js","assets/dialog-r7RRePv5.js","assets/dialog-CTYD3Sbr.css","assets/tap-LkQum5bB.js","assets/themes-BgDJcxRc.js","assets/MobileWindowStack-DGLdgoGr.js","assets/appThemeRegistry-DeWACE9-.js","assets/useMobileNavigationStore-BA7xNhOy.js","assets/gitApiHttp-DGAlAuET.js","assets/vendor-opencode-client-cQ47ywrT.js","assets/vendor-effect-X1Hqc7ba.js","assets/persistence-Dta0OwIa.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/vendor-sonner-BEHGipm5.js","assets/useAssistantUIStore-CYyXdd5c.js","assets/vendor-zod-DZzbCm1s.js","assets/vendor-opencode-schema-DWT45VBX.js","assets/agentColors-DWSbQXy2.js","assets/rasterizePng-056Poix7.js","assets/MarkdownRenderer-BG5J2mhU.js","assets/useEffectiveDirectory-Yn0r_C4_.js","assets/markdownHeightCache-D02GlOiy.js","assets/dualLimitLru-D8Sphgua.js","assets/toolHelpers-iEHVHQ9p.js","assets/image-loading-BUouaouB.js","assets/image-loading-D9Z_BASK.css","assets/ImageLoadingPlaceholder-DTWzB26a.js","assets/useWorkerHighlightedLines-CmzpUaxp.js","assets/markdownTheme-CHNl6tUv.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-tanstack-react-virtual-DSFNK3qc.js","assets/mobileBackNavigation-DFGZEe-t.js","assets/touch-gestures-CErgaXZ7.js","assets/ToolOutputDialog-CbGuK5bP.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEZ1K7qW.js";import{a as r}from"./vendor-zustand-vDaAPGfl.js";import{d as i,f as a,g as o,h as s,m as c,ot as l,p as u,st as d,u as f}from"./vendor-base-ui-CzHs0bHY.js";import{r as p}from"./useUIStore-BDZCXouA.js";import{$ as m,B as h,J as g,K as _,U as v,X as y,q as b,st as x,z as S}from"./persistence-Dta0OwIa.js";import{n as C}from"./vendor-react-DlzBev0S.js";import{s as w}from"./vendor-tanstack-react-query-B2psfNaU.js";import{o as T}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{n as E,r as D}from"./platform-DFJEtBlo.js";import{a as O,i as k,m as A,o as j,p as M,s as N}from"./vendor-reactuses-core-DWo5Wn6R.js";import{f as ee,r as P,t as F}from"./button-BF2cNEuq.js";import{i as te,n as I}from"./MobileShareBridge-gZSJfJFe.js";import{N as L,T as ne,_ as R,f as re,g as z,h as B,j as V,n as ie,r as H,u as U,v as ae,w as oe}from"./MobileDetailNavigation-1eLMIXsT.js";import{Ea as se,Et as W,Jr as G,Xn as ce,Y as K,Yr as le,s as ue}from"./useMobileNavigationStore-BA7xNhOy.js";import{n as de}from"./useAssistantUIStore-CYyXdd5c.js";import{a as fe}from"./fileMentionAutocompleteState-BZJqfgae.js";import{t as pe}from"./AgentAvatar-GVufO03R.js";import{d as me,o as q,t as he}from"./vendor-framer-motion-DDMKlXiP.js";import{n as J}from"./Icon-CLLDJn-P.js";import{t as Y}from"./scheduledTaskNavigation-BqkeRfVc.js";import{D as ge,E as _e,O as ve,a as ye,c as be,d as xe,f as Se,g as Ce,h as we,l as Te,m as X,o as Ee,s as De,t as Oe,u as ke,w as Ae,x as je}from"./sessionLookup-8R_5W-vC.js";import{a as Me,n as Ne,r as Pe,t as Fe}from"./fileMentionTouchSelection-dpFpcetU.js";import{a as Ie,o as Le,t as Re}from"./MarkdownRenderer-BG5J2mhU.js";import{c as ze,s as Be}from"./image-loading-BUouaouB.js";import{t as Ve}from"./ImageLoadingPlaceholder-DTWzB26a.js";import{t as He}from"./LoadingImage-B89ghYMH.js";import{n as Ue}from"./textarea-CIhiRPB2.js";import{t as We}from"./vendor-motion-C9oiAdx-.js";import{i as Ge,n as Ke,r as qe}from"./assistant-attachment-cache-DMw2Smc8.js";var Z=C(),Q=e(d(),1),$=l();function Je(e){let r=(0,Z.c)(12),{assistantID:i,position:a}=e,o=Q.useRef(null),s=Q.useRef(!1),c;r[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={busy:!1,done:!1,retryAt:0},r[0]=c):c=r[0];let l=Q.useRef(c),[u]=Q.useState(et),d;r[1]!==i||r[2]!==a||r[3]!==u?(d=()=>{let e=o.current;if(!e||!s.current||l.current.busy||l.current.done||Date.now()<l.current.retryAt||u.transport!==t()||u.generation!==n()||document.visibilityState!==`visible`||(E()?!document.documentElement.classList.contains(`yuri-native-app-active`):!document.hasFocus())||e.parentElement?.closest(`[inert], [aria-hidden="true"]`))return;let r=e.closest(`[data-assistant-contact-transcript]`);if(!r||r.scrollHeight-r.scrollTop-r.clientHeight>2)return;let c=e.getBoundingClientRect(),d=r.getBoundingClientRect(),f=window.visualViewport,p=f?.offsetTop??0,m=p+(f?.height??window.innerHeight);c.height<=0||c.width<=0||c.bottom>Math.min(d.bottom,m)||c.top<Math.max(d.top,p)||c.right<=Math.max(d.left,0)||c.left>=Math.min(d.right,window.innerWidth)||(l.current.busy=!0,U(i,a).then(()=>{l.current.done=!0}).catch(()=>{l.current.retryAt=Date.now()+15e3}).finally(()=>{l.current.busy=!1}))},r[1]=i,r[2]=a,r[3]=u,r[4]=d):d=r[4];let f=k(d),p;r[5]===f?p=r[6]:(p=e=>{s.current=e.some($e),f()},r[5]=f,r[6]=p);let m;r[7]===Symbol.for(`react.memo_cache_sentinel`)?(m={threshold:1},r[7]=m):m=r[7],j(o,k(p),m),O(`visibilitychange`,f,Qe),O(`focus`,f,Ze),O(`resize`,f,Xe);let h,g;r[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>o.current?.closest(`[data-assistant-contact-transcript]`),g={passive:!0},r[8]=h,r[9]=g):(h=r[8],g=r[9]),O(`scroll`,f,h,g);let _;r[10]===Symbol.for(`react.memo_cache_sentinel`)?(_={attributes:!0,attributeFilter:[`class`]},r[10]=_):_=r[10],M(f,Ye,_),N(f,15e3);let v;return r[11]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(`span`,{ref:o,"aria-hidden":`true`,className:`absolute bottom-0 left-0 block h-px w-px`,"data-assistant-read-marker":``}),r[11]=v):v=r[11],v}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(ve),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}=ee(),c=ze(),l=w({...le(c),select:rt}),u=Q.useMemo(()=>fe({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(Fe,[]);O(`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 _=k(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)(Ne,{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)(F,{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)(F,{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:P(`flex min-h-10 cursor-pointer items-center gap-2 rounded-md px-1.5 py-1 typography-ui-label`,Pe(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)(120),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}=ee(),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}=ge(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,y;t[11]===a.value?y=t[12]:(y=()=>({canonical:a.value,document:v(a.value,new Map)}),t[11]=a.value,t[12]=y);let[C,w]=Q.useState(y),T;t[13]!==C.canonical||t[14]!==C.document||t[15]!==a.value?(T=C.canonical===a.value?C.document:v(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),[A,j]=Q.useState(!0),[M,N]=Q.useState(!1),[F,te]=Q.useState(),I=Q.useRef(null),L=Q.useRef(null),ne=Q.useRef(null),R=Q.useRef(null),re;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(re=be(),t[17]=re):re=t[17];let z=Q.useRef(re),B=Q.useId(),V;t[18]!==n||t[19]!==M||t[20]!==D||t[21]!==A||t[22]!==E.text||t[23]!==a.disabled||t[24]!==a.pending?(V=n&&!a.pending&&!a.disabled&&!A&&!M?Me({text:E.text,cursor:D}):null,t[18]=n,t[19]=M,t[20]=D,t[21]=A,t[22]=E.text,t[23]=a.disabled,t[24]=a.pending,t[25]=V):V=t[25];let ie=V,H=ie?.kind===`mention`?ie:null,U;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(U=()=>{R.current!==null&&(I.current?.focus({preventScroll:!0}),I.current?.setSelectionRange(R.current,R.current),R.current=null)},t[26]=U):U=t[26];let ae;t[27]===E?ae=t[28]:(ae=[E],t[27]=E,t[28]=ae),Q.useLayoutEffect(U,ae);let oe;t[29]===Symbol.for(`react.memo_cache_sentinel`)?(oe=()=>j(!0),t[29]=oe):oe=t[29];let se=k(oe),W;t[30]!==M||t[31]!==D||t[32]!==E||t[33]!==r?(W=(e,t,n)=>{let i=n===void 0||n,a=g(e);a.ok&&(i&&(z.current=Te(z.current,{before:De(E,[],{start:I.current?.selectionStart??D,end:I.current?.selectionEnd??D}),after:De(e,[],{start:t,end:t})})),M||(R.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=k(W),ce;t[35]!==G||t[36]!==E||t[37]!==H||t[38]!==o?(ce=e=>{if(!H)return;let t=e.title||o(`chat.fileMentionAutocomplete.untitledSession`),n=h(E,H.tokenStart,H.tokenEnd,{id:`session:${e.id}:${crypto.randomUUID()}`,kind:`session`,sessionId:e.id,display:x({trigger:`@`,icon:`chat-thread`,label:t})},{inlineBoundaries:!0,padDocumentEdges:!0}),r=n.caret+ +(n.document.text[n.caret]===` `);j(!0),G(n.document,r)},t[35]=G,t[36]=E,t[37]=H,t[38]=o,t[39]=ce):ce=t[39];let K=k(ce),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=_(E,t,t.length,t.length);G(r.document,r.caret),j(!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 ue=k(le),de;t[46]!==n||t[47]!==E.text||t[48]!==ue||t[49]!==r||t[50]!==i||t[51]!==a.disabled||t[52]!==a.pending?(de=e=>{if(!(!n||a.pending||a.disabled||!e.trim())){if(E.text){ue(e);return}r(e),i?.(e)}},t[46]=n,t[47]=E.text,t[48]=ue,t[49]=r,t[50]=i,t[51]=a.disabled,t[52]=a.pending,t[53]=de):de=t[53];let fe=k(de),pe;t[54]!==G||t[55]!==E?(pe=(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=S(n.selectionStart,n.selectionEnd,E.references)??{start:n.selectionStart,end:n.selectionEnd},i=g({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=_(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]=pe):pe=t[56];let me=k(pe),q;t[57]!==E.references||t[58]!==E.text?(q=Ce(E.text,E.references.map(ot))?.map(st),t[57]=E.references,t[58]=E.text,t[59]=q):q=t[59];let he=q,J=u&&E.text.length===0?`true`:void 0,Y;t[60]!==u||t[61]!==ue||t[62]!==a.disabled||t[63]!==a.pending||t[64]!==fe||t[65]!==f?(Y=u&&(0,$.jsx)(nt,{containerRef:s,disabled:!!(a.pending||a.disabled),onInsert:ue,onSend:fe,onRelease:tt,onHintChange:f}),t[60]=u,t[61]=ue,t[62]=a.disabled,t[63]=a.pending,t[64]=fe,t[65]=f,t[66]=Y):Y=t[66];let _e=E.text,ve=a.pending,ye;t[67]===a?ye=t[68]:(ye=()=>{a.pending||a.onSubmit()},t[67]=a,t[68]=ye);let Se=a.layout===`inline`?`py-3 leading-6`:`pt-4 pb-2`,we;t[69]!==a.textLayoutClassName||t[70]!==Se?(we=P(`whitespace-pre-wrap break-words overflow-hidden px-3 typography-markdown md:typography-ui-label`,Se,a.textLayoutClassName),t[69]=a.textLayoutClassName,t[70]=Se,t[71]=we):we=t[71];let X;t[72]!==G||t[73]!==E?(X=(e,t)=>{let n=_(E,e,t?.target.selectionStart??e.length,t?.target.selectionEnd??e.length);G(n.document,n.caret),j(t?.nativeEvent?.inputType===`insertFromPaste`)},t[72]=G,t[73]=E,t[74]=X):X=t[74];let Ee=H?B:void 0,Oe=H?F:void 0,Ne;t[75]===a.textareaProps?Ne=t[76]:(Ne=e=>{a.textareaProps?.onScroll?.(e),L.current&&(L.current.scrollTop=e.currentTarget.scrollTop,L.current.scrollLeft=e.currentTarget.scrollLeft)},t[75]=a.textareaProps,t[76]=Ne);let Pe,Fe;t[77]!==me||t[78]!==a.textareaProps?(Pe=e=>{a.textareaProps?.onCopy?.(e),e.defaultPrevented||me(e,!1)},Fe=e=>{a.textareaProps?.onCut?.(e),e.defaultPrevented||me(e,!0)},t[77]=me,t[78]=a.textareaProps,t[79]=Pe,t[80]=Fe):(Pe=t[79],Fe=t[80]);let Ie;t[81]===a.textareaProps?Ie=t[82]:(Ie=e=>{O(e.currentTarget.selectionStart),a.textareaProps?.onSelect?.(e)},t[81]=a.textareaProps,t[82]=Ie);let Le,Re;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(Le=()=>{N(!0)},Re=e=>{N(!1),O(e.currentTarget.selectionStart)},t[83]=Le,t[84]=Re):(Le=t[83],Re=t[84]);let ze;t[85]!==G||t[86]!==M||t[87]!==E||t[88]!==H||t[89]!==a.textareaProps?(ze=e=>{if(a.textareaProps?.onKeyDown?.(e),!(e.defaultPrevented||Ae(e))){if(M){e.key===`Enter`&&e.preventDefault();return}if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`z`){let t=e.shiftKey?ke(z.current,E):xe(z.current,E);t&&(e.preventDefault(),z.current=t.history,G(t.snapshot.document,t.snapshot.selection.end,!1),j(!0));return}if(e.key===`Backspace`||e.key===`Delete`){let t=b(E,{key:e.key,selectionStart:e.currentTarget.selectionStart,selectionEnd:e.currentTarget.selectionEnd,altKey:e.altKey});if(t){e.preventDefault(),G(t.document,t.caret),j(!0);return}}H&&[`ArrowDown`,`ArrowUp`,`Enter`,`Tab`,`Escape`].includes(e.key)&&(e.preventDefault(),e.stopPropagation(),ne.current?.keyDown(e.key))}},t[85]=G,t[86]=M,t[87]=E,t[88]=H,t[89]=a.textareaProps,t[90]=ze):ze=t[90];let Be;t[91]!==a.textareaProps||t[92]!==Ee||t[93]!==Oe||t[94]!==Ne||t[95]!==Pe||t[96]!==Fe||t[97]!==Ie||t[98]!==ze?(Be={...a.textareaProps,"aria-controls":Ee,"aria-activedescendant":Oe,"aria-autocomplete":`list`,onScroll:Ne,onCopy:Pe,onCut:Fe,onSelect:Ie,onCompositionStart:Le,onCompositionEnd:Re,onKeyDown:ze},t[91]=a.textareaProps,t[92]=Ee,t[93]=Oe,t[94]=Ne,t[95]=Pe,t[96]=Fe,t[97]=Ie,t[98]=ze,t[99]=Be):Be=t[99];let Ve;t[100]!==se||t[101]!==B||t[102]!==H||t[103]!==a.isMobile||t[104]!==K?(Ve=H?(0,$.jsx)(it,{ref:ne,query:H.query,isMobile:a.isMobile??!1,listId:B,onHighlightChange:te,onSelect:K,onClose:se}):null,t[100]=se,t[101]=B,t[102]=H,t[103]=a.isMobile,t[104]=K,t[105]=Ve):Ve=t[105];let He;t[106]!==E.text||t[107]!==he||t[108]!==m||t[109]!==a||t[110]!==ye||t[111]!==we||t[112]!==X||t[113]!==Be||t[114]!==Ve?(He=(0,$.jsx)(je,{...a,value:_e,pending:ve,placeholder:m,disableInputWhilePending:!1,inputRef:I,onSubmit:ye,highlightedContent:he,highlightRef:L,textLayoutClassName:we,onChange:X,textareaProps:Be,children:Ve}),t[106]=E.text,t[107]=he,t[108]=m,t[109]=a,t[110]=ye,t[111]=we,t[112]=X,t[113]=Be,t[114]=Ve,t[115]=He):He=t[115];let Ue;return t[116]!==J||t[117]!==Y||t[118]!==He?(Ue=(0,$.jsxs)(`div`,{ref:s,className:`yuri-hold-to-talk-container`,"data-hold-to-talk-empty":J,children:[Y,He]}),t[116]=J,t[117]=Y,t[118]=He,t[119]=Ue):Ue=t[119],Ue};function ot(e){return{start:e.start,end:e.end,priority:103,...y(e)}}function st(e,t){return(0,$.jsx)(`span`,{className:e.className,children:e.visual?(0,$.jsx)(we,{visual:e.visual,text:e.text}):e.text},`${t}-${e.text.length}`)}var ct=`rounded-[1.35rem] border border-border/40 cursor-zoom-in`;function lt({assistantID:e,descriptor:t,onShowPopup:n}){let{t:r}=ee(),i=ze(),{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=Ie(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=k(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=k(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)(Ve,{className:`h-[var(--yuri-content-image-height)] w-[min(20rem,100%)] rounded-[1.35rem]`}):(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)(F,{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}=ee(),a=/^(?:https?:|data:|blob:)/i.test(n.url)?n.url:``,o=Be(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=k(d);if(Ie(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)(F,{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)(F,{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=ze(),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:l}=e,{t:d}=ee(),p;t[0]===d?p=t[1]:(p=d(`assistants.contact.sendError.viewDetails`),t[0]=d,t[1]=p);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(J,{name:`exclamation-fill`,className:`size-[18px] text-[var(--status-error)]`,"data-assistant-contact-error-dot":``}),t[2]=m):m=t[2];let h;t[3]===p?h=t[4]:(h=(0,$.jsx)(s,{type:`button`,"aria-label":p,"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:m}),t[3]=p,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]===d?_=t[7]:(_=d(`assistants.contact.sendError.title`),t[6]=d,t[7]=_);let v;t[8]===_?v=t[9]:(v=(0,$.jsx)(i,{className:`typography-ui-label font-medium`,children:_}),t[8]=_,t[9]=v);let y;t[10]!==d||t[11]!==n.error?(y=n.error||d(`assistants.contact.sendFailed`),t[10]=d,t[11]=n.error,t[12]=y):y=t[12];let b;t[13]===y?b=t[14]:(b=(0,$.jsx)(f,{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]!==l||t[16]!==n.messageID?(x=()=>l(n.messageID),t[15]=l,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]===d?C=t[20]:(C=d(`chat.history.retry`),t[19]=d,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)(F,{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)(c,{children:(0,$.jsx)(u,{side:`left`,align:`center`,sideOffset:6,collisionPadding:12,collisionAvoidance:g,className:`z-50`,children:(0,$.jsxs)(a,{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)(o,{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}var mt=[],ht=e=>e.flatMap(e=>e.type===`text`&&e.text.trim()?[e.text]:[]).join(`
3
- `),gt=(e,t,n,r=Date.now())=>({assistantID:e,messageID:t,parts:n,status:`sending`,createdAt:r}),_t=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},vt=(e,t)=>{let n=e.filter(e=>e.assistantID===t);return n.length===e.length?e:n},yt=(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:[]}),bt=(e,t,n)=>{let r=e.bubbles.filter(e=>!t.has(e.bubbleIndex)).map((t,r)=>yt(e,t,n+r,t.done?`complete`:`streaming`));return e.status===`failed`?[...r,yt(e,null,n+r.length,`failed`)]:e.status===`admitted`||e.status===`streaming`?[...r,yt(e,null,n+r.length,`admitted`)]:r},xt=(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:ht(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=bt(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)},St=(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},Ct=(e,t)=>e.map(e=>e.messageID===t?{...e,status:`admitted`}:e),wt=(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}]},Tt=(e,t,n)=>!t?.turnID||!t.assistantID||n?.has(t.turnID)?e:wt(e,t.assistantID,t.turnID,t.admittedAt),Et=(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=Tt(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=Ot(u,{assistantID:n,turnID:e.turnID,status:`error`,error:e.text||`upstream_error`,occurredAt:s})));if(u=kt(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},Dt=(e,t)=>wt(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}}),Ot=(e,t,n={})=>n.requireExisting&&!e.some(e=>e.assistantID===t.assistantID&&e.turnID===t.turnID)?e:wt(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}:{}}),kt=(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},At=(e,t,n)=>e.map(e=>e.messageID===t?{...e,status:`failed`,error:n}:e),jt=(e,t)=>e instanceof V?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})`:L(e)?t.timedOut:e instanceof Error&&e.message.trim()?e.message:t.sendFailed,Mt=()=>{let e=!1;return{tryAcquire:()=>!e&&(e=!0,!0),release:()=>{e=!1}}},Nt=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:gt(e.assistantID,r,n,e.createdAt)}},Pt=e=>e.some(e=>e.status===`sending`),Ft=e=>e.some(e=>e.status===`admitted`||e.status===`streaming`),It=r(e=>({workingByID:{},setWorking:(t,n)=>e(e=>({workingByID:{...e.workingByID,[t]:n}}))})),Lt=({sending:e=!1,processing:t=!1,serverWorking:n=!1})=>e||t||n,Rt=(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=It(i),o;return n[2]!==a||n[3]!==r?(o=Lt({processing:a,serverWorking:r}),n[2]=a,n[3]=r,n[4]=o):o=n[4],o},zt=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}=ee(),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 _=It(g),v=!!(o||_),y=`calc(${f}px * var(--dpt-n, 1))`,b;t[3]===c?b=t[4]:(b=P(`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)(pe,{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 Bt(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 Vt=Q.createContext(null),Ht=[`grid h-[148px] w-[19rem] min-w-0 max-w-full shrink-0 grid-rows-[40px_20px_20px_48px] content-start cursor-pointer rounded-[1.35rem] bg-[var(--surface-muted)]`,`px-4 py-2.5 text-left typography-ui-label transition-colors duration-150 motion-reduce:transition-none`,`hover:bg-interactive-hover/45`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)]`].join(` `),Ut=Ht,Wt=Ht,Gt=`row-start-1 mb-2 flex h-8 min-w-0 items-center gap-2`,Kt=`row-start-2 min-w-0 self-start truncate font-medium leading-5 text-foreground`,qt=`row-start-4 flex h-12 min-w-0 flex-col justify-center`;function Jt(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}var Yt=e=>{let t=(0,Z.c)(36),{card:n,assistant:r,active:i}=e,a=i===void 0||i,{t:o}=ee(),s=_e(),c;t[0]===s?c=t[1]:(c=s&&!D(),t[0]=s,t[1]=c);let l=!!c,u=n.name,d=`${n.providerID}/${n.modelID}`,f=Q.useContext(Vt),p;t[2]!==n.assistantID||t[3]!==l||t[4]!==f?(p=()=>{if(f)return f({assistantID:n.assistantID});if(l){ue.getState().openAssistant(n.assistantID);return}de(n.assistantID)},t[2]=n.assistantID,t[3]=l,t[4]=f,t[5]=p):p=t[5];let m=k(p),h;t[6]===m?h=t[7]:(h=e=>{Jt(e,m)},t[6]=m,t[7]=h);let g=k(h),_;t[8]!==o||t[9]!==u?(_=o(`assistants.contact.card.assistant.aria`,{name:u}),t[8]=o,t[9]=u,t[10]=_):_=t[10];let v=r?.avatarSeed,y=a?!!(r?.working||r?.activeContactTurn):void 0,b;t[11]!==n.assistantID||t[12]!==v||t[13]!==y?(b=(0,$.jsx)(`span`,{className:`relative inline-block shrink-0 leading-none`,"aria-hidden":!0,children:(0,$.jsx)(zt,{name:n.assistantID,avatarSeed:v,size:32,working:y,showWorkingDot:!1,followPointer:!1})}),t[11]=n.assistantID,t[12]=v,t[13]=y,t[14]=b):b=t[14];let x;t[15]===o?x=t[16]:(x=o(`assistants.contact.card.assistant.label`),t[15]=o,t[16]=x);let S;t[17]===x?S=t[18]:(S=(0,$.jsx)(`span`,{className:`min-w-0 truncate text-[0.8em] leading-4 text-muted-foreground`,children:x}),t[17]=x,t[18]=S);let C;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(J,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[19]=C):C=t[19];let w;t[20]!==S||t[21]!==b?(w=(0,$.jsxs)(`div`,{className:Gt,children:[b,S,C]}),t[20]=S,t[21]=b,t[22]=w):w=t[22];let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=P(Kt,`row-span-2 self-center`),t[23]=T):T=t[23];let E;t[24]===u?E=t[25]:(E=(0,$.jsx)(`h3`,{className:T,title:u,children:u}),t[24]=u,t[25]=E);let O;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(O=P(qt,`justify-end pb-1`),t[26]=O):O=t[26];let A;t[27]===d?A=t[28]:(A=(0,$.jsx)(`div`,{className:O,children:(0,$.jsx)(`div`,{className:`flex h-4 min-w-0 items-center`,children:(0,$.jsx)(Bt,{value:d})})}),t[27]=d,t[28]=A);let j;return t[29]!==g||t[30]!==m||t[31]!==w||t[32]!==E||t[33]!==A||t[34]!==_?(j=(0,$.jsxs)(`article`,{className:Ut,role:`button`,tabIndex:0,"aria-label":_,"data-assistant-contact-card":`assistant`,onClick:m,onKeyDown:g,children:[w,E,A]}),t[29]=g,t[30]=m,t[31]=w,t[32]=E,t[33]=A,t[34]=_,t[35]=j):j=t[35],j},Xt=e=>!!(e&&typeof e==`object`&&!Array.isArray(e)),Zt=e=>typeof e==`string`&&/^([01]\d|2[0-3]):[0-5]\d$/.test(e),Qt=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0&&e<=6,$t=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,en=e=>{if(!Xt(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)&&Zt(e.time);let t=Array.isArray(e.times)&&e.times.length>0&&e.times.every(Zt);return e.kind===`daily`?t||Zt(e.time):e.kind===`weekly`&&(t||Zt(e.time))&&Array.isArray(e.weekdays)&&e.weekdays.length>0&&e.weekdays.every(Qt)},tn=(e,t)=>{if(!$t(e)||!en(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}},nn=(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(Zt))].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(Qt))].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}},rn=e=>{let t=(0,Z.c)(44),{card:n,task:r}=e,{t:i}=ee(),a=n.name,o;t[0]!==n||t[1]!==i||t[2]!==r?(o=nn(tn(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(Vt),d;t[6]!==n.projectID||t[7]!==n.taskID||t[8]!==u?(d=()=>{if(u)return u({projectID:n.projectID,taskID:n.taskID});Y(n.projectID,n.taskID)},t[6]=n.projectID,t[7]=n.taskID,t[8]=u,t[9]=d):d=t[9];let f=k(d),p;t[10]===f?p=t[11]:(p=e=>{Jt(e,f)},t[10]=f,t[11]=p);let m=k(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:Gt,children:[v,y]}),t[21]=v,t[22]=b);let x;t[23]===a?x=t[24]:(x=(0,$.jsx)(`h3`,{className:Kt,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=P(qt,`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:Ut,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},an=(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`,on=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,sn=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`,cn=e=>e.split(/[/\\]/u).filter(Boolean).at(-1)||e,ln=e=>{let t=(0,Z.c)(57),{card:n}=e,{t:r}=ee(),i=_e(),a;t[0]===i?a=t[1]:(a=i&&!D(),t[0]=i,t[1]=a);let o=!!a,s;t[2]===n.sessionID?s=t[3]:(s=e=>e.activeSessions.find(e=>e.id===n.sessionID)??e.archivedSessions.find(e=>e.id===n.sessionID)??null,t[2]=n.sessionID,t[3]=s);let c=G(s),l=K(n.sessionID),u=(typeof c?.title==`string`&&c.title.trim()?c.title.trim():null)||n.title||r(`assistants.contact.card.session.untitled`),d=an(l?.type,n.status),f=on(d),m;t[4]!==n.directory||t[5]!==c?(m=typeof c?.directory==`string`&&c.directory.trim()?c.directory.trim():n.directory,t[4]=n.directory,t[5]=c,t[6]=m):m=t[6];let h=m,g;t[7]===h?g=t[8]:(g=cn(h),t[7]=h,t[8]=g);let _=g,v=ce(h).data?.current?.trim()||null,y;t[9]===c?y=t[10]:(y=Ee(c),t[9]=c,t[10]=y);let b=y,x=d===`complete`||d===`idle`?ye(c):null,S=Q.useContext(Vt),C;t[11]!==n.directory||t[12]!==n.sessionID||t[13]!==o||t[14]!==S?(C=()=>{let e=Oe(n.sessionID)?.directory||n.directory;if(S)return S({sessionId:n.sessionID,directory:e});W(n.sessionID,e,{phoneShell:o,switchToChat:!0}),o||p.getState().setActiveMainTab(`chat`)},t[11]=n.directory,t[12]=n.sessionID,t[13]=o,t[14]=S,t[15]=C):C=t[15];let w=k(C),T;t[16]===w?T=t[17]:(T=e=>{Jt(e,w)},t[16]=w,t[17]=T);let E=k(T),O=Wt,A=r(`assistants.contact.card.session.aria`,{title:u}),j;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(J,{name:`chat-thread`,weight:`medium`,className:`size-4 shrink-0`}),t[18]=j):j=t[18];let M;t[19]===r?M=t[20]:(M=r(`assistants.contact.card.session.label`),t[19]=r,t[20]=M);let N;t[21]===M?N=t[22]:(N=(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 text-[0.8em] leading-4 text-muted-foreground`,children:[j,(0,$.jsx)(`span`,{className:`truncate`,children:M})]}),t[21]=M,t[22]=N);let F=f?(0,$.jsxs)(`span`,{"data-assistant-session-status":``,className:P(`ml-auto inline-flex shrink-0 items-center gap-1.5 whitespace-nowrap text-[0.75em] leading-4`,sn(d)),children:[(0,$.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`,"aria-hidden":!0}),r(f)]}):null,te;t[23]!==N||t[24]!==F?(te=(0,$.jsxs)(`div`,{className:Gt,children:[N,F]}),t[23]=N,t[24]=F,t[25]=te):te=t[25];let I;t[26]===u?I=t[27]:(I=(0,$.jsx)(`h3`,{className:Kt,title:u,children:u}),t[26]=u,t[27]=I);let L=P(`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 R;t[29]===_?R=t[30]:(R=(0,$.jsx)(`span`,{className:`min-w-0 truncate`,children:_}),t[29]=_,t[30]=R);let re;t[31]!==h||t[32]!==L||t[33]!==R?(re=(0,$.jsxs)(`p`,{className:L,title:h,children:[ne,R]}),t[31]=h,t[32]=L,t[33]=R,t[34]=re):re=t[34];let z;t[35]===v?z=t[36]:(z=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]=z);let B;t[37]!==re||t[38]!==z?(B=(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,z]}),t[37]=re,t[38]=z,t[39]=B):B=t[39];let V=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,ie;t[40]===b?ie=t[41]:(ie=b?(0,$.jsx)(Bt,{value:b}):null,t[40]=b,t[41]=ie);let H;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(J,{name:`arrow-right-s`,weight:`medium`,className:`ml-auto size-4 shrink-0 text-muted-foreground`}),t[42]=H):H=t[42];let U;t[43]===ie?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:[ie,H]}),t[43]=ie,t[44]=U);let ae;t[45]!==B||t[46]!==V||t[47]!==U?(ae=(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:[B,V,U]}),t[45]=B,t[46]=V,t[47]=U,t[48]=ae):ae=t[48];let oe;return t[49]!==E||t[50]!==w||t[51]!==A||t[52]!==te||t[53]!==I||t[54]!==ae||t[55]!==O?(oe=(0,$.jsxs)(`article`,{className:O,role:`button`,tabIndex:0,"aria-label":A,"data-assistant-contact-card":`session`,onClick:w,onKeyDown:E,children:[te,I,ae]}),t[49]=E,t[50]=w,t[51]=A,t[52]=te,t[53]=I,t[54]=ae,t[55]=O,t[56]=oe):oe=t[56],oe},un=3e5,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)||e.getTime()-n.getTime()>un)&&t.set(r.messageID,r.createdAt),n=e)}return t}function pn(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 mn=2,hn=1500,gn=e=>({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight}),_n=e=>e.scrollHeight-e.scrollTop-e.clientHeight,vn=e=>_n(e)<=mn,yn=(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},bn=e=>e.altKey||e.ctrlKey||e.metaKey?!1:e.key===`ArrowDown`||e.key===`PageDown`||e.key===`End`,xn=({active:e,assistantID:t,contentRevision:n,onLoadEarlier:r})=>{let i=Q.useRef(null),[a,o]=Q.useState(null),[s,c]=Q.useState(null),l=Q.useRef(!0),u=Q.useRef(null),d=Q.useRef(null),f=Q.useRef(null),p=Q.useRef(0),m=Q.useRef(null),h=Q.useRef(null),g=Q.useRef(e);g.current=e;let _=he(),v=Q.useRef(!1),y=Q.useRef(null),b=Q.useRef(null),x=k(()=>{y.current?.stop(),y.current=null,b.current=null}),S=Q.useMemo(()=>e=>{i.current=e,o(t=>t===e?t:e)},[]),C=Q.useMemo(()=>e=>{c(t=>t===e?t:e)},[]),w=k(()=>{let e=i.current;if(!e||!g.current||l.current)return;let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.getBoundingClientRect().bottom>t);u.current=n?{id:n.dataset.messageId,offset:n.getBoundingClientRect().top-t,scrollTop:e.scrollTop}:null}),T=k(()=>{let e=i.current,t=u.current;if(!e||!g.current||l.current)return;if(!t){w();return}let n=e.scrollTop-t.scrollTop;if(Math.abs(n)>.5&&m.current){p.current=e.scrollTop,w();return}let r=Array.from(e.querySelectorAll(`[data-message-id]`)).find(e=>e.dataset.messageId===t.id);if(!r){w();return}let a=r.getBoundingClientRect().top-e.getBoundingClientRect().top-(t.offset-n);Math.abs(a)>.5&&(e.scrollTop+=a),p.current=e.scrollTop,u.current={id:t.id,offset:r.getBoundingClientRect().top-e.getBoundingClientRect().top,scrollTop:e.scrollTop}}),E=k(()=>{x(),l.current=!1,p.current=i.current?.scrollTop??0,w()}),D=Q.useRef(null),j=k(e=>{let t=i.current;!g.current||!t||(D.current=e??null,l.current=!0,u.current=null,h.current=null,p.current=t.scrollTop)}),M=k(()=>{if(!g.current||!l.current)return!1;let e=i.current;if(!e)return!1;let t=gn(e),n=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));if(t.scrollTop<n-.5)return x(),l.current=!1,p.current=t.scrollTop,w(),!1;let r=!v.current;if(r&&e.querySelector(`[data-message-id]`)&&(v.current=!0),vn(t))return x(),p.current=t.scrollTop,!1;let a=Math.max(0,t.scrollHeight-t.clientHeight);if(!r&&!_){if(b.current===a)return!1;x(),b.current=a;let t=D.current;return D.current=null,y.current=q(e.scrollTop,a,{duration:t?.duration??.22,ease:t?[...t.ease]:`easeOut`,onUpdate:t=>{if(!g.current||!l.current||i.current!==e)return;let n=Math.max(0,e.scrollHeight-e.clientHeight);if(e.scrollTop<Math.min(p.current,n)-.5){l.current=!1,x(),p.current=e.scrollTop,w();return}e.scrollTop=Math.min(Math.max(e.scrollTop,t),n),p.current=e.scrollTop},onComplete:()=>{y.current=null,b.current=null}}),!0}return x(),e.scrollTop=a,p.current=e.scrollTop,!0}),N=k(e=>{h.current={direction:e,expiresAt:performance.now()+hn}}),ee=k(()=>{let e=h.current;return e?performance.now()>e.expiresAt?(h.current=null,null):e.direction:null}),P=k(()=>{x(),l.current=!1,w()}),F=k(()=>{if(!g.current)return;let e=i.current;if(!e)return;let t=gn(e),n=t.scrollTop>p.current,a=Math.min(p.current,Math.max(0,t.scrollHeight-t.clientHeight));if(p.current=t.scrollTop,l.current){t.scrollTop<a-.5&&P();return}let o=ee();T(),t.scrollTop<=80&&o===`up`&&r?.(),n&&vn(t)&&(o===`down`||o===`scrollbar`)&&(l.current=!0)}),te=k(e=>{let t=i.current;if(!(!t||e.deltaY===0)){if(e.deltaY<0){if(X(t,e.target))return;N(`up`),P(),t.scrollTop<=80&&r?.();return}yn(t,e.target)||N(`down`)}}),I=k(e=>{h.current=null;let t=e.touches.item(0);m.current=t?{x:t.clientX,y:t.clientY,deltaX:0,deltaY:0}:null}),L=k(e=>{let t=i.current,n=e.touches.item(0);if(!t||!n){m.current=null;return}let a=m.current;if(!a)return;let o=n.clientY-a.y,s=o*a.deltaY<0,c=(s?0:a.deltaX)+n.clientX-a.x,l=(s?0:a.deltaY)+o;if(m.current={x:n.clientX,y:n.clientY,deltaX:c,deltaY:l},!(Math.abs(c)>=Math.abs(l))){if(l>0&&X(t,e.target)||l<0&&yn(t,e.target)){m.current.deltaX=0,m.current.deltaY=0;return}N(l>0?`up`:`down`),l>2&&(P(),t.scrollTop<=80&&r?.())}}),ne=k(()=>{m.current=null}),R=k(e=>{if(Se(e)){N(`up`),P(),(i.current?.scrollTop??1/0)<=80&&r?.();return}bn(e)&&N(`down`)}),re=k(e=>{let t=i.current;e.pointerType===`mouse`&&e.target===t&&N(`scrollbar`)});Q.useLayoutEffect(()=>{let n=e?t:null,r=i.current;(d.current!==n||f.current!==r)&&(x(),v.current=!1,d.current=n,f.current=r,l.current=!0,u.current=null,h.current=null,m.current=null,p.current=r?.scrollTop??0),e&&(M(),T())},[e,t,n,a,_]),Q.useLayoutEffect(()=>()=>{x()},[e,t,a,x]);let z=Q.useMemo(()=>()=>void 0,[]),B=e&&a?a:z,V=Q.useMemo(()=>({passive:!0}),[]);O(`scroll`,F,B,V),O(`wheel`,te,B,V),O(`touchstart`,I,B,V),O(`touchmove`,L,B,V),O(`touchend`,ne,B,V),O(`touchcancel`,ne,B,V),O(`keydown`,R,B),O(`pointerdown`,re,B,V);let ie=k(()=>{M(),T()});return A(typeof ResizeObserver<`u`&&e?s:null,ie),{scrollRef:S,contentRef:C,preparePrepend:E,followLatest:j}},Sn=.3,Cn=[.19919472913616398,.010644531250000006,.27920937042459737,.91025390625],wn=[.23,1,.32,1],Tn=me(...Cn),En=me(...wn),Dn=.15,On=.1,kn=.08,An=e=>({left:e.left,top:e.top,width:e.width,height:e.height}),jn=e=>Number.parseFloat(e)||0,Mn=(e,t,n)=>e+(t-e)*n,Nn=e=>[e.borderTopLeftRadius,e.borderTopRightRadius,e.borderBottomRightRadius,e.borderBottomLeftRadius],Pn=e=>{let t=e.getBoundingClientRect(),n=window.getComputedStyle(e),r=t.left+jn(n.borderLeftWidth)+jn(n.paddingLeft),i=t.top+jn(n.borderTopWidth)+jn(n.paddingTop);return{left:r,top:i,width:t.right-jn(n.borderRightWidth)-jn(n.paddingRight)-r,height:t.bottom-jn(n.borderBottomWidth)-jn(n.paddingBottom)-i}},Fn=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`}),In=(e,t,n=!1)=>{if(!t.value.trim())return null;let r=window.getComputedStyle(e),i=Pn(t),a=t.parentElement?.querySelector(`[data-composer-highlight]`),o=Fn(window.getComputedStyle(t));return a&&(o.color=window.getComputedStyle(a).color),{compact:n,background:An(e.getBoundingClientRect()),backgroundColor:r.backgroundColor,radii:Nn(r),text:t.value,textBox:{...i,top:i.top-t.scrollTop},textStyle:o}},Ln=e=>{let t=document.createElement(`div`);return Object.assign(t.style,{position:`absolute`,pointerEvents:`none`,margin:`0px`,...e}),t},Rn=(e,t,n,r)=>(e.style.opacity=String(t),q(e,{opacity:[t,n]},{duration:r,ease:`linear`})),zn=(e,t,n=t,r)=>{let i=window.getComputedStyle(t),a=Nn(i),o=An(t.getBoundingClientRect()),s=Pn(t),c=e.compact?{...e.background,left:e.textBox.left-jn(i.paddingLeft),width:Math.min(e.background.width,Math.max(120,o.width+32))}:e.background,l={left:c.left,top:c.top+c.height-o.height},u={x:e.textBox.left-l.left-(s.left-o.left),y:e.textBox.top-l.top-(s.top-o.top)},d=Ln({position:`fixed`,left:`0px`,top:`0px`,overflow:`hidden`,zIndex:`60`,willChange:`transform, width, height`});d.setAttribute(`aria-hidden`,`true`),d.setAttribute(`data-assistant-contact-send-flight`,``),d.style.backgroundColor=e.backgroundColor;let f=Ln({...e.textStyle,left:`0px`,top:`0px`,width:`${e.textBox.width}px`});f.textContent=e.text;let p=Ln({...Fn(i),left:`0px`,top:`0px`,width:`${s.width}px`});p.textContent=t.textContent??``,d.append(f,p);let m=n=>{let r=Tn(n),i=En(n),m=An(t.getBoundingClientRect()),h=c,g=Mn(h.left,m.left,i),_=Mn(h.left+h.width,m.left+m.width,i),v=Mn(h.top+h.height,m.top+m.height,r),y=Mn(h.height,m.height,r),b=v-y;d.style.transform=`translate3d(${g}px, ${b}px, 0)`,d.style.width=`${_-g}px`,d.style.height=`${y}px`,d.style.borderRadius=a.map((t,n)=>`${Mn(jn(e.radii[n]),jn(t),r)}px`).join(` `);let x=m.left+(l.left-o.left)*(1-i),S=m.top+(l.top-o.top)*(1-r),C=`translate3d(${x+(s.left-o.left)+u.x*(1-r)-g}px, ${S+(s.top-o.top)+u.y*(1-r)-b}px, 0)`;f.style.transform=C,p.style.transform=C},h=!1,g=[],_=()=>{h||(h=!0,g.forEach(e=>e.stop()),d.remove(),n.style.visibility=``,r?.())};return n.style.visibility=`hidden`,m(0),document.body.appendChild(d),g.push(q(d,{backgroundColor:[e.backgroundColor,i.backgroundColor]},{duration:Dn,ease:`linear`}),Rn(f,1,0,On),Rn(p,0,1,kn),q(0,1,{duration:Sn,ease:`linear`,onUpdate:m,onComplete:_})),_},Bn=64,Vn=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)},Hn=e=>Array.from(e?.files||[]),Un=async(e,t=m)=>{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}},Wn=(e,t)=>{let n=[...e,...t];for(let e of n.slice(Bn))e.url.startsWith(`blob:`)&&URL.revokeObjectURL(e.url);return n.slice(0,Bn)},Gn=Le(()=>T(()=>import(`./ToolOutputDialog-CMYmDCR4.js`),__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]))),Kn=e=>e.trim().startsWith(`yuri.settle.`)||e.trim().startsWith(`oc.settle.`),qn=e=>e.status===`error`||e.status===`failed`&&e.messageID.endsWith(`:preview:failed`),Jn=e=>e.role===`assistant`&&e.status!==`error`&&e.parts.some(e=>e.type===`text`)?`${e.turnID}:assistant:${e.bubbleIndex}`:e.messageID,Yn=({assistant:e,warning:t,active:n,overlayHeader:r=!1})=>{let{t:i,locale:a}=ee(),o=ze(),s=p(e=>e.isMobile),c=B(),l=ae(),u=z(e.id,n),d=p(e=>e.isSettingsDialogOpen),f=n&&!d&&!u.hasMessageGap?oe(e,u.data):null,h=te(e.name).displayName||e.name,g=(e,t)=>{let n=e?l.data?.assistants.find(t=>t.id===e):void 0;return n?te(n.name).displayName||n.name:t||i(`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,o]);let w=Q.useRef(new Set),[T,E]=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,T]),Q.useEffect(()=>()=>{for(let e of w.current)URL.revokeObjectURL(e)},[]);let[D,O]=Q.useState([]),[A,j]=Q.useState(null),[M,N]=Q.useState({open:!1,title:``,content:``}),L=p(e=>e.setImagePreviewOpen),ne=k(e=>{(e.image||e.mermaid||e.video)&&(N(e),L(!0))}),ie=k(e=>{N(t=>({...t,open:e})),L(e)});Q.useEffect(()=>()=>{L(!1)},[L]),Q.useEffect(()=>{S.current.clear(),x.current.clear(),E([]),O([]),j(null)},[o]);let U=Q.useMemo(()=>Mt(),[]),W=Q.useRef(new Set),G=Q.useRef(new Map),ce=It(e=>e.setWorking),K=u.data?.messages??mt,le=Q.useMemo(()=>K.some(e=>e.parts.some(e=>e.type===`card`&&e.cardType===`schedule`&&$t(e))),[K]),ue=R(e.id,n&&le),de=Q.useMemo(()=>{let e=new Map;for(let t of ue.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},[ue.data]),fe=_t(T,e.id),pe=vt(D,e.id),me=xt(K,fe,e.id,pe).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`&&Kn(e.text)))}),q=me.length-1;for(;q>=0&&qn(me[q]);)--q;let Y=me.filter((e,t)=>!qn(e)||t>q),ge=fn(Y),_e=he(),ve=`${o}:${e.id}`,ye=Q.useRef(null),be=ye.current,xe=be?.lastID?Y.findIndex(e=>Jn(e)===be.lastID):-1,Se=n&&!_e&&be?.scope===ve&&be.ready&&(be.lastID===null||xe>=0);Q.useLayoutEffect(()=>{let e=Y.at(-1);ye.current={scope:ve,ready:n&&u.isSuccess,lastID:e?Jn(e):null}});let Ce=new Date().toDateString(),we=i(`common.date.today`),Te=Q.useMemo(()=>pn(a,we,new Date(Ce)),[a,we,Ce]),X=Pt(fe),Ee=Ft(pe),De=!!(e.working||e.activeContactTurn),Oe=l.data?.revision??null,ke=pe.reduce((e,t)=>e+t.bubbles.reduce((e,t)=>e+t.text.length,0),0),Ae=new Map(pe.map(e=>[e.turnID,e])),je=Q.useRef(!1),Me=k(async(e=!1)=>{if(!(!n||je.current||u.isFetchingPreviousPage||u.isFillingMessageGap)&&!(e&&u.previousPageError)&&!(!u.hasPreviousPage&&!u.hasMessageGap)){je.current=!0,Fe();try{u.hasMessageGap?await u.retryMessageGap():await u.fetchPreviousPage()}catch{}finally{je.current=!1}}}),{scrollRef:Ne,contentRef:Pe,preparePrepend:Fe,followLatest:Ie}=xn({active:n,assistantID:e.id,contentRevision:`${Y[0]?.messageID}:${Y.length}:${ke}:${u.isFetchingPreviousPage}:${u.hasPreviousPage}:${u.isFillingMessageGap}`,onLoadEarlier:()=>{Me(!0)}}),Le=Q.useRef(null),Be=Q.useRef(null),Ve=Q.useRef(null),He=Q.useRef(null),Ue=Q.useRef(null),[Ke,qe]=Q.useState(null),Z=()=>{let e=Be.current?.querySelector(`[data-assistant-contact-composer-surface]`),t=e?.querySelector(`textarea`);return e&&t?In(e,t,!s):null};Q.useLayoutEffect(()=>{let e=Ve.current;if(!e)return;Ve.current=null;let t=Array.from(Le.current?.querySelectorAll(`[data-message-id]`)??[]).find(t=>t.dataset.messageId===e.messageID)?.querySelector(`[data-assistant-contact-text]`),n=()=>qe(t=>t?.messageID===e.messageID?null:t);if(!t){n();return}Ue.current?.(),Ue.current=zn(e.source,t,t,n)}),Q.useEffect(()=>()=>{Ve.current=null,Ue.current?.(),Ue.current=null},[n,e.id,o]),Q.useEffect(()=>{j(null),x.current.clear(),S.current.clear(),W.current.clear(),G.current=new Map,E(t=>_t(t,e.id)),O(t=>vt(t,e.id)),N({open:!1,title:``,content:``}),L(!1)},[e.id,L]),Q.useEffect(()=>{for(let e of K){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)}}E(e=>St(e,K))},[K]),Q.useEffect(()=>{let t=new Set(fe.filter(e=>e.status===`sending`).map(e=>e.messageID));O(n=>Et(n,{assistantID:e.id,activeContactTurn:e.activeContactTurn?{turnID:e.activeContactTurn.turnID,admittedAt:e.activeContactTurn.admittedAt}:null,serverWorking:De,snapshotRevision:Oe,admissionRevisionByTurnID:G.current,pendingSendTurnIDs:t,messages:K,settledTurnIDs:W.current}))},[e.activeContactTurn,e.id,K,fe,De,Oe]),Q.useEffect(()=>{ce(e.id,X||Ee||De)},[e.id,Ee,X,De,ce]),Q.useEffect(()=>{let t=e.id;return()=>{ce(t,!1)}},[e.id,ce]);let Ye=k(t=>{if(!(!(`assistantID`in t)||t.assistantID!==e.id)){if(t.type===`contact-turn-start`){W.current.delete(t.turnID),O(e=>wt(e,t.assistantID,t.turnID,t.occurredAt));return}if(t.type===`contact-bubble-delta`){if(W.current.has(t.turnID))return;O(e=>Dt(e,t));return}t.type===`contact-turn-end`&&(W.current.add(t.turnID),O(e=>kt(Ot(e,t,{requireExisting:!0}),K)))}});Q.useEffect(()=>{if(n)return se(Ye)},[n,e.id]);let Xe=k(async e=>{if(X)return;let t=C.current,n=await Un(e);if(t.signal.aborted){n.attachments.forEach(e=>URL.revokeObjectURL(e.url));return}n.skippedTooLarge>0&&j(i(`assistants.contact.attachment.tooLarge`)),n.attachments.length!==0&&b(e=>Wn(e,n.attachments))}),Ze=k(e=>{let t=Vn(e.clipboardData);t.length!==0&&(e.preventDefault(),Xe(t))}),Qe=k(e=>{Array.from(e.dataTransfer?.types??[]).includes(`Files`)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)}),$e=k(e=>{let t=Hn(e.dataTransfer);t.length!==0&&(e.preventDefault(),Xe(t))}),et=k(async(t,r)=>{let a=C.current,o=e.id,s=r?x.current.get(r):void 0;if(r&&(!s||s.assistantID!==o))return;let l=s?.text??t??_,u=s?.attachments??y,d=Nt({gate:U,sending:Pt(fe),text:l,attachments:u,assistantID:o,createMessageID:()=>r||`yuri_contact_${m()}`});if(!d.ok)return;ce(o,!0),x.current.set(d.messageID,{assistantID:o,text:l,attachments:u});let f=u.length===0&&t===void 0&&!r&&n&&!_e?Z():null;Ve.current=f?{messageID:d.messageID,source:f}:null,qe(f?{scope:ve,messageID:d.messageID}:null),He.current=f?d.messageID:He.current,r||(Ie(f?{duration:Sn,ease:Cn}:void 0),v(e=>e===l?``:e),b(e=>e.filter(e=>!u.includes(e)))),E(e=>e.some(e=>e.messageID===d.messageID)?e.map(e=>e.messageID===d.messageID?{...d.turn,createdAt:e.createdAt}:e):[...e,d.turn]),j(null);let p=()=>{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,a.signal),a.signal.aborted)return;S.current.set(n,r)}t.push(r)}if(a.signal.aborted)return;let n=[...d.parts.filter(e=>e.type===`text`),...t];E(e=>e.map(e=>e.messageID===d.messageID?{...e,parts:n}:e));let r=await re(o,d.messageID,{parts:n});if(a.signal.aborted)return;p(),typeof r.revision==`number`&&G.current.set(d.messageID,r.revision),E(e=>Ct(e,d.messageID)),W.current.has(d.messageID)||O(e=>wt(e,o,d.messageID)),c.data?.serverInstanceID&&I({serverInstanceID:c.data.serverInstanceID,assistantID:o,name:h,avatarSeed:e.avatarSeed??o}).catch(()=>void 0)}catch(e){if(a.signal.aborted)return;if(e instanceof V&&e.code===`admission_timeout`)try{let e=await H(o,d.messageID);if(a.signal.aborted)return;if(e){p(),typeof e.revision==`number`&&G.current.set(d.messageID,e.revision),E(e=>Ct(e,d.messageID)),W.current.has(d.messageID)||O(e=>wt(e,o,d.messageID));return}}catch{}let t=jt(e,{noProvider:i(`assistants.contact.noProvider`),sendFailed:i(`assistants.contact.sendFailed`),timedOut:i(`assistants.contact.timedOut`)});E(e=>At(e,d.messageID,t))}finally{U.release()}}),tt=k(e=>{et(void 0,e)}),nt=u.isError&&Y.length===0,rt=u.isSuccess&&Y.length===0,it=new Map(fe.map(e=>[e.messageID,e]));return(0,$.jsxs)(`div`,{ref:Le,className:`flex min-h-0 flex-1 flex-col bg-background`,children:[(0,$.jsxs)(`div`,{ref:Ne,className:P(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-4 sm:px-8`,s&&`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,nt?(0,$.jsxs)(`div`,{ref:Pe,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)(zt,{name:e.id,avatarSeed:e.avatarSeed,size:44,label:h,working:n?De: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:h}),(0,$.jsx)(`p`,{className:`mt-1.5 typography-ui leading-6 text-muted-foreground`,children:i(`assistants.contact.loadFailed`)}),(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,onClick:()=>void u.refetch(),children:i(`chat.history.retry`)})]}):rt?(0,$.jsxs)(`div`,{ref:Pe,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)(zt,{name:e.id,avatarSeed:e.avatarSeed,size:48,label:h,className:`opacity-90`,working:n?De:void 0,showWorkingDot:!1,followPointer:!1}),(0,$.jsx)(`p`,{className:`mt-5 typography-ui-header font-medium tracking-[-0.01em] text-foreground`,children:i(`assistants.conversation.emptyTitle`,{name:h})}),(0,$.jsx)(`p`,{className:`mt-2 max-w-xs typography-ui leading-6 text-muted-foreground/80`,children:i(`assistants.contact.empty`)})]}):(0,$.jsxs)(`div`,{ref:Pe,className:`relative mx-auto flex w-full max-w-[42rem] flex-col pb-12`,"data-assistant-contact-content":``,children:[u.isPending?(0,$.jsx)(`p`,{role:`status`,className:`py-3 text-center typography-micro text-muted-foreground`,children:i(`common.loading`)}):null,u.hasPreviousPage||u.hasMessageGap?(0,$.jsxs)(`div`,{className:`mb-3 flex flex-col items-center gap-1`,"data-assistant-contact-pagination":``,"aria-busy":u.isFetchingPreviousPage||u.isFillingMessageGap,children:[u.previousPageError?(0,$.jsx)(`p`,{role:`alert`,className:`typography-micro text-[var(--status-error)]`,children:i(`chat.history.loadOlderFailed`)}):null,u.hasMessageGap?(0,$.jsx)(`p`,{role:`status`,className:`typography-micro text-muted-foreground`,children:i(`assistants.contact.history.gap`)}):null,(0,$.jsx)(F,{type:`button`,size:`sm`,variant:`ghost`,disabled:u.isFetchingPreviousPage||u.isFillingMessageGap,onClick:()=>void Me(),children:i(u.isFetchingPreviousPage||u.isFillingMessageGap?`chat.history.loadingMore`:u.previousPageError||u.hasMessageGap?`chat.history.retry`:`chat.history.loadOlder`)})]}):null,Y.map((t,r)=>{let a=`${ve}:${Jn(t)}`,c=r>0?Y[r-1]:null,u=ge.get(t.messageID),d=u!==void 0,p=d?(0,$.jsx)(`div`,{className:`flex w-full justify-center px-4 pt-7 pb-4 first:pt-1`,"data-assistant-contact-time":``,children:(0,$.jsx)(`time`,{dateTime:new Date(u).toISOString(),className:`text-[11px] font-normal leading-4 tabular-nums text-muted-foreground/70`,children:Te(u)})}):null,m=t.role===`user`,_=t.role===`peer`,v=t.role===`assistant`&&!d&&c?.role===`assistant`&&c.turnID===t.turnID,y=c?.turnID!==t.turnID,b=!m&&(_||!v),x=_?g(t.fromAssistantID,t.fromAssistantName):h,S=_&&t.fromAssistantID?l.data?.assistants.find(e=>e.id===t.fromAssistantID):e,C=it.get(t.messageID),w=Ae.get(t.turnID),T=t.status===`failed`&&t.messageID.endsWith(`:preview:failed`),E=(e,t)=>m?(0,$.jsx)(pt,{failedTurn:n?C:void 0,retryDisabled:X,onRetry:tt,children:e},t):e;return t.status===`error`||T?(0,$.jsxs)(Q.Fragment,{children:[p,(0,$.jsxs)(`div`,{"data-message-id":t.messageID,"data-assistant-contact-error":``,className:P(`relative px-1`,!d&&`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||w?.error||i(`assistants.contact.sendFailed`)}),f?.messageID===t.messageID?(0,$.jsx)(Je,{assistantID:e.id,position:f},`${o}:${e.id}:${f.generation}:${f.ordinal}`):null]})]},a):(0,$.jsxs)(Q.Fragment,{children:[p,(0,$.jsxs)(We.div,{"data-message-id":t.messageID,initial:Se&&r>xe&&t.messageID!==He.current?{opacity:0,y:4}:!1,animate:{opacity:1,y:0},transition:{duration:_e?0:.18,ease:`easeOut`},className:P(`flex w-full`,m?`justify-end`:`justify-start`,d?`mt-0`:y?`mt-6 first:mt-0`:v?`mt-1.5`:`mt-3`),"data-assistant-contact-role":t.role,"data-assistant-contact-turn-status":C?.status??t.status,"data-assistant-contact-run-start":t.role===`assistant`&&!v?``:void 0,children:[m?null:(0,$.jsx)(`div`,{className:`mr-2.5 flex w-9 shrink-0 justify-center pt-0.5`,children:b?(0,$.jsx)(zt,{name:S?.id||t.fromAssistantID||e.id,avatarSeed:S?.avatarSeed??(t.fromAssistantID?void 0:e.avatarSeed),size:32,label:x,working:n?!!(S?.working||S?.activeContactTurn):void 0,showWorkingDot:!1,followPointer:!1}):(0,$.jsx)(`span`,{className:`size-8`,"aria-hidden":!0})}),(0,$.jsxs)(`div`,{className:P(`relative flex min-w-0 flex-col gap-1.5`,m?`max-w-[min(82%,30rem)] items-end`:`max-w-[min(84%,34rem)] items-start`),children:[_?(0,$.jsx)(`span`,{className:`mb-0.5 px-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.peer.from`,{name:x})}):null,t.parts.map((r,o)=>{if(r.type===`card`&&r.cardType===`session`)return(0,$.jsx)(ln,{card:r},`${a}:card:${o}`);if(r.type===`card`&&r.cardType===`assistant`)return(0,$.jsx)(Yt,{card:r,assistant:l.data?.assistants.find(e=>e.id===r.assistantID),active:n},`${a}:card:${o}`);if(r.type===`card`&&r.cardType===`schedule`)return(0,$.jsx)(rn,{card:r,task:de.get(r.projectID)?.get(r.taskID)},`${a}:card:${o}`);if(r.type===`file`)return E((0,$.jsx)(dt,{assistantID:e.id,part:r,onShowPopup:ne},`${a}:file:${o}`),`${a}:file:${o}`);if(r.type===`text`&&Kn(r.text))return null;if(r.type===`text`&&(r.text.trim()||t.status===`streaming`)){let e=!m,n=e&&/^!\[(?:\\.|[^\]\\\n])*\]\(\s*(?:<[^>\n]+>|[^\s()]+)(?:\s+"[^"\n]*")?\s*\)$/.test(r.text.trim());return E((0,$.jsx)(`div`,{"aria-label":_?i(`assistants.contact.peer.aria`,{name:x}):void 0,"data-assistant-contact-text":``,"data-assistant-contact-media":n||void 0,className:P(`min-w-0 max-w-full [overflow-wrap:anywhere] rounded-[1.35rem] typography-markdown leading-6`,s&&!n&&`touch-manipulation [-webkit-user-select:all] [user-select:all]`,n?`p-0`:`px-4 py-2.5`,e?null:`whitespace-pre-wrap`,n?`text-foreground`:m?`rounded-[1.15rem] rounded-br-lg bg-[var(--primary-base)]/90 text-[var(--primary-foreground)]`:_?`rounded-[1.25rem] border border-dashed border-border/50 bg-[var(--surface-muted)]/70 text-foreground`:`bg-[var(--surface-muted)] text-foreground`),children:e?(0,$.jsx)(Re,{content:r.text,messageId:a,isAnimated:!1,isStreaming:t.status===`streaming`,variant:`assistant`,enableFileReferences:!1,onShowPopup:ne,className:`w-full min-w-0 [overflow-wrap:anywhere]`}):r.text},`${a}:text:${o}`),`${a}:text:${o}`)}return null}),C?.status===`sending`?(0,$.jsx)(`p`,{className:`absolute right-1 top-full mt-1 typography-micro text-muted-foreground/75`,children:i(`assistants.contact.sending`)}):null,f?.messageID===t.messageID?(0,$.jsx)(Je,{assistantID:e.id,position:f},`${o}:${e.id}:${f.generation}:${f.ordinal}`):null]})]})]},a)}),(0,$.jsx)(`div`,{className:`pointer-events-none absolute bottom-1 left-[2.875rem] flex h-10 items-center`,"data-assistant-contact-status-slot":``,children:!X&&Ke?.scope!==ve&&(Ee||De)?(0,$.jsxs)(We.div,{role:`status`,"aria-label":i(`assistants.contact.processing`),initial:!_e&&{opacity:0,scale:.8},animate:{opacity:1,scale:1},transition:{duration:_e?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:`absolute -left-[2.875rem] top-0.5 flex w-9 justify-center`,"data-assistant-contact-processing-avatar":``,children:(0,$.jsx)(zt,{name:e.id,avatarSeed:e.avatarSeed,size:32,label:h,working:n?De: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:Be,className:`relative z-10 shrink-0 bg-background 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:P(`relative w-full pt-1.5 pb-4`,s&&`bottom-safe-area yuri-mobile-composer`),onSubmit:e=>{e.preventDefault(),et()},onDragOver:Qe,onDrop:$e,children:(0,$.jsx)(`div`,{className:`chat-input-column relative overflow-visible`,children:(0,$.jsx)(at,{active:n,layout:`inline`,value:_,attachments:y,pending:X,isMobile:s,placeholder:i(`assistants.contact.placeholder`,{name:h}),sendLabel:i(`assistants.contact.send`),addFilesLabel:i(`assistants.contact.addFiles`),removeAttachmentLabel:i(`assistants.contact.removeAttachment`),fileAccept:`*/*`,onChange:e=>v(e),onVoiceSend:e=>{et(e)},onSubmit:()=>{et()},onAddFiles:e=>{Xe(e)},onRemoveAttachment:t=>{X||(S.current.delete(`${e.id}:${t}`),b(e=>e.filter(e=>e.id!==t)))},onPaste:Ze,onDragOver:Qe,onDrop:$e,className:P(`relative z-10`,s&&`yuri-mobile-composer-surface`),style:{borderRadius:`1.5rem`},"data-assistant-contact-composer-surface":``,textareaProps:{"aria-label":i(`assistants.contact.placeholder`,{name:h})}},`${o}:${e.id}`)})})]}),M.open?(0,$.jsx)(Q.Suspense,{fallback:null,children:(0,$.jsx)(Gn,{popup:M,onOpenChange:ie,isMobile:s})}):null]})},Xn=e=>{for(let t=e.messages.length-1;t>=0;t--){let n=e.messages[t];if(n.parts.some(ne)&&Number.isFinite(new Date(n.createdAt).getTime()))return{timestamp:n.createdAt,empty:!1}}return{timestamp:void 0,empty:e.generation>=0&&e.olderComplete&&!e.hasMessageGap}},Zn=(e,t)=>{let n=(0,Z.c)(5),r;n[0]!==e||n[1]!==t?(r=ie(e,t),n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;return n[3]===r?i=n[4]:(i={...r,enabled:!1,select:Xn},n[3]=r,n[4]=i),w(i)},Qn=Q.memo(e=>{let t=(0,Z.c)(17),{assistantID:n,serverWorking:r,lastContactAt:i}=e,{t:a,locale:o}=ee(),s=Rt(n,r),c=Zn(n,ze()),l;t[0]!==c||t[1]!==i?(l=i!==void 0&&Number.isFinite(new Date(i).getTime())?i:c.data?.timestamp,t[0]=c,t[1]=i,t[2]=l):l=t[2];let u=l,d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=new Date().toDateString(),t[3]=d):d=t[3];let f=d,p;t[4]===a?p=t[5]:(p=a(`common.date.today`),t[4]=a,t[5]=p);let m=p,h;bb0:{if(u===void 0){h=null;break bb0}let e;t[6]!==o||t[7]!==u||t[8]!==m?(e=pn(o,m,new Date(f))(u),t[6]=o,t[7]=u,t[8]=m,t[9]=e):e=t[9],h=e}let g=h,_;t[10]!==c||t[11]!==g||t[12]!==a||t[13]!==s?(_=s?a(`assistants.conversation.typing`):g?a(`assistants.conversation.lastContact`,{time:g}):c.data?.empty?a(`assistants.conversation.neverContacted`):c.isError?a(`assistants.contact.loadFailed`):a(`common.loading`),t[10]=c,t[11]=g,t[12]=a,t[13]=s,t[14]=_):_=t[14];let v=_,y;return t[15]===v?y=t[16]:(y=(0,$.jsx)(`span`,{className:`mt-1 block truncate typography-micro font-normal leading-4 text-muted-foreground/70`,"aria-live":`polite`,title:v,children:v}),t[15]=v,t[16]=y),y});export{Rt as a,zt as i,Yn as n,Vt as r,Qn as t};