@paramms/chat-widget 1.0.45 → 1.0.47

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.d.ts CHANGED
@@ -50,8 +50,10 @@ export interface MountOptions {
50
50
  /** Secondary accent (guest bubble + send button). Defaults to the design
51
51
  * blue; omit and it follows `accent` for a cohesive single-token retheme. */
52
52
  accent2?: string;
53
- /** Colour scheme: 'auto' (follow OS, default), 'light', or 'dark'. */
53
+ /** Colour scheme. Default 'light'. 'auto' follows the OS; 'dark'/'light' force it. */
54
54
  theme?: 'auto' | 'light' | 'dark';
55
+ /** Load Baloo 2 + Nunito webfonts (default true). false = system fonts only. */
56
+ webfont?: boolean;
55
57
  /** Stack navigation: when set, the chatroom header shows a back chevron that
56
58
  * calls this. Used by `<ChatApp>` so tapping a conversation opens the room and
57
59
  * the back arrow returns to the list — native-app style. */
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- var Pe = Object.defineProperty;
2
- var $e = (t, e, l) => e in t ? Pe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: l }) : t[e] = l;
1
+ var Be = Object.defineProperty;
2
+ var $e = (t, e, l) => e in t ? Be(t, e, { enumerable: !0, configurable: !0, writable: !0, value: l }) : t[e] = l;
3
3
  var T = (t, e, l) => $e(t, typeof e != "symbol" ? e + "" : e, l);
4
- import { l as Be, b as ge, p as Me, r as Re, a as Ae } from "./codec.js";
5
- import { h as rt } from "./codec.js";
6
- import { P as qe, C as Ne, b as Oe } from "./outbox.js";
7
- import { e as st } from "./outbox.js";
8
- import { E2ESession as De, extractX3DHInit as He } from "./e2e.js";
9
- const _e = `
10
- .ocw { ${Be("ocw")}
4
+ import { l as Me, b as ge, p as Re, r as Ae, a as qe } from "./codec.js";
5
+ import { h as st } 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 = `
10
+ .ocw { ${Me("ocw")}
11
11
  position:relative;
12
12
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
13
13
  font-family:var(--ocw-fb); color:var(--ocw-ink); overflow:hidden; }
14
- @media (prefers-color-scheme: dark) { .ocw:not([data-theme="light"]) { ${ge("ocw")} } }
14
+ @media (prefers-color-scheme: dark) { .ocw[data-theme="auto"] { ${ge("ocw")} } }
15
15
  .ocw[data-theme="dark"] { ${ge("ocw")} }
