@rqmii_immersive/agent-react-sdk 5.3.2 → 5.3.3
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/dist/embed.js +2 -2
- package/dist/embed.js.map +1 -1
- package/dist/hooks/use-rqmii-connection.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/ui/agent-data.d.ts.map +1 -1
- package/dist/ui.cjs +3 -3
- package/dist/ui.cjs.map +1 -1
- package/dist/ui.js +214 -206
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
package/dist/ui.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { A as oe, u as fa, g as Oe, j as de, h as ue, i as ta, l as na, k as ia, R as va, c as ya } from "./RqmiiCloudAvatarPlayer-Bi44g7bl.js";
|
|
2
2
|
import { E as ri, d as si } from "./RqmiiCloudAvatarPlayer-Bi44g7bl.js";
|
|
3
3
|
import { jsx as n, jsxs as f, Fragment as Ve } from "react/jsx-runtime";
|
|
4
|
-
import j, { useContext as Fa, createContext as Ea, forwardRef as oa, createElement as Pe, useState as
|
|
4
|
+
import j, { useContext as Fa, createContext as Ea, forwardRef as oa, createElement as Pe, useState as v, useEffect as D, useRef as _, useLayoutEffect as Ye, useCallback as re, useMemo as te } from "react";
|
|
5
5
|
const Ta = {
|
|
6
6
|
sendMessage: "Stuur 'n boodskap",
|
|
7
7
|
send: "Stuur",
|
|
@@ -2769,20 +2769,27 @@ const $e = {
|
|
|
2769
2769
|
useVoice: !1,
|
|
2770
2770
|
faceIndex: 1,
|
|
2771
2771
|
faceImageUrl: null,
|
|
2772
|
-
languages: ["
|
|
2773
|
-
defaultLanguage: "
|
|
2772
|
+
languages: ["ar-sa"],
|
|
2773
|
+
defaultLanguage: "ar-sa",
|
|
2774
2774
|
allowInterrupt: !0,
|
|
2775
2775
|
allowWelcomeMessageInterrupt: !1,
|
|
2776
2776
|
welcomeMessages: {},
|
|
2777
|
-
conversation: { default_language: "
|
|
2777
|
+
conversation: { default_language: "ar-sa", languages: ["ar-sa"], suggested_messages: {} },
|
|
2778
2778
|
widget: {
|
|
2779
2779
|
appearance: { brand_color: null, position: "right", show_branding: !0, footer_content: {} },
|
|
2780
|
-
behavior: {
|
|
2780
|
+
behavior: {
|
|
2781
|
+
post_chat_rating_enabled: !1,
|
|
2782
|
+
welcome_bubble_enabled: !1,
|
|
2783
|
+
welcome_bubble_delay_seconds: 3,
|
|
2784
|
+
welcome_bubble_sound_enabled: !1,
|
|
2785
|
+
typing_indicator_enabled: !0,
|
|
2786
|
+
suggested_messages: {}
|
|
2787
|
+
}
|
|
2781
2788
|
}
|
|
2782
2789
|
};
|
|
2783
2790
|
function ge(e) {
|
|
2784
2791
|
if (!e) return $e;
|
|
2785
|
-
const a = e, t = a.agent_type || a.agentType || oe.TEXT, i = typeof a.use_text == "boolean" ? a.use_text : typeof a.useText == "boolean" ? a.useText : t !== oe.VOICE, r = typeof a.use_voice == "boolean" ? a.use_voice : typeof a.useVoice == "boolean" ? a.useVoice : t === oe.TEXT_AND_VOICE || t === oe.CLOUD_AVATAR || t === oe.DESKTOP_AVATAR, o = a.conversation || a.agent_customization?.conversation || {}, s = a.speech || a.agent_customization?.speech || {}, c = o.default_language || "
|
|
2792
|
+
const a = e, t = a.agent_type || a.agentType || oe.TEXT, i = typeof a.use_text == "boolean" ? a.use_text : typeof a.useText == "boolean" ? a.useText : t !== oe.VOICE, r = typeof a.use_voice == "boolean" ? a.use_voice : typeof a.useVoice == "boolean" ? a.useVoice : t === oe.TEXT_AND_VOICE || t === oe.CLOUD_AVATAR || t === oe.DESKTOP_AVATAR, o = a.conversation || a.agent_customization?.conversation || {}, s = a.speech || a.agent_customization?.speech || {}, c = o.default_language || "ar-sa", d = pe(o.languages, c), l = a.widget || a.agent_customization?.widget || null, m = l?.appearance, u = l?.behavior, h = l, T = typeof m?.hide_branding == "boolean" ? !m.hide_branding : typeof m?.show_branding == "boolean" ? m.show_branding : !0, b = u?.suggested_messages || l?.suggested_messages || o.suggested_messages || o.suggestedMessages || {}, x = h ? {
|
|
2786
2793
|
appearance: {
|
|
2787
2794
|
brand_color: m?.brand_color,
|
|
2788
2795
|
position: m?.position || "right",
|
|
@@ -2794,11 +2801,12 @@ function ge(e) {
|
|
|
2794
2801
|
welcome_bubble_enabled: typeof u?.welcome_bubble_enabled == "boolean" ? u.welcome_bubble_enabled : !1,
|
|
2795
2802
|
welcome_bubble_delay_seconds: typeof u?.welcome_bubble_delay_seconds == "number" ? u.welcome_bubble_delay_seconds : 3,
|
|
2796
2803
|
welcome_bubble_sound_enabled: typeof u?.welcome_bubble_sound_enabled == "boolean" ? u.welcome_bubble_sound_enabled : !1,
|
|
2797
|
-
typing_indicator_enabled: typeof u?.typing_indicator_enabled == "boolean" ? u.typing_indicator_enabled : !0
|
|
2804
|
+
typing_indicator_enabled: typeof u?.typing_indicator_enabled == "boolean" ? u.typing_indicator_enabled : !0,
|
|
2805
|
+
suggested_messages: b
|
|
2798
2806
|
}
|
|
2799
|
-
} : void 0,
|
|
2800
|
-
Object.entries(
|
|
2801
|
-
),
|
|
2807
|
+
} : void 0, y = a.consent || a.consent_config || null, E = o.welcome_message || o.welcomeMessage || a.welcome_message || a.welcomeMessage || {}, g = Object.fromEntries(
|
|
2808
|
+
Object.entries(E).filter(([, z]) => typeof z == "string").map(([z, S]) => [z, S.slice(0, 1e3)])
|
|
2809
|
+
), k = typeof a.allow_interrupt == "boolean" ? a.allow_interrupt : typeof s.allow_interrupt == "boolean" ? s.allow_interrupt : !0, p = typeof a.allow_welcome_message_interrupt == "boolean" ? a.allow_welcome_message_interrupt : typeof s.allow_welcome_message_interrupt == "boolean" ? s.allow_welcome_message_interrupt : !1;
|
|
2802
2810
|
return {
|
|
2803
2811
|
id: a.id || null,
|
|
2804
2812
|
name: a.name || $e.name,
|
|
@@ -2807,25 +2815,25 @@ function ge(e) {
|
|
|
2807
2815
|
useVoice: r,
|
|
2808
2816
|
faceIndex: typeof a.face_index == "number" ? a.face_index : typeof a.faceIndex == "number" ? a.faceIndex : 1,
|
|
2809
2817
|
faceImageUrl: a.face_image_url || a.faceImageUrl || null,
|
|
2810
|
-
allowInterrupt:
|
|
2811
|
-
allowWelcomeMessageInterrupt:
|
|
2812
|
-
welcomeMessages:
|
|
2818
|
+
allowInterrupt: k,
|
|
2819
|
+
allowWelcomeMessageInterrupt: p,
|
|
2820
|
+
welcomeMessages: g,
|
|
2813
2821
|
languages: d,
|
|
2814
2822
|
defaultLanguage: d.includes(c) ? c : d[0],
|
|
2815
2823
|
conversation: {
|
|
2816
2824
|
default_language: c,
|
|
2817
2825
|
languages: d,
|
|
2818
|
-
suggested_messages:
|
|
2826
|
+
suggested_messages: b
|
|
2819
2827
|
},
|
|
2820
|
-
widget:
|
|
2821
|
-
consent:
|
|
2822
|
-
enabled:
|
|
2823
|
-
title:
|
|
2824
|
-
body:
|
|
2825
|
-
acceptLabel:
|
|
2826
|
-
declineLabel:
|
|
2827
|
-
termsUrl:
|
|
2828
|
-
privacyUrl:
|
|
2828
|
+
widget: x || void 0,
|
|
2829
|
+
consent: y ? {
|
|
2830
|
+
enabled: y.enabled ?? !1,
|
|
2831
|
+
title: y.title || void 0,
|
|
2832
|
+
body: y.body || void 0,
|
|
2833
|
+
acceptLabel: y.accept_label || y.acceptLabel || void 0,
|
|
2834
|
+
declineLabel: y.decline_label || y.declineLabel || void 0,
|
|
2835
|
+
termsUrl: y.terms_url || y.termsUrl || void 0,
|
|
2836
|
+
privacyUrl: y.privacy_url || y.privacyUrl || void 0
|
|
2829
2837
|
} : void 0
|
|
2830
2838
|
};
|
|
2831
2839
|
}
|
|
@@ -2972,7 +2980,7 @@ const jt = (e) => {
|
|
|
2972
2980
|
absoluteStrokeWidth: u = !1,
|
|
2973
2981
|
color: h = "currentColor",
|
|
2974
2982
|
className: T = ""
|
|
2975
|
-
} = Dt() ?? {},
|
|
2983
|
+
} = Dt() ?? {}, b = i ?? u ? Number(t ?? m) * 24 / Number(a ?? l) : t ?? m;
|
|
2976
2984
|
return Pe(
|
|
2977
2985
|
"svg",
|
|
2978
2986
|
{
|
|
@@ -2981,13 +2989,13 @@ const jt = (e) => {
|
|
|
2981
2989
|
width: a ?? l ?? Me.width,
|
|
2982
2990
|
height: a ?? l ?? Me.height,
|
|
2983
2991
|
stroke: e ?? h,
|
|
2984
|
-
strokeWidth:
|
|
2992
|
+
strokeWidth: b,
|
|
2985
2993
|
className: ra("lucide", T, r),
|
|
2986
2994
|
...!o && !jt(c) && { "aria-hidden": "true" },
|
|
2987
2995
|
...c
|
|
2988
2996
|
},
|
|
2989
2997
|
[
|
|
2990
|
-
...s.map(([
|
|
2998
|
+
...s.map(([x, y]) => Pe(x, y)),
|
|
2991
2999
|
...Array.isArray(o) ? o : [o]
|
|
2992
3000
|
]
|
|
2993
3001
|
);
|
|
@@ -3209,7 +3217,7 @@ function Ne(e) {
|
|
|
3209
3217
|
return `${a}:${t}`;
|
|
3210
3218
|
}
|
|
3211
3219
|
function sn(e = !0) {
|
|
3212
|
-
const [a, t] =
|
|
3220
|
+
const [a, t] = v(0);
|
|
3213
3221
|
return D(() => {
|
|
3214
3222
|
if (!e) return;
|
|
3215
3223
|
const i = setInterval(() => t((r) => r + 1), 1e3);
|
|
@@ -3217,7 +3225,7 @@ function sn(e = !0) {
|
|
|
3217
3225
|
}, [e]), a;
|
|
3218
3226
|
}
|
|
3219
3227
|
function ln() {
|
|
3220
|
-
const [e, a] =
|
|
3228
|
+
const [e, a] = v(null);
|
|
3221
3229
|
return D(() => {
|
|
3222
3230
|
const t = window.visualViewport;
|
|
3223
3231
|
if (!t) return;
|
|
@@ -3230,7 +3238,7 @@ function ln() {
|
|
|
3230
3238
|
function cn(e, a) {
|
|
3231
3239
|
const t = _([]);
|
|
3232
3240
|
t.current = e.match(/\S+\s*/g) || [e];
|
|
3233
|
-
const [i, r] =
|
|
3241
|
+
const [i, r] = v(
|
|
3234
3242
|
() => a ? Math.min(1, t.current.length) : t.current.length
|
|
3235
3243
|
);
|
|
3236
3244
|
return D(() => {
|
|
@@ -3250,7 +3258,7 @@ function un(e) {
|
|
|
3250
3258
|
return e?.faceIndex === 0 && e.faceImageUrl ? e.faceImageUrl : e?.faceIndex === 9 ? null : on(e?.faceIndex || 1);
|
|
3251
3259
|
}
|
|
3252
3260
|
const _e = j.memo(function({ language: a, languages: t, onChange: i }) {
|
|
3253
|
-
const [r, o] =
|
|
3261
|
+
const [r, o] = v(!1), s = _(null), c = We(a), d = pe(t, a).map((l) => We(l)).filter(Boolean);
|
|
3254
3262
|
return D(() => {
|
|
3255
3263
|
if (!r) return;
|
|
3256
3264
|
const l = (m) => {
|
|
@@ -3285,7 +3293,7 @@ const _e = j.memo(function({ language: a, languages: t, onChange: i }) {
|
|
|
3285
3293
|
c && /* @__PURE__ */ n("p", { children: s })
|
|
3286
3294
|
] });
|
|
3287
3295
|
}), J = j.memo(function({ agent: a, size: t = "large", active: i = !1, className: r = "" }) {
|
|
3288
|
-
const o = a?.faceIndex === 9, [s, c] =
|
|
3296
|
+
const o = a?.faceIndex === 9, [s, c] = v(null), [d, l] = v(!s);
|
|
3289
3297
|
return D(() => {
|
|
3290
3298
|
let m = !1;
|
|
3291
3299
|
const u = un(a);
|
|
@@ -3318,7 +3326,7 @@ function mn() {
|
|
|
3318
3326
|
}
|
|
3319
3327
|
}
|
|
3320
3328
|
const hn = j.memo(function({ message: a, delaySeconds: t, soundEnabled: i, language: r, buttonPosition: o = "right", onClick: s }) {
|
|
3321
|
-
const [c, d] =
|
|
3329
|
+
const [c, d] = v(!1), l = a.trim();
|
|
3322
3330
|
return D(() => {
|
|
3323
3331
|
if (!l) return;
|
|
3324
3332
|
const u = setTimeout(() => {
|
|
@@ -3337,7 +3345,7 @@ const hn = j.memo(function({ message: a, delaySeconds: t, soundEnabled: i, langu
|
|
|
3337
3345
|
}
|
|
3338
3346
|
);
|
|
3339
3347
|
}), Te = j.memo(function({ language: a, placeholder: t, onSend: i, disabled: r = !1, variant: o = "text" }) {
|
|
3340
|
-
const [s, c] =
|
|
3348
|
+
const [s, c] = v(""), d = _(null), l = 168, m = () => {
|
|
3341
3349
|
const u = s.trim();
|
|
3342
3350
|
!u || r || (i(u), c(""), d.current && (d.current.style.height = "auto"));
|
|
3343
3351
|
};
|
|
@@ -3386,20 +3394,20 @@ function aa(e, a, t, i) {
|
|
|
3386
3394
|
}
|
|
3387
3395
|
}
|
|
3388
3396
|
const Fn = j.memo(function({ suggestions: a, language: t, onClick: i }) {
|
|
3389
|
-
const [r, o] =
|
|
3390
|
-
E.forEach((
|
|
3391
|
-
|
|
3397
|
+
const [r, o] = v(!1), [s, c] = v(!1), [d, l] = v(null), [m, u] = v(null), h = _(null), T = _([]), b = se(t || "en"), x = vn(b), y = (E) => {
|
|
3398
|
+
E.forEach((g) => {
|
|
3399
|
+
g && (g.style.maxWidth = "", g.style.marginRight = "", g.style.marginLeft = "");
|
|
3392
3400
|
});
|
|
3393
3401
|
};
|
|
3394
3402
|
return Ye(() => {
|
|
3395
3403
|
const E = h.current;
|
|
3396
3404
|
if (!E || r) return;
|
|
3397
|
-
const
|
|
3398
|
-
const
|
|
3399
|
-
|
|
3405
|
+
const g = () => {
|
|
3406
|
+
const p = T.current;
|
|
3407
|
+
y(p);
|
|
3400
3408
|
const z = E.clientWidth, S = fn(), M = () => {
|
|
3401
|
-
for (let L = 0; L <
|
|
3402
|
-
const A =
|
|
3409
|
+
for (let L = 0; L < p.length; L++) {
|
|
3410
|
+
const A = p[L];
|
|
3403
3411
|
if (A && A.offsetTop + A.offsetHeight > S + 0.5)
|
|
3404
3412
|
return L;
|
|
3405
3413
|
}
|
|
@@ -3407,59 +3415,59 @@ const Fn = j.memo(function({ suggestions: a, language: t, onClick: i }) {
|
|
|
3407
3415
|
};
|
|
3408
3416
|
let P = M();
|
|
3409
3417
|
if (P !== null)
|
|
3410
|
-
for (let L = 0; L <=
|
|
3411
|
-
|
|
3412
|
-
const A =
|
|
3413
|
-
aa(A, z,
|
|
3418
|
+
for (let L = 0; L <= p.length; L++) {
|
|
3419
|
+
y(p);
|
|
3420
|
+
const A = p.slice(0, P).filter((I) => !!I);
|
|
3421
|
+
aa(A, z, x, ea);
|
|
3414
3422
|
const C = M();
|
|
3415
3423
|
if (C === null || C >= P) break;
|
|
3416
3424
|
P = C;
|
|
3417
3425
|
}
|
|
3418
3426
|
if (l(P), c(P !== null), P !== null) {
|
|
3419
|
-
const L =
|
|
3427
|
+
const L = p.slice(0, P).filter((C) => !!C), A = L.length ? Math.max(...L.map((C) => C.offsetTop + C.offsetHeight)) : he;
|
|
3420
3428
|
u(A - he);
|
|
3421
3429
|
} else
|
|
3422
3430
|
u(null);
|
|
3423
3431
|
};
|
|
3424
|
-
|
|
3425
|
-
const
|
|
3426
|
-
return
|
|
3427
|
-
|
|
3432
|
+
g();
|
|
3433
|
+
const k = typeof ResizeObserver < "u" ? new ResizeObserver(g) : null;
|
|
3434
|
+
return k?.observe(E), () => {
|
|
3435
|
+
k?.disconnect(), y(T.current);
|
|
3428
3436
|
};
|
|
3429
|
-
}, [a, r,
|
|
3437
|
+
}, [a, r, x]), Ye(() => {
|
|
3430
3438
|
const E = h.current;
|
|
3431
3439
|
if (!E || !r) return;
|
|
3432
|
-
const
|
|
3433
|
-
|
|
3434
|
-
const
|
|
3435
|
-
return u(
|
|
3436
|
-
|
|
3440
|
+
const g = T.current.filter((p) => !!p);
|
|
3441
|
+
y(T.current), aa(g, E.clientWidth, x, ea);
|
|
3442
|
+
const k = g.length ? Math.max(...g.map((p) => p.offsetTop + p.offsetHeight)) : he;
|
|
3443
|
+
return u(k - he), () => {
|
|
3444
|
+
y(T.current);
|
|
3437
3445
|
};
|
|
3438
|
-
}, [r, a,
|
|
3439
|
-
a.map((E,
|
|
3440
|
-
const
|
|
3446
|
+
}, [r, a, x]), a.length ? /* @__PURE__ */ n("div", { className: V("rqmii-suggested-messages", r && "is-expanded", s && "has-overflow"), dir: b, children: /* @__PURE__ */ f("div", { ref: h, className: V("rqmii-suggested-messages-inner", r ? "is-expanded" : "is-collapsed"), children: [
|
|
3447
|
+
a.map((E, g) => {
|
|
3448
|
+
const k = !r && d !== null && g >= d;
|
|
3441
3449
|
return /* @__PURE__ */ n(
|
|
3442
3450
|
"button",
|
|
3443
3451
|
{
|
|
3444
|
-
ref: (
|
|
3445
|
-
T.current[
|
|
3452
|
+
ref: (p) => {
|
|
3453
|
+
T.current[g] = p;
|
|
3446
3454
|
},
|
|
3447
3455
|
type: "button",
|
|
3448
3456
|
className: "rqmii-suggested-message",
|
|
3449
3457
|
onClick: () => i(E),
|
|
3450
|
-
style:
|
|
3451
|
-
"aria-hidden":
|
|
3452
|
-
tabIndex:
|
|
3458
|
+
style: k ? { visibility: "hidden" } : void 0,
|
|
3459
|
+
"aria-hidden": k || void 0,
|
|
3460
|
+
tabIndex: k ? -1 : void 0,
|
|
3453
3461
|
children: E
|
|
3454
3462
|
},
|
|
3455
|
-
|
|
3463
|
+
g
|
|
3456
3464
|
);
|
|
3457
3465
|
}),
|
|
3458
3466
|
s && /* @__PURE__ */ n(
|
|
3459
3467
|
"button",
|
|
3460
3468
|
{
|
|
3461
3469
|
type: "button",
|
|
3462
|
-
className: V("rqmii-suggested-messages-toggle",
|
|
3470
|
+
className: V("rqmii-suggested-messages-toggle", x === "left" && "is-start-left"),
|
|
3463
3471
|
style: m != null ? { top: m, bottom: "auto" } : void 0,
|
|
3464
3472
|
onClick: () => o((E) => (E && h.current && (h.current.scrollTop = 0), !E)),
|
|
3465
3473
|
"aria-label": r ? "Show less" : "Show more",
|
|
@@ -3485,15 +3493,15 @@ const zn = {
|
|
|
3485
3493
|
phone: "leadFormPhone",
|
|
3486
3494
|
message: "leadFormMessage"
|
|
3487
3495
|
}, Sn = j.memo(function({ messageId: a, form: t, language: i, textDirection: r, formSubmitted: o }) {
|
|
3488
|
-
const s = fa(), [c, d] =
|
|
3489
|
-
const
|
|
3490
|
-
return `${
|
|
3491
|
-
}, E = (
|
|
3492
|
-
d((z) => ({ ...z, [
|
|
3493
|
-
},
|
|
3494
|
-
if (
|
|
3496
|
+
const s = fa(), [c, d] = v({}), [l, m] = v(!1), [u, h] = v(!!o), [T, b] = v(null), x = t.title || F(i, "leadFormTitle"), y = (k) => {
|
|
3497
|
+
const p = zn[k.key];
|
|
3498
|
+
return `${p ? F(i, p) : k.label}${k.required ? "*" : ""}`;
|
|
3499
|
+
}, E = (k, p) => {
|
|
3500
|
+
d((z) => ({ ...z, [k]: p })), T && b(null);
|
|
3501
|
+
}, g = async (k) => {
|
|
3502
|
+
if (k.preventDefault(), l || u) return;
|
|
3495
3503
|
if (t.fields.some((S) => S.required && !c[S.key]?.trim())) {
|
|
3496
|
-
|
|
3504
|
+
b(F(i, "leadFormRequiredError"));
|
|
3497
3505
|
return;
|
|
3498
3506
|
}
|
|
3499
3507
|
const z = {};
|
|
@@ -3501,7 +3509,7 @@ const zn = {
|
|
|
3501
3509
|
const M = c[S.key]?.trim();
|
|
3502
3510
|
M && (z[S.key] = M);
|
|
3503
3511
|
}
|
|
3504
|
-
m(!0),
|
|
3512
|
+
m(!0), b(null);
|
|
3505
3513
|
try {
|
|
3506
3514
|
await s.submitLead({ agentId: t.agentId, collectedData: z }), h(!0), s.setMessages(
|
|
3507
3515
|
s.messages.map(
|
|
@@ -3509,37 +3517,37 @@ const zn = {
|
|
|
3509
3517
|
)
|
|
3510
3518
|
);
|
|
3511
3519
|
} catch (S) {
|
|
3512
|
-
|
|
3520
|
+
b(S?.message || F(i, "leadFormGenericError"));
|
|
3513
3521
|
} finally {
|
|
3514
3522
|
m(!1);
|
|
3515
3523
|
}
|
|
3516
3524
|
};
|
|
3517
|
-
return u ? /* @__PURE__ */ n("div", { className: "rqmii-chat-message-row rqmii-chat-lead-form-row", children: /* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form rqmii-chat-lead-form--done", dir: r, children: /* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form-success", children: F(i, "leadFormSuccess") }) }) }) : /* @__PURE__ */ n("div", { className: "rqmii-chat-message-row rqmii-chat-lead-form-row", children: /* @__PURE__ */ f("form", { className: "rqmii-chat-lead-form", dir: r, onSubmit:
|
|
3518
|
-
/* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form-title", children:
|
|
3519
|
-
t.fields.map((
|
|
3520
|
-
const
|
|
3521
|
-
return Tn(
|
|
3525
|
+
return u ? /* @__PURE__ */ n("div", { className: "rqmii-chat-message-row rqmii-chat-lead-form-row", children: /* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form rqmii-chat-lead-form--done", dir: r, children: /* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form-success", children: F(i, "leadFormSuccess") }) }) }) : /* @__PURE__ */ n("div", { className: "rqmii-chat-message-row rqmii-chat-lead-form-row", children: /* @__PURE__ */ f("form", { className: "rqmii-chat-lead-form", dir: r, onSubmit: g, children: [
|
|
3526
|
+
/* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form-title", children: x }),
|
|
3527
|
+
t.fields.map((k) => {
|
|
3528
|
+
const p = y(k), z = k.type === "email" ? "email" : k.type === "date" ? "date" : "text";
|
|
3529
|
+
return Tn(k.key) ? /* @__PURE__ */ n(
|
|
3522
3530
|
"textarea",
|
|
3523
3531
|
{
|
|
3524
3532
|
className: "rqmii-chat-lead-form-input rqmii-chat-lead-form-textarea",
|
|
3525
|
-
placeholder:
|
|
3526
|
-
value: c[
|
|
3527
|
-
onChange: (S) => E(
|
|
3533
|
+
placeholder: p,
|
|
3534
|
+
value: c[k.key] || "",
|
|
3535
|
+
onChange: (S) => E(k.key, S.target.value),
|
|
3528
3536
|
disabled: l,
|
|
3529
3537
|
rows: 4
|
|
3530
3538
|
},
|
|
3531
|
-
|
|
3539
|
+
k.key
|
|
3532
3540
|
) : /* @__PURE__ */ n(
|
|
3533
3541
|
"input",
|
|
3534
3542
|
{
|
|
3535
3543
|
className: "rqmii-chat-lead-form-input",
|
|
3536
3544
|
type: z,
|
|
3537
|
-
placeholder:
|
|
3538
|
-
value: c[
|
|
3539
|
-
onChange: (S) => E(
|
|
3545
|
+
placeholder: p,
|
|
3546
|
+
value: c[k.key] || "",
|
|
3547
|
+
onChange: (S) => E(k.key, S.target.value),
|
|
3540
3548
|
disabled: l
|
|
3541
3549
|
},
|
|
3542
|
-
|
|
3550
|
+
k.key
|
|
3543
3551
|
);
|
|
3544
3552
|
}),
|
|
3545
3553
|
T && /* @__PURE__ */ n("div", { className: "rqmii-chat-lead-form-error", children: T }),
|
|
@@ -3573,7 +3581,7 @@ const zn = {
|
|
|
3573
3581
|
] });
|
|
3574
3582
|
}), Mn = 5;
|
|
3575
3583
|
function da({ rating: e, onRate: a, readonly: t, size: i = 28 }) {
|
|
3576
|
-
const [r, o] =
|
|
3584
|
+
const [r, o] = v(0), s = r || e;
|
|
3577
3585
|
return /* @__PURE__ */ n("div", { className: "rqmii-chat-rating-stars", role: "radiogroup", children: Array.from({ length: Mn }, (c, d) => {
|
|
3578
3586
|
const l = d + 1, m = l <= s;
|
|
3579
3587
|
return /* @__PURE__ */ n(
|
|
@@ -3627,7 +3635,7 @@ function Cn({
|
|
|
3627
3635
|
onMinimize: r,
|
|
3628
3636
|
onSubmit: o
|
|
3629
3637
|
}) {
|
|
3630
|
-
const [s, c] =
|
|
3638
|
+
const [s, c] = v(""), [d, l] = v(!1), m = s.trim().length > 0 && !d, u = async () => {
|
|
3631
3639
|
if (m) {
|
|
3632
3640
|
l(!0);
|
|
3633
3641
|
try {
|
|
@@ -3670,14 +3678,14 @@ function be(e) {
|
|
|
3670
3678
|
bottom: 0
|
|
3671
3679
|
};
|
|
3672
3680
|
}
|
|
3673
|
-
const Ln = j.memo(function({ agent: a, language: t, languages: i, onLanguageChange: r, onClose: o, onSend: s, isVoiceEnabled: c = !1, isAudioPlaying: d = !1, isVoiceSetupLoading: l = !1, onStartVoice: m, visualViewportHeight: u, disabled: h = !1, error: T, suggestions:
|
|
3674
|
-
const E = be(u), [
|
|
3681
|
+
const Ln = j.memo(function({ agent: a, language: t, languages: i, onLanguageChange: r, onClose: o, onSend: s, isVoiceEnabled: c = !1, isAudioPlaying: d = !1, isVoiceSetupLoading: l = !1, onStartVoice: m, visualViewportHeight: u, disabled: h = !1, error: T, suggestions: b, onSuggestionClick: x, compact: y = !1 }) {
|
|
3682
|
+
const E = be(u), [g, k] = j.useState(we);
|
|
3675
3683
|
j.useEffect(() => {
|
|
3676
|
-
const M = () =>
|
|
3684
|
+
const M = () => k(we());
|
|
3677
3685
|
return window.addEventListener("resize", M), () => window.removeEventListener("resize", M);
|
|
3678
3686
|
}, []);
|
|
3679
|
-
const
|
|
3680
|
-
return /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--start",
|
|
3687
|
+
const p = y && !g, z = p ? "start" : "hero", S = b && b.length > 0;
|
|
3688
|
+
return /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--start", p && "rqmii-chat-panel--start-compact", H(t)), style: E, children: [
|
|
3681
3689
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-topbar", children: [
|
|
3682
3690
|
/* @__PURE__ */ n("span", {}),
|
|
3683
3691
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-topbar-actions", children: [
|
|
@@ -3686,14 +3694,14 @@ const Ln = j.memo(function({ agent: a, language: t, languages: i, onLanguageChan
|
|
|
3686
3694
|
] })
|
|
3687
3695
|
] }),
|
|
3688
3696
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-start-body", children: [
|
|
3689
|
-
c ? /* @__PURE__ */ f("div", { className: V("rqmii-chat-call-avatar-wrap",
|
|
3697
|
+
c ? /* @__PURE__ */ f("div", { className: V("rqmii-chat-call-avatar-wrap", p && "is-compact"), children: [
|
|
3690
3698
|
/* @__PURE__ */ n(J, { agent: a, size: z, active: d }),
|
|
3691
|
-
/* @__PURE__ */ n("button", { type: "button", className: V("rqmii-chat-call-button",
|
|
3699
|
+
/* @__PURE__ */ n("button", { type: "button", className: V("rqmii-chat-call-button", p && "is-compact"), onClick: m, disabled: l, "aria-label": F(t, "startVoice"), children: l ? /* @__PURE__ */ n(ye, { className: "rqmii-chat-spin", size: p ? 18 : 24 }) : /* @__PURE__ */ n(De, { size: p ? 18 : 24 }) })
|
|
3692
3700
|
] }) : /* @__PURE__ */ n(J, { agent: a, size: z }),
|
|
3693
3701
|
/* @__PURE__ */ n("div", { className: "rqmii-chat-agent-name", children: a.name }),
|
|
3694
3702
|
T && /* @__PURE__ */ n("div", { className: "rqmii-chat-error-text", children: T })
|
|
3695
3703
|
] }),
|
|
3696
|
-
S && /* @__PURE__ */ n("div", { className: "rqmii-chat-start-suggestions", children: /* @__PURE__ */ n(Fn, { suggestions:
|
|
3704
|
+
S && /* @__PURE__ */ n("div", { className: "rqmii-chat-start-suggestions", children: /* @__PURE__ */ n(Fn, { suggestions: b, language: t, onClick: (M) => x?.(M) }) }),
|
|
3697
3705
|
/* @__PURE__ */ n(Te, { language: t, onSend: s, disabled: h }),
|
|
3698
3706
|
/* @__PURE__ */ n(le, { language: t, agent: a })
|
|
3699
3707
|
] });
|
|
@@ -3720,12 +3728,12 @@ const Ln = j.memo(function({ agent: a, language: t, languages: i, onLanguageChan
|
|
|
3720
3728
|
] }),
|
|
3721
3729
|
/* @__PURE__ */ n(le, { language: t, agent: a })
|
|
3722
3730
|
] });
|
|
3723
|
-
}), Vn = j.memo(function({ agent: a, language: t, onEndSession: i, onMinimize: r, messages: o, partialTranscript: s, onSend: c, isAudioPlaying: d, isVoiceEnabled: l, onToggleVoice: m, isListening: u, isSpeaking: h, isLoading: T, isAgentThinking:
|
|
3724
|
-
const
|
|
3731
|
+
}), Vn = j.memo(function({ agent: a, language: t, onEndSession: i, onMinimize: r, messages: o, partialTranscript: s, onSend: c, isAudioPlaying: d, isVoiceEnabled: l, onToggleVoice: m, isListening: u, isSpeaking: h, isLoading: T, isAgentThinking: b, isAgentSpeaking: x, onStartVoice: y, elapsed: E, visualViewportHeight: g, waitingForResponse: k }) {
|
|
3732
|
+
const p = ua({ language: t, isListening: u, isLoading: T, isSpeaking: h, isAudioPlaying: d, isAgentThinking: b, isAgentSpeaking: x, persistentListening: !1 }), z = be(g);
|
|
3725
3733
|
return /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--conversation", H(t)), style: z, children: [
|
|
3726
3734
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-header", children: [
|
|
3727
3735
|
/* @__PURE__ */ n(J, { agent: a, size: "header", active: d }),
|
|
3728
|
-
l &&
|
|
3736
|
+
l && p && /* @__PURE__ */ n("div", { className: "rqmii-chat-header-status", children: /* @__PURE__ */ n("span", { children: p }) }),
|
|
3729
3737
|
/* @__PURE__ */ n("div", { className: "rqmii-chat-header-spacer" }),
|
|
3730
3738
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-header-actions", children: [
|
|
3731
3739
|
r && /* @__PURE__ */ n("button", { type: "button", className: "rqmii-chat-circle-button", onClick: r, "aria-label": F(t, "minimize"), children: /* @__PURE__ */ n(Ee, { size: 20 }) }),
|
|
@@ -3733,14 +3741,14 @@ const Ln = j.memo(function({ agent: a, language: t, languages: i, onLanguageChan
|
|
|
3733
3741
|
/* @__PURE__ */ n("button", { type: "button", className: "rqmii-chat-circle-button is-danger", onClick: i, "aria-label": F(t, "endCall"), children: /* @__PURE__ */ n(Ie, { size: 20 }) })
|
|
3734
3742
|
] })
|
|
3735
3743
|
] }),
|
|
3736
|
-
/* @__PURE__ */ n(Re, { messages: o, partialTranscript: s, language: t, showTypingIndicator:
|
|
3744
|
+
/* @__PURE__ */ n(Re, { messages: o, partialTranscript: s, language: t, showTypingIndicator: k }),
|
|
3737
3745
|
l && /* @__PURE__ */ n("div", { className: "rqmii-chat-session-counter", children: Ne(E) }),
|
|
3738
3746
|
/* @__PURE__ */ n(Te, { language: t, onSend: c }),
|
|
3739
3747
|
/* @__PURE__ */ n(le, { language: t, agent: a })
|
|
3740
3748
|
] });
|
|
3741
3749
|
}), jn = j.memo(function({ agent: a, language: t, onEndSession: i, onMinimize: r, isListening: o, isLoading: s, isSpeaking: c, isAudioPlaying: d, isAgentThinking: l, isAgentSpeaking: m, onToggleVoice: u, elapsed: h, visualViewportHeight: T }) {
|
|
3742
|
-
const
|
|
3743
|
-
return /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--voice-call", H(t)), style:
|
|
3750
|
+
const b = ua({ language: t, isListening: o, isLoading: s, isSpeaking: c, isAudioPlaying: d, isAgentThinking: l, isAgentSpeaking: m, persistentListening: !0 }), x = be(T);
|
|
3751
|
+
return /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--voice-call", H(t)), style: x, children: [
|
|
3744
3752
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-call-status", children: [
|
|
3745
3753
|
/* @__PURE__ */ n("span", { className: V("rqmii-chat-live-dot", o && "is-live") }),
|
|
3746
3754
|
/* @__PURE__ */ n("span", { children: Ne(h) }),
|
|
@@ -3749,7 +3757,7 @@ const Ln = j.memo(function({ agent: a, language: t, languages: i, onLanguageChan
|
|
|
3749
3757
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-voice-frame", children: [
|
|
3750
3758
|
/* @__PURE__ */ n(J, { agent: a, size: "hero", active: d }),
|
|
3751
3759
|
/* @__PURE__ */ n("div", { className: "rqmii-chat-agent-name", children: a.name }),
|
|
3752
|
-
/* @__PURE__ */ n("div", { className: V("rqmii-chat-status-pill", !
|
|
3760
|
+
/* @__PURE__ */ n("div", { className: V("rqmii-chat-status-pill", !b && "is-empty"), children: b || F(t, "listening") }),
|
|
3753
3761
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-voice-actions", children: [
|
|
3754
3762
|
/* @__PURE__ */ n("button", { type: "button", className: V("rqmii-chat-circle-button", c && "is-active"), onClick: u, children: o ? /* @__PURE__ */ n(Fe, { size: 20 }) : /* @__PURE__ */ n(je, { size: 20 }) }),
|
|
3755
3763
|
/* @__PURE__ */ n("button", { type: "button", className: "rqmii-chat-circle-button is-danger", onClick: i, "aria-label": F(t, "endCall"), children: /* @__PURE__ */ n(Ie, { size: 20 }) })
|
|
@@ -3786,23 +3794,23 @@ const In = j.memo(function({ agent: a, language: t, onRestore: i, onClose: r, is
|
|
|
3786
3794
|
visualViewportHeight: u,
|
|
3787
3795
|
rating: h,
|
|
3788
3796
|
endedBy: T,
|
|
3789
|
-
sessionId:
|
|
3790
|
-
ratingInteractive:
|
|
3791
|
-
showTellUsMore:
|
|
3797
|
+
sessionId: b,
|
|
3798
|
+
ratingInteractive: x,
|
|
3799
|
+
showTellUsMore: y,
|
|
3792
3800
|
onRate: E,
|
|
3793
|
-
onTellUsMore:
|
|
3801
|
+
onTellUsMore: g
|
|
3794
3802
|
}) {
|
|
3795
|
-
const
|
|
3803
|
+
const k = be(u), p = b && a.widget?.behavior?.post_chat_rating_enabled ? /* @__PURE__ */ n(
|
|
3796
3804
|
Pn,
|
|
3797
3805
|
{
|
|
3798
3806
|
language: t,
|
|
3799
3807
|
rating: h,
|
|
3800
3808
|
endedBy: T,
|
|
3801
|
-
sessionId:
|
|
3802
|
-
interactive:
|
|
3803
|
-
showTellUsMore:
|
|
3809
|
+
sessionId: b,
|
|
3810
|
+
interactive: x,
|
|
3811
|
+
showTellUsMore: y,
|
|
3804
3812
|
onRate: E,
|
|
3805
|
-
onTellUsMore:
|
|
3813
|
+
onTellUsMore: g
|
|
3806
3814
|
}
|
|
3807
3815
|
) : null, z = r === "voice" || r === "text_and_voice", S = r === "text" || r === "text_and_voice", M = /* @__PURE__ */ f("div", { className: "rqmii-chat-topbar-actions rqmii-chat-topbar-actions--ended", children: [
|
|
3808
3816
|
/* @__PURE__ */ n(_e, { language: t, languages: i, onChange: s }),
|
|
@@ -3828,7 +3836,7 @@ const In = j.memo(function({ agent: a, language: t, onRestore: i, onClose: r, is
|
|
|
3828
3836
|
}
|
|
3829
3837
|
)
|
|
3830
3838
|
] });
|
|
3831
|
-
return r === "voice" ? /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--voice-call", H(t)), style:
|
|
3839
|
+
return r === "voice" ? /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--voice-call", H(t)), style: k, children: [
|
|
3832
3840
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-topbar", children: [
|
|
3833
3841
|
/* @__PURE__ */ n("span", {}),
|
|
3834
3842
|
M
|
|
@@ -3836,16 +3844,16 @@ const In = j.memo(function({ agent: a, language: t, onRestore: i, onClose: r, is
|
|
|
3836
3844
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-voice-frame", children: [
|
|
3837
3845
|
/* @__PURE__ */ n(J, { agent: a, size: "hero" }),
|
|
3838
3846
|
/* @__PURE__ */ n("div", { className: "rqmii-chat-agent-name", children: a.name }),
|
|
3839
|
-
|
|
3847
|
+
p
|
|
3840
3848
|
] }),
|
|
3841
3849
|
/* @__PURE__ */ n(le, { language: t, agent: a })
|
|
3842
|
-
] }) : /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--conversation", H(t)), style:
|
|
3850
|
+
] }) : /* @__PURE__ */ f("div", { className: V("rqmii-chat-panel rqmii-chat-panel--conversation", H(t)), style: k, children: [
|
|
3843
3851
|
/* @__PURE__ */ f("div", { className: "rqmii-chat-topbar", children: [
|
|
3844
3852
|
/* @__PURE__ */ n(J, { agent: a, size: "header" }),
|
|
3845
3853
|
M
|
|
3846
3854
|
] }),
|
|
3847
3855
|
/* @__PURE__ */ n(Re, { messages: o, language: t }),
|
|
3848
|
-
|
|
3856
|
+
p,
|
|
3849
3857
|
S && /* @__PURE__ */ n(Te, { language: t, onSend: l }),
|
|
3850
3858
|
/* @__PURE__ */ n(le, { language: t, agent: a })
|
|
3851
3859
|
] });
|
|
@@ -3934,10 +3942,10 @@ const Be = j.memo(function({
|
|
|
3934
3942
|
sdk: u,
|
|
3935
3943
|
renderPanel: h,
|
|
3936
3944
|
messagesRef: T,
|
|
3937
|
-
initialText:
|
|
3938
|
-
autoStartVoice:
|
|
3945
|
+
initialText: b,
|
|
3946
|
+
autoStartVoice: x
|
|
3939
3947
|
}) {
|
|
3940
|
-
const [
|
|
3948
|
+
const [y, E] = v(!1), g = m || ve(a), [k, p] = v(() => g === "voice" && u.isSessionReady || g === "voice" && !!x), [z, S] = v(() => (g === "text" || g === "text_and_voice") && u.isSessionReady || !!b || g === "text_and_voice" && !!x), [M, P] = v(!1), [L, A] = v(!1), [C, I] = v(null), W = sn(g === "voice" && k || g === "text_and_voice" && z), q = ln(), B = a.consent?.enabled && !y && !l, N = _n(g), { events: U } = ue();
|
|
3941
3949
|
D(() => {
|
|
3942
3950
|
if (!U) return;
|
|
3943
3951
|
const K = () => {
|
|
@@ -3965,23 +3973,23 @@ const Be = j.memo(function({
|
|
|
3965
3973
|
});
|
|
3966
3974
|
const ee = _(!1);
|
|
3967
3975
|
D(() => {
|
|
3968
|
-
ee.current || (
|
|
3976
|
+
ee.current || (b ? (ee.current = !0, ne(b)) : x && (ee.current = !0, I(null), A(!0), u.isVoiceActive || u.startVoice()));
|
|
3969
3977
|
}, []), D(() => {
|
|
3970
|
-
L && u.isSessionReady && (A(!1),
|
|
3971
|
-
}, [L, u.isSessionReady,
|
|
3978
|
+
L && u.isSessionReady && (A(!1), g === "voice" ? p(!0) : S(!0));
|
|
3979
|
+
}, [L, u.isSessionReady, g]), D(() => {
|
|
3972
3980
|
L && u.error && (A(!1), I(u.error));
|
|
3973
3981
|
}, [L, u.error]);
|
|
3974
3982
|
const $ = re(() => {
|
|
3975
3983
|
I(null), A(!0), u.isVoiceActive || u.startVoice();
|
|
3976
3984
|
}, [u]);
|
|
3977
|
-
if (u.error && !l && (z ||
|
|
3985
|
+
if (u.error && !l && (z || k)) return /* @__PURE__ */ n(ca, { message: u.error, language: t, onClose: o });
|
|
3978
3986
|
if (B)
|
|
3979
3987
|
return /* @__PURE__ */ n(qn, { language: t, config: a.consent, onAccept: O, onDecline: Q });
|
|
3980
3988
|
const R = {
|
|
3981
3989
|
agent: a,
|
|
3982
3990
|
language: t,
|
|
3983
3991
|
languages: i,
|
|
3984
|
-
chatKind:
|
|
3992
|
+
chatKind: g,
|
|
3985
3993
|
sdk: u,
|
|
3986
3994
|
isPreview: l,
|
|
3987
3995
|
onLanguageChange: X,
|
|
@@ -3989,35 +3997,35 @@ const Be = j.memo(function({
|
|
|
3989
3997
|
onMinimize: N ? () => P(!0) : void 0,
|
|
3990
3998
|
onRestore: N ? () => P(!1) : void 0,
|
|
3991
3999
|
onSend: ne,
|
|
3992
|
-
voiceStarted:
|
|
4000
|
+
voiceStarted: k,
|
|
3993
4001
|
conversationStarted: z,
|
|
3994
4002
|
isMinimized: M,
|
|
3995
4003
|
elapsed: W,
|
|
3996
|
-
setVoiceStarted:
|
|
4004
|
+
setVoiceStarted: p,
|
|
3997
4005
|
setConversationStarted: S
|
|
3998
4006
|
};
|
|
3999
4007
|
return h ? /* @__PURE__ */ n(Ve, { children: h(R) }) : /* @__PURE__ */ n(Rn, { ...R, connecting: L, connectError: C, visualViewportHeight: q, onCloseWidget: s ?? o, initiateVoice: $, onSendSuggestion: (K) => {
|
|
4000
4008
|
I(null), A(!0), u.sendSuggestion?.(K);
|
|
4001
4009
|
} });
|
|
4002
|
-
}), Rn = j.memo(function({ agent: a, language: t, languages: i, chatKind: r, sdk: o, onLanguageChange: s, onClose: c, onMinimize: d, onRestore: l, onSend: m, voiceStarted: u, conversationStarted: h, isMinimized: T, elapsed:
|
|
4010
|
+
}), Rn = j.memo(function({ agent: a, language: t, languages: i, chatKind: r, sdk: o, onLanguageChange: s, onClose: c, onMinimize: d, onRestore: l, onSend: m, voiceStarted: u, conversationStarted: h, isMinimized: T, elapsed: b, setVoiceStarted: x, setConversationStarted: y, visualViewportHeight: E, connecting: g = !1, connectError: k = null, onCloseWidget: p, initiateVoice: z, onSendSuggestion: S }) {
|
|
4003
4011
|
const M = a.widget?.behavior?.typing_indicator_enabled ?? !0, P = r === "text" ? o.waitingForResponse && M : !1, L = o.messages;
|
|
4004
4012
|
if (r === "avatar") return /* @__PURE__ */ n(ma, { agent: a, language: t, onClose: c });
|
|
4005
4013
|
if (T)
|
|
4006
|
-
return /* @__PURE__ */ n(In, { agent: a, language: t, onRestore: l, onClose: c, isListening: o.isVoiceActive, isAudioPlaying: o.isAudioPlaying, isSpeaking: o.vad.isSpeaking, onToggleVoice: o.toggleVoice, elapsed:
|
|
4014
|
+
return /* @__PURE__ */ n(In, { agent: a, language: t, onRestore: l, onClose: c, isListening: o.isVoiceActive, isAudioPlaying: o.isAudioPlaying, isSpeaking: o.vad.isSpeaking, onToggleVoice: o.toggleVoice, elapsed: b, variant: r === "text" ? "text" : "voice" });
|
|
4007
4015
|
if (r === "voice" && u)
|
|
4008
|
-
return /* @__PURE__ */ n(jn, { agent: a, language: t, onEndSession: c, onMinimize: d, isListening: o.isVoiceActive, isLoading: o.vad.isLoading, isSpeaking: o.vad.isSpeaking, isAudioPlaying: o.isAudioPlaying, isAgentThinking: o.isAgentThinking, isAgentSpeaking: o.isAgentSpeaking, onToggleVoice: o.toggleVoice, elapsed:
|
|
4016
|
+
return /* @__PURE__ */ n(jn, { agent: a, language: t, onEndSession: c, onMinimize: d, isListening: o.isVoiceActive, isLoading: o.vad.isLoading, isSpeaking: o.vad.isSpeaking, isAudioPlaying: o.isAudioPlaying, isAgentThinking: o.isAgentThinking, isAgentSpeaking: o.isAgentSpeaking, onToggleVoice: o.toggleVoice, elapsed: b, visualViewportHeight: E });
|
|
4009
4017
|
if (r === "voice")
|
|
4010
|
-
return /* @__PURE__ */ n(An, { agent: a, language: t, languages: i, onLanguageChange: s, onClose:
|
|
4011
|
-
if (!h && (o.messages.length === 0 ||
|
|
4012
|
-
const A = a.conversation?.suggested_messages?.[t]?.filter((G) => G.trim()) || void 0, C = (G) => {
|
|
4018
|
+
return /* @__PURE__ */ n(An, { agent: a, language: t, languages: i, onLanguageChange: s, onClose: p, isAudioPlaying: o.isAudioPlaying, isVoiceSetupLoading: o.isVoiceSetupLoading || g, onStartVoice: z, visualViewportHeight: E });
|
|
4019
|
+
if (!h && (o.messages.length === 0 || g)) {
|
|
4020
|
+
const A = (a.widget?.behavior?.suggested_messages?.[t] || a.conversation?.suggested_messages?.[t])?.filter((G) => G.trim()) || void 0, C = (G) => {
|
|
4013
4021
|
o.sendSuggestion ? S(G) : m?.(G);
|
|
4014
4022
|
}, I = r === "text_and_voice" || ve(a) === "text_and_voice";
|
|
4015
|
-
return /* @__PURE__ */ n(Ln, { agent: a, language: t, languages: i, onLanguageChange: s, onClose:
|
|
4023
|
+
return /* @__PURE__ */ n(Ln, { agent: a, language: t, languages: i, onLanguageChange: s, onClose: p, onSend: m, isVoiceEnabled: I, isAudioPlaying: o.isAudioPlaying, isVoiceSetupLoading: o.isVoiceSetupLoading || g, onStartVoice: z, visualViewportHeight: E, disabled: g, error: k || void 0, suggestions: A, onSuggestionClick: C, compact: !!A });
|
|
4016
4024
|
}
|
|
4017
|
-
return /* @__PURE__ */ n(Vn, { agent: a, language: t, onEndSession: c, messages: L, partialTranscript: Nn(o.partialTranscript), onSend: m, isAudioPlaying: o.isAudioPlaying, isVoiceEnabled: r === "text_and_voice", isListening: o.isVoiceActive, isSpeaking: o.vad.isSpeaking, isLoading: o.vad.isLoading, isAgentThinking: o.isAgentThinking, isAgentSpeaking: o.isAgentSpeaking, onToggleVoice: o.toggleVoice, onStartVoice: o.startVoice, onMinimize: d, elapsed:
|
|
4025
|
+
return /* @__PURE__ */ n(Vn, { agent: a, language: t, onEndSession: c, messages: L, partialTranscript: Nn(o.partialTranscript), onSend: m, isAudioPlaying: o.isAudioPlaying, isVoiceEnabled: r === "text_and_voice", isListening: o.isVoiceActive, isSpeaking: o.vad.isSpeaking, isLoading: o.vad.isLoading, isAgentThinking: o.isAgentThinking, isAgentSpeaking: o.isAgentSpeaking, onToggleVoice: o.toggleVoice, onStartVoice: o.startVoice, onMinimize: d, elapsed: b, visualViewportHeight: E, waitingForResponse: P });
|
|
4018
4026
|
}), Bn = { isListening: !1, isLoading: !1, isSpeaking: !1, toggle: async () => !1 };
|
|
4019
4027
|
function ha({ isSessionReady: e, sendTextMessage: a, messages: t }) {
|
|
4020
|
-
const [i, r] =
|
|
4028
|
+
const [i, r] = v(null), [o, s] = v(null), c = re(() => {
|
|
4021
4029
|
r((d) => (d && (e ? a(d) : s(d)), null));
|
|
4022
4030
|
}, [e, a]);
|
|
4023
4031
|
return D(() => {
|
|
@@ -4031,7 +4039,7 @@ function ha({ isSessionReady: e, sendTextMessage: a, messages: t }) {
|
|
|
4031
4039
|
}, [e, o, a]), { pendingWelcomeText: i, pendingMessage: o, setPendingWelcomeText: r, setPendingMessage: s, sendPendingWelcomeText: c };
|
|
4032
4040
|
}
|
|
4033
4041
|
function Ge({ isSessionReady: e, signalClientReady: a }) {
|
|
4034
|
-
const [t, i] =
|
|
4042
|
+
const [t, i] = v(!1), [r, o] = v(void 0), s = _(!1);
|
|
4035
4043
|
return D(() => {
|
|
4036
4044
|
!e || s.current || !t || (s.current = !0, a(r), i(!1));
|
|
4037
4045
|
}, [e, t, r, a]), { emitClientReady: re((d) => {
|
|
@@ -4040,7 +4048,7 @@ function Ge({ isSessionReady: e, signalClientReady: a }) {
|
|
|
4040
4048
|
}
|
|
4041
4049
|
const Gn = 300;
|
|
4042
4050
|
function Un(e) {
|
|
4043
|
-
const { isPreview: a = !1, ...t } = e, { messages: i, sendTextMessage: r, emitUserMessage: o, addLocalMessage: s, clearMessages: c } = de(), { changeSessionLanguage: d, clearSessionHistory: l, signalClientReady: m, error: u, isSessionReady: h, isAgentThinking: T, isAgentSpeaking:
|
|
4051
|
+
const { isPreview: a = !1, ...t } = e, { messages: i, sendTextMessage: r, emitUserMessage: o, addLocalMessage: s, clearMessages: c } = de(), { changeSessionLanguage: d, clearSessionHistory: l, signalClientReady: m, error: u, isSessionReady: h, isAgentThinking: T, isAgentSpeaking: b } = ue(), x = _(!1), y = _(null), E = _(!1), [g, k] = v(!1), [p, z] = v(null), [S, M] = v(!1), P = _(i.length);
|
|
4044
4052
|
D(() => {
|
|
4045
4053
|
if (i.length > P.current) {
|
|
4046
4054
|
const q = i[i.length - 1];
|
|
@@ -4050,18 +4058,18 @@ function Un(e) {
|
|
|
4050
4058
|
}, [i]), ta("message_rate_limited", re(() => {
|
|
4051
4059
|
M(!1);
|
|
4052
4060
|
}, [])), D(() => {
|
|
4053
|
-
if (!h || !
|
|
4054
|
-
const q =
|
|
4061
|
+
if (!h || !g || E.current) return;
|
|
4062
|
+
const q = y.current;
|
|
4055
4063
|
if (q === null) return;
|
|
4056
|
-
E.current = !0,
|
|
4064
|
+
E.current = !0, y.current = null, s("user", q), z(null);
|
|
4057
4065
|
const B = e.agent.welcomeMessages?.[e.language];
|
|
4058
4066
|
m(B ? { welcomeMessage: B } : void 0);
|
|
4059
4067
|
const N = setTimeout(() => {
|
|
4060
4068
|
o(q), M(!0);
|
|
4061
4069
|
}, Gn);
|
|
4062
4070
|
return () => clearTimeout(N);
|
|
4063
|
-
}, [h,
|
|
4064
|
-
const L = te(() =>
|
|
4071
|
+
}, [h, g, m, o, s]);
|
|
4072
|
+
const L = te(() => p ? [{ id: "first-user", role: "user", text: p }, ...i] : i, [p, i]), A = re(() => {
|
|
4065
4073
|
z(null), c();
|
|
4066
4074
|
}, [c]), C = {
|
|
4067
4075
|
emitClientReady: m,
|
|
@@ -4077,7 +4085,7 @@ function Un(e) {
|
|
|
4077
4085
|
isVoiceActive: !1,
|
|
4078
4086
|
chatKind: "text"
|
|
4079
4087
|
}, I = (q, B) => {
|
|
4080
|
-
e.onSessionStart?.(),
|
|
4088
|
+
e.onSessionStart?.(), x.current ? (M(!0), B.sendMessage(q)) : (x.current = !0, z(q), y.current = q, k(!0), M(!0));
|
|
4081
4089
|
}, G = (q) => {
|
|
4082
4090
|
e.onTextSend ? e.onTextSend(q, C) : I(q, C);
|
|
4083
4091
|
};
|
|
@@ -4097,7 +4105,7 @@ function Un(e) {
|
|
|
4097
4105
|
changeSessionLanguage: d,
|
|
4098
4106
|
error: u,
|
|
4099
4107
|
isAgentThinking: T,
|
|
4100
|
-
isAgentSpeaking:
|
|
4108
|
+
isAgentSpeaking: b,
|
|
4101
4109
|
isVoiceSetupLoading: !1,
|
|
4102
4110
|
isVoiceActive: !1,
|
|
4103
4111
|
isSessionReady: h,
|
|
@@ -4113,24 +4121,24 @@ function Un(e) {
|
|
|
4113
4121
|
);
|
|
4114
4122
|
}
|
|
4115
4123
|
function Kn(e) {
|
|
4116
|
-
const { isPreview: a = !1, ...t } = e, { messages: i, sendTextMessage: r, clearMessages: o } = de(), { isAudioPlaying: s, partialTranscript: c } = na(), { changeSessionLanguage: d, clearSessionHistory: l, signalClientReady: m, error: u, isSessionReady: h, isAgentThinking: T, isAgentSpeaking:
|
|
4124
|
+
const { isPreview: a = !1, ...t } = e, { messages: i, sendTextMessage: r, clearMessages: o } = de(), { isAudioPlaying: s, partialTranscript: c } = na(), { changeSessionLanguage: d, clearSessionHistory: l, signalClientReady: m, error: u, isSessionReady: h, isAgentThinking: T, isAgentSpeaking: b } = ue(), { setPendingWelcomeText: x, setPendingMessage: y } = ha({ isSessionReady: h, sendTextMessage: r, messages: i }), { emitClientReady: E } = Ge({ isSessionReady: h, signalClientReady: m }), [g, k] = v(!1), p = ia({
|
|
4117
4125
|
enabled: !0,
|
|
4118
4126
|
preloadStream: !1
|
|
4119
|
-
}), { isLoading: z, isListening: S, toggle: M } =
|
|
4127
|
+
}), { isLoading: z, isListening: S, toggle: M } = p, P = z, L = S || g;
|
|
4120
4128
|
D(() => {
|
|
4121
|
-
!
|
|
4122
|
-
}, [
|
|
4129
|
+
!g || !h || z || S || M();
|
|
4130
|
+
}, [g, h, z, S, M]);
|
|
4123
4131
|
const A = () => {
|
|
4124
4132
|
e.onSessionStart?.();
|
|
4125
4133
|
}, C = {
|
|
4126
4134
|
emitClientReady: E,
|
|
4127
4135
|
sendMessage: (N) => {
|
|
4128
|
-
h ? r(N) :
|
|
4136
|
+
h ? r(N) : y(N);
|
|
4129
4137
|
},
|
|
4130
|
-
queueForWelcome: (N) =>
|
|
4131
|
-
enableVoice: () =>
|
|
4138
|
+
queueForWelcome: (N) => x(N),
|
|
4139
|
+
enableVoice: () => k(!0),
|
|
4132
4140
|
disableVoice: () => {
|
|
4133
|
-
|
|
4141
|
+
k(!1), S && M();
|
|
4134
4142
|
},
|
|
4135
4143
|
language: e.language,
|
|
4136
4144
|
isSessionReady: h,
|
|
@@ -4161,11 +4169,11 @@ function Kn(e) {
|
|
|
4161
4169
|
changeSessionLanguage: d,
|
|
4162
4170
|
error: u,
|
|
4163
4171
|
isAgentThinking: T,
|
|
4164
|
-
isAgentSpeaking:
|
|
4172
|
+
isAgentSpeaking: b,
|
|
4165
4173
|
isVoiceSetupLoading: P,
|
|
4166
4174
|
isVoiceActive: L,
|
|
4167
4175
|
isSessionReady: h,
|
|
4168
|
-
vad:
|
|
4176
|
+
vad: p,
|
|
4169
4177
|
startVoice: () => {
|
|
4170
4178
|
e.onVoiceStart ? e.onVoiceStart(C) : I(C);
|
|
4171
4179
|
},
|
|
@@ -4181,7 +4189,7 @@ function Kn(e) {
|
|
|
4181
4189
|
}
|
|
4182
4190
|
const On = 300;
|
|
4183
4191
|
function Yn(e) {
|
|
4184
|
-
const { isPreview: a = !1, ...t } = e, { messages: i, sendTextMessage: r, emitUserMessage: o, addLocalMessage: s, clearMessages: c } = de(), { isAudioPlaying: d, partialTranscript: l } = na(), { changeSessionLanguage: m, clearSessionHistory: u, signalClientReady: h, error: T, isSessionReady:
|
|
4192
|
+
const { isPreview: a = !1, ...t } = e, { messages: i, sendTextMessage: r, emitUserMessage: o, addLocalMessage: s, clearMessages: c } = de(), { isAudioPlaying: d, partialTranscript: l } = na(), { changeSessionLanguage: m, clearSessionHistory: u, signalClientReady: h, error: T, isSessionReady: b, isAgentThinking: x, isAgentSpeaking: y } = ue(), { emitClientReady: E } = Ge({ isSessionReady: b, signalClientReady: h }), [g, k] = v(!1), p = _(null), [z, S] = v(!1), M = _(null), [P, L] = v(!1), A = _(!1), C = _(!1), I = _(!1), [G, W] = v(null), [q, B] = v(!1), N = _(i.length);
|
|
4185
4193
|
D(() => {
|
|
4186
4194
|
if (i.length > N.current) {
|
|
4187
4195
|
const w = i[i.length - 1];
|
|
@@ -4194,25 +4202,25 @@ function Yn(e) {
|
|
|
4194
4202
|
const U = ia({
|
|
4195
4203
|
enabled: !0,
|
|
4196
4204
|
preloadStream: !1
|
|
4197
|
-
}), { isLoading: O, isListening: Q, toggle: X } = U, ne = O, ee = Q ||
|
|
4205
|
+
}), { isLoading: O, isListening: Q, toggle: X } = U, ne = O, ee = Q || g;
|
|
4198
4206
|
D(() => {
|
|
4199
|
-
!
|
|
4200
|
-
}, [
|
|
4201
|
-
if (!
|
|
4202
|
-
const w =
|
|
4207
|
+
!g || !b || O || Q || X();
|
|
4208
|
+
}, [g, b, O, Q, X]), D(() => {
|
|
4209
|
+
if (!b || !z || I.current) return;
|
|
4210
|
+
const w = p.current;
|
|
4203
4211
|
if (w === null) return;
|
|
4204
|
-
I.current = !0,
|
|
4212
|
+
I.current = !0, p.current = null, s("user", w), W(null);
|
|
4205
4213
|
const ae = e.agent.welcomeMessages?.[e.language];
|
|
4206
4214
|
h(ae ? { welcomeMessage: ae } : void 0);
|
|
4207
4215
|
const xe = setTimeout(() => {
|
|
4208
4216
|
o(w), B(!0);
|
|
4209
4217
|
}, On);
|
|
4210
4218
|
return () => clearTimeout(xe);
|
|
4211
|
-
}, [
|
|
4212
|
-
if (!
|
|
4219
|
+
}, [b, z, h, o, s]), D(() => {
|
|
4220
|
+
if (!b || !P || A.current) return;
|
|
4213
4221
|
const w = M.current;
|
|
4214
4222
|
w !== null && (A.current = !0, M.current = null, s("user", w), o(w), B(!0), L(!1));
|
|
4215
|
-
}, [
|
|
4223
|
+
}, [b, P, o, s]);
|
|
4216
4224
|
const $ = te(() => G ? [{ id: "first-user", role: "user", text: G }, ...i] : i, [G, i]), R = re(() => {
|
|
4217
4225
|
W(null), C.current = !1, I.current = !1, c();
|
|
4218
4226
|
}, [c]), K = () => {
|
|
@@ -4226,17 +4234,17 @@ function Yn(e) {
|
|
|
4226
4234
|
},
|
|
4227
4235
|
queueForWelcome: () => {
|
|
4228
4236
|
},
|
|
4229
|
-
enableVoice: () =>
|
|
4237
|
+
enableVoice: () => k(!0),
|
|
4230
4238
|
disableVoice: () => {
|
|
4231
|
-
|
|
4239
|
+
k(!1), Q && X();
|
|
4232
4240
|
},
|
|
4233
4241
|
language: e.language,
|
|
4234
|
-
isSessionReady:
|
|
4242
|
+
isSessionReady: b,
|
|
4235
4243
|
supportsVoice: !0,
|
|
4236
4244
|
isVoiceActive: ee,
|
|
4237
4245
|
chatKind: "text_and_voice"
|
|
4238
4246
|
}, ke = (w, ae) => {
|
|
4239
|
-
K(), !C.current && !I.current ? (C.current = !0, e.onStartText?.(), W(w),
|
|
4247
|
+
K(), !C.current && !I.current ? (C.current = !0, e.onStartText?.(), W(w), p.current = w, S(!0), B(!0)) : (C.current = !0, B(!0), ae.sendMessage(w));
|
|
4240
4248
|
}, ce = (w) => {
|
|
4241
4249
|
K(), C.current = !0, I.current = !0, e.onStartVoice?.(), w.enableVoice();
|
|
4242
4250
|
const ae = e.agent.welcomeMessages?.[e.language];
|
|
@@ -4254,11 +4262,11 @@ function Yn(e) {
|
|
|
4254
4262
|
partialTranscript: l,
|
|
4255
4263
|
changeSessionLanguage: m,
|
|
4256
4264
|
error: T,
|
|
4257
|
-
isAgentThinking:
|
|
4258
|
-
isAgentSpeaking:
|
|
4265
|
+
isAgentThinking: x,
|
|
4266
|
+
isAgentSpeaking: y,
|
|
4259
4267
|
isVoiceSetupLoading: ne,
|
|
4260
4268
|
isVoiceActive: ee,
|
|
4261
|
-
isSessionReady:
|
|
4269
|
+
isSessionReady: b,
|
|
4262
4270
|
vad: U,
|
|
4263
4271
|
startVoice: () => {
|
|
4264
4272
|
e.onVoiceStart ? e.onVoiceStart(Z) : ce(Z);
|
|
@@ -4271,7 +4279,7 @@ function Yn(e) {
|
|
|
4271
4279
|
signalClientReady: h,
|
|
4272
4280
|
waitingForResponse: q,
|
|
4273
4281
|
sendSuggestion: (w) => {
|
|
4274
|
-
K(), C.current = !0, I.current = !0, e.onStartVoice?.(),
|
|
4282
|
+
K(), C.current = !0, I.current = !0, e.onStartVoice?.(), k(!0), M.current = w, L(!0);
|
|
4275
4283
|
}
|
|
4276
4284
|
};
|
|
4277
4285
|
return /* @__PURE__ */ n(
|
|
@@ -4285,8 +4293,8 @@ function Yn(e) {
|
|
|
4285
4293
|
);
|
|
4286
4294
|
}
|
|
4287
4295
|
function Qn(e) {
|
|
4288
|
-
const { isPreview: a = !1, agent: t, language: i, languages: r, onLanguageChange: o, onEndSession: s, onMinimize: c, messages: d, onSendMessage: l } = e, m = s || c || ie, { messages: u, sendTextMessage: h, clearMessages: T } = de(), { changeSessionLanguage:
|
|
4289
|
-
return ha({ isSessionReady:
|
|
4296
|
+
const { isPreview: a = !1, agent: t, language: i, languages: r, onLanguageChange: o, onEndSession: s, onMinimize: c, messages: d, onSendMessage: l } = e, m = s || c || ie, { messages: u, sendTextMessage: h, clearMessages: T } = de(), { changeSessionLanguage: b, clearSessionHistory: x, signalClientReady: y, error: E, isSessionReady: g, isAgentThinking: k, isAgentSpeaking: p } = ue();
|
|
4297
|
+
return ha({ isSessionReady: g, sendTextMessage: h, messages: u }), Ge({ isSessionReady: g, signalClientReady: y }), E && !a ? /* @__PURE__ */ n(ca, { message: E, language: i, onClose: m }) : /* @__PURE__ */ n(ma, { agent: t, language: i, onClose: m });
|
|
4290
4298
|
}
|
|
4291
4299
|
function ai({ agent: e, defaultOpen: a = !1, className: t = "", preview: i = !1, ChatBoxComponent: r }) {
|
|
4292
4300
|
const [o, s] = j.useState(a), [c, d] = j.useState(e.defaultLanguage), l = te(() => pe(e.languages, e.defaultLanguage), [e.defaultLanguage, e.languages]);
|
|
@@ -4298,7 +4306,7 @@ function ai({ agent: e, defaultOpen: a = !1, className: t = "", preview: i = !1,
|
|
|
4298
4306
|
] });
|
|
4299
4307
|
}
|
|
4300
4308
|
function Hn({ restUrl: e, identifier: a, fallbackAgent: t, withCredentials: i = !1, children: r, onError: o }) {
|
|
4301
|
-
const [s, c] =
|
|
4309
|
+
const [s, c] = v(() => t ? ge(t) : null), [d, l] = v(null);
|
|
4302
4310
|
return D(() => {
|
|
4303
4311
|
t && (c(ge(t)), l(null));
|
|
4304
4312
|
}, [t]), D(() => {
|
|
@@ -4309,18 +4317,18 @@ function Hn({ restUrl: e, identifier: a, fallbackAgent: t, withCredentials: i =
|
|
|
4309
4317
|
}), () => m.abort();
|
|
4310
4318
|
}, [t, a, o, e, i]), d ? /* @__PURE__ */ n("div", { className: "rqmii-chat-panel rqmii-chat-panel--error", children: d.message || "Could not load agent" }) : s ? /* @__PURE__ */ n(Ve, { children: r(s) }) : /* @__PURE__ */ n("div", { className: "rqmii-chat-panel rqmii-chat-panel--error", children: "Loading" });
|
|
4311
4319
|
}
|
|
4312
|
-
function Ae({ agent: e, language: a, languages: t, onLanguageChange: i, onEndSession: r, onMinimize: o, onStartText: s, onStartVoice: c, textOnly: d, messages: l, onSendMessage: m, isPreview: u, onSessionStart: h, initialText: T, autoStartVoice:
|
|
4313
|
-
const
|
|
4314
|
-
switch (
|
|
4320
|
+
function Ae({ agent: e, language: a, languages: t, onLanguageChange: i, onEndSession: r, onMinimize: o, onStartText: s, onStartVoice: c, textOnly: d, messages: l, onSendMessage: m, isPreview: u, onSessionStart: h, initialText: T, autoStartVoice: b }) {
|
|
4321
|
+
const x = ve(e), y = { agent: e, language: a, languages: t, onLanguageChange: i, onEndSession: r, onMinimize: o, messages: l, onSendMessage: m, isPreview: u, onSessionStart: h, initialText: T, autoStartVoice: b };
|
|
4322
|
+
switch (x) {
|
|
4315
4323
|
case "avatar":
|
|
4316
|
-
return /* @__PURE__ */ n(Qn, { ...
|
|
4324
|
+
return /* @__PURE__ */ n(Qn, { ...y });
|
|
4317
4325
|
case "voice":
|
|
4318
|
-
return /* @__PURE__ */ n(Kn, { ...
|
|
4326
|
+
return /* @__PURE__ */ n(Kn, { ...y });
|
|
4319
4327
|
case "text_and_voice":
|
|
4320
|
-
return /* @__PURE__ */ n(Yn, { ...
|
|
4328
|
+
return /* @__PURE__ */ n(Yn, { ...y, onStartText: s, onStartVoice: c, textOnly: d });
|
|
4321
4329
|
case "text":
|
|
4322
4330
|
default:
|
|
4323
|
-
return /* @__PURE__ */ n(Un, { ...
|
|
4331
|
+
return /* @__PURE__ */ n(Un, { ...y });
|
|
4324
4332
|
}
|
|
4325
4333
|
}
|
|
4326
4334
|
function Wn({
|
|
@@ -4338,27 +4346,27 @@ function Wn({
|
|
|
4338
4346
|
onStartText: u,
|
|
4339
4347
|
onStartVoice: h
|
|
4340
4348
|
}) {
|
|
4341
|
-
const { connectionState: T, isConnected:
|
|
4349
|
+
const { connectionState: T, isConnected: b, isSessionTerminated: x, creditExhausted: y, session: E, endSession: g, submitFeedback: k, interrupt: p } = ue(), { messages: z } = de(), S = _(!1), M = _(null), [P, L] = v(null), [A, C] = v(0), [I, G] = v(!1), [W, q] = v(!1), [B, N] = v(!1);
|
|
4342
4350
|
D(() => {
|
|
4343
|
-
|
|
4344
|
-
}, [
|
|
4351
|
+
b && (S.current = !0);
|
|
4352
|
+
}, [b]), D(() => {
|
|
4345
4353
|
if (P) return;
|
|
4346
4354
|
let R = null;
|
|
4347
|
-
|
|
4355
|
+
x || T === "ended" ? R = M.current === "user" ? "user_ended" : "terminated" : T === "failed" ? y ? R = "credits_exhausted" : S.current ? R = "connection_lost" : R = "failed" : y && (R = "credits_exhausted"), R && L({
|
|
4348
4356
|
sessionId: E.sessionId,
|
|
4349
4357
|
endedBy: M.current ?? "agent",
|
|
4350
4358
|
reason: R
|
|
4351
4359
|
});
|
|
4352
|
-
}, [
|
|
4360
|
+
}, [x, T, y, E.sessionId, P]);
|
|
4353
4361
|
const U = () => {
|
|
4354
|
-
M.current = "user",
|
|
4362
|
+
M.current = "user", p(), g();
|
|
4355
4363
|
}, O = P?.sessionId ?? null, Q = (R) => {
|
|
4356
|
-
I || (C(R), O &&
|
|
4364
|
+
I || (C(R), O && k({ sessionId: O, rating: R, endedBy: P?.endedBy }).catch(() => {
|
|
4357
4365
|
}), B || (N(!0), q(!0)));
|
|
4358
4366
|
}, X = async (R) => {
|
|
4359
4367
|
if (O)
|
|
4360
4368
|
try {
|
|
4361
|
-
await
|
|
4369
|
+
await k({ sessionId: O, feedback: R, endedBy: P?.endedBy });
|
|
4362
4370
|
} catch {
|
|
4363
4371
|
}
|
|
4364
4372
|
G(!0), q(!1);
|
|
@@ -4428,7 +4436,7 @@ function Wn({
|
|
|
4428
4436
|
}
|
|
4429
4437
|
);
|
|
4430
4438
|
}
|
|
4431
|
-
function ti({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o, defaultOpen: s = !1, open: c, className: d = "", pcmOptions: l, debug: m = !1, withCredentials: u = !1, onError: h, onInitialized: T, config:
|
|
4439
|
+
function ti({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o, defaultOpen: s = !1, open: c, className: d = "", pcmOptions: l, debug: m = !1, withCredentials: u = !1, onError: h, onInitialized: T, config: b, promptOverrides: x, clientTools: y, onMinimize: E, onOpen: g }) {
|
|
4432
4440
|
if ([!!t, !!i].filter(Boolean).length > 1)
|
|
4433
4441
|
throw new Error("RqmiiAgentChat: only one of apiKey, or agentId may be provided");
|
|
4434
4442
|
return /* @__PURE__ */ n(Hn, { restUrl: a, identifier: t || i, fallbackAgent: r, withCredentials: u, onError: h, children: (z) => /* @__PURE__ */ n(
|
|
@@ -4448,16 +4456,16 @@ function ti({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o
|
|
|
4448
4456
|
withCredentials: u,
|
|
4449
4457
|
onError: h,
|
|
4450
4458
|
onInitialized: T,
|
|
4451
|
-
config:
|
|
4452
|
-
promptOverrides:
|
|
4453
|
-
clientTools:
|
|
4459
|
+
config: b,
|
|
4460
|
+
promptOverrides: x,
|
|
4461
|
+
clientTools: y,
|
|
4454
4462
|
onMinimize: E,
|
|
4455
|
-
onOpen:
|
|
4463
|
+
onOpen: g
|
|
4456
4464
|
}
|
|
4457
4465
|
) });
|
|
4458
4466
|
}
|
|
4459
|
-
function $n({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o, defaultOpen: s, open: c, className: d, pcmOptions: l, debug: m, withCredentials: u, onError: h, onInitialized: T, config:
|
|
4460
|
-
const [
|
|
4467
|
+
function $n({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o, defaultOpen: s, open: c, className: d, pcmOptions: l, debug: m, withCredentials: u, onError: h, onInitialized: T, config: b, promptOverrides: x, clientTools: y, onMinimize: E, onOpen: g }) {
|
|
4468
|
+
const [k, p] = v(s), z = c !== void 0 ? c : k, [S, M] = v(!1), [P, L] = v(o || r.defaultLanguage), [A, C] = v("idle"), [I, G] = v(0), [W, q] = v(null), [B, N] = v(!1), U = r.agentType === "cloud_avatar" || r.agentType === "desktop_avatar", O = U, Q = r.widget?.behavior, X = r.welcomeMessages?.[P] || "", ne = !z && !B && !O && !!Q?.welcome_bubble_enabled && !!X.trim(), ee = te(() => pe(r.languages, r.defaultLanguage), [r.defaultLanguage, r.languages]), $ = te(() => A === "text" ? { ...b ?? {}, use_voice: !1, use_text: !0 } : b, [b, A]), R = te(
|
|
4461
4469
|
() => Lt(r, $),
|
|
4462
4470
|
[r, $]
|
|
4463
4471
|
), K = !O && R.useVoice, Z = U ? z : S, ke = te(() => ({
|
|
@@ -4465,8 +4473,8 @@ function $n({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o
|
|
|
4465
4473
|
...i ? { agentId: i } : {},
|
|
4466
4474
|
language: P,
|
|
4467
4475
|
config: $,
|
|
4468
|
-
...
|
|
4469
|
-
}), [i, t, P, $,
|
|
4476
|
+
...x ? { promptOverrides: x } : {}
|
|
4477
|
+
}), [i, t, P, $, x]), ce = _(null), fe = _(!1), ze = _(I), Ue = ze.current !== I;
|
|
4470
4478
|
ze.current = I, S && (!fe.current || Ue) && (ce.current = ke), fe.current = S, S || (ce.current = null);
|
|
4471
4479
|
const Ke = S && ce.current ? ce.current : ke;
|
|
4472
4480
|
D(() => {
|
|
@@ -4481,9 +4489,9 @@ function $n({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o
|
|
|
4481
4489
|
}, ae = () => {
|
|
4482
4490
|
C("voice"), M(!0);
|
|
4483
4491
|
}, xe = () => {
|
|
4484
|
-
c === void 0 &&
|
|
4492
|
+
c === void 0 && p(!1), E?.();
|
|
4485
4493
|
}, ga = () => {
|
|
4486
|
-
c === void 0 &&
|
|
4494
|
+
c === void 0 && p(!0), N(!0), g?.();
|
|
4487
4495
|
}, pa = (me, ba) => {
|
|
4488
4496
|
q(me === "text" ? { mode: "text", text: ba ?? "" } : { mode: "voice" }), C(me), M(!0), G((ka) => ka + 1);
|
|
4489
4497
|
};
|
|
@@ -4500,7 +4508,7 @@ function $n({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o
|
|
|
4500
4508
|
withCredentials: u,
|
|
4501
4509
|
onError: Se,
|
|
4502
4510
|
onInitialized: T,
|
|
4503
|
-
clientTools:
|
|
4511
|
+
clientTools: y,
|
|
4504
4512
|
children: /* @__PURE__ */ f("div", { className: V("rqmii-chat-surface", r.widget?.appearance?.position === "left" && "rqmii-position-left", d), dir: "ltr", children: [
|
|
4505
4513
|
ne && /* @__PURE__ */ n(
|
|
4506
4514
|
hn,
|
|
@@ -4537,7 +4545,7 @@ function $n({ wsUrl: e, restUrl: a, apiKey: t, agentId: i, agent: r, language: o
|
|
|
4537
4545
|
);
|
|
4538
4546
|
}
|
|
4539
4547
|
function ni({ agent: e, language: a, open: t = !0, className: i = "", messages: r, onSendMessage: o, onClose: s }) {
|
|
4540
|
-
const c = te(() => ge(e), [e]), [d, l] =
|
|
4548
|
+
const c = te(() => ge(e), [e]), [d, l] = v(t), [m, u] = v(a || c.defaultLanguage), h = te(() => pe(c.languages, c.defaultLanguage), [c.defaultLanguage, c.languages]);
|
|
4541
4549
|
return D(() => {
|
|
4542
4550
|
a && u(a);
|
|
4543
4551
|
}, [a]), D(() => {
|