@jrapps/my_tickets_chat_ui 0.1.1 → 0.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.
Files changed (87) hide show
  1. package/dist/cjs/components/SiteChatComponent/index.js +1 -1
  2. package/dist/cjs/components/SiteChatComponent/index.js.map +2 -2
  3. package/dist/cjs/components/SiteChatComponentNew/index.js +1280 -0
  4. package/dist/cjs/components/SiteChatComponentNew/index.js.map +7 -0
  5. package/dist/cjs/index.js +1247 -2
  6. package/dist/cjs/index.js.map +4 -4
  7. package/dist/esm/chunks/{chunk-XNTJKZD3.js → chunk-QPJPV2T3.js} +2 -2
  8. package/dist/esm/chunks/chunk-QPJPV2T3.js.map +7 -0
  9. package/dist/esm/chunks/chunk-TWW7V724.js +1248 -0
  10. package/dist/esm/chunks/chunk-TWW7V724.js.map +7 -0
  11. package/dist/esm/components/SiteChatComponent/index.js +1 -1
  12. package/dist/esm/components/SiteChatComponentNew/index.js +9 -0
  13. package/dist/esm/components/SiteChatComponentNew/index.js.map +7 -0
  14. package/dist/esm/index.js +8 -2
  15. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.types.d.ts +1 -18
  16. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.types.d.ts.map +1 -1
  17. package/dist/types/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.d.ts.map +1 -1
  18. package/dist/types/components/SiteChatComponentNew/Footer/Footer.d.ts +6 -0
  19. package/dist/types/components/SiteChatComponentNew/Footer/Footer.d.ts.map +1 -0
  20. package/dist/types/components/SiteChatComponentNew/Footer/index.d.ts +2 -0
  21. package/dist/types/components/SiteChatComponentNew/Footer/index.d.ts.map +1 -0
  22. package/dist/types/components/SiteChatComponentNew/Header/Header.d.ts +6 -0
  23. package/dist/types/components/SiteChatComponentNew/Header/Header.d.ts.map +1 -0
  24. package/dist/types/components/SiteChatComponentNew/Header/index.d.ts +2 -0
  25. package/dist/types/components/SiteChatComponentNew/Header/index.d.ts.map +1 -0
  26. package/dist/types/components/SiteChatComponentNew/Messages/AgentMessage.d.ts +9 -0
  27. package/dist/types/components/SiteChatComponentNew/Messages/AgentMessage.d.ts.map +1 -0
  28. package/dist/types/components/SiteChatComponentNew/Messages/AttachmentMessage.d.ts +9 -0
  29. package/dist/types/components/SiteChatComponentNew/Messages/AttachmentMessage.d.ts.map +1 -0
  30. package/dist/types/components/SiteChatComponentNew/Messages/MessageList.d.ts +9 -0
  31. package/dist/types/components/SiteChatComponentNew/Messages/MessageList.d.ts.map +1 -0
  32. package/dist/types/components/SiteChatComponentNew/Messages/MessageRenderer.d.ts +8 -0
  33. package/dist/types/components/SiteChatComponentNew/Messages/MessageRenderer.d.ts.map +1 -0
  34. package/dist/types/components/SiteChatComponentNew/Messages/SystemMessage.d.ts +9 -0
  35. package/dist/types/components/SiteChatComponentNew/Messages/SystemMessage.d.ts.map +1 -0
  36. package/dist/types/components/SiteChatComponentNew/Messages/TypingIndicator.d.ts +5 -0
  37. package/dist/types/components/SiteChatComponentNew/Messages/TypingIndicator.d.ts.map +1 -0
  38. package/dist/types/components/SiteChatComponentNew/Messages/UserMessage.d.ts +9 -0
  39. package/dist/types/components/SiteChatComponentNew/Messages/UserMessage.d.ts.map +1 -0
  40. package/dist/types/components/SiteChatComponentNew/Messages/index.d.ts +8 -0
  41. package/dist/types/components/SiteChatComponentNew/Messages/index.d.ts.map +1 -0
  42. package/dist/types/components/SiteChatComponentNew/OfflineForm/OfflineForm.d.ts +10 -0
  43. package/dist/types/components/SiteChatComponentNew/OfflineForm/OfflineForm.d.ts.map +1 -0
  44. package/dist/types/components/SiteChatComponentNew/OfflineForm/index.d.ts +2 -0
  45. package/dist/types/components/SiteChatComponentNew/OfflineForm/index.d.ts.map +1 -0
  46. package/dist/types/components/SiteChatComponentNew/Shared/Avatar.d.ts +10 -0
  47. package/dist/types/components/SiteChatComponentNew/Shared/Avatar.d.ts.map +1 -0
  48. package/dist/types/components/SiteChatComponentNew/Shared/Button.d.ts +14 -0
  49. package/dist/types/components/SiteChatComponentNew/Shared/Button.d.ts.map +1 -0
  50. package/dist/types/components/SiteChatComponentNew/Shared/index.d.ts +3 -0
  51. package/dist/types/components/SiteChatComponentNew/Shared/index.d.ts.map +1 -0
  52. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.d.ts +5 -0
  53. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.d.ts.map +1 -0
  54. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.types.d.ts +114 -0
  55. package/dist/types/components/SiteChatComponentNew/SiteChatComponentNew.types.d.ts.map +1 -0
  56. package/dist/types/components/SiteChatComponentNew/States/ChatEndedState.d.ts +5 -0
  57. package/dist/types/components/SiteChatComponentNew/States/ChatEndedState.d.ts.map +1 -0
  58. package/dist/types/components/SiteChatComponentNew/States/LoadingState.d.ts +5 -0
  59. package/dist/types/components/SiteChatComponentNew/States/LoadingState.d.ts.map +1 -0
  60. package/dist/types/components/SiteChatComponentNew/States/OfflineState.d.ts +10 -0
  61. package/dist/types/components/SiteChatComponentNew/States/OfflineState.d.ts.map +1 -0
  62. package/dist/types/components/SiteChatComponentNew/States/StartChatState.d.ts +11 -0
  63. package/dist/types/components/SiteChatComponentNew/States/StartChatState.d.ts.map +1 -0
  64. package/dist/types/components/SiteChatComponentNew/States/index.d.ts +5 -0
  65. package/dist/types/components/SiteChatComponentNew/States/index.d.ts.map +1 -0
  66. package/dist/types/components/SiteChatComponentNew/hooks/index.d.ts +3 -0
  67. package/dist/types/components/SiteChatComponentNew/hooks/index.d.ts.map +1 -0
  68. package/dist/types/components/SiteChatComponentNew/hooks/useAutoScroll.d.ts +15 -0
  69. package/dist/types/components/SiteChatComponentNew/hooks/useAutoScroll.d.ts.map +1 -0
  70. package/dist/types/components/SiteChatComponentNew/hooks/useOfflineForm.d.ts +12 -0
  71. package/dist/types/components/SiteChatComponentNew/hooks/useOfflineForm.d.ts.map +1 -0
  72. package/dist/types/components/SiteChatComponentNew/index.d.ts +4 -0
  73. package/dist/types/components/SiteChatComponentNew/index.d.ts.map +1 -0
  74. package/dist/types/components/SiteChatComponentNew/useSiteChatComponentNew.d.ts +3 -0
  75. package/dist/types/components/SiteChatComponentNew/useSiteChatComponentNew.d.ts.map +1 -0
  76. package/dist/types/components/SiteChatComponentNew/utils/format.d.ts +9 -0
  77. package/dist/types/components/SiteChatComponentNew/utils/format.d.ts.map +1 -0
  78. package/dist/types/components/SiteChatComponentNew/utils/index.d.ts +4 -0
  79. package/dist/types/components/SiteChatComponentNew/utils/index.d.ts.map +1 -0
  80. package/dist/types/components/SiteChatComponentNew/utils/systemMessages.d.ts +4 -0
  81. package/dist/types/components/SiteChatComponentNew/utils/systemMessages.d.ts.map +1 -0
  82. package/dist/types/components/SiteChatComponentNew/utils/theme.d.ts +8 -0
  83. package/dist/types/components/SiteChatComponentNew/utils/theme.d.ts.map +1 -0
  84. package/dist/types/components/index.d.ts +1 -0
  85. package/dist/types/components/index.d.ts.map +1 -1
  86. package/package.json +2 -2
  87. package/dist/esm/chunks/chunk-XNTJKZD3.js.map +0 -7
