deep-chat-dev 9.0.157 → 9.0.159
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/custom-elements.json +1365 -1297
- package/dist/deepChat.bundle.js +1 -1
- package/dist/deepChat.d.ts.map +1 -1
- package/dist/deepChat.js +977 -966
- package/dist/services/openAI/openAIAssistantIO.d.ts.map +1 -1
- package/dist/services/openAI/utils/openAIAssistantFiles.d.ts +8 -1
- package/dist/services/openAI/utils/openAIAssistantFiles.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/deepChat.js
CHANGED
@@ -253,29 +253,29 @@ var us = /*#__PURE__*/function () {
|
|
253
253
|
}
|
254
254
|
}]);
|
255
255
|
}();
|
256
|
-
var
|
257
|
-
function
|
256
|
+
var Ae = /*#__PURE__*/function () {
|
257
|
+
function Ae(e, t) {
|
258
258
|
var _this = this;
|
259
|
-
_classCallCheck(this,
|
259
|
+
_classCallCheck(this, Ae);
|
260
260
|
var n;
|
261
|
-
var i =
|
262
|
-
this.elementRef =
|
261
|
+
var i = Ae.processConfig(t, e.textInput);
|
262
|
+
this.elementRef = Ae.createContainerElement((n = i == null ? void 0 : i.styles) == null ? void 0 : n.container), this.inputElementRef = this.createInputElement(i), this._config = i, this.elementRef.appendChild(this.inputElementRef), setTimeout(function () {
|
263
263
|
var r;
|
264
264
|
Gi.add(_this.inputElementRef, (r = e.textInput) == null ? void 0 : r.characterLimit, e._validationHandler);
|
265
265
|
});
|
266
266
|
}
|
267
|
-
return _createClass(
|
267
|
+
return _createClass(Ae, [{
|
268
268
|
key: "createInputElement",
|
269
269
|
value: function createInputElement(e) {
|
270
270
|
var i, n, r;
|
271
271
|
var t = document.createElement("div");
|
272
|
-
return t.id =
|
272
|
+
return t.id = Ae.TEXT_INPUT_ID, t.classList.add("text-input-styling", "text-input-placeholder"), t.innerText = ((i = e == null ? void 0 : e.placeholder) == null ? void 0 : i.text) || "Ask me anything!", st.IS_CHROMIUM && Ae.preventAutomaticScrollUpOnNewLine(t), typeof (e == null ? void 0 : e.disabled) == "boolean" && e.disabled === !0 ? (t.contentEditable = "false", t.classList.add("text-input-disabled")) : (t.contentEditable = "true", this.addEventListeners(t, e)), Object.assign(t.style, (n = e == null ? void 0 : e.styles) == null ? void 0 : n.text), Object.assign(t.style, (r = e == null ? void 0 : e.placeholder) == null ? void 0 : r.style), t;
|
273
273
|
}
|
274
274
|
}, {
|
275
275
|
key: "removeTextIfPlaceholder",
|
276
276
|
value: function removeTextIfPlaceholder() {
|
277
277
|
var e, t, i, n;
|
278
|
-
this.inputElementRef.classList.contains("text-input-placeholder") && !this.inputElementRef.classList.contains("text-input-disabled") && ((e = this._config.placeholder) != null && e.style && (M.unsetStyle(this.inputElementRef, (t = this._config.placeholder) == null ? void 0 : t.style), Object.assign(this.inputElementRef.style, (n = (i = this._config) == null ? void 0 : i.styles) == null ? void 0 : n.text)),
|
278
|
+
this.inputElementRef.classList.contains("text-input-placeholder") && !this.inputElementRef.classList.contains("text-input-disabled") && ((e = this._config.placeholder) != null && e.style && (M.unsetStyle(this.inputElementRef, (t = this._config.placeholder) == null ? void 0 : t.style), Object.assign(this.inputElementRef.style, (n = (i = this._config) == null ? void 0 : i.styles) == null ? void 0 : n.text)), Ae.clear(this.inputElementRef), this.inputElementRef.classList.remove("text-input-placeholder"));
|
279
279
|
}
|
280
280
|
}, {
|
281
281
|
key: "addEventListeners",
|
@@ -348,8 +348,8 @@ var ke = /*#__PURE__*/function () {
|
|
348
348
|
}
|
349
349
|
}]);
|
350
350
|
}();
|
351
|
-
|
352
|
-
var
|
351
|
+
Ae.TEXT_INPUT_ID = "text-input";
|
352
|
+
var Tt = Ae;
|
353
353
|
var yi = /*#__PURE__*/function () {
|
354
354
|
function yi() {
|
355
355
|
_classCallCheck(this, yi);
|
@@ -365,7 +365,7 @@ var yi = /*#__PURE__*/function () {
|
|
365
365
|
}, {
|
366
366
|
key: "focusFromParentElement",
|
367
367
|
value: function focusFromParentElement(e) {
|
368
|
-
var t = e.querySelector("#".concat(
|
368
|
+
var t = e.querySelector("#".concat(Tt.TEXT_INPUT_ID));
|
369
369
|
t && yi.focusEndOfInput(t);
|
370
370
|
}
|
371
371
|
}]);
|
@@ -477,11 +477,11 @@ var bi = /*#__PURE__*/function () {
|
|
477
477
|
}();
|
478
478
|
bi.LOAD_VOICES_MS = 200;
|
479
479
|
var rt = bi;
|
480
|
-
var
|
481
|
-
function
|
482
|
-
_classCallCheck(this,
|
480
|
+
var he = /*#__PURE__*/function () {
|
481
|
+
function he() {
|
482
|
+
_classCallCheck(this, he);
|
483
483
|
}
|
484
|
-
return _createClass(
|
484
|
+
return _createClass(he, null, [{
|
485
485
|
key: "checkForContainerStyles",
|
486
486
|
value: function checkForContainerStyles(e, t) {
|
487
487
|
var i = e.containerStyle;
|
@@ -603,15 +603,15 @@ var bs = "data:image/svg+xml,%3c?xml%20version='1.0'%20encoding='iso-8859-1'?%3e
|
|
603
603
|
}();
|
604
604
|
ee.CONTAINER_CLASS = "avatar-container";
|
605
605
|
var Zt = ee;
|
606
|
-
var
|
607
|
-
function
|
608
|
-
_classCallCheck(this,
|
606
|
+
var ge = /*#__PURE__*/function () {
|
607
|
+
function ge() {
|
608
|
+
_classCallCheck(this, ge);
|
609
609
|
}
|
610
|
-
return _createClass(
|
610
|
+
return _createClass(ge, null, [{
|
611
611
|
key: "hide",
|
612
612
|
value: function hide(e) {
|
613
613
|
var t;
|
614
|
-
(t = e.getElementsByClassName(
|
614
|
+
(t = e.getElementsByClassName(ge.NAME_CLASS)[0].style).visibility || (t.visibility = "hidden");
|
615
615
|
}
|
616
616
|
}, {
|
617
617
|
key: "getPosition",
|
@@ -637,20 +637,20 @@ var me = /*#__PURE__*/function () {
|
|
637
637
|
key: "createName",
|
638
638
|
value: function createName(e, t) {
|
639
639
|
var i = document.createElement("div");
|
640
|
-
return i.classList.add(
|
640
|
+
return i.classList.add(ge.NAME_CLASS), i.textContent = ge.getNameText(e, t), ge.applyStyle(i, e, t), i;
|
641
641
|
}
|
642
642
|
}, {
|
643
643
|
key: "add",
|
644
644
|
value: function add(e, t, i) {
|
645
645
|
var n = typeof i == "boolean" ? {} : i,
|
646
|
-
r =
|
647
|
-
o =
|
646
|
+
r = ge.createName(t, n),
|
647
|
+
o = ge.getPosition(t, n);
|
648
648
|
r.classList.add(o === "left" ? "left-item-position" : "right-item-position"), e.insertAdjacentElement(o === "left" ? "beforebegin" : "afterend", r);
|
649
649
|
}
|
650
650
|
}]);
|
651
651
|
}();
|
652
|
-
|
653
|
-
var Yt =
|
652
|
+
ge.NAME_CLASS = "name";
|
653
|
+
var Yt = ge;
|
654
654
|
var re = /*#__PURE__*/function () {
|
655
655
|
function re() {
|
656
656
|
_classCallCheck(this, re);
|
@@ -859,7 +859,7 @@ var Le = /*#__PURE__*/function () {
|
|
859
859
|
var o = i.getElementsByClassName(r);
|
860
860
|
Array.from(o || []).forEach(function (a) {
|
861
861
|
var l = Le.getProcessedStyles(t, a, r);
|
862
|
-
|
862
|
+
fe.applyStylesToElement(a, l), Le.applyEvents(a, r);
|
863
863
|
});
|
864
864
|
});
|
865
865
|
var n = i.getElementsByClassName(Es);
|
@@ -869,11 +869,11 @@ var Le = /*#__PURE__*/function () {
|
|
869
869
|
}
|
870
870
|
}]);
|
871
871
|
}();
|
872
|
-
var
|
873
|
-
function
|
874
|
-
_classCallCheck(this,
|
872
|
+
var fe = /*#__PURE__*/function () {
|
873
|
+
function fe() {
|
874
|
+
_classCallCheck(this, fe);
|
875
875
|
}
|
876
|
-
return _createClass(
|
876
|
+
return _createClass(fe, null, [{
|
877
877
|
key: "applyStylesToElement",
|
878
878
|
value: function applyStylesToElement(e, t) {
|
879
879
|
var i = M.processStateful(t, {}, {});
|
@@ -892,7 +892,7 @@ var ue = /*#__PURE__*/function () {
|
|
892
892
|
value: function applyClassUtilitiesToElement(e, t) {
|
893
893
|
var i = t.events,
|
894
894
|
n = t.styles;
|
895
|
-
i &&
|
895
|
+
i && fe.applyEventsToElement(e, i), n && !Le.doesElementContainDeepChatClass(e) && fe.applyStylesToElement(e, n);
|
896
896
|
}
|
897
897
|
}, {
|
898
898
|
key: "applyCustomClassUtilities",
|
@@ -900,14 +900,14 @@ var ue = /*#__PURE__*/function () {
|
|
900
900
|
Object.keys(e).forEach(function (i) {
|
901
901
|
var n = t.getElementsByClassName(i);
|
902
902
|
Array.from(n).forEach(function (r) {
|
903
|
-
e[i] &&
|
903
|
+
e[i] && fe.applyClassUtilitiesToElement(r, e[i]);
|
904
904
|
});
|
905
905
|
});
|
906
906
|
}
|
907
907
|
}, {
|
908
908
|
key: "apply",
|
909
909
|
value: function apply(e, t) {
|
910
|
-
Le.applyDeepChatUtilities(e, e.htmlClassUtilities, t),
|
910
|
+
Le.applyDeepChatUtilities(e, e.htmlClassUtilities, t), fe.applyCustomClassUtilities(e.htmlClassUtilities, t);
|
911
911
|
}
|
912
912
|
}]);
|
913
913
|
}();
|
@@ -931,7 +931,7 @@ var ct = /*#__PURE__*/function () {
|
|
931
931
|
value: function overwrite(e, t, i, n) {
|
932
932
|
var r = e.messages,
|
933
933
|
o = b.overwriteMessage(r, n, t, i, "html", "html-message");
|
934
|
-
return o && (o.bubbleElement.innerHTML = t,
|
934
|
+
return o && (o.bubbleElement.innerHTML = t, fe.apply(e, o.outerContainer), he.flagHTMLUpdateClass(o.bubbleElement)), o;
|
935
935
|
}
|
936
936
|
// prettier-ignore
|
937
937
|
}, {
|
@@ -944,7 +944,7 @@ var ct = /*#__PURE__*/function () {
|
|
944
944
|
r.status = !1;
|
945
945
|
}
|
946
946
|
var o = ct.createElements(e, t, i);
|
947
|
-
return b.fillEmptyMessageElement(o.bubbleElement, t),
|
947
|
+
return b.fillEmptyMessageElement(o.bubbleElement, t), fe.apply(e, o.outerContainer), he.flagHTMLUpdateClass(o.bubbleElement), e.applyCustomStyles(o, i, !1, (a = e.messageStyles) == null ? void 0 : a.html), ct.addElement(e, o.outerContainer), o;
|
948
948
|
}
|
949
949
|
}]);
|
950
950
|
}();
|
@@ -984,14 +984,14 @@ function $i(s) {
|
|
984
984
|
return String.fromCharCode(s);
|
985
985
|
}
|
986
986
|
var ws = /&([a-z#][a-z0-9]{1,31});/gi,
|
987
|
-
|
988
|
-
function
|
987
|
+
Cs = /^#((?:x[a-f0-9]{1,8}|[0-9]{1,8}))/i;
|
988
|
+
function Ts(s, e) {
|
989
989
|
var t = 0,
|
990
990
|
i = Yn(e);
|
991
|
-
return e !== i ? i : e.charCodeAt(0) === 35 &&
|
991
|
+
return e !== i ? i : e.charCodeAt(0) === 35 && Cs.test(e) && (t = e[1].toLowerCase() === "x" ? parseInt(e.slice(2), 16) : parseInt(e.slice(1), 10), es(t)) ? $i(t) : s;
|
992
992
|
}
|
993
993
|
function Ge(s) {
|
994
|
-
return s.indexOf("&") < 0 ? s : s.replace(ws,
|
994
|
+
return s.indexOf("&") < 0 ? s : s.replace(ws, Ts);
|
995
995
|
}
|
996
996
|
var ks = /[&<>"]/,
|
997
997
|
As = /[&<>"]/g,
|
@@ -1592,8 +1592,8 @@ function zs(s) {
|
|
1592
1592
|
var Vs = /['"]/,
|
1593
1593
|
wn = /['"]/g,
|
1594
1594
|
Gs = /[-\s()\[\]]/,
|
1595
|
-
|
1596
|
-
function
|
1595
|
+
Cn = "’";
|
1596
|
+
function Tn(s, e) {
|
1597
1597
|
return e < 0 || e >= s.length ? !1 : !Gs.test(s[e]);
|
1598
1598
|
}
|
1599
1599
|
function Qe(s, e, t) {
|
@@ -1607,8 +1607,8 @@ function Ws(s) {
|
|
1607
1607
|
for (a = E[e].level, f = S.length - 1; f >= 0 && !(S[f].level <= a); f--);
|
1608
1608
|
S.length = f + 1, i = t.content, r = 0, o = i.length;
|
1609
1609
|
e: for (; r < o && (wn.lastIndex = r, n = wn.exec(i), !!n);) {
|
1610
|
-
if (l = !
|
1611
|
-
m && (t.content = Qe(t.content, n.index,
|
1610
|
+
if (l = !Tn(i, n.index - 1), r = n.index + 1, m = n[0] === "'", c = !Tn(i, r), !c && !l) {
|
1611
|
+
m && (t.content = Qe(t.content, n.index, Cn));
|
1612
1612
|
continue;
|
1613
1613
|
}
|
1614
1614
|
if (h = !c, u = !l, u) {
|
@@ -1622,7 +1622,7 @@ function Ws(s) {
|
|
1622
1622
|
pos: n.index,
|
1623
1623
|
single: m,
|
1624
1624
|
level: a
|
1625
|
-
}) : u && m && (t.content = Qe(t.content, n.index,
|
1625
|
+
}) : u && m && (t.content = Qe(t.content, n.index, Cn));
|
1626
1626
|
}
|
1627
1627
|
}
|
1628
1628
|
}
|
@@ -1822,7 +1822,7 @@ function Ys(s, e, t, i) {
|
|
1822
1822
|
S,
|
1823
1823
|
Y,
|
1824
1824
|
ne,
|
1825
|
-
|
1825
|
+
Ce,
|
1826
1826
|
R,
|
1827
1827
|
W = !0,
|
1828
1828
|
$,
|
@@ -1835,11 +1835,11 @@ function Ys(s, e, t, i) {
|
|
1835
1835
|
for (Y = s.tokens.length, E ? (d = s.bMarks[e] + s.tShift[e], m = Number(s.src.substr(d, h - d - 1)), s.tokens.push({
|
1836
1836
|
type: "ordered_list_open",
|
1837
1837
|
order: m,
|
1838
|
-
lines:
|
1838
|
+
lines: Ce = [e, 0],
|
1839
1839
|
level: s.level++
|
1840
1840
|
})) : s.tokens.push({
|
1841
1841
|
type: "bullet_list_open",
|
1842
|
-
lines:
|
1842
|
+
lines: Ce = [e, 0],
|
1843
1843
|
level: s.level++
|
1844
1844
|
}), n = e, ne = !1, $ = s.parser.ruler.getRules("list"); n < t && (S = s.skipSpaces(h), u = s.eMarks[n], S >= u ? f = 1 : f = S - h, f > 4 && (f = 1), f < 1 && (f = 1), r = h - s.bMarks[n] + f, s.tokens.push({
|
1845
1845
|
type: "list_item_open",
|
@@ -1862,7 +1862,7 @@ function Ys(s, e, t, i) {
|
|
1862
1862
|
return s.tokens.push({
|
1863
1863
|
type: E ? "ordered_list_close" : "bullet_list_close",
|
1864
1864
|
level: --s.level
|
1865
|
-
}),
|
1865
|
+
}), Ce[1] = n, s.line = n, W && Zs(s, Y), !0;
|
1866
1866
|
}
|
1867
1867
|
function Qs(s, e, t, i) {
|
1868
1868
|
var n,
|
@@ -2441,7 +2441,7 @@ function Sr(s, e) {
|
|
2441
2441
|
}), s.pos = s.posMax + 1, s.posMax = n, !0);
|
2442
2442
|
}
|
2443
2443
|
var wr = /\\([ \\!"#$%&'()*+,.\/:;<=>?@[\]^_`{|}~-])/g;
|
2444
|
-
function
|
2444
|
+
function Cr(s, e) {
|
2445
2445
|
var t,
|
2446
2446
|
i,
|
2447
2447
|
n = s.posMax,
|
@@ -2460,7 +2460,7 @@ function Tr(s, e) {
|
|
2460
2460
|
content: i.replace(wr, "$1")
|
2461
2461
|
}), s.pos = s.posMax + 1, s.posMax = n, !0);
|
2462
2462
|
}
|
2463
|
-
function
|
2463
|
+
function Tr(s, e) {
|
2464
2464
|
var t,
|
2465
2465
|
i,
|
2466
2466
|
n,
|
@@ -2627,7 +2627,7 @@ function Xr(s, e) {
|
|
2627
2627
|
}
|
2628
2628
|
return e || (s.pending += "&"), s.pos++, !0;
|
2629
2629
|
}
|
2630
|
-
var ji = [["text", pr], ["newline", mr], ["escape", gr], ["backticks", br], ["del", vr], ["ins", yr], ["mark", Er], ["emphasis", xr], ["sub", Sr], ["sup",
|
2630
|
+
var ji = [["text", pr], ["newline", mr], ["escape", gr], ["backticks", br], ["del", vr], ["ins", yr], ["mark", Er], ["emphasis", xr], ["sub", Sr], ["sup", Cr], ["links", Tr], ["footnote_inline", kr], ["footnote_ref", Ar], ["autolink", Lr], ["htmltag", $r], ["entity", Xr]];
|
2631
2631
|
function xi() {
|
2632
2632
|
this.ruler = new Z();
|
2633
2633
|
for (var s = 0; s < ji.length; s++) this.ruler.push(ji[s][0], ji[s][1]);
|
@@ -2786,34 +2786,34 @@ var Yr = {
|
|
2786
2786
|
function as(s, e, t) {
|
2787
2787
|
this.src = e, this.env = t, this.options = s.options, this.tokens = [], this.inlineMode = !1, this.inline = s.inline, this.block = s.block, this.renderer = s.renderer, this.typographer = s.typographer;
|
2788
2788
|
}
|
2789
|
-
function
|
2789
|
+
function _e(s, e) {
|
2790
2790
|
typeof s != "string" && (e = s, s = "default"), e && e.linkify != null && console.warn("linkify option is removed. Use linkify plugin instead:\n\nimport Remarkable from 'remarkable';\nimport linkify from 'remarkable/linkify';\nnew Remarkable().use(linkify)\n"), this.inline = new xi(), this.block = new dn(), this.core = new rs(), this.renderer = new cn(), this.ruler = new Z(), this.options = {}, this.configure(to[s]), this.set(e || {});
|
2791
2791
|
}
|
2792
|
-
|
2792
|
+
_e.prototype.set = function (s) {
|
2793
2793
|
Qn(this.options, s);
|
2794
2794
|
};
|
2795
|
-
|
2795
|
+
_e.prototype.configure = function (s) {
|
2796
2796
|
var e = this;
|
2797
2797
|
if (!s) throw new Error("Wrong `remarkable` preset, check name/content");
|
2798
2798
|
s.options && e.set(s.options), s.components && Object.keys(s.components).forEach(function (t) {
|
2799
2799
|
s.components[t].rules && e[t].ruler.enable(s.components[t].rules, !0);
|
2800
2800
|
});
|
2801
2801
|
};
|
2802
|
-
|
2802
|
+
_e.prototype.use = function (s, e) {
|
2803
2803
|
return s(this, e), this;
|
2804
2804
|
};
|
2805
|
-
|
2805
|
+
_e.prototype.parse = function (s, e) {
|
2806
2806
|
var t = new as(this, s, e);
|
2807
2807
|
return this.core.process(t), t.tokens;
|
2808
2808
|
};
|
2809
|
-
|
2809
|
+
_e.prototype.render = function (s, e) {
|
2810
2810
|
return e = e || {}, this.renderer.render(this.parse(s, e), this.options, e);
|
2811
2811
|
};
|
2812
|
-
|
2812
|
+
_e.prototype.parseInline = function (s, e) {
|
2813
2813
|
var t = new as(this, s, e);
|
2814
2814
|
return t.inlineMode = !0, this.core.process(t), t.tokens;
|
2815
2815
|
};
|
2816
|
-
|
2816
|
+
_e.prototype.renderInline = function (s, e) {
|
2817
2817
|
return e = e || {}, this.renderer.render(this.parseInline(s, e), this.options, e);
|
2818
2818
|
};
|
2819
2819
|
var Mt = /*#__PURE__*/function () {
|
@@ -2824,7 +2824,7 @@ var Mt = /*#__PURE__*/function () {
|
|
2824
2824
|
key: "instantiate",
|
2825
2825
|
value: function instantiate() {
|
2826
2826
|
var e = window.hljs;
|
2827
|
-
return e ? new
|
2827
|
+
return e ? new _e({
|
2828
2828
|
highlight: function highlight(t, i) {
|
2829
2829
|
if (i && e.getLanguage(i)) try {
|
2830
2830
|
return e.highlight(i, t).value;
|
@@ -2850,7 +2850,7 @@ var Mt = /*#__PURE__*/function () {
|
|
2850
2850
|
// set target to open in a new tab
|
2851
2851
|
typographer: !0
|
2852
2852
|
// Enable smartypants and other sweet transforms
|
2853
|
-
}) : new
|
2853
|
+
}) : new _e({
|
2854
2854
|
linkTarget: "_blank"
|
2855
2855
|
// set target to open in a new tab
|
2856
2856
|
});
|
@@ -2865,11 +2865,11 @@ var Mt = /*#__PURE__*/function () {
|
|
2865
2865
|
}
|
2866
2866
|
}]);
|
2867
2867
|
}();
|
2868
|
-
var
|
2869
|
-
function
|
2870
|
-
_classCallCheck(this,
|
2868
|
+
var Me = /*#__PURE__*/function () {
|
2869
|
+
function Me() {
|
2870
|
+
_classCallCheck(this, Me);
|
2871
2871
|
}
|
2872
|
-
return _createClass(
|
2872
|
+
return _createClass(Me, null, [{
|
2873
2873
|
key: "addMessage",
|
2874
2874
|
value: function addMessage(e, t, i, n) {
|
2875
2875
|
var r;
|
@@ -2879,7 +2879,7 @@ var Ae = /*#__PURE__*/function () {
|
|
2879
2879
|
key: "wrapInLink",
|
2880
2880
|
value: function wrapInLink(e, t, i) {
|
2881
2881
|
var n = document.createElement("a");
|
2882
|
-
return n.href = t, n.download = i ||
|
2882
|
+
return n.href = t, n.download = i || Me.DEFAULT_FILE_NAME, n.target = "_blank", n.appendChild(e), n;
|
2883
2883
|
}
|
2884
2884
|
}, {
|
2885
2885
|
key: "isNonLinkableDataUrl",
|
@@ -2889,7 +2889,7 @@ var Ae = /*#__PURE__*/function () {
|
|
2889
2889
|
}, {
|
2890
2890
|
key: "processContent",
|
2891
2891
|
value: function processContent(e, t, i, n) {
|
2892
|
-
return !i ||
|
2892
|
+
return !i || Me.isNonLinkableDataUrl(e, i) ? t : Me.wrapInLink(t, i, n);
|
2893
2893
|
}
|
2894
2894
|
}, {
|
2895
2895
|
key: "waitToLoadThenScroll",
|
@@ -2901,11 +2901,11 @@ var Ae = /*#__PURE__*/function () {
|
|
2901
2901
|
}, {
|
2902
2902
|
key: "scrollDownOnImageLoad",
|
2903
2903
|
value: function scrollDownOnImageLoad(e, t) {
|
2904
|
-
if (e.startsWith("data"))
|
2904
|
+
if (e.startsWith("data")) Me.waitToLoadThenScroll(t);else try {
|
2905
2905
|
fetch(e, {
|
2906
2906
|
mode: "no-cors"
|
2907
2907
|
})["catch"](function () {})["finally"](function () {
|
2908
|
-
|
2908
|
+
Me.waitToLoadThenScroll(t);
|
2909
2909
|
});
|
2910
2910
|
} catch (_unused5) {
|
2911
2911
|
t.scrollTop = t.scrollHeight;
|
@@ -2948,8 +2948,8 @@ var Ae = /*#__PURE__*/function () {
|
|
2948
2948
|
}
|
2949
2949
|
}]);
|
2950
2950
|
}();
|
2951
|
-
|
2952
|
-
var q =
|
2951
|
+
Me.DEFAULT_FILE_NAME = "file";
|
2952
|
+
var q = Me;
|
2953
2953
|
var Qt = /*#__PURE__*/function () {
|
2954
2954
|
function Qt() {
|
2955
2955
|
_classCallCheck(this, Qt);
|
@@ -2965,7 +2965,7 @@ var Qt = /*#__PURE__*/function () {
|
|
2965
2965
|
}));
|
2966
2966
|
q.reAddFileRefToObject(t, n), (r = e.onMessage) == null || r.call(e, n), e.dispatchEvent(new CustomEvent("message", {
|
2967
2967
|
detail: n
|
2968
|
-
})),
|
2968
|
+
})), he.fireOnNewMessage(e, n);
|
2969
2969
|
}
|
2970
2970
|
}, {
|
2971
2971
|
key: "onClearMessages",
|
@@ -3183,13 +3183,13 @@ var ot = /*#__PURE__*/function () {
|
|
3183
3183
|
}
|
3184
3184
|
}]);
|
3185
3185
|
}();
|
3186
|
-
var
|
3186
|
+
var Re = /*#__PURE__*/function () {
|
3187
3187
|
// used for extracting at end and for isStreaming
|
3188
|
-
function
|
3189
|
-
_classCallCheck(this,
|
3188
|
+
function Re(e) {
|
3189
|
+
_classCallCheck(this, Re);
|
3190
3190
|
this._fileAdded = !1, this._streamedContent = "", this._streamType = "", this._hasStreamEnded = !1, this._messages = e;
|
3191
3191
|
}
|
3192
|
-
return _createClass(
|
3192
|
+
return _createClass(Re, [{
|
3193
3193
|
key: "upsertStreamedMessage",
|
3194
3194
|
value: function upsertStreamedMessage(e) {
|
3195
3195
|
var r;
|
@@ -3208,7 +3208,7 @@ var Me = /*#__PURE__*/function () {
|
|
3208
3208
|
key: "setInitialState",
|
3209
3209
|
value: function setInitialState(e, t, i) {
|
3210
3210
|
var _i8;
|
3211
|
-
this._streamType = e, (_i8 = i) !== null && _i8 !== void 0 ? _i8 : i = b.AI_ROLE, this._elements = e === "text" ? this._messages.addNewTextMessage(t, i) : ct.add(this._messages, t, i, this._messages.messageElementRefs), this._elements.bubbleElement.classList.add(
|
3211
|
+
this._streamType = e, (_i8 = i) !== null && _i8 !== void 0 ? _i8 : i = b.AI_ROLE, this._elements = e === "text" ? this._messages.addNewTextMessage(t, i) : ct.add(this._messages, t, i, this._messages.messageElementRefs), this._elements.bubbleElement.classList.add(Re.MESSAGE_CLASS), this._streamedContent = t, this._activeMessageRole = i, this._message = _defineProperty({
|
3212
3212
|
role: this._activeMessageRole
|
3213
3213
|
}, e, this._streamedContent), this._messages.messages.push(this._message);
|
3214
3214
|
}
|
@@ -3228,7 +3228,7 @@ var Me = /*#__PURE__*/function () {
|
|
3228
3228
|
value: function updateHTML(e, t, i) {
|
3229
3229
|
if (i) this._streamedContent = e, t.innerHTML = e;else {
|
3230
3230
|
var n = document.createElement("span");
|
3231
|
-
n.innerHTML = e, t.appendChild(n), this._streamedContent =
|
3231
|
+
n.innerHTML = e, t.appendChild(n), this._streamedContent = Re.HTML_CONTENT_PLACEHOLDER;
|
3232
3232
|
}
|
3233
3233
|
}
|
3234
3234
|
}, {
|
@@ -3238,7 +3238,7 @@ var Me = /*#__PURE__*/function () {
|
|
3238
3238
|
var e = this._messages.textElementsToText;
|
3239
3239
|
if (!(this._fileAdded && !this._elements)) {
|
3240
3240
|
if (!this._elements) throw Error(A.NO_VALID_STREAM_EVENTS_SENT);
|
3241
|
-
(t = this._elements.bubbleElement) != null && t.classList.contains(
|
3241
|
+
(t = this._elements.bubbleElement) != null && t.classList.contains(Re.MESSAGE_CLASS) && (this._streamType === "text" ? (e[e.length - 1][1] = this._streamedContent, this._message && (this._message.text = this._streamedContent), this._messages.textToSpeech && rt.speak(this._streamedContent, this._messages.textToSpeech)) : this._streamType === "html" && (this._streamedContent === Re.HTML_CONTENT_PLACEHOLDER && (this._streamedContent = ((i = this._elements.bubbleElement) == null ? void 0 : i.innerHTML) || ""), this._elements && fe.apply(this._messages, this._elements.outerContainer), this._message && (this._message.html = this._streamedContent)), this._message && this._messages.sendClientUpdate(ot.createMessageContent(this._message), !1), this._hasStreamEnded = !0);
|
3242
3242
|
}
|
3243
3243
|
}
|
3244
3244
|
}, {
|
@@ -3248,8 +3248,8 @@ var Me = /*#__PURE__*/function () {
|
|
3248
3248
|
}
|
3249
3249
|
}]);
|
3250
3250
|
}();
|
3251
|
-
|
3252
|
-
var
|
3251
|
+
Re.MESSAGE_CLASS = "streamed-message", Re.HTML_CONTENT_PLACEHOLDER = "htmlplaceholder";
|
3252
|
+
var Se = Re;
|
3253
3253
|
var Ue = /*#__PURE__*/function () {
|
3254
3254
|
function Ue() {
|
3255
3255
|
_classCallCheck(this, Ue);
|
@@ -3383,29 +3383,29 @@ function io(_x10, _x11) {
|
|
3383
3383
|
return _io.apply(this, arguments);
|
3384
3384
|
}
|
3385
3385
|
function _io() {
|
3386
|
-
_io = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
3386
|
+
_io = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee119(s, e) {
|
3387
3387
|
var t, i;
|
3388
|
-
return _regeneratorRuntime().wrap(function
|
3389
|
-
while (1) switch (
|
3388
|
+
return _regeneratorRuntime().wrap(function _callee119$(_context119) {
|
3389
|
+
while (1) switch (_context119.prev = _context119.next) {
|
3390
3390
|
case 0:
|
3391
3391
|
t = s.getReader();
|
3392
3392
|
case 1:
|
3393
|
-
|
3393
|
+
_context119.next = 3;
|
3394
3394
|
return t.read();
|
3395
3395
|
case 3:
|
3396
|
-
if ((i =
|
3397
|
-
|
3396
|
+
if ((i = _context119.sent).done) {
|
3397
|
+
_context119.next = 7;
|
3398
3398
|
break;
|
3399
3399
|
}
|
3400
3400
|
e(i.value);
|
3401
3401
|
case 5:
|
3402
|
-
|
3402
|
+
_context119.next = 1;
|
3403
3403
|
break;
|
3404
3404
|
case 7:
|
3405
3405
|
case "end":
|
3406
|
-
return
|
3406
|
+
return _context119.stop();
|
3407
3407
|
}
|
3408
|
-
},
|
3408
|
+
}, _callee119);
|
3409
3409
|
}));
|
3410
3410
|
return _io.apply(this, arguments);
|
3411
3411
|
}
|
@@ -3511,7 +3511,7 @@ function lo(s, e) {
|
|
3511
3511
|
Y(), h();
|
3512
3512
|
});
|
3513
3513
|
var ne = c !== null && c !== void 0 ? c : window.fetch,
|
3514
|
-
|
3514
|
+
Ce = n !== null && n !== void 0 ? n : co;
|
3515
3515
|
function R() {
|
3516
3516
|
return _R.apply(this, arguments);
|
3517
3517
|
}
|
@@ -3531,7 +3531,7 @@ function lo(s, e) {
|
|
3531
3531
|
case 4:
|
3532
3532
|
$ = _context3.sent;
|
3533
3533
|
_context3.next = 7;
|
3534
|
-
return
|
3534
|
+
return Ce($);
|
3535
3535
|
case 7:
|
3536
3536
|
_context3.next = 9;
|
3537
3537
|
return io($.body, no(so(function (N) {
|
@@ -3569,11 +3569,11 @@ function co(s) {
|
|
3569
3569
|
var e = s.headers.get("content-type");
|
3570
3570
|
if (!(e != null && e.startsWith(Ji))) throw new Error("Expected content-type to be ".concat(Ji, ", Actual: ").concat(e));
|
3571
3571
|
}
|
3572
|
-
var
|
3573
|
-
function
|
3574
|
-
_classCallCheck(this,
|
3572
|
+
var T = /*#__PURE__*/function () {
|
3573
|
+
function T() {
|
3574
|
+
_classCallCheck(this, T);
|
3575
3575
|
}
|
3576
|
-
return _createClass(
|
3576
|
+
return _createClass(T, null, [{
|
3577
3577
|
key: "request",
|
3578
3578
|
value: // prettier-ignore
|
3579
3579
|
function () {
|
@@ -3585,7 +3585,7 @@ var C = /*#__PURE__*/function () {
|
|
3585
3585
|
S,
|
3586
3586
|
Y,
|
3587
3587
|
ne,
|
3588
|
-
|
3588
|
+
Ce,
|
3589
3589
|
o,
|
3590
3590
|
_yield$v$processReque,
|
3591
3591
|
a,
|
@@ -3628,19 +3628,19 @@ var C = /*#__PURE__*/function () {
|
|
3628
3628
|
_context6.next = 17;
|
3629
3629
|
break;
|
3630
3630
|
}
|
3631
|
-
return _context6.abrupt("return",
|
3631
|
+
return _context6.abrupt("return", Ee.stream(e, a, i));
|
3632
3632
|
case 17:
|
3633
|
-
if (!(((S = e.connectSettings) == null ? void 0 : S.url) ===
|
3633
|
+
if (!(((S = e.connectSettings) == null ? void 0 : S.url) === pe.URL)) {
|
3634
3634
|
_context6.next = 19;
|
3635
3635
|
break;
|
3636
3636
|
}
|
3637
|
-
return _context6.abrupt("return",
|
3637
|
+
return _context6.abrupt("return", pe.requestStream(i, e.streamHandlers));
|
3638
3638
|
case 19:
|
3639
|
-
f = new
|
3639
|
+
f = new Se(i), m = v.fetch.bind(this, e, l, n);
|
3640
3640
|
lo(((Y = e.connectSettings) == null ? void 0 : Y.url) || e.url || "", {
|
3641
3641
|
method: ((ne = e.connectSettings) == null ? void 0 : ne.method) || "POST",
|
3642
3642
|
headers: l,
|
3643
|
-
credentials: (
|
3643
|
+
credentials: (Ce = e.connectSettings) == null ? void 0 : Ce.credentials,
|
3644
3644
|
body: n ? JSON.stringify(a) : a,
|
3645
3645
|
openWhenHidden: !0,
|
3646
3646
|
// keep stream open when browser tab not open
|
@@ -3693,7 +3693,7 @@ var C = /*#__PURE__*/function () {
|
|
3693
3693
|
case 7:
|
3694
3694
|
pt = _context5.t0;
|
3695
3695
|
(N = e.extractResultData) == null || N.call(e, pt, m, a).then(function (Ne) {
|
3696
|
-
e.asyncCallInProgress && Ne && Ne.text !== "" ? (
|
3696
|
+
e.asyncCallInProgress && Ne && Ne.text !== "" ? (T.simulate(i, e.streamHandlers, Ne), h(), e.asyncCallInProgress = !1) : T.upsertWFiles(i, f.upsertStreamedMessage.bind(f), f, Ne);
|
3697
3697
|
})["catch"](function (Ne) {
|
3698
3698
|
return v.displayError(i, Ne);
|
3699
3699
|
});
|
@@ -3744,7 +3744,7 @@ var C = /*#__PURE__*/function () {
|
|
3744
3744
|
}, i), !1), i.text) {
|
3745
3745
|
t.onOpen();
|
3746
3746
|
var r = i.text.split("");
|
3747
|
-
|
3747
|
+
T.populateMessages(r, new Se(e), n);
|
3748
3748
|
}
|
3749
3749
|
}
|
3750
3750
|
}, {
|
@@ -3757,10 +3757,10 @@ var C = /*#__PURE__*/function () {
|
|
3757
3757
|
text: r
|
3758
3758
|
});
|
3759
3759
|
var o = setTimeout(function () {
|
3760
|
-
|
3760
|
+
T.populateMessages(e, t, i, n + 1);
|
3761
3761
|
}, i.simulationInterim || 6);
|
3762
3762
|
i.abortStream.abort = function () {
|
3763
|
-
|
3763
|
+
T.abort(o, t, i.onClose);
|
3764
3764
|
};
|
3765
3765
|
} else t.finaliseStreamedMessage(), i.onClose();
|
3766
3766
|
}
|
@@ -3772,7 +3772,7 @@ var C = /*#__PURE__*/function () {
|
|
3772
3772
|
}, {
|
3773
3773
|
key: "isSimulatable",
|
3774
3774
|
value: function isSimulatable(e, t) {
|
3775
|
-
return
|
3775
|
+
return T.isSimulation(e) && t && (t.text || t.html);
|
3776
3776
|
}
|
3777
3777
|
}, {
|
3778
3778
|
key: "abort",
|
@@ -3845,7 +3845,7 @@ var He = /*#__PURE__*/function () {
|
|
3845
3845
|
_context7.t0 = i;
|
3846
3846
|
case 5:
|
3847
3847
|
n = _context7.t0;
|
3848
|
-
n.error ? (t.addNewErrorMessage("service", n.error), e.completionsHandlers.onFinish()) :
|
3848
|
+
n.error ? (t.addNewErrorMessage("service", n.error), e.completionsHandlers.onFinish()) : T.isSimulatable(e.stream, n) ? T.simulate(t, e.streamHandlers, n) : (t.addNewMessage(n), e.completionsHandlers.onFinish());
|
3849
3849
|
case 7:
|
3850
3850
|
case "end":
|
3851
3851
|
return _context7.stop();
|
@@ -3859,13 +3859,13 @@ var He = /*#__PURE__*/function () {
|
|
3859
3859
|
value: function requestStream(e, t) {
|
3860
3860
|
setTimeout(function () {
|
3861
3861
|
var i = He.getResponse(e);
|
3862
|
-
|
3862
|
+
T.simulate(e, t, i);
|
3863
3863
|
}, 400);
|
3864
3864
|
}
|
3865
3865
|
}]);
|
3866
3866
|
}();
|
3867
3867
|
He.URL = "deep-chat-demo";
|
3868
|
-
var
|
3868
|
+
var pe = He;
|
3869
3869
|
var z = /*#__PURE__*/function () {
|
3870
3870
|
function z() {
|
3871
3871
|
_classCallCheck(this, z);
|
@@ -3873,7 +3873,7 @@ var z = /*#__PURE__*/function () {
|
|
3873
3873
|
return _createClass(z, null, [{
|
3874
3874
|
key: "setup",
|
3875
3875
|
value: function setup(e) {
|
3876
|
-
e.connectSettings.url !==
|
3876
|
+
e.connectSettings.url !== pe.URL && (e.permittedErrorPrefixes = ["Connection error", "Error in server message"], e.websocket = "pending");
|
3877
3877
|
}
|
3878
3878
|
}, {
|
3879
3879
|
key: "createConnection",
|
@@ -3881,7 +3881,7 @@ var z = /*#__PURE__*/function () {
|
|
3881
3881
|
if (!document.body.contains(e.deepChat)) return;
|
3882
3882
|
var i = e.connectSettings.websocket;
|
3883
3883
|
if (i) {
|
3884
|
-
if (e.connectSettings.handler) return
|
3884
|
+
if (e.connectSettings.handler) return Ee.websocket(e, t);
|
3885
3885
|
try {
|
3886
3886
|
var n = typeof i != "boolean" ? i : void 0,
|
3887
3887
|
r = new WebSocket(e.connectSettings.url || "", n);
|
@@ -3942,9 +3942,9 @@ var z = /*#__PURE__*/function () {
|
|
3942
3942
|
}
|
3943
3943
|
throw Error(A.INVALID_RESPONSE(l, "server", !!e.deepChat.responseInterceptor, c));
|
3944
3944
|
case 14:
|
3945
|
-
if (
|
3945
|
+
if (T.isSimulation(e.stream)) {
|
3946
3946
|
h = z.stream.bind(_this6, e, i, n), u = n[l.role || b.AI_ROLE];
|
3947
|
-
|
3947
|
+
T.upsertWFiles(i, h, u, d);
|
3948
3948
|
} else i.addNewMessage(d);
|
3949
3949
|
_context8.next = 20;
|
3950
3950
|
break;
|
@@ -4013,11 +4013,11 @@ var z = /*#__PURE__*/function () {
|
|
4013
4013
|
return _context9.abrupt("return", r.newUserMessage.listener(a));
|
4014
4014
|
case 14:
|
4015
4015
|
c = n ? JSON.stringify(a) : a;
|
4016
|
-
if (!(((h = e.connectSettings) == null ? void 0 : h.url) ===
|
4016
|
+
if (!(((h = e.connectSettings) == null ? void 0 : h.url) === pe.URL)) {
|
4017
4017
|
_context9.next = 17;
|
4018
4018
|
break;
|
4019
4019
|
}
|
4020
|
-
return _context9.abrupt("return",
|
4020
|
+
return _context9.abrupt("return", pe.request(e, i));
|
4021
4021
|
case 17:
|
4022
4022
|
r.readyState === void 0 || r.readyState !== r.OPEN ? (console.error("Connection is not open"), i.isLastMessageError() || i.addNewErrorMessage("service", "Connection error")) : (r.send(JSON.stringify(c)), e.completionsHandlers.onFinish());
|
4023
4023
|
case 18:
|
@@ -4051,16 +4051,16 @@ var z = /*#__PURE__*/function () {
|
|
4051
4051
|
var _i$o;
|
4052
4052
|
var o = n.role || b.AI_ROLE,
|
4053
4053
|
a = i[o];
|
4054
|
-
n.text === r || n.html === r ? (a == null || a.finaliseStreamedMessage(), delete i[o]) : ((_i$o = i[o]) !== null && _i$o !== void 0 ? _i$o : i[o] = new
|
4055
|
-
} else
|
4054
|
+
n.text === r || n.html === r ? (a == null || a.finaliseStreamedMessage(), delete i[o]) : ((_i$o = i[o]) !== null && _i$o !== void 0 ? _i$o : i[o] = new Se(t), i[o].upsertStreamedMessage(n));
|
4055
|
+
} else T.simulate(t, e.streamHandlers, n);
|
4056
4056
|
}
|
4057
4057
|
}]);
|
4058
4058
|
}();
|
4059
|
-
var
|
4060
|
-
function
|
4061
|
-
_classCallCheck(this,
|
4059
|
+
var Ee = /*#__PURE__*/function () {
|
4060
|
+
function Ee() {
|
4061
|
+
_classCallCheck(this, Ee);
|
4062
4062
|
}
|
4063
|
-
return _createClass(
|
4063
|
+
return _createClass(Ee, null, [{
|
4064
4064
|
key: "request",
|
4065
4065
|
value: function () {
|
4066
4066
|
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11(e, t, i) {
|
@@ -4093,7 +4093,7 @@ var ye = /*#__PURE__*/function () {
|
|
4093
4093
|
_context10.t0 = c;
|
4094
4094
|
case 8:
|
4095
4095
|
d = _context10.t0;
|
4096
|
-
v.validateResponseFormat(d) ? typeof d.error == "string" ? (console.error(d.error), i.addNewErrorMessage("service", d.error), e.completionsHandlers.onFinish()) :
|
4096
|
+
v.validateResponseFormat(d) ? typeof d.error == "string" ? (console.error(d.error), i.addNewErrorMessage("service", d.error), e.completionsHandlers.onFinish()) : T.isSimulatable(e.stream, d) ? T.simulate(i, e.streamHandlers, d) : (i.addNewMessage(d), e.completionsHandlers.onFinish()) : (console.error(A.INVALID_RESPONSE(c, "server", !!e.deepChat.responseInterceptor, d)), i.addNewErrorMessage("service", "Error in server message"), e.completionsHandlers.onFinish());
|
4097
4097
|
case 10:
|
4098
4098
|
case "end":
|
4099
4099
|
return _context10.stop();
|
@@ -4103,7 +4103,7 @@ var ye = /*#__PURE__*/function () {
|
|
4103
4103
|
return function r(_x22) {
|
4104
4104
|
return _ref3.apply(this, arguments);
|
4105
4105
|
};
|
4106
|
-
}(), o =
|
4106
|
+
}(), o = Ee.generateOptionalSignals();
|
4107
4107
|
(l = (a = e.connectSettings).handler) == null || l.call(a, t, _objectSpread(_objectSpread({}, o), {}, {
|
4108
4108
|
onResponse: r
|
4109
4109
|
}));
|
@@ -4134,12 +4134,12 @@ var ye = /*#__PURE__*/function () {
|
|
4134
4134
|
var h, u;
|
4135
4135
|
var n = !0,
|
4136
4136
|
r = !1;
|
4137
|
-
var o = new
|
4137
|
+
var o = new Se(i),
|
4138
4138
|
a = function a() {
|
4139
4139
|
r || !n || (e.streamHandlers.onOpen(), r = !0);
|
4140
4140
|
},
|
4141
4141
|
l = function l() {
|
4142
|
-
n && (
|
4142
|
+
n && (Ee.attemptToFinaliseStream(o, i), e.streamHandlers.onClose(), n = !1);
|
4143
4143
|
},
|
4144
4144
|
c = /*#__PURE__*/function () {
|
4145
4145
|
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee12(f) {
|
@@ -4164,7 +4164,7 @@ var ye = /*#__PURE__*/function () {
|
|
4164
4164
|
_context12.t0 = f;
|
4165
4165
|
case 7:
|
4166
4166
|
m = _context12.t0;
|
4167
|
-
v.validateResponseFormat(m) ? m.error ? (console.error(m.error), o.finaliseStreamedMessage(), i.addNewErrorMessage("service", m.error), e.streamHandlers.onClose(), n = !1) :
|
4167
|
+
v.validateResponseFormat(m) ? m.error ? (console.error(m.error), o.finaliseStreamedMessage(), i.addNewErrorMessage("service", m.error), e.streamHandlers.onClose(), n = !1) : T.upsertWFiles(i, o.upsertStreamedMessage.bind(o), o, m) : console.error(A.INVALID_RESPONSE(f, "server", !!e.deepChat.responseInterceptor, m));
|
4168
4168
|
case 9:
|
4169
4169
|
case "end":
|
4170
4170
|
return _context12.stop();
|
@@ -4176,9 +4176,9 @@ var ye = /*#__PURE__*/function () {
|
|
4176
4176
|
};
|
4177
4177
|
}();
|
4178
4178
|
e.streamHandlers.abortStream.abort = function () {
|
4179
|
-
|
4179
|
+
Ee.attemptToFinaliseStream(o, i), e.streamHandlers.onClose(), n = !1;
|
4180
4180
|
};
|
4181
|
-
var d =
|
4181
|
+
var d = Ee.generateOptionalSignals();
|
4182
4182
|
(u = (h = e.connectSettings).handler) == null || u.call(h, t, _objectSpread(_objectSpread({}, d), {}, {
|
4183
4183
|
onOpen: a,
|
4184
4184
|
onResponse: c,
|
@@ -4229,9 +4229,9 @@ var ye = /*#__PURE__*/function () {
|
|
4229
4229
|
_context13.t0 = d;
|
4230
4230
|
case 7:
|
4231
4231
|
h = _context13.t0;
|
4232
|
-
if (!v.validateResponseFormat(h)) console.error(A.INVALID_RESPONSE(d, "server", !!e.deepChat.responseInterceptor, h)), t.addNewErrorMessage("service", "Error in server message");else if (typeof h.error == "string") console.error(h.error), t.isLastMessageError() || t.addNewErrorMessage("service", h.error);else if (
|
4232
|
+
if (!v.validateResponseFormat(h)) console.error(A.INVALID_RESPONSE(d, "server", !!e.deepChat.responseInterceptor, h)), t.addNewErrorMessage("service", "Error in server message");else if (typeof h.error == "string") console.error(h.error), t.isLastMessageError() || t.addNewErrorMessage("service", h.error);else if (T.isSimulation(e.stream)) {
|
4233
4233
|
m = z.stream.bind(_this7, e, t, i.roleToStream), p = i.roleToStream[d.role || b.AI_ROLE];
|
4234
|
-
|
4234
|
+
T.upsertWFiles(t, m, p, d);
|
4235
4235
|
} else t.addNewMessage(h);
|
4236
4236
|
case 9:
|
4237
4237
|
case "end":
|
@@ -4243,7 +4243,7 @@ var ye = /*#__PURE__*/function () {
|
|
4243
4243
|
return _ref5.apply(this, arguments);
|
4244
4244
|
};
|
4245
4245
|
}(),
|
4246
|
-
a =
|
4246
|
+
a = Ee.generateOptionalSignals();
|
4247
4247
|
(c = (l = e.connectSettings).handler) == null || c.call(l, void 0, _objectSpread(_objectSpread({}, a), {}, {
|
4248
4248
|
onOpen: n,
|
4249
4249
|
onResponse: o,
|
@@ -4267,11 +4267,11 @@ var ye = /*#__PURE__*/function () {
|
|
4267
4267
|
}
|
4268
4268
|
}]);
|
4269
4269
|
}();
|
4270
|
-
var
|
4271
|
-
function
|
4272
|
-
_classCallCheck(this,
|
4270
|
+
var C = /*#__PURE__*/function () {
|
4271
|
+
function C() {
|
4272
|
+
_classCallCheck(this, C);
|
4273
4273
|
}
|
4274
|
-
return _createClass(
|
4274
|
+
return _createClass(C, null, [{
|
4275
4275
|
key: "request",
|
4276
4276
|
value: // prettier-ignore
|
4277
4277
|
function () {
|
@@ -4315,13 +4315,13 @@ var T = /*#__PURE__*/function () {
|
|
4315
4315
|
_context15.next = 13;
|
4316
4316
|
break;
|
4317
4317
|
}
|
4318
|
-
return _context15.abrupt("return",
|
4318
|
+
return _context15.abrupt("return", Ee.request(e, o, i));
|
4319
4319
|
case 13:
|
4320
|
-
if (!(((m = e.connectSettings) == null ? void 0 : m.url) ===
|
4320
|
+
if (!(((m = e.connectSettings) == null ? void 0 : m.url) === pe.URL)) {
|
4321
4321
|
_context15.next = 15;
|
4322
4322
|
break;
|
4323
4323
|
}
|
4324
|
-
return _context15.abrupt("return",
|
4324
|
+
return _context15.abrupt("return", pe.request(e, i));
|
4325
4325
|
case 15:
|
4326
4326
|
d = !0;
|
4327
4327
|
h = v.fetch.bind(this, e, a, n);
|
@@ -4368,7 +4368,7 @@ var T = /*#__PURE__*/function () {
|
|
4368
4368
|
}
|
4369
4369
|
throw Error(A.INVALID_RESPONSE(p, "response", !!e.deepChat.responseInterceptor, E));
|
4370
4370
|
case 15:
|
4371
|
-
S.makingAnotherRequest || (
|
4371
|
+
S.makingAnotherRequest || (T.isSimulatable(e.stream, S) ? T.simulate(i, e.streamHandlers, S) : (i.addNewMessage(S), c()));
|
4372
4372
|
case 16:
|
4373
4373
|
case "end":
|
4374
4374
|
return _context14.stop();
|
@@ -4427,8 +4427,8 @@ var T = /*#__PURE__*/function () {
|
|
4427
4427
|
case 11:
|
4428
4428
|
a = _context16.sent;
|
4429
4429
|
a.timeoutMS ? setTimeout(function () {
|
4430
|
-
|
4431
|
-
}, a.timeoutMS) :
|
4430
|
+
C.executePollRequest(e, t, i, n);
|
4431
|
+
}, a.timeoutMS) : T.isSimulatable(e.stream, a) ? T.simulate(n, e.streamHandlers, a) : (n.addNewMessage(a), r());
|
4432
4432
|
case 13:
|
4433
4433
|
case "end":
|
4434
4434
|
return _context16.stop();
|
@@ -4487,7 +4487,7 @@ var T = /*#__PURE__*/function () {
|
|
4487
4487
|
body: h,
|
4488
4488
|
headers: a
|
4489
4489
|
};
|
4490
|
-
e.connectSettings.credentials && (u.credentials = e.connectSettings.credentials),
|
4490
|
+
e.connectSettings.credentials && (u.credentials = e.connectSettings.credentials), C.executePollRequest(e, c, u, i);
|
4491
4491
|
case 12:
|
4492
4492
|
case "end":
|
4493
4493
|
return _context17.stop();
|
@@ -4665,7 +4665,7 @@ var We = /*#__PURE__*/function () {
|
|
4665
4665
|
var _a$url;
|
4666
4666
|
_classCallCheck(this, We);
|
4667
4667
|
var n, r, o, a, l;
|
4668
|
-
this.rawBody = {}, this.validateKeyProperty = !1, this.canSendMessage = We.canSendMessage, this.connectSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = i, Object.assign(this.rawBody, (n = e.connect) == null ? void 0 : n.additionalBodyProps), this.totalMessagesMaxCharLength = (r = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : r.totalMessagesMaxCharLength, this.maxMessages = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.maxMessages, I.set(e, this, t), e.connect && (this.connectSettings = e.connect), this.demo && ((_a$url = (a = this.connectSettings).url) !== null && _a$url !== void 0 ? _a$url : a.url =
|
4668
|
+
this.rawBody = {}, this.validateKeyProperty = !1, this.canSendMessage = We.canSendMessage, this.connectSettings = {}, this.fileTypes = {}, this.completionsHandlers = {}, this.streamHandlers = {}, this.deepChat = e, this.demo = i, Object.assign(this.rawBody, (n = e.connect) == null ? void 0 : n.additionalBodyProps), this.totalMessagesMaxCharLength = (r = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : r.totalMessagesMaxCharLength, this.maxMessages = (o = e == null ? void 0 : e.requestBodyLimits) == null ? void 0 : o.maxMessages, I.set(e, this, t), e.connect && (this.connectSettings = e.connect), this.demo && ((_a$url = (a = this.connectSettings).url) !== null && _a$url !== void 0 ? _a$url : a.url = pe.URL), this.connectSettings.websocket && z.setup(this), this.stream = ((l = this.deepChat.connect) == null ? void 0 : l.stream) || he.checkForStream(this.deepChat);
|
4669
4669
|
}
|
4670
4670
|
return _createClass(We, [{
|
4671
4671
|
key: "verifyKey",
|
@@ -4691,7 +4691,7 @@ var We = /*#__PURE__*/function () {
|
|
4691
4691
|
while (1) switch (_context18.prev = _context18.next) {
|
4692
4692
|
case 0:
|
4693
4693
|
i = _args18.length > 2 && _args18[2] !== undefined ? _args18[2] : !0;
|
4694
|
-
return _context18.abrupt("return", this.stream && !
|
4694
|
+
return _context18.abrupt("return", this.stream && !T.isSimulation(this.stream) ? T.request(this, e, t, i) : C.request(this, e, t, i));
|
4695
4695
|
case 2:
|
4696
4696
|
case "end":
|
4697
4697
|
return _context18.stop();
|
@@ -4825,7 +4825,7 @@ var We = /*#__PURE__*/function () {
|
|
4825
4825
|
_context23.next = 4;
|
4826
4826
|
break;
|
4827
4827
|
}
|
4828
|
-
return _context23.abrupt("return",
|
4828
|
+
return _context23.abrupt("return", he.handleResponseProperty(e));
|
4829
4829
|
case 4:
|
4830
4830
|
if (!v.validateResponseFormat(e)) {
|
4831
4831
|
_context23.next = 6;
|
@@ -4914,7 +4914,7 @@ var U = /*#__PURE__*/function (_We) {
|
|
4914
4914
|
o = _this$keyVerification.createHeaders,
|
4915
4915
|
a = _this$keyVerification.body,
|
4916
4916
|
l = (o == null ? void 0 : o(e)) || this.buildHeadersFunc(e);
|
4917
|
-
|
4917
|
+
C.verifyKey(e, i, l, n, this.keyAuthenticated.bind(this, t.onSuccess), t.onFail, t.onLoad, r, a);
|
4918
4918
|
}
|
4919
4919
|
}, {
|
4920
4920
|
key: "isDirectConnection",
|
@@ -4941,19 +4941,19 @@ var ei = /*#__PURE__*/function () {
|
|
4941
4941
|
}
|
4942
4942
|
}]);
|
4943
4943
|
}();
|
4944
|
-
var
|
4944
|
+
var be = /*#__PURE__*/function (_HTMLElement) {
|
4945
4945
|
// If this is not working, try using propertyName directly
|
4946
|
-
function
|
4946
|
+
function be() {
|
4947
4947
|
var _this9;
|
4948
|
-
_classCallCheck(this,
|
4949
|
-
_this9 = _callSuper(this,
|
4950
|
-
var t =
|
4948
|
+
_classCallCheck(this, be);
|
4949
|
+
_this9 = _callSuper(this, be), _this9._waitingToRender_ = !1, _this9._propUpdated_ = !1, Object.keys(be._attributeToProperty_).forEach(function (e) {
|
4950
|
+
var t = be._attributeToProperty_[e];
|
4951
4951
|
_this9.constructPropertyAccessors(t), _this9.hasOwnProperty(e) || _this9.constructPropertyAccessors(t, e);
|
4952
4952
|
});
|
4953
4953
|
return _this9;
|
4954
4954
|
}
|
4955
|
-
_inherits(
|
4956
|
-
return _createClass(
|
4955
|
+
_inherits(be, _HTMLElement);
|
4956
|
+
return _createClass(be, [{
|
4957
4957
|
key: "constructPropertyAccessors",
|
4958
4958
|
value:
|
4959
4959
|
// need to be called here as accessors need to be set for the class instance
|
@@ -4972,8 +4972,8 @@ var ge = /*#__PURE__*/function (_HTMLElement) {
|
|
4972
4972
|
key: "attributeChangedCallback",
|
4973
4973
|
value: function attributeChangedCallback(e, t, i) {
|
4974
4974
|
if (t === i) return;
|
4975
|
-
var n =
|
4976
|
-
r =
|
4975
|
+
var n = be._attributes_[e](i),
|
4976
|
+
r = be._attributeToProperty_[e];
|
4977
4977
|
this[r] = n;
|
4978
4978
|
}
|
4979
4979
|
}, {
|
@@ -4982,12 +4982,12 @@ var ge = /*#__PURE__*/function (_HTMLElement) {
|
|
4982
4982
|
}], [{
|
4983
4983
|
key: "observedAttributes",
|
4984
4984
|
get: function get() {
|
4985
|
-
return Object.keys(
|
4985
|
+
return Object.keys(be._attributes_) || [];
|
4986
4986
|
}
|
4987
4987
|
}]);
|
4988
4988
|
}( /*#__PURE__*/_wrapNativeSuper(HTMLElement));
|
4989
|
-
|
4990
|
-
var Xi =
|
4989
|
+
be._attributes_ = {}, be._attributeToProperty_ = {};
|
4990
|
+
var Xi = be;
|
4991
4991
|
var ho = "<?xml version=\"1.0\" standalone=\"no\"?>\n<svg version=\"1.1\"\n\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n\txmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0.9em\" height=\"0.9em\"\n\tviewBox=\"0 0 1200 1200\" enable-background=\"new 0 0 1200 1200\">\n\t\t<path d=\"\n\t\t\tM669.727,273.516c-22.891-2.476-46.15-3.895-69.727-4.248c-103.025,0.457-209.823,25.517-310.913,73.536\n\t\t\tc-75.058,37.122-148.173,89.529-211.67,154.174C46.232,529.978,6.431,577.76,0,628.74c0.76,44.162,48.153,98.67,77.417,131.764\n\t\t\tc59.543,62.106,130.754,113.013,211.67,154.174c2.75,1.335,5.51,2.654,8.276,3.955l-75.072,131.102l102.005,60.286l551.416-960.033\n\t\t\tl-98.186-60.008L669.727,273.516z M902.563,338.995l-74.927,129.857c34.47,44.782,54.932,100.006,54.932,159.888\n\t\t\tc0,149.257-126.522,270.264-282.642,270.264c-6.749,0-13.29-0.728-19.922-1.172l-49.585,85.84c22.868,2.449,45.99,4.233,69.58,4.541\n\t\t\tc103.123-0.463,209.861-25.812,310.84-73.535c75.058-37.122,148.246-89.529,211.743-154.174\n\t\t\tc31.186-32.999,70.985-80.782,77.417-131.764c-0.76-44.161-48.153-98.669-77.417-131.763\n\t\t\tc-59.543-62.106-130.827-113.013-211.743-154.175C908.108,341.478,905.312,340.287,902.563,338.995L902.563,338.995z\n\t\t\tM599.927,358.478c6.846,0,13.638,0.274,20.361,0.732l-58.081,100.561c-81.514,16.526-142.676,85.88-142.676,168.897\n\t\t\tc0,20.854,3.841,40.819,10.913,59.325c0.008,0.021-0.008,0.053,0,0.074l-58.228,100.854\n\t\t\tc-34.551-44.823-54.932-100.229-54.932-160.182C317.285,479.484,443.808,358.477,599.927,358.478L599.927,358.478z M768.896,570.513\n\t\t\tL638.013,797.271c81.076-16.837,141.797-85.875,141.797-168.603C779.81,608.194,775.724,588.729,768.896,570.513L768.896,570.513z\"\n\t\t\t/>\n</svg>\n",
|
4992
4992
|
uo = "<?xml version=\"1.0\" standalone=\"no\"?>\n<svg version=\"1.1\"\n\txmlns:sodipodi=\"http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd\" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"\n\txmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"0.9em\" height=\"0.9em\"\n\tviewBox=\"0 0 1200 1200\" enable-background=\"new 0 0 1200 1200\">\n\t\t<path id=\"path6686\" inkscape:connector-curvature=\"0\" d=\"M779.843,599.925c0,95.331-80.664,172.612-180.169,172.612\n\t\t\tc-99.504,0-180.168-77.281-180.168-172.612c0-95.332,80.664-172.612,180.168-172.612\n\t\t\tC699.179,427.312,779.843,504.594,779.843,599.925z M600,240.521c-103.025,0.457-209.814,25.538-310.904,73.557\n\t\t\tc-75.058,37.122-148.206,89.496-211.702,154.141C46.208,501.218,6.431,549,0,599.981c0.76,44.161,48.13,98.669,77.394,131.763\n\t\t\tc59.543,62.106,130.786,113.018,211.702,154.179c94.271,45.751,198.616,72.092,310.904,73.557\n\t\t\tc103.123-0.464,209.888-25.834,310.866-73.557c75.058-37.122,148.243-89.534,211.74-154.179\n\t\t\tc31.185-32.999,70.962-80.782,77.394-131.763c-0.76-44.161-48.13-98.671-77.394-131.764\n\t\t\tc-59.543-62.106-130.824-112.979-211.74-154.141C816.644,268.36,712.042,242.2,600,240.521z M599.924,329.769\n\t\t\tc156.119,0,282.675,120.994,282.675,270.251c0,149.256-126.556,270.25-282.675,270.25S317.249,749.275,317.249,600.02\n\t\t\tC317.249,450.763,443.805,329.769,599.924,329.769L599.924,329.769z\"/>\n</svg>\n";
|
4993
4993
|
var X = /*#__PURE__*/function () {
|
@@ -5001,16 +5001,16 @@ var X = /*#__PURE__*/function () {
|
|
5001
5001
|
}
|
5002
5002
|
}]);
|
5003
5003
|
}();
|
5004
|
-
var
|
5005
|
-
function
|
5006
|
-
_classCallCheck(this,
|
5004
|
+
var Ie = /*#__PURE__*/function () {
|
5005
|
+
function Ie() {
|
5006
|
+
_classCallCheck(this, Ie);
|
5007
5007
|
}
|
5008
|
-
return _createClass(
|
5008
|
+
return _createClass(Ie, null, [{
|
5009
5009
|
key: "changeVisibility",
|
5010
5010
|
value:
|
5011
5011
|
// prettier-ignore
|
5012
5012
|
function changeVisibility(e, t, i, n) {
|
5013
|
-
n.target.id ===
|
5013
|
+
n.target.id === Ie.VISIBLE_ICON_ID ? (t.style.display = "none", i.style.display = "block", e.type = "password") : (t.style.display = "block", i.style.display = "none", e.type = "text");
|
5014
5014
|
}
|
5015
5015
|
}, {
|
5016
5016
|
key: "createIconElement",
|
@@ -5024,15 +5024,15 @@ var Re = /*#__PURE__*/function () {
|
|
5024
5024
|
value: function create(e) {
|
5025
5025
|
var t = document.createElement("div");
|
5026
5026
|
t.id = "visibility-icon-container";
|
5027
|
-
var i =
|
5027
|
+
var i = Ie.createIconElement(uo, Ie.VISIBLE_ICON_ID);
|
5028
5028
|
i.style.display = "none", t.appendChild(i);
|
5029
|
-
var n =
|
5030
|
-
return t.appendChild(n), t.onclick =
|
5029
|
+
var n = Ie.createIconElement(ho, "not-visible-icon");
|
5030
|
+
return t.appendChild(n), t.onclick = Ie.changeVisibility.bind(this, e, i, n), t;
|
5031
5031
|
}
|
5032
5032
|
}]);
|
5033
5033
|
}();
|
5034
|
-
|
5035
|
-
var Zi =
|
5034
|
+
Ie.VISIBLE_ICON_ID = "visible-icon";
|
5035
|
+
var Zi = Ie;
|
5036
5036
|
var D = /*#__PURE__*/function () {
|
5037
5037
|
function D() {
|
5038
5038
|
_classCallCheck(this, D);
|
@@ -5641,7 +5641,7 @@ var On = {
|
|
5641
5641
|
this.streamHandlers.abortStream.abort = function () {
|
5642
5642
|
i.interruptGenerate();
|
5643
5643
|
}, this.streamHandlers.onOpen();
|
5644
|
-
n = new
|
5644
|
+
n = new Se(e);
|
5645
5645
|
_context30.next = 4;
|
5646
5646
|
return i.generate(t, /*#__PURE__*/function () {
|
5647
5647
|
var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee29(r, o) {
|
@@ -5953,7 +5953,7 @@ var St = /*#__PURE__*/function (_U) {
|
|
5953
5953
|
throw new Error("Request settings have not been set up");
|
5954
5954
|
case 2:
|
5955
5955
|
n = this.preprocessBody(this.rawBody, t, i);
|
5956
|
-
|
5956
|
+
C.request(this, n, e);
|
5957
5957
|
case 4:
|
5958
5958
|
case "end":
|
5959
5959
|
return _context35.stop();
|
@@ -5968,8 +5968,8 @@ var St = /*#__PURE__*/function (_U) {
|
|
5968
5968
|
}]);
|
5969
5969
|
}(U);
|
5970
5970
|
St.URL_PREFIX = "https://api-inference.huggingface.co/models/";
|
5971
|
-
var
|
5972
|
-
var Dt = /*#__PURE__*/function (
|
5971
|
+
var we = St;
|
5972
|
+
var Dt = /*#__PURE__*/function (_we) {
|
5973
5973
|
// prettier-ignore
|
5974
5974
|
function Dt(e, t, i, n, r, o) {
|
5975
5975
|
var _this17;
|
@@ -5977,7 +5977,7 @@ var Dt = /*#__PURE__*/function (_Se) {
|
|
5977
5977
|
_this17 = _callSuper(this, Dt, [e, t, i, n, r, o]), _this17.isTextInputDisabled = !0, _this17.canSendMessage = Dt.canSendFile;
|
5978
5978
|
return _this17;
|
5979
5979
|
}
|
5980
|
-
_inherits(Dt,
|
5980
|
+
_inherits(Dt, _we);
|
5981
5981
|
return _createClass(Dt, [{
|
5982
5982
|
key: "preprocessBody",
|
5983
5983
|
value: function preprocessBody(e, t, i) {
|
@@ -6003,7 +6003,7 @@ var Dt = /*#__PURE__*/function (_Se) {
|
|
6003
6003
|
}
|
6004
6004
|
throw new Error("No file was added");
|
6005
6005
|
case 4:
|
6006
|
-
|
6006
|
+
C.poll(this, i[0], e, !1);
|
6007
6007
|
case 5:
|
6008
6008
|
case "end":
|
6009
6009
|
return _context36.stop();
|
@@ -6021,7 +6021,7 @@ var Dt = /*#__PURE__*/function (_Se) {
|
|
6021
6021
|
return !!(t != null && t[0]);
|
6022
6022
|
}
|
6023
6023
|
}]);
|
6024
|
-
}(
|
6024
|
+
}(we);
|
6025
6025
|
var fo = /*#__PURE__*/function (_Dt) {
|
6026
6026
|
// prettier-ignore
|
6027
6027
|
function fo(e) {
|
@@ -6122,11 +6122,11 @@ var po = /*#__PURE__*/function (_Dt2) {
|
|
6122
6122
|
}]);
|
6123
6123
|
}(Dt);
|
6124
6124
|
var Ft = "data:image/png;base64,";
|
6125
|
-
var
|
6126
|
-
function
|
6127
|
-
_classCallCheck(this,
|
6125
|
+
var me = /*#__PURE__*/function () {
|
6126
|
+
function me() {
|
6127
|
+
_classCallCheck(this, me);
|
6128
6128
|
}
|
6129
|
-
return _createClass(
|
6129
|
+
return _createClass(me, null, [{
|
6130
6130
|
key: "buildHeaders",
|
6131
6131
|
value: function buildHeaders(e) {
|
6132
6132
|
return {
|
@@ -6146,7 +6146,7 @@ var pe = /*#__PURE__*/function () {
|
|
6146
6146
|
return {
|
6147
6147
|
url: "https://api.stability.ai/v1/engines/list",
|
6148
6148
|
method: "GET",
|
6149
|
-
handleVerificationResult:
|
6149
|
+
handleVerificationResult: me.handleVerificationResult
|
6150
6150
|
};
|
6151
6151
|
}
|
6152
6152
|
}]);
|
@@ -6177,7 +6177,7 @@ var ni = /*#__PURE__*/function (_i10) {
|
|
6177
6177
|
}
|
6178
6178
|
}
|
6179
6179
|
};
|
6180
|
-
_this19 = _callSuper(this, ni, [e,
|
6180
|
+
_this19 = _callSuper(this, ni, [e, me.buildKeyVerificationDetails(), me.buildHeaders, i, n]), _this19.url = "https://api.stability.ai/v1/generation/esrgan-v1-x2plus/image-to-image/upscale", _this19.textInputPlaceholderText = "Describe image changes", _this19.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI</b></div>\n <div style=\"width: 100%; text-align: center; margin-left: -10px; margin-top: 5px\"><b>Image to Image Upscale</b></div>\n <p>Upload an image to generate a new one with higher resolution.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6181
6181
|
var r = (o = t == null ? void 0 : t.stabilityAI) == null ? void 0 : o.imageToImageUpscale;
|
6182
6182
|
_typeof(r) == "object" && (r.engine_id && (_this19.url = "https://api.stability.ai/v1/generation/".concat(r.engine_id, "/image-to-image/upscale")), ni.cleanConfig(r), Object.assign(_this19.rawBody, r)), _this19.canSendMessage = ni.canSendFileMessage;
|
6183
6183
|
return _this19;
|
@@ -6213,7 +6213,7 @@ var ni = /*#__PURE__*/function (_i10) {
|
|
6213
6213
|
throw new Error("Image was not found");
|
6214
6214
|
case 4:
|
6215
6215
|
n = this.createFormDataBody(this.rawBody, i[0]);
|
6216
|
-
v.tempRemoveContentHeader(this.connectSettings,
|
6216
|
+
v.tempRemoveContentHeader(this.connectSettings, C.request.bind(this, this, n, e), !1);
|
6217
6217
|
case 6:
|
6218
6218
|
case "end":
|
6219
6219
|
return _context39.stop();
|
@@ -6284,7 +6284,7 @@ var si = /*#__PURE__*/function (_i11) {
|
|
6284
6284
|
}
|
6285
6285
|
}
|
6286
6286
|
};
|
6287
|
-
_this20 = _callSuper(this, si, [e,
|
6287
|
+
_this20 = _callSuper(this, si, [e, me.buildKeyVerificationDetails(), me.buildHeaders, i, n]), _this20.url = "https://api.stability.ai/v1/generation/stable-diffusion-xl-1024-v1-0/image-to-image/masking", _this20._maskSource = "MASK_IMAGE_WHITE", _this20.textInputPlaceholderText = "Describe image changes", _this20.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI</b></div>\n <div style=\"width: 100%; text-align: center; margin-left: -10px; margin-top: 5px\"><b>Image to Image Masking</b></div>\n <p>Upload an image, its mask image to create a new one based on the changes you have described for the mask area.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6288
6288
|
var r = (o = t == null ? void 0 : t.stabilityAI) == null ? void 0 : o.imageToImageMasking;
|
6289
6289
|
_typeof(r) == "object" && (r.engine_id && (_this20.url = "https://api.stability.ai/v1/generation/".concat(r.engine_id, "/image-to-image/masking")), r.weight !== void 0 && r.weight !== null && (_this20._imageWeight = r.weight), r.mask_source !== void 0 && r.mask_source !== null && (_this20._maskSource = r.mask_source), si.cleanConfig(r), Object.assign(_this20.rawBody, r)), _this20.canSendMessage = si.canSendFileTextMessage;
|
6290
6290
|
return _this20;
|
@@ -6320,7 +6320,7 @@ var si = /*#__PURE__*/function (_i11) {
|
|
6320
6320
|
throw new Error("Image was not found");
|
6321
6321
|
case 4:
|
6322
6322
|
n = (a = (o = t[t.length - 1]) == null ? void 0 : o.text) == null ? void 0 : a.trim(), r = this.createFormDataBody(this.rawBody, i[0], i[1], n);
|
6323
|
-
v.tempRemoveContentHeader(this.connectSettings,
|
6323
|
+
v.tempRemoveContentHeader(this.connectSettings, C.request.bind(this, this, r, e), !1);
|
6324
6324
|
case 6:
|
6325
6325
|
case "end":
|
6326
6326
|
return _context41.stop();
|
@@ -6424,7 +6424,7 @@ var mo = /*#__PURE__*/function (_Dt3) {
|
|
6424
6424
|
}()
|
6425
6425
|
}]);
|
6426
6426
|
}(Dt);
|
6427
|
-
var go = /*#__PURE__*/function (
|
6427
|
+
var go = /*#__PURE__*/function (_we2) {
|
6428
6428
|
function go(e) {
|
6429
6429
|
_classCallCheck(this, go);
|
6430
6430
|
var n, r, o;
|
@@ -6432,7 +6432,7 @@ var go = /*#__PURE__*/function (_Se2) {
|
|
6432
6432
|
i = (o = e.directConnection) == null ? void 0 : o.huggingFace;
|
6433
6433
|
return _callSuper(this, go, [e, "Once upon a time", "gpt2", t, i]);
|
6434
6434
|
}
|
6435
|
-
_inherits(go,
|
6435
|
+
_inherits(go, _we2);
|
6436
6436
|
return _createClass(go, [{
|
6437
6437
|
key: "extractResultData",
|
6438
6438
|
value: function () {
|
@@ -6462,8 +6462,8 @@ var go = /*#__PURE__*/function (_Se2) {
|
|
6462
6462
|
return extractResultData;
|
6463
6463
|
}()
|
6464
6464
|
}]);
|
6465
|
-
}(
|
6466
|
-
var bo = /*#__PURE__*/function (
|
6465
|
+
}(we);
|
6466
|
+
var bo = /*#__PURE__*/function (_we3) {
|
6467
6467
|
function bo(e) {
|
6468
6468
|
var _this21;
|
6469
6469
|
_classCallCheck(this, bo);
|
@@ -6473,7 +6473,7 @@ var bo = /*#__PURE__*/function (_Se3) {
|
|
6473
6473
|
_this21 = _callSuper(this, bo, [e, "Ask a question", "bert-large-uncased-whole-word-masking-finetuned-squad", t, i]), _this21.permittedErrorPrefixes = ["Authorization header", "Error in"], _this21.context = t.context;
|
6474
6474
|
return _this21;
|
6475
6475
|
}
|
6476
|
-
_inherits(bo,
|
6476
|
+
_inherits(bo, _we3);
|
6477
6477
|
return _createClass(bo, [{
|
6478
6478
|
key: "preprocessBody",
|
6479
6479
|
value: function preprocessBody(e, t) {
|
@@ -6516,8 +6516,8 @@ var bo = /*#__PURE__*/function (_Se3) {
|
|
6516
6516
|
return extractResultData;
|
6517
6517
|
}()
|
6518
6518
|
}]);
|
6519
|
-
}(
|
6520
|
-
var vo = /*#__PURE__*/function (
|
6519
|
+
}(we);
|
6520
|
+
var vo = /*#__PURE__*/function (_we4) {
|
6521
6521
|
function vo(e) {
|
6522
6522
|
_classCallCheck(this, vo);
|
6523
6523
|
var n, r, o;
|
@@ -6525,7 +6525,7 @@ var vo = /*#__PURE__*/function (_Se4) {
|
|
6525
6525
|
i = (o = e.directConnection) == null ? void 0 : o.huggingFace;
|
6526
6526
|
return _callSuper(this, vo, [e, "Insert text to summarize", "facebook/bart-large-cnn", t, i]);
|
6527
6527
|
}
|
6528
|
-
_inherits(vo,
|
6528
|
+
_inherits(vo, _we4);
|
6529
6529
|
return _createClass(vo, [{
|
6530
6530
|
key: "extractResultData",
|
6531
6531
|
value: function () {
|
@@ -6555,8 +6555,8 @@ var vo = /*#__PURE__*/function (_Se4) {
|
|
6555
6555
|
return extractResultData;
|
6556
6556
|
}()
|
6557
6557
|
}]);
|
6558
|
-
}(
|
6559
|
-
var yo = /*#__PURE__*/function (
|
6558
|
+
}(we);
|
6559
|
+
var yo = /*#__PURE__*/function (_we5) {
|
6560
6560
|
function yo(e) {
|
6561
6561
|
var _this22$maxMessages;
|
6562
6562
|
var _this22;
|
@@ -6568,7 +6568,7 @@ var yo = /*#__PURE__*/function (_Se5) {
|
|
6568
6568
|
return _this22;
|
6569
6569
|
}
|
6570
6570
|
// prettier-ignore
|
6571
|
-
_inherits(yo,
|
6571
|
+
_inherits(yo, _we5);
|
6572
6572
|
return _createClass(yo, [{
|
6573
6573
|
key: "processMessages",
|
6574
6574
|
value: function processMessages(e) {
|
@@ -6637,7 +6637,7 @@ var yo = /*#__PURE__*/function (_Se5) {
|
|
6637
6637
|
return extractResultData;
|
6638
6638
|
}()
|
6639
6639
|
}]);
|
6640
|
-
}(
|
6640
|
+
}(we);
|
6641
6641
|
var ri = /*#__PURE__*/function (_i12) {
|
6642
6642
|
function ri(e) {
|
6643
6643
|
var _this23;
|
@@ -6653,7 +6653,7 @@ var ri = /*#__PURE__*/function (_i12) {
|
|
6653
6653
|
}
|
6654
6654
|
}
|
6655
6655
|
};
|
6656
|
-
_this23 = _callSuper(this, ri, [e,
|
6656
|
+
_this23 = _callSuper(this, ri, [e, me.buildKeyVerificationDetails(), me.buildHeaders, i, n]), _this23.url = "https://api.stability.ai/v1/generation/stable-diffusion-v1-6/image-to-image", _this23.textInputPlaceholderText = "Describe image changes", _this23.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI: Image to Image</b></div>\n <p>Upload an image to create a new one with the changes you have described.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6657
6657
|
var r = (o = t.stabilityAI) == null ? void 0 : o.imageToImage;
|
6658
6658
|
_typeof(r) == "object" && (r.engine_id && (_this23.url = "https://api.stability.ai/v1/generation/".concat(r.engine_id, "/text-to-image")), r.weight !== void 0 && r.weight !== null && (_this23._imageWeight = r.weight), ri.cleanConfig(r), Object.assign(_this23.rawBody, r)), _this23.canSendMessage = ri.canSendFileTextMessage;
|
6659
6659
|
return _this23;
|
@@ -6689,7 +6689,7 @@ var ri = /*#__PURE__*/function (_i12) {
|
|
6689
6689
|
throw new Error("Image was not found");
|
6690
6690
|
case 4:
|
6691
6691
|
n = (a = (o = t[t.length - 1]) == null ? void 0 : o.text) == null ? void 0 : a.trim(), r = this.createFormDataBody(this.rawBody, i[0], n);
|
6692
|
-
v.tempRemoveContentHeader(this.connectSettings,
|
6692
|
+
v.tempRemoveContentHeader(this.connectSettings, C.request.bind(this, this, r, e), !1);
|
6693
6693
|
case 6:
|
6694
6694
|
case "end":
|
6695
6695
|
return _context48.stop();
|
@@ -6745,7 +6745,7 @@ var ri = /*#__PURE__*/function (_i12) {
|
|
6745
6745
|
}
|
6746
6746
|
}]);
|
6747
6747
|
}(_i);
|
6748
|
-
var Eo = /*#__PURE__*/function (
|
6748
|
+
var Eo = /*#__PURE__*/function (_we6) {
|
6749
6749
|
function Eo(e) {
|
6750
6750
|
_classCallCheck(this, Eo);
|
6751
6751
|
var n, r, o;
|
@@ -6753,7 +6753,7 @@ var Eo = /*#__PURE__*/function (_Se6) {
|
|
6753
6753
|
i = (o = e.directConnection) == null ? void 0 : o.huggingFace;
|
6754
6754
|
return _callSuper(this, Eo, [e, "Insert text to translate", "Helsinki-NLP/opus-tatoeba-en-ja", t, i]);
|
6755
6755
|
}
|
6756
|
-
_inherits(Eo,
|
6756
|
+
_inherits(Eo, _we6);
|
6757
6757
|
return _createClass(Eo, [{
|
6758
6758
|
key: "extractResultData",
|
6759
6759
|
value: function () {
|
@@ -6783,7 +6783,7 @@ var Eo = /*#__PURE__*/function (_Se6) {
|
|
6783
6783
|
return extractResultData;
|
6784
6784
|
}()
|
6785
6785
|
}]);
|
6786
|
-
}(
|
6786
|
+
}(we);
|
6787
6787
|
var oi = /*#__PURE__*/function (_i13) {
|
6788
6788
|
function oi(e) {
|
6789
6789
|
var _this24;
|
@@ -6791,7 +6791,7 @@ var oi = /*#__PURE__*/function (_i13) {
|
|
6791
6791
|
var r;
|
6792
6792
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
6793
6793
|
i = t.stabilityAI;
|
6794
|
-
_this24 = _callSuper(this, oi, [e,
|
6794
|
+
_this24 = _callSuper(this, oi, [e, me.buildKeyVerificationDetails(), me.buildHeaders, i]), _this24.url = "https://api.stability.ai/v1/generation/stable-diffusion-v1-6/text-to-image", _this24.textInputPlaceholderText = "Describe an image", _this24.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Stability AI: Text to Image</b></div>\n <p>Insert text to generate an image.</p>\n <p>Click <a href=\"https://platform.stability.ai/\">here</a> for more info.</p>";
|
6795
6795
|
var n = (r = t.stabilityAI) == null ? void 0 : r.textToImage;
|
6796
6796
|
_typeof(n) == "object" && (n.engine_id && (_this24.url = "https://api.stability.ai/v1/generation/".concat(n.engine_id, "/text-to-image")), n.weight !== void 0 && n.weight !== null && (_this24._imageWeight = n.weight), oi.cleanConfig(n), Object.assign(_this24.rawBody, n)), _this24.canSendMessage = oi.canSendTextMessage;
|
6797
6797
|
return _this24;
|
@@ -6821,7 +6821,7 @@ var oi = /*#__PURE__*/function (_i13) {
|
|
6821
6821
|
throw new Error("Request settings have not been set up");
|
6822
6822
|
case 2:
|
6823
6823
|
i = this.preprocessBody(this.rawBody, t[t.length - 1].text);
|
6824
|
-
|
6824
|
+
C.request(this, i, e);
|
6825
6825
|
case 4:
|
6826
6826
|
case "end":
|
6827
6827
|
return _context51.stop();
|
@@ -6877,7 +6877,7 @@ var oi = /*#__PURE__*/function (_i13) {
|
|
6877
6877
|
}
|
6878
6878
|
}]);
|
6879
6879
|
}(_i);
|
6880
|
-
var xo = /*#__PURE__*/function (
|
6880
|
+
var xo = /*#__PURE__*/function (_we7) {
|
6881
6881
|
function xo(e) {
|
6882
6882
|
var _this25;
|
6883
6883
|
_classCallCheck(this, xo);
|
@@ -6887,7 +6887,7 @@ var xo = /*#__PURE__*/function (_Se7) {
|
|
6887
6887
|
_this25 = _callSuper(this, xo, [e, "The goal of life is [MASK].", "bert-base-uncased", t, i]), _this25.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>Hugging Face</b></div>\n <p>Insert a sentence with the word [MASK] and the model will try to fill it for you. E.g. I want [MASK].</p>\n <p>First message may take an extented amount of time to complete as the model needs to be initialized.</p>", _this25.permittedErrorPrefixes = ["Authorization header", "No mask_token"];
|
6888
6888
|
return _this25;
|
6889
6889
|
}
|
6890
|
-
_inherits(xo,
|
6890
|
+
_inherits(xo, _we7);
|
6891
6891
|
return _createClass(xo, [{
|
6892
6892
|
key: "extractResultData",
|
6893
6893
|
value: function () {
|
@@ -6917,7 +6917,7 @@ var xo = /*#__PURE__*/function (_Se7) {
|
|
6917
6917
|
return extractResultData;
|
6918
6918
|
}()
|
6919
6919
|
}]);
|
6920
|
-
}(
|
6920
|
+
}(we);
|
6921
6921
|
var ai = /*#__PURE__*/function () {
|
6922
6922
|
function ai() {
|
6923
6923
|
_classCallCheck(this, ai);
|
@@ -6995,7 +6995,7 @@ var _o = /*#__PURE__*/function (_un) {
|
|
6995
6995
|
throw new Error("Request settings have not been set up");
|
6996
6996
|
case 2:
|
6997
6997
|
i = this.preprocessBody(this.rawBody, t);
|
6998
|
-
|
6998
|
+
C.request(this, i, e);
|
6999
6999
|
case 4:
|
7000
7000
|
case "end":
|
7001
7001
|
return _context54.stop();
|
@@ -7070,7 +7070,7 @@ var So = /*#__PURE__*/function (_un2) {
|
|
7070
7070
|
throw new Error("Request settings have not been set up");
|
7071
7071
|
case 2:
|
7072
7072
|
i = this.preprocessBody(this.rawBody, t);
|
7073
|
-
|
7073
|
+
C.request(this, i, e);
|
7074
7074
|
case 4:
|
7075
7075
|
case "end":
|
7076
7076
|
return _context56.stop();
|
@@ -7216,7 +7216,7 @@ var nt = /*#__PURE__*/function (_U4) {
|
|
7216
7216
|
case 2:
|
7217
7217
|
this.url = this.connectSettings.url || this.url;
|
7218
7218
|
i = this.preprocessBody(this.rawBody, t);
|
7219
|
-
|
7219
|
+
C.request(this, i, e);
|
7220
7220
|
case 5:
|
7221
7221
|
case "end":
|
7222
7222
|
return _context59.stop();
|
@@ -7327,7 +7327,7 @@ var oe = /*#__PURE__*/function (_U5) {
|
|
7327
7327
|
case 4:
|
7328
7328
|
this.url = this.connectSettings.url || this._service_url;
|
7329
7329
|
n = this.preprocessBody(this.rawBody, t), r = oe.createFormDataBody(n, i[0]);
|
7330
|
-
v.tempRemoveContentHeader(this.connectSettings,
|
7330
|
+
v.tempRemoveContentHeader(this.connectSettings, C.request.bind(this, this, r, e), !1);
|
7331
7331
|
case 7:
|
7332
7332
|
case "end":
|
7333
7333
|
return _context61.stop();
|
@@ -7502,19 +7502,19 @@ var wo = /*#__PURE__*/function (_U6) {
|
|
7502
7502
|
_inherits(wo, _U6);
|
7503
7503
|
return _createClass(wo);
|
7504
7504
|
}(U);
|
7505
|
-
var
|
7506
|
-
function
|
7505
|
+
var Co = /*#__PURE__*/function (_wo) {
|
7506
|
+
function Co(e) {
|
7507
7507
|
var _a$language;
|
7508
7508
|
var _this30;
|
7509
|
-
_classCallCheck(this,
|
7509
|
+
_classCallCheck(this, Co);
|
7510
7510
|
var n, r, o, a;
|
7511
7511
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.azure) == null ? void 0 : r.summarization,
|
7512
7512
|
i = (o = e.directConnection) == null ? void 0 : o.azure;
|
7513
|
-
_this30 = _callSuper(this,
|
7513
|
+
_this30 = _callSuper(this, Co, [e, ie.buildSummarizationHeader, t.endpoint, i]), _this30.url = "", _this30.textInputPlaceholderText = "Insert text to summarize", (_a$language = (a = _this30.rawBody).language) !== null && _a$language !== void 0 ? _a$language : a.language = "en", Object.assign(_this30.rawBody, t), _this30.url = "".concat(t.endpoint, "/language/analyze-text/jobs?api-version=2022-10-01-preview");
|
7514
7514
|
return _this30;
|
7515
7515
|
}
|
7516
|
-
_inherits(
|
7517
|
-
return _createClass(
|
7516
|
+
_inherits(Co, _wo);
|
7517
|
+
return _createClass(Co, [{
|
7518
7518
|
key: "preprocessBody",
|
7519
7519
|
value: function preprocessBody(e, t) {
|
7520
7520
|
var i = t[t.length - 1].text;
|
@@ -7546,7 +7546,7 @@ var To = /*#__PURE__*/function (_wo) {
|
|
7546
7546
|
throw new Error("Request settings have not been set up");
|
7547
7547
|
case 2:
|
7548
7548
|
i = this.preprocessBody(this.rawBody, t);
|
7549
|
-
|
7549
|
+
C.request(this, i, e), this.messages = e;
|
7550
7550
|
case 4:
|
7551
7551
|
case "end":
|
7552
7552
|
return _context63.stop();
|
@@ -7577,7 +7577,7 @@ var To = /*#__PURE__*/function (_wo) {
|
|
7577
7577
|
method: "GET",
|
7578
7578
|
headers: (t = this.connectSettings) == null ? void 0 : t.headers
|
7579
7579
|
};
|
7580
|
-
|
7580
|
+
C.executePollRequest(this, _i14, n, this.messages);
|
7581
7581
|
}
|
7582
7582
|
return _context64.abrupt("return", {
|
7583
7583
|
makingAnotherRequest: !0
|
@@ -7792,7 +7792,7 @@ var fn = /*#__PURE__*/function (_U7) {
|
|
7792
7792
|
}
|
7793
7793
|
throw new Error("No file was added");
|
7794
7794
|
case 4:
|
7795
|
-
|
7795
|
+
C.request(this, i[0], e, !1);
|
7796
7796
|
case 5:
|
7797
7797
|
case "end":
|
7798
7798
|
return _context67.stop();
|
@@ -7891,7 +7891,7 @@ var vi = /*#__PURE__*/function (_ls) {
|
|
7891
7891
|
throw new Error("Request settings have not been set up");
|
7892
7892
|
case 2:
|
7893
7893
|
i = this.preprocessBody(this.rawBody, t);
|
7894
|
-
|
7894
|
+
C.request(this, i, e, !1);
|
7895
7895
|
case 4:
|
7896
7896
|
case "end":
|
7897
7897
|
return _context69.stop();
|
@@ -7978,7 +7978,7 @@ var wt = /*#__PURE__*/function (_ls2) {
|
|
7978
7978
|
}
|
7979
7979
|
throw new Error("No file was added");
|
7980
7980
|
case 4:
|
7981
|
-
(r = this.connectSettings) != null && r.headers && (this.connectSettings.headers["Content-Type"] = i[0].name.toLocaleLowerCase().endsWith(".wav") ? "audio/wav; codecs=audio/pcm; samplerate=16000" : "audio/ogg; codecs=opus"),
|
7981
|
+
(r = this.connectSettings) != null && r.headers && (this.connectSettings.headers["Content-Type"] = i[0].name.toLocaleLowerCase().endsWith(".wav") ? "audio/wav; codecs=audio/pcm; samplerate=16000" : "audio/ogg; codecs=opus"), C.request(this, i[0], e, !1);
|
7982
7982
|
case 5:
|
7983
7983
|
case "end":
|
7984
7984
|
return _context71.stop();
|
@@ -8028,21 +8028,21 @@ wt.HELP_LINK =
|
|
8028
8028
|
// eslint-disable-next-line max-len
|
8029
8029
|
"https://learn.microsoft.com/en-GB/azure/cognitive-services/speech-service/get-started-text-to-speech?tabs=windows%2Cterminal&pivots=programming-language-rest";
|
8030
8030
|
var tn = wt;
|
8031
|
-
var
|
8031
|
+
var To = /*#__PURE__*/function (_U9) {
|
8032
8032
|
// prettier-ignore
|
8033
|
-
function
|
8033
|
+
function To(e) {
|
8034
8034
|
var _this35;
|
8035
|
-
_classCallCheck(this,
|
8035
|
+
_classCallCheck(this, To);
|
8036
8036
|
var n, r, o;
|
8037
8037
|
var t = (r = (n = e.directConnection) == null ? void 0 : n.azure) == null ? void 0 : r.translation,
|
8038
8038
|
i = (o = e.directConnection) == null ? void 0 : o.azure;
|
8039
|
-
_this35 = _callSuper(this,
|
8039
|
+
_this35 = _callSuper(this, To, [e, ie.buildTranslationKeyVerificationDetails(t.region), ie.buildTranslationHeaders.bind({}, t == null ? void 0 : t.region), i]), _this35.insertKeyPlaceholderText = "Azure Translate Subscription Key", _this35.keyHelpUrl =
|
8040
8040
|
// eslint-disable-next-line max-len
|
8041
8041
|
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal", _this35.url = "", _this35.url = "https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=".concat(t.language || "es");
|
8042
8042
|
return _this35;
|
8043
8043
|
}
|
8044
|
-
_inherits(
|
8045
|
-
return _createClass(
|
8044
|
+
_inherits(To, _U9);
|
8045
|
+
return _createClass(To, [{
|
8046
8046
|
key: "preprocessBody",
|
8047
8047
|
value: function preprocessBody(e) {
|
8048
8048
|
var t = e[e.length - 1].text;
|
@@ -8065,7 +8065,7 @@ var Co = /*#__PURE__*/function (_U9) {
|
|
8065
8065
|
throw new Error("Request settings have not been set up");
|
8066
8066
|
case 2:
|
8067
8067
|
i = this.preprocessBody(t);
|
8068
|
-
|
8068
|
+
C.request(this, i, e);
|
8069
8069
|
case 4:
|
8070
8070
|
case "end":
|
8071
8071
|
return _context73.stop();
|
@@ -8107,11 +8107,11 @@ var Co = /*#__PURE__*/function (_U9) {
|
|
8107
8107
|
}()
|
8108
8108
|
}]);
|
8109
8109
|
}(U);
|
8110
|
-
var
|
8111
|
-
function
|
8112
|
-
_classCallCheck(this,
|
8110
|
+
var ce = /*#__PURE__*/function () {
|
8111
|
+
function ce() {
|
8112
|
+
_classCallCheck(this, ce);
|
8113
8113
|
}
|
8114
|
-
return _createClass(
|
8114
|
+
return _createClass(ce, null, [{
|
8115
8115
|
key: "storeFiles",
|
8116
8116
|
value: function () {
|
8117
8117
|
var _storeFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee76(e, t, i) {
|
@@ -8202,7 +8202,7 @@ var Ie = /*#__PURE__*/function () {
|
|
8202
8202
|
l({
|
8203
8203
|
src: d.target.result,
|
8204
8204
|
name: t[a].name,
|
8205
|
-
type:
|
8205
|
+
type: ce.getType(t, a)
|
8206
8206
|
});
|
8207
8207
|
};
|
8208
8208
|
});
|
@@ -8240,7 +8240,7 @@ var Ie = /*#__PURE__*/function () {
|
|
8240
8240
|
l.text && l.text.startsWith("sandbox:") && (c = l.file_path) != null && c.file_id && i.push({
|
8241
8241
|
path: l.text,
|
8242
8242
|
fileId: l.file_path.file_id,
|
8243
|
-
name:
|
8243
|
+
name: ce.getFileName(l.text)
|
8244
8244
|
});
|
8245
8245
|
});
|
8246
8246
|
}), t != null && t.image_file && i.push({
|
@@ -8262,7 +8262,7 @@ var Ie = /*#__PURE__*/function () {
|
|
8262
8262
|
break;
|
8263
8263
|
}
|
8264
8264
|
_context78.next = 4;
|
8265
|
-
return
|
8265
|
+
return ce.getFiles(e, t);
|
8266
8266
|
case 4:
|
8267
8267
|
r = _context78.sent;
|
8268
8268
|
(o = n == null ? void 0 : n.text) != null && o.value && r.forEach(function (l, c) {
|
@@ -8296,9 +8296,9 @@ var Ie = /*#__PURE__*/function () {
|
|
8296
8296
|
return _regeneratorRuntime().wrap(function _callee79$(_context79) {
|
8297
8297
|
while (1) switch (_context79.prev = _context79.next) {
|
8298
8298
|
case 0:
|
8299
|
-
n =
|
8299
|
+
n = ce.getFileDetails(t, i);
|
8300
8300
|
_context79.next = 3;
|
8301
|
-
return
|
8301
|
+
return ce.getFilesAndNewText(e, n, t.role, i);
|
8302
8302
|
case 3:
|
8303
8303
|
return _context79.abrupt("return", _context79.sent);
|
8304
8304
|
case 4:
|
@@ -8312,6 +8312,79 @@ var Ie = /*#__PURE__*/function () {
|
|
8312
8312
|
}
|
8313
8313
|
return getFilesAndText;
|
8314
8314
|
}()
|
8315
|
+
}, {
|
8316
|
+
key: "parseMesages",
|
8317
|
+
value: function parseMesages(e, t) {
|
8318
|
+
var i = [];
|
8319
|
+
if (t) i = e.data;else for (var n = 0; n < e.data.length; n += 1) {
|
8320
|
+
var r = e.data[n];
|
8321
|
+
if (r.role === "assistant") i.push(r);else break;
|
8322
|
+
}
|
8323
|
+
return i;
|
8324
|
+
}
|
8325
|
+
// test this using this prompt and it should give 2 text mesages and a file:
|
8326
|
+
// "give example data for a csv and create a suitable bar chart"
|
8327
|
+
}, {
|
8328
|
+
key: "parseContent",
|
8329
|
+
value: function parseContent(e, t) {
|
8330
|
+
var i = [];
|
8331
|
+
return t.forEach( /*#__PURE__*/function () {
|
8332
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee81(n) {
|
8333
|
+
return _regeneratorRuntime().wrap(function _callee81$(_context81) {
|
8334
|
+
while (1) switch (_context81.prev = _context81.next) {
|
8335
|
+
case 0:
|
8336
|
+
n.content.filter(function (r) {
|
8337
|
+
return !!r.text || !!r.image_file;
|
8338
|
+
}).sort(function (r) {
|
8339
|
+
return r.text ? -1 : r.image_file ? 1 : 0;
|
8340
|
+
}).forEach( /*#__PURE__*/function () {
|
8341
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee80(r) {
|
8342
|
+
return _regeneratorRuntime().wrap(function _callee80$(_context80) {
|
8343
|
+
while (1) switch (_context80.prev = _context80.next) {
|
8344
|
+
case 0:
|
8345
|
+
i.push(ce.getFilesAndText(e, n, r));
|
8346
|
+
case 1:
|
8347
|
+
case "end":
|
8348
|
+
return _context80.stop();
|
8349
|
+
}
|
8350
|
+
}, _callee80);
|
8351
|
+
}));
|
8352
|
+
return function (_x151) {
|
8353
|
+
return _ref12.apply(this, arguments);
|
8354
|
+
};
|
8355
|
+
}());
|
8356
|
+
case 1:
|
8357
|
+
case "end":
|
8358
|
+
return _context81.stop();
|
8359
|
+
}
|
8360
|
+
}, _callee81);
|
8361
|
+
}));
|
8362
|
+
return function (_x150) {
|
8363
|
+
return _ref11.apply(this, arguments);
|
8364
|
+
};
|
8365
|
+
}()), i;
|
8366
|
+
}
|
8367
|
+
}, {
|
8368
|
+
key: "processAPIMessages",
|
8369
|
+
value: function () {
|
8370
|
+
var _processAPIMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee82(e, t, i) {
|
8371
|
+
var n, r;
|
8372
|
+
return _regeneratorRuntime().wrap(function _callee82$(_context82) {
|
8373
|
+
while (1) switch (_context82.prev = _context82.next) {
|
8374
|
+
case 0:
|
8375
|
+
n = ce.parseMesages(t, i), r = ce.parseContent(e, n);
|
8376
|
+
return _context82.abrupt("return", Promise.all(r));
|
8377
|
+
case 2:
|
8378
|
+
case "end":
|
8379
|
+
return _context82.stop();
|
8380
|
+
}
|
8381
|
+
}, _callee82);
|
8382
|
+
}));
|
8383
|
+
function processAPIMessages(_x152, _x153, _x154) {
|
8384
|
+
return _processAPIMessages.apply(this, arguments);
|
8385
|
+
}
|
8386
|
+
return processAPIMessages;
|
8387
|
+
}()
|
8315
8388
|
}]);
|
8316
8389
|
}();
|
8317
8390
|
var F = /*#__PURE__*/function (_U10) {
|
@@ -8333,8 +8406,8 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8333
8406
|
u = _this36$config.thread_id,
|
8334
8407
|
f = _this36$config.load_thread_history;
|
8335
8408
|
Object.assign(_this36.newAssistantDetails, h), u && (_this36.sessionId = u), f && (_this36.shouldFetchHistory = !0);
|
8336
|
-
var
|
8337
|
-
m =
|
8409
|
+
var _ref13 = (a = (o = e.directConnection) == null ? void 0 : o.openAI) == null ? void 0 : a.assistant,
|
8410
|
+
m = _ref13.function_handler;
|
8338
8411
|
m && (_this36._functionHandler = m);
|
8339
8412
|
} else (l = t.openAI) != null && l.assistant && (t.openAI.assistant = n);
|
8340
8413
|
(_c$headers = (c = _this36.connectSettings).headers) !== null && _c$headers !== void 0 ? _c$headers : c.headers = {}, (_d$OpenAIBeta = (d = _this36.connectSettings.headers)["OpenAI-Beta"]) !== null && _d$OpenAIBeta !== void 0 ? _d$OpenAIBeta : d["OpenAI-Beta"] = "assistants=v1", _this36.maxMessages = 1, _this36.isSSEStream = !!(_this36.stream && (_typeof(_this36.stream) != "object" || !_this36.stream.simulation)), _this36.shouldFetchHistory && _this36.sessionId && (_this36.fetchHistory = _this36.fetchHistoryFunc.bind(_this36));
|
@@ -8344,32 +8417,32 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8344
8417
|
return _createClass(F, [{
|
8345
8418
|
key: "fetchHistoryFunc",
|
8346
8419
|
value: function () {
|
8347
|
-
var _fetchHistoryFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8420
|
+
var _fetchHistoryFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee83() {
|
8348
8421
|
var _this37 = this;
|
8349
8422
|
var e;
|
8350
|
-
return _regeneratorRuntime().wrap(function
|
8351
|
-
while (1) switch (
|
8423
|
+
return _regeneratorRuntime().wrap(function _callee83$(_context83) {
|
8424
|
+
while (1) switch (_context83.prev = _context83.next) {
|
8352
8425
|
case 0:
|
8353
8426
|
setTimeout(function () {
|
8354
8427
|
return _this37.deepChat.disableSubmitButton();
|
8355
8428
|
}, 2);
|
8356
|
-
|
8357
|
-
|
8429
|
+
_context83.prev = 1;
|
8430
|
+
_context83.next = 4;
|
8358
8431
|
return this.getThreadMessages(this.sessionId, !0);
|
8359
8432
|
case 4:
|
8360
|
-
e =
|
8361
|
-
return
|
8433
|
+
e = _context83.sent;
|
8434
|
+
return _context83.abrupt("return", (this.deepChat.disableSubmitButton(!1), e.reverse()));
|
8362
8435
|
case 8:
|
8363
|
-
|
8364
|
-
|
8365
|
-
return
|
8436
|
+
_context83.prev = 8;
|
8437
|
+
_context83.t0 = _context83["catch"](1);
|
8438
|
+
return _context83.abrupt("return", [{
|
8366
8439
|
error: "failed to fetch thread history"
|
8367
8440
|
}]);
|
8368
8441
|
case 11:
|
8369
8442
|
case "end":
|
8370
|
-
return
|
8443
|
+
return _context83.stop();
|
8371
8444
|
}
|
8372
|
-
},
|
8445
|
+
}, _callee83, this, [[1, 8]]);
|
8373
8446
|
}));
|
8374
8447
|
function fetchHistoryFunc() {
|
8375
8448
|
return _fetchHistoryFunc.apply(this, arguments);
|
@@ -8401,71 +8474,71 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8401
8474
|
if (this.messages = e, this.sessionId) {
|
8402
8475
|
this.url = "".concat(F.THREAD_PREFIX, "/").concat(this.sessionId, "/messages");
|
8403
8476
|
var n = this.processMessage(t, i);
|
8404
|
-
|
8477
|
+
C.request(this, n, e);
|
8405
8478
|
} else {
|
8406
8479
|
this.url = "".concat(F.THREAD_PREFIX, "/runs");
|
8407
8480
|
var _n2 = this.createNewThreadMessages(this.rawBody, t, i);
|
8408
|
-
this.isSSEStream ? this.createStreamRun(_n2) :
|
8481
|
+
this.isSSEStream ? this.createStreamRun(_n2) : C.request(this, _n2, e);
|
8409
8482
|
}
|
8410
8483
|
}
|
8411
8484
|
}, {
|
8412
8485
|
key: "callServiceAPI",
|
8413
8486
|
value: function () {
|
8414
|
-
var _callServiceAPI18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8487
|
+
var _callServiceAPI18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee84(e, t, i) {
|
8415
8488
|
var _r$assistant_id;
|
8416
8489
|
var r, n;
|
8417
|
-
return _regeneratorRuntime().wrap(function
|
8418
|
-
while (1) switch (
|
8490
|
+
return _regeneratorRuntime().wrap(function _callee84$(_context84) {
|
8491
|
+
while (1) switch (_context84.prev = _context84.next) {
|
8419
8492
|
case 0:
|
8420
8493
|
if (!(this.waitingForStreamResponse = !1, !this.connectSettings)) {
|
8421
|
-
|
8494
|
+
_context84.next = 2;
|
8422
8495
|
break;
|
8423
8496
|
}
|
8424
8497
|
throw new Error("Request settings have not been set up");
|
8425
8498
|
case 2:
|
8426
8499
|
if (!((_r$assistant_id = (r = this.rawBody).assistant_id) !== null && _r$assistant_id !== void 0)) {
|
8427
|
-
|
8500
|
+
_context84.next = 6;
|
8428
8501
|
break;
|
8429
8502
|
}
|
8430
8503
|
_r$assistant_id;
|
8431
|
-
|
8504
|
+
_context84.next = 12;
|
8432
8505
|
break;
|
8433
8506
|
case 6:
|
8434
|
-
|
8435
|
-
if (
|
8436
|
-
|
8507
|
+
_context84.t0 = this.config.assistant_id;
|
8508
|
+
if (_context84.t0) {
|
8509
|
+
_context84.next = 11;
|
8437
8510
|
break;
|
8438
8511
|
}
|
8439
|
-
|
8512
|
+
_context84.next = 10;
|
8440
8513
|
return this.createNewAssistant();
|
8441
8514
|
case 10:
|
8442
|
-
|
8515
|
+
_context84.t0 = _context84.sent;
|
8443
8516
|
case 11:
|
8444
|
-
r.assistant_id =
|
8517
|
+
r.assistant_id = _context84.t0;
|
8445
8518
|
case 12:
|
8446
8519
|
this.searchedForThreadId || this.searchPreviousMessagesForThreadId(e.messages);
|
8447
8520
|
if (!i) {
|
8448
|
-
|
8521
|
+
_context84.next = 19;
|
8449
8522
|
break;
|
8450
8523
|
}
|
8451
|
-
|
8452
|
-
return
|
8524
|
+
_context84.next = 16;
|
8525
|
+
return ce.storeFiles(this, e, i);
|
8453
8526
|
case 16:
|
8454
|
-
|
8455
|
-
|
8527
|
+
_context84.t1 = _context84.sent;
|
8528
|
+
_context84.next = 20;
|
8456
8529
|
break;
|
8457
8530
|
case 19:
|
8458
|
-
|
8531
|
+
_context84.t1 = void 0;
|
8459
8532
|
case 20:
|
8460
|
-
n =
|
8533
|
+
n = _context84.t1;
|
8461
8534
|
this.connectSettings.method = "POST", this.callService(e, t, n);
|
8462
8535
|
case 22:
|
8463
8536
|
case "end":
|
8464
|
-
return
|
8537
|
+
return _context84.stop();
|
8465
8538
|
}
|
8466
|
-
},
|
8539
|
+
}, _callee84, this);
|
8467
8540
|
}));
|
8468
|
-
function callServiceAPI(
|
8541
|
+
function callServiceAPI(_x155, _x156, _x157) {
|
8469
8542
|
return _callServiceAPI18.apply(this, arguments);
|
8470
8543
|
}
|
8471
8544
|
return callServiceAPI;
|
@@ -8473,27 +8546,27 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8473
8546
|
}, {
|
8474
8547
|
key: "createNewAssistant",
|
8475
8548
|
value: function () {
|
8476
|
-
var _createNewAssistant = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8549
|
+
var _createNewAssistant = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85() {
|
8477
8550
|
var e;
|
8478
|
-
return _regeneratorRuntime().wrap(function
|
8479
|
-
while (1) switch (
|
8551
|
+
return _regeneratorRuntime().wrap(function _callee85$(_context85) {
|
8552
|
+
while (1) switch (_context85.prev = _context85.next) {
|
8480
8553
|
case 0:
|
8481
|
-
|
8554
|
+
_context85.prev = 0;
|
8482
8555
|
this.url = F.NEW_ASSISTANT_URL;
|
8483
|
-
|
8556
|
+
_context85.next = 4;
|
8484
8557
|
return P.directFetch(this, JSON.parse(JSON.stringify(this.newAssistantDetails)), "POST");
|
8485
8558
|
case 4:
|
8486
|
-
e =
|
8487
|
-
return
|
8559
|
+
e = _context85.sent;
|
8560
|
+
return _context85.abrupt("return", (this.config.assistant_id = e.id, this.config.assistant_id));
|
8488
8561
|
case 8:
|
8489
|
-
|
8490
|
-
|
8491
|
-
console.error(
|
8562
|
+
_context85.prev = 8;
|
8563
|
+
_context85.t0 = _context85["catch"](0);
|
8564
|
+
console.error(_context85.t0), console.error("Failed to create a new assistant");
|
8492
8565
|
case 11:
|
8493
8566
|
case "end":
|
8494
|
-
return
|
8567
|
+
return _context85.stop();
|
8495
8568
|
}
|
8496
|
-
},
|
8569
|
+
}, _callee85, this, [[0, 8]]);
|
8497
8570
|
}));
|
8498
8571
|
function createNewAssistant() {
|
8499
8572
|
return _createNewAssistant.apply(this, arguments);
|
@@ -8512,43 +8585,43 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8512
8585
|
}, {
|
8513
8586
|
key: "extractResultData",
|
8514
8587
|
value: function () {
|
8515
|
-
var _extractResultData21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8588
|
+
var _extractResultData21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee86(e) {
|
8516
8589
|
var n, t, i;
|
8517
|
-
return _regeneratorRuntime().wrap(function
|
8518
|
-
while (1) switch (
|
8590
|
+
return _regeneratorRuntime().wrap(function _callee86$(_context86) {
|
8591
|
+
while (1) switch (_context86.prev = _context86.next) {
|
8519
8592
|
case 0:
|
8520
8593
|
if (!(this.waitingForStreamResponse || this.isSSEStream && this.sessionId)) {
|
8521
|
-
|
8594
|
+
_context86.next = 4;
|
8522
8595
|
break;
|
8523
8596
|
}
|
8524
|
-
|
8597
|
+
_context86.next = 3;
|
8525
8598
|
return this.handleStream(e);
|
8526
8599
|
case 3:
|
8527
|
-
return
|
8600
|
+
return _context86.abrupt("return", _context86.sent);
|
8528
8601
|
case 4:
|
8529
8602
|
if (!e.error) {
|
8530
|
-
|
8603
|
+
_context86.next = 6;
|
8531
8604
|
break;
|
8532
8605
|
}
|
8533
8606
|
throw e.error.message;
|
8534
8607
|
case 6:
|
8535
|
-
|
8608
|
+
_context86.next = 8;
|
8536
8609
|
return this.assignThreadAndRun(e);
|
8537
8610
|
case 8:
|
8538
8611
|
t = "".concat(F.THREAD_PREFIX, "/").concat(this.sessionId, "/runs/").concat(this.run_id), i = {
|
8539
8612
|
method: "GET",
|
8540
8613
|
headers: (n = this.connectSettings) == null ? void 0 : n.headers
|
8541
8614
|
};
|
8542
|
-
return
|
8615
|
+
return _context86.abrupt("return", (C.executePollRequest(this, t, i, this.messages), {
|
8543
8616
|
makingAnotherRequest: !0
|
8544
8617
|
}));
|
8545
8618
|
case 10:
|
8546
8619
|
case "end":
|
8547
|
-
return
|
8620
|
+
return _context86.stop();
|
8548
8621
|
}
|
8549
|
-
},
|
8622
|
+
}, _callee86, this);
|
8550
8623
|
}));
|
8551
|
-
function extractResultData(
|
8624
|
+
function extractResultData(_x158) {
|
8552
8625
|
return _extractResultData21.apply(this, arguments);
|
8553
8626
|
}
|
8554
8627
|
return extractResultData;
|
@@ -8556,32 +8629,32 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8556
8629
|
}, {
|
8557
8630
|
key: "assignThreadAndRun",
|
8558
8631
|
value: function () {
|
8559
|
-
var _assignThreadAndRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8632
|
+
var _assignThreadAndRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee87(e) {
|
8560
8633
|
var t;
|
8561
|
-
return _regeneratorRuntime().wrap(function
|
8562
|
-
while (1) switch (
|
8634
|
+
return _regeneratorRuntime().wrap(function _callee87$(_context87) {
|
8635
|
+
while (1) switch (_context87.prev = _context87.next) {
|
8563
8636
|
case 0:
|
8564
8637
|
if (!this.sessionId) {
|
8565
|
-
|
8638
|
+
_context87.next = 8;
|
8566
8639
|
break;
|
8567
8640
|
}
|
8568
8641
|
this.url = "".concat(F.THREAD_PREFIX, "/").concat(this.sessionId, "/runs");
|
8569
|
-
|
8642
|
+
_context87.next = 4;
|
8570
8643
|
return P.directFetch(this, JSON.parse(JSON.stringify(this.rawBody)), "POST");
|
8571
8644
|
case 4:
|
8572
|
-
t =
|
8645
|
+
t = _context87.sent;
|
8573
8646
|
this.run_id = t.id;
|
8574
|
-
|
8647
|
+
_context87.next = 9;
|
8575
8648
|
break;
|
8576
8649
|
case 8:
|
8577
8650
|
this.sessionId = e.thread_id, this.run_id = e.id, this.messages && (this.messages.messages[this.messages.messages.length - 1]._sessionId = this.sessionId);
|
8578
8651
|
case 9:
|
8579
8652
|
case "end":
|
8580
|
-
return
|
8653
|
+
return _context87.stop();
|
8581
8654
|
}
|
8582
|
-
},
|
8655
|
+
}, _callee87, this);
|
8583
8656
|
}));
|
8584
|
-
function assignThreadAndRun(
|
8657
|
+
function assignThreadAndRun(_x159) {
|
8585
8658
|
return _assignThreadAndRun.apply(this, arguments);
|
8586
8659
|
}
|
8587
8660
|
return assignThreadAndRun;
|
@@ -8589,98 +8662,39 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8589
8662
|
}, {
|
8590
8663
|
key: "getThreadMessages",
|
8591
8664
|
value: function () {
|
8592
|
-
var _getThreadMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8593
|
-
var _this38 = this;
|
8665
|
+
var _getThreadMessages = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee88(e) {
|
8594
8666
|
var t,
|
8595
|
-
o,
|
8596
|
-
a,
|
8597
|
-
i,
|
8598
8667
|
n,
|
8599
|
-
l,
|
8600
|
-
c,
|
8601
8668
|
r,
|
8602
|
-
|
8603
|
-
|
8604
|
-
|
8669
|
+
i,
|
8670
|
+
_args88 = arguments;
|
8671
|
+
return _regeneratorRuntime().wrap(function _callee88$(_context88) {
|
8672
|
+
while (1) switch (_context88.prev = _context88.next) {
|
8605
8673
|
case 0:
|
8606
|
-
t =
|
8674
|
+
t = _args88.length > 1 && _args88[1] !== undefined ? _args88[1] : !1;
|
8607
8675
|
this.url = "".concat(F.THREAD_PREFIX, "/").concat(e, "/messages");
|
8608
|
-
|
8676
|
+
_context88.next = 4;
|
8609
8677
|
return P.directFetch(this, {}, "GET");
|
8610
8678
|
case 4:
|
8611
|
-
i =
|
8612
|
-
|
8613
|
-
if (!
|
8614
|
-
|
8679
|
+
i = _context88.sent;
|
8680
|
+
_context88.t0 = !t && this.deepChat.responseInterceptor;
|
8681
|
+
if (!_context88.t0) {
|
8682
|
+
_context88.next = 10;
|
8615
8683
|
break;
|
8616
8684
|
}
|
8617
|
-
|
8618
|
-
return (
|
8685
|
+
_context88.next = 9;
|
8686
|
+
return (r = (n = this.deepChat).responseInterceptor) == null ? void 0 : r.call(n, i);
|
8619
8687
|
case 9:
|
8620
|
-
i =
|
8688
|
+
i = _context88.sent;
|
8621
8689
|
case 10:
|
8622
|
-
|
8623
|
-
|
8624
|
-
_context86.next = 15;
|
8625
|
-
break;
|
8626
|
-
}
|
8627
|
-
n = i.data;
|
8628
|
-
_context86.next = 27;
|
8629
|
-
break;
|
8630
|
-
case 15:
|
8631
|
-
console.log(i.data);
|
8632
|
-
l = 0;
|
8633
|
-
case 17:
|
8634
|
-
if (!(l < i.data.length)) {
|
8635
|
-
_context86.next = 27;
|
8636
|
-
break;
|
8637
|
-
}
|
8638
|
-
c = i.data[l];
|
8639
|
-
if (!(c.role === "assistant")) {
|
8640
|
-
_context86.next = 23;
|
8641
|
-
break;
|
8642
|
-
}
|
8643
|
-
n.push(c);
|
8644
|
-
_context86.next = 24;
|
8645
|
-
break;
|
8646
|
-
case 23:
|
8647
|
-
return _context86.abrupt("break", 27);
|
8648
|
-
case 24:
|
8649
|
-
l += 1;
|
8650
|
-
_context86.next = 17;
|
8651
|
-
break;
|
8652
|
-
case 27:
|
8653
|
-
r = n.map( /*#__PURE__*/function () {
|
8654
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee85(l) {
|
8655
|
-
var c;
|
8656
|
-
return _regeneratorRuntime().wrap(function _callee85$(_context85) {
|
8657
|
-
while (1) switch (_context85.prev = _context85.next) {
|
8658
|
-
case 0:
|
8659
|
-
c = l.content.find(function (d) {
|
8660
|
-
return !!d.text || !!d.image_file;
|
8661
|
-
});
|
8662
|
-
_context85.next = 3;
|
8663
|
-
return Ie.getFilesAndText(_this38, l, c);
|
8664
|
-
case 3:
|
8665
|
-
return _context85.abrupt("return", _context85.sent);
|
8666
|
-
case 4:
|
8667
|
-
case "end":
|
8668
|
-
return _context85.stop();
|
8669
|
-
}
|
8670
|
-
}, _callee85);
|
8671
|
-
}));
|
8672
|
-
return function (_x156) {
|
8673
|
-
return _ref12.apply(this, arguments);
|
8674
|
-
};
|
8675
|
-
}());
|
8676
|
-
return _context86.abrupt("return", Promise.all(r));
|
8677
|
-
case 29:
|
8690
|
+
return _context88.abrupt("return", ce.processAPIMessages(this, i, t));
|
8691
|
+
case 11:
|
8678
8692
|
case "end":
|
8679
|
-
return
|
8693
|
+
return _context88.stop();
|
8680
8694
|
}
|
8681
|
-
},
|
8695
|
+
}, _callee88, this);
|
8682
8696
|
}));
|
8683
|
-
function getThreadMessages(
|
8697
|
+
function getThreadMessages(_x160) {
|
8684
8698
|
return _getThreadMessages.apply(this, arguments);
|
8685
8699
|
}
|
8686
8700
|
return getThreadMessages;
|
@@ -8688,59 +8702,60 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8688
8702
|
}, {
|
8689
8703
|
key: "extractPollResultData",
|
8690
8704
|
value: function () {
|
8691
|
-
var _extractPollResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8692
|
-
var
|
8705
|
+
var _extractPollResultData5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee89(e) {
|
8706
|
+
var _this38 = this;
|
8693
8707
|
var r, t, i, o, _o$pop, a, l, n;
|
8694
|
-
return _regeneratorRuntime().wrap(function
|
8695
|
-
while (1) switch (
|
8708
|
+
return _regeneratorRuntime().wrap(function _callee89$(_context89) {
|
8709
|
+
while (1) switch (_context89.prev = _context89.next) {
|
8696
8710
|
case 0:
|
8697
8711
|
t = e.status, i = e.required_action;
|
8698
8712
|
if (!(t === "queued" || t === "in_progress")) {
|
8699
|
-
|
8713
|
+
_context89.next = 3;
|
8700
8714
|
break;
|
8701
8715
|
}
|
8702
|
-
return
|
8716
|
+
return _context89.abrupt("return", {
|
8703
8717
|
timeoutMS: F.POLLING_TIMEOUT_MS
|
8704
8718
|
});
|
8705
8719
|
case 3:
|
8706
8720
|
if (!(t === "completed" && this.messages)) {
|
8707
|
-
|
8721
|
+
_context89.next = 11;
|
8708
8722
|
break;
|
8709
8723
|
}
|
8710
|
-
|
8724
|
+
_context89.next = 6;
|
8711
8725
|
return this.getThreadMessages(e.thread_id);
|
8712
8726
|
case 6:
|
8713
|
-
o =
|
8714
|
-
|
8715
|
-
|
8716
|
-
|
8727
|
+
o = _context89.sent;
|
8728
|
+
_o$pop = o.pop();
|
8729
|
+
a = _o$pop.text;
|
8730
|
+
l = _o$pop.files;
|
8731
|
+
return _context89.abrupt("return", (setTimeout(function () {
|
8717
8732
|
o.forEach(function (c) {
|
8718
|
-
return
|
8733
|
+
return _this38.deepChat.addMessage(c);
|
8719
8734
|
});
|
8720
8735
|
}), {
|
8721
8736
|
text: a,
|
8722
8737
|
_sessionId: this.sessionId,
|
8723
8738
|
files: l
|
8724
8739
|
}));
|
8725
|
-
case
|
8740
|
+
case 11:
|
8726
8741
|
n = (r = i == null ? void 0 : i.submit_tool_outputs) == null ? void 0 : r.tool_calls;
|
8727
8742
|
if (!(t === "requires_action" && n)) {
|
8728
|
-
|
8743
|
+
_context89.next = 16;
|
8729
8744
|
break;
|
8730
8745
|
}
|
8731
|
-
|
8746
|
+
_context89.next = 15;
|
8732
8747
|
return this.handleTools(n);
|
8733
|
-
case 14:
|
8734
|
-
return _context87.abrupt("return", _context87.sent);
|
8735
8748
|
case 15:
|
8736
|
-
|
8749
|
+
return _context89.abrupt("return", _context89.sent);
|
8737
8750
|
case 16:
|
8751
|
+
throw Error("Thread run status: ".concat(t));
|
8752
|
+
case 17:
|
8738
8753
|
case "end":
|
8739
|
-
return
|
8754
|
+
return _context89.stop();
|
8740
8755
|
}
|
8741
|
-
},
|
8756
|
+
}, _callee89, this);
|
8742
8757
|
}));
|
8743
|
-
function extractPollResultData(
|
8758
|
+
function extractPollResultData(_x161) {
|
8744
8759
|
return _extractPollResultData5.apply(this, arguments);
|
8745
8760
|
}
|
8746
8761
|
return extractPollResultData;
|
@@ -8748,13 +8763,13 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8748
8763
|
}, {
|
8749
8764
|
key: "handleTools",
|
8750
8765
|
value: function () {
|
8751
|
-
var _handleTools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8766
|
+
var _handleTools = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee90(e) {
|
8752
8767
|
var t, i, n;
|
8753
|
-
return _regeneratorRuntime().wrap(function
|
8754
|
-
while (1) switch (
|
8768
|
+
return _regeneratorRuntime().wrap(function _callee90$(_context90) {
|
8769
|
+
while (1) switch (_context90.prev = _context90.next) {
|
8755
8770
|
case 0:
|
8756
8771
|
if (this._functionHandler) {
|
8757
|
-
|
8772
|
+
_context90.next = 2;
|
8758
8773
|
break;
|
8759
8774
|
}
|
8760
8775
|
throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Assistant) object.");
|
@@ -8765,14 +8780,14 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8765
8780
|
arguments: r["function"].arguments
|
8766
8781
|
};
|
8767
8782
|
});
|
8768
|
-
|
8783
|
+
_context90.next = 5;
|
8769
8784
|
return this._functionHandler(t);
|
8770
8785
|
case 5:
|
8771
|
-
i =
|
8786
|
+
i = _context90.sent;
|
8772
8787
|
if (!(!Array.isArray(i) || i.find(function (r) {
|
8773
8788
|
return typeof r != "string";
|
8774
8789
|
}) || e.length !== i.length)) {
|
8775
|
-
|
8790
|
+
_context90.next = 8;
|
8776
8791
|
break;
|
8777
8792
|
}
|
8778
8793
|
throw Error("Response must contain an array of strings for each individual function/tool_call, see https://deepchat.dev/docs/directConnection/OpenAI/#assistant-functions.");
|
@@ -8785,32 +8800,32 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8785
8800
|
});
|
8786
8801
|
this.url = "".concat(F.THREAD_PREFIX, "/").concat(this.sessionId, "/runs/").concat(this.run_id, "/submit_tool_outputs");
|
8787
8802
|
if (!this.isSSEStream) {
|
8788
|
-
|
8803
|
+
_context90.next = 15;
|
8789
8804
|
break;
|
8790
8805
|
}
|
8791
|
-
|
8806
|
+
_context90.next = 13;
|
8792
8807
|
return this.createStreamRun({
|
8793
8808
|
tool_outputs: n
|
8794
8809
|
});
|
8795
8810
|
case 13:
|
8796
|
-
|
8811
|
+
_context90.next = 17;
|
8797
8812
|
break;
|
8798
8813
|
case 15:
|
8799
|
-
|
8814
|
+
_context90.next = 17;
|
8800
8815
|
return P.directFetch(this, {
|
8801
8816
|
tool_outputs: n
|
8802
8817
|
}, "POST");
|
8803
8818
|
case 17:
|
8804
|
-
return
|
8819
|
+
return _context90.abrupt("return", {
|
8805
8820
|
timeoutMS: F.POLLING_TIMEOUT_MS
|
8806
8821
|
});
|
8807
8822
|
case 18:
|
8808
8823
|
case "end":
|
8809
|
-
return
|
8824
|
+
return _context90.stop();
|
8810
8825
|
}
|
8811
|
-
},
|
8826
|
+
}, _callee90, this);
|
8812
8827
|
}));
|
8813
|
-
function handleTools(
|
8828
|
+
function handleTools(_x162) {
|
8814
8829
|
return _handleTools.apply(this, arguments);
|
8815
8830
|
}
|
8816
8831
|
return handleTools;
|
@@ -8818,90 +8833,77 @@ var F = /*#__PURE__*/function (_U10) {
|
|
8818
8833
|
}, {
|
8819
8834
|
key: "handleStream",
|
8820
8835
|
value: function () {
|
8821
|
-
var _handleStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8836
|
+
var _handleStream = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee91(e) {
|
8822
8837
|
var i, n, t, r;
|
8823
|
-
return _regeneratorRuntime().wrap(function
|
8824
|
-
while (1) switch (
|
8838
|
+
return _regeneratorRuntime().wrap(function _callee91$(_context91) {
|
8839
|
+
while (1) switch (_context91.prev = _context91.next) {
|
8825
8840
|
case 0:
|
8826
8841
|
t = (n = (i = e.required_action) == null ? void 0 : i.submit_tool_outputs) == null ? void 0 : n.tool_calls;
|
8827
8842
|
if (!(e.status === "requires_action" && t)) {
|
8828
|
-
|
8843
|
+
_context91.next = 6;
|
8829
8844
|
break;
|
8830
8845
|
}
|
8831
8846
|
this.run_id = e.id;
|
8832
|
-
|
8847
|
+
_context91.next = 5;
|
8833
8848
|
return this.handleTools(t);
|
8834
8849
|
case 5:
|
8835
|
-
return
|
8850
|
+
return _context91.abrupt("return", _context91.sent);
|
8836
8851
|
case 6:
|
8837
8852
|
if (!this.waitingForStreamResponse) {
|
8838
|
-
|
8853
|
+
_context91.next = 8;
|
8839
8854
|
break;
|
8840
8855
|
}
|
8841
|
-
return
|
8856
|
+
return _context91.abrupt("return", this.parseStreamResult(e));
|
8842
8857
|
case 8:
|
8843
8858
|
if (this.isSSEStream && this.sessionId) {
|
8844
8859
|
this.url = "".concat(F.THREAD_PREFIX, "/").concat(this.sessionId, "/runs");
|
8845
8860
|
r = JSON.parse(JSON.stringify(this.rawBody));
|
8846
8861
|
this.createStreamRun(r);
|
8847
8862
|
}
|
8848
|
-
return
|
8863
|
+
return _context91.abrupt("return", {
|
8849
8864
|
makingAnotherRequest: !0
|
8850
8865
|
});
|
8851
8866
|
case 10:
|
8852
8867
|
case "end":
|
8853
|
-
return
|
8868
|
+
return _context91.stop();
|
8854
8869
|
}
|
8855
|
-
},
|
8870
|
+
}, _callee91, this);
|
8856
8871
|
}));
|
8857
|
-
function handleStream(
|
8872
|
+
function handleStream(_x163) {
|
8858
8873
|
return _handleStream.apply(this, arguments);
|
8859
8874
|
}
|
8860
8875
|
return handleStream;
|
8861
8876
|
}()
|
8862
8877
|
}, {
|
8863
8878
|
key: "parseStreamResult",
|
8864
|
-
value: function () {
|
8865
|
-
var
|
8866
|
-
|
8867
|
-
|
8868
|
-
|
8869
|
-
|
8870
|
-
|
8871
|
-
|
8872
|
-
|
8873
|
-
makingAnotherRequest: !0
|
8874
|
-
})));
|
8875
|
-
case 1:
|
8876
|
-
case "end":
|
8877
|
-
return _context90.stop();
|
8878
|
-
}
|
8879
|
-
}, _callee90, this);
|
8880
|
-
}));
|
8881
|
-
function parseStreamResult(_x160) {
|
8882
|
-
return _parseStreamResult.apply(this, arguments);
|
8883
|
-
}
|
8884
|
-
return parseStreamResult;
|
8885
|
-
}() // https://platform.openai.com/docs/api-reference/assistants-streaming
|
8879
|
+
value: function parseStreamResult(e) {
|
8880
|
+
var t;
|
8881
|
+
return (t = e.delta) != null && t.content ? {
|
8882
|
+
text: e.delta.content[0].text.value
|
8883
|
+
} : (!this.sessionId && e.thread_id && (this.sessionId = e.thread_id), {
|
8884
|
+
makingAnotherRequest: !0
|
8885
|
+
});
|
8886
|
+
}
|
8887
|
+
// https://platform.openai.com/docs/api-reference/assistants-streaming
|
8886
8888
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
8887
8889
|
}, {
|
8888
8890
|
key: "createStreamRun",
|
8889
8891
|
value: function () {
|
8890
|
-
var _createStreamRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8891
|
-
return _regeneratorRuntime().wrap(function
|
8892
|
-
while (1) switch (
|
8892
|
+
var _createStreamRun = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee92(e) {
|
8893
|
+
return _regeneratorRuntime().wrap(function _callee92$(_context92) {
|
8894
|
+
while (1) switch (_context92.prev = _context92.next) {
|
8893
8895
|
case 0:
|
8894
8896
|
e.stream = !0;
|
8895
8897
|
this.waitingForStreamResponse = !0;
|
8896
|
-
|
8897
|
-
return
|
8898
|
+
_context92.next = 4;
|
8899
|
+
return T.request(this, e, this.messages, !0, !0);
|
8898
8900
|
case 4:
|
8899
8901
|
case "end":
|
8900
|
-
return
|
8902
|
+
return _context92.stop();
|
8901
8903
|
}
|
8902
|
-
},
|
8904
|
+
}, _callee92, this);
|
8903
8905
|
}));
|
8904
|
-
function createStreamRun(
|
8906
|
+
function createStreamRun(_x164) {
|
8905
8907
|
return _createStreamRun.apply(this, arguments);
|
8906
8908
|
}
|
8907
8909
|
return createStreamRun;
|
@@ -8912,7 +8914,7 @@ F.THREAD_PREFIX = "https://api.openai.com/v1/threads", F.NEW_ASSISTANT_URL = "ht
|
|
8912
8914
|
var nn = F;
|
8913
8915
|
var ae = /*#__PURE__*/function (_U11) {
|
8914
8916
|
function ae(e) {
|
8915
|
-
var
|
8917
|
+
var _this39;
|
8916
8918
|
_classCallCheck(this, ae);
|
8917
8919
|
var o;
|
8918
8920
|
var t = e.directConnection,
|
@@ -8925,19 +8927,19 @@ var ae = /*#__PURE__*/function (_U11) {
|
|
8925
8927
|
}
|
8926
8928
|
}
|
8927
8929
|
};
|
8928
|
-
|
8930
|
+
_this39 = _callSuper(this, ae, [e, P.buildKeyVerificationDetails(), P.buildHeaders, i, n]), _this39.insertKeyPlaceholderText = "OpenAI API Key", _this39.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this39.introPanelMarkUp = "\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI DALL\xB7E</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p><b>Upload 1</b> PNG image to generate its variation and optionally insert text to specify the change.</p>\n <p><b>Upload 2</b> PNG images where the second is a copy of the first with a transparent area where the edit should\n take place and text to specify the edit.</p>\n <p>Click <a href=\"https://platform.openai.com/docs/guides/images/introduction\">here</a> for more info.</p>", _this39.url = "", _this39.permittedErrorPrefixes = ["Incorrect", "Invalid input image"];
|
8929
8931
|
var r = (o = t == null ? void 0 : t.openAI) == null ? void 0 : o.images;
|
8930
|
-
if (
|
8932
|
+
if (_this39.camera) {
|
8931
8933
|
var a = _typeof(r) == "object" && r.size ? Number.parseInt(r.size) : 1024;
|
8932
|
-
|
8934
|
+
_this39.camera.files = {
|
8933
8935
|
dimensions: {
|
8934
8936
|
width: a,
|
8935
8937
|
height: a
|
8936
8938
|
}
|
8937
8939
|
};
|
8938
8940
|
}
|
8939
|
-
_typeof(r) == "object" && Object.assign(
|
8940
|
-
return
|
8941
|
+
_typeof(r) == "object" && Object.assign(_this39.rawBody, r), _this39.canSendMessage = ae.canFileSendMessage;
|
8942
|
+
return _this39;
|
8941
8943
|
}
|
8942
8944
|
_inherits(ae, _U11);
|
8943
8945
|
return _createClass(ae, [{
|
@@ -8958,46 +8960,46 @@ var ae = /*#__PURE__*/function (_U11) {
|
|
8958
8960
|
var l = this.preprocessBody(this.rawBody, r);
|
8959
8961
|
n = ae.createFormDataBody(l, i[0], i[1]);
|
8960
8962
|
} else this.url = ae.IMAGE_VARIATIONS_URL, n = ae.createFormDataBody(this.rawBody, i[0]);
|
8961
|
-
v.tempRemoveContentHeader(this.connectSettings,
|
8963
|
+
v.tempRemoveContentHeader(this.connectSettings, C.request.bind(this, this, n, e), !1);
|
8962
8964
|
}
|
8963
8965
|
}, {
|
8964
8966
|
key: "callServiceAPI",
|
8965
8967
|
value: function () {
|
8966
|
-
var _callServiceAPI19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
8968
|
+
var _callServiceAPI19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee93(e, t, i) {
|
8967
8969
|
var n, r;
|
8968
|
-
return _regeneratorRuntime().wrap(function
|
8969
|
-
while (1) switch (
|
8970
|
+
return _regeneratorRuntime().wrap(function _callee93$(_context93) {
|
8971
|
+
while (1) switch (_context93.prev = _context93.next) {
|
8970
8972
|
case 0:
|
8971
8973
|
if ((n = this.connectSettings) != null && n.headers) {
|
8972
|
-
|
8974
|
+
_context93.next = 2;
|
8973
8975
|
break;
|
8974
8976
|
}
|
8975
8977
|
throw new Error("Request settings have not been set up");
|
8976
8978
|
case 2:
|
8977
8979
|
if (!(i != null && i[0])) {
|
8978
|
-
|
8980
|
+
_context93.next = 6;
|
8979
8981
|
break;
|
8980
8982
|
}
|
8981
8983
|
this.callApiWithImage(e, t, i);
|
8982
|
-
|
8984
|
+
_context93.next = 11;
|
8983
8985
|
break;
|
8984
8986
|
case 6:
|
8985
8987
|
if (this.connectSettings) {
|
8986
|
-
|
8988
|
+
_context93.next = 8;
|
8987
8989
|
break;
|
8988
8990
|
}
|
8989
8991
|
throw new Error("Request settings have not been set up");
|
8990
8992
|
case 8:
|
8991
8993
|
this.url = ae.IMAGE_GENERATION_URL;
|
8992
8994
|
r = this.preprocessBody(this.rawBody, t[t.length - 1].text);
|
8993
|
-
|
8995
|
+
C.request(this, r, e);
|
8994
8996
|
case 11:
|
8995
8997
|
case "end":
|
8996
|
-
return
|
8998
|
+
return _context93.stop();
|
8997
8999
|
}
|
8998
|
-
},
|
9000
|
+
}, _callee93, this);
|
8999
9001
|
}));
|
9000
|
-
function callServiceAPI(
|
9002
|
+
function callServiceAPI(_x165, _x166, _x167) {
|
9001
9003
|
return _callServiceAPI19.apply(this, arguments);
|
9002
9004
|
}
|
9003
9005
|
return callServiceAPI;
|
@@ -9005,17 +9007,17 @@ var ae = /*#__PURE__*/function (_U11) {
|
|
9005
9007
|
}, {
|
9006
9008
|
key: "extractResultData",
|
9007
9009
|
value: function () {
|
9008
|
-
var _extractResultData22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9009
|
-
return _regeneratorRuntime().wrap(function
|
9010
|
-
while (1) switch (
|
9010
|
+
var _extractResultData22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee94(e) {
|
9011
|
+
return _regeneratorRuntime().wrap(function _callee94$(_context94) {
|
9012
|
+
while (1) switch (_context94.prev = _context94.next) {
|
9011
9013
|
case 0:
|
9012
9014
|
if (!e.error) {
|
9013
|
-
|
9015
|
+
_context94.next = 2;
|
9014
9016
|
break;
|
9015
9017
|
}
|
9016
9018
|
throw e.error.message;
|
9017
9019
|
case 2:
|
9018
|
-
return
|
9020
|
+
return _context94.abrupt("return", {
|
9019
9021
|
files: e.data.map(function (i) {
|
9020
9022
|
return i.url ? {
|
9021
9023
|
src: i.url,
|
@@ -9028,11 +9030,11 @@ var ae = /*#__PURE__*/function (_U11) {
|
|
9028
9030
|
});
|
9029
9031
|
case 3:
|
9030
9032
|
case "end":
|
9031
|
-
return
|
9033
|
+
return _context94.stop();
|
9032
9034
|
}
|
9033
|
-
},
|
9035
|
+
}, _callee94);
|
9034
9036
|
}));
|
9035
|
-
function extractResultData(
|
9037
|
+
function extractResultData(_x168) {
|
9036
9038
|
return _extractResultData22.apply(this, arguments);
|
9037
9039
|
}
|
9038
9040
|
return extractResultData;
|
@@ -9064,22 +9066,22 @@ ae.IMAGE_GENERATION_URL = "https://api.openai.com/v1/images/generations", ae.IMA
|
|
9064
9066
|
var sn = ae;
|
9065
9067
|
var yt = /*#__PURE__*/function (_U12) {
|
9066
9068
|
function yt(e) {
|
9067
|
-
var
|
9068
|
-
var
|
9069
|
+
var _this40$maxMessages, _l$model;
|
9070
|
+
var _this40;
|
9069
9071
|
_classCallCheck(this, yt);
|
9070
9072
|
var r, o, a, l;
|
9071
9073
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
9072
9074
|
i = t.openAI;
|
9073
|
-
|
9075
|
+
_this40 = _callSuper(this, yt, [e, P.buildKeyVerificationDetails(), P.buildHeaders, i]), _this40.insertKeyPlaceholderText = "OpenAI API Key", _this40.keyHelpUrl = "https://platform.openai.com/account/api-keys", _this40.url = "https://api.openai.com/v1/chat/completions", _this40.permittedErrorPrefixes = ["Incorrect"], _this40.asyncCallInProgress = !1, _this40._systemMessage = yt.generateSystemMessage("You are a helpful assistant.");
|
9074
9076
|
var n = (r = t.openAI) == null ? void 0 : r.chat;
|
9075
9077
|
if (_typeof(n) == "object") {
|
9076
|
-
n.system_prompt && (
|
9077
|
-
var
|
9078
|
-
c =
|
9079
|
-
c && (
|
9078
|
+
n.system_prompt && (_this40._systemMessage = yt.generateSystemMessage(n.system_prompt));
|
9079
|
+
var _ref14 = (a = (o = e.directConnection) == null ? void 0 : o.openAI) == null ? void 0 : a.chat,
|
9080
|
+
c = _ref14.function_handler;
|
9081
|
+
c && (_this40._functionHandler = c), _this40.cleanConfig(n), Object.assign(_this40.rawBody, n);
|
9080
9082
|
}
|
9081
|
-
(
|
9082
|
-
return
|
9083
|
+
(_this40$maxMessages = _this40.maxMessages) !== null && _this40$maxMessages !== void 0 ? _this40$maxMessages : _this40.maxMessages = -1, (_l$model = (l = _this40.rawBody).model) !== null && _l$model !== void 0 ? _l$model : l.model = "gpt-3.5-turbo";
|
9084
|
+
return _this40;
|
9083
9085
|
}
|
9084
9086
|
_inherits(yt, _U12);
|
9085
9087
|
return _createClass(yt, [{
|
@@ -9107,26 +9109,26 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9107
9109
|
}, {
|
9108
9110
|
key: "callServiceAPI",
|
9109
9111
|
value: function () {
|
9110
|
-
var _callServiceAPI20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9112
|
+
var _callServiceAPI20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee95(e, t) {
|
9111
9113
|
var i, n;
|
9112
|
-
return _regeneratorRuntime().wrap(function
|
9113
|
-
while (1) switch (
|
9114
|
+
return _regeneratorRuntime().wrap(function _callee95$(_context95) {
|
9115
|
+
while (1) switch (_context95.prev = _context95.next) {
|
9114
9116
|
case 0:
|
9115
9117
|
if (this.connectSettings) {
|
9116
|
-
|
9118
|
+
_context95.next = 2;
|
9117
9119
|
break;
|
9118
9120
|
}
|
9119
9121
|
throw new Error("Request settings have not been set up");
|
9120
9122
|
case 2:
|
9121
9123
|
i = this.preprocessBody(this.rawBody, t), n = this.stream;
|
9122
|
-
n && (_typeof(n) != "object" || !n.simulation) || i.stream ? (i.stream = !0,
|
9124
|
+
n && (_typeof(n) != "object" || !n.simulation) || i.stream ? (i.stream = !0, T.request(this, i, e)) : C.request(this, i, e);
|
9123
9125
|
case 4:
|
9124
9126
|
case "end":
|
9125
|
-
return
|
9127
|
+
return _context95.stop();
|
9126
9128
|
}
|
9127
|
-
},
|
9129
|
+
}, _callee95, this);
|
9128
9130
|
}));
|
9129
|
-
function callServiceAPI(
|
9131
|
+
function callServiceAPI(_x169, _x170) {
|
9130
9132
|
return _callServiceAPI20.apply(this, arguments);
|
9131
9133
|
}
|
9132
9134
|
return callServiceAPI;
|
@@ -9134,29 +9136,29 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9134
9136
|
}, {
|
9135
9137
|
key: "extractResultData",
|
9136
9138
|
value: function () {
|
9137
|
-
var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9139
|
+
var _extractResultData23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee96(e, t, i) {
|
9138
9140
|
var n, r, o, a;
|
9139
|
-
return _regeneratorRuntime().wrap(function
|
9140
|
-
while (1) switch (
|
9141
|
+
return _regeneratorRuntime().wrap(function _callee96$(_context96) {
|
9142
|
+
while (1) switch (_context96.prev = _context96.next) {
|
9141
9143
|
case 0:
|
9142
9144
|
if (!e.error) {
|
9143
|
-
|
9145
|
+
_context96.next = 2;
|
9144
9146
|
break;
|
9145
9147
|
}
|
9146
9148
|
throw e.error.message;
|
9147
9149
|
case 2:
|
9148
|
-
return
|
9150
|
+
return _context96.abrupt("return", (r = (n = e.choices) == null ? void 0 : n[0]) != null && r.delta ? this.extractStreamResult(e.choices[0], t, i) : (a = (o = e.choices) == null ? void 0 : o[0]) != null && a.message ? e.choices[0].message.tool_calls ? this.handleTools(e.choices[0].message, t, i) : {
|
9149
9151
|
text: e.choices[0].message.content
|
9150
9152
|
} : {
|
9151
9153
|
text: ""
|
9152
9154
|
});
|
9153
9155
|
case 3:
|
9154
9156
|
case "end":
|
9155
|
-
return
|
9157
|
+
return _context96.stop();
|
9156
9158
|
}
|
9157
|
-
},
|
9159
|
+
}, _callee96, this);
|
9158
9160
|
}));
|
9159
|
-
function extractResultData(
|
9161
|
+
function extractResultData(_x171, _x172, _x173) {
|
9160
9162
|
return _extractResultData23.apply(this, arguments);
|
9161
9163
|
}
|
9162
9164
|
return extractResultData;
|
@@ -9164,37 +9166,37 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9164
9166
|
}, {
|
9165
9167
|
key: "extractStreamResult",
|
9166
9168
|
value: function () {
|
9167
|
-
var _extractStreamResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9168
|
-
var
|
9169
|
+
var _extractStreamResult = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee97(e, t, i) {
|
9170
|
+
var _this41 = this;
|
9169
9171
|
var n, r, o;
|
9170
|
-
return _regeneratorRuntime().wrap(function
|
9171
|
-
while (1) switch (
|
9172
|
+
return _regeneratorRuntime().wrap(function _callee97$(_context97) {
|
9173
|
+
while (1) switch (_context97.prev = _context97.next) {
|
9172
9174
|
case 0:
|
9173
9175
|
n = e.delta, r = e.finish_reason;
|
9174
9176
|
if (!(r === "tool_calls")) {
|
9175
|
-
|
9177
|
+
_context97.next = 7;
|
9176
9178
|
break;
|
9177
9179
|
}
|
9178
9180
|
this.asyncCallInProgress = !0;
|
9179
9181
|
o = {
|
9180
9182
|
tool_calls: this._streamToolCalls
|
9181
9183
|
};
|
9182
|
-
return
|
9184
|
+
return _context97.abrupt("return", (this._streamToolCalls = void 0, this.handleTools(o, t, i)));
|
9183
9185
|
case 7:
|
9184
9186
|
n != null && n.tool_calls && (this._streamToolCalls ? n.tool_calls.forEach(function (o, a) {
|
9185
|
-
|
9187
|
+
_this41._streamToolCalls && (_this41._streamToolCalls[a]["function"].arguments += o["function"].arguments);
|
9186
9188
|
}) : this._streamToolCalls = n.tool_calls);
|
9187
9189
|
case 8:
|
9188
|
-
return
|
9190
|
+
return _context97.abrupt("return", {
|
9189
9191
|
text: (n == null ? void 0 : n.content) || ""
|
9190
9192
|
});
|
9191
9193
|
case 9:
|
9192
9194
|
case "end":
|
9193
|
-
return
|
9195
|
+
return _context97.stop();
|
9194
9196
|
}
|
9195
|
-
},
|
9197
|
+
}, _callee97, this);
|
9196
9198
|
}));
|
9197
|
-
function extractStreamResult(
|
9199
|
+
function extractStreamResult(_x174, _x175, _x176) {
|
9198
9200
|
return _extractStreamResult.apply(this, arguments);
|
9199
9201
|
}
|
9200
9202
|
return extractStreamResult;
|
@@ -9202,13 +9204,13 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9202
9204
|
}, {
|
9203
9205
|
key: "handleTools",
|
9204
9206
|
value: function () {
|
9205
|
-
var _handleTools2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9207
|
+
var _handleTools2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee98(e, t, i) {
|
9206
9208
|
var a, l, c, d, h, n, r, o, u, _u;
|
9207
|
-
return _regeneratorRuntime().wrap(function
|
9208
|
-
while (1) switch (
|
9209
|
+
return _regeneratorRuntime().wrap(function _callee98$(_context98) {
|
9210
|
+
while (1) switch (_context98.prev = _context98.next) {
|
9209
9211
|
case 0:
|
9210
9212
|
if (!(!e.tool_calls || !t || !i || !this._functionHandler)) {
|
9211
|
-
|
9213
|
+
_context98.next = 2;
|
9212
9214
|
break;
|
9213
9215
|
}
|
9214
9216
|
throw Error("Please define the `function_handler` property inside the [openAI](https://deepchat.dev/docs/directConnection/openAI#Chat) object.");
|
@@ -9220,28 +9222,28 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9220
9222
|
arguments: u["function"].arguments
|
9221
9223
|
};
|
9222
9224
|
});
|
9223
|
-
|
9225
|
+
_context98.next = 6;
|
9224
9226
|
return (a = this._functionHandler) == null ? void 0 : a.call(this, r);
|
9225
9227
|
case 6:
|
9226
|
-
o =
|
9228
|
+
o = _context98.sent;
|
9227
9229
|
if (!o.text) {
|
9228
|
-
|
9230
|
+
_context98.next = 15;
|
9229
9231
|
break;
|
9230
9232
|
}
|
9231
9233
|
u = {
|
9232
9234
|
text: o.text
|
9233
9235
|
};
|
9234
|
-
|
9236
|
+
_context98.next = 11;
|
9235
9237
|
return (c = (l = this.deepChat).responseInterceptor) == null ? void 0 : c.call(l, u);
|
9236
9238
|
case 11:
|
9237
|
-
|
9238
|
-
if (
|
9239
|
-
|
9239
|
+
_context98.t0 = _context98.sent;
|
9240
|
+
if (_context98.t0) {
|
9241
|
+
_context98.next = 14;
|
9240
9242
|
break;
|
9241
9243
|
}
|
9242
|
-
|
9244
|
+
_context98.t0 = u;
|
9243
9245
|
case 14:
|
9244
|
-
return
|
9246
|
+
return _context98.abrupt("return", _context98.t0);
|
9245
9247
|
case 15:
|
9246
9248
|
if (!(n.messages.push({
|
9247
9249
|
tool_calls: e.tool_calls,
|
@@ -9250,7 +9252,7 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9250
9252
|
}), Array.isArray(o) && !o.find(function (u) {
|
9251
9253
|
return typeof u != "string";
|
9252
9254
|
}) || r.length === o.length)) {
|
9253
|
-
|
9255
|
+
_context98.next = 35;
|
9254
9256
|
break;
|
9255
9257
|
}
|
9256
9258
|
o.forEach(function (u, f) {
|
@@ -9263,46 +9265,46 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9263
9265
|
content: u.response
|
9264
9266
|
});
|
9265
9267
|
}), delete n.tools, delete n.tool_choice, delete n.stream;
|
9266
|
-
|
9267
|
-
|
9268
|
+
_context98.prev = 17;
|
9269
|
+
_context98.next = 20;
|
9268
9270
|
return t == null ? void 0 : t(n).then(function (f) {
|
9269
9271
|
return v.processResponseByType(f);
|
9270
9272
|
});
|
9271
9273
|
case 20:
|
9272
|
-
_u =
|
9273
|
-
|
9274
|
+
_u = _context98.sent;
|
9275
|
+
_context98.next = 23;
|
9274
9276
|
return (h = (d = this.deepChat).responseInterceptor) == null ? void 0 : h.call(d, _u);
|
9275
9277
|
case 23:
|
9276
|
-
|
9277
|
-
if (
|
9278
|
-
|
9278
|
+
_context98.t1 = _context98.sent;
|
9279
|
+
if (_context98.t1) {
|
9280
|
+
_context98.next = 26;
|
9279
9281
|
break;
|
9280
9282
|
}
|
9281
|
-
|
9283
|
+
_context98.t1 = _u;
|
9282
9284
|
case 26:
|
9283
|
-
_u =
|
9285
|
+
_u = _context98.t1;
|
9284
9286
|
if (!_u.error) {
|
9285
|
-
|
9287
|
+
_context98.next = 29;
|
9286
9288
|
break;
|
9287
9289
|
}
|
9288
9290
|
throw _u.error.message;
|
9289
9291
|
case 29:
|
9290
|
-
return
|
9292
|
+
return _context98.abrupt("return", {
|
9291
9293
|
text: _u.choices[0].message.content || ""
|
9292
9294
|
});
|
9293
9295
|
case 32:
|
9294
|
-
|
9295
|
-
|
9296
|
-
throw this.asyncCallInProgress = !1,
|
9296
|
+
_context98.prev = 32;
|
9297
|
+
_context98.t2 = _context98["catch"](17);
|
9298
|
+
throw this.asyncCallInProgress = !1, _context98.t2;
|
9297
9299
|
case 35:
|
9298
9300
|
throw Error("Response object must either be {response: string}[] for each individual function or {text: string} for a direct response, see https://deepchat.dev/docs/directConnection/OpenAI#FunctionHandler.");
|
9299
9301
|
case 36:
|
9300
9302
|
case "end":
|
9301
|
-
return
|
9303
|
+
return _context98.stop();
|
9302
9304
|
}
|
9303
|
-
},
|
9305
|
+
}, _callee98, this, [[17, 32]]);
|
9304
9306
|
}));
|
9305
|
-
function handleTools(
|
9307
|
+
function handleTools(_x177, _x178, _x179) {
|
9306
9308
|
return _handleTools2.apply(this, arguments);
|
9307
9309
|
}
|
9308
9310
|
return handleTools;
|
@@ -9338,15 +9340,15 @@ var yt = /*#__PURE__*/function (_U12) {
|
|
9338
9340
|
}(U);
|
9339
9341
|
var ko = /*#__PURE__*/function (_un3) {
|
9340
9342
|
function ko(e) {
|
9341
|
-
var
|
9342
|
-
var
|
9343
|
+
var _this42$maxMessages;
|
9344
|
+
var _this42;
|
9343
9345
|
_classCallCheck(this, ko);
|
9344
9346
|
var r;
|
9345
9347
|
var t = JSON.parse(JSON.stringify(e.directConnection)),
|
9346
9348
|
i = (r = t.cohere) == null ? void 0 : r.chat,
|
9347
9349
|
n = t.cohere;
|
9348
|
-
|
9349
|
-
return
|
9350
|
+
_this42 = _callSuper(this, ko, [e, "https://api.cohere.ai/v1/chat", "Ask me anything!", i, n]), _typeof(i) == "object" && Object.assign(_this42.rawBody, i), (_this42$maxMessages = _this42.maxMessages) !== null && _this42$maxMessages !== void 0 ? _this42$maxMessages : _this42.maxMessages = -1;
|
9351
|
+
return _this42;
|
9350
9352
|
}
|
9351
9353
|
_inherits(ko, _un3);
|
9352
9354
|
return _createClass(ko, [{
|
@@ -9366,26 +9368,26 @@ var ko = /*#__PURE__*/function (_un3) {
|
|
9366
9368
|
}, {
|
9367
9369
|
key: "callServiceAPI",
|
9368
9370
|
value: function () {
|
9369
|
-
var _callServiceAPI21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9371
|
+
var _callServiceAPI21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee99(e, t) {
|
9370
9372
|
var i;
|
9371
|
-
return _regeneratorRuntime().wrap(function
|
9372
|
-
while (1) switch (
|
9373
|
+
return _regeneratorRuntime().wrap(function _callee99$(_context99) {
|
9374
|
+
while (1) switch (_context99.prev = _context99.next) {
|
9373
9375
|
case 0:
|
9374
9376
|
if (this.connectSettings) {
|
9375
|
-
|
9377
|
+
_context99.next = 2;
|
9376
9378
|
break;
|
9377
9379
|
}
|
9378
9380
|
throw new Error("Request settings have not been set up");
|
9379
9381
|
case 2:
|
9380
9382
|
i = this.preprocessBody(this.rawBody, t);
|
9381
|
-
|
9383
|
+
C.request(this, i, e);
|
9382
9384
|
case 4:
|
9383
9385
|
case "end":
|
9384
|
-
return
|
9386
|
+
return _context99.stop();
|
9385
9387
|
}
|
9386
|
-
},
|
9388
|
+
}, _callee99, this);
|
9387
9389
|
}));
|
9388
|
-
function callServiceAPI(
|
9390
|
+
function callServiceAPI(_x180, _x181) {
|
9389
9391
|
return _callServiceAPI21.apply(this, arguments);
|
9390
9392
|
}
|
9391
9393
|
return callServiceAPI;
|
@@ -9393,26 +9395,26 @@ var ko = /*#__PURE__*/function (_un3) {
|
|
9393
9395
|
}, {
|
9394
9396
|
key: "extractResultData",
|
9395
9397
|
value: function () {
|
9396
|
-
var _extractResultData24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9397
|
-
return _regeneratorRuntime().wrap(function
|
9398
|
-
while (1) switch (
|
9398
|
+
var _extractResultData24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee100(e) {
|
9399
|
+
return _regeneratorRuntime().wrap(function _callee100$(_context100) {
|
9400
|
+
while (1) switch (_context100.prev = _context100.next) {
|
9399
9401
|
case 0:
|
9400
9402
|
if (!e.message) {
|
9401
|
-
|
9403
|
+
_context100.next = 2;
|
9402
9404
|
break;
|
9403
9405
|
}
|
9404
9406
|
throw e.message;
|
9405
9407
|
case 2:
|
9406
|
-
return
|
9408
|
+
return _context100.abrupt("return", {
|
9407
9409
|
text: e.text
|
9408
9410
|
});
|
9409
9411
|
case 3:
|
9410
9412
|
case "end":
|
9411
|
-
return
|
9413
|
+
return _context100.stop();
|
9412
9414
|
}
|
9413
|
-
},
|
9415
|
+
}, _callee100);
|
9414
9416
|
}));
|
9415
|
-
function extractResultData(
|
9417
|
+
function extractResultData(_x182) {
|
9416
9418
|
return _extractResultData24.apply(this, arguments);
|
9417
9419
|
}
|
9418
9420
|
return extractResultData;
|
@@ -9452,13 +9454,13 @@ var li = /*#__PURE__*/function () {
|
|
9452
9454
|
}();
|
9453
9455
|
var Ao = /*#__PURE__*/function (_U13) {
|
9454
9456
|
function Ao(e) {
|
9455
|
-
var
|
9456
|
-
var
|
9457
|
+
var _this43$maxMessages, _n$model;
|
9458
|
+
var _this43;
|
9457
9459
|
_classCallCheck(this, Ao);
|
9458
9460
|
var n;
|
9459
9461
|
var i = JSON.parse(JSON.stringify(e.directConnection)).mistral;
|
9460
|
-
|
9461
|
-
return
|
9462
|
+
_this43 = _callSuper(this, Ao, [e, li.buildKeyVerificationDetails(), li.buildHeaders, i]), _this43.insertKeyPlaceholderText = "Mistral API Key", _this43.keyHelpUrl = "https://console.mistral.ai/api-keys/", _this43.url = "https://api.mistral.ai/v1/chat/completions", _this43.permittedErrorPrefixes = ["invalid"], i && (_this43.cleanConfig(i), Object.assign(_this43.rawBody, i)), (_this43$maxMessages = _this43.maxMessages) !== null && _this43$maxMessages !== void 0 ? _this43$maxMessages : _this43.maxMessages = -1, (_n$model = (n = _this43.rawBody).model) !== null && _n$model !== void 0 ? _n$model : n.model = "open-mistral-7b";
|
9463
|
+
return _this43;
|
9462
9464
|
}
|
9463
9465
|
_inherits(Ao, _U13);
|
9464
9466
|
return _createClass(Ao, [{
|
@@ -9484,26 +9486,26 @@ var Ao = /*#__PURE__*/function (_U13) {
|
|
9484
9486
|
}, {
|
9485
9487
|
key: "callServiceAPI",
|
9486
9488
|
value: function () {
|
9487
|
-
var _callServiceAPI22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9489
|
+
var _callServiceAPI22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee101(e, t) {
|
9488
9490
|
var i;
|
9489
|
-
return _regeneratorRuntime().wrap(function
|
9490
|
-
while (1) switch (
|
9491
|
+
return _regeneratorRuntime().wrap(function _callee101$(_context101) {
|
9492
|
+
while (1) switch (_context101.prev = _context101.next) {
|
9491
9493
|
case 0:
|
9492
9494
|
if (this.connectSettings) {
|
9493
|
-
|
9495
|
+
_context101.next = 2;
|
9494
9496
|
break;
|
9495
9497
|
}
|
9496
9498
|
throw new Error("Request settings have not been set up");
|
9497
9499
|
case 2:
|
9498
9500
|
i = this.preprocessBody(this.rawBody, t);
|
9499
|
-
|
9501
|
+
C.request(this, i, e);
|
9500
9502
|
case 4:
|
9501
9503
|
case "end":
|
9502
|
-
return
|
9504
|
+
return _context101.stop();
|
9503
9505
|
}
|
9504
|
-
},
|
9506
|
+
}, _callee101, this);
|
9505
9507
|
}));
|
9506
|
-
function callServiceAPI(
|
9508
|
+
function callServiceAPI(_x183, _x184) {
|
9507
9509
|
return _callServiceAPI22.apply(this, arguments);
|
9508
9510
|
}
|
9509
9511
|
return callServiceAPI;
|
@@ -9511,26 +9513,26 @@ var Ao = /*#__PURE__*/function (_U13) {
|
|
9511
9513
|
}, {
|
9512
9514
|
key: "extractResultData",
|
9513
9515
|
value: function () {
|
9514
|
-
var _extractResultData25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9515
|
-
return _regeneratorRuntime().wrap(function
|
9516
|
-
while (1) switch (
|
9516
|
+
var _extractResultData25 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee102(e) {
|
9517
|
+
return _regeneratorRuntime().wrap(function _callee102$(_context102) {
|
9518
|
+
while (1) switch (_context102.prev = _context102.next) {
|
9517
9519
|
case 0:
|
9518
9520
|
if (!e.message) {
|
9519
|
-
|
9521
|
+
_context102.next = 2;
|
9520
9522
|
break;
|
9521
9523
|
}
|
9522
9524
|
throw e.message;
|
9523
9525
|
case 2:
|
9524
|
-
return
|
9526
|
+
return _context102.abrupt("return", {
|
9525
9527
|
text: e.text
|
9526
9528
|
});
|
9527
9529
|
case 3:
|
9528
9530
|
case "end":
|
9529
|
-
return
|
9531
|
+
return _context102.stop();
|
9530
9532
|
}
|
9531
|
-
},
|
9533
|
+
}, _callee102);
|
9532
9534
|
}));
|
9533
|
-
function extractResultData(
|
9535
|
+
function extractResultData(_x185) {
|
9534
9536
|
return _extractResultData25.apply(this, arguments);
|
9535
9537
|
}
|
9536
9538
|
return extractResultData;
|
@@ -9559,8 +9561,8 @@ var Mo = /*#__PURE__*/function () {
|
|
9559
9561
|
if (t.azure) {
|
9560
9562
|
if (t.azure.speechToText) return new tn(e);
|
9561
9563
|
if (t.azure.textToSpeech) return new en(e);
|
9562
|
-
if (t.azure.summarization) return new
|
9563
|
-
if (t.azure.translation) return new
|
9564
|
+
if (t.azure.summarization) return new Co(e);
|
9565
|
+
if (t.azure.translation) return new To(e);
|
9564
9566
|
}
|
9565
9567
|
if (t.stabilityAI) return t.stabilityAI.imageToImage ? new ri(e) : t.stabilityAI.imageToImageUpscale ? new ni(e) : t.stabilityAI.imageToImageMasking ? new si(e) : new oi(e);
|
9566
9568
|
if (t.mistral) return new Ao(e);
|
@@ -9692,20 +9694,20 @@ var Te = /*#__PURE__*/function () {
|
|
9692
9694
|
}, {
|
9693
9695
|
key: "addNewImageMessage",
|
9694
9696
|
value: function () {
|
9695
|
-
var _addNewImageMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9697
|
+
var _addNewImageMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee103(e, t, i) {
|
9696
9698
|
var n, r;
|
9697
|
-
return _regeneratorRuntime().wrap(function
|
9698
|
-
while (1) switch (
|
9699
|
+
return _regeneratorRuntime().wrap(function _callee103$(_context103) {
|
9700
|
+
while (1) switch (_context103.prev = _context103.next) {
|
9699
9701
|
case 0:
|
9700
9702
|
n = Te.createImage(t, e.elementRef), r = e.createNewMessageElement("", i);
|
9701
9703
|
r.bubbleElement.appendChild(n), r.bubbleElement.classList.add("image-message"), q.addMessage(e, r, "image", i);
|
9702
9704
|
case 2:
|
9703
9705
|
case "end":
|
9704
|
-
return
|
9706
|
+
return _context103.stop();
|
9705
9707
|
}
|
9706
|
-
},
|
9708
|
+
}, _callee103);
|
9707
9709
|
}));
|
9708
|
-
function addNewImageMessage(
|
9710
|
+
function addNewImageMessage(_x186, _x187, _x188) {
|
9709
9711
|
return _addNewImageMessage.apply(this, arguments);
|
9710
9712
|
}
|
9711
9713
|
return addNewImageMessage;
|
@@ -9752,28 +9754,28 @@ var Te = /*#__PURE__*/function () {
|
|
9752
9754
|
}
|
9753
9755
|
}]);
|
9754
9756
|
}();
|
9755
|
-
var
|
9756
|
-
function
|
9757
|
-
var
|
9758
|
-
_classCallCheck(this,
|
9757
|
+
var ke = /*#__PURE__*/function (_ot) {
|
9758
|
+
function ke(e, t, i) {
|
9759
|
+
var _this44;
|
9760
|
+
_classCallCheck(this, ke);
|
9759
9761
|
var a, l;
|
9760
|
-
|
9762
|
+
_this44 = _callSuper(this, ke, [e]);
|
9761
9763
|
var n = t.permittedErrorPrefixes,
|
9762
9764
|
r = t.introPanelMarkUp,
|
9763
9765
|
o = t.demo;
|
9764
|
-
|
9765
|
-
return JSON.parse(JSON.stringify(
|
9766
|
-
}, e.clearMessages =
|
9767
|
-
|
9766
|
+
_this44._errorMessageOverrides = (a = e.errorMessages) == null ? void 0 : a.overrides, _this44._onClearMessages = Qt.onClearMessages.bind(_this44, e), _this44._onError = Qt.onError.bind(_this44, e), _this44._displayLoadingMessage = ke.getDisplayLoadingMessage(e, t), _this44._permittedErrorPrefixes = n, _this44.addSetupMessageIfNeeded(e, t) || _this44.populateIntroPanel(i, r, e.introPanelStyle), _this44.addIntroductoryMessage(e, t), _this44.populateHistory(e), _this44._displayServiceErrorMessages = (l = e.errorMessages) == null ? void 0 : l.displayServiceErrorMessages, e.getMessages = function () {
|
9767
|
+
return JSON.parse(JSON.stringify(_this44.messages));
|
9768
|
+
}, e.clearMessages = _this44.clearMessages.bind(_this44, t), e.refreshMessages = _this44.refreshTextMessages.bind(_this44), e.scrollToBottom = j.scrollToBottom.bind(_this44, _this44.elementRef), e.addMessage = function (c, d) {
|
9769
|
+
_this44.addAnyMessage(_objectSpread(_objectSpread({}, c), {}, {
|
9768
9770
|
sendUpdate: !!d
|
9769
9771
|
}), !d);
|
9770
|
-
}, t.isWebModel() && t.setUpMessages(
|
9771
|
-
|
9772
|
-
}), t.fetchHistory &&
|
9773
|
-
return
|
9772
|
+
}, t.isWebModel() && t.setUpMessages(_this44), o && _this44.prepareDemo(o), e.textToSpeech && rt.processConfig(e.textToSpeech, function (c) {
|
9773
|
+
_this44.textToSpeech = c;
|
9774
|
+
}), t.fetchHistory && _this44.fetchHistory(t.fetchHistory);
|
9775
|
+
return _this44;
|
9774
9776
|
}
|
9775
|
-
_inherits(
|
9776
|
-
return _createClass(
|
9777
|
+
_inherits(ke, _ot);
|
9778
|
+
return _createClass(ke, [{
|
9777
9779
|
key: "prepareDemo",
|
9778
9780
|
value: function prepareDemo(e) {
|
9779
9781
|
_typeof(e) == "object" && (e.response && (this.customDemoResponse = e.response), e.displayErrors && (e.displayErrors["default"] && this.addNewErrorMessage("", ""), e.displayErrors.service && this.addNewErrorMessage("service", ""), e.displayErrors.speechToText && this.addNewErrorMessage("speechToText", "")), e.displayLoadingBubble && this.addLoadingMessage());
|
@@ -9810,38 +9812,38 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9810
9812
|
}, {
|
9811
9813
|
key: "populateHistory",
|
9812
9814
|
value: function populateHistory(e) {
|
9813
|
-
var
|
9814
|
-
var t = e.history ||
|
9815
|
+
var _this45 = this;
|
9816
|
+
var t = e.history || he.processHistory(e);
|
9815
9817
|
t && (t.forEach(function (i) {
|
9816
|
-
|
9818
|
+
he.processHistoryFile(i), _this45.addNewMessage(i, !0);
|
9817
9819
|
}), setTimeout(function () {
|
9818
|
-
return j.scrollToBottom(
|
9820
|
+
return j.scrollToBottom(_this45.elementRef);
|
9819
9821
|
}, 0));
|
9820
9822
|
}
|
9821
9823
|
}, {
|
9822
9824
|
key: "fetchHistory",
|
9823
9825
|
value: function () {
|
9824
|
-
var _fetchHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9825
|
-
var
|
9826
|
-
return _regeneratorRuntime().wrap(function
|
9827
|
-
while (1) switch (
|
9826
|
+
var _fetchHistory = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee104(e) {
|
9827
|
+
var _this46 = this;
|
9828
|
+
return _regeneratorRuntime().wrap(function _callee104$(_context104) {
|
9829
|
+
while (1) switch (_context104.prev = _context104.next) {
|
9828
9830
|
case 0:
|
9829
|
-
|
9831
|
+
_context104.next = 2;
|
9830
9832
|
return e();
|
9831
9833
|
case 2:
|
9832
|
-
|
9833
|
-
return
|
9834
|
+
_context104.sent.forEach(function (i) {
|
9835
|
+
return _this46.addAnyMessage(i, !0);
|
9834
9836
|
});
|
9835
9837
|
setTimeout(function () {
|
9836
|
-
return j.scrollToBottom(
|
9838
|
+
return j.scrollToBottom(_this46.elementRef);
|
9837
9839
|
}, 0);
|
9838
9840
|
case 4:
|
9839
9841
|
case "end":
|
9840
|
-
return
|
9842
|
+
return _context104.stop();
|
9841
9843
|
}
|
9842
|
-
},
|
9844
|
+
}, _callee104);
|
9843
9845
|
}));
|
9844
|
-
function fetchHistory(
|
9846
|
+
function fetchHistory(_x189) {
|
9845
9847
|
return _fetchHistory.apply(this, arguments);
|
9846
9848
|
}
|
9847
9849
|
return fetchHistory;
|
@@ -9857,7 +9859,7 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9857
9859
|
key: "addNewMessage",
|
9858
9860
|
value: function addNewMessage(e) {
|
9859
9861
|
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !1;
|
9860
|
-
var i =
|
9862
|
+
var i = ke.createMessageContent(e),
|
9861
9863
|
n = {
|
9862
9864
|
status: e.overwrite
|
9863
9865
|
};
|
@@ -9885,7 +9887,7 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9885
9887
|
value: function removeMessageOnError() {
|
9886
9888
|
var e = this.messageElementRefs[this.messageElementRefs.length - 1],
|
9887
9889
|
t = e == null ? void 0 : e.bubbleElement;
|
9888
|
-
(t != null && t.classList.contains(
|
9890
|
+
(t != null && t.classList.contains(Se.MESSAGE_CLASS) && t.textContent === "" || ke.isTemporaryElement(e)) && this.removeLastMessage();
|
9889
9891
|
}
|
9890
9892
|
// prettier-ignore
|
9891
9893
|
}, {
|
@@ -9893,7 +9895,7 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9893
9895
|
value: function addNewErrorMessage(e, t) {
|
9894
9896
|
var l, c, d, h, u;
|
9895
9897
|
this.removeMessageOnError();
|
9896
|
-
var i =
|
9898
|
+
var i = ke.createBaseElements(),
|
9897
9899
|
n = i.outerContainer,
|
9898
9900
|
r = i.bubbleElement;
|
9899
9901
|
r.classList.add("error-message-text");
|
@@ -9908,10 +9910,10 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9908
9910
|
if (e) {
|
9909
9911
|
if (this._displayServiceErrorMessages) return e;
|
9910
9912
|
if (typeof e == "string" && this._permittedErrorPrefixes) {
|
9911
|
-
var t =
|
9913
|
+
var t = ke.checkPermittedErrorPrefixes(this._permittedErrorPrefixes, e);
|
9912
9914
|
if (t) return t;
|
9913
9915
|
} else if (Array.isArray(e) && this._permittedErrorPrefixes) for (var _t3 = 0; _t3 < e.length; _t3 += 1) {
|
9914
|
-
var _i17 =
|
9916
|
+
var _i17 = ke.checkPermittedErrorPrefixes(this._permittedErrorPrefixes, e[_t3]);
|
9915
9917
|
if (_i17) return _i17;
|
9916
9918
|
}
|
9917
9919
|
}
|
@@ -9936,16 +9938,16 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9936
9938
|
}, {
|
9937
9939
|
key: "populateIntroPanel",
|
9938
9940
|
value: function populateIntroPanel(e, t, i) {
|
9939
|
-
(e || t) && (this._introPanel = new ci(e, t, i), this._introPanel._elementRef && (
|
9941
|
+
(e || t) && (this._introPanel = new ci(e, t, i), this._introPanel._elementRef && (fe.apply(this, this._introPanel._elementRef), this.elementRef.appendChild(this._introPanel._elementRef)));
|
9940
9942
|
}
|
9941
9943
|
}, {
|
9942
9944
|
key: "addMultipleFiles",
|
9943
9945
|
value: function () {
|
9944
|
-
var _addMultipleFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
9945
|
-
return _regeneratorRuntime().wrap(function
|
9946
|
-
while (1) switch (
|
9946
|
+
var _addMultipleFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee105(e) {
|
9947
|
+
return _regeneratorRuntime().wrap(function _callee105$(_context105) {
|
9948
|
+
while (1) switch (_context105.prev = _context105.next) {
|
9947
9949
|
case 0:
|
9948
|
-
return
|
9950
|
+
return _context105.abrupt("return", Promise.all((e || []).map(function (t) {
|
9949
9951
|
return new Promise(function (i) {
|
9950
9952
|
if (!t.type || t.type === "any") {
|
9951
9953
|
var n = t.file.name || q.DEFAULT_FILE_NAME;
|
@@ -9968,11 +9970,11 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9968
9970
|
})));
|
9969
9971
|
case 1:
|
9970
9972
|
case "end":
|
9971
|
-
return
|
9973
|
+
return _context105.stop();
|
9972
9974
|
}
|
9973
|
-
},
|
9975
|
+
}, _callee105);
|
9974
9976
|
}));
|
9975
|
-
function addMultipleFiles(
|
9977
|
+
function addMultipleFiles(_x190) {
|
9976
9978
|
return _addMultipleFiles.apply(this, arguments);
|
9977
9979
|
}
|
9978
9980
|
return addMultipleFiles;
|
@@ -9984,7 +9986,7 @@ var Ce = /*#__PURE__*/function (_ot) {
|
|
9984
9986
|
var i = [];
|
9985
9987
|
this.messageElementRefs.forEach(function (o) {
|
9986
9988
|
var a = o.bubbleElement.classList;
|
9987
|
-
a.contains("loading-message-text") || a.contains(
|
9989
|
+
a.contains("loading-message-text") || a.contains(Se.MESSAGE_CLASS) ? i.push(o) : o.outerContainer.remove();
|
9988
9990
|
}), Array.from(this.elementRef.children).forEach(function (o) {
|
9989
9991
|
var l;
|
9990
9992
|
var a = (l = o.children[0]) == null ? void 0 : l.children[0];
|
@@ -10114,11 +10116,11 @@ var J = /*#__PURE__*/function () {
|
|
10114
10116
|
}]);
|
10115
10117
|
}();
|
10116
10118
|
var Lo = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M16 0c-8.836 0-16 7.163-16 16s7.163 16 16 16c8.837 0 16-7.163 16-16s-7.163-16-16-16zM16 30.032c-7.72 0-14-6.312-14-14.032s6.28-14 14-14 14 6.28 14 14-6.28 14.032-14 14.032zM23 15h-6v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1v6h-6c-0.552 0-1 0.448-1 1s0.448 1 1 1h6v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6h6c0.552 0 1-0.448 1-1s-0.448-1-1-1z\"></path>\n</svg>";
|
10117
|
-
var
|
10118
|
-
function
|
10119
|
-
_classCallCheck(this,
|
10119
|
+
var de = /*#__PURE__*/function () {
|
10120
|
+
function de() {
|
10121
|
+
_classCallCheck(this, de);
|
10120
10122
|
}
|
10121
|
-
return _createClass(
|
10123
|
+
return _createClass(de, null, [{
|
10122
10124
|
key: "unsetAllCSS",
|
10123
10125
|
value: function unsetAllCSS(e, t) {
|
10124
10126
|
var i, n;
|
@@ -10139,7 +10141,7 @@ var ce = /*#__PURE__*/function () {
|
|
10139
10141
|
}, {
|
10140
10142
|
key: "setElementCssUpToState",
|
10141
10143
|
value: function setElementCssUpToState(e, t, i) {
|
10142
|
-
|
10144
|
+
de.setElementsCSS(e, t, "default"), i !== "default" && (de.setElementsCSS(e, t, "hover"), i !== "hover" && de.setElementsCSS(e, t, "click"));
|
10143
10145
|
}
|
10144
10146
|
}]);
|
10145
10147
|
}();
|
@@ -10153,22 +10155,22 @@ var Bt = /*#__PURE__*/function () {
|
|
10153
10155
|
return _createClass(Bt, [{
|
10154
10156
|
key: "buttonMouseLeave",
|
10155
10157
|
value: function buttonMouseLeave(e) {
|
10156
|
-
this._mouseState.state = "default", e && (
|
10158
|
+
this._mouseState.state = "default", e && (de.unsetAllCSS(this.elementRef, e), de.setElementsCSS(this.elementRef, e, "default"));
|
10157
10159
|
}
|
10158
10160
|
}, {
|
10159
10161
|
key: "buttonMouseEnter",
|
10160
10162
|
value: function buttonMouseEnter(e) {
|
10161
|
-
this._mouseState.state = "hover", e &&
|
10163
|
+
this._mouseState.state = "hover", e && de.setElementsCSS(this.elementRef, e, "hover");
|
10162
10164
|
}
|
10163
10165
|
}, {
|
10164
10166
|
key: "buttonMouseUp",
|
10165
10167
|
value: function buttonMouseUp(e) {
|
10166
|
-
e &&
|
10168
|
+
e && de.unsetActionCSS(this.elementRef, e), this.buttonMouseEnter(e);
|
10167
10169
|
}
|
10168
10170
|
}, {
|
10169
10171
|
key: "buttonMouseDown",
|
10170
10172
|
value: function buttonMouseDown(e) {
|
10171
|
-
this._mouseState.state = "click", e &&
|
10173
|
+
this._mouseState.state = "click", e && de.setElementsCSS(this.elementRef, e, "click");
|
10172
10174
|
}
|
10173
10175
|
// be careful not to use onclick as that is used for button functionality
|
10174
10176
|
}, {
|
@@ -10182,7 +10184,7 @@ var Bt = /*#__PURE__*/function () {
|
|
10182
10184
|
if (this._customStyles) for (var t = 0; t < e.length; t += 1) {
|
10183
10185
|
var _i19 = e[t],
|
10184
10186
|
n = _i19 && this._customStyles[_i19];
|
10185
|
-
n &&
|
10187
|
+
n && de.unsetActionCSS(this.elementRef, n);
|
10186
10188
|
}
|
10187
10189
|
}
|
10188
10190
|
}, {
|
@@ -10191,7 +10193,7 @@ var Bt = /*#__PURE__*/function () {
|
|
10191
10193
|
if (!this._customStyles) return;
|
10192
10194
|
t && this.unsetCustomStateStyles(t);
|
10193
10195
|
var i = this._customStyles[e];
|
10194
|
-
i &&
|
10196
|
+
i && de.setElementCssUpToState(this.elementRef, i, this._mouseState.state), this.setEvents(i);
|
10195
10197
|
}
|
10196
10198
|
}]);
|
10197
10199
|
}();
|
@@ -10269,11 +10271,11 @@ var De = /*#__PURE__*/function () {
|
|
10269
10271
|
}();
|
10270
10272
|
var mn = /*#__PURE__*/function () {
|
10271
10273
|
function mn(e, t) {
|
10272
|
-
var
|
10274
|
+
var _this47 = this;
|
10273
10275
|
_classCallCheck(this, mn);
|
10274
10276
|
var i;
|
10275
10277
|
this._isOpen = !0, this._styles = t, this.elementRef = mn.createElement((i = this._styles) == null ? void 0 : i.container), this.close(), setTimeout(function () {
|
10276
|
-
return
|
10278
|
+
return _this47.addWindowEvents(e);
|
10277
10279
|
});
|
10278
10280
|
}
|
10279
10281
|
return _createClass(mn, [{
|
@@ -10326,15 +10328,15 @@ var mn = /*#__PURE__*/function () {
|
|
10326
10328
|
}();
|
10327
10329
|
var at = /*#__PURE__*/function (_Bt) {
|
10328
10330
|
function at(e, t) {
|
10329
|
-
var
|
10331
|
+
var _this48;
|
10330
10332
|
_classCallCheck(this, at);
|
10331
10333
|
var n;
|
10332
|
-
|
10334
|
+
_this48 = _callSuper(this, at, [at.createButtonElement(), void 0, {
|
10333
10335
|
styles: (n = t == null ? void 0 : t.button) == null ? void 0 : n.styles
|
10334
10336
|
}]);
|
10335
|
-
var i =
|
10336
|
-
|
10337
|
-
return
|
10337
|
+
var i = _this48.createInnerElements(_this48._customStyles);
|
10338
|
+
_this48._menu = new mn(e, t == null ? void 0 : t.menu), _this48.addClickEvent(), _this48.buttonContainer = at.createButtonContainer(), _this48.elementRef.appendChild(i.styles), _this48.buttonContainer.appendChild(_this48.elementRef), _this48.elementRef.classList.add("dropup-icon", "upload-file-button"), _this48.elementRef.children[0].id = "dropup-icon", _this48.buttonContainer.appendChild(_this48._menu.elementRef), _this48.reapplyStateStyle("styles"), _this48.addContainerEvents(e);
|
10339
|
+
return _this48;
|
10338
10340
|
}
|
10339
10341
|
_inherits(at, _Bt);
|
10340
10342
|
return _createClass(at, [{
|
@@ -10362,9 +10364,9 @@ var at = /*#__PURE__*/function (_Bt) {
|
|
10362
10364
|
}, {
|
10363
10365
|
key: "addContainerEvents",
|
10364
10366
|
value: function addContainerEvents(e) {
|
10365
|
-
var
|
10367
|
+
var _this49 = this;
|
10366
10368
|
e.addEventListener("click", function (t) {
|
10367
|
-
t.target.classList.contains("dropup-icon") ||
|
10369
|
+
t.target.classList.contains("dropup-icon") || _this49._menu.close();
|
10368
10370
|
});
|
10369
10371
|
}
|
10370
10372
|
}], [{
|
@@ -10496,10 +10498,10 @@ var Po = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\"
|
|
10496
10498
|
Bo = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg height=\"1.4em\" width=\"1.4em\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n\t viewBox=\"0 0 490.9 490.9\" xml:space=\"preserve\">\n\t<g>\n\t\t<g>\n\t\t\t<path d=\"M245.5,322.9c53,0,96.2-43.2,96.2-96.2V96.2c0-53-43.2-96.2-96.2-96.2s-96.2,43.2-96.2,96.2v130.5\n\t\t\t\tC149.3,279.8,192.5,322.9,245.5,322.9z M173.8,96.2c0-39.5,32.2-71.7,71.7-71.7s71.7,32.2,71.7,71.7v130.5\n\t\t\t\tc0,39.5-32.2,71.7-71.7,71.7s-71.7-32.2-71.7-71.7V96.2z\"/>\n\t\t\t<path d=\"M94.4,214.5c-6.8,0-12.3,5.5-12.3,12.3c0,85.9,66.7,156.6,151.1,162.8v76.7h-63.9c-6.8,0-12.3,5.5-12.3,12.3\n\t\t\t\ts5.5,12.3,12.3,12.3h152.3c6.8,0,12.3-5.5,12.3-12.3s-5.5-12.3-12.3-12.3h-63.9v-76.7c84.4-6.3,151.1-76.9,151.1-162.8\n\t\t\t\tc0-6.8-5.5-12.3-12.3-12.3s-12.3,5.5-12.3,12.3c0,76.6-62.3,138.9-138.9,138.9s-138.9-62.3-138.9-138.9\n\t\t\t\tC106.6,220,101.2,214.5,94.4,214.5z\"/>\n\t\t</g>\n\t</g>\n</svg>\n";
|
10497
10499
|
var Lt = /*#__PURE__*/function (_Bt2) {
|
10498
10500
|
function Lt(e) {
|
10499
|
-
var
|
10501
|
+
var _this50;
|
10500
10502
|
_classCallCheck(this, Lt);
|
10501
|
-
(e == null ? void 0 : e.position) === "dropup-menu" && (e.position = "outside-right"),
|
10502
|
-
return
|
10503
|
+
(e == null ? void 0 : e.position) === "dropup-menu" && (e.position = "outside-right"), _this50 = _callSuper(this, Lt, [Lt.createMicrophoneElement(), e == null ? void 0 : e.position, e]), _this50.isActive = !1, _this50._innerElements = _this50.createInnerElements(_this50._customStyles), _this50.changeToDefault();
|
10504
|
+
return _this50;
|
10503
10505
|
}
|
10504
10506
|
_inherits(Lt, _Bt2);
|
10505
10507
|
return _createClass(Lt, [{
|
@@ -10684,11 +10686,11 @@ gt.IS_SAFARI = function () {
|
|
10684
10686
|
return gt._IS_SAFARI === void 0 && (gt._IS_SAFARI = /^((?!chrome|android).)*safari/i.test(navigator.userAgent)), gt._IS_SAFARI;
|
10685
10687
|
};
|
10686
10688
|
var Ut = {},
|
10687
|
-
|
10688
|
-
Object.defineProperty(
|
10689
|
+
Ci = {};
|
10690
|
+
Object.defineProperty(Ci, "__esModule", {
|
10689
10691
|
value: !0
|
10690
10692
|
});
|
10691
|
-
|
10693
|
+
Ci.EventListeners = void 0;
|
10692
10694
|
var te = /*#__PURE__*/function () {
|
10693
10695
|
function te() {
|
10694
10696
|
_classCallCheck(this, te);
|
@@ -10703,9 +10705,9 @@ var te = /*#__PURE__*/function () {
|
|
10703
10705
|
}, {
|
10704
10706
|
key: "keyDownWindow",
|
10705
10707
|
value: function keyDownWindow(e) {
|
10706
|
-
var
|
10708
|
+
var _this51 = this;
|
10707
10709
|
e.element && te.getElementIfFocusedOnAvailable(e.element, document.activeElement) && (te.KEY_DOWN_TIMEOUT !== null && clearTimeout(te.KEY_DOWN_TIMEOUT), te.KEY_DOWN_TIMEOUT = setTimeout(function () {
|
10708
|
-
te.KEY_DOWN_TIMEOUT = null,
|
10710
|
+
te.KEY_DOWN_TIMEOUT = null, _this51.resetRecording(e);
|
10709
10711
|
}, 500));
|
10710
10712
|
}
|
10711
10713
|
}, {
|
@@ -10731,13 +10733,13 @@ var te = /*#__PURE__*/function () {
|
|
10731
10733
|
}
|
10732
10734
|
}]);
|
10733
10735
|
}();
|
10734
|
-
|
10736
|
+
Ci.EventListeners = te;
|
10735
10737
|
te.KEY_DOWN_TIMEOUT = null;
|
10736
|
-
var
|
10737
|
-
Object.defineProperty(
|
10738
|
+
var Ti = {};
|
10739
|
+
Object.defineProperty(Ti, "__esModule", {
|
10738
10740
|
value: !0
|
10739
10741
|
});
|
10740
|
-
|
10742
|
+
Ti.PreResultUtils = void 0;
|
10741
10743
|
var qo = /*#__PURE__*/function () {
|
10742
10744
|
function qo() {
|
10743
10745
|
_classCallCheck(this, qo);
|
@@ -10752,7 +10754,7 @@ var qo = /*#__PURE__*/function () {
|
|
10752
10754
|
}
|
10753
10755
|
}]);
|
10754
10756
|
}();
|
10755
|
-
|
10757
|
+
Ti.PreResultUtils = qo;
|
10756
10758
|
var Ht = {},
|
10757
10759
|
qt = {};
|
10758
10760
|
Object.defineProperty(qt, "__esModule", {
|
@@ -11163,12 +11165,12 @@ Object.defineProperty(Ut, "__esModule", {
|
|
11163
11165
|
value: !0
|
11164
11166
|
});
|
11165
11167
|
Ut.Speech = void 0;
|
11166
|
-
var Hn =
|
11167
|
-
Ko =
|
11168
|
+
var Hn = Ci,
|
11169
|
+
Ko = Ti,
|
11168
11170
|
qn = Ht,
|
11169
11171
|
$t = qt,
|
11170
11172
|
Ui = ki,
|
11171
|
-
|
11173
|
+
ue = Ze,
|
11172
11174
|
Hi = Ai,
|
11173
11175
|
zn = ft,
|
11174
11176
|
Vn = Ye,
|
@@ -11176,7 +11178,7 @@ var Hn = Ti,
|
|
11176
11178
|
var Jo = /*#__PURE__*/function () {
|
11177
11179
|
function Jo() {
|
11178
11180
|
_classCallCheck(this, Jo);
|
11179
|
-
this.finalTranscript = "", this.interimSpan =
|
11181
|
+
this.finalTranscript = "", this.interimSpan = ue.Elements.createInterimSpan(), this.finalSpan = ue.Elements.createGenericSpan(), this.scrollingSpan = ue.Elements.createGenericSpan(), this.isCursorAtEnd = !1, this.spansPopulated = !1, this.startPadding = "", this.endPadding = "", this.numberOfSpacesBeforeNewText = 0, this.numberOfSpacesAfterNewText = 0, this.isHighlighted = !1, this.primitiveTextRecorded = !1, this.recognizing = !1, this._displayInterimResults = !0, this.insertInCursorLocation = !0, this.autoScroll = !0, this.isRestarting = !1, this.isPaused = !1, this.isWaitingForCommand = !1, this.isTargetInShadow = !1, this.cannotBeStopped = !1, this.resetState();
|
11180
11182
|
}
|
11181
11183
|
return _createClass(Jo, [{
|
11182
11184
|
key: "prepareBeforeStart",
|
@@ -11189,12 +11191,12 @@ var Jo = /*#__PURE__*/function () {
|
|
11189
11191
|
if (!r) return;
|
11190
11192
|
this.prepare(r);
|
11191
11193
|
} else this.prepare(e.element);
|
11192
|
-
(e == null ? void 0 : e.displayInterimResults) !== void 0 && (this._displayInterimResults = e.displayInterimResults), e != null && e.textColor && (this._finalTextColor = (t = e == null ? void 0 : e.textColor) === null || t === void 0 ? void 0 : t["final"],
|
11194
|
+
(e == null ? void 0 : e.displayInterimResults) !== void 0 && (this._displayInterimResults = e.displayInterimResults), e != null && e.textColor && (this._finalTextColor = (t = e == null ? void 0 : e.textColor) === null || t === void 0 ? void 0 : t["final"], ue.Elements.applyCustomColors(this, e.textColor)), (e == null ? void 0 : e.insertInCursorLocation) !== void 0 && (this.insertInCursorLocation = e.insertInCursorLocation), (e == null ? void 0 : e.autoScroll) !== void 0 && (this.autoScroll = e.autoScroll), this._onResult = e == null ? void 0 : e.onResult, this._onPreResult = e == null ? void 0 : e.onPreResult, this._onStart = e == null ? void 0 : e.onStart, this._onStop = e == null ? void 0 : e.onStop, this._onError = e == null ? void 0 : e.onError, this.onCommandModeTrigger = e == null ? void 0 : e.onCommandModeTrigger, this.onPauseTrigger = e == null ? void 0 : e.onPauseTrigger, this._options = e, !((i = this._options) === null || i === void 0) && i.commands && (this.commands = qn.CommandUtils.process(this._options.commands));
|
11193
11195
|
}
|
11194
11196
|
}, {
|
11195
11197
|
key: "prepare",
|
11196
11198
|
value: function prepare(e) {
|
11197
|
-
Hi.Padding.setState(this, e), Ui.Highlight.setState(this, e), this.isTargetInShadow =
|
11199
|
+
Hi.Padding.setState(this, e), Ui.Highlight.setState(this, e), this.isTargetInShadow = ue.Elements.isInsideShadowDOM(e), ue.Elements.isPrimitiveElement(e) ? (this._primitiveElement = e, this._originalText = this._primitiveElement.value) : (this._genericElement = e, this._originalText = this._genericElement.textContent);
|
11198
11200
|
}
|
11199
11201
|
// there was an attempt to optimize this by not having to restart the service and just reset state:
|
11200
11202
|
// unfortunately it did not work because the service would still continue firing the intermediate and final results
|
@@ -11238,7 +11240,7 @@ var Jo = /*#__PURE__*/function () {
|
|
11238
11240
|
}, {
|
11239
11241
|
key: "updateGenericElement",
|
11240
11242
|
value: function updateGenericElement(e, t, i) {
|
11241
|
-
this.isHighlighted && Ui.Highlight.removeForGeneric(this, e), this.spansPopulated ||
|
11243
|
+
this.isHighlighted && Ui.Highlight.removeForGeneric(this, e), this.spansPopulated || ue.Elements.appendSpans(this, e);
|
11242
11244
|
var n = (i ? "" : this.startPadding) + qi.Text.lineBreak(this.finalTranscript);
|
11243
11245
|
this.finalSpan.innerHTML = n;
|
11244
11246
|
var r = $t.AutoScroll.isRequired(this.autoScroll, e);
|
@@ -11249,7 +11251,7 @@ var Jo = /*#__PURE__*/function () {
|
|
11249
11251
|
}, {
|
11250
11252
|
key: "finalise",
|
11251
11253
|
value: function finalise(e) {
|
11252
|
-
this._genericElement && (e ? (this.finalSpan =
|
11254
|
+
this._genericElement && (e ? (this.finalSpan = ue.Elements.createGenericSpan(), this.setInterimColorToFinal(), this.interimSpan = ue.Elements.createInterimSpan(), this.scrollingSpan = ue.Elements.createGenericSpan()) : this._genericElement.textContent = this._genericElement.textContent, this.spansPopulated = !1), Hn.EventListeners.remove(this);
|
11253
11255
|
}
|
11254
11256
|
}, {
|
11255
11257
|
key: "setInterimColorToFinal",
|
@@ -11316,22 +11318,22 @@ var ui = /*#__PURE__*/function (_Xo$Speech) {
|
|
11316
11318
|
}, {
|
11317
11319
|
key: "setEvents",
|
11318
11320
|
value: function setEvents() {
|
11319
|
-
var
|
11321
|
+
var _this52 = this;
|
11320
11322
|
this._service && (this._service.onstart = function () {
|
11321
|
-
|
11323
|
+
_this52.setStateOnStart();
|
11322
11324
|
}, this._service.onerror = function (e) {
|
11323
|
-
Wn.Browser.IS_SAFARI() && e.message === "Another request is started" || e.error === "aborted" &&
|
11325
|
+
Wn.Browser.IS_SAFARI() && e.message === "Another request is started" || e.error === "aborted" && _this52.isRestarting || e.error !== "no-speech" && _this52.error(e.message || e.error);
|
11324
11326
|
}, this._service.onaudioend = function () {
|
11325
|
-
|
11327
|
+
_this52.setStateOnStop();
|
11326
11328
|
}, this._service.onend = function () {
|
11327
|
-
|
11329
|
+
_this52._stopping = !1;
|
11328
11330
|
}, this._service.onresult = function (e) {
|
11329
|
-
if (_typeof(e.results) > "u" &&
|
11330
|
-
var
|
11331
|
-
t =
|
11332
|
-
_i21 =
|
11333
|
-
n =
|
11334
|
-
|
11331
|
+
if (_typeof(e.results) > "u" && _this52._service) _this52._service.onend = null, _this52._service.stop();else if (_this52._extractText && !_this52._stopping) {
|
11332
|
+
var _this52$_extractText = _this52._extractText(e, _this52.finalTranscript, _this52._translations),
|
11333
|
+
t = _this52$_extractText.interimTranscript,
|
11334
|
+
_i21 = _this52$_extractText.finalTranscript,
|
11335
|
+
n = _this52$_extractText.newText;
|
11336
|
+
_this52.updateElements(t, _i21, n);
|
11335
11337
|
}
|
11336
11338
|
});
|
11337
11339
|
}
|
@@ -11423,26 +11425,26 @@ var fi = /*#__PURE__*/function () {
|
|
11423
11425
|
}, {
|
11424
11426
|
key: "getNewSpeechConfig",
|
11425
11427
|
value: function () {
|
11426
|
-
var _getNewSpeechConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11427
|
-
return _regeneratorRuntime().wrap(function
|
11428
|
-
while (1) switch (
|
11428
|
+
var _getNewSpeechConfig = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee106(e, t) {
|
11429
|
+
return _regeneratorRuntime().wrap(function _callee106$(_context106) {
|
11430
|
+
while (1) switch (_context106.prev = _context106.next) {
|
11429
11431
|
case 0:
|
11430
11432
|
if (!t.region) {
|
11431
|
-
|
11433
|
+
_context106.next = 2;
|
11432
11434
|
break;
|
11433
11435
|
}
|
11434
|
-
return
|
11436
|
+
return _context106.abrupt("return", t.subscriptionKey ? e.fromSubscription(t.subscriptionKey.trim(), t.region.trim()) : t.token ? e.fromAuthorizationToken(t.token.trim(), t.region.trim()) : t.retrieveToken ? t.retrieveToken().then(function (i) {
|
11435
11437
|
return t.region ? e.fromAuthorizationToken((i == null ? void 0 : i.trim()) || "", t.region.trim()) : null;
|
11436
11438
|
})["catch"](function (i) {
|
11437
11439
|
return console.error(i), null;
|
11438
11440
|
}) : null);
|
11439
11441
|
case 2:
|
11440
11442
|
case "end":
|
11441
|
-
return
|
11443
|
+
return _context106.stop();
|
11442
11444
|
}
|
11443
|
-
},
|
11445
|
+
}, _callee106);
|
11444
11446
|
}));
|
11445
|
-
function getNewSpeechConfig(
|
11447
|
+
function getNewSpeechConfig(_x191, _x192) {
|
11446
11448
|
return _getNewSpeechConfig.apply(this, arguments);
|
11447
11449
|
}
|
11448
11450
|
return getNewSpeechConfig;
|
@@ -11455,23 +11457,23 @@ var fi = /*#__PURE__*/function () {
|
|
11455
11457
|
}, {
|
11456
11458
|
key: "get",
|
11457
11459
|
value: function () {
|
11458
|
-
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11460
|
+
var _get = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee107(e, t) {
|
11459
11461
|
var i;
|
11460
|
-
return _regeneratorRuntime().wrap(function
|
11461
|
-
while (1) switch (
|
11462
|
+
return _regeneratorRuntime().wrap(function _callee107$(_context107) {
|
11463
|
+
while (1) switch (_context107.prev = _context107.next) {
|
11462
11464
|
case 0:
|
11463
|
-
|
11465
|
+
_context107.next = 2;
|
11464
11466
|
return fi.getNewSpeechConfig(e, t);
|
11465
11467
|
case 2:
|
11466
|
-
i =
|
11467
|
-
return
|
11468
|
+
i = _context107.sent;
|
11469
|
+
return _context107.abrupt("return", (i && fi.process(i, t), i));
|
11468
11470
|
case 4:
|
11469
11471
|
case "end":
|
11470
|
-
return
|
11472
|
+
return _context107.stop();
|
11471
11473
|
}
|
11472
|
-
},
|
11474
|
+
}, _callee107);
|
11473
11475
|
}));
|
11474
|
-
function get(
|
11476
|
+
function get(_x193, _x194) {
|
11475
11477
|
return _get.apply(this, arguments);
|
11476
11478
|
}
|
11477
11479
|
return get;
|
@@ -11543,10 +11545,10 @@ var $n = Ii,
|
|
11543
11545
|
ea = Ut;
|
11544
11546
|
var pi = /*#__PURE__*/function (_ea$Speech) {
|
11545
11547
|
function pi() {
|
11546
|
-
var
|
11548
|
+
var _this53;
|
11547
11549
|
_classCallCheck(this, pi);
|
11548
|
-
|
11549
|
-
return
|
11550
|
+
_this53 = _callSuper(this, pi, arguments), _this53._newTextPadding = "";
|
11551
|
+
return _this53;
|
11550
11552
|
}
|
11551
11553
|
_inherits(pi, _ea$Speech);
|
11552
11554
|
return _createClass(pi, [{
|
@@ -11557,28 +11559,28 @@ var pi = /*#__PURE__*/function (_ea$Speech) {
|
|
11557
11559
|
}, {
|
11558
11560
|
key: "startAsync",
|
11559
11561
|
value: function () {
|
11560
|
-
var _startAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11562
|
+
var _startAsync = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee108(e) {
|
11561
11563
|
var t;
|
11562
|
-
return _regeneratorRuntime().wrap(function
|
11563
|
-
while (1) switch (
|
11564
|
+
return _regeneratorRuntime().wrap(function _callee108$(_context108) {
|
11565
|
+
while (1) switch (_context108.prev = _context108.next) {
|
11564
11566
|
case 0:
|
11565
|
-
|
11566
|
-
if (!
|
11567
|
-
|
11567
|
+
_context108.t0 = this.validate(e);
|
11568
|
+
if (!_context108.t0) {
|
11569
|
+
_context108.next = 6;
|
11568
11570
|
break;
|
11569
11571
|
}
|
11570
|
-
|
11572
|
+
_context108.next = 4;
|
11571
11573
|
return this.instantiateService(e);
|
11572
11574
|
case 4:
|
11573
11575
|
this._translations = e == null ? void 0 : e.translations;
|
11574
11576
|
(t = this._service) === null || t === void 0 || t.startContinuousRecognitionAsync(function () {}, this.error);
|
11575
11577
|
case 6:
|
11576
11578
|
case "end":
|
11577
|
-
return
|
11579
|
+
return _context108.stop();
|
11578
11580
|
}
|
11579
|
-
},
|
11581
|
+
}, _callee108, this);
|
11580
11582
|
}));
|
11581
|
-
function startAsync(
|
11583
|
+
function startAsync(_x195) {
|
11582
11584
|
return _startAsync.apply(this, arguments);
|
11583
11585
|
}
|
11584
11586
|
return startAsync;
|
@@ -11591,28 +11593,28 @@ var pi = /*#__PURE__*/function (_ea$Speech) {
|
|
11591
11593
|
}, {
|
11592
11594
|
key: "instantiateService",
|
11593
11595
|
value: function () {
|
11594
|
-
var _instantiateService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
11596
|
+
var _instantiateService = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee109(e) {
|
11595
11597
|
var t, i, n, r;
|
11596
|
-
return _regeneratorRuntime().wrap(function
|
11597
|
-
while (1) switch (
|
11598
|
+
return _regeneratorRuntime().wrap(function _callee109$(_context109) {
|
11599
|
+
while (1) switch (_context109.prev = _context109.next) {
|
11598
11600
|
case 0:
|
11599
11601
|
t = pi.getAPI();
|
11600
11602
|
i = t.AudioConfig.fromDefaultMicrophoneInput();
|
11601
|
-
|
11603
|
+
_context109.next = 4;
|
11602
11604
|
return Kn.AzureSpeechConfig.get(t.SpeechConfig, e);
|
11603
11605
|
case 4:
|
11604
|
-
n =
|
11606
|
+
n = _context109.sent;
|
11605
11607
|
if (n) {
|
11606
11608
|
r = new t.SpeechRecognizer(n, i);
|
11607
11609
|
this.setEvents(r), this._service = r, e.retrieveToken && this.retrieveTokenInterval(e.retrieveToken);
|
11608
11610
|
} else this.error("Unable to contact Azure server");
|
11609
11611
|
case 6:
|
11610
11612
|
case "end":
|
11611
|
-
return
|
11613
|
+
return _context109.stop();
|
11612
11614
|
}
|
11613
|
-
},
|
11615
|
+
}, _callee109, this);
|
11614
11616
|
}));
|
11615
|
-
function instantiateService(
|
11617
|
+
function instantiateService(_x196) {
|
11616
11618
|
return _instantiateService.apply(this, arguments);
|
11617
11619
|
}
|
11618
11620
|
return instantiateService;
|
@@ -11675,12 +11677,12 @@ var pi = /*#__PURE__*/function (_ea$Speech) {
|
|
11675
11677
|
}, {
|
11676
11678
|
key: "retrieveTokenInterval",
|
11677
11679
|
value: function retrieveTokenInterval(e) {
|
11678
|
-
var
|
11680
|
+
var _this54 = this;
|
11679
11681
|
this._retrieveTokenInterval = setInterval(function () {
|
11680
11682
|
e == null || e().then(function (t) {
|
11681
|
-
|
11683
|
+
_this54._service && (_this54._service.authorizationToken = (t == null ? void 0 : t.trim()) || "");
|
11682
11684
|
})["catch"](function (t) {
|
11683
|
-
|
11685
|
+
_this54.error(t);
|
11684
11686
|
});
|
11685
11687
|
}, 1e4);
|
11686
11688
|
}
|
@@ -11764,10 +11766,10 @@ var na = /*#__PURE__*/function () {
|
|
11764
11766
|
return _createClass(na, [{
|
11765
11767
|
key: "setSilenceTimeout",
|
11766
11768
|
value: function setSilenceTimeout(e, t) {
|
11767
|
-
var
|
11769
|
+
var _this55 = this;
|
11768
11770
|
this._silenceTimeout = setTimeout(function () {
|
11769
11771
|
var i;
|
11770
|
-
(i = e.submit) == null || i.call(e), Kt.stop(),
|
11772
|
+
(i = e.submit) == null || i.call(e), Kt.stop(), _this55.stop || setTimeout(t, Ot.MICROPHONE_RESET_TIMEOUT_MS);
|
11771
11773
|
}, this.silenceMS);
|
11772
11774
|
}
|
11773
11775
|
}, {
|
@@ -11787,27 +11789,27 @@ var na = /*#__PURE__*/function () {
|
|
11787
11789
|
}
|
11788
11790
|
}]);
|
11789
11791
|
}();
|
11790
|
-
var
|
11791
|
-
function
|
11792
|
-
var
|
11793
|
-
_classCallCheck(this,
|
11792
|
+
var Ct = /*#__PURE__*/function (_Lt) {
|
11793
|
+
function Ct(e, t, i) {
|
11794
|
+
var _this56;
|
11795
|
+
_classCallCheck(this, Ct);
|
11794
11796
|
var o;
|
11795
|
-
|
11796
|
-
var
|
11797
|
-
n =
|
11798
|
-
r =
|
11799
|
-
if (
|
11797
|
+
_this56 = _callSuper(this, Ct, [_typeof(e.speechToText) == "object" ? (o = e.speechToText) == null ? void 0 : o.button : {}]);
|
11798
|
+
var _this56$processConfig = _this56.processConfiguration(t, e.speechToText),
|
11799
|
+
n = _this56$processConfig.serviceName,
|
11800
|
+
r = _this56$processConfig.processedConfig;
|
11801
|
+
if (_this56._addErrorMessage = i, n === "webspeech" && !Kt.isWebSpeechSupported()) _this56.changeToUnsupported();else {
|
11800
11802
|
var a = !e.textInput || !e.textInput.disabled;
|
11801
|
-
|
11803
|
+
_this56.elementRef.onclick = _this56.buttonClick.bind(_this56, t, a, n, r);
|
11802
11804
|
}
|
11803
11805
|
setTimeout(function () {
|
11804
|
-
|
11806
|
+
_this56._validationHandler = e._validationHandler;
|
11805
11807
|
});
|
11806
|
-
return
|
11808
|
+
return _this56;
|
11807
11809
|
}
|
11808
11810
|
// prettier-ignore
|
11809
|
-
_inherits(
|
11810
|
-
return _createClass(
|
11811
|
+
_inherits(Ct, _Lt);
|
11812
|
+
return _createClass(Ct, [{
|
11811
11813
|
key: "processConfiguration",
|
11812
11814
|
value: function processConfiguration(e, t) {
|
11813
11815
|
var _i$displayInterimResu, _i$textColor, _i$translations, _i$commands;
|
@@ -11831,33 +11833,33 @@ var Tt = /*#__PURE__*/function (_Lt) {
|
|
11831
11833
|
removeNewText: !0
|
11832
11834
|
}) : null;
|
11833
11835
|
}), i.submitAfterSilence && (this._silenceSubmit = new na(i.submitAfterSilence, i.stopAfterSubmit)), {
|
11834
|
-
serviceName:
|
11836
|
+
serviceName: Ct.getServiceName(i),
|
11835
11837
|
processedConfig: o
|
11836
11838
|
};
|
11837
11839
|
}
|
11838
11840
|
}, {
|
11839
11841
|
key: "buttonClick",
|
11840
11842
|
value: function buttonClick(e, t, i, n) {
|
11841
|
-
var
|
11843
|
+
var _this57 = this;
|
11842
11844
|
e.removeTextIfPlaceholder(), Kt.toggle(i, _objectSpread({
|
11843
11845
|
insertInCursorLocation: !1,
|
11844
11846
|
element: t ? e.inputElementRef : void 0,
|
11845
11847
|
onError: function onError() {
|
11846
11848
|
var r;
|
11847
|
-
|
11849
|
+
_this57.onError(), (r = _this57._silenceSubmit) == null || r.clearSilenceTimeout();
|
11848
11850
|
},
|
11849
11851
|
onStart: this.changeToActive.bind(this),
|
11850
11852
|
onStop: function onStop() {
|
11851
11853
|
var r, o;
|
11852
|
-
(r =
|
11854
|
+
(r = _this57._validationHandler) == null || r.call(_this57), (o = _this57._silenceSubmit) == null || o.clearSilenceTimeout(), _this57.changeToDefault();
|
11853
11855
|
},
|
11854
11856
|
onPauseTrigger: function onPauseTrigger(r) {
|
11855
11857
|
var o;
|
11856
|
-
(o =
|
11858
|
+
(o = _this57._silenceSubmit) == null || o.onPause(r, e, _this57.elementRef.onclick);
|
11857
11859
|
},
|
11858
11860
|
onResult: function onResult(r, o) {
|
11859
11861
|
var a, l;
|
11860
|
-
o && ((a =
|
11862
|
+
o && ((a = _this57._validationHandler) == null || a.call(_this57)), (l = _this57._silenceSubmit) == null || l.resetSilenceTimeout(e, _this57.elementRef.onclick);
|
11861
11863
|
},
|
11862
11864
|
onCommandModeTrigger: this.onCommandModeTrigger.bind(this)
|
11863
11865
|
}, n));
|
@@ -11883,38 +11885,38 @@ var Tt = /*#__PURE__*/function (_Lt) {
|
|
11883
11885
|
var t = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : !0;
|
11884
11886
|
e.click(), t || setTimeout(function () {
|
11885
11887
|
return e.click();
|
11886
|
-
},
|
11888
|
+
}, Ct.MICROPHONE_RESET_TIMEOUT_MS);
|
11887
11889
|
}
|
11888
11890
|
}]);
|
11889
11891
|
}(Lt);
|
11890
|
-
|
11891
|
-
var Ot =
|
11892
|
-
var
|
11892
|
+
Ct.MICROPHONE_RESET_TIMEOUT_MS = 300;
|
11893
|
+
var Ot = Ct;
|
11894
|
+
var xe = /*#__PURE__*/function () {
|
11893
11895
|
// prettier-ignore
|
11894
|
-
function
|
11895
|
-
var
|
11896
|
-
_classCallCheck(this,
|
11896
|
+
function xe(e, t, i, n) {
|
11897
|
+
var _this58 = this;
|
11898
|
+
_classCallCheck(this, xe);
|
11897
11899
|
this._attachments = [], this._fileCountLimit = 99, this._acceptedFormat = "", t.maxNumberOfFiles && (this._fileCountLimit = t.maxNumberOfFiles), this._toggleContainerDisplay = i, this._fileAttachmentsContainerRef = n, t.acceptedFormats && (this._acceptedFormat = t.acceptedFormats), setTimeout(function () {
|
11898
|
-
|
11900
|
+
_this58._validationHandler = e._validationHandler;
|
11899
11901
|
});
|
11900
11902
|
}
|
11901
|
-
return _createClass(
|
11903
|
+
return _createClass(xe, [{
|
11902
11904
|
key: "attemptAddFile",
|
11903
11905
|
value: function attemptAddFile(e, t) {
|
11904
|
-
return
|
11906
|
+
return xe.isFileTypeValid(e, this._acceptedFormat) ? (this.addAttachmentBasedOnType(e, t, !0), !0) : !1;
|
11905
11907
|
}
|
11906
11908
|
}, {
|
11907
11909
|
key: "addAttachmentBasedOnType",
|
11908
11910
|
value: function addAttachmentBasedOnType(e, t, i) {
|
11909
|
-
var n =
|
11911
|
+
var n = xe.getTypeFromBlob(e);
|
11910
11912
|
if (n === "image") {
|
11911
|
-
var r =
|
11913
|
+
var r = xe.createImageAttachment(t);
|
11912
11914
|
this.addFileAttachment(e, "image", r, i);
|
11913
11915
|
} else if (n === "audio") {
|
11914
11916
|
var _r2 = Nt.createAudioAttachment(t);
|
11915
11917
|
this.addFileAttachment(e, "audio", _r2, i);
|
11916
11918
|
} else {
|
11917
|
-
var _r3 =
|
11919
|
+
var _r3 = xe.createAnyFileAttachment(e.name);
|
11918
11920
|
this.addFileAttachment(e, "any", _r3, i);
|
11919
11921
|
}
|
11920
11922
|
}
|
@@ -11922,7 +11924,7 @@ var Ee = /*#__PURE__*/function () {
|
|
11922
11924
|
key: "addFileAttachment",
|
11923
11925
|
value: function addFileAttachment(e, t, i, n) {
|
11924
11926
|
var a;
|
11925
|
-
var r =
|
11927
|
+
var r = xe.createContainer(i);
|
11926
11928
|
if (this._attachments.length >= this._fileCountLimit) {
|
11927
11929
|
var l = this._attachments[this._attachments.length - 1].removeButton;
|
11928
11930
|
l == null || l.click();
|
@@ -12024,22 +12026,22 @@ var Ee = /*#__PURE__*/function () {
|
|
12024
12026
|
}();
|
12025
12027
|
var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <title>play</title>\n <path d=\"M5.92 24.096q0 1.088 0.928 1.728 0.512 0.288 1.088 0.288 0.448 0 0.896-0.224l16.16-8.064q0.48-0.256 0.8-0.736t0.288-1.088-0.288-1.056-0.8-0.736l-16.16-8.064q-0.448-0.224-0.896-0.224-0.544 0-1.088 0.288-0.928 0.608-0.928 1.728v16.16z\"></path>\n</svg>",
|
12026
12028
|
Zn = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n<title>stop</title>\n<path d=\"M5.92 24.096q0 0.832 0.576 1.408t1.44 0.608h16.128q0.832 0 1.44-0.608t0.576-1.408v-16.16q0-0.832-0.576-1.44t-1.44-0.576h-16.128q-0.832 0-1.44 0.576t-0.576 1.44v16.16z\"></path>\n</svg>",
|
12027
|
-
|
12029
|
+
ve = /*#__PURE__*/function (_xe) {
|
12028
12030
|
// prettier-ignore
|
12029
|
-
function
|
12030
|
-
_classCallCheck(this,
|
12031
|
-
return _callSuper(this,
|
12031
|
+
function ve(e, t, i, n) {
|
12032
|
+
_classCallCheck(this, ve);
|
12033
|
+
return _callSuper(this, ve, [e, t, i, n]);
|
12032
12034
|
}
|
12033
|
-
_inherits(
|
12034
|
-
return _createClass(
|
12035
|
+
_inherits(ve, _xe);
|
12036
|
+
return _createClass(ve, [{
|
12035
12037
|
key: "createTimer",
|
12036
12038
|
value: function createTimer(e, t) {
|
12037
|
-
var
|
12039
|
+
var _this59 = this;
|
12038
12040
|
var i = 0;
|
12039
|
-
var n = t !== void 0 && t <
|
12041
|
+
var n = t !== void 0 && t < ve.TIMER_LIMIT_S ? t : ve.TIMER_LIMIT_S;
|
12040
12042
|
return setInterval(function () {
|
12041
12043
|
var a;
|
12042
|
-
i += 1, i === n && ((a =
|
12044
|
+
i += 1, i === n && ((a = _this59.stopPlaceholderCallback) == null || a.call(_this59), _this59.clearTimer()), i === 600 && e.classList.add("audio-placeholder-text-4-digits");
|
12043
12045
|
var r = Math.floor(i / 60),
|
12044
12046
|
o = (i % 60).toString().padStart(2, "0");
|
12045
12047
|
e.textContent = "".concat(r, ":").concat(o);
|
@@ -12048,7 +12050,7 @@ var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12048
12050
|
}, {
|
12049
12051
|
key: "createPlaceholderAudioAttachment",
|
12050
12052
|
value: function createPlaceholderAudioAttachment(e) {
|
12051
|
-
var t =
|
12053
|
+
var t = ve.createAudioContainer(),
|
12052
12054
|
i = document.createElement("div");
|
12053
12055
|
i.classList.add("audio-placeholder-text-3-digits");
|
12054
12056
|
var n = document.createElement("div");
|
@@ -12059,7 +12061,7 @@ var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12059
12061
|
}, {
|
12060
12062
|
key: "addPlaceholderAudioAttachmentEvents",
|
12061
12063
|
value: function addPlaceholderAudioAttachmentEvents(e, t, i) {
|
12062
|
-
var
|
12064
|
+
var _this60 = this;
|
12063
12065
|
var n = function n() {
|
12064
12066
|
return e.replaceChildren(t);
|
12065
12067
|
};
|
@@ -12070,7 +12072,7 @@ var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12070
12072
|
e.addEventListener("mouseleave", r);
|
12071
12073
|
var o = function o() {
|
12072
12074
|
var a;
|
12073
|
-
return (a =
|
12075
|
+
return (a = _this60.stopPlaceholderCallback) == null ? void 0 : a.call(_this60);
|
12074
12076
|
};
|
12075
12077
|
e.addEventListener("click", o);
|
12076
12078
|
}
|
@@ -12085,7 +12087,7 @@ var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12085
12087
|
key: "completePlaceholderAttachment",
|
12086
12088
|
value: function completePlaceholderAttachment(e, t) {
|
12087
12089
|
var i = this._activePlaceholderAttachment;
|
12088
|
-
i && (i.file = e,
|
12090
|
+
i && (i.file = e, ve.addAudioElements(i.attachmentContainerElement.children[0], t), i.removeButton = this.createRemoveAttachmentButton(i), i.attachmentContainerElement.appendChild(i.removeButton), this._activePlaceholderAttachment = void 0, this.clearTimer());
|
12089
12091
|
}
|
12090
12092
|
}, {
|
12091
12093
|
key: "removePlaceholderAttachment",
|
@@ -12125,8 +12127,8 @@ var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12125
12127
|
}, {
|
12126
12128
|
key: "createAudioAttachment",
|
12127
12129
|
value: function createAudioAttachment(e) {
|
12128
|
-
var t =
|
12129
|
-
return
|
12130
|
+
var t = ve.createAudioContainer();
|
12131
|
+
return ve.addAudioElements(t, e), t;
|
12130
12132
|
}
|
12131
12133
|
}, {
|
12132
12134
|
key: "stopAttachmentPlayback",
|
@@ -12135,9 +12137,9 @@ var sa = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
12135
12137
|
(n = (i = (t = e.children[0]) == null ? void 0 : t.children) == null ? void 0 : i[0]) != null && n.classList.contains("stop-icon") && e.children[0].click();
|
12136
12138
|
}
|
12137
12139
|
}]);
|
12138
|
-
}(
|
12139
|
-
|
12140
|
-
var Nt =
|
12140
|
+
}(xe);
|
12141
|
+
ve.TIMER_LIMIT_S = 5999;
|
12142
|
+
var Nt = ve;
|
12141
12143
|
var ra = /*#__PURE__*/function () {
|
12142
12144
|
function ra() {
|
12143
12145
|
_classCallCheck(this, ra);
|
@@ -12147,7 +12149,7 @@ var ra = /*#__PURE__*/function () {
|
|
12147
12149
|
value:
|
12148
12150
|
// prettier-ignore
|
12149
12151
|
function create(e, t, i, n, r) {
|
12150
|
-
return r === "audio" ? new Nt(e, t, i, n) : new
|
12152
|
+
return r === "audio" ? new Nt(e, t, i, n) : new xe(e, t, i, n);
|
12151
12153
|
}
|
12152
12154
|
}]);
|
12153
12155
|
}();
|
@@ -12187,33 +12189,33 @@ var zt = /*#__PURE__*/function () {
|
|
12187
12189
|
}, {
|
12188
12190
|
key: "completePlaceholders",
|
12189
12191
|
value: function () {
|
12190
|
-
var _completePlaceholders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12191
|
-
return _regeneratorRuntime().wrap(function
|
12192
|
-
while (1) switch (
|
12192
|
+
var _completePlaceholders = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee111() {
|
12193
|
+
return _regeneratorRuntime().wrap(function _callee111$(_context111) {
|
12194
|
+
while (1) switch (_context111.prev = _context111.next) {
|
12193
12195
|
case 0:
|
12194
|
-
|
12196
|
+
_context111.next = 2;
|
12195
12197
|
return Promise.all(this._fileAttachmentsTypes.map( /*#__PURE__*/function () {
|
12196
|
-
var
|
12198
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee110(e) {
|
12197
12199
|
var t;
|
12198
|
-
return _regeneratorRuntime().wrap(function
|
12199
|
-
while (1) switch (
|
12200
|
+
return _regeneratorRuntime().wrap(function _callee110$(_context110) {
|
12201
|
+
while (1) switch (_context110.prev = _context110.next) {
|
12200
12202
|
case 0:
|
12201
|
-
return
|
12203
|
+
return _context110.abrupt("return", (t = e.stopPlaceholderCallback) == null ? void 0 : t.call(e));
|
12202
12204
|
case 1:
|
12203
12205
|
case "end":
|
12204
|
-
return
|
12206
|
+
return _context110.stop();
|
12205
12207
|
}
|
12206
|
-
},
|
12208
|
+
}, _callee110);
|
12207
12209
|
}));
|
12208
|
-
return function (
|
12209
|
-
return
|
12210
|
+
return function (_x197) {
|
12211
|
+
return _ref15.apply(this, arguments);
|
12210
12212
|
};
|
12211
12213
|
}()));
|
12212
12214
|
case 2:
|
12213
12215
|
case "end":
|
12214
|
-
return
|
12216
|
+
return _context111.stop();
|
12215
12217
|
}
|
12216
|
-
},
|
12218
|
+
}, _callee111, this);
|
12217
12219
|
}));
|
12218
12220
|
function completePlaceholders() {
|
12219
12221
|
return _completePlaceholders.apply(this, arguments);
|
@@ -12262,20 +12264,20 @@ var le = /*#__PURE__*/function () {
|
|
12262
12264
|
}, {
|
12263
12265
|
key: "addButtons",
|
12264
12266
|
value: function addButtons() {
|
12265
|
-
var
|
12267
|
+
var _this61 = this;
|
12266
12268
|
for (var _len2 = arguments.length, e = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
12267
12269
|
e[_key2] = arguments[_key2];
|
12268
12270
|
}
|
12269
12271
|
e.forEach(function (t) {
|
12270
|
-
return
|
12272
|
+
return _this61._buttonPanel.appendChild(t);
|
12271
12273
|
});
|
12272
12274
|
}
|
12273
12275
|
}, {
|
12274
12276
|
key: "close",
|
12275
12277
|
value: function close() {
|
12276
|
-
var
|
12278
|
+
var _this62 = this;
|
12277
12279
|
this._elementRef.classList.remove("show-modal"), this._elementRef.classList.add("hide-modal"), this._backgroundPanelRef.classList.remove("show-modal-background"), this._backgroundPanelRef.classList.add("hide-modal-background"), this._isOpen = !1, setTimeout(function () {
|
12278
|
-
|
12280
|
+
_this62._elementRef.style.display = "none", _this62._backgroundPanelRef.style.display = "none";
|
12279
12281
|
}, le.MODAL_CLOSE_TIMEOUT_MS);
|
12280
12282
|
}
|
12281
12283
|
}, {
|
@@ -12291,10 +12293,10 @@ var le = /*#__PURE__*/function () {
|
|
12291
12293
|
}, {
|
12292
12294
|
key: "addCloseButton",
|
12293
12295
|
value: function addCloseButton(e, t, i) {
|
12294
|
-
var
|
12296
|
+
var _this63 = this;
|
12295
12297
|
var n = t ? le.createSVGButton(e) : le.createTextButton(e);
|
12296
12298
|
return this.addButtons(n), n.onclick = function () {
|
12297
|
-
|
12299
|
+
_this63.close(), setTimeout(function () {
|
12298
12300
|
i == null || i();
|
12299
12301
|
}, 140);
|
12300
12302
|
}, n;
|
@@ -12365,13 +12367,13 @@ var ze = le;
|
|
12365
12367
|
var xt = /*#__PURE__*/function (_Bt3) {
|
12366
12368
|
// prettier-ignore
|
12367
12369
|
function xt(e, t, i, n, r, o) {
|
12368
|
-
var
|
12370
|
+
var _this64;
|
12369
12371
|
_classCallCheck(this, xt);
|
12370
12372
|
var l, c, d, h, u, f;
|
12371
|
-
|
12372
|
-
var a =
|
12373
|
-
|
12374
|
-
return
|
12373
|
+
_this64 = _callSuper(this, xt, [xt.createButtonElement(), (l = i.button) == null ? void 0 : l.position, i.button, o]);
|
12374
|
+
var a = _this64.createInnerElements(n, r, _this64._customStyles);
|
12375
|
+
_this64._inputElement = xt.createInputElement((c = i == null ? void 0 : i.files) == null ? void 0 : c.acceptedFormats), _this64.addClickEvent(e, i), _this64.elementRef.replaceChildren(a.styles), _this64.reapplyStateStyle("styles"), _this64._fileAttachmentsType = t, _this64._openModalOnce = ((h = (d = i.files) == null ? void 0 : d.infoModal) == null ? void 0 : h.openModalOnce) === !1 || (f = (u = i.files) == null ? void 0 : u.infoModal) == null ? void 0 : f.openModalOnce;
|
12376
|
+
return _this64;
|
12375
12377
|
}
|
12376
12378
|
_inherits(xt, _Bt3);
|
12377
12379
|
return _createClass(xt, [{
|
@@ -12429,15 +12431,15 @@ var xt = /*#__PURE__*/function (_Bt3) {
|
|
12429
12431
|
}
|
12430
12432
|
}]);
|
12431
12433
|
}(Bt);
|
12432
|
-
var
|
12433
|
-
function
|
12434
|
-
_classCallCheck(this,
|
12434
|
+
var ye = /*#__PURE__*/function () {
|
12435
|
+
function ye() {
|
12436
|
+
_classCallCheck(this, ye);
|
12435
12437
|
}
|
12436
|
-
return _createClass(
|
12438
|
+
return _createClass(ye, null, [{
|
12437
12439
|
key: "create",
|
12438
12440
|
value: function create(e, t, i) {
|
12439
|
-
var n =
|
12440
|
-
|
12441
|
+
var n = ye.createElement(i);
|
12442
|
+
ye.addEvents(n, e, t), e.appendChild(n);
|
12441
12443
|
}
|
12442
12444
|
}, {
|
12443
12445
|
key: "createElement",
|
@@ -12449,13 +12451,13 @@ var ve = /*#__PURE__*/function () {
|
|
12449
12451
|
key: "addEvents",
|
12450
12452
|
value: function addEvents(e, t, i) {
|
12451
12453
|
t.ondragenter = function (n) {
|
12452
|
-
n.preventDefault(),
|
12454
|
+
n.preventDefault(), ye.display(e);
|
12453
12455
|
}, e.ondragleave = function (n) {
|
12454
|
-
n.preventDefault(),
|
12456
|
+
n.preventDefault(), ye.hide(e);
|
12455
12457
|
}, e.ondragover = function (n) {
|
12456
12458
|
n.preventDefault();
|
12457
12459
|
}, e.ondrop = function (n) {
|
12458
|
-
n.preventDefault(),
|
12460
|
+
n.preventDefault(), ye.uploadFile(i, n), ye.hide(e);
|
12459
12461
|
};
|
12460
12462
|
}
|
12461
12463
|
}, {
|
@@ -12498,26 +12500,26 @@ var Fe = /*#__PURE__*/function () {
|
|
12498
12500
|
}, {
|
12499
12501
|
key: "useValidationFunc",
|
12500
12502
|
value: function () {
|
12501
|
-
var _useValidationFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12503
|
+
var _useValidationFunc = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee112(e, t, i, n) {
|
12502
12504
|
var r, o, a, l;
|
12503
|
-
return _regeneratorRuntime().wrap(function
|
12504
|
-
while (1) switch (
|
12505
|
+
return _regeneratorRuntime().wrap(function _callee112$(_context112) {
|
12506
|
+
while (1) switch (_context112.prev = _context112.next) {
|
12505
12507
|
case 0:
|
12506
12508
|
r = t.inputElementRef, o = r.classList.contains("text-input-placeholder") ? "" : r.textContent;
|
12507
|
-
|
12509
|
+
_context112.next = 3;
|
12508
12510
|
return i.completePlaceholders();
|
12509
12511
|
case 3:
|
12510
12512
|
a = i.getAllFileData(), l = a == null ? void 0 : a.map(function (c) {
|
12511
12513
|
return c.file;
|
12512
12514
|
});
|
12513
|
-
return
|
12515
|
+
return _context112.abrupt("return", Fe.validate(e, n, o, l));
|
12514
12516
|
case 5:
|
12515
12517
|
case "end":
|
12516
|
-
return
|
12518
|
+
return _context112.stop();
|
12517
12519
|
}
|
12518
|
-
},
|
12520
|
+
}, _callee112);
|
12519
12521
|
}));
|
12520
|
-
function useValidationFunc(
|
12522
|
+
function useValidationFunc(_x198, _x199, _x200, _x201) {
|
12521
12523
|
return _useValidationFunc.apply(this, arguments);
|
12522
12524
|
}
|
12523
12525
|
return useValidationFunc;
|
@@ -12525,22 +12527,22 @@ var Fe = /*#__PURE__*/function () {
|
|
12525
12527
|
}, {
|
12526
12528
|
key: "useValidationFuncProgrammatic",
|
12527
12529
|
value: function () {
|
12528
|
-
var _useValidationFuncProgrammatic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12530
|
+
var _useValidationFuncProgrammatic = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee113(e, t, i) {
|
12529
12531
|
var r, n;
|
12530
|
-
return _regeneratorRuntime().wrap(function
|
12531
|
-
while (1) switch (
|
12532
|
+
return _regeneratorRuntime().wrap(function _callee113$(_context113) {
|
12533
|
+
while (1) switch (_context113.prev = _context113.next) {
|
12532
12534
|
case 0:
|
12533
12535
|
n = (r = t.files) == null ? void 0 : r.map(function (o) {
|
12534
12536
|
return o.file;
|
12535
12537
|
});
|
12536
|
-
return
|
12538
|
+
return _context113.abrupt("return", Fe.validate(e, i, t.text, n, !0));
|
12537
12539
|
case 2:
|
12538
12540
|
case "end":
|
12539
|
-
return
|
12541
|
+
return _context113.stop();
|
12540
12542
|
}
|
12541
|
-
},
|
12543
|
+
}, _callee113);
|
12542
12544
|
}));
|
12543
|
-
function useValidationFuncProgrammatic(
|
12545
|
+
function useValidationFuncProgrammatic(_x202, _x203, _x204) {
|
12544
12546
|
return _useValidationFuncProgrammatic.apply(this, arguments);
|
12545
12547
|
}
|
12546
12548
|
return useValidationFuncProgrammatic;
|
@@ -12554,29 +12556,29 @@ var Fe = /*#__PURE__*/function () {
|
|
12554
12556
|
}, {
|
12555
12557
|
key: "attach",
|
12556
12558
|
value: function attach(e, t, i, n, r) {
|
12557
|
-
var o = e.validateInput ||
|
12559
|
+
var o = e.validateInput || he.processValidateInput(e);
|
12558
12560
|
e._validationHandler = /*#__PURE__*/function () {
|
12559
|
-
var
|
12561
|
+
var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee114(a) {
|
12560
12562
|
var l;
|
12561
|
-
return _regeneratorRuntime().wrap(function
|
12562
|
-
while (1) switch (
|
12563
|
+
return _regeneratorRuntime().wrap(function _callee114$(_context114) {
|
12564
|
+
while (1) switch (_context114.prev = _context114.next) {
|
12563
12565
|
case 0:
|
12564
12566
|
if (!(r.status.loadingActive || r.status.requestInProgress || t.isSubmitProgrammaticallyDisabled === !0 || !Fe.validateWebsocket(t, r))) {
|
12565
|
-
|
12567
|
+
_context114.next = 2;
|
12566
12568
|
break;
|
12567
12569
|
}
|
12568
|
-
return
|
12570
|
+
return _context114.abrupt("return", !1);
|
12569
12571
|
case 2:
|
12570
12572
|
l = o || t.canSendMessage;
|
12571
|
-
return
|
12573
|
+
return _context114.abrupt("return", l ? a ? Fe.useValidationFuncProgrammatic(l, a, r) : Fe.useValidationFunc(l, i, n, r) : null);
|
12572
12574
|
case 4:
|
12573
12575
|
case "end":
|
12574
|
-
return
|
12576
|
+
return _context114.stop();
|
12575
12577
|
}
|
12576
|
-
},
|
12578
|
+
}, _callee114);
|
12577
12579
|
}));
|
12578
|
-
return function (
|
12579
|
-
return
|
12580
|
+
return function (_x205) {
|
12581
|
+
return _ref16.apply(this, arguments);
|
12580
12582
|
};
|
12581
12583
|
}();
|
12582
12584
|
}
|
@@ -12599,11 +12601,11 @@ var ds = /*#__PURE__*/function () {
|
|
12599
12601
|
}();
|
12600
12602
|
var oa = /*#__PURE__*/function (_Lt2) {
|
12601
12603
|
function oa(e, t) {
|
12602
|
-
var
|
12604
|
+
var _this65;
|
12603
12605
|
_classCallCheck(this, oa);
|
12604
12606
|
var i, n;
|
12605
|
-
|
12606
|
-
return
|
12607
|
+
_this65 = _callSuper(this, oa, [t.button]), _this65._waitingForBrowserApproval = !1, _this65._audioType = e, _this65._extension = ((i = t.files) == null ? void 0 : i.format) || "mp3", _this65._maxDurationSeconds = (n = t.files) == null ? void 0 : n.maxDurationSeconds, _this65.elementRef.onclick = _this65.buttonClick.bind(_assertThisInitialized(_this65));
|
12608
|
+
return _this65;
|
12607
12609
|
}
|
12608
12610
|
_inherits(oa, _Lt2);
|
12609
12611
|
return _createClass(oa, [{
|
@@ -12614,10 +12616,10 @@ var oa = /*#__PURE__*/function (_Lt2) {
|
|
12614
12616
|
}, {
|
12615
12617
|
key: "stop",
|
12616
12618
|
value: function stop() {
|
12617
|
-
var
|
12619
|
+
var _this66 = this;
|
12618
12620
|
return new Promise(function (e) {
|
12619
12621
|
var t, i;
|
12620
|
-
|
12622
|
+
_this66.changeToDefault(), (t = _this66._mediaRecorder) == null || t.stop(), (i = _this66._mediaStream) == null || i.getTracks().forEach(function (n) {
|
12621
12623
|
return n.stop();
|
12622
12624
|
}), setTimeout(function () {
|
12623
12625
|
e();
|
@@ -12627,23 +12629,23 @@ var oa = /*#__PURE__*/function (_Lt2) {
|
|
12627
12629
|
}, {
|
12628
12630
|
key: "record",
|
12629
12631
|
value: function record() {
|
12630
|
-
var
|
12632
|
+
var _this67 = this;
|
12631
12633
|
navigator.mediaDevices.getUserMedia({
|
12632
12634
|
audio: !0
|
12633
12635
|
}).then(function (e) {
|
12634
|
-
|
12635
|
-
|
12636
|
-
}),
|
12636
|
+
_this67.changeToActive(), _this67._mediaRecorder = new MediaRecorder(e), _this67._audioType.addPlaceholderAttachment(_this67.stop.bind(_this67), _this67._maxDurationSeconds), _this67._mediaStream = e, _this67._mediaRecorder.addEventListener("dataavailable", function (t) {
|
12637
|
+
_this67.createFile(t);
|
12638
|
+
}), _this67._mediaRecorder.start();
|
12637
12639
|
})["catch"](function (e) {
|
12638
|
-
console.error(e),
|
12640
|
+
console.error(e), _this67.stop();
|
12639
12641
|
})["finally"](function () {
|
12640
|
-
|
12642
|
+
_this67._waitingForBrowserApproval = !1;
|
12641
12643
|
});
|
12642
12644
|
}
|
12643
12645
|
}, {
|
12644
12646
|
key: "createFile",
|
12645
12647
|
value: function createFile(e) {
|
12646
|
-
var
|
12648
|
+
var _this68 = this;
|
12647
12649
|
var t = new Blob([e.data], {
|
12648
12650
|
type: "audio/".concat(this._extension)
|
12649
12651
|
}),
|
@@ -12653,7 +12655,7 @@ var oa = /*#__PURE__*/function (_Lt2) {
|
|
12653
12655
|
}),
|
12654
12656
|
r = new FileReader();
|
12655
12657
|
r.readAsDataURL(n), r.onload = function (o) {
|
12656
|
-
|
12658
|
+
_this68._audioType.completePlaceholderAttachment(n, o.target.result);
|
12657
12659
|
};
|
12658
12660
|
}
|
12659
12661
|
}]);
|
@@ -12728,19 +12730,19 @@ var Ve = /*#__PURE__*/function () {
|
|
12728
12730
|
var k = /*#__PURE__*/function (_Bt4) {
|
12729
12731
|
// prettier-ignore
|
12730
12732
|
function k(e, t, i, n, r, o) {
|
12731
|
-
var
|
12733
|
+
var _this69;
|
12732
12734
|
_classCallCheck(this, k);
|
12733
12735
|
var a = Ve.process(e.submitButtonStyles);
|
12734
|
-
|
12736
|
+
_this69 = _callSuper(this, k, [k.createButtonContainerElement(), a == null ? void 0 : a.position, a]), _this69._isSVGLoadingIconOverriden = !1, _this69.status = {
|
12735
12737
|
requestInProgress: !1,
|
12736
12738
|
loadingActive: !1
|
12737
|
-
},
|
12739
|
+
}, _this69._messages = i, _this69._inputElementRef = t, _this69._fileAttachments = r, _this69._innerElements = _this69.createInnerElements(), _this69._abortStream = new AbortController(), _this69._stopClicked = {
|
12738
12740
|
listener: function listener() {}
|
12739
|
-
},
|
12741
|
+
}, _this69._serviceIO = n, _this69._alwaysEnabled = !!(a != null && a.alwaysEnabled), e.disableSubmitButton = _this69.disableSubmitButton.bind(_assertThisInitialized(_this69), n), _this69.attemptOverwriteLoadingStyle(e), o.microphone && _this69.setUpSpeechToText(o.microphone.button, e.speechToText), setTimeout(function () {
|
12740
12742
|
var l;
|
12741
|
-
|
12743
|
+
_this69._validationHandler = e._validationHandler, _this69.assignHandlers(_this69._validationHandler), (l = _this69._validationHandler) == null || l.call(_assertThisInitialized(_this69));
|
12742
12744
|
});
|
12743
|
-
return
|
12745
|
+
return _this69;
|
12744
12746
|
}
|
12745
12747
|
_inherits(k, _Bt4);
|
12746
12748
|
return _createClass(k, [{
|
@@ -12761,7 +12763,7 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12761
12763
|
}, {
|
12762
12764
|
key: "createCustomElements",
|
12763
12765
|
value: function createCustomElements() {
|
12764
|
-
var
|
12766
|
+
var _this70 = this;
|
12765
12767
|
var e = J.createSpecificStateElement(this.elementRef, "submit", this._customStyles),
|
12766
12768
|
t = {
|
12767
12769
|
loading: void 0,
|
@@ -12769,7 +12771,7 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12769
12771
|
};
|
12770
12772
|
return Object.keys(t).forEach(function (i) {
|
12771
12773
|
var n = i,
|
12772
|
-
r = J.createCustomElement(n,
|
12774
|
+
r = J.createCustomElement(n, _this70._customStyles);
|
12773
12775
|
r && (t[n] = r);
|
12774
12776
|
}), t.submit = e, t;
|
12775
12777
|
}
|
@@ -12815,12 +12817,12 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12815
12817
|
}, {
|
12816
12818
|
key: "submitFromInput",
|
12817
12819
|
value: function () {
|
12818
|
-
var _submitFromInput = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12820
|
+
var _submitFromInput = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee115() {
|
12819
12821
|
var t, e, _i22;
|
12820
|
-
return _regeneratorRuntime().wrap(function
|
12821
|
-
while (1) switch (
|
12822
|
+
return _regeneratorRuntime().wrap(function _callee115$(_context115) {
|
12823
|
+
while (1) switch (_context115.prev = _context115.next) {
|
12822
12824
|
case 0:
|
12823
|
-
|
12825
|
+
_context115.next = 2;
|
12824
12826
|
return this._fileAttachments.completePlaceholders();
|
12825
12827
|
case 2:
|
12826
12828
|
e = this._fileAttachments.getAllFileData();
|
@@ -12836,9 +12838,9 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12836
12838
|
}
|
12837
12839
|
case 4:
|
12838
12840
|
case "end":
|
12839
|
-
return
|
12841
|
+
return _context115.stop();
|
12840
12842
|
}
|
12841
|
-
},
|
12843
|
+
}, _callee115, this);
|
12842
12844
|
}));
|
12843
12845
|
function submitFromInput() {
|
12844
12846
|
return _submitFromInput.apply(this, arguments);
|
@@ -12848,31 +12850,31 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12848
12850
|
}, {
|
12849
12851
|
key: "programmaticSubmit",
|
12850
12852
|
value: function () {
|
12851
|
-
var _programmaticSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12852
|
-
var
|
12853
|
+
var _programmaticSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee116(e) {
|
12854
|
+
var _this71 = this;
|
12853
12855
|
var t;
|
12854
|
-
return _regeneratorRuntime().wrap(function
|
12855
|
-
while (1) switch (
|
12856
|
+
return _regeneratorRuntime().wrap(function _callee116$(_context116) {
|
12857
|
+
while (1) switch (_context116.prev = _context116.next) {
|
12856
12858
|
case 0:
|
12857
|
-
typeof e == "string" && (e =
|
12859
|
+
typeof e == "string" && (e = he.processSubmitUserMessage(e));
|
12858
12860
|
t = {
|
12859
12861
|
text: e.text
|
12860
12862
|
};
|
12861
12863
|
e.files && (t.files = Array.from(e.files).map(function (i) {
|
12862
12864
|
return {
|
12863
12865
|
file: i,
|
12864
|
-
type:
|
12866
|
+
type: xe.getTypeFromBlob(i)
|
12865
12867
|
};
|
12866
12868
|
})), setTimeout(function () {
|
12867
|
-
return
|
12869
|
+
return _this71.attemptSubmit(t, !0);
|
12868
12870
|
});
|
12869
12871
|
case 3:
|
12870
12872
|
case "end":
|
12871
|
-
return
|
12873
|
+
return _context116.stop();
|
12872
12874
|
}
|
12873
|
-
},
|
12875
|
+
}, _callee116);
|
12874
12876
|
}));
|
12875
|
-
function programmaticSubmit(
|
12877
|
+
function programmaticSubmit(_x206) {
|
12876
12878
|
return _programmaticSubmit.apply(this, arguments);
|
12877
12879
|
}
|
12878
12880
|
return programmaticSubmit;
|
@@ -12880,52 +12882,52 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12880
12882
|
}, {
|
12881
12883
|
key: "attemptSubmit",
|
12882
12884
|
value: function () {
|
12883
|
-
var _attemptSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12885
|
+
var _attemptSubmit = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee117(e) {
|
12884
12886
|
var t,
|
12885
12887
|
r,
|
12886
12888
|
o,
|
12887
12889
|
a,
|
12888
12890
|
i,
|
12889
12891
|
n,
|
12890
|
-
|
12891
|
-
return _regeneratorRuntime().wrap(function
|
12892
|
-
while (1) switch (
|
12892
|
+
_args117 = arguments;
|
12893
|
+
return _regeneratorRuntime().wrap(function _callee117$(_context117) {
|
12894
|
+
while (1) switch (_context117.prev = _context117.next) {
|
12893
12895
|
case 0:
|
12894
|
-
t =
|
12895
|
-
|
12896
|
+
t = _args117.length > 1 && _args117[1] !== undefined ? _args117[1] : !1;
|
12897
|
+
_context117.next = 3;
|
12896
12898
|
return (r = this._validationHandler) == null ? void 0 : r.call(this, t ? e : void 0);
|
12897
12899
|
case 3:
|
12898
|
-
|
12899
|
-
|
12900
|
-
if (!(
|
12901
|
-
|
12900
|
+
_context117.t0 = _context117.sent;
|
12901
|
+
_context117.t1 = !1;
|
12902
|
+
if (!(_context117.t0 === _context117.t1)) {
|
12903
|
+
_context117.next = 7;
|
12902
12904
|
break;
|
12903
12905
|
}
|
12904
|
-
return
|
12906
|
+
return _context117.abrupt("return");
|
12905
12907
|
case 7:
|
12906
12908
|
this.changeToLoadingIcon();
|
12907
|
-
|
12909
|
+
_context117.next = 10;
|
12908
12910
|
return this.addNewMessage(e);
|
12909
12911
|
case 10:
|
12910
12912
|
this._serviceIO.isWebModel() || this._messages.addLoadingMessage();
|
12911
|
-
|
12913
|
+
Tt.clear(this._inputElementRef);
|
12912
12914
|
i = (o = e.files) == null ? void 0 : o.map(function (l) {
|
12913
12915
|
return l.file;
|
12914
12916
|
}), n = {
|
12915
12917
|
text: e.text === "" ? void 0 : e.text,
|
12916
12918
|
files: i
|
12917
12919
|
};
|
12918
|
-
|
12920
|
+
_context117.next = 15;
|
12919
12921
|
return this._serviceIO.callAPI(n, this._messages);
|
12920
12922
|
case 15:
|
12921
12923
|
(a = this._fileAttachments) == null || a.removeAllFiles();
|
12922
12924
|
case 16:
|
12923
12925
|
case "end":
|
12924
|
-
return
|
12926
|
+
return _context117.stop();
|
12925
12927
|
}
|
12926
|
-
},
|
12928
|
+
}, _callee117, this);
|
12927
12929
|
}));
|
12928
|
-
function attemptSubmit(
|
12930
|
+
function attemptSubmit(_x207) {
|
12929
12931
|
return _attemptSubmit.apply(this, arguments);
|
12930
12932
|
}
|
12931
12933
|
return attemptSubmit;
|
@@ -12933,35 +12935,35 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12933
12935
|
}, {
|
12934
12936
|
key: "addNewMessage",
|
12935
12937
|
value: function () {
|
12936
|
-
var _addNewMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function
|
12938
|
+
var _addNewMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee118(_ref17) {
|
12937
12939
|
var e, t, i;
|
12938
|
-
return _regeneratorRuntime().wrap(function
|
12939
|
-
while (1) switch (
|
12940
|
+
return _regeneratorRuntime().wrap(function _callee118$(_context118) {
|
12941
|
+
while (1) switch (_context118.prev = _context118.next) {
|
12940
12942
|
case 0:
|
12941
|
-
e =
|
12943
|
+
e = _ref17.text, t = _ref17.files;
|
12942
12944
|
i = {
|
12943
12945
|
role: b.USER_ROLE
|
12944
12946
|
};
|
12945
12947
|
e && (i.text = e);
|
12946
|
-
|
12947
|
-
if (!
|
12948
|
-
|
12948
|
+
_context118.t0 = t;
|
12949
|
+
if (!_context118.t0) {
|
12950
|
+
_context118.next = 8;
|
12949
12951
|
break;
|
12950
12952
|
}
|
12951
|
-
|
12953
|
+
_context118.next = 7;
|
12952
12954
|
return this._messages.addMultipleFiles(t);
|
12953
12955
|
case 7:
|
12954
|
-
i.files =
|
12956
|
+
i.files = _context118.sent;
|
12955
12957
|
case 8:
|
12956
12958
|
this._serviceIO.sessionId && (i._sessionId = this._serviceIO.sessionId);
|
12957
12959
|
Object.keys(i).length > 0 && this._messages.addNewMessage(i);
|
12958
12960
|
case 10:
|
12959
12961
|
case "end":
|
12960
|
-
return
|
12962
|
+
return _context118.stop();
|
12961
12963
|
}
|
12962
|
-
},
|
12964
|
+
}, _callee118, this);
|
12963
12965
|
}));
|
12964
|
-
function addNewMessage(
|
12966
|
+
function addNewMessage(_x208) {
|
12965
12967
|
return _addNewMessage.apply(this, arguments);
|
12966
12968
|
}
|
12967
12969
|
return addNewMessage;
|
@@ -12986,10 +12988,10 @@ var k = /*#__PURE__*/function (_Bt4) {
|
|
12986
12988
|
}, {
|
12987
12989
|
key: "changeToSubmitIcon",
|
12988
12990
|
value: function changeToSubmitIcon() {
|
12989
|
-
var
|
12991
|
+
var _this72 = this;
|
12990
12992
|
this.elementRef.classList.contains(k.SUBMIT_CLASS) || (this.elementRef.classList.remove(k.LOADING_CLASS, k.DISABLED_CLASS), this.elementRef.classList.add(k.SUBMIT_CLASS), this.elementRef.replaceChildren(this._innerElements.submit), Ve.resetSubmit(this, this.status.loadingActive), this.elementRef.onclick = function () {
|
12991
12993
|
var e;
|
12992
|
-
|
12994
|
+
_this72.submitFromInput(), (e = _this72._microphoneButton) != null && e.isActive && Ot.toggleSpeechAfterSubmit(_this72._microphoneButton.elementRef, !!_this72._stopSTTAfterSubmit);
|
12993
12995
|
});
|
12994
12996
|
}
|
12995
12997
|
// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
|
@@ -13040,14 +13042,14 @@ var la = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\"
|
|
13040
13042
|
var bn = /*#__PURE__*/function (_ze) {
|
13041
13043
|
// prettier-ignore
|
13042
13044
|
function bn(e, t, i, n) {
|
13043
|
-
var
|
13045
|
+
var _this73;
|
13044
13046
|
_classCallCheck(this, bn);
|
13045
|
-
|
13046
|
-
var
|
13047
|
-
r =
|
13048
|
-
o =
|
13049
|
-
|
13050
|
-
return
|
13047
|
+
_this73 = _callSuper(this, bn, [e, ["modal-content", "modal-camera-content"], i]), _this73._stopped = !1, _this73._format = "image/png", _this73._canvas = document.createElement("canvas"), _this73._canvas.classList.add("camera-modal-canvas");
|
13048
|
+
var _this73$addButtonsAnd = _this73.addButtonsAndTheirEvents(t),
|
13049
|
+
r = _this73$addButtonsAnd.captureButton,
|
13050
|
+
o = _this73$addButtonsAnd.submitButton;
|
13051
|
+
_this73._captureButton = r, _this73._submitButton = o, _this73._captureIcon = _this73._captureButton.children[0], _this73._refreshIcon = X.createSVGElement(la), _this73._refreshIcon.classList.add("modal-svg-button-icon", "modal-svg-refresh-icon"), (n == null ? void 0 : n.format) === "jpeg" && (_this73._format = "image/jpeg"), n != null && n.dimensions && (_this73._dimensions = n.dimensions), _this73._contentRef.appendChild(_this73._canvas), _this73.extensionCloseCallback = _this73.stop;
|
13052
|
+
return _this73;
|
13051
13053
|
}
|
13052
13054
|
_inherits(bn, _ze);
|
13053
13055
|
return _createClass(bn, [{
|
@@ -13067,38 +13069,38 @@ var bn = /*#__PURE__*/function (_ze) {
|
|
13067
13069
|
}, {
|
13068
13070
|
key: "addButtonEvents",
|
13069
13071
|
value: function addButtonEvents(e, t, i, n) {
|
13070
|
-
var
|
13072
|
+
var _this74 = this;
|
13071
13073
|
e.onclick = function () {
|
13072
|
-
|
13074
|
+
_this74.capture();
|
13073
13075
|
}, t.addEventListener("click", this.stop.bind(this)), i.onclick = function () {
|
13074
|
-
var r =
|
13075
|
-
r && zt.addFilesToType([r], [n]),
|
13076
|
+
var r = _this74.getFile();
|
13077
|
+
r && zt.addFilesToType([r], [n]), _this74.stop(), _this74.close();
|
13076
13078
|
};
|
13077
13079
|
}
|
13078
13080
|
}, {
|
13079
13081
|
key: "stop",
|
13080
13082
|
value: function stop() {
|
13081
|
-
var
|
13083
|
+
var _this75 = this;
|
13082
13084
|
this._mediaStream && this._mediaStream.getTracks().forEach(function (e) {
|
13083
13085
|
return e.stop();
|
13084
13086
|
}), this._stopped = !0, setTimeout(function () {
|
13085
|
-
|
13086
|
-
var e =
|
13087
|
-
e == null || e.clearRect(0, 0,
|
13087
|
+
_this75._captureButton.replaceChildren(_this75._captureIcon), _this75._captureButton.classList.replace("modal-svg-refresh-button", "modal-svg-camera-button");
|
13088
|
+
var e = _this75._canvas.getContext("2d");
|
13089
|
+
e == null || e.clearRect(0, 0, _this75._canvas.width, _this75._canvas.height);
|
13088
13090
|
}, ze.MODAL_CLOSE_TIMEOUT_MS);
|
13089
13091
|
}
|
13090
13092
|
}, {
|
13091
13093
|
key: "start",
|
13092
13094
|
value: function start() {
|
13093
|
-
var
|
13095
|
+
var _this76 = this;
|
13094
13096
|
this._dataURL = void 0, this._submitButton.classList.add("modal-svg-submit-disabled"), this._stopped = !1, navigator.mediaDevices.getUserMedia({
|
13095
13097
|
video: this._dimensions || !0
|
13096
13098
|
}).then(function (e) {
|
13097
|
-
if (
|
13099
|
+
if (_this76._mediaStream = e, !_this76.isOpen()) return _this76.stop();
|
13098
13100
|
var t = document.createElement("video");
|
13099
|
-
t.srcObject = e, t.play(), requestAnimationFrame(
|
13101
|
+
t.srcObject = e, t.play(), requestAnimationFrame(_this76.updateCanvas.bind(_this76, t, _this76._canvas));
|
13100
13102
|
})["catch"](function (e) {
|
13101
|
-
console.error(e),
|
13103
|
+
console.error(e), _this76.stop(), _this76.close();
|
13102
13104
|
});
|
13103
13105
|
}
|
13104
13106
|
}, {
|
@@ -13153,13 +13155,13 @@ var bn = /*#__PURE__*/function (_ze) {
|
|
13153
13155
|
var ua = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M29 7h-4.599l-2.401-4h-12l-2.4 4h-4.6c-1 0-3 1-3 2.969v16.031c0 1.657 1.5 3 2.792 3h26.271c1.313 0 2.938-1.406 2.938-2.968v-16.032c0-1-1-3-3-3zM30 26.032c0 0.395-0.639 0.947-0.937 0.969h-26.265c-0.232-0.019-0.797-0.47-0.797-1v-16.031c0-0.634 0.851-0.953 1-0.969h5.732l2.4-4h9.802l1.785 3.030 0.55 0.97h5.731c0.705 0 0.99 0.921 1 1v16.032zM16 10c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zM16 22c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z\"></path>\n</svg>";
|
13154
13156
|
var mi = /*#__PURE__*/function (_Bt5) {
|
13155
13157
|
function mi(e, t, i) {
|
13156
|
-
var
|
13158
|
+
var _this77;
|
13157
13159
|
_classCallCheck(this, mi);
|
13158
13160
|
var r;
|
13159
|
-
|
13160
|
-
var n =
|
13161
|
-
i &&
|
13162
|
-
return
|
13161
|
+
_this77 = _callSuper(this, mi, [mi.createButtonElement(), (r = i == null ? void 0 : i.button) == null ? void 0 : r.position, (i == null ? void 0 : i.button) || {}, "Photo"]);
|
13162
|
+
var n = _this77.createInnerElements(_this77._customStyles);
|
13163
|
+
i && _this77.addClickEvent(e, t, i.modalContainerStyle, i.files), _this77.elementRef.classList.add("upload-file-button"), _this77.elementRef.appendChild(n.styles), _this77.reapplyStateStyle("styles");
|
13164
|
+
return _this77;
|
13163
13165
|
}
|
13164
13166
|
_inherits(mi, _Bt5);
|
13165
13167
|
return _createClass(mi, [{
|
@@ -13200,7 +13202,7 @@ var _t = /*#__PURE__*/function () {
|
|
13200
13202
|
function _t(e, t, i, n) {
|
13201
13203
|
_classCallCheck(this, _t);
|
13202
13204
|
this.elementRef = _t.createPanelElement(e.inputAreaStyle);
|
13203
|
-
var r = new
|
13205
|
+
var r = new Tt(e, i),
|
13204
13206
|
o = {},
|
13205
13207
|
a = this.createFileUploadComponents(e, i, n, o);
|
13206
13208
|
e.speechToText && !o.microphone && (o.microphone = {
|
@@ -13230,7 +13232,7 @@ var _t = /*#__PURE__*/function () {
|
|
13230
13232
|
button: new oa(_d, t.recordAudio)
|
13231
13233
|
};
|
13232
13234
|
}
|
13233
|
-
return
|
13235
|
+
return ye.isEnabled(r, e.dragAndDrop) && ye.create(i, r, e.dragAndDrop), r;
|
13234
13236
|
}
|
13235
13237
|
// prettier-ignore
|
13236
13238
|
}], [{
|
@@ -13279,7 +13281,7 @@ var vn = /*#__PURE__*/function () {
|
|
13279
13281
|
value: function createElements(e, t, i) {
|
13280
13282
|
var n = document.createElement("div");
|
13281
13283
|
n.id = "chat-view";
|
13282
|
-
var r = new
|
13284
|
+
var r = new ke(e, t, i);
|
13283
13285
|
t.websocket && z.createConnection(t, r);
|
13284
13286
|
var o = new _t(e, r, t, n);
|
13285
13287
|
return j.addElements(n, r.elementRef, o.elementRef), n;
|
@@ -13301,22 +13303,31 @@ var pa = Object.defineProperty,
|
|
13301
13303
|
};
|
13302
13304
|
var y = /*#__PURE__*/function (_Xi) {
|
13303
13305
|
function y() {
|
13304
|
-
var
|
13306
|
+
var _this78;
|
13305
13307
|
_classCallCheck(this, y);
|
13306
|
-
|
13308
|
+
_this78 = _callSuper(this, y), _this78.connect = {
|
13309
|
+
// stream: true,
|
13310
|
+
}, _this78.directConnection = {
|
13311
|
+
openAI: {
|
13312
|
+
assistant: {
|
13313
|
+
assistant_id: "asst_dDy5gBApC0nd2puFgj8pEecp"
|
13314
|
+
},
|
13315
|
+
key: "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"
|
13316
|
+
}
|
13317
|
+
}, _this78.getMessages = function () {
|
13307
13318
|
return [];
|
13308
|
-
},
|
13319
|
+
}, _this78.submitUserMessage = function () {
|
13309
13320
|
return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");
|
13310
|
-
},
|
13321
|
+
}, _this78.addMessage = function () {
|
13311
13322
|
return console.warn("addMessage failed - please wait for chat view to render before calling this property.");
|
13312
|
-
},
|
13313
|
-
return yi.focusFromParentElement(
|
13314
|
-
},
|
13323
|
+
}, _this78.focusInput = function () {
|
13324
|
+
return yi.focusFromParentElement(_this78._elementRef);
|
13325
|
+
}, _this78.refreshMessages = function () {}, _this78.clearMessages = function () {}, _this78.scrollToBottom = function () {}, _this78.disableSubmitButton = function () {}, _this78._hasBeenRendered = !1, _this78._auxiliaryStyleApplied = !1, _this78._elementRef = document.createElement("div"), _this78._elementRef.id = "container", _this78.attachShadow({
|
13315
13326
|
mode: "open"
|
13316
|
-
}).appendChild(
|
13317
|
-
|
13327
|
+
}).appendChild(_this78._elementRef), bt.apply(fa, _this78.shadowRoot), setTimeout(function () {
|
13328
|
+
_this78._hasBeenRendered || _this78.onRender();
|
13318
13329
|
}, 20);
|
13319
|
-
return
|
13330
|
+
return _this78;
|
13320
13331
|
}
|
13321
13332
|
_inherits(y, _Xi);
|
13322
13333
|
return _createClass(y, [{
|
@@ -13329,7 +13340,7 @@ var y = /*#__PURE__*/function (_Xi) {
|
|
13329
13340
|
key: "onRender",
|
13330
13341
|
value: function onRender() {
|
13331
13342
|
var _this$_childElement;
|
13332
|
-
Xt.attemptAppendStyleSheetToHead(this.style),
|
13343
|
+
Xt.attemptAppendStyleSheetToHead(this.style), he.processConnect(this), (!this._activeService || this._activeService.demo) && (this._activeService = Mo.create(this)), this.auxiliaryStyle && !this._auxiliaryStyleApplied && (bt.apply(this.auxiliaryStyle, this.shadowRoot), this._auxiliaryStyleApplied = !0), bt.applyDefaultStyleToComponent(this.style, this.chatStyle), he.checkForContainerStyles(this, this._elementRef), this._activeService.key && this._activeService.validateKeyProperty ? Jt.render(this._elementRef, this.changeToChatView.bind(this), this._activeService) : !(this._activeService instanceof U) || this._activeService.key ? ((_this$_childElement = this._childElement) !== null && _this$_childElement !== void 0 ? _this$_childElement : this._childElement = this.children[0], vn.render(this, this._elementRef, this._activeService, this._childElement)) : this._activeService instanceof U && D.render(this._elementRef, this.changeToChatView.bind(this), this._activeService), this._hasBeenRendered = !0, Qt.onRender(this);
|
13333
13344
|
}
|
13334
13345
|
}, {
|
13335
13346
|
key: "disconnectedCallback",
|