@paramms/chat-widget 1.6.2 → 1.7.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/dist/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  var Be = Object.defineProperty;
2
2
  var $e = (t, e, d) => e in t ? Be(t, e, { enumerable: !0, configurable: !0, writable: !0, value: d }) : t[e] = d;
3
3
  var C = (t, e, d) => $e(t, typeof e != "symbol" ? e + "" : e, d);
4
- import { l as Re, b as ve, p as Me, r as Ae, a as qe } from "./codec.js";
5
- import { h as rt } from "./codec.js";
6
- import { P as Ne, C as Oe, b as De } from "./outbox.js";
7
- import { e as dt } from "./outbox.js";
8
- import { E2ESession as He, extractX3DHInit as _e } from "./e2e.js";
9
- const Ue = `
4
+ import { l as Re, b as ve, p as Me, r as Ae, c as qe, a as Ne, m as Oe } from "./chatlist2.js";
5
+ import { h as ut } from "./chatlist2.js";
6
+ import { P as De, C as He, b as _e } from "./outbox.js";
7
+ import { e as ft } from "./outbox.js";
8
+ import { E2ESession as Ue, extractX3DHInit as Fe } from "./e2e.js";
9
+ const We = `
10
10
  .ocw { ${Re("ocw")}
11
11
  position:relative;
12
12
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
@@ -197,30 +197,47 @@ const Ue = `
197
197
  .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
198
198
  .ocw-translation { margin-top:6px; padding-top:6px; border-top:1px solid var(--ocw-line); font-size:13px; line-height:1.45; }
199
199
  .ocw-translation::before { content:'🌐 '; opacity:.75; }
200
- `, ke = "objectchat-widget-styles", Fe = ["👍", "❤️", "😂", "😮", "😢", "🙏"], We = 400, Ge = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
201
- function Ke() {
200
+ `, ke = "objectchat-widget-styles", Ge = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Ke = 400, Ve = '<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M22 2 11 13M22 2l-7 20-4-9-9-4 20-7z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>';
201
+ function Ye() {
202
202
  if (typeof document > "u" || document.getElementById(ke)) return;
203
203
  const t = document.createElement("style");
204
- t.id = ke, t.textContent = Ue, document.head.appendChild(t);
204
+ t.id = ke, t.textContent = We, document.head.appendChild(t);
205
205
  }
206
206
  const Ce = "ocw-webfont";
207
- function Ve() {
207
+ function Xe() {
208
208
  if (typeof document > "u" || document.getElementById(Ce)) return;
209
209
  const t = document.createElement("link");
210
210
  t.id = Ce, t.rel = "stylesheet", t.href = "https://fonts.googleapis.com/css2?family=Baloo+2:wght@500;600;700&family=Nunito:wght@400;500;600;700&display=swap", document.head.appendChild(t);
211
211
  }
212
212
  function n(t, e, d) {
213
- const l = document.createElement(t);
214
- return e && (l.className = e), d !== void 0 && (l.textContent = d), l;
213
+ const s = document.createElement(t);
214
+ return e && (s.className = e), d !== void 0 && (s.textContent = d), s;
215
215
  }
216
- function Ye(t) {
216
+ function Qe(t, e) {
217
+ const d = /(https?:\/\/[^\s]+)/g;
218
+ let s = 0, c = null, h;
219
+ for (; (h = d.exec(e)) !== null; ) {
220
+ if (h.index > s) {
221
+ const a = document.createTextNode(e.slice(s, h.index));
222
+ t.append(a), c ?? (c = a);
223
+ }
224
+ let y = h[0], l = "";
225
+ const u = /[).,!?;:]+$/.exec(y);
226
+ u && (l = u[0], y = y.slice(0, -l.length));
227
+ const x = document.createElement("a");
228
+ x.href = y, x.target = "_blank", x.rel = "noopener noreferrer", x.textContent = y, x.style.cssText = "color:inherit;text-decoration:underline;word-break:break-all", t.append(x), l && t.append(document.createTextNode(l)), s = h.index + h[0].length;
229
+ }
230
+ const b = document.createTextNode(e.slice(s));
231
+ return t.append(b), c ?? (c = b), c;
232
+ }
233
+ function Je(t) {
217
234
  try {
218
235
  return new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
219
236
  } catch {
220
237
  return "";
221
238
  }
222
239
  }
223
- function ce(t) {
240
+ function re(t) {
224
241
  var e;
225
242
  switch (t.kind) {
226
243
  case "text":
@@ -237,9 +254,9 @@ function ce(t) {
237
254
  return `📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`;
238
255
  }
239
256
  }
240
- class Xe {
257
+ class Ze {
241
258
  /** Last seq the guest has seen per conversationId — used to compute unread badges. */
242
- constructor(e, d, l, c = {}) {
259
+ constructor(e, d, s, c = {}) {
243
260
  C(this, "scroll");
244
261
  C(this, "chips");
245
262
  C(this, "typing");
@@ -274,59 +291,59 @@ class Xe {
274
291
  /** Whether the subject card (server Subject entity, mount config fallback)
275
292
  * has been built — built once when data first arrives. */
276
293
  C(this, "subjectBuilt", !1);
277
- var z, O, S, _, a, i, y, h, x, k, E;
278
- this.root = e, this.me = d, this.h = l, this.cfg = c, Ke(), c.webfont !== !1 && Ve(), e.replaceChildren(), e.classList.add("ocw"), c.accent && e.style.setProperty("--ocw-accent", c.accent);
279
- const w = c.accent2 ?? c.accent;
280
- w && e.style.setProperty("--ocw-accent2", w), this.cfgAccent2 = c.accent2, e.dataset.theme = c.theme ?? "light";
294
+ var z, O, T, _, r, i, v, f, m, k, S;
295
+ this.root = e, this.me = d, this.h = s, this.cfg = c, Ye(), c.webfont !== !1 && Xe(), e.replaceChildren(), e.classList.add("ocw"), c.accent && e.style.setProperty("--ocw-accent", c.accent);
296
+ const h = c.accent2 ?? c.accent;
297
+ h && e.style.setProperty("--ocw-accent2", h), this.cfgAccent2 = c.accent2, e.dataset.theme = c.theme ?? "light";
281
298
  const b = n("div", "ocw-head");
282
299
  if (this.h.onBack) {
283
- const f = n("button", "ocw-back", "‹");
284
- f.type = "button", f.setAttribute("aria-label", "Back"), f.addEventListener("click", () => this.h.onBack()), b.append(f);
300
+ const w = n("button", "ocw-back", "‹");
301
+ w.type = "button", w.setAttribute("aria-label", "Back"), w.addEventListener("click", () => this.h.onBack()), b.append(w);
285
302
  }
286
- const v = ((z = c.subject) == null ? void 0 : z.ownerLabel) ?? ((O = c.subject) == null ? void 0 : O.title) ?? "", p = n("div", "ocw-avatar");
287
- v.trim() && (p.textContent = v.trim()[0].toUpperCase(), b.append(p));
303
+ const y = ((z = c.subject) == null ? void 0 : z.ownerLabel) ?? ((O = c.subject) == null ? void 0 : O.title) ?? "", l = n("div", "ocw-avatar");
304
+ y.trim() && (l.textContent = y.trim()[0].toUpperCase(), b.append(l));
288
305
  const u = n("div", "ocw-head-main");
289
- this.headerName = n("div", "ocw-head-name", ((S = c.subject) == null ? void 0 : S.ownerLabel) ?? ((_ = c.subject) == null ? void 0 : _.title) ?? ""), u.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", u.append(this.headStatus), (a = c.subject) != null && a.subtitle && u.append(n("div", "ocw-head-meta", c.subject.subtitle)), b.append(u), this.statusBadge = n("span", "ocw-badge", ((i = c.subject) == null ? void 0 : i.status) ?? ""), (y = c.subject) != null && y.status || (this.statusBadge.style.display = "none"), b.append(this.statusBadge), this.e2eBadge = n("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", b.append(this.e2eBadge), this.connStatus = n("span", "ocw-conn-status"), this.connStatus.style.display = "none", b.append(this.connStatus), b.append(n("button", "ocw-menu", "⋯")), this.chips = n("div", "ocw-chiprow"), this.scroll = n("div", "ocw-scroll"), this.subjectCard = n("div", "ocw-subject"), this.typing = n("div", "ocw-typing");
290
- const g = n("div", "ocw-typing-bubble");
291
- g.append(n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot")), this.typing.append(g), this.quick = n("div", "ocw-quick");
292
- for (const f of c.quickReplies ?? []) {
293
- const T = n("button", void 0, f);
294
- T.addEventListener("click", () => {
295
- this.h.onSend(f), this.quick.style.display = "none";
296
- }), this.quick.append(T);
306
+ this.headerName = n("div", "ocw-head-name", ((T = c.subject) == null ? void 0 : T.ownerLabel) ?? ((_ = c.subject) == null ? void 0 : _.title) ?? ""), u.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", u.append(this.headStatus), (r = c.subject) != null && r.subtitle && u.append(n("div", "ocw-head-meta", c.subject.subtitle)), b.append(u), this.statusBadge = n("span", "ocw-badge", ((i = c.subject) == null ? void 0 : i.status) ?? ""), (v = c.subject) != null && v.status || (this.statusBadge.style.display = "none"), b.append(this.statusBadge), this.e2eBadge = n("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", b.append(this.e2eBadge), this.connStatus = n("span", "ocw-conn-status"), this.connStatus.style.display = "none", b.append(this.connStatus), b.append(n("button", "ocw-menu", "⋯")), this.chips = n("div", "ocw-chiprow"), this.scroll = n("div", "ocw-scroll"), this.subjectCard = n("div", "ocw-subject"), this.typing = n("div", "ocw-typing");
307
+ const x = n("div", "ocw-typing-bubble");
308
+ x.append(n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot")), this.typing.append(x), this.quick = n("div", "ocw-quick");
309
+ for (const w of c.quickReplies ?? []) {
310
+ const I = n("button", void 0, w);
311
+ I.addEventListener("click", () => {
312
+ this.h.onSend(w), this.quick.style.display = "none";
313
+ }), this.quick.append(I);
297
314
  }
298
- this.formHost = n("div", "ocw-form-host"), this.csatPanel = n("div", "ocw-csat"), this.csatPanel.style.display = "none", this.awayNotice = n("div", "ocw-away"), this.awayNotice.style.display = "none", this.preChatPanel = n("div", "ocw-prechat"), this.preChatPanel.style.display = "none", this.deflectPanel = n("div", "ocw-deflect"), this.deflectPanel.style.display = "none", this.input = n("textarea", void 0), this.input.rows = 1, this.input.placeholder = ((h = c.i18n) == null ? void 0 : h.placeholder) ?? "Message…";
299
- const s = n("button", "ocw-sendbtn");
300
- s.type = "button";
301
- const $ = (x = c.i18n) == null ? void 0 : x.send;
302
- $ ? (s.textContent = $, s.classList.add("ocw-sendbtn-label"), s.setAttribute("aria-label", $)) : (s.innerHTML = Ge, s.setAttribute("aria-label", "Send message")), s.disabled = !0, this.sendBtn = s, s.addEventListener("click", () => this.flushSend()), this.input.addEventListener("input", () => {
303
- var f, T;
304
- this.sendBtn.disabled = this.input.value.trim().length === 0, this.autoGrowInput(), this.storeRef && !this.storeRef.messages().some((N) => N.senderRole === "guest") ? (T = (f = this.h).onDeflectQuery) == null || T.call(f, this.input.value) : this.hideDeflection();
305
- }), this.input.addEventListener("keydown", (f) => {
306
- f.isComposing || f.keyCode === 229 || (f.key === "Enter" && !f.shiftKey ? (f.preventDefault(), this.flushSend()) : this.signalTyping());
315
+ this.formHost = n("div", "ocw-form-host"), this.csatPanel = n("div", "ocw-csat"), this.csatPanel.style.display = "none", this.awayNotice = n("div", "ocw-away"), this.awayNotice.style.display = "none", this.preChatPanel = n("div", "ocw-prechat"), this.preChatPanel.style.display = "none", this.deflectPanel = n("div", "ocw-deflect"), this.deflectPanel.style.display = "none", this.input = n("textarea", void 0), this.input.rows = 1, this.input.placeholder = ((f = c.i18n) == null ? void 0 : f.placeholder) ?? "Message…";
316
+ const a = n("button", "ocw-sendbtn");
317
+ a.type = "button";
318
+ const j = (m = c.i18n) == null ? void 0 : m.send;
319
+ j ? (a.textContent = j, a.classList.add("ocw-sendbtn-label"), a.setAttribute("aria-label", j)) : (a.innerHTML = Ve, a.setAttribute("aria-label", "Send message")), a.disabled = !0, this.sendBtn = a, a.addEventListener("click", () => this.flushSend()), this.input.addEventListener("input", () => {
320
+ var w, I;
321
+ this.sendBtn.disabled = this.input.value.trim().length === 0, this.autoGrowInput(), this.storeRef && !this.storeRef.messages().some((N) => N.senderRole === "guest") ? (I = (w = this.h).onDeflectQuery) == null || I.call(w, this.input.value) : this.hideDeflection();
322
+ }), this.input.addEventListener("keydown", (w) => {
323
+ w.isComposing || w.keyCode === 229 || (w.key === "Enter" && !w.shiftKey ? (w.preventDefault(), this.flushSend()) : this.signalTyping());
307
324
  });
308
325
  const R = n("button", "ocw-attach", "📎");
309
326
  R.title = "Attach image or file";
310
- const I = document.createElement("input");
311
- I.type = "file", I.accept = "image/*,.pdf,.txt,.doc,.docx", I.style.display = "none", R.addEventListener("click", () => I.click()), I.addEventListener("change", () => {
312
- var f;
313
- (f = I.files) != null && f[0] && this.h.onAttach && this.h.onAttach(I.files[0]), I.value = "";
327
+ const E = document.createElement("input");
328
+ E.type = "file", E.accept = "image/*,.pdf,.txt,.doc,.docx", E.style.display = "none", R.addEventListener("click", () => E.click()), E.addEventListener("change", () => {
329
+ var w;
330
+ (w = E.files) != null && w[0] && this.h.onAttach && this.h.onAttach(E.files[0]), E.value = "";
314
331
  });
315
332
  const A = n("div", "ocw-input");
316
- A.append(R, I, this.input, s);
317
- const j = n("div", "ocw-footer");
318
- ((k = c.i18n) == null ? void 0 : k.poweredBy) !== void 0 ? j.textContent = c.i18n.poweredBy : j.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = j, this.reopenBtn = n("button", "ocw-reopen", ((E = this.cfg.i18n) == null ? void 0 : E.reopen) ?? "Reopen conversation"), this.reopenBtn.type = "button", this.reopenBtn.addEventListener("click", () => {
333
+ A.append(R, E, this.input, a);
334
+ const P = n("div", "ocw-footer");
335
+ ((k = c.i18n) == null ? void 0 : k.poweredBy) !== void 0 ? P.textContent = c.i18n.poweredBy : P.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = P, this.reopenBtn = n("button", "ocw-reopen", ((S = this.cfg.i18n) == null ? void 0 : S.reopen) ?? "Reopen conversation"), this.reopenBtn.type = "button", this.reopenBtn.addEventListener("click", () => {
319
336
  this.reopenBtn.style.display = "none";
320
- const f = this.root.querySelector(".ocw-input textarea");
321
- f == null || f.focus();
337
+ const w = this.root.querySelector(".ocw-input textarea");
338
+ w == null || w.focus();
322
339
  }), e.append(b, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.preChatPanel, this.deflectPanel, this.awayNotice, A, this.reopenBtn, this.footer);
323
- const P = (f) => {
324
- e.classList.toggle("ocw-compact", f > 0 && f < We);
340
+ const B = (w) => {
341
+ e.classList.toggle("ocw-compact", w > 0 && w < Ke);
325
342
  };
326
- P(e.clientWidth), typeof ResizeObserver < "u" && (this.compactObserver = new ResizeObserver((f) => {
343
+ B(e.clientWidth), typeof ResizeObserver < "u" && (this.compactObserver = new ResizeObserver((w) => {
327
344
  var N;
328
- const T = ((N = f[0]) == null ? void 0 : N.contentRect.width) ?? e.clientWidth;
329
- P(T);
345
+ const I = ((N = w[0]) == null ? void 0 : N.contentRect.width) ?? e.clientWidth;
346
+ B(I);
330
347
  }), this.compactObserver.observe(e));
331
348
  }
332
349
  /** Returns the scroll container so history.ts can attach scroll listeners. */
@@ -365,49 +382,49 @@ class Xe {
365
382
  this.cfg.i18n = { ...this.cfg.i18n ?? {}, aiAssistant: e };
366
383
  }
367
384
  render(e) {
368
- var I, A, j, P, z, O, S, _;
385
+ var E, A, P, B, z, O, T, _;
369
386
  if (this.storeRef = e, e.accent && (this.root.style.setProperty("--ocw-accent", e.accent), this.root.style.setProperty("--ocw-accent2", this.cfgAccent2 ?? e.accent)), this.e2eBadge.style.display = e.e2e ? "inline-flex" : "none", this.buildSubjectCard(e), e.subject) {
370
- const a = (I = this.cfg.subject) == null ? void 0 : I.ownerLabel;
371
- a && (this.headerName.textContent = a);
387
+ const r = (E = this.cfg.subject) == null ? void 0 : E.ownerLabel;
388
+ r && (this.headerName.textContent = r);
372
389
  }
373
390
  this.quick.style.display = e.messages().length === 0 ? "flex" : "none", this.chips.replaceChildren();
374
391
  const d = e.visibleActions();
375
392
  this.chips.style.display = d.length ? "flex" : "none";
376
- for (const a of d) this.chips.append(this.chipEl(a));
377
- const l = this.scroll.scrollHeight, c = this.scroll.scrollTop;
393
+ for (const r of d) this.chips.append(this.chipEl(r));
394
+ const s = this.scroll.scrollHeight, c = this.scroll.scrollTop;
378
395
  if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
379
- const a = n("div", "ocw-load-more");
380
- a.textContent = "↑ Loading earlier messages…", a.style.pointerEvents = "none", this.scroll.append(a);
396
+ const r = n("div", "ocw-load-more");
397
+ r.textContent = "↑ Loading earlier messages…", r.style.pointerEvents = "none", this.scroll.append(r);
381
398
  }
382
- let w = 0, b = null;
383
- const v = [...e.messages()];
384
- for (let a = 0; a < v.length; a++) {
385
- const i = v[a], y = i.senderRole !== "system" && i.senderId !== this.me && !i.internal && i.senderId !== b;
386
- this.scroll.append(this.messageEl(i, e, y, a === v.length - 1)), i.senderRole !== "system" && (b = i.senderId), i.senderId !== this.me && i.seq > w && (w = i.seq);
399
+ let h = 0, b = null;
400
+ const y = [...e.messages()];
401
+ for (let r = 0; r < y.length; r++) {
402
+ const i = y[r], v = i.senderRole !== "system" && i.senderId !== this.me && !i.internal && i.senderId !== b;
403
+ this.scroll.append(this.messageEl(i, e, v, r === y.length - 1)), i.senderRole !== "system" && (b = i.senderId), i.senderId !== this.me && i.seq > h && (h = i.seq);
387
404
  }
388
- c > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - l + c : this.scroll.scrollTop = this.scroll.scrollHeight, w > 0 && this.h.onReadUpTo(w);
389
- const p = [...e.typing];
390
- this.typing.classList.toggle("active", p.length > 0);
405
+ c > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - s + c : this.scroll.scrollTop = this.scroll.scrollHeight, h > 0 && this.h.onReadUpTo(h);
406
+ const l = [...e.typing];
407
+ this.typing.classList.toggle("active", l.length > 0);
391
408
  const u = this.typing.querySelector(".ocw-typing-bubble");
392
- u && u.setAttribute("aria-label", p.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block";
393
- const g = e.messages().some((a) => a.senderRole === "guest");
394
- if (!!((A = e.preChat) != null && A.enabled) && !this.preChatDone && !g && (e.preChat.showWhen !== "offline" || e.offline))
395
- this.preChatBuilt || this.buildPreChatPanel(e.preChat), this.preChatPanel.style.display = "block", this.awayNotice.style.display = "none", (j = this.root.querySelector(".ocw-input")) == null || j.style.setProperty("display", "none");
409
+ u && u.setAttribute("aria-label", l.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block";
410
+ const x = e.messages().some((r) => r.senderRole === "guest");
411
+ if (!!((A = e.preChat) != null && A.enabled) && !this.preChatDone && !x && (e.preChat.showWhen !== "offline" || e.offline))
412
+ this.preChatBuilt || this.buildPreChatPanel(e.preChat), this.preChatPanel.style.display = "block", this.awayNotice.style.display = "none", (P = this.root.querySelector(".ocw-input")) == null || P.style.setProperty("display", "none");
396
413
  else {
397
414
  if (this.preChatPanel.style.display = "none", e.offline) {
398
415
  this.awayNotice.firstChild || this.awayNotice.append(n("span", "ocw-away-icon", "🌙"), n("span", "", ""));
399
- const a = this.awayNotice.lastChild;
400
- a.textContent = e.offlineMessage || ((P = this.cfg.i18n) == null ? void 0 : P.offline) || "We're away right now — send your message and we'll reply as soon as we're back.", this.awayNotice.style.display = "flex";
416
+ const r = this.awayNotice.lastChild;
417
+ r.textContent = e.offlineMessage || ((B = this.cfg.i18n) == null ? void 0 : B.offline) || "We're away right now — send your message and we'll reply as soon as we're back.", this.awayNotice.style.display = "flex";
401
418
  } else
402
419
  this.awayNotice.style.display = "none";
403
420
  (z = this.root.querySelector(".ocw-input")) == null || z.style.removeProperty("display");
404
421
  }
405
- const $ = ["resolved", "closed", "sold", "issued", "checked_out"];
406
- this.h.onCsat && !this.csatSubmitted && $.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
407
- const R = $.includes(e.state);
408
- if (e.offline ? (this.headStatus.textContent = `● ${e.offlineMessage || ((O = this.cfg.i18n) == null ? void 0 : O.away) || "Away"}`, this.headStatus.className = "ocw-head-status away", this.headStatus.style.display = "") : e.conversationId ? (this.headStatus.textContent = `● ${((S = this.cfg.i18n) == null ? void 0 : S.online) ?? "Online"}`, this.headStatus.className = "ocw-head-status online", this.headStatus.style.display = "") : this.headStatus.style.display = "none", R && e.messages().length > 0) {
409
- const a = n("div", "ocw-resolved-note", `— ${((_ = this.cfg.i18n) == null ? void 0 : _.resolved) ?? "Marked as resolved"} —`);
410
- this.scroll.append(a), this.reopenBtn.style.display = "block";
422
+ const j = ["resolved", "closed", "sold", "issued", "checked_out"];
423
+ this.h.onCsat && !this.csatSubmitted && j.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
424
+ const R = j.includes(e.state);
425
+ if (e.offline ? (this.headStatus.textContent = `● ${e.offlineMessage || ((O = this.cfg.i18n) == null ? void 0 : O.away) || "Away"}`, this.headStatus.className = "ocw-head-status away", this.headStatus.style.display = "") : e.conversationId ? (this.headStatus.textContent = `● ${((T = this.cfg.i18n) == null ? void 0 : T.online) ?? "Online"}`, this.headStatus.className = "ocw-head-status online", this.headStatus.style.display = "") : this.headStatus.style.display = "none", R && e.messages().length > 0) {
426
+ const r = n("div", "ocw-resolved-note", `— ${((_ = this.cfg.i18n) == null ? void 0 : _.resolved) ?? "Marked as resolved"} —`);
427
+ this.scroll.append(r), this.reopenBtn.style.display = "block";
411
428
  } else
412
429
  this.reopenBtn.style.display = "none";
413
430
  }
@@ -417,58 +434,58 @@ class Xe {
417
434
  return;
418
435
  }
419
436
  this.connStatus.style.display = "";
420
- const l = e === "error";
421
- this.connStatus.className = `ocw-conn-status${l ? " err" : e === "reconnecting" ? " warn" : ""}`, this.connStatus.textContent = l ? `⚠ ${d ?? "Chat unavailable"}` : e === "reconnecting" ? d ?? "↻ reconnecting…" : "● connecting…";
437
+ const s = e === "error";
438
+ this.connStatus.className = `ocw-conn-status${s ? " err" : e === "reconnecting" ? " warn" : ""}`, this.connStatus.textContent = s ? `⚠ ${d ?? "Chat unavailable"}` : e === "reconnecting" ? d ?? "↻ reconnecting…" : "● connecting…";
422
439
  }
423
440
  buildPreChatPanel(e) {
424
- var p;
441
+ var l;
425
442
  this.preChatBuilt = !0, this.preChatPanel.replaceChildren(), this.preChatPanel.append(n("div", "ocw-prechat-title", e.title ?? "Before we start…"));
426
- const d = n("div", "ocw-offline-form"), l = {};
443
+ const d = n("div", "ocw-offline-form"), s = {};
427
444
  for (const u of e.fields ?? ["name", "email"]) {
428
- const g = n("input", "ocw-offline-input");
429
- g.type = u === "email" ? "email" : u === "phone" ? "tel" : "text", g.placeholder = u === "name" ? "Your name" : u === "email" ? "Your email" : "Your phone number", l[u] = g, d.append(g);
445
+ const x = n("input", "ocw-offline-input");
446
+ x.type = u === "email" ? "email" : u === "phone" ? "tel" : "text", x.placeholder = u === "name" ? "Your name" : u === "email" ? "Your email" : "Your phone number", s[u] = x, d.append(x);
430
447
  }
431
448
  let c = null;
432
- if ((p = e.topics) != null && p.length) {
449
+ if ((l = e.topics) != null && l.length) {
433
450
  c = n("select", void 0);
434
451
  const u = document.createElement("option");
435
452
  u.value = "", u.textContent = "What is this about?", c.append(u);
436
- for (const g of e.topics) {
437
- const s = document.createElement("option");
438
- s.value = g, s.textContent = g, c.append(s);
453
+ for (const x of e.topics) {
454
+ const a = document.createElement("option");
455
+ a.value = x, a.textContent = x, c.append(a);
439
456
  }
440
457
  d.append(c);
441
458
  }
442
- let w = null, b = null;
459
+ let h = null, b = null;
443
460
  if (e.callbackOption) {
444
461
  const u = n("label", "ocw-prechat-cb");
445
- w = document.createElement("input"), w.type = "checkbox", u.append(w, document.createTextNode("📞 Request a call back")), d.append(u), l.phone || (b = n("input", "ocw-offline-input"), b.type = "tel", b.placeholder = "Phone number for the call", b.style.display = "none", w.addEventListener("change", () => b.style.setProperty("display", w.checked ? "block" : "none")), d.append(b));
462
+ h = document.createElement("input"), h.type = "checkbox", u.append(h, document.createTextNode("📞 Request a call back")), d.append(u), s.phone || (b = n("input", "ocw-offline-input"), b.type = "tel", b.placeholder = "Phone number for the call", b.style.display = "none", h.addEventListener("change", () => b.style.setProperty("display", h.checked ? "block" : "none")), d.append(b));
446
463
  }
447
- const v = n("button", "ocw-offline-submit", "Start chat");
448
- v.type = "button", v.addEventListener("click", () => {
449
- var $, R, I, A, j, P, z;
450
- const u = ($ = l.email) == null ? void 0 : $.value.trim();
451
- if (l.email && (!u || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u))) {
452
- l.email.focus();
464
+ const y = n("button", "ocw-offline-submit", "Start chat");
465
+ y.type = "button", y.addEventListener("click", () => {
466
+ var j, R, E, A, P, B, z;
467
+ const u = (j = s.email) == null ? void 0 : j.value.trim();
468
+ if (s.email && (!u || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(u))) {
469
+ s.email.focus();
453
470
  return;
454
471
  }
455
- const g = !!(w != null && w.checked), s = (((R = l.phone) == null ? void 0 : R.value) ?? (b == null ? void 0 : b.value) ?? "").trim();
456
- if (g && !s) {
457
- (I = l.phone ?? b) == null || I.focus();
472
+ const x = !!(h != null && h.checked), a = (((R = s.phone) == null ? void 0 : R.value) ?? (b == null ? void 0 : b.value) ?? "").trim();
473
+ if (x && !a) {
474
+ (E = s.phone ?? b) == null || E.focus();
458
475
  return;
459
476
  }
460
477
  if (c && ((A = e.topics) != null && A.length) && !c.value) {
461
478
  c.focus();
462
479
  return;
463
480
  }
464
- v.disabled = !0, this.completePreChat(), (z = (P = this.h).onPreChat) == null || z.call(P, {
465
- ...(j = l.name) != null && j.value.trim() ? { name: l.name.value.trim() } : {},
481
+ y.disabled = !0, this.completePreChat(), (z = (B = this.h).onPreChat) == null || z.call(B, {
482
+ ...(P = s.name) != null && P.value.trim() ? { name: s.name.value.trim() } : {},
466
483
  ...u ? { email: u } : {},
467
- ...s ? { phone: s } : {},
484
+ ...a ? { phone: a } : {},
468
485
  ...c != null && c.value ? { topic: c.value } : {},
469
- ...g ? { callback: !0 } : {}
486
+ ...x ? { callback: !0 } : {}
470
487
  });
471
- }), d.append(v), this.preChatPanel.append(d);
488
+ }), d.append(y), this.preChatPanel.append(d);
472
489
  }
473
490
  /** Mark pre-chat complete (submitted now or in a previous session). */
474
491
  completePreChat() {
@@ -479,8 +496,8 @@ class Xe {
479
496
  if (!e.length) return this.hideDeflection();
480
497
  this.deflectPanel.replaceChildren(), this.deflectPanel.append(n("div", "ocw-deflect-hint", "Instant answers — tap to expand"));
481
498
  for (const d of e.slice(0, 3)) {
482
- const l = n("button", "ocw-deflect-card");
483
- l.append(n("div", "ocw-deflect-q", d.title), n("div", "ocw-deflect-a", d.answer)), l.addEventListener("click", () => l.classList.toggle("open")), this.deflectPanel.append(l);
499
+ const s = n("button", "ocw-deflect-card");
500
+ s.append(n("div", "ocw-deflect-q", d.title), n("div", "ocw-deflect-a", d.answer)), s.addEventListener("click", () => s.classList.toggle("open")), this.deflectPanel.append(s);
484
501
  }
485
502
  this.deflectPanel.style.display = "flex";
486
503
  }
@@ -490,265 +507,265 @@ class Xe {
490
507
  buildCsatPanel() {
491
508
  this.csatPanel.replaceChildren(), this.csatPanel.append(n("div", "ocw-csat-title", "How did we do?"));
492
509
  const e = n("div", "ocw-csat-stars"), d = [];
493
- for (let l = 1; l <= 5; l++) {
510
+ for (let s = 1; s <= 5; s++) {
494
511
  const c = n("button", "ocw-csat-star", "★");
495
- c.dataset.score = String(l), c.addEventListener("mouseenter", () => d.forEach((w, b) => w.classList.toggle("lit", b < l))), c.addEventListener("mouseleave", () => d.forEach((w) => w.classList.remove("lit"))), c.addEventListener("click", () => {
496
- var w, b;
497
- this.csatSubmitted = !0, this.csatPanel.replaceChildren(n("div", "ocw-csat-done", `Thanks for your ${l}★ rating!`)), (b = (w = this.h).onCsat) == null || b.call(w, l);
512
+ c.dataset.score = String(s), c.addEventListener("mouseenter", () => d.forEach((h, b) => h.classList.toggle("lit", b < s))), c.addEventListener("mouseleave", () => d.forEach((h) => h.classList.remove("lit"))), c.addEventListener("click", () => {
513
+ var h, b;
514
+ this.csatSubmitted = !0, this.csatPanel.replaceChildren(n("div", "ocw-csat-done", `Thanks for your ${s}★ rating!`)), (b = (h = this.h).onCsat) == null || b.call(h, s);
498
515
  }), d.push(c), e.append(c);
499
516
  }
500
517
  this.csatPanel.append(e);
501
518
  }
502
519
  buildSubjectCard(e) {
503
520
  if (this.subjectBuilt) return;
504
- const d = e.subject, l = this.cfg.subject, c = (d == null ? void 0 : d.title) ?? (l == null ? void 0 : l.title);
521
+ const d = e.subject, s = this.cfg.subject, c = (d == null ? void 0 : d.title) ?? (s == null ? void 0 : s.title);
505
522
  if (!c) return;
506
- this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(n("div", "ocw-subject-title", c)), l != null && l.subtitle && this.subjectCard.append(n("div", "ocw-subject-sub", l.subtitle));
507
- const w = n("div", "ocw-tags");
508
- if (d) for (const [v, p] of Object.entries(d.fields)) w.append(n("span", "ocw-tag", `${v}: ${p}`));
509
- else for (const v of (l == null ? void 0 : l.tags) ?? []) w.append(n("span", "ocw-tag", v));
510
- w.childNodes.length && this.subjectCard.append(w);
511
- const b = (d == null ? void 0 : d.state) ?? (l == null ? void 0 : l.status);
523
+ this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(n("div", "ocw-subject-title", c)), s != null && s.subtitle && this.subjectCard.append(n("div", "ocw-subject-sub", s.subtitle));
524
+ const h = n("div", "ocw-tags");
525
+ if (d) for (const [y, l] of Object.entries(d.fields)) h.append(n("span", "ocw-tag", `${y}: ${l}`));
526
+ else for (const y of (s == null ? void 0 : s.tags) ?? []) h.append(n("span", "ocw-tag", y));
527
+ h.childNodes.length && this.subjectCard.append(h);
528
+ const b = (d == null ? void 0 : d.state) ?? (s == null ? void 0 : s.status);
512
529
  b && (this.statusBadge.textContent = b, this.statusBadge.style.display = "inline-flex");
513
530
  }
514
531
  chipEl(e) {
515
532
  const d = n("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
516
533
  return d.dataset.actionId = e.id, d.addEventListener("click", async () => {
517
- var l;
518
- e.confirm && !await this.confirm(e.label) || ((l = e.input) != null && l.length ? this.openForm(e) : this.h.onInvoke(e.id));
534
+ var s;
535
+ e.confirm && !await this.confirm(e.label) || ((s = e.input) != null && s.length ? this.openForm(e) : this.h.onInvoke(e.id));
519
536
  }), d;
520
537
  }
521
538
  /** In-widget confirmation modal (replaces window.confirm). */
522
539
  confirm(e) {
523
540
  return new Promise((d) => {
524
- const l = n("div", "ocw-modal"), c = n("div", "ocw-modal-card");
541
+ const s = n("div", "ocw-modal"), c = n("div", "ocw-modal-card");
525
542
  c.append(n("div", "ocw-modal-title", e)), c.append(n("div", "ocw-modal-body", `Confirm “${e}”?`));
526
- const w = n("div", "ocw-modal-actions"), b = n("button", "ocw-modal-cancel", "Cancel"), v = n("button", "ocw-modal-ok", "Confirm"), p = (u) => {
527
- l.remove(), d(u);
543
+ const h = n("div", "ocw-modal-actions"), b = n("button", "ocw-modal-cancel", "Cancel"), y = n("button", "ocw-modal-ok", "Confirm"), l = (u) => {
544
+ s.remove(), d(u);
528
545
  };
529
- b.addEventListener("click", () => p(!1)), v.addEventListener("click", () => p(!0)), l.addEventListener("click", (u) => {
530
- u.target === l && p(!1);
531
- }), w.append(b, v), c.append(w), l.append(c), this.root.append(l), v.focus();
546
+ b.addEventListener("click", () => l(!1)), y.addEventListener("click", () => l(!0)), s.addEventListener("click", (u) => {
547
+ u.target === s && l(!1);
548
+ }), h.append(b, y), c.append(h), s.append(c), this.root.append(s), y.focus();
532
549
  });
533
550
  }
534
551
  /** Inline form for a form-effect action: typed inputs (date picker, number,
535
552
  * text) rendered above the composer — no browser prompts. */
536
553
  openForm(e) {
537
- var v, p;
554
+ var y, l;
538
555
  this.formHost.replaceChildren();
539
556
  const d = n("div", "ocw-form");
540
557
  d.append(n("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
541
- const l = /* @__PURE__ */ new Map();
558
+ const s = /* @__PURE__ */ new Map();
542
559
  for (const u of e.input ?? []) {
543
- const g = n("label", "ocw-form-row");
544
- if (g.append(n("span", "ocw-form-lbl", u.label)), u.type === "select" && ((v = u.options) != null && v.length)) {
545
- const s = n("select", "ocw-form-input");
546
- u.required || s.append(n("option", void 0, "— select —"));
547
- for (const $ of u.options) {
560
+ const x = n("label", "ocw-form-row");
561
+ if (x.append(n("span", "ocw-form-lbl", u.label)), u.type === "select" && ((y = u.options) != null && y.length)) {
562
+ const a = n("select", "ocw-form-input");
563
+ u.required || a.append(n("option", void 0, "— select —"));
564
+ for (const j of u.options) {
548
565
  const R = n("option");
549
- R.value = $, R.textContent = $, s.append(R);
566
+ R.value = j, R.textContent = j, a.append(R);
550
567
  }
551
- u.required && (s.required = !0), g.append(s), l.set(u.name, s);
568
+ u.required && (a.required = !0), x.append(a), s.set(u.name, a);
552
569
  } else {
553
- const s = n("input", "ocw-form-input");
554
- s.type = u.type === "number" ? "number" : u.type === "date" ? "datetime-local" : "text", u.required && (s.required = !0), g.append(s), l.set(u.name, s);
570
+ const a = n("input", "ocw-form-input");
571
+ a.type = u.type === "number" ? "number" : u.type === "date" ? "datetime-local" : "text", u.required && (a.required = !0), x.append(a), s.set(u.name, a);
555
572
  }
556
- d.append(g);
573
+ d.append(x);
557
574
  }
558
- const c = n("div", "ocw-form-actions"), w = n("button", "ocw-form-cancel", "Cancel"), b = n("button", "ocw-form-submit", "Send");
559
- w.addEventListener("click", () => this.formHost.replaceChildren()), b.addEventListener("click", () => {
575
+ const c = n("div", "ocw-form-actions"), h = n("button", "ocw-form-cancel", "Cancel"), b = n("button", "ocw-form-submit", "Send");
576
+ h.addEventListener("click", () => this.formHost.replaceChildren()), b.addEventListener("click", () => {
560
577
  const u = {};
561
- for (const [g, s] of l) {
562
- if (s.required && !s.value) {
563
- s.style.borderColor = "#e5484d";
578
+ for (const [x, a] of s) {
579
+ if (a.required && !a.value) {
580
+ a.style.borderColor = "#e5484d";
564
581
  return;
565
582
  }
566
- u[g] = s.type === "number" ? Number(s.value) : s.value;
583
+ u[x] = a.type === "number" ? Number(a.value) : a.value;
567
584
  }
568
585
  this.formHost.replaceChildren(), this.h.onInvoke(e.id, u);
569
- }), c.append(w, b), d.append(c), this.formHost.append(d), (p = l.values().next().value) == null || p.focus();
586
+ }), c.append(h, b), d.append(c), this.formHost.append(d), (l = s.values().next().value) == null || l.focus();
570
587
  }
571
- messageEl(e, d, l = !1, c = !1) {
572
- var R, I, A, j, P, z, O, S, _;
588
+ messageEl(e, d, s = !1, c = !1) {
589
+ var R, E, A, P, B, z, O, T, _;
573
590
  if (e.senderRole === "system") {
574
- const a = n("div", "ocw-sys");
575
- return a.textContent = e.deletedAt ? "message deleted" : ce(e.content), a;
591
+ const r = n("div", "ocw-sys");
592
+ return r.textContent = e.deletedAt ? "message deleted" : re(e.content), r;
576
593
  }
577
- const w = e.senderId === this.me, b = !!e.internal, v = n("div", `ocw-row ${b ? "ocw-note mine" : w ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`), p = n("div");
578
- if (l) {
579
- const a = e.senderRole === "bot" ? ((R = this.cfg.i18n) == null ? void 0 : R.aiAssistant) ?? "AI Assistant" : ((I = this.cfg.subject) == null ? void 0 : I.ownerLabel) ?? ((A = this.cfg.subject) == null ? void 0 : A.title) ?? "Support";
580
- p.append(n("div", "ocw-msg-sender", a));
594
+ const h = e.senderId === this.me, b = !!e.internal, y = n("div", `ocw-row ${b ? "ocw-note mine" : h ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`), l = n("div");
595
+ if (s) {
596
+ const r = e.senderRole === "bot" ? ((R = this.cfg.i18n) == null ? void 0 : R.aiAssistant) ?? "AI Assistant" : ((E = this.cfg.subject) == null ? void 0 : E.ownerLabel) ?? ((A = this.cfg.subject) == null ? void 0 : A.title) ?? "Support";
597
+ l.append(n("div", "ocw-msg-sender", r));
581
598
  }
582
599
  const u = n("div", "ocw-bubble-wrap");
583
600
  if (e.replyToId) {
584
- const a = n("div", "ocw-reply-to", "↩ replying to a message");
585
- a.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", p.append(a);
601
+ const r = n("div", "ocw-reply-to", "↩ replying to a message");
602
+ r.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", l.append(r);
586
603
  }
587
- const g = n("div", "ocw-bubble");
588
- let s = null;
589
- if (e.deletedAt) g.append(n("span", "ocw-deleted", "message deleted"));
604
+ const x = n("div", "ocw-bubble");
605
+ let a = null;
606
+ if (e.deletedAt) x.append(n("span", "ocw-deleted", "message deleted"));
590
607
  else if (e.content.kind === "attachment") {
591
- const a = e.content;
592
- if ((j = a.mime) != null && j.startsWith("image/")) {
608
+ const r = e.content;
609
+ if ((P = r.mime) != null && P.startsWith("image/")) {
593
610
  const i = document.createElement("img");
594
- i.src = a.url, i.alt = a.name ?? "image", i.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", i.addEventListener("click", () => window.open(a.url, "_blank")), g.append(i);
595
- } else if ((P = a.mime) != null && P.startsWith("video/")) {
611
+ i.src = r.url, i.alt = r.name ?? "image", i.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", i.addEventListener("click", () => window.open(r.url, "_blank")), x.append(i);
612
+ } else if ((B = r.mime) != null && B.startsWith("video/")) {
596
613
  const i = document.createElement("video");
597
- i.src = a.url, i.controls = !0, i.style.cssText = "max-width:240px;max-height:180px;border-radius:10px;display:block", g.append(i);
614
+ i.src = r.url, i.controls = !0, i.style.cssText = "max-width:240px;max-height:180px;border-radius:10px;display:block", x.append(i);
598
615
  } else {
599
616
  const i = document.createElement("a");
600
- i.href = a.url, i.target = "_blank", i.rel = "noopener", i.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", i.append(n("span", void 0, "📄"), n("span", void 0, a.name ?? "file")), g.append(i);
617
+ i.href = r.url, i.target = "_blank", i.rel = "noopener", i.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", i.append(n("span", void 0, "📄"), n("span", void 0, r.name ?? "file")), x.append(i);
601
618
  }
602
619
  } else if (e.content.kind === "appointment") {
603
- const a = e.content, i = n("div", "ocw-appt");
604
- i.append(n("div", "ocw-appt-title", `📅 ${a.title}`)), i.append(n("div", "ocw-appt-time", new Date(a.startIso).toLocaleString() + " – " + new Date(a.endIso).toLocaleTimeString())), a.location && i.append(n("div", "ocw-appt-loc", `📍 ${a.location}`)), a.description && i.append(n("div", "ocw-appt-desc", a.description));
605
- const y = n("div", "ocw-appt-links"), h = document.createElement("a");
606
- h.href = a.googleUrl, h.target = "_blank", h.rel = "noopener", h.className = "ocw-appt-btn", h.textContent = "📅 Add to Google Calendar";
607
- const x = document.createElement("a");
608
- x.href = a.icalUrl, x.download = `${a.title}.ics`, x.className = "ocw-appt-btn ocw-appt-btn-sec", x.textContent = "🍎 Apple / iCal", y.append(h, x), i.append(y), g.append(i);
620
+ const r = e.content, i = n("div", "ocw-appt");
621
+ i.append(n("div", "ocw-appt-title", `📅 ${r.title}`)), i.append(n("div", "ocw-appt-time", new Date(r.startIso).toLocaleString() + " – " + new Date(r.endIso).toLocaleTimeString())), r.location && i.append(n("div", "ocw-appt-loc", `📍 ${r.location}`)), r.description && i.append(n("div", "ocw-appt-desc", r.description));
622
+ const v = n("div", "ocw-appt-links"), f = document.createElement("a");
623
+ f.href = r.googleUrl, f.target = "_blank", f.rel = "noopener", f.className = "ocw-appt-btn", f.textContent = "📅 Add to Google Calendar";
624
+ const m = document.createElement("a");
625
+ m.href = r.icalUrl, m.download = `${r.title}.ics`, m.className = "ocw-appt-btn ocw-appt-btn-sec", m.textContent = "🍎 Apple / iCal", v.append(f, m), i.append(v), x.append(i);
609
626
  } else
610
- s = document.createTextNode(ce(e.content)), g.append(s), e.editedAt && g.append(n("span", "ocw-edited", "(edited)"));
611
- if (u.append(g), c && !e.deletedAt && e.content.kind === "text" && ((z = e.content.quickReplies) != null && z.length)) {
612
- const a = n("div", "ocw-flow-choices");
613
- a.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";
627
+ a = Qe(x, re(e.content)), e.editedAt && x.append(n("span", "ocw-edited", "(edited)"));
628
+ if (u.append(x), c && !e.deletedAt && e.content.kind === "text" && ((z = e.content.quickReplies) != null && z.length)) {
629
+ const r = n("div", "ocw-flow-choices");
630
+ r.style.cssText = "display:flex;flex-wrap:wrap;gap:6px;margin-top:6px";
614
631
  for (const i of e.content.quickReplies) {
615
- const y = n("button", "ocw-flow-choice", i);
616
- y.type = "button", y.style.cssText = "border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer", y.addEventListener("click", () => {
617
- a.querySelectorAll("button").forEach((h) => h.disabled = !0), a.style.opacity = "0.5", this.h.onSend(i);
618
- }), a.append(y);
632
+ const v = n("button", "ocw-flow-choice", i);
633
+ v.type = "button", v.style.cssText = "border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:var(--ocw-bg,#fff);color:inherit;border-radius:14px;padding:5px 12px;font:inherit;font-size:13px;cursor:pointer", v.addEventListener("click", () => {
634
+ r.querySelectorAll("button").forEach((f) => f.disabled = !0), r.style.opacity = "0.5", this.h.onSend(i);
635
+ }), r.append(v);
619
636
  }
620
- u.append(a);
637
+ u.append(r);
621
638
  }
622
- if (!w && !b && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && s) {
623
- const a = e.content.text;
624
- if (a.trim()) {
639
+ if (!h && !b && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && a) {
640
+ const r = e.content.text;
641
+ if (r.trim()) {
625
642
  const i = n("button", "ocw-translate-btn", "🌐");
626
643
  i.type = "button", i.title = "Translate";
627
- const y = n("div", "ocw-translation");
628
- y.style.display = "none", g.append(y);
629
- const h = (E) => {
630
- y.textContent = E, y.style.display = "", this.showingTranslation.add(e.id), i.textContent = "↩", i.title = "Show original";
631
- }, x = () => {
632
- y.style.display = "none", this.showingTranslation.delete(e.id), i.textContent = "🌐", i.title = "Translate";
644
+ const v = n("div", "ocw-translation");
645
+ v.style.display = "none", x.append(v);
646
+ const f = (S) => {
647
+ v.textContent = S, v.style.display = "", this.showingTranslation.add(e.id), i.textContent = "↩", i.title = "Show original";
648
+ }, m = () => {
649
+ v.style.display = "none", this.showingTranslation.delete(e.id), i.textContent = "🌐", i.title = "Translate";
633
650
  };
634
- i.addEventListener("click", (E) => {
635
- if (E.stopPropagation(), this.showingTranslation.has(e.id)) {
636
- x();
651
+ i.addEventListener("click", (S) => {
652
+ if (S.stopPropagation(), this.showingTranslation.has(e.id)) {
653
+ m();
637
654
  return;
638
655
  }
639
- const f = this.translationCache.get(e.id);
640
- if (f !== void 0) {
641
- h(f);
656
+ const w = this.translationCache.get(e.id);
657
+ if (w !== void 0) {
658
+ f(w);
642
659
  return;
643
660
  }
644
- i.textContent = "⏳", this.h.onTranslate(a).then((T) => {
645
- if (T === null) {
661
+ i.textContent = "⏳", this.h.onTranslate(r).then((I) => {
662
+ if (I === null) {
646
663
  i.textContent = "⚠️", i.title = "Translation unavailable", setTimeout(() => {
647
664
  i.textContent = "🌐", i.title = "Translate";
648
665
  }, 1500);
649
666
  return;
650
667
  }
651
- this.translationCache.set(e.id, T), h(T);
668
+ this.translationCache.set(e.id, I), f(I);
652
669
  });
653
670
  }), u.append(i);
654
671
  const k = this.translationCache.get(e.id);
655
- this.showingTranslation.has(e.id) && k !== void 0 && h(k);
672
+ this.showingTranslation.has(e.id) && k !== void 0 && f(k);
656
673
  }
657
674
  }
658
- if (w && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
659
- const a = n("div", "ocw-msg-menu");
675
+ if (h && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
676
+ const r = n("div", "ocw-msg-menu");
660
677
  if (this.h.onEdit) {
661
678
  const i = n("button", void 0, "✏️");
662
- i.title = "Edit", i.addEventListener("click", (y) => {
663
- y.stopPropagation();
664
- const h = ce(e.content), x = document.createElement("textarea");
665
- x.value = h, x.rows = Math.min(4, Math.ceil(h.length / 40) + 1), x.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";
679
+ i.title = "Edit", i.addEventListener("click", (v) => {
680
+ v.stopPropagation();
681
+ const f = re(e.content), m = document.createElement("textarea");
682
+ m.value = f, m.rows = Math.min(4, Math.ceil(f.length / 40) + 1), m.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:var(--ocw-card);color:#1c1b1a;box-sizing:border-box";
666
683
  const k = n("button", "ocw-form-submit", "Save");
667
684
  k.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
668
- const E = n("button", "ocw-form-cancel", "Cancel");
669
- E.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
670
- const f = n("div");
671
- f.style.cssText = "display:flex;gap:6px;justify-content:flex-end", f.append(E, k);
672
- const T = n("div");
673
- T.append(x, f), g.replaceChildren(T), x.focus(), x.select();
674
- const N = () => g.replaceChildren(s ?? document.createTextNode(h));
675
- E.addEventListener("click", N), k.addEventListener("click", () => {
676
- const D = x.value.trim();
677
- D && D !== h && this.h.onEdit(e.id, D), N();
678
- }), x.addEventListener("keydown", (D) => {
685
+ const S = n("button", "ocw-form-cancel", "Cancel");
686
+ S.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
687
+ const w = n("div");
688
+ w.style.cssText = "display:flex;gap:6px;justify-content:flex-end", w.append(S, k);
689
+ const I = n("div");
690
+ I.append(m, w), x.replaceChildren(I), m.focus(), m.select();
691
+ const N = () => x.replaceChildren(a ?? document.createTextNode(f));
692
+ S.addEventListener("click", N), k.addEventListener("click", () => {
693
+ const D = m.value.trim();
694
+ D && D !== f && this.h.onEdit(e.id, D), N();
695
+ }), m.addEventListener("keydown", (D) => {
679
696
  D.key === "Enter" && !D.shiftKey && (D.preventDefault(), k.click()), D.key === "Escape" && N();
680
697
  });
681
- }), a.append(i);
698
+ }), r.append(i);
682
699
  }
683
700
  if (this.h.onDelete) {
684
701
  const i = n("button", "del", "🗑");
685
- i.title = "Delete", i.addEventListener("click", (y) => {
686
- y.stopPropagation(), this.h.onDelete(e.id);
687
- }), a.append(i);
702
+ i.title = "Delete", i.addEventListener("click", (v) => {
703
+ v.stopPropagation(), this.h.onDelete(e.id);
704
+ }), r.append(i);
688
705
  }
689
- u.append(a);
706
+ u.append(r);
690
707
  }
691
- if (p.append(u), e.senderRole === "bot" && !e.deletedAt && e.seq > 0 && e.content.kind === "text") {
692
- const a = e.content.citations;
693
- if (a != null && a.length) {
708
+ if (l.append(u), e.senderRole === "bot" && !e.deletedAt && e.seq > 0 && e.content.kind === "text") {
709
+ const r = e.content.citations;
710
+ if (r != null && r.length) {
694
711
  const i = n("div", "ocw-cites");
695
- i.style.cssText = "margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)", i.textContent = `${((O = this.cfg.i18n) == null ? void 0 : O.sources) ?? "Sources"}: ${a.map((y) => y.source).join(", ")}`, p.append(i);
712
+ i.style.cssText = "margin-top:4px;font-size:11px;color:var(--ocw-mut,#667)", i.textContent = `${((O = this.cfg.i18n) == null ? void 0 : O.sources) ?? "Sources"}: ${r.map((v) => v.source).join(", ")}`, l.append(i);
696
713
  }
697
714
  if (this.h.onReact) {
698
715
  const i = n("div", "ocw-bot-feedback");
699
716
  i.style.cssText = "display:flex;gap:6px;margin-top:4px";
700
- const y = (h, x) => {
701
- const k = n("button", "ocw-fb-btn", h);
702
- k.type = "button", k.title = x, k.style.cssText = "border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";
703
- const E = () => {
704
- var f, T;
705
- return !!((T = (f = e.reactions) == null ? void 0 : f[h]) != null && T.includes(this.me));
717
+ const v = (f, m) => {
718
+ const k = n("button", "ocw-fb-btn", f);
719
+ k.type = "button", k.title = m, k.style.cssText = "border:1px solid var(--ocw-bd,rgba(0,0,0,.12));background:transparent;border-radius:12px;padding:1px 8px;font-size:12px;cursor:pointer;opacity:.7";
720
+ const S = () => {
721
+ var w, I;
722
+ return !!((I = (w = e.reactions) == null ? void 0 : w[f]) != null && I.includes(this.me));
706
723
  };
707
- return E() && (k.style.opacity = "1"), k.addEventListener("click", () => {
708
- var f, T;
709
- (T = (f = this.h).onReact) == null || T.call(f, e.id, h, E()), k.style.opacity = "1";
724
+ return S() && (k.style.opacity = "1"), k.addEventListener("click", () => {
725
+ var w, I;
726
+ (I = (w = this.h).onReact) == null || I.call(w, e.id, f, S()), k.style.opacity = "1";
710
727
  }), k;
711
728
  };
712
- i.append(y("👍", ((S = this.cfg.i18n) == null ? void 0 : S.helpful) ?? "Helpful"), y("👎", ((_ = this.cfg.i18n) == null ? void 0 : _.notHelpful) ?? "Not helpful")), p.append(i);
729
+ i.append(v("👍", ((T = this.cfg.i18n) == null ? void 0 : T.helpful) ?? "Helpful"), v("👎", ((_ = this.cfg.i18n) == null ? void 0 : _.notHelpful) ?? "Not helpful")), l.append(i);
713
730
  }
714
731
  }
715
732
  if (this.h.onReact && !e.deletedAt && e.seq > 0) {
716
- const a = n("div", "ocw-react-wrap"), i = n("div", "ocw-react");
733
+ const r = n("div", "ocw-react-wrap"), i = n("div", "ocw-react");
717
734
  if (e.reactions && Object.keys(e.reactions).length)
718
- for (const [x, k] of Object.entries(e.reactions)) {
719
- const E = n("button", `ocw-react-pill${k.includes(this.me) ? " mine" : ""}`, `${x} ${k.length}`);
720
- E.addEventListener("click", () => {
721
- var f, T;
722
- return (T = (f = this.h).onReact) == null ? void 0 : T.call(f, e.id, x, k.includes(this.me));
723
- }), i.append(E);
735
+ for (const [m, k] of Object.entries(e.reactions)) {
736
+ const S = n("button", `ocw-react-pill${k.includes(this.me) ? " mine" : ""}`, `${m} ${k.length}`);
737
+ S.addEventListener("click", () => {
738
+ var w, I;
739
+ return (I = (w = this.h).onReact) == null ? void 0 : I.call(w, e.id, m, k.includes(this.me));
740
+ }), i.append(S);
724
741
  }
725
- const y = n("button", "ocw-react-btn", "+"), h = n("div", "ocw-react-picker");
726
- for (const x of Fe) {
727
- const k = n("button", void 0, x);
728
- k.addEventListener("click", (E) => {
729
- var T, N, D, X;
730
- E.stopPropagation();
731
- const f = (N = (T = e.reactions) == null ? void 0 : T[x]) == null ? void 0 : N.includes(this.me);
732
- (X = (D = this.h).onReact) == null || X.call(D, e.id, x, !!f), h.style.display = "none";
733
- }), h.append(k);
742
+ const v = n("button", "ocw-react-btn", "+"), f = n("div", "ocw-react-picker");
743
+ for (const m of Ge) {
744
+ const k = n("button", void 0, m);
745
+ k.addEventListener("click", (S) => {
746
+ var I, N, D, X;
747
+ S.stopPropagation();
748
+ const w = (N = (I = e.reactions) == null ? void 0 : I[m]) == null ? void 0 : N.includes(this.me);
749
+ (X = (D = this.h).onReact) == null || X.call(D, e.id, m, !!w), f.style.display = "none";
750
+ }), f.append(k);
734
751
  }
735
- h.style.display = "none", y.addEventListener("click", (x) => {
736
- x.stopPropagation();
737
- const k = h.style.display === "none";
738
- h.style.display = k ? "flex" : "none", k && document.addEventListener("click", () => {
739
- h.style.display = "none";
752
+ f.style.display = "none", v.addEventListener("click", (m) => {
753
+ m.stopPropagation();
754
+ const k = f.style.display === "none";
755
+ f.style.display = k ? "flex" : "none", k && document.addEventListener("click", () => {
756
+ f.style.display = "none";
740
757
  }, { once: !0 });
741
- }), i.append(y), a.append(i, h), p.append(a);
742
- } else e.reactions && Object.keys(e.reactions).length && p.append(n("div", "ocw-react", Object.entries(e.reactions).map(([a, i]) => `${a}${i.length}`).join(" ")));
743
- const $ = n("div", "ocw-time ocw-meta", Ye(e.ts));
744
- if (w && e.status) {
745
- const a = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Qe(e.status));
746
- $.append(a);
758
+ }), i.append(v), r.append(i, f), l.append(r);
759
+ } else e.reactions && Object.keys(e.reactions).length && l.append(n("div", "ocw-react", Object.entries(e.reactions).map(([r, i]) => `${r}${i.length}`).join(" ")));
760
+ const j = n("div", "ocw-time ocw-meta", Je(e.ts));
761
+ if (h && e.status) {
762
+ const r = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, et(e.status));
763
+ j.append(r);
747
764
  }
748
- return w && e.seq > 0 && d.lastReadByOthers >= e.seq && $.append(n("span", "ocw-seen", " · Seen")), p.append($), v.append(p), v;
765
+ return h && e.seq > 0 && d.lastReadByOthers >= e.seq && j.append(n("span", "ocw-seen", " · Seen")), l.append(j), y.append(l), y;
749
766
  }
750
767
  }
751
- function Qe(t) {
768
+ function et(t) {
752
769
  switch (t) {
753
770
  case "read":
754
771
  return "✓✓";
@@ -761,11 +778,11 @@ function Qe(t) {
761
778
  }
762
779
  }
763
780
  const F = /* @__PURE__ */ new WeakMap(), ne = /* @__PURE__ */ new Map();
764
- function Te(t) {
781
+ function Ie(t) {
765
782
  return `relay-launcher::${t.profileId}::${t.subjectId ?? ""}`;
766
783
  }
767
784
  let Y = null;
768
- function Je() {
785
+ function tt() {
769
786
  if (Y && Y.state !== "closed") return Y;
770
787
  try {
771
788
  return Y = new AudioContext(), Y;
@@ -773,27 +790,70 @@ function Je() {
773
790
  return null;
774
791
  }
775
792
  }
776
- function it(t) {
793
+ function lt(t) {
777
794
  var e;
778
795
  (e = F.get(t)) == null || e.close(), F.delete(t);
779
796
  }
780
- function at(t) {
781
- var de, pe, he, ue, fe, we, be, xe;
782
- F.has(t.el) && (F.get(t.el).close(), F.delete(t.el)), t.launcher && ((de = ne.get(Te(t))) == null || de.close());
797
+ function nt(t) {
798
+ const e = t.el;
799
+ let d = null, s = null, c = !1;
800
+ const h = () => {
801
+ d == null || d.close(), d = null, s == null || s.close(), s = null, e.innerHTML = "";
802
+ };
803
+ function b() {
804
+ c || (h(), s = Oe({
805
+ el: e,
806
+ url: t.url,
807
+ ...t.apiUrl ? { apiUrl: t.apiUrl } : {},
808
+ ...t.profileId ? { profileId: t.profileId } : {},
809
+ scope: t.inboxScope ?? "tenant",
810
+ ...t.token ? { token: t.token } : {},
811
+ ...t.userId ? { userId: t.userId } : {},
812
+ ...t.accent ? { accent: t.accent } : {},
813
+ ...t.theme ? { theme: t.theme } : {},
814
+ ...t.webfont === !1 ? { webfont: !1 } : {},
815
+ ...t.locale ? { locale: t.locale } : {},
816
+ ...t.i18n ? { i18n: t.i18n } : {},
817
+ onSelect: (l) => y(l)
818
+ }));
819
+ }
820
+ function y(l) {
821
+ if (c) return;
822
+ h();
823
+ const { subjectId: u, kind: x, peerId: a, ...j } = t;
824
+ d = ot({
825
+ ...j,
826
+ inbox: !1,
827
+ launcher: !1,
828
+ el: e,
829
+ ...l.profileId ? { profileId: l.profileId } : {},
830
+ ...l.subjectId ? { subjectId: l.subjectId } : {},
831
+ ...l.kind === "direct" && l.peerId ? { kind: "direct", peerId: l.peerId } : {},
832
+ onBack: b
833
+ });
834
+ }
835
+ return b(), { close() {
836
+ c = !0, h();
837
+ } };
838
+ }
839
+ function ot(t) {
840
+ var de, pe, ue, he, fe, we, be, xe;
841
+ if (t.inbox) return nt(t);
842
+ F.has(t.el) && (F.get(t.el).close(), F.delete(t.el)), t.launcher && ((de = ne.get(Ie(t))) == null || de.close());
783
843
  const e = Me();
784
- let d, l = !1;
785
- const c = t.token ?? t.userId ?? e, w = c !== e ? e : void 0, { wsUrl: b, httpBase: v } = Ae(t.url, t.apiUrl);
786
- let p = new Oe(c);
787
- const u = t.subjectId ? `${c}::${t.subjectId}` : c, g = new Ne(u);
788
- let s, $ = !1, R = null, I = null, A = null, j = null;
844
+ let d, s = !1;
845
+ const c = t.token ?? t.userId ?? e, h = c !== e ? e : void 0, { wsUrl: b, httpBase: y } = Ae(t.url, t.apiUrl);
846
+ let l = new He(c);
847
+ const u = t.subjectId ? `${c}::${t.subjectId}` : c, x = new De(u);
848
+ let a, j = !1, R = null, E = null, A = null, P = null;
789
849
  !t.launcher && !t.el.style.height && t.el.clientHeight === 0 && (t.el.style.width = t.el.style.width || "100%", t.el.style.height = "600px");
790
- for (const o of g.load()) p.addOptimistic(o.clientMsgId, o.content);
791
- let P = null, z = null, O = 0, S = !t.launcher;
850
+ for (const o of x.load()) l.addOptimistic(o.clientMsgId, o.content);
851
+ let B = null, z = null, O = 0, T = !t.launcher;
792
852
  if (t.launcher) {
793
- const r = (t.position ?? "bottom-right").includes("right");
794
- P = document.createElement("div"), P.style.cssText = `position:fixed;${r ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${r ? "flex-end" : "flex-start"};gap:12px`;
795
- const m = document.createElement("div"), M = typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(max-width: 479px)") : null, K = (B) => {
796
- t.el.classList.toggle("ocw-fs", B), m.style.cssText = B ? [
853
+ const p = (t.position ?? "bottom-right").includes("right");
854
+ B = document.createElement("div"), B.style.cssText = `position:fixed;${p ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${p ? "flex-end" : "flex-start"};gap:12px`;
855
+ const g = document.createElement("div"), M = typeof window < "u" && typeof window.matchMedia == "function" ? window.matchMedia("(max-width: 479px)") : null, K = ($) => {
856
+ t.el.classList.toggle("ocw-fs", $), g.style.cssText = $ ? [
797
857
  "position:fixed",
798
858
  "inset:0",
799
859
  "width:100%",
@@ -816,15 +876,15 @@ function at(t) {
816
876
  "display:none",
817
877
  "flex-direction:column",
818
878
  "background:#fff",
819
- "transform-origin:bottom " + (r ? "right" : "left"),
879
+ "transform-origin:bottom " + (p ? "right" : "left"),
820
880
  "transition:opacity .18s,transform .18s",
821
881
  "opacity:0",
822
882
  "transform:scale(.95)"
823
883
  ].join(";");
824
884
  };
825
885
  K((M == null ? void 0 : M.matches) ?? !1);
826
- const V = (B) => K(B.matches);
827
- M == null || M.addEventListener("change", V), R = M, I = V, t.el.style.cssText = "width:100%;height:100%;overflow:hidden", m.append(t.el);
886
+ const V = ($) => K($.matches);
887
+ M == null || M.addEventListener("change", V), R = M, E = V, t.el.style.cssText = "width:100%;height:100%;overflow:hidden", g.append(t.el);
828
888
  const J = '<svg viewBox="0 0 24 24" width="26" height="26" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>', Z = '<svg viewBox="0 0 24 24" width="22" height="22" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>', H = document.createElement("button");
829
889
  H.type = "button", H.style.cssText = [
830
890
  "width:56px;height:56px;border-radius:50%",
@@ -840,25 +900,25 @@ function at(t) {
840
900
  H.style.transform = "scale(1)";
841
901
  }, z = document.createElement("span"), z.style.cssText = "position:absolute;top:-4px;right:-4px;background:#4c6fff;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center";
842
902
  const ee = () => {
843
- H.innerHTML = S ? Z : J, H.setAttribute("aria-label", S ? "Close chat" : "Open chat"), H.setAttribute("aria-expanded", String(S)), H.append(z);
903
+ H.innerHTML = T ? Z : J, H.setAttribute("aria-label", T ? "Close chat" : "Open chat"), H.setAttribute("aria-expanded", String(T)), H.append(z);
844
904
  };
845
- ee(), P.append(m, H), document.body.append(P);
905
+ ee(), B.append(g, H), document.body.append(B);
846
906
  const oe = `ocw-teaser-dismissed::${t.profileId}`, te = typeof t.launcherMessage == "string" ? { title: t.launcherMessage } : t.launcherMessage;
847
907
  let L = null;
848
- const je = () => {
908
+ const Le = () => {
849
909
  try {
850
910
  return sessionStorage.getItem(oe) === "1";
851
911
  } catch {
852
912
  return !1;
853
913
  }
854
914
  }, Pe = '<svg viewBox="0 0 24 24" width="15" height="15" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" fill="currentColor" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>', me = () => {
855
- const B = te != null && te.title ? te : p.launcherMessage ?? void 0;
856
- if (!(!!(B != null && B.title) && !S && !je())) {
915
+ const $ = te != null && te.title ? te : l.launcherMessage ?? void 0;
916
+ if (!(!!($ != null && $.title) && !T && !Le())) {
857
917
  L && (L.remove(), L = null);
858
918
  return;
859
919
  }
860
920
  if (L) return;
861
- L = document.createElement("div"), L.setAttribute("role", "button"), L.setAttribute("tabindex", "0"), L.setAttribute("aria-label", B.title), L.style.cssText = [
921
+ L = document.createElement("div"), L.setAttribute("role", "button"), L.setAttribute("tabindex", "0"), L.setAttribute("aria-label", $.title), L.style.cssText = [
862
922
  "max-width:280px",
863
923
  "background:#fff",
864
924
  "border-radius:16px",
@@ -867,17 +927,17 @@ function at(t) {
867
927
  "position:relative",
868
928
  "cursor:pointer",
869
929
  "font-family:inherit",
870
- `align-self:${r ? "flex-end" : "flex-start"}`,
930
+ `align-self:${p ? "flex-end" : "flex-start"}`,
871
931
  "animation:ocw-teaser-in .22s ease-out"
872
932
  ].join(";");
873
933
  const ae = document.createElement("div");
874
- if (ae.textContent = B.title, ae.style.cssText = "font-size:15px;font-weight:600;color:#111;line-height:1.35", L.append(ae), B.subtitle) {
934
+ if (ae.textContent = $.title, ae.style.cssText = "font-size:15px;font-weight:600;color:#111;line-height:1.35", L.append(ae), $.subtitle) {
875
935
  const U = document.createElement("div");
876
936
  U.style.cssText = "display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";
877
- const se = document.createElement("span");
878
- se.innerHTML = Pe, se.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
937
+ const ce = document.createElement("span");
938
+ ce.innerHTML = Pe, ce.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
879
939
  const ye = document.createElement("span");
880
- ye.textContent = B.subtitle, U.append(se, ye), L.append(U);
940
+ ye.textContent = $.subtitle, U.append(ce, ye), L.append(U);
881
941
  }
882
942
  const W = document.createElement("button");
883
943
  W.type = "button", W.setAttribute("aria-label", "Dismiss"), W.innerHTML = '<svg viewBox="0 0 24 24" width="14" height="14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 6 6 18M6 6l12 12" stroke="currentColor" stroke-width="2.5" stroke-linecap="round"/></svg>', W.style.cssText = "position:absolute;top:8px;right:8px;width:24px;height:24px;border:none;border-radius:50%;background:#f3f4f6;color:#6b7280;cursor:pointer;display:flex;align-items:center;justify-content:center;padding:0", W.addEventListener("click", (U) => {
@@ -889,92 +949,92 @@ function at(t) {
889
949
  L && (L.remove(), L = null);
890
950
  }), L.append(W);
891
951
  const ge = () => {
892
- S || (S = !0, ie(!0), ee(), O = 0, z && (z.style.display = "none"), L && (L.remove(), L = null));
952
+ T || (T = !0, ie(!0), ee(), O = 0, z && (z.style.display = "none"), L && (L.remove(), L = null));
893
953
  };
894
954
  L.addEventListener("click", ge), L.addEventListener("keydown", (U) => {
895
955
  (U.key === "Enter" || U.key === " ") && (U.preventDefault(), ge());
896
- }), P.insertBefore(L, H);
956
+ }), B.insertBefore(L, H);
897
957
  };
898
958
  if (!document.getElementById("ocw-teaser-style")) {
899
- const B = document.createElement("style");
900
- B.id = "ocw-teaser-style", B.textContent = "@keyframes ocw-teaser-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}", document.head.append(B);
959
+ const $ = document.createElement("style");
960
+ $.id = "ocw-teaser-style", $.textContent = "@keyframes ocw-teaser-in{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}", document.head.append($);
901
961
  }
902
- j = me, me();
903
- const ie = (B) => {
904
- B ? (m.style.display = "flex", requestAnimationFrame(() => {
905
- m.style.opacity = "1", m.style.transform = "scale(1)";
906
- })) : (m.style.opacity = "0", m.style.transform = "scale(.95)", setTimeout(() => {
907
- S || (m.style.display = "none");
962
+ P = me, me();
963
+ const ie = ($) => {
964
+ $ ? (g.style.display = "flex", requestAnimationFrame(() => {
965
+ g.style.opacity = "1", g.style.transform = "scale(1)";
966
+ })) : (g.style.opacity = "0", g.style.transform = "scale(.95)", setTimeout(() => {
967
+ T || (g.style.display = "none");
908
968
  }, 180));
909
969
  };
910
970
  H.addEventListener("click", () => {
911
- if (S = !S, ie(S), ee(), S) {
971
+ if (T = !T, ie(T), ee(), T) {
912
972
  O = 0, z && (z.style.display = "none");
913
973
  try {
914
974
  sessionStorage.setItem(oe, "1");
915
975
  } catch {
916
976
  }
917
977
  }
918
- j == null || j();
919
- }), A = (B) => {
920
- B.key === "Escape" && S && (S = !1, ie(!1), ee());
978
+ P == null || P();
979
+ }), A = ($) => {
980
+ $.key === "Escape" && T && (T = !1, ie(!1), ee());
921
981
  }, document.addEventListener("keydown", A);
922
982
  }
923
983
  const _ = () => {
924
- S || (O++, z && (z.textContent = String(O), z.style.display = "flex"));
925
- }, a = () => {
984
+ T || (O++, z && (z.textContent = String(O), z.style.display = "flex"));
985
+ }, r = () => {
926
986
  try {
927
- const o = Je();
987
+ const o = tt();
928
988
  if (!o) return;
929
989
  o.state === "suspended" && o.resume().catch(() => {
930
990
  });
931
- const r = o.createOscillator(), m = o.createGain();
932
- r.connect(m), m.connect(o.destination), r.frequency.setValueAtTime(880, o.currentTime), r.frequency.exponentialRampToValueAtTime(440, o.currentTime + 0.15), m.gain.setValueAtTime(0.3, o.currentTime), m.gain.exponentialRampToValueAtTime(1e-3, o.currentTime + 0.3), r.start(), r.stop(o.currentTime + 0.3);
991
+ const p = o.createOscillator(), g = o.createGain();
992
+ p.connect(g), g.connect(o.destination), p.frequency.setValueAtTime(880, o.currentTime), p.frequency.exponentialRampToValueAtTime(440, o.currentTime + 0.15), g.gain.setValueAtTime(0.3, o.currentTime), g.gain.exponentialRampToValueAtTime(1e-3, o.currentTime + 0.3), p.start(), p.stop(o.currentTime + 0.3);
933
993
  } catch {
934
994
  }
935
- }, i = [], y = (o) => {
995
+ }, i = [], v = (o) => {
936
996
  for (; i.length; ) {
937
- const r = i.shift();
938
- g.add({ clientMsgId: r.clientMsgId, content: r.content, ts: Date.now() }), h.send({ type: "send", conversationId: o, clientMsgId: r.clientMsgId, content: r.content });
997
+ const p = i.shift();
998
+ x.add({ clientMsgId: p.clientMsgId, content: p.content, ts: Date.now() }), f.send({ type: "send", conversationId: o, clientMsgId: p.clientMsgId, content: p.content });
939
999
  }
940
1000
  };
941
- let h;
942
- const x = new He(`ocw-e2e-${t.profileId}`);
1001
+ let f;
1002
+ const m = new Ue(`ocw-e2e-${t.profileId}`);
943
1003
  let k = !1;
944
- const E = [], f = [];
945
- let T = !1;
946
- const N = (o, r) => {
947
- x.sealText(r).then((m) => {
948
- s && h.send({ type: "send", conversationId: s, clientMsgId: o, content: m });
1004
+ const S = [], w = [];
1005
+ let I = !1;
1006
+ const N = (o, p) => {
1007
+ m.sealText(p).then((g) => {
1008
+ a && f.send({ type: "send", conversationId: a, clientMsgId: o, content: g });
949
1009
  });
950
- }, D = (o, r, m) => {
951
- x.sealText(r, m).then((M) => {
952
- s && h.send({ type: "send", conversationId: s, clientMsgId: o, content: M });
1010
+ }, D = (o, p, g) => {
1011
+ m.sealText(p, g).then((M) => {
1012
+ a && f.send({ type: "send", conversationId: a, clientMsgId: o, content: M });
953
1013
  });
954
1014
  }, X = () => {
955
- for (; E.length; ) {
956
- const o = E.shift();
1015
+ for (; S.length; ) {
1016
+ const o = S.shift();
957
1017
  N(o.clientMsgId, o.text);
958
1018
  }
959
- for (; f.length; ) {
960
- const o = f.shift();
1019
+ for (; w.length; ) {
1020
+ const o = w.shift();
961
1021
  N(o.clientMsgId, o.text);
962
1022
  }
963
- }, Se = (o) => {
964
- h.send({ type: "fetchPrekey", targetUserId: o });
965
- }, Ee = t.i18n ?? {}, Ie = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
966
- Ie.includes(ze) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
967
- const re = `oc_prechat_${t.profileId}_${c.slice(-8)}`, q = new Xe(t.el, c, {
1023
+ }, Te = (o) => {
1024
+ f.send({ type: "fetchPrekey", targetUserId: o });
1025
+ }, Se = qe(t.locale, t.i18n), Ee = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
1026
+ Ee.includes(ze) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
1027
+ const se = `oc_prechat_${t.profileId}_${c.slice(-8)}`, q = new Ze(t.el, c, {
968
1028
  onSend(o) {
969
- const r = `cm_${Math.random().toString(36).slice(2)}`, m = { kind: "text", text: o };
970
- p.addOptimistic(r, m), q.render(p), p.e2e ? x.ready ? N(r, o) : T ? f.push({ clientMsgId: r, text: o }) : (E.push({ clientMsgId: r, text: o }), p.assignedAgentId && Se(p.assignedAgentId)) : s ? (g.add({ clientMsgId: r, content: m, ts: Date.now() }), h.send({ type: "send", conversationId: s, clientMsgId: r, content: m })) : i.push({ clientMsgId: r, content: m });
1029
+ const p = `cm_${Math.random().toString(36).slice(2)}`, g = { kind: "text", text: o };
1030
+ l.addOptimistic(p, g), q.render(l), l.e2e ? m.ready ? N(p, o) : I ? w.push({ clientMsgId: p, text: o }) : (S.push({ clientMsgId: p, text: o }), l.assignedAgentId && Te(l.assignedAgentId)) : a ? (x.add({ clientMsgId: p, content: g, ts: Date.now() }), f.send({ type: "send", conversationId: a, clientMsgId: p, content: g })) : i.push({ clientMsgId: p, content: g });
971
1031
  },
972
1032
  async onAttach(o) {
973
- if (!s) return;
974
- const r = `${v}/upload?name=${encodeURIComponent(o.name)}`, m = `cm_${Math.random().toString(36).slice(2)}`;
975
- p.addOptimistic(m, { kind: "text", text: `📎 Uploading ${o.name}…` }), q.render(p);
1033
+ if (!a) return;
1034
+ const p = `${y}/upload?name=${encodeURIComponent(o.name)}`, g = `cm_${Math.random().toString(36).slice(2)}`;
1035
+ l.addOptimistic(g, { kind: "text", text: `📎 Uploading ${o.name}…` }), q.render(l);
976
1036
  try {
977
- const M = await fetch(r, {
1037
+ const M = await fetch(p, {
978
1038
  method: "POST",
979
1039
  // Use the resolved connection token (a signed JWT, an explicit userId,
980
1040
  // or the anonymous persistent uid) — NOT just opts.token. The server
@@ -986,23 +1046,23 @@ function at(t) {
986
1046
  });
987
1047
  if (!M.ok) throw new Error(`Upload failed: ${M.status}`);
988
1048
  const { url: K, name: V, mime: J, size: Z } = await M.json();
989
- p.addOptimistic(m, { kind: "attachment", url: K, name: V, mime: J, size: Z }), q.render(p), h.send({ type: "send", conversationId: s, clientMsgId: m, content: { kind: "attachment", url: K, name: V, mime: J, size: Z } });
1049
+ l.addOptimistic(g, { kind: "attachment", url: K, name: V, mime: J, size: Z }), q.render(l), f.send({ type: "send", conversationId: a, clientMsgId: g, content: { kind: "attachment", url: K, name: V, mime: J, size: Z } });
990
1050
  } catch (M) {
991
- p.addOptimistic(m, { kind: "text", text: `⚠️ Upload failed: ${M.message}` }), q.render(p);
1051
+ l.addOptimistic(g, { kind: "text", text: `⚠️ Upload failed: ${M.message}` }), q.render(l);
992
1052
  }
993
1053
  },
994
- onInvoke(o, r) {
995
- s && h.send({ type: "invoke", conversationId: s, actionId: o, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...r ? { inputs: r } : {} });
1054
+ onInvoke(o, p) {
1055
+ a && f.send({ type: "invoke", conversationId: a, actionId: o, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...p ? { inputs: p } : {} });
996
1056
  },
997
- onTyping(o, r) {
998
- s && h.send({ type: "typing", conversationId: s, isTyping: o, ...r ? { preview: r } : {} });
1057
+ onTyping(o, p) {
1058
+ a && f.send({ type: "typing", conversationId: a, isTyping: o, ...p ? { preview: p } : {} });
999
1059
  },
1000
1060
  onPreChat(o) {
1001
1061
  try {
1002
- localStorage.setItem(re, "1");
1062
+ localStorage.setItem(se, "1");
1003
1063
  } catch {
1004
1064
  }
1005
- h.send({
1065
+ f.send({
1006
1066
  type: "open",
1007
1067
  profileId: t.profileId,
1008
1068
  ...t.subjectId ? { subjectId: t.subjectId } : {},
@@ -1015,45 +1075,45 @@ function at(t) {
1015
1075
  } } : {}
1016
1076
  }
1017
1077
  });
1018
- const r = o.callback ? `📞 Call-back requested${o.phone ? `: ${o.phone}` : ""}${o.topic ? ` — ${o.topic}` : ""}` : o.topic ? `Topic: ${o.topic}` : "";
1019
- r && s && !p.e2e && h.send({ type: "send", conversationId: s, clientMsgId: `pc_${Math.random().toString(36).slice(2, 12)}`, content: { kind: "text", text: r } });
1078
+ const p = o.callback ? `📞 Call-back requested${o.phone ? `: ${o.phone}` : ""}${o.topic ? ` — ${o.topic}` : ""}` : o.topic ? `Topic: ${o.topic}` : "";
1079
+ p && a && !l.e2e && f.send({ type: "send", conversationId: a, clientMsgId: `pc_${Math.random().toString(36).slice(2, 12)}`, content: { kind: "text", text: p } });
1020
1080
  },
1021
1081
  ...((pe = t.features) == null ? void 0 : pe.deflection) !== !1 ? {
1022
1082
  onDeflectQuery(o) {
1023
- if (l) return;
1083
+ if (s) return;
1024
1084
  clearTimeout(d);
1025
- const r = o.trim();
1026
- if (r.length < 3) {
1085
+ const p = o.trim();
1086
+ if (p.length < 3) {
1027
1087
  q.hideDeflection();
1028
1088
  return;
1029
1089
  }
1030
1090
  d = setTimeout(() => {
1031
- fetch(`${v}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(r.slice(0, 200))}`).then((m) => m.ok ? m.json() : { articles: [] }).then((m) => q.showDeflection(m.articles ?? [])).catch(() => q.hideDeflection());
1091
+ fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(p.slice(0, 200))}`).then((g) => g.ok ? g.json() : { articles: [] }).then((g) => q.showDeflection(g.articles ?? [])).catch(() => q.hideDeflection());
1032
1092
  }, 350);
1033
1093
  }
1034
1094
  } : {},
