@xpert-ai/chatkit-ui 0.0.2

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 (375) hide show
  1. package/README.md +62 -0
  2. package/dist/app/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  3. package/dist/app/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  4. package/dist/app/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  5. package/dist/app/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  6. package/dist/app/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  7. package/dist/app/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  8. package/dist/app/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  9. package/dist/app/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  10. package/dist/app/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  11. package/dist/app/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  12. package/dist/app/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  13. package/dist/app/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  14. package/dist/app/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  15. package/dist/app/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  16. package/dist/app/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  17. package/dist/app/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  18. package/dist/app/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  19. package/dist/app/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  20. package/dist/app/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  21. package/dist/app/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  22. package/dist/app/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  23. package/dist/app/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  24. package/dist/app/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  25. package/dist/app/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  26. package/dist/app/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  27. package/dist/app/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  28. package/dist/app/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  29. package/dist/app/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  30. package/dist/app/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  31. package/dist/app/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  32. package/dist/app/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  33. package/dist/app/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  34. package/dist/app/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  35. package/dist/app/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  36. package/dist/app/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  37. package/dist/app/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  38. package/dist/app/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  39. package/dist/app/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  40. package/dist/app/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  41. package/dist/app/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  42. package/dist/app/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  43. package/dist/app/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  44. package/dist/app/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  45. package/dist/app/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  46. package/dist/app/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  47. package/dist/app/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  48. package/dist/app/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  49. package/dist/app/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  50. package/dist/app/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  51. package/dist/app/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  52. package/dist/app/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  53. package/dist/app/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  54. package/dist/app/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  55. package/dist/app/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  56. package/dist/app/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  57. package/dist/app/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  58. package/dist/app/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  59. package/dist/app/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  60. package/dist/app/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  61. package/dist/app/assets/abap-r5qEZhbP.js +1 -0
  62. package/dist/app/assets/abnf-B1-snbnN.js +1 -0
  63. package/dist/app/assets/actionscript-DKuzag0S.js +1 -0
  64. package/dist/app/assets/ada-Cf7_jj9e.js +1 -0
  65. package/dist/app/assets/agda-DTzFiqCe.js +1 -0
  66. package/dist/app/assets/al-CxK958n6.js +1 -0
  67. package/dist/app/assets/antlr4-BAQNvWAR.js +1 -0
  68. package/dist/app/assets/apacheconf-BDS7lzSp.js +1 -0
  69. package/dist/app/assets/apex-PrEYueYu.js +1 -0
  70. package/dist/app/assets/apl-BxCE3pUM.js +1 -0
  71. package/dist/app/assets/applescript-CbmkMI2b.js +1 -0
  72. package/dist/app/assets/aql-Br7w2FWv.js +1 -0
  73. package/dist/app/assets/arduino-DztvkRBm.js +1 -0
  74. package/dist/app/assets/arff-DMIMEeal.js +1 -0
  75. package/dist/app/assets/asciidoc-6sbk5AU3.js +1 -0
  76. package/dist/app/assets/asm6502-pvPxs3SS.js +1 -0
  77. package/dist/app/assets/asmatmel-C6DNoRbE.js +1 -0
  78. package/dist/app/assets/aspnet-BbJerGfY.js +1 -0
  79. package/dist/app/assets/autohotkey-DKwYophK.js +1 -0
  80. package/dist/app/assets/autoit-DAz38rob.js +1 -0
  81. package/dist/app/assets/avisynth-CA38jZ01.js +1 -0
  82. package/dist/app/assets/avro-idl-DsorjIu9.js +1 -0
  83. package/dist/app/assets/bash-Byt0YIsi.js +1 -0
  84. package/dist/app/assets/bash-CefCgV5_.js +1 -0
  85. package/dist/app/assets/basic-CMWvkpXD.js +1 -0
  86. package/dist/app/assets/basic-DBS9NaGG.js +1 -0
  87. package/dist/app/assets/batch-DuBQ3McD.js +1 -0
  88. package/dist/app/assets/bbcode-DfssxBA1.js +1 -0
  89. package/dist/app/assets/bicep-9hsCe6m3.js +1 -0
  90. package/dist/app/assets/birb-Bc9BRwRB.js +1 -0
  91. package/dist/app/assets/bison-xsfiYnBc.js +1 -0
  92. package/dist/app/assets/bnf-DjWYNABY.js +1 -0
  93. package/dist/app/assets/brainfuck-DRIStkin.js +1 -0
  94. package/dist/app/assets/brightscript-C2PUL6fB.js +1 -0
  95. package/dist/app/assets/bro-CGiYkxiS.js +1 -0
  96. package/dist/app/assets/bsl-Bl8C3_3D.js +1 -0
  97. package/dist/app/assets/c-ZYvTJlSO.js +1 -0
  98. package/dist/app/assets/c-kgVuzdLE.js +1 -0
  99. package/dist/app/assets/cfscript-BMhAq5o9.js +1 -0
  100. package/dist/app/assets/chaiscript-CPmV-euz.js +1 -0
  101. package/dist/app/assets/cil-B6Amcpic.js +1 -0
  102. package/dist/app/assets/clike-B5tY_8Hg.js +1 -0
  103. package/dist/app/assets/clike-BJEDekBy.js +1 -0
  104. package/dist/app/assets/clojure-CW8XdyJM.js +1 -0
  105. package/dist/app/assets/cmake-C67VTXlG.js +1 -0
  106. package/dist/app/assets/cobol-36MS0vW5.js +1 -0
  107. package/dist/app/assets/coffeescript-HPCQWKbV.js +1 -0
  108. package/dist/app/assets/concurnas-BdV-2hSV.js +1 -0
  109. package/dist/app/assets/coq-B4X2Mh4T.js +1 -0
  110. package/dist/app/assets/core-xfKxb2c-.js +1 -0
  111. package/dist/app/assets/cpp-BdJVwJpi.js +1 -0
  112. package/dist/app/assets/cpp-DbuAZI9Z.js +1 -0
  113. package/dist/app/assets/crystal-Bn0O5Oft.js +1 -0
  114. package/dist/app/assets/csharp-Cd5Udg29.js +1 -0
  115. package/dist/app/assets/csharp-CjsjgIr3.js +1 -0
  116. package/dist/app/assets/cshtml-Cy8WSSs7.js +1 -0
  117. package/dist/app/assets/csp-CfCdno1W.js +1 -0
  118. package/dist/app/assets/css-CF9HHZb0.js +1 -0
  119. package/dist/app/assets/css-DenRb6F4.js +1 -0
  120. package/dist/app/assets/css-extras-Xo_fwYbL.js +1 -0
  121. package/dist/app/assets/csv-BWaJLMiL.js +1 -0
  122. package/dist/app/assets/cypher-BgX9fVzJ.js +1 -0
  123. package/dist/app/assets/d-DyyCNOIH.js +1 -0
  124. package/dist/app/assets/dart-DjzwYiLS.js +1 -0
  125. package/dist/app/assets/dataweave-B-Vy-inP.js +1 -0
  126. package/dist/app/assets/dax-CZ05y54Z.js +1 -0
  127. package/dist/app/assets/dhall-CwkbNTKc.js +1 -0
  128. package/dist/app/assets/diff-C_qDIIt8.js +3 -0
  129. package/dist/app/assets/django-Cchdv5xU.js +1 -0
  130. package/dist/app/assets/dns-zone-file-CyQNz9kq.js +1 -0
  131. package/dist/app/assets/docker-B0pp2G5o.js +1 -0
  132. package/dist/app/assets/dot-CYXSIdXI.js +1 -0
  133. package/dist/app/assets/ebnf-BhtXTbQG.js +1 -0
  134. package/dist/app/assets/editorconfig-BDSiMJB3.js +1 -0
  135. package/dist/app/assets/eiffel-CSI_WtNY.js +1 -0
  136. package/dist/app/assets/ejs-B7FjKtFB.js +1 -0
  137. package/dist/app/assets/elixir-D5ItL-Mz.js +1 -0
  138. package/dist/app/assets/elm-hVteuOs9.js +1 -0
  139. package/dist/app/assets/erb-BN7dXGSL.js +1 -0
  140. package/dist/app/assets/erlang-BSP_-sRS.js +1 -0
  141. package/dist/app/assets/etlua-BJLOsyG2.js +1 -0
  142. package/dist/app/assets/excel-formula-Cz8oPHlg.js +1 -0
  143. package/dist/app/assets/factor-B18ayaMg.js +1 -0
  144. package/dist/app/assets/false-BbwgoANn.js +1 -0
  145. package/dist/app/assets/firestore-security-rules-Cb-sIv4N.js +1 -0
  146. package/dist/app/assets/flow-DwNhMKdq.js +1 -0
  147. package/dist/app/assets/fortran-Q9_x6NYJ.js +1 -0
  148. package/dist/app/assets/fsharp-DAn0fWAf.js +1 -0
  149. package/dist/app/assets/ftl-0VJqQF7L.js +1 -0
  150. package/dist/app/assets/gap-CwARvyeO.js +1 -0
  151. package/dist/app/assets/gcode-DRZ-NtIf.js +1 -0
  152. package/dist/app/assets/gdscript-DLWUxJKZ.js +1 -0
  153. package/dist/app/assets/gedcom-LrWyJR_l.js +1 -0
  154. package/dist/app/assets/gherkin-DILlSFJd.js +1 -0
  155. package/dist/app/assets/git-tykDb3ub.js +1 -0
  156. package/dist/app/assets/glsl-D97iKuQJ.js +1 -0
  157. package/dist/app/assets/gml-DB1PeyPv.js +1 -0
  158. package/dist/app/assets/gn-Oqf78vQS.js +1 -0
  159. package/dist/app/assets/go-module-D7KyvJ4u.js +1 -0
  160. package/dist/app/assets/go-uYHARARY.js +1 -0
  161. package/dist/app/assets/graphql-BIap2FqQ.js +1 -0
  162. package/dist/app/assets/groovy-Cr9o9fqv.js +1 -0
  163. package/dist/app/assets/haml-Dbj6JAX0.js +1 -0
  164. package/dist/app/assets/handlebars-TWtx7Zmf.js +1 -0
  165. package/dist/app/assets/haskell-Ds42Eazu.js +1 -0
  166. package/dist/app/assets/haskell-_f6nn-YC.js +1 -0
  167. package/dist/app/assets/haxe-Dz8mYH5i.js +1 -0
  168. package/dist/app/assets/hcl-CWBhK_2d.js +1 -0
  169. package/dist/app/assets/hlsl-C8w84-ui.js +1 -0
  170. package/dist/app/assets/hoon-EPQkWoKN.js +1 -0
  171. package/dist/app/assets/hpkp-Cuo4Xy5e.js +1 -0
  172. package/dist/app/assets/hsts-CpNIILMG.js +1 -0
  173. package/dist/app/assets/http-CYP6yT6s.js +1 -0
  174. package/dist/app/assets/ichigojam-hUSaDBKO.js +1 -0
  175. package/dist/app/assets/icon-CiwrwB3z.js +1 -0
  176. package/dist/app/assets/icu-message-format-VDYKiTmx.js +1 -0
  177. package/dist/app/assets/idris-BrYqIHFw.js +1 -0
  178. package/dist/app/assets/iecst-CY8zdJ-p.js +1 -0
  179. package/dist/app/assets/ignore-DnPVmmQY.js +1 -0
  180. package/dist/app/assets/index-C3ZmJ6gF.css +1 -0
  181. package/dist/app/assets/index-CfiLrrLw.js +438 -0
  182. package/dist/app/assets/inform7-B5v6FoDj.js +1 -0
  183. package/dist/app/assets/ini-DgEXlHMC.js +1 -0
  184. package/dist/app/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2 +0 -0
  185. package/dist/app/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2 +0 -0
  186. package/dist/app/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2 +0 -0
  187. package/dist/app/assets/inter-greek-wght-normal-CkhJZR-_.woff2 +0 -0
  188. package/dist/app/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2 +0 -0
  189. package/dist/app/assets/inter-latin-wght-normal-Dx4kXJAl.woff2 +0 -0
  190. package/dist/app/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2 +0 -0
  191. package/dist/app/assets/io-CyM_37VY.js +1 -0
  192. package/dist/app/assets/j-DH8W8lNX.js +1 -0
  193. package/dist/app/assets/java-BxMbkJZ_.js +1 -0
  194. package/dist/app/assets/java-CqyMp51C.js +1 -0
  195. package/dist/app/assets/javadoc-D8u9HkgH.js +1 -0
  196. package/dist/app/assets/javadoclike-C1Lq0x6T.js +1 -0
  197. package/dist/app/assets/javadoclike-myFApC35.js +1 -0
  198. package/dist/app/assets/javascript-D8vYUPHd.js +1 -0
  199. package/dist/app/assets/javascript-Dg-dDZaa.js +1 -0
  200. package/dist/app/assets/javastacktrace-tDCrTG88.js +1 -0
  201. package/dist/app/assets/jexl-xmkYJPWN.js +1 -0
  202. package/dist/app/assets/jolie-BxjtsVcI.js +1 -0
  203. package/dist/app/assets/jq-t_D06nWO.js +1 -0
  204. package/dist/app/assets/js-extras-BBCqHvzI.js +1 -0
  205. package/dist/app/assets/js-templates-Bg1HmpMK.js +1 -0
  206. package/dist/app/assets/jsdoc-D80EteFV.js +1 -0
  207. package/dist/app/assets/json-BESjz4hO.js +1 -0
  208. package/dist/app/assets/json-C1i6SnC5.js +1 -0
  209. package/dist/app/assets/json5-CZOwksJ6.js +1 -0
  210. package/dist/app/assets/jsonp-CMd_XDVf.js +1 -0
  211. package/dist/app/assets/jsstacktrace-DGrGR7kW.js +1 -0
  212. package/dist/app/assets/jsx-CYygDQtl.js +1 -0
  213. package/dist/app/assets/julia-BR0LDBvi.js +1 -0
  214. package/dist/app/assets/keepalived-D44bjXvu.js +1 -0
  215. package/dist/app/assets/keyman-DzuVPclz.js +1 -0
  216. package/dist/app/assets/kotlin-DOwz6NW2.js +1 -0
  217. package/dist/app/assets/kumir-nVco3tEb.js +1 -0
  218. package/dist/app/assets/kusto-CM18Mfrd.js +1 -0
  219. package/dist/app/assets/latex-BROy64ts.js +1 -0
  220. package/dist/app/assets/latte-BTs2KkCX.js +1 -0
  221. package/dist/app/assets/less-BKd5Zil6.js +1 -0
  222. package/dist/app/assets/lilypond-COFiYhj_.js +1 -0
  223. package/dist/app/assets/liquid-CJguD-PK.js +1 -0
  224. package/dist/app/assets/lisp-D49Pqw-8.js +1 -0
  225. package/dist/app/assets/livescript-Ik0P2d90.js +1 -0
  226. package/dist/app/assets/llvm-D1Ep8sh7.js +1 -0
  227. package/dist/app/assets/log-C3qpQ9j4.js +1 -0
  228. package/dist/app/assets/lolcode-DRI6_ZBz.js +1 -0
  229. package/dist/app/assets/lua-BmFhPjSF.js +1 -0
  230. package/dist/app/assets/lua-DER4jxlW.js +1 -0
  231. package/dist/app/assets/magma-CU_SnAJn.js +1 -0
  232. package/dist/app/assets/makefile-Br-PJxmu.js +1 -0
  233. package/dist/app/assets/markdown-DNpDsBSv.js +1 -0
  234. package/dist/app/assets/markup-BONeskWm.js +1 -0
  235. package/dist/app/assets/markup-eMO994fL.js +1 -0
  236. package/dist/app/assets/markup-templating-5gNayUbG.js +1 -0
  237. package/dist/app/assets/markup-templating-BxAVv-bL.js +1 -0
  238. package/dist/app/assets/matlab-GWJYeB2_.js +1 -0
  239. package/dist/app/assets/maxscript-CpFmD-Fw.js +1 -0
  240. package/dist/app/assets/mel-BteQuMj1.js +1 -0
  241. package/dist/app/assets/mermaid-CdUPJtSd.js +1 -0
  242. package/dist/app/assets/mizar-MajG2Dpn.js +1 -0
  243. package/dist/app/assets/mongodb-DDvaIpbe.js +1 -0
  244. package/dist/app/assets/monkey-D2s8GYu3.js +1 -0
  245. package/dist/app/assets/moonscript-C3OwgoDV.js +1 -0
  246. package/dist/app/assets/n1ql-B-I37duX.js +1 -0
  247. package/dist/app/assets/n4js-mpVOXLsz.js +1 -0
  248. package/dist/app/assets/nand2tetris-hdl-D3LeJ4lR.js +1 -0
  249. package/dist/app/assets/naniscript-BLmLFeRO.js +1 -0
  250. package/dist/app/assets/nasm-Dab_l8tl.js +1 -0
  251. package/dist/app/assets/neon-Cfars9KI.js +1 -0
  252. package/dist/app/assets/nevod-BZuwf-5p.js +1 -0
  253. package/dist/app/assets/nginx-PFxBbEel.js +1 -0
  254. package/dist/app/assets/nim-vCFXO-Nn.js +1 -0
  255. package/dist/app/assets/nix-BWxxabUK.js +1 -0
  256. package/dist/app/assets/nsis-BnGcOg9C.js +1 -0
  257. package/dist/app/assets/objectivec-B65eHGmp.js +1 -0
  258. package/dist/app/assets/ocaml-DjvuAe7V.js +1 -0
  259. package/dist/app/assets/opencl-Durkzx8Q.js +1 -0
  260. package/dist/app/assets/openqasm-D8fmu6EO.js +1 -0
  261. package/dist/app/assets/oz-B_AoXlHI.js +1 -0
  262. package/dist/app/assets/parigp-CELpLnU5.js +1 -0
  263. package/dist/app/assets/parser-BRBykfrA.js +1 -0
  264. package/dist/app/assets/pascal-Ce2bsA8F.js +1 -0
  265. package/dist/app/assets/pascaligo-BOccKAjF.js +1 -0
  266. package/dist/app/assets/pcaxis-_8AUMo8I.js +1 -0
  267. package/dist/app/assets/peoplecode-B7vJSvNe.js +1 -0
  268. package/dist/app/assets/perl-B6IUwOJU.js +1 -0
  269. package/dist/app/assets/php-DZZMsf5_.js +1 -0
  270. package/dist/app/assets/php-extras-CFCou6pE.js +1 -0
  271. package/dist/app/assets/php-iTdQntIy.js +1 -0
  272. package/dist/app/assets/phpdoc-BihYeqX2.js +1 -0
  273. package/dist/app/assets/plsql-DkoJO_WC.js +1 -0
  274. package/dist/app/assets/powerquery-C9BdK_n1.js +1 -0
  275. package/dist/app/assets/powershell-B6i5FlCn.js +1 -0
  276. package/dist/app/assets/processing-7XippcCI.js +1 -0
  277. package/dist/app/assets/prolog-Pp-7CZ0i.js +1 -0
  278. package/dist/app/assets/promql-B6Hu2BCx.js +1 -0
  279. package/dist/app/assets/properties-BOn4P5Zq.js +1 -0
  280. package/dist/app/assets/protobuf-B3NNx_Xr.js +1 -0
  281. package/dist/app/assets/psl-CIRU9YYt.js +1 -0
  282. package/dist/app/assets/pug-C7F7xuzy.js +1 -0
  283. package/dist/app/assets/puppet-B0u-JHH7.js +1 -0
  284. package/dist/app/assets/pure-CTpP4_SN.js +1 -0
  285. package/dist/app/assets/purebasic-CRaKz7Bg.js +1 -0
  286. package/dist/app/assets/purescript-BwoF668l.js +1 -0
  287. package/dist/app/assets/q-DPdcJodp.js +1 -0
  288. package/dist/app/assets/qml-DOG1bBnZ.js +1 -0
  289. package/dist/app/assets/qore-Bl9DZz9p.js +1 -0
  290. package/dist/app/assets/qsharp-D61ab9U0.js +1 -0
  291. package/dist/app/assets/r-BRGCy6GC.js +1 -0
  292. package/dist/app/assets/racket-DX1mUQtk.js +1 -0
  293. package/dist/app/assets/reason-jGsz7TNy.js +1 -0
  294. package/dist/app/assets/regex-BgBGl-Po.js +1 -0
  295. package/dist/app/assets/rego-DzMdKj2S.js +1 -0
  296. package/dist/app/assets/renpy-CZQbSS0W.js +1 -0
  297. package/dist/app/assets/rest-BlHXtJh-.js +1 -0
  298. package/dist/app/assets/rip-Cp8amRhg.js +1 -0
  299. package/dist/app/assets/roboconf-8dICkxq_.js +1 -0
  300. package/dist/app/assets/robotframework-CQBVnI1B.js +1 -0
  301. package/dist/app/assets/ruby-BySgJbQh.js +1 -0
  302. package/dist/app/assets/ruby-DYsn9XfW.js +1 -0
  303. package/dist/app/assets/rust-DwFCpVnM.js +1 -0
  304. package/dist/app/assets/sas-BVz4-dXi.js +1 -0
  305. package/dist/app/assets/sass-kF1eV1tc.js +1 -0
  306. package/dist/app/assets/scala-BCd79KMC.js +1 -0
  307. package/dist/app/assets/scheme-Cscf027c.js +1 -0
  308. package/dist/app/assets/scheme-DGDH5UrN.js +1 -0
  309. package/dist/app/assets/scss-C3A6bKF2.js +1 -0
  310. package/dist/app/assets/shell-session-Bt1ByUnn.js +1 -0
  311. package/dist/app/assets/smali-BG59gVAI.js +1 -0
  312. package/dist/app/assets/smalltalk-DeWMrHCy.js +1 -0
  313. package/dist/app/assets/smarty-BlMz3kJS.js +1 -0
  314. package/dist/app/assets/sml-CWaZSpkP.js +1 -0
  315. package/dist/app/assets/solidity-Bjo0yzXA.js +1 -0
  316. package/dist/app/assets/solution-file-D8MELZgB.js +1 -0
  317. package/dist/app/assets/soy-BZNmPo5T.js +1 -0
  318. package/dist/app/assets/sparql-W4BcW6wH.js +1 -0
  319. package/dist/app/assets/splunk-spl-hrA6j7ir.js +1 -0
  320. package/dist/app/assets/sqf-Buh6IqkS.js +1 -0
  321. package/dist/app/assets/sql-CJATM1Qp.js +1 -0
  322. package/dist/app/assets/sql-XQlNmVmI.js +1 -0
  323. package/dist/app/assets/squirrel-ogEthJ_u.js +1 -0
  324. package/dist/app/assets/stan-C3I9t6dB.js +1 -0
  325. package/dist/app/assets/stylus-awj24PQU.js +1 -0
  326. package/dist/app/assets/swift-mDS-oIFf.js +1 -0
  327. package/dist/app/assets/systemd-C2laI5tS.js +2 -0
  328. package/dist/app/assets/t4-cs-C03LNWmj.js +1 -0
  329. package/dist/app/assets/t4-templating-B5EzSFYT.js +1 -0
  330. package/dist/app/assets/t4-templating-BsqHjv_U.js +1 -0
  331. package/dist/app/assets/t4-vb-CO8Pw53s.js +1 -0
  332. package/dist/app/assets/tap-Do_BVzJ7.js +1 -0
  333. package/dist/app/assets/tcl-EmfIWHBm.js +1 -0
  334. package/dist/app/assets/textile-RGeNEtU0.js +1 -0
  335. package/dist/app/assets/toml-DOSAiG5P.js +1 -0
  336. package/dist/app/assets/tremor-C8teCYgc.js +1 -0
  337. package/dist/app/assets/tt2-CZSbMCZy.js +1 -0
  338. package/dist/app/assets/turtle-DFryR16s.js +1 -0
  339. package/dist/app/assets/turtle-Ro1R6Je7.js +1 -0
  340. package/dist/app/assets/twig-y7WI1mGR.js +1 -0
  341. package/dist/app/assets/typescript-DZIZH67S.js +1 -0
  342. package/dist/app/assets/typoscript-B5Pie--I.js +1 -0
  343. package/dist/app/assets/unrealscript-DEQuLPVx.js +1 -0
  344. package/dist/app/assets/uorazor-C3fd8YVl.js +1 -0
  345. package/dist/app/assets/uri-i-FmRGl_.js +1 -0
  346. package/dist/app/assets/v-DJ6LpC6A.js +1 -0
  347. package/dist/app/assets/vala-BuGDftgP.js +1 -0
  348. package/dist/app/assets/vbnet-BhrUc4aD.js +1 -0
  349. package/dist/app/assets/vbnet-BnZaMO7X.js +1 -0
  350. package/dist/app/assets/velocity-WmSIATwx.js +1 -0
  351. package/dist/app/assets/verilog-CAXR3v8A.js +1 -0
  352. package/dist/app/assets/vhdl-5m-SQ1vR.js +1 -0
  353. package/dist/app/assets/vim-CQxy_hpv.js +1 -0
  354. package/dist/app/assets/visual-basic-DUXEe4eb.js +1 -0
  355. package/dist/app/assets/warpscript-Dn2sF1Na.js +1 -0
  356. package/dist/app/assets/wasm-CNYCO55I.js +1 -0
  357. package/dist/app/assets/web-idl-qpTEzhMi.js +1 -0
  358. package/dist/app/assets/wiki-IUIM-gLF.js +1 -0
  359. package/dist/app/assets/wolfram-WHvqmd61.js +1 -0
  360. package/dist/app/assets/wren-DHDfXRyN.js +1 -0
  361. package/dist/app/assets/xeora-BmALMX-C.js +1 -0
  362. package/dist/app/assets/xml-doc-DipNs41l.js +1 -0
  363. package/dist/app/assets/xojo-Ch51-LqE.js +1 -0
  364. package/dist/app/assets/xquery-BkfTblI-.js +1 -0
  365. package/dist/app/assets/yaml-DR3QJEOe.js +1 -0
  366. package/dist/app/assets/yaml-pHjxJgpq.js +1 -0
  367. package/dist/app/assets/yang-BnYvEcuQ.js +1 -0
  368. package/dist/app/assets/zig-6vTJYoFe.js +1 -0
  369. package/dist/app/index.html +14 -0
  370. package/dist/index.cjs +2748 -0
  371. package/dist/index.css +107 -0
  372. package/dist/index.d.cts +77 -0
  373. package/dist/index.d.ts +77 -0
  374. package/dist/index.js +2694 -0
  375. package/package.json +93 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,2748 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Avatar: () => Avatar,
