@fv-ui/ai-chat 1.2.0 → 1.4.1

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,5 +1,5 @@
1
1
  import { shallowRef, inject, computed, provide, defineComponent, ref, onBeforeUnmount, openBlock, createElementBlock, Fragment, createElementVNode, createCommentVNode, createBlock, Teleport, watch, normalizeClass, createTextVNode, toDisplayString, normalizeStyle, renderSlot, unref, renderList, createVNode, isRef, nextTick, onMounted, mergeProps, createSlots, withCtx, Transition, getCurrentInstance, useSlots, normalizeProps, guardReactiveProps, reactive, resolveDynamicComponent, markRaw, withModifiers, h, onActivated } from 'vue';
2
- import { ElMessage, ElAvatar, ElButton, ElIcon, ElPopover, ElDialog, ElScrollbar, ElDropdown, ElDropdownMenu, ElDropdownItem, ElMessageBox, ElTooltip, ElSelect, ElOption } from 'element-plus';
2
+ import { ElMessage, ElAvatar, ElButton, ElIcon, ElPopover, ElDialog, ElScrollbar, ElDropdown, ElDropdownMenu, ElDropdownItem, ElMessageBox, ElImageViewer, ElTooltip, ElSelect, ElOption } from 'element-plus';
3
3
  import * as ElementPlusIconsVue from '@element-plus/icons-vue';
4
4
  import { ArrowDown, Close, Check, Delete, Microphone, Promotion, VideoPause, Loading, SuccessFilled, CircleCloseFilled, ArrowUp, Cpu, Cellphone, Link, Folder, Headset, Film, Monitor, DataAnalysis, Document, Notebook, Picture, Paperclip, RefreshRight, MoreFilled, Search, User, DocumentCopy, Bottom, CopyDocument, Download, FullScreen } from '@element-plus/icons-vue';
5
5
 
@@ -33241,7 +33241,9 @@ const zhCN = {
33241
33241
  },
33242
33242
  attachments: {
33243
33243
  add: "\u6DFB\u52A0\u9644\u4EF6",
33244
- retry: "\u91CD\u4F20"
33244
+ retry: "\u91CD\u4F20",
33245
+ /** 上传中状态角标文案(loading 态 files 卡片辅助提示) */
33246
+ uploading: "\u4E0A\u4F20\u4E2D\u2026"
33245
33247
  },
