@glodon-aiot/agent-cli-ui 3.3.2-beta.2 → 3.3.2-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/es/AgentClientUI.mjs +121 -109
  2. package/dist/es/Dialog/AgentChat/HistoryItem/index.mjs +161 -147
  3. package/dist/es/Dialog/AgentChat/index.mjs +265 -250
  4. package/dist/es/Dialog/SessionList/index.mjs +35 -34
  5. package/dist/es/Dialog/index.mjs +101 -94
  6. package/dist/es/ReactTextGenerationUI/components/TextSiders/index.mjs +363 -0
  7. package/dist/es/ReactTextGenerationUI/components/fetchEventSource/fetch.mjs +112 -0
  8. package/dist/es/ReactTextGenerationUI/components/fetchEventSource/parse.mjs +97 -0
  9. package/dist/es/ReactTextGenerationUI/index.mjs +79 -0
  10. package/dist/es/components/FilePreview/index.mjs +26 -25
  11. package/dist/es/index.mjs +402 -217
  12. package/dist/es/node_modules/moment/dist/moment.mjs +2301 -0
  13. package/dist/es/packages/agent-cli-ui/package.json.mjs +162 -0
  14. package/dist/es/packages/react-components/dist/es/components/Markdown/ATag/index.mjs +27 -25
  15. package/dist/es/packages/react-components/dist/es/components/Markdown/Image/index.mjs +29 -27
  16. package/dist/es/packages/react-components/dist/es/components/Markdown/index.mjs +58 -48
  17. package/dist/es/packages/react-components/dist/es/index.mjs +1 -1
  18. package/dist/es/src/style.css +1 -1
  19. package/dist/es/src/style10.css +1 -1
  20. package/dist/es/src/style11.css +1 -1
  21. package/dist/es/src/style12.css +1 -1
  22. package/dist/es/src/style13.css +1 -1
  23. package/dist/es/src/style14.css +1 -1
  24. package/dist/es/src/style15.css +1 -1
  25. package/dist/es/src/style16.css +1 -1
  26. package/dist/es/src/style17.css +1 -1
  27. package/dist/es/src/style18.css +1 -1
  28. package/dist/es/src/style19.css +1 -1
  29. package/dist/es/src/style2.css +1 -1
  30. package/dist/es/src/style20.css +1 -1
  31. package/dist/es/src/style21.css +1 -1
  32. package/dist/es/src/style22.css +1 -1
  33. package/dist/es/src/style23.css +1 -1
  34. package/dist/es/src/style24.css +1 -1
  35. package/dist/es/src/style25.css +1 -1
  36. package/dist/es/src/style26.css +1 -1
  37. package/dist/es/src/style27.css +1 -1
  38. package/dist/es/src/style28.css +1 -1
  39. package/dist/es/src/style29.css +1 -1
  40. package/dist/es/src/style3.css +1 -1
  41. package/dist/es/src/style30.css +1 -0
  42. package/dist/es/src/style31.css +1 -0
  43. package/dist/es/src/style4.css +1 -1
  44. package/dist/es/src/style5.css +1 -1
  45. package/dist/es/src/style6.css +1 -1
  46. package/dist/es/src/style7.css +1 -1
  47. package/dist/es/src/style8.css +1 -1
  48. package/dist/es/src/style9.css +1 -1
  49. package/dist/lib/index.css +1 -1
  50. package/dist/lib/index.js +69 -58
  51. package/dist/src/AgentClientUI.d.ts +10 -2
  52. package/dist/src/Dialog/AgentChat/HistoryItem/index.d.ts +2 -0
  53. package/dist/src/Dialog/SessionList/index.d.ts +1 -0
  54. package/dist/src/Dialog/index.d.ts +9 -1
  55. package/dist/src/ReactTextGenerationUI/components/TextSiders/index.d.ts +21 -0
  56. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/fetch.d.ts +44 -0
  57. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/index.d.ts +1 -0
  58. package/dist/src/ReactTextGenerationUI/components/fetchEventSource/parse.d.ts +36 -0
  59. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/fetch.d.ts +44 -0
  60. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/index.d.ts +1 -0
  61. package/dist/src/ReactTextGenerationUI/components/fetchEventSourcea/parse.d.ts +36 -0
  62. package/dist/src/ReactTextGenerationUI/index.d.ts +4 -0
  63. package/dist/src/index.d.ts +11 -2
  64. package/dist/src/types.d.ts +8 -3
  65. package/package.json +3 -3
