@fv-ui/ai-chat 0.11.0 → 0.12.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.
package/es/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, computed, openBlock, createElementBlock, ref, watch, onBeforeUnmount, normalizeClass, createCommentVNode, createBlock, createTextVNode, toDisplayString, normalizeStyle, renderSlot, unref, createElementVNode, Fragment, renderList, createVNode, isRef, nextTick, onMounted, mergeProps, createSlots, withCtx, Transition, getCurrentInstance, useSlots, normalizeProps, guardReactiveProps, reactive, resolveDynamicComponent, markRaw, withModifiers } from 'vue';
1
+ import { shallowRef, inject, computed, provide, defineComponent, openBlock, createElementBlock, ref, watch, onBeforeUnmount, normalizeClass, createCommentVNode, createBlock, createTextVNode, toDisplayString, normalizeStyle, renderSlot, unref, createElementVNode, Fragment, renderList, createVNode, isRef, nextTick, onMounted, mergeProps, createSlots, withCtx, Transition, getCurrentInstance, useSlots, normalizeProps, guardReactiveProps, reactive, resolveDynamicComponent, markRaw, withModifiers } from 'vue';
2
2
  import MarkdownIt from 'markdown-it';
3
3
  import mdKatex from '@vscode/markdown-it-katex';
4
4
  import DOMPurify from 'dompurify';
@@ -97,8 +97,8 @@ function getPurify() {
97
97
  function renderMarkdown(md, src) {
98
98
  const purify = getPurify();
99
99
  return purify.sanitize(md.render(src), {
100
- ADD_ATTR: ["target", "rel"],
101
- ADD_TAGS: ["semantics", "annotation"]
100
+ ADD_ATTR: ["target", "rel", "data-fv-code-lang", "data-fv-code-trigger", "data-fv-code-index", "type"],
101
+ ADD_TAGS: ["semantics", "annotation", "button"]
102
102
  });
103
103
  }
104
104
 
@@ -1526,6 +1526,249 @@ function prismHighlight(str, lang) {
1526
1526
  }
1527
1527
  }
1528
1528
 
1529
+ const zhCN = {
1530
+ common: {
1531
+ copy: "\u590D\u5236",
1532
+ delete: "\u5220\u9664",
1533
+ confirm: "\u786E\u5B9A",
1534
+ cancel: "\u53D6\u6D88",
1535
+ retry: "\u91CD\u4F20",
1536
+ close: "\u5173\u95ED",
1537
+ preview: "\u9884\u89C8",
1538
+ clear: "\u6E05\u7A7A",
1539
+ stop: "\u505C\u6B62",
1540
+ send: "\u53D1\u9001",
1541
+ download: "\u4E0B\u8F7D",
1542
+ fullscreen: "\u5168\u5C4F",
1543
+ collapse: "\u6536\u8D77",
1544
+ expand: "\u5C55\u5F00"
1545
+ },
1546
+ thinking: {
1547
+ start: "\u5F00\u59CB\u601D\u8003",
1548
+ thinking: "\u601D\u8003\u4E2D...",
1549
+ end: "\u601D\u8003\u5B8C\u6210",
1550
+ error: "\u601D\u8003\u9047\u5230\u95EE\u9898"
1551
+ },
1552
+ sender: {
1553
+ clear: "\u6E05\u7A7A",
1554
+ stop: "\u505C\u6B62",
1555
+ send: "\u53D1\u9001",
1556
+ speech: "\u8BED\u97F3\u8F93\u5165",
1557
+ recordCancel: "\u53D6\u6D88\u5F55\u97F3",
1558
+ recordConfirm: "\u786E\u8BA4\u5F55\u97F3",
1559
+ micUnavailable: "\u65E0\u6CD5\u8BBF\u95EE\u9EA6\u514B\u98CE"
1560
+ },
1561
+ editorSender: {
1562
+ clear: "\u6E05\u7A7A",
1563
+ stop: "\u505C\u6B62",
1564
+ send: "\u53D1\u9001",
1565
+ inputPlaceholder: "\u8BF7\u8F93\u5165",
1566
+ selectTagTitle: "\u9009\u62E9\u6807\u7B7E",
1567
+ loading: "\u52A0\u8F7D\u4E2D\u2026",
1568
+ tagTip: "\u586B\u5199\u5185\u5BB9\u540E\u56DE\u8F66\u786E\u8BA4"
1569
+ },
1570
+ attachments: {
1571
+ add: "\u6DFB\u52A0\u9644\u4EF6",
1572
+ retry: "\u91CD\u4F20"
1573
+ },
1574
+ filesCard: {
1575
+ remove: "\u5220\u9664"
1576
+ },
1577
+ conversations: {
1578
+ menuLabel: "\u4F1A\u8BDD\u64CD\u4F5C",
1579
+ rename: "\u91CD\u547D\u540D",
1580
+ delete: "\u5220\u9664",
1581
+ renameTitle: "\u91CD\u547D\u540D\u4F1A\u8BDD",
1582
+ renamePrompt: "\u8BF7\u8F93\u5165\u65B0\u7684\u4F1A\u8BDD\u540D\u79F0",
1583
+ renamePlaceholder: "\u8BF7\u8F93\u5165\u540D\u79F0",
1584
+ deleteTitle: "\u5220\u9664\u4F1A\u8BDD",
1585
+ deleteConfirm: "\u786E\u5B9A\u5220\u9664\u4F1A\u8BDD\u300C{label}\u300D\u5417?\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002"
1586
+ },
1587
+ scroll: {
1588
+ toBottom: "\u6EDA\u52A8\u5230\u5E95\u90E8"
1589
+ },
1590
+ aiChat: {
1591
+ modelPlaceholder: "\u6A21\u578B",
1592
+ adapterMissing: "\u672A\u914D\u7F6E adapter \u6216 baseURL",
1593
+ generateFailed: "\u751F\u6210\u5931\u8D25",
1594
+ exportUser: "\u4F60",
1595
+ exportAssistant: "\u52A9\u624B"
1596
+ },
1597
+ aiMessage: {
1598
+ copy: "\u590D\u5236",
1599
+ regenerate: "\u91CD\u65B0\u751F\u6210",
1600
+ prevBranch: "\u4E0A\u4E00\u5206\u652F",
1601
+ nextBranch: "\u4E0B\u4E00\u5206\u652F",
1602
+ defaultUserName: "\u4F60",
1603
+ defaultAssistantName: "\u5C0F\u7EF4",
1604
+ querying: "\u6B63\u5728\u67E5\u8BE2",
1605
+ queried: "\u5DF2\u67E5\u8BE2",
1606
+ generateFailed: "\u751F\u6210\u5931\u8D25"
1607
+ },
1608
+ aiArtifacts: {
1609
+ copy: "\u590D\u5236",
1610
+ download: "\u4E0B\u8F7D",
1611
+ fullscreen: "\u5168\u5C4F",
1612
+ close: "\u5173\u95ED"
1613
+ },
1614
+ chat: {
1615
+ fileTag: "[\u9644\u4EF6] {name}",
1616
+ fileImageTag: "(\u56FE\u7247)",
1617
+ filesSystemPrompt: "\u7528\u6237\u968F\u6D88\u606F\u63D0\u4F9B\u4E86\u4EE5\u4E0B\u6587\u4EF6:\n{files}",
1618
+ toolDuration: "\u7528\u65F6 {s}",
1619
+ continuePrompt: "\u8BF7\u57FA\u4E8E\u4EE5\u4E0A\u5185\u5BB9\u7EE7\u7EED\u5B8C\u6210\u56DE\u7B54,\u4E0D\u8981\u91CD\u590D\u5DF2\u6709\u5185\u5BB9\u3002"
1620
+ },
1621
+ errors: {
1622
+ requestFailed: "\u8BF7\u6C42\u5931\u8D25",
1623
+ sessionIdMissing: "\u7F3A\u5C11 sessionId(\u4F1A\u8BDD\u672A\u521B\u5EFA\u6216\u672A\u9009\u4E2D)",
1624
+ noBody: "\u54CD\u5E94\u65E0 body",
1625
+ generateFailed: "\u751F\u6210\u5931\u8D25",
1626
+ recordUnsupported: "\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u97F3\u9891\u5F55\u5236",
1627
+ speechError: "\u8BED\u97F3\u8BC6\u522B\u9519\u8BEF: {error}"
1628
+ }
1629
+ };
1630
+
1631
+ const enUS = {
1632
+ common: {
1633
+ copy: "Copy",
1634
+ delete: "Delete",
1635
+ confirm: "OK",
1636
+ cancel: "Cancel",
1637
+ retry: "Retry",
1638
+ close: "Close",
1639
+ preview: "Preview",
1640
+ clear: "Clear",
1641
+ stop: "Stop",
1642
+ send: "Send",
1643
+ download: "Download",
1644
+ fullscreen: "Fullscreen",
1645
+ collapse: "Collapse",
1646
+ expand: "Expand"
1647
+ },
1648
+ thinking: {
1649
+ start: "Thinking",
1650
+ thinking: "Thinking...",
1651
+ end: "Thought complete",
1652
+ error: "Something went wrong"
1653
+ },
1654
+ sender: {
1655
+ clear: "Clear",
1656
+ stop: "Stop",
1657
+ send: "Send",
1658
+ speech: "Voice input",
1659
+ recordCancel: "Cancel recording",
1660
+ recordConfirm: "Confirm recording",
1661
+ micUnavailable: "Microphone unavailable"
1662
+ },
1663
+ editorSender: {
1664
+ clear: "Clear",
1665
+ stop: "Stop",
1666
+ send: "Send",
1667
+ inputPlaceholder: "Type something...",
1668
+ selectTagTitle: "Select a tag",
1669
+ loading: "Loading...",
1670
+ tagTip: "Type and press Enter to confirm"
1671
+ },
1672
+ attachments: {
1673
+ add: "Add attachment",
1674
+ retry: "Retry"
1675
+ },
1676
+ filesCard: {
1677
+ remove: "Remove"
1678
+ },
1679
+ conversations: {
1680
+ menuLabel: "Conversation actions",
1681
+ rename: "Rename",
1682
+ delete: "Delete",
1683
+ renameTitle: "Rename conversation",
1684
+ renamePrompt: "Enter a new conversation name",
1685
+ renamePlaceholder: "Enter a name",
1686
+ deleteTitle: "Delete conversation",
1687
+ deleteConfirm: 'Delete "{label}"? This cannot be undone.'
1688
+ },
1689
+ scroll: {
1690
+ toBottom: "Scroll to bottom"
1691
+ },
1692
+ aiChat: {
1693
+ modelPlaceholder: "Model",
1694
+ adapterMissing: "Neither adapter nor baseURL is configured",
1695
+ generateFailed: "Generation failed",
1696
+ exportUser: "You",
1697
+ exportAssistant: "Assistant"
1698
+ },
1699
+ aiMessage: {
1700
+ copy: "Copy",
1701
+ regenerate: "Regenerate",
1702
+ prevBranch: "Previous branch",
1703
+ nextBranch: "Next branch",
1704
+ defaultUserName: "You",
1705
+ defaultAssistantName: "Assistant",
1706
+ querying: "Querying ",
1707
+ queried: "Queried ",
1708
+ generateFailed: "Generation failed"
1709
+ },
1710
+ aiArtifacts: {
1711
+ copy: "Copy",
1712
+ download: "Download",
1713
+ fullscreen: "Fullscreen",
1714
+ close: "Close"
1715
+ },
1716
+ chat: {
1717
+ fileTag: "[File] {name}",
1718
+ fileImageTag: " (image)",
1719
+ filesSystemPrompt: "The user provided the following files with the message:\n{files}",
1720
+ toolDuration: "Took {s}",
1721
+ continuePrompt: "Continue completing the answer based on the above content. Do not repeat existing content."
1722
+ },
1723
+ errors: {
1724
+ requestFailed: "Request failed",
1725
+ sessionIdMissing: "sessionId is missing (session not created or selected)",
1726
+ noBody: "Response has no body",
1727
+ generateFailed: "Generation failed",
1728
+ recordUnsupported: "Audio recording is not supported in this environment",
1729
+ speechError: "Speech recognition error: {error}"
1730
+ }
1731
+ };
1732
+
1733
+ let current = zhCN;
1734
+ function getGlobalLocale() {
1735
+ return current;
1736
+ }
1737
+ function setGlobalLocale(m) {
1738
+ current = m;
1739
+ }
1740
+
1741
+ const PACKS = { "zh-CN": zhCN, "en-US": enUS };
1742
+ const tick = shallowRef(0);
1743
+ function configureLocale(locale) {
1744
+ setGlobalLocale(typeof locale === "string" ? PACKS[locale] ?? zhCN : locale);
1745
+ tick.value++;
1746
+ }
1747
+ const LOCALE_KEY = Symbol("fv-locale");
1748
+ function provideLocale(dict) {
1749
+ provide(LOCALE_KEY, dict);
1750
+ }
1751
+ function deepMerge(base, override) {
1752
+ if (!override) return base;
1753
+ const out = { ...base };
1754
+ for (const [k, v] of Object.entries(override)) {
1755
+ const bv = base[k];
1756
+ out[k] = v && typeof v === "object" && !Array.isArray(v) && bv && typeof bv === "object" && !Array.isArray(bv) ? deepMerge(bv, v) : v;
1757
+ }
1758
+ return out;
1759
+ }
1760
+ function useLocaleDict(getPropLocale) {
1761
+ const injected = inject(LOCALE_KEY, void 0);
1762
+ return computed(() => {
1763
+ void tick.value;
1764
+ const prop = getPropLocale?.();
1765
+ if (typeof prop === "string") return PACKS[prop] ?? injected?.value ?? getGlobalLocale();
1766
+ const base = injected?.value ?? getGlobalLocale();
1767
+ if (prop && typeof prop === "object") return deepMerge(base, prop);
1768
+ return base;
1769
+ });
1770
+ }
1771
+
1529
1772
  const _hoisted_1$i = ["innerHTML"];