33246
33248
  filesCard: {
33247
33249
  remove: "\u5220\u9664"
@@ -33276,6 +33278,8 @@ const zhCN = {
33276
33278
  querying: "\u6B63\u5728\u67E5\u8BE2",
33277
33279
  queried: "\u5DF2\u67E5\u8BE2",
33278
33280
  generateFailed: "\u751F\u6210\u5931\u8D25",
33281
+ /** 追问建议 chips 区 aria 标签 */
33282
+ followups: "\u8FFD\u95EE\u5EFA\u8BAE",
33279
33283
  loadingPhrases: ["\u6B63\u5728\u601D\u8003\u2026", "\u6B63\u5728\u6574\u7406\u601D\u8DEF\u2026", "\u6B63\u5728\u751F\u6210\u56DE\u7B54\u2026"]
33280
33284
  },
33281
33285
  aiArtifacts: {
@@ -33356,7 +33360,9 @@ const enUS = {
33356
33360
  },
33357
33361
  attachments: {
33358
33362
  add: "Add attachment",
33359
- retry: "Retry"
33363
+ retry: "Retry",
33364
+ /** 上传中状态角标文案(loading 态 files 卡片辅助提示) */
33365
+ uploading: "Uploading\u2026"
33360
33366
  },
33361
33367
  filesCard: {
33362
33368
  remove: "Remove"
@@ -33391,6 +33397,7 @@ const enUS = {
33391
33397
  querying: "Querying",
33392
33398
  queried: "Queried",
33393
33399
  generateFailed: "Generation failed",
33400
+ followups: "Follow-up suggestions",
33394
33401
  loadingPhrases: ["Thinking...", "Organizing thoughts...", "Generating your answer..."]
33395
33402
  },
33396
33403
  aiArtifacts: {
@@ -34296,7 +34303,7 @@ const _hoisted_6$8 = {
34296
34303
  class: "fv-sender-recording-wave",
34297
34304
  "aria-hidden": "true"
34298
34305
  };
34299
- const _hoisted_7$6 = { class: "fv-sender-recording-duration" };
34306
+ const _hoisted_7$7 = { class: "fv-sender-recording-duration" };
34300
34307
  const _hoisted_8$4 = ["value", "placeholder", "disabled", "readonly"];
34301
34308
  const _hoisted_9$3 = {
34302
34309
  key: 3,
@@ -34727,7 +34734,7 @@ var _sfc_main$d = /* @__PURE__ */ defineComponent({
34727
34734
  ]),
34728
34735
  createElementVNode(
34729
34736
  "span",
34730
- _hoisted_7$6,
34737
+ _hoisted_7$7,
34731
34738
  toDisplayString(recordDuration.value),
34732
34739
  1
34733
34740
  /* TEXT */
@@ -34943,7 +34950,7 @@ const _hoisted_3$c = {
34943
34950
  const _hoisted_4$a = ["onMouseenter", "onClick"];
34944
34951
  const _hoisted_5$8 = { class: "fv-mention-avatar" };
34945
34952
  const _hoisted_6$7 = ["src", "alt"];
34946
- const _hoisted_7$5 = { class: "fv-mention-name" };
34953
+ const _hoisted_7$6 = { class: "fv-mention-name" };
34947
34954
  const CHAR_WIDTH$1 = 8;
34948
34955
  var _sfc_main$c = /* @__PURE__ */ defineComponent({
34949
34956
  ...{ name: "FvMentionSender", inheritAttrs: false },
@@ -35343,7 +35350,7 @@ var _sfc_main$c = /* @__PURE__ */ defineComponent({
35343
35350
  ]),
35344
35351
  createElementVNode(
35345
35352
  "span",
35346
- _hoisted_7$5,
35353
+ _hoisted_7$6,
35347
35354
  toDisplayString(item.name),
35348
35355
  1
35349
35356
  /* TEXT */
@@ -35378,7 +35385,7 @@ const _hoisted_3$b = {
35378
35385
  const _hoisted_4$9 = { class: "fv-editor-input" };
35379
35386
  const _hoisted_5$7 = ["contenteditable", "data-placeholder"];
35380
35387
  const _hoisted_6$6 = { class: "fv-editor-mention-panel" };
35381
- const _hoisted_7$4 = {
35388
+ const _hoisted_7$5 = {
35382
35389
  key: 0,
35383
35390
  class: "fv-editor-mention-title"
35384
35391
  };
@@ -35405,9 +35412,9 @@ const _hoisted_16$1 = {
35405
35412
  };
35406
35413
  const _hoisted_17$1 = { class: "fv-editor-select-dialog" };
35407
35414
  const _hoisted_18$1 = { class: "fv-editor-select-title" };
35408
- const _hoisted_19 = { class: "fv-editor-select-grid" };
35409
- const _hoisted_20 = ["onClick"];
35410
- const _hoisted_21 = ["src", "alt"];
35415
+ const _hoisted_19$1 = { class: "fv-editor-select-grid" };
35416
+ const _hoisted_20$1 = ["onClick"];
35417
+ const _hoisted_21$1 = ["src", "alt"];
35411
35418
  const _hoisted_22 = { class: "fv-editor-select-name" };
35412
35419
  const CHAR_WIDTH = 8;
35413
35420
  var _sfc_main$b = /* @__PURE__ */ defineComponent({
@@ -36198,7 +36205,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
36198
36205
  createElementVNode("div", _hoisted_6$6, [
36199
36206
  panelTitle.value ? (openBlock(), createElementBlock(
36200
36207
  "div",
36201
- _hoisted_7$4,
36208
+ _hoisted_7$5,
36202
36209
  toDisplayString(panelTitle.value),
36203
36210
  1
36204
36211
  /* TEXT */
@@ -36390,7 +36397,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
36390
36397
  1
36391
36398
  /* TEXT */
36392
36399
  ),
36393
- createElementVNode("div", _hoisted_19, [
36400
+ createElementVNode("div", _hoisted_19$1, [
36394
36401
  (openBlock(true), createElementBlock(
36395
36402
  Fragment,
36396
36403
  null,
@@ -36405,7 +36412,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
36405
36412
  class: "fv-editor-select-preview",
36406
36413
  src: option.preview,
36407
36414
  alt: option.name
36408
- }, null, 8, _hoisted_21)) : createCommentVNode("v-if", true),
36415
+ }, null, 8, _hoisted_21$1)) : createCommentVNode("v-if", true),
36409
36416
  createElementVNode(
36410
36417
  "span",
36411
36418
  _hoisted_22,
@@ -36413,7 +36420,7 @@ var _sfc_main$b = /* @__PURE__ */ defineComponent({
36413
36420
  1
36414
36421
  /* TEXT */
36415
36422
  )
36416
- ], 8, _hoisted_20);
36423
+ ], 8, _hoisted_20$1);
36417
36424
  }),
36418
36425
  128
36419
36426
  /* KEYED_FRAGMENT */
@@ -36611,7 +36618,7 @@ const _hoisted_6$5 = {
36611
36618
  key: 0,
36612
36619
  class: "fv-chain-head-preview"
36613
36620
  };
36614
- const _hoisted_7$3 = {
36621
+ const _hoisted_7$4 = {
36615
36622
  key: 0,
36616
36623
  class: "fv-chain-body"
36617
36624
  };
@@ -37090,7 +37097,7 @@ var _sfc_main$9 = /* @__PURE__ */ defineComponent({
37090
37097
  /* DYNAMIC_SLOTS */
37091
37098
  )
37092
37099
  ], 10, _hoisted_4$7),
37093
- isTextExpanded(item.key) ? (openBlock(), createElementBlock("div", _hoisted_7$3, [
37100
+ isTextExpanded(item.key) ? (openBlock(), createElementBlock("div", _hoisted_7$4, [
37094
37101
  createCommentVNode(" \u4E0A/\u4E0B\u7F18\u6E10\u9690\u6761:\u5185\u5BB9\u88AB\u6EDA\u52A8\u88C1\u6389\u7684\u65B9\u5411\u624D\u6E32\u67D3(\u72B6\u6001\u89C1 edgeFade),\r\n \u906E\u7F69\u76D6\u5728\u6EDA\u52A8\u533A\u4E4B\u4E0A\u3001\u4E0D\u62E6\u6307\u9488;\u6837\u5F0F\u7ECF .scroll-edge-fade-top/-bottom "),
37095
37102
  edgeFade(item.key).top ? (openBlock(), createElementBlock("span", _hoisted_8$2)) : createCommentVNode("v-if", true),
37096
37103
  edgeFade(item.key).bottom ? (openBlock(), createElementBlock("span", _hoisted_9$1)) : createCommentVNode("v-if", true),
@@ -37218,7 +37225,7 @@ const _hoisted_3$8 = { class: "fv-welcome-main" };
37218
37225
  const _hoisted_4$6 = { class: "fv-welcome-text" };
37219
37226
  const _hoisted_5$5 = { class: "fv-welcome-name" };
37220
37227
  const _hoisted_6$4 = { class: "fv-welcome-name-accent" };
37221
- const _hoisted_7$2 = { class: "fv-welcome-description" };
37228
+ const _hoisted_7$3 = { class: "fv-welcome-description" };
37222
37229
  const _hoisted_8$1 = {
37223
37230
  key: 0,
37224
37231
  class: "fv-welcome-suggestions"
@@ -37311,7 +37318,7 @@ var _sfc_main$8 = /* @__PURE__ */ defineComponent({
37311
37318
  ])
37312
37319
  ]),
37313
37320
  createCommentVNode(" #description \u63D2\u69FD\u8986\u76D6\u63CF\u8FF0;\u672A\u4F20 description \u65F6\u56DE\u843D\u5185\u7F6E\u9ED8\u8BA4\u63CF\u8FF0 "),
37314
- createElementVNode("p", _hoisted_7$2, [
37321
+ createElementVNode("p", _hoisted_7$3, [
37315
37322
  renderSlot(_ctx.$slots, "description", {}, () => [
37316
37323
  createTextVNode(
37317
37324
  toDisplayString(__props.description || unref(dict).welcome.description),
@@ -37346,7 +37353,7 @@ const _hoisted_6$3 = {
37346
37353
  key: 0,
37347
37354
  class: "fv-prompt-item-label"
37348
37355
  };
37349
- const _hoisted_7$1 = {
37356
+ const _hoisted_7$2 = {
37350
37357
  key: 1,
37351
37358
  class: "fv-prompt-item-description"
37352
37359
  };
@@ -37431,7 +37438,7 @@ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
37431
37438
  )) : createCommentVNode("v-if", true),
37432
37439
  item.description ? (openBlock(), createElementBlock(
37433
37440
  "div",
37434
- _hoisted_7$1,
37441
+ _hoisted_7$2,
37435
37442
  toDisplayString(item.description),
37436
37443
  1
37437
37444
  /* TEXT */
@@ -37456,15 +37463,16 @@ var _sfc_main$7 = /* @__PURE__ */ defineComponent({
37456
37463
  const _hoisted_1$6 = ["src", "alt"];
37457
37464
  const _hoisted_2$6 = { class: "fv-files-card-info" };
37458
37465
  const _hoisted_3$6 = ["title"];
37459
- const _hoisted_4$4 = {
37460
- key: 0,
37466
+ const _hoisted_4$4 = ["title"];
37467
+ const _hoisted_5$3 = {
37468
+ key: 1,
37461
37469
  class: "fv-files-card-size"
37462
37470
  };
37463
- const _hoisted_5$3 = {
37471
+ const _hoisted_6$2 = {
37464
37472
  key: 2,
37465
37473
  class: "fv-files-card-status"
37466
37474
  };
37467
- const _hoisted_6$2 = ["aria-label"];
37475
+ const _hoisted_7$1 = ["aria-label"];
37468
37476
  const KB = 1024;
37469
37477
  const MB = 1024 * 1024;
37470
37478
  var _sfc_main$6 = /* @__PURE__ */ defineComponent({
@@ -37477,6 +37485,7 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
37477
37485
  url: { type: String, required: false, default: "" },
37478
37486
  status: { type: String, required: false, default: "success" },
37479
37487
  imageSize: { type: String, required: false, default: "" },
37488
+ errorText: { type: String, required: false, default: "" },
37480
37489
  onDelete: { type: Function, required: false, default: void 0 },
37481
37490
  locale: { type: null, required: false, default: void 0 }
37482
37491
  },
@@ -37601,16 +37610,21 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
37601
37610
  class: "fv-files-card-name",
37602
37611
  title: __props.name
37603
37612
  }, toDisplayString(__props.name), 9, _hoisted_3$6),
37604
- sizeText.value ? (openBlock(), createElementBlock(
37613
+ createCommentVNode(" error \u5E26\u6587\u6848\u65F6\u66FF\u4EE3\u5927\u5C0F\u884C(\u4E0A\u4F20\u5931\u8D25\u539F\u56E0);\u5426\u5219\u56DE\u843D\u5927\u5C0F "),
37614
+ __props.status === "error" && __props.errorText ? (openBlock(), createElementBlock("div", {
37615
+ key: 0,
37616
+ class: "fv-files-card-error",
37617
+ title: __props.errorText
37618
+ }, toDisplayString(__props.errorText), 9, _hoisted_4$4)) : sizeText.value ? (openBlock(), createElementBlock(
37605
37619
  "div",
37606
- _hoisted_4$4,
37620
+ _hoisted_5$3,
37607
37621
  toDisplayString(sizeText.value),
37608
37622
  1
37609
37623
  /* TEXT */
37610
37624
  )) : createCommentVNode("v-if", true)
37611
37625
  ]),
37612
37626
  createCommentVNode(" \u72B6\u6001\u89D2\u6807:loading spinner;error \u65E0\u89D2\u6807(\u7EA2\u8FB9\u6837\u5F0F) "),
37613
- __props.status === "loading" ? (openBlock(), createElementBlock("div", _hoisted_5$3, [
37627
+ __props.status === "loading" ? (openBlock(), createElementBlock("div", _hoisted_6$2, [
37614
37628
  createVNode(unref(ElIcon), { class: "fv-files-card-loading" }, {
37615
37629
  default: withCtx(() => [
37616
37630
  createVNode(unref(Loading))
@@ -37633,7 +37647,7 @@ var _sfc_main$6 = /* @__PURE__ */ defineComponent({
37633
37647
  _: 1
37634
37648
  /* STABLE */
37635
37649
  })
37636
- ], 8, _hoisted_6$2)
37650
+ ], 8, _hoisted_7$1)
37637
37651
  ],
37638
37652
  2
37639
37653
  /* CLASS */
@@ -37663,10 +37677,11 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
37663
37677
  tip: { type: String, required: false, default: "" },
37664
37678
  count: { type: Number, required: false, default: 0 },
37665
37679
  beforeUpload: { type: Function, required: false, default: void 0 },
37680
+ upload: { type: Function, required: false, default: void 0 },
37666
37681
  layout: { type: String, required: false, default: "inline" },
37667
37682
  locale: { type: null, required: false, default: void 0 }
37668
37683
  },
37669
- emits: ["update:modelValue", "change", "exceed", "delete"],
37684
+ emits: ["update:modelValue", "change", "exceed", "delete", "uploaded"],
37670
37685
  setup(__props, { expose: __expose, emit: __emit }) {
37671
37686
  const props = __props;
37672
37687
  const dict = useLocaleDict(() => props.locale);
@@ -37709,6 +37724,38 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
37709
37724
  if (item.status !== "error") return;
37710
37725
  item.status = "loading";
37711
37726
  sync();
37727
+ void runUpload(item);
37728
+ }
37729
+ async function runUpload(item) {
37730
+ if (!props.upload) {
37731
+ item.status = "success";
37732
+ sync();
37733
+ return;
37734
+ }
37735
+ try {
37736
+ const r = await props.upload(item.raw, item);
37737
+ if (typeof r === "string" && r) {
37738
+ applyResult(item, { status: "error", errMessage: r });
37739
+ emit("uploaded", item, void 0);
37740
+ } else {
37741
+ applyResult(item, r && typeof r === "object" ? { ...r, status: "success", errMessage: void 0 } : { status: "success", errMessage: void 0 });
37742
+ emit("uploaded", item, r && typeof r === "object" ? r : void 0);
37743
+ }
37744
+ } catch (e) {
37745
+ applyResult(item, { status: "error", errMessage: e instanceof Error ? e.message : String(e) });
37746
+ emit("uploaded", item, void 0);
37747
+ }
37748
+ sync();
37749
+ }
37750
+ function applyResult(item, patch) {
37751
+ const i = innerList.value.indexOf(item);
37752
+ const next = { ...item, ...patch };
37753
+ if (i >= 0) {
37754
+ innerList.value.splice(i, 1, next);
37755
+ Object.assign(item, next);
37756
+ } else {
37757
+ Object.assign(item, next);
37758
+ }
37712
37759
  }
37713
37760
  async function onChange(e) {
37714
37761
  const target = e.target;
@@ -37733,12 +37780,14 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
37733
37780
  size: file.size,
37734
37781
  url: isImageFile(file) ? createUrl(file) : "",
37735
37782
  fileType: isImageFile(file) ? "image" : "file",
37736
- status: "success",
37783
+ // 有 upload 钩子:入列即 loading(上传结果落定翻转);无钩子直接 success
37784
+ status: props.upload ? "loading" : "success",
37737
37785
  raw: file
37738
37786
  };
37739
37787
  innerList.value.push(item);
37788
+ sync();
37789
+ if (props.upload) void runUpload(item);
37740
37790
  }
37741
- sync();
37742
37791
  }
37743
37792
  function openSelect() {
37744
37793
  inputRef.value?.click();
@@ -37809,6 +37858,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
37809
37858
  url: item.url,
37810
37859
  "file-type": item.fileType ?? "file",
37811
37860
  status: item.status ?? "success",
37861
+ "error-text": item.errMessage ?? "",
37812
37862
  "on-delete": () => removeItem(item, index)
37813
37863
  }, createSlots({
37814
37864
  _: 2
@@ -37824,7 +37874,7 @@ var _sfc_main$5 = /* @__PURE__ */ defineComponent({
37824
37874
  ]),
37825
37875
  key: "0"
37826
37876
  } : void 0
37827
- ]), 1032, ["name", "size", "url", "file-type", "status", "on-delete"]),
37877
+ ]), 1032, ["name", "size", "url", "file-type", "status", "error-text", "on-delete"]),
37828
37878
  createCommentVNode(" error \u9879:\u91CD\u4F20\u6309\u94AE(\u5220\u9664\u5165\u53E3\u7531 FilesCard \u53F3\u4E0A\u6309\u94AE\u627F\u62C5,onDelete prop \u5DF2\u6CE8\u5165) "),
37829
37879
  item.status === "error" ? (openBlock(), createElementBlock("button", {
37830
37880
  key: 0,
@@ -38264,6 +38314,7 @@ function createMessageTree(initial) {
38264
38314
  error: node.error,
38265
38315
  createdAt: typeof node.createdAt === "number" ? node.createdAt : Date.now(),
38266
38316
  createdTime: node.createdTime,
38317
+ suggestions: node.suggestions ? [...node.suggestions] : void 0,
38267
38318
  usage: node.usage ? { ...node.usage } : void 0
38268
38319
  };
38269
38320
  messages[id] = full;
@@ -38513,7 +38564,7 @@ function useChat(options) {
38513
38564
  if (extraSystem) out.push({ role: "system", content: extraSystem });
38514
38565
  for (const m of chain) {
38515
38566
  if (m.role === "assistant" && !m.content) continue;
38516
- out.push({ role: m.role, content: m.content });
38567
+ out.push(m.role === "user" && m.files?.length ? { role: m.role, content: m.content, files: m.files.map((f) => ({ id: f.id, name: f.name, url: f.url, type: f.type, size: f.size })) } : { role: m.role, content: m.content });
38517
38568
  }
38518
38569
  return out;
38519
38570
  }
@@ -38560,6 +38611,9 @@ function useChat(options) {
38560
38611
  onBackendMessageId: (id) => {
38561
38612
  msgs.edit(assistantId, { backendId: id });
38562
38613
  },
38614
+ onSuggestions: (items) => {
38615
+ msgs.edit(assistantId, { suggestions: items });
38616
+ },
38563
38617
  onTool: (ev) => {
38564
38618
  const label = (name) => options.toolStepLabel ? options.toolStepLabel(name) : name;
38565
38619
  const steps = [...msgs.messages.value[assistantId]?.toolSteps ?? []];
@@ -38732,39 +38786,42 @@ const _hoisted_7 = {
38732
38786
  key: 1,
38733
38787
  class: "fv-msg-files"
38734
38788
  };
38735
- const _hoisted_8 = ["src", "alt"];
38736
- const _hoisted_9 = {
38789
+ const _hoisted_8 = ["title", "onClick"];
38790
+ const _hoisted_9 = ["src", "alt"];
38791
+ const _hoisted_10 = {
38737
38792
  key: 1,
38738
38793
  class: "fv-msg-file-name"
38739
38794
  };
38740
- const _hoisted_10 = {
38741
- key: 3,
38795
+ const _hoisted_11 = {
38796
+ key: 4,
38742
38797
  class: "fv-msg-content"
38743
38798
  };
38744
- const _hoisted_11 = {
38799
+ const _hoisted_12 = {
38745
38800
  key: 0,
38746
38801
  class: "fv-msg-error"
38747
38802
  };
38748
- const _hoisted_12 = {
38803
+ const _hoisted_13 = {
38749
38804
  class: "fv-msg-pending",
38750
38805
  role: "status",
38751
38806
  "aria-live": "polite"
38752
38807
  };
38753
- const _hoisted_13 = { class: "fv-msg-pending-text" };
38754
- const _hoisted_14 = {
38755
- key: 4,
38756
- class: "fv-msg-content fv-msg-content-user"
38757
- };
38808
+ const _hoisted_14 = { class: "fv-msg-pending-text" };
38758
38809
  const _hoisted_15 = {
38759
38810
  key: 5,
38811
+ class: "fv-msg-content fv-msg-content-user"
38812
+ };
38813
+ const _hoisted_16 = ["aria-label"];
38814
+ const _hoisted_17 = ["disabled", "onClick"];
38815
+ const _hoisted_18 = {
38816
+ key: 7,
38760
38817
  class: "fv-msg-actions"
38761
38818
  };
38762
- const _hoisted_16 = {
38819
+ const _hoisted_19 = {
38763
38820
  key: 0,
38764
38821
  class: "fv-msg-branch"
38765
38822
  };
38766
- const _hoisted_17 = { class: "fv-msg-branch-label" };
38767
- const _hoisted_18 = {
38823
+ const _hoisted_20 = { class: "fv-msg-branch-label" };
38824
+ const _hoisted_21 = {
38768
38825
  key: 1,
38769
38826
  class: "fv-msg-time"
38770
38827
  };
@@ -38775,6 +38832,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
38775
38832
  props: {
38776
38833
  message: { type: Object, required: true },
38777
38834
  branch: { type: Object, required: false, default: void 0 },
38835
+ isLast: { type: Boolean, required: false, default: false },
38778
38836
  showActions: { type: Boolean, required: false, default: true },
38779
38837
  showBranchSwitch: { type: Boolean, required: false, default: true },
38780
38838
  showUserAvatar: { type: Boolean, required: false, default: false },
@@ -38794,9 +38852,10 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
38794
38852
  codeTriggerLangs: { type: Array, required: false },
38795
38853
  showTime: { type: Boolean, required: false, default: true },
38796
38854
  timeFormat: { type: Function, required: false, default: void 0 },
38855
+ resolveFileUrl: { type: Function, required: false, default: void 0 },
38797
38856
  locale: { type: null, required: false }
38798
38857
  },
38799
- emits: ["copy", "regenerate", "branch-change", "typing"],
38858
+ emits: ["copy", "regenerate", "branch-change", "typing", "followup-select", "file-click"],
38800
38859
  setup(__props, { expose: __expose, emit: __emit }) {
38801
38860
  const props = __props;
38802
38861
  const dict = useLocaleDict(() => props.locale);
@@ -38988,6 +39047,43 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
38988
39047
  onBeforeUnmount(() => {
38989
39048
  if (phraseTimer !== null) clearInterval(phraseTimer);
38990
39049
  });
39050
+ const followups = computed(() => {
39051
+ if (!props.isLast || isUser.value) return [];
39052
+ const s = props.message.suggestions;
39053
+ return s && s.length ? s : [];
39054
+ });
39055
+ const followupsEnabled = computed(() => props.message.status === "done");
39056
+ function onFollowup(item) {
39057
+ if (!followupsEnabled.value) return;
39058
+ emit("followup-select", item, props.message);
39059
+ }
39060
+ const resolvedUrls = ref({});
39061
+ const resolvingUrls = /* @__PURE__ */ new Set();
39062
+ function displayUrl(f) {
39063
+ if (!f.url) return "";
39064
+ const hit = resolvedUrls.value[f.url];
39065
+ if (hit !== void 0) return hit;
39066
+ const raw = f.url;
39067
+ if (props.resolveFileUrl && /^https?:\/\//i.test(raw) && !resolvingUrls.has(raw)) {
39068
+ resolvingUrls.add(raw);
39069
+ void Promise.resolve(props.resolveFileUrl(f)).then((u) => {
39070
+ if (u && u !== raw) resolvedUrls.value[raw] = u;
39071
+ }).catch(() => {
39072
+ }).finally(() => resolvingUrls.delete(raw));
39073
+ }
39074
+ return raw;
39075
+ }
39076
+ const previewList = computed(() => (props.message.files ?? []).filter((f) => f.type === "image"));
39077
+ const previewVisible = ref(false);
39078
+ const previewIndex = ref(0);
39079
+ function onFileClick(f, index) {
39080
+ emit("file-click", f, props.message);
39081
+ if (f.type === "image" && displayUrl(f)) {
39082
+ previewIndex.value = Math.max(0, index);
39083
+ previewVisible.value = true;
39084
+ }
39085
+ }
39086
+ const previewSrcList = computed(() => previewList.value.map((f) => displayUrl(f)));
38991
39087
  function onCopy() {
38992
39088
  emit("copy", props.message);
38993
39089
  }
@@ -39068,7 +39164,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39068
39164
  /* TEXT */
39069
39165
  )) : createCommentVNode("v-if", true)
39070
39166
  ])) : createCommentVNode("v-if", true),
39071
- createCommentVNode(" \u9644\u4EF6:user \u6D88\u606F files \u4EE5 FilesCard \u5E73\u94FA "),
39167
+ createCommentVNode(" \u9644\u4EF6:user \u6D88\u606F files \u5E73\u94FA;\u56FE\u7247\u7F29\u7565\u53EF\u70B9(\u5185\u7F6E\u653E\u5927\u9884\u89C8),\u6587\u6863\u540D\u53EF\u70B9(\u5BBF\u4E3B\u4E0B\u8F7D) "),
39072
39168
  __props.message.files?.length ? (openBlock(), createElementBlock("div", _hoisted_7, [
39073
39169
  renderSlot(_ctx.$slots, "message-files", {
39074
39170
  message: __props.message,
@@ -39077,41 +39173,46 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39077
39173
  (openBlock(true), createElementBlock(
39078
39174
  Fragment,
39079
39175
  null,
39080
- renderList(__props.message.files, (f) => {
39081
- return openBlock(), createElementBlock(
39082
- "div",
39083
- {
39084
- key: f.id,
39085
- class: normalizeClass(["fv-msg-file", `is-${f.type ?? "file"}`])
39086
- },
39087
- [
39088
- f.type === "image" && f.url ? (openBlock(), createElementBlock("img", {
39089
- key: 0,
39090
- class: "fv-msg-file-img",
39091
- src: f.url,
39092
- alt: f.name
39093
- }, null, 8, _hoisted_8)) : (openBlock(), createElementBlock(
39094
- "span",
39095
- _hoisted_9,
39096
- toDisplayString(f.name),
39097
- 1
39098
- /* TEXT */
39099
- ))
39100
- ],
39101
- 2
39102
- /* CLASS */
39103
- );
39176
+ renderList(__props.message.files, (f, i) => {
39177
+ return openBlock(), createElementBlock("button", {
39178
+ key: f.id,
39179
+ type: "button",
39180
+ class: normalizeClass(["fv-msg-file", `is-${f.type ?? "file"}`]),
39181
+ title: f.name,
39182
+ onClick: ($event) => onFileClick(f, i)
39183
+ }, [
39184
+ f.type === "image" && displayUrl(f) ? (openBlock(), createElementBlock("img", {
39185
+ key: 0,
39186
+ class: "fv-msg-file-img",
39187
+ src: displayUrl(f),
39188
+ alt: f.name
39189
+ }, null, 8, _hoisted_9)) : (openBlock(), createElementBlock(
39190
+ "span",
39191
+ _hoisted_10,
39192
+ toDisplayString(f.name),
39193
+ 1
39194
+ /* TEXT */
39195
+ ))
39196
+ ], 10, _hoisted_8);
39104
39197
  }),
39105
39198
  128
39106
39199
  /* KEYED_FRAGMENT */
39107
39200
  ))
39108
39201
  ])
39109
39202
  ])) : createCommentVNode("v-if", true),
39203
+ createCommentVNode(" \u56FE\u7247\u653E\u5927\u9884\u89C8(\u672C\u6D88\u606F\u9644\u4EF6\u5185\u8F6E\u64AD;teleported \u6302 body \u9632\u88AB\u6D88\u606F\u533A\u88C1\u526A) "),
39204
+ previewVisible.value && previewSrcList.value.length ? (openBlock(), createBlock(unref(ElImageViewer), {
39205
+ key: 2,
39206
+ "url-list": previewSrcList.value,
39207
+ "initial-index": previewIndex.value,
39208
+ teleported: "",
39209
+ onClose: _cache[0] || (_cache[0] = ($event) => previewVisible.value = false)
39210
+ }, null, 8, ["url-list", "initial-index"])) : createCommentVNode("v-if", true),
39110
39211
  createCommentVNode(" \u601D\u8003\u94FE(assistant \u542B toolSteps/reasoning \u65F6):\u591A item \u7531 Thinking \u6298\u53E0\u5934\u627F\u8F7D\u72B6\u6001\r\n \u6C47\u603B\u6587\u6848(\u843D\u5B9A\u5E26\u5DE5\u5177\u6B21\u6570)\u4E0E\u6536\u8D77/\u5C55\u5F00;\u5355 item \u65E0\u6C47\u603B\u5FC5\u8981,\u9690\u85CF\u6298\u53E0\u5934\r\n (hideHeader,\u94FE\u5E73\u94FA\u4E14\u5E38\u9A7B\u5C55\u5F00,\u5355\u6B65\u81EA\u5E26\u72B6\u6001\u56FE\u6807\u4E0E per-item \u6298\u53E0);\r\n \u4EC5 reasoning \u65E0 toolSteps \u65F6(\u7EAF\u601D\u8003\u6D88\u606F)\u56DE\u843D\u94FE\u4E0B Markdown \u6E32\u67D3 "),
39111
39212
  !isUser.value && (hasToolSteps.value || hasReasoning.value) ? (openBlock(), createBlock(_sfc_main$a, {
39112
- key: 2,
39213
+ key: 3,
39113
39214
  modelValue: toolsExpanded.value,
39114
- "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => toolsExpanded.value = $event),
39215
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => toolsExpanded.value = $event),
39115
39216
  status: hasToolSteps.value ? toolThinkingStatus.value : thinkingStatus.value,
39116
39217
  "auto-collapse": false,
39117
39218
  "hide-header": !showChainHeader.value,
@@ -39123,7 +39224,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39123
39224
  items: toolChainItems.value,
39124
39225
  collapsible: __props.collapsible,
39125
39226
  "show-duration": __props.showDuration,
39126
- onTyping: _cache[0] || (_cache[0] = ($event) => emit("typing"))
39227
+ onTyping: _cache[1] || (_cache[1] = ($event) => emit("typing"))
39127
39228
  }, null, 8, ["items", "collapsible", "show-duration"])) : hasReasoning.value && useTypewriter.value && !reasoningFlushed.value ? (openBlock(), createElementBlock(
39128
39229
  Fragment,
39129
39230
  { key: 1 },
@@ -39133,7 +39234,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39133
39234
  content: __props.message.reasoning ?? "",
39134
39235
  "is-markdown": "",
39135
39236
  typing: __props.typing,
39136
- onWriting: _cache[1] || (_cache[1] = ($event) => emit("typing"))
39237
+ onWriting: _cache[2] || (_cache[2] = ($event) => emit("typing"))
39137
39238
  }, null, 8, ["content", "typing"])
39138
39239
  ],
39139
39240
  2112
@@ -39159,10 +39260,10 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39159
39260
  } : void 0
39160
39261
  ]), 1032, ["modelValue", "status", "hide-header", "class"])) : createCommentVNode("v-if", true),
39161
39262
  createCommentVNode(" \u6B63\u6587:user \u7EAF\u6587\u672C\u6C14\u6CE1;assistant Markdown;pending \u7A7A\u5185\u5BB9\u7ED9\u52A0\u8F7D\u5360\u4F4D "),
39162
- !isUser.value ? (openBlock(), createElementBlock("div", _hoisted_10, [
39263
+ !isUser.value ? (openBlock(), createElementBlock("div", _hoisted_11, [
39163
39264
  __props.message.status === "error" ? (openBlock(), createElementBlock(
39164
39265
  "span",
39165
- _hoisted_11,
39266
+ _hoisted_12,
39166
39267
  toDisplayString(__props.message.error || unref(dict).aiMessage.generateFailed),
39167
39268
  1
39168
39269
  /* TEXT */
@@ -39174,7 +39275,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39174
39275
  "is-markdown": "",
39175
39276
  typing: __props.typing,
39176
39277
  "code-trigger-langs": __props.codeTriggerLangs,
39177
- onWriting: _cache[3] || (_cache[3] = ($event) => emit("typing")),
39278
+ onWriting: _cache[4] || (_cache[4] = ($event) => emit("typing")),
39178
39279
  onFinish: maybeCollapseOnDone
39179
39280
  }, null, 8, ["content", "typing", "code-trigger-langs"])) : __props.message.content ? (openBlock(), createBlock(_sfc_main$i, {
39180
39281
  key: 2,
@@ -39185,8 +39286,8 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39185
39286
  { key: 3 },
39186
39287
  [
39187
39288
  createCommentVNode(" \u751F\u6210\u4E2D\u5360\u4F4D:\u4E3B\u9898\u8272\u5708\u5708 spinner + \u8F6E\u6362\u6587\u6848(loadingPhrases,3s \u8F6E\u6362);\r\n \u6709\u5DE5\u5177\u8F68\u8FF9\u65F6\u4E0D\u91CD\u590D\u5360\u4F4D(Thinking \u5934\u5DF2\u662F\u300C\u601D\u8003\u4E2D...\u300D) "),
39188
- createElementVNode("span", _hoisted_12, [
39189
- _cache[6] || (_cache[6] = createElementVNode(
39289
+ createElementVNode("span", _hoisted_13, [
39290
+ _cache[7] || (_cache[7] = createElementVNode(
39190
39291
  "span",
39191
39292
  {
39192
39293
  class: "fv-msg-spinner",
@@ -39198,7 +39299,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39198
39299
  )),
39199
39300
  createElementVNode(
39200
39301
  "span",
39201
- _hoisted_13,
39302
+ _hoisted_14,
39202
39303
  toDisplayString(pendingPhrase.value),
39203
39304
  1
39204
39305
  /* TEXT */
@@ -39210,13 +39311,38 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39210
39311
  )) : createCommentVNode("v-if", true)
39211
39312
  ])) : (openBlock(), createElementBlock(
39212
39313
  "div",
39213
- _hoisted_14,
39314
+ _hoisted_15,
39214
39315
  toDisplayString(__props.message.content),
39215
39316
  1
39216
39317
  /* TEXT */
39217
39318
  )),
39319
+ createCommentVNode(" \u8FFD\u95EE\u5EFA\u8BAE chips:\u4EC5\u94FE\u5C3E assistant \u6D88\u606F\u6E32\u67D3(isLast \u7531 AiMessages \u6CE8\u5165);\r\n \u6D41\u5F0F(message_end \u524D)\u7981\u7528\u9632\u8BEF\u70B9,\u843D\u5B9A\u540E\u53EF\u70B9\u51FB,\u70B9\u51FB\u7ECF followup-select \u4E0A\u629B "),
39320
+ followups.value.length ? (openBlock(), createElementBlock("div", {
39321
+ key: 6,
39322
+ class: "fv-msg-followups",
39323
+ role: "listbox",
39324
+ "aria-label": unref(dict).aiMessage.followups
39325
+ }, [
39326
+ (openBlock(true), createElementBlock(
39327
+ Fragment,
39328
+ null,
39329
+ renderList(followups.value, (item, i) => {
39330
+ return openBlock(), createElementBlock("button", {
39331
+ key: `${i}-${item}`,
39332
+ type: "button",
39333
+ class: normalizeClass(["fv-msg-followup", { "is-disabled": !followupsEnabled.value }]),
39334
+ disabled: !followupsEnabled.value,
39335
+ role: "option",
39336
+ "aria-selected": false,
39337
+ onClick: ($event) => onFollowup(item)
39338
+ }, toDisplayString(item), 11, _hoisted_17);
39339
+ }),
39340
+ 128
39341
+ /* KEYED_FRAGMENT */
39342
+ ))
39343
+ ], 8, _hoisted_16)) : createCommentVNode("v-if", true),
39218
39344
  createCommentVNode(" \u64CD\u4F5C\u533A:assistant \u590D\u5236/\u91CD\u751F\u6210 + \u5206\u652F\u5207\u6362;user \u4EC5\u590D\u5236(hover \u6D88\u606F\u65F6\u6D6E\u73B0,\u89C1 scss) "),
39219
- __props.showActions || __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("div", _hoisted_15, [
39345
+ __props.showActions || __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("div", _hoisted_18, [
39220
39346
  renderSlot(_ctx.$slots, "message-actions", { message: __props.message }, () => [
39221
39347
  __props.showActions && isUser.value ? (openBlock(), createBlock(unref(ElTooltip), {
39222
39348
  key: 0,
@@ -39307,14 +39433,14 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39307
39433
  }, 8, ["content"])) : createCommentVNode("v-if", true)
39308
39434
  ]),
39309
39435
  createCommentVNode(" \u5206\u652F\u5207\u6362:\u5144\u5F1F\u5206\u652F > 1 \u65F6 "),
39310
- __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("span", _hoisted_16, [
39436
+ __props.showBranchSwitch && __props.branch && __props.branch.count > 1 ? (openBlock(), createElementBlock("span", _hoisted_19, [
39311
39437
  createVNode(unref(ElButton), {
39312
39438
  text: "",
39313
39439
  size: "small",
39314
39440
  class: "fv-msg-action",
39315
39441
  disabled: __props.branch.index <= 1,
39316
39442
  "aria-label": unref(dict).aiMessage.prevBranch,
39317
- onClick: _cache[4] || (_cache[4] = ($event) => onBranch("prev"))
39443
+ onClick: _cache[5] || (_cache[5] = ($event) => onBranch("prev"))
39318
39444
  }, {
39319
39445
  default: withCtx(() => [
39320
39446
  createVNode(unref(ElIcon), null, {
@@ -39330,7 +39456,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39330
39456
  }, 8, ["disabled", "aria-label"]),
39331
39457
  createElementVNode(
39332
39458
  "span",
39333
- _hoisted_17,
39459
+ _hoisted_20,
39334
39460
  toDisplayString(__props.branch.index) + " / " + toDisplayString(__props.branch.count),
39335
39461
  1
39336
39462
  /* TEXT */
@@ -39341,7 +39467,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39341
39467
  class: "fv-msg-action",
39342
39468
  disabled: __props.branch.index >= __props.branch.count,
39343
39469
  "aria-label": unref(dict).aiMessage.nextBranch,
39344
- onClick: _cache[5] || (_cache[5] = ($event) => onBranch("next"))
39470
+ onClick: _cache[6] || (_cache[6] = ($event) => onBranch("next"))
39345
39471
  }, {
39346
39472
  default: withCtx(() => [
39347
39473
  createVNode(unref(ElIcon), null, {
@@ -39359,7 +39485,7 @@ var _sfc_main$3 = /* @__PURE__ */ defineComponent({
39359
39485
  createCommentVNode(" \u6D88\u606F\u65F6\u95F4:\u8DDF\u5728\u64CD\u4F5C\u6309\u94AE\u4E0E\u5206\u652F\u5207\u6362\u4E4B\u540E;user \u6D88\u606F hover \u9690\u85CF\u6309\u94AE\u4E0D\u5F71\u54CD\u65F6\u95F4\u5E38\u9A7B;\r\n assistant \u751F\u6210\u4E2D\u4E0D\u663E,\u6B63\u6587\u6253\u5B8C\u5B57(\u6216 error)\u540E\u624D\u6D6E\u73B0 "),
39360
39486
  messageTimeText.value && timeVisible.value ? (openBlock(), createElementBlock(
39361
39487
  "span",
39362
- _hoisted_18,
39488
+ _hoisted_21,
39363
39489
  toDisplayString(messageTimeText.value),
39364
39490
  1
39365
39491
  /* TEXT */
@@ -39411,9 +39537,10 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
39411
39537
  codeTriggerLangs: { type: Array, required: false },
39412
39538
  showTime: { type: Boolean, required: false, default: true },
39413
39539
  timeFormat: { type: Function, required: false, default: void 0 },
39540
+ resolveFileUrl: { type: Function, required: false, default: void 0 },
39414
39541
  locale: { type: null, required: false }
39415
39542
  },
39416
- emits: ["select", "copy", "regenerate", "branch-change", "scroll"],
39543
+ emits: ["select", "copy", "regenerate", "branch-change", "scroll", "followup-select", "message-file-click"],
39417
39544
  setup(__props, { expose: __expose, emit: __emit }) {
39418
39545
  const props = __props;
39419
39546
  const dict = useLocaleDict(() => props.locale);
@@ -39488,7 +39615,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
39488
39615
  );
39489
39616
  watch(
39490
39617
  () => props.messages.reduce(
39491
- (sum, m) => sum + m.content.length + (m.reasoning?.length ?? 0) + (m.toolSteps?.reduce((s, t) => s + (t.status?.length ?? 0) + (t.title?.length ?? 0), 0) ?? 0) + (m.toolSteps?.length ?? 0),
39618
+ (sum, m) => sum + m.content.length + (m.reasoning?.length ?? 0) + (m.toolSteps?.reduce((s, t) => s + (t.status?.length ?? 0) + (t.title?.length ?? 0), 0) ?? 0) + (m.toolSteps?.length ?? 0) + (m.suggestions?.length ?? 0),
39492
39619
  0
39493
39620
  ),
39494
39621
  () => followIfPinned()
@@ -39521,6 +39648,13 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
39521
39648
  function onBranch(dir, m) {
39522
39649
  emit("branch-change", dir, m);
39523
39650
  }
39651
+ function onFollowup(item, m) {
39652
+ emit("followup-select", item, m);
39653
+ }
39654
+ function onFileClick(file, m) {
39655
+ emit("message-file-click", file, m);
39656
+ }
39657
+ const lastMessageId = computed(() => props.messages.length ? props.messages[props.messages.length - 1].id : "");
39524
39658
  function scrollToTop() {
39525
39659
  const el = scrollRef.value;
39526
39660
  if (!el) return;
@@ -39639,6 +39773,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
39639
39773
  ref: (el) => setMessageRef(m.id, el),
39640
39774
  message: m,
39641
39775
  branch: branchInfo(m),
39776
+ "is-last": m.id === lastMessageId.value,
39642
39777
  "show-actions": __props.showActions,
39643
39778
  "show-branch-switch": __props.showBranchSwitch,
39644
39779
  "show-user-avatar": __props.showUserAvatar,
@@ -39658,10 +39793,13 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
39658
39793
  "show-time": __props.showTime,
39659
39794
  "time-format": __props.timeFormat,
39660
39795
  "code-trigger-langs": __props.codeTriggerLangs,
39796
+ "resolve-file-url": __props.resolveFileUrl,
39661
39797
  onTyping: onChildTyping,
39662
39798
  onCopy,
39663
39799
  onRegenerate,
39664
- onBranchChange: onBranch
39800
+ onBranchChange: onBranch,
39801
+ onFollowupSelect: onFollowup,
39802
+ onFileClick
39665
39803
  }, createSlots({
39666
39804
  _: 2
39667
39805
  /* DYNAMIC */
@@ -39708,7 +39846,7 @@ var _sfc_main$2 = /* @__PURE__ */ defineComponent({
39708
39846
  ]),
39709
39847
  key: "5"
39710
39848
  } : void 0
39711
- ]), 1032, ["message", "branch", "show-actions", "show-branch-switch", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "assistant-avatar-scale", "avatar-circle", "user-name", "assistant-name", "typing", "auto-collapse", "collapsible", "show-duration", "show-time", "time-format", "code-trigger-langs"]);
39849
+ ]), 1032, ["message", "branch", "is-last", "show-actions", "show-branch-switch", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "assistant-avatar-scale", "avatar-circle", "user-name", "assistant-name", "typing", "auto-collapse", "collapsible", "show-duration", "show-time", "time-format", "code-trigger-langs", "resolve-file-url"]);
39712
39850
  }),
39713
39851
  128
39714
39852
  /* KEYED_FRAGMENT */
@@ -40078,10 +40216,12 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40078
40216
  allowAttachments: { type: Boolean, required: false, default: false },
40079
40217
  accept: { type: String, required: false, default: "" },
40080
40218
  attachmentLimit: { type: Number, required: false, default: 0 },
40219
+ uploadAttachment: { type: Function, required: false, default: void 0 },
40220
+ resolveFileUrl: { type: Function, required: false, default: void 0 },
40081
40221
  theme: { type: String, required: false, default: "light" },
40082
40222
  locale: { type: null, required: false }
40083
40223
  },
40084
- emits: ["update:messages", "send", "suggestion-select", "message-complete", "error", "branch-change", "attachment-exceed", "scroll", "tool-event"],
40224
+ emits: ["update:messages", "send", "suggestion-select", "followup-select", "message-complete", "error", "branch-change", "attachment-exceed", "attachment-uploaded", "message-file-click", "scroll", "tool-event"],
40085
40225
  setup(__props, { expose: __expose, emit: __emit }) {
40086
40226
  const props = __props;
40087
40227
  const dict = useLocaleDict(() => props.locale);
@@ -40171,6 +40311,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40171
40311
  void regenerateChat(messageId).finally(finishRun);
40172
40312
  }
40173
40313
  const pendingFiles = ref([]);
40314
+ const uploadingCount = computed(() => pendingFiles.value.filter((f) => f.status === "loading").length);
40174
40315
  function toChatFiles(items) {
40175
40316
  return items.map((it) => ({
40176
40317
  id: String(it.uid),
@@ -40183,14 +40324,33 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40183
40324
  function onAttachmentExceed(file) {
40184
40325
  emit("attachment-exceed", file);
40185
40326
  }
40327
+ function onAttachmentUploaded(item, _result) {
40328
+ const err = item.errMessage;
40329
+ emit("attachment-uploaded", item, { ok: item.status === "success", message: item.status === "success" ? void 0 : err });
40330
+ }
40331
+ const attachmentsUploadHook = computed(() => {
40332
+ const hook = props.uploadAttachment;
40333
+ if (!hook) return void 0;
40334
+ return (file, item) => {
40335
+ return Promise.resolve(hook(file, item)).then((r) => {
40336
+ if (typeof r === "string") {
40337
+ if (r) throw new Error(r);
40338
+ return void 0;
40339
+ }
40340
+ return r;
40341
+ });
40342
+ };
40343
+ });
40186
40344
  function drainFiles() {
40187
40345
  if (!props.allowAttachments || !pendingFiles.value.length) return void 0;
40188
- const files = toChatFiles(pendingFiles.value);
40346
+ const ready = pendingFiles.value.filter((f) => f.status !== "error");
40347
+ const files = toChatFiles(ready);
40189
40348
  pendingFiles.value = [];
40190
- return files;
40349
+ return files.length ? files : void 0;
40191
40350
  }
40192
40351
  function onSubmit(text) {
40193
40352
  if (!text.trim() && !pendingFiles.value.length) return;
40353
+ if (uploadingCount.value) return;
40194
40354
  resetArtifactUserClosed();
40195
40355
  const files = drainFiles();
40196
40356
  emit("send", text, files);
@@ -40204,6 +40364,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40204
40364
  emit("send", text);
40205
40365
  void send(text).finally(finishRun);
40206
40366
  }
40367
+ function onFollowupSelect(item, message) {
40368
+ const text = item.trim();
40369
+ if (!text || isLoading.value) return;
40370
+ resetArtifactUserClosed();
40371
+ emit("followup-select", item, message);
40372
+ emit("send", text);
40373
+ void send(text).finally(finishRun);
40374
+ }
40207
40375
  function onCopy(m) {
40208
40376
  const text = `${m.content}`;
40209
40377
  void navigator.clipboard?.writeText(text).catch(() => {
@@ -40217,6 +40385,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40217
40385
  emit("branch-change", dir, m);
40218
40386
  }
40219
40387
  function sendMessage(text, files) {
40388
+ if (uploadingCount.value) return;
40220
40389
  if (!text.trim() && !files?.length && !pendingFiles.value.length) return;
40221
40390
  resetArtifactUserClosed();
40222
40391
  const payload = files ?? drainFiles();
@@ -40343,6 +40512,9 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40343
40512
  function onMessagesScroll(event) {
40344
40513
  emit("scroll", event);
40345
40514
  }
40515
+ function onMessageFileClick(file, message) {
40516
+ emit("message-file-click", file, message);
40517
+ }
40346
40518
  __expose({ sendMessage, stop, regenerate, appendToMessage, clearMessages, exportTxt, openArtifact, expandThoughtChains, collapseThoughtChains, scrollTo });
40347
40519
  return (_ctx, _cache) => {
40348
40520
  return openBlock(), createElementBlock(
@@ -40421,11 +40593,14 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40421
40593
  "show-time": __props.showTime,
40422
40594
  "time-format": __props.timeFormat,
40423
40595
  "code-trigger-langs": artifactsOn.value && artifactsCodeTrigger.value ? ["html", "svg"] : void 0,
40596
+ "resolve-file-url": __props.resolveFileUrl,
40424
40597
  onSelect: onSelectSuggestion,
40598
+ onFollowupSelect,
40425
40599
  onCopy,
40426
40600
  onRegenerate,
40427
40601
  onBranchChange,
40428
- onScroll: onMessagesScroll
40602
+ onScroll: onMessagesScroll,
40603
+ onMessageFileClick
40429
40604
  }, createSlots({
40430
40605
  _: 2
40431
40606
  /* DYNAMIC */
@@ -40521,7 +40696,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40521
40696
  ]),
40522
40697
  key: "12"
40523
40698
  } : void 0
40524
- ]), 1032, ["messages", "nodes", "name", "suggestions", "suggestions-wrap", "show-scroll-button", "scroll-button-threshold", "scroll-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "assistant-avatar-scale", "avatar-circle", "user-name", "assistant-name", "typing", "auto-collapse", "collapsible", "show-duration", "show-time", "time-format", "code-trigger-langs"]),
40699
+ ]), 1032, ["messages", "nodes", "name", "suggestions", "suggestions-wrap", "show-scroll-button", "scroll-button-threshold", "scroll-threshold", "show-user-avatar", "show-user-name", "show-assistant-avatar", "show-assistant-name", "user-avatar", "assistant-avatar", "assistant-avatar-scale", "avatar-circle", "user-name", "assistant-name", "typing", "auto-collapse", "collapsible", "show-duration", "show-time", "time-format", "code-trigger-langs", "resolve-file-url"]),
40525
40700
  artifactsOn.value && artifacts.value.length ? (openBlock(), createBlock(_sfc_main$1, {
40526
40701
  key: 0,
40527
40702
  artifacts: artifacts.value,
@@ -40533,7 +40708,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40533
40708
  onChange: onArtifactChange
40534
40709
  }, null, 8, ["artifacts", "active-key", "width", "min-width", "max-width"])) : createCommentVNode("v-if", true)
40535
40710
  ]),
40536
- 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) "),
40711
+ createCommentVNode(" \u8F93\u5165\u533A:Sender(\u4E0D\u4F20 allowSpeech,Task 15 \u6869\u4E0D\u63A5\u7EBF);\n allowAttachments \u5F00\u542F\u65F6:\u56DE\u5F62\u9488\u5728\u64CD\u4F5C\u680F\u5DE6\u4FA7(#action-left,\u4E0E\u63D0\u4EA4\u6309\u94AE\u540C\u884C),\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);\n \u751F\u6210\u4E2D(loading)\u65F6\u9644\u4EF6\u5165\u53E3\u6574\u4F53\u7981\u7528(\u5355\u98DE\u884C\u95F8\u8BED\u4E49:\u53D1\u9001\u671F\u95F4\u9501\u5B9A\u8F93\u5165) "),
40537
40712
  createElementVNode("div", _hoisted_4, [
40538
40713
  createVNode(_sfc_main$d, {
40539
40714
  placeholder: __props.placeholder,
@@ -40542,7 +40717,7 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40542
40717
  shadow: __props.senderShadow,
40543
40718
  variant: "updown",
40544
40719
  maxlength: 8e3,
40545
- "allow-empty-submit": __props.allowAttachments && !!pendingFiles.value.length,
40720
+ "allow-empty-submit": __props.allowAttachments && !!pendingFiles.value.length && !uploadingCount.value,
40546
40721
  onSubmit,
40547
40722
  onCancel: stop
40548
40723
  }, createSlots({
@@ -40558,8 +40733,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40558
40733
  layout: "listOnly",
40559
40734
  accept: __props.accept,
40560
40735
  count: __props.attachmentLimit,
40561
- onExceed: onAttachmentExceed
40562
- }, null, 8, ["modelValue", "accept", "count"])
40736
+ upload: attachmentsUploadHook.value,
40737
+ onExceed: onAttachmentExceed,
40738
+ onUploaded: onAttachmentUploaded
40739
+ }, null, 8, ["modelValue", "accept", "count", "upload"])
40563
40740
  ]),
40564
40741
  key: "0"
40565
40742
  } : void 0,
@@ -40572,8 +40749,10 @@ var _sfc_main = /* @__PURE__ */ defineComponent({
40572
40749
  layout: "triggerOnly",
40573
40750
  accept: __props.accept,
40574
40751
  count: __props.attachmentLimit,
40575
- onExceed: onAttachmentExceed
40576
- }, null, 8, ["modelValue", "accept", "count"])
40752
+ upload: attachmentsUploadHook.value,
40753
+ onExceed: onAttachmentExceed,
40754
+ onUploaded: onAttachmentUploaded
40755
+ }, null, 8, ["modelValue", "accept", "count", "upload"])
40577
40756
  ]),
40578
40757
  key: "1"
40579
40758
  } : void 0,
@@ -40725,6 +40904,17 @@ class FvCommonError extends Error {
40725
40904
  function resolve(v) {
40726
40905
  return typeof v === "function" ? v() : v;
40727
40906
  }
40907
+ function parseSuggestions(raw) {
40908
+ if (!raw) return void 0;
40909
+ try {
40910
+ const parsed = JSON.parse(raw);
40911
+ if (!Array.isArray(parsed)) return void 0;
40912
+ const items = parsed.filter((s) => typeof s === "string" && s.trim().length > 0);
40913
+ return items.length ? items : void 0;
40914
+ } catch {
40915
+ return void 0;
40916
+ }
40917
+ }
40728
40918
  function FvCommonAdapter(config) {
40729
40919
  const { baseURL, headers, sessionId, errorMessages } = config;
40730
40920
  const activeControllers = /* @__PURE__ */ new Set();
@@ -40800,6 +40990,13 @@ function FvCommonAdapter(config) {
40800
40990
  case "reasoning":
40801
40991
  if (typeof j.text === "string" && j.text) handlers.onReasoning(j.text);
40802
40992
  break;
40993
+ case "suggestions": {
40994
+ if (Array.isArray(j.items)) {
40995
+ const items = j.items.filter((s) => typeof s === "string" && s.trim().length > 0);
40996
+ if (items.length) handlers.onSuggestions?.(items);
40997
+ }
40998
+ break;
40999
+ }
40803
41000
  case "message_end": {
40804
41001
  if (typeof j.messageId === "string") handlers.onBackendMessageId?.(j.messageId);
40805
41002
  const usage = {};
@@ -40913,4 +41110,4 @@ function createMemoryAdapter() {
40913
41110
 
40914
41111
  const version = "0.1.0";
40915
41112
 
40916
- 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 };
41113
+ 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, parseSuggestions, useChat, useMessages, useRecord, useSend, useXStream, version, zhCN };