@ibiz-template-plugin/ai-chat 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.en.md +36 -0
- package/README.md +37 -0
- package/dist/assets/svg/AIChat.svg +1 -0
- package/dist/index.es.js +1655 -0
- package/dist/index.legacy.js +1 -0
- package/dist/polyfills.legacy.js +1 -0
- package/dist/style.css +1 -0
- package/dist/types/app.d.ts +1 -0
- package/dist/types/components/chat-container/chat-container.d.ts +59 -0
- package/dist/types/components/chat-input/chat-input.d.ts +12 -0
- package/dist/types/components/chat-message-item/chat-message-item.d.ts +23 -0
- package/dist/types/components/chat-message-item/error-message/error-message.d.ts +13 -0
- package/dist/types/components/chat-message-item/markdown-message/markdown-message.d.ts +22 -0
- package/dist/types/components/chat-message-item/unknown-message/unknown-message.d.ts +13 -0
- package/dist/types/components/chat-message-item/user-message/user-message.d.ts +13 -0
- package/dist/types/components/chat-messages/chat-messages.d.ts +12 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/controller/ai-chat/ai-chat.controller.d.ts +78 -0
- package/dist/types/controller/chat/chat.controller.d.ts +51 -0
- package/dist/types/controller/index.d.ts +2 -0
- package/dist/types/entity/chat-message/chat-message.d.ts +28 -0
- package/dist/types/entity/index.d.ts +1 -0
- package/dist/types/global.d.ts +2 -0
- package/dist/types/icons/close-svg.d.ts +1 -0
- package/dist/types/icons/fill-svg.d.ts +1 -0
- package/dist/types/icons/index.d.ts +3 -0
- package/dist/types/icons/send-svg.d.ts +1 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/interface/i-chat-container/i-chat-container.d.ts +58 -0
- package/dist/types/interface/i-chat-message/i-chat-message.d.ts +83 -0
- package/dist/types/interface/i-chat-options/i-chat-options.d.ts +46 -0
- package/dist/types/interface/i-message-item-provider/i-message-item-provider.d.ts +18 -0
- package/dist/types/interface/i-portal-async-action/i-portal-async-action.d.ts +90 -0
- package/dist/types/interface/index.d.ts +4 -0
- package/dist/types/main.d.ts +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/namespace/namespace.d.ts +147 -0
- package/dist/types/utils/plugin-static-resource/plugin-static-resource.d.ts +63 -0
- package/dist/types/utils/util/util.d.ts +9 -0
- package/package.json +81 -0
package/dist/index.es.js
ADDED
|
@@ -0,0 +1,1655 @@
|
|
|
1
|
+
var Mt = Object.defineProperty;
|
|
2
|
+
var Pt = (t, e, n) => e in t ? Mt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var A = (t, e, n) => (Pt(t, typeof e != "symbol" ? e + "" : e, n), n);
|
|
4
|
+
import q from "interactjs";
|
|
5
|
+
import "path-browserify";
|
|
6
|
+
import Ut from "cherry-markdown";
|
|
7
|
+
var de, l, at, _t, D, Ue, ct, xe, W = {}, lt = [], Tt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, pe = Array.isArray;
|
|
8
|
+
function T(t, e) {
|
|
9
|
+
for (var n in e)
|
|
10
|
+
t[n] = e[n];
|
|
11
|
+
return t;
|
|
12
|
+
}
|
|
13
|
+
function ut(t) {
|
|
14
|
+
var e = t.parentNode;
|
|
15
|
+
e && e.removeChild(t);
|
|
16
|
+
}
|
|
17
|
+
function Z(t, e, n) {
|
|
18
|
+
var i, o, r, a = {};
|
|
19
|
+
for (r in e)
|
|
20
|
+
r == "key" ? i = e[r] : r == "ref" ? o = e[r] : a[r] = e[r];
|
|
21
|
+
if (arguments.length > 2 && (a.children = arguments.length > 3 ? de.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null)
|
|
22
|
+
for (r in t.defaultProps)
|
|
23
|
+
a[r] === void 0 && (a[r] = t.defaultProps[r]);
|
|
24
|
+
return te(t, a, i, o, null);
|
|
25
|
+
}
|
|
26
|
+
function te(t, e, n, i, o) {
|
|
27
|
+
var r = { type: t, props: e, key: n, ref: i, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: o == null ? ++at : o };
|
|
28
|
+
return o == null && l.vnode != null && l.vnode(r), r;
|
|
29
|
+
}
|
|
30
|
+
function Te() {
|
|
31
|
+
return { current: null };
|
|
32
|
+
}
|
|
33
|
+
function I(t) {
|
|
34
|
+
return t.children;
|
|
35
|
+
}
|
|
36
|
+
function C(t, e) {
|
|
37
|
+
this.props = t, this.context = e;
|
|
38
|
+
}
|
|
39
|
+
function G(t, e) {
|
|
40
|
+
if (e == null)
|
|
41
|
+
return t.__ ? G(t.__, t.__.__k.indexOf(t) + 1) : null;
|
|
42
|
+
for (var n; e < t.__k.length; e++)
|
|
43
|
+
if ((n = t.__k[e]) != null && n.__e != null)
|
|
44
|
+
return n.__d || n.__e;
|
|
45
|
+
return typeof t.type == "function" ? G(t) : null;
|
|
46
|
+
}
|
|
47
|
+
function ft(t) {
|
|
48
|
+
var e, n;
|
|
49
|
+
if ((t = t.__) != null && t.__c != null) {
|
|
50
|
+
for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++)
|
|
51
|
+
if ((n = t.__k[e]) != null && n.__e != null) {
|
|
52
|
+
t.__e = t.__c.base = n.__e;
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
return ft(t);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function ze(t) {
|
|
59
|
+
(!t.__d && (t.__d = !0) && D.push(t) && !re.__r++ || Ue !== l.debounceRendering) && ((Ue = l.debounceRendering) || ct)(re);
|
|
60
|
+
}
|
|
61
|
+
function re() {
|
|
62
|
+
var t, e, n, i, o, r, a, c, _;
|
|
63
|
+
for (D.sort(xe); t = D.shift(); )
|
|
64
|
+
t.__d && (e = D.length, i = void 0, o = void 0, r = void 0, c = (a = (n = t).__v).__e, (_ = n.__P) && (i = [], o = [], (r = T({}, a)).__v = a.__v + 1, Ce(_, a, r, n.__n, _.ownerSVGElement !== void 0, a.__h != null ? [c] : null, i, c == null ? G(a) : c, a.__h, o), vt(i, a, o), a.__e != c && ft(a)), D.length > e && D.sort(xe));
|
|
65
|
+
re.__r = 0;
|
|
66
|
+
}
|
|
67
|
+
function ht(t, e, n, i, o, r, a, c, _, v, p) {
|
|
68
|
+
var s, y, f, u, d, H, m, b, x, w = 0, $ = i && i.__k || lt, M = $.length, N = M, P = e.length;
|
|
69
|
+
for (n.__k = [], s = 0; s < P; s++)
|
|
70
|
+
(u = n.__k[s] = (u = e[s]) == null || typeof u == "boolean" || typeof u == "function" ? null : typeof u == "string" || typeof u == "number" || typeof u == "bigint" ? te(null, u, null, null, u) : pe(u) ? te(I, { children: u }, null, null, null) : u.__b > 0 ? te(u.type, u.props, u.key, u.ref ? u.ref : null, u.__v) : u) != null ? (u.__ = n, u.__b = n.__b + 1, (b = zt(u, $, m = s + w, N)) === -1 ? f = W : (f = $[b] || W, $[b] = void 0, N--), Ce(t, u, f, o, r, a, c, _, v, p), d = u.__e, (y = u.ref) && f.ref != y && (f.ref && He(f.ref, null, u), p.push(y, u.__c || d, u)), d != null && (H == null && (H = d), (x = f === W || f.__v === null) ? b == -1 && w-- : b !== m && (b === m + 1 ? w++ : b > m ? N > P - m ? w += b - m : w-- : w = b < m && b == m - 1 ? b - m : 0), m = s + w, typeof u.type != "function" || b === m && f.__k !== u.__k ? typeof u.type == "function" || b === m && !x ? u.__d !== void 0 ? (_ = u.__d, u.__d = void 0) : _ = d.nextSibling : _ = pt(t, d, _) : _ = dt(u, _, t), typeof n.type == "function" && (n.__d = _))) : (f = $[s]) && f.key == null && f.__e && (f.__e == _ && (f.__ = i, _ = G(f)), Se(f, f, !1), $[s] = null);
|
|
71
|
+
for (n.__e = H, s = M; s--; )
|
|
72
|
+
$[s] != null && (typeof n.type == "function" && $[s].__e != null && $[s].__e == n.__d && (n.__d = $[s].__e.nextSibling), Se($[s], $[s]));
|
|
73
|
+
}
|
|
74
|
+
function dt(t, e, n) {
|
|
75
|
+
for (var i, o = t.__k, r = 0; o && r < o.length; r++)
|
|
76
|
+
(i = o[r]) && (i.__ = t, e = typeof i.type == "function" ? dt(i, e, n) : pt(n, i.__e, e));
|
|
77
|
+
return e;
|
|
78
|
+
}
|
|
79
|
+
function oe(t, e) {
|
|
80
|
+
return e = e || [], t == null || typeof t == "boolean" || (pe(t) ? t.some(function(n) {
|
|
81
|
+
oe(n, e);
|
|
82
|
+
}) : e.push(t)), e;
|
|
83
|
+
}
|
|
84
|
+
function pt(t, e, n) {
|
|
85
|
+
return n == null || n.parentNode !== t ? t.insertBefore(e, null) : e == n && e.parentNode != null || t.insertBefore(e, n), e.nextSibling;
|
|
86
|
+
}
|
|
87
|
+
function zt(t, e, n, i) {
|
|
88
|
+
var o = t.key, r = t.type, a = n - 1, c = n + 1, _ = e[n];
|
|
89
|
+
if (_ === null || _ && o == _.key && r === _.type)
|
|
90
|
+
return n;
|
|
91
|
+
if (i > (_ != null ? 1 : 0))
|
|
92
|
+
for (; a >= 0 || c < e.length; ) {
|
|
93
|
+
if (a >= 0) {
|
|
94
|
+
if ((_ = e[a]) && o == _.key && r === _.type)
|
|
95
|
+
return a;
|
|
96
|
+
a--;
|
|
97
|
+
}
|
|
98
|
+
if (c < e.length) {
|
|
99
|
+
if ((_ = e[c]) && o == _.key && r === _.type)
|
|
100
|
+
return c;
|
|
101
|
+
c++;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return -1;
|
|
105
|
+
}
|
|
106
|
+
function Rt(t, e, n, i, o) {
|
|
107
|
+
var r;
|
|
108
|
+
for (r in n)
|
|
109
|
+
r === "children" || r === "key" || r in e || se(t, r, null, n[r], i);
|
|
110
|
+
for (r in e)
|
|
111
|
+
o && typeof e[r] != "function" || r === "children" || r === "key" || r === "value" || r === "checked" || n[r] === e[r] || se(t, r, e[r], n[r], i);
|
|
112
|
+
}
|
|
113
|
+
function Re(t, e, n) {
|
|
114
|
+
e[0] === "-" ? t.setProperty(e, n == null ? "" : n) : t[e] = n == null ? "" : typeof n != "number" || Tt.test(e) ? n : n + "px";
|
|
115
|
+
}
|
|
116
|
+
function se(t, e, n, i, o) {
|
|
117
|
+
var r;
|
|
118
|
+
e:
|
|
119
|
+
if (e === "style")
|
|
120
|
+
if (typeof n == "string")
|
|
121
|
+
t.style.cssText = n;
|
|
122
|
+
else {
|
|
123
|
+
if (typeof i == "string" && (t.style.cssText = i = ""), i)
|
|
124
|
+
for (e in i)
|
|
125
|
+
n && e in n || Re(t.style, e, "");
|
|
126
|
+
if (n)
|
|
127
|
+
for (e in n)
|
|
128
|
+
i && n[e] === i[e] || Re(t.style, e, n[e]);
|
|
129
|
+
}
|
|
130
|
+
else if (e[0] === "o" && e[1] === "n")
|
|
131
|
+
r = e !== (e = e.replace(/(PointerCapture)$|Capture$/, "$1")), e = e.toLowerCase() in t ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + r] = n, n ? i ? n.u = i.u : (n.u = Date.now(), t.addEventListener(e, r ? Le : Oe, r)) : t.removeEventListener(e, r ? Le : Oe, r);
|
|
132
|
+
else if (e !== "dangerouslySetInnerHTML") {
|
|
133
|
+
if (o)
|
|
134
|
+
e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
135
|
+
else if (e !== "width" && e !== "height" && e !== "href" && e !== "list" && e !== "form" && e !== "tabIndex" && e !== "download" && e !== "rowSpan" && e !== "colSpan" && e !== "role" && e in t)
|
|
136
|
+
try {
|
|
137
|
+
t[e] = n == null ? "" : n;
|
|
138
|
+
break e;
|
|
139
|
+
} catch (a) {
|
|
140
|
+
}
|
|
141
|
+
typeof n == "function" || (n == null || n === !1 && e[4] !== "-" ? t.removeAttribute(e) : t.setAttribute(e, n));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function Oe(t) {
|
|
145
|
+
var e = this.l[t.type + !1];
|
|
146
|
+
if (t.t) {
|
|
147
|
+
if (t.t <= e.u)
|
|
148
|
+
return;
|
|
149
|
+
} else
|
|
150
|
+
t.t = Date.now();
|
|
151
|
+
return e(l.event ? l.event(t) : t);
|
|
152
|
+
}
|
|
153
|
+
function Le(t) {
|
|
154
|
+
return this.l[t.type + !0](l.event ? l.event(t) : t);
|
|
155
|
+
}
|
|
156
|
+
function Ce(t, e, n, i, o, r, a, c, _, v) {
|
|
157
|
+
var p, s, y, f, u, d, H, m, b, x, w, $, M, N, P, E = e.type;
|
|
158
|
+
if (e.constructor !== void 0)
|
|
159
|
+
return null;
|
|
160
|
+
n.__h != null && (_ = n.__h, c = e.__e = n.__e, e.__h = null, r = [c]), (p = l.__b) && p(e);
|
|
161
|
+
e:
|
|
162
|
+
if (typeof E == "function")
|
|
163
|
+
try {
|
|
164
|
+
if (m = e.props, b = (p = E.contextType) && i[p.__c], x = p ? b ? b.props.value : p.__ : i, n.__c ? H = (s = e.__c = n.__c).__ = s.__E : ("prototype" in E && E.prototype.render ? e.__c = s = new E(m, x) : (e.__c = s = new C(m, x), s.constructor = E, s.render = Lt), b && b.sub(s), s.props = m, s.state || (s.state = {}), s.context = x, s.__n = i, y = s.__d = !0, s.__h = [], s._sb = []), s.__s == null && (s.__s = s.state), E.getDerivedStateFromProps != null && (s.__s == s.state && (s.__s = T({}, s.__s)), T(s.__s, E.getDerivedStateFromProps(m, s.__s))), f = s.props, u = s.state, s.__v = e, y)
|
|
165
|
+
E.getDerivedStateFromProps == null && s.componentWillMount != null && s.componentWillMount(), s.componentDidMount != null && s.__h.push(s.componentDidMount);
|
|
166
|
+
else {
|
|
167
|
+
if (E.getDerivedStateFromProps == null && m !== f && s.componentWillReceiveProps != null && s.componentWillReceiveProps(m, x), !s.__e && (s.shouldComponentUpdate != null && s.shouldComponentUpdate(m, s.__s, x) === !1 || e.__v === n.__v)) {
|
|
168
|
+
for (e.__v !== n.__v && (s.props = m, s.state = s.__s, s.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.forEach(function(Q) {
|
|
169
|
+
Q && (Q.__ = e);
|
|
170
|
+
}), w = 0; w < s._sb.length; w++)
|
|
171
|
+
s.__h.push(s._sb[w]);
|
|
172
|
+
s._sb = [], s.__h.length && a.push(s);
|
|
173
|
+
break e;
|
|
174
|
+
}
|
|
175
|
+
s.componentWillUpdate != null && s.componentWillUpdate(m, s.__s, x), s.componentDidUpdate != null && s.__h.push(function() {
|
|
176
|
+
s.componentDidUpdate(f, u, d);
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
if (s.context = x, s.props = m, s.__P = t, s.__e = !1, $ = l.__r, M = 0, "prototype" in E && E.prototype.render) {
|
|
180
|
+
for (s.state = s.__s, s.__d = !1, $ && $(e), p = s.render(s.props, s.state, s.context), N = 0; N < s._sb.length; N++)
|
|
181
|
+
s.__h.push(s._sb[N]);
|
|
182
|
+
s._sb = [];
|
|
183
|
+
} else
|
|
184
|
+
do
|
|
185
|
+
s.__d = !1, $ && $(e), p = s.render(s.props, s.state, s.context), s.state = s.__s;
|
|
186
|
+
while (s.__d && ++M < 25);
|
|
187
|
+
s.state = s.__s, s.getChildContext != null && (i = T(T({}, i), s.getChildContext())), y || s.getSnapshotBeforeUpdate == null || (d = s.getSnapshotBeforeUpdate(f, u)), ht(t, pe(P = p != null && p.type === I && p.key == null ? p.props.children : p) ? P : [P], e, n, i, o, r, a, c, _, v), s.base = e.__e, e.__h = null, s.__h.length && a.push(s), H && (s.__E = s.__ = null);
|
|
188
|
+
} catch (Q) {
|
|
189
|
+
e.__v = null, (_ || r != null) && (e.__e = c, e.__h = !!_, r[r.indexOf(c)] = null), l.__e(Q, e, n);
|
|
190
|
+
}
|
|
191
|
+
else
|
|
192
|
+
r == null && e.__v === n.__v ? (e.__k = n.__k, e.__e = n.__e) : e.__e = Ot(n.__e, e, n, i, o, r, a, _, v);
|
|
193
|
+
(p = l.diffed) && p(e);
|
|
194
|
+
}
|
|
195
|
+
function vt(t, e, n) {
|
|
196
|
+
for (var i = 0; i < n.length; i++)
|
|
197
|
+
He(n[i], n[++i], n[++i]);
|
|
198
|
+
l.__c && l.__c(e, t), t.some(function(o) {
|
|
199
|
+
try {
|
|
200
|
+
t = o.__h, o.__h = [], t.some(function(r) {
|
|
201
|
+
r.call(o);
|
|
202
|
+
});
|
|
203
|
+
} catch (r) {
|
|
204
|
+
l.__e(r, o.__v);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
function Ot(t, e, n, i, o, r, a, c, _) {
|
|
209
|
+
var v, p, s, y = n.props, f = e.props, u = e.type, d = 0;
|
|
210
|
+
if (u === "svg" && (o = !0), r != null) {
|
|
211
|
+
for (; d < r.length; d++)
|
|
212
|
+
if ((v = r[d]) && "setAttribute" in v == !!u && (u ? v.localName === u : v.nodeType === 3)) {
|
|
213
|
+
t = v, r[d] = null;
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
if (t == null) {
|
|
218
|
+
if (u === null)
|
|
219
|
+
return document.createTextNode(f);
|
|
220
|
+
t = o ? document.createElementNS("http://www.w3.org/2000/svg", u) : document.createElement(u, f.is && f), r = null, c = !1;
|
|
221
|
+
}
|
|
222
|
+
if (u === null)
|
|
223
|
+
y === f || c && t.data === f || (t.data = f);
|
|
224
|
+
else {
|
|
225
|
+
if (r = r && de.call(t.childNodes), p = (y = n.props || W).dangerouslySetInnerHTML, s = f.dangerouslySetInnerHTML, !c) {
|
|
226
|
+
if (r != null)
|
|
227
|
+
for (y = {}, d = 0; d < t.attributes.length; d++)
|
|
228
|
+
y[t.attributes[d].name] = t.attributes[d].value;
|
|
229
|
+
(s || p) && (s && (p && s.__html == p.__html || s.__html === t.innerHTML) || (t.innerHTML = s && s.__html || ""));
|
|
230
|
+
}
|
|
231
|
+
if (Rt(t, f, y, o, c), s)
|
|
232
|
+
e.__k = [];
|
|
233
|
+
else if (ht(t, pe(d = e.props.children) ? d : [d], e, n, i, o && u !== "foreignObject", r, a, r ? r[0] : n.__k && G(n, 0), c, _), r != null)
|
|
234
|
+
for (d = r.length; d--; )
|
|
235
|
+
r[d] != null && ut(r[d]);
|
|
236
|
+
c || ("value" in f && (d = f.value) !== void 0 && (d !== t.value || u === "progress" && !d || u === "option" && d !== y.value) && se(t, "value", d, y.value, !1), "checked" in f && (d = f.checked) !== void 0 && d !== t.checked && se(t, "checked", d, y.checked, !1));
|
|
237
|
+
}
|
|
238
|
+
return t;
|
|
239
|
+
}
|
|
240
|
+
function He(t, e, n) {
|
|
241
|
+
try {
|
|
242
|
+
typeof t == "function" ? t(e) : t.current = e;
|
|
243
|
+
} catch (i) {
|
|
244
|
+
l.__e(i, n);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
function Se(t, e, n) {
|
|
248
|
+
var i, o;
|
|
249
|
+
if (l.unmount && l.unmount(t), (i = t.ref) && (i.current && i.current !== t.__e || He(i, null, e)), (i = t.__c) != null) {
|
|
250
|
+
if (i.componentWillUnmount)
|
|
251
|
+
try {
|
|
252
|
+
i.componentWillUnmount();
|
|
253
|
+
} catch (r) {
|
|
254
|
+
l.__e(r, e);
|
|
255
|
+
}
|
|
256
|
+
i.base = i.__P = null, t.__c = void 0;
|
|
257
|
+
}
|
|
258
|
+
if (i = t.__k)
|
|
259
|
+
for (o = 0; o < i.length; o++)
|
|
260
|
+
i[o] && Se(i[o], e, n || typeof t.type != "function");
|
|
261
|
+
n || t.__e == null || ut(t.__e), t.__ = t.__e = t.__d = void 0;
|
|
262
|
+
}
|
|
263
|
+
function Lt(t, e, n) {
|
|
264
|
+
return this.constructor(t, n);
|
|
265
|
+
}
|
|
266
|
+
function De(t, e, n) {
|
|
267
|
+
var i, o, r, a;
|
|
268
|
+
l.__ && l.__(t, e), o = (i = typeof n == "function") ? null : n && n.__k || e.__k, r = [], a = [], Ce(e, t = (!i && n || e).__k = Z(I, null, [t]), o || W, W, e.ownerSVGElement !== void 0, !i && n ? [n] : o ? null : e.firstChild ? de.call(e.childNodes) : null, r, !i && n ? n : o ? o.__e : e.firstChild, i, a), vt(r, t, a);
|
|
269
|
+
}
|
|
270
|
+
de = lt.slice, l = { __e: function(t, e, n, i) {
|
|
271
|
+
for (var o, r, a; e = e.__; )
|
|
272
|
+
if ((o = e.__c) && !o.__)
|
|
273
|
+
try {
|
|
274
|
+
if ((r = o.constructor) && r.getDerivedStateFromError != null && (o.setState(r.getDerivedStateFromError(t)), a = o.__d), o.componentDidCatch != null && (o.componentDidCatch(t, i || {}), a = o.__d), a)
|
|
275
|
+
return o.__E = o;
|
|
276
|
+
} catch (c) {
|
|
277
|
+
t = c;
|
|
278
|
+
}
|
|
279
|
+
throw t;
|
|
280
|
+
} }, at = 0, _t = function(t) {
|
|
281
|
+
return t != null && t.constructor === void 0;
|
|
282
|
+
}, C.prototype.setState = function(t, e) {
|
|
283
|
+
var n;
|
|
284
|
+
n = this.__s != null && this.__s !== this.state ? this.__s : this.__s = T({}, this.state), typeof t == "function" && (t = t(T({}, n), this.props)), t && T(n, t), t != null && this.__v && (e && this._sb.push(e), ze(this));
|
|
285
|
+
}, C.prototype.forceUpdate = function(t) {
|
|
286
|
+
this.__v && (this.__e = !0, t && this.__h.push(t), ze(this));
|
|
287
|
+
}, C.prototype.render = I, D = [], ct = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, xe = function(t, e) {
|
|
288
|
+
return t.__v.__b - e.__v.__b;
|
|
289
|
+
}, re.__r = 0;
|
|
290
|
+
const Dt = "ibiz", Ft = "is-";
|
|
291
|
+
function O(t, e, n, i, o) {
|
|
292
|
+
let r = "".concat(t, "-").concat(e);
|
|
293
|
+
return n && (r += "-".concat(n)), i && (r += "__".concat(i)), o && (r += "--".concat(o)), r;
|
|
294
|
+
}
|
|
295
|
+
class z {
|
|
296
|
+
/**
|
|
297
|
+
* Creates an instance of Namespace.
|
|
298
|
+
*
|
|
299
|
+
* @author chitanda
|
|
300
|
+
* @date 2022-09-06 12:09:12
|
|
301
|
+
* @param {string} block 当前命名空间的根模块,例如组件的名称
|
|
302
|
+
* @param {string} [namespace] 指定命名空间,未指定使用默认值 ibiz
|
|
303
|
+
*/
|
|
304
|
+
constructor(e, n) {
|
|
305
|
+
/**
|
|
306
|
+
* 命名空间
|
|
307
|
+
*
|
|
308
|
+
* @author chitanda
|
|
309
|
+
* @date 2022-09-06 12:09:01
|
|
310
|
+
* @type {string}
|
|
311
|
+
*/
|
|
312
|
+
A(this, "namespace");
|
|
313
|
+
this.block = e, this.namespace = n || Dt;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* namespace-block
|
|
317
|
+
* namespace-block-blockSuffix
|
|
318
|
+
*
|
|
319
|
+
* @author chitanda
|
|
320
|
+
* @date 2022-09-06 12:09:08
|
|
321
|
+
* @param {string} [blockSuffix='']
|
|
322
|
+
* @return {*} {string}
|
|
323
|
+
*/
|
|
324
|
+
b(e = "") {
|
|
325
|
+
return O(this.namespace, this.block, e, "", "");
|
|
326
|
+
}
|
|
327
|
+
/**
|
|
328
|
+
* namespace-block__element
|
|
329
|
+
*
|
|
330
|
+
* @author chitanda
|
|
331
|
+
* @date 2022-09-06 12:09:48
|
|
332
|
+
* @param {string} [element]
|
|
333
|
+
* @return {*} {string}
|
|
334
|
+
*/
|
|
335
|
+
e(e) {
|
|
336
|
+
return e ? O(this.namespace, this.block, "", e, "") : "";
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* namespace-block--modifier
|
|
340
|
+
*
|
|
341
|
+
* @author chitanda
|
|
342
|
+
* @date 2022-09-06 12:09:37
|
|
343
|
+
* @param {string} [modifier]
|
|
344
|
+
* @return {*} {string}
|
|
345
|
+
*/
|
|
346
|
+
m(e) {
|
|
347
|
+
return e ? O(this.namespace, this.block, "", "", e) : "";
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* namespace-block-blockSuffix__element
|
|
351
|
+
*
|
|
352
|
+
* @author chitanda
|
|
353
|
+
* @date 2022-09-06 12:09:52
|
|
354
|
+
* @param {string} [blockSuffix]
|
|
355
|
+
* @param {string} [element]
|
|
356
|
+
* @return {*} {string}
|
|
357
|
+
*/
|
|
358
|
+
be(e, n) {
|
|
359
|
+
return e && n ? O(this.namespace, this.block, e, n, "") : "";
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* namespace-block__element--modifier
|
|
363
|
+
*
|
|
364
|
+
* @author chitanda
|
|
365
|
+
* @date 2022-09-06 12:09:19
|
|
366
|
+
* @param {string} [element]
|
|
367
|
+
* @param {string} [modifier]
|
|
368
|
+
* @return {*} {string}
|
|
369
|
+
*/
|
|
370
|
+
em(e, n) {
|
|
371
|
+
return e && n ? O(this.namespace, this.block, "", e, n) : "";
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* namespace-block-blockSuffix--modifier
|
|
375
|
+
*
|
|
376
|
+
* @author chitanda
|
|
377
|
+
* @date 2022-09-06 12:09:59
|
|
378
|
+
* @param {string} [blockSuffix]
|
|
379
|
+
* @param {string} [modifier]
|
|
380
|
+
* @return {*} {string}
|
|
381
|
+
*/
|
|
382
|
+
bm(e, n) {
|
|
383
|
+
return e && n ? O(this.namespace, this.block, e, "", n) : "";
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* namespace-block-blockSuffix__element--modifier
|
|
387
|
+
*
|
|
388
|
+
* @author chitanda
|
|
389
|
+
* @date 2022-09-06 12:09:37
|
|
390
|
+
* @param {string} [blockSuffix]
|
|
391
|
+
* @param {string} [element]
|
|
392
|
+
* @param {string} [modifier]
|
|
393
|
+
* @return {*} {string}
|
|
394
|
+
*/
|
|
395
|
+
bem(e, n, i) {
|
|
396
|
+
return e && n && i ? O(this.namespace, this.block, e, n, i) : "";
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* 返回状态 class
|
|
400
|
+
*
|
|
401
|
+
* is('loading', false) => '';
|
|
402
|
+
* is('loading', true) => 'is-loading';
|
|
403
|
+
*
|
|
404
|
+
* @author chitanda
|
|
405
|
+
* @date 2022-09-06 12:09:57
|
|
406
|
+
* @param {string} name
|
|
407
|
+
* @param {boolean} [state]
|
|
408
|
+
* @return {*} {string}
|
|
409
|
+
*/
|
|
410
|
+
is(e, n) {
|
|
411
|
+
return e && n ? "".concat(Ft).concat(e) : "";
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* 生成使用到的 css 变量 style 对象
|
|
415
|
+
*
|
|
416
|
+
* @author chitanda
|
|
417
|
+
* @date 2022-09-06 15:09:41
|
|
418
|
+
* @param {Record<string, string>} object
|
|
419
|
+
* @return {*} {Record<string, string>}
|
|
420
|
+
*/
|
|
421
|
+
cssVar(e) {
|
|
422
|
+
const n = {};
|
|
423
|
+
for (const i in e)
|
|
424
|
+
e[i] && (n[this.cssVarName(i)] = e[i]);
|
|
425
|
+
return n;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* 生成使用到的 css block 变量 style 对象
|
|
429
|
+
*
|
|
430
|
+
* @author chitanda
|
|
431
|
+
* @date 2022-09-06 15:09:03
|
|
432
|
+
* @param {Record<string, string>} object
|
|
433
|
+
* @return {*} {Record<string, string>}
|
|
434
|
+
*/
|
|
435
|
+
cssVarBlock(e) {
|
|
436
|
+
const n = {};
|
|
437
|
+
for (const i in e)
|
|
438
|
+
e[i] && (n[this.cssVarBlockName(i)] = e[i]);
|
|
439
|
+
return n;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* 生成 css var 变量名称
|
|
443
|
+
*
|
|
444
|
+
* @author chitanda
|
|
445
|
+
* @date 2022-09-06 15:09:21
|
|
446
|
+
* @param {string} name
|
|
447
|
+
* @return {*} {string}
|
|
448
|
+
*/
|
|
449
|
+
cssVarName(e) {
|
|
450
|
+
return "--".concat(this.namespace, "-").concat(e);
|
|
451
|
+
}
|
|
452
|
+
/**
|
|
453
|
+
* 生成块 css var 变量名称
|
|
454
|
+
*
|
|
455
|
+
* @author chitanda
|
|
456
|
+
* @date 2022-09-06 15:09:35
|
|
457
|
+
* @param {string} name
|
|
458
|
+
* @return {*} {string}
|
|
459
|
+
*/
|
|
460
|
+
cssVarBlockName(e) {
|
|
461
|
+
return "--".concat(this.namespace, "-").concat(this.block, "-").concat(e);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function U() {
|
|
465
|
+
return ((1 + Math.random()) * 65536 | 0).toString(16).substring(1);
|
|
466
|
+
}
|
|
467
|
+
function mt() {
|
|
468
|
+
return "".concat(U() + U(), "-").concat(U(), "-").concat(U(), "-").concat(U(), "-").concat(U()).concat(U()).concat(U());
|
|
469
|
+
}
|
|
470
|
+
var ae, S, be, Fe, _e = 0, yt = [], ne = [], We = l.__b, Ve = l.__r, Ie = l.diffed, Be = l.__c, qe = l.unmount;
|
|
471
|
+
function gt(t, e) {
|
|
472
|
+
l.__h && l.__h(S, t, _e || e), _e = 0;
|
|
473
|
+
var n = S.__H || (S.__H = { __: [], __h: [] });
|
|
474
|
+
return t >= n.__.length && n.__.push({ __V: ne }), n.__[t];
|
|
475
|
+
}
|
|
476
|
+
function ce(t, e) {
|
|
477
|
+
var n = gt(ae++, 3);
|
|
478
|
+
!l.__s && bt(n.__H, e) && (n.__ = t, n.i = e, S.__H.__h.push(n));
|
|
479
|
+
}
|
|
480
|
+
function ve(t) {
|
|
481
|
+
return _e = 5, K(function() {
|
|
482
|
+
return { current: t };
|
|
483
|
+
}, []);
|
|
484
|
+
}
|
|
485
|
+
function K(t, e) {
|
|
486
|
+
var n = gt(ae++, 7);
|
|
487
|
+
return bt(n.__H, e) ? (n.__V = t(), n.i = e, n.__h = t, n.__V) : n.__;
|
|
488
|
+
}
|
|
489
|
+
function je(t, e) {
|
|
490
|
+
return _e = 8, K(function() {
|
|
491
|
+
return t;
|
|
492
|
+
}, e);
|
|
493
|
+
}
|
|
494
|
+
function Wt() {
|
|
495
|
+
for (var t; t = yt.shift(); )
|
|
496
|
+
if (t.__P && t.__H)
|
|
497
|
+
try {
|
|
498
|
+
t.__H.__h.forEach(ie), t.__H.__h.forEach(Ne), t.__H.__h = [];
|
|
499
|
+
} catch (e) {
|
|
500
|
+
t.__H.__h = [], l.__e(e, t.__v);
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
l.__b = function(t) {
|
|
504
|
+
S = null, We && We(t);
|
|
505
|
+
}, l.__r = function(t) {
|
|
506
|
+
Ve && Ve(t), ae = 0;
|
|
507
|
+
var e = (S = t.__c).__H;
|
|
508
|
+
e && (be === S ? (e.__h = [], S.__h = [], e.__.forEach(function(n) {
|
|
509
|
+
n.__N && (n.__ = n.__N), n.__V = ne, n.__N = n.i = void 0;
|
|
510
|
+
})) : (e.__h.forEach(ie), e.__h.forEach(Ne), e.__h = [], ae = 0)), be = S;
|
|
511
|
+
}, l.diffed = function(t) {
|
|
512
|
+
Ie && Ie(t);
|
|
513
|
+
var e = t.__c;
|
|
514
|
+
e && e.__H && (e.__H.__h.length && (yt.push(e) !== 1 && Fe === l.requestAnimationFrame || ((Fe = l.requestAnimationFrame) || Vt)(Wt)), e.__H.__.forEach(function(n) {
|
|
515
|
+
n.i && (n.__H = n.i), n.__V !== ne && (n.__ = n.__V), n.i = void 0, n.__V = ne;
|
|
516
|
+
})), be = S = null;
|
|
517
|
+
}, l.__c = function(t, e) {
|
|
518
|
+
e.some(function(n) {
|
|
519
|
+
try {
|
|
520
|
+
n.__h.forEach(ie), n.__h = n.__h.filter(function(i) {
|
|
521
|
+
return !i.__ || Ne(i);
|
|
522
|
+
});
|
|
523
|
+
} catch (i) {
|
|
524
|
+
e.some(function(o) {
|
|
525
|
+
o.__h && (o.__h = []);
|
|
526
|
+
}), e = [], l.__e(i, n.__v);
|
|
527
|
+
}
|
|
528
|
+
}), Be && Be(t, e);
|
|
529
|
+
}, l.unmount = function(t) {
|
|
530
|
+
qe && qe(t);
|
|
531
|
+
var e, n = t.__c;
|
|
532
|
+
n && n.__H && (n.__H.__.forEach(function(i) {
|
|
533
|
+
try {
|
|
534
|
+
ie(i);
|
|
535
|
+
} catch (o) {
|
|
536
|
+
e = o;
|
|
537
|
+
}
|
|
538
|
+
}), n.__H = void 0, e && l.__e(e, n.__v));
|
|
539
|
+
};
|
|
540
|
+
var Ye = typeof requestAnimationFrame == "function";
|
|
541
|
+
function Vt(t) {
|
|
542
|
+
var e, n = function() {
|
|
543
|
+
clearTimeout(i), Ye && cancelAnimationFrame(e), setTimeout(t);
|
|
544
|
+
}, i = setTimeout(n, 100);
|
|
545
|
+
Ye && (e = requestAnimationFrame(n));
|
|
546
|
+
}
|
|
547
|
+
function ie(t) {
|
|
548
|
+
var e = S, n = t.__c;
|
|
549
|
+
typeof n == "function" && (t.__c = void 0, n()), S = e;
|
|
550
|
+
}
|
|
551
|
+
function Ne(t) {
|
|
552
|
+
var e = S;
|
|
553
|
+
t.__c = t.__(), S = e;
|
|
554
|
+
}
|
|
555
|
+
function bt(t, e) {
|
|
556
|
+
return !t || t.length !== e.length || e.some(function(n, i) {
|
|
557
|
+
return n !== t[i];
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
function me() {
|
|
561
|
+
throw new Error("Cycle detected");
|
|
562
|
+
}
|
|
563
|
+
var It = Symbol.for("preact-signals");
|
|
564
|
+
function Ae() {
|
|
565
|
+
if (V > 1)
|
|
566
|
+
V--;
|
|
567
|
+
else {
|
|
568
|
+
for (var t, e = !1; Y !== void 0; ) {
|
|
569
|
+
var n = Y;
|
|
570
|
+
for (Y = void 0, Ee++; n !== void 0; ) {
|
|
571
|
+
var i = n.o;
|
|
572
|
+
if (n.o = void 0, n.f &= -3, !(8 & n.f) && $t(n))
|
|
573
|
+
try {
|
|
574
|
+
n.c();
|
|
575
|
+
} catch (o) {
|
|
576
|
+
e || (t = o, e = !0);
|
|
577
|
+
}
|
|
578
|
+
n = i;
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
if (Ee = 0, V--, e)
|
|
582
|
+
throw t;
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
var g = void 0, Y = void 0, V = 0, Ee = 0, le = 0;
|
|
586
|
+
function wt(t) {
|
|
587
|
+
if (g !== void 0) {
|
|
588
|
+
var e = t.n;
|
|
589
|
+
if (e === void 0 || e.t !== g)
|
|
590
|
+
return e = { i: 0, S: t, p: g.s, n: void 0, t: g, e: void 0, x: void 0, r: e }, g.s !== void 0 && (g.s.n = e), g.s = e, t.n = e, 32 & g.f && t.S(e), e;
|
|
591
|
+
if (e.i === -1)
|
|
592
|
+
return e.i = 0, e.n !== void 0 && (e.n.p = e.p, e.p !== void 0 && (e.p.n = e.n), e.p = g.s, e.n = void 0, g.s.n = e, g.s = e), e;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function k(t) {
|
|
596
|
+
this.v = t, this.i = 0, this.n = void 0, this.t = void 0;
|
|
597
|
+
}
|
|
598
|
+
k.prototype.brand = It;
|
|
599
|
+
k.prototype.h = function() {
|
|
600
|
+
return !0;
|
|
601
|
+
};
|
|
602
|
+
k.prototype.S = function(t) {
|
|
603
|
+
this.t !== t && t.e === void 0 && (t.x = this.t, this.t !== void 0 && (this.t.e = t), this.t = t);
|
|
604
|
+
};
|
|
605
|
+
k.prototype.U = function(t) {
|
|
606
|
+
if (this.t !== void 0) {
|
|
607
|
+
var e = t.e, n = t.x;
|
|
608
|
+
e !== void 0 && (e.x = n, t.e = void 0), n !== void 0 && (n.e = e, t.x = void 0), t === this.t && (this.t = n);
|
|
609
|
+
}
|
|
610
|
+
};
|
|
611
|
+
k.prototype.subscribe = function(t) {
|
|
612
|
+
var e = this;
|
|
613
|
+
return ye(function() {
|
|
614
|
+
var n = e.value, i = 32 & this.f;
|
|
615
|
+
this.f &= -33;
|
|
616
|
+
try {
|
|
617
|
+
t(n);
|
|
618
|
+
} finally {
|
|
619
|
+
this.f |= i;
|
|
620
|
+
}
|
|
621
|
+
});
|
|
622
|
+
};
|
|
623
|
+
k.prototype.valueOf = function() {
|
|
624
|
+
return this.value;
|
|
625
|
+
};
|
|
626
|
+
k.prototype.toString = function() {
|
|
627
|
+
return this.value + "";
|
|
628
|
+
};
|
|
629
|
+
k.prototype.toJSON = function() {
|
|
630
|
+
return this.value;
|
|
631
|
+
};
|
|
632
|
+
k.prototype.peek = function() {
|
|
633
|
+
return this.v;
|
|
634
|
+
};
|
|
635
|
+
Object.defineProperty(k.prototype, "value", { get: function() {
|
|
636
|
+
var t = wt(this);
|
|
637
|
+
return t !== void 0 && (t.i = this.i), this.v;
|
|
638
|
+
}, set: function(t) {
|
|
639
|
+
if (g instanceof R && function() {
|
|
640
|
+
throw new Error("Computed cannot have side-effects");
|
|
641
|
+
}(), t !== this.v) {
|
|
642
|
+
Ee > 100 && me(), this.v = t, this.i++, le++, V++;
|
|
643
|
+
try {
|
|
644
|
+
for (var e = this.t; e !== void 0; e = e.x)
|
|
645
|
+
e.t.N();
|
|
646
|
+
} finally {
|
|
647
|
+
Ae();
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
} });
|
|
651
|
+
function ue(t) {
|
|
652
|
+
return new k(t);
|
|
653
|
+
}
|
|
654
|
+
function $t(t) {
|
|
655
|
+
for (var e = t.s; e !== void 0; e = e.n)
|
|
656
|
+
if (e.S.i !== e.i || !e.S.h() || e.S.i !== e.i)
|
|
657
|
+
return !0;
|
|
658
|
+
return !1;
|
|
659
|
+
}
|
|
660
|
+
function kt(t) {
|
|
661
|
+
for (var e = t.s; e !== void 0; e = e.n) {
|
|
662
|
+
var n = e.S.n;
|
|
663
|
+
if (n !== void 0 && (e.r = n), e.S.n = e, e.i = -1, e.n === void 0) {
|
|
664
|
+
t.s = e;
|
|
665
|
+
break;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
function xt(t) {
|
|
670
|
+
for (var e = t.s, n = void 0; e !== void 0; ) {
|
|
671
|
+
var i = e.p;
|
|
672
|
+
e.i === -1 ? (e.S.U(e), i !== void 0 && (i.n = e.n), e.n !== void 0 && (e.n.p = i)) : n = e, e.S.n = e.r, e.r !== void 0 && (e.r = void 0), e = i;
|
|
673
|
+
}
|
|
674
|
+
t.s = n;
|
|
675
|
+
}
|
|
676
|
+
function R(t) {
|
|
677
|
+
k.call(this, void 0), this.x = t, this.s = void 0, this.g = le - 1, this.f = 4;
|
|
678
|
+
}
|
|
679
|
+
(R.prototype = new k()).h = function() {
|
|
680
|
+
if (this.f &= -3, 1 & this.f)
|
|
681
|
+
return !1;
|
|
682
|
+
if ((36 & this.f) == 32 || (this.f &= -5, this.g === le))
|
|
683
|
+
return !0;
|
|
684
|
+
if (this.g = le, this.f |= 1, this.i > 0 && !$t(this))
|
|
685
|
+
return this.f &= -2, !0;
|
|
686
|
+
var t = g;
|
|
687
|
+
try {
|
|
688
|
+
kt(this), g = this;
|
|
689
|
+
var e = this.x();
|
|
690
|
+
(16 & this.f || this.v !== e || this.i === 0) && (this.v = e, this.f &= -17, this.i++);
|
|
691
|
+
} catch (n) {
|
|
692
|
+
this.v = n, this.f |= 16, this.i++;
|
|
693
|
+
}
|
|
694
|
+
return g = t, xt(this), this.f &= -2, !0;
|
|
695
|
+
};
|
|
696
|
+
R.prototype.S = function(t) {
|
|
697
|
+
if (this.t === void 0) {
|
|
698
|
+
this.f |= 36;
|
|
699
|
+
for (var e = this.s; e !== void 0; e = e.n)
|
|
700
|
+
e.S.S(e);
|
|
701
|
+
}
|
|
702
|
+
k.prototype.S.call(this, t);
|
|
703
|
+
};
|
|
704
|
+
R.prototype.U = function(t) {
|
|
705
|
+
if (this.t !== void 0 && (k.prototype.U.call(this, t), this.t === void 0)) {
|
|
706
|
+
this.f &= -33;
|
|
707
|
+
for (var e = this.s; e !== void 0; e = e.n)
|
|
708
|
+
e.S.U(e);
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
R.prototype.N = function() {
|
|
712
|
+
if (!(2 & this.f)) {
|
|
713
|
+
this.f |= 6;
|
|
714
|
+
for (var t = this.t; t !== void 0; t = t.x)
|
|
715
|
+
t.t.N();
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
R.prototype.peek = function() {
|
|
719
|
+
if (this.h() || me(), 16 & this.f)
|
|
720
|
+
throw this.v;
|
|
721
|
+
return this.v;
|
|
722
|
+
};
|
|
723
|
+
Object.defineProperty(R.prototype, "value", { get: function() {
|
|
724
|
+
1 & this.f && me();
|
|
725
|
+
var t = wt(this);
|
|
726
|
+
if (this.h(), t !== void 0 && (t.i = this.i), 16 & this.f)
|
|
727
|
+
throw this.v;
|
|
728
|
+
return this.v;
|
|
729
|
+
} });
|
|
730
|
+
function St(t) {
|
|
731
|
+
return new R(t);
|
|
732
|
+
}
|
|
733
|
+
function Nt(t) {
|
|
734
|
+
var e = t.u;
|
|
735
|
+
if (t.u = void 0, typeof e == "function") {
|
|
736
|
+
V++;
|
|
737
|
+
var n = g;
|
|
738
|
+
g = void 0;
|
|
739
|
+
try {
|
|
740
|
+
e();
|
|
741
|
+
} catch (i) {
|
|
742
|
+
throw t.f &= -2, t.f |= 8, Me(t), i;
|
|
743
|
+
} finally {
|
|
744
|
+
g = n, Ae();
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
function Me(t) {
|
|
749
|
+
for (var e = t.s; e !== void 0; e = e.n)
|
|
750
|
+
e.S.U(e);
|
|
751
|
+
t.x = void 0, t.s = void 0, Nt(t);
|
|
752
|
+
}
|
|
753
|
+
function Bt(t) {
|
|
754
|
+
if (g !== this)
|
|
755
|
+
throw new Error("Out-of-order effect");
|
|
756
|
+
xt(this), g = t, this.f &= -2, 8 & this.f && Me(this), Ae();
|
|
757
|
+
}
|
|
758
|
+
function J(t) {
|
|
759
|
+
this.x = t, this.u = void 0, this.s = void 0, this.o = void 0, this.f = 32;
|
|
760
|
+
}
|
|
761
|
+
J.prototype.c = function() {
|
|
762
|
+
var t = this.S();
|
|
763
|
+
try {
|
|
764
|
+
if (8 & this.f || this.x === void 0)
|
|
765
|
+
return;
|
|
766
|
+
var e = this.x();
|
|
767
|
+
typeof e == "function" && (this.u = e);
|
|
768
|
+
} finally {
|
|
769
|
+
t();
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
J.prototype.S = function() {
|
|
773
|
+
1 & this.f && me(), this.f |= 1, this.f &= -9, Nt(this), kt(this), V++;
|
|
774
|
+
var t = g;
|
|
775
|
+
return g = this, Bt.bind(this, t);
|
|
776
|
+
};
|
|
777
|
+
J.prototype.N = function() {
|
|
778
|
+
2 & this.f || (this.f |= 2, this.o = Y, Y = this);
|
|
779
|
+
};
|
|
780
|
+
J.prototype.d = function() {
|
|
781
|
+
this.f |= 8, 1 & this.f || Me(this);
|
|
782
|
+
};
|
|
783
|
+
function ye(t) {
|
|
784
|
+
var e = new J(t);
|
|
785
|
+
try {
|
|
786
|
+
e.c();
|
|
787
|
+
} catch (n) {
|
|
788
|
+
throw e.d(), n;
|
|
789
|
+
}
|
|
790
|
+
return e.d.bind(e);
|
|
791
|
+
}
|
|
792
|
+
var ge, we;
|
|
793
|
+
function B(t, e) {
|
|
794
|
+
l[t] = e.bind(null, l[t] || function() {
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
function fe(t) {
|
|
798
|
+
we && we(), we = t && t.S();
|
|
799
|
+
}
|
|
800
|
+
function Et(t) {
|
|
801
|
+
var e = this, n = t.data, i = he(n);
|
|
802
|
+
i.value = n;
|
|
803
|
+
var o = K(function() {
|
|
804
|
+
for (var r = e.__v; r = r.__; )
|
|
805
|
+
if (r.__c) {
|
|
806
|
+
r.__c.__$f |= 4;
|
|
807
|
+
break;
|
|
808
|
+
}
|
|
809
|
+
return e.__$u.c = function() {
|
|
810
|
+
var a;
|
|
811
|
+
!_t(o.peek()) && ((a = e.base) == null ? void 0 : a.nodeType) === 3 ? e.base.data = o.peek() : (e.__$f |= 1, e.setState({}));
|
|
812
|
+
}, St(function() {
|
|
813
|
+
var a = i.value.value;
|
|
814
|
+
return a === 0 ? 0 : a === !0 ? "" : a || "";
|
|
815
|
+
});
|
|
816
|
+
}, []);
|
|
817
|
+
return o.value;
|
|
818
|
+
}
|
|
819
|
+
Et.displayName = "_st";
|
|
820
|
+
Object.defineProperties(k.prototype, { constructor: { configurable: !0, value: void 0 }, type: { configurable: !0, value: Et }, props: { configurable: !0, get: function() {
|
|
821
|
+
return { data: this };
|
|
822
|
+
} }, __b: { configurable: !0, value: 1 } });
|
|
823
|
+
B("__b", function(t, e) {
|
|
824
|
+
if (typeof e.type == "string") {
|
|
825
|
+
var n, i = e.props;
|
|
826
|
+
for (var o in i)
|
|
827
|
+
if (o !== "children") {
|
|
828
|
+
var r = i[o];
|
|
829
|
+
r instanceof k && (n || (e.__np = n = {}), n[o] = r, i[o] = r.peek());
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
t(e);
|
|
833
|
+
});
|
|
834
|
+
B("__r", function(t, e) {
|
|
835
|
+
fe();
|
|
836
|
+
var n, i = e.__c;
|
|
837
|
+
i && (i.__$f &= -2, (n = i.__$u) === void 0 && (i.__$u = n = function(o) {
|
|
838
|
+
var r;
|
|
839
|
+
return ye(function() {
|
|
840
|
+
r = this;
|
|
841
|
+
}), r.c = function() {
|
|
842
|
+
i.__$f |= 1, i.setState({});
|
|
843
|
+
}, r;
|
|
844
|
+
}())), ge = i, fe(n), t(e);
|
|
845
|
+
});
|
|
846
|
+
B("__e", function(t, e, n, i) {
|
|
847
|
+
fe(), ge = void 0, t(e, n, i);
|
|
848
|
+
});
|
|
849
|
+
B("diffed", function(t, e) {
|
|
850
|
+
fe(), ge = void 0;
|
|
851
|
+
var n;
|
|
852
|
+
if (typeof e.type == "string" && (n = e.__e)) {
|
|
853
|
+
var i = e.__np, o = e.props;
|
|
854
|
+
if (i) {
|
|
855
|
+
var r = n.U;
|
|
856
|
+
if (r)
|
|
857
|
+
for (var a in r) {
|
|
858
|
+
var c = r[a];
|
|
859
|
+
c !== void 0 && !(a in i) && (c.d(), r[a] = void 0);
|
|
860
|
+
}
|
|
861
|
+
else
|
|
862
|
+
n.U = r = {};
|
|
863
|
+
for (var _ in i) {
|
|
864
|
+
var v = r[_], p = i[_];
|
|
865
|
+
v === void 0 ? (v = qt(n, _, p, o), r[_] = v) : v.o(p, o);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
t(e);
|
|
870
|
+
});
|
|
871
|
+
function qt(t, e, n, i) {
|
|
872
|
+
var o = e in t && t.ownerSVGElement === void 0, r = ue(n);
|
|
873
|
+
return { o: function(a, c) {
|
|
874
|
+
r.value = a, i = c;
|
|
875
|
+
}, d: ye(function() {
|
|
876
|
+
var a = r.value.value;
|
|
877
|
+
i[e] !== a && (i[e] = a, o ? t[e] = a : a ? t.setAttribute(e, a) : t.removeAttribute(e));
|
|
878
|
+
}) };
|
|
879
|
+
}
|
|
880
|
+
B("unmount", function(t, e) {
|
|
881
|
+
if (typeof e.type == "string") {
|
|
882
|
+
var n = e.__e;
|
|
883
|
+
if (n) {
|
|
884
|
+
var i = n.U;
|
|
885
|
+
if (i) {
|
|
886
|
+
n.U = void 0;
|
|
887
|
+
for (var o in i) {
|
|
888
|
+
var r = i[o];
|
|
889
|
+
r && r.d();
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
} else {
|
|
894
|
+
var a = e.__c;
|
|
895
|
+
if (a) {
|
|
896
|
+
var c = a.__$u;
|
|
897
|
+
c && (a.__$u = void 0, c.d());
|
|
898
|
+
}
|
|
899
|
+
}
|
|
900
|
+
t(e);
|
|
901
|
+
});
|
|
902
|
+
B("__h", function(t, e, n, i) {
|
|
903
|
+
(i < 3 || i === 9) && (e.__$f |= 2), t(e, n, i);
|
|
904
|
+
});
|
|
905
|
+
C.prototype.shouldComponentUpdate = function(t, e) {
|
|
906
|
+
var n = this.__$u;
|
|
907
|
+
if (!(n && n.s !== void 0 || 4 & this.__$f) || 3 & this.__$f)
|
|
908
|
+
return !0;
|
|
909
|
+
for (var i in e)
|
|
910
|
+
return !0;
|
|
911
|
+
for (var o in t)
|
|
912
|
+
if (o !== "__source" && t[o] !== this.props[o])
|
|
913
|
+
return !0;
|
|
914
|
+
for (var r in this.props)
|
|
915
|
+
if (!(r in t))
|
|
916
|
+
return !0;
|
|
917
|
+
return !1;
|
|
918
|
+
};
|
|
919
|
+
function he(t) {
|
|
920
|
+
return K(function() {
|
|
921
|
+
return ue(t);
|
|
922
|
+
}, []);
|
|
923
|
+
}
|
|
924
|
+
function Pe(t) {
|
|
925
|
+
var e = ve(t);
|
|
926
|
+
return e.current = t, ge.__$f |= 4, K(function() {
|
|
927
|
+
return St(function() {
|
|
928
|
+
return e.current();
|
|
929
|
+
});
|
|
930
|
+
}, []);
|
|
931
|
+
}
|
|
932
|
+
function jt(t) {
|
|
933
|
+
var e = ve(t);
|
|
934
|
+
e.current = t, ce(function() {
|
|
935
|
+
return ye(function() {
|
|
936
|
+
return e.current();
|
|
937
|
+
});
|
|
938
|
+
}, []);
|
|
939
|
+
}
|
|
940
|
+
var Yt = 0;
|
|
941
|
+
function h(t, e, n, i, o, r) {
|
|
942
|
+
var a, c, _ = {};
|
|
943
|
+
for (c in e)
|
|
944
|
+
c == "ref" ? a = e[c] : _[c] = e[c];
|
|
945
|
+
var v = { type: t, props: _, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: --Yt, __source: o, __self: r };
|
|
946
|
+
if (typeof t == "function" && (a = t.defaultProps))
|
|
947
|
+
for (c in a)
|
|
948
|
+
_[c] === void 0 && (_[c] = a[c]);
|
|
949
|
+
return l.vnode && l.vnode(v), v;
|
|
950
|
+
}
|
|
951
|
+
const Xt = () => h("svg", {
|
|
952
|
+
viewBox: "0 0 1024 1024",
|
|
953
|
+
version: "1.1",
|
|
954
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
955
|
+
children: h("path", {
|
|
956
|
+
d: "M843.904 783.573333 783.573333 843.904 512.042667 572.373333 240.512 843.904 180.181333 783.573333 451.712 512.042667 180.181333 240.512 240.512 180.181333 512.042667 451.712 783.573333 180.181333 843.904 240.512 572.373333 512.042667 843.904 783.573333Z"
|
|
957
|
+
})
|
|
958
|
+
}), Zt = () => h("svg", {
|
|
959
|
+
className: "icon",
|
|
960
|
+
viewBox: "0 0 1024 1024",
|
|
961
|
+
version: "1.1",
|
|
962
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
963
|
+
children: h("path", {
|
|
964
|
+
d: "M900.64 379.808l-263.072-256.032c-36.448-35.328-105.76-35.392-142.304 0.096l-327.04 319.904c-56.416 54.72-70.72 76.704-70.72 150.976l0 143.936c0 132.768 26.976 192 186.912 192l131.872 0c81.12 0 128.448-46.656 193.952-111.264l290.016-297.696c18.592-17.984 29.248-43.968 29.248-71.264C929.504 423.36 918.976 397.6 900.64 379.808zM323.008 786.752c-52.928 0-96-43.072-96-96s43.072-96 96-96 96 43.072 96 96S375.936 786.752 323.008 786.752z"
|
|
965
|
+
})
|
|
966
|
+
}), Gt = () => h("svg", {
|
|
967
|
+
viewBox: "0 0 1024 1024",
|
|
968
|
+
version: "1.1",
|
|
969
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
970
|
+
children: h("path", {
|
|
971
|
+
d: "M931.4 498.9L94.9 79.5c-3.4-1.7-7.3-2.1-11-1.2-8.5 2.1-13.8 10.7-11.7 19.3l86.2 352.2c1.3 5.3 5.2 9.6 10.4 11.3l147.7 50.7-147.6 50.7c-5.2 1.8-9.1 6-10.3 11.3L72.2 926.5c-0.9 3.7-0.5 7.6 1.2 10.9 3.9 7.9 13.5 11.1 21.5 7.2l836.5-417c3.1-1.5 5.6-4.1 7.2-7.1 3.9-8 0.7-17.6-7.2-21.6zM170.8 826.3l50.3-205.6 295.2-101.3c2.3-0.8 4.2-2.6 5-5 1.4-4.2-0.8-8.7-5-10.2L221.1 403 171 198.2l628 314.9-628.2 313.2z"
|
|
972
|
+
})
|
|
973
|
+
});
|
|
974
|
+
const L = new z("markdown-message"), Kt = (t) => {
|
|
975
|
+
const {
|
|
976
|
+
message: e,
|
|
977
|
+
size: n
|
|
978
|
+
} = t, i = he(mt()), o = he(null);
|
|
979
|
+
ce(() => {
|
|
980
|
+
n >= 0 && o.value && o.value.setMarkdown(e.content);
|
|
981
|
+
}, [e, n]), ce(() => {
|
|
982
|
+
o.value = new Ut({
|
|
983
|
+
id: i,
|
|
984
|
+
value: e.content,
|
|
985
|
+
editor: {
|
|
986
|
+
defaultModel: "previewOnly"
|
|
987
|
+
}
|
|
988
|
+
});
|
|
989
|
+
}, []);
|
|
990
|
+
const r = () => {
|
|
991
|
+
t.controller.backfill(e);
|
|
992
|
+
};
|
|
993
|
+
return h("div", {
|
|
994
|
+
className: L.b(),
|
|
995
|
+
children: [h("div", {
|
|
996
|
+
className: L.b("header"),
|
|
997
|
+
children: h("div", {
|
|
998
|
+
className: L.be("header", "caption"),
|
|
999
|
+
children: "AI: "
|
|
1000
|
+
})
|
|
1001
|
+
}), h("div", {
|
|
1002
|
+
className: L.b("content"),
|
|
1003
|
+
children: h("div", {
|
|
1004
|
+
id: i
|
|
1005
|
+
})
|
|
1006
|
+
}), h("div", {
|
|
1007
|
+
className: L.b("footer"),
|
|
1008
|
+
children: h("div", {
|
|
1009
|
+
className: L.b("footer-action-wrapper"),
|
|
1010
|
+
children: h("div", {
|
|
1011
|
+
className: L.be("footer", "action-item"),
|
|
1012
|
+
title: "回填当前回复",
|
|
1013
|
+
onClick: r,
|
|
1014
|
+
children: h(Zt, {})
|
|
1015
|
+
})
|
|
1016
|
+
})
|
|
1017
|
+
})]
|
|
1018
|
+
});
|
|
1019
|
+
};
|
|
1020
|
+
const Xe = new z("user-message"), Jt = (t) => {
|
|
1021
|
+
const e = Pe(() => t.message.content);
|
|
1022
|
+
return h("div", {
|
|
1023
|
+
className: Xe.b(),
|
|
1024
|
+
children: h("span", {
|
|
1025
|
+
className: Xe.e("content"),
|
|
1026
|
+
children: e
|
|
1027
|
+
})
|
|
1028
|
+
});
|
|
1029
|
+
};
|
|
1030
|
+
const Ze = new z("error-message"), Qt = (t) => {
|
|
1031
|
+
const e = Pe(() => t.message.content);
|
|
1032
|
+
return h("div", {
|
|
1033
|
+
className: Ze.b(),
|
|
1034
|
+
children: h("span", {
|
|
1035
|
+
className: Ze.e("content"),
|
|
1036
|
+
children: e
|
|
1037
|
+
})
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
const Ge = new z("unknown-message"), en = (t) => h("div", {
|
|
1041
|
+
className: Ge.b(),
|
|
1042
|
+
children: h("span", {
|
|
1043
|
+
className: Ge.e("content"),
|
|
1044
|
+
children: ["暂未支持的消息类型: ", t.message.type]
|
|
1045
|
+
})
|
|
1046
|
+
}), tn = new z("chat-message-item"), nn = (t) => {
|
|
1047
|
+
const {
|
|
1048
|
+
message: e,
|
|
1049
|
+
size: n
|
|
1050
|
+
} = t;
|
|
1051
|
+
let i = null;
|
|
1052
|
+
switch (e.type) {
|
|
1053
|
+
case "DEFAULT":
|
|
1054
|
+
i = e.role === "ASSISTANT" ? Kt : Jt;
|
|
1055
|
+
break;
|
|
1056
|
+
case "ERROR":
|
|
1057
|
+
i = Qt;
|
|
1058
|
+
break;
|
|
1059
|
+
default:
|
|
1060
|
+
i = en;
|
|
1061
|
+
}
|
|
1062
|
+
return h("div", {
|
|
1063
|
+
className: tn.b(),
|
|
1064
|
+
children: Z(i, {
|
|
1065
|
+
size: n,
|
|
1066
|
+
message: e,
|
|
1067
|
+
controller: t.controller
|
|
1068
|
+
})
|
|
1069
|
+
});
|
|
1070
|
+
};
|
|
1071
|
+
const rn = new z("chat-messages"), on = (t) => {
|
|
1072
|
+
const e = ve(null), n = t.controller.messages;
|
|
1073
|
+
return jt(() => {
|
|
1074
|
+
e.current && n.value.length > 0 && (e.current.scrollTop = e.current.scrollHeight);
|
|
1075
|
+
}), h("div", {
|
|
1076
|
+
ref: e,
|
|
1077
|
+
className: rn.b(),
|
|
1078
|
+
children: n.value.map((i) => {
|
|
1079
|
+
var r;
|
|
1080
|
+
const o = ((r = i.content) == null ? void 0 : r.length) || 0;
|
|
1081
|
+
return h(nn, {
|
|
1082
|
+
message: i,
|
|
1083
|
+
size: o,
|
|
1084
|
+
controller: t.controller
|
|
1085
|
+
}, i.messageid);
|
|
1086
|
+
})
|
|
1087
|
+
});
|
|
1088
|
+
};
|
|
1089
|
+
function sn(t, e) {
|
|
1090
|
+
for (var n in e)
|
|
1091
|
+
t[n] = e[n];
|
|
1092
|
+
return t;
|
|
1093
|
+
}
|
|
1094
|
+
function Ke(t, e) {
|
|
1095
|
+
for (var n in t)
|
|
1096
|
+
if (n !== "__source" && !(n in e))
|
|
1097
|
+
return !0;
|
|
1098
|
+
for (var i in e)
|
|
1099
|
+
if (i !== "__source" && t[i] !== e[i])
|
|
1100
|
+
return !0;
|
|
1101
|
+
return !1;
|
|
1102
|
+
}
|
|
1103
|
+
function Je(t) {
|
|
1104
|
+
this.props = t;
|
|
1105
|
+
}
|
|
1106
|
+
(Je.prototype = new C()).isPureReactComponent = !0, Je.prototype.shouldComponentUpdate = function(t, e) {
|
|
1107
|
+
return Ke(this.props, t) || Ke(this.state, e);
|
|
1108
|
+
};
|
|
1109
|
+
var Qe = l.__b;
|
|
1110
|
+
l.__b = function(t) {
|
|
1111
|
+
t.type && t.type.__f && t.ref && (t.props.ref = t.ref, t.ref = null), Qe && Qe(t);
|
|
1112
|
+
};
|
|
1113
|
+
var an = l.__e;
|
|
1114
|
+
l.__e = function(t, e, n, i) {
|
|
1115
|
+
if (t.then) {
|
|
1116
|
+
for (var o, r = e; r = r.__; )
|
|
1117
|
+
if ((o = r.__c) && o.__c)
|
|
1118
|
+
return e.__e == null && (e.__e = n.__e, e.__k = n.__k), o.__c(t, e);
|
|
1119
|
+
}
|
|
1120
|
+
an(t, e, n, i);
|
|
1121
|
+
};
|
|
1122
|
+
var et = l.unmount;
|
|
1123
|
+
function Ct(t, e, n) {
|
|
1124
|
+
return t && (t.__c && t.__c.__H && (t.__c.__H.__.forEach(function(i) {
|
|
1125
|
+
typeof i.__c == "function" && i.__c();
|
|
1126
|
+
}), t.__c.__H = null), (t = sn({}, t)).__c != null && (t.__c.__P === n && (t.__c.__P = e), t.__c = null), t.__k = t.__k && t.__k.map(function(i) {
|
|
1127
|
+
return Ct(i, e, n);
|
|
1128
|
+
})), t;
|
|
1129
|
+
}
|
|
1130
|
+
function Ht(t, e, n) {
|
|
1131
|
+
return t && n && (t.__v = null, t.__k = t.__k && t.__k.map(function(i) {
|
|
1132
|
+
return Ht(i, e, n);
|
|
1133
|
+
}), t.__c && t.__c.__P === e && (t.__e && n.insertBefore(t.__e, t.__d), t.__c.__e = !0, t.__c.__P = n)), t;
|
|
1134
|
+
}
|
|
1135
|
+
function $e() {
|
|
1136
|
+
this.__u = 0, this.t = null, this.__b = null;
|
|
1137
|
+
}
|
|
1138
|
+
function At(t) {
|
|
1139
|
+
var e = t.__.__c;
|
|
1140
|
+
return e && e.__a && e.__a(t);
|
|
1141
|
+
}
|
|
1142
|
+
function ee() {
|
|
1143
|
+
this.u = null, this.o = null;
|
|
1144
|
+
}
|
|
1145
|
+
l.unmount = function(t) {
|
|
1146
|
+
var e = t.__c;
|
|
1147
|
+
e && e.__R && e.__R(), e && t.__h === !0 && (t.type = null), et && et(t);
|
|
1148
|
+
}, ($e.prototype = new C()).__c = function(t, e) {
|
|
1149
|
+
var n = e.__c, i = this;
|
|
1150
|
+
i.t == null && (i.t = []), i.t.push(n);
|
|
1151
|
+
var o = At(i.__v), r = !1, a = function() {
|
|
1152
|
+
r || (r = !0, n.__R = null, o ? o(c) : c());
|
|
1153
|
+
};
|
|
1154
|
+
n.__R = a;
|
|
1155
|
+
var c = function() {
|
|
1156
|
+
if (!--i.__u) {
|
|
1157
|
+
if (i.state.__a) {
|
|
1158
|
+
var v = i.state.__a;
|
|
1159
|
+
i.__v.__k[0] = Ht(v, v.__c.__P, v.__c.__O);
|
|
1160
|
+
}
|
|
1161
|
+
var p;
|
|
1162
|
+
for (i.setState({ __a: i.__b = null }); p = i.t.pop(); )
|
|
1163
|
+
p.forceUpdate();
|
|
1164
|
+
}
|
|
1165
|
+
}, _ = e.__h === !0;
|
|
1166
|
+
i.__u++ || _ || i.setState({ __a: i.__b = i.__v.__k[0] }), t.then(a, a);
|
|
1167
|
+
}, $e.prototype.componentWillUnmount = function() {
|
|
1168
|
+
this.t = [];
|
|
1169
|
+
}, $e.prototype.render = function(t, e) {
|
|
1170
|
+
if (this.__b) {
|
|
1171
|
+
if (this.__v.__k) {
|
|
1172
|
+
var n = document.createElement("div"), i = this.__v.__k[0].__c;
|
|
1173
|
+
this.__v.__k[0] = Ct(this.__b, n, i.__O = i.__P);
|
|
1174
|
+
}
|
|
1175
|
+
this.__b = null;
|
|
1176
|
+
}
|
|
1177
|
+
var o = e.__a && Z(I, null, t.fallback);
|
|
1178
|
+
return o && (o.__h = null), [Z(I, null, e.__a ? null : t.children), o];
|
|
1179
|
+
};
|
|
1180
|
+
var tt = function(t, e, n) {
|
|
1181
|
+
if (++n[1] === n[0] && t.o.delete(e), t.props.revealOrder && (t.props.revealOrder[0] !== "t" || !t.o.size))
|
|
1182
|
+
for (n = t.u; n; ) {
|
|
1183
|
+
for (; n.length > 3; )
|
|
1184
|
+
n.pop()();
|
|
1185
|
+
if (n[1] < n[0])
|
|
1186
|
+
break;
|
|
1187
|
+
t.u = n = n[2];
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
(ee.prototype = new C()).__a = function(t) {
|
|
1191
|
+
var e = this, n = At(e.__v), i = e.o.get(t);
|
|
1192
|
+
return i[0]++, function(o) {
|
|
1193
|
+
var r = function() {
|
|
1194
|
+
e.props.revealOrder ? (i.push(o), tt(e, t, i)) : o();
|
|
1195
|
+
};
|
|
1196
|
+
n ? n(r) : r();
|
|
1197
|
+
};
|
|
1198
|
+
}, ee.prototype.render = function(t) {
|
|
1199
|
+
this.u = null, this.o = /* @__PURE__ */ new Map();
|
|
1200
|
+
var e = oe(t.children);
|
|
1201
|
+
t.revealOrder && t.revealOrder[0] === "b" && e.reverse();
|
|
1202
|
+
for (var n = e.length; n--; )
|
|
1203
|
+
this.o.set(e[n], this.u = [1, 0, this.u]);
|
|
1204
|
+
return t.children;
|
|
1205
|
+
}, ee.prototype.componentDidUpdate = ee.prototype.componentDidMount = function() {
|
|
1206
|
+
var t = this;
|
|
1207
|
+
this.o.forEach(function(e, n) {
|
|
1208
|
+
tt(t, n, e);
|
|
1209
|
+
});
|
|
1210
|
+
};
|
|
1211
|
+
var _n = typeof Symbol < "u" && Symbol.for && Symbol.for("react.element") || 60103, cn = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, ln = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, un = /[A-Z0-9]/g, fn = typeof document < "u", hn = function(t) {
|
|
1212
|
+
return (typeof Symbol < "u" && typeof Symbol() == "symbol" ? /fil|che|rad/ : /fil|che|ra/).test(t);
|
|
1213
|
+
};
|
|
1214
|
+
C.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(t) {
|
|
1215
|
+
Object.defineProperty(C.prototype, t, { configurable: !0, get: function() {
|
|
1216
|
+
return this["UNSAFE_" + t];
|
|
1217
|
+
}, set: function(e) {
|
|
1218
|
+
Object.defineProperty(this, t, { configurable: !0, writable: !0, value: e });
|
|
1219
|
+
} });
|
|
1220
|
+
});
|
|
1221
|
+
var nt = l.event;
|
|
1222
|
+
function dn() {
|
|
1223
|
+
}
|
|
1224
|
+
function pn() {
|
|
1225
|
+
return this.cancelBubble;
|
|
1226
|
+
}
|
|
1227
|
+
function vn() {
|
|
1228
|
+
return this.defaultPrevented;
|
|
1229
|
+
}
|
|
1230
|
+
l.event = function(t) {
|
|
1231
|
+
return nt && (t = nt(t)), t.persist = dn, t.isPropagationStopped = pn, t.isDefaultPrevented = vn, t.nativeEvent = t;
|
|
1232
|
+
};
|
|
1233
|
+
var mn = { enumerable: !1, configurable: !0, get: function() {
|
|
1234
|
+
return this.class;
|
|
1235
|
+
} }, it = l.vnode;
|
|
1236
|
+
l.vnode = function(t) {
|
|
1237
|
+
typeof t.type == "string" && function(e) {
|
|
1238
|
+
var n = e.props, i = e.type, o = {};
|
|
1239
|
+
for (var r in n) {
|
|
1240
|
+
var a = n[r];
|
|
1241
|
+
if (!(r === "value" && "defaultValue" in n && a == null || fn && r === "children" && i === "noscript" || r === "class" || r === "className")) {
|
|
1242
|
+
var c = r.toLowerCase();
|
|
1243
|
+
r === "defaultValue" && "value" in n && n.value == null ? r = "value" : r === "download" && a === !0 ? a = "" : c === "ondoubleclick" ? r = "ondblclick" : c !== "onchange" || i !== "input" && i !== "textarea" || hn(n.type) ? c === "onfocus" ? r = "onfocusin" : c === "onblur" ? r = "onfocusout" : ln.test(r) ? r = c : i.indexOf("-") === -1 && cn.test(r) ? r = r.replace(un, "-$&").toLowerCase() : a === null && (a = void 0) : c = r = "oninput", c === "oninput" && o[r = c] && (r = "oninputCapture"), o[r] = a;
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
i == "select" && o.multiple && Array.isArray(o.value) && (o.value = oe(n.children).forEach(function(_) {
|
|
1247
|
+
_.props.selected = o.value.indexOf(_.props.value) != -1;
|
|
1248
|
+
})), i == "select" && o.defaultValue != null && (o.value = oe(n.children).forEach(function(_) {
|
|
1249
|
+
_.props.selected = o.multiple ? o.defaultValue.indexOf(_.props.value) != -1 : o.defaultValue == _.props.value;
|
|
1250
|
+
})), n.class && !n.className ? (o.class = n.class, Object.defineProperty(o, "className", mn)) : (n.className && !n.class || n.class && n.className) && (o.class = o.className = n.className), e.props = o;
|
|
1251
|
+
}(t), t.$$typeof = _n, it && it(t);
|
|
1252
|
+
};
|
|
1253
|
+
var rt = l.__r;
|
|
1254
|
+
l.__r = function(t) {
|
|
1255
|
+
rt && rt(t), t.__c;
|
|
1256
|
+
};
|
|
1257
|
+
var ot = l.diffed;
|
|
1258
|
+
l.diffed = function(t) {
|
|
1259
|
+
ot && ot(t);
|
|
1260
|
+
var e = t.props, n = t.__e;
|
|
1261
|
+
n != null && t.type === "textarea" && "value" in e && e.value !== n.value && (n.value = e.value == null ? "" : e.value);
|
|
1262
|
+
};
|
|
1263
|
+
var X = /* @__PURE__ */ new Map();
|
|
1264
|
+
function yn(t) {
|
|
1265
|
+
var e = X.get(t);
|
|
1266
|
+
e && e.destroy();
|
|
1267
|
+
}
|
|
1268
|
+
function gn(t) {
|
|
1269
|
+
var e = X.get(t);
|
|
1270
|
+
e && e.update();
|
|
1271
|
+
}
|
|
1272
|
+
var j = null;
|
|
1273
|
+
typeof window > "u" ? ((j = function(t) {
|
|
1274
|
+
return t;
|
|
1275
|
+
}).destroy = function(t) {
|
|
1276
|
+
return t;
|
|
1277
|
+
}, j.update = function(t) {
|
|
1278
|
+
return t;
|
|
1279
|
+
}) : ((j = function(t, e) {
|
|
1280
|
+
return t && Array.prototype.forEach.call(t.length ? t : [t], function(n) {
|
|
1281
|
+
return function(i) {
|
|
1282
|
+
if (i && i.nodeName && i.nodeName === "TEXTAREA" && !X.has(i)) {
|
|
1283
|
+
var o, r = null, a = window.getComputedStyle(i), c = (o = i.value, function() {
|
|
1284
|
+
v({ testForHeightReduction: o === "" || !i.value.startsWith(o), restoreTextAlign: null }), o = i.value;
|
|
1285
|
+
}), _ = (function(s) {
|
|
1286
|
+
i.removeEventListener("autosize:destroy", _), i.removeEventListener("autosize:update", p), i.removeEventListener("input", c), window.removeEventListener("resize", p), Object.keys(s).forEach(function(y) {
|
|
1287
|
+
return i.style[y] = s[y];
|
|
1288
|
+
}), X.delete(i);
|
|
1289
|
+
}).bind(i, { height: i.style.height, resize: i.style.resize, textAlign: i.style.textAlign, overflowY: i.style.overflowY, overflowX: i.style.overflowX, wordWrap: i.style.wordWrap });
|
|
1290
|
+
i.addEventListener("autosize:destroy", _), i.addEventListener("autosize:update", p), i.addEventListener("input", c), window.addEventListener("resize", p), i.style.overflowX = "hidden", i.style.wordWrap = "break-word", X.set(i, { destroy: _, update: p }), p();
|
|
1291
|
+
}
|
|
1292
|
+
function v(s) {
|
|
1293
|
+
var y, f, u = s.restoreTextAlign, d = u === void 0 ? null : u, H = s.testForHeightReduction, m = H === void 0 || H, b = a.overflowY;
|
|
1294
|
+
if (i.scrollHeight !== 0 && (a.resize === "vertical" ? i.style.resize = "none" : a.resize === "both" && (i.style.resize = "horizontal"), m && (y = function(w) {
|
|
1295
|
+
for (var $ = []; w && w.parentNode && w.parentNode instanceof Element; )
|
|
1296
|
+
w.parentNode.scrollTop && $.push([w.parentNode, w.parentNode.scrollTop]), w = w.parentNode;
|
|
1297
|
+
return function() {
|
|
1298
|
+
return $.forEach(function(M) {
|
|
1299
|
+
var N = M[0], P = M[1];
|
|
1300
|
+
N.style.scrollBehavior = "auto", N.scrollTop = P, N.style.scrollBehavior = null;
|
|
1301
|
+
});
|
|
1302
|
+
};
|
|
1303
|
+
}(i), i.style.height = ""), f = a.boxSizing === "content-box" ? i.scrollHeight - (parseFloat(a.paddingTop) + parseFloat(a.paddingBottom)) : i.scrollHeight + parseFloat(a.borderTopWidth) + parseFloat(a.borderBottomWidth), a.maxHeight !== "none" && f > parseFloat(a.maxHeight) ? (a.overflowY === "hidden" && (i.style.overflow = "scroll"), f = parseFloat(a.maxHeight)) : a.overflowY !== "hidden" && (i.style.overflow = "hidden"), i.style.height = f + "px", d && (i.style.textAlign = d), y && y(), r !== f && (i.dispatchEvent(new Event("autosize:resized", { bubbles: !0 })), r = f), b !== a.overflow && !d)) {
|
|
1304
|
+
var x = a.textAlign;
|
|
1305
|
+
a.overflow === "hidden" && (i.style.textAlign = x === "start" ? "end" : "start"), v({ restoreTextAlign: x, testForHeightReduction: !0 });
|
|
1306
|
+
}
|
|
1307
|
+
}
|
|
1308
|
+
function p() {
|
|
1309
|
+
v({ testForHeightReduction: !0, restoreTextAlign: null });
|
|
1310
|
+
}
|
|
1311
|
+
}(n);
|
|
1312
|
+
}), t;
|
|
1313
|
+
}).destroy = function(t) {
|
|
1314
|
+
return t && Array.prototype.forEach.call(t.length ? t : [t], yn), t;
|
|
1315
|
+
}, j.update = function(t) {
|
|
1316
|
+
return t && Array.prototype.forEach.call(t.length ? t : [t], gn), t;
|
|
1317
|
+
});
|
|
1318
|
+
var st = j;
|
|
1319
|
+
const F = new z("chat-input"), bn = (t) => {
|
|
1320
|
+
const e = ve(null), n = t.controller.input, i = he(!1), o = je((_) => {
|
|
1321
|
+
n.value = _.target.value;
|
|
1322
|
+
}, [n]), r = Pe(() => n.value.length <= 0 || i.value === !0);
|
|
1323
|
+
ce(() => (e.current && st(e.current), () => {
|
|
1324
|
+
e.current && st.destroy(e.current);
|
|
1325
|
+
}), [e]);
|
|
1326
|
+
const a = je(async () => {
|
|
1327
|
+
i.value = !0;
|
|
1328
|
+
try {
|
|
1329
|
+
await t.controller.question(n.value), n.value = "";
|
|
1330
|
+
} catch (_) {
|
|
1331
|
+
console.error(_);
|
|
1332
|
+
} finally {
|
|
1333
|
+
i.value = !1;
|
|
1334
|
+
}
|
|
1335
|
+
}, [n, i]), c = (_) => {
|
|
1336
|
+
_.code === "Enter" && _.ctrlKey && (_.stopPropagation(), a());
|
|
1337
|
+
};
|
|
1338
|
+
return h("div", {
|
|
1339
|
+
className: F.b(),
|
|
1340
|
+
children: [h("textarea", {
|
|
1341
|
+
className: F.e("textarea"),
|
|
1342
|
+
type: "text",
|
|
1343
|
+
wrap: "off",
|
|
1344
|
+
autoCorrect: "off",
|
|
1345
|
+
autoCapitalize: "off",
|
|
1346
|
+
autoComplete: "off",
|
|
1347
|
+
value: n,
|
|
1348
|
+
onInput: o,
|
|
1349
|
+
onKeyDown: c,
|
|
1350
|
+
ref: e,
|
|
1351
|
+
disabled: i
|
|
1352
|
+
}), h("div", {
|
|
1353
|
+
className: F.b("action-wrapper"),
|
|
1354
|
+
children: h("div", {
|
|
1355
|
+
title: i ? "思考中..." : "发送消息",
|
|
1356
|
+
className: "".concat(F.be("action-wrapper", "action-item"), " ").concat(F.is("disabled", r.value), " ").concat(F.is("loading", i.value)),
|
|
1357
|
+
onClick: a,
|
|
1358
|
+
disabled: r,
|
|
1359
|
+
children: h(Gt, {})
|
|
1360
|
+
})
|
|
1361
|
+
})]
|
|
1362
|
+
});
|
|
1363
|
+
};
|
|
1364
|
+
class wn extends C {
|
|
1365
|
+
constructor() {
|
|
1366
|
+
super(...arguments);
|
|
1367
|
+
A(this, "ns", new z("chat-container"));
|
|
1368
|
+
A(this, "containerRef", Te());
|
|
1369
|
+
A(this, "dragHandle", Te());
|
|
1370
|
+
A(this, "data", {
|
|
1371
|
+
x: window.innerWidth - 600 - 100,
|
|
1372
|
+
y: 100,
|
|
1373
|
+
width: 600,
|
|
1374
|
+
height: 600,
|
|
1375
|
+
minWidth: 300,
|
|
1376
|
+
minHeight: 300
|
|
1377
|
+
});
|
|
1378
|
+
}
|
|
1379
|
+
calcStyle() {
|
|
1380
|
+
return {
|
|
1381
|
+
left: "".concat(this.data.x, "px"),
|
|
1382
|
+
top: "".concat(this.data.y, "px"),
|
|
1383
|
+
height: "".concat(this.data.height, "px"),
|
|
1384
|
+
width: "".concat(this.data.width, "px"),
|
|
1385
|
+
"z-index": "1000px"
|
|
1386
|
+
};
|
|
1387
|
+
}
|
|
1388
|
+
setStyle() {
|
|
1389
|
+
Object.assign(this.containerRef.current.style, this.calcStyle());
|
|
1390
|
+
}
|
|
1391
|
+
componentDidMount() {
|
|
1392
|
+
this.setStyle();
|
|
1393
|
+
const n = this.data;
|
|
1394
|
+
q(this.dragHandle.current).draggable({
|
|
1395
|
+
modifiers: [q.modifiers.restrictRect({
|
|
1396
|
+
restriction: document.body,
|
|
1397
|
+
endOnly: !0
|
|
1398
|
+
})],
|
|
1399
|
+
cursorChecker: () => "move",
|
|
1400
|
+
listeners: {
|
|
1401
|
+
move: (i) => {
|
|
1402
|
+
n.x += i.dx, n.y += i.dy, this.setStyle();
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1405
|
+
}), q(this.containerRef.current).resizable({
|
|
1406
|
+
// 可拖拽的边缘
|
|
1407
|
+
edges: {
|
|
1408
|
+
top: !0,
|
|
1409
|
+
right: !0,
|
|
1410
|
+
bottom: !0,
|
|
1411
|
+
left: !0
|
|
1412
|
+
},
|
|
1413
|
+
margin: 6,
|
|
1414
|
+
modifiers: [
|
|
1415
|
+
// 保持在父对象内部
|
|
1416
|
+
q.modifiers.restrictEdges({
|
|
1417
|
+
outer: document.body
|
|
1418
|
+
}),
|
|
1419
|
+
// 缩放最小宽度
|
|
1420
|
+
q.modifiers.restrictSize({
|
|
1421
|
+
min: {
|
|
1422
|
+
width: n.minWidth,
|
|
1423
|
+
height: n.minHeight
|
|
1424
|
+
}
|
|
1425
|
+
})
|
|
1426
|
+
],
|
|
1427
|
+
inertia: !0,
|
|
1428
|
+
listeners: {
|
|
1429
|
+
move: (i) => {
|
|
1430
|
+
n.x += i.deltaRect.left, n.y += i.deltaRect.top, n.width = i.rect.width, n.height = i.rect.height, this.setStyle();
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
});
|
|
1434
|
+
}
|
|
1435
|
+
/**
|
|
1436
|
+
* 关闭聊天窗口
|
|
1437
|
+
*
|
|
1438
|
+
* @author chitanda
|
|
1439
|
+
* @date 2023-10-15 19:10:31
|
|
1440
|
+
*/
|
|
1441
|
+
close() {
|
|
1442
|
+
this.props.close();
|
|
1443
|
+
}
|
|
1444
|
+
render() {
|
|
1445
|
+
return h("div", {
|
|
1446
|
+
className: this.ns.b(),
|
|
1447
|
+
ref: this.containerRef,
|
|
1448
|
+
children: [h("div", {
|
|
1449
|
+
ref: this.dragHandle,
|
|
1450
|
+
className: this.ns.b("header"),
|
|
1451
|
+
children: [h("div", {
|
|
1452
|
+
className: this.ns.b("header-caption"),
|
|
1453
|
+
children: "AIChat"
|
|
1454
|
+
}), h("div", {
|
|
1455
|
+
className: this.ns.b("header-action-wrapper"),
|
|
1456
|
+
children: h("div", {
|
|
1457
|
+
className: "".concat(this.ns.be("header-action-wrapper", "action-item"), " ").concat(this.ns.be("header-action-wrapper", "action-close")),
|
|
1458
|
+
onClick: this.close.bind(this),
|
|
1459
|
+
children: h(Xt, {})
|
|
1460
|
+
})
|
|
1461
|
+
})]
|
|
1462
|
+
}), h("div", {
|
|
1463
|
+
className: this.ns.b("content"),
|
|
1464
|
+
children: h(on, {
|
|
1465
|
+
controller: this.props.controller
|
|
1466
|
+
})
|
|
1467
|
+
}), h("div", {
|
|
1468
|
+
className: this.ns.b("footer"),
|
|
1469
|
+
children: h(bn, {
|
|
1470
|
+
controller: this.props.controller
|
|
1471
|
+
})
|
|
1472
|
+
})]
|
|
1473
|
+
});
|
|
1474
|
+
}
|
|
1475
|
+
}
|
|
1476
|
+
class ke {
|
|
1477
|
+
constructor(e) {
|
|
1478
|
+
this.msg = e;
|
|
1479
|
+
}
|
|
1480
|
+
get messageid() {
|
|
1481
|
+
return this.msg.messageid;
|
|
1482
|
+
}
|
|
1483
|
+
get state() {
|
|
1484
|
+
return this.msg.state;
|
|
1485
|
+
}
|
|
1486
|
+
get role() {
|
|
1487
|
+
return this.msg.role;
|
|
1488
|
+
}
|
|
1489
|
+
get type() {
|
|
1490
|
+
return this.msg.type;
|
|
1491
|
+
}
|
|
1492
|
+
get content() {
|
|
1493
|
+
return this.msg.content;
|
|
1494
|
+
}
|
|
1495
|
+
get _origin() {
|
|
1496
|
+
return this.msg;
|
|
1497
|
+
}
|
|
1498
|
+
/**
|
|
1499
|
+
* 更新消息
|
|
1500
|
+
*
|
|
1501
|
+
* @author chitanda
|
|
1502
|
+
* @date 2023-10-10 17:10:07
|
|
1503
|
+
* @param {IChatMessage} msg
|
|
1504
|
+
*/
|
|
1505
|
+
update(e) {
|
|
1506
|
+
e.content || (e.content = ""), this.msg.content += e.content;
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
class $n {
|
|
1510
|
+
/**
|
|
1511
|
+
* Creates an instance of AiChatController.
|
|
1512
|
+
*
|
|
1513
|
+
* @author chitanda
|
|
1514
|
+
* @date 2023-10-15 19:10:34
|
|
1515
|
+
* @param {IChatOptions} opts 聊天配置
|
|
1516
|
+
*/
|
|
1517
|
+
constructor(e) {
|
|
1518
|
+
/**
|
|
1519
|
+
* 聊天记录
|
|
1520
|
+
*
|
|
1521
|
+
* @author chitanda
|
|
1522
|
+
* @date 2023-10-16 16:10:29
|
|
1523
|
+
* @type {Signal<ChatMessage[]>}
|
|
1524
|
+
*/
|
|
1525
|
+
A(this, "messages", ue([]));
|
|
1526
|
+
/**
|
|
1527
|
+
* 聊天框输入值
|
|
1528
|
+
*
|
|
1529
|
+
* @author chitanda
|
|
1530
|
+
* @date 2023-10-16 15:10:43
|
|
1531
|
+
* @type {Signal<string>}
|
|
1532
|
+
*/
|
|
1533
|
+
A(this, "input", ue(""));
|
|
1534
|
+
this.opts = e;
|
|
1535
|
+
}
|
|
1536
|
+
/**
|
|
1537
|
+
* 设置聊天框值
|
|
1538
|
+
*
|
|
1539
|
+
* @author chitanda
|
|
1540
|
+
* @date 2023-10-16 16:10:21
|
|
1541
|
+
* @param {string} input
|
|
1542
|
+
*/
|
|
1543
|
+
setInput(e) {
|
|
1544
|
+
this.input.value = e || "";
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* 新增聊天记录
|
|
1548
|
+
*
|
|
1549
|
+
* @author chitanda
|
|
1550
|
+
* @date 2023-10-09 15:10:15
|
|
1551
|
+
* @param {IMessage} data
|
|
1552
|
+
*/
|
|
1553
|
+
addMessage(e) {
|
|
1554
|
+
const n = this.messages.value.find((i) => i.messageid === e.messageid);
|
|
1555
|
+
n ? (n.update(e), this.messages.value = [...this.messages.value]) : this.messages.value = [...this.messages.value, new ke(e)];
|
|
1556
|
+
}
|
|
1557
|
+
/**
|
|
1558
|
+
* 替换已经存在的聊天消息
|
|
1559
|
+
*
|
|
1560
|
+
* @author chitanda
|
|
1561
|
+
* @date 2023-10-16 22:10:49
|
|
1562
|
+
* @param {IChatMessage} data
|
|
1563
|
+
*/
|
|
1564
|
+
replaceMessage(e) {
|
|
1565
|
+
const n = this.messages.value.findIndex((i) => i.messageid === e.messageid);
|
|
1566
|
+
n !== -1 ? (this.messages.value[n] = new ke(e), this.messages.value = [...this.messages.value]) : this.messages.value = [...this.messages.value, new ke(e)];
|
|
1567
|
+
}
|
|
1568
|
+
/**
|
|
1569
|
+
* 提问
|
|
1570
|
+
*
|
|
1571
|
+
* @author chitanda
|
|
1572
|
+
* @date 2023-10-09 20:10:43
|
|
1573
|
+
* @return {*} {Promise<void>}
|
|
1574
|
+
*/
|
|
1575
|
+
async question(e) {
|
|
1576
|
+
this.addMessage({
|
|
1577
|
+
state: 30,
|
|
1578
|
+
messageid: mt(),
|
|
1579
|
+
role: "USER",
|
|
1580
|
+
type: "DEFAULT",
|
|
1581
|
+
content: e
|
|
1582
|
+
}), await this.opts.question(this.messages.value.filter((n) => n.type !== "ERROR").map((n) => n._origin));
|
|
1583
|
+
}
|
|
1584
|
+
/**
|
|
1585
|
+
* 回填选中的消息
|
|
1586
|
+
*
|
|
1587
|
+
* @author chitanda
|
|
1588
|
+
* @date 2023-10-16 18:10:19
|
|
1589
|
+
* @param {IChatMessage} message
|
|
1590
|
+
*/
|
|
1591
|
+
backfill(e) {
|
|
1592
|
+
this.opts.action && this.opts.action("backfill", e);
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
class kn {
|
|
1596
|
+
constructor() {
|
|
1597
|
+
/**
|
|
1598
|
+
* 聊天框容器
|
|
1599
|
+
*
|
|
1600
|
+
* @author chitanda
|
|
1601
|
+
* @date 2023-10-13 17:10:03
|
|
1602
|
+
* @protected
|
|
1603
|
+
* @type {HTMLDivElement}
|
|
1604
|
+
*/
|
|
1605
|
+
A(this, "container");
|
|
1606
|
+
}
|
|
1607
|
+
/**
|
|
1608
|
+
* 创建聊天窗口(会同时显示出来)
|
|
1609
|
+
*
|
|
1610
|
+
* @author chitanda
|
|
1611
|
+
* @date 2023-10-13 17:10:22
|
|
1612
|
+
*/
|
|
1613
|
+
create(e) {
|
|
1614
|
+
this.container = document.createElement("div"), this.container.classList.add("ibiz-ai-chat"), document.body.appendChild(this.container);
|
|
1615
|
+
const n = new $n(e);
|
|
1616
|
+
return De(Z(wn, {
|
|
1617
|
+
controller: n,
|
|
1618
|
+
close: () => {
|
|
1619
|
+
this.close(), e.closed && e.closed();
|
|
1620
|
+
}
|
|
1621
|
+
}), this.container), n;
|
|
1622
|
+
}
|
|
1623
|
+
/**
|
|
1624
|
+
* 隐藏聊天窗口(必须先创建)
|
|
1625
|
+
*
|
|
1626
|
+
* @author chitanda
|
|
1627
|
+
* @date 2023-10-13 17:10:55
|
|
1628
|
+
*/
|
|
1629
|
+
hidden() {
|
|
1630
|
+
this.container && (this.container.style.display = "none");
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* 显示聊天窗窗口(必须先创建)
|
|
1634
|
+
*
|
|
1635
|
+
* @author chitanda
|
|
1636
|
+
* @date 2023-10-13 17:10:29
|
|
1637
|
+
*/
|
|
1638
|
+
show() {
|
|
1639
|
+
this.container && (this.container.style.display = "flex");
|
|
1640
|
+
}
|
|
1641
|
+
/**
|
|
1642
|
+
* 关闭聊天窗口
|
|
1643
|
+
*
|
|
1644
|
+
* @author chitanda
|
|
1645
|
+
* @date 2023-10-13 17:10:10
|
|
1646
|
+
*/
|
|
1647
|
+
close() {
|
|
1648
|
+
this.container && (De(null, this.container), this.container.remove(), this.container = void 0);
|
|
1649
|
+
}
|
|
1650
|
+
}
|
|
1651
|
+
const Cn = new kn();
|
|
1652
|
+
export {
|
|
1653
|
+
wn as ChatContainer,
|
|
1654
|
+
Cn as chat
|
|
1655
|
+
};
|