@yuhuanowo/yunui 0.2.18 → 0.2.19

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 (558) hide show
  1. package/README.md +55 -6
  2. package/README.zh-CN.md +19 -5
  3. package/README.zh-TW.md +19 -5
  4. package/THIRD_PARTY_NOTICES.md +13 -0
  5. package/agent/catalog.generated.json +29368 -0
  6. package/agent/recipes/analytics.tsx +121 -0
  7. package/agent/recipes/chat.tsx +154 -0
  8. package/agent/recipes/conversation-units.tsx +28 -0
  9. package/agent/recipes/dashboard.tsx +38 -0
  10. package/agent/recipes/landing.tsx +26 -0
  11. package/agent/recipes/setup.md +44 -0
  12. package/agent/skills/yunui/SKILL.md +82 -0
  13. package/dist/adapters.d.ts +5 -0
  14. package/dist/adapters.js +1 -1
  15. package/dist/ai.d.ts +429 -320
  16. package/dist/ai.js +1228 -1966
  17. package/dist/ai.js.map +1 -1
  18. package/dist/charts.d.ts +149 -0
  19. package/dist/charts.js +849 -0
  20. package/dist/charts.js.map +1 -0
  21. package/dist/chat.d.ts +202 -23
  22. package/dist/chat.js +879 -129
  23. package/dist/chat.js.map +1 -1
  24. package/dist/{chunk-GAXVET76.js → chunk-ASPPAL7E.js} +16 -14
  25. package/dist/chunk-ASPPAL7E.js.map +1 -0
  26. package/dist/chunk-AVXIR7ZQ.js +197 -0
  27. package/dist/chunk-AVXIR7ZQ.js.map +1 -0
  28. package/dist/chunk-FJ52MVRF.js +82 -0
  29. package/dist/chunk-FJ52MVRF.js.map +1 -0
  30. package/dist/chunk-GRUB2GXF.js +15 -0
  31. package/dist/chunk-GRUB2GXF.js.map +1 -0
  32. package/dist/{chunk-3RT24MSH.js → chunk-GWD5W5F5.js} +2 -2
  33. package/dist/{chunk-3RT24MSH.js.map → chunk-GWD5W5F5.js.map} +1 -1
  34. package/dist/{chunk-YKWRCA2S.js → chunk-I2DAKAD5.js} +356 -138
  35. package/dist/chunk-I2DAKAD5.js.map +1 -0
  36. package/dist/{chunk-ST6TSBVQ.js → chunk-OM7B4O6K.js} +9 -24
  37. package/dist/chunk-OM7B4O6K.js.map +1 -0
  38. package/dist/chunk-OZIDZFMF.js +70 -0
  39. package/dist/chunk-OZIDZFMF.js.map +1 -0
  40. package/dist/chunk-P6LU2FWV.js +35 -0
  41. package/dist/chunk-P6LU2FWV.js.map +1 -0
  42. package/dist/chunk-SXWMKFKM.js +41 -0
  43. package/dist/chunk-SXWMKFKM.js.map +1 -0
  44. package/dist/chunk-TMTXJFNN.js +2715 -0
  45. package/dist/chunk-TMTXJFNN.js.map +1 -0
  46. package/dist/chunk-VNKAEQKU.js +501 -0
  47. package/dist/chunk-VNKAEQKU.js.map +1 -0
  48. package/dist/chunk-VSS7ASN2.js +12 -0
  49. package/dist/chunk-VSS7ASN2.js.map +1 -0
  50. package/dist/chunk-VYVFMNM7.js +112 -0
  51. package/dist/chunk-VYVFMNM7.js.map +1 -0
  52. package/dist/chunk-YKUQ7GCJ.js +230 -0
  53. package/dist/chunk-YKUQ7GCJ.js.map +1 -0
  54. package/dist/chunk-Z6WXDNBJ.js +366 -0
  55. package/dist/chunk-Z6WXDNBJ.js.map +1 -0
  56. package/dist/chunk-ZBRV6NHL.js +1115 -0
  57. package/dist/chunk-ZBRV6NHL.js.map +1 -0
  58. package/dist/code.d.ts +42 -0
  59. package/dist/code.js +8 -0
  60. package/dist/code.js.map +1 -0
  61. package/dist/content.d.ts +17 -39
  62. package/dist/content.js +373 -401
  63. package/dist/content.js.map +1 -1
  64. package/dist/footer-BCd-S806.d.ts +122 -0
  65. package/dist/index.d.ts +565 -89
  66. package/dist/index.js +7 -5
  67. package/dist/language.d.ts +30 -0
  68. package/dist/language.js +5 -0
  69. package/dist/language.js.map +1 -0
  70. package/dist/model-card.d.ts +43 -0
  71. package/dist/model-card.js +116 -0
  72. package/dist/model-card.js.map +1 -0
  73. package/dist/model.d.ts +51 -0
  74. package/dist/model.js +91 -0
  75. package/dist/model.js.map +1 -0
  76. package/dist/motion.d.ts +11 -0
  77. package/dist/motion.js +9 -0
  78. package/dist/motion.js.map +1 -0
  79. package/dist/patterns.d.ts +443 -8
  80. package/dist/patterns.js +1223 -147
  81. package/dist/patterns.js.map +1 -1
  82. package/dist/pickers.d.ts +134 -0
  83. package/dist/pickers.js +751 -0
  84. package/dist/pickers.js.map +1 -0
  85. package/dist/provider-icons-bgBTnami.d.ts +88 -0
  86. package/dist/segmented-bar-Bsr0PZIL.d.ts +58 -0
  87. package/dist/sparkline-vy5ec5C6.d.ts +67 -0
  88. package/icons/apps/aistudio.webp +0 -0
  89. package/icons/apps/coze.webp +0 -0
  90. package/icons/apps/dify.webp +0 -0
  91. package/icons/apps/doubao.webp +0 -0
  92. package/icons/apps/flowith.webp +0 -0
  93. package/icons/apps/gemini.webp +0 -0
  94. package/icons/apps/github-copilot.webp +0 -0
  95. package/icons/apps/google.webp +0 -0
  96. package/icons/apps/grok.webp +0 -0
  97. package/icons/apps/kimi.webp +0 -0
  98. package/icons/apps/ling.webp +0 -0
  99. package/icons/apps/longcat.webp +0 -0
  100. package/icons/apps/monica.webp +0 -0
  101. package/icons/apps/n8n.webp +0 -0
  102. package/icons/apps/notebooklm.webp +0 -0
  103. package/icons/apps/perplexity.webp +0 -0
  104. package/icons/apps/poe.webp +0 -0
  105. package/icons/apps/qingyan.webp +0 -0
  106. package/icons/apps/stepfun.webp +0 -0
  107. package/icons/apps/tiangong.webp +0 -0
  108. package/icons/apps/yuanbao.webp +0 -0
  109. package/icons/apps/zai.webp +0 -0
  110. package/icons/models/ai21.webp +0 -0
  111. package/icons/models/aimass.webp +0 -0
  112. package/icons/models/anthropic.webp +0 -0
  113. package/icons/models/baichuan.webp +0 -0
  114. package/icons/models/byte_dance.webp +0 -0
  115. package/icons/models/chatglm.webp +0 -0
  116. package/icons/models/claude.webp +0 -0
  117. package/icons/models/codegeex.webp +0 -0
  118. package/icons/models/cogview3flash.webp +0 -0
  119. package/icons/models/cohere.webp +0 -0
  120. package/icons/models/copilot.webp +0 -0
  121. package/icons/models/dalle.webp +0 -0
  122. package/icons/models/dbrx.webp +0 -0
  123. package/icons/models/deepseek.webp +0 -0
  124. package/icons/models/doubao.webp +0 -0
  125. package/icons/models/flux.webp +0 -0
  126. package/icons/models/gemini.webp +0 -0
  127. package/icons/models/gemma.webp +0 -0
  128. package/icons/models/google.webp +0 -0
  129. package/icons/models/grok.webp +0 -0
  130. package/icons/models/hailuo.webp +0 -0
  131. package/icons/models/huggingface.webp +0 -0
  132. package/icons/models/hunyuan.webp +0 -0
  133. package/icons/models/ibm.webp +0 -0
  134. package/icons/models/ideogram.webp +0 -0
  135. package/icons/models/internlm.webp +0 -0
  136. package/icons/models/jina.webp +0 -0
  137. package/icons/models/ling.webp +0 -0
  138. package/icons/models/llava.webp +0 -0
  139. package/icons/models/luma.webp +0 -0
  140. package/icons/models/magic.webp +0 -0
  141. package/icons/models/microsoft.webp +0 -0
  142. package/icons/models/midjourney.webp +0 -0
  143. package/icons/models/minimax.webp +0 -0
  144. package/icons/models/mistral.webp +0 -0
  145. package/icons/models/moonshot.webp +0 -0
  146. package/icons/models/nousresearch.webp +0 -0
  147. package/icons/models/nvidia.webp +0 -0
  148. package/icons/models/o3.webp +0 -0
  149. package/icons/models/openai.webp +0 -0
  150. package/icons/models/palm.webp +0 -0
  151. package/icons/models/perplexity.webp +0 -0
  152. package/icons/models/qwen.webp +0 -0
  153. package/icons/models/stability.webp +0 -0
  154. package/icons/models/step.webp +0 -0
  155. package/icons/models/suno.webp +0 -0
  156. package/icons/models/upstage.webp +0 -0
  157. package/icons/models/vidu.webp +0 -0
  158. package/icons/models/volcengine.webp +0 -0
  159. package/icons/models/voyageai.webp +0 -0
  160. package/icons/models/wenxin.webp +0 -0
  161. package/icons/models/yi.webp +0 -0
  162. package/icons/models/zai.webp +0 -0
  163. package/icons/models/zero-one.webp +0 -0
  164. package/icons/models/zhipu.webp +0 -0
  165. package/icons/providers/302ai.webp +0 -0
  166. package/icons/providers/ace.webp +0 -0
  167. package/icons/providers/adobe.webp +0 -0
  168. package/icons/providers/adobefirefly.webp +0 -0
  169. package/icons/providers/agentvoice.webp +0 -0
  170. package/icons/providers/agnesai.webp +0 -0
  171. package/icons/providers/agui.webp +0 -0
  172. package/icons/providers/ai2.webp +0 -0
  173. package/icons/providers/ai21.webp +0 -0
  174. package/icons/providers/ai302.webp +0 -0
  175. package/icons/providers/ai360.webp +0 -0
  176. package/icons/providers/aihubmix.webp +0 -0
  177. package/icons/providers/aimass.webp +0 -0
  178. package/icons/providers/aimlapi.webp +0 -0
  179. package/icons/providers/aionlabs.webp +0 -0
  180. package/icons/providers/airjelly.webp +0 -0
  181. package/icons/providers/aistudio.webp +0 -0
  182. package/icons/providers/akashchat.webp +0 -0
  183. package/icons/providers/alephalpha.webp +0 -0
  184. package/icons/providers/alibaba.webp +0 -0
  185. package/icons/providers/alibabacloud.webp +0 -0
  186. package/icons/providers/amdradeoncloud.webp +0 -0
  187. package/icons/providers/amp.webp +0 -0
  188. package/icons/providers/anspire.webp +0 -0
  189. package/icons/providers/antgroup.webp +0 -0
  190. package/icons/providers/anthropic.webp +0 -0
  191. package/icons/providers/antigravity.webp +0 -0
  192. package/icons/providers/anyscale.webp +0 -0
  193. package/icons/providers/apertis.webp +0 -0
  194. package/icons/providers/apple.webp +0 -0
  195. package/icons/providers/appwrite.webp +0 -0
  196. package/icons/providers/arcee.webp +0 -0
  197. package/icons/providers/askverdict.webp +0 -0
  198. package/icons/providers/assemblyai.webp +0 -0
  199. package/icons/providers/atlascloud.webp +0 -0
  200. package/icons/providers/automatic.webp +0 -0
  201. package/icons/providers/aws-bedrock.webp +0 -0
  202. package/icons/providers/aws.webp +0 -0
  203. package/icons/providers/aya.webp +0 -0
  204. package/icons/providers/azure.webp +0 -0
  205. package/icons/providers/azureai.webp +0 -0
  206. package/icons/providers/baai.webp +0 -0
  207. package/icons/providers/baichuan.webp +0 -0
  208. package/icons/providers/baidu-cloud.webp +0 -0
  209. package/icons/providers/baidu.webp +0 -0
  210. package/icons/providers/baiducloud.webp +0 -0
  211. package/icons/providers/bailian.webp +0 -0
  212. package/icons/providers/baseten.webp +0 -0
  213. package/icons/providers/bedrock.webp +0 -0
  214. package/icons/providers/bfl.webp +0 -0
  215. package/icons/providers/bigModel.webp +0 -0
  216. package/icons/providers/bilibili.webp +0 -0
  217. package/icons/providers/bilibiliindex.webp +0 -0
  218. package/icons/providers/bing.webp +0 -0
  219. package/icons/providers/bocha.webp +0 -0
  220. package/icons/providers/brave.webp +0 -0
  221. package/icons/providers/briaai.webp +0 -0
  222. package/icons/providers/browserless.webp +0 -0
  223. package/icons/providers/burncloud.webp +0 -0
  224. package/icons/providers/bytedance.webp +0 -0
  225. package/icons/providers/capcut.webp +0 -0
  226. package/icons/providers/celestoai.webp +0 -0
  227. package/icons/providers/centml.webp +0 -0
  228. package/icons/providers/cerebras.webp +0 -0
  229. package/icons/providers/chatglm.webp +0 -0
  230. package/icons/providers/cheaperinference.webp +0 -0
  231. package/icons/providers/cherrystudio.webp +0 -0
  232. package/icons/providers/chutes.webp +0 -0
  233. package/icons/providers/civitai.webp +0 -0
  234. package/icons/providers/claude.webp +0 -0
  235. package/icons/providers/claudecode.webp +0 -0
  236. package/icons/providers/cline.webp +0 -0
  237. package/icons/providers/clipdrop.webp +0 -0
  238. package/icons/providers/cloudflare.webp +0 -0
  239. package/icons/providers/codebuddy.webp +0 -0
  240. package/icons/providers/codeflicker.webp +0 -0
  241. package/icons/providers/codegeex.webp +0 -0
  242. package/icons/providers/codex.webp +0 -0
  243. package/icons/providers/cogvideo.webp +0 -0
  244. package/icons/providers/cogview.webp +0 -0
  245. package/icons/providers/cogview3flash.webp +0 -0
  246. package/icons/providers/cohere.webp +0 -0
  247. package/icons/providers/colab.webp +0 -0
  248. package/icons/providers/cometapi.webp +0 -0
  249. package/icons/providers/comfyui.webp +0 -0
  250. package/icons/providers/commanda.webp +0 -0
  251. package/icons/providers/commandcode.webp +0 -0
  252. package/icons/providers/copilot.webp +0 -0
  253. package/icons/providers/copilotkit.webp +0 -0
  254. package/icons/providers/coqui.webp +0 -0
  255. package/icons/providers/coze.webp +0 -0
  256. package/icons/providers/crewai.webp +0 -0
  257. package/icons/providers/crusoe.webp +0 -0
  258. package/icons/providers/cursor.webp +0 -0
  259. package/icons/providers/cybercut.webp +0 -0
  260. package/icons/providers/dalle.webp +0 -0
  261. package/icons/providers/dbrx.webp +0 -0
  262. package/icons/providers/decart.webp +0 -0
  263. package/icons/providers/deepai.webp +0 -0
  264. package/icons/providers/deepcogito.webp +0 -0
  265. package/icons/providers/deepinfra.webp +0 -0
  266. package/icons/providers/deepl.webp +0 -0
  267. package/icons/providers/deepmind.webp +0 -0
  268. package/icons/providers/deepseek.webp +0 -0
  269. package/icons/providers/devin.webp +0 -0
  270. package/icons/providers/dify.webp +0 -0
  271. package/icons/providers/digitalocean.webp +0 -0
  272. package/icons/providers/doc2x.webp +0 -0
  273. package/icons/providers/docsearch.webp +0 -0
  274. package/icons/providers/dolphin.webp +0 -0
  275. package/icons/providers/dothoosh.webp +0 -0
  276. package/icons/providers/dotsstudio.webp +0 -0
  277. package/icons/providers/doubao.webp +0 -0
  278. package/icons/providers/dreammachine.webp +0 -0
  279. package/icons/providers/elevenlabs.webp +0 -0
  280. package/icons/providers/elevenx.webp +0 -0
  281. package/icons/providers/empiriolabs.webp +0 -0
  282. package/icons/providers/essentialai.webp +0 -0
  283. package/icons/providers/exa.webp +0 -0
  284. package/icons/providers/fal.webp +0 -0
  285. package/icons/providers/fastgpt.webp +0 -0
  286. package/icons/providers/featherless.webp +0 -0
  287. package/icons/providers/figma.webp +0 -0
  288. package/icons/providers/firecrawl.webp +0 -0
  289. package/icons/providers/fireworks.webp +0 -0
  290. package/icons/providers/fishaudio.webp +0 -0
  291. package/icons/providers/flexai.webp +0 -0
  292. package/icons/providers/flora.webp +0 -0
  293. package/icons/providers/flowith.webp +0 -0
  294. package/icons/providers/flux.webp +0 -0
  295. package/icons/providers/friendli.webp +0 -0
  296. package/icons/providers/gemini.webp +0 -0
  297. package/icons/providers/geminicli.webp +0 -0
  298. package/icons/providers/gemma.webp +0 -0
  299. package/icons/providers/gitee-ai.webp +0 -0
  300. package/icons/providers/giteeai.webp +0 -0
  301. package/icons/providers/github.webp +0 -0
  302. package/icons/providers/githubcopilot.webp +0 -0
  303. package/icons/providers/glama.webp +0 -0
  304. package/icons/providers/glif.webp +0 -0
  305. package/icons/providers/glmv.webp +0 -0
  306. package/icons/providers/gmicloud.webp +0 -0
  307. package/icons/providers/google.webp +0 -0
  308. package/icons/providers/googlecloud.webp +0 -0
  309. package/icons/providers/goose.webp +0 -0
  310. package/icons/providers/gradio.webp +0 -0
  311. package/icons/providers/greenpt.webp +0 -0
  312. package/icons/providers/greptile.webp +0 -0
  313. package/icons/providers/grok.webp +0 -0
  314. package/icons/providers/grokbot.webp +0 -0
  315. package/icons/providers/groq.webp +0 -0
  316. package/icons/providers/hailuo.webp +0 -0
  317. package/icons/providers/haiper.webp +0 -0
  318. package/icons/providers/happyhorse.webp +0 -0
  319. package/icons/providers/hedra.webp +0 -0
  320. package/icons/providers/hermesagent.webp +0 -0
  321. package/icons/providers/higress.webp +0 -0
  322. package/icons/providers/huawei.webp +0 -0
  323. package/icons/providers/huaweicloud.webp +0 -0
  324. package/icons/providers/huggingface.webp +0 -0
  325. package/icons/providers/hunyuan.webp +0 -0
  326. package/icons/providers/hyperbolic.webp +0 -0
  327. package/icons/providers/ibm.webp +0 -0
  328. package/icons/providers/ideogram.webp +0 -0
  329. package/icons/providers/iflytekcloud.webp +0 -0
  330. package/icons/providers/inception.webp +0 -0
  331. package/icons/providers/inceptron.webp +0 -0
  332. package/icons/providers/inference.webp +0 -0
  333. package/icons/providers/infermatic.webp +0 -0
  334. package/icons/providers/infini.webp +0 -0
  335. package/icons/providers/infinigence.webp +0 -0
  336. package/icons/providers/inflection.webp +0 -0
  337. package/icons/providers/internlm.webp +0 -0
  338. package/icons/providers/ionet.webp +0 -0
  339. package/icons/providers/jimeng.webp +0 -0
  340. package/icons/providers/jina.webp +0 -0
  341. package/icons/providers/junie.webp +0 -0
  342. package/icons/providers/kagi.webp +0 -0
  343. package/icons/providers/kilocode.webp +0 -0
  344. package/icons/providers/kimi.webp +0 -0
  345. package/icons/providers/kiro.webp +0 -0
  346. package/icons/providers/kling.webp +0 -0
  347. package/icons/providers/kluster.webp +0 -0
  348. package/icons/providers/kolors.webp +0 -0
  349. package/icons/providers/krea.webp +0 -0
  350. package/icons/providers/kwaikat.webp +0 -0
  351. package/icons/providers/kwaipilot.webp +0 -0
  352. package/icons/providers/lambda.webp +0 -0
  353. package/icons/providers/langchain.webp +0 -0
  354. package/icons/providers/langfuse.webp +0 -0
  355. package/icons/providers/langgraph.webp +0 -0
  356. package/icons/providers/langsmith.webp +0 -0
  357. package/icons/providers/leptonai.webp +0 -0
  358. package/icons/providers/lg.webp +0 -0
  359. package/icons/providers/lightricks.webp +0 -0
  360. package/icons/providers/ling.webp +0 -0
  361. package/icons/providers/liquid.webp +0 -0
  362. package/icons/providers/livekit.webp +0 -0
  363. package/icons/providers/llamaindex.webp +0 -0
  364. package/icons/providers/llava.webp +0 -0
  365. package/icons/providers/llmapi.webp +0 -0
  366. package/icons/providers/llmgateway.webp +0 -0
  367. package/icons/providers/lmstudio.webp +0 -0
  368. package/icons/providers/lobehub.webp +0 -0
  369. package/icons/providers/lobot.webp +0 -0
  370. package/icons/providers/longcat.webp +0 -0
  371. package/icons/providers/lovable.webp +0 -0
  372. package/icons/providers/lovart.webp +0 -0
  373. package/icons/providers/luma.webp +0 -0
  374. package/icons/providers/magic.webp +0 -0
  375. package/icons/providers/magpie.webp +0 -0
  376. package/icons/providers/make.webp +0 -0
  377. package/icons/providers/manus.webp +0 -0
  378. package/icons/providers/mastra.webp +0 -0
  379. package/icons/providers/mcp.webp +0 -0
  380. package/icons/providers/mcpso.webp +0 -0
  381. package/icons/providers/menlo.webp +0 -0
  382. package/icons/providers/meshy.webp +0 -0
  383. package/icons/providers/meta.webp +0 -0
  384. package/icons/providers/metaai.webp +0 -0
  385. package/icons/providers/metagpt.webp +0 -0
  386. package/icons/providers/microsoft.webp +0 -0
  387. package/icons/providers/midjourney.webp +0 -0
  388. package/icons/providers/minimax.webp +0 -0
  389. package/icons/providers/mistral.webp +0 -0
  390. package/icons/providers/modelscope.webp +0 -0
  391. package/icons/providers/monica.webp +0 -0
  392. package/icons/providers/moonshot.webp +0 -0
  393. package/icons/providers/morph.webp +0 -0
  394. package/icons/providers/moxt.webp +0 -0
  395. package/icons/providers/muse.webp +0 -0
  396. package/icons/providers/myshell.webp +0 -0
  397. package/icons/providers/n8n.webp +0 -0
  398. package/icons/providers/nanobanana.webp +0 -0
  399. package/icons/providers/nebius.webp +0 -0
  400. package/icons/providers/newapi.webp +0 -0
  401. package/icons/providers/nextbit.webp +0 -0
  402. package/icons/providers/notebooklm.webp +0 -0
  403. package/icons/providers/notion.webp +0 -0
  404. package/icons/providers/nousresearch.webp +0 -0
  405. package/icons/providers/nova.webp +0 -0
  406. package/icons/providers/novelai.webp +0 -0
  407. package/icons/providers/novita.webp +0 -0
  408. package/icons/providers/nplcloud.webp +0 -0
  409. package/icons/providers/nvidia.webp +0 -0
  410. package/icons/providers/o3.webp +0 -0
  411. package/icons/providers/obsidian.webp +0 -0
  412. package/icons/providers/ollama.webp +0 -0
  413. package/icons/providers/omlx.webp +0 -0
  414. package/icons/providers/openai.webp +0 -0
  415. package/icons/providers/openchat.webp +0 -0
  416. package/icons/providers/openclaw.webp +0 -0
  417. package/icons/providers/opencode.webp +0 -0
  418. package/icons/providers/openhands.webp +0 -0
  419. package/icons/providers/openhuman.webp +0 -0
  420. package/icons/providers/openrouter.webp +0 -0
  421. package/icons/providers/openwebui.webp +0 -0
  422. package/icons/providers/paddleocr.webp +0 -0
  423. package/icons/providers/palm.webp +0 -0
  424. package/icons/providers/parasail.webp +0 -0
  425. package/icons/providers/perceptron.webp +0 -0
  426. package/icons/providers/perplexity.webp +0 -0
  427. package/icons/providers/phala.webp +0 -0
  428. package/icons/providers/phidata.webp +0 -0
  429. package/icons/providers/phind.webp +0 -0
  430. package/icons/providers/pi.webp +0 -0
  431. package/icons/providers/pika.webp +0 -0
  432. package/icons/providers/pixverse.webp +0 -0
  433. package/icons/providers/player2.webp +0 -0
  434. package/icons/providers/poe.webp +0 -0
  435. package/icons/providers/pollinations.webp +0 -0
  436. package/icons/providers/poolside.webp +0 -0
  437. package/icons/providers/ppio.webp +0 -0
  438. package/icons/providers/prunaai.webp +0 -0
  439. package/icons/providers/pydanticai.webp +0 -0
  440. package/icons/providers/qingyan.webp +0 -0
  441. package/icons/providers/qiniu.webp +0 -0
  442. package/icons/providers/qoder.webp +0 -0
  443. package/icons/providers/qwen.webp +0 -0
  444. package/icons/providers/railway.webp +0 -0
  445. package/icons/providers/recraft.webp +0 -0
  446. package/icons/providers/reflection.webp +0 -0
  447. package/icons/providers/reka.webp +0 -0
  448. package/icons/providers/relace.webp +0 -0
  449. package/icons/providers/replicate.webp +0 -0
  450. package/icons/providers/replit.webp +0 -0
  451. package/icons/providers/reve.webp +0 -0
  452. package/icons/providers/roocode.webp +0 -0
  453. package/icons/providers/rsshub.webp +0 -0
  454. package/icons/providers/runway.webp +0 -0
  455. package/icons/providers/rwkv.webp +0 -0
  456. package/icons/providers/sakana.webp +0 -0
  457. package/icons/providers/sambanova.webp +0 -0
  458. package/icons/providers/search1api.webp +0 -0
  459. package/icons/providers/searchapi.webp +0 -0
  460. package/icons/providers/searxng.webp +0 -0
  461. package/icons/providers/sensenova.webp +0 -0
  462. package/icons/providers/silicon.webp +0 -0
  463. package/icons/providers/siliconcloud.webp +0 -0
  464. package/icons/providers/sillytavern.webp +0 -0
  465. package/icons/providers/skywork.webp +0 -0
  466. package/icons/providers/slock.webp +0 -0
  467. package/icons/providers/smithery.webp +0 -0
  468. package/icons/providers/snowflake.webp +0 -0
  469. package/icons/providers/sophnet.webp +0 -0
  470. package/icons/providers/sora.webp +0 -0
  471. package/icons/providers/spark.webp +0 -0
  472. package/icons/providers/speedai.webp +0 -0
  473. package/icons/providers/stability.webp +0 -0
  474. package/icons/providers/statecloud.webp +0 -0
  475. package/icons/providers/step.webp +0 -0
  476. package/icons/providers/stepfun.webp +0 -0
  477. package/icons/providers/straico.webp +0 -0
  478. package/icons/providers/streamlake.webp +0 -0
  479. package/icons/providers/sub2api.webp +0 -0
  480. package/icons/providers/submodel.webp +0 -0
  481. package/icons/providers/suno.webp +0 -0
  482. package/icons/providers/sync.webp +0 -0
  483. package/icons/providers/tabbit.webp +0 -0
  484. package/icons/providers/targon.webp +0 -0
  485. package/icons/providers/tavily.webp +0 -0
  486. package/icons/providers/tencent-cloud-ti.webp +0 -0
  487. package/icons/providers/tencent.webp +0 -0
  488. package/icons/providers/tencentcloud.webp +0 -0
  489. package/icons/providers/tiangong.webp +0 -0
  490. package/icons/providers/tii.webp +0 -0
  491. package/icons/providers/together.webp +0 -0
  492. package/icons/providers/topazlabs.webp +0 -0
  493. package/icons/providers/trae.webp +0 -0
  494. package/icons/providers/tripo.webp +0 -0
  495. package/icons/providers/turix.webp +0 -0
  496. package/icons/providers/typesafeai.webp +0 -0
  497. package/icons/providers/udio.webp +0 -0
  498. package/icons/providers/unionalpha.webp +0 -0
  499. package/icons/providers/unsloth.webp +0 -0
  500. package/icons/providers/unstructured.webp +0 -0
  501. package/icons/providers/upstage.webp +0 -0
  502. package/icons/providers/v0.webp +0 -0
  503. package/icons/providers/vectorizerai.webp +0 -0
  504. package/icons/providers/venice.webp +0 -0
  505. package/icons/providers/vercel.webp +0 -0
  506. package/icons/providers/vertexai.webp +0 -0
  507. package/icons/providers/vidu.webp +0 -0
  508. package/icons/providers/viggle.webp +0 -0
  509. package/icons/providers/vllm.webp +0 -0
  510. package/icons/providers/volcengine.webp +0 -0
  511. package/icons/providers/voyage.webp +0 -0
  512. package/icons/providers/voyageai.webp +0 -0
  513. package/icons/providers/wafer.webp +0 -0
  514. package/icons/providers/wandb.webp +0 -0
  515. package/icons/providers/wavespeed.webp +0 -0
  516. package/icons/providers/wenxin.webp +0 -0
  517. package/icons/providers/windsurf.webp +0 -0
  518. package/icons/providers/workbuddy.webp +0 -0
  519. package/icons/providers/workersai.webp +0 -0
  520. package/icons/providers/worldrouter.webp +0 -0
  521. package/icons/providers/xai.webp +0 -0
  522. package/icons/providers/xiaomimimo.webp +0 -0
  523. package/icons/providers/xinference.webp +0 -0
  524. package/icons/providers/xpay.webp +0 -0
  525. package/icons/providers/xuanyuan.webp +0 -0
  526. package/icons/providers/yandex.webp +0 -0
  527. package/icons/providers/yi.webp +0 -0
  528. package/icons/providers/youmind.webp +0 -0
  529. package/icons/providers/yuanbao.webp +0 -0
  530. package/icons/providers/zai.webp +0 -0
  531. package/icons/providers/zapier.webp +0 -0
  532. package/icons/providers/zeabur.webp +0 -0
  533. package/icons/providers/zencoder.webp +0 -0
  534. package/icons/providers/zenmux.webp +0 -0
  535. package/icons/providers/zero-one.webp +0 -0
  536. package/icons/providers/zeroone.webp +0 -0
  537. package/icons/providers/zhipu.webp +0 -0
  538. package/licenses/beautiful-ui-MIT.txt +21 -0
  539. package/package.json +51 -7
  540. package/scripts/yunui-audit.mjs +664 -0
  541. package/scripts/yunui-cli.mjs +868 -0
  542. package/scripts/yunui-init.mjs +138 -0
  543. package/styles/content.css +34 -2
  544. package/styles/tokens.css +41 -0
  545. package/styles/yunui.css +1389 -57
  546. package/dist/chunk-AFVENY4D.js +0 -1466
  547. package/dist/chunk-AFVENY4D.js.map +0 -1
  548. package/dist/chunk-GAXVET76.js.map +0 -1
  549. package/dist/chunk-LEBQPP4B.js +0 -152
  550. package/dist/chunk-LEBQPP4B.js.map +0 -1
  551. package/dist/chunk-ST6TSBVQ.js.map +0 -1
  552. package/dist/chunk-V7VJKZ5Q.js +0 -254
  553. package/dist/chunk-V7VJKZ5Q.js.map +0 -1
  554. package/dist/chunk-YKWRCA2S.js.map +0 -1
  555. package/dist/footer-BoFu7Wqq.d.ts +0 -46
  556. package/icons/apps/ling.png +0 -0
  557. package/icons/models/ling.png +0 -0
  558. package/icons/providers/Kwaipilot.png +0 -0
