@eduzz-automacoes/webchat-widget 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -2
- package/dist/eduzz-webchat.cjs +5 -5
- package/dist/eduzz-webchat.js +486 -443
- package/dist/index.d.ts +264 -112
- package/package.json +1 -1
package/dist/eduzz-webchat.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as o, jsxs as l, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { Container as Ge, MessageList as Ke, Composer as Je, WebchatProvider as
|
|
4
|
-
import './style.css';const
|
|
1
|
+
import { jsx as o, jsxs as l, Fragment as Ue } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Ve, createElement as ke, useState as R, useEffect as M, useRef as ce, useMemo as y, useCallback as re, useReducer as We } from "react";
|
|
3
|
+
import { Container as Ge, MessageList as Ke, Composer as Je, WebchatProvider as Xe, useActiveConversation as Ze, useConversations as Ye, useUser as Qe, useConversationList as et, Block as tt, StylesheetProvider as ot } from "@botpress/webchat";
|
|
4
|
+
import './style.css';const G = {
|
|
5
5
|
botName: "Assistente Virtual",
|
|
6
6
|
subtitle: "Conectado ao bot real",
|
|
7
7
|
botAvatar: "",
|
|
@@ -64,8 +64,8 @@ import './style.css';const j = {
|
|
|
64
64
|
welcomeCloseLabel: "Fechar painel",
|
|
65
65
|
openFabBackgroundColor: "#2563eb",
|
|
66
66
|
openFabIconColor: "#ffffff"
|
|
67
|
-
},
|
|
68
|
-
switch (
|
|
67
|
+
}, Fe = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", at = (e) => {
|
|
68
|
+
switch (Fe(e)) {
|
|
69
69
|
case "bottom-left":
|
|
70
70
|
return {
|
|
71
71
|
bottom: "24px",
|
|
@@ -82,12 +82,12 @@ import './style.css';const j = {
|
|
|
82
82
|
"--panel-transform-origin": "right bottom"
|
|
83
83
|
};
|
|
84
84
|
}
|
|
85
|
-
},
|
|
85
|
+
}, Re = (e, t, a) => Math.min(Math.max(e, t), a), xe = (e) => {
|
|
86
86
|
if (typeof e != "string") return null;
|
|
87
87
|
let t = e.trim();
|
|
88
88
|
return !t || (t.startsWith("#") && (t = t.slice(1)), t.length === 3 && (t = t.split("").map((a) => `${a}${a}`).join("")), !/^[0-9a-fA-F]{6}$/.test(t)) ? null : `#${t.toLowerCase()}`;
|
|
89
|
-
},
|
|
90
|
-
const t =
|
|
89
|
+
}, Ne = (e) => {
|
|
90
|
+
const t = xe(e);
|
|
91
91
|
if (!t) return null;
|
|
92
92
|
const a = t.slice(1);
|
|
93
93
|
return {
|
|
@@ -96,18 +96,18 @@ import './style.css';const j = {
|
|
|
96
96
|
b: Number.parseInt(a.slice(4, 6), 16)
|
|
97
97
|
};
|
|
98
98
|
}, nt = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
|
|
99
|
-
(r) =>
|
|
100
|
-
).join("")}`,
|
|
101
|
-
const r =
|
|
99
|
+
(r) => Re(Math.round(r), 0, 255).toString(16).padStart(2, "0")
|
|
100
|
+
).join("")}`, me = (e, t, a) => {
|
|
101
|
+
const r = Ne(e), s = Ne(t);
|
|
102
102
|
if (!r || !s) return null;
|
|
103
|
-
const n =
|
|
103
|
+
const n = Re(a, 0, 1);
|
|
104
104
|
return nt({
|
|
105
105
|
r: r.r * (1 - n) + s.r * n,
|
|
106
106
|
g: r.g * (1 - n) + s.g * n,
|
|
107
107
|
b: r.b * (1 - n) + s.b * n
|
|
108
108
|
});
|
|
109
|
-
}, rt = (e, t) => t < 0 ?
|
|
110
|
-
const t =
|
|
109
|
+
}, rt = (e, t) => t < 0 ? me(e, "#000000", Math.abs(t)) : me(e, "#ffffff", t), pe = (e) => {
|
|
110
|
+
const t = Ne(e);
|
|
111
111
|
return t && [t.r, t.g, t.b].map((r) => {
|
|
112
112
|
const s = r / 255;
|
|
113
113
|
return s <= 0.03928 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
@@ -116,9 +116,9 @@ import './style.css';const j = {
|
|
|
116
116
|
0
|
|
117
117
|
) > 0.42 ? "#18181b" : "#ffffff";
|
|
118
118
|
}, F = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", st = (e, t) => {
|
|
119
|
-
const a =
|
|
119
|
+
const a = xe(e.brandColor);
|
|
120
120
|
if (!a) return e;
|
|
121
|
-
const r =
|
|
121
|
+
const r = xe(e.brandTextColor) || pe(a), s = me(a, "#ffffff", 0.82) || G.secondaryButtonBorderColor, n = me(a, "#ffffff", 0.92) || G.secondaryButtonHoverBackgroundColor, c = rt(a, -0.12) || G.primaryButtonHoverBackgroundColor;
|
|
122
122
|
return {
|
|
123
123
|
...e,
|
|
124
124
|
brandColor: a,
|
|
@@ -151,7 +151,7 @@ import './style.css';const j = {
|
|
|
151
151
|
) ? e.iconButtonHoverBackgroundColor : n
|
|
152
152
|
};
|
|
153
153
|
}, ct = (e) => {
|
|
154
|
-
const t = e.fabBackgroundColor || e.openFabBackgroundColor ||
|
|
154
|
+
const t = e.fabBackgroundColor || e.openFabBackgroundColor || G.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || G.fabIconColor;
|
|
155
155
|
return {
|
|
156
156
|
...e,
|
|
157
157
|
fabBackgroundColor: t,
|
|
@@ -162,13 +162,13 @@ import './style.css';const j = {
|
|
|
162
162
|
}, lt = (e = {}) => ct(
|
|
163
163
|
st(
|
|
164
164
|
{
|
|
165
|
-
...
|
|
165
|
+
...G,
|
|
166
166
|
...e,
|
|
167
|
-
position:
|
|
167
|
+
position: Fe(e.position ?? G.position)
|
|
168
168
|
},
|
|
169
169
|
e
|
|
170
170
|
)
|
|
171
|
-
),
|
|
171
|
+
), se = (e) => ({
|
|
172
172
|
...at(e.position),
|
|
173
173
|
"--widget-width": e.width,
|
|
174
174
|
"--widget-height": e.height,
|
|
@@ -185,9 +185,9 @@ import './style.css';const j = {
|
|
|
185
185
|
"--bpGray-900": "var(--ui-text)",
|
|
186
186
|
"--bpGray-950": "var(--ui-text)",
|
|
187
187
|
"--accent-color": e.accentColor,
|
|
188
|
-
"--accent-text-color":
|
|
188
|
+
"--accent-text-color": pe(e.accentColor),
|
|
189
189
|
"--header-avatar-bg": e.accentColor,
|
|
190
|
-
"--header-avatar-text":
|
|
190
|
+
"--header-avatar-text": pe(e.accentColor),
|
|
191
191
|
"--primary-button-background-color": e.primaryButtonBackgroundColor,
|
|
192
192
|
"--primary-button-text-color": e.primaryButtonTextColor,
|
|
193
193
|
"--primary-button-hover-background-color": e.primaryButtonHoverBackgroundColor,
|
|
@@ -241,10 +241,10 @@ import './style.css';const j = {
|
|
|
241
241
|
const dt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ut = (e) => e.replace(
|
|
242
242
|
/^([A-Z])|[\s-_]+(\w)/g,
|
|
243
243
|
(t, a, r) => r ? r.toUpperCase() : a.toLowerCase()
|
|
244
|
-
),
|
|
244
|
+
), Me = (e) => {
|
|
245
245
|
const t = ut(e);
|
|
246
246
|
return t.charAt(0).toUpperCase() + t.slice(1);
|
|
247
|
-
},
|
|
247
|
+
}, Pe = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), bt = (e) => {
|
|
248
248
|
for (const t in e)
|
|
249
249
|
if (t.startsWith("aria-") || t === "role" || t === "title")
|
|
250
250
|
return !0;
|
|
@@ -260,7 +260,7 @@ var ht = {
|
|
|
260
260
|
strokeLinecap: "round",
|
|
261
261
|
strokeLinejoin: "round"
|
|
262
262
|
};
|
|
263
|
-
const mt =
|
|
263
|
+
const mt = Ve(
|
|
264
264
|
({
|
|
265
265
|
color: e = "currentColor",
|
|
266
266
|
size: t = 24,
|
|
@@ -269,46 +269,46 @@ const mt = Ie(
|
|
|
269
269
|
className: s = "",
|
|
270
270
|
children: n,
|
|
271
271
|
iconNode: c,
|
|
272
|
-
...
|
|
273
|
-
},
|
|
272
|
+
...i
|
|
273
|
+
}, u) => ke(
|
|
274
274
|
"svg",
|
|
275
275
|
{
|
|
276
|
-
ref:
|
|
276
|
+
ref: u,
|
|
277
277
|
...ht,
|
|
278
278
|
width: t,
|
|
279
279
|
height: t,
|
|
280
280
|
stroke: e,
|
|
281
281
|
strokeWidth: r ? Number(a) * 24 / Number(t) : a,
|
|
282
|
-
className:
|
|
283
|
-
...!n && !bt(
|
|
284
|
-
...
|
|
282
|
+
className: Pe("lucide", s),
|
|
283
|
+
...!n && !bt(i) && { "aria-hidden": "true" },
|
|
284
|
+
...i
|
|
285
285
|
},
|
|
286
286
|
[
|
|
287
|
-
...c.map(([
|
|
287
|
+
...c.map(([m, w]) => ke(m, w)),
|
|
288
288
|
...Array.isArray(n) ? n : [n]
|
|
289
289
|
]
|
|
290
290
|
)
|
|
291
291
|
);
|
|
292
|
-
const
|
|
293
|
-
const a =
|
|
294
|
-
({ className: r, ...s }, n) =>
|
|
292
|
+
const S = (e, t) => {
|
|
293
|
+
const a = Ve(
|
|
294
|
+
({ className: r, ...s }, n) => ke(mt, {
|
|
295
295
|
ref: n,
|
|
296
296
|
iconNode: t,
|
|
297
|
-
className:
|
|
298
|
-
`lucide-${dt(
|
|
297
|
+
className: Pe(
|
|
298
|
+
`lucide-${dt(Me(e))}`,
|
|
299
299
|
`lucide-${e}`,
|
|
300
300
|
r
|
|
301
301
|
),
|
|
302
302
|
...s
|
|
303
303
|
})
|
|
304
304
|
);
|
|
305
|
-
return a.displayName =
|
|
305
|
+
return a.displayName = Me(e), a;
|
|
306
306
|
};
|
|
307
307
|
const pt = [
|
|
308
308
|
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
309
309
|
["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
|
|
310
|
-
], wt =
|
|
311
|
-
const ft = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], gt =
|
|
310
|
+
], wt = S("arrow-right", pt);
|
|
311
|
+
const ft = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], gt = S("chevron-right", ft);
|
|
312
312
|
const yt = [
|
|
313
313
|
["path", { d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8", key: "5wwlr5" }],
|
|
314
314
|
[
|
|
@@ -318,8 +318,8 @@ const yt = [
|
|
|
318
318
|
key: "r6nss1"
|
|
319
319
|
}
|
|
320
320
|
]
|
|
321
|
-
],
|
|
322
|
-
const
|
|
321
|
+
], vt = S("house", yt);
|
|
322
|
+
const Ct = [
|
|
323
323
|
[
|
|
324
324
|
"path",
|
|
325
325
|
{
|
|
@@ -330,7 +330,7 @@ const vt = [
|
|
|
330
330
|
["path", { d: "M8 12h.01", key: "czm47f" }],
|
|
331
331
|
["path", { d: "M12 12h.01", key: "1mp3jc" }],
|
|
332
332
|
["path", { d: "M16 12h.01", key: "1l6xoz" }]
|
|
333
|
-
], Bt =
|
|
333
|
+
], Bt = S("message-circle-more", Ct);
|
|
334
334
|
const kt = [
|
|
335
335
|
[
|
|
336
336
|
"path",
|
|
@@ -339,7 +339,7 @@ const kt = [
|
|
|
339
339
|
key: "1sd12s"
|
|
340
340
|
}
|
|
341
341
|
]
|
|
342
|
-
], xt =
|
|
342
|
+
], xt = S("message-circle", kt);
|
|
343
343
|
const Nt = [
|
|
344
344
|
[
|
|
345
345
|
"path",
|
|
@@ -348,7 +348,7 @@ const Nt = [
|
|
|
348
348
|
key: "18887p"
|
|
349
349
|
}
|
|
350
350
|
]
|
|
351
|
-
],
|
|
351
|
+
], He = S("message-square", Nt);
|
|
352
352
|
const It = [
|
|
353
353
|
[
|
|
354
354
|
"path",
|
|
@@ -364,11 +364,11 @@ const It = [
|
|
|
364
364
|
key: "1qfcsi"
|
|
365
365
|
}
|
|
366
366
|
]
|
|
367
|
-
],
|
|
367
|
+
], $e = S("messages-square", It);
|
|
368
368
|
const Mt = [
|
|
369
369
|
["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
|
|
370
370
|
["path", { d: "M3 3v5h5", key: "1xhq8a" }]
|
|
371
|
-
], St =
|
|
371
|
+
], St = S("rotate-ccw", Mt);
|
|
372
372
|
const Tt = [
|
|
373
373
|
["path", { d: "M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7", key: "1m0v6g" }],
|
|
374
374
|
[
|
|
@@ -378,8 +378,8 @@ const Tt = [
|
|
|
378
378
|
key: "ohrbg2"
|
|
379
379
|
}
|
|
380
380
|
]
|
|
381
|
-
], At =
|
|
382
|
-
const
|
|
381
|
+
], At = S("square-pen", Tt);
|
|
382
|
+
const Ut = [
|
|
383
383
|
[
|
|
384
384
|
"path",
|
|
385
385
|
{
|
|
@@ -388,7 +388,7 @@ const Vt = [
|
|
|
388
388
|
}
|
|
389
389
|
],
|
|
390
390
|
["path", { d: "M17 14V2", key: "8ymqnk" }]
|
|
391
|
-
],
|
|
391
|
+
], Vt = S("thumbs-down", Ut);
|
|
392
392
|
const Ft = [
|
|
393
393
|
[
|
|
394
394
|
"path",
|
|
@@ -398,41 +398,41 @@ const Ft = [
|
|
|
398
398
|
}
|
|
399
399
|
],
|
|
400
400
|
["path", { d: "M7 10v12", key: "1qc93n" }]
|
|
401
|
-
],
|
|
402
|
-
const
|
|
401
|
+
], Rt = S("thumbs-up", Ft);
|
|
402
|
+
const Pt = [
|
|
403
403
|
["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
|
|
404
404
|
["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
|
|
405
|
-
],
|
|
405
|
+
], Ht = S("user-round", Pt);
|
|
406
406
|
const $t = [
|
|
407
407
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
408
408
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
409
|
-
],
|
|
410
|
-
"message-circle-more": /* @__PURE__ */ o(Bt, { ...
|
|
411
|
-
"message-circle": /* @__PURE__ */ o(xt, { ...
|
|
412
|
-
"message-square": /* @__PURE__ */ o(
|
|
413
|
-
"messages-square": /* @__PURE__ */ o(
|
|
414
|
-
}, zt = (e = "messages-square") =>
|
|
415
|
-
const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r =
|
|
416
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${
|
|
417
|
-
<rect width="96" height="96" rx="48" fill="${
|
|
418
|
-
<text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="42" font-weight="700" fill="${
|
|
409
|
+
], _e = S("x", $t), B = { "aria-hidden": !0, strokeWidth: 1.9 }, _t = /* @__PURE__ */ o(St, { ...B }), we = /* @__PURE__ */ o(_e, { ...B }), Lt = /* @__PURE__ */ o(_e, { ...B }), Se = {
|
|
410
|
+
"message-circle-more": /* @__PURE__ */ o(Bt, { ...B }),
|
|
411
|
+
"message-circle": /* @__PURE__ */ o(xt, { ...B }),
|
|
412
|
+
"message-square": /* @__PURE__ */ o(He, { ...B }),
|
|
413
|
+
"messages-square": /* @__PURE__ */ o($e, { ...B })
|
|
414
|
+
}, zt = (e = "messages-square") => Se[e] || Se["messages-square"], Dt = /* @__PURE__ */ o(wt, { ...B }), Le = /* @__PURE__ */ o(vt, { ...B }), qt = /* @__PURE__ */ o(He, { ...B }), Ot = /* @__PURE__ */ o(Rt, { ...B }), jt = /* @__PURE__ */ o(Vt, { ...B }), Et = /* @__PURE__ */ o($e, { ...B }), Wt = /* @__PURE__ */ o(gt, { ...B }), Gt = /* @__PURE__ */ o(At, { ...B }), Kt = /* @__PURE__ */ o(Ht, { ...B }), he = (e) => String(e).replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'"), Jt = ({ name: e, backgroundColor: t }) => {
|
|
415
|
+
const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r = pe(t), s = `
|
|
416
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${he(e || "Bot")}">
|
|
417
|
+
<rect width="96" height="96" rx="48" fill="${he(t)}" />
|
|
418
|
+
<text x="50%" y="52%" dominant-baseline="middle" text-anchor="middle" font-family="Arial, Helvetica, sans-serif" font-size="42" font-weight="700" fill="${he(r)}">${he(a)}</text>
|
|
419
419
|
</svg>
|
|
420
420
|
`.trim();
|
|
421
421
|
return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(s)}`;
|
|
422
|
-
},
|
|
422
|
+
}, Xt = (e) => e ? e.payload?.type === "text" ? e.payload.text : e.payload?.type === "bloc" && e.payload.items?.some((t) => t.type === "text") ? e.payload.items.find((a) => a.type === "text")?.payload.text ?? "Conversa sem mensagens" : "Anexo enviado" : "Conversa sem mensagens", Te = [
|
|
423
423
|
{ unit: "minute", seconds: 60 },
|
|
424
424
|
{ unit: "hour", seconds: 3600 },
|
|
425
425
|
{ unit: "day", seconds: 3600 * 24 },
|
|
426
426
|
{ unit: "week", seconds: 3600 * 24 * 7 },
|
|
427
427
|
{ unit: "month", seconds: 3600 * 24 * 30 },
|
|
428
428
|
{ unit: "year", seconds: 3600 * 24 * 365 }
|
|
429
|
-
],
|
|
429
|
+
], Zt = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), Yt = (e) => {
|
|
430
430
|
const t = Math.round((new Date(e).getTime() - Date.now()) / 1e3);
|
|
431
431
|
if (Math.abs(t) < 45) return "agora";
|
|
432
|
-
let a =
|
|
433
|
-
for (const r of
|
|
432
|
+
let a = Te[0];
|
|
433
|
+
for (const r of Te)
|
|
434
434
|
Math.abs(t) >= r.seconds && (a = r);
|
|
435
|
-
return
|
|
435
|
+
return Zt.format(Math.round(t / a.seconds), a.unit);
|
|
436
436
|
}, Qt = ({ messages: e, user: t, botName: a, botAvatar: r }) => e.map((s) => {
|
|
437
437
|
const n = s.authorId === t?.userId;
|
|
438
438
|
return {
|
|
@@ -441,24 +441,60 @@ const $t = [
|
|
|
441
441
|
sender: n ? { name: t?.name ?? "Você", avatar: t?.pictureUrl } : { name: a, avatar: r }
|
|
442
442
|
};
|
|
443
443
|
}), eo = ({ activeView: e, clientState: t, conversationId: a, messagesLength: r }) => {
|
|
444
|
-
const [s, n] = R(!1), c = e === "chat",
|
|
445
|
-
return
|
|
444
|
+
const [s, n] = R(!1), c = e === "chat", i = c && t === "connecting", u = c && t === "connected" && r === 0, m = s && (!c || r > 0 || t !== "connecting" && t !== "connected");
|
|
445
|
+
return M(() => {
|
|
446
446
|
if (s) {
|
|
447
|
-
if (
|
|
448
|
-
const
|
|
449
|
-
return () => window.clearTimeout(
|
|
447
|
+
if (u) {
|
|
448
|
+
const w = window.setTimeout(() => n(!1), 900);
|
|
449
|
+
return () => window.clearTimeout(w);
|
|
450
450
|
}
|
|
451
|
-
if (
|
|
452
|
-
const
|
|
453
|
-
return () => window.clearTimeout(
|
|
451
|
+
if (m) {
|
|
452
|
+
const w = window.setTimeout(() => n(!1), 0);
|
|
453
|
+
return () => window.clearTimeout(w);
|
|
454
454
|
}
|
|
455
455
|
}
|
|
456
|
-
}, [a, s,
|
|
457
|
-
showInitialLoading:
|
|
456
|
+
}, [a, s, u, m]), {
|
|
457
|
+
showInitialLoading: i || s && c,
|
|
458
458
|
setShowInitialLoading: n
|
|
459
459
|
};
|
|
460
|
+
}, to = 3e4, oo = ({
|
|
461
|
+
getSession: e,
|
|
462
|
+
sessionKey: t,
|
|
463
|
+
onSessionChange: a
|
|
464
|
+
}) => {
|
|
465
|
+
const [r, s] = R(null), [n, c] = R(!!e), i = ce(e);
|
|
466
|
+
i.current = e;
|
|
467
|
+
const u = ce(a);
|
|
468
|
+
return u.current = a, M(() => {
|
|
469
|
+
let m = !0, w;
|
|
470
|
+
const b = (h) => {
|
|
471
|
+
m && (s(h), u.current?.(h));
|
|
472
|
+
};
|
|
473
|
+
if (!i.current) {
|
|
474
|
+
c(!1), b(null);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const P = async () => {
|
|
478
|
+
try {
|
|
479
|
+
const h = await i.current();
|
|
480
|
+
if (!h?.userToken)
|
|
481
|
+
throw new Error("Webchat session not created or empty");
|
|
482
|
+
if (!m) return;
|
|
483
|
+
b(h);
|
|
484
|
+
const x = h.expiresAt - Date.now() - to;
|
|
485
|
+
w = setTimeout(P, Math.max(x, 0));
|
|
486
|
+
} catch (h) {
|
|
487
|
+
console.error("[EduzzWebchat] error creating session: ", h), b(null);
|
|
488
|
+
} finally {
|
|
489
|
+
m && c(!1);
|
|
490
|
+
}
|
|
491
|
+
};
|
|
492
|
+
return c(!0), P(), () => {
|
|
493
|
+
m = !1, w && clearTimeout(w);
|
|
494
|
+
};
|
|
495
|
+
}, [t, !!e]), { session: r, resolving: n };
|
|
460
496
|
};
|
|
461
|
-
function
|
|
497
|
+
function ao({
|
|
462
498
|
botName: e,
|
|
463
499
|
botAvatar: t,
|
|
464
500
|
subtitle: a,
|
|
@@ -483,7 +519,7 @@ function to({
|
|
|
483
519
|
type: "button",
|
|
484
520
|
"aria-label": "Abrir início",
|
|
485
521
|
onClick: r,
|
|
486
|
-
children:
|
|
522
|
+
children: Le
|
|
487
523
|
}
|
|
488
524
|
) : null,
|
|
489
525
|
/* @__PURE__ */ o(
|
|
@@ -513,13 +549,13 @@ function to({
|
|
|
513
549
|
type: "button",
|
|
514
550
|
"aria-label": "Fechar webchat",
|
|
515
551
|
onClick: c,
|
|
516
|
-
children:
|
|
552
|
+
children: we
|
|
517
553
|
}
|
|
518
554
|
) : null
|
|
519
555
|
] })
|
|
520
556
|
] });
|
|
521
557
|
}
|
|
522
|
-
function
|
|
558
|
+
function ze() {
|
|
523
559
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-loading", children: [
|
|
524
560
|
/* @__PURE__ */ l("div", { className: "bp-webchat-loading-hero", children: [
|
|
525
561
|
/* @__PURE__ */ o("div", { className: "bp-webchat-loading-circle" }),
|
|
@@ -537,7 +573,7 @@ function Pe() {
|
|
|
537
573
|
] })
|
|
538
574
|
] });
|
|
539
575
|
}
|
|
540
|
-
function
|
|
576
|
+
function no({
|
|
541
577
|
config: e,
|
|
542
578
|
allowFileUpload: t,
|
|
543
579
|
clientState: a,
|
|
@@ -545,34 +581,34 @@ function oo({
|
|
|
545
581
|
messages: s,
|
|
546
582
|
renderers: n,
|
|
547
583
|
sendMessage: c,
|
|
548
|
-
uploadFile:
|
|
549
|
-
addMessageFeedback:
|
|
550
|
-
showInitialLoading:
|
|
551
|
-
onShowHome:
|
|
552
|
-
onOpenHistory:
|
|
553
|
-
onRestartConversation:
|
|
554
|
-
onCloseWidget:
|
|
584
|
+
uploadFile: i,
|
|
585
|
+
addMessageFeedback: u,
|
|
586
|
+
showInitialLoading: m,
|
|
587
|
+
onShowHome: w,
|
|
588
|
+
onOpenHistory: b,
|
|
589
|
+
onRestartConversation: P,
|
|
590
|
+
onCloseWidget: h
|
|
555
591
|
}) {
|
|
556
592
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-layout", children: [
|
|
557
593
|
/* @__PURE__ */ o(
|
|
558
|
-
|
|
594
|
+
ao,
|
|
559
595
|
{
|
|
560
596
|
botName: e.botName,
|
|
561
597
|
botAvatar: e.botAvatar,
|
|
562
598
|
subtitle: e.subtitle,
|
|
563
|
-
onShowHome:
|
|
564
|
-
onOpenHistory:
|
|
565
|
-
onRestartConversation:
|
|
566
|
-
onCloseWidget:
|
|
599
|
+
onShowHome: w,
|
|
600
|
+
onOpenHistory: b,
|
|
601
|
+
onRestartConversation: P,
|
|
602
|
+
onCloseWidget: h
|
|
567
603
|
}
|
|
568
604
|
),
|
|
569
605
|
/* @__PURE__ */ o(
|
|
570
606
|
Ge,
|
|
571
607
|
{
|
|
572
608
|
className: "bp-webchat-container",
|
|
573
|
-
uploadFile:
|
|
609
|
+
uploadFile: i,
|
|
574
610
|
allowFileUpload: t,
|
|
575
|
-
children:
|
|
611
|
+
children: m ? /* @__PURE__ */ o(ze, {}) : /* @__PURE__ */ l(Ue, { children: [
|
|
576
612
|
/* @__PURE__ */ o(
|
|
577
613
|
Ke,
|
|
578
614
|
{
|
|
@@ -582,7 +618,7 @@ function oo({
|
|
|
582
618
|
isTyping: r,
|
|
583
619
|
messages: s,
|
|
584
620
|
sendMessage: c,
|
|
585
|
-
addMessageFeedback:
|
|
621
|
+
addMessageFeedback: u,
|
|
586
622
|
renderers: n,
|
|
587
623
|
showDateSystemMessage: !1,
|
|
588
624
|
showMessageStatus: !1,
|
|
@@ -595,7 +631,7 @@ function oo({
|
|
|
595
631
|
{
|
|
596
632
|
connected: a !== "disconnected",
|
|
597
633
|
sendMessage: c,
|
|
598
|
-
uploadFile:
|
|
634
|
+
uploadFile: i,
|
|
599
635
|
allowFileUpload: t,
|
|
600
636
|
composerPlaceholder: e.placeholder,
|
|
601
637
|
disableSendButton: !1
|
|
@@ -606,7 +642,7 @@ function oo({
|
|
|
606
642
|
)
|
|
607
643
|
] });
|
|
608
644
|
}
|
|
609
|
-
function
|
|
645
|
+
function De({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
610
646
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-tabs bp-webchat-welcome-bottom", children: [
|
|
611
647
|
/* @__PURE__ */ l(
|
|
612
648
|
"button",
|
|
@@ -616,7 +652,7 @@ function He({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
|
616
652
|
type: "button",
|
|
617
653
|
onClick: t,
|
|
618
654
|
children: [
|
|
619
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children:
|
|
655
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: Le }),
|
|
620
656
|
/* @__PURE__ */ o("span", { children: "Início" })
|
|
621
657
|
]
|
|
622
658
|
}
|
|
@@ -636,7 +672,7 @@ function He({ activeView: e, onShowHome: t, onShowConversations: a }) {
|
|
|
636
672
|
)
|
|
637
673
|
] });
|
|
638
674
|
}
|
|
639
|
-
function
|
|
675
|
+
function ro({
|
|
640
676
|
conversations: e,
|
|
641
677
|
currentConversationId: t,
|
|
642
678
|
isLoading: a,
|
|
@@ -644,10 +680,10 @@ function ao({
|
|
|
644
680
|
botName: s,
|
|
645
681
|
onClose: n,
|
|
646
682
|
onCloseWidget: c,
|
|
647
|
-
onShowHome:
|
|
648
|
-
onShowConversations:
|
|
649
|
-
onNewConversation:
|
|
650
|
-
onConversationClick:
|
|
683
|
+
onShowHome: i,
|
|
684
|
+
onShowConversations: u,
|
|
685
|
+
onNewConversation: m,
|
|
686
|
+
onConversationClick: w
|
|
651
687
|
}) {
|
|
652
688
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-history", children: [
|
|
653
689
|
/* @__PURE__ */ l("div", { className: "bp-webchat-history-header", children: [
|
|
@@ -660,7 +696,7 @@ function ao({
|
|
|
660
696
|
type: "button",
|
|
661
697
|
onClick: n,
|
|
662
698
|
"aria-label": "Fechar conversas",
|
|
663
|
-
children:
|
|
699
|
+
children: we
|
|
664
700
|
}
|
|
665
701
|
),
|
|
666
702
|
c ? /* @__PURE__ */ o(
|
|
@@ -670,47 +706,47 @@ function ao({
|
|
|
670
706
|
type: "button",
|
|
671
707
|
onClick: c,
|
|
672
708
|
"aria-label": "Fechar webchat",
|
|
673
|
-
children:
|
|
709
|
+
children: we
|
|
674
710
|
}
|
|
675
711
|
) : null
|
|
676
712
|
] })
|
|
677
713
|
] }),
|
|
678
|
-
/* @__PURE__ */ o("div", { className: "bp-webchat-history-list", children: a ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-loading", children: "Carregando conversas..." }) : e.length === 0 ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-empty", children: "Nenhuma conversa iniciada ainda." }) : e.map((
|
|
679
|
-
const
|
|
714
|
+
/* @__PURE__ */ o("div", { className: "bp-webchat-history-list", children: a ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-loading", children: "Carregando conversas..." }) : e.length === 0 ? /* @__PURE__ */ o("div", { className: "bp-webchat-history-empty", children: "Nenhuma conversa iniciada ainda." }) : e.map((b) => {
|
|
715
|
+
const P = Xt(b.lastMessage), h = b.lastMessage?.author?.type === "bot";
|
|
680
716
|
return /* @__PURE__ */ l(
|
|
681
717
|
"button",
|
|
682
718
|
{
|
|
683
719
|
className: "bp-webchat-history-item",
|
|
684
720
|
type: "button",
|
|
685
|
-
onClick: () =>
|
|
686
|
-
"data-current":
|
|
721
|
+
onClick: () => w(b.id),
|
|
722
|
+
"data-current": b.id === t || void 0,
|
|
687
723
|
children: [
|
|
688
|
-
/* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind":
|
|
724
|
+
/* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": h ? "bot" : "user", children: h && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : h ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : Kt }),
|
|
689
725
|
/* @__PURE__ */ l("div", { className: "bp-webchat-history-content", children: [
|
|
690
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children:
|
|
691
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: Yt(
|
|
726
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: P }),
|
|
727
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: Yt(b.updatedAt) })
|
|
692
728
|
] }),
|
|
693
729
|
/* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: Wt })
|
|
694
730
|
]
|
|
695
731
|
},
|
|
696
|
-
|
|
732
|
+
b.id
|
|
697
733
|
);
|
|
698
734
|
}) }),
|
|
699
|
-
/* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick:
|
|
735
|
+
/* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick: m, children: [
|
|
700
736
|
Gt,
|
|
701
737
|
/* @__PURE__ */ o("span", { children: "Nova conversa" })
|
|
702
738
|
] }) }),
|
|
703
739
|
/* @__PURE__ */ o(
|
|
704
|
-
|
|
740
|
+
De,
|
|
705
741
|
{
|
|
706
742
|
activeView: "conversations",
|
|
707
|
-
onShowHome:
|
|
708
|
-
onShowConversations:
|
|
743
|
+
onShowHome: i,
|
|
744
|
+
onShowConversations: u
|
|
709
745
|
}
|
|
710
746
|
)
|
|
711
747
|
] });
|
|
712
748
|
}
|
|
713
|
-
function
|
|
749
|
+
function so({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
|
|
714
750
|
return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
|
|
715
751
|
/* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Nos ajude a melhorar" }),
|
|
716
752
|
/* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Conte o que não ficou bom nesta resposta." }),
|
|
@@ -737,7 +773,7 @@ function no({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
|
|
|
737
773
|
] })
|
|
738
774
|
] }) }) : null;
|
|
739
775
|
}
|
|
740
|
-
function
|
|
776
|
+
function co({ open: e, onConfirm: t, onCancel: a }) {
|
|
741
777
|
return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
|
|
742
778
|
/* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Criar nova conversa" }),
|
|
743
779
|
/* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Isso vai limpar a conversa atual e iniciar uma nova sessão com o bot." }),
|
|
@@ -755,7 +791,7 @@ function ro({ open: e, onConfirm: t, onCancel: a }) {
|
|
|
755
791
|
] })
|
|
756
792
|
] }) }) : null;
|
|
757
793
|
}
|
|
758
|
-
function
|
|
794
|
+
function lo({ config: e, activeView: t, onShowHome: a, onShowConversations: r, onStart: s, onClose: n }) {
|
|
759
795
|
const c = e.welcomeCardImage || e.botAvatar;
|
|
760
796
|
return /* @__PURE__ */ l("div", { className: "bp-webchat-welcome", children: [
|
|
761
797
|
/* @__PURE__ */ l("div", { className: "bp-webchat-welcome-hero", children: [
|
|
@@ -766,7 +802,7 @@ function so({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
766
802
|
type: "button",
|
|
767
803
|
onClick: n,
|
|
768
804
|
"aria-label": e.welcomeCloseLabel,
|
|
769
|
-
children:
|
|
805
|
+
children: we
|
|
770
806
|
}
|
|
771
807
|
),
|
|
772
808
|
e.welcomeCoverImage ? /* @__PURE__ */ o("img", { className: "bp-webchat-welcome-cover", src: e.welcomeCoverImage, alt: "" }) : null
|
|
@@ -785,7 +821,7 @@ function so({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
785
821
|
] })
|
|
786
822
|
] }) }),
|
|
787
823
|
/* @__PURE__ */ o(
|
|
788
|
-
|
|
824
|
+
De,
|
|
789
825
|
{
|
|
790
826
|
activeView: t,
|
|
791
827
|
onShowHome: a,
|
|
@@ -794,47 +830,47 @@ function so({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
|
|
|
794
830
|
)
|
|
795
831
|
] });
|
|
796
832
|
}
|
|
797
|
-
const
|
|
833
|
+
const io = 220, fe = "eduzz-webchat", Be = Object.freeze({
|
|
798
834
|
allowFileUpload: !1,
|
|
799
835
|
allowMessageFeedback: !1
|
|
800
|
-
}),
|
|
836
|
+
}), uo = "anonymous-id", bo = (e) => !!e && typeof e == "object" && !Array.isArray(e), qe = (e) => e.replace(/\/+$/, ""), Ie = ({ webchatProxyUrl: e }) => {
|
|
801
837
|
if (typeof e != "string" || !e.trim())
|
|
802
838
|
return null;
|
|
803
|
-
const t =
|
|
839
|
+
const t = qe(e.trim()), a = "/webchat/proxy";
|
|
804
840
|
return t.endsWith(a) ? t.slice(0, -a.length) : null;
|
|
805
|
-
},
|
|
841
|
+
}, ho = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, mo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
|
|
806
842
|
if (!e || !t)
|
|
807
843
|
return null;
|
|
808
|
-
const r =
|
|
844
|
+
const r = Ie({ webchatProxyUrl: e });
|
|
809
845
|
if (!r)
|
|
810
846
|
return null;
|
|
811
847
|
const s = new URLSearchParams();
|
|
812
848
|
typeof a == "string" && a.trim() && s.set("slug", a.trim());
|
|
813
849
|
const n = s.toString();
|
|
814
850
|
return `${r}/webchat/bootstrap/${encodeURIComponent(t)}${n ? `?${n}` : ""}`;
|
|
815
|
-
},
|
|
851
|
+
}, po = (e) => {
|
|
816
852
|
const t = e && typeof e == "object" && e.data && typeof e.data == "object" ? e.data : e;
|
|
817
853
|
return t && typeof t == "object" ? t : null;
|
|
818
|
-
},
|
|
854
|
+
}, Q = (e) => bo(e) ? e : null, wo = (e) => {
|
|
819
855
|
if (!e) return "";
|
|
820
856
|
try {
|
|
821
857
|
return JSON.stringify(e);
|
|
822
858
|
} catch {
|
|
823
859
|
return String(Date.now());
|
|
824
860
|
}
|
|
825
|
-
},
|
|
861
|
+
}, Oe = (e) => {
|
|
826
862
|
if (typeof window > "u") return null;
|
|
827
863
|
try {
|
|
828
864
|
return e === "sessionStorage" ? window.sessionStorage : window.localStorage;
|
|
829
865
|
} catch {
|
|
830
866
|
return null;
|
|
831
867
|
}
|
|
832
|
-
},
|
|
833
|
-
const a =
|
|
868
|
+
}, je = ({ storageKey: e, storageLocation: t }) => {
|
|
869
|
+
const a = Oe(t);
|
|
834
870
|
if (!a) return null;
|
|
835
871
|
try {
|
|
836
872
|
const r = a.getItem(
|
|
837
|
-
`${e ||
|
|
873
|
+
`${e || fe}-client`
|
|
838
874
|
);
|
|
839
875
|
if (!r) return null;
|
|
840
876
|
const s = JSON.parse(r), n = typeof s?.state == "string" ? JSON.parse(s.state) : s?.state ?? s;
|
|
@@ -842,10 +878,10 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
|
|
|
842
878
|
} catch {
|
|
843
879
|
return;
|
|
844
880
|
}
|
|
845
|
-
},
|
|
846
|
-
const a =
|
|
881
|
+
}, fo = ({ storageKey: e, storageLocation: t }) => {
|
|
882
|
+
const a = je({ storageKey: e, storageLocation: t });
|
|
847
883
|
return typeof a?.conversationId == "string" && a.conversationId.trim() || void 0;
|
|
848
|
-
},
|
|
884
|
+
}, Ae = () => {
|
|
849
885
|
try {
|
|
850
886
|
if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
|
|
851
887
|
return crypto.randomUUID();
|
|
@@ -859,19 +895,19 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
|
|
|
859
895
|
const t = Math.random() * 16 | 0;
|
|
860
896
|
return (e === "x" ? t : t & 3 | 8).toString(16);
|
|
861
897
|
});
|
|
862
|
-
},
|
|
863
|
-
const a =
|
|
898
|
+
}, go = (e) => `${e || fe}-${uo}`, yo = ({ storageKey: e, storageLocation: t }) => {
|
|
899
|
+
const a = Oe(t), r = go(e);
|
|
864
900
|
try {
|
|
865
901
|
const s = a?.getItem(r);
|
|
866
902
|
if (s)
|
|
867
903
|
return s;
|
|
868
|
-
const n = `anon_${
|
|
904
|
+
const n = `anon_${Ae()}`;
|
|
869
905
|
return a?.setItem(r, n), n;
|
|
870
906
|
} catch {
|
|
871
|
-
return `anon_${
|
|
907
|
+
return `anon_${Ae()}`;
|
|
872
908
|
}
|
|
873
|
-
},
|
|
874
|
-
const r =
|
|
909
|
+
}, vo = async ({ webchatProxyUrl: e, clientId: t, accountId: a }) => {
|
|
910
|
+
const r = Ie({ webchatProxyUrl: e });
|
|
875
911
|
if (!r)
|
|
876
912
|
throw new Error("public session request requires a valid webchatProxyUrl");
|
|
877
913
|
const s = await fetch(
|
|
@@ -895,11 +931,11 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
|
|
|
895
931
|
userId: c.userId,
|
|
896
932
|
userToken: c.userToken
|
|
897
933
|
};
|
|
898
|
-
},
|
|
934
|
+
}, Co = (e) => ({
|
|
899
935
|
...typeof e.name == "string" && e.name.trim() ? { name: e.name.trim() } : {},
|
|
900
936
|
...typeof e.pictureUrl == "string" && e.pictureUrl.trim() ? { pictureUrl: e.pictureUrl.trim() } : {},
|
|
901
937
|
userData: e
|
|
902
|
-
}),
|
|
938
|
+
}), Bo = ({
|
|
903
939
|
showWelcomeScreen: e,
|
|
904
940
|
storageKey: t,
|
|
905
941
|
storageLocation: a,
|
|
@@ -910,14 +946,14 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
|
|
|
910
946
|
return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
|
|
911
947
|
if (r && s)
|
|
912
948
|
return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
|
|
913
|
-
const n =
|
|
949
|
+
const n = je({ storageKey: t, storageLocation: a });
|
|
914
950
|
if (n == null)
|
|
915
951
|
return { activeView: "home", historyReturnView: "home", bootstrapView: "home" };
|
|
916
952
|
if (n === void 0)
|
|
917
953
|
return { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
|
|
918
|
-
const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "",
|
|
919
|
-
return c &&
|
|
920
|
-
},
|
|
954
|
+
const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "", i = typeof n.user?.userToken == "string" ? n.user.userToken.trim() : "";
|
|
955
|
+
return c && i ? { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" } : !c && !i ? { activeView: "home", historyReturnView: "home", bootstrapView: "home" } : { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
|
|
956
|
+
}, ko = (e, t) => {
|
|
921
957
|
switch (t.type) {
|
|
922
958
|
case "show":
|
|
923
959
|
return { isPanelMounted: !0, isPanelVisible: e.isPanelVisible };
|
|
@@ -931,7 +967,7 @@ const co = 220, ie = "eduzz-webchat", be = Object.freeze({
|
|
|
931
967
|
return e;
|
|
932
968
|
}
|
|
933
969
|
};
|
|
934
|
-
function
|
|
970
|
+
function So({
|
|
935
971
|
clientId: e,
|
|
936
972
|
webchatProxyUrl: t,
|
|
937
973
|
userCredentials: a,
|
|
@@ -939,199 +975,206 @@ function Io({
|
|
|
939
975
|
config: s,
|
|
940
976
|
defaultUserData: n,
|
|
941
977
|
presetSlug: c,
|
|
942
|
-
storageKey:
|
|
943
|
-
storageLocation:
|
|
944
|
-
defaultOpen:
|
|
945
|
-
onUserApiChange:
|
|
978
|
+
storageKey: i = fe,
|
|
979
|
+
storageLocation: u = "localStorage",
|
|
980
|
+
defaultOpen: m,
|
|
981
|
+
onUserApiChange: w,
|
|
982
|
+
getSession: b,
|
|
983
|
+
sessionKey: P,
|
|
984
|
+
onSessionChange: h
|
|
946
985
|
}) {
|
|
947
|
-
const
|
|
986
|
+
const { session: x, resolving: z } = oo({
|
|
987
|
+
getSession: b,
|
|
988
|
+
sessionKey: P,
|
|
989
|
+
onSessionChange: h
|
|
990
|
+
}), ee = !!x && Date.now() < x.expiresAt, le = ee ? { userId: x.userId, userToken: x.userToken } : void 0, q = b ? le : a, te = ee ? x.conversationId : void 0, oe = y(
|
|
948
991
|
() => typeof c == "string" && c.trim() ? c.trim() : void 0,
|
|
949
992
|
[c]
|
|
950
|
-
),
|
|
951
|
-
() => typeof t == "string" && t.trim() ?
|
|
993
|
+
), N = y(
|
|
994
|
+
() => typeof t == "string" && t.trim() ? qe(t.trim()) : void 0,
|
|
952
995
|
[t]
|
|
953
996
|
);
|
|
954
|
-
|
|
955
|
-
() =>
|
|
956
|
-
[
|
|
997
|
+
y(
|
|
998
|
+
() => N ? Ie({ webchatProxyUrl: N }) : null,
|
|
999
|
+
[N]
|
|
957
1000
|
);
|
|
958
|
-
const
|
|
959
|
-
() =>
|
|
960
|
-
webchatProxyUrl:
|
|
1001
|
+
const O = !!(e && N && (oe || !q)), T = y(
|
|
1002
|
+
() => O ? mo({
|
|
1003
|
+
webchatProxyUrl: N,
|
|
961
1004
|
clientId: e,
|
|
962
|
-
presetSlug:
|
|
1005
|
+
presetSlug: oe
|
|
963
1006
|
}) : null,
|
|
964
|
-
[e,
|
|
965
|
-
), [
|
|
1007
|
+
[e, oe, N, O]
|
|
1008
|
+
), [D, K] = R({
|
|
966
1009
|
error: null,
|
|
967
1010
|
isLoading: !1,
|
|
968
1011
|
payload: null,
|
|
969
1012
|
url: null
|
|
970
1013
|
});
|
|
971
|
-
|
|
972
|
-
if (!
|
|
973
|
-
|
|
1014
|
+
M(() => {
|
|
1015
|
+
if (!T) {
|
|
1016
|
+
K({ error: null, isLoading: !1, payload: null, url: null });
|
|
974
1017
|
return;
|
|
975
1018
|
}
|
|
976
|
-
const
|
|
977
|
-
return
|
|
1019
|
+
const v = new AbortController();
|
|
1020
|
+
return K({ error: null, isLoading: !0, payload: null, url: T }), fetch(T, {
|
|
978
1021
|
headers: {
|
|
979
1022
|
accept: "application/json"
|
|
980
1023
|
},
|
|
981
|
-
signal:
|
|
982
|
-
}).then(async (
|
|
983
|
-
if (!
|
|
984
|
-
throw new Error(`bootstrap request failed with status ${
|
|
985
|
-
return
|
|
986
|
-
}).then((
|
|
987
|
-
const
|
|
988
|
-
if (!
|
|
1024
|
+
signal: v.signal
|
|
1025
|
+
}).then(async (g) => {
|
|
1026
|
+
if (!g.ok)
|
|
1027
|
+
throw new Error(`bootstrap request failed with status ${g.status}`);
|
|
1028
|
+
return g.json();
|
|
1029
|
+
}).then((g) => {
|
|
1030
|
+
const U = po(g);
|
|
1031
|
+
if (!U)
|
|
989
1032
|
throw new Error("bootstrap response is invalid");
|
|
990
|
-
|
|
1033
|
+
K({
|
|
991
1034
|
error: null,
|
|
992
1035
|
isLoading: !1,
|
|
993
|
-
payload:
|
|
994
|
-
url:
|
|
1036
|
+
payload: U,
|
|
1037
|
+
url: T
|
|
995
1038
|
});
|
|
996
|
-
}).catch((
|
|
997
|
-
|
|
998
|
-
}), () =>
|
|
999
|
-
}, [
|
|
1000
|
-
const
|
|
1039
|
+
}).catch((g) => {
|
|
1040
|
+
v.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", g), K({ error: g, isLoading: !1, payload: null, url: T }));
|
|
1041
|
+
}), () => v.abort();
|
|
1042
|
+
}, [T]);
|
|
1043
|
+
const f = T && D.url === T ? D.payload : null, ie = T && D.url === T ? D.error : null, k = f?.clientId || e, A = N || f?.webchatProxyUrl || void 0, H = i === fe && f?.storageKey ? f.storageKey : i, j = typeof m == "boolean" ? m : typeof f?.defaultOpen == "boolean" ? f.defaultOpen : m, I = y(
|
|
1001
1044
|
() => ({
|
|
1002
|
-
...
|
|
1003
|
-
...
|
|
1045
|
+
...Q(f?.config) || {},
|
|
1046
|
+
...Q(s) || {}
|
|
1004
1047
|
}),
|
|
1005
|
-
[
|
|
1006
|
-
),
|
|
1048
|
+
[f, s]
|
|
1049
|
+
), ge = y(
|
|
1007
1050
|
() => {
|
|
1008
|
-
const
|
|
1009
|
-
...
|
|
1010
|
-
...
|
|
1051
|
+
const v = {
|
|
1052
|
+
...Q(f?.defaultUserData) || {},
|
|
1053
|
+
...Q(n) || {}
|
|
1011
1054
|
};
|
|
1012
|
-
return Object.keys(
|
|
1055
|
+
return Object.keys(v).length > 0 ? v : null;
|
|
1013
1056
|
},
|
|
1014
|
-
[n,
|
|
1015
|
-
),
|
|
1057
|
+
[n, f]
|
|
1058
|
+
), $ = !!(!q && !z && f?.sessionMode === "service-hub" && A && k), [ae, J] = R({
|
|
1016
1059
|
error: null,
|
|
1017
1060
|
isLoading: !1,
|
|
1018
1061
|
payload: null,
|
|
1019
1062
|
key: null
|
|
1020
1063
|
});
|
|
1021
|
-
|
|
1022
|
-
if (
|
|
1023
|
-
|
|
1064
|
+
M(() => {
|
|
1065
|
+
if (!$) {
|
|
1066
|
+
J({ error: null, isLoading: !1, payload: null, key: null });
|
|
1024
1067
|
return;
|
|
1025
1068
|
}
|
|
1026
|
-
const
|
|
1027
|
-
storageKey:
|
|
1028
|
-
storageLocation:
|
|
1029
|
-
}),
|
|
1030
|
-
let
|
|
1031
|
-
return
|
|
1069
|
+
const v = yo({
|
|
1070
|
+
storageKey: H,
|
|
1071
|
+
storageLocation: u
|
|
1072
|
+
}), g = `${k}:${A}:${v}`;
|
|
1073
|
+
let U = !1;
|
|
1074
|
+
return J({
|
|
1032
1075
|
error: null,
|
|
1033
1076
|
isLoading: !0,
|
|
1034
1077
|
payload: null,
|
|
1035
|
-
key:
|
|
1036
|
-
}),
|
|
1037
|
-
webchatProxyUrl:
|
|
1038
|
-
clientId:
|
|
1039
|
-
accountId:
|
|
1040
|
-
}).then((
|
|
1041
|
-
|
|
1078
|
+
key: g
|
|
1079
|
+
}), vo({
|
|
1080
|
+
webchatProxyUrl: A,
|
|
1081
|
+
clientId: k,
|
|
1082
|
+
accountId: v
|
|
1083
|
+
}).then((p) => {
|
|
1084
|
+
U || J({
|
|
1042
1085
|
error: null,
|
|
1043
1086
|
isLoading: !1,
|
|
1044
|
-
payload:
|
|
1045
|
-
key:
|
|
1087
|
+
payload: p,
|
|
1088
|
+
key: g
|
|
1046
1089
|
});
|
|
1047
|
-
}).catch((
|
|
1048
|
-
|
|
1049
|
-
error:
|
|
1090
|
+
}).catch((p) => {
|
|
1091
|
+
U || (console.warn("[EduzzWebchat] failed to open public session", p), J({
|
|
1092
|
+
error: p,
|
|
1050
1093
|
isLoading: !1,
|
|
1051
1094
|
payload: null,
|
|
1052
|
-
key:
|
|
1095
|
+
key: g
|
|
1053
1096
|
}));
|
|
1054
1097
|
}), () => {
|
|
1055
|
-
|
|
1098
|
+
U = !0;
|
|
1056
1099
|
};
|
|
1057
1100
|
}, [
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1101
|
+
k,
|
|
1102
|
+
H,
|
|
1103
|
+
A,
|
|
1104
|
+
$,
|
|
1105
|
+
u
|
|
1063
1106
|
]);
|
|
1064
|
-
const
|
|
1065
|
-
() => r ||
|
|
1066
|
-
storageKey:
|
|
1067
|
-
storageLocation:
|
|
1107
|
+
const E = $ ? ae.payload : null, X = q || E, _ = y(() => lt(I), [I]), Z = y(
|
|
1108
|
+
() => te || r || fo({
|
|
1109
|
+
storageKey: H,
|
|
1110
|
+
storageLocation: u
|
|
1068
1111
|
}),
|
|
1069
|
-
[r,
|
|
1070
|
-
),
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
}, [
|
|
1074
|
-
const
|
|
1075
|
-
return
|
|
1076
|
-
const
|
|
1077
|
-
webchatProxyUrl:
|
|
1078
|
-
clientId:
|
|
1112
|
+
[te, r, H, u]
|
|
1113
|
+
), V = j ?? _.initiallyOpen ?? !0, [ye, W] = R(V), ne = ce(V), [L, Y] = R(Be), ve = re(() => W((v) => !v), []);
|
|
1114
|
+
M(() => {
|
|
1115
|
+
ne.current !== V && (ne.current = V, W(V));
|
|
1116
|
+
}, [V]);
|
|
1117
|
+
const de = O && !f && !ie, Ce = $ && !E && !ae.error;
|
|
1118
|
+
return M(() => {
|
|
1119
|
+
const v = ho({
|
|
1120
|
+
webchatProxyUrl: A,
|
|
1121
|
+
clientId: k
|
|
1079
1122
|
});
|
|
1080
|
-
if (
|
|
1123
|
+
if (Y(Be), !v)
|
|
1081
1124
|
return;
|
|
1082
|
-
const
|
|
1083
|
-
let
|
|
1084
|
-
return fetch(
|
|
1125
|
+
const g = new AbortController();
|
|
1126
|
+
let U = !1;
|
|
1127
|
+
return fetch(v, {
|
|
1085
1128
|
headers: {
|
|
1086
1129
|
accept: "application/json"
|
|
1087
1130
|
},
|
|
1088
|
-
signal:
|
|
1089
|
-
}).then(async (
|
|
1090
|
-
if (!
|
|
1091
|
-
throw new Error(`runtime config request failed with status ${
|
|
1092
|
-
return
|
|
1093
|
-
}).then((
|
|
1094
|
-
if (
|
|
1131
|
+
signal: g.signal
|
|
1132
|
+
}).then(async (p) => {
|
|
1133
|
+
if (!p.ok)
|
|
1134
|
+
throw new Error(`runtime config request failed with status ${p.status}`);
|
|
1135
|
+
return p.json();
|
|
1136
|
+
}).then((p) => {
|
|
1137
|
+
if (U)
|
|
1095
1138
|
return;
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1098
|
-
allowFileUpload:
|
|
1099
|
-
allowMessageFeedback:
|
|
1139
|
+
const ue = p && typeof p == "object" && p.data && typeof p.data == "object" ? p.data : {};
|
|
1140
|
+
Y({
|
|
1141
|
+
allowFileUpload: ue.allowFileUpload === !0,
|
|
1142
|
+
allowMessageFeedback: ue.allowMessageFeedback === !0
|
|
1100
1143
|
});
|
|
1101
|
-
}).catch((
|
|
1102
|
-
|
|
1144
|
+
}).catch((p) => {
|
|
1145
|
+
g.signal.aborted || U || (console.warn("[EduzzWebchat] failed to load runtime config", p), Y(Be));
|
|
1103
1146
|
}), () => {
|
|
1104
|
-
|
|
1147
|
+
U = !0, g.abort();
|
|
1105
1148
|
};
|
|
1106
|
-
}, [
|
|
1107
|
-
|
|
1149
|
+
}, [k, A]), de || Ce || b && z ? null : ie && !f ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: se(_), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : ae.error && !E ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: se(_), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : A ? k ? /* @__PURE__ */ o(
|
|
1150
|
+
Xe,
|
|
1108
1151
|
{
|
|
1109
|
-
clientId:
|
|
1110
|
-
apiUrl:
|
|
1111
|
-
conversationId:
|
|
1112
|
-
userCredentials:
|
|
1113
|
-
storageKey:
|
|
1114
|
-
storageLocation:
|
|
1152
|
+
clientId: k,
|
|
1153
|
+
apiUrl: A,
|
|
1154
|
+
conversationId: Z,
|
|
1155
|
+
userCredentials: X,
|
|
1156
|
+
storageKey: H,
|
|
1157
|
+
storageLocation: u,
|
|
1115
1158
|
children: /* @__PURE__ */ o(
|
|
1116
|
-
|
|
1159
|
+
xo,
|
|
1117
1160
|
{
|
|
1118
|
-
clientId:
|
|
1119
|
-
config:
|
|
1120
|
-
defaultUserData:
|
|
1121
|
-
conversationIdProp:
|
|
1122
|
-
isOpen:
|
|
1123
|
-
onUserApiChange:
|
|
1124
|
-
onToggle:
|
|
1125
|
-
runtimeCapabilities:
|
|
1126
|
-
storageKey:
|
|
1127
|
-
storageLocation:
|
|
1128
|
-
userToken:
|
|
1161
|
+
clientId: k,
|
|
1162
|
+
config: _,
|
|
1163
|
+
defaultUserData: ge,
|
|
1164
|
+
conversationIdProp: Z,
|
|
1165
|
+
isOpen: ye,
|
|
1166
|
+
onUserApiChange: w,
|
|
1167
|
+
onToggle: ve,
|
|
1168
|
+
runtimeCapabilities: L,
|
|
1169
|
+
storageKey: H,
|
|
1170
|
+
storageLocation: u,
|
|
1171
|
+
userToken: X?.userToken
|
|
1129
1172
|
}
|
|
1130
1173
|
)
|
|
1131
1174
|
}
|
|
1132
|
-
) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style:
|
|
1175
|
+
) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: se(_), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: se(_), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
|
|
1133
1176
|
}
|
|
1134
|
-
function
|
|
1177
|
+
function xo({
|
|
1135
1178
|
clientId: e,
|
|
1136
1179
|
config: t,
|
|
1137
1180
|
defaultUserData: a,
|
|
@@ -1139,166 +1182,166 @@ function Bo({
|
|
|
1139
1182
|
isOpen: s,
|
|
1140
1183
|
onUserApiChange: n,
|
|
1141
1184
|
onToggle: c,
|
|
1142
|
-
runtimeCapabilities:
|
|
1143
|
-
storageKey:
|
|
1144
|
-
storageLocation:
|
|
1145
|
-
userToken:
|
|
1185
|
+
runtimeCapabilities: i,
|
|
1186
|
+
storageKey: u,
|
|
1187
|
+
storageLocation: m,
|
|
1188
|
+
userToken: w
|
|
1146
1189
|
}) {
|
|
1147
|
-
const
|
|
1148
|
-
() =>
|
|
1190
|
+
const b = y(
|
|
1191
|
+
() => Bo({
|
|
1149
1192
|
showWelcomeScreen: t.showWelcomeScreen,
|
|
1150
|
-
storageKey:
|
|
1151
|
-
storageLocation:
|
|
1193
|
+
storageKey: u,
|
|
1194
|
+
storageLocation: m,
|
|
1152
1195
|
conversationId: r,
|
|
1153
|
-
userToken:
|
|
1196
|
+
userToken: w
|
|
1154
1197
|
}),
|
|
1155
1198
|
[
|
|
1156
1199
|
t.showWelcomeScreen,
|
|
1157
1200
|
r,
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1201
|
+
u,
|
|
1202
|
+
m,
|
|
1203
|
+
w
|
|
1161
1204
|
]
|
|
1162
|
-
), [
|
|
1205
|
+
), [P, h] = R(!1), [x, z] = R({ open: !1, messageId: null, draft: "" }), [{ isPanelMounted: ee, isPanelVisible: le }, q] = We(ko, {
|
|
1163
1206
|
isPanelMounted: s,
|
|
1164
1207
|
isPanelVisible: s
|
|
1165
1208
|
}), {
|
|
1166
|
-
conversationId:
|
|
1167
|
-
isTyping:
|
|
1168
|
-
messages:
|
|
1169
|
-
saveMessageFeedback:
|
|
1170
|
-
sendMessage:
|
|
1171
|
-
status:
|
|
1172
|
-
uploadFile:
|
|
1173
|
-
} =
|
|
1174
|
-
userCredentials:
|
|
1175
|
-
listConversations:
|
|
1209
|
+
conversationId: te,
|
|
1210
|
+
isTyping: oe,
|
|
1211
|
+
messages: N,
|
|
1212
|
+
saveMessageFeedback: O,
|
|
1213
|
+
sendMessage: T,
|
|
1214
|
+
status: D,
|
|
1215
|
+
uploadFile: K
|
|
1216
|
+
} = Ze(), { openConversation: f, listConversations: ie } = Ye(), { updateUser: k, userCredentials: A } = Qe(), H = ce({}), [j, I] = R(() => b.activeView), [ge, $] = R(() => b.historyReturnView), { conversations: ae, isLoading: J, refresh: E } = et({
|
|
1217
|
+
userCredentials: A,
|
|
1218
|
+
listConversations: ie,
|
|
1176
1219
|
clientId: e
|
|
1177
|
-
}), X =
|
|
1178
|
-
() =>
|
|
1220
|
+
}), X = y(
|
|
1221
|
+
() => wo(a),
|
|
1179
1222
|
[a]
|
|
1180
|
-
),
|
|
1223
|
+
), _ = re(
|
|
1181
1224
|
async (C = {}) => {
|
|
1182
|
-
if (!
|
|
1225
|
+
if (!k)
|
|
1183
1226
|
return;
|
|
1184
|
-
const
|
|
1185
|
-
...
|
|
1227
|
+
const d = {
|
|
1228
|
+
...Q(a) || {},
|
|
1186
1229
|
...H.current,
|
|
1187
|
-
...
|
|
1230
|
+
...Q(C) || {}
|
|
1188
1231
|
};
|
|
1189
|
-
return H.current =
|
|
1232
|
+
return H.current = d, k(Co(d));
|
|
1190
1233
|
},
|
|
1191
|
-
[a,
|
|
1192
|
-
),
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
}, [
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1234
|
+
[a, k]
|
|
1235
|
+
), Z = ce(_);
|
|
1236
|
+
M(() => {
|
|
1237
|
+
Z.current = _;
|
|
1238
|
+
}, [_]);
|
|
1239
|
+
const V = !!k;
|
|
1240
|
+
M(() => {
|
|
1198
1241
|
H.current = {};
|
|
1199
|
-
}, [X]),
|
|
1242
|
+
}, [X]), M(() => {
|
|
1200
1243
|
if (n)
|
|
1201
1244
|
return n({
|
|
1202
|
-
updateUserData:
|
|
1245
|
+
updateUserData: V ? (C) => Z.current(C) : void 0
|
|
1203
1246
|
}), () => n(null);
|
|
1204
|
-
}, [n,
|
|
1205
|
-
!
|
|
1206
|
-
}, [X,
|
|
1207
|
-
|
|
1208
|
-
}, [
|
|
1209
|
-
const { showInitialLoading:
|
|
1210
|
-
activeView:
|
|
1211
|
-
clientState:
|
|
1212
|
-
conversationId:
|
|
1213
|
-
messagesLength:
|
|
1214
|
-
}),
|
|
1247
|
+
}, [n, V]), M(() => {
|
|
1248
|
+
!V || !X || Z.current();
|
|
1249
|
+
}, [X, V]), M(() => {
|
|
1250
|
+
i.allowMessageFeedback || z({ open: !1, messageId: null, draft: "" });
|
|
1251
|
+
}, [i.allowMessageFeedback]);
|
|
1252
|
+
const { showInitialLoading: ye, setShowInitialLoading: W } = eo({
|
|
1253
|
+
activeView: j,
|
|
1254
|
+
clientState: D,
|
|
1255
|
+
conversationId: te,
|
|
1256
|
+
messagesLength: N.length
|
|
1257
|
+
}), ne = y(
|
|
1215
1258
|
() => t.botAvatar || Jt({ name: t.botName, backgroundColor: t.accentColor }),
|
|
1216
1259
|
[t.accentColor, t.botAvatar, t.botName]
|
|
1217
|
-
),
|
|
1218
|
-
() => ({ ...t, botAvatar:
|
|
1219
|
-
[t,
|
|
1220
|
-
),
|
|
1260
|
+
), L = y(
|
|
1261
|
+
() => ({ ...t, botAvatar: ne }),
|
|
1262
|
+
[t, ne]
|
|
1263
|
+
), Y = re(
|
|
1221
1264
|
async (C) => {
|
|
1222
|
-
|
|
1265
|
+
$(C), I("conversations"), await E();
|
|
1223
1266
|
},
|
|
1224
|
-
[
|
|
1225
|
-
),
|
|
1267
|
+
[E]
|
|
1268
|
+
), ve = re(
|
|
1226
1269
|
(C) => {
|
|
1227
|
-
|
|
1270
|
+
W(!0), f(C), I("chat");
|
|
1228
1271
|
},
|
|
1229
|
-
[
|
|
1230
|
-
),
|
|
1231
|
-
|
|
1232
|
-
}, [
|
|
1272
|
+
[f, W]
|
|
1273
|
+
), de = re(() => {
|
|
1274
|
+
W(!0), f(), I("chat");
|
|
1275
|
+
}, [f, W]), Ce = y(
|
|
1233
1276
|
() => Qt({
|
|
1234
|
-
messages:
|
|
1235
|
-
user:
|
|
1236
|
-
botName:
|
|
1237
|
-
botAvatar:
|
|
1277
|
+
messages: N,
|
|
1278
|
+
user: A,
|
|
1279
|
+
botName: L.botName,
|
|
1280
|
+
botAvatar: L.botAvatar
|
|
1238
1281
|
}),
|
|
1239
|
-
[
|
|
1240
|
-
),
|
|
1241
|
-
|
|
1282
|
+
[N, L.botAvatar, L.botName, A]
|
|
1283
|
+
), v = se(t), g = y(() => it(t), [t]), U = y(() => zt(t.fabChatIconVariant), [t.fabChatIconVariant]);
|
|
1284
|
+
M(() => {
|
|
1242
1285
|
if (s) {
|
|
1243
1286
|
q({ type: "show" });
|
|
1244
|
-
const
|
|
1245
|
-
return () => window.cancelAnimationFrame(
|
|
1287
|
+
const be = window.requestAnimationFrame(() => q({ type: "visible" }));
|
|
1288
|
+
return () => window.cancelAnimationFrame(be);
|
|
1246
1289
|
}
|
|
1247
1290
|
q({ type: "hide" });
|
|
1248
1291
|
const C = window.setTimeout(() => {
|
|
1249
|
-
|
|
1250
|
-
}, 0),
|
|
1292
|
+
h(!1), z({ open: !1, messageId: null, draft: "" });
|
|
1293
|
+
}, 0), d = window.setTimeout(() => q({ type: "unmount" }), io);
|
|
1251
1294
|
return () => {
|
|
1252
|
-
window.clearTimeout(C), window.clearTimeout(
|
|
1295
|
+
window.clearTimeout(C), window.clearTimeout(d);
|
|
1253
1296
|
};
|
|
1254
|
-
}, [s]),
|
|
1255
|
-
if (
|
|
1256
|
-
if (
|
|
1297
|
+
}, [s]), M(() => {
|
|
1298
|
+
if (b.bootstrapView === "pending") {
|
|
1299
|
+
if (N.length > 0) {
|
|
1257
1300
|
const C = window.setTimeout(() => {
|
|
1258
|
-
|
|
1301
|
+
I("chat"), $("chat");
|
|
1259
1302
|
}, 0);
|
|
1260
1303
|
return () => window.clearTimeout(C);
|
|
1261
1304
|
}
|
|
1262
|
-
if (
|
|
1305
|
+
if (D !== "connecting") {
|
|
1263
1306
|
const C = window.setTimeout(() => {
|
|
1264
|
-
|
|
1307
|
+
I("home"), $("home");
|
|
1265
1308
|
}, 0);
|
|
1266
1309
|
return () => window.clearTimeout(C);
|
|
1267
1310
|
}
|
|
1268
1311
|
}
|
|
1269
|
-
}, [
|
|
1270
|
-
const
|
|
1271
|
-
() => function(
|
|
1272
|
-
const
|
|
1273
|
-
...
|
|
1274
|
-
direction:
|
|
1275
|
-
sender:
|
|
1276
|
-
timestamp:
|
|
1277
|
-
messageId:
|
|
1278
|
-
metadata:
|
|
1279
|
-
isReadOnly:
|
|
1280
|
-
status:
|
|
1281
|
-
feedback:
|
|
1282
|
-
sendMessage:
|
|
1283
|
-
addMessageFeedback:
|
|
1312
|
+
}, [D, b.bootstrapView, N.length]);
|
|
1313
|
+
const p = y(
|
|
1314
|
+
() => function(d) {
|
|
1315
|
+
const be = i.allowMessageFeedback && d.direction === "incoming" && typeof d.addMessageFeedback == "function", Ee = {
|
|
1316
|
+
...d.block,
|
|
1317
|
+
direction: d.direction,
|
|
1318
|
+
sender: d.sender,
|
|
1319
|
+
timestamp: d.timestamp,
|
|
1320
|
+
messageId: d.messageId,
|
|
1321
|
+
metadata: d.metadata,
|
|
1322
|
+
isReadOnly: d.isReadOnly,
|
|
1323
|
+
status: d.status,
|
|
1324
|
+
feedback: d.feedback,
|
|
1325
|
+
sendMessage: d.sendMessage,
|
|
1326
|
+
addMessageFeedback: d.addMessageFeedback
|
|
1284
1327
|
};
|
|
1285
1328
|
return /* @__PURE__ */ l(
|
|
1286
1329
|
"div",
|
|
1287
1330
|
{
|
|
1288
1331
|
className: "bpMessageBlocksBubble",
|
|
1289
|
-
"data-direction":
|
|
1290
|
-
"data-feedback":
|
|
1332
|
+
"data-direction": d.direction,
|
|
1333
|
+
"data-feedback": be || void 0,
|
|
1291
1334
|
children: [
|
|
1292
1335
|
/* @__PURE__ */ o(tt, { block: Ee }),
|
|
1293
|
-
|
|
1336
|
+
be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
|
|
1294
1337
|
/* @__PURE__ */ o(
|
|
1295
1338
|
"button",
|
|
1296
1339
|
{
|
|
1297
1340
|
className: "bpMessageBlocksBubbleFeedbackIcon",
|
|
1298
1341
|
type: "button",
|
|
1299
|
-
"data-selected":
|
|
1342
|
+
"data-selected": d.feedback === "positive",
|
|
1300
1343
|
"aria-label": "Feedback positivo",
|
|
1301
|
-
onClick: () =>
|
|
1344
|
+
onClick: () => d.addMessageFeedback(d.messageId, { value: "positive" }),
|
|
1302
1345
|
children: Ot
|
|
1303
1346
|
}
|
|
1304
1347
|
),
|
|
@@ -1307,11 +1350,11 @@ function Bo({
|
|
|
1307
1350
|
{
|
|
1308
1351
|
className: "bpMessageBlocksBubbleFeedbackIcon",
|
|
1309
1352
|
type: "button",
|
|
1310
|
-
"data-selected":
|
|
1353
|
+
"data-selected": d.feedback === "negative",
|
|
1311
1354
|
"aria-label": "Feedback negativo",
|
|
1312
|
-
onClick: () =>
|
|
1355
|
+
onClick: () => z({
|
|
1313
1356
|
open: !0,
|
|
1314
|
-
messageId:
|
|
1357
|
+
messageId: d.messageId,
|
|
1315
1358
|
draft: ""
|
|
1316
1359
|
}),
|
|
1317
1360
|
children: jt
|
|
@@ -1322,88 +1365,88 @@ function Bo({
|
|
|
1322
1365
|
}
|
|
1323
1366
|
);
|
|
1324
1367
|
},
|
|
1325
|
-
[
|
|
1326
|
-
),
|
|
1368
|
+
[i.allowMessageFeedback]
|
|
1369
|
+
), ue = y(() => ({ bubble: p }), [p]);
|
|
1327
1370
|
return /* @__PURE__ */ l(
|
|
1328
1371
|
"div",
|
|
1329
1372
|
{
|
|
1330
1373
|
className: "bp-webchat-shell",
|
|
1331
|
-
"data-panel-mounted":
|
|
1332
|
-
"data-panel-open":
|
|
1333
|
-
style:
|
|
1374
|
+
"data-panel-mounted": ee,
|
|
1375
|
+
"data-panel-open": le,
|
|
1376
|
+
style: v,
|
|
1334
1377
|
children: [
|
|
1335
|
-
/* @__PURE__ */ o(ot, { ...
|
|
1336
|
-
|
|
1337
|
-
|
|
1378
|
+
/* @__PURE__ */ o(ot, { ...g }),
|
|
1379
|
+
ee ? /* @__PURE__ */ o("div", { className: "bp-webchat-panel", "data-state": le ? "open" : "closed", children: j === "home" ? /* @__PURE__ */ o(
|
|
1380
|
+
lo,
|
|
1338
1381
|
{
|
|
1339
|
-
config:
|
|
1340
|
-
activeView:
|
|
1382
|
+
config: L,
|
|
1383
|
+
activeView: j,
|
|
1341
1384
|
onClose: c,
|
|
1342
|
-
onShowHome: () =>
|
|
1343
|
-
onShowConversations: () =>
|
|
1344
|
-
onStart: () =>
|
|
1385
|
+
onShowHome: () => I("home"),
|
|
1386
|
+
onShowConversations: () => Y("home"),
|
|
1387
|
+
onStart: () => I("chat")
|
|
1345
1388
|
}
|
|
1346
|
-
) :
|
|
1347
|
-
|
|
1389
|
+
) : j === "conversations" ? /* @__PURE__ */ o(
|
|
1390
|
+
ro,
|
|
1348
1391
|
{
|
|
1349
1392
|
conversations: ae,
|
|
1350
|
-
currentConversationId:
|
|
1351
|
-
isLoading:
|
|
1352
|
-
botAvatar:
|
|
1353
|
-
botName:
|
|
1354
|
-
onClose: () =>
|
|
1393
|
+
currentConversationId: te,
|
|
1394
|
+
isLoading: J,
|
|
1395
|
+
botAvatar: L.botAvatar,
|
|
1396
|
+
botName: L.botName,
|
|
1397
|
+
onClose: () => I(ge),
|
|
1355
1398
|
onCloseWidget: c,
|
|
1356
1399
|
onShowHome: () => {
|
|
1357
|
-
|
|
1400
|
+
I("home"), $("home");
|
|
1358
1401
|
},
|
|
1359
|
-
onShowConversations:
|
|
1360
|
-
onNewConversation:
|
|
1361
|
-
onConversationClick:
|
|
1402
|
+
onShowConversations: E,
|
|
1403
|
+
onNewConversation: de,
|
|
1404
|
+
onConversationClick: ve
|
|
1362
1405
|
}
|
|
1363
|
-
) :
|
|
1406
|
+
) : j === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(ze, {}) }) : /* @__PURE__ */ l(Ue, { children: [
|
|
1364
1407
|
/* @__PURE__ */ o(
|
|
1365
|
-
|
|
1408
|
+
no,
|
|
1366
1409
|
{
|
|
1367
|
-
config:
|
|
1368
|
-
allowFileUpload:
|
|
1369
|
-
clientState:
|
|
1370
|
-
isTyping:
|
|
1371
|
-
messages:
|
|
1372
|
-
renderers:
|
|
1373
|
-
sendMessage:
|
|
1374
|
-
uploadFile:
|
|
1375
|
-
addMessageFeedback:
|
|
1376
|
-
showInitialLoading:
|
|
1410
|
+
config: L,
|
|
1411
|
+
allowFileUpload: i.allowFileUpload,
|
|
1412
|
+
clientState: D,
|
|
1413
|
+
isTyping: oe,
|
|
1414
|
+
messages: Ce,
|
|
1415
|
+
renderers: ue,
|
|
1416
|
+
sendMessage: T,
|
|
1417
|
+
uploadFile: K,
|
|
1418
|
+
addMessageFeedback: i.allowMessageFeedback ? O : void 0,
|
|
1419
|
+
showInitialLoading: ye,
|
|
1377
1420
|
onShowHome: t.showWelcomeScreen ? () => {
|
|
1378
|
-
|
|
1421
|
+
I("home"), $("home");
|
|
1379
1422
|
} : void 0,
|
|
1380
|
-
onOpenHistory: () =>
|
|
1381
|
-
onRestartConversation: () =>
|
|
1423
|
+
onOpenHistory: () => Y("chat"),
|
|
1424
|
+
onRestartConversation: () => h(!0),
|
|
1382
1425
|
onCloseWidget: c
|
|
1383
1426
|
}
|
|
1384
1427
|
),
|
|
1385
1428
|
/* @__PURE__ */ o(
|
|
1386
|
-
|
|
1429
|
+
co,
|
|
1387
1430
|
{
|
|
1388
|
-
open:
|
|
1389
|
-
onCancel: () =>
|
|
1431
|
+
open: P,
|
|
1432
|
+
onCancel: () => h(!1),
|
|
1390
1433
|
onConfirm: () => {
|
|
1391
|
-
|
|
1434
|
+
h(!1), de();
|
|
1392
1435
|
}
|
|
1393
1436
|
}
|
|
1394
1437
|
),
|
|
1395
|
-
|
|
1396
|
-
|
|
1438
|
+
i.allowMessageFeedback ? /* @__PURE__ */ o(
|
|
1439
|
+
so,
|
|
1397
1440
|
{
|
|
1398
|
-
open:
|
|
1399
|
-
draft:
|
|
1400
|
-
setDraft: (C) =>
|
|
1401
|
-
onCancel: () =>
|
|
1441
|
+
open: x.open,
|
|
1442
|
+
draft: x.draft,
|
|
1443
|
+
setDraft: (C) => z((d) => ({ ...d, draft: C })),
|
|
1444
|
+
onCancel: () => z({ open: !1, messageId: null, draft: "" }),
|
|
1402
1445
|
onConfirm: async () => {
|
|
1403
|
-
|
|
1446
|
+
x.messageId && O && await O(x.messageId, {
|
|
1404
1447
|
value: "negative",
|
|
1405
|
-
comment:
|
|
1406
|
-
}),
|
|
1448
|
+
comment: x.draft
|
|
1449
|
+
}), z({ open: !1, messageId: null, draft: "" });
|
|
1407
1450
|
}
|
|
1408
1451
|
}
|
|
1409
1452
|
) : null
|
|
@@ -1417,7 +1460,7 @@ function Bo({
|
|
|
1417
1460
|
type: "button",
|
|
1418
1461
|
"aria-label": s ? "Fechar webchat" : "Abrir webchat",
|
|
1419
1462
|
children: [
|
|
1420
|
-
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children:
|
|
1463
|
+
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children: U }),
|
|
1421
1464
|
/* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children: Lt })
|
|
1422
1465
|
]
|
|
1423
1466
|
}
|
|
@@ -1427,9 +1470,9 @@ function Bo({
|
|
|
1427
1470
|
);
|
|
1428
1471
|
}
|
|
1429
1472
|
export {
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1473
|
+
So as Webchat,
|
|
1474
|
+
G as defaultConfig,
|
|
1475
|
+
pe as getContrastingTextColor,
|
|
1476
|
+
se as getShellStyle,
|
|
1434
1477
|
lt as normalizeConfig
|
|
1435
1478
|
};
|