16
16
  /* ── Responsive sizing ──────────────────────────────────────────────────────
17
17
  * Sizing is driven by the WIDGET'S OWN width (ResizeObserver toggles
@@ -118,7 +118,7 @@ const _e = `
118
118
  .ocw button:focus-visible, .ocw textarea:focus-visible, .ocw a:focus-visible, .ocw [tabindex]:focus-visible { outline:2px solid var(--ocw-accent); outline-offset:2px; border-radius:8px; }
119
119
  .ocw-sendbtn:active { transform:scale(.92); }
120
120
  .ocw-quick button:active, .ocw-chip:active { transform:scale(.97); }
121
- @media (prefers-color-scheme: dark) { .ocw:not([data-theme="light"]) .ocw-away { background:#3a3018; border-color:#5a4a1f; color:#e8d9a8; } .ocw:not([data-theme="light"]) .ocw-note .ocw-bubble { background:#332b12; border-color:#7a5c17; color:#f0e2bd; } .ocw:not([data-theme="light"]) .ocw-note .ocw-bubble::before { color:#e0c060; } }
121
+ @media (prefers-color-scheme: dark) { .ocw[data-theme="auto"] .ocw-away { background:#3a3018; border-color:#5a4a1f; color:#e8d9a8; } .ocw[data-theme="auto"] .ocw-note .ocw-bubble { background:#332b12; border-color:#7a5c17; color:#f0e2bd; } .ocw[data-theme="auto"] .ocw-note .ocw-bubble::before { color:#e0c060; } }
122
122
  .ocw[data-theme="dark"] .ocw-away { background:#3a3018; border-color:#5a4a1f; color:#e8d9a8; }
123
123
  .ocw[data-theme="dark"] .ocw-note .ocw-bubble { background:#332b12; border-color:#7a5c17; color:#f0e2bd; }
124
124
  .ocw[data-theme="dark"] .ocw-note .ocw-bubble::before { color:#e0c060; }
@@ -197,17 +197,23 @@ const _e = `
197
197
  .ocw-row.theirs .ocw-translate-btn { right:auto; left:-26px; }
198
198
  .ocw-bubble-wrap:hover .ocw-translate-btn { opacity:1; }
199
199
  .ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
200
- `, ye = "objectchat-widget-styles", Ue = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Fe = 400, We = '<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 Ge() {
200
+ `, ye = "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() {
202
202
  if (typeof document > "u" || document.getElementById(ye)) return;
203
203
  const t = document.createElement("style");
204
- t.id = ye, t.textContent = _e, document.head.appendChild(t);
204
+ t.id = ye, t.textContent = Ue, document.head.appendChild(t);
205
+ }
206
+ const ve = "ocw-webfont";
207
+ function Ve() {
208
+ if (typeof document > "u" || document.getElementById(ve)) return;
209
+ const t = document.createElement("link");
210
+ t.id = ve, 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);
205
211
  }
206
212
  function n(t, e, l) {
207
213
  const c = document.createElement(t);
208
214
  return e && (c.className = e), l !== void 0 && (c.textContent = l), c;
209
215
  }
210
- function Ke(t) {
216
+ function Ye(t) {
211
217
  try {
212
218
  return new Date(t).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" });
213
219
  } catch {
@@ -231,7 +237,7 @@ function ae(t) {
231
237
  return `📅 ${t.title} — ${new Date(t.startIso).toLocaleString()}`;
232
238
  }
233
239
  }
234
- class Ve {
240
+ class Xe {
235
241
  /** Last seq the guest has seen per conversationId — used to compute unread badges. */