package/dist/ai.js CHANGED
@@ -1,264 +1,608 @@
1
1
  "use client";
2
- import { capabilityIconColor, copyToClipboard } from './chunk-LEBQPP4B.js';
3
- export { DiscordIcon, Footer, GithubIcon, InstagramIcon } from './chunk-LEBQPP4B.js';
4
- import { TextShimmer, ThemeToggle } from './chunk-GAXVET76.js';
5
- import { cn, useAnchoredPosition, useDismissOnOutside } from './chunk-V7VJKZ5Q.js';
6
- import { useYunUI } from './chunk-3RT24MSH.js';
7
- import { memo, useState, useEffect, useRef, useMemo } from 'react';
8
- import { AnimatePresence, motion } from 'framer-motion';
9
- import { Pin, MessageSquare, Waves, Code, Eye, Brain, Pencil, Ban, Fingerprint, Layers, SlidersHorizontal, Mic, Video, Music, Box, Radio, ChevronUp, ChevronDown, Check, Copy, Image, PauseCircle, Search, X, Sparkles, Bot, Globe, Menu, CircleUserRound, LogOut, ShieldAlert, Wrench, FileText, Terminal, Loader2, Shield, Shuffle, Volume2, Headphones, Palette, Hash } from 'lucide-react';
2
+ export { DiscordIcon, Footer, GithubIcon, InstagramIcon, Navbar } from './chunk-YKUQ7GCJ.js';
3
+ import { TextShimmer } from './chunk-ASPPAL7E.js';
4
+ import { Button, RadioGroup, RadioGroupItem, Checkbox, Badge } from './chunk-I2DAKAD5.js';
5
+ export { LanguageSwitcher } from './chunk-VYVFMNM7.js';
6
+ import { mergeLabels } from './chunk-GRUB2GXF.js';
7
+ import { useDismissOnOutside, FloatingPanel } from './chunk-Z6WXDNBJ.js';
8
+ import { ProviderIcon } from './chunk-ZBRV6NHL.js';
9
+ export { CapabilitySelector, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderNames, getDeveloperIconPath, getIconPath, getProviderIconOptions, normalizeProviderId } from './chunk-ZBRV6NHL.js';
10
+ import { cn } from './chunk-VSS7ASN2.js';
11
+ import { useYunUI } from './chunk-GWD5W5F5.js';
12
+ import { useState, useId, useRef, useEffect, useCallback, useMemo, Children, isValidElement, Fragment as Fragment$1, useLayoutEffect } from 'react';
13
+ import { Sparkles, ChevronDown, X, ArrowRight, Check, CircleAlert, Clock3, Loader2, RefreshCw, ArrowUp, ChevronRight, Bot, CircleUserRound, LogOut, RotateCcw, FileText, Terminal, Pencil, Wrench, Image, Globe, Search, CircleHelp, Scissors, ThumbsUp, Type, Radio, Box, Shield, Shuffle, Music, Video, Mic, Volume2, Headphones, Palette, Hash, MessageSquare, Ban, ShieldQuestion, Copy } from 'lucide-react';
10
14
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
11
15
  import { cva } from 'class-variance-authority';
12
16
 
13
- function ThinkingBlock({ content, isStreaming, defaultOpen = false, renderContent }) {
14
- const t = useYunUI().useT("common.thinking");
15
- const [isOpen, setIsOpen] = useState(defaultOpen);
16
- return /* @__PURE__ */ jsxs("div", { className: "my-2 rounded-xl border border-border bg-muted/30 overflow-hidden", children: [
17
+ function ThinkingBlock({
18
+ content,
19
+ isStreaming = false,
20
+ doneLabel,
21
+ defaultOpen = false,
22
+ open,
23
+ onOpenChange,
24
+ steps = [],
25
+ selectedStepId,
26
+ onStepSelect,
27
+ labels,
28
+ renderContent
29
+ }) {
30
+ const translate = useYunUI().useT("common.thinking");
31
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
32
+ const contentId = `${useId()}-thinking-content`;
33
+ const controlled = open !== void 0;
34
+ const isOpen = controlled ? open : internalOpen;
35
+ const canToggle = !controlled || Boolean(onOpenChange);
36
+ const fallback = (key, value) => {
37
+ try {
38
+ const translated = translate(key);
39
+ return translated && translated !== key && !translated.endsWith(`.${key}`) ? translated : value;
40
+ } catch {
41
+ return value;
42
+ }
43
+ };
44
+ const copy = {
45
+ title: labels?.title ?? fallback("label", "Thinking"),
46
+ active: labels?.active ?? fallback("active", "Thinking"),
47
+ inProgress: labels?.inProgress ?? fallback("inProgress", "In progress"),
48
+ completed: labels?.completed ?? fallback("completed", "Completed"),
49
+ failed: labels?.failed ?? fallback("failed", "Failed"),
50
+ cancelled: labels?.cancelled ?? fallback("cancelled", "Cancelled"),
51
+ pending: labels?.pending ?? fallback("pending", "Pending")
52
+ };
53
+ const wasStreaming = useRef(isStreaming);
54
+ const [justFinished, setJustFinished] = useState(false);
55
+ useEffect(() => {
56
+ if (wasStreaming.current && !isStreaming) setJustFinished(true);
57
+ if (isStreaming) setJustFinished(false);
58
+ wasStreaming.current = isStreaming;
59
+ }, [isStreaming]);
60
+ const requestOpen = () => {
61
+ if (!canToggle) return;
62
+ const next = !isOpen;
63
+ if (!controlled) setInternalOpen(next);
64
+ onOpenChange?.(next);
65
+ };
66
+ const statusLabel = (status) => ({
67
+ pending: copy.pending,
68
+ running: copy.active,
69
+ done: copy.completed,
70
+ failed: copy.failed,
71
+ cancelled: copy.cancelled
72
+ })[status];
73
+ const statusIcon2 = (status) => {
74
+ const common = "h-3.5 w-3.5 shrink-0";
75
+ switch (status) {
76
+ case "running":
77
+ return /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: cn(common, "motion-safe:animate-spin text-primary") });
78
+ case "done":
79
+ return /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: cn(common, "text-(--success)") });
80
+ case "failed":
81
+ return /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, className: cn(common, "text-(--error)") });
82
+ case "cancelled":
83
+ return /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: cn(common, "text-muted-foreground") });
84
+ default:
85
+ return /* @__PURE__ */ jsx(Clock3, { "aria-hidden": true, className: cn(common, "text-muted-foreground/60") });
86
+ }
87
+ };
88
+ return /* @__PURE__ */ jsxs("section", { className: "@container/think my-2 w-full min-w-0", "data-yunui": "thinking-block", children: [
17
89
  /* @__PURE__ */ jsxs(
18
90
  "button",
19
91
  {
20
- onClick: () => setIsOpen(!isOpen),
92
+ type: "button",
93
+ onClick: requestOpen,
94
+ disabled: !canToggle,
21
95
  "aria-expanded": isOpen,
22
- className: "w-full flex items-center gap-2 px-3 py-1.5 text-xs text-muted-foreground hover:bg-muted/50 transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
96
+ "aria-controls": contentId,
97
+ "aria-label": doneLabel && !isStreaming ? `${copy.title}: ${doneLabel}` : void 0,
98
+ className: "group flex min-h-8 w-fit max-w-full items-center gap-2 rounded-md px-1.5 text-left text-[13px] text-muted-foreground transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
23
99
  children: [
24
- /* @__PURE__ */ jsx("div", { className: cn(
25
- "flex items-center justify-center w-5 h-5 rounded-md bg-muted text-muted-foreground",
26
- isStreaming && "animate-pulse"
27
- ), children: /* @__PURE__ */ jsx(Brain, { size: 11 }) }),
28
- /* @__PURE__ */ jsx("span", { className: "font-medium whitespace-nowrap", children: t("label") }),
29
- isStreaming && /* @__PURE__ */ jsx("span", { className: "text-[10px] uppercase tracking-wider font-semibold text-primary bg-primary/10 px-1.5 py-0.5 rounded whitespace-nowrap", children: t("active") }),
30
- /* @__PURE__ */ jsx("div", { className: "ml-auto", children: isOpen ? /* @__PURE__ */ jsx(ChevronUp, { size: 14, className: "text-muted-foreground/70" }) : /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: "text-muted-foreground/70" }) })
100
+ /* @__PURE__ */ jsx(Sparkles, { "aria-hidden": true, className: cn("h-3.5 w-3.5 shrink-0", isStreaming ? "text-primary" : "text-muted-foreground") }),
101
+ isStreaming ? /* @__PURE__ */ jsx(TextShimmer, { text: copy.title, role: "status", className: "min-w-0 truncate font-medium text-foreground" }) : /* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate font-medium text-foreground", justFinished && "yunui-swap-in"), children: doneLabel ?? copy.title }, doneLabel ?? copy.title),
102
+ isStreaming ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "h-1.5 w-1.5 shrink-0 rounded-full bg-primary motion-safe:animate-pulse" }) : null,
103
+ /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn("h-3.5 w-3.5 shrink-0 transition-transform motion-reduce:transition-none", isOpen && "rotate-180") })
31
104
  ]
32
105
  }
33
106
  ),
34
- /* @__PURE__ */ jsx(AnimatePresence, { children: isOpen && /* @__PURE__ */ jsx(
35
- motion.div,
107
+ /* @__PURE__ */ jsx(
108
+ "div",
36
109
  {
37
- initial: { height: 0, opacity: 0 },
38
- animate: { height: "auto", opacity: 1 },
39
- exit: { height: 0, opacity: 0 },
40
- transition: { duration: 0.2, ease: "easeInOut" },
41
- children: /* @__PURE__ */ jsx("div", { className: "px-3 pb-2.5 pt-1.5 text-xs text-muted-foreground leading-relaxed border-t border-border/50", children: content ? /* @__PURE__ */ jsxs("div", { className: "text-muted-foreground", children: [
110
+ id: contentId,
111
+ "aria-hidden": !isOpen,
112
+ inert: !isOpen,
113
+ "data-open": isOpen,
114
+ className: "yunui-disclosure min-w-0",
115
+ children: /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children: steps.length ? /* @__PURE__ */ jsx("ol", { "aria-label": copy.title, className: "ml-2 mt-1 flex min-w-0 flex-col gap-0.5 border-l border-border/70 py-1 pl-3", children: steps.map((step) => {
116
+ const contentNode = /* @__PURE__ */ jsxs(Fragment, { children: [
117
+ statusIcon2(step.status),
118
+ /* @__PURE__ */ jsx("span", { className: cn("min-w-0 text-left text-[12.5px] text-foreground", step.mono && "font-mono text-xs"), children: step.label }),
119
+ step.meta != null ? /* @__PURE__ */ jsx("span", { "data-yunui": "thinking-block-step-meta", className: "col-start-2 min-w-0 break-words text-[11px] tabular-nums text-muted-foreground @min-[360px]/think:col-start-3 @min-[360px]/think:max-w-[10rem] @min-[360px]/think:text-right", children: step.meta }) : null,
120
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: statusLabel(step.status) })
121
+ ] });
122
+ return /* @__PURE__ */ jsxs("li", { "data-yunui": "thinking-block-step", className: "min-w-0", children: [
123
+ onStepSelect ? /* @__PURE__ */ jsx(
124
+ "button",
125
+ {
126
+ type: "button",
127
+ "aria-pressed": selectedStepId === step.id,
128
+ onClick: () => onStepSelect(step.id),
129
+ className: cn("grid min-h-8 w-full min-w-0 grid-cols-[0.875rem_minmax(0,1fr)] items-center gap-x-2 gap-y-0.5 rounded-sm px-1.5 text-left transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring @min-[360px]/think:grid-cols-[0.875rem_minmax(0,1fr)_auto]", selectedStepId === step.id && "bg-muted/60"),
130
+ children: contentNode
131
+ }
132
+ ) : /* @__PURE__ */ jsx("div", { className: "grid min-h-8 min-w-0 grid-cols-[0.875rem_minmax(0,1fr)] items-center gap-x-2 gap-y-0.5 px-1.5 @min-[360px]/think:grid-cols-[0.875rem_minmax(0,1fr)_auto]", children: contentNode }),
133
+ step.detail != null ? /* @__PURE__ */ jsx("div", { "data-yunui": "thinking-block-step-detail", className: "ml-5 border-l border-border/70 py-1 pl-2.5 text-xs leading-relaxed text-muted-foreground", children: step.detail }) : null
134
+ ] }, step.id);
135
+ }) }) : content ? /* @__PURE__ */ jsxs("div", { className: "ml-2 mt-1 border-l border-border/70 py-1 pl-3 pr-2 text-[13px] leading-relaxed text-muted-foreground", children: [
42
136
  renderContent ? renderContent(content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: content }),
43
- isStreaming && /* @__PURE__ */ jsx(
44
- motion.span,
45
- {
46
- animate: { opacity: [0.4, 1, 0.4] },
47
- transition: { duration: 1.2, repeat: Infinity },
48
- className: "inline-block w-1 h-3 bg-muted-foreground/60 ml-0.5 align-middle"
49
- }
50
- )
51
- ] }) : /* @__PURE__ */ jsx("span", { className: "italic opacity-50", children: t("inProgress") }) })
137
+ isStreaming ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "ml-1 inline-block h-3 w-1 animate-pulse bg-muted-foreground/70 align-middle motion-reduce:animate-none" }) : null
138
+ ] }) : isStreaming ? /* @__PURE__ */ jsx("p", { className: "ml-2 mt-1 border-l border-border/70 py-1 pl-3 text-[12px] text-muted-foreground", children: copy.inProgress }) : null })
52
139
  }
53
- ) })
140
+ )
54
141
  ] });
55
142
  }
143
+ function domIdPart(value) {
144
+ return Array.from(value, (character) => character.codePointAt(0)?.toString(16) ?? "0").join("-") || "empty";
145
+ }
56
146
  var ICONS = {
57
147
  terminal: Terminal,
58
148
  search: Search,
59
149
  globe: Globe,
60
150
  image: Image,
61
151
  file: FileText,
62
- tool: Wrench
152
+ tool: Wrench,
153
+ think: Sparkles,
154
+ write: Pencil,
155
+ run: Terminal,
156
+ read: FileText
63
157
  };
64
- function Rail({ children, tone = "muted", isLast }) {
65
- return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center self-stretch", children: [
66
- /* @__PURE__ */ jsx(
67
- "span",
68
- {
69
- className: cn(
70
- "relative z-10 mt-0.5 flex h-[26px] w-[26px] shrink-0 items-center justify-center rounded-full bg-background ring-1 transition-colors",
71
- tone === "muted" && "text-muted-foreground ring-border",
72
- tone === "running" && "text-primary ring-primary/40",
73
- tone === "error" && "text-(--error) ring-(--error)/40",
74
- tone === "warn" && "text-(--warning) ring-(--warning)/40"
75
- ),
76
- children
77
- }
78
- ),
79
- !isLast && /* @__PURE__ */ jsx("span", { className: "my-1 w-0.5 flex-1 rounded-full bg-border" })
80
- ] });
158
+ function useDisclosure({ id, open: controlledOpen, defaultOpen = false, onToggleRow }) {
159
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
160
+ const controlled = controlledOpen !== void 0;
161
+ const open = controlled ? controlledOpen : internalOpen;
162
+ const canToggle = !controlled || Boolean(onToggleRow);
163
+ const toggle = () => {
164
+ if (!canToggle) return;
165
+ const next = !open;
166
+ if (!controlled) setInternalOpen(next);
167
+ onToggleRow?.(id, next);
168
+ };
169
+ return { open, canToggle, toggle };
81
170
  }
