@antdv-next/x 0.0.3 → 0.1.0

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 (55) hide show
  1. package/dist/actions/Actions.js +1 -1
  2. package/dist/actions/ActionsAudio.js +1 -1
  3. package/dist/actions/ActionsCopy.js +1 -1
  4. package/dist/actions/ActionsFeedback.js +1 -1
  5. package/dist/actions/ActionsItem.js +1 -1
  6. package/dist/attachments/index.js +1 -1
  7. package/dist/bubble/Bubble.js +1 -1
  8. package/dist/bubble/BubbleList.js +1 -1
  9. package/dist/bubble/Divider.js +1 -1
  10. package/dist/bubble/System.js +1 -1
  11. package/dist/code-highlighter/CodeHighlighter.js +3 -14
  12. package/dist/code-highlighter/shiki.d.ts +4 -0
  13. package/dist/code-highlighter/shiki.js +72 -0
  14. package/dist/conversations/Creation.js +1 -1
  15. package/dist/conversations/index.js +1 -1
  16. package/dist/file-card/FileCard.js +1 -1
  17. package/dist/file-card/List.js +1 -1
  18. package/dist/index.esm.js +1224 -118
  19. package/dist/index.js +0 -25
  20. package/dist/index.umd.js +1228 -121
  21. package/dist/mermaid/Mermaid.d.ts +1 -1
  22. package/dist/mermaid/Mermaid.js +5 -5
  23. package/dist/mermaid/loader.d.ts +6 -0
  24. package/dist/mermaid/loader.js +33 -0
  25. package/dist/mermaid/mermaid-core.d.js +0 -0
  26. package/dist/package.js +1 -1
  27. package/dist/prompts/Prompts.js +6 -4
  28. package/dist/sender/Sender.d.ts +25 -7
  29. package/dist/sender/Sender.js +60 -14
  30. package/dist/sender/SenderHeader.js +1 -1
  31. package/dist/sender/SenderSwitch.js +2 -2
  32. package/dist/sender/components/ActionButton.d.ts +0 -9
  33. package/dist/sender/components/ActionButton.js +1 -5
  34. package/dist/sender/components/Skill.d.ts +30 -0
  35. package/dist/sender/components/Skill.js +61 -0
  36. package/dist/sender/components/SlotTextArea.d.ts +20 -0
  37. package/dist/sender/components/SlotTextArea.js +747 -0
  38. package/dist/sender/components/TextArea.d.ts +1 -3
  39. package/dist/sender/context.d.ts +1 -0
  40. package/dist/sender/index.d.ts +2 -2
  41. package/dist/sender/interface.d.ts +2 -1
  42. package/dist/sender/style/index.d.ts +7 -0
  43. package/dist/sender/style/index.js +17 -1
  44. package/dist/sender/style/slot-textarea.d.ts +4 -0
  45. package/dist/sender/style/slot-textarea.js +187 -0
  46. package/dist/sources/Sources.js +1 -1
  47. package/dist/suggestion/Suggestion.js +1 -1
  48. package/dist/suggestion/useActive.js +4 -0
  49. package/dist/think/Think.js +1 -1
  50. package/dist/thought-chain/Item.js +1 -1
  51. package/dist/thought-chain/ThoughtChain.js +1 -1
  52. package/dist/welcome/index.js +1 -1
  53. package/dist/x-provider/index.js +1 -1
  54. package/global.d.ts +61 -18
  55. package/package.json +2 -2
package/dist/index.esm.js CHANGED
@@ -1,16 +1,19 @@
1
- import { Fragment, Teleport, Transition, TransitionGroup, computed, createTextVNode, createVNode, defineComponent, inject, isVNode, mergeProps, nextTick, onBeforeUnmount, onMounted, provide, ref, shallowRef, toRefs, unref, useAttrs, useSlots, vShow, watch, withDirectives } from "vue";
1
+ import { Fragment, Teleport, Transition, TransitionGroup, computed, createTextVNode, createVNode, defineComponent, inject, isVNode, mergeProps, nextTick, onBeforeUnmount, onMounted, provide, ref, render, shallowRef, toRefs, unref, useAttrs, useSlots, vShow, watch, withDirectives } from "vue";
2
2
  import { useConfig } from "antdv-next/dist/config-provider/context";
3
- import { Button, Carousel, Cascader, ConfigProvider, Divider, Dropdown, Flex, Image as Image$1, Popover, Progress, Segmented, Skeleton, Spin, TextArea, Tooltip, Typography, Upload, theme } from "antdv-next";
3
+ import { Button, Carousel, Cascader, ConfigProvider, Divider, Dropdown, Flex, Image as Image$1, Input, Popover, Progress, Segmented, Skeleton, Spin, TextArea, Tooltip, Typography, Upload, theme } from "antdv-next";
4
4
  import Icon, { ArrowUpOutlined, AudioMutedOutlined, AudioOutlined, CheckCircleOutlined, CheckOutlined, ClearOutlined, CloseCircleFilled, CloseCircleOutlined, CloseOutlined, CopyOutlined, DislikeFilled, DislikeOutlined, DownloadOutlined, EllipsisOutlined, FileExcelFilled, FileImageFilled, FileMarkdownFilled, FilePdfFilled, FilePptFilled, FileTextFilled, FileWordFilled, FileZipFilled, JavaOutlined, JavaScriptOutlined, LeftOutlined, LikeFilled, LikeOutlined, LoadingOutlined, MinusCircleOutlined, MoonOutlined, MutedOutlined, PlusOutlined, PythonOutlined, RightOutlined, SoundOutlined, SunOutlined, ZoomInOutlined, ZoomOutOutlined } from "@antdv-next/icons";
5
5
  import { Keyframes, unit } from "@antdv-next/cssinjs";
6
6
  import { genStyleUtils, mergeToken } from "@antdv-next/cssinjs/cssinjs-utils";
7
7
  import { FastColor } from "@ant-design/fast-color";
8
8
  import useAntdToken from "antdv-next/dist/theme/useToken";
9
9
  import { useResizeObserver } from "@vueuse/core";
10
+ import { createHighlighterCore } from "shiki/core";
11
+ import darkTheme from "shiki/dist/themes/vitesse-dark.mjs";
12
+ import lightTheme from "shiki/dist/themes/vitesse-light.mjs";
13
+ import { createJavaScriptRegexEngine } from "shiki/engine/javascript";
10
14
  import { KeyCode, classNames } from "@v-c/util";
11
- import mermaid from "mermaid";
12
15
  //#region package.json
13
- var version = "0.0.3";
16
+ var version = "0.1.0";
14
17
  //#endregion
15
18
  //#region components/x-provider/context.ts
16
19
  var XProviderContextKey = Symbol("antdv-next-x-provider-context");
@@ -489,7 +492,7 @@ var style_default$13 = genStyleHooks("Actions", (token) => {
489
492
  }, prepareComponentToken$13);
490
493
  //#endregion
491
494
  //#region components/actions/Actions.tsx
492
- function _isSlot$6(s) {
495
+ function _isSlot$7(s) {
493
496
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
494
497
  }
495
498
  function getMotionTransitionProps(motionName) {
@@ -505,7 +508,7 @@ function getMotionTransitionProps(motionName) {
505
508
  };
506
509
  }
507
510
  var XActions = /* @__PURE__ */ defineComponent({
508
- name: "XActions",
511
+ name: "AxActions",
509
512
  inheritAttrs: false,
510
513
  props: {
511
514
  items: {
@@ -649,7 +652,7 @@ var XActions = /* @__PURE__ */ defineComponent({
649
652
  attrs.style,
650
653
  props.style
651
654
  ]
652
- }), [transitionProps.value ? createVNode(Transition, transitionProps.value, _isSlot$6(_slot = renderList()) ? _slot : { default: () => [_slot] }) : renderList()]);
655
+ }), [transitionProps.value ? createVNode(Transition, transitionProps.value, _isSlot$7(_slot = renderList()) ? _slot : { default: () => [_slot] }) : renderList()]);
653
656
  };
654
657
  }
655
658
  });
@@ -663,7 +666,7 @@ var ACTIONS_ITEM_STATUS = /* @__PURE__ */ function(ACTIONS_ITEM_STATUS) {
663
666
  return ACTIONS_ITEM_STATUS;
664
667
  }({});
