@eduzz-automacoes/webchat-widget 0.2.1 → 0.2.2

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.
@@ -1,7 +1,7 @@
1
- import { jsx as o, jsxs as l, Fragment as Ve } from "react/jsx-runtime";
2
- import { forwardRef as Re, createElement as ke, useState as S, useEffect as M, useRef as Z, useMemo as C, useCallback as ce, useReducer as Ge } from "react";
3
- import { Container as Ke, MessageList as Je, Composer as Xe, WebchatProvider as Ze, useActiveConversation as Ye, useConversations as Qe, useUser as et, useConversationList as tt, Block as ot, StylesheetProvider as at } from "@botpress/webchat";
4
- import './style.css';const X = {
1
+ import { jsx as o, jsxs as l, Fragment as Fe } from "react/jsx-runtime";
2
+ import { forwardRef as Pe, createElement as Ne, useState as S, useEffect as M, useRef as Y, useMemo as k, useCallback as le, useReducer as st } from "react";
3
+ import { Container as ct, MessageList as lt, Composer as it, WebchatProvider as dt, useActiveConversation as ut, useConversations as bt, useUser as ht, useConversationList as pt, Block as Te, StylesheetProvider as mt } from "@botpress/webchat";
4
+ import './style.css';const Z = {
5
5
  botName: "Assistente Virtual",
6
6
  subtitle: "Conectado ao bot real",
7
7
  botAvatar: "",
@@ -64,8 +64,8 @@ import './style.css';const X = {
64
64
  welcomeCloseLabel: "Fechar painel",
65
65
  openFabBackgroundColor: "#2563eb",
66
66
  openFabIconColor: "#ffffff"
67
- }, De = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", nt = (e) => {
68
- switch (De(e)) {
67
+ }, He = (e) => e === "bottom-left" || e === "top-left" ? "bottom-left" : "bottom-right", wt = (e) => {
68
+ switch (He(e)) {
69
69
  case "bottom-left":
70
70
  return {
71
71
  bottom: "24px",
@@ -82,12 +82,12 @@ import './style.css';const X = {
82
82
  "--panel-transform-origin": "right bottom"
83
83
  };
84
84
  }
85
- }, Fe = (e, t, a) => Math.min(Math.max(e, t), a), xe = (e) => {
85
+ }, $e = (e, t, a) => Math.min(Math.max(e, t), a), Ie = (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
- }, Ne = (e) => {
90
- const t = xe(e);
89
+ }, Me = (e) => {
90
+ const t = Ie(e);
91
91
  if (!t) return null;
92
92
  const a = t.slice(1);
93
93
  return {
@@ -95,19 +95,19 @@ import './style.css';const X = {
95
95
  g: Number.parseInt(a.slice(2, 4), 16),
96
96
  b: Number.parseInt(a.slice(4, 6), 16)
97
97
  };
98
- }, rt = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
99
- (r) => Fe(Math.round(r), 0, 255).toString(16).padStart(2, "0")
98
+ }, ft = ({ r: e, g: t, b: a }) => `#${[e, t, a].map(
99
+ (r) => $e(Math.round(r), 0, 255).toString(16).padStart(2, "0")
100
100
  ).join("")}`, pe = (e, t, a) => {
101
- const r = Ne(e), s = Ne(t);
101
+ const r = Me(e), s = Me(t);
102
102
  if (!r || !s) return null;
103
- const n = Fe(a, 0, 1);
104
- return rt({
103
+ const n = $e(a, 0, 1);
104
+ return ft({
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
- }, st = (e, t) => t < 0 ? pe(e, "#000000", Math.abs(t)) : pe(e, "#ffffff", t), me = (e) => {
110
- const t = Ne(e);
109
+ }, gt = (e, t) => t < 0 ? pe(e, "#000000", Math.abs(t)) : pe(e, "#ffffff", t), me = (e) => {
110
+ const t = Me(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;
@@ -115,10 +115,10 @@ import './style.css';const X = {
115
115
  (r, s, n) => r + s * [0.2126, 0.7152, 0.0722][n],
116
116
  0
117
117
  ) > 0.42 ? "#18181b" : "#ffffff";
118
- }, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", ct = (e, t) => {
119
- const a = xe(e.brandColor);
118
+ }, L = (e, t) => e && Object.prototype.hasOwnProperty.call(e, t) && e[t] != null && e[t] !== "", yt = (e, t) => {
119
+ const a = Ie(e.brandColor);
120
120
  if (!a) return e;
121
- const r = xe(e.brandTextColor) || me(a), s = pe(a, "#ffffff", 0.82) || X.secondaryButtonBorderColor, n = pe(a, "#ffffff", 0.92) || X.secondaryButtonHoverBackgroundColor, c = st(a, -0.12) || X.primaryButtonHoverBackgroundColor;
121
+ const r = Ie(e.brandTextColor) || me(a), s = pe(a, "#ffffff", 0.82) || Z.secondaryButtonBorderColor, n = pe(a, "#ffffff", 0.92) || Z.secondaryButtonHoverBackgroundColor, c = gt(a, -0.12) || Z.primaryButtonHoverBackgroundColor;
122
122
  return {
123
123
  ...e,
124
124
  brandColor: a,
@@ -150,8 +150,8 @@ import './style.css';const X = {
150
150
  "iconButtonHoverBackgroundColor"
151
151
  ) ? e.iconButtonHoverBackgroundColor : n
152
152
  };
153
- }, lt = (e) => {
154
- const t = e.fabBackgroundColor || e.openFabBackgroundColor || X.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || X.fabIconColor;
153
+ }, vt = (e) => {
154
+ const t = e.fabBackgroundColor || e.openFabBackgroundColor || Z.fabBackgroundColor, a = e.fabIconColor || e.openFabIconColor || Z.fabIconColor;
155
155
  return {
156
156
  ...e,
157
157
  fabBackgroundColor: t,
@@ -159,17 +159,17 @@ import './style.css';const X = {
159
159
  openFabBackgroundColor: t,
160
160
  openFabIconColor: a
161
161
  };
162
- }, it = (e = {}) => lt(
163
- ct(
162
+ }, Ct = (e = {}) => vt(
163
+ yt(
164
164
  {
165
- ...X,
165
+ ...Z,
166
166
  ...e,
167
- position: De(e.position ?? X.position)
167
+ position: He(e.position ?? Z.position)
168
168
  },
169
169
  e
170
170
  )
171
- ), le = (e) => ({
172
- ...nt(e.position),
171
+ ), ie = (e) => ({
172
+ ...wt(e.position),
173
173
  "--widget-width": e.width,
174
174
  "--widget-height": e.height,
175
175
  "--bpGray-1": "var(--ui-bg)",
@@ -228,7 +228,7 @@ import './style.css';const X = {
228
228
  "--button-text": e.secondaryButtonTextColor,
229
229
  "--fab-background-color": e.fabBackgroundColor,
230
230
  "--fab-icon-color": e.fabIconColor
231
- }), dt = (e) => ({
231
+ }), Bt = (e) => ({
232
232
  color: e.color || e.accentColor,
233
233
  fontFamily: e.fontFamily,
234
234
  radius: e.radius,
@@ -238,18 +238,18 @@ import './style.css';const X = {
238
238
  additionalStylesheet: e.additionalStylesheet,
239
239
  additionalStylesheetUrl: e.additionalStylesheetUrl
240
240
  });
241
- const ut = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), bt = (e) => e.replace(
241
+ const kt = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), xt = (e) => e.replace(
242
242
  /^([A-Z])|[\s-_]+(\w)/g,
243
243
  (t, a, r) => r ? r.toUpperCase() : a.toLowerCase()
244
- ), Me = (e) => {
245
- const t = bt(e);
244
+ ), Ae = (e) => {
245
+ const t = xt(e);
246
246
  return t.charAt(0).toUpperCase() + t.slice(1);
247
- }, Pe = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), ht = (e) => {
247
+ }, Le = (...e) => e.filter((t, a, r) => !!t && t.trim() !== "" && r.indexOf(t) === a).join(" ").trim(), Nt = (e) => {
248
248
  for (const t in e)
249
249
  if (t.startsWith("aria-") || t === "role" || t === "title")
250
250
  return !0;
251
251
  };
252
- var pt = {
252
+ var It = {
253
253
  xmlns: "http://www.w3.org/2000/svg",
254
254
  width: 24,
255
255
  height: 24,
@@ -260,7 +260,7 @@ var pt = {
260
260
  strokeLinecap: "round",
261
261
  strokeLinejoin: "round"
262
262
  };
263
- const mt = Re(
263
+ const Mt = Pe(
264
264
  ({
265
265
  color: e = "currentColor",
266
266
  size: t = 24,
@@ -270,47 +270,47 @@ const mt = Re(
270
270
  children: n,
271
271
  iconNode: c,
272
272
  ...i
273
- }, u) => ke(
273
+ }, u) => Ne(
274
274
  "svg",
275
275
  {
276
276
  ref: u,
277
- ...pt,
277
+ ...It,
278
278
  width: t,
279
279
  height: t,
280
280
  stroke: e,
281
281
  strokeWidth: r ? Number(a) * 24 / Number(t) : a,
282
- className: Pe("lucide", s),
283
- ...!n && !ht(i) && { "aria-hidden": "true" },
282
+ className: Le("lucide", s),
283
+ ...!n && !Nt(i) && { "aria-hidden": "true" },
284
284
  ...i
285
285
  },
286
286
  [
287
- ...c.map(([w, m]) => ke(w, m)),
287
+ ...c.map(([w, m]) => Ne(w, m)),
288
288
  ...Array.isArray(n) ? n : [n]
289
289
  ]
290
290
  )
291
291
  );
292
292
  const A = (e, t) => {
293
- const a = Re(
294
- ({ className: r, ...s }, n) => ke(mt, {
293
+ const a = Pe(
294
+ ({ className: r, ...s }, n) => Ne(Mt, {
295
295
  ref: n,
296
296
  iconNode: t,
297
- className: Pe(
298
- `lucide-${ut(Me(e))}`,
297
+ className: Le(
298
+ `lucide-${kt(Ae(e))}`,
299
299
  `lucide-${e}`,
300
300
  r
301
301
  ),
302
302
  ...s
303
303
  })
304
304
  );
305
- return a.displayName = Me(e), a;
305
+ return a.displayName = Ae(e), a;
306
306
  };
307
- const wt = [
307
+ const St = [
308
308
  ["path", { d: "M5 12h14", key: "1ays0h" }],
309
309
  ["path", { d: "m12 5 7 7-7 7", key: "xquz4c" }]
310
- ], ft = A("arrow-right", wt);
311
- const gt = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], yt = A("chevron-down", gt);
312
- const vt = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Ct = A("chevron-right", vt);
313
- const Bt = [
310
+ ], Tt = A("arrow-right", St);
311
+ const At = [["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]], Ut = A("chevron-down", At);
312
+ const Vt = [["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]], Rt = A("chevron-right", Vt);
313
+ const Dt = [
314
314
  ["path", { d: "M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8", key: "5wwlr5" }],
315
315
  [
316
316
  "path",
@@ -319,8 +319,8 @@ const Bt = [
319
319
  key: "r6nss1"
320
320
  }
321
321
  ]
322
- ], kt = A("house", Bt);
323
- const xt = [
322
+ ], Ft = A("house", Dt);
323
+ const Pt = [
324
324
  [
325
325
  "path",
326
326
  {
@@ -331,8 +331,8 @@ const xt = [
331
331
  ["path", { d: "M8 12h.01", key: "czm47f" }],
332
332
  ["path", { d: "M12 12h.01", key: "1mp3jc" }],
333
333
  ["path", { d: "M16 12h.01", key: "1l6xoz" }]
334
- ], Nt = A("message-circle-more", xt);
335
- const It = [
334
+ ], Ht = A("message-circle-more", Pt);
335
+ const $t = [
336
336
  [
337
337
  "path",
338
338
  {
@@ -340,8 +340,8 @@ const It = [
340
340
  key: "1sd12s"
341
341
  }
342
342
  ]
343
- ], Mt = A("message-circle", It);
344
- const St = [
343
+ ], Lt = A("message-circle", $t);
344
+ const _t = [
345
345
  [
346
346
  "path",
347
347
  {
@@ -349,8 +349,8 @@ const St = [
349
349
  key: "18887p"
350
350
  }
351
351
  ]
352
- ], He = A("message-square", St);
353
- const Tt = [
352
+ ], _e = A("message-square", _t);
353
+ const zt = [
354
354
  [
355
355
  "path",
356
356
  {
@@ -365,12 +365,12 @@ const Tt = [
365
365
  key: "1qfcsi"
366
366
  }
367
367
  ]
368
- ], $e = A("messages-square", Tt);
369
- const At = [
368
+ ], ze = A("messages-square", zt);
369
+ const Et = [
370
370
  ["path", { d: "M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8", key: "1357e3" }],
371
371
  ["path", { d: "M3 3v5h5", key: "1xhq8a" }]
372
- ], Ut = A("rotate-ccw", At);
373
- const Vt = [
372
+ ], Ot = A("rotate-ccw", Et);
373
+ const qt = [
374
374
  ["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" }],
375
375
  [
376
376
  "path",
@@ -379,8 +379,8 @@ const Vt = [
379
379
  key: "ohrbg2"
380
380
  }
381
381
  ]
382
- ], Rt = A("square-pen", Vt);
383
- const Dt = [
382
+ ], jt = A("square-pen", qt);
383
+ const Wt = [
384
384
  [
385
385
  "path",
386
386
  {
@@ -389,8 +389,8 @@ const Dt = [
389
389
  }
390
390
  ],
391
391
  ["path", { d: "M17 14V2", key: "8ymqnk" }]
392
- ], Ft = A("thumbs-down", Dt);
393
- const Pt = [
392
+ ], Gt = A("thumbs-down", Wt);
393
+ const Kt = [
394
394
  [
395
395
  "path",
396
396
  {
@@ -399,20 +399,20 @@ const Pt = [
399
399
  }
400
400
  ],
401
401
  ["path", { d: "M7 10v12", key: "1qc93n" }]
402
- ], Ht = A("thumbs-up", Pt);
403
- const $t = [
402
+ ], Jt = A("thumbs-up", Kt);
403
+ const Xt = [
404
404
  ["circle", { cx: "12", cy: "8", r: "5", key: "1hypcn" }],
405
405
  ["path", { d: "M20 21a8 8 0 0 0-16 0", key: "rfgkzh" }]
406
- ], Lt = A("user-round", $t);
407
- const _t = [
406
+ ], Zt = A("user-round", Xt);
407
+ const Yt = [
408
408
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
409
409
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
410
- ], Le = A("x", _t), k = { "aria-hidden": !0, strokeWidth: 1.9 }, zt = /* @__PURE__ */ o(Ut, { ...k }), we = /* @__PURE__ */ o(Le, { ...k }), Et = /* @__PURE__ */ o(Le, { ...k }), Se = {
411
- "message-circle-more": /* @__PURE__ */ o(Nt, { ...k }),
412
- "message-circle": /* @__PURE__ */ o(Mt, { ...k }),
413
- "message-square": /* @__PURE__ */ o(He, { ...k }),
414
- "messages-square": /* @__PURE__ */ o($e, { ...k })
415
- }, Ot = (e = "messages-square") => Se[e] || Se["messages-square"], qt = /* @__PURE__ */ o(ft, { ...k }), _e = /* @__PURE__ */ o(kt, { ...k }), jt = /* @__PURE__ */ o(He, { ...k }), Wt = /* @__PURE__ */ o(Ht, { ...k }), Gt = /* @__PURE__ */ o(Ft, { ...k }), Kt = /* @__PURE__ */ o($e, { ...k }), Jt = /* @__PURE__ */ o(Ct, { ...k }), Xt = /* @__PURE__ */ o(yt, { ...k }), Zt = /* @__PURE__ */ o(Rt, { ...k }), Yt = /* @__PURE__ */ o(Lt, { ...k }), he = (e) => String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;"), Qt = ({ name: e, backgroundColor: t }) => {
410
+ ], Ee = A("x", Yt), x = { "aria-hidden": !0, strokeWidth: 1.9 }, Qt = /* @__PURE__ */ o(Ot, { ...x }), we = /* @__PURE__ */ o(Ee, { ...x }), eo = /* @__PURE__ */ o(Ee, { ...x }), Ue = {
411
+ "message-circle-more": /* @__PURE__ */ o(Ht, { ...x }),
412
+ "message-circle": /* @__PURE__ */ o(Lt, { ...x }),
413
+ "message-square": /* @__PURE__ */ o(_e, { ...x }),
414
+ "messages-square": /* @__PURE__ */ o(ze, { ...x })
415
+ }, to = (e = "messages-square") => Ue[e] || Ue["messages-square"], oo = /* @__PURE__ */ o(Tt, { ...x }), Oe = /* @__PURE__ */ o(Ft, { ...x }), ao = /* @__PURE__ */ o(_e, { ...x }), no = /* @__PURE__ */ o(Jt, { ...x }), ro = /* @__PURE__ */ o(Gt, { ...x }), so = /* @__PURE__ */ o(ze, { ...x }), co = /* @__PURE__ */ o(Rt, { ...x }), lo = /* @__PURE__ */ o(Ut, { ...x }), io = /* @__PURE__ */ o(jt, { ...x }), uo = /* @__PURE__ */ o(Zt, { ...x }), he = (e) => String(e).replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll('"', "&quot;").replaceAll("'", "&apos;"), bo = ({ name: e, backgroundColor: t }) => {
416
416
  const a = (e || "B").trim().charAt(0).toUpperCase() || "B", r = me(t), s = `
417
417
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 96 96" role="img" aria-label="${he(e || "Bot")}">
418
418
  <rect width="96" height="96" rx="48" fill="${he(t)}" />
@@ -420,28 +420,28 @@ const _t = [
420
420
  </svg>
421
421
  `.trim();
422
422
  return `data:image/svg+xml;charset=UTF-8,${encodeURIComponent(s)}`;
423
- }, eo = (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
+ }, ho = (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", Ve = [
424
424
  { unit: "minute", seconds: 60 },
425
425
  { unit: "hour", seconds: 3600 },
426
426
  { unit: "day", seconds: 3600 * 24 },
427
427
  { unit: "week", seconds: 3600 * 24 * 7 },
428
428
  { unit: "month", seconds: 3600 * 24 * 30 },
429
429
  { unit: "year", seconds: 3600 * 24 * 365 }
430
- ], to = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), oo = (e) => {
430
+ ], po = new Intl.RelativeTimeFormat("pt-BR", { numeric: "auto" }), mo = (e) => {
431
431
  const t = Math.round((new Date(e).getTime() - Date.now()) / 1e3);
432
432
  if (Math.abs(t) < 45) return "agora";
433
- let a = Te[0];
434
- for (const r of Te)
433
+ let a = Ve[0];
434
+ for (const r of Ve)
435
435
  Math.abs(t) >= r.seconds && (a = r);
436
- return to.format(Math.round(t / a.seconds), a.unit);
437
- }, ao = ({ messages: e, user: t, botName: a, botAvatar: r }) => e.map((s) => {
436
+ return po.format(Math.round(t / a.seconds), a.unit);
437
+ }, wo = ({ messages: e, user: t, botName: a, botAvatar: r }) => e.map((s) => {
438
438
  const n = s.authorId === t?.userId;
439
439
  return {
440
440
  ...s,
441
441
  direction: n ? "outgoing" : "incoming",
442
442
  sender: n ? { name: t?.name ?? "Você", avatar: t?.pictureUrl } : { name: a, avatar: r }
443
443
  };
444
- }), no = ({ activeView: e, clientState: t, conversationId: a, messagesLength: r }) => {
444
+ }), fo = ({ activeView: e, clientState: t, conversationId: a, messagesLength: r }) => {
445
445
  const [s, n] = S(!1), c = e === "chat", i = c && t === "connecting", u = c && t === "connected" && r === 0, w = s && (!c || r > 0 || t !== "connecting" && t !== "connected");
446
446
  return M(() => {
447
447
  if (s) {
@@ -458,14 +458,14 @@ const _t = [
458
458
  showInitialLoading: i || s && c,
459
459
  setShowInitialLoading: n
460
460
  };
461
- }, ro = 3e4, so = ({
461
+ }, go = 3e4, yo = ({
462
462
  getSession: e,
463
463
  sessionKey: t,
464
464
  onSessionChange: a
465
465
  }) => {
466
- const [r, s] = S(null), [n, c] = S(!!e), i = Z(e);
466
+ const [r, s] = S(null), [n, c] = S(!!e), i = Y(e);
467
467
  i.current = e;
468
- const u = Z(a);
468
+ const u = Y(a);
469
469
  return u.current = a, M(() => {
470
470
  let w = !0, m;
471
471
  const b = (f) => {
@@ -482,7 +482,7 @@ const _t = [
482
482
  throw new Error("Webchat session not created or empty");
483
483
  if (!w) return;
484
484
  b(f);
485
- const B = f.expiresAt - Date.now() - ro;
485
+ const B = f.expiresAt - Date.now() - go;
486
486
  m = setTimeout(U, Math.max(B, 0));
487
487
  } catch (f) {
488
488
  console.error("[EduzzWebchat] error creating session: ", f), b(null);
@@ -495,7 +495,7 @@ const _t = [
495
495
  };
496
496
  }, [t, !!e]), { session: r, resolving: n };
497
497
  };
498
- function co({
498
+ function vo({
499
499
  botName: e,
500
500
  botAvatar: t,
501
501
  subtitle: a,
@@ -520,7 +520,7 @@ function co({
520
520
  type: "button",
521
521
  "aria-label": "Abrir início",
522
522
  onClick: r,
523
- children: _e
523
+ children: Oe
524
524
  }
525
525
  ) : null,
526
526
  /* @__PURE__ */ o(
@@ -530,7 +530,7 @@ function co({
530
530
  type: "button",
531
531
  "aria-label": "Abrir conversas",
532
532
  onClick: s,
533
- children: Kt
533
+ children: so
534
534
  }
535
535
  ),
536
536
  /* @__PURE__ */ o(
@@ -540,7 +540,7 @@ function co({
540
540
  type: "button",
541
541
  "aria-label": "Reiniciar conversa",
542
542
  onClick: n,
543
- children: zt
543
+ children: Qt
544
544
  }
545
545
  ),
546
546
  c ? /* @__PURE__ */ o(
@@ -556,7 +556,7 @@ function co({
556
556
  ] })
557
557
  ] });
558
558
  }
559
- function ze() {
559
+ function qe() {
560
560
  return /* @__PURE__ */ l("div", { className: "bp-webchat-loading", children: [
561
561
  /* @__PURE__ */ l("div", { className: "bp-webchat-loading-hero", children: [
562
562
  /* @__PURE__ */ o("div", { className: "bp-webchat-loading-circle" }),
@@ -574,7 +574,7 @@ function ze() {
574
574
  ] })
575
575
  ] });
576
576
  }
577
- function lo({
577
+ function Co({
578
578
  config: e,
579
579
  allowFileUpload: t,
580
580
  clientState: a,
@@ -592,7 +592,7 @@ function lo({
592
592
  }) {
593
593
  return /* @__PURE__ */ l("div", { className: "bp-webchat-layout", children: [
594
594
  /* @__PURE__ */ o(
595
- co,
595
+ vo,
596
596
  {
597
597
  botName: e.botName,
598
598
  botAvatar: e.botAvatar,
@@ -604,14 +604,14 @@ function lo({
604
604
  }
605
605
  ),
606
606
  /* @__PURE__ */ o(
607
- Ke,
607
+ ct,
608
608
  {
609
609
  className: "bp-webchat-container",
610
610
  uploadFile: i,
611
611
  allowFileUpload: t,
612
- children: w ? /* @__PURE__ */ o(ze, {}) : /* @__PURE__ */ l(Ve, { children: [
612
+ children: w ? /* @__PURE__ */ o(qe, {}) : /* @__PURE__ */ l(Fe, { children: [
613
613
  /* @__PURE__ */ o(
614
- Je,
614
+ lt,
615
615
  {
616
616
  botName: e.botName,
617
617
  botDescription: e.subtitle,
@@ -628,7 +628,7 @@ function lo({
628
628
  }
629
629
  ),
630
630
  /* @__PURE__ */ o(
631
- Xe,
631
+ it,
632
632
  {
633
633
  connected: a !== "disconnected",
634
634
  sendMessage: c,
@@ -643,7 +643,7 @@ function lo({
643
643
  )
644
644
  ] });
645
645
  }
646
- function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
646
+ function je({ activeView: e, onShowHome: t, onShowConversations: a }) {
647
647
  return /* @__PURE__ */ l("div", { className: "bp-webchat-tabs bp-webchat-welcome-bottom", children: [
648
648
  /* @__PURE__ */ l(
649
649
  "button",
@@ -653,7 +653,7 @@ function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
653
653
  type: "button",
654
654
  onClick: t,
655
655
  children: [
656
- /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: _e }),
656
+ /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: Oe }),
657
657
  /* @__PURE__ */ o("span", { children: "Início" })
658
658
  ]
659
659
  }
@@ -666,14 +666,14 @@ function Ee({ activeView: e, onShowHome: t, onShowConversations: a }) {
666
666
  type: "button",
667
667
  onClick: a,
668
668
  children: [
669
- /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: jt }),
669
+ /* @__PURE__ */ o("span", { className: "bp-webchat-tab-icon bp-webchat-welcome-tab-icon", children: ao }),
670
670
  /* @__PURE__ */ o("span", { children: "Conversas" })
671
671
  ]
672
672
  }
673
673
  )
674
674
  ] });
675
675
  }
676
- function io({
676
+ function Bo({
677
677
  conversations: e,
678
678
  currentConversationId: t,
679
679
  isLoading: a,
@@ -713,7 +713,7 @@ function io({
713
713
  ] })
714
714
  ] }),
715
715
  /* @__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) => {
716
- const U = eo(b.lastMessage), f = b.lastMessage?.author?.type === "bot";
716
+ const U = ho(b.lastMessage), f = b.lastMessage?.author?.type === "bot";
717
717
  return /* @__PURE__ */ l(
718
718
  "button",
719
719
  {
@@ -722,23 +722,23 @@ function io({
722
722
  onClick: () => m(b.id),
723
723
  "data-current": b.id === t || void 0,
724
724
  children: [
725
- /* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": f ? "bot" : "user", children: f && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : f ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : Yt }),
725
+ /* @__PURE__ */ o("div", { className: "bp-webchat-history-avatar", "data-kind": f ? "bot" : "user", children: f && r ? /* @__PURE__ */ o("img", { src: r, alt: "" }) : f ? /* @__PURE__ */ o("span", { children: (s || "B").slice(0, 1).toUpperCase() }) : uo }),
726
726
  /* @__PURE__ */ l("div", { className: "bp-webchat-history-content", children: [
727
727
  /* @__PURE__ */ o("span", { className: "bp-webchat-history-name", children: U }),
728
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: oo(b.updatedAt) })
728
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-time", children: mo(b.updatedAt) })
729
729
  ] }),
730
- /* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: Jt })
730
+ /* @__PURE__ */ o("span", { className: "bp-webchat-history-chevron", children: co })
731
731
  ]
732
732
  },
733
733
  b.id
734
734
  );
735
735
  }) }),
736
736
  /* @__PURE__ */ o("div", { className: "bp-webchat-history-footer", children: /* @__PURE__ */ l("button", { className: "bp-webchat-history-new", type: "button", onClick: w, children: [
737
- Zt,
737
+ io,
738
738
  /* @__PURE__ */ o("span", { children: "Nova conversa" })
739
739
  ] }) }),
740
740
  /* @__PURE__ */ o(
741
- Ee,
741
+ je,
742
742
  {
743
743
  activeView: "conversations",
744
744
  onShowHome: i,
@@ -747,11 +747,11 @@ function io({
747
747
  )
748
748
  ] });
749
749
  }
750
- const Ae = (e) => String(e ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
751
- function uo(e) {
752
- const { label: t, options: a = [], sendMessage: r, isReadOnly: s, messageId: n } = e, [c, i] = S(!1), [u, w] = S(""), [m, b] = S(0), [U, f] = S(null), B = Z(null), F = Z([]), _ = s || U !== null || a.length === 0, V = C(() => {
753
- const d = Ae(u);
754
- return d ? a.filter((p) => Ae(p.label).includes(d)) : a;
750
+ const Re = (e) => String(e ?? "").normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().trim();
751
+ function ko(e) {
752
+ const { label: t, options: a = [], sendMessage: r, isReadOnly: s, messageId: n } = e, [c, i] = S(!1), [u, w] = S(""), [m, b] = S(0), [U, f] = S(null), B = Y(null), F = Y([]), _ = s || U !== null || a.length === 0, V = k(() => {
753
+ const d = Re(u);
754
+ return d ? a.filter((p) => Re(p.label).includes(d)) : a;
755
755
  }, [a, u]);
756
756
  M(() => {
757
757
  b(0);
@@ -764,9 +764,9 @@ function uo(e) {
764
764
  }, [c]), M(() => {
765
765
  c && F.current[m]?.scrollIntoView({ block: "nearest" });
766
766
  }, [m, c]);
767
- const j = (d) => {
767
+ const W = (d) => {
768
768
  d && (r?.({ type: "text", text: d.label, value: d.value }), f(d.label), w(""), i(!1));
769
- }, W = (d) => {
769
+ }, G = (d) => {
770
770
  if (!_)
771
771
  switch (d.key) {
772
772
  case "ArrowDown":
@@ -780,13 +780,13 @@ function uo(e) {
780
780
  d.preventDefault(), b((p) => Math.max(p - 1, 0));
781
781
  break;
782
782
  case "Enter":
783
- d.preventDefault(), c && j(V[m]);
783
+ d.preventDefault(), c && W(V[m]);
784
784
  break;
785
785
  case "Escape":
786
786
  i(!1);
787
787
  break;
788
788
  }
789
- }, x = `bpDropdownList-${n ?? "x"}`;
789
+ }, N = `bpDropdownList-${n ?? "x"}`;
790
790
  return /* @__PURE__ */ l(
791
791
  "div",
792
792
  {
@@ -804,7 +804,7 @@ function uo(e) {
804
804
  type: "text",
805
805
  role: "combobox",
806
806
  "aria-expanded": c,
807
- "aria-controls": x,
807
+ "aria-controls": N,
808
808
  "aria-autocomplete": "list",
809
809
  autoComplete: "off",
810
810
  placeholder: "Selecione...",
@@ -816,12 +816,12 @@ function uo(e) {
816
816
  onChange: (d) => {
817
817
  w(d.target.value), i(!0);
818
818
  },
819
- onKeyDown: W
819
+ onKeyDown: G
820
820
  }
821
821
  ),
822
- /* @__PURE__ */ o("span", { className: "bpDropdownChevron", children: Xt })
822
+ /* @__PURE__ */ o("span", { className: "bpDropdownChevron", children: lo })
823
823
  ] }),
824
- c && !_ ? /* @__PURE__ */ o("ul", { className: "bpDropdownMenu", id: x, role: "listbox", children: V.length > 0 ? V.map((d, p) => /* @__PURE__ */ o(
824
+ c && !_ ? /* @__PURE__ */ o("ul", { className: "bpDropdownMenu", id: N, role: "listbox", children: V.length > 0 ? V.map((d, p) => /* @__PURE__ */ o(
825
825
  "li",
826
826
  {
827
827
  ref: (R) => {
@@ -833,7 +833,7 @@ function uo(e) {
833
833
  "data-active": p === m || void 0,
834
834
  onMouseEnter: () => b(p),
835
835
  onMouseDown: (R) => {
836
- R.preventDefault(), j(d);
836
+ R.preventDefault(), W(d);
837
837
  },
838
838
  children: d.label
839
839
  },
@@ -843,7 +843,7 @@ function uo(e) {
843
843
  }
844
844
  );
845
845
  }
846
- function bo({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
846
+ function xo({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
847
847
  return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
848
848
  /* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Nos ajude a melhorar" }),
849
849
  /* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Conte o que não ficou bom nesta resposta." }),
@@ -870,7 +870,7 @@ function bo({ open: e, draft: t, setDraft: a, onConfirm: r, onCancel: s }) {
870
870
  ] })
871
871
  ] }) }) : null;
872
872
  }
873
- function ho({ open: e, onConfirm: t, onCancel: a }) {
873
+ function No({ open: e, onConfirm: t, onCancel: a }) {
874
874
  return e ? /* @__PURE__ */ o("div", { className: "bp-webchat-modal-backdrop", children: /* @__PURE__ */ l("div", { className: "bp-webchat-modal", children: [
875
875
  /* @__PURE__ */ o("h3", { className: "bp-webchat-modal-title", children: "Criar nova conversa" }),
876
876
  /* @__PURE__ */ o("p", { className: "bp-webchat-modal-description", children: "Isso vai limpar a conversa atual e iniciar uma nova sessão com o bot." }),
@@ -888,7 +888,7 @@ function ho({ open: e, onConfirm: t, onCancel: a }) {
888
888
  ] })
889
889
  ] }) }) : null;
890
890
  }
891
- function po({ config: e, activeView: t, onShowHome: a, onShowConversations: r, onStart: s, onClose: n }) {
891
+ function Io({ config: e, activeView: t, onShowHome: a, onShowConversations: r, onStart: s, onClose: n }) {
892
892
  const c = e.welcomeCardImage || e.botAvatar;
893
893
  return /* @__PURE__ */ l("div", { className: "bp-webchat-welcome", children: [
894
894
  /* @__PURE__ */ l("div", { className: "bp-webchat-welcome-hero", children: [
@@ -914,11 +914,11 @@ function po({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
914
914
  /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-title", children: e.welcomeCtaLabel }),
915
915
  e.welcomeButtonDescription ? /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-description", children: e.welcomeButtonDescription }) : null
916
916
  ] }) }),
917
- /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: qt })
917
+ /* @__PURE__ */ o("span", { className: "bp-webchat-welcome-cta-right", children: oo })
918
918
  ] })
919
919
  ] }) }),
920
920
  /* @__PURE__ */ o(
921
- Ee,
921
+ je,
922
922
  {
923
923
  activeView: t,
924
924
  onShowHome: a,
@@ -927,43 +927,43 @@ function po({ config: e, activeView: t, onShowHome: a, onShowConversations: r, o
927
927
  )
928
928
  ] });
929
929
  }
930
- const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
930
+ const Mo = 220, fe = "eduzz-webchat", xe = Object.freeze({
931
931
  allowFileUpload: !1,
932
932
  allowMessageFeedback: !1
933
- }), wo = "anonymous-id", fo = (e) => !!e && typeof e == "object" && !Array.isArray(e), Oe = (e) => e.replace(/\/+$/, ""), Ie = ({ webchatProxyUrl: e }) => {
933
+ }), So = "anonymous-id", To = (e) => !!e && typeof e == "object" && !Array.isArray(e), We = (e) => e.replace(/\/+$/, ""), Se = ({ webchatProxyUrl: e }) => {
934
934
  if (typeof e != "string" || !e.trim())
935
935
  return null;
936
- const t = Oe(e.trim()), a = "/webchat/proxy";
936
+ const t = We(e.trim()), a = "/webchat/proxy";
937
937
  return t.endsWith(a) ? t.slice(0, -a.length) : null;
938
- }, go = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, yo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
938
+ }, Ao = ({ webchatProxyUrl: e, clientId: t }) => !e || !t ? null : `${e.endsWith("/") ? e.slice(0, -1) : e}/${encodeURIComponent(t)}/runtime-config`, Uo = ({ webchatProxyUrl: e, clientId: t, presetSlug: a }) => {
939
939
  if (!e || !t)
940
940
  return null;
941
- const r = Ie({ webchatProxyUrl: e });
941
+ const r = Se({ webchatProxyUrl: e });
942
942
  if (!r)
943
943
  return null;
944
944
  const s = new URLSearchParams();
945
945
  typeof a == "string" && a.trim() && s.set("slug", a.trim());
946
946
  const n = s.toString();
947
947
  return `${r}/webchat/bootstrap/${encodeURIComponent(t)}${n ? `?${n}` : ""}`;
948
- }, vo = (e) => {
948
+ }, Vo = (e) => {
949
949
  const t = e && typeof e == "object" && e.data && typeof e.data == "object" ? e.data : e;
950
950
  return t && typeof t == "object" ? t : null;
951
- }, ne = (e) => fo(e) ? e : null, Co = (e) => {
951
+ }, re = (e) => To(e) ? e : null, Ro = (e) => {
952
952
  if (!e) return "";
953
953
  try {
954
954
  return JSON.stringify(e);
955
955
  } catch {
956
956
  return String(Date.now());
957
957
  }
958
- }, qe = (e) => {
958
+ }, Ge = (e) => {
959
959
  if (typeof window > "u") return null;
960
960
  try {
961
961
  return e === "sessionStorage" ? window.sessionStorage : window.localStorage;
962
962
  } catch {
963
963
  return null;
964
964
  }
965
- }, je = ({ storageKey: e, storageLocation: t }) => {
966
- const a = qe(t);
965
+ }, Ke = ({ storageKey: e, storageLocation: t }) => {
966
+ const a = Ge(t);
967
967
  if (!a) return null;
968
968
  try {
969
969
  const r = a.getItem(
@@ -975,10 +975,13 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
975
975
  } catch {
976
976
  return;
977
977
  }
978
- }, Bo = ({ storageKey: e, storageLocation: t }) => {
979
- const a = je({ storageKey: e, storageLocation: t });
978
+ }, Do = ({ storageKey: e, storageLocation: t }) => {
979
+ const a = Ke({
980
+ storageKey: e,
981
+ storageLocation: t
982
+ });
980
983
  return typeof a?.conversationId == "string" && a.conversationId.trim() || void 0;
981
- }, Ue = () => {
984
+ }, De = () => {
982
985
  try {
983
986
  if (typeof crypto < "u" && typeof crypto.randomUUID == "function")
984
987
  return crypto.randomUUID();
@@ -992,19 +995,23 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
992
995
  const t = Math.random() * 16 | 0;
993
996
  return (e === "x" ? t : t & 3 | 8).toString(16);
994
997
  });
995
- }, ko = (e) => `${e || fe}-${wo}`, xo = ({ storageKey: e, storageLocation: t }) => {
996
- const a = qe(t), r = ko(e);
998
+ }, Fo = (e) => `${e || fe}-${So}`, Po = ({ storageKey: e, storageLocation: t }) => {
999
+ const a = Ge(t), r = Fo(e);
997
1000
  try {
998
1001
  const s = a?.getItem(r);
999
1002
  if (s)
1000
1003
  return s;
1001
- const n = `anon_${Ue()}`;
1004
+ const n = `anon_${De()}`;
1002
1005
  return a?.setItem(r, n), n;
1003
1006
  } catch {
1004
- return `anon_${Ue()}`;
1007
+ return `anon_${De()}`;
1005
1008
  }
1006
- }, No = async ({ webchatProxyUrl: e, clientId: t, accountId: a }) => {
1007
- const r = Ie({ webchatProxyUrl: e });
1009
+ }, Ho = async ({
1010
+ webchatProxyUrl: e,
1011
+ clientId: t,
1012
+ accountId: a
1013
+ }) => {
1014
+ const r = Se({ webchatProxyUrl: e });
1008
1015
  if (!r)
1009
1016
  throw new Error("public session request requires a valid webchatProxyUrl");
1010
1017
  const s = await fetch(
@@ -1018,7 +1025,9 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
1018
1025
  }
1019
1026
  );
1020
1027
  if (!s.ok)
1021
- throw new Error(`public session request failed with status ${s.status}`);
1028
+ throw new Error(
1029
+ `public session request failed with status ${s.status}`
1030
+ );
1022
1031
  const n = await s.json(), c = n && typeof n == "object" && n.data && typeof n.data == "object" ? n.data : n;
1023
1032
  if (!c || typeof c != "object")
1024
1033
  throw new Error("public session response is invalid");
@@ -1028,11 +1037,11 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
1028
1037
  userId: c.userId,
1029
1038
  userToken: c.userToken
1030
1039
  };
1031
- }, Io = (e) => ({
1040
+ }, $o = (e) => ({
1032
1041
  ...typeof e.name == "string" && e.name.trim() ? { name: e.name.trim() } : {},
1033
1042
  ...typeof e.pictureUrl == "string" && e.pictureUrl.trim() ? { pictureUrl: e.pictureUrl.trim() } : {},
1034
1043
  userData: e
1035
- }), Mo = ({
1044
+ }), Lo = ({
1036
1045
  showWelcomeScreen: e,
1037
1046
  storageKey: t,
1038
1047
  storageLocation: a,
@@ -1040,17 +1049,48 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
1040
1049
  userToken: s
1041
1050
  }) => {
1042
1051
  if (!e)
1043
- return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
1052
+ return {
1053
+ activeView: "chat",
1054
+ historyReturnView: "chat",
1055
+ bootstrapView: "chat"
1056
+ };
1044
1057
  if (r && s)
1045
- return { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" };
1046
- const n = je({ storageKey: t, storageLocation: a });
1058
+ return {
1059
+ activeView: "chat",
1060
+ historyReturnView: "chat",
1061
+ bootstrapView: "chat"
1062
+ };
1063
+ const n = Ke({
1064
+ storageKey: t,
1065
+ storageLocation: a
1066
+ });
1047
1067
  if (n == null)
1048
- return { activeView: "home", historyReturnView: "home", bootstrapView: "home" };
1068
+ return {
1069
+ activeView: "home",
1070
+ historyReturnView: "home",
1071
+ bootstrapView: "home"
1072
+ };
1049
1073
  if (n === void 0)
1050
- return { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
1074
+ return {
1075
+ activeView: "pending",
1076
+ historyReturnView: "home",
1077
+ bootstrapView: "pending"
1078
+ };
1051
1079
  const c = typeof n.conversationId == "string" ? n.conversationId.trim() : "", i = typeof n.user?.userToken == "string" ? n.user.userToken.trim() : "";
1052
- return c && i ? { activeView: "chat", historyReturnView: "chat", bootstrapView: "chat" } : !c && !i ? { activeView: "home", historyReturnView: "home", bootstrapView: "home" } : { activeView: "pending", historyReturnView: "home", bootstrapView: "pending" };
1053
- }, So = (e, t) => {
1080
+ return c && i ? {
1081
+ activeView: "chat",
1082
+ historyReturnView: "chat",
1083
+ bootstrapView: "chat"
1084
+ } : !c && !i ? {
1085
+ activeView: "home",
1086
+ historyReturnView: "home",
1087
+ bootstrapView: "home"
1088
+ } : {
1089
+ activeView: "pending",
1090
+ historyReturnView: "home",
1091
+ bootstrapView: "pending"
1092
+ };
1093
+ }, _o = (e, t) => {
1054
1094
  switch (t.type) {
1055
1095
  case "show":
1056
1096
  return { isPanelMounted: !0, isPanelVisible: e.isPanelVisible };
@@ -1064,7 +1104,7 @@ const mo = 220, fe = "eduzz-webchat", Be = Object.freeze({
1064
1104
  return e;
1065
1105
  }
1066
1106
  };
1067
- function Ro({
1107
+ function jo({
1068
1108
  clientId: e,
1069
1109
  webchatProxyUrl: t,
1070
1110
  userCredentials: a,
@@ -1080,29 +1120,34 @@ function Ro({
1080
1120
  sessionKey: U,
1081
1121
  onSessionChange: f
1082
1122
  }) {
1083
- const { session: B, resolving: F } = so({
1123
+ const { session: B, resolving: F } = yo({
1084
1124
  getSession: b,
1085
1125
  sessionKey: U,
1086
1126
  onSessionChange: f
1087
- }), Y = !!B && Date.now() < B.expiresAt, _ = Y ? { userId: B.userId, userToken: B.userToken } : void 0, V = b ? _ : a, j = Y ? B.conversationId : void 0, W = C(
1127
+ }), Q = !!B && Date.now() < B.expiresAt, _ = Q ? { userId: B.userId, userToken: B.userToken } : void 0, V = b ? _ : a, W = Q ? B.conversationId : void 0, G = k(
1088
1128
  () => typeof c == "string" && c.trim() ? c.trim() : void 0,
1089
1129
  [c]
1090
- ), x = C(
1091
- () => typeof t == "string" && t.trim() ? Oe(t.trim()) : void 0,
1130
+ ), N = k(
1131
+ () => typeof t == "string" && t.trim() ? We(t.trim()) : void 0,
1092
1132
  [t]
1093
1133
  );
1094
- C(
1095
- () => x ? Ie({ webchatProxyUrl: x }) : null,
1096
- [x]
1134
+ k(
1135
+ () => N ? Se({ webchatProxyUrl: N }) : null,
1136
+ [N]
1097
1137
  );
1098
- const d = !!(e && x && (W || !V)), p = C(
1099
- () => d ? yo({
1100
- webchatProxyUrl: x,
1138
+ const d = !!(e && N && (G || !V)), p = k(
1139
+ () => d ? Uo({
1140
+ webchatProxyUrl: N,
1101
1141
  clientId: e,
1102
- presetSlug: W
1142
+ presetSlug: G
1103
1143
  }) : null,
1104
- [e, W, x, d]
1105
- ), [R, Q] = S({
1144
+ [
1145
+ e,
1146
+ G,
1147
+ N,
1148
+ d
1149
+ ]
1150
+ ), [R, ee] = S({
1106
1151
  error: null,
1107
1152
  isLoading: !1,
1108
1153
  payload: null,
@@ -1110,49 +1155,63 @@ function Ro({
1110
1155
  });
1111
1156
  M(() => {
1112
1157
  if (!p) {
1113
- Q({ error: null, isLoading: !1, payload: null, url: null });
1158
+ ee({
1159
+ error: null,
1160
+ isLoading: !1,
1161
+ payload: null,
1162
+ url: null
1163
+ });
1114
1164
  return;
1115
1165
  }
1116
- const N = new AbortController();
1117
- return Q({ error: null, isLoading: !0, payload: null, url: p }), fetch(p, {
1166
+ const I = new AbortController();
1167
+ return ee({
1168
+ error: null,
1169
+ isLoading: !0,
1170
+ payload: null,
1171
+ url: p
1172
+ }), fetch(p, {
1118
1173
  headers: {
1119
1174
  accept: "application/json"
1120
1175
  },
1121
- signal: N.signal
1176
+ signal: I.signal
1122
1177
  }).then(async (v) => {
1123
1178
  if (!v.ok)
1124
- throw new Error(`bootstrap request failed with status ${v.status}`);
1179
+ throw new Error(
1180
+ `bootstrap request failed with status ${v.status}`
1181
+ );
1125
1182
  return v.json();
1126
1183
  }).then((v) => {
1127
- const H = vo(v);
1184
+ const H = Vo(v);
1128
1185
  if (!H)
1129
1186
  throw new Error("bootstrap response is invalid");
1130
- Q({
1187
+ ee({
1131
1188
  error: null,
1132
1189
  isLoading: !1,
1133
1190
  payload: H,
1134
1191
  url: p
1135
1192
  });
1136
1193
  }).catch((v) => {
1137
- N.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", v), Q({ error: v, isLoading: !1, payload: null, url: p }));
1138
- }), () => N.abort();
1194
+ I.signal.aborted || (console.warn("[EduzzWebchat] failed to load bootstrap", v), ee({
1195
+ error: v,
1196
+ isLoading: !1,
1197
+ payload: null,
1198
+ url: p
1199
+ }));
1200
+ }), () => I.abort();
1139
1201
  }, [p]);
1140
- const y = p && R.url === p ? R.payload : null, ie = p && R.url === p ? R.error : null, T = y?.clientId || e, P = x || y?.webchatProxyUrl || void 0, z = i === fe && y?.storageKey ? y.storageKey : i, G = typeof w == "boolean" ? w : typeof y?.defaultOpen == "boolean" ? y.defaultOpen : w, D = C(
1202
+ const y = p && R.url === p ? R.payload : null, de = p && R.url === p ? R.error : null, T = y?.clientId || e, P = N || y?.webchatProxyUrl || void 0, z = i === fe && y?.storageKey ? y.storageKey : i, K = typeof w == "boolean" ? w : typeof y?.defaultOpen == "boolean" ? y.defaultOpen : w, D = k(
1141
1203
  () => ({
1142
- ...ne(y?.config) || {},
1143
- ...ne(s) || {}
1204
+ ...re(y?.config) || {},
1205
+ ...re(s) || {}
1144
1206
  }),
1145
1207
  [y, s]
1146
- ), ge = C(
1147
- () => {
1148
- const N = {
1149
- ...ne(y?.defaultUserData) || {},
1150
- ...ne(n) || {}
1151
- };
1152
- return Object.keys(N).length > 0 ? N : null;
1153
- },
1154
- [n, y]
1155
- ), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [re, ee] = S({
1208
+ ), ge = k(() => {
1209
+ const I = {
1210
+ ...re(y?.defaultUserData) || {},
1211
+ ...re(n) || {}
1212
+ };
1213
+ return Object.keys(I).length > 0 ? I : null;
1214
+ }, [n, y]), E = !!(!V && !F && y?.sessionMode === "service-hub" && P && T), [se, te] = S({
1156
1215
  error: null,
1157
1216
  isLoading: !1,
1158
1217
  payload: null,
@@ -1160,33 +1219,38 @@ function Ro({
1160
1219
  });
1161
1220
  M(() => {
1162
1221
  if (!E) {
1163
- ee({ error: null, isLoading: !1, payload: null, key: null });
1222
+ te({
1223
+ error: null,
1224
+ isLoading: !1,
1225
+ payload: null,
1226
+ key: null
1227
+ });
1164
1228
  return;
1165
1229
  }
1166
- const N = xo({
1230
+ const I = Po({
1167
1231
  storageKey: z,
1168
1232
  storageLocation: u
1169
- }), v = `${T}:${P}:${N}`;
1233
+ }), v = `${T}:${P}:${I}`;
1170
1234
  let H = !1;
1171
- return ee({
1235
+ return te({
1172
1236
  error: null,
1173
1237
  isLoading: !0,
1174
1238
  payload: null,
1175
1239
  key: v
1176
- }), No({
1240
+ }), Ho({
1177
1241
  webchatProxyUrl: P,
1178
1242
  clientId: T,
1179
- accountId: N
1180
- }).then((g) => {
1181
- H || ee({
1243
+ accountId: I
1244
+ }).then((C) => {
1245
+ H || te({
1182
1246
  error: null,
1183
1247
  isLoading: !1,
1184
- payload: g,
1248
+ payload: C,
1185
1249
  key: v
1186
1250
  });
1187
- }).catch((g) => {
1188
- H || (console.warn("[EduzzWebchat] failed to open public session", g), ee({
1189
- error: g,
1251
+ }).catch((C) => {
1252
+ H || (console.warn("[EduzzWebchat] failed to open public session", C), te({
1253
+ error: C,
1190
1254
  isLoading: !1,
1191
1255
  payload: null,
1192
1256
  key: v
@@ -1201,77 +1265,89 @@ function Ro({
1201
1265
  E,
1202
1266
  u
1203
1267
  ]);
1204
- const K = E ? re.payload : null, te = V || K, O = C(() => it(D), [D]), oe = C(
1205
- () => j || r || Bo({
1268
+ const J = E ? se.payload : null, oe = V || J, O = k(
1269
+ () => Ct(D),
1270
+ [D]
1271
+ ), ae = k(
1272
+ () => W || r || Do({
1206
1273
  storageKey: z,
1207
1274
  storageLocation: u
1208
1275
  }),
1209
- [j, r, z, u]
1210
- ), $ = G ?? O.initiallyOpen ?? !0, [ye, J] = S($), se = Z($), [q, ae] = S(Be), ve = ce(() => J((N) => !N), []);
1276
+ [
1277
+ W,
1278
+ r,
1279
+ z,
1280
+ u
1281
+ ]
1282
+ ), $ = K ?? O.initiallyOpen ?? !0, [ye, X] = S($), ce = Y($), [q, ne] = S(
1283
+ xe
1284
+ ), ve = le(() => X((I) => !I), []);
1211
1285
  M(() => {
1212
- se.current !== $ && (se.current = $, J($));
1286
+ ce.current !== $ && (ce.current = $, X($));
1213
1287
  }, [$]);
1214
- const de = d && !y && !ie, Ce = E && !K && !re.error;
1288
+ const ue = d && !y && !de, Ce = E && !J && !se.error;
1215
1289
  return M(() => {
1216
- const N = go({
1290
+ const I = Ao({
1217
1291
  webchatProxyUrl: P,
1218
1292
  clientId: T
1219
1293
  });
1220
- if (ae(Be), !N)
1294
+ if (ne(xe), !I)
1221
1295
  return;
1222
1296
  const v = new AbortController();
1223
1297
  let H = !1;
1224
- return fetch(N, {
1298
+ return fetch(I, {
1225
1299
  headers: {
1226
1300
  accept: "application/json"
1227
1301
  },
1228
1302
  signal: v.signal
1229
- }).then(async (g) => {
1230
- if (!g.ok)
1231
- throw new Error(`runtime config request failed with status ${g.status}`);
1232
- return g.json();
1233
- }).then((g) => {
1303
+ }).then(async (C) => {
1304
+ if (!C.ok)
1305
+ throw new Error(
1306
+ `runtime config request failed with status ${C.status}`
1307
+ );
1308
+ return C.json();
1309
+ }).then((C) => {
1234
1310
  if (H)
1235
1311
  return;
1236
- const ue = g && typeof g == "object" && g.data && typeof g.data == "object" ? g.data : {};
1237
- ae({
1238
- allowFileUpload: ue.allowFileUpload === !0,
1239
- allowMessageFeedback: ue.allowMessageFeedback === !0
1312
+ const h = C && typeof C == "object" && C.data && typeof C.data == "object" ? C.data : {};
1313
+ ne({
1314
+ allowFileUpload: h.allowFileUpload === !0,
1315
+ allowMessageFeedback: h.allowMessageFeedback === !0
1240
1316
  });
1241
- }).catch((g) => {
1242
- v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config", g), ae(Be));
1317
+ }).catch((C) => {
1318
+ v.signal.aborted || H || (console.warn("[EduzzWebchat] failed to load runtime config", C), ne(xe));
1243
1319
  }), () => {
1244
1320
  H = !0, v.abort();
1245
1321
  };
1246
- }, [T, P]), de || Ce || b && F ? null : ie && !y ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : re.error && !K ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : P ? T ? /* @__PURE__ */ o(
1247
- Ze,
1322
+ }, [T, P]), ue || Ce || b && F ? null : de && !y ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel carregar a configuracao publica do webchat." }) }) : se.error && !J ? /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nao foi possivel abrir a sessao publica do webchat." }) }) : P ? T ? /* @__PURE__ */ o(
1323
+ dt,
1248
1324
  {
1249
1325
  clientId: T,
1250
1326
  apiUrl: P,
1251
- conversationId: oe,
1252
- userCredentials: te,
1327
+ conversationId: ae,
1328
+ userCredentials: oe,
1253
1329
  storageKey: z,
1254
1330
  storageLocation: u,
1255
1331
  children: /* @__PURE__ */ o(
1256
- To,
1332
+ zo,
1257
1333
  {
1258
1334
  clientId: T,
1259
1335
  config: O,
1260
1336
  defaultUserData: ge,
1261
- conversationIdProp: oe,
1337
+ conversationIdProp: ae,
1262
1338
  isOpen: ye,
1263
1339
  onUserApiChange: m,
1264
1340
  onToggle: ve,
1265
1341
  runtimeCapabilities: q,
1266
1342
  storageKey: z,
1267
1343
  storageLocation: u,
1268
- userToken: te?.userToken
1344
+ userToken: oe?.userToken
1269
1345
  }
1270
1346
  )
1271
1347
  }
1272
- ) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: le(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
1348
+ ) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhum clientId foi informado." }) }) : /* @__PURE__ */ o("div", { className: "bp-webchat-shell", style: ie(O), children: /* @__PURE__ */ o("div", { className: "bp-webchat-error", children: "Nenhuma URL publica do proxy do webchat foi informada." }) });
1273
1349
  }
1274
- function To({
1350
+ function zo({
1275
1351
  clientId: e,
1276
1352
  config: t,
1277
1353
  defaultUserData: a,
@@ -1284,8 +1360,8 @@ function To({
1284
1360
  storageLocation: w,
1285
1361
  userToken: m
1286
1362
  }) {
1287
- const b = C(
1288
- () => Mo({
1363
+ const b = k(
1364
+ () => Lo({
1289
1365
  showWelcomeScreen: t.showWelcomeScreen,
1290
1366
  storageKey: u,
1291
1367
  storageLocation: w,
@@ -1299,147 +1375,215 @@ function To({
1299
1375
  w,
1300
1376
  m
1301
1377
  ]
1302
- ), [U, f] = S(!1), [B, F] = S({ open: !1, messageId: null, draft: "" }), [{ isPanelMounted: Y, isPanelVisible: _ }, V] = Ge(So, {
1303
- isPanelMounted: s,
1304
- isPanelVisible: s
1305
- }), {
1306
- conversationId: j,
1307
- isTyping: W,
1308
- messages: x,
1378
+ ), [U, f] = S(!1), [B, F] = S({
1379
+ open: !1,
1380
+ messageId: null,
1381
+ draft: ""
1382
+ }), [{ isPanelMounted: Q, isPanelVisible: _ }, V] = st(
1383
+ _o,
1384
+ {
1385
+ isPanelMounted: s,
1386
+ isPanelVisible: s
1387
+ }
1388
+ ), {
1389
+ conversationId: W,
1390
+ isTyping: G,
1391
+ messages: N,
1309
1392
  saveMessageFeedback: d,
1310
1393
  sendMessage: p,
1311
1394
  status: R,
1312
- uploadFile: Q
1313
- } = Ye(), { openConversation: y, listConversations: ie } = Qe(), { updateUser: T, userCredentials: P } = et(), z = Z({}), [G, D] = S(() => b.activeView), [ge, E] = S(() => b.historyReturnView), { conversations: re, isLoading: ee, refresh: K } = tt({
1395
+ uploadFile: ee
1396
+ } = ut(), { openConversation: y, listConversations: de } = bt(), { updateUser: T, userCredentials: P } = ht(), z = Y({}), [K, D] = S(
1397
+ () => b.activeView
1398
+ ), [ge, E] = S(
1399
+ () => b.historyReturnView
1400
+ ), {
1401
+ conversations: se,
1402
+ isLoading: te,
1403
+ refresh: J
1404
+ } = pt({
1314
1405
  userCredentials: P,
1315
- listConversations: ie,
1406
+ listConversations: de,
1316
1407
  clientId: e
1317
- }), te = C(
1318
- () => Co(a),
1408
+ }), oe = k(
1409
+ () => Ro(a),
1319
1410
  [a]
1320
- ), O = ce(
1321
- async (I = {}) => {
1411
+ ), O = le(
1412
+ async (h = {}) => {
1322
1413
  if (!T)
1323
1414
  return;
1324
- const h = {
1325
- ...ne(a) || {},
1415
+ const j = {
1416
+ ...re(a) || {},
1326
1417
  ...z.current,
1327
- ...ne(I) || {}
1418
+ ...re(h) || {}
1328
1419
  };
1329
- return z.current = h, T(Io(h));
1420
+ return z.current = j, T($o(j));
1330
1421
  },
1331
1422
  [a, T]
1332
- ), oe = Z(O);
1423
+ ), ae = Y(O);
1333
1424
  M(() => {
1334
- oe.current = O;
1425
+ ae.current = O;
1335
1426
  }, [O]);
1336
1427
  const $ = !!T;
1337
1428
  M(() => {
1338
1429
  z.current = {};
1339
- }, [te]), M(() => {
1430
+ }, [oe]), M(() => {
1340
1431
  if (n)
1341
1432
  return n({
1342
- updateUserData: $ ? (I) => oe.current(I) : void 0
1433
+ updateUserData: $ ? (h) => ae.current(h) : void 0
1343
1434
  }), () => n(null);
1344
1435
  }, [n, $]), M(() => {
1345
- !$ || !te || oe.current();
1346
- }, [te, $]), M(() => {
1436
+ !$ || !oe || ae.current();
1437
+ }, [oe, $]), M(() => {
1347
1438
  i.allowMessageFeedback || F({ open: !1, messageId: null, draft: "" });
1348
1439
  }, [i.allowMessageFeedback]);
1349
- const { showInitialLoading: ye, setShowInitialLoading: J } = no({
1350
- activeView: G,
1440
+ const { showInitialLoading: ye, setShowInitialLoading: X } = fo({
1441
+ activeView: K,
1351
1442
  clientState: R,
1352
- conversationId: j,
1353
- messagesLength: x.length
1354
- }), se = C(
1355
- () => t.botAvatar || Qt({ name: t.botName, backgroundColor: t.accentColor }),
1443
+ conversationId: W,
1444
+ messagesLength: N.length
1445
+ }), ce = k(
1446
+ () => t.botAvatar || bo({
1447
+ name: t.botName,
1448
+ backgroundColor: t.accentColor
1449
+ }),
1356
1450
  [t.accentColor, t.botAvatar, t.botName]
1357
- ), q = C(
1358
- () => ({ ...t, botAvatar: se }),
1359
- [t, se]
1360
- ), ae = ce(
1361
- async (I) => {
1362
- E(I), D("conversations"), await K();
1451
+ ), q = k(
1452
+ () => ({ ...t, botAvatar: ce }),
1453
+ [t, ce]
1454
+ ), ne = le(
1455
+ async (h) => {
1456
+ E(h), D("conversations"), await J();
1363
1457
  },
1364
- [K]
1365
- ), ve = ce(
1366
- (I) => {
1367
- J(!0), y(I), D("chat");
1458
+ [J]
1459
+ ), ve = le(
1460
+ (h) => {
1461
+ X(!0), y(h), D("chat");
1368
1462
  },
1369
- [y, J]
1370
- ), de = ce(() => {
1371
- J(!0), y(), D("chat");
1372
- }, [y, J]), Ce = C(
1373
- () => ao({
1374
- messages: x,
1463
+ [y, X]
1464
+ ), ue = le(() => {
1465
+ X(!0), y(), D("chat");
1466
+ }, [y, X]), Ce = k(
1467
+ () => wo({
1468
+ messages: N,
1375
1469
  user: P,
1376
1470
  botName: q.botName,
1377
1471
  botAvatar: q.botAvatar
1378
1472
  }),
1379
- [x, q.botAvatar, q.botName, P]
1380
- ), N = le(t), v = C(() => dt(t), [t]), H = C(() => Ot(t.fabChatIconVariant), [t.fabChatIconVariant]);
1473
+ [N, q.botAvatar, q.botName, P]
1474
+ ), I = ie(t), v = k(() => Bt(t), [t]), H = k(
1475
+ () => to(t.fabChatIconVariant),
1476
+ [t.fabChatIconVariant]
1477
+ );
1381
1478
  M(() => {
1382
1479
  if (s) {
1383
1480
  V({ type: "show" });
1384
- const be = window.requestAnimationFrame(() => V({ type: "visible" }));
1481
+ const be = window.requestAnimationFrame(
1482
+ () => V({ type: "visible" })
1483
+ );
1385
1484
  return () => window.cancelAnimationFrame(be);
1386
1485
  }
1387
1486
  V({ type: "hide" });
1388
- const I = window.setTimeout(() => {
1487
+ const h = window.setTimeout(() => {
1389
1488
  f(!1), F({ open: !1, messageId: null, draft: "" });
1390
- }, 0), h = window.setTimeout(() => V({ type: "unmount" }), mo);
1489
+ }, 0), j = window.setTimeout(
1490
+ () => V({ type: "unmount" }),
1491
+ Mo
1492
+ );
1391
1493
  return () => {
1392
- window.clearTimeout(I), window.clearTimeout(h);
1494
+ window.clearTimeout(h), window.clearTimeout(j);
1393
1495
  };
1394
1496
  }, [s]), M(() => {
1395
1497
  if (b.bootstrapView === "pending") {
1396
- if (x.length > 0) {
1397
- const I = window.setTimeout(() => {
1498
+ if (N.length > 0) {
1499
+ const h = window.setTimeout(() => {
1398
1500
  D("chat"), E("chat");
1399
1501
  }, 0);
1400
- return () => window.clearTimeout(I);
1502
+ return () => window.clearTimeout(h);
1401
1503
  }
1402
1504
  if (R !== "connecting") {
1403
- const I = window.setTimeout(() => {
1505
+ const h = window.setTimeout(() => {
1404
1506
  D("home"), E("home");
1405
1507
  }, 0);
1406
- return () => window.clearTimeout(I);
1508
+ return () => window.clearTimeout(h);
1407
1509
  }
1408
1510
  }
1409
- }, [R, b.bootstrapView, x.length]);
1410
- const g = C(
1411
- () => function(h) {
1412
- const be = i.allowMessageFeedback && h.direction === "incoming" && typeof h.addMessageFeedback == "function", We = {
1413
- ...h.block,
1414
- direction: h.direction,
1415
- sender: h.sender,
1416
- timestamp: h.timestamp,
1417
- messageId: h.messageId,
1418
- metadata: h.metadata,
1419
- isReadOnly: h.isReadOnly,
1420
- status: h.status,
1421
- feedback: h.feedback,
1422
- sendMessage: h.sendMessage,
1423
- addMessageFeedback: h.addMessageFeedback
1511
+ }, [R, b.bootstrapView, N.length]);
1512
+ const C = k(() => {
1513
+ const h = {};
1514
+ h.dropdown = ko;
1515
+ const j = (be, g) => function({
1516
+ blocks: ke,
1517
+ horizontalAlignment: Je,
1518
+ verticalAlignment: Xe,
1519
+ direction: Ze,
1520
+ sender: Ye,
1521
+ timestamp: Qe,
1522
+ metadata: et,
1523
+ messageId: tt,
1524
+ isReadOnly: ot,
1525
+ sendMessage: at
1526
+ }) {
1527
+ return /* @__PURE__ */ o(
1528
+ "div",
1529
+ {
1530
+ className: be,
1531
+ "data-horizontal": Je,
1532
+ "data-vertical": Xe,
1533
+ children: ke.map((nt, rt) => /* @__PURE__ */ o(
1534
+ Te,
1535
+ {
1536
+ block: {
1537
+ ...nt,
1538
+ direction: Ze,
1539
+ timestamp: Qe,
1540
+ sender: Ye,
1541
+ messageId: tt,
1542
+ isReadOnly: ot,
1543
+ sendMessage: at,
1544
+ ...g ? { metadata: et } : {}
1545
+ },
1546
+ renderers: h
1547
+ },
1548
+ rt
1549
+ ))
1550
+ }
1551
+ );
1552
+ };
1553
+ return h.column = j("bpMessageBlocksColumn", !1), h.row = j("bpMessageBlocksRow", !0), h.bubble = function(g) {
1554
+ const Be = i.allowMessageFeedback && g.direction === "incoming" && typeof g.addMessageFeedback == "function", ke = {
1555
+ ...g.block,
1556
+ direction: g.direction,
1557
+ sender: g.sender,
1558
+ timestamp: g.timestamp,
1559
+ messageId: g.messageId,
1560
+ metadata: g.metadata,
1561
+ isReadOnly: g.isReadOnly,
1562
+ status: g.status,
1563
+ feedback: g.feedback,
1564
+ sendMessage: g.sendMessage,
1565
+ addMessageFeedback: g.addMessageFeedback
1424
1566
  };
1425
1567
  return /* @__PURE__ */ l(
1426
1568
  "div",
1427
1569
  {
1428
1570
  className: "bpMessageBlocksBubble",
1429
- "data-direction": h.direction,
1430
- "data-feedback": be || void 0,
1571
+ "data-direction": g.direction,
1572
+ "data-feedback": Be || void 0,
1431
1573
  children: [
1432
- /* @__PURE__ */ o(ot, { block: We }),
1433
- be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
1574
+ /* @__PURE__ */ o(Te, { block: ke, renderers: h }),
1575
+ Be ? /* @__PURE__ */ l("div", { className: "bpMessageBlocksBubbleFeedbackContainer", children: [
1434
1576
  /* @__PURE__ */ o(
1435
1577
  "button",
1436
1578
  {
1437
1579
  className: "bpMessageBlocksBubbleFeedbackIcon",
1438
1580
  type: "button",
1439
- "data-selected": h.feedback === "positive",
1581
+ "data-selected": g.feedback === "positive",
1440
1582
  "aria-label": "Feedback positivo",
1441
- onClick: () => h.addMessageFeedback(h.messageId, { value: "positive" }),
1442
- children: Wt
1583
+ onClick: () => g.addMessageFeedback(g.messageId, {
1584
+ value: "positive"
1585
+ }),
1586
+ children: no
1443
1587
  }
1444
1588
  ),
1445
1589
  /* @__PURE__ */ o(
@@ -1447,110 +1591,121 @@ function To({
1447
1591
  {
1448
1592
  className: "bpMessageBlocksBubbleFeedbackIcon",
1449
1593
  type: "button",
1450
- "data-selected": h.feedback === "negative",
1594
+ "data-selected": g.feedback === "negative",
1451
1595
  "aria-label": "Feedback negativo",
1452
1596
  onClick: () => F({
1453
1597
  open: !0,
1454
- messageId: h.messageId,
1598
+ messageId: g.messageId,
1455
1599
  draft: ""
1456
1600
  }),
1457
- children: Gt
1601
+ children: ro
1458
1602
  }
1459
1603
  )
1460
1604
  ] }) : null
1461
1605
  ]
1462
1606
  }
1463
1607
  );
1464
- },
1465
- [i.allowMessageFeedback]
1466
- ), ue = C(
1467
- () => ({ bubble: g, dropdown: uo }),
1468
- [g]
1469
- );
1608
+ }, h;
1609
+ }, [i.allowMessageFeedback]);
1470
1610
  return /* @__PURE__ */ l(
1471
1611
  "div",
1472
1612
  {
1473
1613
  className: "bp-webchat-shell",
1474
- "data-panel-mounted": Y,
1614
+ "data-panel-mounted": Q,
1475
1615
  "data-panel-open": _,
1476
- style: N,
1616
+ style: I,
1477
1617
  children: [
1478
- /* @__PURE__ */ o(at, { ...v }),
1479
- Y ? /* @__PURE__ */ o("div", { className: "bp-webchat-panel", "data-state": _ ? "open" : "closed", children: G === "home" ? /* @__PURE__ */ o(
1480
- po,
1618
+ /* @__PURE__ */ o(mt, { ...v }),
1619
+ Q ? /* @__PURE__ */ o(
1620
+ "div",
1481
1621
  {
1482
- config: q,
1483
- activeView: G,
1484
- onClose: c,
1485
- onShowHome: () => D("home"),
1486
- onShowConversations: () => ae("home"),
1487
- onStart: () => D("chat")
1488
- }
1489
- ) : G === "conversations" ? /* @__PURE__ */ o(
1490
- io,
1491
- {
1492
- conversations: re,
1493
- currentConversationId: j,
1494
- isLoading: ee,
1495
- botAvatar: q.botAvatar,
1496
- botName: q.botName,
1497
- onClose: () => D(ge),
1498
- onCloseWidget: c,
1499
- onShowHome: () => {
1500
- D("home"), E("home");
1501
- },
1502
- onShowConversations: K,
1503
- onNewConversation: de,
1504
- onConversationClick: ve
1505
- }
1506
- ) : G === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(ze, {}) }) : /* @__PURE__ */ l(Ve, { children: [
1507
- /* @__PURE__ */ o(
1508
- lo,
1509
- {
1510
- config: q,
1511
- allowFileUpload: i.allowFileUpload,
1512
- clientState: R,
1513
- isTyping: W,
1514
- messages: Ce,
1515
- renderers: ue,
1516
- sendMessage: p,
1517
- uploadFile: Q,
1518
- addMessageFeedback: i.allowMessageFeedback ? d : void 0,
1519
- showInitialLoading: ye,
1520
- onShowHome: t.showWelcomeScreen ? () => {
1521
- D("home"), E("home");
1522
- } : void 0,
1523
- onOpenHistory: () => ae("chat"),
1524
- onRestartConversation: () => f(!0),
1525
- onCloseWidget: c
1526
- }
1527
- ),
1528
- /* @__PURE__ */ o(
1529
- ho,
1530
- {
1531
- open: U,
1532
- onCancel: () => f(!1),
1533
- onConfirm: () => {
1534
- f(!1), de();
1622
+ className: "bp-webchat-panel",
1623
+ "data-state": _ ? "open" : "closed",
1624
+ children: K === "home" ? /* @__PURE__ */ o(
1625
+ Io,
1626
+ {
1627
+ config: q,
1628
+ activeView: K,
1629
+ onClose: c,
1630
+ onShowHome: () => D("home"),
1631
+ onShowConversations: () => ne("home"),
1632
+ onStart: () => D("chat")
1535
1633
  }
1536
- }
1537
- ),
1538
- i.allowMessageFeedback ? /* @__PURE__ */ o(
1539
- bo,
1540
- {
1541
- open: B.open,
1542
- draft: B.draft,
1543
- setDraft: (I) => F((h) => ({ ...h, draft: I })),
1544
- onCancel: () => F({ open: !1, messageId: null, draft: "" }),
1545
- onConfirm: async () => {
1546
- B.messageId && d && await d(B.messageId, {
1547
- value: "negative",
1548
- comment: B.draft
1549
- }), F({ open: !1, messageId: null, draft: "" });
1634
+ ) : K === "conversations" ? /* @__PURE__ */ o(
1635
+ Bo,
1636
+ {
1637
+ conversations: se,
1638
+ currentConversationId: W,
1639
+ isLoading: te,
1640
+ botAvatar: q.botAvatar,
1641
+ botName: q.botName,
1642
+ onClose: () => D(ge),
1643
+ onCloseWidget: c,
1644
+ onShowHome: () => {
1645
+ D("home"), E("home");
1646
+ },
1647
+ onShowConversations: J,
1648
+ onNewConversation: ue,
1649
+ onConversationClick: ve
1550
1650
  }
1551
- }
1552
- ) : null
1553
- ] }) }) : null,
1651
+ ) : K === "pending" ? /* @__PURE__ */ o("div", { className: "bp-webchat-layout", children: /* @__PURE__ */ o(qe, {}) }) : /* @__PURE__ */ l(Fe, { children: [
1652
+ /* @__PURE__ */ o(
1653
+ Co,
1654
+ {
1655
+ config: q,
1656
+ allowFileUpload: i.allowFileUpload,
1657
+ clientState: R,
1658
+ isTyping: G,
1659
+ messages: Ce,
1660
+ renderers: C,
1661
+ sendMessage: p,
1662
+ uploadFile: ee,
1663
+ addMessageFeedback: i.allowMessageFeedback ? d : void 0,
1664
+ showInitialLoading: ye,
1665
+ onShowHome: t.showWelcomeScreen ? () => {
1666
+ D("home"), E("home");
1667
+ } : void 0,
1668
+ onOpenHistory: () => ne("chat"),
1669
+ onRestartConversation: () => f(!0),
1670
+ onCloseWidget: c
1671
+ }
1672
+ ),
1673
+ /* @__PURE__ */ o(
1674
+ No,
1675
+ {
1676
+ open: U,
1677
+ onCancel: () => f(!1),
1678
+ onConfirm: () => {
1679
+ f(!1), ue();
1680
+ }
1681
+ }
1682
+ ),
1683
+ i.allowMessageFeedback ? /* @__PURE__ */ o(
1684
+ xo,
1685
+ {
1686
+ open: B.open,
1687
+ draft: B.draft,
1688
+ setDraft: (h) => F((j) => ({ ...j, draft: h })),
1689
+ onCancel: () => F({
1690
+ open: !1,
1691
+ messageId: null,
1692
+ draft: ""
1693
+ }),
1694
+ onConfirm: async () => {
1695
+ B.messageId && d && await d(B.messageId, {
1696
+ value: "negative",
1697
+ comment: B.draft
1698
+ }), F({
1699
+ open: !1,
1700
+ messageId: null,
1701
+ draft: ""
1702
+ });
1703
+ }
1704
+ }
1705
+ ) : null
1706
+ ] })
1707
+ }
1708
+ ) : null,
1554
1709
  /* @__PURE__ */ l(
1555
1710
  "button",
1556
1711
  {
@@ -1561,7 +1716,7 @@ function To({
1561
1716
  "aria-label": s ? "Fechar webchat" : "Abrir webchat",
1562
1717
  children: [
1563
1718
  /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--chat", children: H }),
1564
- /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children: Et })
1719
+ /* @__PURE__ */ o("span", { className: "bp-webchat-fab-icon bp-webchat-fab-icon--close", children: eo })
1565
1720
  ]
1566
1721
  }
1567
1722
  )
@@ -1570,9 +1725,9 @@ function To({
1570
1725
  );
1571
1726
  }
1572
1727
  export {
1573
- Ro as Webchat,
1574
- X as defaultConfig,
1728
+ jo as Webchat,
1729
+ Z as defaultConfig,
1575
1730
  me as getContrastingTextColor,
1576
- le as getShellStyle,
1577
- it as normalizeConfig
1731
+ ie as getShellStyle,
1732
+ Ct as normalizeConfig
1578
1733
  };