82
- function Collapse({ open, children }) {
171
+ function Collapse({ open, children, id }) {
83
172
  return /* @__PURE__ */ jsx(
84
173
  "div",
85
174
  {
175
+ id,
176
+ "aria-hidden": !open,
177
+ inert: !open,
86
178
  className: cn(
87
- "grid transition-[grid-template-rows,opacity] duration-200 ease-out motion-reduce:transition-none",
179
+ "grid transition-[grid-template-rows,opacity] duration-(--dur-slow) ease-out motion-reduce:transition-none",
88
180
  open ? "grid-rows-[1fr] opacity-100" : "grid-rows-[0fr] opacity-0"
89
181
  ),
90
182
  children: /* @__PURE__ */ jsx("div", { className: "min-h-0 overflow-hidden", children })
91
183
  }
92
184
  );
93
185
  }
94
- function Chevron({ open }) {
95
- return /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: cn("shrink-0 text-muted-foreground/50 transition-transform duration-200", open && "rotate-180") });
186
+ function statusIcon(status) {
187
+ if (status === "running") return /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 motion-safe:animate-spin text-primary" });
188
+ if (status === "done") return /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-(--success)" });
189
+ if (status === "error" || status === "failed") return /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-(--error)" });
190
+ if (status === "cancelled") return /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" });
191
+ return /* @__PURE__ */ jsx(Clock3, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground/60" });
192
+ }
193
+ function statusText(status, labels) {
194
+ if (status === "done") return labels.completed ?? "Completed";
195
+ if (status === "failed") return labels.failed ?? "Failed";
196
+ if (status === "cancelled") return labels.cancelled ?? "Cancelled";
197
+ if (status === "error") return labels.error ?? "Error";
198
+ if (status === "pending") return labels.pending ?? "Pending";
199
+ return labels.running ?? "Running";
96
200
  }
97
- function ReasoningRow({ block, isLast, renderContent }) {
98
- const [open, setOpen] = useState(block.defaultOpen ?? false);
201
+ function toneClass(tone) {
202
+ if (tone === "add") return "text-(--success)";
203
+ if (tone === "del") return "text-(--error)";
204
+ return "text-muted-foreground";
205
+ }
206
+ function ReasoningRow({ block, labels, onToggleRow, renderContent }) {
207
+ const instanceId = useId();
99
208
  const expandable = Boolean(block.content.trim());
100
- return /* @__PURE__ */ jsxs("div", { className: "flex gap-2.5", children: [
101
- /* @__PURE__ */ jsx(Rail, { tone: block.active ? "running" : "muted", isLast, children: /* @__PURE__ */ jsxs("span", { className: "relative flex items-center justify-center", children: [
102
- block.active ? /* @__PURE__ */ jsx(
103
- "span",
104
- {
105
- "aria-hidden": "true",
106
- className: "absolute h-4 w-4 animate-ping rounded-full bg-primary/15 motion-reduce:hidden"
107
- }
108
- ) : null,
109
- /* @__PURE__ */ jsx(
110
- Brain,
111
- {
112
- size: 13,
113
- strokeWidth: 1.75,
114
- className: cn(block.active && "animate-pulse motion-reduce:animate-none")
115
- }
116
- )
117
- ] }) }),
118
- /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 pb-2", children: /* @__PURE__ */ jsxs(
119
- "div",
209
+ const disclosure = useDisclosure({ id: block.id, open: block.open, defaultOpen: block.defaultOpen, onToggleRow });
210
+ const title = `${instanceId}-reasoning-${domIdPart(block.id)}`;
211
+ return /* @__PURE__ */ jsxs("div", { "data-yunui": "agent-timeline-reasoning-disclosure", className: "min-w-0 py-1", children: [
212
+ /* @__PURE__ */ jsxs(
213
+ "button",
120
214
  {
121
- "data-yunui": "agent-timeline-reasoning-disclosure",
122
- className: cn(
123
- "overflow-hidden rounded-lg",
124
- expandable && "border border-border/60 bg-muted/20"
125
- ),
215
+ type: "button",
216
+ disabled: !expandable || !disclosure.canToggle,
217
+ "aria-expanded": expandable ? disclosure.open : void 0,
218
+ "aria-controls": expandable ? title : void 0,
219
+ onClick: disclosure.toggle,
220
+ className: "flex min-h-8 w-full items-center gap-2 rounded-lg px-2 text-left transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
126
221
  children: [
127
- /* @__PURE__ */ jsxs(
128
- "button",
129
- {
130
- type: "button",
131
- onClick: () => expandable && setOpen(!open),
132
- "aria-expanded": expandable ? open : void 0,
133
- className: cn(
134
- "flex h-[30px] w-full items-center gap-2 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
135
- expandable ? "cursor-pointer rounded-none px-2.5 hover:bg-muted/40" : "cursor-default rounded-md px-1.5"
136
- ),
137
- children: [
138
- block.active ? /* @__PURE__ */ jsx(
139
- TextShimmer,
140
- {
141
- text: block.label,
142
- className: "min-w-0 flex-1 truncate text-[13px]",
143
- "data-agent-timeline-active": "true"
144
- }
145
- ) : /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-[13px] text-muted-foreground", children: block.label }),
146
- expandable ? /* @__PURE__ */ jsx(Chevron, { open }) : null
147
- ]
148
- }
149
- ),
150
- expandable ? /* @__PURE__ */ jsx(Collapse, { open, children: /* @__PURE__ */ jsx(
151
- "div",
152
- {
153
- "data-yunui": "agent-timeline-reasoning-content",
154
- className: "border-t border-border/50 px-2.5 pb-2.5 pt-2 text-[12.5px] leading-relaxed text-muted-foreground",
155
- children: renderContent ? renderContent(block.content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: block.content })
156
- }
157
- ) }) : null
222
+ /* @__PURE__ */ jsx(Sparkles, { "aria-hidden": true, size: 14, className: cn("shrink-0", block.active ? "text-primary" : "text-muted-foreground") }),
223
+ block.active ? /* @__PURE__ */ jsx(TextShimmer, { text: block.label, active: true, "data-agent-timeline-active": "true", className: "min-w-0 flex-1 truncate text-[13px]" }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[13px] text-foreground", children: block.label }),
224
+ block.active ? /* @__PURE__ */ jsx("span", { className: "sr-only", children: labels.running ?? "Running" }) : null,
225
+ expandable ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", disclosure.open && "rotate-180") }) : null
158
226
  ]
159
227
  }
160
- ) })
228
+ ),
229
+ expandable ? /* @__PURE__ */ jsx(Collapse, { id: title, open: disclosure.open, children: /* @__PURE__ */ jsx("div", { "data-yunui": "agent-timeline-reasoning-content", className: "ml-8 border-l border-border pl-3 pr-2 py-2 text-sm leading-relaxed text-muted-foreground", children: renderContent ? renderContent(block.content) : /* @__PURE__ */ jsx("div", { className: "whitespace-pre-wrap", children: block.content }) }) }) : null
161
230
  ] });
162
231
  }
163
- function ToolRow({ block, isLast }) {
164
- const [open, setOpen] = useState(false);
232
+ function ToolRow({ block, labels, onToggleRow, onToggleDiff }) {
233
+ const instanceId = useId();
234
+ const expandable = Boolean(block.command || block.output || block.outputContent != null || block.details?.length || block.files?.length);
235
+ const disclosure = useDisclosure({ id: block.id, open: block.open, defaultOpen: block.defaultOpen, onToggleRow });
236
+ const [openDiff, setOpenDiff] = useState(null);
165
237
  const Icon = ICONS[block.icon ?? "tool"];
166
- const error = block.status === "error";
167
- const expandable = !!block.output || !!block.command;
168
- const tone = block.status === "running" ? "running" : error ? "error" : "muted";
169
- return /* @__PURE__ */ jsxs("div", { className: cn("flex gap-2.5", block.indent && "pl-6"), children: [
170
- /* @__PURE__ */ jsx(Rail, { tone, isLast, children: block.status === "running" ? /* @__PURE__ */ jsx(Loader2, { size: 13, className: "animate-spin" }) : /* @__PURE__ */ jsx(Icon, { size: 13, strokeWidth: 1.75 }) }),
171
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1 pb-2", children: [
172
- /* @__PURE__ */ jsxs(
173
- "button",
174
- {
175
- type: "button",
176
- onClick: () => expandable && setOpen(!open),
177
- "aria-expanded": open,
178
- className: cn(
179
- "flex h-[30px] w-full items-center gap-2 rounded-md px-1.5 text-left outline-none transition-colors focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
180
- expandable ? "hover:bg-muted/50 cursor-pointer" : "cursor-default"
181
- ),
182
- children: [
183
- /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[13px] font-medium text-foreground", children: block.verb }),
184
- block.summary && /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate font-mono text-[11.5px] text-muted-foreground", children: block.summary }),
185
- /* @__PURE__ */ jsxs("span", { className: cn("flex shrink-0 items-center gap-2", !block.summary && "ml-auto"), children: [
186
- block.status === "done" && /* @__PURE__ */ jsx(Check, { size: 14, className: "text-(--success)" }),
187
- error && /* @__PURE__ */ jsx("span", { className: "rounded bg-(--error)/10 px-1.5 py-0.5 font-mono text-[10.5px] font-semibold uppercase tracking-wide text-(--error)", children: "error" }),
188
- expandable && /* @__PURE__ */ jsx(Chevron, { open })
189
- ] })
190
- ]
191
- }
192
- ),
193
- /* @__PURE__ */ jsx(Collapse, { open, children: /* @__PURE__ */ jsxs("div", { className: cn("mt-1.5 overflow-hidden rounded-lg border font-mono text-xs", error ? "border-(--error)/20 bg-(--error)/5" : "border-border bg-muted/40"), children: [
194
- block.command && /* @__PURE__ */ jsxs("div", { className: cn("flex items-center gap-1.5 border-b px-3 py-1.5 text-muted-foreground", error ? "border-(--error)/20" : "border-border/60"), children: [
195
- /* @__PURE__ */ jsx("span", { className: "select-none text-muted-foreground/40", children: "$" }),
196
- /* @__PURE__ */ jsx("span", { className: "truncate", children: block.command })
197
- ] }),
198
- /* @__PURE__ */ jsx(
199
- "div",
200
- {
201
- tabIndex: 0,
202
- role: "region",
203
- "aria-label": `${block.verb} output`,
204
- className: cn("max-h-72 overflow-auto whitespace-pre-wrap break-words px-3 py-2.5 leading-relaxed outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset", error ? "text-(--error)" : "text-foreground/80"),
205
- children: block.output || "\u2014"
206
- }
207
- )
208
- ] }) })
209
- ] })
238
+ const detailId = `${instanceId}-tool-${domIdPart(block.id)}`;
239
+ return /* @__PURE__ */ jsxs("div", { className: cn("min-w-0", block.indent && "ml-5"), "data-yunui": "agent-tool-row", children: [
240
+ /* @__PURE__ */ jsxs(
241
+ "button",
242
+ {
243
+ type: "button",
244
+ disabled: !expandable || !disclosure.canToggle,
245
+ "aria-expanded": expandable ? disclosure.open : void 0,
246
+ "aria-controls": expandable ? detailId : void 0,
247
+ onClick: disclosure.toggle,
248
+ className: "group flex min-h-8 w-full min-w-0 items-center gap-2 rounded-lg px-2 text-left transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
249
+ children: [
250
+ /* @__PURE__ */ jsx(Icon, { "aria-hidden": true, size: 14, className: "shrink-0 text-muted-foreground" }),
251
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[13px] font-medium text-foreground", children: block.verb }),
252
+ block.summary || block.command ? /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11.5px] text-muted-foreground", children: block.summary ?? block.command }) : /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1" }),
253
+ statusIcon(block.status),
254
+ /* @__PURE__ */ jsx("span", { className: "sr-only", children: statusText(block.status, labels) }),
255
+ expandable ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", disclosure.open && "rotate-180") }) : null
256
+ ]
257
+ }
258
+ ),
259
+ expandable ? /* @__PURE__ */ jsx(Collapse, { id: detailId, open: disclosure.open, children: /* @__PURE__ */ jsxs("div", { className: "ml-6 mr-2 mt-0.5 border-l border-border/70 py-1.5 pl-3", children: [
260
+ block.command ? /* @__PURE__ */ jsxs("div", { className: "mb-1.5 font-mono text-xs text-foreground/80", children: [
261
+ "$ ",
262
+ block.command
263
+ ] }) : null,
264
+ block.outputContent != null ? /* @__PURE__ */ jsx("div", { role: "region", "aria-label": labels.toolOutput?.(block.verb) ?? `${block.verb} output`, className: "min-w-0", children: block.outputContent }) : block.output ? /* @__PURE__ */ jsx("pre", { role: "region", "aria-label": labels.toolOutput?.(block.verb) ?? `${block.verb} output`, tabIndex: 0, className: "max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-sm bg-muted/30 px-2 py-1.5 font-mono text-xs text-foreground/80", children: block.output }) : null,
265
+ block.details?.length ? /* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-col gap-1", children: block.details.map((detail) => /* @__PURE__ */ jsx("div", { className: cn("flex items-baseline justify-between gap-3 text-xs", toneClass(detail.tone ?? "context"), detail.mono && "font-mono"), children: /* @__PURE__ */ jsx("span", { className: "min-w-0 whitespace-pre-wrap", children: detail.text }) }, detail.id)) }) : null,
266
+ block.files?.length ? /* @__PURE__ */ jsx("div", { className: "mt-2 flex flex-wrap gap-1.5", children: block.files.map((file, fileIndex) => {
267
+ const fileOpen = openDiff === file.id;
268
+ const canShowLines = Boolean(file.lines?.length || onToggleDiff);
269
+ const diffId = `${instanceId}-diff-${fileIndex}-${domIdPart(file.id)}`;
270
+ const chip = /* @__PURE__ */ jsxs(Fragment, { children: [
271
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: file.file }),
272
+ /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-(--success) tabular-nums", children: [
273
+ "+",
274
+ file.additions
275
+ ] }),
276
+ file.deletions ? /* @__PURE__ */ jsxs("span", { className: "shrink-0 text-(--error) tabular-nums", children: [
277
+ "\u2212",
278
+ file.deletions
279
+ ] }) : null
280
+ ] });
281
+ return /* @__PURE__ */ jsxs("span", { className: "min-w-0", children: [
282
+ canShowLines ? /* @__PURE__ */ jsx("button", { type: "button", "aria-expanded": fileOpen, "aria-controls": file.lines?.length ? diffId : void 0, "aria-label": labels.showDiff?.(file.file) ?? `Show diff for ${file.file}`, onClick: () => {
283
+ const next = fileOpen ? null : file.id;
284
+ setOpenDiff(next);
285
+ onToggleDiff?.(file.id, next !== null);
286
+ }, className: "inline-flex max-w-full items-center gap-2 rounded-full bg-muted/50 px-2 py-1 font-mono text-[11px] text-muted-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: chip }) : /* @__PURE__ */ jsx("span", { className: "inline-flex max-w-full items-center gap-2 rounded-full bg-muted/50 px-2 py-1 font-mono text-[11px] text-muted-foreground", children: chip }),
287
+ file.lines?.length ? /* @__PURE__ */ jsx(Collapse, { open: fileOpen, id: diffId, children: /* @__PURE__ */ jsx("pre", { className: "mt-1 max-h-48 overflow-auto rounded-sm bg-muted/30 p-2 font-mono text-[11px]", children: file.lines.map((line) => /* @__PURE__ */ jsxs("span", { className: cn("block whitespace-pre-wrap", toneClass(line.tone)), children: [
288
+ line.text,
289
+ "\n"
290
+ ] }, line.id)) }) }) : null
291
+ ] }, file.id);
292
+ }) }) : null
293
+ ] }) }) : null
210
294
  ] });
211
295
  }
212
- function ApprovalRow({ block, isLast, onApprove, onReject }) {
213
- return /* @__PURE__ */ jsxs("div", { className: "flex gap-2.5", children: [
214
- /* @__PURE__ */ jsx(Rail, { tone: "warn", isLast, children: /* @__PURE__ */ jsx(ShieldAlert, { size: 13, strokeWidth: 1.75 }) }),
215
- /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1 pb-2", children: /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-(--warning)/25 bg-(--warning)/[0.06] px-3 py-2.5", children: [
216
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-[13px] font-medium text-foreground", children: [
217
- /* @__PURE__ */ jsx("span", { children: block.title }),
218
- /* @__PURE__ */ jsx("span", { className: "font-mono text-xs text-muted-foreground", children: block.verb })
219
- ] }),
220
- block.message && /* @__PURE__ */ jsx("p", { className: "mt-1.5 text-[12.5px] text-muted-foreground", children: block.message }),
221
- block.argsText && /* @__PURE__ */ jsx(
222
- "pre",
223
- {
224
- tabIndex: 0,
225
- role: "region",
226
- "aria-label": `${block.title}: ${block.verb}`,
227
- className: "mt-1.5 max-h-40 overflow-auto rounded-md border border-border bg-muted/50 px-3 py-2 font-mono text-[11.5px] text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
228
- children: block.argsText
229
- }
230
- ),
231
- /* @__PURE__ */ jsx("div", { className: "mt-2.5 flex items-center gap-2", children: block.decision ? /* @__PURE__ */ jsx("span", { className: cn("text-xs font-medium", block.decision === "approved" ? "text-(--success)" : "text-(--error)"), children: block.decidedLabel }) : /* @__PURE__ */ jsxs(Fragment, { children: [
232
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onApprove?.(block.id), className: "rounded-md bg-primary px-3 py-1 text-xs font-medium text-primary-foreground outline-none transition-opacity hover:opacity-90 focus-visible:ring-2 focus-visible:ring-ring", children: block.allowLabel }),
233
- /* @__PURE__ */ jsx("button", { type: "button", onClick: () => onReject?.(block.id), className: "rounded-md border border-border px-3 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring", children: block.denyLabel })
234
- ] }) })
235
- ] }) })
296
+ function TaskRow({ block, labels, onToggleRow }) {
297
+ const instanceId = useId();
298
+ const expandable = Boolean(block.details?.length);
299
+ const disclosure = useDisclosure({ id: block.id, open: block.open, defaultOpen: block.defaultOpen, onToggleRow });
300
+ const detailId = `${instanceId}-task-${domIdPart(block.id)}`;
301
+ return /* @__PURE__ */ jsxs("div", { "data-yunui": "agent-task-row", className: "min-w-0", children: [
302
+ /* @__PURE__ */ jsxs(
303
+ "button",
304
+ {
305
+ type: "button",
306
+ disabled: !expandable || !disclosure.canToggle,
307
+ "aria-expanded": expandable ? disclosure.open : void 0,
308
+ "aria-controls": expandable ? detailId : void 0,
309
+ onClick: disclosure.toggle,
310
+ className: "flex min-h-10 w-full min-w-0 items-center gap-2.5 rounded-sm px-2.5 text-left transition-colors hover:bg-muted/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
311
+ children: [
312
+ statusIcon(block.status),
313
+ block.status === "done" || block.status === "failed" || block.status === "cancelled" ? /* @__PURE__ */ jsx("span", { className: cn("shrink-0 text-[11px] font-medium", block.status === "done" ? "text-(--success)" : block.status === "failed" ? "text-(--error)" : "text-muted-foreground"), children: statusText(block.status, labels) }) : /* @__PURE__ */ jsx("span", { className: "sr-only", children: statusText(block.status, labels) }),
314
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate text-[13px] font-medium text-foreground", children: block.label }),
315
+ block.amount != null ? /* @__PURE__ */ jsx("span", { className: "shrink-0 text-xs tabular-nums text-muted-foreground", children: block.amount }) : null,
316
+ block.step !== void 0 && block.status === "running" ? /* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-[11px] tabular-nums text-muted-foreground", children: block.step }) : null,
317
+ expandable ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", disclosure.open && "rotate-180") }) : null
318
+ ]
319
+ }
320
+ ),
321
+ expandable ? /* @__PURE__ */ jsx(Collapse, { id: detailId, open: disclosure.open, children: /* @__PURE__ */ jsx("div", { className: "ml-5 border-l border-border/70 py-1.5 pl-3 pr-2", children: block.details?.map((detail) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 py-1 text-xs", children: [
322
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 text-muted-foreground", children: detail.label }),
323
+ detail.meta != null ? /* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono tabular-nums text-muted-foreground/80", children: detail.meta }) : null
324
+ ] }, detail.id)) }) }) : null
236
325
  ] });
237
326
  }
238
- function AgentTimeline({ blocks, renderContent, onApprove, onReject, className }) {
239
- const visible = blocks.filter((b) => !(b.kind === "reasoning" && !b.content.trim() && !b.active));
327
+ function ApprovalRow({ block, isLast, onApprove, onReject, labels }) {
328
+ return /* @__PURE__ */ jsxs("div", { className: "min-w-0 py-1.5", "data-yunui": "agent-approval-row", "data-last": isLast || void 0, "aria-busy": block.busy || void 0, children: [
329
+ /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [
330
+ /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, size: 14, className: "shrink-0 text-muted-foreground" }),
331
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-[13px] font-medium text-foreground", children: block.title }),
332
+ /* @__PURE__ */ jsx("span", { className: "shrink-0 font-mono text-[11px] text-muted-foreground", children: block.verb }),
333
+ block.decision ? /* @__PURE__ */ jsx(Badge, { variant: block.decision === "approved" ? "success" : "error", children: block.decidedLabel ?? block.decision }) : null
334
+ ] }),
335
+ block.message != null ? /* @__PURE__ */ jsx("p", { className: "ml-6 mt-1 text-[12.5px] text-muted-foreground", children: block.message }) : null,
336
+ block.argsText ? /* @__PURE__ */ jsx("pre", { tabIndex: 0, role: "region", "aria-label": `${block.title}: ${block.verb}`, className: "ml-6 mt-1 max-h-40 overflow-auto whitespace-pre-wrap bg-muted/30 px-2 py-1.5 font-mono text-[11.5px] text-muted-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring", children: block.argsText }) : null,
337
+ !block.decision ? /* @__PURE__ */ jsxs("div", { className: "ml-6 mt-2 flex flex-wrap items-center gap-2", children: [
338
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "primary", disabled: block.disabled || block.busy || !onApprove, onClick: () => {
339
+ if (!block.disabled && !block.busy) onApprove?.(block.id);
340
+ }, children: block.allowLabel }),
341
+ /* @__PURE__ */ jsx(Button, { type: "button", size: "sm", variant: "outline", disabled: block.disabled || block.busy || !onReject, onClick: () => {
342
+ if (!block.disabled && !block.busy) onReject?.(block.id);
343
+ }, children: block.denyLabel }),
344
+ block.busy ? /* @__PURE__ */ jsx("span", { role: "status", className: "text-xs text-muted-foreground", children: labels?.waitingForHost ?? "Waiting for host\u2026" }) : null
345
+ ] }) : null
346
+ ] });
347
+ }
348
+ function AgentTimeline({
349
+ blocks,
350
+ renderContent,
351
+ onApprove,
352
+ onReject,
353
+ labels,
354
+ open,
355
+ defaultOpen = true,
356
+ onOpenChange,
357
+ onToggleRow,
358
+ onToggleDiff,
359
+ className
360
+ }) {
361
+ const contentId = `${useId()}-timeline-content`;
362
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
363
+ const controlled = open !== void 0;
364
+ const isOpen = controlled ? open : internalOpen;
365
+ const canToggle = !controlled || Boolean(onOpenChange);
366
+ const visible = blocks.filter((block) => !(block.kind === "reasoning" && !block.content.trim() && !block.active));
240
367
  if (!visible.length) return null;
241
- return /* @__PURE__ */ jsx("div", { className: cn("flex flex-col", className), children: visible.map((b, i) => {
242
- const isLast = i === visible.length - 1;
243
- switch (b.kind) {
244
- case "reasoning":
245
- return /* @__PURE__ */ jsx(ReasoningRow, { block: b, isLast, renderContent }, b.id);
246
- case "tool":
247
- return /* @__PURE__ */ jsx(ToolRow, { block: b, isLast }, b.id);
248
- case "approval":
249
- return /* @__PURE__ */ jsx(ApprovalRow, { block: b, isLast, onApprove, onReject }, b.id);
250
- default:
251
- return null;
368
+ const counts = {
369
+ steps: visible.length,
370
+ reasoning: visible.filter((block) => block.kind === "reasoning").length,
371
+ tools: visible.filter((block) => block.kind === "tool").length,
372
+ tasks: visible.filter((block) => block.kind === "task").length,
373
+ approvals: visible.filter((block) => block.kind === "approval").length
374
+ };
375
+ const summary = labels?.summary?.(counts) ?? labels?.stepCount?.(counts.steps) ?? (counts.steps ? `${counts.steps} ${counts.steps === 1 ? "step" : "steps"}` : labels?.process ?? "Process");
376
+ const requestOpen = () => {
377
+ if (!canToggle) return;
378
+ const next = !isOpen;
379
+ if (!controlled) setInternalOpen(next);
380
+ onOpenChange?.(next);
381
+ };
382
+ return /* @__PURE__ */ jsxs("div", { className: cn("flex min-w-0 flex-col", className), "data-yunui": "agent-timeline", children: [
383
+ /* @__PURE__ */ jsxs(
384
+ "button",
385
+ {
386
+ type: "button",
387
+ disabled: !canToggle,
388
+ "aria-expanded": isOpen,
389
+ "aria-controls": contentId,
390
+ onClick: requestOpen,
391
+ className: "flex min-h-8 w-fit max-w-full items-center gap-2 rounded-sm px-1.5 text-left text-[13px] font-medium text-muted-foreground transition-colors hover:bg-muted/50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset disabled:cursor-default",
392
+ children: [
393
+ /* @__PURE__ */ jsx(Sparkles, { "aria-hidden": true, className: "h-3.5 w-3.5 shrink-0 text-muted-foreground" }),
394
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: summary }),
395
+ /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, size: 14, className: cn("shrink-0 text-muted-foreground transition-transform", isOpen && "rotate-180") })
396
+ ]
397
+ }
398
+ ),
399
+ /* @__PURE__ */ jsx(Collapse, { open: isOpen, id: contentId, children: /* @__PURE__ */ jsx("div", { className: "mt-1 flex min-w-0 flex-col gap-0.5", children: visible.map((block, index) => {
400
+ if (block.kind === "reasoning") return /* @__PURE__ */ jsx(ReasoningRow, { block, labels: labels ?? {}, onToggleRow, renderContent }, block.id);
401
+ if (block.kind === "tool") return /* @__PURE__ */ jsx(ToolRow, { block, labels: labels ?? {}, onToggleRow, onToggleDiff }, block.id);
402
+ if (block.kind === "task") return /* @__PURE__ */ jsx(TaskRow, { block, labels: labels ?? {}, onToggleRow }, block.id);
403
+ return /* @__PURE__ */ jsx(ApprovalRow, { block, isLast: index === visible.length - 1, onApprove, onReject, labels }, block.id);
404
+ }) }) })
405
+ ] });
406
+ }
407
+ var DEFAULT_LABELS = {
408
+ dismiss: "Dismiss questions",
409
+ back: "Back",
410
+ next: "Next",
411
+ skip: "Skip",
412
+ submit: "Submit answers",
413
+ submitting: "Submitting\u2026",
414
+ otherPlaceholder: "Something else\u2026"
415
+ };
416
+ function domPart(value) {
417
+ return Array.from(value, (character) => character.codePointAt(0)?.toString(16) ?? "0").join("-") || "empty";
418
+ }
419
+ function ApprovalQuestion({
420
+ questions,
421
+ activeQuestionId,
422
+ answers,
423
+ onAnswersChange,
424
+ onActiveQuestionChange,
425
+ onSkip,
426
+ onSubmit,
427
+ onDismiss,
428
+ submitting = false,
429
+ disabled = false,
430
+ labels,
431
+ className
432
+ }) {
433
+ const generatedId = useId();
434
+ const questionIndex = questions.findIndex((question2) => question2.id === activeQuestionId);
435
+ const question = questions[questionIndex];
436
+ if (!question) return null;
437
+ const copy = {
438
+ dismiss: labels?.dismiss ?? DEFAULT_LABELS.dismiss,
439
+ back: labels?.back ?? DEFAULT_LABELS.back,
440
+ next: labels?.next ?? DEFAULT_LABELS.next,
441
+ skip: labels?.skip ?? DEFAULT_LABELS.skip,
442
+ submit: labels?.submit ?? DEFAULT_LABELS.submit,
443
+ submitting: labels?.submitting ?? DEFAULT_LABELS.submitting,
444
+ otherPlaceholder: labels?.otherPlaceholder ?? DEFAULT_LABELS.otherPlaceholder
445
+ };
446
+ const answer = answers[question.id] ?? { optionIds: [] };
447
+ const hasSelection = answer.optionIds.some(
448
+ (id) => question.options.some((option) => option.id === id && !option.disabled)
449
+ );
450
+ const hasOtherText = Boolean(question.other && answer.optionIds.includes(question.other.id) && answer.otherText?.trim());
451
+ const canContinue = question.required === false || hasSelection || hasOtherText;
452
+ const isLast = questionIndex === questions.length - 1;
453
+ const updateAnswer = (next) => {
454
+ onAnswersChange({ ...answers, [question.id]: next });
455
+ };
456
+ const toggleOption = (optionId) => {
457
+ const option = question.options.find((item) => item.id === optionId);
458
+ const isOtherOption = question.other?.id === optionId;
459
+ if (!option && !isOtherOption || option?.disabled) return;
460
+ const current = answer.optionIds;
461
+ const selected = current.includes(optionId);
462
+ const optionIds = question.type === "single" ? [optionId] : selected ? current.filter((id) => id !== optionId) : [...current, optionId];
463
+ updateAnswer({
464
+ ...answer,
465
+ optionIds,
466
+ ...question.type === "single" && question.other && optionId !== question.other.id ? { otherText: "" } : {}
467
+ });
468
+ };
469
+ const continueQuestion = () => {
470
+ if (!canContinue) return;
471
+ if (isLast) {
472
+ onSubmit?.(answers);
473
+ return;
252
474
  }
253
- }) });
475
+ if (onActiveQuestionChange) onActiveQuestionChange(questions[questionIndex + 1].id);
476
+ };
477
+ return /* @__PURE__ */ jsxs("section", { "data-yunui": "approval-question", className: cn("w-full max-w-md rounded-xl border border-border/70 bg-card p-3.5 shadow-none", className), "aria-labelledby": `${generatedId}-title`, "aria-busy": submitting || void 0, children: [
478
+ /* @__PURE__ */ jsxs("div", { className: "mb-2.5 flex items-start justify-between gap-3", children: [
479
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
480
+ /* @__PURE__ */ jsxs("div", { "aria-live": "polite", "aria-atomic": "true", children: [
481
+ /* @__PURE__ */ jsx("p", { className: "mb-1 text-xs text-muted-foreground", children: labels?.progress?.(questionIndex + 1, questions.length) ?? `Question ${questionIndex + 1} of ${questions.length}` }),
482
+ /* @__PURE__ */ jsx("h3", { id: `${generatedId}-title`, className: "text-sm font-semibold text-foreground", children: question.title })
483
+ ] }),
484
+ question.message != null ? /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-muted-foreground", children: question.message }) : null
485
+ ] }),
486
+ onDismiss ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "h-6 w-6 shrink-0 text-muted-foreground", disabled: disabled || submitting, onClick: onDismiss, "aria-label": copy.dismiss, children: /* @__PURE__ */ jsx(X, { "aria-hidden": true, className: "h-3.5 w-3.5" }) }) : null
487
+ ] }),
488
+ /* @__PURE__ */ jsxs("fieldset", { className: "min-w-0", "aria-labelledby": `${generatedId}-title`, children: [
489
+ /* @__PURE__ */ jsx("legend", { className: "sr-only", children: question.title }),
490
+ question.type === "single" ? /* @__PURE__ */ jsxs(
491
+ RadioGroup,
492
+ {
493
+ value: answer.optionIds.find((id) => id === question.other?.id || question.options.some((option) => option.id === id)) ?? "",
494
+ onValueChange: toggleOption,
495
+ disabled: disabled || submitting,
496
+ orientation: "vertical",
497
+ className: "gap-0",
498
+ children: [
499
+ question.options.map((option) => {
500
+ const checked = answer.optionIds.includes(option.id);
501
+ const inputId = `${generatedId}-${domPart(question.id)}-${domPart(option.id)}`;
502
+ const labelId = `${inputId}-label`;
503
+ return /* @__PURE__ */ jsx("div", { className: cn("transition-colors", checked && "bg-muted/50", !option.disabled && !disabled && !submitting && "hover:bg-muted/50"), children: /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: cn("flex min-h-9 cursor-pointer items-start gap-2.5 px-2 py-1.5", (option.disabled || disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
504
+ /* @__PURE__ */ jsx(RadioGroupItem, { id: inputId, value: option.id, disabled: disabled || submitting || option.disabled, "aria-labelledby": labelId, className: "mt-0.5" }),
505
+ /* @__PURE__ */ jsxs("span", { id: labelId, className: "min-w-0 flex-1 text-sm text-foreground", children: [
506
+ /* @__PURE__ */ jsx("span", { className: "block", children: option.label }),
507
+ option.detail != null ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.detail }) : null
508
+ ] })
509
+ ] }) }, option.id);
510
+ }),
511
+ question.other ? (() => {
512
+ const otherSelected = answer.optionIds.includes(question.other.id);
513
+ const otherId = `${generatedId}-${domPart(question.id)}-${domPart(question.other.id)}`;
514
+ const otherLabelId = `${otherId}-label`;
515
+ return /* @__PURE__ */ jsxs("div", { className: cn("transition-colors", otherSelected && "bg-muted/50", !disabled && !submitting && "hover:bg-muted/50"), children: [
516
+ /* @__PURE__ */ jsxs("label", { htmlFor: otherId, className: cn("flex min-h-9 cursor-pointer items-center gap-2.5 px-2 py-1.5 text-sm text-foreground", (disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
517
+ /* @__PURE__ */ jsx(RadioGroupItem, { id: otherId, value: question.other.id, disabled: disabled || submitting, "aria-labelledby": otherLabelId }),
518
+ /* @__PURE__ */ jsx("span", { id: otherLabelId, children: question.other.label })
519
+ ] }),
520
+ otherSelected ? /* @__PURE__ */ jsx(
521
+ "input",
522
+ {
523
+ value: answer.otherText ?? "",
524
+ disabled: disabled || submitting,
525
+ onChange: (event) => updateAnswer({ ...answer, otherText: event.target.value }),
526
+ placeholder: question.other.placeholder ?? copy.otherPlaceholder,
527
+ "aria-label": question.other.placeholder ?? copy.otherPlaceholder,
528
+ className: "mb-2 ml-9 w-[calc(100%-2.75rem)] rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring"
529
+ }
530
+ ) : null
531
+ ] }, question.other.id);
532
+ })() : null
533
+ ]
534
+ }
535
+ ) : /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-0", children: [
536
+ question.options.map((option) => {
537
+ const checked = answer.optionIds.includes(option.id);
538
+ const inputId = `${generatedId}-${domPart(question.id)}-${domPart(option.id)}`;
539
+ const labelId = `${inputId}-label`;
540
+ return /* @__PURE__ */ jsxs("label", { htmlFor: inputId, className: cn("flex min-h-9 cursor-pointer items-start gap-2.5 px-2 py-1.5 transition-colors", checked && "bg-muted/50", !option.disabled && !disabled && !submitting && "hover:bg-muted/50", (option.disabled || disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
541
+ /* @__PURE__ */ jsx(Checkbox, { id: inputId, checked, disabled: disabled || submitting || option.disabled, onCheckedChange: () => toggleOption(option.id), "aria-labelledby": labelId, className: "mt-0.5" }),
542
+ /* @__PURE__ */ jsxs("span", { id: labelId, className: "min-w-0 flex-1 text-sm text-foreground", children: [
543
+ /* @__PURE__ */ jsx("span", { className: "block", children: option.label }),
544
+ option.detail != null ? /* @__PURE__ */ jsx("span", { className: "mt-0.5 block text-xs text-muted-foreground", children: option.detail }) : null
545
+ ] })
546
+ ] }, option.id);
547
+ }),
548
+ question.other ? (() => {
549
+ const otherSelected = answer.optionIds.includes(question.other.id);
550
+ const otherId = `${generatedId}-${domPart(question.id)}-${domPart(question.other.id)}`;
551
+ const otherLabelId = `${otherId}-label`;
552
+ return /* @__PURE__ */ jsxs("div", { className: cn("transition-colors", otherSelected && "bg-muted/50"), children: [
553
+ /* @__PURE__ */ jsxs("label", { htmlFor: otherId, className: cn("flex min-h-9 cursor-pointer items-center gap-2.5 px-2 py-1.5 text-sm text-foreground transition-colors", !disabled && !submitting && "hover:bg-muted/50", (disabled || submitting) && "cursor-not-allowed opacity-50"), children: [
554
+ /* @__PURE__ */ jsx(Checkbox, { id: otherId, checked: otherSelected, disabled: disabled || submitting, onCheckedChange: () => toggleOption(question.other.id), "aria-labelledby": otherLabelId }),
555
+ /* @__PURE__ */ jsx("span", { id: otherLabelId, children: question.other.label })
556
+ ] }),
557
+ otherSelected ? /* @__PURE__ */ jsx(
558
+ "input",
559
+ {
560
+ value: answer.otherText ?? "",
561
+ disabled: disabled || submitting,
562
+ onChange: (event) => updateAnswer({ ...answer, otherText: event.target.value }),
563
+ placeholder: question.other.placeholder ?? copy.otherPlaceholder,
564
+ "aria-label": question.other.placeholder ?? copy.otherPlaceholder,
565
+ className: "mb-2 ml-9 w-[calc(100%-2.75rem)] rounded-md border border-border bg-background px-2.5 py-1.5 text-sm text-foreground outline-none focus-visible:ring-2 focus-visible:ring-ring"
566
+ }
567
+ ) : null
568
+ ] });
569
+ })() : null
570
+ ] })
571
+ ] }),
572
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 flex items-center justify-between gap-2", children: [
573
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: disabled || submitting || questionIndex === 0 || !onActiveQuestionChange, onClick: () => onActiveQuestionChange?.(questions[questionIndex - 1].id), children: copy.back }),
574
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
575
+ /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", disabled: disabled || submitting || !onSkip, onClick: () => onSkip?.(question.id), children: copy.skip }),
576
+ /* @__PURE__ */ jsxs(Button, { type: "button", variant: "primary", size: "sm", disabled: disabled || submitting || !canContinue || (isLast ? !onSubmit : !onActiveQuestionChange), onClick: continueQuestion, children: [
577
+ isLast ? submitting ? copy.submitting : copy.submit : copy.next,
578
+ !isLast ? /* @__PURE__ */ jsx(ArrowRight, { "aria-hidden": true, className: "ml-1 h-3.5 w-3.5" }) : null
579
+ ] })
580
+ ] })
581
+ ] })
582
+ ] });
254
583
  }
