@paramms/chat-widget 1.0.27 → 1.0.29

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
@@ -36,8 +36,8 @@ function je(s, e, t) {
36
36
  e[i++] = r >> 6 & 31 | 192;
37
37
  else {
38
38
  if (r >= 55296 && r <= 56319 && o < n) {
39
- const p = s.charCodeAt(o);
40
- (p & 64512) === 56320 && (++o, r = ((r & 1023) << 10) + (p & 1023) + 65536);
39
+ const h = s.charCodeAt(o);
40
+ (h & 64512) === 56320 && (++o, r = ((r & 1023) << 10) + (h & 1023) + 65536);
41
41
  }
42
42
  r & 4294901760 ? (e[i++] = r >> 18 & 7 | 240, e[i++] = r >> 12 & 63 | 128, e[i++] = r >> 6 & 63 | 128) : (e[i++] = r >> 12 & 15 | 224, e[i++] = r >> 6 & 63 | 128);
43
43
  }
@@ -56,26 +56,26 @@ function Ve(s, e, t) {
56
56
  s.length > Oe ? Ne(s, e, t) : je(s, e, t);
57
57
  }
58
58
  const We = 4096;
59
- function ke(s, e, t) {
59
+ function Se(s, e, t) {
60
60
  let n = e;
61
61
  const i = n + t, o = [];
62
62
  let r = "";
63
63
  for (; n < i; ) {
64
- const p = s[n++];
65
- if (!(p & 128))
66
- o.push(p);
67
- else if ((p & 224) === 192) {
64
+ const h = s[n++];
65
+ if (!(h & 128))
66
+ o.push(h);
67
+ else if ((h & 224) === 192) {
68
68
  const w = s[n++] & 63;
69
- o.push((p & 31) << 6 | w);
70
- } else if ((p & 240) === 224) {
69
+ o.push((h & 31) << 6 | w);
70
+ } else if ((h & 240) === 224) {
71
71
  const w = s[n++] & 63, d = s[n++] & 63;
72
- o.push((p & 31) << 12 | w << 6 | d);
73
- } else if ((p & 248) === 240) {
72
+ o.push((h & 31) << 12 | w << 6 | d);
73
+ } else if ((h & 248) === 240) {
74
74
  const w = s[n++] & 63, d = s[n++] & 63, v = s[n++] & 63;
75
- let x = (p & 7) << 18 | w << 12 | d << 6 | v;
75
+ let x = (h & 7) << 18 | w << 12 | d << 6 | v;
76
76
  x > 65535 && (x -= 65536, o.push(x >>> 10 & 1023 | 55296), x = 56320 | x & 1023), o.push(x);
77
77
  } else
78
- o.push(p);
78
+ o.push(h);
79
79
  o.length >= We && (r += String.fromCharCode(...o), o.length = 0);
80
80
  }
81
81
  return o.length > 0 && (r += String.fromCharCode(...o)), r;
@@ -86,7 +86,7 @@ function Je(s, e, t) {
86
86
  return Xe.decode(n);
87
87
  }
88
88
  function Ge(s, e, t) {
89
- return t > Ye ? Je(s, e, t) : ke(s, e, t);
89
+ return t > Ye ? Je(s, e, t) : Se(s, e, t);
90
90
  }
91
91
  class G {
92
92
  constructor(e, t) {
@@ -106,16 +106,16 @@ class z extends Error {
106
106
  });
107
107
  }
108
108
  }
109
- const q = 4294967295;
109
+ const j = 4294967295;
110
110
  function Ze(s, e, t) {
111
111
  const n = t / 4294967296, i = t;
112
112
  s.setUint32(e, n), s.setUint32(e + 4, i);
113
113
  }
114
- function Se(s, e, t) {
114
+ function Ie(s, e, t) {
115
115
  const n = Math.floor(t / 4294967296), i = t;
116
116
  s.setUint32(e, n), s.setUint32(e + 4, i);
117
117
  }
118
- function Ie(s, e) {
118
+ function Ce(s, e) {
119
119
  const t = s.getInt32(e), n = s.getUint32(e + 4);
120
120
  return t * 4294967296 + n;
121
121
  }
@@ -135,7 +135,7 @@ function it({ sec: s, nsec: e }) {
135
135
  }
136
136
  else {
137
137
  const t = new Uint8Array(12), n = new DataView(t.buffer);
138
- return n.setUint32(0, e), Se(n, 4, s), t;
138
+ return n.setUint32(0, e), Ie(n, 4, s), t;
139
139
  }
140
140
  }
141
141
  function st(s) {
@@ -162,7 +162,7 @@ function rt(s) {
162
162
  return { sec: i, nsec: o };
163
163
  }
164
164
  case 12: {
165
- const t = Ie(e, 4), n = e.getUint32(0);
165
+ const t = Ce(e, 4), n = e.getUint32(0);
166
166
  return { sec: t, nsec: n };
167
167
  }
168
168
  default:
@@ -462,7 +462,7 @@ class ce {
462
462
  this.ensureBufferSizeToWrite(8), Ze(this.view, this.pos, e), this.pos += 8;
463
463
  }
464
464
  writeI64(e) {
465
- this.ensureBufferSizeToWrite(8), Se(this.view, this.pos, e), this.pos += 8;
465
+ this.ensureBufferSizeToWrite(8), Ie(this.view, this.pos, e), this.pos += 8;
466
466
  }
467
467
  writeBigUint64(e) {
468
468
  this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
@@ -496,8 +496,8 @@ class wt {
496
496
  const i = this.caches[n - 1];
497
497
  e: for (const o of i) {
498
498
  const r = o.bytes;
499
- for (let p = 0; p < n; p++)
500
- if (r[p] !== e[t + p])
499
+ for (let h = 0; h < n; h++)
500
+ if (r[h] !== e[t + h])
501
501
  continue e;
502
502
  return o.str;
503
503
  }
@@ -512,11 +512,11 @@ class wt {
512
512
  if (i != null)
513
513
  return this.hit++, i;
514
514
  this.miss++;
515
- const o = ke(e, t, n), r = Uint8Array.prototype.slice.call(e, t, t + n);
515
+ const o = Se(e, t, n), r = Uint8Array.prototype.slice.call(e, t, t + n);
516
516
  return this.store(r, o), o;
517
517
  }
518
518
  }
519
- const re = "array", N = "map_key", Ce = "map_value", xt = (s) => {
519
+ const re = "array", O = "map_key", Ee = "map_value", xt = (s) => {
520
520
  if (typeof s == "string" || typeof s == "number")
521
521
  return s;
522
522
  throw new z("The type of key must be string or number but " + typeof s);
@@ -538,7 +538,7 @@ class yt {
538
538
  }
539
539
  pushMapState(e) {
540
540
  const t = this.getUninitializedStateFromPool();
541
- t.type = N, t.readCount = 0, t.size = e, t.map = {};
541
+ t.type = O, t.readCount = 0, t.size = e, t.map = {};
542
542
  }
543
543
  getUninitializedStateFromPool() {
544
544
  if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
@@ -562,7 +562,7 @@ class yt {
562
562
  const n = e;
563
563
  n.size = 0, n.array = void 0, n.position = 0, n.type = void 0;
564
564
  }
565
- if (e.type === N || e.type === Ce) {
565
+ if (e.type === O || e.type === Ee) {
566
566
  const n = e;
567
567
  n.size = 0, n.map = void 0, n.readCount = 0, n.type = void 0;
568
568
  }
@@ -572,14 +572,14 @@ class yt {
572
572
  this.stack.length = 0, this.stackHeadPosition = -1;
573
573
  }
574
574
  }
575
- const O = -1, de = new DataView(new ArrayBuffer(0)), gt = new Uint8Array(de.buffer);
575
+ const q = -1, de = new DataView(new ArrayBuffer(0)), gt = new Uint8Array(de.buffer);
576
576
  try {
577
577
  de.getInt8(0);
578
578
  } catch (s) {
579
579
  if (!(s instanceof RangeError))
580
580
  throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
581
581
  }
582
- const xe = new RangeError("Insufficient data"), bt = new wt();
582
+ const ye = new RangeError("Insufficient data"), bt = new wt();
583
583
  class le {
584
584
  constructor(e) {
585
585
  a(this, "extensionCodec");
@@ -597,10 +597,10 @@ class le {
597
597
  a(this, "pos", 0);
598
598
  a(this, "view", de);
599
599
  a(this, "bytes", gt);
600
- a(this, "headByte", O);
600
+ a(this, "headByte", q);
601
601
  a(this, "stack", new yt());
602
602
  a(this, "entered", !1);
603
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Q.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? q, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? q, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? q, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? q, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? q, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : bt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? xt;
603
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Q.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.rawStrings = (e == null ? void 0 : e.rawStrings) ?? !1, this.maxStrLength = (e == null ? void 0 : e.maxStrLength) ?? j, this.maxBinLength = (e == null ? void 0 : e.maxBinLength) ?? j, this.maxArrayLength = (e == null ? void 0 : e.maxArrayLength) ?? j, this.maxMapLength = (e == null ? void 0 : e.maxMapLength) ?? j, this.maxExtLength = (e == null ? void 0 : e.maxExtLength) ?? j, this.keyDecoder = (e == null ? void 0 : e.keyDecoder) !== void 0 ? e.keyDecoder : bt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? xt;
604
604
  }
605
605
  clone() {
606
606
  return new le({
@@ -617,14 +617,14 @@ class le {
617
617
  });
618
618
  }
619
619
  reinitializeState() {
620
- this.totalPos = 0, this.headByte = O, this.stack.reset();
620
+ this.totalPos = 0, this.headByte = q, this.stack.reset();
621
621
  }
622
622
  setBuffer(e) {
623
623
  const t = oe(e);
624
624
  this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
625
625
  }
626
626
  appendBuffer(e) {
627
- if (this.headByte === O && !this.hasRemaining(1))
627
+ if (this.headByte === q && !this.hasRemaining(1))
628
628
  this.setBuffer(e);
629
629
  else {
630
630
  const t = this.bytes.subarray(this.pos), n = oe(e), i = new Uint8Array(t.length + n.length);
@@ -673,10 +673,10 @@ class le {
673
673
  try {
674
674
  this.entered = !0;
675
675
  let t = !1, n;
676
- for await (const p of e) {
676
+ for await (const h of e) {
677
677
  if (t)
678
678
  throw this.entered = !1, this.createExtraByteError(this.totalPos);
679
- this.appendBuffer(p);
679
+ this.appendBuffer(h);
680
680
  try {
681
681
  n = this.doDecodeSync(), t = !0;
682
682
  } catch (w) {
@@ -856,15 +856,15 @@ class le {
856
856
  t = i.array, n.release(i);
857
857
  else
858
858
  continue e;
859
- else if (i.type === N) {
859
+ else if (i.type === O) {
860
860
  if (t === "__proto__")
861
861
  throw new z("The key __proto__ is not allowed");
862
- i.key = this.mapKeyConverter(t), i.type = Ce;
862
+ i.key = this.mapKeyConverter(t), i.type = Ee;
863
863
  continue e;
864
864
  } else if (i.map[i.key] = t, i.readCount++, i.readCount === i.size)
865
865
  t = i.map, n.release(i);
866
866
  else {
867
- i.key = null, i.type = N;
867
+ i.key = null, i.type = O;
868
868
  continue e;
869
869
  }
870
870
  }
@@ -872,10 +872,10 @@ class le {
872
872
  }
873
873
  }
874
874
  readHeadByte() {
875
- return this.headByte === O && (this.headByte = this.readU8()), this.headByte;
875
+ return this.headByte === q && (this.headByte = this.readU8()), this.headByte;
876
876
  }
877
877
  complete() {
878
- this.headByte = O;
878
+ this.headByte = q;
879
879
  }
880
880
  readArraySize() {
881
881
  const e = this.readHeadByte();
@@ -912,13 +912,13 @@ class le {
912
912
  if (e > this.maxStrLength)
913
913
  throw new z(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
914
914
  if (this.bytes.byteLength < this.pos + t + e)
915
- throw xe;
915
+ throw ye;
916
916
  const n = this.pos + t;
917
917
  let i;
918
918
  return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, n, e) : i = Ge(this.bytes, n, e), this.pos += t + e, i;
919
919
  }
920
920
  stateIsMapKey() {
921
- return this.stack.length > 0 ? this.stack.top().type === N : !1;
921
+ return this.stack.length > 0 ? this.stack.top().type === O : !1;
922
922
  }
923
923
  /**
924
924
  * @throws {@link RangeError}
@@ -927,7 +927,7 @@ class le {
927
927
  if (e > this.maxBinLength)
928
928
  throw new z(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
929
929
  if (!this.hasRemaining(e + t))
930
- throw xe;
930
+ throw ye;
931
931
  const n = this.pos + t, i = this.bytes.subarray(n, n + e);
932
932
  return this.pos += t + e, i;
933
933
  }
@@ -979,7 +979,7 @@ class le {
979
979
  return this.pos += 8, e;
980
980
  }
981
981
  readI64() {
982
- const e = Ie(this.view, this.pos);
982
+ const e = Ce(this.view, this.pos);
983
983
  return this.pos += 8, e;
984
984
  }
985
985
  readU64AsBigInt() {
@@ -1017,7 +1017,15 @@ const vt = /* @__PURE__ */ new Set([
1017
1017
  "pubkey",
1018
1018
  "ping",
1019
1019
  "annotate",
1020
- "annotate_clear"
1020
+ "annotate_clear",
1021
+ "uploadPrekeys",
1022
+ "fetchPrekey",
1023
+ "assign",
1024
+ "tag",
1025
+ "note",
1026
+ "agent_status",
1027
+ "subscribe_inbox",
1028
+ "unsubscribe_inbox"
1021
1029
  ]);
1022
1030
  function kt(s) {
1023
1031
  return vt.has(s.type);
@@ -1179,14 +1187,14 @@ class Ct {
1179
1187
  this.byId.set(e.id, t ? { ...t, ...e } : e), e.seq > this._maxSeq && (this._maxSeq = e.seq), this._sorted = null;
1180
1188
  }
1181
1189
  markOwnStatus(e, t) {
1182
- const n = ye(t);
1190
+ const n = ge(t);
1183
1191
  let i = !1;
1184
1192
  for (const [o, r] of this.byId)
1185
- r.senderId !== this.me || r.seq <= 0 || r.seq > e || ye(r.status) >= n || (this.byId.set(o, { ...r, status: t }), i = !0);
1193
+ r.senderId !== this.me || r.seq <= 0 || r.seq > e || ge(r.status) >= n || (this.byId.set(o, { ...r, status: t }), i = !0);
1186
1194
  i && (this._sorted = null);
1187
1195
  }
1188
1196
  }
1189
- function ye(s) {
1197
+ function ge(s) {
1190
1198
  switch (s) {
1191
1199
  case "read":
1192
1200
  return 3;
@@ -1295,7 +1303,7 @@ function Ut(s) {
1295
1303
  function Pt(s) {
1296
1304
  return new WebSocket(s);
1297
1305
  }
1298
- const ge = 200, Bt = 7 * 864e5;
1306
+ const be = 200, Bt = 7 * 864e5;
1299
1307
  class At {
1300
1308
  constructor(e) {
1301
1309
  a(this, "key");
@@ -1315,7 +1323,7 @@ class At {
1315
1323
  add(e) {
1316
1324
  try {
1317
1325
  const t = this.load();
1318
- t.push(e), this.save(t.length > ge ? t.slice(t.length - ge) : t);
1326
+ t.push(e), this.save(t.length > be ? t.slice(t.length - be) : t);
1319
1327
  } catch {
1320
1328
  }
1321
1329
  }
@@ -1346,18 +1354,18 @@ function ae(s) {
1346
1354
  for (let i = 0; i < e.length; i++) n[i] = e.charCodeAt(i);
1347
1355
  return n;
1348
1356
  }
1349
- async function V() {
1357
+ async function N() {
1350
1358
  const s = await C().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1351
1359
  return { publicKey: s.publicKey, privateKey: s.privateKey };
1352
1360
  }
1353
1361
  async function _(s) {
1354
1362
  return ee(await C().exportKey("raw", s));
1355
1363
  }
1356
- async function F(s) {
1364
+ async function R(s) {
1357
1365
  return C().importKey("raw", ae(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1358
1366
  }
1359
1367
  async function Kt(s, e) {
1360
- const t = await F(e);
1368
+ const t = await R(e);
1361
1369
  return C().deriveKey(
1362
1370
  { name: "ECDH", public: t },
1363
1371
  s,
@@ -1379,12 +1387,12 @@ async function Mt(s) {
1379
1387
  try {
1380
1388
  const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
1381
1389
  if (i) {
1382
- const { pub: o, priv: r } = JSON.parse(i), p = await C().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await C().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1383
- return { publicKey: p, privateKey: w };
1390
+ const { pub: o, priv: r } = JSON.parse(i), h = await C().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await C().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1391
+ return { publicKey: h, privateKey: w };
1384
1392
  }
1385
1393
  } catch {
1386
1394
  }
1387
- const e = await V();
1395
+ const e = await N();
1388
1396
  try {
1389
1397
  const i = await C().exportKey("jwk", e.publicKey), o = await C().exportKey("jwk", e.privateKey);
1390
1398
  (n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv: o }));
@@ -1397,7 +1405,7 @@ async function Dt(s, e) {
1397
1405
  return ee(n);
1398
1406
  }
1399
1407
  async function _t() {
1400
- const s = await V(), e = await C().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1408
+ const s = await N(), e = await C().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1401
1409
  return {
1402
1410
  ecdhKP: s,
1403
1411
  ecdsaKP: { publicKey: e.publicKey, privateKey: e.privateKey },
@@ -1405,14 +1413,14 @@ async function _t() {
1405
1413
  sigPublicKeyB64: await _(e.publicKey)
1406
1414
  };
1407
1415
  }
1408
- async function be(s) {
1416
+ async function me(s) {
1409
1417
  var t, n;
1410
1418
  try {
1411
1419
  const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
1412
1420
  if (i) {
1413
- const o = JSON.parse(i), r = await C().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), p = await C().importKey("jwk", o.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await C().importKey("jwk", o.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), d = await C().importKey("jwk", o.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
1421
+ const o = JSON.parse(i), r = await C().importKey("jwk", o.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), h = await C().importKey("jwk", o.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await C().importKey("jwk", o.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), d = await C().importKey("jwk", o.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
1414
1422
  return {
1415
- ecdhKP: { publicKey: r, privateKey: p },
1423
+ ecdhKP: { publicKey: r, privateKey: h },
1416
1424
  ecdsaKP: { publicKey: w, privateKey: d },
1417
1425
  publicKeyB64: await _(r),
1418
1426
  sigPublicKeyB64: await _(w)
@@ -1422,31 +1430,31 @@ async function be(s) {
1422
1430
  }
1423
1431
  const e = await _t();
1424
1432
  try {
1425
- const i = await C().exportKey("jwk", e.ecdhKP.publicKey), o = await C().exportKey("jwk", e.ecdhKP.privateKey), r = await C().exportKey("jwk", e.ecdsaKP.publicKey), p = await C().exportKey("jwk", e.ecdsaKP.privateKey);
1426
- (n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: o, ecdsaPub: r, ecdsaPriv: p }));
1433
+ const i = await C().exportKey("jwk", e.ecdhKP.publicKey), o = await C().exportKey("jwk", e.ecdhKP.privateKey), r = await C().exportKey("jwk", e.ecdsaKP.publicKey), h = await C().exportKey("jwk", e.ecdsaKP.privateKey);
1434
+ (n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: o, ecdsaPub: r, ecdsaPriv: h }));
1427
1435
  } catch {
1428
1436
  }
1429
1437
  return e;
1430
1438
  }
1431
1439
  async function $t(s, e) {
1432
- const t = await V(), n = await _(t.publicKey), i = await F(e.identityKey), o = await F(e.signedPrekey), r = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, p = await D(s.privateKey, o), w = await D(t.privateKey, i), d = await D(t.privateKey, o), v = r ? await D(t.privateKey, r) : null, x = Ee(p, w, d, ...v ? [v] : []);
1433
- return { sharedKey: await Te(x), ephemeralPublicKey: n };
1440
+ const t = await N(), n = await _(t.publicKey), i = await R(e.identityKey), o = await R(e.signedPrekey), r = e.oneTimePrekey ? await R(e.oneTimePrekey) : null, h = await D(s.privateKey, o), w = await D(t.privateKey, i), d = await D(t.privateKey, o), v = r ? await D(t.privateKey, r) : null, x = Te(h, w, d, ...v ? [v] : []);
1441
+ return { sharedKey: await Ue(x), ephemeralPublicKey: n };
1434
1442
  }
1435
1443
  async function Ht(s, e, t, n, i) {
1436
- const o = await F(t), r = await F(n), p = await D(e.privateKey, o), w = await D(s.privateKey, r), d = await D(e.privateKey, r), v = i ? await D(i.privateKey, r) : null, x = Ee(p, w, d, ...v ? [v] : []);
1437
- return Te(x);
1444
+ const o = await R(t), r = await R(n), h = await D(e.privateKey, o), w = await D(s.privateKey, r), d = await D(e.privateKey, r), v = i ? await D(i.privateKey, r) : null, x = Te(h, w, d, ...v ? [v] : []);
1445
+ return Ue(x);
1438
1446
  }
1439
1447
  async function D(s, e) {
1440
1448
  return C().deriveBits({ name: "ECDH", public: e }, s, 256);
1441
1449
  }
1442
- function Ee(...s) {
1450
+ function Te(...s) {
1443
1451
  const e = s.reduce((i, o) => i + o.byteLength, 0), t = new Uint8Array(e);
1444
1452
  let n = 0;
1445
1453
  for (const i of s)
1446
1454
  t.set(new Uint8Array(i), n), n += i.byteLength;
1447
1455
  return t.buffer;
1448
1456
  }
1449
- async function Te(s) {
1457
+ async function Ue(s) {
1450
1458
  const e = await C().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
1451
1459
  return C().deriveKey(
1452
1460
  { name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info: new TextEncoder().encode("ObjectChat X3DH v1") },
@@ -1488,8 +1496,8 @@ class Ft {
1488
1496
  /** X3DH: Generate identity key, signed prekey, and OTP prekeys.
1489
1497
  * Returns the upload frame payload the caller should send to the server. */
1490
1498
  async initX3DH() {
1491
- this.identityKP = await be(this.storageKey), this.signedPreKP = await V(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1492
- for (let i = 0; i < Rt; i++) this.otpKeys.push(await V());
1499
+ this.identityKP = await me(this.storageKey), this.signedPreKP = await N(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1500
+ for (let i = 0; i < Rt; i++) this.otpKeys.push(await N());
1493
1501
  const e = await _(this.signedPreKP.publicKey), t = await Dt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => _(i.publicKey)));
1494
1502
  return {
1495
1503
  identityKey: this.identityKP.publicKeyB64,
@@ -1502,7 +1510,7 @@ class Ft {
1502
1510
  /** X3DH sender: given a recipient's prekey bundle, derive the shared key and
1503
1511
  * return the init message fields to embed in the first encrypted message. */
1504
1512
  async x3dhSendTo(e) {
1505
- this.identityKP || (this.identityKP = await be(this.storageKey));
1513
+ this.identityKP || (this.identityKP = await me(this.storageKey));
1506
1514
  const { sharedKey: t, ephemeralPublicKey: n } = await $t(this.identityKP.ecdhKP, e);
1507
1515
  return this.x3dhShared = t, { ephemeralKey: n, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
1508
1516
  }
@@ -1558,7 +1566,7 @@ function jt(s) {
1558
1566
  const e = s;
1559
1567
  return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
1560
1568
  }
1561
- const me = "objectchat-widget-styles", qt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Ot = `
1569
+ const ve = "objectchat-widget-styles", qt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Ot = `
1562
1570
  .ocw { --ocw-accent:#4F63F5; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
1563
1571
  position:relative;
1564
1572
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
@@ -1719,9 +1727,9 @@ const me = "objectchat-widget-styles", qt = ["👍", "❤️", "😂", "😮", "
1719
1727
  .ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
1720
1728
  `;
1721
1729
  function Nt() {
1722
- if (typeof document > "u" || document.getElementById(me)) return;
1730
+ if (typeof document > "u" || document.getElementById(ve)) return;
1723
1731
  const s = document.createElement("style");
1724
- s.id = me, s.textContent = Ot, document.head.appendChild(s);
1732
+ s.id = ve, s.textContent = Ot, document.head.appendChild(s);
1725
1733
  }
1726
1734
  function c(s, e, t) {
1727
1735
  const n = document.createElement(s);
@@ -1784,17 +1792,17 @@ class Wt {
1784
1792
  a(this, "translationCache", /* @__PURE__ */ new Map());
1785
1793
  a(this, "showingTranslation", /* @__PURE__ */ new Set());
1786
1794
  a(this, "subjectBuilt", !1);
1787
- var m, g, U, A, P, K, b, S, M;
1795
+ var m, y, U, A, P, K, b, S, M;
1788
1796
  this.root = e, this.me = t, this.h = n, this.cfg = i, Nt(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
1789
1797
  const o = c("div", "ocw-head"), r = c("div", "ocw-avatar");
1790
1798
  if ((m = i.userInfo) != null && m.avatar) {
1791
1799
  const k = document.createElement("img");
1792
1800
  k.src = i.userInfo.avatar, k.alt = i.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", r.append(k);
1793
1801
  } else
1794
- r.textContent = (g = i.userInfo) != null && g.name ? i.userInfo.name[0].toUpperCase() : "🧑";
1802
+ r.textContent = (y = i.userInfo) != null && y.name ? i.userInfo.name[0].toUpperCase() : "🧑";
1795
1803
  o.append(r);
1796
- const p = c("div", "ocw-head-main");
1797
- this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((A = i.subject) == null ? void 0 : A.title) ?? ""), p.append(this.headerName), (P = i.subject) != null && P.subtitle && p.append(c("div", "ocw-head-meta", i.subject.subtitle)), o.append(p), this.statusBadge = c("span", "ocw-badge", ((K = i.subject) == null ? void 0 : K.status) ?? ""), (b = i.subject) != null && b.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = c("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = c("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.append(this.connStatus), this.cobrowseBtn = c("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
1804
+ const h = c("div", "ocw-head-main");
1805
+ this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((A = i.subject) == null ? void 0 : A.title) ?? ""), h.append(this.headerName), (P = i.subject) != null && P.subtitle && h.append(c("div", "ocw-head-meta", i.subject.subtitle)), o.append(h), this.statusBadge = c("span", "ocw-badge", ((K = i.subject) == null ? void 0 : K.status) ?? ""), (b = i.subject) != null && b.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = c("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = c("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.append(this.connStatus), this.cobrowseBtn = c("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
1798
1806
  this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
1799
1807
  }), o.append(this.cobrowseBtn), o.append(c("button", "ocw-menu", "⋯")), this.chips = c("div", "ocw-chiprow"), this.scroll = c("div", "ocw-scroll"), this.subjectCard = c("div", "ocw-subject"), this.typing = c("div", "ocw-typing");
1800
1808
  const w = c("div", "ocw-typing-bubble");
@@ -1817,15 +1825,15 @@ class Wt {
1817
1825
  var k;
1818
1826
  (k = x.files) != null && k[0] && this.h.onAttach && this.h.onAttach(x.files[0]), x.value = "";
1819
1827
  });
1820
- const f = c("div", "ocw-input");
1821
- f.append(v, x, this.input, d);
1822
- const u = c("div", "ocw-footer");
1823
- ((M = i.i18n) == null ? void 0 : M.poweredBy) !== void 0 ? u.textContent = i.i18n.poweredBy : u.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = u, e.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, f, this.footer), this.cobrowseCanvas = c("canvas", "ocw-cobrowse-canvas"), this.cobrowseToolbar = c("div", "ocw-cobrowse-toolbar");
1828
+ const u = c("div", "ocw-input");
1829
+ u.append(v, x, this.input, d);
1830
+ const p = c("div", "ocw-footer");
1831
+ ((M = i.i18n) == null ? void 0 : M.poweredBy) !== void 0 ? p.textContent = i.i18n.poweredBy : p.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = p, e.append(o, this.chips, this.scroll, this.typing, this.quick, this.formHost, this.csatPanel, this.offlinePanel, u, this.footer), this.cobrowseCanvas = c("canvas", "ocw-cobrowse-canvas"), this.cobrowseToolbar = c("div", "ocw-cobrowse-toolbar");
1824
1832
  for (const k of ["#f5713c", "#1c1b1a", "#2563eb", "#16a34a", "#dc2626"]) {
1825
1833
  const T = c("button", "ocw-cobrowse-swatch");
1826
1834
  T.style.background = k, T.type = "button", k === this.cobrowseColor && T.classList.add("sel"), T.addEventListener("click", () => {
1827
1835
  this.cobrowseColor = k;
1828
- for (const W of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) W.classList.remove("sel");
1836
+ for (const V of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) V.classList.remove("sel");
1829
1837
  T.classList.add("sel");
1830
1838
  }), this.cobrowseToolbar.append(T);
1831
1839
  }
@@ -1865,26 +1873,26 @@ class Wt {
1865
1873
  render(e) {
1866
1874
  var d, v, x;
1867
1875
  if (this.storeRef = e, this.cobrowseBtn.classList.toggle("show", !!e.subject), !e.subject && this.cobrowseActive && (this.cobrowseActive = !1, this.updateCobrowseUI()), this.cobrowseActive && e.annotationVersion !== this.lastAnnotationVersion && (this.lastAnnotationVersion = e.annotationVersion, this.resizeCobrowseCanvas(), this.redrawCobrowse()), e.accent && this.root.style.setProperty("--ocw-accent", e.accent), this.e2eBadge.style.display = e.e2e ? "inline-flex" : "none", this.buildSubjectCard(e), e.subject) {
1868
- const f = (d = this.cfg.subject) == null ? void 0 : d.ownerLabel;
1869
- f && (this.headerName.textContent = f);
1876
+ const u = (d = this.cfg.subject) == null ? void 0 : d.ownerLabel;
1877
+ u && (this.headerName.textContent = u);
1870
1878
  }
1871
1879
  this.quick.style.display = e.messages().length === 0 ? "flex" : "none", this.chips.replaceChildren();
1872
1880
  const t = e.visibleActions();
1873
1881
  this.chips.style.display = t.length ? "flex" : "none";
1874
- for (const f of t) this.chips.append(this.chipEl(f));
1882
+ for (const u of t) this.chips.append(this.chipEl(u));
1875
1883
  const n = this.scroll.scrollHeight, i = this.scroll.scrollTop;
1876
1884
  if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
1877
- const f = c("div", "ocw-load-more");
1878
- f.textContent = "↑ Loading earlier messages…", f.style.pointerEvents = "none", this.scroll.append(f);
1885
+ const u = c("div", "ocw-load-more");
1886
+ u.textContent = "↑ Loading earlier messages…", u.style.pointerEvents = "none", this.scroll.append(u);
1879
1887
  }
1880
1888
  let o = 0;
1881
- for (const f of e.messages())
1882
- this.scroll.append(this.messageEl(f, e)), f.senderId !== this.me && f.seq > o && (o = f.seq);
1889
+ for (const u of e.messages())
1890
+ this.scroll.append(this.messageEl(u, e)), u.senderId !== this.me && u.seq > o && (o = u.seq);
1883
1891
  i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - n + i : this.scroll.scrollTop = this.scroll.scrollHeight, o > 0 && this.h.onReadUpTo(o);
1884
1892
  const r = [...e.typing];
1885
1893
  this.typing.classList.toggle("active", r.length > 0);
1886
- const p = this.typing.querySelector(".ocw-typing-bubble");
1887
- p && p.setAttribute("aria-label", r.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block", e.offline ? (this.offlinePanel.style.display === "none" && this.buildOfflinePanel(e.offlineMessage), this.offlinePanel.style.display = "block", (v = this.root.querySelector(".ocw-input")) == null || v.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (x = this.root.querySelector(".ocw-input")) == null || x.style.removeProperty("display"));
1894
+ const h = this.typing.querySelector(".ocw-typing-bubble");
1895
+ h && h.setAttribute("aria-label", r.length ? "typing" : ""), this.footer.style.display = e.whiteLabel ? "none" : "block", e.offline ? (this.offlinePanel.style.display === "none" && this.buildOfflinePanel(e.offlineMessage), this.offlinePanel.style.display = "block", (v = this.root.querySelector(".ocw-input")) == null || v.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (x = this.root.querySelector(".ocw-input")) == null || x.style.removeProperty("display"));
1888
1896
  const w = ["resolved", "closed", "sold", "issued", "checked_out"];
1889
1897
  this.h.onCsat && !this.csatSubmitted && w.includes(e.state) && e.messages().length > 0 && (this.csatPanel.style.display === "none" && this.buildCsatPanel(), this.csatPanel.style.display = "block");
1890
1898
  }
@@ -1898,8 +1906,8 @@ class Wt {
1898
1906
  this.connStatus.className = `ocw-conn-status${n ? " err" : e === "reconnecting" ? " warn" : ""}`, this.connStatus.textContent = n ? `⚠ ${t ?? "Chat unavailable"}` : e === "reconnecting" ? t ?? "↻ reconnecting…" : "● connecting…";
1899
1907
  }
1900
1908
  buildOfflinePanel(e) {
1901
- var p;
1902
- this.offlinePanel.replaceChildren(), this.offlinePanel.append(c("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(c("div", "ocw-offline-title", ((p = this.cfg.i18n) == null ? void 0 : p.offline) ?? "We're offline right now")), this.offlinePanel.append(c("div", "ocw-offline-msg", e || "Leave your details and we'll get back to you soon."));
1909
+ var h;
1910
+ this.offlinePanel.replaceChildren(), this.offlinePanel.append(c("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(c("div", "ocw-offline-title", ((h = this.cfg.i18n) == null ? void 0 : h.offline) ?? "We're offline right now")), this.offlinePanel.append(c("div", "ocw-offline-msg", e || "Leave your details and we'll get back to you soon."));
1903
1911
  const t = c("div", "ocw-offline-form"), n = c("input", "ocw-offline-input");
1904
1912
  n.placeholder = "Your name", n.type = "text";
1905
1913
  const i = c("input", "ocw-offline-input");
@@ -1956,7 +1964,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
1956
1964
  bindCobrowsePointerEvents() {
1957
1965
  let e = !1, t = [];
1958
1966
  const n = (r) => {
1959
- const p = this.cobrowseCanvas.getBoundingClientRect(), w = p.width > 0 ? (r.clientX - p.left) / p.width : 0, d = p.height > 0 ? (r.clientY - p.top) / p.height : 0;
1967
+ const h = this.cobrowseCanvas.getBoundingClientRect(), w = h.width > 0 ? (r.clientX - h.left) / h.width : 0, d = h.height > 0 ? (r.clientY - h.top) / h.height : 0;
1960
1968
  return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0, d)) };
1961
1969
  }, i = 6e-3;
1962
1970
  this.cobrowseCanvas.addEventListener("pointerdown", (r) => {
@@ -1965,9 +1973,9 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
1965
1973
  e && (t.push(n(r)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: i }));
1966
1974
  });
1967
1975
  const o = (r) => {
1968
- var p, w;
1976
+ var h, w;
1969
1977
  if (e) {
1970
- e = !1, t.length > 1 && ((w = (p = this.h).onAnnotate) == null || w.call(p, { id: `an_${Date.now()}_${Math.random().toString(36).slice(2)}`, points: t, color: this.cobrowseColor, width: i })), t = [];
1978
+ e = !1, t.length > 1 && ((w = (h = this.h).onAnnotate) == null || w.call(h, { id: `an_${Date.now()}_${Math.random().toString(36).slice(2)}`, points: t, color: this.cobrowseColor, width: i })), t = [];
1971
1979
  try {
1972
1980
  this.cobrowseCanvas.releasePointerCapture(r.pointerId);
1973
1981
  } catch {
@@ -1982,8 +1990,8 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
1982
1990
  if (!i) return;
1983
1991
  this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(c("div", "ocw-subject-title", i)), n != null && n.subtitle && this.subjectCard.append(c("div", "ocw-subject-sub", n.subtitle));
1984
1992
  const o = c("div", "ocw-tags");
1985
- if (t) for (const [p, w] of Object.entries(t.fields)) o.append(c("span", "ocw-tag", `${p}: ${w}`));
1986
- else for (const p of (n == null ? void 0 : n.tags) ?? []) o.append(c("span", "ocw-tag", p));
1993
+ if (t) for (const [h, w] of Object.entries(t.fields)) o.append(c("span", "ocw-tag", `${h}: ${w}`));
1994
+ else for (const h of (n == null ? void 0 : n.tags) ?? []) o.append(c("span", "ocw-tag", h));
1987
1995
  o.childNodes.length && this.subjectCard.append(o);
1988
1996
  const r = (t == null ? void 0 : t.state) ?? (n == null ? void 0 : n.status);
1989
1997
  r && (this.statusBadge.textContent = r, this.statusBadge.style.display = "inline-flex");
@@ -2000,30 +2008,30 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2000
2008
  return new Promise((t) => {
2001
2009
  const n = c("div", "ocw-modal"), i = c("div", "ocw-modal-card");
2002
2010
  i.append(c("div", "ocw-modal-title", e)), i.append(c("div", "ocw-modal-body", `Confirm “${e}”?`));
2003
- const o = c("div", "ocw-modal-actions"), r = c("button", "ocw-modal-cancel", "Cancel"), p = c("button", "ocw-modal-ok", "Confirm"), w = (d) => {
2011
+ const o = c("div", "ocw-modal-actions"), r = c("button", "ocw-modal-cancel", "Cancel"), h = c("button", "ocw-modal-ok", "Confirm"), w = (d) => {
2004
2012
  n.remove(), t(d);
2005
2013
  };
2006
- r.addEventListener("click", () => w(!1)), p.addEventListener("click", () => w(!0)), n.addEventListener("click", (d) => {
2014
+ r.addEventListener("click", () => w(!1)), h.addEventListener("click", () => w(!0)), n.addEventListener("click", (d) => {
2007
2015
  d.target === n && w(!1);
2008
- }), o.append(r, p), i.append(o), n.append(i), this.root.append(n), p.focus();
2016
+ }), o.append(r, h), i.append(o), n.append(i), this.root.append(n), h.focus();
2009
2017
  });
2010
2018
  }
2011
2019
  /** Inline form for a form-effect action: typed inputs (date picker, number,
2012
2020
  * text) rendered above the composer — no browser prompts. */
2013
2021
  openForm(e) {
2014
- var p, w;
2022
+ var h, w;
2015
2023
  this.formHost.replaceChildren();
2016
2024
  const t = c("div", "ocw-form");
2017
2025
  t.append(c("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
2018
2026
  const n = /* @__PURE__ */ new Map();
2019
2027
  for (const d of e.input ?? []) {
2020
2028
  const v = c("label", "ocw-form-row");
2021
- if (v.append(c("span", "ocw-form-lbl", d.label)), d.type === "select" && ((p = d.options) != null && p.length)) {
2029
+ if (v.append(c("span", "ocw-form-lbl", d.label)), d.type === "select" && ((h = d.options) != null && h.length)) {
2022
2030
  const x = c("select", "ocw-form-input");
2023
2031
  d.required || x.append(c("option", void 0, "— select —"));
2024
- for (const f of d.options) {
2025
- const u = c("option");
2026
- u.value = f, u.textContent = f, x.append(u);
2032
+ for (const u of d.options) {
2033
+ const p = c("option");
2034
+ p.value = u, p.textContent = u, x.append(p);
2027
2035
  }
2028
2036
  d.required && (x.required = !0), v.append(x), n.set(d.name, x);
2029
2037
  } else {
@@ -2048,71 +2056,71 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2048
2056
  messageEl(e, t) {
2049
2057
  var x;
2050
2058
  if (e.senderRole === "system") {
2051
- const f = c("div", "ocw-sys");
2052
- return f.textContent = e.deletedAt ? "message deleted" : se(e.content), f;
2059
+ const u = c("div", "ocw-sys");
2060
+ return u.textContent = e.deletedAt ? "message deleted" : se(e.content), u;
2053
2061
  }
2054
2062
  const n = e.senderId === this.me, i = !!e.internal, o = c("div", `ocw-row ${i ? "ocw-note mine" : n ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
2055
2063
  !n && !i && o.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
2056
- const r = c("div"), p = c("div", "ocw-bubble-wrap");
2064
+ const r = c("div"), h = c("div", "ocw-bubble-wrap");
2057
2065
  if (e.replyToId) {
2058
- const f = c("div", "ocw-reply-to", "↩ replying to a message");
2059
- f.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", r.append(f);
2066
+ const u = c("div", "ocw-reply-to", "↩ replying to a message");
2067
+ u.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", r.append(u);
2060
2068
  }
2061
2069
  const w = c("div", "ocw-bubble");
2062
2070
  let d = null;
2063
2071
  if (e.deletedAt) w.append(c("span", "ocw-deleted", "message deleted"));
2064
2072
  else if (e.content.kind === "attachment") {
2065
- const f = e.content;
2066
- if ((x = f.mime) != null && x.startsWith("image/")) {
2067
- const u = document.createElement("img");
2068
- u.src = f.url, u.alt = f.name ?? "image", u.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", u.addEventListener("click", () => window.open(f.url, "_blank")), w.append(u);
2073
+ const u = e.content;
2074
+ if ((x = u.mime) != null && x.startsWith("image/")) {
2075
+ const p = document.createElement("img");
2076
+ p.src = u.url, p.alt = u.name ?? "image", p.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", p.addEventListener("click", () => window.open(u.url, "_blank")), w.append(p);
2069
2077
  } else {
2070
- const u = document.createElement("a");
2071
- u.href = f.url, u.target = "_blank", u.rel = "noopener", u.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", u.append(c("span", void 0, "📄"), c("span", void 0, f.name ?? "file")), w.append(u);
2078
+ const p = document.createElement("a");
2079
+ p.href = u.url, p.target = "_blank", p.rel = "noopener", p.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", p.append(c("span", void 0, "📄"), c("span", void 0, u.name ?? "file")), w.append(p);
2072
2080
  }
2073
2081
  } else if (e.content.kind === "appointment") {
2074
- const f = e.content, u = c("div", "ocw-appt");
2075
- u.append(c("div", "ocw-appt-title", `📅 ${f.title}`)), u.append(c("div", "ocw-appt-time", new Date(f.startIso).toLocaleString() + " – " + new Date(f.endIso).toLocaleTimeString())), f.location && u.append(c("div", "ocw-appt-loc", `📍 ${f.location}`)), f.description && u.append(c("div", "ocw-appt-desc", f.description));
2082
+ const u = e.content, p = c("div", "ocw-appt");
2083
+ p.append(c("div", "ocw-appt-title", `📅 ${u.title}`)), p.append(c("div", "ocw-appt-time", new Date(u.startIso).toLocaleString() + " – " + new Date(u.endIso).toLocaleTimeString())), u.location && p.append(c("div", "ocw-appt-loc", `📍 ${u.location}`)), u.description && p.append(c("div", "ocw-appt-desc", u.description));
2076
2084
  const I = c("div", "ocw-appt-links"), m = document.createElement("a");
2077
- m.href = f.googleUrl, m.target = "_blank", m.rel = "noopener", m.className = "ocw-appt-btn", m.textContent = "📅 Add to Google Calendar";
2078
- const g = document.createElement("a");
2079
- g.href = f.icalUrl, g.download = `${f.title}.ics`, g.className = "ocw-appt-btn ocw-appt-btn-sec", g.textContent = "🍎 Apple / iCal", I.append(m, g), u.append(I), w.append(u);
2085
+ m.href = u.googleUrl, m.target = "_blank", m.rel = "noopener", m.className = "ocw-appt-btn", m.textContent = "📅 Add to Google Calendar";
2086
+ const y = document.createElement("a");
2087
+ y.href = u.icalUrl, y.download = `${u.title}.ics`, y.className = "ocw-appt-btn ocw-appt-btn-sec", y.textContent = "🍎 Apple / iCal", I.append(m, y), p.append(I), w.append(p);
2080
2088
  } else
2081
2089
  d = document.createTextNode(se(e.content)), w.append(d), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
2082
- if (p.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && d) {
2083
- const f = e.content.text;
2084
- if (f.trim()) {
2085
- const u = c("button", "ocw-translate-btn", "🌐");
2086
- u.type = "button", u.title = "Translate", u.addEventListener("click", (I) => {
2090
+ if (h.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && d) {
2091
+ const u = e.content.text;
2092
+ if (u.trim()) {
2093
+ const p = c("button", "ocw-translate-btn", "🌐");
2094
+ p.type = "button", p.title = "Translate", p.addEventListener("click", (I) => {
2087
2095
  if (I.stopPropagation(), this.showingTranslation.has(e.id)) {
2088
- this.showingTranslation.delete(e.id), d.textContent = f, u.textContent = "🌐", u.title = "Translate";
2096
+ this.showingTranslation.delete(e.id), d.textContent = u, p.textContent = "🌐", p.title = "Translate";
2089
2097
  return;
2090
2098
  }
2091
2099
  const m = this.translationCache.get(e.id);
2092
2100
  if (m !== void 0) {
2093
- this.showingTranslation.add(e.id), d.textContent = m, u.textContent = "↩", u.title = "Show original";
2101
+ this.showingTranslation.add(e.id), d.textContent = m, p.textContent = "↩", p.title = "Show original";
2094
2102
  return;
2095
2103
  }
2096
- u.textContent = "⏳", this.h.onTranslate(f).then((g) => {
2097
- if (g === null) {
2098
- u.textContent = "⚠️", u.title = "Translation unavailable", setTimeout(() => {
2099
- u.textContent = "🌐", u.title = "Translate";
2104
+ p.textContent = "⏳", this.h.onTranslate(u).then((y) => {
2105
+ if (y === null) {
2106
+ p.textContent = "⚠️", p.title = "Translation unavailable", setTimeout(() => {
2107
+ p.textContent = "🌐", p.title = "Translate";
2100
2108
  }, 1500);
2101
2109
  return;
2102
2110
  }
2103
- this.translationCache.set(e.id, g), this.showingTranslation.add(e.id), d.textContent = g, u.textContent = "↩", u.title = "Show original";
2111
+ this.translationCache.set(e.id, y), this.showingTranslation.add(e.id), d.textContent = y, p.textContent = "↩", p.title = "Show original";
2104
2112
  });
2105
- }), p.append(u);
2113
+ }), h.append(p);
2106
2114
  }
2107
2115
  }
2108
2116
  if (n && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
2109
- const f = c("div", "ocw-msg-menu");
2117
+ const u = c("div", "ocw-msg-menu");
2110
2118
  if (this.h.onEdit) {
2111
- const u = c("button", void 0, "✏️");
2112
- u.title = "Edit", u.addEventListener("click", (I) => {
2119
+ const p = c("button", void 0, "✏️");
2120
+ p.title = "Edit", p.addEventListener("click", (I) => {
2113
2121
  I.stopPropagation();
2114
- const m = se(e.content), g = document.createElement("textarea");
2115
- g.value = m, g.rows = Math.min(4, Math.ceil(m.length / 40) + 1), g.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
2122
+ const m = se(e.content), y = document.createElement("textarea");
2123
+ y.value = m, y.rows = Math.min(4, Math.ceil(m.length / 40) + 1), y.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
2116
2124
  const U = c("button", "ocw-form-submit", "Save");
2117
2125
  U.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
2118
2126
  const A = c("button", "ocw-form-cancel", "Cancel");
@@ -2120,54 +2128,54 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-t
2120
2128
  const P = c("div");
2121
2129
  P.style.cssText = "display:flex;gap:6px;justify-content:flex-end", P.append(A, U);
2122
2130
  const K = c("div");
2123
- K.append(g, P), w.replaceChildren(K), g.focus(), g.select();
2131
+ K.append(y, P), w.replaceChildren(K), y.focus(), y.select();
2124
2132
  const b = () => w.replaceChildren(d ?? document.createTextNode(m));
2125
2133
  A.addEventListener("click", b), U.addEventListener("click", () => {
2126
- const S = g.value.trim();
2134
+ const S = y.value.trim();
2127
2135
  S && S !== m && this.h.onEdit(e.id, S), b();
2128
- }), g.addEventListener("keydown", (S) => {
2136
+ }), y.addEventListener("keydown", (S) => {
2129
2137
  S.key === "Enter" && !S.shiftKey && (S.preventDefault(), U.click()), S.key === "Escape" && b();
2130
2138
  });
2131
- }), f.append(u);
2139
+ }), u.append(p);
2132
2140
  }
2133
2141
  if (this.h.onDelete) {
2134
- const u = c("button", "del", "🗑");
2135
- u.title = "Delete", u.addEventListener("click", (I) => {
2142
+ const p = c("button", "del", "🗑");
2143
+ p.title = "Delete", p.addEventListener("click", (I) => {
2136
2144
  I.stopPropagation(), this.h.onDelete(e.id);
2137
- }), f.append(u);
2145
+ }), u.append(p);
2138
2146
  }
2139
- p.append(f);
2147
+ h.append(u);
2140
2148
  }
2141
- if (r.append(p), this.h.onReact && !e.deletedAt && e.seq > 0) {
2142
- const f = c("div", "ocw-react-wrap"), u = c("div", "ocw-react");
2149
+ if (r.append(h), this.h.onReact && !e.deletedAt && e.seq > 0) {
2150
+ const u = c("div", "ocw-react-wrap"), p = c("div", "ocw-react");
2143
2151
  if (e.reactions && Object.keys(e.reactions).length)
2144
- for (const [g, U] of Object.entries(e.reactions)) {
2145
- const A = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${g} ${U.length}`);
2152
+ for (const [y, U] of Object.entries(e.reactions)) {
2153
+ const A = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${y} ${U.length}`);
2146
2154
  A.addEventListener("click", () => {
2147
2155
  var P, K;
2148
- return (K = (P = this.h).onReact) == null ? void 0 : K.call(P, e.id, g, U.includes(this.me));
2149
- }), u.append(A);
2156
+ return (K = (P = this.h).onReact) == null ? void 0 : K.call(P, e.id, y, U.includes(this.me));
2157
+ }), p.append(A);
2150
2158
  }
2151
2159
  const I = c("button", "ocw-react-btn", "+"), m = c("div", "ocw-react-picker");
2152
- for (const g of qt) {
2153
- const U = c("button", void 0, g);
2160
+ for (const y of qt) {
2161
+ const U = c("button", void 0, y);
2154
2162
  U.addEventListener("click", (A) => {
2155
2163
  var K, b, S, M;
2156
2164
  A.stopPropagation();
2157
- const P = (b = (K = e.reactions) == null ? void 0 : K[g]) == null ? void 0 : b.includes(this.me);
2158
- (M = (S = this.h).onReact) == null || M.call(S, e.id, g, !!P), m.style.display = "none";
2165
+ const P = (b = (K = e.reactions) == null ? void 0 : K[y]) == null ? void 0 : b.includes(this.me);
2166
+ (M = (S = this.h).onReact) == null || M.call(S, e.id, y, !!P), m.style.display = "none";
2159
2167
  }), m.append(U);
2160
2168
  }
2161
- m.style.display = "none", I.addEventListener("click", (g) => {
2162
- g.stopPropagation(), m.style.display = m.style.display === "none" ? "flex" : "none";
2169
+ m.style.display = "none", I.addEventListener("click", (y) => {
2170
+ y.stopPropagation(), m.style.display = m.style.display === "none" ? "flex" : "none";
2163
2171
  }), document.addEventListener("click", () => {
2164
2172
  m.style.display = "none";
2165
- }, { once: !0 }), u.append(I), f.append(u, m), r.append(f);
2166
- } else e.reactions && Object.keys(e.reactions).length && r.append(c("div", "ocw-react", Object.entries(e.reactions).map(([f, u]) => `${f}${u.length}`).join(" ")));
2173
+ }, { once: !0 }), p.append(I), u.append(p, m), r.append(u);
2174
+ } else e.reactions && Object.keys(e.reactions).length && r.append(c("div", "ocw-react", Object.entries(e.reactions).map(([u, p]) => `${u}${p.length}`).join(" ")));
2167
2175
  const v = c("div", "ocw-time ocw-meta", Vt(e.ts));
2168
2176
  if (n && e.status) {
2169
- const f = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Xt(e.status));
2170
- v.append(f);
2177
+ const u = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Xt(e.status));
2178
+ v.append(u);
2171
2179
  }
2172
2180
  return n && e.seq > 0 && t.lastReadByOthers >= e.seq && v.append(c("span", "ocw-seen", " · Seen")), r.append(v), o.append(r), o;
2173
2181
  }
@@ -2185,7 +2193,7 @@ function Xt(s) {
2185
2193
  }
2186
2194
  }
2187
2195
  const H = /* @__PURE__ */ new WeakMap(), Z = /* @__PURE__ */ new Map();
2188
- function ve(s) {
2196
+ function ke(s) {
2189
2197
  return `relay-launcher::${s.profileId}::${s.subjectId ?? ""}`;
2190
2198
  }
2191
2199
  function Zt(s) {
@@ -2193,20 +2201,20 @@ function Zt(s) {
2193
2201
  (e = H.get(s)) == null || e.close(), H.delete(s);
2194
2202
  }
2195
2203
  function Qt(s) {
2196
- var he, pe, ue, fe, we;
2197
- H.has(s.el) && (H.get(s.el).close(), H.delete(s.el)), s.launcher && ((he = Z.get(ve(s))) == null || he.close());
2204
+ var pe, ue, fe, we, xe;
2205
+ H.has(s.el) && (H.get(s.el).close(), H.delete(s.el)), s.launcher && ((pe = Z.get(ke(s))) == null || pe.close());
2198
2206
  const e = $e(), t = s.token ?? s.userId ?? e, n = t !== e ? e : void 0, { wsUrl: i, httpBase: o } = He(s.url, s.apiUrl);
2199
2207
  let r = new Ct(t);
2200
- const p = s.subjectId ? `${t}::${s.subjectId}` : t, w = new At(p);
2201
- let d, v = !1, x = null, f = null;
2208
+ const h = s.subjectId ? `${t}::${s.subjectId}` : t, w = new At(h);
2209
+ let d, v = !1, x = null, u = null;
2202
2210
  !s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
2203
2211
  for (const l of w.load()) r.addOptimistic(l.clientMsgId, l.content);
2204
- let u = null, I = null, m = 0, g = !s.launcher;
2212
+ let p = null, I = null, m = 0, y = !s.launcher;
2205
2213
  if (s.launcher) {
2206
- const h = (s.position ?? "bottom-right").includes("right");
2207
- u = document.createElement("div"), u.style.cssText = `position:fixed;${h ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${h ? "flex-end" : "flex-start"};gap:12px`;
2208
- const y = document.createElement("div"), E = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, R = ($) => {
2209
- y.style.cssText = $ ? [
2214
+ const f = (s.position ?? "bottom-right").includes("right");
2215
+ p = document.createElement("div"), p.style.cssText = `position:fixed;${f ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${f ? "flex-end" : "flex-start"};gap:12px`;
2216
+ const g = document.createElement("div"), E = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, X = ($) => {
2217
+ g.style.cssText = $ ? [
2210
2218
  "position:fixed",
2211
2219
  "inset:0",
2212
2220
  "width:100%",
@@ -2229,15 +2237,15 @@ function Qt(s) {
2229
2237
  "display:none",
2230
2238
  "flex-direction:column",
2231
2239
  "background:#fff",
2232
- "transform-origin:bottom " + (h ? "right" : "left"),
2240
+ "transform-origin:bottom " + (f ? "right" : "left"),
2233
2241
  "transition:opacity .18s,transform .18s",
2234
2242
  "opacity:0",
2235
2243
  "transform:scale(.95)"
2236
2244
  ].join(";");
2237
2245
  };
2238
- R((E == null ? void 0 : E.matches) ?? !1);
2239
- const Y = ($) => R($.matches);
2240
- E == null || E.addEventListener("change", Y), x = E, f = Y, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2246
+ X((E == null ? void 0 : E.matches) ?? !1);
2247
+ const Y = ($) => X($.matches);
2248
+ E == null || E.addEventListener("change", Y), x = E, u = Y, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", g.append(s.el);
2241
2249
  const B = document.createElement("button");
2242
2250
  B.style.cssText = [
2243
2251
  "width:56px;height:56px;border-radius:50%",
@@ -2250,48 +2258,48 @@ function Qt(s) {
2250
2258
  B.style.transform = "scale(1.08)";
2251
2259
  }, B.onmouseleave = () => {
2252
2260
  B.style.transform = "scale(1)";
2253
- }, I = document.createElement("span"), I.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center", B.append(I), u.append(y, B), document.body.append(u);
2261
+ }, I = document.createElement("span"), I.style.cssText = "position:absolute;top:-4px;right:-4px;background:#ef4444;color:#fff;border-radius:50%;width:20px;height:20px;font-size:11px;font-weight:700;display:none;align-items:center;justify-content:center", B.append(I), p.append(g, B), document.body.append(p);
2254
2262
  const J = ($) => {
2255
- $ ? (y.style.display = "flex", requestAnimationFrame(() => {
2256
- y.style.opacity = "1", y.style.transform = "scale(1)";
2257
- })) : (y.style.opacity = "0", y.style.transform = "scale(.95)", setTimeout(() => {
2258
- g || (y.style.display = "none");
2263
+ $ ? (g.style.display = "flex", requestAnimationFrame(() => {
2264
+ g.style.opacity = "1", g.style.transform = "scale(1)";
2265
+ })) : (g.style.opacity = "0", g.style.transform = "scale(.95)", setTimeout(() => {
2266
+ y || (g.style.display = "none");
2259
2267
  }, 180));
2260
2268
  };
2261
2269
  B.addEventListener("click", () => {
2262
- g = !g, J(g), B.textContent = g ? "✕" : "💬", B.append(I), g && (m = 0, I && (I.style.display = "none"));
2270
+ y = !y, J(y), B.textContent = y ? "✕" : "💬", B.append(I), y && (m = 0, I && (I.style.display = "none"));
2263
2271
  }), document.addEventListener("keydown", ($) => {
2264
- $.key === "Escape" && g && (g = !1, J(!1), B.textContent = "💬", B.append(I));
2272
+ $.key === "Escape" && y && (y = !1, J(!1), B.textContent = "💬", B.append(I));
2265
2273
  });
2266
2274
  }
2267
2275
  const U = () => {
2268
- g || (m++, I && (I.textContent = String(m), I.style.display = "flex"));
2276
+ y || (m++, I && (I.textContent = String(m), I.style.display = "flex"));
2269
2277
  }, A = () => {
2270
2278
  try {
2271
- const l = new AudioContext(), h = l.createOscillator(), y = l.createGain();
2272
- h.connect(y), y.connect(l.destination), h.frequency.setValueAtTime(880, l.currentTime), h.frequency.exponentialRampToValueAtTime(440, l.currentTime + 0.15), y.gain.setValueAtTime(0.3, l.currentTime), y.gain.exponentialRampToValueAtTime(1e-3, l.currentTime + 0.3), h.start(), h.stop(l.currentTime + 0.3);
2279
+ const l = new AudioContext(), f = l.createOscillator(), g = l.createGain();
2280
+ f.connect(g), g.connect(l.destination), f.frequency.setValueAtTime(880, l.currentTime), f.frequency.exponentialRampToValueAtTime(440, l.currentTime + 0.15), g.gain.setValueAtTime(0.3, l.currentTime), g.gain.exponentialRampToValueAtTime(1e-3, l.currentTime + 0.3), f.start(), f.stop(l.currentTime + 0.3);
2273
2281
  } catch {
2274
2282
  }
2275
2283
  }, P = [], K = (l) => {
2276
2284
  for (; P.length; ) {
2277
- const h = P.shift();
2278
- w.add({ clientMsgId: h.clientMsgId, content: h.content, ts: Date.now() }), b.send({ type: "send", conversationId: l, clientMsgId: h.clientMsgId, content: h.content });
2285
+ const f = P.shift();
2286
+ w.add({ clientMsgId: f.clientMsgId, content: f.content, ts: Date.now() }), b.send({ type: "send", conversationId: l, clientMsgId: f.clientMsgId, content: f.content });
2279
2287
  }
2280
2288
  };
2281
2289
  let b;
2282
2290
  const S = new Ft(`ocw-e2e-${s.profileId}`);
2283
2291
  let M = !1;
2284
2292
  const k = [], T = [];
2285
- let W = !1;
2286
- const ne = (l, h) => {
2287
- S.sealText(h).then((y) => {
2288
- d && b.send({ type: "send", conversationId: d, clientMsgId: l, content: y });
2293
+ let V = !1;
2294
+ const ne = (l, f) => {
2295
+ S.sealText(f).then((g) => {
2296
+ d && b.send({ type: "send", conversationId: d, clientMsgId: l, content: g });
2289
2297
  });
2290
- }, Ue = (l, h, y) => {
2291
- S.sealText(h, y).then((E) => {
2298
+ }, Pe = (l, f, g) => {
2299
+ S.sealText(f, g).then((E) => {
2292
2300
  d && b.send({ type: "send", conversationId: d, clientMsgId: l, content: E });
2293
2301
  });
2294
- }, Pe = () => {
2302
+ }, Be = () => {
2295
2303
  for (; k.length; ) {
2296
2304
  const l = k.shift();
2297
2305
  ne(l.clientMsgId, l.text);
@@ -2300,37 +2308,37 @@ function Qt(s) {
2300
2308
  const l = T.shift();
2301
2309
  ne(l.clientMsgId, l.text);
2302
2310
  }
2303
- }, Be = (l) => {
2311
+ }, Ae = (l) => {
2304
2312
  b.send({ type: "fetchPrekey", targetUserId: l });
2305
- }, Ae = s.i18n ?? {}, Ke = ["ar", "he", "fa", "ur"], ze = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2306
- Ke.includes(ze) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2313
+ }, Ke = s.i18n ?? {}, ze = ["ar", "he", "fa", "ur"], Le = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2314
+ ze.includes(Le) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2307
2315
  const L = new Wt(s.el, t, {
2308
2316
  onSend(l) {
2309
- const h = `cm_${Math.random().toString(36).slice(2)}`, y = { kind: "text", text: l };
2310
- r.addOptimistic(h, y), L.render(r), r.e2e ? S.ready ? ne(h, l) : W ? T.push({ clientMsgId: h, text: l }) : (k.push({ clientMsgId: h, text: l }), r.assignedAgentId && Be(r.assignedAgentId)) : d ? (w.add({ clientMsgId: h, content: y, ts: Date.now() }), b.send({ type: "send", conversationId: d, clientMsgId: h, content: y })) : P.push({ clientMsgId: h, content: y });
2317
+ const f = `cm_${Math.random().toString(36).slice(2)}`, g = { kind: "text", text: l };
2318
+ r.addOptimistic(f, g), L.render(r), r.e2e ? S.ready ? ne(f, l) : V ? T.push({ clientMsgId: f, text: l }) : (k.push({ clientMsgId: f, text: l }), r.assignedAgentId && Ae(r.assignedAgentId)) : d ? (w.add({ clientMsgId: f, content: g, ts: Date.now() }), b.send({ type: "send", conversationId: d, clientMsgId: f, content: g })) : P.push({ clientMsgId: f, content: g });
2311
2319
  },
2312
2320
  async onAttach(l) {
2313
2321
  if (!d) return;
2314
- const h = `${o}/upload?name=${encodeURIComponent(l.name)}`, y = `cm_${Math.random().toString(36).slice(2)}`;
2315
- r.addOptimistic(y, { kind: "text", text: `📎 Uploading ${l.name}…` }), L.render(r);
2322
+ const f = `${o}/upload?name=${encodeURIComponent(l.name)}`, g = `cm_${Math.random().toString(36).slice(2)}`;
2323
+ r.addOptimistic(g, { kind: "text", text: `📎 Uploading ${l.name}…` }), L.render(r);
2316
2324
  try {
2317
- const E = await fetch(h, {
2325
+ const E = await fetch(f, {
2318
2326
  method: "POST",
2319
2327
  headers: { "content-type": l.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
2320
2328
  body: l
2321
2329
  });
2322
2330
  if (!E.ok) throw new Error(`Upload failed: ${E.status}`);
2323
- const { url: R, name: Y, mime: B, size: J } = await E.json();
2324
- b.send({ type: "send", conversationId: d, clientMsgId: y, content: { kind: "attachment", url: R, name: Y, mime: B, size: J } });
2331
+ const { url: X, name: Y, mime: B, size: J } = await E.json();
2332
+ b.send({ type: "send", conversationId: d, clientMsgId: g, content: { kind: "attachment", url: X, name: Y, mime: B, size: J } });
2325
2333
  } catch (E) {
2326
- r.addOptimistic(y, { kind: "text", text: `⚠️ Upload failed: ${E.message}` }), L.render(r);
2334
+ r.addOptimistic(g, { kind: "text", text: `⚠️ Upload failed: ${E.message}` }), L.render(r);
2327
2335
  }
2328
2336
  },
2329
- onInvoke(l, h) {
2330
- d && b.send({ type: "invoke", conversationId: d, actionId: l, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...h ? { inputs: h } : {} });
2337
+ onInvoke(l, f) {
2338
+ d && b.send({ type: "invoke", conversationId: d, actionId: l, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...f ? { inputs: f } : {} });
2331
2339
  },
2332
- onTyping(l, h) {
2333
- d && b.send({ type: "typing", conversationId: d, isTyping: l, ...h ? { preview: h } : {} });
2340
+ onTyping(l, f) {
2341
+ d && b.send({ type: "typing", conversationId: d, isTyping: l, ...f ? { preview: f } : {} });
2334
2342
  },
2335
2343
  onReadUpTo(l) {
2336
2344
  d && b.send({ type: "read", conversationId: d, seq: l });
@@ -2340,14 +2348,14 @@ function Qt(s) {
2340
2348
  const l = r.messages()[0];
2341
2349
  l && b.send({ type: "history", conversationId: d, beforeSeq: l.seq, limit: 20 });
2342
2350
  },
2343
- onEdit(l, h) {
2344
- d && b.send({ type: "edit", conversationId: d, messageId: l, content: { kind: "text", text: h } });
2351
+ onEdit(l, f) {
2352
+ d && b.send({ type: "edit", conversationId: d, messageId: l, content: { kind: "text", text: f } });
2345
2353
  },
2346
2354
  onDelete(l) {
2347
2355
  d && b.send({ type: "delete", conversationId: d, messageId: l });
2348
2356
  },
2349
- onReact(l, h, y) {
2350
- d && b.send({ type: "react", conversationId: d, messageId: l, emoji: h, remove: y });
2357
+ onReact(l, f, g) {
2358
+ d && b.send({ type: "react", conversationId: d, messageId: l, emoji: f, remove: g });
2351
2359
  },
2352
2360
  onCsat(l) {
2353
2361
  d && fetch(`${o}/conversations/${d}/csat`, {
@@ -2366,14 +2374,14 @@ function Qt(s) {
2366
2374
  ...s.translateLang ? {
2367
2375
  async onTranslate(l) {
2368
2376
  try {
2369
- const h = await fetch(`${o}/translate`, {
2377
+ const f = await fetch(`${o}/translate`, {
2370
2378
  method: "POST",
2371
2379
  headers: { "content-type": "application/json", authorization: `Bearer ${t}` },
2372
2380
  body: JSON.stringify({ text: l, targetLang: s.translateLang })
2373
2381
  });
2374
- if (!h.ok) return null;
2375
- const { translated: y } = await h.json();
2376
- return y;
2382
+ if (!f.ok) return null;
2383
+ const { translated: g } = await f.json();
2384
+ return g;
2377
2385
  } catch {
2378
2386
  return null;
2379
2387
  }
@@ -2383,56 +2391,53 @@ function Qt(s) {
2383
2391
  ...s.subject ? { subject: s.subject } : {},
2384
2392
  ...s.quickReplies ? { quickReplies: s.quickReplies } : {},
2385
2393
  ...s.accent ? { accent: s.accent } : {},
2386
- ...(pe = s.user) != null && pe.name || (ue = s.user) != null && ue.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2387
- i18n: Ae
2388
- }), Le = {
2394
+ ...(ue = s.user) != null && ue.name || (fe = s.user) != null && fe.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2395
+ i18n: Ke
2396
+ }), he = s.user && (s.user.name || s.user.email || s.user.avatar || s.user.meta) ? {
2397
+ ...s.user.name ? { name: s.user.name } : {},
2398
+ ...s.user.email ? { email: s.user.email } : {},
2399
+ ...s.user.avatar ? { avatar: s.user.avatar } : {},
2400
+ ...s.user.meta ? { meta: s.user.meta } : {}
2401
+ } : void 0, Me = {
2389
2402
  type: "open",
2390
2403
  profileId: s.profileId,
2391
2404
  ...s.subjectId ? { subjectId: s.subjectId } : {},
2392
2405
  ...n ? { linkFrom: n } : {},
2406
+ ...he ? { userInfo: he } : {},
2393
2407
  ...typeof location < "u" ? { pageUrl: location.href } : {},
2394
2408
  ...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
2395
2409
  // Pass subject display info so the server can persist it to the Subject record.
2396
2410
  // This is how listingTitle and listingMeta get saved without a separate API call.
2397
- ...(fe = s.subject) != null && fe.title ? { subjectTitle: s.subject.title } : {},
2398
- ...(we = s.subject) != null && we.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2399
- }, Me = (l) => {
2400
- const h = s.user;
2401
- if (!h || !h.name && !h.email && !h.avatar && !h.meta) return;
2402
- const y = [];
2403
- if (h.name && y.push(`Name: ${h.name}`), h.email && y.push(`Email: ${h.email}`), h.avatar && y.push(`Avatar: ${h.avatar}`), h.meta) for (const [E, R] of Object.entries(h.meta)) y.push(`${E}: ${R}`);
2404
- b.send({ type: "note", conversationId: l, clientMsgId: `ui_${Date.now()}`, text: `[User info]
2405
- ${y.join(`
2406
- `)}` });
2411
+ ...(we = s.subject) != null && we.title ? { subjectTitle: s.subject.title } : {},
2412
+ ...(xe = s.subject) != null && xe.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2407
2413
  };
2408
2414
  b = new Et({
2409
2415
  url: i,
2410
2416
  token: t,
2411
- open: Le,
2417
+ open: Me,
2412
2418
  getCursor: () => r.highestSeq(),
2413
- onStatusChange: (l, h) => L.setConnStatus(l, h),
2419
+ onStatusChange: (l, f) => L.setConnStatus(l, f),
2414
2420
  onFrame(l) {
2415
2421
  if (l.type === "opened") {
2416
- const h = d === void 0;
2417
2422
  if (d = l.conversation.id, !v) {
2418
2423
  v = !0;
2419
- for (const y of w.load())
2420
- b.send({ type: "send", conversationId: d, clientMsgId: y.clientMsgId, content: y.content });
2424
+ for (const f of w.load())
2425
+ b.send({ type: "send", conversationId: d, clientMsgId: f.clientMsgId, content: f.content });
2421
2426
  }
2422
- Re(i, t, d, r, L, o), P.length && K(d), h && l.conversation.lastSeq === 0 && Me(d);
2427
+ Re(i, t, d, r, L, o), P.length && K(d);
2423
2428
  }
2424
2429
  if (l.type === "ack" && w.remove(l.clientMsgId), l.type === "prekeyBundle") {
2425
- l.bundle && (W = !0, S.x3dhSendTo(l.bundle).then((h) => {
2426
- const y = [...k.splice(0), ...T.splice(0)];
2427
- for (const E of y) Ue(E.clientMsgId, E.text, h);
2430
+ l.bundle && (V = !0, S.x3dhSendTo(l.bundle).then((f) => {
2431
+ const g = [...k.splice(0), ...T.splice(0)];
2432
+ for (const E of g) Pe(E.clientMsgId, E.text, f);
2428
2433
  L.render(r);
2429
2434
  }));
2430
2435
  return;
2431
2436
  }
2432
2437
  if (l.type === "message" && r.e2e) {
2433
- const h = jt(l.message.content);
2434
- if (h && !S.ready) {
2435
- S.x3dhReceiveFrom(h.x3dhIK, h.x3dhEK, h.x3dhSPK).then(async () => {
2438
+ const f = jt(l.message.content);
2439
+ if (f && !S.ready) {
2440
+ S.x3dhReceiveFrom(f.x3dhIK, f.x3dhEK, f.x3dhSPK).then(async () => {
2436
2441
  await S.openFrame(l), r.apply(l), L.render(r);
2437
2442
  });
2438
2443
  return;
@@ -2440,26 +2445,26 @@ ${y.join(`
2440
2445
  }
2441
2446
  if (l.type === "peerkey") {
2442
2447
  S.onPeerKey(l.key).then(() => {
2443
- Pe(), L.render(r);
2448
+ Be(), L.render(r);
2444
2449
  });
2445
2450
  return;
2446
2451
  }
2447
2452
  (async () => {
2448
2453
  if (r.e2e && await S.openFrame(l), r.apply(l), l.type === "message" && l.message.senderId !== t && !l.message.internal && (U(), A()), r.e2e && d && !M) {
2449
2454
  M = !0;
2450
- const h = await S.initX3DH();
2451
- b.send({ type: "uploadPrekeys", ...h });
2452
- const y = await S.begin();
2453
- b.send({ type: "pubkey", conversationId: d, key: y });
2455
+ const f = await S.initX3DH();
2456
+ b.send({ type: "uploadPrekeys", ...f });
2457
+ const g = await S.begin();
2458
+ b.send({ type: "pubkey", conversationId: d, key: g });
2454
2459
  }
2455
2460
  L.render(r);
2456
2461
  })();
2457
2462
  }
2458
2463
  }), b.connect(), L.render(r);
2459
- const j = s.launcher ? ve(s) : null, X = { close: () => {
2460
- b.close(), u == null || u.remove(), L.destroy(), x && f && x.removeEventListener("change", f), H.delete(s.el), j && Z.get(j) === X && Z.delete(j);
2464
+ const F = s.launcher ? ke(s) : null, W = { close: () => {
2465
+ b.close(), p == null || p.remove(), L.destroy(), x && u && x.removeEventListener("change", u), H.delete(s.el), F && Z.get(F) === W && Z.delete(F);
2461
2466
  } };
2462
- return H.set(s.el, X), j && Z.set(j, X), X;
2467
+ return H.set(s.el, W), F && Z.set(F, W), W;
2463
2468
  }
2464
2469
  export {
2465
2470
  Ct as ChatStore,