1530
1773
  var _sfc_main$i = /* @__PURE__ */ defineComponent({
1531
1774
  ...{ name: "FvMarkdown" },
@@ -1534,13 +1777,27 @@ var _sfc_main$i = /* @__PURE__ */ defineComponent({
1534
1777
  content: { type: String, required: true },
1535
1778
  mdPlugins: { type: Array, required: false },
1536
1779
  highlight: { type: Function, required: false },
1537
- isTyping: { type: Boolean, required: false }
1780
+ isTyping: { type: Boolean, required: false },
1781
+ codeTriggerLangs: { type: Array, required: false },
1782
+ locale: { type: null, required: false }
1538
1783
  },
1539
1784
  setup(__props, { expose: __expose }) {
1540
1785
  const props = __props;
1786
+ const dict = useLocaleDict(() => props.locale);
1541
1787
  const md = computed(
1542
1788
  () => createMarkdownInstance({
1543
- highlight: (str, lang) => props.highlight ? props.highlight(str, lang) : prismHighlight(str, lang),
1789
+ // highlight 包装:命中 codeTriggerLangs 的代码块返回完整 <pre>(markdown-it 约定:
1790
+ // 返回值以 <pre 开头则原样使用),pre 内追加触发按钮;未命中走原高亮输出。
1791
+ // 序号由消费方按 DOM 内出现次序推导(流式重建实例时闭包计数不稳定,不可用)
1792
+ highlight: (str, lang) => {
1793
+ const base = props.highlight ? props.highlight(str, lang) : prismHighlight(str, lang);
1794
+ const l = lang?.toLowerCase();
1795
+ if (l && props.codeTriggerLangs?.includes(l)) {
1796
+ const preview = dict.value.common.preview;
1797
+ return `<pre class="fv-md-code-pre" data-fv-code-lang="${l}"><code class="language-${l}">${base}</code><button type="button" class="fv-md-code-trigger" data-fv-code-trigger="${l}" aria-label="${preview}">${preview}</button></pre>`;
1798
+ }
1799
+ return base;
1800
+ },
1544
1801
  mdPlugins: props.mdPlugins
1545
1802
  })
1546
1803
  );
@@ -1570,7 +1827,9 @@ var _sfc_main$h = /* @__PURE__ */ defineComponent({
1570
1827
  content: { type: String, required: true },
1571
1828
  isMarkdown: { type: Boolean, required: false, default: false },
1572
1829
  isFog: { type: [Boolean, Object], required: false, default: false },
1573
- typing: { type: [Boolean, Object], required: false, default: false }
1830
+ typing: { type: [Boolean, Object], required: false, default: false },
1831
+ codeTriggerLangs: { type: Array, required: false },
1832
+ locale: { type: null, required: false }
1574
1833
  },
1575
1834
  emits: ["start", "finish", "writing"],
1576
1835
  setup(__props, { expose: __expose, emit: __emit }) {
@@ -1658,8 +1917,10 @@ var _sfc_main$h = /* @__PURE__ */ defineComponent({
1658
1917
  __props.isMarkdown ? (openBlock(), createBlock(_sfc_main$i, {
1659
1918
  key: 0,
1660
1919
  content: renderedContent.value,
1661
- "is-typing": isTyping.value
1662
- }, null, 8, ["content", "is-typing"])) : (openBlock(), createElementBlock("span", _hoisted_1$h, [
1920
+ "is-typing": isTyping.value,
1921
+ "code-trigger-langs": __props.codeTriggerLangs,
1922
+ locale: __props.locale
1923
+ }, null, 8, ["content", "is-typing", "code-trigger-langs", "locale"])) : (openBlock(), createElementBlock("span", _hoisted_1$h, [
1663
1924
  createTextVNode(
1664
1925
  toDisplayString(renderedContent.value),
1665
1926
  1
@@ -1703,15 +1964,15 @@ const _hoisted_3$e = {
1703
1964
  key: 0,
1704
1965
  class: "fv-bubble-header"
1705
1966
  };
1706
- const _hoisted_4$d = {
1967
+ const _hoisted_4$c = {
1707
1968
  key: 0,
1708
1969
  class: "fv-bubble-loading"
1709
1970
  };
1710
- const _hoisted_5$8 = {
1971
+ const _hoisted_5$9 = {
1711
1972
  key: 4,
1712
1973
  class: "fv-bubble-text"
1713
1974
  };
1714
- const _hoisted_6$7 = {
1975
+ const _hoisted_6$8 = {
1715
1976
  key: 1,
1716
1977
  class: "fv-bubble-footer"
1717
1978
  };
@@ -1806,7 +2067,7 @@ var _sfc_main$g = /* @__PURE__ */ defineComponent({
1806
2067
  },
1807
2068
  [
1808
2069
  createCommentVNode(" loading \u4F18\u5148:#loading \u63D2\u69FD\u4F18\u5148\u4E8E\u5185\u7F6E\u4E09\u70B9\u52A8\u753B "),
1809
- __props.loading ? (openBlock(), createElementBlock("div", _hoisted_4$d, [
2070
+ __props.loading ? (openBlock(), createElementBlock("div", _hoisted_4$c, [
1810
2071
  _ctx.$slots.loading ? renderSlot(_ctx.$slots, "loading", {}, void 0, void 0, 0) : (openBlock(), createElementBlock(
1811
2072
  Fragment,
1812
2073
  { key: 1 },
@@ -1859,7 +2120,7 @@ var _sfc_main$g = /* @__PURE__ */ defineComponent({
1859
2120
  content: __props.content
1860
2121
  }, null, 8, ["content"])) : (openBlock(), createElementBlock(
1861
2122
  "span",
1862
- _hoisted_5$8,
2123
+ _hoisted_5$9,
1863
2124
  toDisplayString(__props.content),
1864
2125
  1
1865
2126
  /* TEXT */
@@ -1868,7 +2129,7 @@ var _sfc_main$g = /* @__PURE__ */ defineComponent({
1868
2129
  2
1869
2130
  /* CLASS */
1870
2131
  ),
1871
- _ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_6$7, [
2132
+ _ctx.$slots.footer ? (openBlock(), createElementBlock("div", _hoisted_6$8, [
1872
2133
  renderSlot(_ctx.$slots, "footer")
1873
2134
  ])) : createCommentVNode("v-if", true)
1874
2135
  ])
@@ -1894,11 +2155,13 @@ var _sfc_main$f = /* @__PURE__ */ defineComponent({
1894
2155
  btnColor: { type: String, required: false, default: "" },
1895
2156
  backButtonPosition: { type: Object, required: false, default: () => ({}) },
1896
2157
  btnIconSize: { type: Number, required: false, default: 16 },
1897
- triggerIndices: { type: [String, Array], required: false, default: "only-last" }
2158
+ triggerIndices: { type: [String, Array], required: false, default: "only-last" },
2159
+ locale: { type: null, required: false, default: void 0 }
1898
2160
  },
1899
2161
  emits: ["complete"],
1900
2162
  setup(__props, { expose: __expose, emit: __emit }) {
1901
2163
  const props = __props;
2164
+ const dict = useLocaleDict(() => props.locale);
1902
2165
  const emit = __emit;
1903
2166
  const scrollRef = ref(null);
1904
2167
  const bubbleRefs = ref([]);
@@ -2075,7 +2338,7 @@ var _sfc_main$f = /* @__PURE__ */ defineComponent({
2075
2338
  circle: "",
2076
2339
  loading: __props.btnLoading,
2077
2340
  color: __props.btnColor || void 0,
2078
- "aria-label": "\u6EDA\u52A8\u5230\u5E95\u90E8",
2341
+ "aria-label": unref(dict).scroll.toBottom,
2079
2342
  onClick: goBottom
2080
2343
  }, {
2081
2344
  default: withCtx(() => [
@@ -2094,7 +2357,7 @@ var _sfc_main$f = /* @__PURE__ */ defineComponent({
2094
2357
  ]),
2095
2358
  _: 1
2096
2359
  /* STABLE */
2097
- }, 8, ["style", "loading", "color"])) : createCommentVNode("v-if", true)
2360
+ }, 8, ["style", "loading", "color", "aria-label"])) : createCommentVNode("v-if", true)
2098
2361
  ]),
2099
2362
  _: 1
2100
2363
  /* STABLE */
@@ -2168,7 +2431,7 @@ function useRecord() {
2168
2431
  chunks = [];
2169
2432
  revokeAudioUrl();
2170
2433
  if (typeof MediaRecorder === "undefined" || !navigator.mediaDevices?.getUserMedia) {
2171
- error.value = new Error("\u5F53\u524D\u73AF\u5883\u4E0D\u652F\u6301\u97F3\u9891\u5F55\u5236");
2434
+ error.value = new Error(getGlobalLocale().errors.recordUnsupported);
2172
2435
  return;
2173
2436
  }
2174
2437
  try {
@@ -2205,7 +2468,7 @@ function useRecord() {
2205
2468
  text.value = finalText + interim;
2206
2469
  };
2207
2470
  recognition.onerror = (ev) => {
2208
- error.value = new Error(`\u8BED\u97F3\u8BC6\u522B\u9519\u8BEF: ${ev?.error ?? "unknown"}`);
2471
+ error.value = new Error(getGlobalLocale().errors.speechError.split("{error}").join(String(ev?.error ?? "unknown")));
2209
2472
  };
2210
2473
  recognition.start();
2211
2474
  } catch {
@@ -2246,16 +2509,16 @@ const _hoisted_3$d = {
2246
2509
  key: 0,
2247
2510
  class: "fv-sender-body-top"
2248
2511
  };
2249
- const _hoisted_4$c = { class: "fv-sender-row" };
2250
- const _hoisted_5$7 = {
2512
+ const _hoisted_4$b = { class: "fv-sender-row" };
2513
+ const _hoisted_5$8 = {
2251
2514
  key: 0,
2252
2515
  class: "fv-sender-prefix"
2253
2516
  };
2254
- const _hoisted_6$6 = {
2517
+ const _hoisted_6$7 = {
2255
2518
  class: "fv-sender-recording-wave",
2256
2519
  "aria-hidden": "true"
2257
2520
  };
2258
- const _hoisted_7$4 = { class: "fv-sender-recording-duration" };
2521
+ const _hoisted_7$5 = { class: "fv-sender-recording-duration" };
2259
2522
  const _hoisted_8$3 = ["value", "placeholder", "disabled", "readonly"];
2260
2523
  const _hoisted_9$2 = {
2261
2524
  key: 3,
@@ -2308,11 +2571,13 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2308
2571
  triggerPopoverOffset: { type: Number, required: false, default: 0 },
2309
2572
  triggerPopoverPlacement: { type: null, required: false, default: "top-start" },
2310
2573
  allowSpeech: { type: Boolean, required: false, default: false },
2311
- allowEmptySubmit: { type: Boolean, required: false, default: false }
2574
+ allowEmptySubmit: { type: Boolean, required: false, default: false },
2575
+ locale: { type: null, required: false }
2312
2576
  },
2313
2577
  emits: ["update:modelValue", "submit", "cancel", "change", "trigger", "recording-change", "paste-file", "update:triggerPopoverVisible"],
2314
2578
  setup(__props, { expose: __expose, emit: __emit }) {
2315
2579
  const props = __props;
2580
+ const dict = useLocaleDict(() => props.locale);
2316
2581
  const emit = __emit;
2317
2582
  const innerValue = ref(props.modelValue);
2318
2583
  watch(() => props.modelValue, (v) => {
@@ -2490,7 +2755,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2490
2755
  if (isRecording.value) return;
2491
2756
  await startRecord();
2492
2757
  if (recordError.value) {
2493
- ElMessage.error(recordError.value.message || "\u65E0\u6CD5\u8BBF\u95EE\u9EA6\u514B\u98CE");
2758
+ ElMessage.error(recordError.value.message || dict.value.sender.micUnavailable);
2494
2759
  return;
2495
2760
  }
2496
2761
  emit("recording-change", true);
@@ -2620,9 +2885,9 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2620
2885
  renderSlot(_ctx.$slots, "body-top")
2621
2886
  ])) : createCommentVNode("v-if", true),
2622
2887
  createCommentVNode(" \u4E3B\u4F53\u884C:\u524D\u7F00 + \u8F93\u5165 + \u64CD\u4F5C "),
2623
- createElementVNode("div", _hoisted_4$c, [
2888
+ createElementVNode("div", _hoisted_4$b, [
2624
2889
  createCommentVNode(" \u524D\u7F00\u533A "),
2625
- _ctx.$slots.prefix ? (openBlock(), createElementBlock("div", _hoisted_5$7, [
2890
+ _ctx.$slots.prefix ? (openBlock(), createElementBlock("div", _hoisted_5$8, [
2626
2891
  renderSlot(_ctx.$slots, "prefix")
2627
2892
  ])) : createCommentVNode("v-if", true),
2628
2893
  createCommentVNode(" \u8BED\u97F3\u5F55\u97F3\u4E2D:\u8F93\u5165\u533A\u539F\u4F4D\u66FF\u6362\u4E3A\u5F55\u97F3\u6761(\u53D6\u6D88/\u6CE2\u5F62+\u65F6\u957F/\u786E\u8BA4);Esc \u53D6\u6D88 "),
@@ -2639,7 +2904,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2639
2904
  class: "fv-sender-recording-cancel",
2640
2905
  text: "",
2641
2906
  circle: "",
2642
- "aria-label": "\u53D6\u6D88\u5F55\u97F3",
2907
+ "aria-label": unref(dict).sender.recordCancel,
2643
2908
  onClick: onRecordCancel
2644
2909
  }, {
2645
2910
  default: withCtx(() => [
@@ -2653,8 +2918,8 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2653
2918
  ]),
2654
2919
  _: 1
2655
2920
  /* STABLE */
2656
- }),
2657
- createElementVNode("div", _hoisted_6$6, [
2921
+ }, 8, ["aria-label"]),
2922
+ createElementVNode("div", _hoisted_6$7, [
2658
2923
  (openBlock(true), createElementBlock(
2659
2924
  Fragment,
2660
2925
  null,
@@ -2677,7 +2942,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2677
2942
  ]),
2678
2943
  createElementVNode(
2679
2944
  "span",
2680
- _hoisted_7$4,
2945
+ _hoisted_7$5,
2681
2946
  toDisplayString(recordDuration.value),
2682
2947
  1
2683
2948
  /* TEXT */
@@ -2686,7 +2951,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2686
2951
  class: "fv-sender-recording-confirm",
2687
2952
  type: "primary",
2688
2953
  circle: "",
2689
- "aria-label": "\u786E\u8BA4\u5F55\u97F3",
2954
+ "aria-label": unref(dict).sender.recordConfirm,
2690
2955
  onClick: onRecordConfirm
2691
2956
  }, {
2692
2957
  default: withCtx(() => [
@@ -2700,7 +2965,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2700
2965
  ]),
2701
2966
  _: 1
2702
2967
  /* STABLE */
2703
- })
2968
+ }, 8, ["aria-label"])
2704
2969
  ],
2705
2970
  32
2706
2971
  /* NEED_HYDRATION */
@@ -2771,7 +3036,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2771
3036
  class: "fv-sender-clear",
2772
3037
  text: "",
2773
3038
  disabled: __props.disabled,
2774
- "aria-label": "\u6E05\u7A7A",
3039
+ "aria-label": unref(dict).sender.clear,
2775
3040
  onClick: clear
2776
3041
  }, {
2777
3042
  default: withCtx(() => [
@@ -2785,13 +3050,13 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2785
3050
  ]),
2786
3051
  _: 1
2787
3052
  /* STABLE */
2788
- }, 8, ["disabled"])) : createCommentVNode("v-if", true),
3053
+ }, 8, ["disabled", "aria-label"])) : createCommentVNode("v-if", true),
2789
3054
  __props.allowSpeech && !unref(isRecording) ? (openBlock(), createBlock(unref(ElButton), {
2790
3055
  key: 2,
2791
3056
  class: "fv-sender-speech",
2792
3057
  text: "",
2793
3058
  disabled: __props.disabled,
2794
- "aria-label": "\u8BED\u97F3\u8F93\u5165",
3059
+ "aria-label": unref(dict).sender.speech,
2795
3060
  onClick: onSpeechClick
2796
3061
  }, {
2797
3062
  default: withCtx(() => [
@@ -2805,14 +3070,14 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2805
3070
  ]),
2806
3071
  _: 1
2807
3072
  /* STABLE */
2808
- }, 8, ["disabled"])) : createCommentVNode("v-if", true),
3073
+ }, 8, ["disabled", "aria-label"])) : createCommentVNode("v-if", true),
2809
3074
  createCommentVNode(" loading \u2192 \u505C\u6B62\u6309\u94AE:SVG \u5149\u5E26\u6CBF\u8FB9\u6846\u5300\u901F\u6D41\u8F6C,\u65B9/\u5706\u6309\u94AE\u5747\u9002\u7528 "),
2810
3075
  __props.loading ? (openBlock(), createBlock(unref(ElButton), {
2811
3076
  key: 3,
2812
3077
  class: "fv-sender-stop",
2813
3078
  type: "primary",
2814
3079
  circle: __props.round,
2815
- "aria-label": "\u505C\u6B62",
3080
+ "aria-label": unref(dict).sender.stop,
2816
3081
  onClick: cancel
2817
3082
  }, {
2818
3083
  default: withCtx(() => [
@@ -2844,13 +3109,13 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2844
3109
  ]),
2845
3110
  _: 1
2846
3111
  /* STABLE */
2847
- }, 8, ["circle"])) : (openBlock(), createBlock(unref(ElButton), {
3112
+ }, 8, ["circle", "aria-label"])) : (openBlock(), createBlock(unref(ElButton), {
2848
3113
  key: 4,
2849
3114
  class: "fv-sender-submit",
2850
3115
  type: "primary",
2851
3116
  circle: __props.round,
2852
3117
  disabled: !submitable(),
2853
- "aria-label": "\u53D1\u9001",
3118
+ "aria-label": unref(dict).sender.send,
2854
3119
  onClick: doSubmit
2855
3120
  }, {
2856
3121
  default: withCtx(() => [
@@ -2864,7 +3129,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
2864
3129
  ]),
2865
3130
  _: 1
2866
3131
  /* STABLE */
2867
- }, 8, ["circle", "disabled"]))
3132
+ }, 8, ["circle", "disabled", "aria-label"]))
2868
3133
  ]))
2869
3134
  ]),
2870
3135
  createCommentVNode(" /fv-sender-row ")
@@ -2890,10 +3155,10 @@ const _hoisted_3$c = {
2890
3155
  key: 1,
2891
3156
  class: "fv-mention-loading"
2892
3157
  };
2893
- const _hoisted_4$b = ["onMouseenter", "onClick"];
2894
- const _hoisted_5$6 = { class: "fv-mention-avatar" };
2895
- const _hoisted_6$5 = ["src", "alt"];
2896
- const _hoisted_7$3 = { class: "fv-mention-name" };
3158
+ const _hoisted_4$a = ["onMouseenter", "onClick"];
3159
+ const _hoisted_5$7 = { class: "fv-mention-avatar" };
3160
+ const _hoisted_6$6 = ["src", "alt"];
3161
+ const _hoisted_7$4 = { class: "fv-mention-name" };
2897
3162
  const CHAR_WIDTH$1 = 8;
2898
3163
  var _sfc_main$c = /* @__PURE__ */ defineComponent({
2899
3164
  ...{ name: "FvMentionSender", inheritAttrs: false },
@@ -2902,11 +3167,13 @@ var _sfc_main$c = /* @__PURE__ */ defineComponent({
2902
3167
  modelValue: { type: String, required: false, default: "" },
2903
3168
  userList: { type: Array, required: false, default: () => [] },
2904
3169
  customTrigger: { type: Array, required: false, default: () => [] },
2905
- asyncMatchFun: { type: Function, required: false, default: void 0 }
3170
+ asyncMatchFun: { type: Function, required: false, default: void 0 },
3171
+ locale: { type: null, required: false, default: void 0 }
2906
3172
  },
2907
3173
  emits: ["update:modelValue", "change", "submit", "cancel", "trigger", "recording-change", "paste-file", "update:triggerPopoverVisible", "show-at-dialog"],
2908
3174
  setup(__props, { expose: __expose, emit: __emit }) {
2909
3175
  const props = __props;
3176
+ const dict = useLocaleDict(() => props.locale);
2910
3177
  const emit = __emit;
2911
3178
  const innerValue = ref(props.modelValue);
2912
3179
  watch(() => props.modelValue, (v) => {
@@ -3254,7 +3521,13 @@ var _sfc_main$c = /* @__PURE__ */ defineComponent({
3254
3521
  1
3255
3522
  /* TEXT */
3256
3523
  )) : createCommentVNode("v-if", true),
3257
- asyncLoading.value ? (openBlock(), createElementBlock("div", _hoisted_3$c, "\u52A0\u8F7D\u4E2D\u2026")) : (openBlock(true), createElementBlock(
3524
+ asyncLoading.value ? (openBlock(), createElementBlock(
3525
+ "div",
3526
+ _hoisted_3$c,
3527
+ toDisplayString(unref(dict).editorSender.loading),
3528
+ 1
3529
+ /* TEXT */
3530
+ )) : (openBlock(true), createElementBlock(
3258
3531
  Fragment,
3259
3532
  { key: 2 },
3260
3533
  renderList(candidates.value, (item, index) => {
@@ -3264,12 +3537,12 @@ var _sfc_main$c = /* @__PURE__ */ defineComponent({
3264
3537
  onMouseenter: ($event) => activeIndex.value = index,
3265
3538
  onClick: ($event) => confirmItem(item)
3266
3539
  }, [
3267
- createElementVNode("span", _hoisted_5$6, [
3540
+ createElementVNode("span", _hoisted_5$7, [
3268
3541
  item.avatar ? (openBlock(), createElementBlock("img", {
3269
3542
  key: 0,
3270
3543
  src: item.avatar,
3271
3544
  alt: item.name
3272
- }, null, 8, _hoisted_6$5)) : (openBlock(), createElementBlock(
3545
+ }, null, 8, _hoisted_6$6)) : (openBlock(), createElementBlock(
3273
3546
  Fragment,
3274
3547
  { key: 1 },
3275
3548
  [
@@ -3285,12 +3558,12 @@ var _sfc_main$c = /* @__PURE__ */ defineComponent({
3285
3558
  ]),
3286
3559
  createElementVNode(
3287
3560
  "span",
3288
- _hoisted_7$3,
3561
+ _hoisted_7$4,
3289
3562
  toDisplayString(item.name),
3290
3563
  1
3291
3564
  /* TEXT */
3292
3565
  )
3293
- ], 42, _hoisted_4$b);
3566
+ ], 42, _hoisted_4$a);
3294
3567
  }),
3295
3568
  128
3296
3569
  /* KEYED_FRAGMENT */
@@ -3317,10 +3590,10 @@ const _hoisted_3$b = {
3317
3590
  key: 0,
3318
3591
  class: "fv-editor-prefix"
3319
3592
  };
3320
- const _hoisted_4$a = { class: "fv-editor-input" };
3321
- const _hoisted_5$5 = ["contenteditable", "data-placeholder"];
3322
- const _hoisted_6$4 = { class: "fv-editor-mention-panel" };
3323
- const _hoisted_7$2 = {
3593
+ const _hoisted_4$9 = { class: "fv-editor-input" };
3594
+ const _hoisted_5$6 = ["contenteditable", "data-placeholder"];
3595
+ const _hoisted_6$5 = { class: "fv-editor-mention-panel" };
3596
+ const _hoisted_7$3 = {
3324
3597
  key: 0,
3325
3598
  class: "fv-editor-mention-title"
3326
3599
  };
@@ -3371,11 +3644,13 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
3371
3644
  clearable: { type: Boolean, required: false, default: false },
3372
3645
  headerAnimationTimer: { type: Number, required: false, default: 300 },
3373
3646
  asyncMatchFun: { type: Function, required: false, default: void 0 },
3374
- customDialog: { type: Boolean, required: false, default: false }
3647
+ customDialog: { type: Boolean, required: false, default: false },
3648
+ locale: { type: null, required: false }
3375
3649
  },
3376
3650
  emits: ["submit", "change", "cancel", "show-at-dialog", "show-select-dialog", "show-tag-dialog"],
3377
3651
  setup(__props, { expose: __expose, emit: __emit }) {
3378
3652
  const props = __props;
3653
+ const dict = useLocaleDict(() => props.locale);
3379
3654
  const emit = __emit;
3380
3655
  let uid = 0;
3381
3656
  function genId() {
@@ -3467,7 +3742,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
3467
3742
  const input = document.createElement("input");
3468
3743
  input.className = "fv-editor-tag-input";
3469
3744
  input.value = node.value?.name ?? "";
3470
- input.setAttribute("placeholder", node.meta?.placeholder ?? "\u8BF7\u8F93\u5165");
3745
+ input.setAttribute("placeholder", node.meta?.placeholder ?? dict.value.editorSender.inputPlaceholder);
3471
3746
  input.addEventListener("input", (ev) => {
3472
3747
  node.value = { ...node.value ?? {}, name: ev.target.value };
3473
3748
  ev.stopPropagation();
@@ -4094,7 +4369,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4094
4369
  _ctx.$slots.prefix ? (openBlock(), createElementBlock("div", _hoisted_3$b, [
4095
4370
  renderSlot(_ctx.$slots, "prefix")
4096
4371
  ])) : createCommentVNode("v-if", true),
4097
- createElementVNode("div", _hoisted_4$a, [
4372
+ createElementVNode("div", _hoisted_4$9, [
4098
4373
  createCommentVNode(" \u6807\u7B7E\u7F16\u8F91\u533A:contenteditable,\u5185\u5BB9\u7531\u547D\u4EE4\u5F0F\u6E32\u67D3(nodes \u2192 DOM) "),
4099
4374
  createElementVNode("div", {
4100
4375
  ref_key: "editorRef",
@@ -4109,7 +4384,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4109
4384
  onPaste,
4110
4385
  onFocus: onEditorFocus,
4111
4386
  onBlur: onEditorBlur
4112
- }, null, 40, _hoisted_5$5),
4387
+ }, null, 40, _hoisted_5$6),
4113
4388
  createCommentVNode(" at \u5F39\u5C42\u951A\u70B9:\u4E0D\u53EF\u89C1,\u4EC5\u627F\u8F7D el-popover \u5B9A\u4F4D(\u5728 ElPopover #reference \u5185) "),
4114
4389
  createCommentVNode(" @\u5F39\u5C42:v-if \u6574\u4F53\u5378\u8F7D(el-popover \u5173\u95ED\u4EC5 display:none \u4F1A\u6B8B\u7559 DOM) "),
4115
4390
  mentionVisible.value ? (openBlock(), createBlock(unref(ElPopover), {
@@ -4135,15 +4410,21 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4135
4410
  )
4136
4411
  ]),
4137
4412
  default: withCtx(() => [
4138
- createElementVNode("div", _hoisted_6$4, [
4413
+ createElementVNode("div", _hoisted_6$5, [
4139
4414
  panelTitle.value ? (openBlock(), createElementBlock(
4140
4415
  "div",
4141
- _hoisted_7$2,
4416
+ _hoisted_7$3,
4142
4417
  toDisplayString(panelTitle.value),
4143
4418
  1
4144
4419
  /* TEXT */
4145
4420
  )) : createCommentVNode("v-if", true),
4146
- asyncLoading.value ? (openBlock(), createElementBlock("div", _hoisted_8$2, "\u52A0\u8F7D\u4E2D\u2026")) : (openBlock(true), createElementBlock(
4421
+ asyncLoading.value ? (openBlock(), createElementBlock(
4422
+ "div",
4423
+ _hoisted_8$2,
4424
+ toDisplayString(unref(dict).editorSender.loading),
4425
+ 1
4426
+ /* TEXT */
4427
+ )) : (openBlock(true), createElementBlock(
4147
4428
  Fragment,
4148
4429
  { key: 2 },
4149
4430
  renderList(candidates.value, (item, index) => {
@@ -4212,13 +4493,13 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4212
4493
  default: withCtx(() => [
4213
4494
  createElementVNode("div", _hoisted_13$1, [
4214
4495
  renderSlot(_ctx.$slots, "tag-tip", { nodeId: tipTargetId.value }, () => [
4215
- _cache[5] || (_cache[5] = createElementVNode(
4496
+ createElementVNode(
4216
4497
  "span",
4217
4498
  null,
4218
- "\u586B\u5199\u5185\u5BB9\u540E\u56DE\u8F66\u786E\u8BA4",
4219
- -1
4220
- /* CACHED */
4221
- ))
4499
+ toDisplayString(unref(dict).editorSender.tagTip),
4500
+ 1
4501
+ /* TEXT */
4502
+ )
4222
4503
  ])
4223
4504
  ])
4224
4505
  ]),
@@ -4235,7 +4516,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4235
4516
  class: "fv-editor-clear",
4236
4517
  text: "",
4237
4518
  disabled: __props.disabled,
4238
- "aria-label": "\u6E05\u7A7A",
4519
+ "aria-label": unref(dict).editorSender.clear,
4239
4520
  onClick: clear
4240
4521
  }, {
4241
4522
  default: withCtx(() => [
@@ -4249,13 +4530,13 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4249
4530
  ]),
4250
4531
  _: 1
4251
4532
  /* STABLE */
4252
- }, 8, ["disabled"])) : createCommentVNode("v-if", true),
4533
+ }, 8, ["disabled", "aria-label"])) : createCommentVNode("v-if", true),
4253
4534
  createCommentVNode(" loading \u2192 \u505C\u6B62\u6309\u94AE;\u5426\u5219\u53D1\u9001\u6309\u94AE "),
4254
4535
  __props.loading ? (openBlock(), createBlock(unref(ElButton), {
4255
4536
  key: 1,
4256
4537
  class: "fv-editor-stop",
4257
4538
  type: "primary",
4258
- "aria-label": "\u505C\u6B62",
4539
+ "aria-label": unref(dict).editorSender.stop,
4259
4540
  onClick: _cache[2] || (_cache[2] = ($event) => emit("cancel"))
4260
4541
  }, {
4261
4542
  default: withCtx(() => [
@@ -4269,12 +4550,12 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4269
4550
  ]),
4270
4551
  _: 1
4271
4552
  /* STABLE */
4272
- })) : (openBlock(), createBlock(unref(ElButton), {
4553
+ }, 8, ["aria-label"])) : (openBlock(), createBlock(unref(ElButton), {
4273
4554
  key: 2,
4274
4555
  class: "fv-editor-submit",
4275
4556
  type: "primary",
4276
4557
  disabled: !canSubmit.value,
4277
- "aria-label": "\u53D1\u9001",
4558
+ "aria-label": unref(dict).editorSender.send,
4278
4559
  onClick: doSubmit
4279
4560
  }, {
4280
4561
  default: withCtx(() => [
@@ -4288,7 +4569,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4288
4569
  ]),
4289
4570
  _: 1
4290
4571
  /* STABLE */
4291
- }, 8, ["disabled"]))
4572
+ }, 8, ["disabled", "aria-label"]))
4292
4573
  ]))
4293
4574
  ]),
4294
4575
  createCommentVNode(" \u5E95\u90E8 "),
@@ -4299,7 +4580,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4299
4580
  selectVisible.value && !__props.customDialog ? (openBlock(), createBlock(unref(ElDialog), {
4300
4581
  key: 2,
4301
4582
  "model-value": selectVisible.value,
4302
- title: "\u9009\u62E9\u6807\u7B7E",
4583
+ title: unref(dict).editorSender.selectTagTitle,
4303
4584
  width: "560px",
4304
4585
  "append-to-body": false,
4305
4586
  "onUpdate:modelValue": _cache[3] || (_cache[3] = (v) => {
@@ -4362,7 +4643,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
4362
4643
  ]),
4363
4644
  _: 1
4364
4645
  /* STABLE */
4365
- }, 8, ["model-value"])) : createCommentVNode("v-if", true)
4646
+ }, 8, ["model-value", "title"])) : createCommentVNode("v-if", true)
4366
4647
  ],
4367
4648
  6
4368
4649
  /* CLASS, STYLE */
@@ -4377,7 +4658,7 @@ const _hoisted_2$a = {
4377
4658
  class: "fv-thinking-dot"
4378
4659
  };
4379
4660
  const _hoisted_3$a = { class: "fv-thinking-label" };
4380
- const _hoisted_4$9 = ["hidden"];
4661
+ const _hoisted_4$8 = ["hidden"];
4381
4662
  var _sfc_main$a = /* @__PURE__ */ defineComponent({
4382
4663
  ...{ name: "FvThinking" },
4383
4664
  __name: "index",
@@ -4390,24 +4671,28 @@ var _sfc_main$a = /* @__PURE__ */ defineComponent({
4390
4671
  buttonWidth: { type: String, required: false, default: "" },
4391
4672
  maxWidth: { type: String, required: false, default: "" },
4392
4673
  color: { type: String, required: false, default: "" },
4393
- backgroundColor: { type: String, required: false, default: "" }
4674
+ backgroundColor: { type: String, required: false, default: "" },
4675
+ locale: { type: null, required: false }
4394
4676
  },
4395
4677
  emits: ["update:modelValue"],
4396
4678
  setup(__props, { expose: __expose, emit: __emit }) {
4397
4679
  const props = __props;
4398
4680
  const emit = __emit;
4399
- const statusTextMap = {
4400
- start: "\u5F00\u59CB\u601D\u8003",
4401
- thinking: "\u601D\u8003\u4E2D...",
4402
- end: "\u601D\u8003\u5B8C\u6210",
4403
- error: "\u601D\u8003\u9047\u5230\u95EE\u9898"
4404
- };
4405
4681
  const modelValue = ref(props.modelValue);
4406
4682
  watch(() => props.modelValue, (v) => {
4407
4683
  if (v !== modelValue.value) modelValue.value = v;
4408
4684
  });
4409
4685
  watch(modelValue, (v) => emit("update:modelValue", v));
4410
- const statusText = computed(() => statusTextMap[props.status]);
4686
+ const dict = useLocaleDict(() => props.locale);
4687
+ const statusText = computed(() => {
4688
+ const m = {
4689
+ start: dict.value.thinking.start,
4690
+ thinking: dict.value.thinking.thinking,
4691
+ end: dict.value.thinking.end,
4692
+ error: dict.value.thinking.error
4693
+ };
4694
+ return m[props.status];
4695
+ });
4411
4696
  function toggle() {
4412
4697
  if (props.disabled) return;
4413
4698
  if (props.status === "start") return;
@@ -4518,7 +4803,7 @@ var _sfc_main$a = /* @__PURE__ */ defineComponent({
4518
4803
  /* TEXT */
4519
4804
  )
4520
4805
  ], void 0, 1)
4521
- ], 12, _hoisted_4$9)) : createCommentVNode("v-if", true)
4806
+ ], 12, _hoisted_4$8)) : createCommentVNode("v-if", true)
4522
4807
  ],
4523
4808
  6
4524
4809
  /* CLASS, STYLE */
@@ -4533,15 +4818,22 @@ const _hoisted_2$9 = {
4533
4818
  class: "fv-chain-dot"
4534
4819
  };
4535
4820
  const _hoisted_3$9 = { class: "fv-chain-main" };
4536
- const _hoisted_4$8 = {
4821
+ const _hoisted_4$7 = {
4537
4822
  key: 1,
4538
4823
  class: "fv-chain-title-text"
4539
4824
  };
4540
- const _hoisted_5$4 = ["aria-label", "onClick"];
4541
- const _hoisted_6$3 = {
4825
+ const _hoisted_5$5 = {
4826
+ key: 2,
4827
+ class: "fv-chain-title-text"
4828
+ };
4829
+ const _hoisted_6$4 = ["aria-label", "onClick"];
4830
+ const _hoisted_7$2 = {
4542
4831
  key: 0,
4543
4832
  class: "fv-chain-description"
4544
4833
  };
4834
+ const HOLD_DELAY = 200;
4835
+ const HOLD_MIN_CHARS = 16;
4836
+ const HOLD_WINDOW = 600;
4545
4837
  const TITLE_LINE_HEIGHT = 22;
4546
4838
  const TITLE_MAX_LINES = 3;
4547
4839
  const ELLIPSIS = "\u2026";
@@ -4552,11 +4844,13 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4552
4844
  props: {
4553
4845
  items: { type: Array, required: true, default: () => [] },
4554
4846
  direction: { type: String, required: false, default: "vertical" },
4555
- collapsible: { type: Boolean, required: false, default: false }
4847
+ collapsible: { type: Boolean, required: false, default: false },
4848
+ locale: { type: null, required: false }
4556
4849
  },
4557
4850
  emits: ["typing"],
4558
4851
  setup(__props, { emit: __emit }) {
4559
4852
  const props = __props;
4853
+ const dict = useLocaleDict(() => props.locale);
4560
4854
  const emit = __emit;
4561
4855
  function statusClass(status) {
4562
4856
  return status ? `status-${status}` : "status-pending";
@@ -4567,7 +4861,38 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4567
4861
  }
4568
4862
  const typedKeys = ref(/* @__PURE__ */ new Set());
4569
4863
  const doneKeys = ref(/* @__PURE__ */ new Set());
4864
+ const flushedKeys = ref(/* @__PURE__ */ new Set());
4570
4865
  const typingConfigs = ref(/* @__PURE__ */ new Map());
4866
+ const holdTimers = /* @__PURE__ */ new Map();
4867
+ const holdingKeys = ref(/* @__PURE__ */ new Set());
4868
+ function stopHold(key) {
4869
+ const t = holdTimers.get(key);
4870
+ if (t) {
4871
+ clearTimeout(t);
4872
+ holdTimers.delete(key);
4873
+ }
4874
+ if (holdingKeys.value.has(key)) {
4875
+ const next = new Set(holdingKeys.value);
4876
+ next.delete(key);
4877
+ holdingKeys.value = next;
4878
+ }
4879
+ }
4880
+ function clearAllHolds() {
4881
+ holdTimers.forEach((t) => clearTimeout(t));
4882
+ holdTimers.clear();
4883
+ }
4884
+ onBeforeUnmount(clearAllHolds);
4885
+ function holdItem(key) {
4886
+ if (holdingKeys.value.has(key)) return;
4887
+ holdingKeys.value = new Set(holdingKeys.value).add(key);
4888
+ holdTimers.set(key, setTimeout(() => {
4889
+ holdTimers.delete(key);
4890
+ if (!holdingKeys.value.has(key)) return;
4891
+ const next = new Set(holdingKeys.value);
4892
+ next.delete(key);
4893
+ holdingKeys.value = next;
4894
+ }, HOLD_DELAY));
4895
+ }
4571
4896
  function markTyped(key, typing) {
4572
4897
  if (!typedKeys.value.has(key)) typedKeys.value = new Set(typedKeys.value).add(key);
4573
4898
  if (typing) {
@@ -4579,16 +4904,56 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4579
4904
  function markDone(key) {
4580
4905
  if (!doneKeys.value.has(key)) doneKeys.value = new Set(doneKeys.value).add(key);
4581
4906
  }
4907
+ function flushStep(item) {
4908
+ flushedKeys.value = new Set(flushedKeys.value).add(item.key);
4909
+ doneKeys.value = new Set(doneKeys.value).add(item.key);
4910
+ stopHold(item.key);
4911
+ void nextTick(measure);
4912
+ return normalizeTitle(item.title).length;
4913
+ }
4914
+ let lastFlushAt = 0;
4915
+ let lastFlushChars = 0;
4582
4916
  watch(() => props.items, (items) => {
4583
- for (const it of items) if (it.typing) markTyped(it.key, it.typing);
4917
+ const now = Date.now();
4918
+ let flushedChars = 0;
4919
+ const flushCounting = (it) => {
4920
+ if (!isTypingItem(it) || flushedKeys.value.has(it.key)) return;
4921
+ const counted = !doneKeys.value.has(it.key);
4922
+ const chars = flushStep(it);
4923
+ if (counted) flushedChars += chars;
4924
+ };
4925
+ const preRegistered = new Set(typedKeys.value);
4926
+ const fresh = [];
4927
+ for (const it of items) {
4928
+ if (it.typing && !typedKeys.value.has(it.key)) {
4929
+ markTyped(it.key, it.typing);
4930
+ fresh.push(it);
4931
+ }
4932
+ }
4933
+ if (fresh.length) {
4934
+ const freshKeys = new Set(fresh.map((f) => f.key));
4935
+ for (const it of items) {
4936
+ if (!freshKeys.has(it.key)) flushCounting(it);
4937
+ }
4938
+ }
4939
+ for (const it of items) {
4940
+ if (it.typing && it.closed && preRegistered.has(it.key)) flushCounting(it);
4941
+ }
4942
+ if (flushedChars > 0) {
4943
+ lastFlushAt = now;
4944
+ lastFlushChars = flushedChars;
4945
+ }
4946
+ if (fresh.length && now - lastFlushAt < HOLD_WINDOW && lastFlushChars >= HOLD_MIN_CHARS) {
4947
+ for (const f of fresh) holdItem(f.key);
4948
+ }
4584
4949
  }, { immediate: true, deep: true });
4585
4950
  function typingOf(item) {
4586
4951
  return typingConfigs.value.get(item.key) ?? true;
4587
4952
  }
4588
4953
  function isTypingItem(item) {
4589
- if (item.typing) {
4590
- return !(item.closed && doneKeys.value.has(item.key));
4591
- }
4954
+ if (flushedKeys.value.has(item.key)) return false;
4955
+ if (holdingKeys.value.has(item.key)) return true;
4956
+ if (item.typing) return true;
4592
4957
  return typedKeys.value.has(item.key) && !doneKeys.value.has(item.key);
4593
4958
  }
4594
4959
  function onTypeFinish(key) {
@@ -4680,7 +5045,7 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4680
5045
  }
4681
5046
  function isTypingKey(key) {
4682
5047
  const item = props.items.find((i) => i.key === key);
4683
- return !!item && isTypingItem(item);
5048
+ return !!item && (isTypingItem(item) || holdingKeys.value.has(key));
4684
5049
  }
4685
5050
  function showToggle(key) {
4686
5051
  return overflowKeys.value.has(key) || expandedKeys.value.has(key);
@@ -4794,25 +5159,25 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4794
5159
  class: normalizeClass(["fv-chain-title", { "is-clamped": __props.collapsible && showToggle(item.key) && !expandedKeys.value.has(item.key) }])
4795
5160
  },
4796
5161
  [
4797
- createCommentVNode(" \u622A\u65AD\u7531 JS \u6D4B\u91CF(displayTitle \u524D\u7F00\u539F\u6587):\u6309\u94AE\u4E3A\u5185\u8054\u5143\u7D20\u81EA\u7136\u7D27\u8DDF\r\n \u7B2C\u4E09\u884C\u6587\u5B57\u672B(\u6536\u8D77)/\u5168\u91CF\u672B\u5B57(\u5C55\u5F00);\u65E0\u5E03\u5C40\u73AF\u5883\u4E0D\u88C1\u4E0D\u663E\u6309\u94AE "),
4798
- isTypingItem(item) ? (openBlock(), createBlock(_sfc_main$h, {
5162
+ createCommentVNode(" \u622A\u65AD\u7531 JS \u6D4B\u91CF(displayTitle \u524D\u7F00\u539F\u6587):\u6309\u94AE\u4E3A\u5185\u8054\u5143\u7D20\u81EA\u7136\u7D27\u8DDF\r\n \u7B2C\u4E09\u884C\u6587\u5B57\u672B(\u6536\u8D77)/\u5168\u91CF\u672B\u5B57(\u5C55\u5F00);\u65E0\u5E03\u5C40\u73AF\u5883\u4E0D\u88C1\u4E0D\u663E\u6309\u94AE;\r\n \u5EF6\u8FDF\u5F00\u6253\u7B49\u5F85\u671F(holding)\u6E32\u67D3\u7A7A\u5360\u4F4D,\u5230\u70B9\u518D\u6302\u6253\u5B57\u673A "),
5163
+ isTypingItem(item) && !holdingKeys.value.has(item.key) ? (openBlock(), createBlock(_sfc_main$h, {
4799
5164
  key: 0,
4800
5165
  content: normalizeTitle(item.title),
4801
5166
  typing: typingOf(item),
4802
5167
  onWriting: _cache[0] || (_cache[0] = ($event) => emit("typing")),
4803
5168
  onFinish: ($event) => onTypeFinish(item.key)
4804
- }, null, 8, ["content", "typing", "onFinish"])) : (openBlock(), createElementBlock(
5169
+ }, null, 8, ["content", "typing", "onFinish"])) : holdingKeys.value.has(item.key) ? (openBlock(), createElementBlock("span", _hoisted_4$7)) : (openBlock(), createElementBlock(
4805
5170
  "span",
4806
- _hoisted_4$8,
5171
+ _hoisted_5$5,
4807
5172
  toDisplayString(displayTitle(item.title, item.key)),
4808
5173
  1
4809
5174
  /* TEXT */
4810
5175
  )),
4811
5176
  __props.collapsible && showToggle(item.key) ? (openBlock(), createElementBlock("button", {
4812
- key: 2,
5177
+ key: 3,
4813
5178
  type: "button",
4814
5179
  class: "fv-chain-expand",
4815
- "aria-label": expandedKeys.value.has(item.key) ? "\u6536\u8D77" : "\u5C55\u5F00",
5180
+ "aria-label": expandedKeys.value.has(item.key) ? unref(dict).common.collapse : unref(dict).common.expand,
4816
5181
  onClick: ($event) => toggleExpand(item.key)
4817
5182
  }, [
4818
5183
  createVNode(
@@ -4828,14 +5193,14 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
4828
5193
  1024
4829
5194
  /* DYNAMIC_SLOTS */
4830
5195
  )
4831
- ], 8, _hoisted_5$4)) : createCommentVNode("v-if", true)
5196
+ ], 8, _hoisted_6$4)) : createCommentVNode("v-if", true)
4832
5197
  ],
4833
5198
  2
4834
5199
  /* CLASS */
4835
5200
  ),
4836
5201
  item.description ? (openBlock(), createElementBlock(
4837
5202
  "div",
4838
- _hoisted_6$3,
5203
+ _hoisted_7$2,
4839
5204
  toDisplayString(item.description),
4840
5205
  1
4841
5206
  /* TEXT */
@@ -4864,7 +5229,7 @@ const _hoisted_3$8 = {
4864
5229
  key: 0,
4865
5230
  class: "fv-welcome-name"
4866
5231
  };
4867
- const _hoisted_4$7 = {
5232
+ const _hoisted_4$6 = {
4868
5233
  key: 1,
4869
5234
  class: "fv-welcome-description"
4870
5235
  };
@@ -4917,7 +5282,7 @@ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
4917
5282
  ])
4918
5283
  ])) : createCommentVNode("v-if", true),
4919
5284
  createCommentVNode(" #description \u63D2\u69FD\u8986\u76D6\u63CF\u8FF0 "),
4920
- _ctx.$slots.description || __props.description ? (openBlock(), createElementBlock("p", _hoisted_4$7, [
5285
+ _ctx.$slots.description || __props.description ? (openBlock(), createElementBlock("p", _hoisted_4$6, [
4921
5286
  renderSlot(_ctx.$slots, "description", {}, () => [
4922
5287
  createTextVNode(
4923
5288
  toDisplayString(__props.description),
@@ -4937,9 +5302,9 @@ const _hoisted_2$7 = {
4937
5302
  class: "fv-prompts-title"
4938
5303
  };
4939
5304
  const _hoisted_3$7 = { class: "fv-prompts-list" };
4940
- const _hoisted_4$6 = ["role", "tabindex", "onClick"];
4941
- const _hoisted_5$3 = { class: "fv-prompt-item-main" };
4942
- const _hoisted_6$2 = { class: "fv-prompt-item-text" };
5305
+ const _hoisted_4$5 = ["role", "tabindex", "onClick"];
5306
+ const _hoisted_5$4 = { class: "fv-prompt-item-main" };
5307
+ const _hoisted_6$3 = { class: "fv-prompt-item-text" };
4943
5308
  const _hoisted_7$1 = {
4944
5309
  key: 0,
4945
5310
  class: "fv-prompt-item-label"
@@ -4996,7 +5361,7 @@ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
4996
5361
  item,
4997
5362
  index
4998
5363
  }, () => [
4999
- createElementVNode("div", _hoisted_5$3, [
5364
+ createElementVNode("div", _hoisted_5$4, [
5000
5365
  resolvedIcons.value[index] ? (openBlock(), createBlock(
5001
5366
  unref(ElIcon),
5002
5367
  {
@@ -5013,7 +5378,7 @@ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
5013
5378
  1024
5014
5379
  /* DYNAMIC_SLOTS */
5015
5380
  )) : createCommentVNode("v-if", true),
5016
- createElementVNode("div", _hoisted_6$2, [
5381
+ createElementVNode("div", _hoisted_6$3, [
5017
5382
  item.label ? (openBlock(), createElementBlock(
5018
5383
  "div",
5019
5384
  _hoisted_7$1,
@@ -5031,7 +5396,7 @@ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
5031
5396
  ])
5032
5397
  ])
5033
5398
  ])
5034
- ], 10, _hoisted_4$6);
5399
+ ], 10, _hoisted_4$5);
5035
5400
  }),
5036
5401
  128
5037
5402
  /* KEYED_FRAGMENT */
@@ -5045,14 +5410,15 @@ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
5045
5410
  const _hoisted_1$6 = ["src", "alt"];
5046
5411
  const _hoisted_2$6 = { class: "fv-files-card-info" };
5047
5412
  const _hoisted_3$6 = ["title"];
5048
- const _hoisted_4$5 = {
5413
+ const _hoisted_4$4 = {
5049
5414
  key: 0,
5050
5415
  class: "fv-files-card-size"
5051
5416
  };
5052
- const _hoisted_5$2 = {
5417
+ const _hoisted_5$3 = {
5053
5418
  key: 2,
5054
5419
  class: "fv-files-card-status"
5055
5420
  };
5421
+ const _hoisted_6$2 = ["aria-label"];
5056
5422
  const KB = 1024;
5057
5423
  const MB = 1024 * 1024;
5058
5424
  var _sfc_main$6 = /* @__PURE__ */ defineComponent({
@@ -5065,7 +5431,8 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
5065
5431
  url: { type: String, required: false, default: "" },
5066
5432
  status: { type: String, required: false, default: "success" },
5067
5433
  imageSize: { type: String, required: false, default: "" },
5068
- onDelete: { type: Function, required: false, default: void 0 }
5434
+ onDelete: { type: Function, required: false, default: void 0 },
5435
+ locale: { type: null, required: false, default: void 0 }
5069
5436
  },
5070
5437
  setup(__props) {
5071
5438
  const EXT_ICON = {
@@ -5105,6 +5472,7 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
5105
5472
  dll: Cpu
5106
5473
  };
5107
5474
  const props = __props;
5475
+ const dict = useLocaleDict(() => props.locale);
5108
5476
  const sizeText = computed(() => {
5109
5477
  if (props.size === void 0 || props.size === null || props.size === "" || props.size === 0) return "";
5110
5478
  if (typeof props.size === "string") return props.size;
@@ -5189,14 +5557,14 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
5189
5557
  }, toDisplayString(__props.name), 9, _hoisted_3$6),
5190
5558
  sizeText.value ? (openBlock(), createElementBlock(
5191
5559
  "div",
5192
- _hoisted_4$5,
5560
+ _hoisted_4$4,
5193
5561
  toDisplayString(sizeText.value),
5194
5562
  1
5195
5563
  /* TEXT */
5196
5564
  )) : createCommentVNode("v-if", true)
5197
5565
  ]),
5198
5566
  createCommentVNode(" \u72B6\u6001\u89D2\u6807:loading spinner;error \u65E0\u89D2\u6807(\u7EA2\u8FB9\u6837\u5F0F) "),
5199
- __props.status === "loading" ? (openBlock(), createElementBlock("div", _hoisted_5$2, [
5567
+ __props.status === "loading" ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
5200
5568
  createVNode(unref(ElIcon), { class: "fv-files-card-loading" }, {
5201
5569
  default: withCtx(() => [
5202
5570
  createVNode(unref(Loading))
@@ -5209,7 +5577,7 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
5209
5577
  createElementVNode("button", {
5210
5578
  type: "button",
5211
5579
  class: "fv-files-card-remove",
5212
- "aria-label": "\u5220\u9664",
5580
+ "aria-label": unref(dict).filesCard.remove,
5213
5581
  onClick: onDeleteClick
5214
5582
  }, [
5215
5583
  createVNode(unref(ElIcon), null, {
@@ -5219,7 +5587,7 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
5219
5587
  _: 1
5220
5588
  /* STABLE */
5221
5589
  })
5222
- ])
5590
+ ], 8, _hoisted_6$2)
5223
5591
  ],
5224
5592
  2
5225
5593
  /* CLASS */
@@ -5230,12 +5598,12 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
5230
5598
 
5231
5599
  const _hoisted_1$5 = { class: "fv-attachments" };
5232
5600
  const _hoisted_2$5 = ["accept"];
5233
- const _hoisted_3$5 = ["disabled"];
5234
- const _hoisted_4$4 = {
5601
+ const _hoisted_3$5 = ["disabled", "aria-label"];
5602
+ const _hoisted_4$3 = {
5235
5603
  key: 1,
5236
5604
  class: "fv-attachments-list"
5237
5605
  };
5238
- const _hoisted_5$1 = ["onClick"];
5606
+ const _hoisted_5$2 = ["aria-label", "onClick"];
5239
5607
  const _hoisted_6$1 = {
5240
5608
  key: 2,
5241
5609
  class: "fv-attachments-tip"
@@ -5249,11 +5617,13 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
5249
5617
  tip: { type: String, required: false, default: "" },
5250
5618
  count: { type: Number, required: false, default: 0 },
5251
5619
  beforeUpload: { type: Function, required: false, default: void 0 },
5252
- layout: { type: String, required: false, default: "inline" }
5620
+ layout: { type: String, required: false, default: "inline" },
5621
+ locale: { type: null, required: false, default: void 0 }
5253
5622
  },
5254
5623
  emits: ["update:modelValue", "change", "exceed", "delete"],
5255
5624
  setup(__props, { expose: __expose, emit: __emit }) {
5256
5625
  const props = __props;
5626
+ const dict = useLocaleDict(() => props.locale);
5257
5627
  const emit = __emit;
5258
5628
  const innerList = ref(props.modelValue ? [...props.modelValue] : []);
5259
5629
  watch(() => props.modelValue, (v) => {
@@ -5362,7 +5732,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
5362
5732
  type: "button",
5363
5733
  class: normalizeClass(["fv-attachments-trigger", { "is-full": full.value }]),
5364
5734
  disabled: full.value,
5365
- "aria-label": "\u6DFB\u52A0\u9644\u4EF6",
5735
+ "aria-label": unref(dict).attachments.add,
5366
5736
  onClick: openSelect
5367
5737
  }, [
5368
5738
  createVNode(unref(ElIcon), null, {
@@ -5374,7 +5744,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
5374
5744
  })
5375
5745
  ], 10, _hoisted_3$5)) : createCommentVNode("v-if", true),
5376
5746
  createCommentVNode(" \u6587\u4EF6\u5217\u8868:FilesCard;#list-thumb/#list-item \u8986\u76D6\u9879\u6E32\u67D3(triggerOnly \u5E03\u5C40\u4E0D\u6E32\u67D3) "),
5377
- list.value.length && __props.layout !== "triggerOnly" ? (openBlock(), createElementBlock("div", _hoisted_4$4, [
5747
+ list.value.length && __props.layout !== "triggerOnly" ? (openBlock(), createElementBlock("div", _hoisted_4$3, [
5378
5748
  (openBlock(true), createElementBlock(
5379
5749
  Fragment,
5380
5750
  null,
@@ -5414,7 +5784,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
5414
5784
  key: 0,
5415
5785
  type: "button",
5416
5786
  class: "fv-attachments-retry",
5417
- "aria-label": "\u91CD\u4F20",
5787
+ "aria-label": unref(dict).attachments.retry,
5418
5788
  onClick: ($event) => retry(item)
5419
5789
  }, [
5420
5790
  createVNode(unref(ElIcon), null, {
@@ -5424,7 +5794,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
5424
5794
  _: 1
5425
5795
  /* STABLE */
5426
5796
  })
5427
- ], 8, _hoisted_5$1)) : createCommentVNode("v-if", true)
5797
+ ], 8, _hoisted_5$2)) : createCommentVNode("v-if", true)
5428
5798
  ])
5429
5799
  ]);
5430
5800
  }),
@@ -5451,7 +5821,8 @@ const _hoisted_1$4 = {
5451
5821
  };
5452
5822
  const _hoisted_2$4 = ["onClick"];
5453
5823
  const _hoisted_3$4 = { class: "fv-conversations-item-content" };
5454
- const _hoisted_4$3 = ["title"];
5824
+ const _hoisted_4$2 = ["title"];
5825
+ const _hoisted_5$1 = ["aria-label"];
5455
5826
  var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5456
5827
  ...{ name: "FvConversations" },
5457
5828
  __name: "index",
@@ -5461,11 +5832,13 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5461
5832
  showBuiltInMenuType: { type: String, required: false, default: "hover" },
5462
5833
  groupable: { type: Function, required: false, default: void 0 },
5463
5834
  loading: { type: Boolean, required: false, default: false },
5464
- hasMore: { type: Boolean, required: false, default: false }
5835
+ hasMore: { type: Boolean, required: false, default: false },
5836
+ locale: { type: null, required: false, default: void 0 }
5465
5837
  },
5466
5838
  emits: ["update:active", "change", "menu-command", "load-more"],
5467
5839
  setup(__props, { expose: __expose, emit: __emit }) {
5468
5840
  const props = __props;
5841
+ const dict = useLocaleDict(() => props.locale);
5469
5842
  const emit = __emit;
5470
5843
  const innerActive = ref(props.active);
5471
5844
  watch(() => props.active, (v) => {
@@ -5518,11 +5891,11 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5518
5891
  const item = props.items.find((i) => i.key === key);
5519
5892
  if (!item) return;
5520
5893
  try {
5521
- const { value } = await ElMessageBox.prompt("\u8BF7\u8F93\u5165\u65B0\u7684\u4F1A\u8BDD\u540D\u79F0", "\u91CD\u547D\u540D\u4F1A\u8BDD", {
5522
- confirmButtonText: "\u786E\u5B9A",
5523
- cancelButtonText: "\u53D6\u6D88",
5894
+ const { value } = await ElMessageBox.prompt(dict.value.conversations.renamePrompt, dict.value.conversations.renameTitle, {
5895
+ confirmButtonText: dict.value.common.confirm,
5896
+ cancelButtonText: dict.value.common.cancel,
5524
5897
  inputValue: item.label,
5525
- inputPlaceholder: "\u8BF7\u8F93\u5165\u540D\u79F0"
5898
+ inputPlaceholder: dict.value.conversations.renamePlaceholder
5526
5899
  });
5527
5900
  if (value && value.trim()) emit("menu-command", { item, command: "rename", value: value.trim() });
5528
5901
  } catch {
@@ -5532,11 +5905,15 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5532
5905
  const item = props.items.find((i) => i.key === key);
5533
5906
  if (!item) return;
5534
5907
  try {
5535
- await ElMessageBox.confirm(`\u786E\u5B9A\u5220\u9664\u4F1A\u8BDD\u300C${item.label}\u300D\u5417?\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002`, "\u5220\u9664\u4F1A\u8BDD", {
5536
- confirmButtonText: "\u5220\u9664",
5537
- cancelButtonText: "\u53D6\u6D88",
5538
- type: "warning"
5539
- });
5908
+ await ElMessageBox.confirm(
5909
+ dict.value.conversations.deleteConfirm.split("{label}").join(item.label),
5910
+ dict.value.conversations.deleteTitle,
5911
+ {
5912
+ confirmButtonText: dict.value.conversations.delete,
5913
+ cancelButtonText: dict.value.common.cancel,
5914
+ type: "warning"
5915
+ }
5916
+ );
5540
5917
  emit("menu-command", { item, command: "delete" });
5541
5918
  } catch {
5542
5919
  }
@@ -5590,7 +5967,7 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5590
5967
  createElementVNode("span", {
5591
5968
  class: "fv-conversations-item-label",
5592
5969
  title: item.label
5593
- }, toDisplayString(item.label), 9, _hoisted_4$3)
5970
+ }, toDisplayString(item.label), 9, _hoisted_4$2)
5594
5971
  ])
5595
5972
  ]),
5596
5973
  createCommentVNode(" \u5185\u7F6E\u83DC\u5355:hover \u663E\u793A\u6309\u94AE \u2192 el-dropdown(\u91CD\u547D\u540D/\u5220\u9664);#menu \u8986\u76D6\u83DC\u5355\u5217\u8868 "),
@@ -5608,24 +5985,24 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5608
5985
  default: withCtx(() => [
5609
5986
  renderSlot(_ctx.$slots, "menu", { item }, () => [
5610
5987
  createVNode(unref(ElDropdownItem), { command: "rename" }, {
5611
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
5988
+ default: withCtx(() => [
5612
5989
  createTextVNode(
5613
- "\u91CD\u547D\u540D",
5614
- -1
5615
- /* CACHED */
5990
+ toDisplayString(unref(dict).conversations.rename),
5991
+ 1
5992
+ /* TEXT */
5616
5993
  )
5617
- ])]),
5994
+ ]),
5618
5995
  _: 1
5619
5996
  /* STABLE */
5620
5997
  }),
5621
5998
  createVNode(unref(ElDropdownItem), { command: "delete" }, {
5622
- default: withCtx(() => [..._cache[2] || (_cache[2] = [
5999
+ default: withCtx(() => [
5623
6000
  createTextVNode(
5624
- "\u5220\u9664",
5625
- -1
5626
- /* CACHED */
6001
+ toDisplayString(unref(dict).conversations.delete),
6002
+ 1
6003
+ /* TEXT */
5627
6004
  )
5628
- ])]),
6005
+ ]),
5629
6006
  _: 1
5630
6007
  /* STABLE */
5631
6008
  })
@@ -5642,7 +6019,7 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5642
6019
  createElementVNode("button", {
5643
6020
  type: "button",
5644
6021
  class: "fv-conversations-menu-btn",
5645
- "aria-label": "\u4F1A\u8BDD\u64CD\u4F5C",
6022
+ "aria-label": unref(dict).conversations.menuLabel,
5646
6023
  onClick: _cache[0] || (_cache[0] = withModifiers(() => {
5647
6024
  }, ["stop"]))
5648
6025
  }, [
@@ -5653,7 +6030,7 @@ var _sfc_main$4 = /* @__PURE__ */ defineComponent({
5653
6030
  _: 1
5654
6031
  /* STABLE */
5655
6032
  })
5656
- ])
6033
+ ], 8, _hoisted_5$1)
5657
6034
  ]),
5658
6035
  _: 2
5659
6036
  /* DYNAMIC */
@@ -5760,7 +6137,7 @@ function OpenAIAdapter(config) {
5760
6137
  return;
5761
6138
  }
5762
6139
  if (!res.body) {
5763
- handlers.onError(new Error("\u54CD\u5E94\u65E0 body"));
6140
+ handlers.onError(new Error(getGlobalLocale().errors.noBody));
5764
6141
  return;
5765
6142
  }
5766
6143
  const parser = createSSEParser((ev) => {
@@ -6064,6 +6441,7 @@ function lastAssistant(chain) {
6064
6441
  return void 0;
6065
6442
  }
6066
6443
  function useChat(options) {
6444
+ const dict = () => options.locale ? options.locale() : getGlobalLocale();
6067
6445
  function resolveModels() {
6068
6446
  if (!options.models) return [""];
6069
6447
  return typeof options.models === "function" ? options.models() : options.models;
@@ -6081,11 +6459,10 @@ function useChat(options) {
6081
6459
  const fileParts = [];
6082
6460
  for (const m of chain) {
6083
6461
  if (m.files?.length) {
6084
- fileParts.push(m.files.map((f) => `[\u9644\u4EF6] ${f.name}${f.type === "image" ? "(\u56FE\u7247)" : ""}`).join("\n"));
6462
+ fileParts.push(m.files.map((f) => dict().chat.fileTag.split("{name}").join(f.name) + (f.type === "image" ? dict().chat.fileImageTag : "")).join("\n"));
6085
6463
  }
6086
6464
  }
6087
- if (fileParts.length) out.push({ role: "system", content: `\u7528\u6237\u968F\u6D88\u606F\u63D0\u4F9B\u4E86\u4EE5\u4E0B\u6587\u4EF6:
6088
- ${fileParts.join("\n")}` });
6465
+ if (fileParts.length) out.push({ role: "system", content: dict().chat.filesSystemPrompt.split("{files}").join(fileParts.join("\n")) });
6089
6466
  if (extraSystem) out.push({ role: "system", content: extraSystem });
6090
6467
  for (const m of chain) {
6091
6468
  if (m.role === "assistant" && !m.content) continue;
@@ -6157,7 +6534,7 @@ ${fileParts.join("\n")}` });
6157
6534
  ...steps[i],
6158
6535
  status: "success",
6159
6536
  // 用时回写 description(历史回放同款);丢 start 的补 done 步无起点,保持原 description
6160
- description: typeof startedAt === "number" ? `\u7528\u65F6 ${((Date.now() - startedAt) / 1e3).toFixed(1)}s` : steps[i].description
6537
+ description: typeof startedAt === "number" ? dict().chat.toolDuration.split("{s}").join(`${((Date.now() - startedAt) / 1e3).toFixed(1)}s`) : steps[i].description
6161
6538
  };
6162
6539
  }
6163
6540
  msgs.edit(assistantId, { toolSteps: steps });
@@ -6243,7 +6620,7 @@ ${fileParts.join("\n")}` });
6243
6620
  msgs.setCurrent(target.id);
6244
6621
  isLoading.value = true;
6245
6622
  try {
6246
- const req = buildRequestMessages("\u8BF7\u57FA\u4E8E\u4EE5\u4E0A\u5185\u5BB9\u7EE7\u7EED\u5B8C\u6210\u56DE\u7B54,\u4E0D\u8981\u91CD\u590D\u5DF2\u6709\u5185\u5BB9\u3002");
6623
+ const req = buildRequestMessages(dict().chat.continuePrompt);
6247
6624
  await generateInto(target.id, req, target.model);
6248
6625
  } finally {
6249
6626
  isLoading.value = false;
@@ -6277,7 +6654,7 @@ const _hoisted_2$3 = {
6277
6654
  class: "fv-msg-avatar"
6278
6655
  };
6279
6656
  const _hoisted_3$3 = ["src"];
6280
- const _hoisted_4$2 = ["src"];
6657
+ const _hoisted_4$1 = ["src"];
6281
6658
  const _hoisted_5 = { class: "fv-msg-main" };
6282
6659
  const _hoisted_6 = {
6283
6660
  key: 0,
@@ -6336,11 +6713,14 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6336
6713
  assistantName: { type: String, required: false, default: "" },
6337
6714
  autoCollapse: { type: Boolean, required: false, default: true },
6338
6715
  typing: { type: [Boolean, Object], required: false, default: false },
6339
- collapsible: { type: Boolean, required: false, default: false }
6716
+ collapsible: { type: Boolean, required: false, default: false },
6717
+ codeTriggerLangs: { type: Array, required: false },
6718
+ locale: { type: null, required: false }
6340
6719
  },
6341
6720
  emits: ["copy", "regenerate", "branch-change", "typing"],
6342
6721
  setup(__props, { expose: __expose, emit: __emit }) {
6343
6722
  const props = __props;
6723
+ const dict = useLocaleDict(() => props.locale);
6344
6724
  const emit = __emit;
6345
6725
  const isUser = computed(() => props.message.role === "user");
6346
6726
  const thinkingStatus = computed(() => {
@@ -6388,10 +6768,10 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6388
6768
  }
6389
6769
  if (running) {
6390
6770
  const loading = s.status !== "error" && s.status !== "success";
6391
- return loading ? { ...s, status: "loading", title: `\u6B63\u5728\u67E5\u8BE2${s.title ?? ""}` } : { ...s, icon: toolStepIcon, title: `\u5DF2\u67E5\u8BE2${s.title ?? ""}` };
6771
+ return loading ? { ...s, status: "loading", title: dict.value.aiMessage.querying + (s.title ?? "") } : { ...s, icon: toolStepIcon, title: dict.value.aiMessage.queried + (s.title ?? "") };
6392
6772
  }
6393
6773
  const settled = s.status === "success" || s.status === "error" ? s.status : props.message.status === "error" ? "error" : "success";
6394
- return { ...s, status: settled, icon: toolStepIcon, title: `\u5DF2\u67E5\u8BE2${s.title ?? ""}` };
6774
+ return { ...s, status: settled, icon: toolStepIcon, title: dict.value.aiMessage.queried + (s.title ?? "") };
6395
6775
  });
6396
6776
  });
6397
6777
  const modelLabel = computed(() => props.message.model ?? "");
@@ -6410,7 +6790,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6410
6790
  class: normalizeClass(["fv-msg", [`is-${__props.message.role}`, { "is-error": __props.message.status === "error", "is-user": isUser.value }]]),
6411
6791
  "data-message-id": __props.message.id
6412
6792
  }, [
6413
- createCommentVNode(" \u5934\u50CF:user \u53F3\u4FA7(\u81EA\u8EAB),assistant \u5DE6\u4FA7;\u663E\u9690\u5F00\u5173\u5173\u95ED\u65F6\u4E0D\u6E32\u67D3;\n \u4F18\u5148\u7EA7:message-avatar \u6574\u4F53\u63D2\u69FD > user-avatar/assistant-avatar \u7EC6\u5206\u63D2\u69FD > props \u56FE\u7247 > \u5185\u7F6E\u56FE\u6807 "),
6793
+ createCommentVNode(" \u5934\u50CF:user \u53F3\u4FA7(\u81EA\u8EAB),assistant \u5DE6\u4FA7;\u663E\u9690\u5F00\u5173\u5173\u95ED\u65F6\u4E0D\u6E32\u67D3;\r\n \u4F18\u5148\u7EA7:message-avatar \u6574\u4F53\u63D2\u69FD > user-avatar/assistant-avatar \u7EC6\u5206\u63D2\u69FD > props \u56FE\u7247 > \u5185\u7F6E\u56FE\u6807 "),
6414
6794
  (isUser.value ? __props.showUserAvatar : __props.showAssistantAvatar) ? (openBlock(), createElementBlock("div", _hoisted_2$3, [
6415
6795
  renderSlot(_ctx.$slots, "message-avatar", { message: __props.message }, () => [
6416
6796
  isUser.value ? renderSlot(_ctx.$slots, "user-avatar", {}, () => [
@@ -6437,7 +6817,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6437
6817
  class: "fv-msg-avatar-img",
6438
6818
  src: __props.assistantAvatar || unref(defaultAssistantAvatar),
6439
6819
  alt: ""
6440
- }, null, 8, _hoisted_4$2)
6820
+ }, null, 8, _hoisted_4$1)
6441
6821
  ], void 0, 1)
6442
6822
  ])
6443
6823
  ])) : createCommentVNode("v-if", true),
@@ -6446,13 +6826,13 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6446
6826
  (isUser.value ? __props.showUserName : __props.showAssistantName) ? (openBlock(), createElementBlock("div", _hoisted_6, [
6447
6827
  isUser.value ? renderSlot(_ctx.$slots, "user-name", { message: __props.message }, () => [
6448
6828
  createTextVNode(
6449
- toDisplayString(__props.userName || "\u4F60"),
6829
+ toDisplayString(__props.userName || unref(dict).aiMessage.defaultUserName),
6450
6830
  1
6451
6831
  /* TEXT */
6452
6832
  )
6453
6833
  ], void 0, 0) : renderSlot(_ctx.$slots, "assistant-name", { message: __props.message }, () => [
6454
6834
  createTextVNode(
6455
- toDisplayString(__props.assistantName || "\u5C0F\u7EF4"),
6835
+ toDisplayString(__props.assistantName || unref(dict).aiMessage.defaultAssistantName),
6456
6836
  1
6457
6837
  /* TEXT */
6458
6838
  )
@@ -6504,7 +6884,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6504
6884
  ))
6505
6885
  ])
6506
6886
  ])) : createCommentVNode("v-if", true),
6507
- createCommentVNode(" \u601D\u8003\u94FE(assistant \u542B toolSteps/reasoning \u65F6):Thinking \u6298\u53E0\u5934\u627F\u8F7D\u72B6\u6001\u6587\u6848\u4E0E\n \u6536\u8D77/\u5C55\u5F00(\u6D41\u5F0F\u9ED8\u8BA4\u5C55\u5F00\u770B\u8FDB\u5EA6,\u843D\u5B9A/\u5386\u53F2\u6536\u8D77,\u70B9\u51FB\u56DE\u770B);\u601D\u8003\u6BB5\u6B65\u4E0E\u5DE5\u5177\u6B65\n \u7ECF ThoughtChain \u7EB5\u5411\u6B65\u9AA4\u94FE\u6309\u53D1\u751F\u987A\u5E8F\u6DF7\u6392(\u601D\u8003\u6587\u672C\u7EC7\u5165\u94FE\u4E0A text \u6B65),\u6B63\u6587\u4E4B\u4E0A;\n \u4EC5 reasoning \u65E0 toolSteps \u65F6(\u7EAF\u601D\u8003\u6D88\u606F)\u56DE\u843D\u94FE\u4E0B Markdown \u6E32\u67D3 "),
6887
+ createCommentVNode(" \u601D\u8003\u94FE(assistant \u542B toolSteps/reasoning \u65F6):Thinking \u6298\u53E0\u5934\u627F\u8F7D\u72B6\u6001\u6587\u6848\u4E0E\r\n \u6536\u8D77/\u5C55\u5F00(\u6D41\u5F0F\u9ED8\u8BA4\u5C55\u5F00\u770B\u8FDB\u5EA6,\u843D\u5B9A/\u5386\u53F2\u6536\u8D77,\u70B9\u51FB\u56DE\u770B);\u601D\u8003\u6BB5\u6B65\u4E0E\u5DE5\u5177\u6B65\r\n \u7ECF ThoughtChain \u7EB5\u5411\u6B65\u9AA4\u94FE\u6309\u53D1\u751F\u987A\u5E8F\u6DF7\u6392(\u601D\u8003\u6587\u672C\u7EC7\u5165\u94FE\u4E0A text \u6B65),\u6B63\u6587\u4E4B\u4E0A;\r\n \u4EC5 reasoning \u65E0 toolSteps \u65F6(\u7EAF\u601D\u8003\u6D88\u606F)\u56DE\u843D\u94FE\u4E0B Markdown \u6E32\u67D3 "),
6508
6888
  !isUser.value && (hasToolSteps.value || hasReasoning.value) ? (openBlock(), createBlock(_sfc_main$a, {
6509
6889
  key: 2,
6510
6890
  modelValue: toolsExpanded.value,
@@ -6538,7 +6918,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6538
6918
  __props.message.status === "error" ? (openBlock(), createElementBlock(
6539
6919
  "span",
6540
6920
  _hoisted_12,
6541
- toDisplayString(__props.message.error || "\u751F\u6210\u5931\u8D25"),
6921
+ toDisplayString(__props.message.error || unref(dict).aiMessage.generateFailed),
6542
6922
  1
6543
6923
  /* TEXT */
6544
6924
  )) : useTypewriter.value && __props.message.content ? (openBlock(), createBlock(_sfc_main$h, {
@@ -6546,11 +6926,13 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6546
6926
  content: __props.message.content,
6547
6927
  "is-markdown": "",
6548
6928
  typing: __props.typing,
6929
+ "code-trigger-langs": __props.codeTriggerLangs,
6549
6930
  onWriting: _cache[3] || (_cache[3] = ($event) => emit("typing"))
6550
- }, null, 8, ["content", "typing"])) : __props.message.content ? (openBlock(), createBlock(_sfc_main$i, {
6931
+ }, null, 8, ["content", "typing", "code-trigger-langs"])) : __props.message.content ? (openBlock(), createBlock(_sfc_main$i, {
6551
6932
  key: 2,
6552
- content: __props.message.content
6553
- }, null, 8, ["content"])) : (__props.message.status === "pending" || __props.message.status === "streaming") && !hasToolSteps.value ? (openBlock(), createElementBlock(
6933
+ content: __props.message.content,
6934
+ "code-trigger-langs": __props.codeTriggerLangs
6935
+ }, null, 8, ["content", "code-trigger-langs"])) : (__props.message.status === "pending" || __props.message.status === "streaming") && !hasToolSteps.value ? (openBlock(), createElementBlock(
6554
6936
  Fragment,
6555
6937
  { key: 3 },
6556
6938
  [
@@ -6592,7 +6974,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6592
6974
  renderSlot(_ctx.$slots, "message-actions", { message: __props.message }, () => [
6593
6975
  __props.showActions && isUser.value ? (openBlock(), createBlock(unref(ElTooltip), {
6594
6976
  key: 0,
6595
- content: "\u590D\u5236",
6977
+ content: unref(dict).aiMessage.copy,
6596
6978
  placement: "top"
6597
6979
  }, {
6598
6980
  default: withCtx(() => [
@@ -6600,7 +6982,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6600
6982
  text: "",
6601
6983
  size: "small",
6602
6984
  class: "fv-msg-action",
6603
- "aria-label": "\u590D\u5236",
6985
+ "aria-label": unref(dict).aiMessage.copy,
6604
6986
  onClick: onCopy
6605
6987
  }, {
6606
6988
  default: withCtx(() => [
@@ -6614,14 +6996,14 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6614
6996
  ]),
6615
6997
  _: 1
6616
6998
  /* STABLE */
6617
- })
6999
+ }, 8, ["aria-label"])
6618
7000
  ]),
6619
7001
  _: 1
6620
7002
  /* STABLE */
6621
- })) : createCommentVNode("v-if", true),
7003
+ }, 8, ["content"])) : createCommentVNode("v-if", true),
6622
7004
  __props.showActions && !isUser.value ? (openBlock(), createBlock(unref(ElTooltip), {
6623
7005
  key: 1,
6624
- content: "\u590D\u5236",
7006
+ content: unref(dict).aiMessage.copy,
6625
7007
  placement: "top"
6626
7008
  }, {
6627
7009
  default: withCtx(() => [
@@ -6629,7 +7011,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6629
7011
  text: "",
6630
7012
  size: "small",
6631
7013
  class: "fv-msg-action",
6632
- "aria-label": "\u590D\u5236",
7014
+ "aria-label": unref(dict).aiMessage.copy,
6633
7015
  onClick: onCopy
6634
7016
  }, {
6635
7017
  default: withCtx(() => [
@@ -6643,14 +7025,14 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6643
7025
  ]),
6644
7026
  _: 1
6645
7027
  /* STABLE */
6646
- })
7028
+ }, 8, ["aria-label"])
6647
7029
  ]),
6648
7030
  _: 1
6649
7031
  /* STABLE */
6650
- })) : createCommentVNode("v-if", true),
7032
+ }, 8, ["content"])) : createCommentVNode("v-if", true),
6651
7033
  __props.showActions && !isUser.value ? (openBlock(), createBlock(unref(ElTooltip), {
6652
7034
  key: 2,
6653
- content: "\u91CD\u65B0\u751F\u6210",
7035
+ content: unref(dict).aiMessage.regenerate,
6654
7036
  placement: "top"
6655
7037
  }, {
6656
7038
  default: withCtx(() => [
@@ -6658,7 +7040,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6658
7040
  text: "",
6659
7041
  size: "small",
6660
7042
  class: "fv-msg-action",
6661
- "aria-label": "\u91CD\u65B0\u751F\u6210",
7043
+ "aria-label": unref(dict).aiMessage.regenerate,
6662
7044
  onClick: onRegenerate
6663
7045
  }, {
6664
7046
  default: withCtx(() => [
@@ -6672,11 +7054,11 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6672
7054
  ]),
6673
7055
  _: 1
6674
7056
  /* STABLE */
6675
- })
7057
+ }, 8, ["aria-label"])
6676
7058
  ]),
6677
7059
  _: 1
6678
7060
  /* STABLE */
6679
- })) : createCommentVNode("v-if", true)
7061
+ }, 8, ["content"])) : createCommentVNode("v-if", true)
6680
7062
  ]),
6681
7063
  createCommentVNode(" \u5206\u652F\u5207\u6362:\u5144\u5F1F\u5206\u652F > 1 \u65F6 "),
6682
7064
  __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("span", _hoisted_16, [
@@ -6685,7 +7067,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6685
7067
  size: "small",
6686
7068
  class: "fv-msg-action",
6687
7069
  disabled: __props.branch.index <= 1,
6688
- "aria-label": "\u4E0A\u4E00\u5206\u652F",
7070
+ "aria-label": unref(dict).aiMessage.prevBranch,
6689
7071
  onClick: _cache[4] || (_cache[4] = ($event) => onBranch("prev"))
6690
7072
  }, {
6691
7073
  default: withCtx(() => [
@@ -6699,7 +7081,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6699
7081
  ]),
6700
7082
  _: 1
6701
7083
  /* STABLE */
6702
- }, 8, ["disabled"]),
7084
+ }, 8, ["disabled", "aria-label"]),
6703
7085
  createElementVNode(
6704
7086
  "span",
6705
7087
  _hoisted_17,
@@ -6712,7 +7094,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6712
7094
  size: "small",
6713
7095
  class: "fv-msg-action",
6714
7096
  disabled: __props.branch.index >= __props.branch.count,
6715
- "aria-label": "\u4E0B\u4E00\u5206\u652F",
7097
+ "aria-label": unref(dict).aiMessage.nextBranch,
6716
7098
  onClick: _cache[5] || (_cache[5] = ($event) => onBranch("next"))
6717
7099
  }, {
6718
7100
  default: withCtx(() => [
@@ -6726,7 +7108,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
6726
7108
  ]),
6727
7109
  _: 1
6728
7110
  /* STABLE */
6729
- }, 8, ["disabled"])
7111
+ }, 8, ["disabled", "aria-label"])
6730
7112
  ])) : createCommentVNode("v-if", true)
6731
7113
  ])) : createCommentVNode("v-if", true)
6732
7114
  ])
@@ -6766,11 +7148,14 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6766
7148
  userName: { type: String, required: false, default: "" },
6767
7149
  assistantName: { type: String, required: false, default: "" },
6768
7150
  typing: { type: [Boolean, Object], required: false, default: false },
6769
- collapsible: { type: Boolean, required: false, default: false }
7151
+ collapsible: { type: Boolean, required: false, default: false },
7152
+ codeTriggerLangs: { type: Array, required: false },
7153
+ locale: { type: null, required: false }
6770
7154
  },
