@jrapps/my_tickets_chat_ui 0.0.5 → 0.1.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 (33) hide show
  1. package/README.md +0 -0
  2. package/dist/cjs/components/SiteChatComponent/index.js +302 -252
  3. package/dist/cjs/components/SiteChatComponent/index.js.map +4 -4
  4. package/dist/cjs/index.js +302 -252
  5. package/dist/cjs/index.js.map +4 -4
  6. package/dist/esm/chunks/{chunk-E5MBV2MX.js → chunk-XNTJKZD3.js} +304 -254
  7. package/dist/esm/chunks/chunk-XNTJKZD3.js.map +7 -0
  8. package/dist/esm/components/SiteChatComponent/index.js +1 -1
  9. package/dist/esm/index.js +1 -1
  10. package/dist/types/components/SiteChatComponent/FabButton/FabButton.d.ts.map +1 -1
  11. package/dist/types/components/SiteChatComponent/FabButton/FabButton.types.d.ts +1 -1
  12. package/dist/types/components/SiteChatComponent/FabButton/FabButton.types.d.ts.map +1 -1
  13. package/dist/types/components/SiteChatComponent/Footer/Footer.d.ts.map +1 -1
  14. package/dist/types/components/SiteChatComponent/Footer/Footer.types.d.ts +10 -2
  15. package/dist/types/components/SiteChatComponent/Footer/Footer.types.d.ts.map +1 -1
  16. package/dist/types/components/SiteChatComponent/Footer/attachment-list/attachment-list.d.ts +1 -14
  17. package/dist/types/components/SiteChatComponent/Footer/attachment-list/attachment-list.d.ts.map +1 -1
  18. package/dist/types/components/SiteChatComponent/Footer/message-input/message-input.d.ts +5 -1
  19. package/dist/types/components/SiteChatComponent/Footer/message-input/message-input.d.ts.map +1 -1
  20. package/dist/types/components/SiteChatComponent/Footer/message-input/open-file-picker.d.ts +10 -0
  21. package/dist/types/components/SiteChatComponent/Footer/message-input/open-file-picker.d.ts.map +1 -0
  22. package/dist/types/components/SiteChatComponent/Header/Header.d.ts.map +1 -1
  23. package/dist/types/components/SiteChatComponent/MessageContainer/MessageContainer.d.ts.map +1 -1
  24. package/dist/types/components/SiteChatComponent/MessageContainer/messages/attachment.d.ts +1 -7
  25. package/dist/types/components/SiteChatComponent/MessageContainer/messages/attachment.d.ts.map +1 -1
  26. package/dist/types/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.d.ts +1 -20
  27. package/dist/types/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.d.ts.map +1 -1
  28. package/dist/types/components/SiteChatComponent/SiteChatComponent.d.ts +1 -1
  29. package/dist/types/components/SiteChatComponent/SiteChatComponent.d.ts.map +1 -1
  30. package/dist/types/components/SiteChatComponent/SiteChatComponent.types.d.ts +1 -9
  31. package/dist/types/components/SiteChatComponent/SiteChatComponent.types.d.ts.map +1 -1
  32. package/package.json +6 -3
  33. package/dist/esm/chunks/chunk-E5MBV2MX.js.map +0 -7
package/dist/cjs/index.js CHANGED
@@ -36,186 +36,58 @@ module.exports = __toCommonJS(src_exports);
36
36
 
37
37
  // src/components/SiteChatComponent/SiteChatComponent.tsx
38
38
  var import_react7 = __toESM(require("react"));
39
+ var import_design_system9 = require("@wix/design-system");
40
+ var import_styles_global = require("@wix/design-system/styles.global.css");
39
41
 
40
42
  // src/components/SiteChatComponent/useSiteChatComponent.ts
41
43
  function useSiteChatComponent() {
42
44
  return {};
43
45
  }
44
46
 
45
- // src/components/SiteChatComponent/Header/Header.tsx
47
+ // src/components/SiteChatComponent/FabButton/FabButton.tsx
46
48
  var import_react = __toESM(require("react"));
47
49
  var import_design_system = require("@wix/design-system");
50
+ var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
48
51
  var import_jsx_runtime = require("react/jsx-runtime");
