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