1035
1095
  onReadUpTo(o) {
1036
- s && h.send({ type: "read", conversationId: s, seq: o });
1096
+ a && f.send({ type: "read", conversationId: a, seq: o });
1037
1097
  },
1038
1098
  onLoadMore() {
1039
- if (!s || !p.e2e) return;
1040
- const o = p.messages()[0];
1041
- o && h.send({ type: "history", conversationId: s, beforeSeq: o.seq, limit: 20 });
1099
+ if (!a || !l.e2e) return;
1100
+ const o = l.messages()[0];
1101
+ o && f.send({ type: "history", conversationId: a, beforeSeq: o.seq, limit: 20 });
1042
1102
  },
1043
- onEdit(o, r) {
1044
- s && h.send({ type: "edit", conversationId: s, messageId: o, content: { kind: "text", text: r } });
1103
+ onEdit(o, p) {
1104
+ a && f.send({ type: "edit", conversationId: a, messageId: o, content: { kind: "text", text: p } });
1045
1105
  },
1046
1106
  onDelete(o) {
1047
- s && h.send({ type: "delete", conversationId: s, messageId: o });
1107
+ a && f.send({ type: "delete", conversationId: a, messageId: o });
1048
1108
  },
1049
- ...((he = t.features) == null ? void 0 : he.reactions) !== !1 ? {
1050
- onReact(o, r, m) {
1051
- s && h.send({ type: "react", conversationId: s, messageId: o, emoji: r, remove: m });
1109
+ ...((ue = t.features) == null ? void 0 : ue.reactions) !== !1 ? {
1110
+ onReact(o, p, g) {
1111
+ a && f.send({ type: "react", conversationId: a, messageId: o, emoji: p, remove: g });
1052
1112
  }
1053
1113
  } : {},
1054
- ...((ue = t.features) == null ? void 0 : ue.csat) !== !1 ? {
1114
+ ...((he = t.features) == null ? void 0 : he.csat) !== !1 ? {
1055
1115
  onCsat(o) {
1056
- s && fetch(`${v}/conversations/${s}/csat`, {
1116
+ a && fetch(`${y}/conversations/${a}/csat`, {
1057
1117
  method: "POST",
1058
1118
  headers: { "Content-Type": "application/json", Authorization: `Bearer ${c}` },
1059
1119
  body: JSON.stringify({ score: o })
@@ -1064,14 +1124,14 @@ function at(t) {
1064
1124
  ...t.translateLang ? {
1065
1125
  async onTranslate(o) {
1066
1126
  try {
1067
- const r = await fetch(`${v}/translate`, {
1127
+ const p = await fetch(`${y}/translate`, {
1068
1128
  method: "POST",
1069
1129
  headers: { "content-type": "application/json", authorization: `Bearer ${c}` },
1070
1130
  body: JSON.stringify({ text: o, targetLang: t.translateLang })
1071
1131
  });
1072
- if (!r.ok) return null;
1073
- const { translated: m } = await r.json();
1074
- return m;
1132
+ if (!p.ok) return null;
1133
+ const { translated: g } = await p.json();
1134
+ return g;
1075
1135
  } catch {
1076
1136
  return null;
1077
1137
  }
@@ -1086,10 +1146,10 @@ function at(t) {
1086
1146
  ...t.theme ? { theme: t.theme } : {},
1087
1147
  ...t.webfont === !1 ? { webfont: !1 } : {},
1088
1148
  ...(fe = t.user) != null && fe.name || (we = t.user) != null && we.avatar ? { userInfo: { ...t.user.name ? { name: t.user.name } : {}, ...t.user.avatar ? { avatar: t.user.avatar } : {} } } : {},
1089
- i18n: Ee
1149
+ i18n: Se
1090
1150
  });
1091
1151
  try {
1092
- localStorage.getItem(re) && q.completePreChat();
1152
+ localStorage.getItem(se) && q.completePreChat();
1093
1153
  } catch {
1094
1154
  }
1095
1155
  const le = t.user && (t.user.name || t.user.email || t.user.avatar || t.user.meta) ? {
@@ -1097,14 +1157,14 @@ function at(t) {
1097
1157
  ...t.user.email ? { email: t.user.email } : {},
1098
1158
  ...t.user.avatar ? { avatar: t.user.avatar } : {},
1099
1159
  ...t.user.meta ? { meta: t.user.meta } : {}
1100
- } : void 0, Le = {
1160
+ } : void 0, je = {
1101
1161
  type: "open",
1102
1162
  profileId: t.profileId,
1103
1163
  // Direct conversations use the kind/peerId pair; the dm:… subject key is
1104
1164
  // server-derived and owner-keyed, so passing it as subjectId from the
1105
1165
  // NON-owner side would find-or-create a junk duplicate thread.
1106
1166
  ...t.kind === "direct" && t.peerId ? { kind: "direct", peerId: t.peerId } : t.subjectId ? { subjectId: t.subjectId } : {},
1107
- ...w ? { linkFrom: w } : {},
1167
+ ...h ? { linkFrom: h } : {},
1108
1168
  ...le ? { userInfo: le } : {},
1109
1169
  ...typeof location < "u" ? { pageUrl: location.href } : {},
1110
1170
  ...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
@@ -1113,79 +1173,79 @@ function at(t) {
1113
1173
  ...(be = t.subject) != null && be.title ? { subjectTitle: t.subject.title } : {},
1114
1174
  ...(xe = t.subject) != null && xe.subtitle ? { subjectMeta: t.subject.subtitle } : {}
1115
1175
  };
1116
- h = new De({
1176
+ f = new _e({
1117
1177
  ...t.refreshToken ? { refreshToken: t.refreshToken } : {},
1118
1178
  url: b,
1119
1179
  token: c,
1120
- open: Le,
1121
- getCursor: () => p.highestSeq(),
1122
- onStatusChange: (o, r) => q.setConnStatus(o, r),
1180
+ open: je,
1181
+ getCursor: () => l.highestSeq(),
1182
+ onStatusChange: (o, p) => q.setConnStatus(o, p),
1123
1183
  onFrame(o) {
1124
1184
  if (o.type === "opened") {
1125
- if (s = o.conversation.id, !$) {
1126
- $ = !0;
1127
- for (const r of g.load())
1128
- h.send({ type: "send", conversationId: s, clientMsgId: r.clientMsgId, content: r.content });
1185
+ if (a = o.conversation.id, !j) {
1186
+ j = !0;
1187
+ for (const p of x.load())
1188
+ f.send({ type: "send", conversationId: a, clientMsgId: p.clientMsgId, content: p.content });
1129
1189
  }
1130
- qe(b, c, s, p, q, v), i.length && y(s);
1190
+ Ne(b, c, a, l, q, y), i.length && v(a);
1131
1191
  }
1132
- if (o.type === "ack" && g.remove(o.clientMsgId), o.type === "prekeyBundle") {
1133
- o.bundle && (T = !0, x.x3dhSendTo(o.bundle).then((r) => {
1134
- const m = [...E.splice(0), ...f.splice(0)];
1135
- for (const M of m) D(M.clientMsgId, M.text, r);
1136
- q.render(p);
1192
+ if (o.type === "ack" && x.remove(o.clientMsgId), o.type === "prekeyBundle") {
1193
+ o.bundle && (I = !0, m.x3dhSendTo(o.bundle).then((p) => {
1194
+ const g = [...S.splice(0), ...w.splice(0)];
1195
+ for (const M of g) D(M.clientMsgId, M.text, p);
1196
+ q.render(l);
1137
1197
  }));
1138
1198
  return;
1139
1199
  }
1140
- if (o.type === "message" && p.e2e) {
1141
- const r = _e(o.message.content);
1142
- if (r && !x.ready) {
1143
- x.x3dhReceiveFrom(r.x3dhIK, r.x3dhEK, r.x3dhSPK, r.x3dhOTP).then(async () => {
1144
- await x.openFrame(o), p.apply(o), q.render(p);
1200
+ if (o.type === "message" && l.e2e) {
1201
+ const p = Fe(o.message.content);
1202
+ if (p && !m.ready) {
1203
+ m.x3dhReceiveFrom(p.x3dhIK, p.x3dhEK, p.x3dhSPK, p.x3dhOTP).then(async () => {
1204
+ await m.openFrame(o), l.apply(o), q.render(l);
1145
1205
  });
1146
1206
  return;
1147
1207
  }
1148
1208
  }
1149
1209
  if (o.type === "peerkey") {
1150
- x.onPeerKey(o.key).then(() => {
1151
- X(), q.render(p);
1210
+ m.onPeerKey(o.key).then(() => {
1211
+ X(), q.render(l);
1152
1212
  });
1153
1213
  return;
1154
1214
  }
1155
1215
  (async () => {
1156
- if (p.e2e && await x.openFrame(o), p.apply(o), o.type === "manifest") {
1157
- j == null || j();
1158
- const r = o.botName;
1159
- r && q.setBotName(r);
1216
+ if (l.e2e && await m.openFrame(o), l.apply(o), o.type === "manifest") {
1217
+ P == null || P();
1218
+ const p = o.botName;
1219
+ p && q.setBotName(p);
1160
1220
  }
1161
- if (o.type === "message" && o.message.senderId !== c && !o.message.internal && (_(), a()), p.e2e && s && !k) {
1221
+ if (o.type === "message" && o.message.senderId !== c && !o.message.internal && (_(), r()), l.e2e && a && !k) {
1162
1222
  k = !0;
1163
- const r = await x.initX3DH();
1164
- h.send({ type: "uploadPrekeys", ...r });
1165
- const m = await x.begin();
1166
- h.send({ type: "pubkey", conversationId: s, key: m });
1223
+ const p = await m.initX3DH();
1224
+ f.send({ type: "uploadPrekeys", ...p });
1225
+ const g = await m.begin();
1226
+ f.send({ type: "pubkey", conversationId: a, key: g });
1167
1227
  }
1168
- q.render(p);
1228
+ q.render(l);
1169
1229
  })();
1170
1230
  }
1171
- }), h.connect(), q.render(p);
1172
- const G = t.launcher ? Te(t) : null, Q = { close: () => {
1173
- l = !0, clearTimeout(d), h.close(), P == null || P.remove(), q.destroy(), R && I && R.removeEventListener("change", I), A && (document.removeEventListener("keydown", A), A = null), F.delete(t.el), G && ne.get(G) === Q && ne.delete(G);
1231
+ }), f.connect(), q.render(l);
1232
+ const G = t.launcher ? Ie(t) : null, Q = { close: () => {
1233
+ s = !0, clearTimeout(d), f.close(), B == null || B.remove(), q.destroy(), R && E && R.removeEventListener("change", E), A && (document.removeEventListener("keydown", A), A = null), F.delete(t.el), G && ne.get(G) === Q && ne.delete(G);
1174
1234
  } };
1175
1235
  return F.set(t.el, Q), G && ne.set(G, Q), Q;
1176
1236
  }
1177
1237
  export {
1178
- Oe as ChatStore,
1179
- De as ConnectionManager,
1180
- He as E2ESession,
1181
- Ne as PersistentOutbox,
1182
- Xe as Renderer,
1183
- dt as asConversationId,
1184
- _e as extractX3DHInit,
1185
- rt as httpBaseFromWsUrl,
1186
- at as mount,
1238
+ He as ChatStore,
1239
+ _e as ConnectionManager,
1240
+ Ue as E2ESession,
1241
+ De as PersistentOutbox,
1242
+ Ze as Renderer,
1243
+ ft as asConversationId,
1244
+ Fe as extractX3DHInit,
1245
+ ut as httpBaseFromWsUrl,
1246
+ ot as mount,
1187
1247
  Ae as resolveRelayUrls,
1188
- qe as restoreHistory,
1189
- it as unmount
1248
+ Ne as restoreHistory,
1249
+ lt as unmount
1190
1250
  };
1191
1251
  //# sourceMappingURL=index.js.map