49
- var Header = import_react.default.forwardRef(
52
+ var FabButton = import_react.default.forwardRef(
50
53
  ({
51
54
  className,
52
55
  children,
53
- title,
54
- subtitle,
55
- image,
56
- onClose,
56
+ onClick,
57
+ type = "textIcon",
58
+ icon = /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wix_ui_icons_common.WixChat, {}),
59
+ text,
57
60
  ...rest
58
61
  }, ref) => {
59
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, className: ["site-chat-header", className].filter(Boolean).join(" "), ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Box, { className: "site-chat-component-header-container", verticalAlign: "middle", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design_system.Box, { width: "100%", direction: "horizontal", align: "center", gap: "10px", children: [
60
- image && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Box, { className: "site-chat-component-header-image", width: "60px", height: "50px", borderRadius: "999px", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("img", { style: { borderRadius: "999px" }, width: "100%", height: "100%", src: "https://www.techsmith.com/wp-content/uploads/2023/08/What-are-High-Resolution-Images.png", alt: "Business Logo" }) }),
61
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design_system.Box, { direction: "vertical", className: "site-chat-component-header-text-section", children: [
62
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Box, { className: "site-chat-component-header-top-section", children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_design_system.Box, { className: "site-chat-component-header-top", verticalAlign: "middle", WebkitJustifyContent: "space-between", width: "100%", children: [
63
- title && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", { className: "site-chat-component-header-title", children: title }),
64
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
65
- "button",
66
- {
67
- onClick: onClose,
68
- "aria-label": "Close",
69
- className: "site-chat-component-header-close-button",
70
- children: "\u2715"
71
- }
72
- )
73
- ] }) }),
74
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Box, { className: "site-chat-component-header-bottom-section", children: subtitle && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h3", { className: "site-chat-component-header-subtitle", children: subtitle }) })
75
- ] })
76
- ] }) }) });
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ref, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
63
+ "button",
64
+ {
65
+ className: "site-chat-component-fab",
66
+ onClick,
67
+ children: [
68
+ type === "textIcon" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "site-chat-component-fab-fab-button-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Box, { height: "100%", children: icon }) }) : null,
69
+ type === "textIcon" || type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "site-chat-component-fab-fab-button-text", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "site-chat-component-fab-fab-button-label", children: text }) }) : null,
70
+ type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "site-chat-component-fab-fab-button-icon", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_design_system.Box, { height: "100%", width: "max-content", children: icon }) }) : null
71
+ ]
72
+ }
73
+ ) });
77
74
  }
78
75
  );
79
- Header.displayName = "SiteChatComponent.Header";
76
+ FabButton.displayName = "SiteChatComponent.FabButton";
80
77
 
81
- // src/components/SiteChatComponent/MessageContainer/MessageContainer.tsx
78
+ // src/components/SiteChatComponent/Footer/Footer.tsx
82
79
  var import_react3 = __toESM(require("react"));
83
80
  var import_design_system4 = require("@wix/design-system");
84
81
 
