@seyalhub/chat-widget 0.0.0-stage → 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.
- package/README.md +117 -2
- package/dist/auto.d.ts +1 -0
- package/dist/element.cjs +380 -0
- package/dist/element.cjs.map +7 -0
- package/dist/element.d.ts +14 -0
- package/dist/element.js +357 -0
- package/dist/element.js.map +7 -0
- package/dist/index.cjs +329 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +306 -0
- package/dist/index.js.map +7 -0
- package/dist/react.cjs +343 -0
- package/dist/react.cjs.map +7 -0
- package/dist/react.d.ts +5 -0
- package/dist/react.js +322 -0
- package/dist/react.js.map +7 -0
- package/dist/seyalhub-chat.js +34 -0
- package/dist/seyalhub-chat.js.map +7 -0
- package/dist/styles.d.ts +2 -0
- package/dist/widget.d.ts +27 -0
- package/package.json +69 -4
package/dist/index.js
ADDED
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
// src/styles.ts
|
|
2
|
+
var CSS = `
|
|
3
|
+
:host { all: initial; }
|
|
4
|
+
* { box-sizing: border-box; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
|
|
5
|
+
.root { position: fixed; bottom: 20px; z-index: 2147483000; --c: #4f46e5; }
|
|
6
|
+
.root.right { right: 20px; } .root.left { left: 20px; }
|
|
7
|
+
.launcher { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--c); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); position: relative; }
|
|
8
|
+
.launcher:focus-visible, button:focus-visible, textarea:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }
|
|
9
|
+
.launcher svg { width: 26px; height: 26px; fill: currentColor; }
|
|
10
|
+
.dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; display: none; }
|
|
11
|
+
.dot.on { display: block; }
|
|
12
|
+
.panel { position: absolute; bottom: 70px; width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100vh - 110px)); background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.28); display: none; flex-direction: column; overflow: hidden; color: #0f172a; }
|
|
13
|
+
.right .panel { right: 0; } .left .panel { left: 0; }
|
|
14
|
+
.panel.open { display: flex; }
|
|
15
|
+
.head { background: var(--c); color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }
|
|
16
|
+
.head h2 { margin: 0; font-size: 16px; font-weight: 600; }
|
|
17
|
+
.head .sub { font-size: 12px; opacity: .85; }
|
|
18
|
+
.close { background: transparent; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
|
|
19
|
+
.log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f8fafc; }
|
|
20
|
+
.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
|
|
21
|
+
.msg.them { background: #fff; border: 1px solid #e2e8f0; align-self: flex-start; border-bottom-left-radius: 4px; }
|
|
22
|
+
.msg.me { background: var(--c); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
|
|
23
|
+
.msg.failed { opacity: .75; outline: 2px solid #ef4444; cursor: pointer; }
|
|
24
|
+
.note { align-self: center; font-size: 12px; color: #64748b; text-align: center; }
|
|
25
|
+
.typing { align-self: flex-start; color: #64748b; font-size: 13px; padding: 4px 8px; }
|
|
26
|
+
.error { background: #fef2f2; color: #991b1b; font-size: 13px; padding: 8px 12px; display: none; }
|
|
27
|
+
.error.on { display: block; }
|
|
28
|
+
form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e2e8f0; background: #fff; }
|
|
29
|
+
textarea { flex: 1; resize: none; border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px 10px; font-size: 14px; max-height: 96px; min-height: 40px; }
|
|
30
|
+
.send { border: 0; border-radius: 10px; background: var(--c); color: #fff; padding: 0 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
|
|
31
|
+
.send:disabled { opacity: .5; cursor: default; }
|
|
32
|
+
.foot { text-align: center; font-size: 11px; color: #94a3b8; padding: 0 0 8px; background: #fff; }
|
|
33
|
+
@media (prefers-reduced-motion: no-preference) { .panel.open { animation: rise .15s ease-out; } @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } } }
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
// src/widget.ts
|
|
37
|
+
var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
38
|
+
var COLOR = /^#[0-9a-fA-F]{6}$/;
|
|
39
|
+
var BACKGROUND_POLL_MS = 1e4;
|
|
40
|
+
var MAX_BACKOFF_MS = 15e3;
|
|
41
|
+
var TYPING_TIMEOUT_MS = 6e4;
|
|
42
|
+
function randomId(length) {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
const bytes = new Uint8Array(length);
|
|
45
|
+
(_c = (_b = (_a = globalThis.crypto) != null ? _a : {}).getRandomValues) == null ? void 0 : _c.call(_b, bytes);
|
|
46
|
+
if (!bytes.some((b) => b !== 0)) for (let i = 0; i < length; i++) bytes[i] = Math.floor(Math.random() * 256);
|
|
47
|
+
return Array.from(bytes, (b) => ALPHABET[b % ALPHABET.length]).join("");
|
|
48
|
+
}
|
|
49
|
+
function safeStorage(custom) {
|
|
50
|
+
const memory = /* @__PURE__ */ new Map();
|
|
51
|
+
const fallback = { getItem: (k) => {
|
|
52
|
+
var _a;
|
|
53
|
+
return (_a = memory.get(k)) != null ? _a : null;
|
|
54
|
+
}, setItem: (k, v) => void memory.set(k, v) };
|
|
55
|
+
try {
|
|
56
|
+
const s = custom != null ? custom : window.localStorage;
|
|
57
|
+
s.setItem("seyalhub:probe", "1");
|
|
58
|
+
return s;
|
|
59
|
+
} catch {
|
|
60
|
+
return fallback;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function el(tag, className, text) {
|
|
64
|
+
const node = document.createElement(tag);
|
|
65
|
+
if (className) node.className = className;
|
|
66
|
+
if (text !== void 0) node.textContent = text;
|
|
67
|
+
return node;
|
|
68
|
+
}
|
|
69
|
+
function createChatWidget(options) {
|
|
70
|
+
var _a, _b, _c;
|
|
71
|
+
const doFetch = (_a = options.fetch) != null ? _a : ((...args) => fetch(...args));
|
|
72
|
+
const base = `${options.apiUrl.replace(/\/+$/, "")}/api/v1/public/webchat/${encodeURIComponent(options.siteKey)}`;
|
|
73
|
+
const storage = safeStorage(options.storage);
|
|
74
|
+
const keyVisitor = `seyalhub:visitor:${options.siteKey}`;
|
|
75
|
+
const keyStarted = `seyalhub:started:${options.siteKey}`;
|
|
76
|
+
let visitor = (_b = storage.getItem(keyVisitor)) != null ? _b : "";
|
|
77
|
+
if (!/^[A-Za-z0-9_-]{32,64}$/.test(visitor)) {
|
|
78
|
+
visitor = randomId(40);
|
|
79
|
+
storage.setItem(keyVisitor, visitor);
|
|
80
|
+
}
|
|
81
|
+
let destroyed = false;
|
|
82
|
+
let isOpen = false;
|
|
83
|
+
let loadedHistory = false;
|
|
84
|
+
let lastId = "";
|
|
85
|
+
let backoff = 0;
|
|
86
|
+
let timer;
|
|
87
|
+
let typingTimer;
|
|
88
|
+
const rendered = /* @__PURE__ */ new Map();
|
|
89
|
+
const pendingBubbles = /* @__PURE__ */ new Map();
|
|
90
|
+
const host = el("div");
|
|
91
|
+
host.setAttribute("data-seyalhub-chat", "");
|
|
92
|
+
const shadow = host.attachShadow({ mode: "open" });
|
|
93
|
+
const style = el("style");
|
|
94
|
+
style.textContent = CSS;
|
|
95
|
+
const root = el("div", `root ${options.position === "left" ? "left" : "right"}`);
|
|
96
|
+
const panel = el("section", "panel");
|
|
97
|
+
panel.setAttribute("role", "dialog");
|
|
98
|
+
panel.setAttribute("aria-label", "Chat");
|
|
99
|
+
const head = el("div", "head");
|
|
100
|
+
const headText = el("div");
|
|
101
|
+
const titleEl = el("h2", void 0, (_c = options.title) != null ? _c : "Chat with us");
|
|
102
|
+
const subEl = el("div", "sub");
|
|
103
|
+
headText.append(titleEl, subEl);
|
|
104
|
+
const closeBtn = el("button", "close", "\xD7");
|
|
105
|
+
closeBtn.type = "button";
|
|
106
|
+
closeBtn.setAttribute("aria-label", "Close chat");
|
|
107
|
+
head.append(headText, closeBtn);
|
|
108
|
+
const log = el("div", "log");
|
|
109
|
+
log.setAttribute("role", "log");
|
|
110
|
+
log.setAttribute("aria-live", "polite");
|
|
111
|
+
const typing = el("div", "typing", "Typing\u2026");
|
|
112
|
+
const errorBar = el("div", "error");
|
|
113
|
+
errorBar.setAttribute("role", "alert");
|
|
114
|
+
const form = el("form");
|
|
115
|
+
const input = el("textarea");
|
|
116
|
+
input.rows = 1;
|
|
117
|
+
input.maxLength = 1e3;
|
|
118
|
+
input.placeholder = "Type your message";
|
|
119
|
+
input.setAttribute("aria-label", "Your message");
|
|
120
|
+
const sendBtn = el("button", "send", "Send");
|
|
121
|
+
sendBtn.type = "submit";
|
|
122
|
+
form.append(input, sendBtn);
|
|
123
|
+
const foot = el("div", "foot", "Powered by SeyalHub");
|
|
124
|
+
panel.append(head, log, errorBar, form, foot);
|
|
125
|
+
const launcher = el("button", "launcher");
|
|
126
|
+
launcher.type = "button";
|
|
127
|
+
launcher.setAttribute("aria-label", "Open chat");
|
|
128
|
+
launcher.setAttribute("aria-expanded", "false");
|
|
129
|
+
launcher.innerHTML = '<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 4v-4H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"/></svg>';
|
|
130
|
+
const dot = el("span", "dot");
|
|
131
|
+
launcher.append(dot);
|
|
132
|
+
root.append(panel, launcher);
|
|
133
|
+
shadow.append(style, root);
|
|
134
|
+
function applyColor(color) {
|
|
135
|
+
if (color && COLOR.test(color)) root.style.setProperty("--c", color);
|
|
136
|
+
}
|
|
137
|
+
applyColor(options.color);
|
|
138
|
+
const scrollDown = () => {
|
|
139
|
+
log.scrollTop = log.scrollHeight;
|
|
140
|
+
};
|
|
141
|
+
function showError(message) {
|
|
142
|
+
errorBar.textContent = message != null ? message : "";
|
|
143
|
+
errorBar.classList.toggle("on", Boolean(message));
|
|
144
|
+
}
|
|
145
|
+
function setTyping(on) {
|
|
146
|
+
if (typingTimer) clearTimeout(typingTimer);
|
|
147
|
+
if (on) {
|
|
148
|
+
log.append(typing);
|
|
149
|
+
scrollDown();
|
|
150
|
+
typingTimer = setTimeout(() => typing.remove(), TYPING_TIMEOUT_MS);
|
|
151
|
+
} else typing.remove();
|
|
152
|
+
}
|
|
153
|
+
function bubble(text, kind) {
|
|
154
|
+
const b = el("div", kind === "note" ? "note" : `msg ${kind}`, text);
|
|
155
|
+
typing.remove();
|
|
156
|
+
log.append(b);
|
|
157
|
+
scrollDown();
|
|
158
|
+
return b;
|
|
159
|
+
}
|
|
160
|
+
function addServerLine(line) {
|
|
161
|
+
if (rendered.has(line.id)) return;
|
|
162
|
+
lastId = line.id > lastId ? line.id : lastId;
|
|
163
|
+
if (line.direction === "inbound") {
|
|
164
|
+
const mine = line.client_id ? pendingBubbles.get(line.client_id) : void 0;
|
|
165
|
+
if (mine) {
|
|
166
|
+
rendered.set(line.id, mine);
|
|
167
|
+
pendingBubbles.delete(line.client_id);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
rendered.set(line.id, bubble(line.text, "me"));
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
rendered.set(line.id, bubble(line.text, "them"));
|
|
174
|
+
setTyping(false);
|
|
175
|
+
if (!isOpen) dot.classList.add("on");
|
|
176
|
+
}
|
|
177
|
+
async function api(path, init) {
|
|
178
|
+
var _a2;
|
|
179
|
+
return doFetch(`${base}${path}`, { ...init, headers: { "content-type": "application/json", ...(_a2 = init == null ? void 0 : init.headers) != null ? _a2 : {} } });
|
|
180
|
+
}
|
|
181
|
+
async function poll() {
|
|
182
|
+
var _a2;
|
|
183
|
+
if (destroyed) return;
|
|
184
|
+
let delay = isOpen ? (_a2 = options.pollMs) != null ? _a2 : 2e3 : BACKGROUND_POLL_MS;
|
|
185
|
+
try {
|
|
186
|
+
const qs = new URLSearchParams({ visitor_id: visitor });
|
|
187
|
+
if (lastId) qs.set("after", lastId);
|
|
188
|
+
const res = await api(`/messages?${qs}`);
|
|
189
|
+
if (res.ok) {
|
|
190
|
+
const body = await res.json();
|
|
191
|
+
body.messages.forEach(addServerLine);
|
|
192
|
+
subEl.textContent = body.human ? "You are chatting with our team" : "";
|
|
193
|
+
backoff = 0;
|
|
194
|
+
showError(null);
|
|
195
|
+
} else if (res.status === 403 || res.status === 404) {
|
|
196
|
+
return void destroy();
|
|
197
|
+
} else throw new Error(String(res.status));
|
|
198
|
+
} catch {
|
|
199
|
+
backoff = Math.min(MAX_BACKOFF_MS, (backoff || 1e3) * 2);
|
|
200
|
+
delay = Math.max(delay, backoff);
|
|
201
|
+
}
|
|
202
|
+
if (!destroyed && (isOpen || storage.getItem(keyStarted))) timer = setTimeout(() => void poll(), delay);
|
|
203
|
+
}
|
|
204
|
+
function restartPolling() {
|
|
205
|
+
if (timer) clearTimeout(timer);
|
|
206
|
+
void poll();
|
|
207
|
+
}
|
|
208
|
+
async function loadHistory() {
|
|
209
|
+
var _a2;
|
|
210
|
+
if (loadedHistory) return;
|
|
211
|
+
loadedHistory = true;
|
|
212
|
+
await poll();
|
|
213
|
+
if (rendered.size === 0) bubble((_a2 = options.greeting) != null ? _a2 : greeting, "them");
|
|
214
|
+
}
|
|
215
|
+
let greeting = "Hi! How can we help?";
|
|
216
|
+
async function send(text, clientId, node) {
|
|
217
|
+
node.classList.remove("failed");
|
|
218
|
+
try {
|
|
219
|
+
const res = await api("/messages", { method: "POST", body: JSON.stringify({ visitor_id: visitor, text, client_message_id: clientId }) });
|
|
220
|
+
if (res.status === 429) throw new Error("You are sending messages too fast. Please wait a moment.");
|
|
221
|
+
if (!res.ok) throw new Error(res.status === 503 ? "Chat is not available right now. Please try again shortly." : "Your message could not be sent. Tap it to try again.");
|
|
222
|
+
storage.setItem(keyStarted, "1");
|
|
223
|
+
showError(null);
|
|
224
|
+
setTyping(true);
|
|
225
|
+
restartPolling();
|
|
226
|
+
} catch (err) {
|
|
227
|
+
node.classList.add("failed");
|
|
228
|
+
node.onclick = () => void send(text, clientId, node);
|
|
229
|
+
showError(err instanceof Error && err.message ? err.message : "Your message could not be sent. Tap it to try again.");
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
form.addEventListener("submit", (e) => {
|
|
233
|
+
e.preventDefault();
|
|
234
|
+
const text = input.value.trim();
|
|
235
|
+
if (!text) return;
|
|
236
|
+
input.value = "";
|
|
237
|
+
const clientId = `cm_${randomId(16)}`;
|
|
238
|
+
const node = bubble(text, "me");
|
|
239
|
+
pendingBubbles.set(clientId, node);
|
|
240
|
+
void send(text, clientId, node);
|
|
241
|
+
});
|
|
242
|
+
input.addEventListener("keydown", (e) => {
|
|
243
|
+
if (e.key === "Enter" && !e.shiftKey && !e.isComposing) {
|
|
244
|
+
e.preventDefault();
|
|
245
|
+
form.requestSubmit();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
panel.addEventListener("keydown", (e) => {
|
|
249
|
+
if (e.key === "Escape") close();
|
|
250
|
+
});
|
|
251
|
+
function open() {
|
|
252
|
+
if (destroyed || isOpen) return;
|
|
253
|
+
isOpen = true;
|
|
254
|
+
panel.classList.add("open");
|
|
255
|
+
launcher.setAttribute("aria-expanded", "true");
|
|
256
|
+
launcher.setAttribute("aria-label", "Close chat");
|
|
257
|
+
dot.classList.remove("on");
|
|
258
|
+
void loadHistory().then(() => {
|
|
259
|
+
if (isOpen) restartPolling();
|
|
260
|
+
});
|
|
261
|
+
input.focus();
|
|
262
|
+
}
|
|
263
|
+
function close() {
|
|
264
|
+
if (!isOpen) return;
|
|
265
|
+
isOpen = false;
|
|
266
|
+
panel.classList.remove("open");
|
|
267
|
+
launcher.setAttribute("aria-expanded", "false");
|
|
268
|
+
launcher.setAttribute("aria-label", "Open chat");
|
|
269
|
+
launcher.focus();
|
|
270
|
+
}
|
|
271
|
+
function toggle() {
|
|
272
|
+
isOpen ? close() : open();
|
|
273
|
+
}
|
|
274
|
+
function destroy() {
|
|
275
|
+
destroyed = true;
|
|
276
|
+
if (timer) clearTimeout(timer);
|
|
277
|
+
if (typingTimer) clearTimeout(typingTimer);
|
|
278
|
+
host.remove();
|
|
279
|
+
}
|
|
280
|
+
launcher.addEventListener("click", toggle);
|
|
281
|
+
closeBtn.addEventListener("click", close);
|
|
282
|
+
void (async () => {
|
|
283
|
+
var _a2, _b2, _c2, _d;
|
|
284
|
+
try {
|
|
285
|
+
const res = await api("/config");
|
|
286
|
+
if (!res.ok) {
|
|
287
|
+
if (typeof console !== "undefined") console.warn(`[SeyalHub chat] not shown (${res.status}): check the site key and that this website is listed in the portal.`);
|
|
288
|
+
return void destroy();
|
|
289
|
+
}
|
|
290
|
+
const cfg = await res.json();
|
|
291
|
+
titleEl.textContent = (_a2 = options.title) != null ? _a2 : cfg.title;
|
|
292
|
+
greeting = (_b2 = options.greeting) != null ? _b2 : cfg.greeting;
|
|
293
|
+
applyColor((_c2 = options.color) != null ? _c2 : cfg.color);
|
|
294
|
+
} catch {
|
|
295
|
+
}
|
|
296
|
+
if (destroyed) return;
|
|
297
|
+
((_d = options.container) != null ? _d : document.body).append(host);
|
|
298
|
+
if (storage.getItem(keyStarted)) void poll();
|
|
299
|
+
if (options.open) open();
|
|
300
|
+
})();
|
|
301
|
+
return { open, close, toggle, destroy };
|
|
302
|
+
}
|
|
303
|
+
export {
|
|
304
|
+
createChatWidget
|
|
305
|
+
};
|
|
306
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/styles.ts", "../src/widget.ts"],
|
|
4
|
+
"sourcesContent": ["/** All styles live inside the widget's shadow root, so the host page's CSS cannot break the widget and the widget's CSS cannot touch the page. */\nexport const CSS = `\n:host { all: initial; }\n* { box-sizing: border-box; font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, sans-serif; }\n.root { position: fixed; bottom: 20px; z-index: 2147483000; --c: #4f46e5; }\n.root.right { right: 20px; } .root.left { left: 20px; }\n.launcher { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--c); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); position: relative; }\n.launcher:focus-visible, button:focus-visible, textarea:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }\n.launcher svg { width: 26px; height: 26px; fill: currentColor; }\n.dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: 50%; background: #ef4444; border: 2px solid #fff; display: none; }\n.dot.on { display: block; }\n.panel { position: absolute; bottom: 70px; width: min(380px, calc(100vw - 24px)); height: min(560px, calc(100vh - 110px)); background: #fff; border-radius: 14px; box-shadow: 0 12px 40px rgba(0,0,0,.28); display: none; flex-direction: column; overflow: hidden; color: #0f172a; }\n.right .panel { right: 0; } .left .panel { left: 0; }\n.panel.open { display: flex; }\n.head { background: var(--c); color: #fff; padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; }\n.head h2 { margin: 0; font-size: 16px; font-weight: 600; }\n.head .sub { font-size: 12px; opacity: .85; }\n.close { background: transparent; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px; border-radius: 6px; }\n.log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 8px; background: #f8fafc; }\n.msg { max-width: 82%; padding: 9px 12px; border-radius: 14px; font-size: 14px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }\n.msg.them { background: #fff; border: 1px solid #e2e8f0; align-self: flex-start; border-bottom-left-radius: 4px; }\n.msg.me { background: var(--c); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }\n.msg.failed { opacity: .75; outline: 2px solid #ef4444; cursor: pointer; }\n.note { align-self: center; font-size: 12px; color: #64748b; text-align: center; }\n.typing { align-self: flex-start; color: #64748b; font-size: 13px; padding: 4px 8px; }\n.error { background: #fef2f2; color: #991b1b; font-size: 13px; padding: 8px 12px; display: none; }\n.error.on { display: block; }\nform { display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e2e8f0; background: #fff; }\ntextarea { flex: 1; resize: none; border: 1px solid #cbd5e1; border-radius: 10px; padding: 9px 10px; font-size: 14px; max-height: 96px; min-height: 40px; }\n.send { border: 0; border-radius: 10px; background: var(--c); color: #fff; padding: 0 16px; font-size: 14px; font-weight: 600; cursor: pointer; }\n.send:disabled { opacity: .5; cursor: default; }\n.foot { text-align: center; font-size: 11px; color: #94a3b8; padding: 0 0 8px; background: #fff; }\n@media (prefers-reduced-motion: no-preference) { .panel.open { animation: rise .15s ease-out; } @keyframes rise { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } } }\n`;\n", "import { CSS } from \"./styles\";\n\nexport interface ChatOptions {\n /** The site key from the portal (Settings, Channels). Starts with `wc_`. */\n siteKey: string;\n /** Where the SeyalHub API lives, for example `https://api.example.com`. No path. */\n apiUrl: string;\n /** Override the title, greeting or colour set in the portal. */\n title?: string;\n greeting?: string;\n color?: string;\n position?: \"right\" | \"left\";\n /** Open the chat as soon as it is ready. */\n open?: boolean;\n /** Where to attach the widget. Default: document.body. */\n container?: HTMLElement;\n /** How often to look for new messages while the chat is open. Default 2000 ms. */\n pollMs?: number;\n /** Test hooks. */\n fetch?: typeof fetch;\n storage?: Pick<Storage, \"getItem\" | \"setItem\">;\n}\n\nexport interface ChatWidget {\n open(): void;\n close(): void;\n toggle(): void;\n destroy(): void;\n}\n\ninterface Line {\n id: string;\n direction: \"inbound\" | \"outbound\";\n text: string;\n sent_by?: string | null;\n client_id?: string | null;\n}\n\nconst ALPHABET = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789\";\nconst COLOR = /^#[0-9a-fA-F]{6}$/;\nconst BACKGROUND_POLL_MS = 10_000;\nconst MAX_BACKOFF_MS = 15_000;\nconst TYPING_TIMEOUT_MS = 60_000;\n\nfunction randomId(length: number): string {\n const bytes = new Uint8Array(length);\n (globalThis.crypto ?? ({} as Crypto)).getRandomValues?.(bytes);\n if (!bytes.some((b) => b !== 0)) for (let i = 0; i < length; i++) bytes[i] = Math.floor(Math.random() * 256); // very old browsers: fall back\n return Array.from(bytes, (b) => ALPHABET[b % ALPHABET.length]).join(\"\");\n}\n\nfunction safeStorage(custom?: ChatOptions[\"storage\"]): Pick<Storage, \"getItem\" | \"setItem\"> {\n const memory = new Map<string, string>();\n const fallback = { getItem: (k: string) => memory.get(k) ?? null, setItem: (k: string, v: string) => void memory.set(k, v) };\n try {\n const s = custom ?? window.localStorage;\n s.setItem(\"seyalhub:probe\", \"1\");\n return s;\n } catch {\n return fallback; // private mode or storage blocked: the chat still works, it just does not survive a reload\n }\n}\n\nfunction el<K extends keyof HTMLElementTagNameMap>(tag: K, className?: string, text?: string): HTMLElementTagNameMap[K] {\n const node = document.createElement(tag);\n if (className) node.className = className;\n if (text !== undefined) node.textContent = text; // always textContent: a message can never inject markup\n return node;\n}\n\nexport function createChatWidget(options: ChatOptions): ChatWidget {\n const doFetch = options.fetch ?? ((...args: Parameters<typeof fetch>) => fetch(...args));\n const base = `${options.apiUrl.replace(/\\/+$/, \"\")}/api/v1/public/webchat/${encodeURIComponent(options.siteKey)}`;\n const storage = safeStorage(options.storage);\n const keyVisitor = `seyalhub:visitor:${options.siteKey}`;\n const keyStarted = `seyalhub:started:${options.siteKey}`;\n let visitor = storage.getItem(keyVisitor) ?? \"\";\n if (!/^[A-Za-z0-9_-]{32,64}$/.test(visitor)) {\n visitor = randomId(40); // long and random: it is the only thing that lets this browser read this conversation\n storage.setItem(keyVisitor, visitor);\n }\n\n let destroyed = false;\n let isOpen = false;\n let loadedHistory = false;\n let lastId = \"\";\n let backoff = 0;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let typingTimer: ReturnType<typeof setTimeout> | undefined;\n const rendered = new Map<string, HTMLElement>(); // server id or client id -> bubble\n const pendingBubbles = new Map<string, HTMLElement>(); // client id -> bubble waiting for the server's copy\n\n // --- DOM -----------------------------------------------------------------------------------------------------\n const host = el(\"div\");\n host.setAttribute(\"data-seyalhub-chat\", \"\");\n const shadow = host.attachShadow({ mode: \"open\" });\n const style = el(\"style\");\n style.textContent = CSS;\n const root = el(\"div\", `root ${options.position === \"left\" ? \"left\" : \"right\"}`);\n const panel = el(\"section\", \"panel\");\n panel.setAttribute(\"role\", \"dialog\");\n panel.setAttribute(\"aria-label\", \"Chat\");\n const head = el(\"div\", \"head\");\n const headText = el(\"div\");\n const titleEl = el(\"h2\", undefined, options.title ?? \"Chat with us\");\n const subEl = el(\"div\", \"sub\");\n headText.append(titleEl, subEl);\n const closeBtn = el(\"button\", \"close\", \"\u00D7\");\n closeBtn.type = \"button\";\n closeBtn.setAttribute(\"aria-label\", \"Close chat\");\n head.append(headText, closeBtn);\n const log = el(\"div\", \"log\");\n log.setAttribute(\"role\", \"log\");\n log.setAttribute(\"aria-live\", \"polite\");\n const typing = el(\"div\", \"typing\", \"Typing\u2026\");\n const errorBar = el(\"div\", \"error\");\n errorBar.setAttribute(\"role\", \"alert\");\n const form = el(\"form\");\n const input = el(\"textarea\");\n input.rows = 1;\n input.maxLength = 1000;\n input.placeholder = \"Type your message\";\n input.setAttribute(\"aria-label\", \"Your message\");\n const sendBtn = el(\"button\", \"send\", \"Send\");\n sendBtn.type = \"submit\";\n form.append(input, sendBtn);\n const foot = el(\"div\", \"foot\", \"Powered by SeyalHub\");\n panel.append(head, log, errorBar, form, foot);\n const launcher = el(\"button\", \"launcher\");\n launcher.type = \"button\";\n launcher.setAttribute(\"aria-label\", \"Open chat\");\n launcher.setAttribute(\"aria-expanded\", \"false\");\n launcher.innerHTML = '<svg viewBox=\"0 0 24 24\" aria-hidden=\"true\"><path d=\"M4 4h16a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H9l-5 4v-4H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z\"/></svg>'; // static markup, no user data\n const dot = el(\"span\", \"dot\");\n launcher.append(dot);\n root.append(panel, launcher);\n shadow.append(style, root);\n\n function applyColor(color?: string) {\n if (color && COLOR.test(color)) root.style.setProperty(\"--c\", color);\n }\n applyColor(options.color);\n\n // --- helpers ---------------------------------------------------------------------------------------------------\n const scrollDown = () => { log.scrollTop = log.scrollHeight; };\n function showError(message: string | null) {\n errorBar.textContent = message ?? \"\";\n errorBar.classList.toggle(\"on\", Boolean(message));\n }\n function setTyping(on: boolean) {\n if (typingTimer) clearTimeout(typingTimer);\n if (on) {\n log.append(typing);\n scrollDown();\n typingTimer = setTimeout(() => typing.remove(), TYPING_TIMEOUT_MS);\n } else typing.remove();\n }\n function bubble(text: string, kind: \"me\" | \"them\" | \"note\"): HTMLElement {\n const b = el(\"div\", kind === \"note\" ? \"note\" : `msg ${kind}`, text);\n typing.remove();\n log.append(b);\n scrollDown();\n return b;\n }\n\n function addServerLine(line: Line) {\n if (rendered.has(line.id)) return;\n lastId = line.id > lastId ? line.id : lastId;\n if (line.direction === \"inbound\") {\n const mine = line.client_id ? pendingBubbles.get(line.client_id) : undefined;\n if (mine) { // the server's copy of a message this page sent: keep the bubble, remember its id\n rendered.set(line.id, mine);\n pendingBubbles.delete(line.client_id!);\n return;\n }\n rendered.set(line.id, bubble(line.text, \"me\"));\n return;\n }\n rendered.set(line.id, bubble(line.text, \"them\"));\n setTyping(false);\n if (!isOpen) dot.classList.add(\"on\");\n }\n\n // --- talking to the API ----------------------------------------------------------------------------------------\n async function api(path: string, init?: RequestInit): Promise<Response> {\n return doFetch(`${base}${path}`, { ...init, headers: { \"content-type\": \"application/json\", ...(init?.headers ?? {}) } });\n }\n\n async function poll(): Promise<void> {\n if (destroyed) return;\n let delay = isOpen ? options.pollMs ?? 2000 : BACKGROUND_POLL_MS;\n try {\n const qs = new URLSearchParams({ visitor_id: visitor });\n if (lastId) qs.set(\"after\", lastId);\n const res = await api(`/messages?${qs}`);\n if (res.ok) {\n const body = (await res.json()) as { messages: Line[]; human?: boolean };\n body.messages.forEach(addServerLine);\n subEl.textContent = body.human ? \"You are chatting with our team\" : \"\";\n backoff = 0;\n showError(null);\n } else if (res.status === 403 || res.status === 404) {\n return void destroy(); // not allowed here (website not listed) or the chat was switched off: stop quietly\n } else throw new Error(String(res.status));\n } catch {\n backoff = Math.min(MAX_BACKOFF_MS, (backoff || 1000) * 2);\n delay = Math.max(delay, backoff);\n }\n if (!destroyed && (isOpen || storage.getItem(keyStarted))) timer = setTimeout(() => void poll(), delay);\n }\n\n function restartPolling() {\n if (timer) clearTimeout(timer);\n void poll();\n }\n\n async function loadHistory(): Promise<void> {\n if (loadedHistory) return;\n loadedHistory = true;\n await poll();\n if (rendered.size === 0) bubble(options.greeting ?? greeting, \"them\"); // the greeting is only a first line, not stored as a message\n }\n let greeting = \"Hi! How can we help?\";\n\n async function send(text: string, clientId: string, node: HTMLElement): Promise<void> {\n node.classList.remove(\"failed\");\n try {\n const res = await api(\"/messages\", { method: \"POST\", body: JSON.stringify({ visitor_id: visitor, text, client_message_id: clientId }) });\n if (res.status === 429) throw new Error(\"You are sending messages too fast. Please wait a moment.\");\n if (!res.ok) throw new Error(res.status === 503 ? \"Chat is not available right now. Please try again shortly.\" : \"Your message could not be sent. Tap it to try again.\");\n storage.setItem(keyStarted, \"1\");\n showError(null);\n setTyping(true);\n restartPolling();\n } catch (err) {\n node.classList.add(\"failed\");\n node.onclick = () => void send(text, clientId, node);\n showError(err instanceof Error && err.message ? err.message : \"Your message could not be sent. Tap it to try again.\");\n }\n }\n\n form.addEventListener(\"submit\", (e) => {\n e.preventDefault();\n const text = input.value.trim();\n if (!text) return;\n input.value = \"\";\n const clientId = `cm_${randomId(16)}`;\n const node = bubble(text, \"me\");\n pendingBubbles.set(clientId, node);\n void send(text, clientId, node);\n });\n input.addEventListener(\"keydown\", (e) => {\n if (e.key === \"Enter\" && !e.shiftKey && !e.isComposing) {\n e.preventDefault();\n form.requestSubmit();\n }\n });\n panel.addEventListener(\"keydown\", (e) => { if (e.key === \"Escape\") close(); });\n\n // --- open / close ----------------------------------------------------------------------------------------------\n function open() {\n if (destroyed || isOpen) return;\n isOpen = true;\n panel.classList.add(\"open\");\n launcher.setAttribute(\"aria-expanded\", \"true\");\n launcher.setAttribute(\"aria-label\", \"Close chat\");\n dot.classList.remove(\"on\");\n void loadHistory().then(() => { if (isOpen) restartPolling(); });\n input.focus();\n }\n function close() {\n if (!isOpen) return;\n isOpen = false;\n panel.classList.remove(\"open\");\n launcher.setAttribute(\"aria-expanded\", \"false\");\n launcher.setAttribute(\"aria-label\", \"Open chat\");\n launcher.focus();\n }\n function toggle() { isOpen ? close() : open(); }\n function destroy() {\n destroyed = true;\n if (timer) clearTimeout(timer);\n if (typingTimer) clearTimeout(typingTimer);\n host.remove();\n }\n launcher.addEventListener(\"click\", toggle);\n closeBtn.addEventListener(\"click\", close);\n\n // --- start: fetch the portal's settings, then show the launcher --------------------------------------------------\n void (async () => {\n try {\n const res = await api(\"/config\");\n if (!res.ok) {\n if (typeof console !== \"undefined\") console.warn(`[SeyalHub chat] not shown (${res.status}): check the site key and that this website is listed in the portal.`);\n return void destroy();\n }\n const cfg = (await res.json()) as { title: string; greeting: string; color: string };\n titleEl.textContent = options.title ?? cfg.title;\n greeting = options.greeting ?? cfg.greeting;\n applyColor(options.color ?? cfg.color);\n } catch {\n // the settings are optional: show the chat with defaults, and let sending report any real problem\n }\n if (destroyed) return;\n (options.container ?? document.body).append(host);\n if (storage.getItem(keyStarted)) void poll(); // a returning visitor: look for replies while closed, to show the unread dot\n if (options.open) open();\n })();\n\n return { open, close, toggle, destroy };\n}\n"],
|
|
5
|
+
"mappings": ";AACO,IAAM,MA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