255
584
  function AgentRunStatus({
256
585
  label,
257
586
  phase = "thinking",
258
- active = phase !== "waiting",
587
+ active = !["waiting", "completed", "failed", "cancelled"].includes(phase),
588
+ elapsed,
259
589
  className,
260
590
  ...props
261
591
  }) {
592
+ const lastLabel = useRef(label);
593
+ const [leaving, setLeaving] = useState(null);
594
+ const [rolled, setRolled] = useState(false);
595
+ const leaveId = useRef(0);
596
+ useEffect(() => {
597
+ if (lastLabel.current === label) return;
598
+ setLeaving({ id: ++leaveId.current, text: lastLabel.current });
599
+ setRolled(true);
600
+ lastLabel.current = label;
601
+ const timer = setTimeout(() => setLeaving(null), 200);
602
+ return () => clearTimeout(timer);
603
+ }, [label]);
604
+ const terminal = phase === "completed" || phase === "failed" || phase === "cancelled";
605
+ const Icon = phase === "completed" ? Check : phase === "failed" ? CircleAlert : phase === "cancelled" ? X : phase === "waiting" ? Clock3 : phase === "thinking" && active ? Sparkles : active ? Loader2 : Clock3;
262
606
  return /* @__PURE__ */ jsxs(
263
607
  "div",
264
608
  {
@@ -268,535 +612,440 @@ function AgentRunStatus({
268
612
  "data-yunui": "agent-run-status",
269
613
  "data-phase": phase,
270
614
  "data-active": active || void 0,
271
- className: cn(
272
- "flex min-h-9 w-fit max-w-full min-w-0 items-center gap-2 py-1 text-[13.5px] text-muted-foreground",
273
- className
274
- ),
615
+ className: cn("flex min-h-8 w-fit max-w-full min-w-0 items-center gap-2 py-1 text-[13px] text-muted-foreground", className),
275
616
  ...props,
276
617
  children: [
277
618
  /* @__PURE__ */ jsx(
278
- TextShimmer,
279
- {
280
- text: label,
281
- active,
282
- "data-run-status-label": true,
283
- className: "min-w-0 max-w-xl truncate font-medium"
284
- }
285
- ),
286
- /* @__PURE__ */ jsx(
287
- "span",
619
+ Icon,
288
620
  {
289
- "data-run-status-pulse": true,
290
- "aria-hidden": "true",
621
+ "data-run-status-indicator": true,
622
+ "aria-hidden": true,
291
623
  className: cn(
292
- "flex shrink-0 items-center gap-0.5 transition-opacity",
293
- active ? "opacity-80" : "opacity-0"
294
- ),
295
- children: [0, 1, 2].map((index) => /* @__PURE__ */ jsx(
296
- "span",
297
- {
298
- className: "h-1 w-1 rounded-full bg-primary/60 motion-safe:animate-pulse",
299
- style: {
300
- animationDelay: `${index * 180}ms`,
301
- animationDuration: "1.1s"
302
- }
303
- },
304
- index
305
- ))
624
+ "h-3.5 w-3.5 shrink-0",
625
+ active && !terminal && phase === "thinking" ? "text-primary" : "",
626
+ active && !terminal && phase !== "thinking" ? "motion-safe:animate-spin text-primary" : "",
627
+ phase === "completed" ? "text-(--success)" : "",
628
+ phase === "failed" ? "text-(--error)" : ""
629
+ )
306
630
  }
307
- )
631
+ ),
632
+ /* @__PURE__ */ jsxs("span", { className: "yunui-roll min-w-0 max-w-xl", children: [
633
+ leaving ? /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "yunui-roll-out truncate font-medium text-foreground", children: leaving.text }, leaving.id) : null,
634
+ /* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate", rolled && "yunui-roll-in"), children: /* @__PURE__ */ jsx(
635
+ TextShimmer,
636
+ {
637
+ text: label,
638
+ active: active && !terminal,
639
+ "data-run-status-label": true,
640
+ className: "min-w-0 max-w-xl truncate font-medium text-foreground"
641
+ }
642
+ ) }, label)
643
+ ] }),
644
+ elapsed ? /* @__PURE__ */ jsx("span", { "data-run-status-elapsed": true, className: "shrink-0 text-[12px] tabular-nums text-muted-foreground", children: elapsed }) : null
308
645
  ]
309
646
  }
310
647
  );
311
648
  }
312
- function IDBadge({
313
- text,
314
- truncate = true,
315
- size = "sm"
316
- }) {
317
- const [copied, setCopied] = useState(false);
318
- const t = useYunUI().useT("common.badge");
319
- const sm = size === "sm";
320
- const handleCopy = async (e) => {
321
- e.preventDefault();
322
- e.stopPropagation();
323
- if (!await copyToClipboard(text)) return;
324
- setCopied(true);
325
- setTimeout(() => setCopied(false), 1500);
326
- };
327
- return /* @__PURE__ */ jsxs(
328
- "button",
649
+ var CATEGORY_TONE = {
650
+ accent: "bg-accent",
651
+ muted: "bg-muted-foreground",
652
+ warning: "bg-warning-solid-medium"
653
+ };
654
+ function IncludedMark({ included, tone }) {
655
+ return /* @__PURE__ */ jsx(
656
+ "span",
329
657
  {
330
- type: "button",
331
- onClick: handleCopy,
332
- className: `group/badge relative inline-flex items-center rounded-md bg-muted border border-border hover:bg-muted/70 cursor-pointer transition-colors duration-200 overflow-hidden outline-none focus-visible:ring-2 focus-visible:ring-ring ${truncate ? "max-w-full min-w-0" : ""}`,
333
- title: t("clickToCopy", { text }),
334
- "aria-label": t("clickToCopy", { text }),
335
- children: [
336
- /* @__PURE__ */ jsx("span", { className: `font-mono block ${sm ? "px-1.5 py-0 text-[11px] leading-5 text-muted-foreground" : "px-2 py-0.5 text-xs"} ${truncate ? "truncate max-w-full min-w-0" : "whitespace-nowrap"}`, children: text }),
337
- /* @__PURE__ */ jsx("span", { className: `opacity-0 group-hover/badge:opacity-100 absolute right-0 inset-y-0 flex items-center justify-center rounded-r-md bg-muted/90 backdrop-blur-sm transition-opacity duration-200 ${sm ? "w-4" : "w-5"}`, children: copied ? /* @__PURE__ */ jsx(Check, { size: sm ? 9 : 10 }) : /* @__PURE__ */ jsx(Copy, { size: sm ? 9 : 10 }) })
338
- ]
658
+ "aria-hidden": "true",
659
+ className: cn(
660
+ "flex size-[18px] shrink-0 items-center justify-center rounded-[5px] transition-[background-color,color,transform] duration-(--dur-fast)",
661
+ included ? tone === "error" ? "bg-(--error) text-[var(--bg-base)]" : "bg-(--success) text-[var(--bg-base)]" : "bg-muted text-muted-foreground shadow-[0_0_0_1px_var(--border-default)]"
662
+ ),
663
+ style: { transform: included ? "scale(1)" : "scale(0.92)" },
664
+ children: included ? /* @__PURE__ */ jsx(Check, { "aria-hidden": "true", className: "size-3", strokeWidth: 3 }) : null
339
665
  }
340
666
  );
341
667
  }
342
- var CAPABILITY_ICONS = {
343
- streaming: { color: capabilityIconColor("streaming"), icon: Waves },
344
- vision: { color: capabilityIconColor("vision"), icon: Eye },
345
- thinking: { color: capabilityIconColor("thinking"), icon: Brain },
346
- function_calling: { color: capabilityIconColor("function_calling"), icon: Code },
347
- image_edit: { color: capabilityIconColor("image_edit"), icon: Image },
348
- negative_prompt: { color: capabilityIconColor("negative_prompt"), icon: Ban },
349
- seed_control: { color: capabilityIconColor("seed_control"), icon: Fingerprint },
350
- lora: { color: capabilityIconColor("lora"), icon: Layers },
351
- guidance_scale: { color: capabilityIconColor("guidance_scale"), icon: SlidersHorizontal },
352
- strength: { color: capabilityIconColor("strength"), icon: SlidersHorizontal },
353
- batch: { color: capabilityIconColor("batch"), icon: Waves }
354
- };
355
- function ModelCard({
356
- name,
357
- icon,
358
- ids = [],
359
- description,
360
- capabilities = [],
361
- developer,
362
- context,
363
- tier,
364
- price,
365
- nonofficial,
366
- suspended,
668
+ function stateText(state, labels, count) {
669
+ if (state === "busy") return labels.busy ?? "Applying changes\u2026";
670
+ if (state === "applied") return labels.applied?.(count) ?? `${count} ${count === 1 ? "edit" : "edits"} applied`;
671
+ if (state === "error") return labels.error ?? "Could not apply changes";
672
+ if (state === "cancelled") return labels.cancelled ?? "Changes cancelled";
673
+ if (state === "disabled") return labels.disabled ?? "Changes unavailable";
674
+ return null;
675
+ }
676
+ function DiffTable({
677
+ rows,
678
+ selectedIds,
679
+ onSelectionChange,
680
+ onApply,
681
+ onReject,
682
+ state = "idle",
683
+ statusMessage,
684
+ resultCount,
367
685
  labels,
368
- onClick,
369
- className = ""
686
+ className
370
687
  }) {
371
- const { Image } = useYunUI();
372
- const shownCaps = capabilities.filter((c) => CAPABILITY_ICONS[c]).slice(0, 4);
373
- return /* @__PURE__ */ jsxs(
374
- "div",
375
- {
376
- onClick,
377
- role: onClick ? "button" : void 0,
378
- tabIndex: onClick ? 0 : void 0,
379
- onKeyDown: (e) => {
380
- if (onClick && (e.key === "Enter" || e.key === " ")) {
381
- e.preventDefault();
382
- onClick();
383
- }
384
- },
385
- className: `card card-interactive p-4 text-left w-full group cursor-pointer flex flex-col outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background ${className}`,
386
- children: [
387
- /* @__PURE__ */ jsxs("div", { className: "flex items-start justify-between mb-3", children: [
388
- icon,
389
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1", children: shownCaps.map((cap) => {
390
- const { icon: Icon, color } = CAPABILITY_ICONS[cap];
391
- return /* @__PURE__ */ jsx("div", { className: "p-1 rounded-md bg-muted/50", title: cap, children: /* @__PURE__ */ jsx(Icon, { size: 11, className: color }) }, cap);
392
- }) })
393
- ] }),
394
- /* @__PURE__ */ jsx("div", { className: "mb-2", children: /* @__PURE__ */ jsxs("div", { className: "font-medium text-sm group-hover:text-foreground flex items-center gap-1.5", children: [
395
- /* @__PURE__ */ jsx("span", { className: "truncate", children: name }),
396
- nonofficial && /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[10px] px-1.5 py-0.5 rounded badge-warning font-medium whitespace-nowrap", children: labels?.nonofficial ?? "Unofficial" }),
397
- suspended && /* @__PURE__ */ jsxs("span", { className: "shrink-0 inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded badge-warning font-medium whitespace-nowrap", children: [
398
- /* @__PURE__ */ jsx(PauseCircle, { size: 10 }),
399
- labels?.suspended ?? "Suspended"
400
- ] })
401
- ] }) }),
402
- ids.length > 0 && /* @__PURE__ */ jsx("div", { className: "flex flex-wrap items-center gap-1.5 mb-3", children: ids.map((id, idx) => /* @__PURE__ */ jsx(IDBadge, { text: id }, idx)) }),
403
- /* @__PURE__ */ jsx("div", { className: "text-xs text-muted-foreground line-clamp-2 mb-3 min-h-[2.5em]", children: description || /* @__PURE__ */ jsx("span", { className: "opacity-40", children: labels?.noDescription ?? "No description" }) }),
404
- /* @__PURE__ */ jsxs("div", { className: "mt-auto flex flex-wrap items-center justify-between gap-x-3 gap-y-1.5 text-[11px] text-muted-foreground pt-3 border-t border-border", children: [
405
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-1.5 min-w-0", children: [
406
- developer?.iconUrl && /* @__PURE__ */ jsx("div", { className: "rounded-md overflow-hidden bg-muted", style: { width: 12, height: 12 }, children: /* @__PURE__ */ jsx(Image, { src: developer.iconUrl, alt: developer.label, width: 12, height: 12, className: "object-cover" }) }),
407
- developer?.label && /* @__PURE__ */ jsx("span", { className: "truncate min-w-0", children: developer.label })
408
- ] }),
409
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
410
- context && /* @__PURE__ */ jsx("span", { className: "bg-muted px-1.5 py-0.5 rounded-sm font-medium", children: context }),
411
- tier && tier !== "free" && /* @__PURE__ */ jsx("span", { className: "bg-warning-soft text-warning px-1.5 py-0.5 rounded-sm font-medium", children: tier }),
412
- price && /* @__PURE__ */ jsx("span", { className: "font-mono", children: price })
413
- ] })
414
- ] })
415
- ]
416
- }
417
- );
418
- }
419
- function HScrollRow({ children, className }) {
420
- const scrollRef = useRef(null);
421
- const [thumb, setThumb] = useState({ w: 0, x: 0, show: false });
422
- const sync = () => {
423
- const el = scrollRef.current;
424
- if (!el) return;
425
- const { scrollWidth, clientWidth, scrollLeft } = el;
426
- const overflow = scrollWidth - clientWidth;
427
- if (overflow <= 1) {
428
- setThumb((t) => t.show ? { w: 0, x: 0, show: false } : t);
429
- return;
430
- }
431
- const w = Math.max(clientWidth / scrollWidth * clientWidth, 28);
432
- const x = scrollLeft / overflow * (clientWidth - w);
433
- setThumb({ w, x, show: true });
434
- };
435
- useEffect(() => {
436
- const el = scrollRef.current;
437
- if (!el) return;
438
- sync();
439
- el.addEventListener("scroll", sync, { passive: true });
440
- const ro = typeof ResizeObserver !== "undefined" ? new ResizeObserver(sync) : null;
441
- ro?.observe(el);
442
- if (el.firstElementChild) ro?.observe(el.firstElementChild);
443
- return () => {
444
- el.removeEventListener("scroll", sync);
445
- ro?.disconnect();
446
- };
447
- }, []);
448
- const onThumbDown = (e) => {
449
- const el = scrollRef.current;
450
- if (!el) return;
451
- e.preventDefault();
452
- e.currentTarget.setPointerCapture(e.pointerId);
453
- const startX = e.clientX;
454
- const startScroll = el.scrollLeft;
455
- const move = (ev) => {
456
- const { scrollWidth, clientWidth } = el;
457
- const w = Math.max(clientWidth / scrollWidth * clientWidth, 28);
458
- const travel = clientWidth - w;
459
- if (travel <= 0) return;
460
- el.scrollLeft = startScroll + (ev.clientX - startX) / travel * (scrollWidth - clientWidth);
461
- };
462
- const up = () => {
463
- window.removeEventListener("pointermove", move);
464
- window.removeEventListener("pointerup", up);
465
- };
466
- window.addEventListener("pointermove", move);
467
- window.addEventListener("pointerup", up);
688
+ const selected = new Set(selectedIds);
689
+ const changeRows = rows.filter((row) => row.change !== "unchanged");
690
+ const selectableRows = changeRows.filter((row) => !row.disabled);
691
+ const validSelected = selectableRows.filter((row) => selected.has(row.id));
692
+ const selectedValues = validSelected.map((row) => row.id);
693
+ const removals = validSelected.filter((row) => row.change === "remove").length;
694
+ const additions = validSelected.filter((row) => row.change === "add").length;
695
+ const changeCount = removals + additions;
696
+ const locked = state !== "idle";
697
+ const requestStatus = stateText(state, labels ?? {}, resultCount ?? changeCount);
698
+ const toggleRow = (row) => {
699
+ if (locked || row.disabled || row.change === "unchanged" || !onSelectionChange) return;
700
+ const next = new Set(selectedValues);
701
+ if (next.has(row.id)) next.delete(row.id);
702
+ else next.add(row.id);
703
+ onSelectionChange(selectableRows.filter((candidate) => next.has(candidate.id)).map((candidate) => candidate.id));
468
704
  };
469
- return /* @__PURE__ */ jsxs("div", { className: "relative", children: [
470
- /* @__PURE__ */ jsx(
471
- "div",
705
+ const renderRow = (row) => {
706
+ const changed = row.change !== "unchanged";
707
+ const included = changed && !row.disabled && selected.has(row.id);
708
+ const removed = row.change === "remove";
709
+ const interactive = changed && !row.disabled && !locked && Boolean(onSelectionChange);
710
+ const tint = included ? removed ? "bg-error-soft" : "bg-success-soft" : "";
711
+ const cellTone = included ? removed ? "text-error" : "text-success" : "";
712
+ const accessibleLabel = row.accessibleLabel ?? row.primary;
713
+ return /* @__PURE__ */ jsxs(
714
+ "tr",
472
715
  {
473
- ref: scrollRef,
716
+ tabIndex: interactive ? 0 : void 0,
717
+ "aria-label": changed ? labels?.includeRow?.(accessibleLabel) ?? `Include change: ${accessibleLabel}` : void 0,
718
+ "aria-selected": changed ? included : void 0,
719
+ "aria-disabled": changed && !interactive ? true : void 0,
720
+ onClick: interactive ? () => toggleRow(row) : void 0,
721
+ onKeyDown: interactive ? (event) => {
722
+ if (event.key === "Enter" || event.key === " ") {
723
+ event.preventDefault();
724
+ toggleRow(row);
725
+ }
726
+ } : void 0,
474
727
  className: cn(
475
- "overflow-x-auto overflow-y-hidden overscroll-x-contain touch-pan-x [scrollbar-width:none] [-ms-overflow-style:none] [&::-webkit-scrollbar]:hidden",
476
- className
728
+ "border-b border-border transition-[background-color,filter,opacity] duration-(--dur-fast) last:border-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",
729
+ tint,
730
+ interactive && "cursor-pointer hover:brightness-[0.985]"
477
731
  ),
478
- children
479
- }
480
- ),
481
- thumb.show && /* @__PURE__ */ jsx(
482
- "div",
483
- {
484
- onPointerDown: onThumbDown,
485
- role: "scrollbar",
486
- "aria-orientation": "horizontal",
487
- "aria-hidden": true,
488
- className: "absolute bottom-0 left-0 h-1.5 rounded-full bg-muted-foreground/40 hover:bg-muted-foreground/60 active:bg-muted-foreground/70 cursor-grab active:cursor-grabbing touch-none transition-colors",
489
- style: { width: `${thumb.w}px`, transform: `translateX(${thumb.x}px)` }
490
- }
491
- )
492
- ] });
732
+ children: [
733
+ /* @__PURE__ */ jsx("td", { className: cn("px-3 @max-[320px]/diff:px-2 py-2.5 text-[13px] font-medium tabular-nums text-foreground transition-colors duration-(--dur-base)", cellTone), children: row.primary }),
734
+ /* @__PURE__ */ jsx("td", { className: "px-3 @max-[320px]/diff:px-2 py-2.5", children: /* @__PURE__ */ jsxs("span", { className: "inline-flex h-5 min-w-0 max-w-full items-center gap-1.5 rounded-full bg-muted px-2 @max-[320px]/diff:px-1.5 text-[11.5px] font-medium shadow-[0_0_0_1px_var(--border-default)]", children: [
735
+ row.categoryTone ? /* @__PURE__ */ jsx("span", { className: cn("size-1.5 shrink-0 rounded-full", CATEGORY_TONE[row.categoryTone]), "aria-hidden": "true" }) : null,
736
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate text-[var(--text-secondary)]", children: row.category })
737
+ ] }) }),
738
+ /* @__PURE__ */ jsx(
739
+ "td",
740
+ {
741
+ className: cn("px-3 @max-[320px]/diff:px-2 py-2.5 text-[12.5px] text-[var(--text-secondary)] transition-colors duration-(--dur-base)", cellTone, included && removed && "line-through"),
742
+ style: included && removed ? { textDecorationColor: "color-mix(in srgb, var(--error) 50%, transparent)" } : void 0,
743
+ children: /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-2", children: [
744
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: row.secondary }),
745
+ changed ? /* @__PURE__ */ jsx(IncludedMark, { included, tone: removed ? "error" : "success" }) : null
746
+ ] })
747
+ }
748
+ )
749
+ ]
750
+ },
751
+ row.id
752
+ );
753
+ };
754
+ return /* @__PURE__ */ jsx("div", { className: cn("@container/diff w-full max-w-[380px]", className), "data-yunui": "diff-table", "data-diff-state": state, children: /* @__PURE__ */ jsxs("div", { className: "relative overflow-hidden rounded-xl border border-border bg-card shadow-sm", children: [
755
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-3 border-b border-border px-3 py-2.5", children: [
756
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 text-[12.5px] font-medium text-foreground", children: labels?.title ?? "Proposed changes" }),
757
+ state === "idle" && changeCount > 0 ? /* @__PURE__ */ jsx("span", { className: "shrink-0 text-[11px] text-[var(--text-secondary)]", children: labels?.hint ?? "Select the changes to apply" }) : null
758
+ ] }),
759
+ /* @__PURE__ */ jsxs("table", { className: "w-full table-fixed border-collapse text-left", children: [
760
+ /* @__PURE__ */ jsxs("colgroup", { children: [
761
+ /* @__PURE__ */ jsx("col", { className: "w-[34%] @max-[320px]/diff:w-[40%]" }),
762
+ /* @__PURE__ */ jsx("col", { className: "w-[30%] @max-[320px]/diff:w-[28%]" }),
763
+ /* @__PURE__ */ jsx("col", { className: "w-[36%] @max-[320px]/diff:w-[32%]" })
764
+ ] }),
765
+ /* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { className: "border-b border-border", children: [labels?.primaryColumn ?? "Item", labels?.categoryColumn ?? "Category", labels?.secondaryColumn ?? "Details"].map((heading, index) => /* @__PURE__ */ jsx("th", { scope: "col", className: "px-3 @max-[320px]/diff:px-2 py-2.5 whitespace-nowrap text-[12px] font-medium text-[var(--text-secondary)]", children: heading }, index)) }) }),
766
+ /* @__PURE__ */ jsx("tbody", { children: rows.map(renderRow) })
767
+ ] }),
768
+ /* @__PURE__ */ jsx("div", { className: "flex min-h-11 items-center justify-between gap-3 @max-[320px]/diff:flex-wrap border-t border-border px-2.5 py-2", children: state === "idle" ? /* @__PURE__ */ jsxs(Fragment, { children: [
769
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 @max-[320px]/diff:w-full text-[11.5px] tabular-nums text-[var(--text-secondary)]", "aria-live": "polite", children: labels?.selectionSummary?.(removals, additions) ?? `${removals} ${removals === 1 ? "removal" : "removals"} \xB7 ${additions} ${additions === 1 ? "addition" : "additions"}` }),
770
+ /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1.5 @max-[320px]/diff:ml-auto", children: [
771
+ onReject ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-7 rounded-full px-2.5 text-[12px]", onClick: () => onReject(selectedValues), children: labels?.reject ?? "Reject" }) : null,
772
+ /* @__PURE__ */ jsx(
773
+ Button,
774
+ {
775
+ type: "button",
776
+ variant: "primary",
777
+ size: "sm",
778
+ className: "h-7 rounded-full px-3 text-[12px]",
779
+ disabled: !onApply || changeCount === 0,
780
+ onClick: () => {
781
+ if (onApply && changeCount > 0) onApply(selectedValues);
782
+ },
783
+ children: labels?.apply?.(changeCount) ?? `Apply ${changeCount} ${changeCount === 1 ? "change" : "changes"}`
784
+ }
785
+ )
786
+ ] })
787
+ ] }) : /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "min-w-0 text-[11.5px] text-[var(--text-secondary)]", children: statusMessage ?? requestStatus }) })
788
+ ] }) });
493
789
  }