85
- // src/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.tsx
86
- var import_react2 = require("react");
87
- var import_design_system3 = require("@wix/design-system");
88
-
89
- // src/components/SiteChatComponent/MessageContainer/messages/attachment.tsx
90
- var import_design_system2 = require("@wix/design-system");
91
- var import_wix_ui_icons_common = require("@wix/wix-ui-icons-common");
92
- var import_on_stage = require("@wix/wix-ui-icons-common/on-stage");
93
- var import_jsx_runtime2 = require("react/jsx-runtime");
94
- var Attachment = ({ item }) => {
95
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_design_system2.Box, { direction: "horizontal", maxWidth: "100%", boxSizing: "border-box", className: "site-chat-component-message-container-in-chat-file-item-wrapper-box", children: item && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "site-chat-component-message-container-in-chat-file-item-container", children: [
96
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_wix_ui_icons_common.Page, { className: "site-chat-component-message-container-in-chat-file-icon", width: "20px", height: "20px" }),
97
- /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "site-chat-component-message-container-in-chat-file-names-container", children: [
98
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "site-chat-component-message-container-in-chat-file-name", children: item.name }),
99
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "site-chat-component-message-container-in-chat-file-sub-name", children: "Attachment" })
100
- ] }),
101
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_design_system2.TextButton, { size: "tiny", onClick: () => window.open(item.url, "_blank"), suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_on_stage.ArrowTopRight, { size: "tiny" }), children: "Open" })
102
- ] }, item.id) });
103
- };
104
- var attachment_default = Attachment;
105
-
106
- // src/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.tsx
107
- var import_jsx_runtime3 = require("react/jsx-runtime");
108
- var AGENT_MESSAGE_GAP = "10px";
109
- var AGENT_MESSAGE_WIDTH = "75%";
110
- var AGENT_MESSAGE_INNER_GAP = "4px";
111
- var ONE_MINUTE_MS = 6e4;
112
- var ONE_DAY_MS = 864e5;
113
- var DAYS_IN_WEEK = 7;
114
- var formatTimestamp = (timestamp) => {
115
- if (!timestamp) return "";
116
- const date = new Date(timestamp);
117
- const now = /* @__PURE__ */ new Date();
118
- if (now.getTime() - date.getTime() < ONE_MINUTE_MS) return "Just now";
119
- const time = date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
120
- const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate());
121
- const startOfDay = new Date(date.getFullYear(), date.getMonth(), date.getDate());
122
- const diffDays = Math.floor((startOfToday.getTime() - startOfDay.getTime()) / ONE_DAY_MS);
123
- if (diffDays === 0) return `Today at ${time}`;
124
- if (diffDays === 1) return `Yesterday at ${time}`;
125
- if (diffDays < DAYS_IN_WEEK && date.getDay() < now.getDay())
126
- return `${date.toLocaleDateString([], { weekday: "short" })} at ${time}`;
127
- return `${date.toLocaleDateString([], { month: "short", day: "numeric", year: "numeric" })} at ${time}`;
128
- };
129
- var MessagesWrapper = ({ messages = [] }) => {
130
- const wrapperRef = (0, import_react2.useRef)(null);
131
- (0, import_react2.useEffect)(() => {
132
- if (wrapperRef.current) {
133
- wrapperRef.current.scrollTop = wrapperRef.current.scrollHeight;
134
- }
135
- }, [messages]);
136
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-messages-wrapper", ref: wrapperRef, children: messages.map(({ _id, message, attachment, timestamp, type, agentName }, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `message-item ${type}`, children: type === "agent" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(AgentMessageWrapper, { message, attachment: attachment ? Array.isArray(attachment) ? attachment[0] : attachment : void 0, timestamp, agentName }) : type === "user" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(UserMessageWrapper, { message, attachment: attachment ? Array.isArray(attachment) ? attachment[0] : attachment : void 0, timestamp }) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SystemMessageWrapper, { message, timestamp }) }, _id || index)) });
137
- };
138
- var GetSystemMessage = ({ type }) => {
139
- switch (type) {
140
- case "AGENT_JOINED":
141
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "An agent has joined the chat." });
142
- case "AGENT_LEFT":
143
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "An agent has left the chat." });
144
- case "USER_JOINED":
145
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "A user has joined the chat." });
146
- case "USER_LEFT":
147
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "A user has left the chat." });
148
- case "CHAT_ENDED":
149
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "The chat has ended." });
150
- case "CHAT_REOPENED":
151
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "The chat has been reopened." });
152
- case "CHAT_TRANSFERRED":
153
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "The chat has been transferred to another agent." });
154
- case "WAITING_FOR_AGENT":
155
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "Waiting for an agent to join the chat..." });
156
- default:
157
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "System message" });
158
- }
159
- };
160
- var SystemMessageWrapper = ({ message, timestamp }) => {
161
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-system-message-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "site-chat-component-message-container-system-message", children: [
162
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("hr", { className: "dashed" }),
163
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(GetSystemMessage, { type: message }),
164
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("hr", { className: "dashed" })
165
- ] }) });
166
- };
167
- var AgentMessageWrapper = ({ message, attachment, timestamp, agentName }) => {
168
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "row", gap: AGENT_MESSAGE_GAP }, children: [
169
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system3.Avatar, { size: "size24", className: "site-chat-component-message-container-agent-message-avatar", name: agentName }),
170
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { width: AGENT_MESSAGE_WIDTH, gap: AGENT_MESSAGE_INNER_GAP, display: "flex", flexDirection: "column" }, children: [
171
- agentName && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "site-chat-component-message-container-agent-name-time-container", children: [
172
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-agent-name", children: agentName }),
173
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-agent-message-timestamp", children: formatTimestamp(timestamp) })
174
- ] }),
175
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `site-chat-component-message-container-agent-message-wrapper${attachment ? "-attachment" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "site-chat-component-message-container-agent-message", children: [
176
- message && message,
177
- attachment && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(attachment_default, { item: attachment })
178
- ] }) })
179
- ] })
180
- ] });
181
- };
182
- var UserMessageWrapper = ({ message, attachment, timestamp }) => {
183
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-end", gap: "4px" }, children: [
184
- !attachment && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "site-chat-component-message-container-user-name", children: "Me" }),
185
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: `site-chat-component-message-container-user-message-wrapper${attachment ? "-attachment" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "site-chat-component-message-container-user-message", children: [
186
- message && message,
187
- attachment && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(attachment_default, { item: attachment })
188
- ] }) })
189
- ] });
190
- };
191
- var messages_wrapper_default = MessagesWrapper;
192
-
193
- // src/components/SiteChatComponent/MessageContainer/MessageContainer.tsx
194
- var import_jsx_runtime4 = require("react/jsx-runtime");
195
- var MessageContainer = import_react3.default.forwardRef(
196
- ({ className, children, messages, loading, ...rest }, ref) => {
197
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref, className: ["site-chat-message-container", className].filter(Boolean).join(" "), ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_design_system4.Box, { className: "site-chat-component-message-container-", children: [
198
- loading && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system4.Box, { className: "site-chat-component-message-container-loading-state", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "Loading messages..." }) }),
199
- messages.length === 0 && !loading && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system4.Box, { className: "site-chat-component-message-container-empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: "No messages yet. Start a conversation" }) }),
200
- messages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(messages_wrapper_default, { messages })
201
- ] }) });
202
- }
203
- );
204
- MessageContainer.displayName = "SiteChatComponent.MessageContainer";
205
-
206
- // src/components/SiteChatComponent/Footer/Footer.tsx
207
- var import_react5 = __toESM(require("react"));
208
- var import_design_system6 = require("@wix/design-system");
209
-
210
82
  // src/components/SiteChatComponent/Footer/send-button/send-button.tsx