665
668
  var XActionsItem = /* @__PURE__ */ defineComponent({
666
- name: "XActionsItem",
669
+ name: "AxActionsItem",
667
670
  inheritAttrs: false,
668
671
  props: {
669
672
  status: {
@@ -773,7 +776,7 @@ var XActionsItem = /* @__PURE__ */ defineComponent({
773
776
  //#endregion
774
777
  //#region components/actions/ActionsAudio.tsx
775
778
  var XActionsAudio = /* @__PURE__ */ defineComponent({
776
- name: "XActionsAudio",
779
+ name: "AxActionsAudio",
777
780
  props: {
778
781
  status: {
779
782
  type: String,
@@ -847,7 +850,7 @@ var normalizeCopyIcons = (icon) => {
847
850
  return [icon, icon];
848
851
  };
849
852
  var XActionsCopy = /* @__PURE__ */ defineComponent({
850
- name: "XActionsCopy",
853
+ name: "AxActionsCopy",
851
854
  inheritAttrs: false,
852
855
  props: {
853
856
  text: {
@@ -952,7 +955,7 @@ var FEEDBACK_VALUE = /* @__PURE__ */ function(FEEDBACK_VALUE) {
952
955
  return FEEDBACK_VALUE;
953
956
  }(FEEDBACK_VALUE || {});
954
957
  var XActionsFeedback = /* @__PURE__ */ defineComponent({
955
- name: "XActionsFeedback",
958
+ name: "AxActionsFeedback",
956
959
  inheritAttrs: false,
957
960
  props: {
958
961
  value: {
@@ -1930,7 +1933,7 @@ var DEFAULT_ICON = {
1930
1933
  key: "default"
1931
1934
  };
1932
1935
  var XFileCard = /* @__PURE__ */ defineComponent({
1933
- name: "XFileCard",
1936
+ name: "AxFileCard",
1934
1937
  inheritAttrs: false,
1935
1938
  props: {
1936
1939
  prefixCls: {
@@ -2165,11 +2168,11 @@ var XFileCard = /* @__PURE__ */ defineComponent({
2165
2168
  });
2166
2169
  //#endregion
2167
2170
  //#region components/file-card/List.tsx
2168
- function _isSlot$5(s) {
2171
+ function _isSlot$6(s) {
2169
2172
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
2170
2173
  }
2171
2174
  var XFileCardList = /* @__PURE__ */ defineComponent({
2172
- name: "XFileCardList",
2175
+ name: "AxFileCardList",
2173
2176
  props: {
2174
2177
  prefixCls: {
2175
2178
  type: String,
@@ -2333,7 +2336,7 @@ var XFileCardList = /* @__PURE__ */ defineComponent({
2333
2336
  "style": [props.style, splitStyles.value.root],
2334
2337
  "onScroll": checkPing
2335
2338
  }, [
2336
- createVNode(TransitionGroup, { "name": `${compCls.value}-motion` }, _isSlot$5(_slot = list.value.map((item, itemIndex) => {
2339
+ createVNode(TransitionGroup, { "name": `${compCls.value}-motion` }, _isSlot$6(_slot = list.value.map((item, itemIndex) => {
2337
2340
  const { __key, ...fileItem } = item;
2338
2341
  const cardSlots = {
2339
2342
  description: slots.description ? (slotInfo) => slots.description?.({
@@ -2660,7 +2663,7 @@ var FileList_default = /* @__PURE__ */ defineComponent({
2660
2663
  });
2661
2664
  //#endregion
2662
2665
  //#region components/attachments/PlaceholderUploader.tsx
2663
- function _isSlot$4(s) {
2666
+ function _isSlot$5(s) {
2664
2667
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
2665
2668
  }
2666
2669
  var PlaceholderUploader = /* @__PURE__ */ defineComponent({
@@ -2755,7 +2758,7 @@ var PlaceholderUploader = /* @__PURE__ */ defineComponent({
2755
2758
  border: 0,
2756
2759
  background: "transparent"
2757
2760
  }
2758
- }), _isSlot$4(node) ? node : { default: () => [node] })]);
2761
+ }), _isSlot$5(node) ? node : { default: () => [node] })]);
2759
2762
  };
2760
2763
  }
2761
2764
  });
@@ -2872,11 +2875,11 @@ var style_default$11 = genStyleHooks("Attachments", (token) => {
2872
2875
  }, prepareComponentToken$11);
2873
2876
  //#endregion
2874
2877
  //#region components/attachments/index.tsx
2875
- function _isSlot$3(s) {
2878
+ function _isSlot$4(s) {
2876
2879
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
2877
2880
  }
2878
2881
  var XAttachments = /* @__PURE__ */ defineComponent({
2879
- name: "XAttachments",
2882
+ name: "AxAttachments",
2880
2883
  inheritAttrs: false,
2881
2884
  props: {
2882
2885
  prefixCls: {
@@ -3098,7 +3101,7 @@ var XAttachments = /* @__PURE__ */ defineComponent({
3098
3101
  props.rootClass,
3099
3102
  mergedClasses.value.root
3100
3103
  ]
3101
- }, _isSlot$3(_slot = getPlaceholderNode("drop")) ? _slot : { default: () => [_slot] })]);
3104
+ }, _isSlot$4(_slot = getPlaceholderNode("drop")) ? _slot : { default: () => [_slot] })]);
3102
3105
  };
3103
3106
  const renderNormalMode = () => {
3104
3107
  let _slot2;
@@ -3137,7 +3140,7 @@ var XAttachments = /* @__PURE__ */ defineComponent({
3137
3140
  "getDropContainer": props.getDropContainer || (() => containerRef.value),
3138
3141
  "prefixCls": props.prefixCls,
3139
3142
  "class": [hashId.value, cssVarCls.value]
3140
- }, _isSlot$3(_slot2 = getPlaceholderNode("drop")) ? _slot2 : { default: () => [_slot2] })
3143
+ }, _isSlot$4(_slot2 = getPlaceholderNode("drop")) ? _slot2 : { default: () => [_slot2] })
3141
3144
  ]);
3142
3145
  };
3143
3146
  return () => slots.default ? renderWithChildren() : renderNormalMode();
@@ -3820,7 +3823,7 @@ function hasRenderableNode$7(node) {
3820
3823
  return node !== null && node !== void 0 && node !== false;
3821
3824
  }
3822
3825
  var XBubble = /* @__PURE__ */ defineComponent({
3823
- name: "XBubble",
3826
+ name: "AxBubble",
3824
3827
  inheritAttrs: false,
3825
3828
  props: {
3826
3829
  prefixCls: {
@@ -4157,11 +4160,11 @@ var XBubble = /* @__PURE__ */ defineComponent({
4157
4160
  });
4158
4161
  //#endregion
4159
4162
  //#region components/bubble/Divider.tsx
4160
- function _isSlot$2(s) {
4163
+ function _isSlot$3(s) {
4161
4164
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
4162
4165
  }
4163
4166
  var XBubbleDivider = /* @__PURE__ */ defineComponent({
4164
- name: "XBubbleDivider",
4167
+ name: "AxBubbleDivider",
4165
4168
  props: {
4166
4169
  prefixCls: {
4167
4170
  type: String,
@@ -4223,7 +4226,7 @@ var XBubbleDivider = /* @__PURE__ */ defineComponent({
4223
4226
  "class": [`${props.prefixCls}-divider`, props.class],
4224
4227
  "styles": props.styles,
4225
4228
  "classes": props.classes
4226
- }), { contentRender: ({ content }) => createVNode(Divider, props.dividerProps, _isSlot$2(content) ? content : { default: () => [content] }) });
4229
+ }), { contentRender: ({ content }) => createVNode(Divider, props.dividerProps, _isSlot$3(content) ? content : { default: () => [content] }) });
4227
4230
  }
4228
4231
  });
4229
4232
  //#endregion
@@ -4351,7 +4354,7 @@ function useCompatibleScroll(scrollDomRef, contentDomRef) {
4351
4354
  //#endregion
4352
4355
  //#region components/bubble/System.tsx
4353
4356
  var XBubbleSystem = /* @__PURE__ */ defineComponent({
4354
- name: "XBubbleSystem",
4357
+ name: "AxBubbleSystem",
4355
4358
  props: {
4356
4359
  prefixCls: {
4357
4360
  type: String,
@@ -4440,7 +4443,7 @@ var bubbleSlotNames = [
4440
4443
  "extra"
4441
4444
  ];
4442
4445
  var XBubbleList = /* @__PURE__ */ defineComponent({
4443
- name: "XBubbleList",
4446
+ name: "AxBubbleList",
4444
4447
  inheritAttrs: false,
4445
4448
  props: {
4446
4449
  prefixCls: {
@@ -4678,6 +4681,73 @@ BubbleWithSub.List = XBubbleList;
4678
4681
  BubbleWithSub.System = XBubbleSystem;
4679
4682
  BubbleWithSub.Divider = XBubbleDivider;
4680
4683
  //#endregion
4684
+ //#region components/code-highlighter/shiki.ts
4685
+ var SUPPORTED_LANG_ALIASES = {
4686
+ ts: "typescript",
4687
+ js: "javascript",
4688
+ py: "python",
4689
+ md: "markdown",
4690
+ yml: "yaml",
4691
+ shell: "bash",
4692
+ zsh: "bash",
4693
+ sh: "bash",
4694
+ vue: "vue"
4695
+ };
4696
+ var LANG_LOADERS = {
4697
+ javascript: () => import("shiki/dist/langs/javascript.mjs"),
4698
+ typescript: () => import("shiki/dist/langs/typescript.mjs"),
4699
+ jsx: () => import("shiki/dist/langs/jsx.mjs"),
4700
+ tsx: () => import("shiki/dist/langs/tsx.mjs"),
4701
+ json: () => import("shiki/dist/langs/json.mjs"),
4702
+ bash: () => import("shiki/dist/langs/bash.mjs"),
4703
+ markdown: () => import("shiki/dist/langs/markdown.mjs"),
4704
+ html: () => import("shiki/dist/langs/html.mjs"),
4705
+ css: () => import("shiki/dist/langs/css.mjs"),
4706
+ vue: () => import("shiki/dist/langs/vue.mjs"),
4707
+ "vue-html": () => import("shiki/dist/langs/vue-html.mjs"),
4708
+ python: () => import("shiki/dist/langs/python.mjs"),
4709
+ mermaid: () => import("shiki/dist/langs/mermaid.mjs"),
4710
+ yaml: () => import("shiki/dist/langs/yaml.mjs"),
4711
+ diff: () => import("shiki/dist/langs/diff.mjs")
4712
+ };
4713
+ var highlighter = null;
4714
+ var highlighterPromise = null;
4715
+ var loadedLangs = /* @__PURE__ */ new Set();
4716
+ function normalizeLanguage(language) {
4717
+ const input = (language || "text").toLowerCase();
4718
+ return SUPPORTED_LANG_ALIASES[input] || input;
4719
+ }
4720
+ function escapeHtml(str) {
4721
+ return str.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
4722
+ }
4723
+ async function getHighlighter() {
4724
+ if (highlighter) return highlighter;
4725
+ if (!highlighterPromise) highlighterPromise = createHighlighterCore({
4726
+ themes: [lightTheme, darkTheme],
4727
+ langs: [],
4728
+ engine: createJavaScriptRegexEngine()
4729
+ });
4730
+ highlighter = await highlighterPromise;
4731
+ return highlighter;
4732
+ }
4733
+ async function loadLang(lang) {
4734
+ const loader = LANG_LOADERS[lang];
4735
+ if (!loader || loadedLangs.has(lang)) return false;
4736
+ const instance = await getHighlighter();
4737
+ const mod = await loader();
4738
+ await instance.loadLanguage(mod.default);
4739
+ loadedLangs.add(lang);
4740
+ return true;
4741
+ }
4742
+ async function codeToHtml(code, options = {}) {
4743
+ const lang = normalizeLanguage(options.lang);
4744
+ if (!await loadLang(lang)) return `<pre><code>${escapeHtml(code)}</code></pre>`;
4745
+ return (await getHighlighter()).codeToHtml(code, {
4746
+ lang,
4747
+ theme: options.theme || "vitesse-light"
4748
+ });
4749
+ }
4750
+ //#endregion
4681
4751
  //#region components/code-highlighter/style/index.ts
4682
4752
  var genCodeHighlighterStyle = (token) => {
4683
4753
  const { componentCls } = token;
@@ -4788,21 +4858,9 @@ var style_default$9 = genStyleHooks("CodeHighlighter", (token) => {
4788
4858
  return [genCodeHighlighterStyle(mergeToken(token, {}))];
4789
4859
  }, prepareComponentToken$9);
4790
4860
  //#endregion
4791
- //#region components/code-highlighter/CodeHighlighter.tsx
4792
- var shikiHighlighter = null;
4793
- var shikiPromise = null;
4794
- async function initShiki() {
4795
- if (shikiHighlighter) return;
4796
- if (shikiPromise) return shikiPromise;
4797
- shikiPromise = (async () => {
4798
- shikiHighlighter = (await import("shiki")).codeToHtml;
4799
- })();
4800
- return shikiPromise;
4801
- }
4802
- //#endregion
4803
4861
  //#region components/code-highlighter/index.tsx
4804
4862
  var code_highlighter_default = /* @__PURE__ */ defineComponent({
4805
- name: "XCodeHighlighter",
4863
+ name: "AxCodeHighlighter",
4806
4864
  inheritAttrs: false,
4807
4865
  props: {
4808
4866
  prefixCls: {
@@ -4883,9 +4941,7 @@ var code_highlighter_default = /* @__PURE__ */ defineComponent({
4883
4941
  const highlightedHtml = shallowRef("");
4884
4942
  const highlightCode = async () => {
4885
4943
  try {
4886
- await initShiki();
4887
- if (!shikiHighlighter) return;
4888
- highlightedHtml.value = await shikiHighlighter(props.content, {
4944
+ highlightedHtml.value = await codeToHtml(props.content, {
4889
4945
  lang: props.language,
4890
4946
  theme: props.theme === "dark" ? "vitesse-dark" : "vitesse-light"
4891
4947
  });
@@ -5328,7 +5384,7 @@ function useCreation({ icon, label, align, shortcutKeyInfo, prefixCls }) {
5328
5384
  //#endregion
5329
5385
  //#region components/conversations/Creation.tsx
5330
5386
  var Creation = /* @__PURE__ */ defineComponent({
5331
- name: "XConversationsCreation",
5387
+ name: "AxConversationsCreation",
5332
5388
  props: {
5333
5389
  label: {
5334
5390
  type: [
@@ -5545,7 +5601,7 @@ function useGroupable(groupable, items) {
5545
5601
  }
5546
5602
  //#endregion
5547
5603
  //#region components/conversations/Item.tsx
5548
- function _isSlot$1(s) {
5604
+ function _isSlot$2(s) {
5549
5605
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
5550
5606
  }
5551
5607
  var stopPropagation = (event) => {
@@ -5686,14 +5742,14 @@ var ConversationsItem = /* @__PURE__ */ defineComponent({
5686
5742
  }
5687
5743
  }, [
5688
5744
  hasRenderableNode$6(iconNode) && createVNode("div", { "class": `${props.prefixCls}-icon` }, [iconNode]),
5689
- createVNode(Typography.Text, { "class": `${props.prefixCls}-label` }, _isSlot$1(labelNode) ? labelNode : { default: () => [labelNode] }),
5745
+ createVNode(Typography.Text, { "class": `${props.prefixCls}-label` }, _isSlot$2(labelNode) ? labelNode : { default: () => [labelNode] }),
5690
5746
  !disabled && props.menu && createVNode("div", { "onClick": stopPropagation }, [createVNode(Dropdown, {
5691
5747
  "menu": menuProps.value,
5692
5748
  "placement": props.direction === "rtl" ? "bottomLeft" : "bottomRight",
5693
5749
  "trigger": ["click"],
5694
5750
  "disabled": disabled,
5695
5751
  "getPopupContainer": menuProps.value?.getPopupContainer
5696
- }, _isSlot$1(_slot = renderMenuTrigger(props.info)) ? _slot : { default: () => [_slot] })])
5752
+ }, _isSlot$2(_slot = renderMenuTrigger(props.info)) ? _slot : { default: () => [_slot] })])
5697
5753
  ]);
5698
5754
  };
5699
5755
  }
@@ -5867,7 +5923,7 @@ function isTypingTarget(target) {
5867
5923
  return tagName === "input" || tagName === "textarea" || tagName === "select";
5868
5924
  }
5869
5925
  var ConversationsWithSub = /* @__PURE__ */ defineComponent({
5870
- name: "XConversations",
5926
+ name: "AxConversations",
5871
5927
  inheritAttrs: false,
5872
5928
  props: {
5873
5929
  items: {
@@ -6104,6 +6160,38 @@ var warning = (valid, component, message) => {
6104
6160
  }
6105
6161
  };
6106
6162
  //#endregion
6163
+ //#region components/mermaid/loader.ts
6164
+ var mermaidInstance = null;
6165
+ var mermaidPromise = null;
6166
+ var pendingInitializeConfig = null;
6167
+ async function loadMermaid() {
6168
+ if (mermaidInstance) return mermaidInstance;
6169
+ if (!mermaidPromise) mermaidPromise = import("mermaid/dist/mermaid.core.mjs").then((mod) => mod.default).then((instance) => {
6170
+ mermaidInstance = instance;
6171
+ if (pendingInitializeConfig) {
6172
+ instance.initialize(pendingInitializeConfig);
6173
+ pendingInitializeConfig = null;
6174
+ }
6175
+ return instance;
6176
+ });
6177
+ return mermaidPromise;
6178
+ }
6179
+ function initializeMermaid(config) {
6180
+ pendingInitializeConfig = config;
6181
+ if (mermaidInstance) {
6182
+ mermaidInstance.initialize(config);
6183
+ pendingInitializeConfig = null;
6184
+ return;
6185
+ }
6186
+ loadMermaid();
6187
+ }
6188
+ async function parseMermaid(content, options) {
6189
+ return (await loadMermaid()).parse(content, options);
6190
+ }
6191
+ async function renderMermaid(id, content, container) {
6192
+ return (await loadMermaid()).render(id, content, container);
6193
+ }
6194
+ //#endregion
6107
6195
  //#region components/mermaid/style/index.ts
6108
6196
  var genMermaidStyle = (token) => {
6109
6197
  const { componentCls } = token;
@@ -6210,7 +6298,7 @@ function throttle(fn, wait) {
6210
6298
  //#endregion
6211
6299
  //#region components/mermaid/index.tsx
6212
6300
  var mermaid_default = /* @__PURE__ */ defineComponent({
6213
- name: "XMermaid",
6301
+ name: "AxMermaid",
6214
6302
  inheritAttrs: false,
6215
6303
  props: {
6216
6304
  content: {
@@ -6341,8 +6429,8 @@ var mermaid_default = /* @__PURE__ */ defineComponent({
6341
6429
  const graphEl = graphRef.value;
6342
6430
  if (!graphEl) return;
6343
6431
  try {
6344
- if (await mermaid.parse(props.content, { suppressErrors: true }) === false) throw new Error("Invalid Mermaid syntax");
6345
- const { svg } = await mermaid.render(`${renderBaseId}-${idSeed++}-${props.content.length || 0}`, props.content);
6432
+ if (await parseMermaid(props.content, { suppressErrors: true }) === false) throw new Error("Invalid Mermaid syntax");
6433
+ const { svg } = await renderMermaid(`${renderBaseId}-${idSeed++}-${props.content.length || 0}`, props.content);
6346
6434
  graphEl.innerHTML = svg;
6347
6435
  applySvgTransform();
6348
6436
  } catch (error) {
@@ -6475,7 +6563,7 @@ var mermaid_default = /* @__PURE__ */ defineComponent({
6475
6563
  if (next !== void 0) internalRenderType.value = next;
6476
6564
  });
6477
6565
  watch(() => props.config, (nextConfig) => {
6478
- mermaid.initialize({
6566
+ initializeMermaid({
6479
6567
  startOnLoad: false,
6480
6568
  securityLevel: "strict",
6481
6569
  theme: "default",
@@ -6797,7 +6885,7 @@ function hasRenderableNode$5(node) {
6797
6885
  //#endregion
6798
6886
  //#region components/prompts/index.tsx
6799
6887
  var prompts_default = /* @__PURE__ */ defineComponent({
6800
- name: "XPrompts",
6888
+ name: "AxPrompts",
6801
6889
  inheritAttrs: false,
6802
6890
  props: {
6803
6891
  items: {
@@ -6917,8 +7005,10 @@ var prompts_default = /* @__PURE__ */ defineComponent({
6917
7005
  };
6918
7006
  });
6919
7007
  const triggerItemClick = (item, nested) => {
6920
- if (nested || item.disabled) return;
6921
- emit("itemClick", { data: item });
7008
+ if (item.disabled || !nested && hasChildren(item)) return;
7009
+ const info = { data: item };
7010
+ props.onItemClick?.(info);
7011
+ emit("itemClick", info);
6922
7012
  };
6923
7013
  const renderTitle = () => {
6924
7014
  if (slots.title) return slots.title({ originNode: props.title });
@@ -6963,7 +7053,7 @@ var prompts_default = /* @__PURE__ */ defineComponent({
6963
7053
  }
6964
7054
  ],
6965
7055
  "style": [nested ? mergedStyles.value.subItem : mergedStyles.value.item, item.style],
6966
- "onClick": () => triggerItemClick(item, itemHasChildren)
7056
+ "onClick": () => triggerItemClick(item, nested)
6967
7057
  }), [hasRenderableNode$5(iconNode) && createVNode("div", { "class": `${props.prefixCls}-icon` }, [iconNode]), createVNode("div", {
6968
7058
  "class": [`${props.prefixCls}-content`, mergedClasses.value.itemContent],
6969
7059
  "style": mergedStyles.value.itemContent
@@ -7040,10 +7130,6 @@ var ActionButton = /* @__PURE__ */ defineComponent({
7040
7130
  variant: {
7041
7131
  type: String,
7042
7132
  default: void 0
7043
- },
7044
- class: {
7045
- type: String,
7046
- default: void 0
7047
7133
  }
7048
7134
  },
7049
7135
  setup(props, { attrs }) {
@@ -7066,7 +7152,7 @@ var ActionButton = /* @__PURE__ */ defineComponent({
7066
7152
  "disabled": mergedDisabled.value,
7067
7153
  "class": [
7068
7154
  prefixCls,
7069
- props.class,
7155
+ attrs.class,
7070
7156
  { [`${prefixCls}-disabled`]: mergedDisabled.value }
7071
7157
  ],
7072
7158
  "onClick": (e) => {
@@ -7177,6 +7263,811 @@ var SendButton_default = /* @__PURE__ */ defineComponent({
7177
7263
  }
7178
7264
  });
7179
7265
  //#endregion
7266
+ //#region components/sender/context.ts
7267
+ var SenderContextKey = Symbol("sender-context");
7268
+ function useSenderContext() {
7269
+ return inject(SenderContextKey, computed(() => ({})));
7270
+ }
7271
+ function provideSenderContext(value) {
7272
+ provide(SenderContextKey, value);
7273
+ }
7274
+ //#endregion
7275
+ //#region components/sender/components/Skill.tsx
7276
+ function _isSlot$1(s) {
7277
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
7278
+ }
7279
+ var Skill_default = /* @__PURE__ */ defineComponent({
7280
+ name: "SenderSkill",
7281
+ props: {
7282
+ prefixCls: {
7283
+ type: String,
7284
+ required: true
7285
+ },
7286
+ skill: {
7287
+ type: Object,
7288
+ required: true
7289
+ },
7290
+ removeSkill: {
7291
+ type: Function,
7292
+ required: true
7293
+ }
7294
+ },
7295
+ setup(props) {
7296
+ const componentCls = computed(() => `${props.prefixCls}-skill`);
7297
+ const closeNode = computed(() => {
7298
+ const closable = props.skill.closable;
7299
+ if (!closable) return null;
7300
+ const config = typeof closable === "boolean" ? {} : closable;
7301
+ const closeIcon = config.closeIcon ?? createVNode(CloseOutlined, { "class": `${componentCls.value}-close-icon` }, null);
7302
+ return createVNode("div", {
7303
+ "class": classNames([`${componentCls.value}-close`, { [`${componentCls.value}-close-disabled`]: config.disabled }]),
7304
+ "role": "button",
7305
+ "aria-label": "Close skill",
7306
+ "tabindex": 0,
7307
+ "onClick": (event) => {
7308
+ if (config.disabled) return;
7309
+ event.stopPropagation();
7310
+ props.removeSkill();
7311
+ config.onClose?.(event);
7312
+ }
7313
+ }, [closeIcon]);
7314
+ });
7315
+ return () => {
7316
+ const mergeTitle = props.skill.title ?? props.skill.value;
7317
+ const titleNode = props.skill.toolTip ? createVNode(Tooltip, props.skill.toolTip, _isSlot$1(mergeTitle) ? mergeTitle : { default: () => [mergeTitle] }) : mergeTitle;
7318
+ return createVNode("div", {
7319
+ "class": `${componentCls.value}-wrapper`,
7320
+ "contenteditable": false
7321
+ }, [createVNode("div", {
7322
+ "class": `${componentCls.value}-tag`,
7323
+ "contenteditable": false,
7324
+ "role": "button",
7325
+ "tabindex": 0
7326
+ }, [createVNode("span", { "class": `${componentCls.value}-tag-text` }, [titleNode]), closeNode.value]), createVNode("div", { "class": `${componentCls.value}-holder` }, null)]);
7327
+ };
7328
+ }
7329
+ });
7330
+ //#endregion
7331
+ //#region components/sender/components/SlotTextArea.tsx
7332
+ var SUPPORTED_INPUT_TYPES = new Set([
7333
+ "input",
7334
+ "select",
7335
+ "custom",
7336
+ "content"
7337
+ ]);
7338
+ function stringifyValue(value) {
7339
+ if (value === void 0 || value === null) return "";
7340
+ if (typeof value === "string") return value;
7341
+ if (typeof value === "number" || typeof value === "boolean") return `${value}`;
7342
+ try {
7343
+ return JSON.stringify(value);
7344
+ } catch {
7345
+ return "";
7346
+ }
7347
+ }
7348
+ function getDefaultSlotValue(config) {
7349
+ if (!config.key) return void 0;
7350
+ const props = config.props ?? {};
7351
+ if (SUPPORTED_INPUT_TYPES.has(config.type)) return props.defaultValue ?? "";
7352
+ return props.value ?? props.label ?? "";
7353
+ }
7354
+ var SlotTextArea_default = /* @__PURE__ */ defineComponent({
7355
+ name: "SlotTextArea",
7356
+ setup(_, { expose }) {
7357
+ const senderCtx = useSenderContext();
7358
+ const editableRef = ref();
7359
+ const slotDomMap = ref(/* @__PURE__ */ new Map());
7360
+ const slotConfigMap = ref(/* @__PURE__ */ new Map());
7361
+ const slotValues = ref({});
7362
+ const mountedDomSet = ref(/* @__PURE__ */ new Set());
7363
+ const skillDomRef = ref(null);
7364
+ const currentSkillRef = ref(void 0);
7365
+ const lastSlotConfigRef = ref(void 0);
7366
+ const lastSkillRef = ref(void 0);
7367
+ const isComposing = ref(false);
7368
+ const keyLock = ref(false);
7369
+ const prefixCls = computed(() => senderCtx.value.prefixCls || "antd-sender");
7370
+ const mergeInputStyle = computed(() => ({
7371
+ ...senderCtx.value.styles?.input,
7372
+ ...getAutoSizeStyle()
7373
+ }));
7374
+ const getAutoSizeStyle = () => {
7375
+ const autoSize = senderCtx.value.autoSize;
7376
+ if (autoSize === true) return { height: "auto" };
7377
+ if (!autoSize || typeof autoSize !== "object") return {};
7378
+ const lineHeight = 22;
7379
+ return {
7380
+ minHeight: autoSize.minRows ? `${autoSize.minRows * lineHeight}px` : void 0,
7381
+ maxHeight: autoSize.maxRows ? `${autoSize.maxRows * lineHeight}px` : void 0,
7382
+ overflowY: "auto"
7383
+ };
7384
+ };
7385
+ const getNodeInfo = (targetNode) => {
7386
+ if (!targetNode?.dataset) return null;
7387
+ const slotKey = targetNode.dataset.slotKey;
7388
+ return {
7389
+ slotKey,
7390
+ skillKey: targetNode.dataset.skillKey,
7391
+ nodeType: targetNode.dataset.nodeType,
7392
+ slotConfig: slotKey ? slotConfigMap.value.get(slotKey) : void 0
7393
+ };
7394
+ };
7395
+ const unmountDom = (container) => {
7396
+ if (!container) return;
7397
+ render(null, container);
7398
+ mountedDomSet.value.delete(container);
7399
+ };
7400
+ const unmountAllPortals = () => {
7401
+ mountedDomSet.value.forEach((container) => {
7402
+ render(null, container);
7403
+ });
7404
+ mountedDomSet.value.clear();
7405
+ };
7406
+ const buildSkillSpan = (key) => {
7407
+ const span = document.createElement("span");
7408
+ span.setAttribute("contenteditable", "false");
7409
+ span.dataset.skillKey = key;
7410
+ span.dataset.placeholder = senderCtx.value.placeholder || "";
7411
+ span.className = `${prefixCls.value}-skill`;
7412
+ return span;
7413
+ };
7414
+ const buildSlotSpan = (key) => {
7415
+ const span = document.createElement("span");
7416
+ span.setAttribute("contenteditable", "false");
7417
+ span.dataset.slotKey = key;
7418
+ span.className = `${prefixCls.value}-slot`;
7419
+ return span;
7420
+ };
7421
+ const buildEditSlotSpan = (config) => {
7422
+ const span = document.createElement("span");
7423
+ span.setAttribute("contenteditable", senderCtx.value.readOnly ? "false" : "true");
7424
+ span.dataset.slotKey = config.key;
7425
+ span.className = `${prefixCls.value}-slot ${prefixCls.value}-slot-content`;
7426
+ return span;
7427
+ };
7428
+ const buildSpaceSpan = (slotKey, position) => {
7429
+ const span = document.createElement("span");
7430
+ span.setAttribute("contenteditable", "false");
7431
+ span.dataset.slotKey = slotKey;
7432
+ span.dataset.nodeType = "nbsp";
7433
+ span.className = `${prefixCls.value}-slot-${position} ${prefixCls.value}-slot-no-width`;
7434
+ span.textContent = "\xA0";
7435
+ return span;
7436
+ };
7437
+ const getNodeTextValue = (node) => {
7438
+ if (node.nodeType === Node.TEXT_NODE) return node.textContent ?? "";
7439
+ if (node.nodeType !== Node.ELEMENT_NODE) return "";
7440
+ const element = node;
7441
+ const nodeInfo = getNodeInfo(element);
7442
+ if (!nodeInfo) return element.innerText || "";
7443
+ if (nodeInfo.skillKey) return "";
7444
+ if (nodeInfo.slotKey) {
7445
+ if (nodeInfo.nodeType === "nbsp") return " ";
7446
+ const config = nodeInfo.slotConfig;
7447
+ if (!config || config.type === "content") return element.innerText || "";
7448
+ const rawValue = slotValues.value[nodeInfo.slotKey];
7449
+ return config.formatResult?.(rawValue) ?? stringifyValue(rawValue);
7450
+ }
7451
+ return element.innerText || "";
7452
+ };
7453
+ const getEditorValue = () => {
7454
+ const editable = editableRef.value;
7455
+ const emptyResult = {
7456
+ value: "",
7457
+ slotConfig: [],
7458
+ skill: void 0
7459
+ };
7460
+ if (!editable) return emptyResult;
7461
+ const childNodes = editable.childNodes;
7462
+ if (childNodes.length === 0) return emptyResult;
7463
+ const textList = [];
7464
+ const currentSlotConfig = [];
7465
+ let currentSkill;
7466
+ childNodes.forEach((node) => {
7467
+ const textValue = getNodeTextValue(node);
7468
+ textList.push(textValue);
7469
+ if (node.nodeType === Node.TEXT_NODE) {
7470
+ if (textValue) currentSlotConfig.push({
7471
+ type: "text",
7472
+ value: textValue
7473
+ });
7474
+ return;
7475
+ }
7476
+ if (node.nodeType === Node.ELEMENT_NODE) {
7477
+ const info = getNodeInfo(node);
7478
+ if (!info) return;
7479
+ if (info.skillKey && currentSkillRef.value) currentSkill = currentSkillRef.value;
7480
+ if (info.slotKey && info.nodeType !== "nbsp") {
7481
+ const cfg = slotConfigMap.value.get(info.slotKey);
7482
+ if (cfg) currentSlotConfig.push({
7483
+ ...cfg,
7484
+ value: textValue
7485
+ });
7486
+ }
7487
+ }
7488
+ });
7489
+ return {
7490
+ value: textList.join(""),
7491
+ slotConfig: currentSlotConfig,
7492
+ skill: currentSkill
7493
+ };
7494
+ };
7495
+ const updateSubmitDisabled = () => {
7496
+ const value = getEditorValue();
7497
+ senderCtx.value.setSubmitDisabled?.(!value.value && value.slotConfig.length === 0 && !value.skill);
7498
+ };
7499
+ const triggerValueChange = (event) => {
7500
+ const value = getEditorValue();
7501
+ senderCtx.value.onChange?.(value.value, event, value.slotConfig, value.skill);
7502
+ updateSkillEmptyStatus(value);
7503
+ updateSubmitDisabled();
7504
+ };
7505
+ const updateSlot = (key, value, event) => {
7506
+ slotValues.value = {
7507
+ ...slotValues.value,
7508
+ [key]: value
7509
+ };
7510
+ const config = slotConfigMap.value.get(key);
7511
+ const dom = slotDomMap.value.get(key);
7512
+ if (config && dom && config.type !== "content") renderSlot(config, dom);
7513
+ triggerValueChange(event);
7514
+ };
7515
+ const buildSelectMenuItems = (options) => {
7516
+ return (options ?? []).map((option) => ({
7517
+ label: option,
7518
+ key: option
7519
+ }));
7520
+ };
7521
+ const renderSlot = (config, slotDom) => {
7522
+ if (!("key" in config) || !config.key) return;
7523
+ const slotValue = slotValues.value[config.key];
7524
+ let node = null;
7525
+ switch (config.type) {
7526
+ case "input":
7527
+ node = createVNode(Input, {
7528
+ "class": `${prefixCls.value}-slot-input`,
7529
+ "placeholder": config.props?.placeholder,
7530
+ "value": slotValue ?? "",
7531
+ "size": "small",
7532
+ "variant": "borderless",
7533
+ "readonly": senderCtx.value.readOnly,
7534
+ "disabled": senderCtx.value.disabled,
7535
+ "onKeydown": onInternalKeyDown,
7536
+ "onChange": (e) => {
7537
+ updateSlot(config.key, e?.target?.value ?? "", e);
7538
+ }
7539
+ }, null);
7540
+ break;
7541
+ case "select": {
7542
+ const displayValue = stringifyValue(slotValue);
7543
+ node = createVNode(Dropdown, {
7544
+ "disabled": senderCtx.value.readOnly || senderCtx.value.disabled,
7545
+ "trigger": ["click"],
7546
+ "menu": {
7547
+ items: buildSelectMenuItems(config.props?.options),
7548
+ selectable: true,
7549
+ selectedKeys: displayValue ? [displayValue] : [],
7550
+ onSelect: ({ key, domEvent }) => {
7551
+ updateSlot(config.key, key, domEvent);
7552
+ }
7553
+ }
7554
+ }, { default: () => [createVNode("span", { "class": classNames([`${prefixCls.value}-slot-select`, {
7555
+ placeholder: !displayValue,
7556
+ [`${prefixCls.value}-slot-select-selector-value`]: !!displayValue
7557
+ }]) }, [createVNode("span", {
7558
+ "data-placeholder": config.props?.placeholder,
7559
+ "class": `${prefixCls.value}-slot-select-value`
7560
+ }, [displayValue]), createVNode("span", { "class": `${prefixCls.value}-slot-select-arrow` }, [createTextVNode("▼")])])] });
7561
+ break;
7562
+ }
7563
+ case "tag":
7564
+ node = createVNode("span", { "class": `${prefixCls.value}-slot-tag` }, [config.props?.label ?? config.props?.value ?? ""]);
7565
+ break;
7566
+ case "custom":
7567
+ node = config.customRender?.(slotValue, (nextValue) => {
7568
+ updateSlot(config.key, nextValue);
7569
+ }, {
7570
+ disabled: senderCtx.value.disabled,
7571
+ readOnly: senderCtx.value.readOnly
7572
+ }, config);
7573
+ break;
7574
+ case "content":
7575
+ slotDom.innerText = stringifyValue(slotValue);
7576
+ slotDom.dataset.placeholder = config.props?.placeholder ?? "";
7577
+ return;
7578
+ default: return;
7579
+ }
7580
+ if (!node) return;
7581
+ mountedDomSet.value.add(slotDom);
7582
+ render(node, slotDom);
7583
+ };
7584
+ const buildSlotNodes = (configs) => {
7585
+ const list = [];
7586
+ configs.forEach((config) => {
7587
+ if (config.type === "text") {
7588
+ list.push(document.createTextNode(config.value || ""));
7589
+ return;
7590
+ }
7591
+ if (!("key" in config) || !config.key) {
7592
+ warning(false, "Sender", "Slot key is missing");
7593
+ return;
7594
+ }
7595
+ slotConfigMap.value.set(config.key, config);
7596
+ if (config.type === "content") {
7597
+ const before = buildSpaceSpan(config.key, "before");
7598
+ const slot = buildEditSlotSpan(config);
7599
+ const after = buildSpaceSpan(config.key, "after");
7600
+ slotValues.value[config.key] = slotValues.value[config.key] ?? getDefaultSlotValue(config);
7601
+ slot.innerText = stringifyValue(slotValues.value[config.key]);
7602
+ slot.dataset.placeholder = config.props?.placeholder ?? "";
7603
+ slotDomMap.value.set(`${config.key}_before`, before);
7604
+ slotDomMap.value.set(config.key, slot);
7605
+ slotDomMap.value.set(`${config.key}_after`, after);
7606
+ list.push(before, slot, after);
7607
+ return;
7608
+ }
7609
+ const slot = buildSlotSpan(config.key);
7610
+ slotValues.value[config.key] = slotValues.value[config.key] ?? getDefaultSlotValue(config);
7611
+ slotDomMap.value.set(config.key, slot);
7612
+ renderSlot(config, slot);
7613
+ list.push(slot);
7614
+ });
7615
+ return list;
7616
+ };
7617
+ const mergeSlotConfig = (configs) => {
7618
+ const nextValues = { ...slotValues.value };
7619
+ configs.forEach((config) => {
7620
+ if ("key" in config && config.key) {
7621
+ slotConfigMap.value.set(config.key, config);
7622
+ if (!(config.key in nextValues)) nextValues[config.key] = getDefaultSlotValue(config);
7623
+ }
7624
+ });
7625
+ slotValues.value = nextValues;
7626
+ };
7627
+ const clearEditor = () => {
7628
+ unmountAllPortals();
7629
+ slotDomMap.value.clear();
7630
+ slotConfigMap.value.clear();
7631
+ slotValues.value = {};
7632
+ currentSkillRef.value = void 0;
7633
+ if (skillDomRef.value) unmountDom(skillDomRef.value);
7634
+ skillDomRef.value = null;
7635
+ if (editableRef.value) editableRef.value.innerHTML = "";
7636
+ };
7637
+ const getSelection = () => {
7638
+ if (typeof window === "undefined") return null;
7639
+ return window.getSelection();
7640
+ };
7641
+ const setRange = (range, selection) => {
7642
+ selection.removeAllRanges();
7643
+ selection.addRange(range);
7644
+ };
7645
+ const setCursorPosition = (targetNode, offset, preventScroll) => {
7646
+ const editable = editableRef.value;
7647
+ if (!editable) return;
7648
+ editable.focus({ preventScroll });
7649
+ const selection = getSelection();
7650
+ if (!selection) return;
7651
+ const range = document.createRange();
7652
+ range.setStart(targetNode, offset);
7653
+ range.collapse(true);
7654
+ setRange(range, selection);
7655
+ };
7656
+ const setStartCursor = (preventScroll) => {
7657
+ const editable = editableRef.value;
7658
+ if (!editable) return;
7659
+ setCursorPosition(editable, skillDomRef.value ? 1 : 0, preventScroll);
7660
+ };
7661
+ const setEndCursor = (preventScroll) => {
7662
+ const editable = editableRef.value;
7663
+ if (!editable) return;
7664
+ editable.focus({ preventScroll });
7665
+ const selection = getSelection();
7666
+ if (!selection) return;
7667
+ const range = document.createRange();
7668
+ range.selectNodeContents(editable);
7669
+ range.collapse(false);
7670
+ setRange(range, selection);
7671
+ };
7672
+ const selectAll = (preventScroll) => {
7673
+ const editable = editableRef.value;
7674
+ if (!editable) return;
7675
+ editable.focus({ preventScroll });
7676
+ const selection = getSelection();
7677
+ if (!selection) return;
7678
+ const range = document.createRange();
7679
+ range.selectNodeContents(editable);
7680
+ if (skillDomRef.value) range.setStart(editable, 1);
7681
+ setRange(range, selection);
7682
+ };
7683
+ const focusSlot = (key, preventScroll) => {
7684
+ const editable = editableRef.value;
7685
+ if (!editable) return;
7686
+ const resolveTarget = (slotKey) => {
7687
+ const slotDom = slotDomMap.value.get(slotKey);
7688
+ const slotCfg = slotConfigMap.value.get(slotKey);
7689
+ if (!slotDom || !slotCfg) return null;
7690
+ if (slotCfg.type === "input") return slotDom.querySelector("input");
7691
+ if (slotCfg.type === "content") return slotDom;
7692
+ return null;
7693
+ };
7694
+ if (key) {
7695
+ const target = resolveTarget(key);
7696
+ if (target instanceof HTMLInputElement) {
7697
+ target.focus({ preventScroll });
7698
+ return;
7699
+ }
7700
+ if (target instanceof HTMLSpanElement) {
7701
+ setCursorPosition(target, 0, preventScroll);
7702
+ return;
7703
+ }
7704
+ }
7705
+ for (const node of Array.from(editable.childNodes)) {
7706
+ if (!(node instanceof HTMLElement)) continue;
7707
+ const slotKey = node.dataset.slotKey;
7708
+ const nodeType = node.dataset.nodeType;
7709
+ if (!slotKey || nodeType === "nbsp") continue;
7710
+ const target = resolveTarget(slotKey);
7711
+ if (target instanceof HTMLInputElement) {
7712
+ target.focus({ preventScroll });
7713
+ return;
7714
+ }
7715
+ if (target instanceof HTMLSpanElement) {
7716
+ setCursorPosition(target, 0, preventScroll);
7717
+ return;
7718
+ }
7719
+ }
7720
+ setEndCursor(preventScroll);
7721
+ };
7722
+ const removeSlot = (key, event) => {
7723
+ const editable = editableRef.value;
7724
+ if (!editable) return;
7725
+ editable.querySelectorAll(`[data-slot-key="${key}"]`).forEach((element) => {
7726
+ unmountDom(element);
7727
+ element.remove();
7728
+ });
7729
+ const nextValues = { ...slotValues.value };
7730
+ delete nextValues[key];
7731
+ slotValues.value = nextValues;
7732
+ slotConfigMap.value.delete(key);
7733
+ slotDomMap.value.delete(key);
7734
+ slotDomMap.value.delete(`${key}_before`);
7735
+ slotDomMap.value.delete(`${key}_after`);
7736
+ triggerValueChange(event);
7737
+ };
7738
+ const removeSkill = (triggerChange = true) => {
7739
+ const skillDom = skillDomRef.value;
7740
+ if (!skillDom) return;
7741
+ unmountDom(skillDom);
7742
+ skillDom.remove();
7743
+ skillDomRef.value = null;
7744
+ currentSkillRef.value = void 0;
7745
+ if (triggerChange) triggerValueChange();
7746
+ };
7747
+ const renderSkill = () => {
7748
+ const editable = editableRef.value;
7749
+ const skill = senderCtx.value.skill;
7750
+ if (!editable) return;
7751
+ if (!skill) {
7752
+ removeSkill(false);
7753
+ return;
7754
+ }
7755
+ let skillDom = skillDomRef.value;
7756
+ if (!skillDom) {
7757
+ skillDom = buildSkillSpan(skill.value);
7758
+ editable.insertBefore(skillDom, editable.firstChild);
7759
+ skillDomRef.value = skillDom;
7760
+ }
7761
+ currentSkillRef.value = skill;
7762
+ mountedDomSet.value.add(skillDom);
7763
+ render(createVNode(Skill_default, {
7764
+ "prefixCls": prefixCls.value,
7765
+ "skill": skill,
7766
+ "removeSkill": () => removeSkill(true)
7767
+ }, null), skillDom);
7768
+ };
7769
+ const updateSkillEmptyStatus = (value = getEditorValue()) => {
7770
+ const skillDom = skillDomRef.value;
7771
+ if (!skillDom) return;
7772
+ if (!value.value && value.slotConfig.length === 0 && !!senderCtx.value.placeholder) {
7773
+ skillDom.setAttribute("contenteditable", "true");
7774
+ skillDom.classList.add(`${prefixCls.value}-skill-empty`);
7775
+ } else {
7776
+ skillDom.setAttribute("contenteditable", "false");
7777
+ skillDom.classList.remove(`${prefixCls.value}-skill-empty`);
7778
+ }
7779
+ };
7780
+ const initFromSlotConfig = (configs) => {
7781
+ const editable = editableRef.value;
7782
+ if (!editable) return;
7783
+ clearEditor();
7784
+ const mergeConfigs = configs ?? [];
7785
+ mergeConfigs.forEach((config) => {
7786
+ if ("key" in config && config.key) {
7787
+ slotConfigMap.value.set(config.key, config);
7788
+ const defaultValue = getDefaultSlotValue(config);
7789
+ if (defaultValue !== void 0) slotValues.value[config.key] = defaultValue;
7790
+ }
7791
+ });
7792
+ buildSlotNodes(mergeConfigs).forEach((node) => {
7793
+ editable.appendChild(node);
7794
+ });
7795
+ renderSkill();
7796
+ nextTick(() => {
7797
+ triggerValueChange();
7798
+ });
7799
+ };
7800
+ const removeSpecificBRs = () => {
7801
+ if (senderCtx.value.submitType !== "enter") return;
7802
+ editableRef.value?.querySelectorAll("br").forEach((br) => br.remove());
7803
+ };
7804
+ const shouldSubmit = (event) => {
7805
+ const { key, shiftKey, ctrlKey, altKey, metaKey } = event;
7806
+ if (key !== "Enter") return false;
7807
+ const isModifierPressed = ctrlKey || altKey || metaKey;
7808
+ const submitType = senderCtx.value.submitType ?? "enter";
7809
+ return submitType === "enter" && !shiftKey && !isModifierPressed || submitType === "shiftEnter" && shiftKey && !isModifierPressed;
7810
+ };
7811
+ const findOuterContainer = (node) => {
7812
+ const editable = editableRef.value;
7813
+ if (!node || !editable) return null;
7814
+ let current = node;
7815
+ if (current.nodeType === Node.TEXT_NODE) current = current.parentNode;
7816
+ while (current && current !== editable) {
7817
+ if (current instanceof HTMLElement && current.tagName === "SPAN") return current;
7818
+ current = current.parentNode;
7819
+ }
7820
+ return null;
7821
+ };
7822
+ const handleBackspaceDelete = (event) => {
7823
+ const selection = getSelection();
7824
+ if (!selection || !selection.isCollapsed) return false;
7825
+ const editable = editableRef.value;
7826
+ if (!editable) return false;
7827
+ let anchorNode = selection.anchorNode;
7828
+ let offset = selection.anchorOffset;
7829
+ if (!anchorNode || !editable.contains(anchorNode)) return false;
7830
+ if (anchorNode === editable && offset > 0) {
7831
+ anchorNode = editable.childNodes[offset - 1] ?? anchorNode;
7832
+ offset = 0;
7833
+ }
7834
+ if (anchorNode.nodeType === Node.TEXT_NODE && offset > 0) return false;
7835
+ const target = anchorNode.nodeType === Node.TEXT_NODE ? anchorNode.parentNode : anchorNode;
7836
+ const previous = target === editable ? editable.childNodes[Math.max(0, selection.anchorOffset - 1)] : target?.previousSibling;
7837
+ if (!(previous instanceof HTMLElement)) return false;
7838
+ const info = getNodeInfo(previous);
7839
+ if (info?.slotKey) {
7840
+ event.preventDefault();
7841
+ removeSlot(info.slotKey, event);
7842
+ return true;
7843
+ }
7844
+ if (info?.skillKey) {
7845
+ event.preventDefault();
7846
+ removeSkill(true);
7847
+ return true;
7848
+ }
7849
+ return false;
7850
+ };
7851
+ const onInternalKeyDown = (event) => {
7852
+ if (senderCtx.value.onKeyDown?.(event) === false || keyLock.value || isComposing.value) return;
7853
+ if (event.key === "Backspace" && handleBackspaceDelete(event)) return;
7854
+ if (shouldSubmit(event)) {
7855
+ event.preventDefault();
7856
+ keyLock.value = true;
7857
+ senderCtx.value.triggerSend?.();
7858
+ return;
7859
+ }
7860
+ if ((event.key === "a" || event.key === "A") && (event.ctrlKey || event.metaKey)) {
7861
+ event.preventDefault();
7862
+ selectAll(true);
7863
+ }
7864
+ };
7865
+ const onInternalKeyUp = (event) => {
7866
+ if (event.key === "Enter") keyLock.value = false;
7867
+ senderCtx.value.onKeyUp?.(event);
7868
+ };
7869
+ const onInternalInput = (event) => {
7870
+ removeSpecificBRs();
7871
+ triggerValueChange(event);
7872
+ };
7873
+ const onInternalPaste = (event) => {
7874
+ event.preventDefault();
7875
+ const files = event.clipboardData?.files;
7876
+ const text = event.clipboardData?.getData("text/plain") ?? "";
7877
+ if (!text && files?.length && senderCtx.value.onPasteFile) {
7878
+ senderCtx.value.onPasteFile(files);
7879
+ return;
7880
+ }
7881
+ if (text) {
7882
+ const selection = getSelection();
7883
+ if (selection && selection.rangeCount > 0) {
7884
+ const range = selection.getRangeAt(0);
7885
+ range.deleteContents();
7886
+ const textNode = document.createTextNode(text.replace(/\u200B/g, ""));
7887
+ range.insertNode(textNode);
7888
+ range.setStartAfter(textNode);
7889
+ range.collapse(true);
7890
+ selection.removeAllRanges();
7891
+ selection.addRange(range);
7892
+ }
7893
+ }
7894
+ onInternalInput(event);
7895
+ senderCtx.value.onPaste?.(event);
7896
+ };
7897
+ const onInternalSelect = () => {
7898
+ const selection = getSelection();
7899
+ const editable = editableRef.value;
7900
+ if (!selection || !editable) return;
7901
+ if (selection.focusNode === editable && selection.focusOffset === 0 && getEditorValue().skill) setCursorPosition(editable, 1);
7902
+ };
7903
+ const getRangeForInsert = (position = "cursor") => {
7904
+ const editable = editableRef.value;
7905
+ if (!editable) return null;
7906
+ const selection = getSelection();
7907
+ const range = document.createRange();
7908
+ if (position === "start") {
7909
+ const index = skillDomRef.value ? 1 : 0;
7910
+ range.setStart(editable, index);
7911
+ range.collapse(true);
7912
+ return {
7913
+ range,
7914
+ selection
7915
+ };
7916
+ }
7917
+ if (position === "end") {
7918
+ range.selectNodeContents(editable);
7919
+ range.collapse(false);
7920
+ return {
7921
+ range,
7922
+ selection
7923
+ };
7924
+ }
7925
+ if (selection && selection.rangeCount > 0 && editable.contains(selection.getRangeAt(0).startContainer)) {
7926
+ const currentRange = selection.getRangeAt(0).cloneRange();
7927
+ const outer = findOuterContainer(currentRange.startContainer);
7928
+ const outerInfo = outer ? getNodeInfo(outer) : null;
7929
+ if (outer && outerInfo?.slotKey && outerInfo.slotConfig?.type !== "content") {
7930
+ currentRange.setStartAfter(outer);
7931
+ currentRange.collapse(true);
7932
+ }
7933
+ return {
7934
+ range: currentRange,
7935
+ selection
7936
+ };
7937
+ }
7938
+ range.selectNodeContents(editable);
7939
+ range.collapse(false);
7940
+ return {
7941
+ range,
7942
+ selection
7943
+ };
7944
+ };
7945
+ const insert = (slotConfig, position = "cursor", replaceCharacters, preventScroll) => {
7946
+ const editable = editableRef.value;
7947
+ if (!editable || !slotConfig.length) return;
7948
+ mergeSlotConfig(slotConfig);
7949
+ const nodes = buildSlotNodes(slotConfig);
7950
+ if (!nodes.length) return;
7951
+ const insertContext = getRangeForInsert(position);
7952
+ if (!insertContext?.range) return;
7953
+ const { range, selection } = insertContext;
7954
+ editable.focus({ preventScroll });
7955
+ if (replaceCharacters) {
7956
+ if ((getSelection()?.toString() ?? "").endsWith(replaceCharacters)) range.setStart(range.startContainer, Math.max(0, range.startOffset - replaceCharacters.length));
7957
+ }
7958
+ range.deleteContents();
7959
+ nodes.forEach((node) => {
7960
+ range.insertNode(node);
7961
+ range.setStartAfter(node);
7962
+ });
7963
+ range.collapse(true);
7964
+ if (selection) {
7965
+ selection.removeAllRanges();
7966
+ selection.addRange(range);
7967
+ }
7968
+ onInternalInput();
7969
+ };
7970
+ const focus = (options) => {
7971
+ const cursor = options?.cursor ?? "end";
7972
+ if (cursor === "start") {
7973
+ setStartCursor(options?.preventScroll);
7974
+ return;
7975
+ }
7976
+ if (cursor === "all") {
7977
+ selectAll(options?.preventScroll);
7978
+ return;
7979
+ }
7980
+ if (cursor === "slot") {
7981
+ focusSlot(options?.key, options?.preventScroll);
7982
+ return;
7983
+ }
7984
+ setEndCursor(options?.preventScroll);
7985
+ };
7986
+ const clear = () => {
7987
+ clearEditor();
7988
+ renderSkill();
7989
+ onInternalInput();
7990
+ };
7991
+ expose({
7992
+ get nativeElement() {
7993
+ return editableRef.value ?? null;
7994
+ },
7995
+ focus,
7996
+ blur() {
7997
+ editableRef.value?.blur();
7998
+ },
7999
+ insert,
8000
+ clear,
8001
+ getValue: getEditorValue
8002
+ });
8003
+ const applySlotConfig = (configs, force = false) => {
8004
+ if (!force && configs === lastSlotConfigRef.value) return;
8005
+ lastSlotConfigRef.value = configs;
8006
+ initFromSlotConfig(configs);
8007
+ };
8008
+ watch(() => editableRef.value, (editable) => {
8009
+ if (!editable) return;
8010
+ applySlotConfig(senderCtx.value.slotConfig, true);
8011
+ }, { immediate: true });
8012
+ watch(() => senderCtx.value.slotConfig, (configs) => {
8013
+ applySlotConfig(configs);
8014
+ }, { immediate: true });
8015
+ watch(() => senderCtx.value.skill, (skill) => {
8016
+ if (skill === lastSkillRef.value && skillDomRef.value) return;
8017
+ lastSkillRef.value = skill;
8018
+ renderSkill();
8019
+ nextTick(() => {
8020
+ triggerValueChange();
8021
+ });
8022
+ }, { immediate: true });
8023
+ watch(() => senderCtx.value.readOnly, (readOnly) => {
8024
+ slotConfigMap.value.forEach((config, key) => {
8025
+ if (config.type === "content") slotDomMap.value.get(key)?.setAttribute("contenteditable", readOnly ? "false" : "true");
8026
+ });
8027
+ });
8028
+ onBeforeUnmount(() => {
8029
+ unmountAllPortals();
8030
+ });
8031
+ return () => {
8032
+ const inputCls = `${prefixCls.value}-input`;
8033
+ return createVNode("div", {
8034
+ "ref": editableRef,
8035
+ "role": "textbox",
8036
+ "tabindex": 0,
8037
+ "class": classNames([
8038
+ inputCls,
8039
+ `${inputCls}-slot`,
8040
+ senderCtx.value.classNames?.input
8041
+ ]),
8042
+ "style": mergeInputStyle.value,
8043
+ "data-placeholder": senderCtx.value.placeholder,
8044
+ "contenteditable": !senderCtx.value.readOnly,
8045
+ "spellcheck": false,
8046
+ "onInput": onInternalInput,
8047
+ "onKeydown": onInternalKeyDown,
8048
+ "onKeyup": onInternalKeyUp,
8049
+ "onPaste": onInternalPaste,
8050
+ "onCut": onInternalInput,
8051
+ "onSelect": onInternalSelect,
8052
+ "onFocus": (e) => {
8053
+ senderCtx.value.onFocus?.(e);
8054
+ },
8055
+ "onBlur": (e) => {
8056
+ keyLock.value = false;
8057
+ senderCtx.value.onBlur?.(e);
8058
+ },
8059
+ "onCompositionstart": () => {
8060
+ isComposing.value = true;
8061
+ },
8062
+ "onCompositionend": () => {
8063
+ isComposing.value = false;
8064
+ keyLock.value = false;
8065
+ }
8066
+ }, null);
8067
+ };
8068
+ }
8069
+ });
8070
+ //#endregion
7180
8071
  //#region components/sender/components/SpeechButton/RecordingIcon.tsx
7181
8072
  var SIZE = 1e3;
7182
8073
  var COUNT = 4;
@@ -7253,15 +8144,6 @@ var SpeechButton_default = /* @__PURE__ */ defineComponent({
7253
8144
  }
7254
8145
  });
7255
8146
  //#endregion
7256
- //#region components/sender/context.ts
7257
- var SenderContextKey = Symbol("sender-context");
7258
- function useSenderContext() {
7259
- return inject(SenderContextKey, computed(() => ({})));
7260
- }
7261
- function provideSenderContext(value) {
7262
- provide(SenderContextKey, value);
7263
- }
7264
- //#endregion
7265
8147
  //#region components/sender/components/TextArea.tsx
7266
8148
  var TextArea_default = /* @__PURE__ */ defineComponent({
7267
8149
  name: "SenderTextArea",
@@ -7472,6 +8354,191 @@ var genSenderHeaderStyle = (token) => {
7472
8354
  } };
7473
8355
  };
7474
8356
  //#endregion
8357
+ //#region components/sender/style/slot-textarea.ts
8358
+ var genSlotTextAreaStyle = (token) => {
8359
+ const { componentCls, antCls, calc } = token;
8360
+ const slotCls = `${componentCls}-slot`;
8361
+ const antInputCls = `${antCls}-input`;
8362
+ const antDropdownCls = `${antCls}-dropdown-trigger`;
8363
+ const slotInputCls = `${componentCls}-slot-input`;
8364
+ const slotSelectCls = `${componentCls}-slot-select`;
8365
+ const slotTagCls = `${componentCls}-slot-tag`;
8366
+ const slotContentCls = `${componentCls}-slot-content`;
8367
+ const skillCls = `${componentCls}-skill`;
8368
+ return { [componentCls]: {
8369
+ [`${componentCls}-input-slot`]: {
8370
+ outline: "none",
8371
+ cursor: "text",
8372
+ whiteSpace: "pre-wrap",
8373
+ width: "100%",
8374
+ caretColor: token.colorPrimary,
8375
+ fontSize: token.fontSize,
8376
+ lineHeight: token.lineHeight,
8377
+ [`&:empty::before`]: {
8378
+ content: "attr(data-placeholder)",
8379
+ color: token.colorTextPlaceholder
8380
+ }
8381
+ },
8382
+ [`${slotCls}:not(${slotContentCls})`]: {
8383
+ display: "inline-block",
8384
+ verticalAlign: "middle",
8385
+ alignItems: "center",
8386
+ marginBlock: 1,
8387
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
8388
+ wordBreak: "break-all",
8389
+ marginInline: token.marginXXS
8390
+ },
8391
+ [`${antInputCls}${slotInputCls}`]: {
8392
+ height: "100%",
8393
+ background: token.colorBgSlot,
8394
+ outline: "none",
8395
+ color: token.colorTextSlot,
8396
+ borderRadius: token.borderRadius,
8397
+ paddingInline: token.paddingXXS,
8398
+ fontSize: "inherit",
8399
+ lineHeight: "inherit",
8400
+ position: "relative",
8401
+ [`&::placeholder`]: {
8402
+ color: token.colorTextSlotPlaceholder,
8403
+ fontSize: "inherit",
8404
+ lineHeight: "inherit"
8405
+ }
8406
+ },
8407
+ [slotSelectCls]: {
8408
+ fontSize: token.fontSize,
8409
+ lineHeight: token.lineHeight,
8410
+ paddingInline: token.paddingXXS,
8411
+ transition: `border-color ${token.motionDurationMid}`,
8412
+ position: "relative",
8413
+ display: "inline-flex",
8414
+ alignItems: "center",
8415
+ cursor: "pointer",
8416
+ background: token.colorBgSlot,
8417
+ height: "100%",
8418
+ boxSizing: "border-box",
8419
+ borderRadius: token.borderRadius,
8420
+ color: token.colorTextSlot,
8421
+ border: `1px solid ${token.colorBorderSlot}`,
8422
+ [`&.placeholder`]: { color: token.colorTextSlotPlaceholder },
8423
+ [`&${antDropdownCls}-open`]: { borderColor: token.colorBorderSlotHover }
8424
+ },
8425
+ [`${slotSelectCls}-value`]: {
8426
+ flex: 1,
8427
+ fontSize: token.fontSize,
8428
+ lineHeight: token.lineHeight,
8429
+ [`&:empty::before`]: { content: "attr(data-placeholder)" }
8430
+ },
8431
+ [`${slotSelectCls}-arrow`]: {
8432
+ marginInlineStart: token.marginXXS,
8433
+ fontSize: token.fontSize,
8434
+ lineHeight: token.lineHeight,
8435
+ display: "inline-flex",
8436
+ alignItems: "center",
8437
+ justifyContent: "center"
8438
+ },
8439
+ [slotTagCls]: {
8440
+ background: token.colorBgSlot,
8441
+ border: `1px solid ${token.colorBorderSlot}`,
8442
+ outline: "none",
8443
+ color: token.colorTextSlot,
8444
+ borderRadius: token.borderRadius,
8445
+ padding: `0 ${unit(token.paddingXXS)}`,
8446
+ fontSize: token.fontSize,
8447
+ lineHeight: token.lineHeight,
8448
+ height: "100%",
8449
+ boxSizing: "border-box",
8450
+ position: "relative",
8451
+ cursor: "default"
8452
+ },
8453
+ [slotContentCls]: {
8454
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
8455
+ caretColor: token.colorPrimary,
8456
+ background: token.colorBgSlot,
8457
+ outline: "none",
8458
+ color: token.colorTextSlot,
8459
+ borderRadius: token.borderRadius,
8460
+ paddingInline: token.paddingXXS,
8461
+ boxSizing: "border-box",
8462
+ verticalAlign: "middle",
8463
+ fontSize: token.fontSize,
8464
+ marginBlock: 1,
8465
+ lineHeight: token.lineHeight,
8466
+ display: "inline-block",
8467
+ position: "relative",
8468
+ cursor: "text",
8469
+ [`&:empty`]: {
8470
+ width: "fit-content",
8471
+ [`&::after`]: {
8472
+ display: "inline-block",
8473
+ height: "inherit",
8474
+ content: "attr(data-placeholder)",
8475
+ color: token.colorTextSlotPlaceholder
8476
+ }
8477
+ }
8478
+ },
8479
+ [`${slotCls}-no-width`]: {
8480
+ userSelect: "none",
8481
+ width: "3px",
8482
+ display: "inline-block",
8483
+ lineHeight: "inherit"
8484
+ },
8485
+ [skillCls]: {
8486
+ display: "inline-block",
8487
+ verticalAlign: "baseline",
8488
+ alignItems: "center",
8489
+ marginBlock: 1,
8490
+ height: calc(token.fontSize).mul(token.lineHeight).add(2).equal(),
8491
+ wordBreak: "break-all",
8492
+ paddingInlineEnd: 0,
8493
+ paddingInlineStart: 0,
8494
+ marginInlineEnd: 0,
8495
+ marginInlineStart: -1,
8496
+ [`&${skillCls}-empty`]: { [`&::after`]: {
8497
+ display: "inline-block",
8498
+ pointerEvents: "none",
8499
+ height: "inherit",
8500
+ content: "attr(data-placeholder)",
8501
+ color: token.colorTextPlaceholder
8502
+ } }
8503
+ },
8504
+ [`${skillCls}-wrapper`]: {
8505
+ height: "100%",
8506
+ display: "inline-flex"
8507
+ },
8508
+ [`${skillCls}-tag`]: {
8509
+ paddingInline: token.paddingXS,
8510
+ height: "100%",
8511
+ backgroundColor: token.colorBgSkill,
8512
+ borderRadius: token.borderRadius,
8513
+ color: token.colorPrimary,
8514
+ alignItems: "center",
8515
+ fontWeight: 500,
8516
+ display: "inline-flex",
8517
+ cursor: "pointer",
8518
+ gap: token.marginXXS,
8519
+ transition: `background-color ${token.motionDurationMid}`,
8520
+ [`&:hover`]: {
8521
+ backgroundColor: token.colorBgSkillHover,
8522
+ [`${skillCls}-close:not(${skillCls}-close-disabled)`]: { color: token.colorPrimaryHover }
8523
+ }
8524
+ },
8525
+ [`${skillCls}-close`]: {
8526
+ fontSize: token.fontSizeSM,
8527
+ display: "inline-flex",
8528
+ transition: `color ${token.motionDurationMid}`,
8529
+ color: token.colorPrimary
8530
+ },
8531
+ [`${skillCls}-close-disabled`]: {
8532
+ cursor: "not-allowed",
8533
+ color: token.colorTextDisabled
8534
+ },
8535
+ [`${skillCls}-holder`]: {
8536
+ width: token.marginXS,
8537
+ height: "100%"
8538
+ }
8539
+ } };
8540
+ };
8541
+ //#endregion
7475
8542
  //#region components/sender/style/switch.ts
7476
8543
  var genSenderSwitchStyle = (token) => {
7477
8544
  const { componentCls, antCls } = token;
@@ -7579,12 +8646,26 @@ var genSenderStyle = (token) => {
7579
8646
  };
7580
8647
  var prepareComponentToken$5 = (token) => {
7581
8648
  const { colorPrimary, colorFillTertiary } = token;
8649
+ const colorBgSlot = new FastColor(colorPrimary).setA(.06).toRgbString();
8650
+ const colorBgSkill = new FastColor(colorPrimary).setA(.08).toRgbString();
8651
+ const colorBgSkillHover = new FastColor(colorPrimary).setA(.15).toRgbString();
8652
+ const colorTextSlot = colorPrimary;
8653
+ const colorTextSlotPlaceholder = new FastColor(colorPrimary).setA(.25).toRgbString();
8654
+ const colorBorderSlotHover = new FastColor(colorPrimary).setA(.1).toRgbString();
8655
+ const colorBorderSlot = colorBgSlot;
7582
8656
  const colorBorderInput = new FastColor(colorFillTertiary).setA(.1).toRgbString();
7583
8657
  const switchCheckedBg = new FastColor(colorPrimary).setA(.08).toRgbString();
7584
8658
  const switchCheckedHoverBg = new FastColor(colorPrimary).setA(.1).toRgbString();
7585
8659
  const switchUncheckedHoverBg = new FastColor(colorFillTertiary).setA(.04).toRgbString();
7586
8660
  const colorBgActionsDisabled = new FastColor(colorPrimary).setA(.45).toRgbString();
7587
8661
  return {
8662
+ colorBgSlot,
8663
+ colorBgSkill,
8664
+ colorBgSkillHover,
8665
+ colorTextSlot,
8666
+ colorTextSlotPlaceholder,
8667
+ colorBorderSlotHover,
8668
+ colorBorderSlot,
7588
8669
  colorBorderInput,
7589
8670
  switchCheckedBg,
7590
8671
  switchCheckedHoverBg,
@@ -7599,7 +8680,8 @@ var style_default$5 = genStyleHooks("Sender", (token) => {
7599
8680
  return [
7600
8681
  genSenderStyle(senderToken),
7601
8682
  genSenderHeaderStyle(senderToken),
7602
- genSenderSwitchStyle(senderToken)
8683
+ genSenderSwitchStyle(senderToken),
8684
+ genSlotTextAreaStyle(senderToken)
7603
8685
  ];
7604
8686
  }, prepareComponentToken$5);
7605
8687
  //#endregion
@@ -7611,7 +8693,7 @@ var sharedRenderComponents = {
7611
8693
  SpeechButton: SpeechButton_default
7612
8694
  };
7613
8695
  var Sender_default = /* @__PURE__ */ defineComponent({
7614
- name: "XSender",
8696
+ name: "AxSender",
7615
8697
  inheritAttrs: false,
7616
8698
  props: {
7617
8699
  prefixCls: {
@@ -7658,6 +8740,14 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7658
8740
  type: Boolean,
7659
8741
  default: false
7660
8742
  },
8743
+ slotConfig: {
8744
+ type: Array,
8745
+ default: void 0
8746
+ },
8747
+ skill: {
8748
+ type: Object,
8749
+ default: void 0
8750
+ },
7661
8751
  placeholder: {
7662
8752
  type: String,
7663
8753
  default: void 0
@@ -7756,21 +8846,40 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7756
8846
  const [hashId, cssVarCls] = style_default$5(prefixCls);
7757
8847
  const containerRef = ref();
7758
8848
  const inputRef = ref();
8849
+ const isSlotMode = computed(() => Array.isArray(props.slotConfig) || !!props.skill?.value);
7759
8850
  const innerValue = ref(props.defaultValue);
7760
8851
  const mergedValue = computed(() => props.value ?? innerValue.value);
7761
- const triggerValueChange = (nextValue, event) => {
8852
+ const triggerValueChange = (nextValue, event, slotConfig, skill) => {
7762
8853
  innerValue.value = nextValue;
7763
- props.onChange?.(nextValue, event);
8854
+ props.onChange?.(nextValue, event, slotConfig, skill);
7764
8855
  };
8856
+ const submitDisabled = ref(!mergedValue.value);
8857
+ watch(() => mergedValue.value, (next) => {
8858
+ if (!isSlotMode.value) submitDisabled.value = !next;
8859
+ }, { immediate: true });
7765
8860
  const [speechPermission, triggerSpeech, speechRecording] = useSpeech((transcript) => {
8861
+ if (isSlotMode.value) {
8862
+ inputRef.value?.insert?.([{
8863
+ type: "text",
8864
+ value: transcript
8865
+ }]);
8866
+ return;
8867
+ }
7766
8868
  triggerValueChange(`${mergedValue.value} ${transcript}`);
7767
8869
  }, () => props.allowSpeech);
7768
8870
  const triggerSend = () => {
7769
- if (props.onSubmit && !props.loading && mergedValue.value) props.onSubmit(mergedValue.value);
8871
+ if (!props.onSubmit || props.loading || submitDisabled.value) return;
8872
+ const value = inputRef.value?.getValue?.() ?? { value: "" };
8873
+ const slotConfig = "slotConfig" in value ? value.slotConfig : void 0;
8874
+ const skill = "skill" in value ? value.skill : void 0;
8875
+ props.onSubmit(value.value, slotConfig, skill);
7770
8876
  };
7771
8877
  const triggerClear = () => {
8878
+ if (inputRef.value?.clear) {
8879
+ inputRef.value.clear();
8880
+ return;
8881
+ }
7772
8882
  triggerValueChange("");
7773
- inputRef.value?.clear();
7774
8883
  };
7775
8884
  expose({
7776
8885
  get nativeElement() {
@@ -7786,7 +8895,19 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7786
8895
  triggerClear();
7787
8896
  },
7788
8897
  insert(text, position) {
7789
- inputRef.value?.insert(text, position);
8898
+ if (isSlotMode.value) {
8899
+ const slotList = Array.isArray(text) ? text : [{
8900
+ type: "text",
8901
+ value: text
8902
+ }];
8903
+ inputRef.value?.insert?.(slotList, position);
8904
+ return;
8905
+ }
8906
+ const textValue = Array.isArray(text) ? text.map((config) => {
8907
+ if (config.type === "text") return config.value ?? "";
8908
+ return config.formatResult?.(config.props?.defaultValue) ?? "";
8909
+ }).join("") : text;
8910
+ inputRef.value?.insert?.(textValue, position);
7790
8911
  },
7791
8912
  getValue() {
7792
8913
  return inputRef.value?.getValue() ?? { value: "" };
@@ -7809,15 +8930,20 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7809
8930
  triggerSend,
7810
8931
  placeholder: props.placeholder,
7811
8932
  onFocus: props.onFocus,
7812
- onBlur: props.onBlur
8933
+ onBlur: props.onBlur,
8934
+ slotConfig: props.slotConfig,
8935
+ skill: props.skill,
8936
+ setSubmitDisabled: (disabled) => {
8937
+ submitDisabled.value = disabled;
8938
+ }
7813
8939
  })));
7814
8940
  const actionBtnCls = computed(() => `${prefixCls.value}-actions-btn`);
7815
8941
  provideActionButtonContext(computed(() => ({
7816
8942
  prefixCls: actionBtnCls.value,
7817
8943
  onSend: triggerSend,
7818
- onSendDisabled: !mergedValue.value,
8944
+ onSendDisabled: submitDisabled.value,
7819
8945
  onClear: triggerClear,
7820
- onClearDisabled: !mergedValue.value,
8946
+ onClearDisabled: submitDisabled.value,
7821
8947
  onCancel: props.onCancel,
7822
8948
  onCancelDisabled: !props.loading,
7823
8949
  onSpeech: () => triggerSpeech(false),
@@ -7870,8 +8996,9 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7870
8996
  "class": [`${cls}-content`, props.classNames.content],
7871
8997
  "style": props.styles.content,
7872
8998
  "onMousedown": (e) => {
7873
- if (e.target !== containerRef.value?.querySelector(`.${cls}-input`)) e.preventDefault();
7874
- inputRef.value?.focus();
8999
+ const inputNode = containerRef.value?.querySelector(`.${cls}-input`);
9000
+ if (!isSlotMode.value && e.target !== inputNode) e.preventDefault();
9001
+ if (e.target === inputNode || e.target === containerRef.value) inputRef.value?.focus();
7875
9002
  }
7876
9003
  }, [
7877
9004
  prefixNode && createVNode("div", {
@@ -7882,7 +9009,7 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7882
9009
  ],
7883
9010
  "style": [contextConfig.value.styles?.prefix, props.styles.prefix]
7884
9011
  }, [prefixNode]),
7885
- createVNode(TextArea_default, { "ref": inputRef }, null),
9012
+ isSlotMode.value ? createVNode(SlotTextArea_default, { "ref": inputRef }, null) : createVNode(TextArea_default, { "ref": inputRef }, null),
7886
9013
  suffixNode && createVNode("div", {
7887
9014
  "class": [
7888
9015
  actionListCls,
@@ -7907,7 +9034,7 @@ var Sender_default = /* @__PURE__ */ defineComponent({
7907
9034
  //#endregion
7908
9035
  //#region components/sender/SenderHeader.tsx
7909
9036
  var SenderHeader_default = /* @__PURE__ */ defineComponent({
7910
- name: "XSenderHeader",
9037
+ name: "AxSenderHeader",
7911
9038
  props: {
7912
9039
  open: {
7913
9040
  type: Boolean,
@@ -8011,7 +9138,7 @@ var SenderHeader_default = /* @__PURE__ */ defineComponent({
8011
9138
  //#endregion
8012
9139
  //#region components/sender/SenderSwitch.tsx
8013
9140
  var SenderSwitch_default = /* @__PURE__ */ defineComponent({
8014
- name: "XSenderSwitch",
9141
+ name: "AxSenderSwitch",
8015
9142
  inheritAttrs: false,
8016
9143
  props: {
8017
9144
  prefixCls: {
@@ -8127,7 +9254,7 @@ var SenderSwitch_default = /* @__PURE__ */ defineComponent({
8127
9254
  "class": [`${cls}-content`, props.classNames.content],
8128
9255
  "style": props.styles.content
8129
9256
  }, {
8130
- classNames: {
9257
+ classes: {
8131
9258
  icon: props.classNames.icon,
8132
9259
  content: props.classNames.title
8133
9260
  },
@@ -8382,7 +9509,7 @@ var hasRenderableNode$3 = (node) => {
8382
9509
  //#endregion
8383
9510
  //#region components/sources/index.tsx
8384
9511
  var sources_default = /* @__PURE__ */ defineComponent({
8385
- name: "XSources",
9512
+ name: "AxSources",
8386
9513
  inheritAttrs: false,
8387
9514
  props: {
8388
9515
  prefixCls: {
@@ -8647,20 +9774,24 @@ function useActive(items, open, rtl, onCancel) {
8647
9774
  case "ArrowDown":
8648
9775
  offsetRow(1);
8649
9776
  event.preventDefault();
9777
+ event.stopPropagation();
8650
9778
  break;
8651
9779
  case "ArrowUp":
8652
9780
  offsetRow(-1);
8653
9781
  event.preventDefault();
9782
+ event.stopPropagation();
8654
9783
  break;
8655
9784
  case "ArrowRight":
8656
9785
  if (rtl.value) offsetPrev();
8657
9786
  else offsetNext();
8658
9787
  event.preventDefault();
9788
+ event.stopPropagation();
8659
9789
  break;
8660
9790
  case "ArrowLeft":
8661
9791
  if (rtl.value) offsetNext();
8662
9792
  else offsetPrev();
8663
9793
  event.preventDefault();
9794
+ event.stopPropagation();
8664
9795
  break;
8665
9796
  case "Enter":
8666
9797
  event.preventDefault();
@@ -8686,7 +9817,7 @@ var hasRenderableNode$2 = (node) => {
8686
9817
  //#endregion
8687
9818
  //#region components/suggestion/index.tsx
8688
9819
  var suggestion_default = /* @__PURE__ */ defineComponent({
8689
- name: "XSuggestion",
9820
+ name: "AxSuggestion",
8690
9821
  inheritAttrs: false,
8691
9822
  props: {
8692
9823
  prefixCls: {
@@ -8964,7 +10095,7 @@ var style_default$2 = genStyleHooks("Think", (token) => {
8964
10095
  //#endregion
8965
10096
  //#region components/think/index.tsx
8966
10097
  var think_default = /* @__PURE__ */ defineComponent({
8967
- name: "XThink",
10098
+ name: "AxThink",
8968
10099
  inheritAttrs: false,
8969
10100
  props: {
8970
10101
  prefixCls: {
@@ -9374,7 +10505,7 @@ function hasRenderableNode$1(node) {
9374
10505
  return node !== null && node !== void 0 && node !== false;
9375
10506
  }
9376
10507
  var XThoughtChainItem = /* @__PURE__ */ defineComponent({
9377
- name: "XThoughtChainItem",
10508
+ name: "AxThoughtChainItem",
9378
10509
  props: {
9379
10510
  prefixCls: {
9380
10511
  type: String,
@@ -9704,7 +10835,7 @@ var Node_default = /* @__PURE__ */ defineComponent({
9704
10835
  //#endregion
9705
10836
  //#region components/thought-chain/index.tsx
9706
10837
  var ThoughtChainWithSub = /* @__PURE__ */ defineComponent({
9707
- name: "XThoughtChain",
10838
+ name: "AxThoughtChain",
9708
10839
  inheritAttrs: false,
9709
10840
  props: {
9710
10841
  prefixCls: {
@@ -9922,7 +11053,7 @@ function hasContent(value) {
9922
11053
  return Array.isArray(value) ? value.length > 0 : value !== null && value !== void 0;
9923
11054
  }
9924
11055
  var XWelcome = /* @__PURE__ */ defineComponent({
9925
- name: "XWelcome",
11056
+ name: "AxWelcome",
9926
11057
  inheritAttrs: false,
9927
11058
  props: {
9928
11059
  prefixCls: {
@@ -10087,7 +11218,7 @@ var XWelcome = /* @__PURE__ */ defineComponent({
10087
11218
  //#endregion
10088
11219
  //#region components/x-provider/index.tsx
10089
11220
  var XProvider = /* @__PURE__ */ defineComponent({
10090
- name: "XProvider",
11221
+ name: "AxProvider",
10091
11222
  inheritAttrs: false,
10092
11223
  props: {
10093
11224
  attachments: {
@@ -10192,36 +11323,11 @@ var components = [
10192
11323
  ThoughtChainWithSub,
10193
11324
  XThoughtChainItem
10194
11325
  ];
10195
- var componentAliases = new Map([
10196
- ["XBubble", ["ABubble"]],
10197
- ["XBubbleList", ["ABubbleList"]],
10198
- ["XBubbleSystem", ["ABubbleSystem"]],
10199
- ["XBubbleDivider", ["ABubbleDivider"]],
10200
- ["XActions", ["AActions"]],
10201
- ["XActionsAudio", ["AActionsAudio"]],
10202
- ["XActionsCopy", ["AActionsCopy"]],
10203
- ["XActionsFeedback", ["AActionsFeedback"]],
10204
- ["XActionsItem", ["AActionsItem"]],
10205
- ["XFileCard", ["AFileCard"]],
10206
- ["XFileCardList", ["AFileCardList"]],
10207
- ["XMermaid", ["AMermaid"]],
10208
- ["XAttachments", ["AAttachments"]],
10209
- ["XSender", ["ASender"]],
10210
- ["XSenderHeader", ["ASenderHeader"]],
10211
- ["XSenderSwitch", ["ASenderSwitch"]],
10212
- ["XSuggestion", ["ASuggestion"]],
10213
- ["XThink", ["AThink"]],
10214
- ["XThoughtChain", ["AThoughtChain"]],
10215
- ["XThoughtChainItem", ["AThoughtChainItem"]]
10216
- ]);
10217
11326
  var components_default = {
10218
11327
  install(app) {
10219
11328
  components.forEach((component) => {
10220
11329
  if (!component.name) return;
10221
11330
  app.component(component.name, component);
10222
- componentAliases.get(component.name)?.forEach((alias) => {
10223
- app.component(alias, component);
10224
- });
10225
11331
  });
10226
11332
  },
10227
11333
  version