@glodon-aiot/agent-cli-ui 3.7.0-alpha.3 → 3.8.0-alpha.4

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,165 +1,176 @@
1
- var vt = Object.defineProperty;
1
+ var ut = Object.defineProperty;
2
2
  var Z = Object.getOwnPropertySymbols;
3
- var Nt = Object.prototype.hasOwnProperty, ut = Object.prototype.propertyIsEnumerable;
4
- var I = (N, m, e) => m in N ? vt(N, m, { enumerable: !0, configurable: !0, writable: !0, value: e }) : N[m] = e, tt = (N, m) => {
3
+ var Nt = Object.prototype.hasOwnProperty, wt = Object.prototype.propertyIsEnumerable;
4
+ var tt = (u, m, e) => m in u ? ut(u, m, { enumerable: !0, configurable: !0, writable: !0, value: e }) : u[m] = e, et = (u, m) => {
5
5
  for (var e in m || (m = {}))
6
- Nt.call(m, e) && I(N, e, m[e]);
6
+ Nt.call(m, e) && tt(u, e, m[e]);
7
7
  if (Z)
8
8
  for (var e of Z(m))
9
- ut.call(m, e) && I(N, e, m[e]);
10
- return N;
9
+ wt.call(m, e) && tt(u, e, m[e]);
10
+ return u;
11
11
  };
12
- var P = (N, m, e) => new Promise((n, b) => {
13
- var A = (u) => {
12
+ var _ = (u, m, e) => new Promise((l, b) => {
13
+ var k = (N) => {
14
14
  try {
15
- E(e.next(u));
16
- } catch (j) {
17
- b(j);
15
+ O(e.next(N));
16
+ } catch (L) {
17
+ b(L);
18
18
  }
19
- }, F = (u) => {
19
+ }, H = (N) => {
20
20
  try {
21
- E(e.throw(u));
22
- } catch (j) {
23
- b(j);
21
+ O(e.throw(N));
22
+ } catch (L) {
23
+ b(L);
24
24
  }
25
- }, E = (u) => u.done ? n(u.value) : Promise.resolve(u.value).then(A, F);
26
- E((e = e.apply(N, m)).next());
25
+ }, O = (N) => N.done ? l(N.value) : Promise.resolve(N.value).then(k, H);
26
+ O((e = e.apply(u, m)).next());
27
27
  });
28
28
  import { jsx as r, jsxs as M } from "react/jsx-runtime";
29
- import { forwardRef as gt, useState as x, useContext as kt, useEffect as Y, useImperativeHandle as wt, useMemo as At } from "react";
30
- import { Button as bt, Typography as Et, Space as et, Popconfirm as at, Input as Ot } from "antd";
29
+ import { forwardRef as At, useState as x, useContext as Et, useEffect as C, useImperativeHandle as kt, useMemo as bt } from "react";
30
+ import { Button as Ot, Typography as Mt, Space as at, Popconfirm as ot, Input as Lt } from "antd";
31
31
  import h from "dayjs";
32
- import Mt from "classnames";
32
+ import _t from "classnames";
33
33
  import dt from "../../components/Iconfont/index.mjs";
34
34
  import jt from "../../context.mjs";
35
- /* empty css */import { useMemoizedFn as ot } from "ahooks";
36
- import { NET_OPEN_STATUS as it } from "../../constant.mjs";
37
- import { useSessionState as Pt } from "../../hooks/useSessionState.mjs";
38
- const B = 15, Lt = gt((N, m) => {
35
+ /* empty css */import { useMemoizedFn as nt } from "ahooks";
36
+ import { MAX_KNOWLEDGES_AND_FILES_COUNT as T, NET_OPEN_STATUS as it } from "../../constant.mjs";
37
+ import { useSessionState as xt } from "../../hooks/useSessionState.mjs";
38
+ import { calcKnowledgesLeafCount as lt } from "../../utils/index.mjs";
39
+ const F = 15, Pt = At((u, m) => {
39
40
  const {
40
41
  currentSession: e,
41
- setCurrentSession: n,
42
+ setCurrentSession: l,
42
43
  checkKnowledges: b,
43
- application: A,
44
- networkStatus: F,
45
- isShowHeader: E = !0,
46
- afterSessionClick: u,
47
- sessionId: j
48
- } = N, [V, _] = x(), {
44
+ application: k,
45
+ networkStatus: H,
46
+ isShowHeader: O = !0,
47
+ afterSessionClick: N,
48
+ sessionId: L
49
+ } = u, [D, Y] = x(), {
49
50
  agentClient: v,
50
- mode: nt,
51
- features: a
52
- } = kt(jt), [R, C] = x(b), {
53
- sessions: L,
54
- setSessions: S
55
- } = Pt(), [K, D] = x(0), [lt, T] = x(""), [ct, z] = x(null), G = ot((t) => {
56
- t.id && S((d) => [...d.map((l) => {
51
+ mode: st,
52
+ features: o
53
+ } = Et(jt), [K, B] = x(b), {
54
+ sessions: j,
55
+ setSessions: P
56
+ } = xt(), [R, $] = x(0), [ct, S] = x(""), [rt, G] = x(null), U = nt((t) => {
57
+ t.id && P((a) => [...a.map((n) => {
57
58
  var s;
58
- return ((s = l.data) == null ? void 0 : s.id) === t.id && (l.data = tt({}, t)), l;
59
- })].sort((l, s) => {
60
- var w, k;
61
- const g = h((w = l.data) == null ? void 0 : w.createdAt).valueOf();
62
- return h((k = s.data) == null ? void 0 : k.createdAt).valueOf() - g;
59
+ return ((s = n.data) == null ? void 0 : s.id) === t.id && (n.data = et({}, t)), n;
60
+ })].sort((n, s) => {
61
+ var E, w;
62
+ const g = h((E = n.data) == null ? void 0 : E.createdAt).valueOf();
63
+ return h((w = s.data) == null ? void 0 : w.createdAt).valueOf() - g;
63
64
  }));
64
65
  });
65
- Y(() => {
66
- v == null || v.getSessions().then((t) => P(void 0, null, function* () {
67
- var d;
68
- if (S([...t]), !((d = e == null ? void 0 : e.data) != null && d.id) && (t != null && t.length) && nt === "inlay") {
69
- const o = t[0];
70
- j || n == null || n(o);
66
+ C(() => {
67
+ v == null || v.getSessions().then((t) => _(void 0, null, function* () {
68
+ var a;
69
+ if (P([...t]), !((a = e == null ? void 0 : e.data) != null && a.id) && (t != null && t.length) && st === "inlay") {
70
+ const d = t[0];
71
+ L || l == null || l(d);
71
72
  } else
72
- e === void 0 && (j || n == null || n(null));
73
+ e === void 0 && (L || l == null || l(null));
73
74
  }));
74
- }, []), Y(() => {
75
+ }, []), C(() => {
75
76
  var t;
76
77
  if (!((t = e == null ? void 0 : e.data) != null && t.id) && b === void 0) {
77
- const d = typeof (a == null ? void 0 : a.knowledges) == "object" && a.knowledges.default || void 0;
78
- C(d);
78
+ const a = typeof (o == null ? void 0 : o.knowledges) == "object" && o.knowledges.default || void 0;
79
+ if (Array.isArray(a) && a.some((n) => Array.isArray(n.fileIds) && n.fileIds.length === 0))
80
+ throw Error("fileIds cannot be an empty array");
81
+ if (lt(a || []) > T)
82
+ throw Error(`knowledges and fileIds total count cannot exceed ${T}`);
83
+ B(a);
79
84
  return;
80
85
  }
81
- C(b);
82
- }, [b]), Y(() => {
83
- e == null || e.addEventListener("data:updated", G);
84
- }, [e]), wt(m, () => ({
86
+ B(b);
87
+ }, [b]), C(() => {
88
+ e == null || e.addEventListener("data:updated", U);
89
+ }, [e]), kt(m, () => ({
85
90
  create(t) {
86
- return U(t).then((d) => (n == null || n(d), d));
91
+ return z(t).then((a) => (l == null || l(a), a));
87
92
  },
88
- list: () => Promise.resolve(L)
93
+ list: () => Promise.resolve(j)
89
94
  }));
90
- const U = (t) => {
91
- const d = typeof (a == null ? void 0 : a.connectNetwork) == "object" && typeof (a == null ? void 0 : a.connectNetwork.default) == "boolean" ? a.connectNetwork.default : !1;
92
- return new Promise((o) => P(void 0, null, function* () {
95
+ const z = (t) => {
96
+ const a = typeof (o == null ? void 0 : o.connectNetwork) == "object" && typeof (o == null ? void 0 : o.connectNetwork.default) == "boolean" ? o.connectNetwork.default : !1;
97
+ return new Promise((d) => _(void 0, null, function* () {
93
98
  var s;
94
- const f = typeof (a == null ? void 0 : a.promptVariables) == "object" ? (a == null ? void 0 : a.promptVariables.default) || [] : void 0, l = yield v == null ? void 0 : v.loadSession("", {
99
+ const f = typeof (o == null ? void 0 : o.promptVariables) == "object" ? (o == null ? void 0 : o.promptVariables.default) || [] : void 0, n = yield v == null ? void 0 : v.loadSession("", {
95
100
  name: t == null ? void 0 : t.name,
96
101
  // @ts-ignore netOpen入参是number 响应是boolen
97
102
  // 只有对话有联网 其它没有
98
103
  // 不传netOpen会默认取defaultNetOpen
99
- netOpen: (A == null ? void 0 : A.type) === 0 ? t != null && t.netOpen ? t.netOpen : d ? it.OPEN : it.CLOSE : void 0,
100
- knowledges: (s = e == null ? void 0 : e.data) != null && s.id ? t == null ? void 0 : t.knowledges : R,
104
+ netOpen: (k == null ? void 0 : k.type) === 0 ? t != null && t.netOpen ? t.netOpen : a ? it.OPEN : it.CLOSE : void 0,
105
+ knowledges: (s = e == null ? void 0 : e.data) != null && s.id ? t == null ? void 0 : t.knowledges : K,
101
106
  promptVariables: f
102
107
  });
103
- l == null || l.addEventListener("data:created", () => P(void 0, null, function* () {
104
- S([l, ...L]), o(l);
108
+ n == null || n.addEventListener("data:created", () => _(void 0, null, function* () {
109
+ P([n, ...j]), d(n);
105
110
  }));
106
111
  }));
107
- }, st = () => {
108
- U({
109
- knowledges: R
112
+ }, mt = () => {
113
+ z({
114
+ knowledges: K
110
115
  }).then((t) => {
111
- n == null || n(t);
116
+ l == null || l(t);
112
117
  });
113
- }, rt = (t) => {
114
- v == null || v.removeSession(t, !0).then(() => P(void 0, null, function* () {
115
- var o, f;
116
- const d = L.filter((l) => {
118
+ }, ft = (t) => {
119
+ v == null || v.removeSession(t, !0).then(() => _(void 0, null, function* () {
120
+ var d, f;
121
+ const a = j.filter((n) => {
117
122
  var s, g;
118
- return ((s = l.data) == null ? void 0 : s.id) !== ((g = t.data) == null ? void 0 : g.id);
123
+ return ((s = n.data) == null ? void 0 : s.id) !== ((g = t.data) == null ? void 0 : g.id);
119
124
  });
120
- ((o = t.data) == null ? void 0 : o.id) === ((f = e == null ? void 0 : e.data) == null ? void 0 : f.id) && (d != null && d.length ? n == null || n(d[0]) : n == null || n(null)), S([...d]);
125
+ ((d = t.data) == null ? void 0 : d.id) === ((f = e == null ? void 0 : e.data) == null ? void 0 : f.id) && (a != null && a.length ? l == null || l(a[0]) : l == null || l(null)), P([...a]);
121
126
  }));
122
- }, mt = (t) => {
123
- var d, o;
124
- _((d = t.data) == null ? void 0 : d.name), T(""), z(((o = t.data) == null ? void 0 : o.id) || null);
125
127
  }, pt = (t) => {
126
- const d = q(V || "");
127
- if (d) {
128
- T(d);
128
+ var a, d;
129
+ Y((a = t.data) == null ? void 0 : a.name), S(""), G(((d = t.data) == null ? void 0 : d.id) || null);
130
+ }, ht = (t) => {
131
+ const a = W(D || "");
132
+ if (a) {
133
+ S(a);
129
134
  return;
130
135
  }
131
- t.rename(V.trim()), t == null || t.addEventListener("data:updated", G), X();
132
- }, ht = () => {
136
+ t.rename(D.trim()), t == null || t.addEventListener("data:updated", U), X();
137
+ }, yt = () => {
133
138
  X();
134
139
  }, X = () => {
135
- z(null), _(""), T(""), D((t) => t + 1);
136
- }, q = (t) => !t || t.trim().length === 0 ? "会话名称不能为空" : t.length > B ? `不能超过${B}个字符` : "", ft = (t) => P(void 0, null, function* () {
137
- n == null || n(t), u == null || u(t);
138
- }), yt = (t) => {
139
- const d = t.target.value;
140
- _(d), T(q(d));
140
+ G(null), Y(""), S(""), $((t) => t + 1);
141
+ }, W = (t) => !t || t.trim().length === 0 ? "会话名称不能为空" : t.length > F ? `不能超过${F}个字符` : "", vt = (t) => _(void 0, null, function* () {
142
+ l == null || l(t), N == null || N(t);
143
+ }), gt = (t) => {
144
+ const a = t.target.value;
145
+ Y(a), S(W(a));
141
146
  };
142
- Y(() => {
143
- var d, o, f, l;
147
+ C(() => {
148
+ var a, d, f, n;
144
149
  if (!(e != null && e.id))
145
150
  return;
146
151
  const t = {};
147
- typeof (a == null ? void 0 : a.knowledges) == "object" && ((d = a == null ? void 0 : a.knowledges) != null && d.default) && (t.knowledges = (o = a == null ? void 0 : a.knowledges) == null ? void 0 : o.default), typeof (a == null ? void 0 : a.promptVariables) == "object" && ((f = a == null ? void 0 : a.promptVariables) != null && f.default) && (t.promptVariables = (l = a == null ? void 0 : a.promptVariables) == null ? void 0 : l.default), v == null || v.loadSession(e.id, t);
152
+ if (typeof (o == null ? void 0 : o.knowledges) == "object" && ((a = o == null ? void 0 : o.knowledges) != null && a.default)) {
153
+ if (t.knowledges = (d = o == null ? void 0 : o.knowledges) == null ? void 0 : d.default, Array.isArray(t.knowledges) && t.knowledges.some((A) => Array.isArray(A.fileIds) && A.fileIds.length === 0))
154
+ throw Error("fileIds cannot be an empty array");
155
+ if (lt(t.knowledges) > T)
156
+ throw Error(`knowledges and fileIds total count cannot exceed ${T}`);
157
+ }
158
+ typeof (o == null ? void 0 : o.promptVariables) == "object" && ((f = o == null ? void 0 : o.promptVariables) != null && f.default) && (t.promptVariables = (n = o == null ? void 0 : o.promptVariables) == null ? void 0 : n.default), v == null || v.loadSession(e.id, t);
148
159
  }, [e]);
149
- const J = ot((t) => {
150
- const d = h().endOf("day"), o = d.subtract(1, "day"), f = d.subtract(7, "day"), l = d.subtract(30, "day"), s = [], g = [], O = [], w = [], k = {};
160
+ const q = nt((t) => {
161
+ const a = h().endOf("day"), d = a.subtract(1, "day"), f = a.subtract(7, "day"), n = a.subtract(30, "day"), s = [], g = [], A = [], E = [], w = {};
151
162
  return t.forEach((c) => {
152
163
  var y;
153
164
  const i = h((y = c.data) == null ? void 0 : y.createdAt);
154
- if (i.isAfter(o))
165
+ if (i.isAfter(d))
155
166
  g.push(c);
156
167
  else if (i.isAfter(f))
157
- O.push(c);
158
- else if (i.isAfter(l))
159
- w.push(c);
168
+ A.push(c);
169
+ else if (i.isAfter(n))
170
+ E.push(c);
160
171
  else {
161
172
  const p = i.format("YYYY-MM");
162
- k[p] || (k[p] = []), k[p].push(c);
173
+ w[p] || (w[p] = []), w[p].push(c);
163
174
  }
164
175
  }), g.length > 0 && s.push({
165
176
  title: "今天",
@@ -168,24 +179,24 @@ const B = 15, Lt = gt((N, m) => {
168
179
  return h((y = i.data) == null ? void 0 : y.createdAt).valueOf() - h((p = c.data) == null ? void 0 : p.createdAt).valueOf();
169
180
  }),
170
181
  key: "today"
171
- }), O.length > 0 && s.push({
182
+ }), A.length > 0 && s.push({
172
183
  title: "7天内",
173
- sessions: O.sort((c, i) => {
184
+ sessions: A.sort((c, i) => {
174
185
  var y, p;
175
186
  return h((y = i.data) == null ? void 0 : y.createdAt).valueOf() - h((p = c.data) == null ? void 0 : p.createdAt).valueOf();
176
187
  }),
177
188
  key: "seven-days"
178
- }), w.length > 0 && s.push({
189
+ }), E.length > 0 && s.push({
179
190
  title: "30天内",
180
- sessions: w.sort((c, i) => {
191
+ sessions: E.sort((c, i) => {
181
192
  var y, p;
182
193
  return h((y = i.data) == null ? void 0 : y.createdAt).valueOf() - h((p = c.data) == null ? void 0 : p.createdAt).valueOf();
183
194
  }),
184
195
  key: "thirty-days"
185
- }), Object.keys(k).sort((c, i) => i.localeCompare(c)).forEach((c) => {
186
- const i = k[c].sort((y, p) => {
187
- var Q, W;
188
- return h((Q = p.data) == null ? void 0 : Q.createdAt).valueOf() - h((W = y.data) == null ? void 0 : W.createdAt).valueOf();
196
+ }), Object.keys(w).sort((c, i) => i.localeCompare(c)).forEach((c) => {
197
+ const i = w[c].sort((y, p) => {
198
+ var J, Q;
199
+ return h((J = p.data) == null ? void 0 : J.createdAt).valueOf() - h((Q = y.data) == null ? void 0 : Q.createdAt).valueOf();
189
200
  });
190
201
  s.push({
191
202
  title: h(c).format("YYYY年MM月"),
@@ -193,50 +204,50 @@ const B = 15, Lt = gt((N, m) => {
193
204
  key: `month-${c}`
194
205
  });
195
206
  }), s;
196
- }), $ = At(() => J(L), [L, J]);
207
+ }), V = bt(() => q(j), [j, q]);
197
208
  return /* @__PURE__ */ r("div", {
198
209
  className: "bot-session-container",
199
210
  children: /* @__PURE__ */ M("div", {
200
211
  className: "agent-sessions",
201
- children: [E && (a == null ? void 0 : a.siderTitle) && /* @__PURE__ */ r("div", {
212
+ children: [O && (o == null ? void 0 : o.siderTitle) && /* @__PURE__ */ r("div", {
202
213
  className: "sessions-header",
203
214
  children: /* @__PURE__ */ r("div", {
204
215
  className: "session-header-title",
205
- children: (A == null ? void 0 : A.name) || "-"
216
+ children: (k == null ? void 0 : k.name) || "-"
206
217
  })
207
218
  }), /* @__PURE__ */ M("div", {
208
219
  className: "sessions-main",
209
- children: [E && /* @__PURE__ */ r("div", {
220
+ children: [O && /* @__PURE__ */ r("div", {
210
221
  className: "session-header-btn-wrapper",
211
- children: /* @__PURE__ */ r(bt, {
222
+ children: /* @__PURE__ */ r(Ot, {
212
223
  className: "session-header-btn",
213
- onClick: st,
224
+ onClick: mt,
214
225
  type: "primary",
215
226
  children: "+ 新会话"
216
227
  })
217
- }), $ == null ? void 0 : $.map((t) => {
218
- var d;
228
+ }), V == null ? void 0 : V.map((t) => {
229
+ var a;
219
230
  return /* @__PURE__ */ M("div", {
220
231
  className: "session-group",
221
232
  children: [/* @__PURE__ */ r("div", {
222
233
  className: "group-header",
223
234
  style: {
224
- top: E ? 48 : 0
235
+ top: O ? 48 : 0
225
236
  },
226
237
  children: t.title
227
- }), (d = t.sessions) == null ? void 0 : d.map((o) => {
228
- var f, l, s, g, O, w, k, H, c;
238
+ }), (a = t.sessions) == null ? void 0 : a.map((d) => {
239
+ var f, n, s, g, A, E, w, I, c;
229
240
  return /* @__PURE__ */ r("div", {
230
- className: Mt({
241
+ className: _t({
231
242
  "session-item": !0,
232
- "session-item__active": ((f = o.data) == null ? void 0 : f.id) === ((l = e == null ? void 0 : e.data) == null ? void 0 : l.id)
243
+ "session-item__active": ((f = d.data) == null ? void 0 : f.id) === ((n = e == null ? void 0 : e.data) == null ? void 0 : n.id)
233
244
  }),
234
- onClick: () => ft(o),
245
+ onClick: () => vt(d),
235
246
  children: /* @__PURE__ */ r("div", {
236
247
  className: "session-item-wrapper",
237
248
  children: /* @__PURE__ */ M("div", {
238
249
  className: "session-item-top",
239
- children: [/* @__PURE__ */ r(Et.Paragraph, {
250
+ children: [/* @__PURE__ */ r(Mt.Paragraph, {
240
251
  className: "item-top-title",
241
252
  style: {
242
253
  margin: 0,
@@ -245,45 +256,45 @@ const B = 15, Lt = gt((N, m) => {
245
256
  ellipsis: {
246
257
  rows: 1,
247
258
  tooltip: {
248
- title: ((s = o.data) == null ? void 0 : s.name) || "-",
259
+ title: ((s = d.data) == null ? void 0 : s.name) || "-",
249
260
  placement: "topLeft"
250
261
  }
251
262
  },
252
- children: ((g = o.data) == null ? void 0 : g.name) || "-"
253
- }), /* @__PURE__ */ M(et, {
263
+ children: ((g = d.data) == null ? void 0 : g.name) || "-"
264
+ }), /* @__PURE__ */ M(at, {
254
265
  children: [/* @__PURE__ */ r("span", {
255
266
  className: "item-top-time",
256
- children: h((O = o.data) == null ? void 0 : O.createdAt).format("MM/DD HH:mm:ss")
267
+ children: h((A = d.data) == null ? void 0 : A.createdAt).format("MM/DD HH:mm:ss")
257
268
  }), /* @__PURE__ */ M("div", {
258
269
  className: "item-top-action",
259
270
  onClick: (i) => i.stopPropagation(),
260
- children: [/* @__PURE__ */ r(at, {
261
- open: ct === ((w = o.data) == null ? void 0 : w.id),
271
+ children: [/* @__PURE__ */ r(ot, {
272
+ open: rt === ((E = d.data) == null ? void 0 : E.id),
262
273
  getPopupContainer: (i) => i.parentNode,
263
274
  icon: !1,
264
- title: /* @__PURE__ */ r(Ot, {
275
+ title: /* @__PURE__ */ r(Lt, {
265
276
  placeholder: "请输入内容",
266
277
  autoComplete: "off",
267
278
  showCount: !0,
268
- value: V,
269
- onChange: yt,
270
- maxLength: B,
271
- status: lt ? "error" : ""
279
+ value: D,
280
+ onChange: gt,
281
+ maxLength: F,
282
+ status: ct ? "error" : ""
272
283
  }),
273
- onConfirm: () => pt(o),
274
- onCancel: ht,
284
+ onConfirm: () => ht(d),
285
+ onCancel: yt,
275
286
  children: /* @__PURE__ */ r(dt, {
276
287
  type: "icon-bianji2",
277
- onClick: () => mt(o),
288
+ onClick: () => pt(d),
278
289
  className: "icon-action",
279
290
  style: {
280
291
  marginRight: "8px"
281
292
  }
282
293
  })
283
- }, `edit-${(k = o.data) == null ? void 0 : k.id}-${K}`), /* @__PURE__ */ r(at, {
294
+ }, `edit-${(w = d.data) == null ? void 0 : w.id}-${R}`), /* @__PURE__ */ r(ot, {
284
295
  getPopupContainer: (i) => i.parentNode,
285
296
  icon: !1,
286
- title: /* @__PURE__ */ M(et, {
297
+ title: /* @__PURE__ */ M(at, {
287
298
  direction: "vertical",
288
299
  children: [/* @__PURE__ */ r("div", {
289
300
  children: "删除确认?"
@@ -292,10 +303,10 @@ const B = 15, Lt = gt((N, m) => {
292
303
  })]
293
304
  }),
294
305
  onConfirm: () => {
295
- rt(o), D((i) => i + 1);
306
+ ft(d), $((i) => i + 1);
296
307
  },
297
308
  onCancel: () => {
298
- D((i) => i + 1);
309
+ $((i) => i + 1);
299
310
  },
300
311
  children: /* @__PURE__ */ r(dt, {
301
312
  style: {
@@ -304,12 +315,12 @@ const B = 15, Lt = gt((N, m) => {
304
315
  className: "icon-action",
305
316
  type: "icon-del"
306
317
  })
307
- }, `delete-${(H = o.data) == null ? void 0 : H.id}-${K}`)]
318
+ }, `delete-${(I = d.data) == null ? void 0 : I.id}-${R}`)]
308
319
  })]
309
320
  })]
310
321
  })
311
322
  })
312
- }, (c = o.data) == null ? void 0 : c.id);
323
+ }, (c = d.data) == null ? void 0 : c.id);
313
324
  })]
314
325
  }, t.key);
315
326
  })]
@@ -317,7 +328,7 @@ const B = 15, Lt = gt((N, m) => {
317
328
  })
318
329
  });
319
330
  });
320
- Lt.displayName = "SessionList";
331
+ Pt.displayName = "SessionList";
321
332
  export {
322
- Lt as default
333
+ Pt as default
323
334
  };
@@ -1,73 +1,79 @@
1
- import { jsxs as u, jsx as A } from "react/jsx-runtime";
2
- import { useContext as H, useState as r, useEffect as v } from "react";
3
- /* empty css */import K from "../../context.mjs";
4
- import { Space as q } from "antd";
5
- import z from "./KnowledgeSelect/index.mjs";
6
- const M = (y) => {
7
- var j, x;
1
+ import { jsxs as x, jsx as F } from "react/jsx-runtime";
2
+ import { useContext as K, useState as c, useEffect as j } from "react";
3
+ /* empty css */import L from "../../context.mjs";
4
+ import { Space as D } from "antd";
5
+ import O from "./KnowledgeSelect/index.mjs";
6
+ import { MAX_KNOWLEDGES_AND_FILES_COUNT as I } from "../../constant.mjs";
7
+ import { calcKnowledgesLeafCount as G } from "../../utils/index.mjs";
8
+ const z = (N) => {
9
+ var A, b;
8
10
  const {
9
11
  currentSession: t,
10
12
  application: o,
11
- setCheckKnowledges: g
12
- } = y, {
13
- mode: h,
14
- transform: w,
13
+ setCheckKnowledges: s
14
+ } = N, {
15
+ mode: C,
16
+ transform: p,
15
17
  features: n
16
- } = H(K), [d, k] = r([]), [f, p] = r(typeof (n == null ? void 0 : n.knowledges) == "object" ? ((j = n.knowledges.default) == null ? void 0 : j.map((e) => e.id)) || [] : []), [E, c] = r(0), [C, b] = r(!1);
17
- v(() => {
18
+ } = K(L), [a, v] = c([]), [m, w] = c(typeof (n == null ? void 0 : n.knowledges) == "object" ? ((A = n.knowledges.default) == null ? void 0 : A.map((e) => e.id)) || [] : []), [S, h] = c(0), [E, u] = c(!1);
19
+ j(() => {
18
20
  if (!(o != null && o.id))
19
21
  return;
20
22
  const e = o.arrange;
21
23
  if (!(e != null && e.length))
22
24
  return;
23
- const s = e[0].knowledges || [];
24
- k(s);
25
- const l = typeof (n == null ? void 0 : n.knowledges) == "object" && n.knowledges.default || s;
25
+ const l = e[0].knowledges || [];
26
+ v(l);
27
+ const d = typeof (n == null ? void 0 : n.knowledges) == "object" && n.knowledges.default || l;
28
+ if (Array.isArray(d) && d.some((i) => Array.isArray(i.fileIds) && i.fileIds.length === 0))
29
+ throw Error("fileIds cannot be an empty array");
30
+ if (G(d || []) > I)
31
+ throw Error(`knowledges and fileIds total count cannot exceed ${I}`);
26
32
  if (!t) {
27
- p(l.map((i) => i.id)), c(l.length), g == null || g(l);
33
+ w(d.map((f) => f.id)), h(d.length), s == null || s(d);
28
34
  return;
29
35
  }
30
- const a = () => {
31
- const i = t.knowledges || l;
32
- c(i.length);
33
- const N = i.map((S) => S.id);
34
- p(N);
36
+ const y = () => {
37
+ const f = t.knowledges || d;
38
+ h(f.length);
39
+ const i = f.map((k) => k.id);
40
+ w(i);
35
41
  };
36
- return a(), t.addEventListener("data:updated", a), () => {
37
- t == null || t.removeEventListener("data:updated", a);
42
+ return y(), t.addEventListener("data:updated", y), () => {
43
+ t == null || t.removeEventListener("data:updated", y);
38
44
  };
39
- }, [o, t]), v(() => {
40
- var m;
41
- if (!C || (b(!1), !(o != null && o.id)))
45
+ }, [o, t]), j(() => {
46
+ var r;
47
+ if (!E || (u(!1), !(o != null && o.id)))
42
48
  return;
43
49
  const e = [];
44
- f == null || f.map((s) => {
45
- const l = d == null ? void 0 : d.find((a) => a.id === s);
46
- e.push(l);
47
- }), (m = t == null ? void 0 : t.data) != null && m.id && t.setKnowledges(e);
48
- }, [C]);
49
- const F = (e) => {
50
- b(!0), p(e);
51
- const m = [];
52
- e == null || e.map((s) => {
53
- const l = d == null ? void 0 : d.find((a) => a.id === s);
54
- m.push(l);
55
- }), g == null || g(m), c(e.length);
50
+ m == null || m.map((l) => {
51
+ const d = a == null ? void 0 : a.find((g) => g.id === l);
52
+ e.push(d);
53
+ }), (r = t == null ? void 0 : t.data) != null && r.id && t.setKnowledges(e);
54
+ }, [E]);
55
+ const _ = (e) => {
56
+ u(!0), w(e);
57
+ const r = [];
58
+ e == null || e.map((l) => {
59
+ const d = a == null ? void 0 : a.find((g) => g.id === l);
60
+ r.push(d);
61
+ }), s == null || s(r), h(e.length);
56
62
  };
57
- return /* @__PURE__ */ u("div", {
63
+ return /* @__PURE__ */ x("div", {
58
64
  className: "chat-header",
59
- children: [/* @__PURE__ */ u(q, {
65
+ children: [/* @__PURE__ */ x(D, {
60
66
  className: "header-title",
61
- children: [h === "inlay" && ((x = t == null ? void 0 : t.data) == null ? void 0 : x.name), h === "float" && (o == null ? void 0 : o.name)]
62
- }), (w == null ? void 0 : w.knowledges) && d.length !== 0 && /* @__PURE__ */ A(z, {
67
+ children: [C === "inlay" && ((b = t == null ? void 0 : t.data) == null ? void 0 : b.name), C === "float" && (o == null ? void 0 : o.name)]
68
+ }), (p == null ? void 0 : p.knowledges) && a.length !== 0 && /* @__PURE__ */ F(O, {
63
69
  disabled: typeof (n == null ? void 0 : n.knowledges) == "object" && (n == null ? void 0 : n.knowledges.diabled) || !1,
64
- checkedValues: f,
65
- currKnowledgeList: d,
66
- selectCount: E,
67
- onSelectChange: F
70
+ checkedValues: m,
71
+ currKnowledgeList: a,
72
+ selectCount: S,
73
+ onSelectChange: _
68
74
  })]
69
75
  });
70
76
  };
71
77
  export {
72
- M as default
78
+ z as default
73
79
  };
@@ -105,16 +105,17 @@ const u = {
105
105
  doc: r,
106
106
  docx: s,
107
107
  pdf: o
108
- }, b = {
108
+ }, N = {
109
109
  OPEN: 1,
110
110
  CLOSE: 2
111
- };
111
+ }, b = 100;
112
112
  export {
113
113
  h as FILE_ICONS,
114
114
  g as GB,
115
115
  m as KB,
116
+ b as MAX_KNOWLEDGES_AND_FILES_COUNT,
116
117
  d as MB,
117
- b as NET_OPEN_STATUS,
118
+ N as NET_OPEN_STATUS,
118
119
  t as brand,
119
120
  c as defaultApiUrl,
120
121
  f as defaultDovViewerUrl,