211
- var import_jsx_runtime5 = require("react/jsx-runtime");
83
+ var import_jsx_runtime2 = require("react/jsx-runtime");
212
84
  var SendButton = ({
213
85
  text = "Send",
214
86
  className = "",
215
87
  onClick,
216
88
  disabled = false
217
89
  }) => {
218
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
90
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
219
91
  "button",
220
92
  {
221
93
  className: `site-chat-component-footer-my-tickets-chat-widget-send-button ${className}`,
@@ -228,13 +100,13 @@ var SendButton = ({
228
100
  var send_button_default = SendButton;
229
101
 
230
102
  // src/components/SiteChatComponent/Footer/attachment-list/attachment-list.tsx
231
- var import_react4 = require("react");
232
- var import_design_system5 = require("@wix/design-system");
103
+ var import_react2 = require("react");
104
+ var import_design_system2 = require("@wix/design-system");
233
105
  var import_wix_ui_icons_common2 = require("@wix/wix-ui-icons-common");
234
- var import_jsx_runtime6 = require("react/jsx-runtime");
106
+ var import_jsx_runtime3 = require("react/jsx-runtime");
235
107
  var AttachmentList = ({ items, onRemove, onClick, onFilesSent }) => {
236
- const [localItems, setLocalItems] = (0, import_react4.useState)(items);
237
- (0, import_react4.useEffect)(() => {
108
+ const [localItems, setLocalItems] = (0, import_react2.useState)(items);
109
+ (0, import_react2.useEffect)(() => {
238
110
  setLocalItems(items);
239
111
  }, [items]);
240
112
  const handleOnRemove = (id) => {
@@ -249,60 +121,137 @@ var AttachmentList = ({ items, onRemove, onClick, onFilesSent }) => {
249
121
  setLocalItems([]);
250
122
  }
251
123
  };
252
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.Box, { direction: "horizontal", gap: 2, maxWidth: "100%", minWidth: "100%", overflowY: "hidden", boxSizing: "border-box", scrollbarWidth: "thin", overflowX: "auto", children: localItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "site-chat-component-footer-file-item-container", onClick: () => onClick && onClick(item.id, item.url), children: [
253
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_wix_ui_icons_common2.Page, { size: "15px" }),
254
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "site-chat-component-footer-file-name", children: item.name }),
255
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.IconButton, { size: "tiny", onClick: () => handleOnRemove(item.id), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_wix_ui_icons_common2.DismissSmall, {}) })
124
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.Box, { direction: "horizontal", gap: 2, maxWidth: "100%", minWidth: "100%", overflowY: "hidden", boxSizing: "border-box", scrollbarWidth: "thin", overflowX: "auto", children: localItems.map((item) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: "site-chat-component-footer-file-item-container", onClick: () => onClick && onClick(item.id, item.url), children: [
125
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_wix_ui_icons_common2.Page, { size: "15px" }),
126
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { className: "site-chat-component-footer-file-name", children: item.name }),
127
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_design_system2.IconButton, { size: "tiny", onClick: () => handleOnRemove(item.id), children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_wix_ui_icons_common2.DismissSmall, {}) })
256
128
  ] }, item.id)) });
257
129
  };
258
130
  var attachment_list_default = AttachmentList;
259
131
 
260
132
  // src/components/SiteChatComponent/Footer/message-input/message-input.tsx
261
- var import_jsx_runtime7 = require("react/jsx-runtime");
133
+ var import_design_system3 = require("@wix/design-system");
134
+ var import_wix_ui_icons_common3 = require("@wix/wix-ui-icons-common");
135
+
136
+ // src/components/SiteChatComponent/Footer/message-input/open-file-picker.ts
137
+ var import_essentials = require("@wix/essentials");
138
+ var import_meta = {};
139
+ var uploadFile = async (file) => {
140
+ var _a;
141
+ try {
142
+ const baseApiUrl = new URL(import_meta.url).origin;
143
+ const response = await import_essentials.httpClient.fetchWithAuth(`${baseApiUrl}/api/widget/chat/upload-attachment`, {
144
+ method: "POST",
145
+ headers: {
146
+ "Content-Type": file.type || "application/octet-stream",
147
+ "x-file-name": encodeURIComponent(file.name),
148
+ "x-file-type": file.type || "application/octet-stream"
149
+ },
150
+ body: file
151
+ });
152
+ const data = await response.json();
153
+ if (!response.ok) {
154
+ throw new Error(data.error || "Failed to upload file");
155
+ }
156
+ if (!((_a = data.file) == null ? void 0 : _a.id) || !data.file.displayName || !data.file.url) {
157
+ throw new Error("Invalid response format from upload endpoint");
158
+ }
159
+ return data.file;
160
+ } catch (error) {
161
+ console.error("Error uploading file:", error);
162
+ return null;
163
+ }
164
+ };
165
+ var openFilePicker = async (options) => {
166
+ const win = window;
167
+ if (!win.showOpenFilePicker) {
168
+ console.error("File Picker API is not supported in this browser.");
169
+ return;
170
+ }
171
+ try {
172
+ const fileHandles = await win.showOpenFilePicker(options);
173
+ const fileHandle = fileHandles[0];
174
+ const file = await fileHandle.getFile();
175
+ const uploadedFile = await uploadFile(file);
176
+ if (!uploadedFile) {
177
+ console.error("Failed to upload file.");
178
+ return;
179
+ }
180
+ return {
181
+ id: uploadedFile.id,
182
+ name: uploadedFile.displayName,
183
+ url: uploadedFile.url
184
+ };
185
+ } catch (error) {
186
+ console.error("Error opening file picker:", error);
187
+ return null;
188
+ }
189
+ };
190
+
191
+ // src/components/SiteChatComponent/Footer/message-input/message-input.tsx
192
+ var import_jsx_runtime4 = require("react/jsx-runtime");
262
193
  var MessageInput = ({
263
194
  placeholder = "Type a message...",
264
195
  disabled = false,
265
196
  className = "",
266
- suffix = null,
197
+ suffix,
267
198
  value = "",
268
199
  onChange,
269
200
  onKeyDown,
270
- attachmentButton
201
+ onAttachmentAdded
271
202
  }) => {
272
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: `site-chat-component-footer-input-wrapper ${className}`, children: [
273
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
203
+ const handleAttachmentOnClick = async () => {
204
+ try {
205
+ await openFilePicker({ multiple: false }).then((file) => {
206
+ if (file && onAttachmentAdded) {
207
+ onAttachmentAdded(file);
208
+ }
209
+ });
210
+ } catch (error) {
211
+ console.error("Error opening file picker:", error);
212
+ }
213
+ };
214
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: `site-chat-component-footer-input-wrapper ${className}`, children: [
215
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
274
216
  "input",
275
217
  {
276
218
  name: "messageInput",
277
- className: "chat-input",
219
+ className: "site-chat-component-footer-chat-input",
278
220
  placeholder,
279
221
  disabled,
280
222
  value,
281
223
  onChange,
282
- onKeyDown,
283
- readOnly: !onChange
224
+ onKeyDown
284
225
  }
285
226
  ),
286
- suffix && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("sub", { className: "suffix", children: attachmentButton })
227
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("sub", { className: "site-chat-component-footer-suffix", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_design_system3.IconButton, { onClick: handleAttachmentOnClick, className: "attachment-icon-button", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_wix_ui_icons_common3.AttachmentSmall, {}) }) })
287
228
  ] });
