@aigentyc/chat-sdk 0.4.0 → 0.5.1
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/context7.json +1 -1
- package/dist/{ChatInterface-0rq8D5-8.d.cts → ChatInterface-DrzYAWnG.d.cts} +1 -1
- package/dist/{ChatInterface--yaDB5yp.d.ts → ChatInterface-qiVhkmx3.d.ts} +1 -1
- package/dist/{SlotsContext-CWTjP0mA.d.ts → SlotsContext-B_087V7B.d.ts} +99 -5
- package/dist/{SlotsContext-u5CFB7MS.d.cts → SlotsContext-DAQiASVu.d.cts} +99 -5
- package/dist/ai-elements.cjs +164 -567
- package/dist/ai-elements.cjs.map +1 -1
- package/dist/ai-elements.d.cts +10 -2
- package/dist/ai-elements.d.ts +10 -2
- package/dist/ai-elements.js +17 -462
- package/dist/ai-elements.js.map +1 -1
- package/dist/{chunk-LSKOJ7SH.js → chunk-3H4CX3MS.js} +8 -5
- package/dist/chunk-3H4CX3MS.js.map +1 -0
- package/dist/{chunk-4WOBNRRB.cjs → chunk-6CVBJ4EI.cjs} +594 -10
- package/dist/chunk-6CVBJ4EI.cjs.map +1 -0
- package/dist/{chunk-3MP2EGEJ.cjs → chunk-72QJ2ORD.cjs} +4 -2
- package/dist/chunk-72QJ2ORD.cjs.map +1 -0
- package/dist/chunk-BYTPAQ7F.js +70 -0
- package/dist/chunk-BYTPAQ7F.js.map +1 -0
- package/dist/{chunk-P3RPAI4F.cjs → chunk-BYX6IOGX.cjs} +4 -4
- package/dist/{chunk-P3RPAI4F.cjs.map → chunk-BYX6IOGX.cjs.map} +1 -1
- package/dist/{chunk-B27JIQ4Z.js → chunk-CNGIOCLR.js} +577 -7
- package/dist/chunk-CNGIOCLR.js.map +1 -0
- package/dist/chunk-CNPYBLLT.js +81 -0
- package/dist/chunk-CNPYBLLT.js.map +1 -0
- package/dist/{chunk-6ZZTTD5E.js → chunk-CW6LCVNC.js} +3 -3
- package/dist/{chunk-6ZZTTD5E.js.map → chunk-CW6LCVNC.js.map} +1 -1
- package/dist/chunk-DDATCJ3O.cjs +75 -0
- package/dist/chunk-DDATCJ3O.cjs.map +1 -0
- package/dist/{chunk-LVWSWTI3.cjs → chunk-DTOOWY2S.cjs} +184 -74
- package/dist/chunk-DTOOWY2S.cjs.map +1 -0
- package/dist/{chunk-NYQSM3EB.cjs → chunk-DVWX2UGY.cjs} +16 -2
- package/dist/chunk-DVWX2UGY.cjs.map +1 -0
- package/dist/{chunk-TZ7EM3EG.cjs → chunk-EMVZ7HWM.cjs} +44 -2
- package/dist/chunk-EMVZ7HWM.cjs.map +1 -0
- package/dist/{chunk-3EN3DMUL.js → chunk-JAEXKKSE.js} +47 -38
- package/dist/chunk-JAEXKKSE.js.map +1 -0
- package/dist/{chunk-JHWSG5IB.js → chunk-JAOD6CNW.js} +38 -3
- package/dist/chunk-JAOD6CNW.js.map +1 -0
- package/dist/{chunk-OEEDYJTV.cjs → chunk-JEK2V5I3.cjs} +6 -6
- package/dist/{chunk-OEEDYJTV.cjs.map → chunk-JEK2V5I3.cjs.map} +1 -1
- package/dist/{chunk-QYCEHFAB.js → chunk-LDQVDUUJ.js} +4 -2
- package/dist/chunk-LDQVDUUJ.js.map +1 -0
- package/dist/{chunk-AWRQSM42.cjs → chunk-NBZDBH4M.cjs} +8 -5
- package/dist/chunk-NBZDBH4M.cjs.map +1 -0
- package/dist/{chunk-5F3O3ZJH.js → chunk-P7UR37HP.js} +17 -4
- package/dist/chunk-P7UR37HP.js.map +1 -0
- package/dist/{chunk-3KSMOHNY.js → chunk-R3TYC66R.js} +46 -81
- package/dist/chunk-R3TYC66R.js.map +1 -0
- package/dist/{chunk-RAQVW2D7.js → chunk-UTEGHMBN.js} +142 -33
- package/dist/chunk-UTEGHMBN.js.map +1 -0
- package/dist/{chunk-46MUOYPR.cjs → chunk-UXVOUC2A.cjs} +47 -38
- package/dist/chunk-UXVOUC2A.cjs.map +1 -0
- package/dist/{chunk-IU7Q7O5G.js → chunk-VQPOUMBC.js} +3 -3
- package/dist/{chunk-IU7Q7O5G.js.map → chunk-VQPOUMBC.js.map} +1 -1
- package/dist/chunk-VYBHYFG3.cjs +87 -0
- package/dist/chunk-VYBHYFG3.cjs.map +1 -0
- package/dist/{chunk-OU5OZKYH.cjs → chunk-Y4B45DW4.cjs} +48 -90
- package/dist/chunk-Y4B45DW4.cjs.map +1 -0
- package/dist/components.cjs +22 -21
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +3 -3
- package/dist/components.d.ts +3 -3
- package/dist/components.js +10 -9
- package/dist/components.js.map +1 -1
- package/dist/core.cjs +21 -82
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +2 -78
- package/dist/core.js.map +1 -1
- package/dist/hooks.cjs +36 -14
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +2 -2
- package/dist/hooks.d.ts +2 -2
- package/dist/hooks.js +7 -5
- package/dist/hooks.js.map +1 -1
- package/dist/i18n.cjs +5 -5
- package/dist/i18n.d.cts +2 -2
- package/dist/i18n.d.ts +2 -2
- package/dist/i18n.js +1 -1
- package/dist/index.cjs +61 -35
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +15 -5
- package/dist/index.d.ts +15 -5
- package/dist/index.js +16 -14
- package/dist/index.js.map +1 -1
- package/dist/llms-full.txt +10 -10
- package/dist/styles.css +1 -1
- package/dist/theme.cjs +4 -4
- package/dist/theme.d.cts +1 -1
- package/dist/theme.d.ts +1 -1
- package/dist/theme.js +2 -2
- package/dist/tools.cjs +6 -5
- package/dist/tools.d.cts +2 -2
- package/dist/tools.d.ts +2 -2
- package/dist/tools.js +3 -2
- package/dist/{types-DQCjs81O.d.cts → types-DRa1zFlN.d.cts} +33 -1
- package/dist/{types-DQCjs81O.d.ts → types-DRa1zFlN.d.ts} +33 -1
- package/dist/ui.cjs +52 -52
- package/dist/ui.js +2 -2
- package/package.json +2 -2
- package/dist/chunk-3EN3DMUL.js.map +0 -1
- package/dist/chunk-3KSMOHNY.js.map +0 -1
- package/dist/chunk-3MP2EGEJ.cjs.map +0 -1
- package/dist/chunk-46MUOYPR.cjs.map +0 -1
- package/dist/chunk-4WOBNRRB.cjs.map +0 -1
- package/dist/chunk-5F3O3ZJH.js.map +0 -1
- package/dist/chunk-AWRQSM42.cjs.map +0 -1
- package/dist/chunk-B27JIQ4Z.js.map +0 -1
- package/dist/chunk-JHWSG5IB.js.map +0 -1
- package/dist/chunk-LSKOJ7SH.js.map +0 -1
- package/dist/chunk-LVWSWTI3.cjs.map +0 -1
- package/dist/chunk-NYQSM3EB.cjs.map +0 -1
- package/dist/chunk-OU5OZKYH.cjs.map +0 -1
- package/dist/chunk-QYCEHFAB.js.map +0 -1
- package/dist/chunk-RAQVW2D7.js.map +0 -1
- package/dist/chunk-TZ7EM3EG.cjs.map +0 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
var react = require('react');
|
|
5
|
+
|
|
6
|
+
// src/hooks/use-keyboard-language.ts
|
|
7
|
+
var LATIN = "latin";
|
|
8
|
+
var SCRIPT_RANGES = [
|
|
9
|
+
{ test: /[-]/, lang: "he-IL" },
|
|
10
|
+
{ test: /[-ۿݐ-ݿ]/, lang: "ar-SA" },
|
|
11
|
+
{ test: /[Ѐ-ӿ]/, lang: "ru-RU" },
|
|
12
|
+
{ test: /[Ͱ-Ͽ]/, lang: "el-GR" },
|
|
13
|
+
{ test: /[一-鿿]/, lang: "zh-CN" },
|
|
14
|
+
{ test: /[-ヿ]/, lang: "ja-JP" },
|
|
15
|
+
{ test: /[가-]/, lang: "ko-KR" },
|
|
16
|
+
// Latin identifies a script but not a language — English, Spanish and German
|
|
17
|
+
// are indistinguishable from a character — so it reports the sentinel and the
|
|
18
|
+
// caller says which Latin language it means.
|
|
19
|
+
{ test: /[A-Za-z]/, lang: LATIN }
|
|
20
|
+
];
|
|
21
|
+
function scriptLanguageOf(char) {
|
|
22
|
+
for (const { test, lang } of SCRIPT_RANGES) {
|
|
23
|
+
if (test.test(char)) return lang;
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
function detectLanguage(text) {
|
|
28
|
+
for (let i = text.length - 1; i >= 0; i--) {
|
|
29
|
+
const lang = scriptLanguageOf(text[i]);
|
|
30
|
+
if (lang) return lang;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
function browserLanguage() {
|
|
35
|
+
if (typeof navigator === "undefined") return "en-US";
|
|
36
|
+
return navigator.language || "en-US";
|
|
37
|
+
}
|
|
38
|
+
function useKeyboardLanguage({
|
|
39
|
+
fallback,
|
|
40
|
+
supported,
|
|
41
|
+
latin = "en-US"
|
|
42
|
+
} = {}) {
|
|
43
|
+
const initial = fallback ?? browserLanguage();
|
|
44
|
+
const [lang, setLang] = react.useState(initial);
|
|
45
|
+
const lastTextRef = react.useRef("");
|
|
46
|
+
const isSupported = react.useCallback(
|
|
47
|
+
(candidate) => {
|
|
48
|
+
if (!supported || supported.length === 0) return true;
|
|
49
|
+
return supported.includes(candidate);
|
|
50
|
+
},
|
|
51
|
+
[supported]
|
|
52
|
+
);
|
|
53
|
+
const observe = react.useCallback(
|
|
54
|
+
(text) => {
|
|
55
|
+
const previous = lastTextRef.current;
|
|
56
|
+
lastTextRef.current = text;
|
|
57
|
+
if (text.length <= previous.length) return;
|
|
58
|
+
const added = text.startsWith(previous) ? text.slice(previous.length) : text;
|
|
59
|
+
const detected = detectLanguage(added);
|
|
60
|
+
if (detected === null) return;
|
|
61
|
+
const next = detected === LATIN ? latin : detected;
|
|
62
|
+
if (!isSupported(next)) return;
|
|
63
|
+
setLang((current) => current === next ? current : next);
|
|
64
|
+
},
|
|
65
|
+
[isSupported, latin]
|
|
66
|
+
);
|
|
67
|
+
return { lang, setLang, observe };
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
exports.LATIN = LATIN;
|
|
71
|
+
exports.detectLanguage = detectLanguage;
|
|
72
|
+
exports.scriptLanguageOf = scriptLanguageOf;
|
|
73
|
+
exports.useKeyboardLanguage = useKeyboardLanguage;
|
|
74
|
+
//# sourceMappingURL=chunk-DDATCJ3O.cjs.map
|
|
75
|
+
//# sourceMappingURL=chunk-DDATCJ3O.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/hooks/use-keyboard-language.ts"],"names":["useState","useRef","useCallback"],"mappings":"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","file":"chunk-DDATCJ3O.cjs","sourcesContent":["\"use client\";\n\nimport { useCallback, useRef, useState } from \"react\";\n\n/**\n * The scripts we can tell apart from a single character, mapped to the BCP-47\n * tag a speech recogniser wants.\n *\n * Deliberately short. A script the visitor is not typing in cannot be guessed\n * from their text, and a wrong guess is worse than the fallback — dictation in\n * the wrong language produces confident nonsense rather than an obvious failure.\n */\n/** Reported for Latin script, which pins a keyboard but not a language. */\nexport const LATIN = \"latin\";\n\nconst SCRIPT_RANGES: Array<{ test: RegExp; lang: string }> = [\n { test: /[-]/, lang: \"he-IL\" },\n { test: /[-ۿݐ-ݿ]/, lang: \"ar-SA\" },\n { test: /[Ѐ-ӿ]/, lang: \"ru-RU\" },\n { test: /[Ͱ-Ͽ]/, lang: \"el-GR\" },\n { test: /[一-鿿]/, lang: \"zh-CN\" },\n { test: /[-ヿ]/, lang: \"ja-JP\" },\n { test: /[가-]/, lang: \"ko-KR\" },\n // Latin identifies a script but not a language — English, Spanish and German\n // are indistinguishable from a character — so it reports the sentinel and the\n // caller says which Latin language it means.\n { test: /[A-Za-z]/, lang: LATIN },\n];\n\n/**\n * The BCP-47 tag implied by a character's script, {@link LATIN} when the script\n * is Latin, or null when the character says nothing (digits, punctuation,\n * whitespace, emoji).\n */\nexport function scriptLanguageOf(char: string): string | null {\n for (const { test, lang } of SCRIPT_RANGES) {\n if (test.test(char)) return lang;\n }\n return null;\n}\n\n/**\n * The language of the last character in `text` whose script is identifiable.\n *\n * Read from the end because that is what the visitor is typing now: a Hebrew\n * question that opens with an English part number is still a Hebrew question.\n */\nexport function detectLanguage(text: string): string | null {\n for (let i = text.length - 1; i >= 0; i--) {\n const lang = scriptLanguageOf(text[i]);\n if (lang) return lang;\n }\n return null;\n}\n\nexport interface KeyboardLanguageOptions {\n /**\n * Used until the visitor has typed something identifiable. Defaults to the\n * browser's own language.\n */\n fallback?: string;\n /**\n * Tags this consumer can actually act on, e.g. the languages a recogniser is\n * configured for. A detection outside the list is ignored rather than\n * switching to something unsupported.\n */\n supported?: string[];\n /** Latin text is ambiguous; this is which Latin language to call it. */\n latin?: string;\n}\n\nfunction browserLanguage(): string {\n if (typeof navigator === \"undefined\") return \"en-US\";\n return navigator.language || \"en-US\";\n}\n\n/**\n * Tracks which keyboard the visitor is typing on, by the script of what they type.\n *\n * The web exposes no keyboard-layout API, so the characters themselves are the\n * signal — and they are a good one: a visitor typing Hebrew has a Hebrew\n * keyboard active, which is exactly what dictation should follow. The answer is\n * sticky, so clearing the box or dictating into it does not reset the language\n * back to a default the visitor never chose.\n *\n * Feed it every value the composer sees via `observe`.\n */\nexport function useKeyboardLanguage({\n fallback,\n supported,\n latin = \"en-US\",\n}: KeyboardLanguageOptions = {}) {\n const initial = fallback ?? browserLanguage();\n const [lang, setLang] = useState(initial);\n // The last text observed, so `observe` can look only at what was added rather\n // than re-reading the whole box on every keystroke.\n const lastTextRef = useRef(\"\");\n\n const isSupported = useCallback(\n (candidate: string) => {\n if (!supported || supported.length === 0) return true;\n return supported.includes(candidate);\n },\n [supported],\n );\n\n const observe = useCallback(\n (text: string) => {\n const previous = lastTextRef.current;\n lastTextRef.current = text;\n // Only additions carry a keyboard signal. Deleting back through Hebrew\n // does not mean the visitor switched to English.\n if (text.length <= previous.length) return;\n const added = text.startsWith(previous) ? text.slice(previous.length) : text;\n const detected = detectLanguage(added);\n if (detected === null) return;\n const next = detected === LATIN ? latin : detected;\n if (!isSupported(next)) return;\n setLang((current) => (current === next ? current : next));\n },\n [isSupported, latin],\n );\n\n return { lang, setLang, observe };\n}\n"]}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
4
|
+
var chunkDVWX2UGY_cjs = require('./chunk-DVWX2UGY.cjs');
|
|
5
|
+
var chunkBYX6IOGX_cjs = require('./chunk-BYX6IOGX.cjs');
|
|
6
|
+
var chunk6CVBJ4EI_cjs = require('./chunk-6CVBJ4EI.cjs');
|
|
7
|
+
var chunk72QJ2ORD_cjs = require('./chunk-72QJ2ORD.cjs');
|
|
8
|
+
var chunkJEK2V5I3_cjs = require('./chunk-JEK2V5I3.cjs');
|
|
9
|
+
var chunkUXVOUC2A_cjs = require('./chunk-UXVOUC2A.cjs');
|
|
10
10
|
var chunk525KS5HM_cjs = require('./chunk-525KS5HM.cjs');
|
|
11
11
|
var react = require('react');
|
|
12
12
|
var lucideReact = require('lucide-react');
|
|
@@ -30,8 +30,8 @@ var ChatHeader = react.memo(function ChatHeader2({
|
|
|
30
30
|
cartCount,
|
|
31
31
|
onCartClick
|
|
32
32
|
}) {
|
|
33
|
-
const { t, direction } =
|
|
34
|
-
const ctx =
|
|
33
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
34
|
+
const ctx = chunkUXVOUC2A_cjs.useChatContext();
|
|
35
35
|
const displayName = clientName || ctx.config.clientName || "AI Assistant";
|
|
36
36
|
const LogoOrIcon = () => {
|
|
37
37
|
if (logoUrl) {
|
|
@@ -163,23 +163,30 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
163
163
|
placeholder
|
|
164
164
|
}) {
|
|
165
165
|
const [isFocused, setIsFocused] = react.useState(false);
|
|
166
|
-
const
|
|
166
|
+
const [isComposing, setIsComposing] = react.useState(false);
|
|
167
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
168
|
+
const { ref: textareaRef } = chunkDVWX2UGY_cjs.useAutoResize(value, {
|
|
169
|
+
minHeight: 24,
|
|
170
|
+
maxHeight: 160
|
|
171
|
+
});
|
|
167
172
|
const handleKeyDown = (e) => {
|
|
168
|
-
if (e.key
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
173
|
+
if (e.key !== "Enter") return;
|
|
174
|
+
if (isComposing || e.nativeEvent.isComposing) return;
|
|
175
|
+
if (e.shiftKey) return;
|
|
176
|
+
e.preventDefault();
|
|
177
|
+
if (!value.trim() || isProcessing) return;
|
|
178
|
+
onSubmit(value);
|
|
172
179
|
};
|
|
173
180
|
const hasValue = value.trim().length > 0;
|
|
174
181
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
175
182
|
"div",
|
|
176
183
|
{
|
|
177
184
|
className: `
|
|
178
|
-
relative flex items-
|
|
185
|
+
relative flex items-end gap-3
|
|
179
186
|
rounded-2xl
|
|
180
187
|
border-2 transition-all duration-300
|
|
181
188
|
${isFocused ? "shadow-lg" : "shadow-md hover:shadow-lg"}
|
|
182
|
-
ps-4 md:ps-5 pe-1.5 md:pe-2
|
|
189
|
+
ps-4 md:ps-5 pe-1.5 md:pe-2 py-1.5 md:py-2
|
|
183
190
|
`,
|
|
184
191
|
style: {
|
|
185
192
|
backgroundColor: "var(--ac-background)",
|
|
@@ -189,7 +196,7 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
189
196
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
190
197
|
"div",
|
|
191
198
|
{
|
|
192
|
-
className: "shrink-0 transition-colors duration-300",
|
|
199
|
+
className: "shrink-0 transition-colors duration-300 self-center",
|
|
193
200
|
style: { color: isFocused ? "var(--ac-primary)" : "#a0a0a0" },
|
|
194
201
|
children: /* @__PURE__ */ jsxRuntime.jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
195
202
|
/* @__PURE__ */ jsxRuntime.jsx("circle", { cx: "11", cy: "11", r: "8" }),
|
|
@@ -198,18 +205,21 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
198
205
|
}
|
|
199
206
|
),
|
|
200
207
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
201
|
-
"
|
|
208
|
+
"textarea",
|
|
202
209
|
{
|
|
210
|
+
ref: textareaRef,
|
|
203
211
|
dir: direction,
|
|
204
|
-
|
|
212
|
+
rows: 1,
|
|
205
213
|
value,
|
|
206
214
|
onChange: (e) => onChange(e.target.value),
|
|
207
215
|
onKeyDown: handleKeyDown,
|
|
216
|
+
onCompositionStart: () => setIsComposing(true),
|
|
217
|
+
onCompositionEnd: () => setIsComposing(false),
|
|
208
218
|
onFocus: () => setIsFocused(true),
|
|
209
219
|
onBlur: () => setIsFocused(false),
|
|
210
220
|
disabled: isProcessing,
|
|
211
221
|
placeholder: placeholder || t("typeMessage"),
|
|
212
|
-
className: "\n flex-1 bg-transparent text-start\n outline-none text-base\n
|
|
222
|
+
className: "\n flex-1 bg-transparent text-start\n outline-none text-base resize-none\n py-[14px] md:py-[17px]\n disabled:opacity-50\n ",
|
|
213
223
|
style: { color: "var(--ac-text)" }
|
|
214
224
|
}
|
|
215
225
|
),
|
|
@@ -222,7 +232,7 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
222
232
|
className: `
|
|
223
233
|
group relative flex items-center justify-center
|
|
224
234
|
w-10 h-10 md:w-12 md:h-12
|
|
225
|
-
rounded-xl shrink-0
|
|
235
|
+
rounded-xl shrink-0 self-end mb-1
|
|
226
236
|
transition-all duration-300 overflow-hidden
|
|
227
237
|
${hasValue && !isProcessing ? "shadow-md hover:shadow-lg hover:scale-105" : "cursor-not-allowed"}
|
|
228
238
|
disabled:hover:scale-100
|
|
@@ -255,7 +265,7 @@ var ChatInput = react.memo(function ChatInput2({
|
|
|
255
265
|
);
|
|
256
266
|
});
|
|
257
267
|
function ChatFooter({ footerText }) {
|
|
258
|
-
const { t } =
|
|
268
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
259
269
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
260
270
|
"div",
|
|
261
271
|
{
|
|
@@ -320,8 +330,8 @@ function WelcomePage({
|
|
|
320
330
|
questionsLayout = "vertical",
|
|
321
331
|
questionsLayoutMobile
|
|
322
332
|
}) {
|
|
323
|
-
const isMobile =
|
|
324
|
-
const { t } =
|
|
333
|
+
const isMobile = chunkDVWX2UGY_cjs.useIsMobile();
|
|
334
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
325
335
|
const layout = isMobile && questionsLayoutMobile ? questionsLayoutMobile : questionsLayout;
|
|
326
336
|
const isHorizontal = layout === "horizontal";
|
|
327
337
|
const [shouldAnimate, setShouldAnimate] = react.useState(false);
|
|
@@ -485,7 +495,7 @@ function QuickQuestions({ questions, onSelect, isProcessing = false, pageKey })
|
|
|
485
495
|
const [dismissed, setDismissed] = react.useState(false);
|
|
486
496
|
const prevPageKeyRef = react.useRef(pageKey);
|
|
487
497
|
const scrollRef = react.useRef(null);
|
|
488
|
-
const { direction } =
|
|
498
|
+
const { direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
489
499
|
react.useEffect(() => {
|
|
490
500
|
if (prevPageKeyRef.current !== pageKey) {
|
|
491
501
|
setDismissed(false);
|
|
@@ -582,7 +592,7 @@ function decodeHtmlEntities(text) {
|
|
|
582
592
|
return text.replace(/&#(\d+);/g, (_, code) => String.fromCharCode(Number(code))).replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/–/g, "\u2013").replace(/—/g, "\u2014").replace(/«/g, "\xAB").replace(/»/g, "\xBB");
|
|
583
593
|
}
|
|
584
594
|
function CartDrawer({ storeOrigin, isOpen, onClose, onCartUpdate }) {
|
|
585
|
-
const { t } =
|
|
595
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
586
596
|
const [cart, setCart] = react.useState(null);
|
|
587
597
|
const [loading, setLoading] = react.useState(false);
|
|
588
598
|
const [updatingKeys, setUpdatingKeys] = react.useState(/* @__PURE__ */ new Set());
|
|
@@ -785,6 +795,71 @@ function SystemMessage({ message, type }) {
|
|
|
785
795
|
const displayMessage = translateMessage(message, type);
|
|
786
796
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center my-3", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-muted-foreground bg-muted px-4 py-1.5 rounded-full border border-border/50", children: displayMessage }) });
|
|
787
797
|
}
|
|
798
|
+
function serverMessage(error) {
|
|
799
|
+
const raw = error?.message?.trim();
|
|
800
|
+
if (!raw || !raw.startsWith("{")) return null;
|
|
801
|
+
try {
|
|
802
|
+
const parsed = JSON.parse(raw);
|
|
803
|
+
const message = typeof parsed.error === "string" ? parsed.error.trim() : "";
|
|
804
|
+
return message || null;
|
|
805
|
+
} catch {
|
|
806
|
+
return null;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
function isTerminal(error) {
|
|
810
|
+
const raw = error?.message ?? "";
|
|
811
|
+
if (/too_many_messages|message_too_long|request_too_large/.test(raw)) {
|
|
812
|
+
return true;
|
|
813
|
+
}
|
|
814
|
+
return /conversation too long|request too large|message too long/i.test(raw);
|
|
815
|
+
}
|
|
816
|
+
function ChatError({ error, onRetry, onNewConversation }) {
|
|
817
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
818
|
+
const terminal = isTerminal(error);
|
|
819
|
+
const detail = serverMessage(error);
|
|
820
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
821
|
+
"div",
|
|
822
|
+
{
|
|
823
|
+
role: "alert",
|
|
824
|
+
dir: direction,
|
|
825
|
+
className: "mx-auto w-full max-w-[520px] rounded-xl border px-4 py-3 text-sm",
|
|
826
|
+
style: {
|
|
827
|
+
borderColor: "var(--ac-error-border, rgba(220, 38, 38, 0.25))",
|
|
828
|
+
backgroundColor: "var(--ac-error-background, rgba(220, 38, 38, 0.06))",
|
|
829
|
+
color: "var(--ac-foreground, inherit)"
|
|
830
|
+
},
|
|
831
|
+
children: [
|
|
832
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "font-medium", children: terminal ? t("conversationTooLong") : t("somethingWentWrong") }),
|
|
833
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 opacity-80", children: detail ?? (terminal ? t("conversationTooLongDesc") : t("somethingWentWrongDesc")) }),
|
|
834
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
|
|
835
|
+
onRetry && !terminal && /* @__PURE__ */ jsxRuntime.jsx(
|
|
836
|
+
"button",
|
|
837
|
+
{
|
|
838
|
+
type: "button",
|
|
839
|
+
onClick: onRetry,
|
|
840
|
+
className: "rounded-lg px-3 py-1.5 text-sm font-medium",
|
|
841
|
+
style: {
|
|
842
|
+
backgroundColor: "var(--ac-primary, #111827)",
|
|
843
|
+
color: "var(--ac-primary-foreground, #ffffff)"
|
|
844
|
+
},
|
|
845
|
+
children: t("tryAgain")
|
|
846
|
+
}
|
|
847
|
+
),
|
|
848
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
849
|
+
"button",
|
|
850
|
+
{
|
|
851
|
+
type: "button",
|
|
852
|
+
onClick: onNewConversation,
|
|
853
|
+
className: "rounded-lg border px-3 py-1.5 text-sm font-medium",
|
|
854
|
+
style: { borderColor: "var(--ac-border, rgba(0, 0, 0, 0.15))" },
|
|
855
|
+
children: t("startNewConversation")
|
|
856
|
+
}
|
|
857
|
+
)
|
|
858
|
+
] })
|
|
859
|
+
]
|
|
860
|
+
}
|
|
861
|
+
);
|
|
862
|
+
}
|
|
788
863
|
var ChatErrorBoundary = class extends react.Component {
|
|
789
864
|
state = { error: null };
|
|
790
865
|
static getDerivedStateFromError(error) {
|
|
@@ -884,7 +959,7 @@ function DefaultUserMessage({ text }) {
|
|
|
884
959
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
885
960
|
"div",
|
|
886
961
|
{
|
|
887
|
-
className: "inline-block rounded-2xl px-3 py-2 max-w-[85%]",
|
|
962
|
+
className: "inline-block rounded-2xl px-3 py-2 max-w-[85%] whitespace-pre-wrap break-words",
|
|
888
963
|
style: {
|
|
889
964
|
backgroundColor: "var(--ac-user-bubble-bg, var(--ac-primary))",
|
|
890
965
|
color: "var(--ac-primary-foreground, #fff)"
|
|
@@ -895,13 +970,13 @@ function DefaultUserMessage({ text }) {
|
|
|
895
970
|
}
|
|
896
971
|
function ChatInterface(props) {
|
|
897
972
|
const { showSources = false } = props;
|
|
898
|
-
const { messages, status, sendMessage, sessionId, config, newConversation: ctxNewConversation } =
|
|
899
|
-
const { t, direction } =
|
|
900
|
-
|
|
901
|
-
const slots =
|
|
973
|
+
const { messages, status, error, sendMessage, sessionId, config, retryLastTurn, newConversation: ctxNewConversation } = chunkUXVOUC2A_cjs.useChatContext();
|
|
974
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
975
|
+
chunkBYX6IOGX_cjs.useTheme();
|
|
976
|
+
const slots = chunkUXVOUC2A_cjs.useSlots();
|
|
902
977
|
let liveChat = null;
|
|
903
978
|
try {
|
|
904
|
-
liveChat =
|
|
979
|
+
liveChat = chunkDVWX2UGY_cjs.useLiveChat();
|
|
905
980
|
} catch {
|
|
906
981
|
liveChat = null;
|
|
907
982
|
}
|
|
@@ -917,12 +992,12 @@ function ChatInterface(props) {
|
|
|
917
992
|
if (messages.length === 0 && !showWelcome) setShowWelcome(true);
|
|
918
993
|
}, [messages.length, showWelcome]);
|
|
919
994
|
const handleSubmit = react.useCallback(
|
|
920
|
-
(text) => {
|
|
921
|
-
if (!text.trim() || isProcessing) return;
|
|
995
|
+
(text, files) => {
|
|
996
|
+
if (!text.trim() && !files?.length || isProcessing) return;
|
|
922
997
|
if (liveChat?.state === "live") return;
|
|
923
998
|
setShowWelcome(false);
|
|
924
999
|
setInput("");
|
|
925
|
-
sendMessage(text);
|
|
1000
|
+
sendMessage(text, files);
|
|
926
1001
|
},
|
|
927
1002
|
[isProcessing, sendMessage, liveChat]
|
|
928
1003
|
);
|
|
@@ -972,8 +1047,8 @@ function ChatInterface(props) {
|
|
|
972
1047
|
);
|
|
973
1048
|
if (showWelcome && messages.length === 0) {
|
|
974
1049
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", dir: direction, style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
975
|
-
!props.hideHeader &&
|
|
976
|
-
|
|
1050
|
+
!props.hideHeader && chunkUXVOUC2A_cjs.renderSlot("header", headerProps, ChatHeader, slots),
|
|
1051
|
+
chunkUXVOUC2A_cjs.renderSlot(
|
|
977
1052
|
"welcomePage",
|
|
978
1053
|
{
|
|
979
1054
|
onSelectCategory: handleSelectCategory,
|
|
@@ -992,18 +1067,18 @@ function ChatInterface(props) {
|
|
|
992
1067
|
slots
|
|
993
1068
|
),
|
|
994
1069
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px]", style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
995
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto z-40 w-full", children:
|
|
1070
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mx-auto z-40 w-full", children: chunkUXVOUC2A_cjs.renderSlot(
|
|
996
1071
|
"input",
|
|
997
1072
|
{ value: input, onChange: setInput, onSubmit: handleSubmit, isProcessing },
|
|
998
1073
|
ChatInput,
|
|
999
1074
|
slots
|
|
1000
1075
|
) }),
|
|
1001
|
-
|
|
1076
|
+
chunkUXVOUC2A_cjs.renderSlot("footer", { footerText: props.footerText }, ChatFooter, slots)
|
|
1002
1077
|
] })
|
|
1003
1078
|
] });
|
|
1004
1079
|
}
|
|
1005
1080
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex h-full flex-col", dir: direction, style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
1006
|
-
!props.hideHeader &&
|
|
1081
|
+
!props.hideHeader && chunkUXVOUC2A_cjs.renderSlot("header", headerProps, ChatHeader, slots),
|
|
1007
1082
|
storeOrigin && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1008
1083
|
CartDrawer,
|
|
1009
1084
|
{
|
|
@@ -1013,29 +1088,53 @@ function ChatInterface(props) {
|
|
|
1013
1088
|
onCartUpdate: (count) => setCartCount(count)
|
|
1014
1089
|
}
|
|
1015
1090
|
),
|
|
1016
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1017
|
-
messages.length === 0 &&
|
|
1091
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk6CVBJ4EI_cjs.Conversation, { className: "flex-1", children: /* @__PURE__ */ jsxRuntime.jsxs(chunk6CVBJ4EI_cjs.ConversationContent, { className: "px-[15px] md:px-[40px] py-6 sm:py-8 w-full space-y-6", children: [
|
|
1092
|
+
messages.length === 0 && chunkUXVOUC2A_cjs.renderSlot("emptyState", {}, chunk6CVBJ4EI_cjs.ConversationEmptyState, slots),
|
|
1018
1093
|
messages.map((message, messageIndex) => {
|
|
1019
1094
|
if (hideFirstUserMessage && messageIndex === 0 && message.role === "user") return null;
|
|
1020
1095
|
if (message.role === "system") {
|
|
1021
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children:
|
|
1096
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunkUXVOUC2A_cjs.renderSlot("systemMessage", { message: message.content }, SystemMessage, slots) }, message.id);
|
|
1022
1097
|
}
|
|
1023
1098
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1024
1099
|
"div",
|
|
1025
1100
|
{
|
|
1026
1101
|
className: `group ${message.role === "assistant" ? "is-assistant" : "is-user"}`,
|
|
1027
1102
|
children: [
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1103
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1104
|
+
chunk6CVBJ4EI_cjs.MessageAttachments,
|
|
1105
|
+
{
|
|
1106
|
+
className: message.role === "user" ? "mb-2" : "mr-auto ml-0 mb-2",
|
|
1107
|
+
children: (message.parts || []).filter((p) => p.type === "file" && p.url).map((p, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1108
|
+
chunk6CVBJ4EI_cjs.MessageAttachment,
|
|
1109
|
+
{
|
|
1110
|
+
className: "size-32",
|
|
1111
|
+
data: {
|
|
1112
|
+
type: "file",
|
|
1113
|
+
url: p.url,
|
|
1114
|
+
mediaType: p.mediaType ?? "",
|
|
1115
|
+
filename: p.filename
|
|
1116
|
+
}
|
|
1117
|
+
},
|
|
1118
|
+
`${message.id}-file-${i}`
|
|
1119
|
+
))
|
|
1120
|
+
}
|
|
1121
|
+
),
|
|
1122
|
+
(() => {
|
|
1123
|
+
const parts = (message.parts || []).filter(
|
|
1124
|
+
(p) => p.type !== "file" && !(p.type === "text" && !(p.text || "").trim())
|
|
1125
|
+
);
|
|
1126
|
+
return props.messagePartOrder === "stream-order" ? parts : [...parts].sort((a, b) => {
|
|
1127
|
+
const textFirst = props.messagePartOrder !== "tools-first";
|
|
1128
|
+
if (a.type === "text" && b.type !== "text") return textFirst ? -1 : 1;
|
|
1129
|
+
if (a.type !== "text" && b.type === "text") return textFirst ? 1 : -1;
|
|
1130
|
+
return 0;
|
|
1131
|
+
});
|
|
1132
|
+
})().map((part, i) => {
|
|
1034
1133
|
if (part.type === "text") {
|
|
1035
1134
|
if (message.role === "assistant") {
|
|
1036
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children:
|
|
1135
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunkUXVOUC2A_cjs.renderSlot("assistantMessage", { message, partIndex: i, text: part.text || "" }, DefaultAssistantMessage, slots) }, `${message.id}-${i}`);
|
|
1037
1136
|
}
|
|
1038
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { children:
|
|
1137
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { children: chunkUXVOUC2A_cjs.renderSlot("userMessage", { message, partIndex: i, text: part.text || "" }, DefaultUserMessage, slots) }, `${message.id}-${i}`);
|
|
1039
1138
|
}
|
|
1040
1139
|
if (part.type.startsWith("tool-")) {
|
|
1041
1140
|
const toolName = part.type.replace("tool-", "");
|
|
@@ -1053,7 +1152,7 @@ function ChatInterface(props) {
|
|
|
1053
1152
|
{
|
|
1054
1153
|
label: `tool "${toolName}"`,
|
|
1055
1154
|
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1056
|
-
|
|
1155
|
+
chunkJEK2V5I3_cjs.ToolRenderer,
|
|
1057
1156
|
{
|
|
1058
1157
|
toolName,
|
|
1059
1158
|
state: part.state ?? "output-available",
|
|
@@ -1072,10 +1171,10 @@ function ChatInterface(props) {
|
|
|
1072
1171
|
showSources && message.role === "assistant" && (() => {
|
|
1073
1172
|
const kbSources = extractKbSources(message.parts);
|
|
1074
1173
|
if (kbSources.length === 0) return null;
|
|
1075
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1076
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1077
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1078
|
-
|
|
1174
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(chunk6CVBJ4EI_cjs.Sources, { children: [
|
|
1175
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk6CVBJ4EI_cjs.SourcesTrigger, { count: kbSources.length }),
|
|
1176
|
+
/* @__PURE__ */ jsxRuntime.jsx(chunk6CVBJ4EI_cjs.SourcesContent, { children: kbSources.map((s, idx) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1177
|
+
chunk6CVBJ4EI_cjs.Source,
|
|
1079
1178
|
{
|
|
1080
1179
|
href: s.sourceUrl ?? "#",
|
|
1081
1180
|
title: s.documentName || s.pageTitle || `Source ${idx + 1}`
|
|
@@ -1084,14 +1183,14 @@ function ChatInterface(props) {
|
|
|
1084
1183
|
)) })
|
|
1085
1184
|
] });
|
|
1086
1185
|
})(),
|
|
1087
|
-
message.role === "assistant" &&
|
|
1186
|
+
message.role === "assistant" && chunkUXVOUC2A_cjs.renderSlot("feedback", {
|
|
1088
1187
|
messageId: message.id,
|
|
1089
1188
|
projectId: config.projectId,
|
|
1090
1189
|
sessionId,
|
|
1091
1190
|
apiKey: config.apiKey,
|
|
1092
1191
|
apiEndpoint: config.apiEndpoint,
|
|
1093
1192
|
textContent: (message.parts || []).filter((p) => p.type === "text").map((p) => p.text || "").join("\n") || (typeof message.content === "string" ? message.content : "")
|
|
1094
|
-
},
|
|
1193
|
+
}, chunk6CVBJ4EI_cjs.MessageFeedback, slots)
|
|
1095
1194
|
]
|
|
1096
1195
|
},
|
|
1097
1196
|
message.id
|
|
@@ -1105,7 +1204,17 @@ function ChatInterface(props) {
|
|
|
1105
1204
|
);
|
|
1106
1205
|
const allToolsComplete = (lastMessage.parts || []).filter((p) => p.type.startsWith("tool-")).every((p) => p.state === "output-available");
|
|
1107
1206
|
return allToolsComplete && !hasText;
|
|
1108
|
-
})() && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1207
|
+
})() && /* @__PURE__ */ jsxRuntime.jsx(chunk6CVBJ4EI_cjs.Loader, { text: t("thinking") }),
|
|
1208
|
+
status === "error" && chunkUXVOUC2A_cjs.renderSlot(
|
|
1209
|
+
"error",
|
|
1210
|
+
{
|
|
1211
|
+
error,
|
|
1212
|
+
onRetry: retryLastTurn,
|
|
1213
|
+
onNewConversation: handleNewConversation
|
|
1214
|
+
},
|
|
1215
|
+
ChatError,
|
|
1216
|
+
slots
|
|
1217
|
+
)
|
|
1109
1218
|
] }) }),
|
|
1110
1219
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "shrink-0 px-[15px] md:px-[40px] pb-2", style: { backgroundColor: "var(--ac-background)" }, children: [
|
|
1111
1220
|
props.pageQuestions && props.pageQuestions.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1118,9 +1227,9 @@ function ChatInterface(props) {
|
|
|
1118
1227
|
}
|
|
1119
1228
|
),
|
|
1120
1229
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mx-auto z-40 w-full flex items-end gap-2", children: [
|
|
1121
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children:
|
|
1230
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-1", children: chunkUXVOUC2A_cjs.renderSlot(
|
|
1122
1231
|
"input",
|
|
1123
|
-
{ value: input, onChange: setInput, onSubmit:
|
|
1232
|
+
{ value: input, onChange: setInput, onSubmit: handleSubmit, isProcessing },
|
|
1124
1233
|
ChatInput,
|
|
1125
1234
|
slots
|
|
1126
1235
|
) }),
|
|
@@ -1135,7 +1244,7 @@ function ChatInterface(props) {
|
|
|
1135
1244
|
}
|
|
1136
1245
|
)
|
|
1137
1246
|
] }),
|
|
1138
|
-
|
|
1247
|
+
chunkUXVOUC2A_cjs.renderSlot("footer", { footerText: props.footerText }, ChatFooter, slots)
|
|
1139
1248
|
] }),
|
|
1140
1249
|
/* @__PURE__ */ jsxRuntime.jsx("span", { "data-session-id": sessionId, className: "hidden" })
|
|
1141
1250
|
] });
|
|
@@ -1168,11 +1277,11 @@ function FloatingButton({
|
|
|
1168
1277
|
hideGreeting = false
|
|
1169
1278
|
}) {
|
|
1170
1279
|
const [showGreeting, setShowGreeting] = react.useState(false);
|
|
1171
|
-
const { t, direction } =
|
|
1280
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1172
1281
|
const isRtl = direction === "rtl";
|
|
1173
1282
|
const effectiveGreeting = greeting || t("greeting");
|
|
1174
1283
|
const [greetingDismissed, setGreetingDismissed] = react.useState(false);
|
|
1175
|
-
const isMobile =
|
|
1284
|
+
const isMobile = chunkDVWX2UGY_cjs.useIsMobile();
|
|
1176
1285
|
const effectivePosition = isMobile && positionMobile ? positionMobile : position;
|
|
1177
1286
|
const isRightSide = effectivePosition === "bottom-right" || effectivePosition === "top-right";
|
|
1178
1287
|
const isBottom = effectivePosition === "bottom-right" || effectivePosition === "bottom-left";
|
|
@@ -1299,12 +1408,12 @@ function FloatingButton({
|
|
|
1299
1408
|
);
|
|
1300
1409
|
}
|
|
1301
1410
|
function useLiveChatOrThrow() {
|
|
1302
|
-
const ctx =
|
|
1411
|
+
const ctx = chunkDVWX2UGY_cjs.useLiveChat();
|
|
1303
1412
|
if (!ctx) throw new Error("LiveChat sub-view rendered outside LiveChatProvider \u2014 this should never happen");
|
|
1304
1413
|
return ctx;
|
|
1305
1414
|
}
|
|
1306
1415
|
function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex }) {
|
|
1307
|
-
const lc =
|
|
1416
|
+
const lc = chunkDVWX2UGY_cjs.useLiveChat();
|
|
1308
1417
|
if (!lc) return null;
|
|
1309
1418
|
const isActive = lc.state !== "ai" || lc.showIdentityForm;
|
|
1310
1419
|
const showPanel = isWidgetOpen && isActive;
|
|
@@ -1340,8 +1449,8 @@ function LiveChatPanel({ isWidgetOpen, isRightSide, zIndex }) {
|
|
|
1340
1449
|
);
|
|
1341
1450
|
}
|
|
1342
1451
|
function MobileLiveChatDrawer() {
|
|
1343
|
-
const lc =
|
|
1344
|
-
const { t } =
|
|
1452
|
+
const lc = chunkDVWX2UGY_cjs.useLiveChat();
|
|
1453
|
+
const { t } = chunk72QJ2ORD_cjs.useI18n();
|
|
1345
1454
|
if (!lc) return null;
|
|
1346
1455
|
const isActive = lc.state !== "ai" || lc.showIdentityForm;
|
|
1347
1456
|
const [minimized, setMinimized] = react.useState(false);
|
|
@@ -1422,7 +1531,7 @@ function isValidEmail(email) {
|
|
|
1422
1531
|
}
|
|
1423
1532
|
function IdentityView() {
|
|
1424
1533
|
const lc = useLiveChatOrThrow();
|
|
1425
|
-
const { t, direction } =
|
|
1534
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1426
1535
|
const userInfo = lc.userInfo;
|
|
1427
1536
|
const [name, setName] = react.useState(userInfo?.name || "");
|
|
1428
1537
|
const [email, setEmail] = react.useState(userInfo?.email || "");
|
|
@@ -1500,7 +1609,7 @@ function IdentityView() {
|
|
|
1500
1609
|
}
|
|
1501
1610
|
function QueueView() {
|
|
1502
1611
|
const lc = useLiveChatOrThrow();
|
|
1503
|
-
const { t, direction } =
|
|
1612
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1504
1613
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 flex flex-col items-center justify-center p-8 text-center", dir: direction, children: [
|
|
1505
1614
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-16 w-16 rounded-2xl bg-blue-50 flex items-center justify-center mb-4", children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Headset, { className: "h-8 w-8 text-blue-500" }) }),
|
|
1506
1615
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-blue-500 animate-pulse mb-4" }),
|
|
@@ -1519,7 +1628,7 @@ function QueueView() {
|
|
|
1519
1628
|
}
|
|
1520
1629
|
function ChatView() {
|
|
1521
1630
|
const lc = useLiveChatOrThrow();
|
|
1522
|
-
const { t, language, direction } =
|
|
1631
|
+
const { t, language, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1523
1632
|
const [input, setInput] = react.useState("");
|
|
1524
1633
|
const messagesEndRef = react.useRef(null);
|
|
1525
1634
|
const isRTL = direction === "rtl";
|
|
@@ -1626,7 +1735,7 @@ function ChatView() {
|
|
|
1626
1735
|
}
|
|
1627
1736
|
function EndedView() {
|
|
1628
1737
|
const lc = useLiveChatOrThrow();
|
|
1629
|
-
const { t, direction } =
|
|
1738
|
+
const { t, direction } = chunk72QJ2ORD_cjs.useI18n();
|
|
1630
1739
|
const [selected, setSelected] = react.useState(null);
|
|
1631
1740
|
const [comment, setComment] = react.useState("");
|
|
1632
1741
|
const [submitted, setSubmitted] = react.useState(false);
|
|
@@ -1718,7 +1827,7 @@ function EndedView() {
|
|
|
1718
1827
|
] });
|
|
1719
1828
|
}
|
|
1720
1829
|
function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
|
|
1721
|
-
const previewEmbed =
|
|
1830
|
+
const previewEmbed = chunkDVWX2UGY_cjs.usePreviewEmbed();
|
|
1722
1831
|
if (!previewEmbed) return null;
|
|
1723
1832
|
const { preview, closePreview } = previewEmbed;
|
|
1724
1833
|
const showPanel = isOpen && !!preview;
|
|
@@ -1774,6 +1883,7 @@ function PreviewEmbedPanel({ isOpen, isRightSide, zIndex }) {
|
|
|
1774
1883
|
}
|
|
1775
1884
|
|
|
1776
1885
|
exports.CartDrawer = CartDrawer;
|
|
1886
|
+
exports.ChatError = ChatError;
|
|
1777
1887
|
exports.ChatErrorBoundary = ChatErrorBoundary;
|
|
1778
1888
|
exports.ChatFooter = ChatFooter;
|
|
1779
1889
|
exports.ChatHeader = ChatHeader;
|
|
@@ -1786,5 +1896,5 @@ exports.PreviewEmbedPanel = PreviewEmbedPanel;
|
|
|
1786
1896
|
exports.QuickQuestions = QuickQuestions;
|
|
1787
1897
|
exports.SystemMessage = SystemMessage;
|
|
1788
1898
|
exports.WelcomePage = WelcomePage;
|
|
1789
|
-
//# sourceMappingURL=chunk-
|
|
1790
|
-
//# sourceMappingURL=chunk-
|
|
1899
|
+
//# sourceMappingURL=chunk-DTOOWY2S.cjs.map
|
|
1900
|
+
//# sourceMappingURL=chunk-DTOOWY2S.cjs.map
|