6771
7155
  emits: ["select", "copy", "regenerate", "branch-change"],
6772
7156
  setup(__props, { expose: __expose, emit: __emit }) {
6773
7157
  const props = __props;
7158
+ const dict = useLocaleDict(() => props.locale);
6774
7159
  const emit = __emit;
6775
7160
  function onChildTyping() {
6776
7161
  followIfPinned();
@@ -6924,6 +7309,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6924
7309
  "assistant-name": __props.assistantName,
6925
7310
  typing: __props.typing,
6926
7311
  collapsible: __props.collapsible,
7312
+ "code-trigger-langs": __props.codeTriggerLangs,
6927
7313
  onTyping: onChildTyping,
6928
7314
  onCopy,
6929
7315
  onRegenerate,
@@ -6974,7 +7360,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6974
7360
  ]),
6975
7361
  key: "5"
6976
7362
  } : void 0
6977
- ]), 1032, ["message", "branch", "show-actions", "show-branch-switch", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing", "collapsible"]);
7363
+ ]), 1032, ["message", "branch", "show-actions", "show-branch-switch", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing", "collapsible", "code-trigger-langs"]);
6978
7364
  }),
6979
7365
  128
6980
7366
  /* KEYED_FRAGMENT */
@@ -6990,7 +7376,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
6990
7376
  key: 0,