494
- function ModelSelect({
495
- options,
496
- value,
497
- onChange,
498
- className,
790
+ var DEFAULT_LABELS2 = {
791
+ keep: "Keep",
792
+ discard: "Discard",
793
+ placeholder: "Describe edits",
794
+ submitInstruction: "Submit custom instruction",
795
+ customAction: "Custom instruction",
796
+ working: "Working",
797
+ error: "The edit request failed. Original text is unchanged.",
798
+ cancelled: "Edit request cancelled. Original text is unchanged.",
799
+ retry: "Try again",
800
+ showMoreActions: "Show more actions",
801
+ showFewerActions: "Show fewer actions",
802
+ result: "Suggested edit"
803
+ };
804
+ var iconProps = { size: 14, strokeWidth: 1.8, "aria-hidden": true };
805
+ var DEFAULT_ACTIONS = [
806
+ { id: "Explain", action: "Explain", icon: /* @__PURE__ */ jsx(CircleHelp, { ...iconProps }) },
807
+ { id: "Improve", action: "Improve", busyLabel: "Improving", icon: /* @__PURE__ */ jsx(Sparkles, { ...iconProps }) },
808
+ { id: "Shorten", action: "Shorten", busyLabel: "Shortening", icon: /* @__PURE__ */ jsx(Scissors, { ...iconProps }) },
809
+ { id: "Tone", action: "Change tone", busyLabel: "Changing tone", icon: /* @__PURE__ */ jsx(ThumbsUp, { ...iconProps }) },
810
+ { id: "Grammar", action: "Fix grammar", icon: /* @__PURE__ */ jsx(Type, { ...iconProps }) }
811
+ ];
812
+ var useIsomorphicLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
813
+ function SelectionActions({
814
+ lead = "",
815
+ selectedText,
816
+ resultText,
817
+ state = "idle",
818
+ actions = DEFAULT_ACTIONS,
819
+ busyLabel,
499
820
  labels,
500
- pinned,
501
- onTogglePin,
502
- filters,
503
- renderFooter,
504
- renderHeader,
505
- filterResetKey
821
+ disabled = false,
822
+ onAction,
823
+ onAccept,
824
+ onDismiss,
825
+ onRetry,
826
+ className
506
827
  }) {
507
- const L = {
508
- placeholder: "Select a model",
509
- search: "Search models\u2026",
510
- clearSearch: "Clear",
511
- clearFilters: "Clear filters",
512
- all: "All",
513
- pinned: "Pinned",
514
- noResults: "No models found",
515
- ...labels
516
- };
517
- const [isOpen, setIsOpen] = useState(false);
518
- const [search, setSearch] = useState("");
519
- const [activeGroup, setActiveGroup] = useState(null);
520
- const [activeFilters, setActiveFilters] = useState([]);
521
- useEffect(() => {
522
- setSearch("");
523
- setActiveFilters([]);
524
- setActiveGroup(null);
525
- }, [filterResetKey]);
526
- const rootRef = useRef(null);
527
- const inputRef = useRef(null);
528
- const listRef = useRef(null);
529
- const panelRef = useRef(null);
530
- const { shift, maxHeight, placement } = useAnchoredPosition(isOpen, panelRef);
531
- const pinnedSet = useMemo(() => new Set(pinned ?? []), [pinned]);
532
- useDismissOnOutside(isOpen, () => setIsOpen(false), rootRef, { escape: false });
533
- useEffect(() => {
534
- if (!isOpen) return;
535
- const t = setTimeout(() => {
536
- inputRef.current?.focus();
537
- if (value && listRef.current) {
538
- const el = listRef.current.querySelector(`[data-model-id="${CSS.escape(value)}"]`);
539
- el?.scrollIntoView({ block: "nearest" });
540
- }
541
- }, 50);
542
- return () => clearTimeout(t);
543
- }, [isOpen, value]);
544
- const groups = useMemo(() => {
545
- const counts = {};
546
- for (const o of options) counts[o.group] = (counts[o.group] || 0) + 1;
547
- return Object.entries(counts).sort((a, b) => b[1] - a[1]).map(([g]) => g);
548
- }, [options]);
549
- const groupLabel = useMemo(() => {
550
- const m = {};
551
- for (const o of options) if (o.groupLabel) m[o.group] = o.groupLabel;
552
- return m;
553
- }, [options]);
554
- const groupIcon = useMemo(() => {
555
- const m = {};
556
- for (const o of options) if (o.groupIcon && !(o.group in m)) m[o.group] = o.groupIcon;
557
- return m;
558
- }, [options]);
559
- const filtered = useMemo(() => {
560
- const q = search.trim().toLowerCase();
561
- return options.filter((o) => {
562
- if (q) {
563
- const hay = `${o.label} ${o.searchText ?? ""} ${o.group}`.toLowerCase();
564
- if (!hay.includes(q)) return false;
565
- }
566
- if (activeGroup && o.group !== activeGroup) return false;
567
- if (activeFilters.length && filters) {
568
- const fs = filters.filter((f) => activeFilters.includes(f.key));
569
- if (!fs.every((f) => f.match(o))) return false;
828
+ const copy = mergeLabels(DEFAULT_LABELS2, labels);
829
+ const [prompt, setPrompt] = useState("");
830
+ const [expanded, setExpanded] = useState(false);
831
+ const [anchor, setAnchor] = useState({ x: 0, y: 0 });
832
+ const [positioned, setPositioned] = useState(false);
833
+ const [maxBarWidth, setMaxBarWidth] = useState(0);
834
+ const hostRef = useRef(null);
835
+ const selectionRef = useRef(null);
836
+ const barRef = useRef(null);
837
+ const frameRef = useRef(null);
838
+ const previousSelectionRef = useRef(selectedText);
839
+ const place = useCallback(() => {
840
+ if (typeof window === "undefined") return;
841
+ if (frameRef.current) {
842
+ if (frameRef.current.kind === "raf") window.cancelAnimationFrame(frameRef.current.id);
843
+ else window.clearTimeout(frameRef.current.id);
844
+ }
845
+ const measure = () => {
846
+ frameRef.current = null;
847
+ const host = hostRef.current;
848
+ const selected = selectionRef.current;
849
+ if (!host || !selected) return;
850
+ const bounds = selected.getBoundingClientRect();
851
+ const lines = Array.from(selected.getClientRects());
852
+ const lastLine = lines.at(-1);
853
+ const hostBounds = host.getBoundingClientRect();
854
+ if (!lastLine || bounds.width === 0 || bounds.height === 0 || hostBounds.width === 0) {
855
+ setPositioned(false);
856
+ return;
570
857
  }
571
- return true;
572
- });
573
- }, [options, search, activeGroup, activeFilters, filters]);
574
- const pinnedList = filtered.filter((o) => pinnedSet.has(o.id));
575
- const grouped = useMemo(() => {
576
- const acc = {};
577
- for (const o of filtered) {
578
- if (pinnedSet.has(o.id)) continue;
579
- (acc[o.group] ??= []).push(o);
858
+ const availableWidth = Math.max(0, Math.min(hostBounds.width - 16, window.innerWidth - 48));
859
+ setMaxBarWidth((current) => Math.abs(current - availableWidth) < 1 ? current : availableWidth);
860
+ const barWidth = barRef.current?.getBoundingClientRect().width ?? 0;
861
+ const hostPadding = Math.min(8, hostBounds.width / 2);
862
+ const halfBar = Math.min(barWidth / 2, Math.max(0, hostBounds.width / 2 - hostPadding));
863
+ const minX = hostPadding + halfBar;
864
+ const maxX = Math.max(minX, hostBounds.width - hostPadding - halfBar);
865
+ const next = {
866
+ x: Math.round(Math.min(maxX, Math.max(minX, bounds.left - hostBounds.left + bounds.width / 2))),
867
+ y: Math.round(lastLine.bottom - hostBounds.top + 8)
868
+ };
869
+ setAnchor((current) => current.x === next.x && current.y === next.y ? current : next);
870
+ setPositioned(true);
871
+ };
872
+ frameRef.current = typeof window.requestAnimationFrame === "function" ? { id: window.requestAnimationFrame(measure), kind: "raf" } : { id: window.setTimeout(measure, 0), kind: "timeout" };
873
+ }, []);
874
+ useIsomorphicLayoutEffect(() => {
875
+ if (previousSelectionRef.current !== selectedText) {
876
+ previousSelectionRef.current = selectedText;
877
+ setPrompt("");
878
+ setExpanded(false);
580
879
  }
581
- return acc;
582
- }, [filtered, pinnedSet]);
583
- const selected = options.find((o) => o.id === value);
584
- const onWheel = (e) => {
585
- const el = e.currentTarget;
586
- const atTop = el.scrollTop <= 1;
587
- const atBottom = el.scrollTop + el.clientHeight >= el.scrollHeight - 1;
588
- if (atTop && e.deltaY < 0 || atBottom && e.deltaY > 0) e.preventDefault();
589
- };
590
- const select = (id) => {
591
- onChange(id);
592
- setIsOpen(false);
593
- };
594
- const panelMaxHeight = maxHeight == null ? "min(32rem, calc(100dvh - 7rem))" : `min(${maxHeight}px, 32rem, calc(100dvh - 7rem))`;
595
- const flatOptions = useMemo(() => {
596
- const out = [...pinnedList];
597
- for (const opts of Object.values(grouped)) out.push(...opts);
598
- return out;
599
- }, [pinnedList, grouped]);
600
- const [activeIndex, setActiveIndex] = useState(-1);
880
+ place();
881
+ }, [place, selectedText, resultText, state, lead]);
601
882
  useEffect(() => {
602
- setActiveIndex(-1);
603
- }, [isOpen, search, activeGroup, activeFilters]);
604
- const clearActiveOnPointer = () => setActiveIndex((i) => i === -1 ? i : -1);
605
- useEffect(() => {
606
- const id = flatOptions[activeIndex]?.id;
607
- if (!isOpen || !id || !listRef.current) return;
608
- listRef.current.querySelector(`[data-model-id="${CSS.escape(id)}"]`)?.scrollIntoView({ block: "nearest" });
609
- }, [activeIndex, isOpen, flatOptions]);
610
- const activeId = flatOptions[activeIndex]?.id;
611
- const rowDomId = (id) => `yunui-ms-opt-${id.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
612
- const onSearchKeyDown = (e) => {
613
- if (e.key === "ArrowDown") {
614
- e.preventDefault();
615
- setActiveIndex((i) => Math.min(i + 1, flatOptions.length - 1));
616
- } else if (e.key === "ArrowUp") {
617
- e.preventDefault();
618
- setActiveIndex((i) => i < 0 ? flatOptions.length - 1 : Math.max(i - 1, 0));
619
- } else if (e.key === "Enter") {
620
- e.preventDefault();
621
- const o = flatOptions[activeIndex] ?? flatOptions[0];
622
- if (o) select(o.id);
623
- } else if (e.key === "Escape") {
624
- e.preventDefault();
625
- setIsOpen(false);
883
+ const host = hostRef.current;
884
+ const selected = selectionRef.current;
885
+ if (!host) return;
886
+ const resizeObserver = typeof ResizeObserver !== "undefined" ? new ResizeObserver(() => place()) : null;
887
+ if (resizeObserver) {
888
+ resizeObserver.observe(host);
889
+ if (selected) resizeObserver.observe(selected);
890
+ if (barRef.current) resizeObserver.observe(barRef.current);
626
891
  }
892
+ window.addEventListener("resize", place);
893
+ return () => {
894
+ resizeObserver?.disconnect();
895
+ window.removeEventListener("resize", place);
896
+ if (frameRef.current) {
897
+ if (frameRef.current.kind === "raf") window.cancelAnimationFrame(frameRef.current.id);
898
+ else window.clearTimeout(frameRef.current.id);
899
+ frameRef.current = null;
900
+ }
901
+ };
902
+ }, [place]);
903
+ const busy = state === "busy";
904
+ const hasResult = state === "result" && typeof resultText === "string";
905
+ const locked = busy || disabled;
906
+ const visibleText = hasResult ? resultText : selectedText;
907
+ const activity = busyLabel ?? labels?.working ?? DEFAULT_LABELS2.working;
908
+ const run = (action, instruction) => {
909
+ if (locked || !onAction) return;
910
+ setExpanded(false);
911
+ onAction(action, instruction);
627
912
  };
628
- return (
629
- // Fixed-width root so the trigger doesn't grow/shrink as the selected
630
- // label changes; override the width via `className`.
631
- /* @__PURE__ */ jsxs("div", { ref: rootRef, className: cn("relative w-64", className), children: [
632
- /* @__PURE__ */ jsxs(
633
- "button",
634
- {
635
- type: "button",
636
- onClick: () => setIsOpen((o) => !o),
637
- "aria-expanded": isOpen,
638
- "aria-haspopup": "listbox",
639
- className: cn(
640
- "flex items-center gap-2 px-3 py-2 bg-card border border-border rounded-xl text-left group transition-all w-full shadow-sm hover:shadow-md outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
641
- isOpen ? "border-ring/60 ring-2 ring-ring/25" : "border-border hover:border-ring"
642
- ),
643
- children: [
644
- selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
645
- selected.icon,
646
- /* @__PURE__ */ jsx("span", { className: "flex-1 truncate text-sm font-medium", children: selected.label })
647
- ] }) : /* @__PURE__ */ jsx("span", { className: "flex-1 text-sm text-muted-foreground", children: L.placeholder }),
648
- /* @__PURE__ */ jsx(ChevronDown, { size: 14, className: cn("text-muted-foreground transition-transform shrink-0", isOpen && "rotate-180") })
649
- ]
650
- }
651
- ),
652
- isOpen && /* @__PURE__ */ jsxs(
653
- motion.div,
654
- {
655
- ref: panelRef,
656
- initial: { opacity: 0, y: -8, scale: 0.96 },
657
- animate: { opacity: 1, y: 0, scale: 1 },
658
- transition: { duration: 0.16, ease: "easeOut" },
659
- "data-yunui": "model-select-panel",
660
- style: { maxWidth: "calc(100vw - 1rem)", marginLeft: shift, maxHeight: panelMaxHeight },
661
- className: `absolute z-50 left-0 ${placement === "top" ? "bottom-full mb-2 origin-bottom" : "top-full mt-2 origin-top"} w-96 max-w-[calc(100vw-1rem)] flex flex-col bg-popover border border-border rounded-2xl shadow-lg shadow-black/5 text-popover-foreground overflow-hidden`,
662
- children: [
663
- renderHeader && /* @__PURE__ */ jsx("div", { className: "p-2.5 border-b border-border/50", children: renderHeader() }),
664
- /* @__PURE__ */ jsxs("div", { className: "p-2.5 border-b border-border/50", children: [
665
- /* @__PURE__ */ jsxs("div", { className: "relative", children: [
666
- /* @__PURE__ */ jsx(Search, { size: 15, className: "absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground pointer-events-none" }),
667
- /* @__PURE__ */ jsx(
668
- "input",
669
- {
670
- ref: inputRef,
671
- value: search,
672
- onChange: (e) => setSearch(e.target.value),
673
- onKeyDown: onSearchKeyDown,
674
- placeholder: L.search,
675
- "aria-label": L.search,
676
- role: "combobox",
677
- "aria-expanded": isOpen,
678
- "aria-controls": "yunui-ms-listbox",
679
- "aria-activedescendant": activeId ? rowDomId(activeId) : void 0,
680
- className: "w-full pl-9 pr-8 py-2 text-base md:text-sm bg-muted/50 border border-transparent rounded-xl outline-none focus:border-ring focus:bg-background transition-colors"
681
- }
682
- ),
683
- search && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setSearch(""), title: L.clearSearch, "aria-label": L.clearSearch, className: "absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors p-0.5 rounded-md hover:bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ jsx(X, { size: 13 }) })
684
- ] }),
685
- filters && filters.length > 0 && /* @__PURE__ */ jsx(HScrollRow, { className: "mt-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 px-2.5 pb-2 w-max", children: [
686
- filters.map((f) => {
687
- const on = activeFilters.includes(f.key);
688
- return /* @__PURE__ */ jsx("button", { type: "button", title: f.title, "aria-label": f.title, "aria-pressed": on, onClick: () => setActiveFilters((p) => p.includes(f.key) ? p.filter((k) => k !== f.key) : [...p, f.key]), className: cn("shrink-0 p-1 rounded-md transition-colors outline-none focus-visible:ring-2 focus-visible:ring-ring", on ? "bg-foreground/10" : "hover:bg-muted"), children: f.node }, f.key);
689
- }),
690
- activeFilters.length > 0 && /* @__PURE__ */ jsx("button", { type: "button", onClick: () => setActiveFilters([]), title: L.clearFilters, "aria-label": L.clearFilters, className: "shrink-0 p-1 rounded-md text-muted-foreground hover:bg-muted outline-none focus-visible:ring-2 focus-visible:ring-ring", children: /* @__PURE__ */ jsx(X, { size: 14 }) })
691
- ] }) })
692
- ] }),
693
- groups.length > 1 && /* @__PURE__ */ jsx("div", { className: "border-b border-border/50", children: /* @__PURE__ */ jsx(HScrollRow, { children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1 px-2.5 pt-2 pb-2.5 w-max", children: [
694
- /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setActiveGroup(null), "aria-pressed": !activeGroup, className: cn("px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring", !activeGroup ? "bg-foreground text-background" : "bg-muted text-muted-foreground hover:bg-muted/80"), children: [
695
- L.all,
696
- " (",
697
- options.length,
698
- ")"
699
- ] }),
700
- groups.map((g) => /* @__PURE__ */ jsxs("button", { type: "button", onClick: () => setActiveGroup((c) => c === g ? null : g), "aria-pressed": activeGroup === g, className: cn("px-2.5 py-1.5 text-xs rounded-lg font-medium transition-colors flex items-center gap-1.5 whitespace-nowrap outline-none focus-visible:ring-2 focus-visible:ring-ring", activeGroup === g ? "bg-foreground text-background" : "bg-muted text-muted-foreground hover:bg-muted/80"), children: [
701
- groupIcon[g],
702
- groupLabel[g] ?? g
703
- ] }, g))
704
- ] }) }) }),
705
- /* @__PURE__ */ jsxs("div", { ref: listRef, onWheel, onMouseMove: clearActiveOnPointer, id: "yunui-ms-listbox", role: "listbox", className: "flex-1 min-h-0 max-h-96 overflow-y-auto overscroll-contain", children: [
706
- pinnedList.length > 0 && /* @__PURE__ */ jsxs("div", { className: "px-1.5 py-1.5 border-b border-border/40", children: [
707
- /* @__PURE__ */ jsxs("div", { className: "text-[10px] font-medium text-muted-foreground uppercase tracking-wide px-2 mb-1 flex items-center gap-1", children: [
708
- /* @__PURE__ */ jsx(Pin, { size: 9 }),
709
- " ",
710
- L.pinned
711
- ] }),
712
- pinnedList.map((o) => /* @__PURE__ */ jsx(ModelRow, { domId: rowDomId(o.id), active: o.id === activeId, option: o, selected: o.id === value, pinned: true, isPinnable: !!onTogglePin, onSelect: () => select(o.id), onTogglePin: () => onTogglePin?.(o.id) }, o.id))
713
- ] }),
714
- /* @__PURE__ */ jsx("div", { className: "px-1.5 py-1.5", children: Object.entries(grouped).map(([g, opts]) => /* @__PURE__ */ jsxs("div", { className: "mb-3 last:mb-0", children: [
715
- /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 pt-1 pb-1.5", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-xl bg-muted px-3 py-2", children: [
716
- groupIcon[g],
717
- /* @__PURE__ */ jsx("span", { className: "text-xs font-semibold", children: groupLabel[g] ?? g }),
718
- /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 min-w-5 text-center text-[10px] font-semibold tabular-nums text-muted-foreground bg-foreground/10 px-1.5 py-0.5 rounded-md", children: opts.length })
719
- ] }) }),
720
- opts.map((o) => /* @__PURE__ */ jsx(ModelRow, { domId: rowDomId(o.id), active: o.id === activeId, option: o, selected: o.id === value, pinned: false, isPinnable: !!onTogglePin, onSelect: () => select(o.id), onTogglePin: () => onTogglePin?.(o.id) }, o.id))
721
- ] }, g)) }),
722
- filtered.length === 0 && /* @__PURE__ */ jsxs("div", { className: "py-12 text-center text-muted-foreground", children: [
723
- /* @__PURE__ */ jsx(Sparkles, { size: 28, className: "mx-auto mb-3 opacity-40" }),
724
- /* @__PURE__ */ jsx("p", { className: "text-sm", children: L.noResults })
725
- ] })
726
- ] }),
727
- renderFooter && filtered.length > 0 && /* @__PURE__ */ jsx("div", { className: "border-t border-border/50 px-3 py-2 bg-muted/30 text-xs text-muted-foreground", children: renderFooter(filtered.length) })
728
- ]
729
- }
730
- )
731
- ] })
732
- );
733
- }
734
- var ModelRow = memo(function ModelRow2({
735
- option,
736
- selected,
737
- active,
738
- domId,
739
- pinned,
740
- isPinnable,
741
- onSelect,
742
- onTogglePin
743
- }) {
744
- return /* @__PURE__ */ jsxs(
745
- "div",
746
- {
747
- id: domId,
748
- "data-model-id": option.id,
749
- role: "option",
750
- "aria-selected": selected,
751
- onClick: onSelect,
752
- className: cn(
753
- "relative flex items-center gap-3 px-3 py-2.5 rounded-xl cursor-pointer group transition-colors",
754
- // A clear gray fill on both states (selected solid, hover lighter)
755
- // — the bar's opacity then tells selected from merely-hovered.
756
- selected ? "bg-muted" : "hover:bg-muted",
757
- // keyboard highlight (arrow-key navigation)
758
- active && "bg-muted ring-2 ring-ring/40"
759
- ),
760
- children: [
761
- /* @__PURE__ */ jsx(
913
+ const submitPrompt = (event) => {
914
+ event.preventDefault();
915
+ const instruction = prompt.trim();
916
+ if (!instruction) return;
917
+ run(labels?.customAction ?? DEFAULT_LABELS2.customAction, instruction);
918
+ };
919
+ return /* @__PURE__ */ jsx("div", { className: cn("@container/selection w-full max-w-[460px]", className), "data-yunui": "selection-actions", "data-selection-state": state, children: /* @__PURE__ */ jsxs("div", { ref: hostRef, "data-yunui": "selection-actions-host", className: "relative pb-12", children: [
920
+ /* @__PURE__ */ jsxs("p", { className: "text-[13px] leading-relaxed text-foreground", children: [
921
+ lead,
922
+ /* @__PURE__ */ jsxs("span", { ref: selectionRef, "data-yunui": "selection-actions-selected", style: hasResult && resultText === "" ? { display: "inline-block", minWidth: 1, minHeight: "1em" } : void 0, className: "box-decoration-clone rounded-[3px] bg-accent-subtle text-foreground", children: [
923
+ hasResult ? /* @__PURE__ */ jsxs("span", { className: "sr-only", children: [
924
+ copy.result,
925
+ ": "
926
+ ] }) : null,
927
+ visibleText
928
+ ] })
929
+ ] }),
930
+ /* @__PURE__ */ jsx(
931
+ "div",
932
+ {
933
+ "data-yunui": "selection-actions-anchor",
934
+ className: "absolute left-0 top-0 z-10",
935
+ style: {
936
+ transform: `translate3d(${anchor.x}px, ${anchor.y}px, 0) translateX(-50%)`,
937
+ transition: "transform 320ms cubic-bezier(0.77,0,0.175,1), opacity 180ms ease-out",
938
+ opacity: positioned ? 1 : 0,
939
+ pointerEvents: positioned ? "auto" : "none",
940
+ willChange: "transform"
941
+ },
942
+ "aria-hidden": !positioned,
943
+ inert: !positioned,
944
+ children: /* @__PURE__ */ jsxs(
762
945
  "div",
763
946
  {
764
- style: { left: "5px" },
765
- className: cn(
766
- "absolute top-1/2 w-1 h-6 rounded-full bg-primary transition-all duration-150 -translate-y-1/2",
767
- selected ? "opacity-100 translate-x-0" : "opacity-0 -translate-x-1.5 group-hover:opacity-50 group-hover:translate-x-0"
768
- )
769
- }
770
- ),
771
- option.icon,
772
- /* @__PURE__ */ jsxs("div", { className: "flex-1 min-w-0", children: [
773
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5", children: [
774
- /* @__PURE__ */ jsx("span", { className: "font-medium truncate", children: option.label }),
775
- option.badges
776
- ] }),
777
- option.detail
778
- ] }),
779
- option.meta && /* @__PURE__ */ jsx("div", { className: "flex items-center gap-1 shrink-0", children: option.meta }),
780
- isPinnable && /* @__PURE__ */ jsx(
781
- "button",
782
- {
783
- type: "button",
784
- onClick: (e) => {
785
- e.stopPropagation();
786
- onTogglePin();
787
- },
947
+ ref: barRef,
788
948
  className: cn(
789
- "p-1.5 rounded-md transition-all shrink-0 lg:opacity-0 lg:group-hover:opacity-100",
790
- pinned ? "text-foreground opacity-100 hover:bg-muted/50" : "text-muted-foreground/40 opacity-60 hover:text-foreground/70 hover:bg-muted/50"
949
+ "flex w-fit max-w-[calc(100vw-48px)] items-center justify-center gap-0.5 rounded-full border border-border bg-card p-1 font-sans text-foreground shadow-lg",
950
+ state === "error" || state === "cancelled" || busy ? "min-h-9" : "h-9 overflow-hidden"
791
951
  ),
792
- "aria-label": pinned ? "Unpin" : "Pin",
793
- children: /* @__PURE__ */ jsx(Pin, { size: 14, className: pinned ? "fill-current" : "" })
952
+ style: maxBarWidth > 0 ? { maxWidth: maxBarWidth } : void 0,
953
+ children: [
954
+ busy ? /* @__PURE__ */ jsxs("span", { role: "status", className: "inline-flex min-w-0 max-w-full items-center gap-1.5 whitespace-normal break-words px-2.5 py-1 text-[12.5px] text-[var(--text-secondary)]", children: [
955
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "size-3 shrink-0 rounded-full border-[1.5px] border-border border-t-foreground motion-safe:animate-spin" }),
956
+ activity,
957
+ "\u2026"
958
+ ] }) : null,
959
+ hasResult ? /* @__PURE__ */ jsxs(Fragment, { children: [
960
+ /* @__PURE__ */ jsxs(Button, { type: "button", variant: "primary", size: "sm", className: "h-7 shrink-0 rounded-full px-2.5 text-[12.5px]", disabled: disabled || !onAccept, onClick: () => {
961
+ if (resultText !== void 0) onAccept?.(resultText);
962
+ }, children: [
963
+ /* @__PURE__ */ jsx(Check, { "aria-hidden": "true", size: 14 }),
964
+ copy.keep
965
+ ] }),
966
+ onDismiss ? /* @__PURE__ */ jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "h-7 shrink-0 rounded-full px-2.5 text-[12.5px]", disabled, onClick: onDismiss, children: [
967
+ /* @__PURE__ */ jsx(X, { "aria-hidden": "true", size: 14 }),
968
+ copy.discard
969
+ ] }) : null,
970
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mx-0.5 h-4 w-px shrink-0 bg-border" }),
971
+ onRetry ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "size-7 shrink-0 rounded-full p-0", disabled, "aria-label": copy.retry, onClick: onRetry, children: /* @__PURE__ */ jsx(RefreshCw, { "aria-hidden": "true", size: 14 }) }) : null
972
+ ] }) : null,
973
+ state === "error" || state === "cancelled" ? /* @__PURE__ */ jsxs(Fragment, { children: [
974
+ /* @__PURE__ */ jsx("span", { role: "status", className: "min-w-0 max-w-[min(18rem,calc(100vw-8rem))] whitespace-normal break-words px-2 py-1 text-[11px] leading-snug text-[var(--text-secondary)]", children: state === "error" ? labels?.error ?? DEFAULT_LABELS2.error : labels?.cancelled ?? DEFAULT_LABELS2.cancelled }),
975
+ onDismiss ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "h-7 shrink-0 rounded-full px-2.5 text-[12.5px]", disabled, onClick: onDismiss, children: copy.discard }) : null,
976
+ onRetry ? /* @__PURE__ */ jsx(Button, { type: "button", variant: "ghost", size: "icon", className: "size-7 shrink-0 rounded-full p-0", disabled, "aria-label": copy.retry, onClick: onRetry, children: /* @__PURE__ */ jsx(RefreshCw, { "aria-hidden": "true", size: 14 }) }) : null
977
+ ] }) : null,
978
+ state === "idle" ? /* @__PURE__ */ jsxs(Fragment, { children: [
979
+ /* @__PURE__ */ jsx(
980
+ "div",
981
+ {
982
+ className: "flex min-w-0 items-center overflow-hidden transition-[max-width,opacity,transform] duration-(--dur-slow)",
983
+ "aria-hidden": expanded,
984
+ inert: expanded,
985
+ style: { maxWidth: expanded ? 0 : 145, opacity: expanded ? 0 : 1, transform: expanded ? "translateX(-8px)" : "translateX(0)", transitionTimingFunction: "cubic-bezier(0.23,1,0.32,1)" },
986
+ children: /* @__PURE__ */ jsxs("form", { className: "flex h-7 w-[145px] min-w-0 shrink-0 items-center max-[420px]:w-[94px] @max-[360px]/selection:w-[94px]", onSubmit: submitPrompt, children: [
987
+ /* @__PURE__ */ jsx(
988
+ "input",
989
+ {
990
+ value: prompt,
991
+ onChange: (event) => setPrompt(event.target.value),
992
+ "aria-label": copy.placeholder,
993
+ placeholder: copy.placeholder,
994
+ disabled: disabled || !onAction,
995
+ className: "h-7 w-full min-w-0 bg-transparent py-0 pr-2.5 pl-3 text-[12.5px] text-foreground placeholder:text-muted-foreground focus:outline-none max-[420px]:pr-0 max-[420px]:pl-2 @max-[360px]/selection:pr-0 @max-[360px]/selection:pl-2"
996
+ }
997
+ ),
998
+ /* @__PURE__ */ jsx("button", { type: "submit", "aria-label": copy.submitInstruction, disabled: disabled || !onAction || !prompt.trim(), className: "mr-1 flex size-6 shrink-0 items-center justify-center rounded-full text-foreground hover:bg-muted disabled:opacity-40", children: /* @__PURE__ */ jsx(ArrowUp, { "aria-hidden": "true", size: 13 }) })
999
+ ] })
1000
+ }
1001
+ ),
1002
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mx-1 h-4 w-px shrink-0 bg-border" }),
1003
+ /* @__PURE__ */ jsx(
1004
+ "div",
1005
+ {
1006
+ "data-yunui": "selection-actions-scroll",
1007
+ className: "flex min-w-0 flex-1 items-center gap-0.5 overflow-x-auto overflow-y-hidden overscroll-x-contain [scrollbar-width:none]",
1008
+ children: (expanded ? actions : actions.slice(0, 2)).map((item) => /* @__PURE__ */ jsxs(
1009
+ Button,
1010
+ {
1011
+ type: "button",
1012
+ variant: "ghost",
1013
+ size: "sm",
1014
+ className: "h-7 shrink-0 rounded-full px-2.5 text-[12px]",
1015
+ disabled: disabled || !onAction,
1016
+ onClick: () => run(item.action ?? item.id),
1017
+ children: [
1018
+ item.icon,
1019
+ item.label ?? item.id
1020
+ ]
1021
+ },
1022
+ item.id
1023
+ ))
1024
+ }
1025
+ ),
1026
+ actions.length > 2 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1027
+ /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: "mx-0.5 h-4 w-px shrink-0 bg-border" }),
1028
+ /* @__PURE__ */ jsx(
1029
+ "button",
1030
+ {
1031
+ type: "button",
1032
+ "aria-label": expanded ? copy.showFewerActions : copy.showMoreActions,
1033
+ "aria-expanded": expanded,
1034
+ disabled,
1035
+ onClick: () => setExpanded((value) => !value),
1036
+ className: "flex size-7 shrink-0 items-center justify-center rounded-full text-foreground transition-[background-color,transform] hover:bg-muted active:scale-[0.96] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1037
+ children: /* @__PURE__ */ jsx(ChevronRight, { "aria-hidden": "true", size: 14, style: { transform: expanded ? "rotate(180deg)" : void 0 } })
1038
+ }
1039
+ )
1040
+ ] }) : null
1041
+ ] }) : null
1042
+ ]
794
1043
  }
795
1044
  )
796
- ]
797
- }
798
- );
799
- });
1045
+ }
1046
+ )
1047
+ ] }) });
1048
+ }
800
1049
  function ModelManagerCard({
801
1050
  icon,
802
1051
  name,
@@ -847,1011 +1096,6 @@ function ModelManagerCard({
847
1096
  }
848
1097
  );
849
1098
  }
850
- var llmCapabilityConfig = [
851
- { value: "chat", icon: MessageSquare, iconColor: "text-blue-500", color: "bg-blue-500/10 text-blue-700 dark:text-blue-400 border-blue-500/20 hover:bg-blue-500/20" },
852
- { value: "streaming", icon: Waves, iconColor: "text-cyan-500", color: "bg-cyan-500/10 text-cyan-700 dark:text-cyan-400 border-cyan-500/20 hover:bg-cyan-500/20" },
853
- { value: "function_calling", icon: Code, iconColor: "text-purple-500", color: "bg-purple-500/10 text-purple-700 dark:text-purple-400 border-purple-500/20 hover:bg-purple-500/20" },
854
- { value: "vision", icon: Eye, iconColor: "text-amber-500", color: "bg-amber-500/10 text-amber-700 dark:text-amber-400 border-amber-500/20 hover:bg-amber-500/20" },
855
- { value: "thinking", icon: Brain, iconColor: "text-pink-500", color: "bg-pink-500/10 text-pink-700 dark:text-pink-400 border-pink-500/20 hover:bg-pink-500/20" }
856
- ];
857
- var imageCapabilityConfig = [
858
- { value: "image_edit", icon: Pencil, iconColor: "text-orange-500", color: "bg-orange-500/10 text-orange-700 dark:text-orange-400 border-orange-500/20 hover:bg-orange-500/20" },
859
- { value: "negative_prompt", icon: Ban, iconColor: "text-red-500", color: "bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20 hover:bg-red-500/20" },
860
- { value: "seed_control", icon: Fingerprint, iconColor: "text-indigo-500", color: "bg-indigo-500/10 text-indigo-700 dark:text-indigo-400 border-indigo-500/20 hover:bg-indigo-500/20" },
861
- { value: "lora", icon: Layers, iconColor: "text-teal-500", color: "bg-teal-500/10 text-teal-700 dark:text-teal-400 border-teal-500/20 hover:bg-teal-500/20" },
862
- { value: "guidance_scale", icon: SlidersHorizontal, iconColor: "text-yellow-500", color: "bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 border-yellow-500/20 hover:bg-yellow-500/20" },
863
- { value: "strength", icon: SlidersHorizontal, iconColor: "text-orange-500", color: "bg-orange-500/10 text-orange-700 dark:text-orange-400 border-orange-500/20 hover:bg-orange-500/20" },
864
- { value: "batch", icon: Waves, iconColor: "text-cyan-500", color: "bg-cyan-500/10 text-cyan-700 dark:text-cyan-400 border-cyan-500/20 hover:bg-cyan-500/20" }
865
- ];
866
- var audioCapabilityConfig = [
867
- { value: "tts", icon: Mic, iconColor: "text-green-500", color: "bg-green-500/10 text-green-700 dark:text-green-400 border-green-500/20 hover:bg-green-500/20" },
868
- { value: "stt", icon: MessageSquare, iconColor: "text-blue-500", color: "bg-blue-500/10 text-blue-700 dark:text-blue-400 border-blue-500/20 hover:bg-blue-500/20" },
869
- { value: "audio_translation", icon: Waves, iconColor: "text-purple-500", color: "bg-purple-500/10 text-purple-700 dark:text-purple-400 border-purple-500/20 hover:bg-purple-500/20" }
870
- ];
871
- var videoCapabilityConfig = [
872
- { value: "video_generation", icon: Video, iconColor: "text-red-500", color: "bg-red-500/10 text-red-700 dark:text-red-400 border-red-500/20 hover:bg-red-500/20" }
873
- ];
874
- var musicCapabilityConfig = [
875
- { value: "music_generation", icon: Music, iconColor: "text-pink-500", color: "bg-pink-500/10 text-pink-700 dark:text-pink-400 border-pink-500/20 hover:bg-pink-500/20" }
876
- ];
877
- var threedCapabilityConfig = [
878
- { value: "threed_generation", icon: Box, iconColor: "text-indigo-500", color: "bg-indigo-500/10 text-indigo-700 dark:text-indigo-400 border-indigo-500/20 hover:bg-indigo-500/20" }
879
- ];
880
- var realtimeCapabilityConfig = [
881
- { value: "realtime_voice", icon: Radio, iconColor: "text-yellow-500", color: "bg-yellow-500/10 text-yellow-700 dark:text-yellow-400 border-yellow-500/20 hover:bg-yellow-500/20" }
882
- ];
883
- function CapabilitySelector({ selected, onChange, disabled = false, size = "md", columns = 4, modelType }) {
884
- const t = useYunUI().useT("capabilities");
885
- const toggleCapability = (cap) => {
886
- if (disabled) return;
887
- onChange(
888
- selected.includes(cap) ? selected.filter((c) => c !== cap) : [...selected, cap]
889
- );
890
- };
891
- const buildCapabilities = (config) => {
892
- return config.map((cap) => ({
893
- ...cap,
894
- label: t(cap.value)
895
- }));
896
- };
897
- const getCapabilities = () => {
898
- switch (modelType) {
899
- case "image_generation":
900
- return buildCapabilities(imageCapabilityConfig);
901
- case "audio":
902
- case "tts":
903
- case "stt":
904
- return buildCapabilities(audioCapabilityConfig);
905
- case "video":
906
- case "video_generation":
907
- return buildCapabilities(videoCapabilityConfig);
908
- case "music":
909
- case "music_generation":
910
- return buildCapabilities(musicCapabilityConfig);
911
- case "3d":
912
- case "threed":
913
- case "threed_generation":
914
- return buildCapabilities(threedCapabilityConfig);
915
- case "realtime":
916
- case "realtime_voice":
917
- return buildCapabilities(realtimeCapabilityConfig);
918
- default:
919
- return buildCapabilities(llmCapabilityConfig);
920
- }
921
- };
922
- const capabilityOptions = getCapabilities();
923
- const sizeClasses = size === "sm" ? "p-2.5 text-xs gap-1.5" : "p-3 text-sm gap-2";
924
- const iconSize = size === "sm" ? 14 : 16;
925
- const gridColsClass = {
926
- 1: "grid-cols-1",
927
- 2: "grid-cols-2",
928
- 3: "grid-cols-2 sm:grid-cols-3",
929
- 4: "grid-cols-2 sm:grid-cols-4",
930
- 5: "grid-cols-2 sm:grid-cols-3 lg:grid-cols-5",
931
- 6: "grid-cols-2 sm:grid-cols-3 lg:grid-cols-6"
932
- }[columns] || "grid-cols-2 sm:grid-cols-3";
933
- return /* @__PURE__ */ jsx("div", { className: `grid ${gridColsClass} gap-2`, children: capabilityOptions.map((cap) => {
934
- const isSelected = selected.includes(cap.value);
935
- const Icon = cap.icon;
936
- return /* @__PURE__ */ jsxs(
937
- "button",
938
- {
939
- type: "button",
940
- onClick: () => toggleCapability(cap.value),
941
- disabled,
942
- "aria-pressed": isSelected,
943
- className: `rounded-lg border text-left transition-colors flex items-center outline-none focus-visible:ring-2 focus-visible:ring-ring ${sizeClasses} ${isSelected ? cap.color : "bg-background border-border hover:bg-muted/50"} ${disabled ? "opacity-50 cursor-not-allowed" : ""}`,
944
- children: [
945
- /* @__PURE__ */ jsx(Icon, { size: iconSize, className: `${isSelected ? "" : cap.iconColor} shrink-0` }),
946
- /* @__PURE__ */ jsx("span", { className: "font-medium", children: cap.label })
947
- ]
948
- },
949
- cap.value
950
- );
951
- }) });
952
- }
953
- var CAPABILITY_BY_KEY = Object.fromEntries(
954
- [
955
- ...llmCapabilityConfig,
956
- ...imageCapabilityConfig,
957
- ...audioCapabilityConfig,
958
- ...videoCapabilityConfig,
959
- ...musicCapabilityConfig,
960
- ...threedCapabilityConfig,
961
- ...realtimeCapabilityConfig
962
- ].map((c) => [c.value, c])
963
- );
964
- function isKnownCapability(capability) {
965
- return capability in CAPABILITY_BY_KEY;
966
- }
967
- function CapabilityIcon({
968
- capability,
969
- size = 14,
970
- className
971
- }) {
972
- const cfg = CAPABILITY_BY_KEY[capability];
973
- if (!cfg) return null;
974
- const Icon = cfg.icon;
975
- return /* @__PURE__ */ jsx(Icon, { size, className: cn(cfg.iconColor, "shrink-0", className) });
976
- }
977
-
978
- // src/ai/icon-slugs.generated.ts
979
- var PROVIDER_ICON_SLUGS = /* @__PURE__ */ new Set([
980
- "ace",
981
- "adobe",
982
- "adobefirefly",
983
- "agentvoice",
984
- "agui",
985
- "ai2",
986
- "ai21",
987
- "ai302",
988
- "ai360",
989
- "aihubmix",
990
- "aimass",
991
- "aionlabs",
992
- "airjelly",
993
- "aistudio",
994
- "akashchat",
995
- "alephalpha",
996
- "alibaba",
997
- "alibabacloud",
998
- "amp",
999
- "antgroup",
1000
- "anthropic",
1001
- "antigravity",
1002
- "anyscale",
1003
- "apertis",
1004
- "apple",
1005
- "arcee",
1006
- "askverdict",
1007
- "assemblyai",
1008
- "atlascloud",
1009
- "automatic",
1010
- "aws",
1011
- "aya",
1012
- "azure",
1013
- "azureai",
1014
- "baai",
1015
- "baichuan",
1016
- "baidu",
1017
- "baiducloud",
1018
- "bailian",
1019
- "baseten",
1020
- "bedrock",
1021
- "bfl",
1022
- "bilibili",
1023
- "bilibiliindex",
1024
- "bing",
1025
- "briaai",
1026
- "burncloud",
1027
- "bytedance",
1028
- "capcut",
1029
- "centml",
1030
- "cerebras",
1031
- "chatglm",
1032
- "cherrystudio",
1033
- "civitai",
1034
- "claude",
1035
- "claudecode",
1036
- "cline",
1037
- "clipdrop",
1038
- "cloudflare",
1039
- "codebuddy",
1040
- "codeflicker",
1041
- "codegeex",
1042
- "codex",
1043
- "cogvideo",
1044
- "cogview",
1045
- "cohere",
1046
- "colab",
1047
- "cometapi",
1048
- "comfyui",
1049
- "commanda",
1050
- "copilot",
1051
- "copilotkit",
1052
- "coqui",
1053
- "coze",
1054
- "crewai",
1055
- "crusoe",
1056
- "cursor",
1057
- "cybercut",
1058
- "dalle",
1059
- "dbrx",
1060
- "deepai",
1061
- "deepcogito",
1062
- "deepinfra",
1063
- "deepl",
1064
- "deepmind",
1065
- "deepseek",
1066
- "devin",
1067
- "dify",
1068
- "doc2x",
1069
- "docsearch",
1070
- "dolphin",
1071
- "doubao",
1072
- "dreammachine",
1073
- "elevenlabs",
1074
- "elevenx",
1075
- "essentialai",
1076
- "exa",
1077
- "fal",
1078
- "fastgpt",
1079
- "featherless",
1080
- "figma",
1081
- "fireworks",
1082
- "fishaudio",
1083
- "flora",
1084
- "flowith",
1085
- "flux",
1086
- "friendli",
1087
- "gemini",
1088
- "geminicli",
1089
- "gemma",
1090
- "giteeai",
1091
- "github",
1092
- "githubcopilot",
1093
- "glama",
1094
- "glif",
1095
- "glmv",
1096
- "google",
1097
- "googlecloud",
1098
- "goose",
1099
- "gradio",
1100
- "greptile",
1101
- "grok",
1102
- "groq",
1103
- "hailuo",
1104
- "haiper",
1105
- "hedra",
1106
- "hermesagent",
1107
- "higress",
1108
- "huawei",
1109
- "huaweicloud",
1110
- "huggingface",
1111
- "hunyuan",
1112
- "hyperbolic",
1113
- "ibm",
1114
- "ideogram",
1115
- "iflytekcloud",
1116
- "inception",
1117
- "inference",
1118
- "infermatic",
1119
- "infinigence",
1120
- "inflection",
1121
- "internlm",
1122
- "jimeng",
1123
- "jina",
1124
- "junie",
1125
- "kilocode",
1126
- "kimi",
1127
- "kiro",
1128
- "kling",
1129
- "kluster",
1130
- "kolors",
1131
- "krea",
1132
- "kwaikat",
1133
- "kwaipilot",
1134
- "lambda",
1135
- "langchain",
1136
- "langfuse",
1137
- "langgraph",
1138
- "langsmith",
1139
- "leptonai",
1140
- "lg",
1141
- "lightricks",
1142
- "liquid",
1143
- "livekit",
1144
- "llamaindex",
1145
- "llava",
1146
- "llmapi",
1147
- "lmstudio",
1148
- "lobehub",
1149
- "longcat",
1150
- "lovable",
1151
- "lovart",
1152
- "luma",
1153
- "magic",
1154
- "make",
1155
- "manus",
1156
- "mastra",
1157
- "mcp",
1158
- "mcpso",
1159
- "menlo",
1160
- "meshy",
1161
- "meta",
1162
- "metaai",
1163
- "metagpt",
1164
- "microsoft",
1165
- "midjourney",
1166
- "minimax",
1167
- "mistral",
1168
- "modelscope",
1169
- "monica",
1170
- "moonshot",
1171
- "morph",
1172
- "moxt",
1173
- "myshell",
1174
- "n8n",
1175
- "nanobanana",
1176
- "nebius",
1177
- "newapi",
1178
- "notebooklm",
1179
- "notion",
1180
- "nousresearch",
1181
- "nova",
1182
- "novelai",
1183
- "novita",
1184
- "nplcloud",
1185
- "nvidia",
1186
- "obsidian",
1187
- "ollama",
1188
- "openai",
1189
- "openchat",
1190
- "openclaw",
1191
- "opencode",
1192
- "openhands",
1193
- "openhuman",
1194
- "openrouter",
1195
- "openwebui",
1196
- "palm",
1197
- "parasail",
1198
- "perplexity",
1199
- "phidata",
1200
- "phind",
1201
- "pika",
1202
- "pixverse",
1203
- "player2",
1204
- "poe",
1205
- "pollinations",
1206
- "ppio",
1207
- "prunaai",
1208
- "pydanticai",
1209
- "qingyan",
1210
- "qiniu",
1211
- "qoder",
1212
- "qwen",
1213
- "railway",
1214
- "recraft",
1215
- "relace",
1216
- "replicate",
1217
- "replit",
1218
- "reve",
1219
- "roocode",
1220
- "rsshub",
1221
- "runway",
1222
- "rwkv",
1223
- "sambanova",
1224
- "search1api",
1225
- "searchapi",
1226
- "sensenova",
1227
- "siliconcloud",
1228
- "sillytavern",
1229
- "skywork",
1230
- "slock",
1231
- "smithery",
1232
- "snowflake",
1233
- "sophnet",
1234
- "sora",
1235
- "spark",
1236
- "speedai",
1237
- "stability",
1238
- "statecloud",
1239
- "stepfun",
1240
- "straico",
1241
- "streamlake",
1242
- "submodel",
1243
- "suno",
1244
- "sync",
1245
- "targon",
1246
- "tavily",
1247
- "tencent",
1248
- "tencentcloud",
1249
- "tiangong",
1250
- "tii",
1251
- "together",
1252
- "topazlabs",
1253
- "trae",
1254
- "tripo",
1255
- "turix",
1256
- "udio",
1257
- "unstructured",
1258
- "upstage",
1259
- "v0",
1260
- "vectorizerai",
1261
- "venice",
1262
- "vercel",
1263
- "vertexai",
1264
- "vidu",
1265
- "viggle",
1266
- "vllm",
1267
- "volcengine",
1268
- "voyage",
1269
- "wenxin",
1270
- "windsurf",
1271
- "workersai",
1272
- "worldrouter",
1273
- "xai",
1274
- "xiaomimimo",
1275
- "xinference",
1276
- "xpay",
1277
- "xuanyuan",
1278
- "yandex",
1279
- "yi",
1280
- "youmind",
1281
- "yuanbao",
1282
- "zai",
1283
- "zapier",
1284
- "zeabur",
1285
- "zencoder",
1286
- "zenmux",
1287
- "zeroone",
1288
- "zhipu"
1289
- ]);
1290
- var developerIconMap = {
1291
- // Major AI companies
1292
- openai: "openai.webp",
1293
- anthropic: "anthropic.webp",
1294
- google: "google.webp",
1295
- gemini: "gemini.webp",
1296
- gemma: "gemma.webp",
1297
- "deepseek": "deepseek.webp",
1298
- qwen: "qwen.webp",
1299
- mistral: "mistral.webp",
1300
- "01.ai": "zero-one.webp",
1301
- "zero-one": "zero-one.webp",
1302
- xai: "grok.webp",
1303
- // Chinese companies
1304
- zhipu: "zhipu.webp",
1305
- moonshot: "moonshot.webp",
1306
- baichuan: "baichuan.webp",
1307
- alibaba: "dashscope.png",
1308
- minimax: "minimax.webp",
1309
- volcengine: "volcengine.webp",
1310
- bytedance: "byte_dance.webp",
1311
- baidu: "wenxin.webp",
1312
- // baidu-cloud.svg only exists under /icons/providers/; ERNIE/Wenxin icon lives in /icons/models/
1313
- tencent: "dianxin.png",
1314
- doubao: "doubao.webp",
1315
- hunyuan: "hunyuan.webp",
1316
- sparkdesk: "sparkdesk.webp",
1317
- wenxin: "wenxin.webp",
1318
- stepfun: "step.webp",
1319
- // Research organizations
1320
- ai21: "ai21.webp",
1321
- adept: "adept.png",
1322
- aisingapore: "aisingapore.png",
1323
- bigcode: "bigcode.webp",
1324
- codegeex: "codegeex.webp",
1325
- cohere: "cohere.webp",
1326
- dbrx: "dbrx.webp",
1327
- gryphe: "gryphe.png",
1328
- hailuo: "hailuo.webp",
1329
- internlm: "internlm.webp",
1330
- jina: "jina.webp",
1331
- nvidia: "nvidia.webp",
1332
- rakutenai: "rakutenai.png",
1333
- upstage: "upstage.webp",
1334
- voyageai: "voyageai.webp",
1335
- xirang: "xirang.png",
1336
- yi: "zero-one.webp",
1337
- zai: "zai.webp",
1338
- // Image/Audio/Video models
1339
- chatgpt: "chatgpt.jpeg",
1340
- dalle: "dalle.webp",
1341
- flux: "flux.webp",
1342
- ideogram: "ideogram.webp",
1343
- keling: "keling.png",
1344
- luma: "luma.webp",
1345
- midjourney: "midjourney.webp",
1346
- stability: "stability.webp",
1347
- suno: "suno.webp",
1348
- vidu: "vidu.webp",
1349
- tokenflux: "tokenflux.png",
1350
- // Other
1351
- huggingface: "huggingface.webp",
1352
- meta: "llama.png",
1353
- facebook: "llama.png",
1354
- // no meta.png under /icons/models/; Meta/Facebook family uses the Llama icon
1355
- microsoft: "microsoft.webp",
1356
- ibm: "ibm.webp",
1357
- github: "copilot.webp",
1358
- tele: "tele.png",
1359
- ling: "ling.png",
1360
- mimo: "mimo.svg",
1361
- pangu: "pangu.svg",
1362
- xiaomi: "xiaomi.png",
1363
- // Model-family icons with dedicated art under /icons/models/
1364
- claude: "claude.webp",
1365
- codestral: "codestral.png",
1366
- mixtral: "mixtral.png",
1367
- pixtral: "pixtral.png",
1368
- llava: "llava.webp",
1369
- palm: "palm.webp",
1370
- chatglm: "chatglm.webp",
1371
- internvl: "internvl.png",
1372
- minicpm: "minicpm.webp",
1373
- nousresearch: "nousresearch.webp"
1374
- };
1375
- var modelDeveloperPatterns = [
1376
- [/claude|anthropic/, "claude"],
1377
- [/gemini/, "gemini"],
1378
- [/gemma/, "gemma"],
1379
- [/palm|bison/, "palm"],
1380
- [/gpt|openai|davinci|chatgpt|text-embedding|dall-?e|whisper|codex|o[134]-/, "openai"],
1381
- [/glm|chatglm|zhipu|z\.?ai/, "zai"],
1382
- [/minimax|hailuo|abab/, "minimax"],
1383
- [/qwen|qwq|dashscope|alibaba|tongyi/, "qwen"],
1384
- [/deepseek/, "deepseek"],
1385
- [/llama|meta-/, "meta"],
1386
- [/mistral|mixtral|codestral|pixtral|magistral|ministral/, "mistral"],
1387
- [/grok|x-?ai/, "xai"],
1388
- [/moonshot|kimi/, "moonshot"],
1389
- [/doubao/, "doubao"],
1390
- [/hunyuan/, "hunyuan"],
1391
- [/ernie|wenxin|baidu/, "wenxin"],
1392
- [/step-|stepfun/, "stepfun"],
1393
- [/yi-|zero-one|01-ai/, "yi"],
1394
- [/command|cohere/, "cohere"],
1395
- [/phi-\d|microsoft/, "microsoft"],
1396
- [/nemotron|nvidia/, "nvidia"],
1397
- [/internlm|internvl/, "internlm"],
1398
- [/flux/, "flux"]
1399
- ];
1400
- function getModelDeveloperId(...identifiers) {
1401
- const haystack = identifiers.filter(Boolean).join(" ").toLowerCase();
1402
- for (const [pattern, developer] of modelDeveloperPatterns) {
1403
- if (pattern.test(haystack)) return developer;
1404
- }
1405
- const first = identifiers.find((value) => Boolean(value));
1406
- if (!first) return "";
1407
- const parts = first.split("/").filter(Boolean);
1408
- return parts.at(-1) || first;
1409
- }
1410
- function getDeveloperIconPath(developer) {
1411
- if (!developer) return null;
1412
- const file = getDeveloperIconFile(developer);
1413
- return file ? `/icons/models/${file}` : null;
1414
- }
1415
- function getDeveloperIconFile(developer) {
1416
- if (!developer) return null;
1417
- const normalized = developer.toLowerCase().replace(/[-_\s]/g, "");
1418
- if (developerIconMap[normalized]) {
1419
- return developerIconMap[normalized];
1420
- }
1421
- let best = null;
1422
- for (const [key, file] of Object.entries(developerIconMap)) {
1423
- if (key.length >= 3 && normalized.includes(key) && (!best || key.length > best.key.length)) {
1424
- best = { key, file };
1425
- }
1426
- }
1427
- if (best) return best.file;
1428
- return null;
1429
- }
1430
- var providerIconMap = {
1431
- // Major providers
1432
- openai: "openai.webp",
1433
- anthropic: "anthropic.webp",
1434
- google: "google.webp",
1435
- gemini: "gemini.webp",
1436
- deepseek: "deepseek.webp",
1437
- mistral: "mistral.webp",
1438
- groq: "groq.webp",
1439
- grok: "grok.webp",
1440
- xai: "grok.webp",
1441
- // Cloud providers
1442
- azure: "azure.webp",
1443
- "azure-openai": "azure.webp",
1444
- aws: "aws.webp",
1445
- bedrock: "bedrock.webp",
1446
- // Chinese providers
1447
- zhipu: "zhipu.webp",
1448
- moonshot: "moonshot.webp",
1449
- baichuan: "baichuan.webp",
1450
- alibaba: "dashscope.png",
1451
- qwen: "dashscope.png",
1452
- dashscope: "dashscope.png",
1453
- minimax: "minimax.webp",
1454
- volcengine: "volcengine.webp",
1455
- doubao: "doubao.webp",
1456
- bytedance: "bytedance.webp",
1457
- baidu: "baidu-cloud.webp",
1458
- // Other providers
1459
- nvidia: "nvidia.webp",
1460
- huggingface: "huggingface.webp",
1461
- ollama: "ollama.webp",
1462
- lmstudio: "lmstudio.webp",
1463
- openrouter: "openrouter.webp",
1464
- tokenrouter: "tokenrouter.png",
1465
- together: "together.webp",
1466
- cohere: "cohere.webp",
1467
- perplexity: "perplexity.webp",
1468
- fireworks: "fireworks.webp",
1469
- github: "github.webp",
1470
- jina: "jina.webp",
1471
- modelscope: "modelscope.webp",
1472
- siliconflow: "silicon.webp",
1473
- silicon: "silicon.webp",
1474
- cerebras: "cerebras.webp",
1475
- hyperbolic: "hyperbolic.webp",
1476
- lepton: "lepton.png",
1477
- cloudflare: "cloudflare.webp",
1478
- vllm: "vllm.webp",
1479
- zai: "zai.webp",
1480
- // Image/special
1481
- step: "step.webp",
1482
- "zero-one": "zero-one.webp",
1483
- yi: "zero-one.webp",
1484
- infini: "infini.webp",
1485
- // Additional providers / gateways with icons under /icons/providers/.
1486
- // Keys are normalized (lowercase, separators stripped) to match getIconPath().
1487
- xiaomi: "Xiaomi.png",
1488
- intel: "intel.png",
1489
- nomic: "nomic.png",
1490
- mixedbread: "mixedbread.png",
1491
- lanyun: "lanyun.png",
1492
- newapi: "newapi.webp",
1493
- ocoolai: "ocoolai.png",
1494
- ph8: "ph8.png",
1495
- ppio: "ppio.webp",
1496
- vertexai: "vertexai.webp",
1497
- gcp: "vertexai.webp",
1498
- gmi: "gmi.svg",
1499
- "302ai": "302ai.webp",
1500
- aihubmix: "aihubmix.webp",
1501
- dmxapi: "DMXAPI.png",
1502
- bailian: "bailian.webp",
1503
- bigmodel: "bigModel.webp",
1504
- burncloud: "burncloud.webp",
1505
- cherryin: "cherryin.png",
1506
- giteeai: "gitee-ai.webp",
1507
- qiniu: "qiniu.webp",
1508
- sophnet: "sophnet.webp",
1509
- longcat: "longcat.webp",
1510
- alayanew: "alayanew.webp",
1511
- cephalon: "cephalon.jpeg",
1512
- mcprouter: "mcprouter.webp",
1513
- gpustack: "gpustack.svg",
1514
- kwaipilot: "Kwaipilot.webp",
1515
- tencentcloudti: "tencent-cloud-ti.webp",
1516
- neteaseyoudao: "netease-youdao.svg",
1517
- aionly: "aiOnly.webp"
1518
- };
1519
- function getProviderIconOptions() {
1520
- const seen = /* @__PURE__ */ new Set();
1521
- const out = [];
1522
- for (const [key, file] of Object.entries(providerIconMap)) {
1523
- if (seen.has(file)) continue;
1524
- seen.add(file);
1525
- out.push({ value: `/icons/providers/${file}`, label: key });
1526
- }
1527
- return out.sort((a, b) => a.label.localeCompare(b.label));
1528
- }
1529
- function normalizeProviderId(id) {
1530
- return (id ?? "").toLowerCase().replace(/[-_\s]/g, "");
1531
- }
1532
- function getIconPath(providerId) {
1533
- const normalized = normalizeProviderId(providerId);
1534
- if (!normalized) return null;
1535
- if (providerIconMap[normalized]) {
1536
- return `/icons/providers/${providerIconMap[normalized]}`;
1537
- }
1538
- if (PROVIDER_ICON_SLUGS.has(normalized)) {
1539
- return `/icons/providers/${normalized}.webp`;
1540
- }
1541
- let best = null;
1542
- for (const [key, file] of Object.entries(providerIconMap)) {
1543
- if (key.length >= 3 && normalized.includes(key) && (!best || key.length > best.key.length)) {
1544
- best = { key, file };
1545
- }
1546
- }
1547
- if (best) return `/icons/providers/${best.file}`;
1548
- return null;
1549
- }
1550
- function applyIconBase(path, base) {
1551
- if (!path || base === "/icons") return path;
1552
- return path.startsWith("/icons/") ? base + path.slice(6) : path;
1553
- }
1554
- function ProviderIcon({
1555
- provider,
1556
- className = "",
1557
- size = 20,
1558
- rounded = false,
1559
- iconUrl
1560
- }) {
1561
- const { Image, iconBasePath } = useYunUI();
1562
- const [customError, setCustomError] = useState(false);
1563
- const [pathError, setPathError] = useState(false);
1564
- const effectiveIconUrl = iconUrl;
1565
- if (effectiveIconUrl && !customError) {
1566
- if (rounded) {
1567
- const getRadius = () => size <= 14 ? "rounded-sm" : size <= 20 ? "rounded-md" : "rounded-lg";
1568
- return /* @__PURE__ */ jsx(
1569
- "div",
1570
- {
1571
- className: `${getRadius()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1572
- style: { width: size, height: size },
1573
- children: /* @__PURE__ */ jsx("img", { src: effectiveIconUrl, alt: provider, width: size, height: size, className: "object-cover", onError: () => setCustomError(true) })
1574
- }
1575
- );
1576
- }
1577
- return /* @__PURE__ */ jsx("img", { src: effectiveIconUrl, alt: provider, width: size, height: size, className: `object-contain ${className}`, onError: () => setCustomError(true) });
1578
- }
1579
- const iconPath = applyIconBase(getIconPath(provider), iconBasePath);
1580
- const getRadiusClass = () => {
1581
- if (size <= 14) return "rounded-sm";
1582
- if (size <= 20) return "rounded-md";
1583
- return "rounded-lg";
1584
- };
1585
- if (iconPath && !pathError) {
1586
- if (rounded) {
1587
- return /* @__PURE__ */ jsx(
1588
- "div",
1589
- {
1590
- className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1591
- style: { width: size, height: size },
1592
- children: /* @__PURE__ */ jsx(
1593
- Image,
1594
- {
1595
- src: iconPath,
1596
- alt: provider,
1597
- width: size,
1598
- height: size,
1599
- className: "object-cover",
1600
- unoptimized: true,
1601
- onError: () => setPathError(true)
1602
- }
1603
- )
1604
- }
1605
- );
1606
- }
1607
- return /* @__PURE__ */ jsx(
1608
- Image,
1609
- {
1610
- src: iconPath,
1611
- alt: provider,
1612
- width: size,
1613
- height: size,
1614
- className: `object-contain ${className}`,
1615
- unoptimized: true,
1616
- onError: () => setPathError(true)
1617
- }
1618
- );
1619
- }
1620
- if (rounded) {
1621
- return /* @__PURE__ */ jsx(
1622
- "div",
1623
- {
1624
- className: `${getRadiusClass()} bg-muted flex items-center justify-center ${className}`,
1625
- style: { width: size, height: size },
1626
- children: /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-muted-foreground", children: (provider || "?").charAt(0).toUpperCase() })
1627
- }
1628
- );
1629
- }
1630
- return /* @__PURE__ */ jsxs(
1631
- "svg",
1632
- {
1633
- className,
1634
- width: size,
1635
- height: size,
1636
- viewBox: "0 0 24 24",
1637
- fill: "none",
1638
- stroke: "currentColor",
1639
- strokeWidth: "2",
1640
- children: [
1641
- /* @__PURE__ */ jsx("rect", { x: "3", y: "3", width: "18", height: "18", rx: "3" }),
1642
- /* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "3" })
1643
- ]
1644
- }
1645
- );
1646
- }
1647
- function ProviderAvatar({
1648
- provider,
1649
- size = 32,
1650
- className = ""
1651
- }) {
1652
- return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded: true, className });
1653
- }
1654
- var ProviderNames = {
1655
- openai: "OpenAI",
1656
- anthropic: "Anthropic",
1657
- google: "Google",
1658
- gemini: "Gemini",
1659
- deepseek: "DeepSeek",
1660
- mistral: "Mistral",
1661
- xai: "xAI",
1662
- grok: "Grok",
1663
- groq: "Groq",
1664
- azure: "Azure",
1665
- "azure-openai": "Azure OpenAI",
1666
- aws: "AWS",
1667
- bedrock: "Bedrock",
1668
- nvidia: "NVIDIA",
1669
- zhipu: "Zhipu",
1670
- moonshot: "Moonshot",
1671
- alibaba: "Alibaba",
1672
- qwen: "Qwen",
1673
- dashscope: "DashScope",
1674
- minimax: "MiniMax",
1675
- volcengine: "Volcengine",
1676
- doubao: "Doubao",
1677
- bytedance: "ByteDance",
1678
- baidu: "Baidu",
1679
- baichuan: "Baichuan",
1680
- yi: "Yi",
1681
- openrouter: "OpenRouter",
1682
- tokenrouter: "TokenRouter",
1683
- huggingface: "HuggingFace",
1684
- ollama: "Ollama",
1685
- lmstudio: "LM Studio",
1686
- together: "Together",
1687
- cohere: "Cohere",
1688
- perplexity: "Perplexity",
1689
- fireworks: "Fireworks",
1690
- github: "GitHub Models",
1691
- jina: "Jina",
1692
- modelscope: "ModelScope",
1693
- siliconflow: "SiliconFlow",
1694
- silicon: "SiliconFlow",
1695
- cerebras: "Cerebras",
1696
- hyperbolic: "Hyperbolic",
1697
- lepton: "Lepton",
1698
- step: "Step",
1699
- infini: "Infini",
1700
- cloudflare: "Cloudflare",
1701
- vllm: "vLLM",
1702
- zai: "Z.ai",
1703
- // Additional providers / gateways
1704
- xiaomi: "Xiaomi",
1705
- intel: "Intel",
1706
- nomic: "Nomic",
1707
- mixedbread: "Mixedbread",
1708
- lanyun: "Lanyun",
1709
- newapi: "New API",
1710
- ocoolai: "OCoolAI",
1711
- ph8: "PH8",
1712
- ppio: "PPIO",
1713
- vertexai: "Vertex AI",
1714
- gcp: "Vertex AI",
1715
- gmi: "GMI Cloud",
1716
- "302ai": "302.AI",
1717
- aihubmix: "AiHubMix",
1718
- dmxapi: "DMXAPI",
1719
- bailian: "Bailian",
1720
- bigmodel: "BigModel",
1721
- burncloud: "BurnCloud",
1722
- cherryin: "CherryIN",
1723
- giteeai: "Gitee AI",
1724
- qiniu: "Qiniu",
1725
- sophnet: "SophNet",
1726
- longcat: "LongCat",
1727
- alayanew: "AlayaNew",
1728
- cephalon: "Cephalon",
1729
- mcprouter: "MCP Router",
1730
- gpustack: "GPUStack",
1731
- kwaipilot: "Kwaipilot",
1732
- tencentcloudti: "Tencent Cloud TI",
1733
- neteaseyoudao: "NetEase Youdao",
1734
- aionly: "AiOnly"
1735
- };
1736
- function getProviderName(providerId) {
1737
- if (!providerId) return "";
1738
- const normalized = providerId.toLowerCase().replace(/[-_\s]/g, "");
1739
- if (ProviderNames[normalized]) return ProviderNames[normalized];
1740
- let best = null;
1741
- for (const [key, name] of Object.entries(ProviderNames)) {
1742
- if (key.length >= 3 && normalized.includes(key) && (!best || key.length > best.key.length)) {
1743
- best = { key, name };
1744
- }
1745
- }
1746
- if (best) return best.name;
1747
- return providerId.charAt(0).toUpperCase() + providerId.slice(1);
1748
- }
1749
- function getProxiedImageUrl(url) {
1750
- return url;
1751
- }
1752
- function ModelIcon({
1753
- iconUrl,
1754
- developer,
1755
- provider,
1756
- className = "",
1757
- size = 20,
1758
- rounded = false
1759
- }) {
1760
- const { Image, iconBasePath } = useYunUI();
1761
- const [failedPriority, setFailedPriority] = useState(0);
1762
- const getRadiusClass = () => {
1763
- if (size <= 14) return "rounded-sm";
1764
- if (size <= 20) return "rounded-md";
1765
- return "rounded-lg";
1766
- };
1767
- if (failedPriority < 1 && iconUrl && iconUrl.trim()) {
1768
- const src = iconUrl.startsWith("http") ? getProxiedImageUrl(iconUrl) : iconUrl.startsWith("/") ? iconUrl : `${iconBasePath}/models/${iconUrl}`;
1769
- const handleError = () => setFailedPriority(1);
1770
- if (rounded) {
1771
- return /* @__PURE__ */ jsx(
1772
- "div",
1773
- {
1774
- className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1775
- style: { width: size, height: size },
1776
- children: /* @__PURE__ */ jsx(
1777
- Image,
1778
- {
1779
- src,
1780
- alt: provider,
1781
- width: size,
1782
- height: size,
1783
- className: "object-cover",
1784
- unoptimized: true,
1785
- onError: handleError
1786
- }
1787
- )
1788
- }
1789
- );
1790
- }
1791
- return /* @__PURE__ */ jsx(
1792
- Image,
1793
- {
1794
- src,
1795
- alt: provider,
1796
- width: size,
1797
- height: size,
1798
- className: `object-contain ${className}`,
1799
- unoptimized: true,
1800
- onError: handleError
1801
- }
1802
- );
1803
- }
1804
- if (failedPriority < 2 && developer) {
1805
- const developerIconFile = getDeveloperIconFile(developer);
1806
- if (developerIconFile) {
1807
- const src = `${iconBasePath}/models/${developerIconFile}`;
1808
- const handleError = () => setFailedPriority(2);
1809
- if (rounded) {
1810
- return /* @__PURE__ */ jsx(
1811
- "div",
1812
- {
1813
- className: `${getRadiusClass()} overflow-hidden bg-muted flex items-center justify-center ${className}`,
1814
- style: { width: size, height: size },
1815
- children: /* @__PURE__ */ jsx(
1816
- Image,
1817
- {
1818
- src,
1819
- alt: developer,
1820
- width: size,
1821
- height: size,
1822
- className: "object-cover",
1823
- unoptimized: true,
1824
- onError: handleError
1825
- }
1826
- )
1827
- }
1828
- );
1829
- }
1830
- return /* @__PURE__ */ jsx(
1831
- Image,
1832
- {
1833
- src,
1834
- alt: developer,
1835
- width: size,
1836
- height: size,
1837
- className: `object-contain ${className}`,
1838
- unoptimized: true,
1839
- onError: handleError
1840
- }
1841
- );
1842
- }
1843
- }
1844
- return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded, className });
1845
- }
1846
- function ModelAvatar({
1847
- iconUrl,
1848
- developer,
1849
- provider,
1850
- size = 32,
1851
- className = ""
1852
- }) {
1853
- return /* @__PURE__ */ jsx(ModelIcon, { iconUrl, developer, provider, size, rounded: true, className });
1854
- }
1855
1099
  function ProviderIconImg({ provider, size = 16 }) {
1856
1100
  return /* @__PURE__ */ jsx(ProviderIcon, { provider, size, rounded: true });
1857
1101
  }