288
229
  };
289
230
  var message_input_default = MessageInput;
290
231
 
291
232
  // src/components/SiteChatComponent/Footer/Footer.tsx
292
- var import_jsx_runtime8 = require("react/jsx-runtime");
293
- var Footer = import_react5.default.forwardRef(
233
+ var import_jsx_runtime5 = require("react/jsx-runtime");
234
+ var Footer = import_react3.default.forwardRef(
294
235
  ({
295
236
  className,
296
237
  children,
297
238
  sendButtonConfig,
298
239
  attachmentListConfig,
299
240
  messageInputConfig,
241
+ onAttachmentAdded,
300
242
  ...rest
301
243
  }, ref) => {
302
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { ref, className: ["site-chat-footer", className].filter(Boolean).join(" "), ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_design_system6.Box, { className: "site-chat-component-footer-message-input-container", direction: "vertical", gap: 1, verticalAlign: "middle", children: [
303
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_design_system6.Box, { width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(attachment_list_default, { items: (attachmentListConfig == null ? void 0 : attachmentListConfig.items) || [], onRemove: attachmentListConfig == null ? void 0 : attachmentListConfig.onRemove, onClick: attachmentListConfig == null ? void 0 : attachmentListConfig.onClick, onFilesSent: attachmentListConfig == null ? void 0 : attachmentListConfig.onFilesSent }) }),
304
- /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_design_system6.Box, { alignContent: "bottom", width: "100%", direction: "horizontal", gap: 2, verticalAlign: "middle", children: [
305
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
244
+ const handleSendMessage = (text, messageType, attachment) => {
245
+ if (sendButtonConfig == null ? void 0 : sendButtonConfig.onClick) {
246
+ sendButtonConfig.onClick(text, messageType, attachment);
247
+ } else {
248
+ console.warn("handleSendMessage function is not provided in sendButtonConfig");
249
+ }
250
+ };
251
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_design_system4.Box, { ref, className: "site-chat-component-footer-message-input-container", direction: "vertical", gap: 1, verticalAlign: "middle", children: [
252
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_design_system4.Box, { width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(attachment_list_default, { items: (attachmentListConfig == null ? void 0 : attachmentListConfig.items) || [], onRemove: attachmentListConfig == null ? void 0 : attachmentListConfig.onRemove, onClick: attachmentListConfig == null ? void 0 : attachmentListConfig.onClick, onFilesSent: attachmentListConfig == null ? void 0 : attachmentListConfig.onFilesSent }) }),
253
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_design_system4.Box, { alignContent: "bottom", width: "100%", direction: "horizontal", gap: 2, verticalAlign: "middle", children: [
254
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
306
255
  message_input_default,
307
256
  {
308
257
  placeholder: (messageInputConfig == null ? void 0 : messageInputConfig.placeholder) || "Type your message here...",
@@ -311,56 +260,189 @@ var Footer = import_react5.default.forwardRef(
311
260
  onChange: messageInputConfig == null ? void 0 : messageInputConfig.onChange,
312
261
  onKeyDown: messageInputConfig == null ? void 0 : messageInputConfig.onKeyDown,
313
262
  disabled: messageInputConfig == null ? void 0 : messageInputConfig.disabled,
314
- attachmentButton: messageInputConfig == null ? void 0 : messageInputConfig.attachmentButton
263
+ onAttachmentAdded
315
264
  }
316
265
  ),
317
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
266
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
318
267
  send_button_default,
319
268
  {
320
- onClick: sendButtonConfig == null ? void 0 : sendButtonConfig.onClick,
269
+ onClick: () => handleSendMessage((messageInputConfig == null ? void 0 : messageInputConfig.value) || "", (attachmentListConfig == null ? void 0 : attachmentListConfig.items) ? "ATTACHMENT" : "TEXT"),
321
270
  disabled: sendButtonConfig == null ? void 0 : sendButtonConfig.disabled,
322
271
  text: (sendButtonConfig == null ? void 0 : sendButtonConfig.buttonText) || "Send"
323
272
  }
324
273
  )
325
274
  ] })
326
- ] }) });
275
+ ] });
327
276
  }
