@0xbot/chat-react 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/chat-library.es.js +828 -0
- package/dist/chat-library.umd.js +43 -0
- package/dist/{style.css → index.css} +1 -1
- package/package.json +22 -30
- package/dist/index.es.js +0 -1035
- package/dist/index.umd.js +0 -52
package/dist/index.es.js
DELETED
|
@@ -1,1035 +0,0 @@
|
|
|
1
|
-
import He, { useState as $, useEffect as Q, useRef as Ue } from "react";
|
|
2
|
-
import Er from "markdown-it";
|
|
3
|
-
import ve from "highlight.js";
|
|
4
|
-
import de from "localforage";
|
|
5
|
-
import Rr from "axios";
|
|
6
|
-
import Ke from "@fingerprintjs/fingerprintjs";
|
|
7
|
-
import "@unocss/reset/tailwind.css";
|
|
8
|
-
var Ce = { exports: {} }, oe = {};
|
|
9
|
-
/**
|
|
10
|
-
* @license React
|
|
11
|
-
* react-jsx-runtime.production.min.js
|
|
12
|
-
*
|
|
13
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
-
*
|
|
15
|
-
* This source code is licensed under the MIT license found in the
|
|
16
|
-
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/
|
|
18
|
-
var qe;
|
|
19
|
-
function wr() {
|
|
20
|
-
if (qe) return oe;
|
|
21
|
-
qe = 1;
|
|
22
|
-
var n = He, o = Symbol.for("react.element"), y = Symbol.for("react.fragment"), d = Object.prototype.hasOwnProperty, E = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, R = { key: !0, ref: !0, __self: !0, __source: !0 };
|
|
23
|
-
function k(x, h, f) {
|
|
24
|
-
var l, g = {}, C = null, D = null;
|
|
25
|
-
f !== void 0 && (C = "" + f), h.key !== void 0 && (C = "" + h.key), h.ref !== void 0 && (D = h.ref);
|
|
26
|
-
for (l in h) d.call(h, l) && !R.hasOwnProperty(l) && (g[l] = h[l]);
|
|
27
|
-
if (x && x.defaultProps) for (l in h = x.defaultProps, h) g[l] === void 0 && (g[l] = h[l]);
|
|
28
|
-
return { $$typeof: o, type: x, key: C, ref: D, props: g, _owner: E.current };
|
|
29
|
-
}
|
|
30
|
-
return oe.Fragment = y, oe.jsx = k, oe.jsxs = k, oe;
|
|
31
|
-
}
|
|
32
|
-
var se = {};
|
|
33
|
-
/**
|
|
34
|
-
* @license React
|
|
35
|
-
* react-jsx-runtime.development.js
|
|
36
|
-
*
|
|
37
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the MIT license found in the
|
|
40
|
-
* LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/
|
|
42
|
-
var Be;
|
|
43
|
-
function Sr() {
|
|
44
|
-
return Be || (Be = 1, process.env.NODE_ENV !== "production" && function() {
|
|
45
|
-
var n = He, o = Symbol.for("react.element"), y = Symbol.for("react.portal"), d = Symbol.for("react.fragment"), E = Symbol.for("react.strict_mode"), R = Symbol.for("react.profiler"), k = Symbol.for("react.provider"), x = Symbol.for("react.context"), h = Symbol.for("react.forward_ref"), f = Symbol.for("react.suspense"), l = Symbol.for("react.suspense_list"), g = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), D = Symbol.for("react.offscreen"), I = Symbol.iterator, W = "@@iterator";
|
|
46
|
-
function q(e) {
|
|
47
|
-
if (e === null || typeof e != "object")
|
|
48
|
-
return null;
|
|
49
|
-
var r = I && e[I] || e[W];
|
|
50
|
-
return typeof r == "function" ? r : null;
|
|
51
|
-
}
|
|
52
|
-
var j = n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
53
|
-
function m(e) {
|
|
54
|
-
{
|
|
55
|
-
for (var r = arguments.length, t = new Array(r > 1 ? r - 1 : 0), a = 1; a < r; a++)
|
|
56
|
-
t[a - 1] = arguments[a];
|
|
57
|
-
B("error", e, t);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
function B(e, r, t) {
|
|
61
|
-
{
|
|
62
|
-
var a = j.ReactDebugCurrentFrame, u = a.getStackAddendum();
|
|
63
|
-
u !== "" && (r += "%s", t = t.concat([u]));
|
|
64
|
-
var p = t.map(function(c) {
|
|
65
|
-
return String(c);
|
|
66
|
-
});
|
|
67
|
-
p.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, p);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
var Y = !1, L = !1, ee = !1, J = !1, H = !1, N;
|
|
71
|
-
N = Symbol.for("react.module.reference");
|
|
72
|
-
function M(e) {
|
|
73
|
-
return !!(typeof e == "string" || typeof e == "function" || e === d || e === R || H || e === E || e === f || e === l || J || e === D || Y || L || ee || typeof e == "object" && e !== null && (e.$$typeof === C || e.$$typeof === g || e.$$typeof === k || e.$$typeof === x || e.$$typeof === h || // This needs to include all possible module reference object
|
|
74
|
-
// types supported by any Flight configuration anywhere since
|
|
75
|
-
// we don't know which Flight build this will end up being used
|
|
76
|
-
// with.
|
|
77
|
-
e.$$typeof === N || e.getModuleId !== void 0));
|
|
78
|
-
}
|
|
79
|
-
function he(e, r, t) {
|
|
80
|
-
var a = e.displayName;
|
|
81
|
-
if (a)
|
|
82
|
-
return a;
|
|
83
|
-
var u = r.displayName || r.name || "";
|
|
84
|
-
return u !== "" ? t + "(" + u + ")" : t;
|
|
85
|
-
}
|
|
86
|
-
function re(e) {
|
|
87
|
-
return e.displayName || "Context";
|
|
88
|
-
}
|
|
89
|
-
function A(e) {
|
|
90
|
-
if (e == null)
|
|
91
|
-
return null;
|
|
92
|
-
if (typeof e.tag == "number" && m("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof e == "function")
|
|
93
|
-
return e.displayName || e.name || null;
|
|
94
|
-
if (typeof e == "string")
|
|
95
|
-
return e;
|
|
96
|
-
switch (e) {
|
|
97
|
-
case d:
|
|
98
|
-
return "Fragment";
|
|
99
|
-
case y:
|
|
100
|
-
return "Portal";
|
|
101
|
-
case R:
|
|
102
|
-
return "Profiler";
|
|
103
|
-
case E:
|
|
104
|
-
return "StrictMode";
|
|
105
|
-
case f:
|
|
106
|
-
return "Suspense";
|
|
107
|
-
case l:
|
|
108
|
-
return "SuspenseList";
|
|
109
|
-
}
|
|
110
|
-
if (typeof e == "object")
|
|
111
|
-
switch (e.$$typeof) {
|
|
112
|
-
case x:
|
|
113
|
-
var r = e;
|
|
114
|
-
return re(r) + ".Consumer";
|
|
115
|
-
case k:
|
|
116
|
-
var t = e;
|
|
117
|
-
return re(t._context) + ".Provider";
|
|
118
|
-
case h:
|
|
119
|
-
return he(e, e.render, "ForwardRef");
|
|
120
|
-
case g:
|
|
121
|
-
var a = e.displayName || null;
|
|
122
|
-
return a !== null ? a : A(e.type) || "Memo";
|
|
123
|
-
case C: {
|
|
124
|
-
var u = e, p = u._payload, c = u._init;
|
|
125
|
-
try {
|
|
126
|
-
return A(c(p));
|
|
127
|
-
} catch {
|
|
128
|
-
return null;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
return null;
|
|
133
|
-
}
|
|
134
|
-
var V = Object.assign, K = 0, te, ie, s, v, _, w, U;
|
|
135
|
-
function z() {
|
|
136
|
-
}
|
|
137
|
-
z.__reactDisabledLog = !0;
|
|
138
|
-
function me() {
|
|
139
|
-
{
|
|
140
|
-
if (K === 0) {
|
|
141
|
-
te = console.log, ie = console.info, s = console.warn, v = console.error, _ = console.group, w = console.groupCollapsed, U = console.groupEnd;
|
|
142
|
-
var e = {
|
|
143
|
-
configurable: !0,
|
|
144
|
-
enumerable: !0,
|
|
145
|
-
value: z,
|
|
146
|
-
writable: !0
|
|
147
|
-
};
|
|
148
|
-
Object.defineProperties(console, {
|
|
149
|
-
info: e,
|
|
150
|
-
log: e,
|
|
151
|
-
warn: e,
|
|
152
|
-
error: e,
|
|
153
|
-
group: e,
|
|
154
|
-
groupCollapsed: e,
|
|
155
|
-
groupEnd: e
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
K++;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function ne() {
|
|
162
|
-
{
|
|
163
|
-
if (K--, K === 0) {
|
|
164
|
-
var e = {
|
|
165
|
-
configurable: !0,
|
|
166
|
-
enumerable: !0,
|
|
167
|
-
writable: !0
|
|
168
|
-
};
|
|
169
|
-
Object.defineProperties(console, {
|
|
170
|
-
log: V({}, e, {
|
|
171
|
-
value: te
|
|
172
|
-
}),
|
|
173
|
-
info: V({}, e, {
|
|
174
|
-
value: ie
|
|
175
|
-
}),
|
|
176
|
-
warn: V({}, e, {
|
|
177
|
-
value: s
|
|
178
|
-
}),
|
|
179
|
-
error: V({}, e, {
|
|
180
|
-
value: v
|
|
181
|
-
}),
|
|
182
|
-
group: V({}, e, {
|
|
183
|
-
value: _
|
|
184
|
-
}),
|
|
185
|
-
groupCollapsed: V({}, e, {
|
|
186
|
-
value: w
|
|
187
|
-
}),
|
|
188
|
-
groupEnd: V({}, e, {
|
|
189
|
-
value: U
|
|
190
|
-
})
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
K < 0 && m("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
var ye = j.ReactCurrentDispatcher, _e;
|
|
197
|
-
function ce(e, r, t) {
|
|
198
|
-
{
|
|
199
|
-
if (_e === void 0)
|
|
200
|
-
try {
|
|
201
|
-
throw Error();
|
|
202
|
-
} catch (u) {
|
|
203
|
-
var a = u.stack.trim().match(/\n( *(at )?)/);
|
|
204
|
-
_e = a && a[1] || "";
|
|
205
|
-
}
|
|
206
|
-
return `
|
|
207
|
-
` + _e + e;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
var be = !1, le;
|
|
211
|
-
{
|
|
212
|
-
var ze = typeof WeakMap == "function" ? WeakMap : Map;
|
|
213
|
-
le = new ze();
|
|
214
|
-
}
|
|
215
|
-
function je(e, r) {
|
|
216
|
-
if (!e || be)
|
|
217
|
-
return "";
|
|
218
|
-
{
|
|
219
|
-
var t = le.get(e);
|
|
220
|
-
if (t !== void 0)
|
|
221
|
-
return t;
|
|
222
|
-
}
|
|
223
|
-
var a;
|
|
224
|
-
be = !0;
|
|
225
|
-
var u = Error.prepareStackTrace;
|
|
226
|
-
Error.prepareStackTrace = void 0;
|
|
227
|
-
var p;
|
|
228
|
-
p = ye.current, ye.current = null, me();
|
|
229
|
-
try {
|
|
230
|
-
if (r) {
|
|
231
|
-
var c = function() {
|
|
232
|
-
throw Error();
|
|
233
|
-
};
|
|
234
|
-
if (Object.defineProperty(c.prototype, "props", {
|
|
235
|
-
set: function() {
|
|
236
|
-
throw Error();
|
|
237
|
-
}
|
|
238
|
-
}), typeof Reflect == "object" && Reflect.construct) {
|
|
239
|
-
try {
|
|
240
|
-
Reflect.construct(c, []);
|
|
241
|
-
} catch (P) {
|
|
242
|
-
a = P;
|
|
243
|
-
}
|
|
244
|
-
Reflect.construct(e, [], c);
|
|
245
|
-
} else {
|
|
246
|
-
try {
|
|
247
|
-
c.call();
|
|
248
|
-
} catch (P) {
|
|
249
|
-
a = P;
|
|
250
|
-
}
|
|
251
|
-
e.call(c.prototype);
|
|
252
|
-
}
|
|
253
|
-
} else {
|
|
254
|
-
try {
|
|
255
|
-
throw Error();
|
|
256
|
-
} catch (P) {
|
|
257
|
-
a = P;
|
|
258
|
-
}
|
|
259
|
-
e();
|
|
260
|
-
}
|
|
261
|
-
} catch (P) {
|
|
262
|
-
if (P && a && typeof P.stack == "string") {
|
|
263
|
-
for (var i = P.stack.split(`
|
|
264
|
-
`), O = a.stack.split(`
|
|
265
|
-
`), b = i.length - 1, S = O.length - 1; b >= 1 && S >= 0 && i[b] !== O[S]; )
|
|
266
|
-
S--;
|
|
267
|
-
for (; b >= 1 && S >= 0; b--, S--)
|
|
268
|
-
if (i[b] !== O[S]) {
|
|
269
|
-
if (b !== 1 || S !== 1)
|
|
270
|
-
do
|
|
271
|
-
if (b--, S--, S < 0 || i[b] !== O[S]) {
|
|
272
|
-
var F = `
|
|
273
|
-
` + i[b].replace(" at new ", " at ");
|
|
274
|
-
return e.displayName && F.includes("<anonymous>") && (F = F.replace("<anonymous>", e.displayName)), typeof e == "function" && le.set(e, F), F;
|
|
275
|
-
}
|
|
276
|
-
while (b >= 1 && S >= 0);
|
|
277
|
-
break;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
} finally {
|
|
281
|
-
be = !1, ye.current = p, ne(), Error.prepareStackTrace = u;
|
|
282
|
-
}
|
|
283
|
-
var Z = e ? e.displayName || e.name : "", G = Z ? ce(Z) : "";
|
|
284
|
-
return typeof e == "function" && le.set(e, G), G;
|
|
285
|
-
}
|
|
286
|
-
function Xe(e, r, t) {
|
|
287
|
-
return je(e, !1);
|
|
288
|
-
}
|
|
289
|
-
function Ze(e) {
|
|
290
|
-
var r = e.prototype;
|
|
291
|
-
return !!(r && r.isReactComponent);
|
|
292
|
-
}
|
|
293
|
-
function ue(e, r, t) {
|
|
294
|
-
if (e == null)
|
|
295
|
-
return "";
|
|
296
|
-
if (typeof e == "function")
|
|
297
|
-
return je(e, Ze(e));
|
|
298
|
-
if (typeof e == "string")
|
|
299
|
-
return ce(e);
|
|
300
|
-
switch (e) {
|
|
301
|
-
case f:
|
|
302
|
-
return ce("Suspense");
|
|
303
|
-
case l:
|
|
304
|
-
return ce("SuspenseList");
|
|
305
|
-
}
|
|
306
|
-
if (typeof e == "object")
|
|
307
|
-
switch (e.$$typeof) {
|
|
308
|
-
case h:
|
|
309
|
-
return Xe(e.render);
|
|
310
|
-
case g:
|
|
311
|
-
return ue(e.type, r, t);
|
|
312
|
-
case C: {
|
|
313
|
-
var a = e, u = a._payload, p = a._init;
|
|
314
|
-
try {
|
|
315
|
-
return ue(p(u), r, t);
|
|
316
|
-
} catch {
|
|
317
|
-
}
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
return "";
|
|
321
|
-
}
|
|
322
|
-
var ae = Object.prototype.hasOwnProperty, ke = {}, Oe = j.ReactDebugCurrentFrame;
|
|
323
|
-
function fe(e) {
|
|
324
|
-
if (e) {
|
|
325
|
-
var r = e._owner, t = ue(e.type, e._source, r ? r.type : null);
|
|
326
|
-
Oe.setExtraStackFrame(t);
|
|
327
|
-
} else
|
|
328
|
-
Oe.setExtraStackFrame(null);
|
|
329
|
-
}
|
|
330
|
-
function Qe(e, r, t, a, u) {
|
|
331
|
-
{
|
|
332
|
-
var p = Function.call.bind(ae);
|
|
333
|
-
for (var c in e)
|
|
334
|
-
if (p(e, c)) {
|
|
335
|
-
var i = void 0;
|
|
336
|
-
try {
|
|
337
|
-
if (typeof e[c] != "function") {
|
|
338
|
-
var O = Error((a || "React class") + ": " + t + " type `" + c + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof e[c] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
339
|
-
throw O.name = "Invariant Violation", O;
|
|
340
|
-
}
|
|
341
|
-
i = e[c](r, c, a, t, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
342
|
-
} catch (b) {
|
|
343
|
-
i = b;
|
|
344
|
-
}
|
|
345
|
-
i && !(i instanceof Error) && (fe(u), m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", a || "React class", t, c, typeof i), fe(null)), i instanceof Error && !(i.message in ke) && (ke[i.message] = !0, fe(u), m("Failed %s type: %s", t, i.message), fe(null));
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
var er = Array.isArray;
|
|
350
|
-
function Ee(e) {
|
|
351
|
-
return er(e);
|
|
352
|
-
}
|
|
353
|
-
function rr(e) {
|
|
354
|
-
{
|
|
355
|
-
var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
356
|
-
return t;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
function tr(e) {
|
|
360
|
-
try {
|
|
361
|
-
return Pe(e), !1;
|
|
362
|
-
} catch {
|
|
363
|
-
return !0;
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
function Pe(e) {
|
|
367
|
-
return "" + e;
|
|
368
|
-
}
|
|
369
|
-
function Ie(e) {
|
|
370
|
-
if (tr(e))
|
|
371
|
-
return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", rr(e)), Pe(e);
|
|
372
|
-
}
|
|
373
|
-
var Ae = j.ReactCurrentOwner, nr = {
|
|
374
|
-
key: !0,
|
|
375
|
-
ref: !0,
|
|
376
|
-
__self: !0,
|
|
377
|
-
__source: !0
|
|
378
|
-
}, Fe, De;
|
|
379
|
-
function ar(e) {
|
|
380
|
-
if (ae.call(e, "ref")) {
|
|
381
|
-
var r = Object.getOwnPropertyDescriptor(e, "ref").get;
|
|
382
|
-
if (r && r.isReactWarning)
|
|
383
|
-
return !1;
|
|
384
|
-
}
|
|
385
|
-
return e.ref !== void 0;
|
|
386
|
-
}
|
|
387
|
-
function or(e) {
|
|
388
|
-
if (ae.call(e, "key")) {
|
|
389
|
-
var r = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
390
|
-
if (r && r.isReactWarning)
|
|
391
|
-
return !1;
|
|
392
|
-
}
|
|
393
|
-
return e.key !== void 0;
|
|
394
|
-
}
|
|
395
|
-
function sr(e, r) {
|
|
396
|
-
typeof e.ref == "string" && Ae.current;
|
|
397
|
-
}
|
|
398
|
-
function ir(e, r) {
|
|
399
|
-
{
|
|
400
|
-
var t = function() {
|
|
401
|
-
Fe || (Fe = !0, m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
402
|
-
};
|
|
403
|
-
t.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
404
|
-
get: t,
|
|
405
|
-
configurable: !0
|
|
406
|
-
});
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
function cr(e, r) {
|
|
410
|
-
{
|
|
411
|
-
var t = function() {
|
|
412
|
-
De || (De = !0, m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
|
|
413
|
-
};
|
|
414
|
-
t.isReactWarning = !0, Object.defineProperty(e, "ref", {
|
|
415
|
-
get: t,
|
|
416
|
-
configurable: !0
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
var lr = function(e, r, t, a, u, p, c) {
|
|
421
|
-
var i = {
|
|
422
|
-
// This tag allows us to uniquely identify this as a React Element
|
|
423
|
-
$$typeof: o,
|
|
424
|
-
// Built-in properties that belong on the element
|
|
425
|
-
type: e,
|
|
426
|
-
key: r,
|
|
427
|
-
ref: t,
|
|
428
|
-
props: c,
|
|
429
|
-
// Record the component responsible for creating this element.
|
|
430
|
-
_owner: p
|
|
431
|
-
};
|
|
432
|
-
return i._store = {}, Object.defineProperty(i._store, "validated", {
|
|
433
|
-
configurable: !1,
|
|
434
|
-
enumerable: !1,
|
|
435
|
-
writable: !0,
|
|
436
|
-
value: !1
|
|
437
|
-
}), Object.defineProperty(i, "_self", {
|
|
438
|
-
configurable: !1,
|
|
439
|
-
enumerable: !1,
|
|
440
|
-
writable: !1,
|
|
441
|
-
value: a
|
|
442
|
-
}), Object.defineProperty(i, "_source", {
|
|
443
|
-
configurable: !1,
|
|
444
|
-
enumerable: !1,
|
|
445
|
-
writable: !1,
|
|
446
|
-
value: u
|
|
447
|
-
}), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
|
|
448
|
-
};
|
|
449
|
-
function ur(e, r, t, a, u) {
|
|
450
|
-
{
|
|
451
|
-
var p, c = {}, i = null, O = null;
|
|
452
|
-
t !== void 0 && (Ie(t), i = "" + t), or(r) && (Ie(r.key), i = "" + r.key), ar(r) && (O = r.ref, sr(r, u));
|
|
453
|
-
for (p in r)
|
|
454
|
-
ae.call(r, p) && !nr.hasOwnProperty(p) && (c[p] = r[p]);
|
|
455
|
-
if (e && e.defaultProps) {
|
|
456
|
-
var b = e.defaultProps;
|
|
457
|
-
for (p in b)
|
|
458
|
-
c[p] === void 0 && (c[p] = b[p]);
|
|
459
|
-
}
|
|
460
|
-
if (i || O) {
|
|
461
|
-
var S = typeof e == "function" ? e.displayName || e.name || "Unknown" : e;
|
|
462
|
-
i && ir(c, S), O && cr(c, S);
|
|
463
|
-
}
|
|
464
|
-
return lr(e, i, O, u, a, Ae.current, c);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
var Re = j.ReactCurrentOwner, Me = j.ReactDebugCurrentFrame;
|
|
468
|
-
function X(e) {
|
|
469
|
-
if (e) {
|
|
470
|
-
var r = e._owner, t = ue(e.type, e._source, r ? r.type : null);
|
|
471
|
-
Me.setExtraStackFrame(t);
|
|
472
|
-
} else
|
|
473
|
-
Me.setExtraStackFrame(null);
|
|
474
|
-
}
|
|
475
|
-
var we;
|
|
476
|
-
we = !1;
|
|
477
|
-
function Se(e) {
|
|
478
|
-
return typeof e == "object" && e !== null && e.$$typeof === o;
|
|
479
|
-
}
|
|
480
|
-
function $e() {
|
|
481
|
-
{
|
|
482
|
-
if (Re.current) {
|
|
483
|
-
var e = A(Re.current.type);
|
|
484
|
-
if (e)
|
|
485
|
-
return `
|
|
486
|
-
|
|
487
|
-
Check the render method of \`` + e + "`.";
|
|
488
|
-
}
|
|
489
|
-
return "";
|
|
490
|
-
}
|
|
491
|
-
}
|
|
492
|
-
function fr(e) {
|
|
493
|
-
return "";
|
|
494
|
-
}
|
|
495
|
-
var Le = {};
|
|
496
|
-
function dr(e) {
|
|
497
|
-
{
|
|
498
|
-
var r = $e();
|
|
499
|
-
if (!r) {
|
|
500
|
-
var t = typeof e == "string" ? e : e.displayName || e.name;
|
|
501
|
-
t && (r = `
|
|
502
|
-
|
|
503
|
-
Check the top-level render call using <` + t + ">.");
|
|
504
|
-
}
|
|
505
|
-
return r;
|
|
506
|
-
}
|
|
507
|
-
}
|
|
508
|
-
function Ne(e, r) {
|
|
509
|
-
{
|
|
510
|
-
if (!e._store || e._store.validated || e.key != null)
|
|
511
|
-
return;
|
|
512
|
-
e._store.validated = !0;
|
|
513
|
-
var t = dr(r);
|
|
514
|
-
if (Le[t])
|
|
515
|
-
return;
|
|
516
|
-
Le[t] = !0;
|
|
517
|
-
var a = "";
|
|
518
|
-
e && e._owner && e._owner !== Re.current && (a = " It was passed a child from " + A(e._owner.type) + "."), X(e), m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', t, a), X(null);
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
function We(e, r) {
|
|
522
|
-
{
|
|
523
|
-
if (typeof e != "object")
|
|
524
|
-
return;
|
|
525
|
-
if (Ee(e))
|
|
526
|
-
for (var t = 0; t < e.length; t++) {
|
|
527
|
-
var a = e[t];
|
|
528
|
-
Se(a) && Ne(a, r);
|
|
529
|
-
}
|
|
530
|
-
else if (Se(e))
|
|
531
|
-
e._store && (e._store.validated = !0);
|
|
532
|
-
else if (e) {
|
|
533
|
-
var u = q(e);
|
|
534
|
-
if (typeof u == "function" && u !== e.entries)
|
|
535
|
-
for (var p = u.call(e), c; !(c = p.next()).done; )
|
|
536
|
-
Se(c.value) && Ne(c.value, r);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
function vr(e) {
|
|
541
|
-
{
|
|
542
|
-
var r = e.type;
|
|
543
|
-
if (r == null || typeof r == "string")
|
|
544
|
-
return;
|
|
545
|
-
var t;
|
|
546
|
-
if (typeof r == "function")
|
|
547
|
-
t = r.propTypes;
|
|
548
|
-
else if (typeof r == "object" && (r.$$typeof === h || // Note: Memo only checks outer props here.
|
|
549
|
-
// Inner props are checked in the reconciler.
|
|
550
|
-
r.$$typeof === g))
|
|
551
|
-
t = r.propTypes;
|
|
552
|
-
else
|
|
553
|
-
return;
|
|
554
|
-
if (t) {
|
|
555
|
-
var a = A(r);
|
|
556
|
-
Qe(t, e.props, "prop", a, e);
|
|
557
|
-
} else if (r.PropTypes !== void 0 && !we) {
|
|
558
|
-
we = !0;
|
|
559
|
-
var u = A(r);
|
|
560
|
-
m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", u || "Unknown");
|
|
561
|
-
}
|
|
562
|
-
typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
function pr(e) {
|
|
566
|
-
{
|
|
567
|
-
for (var r = Object.keys(e.props), t = 0; t < r.length; t++) {
|
|
568
|
-
var a = r[t];
|
|
569
|
-
if (a !== "children" && a !== "key") {
|
|
570
|
-
X(e), m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", a), X(null);
|
|
571
|
-
break;
|
|
572
|
-
}
|
|
573
|
-
}
|
|
574
|
-
e.ref !== null && (X(e), m("Invalid attribute `ref` supplied to `React.Fragment`."), X(null));
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
var Ve = {};
|
|
578
|
-
function Ye(e, r, t, a, u, p) {
|
|
579
|
-
{
|
|
580
|
-
var c = M(e);
|
|
581
|
-
if (!c) {
|
|
582
|
-
var i = "";
|
|
583
|
-
(e === void 0 || typeof e == "object" && e !== null && Object.keys(e).length === 0) && (i += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
|
|
584
|
-
var O = fr();
|
|
585
|
-
O ? i += O : i += $e();
|
|
586
|
-
var b;
|
|
587
|
-
e === null ? b = "null" : Ee(e) ? b = "array" : e !== void 0 && e.$$typeof === o ? (b = "<" + (A(e.type) || "Unknown") + " />", i = " Did you accidentally export a JSX literal instead of a component?") : b = typeof e, m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", b, i);
|
|
588
|
-
}
|
|
589
|
-
var S = ur(e, r, t, u, p);
|
|
590
|
-
if (S == null)
|
|
591
|
-
return S;
|
|
592
|
-
if (c) {
|
|
593
|
-
var F = r.children;
|
|
594
|
-
if (F !== void 0)
|
|
595
|
-
if (a)
|
|
596
|
-
if (Ee(F)) {
|
|
597
|
-
for (var Z = 0; Z < F.length; Z++)
|
|
598
|
-
We(F[Z], e);
|
|
599
|
-
Object.freeze && Object.freeze(F);
|
|
600
|
-
} else
|
|
601
|
-
m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
602
|
-
else
|
|
603
|
-
We(F, e);
|
|
604
|
-
}
|
|
605
|
-
if (ae.call(r, "key")) {
|
|
606
|
-
var G = A(e), P = Object.keys(r).filter(function(br) {
|
|
607
|
-
return br !== "key";
|
|
608
|
-
}), xe = P.length > 0 ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}";
|
|
609
|
-
if (!Ve[G + xe]) {
|
|
610
|
-
var _r = P.length > 0 ? "{" + P.join(": ..., ") + ": ...}" : "{}";
|
|
611
|
-
m(`A props object containing a "key" prop is being spread into JSX:
|
|
612
|
-
let props = %s;
|
|
613
|
-
<%s {...props} />
|
|
614
|
-
React keys must be passed directly to JSX without using spread:
|
|
615
|
-
let props = %s;
|
|
616
|
-
<%s key={someKey} {...props} />`, xe, G, _r, G), Ve[G + xe] = !0;
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
return e === d ? pr(S) : vr(S), S;
|
|
620
|
-
}
|
|
621
|
-
}
|
|
622
|
-
function gr(e, r, t) {
|
|
623
|
-
return Ye(e, r, t, !0);
|
|
624
|
-
}
|
|
625
|
-
function hr(e, r, t) {
|
|
626
|
-
return Ye(e, r, t, !1);
|
|
627
|
-
}
|
|
628
|
-
var mr = hr, yr = gr;
|
|
629
|
-
se.Fragment = d, se.jsx = mr, se.jsxs = yr;
|
|
630
|
-
}()), se;
|
|
631
|
-
}
|
|
632
|
-
process.env.NODE_ENV === "production" ? Ce.exports = wr() : Ce.exports = Sr();
|
|
633
|
-
var T = Ce.exports;
|
|
634
|
-
const Je = ({
|
|
635
|
-
self: n,
|
|
636
|
-
UserAvatar: o,
|
|
637
|
-
AgentAvatar: y,
|
|
638
|
-
loading: d,
|
|
639
|
-
loadingText: E,
|
|
640
|
-
emptyText: R,
|
|
641
|
-
content: k,
|
|
642
|
-
children: x
|
|
643
|
-
}) => /* @__PURE__ */ T.jsxs("div", { className: `message-container message-spacing-small message-spacing-medium ${n ? "message-align-right" : "message-align-left"}`, children: [
|
|
644
|
-
!n && /* @__PURE__ */ T.jsx("img", { src: y, className: "chat-avatar", alt: "Agent Avatar" }),
|
|
645
|
-
/* @__PURE__ */ T.jsxs("div", { className: `message-bubble ${n ? "chat-message" : ""}`, children: [
|
|
646
|
-
!k && !d && /* @__PURE__ */ T.jsx("div", { className: "message-empty", children: R }),
|
|
647
|
-
x,
|
|
648
|
-
d && /* @__PURE__ */ T.jsx("div", { className: "message-loading", children: E })
|
|
649
|
-
] }),
|
|
650
|
-
n && /* @__PURE__ */ T.jsx("img", { src: o, className: "chat-avatar", alt: "User Avatar" })
|
|
651
|
-
] }), xr = (n) => {
|
|
652
|
-
n.renderer.rules.fence = (o, y) => {
|
|
653
|
-
const d = o[y], E = d.info ? d.info.trim() : "";
|
|
654
|
-
let R = "";
|
|
655
|
-
if (E && ve.getLanguage(E))
|
|
656
|
-
try {
|
|
657
|
-
R = ve.highlight(d.content, { language: E }).value;
|
|
658
|
-
} catch {
|
|
659
|
-
R = n.utils.escapeHtml(d.content);
|
|
660
|
-
}
|
|
661
|
-
else
|
|
662
|
-
R = n.utils.escapeHtml(d.content);
|
|
663
|
-
return `
|
|
664
|
-
<div class="code-block-element">
|
|
665
|
-
<div class="code-area">
|
|
666
|
-
<div class="header">
|
|
667
|
-
<div class="text">
|
|
668
|
-
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none" viewBox="0 0 24 24">
|
|
669
|
-
<path fill="#fff" fill-opacity="0.55" fill-rule="evenodd" d="M7 9v6H5.2V9H7Zm0-1v8H5c-.552 0-1-.299-1-.667V8.667C4 8.298 4.448 8 5 8h2Z" clip-rule="evenodd"/>
|
|
670
|
-
<path stroke="#fff" stroke-linejoin="bevel" stroke-opacity="0.55" d="m8.5 10 3 2-3 2M15.5 15h-4"/>
|
|
671
|
-
<path fill="#fff" fill-opacity="0.55" fill-rule="evenodd" d="M17 9v6h1.8V9H17Zm0-1v8h2c.552 0 1-.299 1-.667V8.667C20 8.298 19.552 8 19 8h-2Z" clip-rule="evenodd"/>
|
|
672
|
-
</svg>
|
|
673
|
-
<span class="code-area-language">${E}</span>
|
|
674
|
-
</div>
|
|
675
|
-
<div class="copy">
|
|
676
|
-
<button class="copy-btn" onclick="copyCodeToClipboard(this)">Copy</button>
|
|
677
|
-
</div>
|
|
678
|
-
</div>
|
|
679
|
-
<div class="content">
|
|
680
|
-
<pre><code class="hljs language-${n.utils.escapeHtml(E)}">${R}</code></pre>
|
|
681
|
-
</div>
|
|
682
|
-
</div>
|
|
683
|
-
</div>
|
|
684
|
-
`;
|
|
685
|
-
};
|
|
686
|
-
}, Cr = new Er({
|
|
687
|
-
highlight: (n, o) => {
|
|
688
|
-
if (o && ve.getLanguage(o))
|
|
689
|
-
try {
|
|
690
|
-
return ve.highlight(n, { language: o }).value;
|
|
691
|
-
} catch {
|
|
692
|
-
}
|
|
693
|
-
return "";
|
|
694
|
-
}
|
|
695
|
-
}).use(xr), Tr = (n, o = !1) => Cr.render(n, o);
|
|
696
|
-
function pe(n = {}) {
|
|
697
|
-
const { prefix: o = "0xbot-chat" } = n, y = (f) => o ? `${o}_${f}` : f, d = de.createInstance({
|
|
698
|
-
name: o,
|
|
699
|
-
storeName: o,
|
|
700
|
-
driver: [
|
|
701
|
-
de.INDEXEDDB,
|
|
702
|
-
de.LOCALSTORAGE,
|
|
703
|
-
de.WEBSQL
|
|
704
|
-
]
|
|
705
|
-
}), E = async (f) => {
|
|
706
|
-
try {
|
|
707
|
-
const l = y(f), g = await d.getItem(l);
|
|
708
|
-
if (g === null) return null;
|
|
709
|
-
try {
|
|
710
|
-
return JSON.parse(g);
|
|
711
|
-
} catch {
|
|
712
|
-
return g;
|
|
713
|
-
}
|
|
714
|
-
} catch (l) {
|
|
715
|
-
return console.error("Error getting value from storage:", l), null;
|
|
716
|
-
}
|
|
717
|
-
}, R = async (f, l) => {
|
|
718
|
-
try {
|
|
719
|
-
const g = y(f), C = typeof l == "string" ? l : JSON.stringify(l);
|
|
720
|
-
await d.setItem(g, C);
|
|
721
|
-
} catch (g) {
|
|
722
|
-
console.error("Error setting value in storage:", g);
|
|
723
|
-
}
|
|
724
|
-
};
|
|
725
|
-
return {
|
|
726
|
-
getStorage: E,
|
|
727
|
-
setStorage: R,
|
|
728
|
-
removeStorage: async (f) => {
|
|
729
|
-
try {
|
|
730
|
-
const l = y(f);
|
|
731
|
-
await d.removeItem(l);
|
|
732
|
-
} catch (l) {
|
|
733
|
-
console.error("Error removing value from storage:", l);
|
|
734
|
-
}
|
|
735
|
-
},
|
|
736
|
-
clearStorage: async () => {
|
|
737
|
-
try {
|
|
738
|
-
await d.clear();
|
|
739
|
-
} catch (f) {
|
|
740
|
-
console.error("Error clearing storage:", f);
|
|
741
|
-
}
|
|
742
|
-
},
|
|
743
|
-
useStorageState: (f, l) => {
|
|
744
|
-
const [g, C] = $(l);
|
|
745
|
-
return Q(() => {
|
|
746
|
-
E(f).then((D) => {
|
|
747
|
-
D !== null && C(D);
|
|
748
|
-
});
|
|
749
|
-
}, [f]), Q(() => {
|
|
750
|
-
R(f, g);
|
|
751
|
-
}, [f, g]), [g, C];
|
|
752
|
-
}
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
const { getStorage: jr } = pe();
|
|
756
|
-
let Te = "https://sdk.dorylus.chat/apis";
|
|
757
|
-
const kr = (n) => {
|
|
758
|
-
n && (Te = n);
|
|
759
|
-
}, Ge = Rr.create({
|
|
760
|
-
baseURL: Te,
|
|
761
|
-
timeout: 6e4
|
|
762
|
-
});
|
|
763
|
-
Ge.interceptors.request.use(
|
|
764
|
-
async (n) => {
|
|
765
|
-
const o = await jr("auth");
|
|
766
|
-
return o && (n.headers.Token = (o == null ? void 0 : o.token) || ""), n;
|
|
767
|
-
},
|
|
768
|
-
(n) => Promise.reject(n)
|
|
769
|
-
);
|
|
770
|
-
const ge = async (n, o) => (await Ge.post(n, o)).data, Or = (n) => {
|
|
771
|
-
const { setStorage: o } = pe();
|
|
772
|
-
return n.unique_id || Ke.load().then((y) => y.get()).then((y) => {
|
|
773
|
-
const d = y.visitorId;
|
|
774
|
-
n.unique_id = d, o("visitorId", d);
|
|
775
|
-
}), ge("/sdk/sdk_get_token", n);
|
|
776
|
-
}, Pr = (n) => ge("/app/conversation_history", n), Ir = (n) => ge("/app/upsert_conversation", n), Ar = (n) => ge("/app/delete_one_conversation_history", { id: n }), Fr = () => {
|
|
777
|
-
const [n, o] = $(null), [y, d] = $(!0), [E, R] = $(null), k = async (h, f, l) => new Promise(async (g, C) => {
|
|
778
|
-
var D;
|
|
779
|
-
try {
|
|
780
|
-
const { getStorage: I } = pe(), W = await I("auth"), q = await fetch(f, {
|
|
781
|
-
method: "POST",
|
|
782
|
-
headers: {
|
|
783
|
-
"Content-Type": "application/json",
|
|
784
|
-
token: (W == null ? void 0 : W.token) || ""
|
|
785
|
-
},
|
|
786
|
-
body: JSON.stringify(h)
|
|
787
|
-
});
|
|
788
|
-
if (!q.ok)
|
|
789
|
-
throw new Error(`Server responded with status: ${q.status}`);
|
|
790
|
-
const j = (D = q.body) == null ? void 0 : D.getReader();
|
|
791
|
-
if (!j)
|
|
792
|
-
throw new Error("Failed to get response reader");
|
|
793
|
-
R(j);
|
|
794
|
-
const m = new TextDecoder();
|
|
795
|
-
let B = "";
|
|
796
|
-
(async () => {
|
|
797
|
-
try {
|
|
798
|
-
for (; ; ) {
|
|
799
|
-
const { done: L, value: ee } = await j.read();
|
|
800
|
-
if (L) {
|
|
801
|
-
d(!1), g();
|
|
802
|
-
break;
|
|
803
|
-
}
|
|
804
|
-
B += m.decode(ee, { stream: !0 });
|
|
805
|
-
const J = B.split(`
|
|
806
|
-
`);
|
|
807
|
-
B = J.pop() || "";
|
|
808
|
-
for (const H of J)
|
|
809
|
-
try {
|
|
810
|
-
if (H.startsWith("data:")) {
|
|
811
|
-
const N = H.substring(5).trim();
|
|
812
|
-
if (N) {
|
|
813
|
-
const M = JSON.parse(N);
|
|
814
|
-
l(M);
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
} catch (N) {
|
|
818
|
-
console.error("Error parsing message:", N);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
} catch (L) {
|
|
822
|
-
C(L);
|
|
823
|
-
}
|
|
824
|
-
})();
|
|
825
|
-
} catch (I) {
|
|
826
|
-
o(I), C(I);
|
|
827
|
-
}
|
|
828
|
-
}), x = () => {
|
|
829
|
-
E && (E.cancel(), R(null));
|
|
830
|
-
};
|
|
831
|
-
return Q(() => () => {
|
|
832
|
-
x();
|
|
833
|
-
}, []), {
|
|
834
|
-
loading: y,
|
|
835
|
-
error: n,
|
|
836
|
-
connect: k,
|
|
837
|
-
close: x
|
|
838
|
-
};
|
|
839
|
-
}, Dr = (n) => n.map((o) => ({
|
|
840
|
-
self: o.is_user,
|
|
841
|
-
content: o.message
|
|
842
|
-
})), Ur = ({
|
|
843
|
-
apiKey: n,
|
|
844
|
-
serverUrl: o,
|
|
845
|
-
UserAvatar: y,
|
|
846
|
-
AgentAvatar: d,
|
|
847
|
-
loadingText: E = "AI is thinking...",
|
|
848
|
-
emptyText: R = "No messages yet",
|
|
849
|
-
theme: k = {}
|
|
850
|
-
}) => {
|
|
851
|
-
const [x, h] = $([]), [f, l] = $(""), [g, C] = $(!1), [D, I] = $(!1), [W, q] = $(""), [j, m] = $(null), B = Ue(null), { getStorage: Y, setStorage: L } = pe(), { connect: ee } = Fr(), J = Ue(null), [H, N] = $(""), M = {
|
|
852
|
-
padding: k.padding || 20,
|
|
853
|
-
borderRadius: k.borderRadius || 20,
|
|
854
|
-
bgColor: k.bgColor || "#151515",
|
|
855
|
-
primary: k.primary || "#AFAFFE",
|
|
856
|
-
textColor: k.textColor || "#fff"
|
|
857
|
-
}, he = (s) => {
|
|
858
|
-
console.log("Received message:", s), s.type === "text" ? (N((v) => v + s.content), h((v) => {
|
|
859
|
-
const _ = [...v], w = j !== null ? j : _.length - 1;
|
|
860
|
-
if (w >= 0 && w < _.length) {
|
|
861
|
-
const U = _[w];
|
|
862
|
-
U.loading && (U.loading = !1, I(!1)), U.content = H + s.content;
|
|
863
|
-
}
|
|
864
|
-
return _;
|
|
865
|
-
})) : s.type === "complete" && (console.log("Message complete"), j !== null && h((v) => {
|
|
866
|
-
const _ = [...v], w = _[j];
|
|
867
|
-
return w.loading = !1, w.content = H || R, _;
|
|
868
|
-
}), N(""), m(null), C(!1), I(!1));
|
|
869
|
-
}, re = async () => {
|
|
870
|
-
if (!f.trim()) return;
|
|
871
|
-
C(!0), I(!0), m(null);
|
|
872
|
-
const s = {
|
|
873
|
-
self: !0,
|
|
874
|
-
content: f,
|
|
875
|
-
loading: !1
|
|
876
|
-
}, v = {
|
|
877
|
-
self: !1,
|
|
878
|
-
content: "",
|
|
879
|
-
loading: !0
|
|
880
|
-
};
|
|
881
|
-
h((z) => [...z, s, v]), m(x.length + 1);
|
|
882
|
-
const _ = await Y("conversation"), w = await Y("agent"), U = {
|
|
883
|
-
q: f,
|
|
884
|
-
app_id: (w == null ? void 0 : w.app_id) || "",
|
|
885
|
-
conversation_id: _ || "",
|
|
886
|
-
is_debug: !1,
|
|
887
|
-
medias: []
|
|
888
|
-
};
|
|
889
|
-
l("");
|
|
890
|
-
try {
|
|
891
|
-
console.log("Connecting to stream..."), await ee(U, `${Te}/app/stream_chat`, he);
|
|
892
|
-
} catch (z) {
|
|
893
|
-
console.error("Error sending message:", z), j !== null && h((me) => {
|
|
894
|
-
const ne = [...me];
|
|
895
|
-
return ne[j].loading = !1, ne[j].content = "Error: Failed to get response", ne;
|
|
896
|
-
}), m(null), I(!1);
|
|
897
|
-
} finally {
|
|
898
|
-
C(!1);
|
|
899
|
-
}
|
|
900
|
-
}, A = () => {
|
|
901
|
-
var s;
|
|
902
|
-
(s = J.current) == null || s.scrollIntoView({ behavior: "smooth" });
|
|
903
|
-
}, V = async (s) => {
|
|
904
|
-
const _ = await Or({
|
|
905
|
-
api_key: n,
|
|
906
|
-
unique_id: s
|
|
907
|
-
});
|
|
908
|
-
_.code == 0 && (L("auth", _.data.auth), L("agent", _.data.agent), ie(_.data.agent));
|
|
909
|
-
}, K = async () => {
|
|
910
|
-
const s = await Y("conversation");
|
|
911
|
-
s && (await Ar(s)).code == 0 && h([]);
|
|
912
|
-
}, te = async (s) => {
|
|
913
|
-
const v = await Y("agent"), _ = {
|
|
914
|
-
page: 1,
|
|
915
|
-
pagesize: 2e6,
|
|
916
|
-
app_id: (v == null ? void 0 : v.app_id) || "",
|
|
917
|
-
conversation_id: s || ""
|
|
918
|
-
}, w = await Pr(_);
|
|
919
|
-
w.code == 0 && (h(Dr(w.data.list).reverse()), !x.length && (v != null && v.opening_text) && q(v.opening_text), A());
|
|
920
|
-
}, ie = async (s) => {
|
|
921
|
-
const v = await Y("conversation");
|
|
922
|
-
if (v)
|
|
923
|
-
te(v);
|
|
924
|
-
else {
|
|
925
|
-
const _ = {
|
|
926
|
-
id: "",
|
|
927
|
-
app_id: (s == null ? void 0 : s.app_id) || "",
|
|
928
|
-
name: "Unnamed"
|
|
929
|
-
}, w = await Ir(_);
|
|
930
|
-
w.code == 0 && (await L("conversation", w.data.id || ""), te(w.data.id || ""));
|
|
931
|
-
}
|
|
932
|
-
};
|
|
933
|
-
return Q(() => {
|
|
934
|
-
A(), n && Ke.load().then((s) => s.get()).then(async (s) => {
|
|
935
|
-
const v = s.visitorId;
|
|
936
|
-
await L("visitorId", v), V(v);
|
|
937
|
-
});
|
|
938
|
-
}, []), Q(() => {
|
|
939
|
-
kr(o);
|
|
940
|
-
}, [o]), Q(() => {
|
|
941
|
-
A();
|
|
942
|
-
}, [x]), /* @__PURE__ */ T.jsxs(
|
|
943
|
-
"div",
|
|
944
|
-
{
|
|
945
|
-
className: "chat-library",
|
|
946
|
-
style: {
|
|
947
|
-
backgroundColor: M.bgColor,
|
|
948
|
-
color: M.textColor,
|
|
949
|
-
borderRadius: `${M.borderRadius}px`,
|
|
950
|
-
padding: `${M.padding}px`
|
|
951
|
-
},
|
|
952
|
-
children: [
|
|
953
|
-
/* @__PURE__ */ T.jsx("div", { className: "chat-container", ref: B, children: /* @__PURE__ */ T.jsxs("div", { className: "chat-container-list", children: [
|
|
954
|
-
x.map((s, v) => /* @__PURE__ */ T.jsx(
|
|
955
|
-
Je,
|
|
956
|
-
{
|
|
957
|
-
self: s.self,
|
|
958
|
-
UserAvatar: y,
|
|
959
|
-
AgentAvatar: d,
|
|
960
|
-
loading: s.loading,
|
|
961
|
-
loadingText: E,
|
|
962
|
-
emptyText: R,
|
|
963
|
-
content: s.content,
|
|
964
|
-
children: /* @__PURE__ */ T.jsx("div", { dangerouslySetInnerHTML: { __html: Tr(s.content) } })
|
|
965
|
-
},
|
|
966
|
-
v
|
|
967
|
-
)),
|
|
968
|
-
!x.length && W && /* @__PURE__ */ T.jsx(
|
|
969
|
-
Je,
|
|
970
|
-
{
|
|
971
|
-
self: !1,
|
|
972
|
-
AgentAvatar: d,
|
|
973
|
-
loading: !1,
|
|
974
|
-
content: W,
|
|
975
|
-
children: /* @__PURE__ */ T.jsx("div", { dangerouslySetInnerHTML: { __html: W } })
|
|
976
|
-
}
|
|
977
|
-
),
|
|
978
|
-
/* @__PURE__ */ T.jsx("div", { ref: J })
|
|
979
|
-
] }) }),
|
|
980
|
-
/* @__PURE__ */ T.jsxs("div", { className: "chat-bar", children: [
|
|
981
|
-
/* @__PURE__ */ T.jsx(
|
|
982
|
-
"svg",
|
|
983
|
-
{
|
|
984
|
-
onClick: K,
|
|
985
|
-
className: "chat-bar-trash",
|
|
986
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
987
|
-
viewBox: "0 0 24 24",
|
|
988
|
-
children: /* @__PURE__ */ T.jsx(
|
|
989
|
-
"path",
|
|
990
|
-
{
|
|
991
|
-
fill: "none",
|
|
992
|
-
stroke: "currentColor",
|
|
993
|
-
strokeLinecap: "round",
|
|
994
|
-
strokeLinejoin: "round",
|
|
995
|
-
strokeWidth: "2",
|
|
996
|
-
d: "M4 7h16m-10 4v6m4-6v6M5 7l1 12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2l1-12M9 7V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v3"
|
|
997
|
-
}
|
|
998
|
-
)
|
|
999
|
-
}
|
|
1000
|
-
),
|
|
1001
|
-
/* @__PURE__ */ T.jsx(
|
|
1002
|
-
"input",
|
|
1003
|
-
{
|
|
1004
|
-
className: "chat-bar-input",
|
|
1005
|
-
disabled: g,
|
|
1006
|
-
placeholder: "Ask anything...",
|
|
1007
|
-
value: f,
|
|
1008
|
-
onChange: (s) => l(s.target.value),
|
|
1009
|
-
onKeyUp: (s) => s.key === "Enter" && re()
|
|
1010
|
-
}
|
|
1011
|
-
),
|
|
1012
|
-
/* @__PURE__ */ T.jsx(
|
|
1013
|
-
"button",
|
|
1014
|
-
{
|
|
1015
|
-
className: "chat-bar-send",
|
|
1016
|
-
disabled: g,
|
|
1017
|
-
style: {
|
|
1018
|
-
borderColor: M.primary,
|
|
1019
|
-
color: M.primary,
|
|
1020
|
-
"--primary-color": M.primary
|
|
1021
|
-
},
|
|
1022
|
-
onClick: re,
|
|
1023
|
-
children: "Send"
|
|
1024
|
-
}
|
|
1025
|
-
)
|
|
1026
|
-
] })
|
|
1027
|
-
]
|
|
1028
|
-
}
|
|
1029
|
-
);
|
|
1030
|
-
};
|
|
1031
|
-
export {
|
|
1032
|
-
Ur as ChatLibrary,
|
|
1033
|
-
Je as MessageItem,
|
|
1034
|
-
Ur as default
|
|
1035
|
-
};
|