@@ -1884,273 +1128,23 @@ var variants = {
1884
1128
  ghost: "hover:bg-accent hover:text-accent-foreground",
1885
1129
  secondary: "border border-border bg-secondary text-secondary-foreground hover:bg-accent hover:text-accent-foreground"
1886
1130
  };
1131
+ var sizes = {
1132
+ sm: "gap-1 px-2 py-1.5 text-xs",
1133
+ icon: "p-1.5 [&_svg]:size-5",
1134
+ "icon-sm": "p-1.5 [&_svg]:size-4.5",
1135
+ "icon-xs": "p-1 [&_svg]:size-4"
1136
+ };
1887
1137
  var buttonVariants = cva(
1888
- "inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-100 disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1138
+ "inline-flex items-center justify-center rounded-md p-2 text-sm font-medium transition-colors duration-(--dur-fast) disabled:pointer-events-none disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1889
1139
  {
1890
1140
  variants: {
1891
1141
  variant: variants,
1892
1142
  // fumadocs use `color` instead of `variant`
1893
1143
  color: variants,
1894
- size: {
1895
- sm: "gap-1 px-2 py-1.5 text-xs",
1896
- icon: "p-1.5 [&_svg]:size-5",
1897
- "icon-sm": "p-1.5 [&_svg]:size-4.5",
1898
- "icon-xs": "p-1 [&_svg]:size-4"
1899
- }
1144
+ size: sizes
1900
1145
  }
1901
1146
  }
1902
1147
  );