328
277
  );
329
278
  Footer.displayName = "SiteChatComponent.Footer";
330
279
 
331
- // src/components/SiteChatComponent/FabButton/FabButton.tsx
280
+ // src/components/SiteChatComponent/Header/Header.tsx
281
+ var import_react4 = __toESM(require("react"));
282
+ var import_design_system5 = require("@wix/design-system");
283
+ var import_jsx_runtime6 = require("react/jsx-runtime");
284
+ var Header = import_react4.default.forwardRef(
285
+ ({
286
+ className,
287
+ children,
288
+ title,
289
+ subtitle,
290
+ image,
291
+ onClose,
292
+ ...rest
293
+ }, ref) => {
294
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.Box, { ref, className: "site-chat-component-header-container", verticalAlign: "middle", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_design_system5.Box, { width: "100%", direction: "horizontal", align: "center", gap: "10px", children: [
295
+ image && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.Box, { className: "site-chat-component-header-image", width: "60px", height: "50px", borderRadius: "999px", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { style: { borderRadius: "999px" }, width: "100%", height: "100%", src: String(image), alt: "Business Logo" }) }),
296
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_design_system5.Box, { direction: "vertical", className: "site-chat-component-header-text-section", children: [
297
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.Box, { className: "site-chat-component-header-top-section", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_design_system5.Box, { className: "site-chat-component-header-top", verticalAlign: "middle", WebkitJustifyContent: "space-between", width: "100%", children: [
298
+ title && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { className: "site-chat-component-header-title", children: title }),
299
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
300
+ "button",
301
+ {
302
+ onClick: onClose,
303
+ "aria-label": "Close",
304
+ className: "site-chat-component-header-close-button",
305
+ children: "\u2715"
306
+ }
307
+ )
308
+ ] }) }),
309
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_design_system5.Box, { className: "site-chat-component-header-bottom-section", children: subtitle && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "site-chat-component-header-subtitle", children: subtitle }) })
310
+ ] })
311
+ ] }) });
312
+ }
313
+ );
314
+ Header.displayName = "SiteChatComponent.Header";
315
+
316
+ // src/components/SiteChatComponent/MessageContainer/MessageContainer.tsx
332
317
  var import_react6 = __toESM(require("react"));
318
+ var import_design_system8 = require("@wix/design-system");
319
+
320
+ // src/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.tsx
321
+ var import_react5 = require("react");
333
322
  var import_design_system7 = require("@wix/design-system");