@@ -0,0 +1,1248 @@
1
+ // src/components/SiteChatComponentNew/SiteChatComponentNew.tsx
2
+ import React2 from "react";
3
+
4
+ // src/components/SiteChatComponentNew/useSiteChatComponentNew.ts
5
+ import { useState, useCallback } from "react";
6
+ function useSiteChatComponentNew(defaultOpen = false) {
7
+ const [open, setOpen] = useState(defaultOpen);
8
+ const openWidget = useCallback(() => setOpen(true), []);
9
+ const closeWidget = useCallback(() => setOpen(false), []);
10
+ return { open, openWidget, closeWidget };
11
+ }
12
+
13
+ // src/components/SiteChatComponentNew/utils/theme.ts
14
+ var FONT_FAMILY = "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, sans-serif";
15
+ var FONT_SIZE = "14px";
16
+ var SHADOW = "0 4px 24px rgba(0,0,0,0.12)";
17
+ var WIDTH = "400px";
18
+ var HEIGHT = "600px";
19
+ var HEADER_HEIGHT = "64px";
20
+ var defaultTheme = {
21
+ primary: "#4f46e5",
22
+ background: "#ffffff",
23
+ surface: "#f9fafb",
24
+ border: "#e5e7eb",
25
+ userBubble: "#4f46e5",
26
+ userText: "#ffffff",
27
+ agentBubble: "#f3f4f6",
28
+ agentText: "#111827",
29
+ systemText: "#6b7280",
30
+ inputBackground: "#ffffff",
31
+ inputBorder: "#d1d5db",
32
+ buttonRadius: 8,
33
+ borderRadius: 12
34
+ };
35
+ function buildThemeVars(partial) {
36
+ const theme = { ...defaultTheme, ...partial };
37
+ return {
38
+ // Colours
39
+ "--cw-primary": theme.primary,
40
+ "--cw-background": theme.background,
41
+ "--cw-surface": theme.surface,
42
+ "--cw-border": theme.border,
43
+ "--cw-user-bubble": theme.userBubble,
44
+ "--cw-user-text": theme.userText,
45
+ "--cw-agent-bubble": theme.agentBubble,
46
+ "--cw-agent-text": theme.agentText,
47
+ "--cw-system-text": theme.systemText,
48
+ "--cw-input-background": theme.inputBackground,
49
+ "--cw-input-border": theme.inputBorder,
50
+ // Border radii
51
+ "--cw-button-radius": `${theme.buttonRadius}px`,
52
+ "--cw-border-radius": `${theme.borderRadius}px`,
53
+ // Fixed constants — not exposed as theme props
54
+ "--cw-font-family": FONT_FAMILY,
55
+ "--cw-font-size": FONT_SIZE,
56
+ "--cw-shadow": SHADOW,
57
+ "--cw-width": WIDTH,
58
+ "--cw-height": HEIGHT,
59
+ "--cw-header-height": HEADER_HEIGHT
60
+ };
61
+ }
62
+
63
+ // src/components/SiteChatComponentNew/utils/systemMessages.ts
64
+ var systemEventLabels = {
65
+ AGENT_JOINED: "Agent joined",
66
+ AGENT_LEFT: "Agent left",
67
+ USER_JOINED: "You joined",
68
+ USER_LEFT: "You left",
69
+ CHAT_ENDED: "Chat ended",
70
+ CHAT_REOPENED: "Chat reopened",
71
+ CHAT_TRANSFERRED: "Chat transferred",
72
+ WAITING_FOR_AGENT: "Waiting for an agent"
73
+ };
74
+ function getSystemLabel(event) {
75
+ var _a;
76
+ return (_a = systemEventLabels[event]) != null ? _a : event;
77
+ }
78
+
79
+ // src/components/SiteChatComponentNew/utils/format.ts
80
+ function formatTime(timestamp) {
81
+ return new Date(timestamp).toLocaleTimeString([], {
82
+ hour: "2-digit",
83
+ minute: "2-digit"
84
+ });
85
+ }
86
+
87
+ // src/components/SiteChatComponentNew/Header/Header.css
88
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-45eba566")) {
89
+ const s = document.createElement("style");
90
+ s.id = "jrapps-style-45eba566";
91
+ s.textContent = ".cw-header {\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 0 16px;\n height: var(--cw-header-height);\n background-color: var(--cw-primary);\n color: #ffffff;\n flex-shrink: 0;\n border-radius: var(--cw-border-radius) var(--cw-border-radius) 0 0;\n}\n\n.cw-header__identity {\n display: flex;\n align-items: center;\n gap: 12px;\n min-width: 0;\n}\n\n.cw-header__avatar {\n width: 40px;\n height: 40px;\n border-radius: 50%;\n object-fit: cover;\n flex-shrink: 0;\n border: 2px solid rgba(255, 255, 255, 0.4);\n}\n\n.cw-header__text {\n display: flex;\n flex-direction: column;\n min-width: 0;\n}\n\n.cw-header__title {\n font-size: 15px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n}\n\n.cw-header__subtitle {\n font-size: 12px;\n opacity: 0.85;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n line-height: 1.3;\n}\n\n.cw-header__close {\n background: none;\n border: none;\n cursor: pointer;\n color: #ffffff;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 6px;\n border-radius: 50%;\n flex-shrink: 0;\n transition: background-color 0.15s ease;\n}\n\n.cw-header__close:hover {\n background-color: rgba(255, 255, 255, 0.15);\n}\n\n.cw-header__close:focus-visible {\n outline: 2px solid #ffffff;\n outline-offset: 2px;\n}\n";
92
+ document.head.appendChild(s);
93
+ }
94
+
95
+ // src/components/SiteChatComponentNew/Header/Header.tsx
96
+ import { jsx, jsxs } from "react/jsx-runtime";
97
+ var Header = ({ image, title, subtitle, onClose }) => {
98
+ return /* @__PURE__ */ jsxs("header", { className: "cw-header", role: "banner", children: [
99
+ /* @__PURE__ */ jsxs("div", { className: "cw-header__identity", children: [
100
+ image && /* @__PURE__ */ jsx(
101
+ "img",
102
+ {
103
+ src: image,
104
+ alt: `${title} avatar`,
105
+ className: "cw-header__avatar"
106
+ }
107
+ ),
108
+ /* @__PURE__ */ jsxs("div", { className: "cw-header__text", children: [
109
+ /* @__PURE__ */ jsx("span", { className: "cw-header__title", children: title }),
110
+ subtitle && /* @__PURE__ */ jsx("span", { className: "cw-header__subtitle", children: subtitle })
111
+ ] })
112
+ ] }),
113
+ /* @__PURE__ */ jsx(
114
+ "button",
115
+ {
116
+ className: "cw-header__close",
117
+ onClick: onClose,
118
+ "aria-label": "Close chat",
119
+ type: "button",
120
+ children: /* @__PURE__ */ jsxs(
121
+ "svg",
122
+ {
123
+ xmlns: "http://www.w3.org/2000/svg",
124
+ width: "20",
125
+ height: "20",
126
+ viewBox: "0 0 24 24",
127
+ fill: "none",
128
+ stroke: "currentColor",
129
+ strokeWidth: "2",
130
+ strokeLinecap: "round",
131
+ strokeLinejoin: "round",
132
+ "aria-hidden": "true",
133
+ children: [
134
+ /* @__PURE__ */ jsx("line", { x1: "18", y1: "6", x2: "6", y2: "18" }),
135
+ /* @__PURE__ */ jsx("line", { x1: "6", y1: "6", x2: "18", y2: "18" })
136
+ ]
137
+ }
138
+ )
139
+ }
140
+ )
141
+ ] });
142
+ };
143
+ var Header_default = Header;
144
+
145
+ // src/components/SiteChatComponentNew/Footer/Footer.tsx
146
+ import { useRef, useState as useState2, useCallback as useCallback2 } from "react";
147
+
148
+ // src/components/SiteChatComponentNew/Footer/Footer.css
149
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ebcf221d")) {
150
+ const s = document.createElement("style");
151
+ s.id = "jrapps-style-ebcf221d";
152
+ s.textContent = ".cw-footer {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n padding: 10px 12px;\n background-color: var(--cw-background);\n border-top: 1px solid var(--cw-border);\n flex-shrink: 0;\n}\n\n.cw-footer__input {\n flex: 1;\n resize: none;\n border: 1px solid var(--cw-input-border);\n border-radius: var(--cw-button-radius);\n background-color: var(--cw-input-background);\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n color: inherit;\n padding: 8px 12px;\n line-height: 1.5;\n min-height: 38px;\n max-height: 120px;\n overflow-y: auto;\n transition: border-color 0.15s ease;\n}\n\n.cw-footer__input:focus {\n outline: none;\n border-color: var(--cw-primary);\n box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);\n}\n\n.cw-footer__input:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.cw-footer__attach-btn,\n.cw-footer__send-btn {\n background: none;\n border: none;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 8px;\n border-radius: 50%;\n flex-shrink: 0;\n transition: background-color 0.15s ease, color 0.15s ease;\n color: var(--cw-primary);\n margin-bottom: 1px;\n}\n\n.cw-footer__attach-btn:hover,\n.cw-footer__send-btn:not(.cw-footer__send-btn--disabled):hover {\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n}\n\n.cw-footer__attach-btn:focus-visible,\n.cw-footer__send-btn:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 2px;\n}\n\n.cw-footer__attach-btn:disabled {\n opacity: 0.4;\n cursor: not-allowed;\n}\n\n.cw-footer__send-btn--disabled {\n opacity: 0.35;\n cursor: not-allowed;\n}\n\n.cw-footer__file-input {\n display: none;\n}\n";
153
+ document.head.appendChild(s);
154
+ }
155
+
156
+ // src/components/SiteChatComponentNew/Footer/Footer.tsx
157
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
158
+ var Footer = ({ onSend, onAttachment, disabled }) => {
159
+ const [text, setText] = useState2("");
160
+ const fileInputRef = useRef(null);
161
+ const textareaRef = useRef(null);
162
+ const isEmpty = text.trim().length === 0;
163
+ const handleKeyDown = useCallback2(
164
+ (e) => {
165
+ if (e.key === "Enter" && !e.shiftKey) {
166
+ e.preventDefault();
167
+ if (!isEmpty && !disabled) {
168
+ onSend(text.trim());
169
+ setText("");
170
+ if (textareaRef.current) {
171
+ textareaRef.current.style.height = "auto";
172
+ }
173
+ }
174
+ }
175
+ },
176
+ [isEmpty, disabled, onSend, text]
177
+ );
178
+ const handleSend = useCallback2(() => {
179
+ if (!isEmpty && !disabled) {
180
+ onSend(text.trim());
181
+ setText("");
182
+ if (textareaRef.current) {
183
+ textareaRef.current.style.height = "auto";
184
+ textareaRef.current.focus();
185
+ }
186
+ }
187
+ }, [isEmpty, disabled, onSend, text]);
188
+ const handleChange = useCallback2(
189
+ (e) => {
190
+ setText(e.target.value);
191
+ const el = e.target;
192
+ el.style.height = "auto";
193
+ el.style.height = `${Math.min(el.scrollHeight, 120)}px`;
194
+ },
195
+ []
196
+ );
197
+ const handleAttachmentClick = useCallback2(() => {
198
+ var _a;
199
+ (_a = fileInputRef.current) == null ? void 0 : _a.click();
200
+ }, []);
201
+ const handleFileChange = useCallback2(
202
+ (e) => {
203
+ var _a;
204
+ const file = (_a = e.target.files) == null ? void 0 : _a[0];
205
+ if (file) {
206
+ onAttachment(file);
207
+ }
208
+ if (fileInputRef.current) {
209
+ fileInputRef.current.value = "";
210
+ }
211
+ },
212
+ [onAttachment]
213
+ );
214
+ return /* @__PURE__ */ jsxs2("footer", { className: "cw-footer", role: "contentinfo", children: [
215
+ /* @__PURE__ */ jsx2(
216
+ "button",
217
+ {
218
+ className: "cw-footer__attach-btn",
219
+ onClick: handleAttachmentClick,
220
+ "aria-label": "Attach file",
221
+ type: "button",
222
+ disabled,
223
+ children: /* @__PURE__ */ jsx2(
224
+ "svg",
225
+ {
226
+ xmlns: "http://www.w3.org/2000/svg",
227
+ width: "20",
228
+ height: "20",
229
+ viewBox: "0 0 24 24",
230
+ fill: "none",
231
+ stroke: "currentColor",
232
+ strokeWidth: "2",
233
+ strokeLinecap: "round",
234
+ strokeLinejoin: "round",
235
+ "aria-hidden": "true",
236
+ children: /* @__PURE__ */ jsx2("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48" })
237
+ }
238
+ )
239
+ }
240
+ ),
241
+ /* @__PURE__ */ jsx2(
242
+ "textarea",
243
+ {
244
+ ref: textareaRef,
245
+ className: "cw-footer__input",
246
+ value: text,
247
+ onChange: handleChange,
248
+ onKeyDown: handleKeyDown,
249
+ placeholder: "Type a message\u2026",
250
+ "aria-label": "Message input",
251
+ rows: 1,
252
+ disabled
253
+ }
254
+ ),
255
+ /* @__PURE__ */ jsx2(
256
+ "button",
257
+ {
258
+ className: `cw-footer__send-btn${isEmpty || disabled ? " cw-footer__send-btn--disabled" : ""}`,
259
+ onClick: handleSend,
260
+ "aria-label": "Send message",
261
+ type: "button",
262
+ disabled: isEmpty || disabled,
263
+ children: /* @__PURE__ */ jsx2(
264
+ "svg",
265
+ {
266
+ xmlns: "http://www.w3.org/2000/svg",
267
+ width: "20",
268
+ height: "20",
269
+ viewBox: "0 0 24 24",
270
+ fill: "currentColor",
271
+ "aria-hidden": "true",
272
+ children: /* @__PURE__ */ jsx2("path", { d: "M2.01 21L23 12 2.01 3 2 10l15 2-15 2z" })
273
+ }
274
+ )
275
+ }
276
+ ),
277
+ /* @__PURE__ */ jsx2(
278
+ "input",
279
+ {
280
+ ref: fileInputRef,
281
+ type: "file",
282
+ className: "cw-footer__file-input",
283
+ onChange: handleFileChange,
284
+ "aria-hidden": "true",
285
+ tabIndex: -1
286
+ }
287
+ )
288
+ ] });
289
+ };
290
+ var Footer_default = Footer;
291
+
292
+ // src/components/SiteChatComponentNew/hooks/useAutoScroll.ts
293
+ import { useEffect, useRef as useRef2, useState as useState3 } from "react";
294
+ function useAutoScroll(dependency) {
295
+ const ref = useRef2(null);
296
+ const userScrolledUp = useRef2(false);
297
+ useEffect(() => {
298
+ const el = ref.current;
299
+ if (!el) return;
300
+ const handleScroll = () => {
301
+ const atBottom = el.scrollHeight - el.scrollTop - el.clientHeight < 64;
302
+ userScrolledUp.current = !atBottom;
303
+ };
304
+ el.addEventListener("scroll", handleScroll, { passive: true });
305
+ return () => el.removeEventListener("scroll", handleScroll);
306
+ }, []);
307
+ useEffect(() => {
308
+ const el = ref.current;
309
+ if (!el || userScrolledUp.current) return;
310
+ el.scrollTo({ top: el.scrollHeight, behavior: "smooth" });
311
+ }, [dependency]);
312
+ return ref;
313
+ }
314
+
315
+ // src/components/SiteChatComponentNew/hooks/useOfflineForm.ts
316
+ import { useState as useState4, useCallback as useCallback3 } from "react";
317
+ function validateField(field, value) {
318
+ if (field.required) {
319
+ if (field.type === "checkbox" && !value) {
320
+ return `${field.label} is required.`;
321
+ }
322
+ if (field.type !== "checkbox" && (value === void 0 || value === null || String(value).trim() === "")) {
323
+ return `${field.label} is required.`;
324
+ }
325
+ }
326
+ if (field.type === "email") {
327
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
328
+ if (value && !emailRegex.test(String(value))) {
329
+ return "Please enter a valid email address.";
330
+ }
331
+ }
332
+ if (field.type === "phone") {
333
+ const phoneRegex = /^\+?[\d\s\-().]{7,20}$/;
334
+ if (value && !phoneRegex.test(String(value))) {
335
+ return "Please enter a valid phone number.";
336
+ }
337
+ }
338
+ return "";
339
+ }
340
+ function useOfflineForm(schema) {
341
+ const initialValues = {};
342
+ for (const field of schema.fields) {
343
+ initialValues[field.id] = field.type === "checkbox" ? false : "";
344
+ }
345
+ const [values, setValues] = useState4(initialValues);
346
+ const [errors, setErrors] = useState4({});
347
+ const [submitted, setSubmitted] = useState4(false);
348
+ const setValue = useCallback3(
349
+ (id, value) => {
350
+ setValues((prev) => ({ ...prev, [id]: value }));
351
+ if (submitted) {
352
+ const field = schema.fields.find((f) => f.id === id);
353
+ if (field) {
354
+ const error = validateField(field, value);
355
+ setErrors((prev) => ({ ...prev, [id]: error }));
356
+ }
357
+ }
358
+ },
359
+ [schema.fields, submitted]
360
+ );
361
+ const validate = useCallback3(() => {
362
+ const newErrors = {};
363
+ let valid = true;
364
+ for (const field of schema.fields) {
365
+ const error = validateField(field, values[field.id]);
366
+ newErrors[field.id] = error;
367
+ if (error) valid = false;
368
+ }
369
+ setErrors(newErrors);
370
+ return valid;
371
+ }, [schema.fields, values]);
372
+ const handleSubmit = useCallback3(
373
+ (onSubmit) => {
374
+ setSubmitted(true);
375
+ if (validate()) {
376
+ onSubmit(values);
377
+ }
378
+ },
379
+ [validate, values]
380
+ );
381
+ const reset = useCallback3(() => {
382
+ setValues(initialValues);
383
+ setErrors({});
384
+ setSubmitted(false);
385
+ }, []);
386
+ return { values, errors, setValue, handleSubmit, reset };
387
+ }
388
+
389
+ // src/components/SiteChatComponentNew/Messages/UserMessage.css
390
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-aed321e0")) {
391
+ const s = document.createElement("style");
392
+ s.id = "jrapps-style-aed321e0";
393
+ s.textContent = ".cw-user-message {\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n max-width: 75%;\n align-self: flex-end;\n gap: 3px;\n}\n\n.cw-user-message__bubble {\n background-color: var(--cw-user-bubble);\n color: var(--cw-user-text);\n padding: 10px 14px;\n border-radius: 18px 18px 4px 18px;\n font-size: var(--cw-font-size);\n line-height: 1.5;\n word-break: break-word;\n white-space: pre-wrap;\n}\n\n.cw-user-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-right: 2px;\n}\n";
394
+ document.head.appendChild(s);
395
+ }
396
+
397
+ // src/components/SiteChatComponentNew/Messages/UserMessage.tsx
398
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
399
+ var UserMessage = ({ message }) => {
400
+ return /* @__PURE__ */ jsxs3("div", { className: "cw-user-message", role: "listitem", "aria-label": "Your message", children: [
401
+ /* @__PURE__ */ jsx3("div", { className: "cw-user-message__bubble", children: message.message }),
402
+ message.timestamp !== void 0 && /* @__PURE__ */ jsx3("span", { className: "cw-user-message__time", children: formatTime(message.timestamp) })
403
+ ] });
404
+ };
405
+ var UserMessage_default = UserMessage;
406
+
407
+ // src/components/SiteChatComponentNew/Shared/Avatar.css
408
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-ce14fbec")) {
409
+ const s = document.createElement("style");
410
+ s.id = "jrapps-style-ce14fbec";
411
+ s.textContent = ".cw-avatar {\n border-radius: 50%;\n flex-shrink: 0;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n}\n\n.cw-avatar--image {\n object-fit: cover;\n}\n\n.cw-avatar--initials {\n background-color: var(--cw-primary);\n color: #ffffff;\n font-weight: 600;\n user-select: none;\n}\n";
412
+ document.head.appendChild(s);
413
+ }
414
+
415
+ // src/components/SiteChatComponentNew/Shared/Avatar.tsx
416
+ import { jsx as jsx4 } from "react/jsx-runtime";
417
+ function getInitials(name) {
418
+ return name.split(" ").slice(0, 2).map((w) => w[0]).join("").toUpperCase();
419
+ }
420
+ var Avatar = ({ src, name, size = 32 }) => {
421
+ const style = {
422
+ width: `${size}px`,
423
+ height: `${size}px`,
424
+ fontSize: `${Math.round(size * 0.38)}px`
425
+ };
426
+ if (src) {
427
+ return /* @__PURE__ */ jsx4(
428
+ "img",
429
+ {
430
+ src,
431
+ alt: name ? `${name} avatar` : "Agent avatar",
432
+ className: "cw-avatar cw-avatar--image",
433
+ style
434
+ }
435
+ );
436
+ }
437
+ return /* @__PURE__ */ jsx4(
438
+ "span",
439
+ {
440
+ className: "cw-avatar cw-avatar--initials",
441
+ "aria-label": name ? `${name} avatar` : "Agent avatar",
442
+ style,
443
+ children: name ? getInitials(name) : "A"
444
+ }
445
+ );
446
+ };
447
+ var Avatar_default = Avatar;
448
+
449
+ // src/components/SiteChatComponentNew/Shared/Button.css
450
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-2aa106ea")) {
451
+ const s = document.createElement("style");
452
+ s.id = "jrapps-style-2aa106ea";
453
+ s.textContent = ".cw-button {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n gap: 8px;\n padding: 10px 20px;\n border: none;\n border-radius: var(--cw-button-radius);\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n font-weight: 600;\n cursor: pointer;\n transition: opacity 0.15s ease, transform 0.1s ease;\n white-space: nowrap;\n}\n\n.cw-button:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 3px;\n}\n\n.cw-button:active:not(:disabled) {\n transform: scale(0.98);\n}\n\n.cw-button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n.cw-button--primary {\n background-color: var(--cw-primary);\n color: #ffffff;\n}\n\n.cw-button--primary:hover:not(:disabled) {\n opacity: 0.88;\n}\n\n.cw-button--secondary {\n background-color: var(--cw-surface);\n color: var(--cw-primary);\n border: 1px solid var(--cw-border);\n}\n\n.cw-button--secondary:hover:not(:disabled) {\n background-color: var(--cw-border);\n}\n\n.cw-button--full {\n width: 100%;\n}\n";
454
+ document.head.appendChild(s);
455
+ }
456
+
457
+ // src/components/SiteChatComponentNew/Shared/Button.tsx
458
+ import { jsx as jsx5 } from "react/jsx-runtime";
459
+ var Button = ({
460
+ children,
461
+ onClick,
462
+ variant = "primary",
463
+ disabled = false,
464
+ type = "button",
465
+ fullWidth = false,
466
+ ariaLabel
467
+ }) => {
468
+ return /* @__PURE__ */ jsx5(
469
+ "button",
470
+ {
471
+ className: `cw-button cw-button--${variant}${fullWidth ? " cw-button--full" : ""}`,
472
+ onClick,
473
+ disabled,
474
+ type,
475
+ "aria-label": ariaLabel,
476
+ children
477
+ }
478
+ );
479
+ };
480
+ var Button_default = Button;
481
+
482
+ // src/components/SiteChatComponentNew/Messages/AgentMessage.css
483
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-5df522b1")) {
484
+ const s = document.createElement("style");
485
+ s.id = "jrapps-style-5df522b1";
486
+ s.textContent = ".cw-agent-message {\n display: flex;\n align-items: flex-end;\n gap: 8px;\n max-width: 75%;\n align-self: flex-start;\n}\n\n.cw-agent-message__content {\n display: flex;\n flex-direction: column;\n gap: 3px;\n}\n\n.cw-agent-message__name {\n font-size: 11px;\n font-weight: 600;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n\n.cw-agent-message__bubble {\n background-color: var(--cw-agent-bubble);\n color: var(--cw-agent-text);\n padding: 10px 14px;\n border-radius: 18px 18px 18px 4px;\n font-size: var(--cw-font-size);\n line-height: 1.5;\n word-break: break-word;\n white-space: pre-wrap;\n}\n\n.cw-agent-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n";
487
+ document.head.appendChild(s);
488
+ }
489
+
490
+ // src/components/SiteChatComponentNew/Messages/AgentMessage.tsx
491
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
492
+ var AgentMessage = ({ message }) => {
493
+ var _a;
494
+ return /* @__PURE__ */ jsxs4(
495
+ "div",
496
+ {
497
+ className: "cw-agent-message",
498
+ role: "listitem",
499
+ "aria-label": `Message from ${(_a = message.senderName) != null ? _a : "Agent"}`,
500
+ children: [
501
+ /* @__PURE__ */ jsx6(Avatar_default, { name: message.senderName, size: 32 }),
502
+ /* @__PURE__ */ jsxs4("div", { className: "cw-agent-message__content", children: [
503
+ message.senderName && /* @__PURE__ */ jsx6("span", { className: "cw-agent-message__name", children: message.senderName }),
504
+ /* @__PURE__ */ jsx6("div", { className: "cw-agent-message__bubble", children: message.message }),
505
+ message.timestamp !== void 0 && /* @__PURE__ */ jsx6("span", { className: "cw-agent-message__time", children: formatTime(message.timestamp) })
506
+ ] })
507
+ ]
508
+ }
509
+ );
510
+ };
511
+ var AgentMessage_default = AgentMessage;
512
+
513
+ // src/components/SiteChatComponentNew/Messages/SystemMessage.css
514
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-464a3601")) {
515
+ const s = document.createElement("style");
516
+ s.id = "jrapps-style-464a3601";
517
+ s.textContent = ".cw-system-message {\n display: flex;\n align-items: center;\n gap: 10px;\n align-self: stretch;\n padding: 4px 8px;\n}\n\n.cw-system-message__line {\n flex: 1;\n border-top: 1px dashed var(--cw-border);\n}\n\n.cw-system-message__text {\n font-size: 11px;\n color: var(--cw-system-text);\n white-space: nowrap;\n flex-shrink: 0;\n font-style: italic;\n}\n";
518
+ document.head.appendChild(s);
519
+ }
520
+
521
+ // src/components/SiteChatComponentNew/Messages/SystemMessage.tsx
522
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
523
+ var SystemMessage = ({ message }) => {
524
+ var _a;
525
+ const label = message.message ? getSystemLabel(message.message) : (_a = message.message) != null ? _a : "";
526
+ return /* @__PURE__ */ jsxs5(
527
+ "div",
528
+ {
529
+ className: "cw-system-message",
530
+ role: "listitem",
531
+ "aria-label": `System notification: ${label}`,
532
+ children: [
533
+ /* @__PURE__ */ jsx7("span", { className: "cw-system-message__line", "aria-hidden": "true" }),
534
+ /* @__PURE__ */ jsx7("span", { className: "cw-system-message__text", children: label }),
535
+ /* @__PURE__ */ jsx7("span", { className: "cw-system-message__line", "aria-hidden": "true" })
536
+ ]
537
+ }
538
+ );
539
+ };
540
+ var SystemMessage_default = SystemMessage;
541
+
542
+ // src/components/SiteChatComponentNew/Messages/AttachmentMessage.css
543
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-dd846dee")) {
544
+ const s = document.createElement("style");
545
+ s.id = "jrapps-style-dd846dee";
546
+ s.textContent = ".cw-attachment-message {\n display: flex;\n flex-direction: column;\n gap: 3px;\n align-self: flex-start;\n max-width: 80%;\n}\n\n.cw-attachment-message--user {\n align-self: flex-end;\n align-items: flex-end;\n}\n\n.cw-attachment-message__card {\n display: flex;\n align-items: center;\n gap: 10px;\n background-color: var(--cw-agent-bubble);\n border: 1px solid var(--cw-border);\n border-radius: 12px;\n padding: 10px 14px;\n}\n\n.cw-attachment-message--user .cw-attachment-message__card {\n background-color: var(--cw-user-bubble);\n border-color: transparent;\n color: var(--cw-user-text);\n}\n\n.cw-attachment-message__icon {\n flex-shrink: 0;\n opacity: 0.75;\n display: flex;\n align-items: center;\n}\n\n.cw-attachment-message__info {\n display: flex;\n flex-direction: column;\n min-width: 0;\n flex: 1;\n}\n\n.cw-attachment-message__name {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n}\n\n.cw-attachment-message__label {\n font-size: 11px;\n opacity: 0.65;\n}\n\n.cw-attachment-message__open-btn {\n background-color: var(--cw-primary);\n color: #ffffff;\n border: none;\n border-radius: 6px;\n padding: 5px 12px;\n font-family: var(--cw-font-family);\n font-size: 12px;\n font-weight: 600;\n cursor: pointer;\n flex-shrink: 0;\n transition: opacity 0.15s ease;\n}\n\n.cw-attachment-message--user .cw-attachment-message__open-btn {\n background-color: rgba(255, 255, 255, 0.25);\n color: #ffffff;\n}\n\n.cw-attachment-message__open-btn:hover {\n opacity: 0.85;\n}\n\n.cw-attachment-message__open-btn:focus-visible {\n outline: 2px solid var(--cw-primary);\n outline-offset: 2px;\n}\n\n.cw-attachment-message__time {\n font-size: 11px;\n color: var(--cw-system-text);\n padding-left: 2px;\n}\n\n.cw-attachment-message__time--right {\n padding-left: 0;\n padding-right: 2px;\n align-self: flex-end;\n}\n";
547
+ document.head.appendChild(s);
548
+ }
549
+
550
+ // src/components/SiteChatComponentNew/Messages/AttachmentMessage.tsx
551
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
552
+ var AttachmentMessage = ({ message }) => {
553
+ var _a;
554
+ const attachment = (_a = message.item) != null ? _a : message.attachment;
555
+ if (!attachment) return null;
556
+ const handleOpen = () => {
557
+ window.open(attachment.url, "_blank", "noopener,noreferrer");
558
+ };
559
+ return /* @__PURE__ */ jsxs6(
560
+ "div",
561
+ {
562
+ className: `cw-attachment-message${message.senderType === "user" ? " cw-attachment-message--user" : ""}`,
563
+ role: "listitem",
564
+ "aria-label": `Attachment: ${attachment.name}`,
565
+ children: [
566
+ /* @__PURE__ */ jsxs6("div", { className: "cw-attachment-message__card", children: [
567
+ /* @__PURE__ */ jsx8("div", { className: "cw-attachment-message__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsxs6(
568
+ "svg",
569
+ {
570
+ xmlns: "http://www.w3.org/2000/svg",
571
+ width: "24",
572
+ height: "24",
573
+ viewBox: "0 0 24 24",
574
+ fill: "none",
575
+ stroke: "currentColor",
576
+ strokeWidth: "2",
577
+ strokeLinecap: "round",
578
+ strokeLinejoin: "round",
579
+ children: [
580
+ /* @__PURE__ */ jsx8("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
581
+ /* @__PURE__ */ jsx8("polyline", { points: "14 2 14 8 20 8" })
582
+ ]
583
+ }
584
+ ) }),
585
+ /* @__PURE__ */ jsxs6("div", { className: "cw-attachment-message__info", children: [
586
+ /* @__PURE__ */ jsx8("span", { className: "cw-attachment-message__name", children: attachment.name }),
587
+ /* @__PURE__ */ jsx8("span", { className: "cw-attachment-message__label", children: "Attachment" })
588
+ ] }),
589
+ /* @__PURE__ */ jsx8(
590
+ "button",
591
+ {
592
+ className: "cw-attachment-message__open-btn",
593
+ onClick: handleOpen,
594
+ "aria-label": `Open attachment ${attachment.name}`,
595
+ type: "button",
596
+ children: "Open"
597
+ }
598
+ )
599
+ ] }),
600
+ message.timestamp !== void 0 && /* @__PURE__ */ jsx8(
601
+ "span",
602
+ {
603
+ className: `cw-attachment-message__time${message.senderType === "user" ? " cw-attachment-message__time--right" : ""}`,
604
+ children: formatTime(message.timestamp)
605
+ }
606
+ )
607
+ ]
608
+ }
609
+ );
610
+ };
611
+ var AttachmentMessage_default = AttachmentMessage;
612
+
613
+ // src/components/SiteChatComponentNew/Messages/MessageRenderer.tsx
614
+ import { jsx as jsx9 } from "react/jsx-runtime";
615
+ var MessageRenderer = ({ message }) => {
616
+ if (message.messageType === "ATTACHMENT") {
617
+ return /* @__PURE__ */ jsx9(AttachmentMessage_default, { message });
618
+ }
619
+ switch (message.senderType) {
620
+ case "user":
621
+ return /* @__PURE__ */ jsx9(UserMessage_default, { message });
622
+ case "agent":
623
+ return /* @__PURE__ */ jsx9(AgentMessage_default, { message });
624
+ case "system":
625
+ return /* @__PURE__ */ jsx9(SystemMessage_default, { message });
626
+ default:
627
+ return null;
628
+ }
629
+ };
630
+ var MessageRenderer_default = MessageRenderer;
631
+
632
+ // src/components/SiteChatComponentNew/Messages/MessageList.css
633
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-15ae1a6b")) {
634
+ const s = document.createElement("style");
635
+ s.id = "jrapps-style-15ae1a6b";
636
+ s.textContent = ".cw-message-list {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 10px;\n overflow-y: auto;\n padding: 16px;\n background-color: var(--cw-background);\n scroll-behavior: smooth;\n}\n\n/* Scrollbar styling */\n.cw-message-list::-webkit-scrollbar {\n width: 5px;\n}\n\n.cw-message-list::-webkit-scrollbar-track {\n background: transparent;\n}\n\n.cw-message-list::-webkit-scrollbar-thumb {\n background-color: var(--cw-border);\n border-radius: 10px;\n}\n";
637
+ document.head.appendChild(s);
638
+ }
639
+
640
+ // src/components/SiteChatComponentNew/Messages/MessageList.tsx
641
+ import { jsx as jsx10 } from "react/jsx-runtime";
642
+ var MessageList = ({ messages }) => {
643
+ const scrollRef = useAutoScroll(messages);
644
+ return /* @__PURE__ */ jsx10(
645
+ "div",
646
+ {
647
+ ref: scrollRef,
648
+ className: "cw-message-list",
649
+ role: "list",
650
+ "aria-label": "Chat messages",
651
+ "aria-live": "polite",
652
+ "aria-relevant": "additions",
653
+ children: messages.map((msg, index) => {
654
+ var _a, _b;
655
+ return /* @__PURE__ */ jsx10(
656
+ MessageRenderer_default,
657
+ {
658
+ message: msg
659
+ },
660
+ (_b = msg._id) != null ? _b : `${(_a = msg.timestamp) != null ? _a : index}-${index}`
661
+ );
662
+ })
663
+ }
664
+ );
665
+ };
666
+ var MessageList_default = MessageList;
667
+
668
+ // src/components/SiteChatComponentNew/Messages/TypingIndicator.css
669
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-4b0ca05b")) {
670
+ const s = document.createElement("style");
671
+ s.id = "jrapps-style-4b0ca05b";
672
+ s.textContent = "@keyframes cw-bounce {\n 0%, 60%, 100% {\n transform: translateY(0);\n }\n 30% {\n transform: translateY(-6px);\n }\n}\n\n.cw-typing-indicator {\n align-self: flex-start;\n}\n\n.cw-typing-indicator__bubble {\n display: inline-flex;\n align-items: center;\n gap: 4px;\n background-color: var(--cw-agent-bubble);\n border-radius: 18px 18px 18px 4px;\n padding: 10px 14px;\n}\n\n.cw-typing-indicator__dot {\n display: block;\n width: 7px;\n height: 7px;\n border-radius: 50%;\n background-color: var(--cw-system-text);\n animation: cw-bounce 1.2s infinite ease-in-out;\n}\n\n.cw-typing-indicator__dot:nth-child(2) {\n animation-delay: 0.2s;\n}\n\n.cw-typing-indicator__dot:nth-child(3) {\n animation-delay: 0.4s;\n}\n";
673
+ document.head.appendChild(s);
674
+ }
675
+
676
+ // src/components/SiteChatComponentNew/Messages/TypingIndicator.tsx
677
+ import { jsx as jsx11, jsxs as jsxs7 } from "react/jsx-runtime";
678
+
679
+ // src/components/SiteChatComponentNew/States/LoadingState.css
680
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-7a5a4f05")) {
681
+ const s = document.createElement("style");
682
+ s.id = "jrapps-style-7a5a4f05";
683
+ s.textContent = "@keyframes cw-spin {\n to {\n transform: rotate(360deg);\n }\n}\n\n.cw-loading-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 12px;\n}\n\n.cw-loading-state__spinner {\n width: 48px;\n height: 48px;\n}\n\n.cw-loading-state__spinner-ring {\n width: 48px;\n height: 48px;\n border-radius: 50%;\n border: 3px solid var(--cw-border);\n border-top-color: var(--cw-primary);\n animation: cw-spin 0.8s linear infinite;\n}\n\n.cw-loading-state__title {\n font-size: 16px;\n font-weight: 600;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-loading-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 240px;\n line-height: 1.5;\n}\n";
684
+ document.head.appendChild(s);
685
+ }
686
+
687
+ // src/components/SiteChatComponentNew/States/LoadingState.tsx
688
+ import { jsx as jsx12, jsxs as jsxs8 } from "react/jsx-runtime";
689
+ var LoadingState = () => {
690
+ return /* @__PURE__ */ jsxs8(
691
+ "div",
692
+ {
693
+ className: "cw-loading-state",
694
+ role: "status",
695
+ "aria-label": "Connecting to chat",
696
+ children: [
697
+ /* @__PURE__ */ jsx12("div", { className: "cw-loading-state__spinner", "aria-hidden": "true", children: /* @__PURE__ */ jsx12("div", { className: "cw-loading-state__spinner-ring" }) }),
698
+ /* @__PURE__ */ jsx12("p", { className: "cw-loading-state__title", children: "Connecting\u2026" }),
699
+ /* @__PURE__ */ jsx12("p", { className: "cw-loading-state__subtitle", children: "Please wait while we connect you to an available agent." })
700
+ ]
701
+ }
702
+ );
703
+ };
704
+ var LoadingState_default = LoadingState;
705
+
706
+ // src/components/SiteChatComponentNew/States/StartChatState.css
707
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3e05ef30")) {
708
+ const s = document.createElement("style");
709
+ s.id = "jrapps-style-3e05ef30";
710
+ s.textContent = ".cw-start-chat-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px 24px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 14px;\n}\n\n.cw-start-chat-state__image {\n width: 80px;\n height: 80px;\n object-fit: contain;\n border-radius: 50%;\n margin-bottom: 4px;\n}\n\n.cw-start-chat-state__title {\n font-size: 20px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-start-chat-state__description {\n font-size: 14px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 260px;\n line-height: 1.6;\n}\n";
711
+ document.head.appendChild(s);
712
+ }
713
+
714
+ // src/components/SiteChatComponentNew/States/StartChatState.tsx
715
+ import { jsx as jsx13, jsxs as jsxs9 } from "react/jsx-runtime";
716
+ var StartChatState = ({
717
+ image,
718
+ title,
719
+ description,
720
+ onStart
721
+ }) => {
722
+ return /* @__PURE__ */ jsxs9(
723
+ "div",
724
+ {
725
+ className: "cw-start-chat-state",
726
+ role: "main",
727
+ "aria-label": "Start a chat",
728
+ children: [
729
+ image && /* @__PURE__ */ jsx13(
730
+ "img",
731
+ {
732
+ src: image,
733
+ alt: "Support illustration",
734
+ className: "cw-start-chat-state__image"
735
+ }
736
+ ),
737
+ /* @__PURE__ */ jsx13("h2", { className: "cw-start-chat-state__title", children: title }),
738
+ description && /* @__PURE__ */ jsx13("p", { className: "cw-start-chat-state__description", children: description }),
739
+ /* @__PURE__ */ jsx13(Button_default, { onClick: onStart, ariaLabel: "Start chat", children: "Start Chat" })
740
+ ]
741
+ }
742
+ );
743
+ };
744
+ var StartChatState_default = StartChatState;
745
+
746
+ // src/components/SiteChatComponentNew/OfflineForm/OfflineForm.css
747
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-d9ff3956")) {
748
+ const s = document.createElement("style");
749
+ s.id = "jrapps-style-d9ff3956";
750
+ s.textContent = `.cw-offline-form {
751
+ display: flex;
752
+ flex-direction: column;
753
+ gap: 14px;
754
+ }
755
+
756
+ .cw-offline-form__title {
757
+ font-size: 15px;
758
+ font-weight: 600;
759
+ color: var(--cw-agent-text);
760
+ margin: 0 0 4px;
761
+ }
762
+
763
+ /* Field wrapper */
764
+ .cw-offline-form__field {
765
+ display: flex;
766
+ flex-direction: column;
767
+ gap: 5px;
768
+ }
769
+
770
+ .cw-offline-form__field--checkbox {
771
+ gap: 4px;
772
+ }
773
+
774
+ /* Label */
775
+ .cw-offline-form__label {
776
+ font-size: 13px;
777
+ font-weight: 500;
778
+ color: var(--cw-agent-text);
779
+ }
780
+
781
+ .cw-offline-form__required {
782
+ color: #ef4444;
783
+ }
784
+
785
+ /* Text input */
786
+ .cw-offline-form__input {
787
+ width: 100%;
788
+ padding: 8px 12px;
789
+ border: 1px solid var(--cw-input-border);
790
+ border-radius: var(--cw-button-radius);
791
+ background-color: var(--cw-input-background);
792
+ font-family: var(--cw-font-family);
793
+ font-size: var(--cw-font-size);
794
+ color: inherit;
795
+ box-sizing: border-box;
796
+ transition: border-color 0.15s ease;
797
+ }
798
+
799
+ .cw-offline-form__input:focus {
800
+ outline: none;
801
+ border-color: var(--cw-primary);
802
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
803
+ }
804
+
805
+ .cw-offline-form__input--error {
806
+ border-color: #ef4444;
807
+ }
808
+
809
+ /* Textarea */
810
+ .cw-offline-form__textarea {
811
+ width: 100%;
812
+ padding: 8px 12px;
813
+ border: 1px solid var(--cw-input-border);
814
+ border-radius: var(--cw-button-radius);
815
+ background-color: var(--cw-input-background);
816
+ font-family: var(--cw-font-family);
817
+ font-size: var(--cw-font-size);
818
+ color: inherit;
819
+ resize: vertical;
820
+ box-sizing: border-box;
821
+ transition: border-color 0.15s ease;
822
+ }
823
+
824
+ .cw-offline-form__textarea:focus {
825
+ outline: none;
826
+ border-color: var(--cw-primary);
827
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
828
+ }
829
+
830
+ .cw-offline-form__textarea--error {
831
+ border-color: #ef4444;
832
+ }
833
+
834
+ /* Select */
835
+ .cw-offline-form__select {
836
+ width: 100%;
837
+ padding: 8px 12px;
838
+ border: 1px solid var(--cw-input-border);
839
+ border-radius: var(--cw-button-radius);
840
+ background-color: var(--cw-input-background);
841
+ font-family: var(--cw-font-family);
842
+ font-size: var(--cw-font-size);
843
+ color: inherit;
844
+ box-sizing: border-box;
845
+ appearance: none;
846
+ background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
847
+ background-repeat: no-repeat;
848
+ background-position: right 12px center;
849
+ padding-right: 32px;
850
+ cursor: pointer;
851
+ transition: border-color 0.15s ease;
852
+ }
853
+
854
+ .cw-offline-form__select:focus {
855
+ outline: none;
856
+ border-color: var(--cw-primary);
857
+ box-shadow: 0 0 0 2px color-mix(in srgb, var(--cw-primary) 20%, transparent);
858
+ }
859
+
860
+ .cw-offline-form__select--error {
861
+ border-color: #ef4444;
862
+ }
863
+
864
+ /* Checkbox */
865
+ .cw-offline-form__checkbox-label {
866
+ display: flex;
867
+ align-items: flex-start;
868
+ gap: 8px;
869
+ cursor: pointer;
870
+ font-size: 13px;
871
+ color: var(--cw-agent-text);
872
+ }
873
+
874
+ .cw-offline-form__checkbox {
875
+ width: 16px;
876
+ height: 16px;
877
+ accent-color: var(--cw-primary);
878
+ flex-shrink: 0;
879
+ margin-top: 1px;
880
+ cursor: pointer;
881
+ }
882
+
883
+ .cw-offline-form__checkbox:focus-visible {
884
+ outline: 2px solid var(--cw-primary);
885
+ outline-offset: 2px;
886
+ }
887
+
888
+ .cw-offline-form__checkbox-text {
889
+ line-height: 1.4;
890
+ }
891
+
892
+ /* Error message */
893
+ .cw-offline-form__error {
894
+ font-size: 12px;
895
+ color: #ef4444;
896
+ font-weight: 500;
897
+ }
898
+
899
+ /* Actions */
900
+ .cw-offline-form__actions {
901
+ margin-top: 4px;
902
+ }
903
+ `;
904
+ document.head.appendChild(s);
905
+ }
906
+
907
+ // src/components/SiteChatComponentNew/OfflineForm/OfflineForm.tsx
908
+ import { jsx as jsx14, jsxs as jsxs10 } from "react/jsx-runtime";
909
+ var FieldRenderer = ({
910
+ field,
911
+ value,
912
+ error,
913
+ onChange
914
+ }) => {
915
+ var _a, _b;
916
+ const hasError = error.length > 0;
917
+ const fieldId = `cw-offline-field-${field.id}`;
918
+ const errorId = `${fieldId}-error`;
919
+ const commonProps = {
920
+ id: fieldId,
921
+ className: `cw-offline-form__input${hasError ? " cw-offline-form__input--error" : ""}`,
922
+ "aria-invalid": hasError,
923
+ "aria-describedby": hasError ? errorId : void 0,
924
+ required: field.required
925
+ };
926
+ if (field.type === "textarea") {
927
+ return /* @__PURE__ */ jsxs10("div", { className: "cw-offline-form__field", children: [
928
+ /* @__PURE__ */ jsxs10("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
929
+ field.label,
930
+ field.required && /* @__PURE__ */ jsxs10("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
931
+ " ",
932
+ "*"
933
+ ] })
934
+ ] }),
935
+ /* @__PURE__ */ jsx14(
936
+ "textarea",
937
+ {
938
+ ...commonProps,
939
+ value: String(value != null ? value : ""),
940
+ placeholder: field.placeholder,
941
+ rows: 3,
942
+ onChange: (e) => onChange(field.id, e.target.value),
943
+ className: `cw-offline-form__textarea${hasError ? " cw-offline-form__textarea--error" : ""}`
944
+ }
945
+ ),
946
+ hasError && /* @__PURE__ */ jsx14("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
947
+ ] });
948
+ }
949
+ if (field.type === "select") {
950
+ return /* @__PURE__ */ jsxs10("div", { className: "cw-offline-form__field", children: [
951
+ /* @__PURE__ */ jsxs10("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
952
+ field.label,
953
+ field.required && /* @__PURE__ */ jsxs10("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
954
+ " ",
955
+ "*"
956
+ ] })
957
+ ] }),
958
+ /* @__PURE__ */ jsxs10(
959
+ "select",
960
+ {
961
+ ...commonProps,
962
+ value: String(value != null ? value : ""),
963
+ onChange: (e) => onChange(field.id, e.target.value),
964
+ className: `cw-offline-form__select${hasError ? " cw-offline-form__select--error" : ""}`,
965
+ children: [
966
+ /* @__PURE__ */ jsx14("option", { value: "", children: (_a = field.placeholder) != null ? _a : `Select ${field.label}` }),
967
+ (_b = field.options) == null ? void 0 : _b.map((opt) => /* @__PURE__ */ jsx14("option", { value: opt.value, children: opt.label }, opt.value))
968
+ ]
969
+ }
970
+ ),
971
+ hasError && /* @__PURE__ */ jsx14("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
972
+ ] });
973
+ }
974
+ if (field.type === "checkbox") {
975
+ return /* @__PURE__ */ jsxs10("div", { className: "cw-offline-form__field cw-offline-form__field--checkbox", children: [
976
+ /* @__PURE__ */ jsxs10("label", { className: "cw-offline-form__checkbox-label", htmlFor: fieldId, children: [
977
+ /* @__PURE__ */ jsx14(
978
+ "input",
979
+ {
980
+ type: "checkbox",
981
+ id: fieldId,
982
+ checked: Boolean(value),
983
+ onChange: (e) => onChange(field.id, e.target.checked),
984
+ className: "cw-offline-form__checkbox",
985
+ "aria-invalid": hasError,
986
+ "aria-describedby": hasError ? errorId : void 0,
987
+ required: field.required
988
+ }
989
+ ),
990
+ /* @__PURE__ */ jsxs10("span", { className: "cw-offline-form__checkbox-text", children: [
991
+ field.label,
992
+ field.required && /* @__PURE__ */ jsxs10("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
993
+ " ",
994
+ "*"
995
+ ] })
996
+ ] })
997
+ ] }),
998
+ hasError && /* @__PURE__ */ jsx14("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
999
+ ] });
1000
+ }
1001
+ return /* @__PURE__ */ jsxs10("div", { className: "cw-offline-form__field", children: [
1002
+ /* @__PURE__ */ jsxs10("label", { htmlFor: fieldId, className: "cw-offline-form__label", children: [
1003
+ field.label,
1004
+ field.required && /* @__PURE__ */ jsxs10("span", { className: "cw-offline-form__required", "aria-hidden": "true", children: [
1005
+ " ",
1006
+ "*"
1007
+ ] })
1008
+ ] }),
1009
+ /* @__PURE__ */ jsx14(
1010
+ "input",
1011
+ {
1012
+ ...commonProps,
1013
+ type: field.type,
1014
+ value: String(value != null ? value : ""),
1015
+ placeholder: field.placeholder,
1016
+ onChange: (e) => onChange(field.id, e.target.value)
1017
+ }
1018
+ ),
1019
+ hasError && /* @__PURE__ */ jsx14("span", { id: errorId, className: "cw-offline-form__error", role: "alert", children: error })
1020
+ ] });
1021
+ };
1022
+ var OfflineForm = ({ schema, onSubmit }) => {
1023
+ const { values, errors, setValue, handleSubmit } = useOfflineForm(schema);
1024
+ const onFormSubmit = (e) => {
1025
+ e.preventDefault();
1026
+ handleSubmit(onSubmit);
1027
+ };
1028
+ return /* @__PURE__ */ jsxs10(
1029
+ "form",
1030
+ {
1031
+ className: "cw-offline-form",
1032
+ onSubmit: onFormSubmit,
1033
+ "aria-label": schema.title,
1034
+ noValidate: true,
1035
+ children: [
1036
+ /* @__PURE__ */ jsx14("h3", { className: "cw-offline-form__title", children: schema.title }),
1037
+ schema.fields.map((field) => {
1038
+ var _a;
1039
+ return /* @__PURE__ */ jsx14(
1040
+ FieldRenderer,
1041
+ {
1042
+ field,
1043
+ value: values[field.id],
1044
+ error: (_a = errors[field.id]) != null ? _a : "",
1045
+ onChange: setValue
1046
+ },
1047
+ field.id
1048
+ );
1049
+ }),
1050
+ /* @__PURE__ */ jsx14("div", { className: "cw-offline-form__actions", children: /* @__PURE__ */ jsx14(Button_default, { type: "submit", fullWidth: true, children: schema.submitButtonText }) })
1051
+ ]
1052
+ }
1053
+ );
1054
+ };
1055
+ var OfflineForm_default = OfflineForm;
1056
+
1057
+ // src/components/SiteChatComponentNew/States/OfflineState.css
1058
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-8b15ae78")) {
1059
+ const s = document.createElement("style");
1060
+ s.id = "jrapps-style-8b15ae78";
1061
+ s.textContent = ".cw-offline-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n background-color: var(--cw-background);\n overflow-y: auto;\n}\n\n.cw-offline-state__header {\n display: flex;\n flex-direction: column;\n align-items: center;\n text-align: center;\n padding: 28px 24px 16px;\n gap: 8px;\n}\n\n.cw-offline-state__icon {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n color: var(--cw-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n margin-bottom: 4px;\n}\n\n.cw-offline-state__title {\n font-size: 17px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-offline-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n line-height: 1.6;\n max-width: 280px;\n}\n\n.cw-offline-state__form-wrapper {\n padding: 0 16px 16px;\n}\n";
1062
+ document.head.appendChild(s);
1063
+ }
1064
+
1065
+ // src/components/SiteChatComponentNew/States/OfflineState.tsx
1066
+ import { jsx as jsx15, jsxs as jsxs11 } from "react/jsx-runtime";
1067
+ var OfflineState = ({ form, onSubmit }) => {
1068
+ return /* @__PURE__ */ jsxs11(
1069
+ "div",
1070
+ {
1071
+ className: "cw-offline-state",
1072
+ role: "main",
1073
+ "aria-label": "Business is offline",
1074
+ children: [
1075
+ /* @__PURE__ */ jsxs11("div", { className: "cw-offline-state__header", children: [
1076
+ /* @__PURE__ */ jsx15("div", { className: "cw-offline-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx15(
1077
+ "svg",
1078
+ {
1079
+ xmlns: "http://www.w3.org/2000/svg",
1080
+ width: "32",
1081
+ height: "32",
1082
+ viewBox: "0 0 24 24",
1083
+ fill: "none",
1084
+ stroke: "currentColor",
1085
+ strokeWidth: "2",
1086
+ strokeLinecap: "round",
1087
+ strokeLinejoin: "round",
1088
+ children: /* @__PURE__ */ jsx15("path", { d: "M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" })
1089
+ }
1090
+ ) }),
1091
+ /* @__PURE__ */ jsx15("h2", { className: "cw-offline-state__title", children: "We're currently offline" }),
1092
+ /* @__PURE__ */ jsx15("p", { className: "cw-offline-state__subtitle", children: "Please leave us a message and we'll get back to you as soon as possible." })
1093
+ ] }),
1094
+ form && /* @__PURE__ */ jsx15("div", { className: "cw-offline-state__form-wrapper", children: /* @__PURE__ */ jsx15(OfflineForm_default, { schema: form, onSubmit }) })
1095
+ ]
1096
+ }
1097
+ );
1098
+ };
1099
+ var OfflineState_default = OfflineState;
1100
+
1101
+ // src/components/SiteChatComponentNew/States/ChatEndedState.css
1102
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-59a49fdf")) {
1103
+ const s = document.createElement("style");
1104
+ s.id = "jrapps-style-59a49fdf";
1105
+ s.textContent = ".cw-chat-ended-state {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n padding: 32px 24px;\n background-color: var(--cw-background);\n text-align: center;\n gap: 12px;\n}\n\n.cw-chat-ended-state__icon {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n background-color: color-mix(in srgb, var(--cw-primary) 10%, transparent);\n color: var(--cw-primary);\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.cw-chat-ended-state__title {\n font-size: 17px;\n font-weight: 700;\n color: var(--cw-agent-text);\n margin: 0;\n}\n\n.cw-chat-ended-state__subtitle {\n font-size: 13px;\n color: var(--cw-system-text);\n margin: 0;\n max-width: 240px;\n line-height: 1.6;\n}\n";
1106
+ document.head.appendChild(s);
1107
+ }
1108
+
1109
+ // src/components/SiteChatComponentNew/States/ChatEndedState.tsx
1110
+ import { jsx as jsx16, jsxs as jsxs12 } from "react/jsx-runtime";
1111
+ var ChatEndedState = () => {
1112
+ return /* @__PURE__ */ jsxs12(
1113
+ "div",
1114
+ {
1115
+ className: "cw-chat-ended-state",
1116
+ role: "status",
1117
+ "aria-label": "Chat has ended",
1118
+ children: [
1119
+ /* @__PURE__ */ jsx16("div", { className: "cw-chat-ended-state__icon", "aria-hidden": "true", children: /* @__PURE__ */ jsx16(
1120
+ "svg",
1121
+ {
1122
+ xmlns: "http://www.w3.org/2000/svg",
1123
+ width: "32",
1124
+ height: "32",
1125
+ viewBox: "0 0 24 24",
1126
+ fill: "none",
1127
+ stroke: "currentColor",
1128
+ strokeWidth: "2",
1129
+ strokeLinecap: "round",
1130
+ strokeLinejoin: "round",
1131
+ children: /* @__PURE__ */ jsx16("polyline", { points: "20 6 9 17 4 12" })
1132
+ }
1133
+ ) }),
1134
+ /* @__PURE__ */ jsx16("p", { className: "cw-chat-ended-state__title", children: "Chat Ended" }),
1135
+ /* @__PURE__ */ jsx16("p", { className: "cw-chat-ended-state__subtitle", children: "Your chat session has ended. Thank you for reaching out!" })
1136
+ ]
1137
+ }
1138
+ );
1139
+ };
1140
+ var ChatEndedState_default = ChatEndedState;
1141
+
1142
+ // src/components/SiteChatComponentNew/SiteChatComponentNew.css
1143
+ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-871af89c")) {
1144
+ const s = document.createElement("style");
1145
+ s.id = "jrapps-style-871af89c";
1146
+ s.textContent = "/* \u2500\u2500\u2500 Root container \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n * Fixed to bottom-right by default so it works out-of-the-box.\n * Override with your own positioning class if embedding differently.\n * \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n.cw-root {\n position: fixed;\n bottom: max(24px, env(safe-area-inset-bottom));\n right: max(24px, env(safe-area-inset-right));\n display: flex;\n flex-direction: column;\n align-items: flex-end;\n gap: 12px;\n z-index: 9999;\n /* Scope CSS vars and stacking context */\n isolation: isolate;\n font-family: var(--cw-font-family);\n font-size: var(--cw-font-size);\n}\n\n/* \u2500\u2500\u2500 Widget Panel \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.cw-widget {\n display: flex;\n flex-direction: column;\n width: var(--cw-width);\n height: var(--cw-height);\n /* Clamp so it never overflows the viewport on small screens */\n max-width: calc(100vw - 48px);\n max-height: calc(100dvh - 96px);\n background-color: var(--cw-background);\n border-radius: var(--cw-border-radius);\n box-shadow: var(--cw-shadow);\n overflow: hidden;\n /* Entry animation */\n animation: cw-panel-in 0.22s ease;\n transform-origin: bottom right;\n}\n\n@keyframes cw-panel-in {\n from {\n opacity: 0;\n transform: scale(0.92) translateY(10px);\n }\n to {\n opacity: 1;\n transform: scale(1) translateY(0);\n }\n}\n\n.cw-widget__body {\n display: flex;\n flex-direction: column;\n flex: 1;\n overflow: hidden;\n}\n\n/* \u2500\u2500\u2500 Launcher Button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n.cw-launcher {\n width: 56px;\n height: 56px;\n border-radius: 50%;\n border: none;\n background-color: var(--cw-primary);\n color: #ffffff;\n cursor: pointer;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);\n flex-shrink: 0;\n transition: transform 0.15s ease, box-shadow 0.15s ease;\n}\n\n.cw-launcher:hover {\n transform: scale(1.07);\n box-shadow: 0 6px 20px rgba(0, 0, 0, 0.26);\n}\n\n.cw-launcher:focus-visible {\n outline: 3px solid var(--cw-primary);\n outline-offset: 3px;\n}\n\n.cw-launcher:active {\n transform: scale(0.96);\n}\n\n/* \u2500\u2500\u2500 Tablet (481px \u2013 768px): panel floats, slightly narrower margin \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n@media (min-width: 481px) and (max-width: 768px) {\n .cw-root {\n bottom: max(16px, env(safe-area-inset-bottom));\n right: max(16px, env(safe-area-inset-right));\n }\n\n .cw-widget {\n max-width: calc(100vw - 32px);\n max-height: calc(100dvh - 80px);\n }\n}\n\n/* \u2500\u2500\u2500 Mobile (\u2264 480px): full-screen panel, launcher stays fixed \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */\n\n@media (max-width: 480px) {\n .cw-root {\n bottom: 0;\n right: 0;\n gap: 0;\n }\n\n .cw-root > .cw-launcher {\n position: fixed;\n bottom: max(20px, env(safe-area-inset-bottom));\n right: max(20px, env(safe-area-inset-right));\n }\n\n .cw-widget {\n width: 100vw;\n max-width: 100vw;\n height: 100dvh;\n max-height: 100dvh;\n border-radius: 0;\n transform-origin: bottom center;\n }\n}\n";
1147
+ document.head.appendChild(s);
1148
+ }
1149
+
1150
+ // src/components/SiteChatComponentNew/SiteChatComponentNew.tsx
1151
+ import { Fragment, jsx as jsx17, jsxs as jsxs13 } from "react/jsx-runtime";
1152
+ var SiteChatComponentNew = React2.forwardRef(({
1153
+ title,
1154
+ subtitle,
1155
+ image,
1156
+ theme,
1157
+ messages,
1158
+ offlineForm,
1159
+ defaultOpen = false,
1160
+ loading = false,
1161
+ chatEnded = false,
1162
+ onSend,
1163
+ onAttachment,
1164
+ onOfflineSubmit,
1165
+ onClose
1166
+ }, ref) => {
1167
+ const { open, openWidget, closeWidget } = useSiteChatComponentNew(defaultOpen);
1168
+ const themeVars = buildThemeVars(theme);
1169
+ const handleClose = () => {
1170
+ closeWidget();
1171
+ onClose == null ? void 0 : onClose();
1172
+ };
1173
+ const renderBody = () => {
1174
+ if (loading) {
1175
+ return /* @__PURE__ */ jsx17(LoadingState_default, {});
1176
+ }
1177
+ if (offlineForm) {
1178
+ return /* @__PURE__ */ jsx17(OfflineState_default, { form: offlineForm, onSubmit: onOfflineSubmit });
1179
+ }
1180
+ if (messages.length === 0) {
1181
+ return /* @__PURE__ */ jsx17(
1182
+ StartChatState_default,
1183
+ {
1184
+ image,
1185
+ title,
1186
+ description: subtitle,
1187
+ onStart: () => onSend("__start_chat__")
1188
+ }
1189
+ );
1190
+ }
1191
+ return /* @__PURE__ */ jsxs13(Fragment, { children: [
1192
+ /* @__PURE__ */ jsx17(MessageList_default, { messages }),
1193
+ chatEnded ? /* @__PURE__ */ jsx17(ChatEndedState_default, {}) : /* @__PURE__ */ jsx17(Footer_default, { onSend, onAttachment })
1194
+ ] });
1195
+ };
1196
+ return /* @__PURE__ */ jsxs13("div", { ref, className: "cw-root", style: themeVars, children: [
1197
+ open && /* @__PURE__ */ jsxs13(
1198
+ "div",
1199
+ {
1200
+ className: "cw-widget",
1201
+ role: "dialog",
1202
+ "aria-modal": "true",
1203
+ "aria-label": `${title} chat widget`,
1204
+ children: [
1205
+ /* @__PURE__ */ jsx17(
1206
+ Header_default,
1207
+ {
1208
+ image,
1209
+ title,
1210
+ subtitle,
1211
+ onClose: handleClose
1212
+ }
1213
+ ),
1214
+ /* @__PURE__ */ jsx17("div", { className: "cw-widget__body", children: renderBody() })
1215
+ ]
1216
+ }
1217
+ ),
1218
+ !open && /* @__PURE__ */ jsx17(
1219
+ "button",
1220
+ {
1221
+ className: "cw-launcher",
1222
+ onClick: openWidget,
1223
+ "aria-label": "Open chat",
1224
+ "aria-haspopup": "dialog",
1225
+ type: "button",
1226
+ children: /* @__PURE__ */ jsx17(
1227
+ "svg",
1228
+ {
1229
+ xmlns: "http://www.w3.org/2000/svg",
1230
+ width: "26",
1231
+ height: "26",
1232
+ viewBox: "0 0 24 24",
1233
+ fill: "currentColor",
1234
+ "aria-hidden": "true",
1235
+ children: /* @__PURE__ */ jsx17("path", { d: "M20 2H4c-1.1 0-2 .9-2 2v18l4-4h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2z" })
1236
+ }
1237
+ )
1238
+ }
1239
+ )
1240
+ ] });
1241
+ });
1242
+ SiteChatComponentNew.displayName = "SiteChatComponentNew";
1243
+
1244
+ export {
1245
+ useSiteChatComponentNew,
1246
+ SiteChatComponentNew
1247
+ };
1248
+ //# sourceMappingURL=chunk-TWW7V724.js.map