1903
- function LanguageSwitcher({
1904
- locales,
1905
- currentLocale,
1906
- onChange,
1907
- variant = "icon",
1908
- align = "right",
1909
- label = "Language",
1910
- pending = false,
1911
- className = ""
1912
- }) {
1913
- const [isOpen, setIsOpen] = useState(false);
1914
- const containerRef = useRef(null);
1915
- const triggerRef = useRef(null);
1916
- const panelRef = useRef(null);
1917
- const { shift, maxHeight, placement } = useAnchoredPosition(isOpen, panelRef);
1918
- useDismissOnOutside(isOpen, () => setIsOpen(false), containerRef, { escape: false });
1919
- useEffect(() => {
1920
- if (!isOpen) return;
1921
- const onKey = (e) => {
1922
- if (e.key === "Escape") {
1923
- setIsOpen(false);
1924
- triggerRef.current?.focus();
1925
- }
1926
- };
1927
- document.addEventListener("keydown", onKey);
1928
- return () => document.removeEventListener("keydown", onKey);
1929
- }, [isOpen]);
1930
- const handleLocaleChange = (newLocale) => {
1931
- if (newLocale === currentLocale || pending) return;
1932
- setIsOpen(false);
1933
- onChange(newLocale);
1934
- };
1935
- const currentLabel = locales.find((l) => l.value === currentLocale)?.label ?? currentLocale;
1936
- return (
1937
- // inline-flex so the root shrink-wraps the trigger; a block root filled the row and made the
1938
- // right-0 dropdown anchor to the row's far edge instead of the trigger.
1939
- /* @__PURE__ */ jsxs("div", { ref: containerRef, className: `relative inline-flex ${className}`, children: [
1940
- variant === "pill" ? /* @__PURE__ */ jsxs(
1941
- "button",
1942
- {
1943
- ref: triggerRef,
1944
- onClick: () => setIsOpen(!isOpen),
1945
- className: "flex items-center gap-1.5 h-9 px-2.5 sm:px-3 rounded-full text-sm font-medium transition-all bg-(--bg-elevated) hover:bg-(--bg-elevated)/80 border border-(--border-hairline) text-(--text-secondary) hover:text-(--text-primary) disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
1946
- disabled: pending,
1947
- "aria-label": label,
1948
- "aria-expanded": isOpen,
1949
- "aria-haspopup": "listbox",
1950
- children: [
1951
- /* @__PURE__ */ jsx(Globe, { size: 14, className: "shrink-0" }),
1952
- /* @__PURE__ */ jsx("span", { className: "whitespace-nowrap", children: currentLabel })
1953
- ]
1954
- }
1955
- ) : /* @__PURE__ */ jsx(
1956
- "button",
1957
- {
1958
- ref: triggerRef,
1959
- onClick: () => setIsOpen(!isOpen),
1960
- className: "w-9 h-9 rounded-lg flex items-center justify-center hover:bg-foreground/5 transition-colors disabled:opacity-50 outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background",
1961
- disabled: pending,
1962
- "aria-label": label,
1963
- "aria-expanded": isOpen,
1964
- "aria-haspopup": "listbox",
1965
- children: /* @__PURE__ */ jsx(Globe, { className: "h-[1.2rem] w-[1.2rem]" })
1966
- }
1967
- ),
1968
- isOpen && /* @__PURE__ */ jsx(
1969
- "div",
1970
- {
1971
- ref: panelRef,
1972
- style: { marginLeft: shift, maxHeight },
1973
- className: `absolute ${align === "left" ? "left-0" : "right-0"} ${placement === "top" ? "bottom-full mb-2 origin-bottom" : "top-full mt-2 origin-top"} z-50 flex flex-col overflow-hidden rounded-2xl border border-border bg-popover/95 backdrop-blur-2xl text-popover-foreground shadow-lg shadow-black/5 animate-in fade-in-0 zoom-in-95 duration-200`,
1974
- children: /* @__PURE__ */ jsx("div", { className: "p-1 flex-1 min-h-0 overflow-y-auto", children: locales.map((lang) => /* @__PURE__ */ jsx(
1975
- "button",
1976
- {
1977
- onClick: () => handleLocaleChange(lang.value),
1978
- className: `dropdown-item w-full text-left ${currentLocale === lang.value ? "active" : ""}`,
1979
- children: /* @__PURE__ */ jsx("span", { className: "flex-1", children: lang.label })
1980
- },
1981
- lang.value
1982
- )) })
1983
- }
1984
- )
1985
- ] })
1986
- );
1987
- }
1988
- function Navbar({
1989
- appName,
1990
- logoSrc = "/favicon.ico",
1991
- links = [],
1992
- currentPath = "/",
1993
- variant = "public",
1994
- labels,
1995
- languageSwitcher,
1996
- themeToggle,
1997
- homeHref = "/",
1998
- loginHref = "/login",
1999
- signupHref = "/signup",
2000
- account,
2001
- brand,
2002
- actions,
2003
- mobileMenuHeader,
2004
- mobileMenuFooter,
2005
- label,
2006
- className
2007
- }) {
2008
- const { Link, Image } = useYunUI();
2009
- const [scrollSection, setScrollSection] = useState("");
2010
- const [menuOpen, setMenuOpen] = useState(false);
2011
- const signIn = labels?.signIn ?? "Sign In";
2012
- const signUp = labels?.signUp ?? "Sign Up";
2013
- const menuLabel = labels?.menu ?? "Menu";
2014
- const activeSection = useMemo(() => {
2015
- return currentPath === "/" ? scrollSection : "";
2016
- }, [currentPath, scrollSection]);
2017
- useEffect(() => {
2018
- if (currentPath !== "/") return;
2019
- const sections = document.querySelectorAll("section[id]");
2020
- if (sections.length === 0) return;
2021
- const handleScroll = () => {
2022
- const scrollPosition = window.scrollY + 150;
2023
- let currentSection = "";
2024
- sections.forEach((section) => {
2025
- const sectionTop = section.offsetTop;
2026
- const sectionHeight = section.offsetHeight;
2027
- if (scrollPosition >= sectionTop && scrollPosition < sectionTop + sectionHeight) {
2028
- currentSection = `#${section.id}`;
2029
- }
2030
- });
2031
- setScrollSection(currentSection);
2032
- };
2033
- handleScroll();
2034
- let ticking = false;
2035
- const onScroll = () => {
2036
- if (!ticking) {
2037
- window.requestAnimationFrame(() => {
2038
- handleScroll();
2039
- ticking = false;
2040
- });
2041
- ticking = true;
2042
- }
2043
- };
2044
- window.addEventListener("scroll", onScroll, { passive: true });
2045
- return () => window.removeEventListener("scroll", onScroll);
2046
- }, [currentPath]);
2047
- const isActive = (path) => {
2048
- if (currentPath === path) return true;
2049
- if (path.startsWith("/#")) {
2050
- return currentPath === "/" && activeSection === path.slice(1);
2051
- }
2052
- return false;
2053
- };
2054
- return /* @__PURE__ */ jsxs(
2055
- "nav",
2056
- {
2057
- style: { top: "max(1.5rem, env(safe-area-inset-top))" },
2058
- "aria-label": label,
2059
- className: `fixed inset-x-0 mx-auto z-50 px-6 py-2.5 max-w-6xl w-[calc(100%-48px)] bg-background/80 backdrop-blur-xl border border-border rounded-full shadow-md flex items-center justify-between${className ? ` ${className}` : ""}`,
2060
- children: [
2061
- /* @__PURE__ */ jsx(Link, { href: homeHref, className: "flex items-center gap-2 min-w-0 rounded-lg px-2 py-1 -mx-2 hover:bg-foreground/5 transition-colors duration-200", children: brand ?? /* @__PURE__ */ jsxs(Fragment, { children: [
2062
- /* @__PURE__ */ jsx(Image, { src: logoSrc, alt: appName, width: 28, height: 28, className: "w-7 h-7 shrink-0" }),
2063
- /* @__PURE__ */ jsx("span", { className: "font-semibold text-sm tracking-tight truncate", children: appName })
2064
- ] }) }),
2065
- variant === "public" && /* @__PURE__ */ jsx("div", { className: "hidden md:flex items-center gap-6 lg:gap-8 absolute left-1/2 -translate-x-1/2", children: links.map((link) => /* @__PURE__ */ jsxs(
2066
- Link,
2067
- {
2068
- href: link.href,
2069
- className: "group relative px-2 lg:px-3 py-2 whitespace-nowrap min-w-15 text-center",
2070
- children: [
2071
- /* @__PURE__ */ jsx("span", { className: `text-sm relative z-10 ${isActive(link.href) ? "text-foreground font-medium" : "text-muted-foreground"}`, children: link.label }),
2072
- /* @__PURE__ */ jsx("span", { className: `absolute bottom-1.5 left-1/2 -translate-x-1/2 h-0.5 bg-foreground rounded-full transition-all duration-200 yunui-accent-bg ${isActive(link.href) ? "w-8" : "w-0 group-hover:w-8"}` })
2073
- ]
2074
- },
2075
- link.href
2076
- )) }),
2077
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1.5 shrink-0", children: [
2078
- actions && /* @__PURE__ */ jsx("span", { className: "hidden md:flex items-center gap-1.5", children: actions }),
2079
- languageSwitcher && /* @__PURE__ */ jsx("span", { className: "hidden md:flex items-center gap-1.5", children: languageSwitcher }),
2080
- themeToggle ?? /* @__PURE__ */ jsx(ThemeToggle, { variant: "pill" }),
2081
- variant !== "minimal" && account,
2082
- variant !== "minimal" && !account && /* @__PURE__ */ jsxs(Fragment, { children: [
2083
- /* @__PURE__ */ jsx(
2084
- Link,
2085
- {
2086
- href: loginHref,
2087
- className: "hidden md:block text-sm text-muted-foreground hover:text-foreground transition-colors duration-200 py-2 whitespace-nowrap min-w-15 text-center",
2088
- children: signIn
2089
- }
2090
- ),
2091
- /* @__PURE__ */ jsx(
2092
- Link,
2093
- {
2094
- href: signupHref,
2095
- className: "hidden md:inline-block px-4 py-2 bg-foreground text-background text-sm font-medium rounded-lg hover:bg-foreground/90 hover:shadow-md transition-all duration-200 whitespace-nowrap min-w-20 text-center yunui-accent-bg yunui-accent-on",
2096
- children: signUp
2097
- }
2098
- )
2099
- ] }),
2100
- variant === "public" && /* @__PURE__ */ jsx(
2101
- "button",
2102
- {
2103
- type: "button",
2104
- onClick: () => setMenuOpen((o) => !o),
2105
- className: "md:hidden w-9 h-9 rounded-full flex items-center justify-center hover:bg-foreground/5 transition-colors",
2106
- "aria-label": menuLabel,
2107
- "aria-expanded": menuOpen,
2108
- children: menuOpen ? /* @__PURE__ */ jsx(X, { className: "w-5 h-5" }) : /* @__PURE__ */ jsx(Menu, { className: "w-5 h-5" })
2109
- }
2110
- )
2111
- ] }),
2112
- variant === "public" && menuOpen && /* @__PURE__ */ jsxs(Fragment, { children: [
2113
- /* @__PURE__ */ jsx("div", { className: "md:hidden fixed inset-0 -z-10", "aria-hidden": "true", onClick: () => setMenuOpen(false) }),
2114
- /* @__PURE__ */ jsxs("div", { className: "md:hidden absolute top-full left-0 right-0 mt-3 p-2 bg-popover border border-border rounded-2xl shadow-lg shadow-black/5 flex flex-col gap-0.5", children: [
2115
- mobileMenuHeader,
2116
- links.map((link) => /* @__PURE__ */ jsx(
2117
- Link,
2118
- {
2119
- href: link.href,
2120
- onClick: () => setMenuOpen(false),
2121
- className: `px-4 py-2.5 rounded-xl text-sm transition-colors hover:bg-foreground/5 ${isActive(link.href) ? "text-foreground font-medium" : "text-muted-foreground"}`,
2122
- children: link.label
2123
- },
2124
- link.href
2125
- )),
2126
- /* @__PURE__ */ jsx("div", { className: "my-1 border-t border-border" }),
2127
- mobileMenuFooter ?? (languageSwitcher && /* @__PURE__ */ jsx("div", { className: "px-2 py-1.5", children: languageSwitcher })),
2128
- !account && /* @__PURE__ */ jsxs(Fragment, { children: [
2129
- /* @__PURE__ */ jsx(
2130
- Link,
2131
- {
2132
- href: loginHref,
2133
- onClick: () => setMenuOpen(false),
2134
- className: "px-4 py-2.5 rounded-xl text-sm text-muted-foreground transition-colors hover:bg-foreground/5",
2135
- children: signIn
2136
- }
2137
- ),
2138
- /* @__PURE__ */ jsx(
2139
- Link,
2140
- {
2141
- href: signupHref,
2142
- onClick: () => setMenuOpen(false),
2143
- className: "mt-0.5 px-4 py-2.5 rounded-xl text-sm font-medium text-center bg-foreground text-background hover:bg-foreground/90 transition-colors yunui-accent-bg yunui-accent-on",
2144
- children: signUp
2145
- }
2146
- )
2147
- ] })
2148
- ] })
2149
- ] })
2150
- ]
2151
- }
2152
- );
2153
- }
2154
1148
  function AccountMenu({
2155
1149
  user,
2156
1150
  items = [],
@@ -2162,10 +1156,55 @@ function AccountMenu({
2162
1156
  const { Link } = useYunUI();
2163
1157
  const [open, setOpen] = useState(false);
2164
1158
  const ref = useRef(null);
1159
+ const triggerRef = useRef(null);
1160
+ const menuRef = useRef(null);
1161
+ const insideRefs = useMemo(() => [menuRef], []);
1162
+ const menuId = `${useId()}-account-menu`;
2165
1163
  const signInLabel = labels?.signIn ?? "Sign in";
2166
1164
  const signOutLabel = labels?.signOut ?? "Sign out";
2167
1165
  const fallbackName = labels?.fallbackName ?? "Account";
2168
- useDismissOnOutside(open, () => setOpen(false), ref);
1166
+ useDismissOnOutside(open, () => setOpen(false), ref, { escape: false, extraRefs: insideRefs });
1167
+ const identityKey = user == null ? String(user) : JSON.stringify([user.name ?? "", user.email ?? "", user.avatarUrl ?? ""]);
1168
+ useEffect(() => setOpen(false), [identityKey]);
1169
+ useEffect(() => {
1170
+ if (!open) return;
1171
+ const focusableItems = () => Array.from(
1172
+ menuRef.current?.querySelectorAll("[role='menuitem']:not([aria-disabled='true'])") ?? []
1173
+ );
1174
+ const focusFirstItem = () => focusableItems()[0]?.focus();
1175
+ const frame = requestAnimationFrame(focusFirstItem);
1176
+ const onKeyDown = (event) => {
1177
+ if (event.key === "Escape") {
1178
+ event.preventDefault();
1179
+ event.stopPropagation();
1180
+ setOpen(false);
1181
+ triggerRef.current?.focus();
1182
+ return;
1183
+ }
1184
+ if (event.key === "Tab") {
1185
+ setOpen(false);
1186
+ return;
1187
+ }
1188
+ const items2 = focusableItems();
1189
+ if (!items2.length) return;
1190
+ const currentIndex = items2.indexOf(document.activeElement);
1191
+ let nextIndex;
1192
+ if (event.key === "ArrowDown") nextIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % items2.length;
1193
+ else if (event.key === "ArrowUp") nextIndex = currentIndex < 0 ? items2.length - 1 : (currentIndex - 1 + items2.length) % items2.length;
1194
+ else if (event.key === "Home") nextIndex = 0;
1195
+ else if (event.key === "End") nextIndex = items2.length - 1;
1196
+ if (nextIndex !== void 0) {
1197
+ event.preventDefault();
1198
+ event.stopPropagation();
1199
+ items2[nextIndex]?.focus();
1200
+ }
1201
+ };
1202
+ document.addEventListener("keydown", onKeyDown, true);
1203
+ return () => {
1204
+ cancelAnimationFrame(frame);
1205
+ document.removeEventListener("keydown", onKeyDown, true);
1206
+ };
1207
+ }, [open]);
2169
1208
  if (user === void 0) {
2170
1209
  return /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: cn("block h-9 w-9", className) });
2171
1210
  }
@@ -2188,9 +1227,11 @@ function AccountMenu({
2188
1227
  /* @__PURE__ */ jsx(
2189
1228
  "button",
2190
1229
  {
1230
+ ref: triggerRef,
2191
1231
  type: "button",
2192
1232
  onClick: () => setOpen((v) => !v),
2193
1233
  "aria-haspopup": "menu",
1234
+ "aria-controls": open ? menuId : void 0,
2194
1235
  "aria-expanded": open,
2195
1236
  "aria-label": labels?.menu ?? name,
2196
1237
  className: "flex h-9 w-9 items-center justify-center overflow-hidden rounded-full transition-colors hover:bg-foreground/5 outline-none focus-visible:ring-2 focus-visible:ring-ring",
@@ -2201,10 +1242,14 @@ function AccountMenu({
2201
1242
  }
2202
1243
  ),
2203
1244
  open && /* @__PURE__ */ jsxs(
2204
- "div",
1245
+ FloatingPanel,
2205
1246
  {
1247
+ id: menuId,
1248
+ ref: menuRef,
1249
+ anchorRef: ref,
1250
+ align: "end",
2206
1251
  role: "menu",
2207
- className: "absolute right-0 top-full z-50 mt-2 w-56 rounded-2xl border border-border bg-popover/95 p-1.5 shadow-lg shadow-black/5 backdrop-blur-2xl",
1252
+ className: "z-50 w-56 overflow-y-auto rounded-2xl border border-border bg-popover p-1.5 shadow-lg shadow-black/5",
2208
1253
  children: [
2209
1254
  /* @__PURE__ */ jsxs("div", { className: "border-b border-border px-3 py-2.5", children: [
2210
1255
  /* @__PURE__ */ jsx("p", { className: "truncate text-sm font-medium", children: name }),
@@ -2234,6 +1279,7 @@ function AccountMenu({
2234
1279
  Link,
2235
1280
  {
2236
1281
  href: item.href ?? "#",
1282
+ role: "menuitem",
2237
1283
  onClick: () => setOpen(false),
2238
1284
  className: rowClass,
2239
1285
  children: body
@@ -2262,7 +1308,223 @@ function AccountMenu({
2262
1308
  )
2263
1309
  ] });
2264
1310
  }
1311
+ var DEFAULT_LABELS3 = {
1312
+ running: "Running",
1313
+ success: "Done",
1314
+ error: "Failed",
1315
+ approval: "Waiting for approval",
1316
+ denied: "Denied",
1317
+ input: "Input",
1318
+ output: "Output",
1319
+ allow: "Allow",
1320
+ deny: "Deny",
1321
+ retry: "Retry",
1322
+ copy: "Copy",
1323
+ copied: "Copied",
1324
+ copyFailed: "Copy failed",
1325
+ showMore: "Show more",
1326
+ showLess: "Show less"
1327
+ };
1328
+ function StatusIcon({ status }) {
1329
+ const common = "h-4 w-4 shrink-0";
1330
+ switch (status) {
1331
+ case "running":
1332
+ return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(Loader2, { "aria-hidden": true, className: cn(common, "text-muted-foreground motion-safe:animate-spin") }) }, "running");
1333
+ case "success":
1334
+ return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap yunui-check-draw", children: /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: cn(common, "text-(--success)") }) }, "success");
1335
+ case "error":
1336
+ return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(CircleAlert, { "aria-hidden": true, className: cn(common, "text-(--error)") }) }, "error");
1337
+ case "approval":
1338
+ return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(ShieldQuestion, { "aria-hidden": true, className: cn(common, "text-primary") }) }, "approval");
1339
+ default:
1340
+ return /* @__PURE__ */ jsx("span", { className: "yunui-icon-swap", children: /* @__PURE__ */ jsx(Ban, { "aria-hidden": true, className: cn(common, "text-muted-foreground") }) }, "denied");
1341
+ }
1342
+ }
1343
+ function CopyButton({ text, label, copiedLabel, failedLabel }) {
1344
+ const [state, setState] = useState("idle");
1345
+ const timer = useRef(void 0);
1346
+ useEffect(() => () => clearTimeout(timer.current), []);
1347
+ const onClick = async () => {
1348
+ try {
1349
+ await navigator.clipboard.writeText(text);
1350
+ setState("copied");
1351
+ } catch {
1352
+ setState("failed");
1353
+ }
1354
+ clearTimeout(timer.current);
1355
+ timer.current = setTimeout(() => setState("idle"), 1600);
1356
+ };
1357
+ const shown = state === "copied" ? copiedLabel : state === "failed" ? failedLabel : label;
1358
+ return (
1359
+ // Fixed-width slot: the label swaps in place so the row never changes width.
1360
+ /* @__PURE__ */ jsxs("button", { type: "button", onClick, className: "inline-flex h-6 min-w-[4.5rem] items-center justify-center gap-1 rounded-md px-1.5 text-[11px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [
1361
+ /* @__PURE__ */ jsxs("span", { className: "yunui-swap-in inline-flex items-center gap-1", children: [
1362
+ state === "copied" ? /* @__PURE__ */ jsx(Check, { "aria-hidden": true, className: "h-3 w-3 text-(--success)" }) : /* @__PURE__ */ jsx(Copy, { "aria-hidden": true, className: "h-3 w-3" }),
1363
+ shown
1364
+ ] }, state),
1365
+ /* @__PURE__ */ jsx("span", { role: "status", className: "sr-only", children: state === "idle" ? "" : shown })
1366
+ ] })
1367
+ );
1368
+ }
1369
+ function Block({ title, text, maxLines, labels }) {
1370
+ const [expanded, setExpanded] = useState(false);
1371
+ const lines = text.split("\n");
1372
+ const long = lines.length > maxLines;
1373
+ const shown = long && !expanded ? lines.slice(0, maxLines).join("\n") : text;
1374
+ return /* @__PURE__ */ jsxs("div", { className: "min-w-0", children: [
1375
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2", children: [
1376
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] font-medium text-muted-foreground", children: title }),
1377
+ /* @__PURE__ */ jsx(CopyButton, { text, label: labels.copy, copiedLabel: labels.copied, failedLabel: labels.copyFailed })
1378
+ ] }),
1379
+ /* @__PURE__ */ jsx("pre", { tabIndex: 0, className: "mt-1 max-h-72 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-muted/50 px-2.5 py-2 font-mono text-[11.5px] leading-relaxed text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: shown }),
1380
+ long ? /* @__PURE__ */ jsx("button", { type: "button", "aria-expanded": expanded, onClick: () => setExpanded((v) => !v), className: "mt-1 text-[11px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline", children: expanded ? labels.showLess : labels.showMore }) : null
1381
+ ] });
1382
+ }
1383
+ function ToolCall({
1384
+ title,
1385
+ status,
1386
+ mark,
1387
+ summary,
1388
+ duration,
1389
+ reason,
1390
+ input,
1391
+ output,
1392
+ maxLines = 8,
1393
+ open,
1394
+ defaultOpen = false,
1395
+ onOpenChange,
1396
+ onApprove,
1397
+ onDeny,
1398
+ onRetry,
1399
+ labels,
1400
+ index = 0,
1401
+ className
1402
+ }) {
1403
+ const copy = mergeLabels(DEFAULT_LABELS3, labels);
1404
+ const baseId = useId();
1405
+ const [internalOpen, setInternalOpen] = useState(defaultOpen);
1406
+ const controlled = open !== void 0;
1407
+ const isOpen = controlled ? open : internalOpen;
1408
+ const hasDetails = Boolean(input || output);
1409
+ const toggle = () => {
1410
+ if (!hasDetails) return;
1411
+ if (!controlled) setInternalOpen(!isOpen);
1412
+ onOpenChange?.(!isOpen);
1413
+ };
1414
+ const statusText2 = { running: copy.running, success: copy.success, error: copy.error, approval: copy.approval, denied: copy.denied }[status];
1415
+ const meta = [summary, duration].filter(Boolean).join(" \xB7 ");
1416
+ const [announce, setAnnounce] = useState("");
1417
+ const first = useRef(true);
1418
+ useEffect(() => {
1419
+ if (first.current) {
1420
+ first.current = false;
1421
+ return;
1422
+ }
1423
+ setAnnounce(`${title}: ${statusText2}`);
1424
+ }, [status]);
1425
+ const detailsId = `${baseId}-details`;
1426
+ return /* @__PURE__ */ jsxs("div", { "data-yunui": "tool-call", "data-status": status, style: { ["--i"]: index }, className: cn("min-w-0 rounded-xl", status === "approval" && "ring-1 ring-primary/50", className), children: [
1427
+ /* @__PURE__ */ jsxs("div", { className: "flex min-h-9 items-center gap-2 px-2 py-1", children: [
1428
+ /* @__PURE__ */ jsxs(
1429
+ "button",
1430
+ {
1431
+ type: "button",
1432
+ onClick: toggle,
1433
+ "aria-expanded": hasDetails ? isOpen : void 0,
1434
+ "aria-controls": hasDetails ? detailsId : void 0,
1435
+ disabled: !hasDetails,
1436
+ className: "flex min-w-0 flex-1 items-center gap-2 rounded-md text-left text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:cursor-default",
1437
+ children: [
1438
+ mark ? /* @__PURE__ */ jsx("span", { className: "flex h-4 w-4 shrink-0 items-center justify-center text-muted-foreground", "aria-hidden": true, children: mark }) : null,
1439
+ status === "running" ? /* @__PURE__ */ jsx(TextShimmer, { text: title, className: "min-w-0 truncate text-foreground" }) : /* @__PURE__ */ jsx("span", { className: cn("min-w-0 truncate", status === "success" ? "text-foreground" : status === "denied" ? "text-muted-foreground line-through decoration-muted-foreground/40" : "text-foreground"), children: title }),
1440
+ meta ? /* @__PURE__ */ jsx("span", { className: "ml-auto shrink-0 pl-2 text-[11.5px] tabular-nums text-muted-foreground", children: meta }) : null
1441
+ ]
1442
+ }
1443
+ ),
1444
+ status === "approval" ? /* @__PURE__ */ jsxs("span", { className: "flex shrink-0 items-center gap-1", children: [
1445
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: !onDeny, onClick: onDeny, className: "h-7 rounded-lg px-2.5 text-[12px] text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: copy.deny }),
1446
+ /* @__PURE__ */ jsx("button", { type: "button", disabled: !onApprove, onClick: onApprove, className: "h-7 rounded-lg bg-foreground px-2.5 text-[12px] text-background transition-opacity hover:opacity-90 disabled:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: copy.allow })
1447
+ ] }) : null,
1448
+ status === "error" && onRetry ? /* @__PURE__ */ jsxs("button", { type: "button", onClick: onRetry, className: "inline-flex h-7 shrink-0 items-center gap-1 rounded-lg border border-border px-2.5 text-[12px] text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring", children: [
1449
+ /* @__PURE__ */ jsx(RotateCcw, { "aria-hidden": true, className: "h-3 w-3" }),
1450
+ copy.retry
1451
+ ] }) : null,
1452
+ /* @__PURE__ */ jsx(StatusIcon, { status }),
1453
+ hasDetails ? /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-(--dur-spring) ease-(--ease-spring)", isOpen && "rotate-180") }) : null
1454
+ ] }),
1455
+ reason ? /* @__PURE__ */ jsx("p", { className: "px-2 pb-1.5 pl-8 text-[12px] leading-snug text-muted-foreground", children: reason }) : null,
1456
+ hasDetails ? /* @__PURE__ */ jsx("div", { id: detailsId, "data-open": isOpen, inert: !isOpen, "aria-hidden": !isOpen, className: "yunui-disclosure", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2.5 px-2 pb-2.5 pt-1", children: [
1457
+ input ? /* @__PURE__ */ jsx(Block, { title: copy.input, text: input, maxLines, labels: copy }) : null,
1458
+ output ? /* @__PURE__ */ jsx(Block, { title: copy.output, text: output, maxLines, labels: copy }) : null
1459
+ ] }) }) }) : null,
1460
+ /* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", className: "sr-only", children: announce })
1461
+ ] });
1462
+ }
1463
+ var DEFAULT_GROUP_LABELS = {
1464
+ used: (n) => n === 1 ? "Used 1 tool" : `Used ${n} tools`,
1465
+ using: (n) => n === 1 ? "Using 1 tool" : `Using ${n} tools`,
1466
+ waiting: "Waiting for you",
1467
+ failed: (n) => `${n} failed`
1468
+ };
1469
+ function ToolCallGroup({ children, marks, duration, open, defaultOpen, onOpenChange, autoCollapse = true, labels, className }) {
1470
+ const copy = { ...DEFAULT_GROUP_LABELS, ...labels };
1471
+ const calls = Children.toArray(children).filter((c) => isValidElement(c));
1472
+ const statuses = calls.map((c) => c.props.status);
1473
+ const running = statuses.filter((s) => s === "running").length;
1474
+ const approval = statuses.filter((s) => s === "approval").length;
1475
+ const failed = statuses.filter((s) => s === "error").length;
1476
+ const busy = running > 0 || approval > 0;
1477
+ const baseId = useId();
1478
+ const controlled = open !== void 0;
1479
+ const [internalOpen, setInternalOpen] = useState(defaultOpen ?? busy);
1480
+ const touched = useRef(false);
1481
+ const isOpen = controlled ? open : internalOpen;
1482
+ const set = useCallback(
1483
+ (next) => {
1484
+ if (!controlled) setInternalOpen(next);
1485
+ onOpenChange?.(next);
1486
+ },
1487
+ [controlled, onOpenChange]
1488
+ );
1489
+ useEffect(() => {
1490
+ if (approval > 0 && !isOpen) set(true);
1491
+ }, [approval]);
1492
+ const wasBusy = useRef(busy);
1493
+ useEffect(() => {
1494
+ let timer;
1495
+ if (wasBusy.current && !busy && autoCollapse && !touched.current && isOpen) timer = setTimeout(() => set(false), 450);
1496
+ wasBusy.current = busy;
1497
+ return () => clearTimeout(timer);
1498
+ }, [busy]);
1499
+ const headline = approval > 0 ? copy.waiting : running > 0 ? copy.using(calls.length) : copy.used(calls.length);
1500
+ const listId = `${baseId}-list`;
1501
+ return /* @__PURE__ */ jsxs("div", { "data-yunui": "tool-call-group", "data-busy": busy || void 0, className: cn("min-w-0 rounded-2xl border border-border bg-card/40", className), children: [
1502
+ /* @__PURE__ */ jsxs(
1503
+ "button",
1504
+ {
1505
+ type: "button",
1506
+ "aria-expanded": isOpen,
1507
+ "aria-controls": listId,
1508
+ onClick: () => {
1509
+ touched.current = true;
1510
+ set(!isOpen);
1511
+ },
1512
+ className: "flex min-h-10 w-full items-center gap-2.5 rounded-2xl px-3 text-left text-[13px] focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring",
1513
+ children: [
1514
+ marks ? /* @__PURE__ */ jsx("span", { className: "flex -space-x-1.5 text-muted-foreground", "aria-hidden": true, children: marks }) : null,
1515
+ busy ? /* @__PURE__ */ jsx(TextShimmer, { text: headline, className: "min-w-0 truncate text-foreground" }) : /* @__PURE__ */ jsx("span", { className: "yunui-swap-in min-w-0 truncate text-foreground", children: headline }, "done"),
1516
+ /* @__PURE__ */ jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-2 text-[11.5px] tabular-nums text-muted-foreground", children: [
1517
+ failed > 0 ? /* @__PURE__ */ jsx("span", { className: "text-(--error)", children: copy.failed(failed) }) : null,
1518
+ duration && !busy ? /* @__PURE__ */ jsx("span", { children: duration }) : null
1519
+ ] }),
1520
+ /* @__PURE__ */ jsx(ChevronDown, { "aria-hidden": true, className: cn("h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-(--dur-spring) ease-(--ease-spring)", isOpen && "rotate-180") })
1521
+ ]
1522
+ }
1523
+ ),
1524
+ /* @__PURE__ */ jsx("div", { id: listId, "data-open": isOpen, inert: !isOpen, "aria-hidden": !isOpen, className: "yunui-disclosure", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "border-t border-border/70 py-1", children: calls.map((call, i) => /* @__PURE__ */ jsx("div", { className: isOpen ? "yunui-stagger-in" : void 0, style: { ["--i"]: i }, children: /* @__PURE__ */ jsx(Fragment$1, { children: call }) }, call.key ?? i)) }) }) })
1525
+ ] });
1526
+ }
2265
1527
 
2266
- export { AccountMenu, AgentRunStatus, AgentTimeline, CapabilityIcon, CapabilitySelector, IDBadge, LanguageSwitcher, ModelAvatar, ModelCard, ModelIcon, ModelManagerCard, ModelSelect, ModelTypeIcon, Navbar, PROVIDER_ICON_SLUGS, ProviderAvatar, ProviderIcon, ProviderIconImg, ProviderNames, ThinkingBlock, buttonVariants, getDeveloperIconPath, getIconPath, getModelDeveloperId, getProviderIconOptions, getProviderName, isKnownCapability, normalizeProviderId };
1528
+ export { AccountMenu, AgentRunStatus, AgentTimeline, ApprovalQuestion, DiffTable, ModelManagerCard, ModelTypeIcon, ProviderIconImg, SelectionActions, ThinkingBlock, ToolCall, ToolCallGroup, buttonVariants };
2267
1529
  //# sourceMappingURL=ai.js.map
2268
1530
  //# sourceMappingURL=ai.js.map