@asgard-js/react 0.0.6 → 0.0.8

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