34
+ AvatarFallback: () => AvatarFallback,
35
+ AvatarImage: () => AvatarImage,
36
+ Badge: () => Badge,
37
+ Button: () => Button,
38
+ Card: () => Card,
39
+ CardAction: () => CardAction,
40
+ CardContent: () => CardContent,
41
+ CardDescription: () => CardDescription,
42
+ CardFooter: () => CardFooter,
43
+ CardHeader: () => CardHeader,
44
+ CardTitle: () => CardTitle,
45
+ Chat: () => Chat,
46
+ Input: () => Input,
47
+ ScrollArea: () => ScrollArea,
48
+ ScrollBar: () => ScrollBar,
49
+ Separator: () => Separator,
50
+ Tabs: () => Tabs,
51
+ TabsContent: () => TabsContent,
52
+ TabsList: () => TabsList,
53
+ TabsTrigger: () => TabsTrigger,
54
+ chatkitSupportedLocales: () => supportedLocales,
55
+ getChatkitLanguage: () => getLanguage,
56
+ setChatkitLanguage: () => setLanguage,
57
+ useParentMessenger: () => useParentMessenger
58
+ });
59
+ module.exports = __toCommonJS(index_exports);
60
+
61
+ // src/components/chat.tsx
62
+ var React17 = __toESM(require("react"), 1);
63
+
64
+ // src/lib/utils.ts
65
+ var import_clsx = require("clsx");
66
+ var import_tailwind_merge = require("tailwind-merge");
67
+ function cn(...inputs) {
68
+ return (0, import_tailwind_merge.twMerge)((0, import_clsx.clsx)(inputs));
69
+ }
70
+
71
+ // src/providers/Stream.tsx
72
+ var import_react2 = require("react");
73
+ var import_nuqs = require("nuqs");
74
+ var import_xpert_sdk = require("@xpert-ai/xpert-sdk");
75
+ var import_tool = require("@langchain/core/messages/tool");
76
+ var import_chatkit_types = require("@xpert-ai/chatkit-types");
77
+
78
+ // src/hooks/useParentMessenger.ts
79
+ var import_react = require("react");
80
+
81
+ // src/hooks/useStream.ts
82
+ var streamRef = { current: null };
83
+ function useStreamManager() {
84
+ return {
85
+ streamRef,
86
+ stream: streamRef.current,
87
+ setStream: (stream) => {
88
+ streamRef.current = stream;
89
+ }
90
+ };
91
+ }
92
+
93
+ // src/hooks/useParentMessenger.ts
94
+ var getParentOrigin = () => {
95
+ if (typeof document === "undefined" || !document.referrer) return "*";
96
+ try {
97
+ return new URL(document.referrer).origin;
98
+ } catch {
99
+ return "*";
100
+ }
101
+ };
102
+ var createNonce = () => {
103
+ if (typeof crypto !== "undefined" && "randomUUID" in crypto) {
104
+ return crypto.randomUUID();
105
+ }
106
+ return `ck_${Date.now()}_${Math.random().toString(16).slice(2)}`;
107
+ };
108
+ function useParentMessenger({ onSetOptions } = {}) {
109
+ const { streamRef: streamRef2 } = useStreamManager();
110
+ const parentOriginRef = (0, import_react.useRef)("*");
111
+ const pendingRef = (0, import_react.useRef)(
112
+ /* @__PURE__ */ new Map()
113
+ );
114
+ const isParentAvailable = (0, import_react.useMemo)(() => {
115
+ return typeof window !== "undefined" && window.parent !== window;
116
+ }, []);
117
+ (0, import_react.useEffect)(() => {
118
+ parentOriginRef.current = getParentOrigin();
119
+ }, []);
120
+ (0, import_react.useEffect)(() => {
121
+ if (!isParentAvailable) return;
122
+ const sendResponse = (nonce, response, error) => {
123
+ const message = {
124
+ __xpaiChatKit: true,
125
+ type: "response",
126
+ nonce,
127
+ response,
128
+ error
129
+ };
130
+ window.parent.postMessage(message, parentOriginRef.current);
131
+ };
132
+ const handleMessage = (event) => {
133
+ if (event.source !== window.parent) return;
134
+ if (!event.data || typeof event.data !== "object") return;
135
+ if (parentOriginRef.current !== "*" && typeof event.origin === "string" && event.origin !== parentOriginRef.current) {
136
+ return;
137
+ }
138
+ const payload = event.data;
139
+ if (payload.__xpaiChatKit !== true) return;
140
+ if (payload.type == "command" && payload.command === "onSendUserMessage") {
141
+ streamRef2.current?.submit({
142
+ input: {
143
+ input: payload.data.text
144
+ }
145
+ });
146
+ if (payload.nonce) {
147
+ sendResponse(payload.nonce, { ok: true });
148
+ }
149
+ return;
150
+ }
151
+ if (payload.type == "command" && payload.command === "onSetOptions") {
152
+ if (onSetOptions) {
153
+ onSetOptions(payload.data);
154
+ }
155
+ if (payload.nonce) {
156
+ sendResponse(payload.nonce, { ok: true });
157
+ }
158
+ return;
159
+ }
160
+ if (payload.type !== "response") return;
161
+ if (typeof payload.nonce !== "string") return;
162
+ const handler = pendingRef.current.get(payload.nonce);
163
+ if (!handler) return;
164
+ if (payload.error !== void 0) {
165
+ handler.reject(payload.error);
166
+ } else {
167
+ handler.resolve(payload.response);
168
+ }
169
+ pendingRef.current.delete(payload.nonce);
170
+ };
171
+ window.addEventListener("message", handleMessage);
172
+ return () => {
173
+ window.removeEventListener("message", handleMessage);
174
+ pendingRef.current.forEach((handler) => {
175
+ handler.reject(new Error("Parent messenger closed"));
176
+ });
177
+ pendingRef.current.clear();
178
+ };
179
+ }, [isParentAvailable]);
180
+ const sendCommand = (0, import_react.useCallback)(
181
+ (command, data, transfer) => {
182
+ if (!isParentAvailable) {
183
+ return Promise.reject(new Error("Parent window not available"));
184
+ }
185
+ const nonce = createNonce();
186
+ const message = {
187
+ __xpaiChatKit: true,
188
+ type: "command",
189
+ nonce,
190
+ command,
191
+ data: data ?? null
192
+ };
193
+ return new Promise((resolve, reject) => {
194
+ pendingRef.current.set(nonce, { resolve, reject });
195
+ window.parent.postMessage(message, parentOriginRef.current, transfer);
196
+ });
197
+ },
198
+ [isParentAvailable]
199
+ );
200
+ const sendEvent = (0, import_react.useCallback)(
201
+ (event, data, transfer) => {
202
+ if (!isParentAvailable) return;
203
+ const message = {
204
+ __xpaiChatKit: true,
205
+ type: "event",
206
+ event,
207
+ data
208
+ };
209
+ window.parent.postMessage(message, parentOriginRef.current, transfer);
210
+ },
211
+ [isParentAvailable]
212
+ );
213
+ return {
214
+ isParentAvailable,
215
+ sendCommand,
216
+ sendEvent
217
+ };
218
+ }
219
+
220
+ // src/providers/Stream.tsx
221
+ var import_jsx_runtime = require("react/jsx-runtime");
222
+ var import_meta = {};
223
+ var StreamContext = (0, import_react2.createContext)(void 0);
224
+ var defaultApiUrl = import_meta.env.VITE_XPERTAI_API_URL ?? "https://api.mtda.cloud/api/ai";
225
+ var useStreamContext = () => {
226
+ const context = (0, import_react2.useContext)(StreamContext);
227
+ if (!context) {
228
+ throw new Error("useStreamContext must be used within a StreamProvider");
229
+ }
230
+ return context;
231
+ };
232
+
233
+ // src/components/composer/ComposerMenu.tsx
234
+ var React4 = __toESM(require("react"), 1);
235
+
236
+ // src/components/ui/button.tsx
237
+ var React2 = __toESM(require("react"), 1);
238
+ var import_jsx_runtime2 = require("react/jsx-runtime");
239
+ var base = "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 ring-offset-background";
240
+ var variants = {
241
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
242
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
243
+ ghost: "hover:bg-accent hover:text-accent-foreground"
244
+ };
245
+ var sizes = {
246
+ default: "h-10 px-4 py-2",
247
+ sm: "h-9 rounded-md px-3",
248
+ icon: "h-10 w-10"
249
+ };
250
+ var Button = React2.forwardRef(
251
+ ({ className, variant = "default", size = "default", type, ...props }, ref) => {
252
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
253
+ "button",
254
+ {
255
+ ref,
256
+ type: type ?? "button",
257
+ className: cn(base, variants[variant], sizes[size], className),
258
+ ...props
259
+ }
260
+ );
261
+ }
262
+ );
263
+ Button.displayName = "Button";
264
+
265
+ // src/components/ui/popover.tsx
266
+ var React3 = require("react");
267
+ var PopoverPrimitive = __toESM(require("@radix-ui/react-popover"), 1);
268
+ var import_jsx_runtime3 = require("react/jsx-runtime");
269
+ function Popover({
270
+ ...props
271
+ }) {
272
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PopoverPrimitive.Root, { "data-slot": "popover", ...props });
273
+ }
274
+ function PopoverTrigger({
275
+ ...props
276
+ }) {
277
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PopoverPrimitive.Trigger, { "data-slot": "popover-trigger", ...props });
278
+ }
279
+ function PopoverContent({
280
+ className,
281
+ align = "center",
282
+ sideOffset = 4,
283
+ ...props
284
+ }) {
285
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PopoverPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
286
+ PopoverPrimitive.Content,
287
+ {
288
+ "data-slot": "popover-content",
289
+ align,
290
+ sideOffset,
291
+ className: cn(
292
+ "bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 rounded-md border p-4 shadow-md outline-none",
293
+ className
294
+ ),
295
+ ...props
296
+ }
297
+ ) });
298
+ }
299
+
300
+ // src/i18n/useChatkitTranslation.ts
301
+ var import_react_i18next2 = require("react-i18next");
302
+
303
+ // src/i18n/index.ts
304
+ var import_i18next = __toESM(require("i18next"), 1);
305
+ var import_react_i18next = require("react-i18next");
306
+
307
+ // src/i18n/locales/en-US.json
308
+ var en_US_default = {
309
+ chat: {
310
+ title: "Chat",
311
+ placeholder: "Type a message...",
312
+ statusOnline: "Online",
313
+ missingConfigShort: "Missing ChatKit configuration.",
314
+ missingConfigDetail: "Missing ChatKit configuration. Check `VITE_XPERTAI_API_URL`, and the `clientSecret` prop.",
315
+ loadingConversation: "Loading conversation...",
316
+ stop: "Stop",
317
+ send: "Send message",
318
+ poweredBy: "Powered by Xpert AI",
319
+ errors: {
320
+ loadMessages: "Failed to load conversation messages",
321
+ createConversation: "Failed to create conversation",
322
+ deleteConversation: "Failed to delete conversation"
323
+ }
324
+ },
325
+ history: {
326
+ conversationHistory: "Conversation history",
327
+ title: "Conversations",
328
+ newChat: "New Chat",
329
+ empty: "No conversations yet",
330
+ newConversationTitle: "New conversation",
331
+ conversationWithId: "Conversation {{id}}",
332
+ conversationFallback: "Conversation"
333
+ },
334
+ messageActions: {
335
+ copied: "Copied!",
336
+ copy: "Copy to clipboard",
337
+ regenerate: "Regenerate response"
338
+ },
339
+ startScreen: {
340
+ greeting: "What can I help with today?"
341
+ },
342
+ composer: {
343
+ openMenu: "Open menu",
344
+ addAttachment: "Add attachment"
345
+ },
346
+ sheet: {
347
+ close: "Close"
348
+ },
349
+ markdown: {
350
+ copy: "Copy"
351
+ },
352
+ thread: {
353
+ errorToast: "An error occurred. Please try again.",
354
+ errorLabel: "Error:",
355
+ langGraphMessages: "LangGraph Messages..."
356
+ }
357
+ };
358
+
359
+ // src/i18n/locales/zh-CN.json
360
+ var zh_CN_default = {
361
+ chat: {
362
+ title: "\u804A\u5929",
363
+ placeholder: "\u8F93\u5165\u6D88\u606F...",
364
+ statusOnline: "\u5728\u7EBF",
365
+ missingConfigShort: "\u7F3A\u5C11 ChatKit \u914D\u7F6E\u3002",
366
+ missingConfigDetail: "\u7F3A\u5C11 ChatKit \u914D\u7F6E\u3002\u8BF7\u68C0\u67E5 `VITE_XPERTAI_API_URL` \u548C `clientSecret` \u53C2\u6570\u3002",
367
+ loadingConversation: "\u6B63\u5728\u52A0\u8F7D\u5BF9\u8BDD...",
368
+ stop: "\u505C\u6B62",
369
+ send: "\u53D1\u9001\u6D88\u606F",
370
+ poweredBy: "\u7531 Xpert AI \u9A71\u52A8",
371
+ errors: {
372
+ loadMessages: "\u52A0\u8F7D\u5BF9\u8BDD\u6D88\u606F\u5931\u8D25",
373
+ createConversation: "\u521B\u5EFA\u5BF9\u8BDD\u5931\u8D25",
374
+ deleteConversation: "\u5220\u9664\u5BF9\u8BDD\u5931\u8D25"
375
+ }
376
+ },
377
+ history: {
378
+ conversationHistory: "\u5BF9\u8BDD\u5386\u53F2",
379
+ title: "\u5BF9\u8BDD",
380
+ newChat: "\u65B0\u5BF9\u8BDD",
381
+ empty: "\u6682\u65E0\u5BF9\u8BDD",
382
+ newConversationTitle: "\u65B0\u5BF9\u8BDD",
383
+ conversationWithId: "\u5BF9\u8BDD {{id}}",
384
+ conversationFallback: "\u5BF9\u8BDD"
385
+ },
386
+ messageActions: {
387
+ copied: "\u5DF2\u590D\u5236\uFF01",
388
+ copy: "\u590D\u5236\u5230\u526A\u8D34\u677F",
389
+ regenerate: "\u91CD\u65B0\u751F\u6210\u56DE\u590D"
390
+ },
391
+ startScreen: {
392
+ greeting: "\u4ECA\u5929\u6211\u80FD\u5E2E\u4F60\u4EC0\u4E48\uFF1F"
393
+ },
394
+ composer: {
395
+ openMenu: "\u6253\u5F00\u83DC\u5355",
396
+ addAttachment: "\u6DFB\u52A0\u9644\u4EF6"
397
+ },
398
+ sheet: {
399
+ close: "\u5173\u95ED"
400
+ },
401
+ markdown: {
402
+ copy: "\u590D\u5236"
403
+ },
404
+ thread: {
405
+ errorToast: "\u53D1\u751F\u9519\u8BEF\uFF0C\u8BF7\u91CD\u8BD5\u3002",
406
+ errorLabel: "\u9519\u8BEF\uFF1A",
407
+ langGraphMessages: "LangGraph \u6D88\u606F..."
408
+ }
409
+ };
410
+
411
+ // src/i18n/index.ts
412
+ var localeStorageKey = "chatkit:locale";
413
+ var supportedLocales = ["en-US", "zh-CN"];
414
+ var defaultLocale = "en-US";
415
+ function normalizeLocale(locale) {
416
+ if (!locale) return defaultLocale;
417
+ const normalized = locale.trim();
418
+ if (!normalized) return defaultLocale;
419
+ if (normalized === "zh-CN" || normalized.startsWith("zh")) return "zh-CN";
420
+ if (normalized === "en-US" || normalized.startsWith("en")) return "en-US";
421
+ return defaultLocale;
422
+ }
423
+ function getStoredLocale() {
424
+ if (typeof window === "undefined") return null;
425
+ try {
426
+ return window.localStorage.getItem(localeStorageKey);
427
+ } catch {
428
+ return null;
429
+ }
430
+ }
431
+ function getBrowserLocale() {
432
+ if (typeof navigator === "undefined") return null;
433
+ return navigator.language || null;
434
+ }
435
+ function initI18n() {
436
+ if (import_i18next.default.isInitialized) return import_i18next.default;
437
+ const initialLocale = normalizeLocale(getStoredLocale() ?? getBrowserLocale());
438
+ void import_i18next.default.use(import_react_i18next.initReactI18next).init({
439
+ resources: {
440
+ "en-US": { translation: en_US_default },
441
+ "zh-CN": { translation: zh_CN_default }
442
+ },
443
+ lng: initialLocale,
444
+ fallbackLng: defaultLocale,
445
+ interpolation: {
446
+ escapeValue: false
447
+ },
448
+ react: {
449
+ useSuspense: false
450
+ },
451
+ initImmediate: false
452
+ });
453
+ return import_i18next.default;
454
+ }
455
+ function setLanguage(locale) {
456
+ const resolved = normalizeLocale(locale);
457
+ initI18n();
458
+ void import_i18next.default.changeLanguage(resolved);
459
+ if (typeof window !== "undefined") {
460
+ try {
461
+ window.localStorage.setItem(localeStorageKey, resolved);
462
+ } catch {
463
+ }
464
+ }
465
+ return resolved;
466
+ }
467
+ function getLanguage() {
468
+ if (import_i18next.default.isInitialized) {
469
+ return normalizeLocale(import_i18next.default.language);
470
+ }
471
+ return normalizeLocale(getStoredLocale() ?? getBrowserLocale());
472
+ }
473
+
474
+ // src/i18n/useChatkitTranslation.ts
475
+ function useChatkitTranslation() {
476
+ initI18n();
477
+ return (0, import_react_i18next2.useTranslation)();
478
+ }
479
+
480
+ // src/components/composer/ComposerMenu.tsx
481
+ var import_jsx_runtime4 = require("react/jsx-runtime");
482
+ function getIconComponent(icon) {
483
+ const iconMap = {
484
+ "plus": /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M5 12h14M12 5v14" }) }),
485
+ "document": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
486
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" }),
487
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("polyline", { points: "14 2 14 8 20 8" })
488
+ ] }),
489
+ "write": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
490
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 20h9" }),
491
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
492
+ ] }),
493
+ "sparkle": /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" }) }),
494
+ "lightbulb": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
495
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" }),
496
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 18h6" }),
497
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M10 22h4" })
498
+ ] }),
499
+ "settings-slider": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
500
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "4", x2: "4", y1: "21", y2: "14" }),
501
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "4", x2: "4", y1: "10", y2: "3" }),
502
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "12", x2: "12", y1: "21", y2: "12" }),
503
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "12", x2: "12", y1: "8", y2: "3" }),
504
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "20", x2: "20", y1: "21", y2: "16" }),
505
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "20", x2: "20", y1: "12", y2: "3" }),
506
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "2", x2: "6", y1: "14", y2: "14" }),
507
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "10", x2: "14", y1: "8", y2: "8" }),
508
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "18", x2: "22", y1: "16", y2: "16" })
509
+ ] }),
510
+ "search": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
511
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "11", cy: "11", r: "8" }),
512
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m21 21-4.3-4.3" })
513
+ ] }),
514
+ "globe": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
515
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
516
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "2", x2: "22", y1: "12", y2: "12" }),
517
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" })
518
+ ] }),
519
+ "images": /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
520
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M18 22H4a2 2 0 0 1-2-2V6" }),
521
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m22 13-1.296-1.296a2.41 2.41 0 0 0-3.408 0L11 18" }),
522
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "8", r: "2" }),
523
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { width: "16", height: "16", x: "6", y: "2", rx: "2" })
524
+ ] })
525
+ };
526
+ return iconMap[icon] || iconMap["sparkle"];
527
+ }
528
+ function PaperclipIcon() {
529
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "m21.44 11.05-9.19 9.19a6 6 0 0 1-8.49-8.49l8.57-8.57A4 4 0 1 1 18 8.84l-8.59 8.57a2 2 0 0 1-2.83-2.83l8.49-8.48" }) });
530
+ }
531
+ function PlusIcon() {
532
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M5 12h14M12 5v14" }) });
533
+ }
534
+ function ComposerMenu({
535
+ composer,
536
+ onAttachmentClick,
537
+ onToolSelect,
538
+ selectedTool,
539
+ disabled = false
540
+ }) {
541
+ const { t } = useChatkitTranslation();
542
+ const [open, setOpen] = React4.useState(false);
543
+ const attachmentsEnabled = composer?.attachments?.enabled ?? false;
544
+ const tools = composer?.tools ?? [];
545
+ if (!attachmentsEnabled && tools.length === 0) {
546
+ return null;
547
+ }
548
+ const handleAttachmentClick = () => {
549
+ onAttachmentClick?.();
550
+ setOpen(false);
551
+ };
552
+ const handleToolSelect = (tool) => {
553
+ onToolSelect?.(tool);
554
+ setOpen(false);
555
+ };
556
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(Popover, { open, onOpenChange: setOpen, children: [
557
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PopoverTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
558
+ Button,
559
+ {
560
+ type: "button",
561
+ variant: "ghost",
562
+ size: "icon",
563
+ disabled,
564
+ className: cn(
565
+ "h-10 w-10 shrink-0 rounded-full hover:bg-muted",
566
+ open && "bg-muted"
567
+ ),
568
+ children: [
569
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PlusIcon, {}),
570
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "sr-only", children: t("composer.openMenu") })
571
+ ]
572
+ }
573
+ ) }),
574
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
575
+ PopoverContent,
576
+ {
577
+ align: "start",
578
+ side: "top",
579
+ className: "w-56 p-1",
580
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: "flex flex-col", children: [
581
+ attachmentsEnabled && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
582
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
583
+ "button",
584
+ {
585
+ type: "button",
586
+ onClick: handleAttachmentClick,
587
+ className: "flex items-center gap-3 rounded-md px-3 py-2 text-sm hover:bg-muted transition-colors",
588
+ children: [
589
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "flex h-6 w-6 items-center justify-center text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(PaperclipIcon, {}) }),
590
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t("composer.addAttachment") })
591
+ ]
592
+ }
593
+ ),
594
+ tools.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "my-1 h-px bg-border" })
595
+ ] }),
596
+ tools.map((tool) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
597
+ "button",
598
+ {
599
+ type: "button",
600
+ onClick: () => handleToolSelect(tool),
601
+ className: cn(
602
+ "flex items-center gap-3 rounded-md px-3 py-2 text-sm hover:bg-muted transition-colors",
603
+ selectedTool?.id === tool.id && "bg-muted"
604
+ ),
605
+ children: [
606
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "flex h-6 w-6 items-center justify-center text-muted-foreground", children: getIconComponent(tool.icon) }),
607
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: tool.label })
608
+ ]
609
+ },
610
+ tool.id
611
+ ))
612
+ ] })
613
+ }
614
+ )
615
+ ] });
616
+ }
617
+
618
+ // src/components/composer/SendButton.tsx
619
+ var React5 = require("react");
620
+ var import_jsx_runtime5 = require("react/jsx-runtime");
621
+ function ArrowUpIcon() {
622
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
623
+ "svg",
624
+ {
625
+ xmlns: "http://www.w3.org/2000/svg",
626
+ width: "18",
627
+ height: "18",
628
+ viewBox: "0 0 24 24",
629
+ fill: "none",
630
+ stroke: "currentColor",
631
+ strokeWidth: "2.5",
632
+ strokeLinecap: "round",
633
+ strokeLinejoin: "round",
634
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M12 19V5M5 12l7-7 7 7" })
635
+ }
636
+ );
637
+ }
638
+ function StopIcon() {
639
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
640
+ "svg",
641
+ {
642
+ xmlns: "http://www.w3.org/2000/svg",
643
+ width: "14",
644
+ height: "14",
645
+ viewBox: "0 0 24 24",
646
+ fill: "currentColor",
647
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("rect", { x: "4", y: "4", width: "16", height: "16", rx: "2" })
648
+ }
649
+ );
650
+ }
651
+ function SendButton({
652
+ disabled = false,
653
+ isLoading = false,
654
+ onStop,
655
+ stopLabel = "Stop",
656
+ sendLabel = "Send"
657
+ }) {
658
+ if (isLoading) {
659
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
660
+ "button",
661
+ {
662
+ type: "button",
663
+ onClick: onStop,
664
+ className: cn(
665
+ "flex h-9 w-9 shrink-0 items-center justify-center rounded-full",
666
+ "bg-foreground text-background",
667
+ "transition-transform duration-150 ease-out",
668
+ "hover:scale-105 active:scale-95"
669
+ ),
670
+ "aria-label": stopLabel,
671
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(StopIcon, {})
672
+ }
673
+ );
674
+ }
675
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
676
+ "button",
677
+ {
678
+ type: "submit",
679
+ disabled,
680
+ className: cn(
681
+ "flex h-9 w-9 shrink-0 items-center justify-center rounded-full",
682
+ "bg-foreground text-background",
683
+ "transition-all duration-150 ease-out",
684
+ "hover:scale-105 active:scale-95",
685
+ "disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:scale-100"
686
+ ),
687
+ "aria-label": sendLabel,
688
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ArrowUpIcon, {})
689
+ }
690
+ );
691
+ }
692
+
693
+ // src/components/history/HistorySidebar.tsx
694
+ var React8 = __toESM(require("react"), 1);
695
+
696
+ // src/components/ui/scroll-area.tsx
697
+ var React6 = __toESM(require("react"), 1);
698
+ var ScrollAreaPrimitive = __toESM(require("@radix-ui/react-scroll-area"), 1);
699
+ var import_jsx_runtime6 = require("react/jsx-runtime");
700
+ var ScrollArea = React6.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
701
+ ScrollAreaPrimitive.Root,
702
+ {
703
+ ref,
704
+ className: cn("relative overflow-hidden", className),
705
+ ...props,
706
+ children: [
707
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScrollAreaPrimitive.Viewport, { className: "h-full w-full rounded-[inherit]", children }),
708
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScrollBar, {}),
709
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScrollAreaPrimitive.Corner, {})
710
+ ]
711
+ }
712
+ ));
713
+ ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
714
+ var ScrollBar = React6.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
715
+ ScrollAreaPrimitive.ScrollAreaScrollbar,
716
+ {
717
+ ref,
718
+ orientation,
719
+ className: cn(
720
+ "flex touch-none select-none transition-colors",
721
+ orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]",
722
+ orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]",
723
+ className
724
+ ),
725
+ ...props,
726
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ScrollAreaPrimitive.ScrollAreaThumb, { className: "relative flex-1 rounded-full bg-border" })
727
+ }
728
+ ));
729
+ ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
730
+
731
+ // src/components/ui/sheet.tsx
732
+ var React7 = require("react");
733
+ var SheetPrimitive = __toESM(require("@radix-ui/react-dialog"), 1);
734
+ var import_jsx_runtime7 = require("react/jsx-runtime");
735
+ function Sheet({ ...props }) {
736
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SheetPrimitive.Root, { ...props });
737
+ }
738
+ function SheetTrigger({ ...props }) {
739
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SheetPrimitive.Trigger, { ...props });
740
+ }
741
+ function SheetPortal({ ...props }) {
742
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SheetPrimitive.Portal, { ...props });
743
+ }
744
+ function SheetOverlay({
745
+ className,
746
+ ...props
747
+ }) {
748
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
749
+ SheetPrimitive.Overlay,
750
+ {
751
+ className: cn(
752
+ "fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",
753
+ className
754
+ ),
755
+ ...props
756
+ }
757
+ );
758
+ }
759
+ function SheetContent({
760
+ side = "right",
761
+ className,
762
+ children,
763
+ ...props
764
+ }) {
765
+ const { t } = useChatkitTranslation();
766
+ const sideVariants = {
767
+ top: "inset-x-0 top-0 border-b data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top",
768
+ bottom: "inset-x-0 bottom-0 border-t data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom",
769
+ left: "inset-y-0 left-0 h-full w-3/4 border-r data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left sm:max-w-sm",
770
+ right: "inset-y-0 right-0 h-full w-3/4 border-l data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right sm:max-w-sm"
771
+ };
772
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(SheetPortal, { children: [
773
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(SheetOverlay, {}),
774
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
775
+ SheetPrimitive.Content,
776
+ {
777
+ className: cn(
778
+ "fixed z-50 gap-4 bg-background p-6 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500 data-[state=open]:animate-in data-[state=closed]:animate-out",
779
+ sideVariants[side],
780
+ className
781
+ ),
782
+ ...props,
783
+ children: [
784
+ children,
785
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(SheetPrimitive.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-secondary", children: [
786
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
787
+ "svg",
788
+ {
789
+ xmlns: "http://www.w3.org/2000/svg",
790
+ width: "16",
791
+ height: "16",
792
+ viewBox: "0 0 24 24",
793
+ fill: "none",
794
+ stroke: "currentColor",
795
+ strokeWidth: "2",
796
+ strokeLinecap: "round",
797
+ strokeLinejoin: "round",
798
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M18 6 6 18M6 6l12 12" })
799
+ }
800
+ ),
801
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "sr-only", children: t("sheet.close") })
802
+ ] })
803
+ ]
804
+ }
805
+ )
806
+ ] });
807
+ }
808
+ function SheetHeader({
809
+ className,
810
+ ...props
811
+ }) {
812
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
813
+ "div",
814
+ {
815
+ className: cn(
816
+ "flex flex-col space-y-2 text-center sm:text-left",
817
+ className
818
+ ),
819
+ ...props
820
+ }
821
+ );
822
+ }
823
+ function SheetTitle({
824
+ className,
825
+ ...props
826
+ }) {
827
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
828
+ SheetPrimitive.Title,
829
+ {
830
+ className: cn("text-lg font-semibold text-foreground", className),
831
+ ...props
832
+ }
833
+ );
834
+ }
835
+
836
+ // src/components/history/HistorySidebar.tsx
837
+ var import_jsx_runtime8 = require("react/jsx-runtime");
838
+ function HistoryIcon() {
839
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
840
+ "svg",
841
+ {
842
+ xmlns: "http://www.w3.org/2000/svg",
843
+ width: "18",
844
+ height: "18",
845
+ viewBox: "0 0 24 24",
846
+ fill: "none",
847
+ stroke: "currentColor",
848
+ strokeWidth: "2",
849
+ strokeLinecap: "round",
850
+ strokeLinejoin: "round",
851
+ children: [
852
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" }),
853
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M3 3v5h5" }),
854
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M12 7v5l4 2" })
855
+ ]
856
+ }
857
+ );
858
+ }
859
+ function PlusCircleIcon() {
860
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
861
+ "svg",
862
+ {
863
+ xmlns: "http://www.w3.org/2000/svg",
864
+ width: "16",
865
+ height: "16",
866
+ viewBox: "0 0 24 24",
867
+ fill: "none",
868
+ stroke: "currentColor",
869
+ strokeWidth: "2",
870
+ strokeLinecap: "round",
871
+ strokeLinejoin: "round",
872
+ children: [
873
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
874
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M8 12h8M12 8v8" })
875
+ ]
876
+ }
877
+ );
878
+ }
879
+ function MessageIcon() {
880
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
881
+ "svg",
882
+ {
883
+ xmlns: "http://www.w3.org/2000/svg",
884
+ width: "16",
885
+ height: "16",
886
+ viewBox: "0 0 24 24",
887
+ fill: "none",
888
+ stroke: "currentColor",
889
+ strokeWidth: "2",
890
+ strokeLinecap: "round",
891
+ strokeLinejoin: "round",
892
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
893
+ }
894
+ );
895
+ }
896
+ function TrashIcon() {
897
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
898
+ "svg",
899
+ {
900
+ xmlns: "http://www.w3.org/2000/svg",
901
+ width: "14",
902
+ height: "14",
903
+ viewBox: "0 0 24 24",
904
+ fill: "none",
905
+ stroke: "currentColor",
906
+ strokeWidth: "2",
907
+ strokeLinecap: "round",
908
+ strokeLinejoin: "round",
909
+ children: [
910
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M3 6h18" }),
911
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6" }),
912
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2" })
913
+ ]
914
+ }
915
+ );
916
+ }
917
+ function HistorySidebar({
918
+ conversations = [],
919
+ currentConversationId,
920
+ onNewConversation,
921
+ onSelectConversation,
922
+ onDeleteConversation,
923
+ showDelete = true,
924
+ disabled = false
925
+ }) {
926
+ const { t } = useChatkitTranslation();
927
+ const [open, setOpen] = React8.useState(false);
928
+ const handleNewConversation = () => {
929
+ onNewConversation?.();
930
+ setOpen(false);
931
+ };
932
+ const handleSelectConversation = (id) => {
933
+ onSelectConversation?.(id);
934
+ setOpen(false);
935
+ };
936
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(Sheet, { open, onOpenChange: setOpen, children: [
937
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SheetTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
938
+ Button,
939
+ {
940
+ variant: "ghost",
941
+ size: "icon",
942
+ disabled,
943
+ className: "h-8 w-8",
944
+ children: [
945
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(HistoryIcon, {}),
946
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "sr-only", children: t("history.conversationHistory") })
947
+ ]
948
+ }
949
+ ) }),
950
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(SheetContent, { side: "right", className: "w-80 p-0", children: [
951
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SheetHeader, { className: "border-b p-4", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SheetTitle, { children: t("history.title") }) }),
952
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "p-4", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
953
+ Button,
954
+ {
955
+ onClick: handleNewConversation,
956
+ className: "w-full justify-start gap-2",
957
+ variant: "secondary",
958
+ children: [
959
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PlusCircleIcon, {}),
960
+ t("history.newChat")
961
+ ]
962
+ }
963
+ ) }),
964
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ScrollArea, { className: "h-[calc(100vh-140px)]", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "px-4 pb-4", children: conversations.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "py-8 text-center text-sm text-muted-foreground", children: t("history.empty") }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "space-y-1", children: conversations.map((conversation) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
965
+ "div",
966
+ {
967
+ className: cn(
968
+ "group flex items-center gap-2 rounded-lg px-3 py-2 text-sm transition-colors",
969
+ "hover:bg-muted cursor-pointer",
970
+ currentConversationId === conversation.id && "bg-muted"
971
+ ),
972
+ onClick: () => handleSelectConversation(conversation.id),
973
+ children: [
974
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(MessageIcon, {}) }),
975
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { className: "flex-1 truncate", children: conversation.title }),
976
+ showDelete && onDeleteConversation && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
977
+ "button",
978
+ {
979
+ type: "button",
980
+ onClick: (e) => {
981
+ e.stopPropagation();
982
+ onDeleteConversation(conversation.id);
983
+ },
984
+ className: "opacity-0 group-hover:opacity-100 p-1 rounded hover:bg-destructive/10 hover:text-destructive transition-all",
985
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TrashIcon, {})
986
+ }
987
+ )
988
+ ]
989
+ },
990
+ conversation.id
991
+ )) }) }) })
992
+ ] })
993
+ ] });
994
+ }
995
+
996
+ // src/components/thread/messages/ai.tsx
997
+ var React13 = require("react");
998
+
999
+ // src/components/ui/badge.tsx
1000
+ var React9 = __toESM(require("react"), 1);
1001
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1002
+ var base2 = "inline-flex items-center rounded-full border border-transparent px-2.5 py-0.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background";
1003
+ var variants2 = {
1004
+ default: "bg-primary text-primary-foreground",
1005
+ secondary: "bg-secondary text-secondary-foreground",
1006
+ outline: "border-input text-foreground"
1007
+ };
1008
+ var Badge = React9.forwardRef(
1009
+ ({ className, variant = "default", ...props }, ref) => {
1010
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { ref, className: cn(base2, variants2[variant], className), ...props });
1011
+ }
1012
+ );
1013
+ Badge.displayName = "Badge";
1014
+
1015
+ // src/components/ui/card.tsx
1016
+ var React10 = __toESM(require("react"), 1);
1017
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1018
+ var Card = React10.forwardRef(
1019
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1020
+ "div",
1021
+ {
1022
+ ref,
1023
+ className: cn(
1024
+ "rounded-xl border bg-background/80 text-foreground shadow-[0_14px_40px_-30px_rgba(15,23,42,0.5)] backdrop-blur",
1025
+ className
1026
+ ),
1027
+ ...props
1028
+ }
1029
+ )
1030
+ );
1031
+ Card.displayName = "Card";
1032
+ var CardHeader = React10.forwardRef(
1033
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref, className: cn("flex flex-col gap-1.5 px-6 pt-6", className), ...props })
1034
+ );
1035
+ CardHeader.displayName = "CardHeader";
1036
+ var CardTitle = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("h3", { ref, className: cn("text-lg font-semibold leading-tight", className), ...props }));
1037
+ CardTitle.displayName = "CardTitle";
1038
+ var CardDescription = React10.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("p", { ref, className: cn("text-sm text-muted-foreground", className), ...props }));
1039
+ CardDescription.displayName = "CardDescription";
1040
+ var CardContent = React10.forwardRef(
1041
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref, className: cn("px-6 pb-6", className), ...props })
1042
+ );
1043
+ CardContent.displayName = "CardContent";
1044
+ var CardFooter = React10.forwardRef(
1045
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref, className: cn("flex items-center px-6 pb-6", className), ...props })
1046
+ );
1047
+ CardFooter.displayName = "CardFooter";
1048
+ var CardAction = React10.forwardRef(
1049
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { ref, className: cn("ml-auto flex items-center", className), ...props })
1050
+ );
1051
+ CardAction.displayName = "CardAction";
1052
+
1053
+ // src/components/ui/tabs.tsx
1054
+ var React11 = __toESM(require("react"), 1);
1055
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1056
+ var TabsContext = React11.createContext(null);
1057
+ function Tabs({ className, defaultValue, value, onValueChange, ...props }) {
1058
+ const [internalValue, setInternalValue] = React11.useState(defaultValue ?? "");
1059
+ const activeValue = value ?? internalValue;
1060
+ const setValue = React11.useCallback(
1061
+ (nextValue) => {
1062
+ if (value === void 0) setInternalValue(nextValue);
1063
+ onValueChange?.(nextValue);
1064
+ },
1065
+ [onValueChange, value]
1066
+ );
1067
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(TabsContext.Provider, { value: { value: activeValue, setValue }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { className: cn("w-full", className), ...props }) });
1068
+ }
1069
+ var TabsList = React11.forwardRef(
1070
+ ({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1071
+ "div",
1072
+ {
1073
+ ref,
1074
+ className: cn(
1075
+ "inline-flex h-11 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",
1076
+ className
1077
+ ),
1078
+ role: "tablist",
1079
+ ...props
1080
+ }
1081
+ )
1082
+ );
1083
+ TabsList.displayName = "TabsList";
1084
+ var TabsTrigger = React11.forwardRef(
1085
+ ({ className, value, onClick, ...props }, ref) => {
1086
+ const context = React11.useContext(TabsContext);
1087
+ if (!context) {
1088
+ throw new Error("TabsTrigger must be used within Tabs");
1089
+ }
1090
+ const isActive = context.value === value;
1091
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1092
+ "button",
1093
+ {
1094
+ ref,
1095
+ type: "button",
1096
+ role: "tab",
1097
+ "aria-selected": isActive,
1098
+ "data-state": isActive ? "active" : "inactive",
1099
+ className: cn(
1100
+ "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-2 text-sm font-medium transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
1101
+ className
1102
+ ),
1103
+ onClick: (event) => {
1104
+ context.setValue(value);
1105
+ onClick?.(event);
1106
+ },
1107
+ ...props
1108
+ }
1109
+ );
1110
+ }
1111
+ );
1112
+ TabsTrigger.displayName = "TabsTrigger";
1113
+ var TabsContent = React11.forwardRef(
1114
+ ({ className, value, ...props }, ref) => {
1115
+ const context = React11.useContext(TabsContext);
1116
+ if (!context) {
1117
+ throw new Error("TabsContent must be used within Tabs");
1118
+ }
1119
+ if (context.value !== value) return null;
1120
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1121
+ "div",
1122
+ {
1123
+ ref,
1124
+ role: "tabpanel",
1125
+ className: cn(
1126
+ "mt-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ring-offset-background",
1127
+ className
1128
+ ),
1129
+ ...props
1130
+ }
1131
+ );
1132
+ }
1133
+ );
1134
+ TabsContent.displayName = "TabsContent";
1135
+
1136
+ // src/components/thread/markdown-text.tsx
1137
+ var import_react_markdown = __toESM(require("react-markdown"), 1);
1138
+ var import_remark_gfm = __toESM(require("remark-gfm"), 1);
1139
+ var import_rehype_katex = __toESM(require("rehype-katex"), 1);
1140
+ var import_remark_math = __toESM(require("remark-math"), 1);
1141
+ var import_react5 = require("react");
1142
+ var import_lucide_react = require("lucide-react");
1143
+
1144
+ // src/components/thread/syntax-highlighter.tsx
1145
+ var import_react_syntax_highlighter = require("react-syntax-highlighter");
1146
+ var import_tsx = __toESM(require("react-syntax-highlighter/dist/esm/languages/prism/tsx"), 1);
1147
+ var import_python = __toESM(require("react-syntax-highlighter/dist/esm/languages/prism/python"), 1);
1148
+ var import_prism = require("react-syntax-highlighter/dist/cjs/styles/prism");
1149
+ var import_react3 = require("react");
1150
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1151
+ import_react_syntax_highlighter.PrismAsyncLight.registerLanguage("js", import_tsx.default);
1152
+ import_react_syntax_highlighter.PrismAsyncLight.registerLanguage("jsx", import_tsx.default);
1153
+ import_react_syntax_highlighter.PrismAsyncLight.registerLanguage("ts", import_tsx.default);
1154
+ import_react_syntax_highlighter.PrismAsyncLight.registerLanguage("tsx", import_tsx.default);
1155
+ import_react_syntax_highlighter.PrismAsyncLight.registerLanguage("python", import_python.default);
1156
+ var SyntaxHighlighter = ({
1157
+ children,
1158
+ language,
1159
+ className
1160
+ }) => {
1161
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1162
+ import_react_syntax_highlighter.PrismAsyncLight,
1163
+ {
1164
+ language,
1165
+ style: import_prism.coldarkDark,
1166
+ customStyle: {
1167
+ margin: 0,
1168
+ width: "100%",
1169
+ background: "transparent",
1170
+ padding: "1.5rem 1rem"
1171
+ },
1172
+ className,
1173
+ children
1174
+ }
1175
+ );
1176
+ };
1177
+
1178
+ // src/components/thread/tooltip-icon-button.tsx
1179
+ var import_react4 = require("react");
1180
+
1181
+ // src/components/ui/tooltip.tsx
1182
+ var React12 = require("react");
1183
+ var TooltipPrimitive = __toESM(require("@radix-ui/react-tooltip"), 1);
1184
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1185
+ function TooltipProvider({
1186
+ delayDuration = 0,
1187
+ ...props
1188
+ }) {
1189
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1190
+ TooltipPrimitive.Provider,
1191
+ {
1192
+ "data-slot": "tooltip-provider",
1193
+ delayDuration,
1194
+ ...props
1195
+ }
1196
+ );
1197
+ }
1198
+ function Tooltip({
1199
+ ...props
1200
+ }) {
1201
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1202
+ TooltipPrimitive.Root,
1203
+ {
1204
+ "data-slot": "tooltip",
1205
+ ...props
1206
+ }
1207
+ ) });
1208
+ }
1209
+ function TooltipTrigger({
1210
+ ...props
1211
+ }) {
1212
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
1213
+ TooltipPrimitive.Trigger,
1214
+ {
1215
+ "data-slot": "tooltip-trigger",
1216
+ ...props
1217
+ }
1218
+ );
1219
+ }
1220
+ function TooltipContent({
1221
+ className,
1222
+ sideOffset = 0,
1223
+ children,
1224
+ ...props
1225
+ }) {
1226
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipPrimitive.Portal, { children: /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
1227
+ TooltipPrimitive.Content,
1228
+ {
1229
+ "data-slot": "tooltip-content",
1230
+ sideOffset,
1231
+ className: cn(
1232
+ "bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit rounded-md px-3 py-1.5 text-xs text-balance",
1233
+ className
1234
+ ),
1235
+ ...props,
1236
+ children: [
1237
+ children,
1238
+ /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(TooltipPrimitive.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })
1239
+ ]
1240
+ }
1241
+ ) });
1242
+ }
1243
+
1244
+ // src/components/thread/tooltip-icon-button.tsx
1245
+ var import_jsx_runtime14 = require("react/jsx-runtime");
1246
+ var TooltipIconButton = (0, import_react4.forwardRef)(({ children, tooltip, side = "bottom", className, ...rest }, ref) => {
1247
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(Tooltip, { children: [
1248
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipTrigger, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
1249
+ Button,
1250
+ {
1251
+ variant: "ghost",
1252
+ size: "icon",
1253
+ ...rest,
1254
+ className: cn("size-6 p-1", className),
1255
+ ref,
1256
+ children: [
1257
+ children,
1258
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "sr-only", children: tooltip })
1259
+ ]
1260
+ }
1261
+ ) }),
1262
+ /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(TooltipContent, { side, children: tooltip })
1263
+ ] }) });
1264
+ });
1265
+ TooltipIconButton.displayName = "TooltipIconButton";
1266
+
1267
+ // src/components/thread/markdown-text.tsx
1268
+ var import_katex_min = require("katex/dist/katex.min.css");
1269
+ var import_jsx_runtime15 = require("react/jsx-runtime");
1270
+ var useCopyToClipboard = ({
1271
+ copiedDuration = 3e3
1272
+ } = {}) => {
1273
+ const [isCopied, setIsCopied] = (0, import_react5.useState)(false);
1274
+ const copyToClipboard = (value) => {
1275
+ if (!value) return;
1276
+ navigator.clipboard.writeText(value).then(() => {
1277
+ setIsCopied(true);
1278
+ setTimeout(() => setIsCopied(false), copiedDuration);
1279
+ });
1280
+ };
1281
+ return { isCopied, copyToClipboard };
1282
+ };
1283
+ var CodeHeader = ({ language, code }) => {
1284
+ const { t } = useChatkitTranslation();
1285
+ const { isCopied, copyToClipboard } = useCopyToClipboard();
1286
+ const onCopy = () => {
1287
+ if (!code || isCopied) return;
1288
+ copyToClipboard(code);
1289
+ };
1290
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between gap-4 rounded-t-lg bg-zinc-900 px-4 py-2 text-sm font-semibold text-white", children: [
1291
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "lowercase [&>span]:text-xs", children: language }),
1292
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
1293
+ TooltipIconButton,
1294
+ {
1295
+ tooltip: t("markdown.copy"),
1296
+ onClick: onCopy,
1297
+ children: [
1298
+ !isCopied && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react.CopyIcon, {}),
1299
+ isCopied && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react.CheckIcon, {})
1300
+ ]
1301
+ }
1302
+ )
1303
+ ] });
1304
+ };
1305
+ var defaultComponents = {
1306
+ h1: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1307
+ "h1",
1308
+ {
1309
+ className: cn(
1310
+ "mb-8 scroll-m-20 text-4xl font-extrabold tracking-tight last:mb-0",
1311
+ className
1312
+ ),
1313
+ ...props
1314
+ }
1315
+ ),
1316
+ h2: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1317
+ "h2",
1318
+ {
1319
+ className: cn(
1320
+ "mt-8 mb-4 scroll-m-20 text-3xl font-semibold tracking-tight first:mt-0 last:mb-0",
1321
+ className
1322
+ ),
1323
+ ...props
1324
+ }
1325
+ ),
1326
+ h3: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1327
+ "h3",
1328
+ {
1329
+ className: cn(
1330
+ "mt-6 mb-4 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0 last:mb-0",
1331
+ className
1332
+ ),
1333
+ ...props
1334
+ }
1335
+ ),
1336
+ h4: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1337
+ "h4",
1338
+ {
1339
+ className: cn(
1340
+ "mt-6 mb-4 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0 last:mb-0",
1341
+ className
1342
+ ),
1343
+ ...props
1344
+ }
1345
+ ),
1346
+ h5: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1347
+ "h5",
1348
+ {
1349
+ className: cn(
1350
+ "my-4 text-lg font-semibold first:mt-0 last:mb-0",
1351
+ className
1352
+ ),
1353
+ ...props
1354
+ }
1355
+ ),
1356
+ h6: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1357
+ "h6",
1358
+ {
1359
+ className: cn("my-4 font-semibold first:mt-0 last:mb-0", className),
1360
+ ...props
1361
+ }
1362
+ ),
1363
+ p: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1364
+ "p",
1365
+ {
1366
+ className: cn("mt-5 mb-5 leading-7 first:mt-0 last:mb-0", className),
1367
+ ...props
1368
+ }
1369
+ ),
1370
+ a: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1371
+ "a",
1372
+ {
1373
+ className: cn(
1374
+ "text-primary font-medium underline underline-offset-4",
1375
+ className
1376
+ ),
1377
+ ...props
1378
+ }
1379
+ ),
1380
+ blockquote: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1381
+ "blockquote",
1382
+ {
1383
+ className: cn("border-l-2 pl-6 italic", className),
1384
+ ...props
1385
+ }
1386
+ ),
1387
+ ul: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1388
+ "ul",
1389
+ {
1390
+ className: cn("my-5 ml-6 list-disc [&>li]:mt-2", className),
1391
+ ...props
1392
+ }
1393
+ ),
1394
+ ol: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1395
+ "ol",
1396
+ {
1397
+ className: cn("my-5 ml-6 list-decimal [&>li]:mt-2", className),
1398
+ ...props
1399
+ }
1400
+ ),
1401
+ hr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1402
+ "hr",
1403
+ {
1404
+ className: cn("my-5 border-b", className),
1405
+ ...props
1406
+ }
1407
+ ),
1408
+ table: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1409
+ "table",
1410
+ {
1411
+ className: cn(
1412
+ "my-5 w-full border-separate border-spacing-0 overflow-y-auto",
1413
+ className
1414
+ ),
1415
+ ...props
1416
+ }
1417
+ ),
1418
+ th: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1419
+ "th",
1420
+ {
1421
+ className: cn(
1422
+ "bg-muted px-4 py-2 text-left font-bold first:rounded-tl-lg last:rounded-tr-lg [&[align=center]]:text-center [&[align=right]]:text-right",
1423
+ className
1424
+ ),
1425
+ ...props
1426
+ }
1427
+ ),
1428
+ td: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1429
+ "td",
1430
+ {
1431
+ className: cn(
1432
+ "border-b border-l px-4 py-2 text-left last:border-r [&[align=center]]:text-center [&[align=right]]:text-right",
1433
+ className
1434
+ ),
1435
+ ...props
1436
+ }
1437
+ ),
1438
+ tr: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1439
+ "tr",
1440
+ {
1441
+ className: cn(
1442
+ "m-0 border-b p-0 first:border-t [&:last-child>td:first-child]:rounded-bl-lg [&:last-child>td:last-child]:rounded-br-lg",
1443
+ className
1444
+ ),
1445
+ ...props
1446
+ }
1447
+ ),
1448
+ sup: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1449
+ "sup",
1450
+ {
1451
+ className: cn("[&>a]:text-xs [&>a]:no-underline", className),
1452
+ ...props
1453
+ }
1454
+ ),
1455
+ pre: ({ className, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1456
+ "pre",
1457
+ {
1458
+ className: cn(
1459
+ "max-w-4xl overflow-x-auto rounded-lg bg-black text-white",
1460
+ className
1461
+ ),
1462
+ ...props
1463
+ }
1464
+ ),
1465
+ code: ({
1466
+ className,
1467
+ children,
1468
+ ...props
1469
+ }) => {
1470
+ const match = /language-(\w+)/.exec(className || "");
1471
+ if (match) {
1472
+ const language = match[1];
1473
+ const code = String(children).replace(/\n$/, "");
1474
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
1475
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1476
+ CodeHeader,
1477
+ {
1478
+ language,
1479
+ code
1480
+ }
1481
+ ),
1482
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1483
+ SyntaxHighlighter,
1484
+ {
1485
+ language,
1486
+ className,
1487
+ children: code
1488
+ }
1489
+ )
1490
+ ] });
1491
+ }
1492
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1493
+ "code",
1494
+ {
1495
+ className: cn("rounded font-semibold", className),
1496
+ ...props,
1497
+ children
1498
+ }
1499
+ );
1500
+ }
1501
+ };
1502
+ var MarkdownTextImpl = ({ children }) => {
1503
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { className: "markdown-content", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
1504
+ import_react_markdown.default,
1505
+ {
1506
+ remarkPlugins: [import_remark_gfm.default, import_remark_math.default],
1507
+ rehypePlugins: [import_rehype_katex.default],
1508
+ components: defaultComponents,
1509
+ children
1510
+ }
1511
+ ) });
1512
+ };
1513
+ var MarkdownText = (0, import_react5.memo)(MarkdownTextImpl);
1514
+
1515
+ // src/components/thread/messages/widget.tsx
1516
+ var import_a2ui_react = require("@xpert-ai/a2ui-react");
1517
+ var import_jsx_runtime16 = require("react/jsx-runtime");
1518
+ function WidgetMessage({ messageId, data }) {
1519
+ const widgets = Array.isArray(data.widgets) ? data.widgets : [];
1520
+ if (widgets.length === 0) return null;
1521
+ const baseSurfaceId = `widget-${messageId}`;
1522
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("div", { className: "space-y-3", children: widgets.map((widget, index) => {
1523
+ const config = widget?.config;
1524
+ if (!config || typeof config !== "object") {
1525
+ return null;
1526
+ }
1527
+ const surfaceId = widgets.length > 1 ? `${baseSurfaceId}-${index}` : baseSurfaceId;
1528
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1529
+ import_a2ui_react.SurfaceRenderer,
1530
+ {
1531
+ surfaceId,
1532
+ surface: config
1533
+ },
1534
+ widget?.name ?? surfaceId
1535
+ );
1536
+ }) });
1537
+ }
1538
+
1539
+ // src/components/thread/messages/ai.tsx
1540
+ var import_jsx_runtime17 = require("react/jsx-runtime");
1541
+ function isTextContent(content) {
1542
+ return content.type === "text";
1543
+ }
1544
+ function isReasoningContent(content) {
1545
+ return content.type === "reasoning";
1546
+ }
1547
+ function isImageContent(content) {
1548
+ return content.type === "image_url";
1549
+ }
1550
+ function isComponentContent(content) {
1551
+ return content.type === "component";
1552
+ }
1553
+ function isWidgetComponent(content) {
1554
+ const data = content.data;
1555
+ return data?.type === "Widget" && Array.isArray(data.widgets);
1556
+ }
1557
+ function isMemoryContent(content) {
1558
+ return content.type === "memory";
1559
+ }
1560
+ function safeJson(value) {
1561
+ try {
1562
+ return JSON.stringify(value, null, 2);
1563
+ } catch {
1564
+ return String(value);
1565
+ }
1566
+ }
1567
+ function ReasoningBlock({ reasoning }) {
1568
+ const blocks = reasoning.filter((item) => item.text?.trim());
1569
+ if (blocks.length === 0) return null;
1570
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "space-y-2", children: blocks.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
1571
+ "div",
1572
+ {
1573
+ className: "rounded-lg border bg-muted/40 p-3 text-xs text-muted-foreground",
1574
+ children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "whitespace-pre-wrap break-words leading-relaxed", children: item.text })
1575
+ },
1576
+ item.id ?? `reasoning-${index}`
1577
+ )) });
1578
+ }
1579
+ function ImageBlock({ content }) {
1580
+ const imageUrl = typeof content.image_url === "string" ? content.image_url : typeof content.image_url?.url === "string" ? content.image_url.url : null;
1581
+ if (!imageUrl) {
1582
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Card, { children: [
1583
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardHeader, { className: "space-y-1", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardTitle, { className: "text-sm", children: "Image" }) }),
1584
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardContent, { className: "text-xs text-muted-foreground", children: safeJson(content) })
1585
+ ] });
1586
+ }
1587
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("figure", { className: "overflow-hidden rounded-lg border bg-background", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("img", { src: imageUrl, alt: "Assistant output", className: "h-auto w-full object-cover" }) });
1588
+ }
1589
+ function MemoryBlock({ content }) {
1590
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Card, { children: [
1591
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(CardHeader, { className: "flex flex-row items-center justify-between gap-2", children: [
1592
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardTitle, { className: "text-sm", children: "Memory" }),
1593
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Badge, { variant: "secondary", children: "Memory" })
1594
+ ] }),
1595
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardContent, { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("pre", { className: "whitespace-pre-wrap break-words", children: safeJson(content.data ?? []) }) })
1596
+ ] });
1597
+ }
1598
+ function ComponentBlock({ content }) {
1599
+ console.log(content);
1600
+ const data = content.data ?? {};
1601
+ const title = typeof data.title === "string" ? data.title : typeof data.type === "string" ? data.type : "Component";
1602
+ const category = typeof data.category === "string" ? data.category : "Component";
1603
+ const status = typeof data.status === "string" ? data.status : null;
1604
+ const message = typeof data.message === "string" ? data.message : null;
1605
+ const output = typeof data.output === "string" ? data.output : null;
1606
+ const fallback = message ?? output ?? safeJson(data.data ?? data.input ?? data);
1607
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Card, { children: [
1608
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(CardHeader, { className: "flex flex-row items-center justify-between gap-2", children: [
1609
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "space-y-1", children: [
1610
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardTitle, { className: "text-sm", children: title }),
1611
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("p", { className: "text-xs text-muted-foreground", children: category })
1612
+ ] }),
1613
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-wrap items-center gap-2", children: [
1614
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Badge, { variant: "secondary", children: category }),
1615
+ status && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Badge, { variant: "outline", children: status })
1616
+ ] })
1617
+ ] }),
1618
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardContent, { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("pre", { className: "whitespace-pre-wrap break-words", children: fallback }) })
1619
+ ] });
1620
+ }
1621
+ function UnknownBlock({ content }) {
1622
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(Card, { children: [
1623
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(CardHeader, { className: "flex flex-row items-center justify-between gap-2", children: [
1624
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardTitle, { className: "text-sm", children: "Assistant Content" }),
1625
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(Badge, { variant: "outline", children: content.type ?? "unknown" })
1626
+ ] }),
1627
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CardContent, { className: "text-xs text-muted-foreground", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("pre", { className: "whitespace-pre-wrap break-words", children: safeJson(content) }) })
1628
+ ] });
1629
+ }
1630
+ function renderContentItem(content, index, messageId) {
1631
+ if (typeof content === "string") {
1632
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { children: [
1633
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MarkdownText, { children: content }),
1634
+ ";"
1635
+ ] }, `text-${index}`);
1636
+ }
1637
+ if (isTextContent(content)) {
1638
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MarkdownText, { children: content.text }) }, content.id ?? `text-${index}`);
1639
+ }
1640
+ if (isReasoningContent(content)) {
1641
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ReasoningBlock, { reasoning: [content] }) }, content.id ?? `reasoning-${index}`);
1642
+ }
1643
+ if (isImageContent(content)) {
1644
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ImageBlock, { content }) }, content.id ?? `image-${index}`);
1645
+ }
1646
+ if (isComponentContent(content)) {
1647
+ if (isWidgetComponent(content)) {
1648
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(WidgetMessage, { messageId, data: content.data }) }, content.id ?? `widget-${index}`);
1649
+ }
1650
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ComponentBlock, { content }) }, content.id ?? `component-${index}`);
1651
+ }
1652
+ if (isMemoryContent(content)) {
1653
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MemoryBlock, { content }) }, content.id ?? `memory-${index}`);
1654
+ }
1655
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(UnknownBlock, { content }) }, content.id ?? `unknown-${index}`);
1656
+ }
1657
+ function renderContent(content, messageId) {
1658
+ if (typeof content === "string") {
1659
+ if (!content.trim()) return null;
1660
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(MarkdownText, { children: content });
1661
+ }
1662
+ if (!Array.isArray(content) || content.length === 0) return null;
1663
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "space-y-3", children: content.map((item, index) => renderContentItem(item, index, messageId)) });
1664
+ }
1665
+ function AssistantMessage({ message, className, isStreaming = false }) {
1666
+ const hasContent = message.content != null && !(typeof message.content === "string" && message.content.trim() === "" || Array.isArray(message.content) && message.content.length === 0);
1667
+ const hasReasoning = Array.isArray(message.reasoning) && message.reasoning.some((item) => item.text?.trim());
1668
+ const answerNode = renderContent(message.content, message.id);
1669
+ const reasoningNode = hasReasoning ? /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(ReasoningBlock, { reasoning: message.reasoning ?? [] }) : null;
1670
+ if (!hasContent && !hasReasoning) return null;
1671
+ const streamingClass = isStreaming ? "streaming-active" : "";
1672
+ if (hasContent && hasReasoning) {
1673
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("space-y-3", streamingClass, className), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
1674
+ Tabs,
1675
+ {
1676
+ defaultValue: message.status === "reasoning" ? "reasoning" : "answer",
1677
+ className: "w-full",
1678
+ children: [
1679
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(TabsList, { className: "h-9", children: [
1680
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabsTrigger, { value: "answer", children: "Answer" }),
1681
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabsTrigger, { value: "reasoning", children: "Reasoning" })
1682
+ ] }),
1683
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabsContent, { value: "answer", className: "space-y-3", children: answerNode }),
1684
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(TabsContent, { value: "reasoning", className: "space-y-3", children: reasoningNode })
1685
+ ]
1686
+ }
1687
+ ) });
1688
+ }
1689
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: cn("space-y-3", streamingClass, className), children: hasReasoning ? reasoningNode : answerNode });
1690
+ }
1691
+
1692
+ // src/components/thread/MessageActions.tsx
1693
+ var React14 = __toESM(require("react"), 1);
1694
+ var import_jsx_runtime18 = require("react/jsx-runtime");
1695
+ function CopyIcon2() {
1696
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1697
+ "svg",
1698
+ {
1699
+ xmlns: "http://www.w3.org/2000/svg",
1700
+ width: "14",
1701
+ height: "14",
1702
+ viewBox: "0 0 24 24",
1703
+ fill: "none",
1704
+ stroke: "currentColor",
1705
+ strokeWidth: "2",
1706
+ strokeLinecap: "round",
1707
+ strokeLinejoin: "round",
1708
+ children: [
1709
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2" }),
1710
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" })
1711
+ ]
1712
+ }
1713
+ );
1714
+ }
1715
+ function CheckIcon2() {
1716
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1717
+ "svg",
1718
+ {
1719
+ xmlns: "http://www.w3.org/2000/svg",
1720
+ width: "14",
1721
+ height: "14",
1722
+ viewBox: "0 0 24 24",
1723
+ fill: "none",
1724
+ stroke: "currentColor",
1725
+ strokeWidth: "2",
1726
+ strokeLinecap: "round",
1727
+ strokeLinejoin: "round",
1728
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M20 6 9 17l-5-5" })
1729
+ }
1730
+ );
1731
+ }
1732
+ function RetryIcon() {
1733
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1734
+ "svg",
1735
+ {
1736
+ xmlns: "http://www.w3.org/2000/svg",
1737
+ width: "14",
1738
+ height: "14",
1739
+ viewBox: "0 0 24 24",
1740
+ fill: "none",
1741
+ stroke: "currentColor",
1742
+ strokeWidth: "2",
1743
+ strokeLinecap: "round",
1744
+ strokeLinejoin: "round",
1745
+ children: [
1746
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8" }),
1747
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M21 3v5h-5" }),
1748
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16" }),
1749
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("path", { d: "M8 16H3v5" })
1750
+ ]
1751
+ }
1752
+ );
1753
+ }
1754
+ function MessageActions({
1755
+ content,
1756
+ isAssistant = false,
1757
+ isStreaming = false,
1758
+ onRetry,
1759
+ className
1760
+ }) {
1761
+ const { t } = useChatkitTranslation();
1762
+ const [copied, setCopied] = React14.useState(false);
1763
+ const handleCopy = async () => {
1764
+ try {
1765
+ await navigator.clipboard.writeText(content);
1766
+ setCopied(true);
1767
+ setTimeout(() => setCopied(false), 2e3);
1768
+ } catch (err) {
1769
+ console.error("Failed to copy:", err);
1770
+ }
1771
+ };
1772
+ if (isStreaming) {
1773
+ return null;
1774
+ }
1775
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1776
+ "div",
1777
+ {
1778
+ className: cn(
1779
+ "flex items-center gap-1 mt-2 opacity-0 group-hover:opacity-100 transition-opacity",
1780
+ className
1781
+ ),
1782
+ children: [
1783
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1784
+ "button",
1785
+ {
1786
+ type: "button",
1787
+ onClick: handleCopy,
1788
+ className: cn(
1789
+ "p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
1790
+ copied && "text-green-500"
1791
+ ),
1792
+ title: copied ? t("messageActions.copied") : t("messageActions.copy"),
1793
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CheckIcon2, {}) : /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(CopyIcon2, {})
1794
+ }
1795
+ ),
1796
+ isAssistant && onRetry && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1797
+ "button",
1798
+ {
1799
+ type: "button",
1800
+ onClick: onRetry,
1801
+ className: "p-1.5 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted transition-colors",
1802
+ title: t("messageActions.regenerate"),
1803
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RetryIcon, {})
1804
+ }
1805
+ )
1806
+ ]
1807
+ }
1808
+ );
1809
+ }
1810
+
1811
+ // src/components/thread/StartScreen.tsx
1812
+ var React15 = require("react");
1813
+ var import_jsx_runtime19 = require("react/jsx-runtime");
1814
+ function getIconComponent2(icon) {
1815
+ const iconMap = {
1816
+ "circle-question": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1817
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1818
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" }),
1819
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M12 17h.01" })
1820
+ ] }),
1821
+ "lightbulb": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1822
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5" }),
1823
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M9 18h6" }),
1824
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M10 22h4" })
1825
+ ] }),
1826
+ "sparkle": /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M9.937 15.5A2 2 0 0 0 8.5 14.063l-6.135-1.582a.5.5 0 0 1 0-.962L8.5 9.936A2 2 0 0 0 9.937 8.5l1.582-6.135a.5.5 0 0 1 .963 0L14.063 8.5A2 2 0 0 0 15.5 9.937l6.135 1.581a.5.5 0 0 1 0 .964L15.5 14.063a2 2 0 0 0-1.437 1.437l-1.582 6.135a.5.5 0 0 1-.963 0z" }) }),
1827
+ "write": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1828
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M12 20h9" }),
1829
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
1830
+ ] }),
1831
+ "search": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1832
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "11", cy: "11", r: "8" }),
1833
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "m21 21-4.3-4.3" })
1834
+ ] }),
1835
+ "globe": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1836
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1837
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("line", { x1: "2", x2: "22", y1: "12", y2: "12" }),
1838
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z" })
1839
+ ] }),
1840
+ "book-open": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1841
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" }),
1842
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z" })
1843
+ ] }),
1844
+ "compass": /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
1845
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
1846
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("polygon", { points: "16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76" })
1847
+ ] }),
1848
+ "bolt": /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("path", { d: "M13 2 3 14h9l-1 8 10-12h-9l1-8z" }) })
1849
+ };
1850
+ return icon ? iconMap[icon] || iconMap["sparkle"] : iconMap["sparkle"];
1851
+ }
1852
+ function StartScreen({ startScreen, onPromptClick, className }) {
1853
+ const { t } = useChatkitTranslation();
1854
+ const greeting = startScreen?.greeting ?? t("startScreen.greeting");
1855
+ const prompts = startScreen?.prompts ?? [];
1856
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)("div", { className: cn("flex flex-col items-center justify-center py-12 px-4", className), children: [
1857
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "mb-8 text-center", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("h2", { className: "text-2xl font-semibold text-foreground mb-2", children: greeting }) }),
1858
+ prompts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "w-full max-w-2xl", children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: prompts.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(
1859
+ "button",
1860
+ {
1861
+ type: "button",
1862
+ onClick: () => onPromptClick?.(item.prompt),
1863
+ className: cn(
1864
+ "flex items-center gap-3 rounded-xl border bg-card p-4 text-left",
1865
+ "hover:bg-muted/50 hover:border-primary/20 transition-colors",
1866
+ "focus:outline-none focus:ring-2 focus:ring-primary/20"
1867
+ ),
1868
+ children: [
1869
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-lg bg-primary/10 text-primary", children: getIconComponent2(item.icon) }),
1870
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)("span", { className: "text-sm font-medium text-foreground", children: item.label })
1871
+ ]
1872
+ },
1873
+ `prompt-${index}`
1874
+ )) }) })
1875
+ ] });
1876
+ }
1877
+
1878
+ // src/hooks/useThreads.ts
1879
+ var React16 = __toESM(require("react"), 1);
1880
+ var DEFAULT_LIMIT = 50;
1881
+ var getConversationTitle = (conversation) => {
1882
+ const title = conversation.title?.trim();
1883
+ if (title) return title;
1884
+ initI18n();
1885
+ const suffix = (conversation.id ?? conversation.threadId ?? "").slice(0, 8);
1886
+ return suffix ? import_i18next.default.t("history.conversationWithId", { id: suffix }) : import_i18next.default.t("history.conversationFallback");
1887
+ };
1888
+ var toDate = (value) => {
1889
+ if (!value) return void 0;
1890
+ const timestamp = Date.parse(value);
1891
+ if (Number.isNaN(timestamp)) return void 0;
1892
+ return new Date(timestamp);
1893
+ };
1894
+ var toConversation = (conversation) => ({
1895
+ id: conversation.id,
1896
+ threadId: conversation.threadId ?? null,
1897
+ title: getConversationTitle(conversation),
1898
+ lastMessageAt: toDate(conversation.updatedAt)
1899
+ });
1900
+ var sortConversations = (conversations) => {
1901
+ return [...conversations].sort((a, b) => {
1902
+ const aTime = Date.parse(a.updatedAt ?? "");
1903
+ const bTime = Date.parse(b.updatedAt ?? "");
1904
+ return (Number.isNaN(bTime) ? 0 : bTime) - (Number.isNaN(aTime) ? 0 : aTime);
1905
+ });
1906
+ };
1907
+ function useThreads(limit = DEFAULT_LIMIT) {
1908
+ const { client, threadId } = useStreamContext();
1909
+ const [conversationsState, setConversationsState] = React16.useState([]);
1910
+ const [isLoading, setIsLoading] = React16.useState(false);
1911
+ const [error, setError] = React16.useState(null);
1912
+ const upsertConversation = React16.useCallback((conversation) => {
1913
+ setConversationsState((prev) => {
1914
+ const next = prev.filter((item) => item.id !== conversation.id);
1915
+ return sortConversations([conversation, ...next]);
1916
+ });
1917
+ }, []);
1918
+ const refreshConversations = React16.useCallback(async () => {
1919
+ setIsLoading(true);
1920
+ setError(null);
1921
+ try {
1922
+ const { items } = await client.conversations.search({
1923
+ limit,
1924
+ order: { updatedAt: "DESC" }
1925
+ });
1926
+ setConversationsState(items ?? []);
1927
+ console.log("Conversations refreshed", items);
1928
+ } catch (err) {
1929
+ setError(err);
1930
+ } finally {
1931
+ setIsLoading(false);
1932
+ }
1933
+ }, [client, limit]);
1934
+ const createConversation = React16.useCallback(
1935
+ async (input) => {
1936
+ setError(null);
1937
+ const payload = {};
1938
+ if (input?.conversationId) payload.id = input.conversationId;
1939
+ if (input?.threadId) payload.threadId = input.threadId;
1940
+ if (input?.title) payload.title = input.title;
1941
+ if (input?.options) payload.options = input.options;
1942
+ const created = await client.conversations.create(payload);
1943
+ upsertConversation(created);
1944
+ return created;
1945
+ },
1946
+ [client, upsertConversation]
1947
+ );
1948
+ const updateConversation = React16.useCallback(
1949
+ async (id, payload) => {
1950
+ setError(null);
1951
+ const updated = await client.conversations.update(id, payload);
1952
+ upsertConversation(updated);
1953
+ return updated;
1954
+ },
1955
+ [client, upsertConversation]
1956
+ );
1957
+ const deleteConversation = React16.useCallback(
1958
+ async (id) => {
1959
+ setError(null);
1960
+ await client.conversations.delete(id);
1961
+ setConversationsState((prev) => prev.filter((item) => item.id !== id));
1962
+ },
1963
+ [client]
1964
+ );
1965
+ React16.useEffect(() => {
1966
+ void refreshConversations();
1967
+ }, [refreshConversations]);
1968
+ React16.useEffect(() => {
1969
+ if (!threadId) return;
1970
+ if (conversationsState.some((item) => item.threadId === threadId)) return;
1971
+ void client.conversations.search({ where: { threadId }, limit: 1 }).then((result) => {
1972
+ const found = result.items?.[0];
1973
+ if (found) upsertConversation(found);
1974
+ }).catch((err) => {
1975
+ setError(err);
1976
+ });
1977
+ }, [client, threadId, conversationsState, upsertConversation]);
1978
+ const conversations = React16.useMemo(
1979
+ () => conversationsState.map((conversation) => toConversation(conversation)),
1980
+ [conversationsState]
1981
+ );
1982
+ return {
1983
+ conversations,
1984
+ rawConversations: conversationsState,
1985
+ isLoading,
1986
+ error,
1987
+ refreshConversations,
1988
+ createConversation,
1989
+ updateConversation,
1990
+ deleteConversation,
1991
+ // Legacy aliases
1992
+ refreshThreads: refreshConversations,
1993
+ createThread: createConversation,
1994
+ updateThreadMetadata: updateConversation,
1995
+ deleteThread: deleteConversation
1996
+ };
1997
+ }
1998
+
1999
+ // src/components/chat.tsx
2000
+ var import_jsx_runtime20 = require("react/jsx-runtime");
2001
+ var import_meta2 = {};
2002
+ var defaultApiUrl2 = import_meta2.env.VITE_XPERTAI_API_URL;
2003
+ var DEFAULT_HISTORY_LIMIT = 200;
2004
+ function createMessageId() {
2005
+ return globalThis.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`;
2006
+ }
2007
+ function formatMessageContent(content) {
2008
+ if (typeof content === "string") {
2009
+ return content;
2010
+ }
2011
+ if (Array.isArray(content)) {
2012
+ return content.map((part) => {
2013
+ if (typeof part === "string") return part;
2014
+ if (part && typeof part === "object" && "text" in part) {
2015
+ const textValue = part.text;
2016
+ return typeof textValue === "string" ? textValue : "";
2017
+ }
2018
+ return "";
2019
+ }).join("");
2020
+ }
2021
+ if (content == null) return "";
2022
+ if (typeof content === "object" && "text" in content) {
2023
+ const textValue = content.text;
2024
+ return typeof textValue === "string" ? textValue : "";
2025
+ }
2026
+ return "";
2027
+ }
2028
+ function normalizeRoleToMessageType(role) {
2029
+ const normalized = (role ?? "").toLowerCase();
2030
+ if (normalized === "user" || normalized === "human") return "human";
2031
+ if (normalized === "assistant" || normalized === "ai") return "ai";
2032
+ if (normalized === "system") return "system";
2033
+ if (normalized === "tool") return "tool";
2034
+ return "ai";
2035
+ }
2036
+ function mapChatMessageToUiMessage(message) {
2037
+ return {
2038
+ id: message.id ?? createMessageId(),
2039
+ type: normalizeRoleToMessageType(message.role),
2040
+ content: message.content ?? "",
2041
+ ...message.reasoning ? { reasoning: message.reasoning } : {},
2042
+ ...message.executionId ? { executionId: message.executionId } : {}
2043
+ };
2044
+ }
2045
+ function sortMessagesByCreatedAt(items) {
2046
+ return [...items].sort((a, b) => {
2047
+ const aTime = Date.parse(a.createdAt ?? "");
2048
+ const bTime = Date.parse(b.createdAt ?? "");
2049
+ if (Number.isNaN(aTime) && Number.isNaN(bTime)) return 0;
2050
+ if (Number.isNaN(aTime)) return -1;
2051
+ if (Number.isNaN(bTime)) return 1;
2052
+ return aTime - bTime;
2053
+ });
2054
+ }
2055
+ function Chat({
2056
+ className,
2057
+ options,
2058
+ title,
2059
+ placeholder,
2060
+ clientSecret = ""
2061
+ }) {
2062
+ const { t } = useChatkitTranslation();
2063
+ const composer = options?.composer;
2064
+ const startScreen = options?.startScreen;
2065
+ const history = options?.history;
2066
+ const disclaimer = options?.disclaimer;
2067
+ const apiUrl = options?.api?.apiUrl || defaultApiUrl2;
2068
+ const { setStream } = useStreamManager();
2069
+ const stream = useStreamContext();
2070
+ const [activeConversationId, setActiveConversationId] = React17.useState(null);
2071
+ const [isHistoryLoading, setIsHistoryLoading] = React17.useState(false);
2072
+ const [historyError, setHistoryError] = React17.useState(null);
2073
+ const [assistantName, setAssistantName] = React17.useState(null);
2074
+ const LOADING_DOTS_MIN_DURATION = 800;
2075
+ const [showLoadingDots, setShowLoadingDots] = React17.useState(false);
2076
+ const loadingStartTimeRef = React17.useRef(null);
2077
+ React17.useEffect(() => {
2078
+ setStream(stream);
2079
+ }, [setStream, stream]);
2080
+ React17.useEffect(() => {
2081
+ if (stream.isLoading) {
2082
+ if (!loadingStartTimeRef.current) {
2083
+ loadingStartTimeRef.current = Date.now();
2084
+ setShowLoadingDots(true);
2085
+ }
2086
+ } else {
2087
+ if (loadingStartTimeRef.current) {
2088
+ const elapsed = Date.now() - loadingStartTimeRef.current;
2089
+ const remaining = LOADING_DOTS_MIN_DURATION - elapsed;
2090
+ if (remaining > 0) {
2091
+ const timer = setTimeout(() => {
2092
+ setShowLoadingDots(false);
2093
+ loadingStartTimeRef.current = null;
2094
+ }, remaining);
2095
+ return () => clearTimeout(timer);
2096
+ } else {
2097
+ setShowLoadingDots(false);
2098
+ loadingStartTimeRef.current = null;
2099
+ }
2100
+ }
2101
+ }
2102
+ }, [stream.isLoading]);
2103
+ const [draft, setDraft] = React17.useState("");
2104
+ const [selectedTool, setSelectedTool] = React17.useState(null);
2105
+ const [attachments, setAttachments] = React17.useState([]);
2106
+ const {
2107
+ conversations,
2108
+ createConversation,
2109
+ deleteConversation,
2110
+ refreshConversations,
2111
+ isLoading: isThreadsLoading
2112
+ } = useThreads();
2113
+ const scrollAreaRef = React17.useRef(null);
2114
+ const viewportRef = React17.useRef(null);
2115
+ const fileInputRef = React17.useRef(null);
2116
+ const resolvedTitle = title ?? t("chat.title");
2117
+ const resolvedPlaceholder = placeholder ?? t("chat.placeholder");
2118
+ const inputPlaceholder = selectedTool?.placeholderOverride ?? composer?.placeholder ?? resolvedPlaceholder;
2119
+ const messages = stream.messages ?? [];
2120
+ const trimmedDraft = draft.trim();
2121
+ const scrollToBottom = React17.useCallback((smooth = false) => {
2122
+ requestAnimationFrame(() => {
2123
+ const viewport = scrollAreaRef.current?.querySelector("[data-radix-scroll-area-viewport]");
2124
+ if (viewport) {
2125
+ viewport.scrollTo({
2126
+ top: viewport.scrollHeight,
2127
+ behavior: smooth ? "smooth" : "instant"
2128
+ });
2129
+ }
2130
+ });
2131
+ }, []);
2132
+ React17.useEffect(() => {
2133
+ scrollToBottom();
2134
+ }, [messages.length, scrollToBottom]);
2135
+ React17.useEffect(() => {
2136
+ if (stream.isLoading) {
2137
+ scrollToBottom();
2138
+ }
2139
+ }, [stream.isLoading, messages, scrollToBottom]);
2140
+ const hasApiKey = Boolean(clientSecret.trim());
2141
+ const missingConfig = !apiUrl || !hasApiKey;
2142
+ const isSendDisabled = !trimmedDraft || stream.isLoading || missingConfig || isHistoryLoading;
2143
+ React17.useEffect(() => {
2144
+ if (missingConfig) return;
2145
+ void refreshConversations();
2146
+ }, [missingConfig, refreshConversations]);
2147
+ React17.useEffect(() => {
2148
+ if (missingConfig || !stream.client || !stream.assistantId) return;
2149
+ stream.client.assistants.get(stream.assistantId).then((assistant) => {
2150
+ if (assistant?.name) {
2151
+ setAssistantName(assistant.name);
2152
+ }
2153
+ }).catch((err) => {
2154
+ console.warn("[Chat] Failed to load assistant info:", err);
2155
+ });
2156
+ }, [missingConfig, stream.client, stream.assistantId]);
2157
+ const handleSubmit = (event) => {
2158
+ event.preventDefault();
2159
+ if (isSendDisabled) return;
2160
+ const newMessage = {
2161
+ id: createMessageId(),
2162
+ type: "human",
2163
+ content: trimmedDraft
2164
+ };
2165
+ setDraft("");
2166
+ stream.submit(
2167
+ { input: { input: trimmedDraft } },
2168
+ {
2169
+ optimisticValues: (prev) => {
2170
+ const prevMessages = prev?.messages ?? [];
2171
+ return { ...prev, messages: [...prevMessages, newMessage] };
2172
+ }
2173
+ }
2174
+ );
2175
+ scrollToBottom(true);
2176
+ if (selectedTool && !selectedTool.pinned) {
2177
+ setSelectedTool(null);
2178
+ }
2179
+ setAttachments([]);
2180
+ };
2181
+ const handleAttachmentClick = () => {
2182
+ fileInputRef.current?.click();
2183
+ };
2184
+ const handleFileChange = (event) => {
2185
+ const files = event.target.files;
2186
+ if (!files || files.length === 0) return;
2187
+ const maxCount = composer?.attachments?.maxCount ?? 10;
2188
+ const maxSize = composer?.attachments?.maxSize ?? 100 * 1024 * 1024;
2189
+ const validFiles = [];
2190
+ for (let i = 0; i < files.length; i++) {
2191
+ const file = files[i];
2192
+ if (file.size > maxSize) {
2193
+ console.warn(`File ${file.name} exceeds max size of ${maxSize} bytes`);
2194
+ continue;
2195
+ }
2196
+ validFiles.push(file);
2197
+ }
2198
+ setAttachments((prev) => {
2199
+ const combined = [...prev, ...validFiles];
2200
+ return combined.slice(0, maxCount);
2201
+ });
2202
+ event.target.value = "";
2203
+ };
2204
+ const handleRemoveAttachment = (index) => {
2205
+ setAttachments((prev) => prev.filter((_, i) => i !== index));
2206
+ };
2207
+ const handleToolSelect = (tool) => {
2208
+ setSelectedTool((prev) => prev?.id === tool.id ? null : tool);
2209
+ };
2210
+ const handlePromptClick = (prompt) => {
2211
+ if (missingConfig || stream.isLoading || isHistoryLoading) return;
2212
+ const newMessage = {
2213
+ id: createMessageId(),
2214
+ type: "human",
2215
+ content: prompt
2216
+ };
2217
+ stream.submit(
2218
+ { input: { input: prompt } },
2219
+ {
2220
+ optimisticValues: (prev) => {
2221
+ const prevMessages = prev?.messages ?? [];
2222
+ return { ...prev, messages: [...prevMessages, newMessage] };
2223
+ }
2224
+ }
2225
+ );
2226
+ scrollToBottom(true);
2227
+ };
2228
+ const loadConversationMessages = React17.useCallback(
2229
+ async (conversationId, threadId) => {
2230
+ if (missingConfig) {
2231
+ setHistoryError(t("chat.missingConfigShort"));
2232
+ return;
2233
+ }
2234
+ setHistoryError(null);
2235
+ setIsHistoryLoading(true);
2236
+ try {
2237
+ stream.stop();
2238
+ } catch {
2239
+ }
2240
+ try {
2241
+ const response = await stream.client.conversations.listMessages(conversationId, {
2242
+ limit: DEFAULT_HISTORY_LIMIT,
2243
+ offset: 0
2244
+ });
2245
+ const sorted = sortMessagesByCreatedAt(response.items ?? []);
2246
+ const mapped = sorted.map(mapChatMessageToUiMessage);
2247
+ stream.reset(threadId ?? null, mapped);
2248
+ setActiveConversationId(conversationId);
2249
+ } catch (err) {
2250
+ console.warn("Failed to load conversation messages", err);
2251
+ setHistoryError(
2252
+ err instanceof Error ? err.message : t("chat.errors.loadMessages")
2253
+ );
2254
+ stream.reset(threadId ?? null, []);
2255
+ } finally {
2256
+ setIsHistoryLoading(false);
2257
+ }
2258
+ },
2259
+ [missingConfig, stream, t]
2260
+ );
2261
+ React17.useEffect(() => {
2262
+ if (!stream.threadId) return;
2263
+ if (isHistoryLoading) return;
2264
+ const matched = conversations.find((item) => item.threadId === stream.threadId);
2265
+ if (!matched) return;
2266
+ if (activeConversationId && activeConversationId === matched.id) return;
2267
+ if (messages.length > 0) {
2268
+ setActiveConversationId(matched.id);
2269
+ return;
2270
+ }
2271
+ void loadConversationMessages(matched.id, matched.threadId ?? null);
2272
+ }, [
2273
+ conversations,
2274
+ stream.threadId,
2275
+ messages.length,
2276
+ activeConversationId,
2277
+ isHistoryLoading,
2278
+ loadConversationMessages
2279
+ ]);
2280
+ const handleNewConversation = async () => {
2281
+ if (missingConfig || stream.isLoading || isHistoryLoading) return;
2282
+ setHistoryError(null);
2283
+ try {
2284
+ const created = await createConversation({ title: t("history.newConversationTitle") });
2285
+ setActiveConversationId(created.id);
2286
+ stream.reset(created.threadId ?? null, []);
2287
+ await refreshConversations();
2288
+ } catch (err) {
2289
+ console.warn("Failed to create conversation", err);
2290
+ setHistoryError(
2291
+ err instanceof Error ? err.message : t("chat.errors.createConversation")
2292
+ );
2293
+ }
2294
+ };
2295
+ const handleSelectConversation = (id) => {
2296
+ if (isHistoryLoading) return;
2297
+ setHistoryError(null);
2298
+ const conversation = conversations.find((item) => item.id === id);
2299
+ const nextThreadId = conversation?.threadId ?? null;
2300
+ if (id === activeConversationId && stream.threadId === nextThreadId) return;
2301
+ void loadConversationMessages(id, nextThreadId);
2302
+ };
2303
+ const handleDeleteConversation = (id) => {
2304
+ setHistoryError(null);
2305
+ void deleteConversation(id).then(() => {
2306
+ if (activeConversationId === id) {
2307
+ stream.reset(null, []);
2308
+ setActiveConversationId(null);
2309
+ }
2310
+ return refreshConversations();
2311
+ }).catch((err) => {
2312
+ console.warn("Failed to delete conversation", err);
2313
+ setHistoryError(
2314
+ err instanceof Error ? err.message : t("chat.errors.deleteConversation")
2315
+ );
2316
+ });
2317
+ };
2318
+ const handleRetry = (messageIndex) => {
2319
+ const messagesUpToIndex = messages.slice(0, messageIndex);
2320
+ const lastHumanMessage = [...messagesUpToIndex].reverse().find(
2321
+ (m) => String(m.type) === "human"
2322
+ );
2323
+ if (lastHumanMessage && typeof lastHumanMessage.content === "string") {
2324
+ stream.submit(
2325
+ { input: { input: lastHumanMessage.content } },
2326
+ {
2327
+ optimisticValues: (prev) => {
2328
+ const prevMessages = prev?.messages ?? [];
2329
+ return {
2330
+ ...prev,
2331
+ messages: prevMessages.slice(0, messageIndex)
2332
+ };
2333
+ }
2334
+ }
2335
+ );
2336
+ }
2337
+ };
2338
+ const acceptMimes = composer?.attachments?.accept ? Object.entries(composer.attachments.accept).map(([mime, exts]) => [mime, ...exts.map((e) => `.${e}`)].join(",")).join(",") : void 0;
2339
+ const errorMessage = stream.error instanceof Error ? stream.error.message : void 0;
2340
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2341
+ "div",
2342
+ {
2343
+ className: cn(
2344
+ "flex h-full w-full flex-col overflow-hidden bg-background shadow-sm",
2345
+ className
2346
+ ),
2347
+ children: [
2348
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center justify-between border-b bg-muted/30 px-6 py-4", children: [
2349
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-3", children: [
2350
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "h-2 w-2 rounded-full bg-green-500" }),
2351
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { children: [
2352
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("h2", { className: "text-lg font-semibold", children: assistantName || resolvedTitle }),
2353
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "text-xs text-muted-foreground", children: t("chat.statusOnline") })
2354
+ ] })
2355
+ ] }),
2356
+ history?.enabled !== false && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex items-center gap-1", children: [
2357
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2358
+ "button",
2359
+ {
2360
+ type: "button",
2361
+ onClick: handleNewConversation,
2362
+ disabled: missingConfig || stream.isLoading || isHistoryLoading,
2363
+ className: cn(
2364
+ "flex h-9 w-9 items-center justify-center rounded-md",
2365
+ "text-muted-foreground hover:text-foreground hover:bg-muted",
2366
+ "transition-colors duration-150",
2367
+ "disabled:opacity-50 disabled:cursor-not-allowed"
2368
+ ),
2369
+ title: t("history.newConversation"),
2370
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2371
+ "svg",
2372
+ {
2373
+ xmlns: "http://www.w3.org/2000/svg",
2374
+ width: "18",
2375
+ height: "18",
2376
+ viewBox: "0 0 24 24",
2377
+ fill: "none",
2378
+ stroke: "currentColor",
2379
+ strokeWidth: "2",
2380
+ strokeLinecap: "round",
2381
+ strokeLinejoin: "round",
2382
+ children: [
2383
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M12 20h9" }),
2384
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z" })
2385
+ ]
2386
+ }
2387
+ )
2388
+ }
2389
+ ),
2390
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2391
+ HistorySidebar,
2392
+ {
2393
+ conversations,
2394
+ currentConversationId: activeConversationId ?? void 0,
2395
+ onNewConversation: handleNewConversation,
2396
+ onSelectConversation: handleSelectConversation,
2397
+ onDeleteConversation: handleDeleteConversation,
2398
+ showDelete: history?.showDelete !== false,
2399
+ disabled: missingConfig || stream.isLoading || isThreadsLoading || isHistoryLoading
2400
+ }
2401
+ )
2402
+ ] })
2403
+ ] }),
2404
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(ScrollArea, { ref: scrollAreaRef, className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { ref: viewportRef, className: "px-6 py-4", children: [
2405
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-4 rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive", children: errorMessage }),
2406
+ historyError && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900", children: historyError }),
2407
+ missingConfig && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-sm text-amber-900", children: t("chat.missingConfigDetail") }),
2408
+ isHistoryLoading && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-4 rounded-lg border border-muted px-3 py-2 text-sm text-muted-foreground", children: t("chat.loadingConversation") }),
2409
+ messages.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2410
+ StartScreen,
2411
+ {
2412
+ startScreen,
2413
+ onPromptClick: handlePromptClick
2414
+ }
2415
+ ) : /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "space-y-4", children: [
2416
+ messages.map((message, index) => {
2417
+ const messageType = String(message.type);
2418
+ const isAssistantMessage = messageType === "assistant" || messageType === "ai";
2419
+ const messageContent = typeof message.content === "string" ? message.content : Array.isArray(message.content) ? message.content.map((part) => formatMessageContent(part)).join("") : formatMessageContent(message.content);
2420
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2421
+ "div",
2422
+ {
2423
+ className: cn(
2424
+ "group flex gap-3",
2425
+ message.type === "human" ? "justify-end" : "justify-start -ml-1"
2426
+ // AI messages: slightly closer to left
2427
+ ),
2428
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex flex-col", children: [
2429
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2430
+ "div",
2431
+ {
2432
+ className: cn(
2433
+ "max-w-full rounded-2xl",
2434
+ message.type === "human" ? "bg-primary text-primary-foreground px-4 py-2.5" : message.type === "system" ? "bg-muted text-muted-foreground text-xs px-4 py-2.5" : "py-1 text-chat-foreground"
2435
+ // AI messages: use chat-specific foreground color
2436
+ ),
2437
+ children: isAssistantMessage ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2438
+ AssistantMessage,
2439
+ {
2440
+ message: {
2441
+ ...message,
2442
+ type: "assistant"
2443
+ },
2444
+ isStreaming: stream.isLoading && index === messages.length - 1
2445
+ }
2446
+ ) : Array.isArray(message.content) ? message.content.map((part, partIndex) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2447
+ "p",
2448
+ {
2449
+ className: "break-words text-sm leading-relaxed",
2450
+ children: formatMessageContent(part)
2451
+ },
2452
+ `${part.type}-${partIndex}`
2453
+ )) : formatMessageContent(message.content)
2454
+ }
2455
+ ),
2456
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2457
+ MessageActions,
2458
+ {
2459
+ content: messageContent,
2460
+ isAssistant: isAssistantMessage,
2461
+ isStreaming: stream.isLoading && index === messages.length - 1,
2462
+ onRetry: isAssistantMessage && !stream.isLoading && index === messages.length - 1 ? () => handleRetry(index) : void 0
2463
+ }
2464
+ )
2465
+ ] })
2466
+ },
2467
+ message.id ?? `${message.type}-${index}`
2468
+ );
2469
+ }),
2470
+ showLoadingDots && (() => {
2471
+ const lastMessage = messages[messages.length - 1];
2472
+ const lastMessageType = lastMessage ? String(lastMessage.type) : "";
2473
+ const isLastMessageFromAI = lastMessageType === "ai" || lastMessageType === "assistant";
2474
+ const lastMsgContent = lastMessage?.content;
2475
+ const hasSubstantialContent = isLastMessageFromAI && (typeof lastMsgContent === "string" && lastMsgContent.length > 10 || Array.isArray(lastMsgContent) && lastMsgContent.length > 0);
2476
+ if (hasSubstantialContent) return null;
2477
+ return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "flex justify-start gap-3 -ml-2", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "max-w-full rounded-2xl py-2.5", children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "flex gap-1.5", children: [
2478
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "h-2 w-2 animate-bounce rounded-full bg-muted-foreground/60 [animation-delay:-0.3s]" }),
2479
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "h-2 w-2 animate-bounce rounded-full bg-muted-foreground/60 [animation-delay:-0.15s]" }),
2480
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "h-2 w-2 animate-bounce rounded-full bg-muted-foreground/60" })
2481
+ ] }) }) });
2482
+ })()
2483
+ ] })
2484
+ ] }) }),
2485
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "border-t bg-muted/30 p-4", children: [
2486
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2487
+ "input",
2488
+ {
2489
+ ref: fileInputRef,
2490
+ type: "file",
2491
+ multiple: true,
2492
+ accept: acceptMimes,
2493
+ onChange: handleFileChange,
2494
+ className: "hidden"
2495
+ }
2496
+ ),
2497
+ attachments.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("div", { className: "mb-3 flex flex-wrap gap-2", children: attachments.map((file, index) => /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2498
+ "div",
2499
+ {
2500
+ className: "flex items-center gap-2 rounded-md bg-muted px-2 py-1 text-sm",
2501
+ children: [
2502
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2503
+ "svg",
2504
+ {
2505
+ xmlns: "http://www.w3.org/2000/svg",
2506
+ width: "14",
2507
+ height: "14",
2508
+ viewBox: "0 0 24 24",
2509
+ fill: "none",
2510
+ stroke: "currentColor",
2511
+ strokeWidth: "2",
2512
+ strokeLinecap: "round",
2513
+ strokeLinejoin: "round",
2514
+ className: "text-muted-foreground",
2515
+ children: [
2516
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z" }),
2517
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("polyline", { points: "14 2 14 8 20 8" })
2518
+ ]
2519
+ }
2520
+ ),
2521
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "max-w-[120px] truncate", children: file.name }),
2522
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2523
+ "button",
2524
+ {
2525
+ type: "button",
2526
+ onClick: () => handleRemoveAttachment(index),
2527
+ className: "ml-1 rounded-full p-0.5 hover:bg-muted-foreground/20",
2528
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2529
+ "svg",
2530
+ {
2531
+ xmlns: "http://www.w3.org/2000/svg",
2532
+ width: "12",
2533
+ height: "12",
2534
+ viewBox: "0 0 24 24",
2535
+ fill: "none",
2536
+ stroke: "currentColor",
2537
+ strokeWidth: "2",
2538
+ strokeLinecap: "round",
2539
+ strokeLinejoin: "round",
2540
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M18 6 6 18M6 6l12 12" })
2541
+ }
2542
+ )
2543
+ }
2544
+ )
2545
+ ]
2546
+ },
2547
+ `${file.name}-${index}`
2548
+ )) }),
2549
+ selectedTool && /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)("div", { className: "mb-2 flex items-center gap-2", children: [
2550
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("span", { className: "rounded-full bg-primary/10 px-2 py-0.5 text-xs font-medium text-primary", children: selectedTool.shortLabel ?? selectedTool.label }),
2551
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2552
+ "button",
2553
+ {
2554
+ type: "button",
2555
+ onClick: () => setSelectedTool(null),
2556
+ className: "rounded-full p-0.5 text-muted-foreground hover:bg-muted",
2557
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2558
+ "svg",
2559
+ {
2560
+ xmlns: "http://www.w3.org/2000/svg",
2561
+ width: "12",
2562
+ height: "12",
2563
+ viewBox: "0 0 24 24",
2564
+ fill: "none",
2565
+ stroke: "currentColor",
2566
+ strokeWidth: "2",
2567
+ strokeLinecap: "round",
2568
+ strokeLinejoin: "round",
2569
+ children: /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("path", { d: "M18 6 6 18M6 6l12 12" })
2570
+ }
2571
+ )
2572
+ }
2573
+ )
2574
+ ] }),
2575
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("form", { className: "flex items-center", onSubmit: handleSubmit, children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(
2576
+ "div",
2577
+ {
2578
+ className: cn(
2579
+ "flex flex-1 items-center gap-1 rounded-full",
2580
+ "bg-background border border-border shadow-sm",
2581
+ "pl-1.5 pr-1.5 py-1",
2582
+ "focus-within:border-muted-foreground/30 focus-within:shadow-md",
2583
+ "transition-shadow duration-200"
2584
+ ),
2585
+ children: [
2586
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2587
+ ComposerMenu,
2588
+ {
2589
+ composer,
2590
+ onAttachmentClick: handleAttachmentClick,
2591
+ onToolSelect: handleToolSelect,
2592
+ selectedTool,
2593
+ disabled: stream.isLoading || missingConfig || isHistoryLoading
2594
+ }
2595
+ ),
2596
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2597
+ "input",
2598
+ {
2599
+ type: "text",
2600
+ value: draft,
2601
+ onChange: (event) => setDraft(event.target.value),
2602
+ placeholder: inputPlaceholder,
2603
+ disabled: stream.isLoading || missingConfig || isHistoryLoading,
2604
+ className: cn(
2605
+ "flex-1 bg-transparent text-sm text-foreground outline-none px-2",
2606
+ "placeholder:text-muted-foreground",
2607
+ "disabled:cursor-not-allowed disabled:opacity-50"
2608
+ ),
2609
+ autoComplete: "off"
2610
+ }
2611
+ ),
2612
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2613
+ SendButton,
2614
+ {
2615
+ disabled: isSendDisabled,
2616
+ isLoading: stream.isLoading,
2617
+ onStop: () => stream.stop(),
2618
+ stopLabel: t("chat.stop"),
2619
+ sendLabel: t("chat.send")
2620
+ }
2621
+ )
2622
+ ]
2623
+ }
2624
+ ) }),
2625
+ disclaimer?.text && /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
2626
+ "p",
2627
+ {
2628
+ className: cn(
2629
+ "mt-2 text-center text-xs",
2630
+ disclaimer.highContrast ? "text-foreground" : "text-muted-foreground"
2631
+ ),
2632
+ children: disclaimer.text
2633
+ }
2634
+ ),
2635
+ /* @__PURE__ */ (0, import_jsx_runtime20.jsx)("p", { className: "mt-2 text-center text-xs text-muted-foreground", children: t("chat.poweredBy") })
2636
+ ] })
2637
+ ]
2638
+ }
2639
+ );
2640
+ }
2641
+
2642
+ // src/components/ui/input.tsx
2643
+ var React18 = __toESM(require("react"), 1);
2644
+ var import_jsx_runtime21 = require("react/jsx-runtime");
2645
+ var Input = React18.forwardRef(
2646
+ ({ className, type, ...props }, ref) => {
2647
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
2648
+ "input",
2649
+ {
2650
+ ref,
2651
+ type,
2652
+ className: cn(
2653
+ "flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",
2654
+ className
2655
+ ),
2656
+ ...props
2657
+ }
2658
+ );
2659
+ }
2660
+ );
2661
+ Input.displayName = "Input";
2662
+
2663
+ // src/components/ui/avatar.tsx
2664
+ var React19 = __toESM(require("react"), 1);
2665
+ var AvatarPrimitive = __toESM(require("@radix-ui/react-avatar"), 1);
2666
+ var import_jsx_runtime22 = require("react/jsx-runtime");
2667
+ var Avatar = React19.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2668
+ AvatarPrimitive.Root,
2669
+ {
2670
+ ref,
2671
+ className: cn(
2672
+ "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full",
2673
+ className
2674
+ ),
2675
+ ...props
2676
+ }
2677
+ ));
2678
+ Avatar.displayName = AvatarPrimitive.Root.displayName;
2679
+ var AvatarImage = React19.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2680
+ AvatarPrimitive.Image,
2681
+ {
2682
+ ref,
2683
+ className: cn("aspect-square h-full w-full", className),
2684
+ ...props
2685
+ }
2686
+ ));
2687
+ AvatarImage.displayName = AvatarPrimitive.Image.displayName;
2688
+ var AvatarFallback = React19.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
2689
+ AvatarPrimitive.Fallback,
2690
+ {
2691
+ ref,
2692
+ className: cn(
2693
+ "flex h-full w-full items-center justify-center rounded-full bg-muted",
2694
+ className
2695
+ ),
2696
+ ...props
2697
+ }
2698
+ ));
2699
+ AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName;
2700
+
2701
+ // src/components/ui/separator.tsx
2702
+ var React20 = __toESM(require("react"), 1);
2703
+ var import_jsx_runtime23 = require("react/jsx-runtime");
2704
+ var Separator = React20.forwardRef(
2705
+ ({ className, orientation = "horizontal", ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
2706
+ "div",
2707
+ {
2708
+ ref,
2709
+ role: "separator",
2710
+ "aria-orientation": orientation,
2711
+ className: cn(
2712
+ "shrink-0 bg-border",
2713
+ orientation === "horizontal" ? "h-px w-full" : "h-full w-px",
2714
+ className
2715
+ ),
2716
+ ...props
2717
+ }
2718
+ )
2719
+ );
2720
+ Separator.displayName = "Separator";
2721
+ // Annotate the CommonJS export names for ESM import in node:
2722
+ 0 && (module.exports = {
2723
+ Avatar,
2724
+ AvatarFallback,
2725
+ AvatarImage,
2726
+ Badge,
2727
+ Button,
2728
+ Card,
2729
+ CardAction,
2730
+ CardContent,
2731
+ CardDescription,
2732
+ CardFooter,
2733
+ CardHeader,
2734
+ CardTitle,
2735
+ Chat,
2736
+ Input,
2737
+ ScrollArea,
2738
+ ScrollBar,
2739
+ Separator,
2740
+ Tabs,
2741
+ TabsContent,
2742
+ TabsList,
2743
+ TabsTrigger,
2744
+ chatkitSupportedLocales,
2745
+ getChatkitLanguage,
2746
+ setChatkitLanguage,
2747
+ useParentMessenger
2748
+ });