@asgard-js/react 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +543 -337
- package/dist/style.css +1 -1
- package/package.json +5 -1
- package/dist/components/chatbot/chatbot-body.d.ts +0 -4
- package/dist/components/chatbot/chatbot-body.d.ts.map +0 -1
- package/dist/components/chatbot/chatbot-footer.d.ts +0 -4
- package/dist/components/chatbot/chatbot-footer.d.ts.map +0 -1
- package/dist/components/chatbot/chatbot-header.d.ts +0 -8
- package/dist/components/chatbot/chatbot-header.d.ts.map +0 -1
- package/dist/components/chatbot/chatbot.d.ts +0 -16
- package/dist/components/chatbot/chatbot.d.ts.map +0 -1
- package/dist/components/chatbot/profile-icon.d.ts +0 -4
- package/dist/components/chatbot/profile-icon.d.ts.map +0 -1
- package/dist/components/conversation-message-renderer/conversation-message-renderer.d.ts +0 -9
- 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/index.d.ts +0 -2
- package/dist/components/index.d.ts.map +0 -1
- package/dist/components/templates/avatar/avatar.d.ts +0 -4
- package/dist/components/templates/avatar/avatar.d.ts.map +0 -1
- package/dist/components/templates/avatar/index.d.ts +0 -2
- package/dist/components/templates/avatar/index.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts +0 -9
- package/dist/components/templates/bot-typing-box/bot-typing-box.d.ts.map +0 -1
- package/dist/components/templates/bot-typing-box/index.d.ts +0 -2
- 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/templates/button-template/button-template.d.ts +0 -9
- package/dist/components/templates/button-template/button-template.d.ts.map +0 -1
- package/dist/components/templates/button-template/card.d.ts +0 -9
- package/dist/components/templates/button-template/card.d.ts.map +0 -1
- package/dist/components/templates/button-template/index.d.ts +0 -2
- package/dist/components/templates/button-template/index.d.ts.map +0 -1
- package/dist/components/templates/carousel-template/carousel-template.d.ts +0 -9
- package/dist/components/templates/carousel-template/carousel-template.d.ts.map +0 -1
- package/dist/components/templates/carousel-template/index.d.ts +0 -2
- package/dist/components/templates/carousel-template/index.d.ts.map +0 -1
- package/dist/components/templates/hint-template/hint-template.d.ts +0 -9
- package/dist/components/templates/hint-template/hint-template.d.ts.map +0 -1
- package/dist/components/templates/hint-template/index.d.ts +0 -2
- package/dist/components/templates/hint-template/index.d.ts.map +0 -1
- package/dist/components/templates/index.d.ts +0 -8
- package/dist/components/templates/index.d.ts.map +0 -1
- package/dist/components/templates/quick-replies/index.d.ts +0 -2
- package/dist/components/templates/quick-replies/index.d.ts.map +0 -1
- package/dist/components/templates/quick-replies/quick-replies.d.ts +0 -10
- package/dist/components/templates/quick-replies/quick-replies.d.ts.map +0 -1
- package/dist/components/templates/template-box/index.d.ts +0 -3
- package/dist/components/templates/template-box/index.d.ts.map +0 -1
- package/dist/components/templates/template-box/template-box-content.d.ts +0 -12
- package/dist/components/templates/template-box/template-box-content.d.ts.map +0 -1
- package/dist/components/templates/template-box/template-box.d.ts +0 -14
- package/dist/components/templates/template-box/template-box.d.ts.map +0 -1
- package/dist/components/templates/text-template/index.d.ts +0 -2
- package/dist/components/templates/text-template/index.d.ts.map +0 -1
- package/dist/components/templates/text-template/text-template.d.ts +0 -9
- package/dist/components/templates/text-template/text-template.d.ts.map +0 -1
- package/dist/components/templates/time/index.d.ts +0 -2
- package/dist/components/templates/time/index.d.ts.map +0 -1
- package/dist/components/templates/time/time.d.ts +0 -9
- package/dist/components/templates/time/time.d.ts.map +0 -1
- package/dist/context/asgard-service-context.d.ts +0 -28
- package/dist/context/asgard-service-context.d.ts.map +0 -1
- package/dist/hooks/index.d.ts +0 -4
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/use-asgard-service-client.d.ts +0 -8
- package/dist/hooks/use-asgard-service-client.d.ts.map +0 -1
- package/dist/hooks/use-channel.d.ts +0 -19
- package/dist/hooks/use-channel.d.ts.map +0 -1
- package/dist/hooks/use-debounce.d.ts +0 -2
- package/dist/hooks/use-debounce.d.ts.map +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.d.ts.map +0 -1
- package/dist/utils/format-time.d.ts +0 -2
- package/dist/utils/format-time.d.ts.map +0 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,143 +1,206 @@
|
|
|
1
|
-
import { jsx as o, jsxs as
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
1
|
+
import { jsx as o, jsxs as _ } from "react/jsx-runtime";
|
|
2
|
+
import * as x from "react";
|
|
3
|
+
import { useRef as z, useEffect as R, useState as N, useCallback as d, useMemo as B, createContext as ot, useContext as st, memo as ct } from "react";
|
|
4
|
+
import { AsgardServiceClient as rt, Channel as it, Conversation as at, MessageTemplateType as j } from "@asgard-js/core";
|
|
5
|
+
function G(e) {
|
|
6
|
+
var t, s, n = "";
|
|
7
|
+
if (typeof e == "string" || typeof e == "number") n += e;
|
|
8
|
+
else if (typeof e == "object") if (Array.isArray(e)) {
|
|
9
|
+
var c = e.length;
|
|
10
|
+
for (t = 0; t < c; t++) e[t] && (s = G(e[t])) && (n && (n += " "), n += s);
|
|
11
|
+
} else for (s in e) e[s] && (n && (n += " "), n += s);
|
|
12
|
+
return n;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
for (var
|
|
15
|
-
return
|
|
14
|
+
function T() {
|
|
15
|
+
for (var e, t, s = 0, n = "", c = arguments.length; s < c; s++) (e = arguments[s]) && (t = G(e)) && (n && (n += " "), n += t);
|
|
16
|
+
return n;
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
-
const { config: t } =
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
}, [t]),
|
|
18
|
+
function lt(e) {
|
|
19
|
+
const { config: t } = e, s = z(null);
|
|
20
|
+
return s.current || (s.current = new rt(t)), R(() => () => {
|
|
21
|
+
s.current && (s.current.close(), s.current = null);
|
|
22
|
+
}, [t]), s.current;
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
-
const {
|
|
24
|
+
function _t(e) {
|
|
25
|
+
const {
|
|
26
|
+
client: t,
|
|
27
|
+
customChannelId: s,
|
|
28
|
+
customMessageId: n,
|
|
29
|
+
initMessages: c,
|
|
30
|
+
showDebugMessage: r
|
|
31
|
+
} = e;
|
|
25
32
|
if (!t)
|
|
26
33
|
throw new Error("Client instance is required");
|
|
27
|
-
if (!
|
|
34
|
+
if (!s)
|
|
28
35
|
throw new Error("Custom channel id is required");
|
|
29
|
-
const [a,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(M) => p.onMessage(M, N, {
|
|
65
|
-
showDebugMessage: c == null ? void 0 : c.showDebugMessage
|
|
66
|
-
})
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
), p;
|
|
71
|
-
});
|
|
36
|
+
const [i, a] = N(null), [u, p] = N(!0), [m, b] = N(!1), [l, h] = N(!1), [f, v] = N(null), C = z(null), L = d(() => {
|
|
37
|
+
b(!0), t == null || t.resetChannel(
|
|
38
|
+
{ customChannelId: s, customMessageId: n },
|
|
39
|
+
{
|
|
40
|
+
onSseCompleted: () => {
|
|
41
|
+
b(!1), a(() => {
|
|
42
|
+
const g = new it({
|
|
43
|
+
client: t,
|
|
44
|
+
customChannelId: s,
|
|
45
|
+
conversation: new at({
|
|
46
|
+
showDebugMessage: r,
|
|
47
|
+
messages: new Map(
|
|
48
|
+
c == null ? void 0 : c.map((w) => [w.messageId, w])
|
|
49
|
+
)
|
|
50
|
+
})
|
|
51
|
+
});
|
|
52
|
+
return p(!0), h(g.isConnecting$.value), v(g.conversation$.value), g;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}, [
|
|
58
|
+
t,
|
|
59
|
+
s,
|
|
60
|
+
n,
|
|
61
|
+
c,
|
|
62
|
+
r
|
|
63
|
+
]), M = d(() => {
|
|
64
|
+
var g;
|
|
65
|
+
a((w) => (w == null || w.close(), null)), p(!1), b(!1), h(!1), v(null), (g = C.current) == null || g.forEach(
|
|
66
|
+
(w) => w.unsubscribe()
|
|
67
|
+
);
|
|
68
|
+
}, []), $ = d(
|
|
69
|
+
(g) => {
|
|
70
|
+
i == null || i.sendMessage({ text: g });
|
|
72
71
|
},
|
|
73
|
-
[
|
|
72
|
+
[i]
|
|
74
73
|
);
|
|
75
|
-
return
|
|
74
|
+
return R(() => {
|
|
75
|
+
if (i)
|
|
76
|
+
return C.current = [
|
|
77
|
+
i == null ? void 0 : i.isConnecting$.subscribe(h),
|
|
78
|
+
i == null ? void 0 : i.conversation$.subscribe(v)
|
|
79
|
+
], () => {
|
|
80
|
+
var g;
|
|
81
|
+
(g = C.current) == null || g.forEach(
|
|
82
|
+
(w) => w.unsubscribe()
|
|
83
|
+
);
|
|
84
|
+
};
|
|
85
|
+
}, [i]), R(() => {
|
|
86
|
+
!i && u && L();
|
|
87
|
+
}, [i, u, L]), R(() => () => M(), [M]), B(
|
|
76
88
|
() => ({
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
89
|
+
isOpen: u,
|
|
90
|
+
isResetting: m,
|
|
91
|
+
isConnecting: l,
|
|
92
|
+
conversation: f,
|
|
93
|
+
sendMessage: $,
|
|
94
|
+
resetChannel: L,
|
|
95
|
+
closeChannel: M
|
|
80
96
|
}),
|
|
81
|
-
[
|
|
97
|
+
[
|
|
98
|
+
u,
|
|
99
|
+
m,
|
|
100
|
+
l,
|
|
101
|
+
f,
|
|
102
|
+
$,
|
|
103
|
+
L,
|
|
104
|
+
M
|
|
105
|
+
]
|
|
82
106
|
);
|
|
83
107
|
}
|
|
84
|
-
function
|
|
85
|
-
const [
|
|
86
|
-
return
|
|
108
|
+
function ut(e, t) {
|
|
109
|
+
const [s, n] = N(e);
|
|
110
|
+
return R(() => {
|
|
87
111
|
const c = window.setTimeout(() => {
|
|
88
|
-
|
|
112
|
+
n(e);
|
|
89
113
|
}, t ?? 300);
|
|
90
114
|
return () => clearTimeout(c);
|
|
91
|
-
}, [
|
|
115
|
+
}, [e, t]), s;
|
|
92
116
|
}
|
|
93
|
-
const
|
|
117
|
+
const Y = ot({
|
|
118
|
+
avatar: void 0,
|
|
94
119
|
client: null,
|
|
120
|
+
isOpen: !1,
|
|
121
|
+
isResetting: !1,
|
|
95
122
|
isConnecting: !1,
|
|
96
123
|
messages: null,
|
|
97
|
-
typingMessages: null,
|
|
98
124
|
messageBoxBottomRef: { current: null },
|
|
99
|
-
|
|
100
|
-
}
|
|
125
|
+
botTypingPlaceholder: void 0
|
|
101
126
|
});
|
|
102
|
-
function
|
|
127
|
+
function dt(e) {
|
|
103
128
|
const {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
129
|
+
avatar: t,
|
|
130
|
+
children: s,
|
|
131
|
+
config: n,
|
|
132
|
+
botTypingPlaceholder: c,
|
|
133
|
+
customChannelId: r,
|
|
134
|
+
customMessageId: i,
|
|
108
135
|
delayTime: a,
|
|
109
|
-
initMessages:
|
|
110
|
-
options:
|
|
111
|
-
...
|
|
112
|
-
} =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
136
|
+
initMessages: u,
|
|
137
|
+
options: p,
|
|
138
|
+
...m
|
|
139
|
+
} = e, b = z(null), l = lt({ config: n }), {
|
|
140
|
+
isOpen: h,
|
|
141
|
+
isResetting: f,
|
|
142
|
+
isConnecting: v,
|
|
143
|
+
conversation: C,
|
|
144
|
+
sendMessage: L,
|
|
145
|
+
resetChannel: M,
|
|
146
|
+
closeChannel: $
|
|
147
|
+
} = _t({
|
|
148
|
+
client: l,
|
|
149
|
+
customChannelId: r,
|
|
150
|
+
initMessages: u,
|
|
151
|
+
showDebugMessage: p == null ? void 0 : p.showDebugMessage
|
|
152
|
+
}), g = B(
|
|
118
153
|
() => ({
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
154
|
+
avatar: t,
|
|
155
|
+
client: l,
|
|
156
|
+
isOpen: h,
|
|
157
|
+
isResetting: f,
|
|
158
|
+
isConnecting: v,
|
|
159
|
+
messages: (C == null ? void 0 : C.messages) ?? null,
|
|
160
|
+
sendMessage: L,
|
|
161
|
+
resetChannel: M,
|
|
162
|
+
closeChannel: $,
|
|
163
|
+
botTypingPlaceholder: c,
|
|
164
|
+
messageBoxBottomRef: b
|
|
125
165
|
}),
|
|
126
|
-
[
|
|
166
|
+
[
|
|
167
|
+
t,
|
|
168
|
+
l,
|
|
169
|
+
h,
|
|
170
|
+
f,
|
|
171
|
+
v,
|
|
172
|
+
C == null ? void 0 : C.messages,
|
|
173
|
+
L,
|
|
174
|
+
M,
|
|
175
|
+
$,
|
|
176
|
+
c
|
|
177
|
+
]
|
|
127
178
|
);
|
|
128
|
-
return /* @__PURE__ */ o(
|
|
179
|
+
return /* @__PURE__ */ o(Y.Provider, { value: g, children: /* @__PURE__ */ o("div", { ...m, children: s }) });
|
|
129
180
|
}
|
|
130
|
-
function
|
|
131
|
-
return
|
|
181
|
+
function y() {
|
|
182
|
+
return st(Y);
|
|
132
183
|
}
|
|
133
|
-
const
|
|
134
|
-
chatbot_header:
|
|
135
|
-
chatbot_header__content:
|
|
136
|
-
chatbot_header__title:
|
|
137
|
-
chatbot_header__extra:
|
|
184
|
+
const ht = "_chatbot_header_f3p4c_1", mt = "_chatbot_header__content_f3p4c_1", bt = "_chatbot_header__title_f3p4c_9", gt = "_chatbot_header__extra_f3p4c_20", I = {
|
|
185
|
+
chatbot_header: ht,
|
|
186
|
+
chatbot_header__content: mt,
|
|
187
|
+
chatbot_header__title: bt,
|
|
188
|
+
chatbot_header__extra: gt
|
|
138
189
|
};
|
|
139
|
-
function
|
|
140
|
-
|
|
190
|
+
function pt(e) {
|
|
191
|
+
const { avatar: t } = e;
|
|
192
|
+
return t ? /* @__PURE__ */ o(
|
|
193
|
+
"img",
|
|
194
|
+
{
|
|
195
|
+
src: t,
|
|
196
|
+
alt: "avatar",
|
|
197
|
+
style: {
|
|
198
|
+
width: 33,
|
|
199
|
+
height: 32,
|
|
200
|
+
borderRadius: "50%"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
) : /* @__PURE__ */ _(
|
|
141
204
|
"svg",
|
|
142
205
|
{
|
|
143
206
|
width: "33",
|
|
@@ -146,7 +209,7 @@ function st() {
|
|
|
146
209
|
fill: "none",
|
|
147
210
|
xmlns: "http://www.w3.org/2000/svg",
|
|
148
211
|
children: [
|
|
149
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ _("g", { "clip-path": "url(#clip0_3084_29383)", children: [
|
|
150
213
|
/* @__PURE__ */ o(
|
|
151
214
|
"path",
|
|
152
215
|
{
|
|
@@ -175,96 +238,116 @@ function st() {
|
|
|
175
238
|
}
|
|
176
239
|
);
|
|
177
240
|
}
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
241
|
+
const ft = (e) => /* @__PURE__ */ x.createElement("svg", { width: 16, height: 16, viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ x.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" })), Ct = (e) => /* @__PURE__ */ x.createElement("svg", { width: 15, height: 14, viewBox: "0 0 15 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ x.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" }));
|
|
242
|
+
function vt(e) {
|
|
243
|
+
const { title: t } = e, { avatar: s, isOpen: n, isResetting: c, resetChannel: r, closeChannel: i } = y(), a = d(
|
|
244
|
+
(m) => {
|
|
245
|
+
!n && !c && (m.stopPropagation(), r == null || r());
|
|
246
|
+
},
|
|
247
|
+
[n, c, r]
|
|
248
|
+
), u = d(
|
|
249
|
+
(m) => {
|
|
250
|
+
n && !c && (m.stopPropagation(), r == null || r());
|
|
251
|
+
},
|
|
252
|
+
[n, c, r]
|
|
253
|
+
), p = d(
|
|
254
|
+
(m) => {
|
|
255
|
+
c || (m.stopPropagation(), i == null || i());
|
|
256
|
+
},
|
|
257
|
+
[c, i]
|
|
258
|
+
);
|
|
259
|
+
return /* @__PURE__ */ o("div", { className: I.chatbot_header, onClick: a, children: /* @__PURE__ */ _("div", { className: I.chatbot_header__content, children: [
|
|
260
|
+
/* @__PURE__ */ _("div", { className: I.chatbot_header__title, children: [
|
|
261
|
+
/* @__PURE__ */ o(pt, { avatar: s }),
|
|
183
262
|
/* @__PURE__ */ o("h4", { children: t })
|
|
184
263
|
] }),
|
|
185
|
-
/* @__PURE__ */
|
|
264
|
+
/* @__PURE__ */ _("div", { className: I.chatbot_header__extra, children: [
|
|
265
|
+
/* @__PURE__ */ o("div", { onClick: u, children: /* @__PURE__ */ o(ft, {}) }),
|
|
266
|
+
/* @__PURE__ */ o("div", { onClick: p, children: /* @__PURE__ */ o(Ct, {}) })
|
|
267
|
+
] })
|
|
186
268
|
] }) });
|
|
187
269
|
}
|
|
188
|
-
const
|
|
189
|
-
chatbot_body:
|
|
190
|
-
chatbot_body__content:
|
|
191
|
-
},
|
|
192
|
-
template_box:
|
|
270
|
+
const xt = "_chatbot_body_1f0gq_1", yt = "_chatbot_body__content_1f0gq_7", P = {
|
|
271
|
+
chatbot_body: xt,
|
|
272
|
+
chatbot_body__content: yt
|
|
273
|
+
}, wt = "_template_box_1ozig_1", k = {
|
|
274
|
+
template_box: wt,
|
|
193
275
|
"template_box--bot": "_template_box--bot_1ozig_7",
|
|
194
276
|
"template_box--horizontal": "_template_box--horizontal_1ozig_7",
|
|
195
277
|
"template_box--vertical": "_template_box--vertical_1ozig_10",
|
|
196
278
|
"template_box--user": "_template_box--user_1ozig_14"
|
|
197
279
|
};
|
|
198
|
-
function
|
|
199
|
-
const { type: t, direction:
|
|
280
|
+
function E(e) {
|
|
281
|
+
const { type: t, direction: s = "horizontal", children: n } = e, c = B(() => {
|
|
200
282
|
switch (t) {
|
|
201
283
|
case "user":
|
|
202
|
-
return
|
|
284
|
+
return T(k.template_box, k["template_box--user"]);
|
|
203
285
|
case "bot":
|
|
204
286
|
default:
|
|
205
|
-
return
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
287
|
+
return T(
|
|
288
|
+
k.template_box,
|
|
289
|
+
k["template_box--bot"],
|
|
290
|
+
s === "horizontal" ? k["template_box--horizontal"] : k["template_box--vertical"]
|
|
209
291
|
);
|
|
210
292
|
}
|
|
211
|
-
}, [
|
|
212
|
-
return /* @__PURE__ */ o("div", { className: c, children:
|
|
293
|
+
}, [s, t]);
|
|
294
|
+
return /* @__PURE__ */ o("div", { className: c, children: n });
|
|
213
295
|
}
|
|
214
|
-
const
|
|
215
|
-
template_box_content:
|
|
216
|
-
content:
|
|
217
|
-
},
|
|
218
|
-
quick_replies_box:
|
|
219
|
-
quick_reply:
|
|
296
|
+
const Nt = "_template_box_content_12ojl_1", Tt = "_content_12ojl_7", F = {
|
|
297
|
+
template_box_content: Nt,
|
|
298
|
+
content: Tt
|
|
299
|
+
}, Rt = "_quick_replies_box_zoq7y_1", Lt = "_quick_reply_zoq7y_7", U = {
|
|
300
|
+
quick_replies_box: Rt,
|
|
301
|
+
quick_reply: Lt
|
|
220
302
|
};
|
|
221
|
-
function
|
|
222
|
-
const { quickReplies: t } =
|
|
223
|
-
(
|
|
224
|
-
|
|
303
|
+
function Mt(e) {
|
|
304
|
+
const { quickReplies: t } = e, { sendMessage: s, isConnecting: n } = y(), c = d(
|
|
305
|
+
(r) => {
|
|
306
|
+
s == null || s(r);
|
|
225
307
|
},
|
|
226
|
-
[
|
|
308
|
+
[s]
|
|
227
309
|
);
|
|
228
|
-
return t != null && t.length ? /* @__PURE__ */ o("div", { className:
|
|
229
|
-
"
|
|
310
|
+
return t != null && t.length ? /* @__PURE__ */ o("div", { className: U.quick_replies_box, children: t.map((r) => /* @__PURE__ */ o(
|
|
311
|
+
"button",
|
|
230
312
|
{
|
|
231
|
-
className:
|
|
232
|
-
|
|
233
|
-
|
|
313
|
+
className: U.quick_reply,
|
|
314
|
+
disabled: n,
|
|
315
|
+
onClick: () => c(r.text),
|
|
316
|
+
children: r.text
|
|
234
317
|
},
|
|
235
|
-
|
|
318
|
+
r.text
|
|
236
319
|
)) }) : null;
|
|
237
320
|
}
|
|
238
|
-
function
|
|
239
|
-
return
|
|
321
|
+
function tt(e) {
|
|
322
|
+
return e.toLocaleTimeString("zh-TW", {
|
|
240
323
|
timeZone: "Asia/Taipei",
|
|
241
324
|
hour: "2-digit",
|
|
242
325
|
minute: "2-digit",
|
|
243
326
|
hour12: !1
|
|
244
327
|
});
|
|
245
328
|
}
|
|
246
|
-
const
|
|
247
|
-
time:
|
|
329
|
+
const St = "_time_rgg92_1", Bt = {
|
|
330
|
+
time: St
|
|
248
331
|
};
|
|
249
|
-
function
|
|
250
|
-
const { time: t, className:
|
|
251
|
-
return t ? /* @__PURE__ */ o("div", { className:
|
|
332
|
+
function D(e) {
|
|
333
|
+
const { time: t, className: s } = e;
|
|
334
|
+
return t ? /* @__PURE__ */ o("div", { className: T(Bt.time, s), children: tt(t) }) : null;
|
|
252
335
|
}
|
|
253
|
-
function
|
|
254
|
-
const { quickReplies: t, time:
|
|
255
|
-
return /* @__PURE__ */
|
|
256
|
-
/* @__PURE__ */
|
|
257
|
-
|
|
258
|
-
/* @__PURE__ */ o(
|
|
336
|
+
function O(e) {
|
|
337
|
+
const { quickReplies: t, time: s, children: n } = e;
|
|
338
|
+
return /* @__PURE__ */ _("div", { className: F.template_box_content, children: [
|
|
339
|
+
/* @__PURE__ */ _("div", { className: F.content, children: [
|
|
340
|
+
n,
|
|
341
|
+
/* @__PURE__ */ o(D, { time: s })
|
|
259
342
|
] }),
|
|
260
|
-
!!(t != null && t.length) && /* @__PURE__ */ o(
|
|
343
|
+
!!(t != null && t.length) && /* @__PURE__ */ o(Mt, { quickReplies: t })
|
|
261
344
|
] });
|
|
262
345
|
}
|
|
263
|
-
const
|
|
264
|
-
bot_avatar:
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
return /* @__PURE__ */ o("div", { className:
|
|
346
|
+
const kt = "_bot_avatar_xrs9x_1", J = {
|
|
347
|
+
bot_avatar: kt
|
|
348
|
+
}, A = ct((e) => {
|
|
349
|
+
const { avatar: t } = e;
|
|
350
|
+
return t ? /* @__PURE__ */ o("img", { src: t, alt: "Bot Avatar", className: J.bot_avatar }) : /* @__PURE__ */ o("div", { className: J.bot_avatar, children: /* @__PURE__ */ _(
|
|
268
351
|
"svg",
|
|
269
352
|
{
|
|
270
353
|
style: { width: "100%", height: "100%" },
|
|
@@ -289,55 +372,63 @@ function z() {
|
|
|
289
372
|
]
|
|
290
373
|
}
|
|
291
374
|
) });
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
text: ft,
|
|
375
|
+
}), Ht = "_text_1djgp_1", zt = "_dot_1djgp_18", $t = "_blink_1djgp_1", H = {
|
|
376
|
+
text: Ht,
|
|
295
377
|
"text--bot": "_text--bot_1djgp_7",
|
|
296
378
|
"typing-indicator": "_typing-indicator_1djgp_13",
|
|
297
|
-
dot:
|
|
298
|
-
blink:
|
|
379
|
+
dot: zt,
|
|
380
|
+
blink: $t
|
|
299
381
|
};
|
|
300
|
-
function
|
|
301
|
-
const { children: t, onResize:
|
|
302
|
-
return
|
|
303
|
-
const c = new ResizeObserver((
|
|
304
|
-
for (const
|
|
305
|
-
const { width:
|
|
306
|
-
|
|
382
|
+
function Vt(e) {
|
|
383
|
+
const { children: t, onResize: s } = e, n = z(null);
|
|
384
|
+
return R(() => {
|
|
385
|
+
const c = new ResizeObserver((r) => {
|
|
386
|
+
for (const i of r) {
|
|
387
|
+
const { width: a, height: u } = i.contentRect;
|
|
388
|
+
s(a, u);
|
|
307
389
|
}
|
|
308
390
|
});
|
|
309
|
-
return
|
|
391
|
+
return n.current && c.observe(n.current), () => {
|
|
310
392
|
c.disconnect();
|
|
311
393
|
};
|
|
312
|
-
}, [
|
|
394
|
+
}, [n, s]), /* @__PURE__ */ o("div", { ref: n, children: t });
|
|
313
395
|
}
|
|
314
|
-
function
|
|
315
|
-
const {
|
|
396
|
+
function et(e) {
|
|
397
|
+
const { isTyping: t, typingText: s } = e, { messageBoxBottomRef: n, avatar: c } = y(), r = d(() => {
|
|
316
398
|
var a;
|
|
317
|
-
(a =
|
|
318
|
-
}, [
|
|
319
|
-
return
|
|
320
|
-
/* @__PURE__ */ o(
|
|
321
|
-
/* @__PURE__ */ o(
|
|
322
|
-
/* @__PURE__ */ o("span", { children:
|
|
323
|
-
|
|
324
|
-
/* @__PURE__ */ o("div", { className:
|
|
325
|
-
/* @__PURE__ */ o("div", { className:
|
|
326
|
-
/* @__PURE__ */ o("div", { className:
|
|
399
|
+
(a = n.current) == null || a.scrollIntoView({ behavior: "smooth" });
|
|
400
|
+
}, [n]), i = ut(t, 500);
|
|
401
|
+
return i ? /* @__PURE__ */ _(E, { type: "bot", direction: "horizontal", children: [
|
|
402
|
+
/* @__PURE__ */ o(A, { avatar: c }),
|
|
403
|
+
/* @__PURE__ */ o(O, { time: /* @__PURE__ */ new Date(), children: /* @__PURE__ */ o("div", { className: T(H.text, H["text--bot"]), children: /* @__PURE__ */ _(Vt, { onResize: r, children: [
|
|
404
|
+
/* @__PURE__ */ o("span", { children: s ?? "" }),
|
|
405
|
+
i && /* @__PURE__ */ _("span", { className: H["typing-indicator"], children: [
|
|
406
|
+
/* @__PURE__ */ o("div", { className: H.dot }),
|
|
407
|
+
/* @__PURE__ */ o("div", { className: H.dot }),
|
|
408
|
+
/* @__PURE__ */ o("div", { className: H.dot })
|
|
327
409
|
] })
|
|
328
410
|
] }) }) })
|
|
329
411
|
] }) : null;
|
|
330
412
|
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
413
|
+
function jt(e) {
|
|
414
|
+
const { placeholder: t } = e, { isConnecting: s, messages: n } = y(), c = B(
|
|
415
|
+
() => Array.from((n == null ? void 0 : n.values()) ?? []).some(
|
|
416
|
+
(r) => r.type === "bot" && r.isTyping
|
|
417
|
+
),
|
|
418
|
+
[n]
|
|
419
|
+
);
|
|
420
|
+
return s && !c ? /* @__PURE__ */ o(et, { isTyping: !0, typingText: t }) : null;
|
|
421
|
+
}
|
|
422
|
+
const Et = "_card_root_1ygom_1", It = "_card_content_1ygom_10", Zt = "_card_title_1ygom_17", qt = "_card_description_1ygom_23", At = "_card_actions_1ygom_37", V = {
|
|
423
|
+
card_root: Et,
|
|
424
|
+
card_content: It,
|
|
425
|
+
card_title: Zt,
|
|
426
|
+
card_description: qt,
|
|
427
|
+
card_actions: At
|
|
337
428
|
};
|
|
338
|
-
function
|
|
339
|
-
var
|
|
340
|
-
const { template: t } =
|
|
429
|
+
function nt(e) {
|
|
430
|
+
var i;
|
|
431
|
+
const { template: t } = e, { sendMessage: s } = y(), n = B(() => (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]), c = B(() => {
|
|
341
432
|
switch (t == null ? void 0 : t.imageAspectRatio) {
|
|
342
433
|
case "square":
|
|
343
434
|
return "1 / 1";
|
|
@@ -345,25 +436,25 @@ function P(n) {
|
|
|
345
436
|
default:
|
|
346
437
|
return "1.51 / 1";
|
|
347
438
|
}
|
|
348
|
-
}, [t]),
|
|
349
|
-
(
|
|
350
|
-
switch (
|
|
439
|
+
}, [t]), r = d(
|
|
440
|
+
(a) => function() {
|
|
441
|
+
switch (a.type) {
|
|
351
442
|
case "message":
|
|
352
|
-
|
|
443
|
+
s(a.text);
|
|
353
444
|
return;
|
|
354
445
|
case "uri":
|
|
355
|
-
window.open(
|
|
446
|
+
window.open(a.uri, "_blank");
|
|
356
447
|
return;
|
|
357
448
|
}
|
|
358
449
|
},
|
|
359
|
-
[
|
|
450
|
+
[s]
|
|
360
451
|
);
|
|
361
|
-
return /* @__PURE__ */
|
|
452
|
+
return /* @__PURE__ */ _("div", { className: V.card_root, children: [
|
|
362
453
|
(t == null ? void 0 : t.thumbnailImageUrl) && /* @__PURE__ */ o(
|
|
363
454
|
"img",
|
|
364
455
|
{
|
|
365
456
|
alt: t == null ? void 0 : t.title,
|
|
366
|
-
src:
|
|
457
|
+
src: n,
|
|
367
458
|
style: {
|
|
368
459
|
display: "block",
|
|
369
460
|
width: "100%",
|
|
@@ -372,186 +463,301 @@ function P(n) {
|
|
|
372
463
|
}
|
|
373
464
|
}
|
|
374
465
|
),
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */ o("h5", { className:
|
|
377
|
-
/* @__PURE__ */ o("div", { className:
|
|
378
|
-
/* @__PURE__ */ o("div", { className:
|
|
466
|
+
/* @__PURE__ */ _("div", { className: V.card_content, children: [
|
|
467
|
+
/* @__PURE__ */ o("h5", { className: V.card_title, children: t == null ? void 0 : t.title }),
|
|
468
|
+
/* @__PURE__ */ o("div", { className: V.card_description, children: t == null ? void 0 : t.text }),
|
|
469
|
+
/* @__PURE__ */ o("div", { className: V.card_actions, children: (i = t == null ? void 0 : t.buttons) == null ? void 0 : i.map((a, u) => /* @__PURE__ */ o("button", { onClick: r(a.action), children: a.label }, u)) })
|
|
379
470
|
] })
|
|
380
471
|
] });
|
|
381
472
|
}
|
|
382
|
-
function
|
|
383
|
-
const {
|
|
384
|
-
return /* @__PURE__ */
|
|
385
|
-
/* @__PURE__ */ o(
|
|
473
|
+
function Dt(e) {
|
|
474
|
+
const { message: t } = e, { avatar: s } = y(), n = t.message.template;
|
|
475
|
+
return /* @__PURE__ */ _(E, { type: "bot", direction: "horizontal", children: [
|
|
476
|
+
/* @__PURE__ */ o(A, { avatar: s }),
|
|
386
477
|
/* @__PURE__ */ o(
|
|
387
|
-
|
|
478
|
+
O,
|
|
388
479
|
{
|
|
389
480
|
time: t.time,
|
|
390
|
-
quickReplies:
|
|
391
|
-
children: /* @__PURE__ */ o(
|
|
481
|
+
quickReplies: n == null ? void 0 : n.quickReplies,
|
|
482
|
+
children: /* @__PURE__ */ o(nt, { template: n })
|
|
392
483
|
}
|
|
393
484
|
)
|
|
394
485
|
] });
|
|
395
486
|
}
|
|
396
|
-
const
|
|
397
|
-
text:
|
|
487
|
+
const Ot = "_text_sbjtw_1", Pt = "_content_sbjtw_19", Z = {
|
|
488
|
+
text: Ot,
|
|
398
489
|
"text--user": "_text--user_sbjtw_7",
|
|
399
490
|
"text--bot": "_text--bot_sbjtw_13",
|
|
400
|
-
content:
|
|
491
|
+
content: Pt
|
|
401
492
|
};
|
|
402
|
-
function
|
|
403
|
-
var
|
|
404
|
-
const {
|
|
405
|
-
return t.type === "user" ? /* @__PURE__ */
|
|
406
|
-
/* @__PURE__ */ o("div", { className:
|
|
407
|
-
/* @__PURE__ */ o(
|
|
408
|
-
] }) : /* @__PURE__ */
|
|
409
|
-
/* @__PURE__ */ o(
|
|
493
|
+
function W(e) {
|
|
494
|
+
var n;
|
|
495
|
+
const { message: t } = e, { avatar: s } = y();
|
|
496
|
+
return t.type === "user" ? /* @__PURE__ */ _(E, { type: "user", direction: "horizontal", children: [
|
|
497
|
+
/* @__PURE__ */ o("div", { className: T(Z.text, Z["text--user"]), children: t.text }),
|
|
498
|
+
/* @__PURE__ */ o(D, { time: t.time })
|
|
499
|
+
] }) : /* @__PURE__ */ _(E, { type: "bot", direction: "horizontal", children: [
|
|
500
|
+
/* @__PURE__ */ o(A, { avatar: s }),
|
|
410
501
|
/* @__PURE__ */ o(
|
|
411
|
-
|
|
502
|
+
O,
|
|
412
503
|
{
|
|
413
504
|
time: t.time,
|
|
414
|
-
quickReplies: (
|
|
415
|
-
children: /* @__PURE__ */ o("div", { className:
|
|
505
|
+
quickReplies: (n = t.message.template) == null ? void 0 : n.quickReplies,
|
|
506
|
+
children: /* @__PURE__ */ o("div", { className: T(Z.text, Z["text--bot"]), children: t.message.text })
|
|
416
507
|
}
|
|
417
508
|
)
|
|
418
509
|
] });
|
|
419
510
|
}
|
|
420
|
-
const
|
|
421
|
-
carousel_root:
|
|
422
|
-
carousel_time:
|
|
511
|
+
const Ft = "_carousel_root_sv1hc_1", Ut = "_carousel_time_sv1hc_12", K = {
|
|
512
|
+
carousel_root: Ft,
|
|
513
|
+
carousel_time: Ut
|
|
423
514
|
};
|
|
424
|
-
function
|
|
425
|
-
var
|
|
426
|
-
const {
|
|
427
|
-
return /* @__PURE__ */
|
|
428
|
-
/* @__PURE__ */ o(
|
|
429
|
-
/* @__PURE__ */ o("div", { className:
|
|
430
|
-
/* @__PURE__ */ o(
|
|
515
|
+
function Jt(e) {
|
|
516
|
+
var c;
|
|
517
|
+
const { message: t } = e, { avatar: s } = y(), n = t.message.template;
|
|
518
|
+
return /* @__PURE__ */ _(E, { type: "bot", direction: "vertical", children: [
|
|
519
|
+
/* @__PURE__ */ o(A, { avatar: s }),
|
|
520
|
+
/* @__PURE__ */ o("div", { className: K.carousel_root, children: (c = n.columns) == null ? void 0 : c.map((r, i) => /* @__PURE__ */ o(nt, { template: r }, i)) }),
|
|
521
|
+
/* @__PURE__ */ o(D, { className: K.carousel_time, time: t.time })
|
|
431
522
|
] });
|
|
432
523
|
}
|
|
433
|
-
const
|
|
434
|
-
hint_root:
|
|
435
|
-
time:
|
|
524
|
+
const Wt = "_hint_root_g119q_1", Kt = "_time_g119q_14", Q = {
|
|
525
|
+
hint_root: Wt,
|
|
526
|
+
time: Kt
|
|
436
527
|
};
|
|
437
|
-
function
|
|
438
|
-
const {
|
|
528
|
+
function Qt(e) {
|
|
529
|
+
const { message: t } = e;
|
|
439
530
|
if (t.type === "user") return null;
|
|
440
|
-
const
|
|
441
|
-
return
|
|
442
|
-
/* @__PURE__ */ o("div", { className:
|
|
443
|
-
|
|
531
|
+
const s = t.message.template;
|
|
532
|
+
return s.type !== j.HINT ? null : /* @__PURE__ */ _("div", { className: Q.hint_root, children: [
|
|
533
|
+
/* @__PURE__ */ o("div", { className: Q.time, children: tt(t.time) }),
|
|
534
|
+
s.text
|
|
444
535
|
] });
|
|
445
536
|
}
|
|
446
|
-
function
|
|
447
|
-
|
|
537
|
+
function Xt(e) {
|
|
538
|
+
var s;
|
|
539
|
+
const { message: t } = e;
|
|
448
540
|
if (t.type === "user")
|
|
449
|
-
return /* @__PURE__ */ o(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
541
|
+
return /* @__PURE__ */ o(W, { message: t });
|
|
542
|
+
if (t.isTyping)
|
|
543
|
+
return /* @__PURE__ */ o(
|
|
544
|
+
et,
|
|
545
|
+
{
|
|
546
|
+
isTyping: t.isTyping,
|
|
547
|
+
typingText: t.typingText
|
|
548
|
+
}
|
|
549
|
+
);
|
|
550
|
+
switch ((s = t.message.template) == null ? void 0 : s.type) {
|
|
551
|
+
case j.TEXT:
|
|
552
|
+
return /* @__PURE__ */ o(W, { message: t });
|
|
553
|
+
case j.HINT:
|
|
554
|
+
return /* @__PURE__ */ o(Qt, { message: t });
|
|
555
|
+
case j.BUTTON:
|
|
556
|
+
return /* @__PURE__ */ o(Dt, { message: t });
|
|
557
|
+
case j.CAROUSEL:
|
|
558
|
+
return /* @__PURE__ */ o(Jt, { message: t });
|
|
460
559
|
default:
|
|
461
|
-
return /* @__PURE__ */ o("div", {
|
|
560
|
+
return /* @__PURE__ */ o("div", {});
|
|
462
561
|
}
|
|
463
562
|
}
|
|
464
|
-
function
|
|
465
|
-
const { messages:
|
|
466
|
-
return
|
|
467
|
-
var
|
|
468
|
-
(
|
|
469
|
-
}, [
|
|
470
|
-
Array.from((
|
|
471
|
-
|
|
563
|
+
function Gt() {
|
|
564
|
+
const { messages: e, messageBoxBottomRef: t, botTypingPlaceholder: s } = y();
|
|
565
|
+
return R(() => {
|
|
566
|
+
var n;
|
|
567
|
+
(n = t.current) == null || n.scrollIntoView({ behavior: "smooth" });
|
|
568
|
+
}, [e, t]), /* @__PURE__ */ o("div", { className: P.chatbot_body, children: /* @__PURE__ */ _("div", { className: P.chatbot_body__content, children: [
|
|
569
|
+
Array.from((e == null ? void 0 : e.values()) ?? []).map((n) => /* @__PURE__ */ o(
|
|
570
|
+
Xt,
|
|
472
571
|
{
|
|
473
|
-
|
|
572
|
+
message: n
|
|
474
573
|
},
|
|
475
|
-
|
|
574
|
+
n.messageId
|
|
476
575
|
)),
|
|
477
|
-
|
|
478
|
-
|
|
576
|
+
/* @__PURE__ */ o(
|
|
577
|
+
jt,
|
|
479
578
|
{
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
)
|
|
484
|
-
/* @__PURE__ */ o("div", { ref: e })
|
|
579
|
+
placeholder: s ?? "正在輸入訊息"
|
|
580
|
+
}
|
|
581
|
+
),
|
|
582
|
+
/* @__PURE__ */ o("div", { ref: t })
|
|
485
583
|
] }) });
|
|
486
584
|
}
|
|
487
|
-
const
|
|
488
|
-
chatbot_footer:
|
|
489
|
-
chatbot_footer__content:
|
|
490
|
-
chatbot_textarea:
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
585
|
+
const Yt = "_chatbot_footer_aa5it_1", te = "_chatbot_footer__content_aa5it_1", ee = "_chatbot_textarea_aa5it_12", ne = "_chatbot_submit_button_aa5it_27", oe = "_chatbot_submit_button__disabled_aa5it_52", S = {
|
|
586
|
+
chatbot_footer: Yt,
|
|
587
|
+
chatbot_footer__content: te,
|
|
588
|
+
chatbot_textarea: ee,
|
|
589
|
+
chatbot_submit_button: ne,
|
|
590
|
+
chatbot_submit_button__disabled: oe
|
|
591
|
+
}, se = (e) => /* @__PURE__ */ x.createElement("svg", { width: 15, height: 12, viewBox: "0 0 15 12", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ x.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__ */ x.createElement("svg", { width: 11, height: 16, viewBox: "0 0 11 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ x.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" })), re = (e) => /* @__PURE__ */ x.createElement("svg", { width: 40, height: 40, viewBox: "0 0 40 40", xmlns: "http://www.w3.org/2000/svg", ...e }, /* @__PURE__ */ x.createElement("circle", { cx: 20, cy: 20, r: 18, fill: "#D04444" }), /* @__PURE__ */ x.createElement("rect", { x: 12, y: 12, width: 16, height: 16, fill: "#FFFFFF", rx: 2, ry: 2 }));
|
|
592
|
+
function ie(e) {
|
|
593
|
+
const { setValue: t, className: s } = e, [n, c] = N(!1), r = z(null);
|
|
594
|
+
R(() => {
|
|
595
|
+
const l = window.SpeechRecognition || window.webkitSpeechRecognition;
|
|
596
|
+
if (!l) return;
|
|
597
|
+
const h = new l();
|
|
598
|
+
h.lang = "zh-TW", h.continuous = !0, h.interimResults = !0, h.onresult = (f) => {
|
|
599
|
+
for (let v = f.resultIndex; v < f.results.length; v++)
|
|
600
|
+
f.results[v].isFinal && t((C) => C + f.results[v][0].transcript);
|
|
601
|
+
}, h.onerror = (f) => {
|
|
602
|
+
alert(`語音識別錯誤: ${JSON.stringify(f.error)}`);
|
|
603
|
+
}, h.onend = () => {
|
|
604
|
+
c(!1);
|
|
605
|
+
}, r.current = h;
|
|
606
|
+
}, [t]);
|
|
607
|
+
const i = d(() => {
|
|
608
|
+
if (!r.current) {
|
|
609
|
+
alert("無法開始辨識: 語音識別器未初始化,請檢查是否有授權使用麥克風");
|
|
610
|
+
return;
|
|
611
|
+
}
|
|
612
|
+
try {
|
|
613
|
+
r.current.start(), c(!0);
|
|
614
|
+
} catch (l) {
|
|
615
|
+
alert(`無法開始辨識: ${JSON.stringify(l)}`);
|
|
616
|
+
}
|
|
617
|
+
}, []), a = d(() => {
|
|
618
|
+
r.current && (r.current.stop(), c(!1));
|
|
619
|
+
}, []), u = d(
|
|
620
|
+
(l) => {
|
|
621
|
+
n || (l.preventDefault(), i());
|
|
497
622
|
},
|
|
498
|
-
[]
|
|
499
|
-
),
|
|
500
|
-
(
|
|
501
|
-
|
|
623
|
+
[n, i]
|
|
624
|
+
), p = d(
|
|
625
|
+
(l) => {
|
|
626
|
+
n && (l.preventDefault(), a());
|
|
627
|
+
},
|
|
628
|
+
[n, a]
|
|
629
|
+
), m = d(
|
|
630
|
+
(l) => {
|
|
631
|
+
n || (l.preventDefault(), i());
|
|
502
632
|
},
|
|
503
|
-
[
|
|
633
|
+
[n, i]
|
|
634
|
+
), b = d(
|
|
635
|
+
(l) => {
|
|
636
|
+
n && (l.preventDefault(), a());
|
|
637
|
+
},
|
|
638
|
+
[n, a]
|
|
504
639
|
);
|
|
505
|
-
return /* @__PURE__ */ o(
|
|
506
|
-
"
|
|
640
|
+
return /* @__PURE__ */ o(
|
|
641
|
+
"div",
|
|
507
642
|
{
|
|
508
|
-
className:
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
onKeyDown: l,
|
|
515
|
-
onCompositionStart: () => a(!0),
|
|
516
|
-
onCompositionEnd: () => a(!1)
|
|
643
|
+
className: s,
|
|
644
|
+
onMouseDown: u,
|
|
645
|
+
onMouseUp: p,
|
|
646
|
+
onTouchStart: m,
|
|
647
|
+
onTouchEnd: b,
|
|
648
|
+
children: n ? /* @__PURE__ */ o(re, {}) : /* @__PURE__ */ o(ce, {})
|
|
517
649
|
}
|
|
518
|
-
)
|
|
650
|
+
);
|
|
519
651
|
}
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
652
|
+
function ae() {
|
|
653
|
+
const { sendMessage: e, isConnecting: t } = y(), [s, n] = N(""), [c, r] = N(!1), i = z(null), a = B(() => t || !s, [t, s]), u = d(
|
|
654
|
+
(b) => {
|
|
655
|
+
const l = b.target, h = l.value;
|
|
656
|
+
l.style.height = "20px", h && (l.style.height = `${l.scrollHeight - 16}px`), n(b.target.value);
|
|
657
|
+
},
|
|
658
|
+
[]
|
|
659
|
+
), p = d(() => {
|
|
660
|
+
!c && !t && (e == null || e(s), n(""), i.current && (i.current.style.height = "20px"));
|
|
661
|
+
}, [c, t, e, s]), m = d(
|
|
662
|
+
(b) => {
|
|
663
|
+
if (b.key === "Enter" && !c && !t) {
|
|
664
|
+
e == null || e(s), n("");
|
|
665
|
+
const l = b.target;
|
|
666
|
+
l.style.height = "20px";
|
|
667
|
+
}
|
|
668
|
+
},
|
|
669
|
+
[c, t, e, s]
|
|
670
|
+
);
|
|
671
|
+
return /* @__PURE__ */ o("div", { className: S.chatbot_footer, children: /* @__PURE__ */ _("div", { className: S.chatbot_footer__content, children: [
|
|
672
|
+
/* @__PURE__ */ o(
|
|
673
|
+
"textarea",
|
|
674
|
+
{
|
|
675
|
+
ref: i,
|
|
676
|
+
className: S.chatbot_textarea,
|
|
677
|
+
disabled: t,
|
|
678
|
+
cols: 40,
|
|
679
|
+
value: s,
|
|
680
|
+
placeholder: "Enter message",
|
|
681
|
+
onChange: u,
|
|
682
|
+
onKeyDown: m,
|
|
683
|
+
onCompositionStart: () => r(!0),
|
|
684
|
+
onCompositionEnd: () => r(!1)
|
|
685
|
+
}
|
|
686
|
+
),
|
|
687
|
+
s ? /* @__PURE__ */ o(
|
|
688
|
+
"button",
|
|
689
|
+
{
|
|
690
|
+
className: T(
|
|
691
|
+
S.chatbot_submit_button,
|
|
692
|
+
a && S.chatbot_submit_button__disabled
|
|
693
|
+
),
|
|
694
|
+
disabled: a,
|
|
695
|
+
onClick: p,
|
|
696
|
+
children: /* @__PURE__ */ o(se, {})
|
|
697
|
+
}
|
|
698
|
+
) : /* @__PURE__ */ o(
|
|
699
|
+
ie,
|
|
700
|
+
{
|
|
701
|
+
setValue: n,
|
|
702
|
+
className: T(
|
|
703
|
+
S.chatbot_submit_button,
|
|
704
|
+
t && S.chatbot_submit_button__disabled
|
|
705
|
+
)
|
|
706
|
+
}
|
|
707
|
+
)
|
|
708
|
+
] }) });
|
|
709
|
+
}
|
|
710
|
+
const le = "_chatbot_root_18brc_1", _e = "_chatbot_root__fullScreen_18brc_13", X = {
|
|
711
|
+
chatbot_root: le,
|
|
712
|
+
chatbot_root__fullScreen: _e
|
|
713
|
+
}, ue = "_loading_16ajc_1", de = "_spinner_16ajc_14", he = "_spinner_svg_16ajc_19", me = "_rotate_16ajc_1", be = "_spinner_circle_16ajc_25", ge = "_dash_16ajc_1", q = {
|
|
714
|
+
loading: ue,
|
|
715
|
+
spinner: de,
|
|
716
|
+
spinner_svg: he,
|
|
717
|
+
rotate: me,
|
|
718
|
+
spinner_circle: be,
|
|
719
|
+
dash: ge
|
|
523
720
|
};
|
|
524
|
-
function
|
|
721
|
+
function pe() {
|
|
722
|
+
const { isResetting: e } = y();
|
|
723
|
+
return e ? /* @__PURE__ */ o("div", { className: q.loading, children: /* @__PURE__ */ o("div", { className: q.spinner, children: /* @__PURE__ */ o("svg", { className: q.spinner_svg, viewBox: "0 0 50 50", children: /* @__PURE__ */ o("circle", { className: q.spinner_circle, cx: "25", cy: "25", r: "20" }) }) }) }) : null;
|
|
724
|
+
}
|
|
725
|
+
function xe(e) {
|
|
525
726
|
const {
|
|
526
727
|
title: t,
|
|
527
|
-
config:
|
|
528
|
-
customChannelId:
|
|
728
|
+
config: s,
|
|
729
|
+
customChannelId: n,
|
|
529
730
|
initMessages: c,
|
|
530
|
-
fullScreen:
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
731
|
+
fullScreen: r = !1,
|
|
732
|
+
avatar: i,
|
|
733
|
+
options: a,
|
|
734
|
+
botTypingPlaceholder: u
|
|
735
|
+
} = e;
|
|
736
|
+
return /* @__PURE__ */ _(
|
|
737
|
+
dt,
|
|
535
738
|
{
|
|
536
|
-
className:
|
|
537
|
-
|
|
538
|
-
|
|
739
|
+
className: T(
|
|
740
|
+
X.chatbot_root,
|
|
741
|
+
r && X.chatbot_root__fullScreen
|
|
539
742
|
),
|
|
540
|
-
|
|
541
|
-
|
|
743
|
+
avatar: i,
|
|
744
|
+
config: s,
|
|
745
|
+
customChannelId: n,
|
|
542
746
|
initMessages: c,
|
|
543
|
-
|
|
747
|
+
botTypingPlaceholder: u,
|
|
748
|
+
options: a,
|
|
544
749
|
children: [
|
|
545
|
-
/* @__PURE__ */ o(
|
|
546
|
-
/* @__PURE__ */ o(
|
|
547
|
-
/* @__PURE__ */ o(
|
|
750
|
+
/* @__PURE__ */ o(pe, {}),
|
|
751
|
+
/* @__PURE__ */ o(vt, { title: t }),
|
|
752
|
+
/* @__PURE__ */ o(Gt, {}),
|
|
753
|
+
/* @__PURE__ */ o(ae, {})
|
|
548
754
|
]
|
|
549
755
|
}
|
|
550
756
|
);
|
|
551
757
|
}
|
|
552
758
|
export {
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
759
|
+
xe as Chatbot,
|
|
760
|
+
lt as useAsgardServiceClient,
|
|
761
|
+
_t as useChannel,
|
|
762
|
+
ut as useDebounce
|
|
557
763
|
};
|