@@ -0,0 +1,363 @@
1
+ var me = Object.defineProperty, ue = Object.defineProperties;
2
+ var ge = Object.getOwnPropertyDescriptors;
3
+ var $ = Object.getOwnPropertySymbols;
4
+ var fe = Object.prototype.hasOwnProperty, he = Object.prototype.propertyIsEnumerable;
5
+ var j = (s, l, t) => l in s ? me(s, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[l] = t, S = (s, l) => {
6
+ for (var t in l || (l = {}))
7
+ fe.call(l, t) && j(s, t, l[t]);
8
+ if ($)
9
+ for (var t of $(l))
10
+ he.call(l, t) && j(s, t, l[t]);
11
+ return s;
12
+ }, z = (s, l) => ue(s, ge(l));
13
+ var A = (s, l, t) => new Promise((C, N) => {
14
+ var x = (g) => {
15
+ try {
16
+ I(t.next(g));
17
+ } catch (y) {
18
+ N(y);
19
+ }
20
+ }, p = (g) => {
21
+ try {
22
+ I(t.throw(g));
23
+ } catch (y) {
24
+ N(y);
25
+ }
26
+ }, I = (g) => g.done ? C(g.value) : Promise.resolve(g.value).then(x, p);
27
+ I((t = t.apply(s, l)).next());
28
+ });
29
+ import { jsxs as v, jsx as o, Fragment as Ie } from "react/jsx-runtime";
30
+ import { useState as u, useRef as ye, useContext as ke, useEffect as b } from "react";
31
+ import { Form as R, Space as ve, Button as E, Input as J, message as q, notification as xe } from "antd";
32
+ import { v4 as Ce } from "uuid";
33
+ import we from "../../../context.mjs";
34
+ import U from "../../../components/Iconfont/index.mjs";
35
+ import Se from "../../../components/KnowledgeList/KnowledgeSelect/index.mjs";
36
+ import "../../../packages/react-components/dist/es/index.mjs";
37
+ import be from "../../../Dialog/AgentChat/HistoryItem/SessionRefer/index.mjs";
38
+ import Ne from "../../../node_modules/moment/dist/moment.mjs";
39
+ /* empty css */import { fetchEventSource as pe } from "../fetchEventSource/fetch.mjs";
40
+ import { Markdown as Te } from "../../../packages/react-components/dist/es/components/Markdown/index.mjs";
41
+ const ze = ({
42
+ application: s,
43
+ sessionId: l
44
+ }) => {
45
+ const t = s.id, [C, N] = u(""), [x, p] = u(""), [I, g] = u(), [y, w] = u(!1), B = ye(null), [D, W] = u([]), [T, H] = u([]), [G, K] = u(0), [Q, O] = u(), [c, P] = u(), [Y] = R.useForm(), [M, X] = u(!1), [V, Z] = u({}), [_, ee] = u(0), {
46
+ service: f,
47
+ agentClient: k,
48
+ beforeMessageSend: Ae,
49
+ popupContainer: F,
50
+ icon: Pe,
51
+ token: ne,
52
+ apiUrl: re
53
+ } = ke(we), te = (n, a, m, e) => {
54
+ const r = {
55
+ messageId: Ce(),
56
+ content: "",
57
+ role: 1,
58
+ sessionId: "",
59
+ reference: [],
60
+ messageTime: "",
61
+ llmModel: "",
62
+ searchReference: []
63
+ }, d = z(S({}, m), {
64
+ stream: !0
65
+ });
66
+ pe(`${re}/chat/v2/chat?applicationId=${n}&sessionId=${a}`, {
67
+ method: "POST",
68
+ headers: {
69
+ Authorization: `Bearer ${ne}`,
70
+ "Content-Type": "application/json"
71
+ },
72
+ body: JSON.stringify(d),
73
+ openWhenHidden: !0,
74
+ onopen(i) {
75
+ return console.log("onopen"), i.ok && e != null && e.onopen && e.onopen(), Promise.resolve();
76
+ },
77
+ onmessage(i) {
78
+ if (!i.id && !i.data && !i.event && !i.retry)
79
+ return;
80
+ if (!i.data.includes('{"code": ')) {
81
+ r.content = r.content + i.data;
82
+ const L = {
83
+ content: r.content,
84
+ role: 1,
85
+ reference: r.reference,
86
+ messageId: r.messageId,
87
+ sessionId: a,
88
+ messageTime: Ne(/* @__PURE__ */ new Date()).format("YYYY-MM-DD HH:mm:ss"),
89
+ searchReference: []
90
+ };
91
+ return (e == null ? void 0 : e.onmessage) && e.onmessage(L);
92
+ }
93
+ const h = JSON.parse(i.data);
94
+ if (r.reference = h.data.reference, r.messageTime = h.data.messageTime, r.messageId = h.data.messageId, r.llmModel = h.data.llmModel, r.content = h.data.content, r.code = h.code, h.code === 200) {
95
+ const L = {
96
+ code: r.code,
97
+ content: r.content,
98
+ role: 1,
99
+ reference: r.reference,
100
+ messageId: r.messageId,
101
+ sessionId: a,
102
+ messageTime: r.messageTime,
103
+ searchReference: []
104
+ };
105
+ e != null && e.onmessage && e.onmessage(L);
106
+ } else
107
+ return xe.error({
108
+ message: h.message
109
+ });
110
+ },
111
+ onerror() {
112
+ e != null && e.onerror && e.onerror();
113
+ },
114
+ onclose() {
115
+ console.log("onclose");
116
+ const i = {
117
+ code: r.code,
118
+ content: r.content,
119
+ role: 1,
120
+ reference: r.reference,
121
+ messageId: r.messageId,
122
+ sessionId: a,
123
+ messageTime: r.messageTime,
124
+ comment: {
125
+ isAgree: 0
126
+ },
127
+ searchReference: []
128
+ };
129
+ e != null && e.onclose && e.onclose(i);
130
+ }
131
+ });
132
+ };
133
+ b(() => {
134
+ if (!(s != null && s.id))
135
+ return;
136
+ const n = s.arrange;
137
+ if (!(n != null && n.length))
138
+ return;
139
+ const m = n[0].knowledges || [];
140
+ W(m), K(m.length);
141
+ const e = m.map((r) => r.id);
142
+ H(e);
143
+ }, [s]), b(() => {
144
+ if (!(s != null && s.id) || !k)
145
+ return;
146
+ const n = k.questionContextMaxLength || 4e3;
147
+ ee(n), se();
148
+ }, [s, k]);
149
+ const se = () => A(void 0, null, function* () {
150
+ if (!f || !t)
151
+ return;
152
+ const n = yield f.postApplicationIdSession({
153
+ name: "AI 会话",
154
+ applicationId: t
155
+ });
156
+ debugger;
157
+ O(n);
158
+ });
159
+ b(() => {
160
+ t && (f == null || f.getApplicationIdPromptVariables(t, {
161
+ status: 1
162
+ }).then((n) => {
163
+ const m = n.filter((e) => e.key !== "query").map((e) => ({
164
+ id: e.id,
165
+ key: e.key,
166
+ name: e.name,
167
+ value: ""
168
+ }));
169
+ P(m);
170
+ }));
171
+ }, [f]), b(() => {
172
+ if (!c)
173
+ return;
174
+ const n = {};
175
+ c == null || c.map((a) => {
176
+ a.key && (n[a.key] = a.value);
177
+ }), Y.setFieldsValue(S({}, n)), Z(n);
178
+ }, [c]);
179
+ const oe = (n, a) => {
180
+ }, ae = (n) => {
181
+ N(n.target.value);
182
+ }, ce = () => A(void 0, null, function* () {
183
+ if (w(!0), !t || !f || !k)
184
+ return;
185
+ for (const e in V)
186
+ V[e] || (w(!1), q.config({
187
+ getContainer: () => (F == null ? void 0 : F.current) || document.body
188
+ }), q.error("变量值不能为空"), q.config({
189
+ getContainer: void 0
190
+ }));
191
+ const n = yield f.postApplicationIdSession({
192
+ name: "AI 会话",
193
+ applicationId: t
194
+ });
195
+ debugger;
196
+ O(n);
197
+ const a = T == null ? void 0 : T.map((e) => e.toString()), m = {
198
+ content: C,
199
+ chatMode: 1,
200
+ knowledges: a,
201
+ promptVariables: V
202
+ };
203
+ te(t, n.id, m, {
204
+ onmessage: (e) => {
205
+ w(!0), g(void 0), p(e.content);
206
+ },
207
+ onclose: (e) => A(void 0, null, function* () {
208
+ if (w(!1), e.code == 200) {
209
+ p(e.content);
210
+ const r = yield Promise.all(e.reference.map((d) => f.getKnowledgeIdFileId(d.knowledgeId, d.docId)));
211
+ e.reference = e.reference.map((d, i) => S(S({}, d), r[i])), g(e);
212
+ }
213
+ }),
214
+ onerror: () => {
215
+ w(!1);
216
+ }
217
+ }), c && f.getApplicationIdSessionIdPromptVariables(t, n.id).then((e) => {
218
+ const r = e.filter((d) => d.key !== "query").map((d) => {
219
+ const i = c.filter((h) => h.key === d.key);
220
+ return d.value = i[0].value, d;
221
+ });
222
+ Promise.all(r.map((d) => {
223
+ oe(d.id, d.value);
224
+ })), P(r);
225
+ });
226
+ });
227
+ b(() => {
228
+ if (!x)
229
+ return;
230
+ const n = B.current;
231
+ n && (n.scrollTop = n.scrollHeight);
232
+ }, [x]);
233
+ const le = (n) => {
234
+ H(n), K(n.length);
235
+ }, de = (n, a) => {
236
+ c && (c.map((m) => {
237
+ m.id === n && (m.value = a.target.value);
238
+ }), P([...c]));
239
+ }, ie = () => {
240
+ X(!M);
241
+ };
242
+ return /* @__PURE__ */ v("div", {
243
+ className: "text-main",
244
+ children: [/* @__PURE__ */ v("div", {
245
+ className: "text-left-sider",
246
+ children: [/* @__PURE__ */ v("div", {
247
+ className: "text-prompts",
248
+ children: [/* @__PURE__ */ o("div", {
249
+ className: "prompts-header",
250
+ children: /* @__PURE__ */ v(ve, {
251
+ children: [/* @__PURE__ */ o(E, {
252
+ className: "prompts-btn",
253
+ icon: M ? /* @__PURE__ */ o(U, {
254
+ type: "icon-biaoge-shouqi"
255
+ }) : /* @__PURE__ */ o(U, {
256
+ type: "icon-biaoge-zhankai"
257
+ }),
258
+ type: "link",
259
+ onClick: () => ie()
260
+ }), /* @__PURE__ */ o("span", {
261
+ className: "prompts-title",
262
+ children: "文本生成设置"
263
+ })]
264
+ })
265
+ }), !M && (c != null && c.length ? /* @__PURE__ */ o(R, {
266
+ autoComplete: "off",
267
+ form: Y,
268
+ labelWrap: !0,
269
+ labelAlign: "left",
270
+ labelCol: {
271
+ style: {
272
+ width: 194
273
+ }
274
+ },
275
+ className: "prompts-form",
276
+ children: c == null ? void 0 : c.map((n) => /* @__PURE__ */ o(R.Item, {
277
+ label: n.name,
278
+ name: n.key,
279
+ style: {
280
+ marginBottom: 8
281
+ },
282
+ rules: [{
283
+ required: !0,
284
+ message: "请输入"
285
+ }],
286
+ children: /* @__PURE__ */ o(J, {
287
+ placeholder: "请输入",
288
+ maxLength: k == null ? void 0 : k.questionContextMaxLength,
289
+ onBlur: (a) => de(n.id, a)
290
+ })
291
+ }, n.key))
292
+ }) : null)]
293
+ }), /* @__PURE__ */ v("div", {
294
+ className: "sider-header",
295
+ children: [/* @__PURE__ */ o("span", {
296
+ className: "header-title",
297
+ children: "文本生成输入"
298
+ }), D.length !== 0 && /* @__PURE__ */ o(Se, {
299
+ checkedValues: T,
300
+ currKnowledgeList: D,
301
+ selectCount: G,
302
+ onSelectChange: le,
303
+ disabled: !1
304
+ })]
305
+ }), /* @__PURE__ */ o("div", {
306
+ className: "sider-main",
307
+ children: /* @__PURE__ */ v("div", {
308
+ className: "sider-text",
309
+ children: [/* @__PURE__ */ o(J.TextArea, {
310
+ style: {
311
+ height: "100%",
312
+ resize: "none"
313
+ },
314
+ placeholder: "请输入你的问题,通过shift+enter换行",
315
+ maxLength: _,
316
+ showCount: !0,
317
+ bordered: !1,
318
+ onChange: ae,
319
+ value: C,
320
+ className: "left-input"
321
+ }), /* @__PURE__ */ o(E, {
322
+ type: "primary",
323
+ disabled: !C || y,
324
+ onClick: ce,
325
+ className: "sider-btn",
326
+ loading: y,
327
+ children: y ? "生成中" : "确认生成"
328
+ })]
329
+ })
330
+ })]
331
+ }), /* @__PURE__ */ o("div", {
332
+ className: "text-right-sider",
333
+ children: /* @__PURE__ */ o("div", {
334
+ className: "sider-main",
335
+ children: /* @__PURE__ */ o("div", {
336
+ className: "sider-text",
337
+ ref: B,
338
+ children: x ? /* @__PURE__ */ v(Ie, {
339
+ children: [/* @__PURE__ */ o(Te, {
340
+ children: x
341
+ }), I && (I == null ? void 0 : I.reference.length) !== 0 && /* @__PURE__ */ o("div", {
342
+ style: {
343
+ marginTop: 16
344
+ },
345
+ children: /* @__PURE__ */ o(be, {
346
+ history: I,
347
+ docViewerUrl: ""
348
+ })
349
+ })]
350
+ }) : /* @__PURE__ */ o("div", {
351
+ className: "text-pannel",
352
+ children: /* @__PURE__ */ o("span", {
353
+ children: "请在左侧输入需要 AI 生成的内容"
354
+ })
355
+ })
356
+ })
357
+ })
358
+ })]
359
+ });
360
+ };
361
+ export {
362
+ ze as default
363
+ };
@@ -0,0 +1,112 @@
1
+ var W = Object.defineProperty, j = Object.defineProperties;
2
+ var k = Object.getOwnPropertyDescriptors;
3
+ var v = Object.getOwnPropertySymbols;
4
+ var A = Object.prototype.hasOwnProperty, R = Object.prototype.propertyIsEnumerable;
5
+ var I = (t, e, a) => e in t ? W(t, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : t[e] = a, E = (t, e) => {
6
+ for (var a in e || (e = {}))
7
+ A.call(e, a) && I(t, a, e[a]);
8
+ if (v)
9
+ for (var a of v(e))
10
+ R.call(e, a) && I(t, a, e[a]);
11
+ return t;
12
+ }, $ = (t, e) => j(t, k(e));
13
+ var q = (t, e) => {
14
+ var a = {};
15
+ for (var n in t)
16
+ A.call(t, n) && e.indexOf(n) < 0 && (a[n] = t[n]);
17
+ if (t != null && v)
18
+ for (var n of v(t))
19
+ e.indexOf(n) < 0 && R.call(t, n) && (a[n] = t[n]);
20
+ return a;
21
+ };
22
+ var B = (t, e, a) => new Promise((n, w) => {
23
+ var o = (r) => {
24
+ try {
25
+ c(a.next(r));
26
+ } catch (d) {
27
+ w(d);
28
+ }
29
+ }, i = (r) => {
30
+ try {
31
+ c(a.throw(r));
32
+ } catch (d) {
33
+ w(d);
34
+ }
35
+ }, c = (r) => r.done ? n(r.value) : Promise.resolve(r.value).then(o, i);
36
+ c((a = a.apply(t, e)).next());
37
+ });
38
+ import { getBytes as z, getLines as G, getMessages as H } from "./parse.mjs";
39
+ const g = "text/event-stream", J = 1e3, D = "last-event-id";
40
+ function X(t, N) {
41
+ var u = N, {
42
+ signal: e,
43
+ headers: a,
44
+ onopen: n,
45
+ onmessage: w,
46
+ onclose: o,
47
+ onerror: i,
48
+ openWhenHidden: c,
49
+ fetch: r
50
+ } = u, d = q(u, [
51
+ "signal",
52
+ "headers",
53
+ "onopen",
54
+ "onmessage",
55
+ "onclose",
56
+ "onerror",
57
+ "openWhenHidden",
58
+ "fetch"
59
+ ]);
60
+ return new Promise((L, M) => {
61
+ const f = E({}, a);
62
+ f.accept || (f.accept = g);
63
+ let l;
64
+ function C() {
65
+ l.abort(), document.hidden || b();
66
+ }
67
+ c || document.addEventListener("visibilitychange", C);
68
+ let T = J, y = 0;
69
+ function h() {
70
+ document.removeEventListener("visibilitychange", C), window.clearTimeout(y), l.abort();
71
+ }
72
+ e == null || e.addEventListener("abort", () => {
73
+ h(), L();
74
+ });
75
+ const P = r != null ? r : window.fetch, V = n != null ? n : K;
76
+ function b() {
77
+ return B(this, null, function* () {
78
+ var x;
79
+ l = new AbortController();
80
+ try {
81
+ const m = yield P(t, $(E({}, d), {
82
+ headers: f,
83
+ signal: l.signal
84
+ }));
85
+ yield V(m), yield z(m.body, G(H((s) => {
86
+ s ? f[D] = s : delete f[D];
87
+ }, (s) => {
88
+ T = s;
89
+ }, w))), o == null || o(), h(), L();
90
+ } catch (m) {
91
+ if (!l.signal.aborted)
92
+ try {
93
+ const s = (x = i == null ? void 0 : i(m)) != null ? x : T;
94
+ window.clearTimeout(y), y = window.setTimeout(b, s);
95
+ } catch (s) {
96
+ h(), M(s);
97
+ }
98
+ }
99
+ });
100
+ }
101
+ b();
102
+ });
103
+ }
104
+ function K(t) {
105
+ const e = t.headers.get("content-type");
106
+ if (!(e != null && e.startsWith(g)))
107
+ throw new Error(`Expected content-type to be ${g}, Actual: ${e}`);
108
+ }
109
+ export {
110
+ g as EventStreamContentType,
111
+ X as fetchEventSource
112
+ };
@@ -0,0 +1,97 @@
1
+ var b = (s, t, e) => new Promise((a, c) => {
2
+ var f = (r) => {
3
+ try {
4
+ i(e.next(r));
5
+ } catch (n) {
6
+ c(n);
7
+ }
8
+ }, l = (r) => {
9
+ try {
10
+ i(e.throw(r));
11
+ } catch (n) {
12
+ c(n);
13
+ }
14
+ }, i = (r) => r.done ? a(r.value) : Promise.resolve(r.value).then(f, l);
15
+ i((e = e.apply(s, t)).next());
16
+ });
17
+ function w(s, t) {
18
+ return b(this, null, function* () {
19
+ const e = s.getReader();
20
+ let a;
21
+ for (; !(a = yield e.read()).done; )
22
+ t(a.value);
23
+ });
24
+ }
25
+ function g(s) {
26
+ let t, e, a, c = !1, f;
27
+ return function(i) {
28
+ t === void 0 ? (t = i, e = 0, a = -1, f = !1) : t = h(t, i);
29
+ const r = t.length;
30
+ let n = 0;
31
+ for (; e < r; ) {
32
+ c && (t[e] === 10 && (n = ++e), c = !1);
33
+ let o = -1;
34
+ for (; e < r && o === -1; ++e)
35
+ switch (t[e]) {
36
+ case 58:
37
+ a === -1 && (a = e - n);
38
+ break;
39
+ case 13:
40
+ c = !1, e + 4 < r && t[e + 1] === 10 && t[e + 2] !== 13 && t[e - 1] !== 10 && t[e - 2] !== 13 && (f = !0);
41
+ case 10:
42
+ o = e;
43
+ break;
44
+ }
45
+ if (o === -1)
46
+ break;
47
+ s(t.subarray(n, o), a, f), n = e, a = -1, f = !1;
48
+ }
49
+ n === r ? t = void 0 : n !== 0 && (t = t.subarray(n), e -= n);
50
+ };
51
+ }
52
+ function k(s, t, e) {
53
+ let a = y();
54
+ const c = new TextDecoder();
55
+ return function(l, i, r) {
56
+ if (l.length === 0)
57
+ e == null || e(a), a = y();
58
+ else if (i > 0) {
59
+ const n = c.decode(l.subarray(0, i)), o = i + (l[i + 1] === 32 ? 2 : 1);
60
+ let d = c.decode(l.subarray(o));
61
+ switch (r && (d += `
62
+ `), n) {
63
+ case "data":
64
+ a.data = a.data ? a.data + `
65
+ ` + d : d;
66
+ break;
67
+ case "event":
68
+ a.event = d;
69
+ break;
70
+ case "id":
71
+ s(a.id = d);
72
+ break;
73
+ case "retry":
74
+ const u = parseInt(d, 10);
75
+ isNaN(u) || t(a.retry = u);
76
+ break;
77
+ }
78
+ }
79
+ };
80
+ }
81
+ function h(s, t) {
82
+ const e = new Uint8Array(s.length + t.length);
83
+ return e.set(s), e.set(t, s.length), e;
84
+ }
85
+ function y() {
86
+ return {
87
+ data: "",
88
+ event: "",
89
+ id: "",
90
+ retry: void 0
91
+ };
92
+ }
93
+ export {
94
+ w as getBytes,
95
+ g as getLines,
96
+ k as getMessages
97
+ };
@@ -0,0 +1,79 @@
1
+ var A = Object.defineProperty, L = Object.defineProperties;
2
+ var M = Object.getOwnPropertyDescriptors;
3
+ var i = Object.getOwnPropertySymbols;
4
+ var P = Object.prototype.hasOwnProperty, U = Object.prototype.propertyIsEnumerable;
5
+ var s = (o, e, t) => e in o ? A(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t, a = (o, e) => {
6
+ for (var t in e || (e = {}))
7
+ P.call(e, t) && s(o, t, e[t]);
8
+ if (i)
9
+ for (var t of i(e))
10
+ U.call(e, t) && s(o, t, e[t]);
11
+ return o;
12
+ }, d = (o, e) => L(o, M(e));
13
+ import { jsx as n } from "react/jsx-runtime";
14
+ import { useRef as j, useState as l, useEffect as z } from "react";
15
+ /* empty css */import { ConfigProvider as m } from "antd";
16
+ import B from "antd/es/locale/zh_CN";
17
+ import E from "./components/TextSiders/index.mjs";
18
+ import { JWT as J } from "../utils/index.mjs";
19
+ import { AgentClientProvider as W } from "../context.mjs";
20
+ const Y = (o) => {
21
+ const {
22
+ application: e,
23
+ theme: t,
24
+ token: r,
25
+ footer: f,
26
+ defaultInput: c,
27
+ onComment: p,
28
+ onSessionLoad: u,
29
+ onSessionUnload: g,
30
+ onMessage: h,
31
+ beforeMessageSend: C,
32
+ bodyStyle: S,
33
+ sessionId: v,
34
+ disabled: x,
35
+ transform: I,
36
+ features: b,
37
+ agentClient: N
38
+ } = o, R = j(null), [T, q] = l(!1), [w, k] = l();
39
+ return z(() => {
40
+ if (!r)
41
+ return;
42
+ const y = J(r);
43
+ k(y.rid);
44
+ }, [r]), m.config({
45
+ theme: t
46
+ }), /* @__PURE__ */ n(m, {
47
+ locale: B,
48
+ children: /* @__PURE__ */ n(W, {
49
+ value: d(a({}, o), {
50
+ popupContainer: R,
51
+ agentClient: N,
52
+ footer: f,
53
+ defaultInput: c,
54
+ onComment: p,
55
+ onSessionLoad: u,
56
+ onSessionUnload: g,
57
+ onMessage: h,
58
+ beforeMessageSend: C,
59
+ bodyStyle: S,
60
+ disabled: x,
61
+ transform: I,
62
+ features: b
63
+ }),
64
+ children: !T && /* @__PURE__ */ n("div", {
65
+ className: "gbot-dialog-modal chat-text",
66
+ children: /* @__PURE__ */ n("div", {
67
+ className: "text-pannel",
68
+ children: /* @__PURE__ */ n(E, {
69
+ application: e,
70
+ sessionId: v
71
+ })
72
+ })
73
+ })
74
+ })
75
+ });
76
+ };
77
+ export {
78
+ Y as default
79
+ };