@asgard-js/react 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +142 -21
- package/dist/components/chatbot/chatbot-body/chatbot-body.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-body/conversation-message-renderer.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-body/index.d.ts +2 -0
- package/dist/components/chatbot/chatbot-body/index.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-container/chatbot-container.d.ts +8 -0
- package/dist/components/chatbot/chatbot-container/chatbot-container.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-container/chatbot-full-screen-container.d.ts +4 -0
- package/dist/components/chatbot/chatbot-container/chatbot-full-screen-container.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-footer/chatbot-footer.d.ts.map +1 -1
- package/dist/components/chatbot/chatbot-header/chatbot-header.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot-header/index.d.ts +2 -0
- package/dist/components/chatbot/chatbot-header/index.d.ts.map +1 -0
- package/dist/components/chatbot/chatbot.d.ts.map +1 -1
- package/dist/components/templates/hint-template/hint-template.d.ts.map +1 -1
- package/dist/components/templates/index.d.ts +0 -1
- package/dist/components/templates/index.d.ts.map +1 -1
- package/dist/components/templates/text-template/bot-typing-box.d.ts.map +1 -0
- package/dist/components/templates/text-template/bot-typing-placeholder.d.ts.map +1 -0
- package/dist/components/templates/text-template/index.d.ts +2 -0
- package/dist/components/templates/text-template/index.d.ts.map +1 -1
- package/dist/components/templates/text-template/text-template.d.ts.map +1 -1
- package/dist/context/asgard-service-context.d.ts.map +1 -1
- package/dist/context/asgard-theme-context.d.ts +0 -1
- package/dist/context/asgard-theme-context.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/use-channel.d.ts.map +1 -1
- package/dist/hooks/use-is-on-screen-keyboard-open.d.ts +2 -0
- package/dist/hooks/use-is-on-screen-keyboard-open.d.ts.map +1 -0
- package/dist/hooks/use-on-screen-keyboard-scroll-fix.d.ts +2 -0
- package/dist/hooks/use-on-screen-keyboard-scroll-fix.d.ts.map +1 -0
- package/dist/hooks/use-prevent-over-scrolling.d.ts +4 -0
- package/dist/hooks/use-prevent-over-scrolling.d.ts.map +1 -0
- package/dist/hooks/use-resize-observer.d.ts +9 -0
- package/dist/hooks/use-resize-observer.d.ts.map +1 -0
- package/dist/hooks/use-update-vh.d.ts +4 -0
- package/dist/hooks/use-update-vh.d.ts.map +1 -0
- package/dist/hooks/use-viewport-size.d.ts +6 -0
- package/dist/hooks/use-viewport-size.d.ts.map +1 -0
- package/dist/index.js +566 -380
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/dist/components/chatbot/chatbot-body.d.ts.map +0 -1
- package/dist/components/chatbot/chatbot-header.d.ts.map +0 -1
- package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts.map +0 -1
- package/dist/components/conversation-message-renderer/index.d.ts +0 -2
- package/dist/components/conversation-message-renderer/index.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/bot-typing-placeholder.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/index.d.ts +0 -3
- package/dist/components/templates/bot-typing-box/index.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/resize-observer-box.d.ts +0 -9
- package/dist/components/templates/bot-typing-box/resize-observer-box.d.ts.map +0 -1
- /package/dist/components/chatbot/{chatbot-body.d.ts → chatbot-body/chatbot-body.d.ts} +0 -0
- /package/dist/components/{conversation-message-renderer → chatbot/chatbot-body}/conversation-message-renderer.d.ts +0 -0
- /package/dist/components/chatbot/{chatbot-header.d.ts → chatbot-header/chatbot-header.d.ts} +0 -0
- /package/dist/components/templates/{bot-typing-box → text-template}/bot-typing-box.d.ts +0 -0
- /package/dist/components/templates/{bot-typing-box → text-template}/bot-typing-placeholder.d.ts +0 -0
package/dist/index.js
CHANGED
|
@@ -1,36 +1,23 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
2
|
-
import * as
|
|
3
|
-
import { createContext as
|
|
4
|
-
import { AsgardServiceClient as
|
|
5
|
-
function
|
|
6
|
-
var t, o, n = "";
|
|
7
|
-
if (typeof e == "string" || typeof e == "number") n += e;
|
|
8
|
-
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
9
|
-
var r = e.length;
|
|
10
|
-
for (t = 0; t < r; t++) e[t] && (o = ot(e[t])) && (n && (n += " "), n += o);
|
|
11
|
-
} else for (o in e) e[o] && (n && (n += " "), n += o);
|
|
12
|
-
return n;
|
|
13
|
-
}
|
|
14
|
-
function R() {
|
|
15
|
-
for (var e, t, o = 0, n = "", r = arguments.length; o < r; o++) (e = arguments[o]) && (t = ot(e)) && (n && (n += " "), n += t);
|
|
16
|
-
return n;
|
|
17
|
-
}
|
|
18
|
-
function F(e) {
|
|
1
|
+
import { jsx as s, jsxs as p } from "react/jsx-runtime";
|
|
2
|
+
import * as g from "react";
|
|
3
|
+
import { createContext as nt, useMemo as C, useContext as ot, useRef as M, useEffect as w, useState as x, useCallback as b, useLayoutEffect as rt, memo as gt } from "react";
|
|
4
|
+
import { AsgardServiceClient as ft, Conversation as mt, Channel as bt, MessageTemplateType as A } from "@asgard-js/core";
|
|
5
|
+
function U(e) {
|
|
19
6
|
return e !== null && typeof e == "object" && !Array.isArray(e);
|
|
20
7
|
}
|
|
21
|
-
function
|
|
8
|
+
function st(e, t) {
|
|
22
9
|
const o = { ...e };
|
|
23
10
|
if (!t) return o;
|
|
24
11
|
for (const [n, r] of Object.entries(t)) {
|
|
25
|
-
if (!
|
|
12
|
+
if (!U(r)) {
|
|
26
13
|
o[n] = r;
|
|
27
14
|
continue;
|
|
28
15
|
}
|
|
29
|
-
o[n] =
|
|
16
|
+
o[n] = st(U(o[n]) ? o[n] : {}, r);
|
|
30
17
|
}
|
|
31
18
|
return o;
|
|
32
19
|
}
|
|
33
|
-
const
|
|
20
|
+
const ct = {
|
|
34
21
|
chatbot: {
|
|
35
22
|
width: "375px",
|
|
36
23
|
height: "640px",
|
|
@@ -47,35 +34,26 @@ const nt = {
|
|
|
47
34
|
color: "var(--asg-color-text)",
|
|
48
35
|
backgroundColor: "var(--asg-color-primary)"
|
|
49
36
|
}
|
|
50
|
-
},
|
|
51
|
-
|
|
37
|
+
}, it = nt(
|
|
38
|
+
ct
|
|
52
39
|
);
|
|
53
|
-
function
|
|
54
|
-
const { children: t,
|
|
55
|
-
() =>
|
|
56
|
-
|
|
57
|
-
o ? P(n, {
|
|
58
|
-
chatbot: {
|
|
59
|
-
width: "100vw",
|
|
60
|
-
height: "100vh",
|
|
61
|
-
borderRadius: "var(--asg-radius-none)"
|
|
62
|
-
}
|
|
63
|
-
}) : n
|
|
64
|
-
),
|
|
65
|
-
[o, n]
|
|
40
|
+
function pt(e) {
|
|
41
|
+
const { children: t, theme: o = {} } = e, n = C(
|
|
42
|
+
() => st(ct, o),
|
|
43
|
+
[o]
|
|
66
44
|
);
|
|
67
|
-
return /* @__PURE__ */ s(
|
|
45
|
+
return /* @__PURE__ */ s(it.Provider, { value: n, children: t });
|
|
68
46
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
47
|
+
function z() {
|
|
48
|
+
return ot(it);
|
|
71
49
|
}
|
|
72
|
-
function
|
|
73
|
-
const { config: t } = e, o =
|
|
74
|
-
return o.current || (o.current = new
|
|
50
|
+
function vt(e) {
|
|
51
|
+
const { config: t } = e, o = M(null);
|
|
52
|
+
return o.current || (o.current = new ft(t)), w(() => () => {
|
|
75
53
|
o.current && (o.current.close(), o.current = null);
|
|
76
54
|
}, [t]), o.current;
|
|
77
55
|
}
|
|
78
|
-
function
|
|
56
|
+
function Ct(e) {
|
|
79
57
|
const {
|
|
80
58
|
client: t,
|
|
81
59
|
customChannelId: o,
|
|
@@ -87,78 +65,205 @@ function gt(e) {
|
|
|
87
65
|
throw new Error("Client instance is required");
|
|
88
66
|
if (!o)
|
|
89
67
|
throw new Error("Custom channel id is required");
|
|
90
|
-
const [i, a] =
|
|
91
|
-
const
|
|
68
|
+
const [i, a] = x(null), [l, d] = x(!0), [h, f] = x(!1), [u, _] = x(!1), [m, v] = x(null), E = b(async () => {
|
|
69
|
+
const L = new mt({
|
|
92
70
|
showDebugMessage: c,
|
|
93
71
|
messages: new Map(
|
|
94
|
-
r == null ? void 0 : r.map((
|
|
72
|
+
r == null ? void 0 : r.map((H) => [H.messageId, H])
|
|
95
73
|
)
|
|
96
74
|
});
|
|
97
|
-
f(!0),
|
|
98
|
-
const
|
|
75
|
+
f(!0), _(!0), v(L);
|
|
76
|
+
const ht = await bt.reset(
|
|
99
77
|
{
|
|
100
78
|
client: t,
|
|
101
79
|
customChannelId: o,
|
|
102
80
|
customMessageId: n,
|
|
103
|
-
conversation:
|
|
104
|
-
statesObserver: (
|
|
105
|
-
|
|
81
|
+
conversation: L,
|
|
82
|
+
statesObserver: (H) => {
|
|
83
|
+
_(H.isConnecting), v(H.conversation);
|
|
106
84
|
}
|
|
107
85
|
},
|
|
108
86
|
{
|
|
109
87
|
onSseCompleted() {
|
|
110
88
|
f(!1);
|
|
89
|
+
},
|
|
90
|
+
onSseError() {
|
|
91
|
+
f(!1);
|
|
111
92
|
}
|
|
112
93
|
}
|
|
113
94
|
);
|
|
114
|
-
a(
|
|
95
|
+
a(ht);
|
|
115
96
|
}, [
|
|
116
97
|
t,
|
|
117
98
|
o,
|
|
118
99
|
n,
|
|
119
100
|
r,
|
|
120
101
|
c
|
|
121
|
-
]),
|
|
122
|
-
a((
|
|
123
|
-
}, []),
|
|
124
|
-
(
|
|
125
|
-
i == null || i.sendMessage({ text:
|
|
102
|
+
]), S = b(() => {
|
|
103
|
+
a((L) => (L == null || L.close(), null)), d(!1), f(!1), _(!1), v(null);
|
|
104
|
+
}, []), W = b(
|
|
105
|
+
(L) => {
|
|
106
|
+
i == null || i.sendMessage({ text: L });
|
|
126
107
|
},
|
|
127
108
|
[i]
|
|
128
109
|
);
|
|
129
|
-
return
|
|
130
|
-
!i &&
|
|
131
|
-
}, [i,
|
|
110
|
+
return w(() => {
|
|
111
|
+
!i && l && E();
|
|
112
|
+
}, [i, l, E]), w(() => () => S(), [S]), C(
|
|
132
113
|
() => ({
|
|
133
|
-
isOpen:
|
|
134
|
-
isResetting:
|
|
135
|
-
isConnecting:
|
|
136
|
-
conversation:
|
|
137
|
-
sendMessage:
|
|
138
|
-
resetChannel:
|
|
139
|
-
closeChannel:
|
|
114
|
+
isOpen: l,
|
|
115
|
+
isResetting: h,
|
|
116
|
+
isConnecting: u,
|
|
117
|
+
conversation: m,
|
|
118
|
+
sendMessage: W,
|
|
119
|
+
resetChannel: E,
|
|
120
|
+
closeChannel: S
|
|
140
121
|
}),
|
|
141
122
|
[
|
|
142
|
-
_,
|
|
143
|
-
v,
|
|
144
123
|
l,
|
|
145
124
|
h,
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
125
|
+
u,
|
|
126
|
+
m,
|
|
127
|
+
W,
|
|
128
|
+
E,
|
|
129
|
+
S
|
|
149
130
|
]
|
|
150
131
|
);
|
|
151
132
|
}
|
|
152
|
-
function
|
|
153
|
-
const [o, n] =
|
|
154
|
-
return
|
|
133
|
+
function wt(e, t) {
|
|
134
|
+
const [o, n] = x(e);
|
|
135
|
+
return w(() => {
|
|
155
136
|
const r = window.setTimeout(() => {
|
|
156
137
|
n(e);
|
|
157
138
|
}, t ?? 300);
|
|
158
139
|
return () => clearTimeout(r);
|
|
159
140
|
}, [e, t]), o;
|
|
160
141
|
}
|
|
161
|
-
const
|
|
142
|
+
const D = typeof window < "u" ? rt : null;
|
|
143
|
+
function xt() {
|
|
144
|
+
return window.visualViewport ? [window.visualViewport.width, window.visualViewport.height] : [window.innerWidth, window.innerHeight];
|
|
145
|
+
}
|
|
146
|
+
function yt() {
|
|
147
|
+
const [e, t] = x(), o = b(() => {
|
|
148
|
+
const n = xt();
|
|
149
|
+
t(
|
|
150
|
+
(r) => r && r[0] === n[0] && r[1] === n[1] ? r : n
|
|
151
|
+
);
|
|
152
|
+
}, []);
|
|
153
|
+
return D == null || D(o, [o]), w(() => {
|
|
154
|
+
var r;
|
|
155
|
+
function n() {
|
|
156
|
+
o(), setTimeout(o, 1e3);
|
|
157
|
+
}
|
|
158
|
+
return window.addEventListener("resize", n), window.addEventListener("orientationchange", n), (r = window.visualViewport) == null || r.addEventListener("resize", n), () => {
|
|
159
|
+
var c;
|
|
160
|
+
window.removeEventListener("resize", n), window.removeEventListener("orientationchange", n), (c = window.visualViewport) == null || c.removeEventListener("resize", n);
|
|
161
|
+
};
|
|
162
|
+
}, [o]), e;
|
|
163
|
+
}
|
|
164
|
+
function K(e) {
|
|
165
|
+
return ["INPUT", "TEXTAREA"].includes(e.tagName) && !["button", "submit", "checkbox", "file", "image"].includes(
|
|
166
|
+
e.type
|
|
167
|
+
) || e.hasAttribute("contenteditable");
|
|
168
|
+
}
|
|
169
|
+
function Tt() {
|
|
170
|
+
const [e, t] = x(!1);
|
|
171
|
+
return w(() => {
|
|
172
|
+
function o(r) {
|
|
173
|
+
if (!r.target) return;
|
|
174
|
+
const c = r.target;
|
|
175
|
+
K(c) && t(!0);
|
|
176
|
+
}
|
|
177
|
+
function n(r) {
|
|
178
|
+
if (!r.target) return;
|
|
179
|
+
const c = r.target;
|
|
180
|
+
K(c) && t(!1);
|
|
181
|
+
}
|
|
182
|
+
return document.addEventListener("focusin", o), document.addEventListener("focusout", n), () => {
|
|
183
|
+
document.removeEventListener("focusin", o), document.removeEventListener("focusout", n);
|
|
184
|
+
};
|
|
185
|
+
}, []), e;
|
|
186
|
+
}
|
|
187
|
+
function Nt() {
|
|
188
|
+
w(() => {
|
|
189
|
+
function e() {
|
|
190
|
+
window.scrollTo(0, 0);
|
|
191
|
+
}
|
|
192
|
+
return window.addEventListener("scroll", e), () => {
|
|
193
|
+
window.removeEventListener("scroll", e);
|
|
194
|
+
};
|
|
195
|
+
}, []);
|
|
196
|
+
}
|
|
197
|
+
function at(e) {
|
|
198
|
+
if (e.scrollHeight > e.offsetHeight)
|
|
199
|
+
return e;
|
|
200
|
+
const t = e.parentElement;
|
|
201
|
+
if (t)
|
|
202
|
+
return at(t);
|
|
203
|
+
}
|
|
204
|
+
function Et(e) {
|
|
205
|
+
w(() => {
|
|
206
|
+
const t = e.current;
|
|
207
|
+
if (!t) return;
|
|
208
|
+
let o;
|
|
209
|
+
function n(c) {
|
|
210
|
+
c.touches.length === 1 && (o = c.touches[0]);
|
|
211
|
+
}
|
|
212
|
+
function r(c) {
|
|
213
|
+
if (c.touches.length !== 1 || !o) return;
|
|
214
|
+
const i = o.pageY - c.targetTouches[0].pageY, a = o.pageX - c.targetTouches[0].pageX;
|
|
215
|
+
if (Math.abs(a) > Math.abs(i)) return;
|
|
216
|
+
const l = c.target, d = at(l);
|
|
217
|
+
if (!d) {
|
|
218
|
+
c.preventDefault();
|
|
219
|
+
return;
|
|
220
|
+
}
|
|
221
|
+
const h = i < 0, f = d.scrollTop === 0;
|
|
222
|
+
if (h && f) {
|
|
223
|
+
c.preventDefault();
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
const u = d.scrollTop === d.scrollHeight - d.clientHeight;
|
|
227
|
+
if (!h && u) {
|
|
228
|
+
c.preventDefault();
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return t.addEventListener("touchstart", n), t.addEventListener("touchmove", r), () => {
|
|
233
|
+
t.removeEventListener("touchstart", n), t.removeEventListener("touchmove", r);
|
|
234
|
+
};
|
|
235
|
+
}, [e]);
|
|
236
|
+
}
|
|
237
|
+
const j = typeof window < "u" ? rt : null;
|
|
238
|
+
function Lt(e) {
|
|
239
|
+
const t = b(() => {
|
|
240
|
+
const o = window.innerHeight * 0.01;
|
|
241
|
+
e.current && e.current.style.setProperty("--vh", `${o}px`);
|
|
242
|
+
}, [e]);
|
|
243
|
+
j == null || j(t, [t]), w(() => {
|
|
244
|
+
function o() {
|
|
245
|
+
t(), setTimeout(t, 1e3);
|
|
246
|
+
}
|
|
247
|
+
return t(), window.addEventListener("resize", o), () => {
|
|
248
|
+
window.removeEventListener("resize", o);
|
|
249
|
+
};
|
|
250
|
+
}, [t]);
|
|
251
|
+
}
|
|
252
|
+
function kt(e) {
|
|
253
|
+
const { ref: t, onResize: o } = e;
|
|
254
|
+
w(() => {
|
|
255
|
+
const n = new ResizeObserver((r) => {
|
|
256
|
+
for (const c of r) {
|
|
257
|
+
const { width: i, height: a } = c.contentRect;
|
|
258
|
+
o(i, a);
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
return t.current && n.observe(t.current), () => {
|
|
262
|
+
n.disconnect();
|
|
263
|
+
};
|
|
264
|
+
}, [t, o]);
|
|
265
|
+
}
|
|
266
|
+
const lt = nt({
|
|
162
267
|
avatar: void 0,
|
|
163
268
|
client: null,
|
|
164
269
|
isOpen: !1,
|
|
@@ -168,70 +273,67 @@ const rt = tt({
|
|
|
168
273
|
messageBoxBottomRef: { current: null },
|
|
169
274
|
botTypingPlaceholder: void 0
|
|
170
275
|
});
|
|
171
|
-
function
|
|
276
|
+
function Mt(e) {
|
|
172
277
|
const {
|
|
173
278
|
avatar: t,
|
|
174
279
|
children: o,
|
|
175
280
|
config: n,
|
|
176
281
|
botTypingPlaceholder: r,
|
|
177
282
|
customChannelId: c,
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
closeChannel: x
|
|
191
|
-
} = gt({
|
|
192
|
-
client: l,
|
|
283
|
+
initMessages: i,
|
|
284
|
+
options: a
|
|
285
|
+
} = e, l = M(null), d = vt({ config: n }), {
|
|
286
|
+
isOpen: h,
|
|
287
|
+
isResetting: f,
|
|
288
|
+
isConnecting: u,
|
|
289
|
+
conversation: _,
|
|
290
|
+
sendMessage: m,
|
|
291
|
+
resetChannel: v,
|
|
292
|
+
closeChannel: E
|
|
293
|
+
} = Ct({
|
|
294
|
+
client: d,
|
|
193
295
|
customChannelId: c,
|
|
194
|
-
initMessages:
|
|
195
|
-
showDebugMessage:
|
|
196
|
-
}),
|
|
296
|
+
initMessages: i,
|
|
297
|
+
showDebugMessage: a == null ? void 0 : a.showDebugMessage
|
|
298
|
+
}), S = C(
|
|
197
299
|
() => ({
|
|
198
300
|
avatar: t,
|
|
199
|
-
client:
|
|
200
|
-
isOpen:
|
|
201
|
-
isResetting:
|
|
202
|
-
isConnecting:
|
|
203
|
-
messages: (
|
|
204
|
-
sendMessage:
|
|
205
|
-
resetChannel:
|
|
206
|
-
closeChannel:
|
|
301
|
+
client: d,
|
|
302
|
+
isOpen: h,
|
|
303
|
+
isResetting: f,
|
|
304
|
+
isConnecting: u,
|
|
305
|
+
messages: (_ == null ? void 0 : _.messages) ?? null,
|
|
306
|
+
sendMessage: m,
|
|
307
|
+
resetChannel: v,
|
|
308
|
+
closeChannel: E,
|
|
207
309
|
botTypingPlaceholder: r,
|
|
208
|
-
messageBoxBottomRef:
|
|
310
|
+
messageBoxBottomRef: l
|
|
209
311
|
}),
|
|
210
312
|
[
|
|
211
313
|
t,
|
|
212
|
-
l,
|
|
213
314
|
d,
|
|
214
315
|
h,
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
316
|
+
f,
|
|
317
|
+
u,
|
|
318
|
+
_ == null ? void 0 : _.messages,
|
|
319
|
+
m,
|
|
320
|
+
v,
|
|
321
|
+
E,
|
|
220
322
|
r
|
|
221
323
|
]
|
|
222
|
-
)
|
|
223
|
-
return /* @__PURE__ */ s(
|
|
224
|
-
}
|
|
225
|
-
function
|
|
226
|
-
return
|
|
227
|
-
}
|
|
228
|
-
const
|
|
229
|
-
chatbot_header:
|
|
230
|
-
chatbot_header__content:
|
|
231
|
-
chatbot_header__title:
|
|
232
|
-
chatbot_header__extra:
|
|
233
|
-
},
|
|
234
|
-
function
|
|
324
|
+
);
|
|
325
|
+
return /* @__PURE__ */ s(lt.Provider, { value: S, children: o });
|
|
326
|
+
}
|
|
327
|
+
function N() {
|
|
328
|
+
return ot(lt);
|
|
329
|
+
}
|
|
330
|
+
const St = "_chatbot_header_luxt4_1", Rt = "_chatbot_header__content_luxt4_4", zt = "_chatbot_header__title_luxt4_12", Ht = "_chatbot_header__extra_luxt4_23", Z = {
|
|
331
|
+
chatbot_header: St,
|
|
332
|
+
chatbot_header__content: Rt,
|
|
333
|
+
chatbot_header__title: zt,
|
|
334
|
+
chatbot_header__extra: Ht
|
|
335
|
+
}, Vt = (e) => /* @__PURE__ */ g.createElement("svg", { width: 33, height: 32, viewBox: "0 0 33 32", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("g", { clipPath: "url(#clip0_3084_29383)" }, /* @__PURE__ */ g.createElement("path", { d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z", fill: "#333333" }), /* @__PURE__ */ g.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M16.5788 6.33398C19.8925 6.33398 22.5788 9.02028 22.5788 12.334C22.5788 14.2211 21.7075 15.9048 20.3453 17.0047C23.6487 18.3735 26.0607 21.6974 26.4106 25.6673H24.4569C24.0206 21.6274 20.9742 18.4911 17.2591 18.3397L16.9776 18.334H16.5788H15.8437C12.0019 18.334 8.81164 21.5258 8.36437 25.6673H6.41064C6.76857 21.607 9.28344 18.2225 12.7029 16.9143C11.4036 15.8137 10.5788 14.1701 10.5788 12.334C10.5788 9.02028 13.265 6.33398 16.5788 6.33398ZM16.5788 16.334C18.7879 16.334 20.5788 14.5431 20.5788 12.334C20.5788 10.1248 18.7879 8.33398 16.5788 8.33398C14.3696 8.33398 12.5788 10.1248 12.5788 12.334C12.5788 14.5431 14.3696 16.334 16.5788 16.334Z", fill: "#8C8C8C" })), /* @__PURE__ */ g.createElement("defs", null, /* @__PURE__ */ g.createElement("clipPath", { id: "clip0_3084_29383" }, /* @__PURE__ */ g.createElement("path", { d: "M0.410645 16C0.410645 7.16344 7.57409 0 16.4106 0C25.2472 0 32.4106 7.16344 32.4106 16C32.4106 24.8366 25.2472 32 16.4106 32C7.57409 32 0.410645 24.8366 0.410645 16Z", fill: "white" }))));
|
|
336
|
+
function Bt(e) {
|
|
235
337
|
const { avatar: t } = e;
|
|
236
338
|
return t ? /* @__PURE__ */ s(
|
|
237
339
|
"img",
|
|
@@ -244,72 +346,86 @@ function wt(e) {
|
|
|
244
346
|
borderRadius: "50%"
|
|
245
347
|
}
|
|
246
348
|
}
|
|
247
|
-
) : /* @__PURE__ */ s(
|
|
349
|
+
) : /* @__PURE__ */ s(Vt, {});
|
|
248
350
|
}
|
|
249
|
-
const
|
|
250
|
-
function
|
|
251
|
-
const { title: t, onReset: o, onClose: n } = e, { chatbot: r } =
|
|
351
|
+
const At = (e) => /* @__PURE__ */ g.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M3.49453 2.3352C6.44049 -0.226723 10.9105 -0.106316 13.7142 2.69633C16.6428 5.62613 16.6428 10.3739 13.7144 13.3035C10.7846 16.2322 6.03581 16.2322 3.1073 13.3036C2.30873 12.505 1.71132 11.5536 1.34188 10.5109L1.78892 10.3525L1.34171 10.5106L1.22791 10.162C1.01752 9.46018 0.910643 8.73159 0.910643 7.9997H2.4542L2.46382 8.33865C2.49584 8.9024 2.60763 9.46037 2.79674 9.99539L2.7968 9.99536L2.90116 10.2683C3.19714 10.9887 3.63414 11.6475 4.19876 12.2121C6.52451 14.5379 10.2961 14.5379 12.6229 12.212C14.9486 9.88539 14.9486 6.11464 12.6227 3.78781C10.3306 1.49653 6.63579 1.46263 4.30292 3.68622L6.68087 3.68698V5.22954H3.49394H1.95141V3.68698V0.5H3.49394L3.49453 2.3352Z", fill: "#8C8C8C" })), It = (e) => /* @__PURE__ */ g.createElement("svg", { width: 15, height: 14, viewBox: "0 0 15 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M13.3496 0L7.41062 5.938L1.47162 0L0.411621 1.06L6.34962 6.999L0.411621 12.938L1.47162 13.999L7.41062 8.059L13.3496 13.999L14.4096 12.938L8.47162 6.999L14.4096 1.06L13.3496 0Z", fill: "#8C8C8C" }));
|
|
352
|
+
function Ot(e) {
|
|
353
|
+
const { title: t, onReset: o, onClose: n } = e, { chatbot: r } = z(), { avatar: c, isResetting: i, resetChannel: a, closeChannel: l } = N(), d = C(
|
|
252
354
|
() => ({
|
|
253
|
-
maxWidth: (r == null ? void 0 : r.contentMaxWidth) ?? "1200px"
|
|
355
|
+
maxWidth: (r == null ? void 0 : r.contentMaxWidth) ?? "1200px",
|
|
356
|
+
borderBottomColor: r == null ? void 0 : r.borderColor
|
|
254
357
|
}),
|
|
255
358
|
[r]
|
|
256
|
-
),
|
|
257
|
-
(
|
|
258
|
-
i || (
|
|
359
|
+
), h = b(
|
|
360
|
+
(u) => {
|
|
361
|
+
i || (u.stopPropagation(), o == null || o(), a == null || a());
|
|
259
362
|
},
|
|
260
363
|
[i, o, a]
|
|
261
|
-
), f =
|
|
262
|
-
(
|
|
263
|
-
i || (
|
|
364
|
+
), f = b(
|
|
365
|
+
(u) => {
|
|
366
|
+
i || (u.stopPropagation(), n == null || n(), l == null || l());
|
|
264
367
|
},
|
|
265
|
-
[i, n,
|
|
368
|
+
[i, n, l]
|
|
266
369
|
);
|
|
267
|
-
return /* @__PURE__ */ s("div", { className:
|
|
268
|
-
/* @__PURE__ */
|
|
269
|
-
/* @__PURE__ */ s(
|
|
370
|
+
return /* @__PURE__ */ s("div", { className: Z.chatbot_header, children: /* @__PURE__ */ p("div", { className: Z.chatbot_header__content, style: d, children: [
|
|
371
|
+
/* @__PURE__ */ p("div", { className: Z.chatbot_header__title, children: [
|
|
372
|
+
/* @__PURE__ */ s(Bt, { avatar: c }),
|
|
270
373
|
/* @__PURE__ */ s("h4", { children: t })
|
|
271
374
|
] }),
|
|
272
|
-
/* @__PURE__ */
|
|
273
|
-
/* @__PURE__ */ s("div", { onClick:
|
|
274
|
-
/* @__PURE__ */ s("div", { onClick: f, children: /* @__PURE__ */ s(
|
|
375
|
+
/* @__PURE__ */ p("div", { className: Z.chatbot_header__extra, children: [
|
|
376
|
+
/* @__PURE__ */ s("div", { onClick: h, children: /* @__PURE__ */ s(At, {}) }),
|
|
377
|
+
/* @__PURE__ */ s("div", { onClick: f, children: /* @__PURE__ */ s(It, {}) })
|
|
275
378
|
] })
|
|
276
379
|
] }) });
|
|
277
380
|
}
|
|
278
|
-
const
|
|
279
|
-
chatbot_body:
|
|
280
|
-
chatbot_body__content:
|
|
281
|
-
},
|
|
282
|
-
template_box:
|
|
381
|
+
const Zt = "_chatbot_body_f6sqm_1", Pt = "_chatbot_body__content_f6sqm_5", X = {
|
|
382
|
+
chatbot_body: Zt,
|
|
383
|
+
chatbot_body__content: Pt
|
|
384
|
+
}, Dt = "_template_box_1ozig_1", R = {
|
|
385
|
+
template_box: Dt,
|
|
283
386
|
"template_box--bot": "_template_box--bot_1ozig_7",
|
|
284
387
|
"template_box--horizontal": "_template_box--horizontal_1ozig_7",
|
|
285
388
|
"template_box--vertical": "_template_box--vertical_1ozig_10",
|
|
286
389
|
"template_box--user": "_template_box--user_1ozig_14"
|
|
287
390
|
};
|
|
288
|
-
function
|
|
289
|
-
|
|
391
|
+
function ut(e) {
|
|
392
|
+
var t, o, n = "";
|
|
393
|
+
if (typeof e == "string" || typeof e == "number") n += e;
|
|
394
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
395
|
+
var r = e.length;
|
|
396
|
+
for (t = 0; t < r; t++) e[t] && (o = ut(e[t])) && (n && (n += " "), n += o);
|
|
397
|
+
} else for (o in e) e[o] && (n && (n += " "), n += o);
|
|
398
|
+
return n;
|
|
399
|
+
}
|
|
400
|
+
function T() {
|
|
401
|
+
for (var e, t, o = 0, n = "", r = arguments.length; o < r; o++) (e = arguments[o]) && (t = ut(e)) && (n && (n += " "), n += t);
|
|
402
|
+
return n;
|
|
403
|
+
}
|
|
404
|
+
function O(e) {
|
|
405
|
+
const { type: t, direction: o = "horizontal", children: n } = e, r = C(() => {
|
|
290
406
|
switch (t) {
|
|
291
407
|
case "user":
|
|
292
|
-
return R
|
|
408
|
+
return T(R.template_box, R["template_box--user"]);
|
|
293
409
|
case "bot":
|
|
294
410
|
default:
|
|
295
|
-
return
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
o === "horizontal" ?
|
|
411
|
+
return T(
|
|
412
|
+
R.template_box,
|
|
413
|
+
R["template_box--bot"],
|
|
414
|
+
o === "horizontal" ? R["template_box--horizontal"] : R["template_box--vertical"]
|
|
299
415
|
);
|
|
300
416
|
}
|
|
301
417
|
}, [o, t]);
|
|
302
418
|
return /* @__PURE__ */ s("div", { className: r, children: n });
|
|
303
419
|
}
|
|
304
|
-
const
|
|
305
|
-
template_box_content:
|
|
306
|
-
content:
|
|
307
|
-
},
|
|
308
|
-
quick_replies_box:
|
|
309
|
-
quick_reply:
|
|
420
|
+
const jt = "_template_box_content_fs2wk_1", qt = "_content_fs2wk_8", Y = {
|
|
421
|
+
template_box_content: jt,
|
|
422
|
+
content: qt
|
|
423
|
+
}, $t = "_quick_replies_box_zoq7y_1", Ft = "_quick_reply_zoq7y_7", J = {
|
|
424
|
+
quick_replies_box: $t,
|
|
425
|
+
quick_reply: Ft
|
|
310
426
|
};
|
|
311
|
-
function
|
|
312
|
-
const { quickReplies: t } = e, { sendMessage: o, isConnecting: n } =
|
|
427
|
+
function Wt(e) {
|
|
428
|
+
const { quickReplies: t } = e, { sendMessage: o, isConnecting: n } = N(), r = b(
|
|
313
429
|
(c) => {
|
|
314
430
|
o == null || o(c);
|
|
315
431
|
},
|
|
@@ -326,7 +442,7 @@ function zt(e) {
|
|
|
326
442
|
c.text
|
|
327
443
|
)) }) : null;
|
|
328
444
|
}
|
|
329
|
-
function
|
|
445
|
+
function q(e) {
|
|
330
446
|
return e.toLocaleTimeString("zh-TW", {
|
|
331
447
|
timeZone: "Asia/Taipei",
|
|
332
448
|
hour: "2-digit",
|
|
@@ -334,84 +450,38 @@ function ct(e) {
|
|
|
334
450
|
hour12: !1
|
|
335
451
|
});
|
|
336
452
|
}
|
|
337
|
-
const
|
|
338
|
-
time:
|
|
453
|
+
const Ut = "_time_rgg92_1", Kt = {
|
|
454
|
+
time: Ut
|
|
339
455
|
};
|
|
340
|
-
function
|
|
456
|
+
function $(e) {
|
|
341
457
|
const { time: t, className: o } = e;
|
|
342
|
-
return t ? /* @__PURE__ */ s("div", { className:
|
|
458
|
+
return t ? /* @__PURE__ */ s("div", { className: T(Kt.time, o), children: q(t) }) : null;
|
|
343
459
|
}
|
|
344
|
-
function
|
|
460
|
+
function F(e) {
|
|
345
461
|
const { quickReplies: t, time: o, children: n } = e;
|
|
346
|
-
return /* @__PURE__ */
|
|
347
|
-
/* @__PURE__ */
|
|
462
|
+
return /* @__PURE__ */ p("div", { className: Y.template_box_content, children: [
|
|
463
|
+
/* @__PURE__ */ p("div", { className: Y.content, children: [
|
|
348
464
|
n,
|
|
349
|
-
/* @__PURE__ */ s(
|
|
465
|
+
/* @__PURE__ */ s($, { time: o })
|
|
350
466
|
] }),
|
|
351
|
-
!!(t != null && t.length) && /* @__PURE__ */ s(
|
|
467
|
+
!!(t != null && t.length) && /* @__PURE__ */ s(Wt, { quickReplies: t })
|
|
352
468
|
] });
|
|
353
469
|
}
|
|
354
|
-
const
|
|
355
|
-
bot_avatar:
|
|
356
|
-
},
|
|
470
|
+
const Xt = "_bot_avatar_xrs9x_1", Q = {
|
|
471
|
+
bot_avatar: Xt
|
|
472
|
+
}, Yt = (e) => /* @__PURE__ */ g.createElement("svg", { viewBox: "0 0 25 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("path", { d: "M0.40625 12C0.40625 5.37258 5.77883 0 12.4062 0C19.0337 0 24.4062 5.37258 24.4062 12C24.4062 18.6274 19.0337 24 12.4062 24C5.77883 24 0.40625 18.6274 0.40625 12Z", fill: "#585858" }), /* @__PURE__ */ g.createElement("path", { d: "M6.40625 18.75V15C6.40625 14.5875 6.55313 14.2344 6.84688 13.9406C7.14063 13.6469 7.49375 13.5 7.90625 13.5H16.9062C17.3188 13.5 17.6719 13.6469 17.9656 13.9406C18.2594 14.2344 18.4062 14.5875 18.4062 15V18.75H6.40625ZM10.1562 12.75C9.11875 12.75 8.23438 12.3844 7.50312 11.6531C6.77187 10.9219 6.40625 10.0375 6.40625 9C6.40625 7.9625 6.77187 7.07812 7.50312 6.34687C8.23438 5.61562 9.11875 5.25 10.1562 5.25H14.6562C15.6938 5.25 16.5781 5.61562 17.3094 6.34687C18.0406 7.07812 18.4062 7.9625 18.4062 9C18.4062 10.0375 18.0406 10.9219 17.3094 11.6531C16.5781 12.3844 15.6938 12.75 14.6562 12.75H10.1562ZM7.90625 17.25H16.9062V15H7.90625V17.25ZM10.1562 11.25H14.6562C15.2812 11.25 15.8125 11.0312 16.25 10.5938C16.6875 10.1562 16.9062 9.625 16.9062 9C16.9062 8.375 16.6875 7.84375 16.25 7.40625C15.8125 6.96875 15.2812 6.75 14.6562 6.75H10.1562C9.53125 6.75 9 6.96875 8.5625 7.40625C8.125 7.84375 7.90625 8.375 7.90625 9C7.90625 9.625 8.125 10.1562 8.5625 10.5938C9 11.0312 9.53125 11.25 10.1562 11.25ZM10.1562 9.75C10.3688 9.75 10.5469 9.67812 10.6906 9.53438C10.8344 9.39062 10.9062 9.2125 10.9062 9C10.9062 8.7875 10.8344 8.60938 10.6906 8.46562C10.5469 8.32187 10.3688 8.25 10.1562 8.25C9.94375 8.25 9.76562 8.32187 9.62187 8.46562C9.47812 8.60938 9.40625 8.7875 9.40625 9C9.40625 9.2125 9.47812 9.39062 9.62187 9.53438C9.76562 9.67812 9.94375 9.75 10.1562 9.75ZM14.6562 9.75C14.8687 9.75 15.0469 9.67812 15.1906 9.53438C15.3344 9.39062 15.4062 9.2125 15.4062 9C15.4062 8.7875 15.3344 8.60938 15.1906 8.46562C15.0469 8.32187 14.8687 8.25 14.6562 8.25C14.4438 8.25 14.2656 8.32187 14.1219 8.46562C13.9781 8.60938 13.9062 8.7875 13.9062 9C13.9062 9.2125 13.9781 9.39062 14.1219 9.53438C14.2656 9.67812 14.4438 9.75 14.6562 9.75Z", fill: "white" })), P = gt((e) => {
|
|
357
473
|
const { avatar: t } = e;
|
|
358
|
-
return t ? /* @__PURE__ */ s("img", { src: t, alt: "Bot Avatar", className:
|
|
359
|
-
}),
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
function $t(e) {
|
|
366
|
-
const { children: t, onResize: o } = e, n = q(null);
|
|
367
|
-
return L(() => {
|
|
368
|
-
const r = new ResizeObserver((c) => {
|
|
369
|
-
for (const i of c) {
|
|
370
|
-
const { width: a, height: _ } = i.contentRect;
|
|
371
|
-
o(a, _);
|
|
372
|
-
}
|
|
373
|
-
});
|
|
374
|
-
return n.current && r.observe(n.current), () => {
|
|
375
|
-
r.disconnect();
|
|
376
|
-
};
|
|
377
|
-
}, [n, o]), /* @__PURE__ */ s("div", { ref: n, children: t });
|
|
378
|
-
}
|
|
379
|
-
function it(e) {
|
|
380
|
-
const { isTyping: t, typingText: o } = e, { messageBoxBottomRef: n, avatar: r } = w(), c = g(() => {
|
|
381
|
-
var a;
|
|
382
|
-
(a = n.current) == null || a.scrollIntoView({ behavior: "smooth" });
|
|
383
|
-
}, [n]), i = bt(t, 500);
|
|
384
|
-
return i ? /* @__PURE__ */ m(V, { type: "bot", direction: "horizontal", children: [
|
|
385
|
-
/* @__PURE__ */ s(j, { avatar: r }),
|
|
386
|
-
/* @__PURE__ */ s(O, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ s("div", { className: R(B.text, B["text--bot"]), children: /* @__PURE__ */ m($t, { onResize: c, children: [
|
|
387
|
-
/* @__PURE__ */ s("span", { children: o ?? "" }),
|
|
388
|
-
i && /* @__PURE__ */ m("span", { className: B["typing-indicator"], children: [
|
|
389
|
-
/* @__PURE__ */ s("div", { className: B.dot }),
|
|
390
|
-
/* @__PURE__ */ s("div", { className: B.dot }),
|
|
391
|
-
/* @__PURE__ */ s("div", { className: B.dot })
|
|
392
|
-
] })
|
|
393
|
-
] }) }) })
|
|
394
|
-
] }) : null;
|
|
395
|
-
}
|
|
396
|
-
function Pt(e) {
|
|
397
|
-
const { placeholder: t } = e, { isConnecting: o, messages: n } = w(), r = y(
|
|
398
|
-
() => Array.from((n == null ? void 0 : n.values()) ?? []).some(
|
|
399
|
-
(c) => c.type === "bot" && c.isTyping
|
|
400
|
-
),
|
|
401
|
-
[n]
|
|
402
|
-
);
|
|
403
|
-
return o && !r ? /* @__PURE__ */ s(it, { isTyping: !0, typingText: t }) : null;
|
|
404
|
-
}
|
|
405
|
-
const Dt = "_card_root_1ygom_1", Ot = "_card_content_1ygom_10", Ft = "_card_title_1ygom_17", Wt = "_card_description_1ygom_23", Ut = "_card_actions_1ygom_37", H = {
|
|
406
|
-
card_root: Dt,
|
|
407
|
-
card_content: Ot,
|
|
408
|
-
card_title: Ft,
|
|
409
|
-
card_description: Wt,
|
|
410
|
-
card_actions: Ut
|
|
474
|
+
return t ? /* @__PURE__ */ s("img", { src: t, alt: "Bot Avatar", className: Q.bot_avatar }) : /* @__PURE__ */ s("div", { className: Q.bot_avatar, children: /* @__PURE__ */ s(Yt, {}) });
|
|
475
|
+
}), Jt = "_card_root_1ygom_1", Qt = "_card_content_1ygom_10", Gt = "_card_title_1ygom_17", te = "_card_description_1ygom_23", ee = "_card_actions_1ygom_37", V = {
|
|
476
|
+
card_root: Jt,
|
|
477
|
+
card_content: Qt,
|
|
478
|
+
card_title: Gt,
|
|
479
|
+
card_description: te,
|
|
480
|
+
card_actions: ee
|
|
411
481
|
};
|
|
412
|
-
function
|
|
482
|
+
function dt(e) {
|
|
413
483
|
var i;
|
|
414
|
-
const { template: t } = e, { sendMessage: o } =
|
|
484
|
+
const { template: t } = e, { sendMessage: o } = N(), n = C(() => (t == null ? void 0 : t.thumbnailImageUrl.replace(/^http:/, "").replace(/^https:/, "")) || "https://via.assets.so/img.jpg?w=200&h=270&tc=white&bg=#eeeeee", [t]), r = C(() => {
|
|
415
485
|
switch (t == null ? void 0 : t.imageAspectRatio) {
|
|
416
486
|
case "square":
|
|
417
487
|
return "1 / 1";
|
|
@@ -419,7 +489,7 @@ function at(e) {
|
|
|
419
489
|
default:
|
|
420
490
|
return "1.51 / 1";
|
|
421
491
|
}
|
|
422
|
-
}, [t]), c =
|
|
492
|
+
}, [t]), c = b(
|
|
423
493
|
(a) => function() {
|
|
424
494
|
switch (a.type) {
|
|
425
495
|
case "message":
|
|
@@ -432,7 +502,7 @@ function at(e) {
|
|
|
432
502
|
},
|
|
433
503
|
[o]
|
|
434
504
|
);
|
|
435
|
-
return /* @__PURE__ */
|
|
505
|
+
return /* @__PURE__ */ p("div", { className: V.card_root, children: [
|
|
436
506
|
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */ s(
|
|
437
507
|
"img",
|
|
438
508
|
{
|
|
@@ -447,124 +517,209 @@ function at(e) {
|
|
|
447
517
|
}
|
|
448
518
|
}
|
|
449
519
|
),
|
|
450
|
-
/* @__PURE__ */
|
|
451
|
-
/* @__PURE__ */ s("h5", { className:
|
|
452
|
-
/* @__PURE__ */ s("div", { className:
|
|
453
|
-
/* @__PURE__ */ s("div", { className:
|
|
520
|
+
/* @__PURE__ */ p("div", { className: V.card_content, children: [
|
|
521
|
+
/* @__PURE__ */ s("h5", { className: V.card_title, children: t == null ? void 0 : t.title }),
|
|
522
|
+
/* @__PURE__ */ s("div", { className: V.card_description, children: t == null ? void 0 : t.text }),
|
|
523
|
+
/* @__PURE__ */ s("div", { className: V.card_actions, children: (i = t == null ? void 0 : t.buttons) == null ? void 0 : i.map((a, l) => /* @__PURE__ */ s("button", { onClick: c(a.action), children: a.label }, l)) })
|
|
454
524
|
] })
|
|
455
525
|
] });
|
|
456
526
|
}
|
|
457
|
-
function
|
|
458
|
-
const { message: t } = e, { avatar: o } =
|
|
459
|
-
return /* @__PURE__ */
|
|
460
|
-
/* @__PURE__ */ s(
|
|
527
|
+
function ne(e) {
|
|
528
|
+
const { message: t } = e, { avatar: o } = N(), n = t.message.template;
|
|
529
|
+
return /* @__PURE__ */ p(O, { type: "bot", direction: "horizontal", children: [
|
|
530
|
+
/* @__PURE__ */ s(P, { avatar: o }),
|
|
461
531
|
/* @__PURE__ */ s(
|
|
462
|
-
|
|
532
|
+
F,
|
|
463
533
|
{
|
|
464
534
|
time: t.time,
|
|
465
535
|
quickReplies: n == null ? void 0 : n.quickReplies,
|
|
466
|
-
children: /* @__PURE__ */ s(
|
|
536
|
+
children: /* @__PURE__ */ s(dt, { template: n })
|
|
467
537
|
}
|
|
468
538
|
)
|
|
469
539
|
] });
|
|
470
540
|
}
|
|
471
|
-
const
|
|
472
|
-
text:
|
|
473
|
-
"text--user": "_text--
|
|
474
|
-
"text--bot": "_text--
|
|
541
|
+
const oe = "_text_5fknl_1", re = "_dot_5fknl_31", y = {
|
|
542
|
+
text: oe,
|
|
543
|
+
"text--user": "_text--user_5fknl_8",
|
|
544
|
+
"text--bot": "_text--bot_5fknl_14",
|
|
545
|
+
"typing-indicator": "_typing-indicator_5fknl_26",
|
|
546
|
+
dot: re
|
|
475
547
|
};
|
|
476
|
-
function
|
|
477
|
-
var
|
|
478
|
-
const { message: t } = e, { avatar: o } =
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
548
|
+
function G(e) {
|
|
549
|
+
var c;
|
|
550
|
+
const { message: t } = e, { avatar: o } = N(), n = z(), r = C(() => {
|
|
551
|
+
var i, a, l, d;
|
|
552
|
+
switch (t.type) {
|
|
553
|
+
case "user":
|
|
554
|
+
return {
|
|
555
|
+
color: (i = n == null ? void 0 : n.userMessage) == null ? void 0 : i.color,
|
|
556
|
+
backgroundColor: (a = n == null ? void 0 : n.userMessage) == null ? void 0 : a.backgroundColor
|
|
557
|
+
};
|
|
558
|
+
case "bot":
|
|
559
|
+
return {
|
|
560
|
+
color: (l = n == null ? void 0 : n.botMessage) == null ? void 0 : l.color,
|
|
561
|
+
backgroundColor: (d = n == null ? void 0 : n.botMessage) == null ? void 0 : d.backgroundColor
|
|
562
|
+
};
|
|
563
|
+
default:
|
|
564
|
+
return {};
|
|
565
|
+
}
|
|
566
|
+
}, [t, n]);
|
|
567
|
+
return t.type === "error" ? null : t.type === "user" ? /* @__PURE__ */ p(O, { type: "user", direction: "horizontal", children: [
|
|
484
568
|
/* @__PURE__ */ s(
|
|
485
|
-
|
|
569
|
+
"div",
|
|
570
|
+
{
|
|
571
|
+
className: T(y.text, y["text--user"]),
|
|
572
|
+
style: r,
|
|
573
|
+
children: t.text
|
|
574
|
+
}
|
|
575
|
+
),
|
|
576
|
+
/* @__PURE__ */ s($, { time: t.time })
|
|
577
|
+
] }) : /* @__PURE__ */ p(O, { type: "bot", direction: "horizontal", children: [
|
|
578
|
+
/* @__PURE__ */ s(P, { avatar: o }),
|
|
579
|
+
/* @__PURE__ */ s(
|
|
580
|
+
F,
|
|
486
581
|
{
|
|
487
582
|
time: t.time,
|
|
488
|
-
quickReplies: (
|
|
489
|
-
children: /* @__PURE__ */ s(
|
|
583
|
+
quickReplies: (c = t.message.template) == null ? void 0 : c.quickReplies,
|
|
584
|
+
children: /* @__PURE__ */ s(
|
|
585
|
+
"div",
|
|
586
|
+
{
|
|
587
|
+
className: T(y.text, y["text--bot"]),
|
|
588
|
+
style: r,
|
|
589
|
+
children: t.message.text
|
|
590
|
+
}
|
|
591
|
+
)
|
|
490
592
|
}
|
|
491
593
|
)
|
|
492
594
|
] });
|
|
493
595
|
}
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
596
|
+
function _t(e) {
|
|
597
|
+
const { isTyping: t, typingText: o } = e, { messageBoxBottomRef: n, avatar: r } = N(), c = z(), i = M(null), a = b(() => {
|
|
598
|
+
var h;
|
|
599
|
+
(h = n.current) == null || h.scrollIntoView({ behavior: "smooth" });
|
|
600
|
+
}, [n]);
|
|
601
|
+
kt({ ref: i, onResize: a });
|
|
602
|
+
const l = wt(t, 500), d = C(
|
|
603
|
+
() => {
|
|
604
|
+
var h, f;
|
|
605
|
+
return {
|
|
606
|
+
color: (h = c == null ? void 0 : c.botMessage) == null ? void 0 : h.color,
|
|
607
|
+
backgroundColor: (f = c == null ? void 0 : c.botMessage) == null ? void 0 : f.backgroundColor
|
|
608
|
+
};
|
|
609
|
+
},
|
|
610
|
+
[c]
|
|
611
|
+
);
|
|
612
|
+
return l ? /* @__PURE__ */ p(O, { type: "bot", direction: "horizontal", children: [
|
|
613
|
+
/* @__PURE__ */ s(P, { avatar: r }),
|
|
614
|
+
/* @__PURE__ */ s(F, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ s(
|
|
615
|
+
"div",
|
|
616
|
+
{
|
|
617
|
+
ref: i,
|
|
618
|
+
className: T(y.text, y["text--bot"]),
|
|
619
|
+
style: d,
|
|
620
|
+
children: /* @__PURE__ */ p("span", { children: [
|
|
621
|
+
o ?? "",
|
|
622
|
+
l && /* @__PURE__ */ p("span", { className: y["typing-indicator"], children: [
|
|
623
|
+
/* @__PURE__ */ s("div", { className: y.dot }),
|
|
624
|
+
/* @__PURE__ */ s("div", { className: y.dot }),
|
|
625
|
+
/* @__PURE__ */ s("div", { className: y.dot })
|
|
626
|
+
] })
|
|
627
|
+
] })
|
|
628
|
+
}
|
|
629
|
+
) })
|
|
630
|
+
] }) : null;
|
|
631
|
+
}
|
|
632
|
+
function se(e) {
|
|
633
|
+
const { placeholder: t } = e, { isConnecting: o, messages: n } = N(), r = C(
|
|
634
|
+
() => Array.from((n == null ? void 0 : n.values()) ?? []).some(
|
|
635
|
+
(c) => c.type === "bot" && c.isTyping
|
|
636
|
+
),
|
|
637
|
+
[n]
|
|
638
|
+
);
|
|
639
|
+
return o && !r ? /* @__PURE__ */ s(_t, { isTyping: !0, typingText: t }) : null;
|
|
640
|
+
}
|
|
641
|
+
const ce = "_carousel_root_sv1hc_1", ie = "_carousel_time_sv1hc_12", tt = {
|
|
642
|
+
carousel_root: ce,
|
|
643
|
+
carousel_time: ie
|
|
497
644
|
};
|
|
498
|
-
function
|
|
645
|
+
function ae(e) {
|
|
499
646
|
var r;
|
|
500
|
-
const { message: t } = e, { avatar: o } =
|
|
501
|
-
return /* @__PURE__ */
|
|
502
|
-
/* @__PURE__ */ s(
|
|
503
|
-
/* @__PURE__ */ s("div", { className:
|
|
504
|
-
/* @__PURE__ */ s(
|
|
647
|
+
const { message: t } = e, { avatar: o } = N(), n = t.message.template;
|
|
648
|
+
return /* @__PURE__ */ p(O, { type: "bot", direction: "vertical", children: [
|
|
649
|
+
/* @__PURE__ */ s(P, { avatar: o }),
|
|
650
|
+
/* @__PURE__ */ s("div", { className: tt.carousel_root, children: (r = n.columns) == null ? void 0 : r.map((c, i) => /* @__PURE__ */ s(dt, { template: c }, i)) }),
|
|
651
|
+
/* @__PURE__ */ s($, { className: tt.carousel_time, time: t.time })
|
|
505
652
|
] });
|
|
506
653
|
}
|
|
507
|
-
const
|
|
508
|
-
hint_root:
|
|
509
|
-
|
|
654
|
+
const le = "_hint_root_k5fud_1", ue = "_hint_root__error_k5fud_13", de = "_time_k5fud_17", B = {
|
|
655
|
+
hint_root: le,
|
|
656
|
+
hint_root__error: ue,
|
|
657
|
+
time: de
|
|
510
658
|
};
|
|
511
|
-
function
|
|
659
|
+
function et(e) {
|
|
512
660
|
const { message: t } = e;
|
|
513
661
|
if (t.type === "user") return null;
|
|
662
|
+
if (t.type === "error")
|
|
663
|
+
return /* @__PURE__ */ p("div", { className: T(B.hint_root, B.hint_root__error), children: [
|
|
664
|
+
/* @__PURE__ */ s("div", { className: B.time, children: q(t.time) }),
|
|
665
|
+
/* @__PURE__ */ s("span", { children: "Unexpected error" })
|
|
666
|
+
] });
|
|
514
667
|
const o = t.message.template;
|
|
515
|
-
return o.type !==
|
|
516
|
-
/* @__PURE__ */ s("div", { className:
|
|
668
|
+
return o.type !== A.HINT ? null : /* @__PURE__ */ p("div", { className: B.hint_root, children: [
|
|
669
|
+
/* @__PURE__ */ s("div", { className: B.time, children: q(t.time) }),
|
|
517
670
|
o.text
|
|
518
671
|
] });
|
|
519
672
|
}
|
|
520
|
-
function
|
|
673
|
+
function _e(e) {
|
|
521
674
|
var o;
|
|
522
675
|
const { message: t } = e;
|
|
523
676
|
if (t.type === "user")
|
|
524
|
-
return /* @__PURE__ */ s(
|
|
677
|
+
return /* @__PURE__ */ s(G, { message: t });
|
|
678
|
+
if (t.type === "error")
|
|
679
|
+
return /* @__PURE__ */ s(et, { message: t });
|
|
525
680
|
if (t.isTyping)
|
|
526
681
|
return /* @__PURE__ */ s(
|
|
527
|
-
|
|
682
|
+
_t,
|
|
528
683
|
{
|
|
529
684
|
isTyping: t.isTyping,
|
|
530
685
|
typingText: t.typingText
|
|
531
686
|
}
|
|
532
687
|
);
|
|
533
688
|
switch ((o = t.message.template) == null ? void 0 : o.type) {
|
|
534
|
-
case
|
|
535
|
-
return /* @__PURE__ */ s(
|
|
536
|
-
case
|
|
537
|
-
return /* @__PURE__ */ s(
|
|
538
|
-
case
|
|
539
|
-
return /* @__PURE__ */ s(
|
|
540
|
-
case
|
|
541
|
-
return /* @__PURE__ */ s(
|
|
689
|
+
case A.TEXT:
|
|
690
|
+
return /* @__PURE__ */ s(G, { message: t });
|
|
691
|
+
case A.HINT:
|
|
692
|
+
return /* @__PURE__ */ s(et, { message: t });
|
|
693
|
+
case A.BUTTON:
|
|
694
|
+
return /* @__PURE__ */ s(ne, { message: t });
|
|
695
|
+
case A.CAROUSEL:
|
|
696
|
+
return /* @__PURE__ */ s(ae, { message: t });
|
|
542
697
|
default:
|
|
543
698
|
return /* @__PURE__ */ s("div", {});
|
|
544
699
|
}
|
|
545
700
|
}
|
|
546
|
-
function
|
|
547
|
-
const { chatbot: e } =
|
|
548
|
-
|
|
701
|
+
function he() {
|
|
702
|
+
const { chatbot: e } = z(), { messages: t, messageBoxBottomRef: o, botTypingPlaceholder: n } = N();
|
|
703
|
+
w(() => {
|
|
549
704
|
var c;
|
|
550
705
|
(c = o.current) == null || c.scrollIntoView({ behavior: "smooth" });
|
|
551
706
|
}, [t, o]);
|
|
552
|
-
const r =
|
|
707
|
+
const r = C(
|
|
553
708
|
() => ({
|
|
554
709
|
maxWidth: (e == null ? void 0 : e.contentMaxWidth) ?? "1200px"
|
|
555
710
|
}),
|
|
556
711
|
[e]
|
|
557
712
|
);
|
|
558
|
-
return /* @__PURE__ */ s("div", { className:
|
|
713
|
+
return /* @__PURE__ */ s("div", { className: X.chatbot_body, children: /* @__PURE__ */ p("div", { className: X.chatbot_body__content, style: r, children: [
|
|
559
714
|
Array.from((t == null ? void 0 : t.values()) ?? []).map((c) => /* @__PURE__ */ s(
|
|
560
|
-
|
|
715
|
+
_e,
|
|
561
716
|
{
|
|
562
717
|
message: c
|
|
563
718
|
},
|
|
564
719
|
c.messageId
|
|
565
720
|
)),
|
|
566
721
|
/* @__PURE__ */ s(
|
|
567
|
-
|
|
722
|
+
se,
|
|
568
723
|
{
|
|
569
724
|
placeholder: n ?? "正在輸入訊息"
|
|
570
725
|
}
|
|
@@ -572,58 +727,58 @@ function ne() {
|
|
|
572
727
|
/* @__PURE__ */ s("div", { ref: o })
|
|
573
728
|
] }) });
|
|
574
729
|
}
|
|
575
|
-
const
|
|
576
|
-
chatbot_footer:
|
|
577
|
-
chatbot_footer__content:
|
|
578
|
-
chatbot_textarea:
|
|
579
|
-
chatbot_submit_button:
|
|
580
|
-
chatbot_submit_button__disabled:
|
|
581
|
-
},
|
|
582
|
-
function
|
|
583
|
-
const { setValue: t, className: o } = e, [n, r] =
|
|
584
|
-
|
|
585
|
-
const
|
|
586
|
-
if (!
|
|
587
|
-
const
|
|
588
|
-
|
|
589
|
-
for (let
|
|
590
|
-
|
|
591
|
-
},
|
|
592
|
-
alert(`語音識別錯誤: ${JSON.stringify(
|
|
593
|
-
},
|
|
730
|
+
const ge = "_chatbot_footer_1slg7_1", fe = "_chatbot_footer__content_1slg7_4", me = "_chatbot_textarea_1slg7_14", be = "_chatbot_submit_button_1slg7_29", pe = "_chatbot_submit_button__disabled_1slg7_54", k = {
|
|
731
|
+
chatbot_footer: ge,
|
|
732
|
+
chatbot_footer__content: fe,
|
|
733
|
+
chatbot_textarea: me,
|
|
734
|
+
chatbot_submit_button: be,
|
|
735
|
+
chatbot_submit_button__disabled: pe
|
|
736
|
+
}, ve = (e) => /* @__PURE__ */ g.createElement("svg", { width: 15, height: 12, viewBox: "0 0 15 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("path", { d: "M0.823242 11.6953V0.945312L14.3328 6.32031L0.823242 11.6953ZM1.90658 10.0911L11.3649 6.32031L1.90658 2.54948V4.98052L5.92574 6.32031L1.90658 7.6601V10.0911Z", fill: "white" })), Ce = (e) => /* @__PURE__ */ g.createElement("svg", { width: 11, height: 16, viewBox: "0 0 11 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("path", { d: "M5.40658 9.90397C4.82435 9.90397 4.33158 9.7023 3.92824 9.29897C3.52491 8.89564 3.32324 8.40286 3.32324 7.82064V2.82064C3.32324 2.23842 3.52491 1.74564 3.92824 1.3423C4.33158 0.938971 4.82435 0.737305 5.40658 0.737305C5.9888 0.737305 6.48158 0.938971 6.88491 1.3423C7.28824 1.74564 7.48991 2.23842 7.48991 2.82064V7.82064C7.48991 8.40286 7.28824 8.89564 6.88491 9.29897C6.48158 9.7023 5.9888 9.90397 5.40658 9.90397ZM4.86491 15.1123V12.8654C3.56213 12.7208 2.47949 12.1724 1.61699 11.2202C0.754492 10.2679 0.323242 9.13467 0.323242 7.82064H1.40658C1.40658 8.92731 1.79706 9.87064 2.57803 10.6506C3.35887 11.4306 4.30331 11.8206 5.41137 11.8206C6.51928 11.8206 7.46213 11.4306 8.23991 10.6506C9.01769 9.87064 9.40658 8.92731 9.40658 7.82064H10.4899C10.4899 9.13467 10.0587 10.2679 9.19616 11.2202C8.33366 12.1724 7.25102 12.7208 5.94824 12.8654V15.1123H4.86491ZM5.40658 8.82064C5.68991 8.82064 5.92741 8.7248 6.11908 8.53314C6.31074 8.34147 6.40658 8.10397 6.40658 7.82064V2.82064C6.40658 2.5373 6.31074 2.2998 6.11908 2.10814C5.92741 1.91647 5.68991 1.82064 5.40658 1.82064C5.12324 1.82064 4.88574 1.91647 4.69408 2.10814C4.50241 2.2998 4.40658 2.5373 4.40658 2.82064V7.82064C4.40658 8.10397 4.50241 8.34147 4.69408 8.53314C4.88574 8.7248 5.12324 8.82064 5.40658 8.82064Z", fill: "white" })), we = (e) => /* @__PURE__ */ g.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ g.createElement("circle", { cx: 20, cy: 20, r: 18, fill: "#D04444" }), /* @__PURE__ */ g.createElement("rect", { x: 12, y: 12, width: 16, height: 16, fill: "#FFFFFF", rx: 2, ry: 2 }));
|
|
737
|
+
function xe(e) {
|
|
738
|
+
const { setValue: t, className: o } = e, [n, r] = x(!1), c = M(null);
|
|
739
|
+
w(() => {
|
|
740
|
+
const u = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
741
|
+
if (!u) return;
|
|
742
|
+
const _ = new u();
|
|
743
|
+
_.lang = "zh-TW", _.continuous = !0, _.interimResults = !0, _.onresult = (m) => {
|
|
744
|
+
for (let v = m.resultIndex; v < m.results.length; v++)
|
|
745
|
+
m.results[v].isFinal && t((E) => E + m.results[v][0].transcript);
|
|
746
|
+
}, _.onerror = (m) => {
|
|
747
|
+
alert(`語音識別錯誤: ${JSON.stringify(m.error)}`);
|
|
748
|
+
}, _.onend = () => {
|
|
594
749
|
r(!1);
|
|
595
|
-
}, c.current =
|
|
750
|
+
}, c.current = _;
|
|
596
751
|
}, [t]);
|
|
597
|
-
const i =
|
|
752
|
+
const i = b(() => {
|
|
598
753
|
if (!c.current) {
|
|
599
754
|
alert("無法開始辨識: 語音識別器未初始化,請檢查是否有授權使用麥克風");
|
|
600
755
|
return;
|
|
601
756
|
}
|
|
602
757
|
try {
|
|
603
758
|
c.current.start(), r(!0);
|
|
604
|
-
} catch (
|
|
605
|
-
alert(`無法開始辨識: ${JSON.stringify(
|
|
759
|
+
} catch (u) {
|
|
760
|
+
alert(`無法開始辨識: ${JSON.stringify(u)}`);
|
|
606
761
|
}
|
|
607
|
-
}, []), a =
|
|
762
|
+
}, []), a = b(() => {
|
|
608
763
|
c.current && (c.current.stop(), r(!1));
|
|
609
|
-
}, []),
|
|
610
|
-
(
|
|
611
|
-
n || (
|
|
764
|
+
}, []), l = b(
|
|
765
|
+
(u) => {
|
|
766
|
+
n || (u.preventDefault(), i());
|
|
612
767
|
},
|
|
613
768
|
[n, i]
|
|
614
|
-
),
|
|
615
|
-
(
|
|
616
|
-
n && (
|
|
769
|
+
), d = b(
|
|
770
|
+
(u) => {
|
|
771
|
+
n && (u.preventDefault(), a());
|
|
617
772
|
},
|
|
618
773
|
[n, a]
|
|
619
|
-
),
|
|
620
|
-
(
|
|
621
|
-
n || (
|
|
774
|
+
), h = b(
|
|
775
|
+
(u) => {
|
|
776
|
+
n || (u.preventDefault(), i());
|
|
622
777
|
},
|
|
623
778
|
[n, i]
|
|
624
|
-
), f =
|
|
625
|
-
(
|
|
626
|
-
n && (
|
|
779
|
+
), f = b(
|
|
780
|
+
(u) => {
|
|
781
|
+
n && (u.preventDefault(), a());
|
|
627
782
|
},
|
|
628
783
|
[n, a]
|
|
629
784
|
);
|
|
@@ -631,50 +786,54 @@ function de(e) {
|
|
|
631
786
|
"div",
|
|
632
787
|
{
|
|
633
788
|
className: o,
|
|
634
|
-
onMouseDown:
|
|
635
|
-
onMouseUp:
|
|
636
|
-
onTouchStart:
|
|
789
|
+
onMouseDown: l,
|
|
790
|
+
onMouseUp: d,
|
|
791
|
+
onTouchStart: h,
|
|
637
792
|
onTouchEnd: f,
|
|
638
|
-
children: n ? /* @__PURE__ */ s(
|
|
793
|
+
children: n ? /* @__PURE__ */ s(we, {}) : /* @__PURE__ */ s(Ce, {})
|
|
639
794
|
}
|
|
640
795
|
);
|
|
641
796
|
}
|
|
642
|
-
function
|
|
643
|
-
const { sendMessage: e, isConnecting: t } =
|
|
797
|
+
function ye() {
|
|
798
|
+
const { sendMessage: e, isConnecting: t } = N(), { chatbot: o } = z(), [n, r] = x(""), [c, i] = x(!1), a = M(null), l = C(
|
|
799
|
+
() => t || !n.trim(),
|
|
800
|
+
[t, n]
|
|
801
|
+
), d = C(
|
|
644
802
|
() => ({
|
|
645
|
-
maxWidth: (o == null ? void 0 : o.contentMaxWidth) ?? "1200px"
|
|
803
|
+
maxWidth: (o == null ? void 0 : o.contentMaxWidth) ?? "1200px",
|
|
804
|
+
borderTopColor: o == null ? void 0 : o.borderColor
|
|
646
805
|
}),
|
|
647
806
|
[o]
|
|
648
|
-
),
|
|
649
|
-
(
|
|
650
|
-
const
|
|
651
|
-
|
|
807
|
+
), h = b(
|
|
808
|
+
(_) => {
|
|
809
|
+
const m = _.target, v = m.value;
|
|
810
|
+
m.style.height = "36px", v && (m.style.height = `${m.scrollHeight}px`), r(_.target.value);
|
|
652
811
|
},
|
|
653
812
|
[]
|
|
654
|
-
), f =
|
|
813
|
+
), f = b(() => {
|
|
655
814
|
!c && !t && (e == null || e(n), r(""), a.current && (a.current.style.height = "36px"));
|
|
656
|
-
}, [c, t, e, n]),
|
|
657
|
-
(
|
|
658
|
-
if (
|
|
815
|
+
}, [c, t, e, n]), u = b(
|
|
816
|
+
(_) => {
|
|
817
|
+
if (_.key === "Enter" && !c && !t && n.trim()) {
|
|
659
818
|
e == null || e(n), r("");
|
|
660
|
-
const
|
|
661
|
-
|
|
819
|
+
const m = _.target;
|
|
820
|
+
m.style.height = "36px";
|
|
662
821
|
}
|
|
663
822
|
},
|
|
664
823
|
[c, t, e, n]
|
|
665
824
|
);
|
|
666
|
-
return /* @__PURE__ */ s("div", { className:
|
|
825
|
+
return /* @__PURE__ */ s("div", { className: k.chatbot_footer, children: /* @__PURE__ */ p("div", { className: k.chatbot_footer__content, style: d, children: [
|
|
667
826
|
/* @__PURE__ */ s(
|
|
668
827
|
"textarea",
|
|
669
828
|
{
|
|
670
829
|
ref: a,
|
|
671
|
-
className:
|
|
830
|
+
className: k.chatbot_textarea,
|
|
672
831
|
disabled: t,
|
|
673
832
|
cols: 40,
|
|
674
833
|
value: n,
|
|
675
834
|
placeholder: "Enter message",
|
|
676
|
-
onChange:
|
|
677
|
-
onKeyDown:
|
|
835
|
+
onChange: h,
|
|
836
|
+
onKeyDown: u,
|
|
678
837
|
onCompositionStart: () => i(!0),
|
|
679
838
|
onCompositionEnd: () => i(!1)
|
|
680
839
|
}
|
|
@@ -682,31 +841,56 @@ function he() {
|
|
|
682
841
|
n ? /* @__PURE__ */ s(
|
|
683
842
|
"button",
|
|
684
843
|
{
|
|
685
|
-
className:
|
|
686
|
-
|
|
687
|
-
|
|
844
|
+
className: T(
|
|
845
|
+
k.chatbot_submit_button,
|
|
846
|
+
l && k.chatbot_submit_button__disabled
|
|
688
847
|
),
|
|
689
|
-
disabled:
|
|
848
|
+
disabled: l,
|
|
690
849
|
onClick: f,
|
|
691
|
-
children: /* @__PURE__ */ s(
|
|
850
|
+
children: /* @__PURE__ */ s(ve, {})
|
|
692
851
|
}
|
|
693
852
|
) : /* @__PURE__ */ s(
|
|
694
|
-
|
|
853
|
+
xe,
|
|
695
854
|
{
|
|
696
855
|
setValue: r,
|
|
697
|
-
className:
|
|
698
|
-
|
|
699
|
-
t &&
|
|
856
|
+
className: T(
|
|
857
|
+
k.chatbot_submit_button,
|
|
858
|
+
t && k.chatbot_submit_button__disabled
|
|
700
859
|
)
|
|
701
860
|
}
|
|
702
861
|
)
|
|
703
862
|
] }) });
|
|
704
863
|
}
|
|
705
|
-
const
|
|
706
|
-
chatbot_root:
|
|
707
|
-
|
|
864
|
+
const Te = "_chatbot_root_1tnjj_1", Ne = "_full_screen_1tnjj_121", Ee = "_chatbot_container_1tnjj_129", Le = "_screen_keyboard_open_1tnjj_134", I = {
|
|
865
|
+
chatbot_root: Te,
|
|
866
|
+
full_screen: Ne,
|
|
867
|
+
chatbot_container: Ee,
|
|
868
|
+
screen_keyboard_open: Le
|
|
708
869
|
};
|
|
709
|
-
function
|
|
870
|
+
function ke(e) {
|
|
871
|
+
const { children: t } = e, o = M(null);
|
|
872
|
+
Et(o), Nt();
|
|
873
|
+
const [, n] = yt() ?? [], r = Tt();
|
|
874
|
+
return /* @__PURE__ */ s("div", { className: I.full_screen, children: /* @__PURE__ */ s(
|
|
875
|
+
"div",
|
|
876
|
+
{
|
|
877
|
+
ref: o,
|
|
878
|
+
className: T(
|
|
879
|
+
I.chatbot_container,
|
|
880
|
+
r && I.screen_keyboard_open
|
|
881
|
+
),
|
|
882
|
+
style: r ? { height: n } : void 0,
|
|
883
|
+
children: t
|
|
884
|
+
}
|
|
885
|
+
) });
|
|
886
|
+
}
|
|
887
|
+
function Me(e) {
|
|
888
|
+
const { fullScreen: t, children: o } = e, n = M(null);
|
|
889
|
+
Lt(n);
|
|
890
|
+
const r = z();
|
|
891
|
+
return /* @__PURE__ */ s("div", { ref: n, className: I.chatbot_root, children: t ? /* @__PURE__ */ s(ke, { children: o }) : /* @__PURE__ */ s("div", { className: I.chatbot_container, style: r == null ? void 0 : r.chatbot, children: o }) });
|
|
892
|
+
}
|
|
893
|
+
function He(e) {
|
|
710
894
|
const {
|
|
711
895
|
title: t,
|
|
712
896
|
theme: o,
|
|
@@ -715,35 +899,37 @@ function Ce(e) {
|
|
|
715
899
|
initMessages: c,
|
|
716
900
|
debugMode: i = !1,
|
|
717
901
|
fullScreen: a = !1,
|
|
718
|
-
avatar:
|
|
719
|
-
botTypingPlaceholder:
|
|
720
|
-
onReset:
|
|
902
|
+
avatar: l,
|
|
903
|
+
botTypingPlaceholder: d,
|
|
904
|
+
onReset: h,
|
|
721
905
|
onClose: f
|
|
722
906
|
} = e;
|
|
723
|
-
return /* @__PURE__ */ s(
|
|
724
|
-
|
|
907
|
+
return /* @__PURE__ */ s(pt, { theme: o, children: /* @__PURE__ */ s(
|
|
908
|
+
Mt,
|
|
725
909
|
{
|
|
726
|
-
|
|
727
|
-
Y.chatbot_root,
|
|
728
|
-
a && Y.chatbot_root__fullScreen
|
|
729
|
-
),
|
|
730
|
-
avatar: _,
|
|
910
|
+
avatar: l,
|
|
731
911
|
config: n,
|
|
732
912
|
customChannelId: r,
|
|
733
913
|
initMessages: c,
|
|
734
|
-
botTypingPlaceholder:
|
|
914
|
+
botTypingPlaceholder: d,
|
|
735
915
|
options: { showDebugMessage: i },
|
|
736
|
-
children: [
|
|
737
|
-
/* @__PURE__ */ s(
|
|
738
|
-
/* @__PURE__ */ s(
|
|
739
|
-
/* @__PURE__ */ s(
|
|
740
|
-
]
|
|
916
|
+
children: /* @__PURE__ */ p(Me, { fullScreen: a, children: [
|
|
917
|
+
/* @__PURE__ */ s(Ot, { title: t, onReset: h, onClose: f }),
|
|
918
|
+
/* @__PURE__ */ s(he, {}),
|
|
919
|
+
/* @__PURE__ */ s(ye, {})
|
|
920
|
+
] })
|
|
741
921
|
}
|
|
742
922
|
) });
|
|
743
923
|
}
|
|
744
924
|
export {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
925
|
+
He as Chatbot,
|
|
926
|
+
vt as useAsgardServiceClient,
|
|
927
|
+
Ct as useChannel,
|
|
928
|
+
wt as useDebounce,
|
|
929
|
+
Tt as useIsOnScreenKeyboardOpen,
|
|
930
|
+
Nt as useOnScreenKeyboardScrollFix,
|
|
931
|
+
Et as usePreventOverScrolling,
|
|
932
|
+
kt as useResizeObserver,
|
|
933
|
+
Lt as useUpdateVh,
|
|
934
|
+
yt as useViewportSize
|
|
749
935
|
};
|