323
+
324
+ // src/components/SiteChatComponent/MessageContainer/messages/attachment.tsx
325
+ var import_design_system6 = require("@wix/design-system");
326
+ var import_wix_ui_icons_common4 = require("@wix/wix-ui-icons-common");
327
+ var import_on_stage = require("@wix/wix-ui-icons-common/on-stage");
328
+ var import_jsx_runtime7 = require("react/jsx-runtime");
329
+ var Attachment = ({ item }) => {
330
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_design_system6.Box, { direction: "horizontal", maxWidth: "100%", boxSizing: "border-box", className: "site-chat-component-message-container-in-chat-file-item-wrapper-box", children: item && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "site-chat-component-message-container-in-chat-file-item-container", children: [
331
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_wix_ui_icons_common4.Page, { className: "site-chat-component-message-container-in-chat-file-icon", width: "20px", height: "20px" }),
332
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "site-chat-component-message-container-in-chat-file-names-container", children: [
333
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "site-chat-component-message-container-in-chat-file-name", children: item.name }),
334
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "site-chat-component-message-container-in-chat-file-sub-name", children: "Attachment" })
335
+ ] }),
336
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_design_system6.TextButton, { size: "tiny", onClick: () => window.open(item.url, "_blank"), suffixIcon: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_on_stage.ArrowTopRight, { size: "tiny" }), children: "Open" })
337
+ ] }, item.id) });
338
+ };
339
+ var attachment_default = Attachment;
340
+
341
+ // src/components/SiteChatComponent/MessageContainer/messages/messages-wrapper.tsx
342
+ var import_jsx_runtime8 = require("react/jsx-runtime");
343
+ var AGENT_MESSAGE_GAP = "10px";
344
+ var AGENT_MESSAGE_WIDTH = "75%";
345
+ var AGENT_MESSAGE_INNER_GAP = "4px";
346
+ var ONE_MINUTE_MS = 6e4;
347
+ var ONE_DAY_MS = 864e5;
348
+ var DAYS_IN_WEEK = 7;
349
+ var formatTimestamp = (timestamp) => {
350
+ if (!timestamp) return "";
351
+ const date = new Date(timestamp);
352
+ const now = /* @__PURE__ */ new Date();
353
+ if (now.getTime() - date.getTime() < ONE_MINUTE_MS) return "Just now";
354
+ const time = date.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
355
+ const startOfToday = new Date(now.getFullYear(), now.getMonth(), now.getDate());
356
+ const startOfDay = new Date(date.getFullYear(), date.getMonth(), date.getDate());
357
+ const diffDays = Math.floor((startOfToday.getTime() - startOfDay.getTime()) / ONE_DAY_MS);
358
+ if (diffDays === 0) return `Today at ${time}`;
359
+ if (diffDays === 1) return `Yesterday at ${time}`;
360
+ if (diffDays < DAYS_IN_WEEK && date.getDay() < now.getDay())
361
+ return `${date.toLocaleDateString([], { weekday: "short" })} at ${time}`;
362
+ return `${date.toLocaleDateString([], { month: "short", day: "numeric", year: "numeric" })} at ${time}`;
363
+ };
364
+ var MessagesWrapper = ({ messages = [] }) => {
365
+ const wrapperRef = (0, import_react5.useRef)(null);
366
+ (0, import_react5.useEffect)(() => {
367
+ if (wrapperRef.current) {
368
+ wrapperRef.current.scrollTop = wrapperRef.current.scrollHeight;
369
+ }
370
+ }, [messages]);
371
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-messages-wrapper", ref: wrapperRef, children: messages.map(({ _id, message, attachment, timestamp, type, agentName }, index) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `message-item ${type}`, children: type === "agent" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AgentMessageWrapper, { message, attachment: attachment ? Array.isArray(attachment) ? attachment[0] : attachment : void 0, timestamp, agentName }) : type === "user" ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(UserMessageWrapper, { message, attachment: attachment ? Array.isArray(attachment) ? attachment[0] : attachment : void 0, timestamp }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SystemMessageWrapper, { message, timestamp }) }, _id || index)) });
372
+ };
373
+ var GetSystemMessage = ({ type }) => {
374
+ switch (type) {
375
+ case "AGENT_JOINED":
376
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "An agent has joined the chat." });
377
+ case "AGENT_LEFT":
378
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "An agent has left the chat." });
379
+ case "USER_JOINED":
380
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "A user has joined the chat." });
381
+ case "USER_LEFT":
382
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "A user has left the chat." });
383
+ case "CHAT_ENDED":
384
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "The chat has ended." });
385
+ case "CHAT_REOPENED":
386
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "The chat has been reopened." });
387
+ case "CHAT_TRANSFERRED":
388
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "The chat has been transferred to another agent." });
389
+ case "WAITING_FOR_AGENT":
390
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "Waiting for an agent to join the chat..." });
391
+ default:
392
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-message", children: "System message" });
393
+ }
394
+ };
395
+ var SystemMessageWrapper = ({ message, timestamp }) => {
396
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-system-message-wrapper", children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "site-chat-component-message-container-system-message", children: [
397
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("hr", { className: "dashed" }),
398
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(GetSystemMessage, { type: message }),
399
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("hr", { className: "dashed" })
400
+ ] }) });
401
+ };
402
+ var AgentMessageWrapper = ({ message, attachment, timestamp, agentName }) => {
403
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex", flexDirection: "row", gap: AGENT_MESSAGE_GAP }, children: [
404
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_design_system7.Avatar, { size: "size24", className: "site-chat-component-message-container-agent-message-avatar", name: agentName }),
405
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { width: AGENT_MESSAGE_WIDTH, gap: AGENT_MESSAGE_INNER_GAP, display: "flex", flexDirection: "column" }, children: [
406
+ agentName && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "site-chat-component-message-container-agent-name-time-container", children: [
407
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-agent-name", children: agentName }),
408
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-agent-message-timestamp", children: formatTimestamp(timestamp) })
409
+ ] }),
410
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `site-chat-component-message-container-agent-message-wrapper${attachment ? "-attachment" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "site-chat-component-message-container-agent-message", children: [
411
+ message && message,
412
+ attachment && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(attachment_default, { item: attachment })
413
+ ] }) })
414
+ ] })
415
+ ] });
416
+ };
417
+ var UserMessageWrapper = ({ message, attachment, timestamp }) => {
418
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex", flexDirection: "column", alignItems: "flex-end", gap: "4px" }, children: [
419
+ !attachment && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "site-chat-component-message-container-user-name", children: "Me" }),
420
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: `site-chat-component-message-container-user-message-wrapper${attachment ? "-attachment" : ""}`, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "site-chat-component-message-container-user-message", children: [
421
+ message && message,
422
+ attachment && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(attachment_default, { item: attachment })
423
+ ] }) })
424
+ ] });
425
+ };
426
+ var messages_wrapper_default = MessagesWrapper;
427
+
428
+ // src/components/SiteChatComponent/MessageContainer/MessageContainer.tsx
334
429
  var import_jsx_runtime9 = require("react/jsx-runtime");
335
- var FabButton = import_react6.default.forwardRef(
430
+ var MessageContainer = import_react6.default.forwardRef(
336
431
  ({
337
432
  className,
338
433
  children,
339
- onClick,
340
- type,
341
- icon,
342
- text,
434
+ messages,
435
+ loading,
343
436
  ...rest
344
437
  }, ref) => {
345
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { ref, className: ["site-chat-fab-button", className].filter(Boolean).join(" "), ...rest, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
346
- "button",
347
- {
348
- className: "site-chat-component-fab",
349
- onClick,
350
- children: [
351
- type === "textIcon" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "site-chat-component-fab-fab-button-icon", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_design_system7.Box, { height: "100%", children: icon }) }) : null,
352
- type === "textIcon" || type === "text" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "site-chat-component-fab-fab-button-text", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "site-chat-component-fab-fab-button-label", children: text }) }) : null,
353
- type === "icon" ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { className: "site-chat-component-fab-fab-button-icon", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_design_system7.Box, { height: "100%", width: "max-content", children: icon }) }) : null
354
- ]
355
- }
356
- ) });
438
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_design_system8.Box, { ref, className: "site-chat-component-message-container", children: [
439
+ loading && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_design_system8.Box, { className: "site-chat-component-message-container-loading-state", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: "Loading messages..." }) }),
440
+ messages.length === 0 && !loading && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_design_system8.Box, { className: "site-chat-component-message-container-empty-state", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: "No messages yet. Start a conversation" }) }),
441
+ messages.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(messages_wrapper_default, { messages })
442
+ ] });
357
443
  }
358
444
  );
359
- FabButton.displayName = "SiteChatComponent.FabButton";
360
-
361
- // src/components/SiteChatComponent/SiteChatComponent.tsx
362
- var import_design_system8 = require("@wix/design-system");
363
- var import_styles_global = require("@wix/design-system/styles.global.css");
445
+ MessageContainer.displayName = "SiteChatComponent.MessageContainer";
364
446
 
365
447
  // src/components/SiteChatComponent/SiteChatComponent.css
366
448
  if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3c48ccde")) {
@@ -379,7 +461,7 @@ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3c
379
461
  border-top-left-radius: inherit;
380
462
  }
381
463
 
382
- .site-chat-component-header-container .text-section {
464
+ .site-chat-component-header-container .site-chat-component-header-text-section {
383
465
  width: 100%;
384
466
  }
385
467
 
@@ -697,13 +779,13 @@ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3c
697
779
  gap: 0px;
698
780
  }
699
781
 
700
- .site-chat-component-message-container-user-message-wrapper-attachment .in-chat-file-item-wrapper-box {
782
+ .site-chat-component-message-container-user-message-wrapper-attachment .site-chat-component-message-container-in-chat-file-item-wrapper-box {
701
783
  align-items: flex-end;
702
784
  display: flex;
703
785
  flex-direction: column;
704
786
  }
705
787
 
706
- .site-chat-component-message-container-agent-message-wrapper-attachment .in-chat-file-item-wrapper-box {
788
+ .site-chat-component-message-container-agent-message-wrapper-attachment .site-chat-component-message-container-in-chat-file-item-wrapper-box {
707
789
  align-items: flex-start;
708
790
  display: flex;
709
791
  flex-direction: column;
@@ -883,59 +965,27 @@ if (typeof document !== "undefined" && !document.getElementById("jrapps-style-3c
883
965
  var import_jsx_runtime10 = require("react/jsx-runtime");
884
966
  var SiteChatComponentRoot = import_react7.default.forwardRef(
885
967
  ({
886
- className,
887
968
  children,
888
969
  viewMode,
889
970
  editorShowChatPanel,
890
971
  handleToggle,
891
- handleClose,
892
972
  buttonTextValue,
893
- demoMessages,
894
- loading,
895
- messages,
896
- handleSendMessage,
897
- isOpen,
898
- ...rest
899
- }, ref) => {
900
- const {} = useSiteChatComponent();
901
- const ToRender = ({ children: children2 }) => {
902
- if (viewMode === "Editor") {
903
- editorShowChatPanel = true;
904
- if (typeof editorShowChatPanel === "undefined") {
905
- console.error("Editor view mode detected but editorShowChatPanel prop is not provided. Please provide editorShowChatPanel prop to control the chat panel visibility in Editor mode.");
906
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.Box, { align: "center", verticalAlign: "middle", height: "100%", width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system8.Text, { children: "Editor view mode detected but editorShowChatPanel prop is not provided" }) });
907
- }
908
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system8.Box, { children: [
909
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FabButton, { onClick: handleToggle, text: buttonTextValue }),
910
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
911
- import_design_system8.Box,
912
- {
913
- className: `site-chat-component-panel ${editorShowChatPanel ? "open" : ""}`,
914
- children: children2
915
- }
916
- )
917
- ] });
973
+ isOpen
974
+ }, _ref) => {
975
+ useSiteChatComponent();
976
+ if (viewMode === "Editor") {
977
+ if (typeof editorShowChatPanel === "undefined") {
978
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system9.Box, { align: "center", verticalAlign: "middle", height: "100%", width: "100%", children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system9.Text, { children: "Editor view mode detected but editorShowChatPanel prop is not provided" }) });
918
979
  }
919
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system8.Box, { children: [
980
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system9.Box, { children: [
920
981
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FabButton, { onClick: handleToggle, text: buttonTextValue }),
921
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
922
- import_design_system8.Box,
923
- {
924
- className: `site-chat-component-panel ${isOpen ? "open" : ""}`,
925
- children: children2
926
- }
927
- )
982
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system9.Box, { className: `site-chat-component-panel ${editorShowChatPanel ? "open" : ""}`, children })
928
983
  ] });
929
- };
930
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
931
- "div",
932
- {
933
- ref,
934
- className: ["site-chat-component", className].filter(Boolean).join(" "),
935
- ...rest,
936
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(ToRender, { children })
937
- }
938
- );
984
+ }
985
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_design_system9.Box, { children: [
986
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FabButton, { onClick: handleToggle, text: buttonTextValue }),
987
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_design_system9.Box, { className: `site-chat-component-panel ${isOpen ? "open" : ""}`, children })
988
+ ] });
939
989
  }
940
990
  );
941
991
  SiteChatComponentRoot.displayName = "SiteChatComponent";