236
242
  constructor(e, l, c, i = {}) {
237
243
  T(this, "scroll");
@@ -268,10 +274,10 @@ class Ve {
268
274
  /** Whether the subject card (server Subject entity, mount config fallback)
269
275
  * has been built — built once when data first arrives. */
270
276
  T(this, "subjectBuilt", !1);
271
- var r, C, v, u, f, R, $, A, k, S, D;
272
- this.root = e, this.me = l, this.h = c, this.cfg = i, Ge(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
277
+ var r, C, v, u, f, R, B, A, k, S, D;
278
+ this.root = e, this.me = l, this.h = c, this.cfg = i, Ke(), i.webfont !== !1 && Ve(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
273
279
  const x = i.accent2 ?? i.accent;
274
- x && e.style.setProperty("--ocw-accent2", x), this.cfgAccent2 = i.accent2, i.theme && i.theme !== "auto" && (e.dataset.theme = i.theme);
280
+ x && e.style.setProperty("--ocw-accent2", x), this.cfgAccent2 = i.accent2, e.dataset.theme = i.theme ?? "light";
275
281
  const w = n("div", "ocw-head");
276
282
  if (this.h.onBack) {
277
283
  const g = n("button", "ocw-back", "‹");
@@ -285,7 +291,7 @@ class Ve {
285
291
  y.textContent = (C = i.userInfo) != null && C.name ? i.userInfo.name[0].toUpperCase() : "🧑";
286
292
  w.append(y);
287
293
  const p = n("div", "ocw-head-main");
288
- this.headerName = n("div", "ocw-head-name", ((v = i.subject) == null ? void 0 : v.ownerLabel) ?? ((u = i.subject) == null ? void 0 : u.title) ?? ""), p.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", p.append(this.headStatus), (f = i.subject) != null && f.subtitle && p.append(n("div", "ocw-head-meta", i.subject.subtitle)), w.append(p), this.statusBadge = n("span", "ocw-badge", ((R = i.subject) == null ? void 0 : R.status) ?? ""), ($ = i.subject) != null && $.status || (this.statusBadge.style.display = "none"), w.append(this.statusBadge), this.e2eBadge = n("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", w.append(this.e2eBadge), this.connStatus = n("span", "ocw-conn-status"), this.connStatus.style.display = "none", w.append(this.connStatus), w.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");
294
+ this.headerName = n("div", "ocw-head-name", ((v = i.subject) == null ? void 0 : v.ownerLabel) ?? ((u = i.subject) == null ? void 0 : u.title) ?? ""), p.append(this.headerName), this.headStatus = n("div", "ocw-head-status"), this.headStatus.style.display = "none", p.append(this.headStatus), (f = i.subject) != null && f.subtitle && p.append(n("div", "ocw-head-meta", i.subject.subtitle)), w.append(p), this.statusBadge = n("span", "ocw-badge", ((R = i.subject) == null ? void 0 : R.status) ?? ""), (B = i.subject) != null && B.status || (this.statusBadge.style.display = "none"), w.append(this.statusBadge), this.e2eBadge = n("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", w.append(this.e2eBadge), this.connStatus = n("span", "ocw-conn-status"), this.connStatus.style.display = "none", w.append(this.connStatus), w.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");
289
295
  const h = n("div", "ocw-typing-bubble");
290
296
  h.append(n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot"), n("div", "ocw-typing-dot")), this.typing.append(n("div", "ocw-dot", "🧑"), h), this.quick = n("div", "ocw-quick");
291
297
  for (const g of i.quickReplies ?? []) {
@@ -298,7 +304,7 @@ class Ve {
298
304
  const b = n("button", "ocw-sendbtn");
299
305
  b.type = "button";
300
306
  const a = (k = i.i18n) == null ? void 0 : k.send;
301
- a ? (b.textContent = a, b.classList.add("ocw-sendbtn-label"), b.setAttribute("aria-label", a)) : (b.innerHTML = We, b.setAttribute("aria-label", "Send message")), b.disabled = !0, this.sendBtn = b, b.addEventListener("click", () => this.flushSend()), this.input.addEventListener("input", () => {
307
+ a ? (b.textContent = a, b.classList.add("ocw-sendbtn-label"), b.setAttribute("aria-label", a)) : (b.innerHTML = Ge, b.setAttribute("aria-label", "Send message")), b.disabled = !0, this.sendBtn = b, b.addEventListener("click", () => this.flushSend()), this.input.addEventListener("input", () => {
302
308
  var g, N;
303
309
  this.sendBtn.disabled = this.input.value.trim().length === 0, this.autoGrowInput(), this.storeRef && !this.storeRef.messages().some((H) => H.senderRole === "guest") ? (N = (g = this.h).onDeflectQuery) == null || N.call(g, this.input.value) : this.hideDeflection();
304
310
  }), this.input.addEventListener("keydown", (g) => {
@@ -320,7 +326,7 @@ class Ve {
320
326
  g == null || g.focus();
321
327
  }), e.append(w, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.preChatPanel, this.deflectPanel, this.awayNotice, M, this.reopenBtn, this.footer);
322
328
  const d = (g) => {
323
- e.classList.toggle("ocw-compact", g > 0 && g < Fe);
329
+ e.classList.toggle("ocw-compact", g > 0 && g < We);
324
330
  };
325
331
  d(e.clientWidth), typeof ResizeObserver < "u" && (this.compactObserver = new ResizeObserver((g) => {
326
332
  var H;
@@ -639,10 +645,10 @@ class Ve {
639
645
  f.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
640
646
  const R = n("button", "ocw-form-cancel", "Cancel");
641
647
  R.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
642
- const $ = n("div");
643
- $.style.cssText = "display:flex;gap:6px;justify-content:flex-end", $.append(R, f);
648
+ const B = n("div");
649
+ B.style.cssText = "display:flex;gap:6px;justify-content:flex-end", B.append(R, f);
644
650
  const A = n("div");
645
- A.append(u, $), h.replaceChildren(A), u.focus(), u.select();
651
+ A.append(u, B), h.replaceChildren(A), u.focus(), u.select();
646
652
  const k = () => h.replaceChildren(b ?? document.createTextNode(v));
647
653
  R.addEventListener("click", k), f.addEventListener("click", () => {
648
654
  const S = u.value.trim();
@@ -666,18 +672,18 @@ class Ve {
666
672
  for (const [u, f] of Object.entries(e.reactions)) {
667
673
  const R = n("button", `ocw-react-pill${f.includes(this.me) ? " mine" : ""}`, `${u} ${f.length}`);
668
674
  R.addEventListener("click", () => {
669
- var $, A;
670
- return (A = ($ = this.h).onReact) == null ? void 0 : A.call($, e.id, u, f.includes(this.me));
675
+ var B, A;
676
+ return (A = (B = this.h).onReact) == null ? void 0 : A.call(B, e.id, u, f.includes(this.me));
671
677
  }), r.append(R);
672
678
  }
673
679
  const C = n("button", "ocw-react-btn", "+"), v = n("div", "ocw-react-picker");
674
- for (const u of Ue) {
680
+ for (const u of Fe) {
675
681
  const f = n("button", void 0, u);
676
682
  f.addEventListener("click", (R) => {
677
683
  var A, k, S, D;
678
684
  R.stopPropagation();
679
- const $ = (k = (A = e.reactions) == null ? void 0 : A[u]) == null ? void 0 : k.includes(this.me);
680
- (D = (S = this.h).onReact) == null || D.call(S, e.id, u, !!$), v.style.display = "none";
685
+ const B = (k = (A = e.reactions) == null ? void 0 : A[u]) == null ? void 0 : k.includes(this.me);
686
+ (D = (S = this.h).onReact) == null || D.call(S, e.id, u, !!B), v.style.display = "none";
681
687
  }), v.append(f);
682
688
  }
683
689
  v.style.display = "none", C.addEventListener("click", (u) => {
@@ -688,15 +694,15 @@ class Ve {
688
694
  }, { once: !0 });
689
695
  }), r.append(C), d.append(r, v), y.append(d);
690
696
  } else e.reactions && Object.keys(e.reactions).length && y.append(n("div", "ocw-react", Object.entries(e.reactions).map(([d, r]) => `${d}${r.length}`).join(" ")));
691
- const a = n("div", "ocw-time ocw-meta", Ke(e.ts));
697
+ const a = n("div", "ocw-time ocw-meta", Ye(e.ts));
692
698
  if (i && e.status) {
693
- const d = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Ye(e.status));
699
+ const d = n("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Qe(e.status));
694
700
  a.append(d);
695
701
  }
696
702
  return i && e.seq > 0 && l.lastReadByOthers >= e.seq && a.append(n("span", "ocw-seen", " · Seen")), y.append(a), w.append(y), w;
697
703
  }
698
704
  }
699
- function Ye(t) {
705
+ function Qe(t) {
700
706
  switch (t) {
701
707
  case "read":
702
708
  return "✓✓";
@@ -709,11 +715,11 @@ function Ye(t) {
709
715
  }
710
716
  }
711
717
  const _ = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
712
- function ve(t) {
718
+ function ke(t) {
713
719
  return `relay-launcher::${t.profileId}::${t.subjectId ?? ""}`;
714
720
  }
715
721
  let K = null;
716
- function Xe() {
722
+ function Je() {
717
723
  if (K && K.state !== "closed") return K;
718
724
  try {
719
725
  return K = new AudioContext(), K;
@@ -721,18 +727,18 @@ function Xe() {
721
727
  return null;
722
728
  }
723
729
  }
724
- function nt(t) {
730
+ function it(t) {
725
731
  var e;
726
732
  (e = _.get(t)) == null || e.close(), _.delete(t);
727
733
  }
728
- function ot(t) {
734
+ function at(t) {
729
735
  var se, le, de, pe, he, ue, fe, we;
730
- _.has(t.el) && (_.get(t.el).close(), _.delete(t.el)), t.launcher && ((se = Z.get(ve(t))) == null || se.close());
731
- const e = Me();
736
+ _.has(t.el) && (_.get(t.el).close(), _.delete(t.el)), t.launcher && ((se = Z.get(ke(t))) == null || se.close());
737
+ const e = Re();
732
738
  let l, c = !1;
733
- const i = t.token ?? t.userId ?? e, x = i !== e ? e : void 0, { wsUrl: w, httpBase: y } = Re(t.url, t.apiUrl);
734
- let p = new Ne(i);
735
- const h = t.subjectId ? `${i}::${t.subjectId}` : i, b = new qe(h);
739
+ const i = t.token ?? t.userId ?? e, x = i !== e ? e : void 0, { wsUrl: w, httpBase: y } = Ae(t.url, t.apiUrl);
740
+ let p = new Oe(i);
741
+ const h = t.subjectId ? `${i}::${t.subjectId}` : i, b = new Ne(h);
736
742
  let a, P = !1, I = null, M = null, j = null, d = null;
737
743
  !t.launcher && !t.el.style.height && t.el.clientHeight === 0 && (t.el.style.width = t.el.style.width || "100%", t.el.style.height = "600px");
738
744
  for (const o of b.load()) p.addOptimistic(o.clientMsgId, o.content);
@@ -793,15 +799,15 @@ function ot(t) {
793
799
  Q(), r.append(m, q), document.body.append(r);
794
800
  const te = `ocw-teaser-dismissed::${t.profileId}`, J = typeof t.launcherMessage == "string" ? { title: t.launcherMessage } : t.launcherMessage;
795
801
  let E = null;
796
- const je = () => {
802
+ const Le = () => {
797
803
  try {
798
804
  return sessionStorage.getItem(te) === "1";
799
805
  } catch {
800
806
  return !1;
801
807
  }
802
- }, Le = '<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>', be = () => {
808
+ }, 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>', be = () => {
803
809
  const z = J != null && J.title ? J : p.launcherMessage ?? void 0;
804
- if (!(!!(z != null && z.title) && !u && !je())) {
810
+ if (!(!!(z != null && z.title) && !u && !Le())) {
805
811
  E && (E.remove(), E = null);
806
812
  return;
807
813
  }
@@ -823,7 +829,7 @@ function ot(t) {
823
829
  const O = document.createElement("div");
824
830
  O.style.cssText = "display:flex;align-items:center;gap:6px;margin-top:6px;font-size:13px;color:#6b7280";
825
831
  const ie = document.createElement("span");
826
- ie.innerHTML = Le, ie.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
832
+ ie.innerHTML = Pe, ie.style.cssText = `color:${t.accent ?? "#6c5ce7"};display:inline-flex`;
827
833
  const me = document.createElement("span");
828
834
  me.textContent = z.subtitle, O.append(ie, me), E.append(O);
829
835
  }
@@ -872,7 +878,7 @@ function ot(t) {
872
878
  u || (v++, C && (C.textContent = String(v), C.style.display = "flex"));
873
879
  }, R = () => {
874
880
  try {
875
- const o = Xe();
881
+ const o = Je();
876
882
  if (!o) return;
877
883
  o.state === "suspended" && o.resume().catch(() => {
878
884
  });
@@ -880,14 +886,14 @@ function ot(t) {
880
886
  s.connect(m), m.connect(o.destination), s.frequency.setValueAtTime(880, o.currentTime), s.frequency.exponentialRampToValueAtTime(440, o.currentTime + 0.15), m.gain.setValueAtTime(0.3, o.currentTime), m.gain.exponentialRampToValueAtTime(1e-3, o.currentTime + 0.3), s.start(), s.stop(o.currentTime + 0.3);
881
887
  } catch {
882
888
  }
883
- }, $ = [], A = (o) => {
884
- for (; $.length; ) {
885
- const s = $.shift();
889
+ }, B = [], A = (o) => {
890
+ for (; B.length; ) {
891
+ const s = B.shift();
886
892
  b.add({ clientMsgId: s.clientMsgId, content: s.content, ts: Date.now() }), k.send({ type: "send", conversationId: o, clientMsgId: s.clientMsgId, content: s.content });
887
893
  }
888
894
  };
889
895
  let k;
890
- const S = new De(`ocw-e2e-${t.profileId}`);
896
+ const S = new He(`ocw-e2e-${t.profileId}`);
891
897
  let D = !1;
892
898
  const g = [], N = [];
893
899
  let H = !1;
@@ -895,11 +901,11 @@ function ot(t) {
895
901
  S.sealText(s).then((m) => {
896
902
  a && k.send({ type: "send", conversationId: a, clientMsgId: o, content: m });
897
903
  });
898
- }, ke = (o, s, m) => {
904
+ }, Ce = (o, s, m) => {
899
905
  S.sealText(s, m).then((L) => {
900
906
  a && k.send({ type: "send", conversationId: a, clientMsgId: o, content: L });
901
907
  });
902
- }, Ce = () => {
908
+ }, Te = () => {
903
909
  for (; g.length; ) {
904
910
  const o = g.shift();
905
911
  ee(o.clientMsgId, o.text);
@@ -908,19 +914,19 @@ function ot(t) {
908
914
  const o = N.shift();
909
915
  ee(o.clientMsgId, o.text);
910
916
  }
911
- }, Te = (o) => {
917
+ }, Ie = (o) => {
912
918
  k.send({ type: "fetchPrekey", targetUserId: o });
913
- }, Ie = t.i18n ?? {}, Se = ["ar", "he", "fa", "ur"], Ee = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
914
- Se.includes(Ee) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
915
- const re = `oc_prechat_${t.profileId}_${i.slice(-8)}`, B = new Ve(t.el, i, {
919
+ }, Se = t.i18n ?? {}, Ee = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
920
+ Ee.includes(ze) && !t.el.dir && (t.el.dir = "rtl", t.el.style.fontFamily = t.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
921
+ const re = `oc_prechat_${t.profileId}_${i.slice(-8)}`, $ = new Xe(t.el, i, {
916
922
  onSend(o) {
917
923
  const s = `cm_${Math.random().toString(36).slice(2)}`, m = { kind: "text", text: o };
918
- p.addOptimistic(s, m), B.render(p), p.e2e ? S.ready ? ee(s, o) : H ? N.push({ clientMsgId: s, text: o }) : (g.push({ clientMsgId: s, text: o }), p.assignedAgentId && Te(p.assignedAgentId)) : a ? (b.add({ clientMsgId: s, content: m, ts: Date.now() }), k.send({ type: "send", conversationId: a, clientMsgId: s, content: m })) : $.push({ clientMsgId: s, content: m });
924
+ p.addOptimistic(s, m), $.render(p), p.e2e ? S.ready ? ee(s, o) : H ? N.push({ clientMsgId: s, text: o }) : (g.push({ clientMsgId: s, text: o }), p.assignedAgentId && Ie(p.assignedAgentId)) : a ? (b.add({ clientMsgId: s, content: m, ts: Date.now() }), k.send({ type: "send", conversationId: a, clientMsgId: s, content: m })) : B.push({ clientMsgId: s, content: m });
919
925
  },
920
926
  async onAttach(o) {
921
927
  if (!a) return;
922
928
  const s = `${y}/upload?name=${encodeURIComponent(o.name)}`, m = `cm_${Math.random().toString(36).slice(2)}`;
923
- p.addOptimistic(m, { kind: "text", text: `📎 Uploading ${o.name}…` }), B.render(p);
929
+ p.addOptimistic(m, { kind: "text", text: `📎 Uploading ${o.name}…` }), $.render(p);
924
930
  try {
925
931
  const L = await fetch(s, {
926
932
  method: "POST",
@@ -934,9 +940,9 @@ function ot(t) {
934
940
  });
935
941
  if (!L.ok) throw new Error(`Upload failed: ${L.status}`);
936
942
  const { url: W, name: G, mime: Y, size: X } = await L.json();
937
- p.addOptimistic(m, { kind: "attachment", url: W, name: G, mime: Y, size: X }), B.render(p), k.send({ type: "send", conversationId: a, clientMsgId: m, content: { kind: "attachment", url: W, name: G, mime: Y, size: X } });
943
+ p.addOptimistic(m, { kind: "attachment", url: W, name: G, mime: Y, size: X }), $.render(p), k.send({ type: "send", conversationId: a, clientMsgId: m, content: { kind: "attachment", url: W, name: G, mime: Y, size: X } });
938
944
  } catch (L) {
939
- p.addOptimistic(m, { kind: "text", text: `⚠️ Upload failed: ${L.message}` }), B.render(p);
945
+ p.addOptimistic(m, { kind: "text", text: `⚠️ Upload failed: ${L.message}` }), $.render(p);
940
946
  }
941
947
  },
942
948
  onInvoke(o, s) {
@@ -972,11 +978,11 @@ function ot(t) {
972
978
  clearTimeout(l);
973
979
  const s = o.trim();
974
980
  if (s.length < 3) {
975
- B.hideDeflection();
981
+ $.hideDeflection();
976
982
  return;
977
983
  }
978
984
  l = setTimeout(() => {
979
- fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(s.slice(0, 200))}`).then((m) => m.ok ? m.json() : { articles: [] }).then((m) => B.showDeflection(m.articles ?? [])).catch(() => B.hideDeflection());
985
+ fetch(`${y}/kb/search?profileId=${encodeURIComponent(t.profileId)}&q=${encodeURIComponent(s.slice(0, 200))}`).then((m) => m.ok ? m.json() : { articles: [] }).then((m) => $.showDeflection(m.articles ?? [])).catch(() => $.hideDeflection());
980
986
  }, 350);
981
987
  }
982
988
  } : {},
@@ -1032,11 +1038,12 @@ function ot(t) {
1032
1038
  ...t.accent ? { accent: t.accent } : {},
1033
1039
  ...t.accent2 ? { accent2: t.accent2 } : {},
1034
1040
  ...t.theme ? { theme: t.theme } : {},
1041
+ ...t.webfont === !1 ? { webfont: !1 } : {},
1035
1042
  ...(he = t.user) != null && he.name || (ue = t.user) != null && ue.avatar ? { userInfo: { ...t.user.name ? { name: t.user.name } : {}, ...t.user.avatar ? { avatar: t.user.avatar } : {} } } : {},
1036
- i18n: Ie
1043
+ i18n: Se
1037
1044
  });
1038
1045
  try {
1039
- localStorage.getItem(re) && B.completePreChat();
1046
+ localStorage.getItem(re) && $.completePreChat();
1040
1047
  } catch {
1041
1048
  }
1042
1049
  const ce = t.user && (t.user.name || t.user.email || t.user.avatar || t.user.meta) ? {
@@ -1044,7 +1051,7 @@ function ot(t) {
1044
1051
  ...t.user.email ? { email: t.user.email } : {},
1045
1052
  ...t.user.avatar ? { avatar: t.user.avatar } : {},
1046
1053
  ...t.user.meta ? { meta: t.user.meta } : {}
1047
- } : void 0, ze = {
1054
+ } : void 0, je = {
1048
1055
  type: "open",
1049
1056
  profileId: t.profileId,
1050
1057
  // Direct conversations use the kind/peerId pair; the dm:… subject key is
@@ -1060,13 +1067,13 @@ function ot(t) {
1060
1067
  ...(fe = t.subject) != null && fe.title ? { subjectTitle: t.subject.title } : {},
1061
1068
  ...(we = t.subject) != null && we.subtitle ? { subjectMeta: t.subject.subtitle } : {}
1062
1069
  };
1063
- k = new Oe({
1070
+ k = new De({
1064
1071
  ...t.refreshToken ? { refreshToken: t.refreshToken } : {},
1065
1072
  url: w,
1066
1073
  token: i,
1067
- open: ze,
1074
+ open: je,
1068
1075
  getCursor: () => p.highestSeq(),
1069
- onStatusChange: (o, s) => B.setConnStatus(o, s),
1076
+ onStatusChange: (o, s) => $.setConnStatus(o, s),
1070
1077
  onFrame(o) {
1071
1078
  if (o.type === "opened") {
1072
1079
  if (a = o.conversation.id, !P) {
@@ -1074,28 +1081,28 @@ function ot(t) {
1074
1081
  for (const s of b.load())
1075
1082
  k.send({ type: "send", conversationId: a, clientMsgId: s.clientMsgId, content: s.content });
1076
1083
  }
1077
- Ae(w, i, a, p, B, y), $.length && A(a);
1084
+ qe(w, i, a, p, $, y), B.length && A(a);
1078
1085
  }
1079
1086
  if (o.type === "ack" && b.remove(o.clientMsgId), o.type === "prekeyBundle") {
1080
1087
  o.bundle && (H = !0, S.x3dhSendTo(o.bundle).then((s) => {
1081
1088
  const m = [...g.splice(0), ...N.splice(0)];
1082
- for (const L of m) ke(L.clientMsgId, L.text, s);
1083
- B.render(p);
1089
+ for (const L of m) Ce(L.clientMsgId, L.text, s);
1090
+ $.render(p);
1084
1091
  }));
1085
1092
  return;
1086
1093
  }
1087
1094
  if (o.type === "message" && p.e2e) {
1088
- const s = He(o.message.content);
1095
+ const s = _e(o.message.content);
1089
1096
  if (s && !S.ready) {
1090
1097
  S.x3dhReceiveFrom(s.x3dhIK, s.x3dhEK, s.x3dhSPK, s.x3dhOTP).then(async () => {
1091
- await S.openFrame(o), p.apply(o), B.render(p);
1098
+ await S.openFrame(o), p.apply(o), $.render(p);
1092
1099
  });
1093
1100
  return;
1094
1101
  }
1095
1102
  }
1096
1103
  if (o.type === "peerkey") {
1097
1104
  S.onPeerKey(o.key).then(() => {
1098
- Ce(), B.render(p);
1105
+ Te(), $.render(p);
1099
1106
  });
1100
1107
  return;
1101
1108
  }
@@ -1107,27 +1114,27 @@ function ot(t) {
1107
1114
  const m = await S.begin();
1108
1115
  k.send({ type: "pubkey", conversationId: a, key: m });
1109
1116
  }
1110
- B.render(p);
1117
+ $.render(p);
1111
1118
  })();
1112
1119
  }
1113
- }), k.connect(), B.render(p);
1114
- const F = t.launcher ? ve(t) : null, V = { close: () => {
1115
- c = !0, clearTimeout(l), k.close(), r == null || r.remove(), B.destroy(), I && M && I.removeEventListener("change", M), j && (document.removeEventListener("keydown", j), j = null), _.delete(t.el), F && Z.get(F) === V && Z.delete(F);
1120
+ }), k.connect(), $.render(p);
1121
+ const F = t.launcher ? ke(t) : null, V = { close: () => {
1122
+ c = !0, clearTimeout(l), k.close(), r == null || r.remove(), $.destroy(), I && M && I.removeEventListener("change", M), j && (document.removeEventListener("keydown", j), j = null), _.delete(t.el), F && Z.get(F) === V && Z.delete(F);
1116
1123
  } };
1117
1124
  return _.set(t.el, V), F && Z.set(F, V), V;
1118
1125
  }
1119
1126
  export {
1120
- Ne as ChatStore,
1121
- Oe as ConnectionManager,
1122
- De as E2ESession,
1123
- qe as PersistentOutbox,
1124
- Ve as Renderer,
1125
- st as asConversationId,
1126
- He as extractX3DHInit,
1127
- rt as httpBaseFromWsUrl,
1128
- ot as mount,
1129
- Re as resolveRelayUrls,
1130
- Ae as restoreHistory,
1131
- nt as unmount
1127
+ Oe as ChatStore,
1128
+ De as ConnectionManager,
1129
+ He as E2ESession,
1130
+ Ne as PersistentOutbox,
1131
+ Xe as Renderer,
1132
+ dt as asConversationId,
1133
+ _e as extractX3DHInit,
1134
+ st as httpBaseFromWsUrl,
1135
+ at as mount,
1136
+ Ae as resolveRelayUrls,
1137
+ qe as restoreHistory,
1138
+ it as unmount
1132
1139
  };
1133
1140
  //# sourceMappingURL=index.js.map