6991
7377
  class: "fv-messages-back",
6992
7378
  circle: "",
6993
- "aria-label": "\u6EDA\u52A8\u5230\u5E95\u90E8",
7379
+ "aria-label": unref(dict).scroll.toBottom,
6994
7380
  onClick: _cache[0] || (_cache[0] = ($event) => scrollToBottom())
6995
7381
  }, {
6996
7382
  default: withCtx(() => [
@@ -7006,7 +7392,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
7006
7392
  ]),
7007
7393
  _: 3
7008
7394
  /* FORWARDED */
7009
- })) : createCommentVNode("v-if", true)
7395
+ }, 8, ["aria-label"])) : createCommentVNode("v-if", true)
7010
7396
  ])
7011
7397
  ]),
7012
7398
  _: 3
@@ -7026,13 +7412,9 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
7026
7412
  }
7027
7413
  });
7028
7414
 
7029
- const _hoisted_1$1 = {
7030
- key: 0,
7031
- class: "fv-artifacts"
7032
- };
7033
- const _hoisted_2$1 = { class: "fv-artifacts-tabs" };
7034
- const _hoisted_3$1 = ["onClick"];
7035
- const _hoisted_4$1 = ["srcdoc"];
7415
+ const _hoisted_1$1 = { class: "fv-artifacts-tabs" };
7416
+ const _hoisted_2$1 = ["onClick"];
7417
+ const _hoisted_3$1 = ["srcdoc"];
7036
7418
  const NAV_SCRIPT = `<script>(function(){
7037
7419
  document.addEventListener('click',function(e){
7038
7420
  var t=e.target&&e.target.closest?e.target.closest('a'):null;
@@ -7045,11 +7427,16 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
7045
7427
  __name: "index",
7046
7428
  props: {
7047
7429
  artifacts: { type: Array, required: true, default: () => [] },
7048
- activeKey: { type: String, required: false, default: "" }
7430
+ activeKey: { type: String, required: false, default: "" },
7431
+ width: { type: String, required: false, default: "420px" },
7432
+ minWidth: { type: String, required: false, default: "360px" },
7433
+ maxWidth: { type: String, required: false, default: "60%" },
7434
+ locale: { type: null, required: false }
7049
7435
  },
7050
7436
  emits: ["close", "change", "navigate"],
7051
7437
  setup(__props, { expose: __expose, emit: __emit }) {
7052
7438
  const props = __props;
7439
+ const dict = useLocaleDict(() => props.locale);
7053
7440
  const emit = __emit;
7054
7441
  const visible = ref(props.activeKey !== "");
7055
7442
  watch(() => props.activeKey, (k) => {
@@ -7135,143 +7522,157 @@ var _sfc_main$1 = /* @__PURE__ */ defineComponent({
7135
7522
  Fragment,
7136
7523
  null,
7137
7524
  [
7138
- createCommentVNode(" activeKey \u4E3A\u7A7A\u65F6\u4E0D\u6E32\u67D3\u9762\u677F "),
7139
- visible.value && current.value ? (openBlock(), createElementBlock("div", _hoisted_1$1, [
7140
- createCommentVNode(" tab \u5207\u6362\u680F "),
7141
- createElementVNode("div", _hoisted_2$1, [
7142
- (openBlock(true), createElementBlock(
7143
- Fragment,
7144
- null,
7145
- renderList(__props.artifacts, (a) => {
7146
- return openBlock(), createElementBlock("button", {
7147
- key: a.key,
7148
- type: "button",
7149
- class: normalizeClass(["fv-artifact-tab", { "is-active": a.key === currentKey.value }]),
7150
- onClick: ($event) => select(a.key)
7151
- }, toDisplayString(a.title || a.key), 11, _hoisted_3$1);
7152
- }),
7153
- 128
7154
- /* KEYED_FRAGMENT */
7155
- )),
7156
- _cache[0] || (_cache[0] = createElementVNode(
7157
- "span",
7158
- { class: "fv-artifacts-spacer" },
7159
- null,
7160
- -1
7161
- /* CACHED */
7162
- )),
7163
- createVNode(unref(ElTooltip), {
7164
- content: "\u590D\u5236",
7165
- placement: "top"
7166
- }, {
7167
- default: withCtx(() => [
7168
- createVNode(unref(ElButton), {
7169
- text: "",
7170
- size: "small",
7171
- "aria-label": "\u590D\u5236",
7172
- onClick: onCopy
7173
- }, {
7174
- default: withCtx(() => [
7175
- createVNode(unref(ElIcon), null, {
7176
- default: withCtx(() => [
7177
- createVNode(unref(CopyDocument))
7178
- ]),
7179
- _: 1
7180
- /* STABLE */
7181
- })
7182
- ]),
7183
- _: 1
7184
- /* STABLE */
7185
- })
7186
- ]),
7187
- _: 1
7188
- /* STABLE */
7189
- }),
7190
- createVNode(unref(ElTooltip), {
7191
- content: "\u4E0B\u8F7D",
7192
- placement: "top"
7193
- }, {
7194
- default: withCtx(() => [
7195
- createVNode(unref(ElButton), {
7196
- text: "",
7197
- size: "small",
7198
- "aria-label": "\u4E0B\u8F7D",
7199
- onClick: onDownload
7200
- }, {
7201
- default: withCtx(() => [
7202
- createVNode(unref(ElIcon), null, {
7203
- default: withCtx(() => [
7204
- createVNode(unref(Download))
7205
- ]),
7206
- _: 1
7207
- /* STABLE */
7208
- })
7209
- ]),
7210
- _: 1
7211
- /* STABLE */
7212
- })
7213
- ]),
7214
- _: 1
7215
- /* STABLE */
7216
- }),
7217
- current.value?.type === "html" ? (openBlock(), createBlock(unref(ElTooltip), {
7218
- key: 0,
7219
- content: "\u5168\u5C4F",
7220
- placement: "top"
7221
- }, {
7222
- default: withCtx(() => [
7223
- createVNode(unref(ElButton), {
7224
- text: "",
7225
- size: "small",
7226
- "aria-label": "\u5168\u5C4F",
7227
- onClick: onFullscreen
7228
- }, {
7229
- default: withCtx(() => [
7230
- createVNode(unref(ElIcon), null, {
7231
- default: withCtx(() => [
7232
- createVNode(unref(FullScreen))
7233
- ]),
7234
- _: 1
7235
- /* STABLE */
7236
- })
7237
- ]),
7238
- _: 1
7239
- /* STABLE */
7240
- })
7241
- ]),
7242
- _: 1
7243
- /* STABLE */
7244
- })) : createCommentVNode("v-if", true),
7245
- createVNode(unref(ElButton), {
7246
- text: "",
7247
- size: "small",
7248
- class: "fv-artifacts-close",
7249
- "aria-label": "\u5173\u95ED",
7250
- onClick: onClose
7251
- }, {
7252
- default: withCtx(() => [
7253
- createVNode(unref(ElIcon), null, {
7254
- default: withCtx(() => [
7255
- createVNode(unref(Close))
7256
- ]),
7257
- _: 1
7258
- /* STABLE */
7259
- })
7260
- ]),
7261
- _: 1
7262
- /* STABLE */
7525
+ createCommentVNode(" activeKey \u4E3A\u7A7A\u65F6\u4E0D\u6E32\u67D3\u9762\u677F;\u5BBD\u5EA6\u7ECF CSS \u53D8\u91CF\u843D\u5730(width/min/max),\u6D88\u8D39\u65B9\u4EA6\u53EF\u7528\r\n --fv-artifacts-width \u7B49\u53D8\u91CF\u6574\u4F53\u8986\u76D6 "),
7526
+ visible.value && current.value ? (openBlock(), createElementBlock(
7527
+ "div",
7528
+ {
7529
+ key: 0,
7530
+ class: "fv-artifacts",
7531
+ style: normalizeStyle({
7532
+ "--fv-artifacts-width": __props.width,
7533
+ "--fv-artifacts-min-width": __props.minWidth,
7534
+ "--fv-artifacts-max-width": __props.maxWidth
7263
7535
  })
7264
- ]),
7265
- createCommentVNode(" iframe \u6C99\u7BB1\u9884\u89C8 "),
7266
- createElementVNode("iframe", {
7267
- ref_key: "iframeRef",
7268
- ref: iframeRef,
7269
- class: "fv-artifacts-frame",
7270
- srcdoc: srcdoc.value,
7271
- sandbox: "allow-scripts allow-downloads",
7272
- title: "artifact-preview"
7273
- }, null, 8, _hoisted_4$1)
7274
- ])) : createCommentVNode("v-if", true)
7536
+ },
7537
+ [
7538
+ createCommentVNode(" tab \u5207\u6362\u680F "),
7539
+ createElementVNode("div", _hoisted_1$1, [
7540
+ (openBlock(true), createElementBlock(
7541
+ Fragment,
7542
+ null,
7543
+ renderList(__props.artifacts, (a) => {
7544
+ return openBlock(), createElementBlock("button", {
7545
+ key: a.key,
7546
+ type: "button",
7547
+ class: normalizeClass(["fv-artifact-tab", { "is-active": a.key === currentKey.value }]),
7548
+ onClick: ($event) => select(a.key)
7549
+ }, toDisplayString(a.title || a.key), 11, _hoisted_2$1);
7550
+ }),
7551
+ 128
7552
+ /* KEYED_FRAGMENT */
7553
+ )),
7554
+ _cache[0] || (_cache[0] = createElementVNode(
7555
+ "span",
7556
+ { class: "fv-artifacts-spacer" },
7557
+ null,
7558
+ -1
7559
+ /* CACHED */
7560
+ )),
7561
+ createVNode(unref(ElTooltip), {
7562
+ content: unref(dict).aiArtifacts.copy,
7563
+ placement: "top"
7564
+ }, {
7565
+ default: withCtx(() => [
7566
+ createVNode(unref(ElButton), {
7567
+ text: "",
7568
+ size: "small",
7569
+ "aria-label": unref(dict).aiArtifacts.copy,
7570
+ onClick: onCopy
7571
+ }, {
7572
+ default: withCtx(() => [
7573
+ createVNode(unref(ElIcon), null, {
7574
+ default: withCtx(() => [
7575
+ createVNode(unref(CopyDocument))
7576
+ ]),
7577
+ _: 1
7578
+ /* STABLE */
7579
+ })
7580
+ ]),
7581
+ _: 1
7582
+ /* STABLE */
7583
+ }, 8, ["aria-label"])
7584
+ ]),
7585
+ _: 1
7586
+ /* STABLE */
7587
+ }, 8, ["content"]),
7588
+ createVNode(unref(ElTooltip), {
7589
+ content: unref(dict).aiArtifacts.download,
7590
+ placement: "top"
7591
+ }, {
7592
+ default: withCtx(() => [
7593
+ createVNode(unref(ElButton), {
7594
+ text: "",
7595
+ size: "small",
7596
+ "aria-label": unref(dict).aiArtifacts.download,
7597
+ onClick: onDownload
7598
+ }, {
7599
+ default: withCtx(() => [
7600
+ createVNode(unref(ElIcon), null, {
7601
+ default: withCtx(() => [
7602
+ createVNode(unref(Download))
7603
+ ]),
7604
+ _: 1
7605
+ /* STABLE */
7606
+ })
7607
+ ]),
7608
+ _: 1
7609
+ /* STABLE */
7610
+ }, 8, ["aria-label"])
7611
+ ]),
7612
+ _: 1
7613
+ /* STABLE */
7614
+ }, 8, ["content"]),
7615
+ current.value?.type === "html" ? (openBlock(), createBlock(unref(ElTooltip), {
7616
+ key: 0,
7617
+ content: unref(dict).aiArtifacts.fullscreen,
7618
+ placement: "top"
7619
+ }, {
7620
+ default: withCtx(() => [
7621
+ createVNode(unref(ElButton), {
7622
+ text: "",
7623
+ size: "small",
7624
+ "aria-label": unref(dict).aiArtifacts.fullscreen,
7625
+ onClick: onFullscreen
7626
+ }, {
7627
+ default: withCtx(() => [
7628
+ createVNode(unref(ElIcon), null, {
7629
+ default: withCtx(() => [
7630
+ createVNode(unref(FullScreen))
7631
+ ]),
7632
+ _: 1
7633
+ /* STABLE */
7634
+ })
7635
+ ]),
7636
+ _: 1
7637
+ /* STABLE */
7638
+ }, 8, ["aria-label"])
7639
+ ]),
7640
+ _: 1
7641
+ /* STABLE */
7642
+ }, 8, ["content"])) : createCommentVNode("v-if", true),
7643
+ createVNode(unref(ElButton), {
7644
+ text: "",
7645
+ size: "small",
7646
+ class: "fv-artifacts-close",
7647
+ "aria-label": unref(dict).aiArtifacts.close,
7648
+ onClick: onClose
7649
+ }, {
7650
+ default: withCtx(() => [
7651
+ createVNode(unref(ElIcon), null, {
7652
+ default: withCtx(() => [
7653
+ createVNode(unref(Close))
7654
+ ]),
7655
+ _: 1
7656
+ /* STABLE */
7657
+ })
7658
+ ]),
7659
+ _: 1
7660
+ /* STABLE */
7661
+ }, 8, ["aria-label"])
7662
+ ]),
7663
+ createCommentVNode(" iframe \u6C99\u7BB1\u9884\u89C8 "),
7664
+ createElementVNode("iframe", {
7665
+ ref_key: "iframeRef",
7666
+ ref: iframeRef,
7667
+ class: "fv-artifacts-frame",
7668
+ srcdoc: srcdoc.value,
7669
+ sandbox: "allow-scripts allow-downloads",
7670
+ title: "artifact-preview"
7671
+ }, null, 8, _hoisted_3$1)
7672
+ ],
7673
+ 4
7674
+ /* STYLE */
7675
+ )) : createCommentVNode("v-if", true)
7275
7676
  ],
7276
7677
  2112
7277
7678
  /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
@@ -7321,11 +7722,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7321
7722
  allowAttachments: { type: Boolean, required: false, default: false },
7322
7723
  accept: { type: String, required: false, default: "" },
7323
7724
  attachmentLimit: { type: Number, required: false, default: 0 },
7324
- theme: { type: String, required: false, default: "light" }
7725
+ theme: { type: String, required: false, default: "light" },
7726
+ locale: { type: null, required: false }
7325
7727
  },
7326
7728
  emits: ["update:messages", "send", "message-complete", "error", "branch-change", "attachment-exceed", "tool-event"],
7327
7729
  setup(__props, { expose: __expose, emit: __emit }) {
7328
7730
  const props = __props;
7731
+ const dict = useLocaleDict(() => props.locale);
7732
+ provideLocale(dict);
7329
7733
  const emit = __emit;
7330
7734
  function resolveAdapter() {
7331
7735
  if (props.adapter) return props.adapter;
@@ -7334,7 +7738,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7334
7738
  }
7335
7739
  return {
7336
7740
  async send(_req, handlers) {
7337
- handlers.onError(new Error("\u672A\u914D\u7F6E adapter \u6216 baseURL"));
7741
+ handlers.onError(new Error(dict.value.aiChat.adapterMissing));
7338
7742
  },
7339
7743
  abort() {
7340
7744
  }
@@ -7348,8 +7752,19 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7348
7752
  let initialId = null;
7349
7753
  if (props.messages?.length) {
7350
7754
  const table = {};
7755
+ let prevId = null;
7351
7756
  for (const m of props.messages) {
7352
- table[m.id] = JSON.parse(JSON.stringify(m));
7757
+ const node = JSON.parse(JSON.stringify(m));
7758
+ if (node.parentId === void 0) node.parentId = prevId;
7759
+ if (!Array.isArray(node.childrenIds)) node.childrenIds = [];
7760
+ table[node.id] = node;
7761
+ prevId = node.id;
7762
+ }
7763
+ for (const node of Object.values(table)) {
7764
+ if (node.parentId !== null) {
7765
+ const parent = table[node.parentId];
7766
+ if (parent && !parent.childrenIds.includes(node.id)) parent.childrenIds.push(node.id);
7767
+ }
7353
7768
  }
7354
7769
  initialTable = table;
7355
7770
  initialId = props.messages[props.messages.length - 1]?.id ?? null;
@@ -7361,7 +7776,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7361
7776
  // 与 adapter/models 同语义按工厂惰性取用:options 在 setup 构造一次,
7362
7777
  // 按值快照会把父组件运行期更换的函数 prop 冻在旧引用上(换了映射不生效)
7363
7778
  toolStepLabel: (name) => props.toolStepLabel ? props.toolStepLabel(name) : name,
7364
- onToolEvent: (ev) => emit("tool-event", ev)
7779
+ onToolEvent: (ev) => emit("tool-event", ev),
7780
+ locale: () => dict.value
7365
7781
  });
7366
7782
  const { send, stop: stopChat, regenerate: regenerateChat, msgs, isLoading } = chat;
7367
7783
  const nodeTable = chat.messages;
@@ -7380,7 +7796,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7380
7796
  if (stopped) return;
7381
7797
  const last = chain.value[chain.value.length - 1];
7382
7798
  if (!last || last.role !== "assistant") return;
7383
- if (last.status === "error") emit("error", new Error(last.error || "\u751F\u6210\u5931\u8D25"), last);
7799
+ if (last.status === "error") emit("error", new Error(last.error || dict.value.aiChat.generateFailed), last);
7384
7800
  else if (last.content) emit("message-complete", last);
7385
7801
  }
7386
7802
  function finishRun() {
@@ -7456,8 +7872,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7456
7872
  for (const id of Object.keys(nodeTable.value)) msgs.remove(id);
7457
7873
  }
7458
7874
  function exportTxt() {
7459
- return chain.value.map((m) => `${m.role === "user" ? "\u4F60" : "\u52A9\u624B"}: ${m.content}`).join("\n\n");
7875
+ return chain.value.map((m) => `${m.role === "user" ? dict.value.aiChat.exportUser : dict.value.aiChat.exportAssistant}: ${m.content}`).join("\n\n");
7460
7876
  }
7877
+ const artifactsOn = computed(() => !!props.features?.artifacts);
7878
+ const artifactsOpts = computed(
7879
+ () => typeof props.features?.artifacts === "object" ? props.features.artifacts : {}
7880
+ );
7881
+ const artifactsAutoOpen = computed(() => artifactsOpts.value.autoOpen !== false);
7882
+ const artifactsCodeTrigger = computed(() => artifactsOpts.value.codeBlockTrigger !== false);
7461
7883
  const CODE_BLOCK_RE = /```(html|svg)\s*\n([\s\S]*?)```/gi;
7462
7884
  function extractArtifacts(m) {
7463
7885
  const out = [];
@@ -7477,7 +7899,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7477
7899
  return out;
7478
7900
  }
7479
7901
  const artifacts = computed(() => {
7480
- if (!props.features?.artifacts) return [];
7902
+ if (!artifactsOn.value) return [];
7481
7903
  return chain.value.flatMap((m) => extractArtifacts(m));
7482
7904
  });
7483
7905
  const artifactActiveKey = ref("");
@@ -7496,9 +7918,29 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7496
7918
  artifactUserClosed = false;
7497
7919
  }
7498
7920
  watch(artifacts, (list) => {
7921
+ if (!artifactsAutoOpen.value) return;
7499
7922
  if (artifactUserClosed) return;
7500
7923
  if (list.length && !artifactActiveKey.value) artifactActiveKey.value = list[0].key;
7501
- });
7924
+ }, { immediate: true });
7925
+ function onBodyClick(e) {
7926
+ if (!artifactsOn.value || !artifactsCodeTrigger.value) return;
7927
+ const target = e.target;
7928
+ const btn = target?.closest?.("[data-fv-code-trigger]");
7929
+ if (!btn) return;
7930
+ e.preventDefault();
7931
+ const lang = btn.getAttribute("data-fv-code-trigger") ?? "";
7932
+ const msgEl = btn.closest(".fv-msg");
7933
+ const msgId = msgEl?.getAttribute("data-message-id") ?? "";
7934
+ if (!lang || !msgId || !msgEl) return;
7935
+ const pres = Array.from(msgEl.querySelectorAll("pre"));
7936
+ const pre = btn.closest("pre");
7937
+ const idx = pre ? pres.indexOf(pre) : -1;
7938
+ if (idx < 0) return;
7939
+ const key = `${msgId}:${idx}:${lang}`;
7940
+ if (!artifacts.value.some((a) => a.key === key)) return;
7941
+ artifactUserClosed = false;
7942
+ artifactActiveKey.value = key;
7943
+ }
7502
7944
  watch(artifacts, (list) => {
7503
7945
  if (artifactActiveKey.value && !list.some((a) => a.key === artifactActiveKey.value)) {
7504
7946
  artifactActiveKey.value = "";
@@ -7515,12 +7957,15 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7515
7957
  document.documentElement.classList.toggle("dark", isDark.value);
7516
7958
  }
7517
7959
  watch(isDark, applyTheme, { immediate: true });
7960
+ const rootEl = ref(null);
7518
7961
  onMounted(() => {
7519
7962
  media?.addEventListener("change", onMediaChange);
7520
7963
  applyTheme();
7964
+ rootEl.value?.addEventListener("click", onBodyClick);
7521
7965
  });
7522
7966
  onBeforeUnmount(() => {
7523
7967
  media?.removeEventListener("change", onMediaChange);
7968
+ rootEl.value?.removeEventListener("click", onBodyClick);
7524
7969
  if (typeof document !== "undefined") document.documentElement.classList.remove("dark");
7525
7970
  if (flushTimer) {
7526
7971
  clearTimeout(flushTimer);
@@ -7532,6 +7977,8 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7532
7977
  return openBlock(), createElementBlock(
7533
7978
  "div",
7534
7979
  {
7980
+ ref_key: "rootEl",
7981
+ ref: rootEl,
7535
7982
  class: normalizeClass(["fv-ai-chat", { "is-dark": isDark.value, "is-center-welcome": isCenterWelcome.value }])
7536
7983
  },
7537
7984
  [
@@ -7551,7 +7998,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7551
7998
  class: "fv-ai-chat-models",
7552
7999
  multiple: "",
7553
8000
  "collapse-tags": "",
7554
- placeholder: "\u6A21\u578B",
8001
+ placeholder: unref(dict).aiChat.modelPlaceholder,
7555
8002
  size: "small"
7556
8003
  }, {
7557
8004
  default: withCtx(() => [
@@ -7571,7 +8018,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7571
8018
  ]),
7572
8019
  _: 1
7573
8020
  /* STABLE */
7574
- }, 8, ["modelValue"])) : createCommentVNode("v-if", true)
8021
+ }, 8, ["modelValue", "placeholder"])) : createCommentVNode("v-if", true)
7575
8022
  ])) : createCommentVNode("v-if", true),
7576
8023
  createCommentVNode(" \u6D88\u606F\u533A:\u7A7A\u65F6 Welcome + Prompts(AiMessages \u5185\u7F6E);\u5F00\u542F artifacts \u65F6\u53F3\u4FA7\u62FC\u9884\u89C8\u9762\u677F "),
7577
8024
  createElementVNode("div", _hoisted_3, [
@@ -7593,6 +8040,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7593
8040
  "assistant-name": __props.assistantName,
7594
8041
  typing: __props.typing,
7595
8042
  collapsible: __props.collapsible,
8043
+ "code-trigger-langs": artifactsOn.value && artifactsCodeTrigger.value ? ["html", "svg"] : void 0,
7596
8044
  onSelect: onSelectSuggestion,
7597
8045
  onCopy,
7598
8046
  onRegenerate,
@@ -7664,14 +8112,17 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
7664
8112
  ]),
7665
8113
  key: "8"
7666
8114
  } : void 0
7667
- ]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "scroll-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing", "collapsible"]),
7668
- __props.features?.artifacts && artifacts.value.length ? (openBlock(), createBlock(_sfc_main$1, {
8115
+ ]), 1032, ["messages", "nodes", "name", "suggestions", "show-scroll-button", "scroll-button-threshold", "scroll-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "user-name", "assistant-name", "typing", "collapsible", "code-trigger-langs"]),
8116
+ artifactsOn.value && artifacts.value.length ? (openBlock(), createBlock(_sfc_main$1, {
7669
8117
  key: 0,
7670
8118
  artifacts: artifacts.value,
7671
8119
  "active-key": artifactActiveKey.value,
8120
+ width: artifactsOpts.value.width,
8121
+ "min-width": artifactsOpts.value.minWidth,
8122
+ "max-width": artifactsOpts.value.maxWidth,
7672
8123
  onClose: onArtifactClose,
7673
8124
  onChange: onArtifactChange
7674
- }, null, 8, ["artifacts", "active-key"])) : createCommentVNode("v-if", true)
8125
+ }, null, 8, ["artifacts", "active-key", "width", "min-width", "max-width"])) : createCommentVNode("v-if", true)
7675
8126
  ]),
7676
8127
  createCommentVNode(" \u8F93\u5165\u533A:Sender(\u4E0D\u4F20 allowSpeech,Task 15 \u6869\u4E0D\u63A5\u7EBF);\r\n allowAttachments \u5F00\u542F\u65F6:\u56DE\u5F62\u9488\u5728\u64CD\u4F5C\u680F\u5DE6\u4FA7(#action-left,\u4E0E\u63D0\u4EA4\u6309\u94AE\u540C\u884C),\r\n \u5DF2\u9009\u9644\u4EF6\u5217\u8868\u5728 fv-sender-body \u5185\u8F93\u5165\u884C\u4E0A\u65B9(#body-top,body-top:empty \u81EA\u52A8\u9690\u85CF) "),
7677
8128
  createElementVNode("div", _hoisted_4, [
@@ -7879,7 +8330,7 @@ function FvCommonAdapter(config) {
7879
8330
  function toError(code, message) {
7880
8331
  const c = typeof code === "number" ? code : void 0;
7881
8332
  const mapped = c !== void 0 ? errorMessages?.[c] : void 0;
7882
- return new FvCommonError(mapped ?? String(message ?? "\u8BF7\u6C42\u5931\u8D25"), c ?? code);
8333
+ return new FvCommonError(mapped ?? String(message ?? getGlobalLocale().errors.requestFailed), c ?? code);
7883
8334
  }
7884
8335
  return {
7885
8336
  async send(req, handlers) {
@@ -7889,7 +8340,7 @@ function FvCommonAdapter(config) {
7889
8340
  try {
7890
8341
  const sid = resolve(sessionId);
7891
8342
  if (!sid) {
7892
- handlers.onError(new FvCommonError("\u7F3A\u5C11 sessionId(\u4F1A\u8BDD\u672A\u521B\u5EFA\u6216\u672A\u9009\u4E2D)"));
8343
+ handlers.onError(new FvCommonError(getGlobalLocale().errors.sessionIdMissing));
7893
8344
  return;
7894
8345
  }
7895
8346
  const res = await fetch(`${baseURL.replace(/\/+$/, "")}/ai-chat/message/send`, {
@@ -7912,7 +8363,7 @@ function FvCommonAdapter(config) {
7912
8363
  return;
7913
8364
  }
7914
8365
  if (!res.body) {
7915
- handlers.onError(new FvCommonError("\u54CD\u5E94\u65E0 body"));
8366
+ handlers.onError(new FvCommonError(getGlobalLocale().errors.noBody));
7916
8367
  return;
7917
8368
  }
7918
8369
  let errored = false;
@@ -7951,7 +8402,7 @@ function FvCommonAdapter(config) {
7951
8402
  }
7952
8403
  case "error": {
7953
8404
  errored = true;
7954
- handlers.onError(new FvCommonError(String(j.message ?? "\u751F\u6210\u5931\u8D25"), j.code));
8405
+ handlers.onError(new FvCommonError(String(j.message ?? getGlobalLocale().errors.generateFailed), j.code));
7955
8406
  break;
7956
8407
  }
7957
8408
  }
@@ -8052,4 +8503,4 @@ function createMemoryAdapter() {
8052
8503
 
8053
8504
  const version = "0.1.0";
8054
8505
 
8055
- export { _sfc_main$1 as FvAiArtifacts, _sfc_main as FvAiChat, _sfc_main$3 as FvAiMessage, _sfc_main$2 as FvAiMessages, _sfc_main$5 as FvAttachments, _sfc_main$g as FvBubble, _sfc_main$f as FvBubbleList, FvCommonAdapter, FvCommonError, _sfc_main$4 as FvConversations, _sfc_main$b as FvEditorSender, _sfc_main$6 as FvFilesCard, _sfc_main$i as FvMarkdown, _sfc_main$c as FvMentionSender, _sfc_main$7 as FvPrompts, _sfc_main$d as FvSender, _sfc_main$a as FvThinking, _sfc_main$9 as FvThoughtChain, _sfc_main$h as FvTypewriter, _sfc_main$8 as FvWelcome, OpenAIAdapter, XRequest, createLocalStorageAdapter, createMemoryAdapter, createMessageTree, createSSEParser, useChat, useMessages, useRecord, useSend, useXStream, version };
8506
+ export { _sfc_main$1 as FvAiArtifacts, _sfc_main as FvAiChat, _sfc_main$3 as FvAiMessage, _sfc_main$2 as FvAiMessages, _sfc_main$5 as FvAttachments, _sfc_main$g as FvBubble, _sfc_main$f as FvBubbleList, FvCommonAdapter, FvCommonError, _sfc_main$4 as FvConversations, _sfc_main$b as FvEditorSender, _sfc_main$6 as FvFilesCard, _sfc_main$i as FvMarkdown, _sfc_main$c as FvMentionSender, _sfc_main$7 as FvPrompts, _sfc_main$d as FvSender, _sfc_main$a as FvThinking, _sfc_main$9 as FvThoughtChain, _sfc_main$h as FvTypewriter, _sfc_main$8 as FvWelcome, OpenAIAdapter, XRequest, configureLocale, createLocalStorageAdapter, createMemoryAdapter, createMessageTree, createSSEParser, enUS, useChat, useMessages, useRecord, useSend, useXStream, version, zhCN };