@d-id/client-sdk 0.0.1-beta.8
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 -0
- package/dist/package/index.js +2122 -0
- package/dist/package/style.css +1 -0
- package/package.json +82 -0
|
@@ -0,0 +1,2122 @@
|
|
|
1
|
+
var be, f, Mt, V, Ye, wt, xe, vt, _e = {}, yt = [], $t = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, Ne = Array.isArray;
|
|
2
|
+
function Y(e, t) {
|
|
3
|
+
for (var n in t)
|
|
4
|
+
e[n] = t[n];
|
|
5
|
+
return e;
|
|
6
|
+
}
|
|
7
|
+
function Ct(e) {
|
|
8
|
+
var t = e.parentNode;
|
|
9
|
+
t && t.removeChild(e);
|
|
10
|
+
}
|
|
11
|
+
function ze(e, t, n) {
|
|
12
|
+
var i, a, o, s = {};
|
|
13
|
+
for (o in t)
|
|
14
|
+
o == "key" ? i = t[o] : o == "ref" ? a = t[o] : s[o] = t[o];
|
|
15
|
+
if (arguments.length > 2 && (s.children = arguments.length > 3 ? be.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null)
|
|
16
|
+
for (o in e.defaultProps)
|
|
17
|
+
s[o] === void 0 && (s[o] = e.defaultProps[o]);
|
|
18
|
+
return Ie(e, s, i, a, null);
|
|
19
|
+
}
|
|
20
|
+
function Ie(e, t, n, i, a) {
|
|
21
|
+
var o = { type: e, props: t, key: n, ref: i, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: a ?? ++Mt, __i: -1, __u: 0 };
|
|
22
|
+
return a == null && f.vnode != null && f.vnode(o), o;
|
|
23
|
+
}
|
|
24
|
+
function Q(e) {
|
|
25
|
+
return e.children;
|
|
26
|
+
}
|
|
27
|
+
function B(e, t) {
|
|
28
|
+
this.props = e, this.context = t;
|
|
29
|
+
}
|
|
30
|
+
function ee(e, t) {
|
|
31
|
+
if (t == null)
|
|
32
|
+
return e.__ ? ee(e.__, e.__i + 1) : null;
|
|
33
|
+
for (var n; t < e.__k.length; t++)
|
|
34
|
+
if ((n = e.__k[t]) != null && n.__e != null)
|
|
35
|
+
return n.__e;
|
|
36
|
+
return typeof e.type == "function" ? ee(e) : null;
|
|
37
|
+
}
|
|
38
|
+
function At(e) {
|
|
39
|
+
var t, n;
|
|
40
|
+
if ((e = e.__) != null && e.__c != null) {
|
|
41
|
+
for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++)
|
|
42
|
+
if ((n = e.__k[t]) != null && n.__e != null) {
|
|
43
|
+
e.__e = e.__c.base = n.__e;
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
return At(e);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function Oe(e) {
|
|
50
|
+
(!e.__d && (e.__d = !0) && V.push(e) && !ye.__r++ || Ye !== f.debounceRendering) && ((Ye = f.debounceRendering) || wt)(ye);
|
|
51
|
+
}
|
|
52
|
+
function ye() {
|
|
53
|
+
var e, t, n, i, a, o, s, c, l;
|
|
54
|
+
for (V.sort(xe); e = V.shift(); )
|
|
55
|
+
e.__d && (t = V.length, i = void 0, o = (a = (n = e).__v).__e, c = [], l = [], (s = n.__P) && ((i = Y({}, a)).__v = a.__v + 1, f.vnode && f.vnode(i), Pe(s, i, a, n.__n, s.ownerSVGElement !== void 0, 32 & a.__u ? [o] : null, c, o ?? ee(a), !!(32 & a.__u), l), i.__.__k[i.__i] = i, Dt(c, i, l), i.__e != o && At(i)), V.length > t && V.sort(xe));
|
|
56
|
+
ye.__r = 0;
|
|
57
|
+
}
|
|
58
|
+
function bt(e, t, n, i, a, o, s, c, l, d, p) {
|
|
59
|
+
var r, _, u, m, I, M = i && i.__k || yt, h = t.length;
|
|
60
|
+
for (n.__d = l, Gt(n, t, M), l = n.__d, r = 0; r < h; r++)
|
|
61
|
+
(u = n.__k[r]) != null && typeof u != "boolean" && typeof u != "function" && (_ = u.__i === -1 ? _e : M[u.__i] || _e, u.__i = r, Pe(e, u, _, a, o, s, c, l, d, p), m = u.__e, u.ref && _.ref != u.ref && (_.ref && He(_.ref, null, u), p.push(u.ref, u.__c || m, u)), I == null && m != null && (I = m), 65536 & u.__u || _.__k === u.__k ? l = Nt(u, l, e) : typeof u.type == "function" && u.__d !== void 0 ? l = u.__d : m && (l = m.nextSibling), u.__d = void 0, u.__u &= -196609);
|
|
62
|
+
n.__d = l, n.__e = I;
|
|
63
|
+
}
|
|
64
|
+
function Gt(e, t, n) {
|
|
65
|
+
var i, a, o, s, c, l = t.length, d = n.length, p = d, r = 0;
|
|
66
|
+
for (e.__k = [], i = 0; i < l; i++)
|
|
67
|
+
(a = e.__k[i] = (a = t[i]) == null || typeof a == "boolean" || typeof a == "function" ? null : typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? Ie(null, a, null, null, a) : Ne(a) ? Ie(Q, { children: a }, null, null, null) : a.constructor === void 0 && a.__b > 0 ? Ie(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : a) != null ? (a.__ = e, a.__b = e.__b + 1, c = Yt(a, n, s = i + r, p), a.__i = c, o = null, c !== -1 && (p--, (o = n[c]) && (o.__u |= 131072)), o == null || o.__v === null ? (c == -1 && r--, typeof a.type != "function" && (a.__u |= 65536)) : c !== s && (c === s + 1 ? r++ : c > s ? p > l - s ? r += c - s : r-- : r = c < s && c == s - 1 ? c - s : 0, c !== i + r && (a.__u |= 65536))) : (o = n[i]) && o.key == null && o.__e && (o.__e == e.__d && (e.__d = ee(o)), Ee(o, o, !1), n[i] = null, p--);
|
|
68
|
+
if (p)
|
|
69
|
+
for (i = 0; i < d; i++)
|
|
70
|
+
(o = n[i]) != null && !(131072 & o.__u) && (o.__e == e.__d && (e.__d = ee(o)), Ee(o, o));
|
|
71
|
+
}
|
|
72
|
+
function Nt(e, t, n) {
|
|
73
|
+
var i, a;
|
|
74
|
+
if (typeof e.type == "function") {
|
|
75
|
+
for (i = e.__k, a = 0; i && a < i.length; a++)
|
|
76
|
+
i[a] && (i[a].__ = e, t = Nt(i[a], t, n));
|
|
77
|
+
return t;
|
|
78
|
+
}
|
|
79
|
+
return e.__e != t && (n.insertBefore(e.__e, t || null), t = e.__e), t && t.nextSibling;
|
|
80
|
+
}
|
|
81
|
+
function Ce(e, t) {
|
|
82
|
+
return t = t || [], e == null || typeof e == "boolean" || (Ne(e) ? e.some(function(n) {
|
|
83
|
+
Ce(n, t);
|
|
84
|
+
}) : t.push(e)), t;
|
|
85
|
+
}
|
|
86
|
+
function Yt(e, t, n, i) {
|
|
87
|
+
var a = e.key, o = e.type, s = n - 1, c = n + 1, l = t[n];
|
|
88
|
+
if (l === null || l && a == l.key && o === l.type)
|
|
89
|
+
return n;
|
|
90
|
+
if (i > (l != null && !(131072 & l.__u) ? 1 : 0))
|
|
91
|
+
for (; s >= 0 || c < t.length; ) {
|
|
92
|
+
if (s >= 0) {
|
|
93
|
+
if ((l = t[s]) && !(131072 & l.__u) && a == l.key && o === l.type)
|
|
94
|
+
return s;
|
|
95
|
+
s--;
|
|
96
|
+
}
|
|
97
|
+
if (c < t.length) {
|
|
98
|
+
if ((l = t[c]) && !(131072 & l.__u) && a == l.key && o === l.type)
|
|
99
|
+
return c;
|
|
100
|
+
c++;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return -1;
|
|
104
|
+
}
|
|
105
|
+
function Fe(e, t, n) {
|
|
106
|
+
t[0] === "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || $t.test(t) ? n : n + "px";
|
|
107
|
+
}
|
|
108
|
+
function fe(e, t, n, i, a) {
|
|
109
|
+
var o;
|
|
110
|
+
e:
|
|
111
|
+
if (t === "style")
|
|
112
|
+
if (typeof n == "string")
|
|
113
|
+
e.style.cssText = n;
|
|
114
|
+
else {
|
|
115
|
+
if (typeof i == "string" && (e.style.cssText = i = ""), i)
|
|
116
|
+
for (t in i)
|
|
117
|
+
n && t in n || Fe(e.style, t, "");
|
|
118
|
+
if (n)
|
|
119
|
+
for (t in n)
|
|
120
|
+
i && n[t] === i[t] || Fe(e.style, t, n[t]);
|
|
121
|
+
}
|
|
122
|
+
else if (t[0] === "o" && t[1] === "n")
|
|
123
|
+
o = t !== (t = t.replace(/(PointerCapture)$|Capture$/, "$1")), t = t.toLowerCase() in e ? t.toLowerCase().slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + o] = n, n ? i ? n.u = i.u : (n.u = Date.now(), e.addEventListener(t, o ? Ve : Je, o)) : e.removeEventListener(t, o ? Ve : Je, o);
|
|
124
|
+
else {
|
|
125
|
+
if (a)
|
|
126
|
+
t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
127
|
+
else if (t !== "width" && t !== "height" && t !== "href" && t !== "list" && t !== "form" && t !== "tabIndex" && t !== "download" && t !== "rowSpan" && t !== "colSpan" && t !== "role" && t in e)
|
|
128
|
+
try {
|
|
129
|
+
e[t] = n ?? "";
|
|
130
|
+
break e;
|
|
131
|
+
} catch {
|
|
132
|
+
}
|
|
133
|
+
typeof n == "function" || (n == null || n === !1 && t[4] !== "-" ? e.removeAttribute(t) : e.setAttribute(t, n));
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function Je(e) {
|
|
137
|
+
var t = this.l[e.type + !1];
|
|
138
|
+
if (e.t) {
|
|
139
|
+
if (e.t <= t.u)
|
|
140
|
+
return;
|
|
141
|
+
} else
|
|
142
|
+
e.t = Date.now();
|
|
143
|
+
return t(f.event ? f.event(e) : e);
|
|
144
|
+
}
|
|
145
|
+
function Ve(e) {
|
|
146
|
+
return this.l[e.type + !0](f.event ? f.event(e) : e);
|
|
147
|
+
}
|
|
148
|
+
function Pe(e, t, n, i, a, o, s, c, l, d) {
|
|
149
|
+
var p, r, _, u, m, I, M, h, w, A, T, v, x, z, O, S = t.type;
|
|
150
|
+
if (t.constructor !== void 0)
|
|
151
|
+
return null;
|
|
152
|
+
128 & n.__u && (l = !!(32 & n.__u), o = [c = t.__e = n.__e]), (p = f.__b) && p(t);
|
|
153
|
+
e:
|
|
154
|
+
if (typeof S == "function")
|
|
155
|
+
try {
|
|
156
|
+
if (h = t.props, w = (p = S.contextType) && i[p.__c], A = p ? w ? w.props.value : p.__ : i, n.__c ? M = (r = t.__c = n.__c).__ = r.__E : ("prototype" in S && S.prototype.render ? t.__c = r = new S(h, A) : (t.__c = r = new B(h, A), r.constructor = S, r.render = Jt), w && w.sub(r), r.props = h, r.state || (r.state = {}), r.context = A, r.__n = i, _ = r.__d = !0, r.__h = [], r._sb = []), r.__s == null && (r.__s = r.state), S.getDerivedStateFromProps != null && (r.__s == r.state && (r.__s = Y({}, r.__s)), Y(r.__s, S.getDerivedStateFromProps(h, r.__s))), u = r.props, m = r.state, r.__v = t, _)
|
|
157
|
+
S.getDerivedStateFromProps == null && r.componentWillMount != null && r.componentWillMount(), r.componentDidMount != null && r.__h.push(r.componentDidMount);
|
|
158
|
+
else {
|
|
159
|
+
if (S.getDerivedStateFromProps == null && h !== u && r.componentWillReceiveProps != null && r.componentWillReceiveProps(h, A), !r.__e && (r.shouldComponentUpdate != null && r.shouldComponentUpdate(h, r.__s, A) === !1 || t.__v === n.__v)) {
|
|
160
|
+
for (t.__v !== n.__v && (r.props = h, r.state = r.__s, r.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.forEach(function(k) {
|
|
161
|
+
k && (k.__ = t);
|
|
162
|
+
}), T = 0; T < r._sb.length; T++)
|
|
163
|
+
r.__h.push(r._sb[T]);
|
|
164
|
+
r._sb = [], r.__h.length && s.push(r);
|
|
165
|
+
break e;
|
|
166
|
+
}
|
|
167
|
+
r.componentWillUpdate != null && r.componentWillUpdate(h, r.__s, A), r.componentDidUpdate != null && r.__h.push(function() {
|
|
168
|
+
r.componentDidUpdate(u, m, I);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
if (r.context = A, r.props = h, r.__P = e, r.__e = !1, v = f.__r, x = 0, "prototype" in S && S.prototype.render) {
|
|
172
|
+
for (r.state = r.__s, r.__d = !1, v && v(t), p = r.render(r.props, r.state, r.context), z = 0; z < r._sb.length; z++)
|
|
173
|
+
r.__h.push(r._sb[z]);
|
|
174
|
+
r._sb = [];
|
|
175
|
+
} else
|
|
176
|
+
do
|
|
177
|
+
r.__d = !1, v && v(t), p = r.render(r.props, r.state, r.context), r.state = r.__s;
|
|
178
|
+
while (r.__d && ++x < 25);
|
|
179
|
+
r.state = r.__s, r.getChildContext != null && (i = Y(Y({}, i), r.getChildContext())), _ || r.getSnapshotBeforeUpdate == null || (I = r.getSnapshotBeforeUpdate(u, m)), bt(e, Ne(O = p != null && p.type === Q && p.key == null ? p.props.children : p) ? O : [O], t, n, i, a, o, s, c, l, d), r.base = t.__e, t.__u &= -161, r.__h.length && s.push(r), M && (r.__E = r.__ = null);
|
|
180
|
+
} catch (k) {
|
|
181
|
+
t.__v = null, l || o != null ? (t.__e = c, t.__u |= l ? 160 : 32, o[o.indexOf(c)] = null) : (t.__e = n.__e, t.__k = n.__k), f.__e(k, t, n);
|
|
182
|
+
}
|
|
183
|
+
else
|
|
184
|
+
o == null && t.__v === n.__v ? (t.__k = n.__k, t.__e = n.__e) : t.__e = Ft(n.__e, t, n, i, a, o, s, l, d);
|
|
185
|
+
(p = f.diffed) && p(t);
|
|
186
|
+
}
|
|
187
|
+
function Dt(e, t, n) {
|
|
188
|
+
t.__d = void 0;
|
|
189
|
+
for (var i = 0; i < n.length; i++)
|
|
190
|
+
He(n[i], n[++i], n[++i]);
|
|
191
|
+
f.__c && f.__c(t, e), e.some(function(a) {
|
|
192
|
+
try {
|
|
193
|
+
e = a.__h, a.__h = [], e.some(function(o) {
|
|
194
|
+
o.call(a);
|
|
195
|
+
});
|
|
196
|
+
} catch (o) {
|
|
197
|
+
f.__e(o, a.__v);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
function Ft(e, t, n, i, a, o, s, c, l) {
|
|
202
|
+
var d, p, r, _, u, m, I, M = n.props, h = t.props, w = t.type;
|
|
203
|
+
if (w === "svg" && (a = !0), o != null) {
|
|
204
|
+
for (d = 0; d < o.length; d++)
|
|
205
|
+
if ((u = o[d]) && "setAttribute" in u == !!w && (w ? u.localName === w : u.nodeType === 3)) {
|
|
206
|
+
e = u, o[d] = null;
|
|
207
|
+
break;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
if (e == null) {
|
|
211
|
+
if (w === null)
|
|
212
|
+
return document.createTextNode(h);
|
|
213
|
+
e = a ? document.createElementNS("http://www.w3.org/2000/svg", w) : document.createElement(w, h.is && h), o = null, c = !1;
|
|
214
|
+
}
|
|
215
|
+
if (w === null)
|
|
216
|
+
M === h || c && e.data === h || (e.data = h);
|
|
217
|
+
else {
|
|
218
|
+
if (o = o && be.call(e.childNodes), M = n.props || _e, !c && o != null)
|
|
219
|
+
for (M = {}, d = 0; d < e.attributes.length; d++)
|
|
220
|
+
M[(u = e.attributes[d]).name] = u.value;
|
|
221
|
+
for (d in M)
|
|
222
|
+
u = M[d], d == "children" || (d == "dangerouslySetInnerHTML" ? r = u : d === "key" || d in h || fe(e, d, null, u, a));
|
|
223
|
+
for (d in h)
|
|
224
|
+
u = h[d], d == "children" ? _ = u : d == "dangerouslySetInnerHTML" ? p = u : d == "value" ? m = u : d == "checked" ? I = u : d === "key" || c && typeof u != "function" || M[d] === u || fe(e, d, u, M[d], a);
|
|
225
|
+
if (p)
|
|
226
|
+
c || r && (p.__html === r.__html || p.__html === e.innerHTML) || (e.innerHTML = p.__html), t.__k = [];
|
|
227
|
+
else if (r && (e.innerHTML = ""), bt(e, Ne(_) ? _ : [_], t, n, i, a && w !== "foreignObject", o, s, o ? o[0] : n.__k && ee(n, 0), c, l), o != null)
|
|
228
|
+
for (d = o.length; d--; )
|
|
229
|
+
o[d] != null && Ct(o[d]);
|
|
230
|
+
c || (d = "value", m !== void 0 && (m !== e[d] || w === "progress" && !m || w === "option" && m !== M[d]) && fe(e, d, m, M[d], !1), d = "checked", I !== void 0 && I !== e[d] && fe(e, d, I, M[d], !1));
|
|
231
|
+
}
|
|
232
|
+
return e;
|
|
233
|
+
}
|
|
234
|
+
function He(e, t, n) {
|
|
235
|
+
try {
|
|
236
|
+
typeof e == "function" ? e(t) : e.current = t;
|
|
237
|
+
} catch (i) {
|
|
238
|
+
f.__e(i, n);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function Ee(e, t, n) {
|
|
242
|
+
var i, a;
|
|
243
|
+
if (f.unmount && f.unmount(e), (i = e.ref) && (i.current && i.current !== e.__e || He(i, null, t)), (i = e.__c) != null) {
|
|
244
|
+
if (i.componentWillUnmount)
|
|
245
|
+
try {
|
|
246
|
+
i.componentWillUnmount();
|
|
247
|
+
} catch (o) {
|
|
248
|
+
f.__e(o, t);
|
|
249
|
+
}
|
|
250
|
+
i.base = i.__P = null, e.__c = void 0;
|
|
251
|
+
}
|
|
252
|
+
if (i = e.__k)
|
|
253
|
+
for (a = 0; a < i.length; a++)
|
|
254
|
+
i[a] && Ee(i[a], t, n || typeof e.type != "function");
|
|
255
|
+
n || e.__e == null || Ct(e.__e), e.__ = e.__e = e.__d = void 0;
|
|
256
|
+
}
|
|
257
|
+
function Jt(e, t, n) {
|
|
258
|
+
return this.constructor(e, n);
|
|
259
|
+
}
|
|
260
|
+
function Vt(e, t, n) {
|
|
261
|
+
var i, a, o, s;
|
|
262
|
+
f.__ && f.__(e, t), a = (i = typeof n == "function") ? null : n && n.__k || t.__k, o = [], s = [], Pe(t, e = (!i && n || t).__k = ze(Q, null, [e]), a || _e, _e, t.ownerSVGElement !== void 0, !i && n ? [n] : a ? null : t.firstChild ? be.call(t.childNodes) : null, o, !i && n ? n : a ? a.__e : t.firstChild, i, s), Dt(o, e, s);
|
|
263
|
+
}
|
|
264
|
+
function Lt(e, t) {
|
|
265
|
+
var n = { __c: t = "__cC" + vt++, __: e, Consumer: function(i, a) {
|
|
266
|
+
return i.children(a);
|
|
267
|
+
}, Provider: function(i) {
|
|
268
|
+
var a, o;
|
|
269
|
+
return this.getChildContext || (a = [], (o = {})[t] = this, this.getChildContext = function() {
|
|
270
|
+
return o;
|
|
271
|
+
}, this.shouldComponentUpdate = function(s) {
|
|
272
|
+
this.props.value !== s.value && a.some(function(c) {
|
|
273
|
+
c.__e = !0, Oe(c);
|
|
274
|
+
});
|
|
275
|
+
}, this.sub = function(s) {
|
|
276
|
+
a.push(s);
|
|
277
|
+
var c = s.componentWillUnmount;
|
|
278
|
+
s.componentWillUnmount = function() {
|
|
279
|
+
a.splice(a.indexOf(s), 1), c && c.call(s);
|
|
280
|
+
};
|
|
281
|
+
}), i.children;
|
|
282
|
+
} };
|
|
283
|
+
return n.Provider.__ = n.Consumer.contextType = n;
|
|
284
|
+
}
|
|
285
|
+
be = yt.slice, f = { __e: function(e, t, n, i) {
|
|
286
|
+
for (var a, o, s; t = t.__; )
|
|
287
|
+
if ((a = t.__c) && !a.__)
|
|
288
|
+
try {
|
|
289
|
+
if ((o = a.constructor) && o.getDerivedStateFromError != null && (a.setState(o.getDerivedStateFromError(e)), s = a.__d), a.componentDidCatch != null && (a.componentDidCatch(e, i || {}), s = a.__d), s)
|
|
290
|
+
return a.__E = a;
|
|
291
|
+
} catch (c) {
|
|
292
|
+
e = c;
|
|
293
|
+
}
|
|
294
|
+
throw e;
|
|
295
|
+
} }, Mt = 0, B.prototype.setState = function(e, t) {
|
|
296
|
+
var n;
|
|
297
|
+
n = this.__s != null && this.__s !== this.state ? this.__s : this.__s = Y({}, this.state), typeof e == "function" && (e = e(Y({}, n), this.props)), e && Y(n, e), e != null && this.__v && (t && this._sb.push(t), Oe(this));
|
|
298
|
+
}, B.prototype.forceUpdate = function(e) {
|
|
299
|
+
this.__v && (this.__e = !0, e && this.__h.push(e), Oe(this));
|
|
300
|
+
}, B.prototype.render = Q, V = [], wt = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, xe = function(e, t) {
|
|
301
|
+
return e.__v.__b - t.__v.__b;
|
|
302
|
+
}, ye.__r = 0, vt = 0;
|
|
303
|
+
const Qt = "https://api.d-id.com", Xt = "wss://notifications.d-id.com", Qe = "100", Ze = {
|
|
304
|
+
mixpanelKey: "79f81a83a67430be2bc0fd61042b8faa"
|
|
305
|
+
};
|
|
306
|
+
var N = /* @__PURE__ */ ((e) => (e[e.New = 0] = "New", e[e.Fail = 1] = "Fail", e[e.Connected = 2] = "Connected", e[e.Connecting = 3] = "Connecting", e[e.Terminating = 4] = "Terminating", e))(N || {}), L = /* @__PURE__ */ ((e) => (e[e.New = 0] = "New", e[e.Loading = 1] = "Loading", e[e.Buffering = 2] = "Buffering", e[e.Start = 3] = "Start", e[e.Fail = 4] = "Fail", e))(L || {});
|
|
307
|
+
window.appLogs = {};
|
|
308
|
+
const Xe = (e) => {
|
|
309
|
+
try {
|
|
310
|
+
if (Object.keys(e ?? {}).length === 0)
|
|
311
|
+
return;
|
|
312
|
+
window.appLogs = {
|
|
313
|
+
...window.appLogs,
|
|
314
|
+
...e
|
|
315
|
+
};
|
|
316
|
+
} catch (t) {
|
|
317
|
+
console.warn(t);
|
|
318
|
+
}
|
|
319
|
+
}, ne = "https://api.d-id.com", Kt = "wss://notifications.d-id.com";
|
|
320
|
+
function Tt(e) {
|
|
321
|
+
if (e.type === "bearer")
|
|
322
|
+
return `Bearer ${e.token}`;
|
|
323
|
+
if (e.type === "basic")
|
|
324
|
+
return `Basic ${btoa(`${e.username}:${e.password}`)}`;
|
|
325
|
+
if (e.type === "key")
|
|
326
|
+
return `Client-Key ${e.clientKey}`;
|
|
327
|
+
throw new Error(`Unknown auth type: ${e}`);
|
|
328
|
+
}
|
|
329
|
+
function ie(e, t = ne) {
|
|
330
|
+
const n = async (i, a) => {
|
|
331
|
+
const o = await fetch(t + (i != null && i.startsWith("/") ? i : `/${i}`), {
|
|
332
|
+
...a,
|
|
333
|
+
headers: {
|
|
334
|
+
...a == null ? void 0 : a.headers,
|
|
335
|
+
Authorization: Tt(e),
|
|
336
|
+
"Content-Type": "application/json"
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
if (!o.ok) {
|
|
340
|
+
let s = await o.text().catch(() => "Failed to fetch");
|
|
341
|
+
throw new Error(s);
|
|
342
|
+
}
|
|
343
|
+
return o.json();
|
|
344
|
+
};
|
|
345
|
+
return {
|
|
346
|
+
get(i, a) {
|
|
347
|
+
return n(i, {
|
|
348
|
+
...a,
|
|
349
|
+
method: "GET"
|
|
350
|
+
});
|
|
351
|
+
},
|
|
352
|
+
post(i, a, o) {
|
|
353
|
+
return n(i, {
|
|
354
|
+
...o,
|
|
355
|
+
body: JSON.stringify(a),
|
|
356
|
+
method: "POST"
|
|
357
|
+
});
|
|
358
|
+
},
|
|
359
|
+
delete(i, a, o) {
|
|
360
|
+
return n(i, {
|
|
361
|
+
...o,
|
|
362
|
+
body: JSON.stringify(a),
|
|
363
|
+
method: "DELETE"
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
patch(i, a, o) {
|
|
367
|
+
return n(i, {
|
|
368
|
+
...o,
|
|
369
|
+
body: JSON.stringify(a),
|
|
370
|
+
method: "PATCH"
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
function qt(e, t = ne) {
|
|
376
|
+
const n = ie(e, `${t}/agents`);
|
|
377
|
+
return {
|
|
378
|
+
create(i, a) {
|
|
379
|
+
return n.post("/", i, a);
|
|
380
|
+
},
|
|
381
|
+
getAgents(i, a) {
|
|
382
|
+
return n.get(`/${i ? `?tag=${i}` : ""}`, a).then((o) => o ?? []);
|
|
383
|
+
},
|
|
384
|
+
getById(i, a) {
|
|
385
|
+
return n.get(`/${i}`, a);
|
|
386
|
+
},
|
|
387
|
+
delete(i, a) {
|
|
388
|
+
return n.delete(`/${i}`, void 0, a);
|
|
389
|
+
},
|
|
390
|
+
update(i, a, o) {
|
|
391
|
+
return n.patch(`/${i}`, a, o);
|
|
392
|
+
},
|
|
393
|
+
newChat(i, a) {
|
|
394
|
+
return n.post(`/${i}/chat`, void 0, a);
|
|
395
|
+
},
|
|
396
|
+
chat(i, a, o, s) {
|
|
397
|
+
return n.post(`/${i}/chat/${a}`, o, s);
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
function en(e, t = ne) {
|
|
402
|
+
const n = ie(e, `${t}/knowledge`);
|
|
403
|
+
return {
|
|
404
|
+
createKnowledge(i, a) {
|
|
405
|
+
return n.post("/", i, a);
|
|
406
|
+
},
|
|
407
|
+
getKnowledgeBase(i) {
|
|
408
|
+
return n.get("/", i);
|
|
409
|
+
},
|
|
410
|
+
getKnowledge(i, a) {
|
|
411
|
+
return n.get(`/${i}`, a);
|
|
412
|
+
},
|
|
413
|
+
deleteKnowledge(i, a) {
|
|
414
|
+
return n.delete(`/${i}`, void 0, a);
|
|
415
|
+
},
|
|
416
|
+
createDocument(i, a, o) {
|
|
417
|
+
return n.post(`/${i}/documents`, a, o);
|
|
418
|
+
},
|
|
419
|
+
deleteDocument(i, a, o) {
|
|
420
|
+
return n.delete(`/${i}/documents/${a}`, void 0, o);
|
|
421
|
+
},
|
|
422
|
+
getDocuments(i, a) {
|
|
423
|
+
return n.get(`/${i}/documents`, a);
|
|
424
|
+
},
|
|
425
|
+
getDocument(i, a, o) {
|
|
426
|
+
return n.get(`/${i}/documents/${a}`, o);
|
|
427
|
+
},
|
|
428
|
+
getRecords(i, a, o) {
|
|
429
|
+
return n.get(`/${i}/documents/${a}/records`, o);
|
|
430
|
+
},
|
|
431
|
+
query(i, a, o) {
|
|
432
|
+
return n.post(`/${i}/query`, {
|
|
433
|
+
query: a
|
|
434
|
+
}, o);
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function tn(e, t = ne) {
|
|
439
|
+
const n = ie(e, `${t}/chats/ratings`);
|
|
440
|
+
return {
|
|
441
|
+
create(i, a) {
|
|
442
|
+
return n.post("/", i, a);
|
|
443
|
+
},
|
|
444
|
+
getByKnowledge(i, a) {
|
|
445
|
+
return n.get(`/${i}`, a).then((o) => o ?? []);
|
|
446
|
+
},
|
|
447
|
+
update(i, a, o) {
|
|
448
|
+
return n.patch(`/${i}`, a, o);
|
|
449
|
+
},
|
|
450
|
+
delete(i, a) {
|
|
451
|
+
return n.delete(`/${i}`, a);
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
const nn = (e) => new Promise((t) => setTimeout(t, e));
|
|
456
|
+
function an(e) {
|
|
457
|
+
return new Promise((t, n) => {
|
|
458
|
+
const {
|
|
459
|
+
callbacks: i,
|
|
460
|
+
host: a,
|
|
461
|
+
auth: o
|
|
462
|
+
} = e, {
|
|
463
|
+
onMessage: s = null,
|
|
464
|
+
onOpen: c = null,
|
|
465
|
+
onClose: l = null,
|
|
466
|
+
onError: d = null
|
|
467
|
+
} = i || {}, p = new WebSocket(`${a}?authorization=${Tt(o)}`);
|
|
468
|
+
p.onmessage = s, p.onclose = l, p.onerror = (r) => {
|
|
469
|
+
console.log(r), d == null || d(r), n(r);
|
|
470
|
+
}, p.onopen = (r) => {
|
|
471
|
+
c == null || c(r), t(p);
|
|
472
|
+
};
|
|
473
|
+
});
|
|
474
|
+
}
|
|
475
|
+
async function on(e) {
|
|
476
|
+
const {
|
|
477
|
+
retries: t = 1
|
|
478
|
+
} = e;
|
|
479
|
+
let n = null;
|
|
480
|
+
for (let i = 0; (n == null ? void 0 : n.readyState) !== WebSocket.OPEN; i++)
|
|
481
|
+
try {
|
|
482
|
+
n = await an(e);
|
|
483
|
+
} catch (a) {
|
|
484
|
+
if (i === t)
|
|
485
|
+
throw a;
|
|
486
|
+
await nn(i * 500);
|
|
487
|
+
}
|
|
488
|
+
return n;
|
|
489
|
+
}
|
|
490
|
+
async function rn(e, t, n) {
|
|
491
|
+
const i = n ? [n] : [], a = await on({
|
|
492
|
+
auth: e,
|
|
493
|
+
host: t,
|
|
494
|
+
callbacks: {
|
|
495
|
+
onMessage: (o) => {
|
|
496
|
+
const s = JSON.parse(o.data);
|
|
497
|
+
i.forEach((c) => c(s.event, s));
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
return {
|
|
502
|
+
socket: a,
|
|
503
|
+
terminate: () => a.close(),
|
|
504
|
+
subscribeToEvents: (o) => i.push(o)
|
|
505
|
+
};
|
|
506
|
+
}
|
|
507
|
+
var Me = /* @__PURE__ */ ((e) => (e.Start = "START", e.Stop = "STOP", e))(Me || {}), Ae = /* @__PURE__ */ ((e) => (e.ChatAnswer = "chat/answer", e.ChatPartial = "chat/partial", e.StreamDone = "stream/done", e.StreamStarted = "stream/started", e))(Ae || {}), Z = /* @__PURE__ */ ((e) => (e.Unrated = "Unrated", e.Positive = "Positive", e.Negative = "Negative", e))(Z || {}), E = /* @__PURE__ */ ((e) => (e.Functional = "Functional", e.TextOnly = "TextOnly", e.Maintainance = "Maintainance", e))(E || {}), le = /* @__PURE__ */ ((e) => (e.Embed = "embed", e.Query = "query", e.Partial = "partial", e.Answer = "answer", e.Complete = "done", e))(le || {}), se = /* @__PURE__ */ ((e) => (e.Clip = "clip", e.Talk = "talk", e))(se || {});
|
|
508
|
+
function cn(e) {
|
|
509
|
+
return e.presenter.type === se.Clip ? {
|
|
510
|
+
videoType: se.Clip,
|
|
511
|
+
driver_id: e.presenter.driver_id,
|
|
512
|
+
presenter_id: e.presenter.presenter_id
|
|
513
|
+
} : {
|
|
514
|
+
videoType: se.Talk,
|
|
515
|
+
source_url: e.presenter.source_url
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
function Ke(e, t, n, i) {
|
|
519
|
+
return new Promise(async (a, o) => {
|
|
520
|
+
const s = await gn(cn(e), {
|
|
521
|
+
...t,
|
|
522
|
+
callbacks: {
|
|
523
|
+
...t.callbacks,
|
|
524
|
+
onConnectionStateChange: async (c) => {
|
|
525
|
+
var l, d;
|
|
526
|
+
c === "connected" ? (i || (i = await n.newChat(e.id)), a({
|
|
527
|
+
chat: i,
|
|
528
|
+
streamingManager: s
|
|
529
|
+
})) : c === "failed" && o(new Error("Cannot create connection")), (d = (l = t.callbacks).onConnectionStateChange) == null || d.call(l, c);
|
|
530
|
+
},
|
|
531
|
+
// TODO remove when webscoket will return partial
|
|
532
|
+
onMessage: (c, l) => {
|
|
533
|
+
var d, p;
|
|
534
|
+
c === Ae.ChatPartial && ((p = (d = t.callbacks).onChatEvents) == null || p.call(d, le.Partial, {
|
|
535
|
+
content: l,
|
|
536
|
+
event: le.Partial
|
|
537
|
+
}));
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
async function sn(e, t) {
|
|
544
|
+
const n = t.baseURL || ne, i = t.wsURL || Kt, a = new AbortController(), o = qt(t.auth, n), s = tn(t.auth, n), c = en(t.auth, n), l = await o.getById(e), d = await rn(t.auth, i, t.callbacks.onChatEvents);
|
|
545
|
+
let {
|
|
546
|
+
chat: p,
|
|
547
|
+
streamingManager: r
|
|
548
|
+
} = await Ke(l, t, o);
|
|
549
|
+
return {
|
|
550
|
+
agent: l,
|
|
551
|
+
async reconnectToChat() {
|
|
552
|
+
const {
|
|
553
|
+
streamingManager: _
|
|
554
|
+
} = await Ke(l, t, o, p);
|
|
555
|
+
r = _;
|
|
556
|
+
},
|
|
557
|
+
terminate() {
|
|
558
|
+
return a.abort(), d.terminate(), r.terminate();
|
|
559
|
+
},
|
|
560
|
+
chatId: p.id,
|
|
561
|
+
chat(_) {
|
|
562
|
+
return o.chat(e, p.id, {
|
|
563
|
+
sessionId: r.sessionId,
|
|
564
|
+
streamId: r.streamId,
|
|
565
|
+
messages: _
|
|
566
|
+
}, {
|
|
567
|
+
signal: a.signal
|
|
568
|
+
});
|
|
569
|
+
},
|
|
570
|
+
rate(_, u) {
|
|
571
|
+
return u ? s.update(u, _) : s.create(_);
|
|
572
|
+
},
|
|
573
|
+
deleteRate(_) {
|
|
574
|
+
return s.delete(_);
|
|
575
|
+
},
|
|
576
|
+
speak(_) {
|
|
577
|
+
let u;
|
|
578
|
+
return _.type === "text" ? u = {
|
|
579
|
+
script: {
|
|
580
|
+
type: "text",
|
|
581
|
+
provider: _.provider,
|
|
582
|
+
input: _.input,
|
|
583
|
+
ssml: _.ssml || !1
|
|
584
|
+
}
|
|
585
|
+
} : _.type === "audio" && (u = {
|
|
586
|
+
script: {
|
|
587
|
+
type: "audio",
|
|
588
|
+
audio_url: _.audio_url
|
|
589
|
+
}
|
|
590
|
+
}), r.speak(u);
|
|
591
|
+
},
|
|
592
|
+
getStarterMessages() {
|
|
593
|
+
var _, u;
|
|
594
|
+
return (_ = l.knowledge) != null && _.id ? c.getKnowledge((u = l.knowledge) == null ? void 0 : u.id).then((m) => (m == null ? void 0 : m.starter_message) || []) : Promise.resolve([]);
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function _n(e, t) {
|
|
599
|
+
const n = ie(e, t);
|
|
600
|
+
return {
|
|
601
|
+
createStream(i) {
|
|
602
|
+
return n.post("/clips/streams", {
|
|
603
|
+
driver_id: i.driver_id,
|
|
604
|
+
presenter_id: i.presenter_id,
|
|
605
|
+
compatibility_mode: i.compatibility_mode
|
|
606
|
+
});
|
|
607
|
+
},
|
|
608
|
+
startConnection(i, a, o) {
|
|
609
|
+
return n.post(`/clips/streams/${i}/sdp`, {
|
|
610
|
+
session_id: o,
|
|
611
|
+
answer: a
|
|
612
|
+
});
|
|
613
|
+
},
|
|
614
|
+
addIceCandidate(i, a, o) {
|
|
615
|
+
return n.post(`/clips/streams/${i}/ice`, {
|
|
616
|
+
session_id: o,
|
|
617
|
+
...a
|
|
618
|
+
});
|
|
619
|
+
},
|
|
620
|
+
sendStreamRequest(i, a, o) {
|
|
621
|
+
return n.post(`/clips/streams/${i}`, {
|
|
622
|
+
session_id: a,
|
|
623
|
+
...o
|
|
624
|
+
});
|
|
625
|
+
},
|
|
626
|
+
close(i, a) {
|
|
627
|
+
return n.delete(`/clips/streams/${i}`, {
|
|
628
|
+
session_id: a
|
|
629
|
+
});
|
|
630
|
+
}
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
function ln(e, t) {
|
|
634
|
+
const n = ie(e, t);
|
|
635
|
+
return {
|
|
636
|
+
createStream(i, a) {
|
|
637
|
+
return n.post("/talks/streams", {
|
|
638
|
+
source_url: i.source_url,
|
|
639
|
+
driver_url: i.driver_url,
|
|
640
|
+
face: i.face,
|
|
641
|
+
config: i.config
|
|
642
|
+
}, a);
|
|
643
|
+
},
|
|
644
|
+
startConnection(i, a, o, s) {
|
|
645
|
+
return n.post(`/talks/streams/${i}/sdp`, {
|
|
646
|
+
session_id: o,
|
|
647
|
+
answer: a
|
|
648
|
+
}, s);
|
|
649
|
+
},
|
|
650
|
+
addIceCandidate(i, a, o, s) {
|
|
651
|
+
return n.post(`/talks/streams/${i}/ice`, {
|
|
652
|
+
session_id: o,
|
|
653
|
+
...a
|
|
654
|
+
}, s);
|
|
655
|
+
},
|
|
656
|
+
sendStreamRequest(i, a, o, s) {
|
|
657
|
+
return n.post(`/talks/streams/${i}`, {
|
|
658
|
+
session_id: a,
|
|
659
|
+
...o
|
|
660
|
+
}, s);
|
|
661
|
+
},
|
|
662
|
+
close(i, a, o) {
|
|
663
|
+
return n.delete(`/talks/streams/${i}`, {
|
|
664
|
+
session_id: a
|
|
665
|
+
}, o);
|
|
666
|
+
}
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function dn(e, t) {
|
|
670
|
+
return e.map((n, i) => i === 0 ? t ? {
|
|
671
|
+
index: i,
|
|
672
|
+
timestamp: n.timestamp,
|
|
673
|
+
bytesReceived: n.bytesReceived - t.bytesReceived,
|
|
674
|
+
packetsReceived: n.packetsReceived - t.packetsReceived,
|
|
675
|
+
packetsLost: n.packetsLost - t.packetsLost,
|
|
676
|
+
jitter: n.jitter,
|
|
677
|
+
frameWidth: n.frameWidth,
|
|
678
|
+
frameHeight: n.frameHeight,
|
|
679
|
+
frameRate: n.frameRate
|
|
680
|
+
} : {
|
|
681
|
+
index: i,
|
|
682
|
+
timestamp: n.timestamp,
|
|
683
|
+
bytesReceived: n.bytesReceived,
|
|
684
|
+
packetsReceived: n.packetsReceived,
|
|
685
|
+
packetsLost: n.packetsLost,
|
|
686
|
+
jitter: n.jitter,
|
|
687
|
+
frameWidth: n.frameWidth,
|
|
688
|
+
frameHeight: n.frameHeight,
|
|
689
|
+
frameRate: n.frameRate
|
|
690
|
+
} : {
|
|
691
|
+
index: i,
|
|
692
|
+
timestamp: n.timestamp,
|
|
693
|
+
bytesReceived: n.bytesReceived - e[i - 1].bytesReceived,
|
|
694
|
+
packetsReceived: n.packetsReceived - e[i - 1].packetsReceived,
|
|
695
|
+
packetsLost: n.packetsLost - e[i - 1].packetsLost,
|
|
696
|
+
jitter: n.jitter,
|
|
697
|
+
frameWidth: n.frameWidth,
|
|
698
|
+
frameHeight: n.frameHeight,
|
|
699
|
+
frameRate: n.frameRate
|
|
700
|
+
});
|
|
701
|
+
}
|
|
702
|
+
let St = !1;
|
|
703
|
+
const J = (e, t) => St && console.log(e, t), un = (window.RTCPeerConnection || window.webkitRTCPeerConnection || window.mozRTCPeerConnection).bind(window);
|
|
704
|
+
async function gn(e, {
|
|
705
|
+
debug: t = !1,
|
|
706
|
+
callbacks: n,
|
|
707
|
+
auth: i,
|
|
708
|
+
baseURL: a = ne
|
|
709
|
+
}) {
|
|
710
|
+
St = t;
|
|
711
|
+
const o = {
|
|
712
|
+
...n
|
|
713
|
+
}, {
|
|
714
|
+
startConnection: s,
|
|
715
|
+
sendStreamRequest: c,
|
|
716
|
+
close: l,
|
|
717
|
+
createStream: d,
|
|
718
|
+
addIceCandidate: p
|
|
719
|
+
} = e.videoType === se.Clip ? _n(i, a) : ln(i, a), {
|
|
720
|
+
id: r,
|
|
721
|
+
offer: _,
|
|
722
|
+
ice_servers: u,
|
|
723
|
+
session_id: m
|
|
724
|
+
} = await d(e), I = new un({
|
|
725
|
+
iceServers: u
|
|
726
|
+
}), M = I.createDataChannel("JanusDataChannel"), h = [];
|
|
727
|
+
let w = 0, A;
|
|
728
|
+
if (!m)
|
|
729
|
+
throw new Error("Could not create session_id");
|
|
730
|
+
I.onicecandidate = (v) => {
|
|
731
|
+
J("peerConnection.onicecandidate", v), v.candidate && v.candidate.sdpMid && v.candidate.sdpMLineIndex !== null && p(r, {
|
|
732
|
+
candidate: v.candidate.candidate,
|
|
733
|
+
sdpMid: v.candidate.sdpMid,
|
|
734
|
+
sdpMLineIndex: v.candidate.sdpMLineIndex
|
|
735
|
+
}, m);
|
|
736
|
+
}, I.oniceconnectionstatechange = () => {
|
|
737
|
+
var v;
|
|
738
|
+
J("peerConnection.oniceconnectionstatechange => " + I.iceConnectionState), (v = o.onConnectionStateChange) == null || v.call(o, I.iceConnectionState);
|
|
739
|
+
}, I.ontrack = (v) => {
|
|
740
|
+
var x;
|
|
741
|
+
J("peerConnection.ontrack", v), (x = o.onSrcObjectReady) == null || x.call(o, v.streams[0]);
|
|
742
|
+
}, M.onmessage = (v) => {
|
|
743
|
+
var x, z, O;
|
|
744
|
+
if (M.readyState === "open") {
|
|
745
|
+
const [S, k] = v.data.split(":");
|
|
746
|
+
if (S === Ae.StreamStarted)
|
|
747
|
+
w = h.length, A = setInterval(() => {
|
|
748
|
+
I.getStats().then((j) => {
|
|
749
|
+
j.forEach((W) => {
|
|
750
|
+
W.type === "inbound-rtp" && W.kind === "video" && h.push(W);
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
}, 1e3), (x = o.onVideoStateChange) == null || x.call(o, Me.Start);
|
|
754
|
+
else if (S === Ae.StreamDone) {
|
|
755
|
+
clearInterval(A);
|
|
756
|
+
const j = h.slice(w);
|
|
757
|
+
if (j) {
|
|
758
|
+
const W = w === 0 ? void 0 : h[w - 1], U = dn(j, W);
|
|
759
|
+
w = h.length, (z = o.onVideoStateChange) == null || z.call(o, Me.Stop, U.sort((Le, ge) => ge.packetsLost - Le.packetsLost).slice(0, 5));
|
|
760
|
+
}
|
|
761
|
+
} else
|
|
762
|
+
(O = o.onMessage) == null || O.call(o, S, decodeURIComponent(k));
|
|
763
|
+
}
|
|
764
|
+
}, await I.setRemoteDescription(_), J("set remote description OK");
|
|
765
|
+
const T = await I.createAnswer();
|
|
766
|
+
return J("create answer OK"), await I.setLocalDescription(T), J("set local description OK"), await s(r, T, m), J("start connection OK"), {
|
|
767
|
+
/**
|
|
768
|
+
* Method to send request to server to get clip or talk depend on you payload
|
|
769
|
+
* @param payload
|
|
770
|
+
*/
|
|
771
|
+
speak(v) {
|
|
772
|
+
return c(r, m, v);
|
|
773
|
+
},
|
|
774
|
+
/**
|
|
775
|
+
* Method to close RTC connection
|
|
776
|
+
*/
|
|
777
|
+
async terminate() {
|
|
778
|
+
var v, x;
|
|
779
|
+
r && (I && (I.close(), I.oniceconnectionstatechange = null, I.onnegotiationneeded = null, I.onicecandidate = null, I.ontrack = null), await l(r, m).catch((z) => {
|
|
780
|
+
}), (v = o.onConnectionStateChange) == null || v.call(o, "closed"), (x = o.onVideoStateChange) == null || x.call(o, Me.Stop));
|
|
781
|
+
},
|
|
782
|
+
/**
|
|
783
|
+
* Session identifier information, should be returned in the body of all streaming requests
|
|
784
|
+
*/
|
|
785
|
+
sessionId: m,
|
|
786
|
+
/**
|
|
787
|
+
* Id of current RTC stream
|
|
788
|
+
*/
|
|
789
|
+
streamId: r,
|
|
790
|
+
/**
|
|
791
|
+
* Method to add callback that will be trigered on supported events
|
|
792
|
+
* @param eventName
|
|
793
|
+
* @param callback
|
|
794
|
+
*/
|
|
795
|
+
onCallback(v, x) {
|
|
796
|
+
o[v] = x;
|
|
797
|
+
}
|
|
798
|
+
};
|
|
799
|
+
}
|
|
800
|
+
var X, D, Te, qe, de = 0, kt = [], we = [], et = f.__b, tt = f.__r, nt = f.diffed, it = f.__c, at = f.unmount;
|
|
801
|
+
function ue(e, t) {
|
|
802
|
+
f.__h && f.__h(D, e, de || t), de = 0;
|
|
803
|
+
var n = D.__H || (D.__H = { __: [], __h: [] });
|
|
804
|
+
return e >= n.__.length && n.__.push({ __V: we }), n.__[e];
|
|
805
|
+
}
|
|
806
|
+
function b(e) {
|
|
807
|
+
return de = 1, pn(jt, e);
|
|
808
|
+
}
|
|
809
|
+
function pn(e, t, n) {
|
|
810
|
+
var i = ue(X++, 2);
|
|
811
|
+
if (i.t = e, !i.__c && (i.__ = [n ? n(t) : jt(void 0, t), function(c) {
|
|
812
|
+
var l = i.__N ? i.__N[0] : i.__[0], d = i.t(l, c);
|
|
813
|
+
l !== d && (i.__N = [d, i.__[1]], i.__c.setState({}));
|
|
814
|
+
}], i.__c = D, !D.u)) {
|
|
815
|
+
var a = function(c, l, d) {
|
|
816
|
+
if (!i.__c.__H)
|
|
817
|
+
return !0;
|
|
818
|
+
var p = i.__c.__H.__.filter(function(_) {
|
|
819
|
+
return _.__c;
|
|
820
|
+
});
|
|
821
|
+
if (p.every(function(_) {
|
|
822
|
+
return !_.__N;
|
|
823
|
+
}))
|
|
824
|
+
return !o || o.call(this, c, l, d);
|
|
825
|
+
var r = !1;
|
|
826
|
+
return p.forEach(function(_) {
|
|
827
|
+
if (_.__N) {
|
|
828
|
+
var u = _.__[0];
|
|
829
|
+
_.__ = _.__N, _.__N = void 0, u !== _.__[0] && (r = !0);
|
|
830
|
+
}
|
|
831
|
+
}), !(!r && i.__c.props === c) && (!o || o.call(this, c, l, d));
|
|
832
|
+
};
|
|
833
|
+
D.u = !0;
|
|
834
|
+
var o = D.shouldComponentUpdate, s = D.componentWillUpdate;
|
|
835
|
+
D.componentWillUpdate = function(c, l, d) {
|
|
836
|
+
if (this.__e) {
|
|
837
|
+
var p = o;
|
|
838
|
+
o = void 0, a(c, l, d), o = p;
|
|
839
|
+
}
|
|
840
|
+
s && s.call(this, c, l, d);
|
|
841
|
+
}, D.shouldComponentUpdate = a;
|
|
842
|
+
}
|
|
843
|
+
return i.__N || i.__;
|
|
844
|
+
}
|
|
845
|
+
function H(e, t) {
|
|
846
|
+
var n = ue(X++, 3);
|
|
847
|
+
!f.__s && Re(n.__H, t) && (n.__ = e, n.i = t, D.__H.__h.push(n));
|
|
848
|
+
}
|
|
849
|
+
function fn(e, t) {
|
|
850
|
+
var n = ue(X++, 4);
|
|
851
|
+
!f.__s && Re(n.__H, t) && (n.__ = e, n.i = t, D.__h.push(n));
|
|
852
|
+
}
|
|
853
|
+
function te(e) {
|
|
854
|
+
return de = 5, De(function() {
|
|
855
|
+
return { current: e };
|
|
856
|
+
}, []);
|
|
857
|
+
}
|
|
858
|
+
function De(e, t) {
|
|
859
|
+
var n = ue(X++, 7);
|
|
860
|
+
return Re(n.__H, t) ? (n.__V = e(), n.i = t, n.__h = e, n.__V) : n.__;
|
|
861
|
+
}
|
|
862
|
+
function ot(e, t) {
|
|
863
|
+
return de = 8, De(function() {
|
|
864
|
+
return e;
|
|
865
|
+
}, t);
|
|
866
|
+
}
|
|
867
|
+
function $(e) {
|
|
868
|
+
var t = D.context[e.__c], n = ue(X++, 9);
|
|
869
|
+
return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(D)), t.props.value) : e.__;
|
|
870
|
+
}
|
|
871
|
+
function hn() {
|
|
872
|
+
for (var e; e = kt.shift(); )
|
|
873
|
+
if (e.__P && e.__H)
|
|
874
|
+
try {
|
|
875
|
+
e.__H.__h.forEach(ve), e.__H.__h.forEach(We), e.__H.__h = [];
|
|
876
|
+
} catch (t) {
|
|
877
|
+
e.__H.__h = [], f.__e(t, e.__v);
|
|
878
|
+
}
|
|
879
|
+
}
|
|
880
|
+
f.__b = function(e) {
|
|
881
|
+
D = null, et && et(e);
|
|
882
|
+
}, f.__r = function(e) {
|
|
883
|
+
tt && tt(e), X = 0;
|
|
884
|
+
var t = (D = e.__c).__H;
|
|
885
|
+
t && (Te === D ? (t.__h = [], D.__h = [], t.__.forEach(function(n) {
|
|
886
|
+
n.__N && (n.__ = n.__N), n.__V = we, n.__N = n.i = void 0;
|
|
887
|
+
})) : (t.__h.forEach(ve), t.__h.forEach(We), t.__h = [], X = 0)), Te = D;
|
|
888
|
+
}, f.diffed = function(e) {
|
|
889
|
+
nt && nt(e);
|
|
890
|
+
var t = e.__c;
|
|
891
|
+
t && t.__H && (t.__H.__h.length && (kt.push(t) !== 1 && qe === f.requestAnimationFrame || ((qe = f.requestAnimationFrame) || mn)(hn)), t.__H.__.forEach(function(n) {
|
|
892
|
+
n.i && (n.__H = n.i), n.__V !== we && (n.__ = n.__V), n.i = void 0, n.__V = we;
|
|
893
|
+
})), Te = D = null;
|
|
894
|
+
}, f.__c = function(e, t) {
|
|
895
|
+
t.some(function(n) {
|
|
896
|
+
try {
|
|
897
|
+
n.__h.forEach(ve), n.__h = n.__h.filter(function(i) {
|
|
898
|
+
return !i.__ || We(i);
|
|
899
|
+
});
|
|
900
|
+
} catch (i) {
|
|
901
|
+
t.some(function(a) {
|
|
902
|
+
a.__h && (a.__h = []);
|
|
903
|
+
}), t = [], f.__e(i, n.__v);
|
|
904
|
+
}
|
|
905
|
+
}), it && it(e, t);
|
|
906
|
+
}, f.unmount = function(e) {
|
|
907
|
+
at && at(e);
|
|
908
|
+
var t, n = e.__c;
|
|
909
|
+
n && n.__H && (n.__H.__.forEach(function(i) {
|
|
910
|
+
try {
|
|
911
|
+
ve(i);
|
|
912
|
+
} catch (a) {
|
|
913
|
+
t = a;
|
|
914
|
+
}
|
|
915
|
+
}), n.__H = void 0, t && f.__e(t, n.__v));
|
|
916
|
+
};
|
|
917
|
+
var rt = typeof requestAnimationFrame == "function";
|
|
918
|
+
function mn(e) {
|
|
919
|
+
var t, n = function() {
|
|
920
|
+
clearTimeout(i), rt && cancelAnimationFrame(t), setTimeout(e);
|
|
921
|
+
}, i = setTimeout(n, 100);
|
|
922
|
+
rt && (t = requestAnimationFrame(n));
|
|
923
|
+
}
|
|
924
|
+
function ve(e) {
|
|
925
|
+
var t = D, n = e.__c;
|
|
926
|
+
typeof n == "function" && (e.__c = void 0, n()), D = t;
|
|
927
|
+
}
|
|
928
|
+
function We(e) {
|
|
929
|
+
var t = D;
|
|
930
|
+
e.__c = e.__(), D = t;
|
|
931
|
+
}
|
|
932
|
+
function Re(e, t) {
|
|
933
|
+
return !e || e.length !== t.length || t.some(function(n, i) {
|
|
934
|
+
return n !== e[i];
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
function jt(e, t) {
|
|
938
|
+
return typeof t == "function" ? t(e) : t;
|
|
939
|
+
}
|
|
940
|
+
function xt() {
|
|
941
|
+
return Math.random().toString(16).slice(2);
|
|
942
|
+
}
|
|
943
|
+
function In() {
|
|
944
|
+
const e = localStorage.getItem("tracking_id") ?? xt();
|
|
945
|
+
return localStorage.setItem("tracking_id", e), e;
|
|
946
|
+
}
|
|
947
|
+
function P(e, t) {
|
|
948
|
+
if (window.localStorage.getItem("track_enabled") === "false")
|
|
949
|
+
return;
|
|
950
|
+
const n = {
|
|
951
|
+
method: "POST",
|
|
952
|
+
headers: {
|
|
953
|
+
"Content-Type": "application/x-www-form-urlencoded"
|
|
954
|
+
},
|
|
955
|
+
body: new URLSearchParams({
|
|
956
|
+
data: JSON.stringify([{
|
|
957
|
+
event: e,
|
|
958
|
+
properties: {
|
|
959
|
+
...t,
|
|
960
|
+
token: Ze.mixpanelKey,
|
|
961
|
+
time: Date.now(),
|
|
962
|
+
distinct_id: In(),
|
|
963
|
+
$insert_id: xt(),
|
|
964
|
+
origin: window.location.href,
|
|
965
|
+
"Screen Height": window.screen.height || window.innerWidth,
|
|
966
|
+
"Screen Width": window.screen.width || window.innerHeight,
|
|
967
|
+
"User Agent": navigator.userAgent
|
|
968
|
+
}
|
|
969
|
+
}])
|
|
970
|
+
})
|
|
971
|
+
};
|
|
972
|
+
return fetch("https://api-js.mixpanel.com/track/?verbose=1&ip=1", n).then((i) => i.json()).catch((i) => console.error(i));
|
|
973
|
+
}
|
|
974
|
+
var Mn = 0;
|
|
975
|
+
function g(e, t, n, i, a, o) {
|
|
976
|
+
var s, c, l = {};
|
|
977
|
+
for (c in t)
|
|
978
|
+
c == "ref" ? s = t[c] : l[c] = t[c];
|
|
979
|
+
var d = { type: e, props: l, key: n, ref: s, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, constructor: void 0, __v: --Mn, __i: -1, __u: 0, __source: a, __self: o };
|
|
980
|
+
if (typeof e == "function" && (s = e.defaultProps))
|
|
981
|
+
for (c in s)
|
|
982
|
+
l[c] === void 0 && (l[c] = s[c]);
|
|
983
|
+
return f.vnode && f.vnode(d), d;
|
|
984
|
+
}
|
|
985
|
+
const ae = Lt({
|
|
986
|
+
didFetch: async () => {
|
|
987
|
+
},
|
|
988
|
+
authenticate: () => {
|
|
989
|
+
},
|
|
990
|
+
auth: {},
|
|
991
|
+
host: "",
|
|
992
|
+
wsHost: "",
|
|
993
|
+
isAuthenticated: !1
|
|
994
|
+
});
|
|
995
|
+
ae.displayName = "DidFetch";
|
|
996
|
+
function wn({
|
|
997
|
+
children: e,
|
|
998
|
+
auth: t,
|
|
999
|
+
didApiUrl: n,
|
|
1000
|
+
didSocketApiUrl: i
|
|
1001
|
+
}) {
|
|
1002
|
+
const [a, o] = b(t), s = De(() => a && ie(a, n), [a]), c = async (l) => {
|
|
1003
|
+
o((d) => JSON.stringify(l) === JSON.stringify(d) ? d : l);
|
|
1004
|
+
};
|
|
1005
|
+
return g(ae.Provider, {
|
|
1006
|
+
value: {
|
|
1007
|
+
didFetch: s,
|
|
1008
|
+
auth: a,
|
|
1009
|
+
host: n,
|
|
1010
|
+
wsHost: i,
|
|
1011
|
+
authenticate: c,
|
|
1012
|
+
isAuthenticated: !!a
|
|
1013
|
+
},
|
|
1014
|
+
children: e
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
const K = Lt({
|
|
1018
|
+
connectionState: N.New,
|
|
1019
|
+
chatMode: E.Functional,
|
|
1020
|
+
setChatMode: () => {
|
|
1021
|
+
},
|
|
1022
|
+
streamState: L.New,
|
|
1023
|
+
starterMessage: [],
|
|
1024
|
+
connect: async () => {
|
|
1025
|
+
},
|
|
1026
|
+
terminate: async () => {
|
|
1027
|
+
},
|
|
1028
|
+
setStreamState: () => {
|
|
1029
|
+
},
|
|
1030
|
+
streamedMessage: "",
|
|
1031
|
+
agentManager: {
|
|
1032
|
+
agent: {},
|
|
1033
|
+
reconnectToChat: async () => {
|
|
1034
|
+
},
|
|
1035
|
+
terminate: async () => {
|
|
1036
|
+
},
|
|
1037
|
+
chatId: "",
|
|
1038
|
+
chat: async () => ({
|
|
1039
|
+
result: ""
|
|
1040
|
+
}),
|
|
1041
|
+
rate: async () => ({}),
|
|
1042
|
+
deleteRate: async () => ({}),
|
|
1043
|
+
speak: async () => ({}),
|
|
1044
|
+
getStarterMessages: async () => []
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
K.displayName = "Streaming Manager";
|
|
1048
|
+
function vn(e) {
|
|
1049
|
+
switch (e) {
|
|
1050
|
+
case "connected":
|
|
1051
|
+
return N.Connected;
|
|
1052
|
+
case "checking":
|
|
1053
|
+
return N.Connecting;
|
|
1054
|
+
case "failed":
|
|
1055
|
+
return N.Fail;
|
|
1056
|
+
case "new":
|
|
1057
|
+
case "closed":
|
|
1058
|
+
case "disconnected":
|
|
1059
|
+
default:
|
|
1060
|
+
return N.New;
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
function yn({
|
|
1064
|
+
children: e,
|
|
1065
|
+
agentId: t
|
|
1066
|
+
}) {
|
|
1067
|
+
const [n, i] = b(new AbortController()), [a, o] = b(N.New), [s, c] = b(E.Functional), [l, d] = b(L.New), [p, r] = b(), [_, u] = b(""), [m, I] = b([]), [M, h] = b(), {
|
|
1068
|
+
auth: w,
|
|
1069
|
+
host: A,
|
|
1070
|
+
wsHost: T
|
|
1071
|
+
} = $(ae);
|
|
1072
|
+
async function v() {
|
|
1073
|
+
if (w && A && T)
|
|
1074
|
+
try {
|
|
1075
|
+
n == null || n.abort(), o(N.Connecting);
|
|
1076
|
+
const z = new AbortController();
|
|
1077
|
+
i(z);
|
|
1078
|
+
const O = await sn(t, {
|
|
1079
|
+
auth: w,
|
|
1080
|
+
baseURL: A,
|
|
1081
|
+
wsURL: T,
|
|
1082
|
+
callbacks: {
|
|
1083
|
+
onSrcObjectReady: r,
|
|
1084
|
+
onConnectionStateChange(k) {
|
|
1085
|
+
const j = vn(k);
|
|
1086
|
+
Xe({
|
|
1087
|
+
connectionState: N[j]
|
|
1088
|
+
}), j === N.Connected && P("agent-chat-loaded"), o(j);
|
|
1089
|
+
},
|
|
1090
|
+
onVideoStateChange(k) {
|
|
1091
|
+
const j = k === "START" ? L.Start : L.New;
|
|
1092
|
+
d(j), Xe({
|
|
1093
|
+
streamState: L[j]
|
|
1094
|
+
}), P("agent-video", {
|
|
1095
|
+
chatId: O.chatId,
|
|
1096
|
+
event: k,
|
|
1097
|
+
agent_id: t
|
|
1098
|
+
});
|
|
1099
|
+
},
|
|
1100
|
+
onChatEvents(k, j) {
|
|
1101
|
+
k === le.Partial ? u((W) => W + j.content) : k === le.Answer && j.content && u(j.content);
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
h({
|
|
1106
|
+
...O,
|
|
1107
|
+
chat: async (k) => {
|
|
1108
|
+
if (O.agent && O.agent.presenter.voice) {
|
|
1109
|
+
u(""), n == null || n.abort();
|
|
1110
|
+
const j = new AbortController();
|
|
1111
|
+
return i(j), await O.chat(k).catch((U) => {
|
|
1112
|
+
throw (U == null ? void 0 : U.kind) === "InsufficientCreditsError" && c(E.TextOnly), U;
|
|
1113
|
+
});
|
|
1114
|
+
}
|
|
1115
|
+
return Promise.reject();
|
|
1116
|
+
}
|
|
1117
|
+
}), I(await O.getStarterMessages());
|
|
1118
|
+
} catch (z) {
|
|
1119
|
+
console.error(z), o(N.Fail), n.abort(), c(E.Maintainance);
|
|
1120
|
+
}
|
|
1121
|
+
}
|
|
1122
|
+
async function x() {
|
|
1123
|
+
n == null || n.abort(), d(L.New), o(N.Terminating), await (M == null ? void 0 : M.terminate()), o(N.New);
|
|
1124
|
+
}
|
|
1125
|
+
return H(() => {
|
|
1126
|
+
v();
|
|
1127
|
+
}, [w, A, T]), g(K.Provider, {
|
|
1128
|
+
value: {
|
|
1129
|
+
streamedMessage: _,
|
|
1130
|
+
starterMessage: m,
|
|
1131
|
+
srcObject: p,
|
|
1132
|
+
streamState: l,
|
|
1133
|
+
connectionState: a,
|
|
1134
|
+
chatMode: s,
|
|
1135
|
+
setChatMode: c,
|
|
1136
|
+
setStreamState: d,
|
|
1137
|
+
terminate: x,
|
|
1138
|
+
connect: v,
|
|
1139
|
+
agentManager: M
|
|
1140
|
+
},
|
|
1141
|
+
children: e
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
const ct = "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iaXNvLTg4NTktMSI/Pg0KPCEtLSBVcGxvYWRlZCB0bzogU1ZHIFJlcG8sIHd3dy5zdmdyZXBvLmNvbSwgR2VuZXJhdG9yOiBTVkcgUmVwbyBNaXhlciBUb29scyAtLT4NCjxzdmcgaGVpZ2h0PSI4MDBweCIgd2lkdGg9IjgwMHB4IiB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIA0KCSB2aWV3Qm94PSIwIDAgMTk5Ljk0MyAxOTkuOTQzIiB4bWw6c3BhY2U9InByZXNlcnZlIj4NCjxnPg0KCTxnPg0KCQk8cGF0aCBzdHlsZT0iZmlsbDojMDEwMDAyOyIgZD0iTTk5Ljk3MiwwLjAwNEM0NC44NSwwLjAwNCwwLDQ0Ljg0NywwLDk5Ljk2OGMwLDU1LjEyNSw0NC44NDcsOTkuOTcyLDk5Ljk3Miw5OS45NzINCgkJCXM5OS45NzItNDQuODQ3LDk5Ljk3Mi05OS45NzJDMTk5Ljk0Myw0N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yIDE1LjU0NzNDMTYuMjI4MiAxNC4wMzMzIDE2Ljg2MTggMTEuOTcyMyAxNi42MTQ5IDEwLjAwMDRNMTUuMzAzNSA2LjcwODUxSDExLjc2NzlNMTUuMzAzNSA2LjcwODUxVjMuMTcyOTciIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiLz4KPC9zdmc+Cg==", Cn = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjQiIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgMCAyNCAyNCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE2LjkzOTkgNi45NjY4NEw2Ljg3MjA3IDE3LjAzNDdNNi44NzIwMyA2Ljk2NjhMMTYuOTM5OSAxNy4wMzQ2IiBzdHJva2U9IndoaXRlIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIi8+Cjwvc3ZnPgo=";
|
|
1145
|
+
function R({
|
|
1146
|
+
src: e,
|
|
1147
|
+
size: t,
|
|
1148
|
+
color: n = "currentcolor",
|
|
1149
|
+
padding: i = "0",
|
|
1150
|
+
rotated: a,
|
|
1151
|
+
margin: o = "0",
|
|
1152
|
+
width: s,
|
|
1153
|
+
className: c = ""
|
|
1154
|
+
}) {
|
|
1155
|
+
return g("svg", {
|
|
1156
|
+
className: "didagent__maskedicon " + c,
|
|
1157
|
+
style: {
|
|
1158
|
+
"--mask-url": `url('${e}')`,
|
|
1159
|
+
"--color": n,
|
|
1160
|
+
"--width": s,
|
|
1161
|
+
"--size": t,
|
|
1162
|
+
"--padding": i,
|
|
1163
|
+
"--margin": o,
|
|
1164
|
+
"--rotation": a ? "180deg" : "0deg"
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
function An({
|
|
1169
|
+
name: e,
|
|
1170
|
+
agent: t,
|
|
1171
|
+
displayRestart: n,
|
|
1172
|
+
onRestart: i,
|
|
1173
|
+
restartDisabled: a,
|
|
1174
|
+
isRestarting: o,
|
|
1175
|
+
onClose: s,
|
|
1176
|
+
onEasterEgg: c,
|
|
1177
|
+
closeClassName: l
|
|
1178
|
+
}) {
|
|
1179
|
+
(t == null ? void 0 : t.chats) !== void 0 && Math.max(0, Qe - t.chats);
|
|
1180
|
+
const d = te(0), {
|
|
1181
|
+
chatMode: p
|
|
1182
|
+
} = $(K);
|
|
1183
|
+
function r() {
|
|
1184
|
+
d.current += 1, d.current === 5 && (c == null || c(), d.current = 0);
|
|
1185
|
+
}
|
|
1186
|
+
return g("header", {
|
|
1187
|
+
className: "didagent__header",
|
|
1188
|
+
children: [g("div", {
|
|
1189
|
+
className: "didagent__header-left",
|
|
1190
|
+
children: [g("button", {
|
|
1191
|
+
onClick: s,
|
|
1192
|
+
className: `didagent__close__button ${l}`,
|
|
1193
|
+
children: g(R, {
|
|
1194
|
+
src: Cn,
|
|
1195
|
+
size: "20px"
|
|
1196
|
+
})
|
|
1197
|
+
}), g("h2", {
|
|
1198
|
+
className: "didagent__header__name",
|
|
1199
|
+
onClick: r,
|
|
1200
|
+
children: e
|
|
1201
|
+
})]
|
|
1202
|
+
}), p === E.TextOnly && g("div", {
|
|
1203
|
+
className: "",
|
|
1204
|
+
children: [g("pre", {
|
|
1205
|
+
className: "didagent__info_message_agent_unavailable_indication",
|
|
1206
|
+
children: [g("pre", {
|
|
1207
|
+
children: "Performance mode"
|
|
1208
|
+
}), g(R, {
|
|
1209
|
+
src: ct,
|
|
1210
|
+
size: "20px"
|
|
1211
|
+
})]
|
|
1212
|
+
}), g("pre", {
|
|
1213
|
+
className: "didagent__info_message_agent_unavailable_message",
|
|
1214
|
+
children: [e, " is currently in performance mode, sound and face animations will not play"]
|
|
1215
|
+
})]
|
|
1216
|
+
}), p === E.Maintainance && g("div", {
|
|
1217
|
+
className: "didagent__info_message_agent_unavailable",
|
|
1218
|
+
children: g("pre", {
|
|
1219
|
+
className: "didagent__info_message_agent_unavailable_danger",
|
|
1220
|
+
children: [g(R, {
|
|
1221
|
+
src: ct,
|
|
1222
|
+
size: "20px"
|
|
1223
|
+
}), g("pre", {
|
|
1224
|
+
children: [e || "Agent", " is unavailable at the moment"]
|
|
1225
|
+
})]
|
|
1226
|
+
})
|
|
1227
|
+
}), n && g("button", {
|
|
1228
|
+
onClick: i,
|
|
1229
|
+
disabled: a,
|
|
1230
|
+
title: "Restart conversation",
|
|
1231
|
+
className: `didagent__header__menu__item ${o ? "didagent__header__menu__item-rotate" : ""}`,
|
|
1232
|
+
children: g(R, {
|
|
1233
|
+
src: zt,
|
|
1234
|
+
size: "20px"
|
|
1235
|
+
})
|
|
1236
|
+
})]
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
const bn = "data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMOSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCgl2aWV3Qm94PSIwIDAgMTAwIDEwMCIgZW5hYmxlLWJhY2tncm91bmQ9Im5ldyAwIDAgMCAwIiB4bWw6c3BhY2U9InByZXNlcnZlIj4KCTxwYXRoIGZpbGw9IiNmZmYiIAoJCWQ9Ik03Myw1MGMwLTEyLjctMTAuMy0yMy0yMy0yM1MyNywzNy4zLDI3LDUwIE0zMC45LDUwYzAtMTAuNSw4LjUtMTkuMSwxOS4xLTE5LjFTNjkuMSwzOS41LDY5LjEsNTAiPgoJCTxhbmltYXRlVHJhbnNmb3JtIGF0dHJpYnV0ZU5hbWU9InRyYW5zZm9ybSIgYXR0cmlidXRlVHlwZT0iWE1MIiB0eXBlPSJyb3RhdGUiIGR1cj0iMXMiIGZyb209IjAgNTAgNTAiCgkJCXRvPSIzNjAgNTAgNTAiIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiAvPgoJPC9wYXRoPgo8L3N2Zz4=";
|
|
1240
|
+
function he() {
|
|
1241
|
+
return (/* @__PURE__ */ new Date()).toISOString();
|
|
1242
|
+
}
|
|
1243
|
+
const Ot = "data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJMNSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayIgeD0iMHB4IiB5PSIwcHgiCiAgdmlld0JveD0iMCAwIDUyIDQyIiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAwIDAiIHhtbDpzcGFjZT0icHJlc2VydmUiPgogIDxjaXJjbGUgZmlsbD0iI2ZmZiIgc3Ryb2tlPSJub25lIiBjeD0iNiIgY3k9IjIxIiByPSI2Ij4KICAgIDxhbmltYXRlVHJhbnNmb3JtIAogICAgICAgYXR0cmlidXRlTmFtZT0idHJhbnNmb3JtIiAKICAgICAgIGR1cj0iMXMiIAogICAgICAgdHlwZT0idHJhbnNsYXRlIiAKICAgICAgIHZhbHVlcz0iMCAxNSA7IDAgLTE1OyAwIDE1IiAKICAgICAgIHJlcGVhdENvdW50PSJpbmRlZmluaXRlIiAKICAgICAgIGJlZ2luPSIwLjEiLz4KICA8L2NpcmNsZT4KICA8Y2lyY2xlIGZpbGw9IiNmZmYiIHN0cm9rZT0ibm9uZSIgY3g9IjI1IiBjeT0iMjEiIHI9IjYiPgogICAgPGFuaW1hdGVUcmFuc2Zvcm0gCiAgICAgICBhdHRyaWJ1dGVOYW1lPSJ0cmFuc2Zvcm0iIAogICAgICAgZHVyPSIxcyIgCiAgICAgICB0eXBlPSJ0cmFuc2xhdGUiIAogICAgICAgdmFsdWVzPSIwIDEwIDsgMCAtMTA7IDAgMTAiIAogICAgICAgcmVwZWF0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CwxLDAsMiwwczAsMCwwLDBWMTZhMSwxLDAsMCwwLTEtMUg0OC45MVoiIC8+Cjwvc3ZnPg==";
|
|
1244
|
+
function Tn() {
|
|
1245
|
+
return navigator.userAgent.toLowerCase().match(/(android|windows).+chrome|(iphone|mac).+safari/) && (window.SpeechRecognition || window.webkitSpeechRecognition);
|
|
1246
|
+
}
|
|
1247
|
+
function Sn({
|
|
1248
|
+
onstart: e,
|
|
1249
|
+
onend: t,
|
|
1250
|
+
onresult: n,
|
|
1251
|
+
onerror: i,
|
|
1252
|
+
interimResults: a = !1
|
|
1253
|
+
}) {
|
|
1254
|
+
const o = Tn();
|
|
1255
|
+
if (!o)
|
|
1256
|
+
return null;
|
|
1257
|
+
const s = new o();
|
|
1258
|
+
return s.interimResults = a, s.onerror = (c) => i == null ? void 0 : i(c), s.onstart = () => {
|
|
1259
|
+
e == null || e();
|
|
1260
|
+
}, s.onspeechend = () => {
|
|
1261
|
+
t == null || t(), s.stop();
|
|
1262
|
+
}, s.onresult = n, {
|
|
1263
|
+
start: () => s.start(),
|
|
1264
|
+
stop: () => s.stop()
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
function kn({
|
|
1268
|
+
text: e,
|
|
1269
|
+
onSend: t,
|
|
1270
|
+
onRestart: n,
|
|
1271
|
+
onTranscript: i
|
|
1272
|
+
}) {
|
|
1273
|
+
var M;
|
|
1274
|
+
const [a, o] = b(), [s, c] = b(!1), l = $(K), d = (l == null ? void 0 : l.connectionState) || N.New, p = (l == null ? void 0 : l.streamState) || L.New, r = ((M = l == null ? void 0 : l.agentManager) == null ? void 0 : M.chatId) || "", _ = (l == null ? void 0 : l.chatMode) === E.TextOnly, {
|
|
1275
|
+
isAuthenticated: u
|
|
1276
|
+
} = $(ae), m = De(() => Sn({
|
|
1277
|
+
onresult(h) {
|
|
1278
|
+
const w = [...h.results].map((A) => [...A].map((T) => T.transcript.trim()).join(" ")).join(" ");
|
|
1279
|
+
i(w);
|
|
1280
|
+
},
|
|
1281
|
+
onstart: () => c(!0),
|
|
1282
|
+
onend: () => c(!1),
|
|
1283
|
+
onerror: (h) => {
|
|
1284
|
+
P("agent-stt-error", {
|
|
1285
|
+
event: "error",
|
|
1286
|
+
error: h.error,
|
|
1287
|
+
engine: "native",
|
|
1288
|
+
chatId: r
|
|
1289
|
+
}), o(h);
|
|
1290
|
+
}
|
|
1291
|
+
}), [i]);
|
|
1292
|
+
if (u) {
|
|
1293
|
+
if (d === N.Connecting)
|
|
1294
|
+
return g("button", {
|
|
1295
|
+
className: "didagaent__send__button",
|
|
1296
|
+
disabled: !0,
|
|
1297
|
+
children: [g("div", {
|
|
1298
|
+
className: "didagent__box__blur border8"
|
|
1299
|
+
}), g(R, {
|
|
1300
|
+
src: Ot,
|
|
1301
|
+
size: "16px"
|
|
1302
|
+
})]
|
|
1303
|
+
});
|
|
1304
|
+
if ([N.New, N.Fail, N.Terminating].includes(d) && !_)
|
|
1305
|
+
return g("button", {
|
|
1306
|
+
className: "didagaent__send__button",
|
|
1307
|
+
onClick: n,
|
|
1308
|
+
disabled: d === N.Terminating,
|
|
1309
|
+
children: [g("div", {
|
|
1310
|
+
className: "didagent__box__blur border8"
|
|
1311
|
+
}), g(R, {
|
|
1312
|
+
src: zt,
|
|
1313
|
+
size: "24px"
|
|
1314
|
+
})]
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
const I = [L.Start, L.Loading, L.Buffering].includes(p) && !_;
|
|
1318
|
+
return (e.length === 0 || s) && !a ? g("button", {
|
|
1319
|
+
className: "didagaent__send__button",
|
|
1320
|
+
onClick: function() {
|
|
1321
|
+
if (m) {
|
|
1322
|
+
const w = s ? "stop" : "start";
|
|
1323
|
+
m[w](), P(`agent-stt-${w}`, {
|
|
1324
|
+
event: "click",
|
|
1325
|
+
engine: "native",
|
|
1326
|
+
chatId: r
|
|
1327
|
+
});
|
|
1328
|
+
}
|
|
1329
|
+
},
|
|
1330
|
+
disabled: I,
|
|
1331
|
+
children: [g("div", {
|
|
1332
|
+
className: "didagent__box__blur border8"
|
|
1333
|
+
}), g(R, {
|
|
1334
|
+
src: s ? Ln : Nn,
|
|
1335
|
+
size: "24px"
|
|
1336
|
+
})]
|
|
1337
|
+
}) : g("button", {
|
|
1338
|
+
className: "didagaent__send__button",
|
|
1339
|
+
onClick: t,
|
|
1340
|
+
disabled: !e.trim() || I,
|
|
1341
|
+
children: [g("div", {
|
|
1342
|
+
className: "didagent__box__blur border8"
|
|
1343
|
+
}), g(R, {
|
|
1344
|
+
src: Dn,
|
|
1345
|
+
size: "24px",
|
|
1346
|
+
color: "white"
|
|
1347
|
+
})]
|
|
1348
|
+
});
|
|
1349
|
+
}
|
|
1350
|
+
function Et(e, t) {
|
|
1351
|
+
for (var n in t)
|
|
1352
|
+
e[n] = t[n];
|
|
1353
|
+
return e;
|
|
1354
|
+
}
|
|
1355
|
+
function st(e, t) {
|
|
1356
|
+
for (var n in e)
|
|
1357
|
+
if (n !== "__source" && !(n in t))
|
|
1358
|
+
return !0;
|
|
1359
|
+
for (var i in t)
|
|
1360
|
+
if (i !== "__source" && e[i] !== t[i])
|
|
1361
|
+
return !0;
|
|
1362
|
+
return !1;
|
|
1363
|
+
}
|
|
1364
|
+
function _t(e) {
|
|
1365
|
+
this.props = e;
|
|
1366
|
+
}
|
|
1367
|
+
(_t.prototype = new B()).isPureReactComponent = !0, _t.prototype.shouldComponentUpdate = function(e, t) {
|
|
1368
|
+
return st(this.props, e) || st(this.state, t);
|
|
1369
|
+
};
|
|
1370
|
+
var lt = f.__b;
|
|
1371
|
+
f.__b = function(e) {
|
|
1372
|
+
e.type && e.type.__f && e.ref && (e.props.ref = e.ref, e.ref = null), lt && lt(e);
|
|
1373
|
+
};
|
|
1374
|
+
var jn = typeof Symbol < "u" && Symbol.for && Symbol.for("react.forward_ref") || 3911;
|
|
1375
|
+
function xn(e) {
|
|
1376
|
+
function t(n) {
|
|
1377
|
+
var i = Et({}, n);
|
|
1378
|
+
return delete i.ref, e(i, n.ref || null);
|
|
1379
|
+
}
|
|
1380
|
+
return t.$$typeof = jn, t.render = t, t.prototype.isReactComponent = t.__f = !0, t.displayName = "ForwardRef(" + (e.displayName || e.name) + ")", t;
|
|
1381
|
+
}
|
|
1382
|
+
var zn = f.__e;
|
|
1383
|
+
f.__e = function(e, t, n, i) {
|
|
1384
|
+
if (e.then) {
|
|
1385
|
+
for (var a, o = t; o = o.__; )
|
|
1386
|
+
if ((a = o.__c) && a.__c)
|
|
1387
|
+
return t.__e == null && (t.__e = n.__e, t.__k = n.__k), a.__c(e, t);
|
|
1388
|
+
}
|
|
1389
|
+
zn(e, t, n, i);
|
|
1390
|
+
};
|
|
1391
|
+
var dt = f.unmount;
|
|
1392
|
+
function Zt(e, t, n) {
|
|
1393
|
+
return e && (e.__c && e.__c.__H && (e.__c.__H.__.forEach(function(i) {
|
|
1394
|
+
typeof i.__c == "function" && i.__c();
|
|
1395
|
+
}), e.__c.__H = null), (e = Et({}, e)).__c != null && (e.__c.__P === n && (e.__c.__P = t), e.__c = null), e.__k = e.__k && e.__k.map(function(i) {
|
|
1396
|
+
return Zt(i, t, n);
|
|
1397
|
+
})), e;
|
|
1398
|
+
}
|
|
1399
|
+
function Wt(e, t, n) {
|
|
1400
|
+
return e && n && (e.__v = null, e.__k = e.__k && e.__k.map(function(i) {
|
|
1401
|
+
return Wt(i, t, n);
|
|
1402
|
+
}), e.__c && e.__c.__P === t && (e.__e && n.appendChild(e.__e), e.__c.__e = !0, e.__c.__P = n)), e;
|
|
1403
|
+
}
|
|
1404
|
+
function Se() {
|
|
1405
|
+
this.__u = 0, this.t = null, this.__b = null;
|
|
1406
|
+
}
|
|
1407
|
+
function Pt(e) {
|
|
1408
|
+
var t = e.__.__c;
|
|
1409
|
+
return t && t.__a && t.__a(e);
|
|
1410
|
+
}
|
|
1411
|
+
function me() {
|
|
1412
|
+
this.u = null, this.o = null;
|
|
1413
|
+
}
|
|
1414
|
+
f.unmount = function(e) {
|
|
1415
|
+
var t = e.__c;
|
|
1416
|
+
t && t.__R && t.__R(), t && 32 & e.__u && (e.type = null), dt && dt(e);
|
|
1417
|
+
}, (Se.prototype = new B()).__c = function(e, t) {
|
|
1418
|
+
var n = t.__c, i = this;
|
|
1419
|
+
i.t == null && (i.t = []), i.t.push(n);
|
|
1420
|
+
var a = Pt(i.__v), o = !1, s = function() {
|
|
1421
|
+
o || (o = !0, n.__R = null, a ? a(c) : c());
|
|
1422
|
+
};
|
|
1423
|
+
n.__R = s;
|
|
1424
|
+
var c = function() {
|
|
1425
|
+
if (!--i.__u) {
|
|
1426
|
+
if (i.state.__a) {
|
|
1427
|
+
var l = i.state.__a;
|
|
1428
|
+
i.__v.__k[0] = Wt(l, l.__c.__P, l.__c.__O);
|
|
1429
|
+
}
|
|
1430
|
+
var d;
|
|
1431
|
+
for (i.setState({ __a: i.__b = null }); d = i.t.pop(); )
|
|
1432
|
+
d.forceUpdate();
|
|
1433
|
+
}
|
|
1434
|
+
};
|
|
1435
|
+
i.__u++ || 32 & t.__u || i.setState({ __a: i.__b = i.__v.__k[0] }), e.then(s, s);
|
|
1436
|
+
}, Se.prototype.componentWillUnmount = function() {
|
|
1437
|
+
this.t = [];
|
|
1438
|
+
}, Se.prototype.render = function(e, t) {
|
|
1439
|
+
if (this.__b) {
|
|
1440
|
+
if (this.__v.__k) {
|
|
1441
|
+
var n = document.createElement("div"), i = this.__v.__k[0].__c;
|
|
1442
|
+
this.__v.__k[0] = Zt(this.__b, n, i.__O = i.__P);
|
|
1443
|
+
}
|
|
1444
|
+
this.__b = null;
|
|
1445
|
+
}
|
|
1446
|
+
var a = t.__a && ze(Q, null, e.fallback);
|
|
1447
|
+
return a && (a.__u &= -33), [ze(Q, null, t.__a ? null : e.children), a];
|
|
1448
|
+
};
|
|
1449
|
+
var ut = function(e, t, n) {
|
|
1450
|
+
if (++n[1] === n[0] && e.o.delete(t), e.props.revealOrder && (e.props.revealOrder[0] !== "t" || !e.o.size))
|
|
1451
|
+
for (n = e.u; n; ) {
|
|
1452
|
+
for (; n.length > 3; )
|
|
1453
|
+
n.pop()();
|
|
1454
|
+
if (n[1] < n[0])
|
|
1455
|
+
break;
|
|
1456
|
+
e.u = n = n[2];
|
|
1457
|
+
}
|
|
1458
|
+
};
|
|
1459
|
+
(me.prototype = new B()).__a = function(e) {
|
|
1460
|
+
var t = this, n = Pt(t.__v), i = t.o.get(e);
|
|
1461
|
+
return i[0]++, function(a) {
|
|
1462
|
+
var o = function() {
|
|
1463
|
+
t.props.revealOrder ? (i.push(a), ut(t, e, i)) : a();
|
|
1464
|
+
};
|
|
1465
|
+
n ? n(o) : o();
|
|
1466
|
+
};
|
|
1467
|
+
}, me.prototype.render = function(e) {
|
|
1468
|
+
this.u = null, this.o = /* @__PURE__ */ new Map();
|
|
1469
|
+
var t = Ce(e.children);
|
|
1470
|
+
e.revealOrder && e.revealOrder[0] === "b" && t.reverse();
|
|
1471
|
+
for (var n = t.length; n--; )
|
|
1472
|
+
this.o.set(t[n], this.u = [1, 0, this.u]);
|
|
1473
|
+
return e.children;
|
|
1474
|
+
}, me.prototype.componentDidUpdate = me.prototype.componentDidMount = function() {
|
|
1475
|
+
var e = this;
|
|
1476
|
+
this.o.forEach(function(t, n) {
|
|
1477
|
+
ut(e, n, t);
|
|
1478
|
+
});
|
|
1479
|
+
};
|
|
1480
|
+
var On = typeof Symbol < "u" && Symbol.for && Symbol.for("react.element") || 60103, En = /^(?: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]/, Zn = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, Wn = /[A-Z0-9]/g, Pn = typeof document < "u", Hn = function(e) {
|
|
1481
|
+
return (typeof Symbol < "u" && typeof Symbol() == "symbol" ? /fil|che|rad/ : /fil|che|ra/).test(e);
|
|
1482
|
+
};
|
|
1483
|
+
B.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(e) {
|
|
1484
|
+
Object.defineProperty(B.prototype, e, { configurable: !0, get: function() {
|
|
1485
|
+
return this["UNSAFE_" + e];
|
|
1486
|
+
}, set: function(t) {
|
|
1487
|
+
Object.defineProperty(this, e, { configurable: !0, writable: !0, value: t });
|
|
1488
|
+
} });
|
|
1489
|
+
});
|
|
1490
|
+
var gt = f.event;
|
|
1491
|
+
function Rn() {
|
|
1492
|
+
}
|
|
1493
|
+
function Un() {
|
|
1494
|
+
return this.cancelBubble;
|
|
1495
|
+
}
|
|
1496
|
+
function Bn() {
|
|
1497
|
+
return this.defaultPrevented;
|
|
1498
|
+
}
|
|
1499
|
+
f.event = function(e) {
|
|
1500
|
+
return gt && (e = gt(e)), e.persist = Rn, e.isPropagationStopped = Un, e.isDefaultPrevented = Bn, e.nativeEvent = e;
|
|
1501
|
+
};
|
|
1502
|
+
var $n = { enumerable: !1, configurable: !0, get: function() {
|
|
1503
|
+
return this.class;
|
|
1504
|
+
} }, pt = f.vnode;
|
|
1505
|
+
f.vnode = function(e) {
|
|
1506
|
+
typeof e.type == "string" && function(t) {
|
|
1507
|
+
var n = t.props, i = t.type, a = {};
|
|
1508
|
+
for (var o in n) {
|
|
1509
|
+
var s = n[o];
|
|
1510
|
+
if (!(o === "value" && "defaultValue" in n && s == null || Pn && o === "children" && i === "noscript" || o === "class" || o === "className")) {
|
|
1511
|
+
var c = o.toLowerCase();
|
|
1512
|
+
o === "defaultValue" && "value" in n && n.value == null ? o = "value" : o === "download" && s === !0 ? s = "" : c === "ondoubleclick" ? o = "ondblclick" : c !== "onchange" || i !== "input" && i !== "textarea" || Hn(n.type) ? c === "onfocus" ? o = "onfocusin" : c === "onblur" ? o = "onfocusout" : Zn.test(o) ? o = c : i.indexOf("-") === -1 && En.test(o) ? o = o.replace(Wn, "-$&").toLowerCase() : s === null && (s = void 0) : c = o = "oninput", c === "oninput" && a[o = c] && (o = "oninputCapture"), a[o] = s;
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
i == "select" && a.multiple && Array.isArray(a.value) && (a.value = Ce(n.children).forEach(function(l) {
|
|
1516
|
+
l.props.selected = a.value.indexOf(l.props.value) != -1;
|
|
1517
|
+
})), i == "select" && a.defaultValue != null && (a.value = Ce(n.children).forEach(function(l) {
|
|
1518
|
+
l.props.selected = a.multiple ? a.defaultValue.indexOf(l.props.value) != -1 : a.defaultValue == l.props.value;
|
|
1519
|
+
})), n.class && !n.className ? (a.class = n.class, Object.defineProperty(a, "className", $n)) : (n.className && !n.class || n.class && n.className) && (a.class = a.className = n.className), t.props = a;
|
|
1520
|
+
}(e), e.$$typeof = On, pt && pt(e);
|
|
1521
|
+
};
|
|
1522
|
+
var ft = f.__r;
|
|
1523
|
+
f.__r = function(e) {
|
|
1524
|
+
ft && ft(e), e.__c;
|
|
1525
|
+
};
|
|
1526
|
+
var ht = f.diffed;
|
|
1527
|
+
f.diffed = function(e) {
|
|
1528
|
+
ht && ht(e);
|
|
1529
|
+
var t = e.props, n = e.__e;
|
|
1530
|
+
n != null && e.type === "textarea" && "value" in t && t.value !== n.value && (n.value = t.value == null ? "" : t.value);
|
|
1531
|
+
};
|
|
1532
|
+
function Gn(e, t, n) {
|
|
1533
|
+
return e ? "var(--did-primary-black-00040)" : "var(--did-primary-black-00012)";
|
|
1534
|
+
}
|
|
1535
|
+
function mt({
|
|
1536
|
+
negative: e,
|
|
1537
|
+
toggled: t,
|
|
1538
|
+
onClick: n,
|
|
1539
|
+
disabled: i
|
|
1540
|
+
}) {
|
|
1541
|
+
const a = e === !0, o = {
|
|
1542
|
+
"--flip": a ? -1 : 1,
|
|
1543
|
+
"--hover-color": "var(--did-primary-black-00030)",
|
|
1544
|
+
"--color": Gn(t, a, i === !0),
|
|
1545
|
+
"--cursor": i === !0 ? "default" : "pointer"
|
|
1546
|
+
};
|
|
1547
|
+
return g("div", {
|
|
1548
|
+
className: "didagent__thumb__container",
|
|
1549
|
+
style: o,
|
|
1550
|
+
onClick: () => !i && (n == null ? void 0 : n(!t)),
|
|
1551
|
+
children: "👍"
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
const Yn = (e, t) => e === "up" ? t === Z.Positive ? Z.Unrated : Z.Positive : t === Z.Negative ? Z.Unrated : Z.Negative;
|
|
1555
|
+
function Fn({
|
|
1556
|
+
className: e,
|
|
1557
|
+
onRate: t,
|
|
1558
|
+
message: n,
|
|
1559
|
+
style: i
|
|
1560
|
+
}) {
|
|
1561
|
+
const [a, o] = b(Z.Unrated), [s, c] = b(), [l, d] = b(!1), {
|
|
1562
|
+
agentManager: p
|
|
1563
|
+
} = $(K);
|
|
1564
|
+
function r(_) {
|
|
1565
|
+
return async () => {
|
|
1566
|
+
var I, M;
|
|
1567
|
+
const u = Yn(_, a);
|
|
1568
|
+
o(u), d(!0);
|
|
1569
|
+
const m = await (t == null ? void 0 : t(u, n, s));
|
|
1570
|
+
P("agents-rating", {
|
|
1571
|
+
thumb: _,
|
|
1572
|
+
rate: u,
|
|
1573
|
+
agentId: (I = p == null ? void 0 : p.agent) == null ? void 0 : I.id,
|
|
1574
|
+
matches: ((M = n.matches) == null ? void 0 : M.map((h) => [h.document_id, h.id])) ?? []
|
|
1575
|
+
}), d(!1), c(m);
|
|
1576
|
+
};
|
|
1577
|
+
}
|
|
1578
|
+
return g("div", {
|
|
1579
|
+
className: `${e} didagent__rating`,
|
|
1580
|
+
style: i,
|
|
1581
|
+
children: [g(mt, {
|
|
1582
|
+
disabled: l,
|
|
1583
|
+
toggled: a === Z.Positive,
|
|
1584
|
+
onClick: r("up")
|
|
1585
|
+
}), g(mt, {
|
|
1586
|
+
disabled: l,
|
|
1587
|
+
negative: !0,
|
|
1588
|
+
toggled: a === Z.Negative,
|
|
1589
|
+
onClick: r("down")
|
|
1590
|
+
})]
|
|
1591
|
+
});
|
|
1592
|
+
}
|
|
1593
|
+
const Jn = ["Juggling thoughts and data...", "Processing, just a moment...", "Cooking up a response...", "Brainstorming potential answers...", "Let me look this up..."], It = ["Pondering the best reply...", "Processing, just a moment...", "Convincing my electrons to run faster...", "This is interesting..."], Vn = [{
|
|
1594
|
+
text: [""],
|
|
1595
|
+
duration: 2e3
|
|
1596
|
+
}, {
|
|
1597
|
+
text: ["Thinking..."],
|
|
1598
|
+
duration: 3e3
|
|
1599
|
+
}, {
|
|
1600
|
+
text: Jn,
|
|
1601
|
+
duration: 4e3
|
|
1602
|
+
}, {
|
|
1603
|
+
text: It,
|
|
1604
|
+
duration: 4e3
|
|
1605
|
+
}, {
|
|
1606
|
+
text: It,
|
|
1607
|
+
duration: 4e3
|
|
1608
|
+
}];
|
|
1609
|
+
function Qn(e) {
|
|
1610
|
+
return e[Math.floor(Math.random() * e.length)];
|
|
1611
|
+
}
|
|
1612
|
+
function Xn(e) {
|
|
1613
|
+
const [t, n] = b(e[0].text[0]), i = te(), a = (s = 0) => {
|
|
1614
|
+
s < e.length && !i.current && (i.current = setTimeout(() => {
|
|
1615
|
+
i.current = void 0;
|
|
1616
|
+
const c = (s + 1) % e.length;
|
|
1617
|
+
n(Qn(e[c].text)), a(c);
|
|
1618
|
+
}, e[s].duration));
|
|
1619
|
+
};
|
|
1620
|
+
return {
|
|
1621
|
+
text: t,
|
|
1622
|
+
doStep: a,
|
|
1623
|
+
clear: () => {
|
|
1624
|
+
clearTimeout(i.current), n(e[0].text[0]), i.current = void 0;
|
|
1625
|
+
}
|
|
1626
|
+
};
|
|
1627
|
+
}
|
|
1628
|
+
const Kn = "#b8b8b8", qn = xn(function({
|
|
1629
|
+
messages: e,
|
|
1630
|
+
isLoading: t,
|
|
1631
|
+
onRate: n
|
|
1632
|
+
}, i) {
|
|
1633
|
+
const {
|
|
1634
|
+
doStep: a,
|
|
1635
|
+
text: o,
|
|
1636
|
+
clear: s
|
|
1637
|
+
} = Xn(Vn);
|
|
1638
|
+
return H(() => t ? a() : s(), [t]), g("div", {
|
|
1639
|
+
className: "didagent__messages__container",
|
|
1640
|
+
ref: i,
|
|
1641
|
+
children: [e.filter(({
|
|
1642
|
+
content: c
|
|
1643
|
+
}) => !!c).map((c, l) => g("div", {
|
|
1644
|
+
className: `didagent__message__container didagent__message__container__${c.role}`,
|
|
1645
|
+
children: [g("pre", {
|
|
1646
|
+
className: `didagent__message didagent__message__${c.role}`,
|
|
1647
|
+
children: c.content
|
|
1648
|
+
}), l > 0 && c.role === "assistant" && g(Fn, {
|
|
1649
|
+
className: "didagent__message__rating",
|
|
1650
|
+
message: c,
|
|
1651
|
+
onRate: n,
|
|
1652
|
+
style: {
|
|
1653
|
+
opacity: l === e.length - 1 ? 1 : void 0
|
|
1654
|
+
}
|
|
1655
|
+
})]
|
|
1656
|
+
})), t && g("div", {
|
|
1657
|
+
className: "didagent__message__container didagent__message__container__assistant",
|
|
1658
|
+
children: g("pre", {
|
|
1659
|
+
className: "didagent__message didagent__message__assistant didagent__message__assistant__loader",
|
|
1660
|
+
children: [g(R, {
|
|
1661
|
+
src: Ot,
|
|
1662
|
+
color: Kn,
|
|
1663
|
+
size: "22px"
|
|
1664
|
+
}), o]
|
|
1665
|
+
})
|
|
1666
|
+
})]
|
|
1667
|
+
});
|
|
1668
|
+
});
|
|
1669
|
+
function ei({
|
|
1670
|
+
messages: e,
|
|
1671
|
+
onClick: t,
|
|
1672
|
+
show: n
|
|
1673
|
+
}) {
|
|
1674
|
+
const [i, a] = b(!1);
|
|
1675
|
+
return H(() => {
|
|
1676
|
+
n && setTimeout(() => {
|
|
1677
|
+
a(!0);
|
|
1678
|
+
}, 2e3);
|
|
1679
|
+
}, [n]), n ? g("div", {
|
|
1680
|
+
className: "didagent__starter_messages__container",
|
|
1681
|
+
style: {
|
|
1682
|
+
maxHeight: i ? "120px" : "0"
|
|
1683
|
+
},
|
|
1684
|
+
children: e.map((o) => g("div", {
|
|
1685
|
+
className: "didagent__starter_message__container",
|
|
1686
|
+
onClick: () => t(o),
|
|
1687
|
+
children: o
|
|
1688
|
+
}, o))
|
|
1689
|
+
}) : null;
|
|
1690
|
+
}
|
|
1691
|
+
function ti({
|
|
1692
|
+
size: e = 40
|
|
1693
|
+
}) {
|
|
1694
|
+
const t = `${-e / 2}px`;
|
|
1695
|
+
return g("div", {
|
|
1696
|
+
className: "didagent__video_blur",
|
|
1697
|
+
children: [g("div", {
|
|
1698
|
+
className: "didagent__video_blur__position didagent__video_blur__position_right",
|
|
1699
|
+
style: {
|
|
1700
|
+
top: 0,
|
|
1701
|
+
right: t,
|
|
1702
|
+
width: `${e}px`,
|
|
1703
|
+
height: "100%"
|
|
1704
|
+
},
|
|
1705
|
+
children: [g("div", {
|
|
1706
|
+
className: "didagent__video_blur__inner_v"
|
|
1707
|
+
}), g("div", {
|
|
1708
|
+
className: "didagent__video_blur__outer"
|
|
1709
|
+
})]
|
|
1710
|
+
}), g("div", {
|
|
1711
|
+
className: "didagent__video_blur__position didagent__video_blur__position_left",
|
|
1712
|
+
style: {
|
|
1713
|
+
top: 0,
|
|
1714
|
+
left: t,
|
|
1715
|
+
width: `${e}px`,
|
|
1716
|
+
height: "100%"
|
|
1717
|
+
},
|
|
1718
|
+
children: [g("div", {
|
|
1719
|
+
className: "didagent__video_blur__inner_v"
|
|
1720
|
+
}), g("div", {
|
|
1721
|
+
className: "didagent__video_blur__outer"
|
|
1722
|
+
})]
|
|
1723
|
+
}), g("div", {
|
|
1724
|
+
className: "didagent__video_blur__position didagent__video_blur__position_bottom",
|
|
1725
|
+
style: {
|
|
1726
|
+
bottom: t,
|
|
1727
|
+
left: 0,
|
|
1728
|
+
width: "100%",
|
|
1729
|
+
height: `${e}px`
|
|
1730
|
+
},
|
|
1731
|
+
children: [g("div", {
|
|
1732
|
+
className: "didagent__video_blur__inner_h"
|
|
1733
|
+
}), g("div", {
|
|
1734
|
+
className: "didagent__video_blur__outer"
|
|
1735
|
+
})]
|
|
1736
|
+
})]
|
|
1737
|
+
});
|
|
1738
|
+
}
|
|
1739
|
+
function ni({
|
|
1740
|
+
streamState: e,
|
|
1741
|
+
srcObject: t,
|
|
1742
|
+
idleVideo: n,
|
|
1743
|
+
isBlur: i,
|
|
1744
|
+
onVideoPlay: a,
|
|
1745
|
+
onVideoStop: o,
|
|
1746
|
+
onIdleLoad: s
|
|
1747
|
+
}) {
|
|
1748
|
+
const c = te(null), l = te(), [d, p] = b(0);
|
|
1749
|
+
return H(() => {
|
|
1750
|
+
t && c.current && (l.current = t);
|
|
1751
|
+
}, [t, c.current]), H(() => {
|
|
1752
|
+
c.current && (e === L.Start ? c.current.srcObject = l.current : (p(0), setTimeout(() => {
|
|
1753
|
+
c.current && (c.current.srcObject = null);
|
|
1754
|
+
}, 1e3)));
|
|
1755
|
+
}, [e]), g("div", {
|
|
1756
|
+
className: `didagent__embedded__video__container ${i ? "didagent__embedded__video__maintainance" : ""}`,
|
|
1757
|
+
children: [g("video", {
|
|
1758
|
+
onPlay: (r) => {
|
|
1759
|
+
p(1), a == null || a();
|
|
1760
|
+
},
|
|
1761
|
+
ref: c,
|
|
1762
|
+
autoPlay: !0,
|
|
1763
|
+
playsInline: !0,
|
|
1764
|
+
onAbort: (r) => o == null ? void 0 : o(r),
|
|
1765
|
+
onPause: (r) => o == null ? void 0 : o(r),
|
|
1766
|
+
style: {
|
|
1767
|
+
opacity: d
|
|
1768
|
+
}
|
|
1769
|
+
}), g("video", {
|
|
1770
|
+
autoplay: !0,
|
|
1771
|
+
onLoadedData: s,
|
|
1772
|
+
playsinline: !0,
|
|
1773
|
+
src: n,
|
|
1774
|
+
muted: !0,
|
|
1775
|
+
loop: !0,
|
|
1776
|
+
style: {
|
|
1777
|
+
opacity: 1 - d
|
|
1778
|
+
}
|
|
1779
|
+
}), g(ti, {})]
|
|
1780
|
+
});
|
|
1781
|
+
}
|
|
1782
|
+
let ke = [], je = 0;
|
|
1783
|
+
function ii({
|
|
1784
|
+
offline: e,
|
|
1785
|
+
styles: t,
|
|
1786
|
+
onClose: n
|
|
1787
|
+
}) {
|
|
1788
|
+
var Be, $e;
|
|
1789
|
+
const {
|
|
1790
|
+
isAuthenticated: i
|
|
1791
|
+
} = $(ae), {
|
|
1792
|
+
terminate: a,
|
|
1793
|
+
setStreamState: o,
|
|
1794
|
+
streamedMessage: s,
|
|
1795
|
+
starterMessage: c,
|
|
1796
|
+
streamState: l,
|
|
1797
|
+
connectionState: d,
|
|
1798
|
+
chatMode: p,
|
|
1799
|
+
setChatMode: r,
|
|
1800
|
+
agentManager: _,
|
|
1801
|
+
srcObject: u,
|
|
1802
|
+
connect: m
|
|
1803
|
+
} = $(K), I = te(null), M = te(null), [h, w] = b(""), [A, T] = b([]), [v, x] = b(
|
|
1804
|
+
"Unrevealed"
|
|
1805
|
+
/* Unrevealed */
|
|
1806
|
+
), [z, O] = b(!1), [S, k] = b(!1), [j, W] = b(!1), [U, Le] = b(!1);
|
|
1807
|
+
function ge() {
|
|
1808
|
+
s && T((C) => {
|
|
1809
|
+
const G = C.pop();
|
|
1810
|
+
return G ? [...C, {
|
|
1811
|
+
...G,
|
|
1812
|
+
content: s
|
|
1813
|
+
}] : C;
|
|
1814
|
+
});
|
|
1815
|
+
}
|
|
1816
|
+
H(() => {
|
|
1817
|
+
u && I.current && (I.current.srcObject = u), window.onbeforeunload = (C) => {
|
|
1818
|
+
a().then(() => console.log("terminated"));
|
|
1819
|
+
};
|
|
1820
|
+
}, [a, u]), fn(() => {
|
|
1821
|
+
var C;
|
|
1822
|
+
(C = M.current) != null && C.lastElementChild && M.current.scrollTo({
|
|
1823
|
+
top: M.current.lastElementChild.offsetTop - M.current.offsetTop - 5,
|
|
1824
|
+
behavior: "smooth"
|
|
1825
|
+
});
|
|
1826
|
+
}, [A, S]), H(() => {
|
|
1827
|
+
_ != null && _.agent && (ke = [{
|
|
1828
|
+
role: "assistant",
|
|
1829
|
+
content: `Hi! I'm ${_ == null ? void 0 : _.agent.preview_name}, welcome to agents. How can I help you?`,
|
|
1830
|
+
created_at: he()
|
|
1831
|
+
}], T(ke));
|
|
1832
|
+
}, [_ == null ? void 0 : _.agent]), H(() => {
|
|
1833
|
+
var C;
|
|
1834
|
+
l === L.Start ? P("agent-video", {
|
|
1835
|
+
event: "start",
|
|
1836
|
+
chatId: _ == null ? void 0 : _.chatId,
|
|
1837
|
+
messages: A.length + 1,
|
|
1838
|
+
latency: Date.now() - je,
|
|
1839
|
+
agent_id: (C = _ == null ? void 0 : _.agent) == null ? void 0 : C.id
|
|
1840
|
+
}) : [L.Buffering, L.Loading].includes(l) ? k(!0) : [L.New, L.Fail].includes(l) && (k(!1), ge());
|
|
1841
|
+
}, [l]), H(() => {
|
|
1842
|
+
j && (k(!1), ge());
|
|
1843
|
+
}, [j, s]);
|
|
1844
|
+
function Ht() {
|
|
1845
|
+
var C;
|
|
1846
|
+
return _ != null && _.agent ? ((C = _.agent) == null ? void 0 : C.preview_name) ?? "Agent" : d === N.Fail ? "" : "Loading...";
|
|
1847
|
+
}
|
|
1848
|
+
async function pe(C) {
|
|
1849
|
+
var F, oe, re;
|
|
1850
|
+
if (i) {
|
|
1851
|
+
if (p !== E.TextOnly && (!M.current || C.trim().length === 0 || ![L.New].includes(l) || ![N.Connected].includes(d)))
|
|
1852
|
+
return;
|
|
1853
|
+
} else
|
|
1854
|
+
return P("agent-offline-onsend", {
|
|
1855
|
+
event: "click"
|
|
1856
|
+
}), e == null ? void 0 : e.onSend(h);
|
|
1857
|
+
const G = [...A, {
|
|
1858
|
+
role: "user",
|
|
1859
|
+
content: C.trim(),
|
|
1860
|
+
created_at: he()
|
|
1861
|
+
}];
|
|
1862
|
+
w(""), o(L.Loading), T(G);
|
|
1863
|
+
try {
|
|
1864
|
+
je = Date.now(), P("agent-message-send", {
|
|
1865
|
+
event: "success",
|
|
1866
|
+
messages: A.length + 1,
|
|
1867
|
+
agent_id: (F = _ == null ? void 0 : _.agent) == null ? void 0 : F.id,
|
|
1868
|
+
chatId: _ == null ? void 0 : _.chatId
|
|
1869
|
+
});
|
|
1870
|
+
const y = await (_ == null ? void 0 : _.chat(G));
|
|
1871
|
+
if (y != null && y.chatMode && r(y == null ? void 0 : y.chatMode), (y == null ? void 0 : y.chatMode) === E.Maintainance) {
|
|
1872
|
+
a();
|
|
1873
|
+
return;
|
|
1874
|
+
}
|
|
1875
|
+
if ((y == null ? void 0 : y.chatMode) === E.TextOnly ? T((q) => [...q, {
|
|
1876
|
+
role: "assistant",
|
|
1877
|
+
content: (y == null ? void 0 : y.result) || "",
|
|
1878
|
+
created_at: he(),
|
|
1879
|
+
matches: y == null ? void 0 : y.matches
|
|
1880
|
+
}]) : T((q) => [...q, {
|
|
1881
|
+
role: "assistant",
|
|
1882
|
+
content: "",
|
|
1883
|
+
created_at: he(),
|
|
1884
|
+
matches: y == null ? void 0 : y.matches
|
|
1885
|
+
}]), !y)
|
|
1886
|
+
throw new Error("Error in creating chat response");
|
|
1887
|
+
P("agent-message-received", {
|
|
1888
|
+
agent_id: (oe = _ == null ? void 0 : _.agent) == null ? void 0 : oe.id,
|
|
1889
|
+
latency: Date.now() - je,
|
|
1890
|
+
messages: A.length + 1,
|
|
1891
|
+
chatId: _ == null ? void 0 : _.chatId
|
|
1892
|
+
}), (y == null ? void 0 : y.chatMode) === E.TextOnly ? o(L.New) : o(L.Buffering);
|
|
1893
|
+
} catch (y) {
|
|
1894
|
+
throw o(L.New), P("agent-message-send", {
|
|
1895
|
+
event: "fail",
|
|
1896
|
+
messages: A.length,
|
|
1897
|
+
agent_id: (re = _ == null ? void 0 : _.agent) == null ? void 0 : re.id,
|
|
1898
|
+
chatId: _ == null ? void 0 : _.chatId
|
|
1899
|
+
}), y;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
async function Rt(C, G, F) {
|
|
1903
|
+
var oe, re, y, q;
|
|
1904
|
+
if (!(!((re = (oe = _ == null ? void 0 : _.agent) == null ? void 0 : oe.knowledge) != null && re.id) || !_.chatId))
|
|
1905
|
+
if (F)
|
|
1906
|
+
if (C === Z.Unrated)
|
|
1907
|
+
await _.deleteRate(F);
|
|
1908
|
+
else
|
|
1909
|
+
return await _.rate({
|
|
1910
|
+
score: C === Z.Positive ? 1 : -1,
|
|
1911
|
+
knowledge_id: _.agent.knowledge.id,
|
|
1912
|
+
chat_id: _.chatId,
|
|
1913
|
+
agent_id: _.agent.id,
|
|
1914
|
+
matches: ((y = G.matches) == null ? void 0 : y.map((ce) => [ce.document_id, ce.id])) ?? []
|
|
1915
|
+
}, F), F;
|
|
1916
|
+
else {
|
|
1917
|
+
const ce = await _.rate({
|
|
1918
|
+
score: C === Z.Positive ? 1 : -1,
|
|
1919
|
+
knowledge_id: _.agent.knowledge.id,
|
|
1920
|
+
chat_id: _.chatId,
|
|
1921
|
+
agent_id: _.agent.id,
|
|
1922
|
+
matches: ((q = G.matches) == null ? void 0 : q.map((Ge) => [Ge.document_id, Ge.id])) ?? []
|
|
1923
|
+
});
|
|
1924
|
+
if (!ce)
|
|
1925
|
+
throw new Error("Error in creating rating");
|
|
1926
|
+
return ce.id;
|
|
1927
|
+
}
|
|
1928
|
+
}
|
|
1929
|
+
const Ut = ot(() => {
|
|
1930
|
+
if (v === "Unrevealed") {
|
|
1931
|
+
x(
|
|
1932
|
+
"Displayed"
|
|
1933
|
+
/* Displayed */
|
|
1934
|
+
);
|
|
1935
|
+
const C = setTimeout(() => x(
|
|
1936
|
+
"Hidden"
|
|
1937
|
+
/* Hidden */
|
|
1938
|
+
), 3e3);
|
|
1939
|
+
return () => clearTimeout(C);
|
|
1940
|
+
}
|
|
1941
|
+
}, [v]), Ue = ot(async () => {
|
|
1942
|
+
var C;
|
|
1943
|
+
await a(), T(ke), await m(), P("agent-new-chat", {
|
|
1944
|
+
event: "click",
|
|
1945
|
+
agentId: (C = _ == null ? void 0 : _.agent) == null ? void 0 : C.id,
|
|
1946
|
+
chatId: _ == null ? void 0 : _.chatId
|
|
1947
|
+
});
|
|
1948
|
+
}, [_]), Bt = z || p === E.Maintainance;
|
|
1949
|
+
return g("div", {
|
|
1950
|
+
className: `didagent__embedded__container ${U ? "didagent__fullscreen" : ""}`,
|
|
1951
|
+
children: [g("div", {
|
|
1952
|
+
className: "didagent__embedded__container__connecting",
|
|
1953
|
+
style: {
|
|
1954
|
+
opacity: +!Bt
|
|
1955
|
+
},
|
|
1956
|
+
children: [g(R, {
|
|
1957
|
+
src: bn,
|
|
1958
|
+
size: "64px",
|
|
1959
|
+
color: "var(--did-primary-black-50)"
|
|
1960
|
+
}), g("span", {
|
|
1961
|
+
children: "Starting conversation..."
|
|
1962
|
+
})]
|
|
1963
|
+
}), g("div", {
|
|
1964
|
+
className: "didagent__background",
|
|
1965
|
+
style: {
|
|
1966
|
+
background: `url(${_ == null ? void 0 : _.agent.preview_thumbnail}) top center no-repeat transparent`
|
|
1967
|
+
}
|
|
1968
|
+
}), g(ni, {
|
|
1969
|
+
streamState: l,
|
|
1970
|
+
srcObject: u,
|
|
1971
|
+
idleVideo: ($e = (Be = _ == null ? void 0 : _.agent) == null ? void 0 : Be.presenter) == null ? void 0 : $e.idle_video,
|
|
1972
|
+
isBlur: p === E.Maintainance,
|
|
1973
|
+
onVideoPlay: () => W(!0),
|
|
1974
|
+
onVideoStop: () => W(!1),
|
|
1975
|
+
onIdleLoad: () => O(!0)
|
|
1976
|
+
}), g(An, {
|
|
1977
|
+
name: Ht(),
|
|
1978
|
+
agent: _ == null ? void 0 : _.agent,
|
|
1979
|
+
displayRestart: A.length > 1,
|
|
1980
|
+
onRestart: Ue,
|
|
1981
|
+
restartDisabled: ![N.Connected, N.New].includes(d),
|
|
1982
|
+
isRestarting: d === N.Terminating,
|
|
1983
|
+
closeClassName: t == null ? void 0 : t.closeClassName,
|
|
1984
|
+
onClose: n,
|
|
1985
|
+
onEasterEgg: () => Le(!U)
|
|
1986
|
+
}), p !== E.Maintainance && g(Q, {
|
|
1987
|
+
children: [g(qn, {
|
|
1988
|
+
messages: A,
|
|
1989
|
+
isLoading: S,
|
|
1990
|
+
ref: M,
|
|
1991
|
+
onRate: Rt
|
|
1992
|
+
}), g(ei, {
|
|
1993
|
+
show: A.length <= 1 && z,
|
|
1994
|
+
messages: c,
|
|
1995
|
+
onClick: pe
|
|
1996
|
+
}), g("div", {
|
|
1997
|
+
className: "didagent__main__input",
|
|
1998
|
+
children: [g("div", {
|
|
1999
|
+
className: "didagent__main__input__container",
|
|
2000
|
+
children: [g("div", {
|
|
2001
|
+
className: "didagent__box__blur border8"
|
|
2002
|
+
}), g("input", {
|
|
2003
|
+
type: "text",
|
|
2004
|
+
placeholder: "Send message",
|
|
2005
|
+
value: h,
|
|
2006
|
+
onInput: (C) => w(C.currentTarget.value),
|
|
2007
|
+
onKeyPress: (C) => C.key === "Enter" && pe(h),
|
|
2008
|
+
onMouseOver: Ut
|
|
2009
|
+
})]
|
|
2010
|
+
}), g(kn, {
|
|
2011
|
+
onRestart: Ue,
|
|
2012
|
+
onSend: () => pe(h),
|
|
2013
|
+
onTranscript: pe,
|
|
2014
|
+
text: h
|
|
2015
|
+
})]
|
|
2016
|
+
})]
|
|
2017
|
+
})]
|
|
2018
|
+
});
|
|
2019
|
+
}
|
|
2020
|
+
function ai({
|
|
2021
|
+
onApiReady: e,
|
|
2022
|
+
children: t
|
|
2023
|
+
}) {
|
|
2024
|
+
const {
|
|
2025
|
+
terminate: n,
|
|
2026
|
+
connectionState: i,
|
|
2027
|
+
agentManager: a
|
|
2028
|
+
} = $(K), {
|
|
2029
|
+
authenticate: o
|
|
2030
|
+
} = $(ae);
|
|
2031
|
+
return H(() => {
|
|
2032
|
+
e && e({
|
|
2033
|
+
agent: a == null ? void 0 : a.agent,
|
|
2034
|
+
disconnect: n,
|
|
2035
|
+
connectionState: i,
|
|
2036
|
+
authenticate: o
|
|
2037
|
+
});
|
|
2038
|
+
}, [a, i, n, o]), t;
|
|
2039
|
+
}
|
|
2040
|
+
function oi({
|
|
2041
|
+
agentId: e,
|
|
2042
|
+
auth: t,
|
|
2043
|
+
onApiReady: n,
|
|
2044
|
+
offline: i,
|
|
2045
|
+
isOwner: a,
|
|
2046
|
+
mode: o,
|
|
2047
|
+
track: s,
|
|
2048
|
+
didApiUrl: c,
|
|
2049
|
+
didSocketApiUrl: l,
|
|
2050
|
+
onerror: d,
|
|
2051
|
+
customMixpanelKey: p,
|
|
2052
|
+
styles: r,
|
|
2053
|
+
onClose: _
|
|
2054
|
+
}) {
|
|
2055
|
+
return window.localStorage.setItem("track_enabled", (s ?? !0).toString()), Ze.mixpanelKey = p || Ze.mixpanelKey, H(() => {
|
|
2056
|
+
function u(m) {
|
|
2057
|
+
d && (m.preventDefault(), d == null || d(m.reason));
|
|
2058
|
+
}
|
|
2059
|
+
return window.addEventListener("unhandledrejection", u), () => window.removeEventListener("unhandledrejection", u);
|
|
2060
|
+
}, []), g(wn, {
|
|
2061
|
+
auth: t,
|
|
2062
|
+
didApiUrl: c ?? Qt,
|
|
2063
|
+
didSocketApiUrl: l ?? Xt,
|
|
2064
|
+
children: g(yn, {
|
|
2065
|
+
agentId: e,
|
|
2066
|
+
children: g(ai, {
|
|
2067
|
+
onApiReady: n,
|
|
2068
|
+
children: g(ii, {
|
|
2069
|
+
mode: o,
|
|
2070
|
+
offline: i,
|
|
2071
|
+
isOwner: a,
|
|
2072
|
+
styles: r,
|
|
2073
|
+
onClose: _
|
|
2074
|
+
})
|
|
2075
|
+
})
|
|
2076
|
+
})
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
function ci(e, t, n = (i) => {
|
|
2080
|
+
}) {
|
|
2081
|
+
Vt(g(oi, {
|
|
2082
|
+
...t,
|
|
2083
|
+
onApiReady: n
|
|
2084
|
+
}), e);
|
|
2085
|
+
}
|
|
2086
|
+
function ri() {
|
|
2087
|
+
let e = window.localStorage.getItem("external_key_d_id");
|
|
2088
|
+
return e || (e = Math.random().toString(16).slice(2), window.localStorage.setItem("external_key_d_id", e)), e;
|
|
2089
|
+
}
|
|
2090
|
+
function si(e) {
|
|
2091
|
+
const {
|
|
2092
|
+
token: t,
|
|
2093
|
+
username: n,
|
|
2094
|
+
password: i,
|
|
2095
|
+
clientKey: a
|
|
2096
|
+
} = e;
|
|
2097
|
+
if (!a) {
|
|
2098
|
+
if (!t) {
|
|
2099
|
+
if (!n || !i)
|
|
2100
|
+
throw new Error("Failed to load agent. No auth method provided");
|
|
2101
|
+
return {
|
|
2102
|
+
type: "basic",
|
|
2103
|
+
username: n,
|
|
2104
|
+
password: i
|
|
2105
|
+
};
|
|
2106
|
+
}
|
|
2107
|
+
return {
|
|
2108
|
+
type: "bearer",
|
|
2109
|
+
token: t
|
|
2110
|
+
};
|
|
2111
|
+
}
|
|
2112
|
+
let o = ri();
|
|
2113
|
+
return {
|
|
2114
|
+
type: "key",
|
|
2115
|
+
clientKey: a,
|
|
2116
|
+
externalId: o
|
|
2117
|
+
};
|
|
2118
|
+
}
|
|
2119
|
+
export {
|
|
2120
|
+
si as getAuth,
|
|
2121
|
+
ci as init
|
|
2122
|
+
};
|