@enjoys/react-chatbot-plugin 1.0.0 → 1.2.0
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 +541 -6
- package/dist/index.cjs +45 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +372 -64
- package/dist/index.mjs +2076 -646
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Fragment as
|
|
3
|
-
function
|
|
1
|
+
import _, { createContext as N, useCallback as v, useContext as Y, useEffect as A, useMemo as U, useReducer as Q, useRef as C, useState as I } from "react";
|
|
2
|
+
import { Fragment as K, jsx as a, jsxs as x } from "react/jsx-runtime";
|
|
3
|
+
function J(e, t) {
|
|
4
4
|
switch (t.type) {
|
|
5
5
|
case "TOGGLE_OPEN":
|
|
6
6
|
return {
|
|
@@ -50,19 +50,43 @@ function A(e, t) {
|
|
|
50
50
|
...e,
|
|
51
51
|
isLoggedIn: t.payload
|
|
52
52
|
};
|
|
53
|
-
case "CLEAR_QUICK_REPLIES":
|
|
53
|
+
case "CLEAR_QUICK_REPLIES": {
|
|
54
|
+
let r = -1;
|
|
55
|
+
for (let o = e.messages.length - 1; o >= 0; o--) if (e.messages[o].quickReplies) {
|
|
56
|
+
r = o;
|
|
57
|
+
break;
|
|
58
|
+
}
|
|
59
|
+
if (r === -1) return e;
|
|
60
|
+
const n = [...e.messages];
|
|
61
|
+
return n[r] = {
|
|
62
|
+
...n[r],
|
|
63
|
+
quickReplies: void 0
|
|
64
|
+
}, {
|
|
65
|
+
...e,
|
|
66
|
+
messages: n
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
case "RESET_CHAT":
|
|
54
70
|
return {
|
|
55
71
|
...e,
|
|
56
|
-
messages:
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
72
|
+
messages: [],
|
|
73
|
+
isTyping: !1,
|
|
74
|
+
currentStepId: null,
|
|
75
|
+
collectedData: {}
|
|
76
|
+
};
|
|
77
|
+
case "UPDATE_MESSAGE":
|
|
78
|
+
return {
|
|
79
|
+
...e,
|
|
80
|
+
messages: e.messages.map((r) => r.id === t.payload.id ? {
|
|
81
|
+
...r,
|
|
82
|
+
...t.payload.updates
|
|
83
|
+
} : r)
|
|
60
84
|
};
|
|
61
85
|
default:
|
|
62
86
|
return e;
|
|
63
87
|
}
|
|
64
88
|
}
|
|
65
|
-
var
|
|
89
|
+
var V = (e) => ({
|
|
66
90
|
isOpen: e.defaultOpen ?? !1,
|
|
67
91
|
messages: e.initialMessages ?? [],
|
|
68
92
|
isTyping: !1,
|
|
@@ -70,33 +94,69 @@ var _ = (e) => ({
|
|
|
70
94
|
currentStepId: null,
|
|
71
95
|
collectedData: {},
|
|
72
96
|
isLoggedIn: !e.loginForm
|
|
73
|
-
}),
|
|
74
|
-
function
|
|
75
|
-
const e =
|
|
97
|
+
}), $ = N(null);
|
|
98
|
+
function j() {
|
|
99
|
+
const e = Y($);
|
|
76
100
|
if (!e) throw new Error("useChatContext must be used within ChatProvider");
|
|
77
101
|
return e;
|
|
78
102
|
}
|
|
79
|
-
var
|
|
80
|
-
primaryColor: "#
|
|
81
|
-
headerBg: "#
|
|
103
|
+
var X = {
|
|
104
|
+
primaryColor: "#6C5CE7",
|
|
105
|
+
headerBg: "linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%)",
|
|
82
106
|
headerText: "#FFFFFF",
|
|
83
|
-
bubbleBg: "
|
|
84
|
-
bubbleText: "#
|
|
85
|
-
userBubbleBg: "#
|
|
107
|
+
bubbleBg: "rgba(241, 243, 249, 0.85)",
|
|
108
|
+
bubbleText: "#2D3436",
|
|
109
|
+
userBubbleBg: "linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%)",
|
|
86
110
|
userBubbleText: "#FFFFFF",
|
|
87
|
-
fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
111
|
+
fontFamily: '"Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',
|
|
88
112
|
fontSize: "14px",
|
|
89
|
-
borderRadius: "
|
|
90
|
-
windowWidth: "
|
|
91
|
-
windowHeight: "
|
|
113
|
+
borderRadius: "20px",
|
|
114
|
+
windowWidth: "400px",
|
|
115
|
+
windowHeight: "600px",
|
|
116
|
+
mode: "light"
|
|
117
|
+
}, Z = {
|
|
118
|
+
headerBg: "linear-gradient(135deg, #2D1B69 0%, #4A3298 100%)",
|
|
119
|
+
headerText: "#F0F0FF",
|
|
120
|
+
bubbleBg: "rgba(45, 45, 70, 0.85)",
|
|
121
|
+
bubbleText: "#E8E8F0",
|
|
122
|
+
userBubbleBg: "linear-gradient(135deg, #6C5CE7 0%, #A29BFE 100%)",
|
|
123
|
+
userBubbleText: "#FFFFFF"
|
|
92
124
|
};
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
...
|
|
125
|
+
function O(e) {
|
|
126
|
+
const t = {
|
|
127
|
+
...X,
|
|
128
|
+
...e
|
|
129
|
+
};
|
|
130
|
+
return t.mode === "dark" ? {
|
|
131
|
+
...t,
|
|
132
|
+
...Z,
|
|
96
133
|
...e
|
|
134
|
+
} : t;
|
|
135
|
+
}
|
|
136
|
+
function ee(e) {
|
|
137
|
+
return {
|
|
138
|
+
"--cb-primary": e.primaryColor,
|
|
139
|
+
"--cb-header-bg": e.headerBg,
|
|
140
|
+
"--cb-header-text": e.headerText,
|
|
141
|
+
"--cb-bubble-bg": e.bubbleBg,
|
|
142
|
+
"--cb-bubble-text": e.bubbleText,
|
|
143
|
+
"--cb-user-bubble-bg": e.userBubbleBg,
|
|
144
|
+
"--cb-user-bubble-text": e.userBubbleText,
|
|
145
|
+
"--cb-font-family": e.fontFamily,
|
|
146
|
+
"--cb-font-size": e.fontSize,
|
|
147
|
+
"--cb-border-radius": e.borderRadius,
|
|
148
|
+
"--cb-window-width": e.windowWidth,
|
|
149
|
+
"--cb-window-height": e.windowHeight,
|
|
150
|
+
"--cb-bg": e.mode === "dark" ? "rgba(22, 22, 40, 0.95)" : "rgba(255, 255, 255, 0.92)",
|
|
151
|
+
"--cb-border": e.mode === "dark" ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.06)",
|
|
152
|
+
"--cb-input-bg": e.mode === "dark" ? "rgba(40, 40, 65, 0.8)" : "rgba(245, 247, 252, 0.9)",
|
|
153
|
+
"--cb-input-border": e.mode === "dark" ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.06)",
|
|
154
|
+
"--cb-input-text": e.mode === "dark" ? "#E0E0E0" : "#2D3436",
|
|
155
|
+
"--cb-branding-bg": e.mode === "dark" ? "rgba(20, 20, 35, 0.8)" : "rgba(250, 250, 255, 0.8)"
|
|
97
156
|
};
|
|
98
157
|
}
|
|
99
|
-
function
|
|
158
|
+
function te(e, t) {
|
|
159
|
+
const r = e.mode === "dark";
|
|
100
160
|
return {
|
|
101
161
|
root: {
|
|
102
162
|
fontFamily: e.fontFamily,
|
|
@@ -105,18 +165,18 @@ function M(e, t) {
|
|
|
105
165
|
},
|
|
106
166
|
launcher: {
|
|
107
167
|
position: "fixed",
|
|
108
|
-
width: "
|
|
109
|
-
height: "
|
|
168
|
+
width: "62px",
|
|
169
|
+
height: "62px",
|
|
110
170
|
borderRadius: "50%",
|
|
111
|
-
|
|
171
|
+
background: e.headerBg,
|
|
112
172
|
color: "#fff",
|
|
113
173
|
border: "none",
|
|
114
174
|
cursor: "pointer",
|
|
115
175
|
display: "flex",
|
|
116
176
|
alignItems: "center",
|
|
117
177
|
justifyContent: "center",
|
|
118
|
-
boxShadow: "0
|
|
119
|
-
transition: "
|
|
178
|
+
boxShadow: "0 6px 24px rgba(108, 92, 231, 0.4), 0 2px 8px rgba(0,0,0,0.1)",
|
|
179
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
120
180
|
zIndex: 9998,
|
|
121
181
|
...t?.launcher
|
|
122
182
|
},
|
|
@@ -124,330 +184,607 @@ function M(e, t) {
|
|
|
124
184
|
position: "fixed",
|
|
125
185
|
width: e.windowWidth,
|
|
126
186
|
height: e.windowHeight,
|
|
127
|
-
maxHeight: "
|
|
187
|
+
maxHeight: "85vh",
|
|
128
188
|
borderRadius: e.borderRadius,
|
|
129
189
|
overflow: "hidden",
|
|
130
190
|
display: "flex",
|
|
131
191
|
flexDirection: "column",
|
|
132
|
-
boxShadow: "0
|
|
133
|
-
backgroundColor: "
|
|
192
|
+
boxShadow: r ? "0 20px 60px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05)" : "0 20px 60px rgba(108, 92, 231, 0.15), 0 8px 24px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04)",
|
|
193
|
+
backgroundColor: r ? "rgba(22, 22, 40, 0.95)" : "rgba(255, 255, 255, 0.95)",
|
|
194
|
+
backdropFilter: "blur(20px)",
|
|
195
|
+
WebkitBackdropFilter: "blur(20px)",
|
|
196
|
+
border: r ? "1px solid rgba(255,255,255,0.08)" : "1px solid rgba(255,255,255,0.8)",
|
|
134
197
|
zIndex: 9999,
|
|
198
|
+
animation: "cb-window-enter 0.35s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
135
199
|
...t?.window
|
|
136
200
|
},
|
|
137
201
|
header: {
|
|
138
|
-
|
|
202
|
+
background: e.headerBg,
|
|
139
203
|
color: e.headerText,
|
|
140
|
-
padding: "
|
|
204
|
+
padding: "18px 20px",
|
|
141
205
|
display: "flex",
|
|
142
206
|
alignItems: "center",
|
|
143
207
|
justifyContent: "space-between",
|
|
144
208
|
gap: "12px",
|
|
145
209
|
flexShrink: 0,
|
|
210
|
+
position: "relative",
|
|
211
|
+
overflow: "hidden",
|
|
146
212
|
...t?.header
|
|
147
213
|
},
|
|
148
214
|
messageList: {
|
|
149
215
|
flex: 1,
|
|
150
216
|
overflowY: "auto",
|
|
151
|
-
padding: "16px",
|
|
217
|
+
padding: "20px 16px",
|
|
152
218
|
display: "flex",
|
|
153
219
|
flexDirection: "column",
|
|
154
|
-
gap: "
|
|
220
|
+
gap: "10px",
|
|
221
|
+
background: r ? "linear-gradient(180deg, rgba(22, 22, 40, 0.98) 0%, rgba(30, 30, 50, 0.98) 100%)" : "linear-gradient(180deg, rgba(248, 249, 254, 0.95) 0%, rgba(255, 255, 255, 0.95) 100%)",
|
|
155
222
|
...t?.messageList
|
|
156
223
|
},
|
|
157
224
|
inputArea: {
|
|
158
|
-
padding: "12px 16px",
|
|
159
|
-
borderTop:
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
225
|
+
padding: "12px 16px 14px",
|
|
226
|
+
borderTop: `1px solid ${r ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.05)"}`,
|
|
227
|
+
backgroundColor: r ? "rgba(20, 20, 38, 0.9)" : "rgba(255, 255, 255, 0.95)",
|
|
228
|
+
backdropFilter: "blur(12px)",
|
|
229
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
163
230
|
flexShrink: 0,
|
|
164
231
|
...t?.inputArea
|
|
165
232
|
},
|
|
166
233
|
botBubble: {
|
|
167
|
-
|
|
168
|
-
color:
|
|
169
|
-
padding: "
|
|
170
|
-
borderRadius: "
|
|
171
|
-
maxWidth: "
|
|
234
|
+
background: r ? "rgba(45, 45, 70, 0.7)" : "rgba(241, 243, 249, 0.9)",
|
|
235
|
+
color: r ? "#E8E8F0" : "#2D3436",
|
|
236
|
+
padding: "12px 16px",
|
|
237
|
+
borderRadius: "18px 18px 18px 4px",
|
|
238
|
+
maxWidth: "82%",
|
|
172
239
|
alignSelf: "flex-start",
|
|
173
240
|
wordBreak: "break-word",
|
|
174
|
-
whiteSpace: "pre-wrap"
|
|
241
|
+
whiteSpace: "pre-wrap",
|
|
242
|
+
backdropFilter: "blur(8px)",
|
|
243
|
+
WebkitBackdropFilter: "blur(8px)",
|
|
244
|
+
border: r ? "1px solid rgba(255,255,255,0.06)" : "1px solid rgba(0,0,0,0.04)",
|
|
245
|
+
boxShadow: r ? "0 2px 8px rgba(0,0,0,0.2)" : "0 2px 8px rgba(0,0,0,0.04)",
|
|
246
|
+
fontSize: "14px",
|
|
247
|
+
lineHeight: "1.55",
|
|
248
|
+
letterSpacing: "0.01em"
|
|
175
249
|
},
|
|
176
250
|
userBubble: {
|
|
177
|
-
|
|
251
|
+
background: e.userBubbleBg,
|
|
178
252
|
color: e.userBubbleText,
|
|
179
|
-
padding: "
|
|
180
|
-
borderRadius: "
|
|
181
|
-
maxWidth: "
|
|
253
|
+
padding: "12px 16px",
|
|
254
|
+
borderRadius: "18px 18px 4px 18px",
|
|
255
|
+
maxWidth: "82%",
|
|
182
256
|
alignSelf: "flex-end",
|
|
183
257
|
wordBreak: "break-word",
|
|
184
|
-
whiteSpace: "pre-wrap"
|
|
258
|
+
whiteSpace: "pre-wrap",
|
|
259
|
+
boxShadow: "0 4px 14px rgba(108, 92, 231, 0.25)",
|
|
260
|
+
fontSize: "14px",
|
|
261
|
+
lineHeight: "1.55",
|
|
262
|
+
letterSpacing: "0.01em"
|
|
185
263
|
}
|
|
186
264
|
};
|
|
187
265
|
}
|
|
188
|
-
var
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
onClick: e,
|
|
198
|
-
"aria-label": t ? "Close chat" : "Open chat",
|
|
199
|
-
style: {
|
|
200
|
-
...r.launcher,
|
|
201
|
-
...l,
|
|
202
|
-
...u != null ? { zIndex: u } : {},
|
|
203
|
-
transform: t ? "scale(0.9)" : "scale(1)"
|
|
204
|
-
},
|
|
205
|
-
children: t ? s ?? /* @__PURE__ */ o(G, {}) : i ?? /* @__PURE__ */ o(q, {})
|
|
206
|
-
});
|
|
207
|
-
}, q = () => /* @__PURE__ */ o("svg", {
|
|
208
|
-
width: "28",
|
|
209
|
-
height: "28",
|
|
266
|
+
var re = ({ size: e = 18, color: t = "currentColor" }) => /* @__PURE__ */ a("svg", {
|
|
267
|
+
width: e,
|
|
268
|
+
height: e,
|
|
269
|
+
viewBox: "0 0 24 24",
|
|
270
|
+
fill: t,
|
|
271
|
+
children: /* @__PURE__ */ a("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" })
|
|
272
|
+
}), ne = ({ size: e = 28, color: t = "currentColor" }) => /* @__PURE__ */ a("svg", {
|
|
273
|
+
width: e,
|
|
274
|
+
height: e,
|
|
210
275
|
viewBox: "0 0 24 24",
|
|
211
276
|
fill: "none",
|
|
212
|
-
stroke:
|
|
277
|
+
stroke: t,
|
|
213
278
|
strokeWidth: "2",
|
|
214
279
|
strokeLinecap: "round",
|
|
215
280
|
strokeLinejoin: "round",
|
|
216
|
-
children: /* @__PURE__ */
|
|
217
|
-
}),
|
|
218
|
-
width:
|
|
219
|
-
height:
|
|
281
|
+
children: /* @__PURE__ */ a("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
|
|
282
|
+
}), P = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ x("svg", {
|
|
283
|
+
width: e,
|
|
284
|
+
height: e,
|
|
220
285
|
viewBox: "0 0 24 24",
|
|
221
286
|
fill: "none",
|
|
222
|
-
stroke:
|
|
287
|
+
stroke: t,
|
|
223
288
|
strokeWidth: "2",
|
|
224
289
|
strokeLinecap: "round",
|
|
225
290
|
strokeLinejoin: "round",
|
|
226
|
-
children: [/* @__PURE__ */
|
|
291
|
+
children: [/* @__PURE__ */ a("line", {
|
|
227
292
|
x1: "18",
|
|
228
293
|
y1: "6",
|
|
229
294
|
x2: "6",
|
|
230
295
|
y2: "18"
|
|
231
|
-
}), /* @__PURE__ */
|
|
296
|
+
}), /* @__PURE__ */ a("line", {
|
|
232
297
|
x1: "6",
|
|
233
298
|
y1: "6",
|
|
234
299
|
x2: "18",
|
|
235
300
|
y2: "18"
|
|
236
301
|
})]
|
|
237
|
-
}),
|
|
238
|
-
|
|
239
|
-
|
|
302
|
+
}), ae = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ a("svg", {
|
|
303
|
+
width: e,
|
|
304
|
+
height: e,
|
|
305
|
+
viewBox: "0 0 24 24",
|
|
306
|
+
fill: "none",
|
|
307
|
+
stroke: t,
|
|
308
|
+
strokeWidth: "2",
|
|
309
|
+
strokeLinecap: "round",
|
|
310
|
+
strokeLinejoin: "round",
|
|
311
|
+
children: /* @__PURE__ */ a("line", {
|
|
312
|
+
x1: "5",
|
|
313
|
+
y1: "12",
|
|
314
|
+
x2: "19",
|
|
315
|
+
y2: "12"
|
|
316
|
+
})
|
|
317
|
+
}), oe = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ x("svg", {
|
|
318
|
+
width: e,
|
|
319
|
+
height: e,
|
|
320
|
+
viewBox: "0 0 24 24",
|
|
321
|
+
fill: "none",
|
|
322
|
+
stroke: t,
|
|
323
|
+
strokeWidth: "2",
|
|
324
|
+
strokeLinecap: "round",
|
|
325
|
+
strokeLinejoin: "round",
|
|
326
|
+
children: [
|
|
327
|
+
/* @__PURE__ */ a("circle", {
|
|
328
|
+
cx: "12",
|
|
329
|
+
cy: "12",
|
|
330
|
+
r: "10"
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ a("path", { d: "M8 14s1.5 2 4 2 4-2 4-2" }),
|
|
333
|
+
/* @__PURE__ */ a("line", {
|
|
334
|
+
x1: "9",
|
|
335
|
+
y1: "9",
|
|
336
|
+
x2: "9.01",
|
|
337
|
+
y2: "9"
|
|
338
|
+
}),
|
|
339
|
+
/* @__PURE__ */ a("line", {
|
|
340
|
+
x1: "15",
|
|
341
|
+
y1: "9",
|
|
342
|
+
x2: "15.01",
|
|
343
|
+
y2: "9"
|
|
344
|
+
})
|
|
345
|
+
]
|
|
346
|
+
}), ie = ({ size: e = 20, color: t = "currentColor" }) => /* @__PURE__ */ a("svg", {
|
|
347
|
+
width: e,
|
|
348
|
+
height: e,
|
|
349
|
+
viewBox: "0 0 24 24",
|
|
350
|
+
fill: "none",
|
|
351
|
+
stroke: t,
|
|
352
|
+
strokeWidth: "2",
|
|
353
|
+
strokeLinecap: "round",
|
|
354
|
+
strokeLinejoin: "round",
|
|
355
|
+
children: /* @__PURE__ */ a("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48" })
|
|
356
|
+
}), G = ({ size: e = 16, color: t = "currentColor" }) => /* @__PURE__ */ x("svg", {
|
|
357
|
+
width: e,
|
|
358
|
+
height: e,
|
|
359
|
+
viewBox: "0 0 24 24",
|
|
360
|
+
fill: "none",
|
|
361
|
+
stroke: t,
|
|
362
|
+
strokeWidth: "2",
|
|
363
|
+
strokeLinecap: "round",
|
|
364
|
+
strokeLinejoin: "round",
|
|
365
|
+
children: [/* @__PURE__ */ a("path", { d: "M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z" }), /* @__PURE__ */ a("polyline", { points: "14 2 14 8 20 8" })]
|
|
366
|
+
}), se = ({ size: e = 16, color: t = "currentColor" }) => /* @__PURE__ */ x("svg", {
|
|
367
|
+
width: e,
|
|
368
|
+
height: e,
|
|
369
|
+
viewBox: "0 0 24 24",
|
|
370
|
+
fill: "none",
|
|
371
|
+
stroke: t,
|
|
372
|
+
strokeWidth: "2",
|
|
373
|
+
strokeLinecap: "round",
|
|
374
|
+
strokeLinejoin: "round",
|
|
375
|
+
children: [
|
|
376
|
+
/* @__PURE__ */ a("rect", {
|
|
377
|
+
x: "3",
|
|
378
|
+
y: "3",
|
|
379
|
+
width: "18",
|
|
380
|
+
height: "18",
|
|
381
|
+
rx: "2",
|
|
382
|
+
ry: "2"
|
|
383
|
+
}),
|
|
384
|
+
/* @__PURE__ */ a("circle", {
|
|
385
|
+
cx: "8.5",
|
|
386
|
+
cy: "8.5",
|
|
387
|
+
r: "1.5"
|
|
388
|
+
}),
|
|
389
|
+
/* @__PURE__ */ a("polyline", { points: "21 15 16 10 5 21" })
|
|
390
|
+
]
|
|
391
|
+
}), le = ({ size: e = 14, color: t = "currentColor" }) => /* @__PURE__ */ x("svg", {
|
|
392
|
+
width: e,
|
|
393
|
+
height: e,
|
|
394
|
+
viewBox: "0 0 24 24",
|
|
395
|
+
fill: "none",
|
|
396
|
+
stroke: t,
|
|
397
|
+
strokeWidth: "2",
|
|
398
|
+
strokeLinecap: "round",
|
|
399
|
+
strokeLinejoin: "round",
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ a("circle", {
|
|
402
|
+
cx: "12",
|
|
403
|
+
cy: "12",
|
|
404
|
+
r: "10"
|
|
405
|
+
}),
|
|
406
|
+
/* @__PURE__ */ a("line", {
|
|
407
|
+
x1: "15",
|
|
408
|
+
y1: "9",
|
|
409
|
+
x2: "9",
|
|
410
|
+
y2: "15"
|
|
411
|
+
}),
|
|
412
|
+
/* @__PURE__ */ a("line", {
|
|
413
|
+
x1: "9",
|
|
414
|
+
y1: "9",
|
|
415
|
+
x2: "15",
|
|
416
|
+
y2: "15"
|
|
417
|
+
})
|
|
418
|
+
]
|
|
419
|
+
}), ce = ({ size: e = 16, color: t = "currentColor" }) => /* @__PURE__ */ x("svg", {
|
|
420
|
+
width: e,
|
|
421
|
+
height: e,
|
|
422
|
+
viewBox: "0 0 24 24",
|
|
423
|
+
fill: "none",
|
|
424
|
+
stroke: t,
|
|
425
|
+
strokeWidth: "2",
|
|
426
|
+
strokeLinecap: "round",
|
|
427
|
+
strokeLinejoin: "round",
|
|
428
|
+
children: [/* @__PURE__ */ a("polyline", { points: "1 4 1 10 7 10" }), /* @__PURE__ */ a("path", { d: "M3.51 15a9 9 0 1 0 2.13-9.36L1 10" })]
|
|
429
|
+
}), de = ({ onClick: e, isOpen: t, position: r, styles: n, icon: o, closeIcon: s, zIndex: i }) => {
|
|
430
|
+
const c = r === "bottom-left" ? {
|
|
431
|
+
bottom: "24px",
|
|
432
|
+
left: "24px"
|
|
433
|
+
} : {
|
|
434
|
+
bottom: "24px",
|
|
435
|
+
right: "24px"
|
|
436
|
+
};
|
|
437
|
+
return /* @__PURE__ */ a("button", {
|
|
438
|
+
onClick: e,
|
|
439
|
+
"aria-label": t ? "Close chat" : "Open chat",
|
|
240
440
|
style: {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
441
|
+
...n.launcher,
|
|
442
|
+
...c,
|
|
443
|
+
...i != null ? { zIndex: i } : {},
|
|
444
|
+
transform: t ? "scale(0.92) rotate(90deg)" : "scale(1)",
|
|
445
|
+
animation: t ? "none" : "cb-launcher-pulse 3s ease-in-out infinite"
|
|
245
446
|
},
|
|
246
|
-
children:
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
447
|
+
children: t ? s ?? /* @__PURE__ */ a(P, { size: 22 }) : o ?? /* @__PURE__ */ a(ne, { size: 26 })
|
|
448
|
+
});
|
|
449
|
+
}, pe = ({ config: e, styles: t, onClose: r, onRestart: n, logo: o, logoWidth: s }) => /* @__PURE__ */ x("div", {
|
|
450
|
+
style: t.header,
|
|
451
|
+
children: [
|
|
452
|
+
/* @__PURE__ */ a("div", { style: {
|
|
453
|
+
position: "absolute",
|
|
454
|
+
top: 0,
|
|
455
|
+
left: 0,
|
|
456
|
+
right: 0,
|
|
457
|
+
bottom: 0,
|
|
458
|
+
background: "linear-gradient(135deg, rgba(255,255,255,0.12) 0%, transparent 50%)",
|
|
459
|
+
pointerEvents: "none"
|
|
460
|
+
} }),
|
|
461
|
+
/* @__PURE__ */ x("div", {
|
|
256
462
|
style: {
|
|
257
|
-
|
|
258
|
-
|
|
463
|
+
display: "flex",
|
|
464
|
+
alignItems: "center",
|
|
465
|
+
gap: "12px",
|
|
466
|
+
flex: 1,
|
|
467
|
+
position: "relative",
|
|
468
|
+
zIndex: 1
|
|
259
469
|
},
|
|
260
|
-
children:
|
|
261
|
-
|
|
470
|
+
children: [
|
|
471
|
+
e.avatar && /* @__PURE__ */ x("div", {
|
|
472
|
+
style: { position: "relative" },
|
|
473
|
+
children: [/* @__PURE__ */ a("img", {
|
|
474
|
+
src: e.avatar,
|
|
475
|
+
alt: "",
|
|
476
|
+
style: {
|
|
477
|
+
width: "40px",
|
|
478
|
+
height: "40px",
|
|
479
|
+
borderRadius: "50%",
|
|
480
|
+
objectFit: "cover",
|
|
481
|
+
border: "2px solid rgba(255,255,255,0.3)"
|
|
482
|
+
}
|
|
483
|
+
}), /* @__PURE__ */ a("span", { style: {
|
|
484
|
+
position: "absolute",
|
|
485
|
+
bottom: "1px",
|
|
486
|
+
right: "1px",
|
|
487
|
+
width: "10px",
|
|
488
|
+
height: "10px",
|
|
489
|
+
backgroundColor: "#2ECC71",
|
|
490
|
+
borderRadius: "50%",
|
|
491
|
+
border: "2px solid rgba(255,255,255,0.8)"
|
|
492
|
+
} })]
|
|
493
|
+
}),
|
|
494
|
+
o && !e.avatar && /* @__PURE__ */ a("img", {
|
|
495
|
+
src: o,
|
|
496
|
+
alt: "",
|
|
497
|
+
style: {
|
|
498
|
+
width: s ?? "36px",
|
|
499
|
+
height: "auto",
|
|
500
|
+
objectFit: "contain",
|
|
501
|
+
filter: "brightness(1.1)"
|
|
502
|
+
}
|
|
503
|
+
}),
|
|
504
|
+
!e.avatar && !o && /* @__PURE__ */ a("div", {
|
|
505
|
+
style: {
|
|
506
|
+
width: "40px",
|
|
507
|
+
height: "40px",
|
|
508
|
+
borderRadius: "50%",
|
|
509
|
+
background: "rgba(255,255,255,0.2)",
|
|
510
|
+
backdropFilter: "blur(4px)",
|
|
511
|
+
display: "flex",
|
|
512
|
+
alignItems: "center",
|
|
513
|
+
justifyContent: "center",
|
|
514
|
+
fontSize: "18px",
|
|
515
|
+
fontWeight: 700,
|
|
516
|
+
color: "rgba(255,255,255,0.9)",
|
|
517
|
+
border: "1px solid rgba(255,255,255,0.2)"
|
|
518
|
+
},
|
|
519
|
+
children: (e.title ?? "C").charAt(0).toUpperCase()
|
|
520
|
+
}),
|
|
521
|
+
/* @__PURE__ */ x("div", { children: [/* @__PURE__ */ a("div", {
|
|
522
|
+
style: {
|
|
523
|
+
fontWeight: 600,
|
|
524
|
+
fontSize: "16px",
|
|
525
|
+
letterSpacing: "-0.01em"
|
|
526
|
+
},
|
|
527
|
+
children: e.title ?? "Chat with us"
|
|
528
|
+
}), e.subtitle && /* @__PURE__ */ x("div", {
|
|
529
|
+
style: {
|
|
530
|
+
fontSize: "12px",
|
|
531
|
+
opacity: 0.8,
|
|
532
|
+
display: "flex",
|
|
533
|
+
alignItems: "center",
|
|
534
|
+
gap: "5px",
|
|
535
|
+
marginTop: "1px"
|
|
536
|
+
},
|
|
537
|
+
children: [/* @__PURE__ */ a("span", { style: {
|
|
538
|
+
width: "6px",
|
|
539
|
+
height: "6px",
|
|
540
|
+
borderRadius: "50%",
|
|
541
|
+
backgroundColor: "#2ECC71",
|
|
542
|
+
display: "inline-block"
|
|
543
|
+
} }), e.subtitle]
|
|
544
|
+
})] })
|
|
545
|
+
]
|
|
546
|
+
}),
|
|
547
|
+
/* @__PURE__ */ x("div", {
|
|
262
548
|
style: {
|
|
263
|
-
|
|
264
|
-
|
|
549
|
+
display: "flex",
|
|
550
|
+
alignItems: "center",
|
|
551
|
+
gap: "2px",
|
|
552
|
+
position: "relative",
|
|
553
|
+
zIndex: 1
|
|
265
554
|
},
|
|
266
|
-
children:
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
555
|
+
children: [
|
|
556
|
+
e.showRestart && n && /* @__PURE__ */ a("button", {
|
|
557
|
+
onClick: n,
|
|
558
|
+
"aria-label": "Restart conversation",
|
|
559
|
+
title: "Restart conversation",
|
|
560
|
+
style: {
|
|
561
|
+
background: "rgba(255,255,255,0.1)",
|
|
562
|
+
border: "none",
|
|
563
|
+
color: "inherit",
|
|
564
|
+
cursor: "pointer",
|
|
565
|
+
padding: "6px",
|
|
566
|
+
display: "flex",
|
|
567
|
+
alignItems: "center",
|
|
568
|
+
borderRadius: "8px",
|
|
569
|
+
transition: "background 0.2s ease"
|
|
570
|
+
},
|
|
571
|
+
onMouseEnter: (i) => i.currentTarget.style.background = "rgba(255,255,255,0.2)",
|
|
572
|
+
onMouseLeave: (i) => i.currentTarget.style.background = "rgba(255,255,255,0.1)",
|
|
573
|
+
children: /* @__PURE__ */ a(ce, { size: 16 })
|
|
574
|
+
}),
|
|
575
|
+
e.showMinimize && /* @__PURE__ */ a("button", {
|
|
576
|
+
onClick: r,
|
|
577
|
+
"aria-label": "Minimize chat",
|
|
578
|
+
style: {
|
|
579
|
+
background: "rgba(255,255,255,0.1)",
|
|
580
|
+
border: "none",
|
|
581
|
+
color: "inherit",
|
|
582
|
+
cursor: "pointer",
|
|
583
|
+
padding: "6px",
|
|
584
|
+
display: "flex",
|
|
585
|
+
alignItems: "center",
|
|
586
|
+
borderRadius: "8px",
|
|
587
|
+
transition: "background 0.2s ease"
|
|
588
|
+
},
|
|
589
|
+
onMouseEnter: (i) => i.currentTarget.style.background = "rgba(255,255,255,0.2)",
|
|
590
|
+
onMouseLeave: (i) => i.currentTarget.style.background = "rgba(255,255,255,0.1)",
|
|
591
|
+
children: /* @__PURE__ */ a(ae, { size: 16 })
|
|
592
|
+
}),
|
|
593
|
+
e.showClose !== !1 && /* @__PURE__ */ a("button", {
|
|
594
|
+
onClick: r,
|
|
595
|
+
"aria-label": "Close chat",
|
|
596
|
+
style: {
|
|
597
|
+
background: "rgba(255,255,255,0.1)",
|
|
598
|
+
border: "none",
|
|
599
|
+
color: "inherit",
|
|
600
|
+
cursor: "pointer",
|
|
601
|
+
padding: "6px",
|
|
602
|
+
display: "flex",
|
|
603
|
+
alignItems: "center",
|
|
604
|
+
borderRadius: "8px",
|
|
605
|
+
transition: "background 0.2s ease"
|
|
606
|
+
},
|
|
607
|
+
onMouseEnter: (i) => i.currentTarget.style.background = "rgba(255,255,255,0.2)",
|
|
608
|
+
onMouseLeave: (i) => i.currentTarget.style.background = "rgba(255,255,255,0.1)",
|
|
609
|
+
children: /* @__PURE__ */ a(P, { size: 18 })
|
|
610
|
+
})
|
|
611
|
+
]
|
|
300
612
|
})
|
|
301
|
-
|
|
302
|
-
}),
|
|
613
|
+
]
|
|
614
|
+
}), ue = ({ content: e, onDismiss: t, primaryColor: r }) => /* @__PURE__ */ x("div", {
|
|
303
615
|
style: {
|
|
304
616
|
flex: 1,
|
|
305
617
|
display: "flex",
|
|
306
618
|
flexDirection: "column",
|
|
307
|
-
overflow: "auto"
|
|
619
|
+
overflow: "auto",
|
|
620
|
+
background: "linear-gradient(180deg, rgba(248, 249, 254, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%)"
|
|
308
621
|
},
|
|
309
|
-
children: [/* @__PURE__ */
|
|
622
|
+
children: [/* @__PURE__ */ a("div", {
|
|
310
623
|
style: {
|
|
311
624
|
flex: 1,
|
|
312
|
-
padding: "
|
|
625
|
+
padding: "28px 24px",
|
|
313
626
|
overflow: "auto"
|
|
314
627
|
},
|
|
315
628
|
children: e
|
|
316
|
-
}), /* @__PURE__ */
|
|
629
|
+
}), /* @__PURE__ */ a("div", {
|
|
317
630
|
style: {
|
|
318
|
-
padding: "
|
|
319
|
-
borderTop: "1px solid
|
|
631
|
+
padding: "16px 20px",
|
|
632
|
+
borderTop: "1px solid rgba(0,0,0,0.05)",
|
|
633
|
+
backdropFilter: "blur(12px)",
|
|
634
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
320
635
|
flexShrink: 0
|
|
321
636
|
},
|
|
322
|
-
children: /* @__PURE__ */
|
|
637
|
+
children: /* @__PURE__ */ a("button", {
|
|
323
638
|
onClick: t,
|
|
324
639
|
style: {
|
|
325
640
|
width: "100%",
|
|
326
|
-
padding: "
|
|
327
|
-
|
|
641
|
+
padding: "14px",
|
|
642
|
+
background: `linear-gradient(135deg, ${r} 0%, ${ge(r, 30)} 100%)`,
|
|
328
643
|
color: "#fff",
|
|
329
644
|
border: "none",
|
|
330
|
-
borderRadius: "
|
|
331
|
-
fontSize: "
|
|
645
|
+
borderRadius: "14px",
|
|
646
|
+
fontSize: "15px",
|
|
332
647
|
fontWeight: 600,
|
|
333
|
-
cursor: "pointer"
|
|
648
|
+
cursor: "pointer",
|
|
649
|
+
fontFamily: "inherit",
|
|
650
|
+
letterSpacing: "0.02em",
|
|
651
|
+
boxShadow: `0 6px 20px ${r}44`,
|
|
652
|
+
transition: "all 0.25s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
653
|
+
},
|
|
654
|
+
onMouseEnter: (n) => {
|
|
655
|
+
n.currentTarget.style.transform = "translateY(-1px)", n.currentTarget.style.boxShadow = `0 8px 28px ${r}55`;
|
|
656
|
+
},
|
|
657
|
+
onMouseLeave: (n) => {
|
|
658
|
+
n.currentTarget.style.transform = "translateY(0)", n.currentTarget.style.boxShadow = `0 6px 20px ${r}44`;
|
|
334
659
|
},
|
|
335
660
|
children: "Start Chat"
|
|
336
661
|
})
|
|
337
662
|
})]
|
|
338
|
-
})
|
|
339
|
-
|
|
663
|
+
});
|
|
664
|
+
function ge(e, t) {
|
|
665
|
+
const r = parseInt(e.replace("#", ""), 16), n = Math.min(255, (r >> 16 & 255) + t), o = Math.min(255, (r >> 8 & 255) + t), s = Math.min(255, (r & 255) + t);
|
|
666
|
+
return `#${(n << 16 | o << 8 | s).toString(16).padStart(6, "0")}`;
|
|
667
|
+
}
|
|
668
|
+
var be = ({ field: e, value: t, onChange: r, error: n }) => {
|
|
669
|
+
const o = e.type === "textarea", s = e.type === "textarea" ? void 0 : e.type, i = {
|
|
340
670
|
width: "100%",
|
|
341
|
-
padding: "
|
|
342
|
-
border: `
|
|
343
|
-
borderRadius: "
|
|
671
|
+
padding: "10px 14px",
|
|
672
|
+
border: `1.5px solid ${n ? "rgba(229, 62, 62, 0.5)" : "rgba(0,0,0,0.08)"}`,
|
|
673
|
+
borderRadius: "12px",
|
|
344
674
|
fontSize: "13px",
|
|
345
675
|
fontFamily: "inherit",
|
|
346
676
|
outline: "none",
|
|
347
677
|
boxSizing: "border-box",
|
|
348
|
-
transition: "
|
|
678
|
+
transition: "all 0.2s ease",
|
|
679
|
+
backgroundColor: "rgba(245, 247, 252, 0.6)",
|
|
680
|
+
color: "#2D3436",
|
|
681
|
+
letterSpacing: "0.01em"
|
|
349
682
|
};
|
|
350
|
-
return /* @__PURE__ */
|
|
351
|
-
style: { marginBottom: "
|
|
683
|
+
return /* @__PURE__ */ x("div", {
|
|
684
|
+
style: { marginBottom: "14px" },
|
|
352
685
|
children: [
|
|
353
|
-
e.label && /* @__PURE__ */
|
|
686
|
+
e.label && /* @__PURE__ */ x("label", {
|
|
354
687
|
style: {
|
|
355
688
|
display: "block",
|
|
356
|
-
marginBottom: "
|
|
689
|
+
marginBottom: "6px",
|
|
357
690
|
fontSize: "13px",
|
|
358
|
-
fontWeight: 500
|
|
691
|
+
fontWeight: 500,
|
|
692
|
+
color: "#2D3436"
|
|
359
693
|
},
|
|
360
|
-
children: [e.label, e.required && /* @__PURE__ */
|
|
694
|
+
children: [e.label, e.required && /* @__PURE__ */ a("span", {
|
|
361
695
|
style: {
|
|
362
696
|
color: "#E53E3E",
|
|
363
|
-
marginLeft: "
|
|
697
|
+
marginLeft: "3px"
|
|
364
698
|
},
|
|
365
699
|
children: "*"
|
|
366
700
|
})]
|
|
367
701
|
}),
|
|
368
|
-
|
|
702
|
+
o ? /* @__PURE__ */ a("textarea", {
|
|
369
703
|
value: t,
|
|
370
|
-
onChange: (
|
|
704
|
+
onChange: (c) => r(c.target.value),
|
|
371
705
|
placeholder: e.placeholder,
|
|
372
706
|
required: e.required,
|
|
373
707
|
rows: 3,
|
|
374
708
|
style: {
|
|
375
|
-
...
|
|
709
|
+
...i,
|
|
376
710
|
resize: "vertical"
|
|
377
711
|
},
|
|
378
712
|
minLength: e.validation?.minLength,
|
|
379
713
|
maxLength: e.validation?.maxLength
|
|
380
|
-
}) : /* @__PURE__ */
|
|
714
|
+
}) : /* @__PURE__ */ a("input", {
|
|
381
715
|
type: s,
|
|
382
716
|
value: t,
|
|
383
|
-
onChange: (
|
|
717
|
+
onChange: (c) => r(c.target.value),
|
|
384
718
|
placeholder: e.placeholder,
|
|
385
719
|
required: e.required,
|
|
386
|
-
style:
|
|
720
|
+
style: i,
|
|
387
721
|
min: e.validation?.min,
|
|
388
722
|
max: e.validation?.max,
|
|
389
723
|
minLength: e.validation?.minLength,
|
|
390
724
|
maxLength: e.validation?.maxLength,
|
|
391
725
|
pattern: e.validation?.pattern
|
|
392
726
|
}),
|
|
393
|
-
|
|
727
|
+
n && /* @__PURE__ */ a("div", {
|
|
394
728
|
style: {
|
|
395
729
|
color: "#E53E3E",
|
|
396
730
|
fontSize: "12px",
|
|
397
731
|
marginTop: "2px"
|
|
398
732
|
},
|
|
399
|
-
children:
|
|
733
|
+
children: n
|
|
400
734
|
})
|
|
401
735
|
]
|
|
402
736
|
});
|
|
403
|
-
},
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
},
|
|
407
|
-
return /* @__PURE__ */
|
|
408
|
-
style: { marginBottom: "
|
|
737
|
+
}, xe = ({ field: e, value: t, onChange: r, error: n }) => {
|
|
738
|
+
const o = e.type === "multiselect" || e.multiple, s = (c) => {
|
|
739
|
+
r(o ? Array.from(c.target.selectedOptions, (u) => u.value) : c.target.value);
|
|
740
|
+
}, i = o ? Array.isArray(t) ? t : [t].filter(Boolean) : typeof t == "string" ? t : "";
|
|
741
|
+
return /* @__PURE__ */ x("div", {
|
|
742
|
+
style: { marginBottom: "14px" },
|
|
409
743
|
children: [
|
|
410
|
-
e.label && /* @__PURE__ */
|
|
744
|
+
e.label && /* @__PURE__ */ x("label", {
|
|
411
745
|
style: {
|
|
412
746
|
display: "block",
|
|
413
|
-
marginBottom: "
|
|
747
|
+
marginBottom: "6px",
|
|
414
748
|
fontSize: "13px",
|
|
415
|
-
fontWeight: 500
|
|
749
|
+
fontWeight: 500,
|
|
750
|
+
color: "#2D3436"
|
|
416
751
|
},
|
|
417
|
-
children: [e.label, e.required && /* @__PURE__ */
|
|
752
|
+
children: [e.label, e.required && /* @__PURE__ */ a("span", {
|
|
418
753
|
style: {
|
|
419
754
|
color: "#E53E3E",
|
|
420
|
-
marginLeft: "
|
|
755
|
+
marginLeft: "3px"
|
|
421
756
|
},
|
|
422
757
|
children: "*"
|
|
423
758
|
})]
|
|
424
759
|
}),
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
-
value:
|
|
760
|
+
/* @__PURE__ */ x("select", {
|
|
761
|
+
value: i,
|
|
427
762
|
onChange: s,
|
|
428
|
-
multiple:
|
|
763
|
+
multiple: o,
|
|
429
764
|
required: e.required,
|
|
430
765
|
style: {
|
|
431
766
|
width: "100%",
|
|
432
|
-
padding: "
|
|
433
|
-
border: `
|
|
434
|
-
borderRadius: "
|
|
767
|
+
padding: "10px 14px",
|
|
768
|
+
border: `1.5px solid ${n ? "rgba(229, 62, 62, 0.5)" : "rgba(0,0,0,0.08)"}`,
|
|
769
|
+
borderRadius: "12px",
|
|
435
770
|
fontSize: "13px",
|
|
436
771
|
fontFamily: "inherit",
|
|
437
772
|
outline: "none",
|
|
438
|
-
backgroundColor: "
|
|
773
|
+
backgroundColor: "rgba(245, 247, 252, 0.6)",
|
|
774
|
+
color: "#2D3436",
|
|
439
775
|
boxSizing: "border-box",
|
|
440
|
-
|
|
776
|
+
transition: "all 0.2s ease",
|
|
777
|
+
...o ? { minHeight: "80px" } : {}
|
|
441
778
|
},
|
|
442
|
-
children: [!
|
|
779
|
+
children: [!o && /* @__PURE__ */ a("option", {
|
|
443
780
|
value: "",
|
|
444
781
|
children: "Select..."
|
|
445
|
-
}), e.options?.map((
|
|
446
|
-
value:
|
|
447
|
-
children:
|
|
448
|
-
},
|
|
782
|
+
}), e.options?.map((c) => /* @__PURE__ */ a("option", {
|
|
783
|
+
value: c.value,
|
|
784
|
+
children: c.label
|
|
785
|
+
}, c.value))]
|
|
449
786
|
}),
|
|
450
|
-
|
|
787
|
+
o && /* @__PURE__ */ a("div", {
|
|
451
788
|
style: {
|
|
452
789
|
fontSize: "11px",
|
|
453
790
|
color: "#888",
|
|
@@ -455,27 +792,27 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
455
792
|
},
|
|
456
793
|
children: "Hold Ctrl/Cmd to select multiple"
|
|
457
794
|
}),
|
|
458
|
-
|
|
795
|
+
n && /* @__PURE__ */ a("div", {
|
|
459
796
|
style: {
|
|
460
797
|
color: "#E53E3E",
|
|
461
798
|
fontSize: "12px",
|
|
462
799
|
marginTop: "2px"
|
|
463
800
|
},
|
|
464
|
-
children:
|
|
801
|
+
children: n
|
|
465
802
|
})
|
|
466
803
|
]
|
|
467
804
|
});
|
|
468
|
-
},
|
|
805
|
+
}, he = ({ field: e, value: t, onChange: r, error: n }) => /* @__PURE__ */ x("div", {
|
|
469
806
|
style: { marginBottom: "12px" },
|
|
470
807
|
children: [
|
|
471
|
-
e.label && /* @__PURE__ */
|
|
808
|
+
e.label && /* @__PURE__ */ x("label", {
|
|
472
809
|
style: {
|
|
473
810
|
display: "block",
|
|
474
811
|
marginBottom: "6px",
|
|
475
812
|
fontSize: "13px",
|
|
476
813
|
fontWeight: 500
|
|
477
814
|
},
|
|
478
|
-
children: [e.label, e.required && /* @__PURE__ */
|
|
815
|
+
children: [e.label, e.required && /* @__PURE__ */ a("span", {
|
|
479
816
|
style: {
|
|
480
817
|
color: "#E53E3E",
|
|
481
818
|
marginLeft: "2px"
|
|
@@ -483,13 +820,13 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
483
820
|
children: "*"
|
|
484
821
|
})]
|
|
485
822
|
}),
|
|
486
|
-
/* @__PURE__ */
|
|
823
|
+
/* @__PURE__ */ a("div", {
|
|
487
824
|
style: {
|
|
488
825
|
display: "flex",
|
|
489
826
|
flexDirection: "column",
|
|
490
827
|
gap: "6px"
|
|
491
828
|
},
|
|
492
|
-
children: e.options?.map((
|
|
829
|
+
children: e.options?.map((o) => /* @__PURE__ */ x("label", {
|
|
493
830
|
style: {
|
|
494
831
|
display: "flex",
|
|
495
832
|
alignItems: "center",
|
|
@@ -497,40 +834,40 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
497
834
|
cursor: "pointer",
|
|
498
835
|
fontSize: "13px"
|
|
499
836
|
},
|
|
500
|
-
children: [/* @__PURE__ */
|
|
837
|
+
children: [/* @__PURE__ */ a("input", {
|
|
501
838
|
type: "radio",
|
|
502
839
|
name: e.name,
|
|
503
|
-
value:
|
|
504
|
-
checked: t ===
|
|
505
|
-
onChange: () =>
|
|
840
|
+
value: o.value,
|
|
841
|
+
checked: t === o.value,
|
|
842
|
+
onChange: () => r(o.value),
|
|
506
843
|
style: { margin: 0 }
|
|
507
|
-
}),
|
|
508
|
-
},
|
|
844
|
+
}), o.label]
|
|
845
|
+
}, o.value))
|
|
509
846
|
}),
|
|
510
|
-
|
|
847
|
+
n && /* @__PURE__ */ a("div", {
|
|
511
848
|
style: {
|
|
512
849
|
color: "#E53E3E",
|
|
513
850
|
fontSize: "12px",
|
|
514
851
|
marginTop: "2px"
|
|
515
852
|
},
|
|
516
|
-
children:
|
|
853
|
+
children: n
|
|
517
854
|
})
|
|
518
855
|
]
|
|
519
|
-
}),
|
|
520
|
-
const
|
|
521
|
-
t.includes(s) ?
|
|
856
|
+
}), me = ({ field: e, value: t, onChange: r, error: n }) => {
|
|
857
|
+
const o = (s) => {
|
|
858
|
+
t.includes(s) ? r(t.filter((i) => i !== s)) : r([...t, s]);
|
|
522
859
|
};
|
|
523
|
-
return /* @__PURE__ */
|
|
860
|
+
return /* @__PURE__ */ x("div", {
|
|
524
861
|
style: { marginBottom: "12px" },
|
|
525
862
|
children: [
|
|
526
|
-
e.label && /* @__PURE__ */
|
|
863
|
+
e.label && /* @__PURE__ */ x("label", {
|
|
527
864
|
style: {
|
|
528
865
|
display: "block",
|
|
529
866
|
marginBottom: "6px",
|
|
530
867
|
fontSize: "13px",
|
|
531
868
|
fontWeight: 500
|
|
532
869
|
},
|
|
533
|
-
children: [e.label, e.required && /* @__PURE__ */
|
|
870
|
+
children: [e.label, e.required && /* @__PURE__ */ a("span", {
|
|
534
871
|
style: {
|
|
535
872
|
color: "#E53E3E",
|
|
536
873
|
marginLeft: "2px"
|
|
@@ -538,13 +875,13 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
538
875
|
children: "*"
|
|
539
876
|
})]
|
|
540
877
|
}),
|
|
541
|
-
/* @__PURE__ */
|
|
878
|
+
/* @__PURE__ */ a("div", {
|
|
542
879
|
style: {
|
|
543
880
|
display: "flex",
|
|
544
881
|
flexDirection: "column",
|
|
545
882
|
gap: "6px"
|
|
546
883
|
},
|
|
547
|
-
children: e.options?.map((s) => /* @__PURE__ */
|
|
884
|
+
children: e.options?.map((s) => /* @__PURE__ */ x("label", {
|
|
548
885
|
style: {
|
|
549
886
|
display: "flex",
|
|
550
887
|
alignItems: "center",
|
|
@@ -552,37 +889,37 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
552
889
|
cursor: "pointer",
|
|
553
890
|
fontSize: "13px"
|
|
554
891
|
},
|
|
555
|
-
children: [/* @__PURE__ */
|
|
892
|
+
children: [/* @__PURE__ */ a("input", {
|
|
556
893
|
type: "checkbox",
|
|
557
894
|
checked: t.includes(s.value),
|
|
558
|
-
onChange: () =>
|
|
895
|
+
onChange: () => o(s.value),
|
|
559
896
|
style: { margin: 0 }
|
|
560
897
|
}), s.label]
|
|
561
898
|
}, s.value))
|
|
562
899
|
}),
|
|
563
|
-
|
|
900
|
+
n && /* @__PURE__ */ a("div", {
|
|
564
901
|
style: {
|
|
565
902
|
color: "#E53E3E",
|
|
566
903
|
fontSize: "12px",
|
|
567
904
|
marginTop: "2px"
|
|
568
905
|
},
|
|
569
|
-
children:
|
|
906
|
+
children: n
|
|
570
907
|
})
|
|
571
908
|
]
|
|
572
909
|
});
|
|
573
|
-
},
|
|
574
|
-
const s =
|
|
575
|
-
return /* @__PURE__ */
|
|
910
|
+
}, ye = ({ field: e, value: t, onChange: r, error: n, primaryColor: o }) => {
|
|
911
|
+
const s = C(null), i = t ? Array.from(t).map((c) => c.name).join(", ") : "";
|
|
912
|
+
return /* @__PURE__ */ x("div", {
|
|
576
913
|
style: { marginBottom: "12px" },
|
|
577
914
|
children: [
|
|
578
|
-
e.label && /* @__PURE__ */
|
|
915
|
+
e.label && /* @__PURE__ */ x("label", {
|
|
579
916
|
style: {
|
|
580
917
|
display: "block",
|
|
581
918
|
marginBottom: "4px",
|
|
582
919
|
fontSize: "13px",
|
|
583
920
|
fontWeight: 500
|
|
584
921
|
},
|
|
585
|
-
children: [e.label, e.required && /* @__PURE__ */
|
|
922
|
+
children: [e.label, e.required && /* @__PURE__ */ a("span", {
|
|
586
923
|
style: {
|
|
587
924
|
color: "#E53E3E",
|
|
588
925
|
marginLeft: "2px"
|
|
@@ -590,20 +927,20 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
590
927
|
children: "*"
|
|
591
928
|
})]
|
|
592
929
|
}),
|
|
593
|
-
/* @__PURE__ */
|
|
930
|
+
/* @__PURE__ */ a("input", {
|
|
594
931
|
ref: s,
|
|
595
932
|
type: "file",
|
|
596
933
|
accept: e.accept,
|
|
597
934
|
multiple: e.multiple,
|
|
598
|
-
onChange: (
|
|
935
|
+
onChange: (c) => r(c.target.files),
|
|
599
936
|
style: { display: "none" }
|
|
600
937
|
}),
|
|
601
|
-
/* @__PURE__ */
|
|
938
|
+
/* @__PURE__ */ a("button", {
|
|
602
939
|
type: "button",
|
|
603
940
|
onClick: () => s.current?.click(),
|
|
604
941
|
style: {
|
|
605
942
|
padding: "8px 16px",
|
|
606
|
-
border: `1px dashed ${
|
|
943
|
+
border: `1px dashed ${n ? "#E53E3E" : "#D1D5DB"}`,
|
|
607
944
|
borderRadius: "8px",
|
|
608
945
|
backgroundColor: "#FAFAFA",
|
|
609
946
|
cursor: "pointer",
|
|
@@ -612,114 +949,137 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
612
949
|
width: "100%",
|
|
613
950
|
textAlign: "left"
|
|
614
951
|
},
|
|
615
|
-
children:
|
|
952
|
+
children: i || e.placeholder || "Choose file(s)..."
|
|
616
953
|
}),
|
|
617
|
-
|
|
954
|
+
i && /* @__PURE__ */ x("div", {
|
|
618
955
|
style: {
|
|
619
956
|
fontSize: "12px",
|
|
620
|
-
color:
|
|
957
|
+
color: o,
|
|
621
958
|
marginTop: "4px"
|
|
622
959
|
},
|
|
623
960
|
children: [Array.from(t).length, " file(s) selected"]
|
|
624
961
|
}),
|
|
625
|
-
|
|
962
|
+
n && /* @__PURE__ */ a("div", {
|
|
626
963
|
style: {
|
|
627
964
|
color: "#E53E3E",
|
|
628
965
|
fontSize: "12px",
|
|
629
966
|
marginTop: "2px"
|
|
630
967
|
},
|
|
631
|
-
children:
|
|
968
|
+
children: n
|
|
632
969
|
})
|
|
633
970
|
]
|
|
634
971
|
});
|
|
635
|
-
},
|
|
636
|
-
const [
|
|
637
|
-
const
|
|
638
|
-
for (const
|
|
639
|
-
return
|
|
640
|
-
}), [s,
|
|
641
|
-
|
|
642
|
-
...
|
|
643
|
-
[
|
|
644
|
-
})),
|
|
645
|
-
const
|
|
646
|
-
return delete
|
|
972
|
+
}, H = ({ config: e, onSubmit: t, primaryColor: r }) => {
|
|
973
|
+
const [n, o] = I(() => {
|
|
974
|
+
const g = {};
|
|
975
|
+
for (const h of e.fields) h.defaultValue !== void 0 ? g[h.name] = h.defaultValue : h.type === "checkbox" || h.type === "multiselect" ? g[h.name] = [] : h.type === "file" ? g[h.name] = null : g[h.name] = "";
|
|
976
|
+
return g;
|
|
977
|
+
}), [s, i] = I({}), [c, u] = I(!1), f = v((g, h) => {
|
|
978
|
+
o((k) => ({
|
|
979
|
+
...k,
|
|
980
|
+
[g]: h
|
|
981
|
+
})), i((k) => {
|
|
982
|
+
const D = { ...k };
|
|
983
|
+
return delete D[g], D;
|
|
647
984
|
});
|
|
648
|
-
}, []),
|
|
649
|
-
const
|
|
650
|
-
for (const
|
|
651
|
-
const
|
|
652
|
-
if (
|
|
653
|
-
|
|
985
|
+
}, []), w = () => {
|
|
986
|
+
const g = {};
|
|
987
|
+
for (const h of e.fields) {
|
|
988
|
+
const k = n[h.name];
|
|
989
|
+
if (h.required && (k === "" || k === null || k === void 0 || Array.isArray(k) && k.length === 0)) {
|
|
990
|
+
g[h.name] = h.validation?.message ?? `${h.label || h.name} is required`;
|
|
654
991
|
continue;
|
|
655
992
|
}
|
|
656
|
-
|
|
993
|
+
if (h.validation?.pattern && typeof k == "string" && k) try {
|
|
994
|
+
new RegExp(h.validation.pattern).test(k) || (g[h.name] = h.validation.message ?? "Invalid format");
|
|
995
|
+
} catch {
|
|
996
|
+
}
|
|
657
997
|
}
|
|
658
|
-
return
|
|
659
|
-
},
|
|
660
|
-
|
|
998
|
+
return i(g), Object.keys(g).length === 0;
|
|
999
|
+
}, p = (g) => {
|
|
1000
|
+
g.preventDefault(), w() && (u(!0), t(n));
|
|
661
1001
|
};
|
|
662
|
-
return
|
|
1002
|
+
return c ? /* @__PURE__ */ a("div", {
|
|
663
1003
|
style: {
|
|
664
|
-
padding: "
|
|
665
|
-
|
|
666
|
-
borderRadius: "
|
|
667
|
-
fontSize: "
|
|
668
|
-
color: "#
|
|
669
|
-
textAlign: "center"
|
|
1004
|
+
padding: "16px",
|
|
1005
|
+
background: "linear-gradient(135deg, rgba(46, 213, 115, 0.1), rgba(46, 213, 115, 0.05))",
|
|
1006
|
+
borderRadius: "14px",
|
|
1007
|
+
fontSize: "14px",
|
|
1008
|
+
color: "#2ecc71",
|
|
1009
|
+
textAlign: "center",
|
|
1010
|
+
fontWeight: 500,
|
|
1011
|
+
border: "1px solid rgba(46, 213, 115, 0.15)",
|
|
1012
|
+
animation: "cb-fade-in 0.3s ease-out"
|
|
670
1013
|
},
|
|
671
|
-
children: "Submitted successfully"
|
|
672
|
-
}) : /* @__PURE__ */
|
|
673
|
-
onSubmit:
|
|
1014
|
+
children: "✓ Submitted successfully"
|
|
1015
|
+
}) : /* @__PURE__ */ x("form", {
|
|
1016
|
+
onSubmit: p,
|
|
674
1017
|
style: {
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
1018
|
+
background: "rgba(255, 255, 255, 0.7)",
|
|
1019
|
+
backdropFilter: "blur(12px)",
|
|
1020
|
+
WebkitBackdropFilter: "blur(12px)",
|
|
1021
|
+
borderRadius: "16px",
|
|
1022
|
+
padding: "20px",
|
|
1023
|
+
border: "1px solid rgba(0,0,0,0.06)",
|
|
1024
|
+
boxShadow: "0 4px 16px rgba(0,0,0,0.04)",
|
|
1025
|
+
animation: "cb-slide-up 0.35s ease-out"
|
|
679
1026
|
},
|
|
680
1027
|
children: [
|
|
681
|
-
e.title && /* @__PURE__ */
|
|
1028
|
+
e.title && /* @__PURE__ */ a("div", {
|
|
682
1029
|
style: {
|
|
683
1030
|
fontWeight: 600,
|
|
684
|
-
fontSize: "
|
|
685
|
-
marginBottom: "4px"
|
|
1031
|
+
fontSize: "15px",
|
|
1032
|
+
marginBottom: "4px",
|
|
1033
|
+
color: "#2D3436",
|
|
1034
|
+
letterSpacing: "-0.01em"
|
|
686
1035
|
},
|
|
687
1036
|
children: e.title
|
|
688
1037
|
}),
|
|
689
|
-
e.description && /* @__PURE__ */
|
|
1038
|
+
e.description && /* @__PURE__ */ a("div", {
|
|
690
1039
|
style: {
|
|
691
1040
|
fontSize: "12px",
|
|
692
|
-
color: "
|
|
693
|
-
marginBottom: "
|
|
1041
|
+
color: "rgba(0,0,0,0.45)",
|
|
1042
|
+
marginBottom: "16px",
|
|
1043
|
+
lineHeight: "1.5"
|
|
694
1044
|
},
|
|
695
1045
|
children: e.description
|
|
696
1046
|
}),
|
|
697
|
-
e.fields.map((
|
|
698
|
-
field:
|
|
699
|
-
value:
|
|
700
|
-
onChange: (
|
|
701
|
-
error: s[
|
|
702
|
-
primaryColor:
|
|
703
|
-
},
|
|
704
|
-
/* @__PURE__ */
|
|
1047
|
+
e.fields.map((g) => /* @__PURE__ */ a(fe, {
|
|
1048
|
+
field: g,
|
|
1049
|
+
value: n[g.name],
|
|
1050
|
+
onChange: (h) => f(g.name, h),
|
|
1051
|
+
error: s[g.name],
|
|
1052
|
+
primaryColor: r
|
|
1053
|
+
}, g.name)),
|
|
1054
|
+
/* @__PURE__ */ a("button", {
|
|
705
1055
|
type: "submit",
|
|
706
1056
|
style: {
|
|
707
1057
|
width: "100%",
|
|
708
|
-
padding: "
|
|
709
|
-
|
|
1058
|
+
padding: "12px",
|
|
1059
|
+
background: `linear-gradient(135deg, ${r} 0%, ${Se(r, 30)} 100%)`,
|
|
710
1060
|
color: "#fff",
|
|
711
1061
|
border: "none",
|
|
712
|
-
borderRadius: "
|
|
1062
|
+
borderRadius: "12px",
|
|
713
1063
|
fontSize: "14px",
|
|
714
1064
|
fontWeight: 600,
|
|
715
1065
|
cursor: "pointer",
|
|
716
|
-
marginTop: "
|
|
1066
|
+
marginTop: "8px",
|
|
1067
|
+
fontFamily: "inherit",
|
|
1068
|
+
letterSpacing: "0.02em",
|
|
1069
|
+
boxShadow: `0 4px 14px ${r}33`,
|
|
1070
|
+
transition: "all 0.25s cubic-bezier(0.4, 0, 0.2, 1)"
|
|
1071
|
+
},
|
|
1072
|
+
onMouseEnter: (g) => {
|
|
1073
|
+
g.currentTarget.style.transform = "translateY(-1px)", g.currentTarget.style.boxShadow = `0 6px 20px ${r}44`;
|
|
1074
|
+
},
|
|
1075
|
+
onMouseLeave: (g) => {
|
|
1076
|
+
g.currentTarget.style.transform = "translateY(0)", g.currentTarget.style.boxShadow = `0 4px 14px ${r}33`;
|
|
717
1077
|
},
|
|
718
1078
|
children: e.submitLabel ?? "Submit"
|
|
719
1079
|
})
|
|
720
1080
|
]
|
|
721
1081
|
});
|
|
722
|
-
},
|
|
1082
|
+
}, fe = ({ field: e, value: t, onChange: r, error: n, primaryColor: o }) => {
|
|
723
1083
|
switch (e.type) {
|
|
724
1084
|
case "text":
|
|
725
1085
|
case "email":
|
|
@@ -730,44 +1090,44 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
730
1090
|
case "textarea":
|
|
731
1091
|
case "date":
|
|
732
1092
|
case "time":
|
|
733
|
-
return /* @__PURE__ */
|
|
1093
|
+
return /* @__PURE__ */ a(be, {
|
|
734
1094
|
field: e,
|
|
735
1095
|
value: String(t ?? ""),
|
|
736
|
-
onChange:
|
|
737
|
-
error:
|
|
1096
|
+
onChange: r,
|
|
1097
|
+
error: n
|
|
738
1098
|
});
|
|
739
1099
|
case "select":
|
|
740
1100
|
case "multiselect":
|
|
741
|
-
return /* @__PURE__ */
|
|
1101
|
+
return /* @__PURE__ */ a(xe, {
|
|
742
1102
|
field: e,
|
|
743
1103
|
value: t,
|
|
744
|
-
onChange:
|
|
745
|
-
error:
|
|
1104
|
+
onChange: r,
|
|
1105
|
+
error: n
|
|
746
1106
|
});
|
|
747
1107
|
case "radio":
|
|
748
|
-
return /* @__PURE__ */
|
|
1108
|
+
return /* @__PURE__ */ a(he, {
|
|
749
1109
|
field: e,
|
|
750
1110
|
value: String(t ?? ""),
|
|
751
|
-
onChange:
|
|
752
|
-
error:
|
|
1111
|
+
onChange: r,
|
|
1112
|
+
error: n
|
|
753
1113
|
});
|
|
754
1114
|
case "checkbox":
|
|
755
|
-
return /* @__PURE__ */
|
|
1115
|
+
return /* @__PURE__ */ a(me, {
|
|
756
1116
|
field: e,
|
|
757
1117
|
value: t ?? [],
|
|
758
|
-
onChange:
|
|
759
|
-
error:
|
|
1118
|
+
onChange: r,
|
|
1119
|
+
error: n
|
|
760
1120
|
});
|
|
761
1121
|
case "file":
|
|
762
|
-
return /* @__PURE__ */
|
|
1122
|
+
return /* @__PURE__ */ a(ye, {
|
|
763
1123
|
field: e,
|
|
764
1124
|
value: t,
|
|
765
|
-
onChange:
|
|
766
|
-
error:
|
|
767
|
-
primaryColor:
|
|
1125
|
+
onChange: r,
|
|
1126
|
+
error: n,
|
|
1127
|
+
primaryColor: o
|
|
768
1128
|
});
|
|
769
1129
|
case "hidden":
|
|
770
|
-
return /* @__PURE__ */
|
|
1130
|
+
return /* @__PURE__ */ a("input", {
|
|
771
1131
|
type: "hidden",
|
|
772
1132
|
name: e.name,
|
|
773
1133
|
value: String(t ?? "")
|
|
@@ -775,205 +1135,759 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
775
1135
|
default:
|
|
776
1136
|
return null;
|
|
777
1137
|
}
|
|
778
|
-
}
|
|
1138
|
+
};
|
|
1139
|
+
function Se(e, t) {
|
|
1140
|
+
const r = parseInt(e.replace("#", ""), 16), n = Math.min(255, (r >> 16 & 255) + t), o = Math.min(255, (r >> 8 & 255) + t), s = Math.min(255, (r & 255) + t);
|
|
1141
|
+
return `#${(n << 16 | o << 8 | s).toString(16).padStart(6, "0")}`;
|
|
1142
|
+
}
|
|
1143
|
+
var ke = ({ config: e, onLogin: t, primaryColor: r }) => /* @__PURE__ */ a("div", {
|
|
779
1144
|
style: {
|
|
780
1145
|
flex: 1,
|
|
781
1146
|
display: "flex",
|
|
782
1147
|
flexDirection: "column",
|
|
783
1148
|
justifyContent: "center",
|
|
784
|
-
padding: "
|
|
785
|
-
overflow: "auto"
|
|
1149
|
+
padding: "24px",
|
|
1150
|
+
overflow: "auto",
|
|
1151
|
+
background: "linear-gradient(180deg, rgba(248, 249, 254, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%)"
|
|
786
1152
|
},
|
|
787
|
-
children: /* @__PURE__ */
|
|
1153
|
+
children: /* @__PURE__ */ a(H, {
|
|
788
1154
|
config: e,
|
|
789
1155
|
onSubmit: t,
|
|
790
|
-
primaryColor:
|
|
1156
|
+
primaryColor: r
|
|
791
1157
|
})
|
|
792
|
-
}),
|
|
793
|
-
const
|
|
794
|
-
return
|
|
795
|
-
style:
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
1158
|
+
}), we = ({ message: e, styles: t }) => {
|
|
1159
|
+
const r = e.sender === "bot", n = e.sender === "system", o = r || n ? t.botBubble : t.userBubble;
|
|
1160
|
+
return e.text || e.attachments && e.attachments.length > 0 ? /* @__PURE__ */ x("div", {
|
|
1161
|
+
style: {
|
|
1162
|
+
...o,
|
|
1163
|
+
...n ? {
|
|
1164
|
+
background: "transparent",
|
|
1165
|
+
border: "none",
|
|
1166
|
+
boxShadow: "none",
|
|
1167
|
+
color: "#999",
|
|
1168
|
+
fontSize: "12px",
|
|
1169
|
+
alignSelf: "center",
|
|
1170
|
+
padding: "6px 12px",
|
|
1171
|
+
backdropFilter: "none",
|
|
1172
|
+
WebkitBackdropFilter: "none"
|
|
1173
|
+
} : {},
|
|
1174
|
+
animation: "cb-fade-in 0.3s ease-out"
|
|
1175
|
+
},
|
|
1176
|
+
children: [e.text && /* @__PURE__ */ a("span", {
|
|
1177
|
+
style: { display: "block" },
|
|
1178
|
+
children: e.text
|
|
1179
|
+
}), e.attachments && e.attachments.length > 0 && /* @__PURE__ */ a("div", {
|
|
1180
|
+
style: {
|
|
1181
|
+
marginTop: e.text ? "10px" : 0,
|
|
1182
|
+
display: "flex",
|
|
1183
|
+
flexDirection: "column",
|
|
1184
|
+
gap: "6px"
|
|
1185
|
+
},
|
|
1186
|
+
children: e.attachments.map((i, c) => /* @__PURE__ */ a(ve, {
|
|
1187
|
+
attachment: i,
|
|
1188
|
+
isBot: r
|
|
1189
|
+
}, c))
|
|
809
1190
|
})]
|
|
810
|
-
});
|
|
811
|
-
},
|
|
1191
|
+
}) : null;
|
|
1192
|
+
}, ve = ({ attachment: e, isBot: t }) => e.type.startsWith("image/") && e.url ? /* @__PURE__ */ x("div", {
|
|
1193
|
+
style: {
|
|
1194
|
+
borderRadius: "12px",
|
|
1195
|
+
overflow: "hidden",
|
|
1196
|
+
maxWidth: "220px"
|
|
1197
|
+
},
|
|
1198
|
+
children: [/* @__PURE__ */ a("img", {
|
|
1199
|
+
src: e.url,
|
|
1200
|
+
alt: e.name,
|
|
1201
|
+
style: {
|
|
1202
|
+
width: "100%",
|
|
1203
|
+
height: "auto",
|
|
1204
|
+
display: "block",
|
|
1205
|
+
borderRadius: "12px"
|
|
1206
|
+
}
|
|
1207
|
+
}), /* @__PURE__ */ a("div", {
|
|
1208
|
+
style: {
|
|
1209
|
+
fontSize: "11px",
|
|
1210
|
+
padding: "4px 0",
|
|
1211
|
+
opacity: 0.6
|
|
1212
|
+
},
|
|
1213
|
+
children: e.name
|
|
1214
|
+
})]
|
|
1215
|
+
}) : /* @__PURE__ */ x("a", {
|
|
1216
|
+
href: e.url,
|
|
1217
|
+
target: "_blank",
|
|
1218
|
+
rel: "noopener noreferrer",
|
|
1219
|
+
style: {
|
|
1220
|
+
display: "flex",
|
|
1221
|
+
alignItems: "center",
|
|
1222
|
+
gap: "8px",
|
|
1223
|
+
padding: "8px 12px",
|
|
1224
|
+
backgroundColor: t ? "rgba(0,0,0,0.04)" : "rgba(255,255,255,0.15)",
|
|
1225
|
+
borderRadius: "10px",
|
|
1226
|
+
textDecoration: "none",
|
|
1227
|
+
color: "inherit",
|
|
1228
|
+
fontSize: "13px",
|
|
1229
|
+
border: t ? "1px solid rgba(0,0,0,0.06)" : "1px solid rgba(255,255,255,0.15)",
|
|
1230
|
+
transition: "background 0.2s ease"
|
|
1231
|
+
},
|
|
1232
|
+
children: [
|
|
1233
|
+
/* @__PURE__ */ a(G, { size: 16 }),
|
|
1234
|
+
/* @__PURE__ */ a("span", {
|
|
1235
|
+
style: {
|
|
1236
|
+
overflow: "hidden",
|
|
1237
|
+
textOverflow: "ellipsis",
|
|
1238
|
+
whiteSpace: "nowrap",
|
|
1239
|
+
flex: 1
|
|
1240
|
+
},
|
|
1241
|
+
children: e.name
|
|
1242
|
+
}),
|
|
1243
|
+
e.size && /* @__PURE__ */ a("span", {
|
|
1244
|
+
style: {
|
|
1245
|
+
fontSize: "11px",
|
|
1246
|
+
opacity: 0.5,
|
|
1247
|
+
flexShrink: 0
|
|
1248
|
+
},
|
|
1249
|
+
children: Ee(e.size)
|
|
1250
|
+
})
|
|
1251
|
+
]
|
|
1252
|
+
});
|
|
1253
|
+
function Ee(e) {
|
|
1254
|
+
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
1255
|
+
}
|
|
1256
|
+
var Ce = ({ replies: e, onSelect: t, primaryColor: r }) => /* @__PURE__ */ a("div", {
|
|
812
1257
|
style: {
|
|
813
1258
|
display: "flex",
|
|
814
1259
|
flexWrap: "wrap",
|
|
815
|
-
gap: "
|
|
1260
|
+
gap: "8px",
|
|
816
1261
|
alignSelf: "flex-start",
|
|
817
|
-
maxWidth: "90%"
|
|
1262
|
+
maxWidth: "90%",
|
|
1263
|
+
animation: "cb-slide-up 0.35s ease-out",
|
|
1264
|
+
padding: "4px 0"
|
|
818
1265
|
},
|
|
819
|
-
children: e.map((
|
|
820
|
-
onClick: () => t(
|
|
1266
|
+
children: e.map((n) => /* @__PURE__ */ a("button", {
|
|
1267
|
+
onClick: () => t(n.value, n.label),
|
|
821
1268
|
style: {
|
|
822
|
-
padding: "
|
|
823
|
-
borderRadius: "
|
|
824
|
-
border: `
|
|
825
|
-
backgroundColor: "
|
|
826
|
-
color:
|
|
1269
|
+
padding: "8px 18px",
|
|
1270
|
+
borderRadius: "22px",
|
|
1271
|
+
border: `1.5px solid ${r}`,
|
|
1272
|
+
backgroundColor: "rgba(108, 92, 231, 0.06)",
|
|
1273
|
+
color: r,
|
|
827
1274
|
cursor: "pointer",
|
|
828
1275
|
fontSize: "13px",
|
|
829
1276
|
fontWeight: 500,
|
|
830
|
-
|
|
1277
|
+
fontFamily: "inherit",
|
|
1278
|
+
transition: "all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
1279
|
+
backdropFilter: "blur(4px)",
|
|
1280
|
+
WebkitBackdropFilter: "blur(4px)",
|
|
1281
|
+
letterSpacing: "0.01em"
|
|
831
1282
|
},
|
|
832
|
-
onMouseEnter: (
|
|
833
|
-
|
|
1283
|
+
onMouseEnter: (o) => {
|
|
1284
|
+
o.currentTarget.style.backgroundColor = r, o.currentTarget.style.color = "#fff", o.currentTarget.style.transform = "translateY(-1px)", o.currentTarget.style.boxShadow = `0 4px 14px ${r}44`;
|
|
834
1285
|
},
|
|
835
|
-
onMouseLeave: (
|
|
836
|
-
|
|
1286
|
+
onMouseLeave: (o) => {
|
|
1287
|
+
o.currentTarget.style.backgroundColor = "rgba(108, 92, 231, 0.06)", o.currentTarget.style.color = r, o.currentTarget.style.transform = "translateY(0)", o.currentTarget.style.boxShadow = "none";
|
|
837
1288
|
},
|
|
838
|
-
children:
|
|
839
|
-
},
|
|
840
|
-
}),
|
|
1289
|
+
children: n.label
|
|
1290
|
+
}, n.value))
|
|
1291
|
+
}), De = ({ color: e }) => {
|
|
841
1292
|
const t = {
|
|
842
|
-
width: "
|
|
843
|
-
height: "
|
|
1293
|
+
width: "7px",
|
|
1294
|
+
height: "7px",
|
|
844
1295
|
borderRadius: "50%",
|
|
845
1296
|
backgroundColor: e,
|
|
846
|
-
opacity: 0.
|
|
847
|
-
animation: "
|
|
1297
|
+
opacity: 0.35,
|
|
1298
|
+
animation: "cb-typing-bounce 1.4s infinite ease-in-out"
|
|
848
1299
|
};
|
|
849
|
-
return /* @__PURE__ */
|
|
850
|
-
@keyframes chatbot-typing-bounce {
|
|
851
|
-
0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
|
|
852
|
-
40% { transform: scale(1); opacity: 1; }
|
|
853
|
-
}
|
|
854
|
-
` }), /* @__PURE__ */ d("div", {
|
|
1300
|
+
return /* @__PURE__ */ x("div", {
|
|
855
1301
|
style: {
|
|
856
1302
|
display: "flex",
|
|
857
|
-
gap: "
|
|
858
|
-
padding: "
|
|
859
|
-
|
|
860
|
-
|
|
1303
|
+
gap: "5px",
|
|
1304
|
+
padding: "14px 18px",
|
|
1305
|
+
background: "rgba(241, 243, 249, 0.8)",
|
|
1306
|
+
backdropFilter: "blur(8px)",
|
|
1307
|
+
WebkitBackdropFilter: "blur(8px)",
|
|
1308
|
+
borderRadius: "18px 18px 18px 4px",
|
|
861
1309
|
alignSelf: "flex-start",
|
|
862
|
-
alignItems: "center"
|
|
1310
|
+
alignItems: "center",
|
|
1311
|
+
border: "1px solid rgba(0,0,0,0.04)",
|
|
1312
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.04)",
|
|
1313
|
+
animation: "cb-fade-in 0.3s ease-out"
|
|
863
1314
|
},
|
|
864
1315
|
children: [
|
|
865
|
-
/* @__PURE__ */
|
|
1316
|
+
/* @__PURE__ */ a("span", { style: {
|
|
866
1317
|
...t,
|
|
867
1318
|
animationDelay: "0s"
|
|
868
1319
|
} }),
|
|
869
|
-
/* @__PURE__ */
|
|
1320
|
+
/* @__PURE__ */ a("span", { style: {
|
|
870
1321
|
...t,
|
|
871
1322
|
animationDelay: "0.2s"
|
|
872
1323
|
} }),
|
|
873
|
-
/* @__PURE__ */
|
|
1324
|
+
/* @__PURE__ */ a("span", { style: {
|
|
874
1325
|
...t,
|
|
875
1326
|
animationDelay: "0.4s"
|
|
876
1327
|
} })
|
|
877
1328
|
]
|
|
878
|
-
})
|
|
879
|
-
},
|
|
880
|
-
const
|
|
881
|
-
return
|
|
882
|
-
|
|
883
|
-
}, [e, t]), /* @__PURE__ */
|
|
884
|
-
style:
|
|
1329
|
+
});
|
|
1330
|
+
}, Fe = ({ messages: e, isTyping: t, styles: r, primaryColor: n, onQuickReply: o, onFormSubmit: s, components: i, onComponentComplete: c, collectedData: u, currentStepId: f }) => {
|
|
1331
|
+
const w = C(null);
|
|
1332
|
+
return A(() => {
|
|
1333
|
+
w.current?.scrollIntoView({ behavior: "smooth" });
|
|
1334
|
+
}, [e, t]), /* @__PURE__ */ x("div", {
|
|
1335
|
+
style: r.messageList,
|
|
1336
|
+
className: "cb-scrollbar",
|
|
885
1337
|
children: [
|
|
886
|
-
e.map((
|
|
887
|
-
/* @__PURE__ */
|
|
888
|
-
message:
|
|
889
|
-
styles:
|
|
1338
|
+
e.map((p) => /* @__PURE__ */ x(_.Fragment, { children: [
|
|
1339
|
+
/* @__PURE__ */ a(we, {
|
|
1340
|
+
message: p,
|
|
1341
|
+
styles: r
|
|
890
1342
|
}),
|
|
891
|
-
|
|
892
|
-
replies:
|
|
893
|
-
onSelect:
|
|
894
|
-
primaryColor:
|
|
1343
|
+
p.quickReplies && p.quickReplies.length > 0 && /* @__PURE__ */ a(Ce, {
|
|
1344
|
+
replies: p.quickReplies,
|
|
1345
|
+
onSelect: o,
|
|
1346
|
+
primaryColor: n
|
|
895
1347
|
}),
|
|
896
|
-
|
|
1348
|
+
p.form && /* @__PURE__ */ a("div", {
|
|
897
1349
|
style: {
|
|
898
1350
|
alignSelf: "flex-start",
|
|
899
|
-
width: "
|
|
1351
|
+
width: "92%",
|
|
1352
|
+
animation: "cb-slide-up 0.35s ease-out"
|
|
900
1353
|
},
|
|
901
|
-
children: /* @__PURE__ */
|
|
902
|
-
config:
|
|
903
|
-
onSubmit: (g) => s(
|
|
904
|
-
primaryColor:
|
|
1354
|
+
children: /* @__PURE__ */ a(H, {
|
|
1355
|
+
config: p.form,
|
|
1356
|
+
onSubmit: (g) => s(p.form.id, g),
|
|
1357
|
+
primaryColor: n
|
|
1358
|
+
})
|
|
1359
|
+
}),
|
|
1360
|
+
p.component && i?.[p.component] && /* @__PURE__ */ a("div", {
|
|
1361
|
+
style: {
|
|
1362
|
+
alignSelf: "flex-start",
|
|
1363
|
+
width: "92%",
|
|
1364
|
+
animation: "cb-slide-up 0.35s ease-out"
|
|
1365
|
+
},
|
|
1366
|
+
children: _.createElement(i[p.component], {
|
|
1367
|
+
stepId: f ?? "",
|
|
1368
|
+
data: u ?? {},
|
|
1369
|
+
onComplete: (g) => c?.(g)
|
|
905
1370
|
})
|
|
906
1371
|
})
|
|
907
|
-
] },
|
|
908
|
-
t && /* @__PURE__ */
|
|
909
|
-
/* @__PURE__ */
|
|
1372
|
+
] }, p.id)),
|
|
1373
|
+
t && /* @__PURE__ */ a(De, { color: n }),
|
|
1374
|
+
/* @__PURE__ */ a("div", { ref: w })
|
|
910
1375
|
]
|
|
911
1376
|
});
|
|
912
|
-
},
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1377
|
+
}, W = [
|
|
1378
|
+
{
|
|
1379
|
+
name: "Smileys",
|
|
1380
|
+
emojis: [
|
|
1381
|
+
"😀",
|
|
1382
|
+
"😃",
|
|
1383
|
+
"😄",
|
|
1384
|
+
"😁",
|
|
1385
|
+
"😅",
|
|
1386
|
+
"😂",
|
|
1387
|
+
"🤣",
|
|
1388
|
+
"😊",
|
|
1389
|
+
"😇",
|
|
1390
|
+
"🙂",
|
|
1391
|
+
"😉",
|
|
1392
|
+
"😍",
|
|
1393
|
+
"🥰",
|
|
1394
|
+
"😘",
|
|
1395
|
+
"😋",
|
|
1396
|
+
"😜",
|
|
1397
|
+
"🤪",
|
|
1398
|
+
"🤗",
|
|
1399
|
+
"🤔",
|
|
1400
|
+
"🤫",
|
|
1401
|
+
"🤭",
|
|
1402
|
+
"😏",
|
|
1403
|
+
"😐",
|
|
1404
|
+
"😑",
|
|
1405
|
+
"😶",
|
|
1406
|
+
"😌",
|
|
1407
|
+
"😴",
|
|
1408
|
+
"🤤",
|
|
1409
|
+
"😷",
|
|
1410
|
+
"🤒"
|
|
1411
|
+
]
|
|
1412
|
+
},
|
|
1413
|
+
{
|
|
1414
|
+
name: "Gestures",
|
|
1415
|
+
emojis: [
|
|
1416
|
+
"👍",
|
|
1417
|
+
"👎",
|
|
1418
|
+
"👌",
|
|
1419
|
+
"✌️",
|
|
1420
|
+
"🤞",
|
|
1421
|
+
"🤟",
|
|
1422
|
+
"🤘",
|
|
1423
|
+
"👋",
|
|
1424
|
+
"🤚",
|
|
1425
|
+
"✋",
|
|
1426
|
+
"🖖",
|
|
1427
|
+
"👏",
|
|
1428
|
+
"🙌",
|
|
1429
|
+
"🤝",
|
|
1430
|
+
"🙏",
|
|
1431
|
+
"💪",
|
|
1432
|
+
"🖐️",
|
|
1433
|
+
"☝️",
|
|
1434
|
+
"👆",
|
|
1435
|
+
"👇",
|
|
1436
|
+
"👈",
|
|
1437
|
+
"👉",
|
|
1438
|
+
"🤙",
|
|
1439
|
+
"🫡",
|
|
1440
|
+
"🫶",
|
|
1441
|
+
"🫰",
|
|
1442
|
+
"🫳",
|
|
1443
|
+
"🫴",
|
|
1444
|
+
"🫲",
|
|
1445
|
+
"🫱"
|
|
1446
|
+
]
|
|
1447
|
+
},
|
|
1448
|
+
{
|
|
1449
|
+
name: "Hearts",
|
|
1450
|
+
emojis: [
|
|
1451
|
+
"❤️",
|
|
1452
|
+
"🧡",
|
|
1453
|
+
"💛",
|
|
1454
|
+
"💚",
|
|
1455
|
+
"💙",
|
|
1456
|
+
"💜",
|
|
1457
|
+
"🖤",
|
|
1458
|
+
"🤍",
|
|
1459
|
+
"🤎",
|
|
1460
|
+
"💔",
|
|
1461
|
+
"❣️",
|
|
1462
|
+
"💕",
|
|
1463
|
+
"💞",
|
|
1464
|
+
"💓",
|
|
1465
|
+
"💗",
|
|
1466
|
+
"💖",
|
|
1467
|
+
"💘",
|
|
1468
|
+
"💝",
|
|
1469
|
+
"💟",
|
|
1470
|
+
"♥️",
|
|
1471
|
+
"🫀",
|
|
1472
|
+
"💌",
|
|
1473
|
+
"💐",
|
|
1474
|
+
"🌹",
|
|
1475
|
+
"🌺",
|
|
1476
|
+
"🌸",
|
|
1477
|
+
"🌼",
|
|
1478
|
+
"🌻",
|
|
1479
|
+
"🌷",
|
|
1480
|
+
"💮"
|
|
1481
|
+
]
|
|
1482
|
+
},
|
|
1483
|
+
{
|
|
1484
|
+
name: "Objects",
|
|
1485
|
+
emojis: [
|
|
1486
|
+
"🔥",
|
|
1487
|
+
"⭐",
|
|
1488
|
+
"✨",
|
|
1489
|
+
"💯",
|
|
1490
|
+
"🎉",
|
|
1491
|
+
"🎊",
|
|
1492
|
+
"🎯",
|
|
1493
|
+
"🚀",
|
|
1494
|
+
"💡",
|
|
1495
|
+
"📌",
|
|
1496
|
+
"📎",
|
|
1497
|
+
"🔗",
|
|
1498
|
+
"💻",
|
|
1499
|
+
"📱",
|
|
1500
|
+
"☎️",
|
|
1501
|
+
"📧",
|
|
1502
|
+
"📝",
|
|
1503
|
+
"📋",
|
|
1504
|
+
"📊",
|
|
1505
|
+
"📈",
|
|
1506
|
+
"🗂️",
|
|
1507
|
+
"📁",
|
|
1508
|
+
"🔒",
|
|
1509
|
+
"🔑",
|
|
1510
|
+
"⚙️",
|
|
1511
|
+
"🛠️",
|
|
1512
|
+
"🔧",
|
|
1513
|
+
"📦",
|
|
1514
|
+
"🏷️",
|
|
1515
|
+
"✅"
|
|
1516
|
+
]
|
|
1517
|
+
}
|
|
1518
|
+
], Te = ({ onSelect: e, onClose: t, primaryColor: r }) => {
|
|
1519
|
+
const [n, o] = I(0), s = C(null);
|
|
1520
|
+
A(() => {
|
|
1521
|
+
const c = (u) => {
|
|
1522
|
+
s.current && !s.current.contains(u.target) && t();
|
|
1523
|
+
};
|
|
1524
|
+
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
1525
|
+
}, [t]);
|
|
1526
|
+
const i = W[n]?.emojis ?? [];
|
|
1527
|
+
return /* @__PURE__ */ x("div", {
|
|
1528
|
+
ref: s,
|
|
920
1529
|
style: {
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
1530
|
+
position: "absolute",
|
|
1531
|
+
bottom: "100%",
|
|
1532
|
+
left: 0,
|
|
1533
|
+
width: "280px",
|
|
1534
|
+
backgroundColor: "rgba(255, 255, 255, 0.92)",
|
|
1535
|
+
backdropFilter: "blur(20px)",
|
|
1536
|
+
WebkitBackdropFilter: "blur(20px)",
|
|
1537
|
+
borderRadius: "16px",
|
|
1538
|
+
boxShadow: "0 8px 32px rgba(0,0,0,0.12), 0 0 0 1px rgba(0,0,0,0.04)",
|
|
1539
|
+
border: "1px solid rgba(255,255,255,0.8)",
|
|
1540
|
+
overflow: "hidden",
|
|
1541
|
+
zIndex: 10,
|
|
1542
|
+
marginBottom: "8px",
|
|
1543
|
+
animation: "cb-slide-up 0.25s ease-out"
|
|
925
1544
|
},
|
|
926
|
-
children: [/* @__PURE__ */
|
|
927
|
-
ref: l,
|
|
928
|
-
value: s,
|
|
929
|
-
onChange: (p) => u(p.target.value),
|
|
930
|
-
onKeyDown: x,
|
|
931
|
-
placeholder: t,
|
|
932
|
-
disabled: r,
|
|
933
|
-
rows: 1,
|
|
934
|
-
style: {
|
|
935
|
-
flex: 1,
|
|
936
|
-
padding: "10px 14px",
|
|
937
|
-
border: "1px solid #E0E0E0",
|
|
938
|
-
borderRadius: "20px",
|
|
939
|
-
outline: "none",
|
|
940
|
-
resize: "none",
|
|
941
|
-
fontFamily: "inherit",
|
|
942
|
-
fontSize: "14px",
|
|
943
|
-
lineHeight: "1.4",
|
|
944
|
-
maxHeight: "100px",
|
|
945
|
-
overflowY: "auto"
|
|
946
|
-
}
|
|
947
|
-
}), /* @__PURE__ */ o("button", {
|
|
948
|
-
onClick: g,
|
|
949
|
-
disabled: r || !s.trim(),
|
|
950
|
-
"aria-label": "Send message",
|
|
1545
|
+
children: [/* @__PURE__ */ a("div", {
|
|
951
1546
|
style: {
|
|
952
|
-
width: "38px",
|
|
953
|
-
height: "38px",
|
|
954
|
-
borderRadius: "50%",
|
|
955
|
-
backgroundColor: s.trim() ? n : "#CCC",
|
|
956
|
-
color: "#fff",
|
|
957
|
-
border: "none",
|
|
958
|
-
cursor: s.trim() ? "pointer" : "default",
|
|
959
1547
|
display: "flex",
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
transition: "background-color 0.15s ease"
|
|
1548
|
+
borderBottom: "1px solid rgba(0,0,0,0.06)",
|
|
1549
|
+
padding: "6px",
|
|
1550
|
+
gap: "3px"
|
|
964
1551
|
},
|
|
965
|
-
children: /* @__PURE__ */
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1552
|
+
children: W.map((c, u) => /* @__PURE__ */ a("button", {
|
|
1553
|
+
onClick: () => o(u),
|
|
1554
|
+
title: c.name,
|
|
1555
|
+
style: {
|
|
1556
|
+
flex: 1,
|
|
1557
|
+
padding: "6px 4px",
|
|
1558
|
+
border: "none",
|
|
1559
|
+
borderRadius: "8px",
|
|
1560
|
+
cursor: "pointer",
|
|
1561
|
+
fontSize: "11px",
|
|
1562
|
+
fontWeight: 600,
|
|
1563
|
+
fontFamily: "inherit",
|
|
1564
|
+
letterSpacing: "0.02em",
|
|
1565
|
+
background: u === n ? `linear-gradient(135deg, ${r}, ${r}CC)` : "transparent",
|
|
1566
|
+
color: u === n ? "#fff" : "rgba(0,0,0,0.4)",
|
|
1567
|
+
transition: "all 0.2s ease",
|
|
1568
|
+
boxShadow: u === n ? `0 2px 8px ${r}33` : "none"
|
|
1569
|
+
},
|
|
1570
|
+
children: c.name
|
|
1571
|
+
}, c.name))
|
|
1572
|
+
}), /* @__PURE__ */ a("div", {
|
|
1573
|
+
style: {
|
|
1574
|
+
display: "grid",
|
|
1575
|
+
gridTemplateColumns: "repeat(8, 1fr)",
|
|
1576
|
+
gap: "2px",
|
|
1577
|
+
padding: "8px",
|
|
1578
|
+
maxHeight: "180px",
|
|
1579
|
+
overflowY: "auto"
|
|
1580
|
+
},
|
|
1581
|
+
children: i.map((c) => /* @__PURE__ */ a("button", {
|
|
1582
|
+
onClick: () => {
|
|
1583
|
+
e(c), t();
|
|
1584
|
+
},
|
|
1585
|
+
style: {
|
|
1586
|
+
width: "30px",
|
|
1587
|
+
height: "30px",
|
|
1588
|
+
border: "none",
|
|
1589
|
+
backgroundColor: "transparent",
|
|
1590
|
+
cursor: "pointer",
|
|
1591
|
+
fontSize: "18px",
|
|
1592
|
+
borderRadius: "6px",
|
|
1593
|
+
display: "flex",
|
|
1594
|
+
alignItems: "center",
|
|
1595
|
+
justifyContent: "center",
|
|
1596
|
+
transition: "all 0.15s ease"
|
|
1597
|
+
},
|
|
1598
|
+
onMouseEnter: (u) => u.currentTarget.style.backgroundColor = "rgba(108, 92, 231, 0.08)",
|
|
1599
|
+
onMouseLeave: (u) => u.currentTarget.style.backgroundColor = "transparent",
|
|
1600
|
+
children: c
|
|
1601
|
+
}, c))
|
|
972
1602
|
})]
|
|
973
1603
|
});
|
|
974
|
-
},
|
|
1604
|
+
}, Ie = ({ config: e, onFiles: t, selectedFiles: r, onRemoveFile: n, primaryColor: o }) => {
|
|
1605
|
+
const s = C(null), i = (c) => {
|
|
1606
|
+
const u = c.target.files;
|
|
1607
|
+
if (!u || u.length === 0) return;
|
|
1608
|
+
const f = Array.from(u);
|
|
1609
|
+
if (e.maxSize && f.filter((p) => p.size > e.maxSize).length > 0) {
|
|
1610
|
+
alert(`File(s) too large. Max size: ${q(e.maxSize)}`);
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
const w = e.maxFiles ?? 5;
|
|
1614
|
+
if (r.length + f.length > w) {
|
|
1615
|
+
alert(`Maximum ${w} files allowed`);
|
|
1616
|
+
return;
|
|
1617
|
+
}
|
|
1618
|
+
t(f), s.current && (s.current.value = "");
|
|
1619
|
+
};
|
|
1620
|
+
return /* @__PURE__ */ x("div", { children: [/* @__PURE__ */ a("input", {
|
|
1621
|
+
ref: s,
|
|
1622
|
+
type: "file",
|
|
1623
|
+
accept: e.accept,
|
|
1624
|
+
multiple: e.multiple !== !1,
|
|
1625
|
+
onChange: i,
|
|
1626
|
+
style: { display: "none" }
|
|
1627
|
+
}), /* @__PURE__ */ a("button", {
|
|
1628
|
+
type: "button",
|
|
1629
|
+
onClick: () => s.current?.click(),
|
|
1630
|
+
"aria-label": "Attach file",
|
|
1631
|
+
title: "Attach file",
|
|
1632
|
+
style: {
|
|
1633
|
+
background: "none",
|
|
1634
|
+
border: "none",
|
|
1635
|
+
cursor: "pointer",
|
|
1636
|
+
padding: "6px",
|
|
1637
|
+
display: "flex",
|
|
1638
|
+
alignItems: "center",
|
|
1639
|
+
color: "#999",
|
|
1640
|
+
borderRadius: "6px",
|
|
1641
|
+
transition: "color 0.15s ease"
|
|
1642
|
+
},
|
|
1643
|
+
onMouseEnter: (c) => c.currentTarget.style.color = o,
|
|
1644
|
+
onMouseLeave: (c) => c.currentTarget.style.color = "#999",
|
|
1645
|
+
children: /* @__PURE__ */ a(ie, { size: 20 })
|
|
1646
|
+
})] });
|
|
1647
|
+
}, Re = ({ files: e, onRemove: t, primaryColor: r }) => e.length === 0 ? null : /* @__PURE__ */ a("div", {
|
|
1648
|
+
style: {
|
|
1649
|
+
display: "flex",
|
|
1650
|
+
flexWrap: "wrap",
|
|
1651
|
+
gap: "6px",
|
|
1652
|
+
padding: "8px 12px 0"
|
|
1653
|
+
},
|
|
1654
|
+
children: e.map((n, o) => /* @__PURE__ */ a(Ae, {
|
|
1655
|
+
file: n,
|
|
1656
|
+
onRemove: () => t(o),
|
|
1657
|
+
primaryColor: r
|
|
1658
|
+
}, `${n.name}-${o}`))
|
|
1659
|
+
}), Ae = ({ file: e, onRemove: t, primaryColor: r }) => {
|
|
1660
|
+
const n = e.type.startsWith("image/");
|
|
1661
|
+
return /* @__PURE__ */ x("div", {
|
|
1662
|
+
style: {
|
|
1663
|
+
display: "flex",
|
|
1664
|
+
alignItems: "center",
|
|
1665
|
+
gap: "6px",
|
|
1666
|
+
padding: "4px 8px",
|
|
1667
|
+
backgroundColor: "#F3F4F6",
|
|
1668
|
+
borderRadius: "8px",
|
|
1669
|
+
fontSize: "12px",
|
|
1670
|
+
maxWidth: "200px"
|
|
1671
|
+
},
|
|
1672
|
+
children: [
|
|
1673
|
+
/* @__PURE__ */ a("span", {
|
|
1674
|
+
style: {
|
|
1675
|
+
color: r,
|
|
1676
|
+
flexShrink: 0
|
|
1677
|
+
},
|
|
1678
|
+
children: n ? /* @__PURE__ */ a(se, { size: 14 }) : /* @__PURE__ */ a(G, { size: 14 })
|
|
1679
|
+
}),
|
|
1680
|
+
/* @__PURE__ */ a("span", {
|
|
1681
|
+
style: {
|
|
1682
|
+
overflow: "hidden",
|
|
1683
|
+
textOverflow: "ellipsis",
|
|
1684
|
+
whiteSpace: "nowrap",
|
|
1685
|
+
color: "#555"
|
|
1686
|
+
},
|
|
1687
|
+
children: e.name
|
|
1688
|
+
}),
|
|
1689
|
+
/* @__PURE__ */ a("span", {
|
|
1690
|
+
style: {
|
|
1691
|
+
color: "#999",
|
|
1692
|
+
fontSize: "11px",
|
|
1693
|
+
flexShrink: 0
|
|
1694
|
+
},
|
|
1695
|
+
children: q(e.size)
|
|
1696
|
+
}),
|
|
1697
|
+
/* @__PURE__ */ a("button", {
|
|
1698
|
+
onClick: t,
|
|
1699
|
+
style: {
|
|
1700
|
+
background: "none",
|
|
1701
|
+
border: "none",
|
|
1702
|
+
cursor: "pointer",
|
|
1703
|
+
padding: "0",
|
|
1704
|
+
display: "flex",
|
|
1705
|
+
color: "#999",
|
|
1706
|
+
flexShrink: 0
|
|
1707
|
+
},
|
|
1708
|
+
children: /* @__PURE__ */ a(le, { size: 14 })
|
|
1709
|
+
})
|
|
1710
|
+
]
|
|
1711
|
+
});
|
|
1712
|
+
};
|
|
1713
|
+
function q(e) {
|
|
1714
|
+
return e < 1024 ? `${e}B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)}KB` : `${(e / (1024 * 1024)).toFixed(1)}MB`;
|
|
1715
|
+
}
|
|
1716
|
+
var Me = ({ onSend: e, placeholder: t = "Type a message...", primaryColor: r, isDark: n = !1, disabled: o, styleOverride: s, enableEmoji: i = !1, fileUpload: c, onFileUpload: u }) => {
|
|
1717
|
+
const [f, w] = I(""), [p, g] = I(!1), [h, k] = I([]), D = C(null), R = v(() => {
|
|
1718
|
+
const d = f.trim();
|
|
1719
|
+
!d && h.length === 0 || (e(d, h.length > 0 ? h : void 0), w(""), k([]), D.current?.focus());
|
|
1720
|
+
}, [
|
|
1721
|
+
f,
|
|
1722
|
+
h,
|
|
1723
|
+
e
|
|
1724
|
+
]), T = (d) => {
|
|
1725
|
+
d.key === "Enter" && !d.shiftKey && (d.preventDefault(), R());
|
|
1726
|
+
}, l = (d) => {
|
|
1727
|
+
w((S) => S + d), D.current?.focus();
|
|
1728
|
+
}, b = (d) => {
|
|
1729
|
+
k((S) => [...S, ...d]), u?.(d);
|
|
1730
|
+
}, m = (d) => {
|
|
1731
|
+
k((S) => S.filter((M, E) => E !== d));
|
|
1732
|
+
}, y = f.trim() || h.length > 0;
|
|
1733
|
+
return /* @__PURE__ */ x("div", {
|
|
1734
|
+
style: {
|
|
1735
|
+
position: "relative",
|
|
1736
|
+
...s
|
|
1737
|
+
},
|
|
1738
|
+
children: [
|
|
1739
|
+
h.length > 0 && /* @__PURE__ */ a(Re, {
|
|
1740
|
+
files: h,
|
|
1741
|
+
onRemove: m,
|
|
1742
|
+
primaryColor: r
|
|
1743
|
+
}),
|
|
1744
|
+
p && /* @__PURE__ */ a(Te, {
|
|
1745
|
+
onSelect: l,
|
|
1746
|
+
onClose: () => g(!1),
|
|
1747
|
+
primaryColor: r
|
|
1748
|
+
}),
|
|
1749
|
+
/* @__PURE__ */ x("div", {
|
|
1750
|
+
style: {
|
|
1751
|
+
display: "flex",
|
|
1752
|
+
gap: "8px",
|
|
1753
|
+
alignItems: "flex-end",
|
|
1754
|
+
background: n ? "rgba(40, 40, 65, 0.5)" : "rgba(245, 247, 252, 0.7)",
|
|
1755
|
+
borderRadius: "16px",
|
|
1756
|
+
border: `1px solid ${n ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.05)"}`,
|
|
1757
|
+
backdropFilter: "blur(8px)",
|
|
1758
|
+
WebkitBackdropFilter: "blur(8px)",
|
|
1759
|
+
padding: "6px 6px 6px 12px"
|
|
1760
|
+
},
|
|
1761
|
+
children: [
|
|
1762
|
+
/* @__PURE__ */ x("div", {
|
|
1763
|
+
style: {
|
|
1764
|
+
display: "flex",
|
|
1765
|
+
alignItems: "center",
|
|
1766
|
+
gap: "2px",
|
|
1767
|
+
flexShrink: 0,
|
|
1768
|
+
paddingBottom: "2px"
|
|
1769
|
+
},
|
|
1770
|
+
children: [i && /* @__PURE__ */ a("button", {
|
|
1771
|
+
type: "button",
|
|
1772
|
+
onClick: () => g(!p),
|
|
1773
|
+
"aria-label": "Emoji",
|
|
1774
|
+
title: "Emoji",
|
|
1775
|
+
style: {
|
|
1776
|
+
background: "none",
|
|
1777
|
+
border: "none",
|
|
1778
|
+
cursor: "pointer",
|
|
1779
|
+
padding: "6px",
|
|
1780
|
+
display: "flex",
|
|
1781
|
+
color: p ? r : n ? "rgba(255,255,255,0.35)" : "rgba(0,0,0,0.3)",
|
|
1782
|
+
borderRadius: "8px",
|
|
1783
|
+
transition: "all 0.2s ease"
|
|
1784
|
+
},
|
|
1785
|
+
children: /* @__PURE__ */ a(oe, { size: 20 })
|
|
1786
|
+
}), c?.enabled && /* @__PURE__ */ a(Ie, {
|
|
1787
|
+
config: c,
|
|
1788
|
+
onFiles: b,
|
|
1789
|
+
selectedFiles: h,
|
|
1790
|
+
onRemoveFile: m,
|
|
1791
|
+
primaryColor: r
|
|
1792
|
+
})]
|
|
1793
|
+
}),
|
|
1794
|
+
/* @__PURE__ */ a("textarea", {
|
|
1795
|
+
ref: D,
|
|
1796
|
+
value: f,
|
|
1797
|
+
onChange: (d) => w(d.target.value),
|
|
1798
|
+
onKeyDown: T,
|
|
1799
|
+
placeholder: t,
|
|
1800
|
+
disabled: o,
|
|
1801
|
+
rows: 1,
|
|
1802
|
+
style: {
|
|
1803
|
+
flex: 1,
|
|
1804
|
+
padding: "8px 2px",
|
|
1805
|
+
border: "none",
|
|
1806
|
+
borderRadius: "12px",
|
|
1807
|
+
outline: "none",
|
|
1808
|
+
resize: "none",
|
|
1809
|
+
fontFamily: "inherit",
|
|
1810
|
+
fontSize: "14px",
|
|
1811
|
+
lineHeight: "1.45",
|
|
1812
|
+
maxHeight: "100px",
|
|
1813
|
+
overflowY: "auto",
|
|
1814
|
+
backgroundColor: "transparent",
|
|
1815
|
+
color: n ? "#E0E0E0" : "#2D3436",
|
|
1816
|
+
letterSpacing: "0.01em"
|
|
1817
|
+
}
|
|
1818
|
+
}),
|
|
1819
|
+
/* @__PURE__ */ a("button", {
|
|
1820
|
+
onClick: R,
|
|
1821
|
+
disabled: o || !y,
|
|
1822
|
+
"aria-label": "Send message",
|
|
1823
|
+
style: {
|
|
1824
|
+
width: "36px",
|
|
1825
|
+
height: "36px",
|
|
1826
|
+
borderRadius: "12px",
|
|
1827
|
+
background: y ? `linear-gradient(135deg, ${r} 0%, ${Be(r, 30)} 100%)` : n ? "rgba(255,255,255,0.08)" : "rgba(0,0,0,0.06)",
|
|
1828
|
+
color: y ? "#fff" : n ? "rgba(255,255,255,0.25)" : "rgba(0,0,0,0.2)",
|
|
1829
|
+
border: "none",
|
|
1830
|
+
cursor: y ? "pointer" : "default",
|
|
1831
|
+
display: "flex",
|
|
1832
|
+
alignItems: "center",
|
|
1833
|
+
justifyContent: "center",
|
|
1834
|
+
flexShrink: 0,
|
|
1835
|
+
transition: "all 0.25s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
1836
|
+
boxShadow: y ? `0 4px 12px ${r}44` : "none"
|
|
1837
|
+
},
|
|
1838
|
+
children: /* @__PURE__ */ a(re, { size: 16 })
|
|
1839
|
+
})
|
|
1840
|
+
]
|
|
1841
|
+
})
|
|
1842
|
+
]
|
|
1843
|
+
});
|
|
1844
|
+
};
|
|
1845
|
+
function Be(e, t) {
|
|
1846
|
+
const r = parseInt(e.replace("#", ""), 16), n = Math.min(255, (r >> 16 & 255) + t), o = Math.min(255, (r >> 8 & 255) + t), s = Math.min(255, (r & 255) + t);
|
|
1847
|
+
return `#${(n << 16 | o << 8 | s).toString(16).padStart(6, "0")}`;
|
|
1848
|
+
}
|
|
1849
|
+
var Le = ({ config: e, primaryColor: t }) => {
|
|
1850
|
+
if (e.showBranding === !1) return null;
|
|
1851
|
+
const r = e.poweredBy ?? "React ChatBot";
|
|
1852
|
+
return /* @__PURE__ */ x("div", {
|
|
1853
|
+
style: {
|
|
1854
|
+
padding: "8px 16px",
|
|
1855
|
+
textAlign: "center",
|
|
1856
|
+
fontSize: "11px",
|
|
1857
|
+
color: "rgba(0,0,0,0.35)",
|
|
1858
|
+
background: "rgba(250, 250, 255, 0.7)",
|
|
1859
|
+
backdropFilter: "blur(8px)",
|
|
1860
|
+
WebkitBackdropFilter: "blur(8px)",
|
|
1861
|
+
borderTop: "1px solid rgba(0,0,0,0.04)",
|
|
1862
|
+
flexShrink: 0,
|
|
1863
|
+
letterSpacing: "0.02em"
|
|
1864
|
+
},
|
|
1865
|
+
children: [
|
|
1866
|
+
"Powered by",
|
|
1867
|
+
" ",
|
|
1868
|
+
e.poweredByUrl ? /* @__PURE__ */ a("a", {
|
|
1869
|
+
href: e.poweredByUrl,
|
|
1870
|
+
target: "_blank",
|
|
1871
|
+
rel: "noopener noreferrer",
|
|
1872
|
+
style: {
|
|
1873
|
+
color: t,
|
|
1874
|
+
textDecoration: "none",
|
|
1875
|
+
fontWeight: 600,
|
|
1876
|
+
transition: "opacity 0.2s ease"
|
|
1877
|
+
},
|
|
1878
|
+
children: r
|
|
1879
|
+
}) : /* @__PURE__ */ a("span", {
|
|
1880
|
+
style: {
|
|
1881
|
+
color: t,
|
|
1882
|
+
fontWeight: 600
|
|
1883
|
+
},
|
|
1884
|
+
children: r
|
|
1885
|
+
})
|
|
1886
|
+
]
|
|
1887
|
+
});
|
|
1888
|
+
}, ze = class {
|
|
975
1889
|
constructor(e) {
|
|
976
|
-
this.collectedData = {}, this.startStep = e.startStep, this.steps = new Map(e.steps.map((t) => [t.id, t]));
|
|
1890
|
+
this.collectedData = {}, this.idCounter = 0, this.uid = () => `msg_${Date.now()}_${++this.idCounter}`, this.stepHistory = [], this.startStep = e.startStep, this.steps = new Map(e.steps.map((t) => [t.id, t]));
|
|
977
1891
|
}
|
|
978
1892
|
getStartStepId() {
|
|
979
1893
|
return this.startStep;
|
|
@@ -990,277 +1904,683 @@ var O = ({ onClick: e, isOpen: t, position: n, styles: r, icon: i, closeIcon: s,
|
|
|
990
1904
|
mergeData(e) {
|
|
991
1905
|
Object.assign(this.collectedData, e);
|
|
992
1906
|
}
|
|
1907
|
+
pushHistory(e) {
|
|
1908
|
+
this.stepHistory.push(e);
|
|
1909
|
+
}
|
|
1910
|
+
popHistory() {
|
|
1911
|
+
return this.stepHistory.pop(), this.stepHistory.pop();
|
|
1912
|
+
}
|
|
1913
|
+
canGoBack() {
|
|
1914
|
+
return this.stepHistory.length > 1;
|
|
1915
|
+
}
|
|
1916
|
+
reset() {
|
|
1917
|
+
this.collectedData = {}, this.stepHistory = [];
|
|
1918
|
+
}
|
|
993
1919
|
resolveNext(e, t) {
|
|
994
1920
|
if (e.condition) {
|
|
995
|
-
const { field:
|
|
996
|
-
return this.evaluate(
|
|
1921
|
+
const { field: r, operator: n, value: o, then: s, else: i } = e.condition, c = this.collectedData[r];
|
|
1922
|
+
return this.evaluate(c, n, o) ? s : i;
|
|
997
1923
|
}
|
|
998
1924
|
if (t && e.quickReplies) {
|
|
999
|
-
const
|
|
1000
|
-
if (
|
|
1925
|
+
const r = e.quickReplies.find((n) => n.value === t);
|
|
1926
|
+
if (r?.next) return r.next;
|
|
1001
1927
|
}
|
|
1002
1928
|
return e.next;
|
|
1003
1929
|
}
|
|
1930
|
+
stepExpectsQuickReply(e) {
|
|
1931
|
+
return !!(e.quickReplies && e.quickReplies.length > 0);
|
|
1932
|
+
}
|
|
1933
|
+
stepExpectsForm(e) {
|
|
1934
|
+
return !!e.form;
|
|
1935
|
+
}
|
|
1936
|
+
matchQuickReply(e, t) {
|
|
1937
|
+
if (!e.quickReplies) return;
|
|
1938
|
+
const r = t.toLowerCase().trim(), n = e.quickReplies.find((s) => s.value.toLowerCase() === r);
|
|
1939
|
+
if (n) return n;
|
|
1940
|
+
const o = e.quickReplies.find((s) => s.label.toLowerCase().replace(/[^\w\s]/g, "").trim() === r);
|
|
1941
|
+
return o || e.quickReplies.find((s) => r.includes(s.value.toLowerCase()) || s.label.toLowerCase().includes(r));
|
|
1942
|
+
}
|
|
1004
1943
|
buildMessages(e) {
|
|
1005
|
-
const t = [],
|
|
1006
|
-
for (const
|
|
1007
|
-
id:
|
|
1944
|
+
const t = [], r = e.messages ?? (e.message ? [e.message] : []);
|
|
1945
|
+
for (const n of r) t.push({
|
|
1946
|
+
id: this.uid(),
|
|
1008
1947
|
sender: "bot",
|
|
1009
|
-
text:
|
|
1948
|
+
text: n,
|
|
1010
1949
|
timestamp: Date.now()
|
|
1011
1950
|
});
|
|
1012
1951
|
return e.quickReplies && t.length > 0 && (t[t.length - 1].quickReplies = e.quickReplies), e.form && t.push({
|
|
1013
|
-
id:
|
|
1952
|
+
id: this.uid(),
|
|
1014
1953
|
sender: "bot",
|
|
1015
1954
|
timestamp: Date.now(),
|
|
1016
1955
|
form: e.form
|
|
1956
|
+
}), e.component && t.push({
|
|
1957
|
+
id: this.uid(),
|
|
1958
|
+
sender: "bot",
|
|
1959
|
+
timestamp: Date.now(),
|
|
1960
|
+
component: e.component
|
|
1017
1961
|
}), t;
|
|
1018
1962
|
}
|
|
1019
|
-
evaluate(e, t,
|
|
1963
|
+
evaluate(e, t, r) {
|
|
1020
1964
|
switch (t) {
|
|
1021
1965
|
case "eq":
|
|
1022
|
-
return String(e) === String(
|
|
1966
|
+
return String(e) === String(r);
|
|
1023
1967
|
case "neq":
|
|
1024
|
-
return String(e) !== String(
|
|
1968
|
+
return String(e) !== String(r);
|
|
1025
1969
|
case "contains":
|
|
1026
|
-
return String(e).includes(String(
|
|
1970
|
+
return String(e).includes(String(r));
|
|
1027
1971
|
case "gt":
|
|
1028
|
-
return Number(e) > Number(
|
|
1972
|
+
return Number(e) > Number(r);
|
|
1029
1973
|
case "lt":
|
|
1030
|
-
return Number(e) < Number(
|
|
1974
|
+
return Number(e) < Number(r);
|
|
1031
1975
|
default:
|
|
1032
1976
|
return !1;
|
|
1033
1977
|
}
|
|
1034
1978
|
}
|
|
1035
|
-
},
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1979
|
+
}, _e = 0, F = () => `msg_${Date.now()}_${++_e}`, B = (e) => new Promise((t) => setTimeout(t, e)), We = {
|
|
1980
|
+
"/help": "Show available commands",
|
|
1981
|
+
"/cancel": "Cancel current step and go back",
|
|
1982
|
+
"/back": "Go back to the previous step",
|
|
1983
|
+
"/restart": "Restart the conversation from the beginning"
|
|
1984
|
+
};
|
|
1985
|
+
function $e() {
|
|
1986
|
+
const { state: e, dispatch: t, props: r } = j(), n = C(null), o = C(!1), s = C(e);
|
|
1987
|
+
s.current = e;
|
|
1988
|
+
const i = C(r);
|
|
1989
|
+
i.current = r, A(() => {
|
|
1990
|
+
r.flow && (n.current = new ze(r.flow), o.current = !1);
|
|
1991
|
+
}, [r.flow]);
|
|
1992
|
+
const c = v(async (l, b) => {
|
|
1042
1993
|
t({
|
|
1043
1994
|
type: "SET_TYPING",
|
|
1044
1995
|
payload: !0
|
|
1045
|
-
}), await
|
|
1046
|
-
const
|
|
1047
|
-
id:
|
|
1996
|
+
}), await B(400);
|
|
1997
|
+
const m = {
|
|
1998
|
+
id: F(),
|
|
1048
1999
|
sender: "bot",
|
|
1049
|
-
text:
|
|
2000
|
+
text: l,
|
|
1050
2001
|
timestamp: Date.now(),
|
|
1051
|
-
...
|
|
2002
|
+
...b
|
|
1052
2003
|
};
|
|
1053
2004
|
t({
|
|
1054
2005
|
type: "SET_TYPING",
|
|
1055
2006
|
payload: !1
|
|
1056
2007
|
}), t({
|
|
1057
2008
|
type: "ADD_MESSAGE",
|
|
1058
|
-
payload:
|
|
1059
|
-
}),
|
|
1060
|
-
}, [t
|
|
1061
|
-
|
|
1062
|
-
id: f(),
|
|
1063
|
-
sender: "user",
|
|
1064
|
-
text: x,
|
|
1065
|
-
timestamp: Date.now()
|
|
1066
|
-
};
|
|
1067
|
-
if (t({
|
|
2009
|
+
payload: m
|
|
2010
|
+
}), i.current.callbacks?.onMessageReceive?.(m);
|
|
2011
|
+
}, [t]), u = v((l) => {
|
|
2012
|
+
t({
|
|
1068
2013
|
type: "ADD_MESSAGE",
|
|
1069
|
-
payload:
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
const a = r.current.resolveNext(h, x);
|
|
1075
|
-
a ? l(a) : (n.callbacks?.onFlowEnd?.(r.current.getData()), t({
|
|
1076
|
-
type: "SET_STEP",
|
|
1077
|
-
payload: null
|
|
1078
|
-
}));
|
|
2014
|
+
payload: {
|
|
2015
|
+
id: F(),
|
|
2016
|
+
sender: "system",
|
|
2017
|
+
text: l,
|
|
2018
|
+
timestamp: Date.now()
|
|
1079
2019
|
}
|
|
1080
|
-
}
|
|
1081
|
-
}, [
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
const
|
|
1087
|
-
if (!
|
|
1088
|
-
|
|
1089
|
-
if (!h) return;
|
|
1090
|
-
t({
|
|
2020
|
+
});
|
|
2021
|
+
}, [t]), f = C(async () => {
|
|
2022
|
+
});
|
|
2023
|
+
f.current = async (l) => {
|
|
2024
|
+
const b = n.current;
|
|
2025
|
+
if (!b) return;
|
|
2026
|
+
const m = b.getStep(l);
|
|
2027
|
+
if (!m) return;
|
|
2028
|
+
b.pushHistory(l), t({
|
|
1091
2029
|
type: "SET_STEP",
|
|
1092
|
-
payload:
|
|
2030
|
+
payload: l
|
|
1093
2031
|
}), t({
|
|
1094
2032
|
type: "SET_TYPING",
|
|
1095
2033
|
payload: !0
|
|
1096
|
-
}), await
|
|
1097
|
-
const
|
|
1098
|
-
t({
|
|
2034
|
+
}), await B(m.delay ?? 500);
|
|
2035
|
+
const y = b.buildMessages(m);
|
|
2036
|
+
if (t({
|
|
1099
2037
|
type: "SET_TYPING",
|
|
1100
2038
|
payload: !1
|
|
1101
2039
|
}), t({
|
|
1102
2040
|
type: "ADD_MESSAGES",
|
|
1103
|
-
payload:
|
|
1104
|
-
}),
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
2041
|
+
payload: y
|
|
2042
|
+
}), y.forEach((d) => i.current.callbacks?.onMessageReceive?.(d)), m.asyncAction) {
|
|
2043
|
+
const d = i.current.actionHandlers?.[m.asyncAction.handler];
|
|
2044
|
+
if (d) {
|
|
2045
|
+
const S = F();
|
|
2046
|
+
t({
|
|
2047
|
+
type: "ADD_MESSAGE",
|
|
2048
|
+
payload: {
|
|
2049
|
+
id: S,
|
|
2050
|
+
sender: "bot",
|
|
2051
|
+
text: m.asyncAction.loadingMessage ?? "Processing...",
|
|
2052
|
+
timestamp: Date.now()
|
|
2053
|
+
}
|
|
2054
|
+
});
|
|
2055
|
+
const M = { updateMessage: (E) => {
|
|
2056
|
+
t({
|
|
2057
|
+
type: "UPDATE_MESSAGE",
|
|
2058
|
+
payload: {
|
|
2059
|
+
id: S,
|
|
2060
|
+
updates: { text: E }
|
|
2061
|
+
}
|
|
2062
|
+
});
|
|
2063
|
+
} };
|
|
2064
|
+
try {
|
|
2065
|
+
const E = await d(b.getData(), M);
|
|
2066
|
+
E.data && (b.mergeData(E.data), t({
|
|
2067
|
+
type: "SET_DATA",
|
|
2068
|
+
payload: E.data
|
|
2069
|
+
})), t({
|
|
2070
|
+
type: "UPDATE_MESSAGE",
|
|
2071
|
+
payload: {
|
|
2072
|
+
id: S,
|
|
2073
|
+
updates: { text: E.message ?? (E.status === "success" ? m.asyncAction.successMessage ?? "Done!" : m.asyncAction.errorMessage ?? "Something went wrong.") }
|
|
2074
|
+
}
|
|
2075
|
+
});
|
|
2076
|
+
const z = w(m, E);
|
|
2077
|
+
z && (await B(600), f.current(z));
|
|
2078
|
+
} catch {
|
|
2079
|
+
t({
|
|
2080
|
+
type: "UPDATE_MESSAGE",
|
|
2081
|
+
payload: {
|
|
2082
|
+
id: S,
|
|
2083
|
+
updates: { text: m.asyncAction.errorMessage ?? "❌ Something went wrong." }
|
|
2084
|
+
}
|
|
2085
|
+
}), m.asyncAction.onError && (await B(600), f.current(m.asyncAction.onError));
|
|
2086
|
+
}
|
|
2087
|
+
return;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
m.component && i.current.components?.[m.component] || !m.quickReplies && !m.form && m.next && (await B(300), f.current(m.next));
|
|
2091
|
+
};
|
|
2092
|
+
function w(l, b) {
|
|
2093
|
+
return b.next ? b.next : l.asyncAction?.routes?.[b.status] ? l.asyncAction.routes[b.status] : b.status === "success" && l.asyncAction?.onSuccess ? l.asyncAction.onSuccess : b.status === "error" && l.asyncAction?.onError ? l.asyncAction.onError : l.next;
|
|
2094
|
+
}
|
|
2095
|
+
const p = v((l) => f.current(l), []), g = v(() => {
|
|
2096
|
+
const l = n.current;
|
|
2097
|
+
if (!l || !l.canGoBack()) {
|
|
2098
|
+
u("There is no previous step to go back to.");
|
|
2099
|
+
return;
|
|
2100
|
+
}
|
|
2101
|
+
t({ type: "CLEAR_QUICK_REPLIES" });
|
|
2102
|
+
const b = l.popHistory();
|
|
2103
|
+
b ? p(b) : u("There is no previous step to go back to.");
|
|
1111
2104
|
}, [
|
|
1112
|
-
|
|
2105
|
+
t,
|
|
2106
|
+
p,
|
|
2107
|
+
u
|
|
2108
|
+
]), h = v(() => {
|
|
2109
|
+
const l = n.current;
|
|
2110
|
+
l && l.reset(), o.current = !1, t({ type: "RESET_CHAT" }), l && (o.current = !0, p(l.getStartStepId()));
|
|
2111
|
+
}, [t, p]), k = C(() => !1);
|
|
2112
|
+
k.current = (l) => {
|
|
2113
|
+
const b = l.trim().toLowerCase();
|
|
2114
|
+
if (!b.startsWith("/")) return !1;
|
|
2115
|
+
switch (b) {
|
|
2116
|
+
case "/help":
|
|
2117
|
+
return u(`Available commands:
|
|
2118
|
+
${Object.entries(We).map(([m, y]) => `**${m}** — ${y}`).join(`
|
|
2119
|
+
`)}`), !0;
|
|
2120
|
+
case "/cancel":
|
|
2121
|
+
case "/back":
|
|
2122
|
+
return g(), !0;
|
|
2123
|
+
case "/restart":
|
|
2124
|
+
return h(), !0;
|
|
2125
|
+
default:
|
|
2126
|
+
return u(`Unknown command: ${b}. Type /help for available commands.`), !0;
|
|
2127
|
+
}
|
|
2128
|
+
};
|
|
2129
|
+
const D = v((l) => {
|
|
2130
|
+
const b = n.current, m = s.current.currentStepId;
|
|
2131
|
+
if (!b || !m) return;
|
|
2132
|
+
const y = b.getStep(m);
|
|
2133
|
+
if (!y) return;
|
|
2134
|
+
l?.data && (b.mergeData(l.data), t({
|
|
2135
|
+
type: "SET_DATA",
|
|
2136
|
+
payload: l.data
|
|
2137
|
+
})), l?.message && t({
|
|
2138
|
+
type: "ADD_MESSAGE",
|
|
2139
|
+
payload: {
|
|
2140
|
+
id: F(),
|
|
2141
|
+
sender: "bot",
|
|
2142
|
+
text: l.message,
|
|
2143
|
+
timestamp: Date.now()
|
|
2144
|
+
}
|
|
2145
|
+
});
|
|
2146
|
+
const d = l?.next ?? y.next;
|
|
2147
|
+
d ? p(d) : (i.current.callbacks?.onFlowEnd?.(b.getData()), t({
|
|
2148
|
+
type: "SET_STEP",
|
|
2149
|
+
payload: null
|
|
2150
|
+
}));
|
|
2151
|
+
}, [t, p]), R = v((l) => {
|
|
2152
|
+
if (k.current(l)) return;
|
|
2153
|
+
const b = {
|
|
2154
|
+
id: F(),
|
|
2155
|
+
sender: "user",
|
|
2156
|
+
text: l,
|
|
2157
|
+
timestamp: Date.now()
|
|
2158
|
+
};
|
|
2159
|
+
t({
|
|
2160
|
+
type: "ADD_MESSAGE",
|
|
2161
|
+
payload: b
|
|
2162
|
+
}), i.current.callbacks?.onMessageSend?.(b), i.current.callbacks?.onSubmit?.({ message: l });
|
|
2163
|
+
const m = s.current.currentStepId;
|
|
2164
|
+
if (n.current && m) {
|
|
2165
|
+
const y = n.current.getStep(m);
|
|
2166
|
+
if (y) {
|
|
2167
|
+
if (y.asyncAction || y.component) {
|
|
2168
|
+
c("Please wait, I'm still processing. You can type /back to go back.");
|
|
2169
|
+
return;
|
|
2170
|
+
}
|
|
2171
|
+
if (n.current.stepExpectsQuickReply(y)) {
|
|
2172
|
+
const d = n.current.matchQuickReply(y, l);
|
|
2173
|
+
if (d) {
|
|
2174
|
+
t({ type: "CLEAR_QUICK_REPLIES" }), n.current.setData(y.id, d.value);
|
|
2175
|
+
const S = n.current.resolveNext(y, d.value);
|
|
2176
|
+
S ? p(S) : (i.current.callbacks?.onFlowEnd?.(n.current.getData()), t({
|
|
2177
|
+
type: "SET_STEP",
|
|
2178
|
+
payload: null
|
|
2179
|
+
}));
|
|
2180
|
+
} else c("I didn't quite get that. Please choose one of the options below:", { quickReplies: y.quickReplies });
|
|
2181
|
+
} else if (n.current.stepExpectsForm(y)) c("Please fill out the form above to continue.");
|
|
2182
|
+
else {
|
|
2183
|
+
n.current.setData(y.id, l);
|
|
2184
|
+
const d = n.current.resolveNext(y, l);
|
|
2185
|
+
d ? p(d) : (c("Thanks for your message! Our team will get back to you soon. 🙌"), i.current.callbacks?.onFlowEnd?.(n.current.getData()), t({
|
|
2186
|
+
type: "SET_STEP",
|
|
2187
|
+
payload: null
|
|
2188
|
+
}));
|
|
2189
|
+
}
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
}, [
|
|
2193
|
+
t,
|
|
2194
|
+
c,
|
|
2195
|
+
p
|
|
2196
|
+
]), T = v(() => {
|
|
2197
|
+
const l = n.current;
|
|
2198
|
+
!l || o.current || (o.current = !0, p(l.getStartStepId()));
|
|
2199
|
+
}, [p]);
|
|
2200
|
+
return A(() => {
|
|
2201
|
+
r.flow && !e.showWelcome && e.isLoggedIn && !o.current && T();
|
|
2202
|
+
}, [
|
|
2203
|
+
r.flow,
|
|
1113
2204
|
e.showWelcome,
|
|
1114
2205
|
e.isLoggedIn,
|
|
1115
|
-
|
|
2206
|
+
T
|
|
1116
2207
|
]), {
|
|
1117
2208
|
state: e,
|
|
1118
|
-
sendMessage:
|
|
1119
|
-
addBotMessage:
|
|
1120
|
-
handleQuickReply:
|
|
1121
|
-
|
|
2209
|
+
sendMessage: R,
|
|
2210
|
+
addBotMessage: c,
|
|
2211
|
+
handleQuickReply: v((l, b) => {
|
|
2212
|
+
t({ type: "CLEAR_QUICK_REPLIES" }), t({
|
|
1122
2213
|
type: "ADD_MESSAGE",
|
|
1123
2214
|
payload: {
|
|
1124
|
-
id:
|
|
2215
|
+
id: F(),
|
|
1125
2216
|
sender: "user",
|
|
1126
|
-
text:
|
|
2217
|
+
text: b,
|
|
1127
2218
|
timestamp: Date.now()
|
|
1128
2219
|
}
|
|
1129
|
-
}),
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
2220
|
+
}), i.current.callbacks?.onQuickReply?.(l, b);
|
|
2221
|
+
const m = s.current.currentStepId;
|
|
2222
|
+
if (n.current && m) {
|
|
2223
|
+
const y = n.current.getStep(m);
|
|
2224
|
+
if (y) {
|
|
2225
|
+
n.current.setData(y.id, l);
|
|
2226
|
+
const d = n.current.resolveNext(y, l);
|
|
2227
|
+
d ? p(d) : (i.current.callbacks?.onFlowEnd?.(n.current.getData()), t({
|
|
1135
2228
|
type: "SET_STEP",
|
|
1136
2229
|
payload: null
|
|
1137
2230
|
}));
|
|
1138
2231
|
}
|
|
1139
2232
|
}
|
|
1140
|
-
}, [
|
|
1141
|
-
|
|
1142
|
-
n.callbacks,
|
|
1143
|
-
e.currentStepId,
|
|
1144
|
-
l
|
|
1145
|
-
]),
|
|
1146
|
-
handleFormSubmit: y(async (x, p) => {
|
|
2233
|
+
}, [t, p]),
|
|
2234
|
+
handleFormSubmit: v(async (l, b) => {
|
|
1147
2235
|
t({
|
|
1148
2236
|
type: "SET_DATA",
|
|
1149
|
-
payload:
|
|
1150
|
-
}),
|
|
1151
|
-
const
|
|
2237
|
+
payload: b
|
|
2238
|
+
}), n.current && n.current.mergeData(b);
|
|
2239
|
+
const m = Object.entries(b).filter(([, d]) => d !== void 0 && d !== "").map(([d, S]) => `${d}: ${String(S)}`).join(`
|
|
1152
2240
|
`);
|
|
1153
|
-
|
|
2241
|
+
t({
|
|
1154
2242
|
type: "ADD_MESSAGE",
|
|
1155
2243
|
payload: {
|
|
1156
|
-
id:
|
|
2244
|
+
id: F(),
|
|
1157
2245
|
sender: "user",
|
|
1158
|
-
text:
|
|
1159
|
-
formData:
|
|
2246
|
+
text: m,
|
|
2247
|
+
formData: b,
|
|
1160
2248
|
timestamp: Date.now()
|
|
1161
2249
|
}
|
|
1162
|
-
}), await
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
2250
|
+
}), await i.current.callbacks?.onFormSubmit?.(l, b);
|
|
2251
|
+
const y = s.current.currentStepId;
|
|
2252
|
+
if (n.current && y) {
|
|
2253
|
+
const d = n.current.getStep(y);
|
|
2254
|
+
if (d) {
|
|
2255
|
+
const S = n.current.resolveNext(d);
|
|
2256
|
+
S ? p(S) : (i.current.callbacks?.onFlowEnd?.(n.current.getData()), t({
|
|
1167
2257
|
type: "SET_STEP",
|
|
1168
2258
|
payload: null
|
|
1169
2259
|
}));
|
|
1170
2260
|
}
|
|
1171
2261
|
}
|
|
1172
|
-
}, [
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
e.currentStepId,
|
|
1176
|
-
l
|
|
1177
|
-
]),
|
|
1178
|
-
handleLogin: y(async (x) => {
|
|
1179
|
-
await n.callbacks?.onLogin?.(x), t({
|
|
2262
|
+
}, [t, p]),
|
|
2263
|
+
handleLogin: v(async (l) => {
|
|
2264
|
+
await i.current.callbacks?.onLogin?.(l), t({
|
|
1180
2265
|
type: "SET_LOGGED_IN",
|
|
1181
2266
|
payload: !0
|
|
1182
2267
|
});
|
|
1183
|
-
}, [t
|
|
1184
|
-
toggleChat:
|
|
1185
|
-
const
|
|
1186
|
-
t({ type: "TOGGLE_OPEN" }),
|
|
1187
|
-
}, [
|
|
1188
|
-
|
|
1189
|
-
e.isOpen,
|
|
1190
|
-
n.callbacks
|
|
1191
|
-
]),
|
|
1192
|
-
dismissWelcome: y(() => {
|
|
2268
|
+
}, [t]),
|
|
2269
|
+
toggleChat: v(() => {
|
|
2270
|
+
const l = !s.current.isOpen;
|
|
2271
|
+
t({ type: "TOGGLE_OPEN" }), l ? i.current.callbacks?.onOpen?.() : i.current.callbacks?.onClose?.();
|
|
2272
|
+
}, [t]),
|
|
2273
|
+
dismissWelcome: v(() => {
|
|
1193
2274
|
t({ type: "DISMISS_WELCOME" });
|
|
1194
2275
|
}, [t]),
|
|
1195
|
-
startFlow:
|
|
1196
|
-
processFlowStep:
|
|
2276
|
+
startFlow: T,
|
|
2277
|
+
processFlowStep: p,
|
|
2278
|
+
goBack: g,
|
|
2279
|
+
restartSession: h,
|
|
2280
|
+
handleComponentComplete: D
|
|
1197
2281
|
};
|
|
1198
2282
|
}
|
|
1199
|
-
var
|
|
1200
|
-
const { props:
|
|
1201
|
-
bottom: "
|
|
1202
|
-
left: "
|
|
2283
|
+
var je = ({ styles: e, position: t, zIndex: r, hidden: n }) => {
|
|
2284
|
+
const { props: o, dispatch: s } = j(), i = O(o.theme), c = i.mode === "dark", { state: u, sendMessage: f, handleQuickReply: w, handleFormSubmit: p, handleLogin: g, toggleChat: h, dismissWelcome: k, restartSession: D, handleComponentComplete: R } = $e(), T = t === "bottom-left" ? {
|
|
2285
|
+
bottom: "96px",
|
|
2286
|
+
left: "24px"
|
|
1203
2287
|
} : {
|
|
1204
|
-
bottom: "
|
|
1205
|
-
right: "
|
|
1206
|
-
}
|
|
1207
|
-
|
|
2288
|
+
bottom: "96px",
|
|
2289
|
+
right: "24px"
|
|
2290
|
+
}, l = v((d, S) => {
|
|
2291
|
+
if (S && S.length > 0) {
|
|
2292
|
+
const M = S.map((E) => ({
|
|
2293
|
+
name: E.name,
|
|
2294
|
+
url: URL.createObjectURL(E),
|
|
2295
|
+
type: E.type,
|
|
2296
|
+
size: E.size
|
|
2297
|
+
}));
|
|
2298
|
+
d ? (s({
|
|
2299
|
+
type: "ADD_MESSAGE",
|
|
2300
|
+
payload: {
|
|
2301
|
+
id: F(),
|
|
2302
|
+
sender: "user",
|
|
2303
|
+
text: d,
|
|
2304
|
+
timestamp: Date.now(),
|
|
2305
|
+
attachments: M
|
|
2306
|
+
}
|
|
2307
|
+
}), f(d)) : s({
|
|
2308
|
+
type: "ADD_MESSAGE",
|
|
2309
|
+
payload: {
|
|
2310
|
+
id: F(),
|
|
2311
|
+
sender: "user",
|
|
2312
|
+
timestamp: Date.now(),
|
|
2313
|
+
attachments: M
|
|
2314
|
+
}
|
|
2315
|
+
}), o.callbacks?.onFileUpload?.(S);
|
|
2316
|
+
} else d && f(d);
|
|
2317
|
+
}, [
|
|
2318
|
+
f,
|
|
2319
|
+
s,
|
|
2320
|
+
o.callbacks
|
|
2321
|
+
]), b = U(() => ({
|
|
2322
|
+
currentStepId: u.currentStepId,
|
|
2323
|
+
isOpen: u.isOpen,
|
|
2324
|
+
messages: u.messages,
|
|
2325
|
+
collectedData: u.collectedData,
|
|
2326
|
+
toggleChat: h,
|
|
2327
|
+
restartSession: D,
|
|
2328
|
+
sendMessage: f
|
|
2329
|
+
}), [
|
|
2330
|
+
u.currentStepId,
|
|
2331
|
+
u.isOpen,
|
|
2332
|
+
u.messages,
|
|
2333
|
+
u.collectedData,
|
|
2334
|
+
h,
|
|
2335
|
+
D,
|
|
2336
|
+
f
|
|
2337
|
+
]), m = /* @__PURE__ */ a(pe, {
|
|
2338
|
+
config: o.header ?? { title: "Chat with us" },
|
|
2339
|
+
styles: e,
|
|
2340
|
+
onClose: h,
|
|
2341
|
+
onRestart: D,
|
|
2342
|
+
logo: o.branding?.logo,
|
|
2343
|
+
logoWidth: o.branding?.logoWidth
|
|
2344
|
+
}), y = /* @__PURE__ */ a(Me, {
|
|
2345
|
+
onSend: l,
|
|
2346
|
+
placeholder: o.inputPlaceholder,
|
|
2347
|
+
primaryColor: i.primaryColor,
|
|
2348
|
+
isDark: c,
|
|
2349
|
+
enableEmoji: o.enableEmoji,
|
|
2350
|
+
fileUpload: o.fileUpload,
|
|
2351
|
+
onFileUpload: o.callbacks?.onFileUpload
|
|
2352
|
+
});
|
|
2353
|
+
return n ? /* @__PURE__ */ a("div", { style: { display: "none" } }) : /* @__PURE__ */ x("div", {
|
|
1208
2354
|
style: {
|
|
1209
2355
|
...e.window,
|
|
1210
|
-
...
|
|
1211
|
-
...
|
|
2356
|
+
...T,
|
|
2357
|
+
...r != null ? { zIndex: r } : {}
|
|
1212
2358
|
},
|
|
1213
|
-
children: [/* @__PURE__ */
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
onClose: p
|
|
1217
|
-
}), s.showWelcome && r.welcomeScreen ? /* @__PURE__ */ o(P, {
|
|
1218
|
-
content: r.welcomeScreen,
|
|
1219
|
-
onDismiss: h,
|
|
2359
|
+
children: [o.renderHeader ? o.renderHeader(b, m) : m, u.showWelcome && o.welcomeScreen ? /* @__PURE__ */ a(ue, {
|
|
2360
|
+
content: o.welcomeScreen,
|
|
2361
|
+
onDismiss: k,
|
|
1220
2362
|
primaryColor: i.primaryColor
|
|
1221
|
-
}) : !
|
|
1222
|
-
config:
|
|
1223
|
-
onLogin:
|
|
2363
|
+
}) : !u.isLoggedIn && o.loginForm ? /* @__PURE__ */ a(ke, {
|
|
2364
|
+
config: o.loginForm,
|
|
2365
|
+
onLogin: g,
|
|
1224
2366
|
primaryColor: i.primaryColor
|
|
1225
|
-
}) : /* @__PURE__ */
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
2367
|
+
}) : /* @__PURE__ */ x(K, { children: [
|
|
2368
|
+
/* @__PURE__ */ a(Fe, {
|
|
2369
|
+
messages: u.messages,
|
|
2370
|
+
isTyping: u.isTyping,
|
|
2371
|
+
styles: e,
|
|
2372
|
+
primaryColor: i.primaryColor,
|
|
2373
|
+
onQuickReply: w,
|
|
2374
|
+
onFormSubmit: p,
|
|
2375
|
+
components: o.components,
|
|
2376
|
+
onComponentComplete: R,
|
|
2377
|
+
collectedData: u.collectedData,
|
|
2378
|
+
currentStepId: u.currentStepId
|
|
2379
|
+
}),
|
|
2380
|
+
/* @__PURE__ */ a("div", {
|
|
2381
|
+
style: e.inputArea,
|
|
2382
|
+
children: o.renderInput ? o.renderInput(b, y) : y
|
|
2383
|
+
}),
|
|
2384
|
+
o.branding && /* @__PURE__ */ a(Le, {
|
|
2385
|
+
config: o.branding,
|
|
1237
2386
|
primaryColor: i.primaryColor
|
|
1238
2387
|
})
|
|
1239
|
-
|
|
2388
|
+
] })]
|
|
1240
2389
|
});
|
|
1241
|
-
},
|
|
1242
|
-
|
|
1243
|
-
|
|
2390
|
+
}, Oe = class {
|
|
2391
|
+
constructor() {
|
|
2392
|
+
this.plugins = [], this.context = null, this.eventHandlers = /* @__PURE__ */ new Map();
|
|
2393
|
+
}
|
|
2394
|
+
register(e) {
|
|
2395
|
+
this.plugins = [...e];
|
|
2396
|
+
}
|
|
2397
|
+
setContext(e) {
|
|
2398
|
+
this.context = {
|
|
2399
|
+
...e,
|
|
2400
|
+
on: (t, r) => this.on(t, r),
|
|
2401
|
+
emit: (t, ...r) => this.emit(t, ...r)
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2404
|
+
on(e, t) {
|
|
2405
|
+
this.eventHandlers.has(e) || this.eventHandlers.set(e, /* @__PURE__ */ new Set()), this.eventHandlers.get(e).add(t);
|
|
2406
|
+
}
|
|
2407
|
+
emit(e, ...t) {
|
|
2408
|
+
const r = this.eventHandlers.get(e);
|
|
2409
|
+
r && r.forEach((n) => n(...t));
|
|
2410
|
+
}
|
|
2411
|
+
async init() {
|
|
2412
|
+
if (this.context)
|
|
2413
|
+
for (const e of this.plugins) try {
|
|
2414
|
+
await e.onInit?.(this.context);
|
|
2415
|
+
} catch (t) {
|
|
2416
|
+
console.error(`[Plugin:${e.name}] onInit error:`, t);
|
|
2417
|
+
}
|
|
2418
|
+
}
|
|
2419
|
+
async onMessage(e) {
|
|
2420
|
+
if (!this.context) return e;
|
|
2421
|
+
let t = e;
|
|
2422
|
+
for (const r of this.plugins) try {
|
|
2423
|
+
const n = await r.onMessage?.(t, this.context);
|
|
2424
|
+
n && typeof n == "object" && "id" in n && (t = n);
|
|
2425
|
+
} catch (n) {
|
|
2426
|
+
console.error(`[Plugin:${r.name}] onMessage error:`, n);
|
|
2427
|
+
}
|
|
2428
|
+
return this.dispatchEvent({
|
|
2429
|
+
type: "message",
|
|
2430
|
+
payload: t,
|
|
2431
|
+
timestamp: Date.now()
|
|
2432
|
+
}), t;
|
|
2433
|
+
}
|
|
2434
|
+
async onSubmit(e) {
|
|
2435
|
+
if (this.context) {
|
|
2436
|
+
for (const t of this.plugins) try {
|
|
2437
|
+
await t.onSubmit?.(e, this.context);
|
|
2438
|
+
} catch (r) {
|
|
2439
|
+
console.error(`[Plugin:${t.name}] onSubmit error:`, r);
|
|
2440
|
+
}
|
|
2441
|
+
this.dispatchEvent({
|
|
2442
|
+
type: "submit",
|
|
2443
|
+
payload: e,
|
|
2444
|
+
timestamp: Date.now()
|
|
2445
|
+
});
|
|
2446
|
+
}
|
|
2447
|
+
}
|
|
2448
|
+
async destroy() {
|
|
2449
|
+
if (this.context) {
|
|
2450
|
+
for (const e of this.plugins) try {
|
|
2451
|
+
await e.onDestroy?.(this.context);
|
|
2452
|
+
} catch (t) {
|
|
2453
|
+
console.error(`[Plugin:${e.name}] onDestroy error:`, t);
|
|
2454
|
+
}
|
|
2455
|
+
this.eventHandlers.clear(), this.plugins = [];
|
|
2456
|
+
}
|
|
2457
|
+
}
|
|
2458
|
+
dispatchEvent(e) {
|
|
2459
|
+
if (this.context)
|
|
2460
|
+
for (const t of this.plugins) try {
|
|
2461
|
+
t.onEvent?.(e, this.context);
|
|
2462
|
+
} catch (r) {
|
|
2463
|
+
console.error(`[Plugin:${t.name}] onEvent error:`, r);
|
|
2464
|
+
}
|
|
2465
|
+
}
|
|
2466
|
+
}, Pe = `
|
|
2467
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
2468
|
+
|
|
2469
|
+
@keyframes cb-window-enter {
|
|
2470
|
+
0% { opacity: 0; transform: translateY(16px) scale(0.96); }
|
|
2471
|
+
100% { opacity: 1; transform: translateY(0) scale(1); }
|
|
2472
|
+
}
|
|
2473
|
+
|
|
2474
|
+
@keyframes cb-launcher-pulse {
|
|
2475
|
+
0%, 100% { box-shadow: 0 6px 24px rgba(108, 92, 231, 0.4), 0 2px 8px rgba(0,0,0,0.1); }
|
|
2476
|
+
50% { box-shadow: 0 8px 32px rgba(108, 92, 231, 0.55), 0 4px 12px rgba(0,0,0,0.15); }
|
|
2477
|
+
}
|
|
2478
|
+
|
|
2479
|
+
@keyframes cb-fade-in {
|
|
2480
|
+
0% { opacity: 0; transform: translateY(6px); }
|
|
2481
|
+
100% { opacity: 1; transform: translateY(0); }
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2484
|
+
@keyframes cb-typing-bounce {
|
|
2485
|
+
0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
|
|
2486
|
+
40% { transform: scale(1); opacity: 1; }
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
@keyframes cb-slide-up {
|
|
2490
|
+
0% { opacity: 0; transform: translateY(10px); }
|
|
2491
|
+
100% { opacity: 1; transform: translateY(0); }
|
|
2492
|
+
}
|
|
2493
|
+
|
|
2494
|
+
.cb-scrollbar::-webkit-scrollbar {
|
|
2495
|
+
width: 5px;
|
|
2496
|
+
}
|
|
2497
|
+
.cb-scrollbar::-webkit-scrollbar-track {
|
|
2498
|
+
background: transparent;
|
|
2499
|
+
}
|
|
2500
|
+
.cb-scrollbar::-webkit-scrollbar-thumb {
|
|
2501
|
+
background: rgba(108, 92, 231, 0.2);
|
|
2502
|
+
border-radius: 10px;
|
|
2503
|
+
}
|
|
2504
|
+
.cb-scrollbar::-webkit-scrollbar-thumb:hover {
|
|
2505
|
+
background: rgba(108, 92, 231, 0.35);
|
|
2506
|
+
}
|
|
2507
|
+
`, L = !1;
|
|
2508
|
+
function Ge() {
|
|
2509
|
+
if (L || typeof document > "u") return;
|
|
2510
|
+
if (document.querySelector("style[data-chatbot-styles]")) {
|
|
2511
|
+
L = !0;
|
|
2512
|
+
return;
|
|
2513
|
+
}
|
|
2514
|
+
const e = document.createElement("style");
|
|
2515
|
+
e.setAttribute("data-chatbot-styles", ""), e.textContent = Pe, document.head.appendChild(e), L = !0;
|
|
2516
|
+
}
|
|
2517
|
+
var Ne = (e) => {
|
|
2518
|
+
const [t, r] = Q(J, e, V), n = O(e.theme), o = te(n, e.style), s = ee(n), i = e.position ?? "bottom-right", c = e.showLauncher !== !1, u = C(null), f = C(t);
|
|
2519
|
+
f.current = t, A(() => {
|
|
2520
|
+
Ge();
|
|
2521
|
+
}, []), A(() => {
|
|
2522
|
+
if (e.plugins && e.plugins.length > 0) {
|
|
2523
|
+
const p = new Oe();
|
|
2524
|
+
return p.register(e.plugins), p.setContext({
|
|
2525
|
+
sendMessage: (g) => {
|
|
2526
|
+
r({
|
|
2527
|
+
type: "ADD_MESSAGE",
|
|
2528
|
+
payload: {
|
|
2529
|
+
id: F(),
|
|
2530
|
+
sender: "user",
|
|
2531
|
+
text: g,
|
|
2532
|
+
timestamp: Date.now()
|
|
2533
|
+
}
|
|
2534
|
+
});
|
|
2535
|
+
},
|
|
2536
|
+
addBotMessage: (g) => {
|
|
2537
|
+
r({
|
|
2538
|
+
type: "ADD_MESSAGE",
|
|
2539
|
+
payload: {
|
|
2540
|
+
id: F(),
|
|
2541
|
+
sender: "bot",
|
|
2542
|
+
text: g,
|
|
2543
|
+
timestamp: Date.now()
|
|
2544
|
+
}
|
|
2545
|
+
});
|
|
2546
|
+
},
|
|
2547
|
+
getMessages: () => f.current.messages,
|
|
2548
|
+
getData: () => f.current.collectedData,
|
|
2549
|
+
setData: (g, h) => r({
|
|
2550
|
+
type: "SET_DATA",
|
|
2551
|
+
payload: { [g]: h }
|
|
2552
|
+
})
|
|
2553
|
+
}), p.init(), u.current = p, () => {
|
|
2554
|
+
p.destroy();
|
|
2555
|
+
};
|
|
2556
|
+
}
|
|
2557
|
+
}, [e.plugins]);
|
|
2558
|
+
const w = v(() => {
|
|
2559
|
+
const p = !t.isOpen;
|
|
2560
|
+
r({ type: "TOGGLE_OPEN" }), p ? e.callbacks?.onOpen?.() : e.callbacks?.onClose?.();
|
|
2561
|
+
}, [t.isOpen, e.callbacks]);
|
|
2562
|
+
return /* @__PURE__ */ a($.Provider, {
|
|
1244
2563
|
value: {
|
|
1245
2564
|
state: t,
|
|
1246
|
-
dispatch:
|
|
2565
|
+
dispatch: r,
|
|
1247
2566
|
props: e
|
|
1248
2567
|
},
|
|
1249
|
-
children: /* @__PURE__ */
|
|
1250
|
-
style:
|
|
2568
|
+
children: /* @__PURE__ */ x("div", {
|
|
2569
|
+
style: {
|
|
2570
|
+
...o.root,
|
|
2571
|
+
...s
|
|
2572
|
+
},
|
|
1251
2573
|
className: e.className,
|
|
1252
|
-
children: [
|
|
1253
|
-
styles:
|
|
2574
|
+
children: [/* @__PURE__ */ a(je, {
|
|
2575
|
+
styles: o,
|
|
1254
2576
|
position: i,
|
|
1255
|
-
zIndex: e.zIndex
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
n({ type: "TOGGLE_OPEN" }), u ? e.callbacks?.onOpen?.() : e.callbacks?.onClose?.();
|
|
1260
|
-
},
|
|
2577
|
+
zIndex: e.zIndex,
|
|
2578
|
+
hidden: !t.isOpen
|
|
2579
|
+
}), c && /* @__PURE__ */ a(de, {
|
|
2580
|
+
onClick: w,
|
|
1261
2581
|
isOpen: t.isOpen,
|
|
1262
2582
|
position: i,
|
|
1263
|
-
styles:
|
|
2583
|
+
styles: o,
|
|
1264
2584
|
icon: e.launcherIcon,
|
|
1265
2585
|
closeIcon: e.closeIcon,
|
|
1266
2586
|
zIndex: e.zIndex
|
|
@@ -1268,28 +2588,138 @@ var ie = ({ styles: e, position: t, zIndex: n }) => {
|
|
|
1268
2588
|
})
|
|
1269
2589
|
});
|
|
1270
2590
|
};
|
|
2591
|
+
function Ye(e) {
|
|
2592
|
+
let t = 0, r = 0;
|
|
2593
|
+
return {
|
|
2594
|
+
name: "analytics",
|
|
2595
|
+
onInit(n) {
|
|
2596
|
+
t = 0, r = 0, e?.onTrack?.("chatbot:init");
|
|
2597
|
+
},
|
|
2598
|
+
onMessage(n, o) {
|
|
2599
|
+
t++, e?.onTrack?.("chatbot:message", {
|
|
2600
|
+
sender: n.sender,
|
|
2601
|
+
messageCount: t
|
|
2602
|
+
});
|
|
2603
|
+
},
|
|
2604
|
+
onSubmit(n, o) {
|
|
2605
|
+
r++, e?.onTrack?.("chatbot:submit", {
|
|
2606
|
+
formSubmissions: r,
|
|
2607
|
+
fields: Object.keys(n)
|
|
2608
|
+
});
|
|
2609
|
+
},
|
|
2610
|
+
onDestroy() {
|
|
2611
|
+
e?.onTrack?.("chatbot:destroy", {
|
|
2612
|
+
totalMessages: t,
|
|
2613
|
+
totalFormSubmissions: r
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
};
|
|
2617
|
+
}
|
|
2618
|
+
function Ue(e) {
|
|
2619
|
+
const t = e.events ?? ["message", "submit"], r = async (n, o) => {
|
|
2620
|
+
try {
|
|
2621
|
+
await fetch(e.url, {
|
|
2622
|
+
method: "POST",
|
|
2623
|
+
headers: {
|
|
2624
|
+
"Content-Type": "application/json",
|
|
2625
|
+
...e.headers
|
|
2626
|
+
},
|
|
2627
|
+
body: JSON.stringify({
|
|
2628
|
+
type: n,
|
|
2629
|
+
payload: o,
|
|
2630
|
+
timestamp: Date.now()
|
|
2631
|
+
})
|
|
2632
|
+
});
|
|
2633
|
+
} catch (s) {
|
|
2634
|
+
console.error(`[webhook] Failed to send ${n}:`, s);
|
|
2635
|
+
}
|
|
2636
|
+
};
|
|
2637
|
+
return {
|
|
2638
|
+
name: "webhook",
|
|
2639
|
+
async onInit() {
|
|
2640
|
+
t.includes("init") && await r("init", {});
|
|
2641
|
+
},
|
|
2642
|
+
async onMessage(n) {
|
|
2643
|
+
t.includes("message") && await r("message", n);
|
|
2644
|
+
},
|
|
2645
|
+
async onSubmit(n) {
|
|
2646
|
+
t.includes("submit") && await r("submit", n);
|
|
2647
|
+
},
|
|
2648
|
+
async onDestroy() {
|
|
2649
|
+
t.includes("destroy") && await r("destroy", {});
|
|
2650
|
+
}
|
|
2651
|
+
};
|
|
2652
|
+
}
|
|
2653
|
+
function Qe(e) {
|
|
2654
|
+
const t = e?.storageKey ?? "chatbot_history", r = e?.storage === "session" ? sessionStorage : localStorage;
|
|
2655
|
+
return {
|
|
2656
|
+
name: "persistence",
|
|
2657
|
+
onInit(n) {
|
|
2658
|
+
try {
|
|
2659
|
+
const o = r.getItem(t);
|
|
2660
|
+
if (o) {
|
|
2661
|
+
const s = JSON.parse(o);
|
|
2662
|
+
Array.isArray(s) && s.forEach((i) => {
|
|
2663
|
+
i.sender === "bot" && n.addBotMessage(i.text);
|
|
2664
|
+
});
|
|
2665
|
+
}
|
|
2666
|
+
} catch {
|
|
2667
|
+
}
|
|
2668
|
+
},
|
|
2669
|
+
onMessage(n, o) {
|
|
2670
|
+
try {
|
|
2671
|
+
const s = o.getMessages();
|
|
2672
|
+
r.setItem(t, JSON.stringify(s.slice(-50)));
|
|
2673
|
+
} catch {
|
|
2674
|
+
}
|
|
2675
|
+
},
|
|
2676
|
+
onDestroy() {
|
|
2677
|
+
}
|
|
2678
|
+
};
|
|
2679
|
+
}
|
|
1271
2680
|
export {
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
2681
|
+
ie as AttachmentIcon,
|
|
2682
|
+
Le as Branding,
|
|
2683
|
+
Ne as ChatBot,
|
|
2684
|
+
ne as ChatBubbleIcon,
|
|
2685
|
+
$ as ChatContext,
|
|
2686
|
+
pe as ChatHeader,
|
|
2687
|
+
Me as ChatInput,
|
|
2688
|
+
je as ChatWindow,
|
|
2689
|
+
me as CheckboxField,
|
|
2690
|
+
P as CloseIcon,
|
|
2691
|
+
H as DynamicForm,
|
|
2692
|
+
oe as EmojiIcon,
|
|
2693
|
+
Te as EmojiPicker,
|
|
2694
|
+
G as FileIcon,
|
|
2695
|
+
Re as FilePreviewList,
|
|
2696
|
+
Ie as FileUploadButton,
|
|
2697
|
+
ye as FileUploadField,
|
|
2698
|
+
ze as FlowEngine,
|
|
2699
|
+
se as ImageIcon,
|
|
2700
|
+
de as Launcher,
|
|
2701
|
+
ke as LoginScreen,
|
|
2702
|
+
we as MessageBubble,
|
|
2703
|
+
Fe as MessageList,
|
|
2704
|
+
ae as MinimizeIcon,
|
|
2705
|
+
Oe as PluginManager,
|
|
2706
|
+
Ce as QuickReplies,
|
|
2707
|
+
he as RadioField,
|
|
2708
|
+
le as RemoveIcon,
|
|
2709
|
+
ce as RestartIcon,
|
|
2710
|
+
xe as SelectField,
|
|
2711
|
+
re as SendIcon,
|
|
2712
|
+
be as TextField,
|
|
2713
|
+
De as TypingIndicator,
|
|
2714
|
+
ue as WelcomeScreen,
|
|
2715
|
+
Ye as analyticsPlugin,
|
|
2716
|
+
ee as buildCSSVariables,
|
|
2717
|
+
te as buildStyles,
|
|
2718
|
+
Qe as persistencePlugin,
|
|
2719
|
+
O as resolveTheme,
|
|
2720
|
+
$e as useChat,
|
|
2721
|
+
j as useChatContext,
|
|
2722
|
+
Ue as webhookPlugin
|
|
1293
2723
|
};
|
|
1294
2724
|
|
|
1295
2725
|
//# sourceMappingURL=index.mjs.map
|