@glodon-aiot/agent-cli-ui 3.4.0-alpha.3 → 3.4.0-alpha.5

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.
@@ -1,130 +1,140 @@
1
- var sn = Object.defineProperty, an = Object.defineProperties;
2
- var ln = Object.getOwnPropertyDescriptors;
1
+ var an = Object.defineProperty, ln = Object.defineProperties;
2
+ var dn = Object.getOwnPropertyDescriptors;
3
3
  var ct = Object.getOwnPropertySymbols;
4
- var dn = Object.prototype.hasOwnProperty, cn = Object.prototype.propertyIsEnumerable;
5
- var Ce = (x, k, o) => k in x ? sn(x, k, { enumerable: !0, configurable: !0, writable: !0, value: o }) : x[k] = o, ft = (x, k) => {
4
+ var cn = Object.prototype.hasOwnProperty, fn = Object.prototype.propertyIsEnumerable;
5
+ var Le = (x, k, o) => k in x ? an(x, k, { enumerable: !0, configurable: !0, writable: !0, value: o }) : x[k] = o, ft = (x, k) => {
6
6
  for (var o in k || (k = {}))
7
- dn.call(k, o) && Ce(x, o, k[o]);
7
+ cn.call(k, o) && Le(x, o, k[o]);
8
8
  if (ct)
9
9
  for (var o of ct(k))
10
- cn.call(k, o) && Ce(x, o, k[o]);
10
+ fn.call(k, o) && Le(x, o, k[o]);
11
11
  return x;
12
- }, gt = (x, k) => an(x, ln(k));
13
- var H = (x, k, o) => (Ce(x, typeof k != "symbol" ? k + "" : k, o), o);
14
- var j = (x, k, o) => new Promise((q, e) => {
15
- var C = (E) => {
12
+ }, gt = (x, k) => ln(x, dn(k));
13
+ var D = (x, k, o) => (Le(x, typeof k != "symbol" ? k + "" : k, o), o);
14
+ var j = (x, k, o) => new Promise(($, e) => {
15
+ var L = (E) => {
16
16
  try {
17
17
  p(o.next(E));
18
18
  } catch (P) {
19
19
  e(P);
20
20
  }
21
- }, ye = (E) => {
21
+ }, pe = (E) => {
22
22
  try {
23
23
  p(o.throw(E));
24
24
  } catch (P) {
25
25
  e(P);
26
26
  }
27
- }, p = (E) => E.done ? q(E.value) : Promise.resolve(E.value).then(C, ye);
27
+ }, p = (E) => E.done ? $(E.value) : Promise.resolve(E.value).then(L, pe);
28
28
  p((o = o.apply(x, k)).next());
29
29
  });
30
- import { jsx as c, jsxs as B, Fragment as fn } from "react/jsx-runtime";
31
- import { memo as gn, forwardRef as un, useState as h, useRef as K, useContext as hn, useMemo as ut, useEffect as L, useImperativeHandle as mn } from "react";
32
- /* empty css */import { Spin as ht, Divider as yn, Button as X, Space as ge, Upload as pn, Tooltip as vn, notification as ue, message as u } from "antd";
33
- import he from "../../components/Iconfont/index.mjs";
34
- import { IHistoryRole as Z, ChatMessageRole as mt, PromptVariableType as me } from "@glodon-aiot/apis";
35
- import vt from "./HistoryItem/index.mjs";
36
- import kt from "dayjs";
30
+ import { jsx as c, jsxs as z, Fragment as gn } from "react/jsx-runtime";
31
+ import { memo as un, forwardRef as hn, useState as h, useRef as W, useContext as mn, useEffect as C, useMemo as yn, useImperativeHandle as pn } from "react";
32
+ /* empty css */import { Spin as ut, Divider as vn, Button as Q, Space as he, Upload as kn, Tooltip as bn, Popover as wn, notification as me, message as u } from "antd";
33
+ import ie from "../../components/Iconfont/index.mjs";
34
+ import { IHistoryRole as J, ChatMessageRole as ht, PromptVariableType as ye } from "@glodon-aiot/apis";
35
+ import pt from "./HistoryItem/index.mjs";
36
+ import vt from "dayjs";
37
37
  import { v4 as Pe } from "uuid";
38
- import kn from "../../context.mjs";
39
- import { configuration as bn } from "@glodon-aiot/bot-client-sdk";
40
- import { NET_OPEN_STATUS as $, MB as wn } from "../../constant.mjs";
41
- import xn from "../../components/FilePreview/index.mjs";
42
- import { getImageExtension as In } from "../../utils/index.mjs";
43
- import Nn from "../../QuillEditor/index.mjs";
44
- import Ln from "../../components/Recommend/index.mjs";
45
- import Cn from "../../components/Greeting/index.mjs";
46
- import En from "../../Footer/index.mjs";
47
- import { CameraOutlined as Pn, PlusOutlined as Tn } from "@ant-design/icons";
48
- import On from "./Tools/UploadKnowledgeFiles/index.mjs";
49
- import Fn from "../UploadingPrompt/index.mjs";
50
- import Rn from "./PromptSetting/index.mjs";
38
+ import xn from "../../context.mjs";
39
+ import { configuration as In } from "@glodon-aiot/bot-client-sdk";
40
+ import { NET_OPEN_STATUS as B, MB as Nn } from "../../constant.mjs";
41
+ import Cn from "../../components/FilePreview/index.mjs";
42
+ import { getImageExtension as Ln } from "../../utils/index.mjs";
43
+ import En from "../../QuillEditor/index.mjs";
44
+ import Pn from "../../components/Recommend/index.mjs";
45
+ import Tn from "../../components/Greeting/index.mjs";
46
+ import Fn from "../../Footer/index.mjs";
47
+ import { CameraOutlined as On, PlusOutlined as Hn } from "@ant-design/icons";
48
+ import Rn from "./Tools/UploadKnowledgeFiles/index.mjs";
49
+ import Dn from "../UploadingPrompt/index.mjs";
50
+ import Un from "./PromptSetting/index.mjs";
51
51
  import { useMemoizedFn as Ee } from "ahooks";
52
- import Dn from "./Tools/SessionListDrawer/index.mjs";
53
- import Hn from "./Tools/SessionHistoryDrawer/index.mjs";
54
- import Un from "react-infinite-scroll-component";
55
- import Mn from "./Tools/ConnectToNetwork/index.mjs";
56
- import jn from "./Tools/PromptManager/index.mjs";
57
- import zn from "../../assets/icon.svg.mjs";
58
- const Vn = gn(vt), yt = {
59
- icon: zn,
52
+ import Mn from "./Tools/SessionListDrawer/index.mjs";
53
+ import jn from "./Tools/SessionHistoryDrawer/index.mjs";
54
+ import zn from "react-infinite-scroll-component";
55
+ import Vn from "./Tools/ConnectToNetwork/index.mjs";
56
+ import An from "./Tools/PromptManager/index.mjs";
57
+ import qn from "../../assets/icon.svg.mjs";
58
+ const Bn = un(pt), mt = {
59
+ icon: qn,
60
60
  text: "今天我能帮你什么?"
61
61
  };
62
- class ne {
63
- constructor(k, o, q, e) {
64
- H(this, "messageTime");
65
- H(this, "isWaiting");
66
- H(this, "messageId");
67
- H(this, "isContext");
68
- H(this, "actions");
69
- H(this, "reference");
70
- H(this, "isSensitive");
71
- H(this, "isSuspend");
72
- H(this, "comment");
73
- this.content = k, this.sessionId = o, this.role = q, this.files = e, this.content = k, this.role = q, this.sessionId = o, this.files = e, this.messageTime = kt(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"), this.isWaiting = !1, this.messageId = Pe(), this.isContext = !1, this.actions = [], this.reference = [], this.isSensitive = !1, this.isSuspend = !1, this.comment = {
62
+ class oe {
63
+ constructor(k, o, $, e) {
64
+ D(this, "messageTime");
65
+ D(this, "isWaiting");
66
+ D(this, "messageId");
67
+ D(this, "isContext");
68
+ D(this, "actions");
69
+ D(this, "reference");
70
+ D(this, "isSensitive");
71
+ D(this, "isSuspend");
72
+ D(this, "comment");
73
+ this.content = k, this.sessionId = o, this.role = $, this.files = e, this.content = k, this.role = $, this.sessionId = o, this.files = e, this.messageTime = vt(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"), this.isWaiting = !1, this.messageId = Pe(), this.isContext = !1, this.actions = [], this.reference = [], this.isSensitive = !1, this.isSuspend = !1, this.comment = {
74
74
  isAgree: 0
75
75
  };
76
76
  }
77
77
  }
78
- const pt = 10, yi = un((x, k) => {
79
- var Ze, Je, Se, et, tt, nt, it, ot, rt, st, at, lt, dt;
78
+ const yt = 10, ki = hn((x, k) => {
79
+ var Je, Se, et, tt, nt, it, ot, st, rt, at, lt, dt;
80
80
  const {
81
81
  application: o,
82
- docViewerUrl: q = "",
82
+ docViewerUrl: $ = "",
83
83
  currentSession: e,
84
- onCreateSession: C,
85
- embeddingService: ye,
84
+ onCreateSession: L,
85
+ embeddingService: pe,
86
86
  setCurrentSession: p,
87
87
  networkStatus: E,
88
88
  setNetworkStatus: P,
89
- sessions: bt,
89
+ sessions: kt,
90
90
  // 👈 新增
91
- setSessions: wt
91
+ setSessions: bt
92
92
  // 👈 新增
93
- } = x, [v, I] = h([]), [xt, J] = h(), [pe, Te] = h(), R = K(null), {
93
+ } = x, [v, I] = h([]), [wt, S] = h(), [ve, Te] = h(), H = W(null), {
94
94
  service: T,
95
95
  agentClient: N,
96
- depId: It,
97
- footer: Nt,
96
+ depId: xt,
97
+ footer: It,
98
98
  transform: g,
99
- defaultInput: ve,
100
- onMessage: ie,
101
- onHistoryLoad: Oe,
102
- beforeMessageSend: z,
103
- bodyStyle: Lt,
104
- disabled: D,
105
- features: r,
99
+ defaultInput: ke,
100
+ onMessage: se,
101
+ onHistoryLoad: Fe,
102
+ beforeMessageSend: V,
103
+ bodyStyle: Nt,
104
+ disabled: R,
105
+ features: s,
106
106
  popupContainer: f,
107
107
  icon: Ct,
108
- sider: Et,
109
- mode: Pt
110
- } = hn(kn), [Fe, ke] = h(!1), m = K(v), Re = K(void 0), [Tt, Ot] = h(0), [S, W] = h(), [Q, oe] = h(""), [De, be] = h(!1), re = K(null), [He, Ft] = h([]), [Ue, _] = h(!1), [Me, Rt] = h(!1), [Dt, Ht] = h(""), [Ut, Y] = h(), [se, ae] = h({}), le = K(null), je = K(null), we = K(null), [ze, Mt] = h(!1), [jt, zt] = h([]), [Vt, de] = h(!0), [At, Bt] = h(!0), [Ve, U] = h(!1), [xe, V] = h(!1), [Ae, $t] = h(!1), [F, ce] = h(typeof (r == null ? void 0 : r.promptVariables) == "object" ? r.promptVariables.default || [] : []), [qt, Yt] = h(typeof (r == null ? void 0 : r.knowledges) == "object" && r.knowledges.default || void 0), [Be, M] = h(!1), [$e, ee] = h(!1), [Kt, G] = h(typeof (r == null ? void 0 : r.connectNetwork) == "object" && typeof (r == null ? void 0 : r.connectNetwork.default) == "boolean" ? r.connectNetwork.default : !1), [qe, fe] = h(!1), [Wt, Ie] = h(!1), Ye = ut(() => e === null ? !1 : e === void 0 ? !0 : e ? !e.ready : !0, [e, e == null ? void 0 : e.ready, (Ze = e == null ? void 0 : e.data) == null ? void 0 : Ze.id]);
111
- L(() => {
112
- Ie(Ye);
113
- }, [Ye]), L(() => {
108
+ sider: Lt,
109
+ mode: Et
110
+ } = mn(xn), [Oe, be] = h(!1), m = W(v), He = W(void 0), [Pt, Tt] = h(0), [ee, _] = h(), [G, re] = h(""), [Re, we] = h(!1), ae = W(null), [De, Ft] = h([]), [Ue, X] = h(!1), [Me, Ot] = h(!1), [Ht, Rt] = h(""), [Dt, Y] = h(), [le, de] = h({}), ce = W(null), je = W(null), xe = W(null), [ze, Ut] = h(!1), [Mt, jt] = h([]), [zt, fe] = h(!0), [Vt, At] = h(!0), [Ve, U] = h(!1), [Ie, A] = h(!1), [Ae, qt] = h(!1), [O, ge] = h(typeof (s == null ? void 0 : s.promptVariables) == "object" ? s.promptVariables.default || [] : []), [Bt, $t] = h(typeof (s == null ? void 0 : s.knowledges) == "object" && s.knowledges.default || void 0), [qe, M] = h(!1), [Be, te] = h(!1), [Yt, Z] = h(typeof (s == null ? void 0 : s.connectNetwork) == "object" && typeof (s == null ? void 0 : s.connectNetwork.default) == "boolean" ? s.connectNetwork.default : !1), [$e, ue] = h(!1), [Kt, K] = h(!1), [Wt, Qt] = h(null), [Ye, Ke] = h(!1);
111
+ C(() => {
112
+ if (Qt(e), e === null)
113
+ K(!1);
114
+ else if (e === void 0)
115
+ K(!0);
116
+ else {
117
+ if (Wt === null) {
118
+ K(!1);
119
+ return;
120
+ }
121
+ e.ready ? K(!1) : K(!0);
122
+ }
123
+ }, [e, e == null ? void 0 : e.ready]), C(() => {
114
124
  var a, i;
115
125
  e && (m.current = []), I([]);
116
- const t = R.current;
126
+ const t = H.current;
117
127
  if (t && t.scrollTo({
118
128
  top: 0
119
129
  }), !((a = e == null ? void 0 : e.data) != null && a.id))
120
130
  return;
121
- if (V(!1), U(!1), (i = e.messages) != null && i.length) {
122
- const s = [...e.messages.filter((d) => d == null ? void 0 : d.messageId)].reverse();
123
- m.current = [...s], I([...s]), Ie(!1);
131
+ if (A(!1), U(!1), (i = e.messages) != null && i.length) {
132
+ const r = [...e.messages.filter((d) => d == null ? void 0 : d.messageId)].reverse();
133
+ m.current = [...r], I([...r]), K(!1);
124
134
  }
125
135
  const n = (l) => {
126
- var s;
127
- (s = e == null ? void 0 : e.data) != null && s.id && (m.current = [...l].reverse(), I([...l].reverse()), !l || l.length < 10 ? ee(!1) : ee(!0), Ie(!1), Oe && Oe({
136
+ var r;
137
+ (r = e == null ? void 0 : e.data) != null && r.id && (m.current = [...l].reverse(), I([...l].reverse()), !l || l.length < 10 ? te(!1) : te(!0), K(!1), Fe && Fe({
128
138
  applicationId: o.id,
129
139
  sessionId: e.data.id,
130
140
  histories: l
@@ -133,25 +143,25 @@ const pt = 10, yi = un((x, k) => {
133
143
  return e.addEventListener("history:loaded", n), () => {
134
144
  m.current = [], I([]), e == null || e.removeEventListener("history:loaded", n);
135
145
  };
136
- }, [e]), L(() => {
146
+ }, [e]), C(() => {
137
147
  const t = () => {
138
148
  var n;
139
- (n = e == null ? void 0 : e.data) != null && n.id && (e.promptVariables && ce(e.promptVariables.sort((a, i) => a.key.localeCompare(i.key))), e.knowledges && Yt(e.knowledges), P(e.netOpen));
149
+ (n = e == null ? void 0 : e.data) != null && n.id && (e.promptVariables && ge(e.promptVariables.sort((a, i) => a.key.localeCompare(i.key))), e.knowledges && $t(e.knowledges), P(e.netOpen));
140
150
  };
141
151
  return e == null || e.addEventListener("data:updated", t), () => {
142
152
  e == null || e.removeEventListener("data:updated", t);
143
153
  };
144
- }, [e]), L(() => {
154
+ }, [e]), C(() => {
145
155
  var n;
146
156
  if (!((n = e == null ? void 0 : e.data) != null && n.id))
147
157
  return;
148
158
  const t = (a) => {
149
159
  var i;
150
- console.error(a.message, a.cause, "e.case"), ue.config({
160
+ console.error(a.message, a.cause, "e.case"), me.config({
151
161
  getContainer: () => (f == null ? void 0 : f.current) || document.body
152
- }), ue.error({
162
+ }), me.error({
153
163
  message: ((i = a.cause) == null ? void 0 : i.message) || a.message
154
- }), ue.config({
164
+ }), me.config({
155
165
  getContainer: void 0
156
166
  });
157
167
  };
@@ -159,7 +169,7 @@ const pt = 10, yi = un((x, k) => {
159
169
  e == null || e.removeEventListener("error", t);
160
170
  };
161
171
  }, [e]);
162
- const Qt = () => {
172
+ const _t = () => {
163
173
  var a;
164
174
  if (!((a = e == null ? void 0 : e.data) != null && a.id) || !(o != null && o.id))
165
175
  return;
@@ -173,18 +183,18 @@ const pt = 10, yi = un((x, k) => {
173
183
  return;
174
184
  } else
175
185
  e.clear().then(() => {
176
- const i = new ne("", t, Z.System);
186
+ const i = new oe("", t, J.System);
177
187
  i.isContext = !0, I([i, ...v]);
178
188
  });
179
189
  };
180
- L(() => {
190
+ C(() => {
181
191
  o != null && o.id && (T == null || T.getRecommendQues(o.id).then((t) => {
182
192
  Ft(t);
183
193
  }));
184
- }, [It, o]);
185
- const Ke = (t) => j(void 0, null, function* () {
186
- var y, O;
187
- if (D) {
194
+ }, [xt, o]);
195
+ const We = (t) => j(void 0, null, function* () {
196
+ var y, F;
197
+ if (R) {
188
198
  u.config({
189
199
  getContainer: () => (f == null ? void 0 : f.current) || document.body
190
200
  }), u.error("发送功能被禁用"), u.config({
@@ -192,7 +202,7 @@ const pt = 10, yi = un((x, k) => {
192
202
  });
193
203
  return;
194
204
  }
195
- const n = t || xt;
205
+ const n = t || wt;
196
206
  if (!(n != null && n.trim())) {
197
207
  u.config({
198
208
  getContainer: () => (f == null ? void 0 : f.current) || document.body
@@ -201,7 +211,7 @@ const pt = 10, yi = un((x, k) => {
201
211
  });
202
212
  return;
203
213
  }
204
- if (!(F == null ? void 0 : F.every((b) => !!(b != null && b.value))))
214
+ if (!(O == null ? void 0 : O.every((b) => !!(b != null && b.value))))
205
215
  if (g != null && g.promptVariables) {
206
216
  u.config({
207
217
  getContainer: () => (f == null ? void 0 : f.current) || document.body
@@ -210,8 +220,8 @@ const pt = 10, yi = un((x, k) => {
210
220
  });
211
221
  return;
212
222
  } else
213
- console.error("变量值不能为空", F == null ? void 0 : F.map((b) => !!(b != null && b.value)));
214
- if (xe) {
223
+ console.error("变量值不能为空", O == null ? void 0 : O.map((b) => !!(b != null && b.value)));
224
+ if (Ie) {
215
225
  u.config({
216
226
  getContainer: () => (f == null ? void 0 : f.current) || document.body
217
227
  }), u.error("正在回复中"), u.config({
@@ -219,7 +229,7 @@ const pt = 10, yi = un((x, k) => {
219
229
  });
220
230
  return;
221
231
  }
222
- if (Fe) {
232
+ if (Oe) {
223
233
  u.config({
224
234
  getContainer: () => (f == null ? void 0 : f.current) || document.body
225
235
  }), u.error("等待初始化"), u.config({
@@ -227,7 +237,7 @@ const pt = 10, yi = un((x, k) => {
227
237
  });
228
238
  return;
229
239
  }
230
- if (!Vt) {
240
+ if (!zt) {
231
241
  u.config({
232
242
  getContainer: () => (f == null ? void 0 : f.current) || document.body
233
243
  }), u.error("正在解析文件"), u.config({
@@ -235,7 +245,7 @@ const pt = 10, yi = un((x, k) => {
235
245
  });
236
246
  return;
237
247
  }
238
- if (De) {
248
+ if (Re) {
239
249
  u.config({
240
250
  getContainer: () => (f == null ? void 0 : f.current) || document.body
241
251
  }), u.error("正在上传图片"), u.config({
@@ -243,233 +253,233 @@ const pt = 10, yi = un((x, k) => {
243
253
  });
244
254
  return;
245
255
  }
246
- W(void 0), oe("");
256
+ _(void 0), re("");
247
257
  const i = (y = e == null ? void 0 : e.data) == null ? void 0 : y.id;
248
258
  if (!i) {
249
- C == null || C({
250
- netOpen: E ? $.OPEN : $.CLOSE
259
+ L == null || L({
260
+ netOpen: E ? B.OPEN : B.CLOSE
251
261
  }).then((b) => {
252
- var A, te;
253
- M(!0), P(!!((A = b.data) != null && A.netOpen)), G(!!((te = b.data) != null && te.enableNetOpen)), We(b).then(() => {
262
+ var q, ne;
263
+ M(!0), P(!!((q = b.data) != null && q.netOpen)), Z(!!((ne = b.data) != null && ne.enableNetOpen)), Qe(b).then(() => {
254
264
  p == null || p(b), M(!1), Te(n);
255
265
  });
256
266
  });
257
267
  return;
258
268
  }
259
- fe(!0);
260
- const l = Q ? `![](${Q})
269
+ ue(!0);
270
+ const l = G ? `![](${G})
261
271
  ${n}` : n;
262
- let s;
272
+ let r;
263
273
  try {
264
- z ? s = yield z == null ? void 0 : z({
274
+ V ? r = yield V == null ? void 0 : V({
265
275
  applicationId: o.id,
266
276
  sessionId: i,
267
277
  message: {
268
278
  content: l,
269
279
  sessionId: i,
270
- role: mt.User,
271
- files: se[i]
280
+ role: ht.User,
281
+ files: le[i]
272
282
  }
273
- }) : s = !0;
283
+ }) : r = !0;
274
284
  } catch (b) {
275
- s = !1;
285
+ r = !1;
276
286
  }
277
- if (fe(!1), s === !1)
287
+ if (ue(!1), r === !1)
278
288
  return;
279
289
  let d = n;
280
- typeof s == "object" && (d = s.content || n), (yield e.setPromptVariables(F)) && (((O = se[i]) == null ? void 0 : O.length) > 0 ? _t(d) : Ne(d));
281
- }), We = (t) => new Promise((n, a) => j(void 0, null, function* () {
282
- const s = (t == null ? void 0 : t.promptVariables).filter((d) => d.type ? !((d.type === me.User || d.type === void 0) && d.key === "query") && !((d.type === me.System || d.type === void 0) && d.key === "datetime") : d.key !== "query").map((d) => {
290
+ typeof r == "object" && (d = r.content || n), (yield e.setPromptVariables(O)) && (((F = le[i]) == null ? void 0 : F.length) > 0 ? Gt(d) : Ne(d));
291
+ }), Qe = (t) => new Promise((n, a) => j(void 0, null, function* () {
292
+ const r = (t == null ? void 0 : t.promptVariables).filter((d) => d.type ? !((d.type === ye.User || d.type === void 0) && d.key === "query") && !((d.type === ye.System || d.type === void 0) && d.key === "datetime") : d.key !== "query").map((d) => {
283
293
  var y;
284
- const w = (y = F.find((O) => O.key === d.key && O.type === d.type)) == null ? void 0 : y.value;
294
+ const w = (y = O.find((F) => F.key === d.key && F.type === d.type)) == null ? void 0 : y.value;
285
295
  return d.value = w || "", d;
286
296
  });
287
- ce(s.sort((d, w) => d.key.localeCompare(w.key))), yield t == null ? void 0 : t.setPromptVariables(s).catch((d) => {
297
+ ge(r.sort((d, w) => d.key.localeCompare(w.key))), yield t == null ? void 0 : t.setPromptVariables(r).catch((d) => {
288
298
  console.error(d), u.config({
289
299
  getContainer: () => (f == null ? void 0 : f.current) || document.body
290
300
  }), u.error(d.message), u.config({
291
301
  getContainer: void 0
292
302
  });
293
303
  }), n();
294
- })), _t = (t) => {
295
- var s, d, w;
296
- if (de(!1), !((s = e == null ? void 0 : e.data) != null && s.id) || !(o != null && o.id))
304
+ })), Gt = (t) => {
305
+ var r, d, w;
306
+ if (fe(!1), !((r = e == null ? void 0 : e.data) != null && r.id) || !(o != null && o.id))
297
307
  return;
298
308
  const n = ((d = e.data) == null ? void 0 : d.id) || "", a = [];
299
309
  let i = [], l = /* @__PURE__ */ new Set();
300
- (w = se[n]) == null || w.forEach((y) => {
310
+ (w = le[n]) == null || w.forEach((y) => {
301
311
  l.has(y.id) || (i.push(y), l.add(y.id));
302
312
  }), Promise.all(i.map((y) => T == null ? void 0 : T.patchApplicationIdKnowledgeIdFileId(o == null ? void 0 : o.id, n, y.id, {
303
313
  enabled: 1
304
- }).then((O) => {
314
+ }).then((F) => {
305
315
  a.push(y);
306
316
  }))).then((y) => {
307
- de(!0), Ne(t, a);
317
+ fe(!0), Ne(t, a);
308
318
  }).catch((y) => {
309
319
  throw Error(y);
310
320
  });
311
321
  };
312
- L(() => {
313
- if (!pe || !e)
322
+ C(() => {
323
+ if (!ve || !e)
314
324
  return;
315
- const t = pe, n = () => j(void 0, null, function* () {
316
- fe(!0);
317
- const a = Q ? `![](${Q})
325
+ const t = ve, n = () => j(void 0, null, function* () {
326
+ ue(!0);
327
+ const a = G ? `![](${G})
318
328
  ${t}` : t;
319
329
  let i;
320
330
  try {
321
- z ? i = yield z == null ? void 0 : z({
331
+ V ? i = yield V == null ? void 0 : V({
322
332
  applicationId: o.id,
323
333
  sessionId: e.id,
324
334
  message: {
325
335
  content: a,
326
336
  sessionId: e.id,
327
- role: mt.User,
328
- files: se[e.id]
337
+ role: ht.User,
338
+ files: le[e.id]
329
339
  }
330
340
  }) : i = !0;
331
341
  } catch (l) {
332
342
  i = !1;
333
343
  }
334
- fe(!1), i !== !1 && (Ne(t), Te(void 0));
344
+ ue(!1), i !== !1 && (Ne(t), Te(void 0));
335
345
  });
336
346
  return e.ready ? n() : e.addEventListener("ready", n, !0), () => {
337
347
  e == null || e.removeEventListener("ready", n);
338
348
  };
339
- }, [pe, e]);
349
+ }, [ve, e]);
340
350
  const Ne = (t, n) => j(void 0, null, function* () {
341
- var y, O;
351
+ var y, F;
342
352
  const a = (y = e == null ? void 0 : e.data) == null ? void 0 : y.id;
343
353
  if (!a)
344
354
  return;
345
- V(!0), U(!0);
346
- const i = Q ? `![](${Q})
347
- ${t}` : t, l = new ne(i, a, Z.User, n);
348
- J(void 0), Y(void 0), m.current = [l, ...v], I(m.current), o.id && ie && ie({
355
+ A(!0), U(!0);
356
+ const i = G ? `![](${G})
357
+ ${t}` : t, l = new oe(i, a, J.User, n);
358
+ S(void 0), Y(void 0), m.current = [l, ...v], I(m.current), o.id && se && se({
349
359
  applicationId: o.id,
350
360
  sessionId: a,
351
361
  message: l
352
362
  });
353
- const s = new ne("", a, Z.System);
354
- s.isWaiting = !0, m.current = [s, ...m.current], I(m.current);
363
+ const r = new oe("", a, J.System);
364
+ r.isWaiting = !0, m.current = [r, ...m.current], I(m.current);
355
365
  const d = (n == null ? void 0 : n.map((b) => b.id)) || [], w = {
356
- stream: bn.stream,
366
+ stream: In.stream,
357
367
  referenceFirst: !1
358
368
  };
359
369
  if (g != null && g.promptVariables) {
360
- const b = F == null ? void 0 : F.reduce((A, te) => (A[te.key] = te.value, A), {});
370
+ const b = O == null ? void 0 : O.reduce((q, ne) => (q[ne.key] = ne.value, q), {});
361
371
  w.formatValues = b;
362
372
  }
363
373
  if (g != null && g.knowledges) {
364
- const b = qt;
374
+ const b = Bt;
365
375
  w.knowledges = b;
366
376
  }
367
377
  yield e.send({
368
378
  text: i,
369
379
  fileIds: d,
370
380
  files: n
371
- }, w), ae({
381
+ }, w), de({
372
382
  [a]: []
373
- }), (O = le.current) == null || O.update();
383
+ }), (F = ce.current) == null || F.update();
374
384
  });
375
- L(() => {
385
+ C(() => {
376
386
  var a;
377
387
  const t = (a = e == null ? void 0 : e.data) == null ? void 0 : a.id;
378
388
  if (!t)
379
389
  return;
380
390
  const n = (i) => {
381
- if (!i.sessionId || i.sessionId && i.sessionId !== Re.current || i.role === Z.User)
391
+ if (!i.sessionId || i.sessionId && i.sessionId !== He.current || i.role === J.User)
382
392
  return;
383
- if (i.index === -1 && i.code !== 200 && i.code !== 11915 && (U(!1), V(!1), m.current = m.current.filter((d) => !d.isWaiting), I([...m.current]), m.current = [...m.current], i.content))
384
- return ue.error({
393
+ if (i.index === -1 && i.code !== 200 && i.code !== 11915 && (U(!1), A(!1), m.current = m.current.filter((d) => !d.isWaiting), I([...m.current]), m.current = [...m.current], i.content))
394
+ return me.error({
385
395
  message: i.content
386
396
  });
387
- const l = i.actions || [], s = new ne(i.content, t, Z.Robot);
388
- s.messageId = i.messageId || Pe(), s.reasoningContent = i.reasoningContent, s.searchReference = i.searchReference, s.thinkingSecs = i.thinkingSecs, s.thinkingStatus = i.thinkingStatus, s.actions = l, s.isLoading = !0, s.searchingStatus = i.searchingStatus, m.current = m.current.filter((d) => !d.isWaiting).filter((d) => !d.isReplying), i.index === void 0 && I([s, ...m.current]), i.code === 11915 && (U(!1), V(!1), s.isLoading = !1, s.content = "请您换个问题问我吧~", s.isSensitive = !0, I([s, ...m.current])), i.index === -2 && (U(!1), V(!1), s.isLoading = !1, s.content = "回答已中止~", s.isSuspend = !0, I([s, ...m.current])), i.index === -1 && (U(!1), V(!1), s.isLoading = !1, s.reference = i.reference, I([s, ...m.current]), o.id && ie && ie({
397
+ const l = i.actions || [], r = new oe(i.content, t, J.Robot);
398
+ r.messageId = i.messageId || Pe(), r.reasoningContent = i.reasoningContent, r.searchReference = i.searchReference, r.thinkingSecs = i.thinkingSecs, r.thinkingStatus = i.thinkingStatus, r.actions = l, r.isLoading = !0, r.searchingStatus = i.searchingStatus, m.current = m.current.filter((d) => !d.isWaiting).filter((d) => !d.isReplying), i.index === void 0 && I([r, ...m.current]), i.code === 11915 && (U(!1), A(!1), r.isLoading = !1, r.content = "请您换个问题问我吧~", r.isSensitive = !0, I([r, ...m.current])), i.index === -2 && (U(!1), A(!1), r.isLoading = !1, r.content = "回答已中止~", r.isSuspend = !0, I([r, ...m.current])), i.index === -1 && (U(!1), A(!1), r.isLoading = !1, r.reference = i.reference, I([r, ...m.current]), o.id && se && se({
389
399
  applicationId: o.id,
390
400
  sessionId: t,
391
- message: s
392
- })), i.index === -3 && (U(!1), V(!1), s.isLoading = !1, s.reference = i.reference, s.relatedQuesion = i.relatedQuesion, I([s, ...m.current]));
401
+ message: r
402
+ })), i.index === -3 && (U(!1), A(!1), r.isLoading = !1, r.reference = i.reference, r.relatedQuesion = i.relatedQuesion, I([r, ...m.current]));
393
403
  };
394
404
  return e.ready ? e.addEventListener("message:updated", n) : e.addEventListener("ready", () => {
395
405
  e.addEventListener("message:updated", n);
396
406
  }), () => {
397
407
  e == null || e.removeEventListener("message:updated", n);
398
408
  };
399
- }, [e]), L(() => {
409
+ }, [e]), C(() => {
400
410
  if (!e) {
401
- ke(!1);
411
+ be(!1);
402
412
  return;
403
413
  }
404
414
  const t = (n) => {
405
- ke(n);
415
+ be(n);
406
416
  };
407
- return ke(e.frozen), e.addEventListener("frozen", t), () => {
417
+ return be(e.frozen), e.addEventListener("frozen", t), () => {
408
418
  e == null || e.removeEventListener("frozen", t);
409
419
  };
410
- }, [e]), L(() => {
411
- e && (Y(void 0), J(void 0));
412
- }, [(Je = e == null ? void 0 : e.data) == null ? void 0 : Je.id]), L(() => {
420
+ }, [e]), C(() => {
421
+ e && (Y(void 0), S(void 0));
422
+ }, [(Je = e == null ? void 0 : e.data) == null ? void 0 : Je.id]), C(() => {
413
423
  if (!N)
414
424
  return;
415
425
  const t = N.questionContextMaxLength || 4e3;
416
- Ot(t);
417
- }, [N, T]), L(() => {
418
- ve && Y(ve.text);
419
- }, [ve]);
420
- const Gt = (t) => {
426
+ Tt(t);
427
+ }, [N, T]), C(() => {
428
+ ke && Y(ke.text);
429
+ }, [ke]);
430
+ const Xt = (t) => {
421
431
  const n = t.size;
422
432
  return n <= 0 ? (u.config({
423
433
  getContainer: () => (f == null ? void 0 : f.current) || document.body
424
434
  }), u.error("该文件为空,请重新上传"), u.config({
425
435
  getContainer: void 0
426
- }), !1) : n > 20 * wn ? (u.config({
436
+ }), !1) : n > 20 * Nn ? (u.config({
427
437
  getContainer: () => (f == null ? void 0 : f.current) || document.body
428
438
  }), u.error("图片须小于20M"), u.config({
429
439
  getContainer: void 0
430
- }), !1) : (W(t), !1);
431
- }, Xt = (t) => j(void 0, null, function* () {
440
+ }), !1) : (_(t), !1);
441
+ }, Zt = (t) => j(void 0, null, function* () {
432
442
  var n;
433
- return W(t), (n = e == null ? void 0 : e.data) != null && n.id ? Qe(e, t) : new Promise((a) => {
434
- M(!0), C == null || C({
435
- netOpen: E ? $.OPEN : $.CLOSE
443
+ return _(t), (n = e == null ? void 0 : e.data) != null && n.id ? _e(e, t) : new Promise((a) => {
444
+ M(!0), L == null || L({
445
+ netOpen: E ? B.OPEN : B.CLOSE
436
446
  }).then((i) => {
437
- var l, s;
438
- p == null || p(i), M(!1), P(!!((l = i.data) != null && l.netOpen)), G(!!((s = i.data) != null && s.enableNetOpen)), a(Qe(i, t));
447
+ var l, r;
448
+ p == null || p(i), M(!1), P(!!((l = i.data) != null && l.netOpen)), Z(!!((r = i.data) != null && r.enableNetOpen)), a(_e(i, t));
439
449
  });
440
450
  });
441
- }), Qe = (t, n) => {
442
- const a = In(n.name);
451
+ }), _e = (t, n) => {
452
+ const a = Ln(n.name);
443
453
  return new Promise((i) => {
444
- var s;
454
+ var r;
445
455
  const l = {
446
456
  files: [`${Pe()}.${a}`],
447
457
  isv: "minio",
448
- knowledgeId: ((s = t.data) == null ? void 0 : s.id) || "",
458
+ knowledgeId: ((r = t.data) == null ? void 0 : r.id) || "",
449
459
  type: 1
450
460
  };
451
- be(!0), T == null || T.postTicket(l).then((d) => {
461
+ we(!0), T == null || T.postTicket(l).then((d) => {
452
462
  T.uploadMinioFile(d.minio, n).then(() => {
453
- var b, A;
454
- const w = (b = d.minio.endpoints) == null ? void 0 : b[0], y = d.minio.bucket, O = (A = d.minio.fileKeys) == null ? void 0 : A[0];
455
- i(`${location.protocol}//${w}/${y}/${O}`);
463
+ var b, q;
464
+ const w = (b = d.minio.endpoints) == null ? void 0 : b[0], y = d.minio.bucket, F = (q = d.minio.fileKeys) == null ? void 0 : q[0];
465
+ i(`${location.protocol}//${w}/${y}/${F}`);
456
466
  }).catch(() => {
457
- oe(""), W(void 0);
467
+ re(""), _(void 0);
458
468
  }).finally(() => {
459
- be(!1);
469
+ we(!1);
460
470
  });
461
471
  }).catch(() => {
462
- oe(""), W(void 0), be(!1);
472
+ re(""), _(void 0), we(!1);
463
473
  });
464
474
  });
465
475
  };
466
- L(() => {
467
- const t = R.current;
476
+ C(() => {
477
+ const t = H.current;
468
478
  t && !Ae && t.scrollTo({
469
479
  top: t.scrollHeight
470
480
  });
471
481
  }, [v]);
472
- const _e = (t, n) => new Promise((a) => {
482
+ const Ge = (t, n) => new Promise((a) => {
473
483
  if (!n.file.url || !(o != null && o.id))
474
484
  return a();
475
485
  const i = gt(ft({}, n.file), {
@@ -477,56 +487,56 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
477
487
  });
478
488
  T == null || T.postApplicationIdSessionKnowledgeSessionFile(o == null ? void 0 : o.id, t, i).finally(() => {
479
489
  var l;
480
- (l = le.current) == null || l.update().finally(a);
490
+ (l = ce.current) == null || l.update().finally(a);
481
491
  });
482
- }), Zt = () => {
492
+ }), Jt = () => {
483
493
  var t;
484
494
  (t = e == null ? void 0 : e.data) != null && t.id && (U(!1), e.suspend());
485
- }, Jt = (t) => {
486
- const n = R.current;
495
+ }, St = (t) => {
496
+ const n = H.current;
487
497
  n && setTimeout(() => {
488
498
  n.scrollTo({
489
499
  top: n.scrollHeight,
490
500
  behavior: t == null ? void 0 : t.behavior
491
501
  });
492
502
  }, t == null ? void 0 : t.ms);
493
- }, St = () => {
494
- if (!R.current)
503
+ }, en = () => {
504
+ if (!H.current)
495
505
  return;
496
- const t = R.current.scrollTop <= -80;
497
- $t(t);
498
- }, en = Ee((t) => {
506
+ const t = H.current.scrollTop <= -80;
507
+ qt(t);
508
+ }, tn = Ee((t) => {
499
509
  var n, a;
500
- (n = re.current) == null || n.update(t), (a = re.current) == null || a.focus();
501
- }), tn = Ee((t) => {
502
- Ke(t);
503
- }), nn = Ee(() => {
510
+ (n = ae.current) == null || n.update(t), (a = ae.current) == null || a.focus();
511
+ }), nn = Ee((t) => {
512
+ We(t);
513
+ }), on = Ee(() => {
504
514
  var n;
505
515
  if (!((n = e == null ? void 0 : e.data) != null && n.id))
506
516
  return;
507
517
  m.current = [...v.slice(1, v.length)], I(m.current);
508
- const t = new ne("", e.data.id, Z.System);
509
- t.isWaiting = !0, m.current = [t, ...m.current], I(m.current), V(!0), U(!0), e.answerAgain();
518
+ const t = new oe("", e.data.id, J.System);
519
+ t.isWaiting = !0, m.current = [t, ...m.current], I(m.current), A(!0), U(!0), e.answerAgain();
510
520
  });
511
- L(() => {
521
+ C(() => {
512
522
  var t, n;
513
- Re.current = (t = e == null ? void 0 : e.data) == null ? void 0 : t.id, !Be && ((n = we.current) == null || n.clear());
523
+ He.current = (t = e == null ? void 0 : e.data) == null ? void 0 : t.id, !qe && ((n = xe.current) == null || n.clear());
514
524
  }, [e]);
515
- const on = () => {
525
+ const sn = () => {
516
526
  var a;
517
527
  if (!((a = e == null ? void 0 : e.data) != null && a.id))
518
528
  return;
519
529
  const n = v[v.length - 1].messageTime;
520
530
  e.fetchMessages({
521
531
  endTime: n,
522
- pageSize: pt
532
+ pageSize: yt
523
533
  }).then((i) => {
524
534
  const l = i || [];
525
535
  if (!l || !(l != null && l.length)) {
526
- ee(!1);
536
+ te(!1);
527
537
  return;
528
538
  }
529
- l.length < 10 ? ee(!1) : ee(!0), I([...v, ...l.reverse()]);
539
+ l.length < 10 ? te(!1) : te(!0), I([...v, ...l.reverse()]);
530
540
  });
531
541
  }, rn = (t) => j(void 0, null, function* () {
532
542
  var n, a;
@@ -537,60 +547,62 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
537
547
  return;
538
548
  P(t);
539
549
  }
540
- }), Le = () => j(void 0, null, function* () {
550
+ }), Ce = () => j(void 0, null, function* () {
541
551
  e ? e.fetchData().then((t) => {
542
552
  var n;
543
- (n = e == null ? void 0 : e.data) != null && n.id && (P(t.netOpen), G(t.enableNetOpen));
544
- }) : (P(typeof (r == null ? void 0 : r.connectNetwork) == "object" && typeof (r == null ? void 0 : r.connectNetwork.default) == "boolean" ? r.connectNetwork.default : !1), G(o.arrange[0].enableNetOpen));
553
+ (n = e == null ? void 0 : e.data) != null && n.id && (P(t.netOpen), Z(t.enableNetOpen));
554
+ }) : (P(typeof (s == null ? void 0 : s.connectNetwork) == "object" && typeof (s == null ? void 0 : s.connectNetwork.default) == "boolean" ? s.connectNetwork.default : !1), Z(o.arrange[0].enableNetOpen));
545
555
  });
546
- L(() => {
547
- Le();
548
- }, [e]), L(() => {
549
- var t, n;
550
- if (R.current) {
551
- const a = document.getElementById("chat-main"), i = (t = R.current) == null ? void 0 : t.querySelector(".infinite-scroll-component__outerdiv"), l = (n = R.current) == null ? void 0 : n.querySelector(".infinite-scroll-component");
552
- if (!i || !l || !a)
553
- return;
554
- const s = a.offsetHeight;
555
- if (l.offsetHeight <= s) {
556
- if (i.style.height === "100%")
557
- return;
558
- i.style.height = "100%";
559
- } else {
560
- if (i.style.height === "auto")
556
+ C(() => {
557
+ Ce();
558
+ }, [e]), C(() => {
559
+ requestAnimationFrame(() => {
560
+ var n, a;
561
+ if (H.current) {
562
+ const i = document.getElementById("chat-main"), l = (n = H.current) == null ? void 0 : n.querySelector(".infinite-scroll-component__outerdiv"), r = (a = H.current) == null ? void 0 : a.querySelector(".infinite-scroll-component");
563
+ if (!l || !r || !i)
561
564
  return;
562
- i.style.height = "auto";
565
+ const d = i.offsetHeight;
566
+ if (r.offsetHeight <= d) {
567
+ if (l.style.height === "100%")
568
+ return;
569
+ l.style.height = "100%";
570
+ } else {
571
+ if (l.style.height === "auto")
572
+ return;
573
+ l.style.height = "auto";
574
+ }
563
575
  }
564
- }
565
- }, [v]), L(() => {
576
+ });
577
+ }, [v]), C(() => {
566
578
  if (e)
567
579
  return;
568
580
  const t = () => {
569
- const i = ((N == null ? void 0 : N.promptVariables) || []).filter((l) => l.type ? !(l.type === me.User && l.key === "query") && !(l.type === me.System && l.key === "datetime") && l.status === 1 : l.key !== "query" && l.status === 1).map((l, s) => {
581
+ const i = ((N == null ? void 0 : N.promptVariables) || []).filter((l) => l.type ? !(l.type === ye.User && l.key === "query") && !(l.type === ye.System && l.key === "datetime") && l.status === 1 : l.key !== "query" && l.status === 1).map((l, r) => {
570
582
  var w, y;
571
583
  let d = "";
572
- return typeof (r == null ? void 0 : r.promptVariables) == "object" && (d = ((y = (w = r.promptVariables.default) == null ? void 0 : w.find((O) => O.key === l.key && O.type === l.type)) == null ? void 0 : y.value) || ""), {
573
- id: s + "",
584
+ return typeof (s == null ? void 0 : s.promptVariables) == "object" && (d = ((y = (w = s.promptVariables.default) == null ? void 0 : w.find((F) => F.key === l.key && F.type === l.type)) == null ? void 0 : y.value) || ""), {
585
+ id: r + "",
574
586
  key: l.key,
575
587
  name: l.name,
576
588
  value: d,
577
589
  type: l.type
578
590
  };
579
591
  });
580
- ce([...i].sort((l, s) => l.key.localeCompare(s.key)));
592
+ ge([...i].sort((l, r) => l.key.localeCompare(r.key)));
581
593
  };
582
594
  return N != null && N.ready ? t() : N == null || N.addEventListener("ready", t), () => {
583
595
  N == null || N.removeEventListener("ready", t);
584
596
  };
585
- }, [e, N, r == null ? void 0 : r.promptVariables]);
586
- const Ge = () => C == null ? void 0 : C({
587
- netOpen: E ? $.OPEN : $.CLOSE
597
+ }, [e, N, s == null ? void 0 : s.promptVariables]);
598
+ const Xe = () => L == null ? void 0 : L({
599
+ netOpen: E ? B.OPEN : B.CLOSE
588
600
  }).then((t) => {
589
601
  var n, a;
590
- return p == null || p(t), M(!1), P(!!((n = t.data) != null && n.netOpen)), G(!!((a = t.data) != null && a.enableNetOpen)), We(t), t;
591
- }), Xe = ut(() => {
602
+ return p == null || p(t), M(!1), P(!!((n = t.data) != null && n.netOpen)), Z(!!((a = t.data) != null && a.enableNetOpen)), Qe(t), t;
603
+ }), Ze = yn(() => {
592
604
  var t;
593
- return o.arrange && ((t = o.arrange[0]) != null && t.openingContent) ? /* @__PURE__ */ c(vt, {
605
+ return o.arrange && ((t = o.arrange[0]) != null && t.openingContent) ? /* @__PURE__ */ c(pt, {
594
606
  application: o,
595
607
  history: {
596
608
  role: 1,
@@ -600,36 +612,36 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
600
612
  sessionId: "",
601
613
  reference: [],
602
614
  searchReference: [],
603
- messageTime: kt(Date.now()).format("YYYY-MM-DD HH:mm:ss"),
615
+ messageTime: vt(Date.now()).format("YYYY-MM-DD HH:mm:ss"),
604
616
  actions: [],
605
617
  isLoading: !1
606
618
  },
607
619
  actions: !!v.length,
608
- markdown: r == null ? void 0 : r.markdown
620
+ markdown: s == null ? void 0 : s.markdown
609
621
  }) : null;
610
622
  }, [o == null ? void 0 : o.arrange, v]);
611
- return mn(k, () => ({
623
+ return pn(k, () => ({
612
624
  getCurrentInputText: () => {
613
625
  var t;
614
- return (t = re.current) == null ? void 0 : t.getCurrentText();
626
+ return (t = ae.current) == null ? void 0 : t.getCurrentText();
615
627
  }
616
- })), /* @__PURE__ */ c("div", {
628
+ })), /* @__PURE__ */ z("div", {
617
629
  className: "agent-chat",
618
- children: Wt ? /* @__PURE__ */ c("div", {
630
+ children: [Kt ? /* @__PURE__ */ c("div", {
619
631
  className: "session-loading",
620
- children: /* @__PURE__ */ c(ht, {})
621
- }) : /* @__PURE__ */ B(fn, {
622
- children: [(g == null ? void 0 : g.promptVariables) && /* @__PURE__ */ c(Rn, {
632
+ children: /* @__PURE__ */ c(ut, {})
633
+ }) : /* @__PURE__ */ z(gn, {
634
+ children: [(g == null ? void 0 : g.promptVariables) && /* @__PURE__ */ c(Un, {
623
635
  ref: je,
624
636
  appId: o.id,
625
637
  currentSession: e,
626
- promptVariables: F,
627
- setPromptVariables: ce,
638
+ promptVariables: O,
639
+ setPromptVariables: ge,
628
640
  setCurrentSession: p
629
- }), /* @__PURE__ */ B("div", {
641
+ }), /* @__PURE__ */ z("div", {
630
642
  className: "chat-main",
631
643
  id: "chat-main",
632
- style: Lt,
644
+ style: Nt,
633
645
  children: [/* @__PURE__ */ c("div", {
634
646
  className: "chat-main-wrapper",
635
647
  id: "scrollableDiv",
@@ -639,102 +651,102 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
639
651
  display: "flex",
640
652
  flexDirection: "column-reverse"
641
653
  },
642
- ref: R,
643
- onScroll: St,
644
- children: (Se = e == null ? void 0 : e.data) != null && Se.id && (v != null && v.length) ? /* @__PURE__ */ B(Un, {
654
+ ref: H,
655
+ onScroll: en,
656
+ children: (Se = e == null ? void 0 : e.data) != null && Se.id && (v != null && v.length) ? /* @__PURE__ */ z(zn, {
645
657
  dataLength: v.length,
646
- next: on,
658
+ next: sn,
647
659
  style: {
648
660
  display: "flex",
649
661
  flexDirection: "column-reverse",
650
662
  overflowX: "hidden"
651
663
  },
652
664
  inverse: !0,
653
- endMessage: v.length > pt && // 少于一页不展示这个提示
654
- ((et = R.current) != null && et.scrollTop) && ((tt = R.current) == null ? void 0 : tt.scrollTop) < -10 ? /* @__PURE__ */ c(yn, {
665
+ endMessage: v.length > yt && // 少于一页不展示这个提示
666
+ ((et = H.current) != null && et.scrollTop) && ((tt = H.current) == null ? void 0 : tt.scrollTop) < -10 ? /* @__PURE__ */ c(vn, {
655
667
  plain: !0,
656
668
  children: "没有更多数据了"
657
669
  }) : null,
658
- hasMore: $e,
670
+ hasMore: Be,
659
671
  loader: /* @__PURE__ */ c("div", {
660
672
  style: {
661
673
  height: "50px",
662
674
  textAlign: "center",
663
675
  overflow: "hidden"
664
676
  },
665
- children: /* @__PURE__ */ c(ht, {})
677
+ children: /* @__PURE__ */ c(ut, {})
666
678
  }),
667
679
  scrollableTarget: "scrollableDiv",
668
- children: [v.map((t, n) => /* @__PURE__ */ c(Vn, {
680
+ children: [v.map((t, n) => /* @__PURE__ */ c(Bn, {
669
681
  application: o,
670
682
  currentSession: e,
671
683
  history: t,
672
- docViewerUrl: q,
684
+ docViewerUrl: $,
673
685
  isLastHistory: n === 0,
674
- onRelatedClick: tn,
675
- onAgainClick: nn,
676
- onEditClick: en,
677
- markdown: r == null ? void 0 : r.markdown
678
- }, t.messageId + n)), !$e && Xe]
679
- }) : /* @__PURE__ */ B("div", {
686
+ onRelatedClick: nn,
687
+ onAgainClick: on,
688
+ onEditClick: tn,
689
+ markdown: s == null ? void 0 : s.markdown
690
+ }, t.messageId + n)), !Be && Ze]
691
+ }) : /* @__PURE__ */ z("div", {
680
692
  className: "main-empty",
681
- children: [(r == null ? void 0 : r.greeting) !== !1 && /* @__PURE__ */ c(Cn, {
682
- text: r === void 0 || r.greeting === !0 || ((nt = r.greeting) == null ? void 0 : nt.text) === void 0 ? yt.text : r.greeting.text,
683
- icon: r === void 0 || r.greeting === !0 || ((it = r.greeting) == null ? void 0 : it.icon) === void 0 ? Ct || yt.icon : r.greeting.icon,
684
- children: !!He.length && (((r == null ? void 0 : r.greeting) === void 0 || (r == null ? void 0 : r.greeting)) === !0 || typeof (r == null ? void 0 : r.greeting) == "object" && r.greeting.questions !== !1) && /* @__PURE__ */ c(Ln, {
685
- ref: we,
693
+ children: [(s == null ? void 0 : s.greeting) !== !1 && /* @__PURE__ */ c(Tn, {
694
+ text: s === void 0 || s.greeting === !0 || ((nt = s.greeting) == null ? void 0 : nt.text) === void 0 ? mt.text : s.greeting.text,
695
+ icon: s === void 0 || s.greeting === !0 || ((it = s.greeting) == null ? void 0 : it.icon) === void 0 ? Ct || mt.icon : s.greeting.icon,
696
+ children: !!De.length && (((s == null ? void 0 : s.greeting) === void 0 || (s == null ? void 0 : s.greeting)) === !0 || typeof (s == null ? void 0 : s.greeting) == "object" && s.greeting.questions !== !1) && /* @__PURE__ */ c(Pn, {
697
+ ref: xe,
686
698
  sid: (ot = e == null ? void 0 : e.data) == null ? void 0 : ot.id,
687
699
  isRecommendClearing: Ue,
688
- data: He,
689
- layoutBreakpoints: typeof (r == null ? void 0 : r.greeting) == "object" ? r.greeting.layoutBreakpoints : void 0,
700
+ data: De,
701
+ layoutBreakpoints: typeof (s == null ? void 0 : s.greeting) == "object" ? s.greeting.layoutBreakpoints : void 0,
690
702
  onItemClick: (t) => {
691
703
  var a, i, l;
692
- if (J(t == null ? void 0 : t.question), Y(t == null ? void 0 : t.question), Ue)
704
+ if (S(t == null ? void 0 : t.question), Y(t == null ? void 0 : t.question), Ue)
693
705
  return;
694
- t != null && t.id && _(!0);
706
+ t != null && t.id && X(!0);
695
707
  const n = (a = e == null ? void 0 : e.data) == null ? void 0 : a.id;
696
- g != null && g.fileUpload ? (l = (i = le.current) == null ? void 0 : i.clear()) == null || l.then(() => {
697
- var s, d;
698
- t != null && t.id && (n ? (s = _e(n, t)) == null || s.finally(() => {
699
- _(!1);
700
- }) : (_(!1), M(!0), (d = Ge()) == null || d.then((w) => {
708
+ g != null && g.fileUpload ? (l = (i = ce.current) == null ? void 0 : i.clear()) == null || l.then(() => {
709
+ var r, d;
710
+ t != null && t.id && (n ? (r = Ge(n, t)) == null || r.finally(() => {
711
+ X(!1);
712
+ }) : (X(!1), M(!0), (d = Xe()) == null || d.then((w) => {
701
713
  var y;
702
- (y = _e(w.id, t)) == null || y.finally(() => {
703
- _(!1);
714
+ (y = Ge(w.id, t)) == null || y.finally(() => {
715
+ X(!1);
704
716
  });
705
717
  })));
706
- }) : n ? _(!1) : (_(!1), M(!0), Ge());
718
+ }) : n ? X(!1) : (X(!1), M(!0), Xe());
707
719
  }
708
720
  })
709
- }), Xe]
721
+ }), Ze]
710
722
  })
711
723
  }), Ve && /* @__PURE__ */ c("div", {
712
724
  className: "session-stop",
713
- children: /* @__PURE__ */ c(X, {
725
+ children: /* @__PURE__ */ c(Q, {
714
726
  type: "primary",
715
727
  style: {
716
728
  background: "white"
717
729
  },
718
730
  ghost: !0,
719
731
  size: "small",
720
- icon: /* @__PURE__ */ c(he, {
732
+ icon: /* @__PURE__ */ c(ie, {
721
733
  type: "icon-zantinghuida",
722
734
  style: {
723
735
  fontSize: 16
724
736
  }
725
737
  }),
726
- onClick: () => Zt(),
738
+ onClick: () => Jt(),
727
739
  children: "停止回答"
728
740
  })
729
741
  }), Ae && (v == null ? void 0 : v.length) > 0 && /* @__PURE__ */ c("div", {
730
742
  className: "back-bottom",
731
- children: /* @__PURE__ */ c(X, {
743
+ children: /* @__PURE__ */ c(Q, {
732
744
  size: "small",
733
- onClick: () => Jt({
745
+ onClick: () => St({
734
746
  behavior: "smooth"
735
747
  }),
736
748
  type: "link",
737
- icon: /* @__PURE__ */ c(he, {
749
+ icon: /* @__PURE__ */ c(ie, {
738
750
  type: "icon-yijianhuidaodibu",
739
751
  style: {
740
752
  fontSize: 24
@@ -744,32 +756,32 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
744
756
  })]
745
757
  }), /* @__PURE__ */ c("div", {
746
758
  className: "chat-footer",
747
- children: /* @__PURE__ */ B("div", {
759
+ children: /* @__PURE__ */ z("div", {
748
760
  className: "chat-footer-input",
749
- children: [S && /* @__PURE__ */ c("div", {
761
+ children: [ee && /* @__PURE__ */ c("div", {
750
762
  className: "input-files",
751
- children: /* @__PURE__ */ c(xn, {
752
- file: S,
763
+ children: /* @__PURE__ */ c(Cn, {
764
+ file: ee,
753
765
  actions: {
754
- upload: Xt,
766
+ upload: Zt,
755
767
  remove: () => {
756
- W(void 0);
768
+ _(void 0);
757
769
  }
758
770
  },
759
- onUrlChange: (t) => oe(t)
771
+ onUrlChange: (t) => re(t)
760
772
  })
761
- }), /* @__PURE__ */ B(ge, {
773
+ }), /* @__PURE__ */ z(he, {
762
774
  className: "footer-upload-action",
763
775
  onClick: (t) => t.preventDefault(),
764
- children: [/* @__PURE__ */ B(ge, {
765
- children: [o.type === 2 && (g == null ? void 0 : g.imageUpload) && /* @__PURE__ */ c(pn, {
766
- disabled: !!S || D,
776
+ children: [/* @__PURE__ */ z(he, {
777
+ children: [o.type === 2 && (g == null ? void 0 : g.imageUpload) && /* @__PURE__ */ c(kn, {
778
+ disabled: !!ee || R,
767
779
  accept: ".jpg, .png, .jpeg,.bmp",
768
780
  listType: "picture-card",
769
- beforeUpload: Gt,
781
+ beforeUpload: Xt,
770
782
  className: "footer-upload-picture",
771
783
  showUploadList: !1,
772
- children: S ? /* @__PURE__ */ c(X, {
784
+ children: ee ? /* @__PURE__ */ c(Q, {
773
785
  type: "text",
774
786
  className: "camera-out-btn",
775
787
  style: {
@@ -777,20 +789,20 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
777
789
  position: "relative",
778
790
  bottom: "-2px"
779
791
  },
780
- disabled: !!S || D,
781
- icon: /* @__PURE__ */ c(Pn, {
792
+ disabled: !!ee || R,
793
+ icon: /* @__PURE__ */ c(On, {
782
794
  className: "icon-tianjia",
783
795
  style: {
784
796
  fontSize: "22px"
785
797
  }
786
798
  })
787
- }) : /* @__PURE__ */ c(vn, {
799
+ }) : /* @__PURE__ */ c(bn, {
788
800
  placement: "topLeft",
789
801
  overlayClassName: "footer-upload-tooltip",
790
802
  title: /* @__PURE__ */ c("div", {
791
803
  children: "支持上传.jpg .png .jpeg .bmp格式的图片数据,最大20M,单次仅可上传1个"
792
804
  }),
793
- children: /* @__PURE__ */ c(X, {
805
+ children: /* @__PURE__ */ c(Q, {
794
806
  type: "text",
795
807
  className: "camera-out-btn",
796
808
  style: {
@@ -798,7 +810,7 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
798
810
  position: "relative",
799
811
  bottom: "-2px"
800
812
  },
801
- icon: /* @__PURE__ */ c(he, {
813
+ icon: /* @__PURE__ */ c(ie, {
802
814
  type: "icon-Vector",
803
815
  className: "icon-tianjia",
804
816
  style: {
@@ -807,28 +819,28 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
807
819
  })
808
820
  })
809
821
  })
810
- }), ye && (g != null && g.fileUpload) && (o != null && o.id) ? /* @__PURE__ */ c(On, {
822
+ }), pe && (g != null && g.fileUpload) && (o != null && o.id) ? /* @__PURE__ */ c(Rn, {
811
823
  appId: o == null ? void 0 : o.id,
812
- ref: le,
813
- isFirstSession: Be,
814
- docViewerUrl: q,
824
+ ref: ce,
825
+ isFirstSession: qe,
826
+ docViewerUrl: $,
815
827
  onStatusChange: (t) => j(void 0, null, function* () {
816
- t !== "process" ? (de(!0), Le()) : de(!1);
828
+ t !== "process" ? (fe(!0), Ce()) : fe(!1);
817
829
  }),
818
830
  createSession: () => new Promise((t) => {
819
- M(!0), C == null || C({
820
- netOpen: E ? $.OPEN : $.CLOSE
831
+ M(!0), L == null || L({
832
+ netOpen: E ? B.OPEN : B.CLOSE
821
833
  }).then((n) => {
822
- var i, l, s;
823
- p == null || p(n), M(!1), P(!!((i = n.data) != null && i.netOpen)), G(!!((l = n.data) != null && l.enableNetOpen));
824
- const a = ((s = n.data) == null ? void 0 : s.id) || "";
834
+ var i, l, r;
835
+ p == null || p(n), M(!1), P(!!((i = n.data) != null && i.netOpen)), Z(!!((l = n.data) != null && l.enableNetOpen));
836
+ const a = ((r = n.data) == null ? void 0 : r.id) || "";
825
837
  t(a);
826
838
  });
827
839
  }),
828
- sid: (rt = e == null ? void 0 : e.data) == null ? void 0 : rt.id,
829
- disabled: xe || D,
840
+ sid: (st = e == null ? void 0 : e.data) == null ? void 0 : st.id,
841
+ disabled: Ie || R,
830
842
  afterFileAdd: (t, n) => {
831
- n && ae((a) => {
843
+ n && de((a) => {
832
844
  const i = a[n] || [];
833
845
  return {
834
846
  [n]: [...i, t]
@@ -838,114 +850,140 @@ ${t}` : t, l = new ne(i, a, Z.User, n);
838
850
  afterFileDelete: (t) => {
839
851
  var a;
840
852
  const n = (a = e == null ? void 0 : e.data) == null ? void 0 : a.id;
841
- n && ae((i) => {
853
+ n && de((i) => {
842
854
  const l = i[n] || [];
843
855
  return {
844
- [n]: l.filter((s) => s.id !== t)
856
+ [n]: l.filter((r) => r.id !== t)
845
857
  };
846
858
  });
847
859
  },
848
860
  onFileListChange: (t) => {
849
- zt(t);
861
+ jt(t);
850
862
  },
851
- shouldContinue: At,
863
+ shouldContinue: Vt,
852
864
  afterFilesClear: () => {
853
865
  var n;
854
866
  const t = (n = e == null ? void 0 : e.data) == null ? void 0 : n.id;
855
- t && (ae({
867
+ t && (de({
856
868
  [t]: []
857
- }), Le());
869
+ }), Ce());
858
870
  }
859
- }) : null, (g == null ? void 0 : g.prompt) && (o == null ? void 0 : o.id) && /* @__PURE__ */ c(jn, {
871
+ }) : null, (g == null ? void 0 : g.prompt) && (o == null ? void 0 : o.id) && /* @__PURE__ */ c(An, {
860
872
  appId: o.id,
861
873
  list: [],
862
- search: Me ? Dt : "",
874
+ search: Me ? Ht : "",
863
875
  onPromptSelect: (t) => {
864
- Y(t.context), J(t.context);
876
+ Y(t.context), S(t.context);
865
877
  },
866
- disabled: D
878
+ disabled: R
867
879
  })]
868
- }), /* @__PURE__ */ B(ge, {
869
- children: [(g == null ? void 0 : g.connectNetwork) && o.type === 0 && ((st = o.arrange) == null ? void 0 : st.length) && !!o.arrange[0].enableNetOpen && /* @__PURE__ */ c(Mn, {
880
+ }), /* @__PURE__ */ z(he, {
881
+ children: [(g == null ? void 0 : g.connectNetwork) && o.type === 0 && ((rt = o.arrange) == null ? void 0 : rt.length) && !!o.arrange[0].enableNetOpen && /* @__PURE__ */ c(Vn, {
870
882
  sessionId: (at = e == null ? void 0 : e.data) == null ? void 0 : at.id,
871
883
  netStatus: E,
872
- enable: typeof (r == null ? void 0 : r.connectNetwork) == "object" && typeof (r == null ? void 0 : r.connectNetwork.diabled) == "boolean" ? !(r != null && r.connectNetwork.diabled) : Kt,
884
+ enable: typeof (s == null ? void 0 : s.connectNetwork) == "object" && typeof (s == null ? void 0 : s.connectNetwork.diabled) == "boolean" ? !(s != null && s.connectNetwork.diabled) : Yt,
873
885
  disabledTip: e ? void 0 : "网络访问已被禁用",
874
886
  onNetStatusChange: (t) => {
875
887
  rn(t);
876
888
  }
877
- }), (g == null ? void 0 : g.sessionList) && /* @__PURE__ */ c(Dn, {
889
+ }), (g == null ? void 0 : g.sessionList) && /* @__PURE__ */ c(Mn, {
878
890
  currentSessionId: (lt = e == null ? void 0 : e.data) == null ? void 0 : lt.id,
879
891
  onSessionChange: (t, n) => {
880
892
  Y(void 0), p == null || p(n);
881
893
  },
882
- disabled: D
883
- }), Et && Pt === "float" && /* @__PURE__ */ c(Hn, {
884
- currentSession: e,
885
- application: o,
886
- networkStatus: E,
887
- setCurrentSession: p,
888
- sessions: bt,
889
- setSessions: wt,
890
- disabled: D
891
- }), (g == null ? void 0 : g.sessionOpen) && /* @__PURE__ */ c(X, {
892
- icon: /* @__PURE__ */ c(Tn, {}),
894
+ disabled: R
895
+ }), Lt && Et === "float" && /* @__PURE__ */ c("div", {
896
+ className: "session-history-drawer-component",
897
+ children: /* @__PURE__ */ c(wn, {
898
+ placement: "topRight",
899
+ showArrow: !1,
900
+ overlayClassName: "session-history-overlay",
901
+ overlayStyle: {
902
+ padding: "4px"
903
+ },
904
+ getPopupContainer: (t) => t.parentNode,
905
+ content: "会话历史记录",
906
+ children: /* @__PURE__ */ c(Q, {
907
+ className: "history-overlay-action",
908
+ disabled: R,
909
+ type: "text",
910
+ icon: /* @__PURE__ */ c(ie, {
911
+ type: "icon-lishijilu",
912
+ style: {
913
+ fontSize: 24
914
+ }
915
+ }),
916
+ onClick: () => Ke(!0)
917
+ })
918
+ })
919
+ }), (g == null ? void 0 : g.sessionOpen) && /* @__PURE__ */ c(Q, {
920
+ icon: /* @__PURE__ */ c(Hn, {}),
893
921
  className: "add-btn",
894
922
  type: "primary",
895
- disabled: Ve || !e || !v.length || D,
923
+ disabled: Ve || !e || !v.length || R,
896
924
  onClick: () => {
897
925
  var t, n;
898
- p == null || p(null), P(!1), (t = je.current) == null || t.clear(), (n = we.current) == null || n.clear();
926
+ p == null || p(null), P(!1), (t = je.current) == null || t.clear(), (n = xe.current) == null || n.clear();
899
927
  },
900
928
  children: "新会话"
901
929
  })]
902
930
  })]
903
931
  }), /* @__PURE__ */ c("div", {
904
932
  className: "footer-textarea",
905
- children: /* @__PURE__ */ c(Nn, {
906
- ref: re,
907
- maxLength: Tt,
908
- text: Ut,
933
+ children: /* @__PURE__ */ c(En, {
934
+ ref: ae,
935
+ maxLength: Pt,
936
+ text: Dt,
909
937
  networkStatus: !1,
910
- loading: qe,
911
- disabled: Fe || De || D || qe,
912
- onTextSend: Ke,
938
+ loading: $e,
939
+ disabled: Oe || Re || R || $e,
940
+ onTextSend: We,
913
941
  onChange: (t, n) => {
914
942
  Y(t);
915
943
  const a = n.getText().replace(/[\n\s]+$/, "");
916
- J(a), Ht(a), Me || Rt(!0);
944
+ S(a), Rt(a), Me || Ot(!0);
917
945
  },
918
- clearAction: /* @__PURE__ */ c(ge, {
946
+ clearAction: /* @__PURE__ */ c(he, {
919
947
  size: 0,
920
- children: /* @__PURE__ */ c(X, {
948
+ children: /* @__PURE__ */ c(Q, {
921
949
  type: "link",
922
- disabled: xe || D,
950
+ disabled: Ie || R,
923
951
  ghost: !0,
924
- icon: /* @__PURE__ */ c(he, {
952
+ icon: /* @__PURE__ */ c(ie, {
925
953
  style: {
926
954
  fontSize: 22
927
955
  },
928
956
  type: "icon-qingchujiyi"
929
957
  }),
930
- onClick: () => Qt()
958
+ onClick: () => _t()
931
959
  })
932
960
  })
933
961
  })
934
962
  })]
935
963
  })
936
- }), /* @__PURE__ */ c(En, {
937
- tips: Nt
938
- }), ze && /* @__PURE__ */ c(Fn, {
964
+ }), /* @__PURE__ */ c(Fn, {
965
+ tips: It
966
+ }), ze && /* @__PURE__ */ c(Dn, {
939
967
  isvisible: ze,
940
- files: jt,
968
+ files: Mt,
941
969
  sessionId: (dt = e == null ? void 0 : e.data) == null ? void 0 : dt.id,
942
970
  onClose: (t) => {
943
- Mt(!1), Bt(!1);
971
+ Ut(!1), At(!1);
944
972
  }
945
973
  })]
946
- })
974
+ }), Ye && /* @__PURE__ */ c(jn, {
975
+ currentSession: e,
976
+ application: o,
977
+ networkStatus: E,
978
+ setCurrentSession: p,
979
+ sessions: kt,
980
+ setSessions: bt,
981
+ disabled: R,
982
+ isSessionHistoryVisible: Ye,
983
+ setIsSessionHistoryVisible: Ke
984
+ })]
947
985
  });
948
986
  });
949
987
  export {
950
- yi as default
988
+ ki as default
951
989
  };