@paramms/chat-widget 1.0.15 → 1.0.16

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
@@ -55,7 +55,7 @@ function He(s, e, t) {
55
55
  s.length > _e ? $e(s, e, t) : Me(s, e, t);
56
56
  }
57
57
  const Re = 4096;
58
- function xe(s, e, t) {
58
+ function ye(s, e, t) {
59
59
  let n = e;
60
60
  const i = n + t, o = [];
61
61
  let c = "";
@@ -85,9 +85,9 @@ function qe(s, e, t) {
85
85
  return Fe.decode(n);
86
86
  }
87
87
  function Oe(s, e, t) {
88
- return t > je ? qe(s, e, t) : xe(s, e, t);
88
+ return t > je ? qe(s, e, t) : ye(s, e, t);
89
89
  }
90
- class W {
90
+ class X {
91
91
  constructor(e, t) {
92
92
  r(this, "type");
93
93
  r(this, "data");
@@ -105,16 +105,16 @@ class z extends Error {
105
105
  });
106
106
  }
107
107
  }
108
- const j = 4294967295;
108
+ const q = 4294967295;
109
109
  function Ne(s, e, t) {
110
110
  const n = t / 4294967296, i = t;
111
111
  s.setUint32(e, n), s.setUint32(e + 4, i);
112
112
  }
113
- function ye(s, e, t) {
113
+ function ge(s, e, t) {
114
114
  const n = Math.floor(t / 4294967296), i = t;
115
115
  s.setUint32(e, n), s.setUint32(e + 4, i);
116
116
  }
117
- function ge(s, e) {
117
+ function be(s, e) {
118
118
  const t = s.getInt32(e), n = s.getUint32(e + 4);
119
119
  return t * 4294967296 + n;
120
120
  }
@@ -134,7 +134,7 @@ function Je({ sec: s, nsec: e }) {
134
134
  }
135
135
  else {
136
136
  const t = new Uint8Array(12), n = new DataView(t.buffer);
137
- return n.setUint32(0, e), ye(n, 4, s), t;
137
+ return n.setUint32(0, e), ge(n, 4, s), t;
138
138
  }
139
139
  }
140
140
  function Ge(s) {
@@ -161,7 +161,7 @@ function Ze(s) {
161
161
  return { sec: i, nsec: o };
162
162
  }
163
163
  case 12: {
164
- const t = ge(e, 4), n = e.getUint32(0);
164
+ const t = be(e, 4), n = e.getUint32(0);
165
165
  return { sec: t, nsec: n };
166
166
  }
167
167
  default:
@@ -176,7 +176,7 @@ const tt = {
176
176
  type: We,
177
177
  encode: Qe,
178
178
  decode: et
179
- }, J = class J {
179
+ }, G = class G {
180
180
  constructor() {
181
181
  // ensures ExtensionCodecType<X> matches ExtensionCodec<X>
182
182
  // this will make type errors a lot more clear
@@ -205,7 +205,7 @@ const tt = {
205
205
  const o = i(e, t);
206
206
  if (o != null) {
207
207
  const c = -1 - n;
208
- return new W(c, o);
208
+ return new X(c, o);
209
209
  }
210
210
  }
211
211
  }
@@ -215,27 +215,27 @@ const tt = {
215
215
  const o = i(e, t);
216
216
  if (o != null) {
217
217
  const c = n;
218
- return new W(c, o);
218
+ return new X(c, o);
219
219
  }
220
220
  }
221
221
  }
222
- return e instanceof W ? e : null;
222
+ return e instanceof X ? e : null;
223
223
  }
224
224
  decode(e, t, n) {
225
225
  const i = t < 0 ? this.builtInDecoders[-1 - t] : this.decoders[t];
226
- return i ? i(e, t, n) : new W(t, e);
226
+ return i ? i(e, t, n) : new X(t, e);
227
227
  }
228
228
  };
229
- r(J, "defaultCodec", new J());
230
- let X = J;
229
+ r(G, "defaultCodec", new G());
230
+ let Y = G;
231
231
  function nt(s) {
232
232
  return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
233
233
  }
234
- function ee(s) {
234
+ function te(s) {
235
235
  return s instanceof Uint8Array ? s : ArrayBuffer.isView(s) ? new Uint8Array(s.buffer, s.byteOffset, s.byteLength) : nt(s) ? new Uint8Array(s) : Uint8Array.from(s);
236
236
  }
237
237
  const it = 100, st = 2048;
238
- class ie {
238
+ class se {
239
239
  constructor(e) {
240
240
  r(this, "extensionCodec");
241
241
  r(this, "context");
@@ -250,10 +250,10 @@ class ie {
250
250
  r(this, "view");
251
251
  r(this, "bytes");
252
252
  r(this, "entered", !1);
253
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? X.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? it, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? st, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
253
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.defaultCodec, this.context = e == null ? void 0 : e.context, this.useBigInt64 = (e == null ? void 0 : e.useBigInt64) ?? !1, this.maxDepth = (e == null ? void 0 : e.maxDepth) ?? it, this.initialBufferSize = (e == null ? void 0 : e.initialBufferSize) ?? st, this.sortKeys = (e == null ? void 0 : e.sortKeys) ?? !1, this.forceFloat32 = (e == null ? void 0 : e.forceFloat32) ?? !1, this.ignoreUndefined = (e == null ? void 0 : e.ignoreUndefined) ?? !1, this.forceIntegerToFloat = (e == null ? void 0 : e.forceIntegerToFloat) ?? !1, this.pos = 0, this.view = new DataView(new ArrayBuffer(this.initialBufferSize)), this.bytes = new Uint8Array(this.view.buffer);
254
254
  }
255
255
  clone() {
256
- return new ie({
256
+ return new se({
257
257
  extensionCodec: this.extensionCodec,
258
258
  context: this.context,
259
259
  useBigInt64: this.useBigInt64,
@@ -361,7 +361,7 @@ class ie {
361
361
  this.writeU8(198), this.writeU32(t);
362
362
  else
363
363
  throw new Error(`Too large binary: ${t}`);
364
- const n = ee(e);
364
+ const n = te(e);
365
365
  this.writeU8a(n);
366
366
  }
367
367
  encodeArray(e, t) {
@@ -461,7 +461,7 @@ class ie {
461
461
  this.ensureBufferSizeToWrite(8), Ne(this.view, this.pos, e), this.pos += 8;
462
462
  }
463
463
  writeI64(e) {
464
- this.ensureBufferSizeToWrite(8), ye(this.view, this.pos, e), this.pos += 8;
464
+ this.ensureBufferSizeToWrite(8), ge(this.view, this.pos, e), this.pos += 8;
465
465
  }
466
466
  writeBigUint64(e) {
467
467
  this.ensureBufferSizeToWrite(8), this.view.setBigUint64(this.pos, e), this.pos += 8;
@@ -471,9 +471,9 @@ class ie {
471
471
  }
472
472
  }
473
473
  function ot(s, e) {
474
- return new ie(e).encodeSharedRef(s);
474
+ return new se(e).encodeSharedRef(s);
475
475
  }
476
- function Q(s) {
476
+ function Z(s) {
477
477
  return `${s < 0 ? "-" : ""}0x${Math.abs(s).toString(16).padStart(2, "0")}`;
478
478
  }
479
479
  const rt = 16, at = 16;
@@ -511,11 +511,11 @@ class ct {
511
511
  if (i != null)
512
512
  return this.hit++, i;
513
513
  this.miss++;
514
- const o = xe(e, t, n), c = Uint8Array.prototype.slice.call(e, t, t + n);
514
+ const o = ye(e, t, n), c = Uint8Array.prototype.slice.call(e, t, t + n);
515
515
  return this.store(c, o), o;
516
516
  }
517
517
  }
518
- const te = "array", O = "map_key", be = "map_value", dt = (s) => {
518
+ const ne = "array", N = "map_key", me = "map_value", dt = (s) => {
519
519
  if (typeof s == "string" || typeof s == "number")
520
520
  return s;
521
521
  throw new z("The type of key must be string or number but " + typeof s);
@@ -533,11 +533,11 @@ class lt {
533
533
  }
534
534
  pushArrayState(e) {
535
535
  const t = this.getUninitializedStateFromPool();
536
- t.type = te, t.position = 0, t.size = e, t.array = new Array(e);
536
+ t.type = ne, t.position = 0, t.size = e, t.array = new Array(e);
537
537
  }
538
538
  pushMapState(e) {
539
539
  const t = this.getUninitializedStateFromPool();
540
- t.type = O, t.readCount = 0, t.size = e, t.map = {};
540
+ t.type = N, t.readCount = 0, t.size = e, t.map = {};
541
541
  }
542
542
  getUninitializedStateFromPool() {
543
543
  if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
@@ -557,11 +557,11 @@ class lt {
557
557
  release(e) {
558
558
  if (this.stack[this.stackHeadPosition] !== e)
559
559
  throw new Error("Invalid stack state. Released state is not on top of the stack.");
560
- if (e.type === te) {
560
+ if (e.type === ne) {
561
561
  const n = e;
562
562
  n.size = 0, n.array = void 0, n.position = 0, n.type = void 0;
563
563
  }
564
- if (e.type === O || e.type === be) {
564
+ if (e.type === N || e.type === me) {
565
565
  const n = e;
566
566
  n.size = 0, n.map = void 0, n.readCount = 0, n.type = void 0;
567
567
  }
@@ -571,15 +571,15 @@ class lt {
571
571
  this.stack.length = 0, this.stackHeadPosition = -1;
572
572
  }
573
573
  }
574
- const q = -1, se = new DataView(new ArrayBuffer(0)), ht = new Uint8Array(se.buffer);
574
+ const O = -1, oe = new DataView(new ArrayBuffer(0)), ht = new Uint8Array(oe.buffer);
575
575
  try {
576
- se.getInt8(0);
576
+ oe.getInt8(0);
577
577
  } catch (s) {
578
578
  if (!(s instanceof RangeError))
579
579
  throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access");
580
580
  }
581
- const he = new RangeError("Insufficient data"), pt = new ct();
582
- class oe {
581
+ const pe = new RangeError("Insufficient data"), pt = new ct();
582
+ class re {
583
583
  constructor(e) {
584
584
  r(this, "extensionCodec");
585
585
  r(this, "context");
@@ -594,15 +594,15 @@ class oe {
594
594
  r(this, "mapKeyConverter");
595
595
  r(this, "totalPos", 0);
596
596
  r(this, "pos", 0);
597
- r(this, "view", se);
597
+ r(this, "view", oe);
598
598
  r(this, "bytes", ht);
599
- r(this, "headByte", q);
599
+ r(this, "headByte", O);
600
600
  r(this, "stack", new lt());
601
601
  r(this, "entered", !1);
602
- this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? X.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 : pt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? dt;
602
+ this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ?? Y.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 : pt, this.mapKeyConverter = (e == null ? void 0 : e.mapKeyConverter) ?? dt;
603
603
  }
604
604
  clone() {
605
- return new oe({
605
+ return new re({
606
606
  extensionCodec: this.extensionCodec,
607
607
  context: this.context,
608
608
  useBigInt64: this.useBigInt64,
@@ -616,17 +616,17 @@ class oe {
616
616
  });
617
617
  }
618
618
  reinitializeState() {
619
- this.totalPos = 0, this.headByte = q, this.stack.reset();
619
+ this.totalPos = 0, this.headByte = O, this.stack.reset();
620
620
  }
621
621
  setBuffer(e) {
622
- const t = ee(e);
622
+ const t = te(e);
623
623
  this.bytes = t, this.view = new DataView(t.buffer, t.byteOffset, t.byteLength), this.pos = 0;
624
624
  }
625
625
  appendBuffer(e) {
626
- if (this.headByte === q && !this.hasRemaining(1))
626
+ if (this.headByte === O && !this.hasRemaining(1))
627
627
  this.setBuffer(e);
628
628
  else {
629
- const t = this.bytes.subarray(this.pos), n = ee(e), i = new Uint8Array(t.length + n.length);
629
+ const t = this.bytes.subarray(this.pos), n = te(e), i = new Uint8Array(t.length + n.length);
630
630
  i.set(t), i.set(n, t.length), this.setBuffer(i);
631
631
  }
632
632
  }
@@ -690,7 +690,7 @@ class oe {
690
690
  return n;
691
691
  }
692
692
  const { headByte: i, pos: o, totalPos: c } = this;
693
- throw new RangeError(`Insufficient data in parsing ${Q(i)} at ${c} (${o} in the current buffer)`);
693
+ throw new RangeError(`Insufficient data in parsing ${Z(i)} at ${c} (${o} in the current buffer)`);
694
694
  } finally {
695
695
  this.entered = !1;
696
696
  }
@@ -845,25 +845,25 @@ class oe {
845
845
  const i = this.lookU32();
846
846
  t = this.decodeExtension(i, 4);
847
847
  } else
848
- throw new z(`Unrecognized type byte: ${Q(e)}`);
848
+ throw new z(`Unrecognized type byte: ${Z(e)}`);
849
849
  this.complete();
850
850
  const n = this.stack;
851
851
  for (; n.length > 0; ) {
852
852
  const i = n.top();
853
- if (i.type === te)
853
+ if (i.type === ne)
854
854
  if (i.array[i.position] = t, i.position++, i.position === i.size)
855
855
  t = i.array, n.release(i);
856
856
  else
857
857
  continue e;
858
- else if (i.type === O) {
858
+ else if (i.type === N) {
859
859
  if (t === "__proto__")
860
860
  throw new z("The key __proto__ is not allowed");
861
- i.key = this.mapKeyConverter(t), i.type = be;
861
+ i.key = this.mapKeyConverter(t), i.type = me;
862
862
  continue e;
863
863
  } else if (i.map[i.key] = t, i.readCount++, i.readCount === i.size)
864
864
  t = i.map, n.release(i);
865
865
  else {
866
- i.key = null, i.type = O;
866
+ i.key = null, i.type = N;
867
867
  continue e;
868
868
  }
869
869
  }
@@ -871,10 +871,10 @@ class oe {
871
871
  }
872
872
  }
873
873
  readHeadByte() {
874
- return this.headByte === q && (this.headByte = this.readU8()), this.headByte;
874
+ return this.headByte === O && (this.headByte = this.readU8()), this.headByte;
875
875
  }
876
876
  complete() {
877
- this.headByte = q;
877
+ this.headByte = O;
878
878
  }
879
879
  readArraySize() {
880
880
  const e = this.readHeadByte();
@@ -886,7 +886,7 @@ class oe {
886
886
  default: {
887
887
  if (e < 160)
888
888
  return e - 144;
889
- throw new z(`Unrecognized array type byte: ${Q(e)}`);
889
+ throw new z(`Unrecognized array type byte: ${Z(e)}`);
890
890
  }
891
891
  }
892
892
  }
@@ -911,13 +911,13 @@ class oe {
911
911
  if (e > this.maxStrLength)
912
912
  throw new z(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);
913
913
  if (this.bytes.byteLength < this.pos + t + e)
914
- throw he;
914
+ throw pe;
915
915
  const n = this.pos + t;
916
916
  let i;
917
917
  return this.stateIsMapKey() && ((o = this.keyDecoder) != null && o.canBeCached(e)) ? i = this.keyDecoder.decode(this.bytes, n, e) : i = Oe(this.bytes, n, e), this.pos += t + e, i;
918
918
  }
919
919
  stateIsMapKey() {
920
- return this.stack.length > 0 ? this.stack.top().type === O : !1;
920
+ return this.stack.length > 0 ? this.stack.top().type === N : !1;
921
921
  }
922
922
  /**
923
923
  * @throws {@link RangeError}
@@ -926,7 +926,7 @@ class oe {
926
926
  if (e > this.maxBinLength)
927
927
  throw new z(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);
928
928
  if (!this.hasRemaining(e + t))
929
- throw he;
929
+ throw pe;
930
930
  const n = this.pos + t, i = this.bytes.subarray(n, n + e);
931
931
  return this.pos += t + e, i;
932
932
  }
@@ -978,7 +978,7 @@ class oe {
978
978
  return this.pos += 8, e;
979
979
  }
980
980
  readI64() {
981
- const e = ge(this.view, this.pos);
981
+ const e = be(this.view, this.pos);
982
982
  return this.pos += 8, e;
983
983
  }
984
984
  readU64AsBigInt() {
@@ -999,7 +999,7 @@ class oe {
999
999
  }
1000
1000
  }
1001
1001
  function ut(s, e) {
1002
- return new oe(e).decode(s);
1002
+ return new re(e).decode(s);
1003
1003
  }
1004
1004
  const ft = /* @__PURE__ */ new Set([
1005
1005
  "auth",
@@ -1178,14 +1178,14 @@ class gt {
1178
1178
  this.byId.set(e.id, t ? { ...t, ...e } : e), e.seq > this._maxSeq && (this._maxSeq = e.seq), this._sorted = null;
1179
1179
  }
1180
1180
  markOwnStatus(e, t) {
1181
- const n = pe(t);
1181
+ const n = ue(t);
1182
1182
  let i = !1;
1183
1183
  for (const [o, c] of this.byId)
1184
- c.senderId !== this.me || c.seq <= 0 || c.seq > e || pe(c.status) >= n || (this.byId.set(o, { ...c, status: t }), i = !0);
1184
+ c.senderId !== this.me || c.seq <= 0 || c.seq > e || ue(c.status) >= n || (this.byId.set(o, { ...c, status: t }), i = !0);
1185
1185
  i && (this._sorted = null);
1186
1186
  }
1187
1187
  }
1188
- function pe(s) {
1188
+ function ue(s) {
1189
1189
  switch (s) {
1190
1190
  case "read":
1191
1191
  return 3;
@@ -1274,7 +1274,7 @@ class bt {
1274
1274
  function mt(s) {
1275
1275
  return new WebSocket(s);
1276
1276
  }
1277
- const ue = 200, vt = 7 * 864e5;
1277
+ const fe = 200, vt = 7 * 864e5;
1278
1278
  class kt {
1279
1279
  constructor(e) {
1280
1280
  r(this, "key");
@@ -1294,7 +1294,7 @@ class kt {
1294
1294
  add(e) {
1295
1295
  try {
1296
1296
  const t = this.load();
1297
- t.push(e), this.save(t.length > ue ? t.slice(t.length - ue) : t);
1297
+ t.push(e), this.save(t.length > fe ? t.slice(t.length - fe) : t);
1298
1298
  } catch {
1299
1299
  }
1300
1300
  }
@@ -1314,29 +1314,29 @@ class kt {
1314
1314
  }
1315
1315
  }
1316
1316
  const S = () => globalThis.crypto.subtle;
1317
- function Y(s) {
1317
+ function J(s) {
1318
1318
  const e = s instanceof Uint8Array ? s : new Uint8Array(s);
1319
1319
  let t = "";
1320
1320
  for (const n of e) t += String.fromCharCode(n);
1321
1321
  return btoa(t);
1322
1322
  }
1323
- function ne(s) {
1323
+ function ie(s) {
1324
1324
  const e = atob(s), t = new ArrayBuffer(e.length), n = new Uint8Array(t);
1325
1325
  for (let i = 0; i < e.length; i++) n[i] = e.charCodeAt(i);
1326
1326
  return n;
1327
1327
  }
1328
- async function N() {
1328
+ async function V() {
1329
1329
  const s = await S().generateKey({ name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
1330
1330
  return { publicKey: s.publicKey, privateKey: s.privateKey };
1331
1331
  }
1332
- async function H(s) {
1333
- return Y(await S().exportKey("raw", s));
1332
+ async function R(s) {
1333
+ return J(await S().exportKey("raw", s));
1334
1334
  }
1335
- async function F(s) {
1336
- return S().importKey("raw", ne(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1335
+ async function j(s) {
1336
+ return S().importKey("raw", ie(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
1337
1337
  }
1338
1338
  async function St(s, e) {
1339
- const t = await F(e);
1339
+ const t = await j(e);
1340
1340
  return S().deriveKey(
1341
1341
  { name: "ECDH", public: t },
1342
1342
  s,
@@ -1347,10 +1347,10 @@ async function St(s, e) {
1347
1347
  }
1348
1348
  async function It(s, e) {
1349
1349
  const t = globalThis.crypto.getRandomValues(new Uint8Array(12)), n = new TextEncoder().encode(e), i = await S().encrypt({ name: "AES-GCM", iv: t }, s, n);
1350
- return { ct: Y(i), iv: Y(t) };
1350
+ return { ct: J(i), iv: J(t) };
1351
1351
  }
1352
1352
  async function Ct(s, e, t) {
1353
- const n = await S().decrypt({ name: "AES-GCM", iv: ne(t) }, s, ne(e));
1353
+ const n = await S().decrypt({ name: "AES-GCM", iv: ie(t) }, s, ie(e));
1354
1354
  return new TextDecoder().decode(n);
1355
1355
  }
1356
1356
  async function Et(s) {
@@ -1363,7 +1363,7 @@ async function Et(s) {
1363
1363
  }
1364
1364
  } catch {
1365
1365
  }
1366
- const e = await N();
1366
+ const e = await V();
1367
1367
  try {
1368
1368
  const i = await S().exportKey("jwk", e.publicKey), o = await S().exportKey("jwk", e.privateKey);
1369
1369
  (n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv: o }));
@@ -1373,18 +1373,18 @@ async function Et(s) {
1373
1373
  }
1374
1374
  async function Tt(s, e) {
1375
1375
  const t = await S().exportKey("raw", e), n = await S().sign({ name: "ECDSA", hash: "SHA-256" }, s, t);
1376
- return Y(n);
1376
+ return J(n);
1377
1377
  }
1378
1378
  async function Ut() {
1379
- const s = await N(), e = await S().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1379
+ const s = await V(), e = await S().generateKey({ name: "ECDSA", namedCurve: "P-256" }, !0, ["sign", "verify"]);
1380
1380
  return {
1381
1381
  ecdhKP: s,
1382
1382
  ecdsaKP: { publicKey: e.publicKey, privateKey: e.privateKey },
1383
- publicKeyB64: await H(s.publicKey),
1384
- sigPublicKeyB64: await H(e.publicKey)
1383
+ publicKeyB64: await R(s.publicKey),
1384
+ sigPublicKeyB64: await R(e.publicKey)
1385
1385
  };
1386
1386
  }
1387
- async function fe(s) {
1387
+ async function we(s) {
1388
1388
  var t, n;
1389
1389
  try {
1390
1390
  const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(`${s}-identity`);
@@ -1393,8 +1393,8 @@ async function fe(s) {
1393
1393
  return {
1394
1394
  ecdhKP: { publicKey: c, privateKey: l },
1395
1395
  ecdsaKP: { publicKey: w, privateKey: f },
1396
- publicKeyB64: await H(c),
1397
- sigPublicKeyB64: await H(w)
1396
+ publicKeyB64: await R(c),
1397
+ sigPublicKeyB64: await R(w)
1398
1398
  };
1399
1399
  }
1400
1400
  } catch {
@@ -1408,24 +1408,24 @@ async function fe(s) {
1408
1408
  return e;
1409
1409
  }
1410
1410
  async function Pt(s, e) {
1411
- const t = await N(), n = await H(t.publicKey), i = await F(e.identityKey), o = await F(e.signedPrekey), c = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, l = await $(s.privateKey, o), w = await $(t.privateKey, i), f = await $(t.privateKey, o), b = c ? await $(t.privateKey, c) : null, x = me(l, w, f, ...b ? [b] : []);
1412
- return { sharedKey: await ve(x), ephemeralPublicKey: n };
1411
+ const t = await V(), n = await R(t.publicKey), i = await j(e.identityKey), o = await j(e.signedPrekey), c = e.oneTimePrekey ? await j(e.oneTimePrekey) : null, l = await H(s.privateKey, o), w = await H(t.privateKey, i), f = await H(t.privateKey, o), b = c ? await H(t.privateKey, c) : null, x = ve(l, w, f, ...b ? [b] : []);
1412
+ return { sharedKey: await ke(x), ephemeralPublicKey: n };
1413
1413
  }
1414
1414
  async function Bt(s, e, t, n, i) {
1415
- const o = await F(t), c = await F(n), l = await $(e.privateKey, o), w = await $(s.privateKey, c), f = await $(e.privateKey, c), b = i ? await $(i.privateKey, c) : null, x = me(l, w, f, ...b ? [b] : []);
1416
- return ve(x);
1415
+ const o = await j(t), c = await j(n), l = await H(e.privateKey, o), w = await H(s.privateKey, c), f = await H(e.privateKey, c), b = i ? await H(i.privateKey, c) : null, x = ve(l, w, f, ...b ? [b] : []);
1416
+ return ke(x);
1417
1417
  }
1418
- async function $(s, e) {
1418
+ async function H(s, e) {
1419
1419
  return S().deriveBits({ name: "ECDH", public: e }, s, 256);
1420
1420
  }
1421
- function me(...s) {
1421
+ function ve(...s) {
1422
1422
  const e = s.reduce((i, o) => i + o.byteLength, 0), t = new Uint8Array(e);
1423
1423
  let n = 0;
1424
1424
  for (const i of s)
1425
1425
  t.set(new Uint8Array(i), n), n += i.byteLength;
1426
1426
  return t.buffer;
1427
1427
  }
1428
- async function ve(s) {
1428
+ async function ke(s) {
1429
1429
  const e = await S().importKey("raw", s, "HKDF", !1, ["deriveKey"]);
1430
1430
  return S().deriveKey(
1431
1431
  { name: "HKDF", hash: "SHA-256", salt: new Uint8Array(32), info: new TextEncoder().encode("ObjectChat X3DH v1") },
@@ -1457,7 +1457,7 @@ class At {
1457
1457
  }
1458
1458
  /** Live ECDH mode: Generate/restore our keypair and return our public key to publish. */
1459
1459
  async begin() {
1460
- return this.kp = await Et(this.storageKey), H(this.kp.publicKey);
1460
+ return this.kp = await Et(this.storageKey), R(this.kp.publicKey);
1461
1461
  }
1462
1462
  /** Live ECDH mode: A peer published their key — derive the shared secret. */
1463
1463
  async onPeerKey(e) {
@@ -1467,9 +1467,9 @@ class At {
1467
1467
  /** X3DH: Generate identity key, signed prekey, and OTP prekeys.
1468
1468
  * Returns the upload frame payload the caller should send to the server. */
1469
1469
  async initX3DH() {
1470
- this.identityKP = await fe(this.storageKey), this.signedPreKP = await N(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1471
- for (let i = 0; i < Kt; i++) this.otpKeys.push(await N());
1472
- const e = await H(this.signedPreKP.publicKey), t = await Tt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => H(i.publicKey)));
1470
+ this.identityKP = await we(this.storageKey), this.signedPreKP = await V(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
1471
+ for (let i = 0; i < Kt; i++) this.otpKeys.push(await V());
1472
+ const e = await R(this.signedPreKP.publicKey), t = await Tt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => R(i.publicKey)));
1473
1473
  return {
1474
1474
  identityKey: this.identityKP.publicKeyB64,
1475
1475
  signedPrekey: e,
@@ -1481,7 +1481,7 @@ class At {
1481
1481
  /** X3DH sender: given a recipient's prekey bundle, derive the shared key and
1482
1482
  * return the init message fields to embed in the first encrypted message. */
1483
1483
  async x3dhSendTo(e) {
1484
- this.identityKP || (this.identityKP = await fe(this.storageKey));
1484
+ this.identityKP || (this.identityKP = await we(this.storageKey));
1485
1485
  const { sharedKey: t, ephemeralPublicKey: n } = await Pt(this.identityKP.ecdhKP, e);
1486
1486
  return this.x3dhShared = t, { ephemeralKey: n, spkId: e.signedPrekeyId, usedOTP: !!e.oneTimePrekey, senderIK: this.identityKP.publicKeyB64 };
1487
1487
  }
@@ -1537,7 +1537,7 @@ function zt(s) {
1537
1537
  const e = s;
1538
1538
  return !e.x3dhEK || !e.x3dhSPK || !e.x3dhIK ? null : { x3dhEK: e.x3dhEK, x3dhSPK: e.x3dhSPK, x3dhIK: e.x3dhIK };
1539
1539
  }
1540
- const we = "objectchat-widget-styles", Lt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Mt = `
1540
+ const xe = "objectchat-widget-styles", Lt = ["👍", "❤️", "😂", "😮", "😢", "🙏"], Mt = `
1541
1541
  .ocw { --ocw-accent:#f5713c; --ocw-bg:#f3efe9; --ocw-card:#fff; --ocw-line:#ececec; --ocw-ink:#1c1b1a; --ocw-mut:#9b9690;
1542
1542
  position:relative;
1543
1543
  display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
@@ -1697,9 +1697,9 @@ const we = "objectchat-widget-styles", Lt = ["👍", "❤️", "😂", "😮", "
1697
1697
  .ocw-translated-tag { font-size:10px; color:var(--ocw-mut); margin-top:2px; }
1698
1698
  `;
1699
1699
  function Dt() {
1700
- if (typeof document > "u" || document.getElementById(we)) return;
1700
+ if (typeof document > "u" || document.getElementById(xe)) return;
1701
1701
  const s = document.createElement("style");
1702
- s.id = we, s.textContent = Mt, document.head.appendChild(s);
1702
+ s.id = xe, s.textContent = Mt, document.head.appendChild(s);
1703
1703
  }
1704
1704
  function a(s, e, t) {
1705
1705
  const n = document.createElement(s);
@@ -1712,7 +1712,7 @@ function _t(s) {
1712
1712
  return "";
1713
1713
  }
1714
1714
  }
1715
- function Z(s) {
1715
+ function ee(s) {
1716
1716
  var e;
1717
1717
  switch (s.kind) {
1718
1718
  case "text":
@@ -1762,7 +1762,7 @@ class $t {
1762
1762
  r(this, "translationCache", /* @__PURE__ */ new Map());
1763
1763
  r(this, "showingTranslation", /* @__PURE__ */ new Set());
1764
1764
  r(this, "subjectBuilt", !1);
1765
- var v, m, g, I, K, P, B, T, M;
1765
+ var v, m, g, I, K, U, P, E, M;
1766
1766
  this.root = e, this.me = t, this.h = n, this.cfg = i, Dt(), e.replaceChildren(), e.classList.add("ocw"), i.accent && e.style.setProperty("--ocw-accent", i.accent);
1767
1767
  const o = a("div", "ocw-head"), c = a("div", "ocw-avatar");
1768
1768
  if ((v = i.userInfo) != null && v.avatar) {
@@ -1772,7 +1772,7 @@ class $t {
1772
1772
  c.textContent = (m = i.userInfo) != null && m.name ? i.userInfo.name[0].toUpperCase() : "🧑";
1773
1773
  o.append(c);
1774
1774
  const l = a("div", "ocw-head-main");
1775
- this.headerName = a("div", "ocw-head-name", ((g = i.subject) == null ? void 0 : g.ownerLabel) ?? ((I = i.subject) == null ? void 0 : I.title) ?? ""), l.append(this.headerName), (K = i.subject) != null && K.subtitle && l.append(a("div", "ocw-head-meta", i.subject.subtitle)), o.append(l), this.statusBadge = a("span", "ocw-badge", ((P = i.subject) == null ? void 0 : P.status) ?? ""), (B = i.subject) != null && B.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = a("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = a("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.append(this.connStatus), this.cobrowseBtn = a("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
1775
+ this.headerName = a("div", "ocw-head-name", ((g = i.subject) == null ? void 0 : g.ownerLabel) ?? ((I = i.subject) == null ? void 0 : I.title) ?? ""), l.append(this.headerName), (K = i.subject) != null && K.subtitle && l.append(a("div", "ocw-head-meta", i.subject.subtitle)), o.append(l), this.statusBadge = a("span", "ocw-badge", ((U = i.subject) == null ? void 0 : U.status) ?? ""), (P = i.subject) != null && P.status || (this.statusBadge.style.display = "none"), o.append(this.statusBadge), this.e2eBadge = a("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", o.append(this.e2eBadge), this.connStatus = a("span", "ocw-conn-status"), this.connStatus.style.display = "none", o.append(this.connStatus), this.cobrowseBtn = a("button", "ocw-menu ocw-cobrowse-btn", "🖍"), this.cobrowseBtn.title = "Shared whiteboard — draw to point things out together", this.cobrowseBtn.addEventListener("click", () => {
1776
1776
  this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
1777
1777
  }), o.append(this.cobrowseBtn), o.append(a("button", "ocw-menu", "⋯")), this.chips = a("div", "ocw-chiprow"), this.scroll = a("div", "ocw-scroll"), this.subjectCard = a("div", "ocw-subject"), this.typing = a("div", "ocw-typing");
1778
1778
  const w = a("div", "ocw-typing-bubble");
@@ -1784,7 +1784,7 @@ class $t {
1784
1784
  }), this.quick.append(A);
1785
1785
  }
1786
1786
  this.formHost = a("div", "ocw-form-host"), this.csatPanel = a("div", "ocw-csat"), this.csatPanel.style.display = "none", this.offlinePanel = a("div", "ocw-offline"), this.offlinePanel.style.display = "none", this.input = a("textarea", void 0), this.input.rows = 1, this.input.placeholder = "Message…";
1787
- const f = a("button", "ocw-sendbtn", ((T = i.i18n) == null ? void 0 : T.send) ?? "➤");
1787
+ const f = a("button", "ocw-sendbtn", ((E = i.i18n) == null ? void 0 : E.send) ?? "➤");
1788
1788
  f.addEventListener("click", () => this.flushSend()), this.input.addEventListener("keydown", (k) => {
1789
1789
  k.isComposing || k.keyCode === 229 || (k.key === "Enter" && !k.shiftKey ? (k.preventDefault(), this.flushSend()) : this.signalTyping());
1790
1790
  });
@@ -1803,15 +1803,15 @@ class $t {
1803
1803
  const A = a("button", "ocw-cobrowse-swatch");
1804
1804
  A.style.background = k, A.type = "button", k === this.cobrowseColor && A.classList.add("sel"), A.addEventListener("click", () => {
1805
1805
  this.cobrowseColor = k;
1806
- for (const G of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) G.classList.remove("sel");
1806
+ for (const Q of this.cobrowseToolbar.querySelectorAll(".ocw-cobrowse-swatch")) Q.classList.remove("sel");
1807
1807
  A.classList.add("sel");
1808
1808
  }), this.cobrowseToolbar.append(A);
1809
1809
  }
1810
- const U = a("button", "ocw-cobrowse-clear", "Clear");
1811
- U.addEventListener("click", () => {
1810
+ const T = a("button", "ocw-cobrowse-clear", "Clear");
1811
+ T.addEventListener("click", () => {
1812
1812
  var k, A;
1813
1813
  return (A = (k = this.h).onAnnotateClear) == null ? void 0 : A.call(k);
1814
- }), this.cobrowseToolbar.append(U), this.cobrowseHint = a("div", "ocw-cobrowse-hint", "🖍 Draw to point things out — visible to both sides"), e.append(this.cobrowseCanvas, this.cobrowseToolbar, this.cobrowseHint), this.bindCobrowsePointerEvents();
1814
+ }), this.cobrowseToolbar.append(T), this.cobrowseHint = a("div", "ocw-cobrowse-hint", "🖍 Draw to point things out — visible to both sides"), e.append(this.cobrowseCanvas, this.cobrowseToolbar, this.cobrowseHint), this.bindCobrowsePointerEvents();
1815
1815
  }
1816
1816
  /** Returns the scroll container so history.ts can attach scroll listeners. */
1817
1817
  getScrollEl() {
@@ -2025,7 +2025,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
2025
2025
  var x;
2026
2026
  if (e.senderRole === "system") {
2027
2027
  const h = a("div", "ocw-sys");
2028
- return h.textContent = e.deletedAt ? "message deleted" : Z(e.content), h;
2028
+ return h.textContent = e.deletedAt ? "message deleted" : ee(e.content), h;
2029
2029
  }
2030
2030
  const n = e.senderId === this.me, i = !!e.internal, o = a("div", `ocw-row ${i ? "ocw-note mine" : n ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
2031
2031
  !n && !i && o.append(a("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
@@ -2049,18 +2049,18 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
2049
2049
  } else if (e.content.kind === "appointment") {
2050
2050
  const h = e.content, u = a("div", "ocw-appt");
2051
2051
  u.append(a("div", "ocw-appt-title", `📅 ${h.title}`)), u.append(a("div", "ocw-appt-time", new Date(h.startIso).toLocaleString() + " – " + new Date(h.endIso).toLocaleTimeString())), h.location && u.append(a("div", "ocw-appt-loc", `📍 ${h.location}`)), h.description && u.append(a("div", "ocw-appt-desc", h.description));
2052
- const U = a("div", "ocw-appt-links"), v = document.createElement("a");
2052
+ const T = a("div", "ocw-appt-links"), v = document.createElement("a");
2053
2053
  v.href = h.googleUrl, v.target = "_blank", v.rel = "noopener", v.className = "ocw-appt-btn", v.textContent = "📅 Add to Google Calendar";
2054
2054
  const m = document.createElement("a");
2055
- m.href = h.icalUrl, m.download = `${h.title}.ics`, m.className = "ocw-appt-btn ocw-appt-btn-sec", m.textContent = "🍎 Apple / iCal", U.append(v, m), u.append(U), w.append(u);
2055
+ m.href = h.icalUrl, m.download = `${h.title}.ics`, m.className = "ocw-appt-btn ocw-appt-btn-sec", m.textContent = "🍎 Apple / iCal", T.append(v, m), u.append(T), w.append(u);
2056
2056
  } else
2057
- f = document.createTextNode(Z(e.content)), w.append(f), e.editedAt && w.append(a("span", "ocw-edited", "(edited)"));
2057
+ f = document.createTextNode(ee(e.content)), w.append(f), e.editedAt && w.append(a("span", "ocw-edited", "(edited)"));
2058
2058
  if (l.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && f) {
2059
2059
  const h = e.content.text;
2060
2060
  if (h.trim()) {
2061
2061
  const u = a("button", "ocw-translate-btn", "🌐");
2062
- u.type = "button", u.title = "Translate", u.addEventListener("click", (U) => {
2063
- if (U.stopPropagation(), this.showingTranslation.has(e.id)) {
2062
+ u.type = "button", u.title = "Translate", u.addEventListener("click", (T) => {
2063
+ if (T.stopPropagation(), this.showingTranslation.has(e.id)) {
2064
2064
  this.showingTranslation.delete(e.id), f.textContent = h, u.textContent = "🌐", u.title = "Translate";
2065
2065
  return;
2066
2066
  }
@@ -2085,9 +2085,9 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
2085
2085
  const h = a("div", "ocw-msg-menu");
2086
2086
  if (this.h.onEdit) {
2087
2087
  const u = a("button", void 0, "✏️");
2088
- u.title = "Edit", u.addEventListener("click", (U) => {
2089
- U.stopPropagation();
2090
- const v = Z(e.content), m = document.createElement("textarea");
2088
+ u.title = "Edit", u.addEventListener("click", (T) => {
2089
+ T.stopPropagation();
2090
+ const v = ee(e.content), m = document.createElement("textarea");
2091
2091
  m.value = v, m.rows = Math.min(4, Math.ceil(v.length / 40) + 1), m.style.cssText = "width:100%;resize:vertical;border:1px solid var(--ocw-accent);border-radius:8px;padding:6px 10px;font:inherit;font-size:14px;background:#fff;color:#1c1b1a;box-sizing:border-box";
2092
2092
  const g = a("button", "ocw-form-submit", "Save");
2093
2093
  g.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
@@ -2095,21 +2095,21 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
2095
2095
  I.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
2096
2096
  const K = a("div");
2097
2097
  K.style.cssText = "display:flex;gap:6px;justify-content:flex-end", K.append(I, g);
2098
- const P = a("div");
2099
- P.append(m, K), w.replaceChildren(P), m.focus(), m.select();
2100
- const B = () => w.replaceChildren(f ?? document.createTextNode(v));
2101
- I.addEventListener("click", B), g.addEventListener("click", () => {
2102
- const T = m.value.trim();
2103
- T && T !== v && this.h.onEdit(e.id, T), B();
2104
- }), m.addEventListener("keydown", (T) => {
2105
- T.key === "Enter" && !T.shiftKey && (T.preventDefault(), g.click()), T.key === "Escape" && B();
2098
+ const U = a("div");
2099
+ U.append(m, K), w.replaceChildren(U), m.focus(), m.select();
2100
+ const P = () => w.replaceChildren(f ?? document.createTextNode(v));
2101
+ I.addEventListener("click", P), g.addEventListener("click", () => {
2102
+ const E = m.value.trim();
2103
+ E && E !== v && this.h.onEdit(e.id, E), P();
2104
+ }), m.addEventListener("keydown", (E) => {
2105
+ E.key === "Enter" && !E.shiftKey && (E.preventDefault(), g.click()), E.key === "Escape" && P();
2106
2106
  });
2107
2107
  }), h.append(u);
2108
2108
  }
2109
2109
  if (this.h.onDelete) {
2110
2110
  const u = a("button", "del", "🗑");
2111
- u.title = "Delete", u.addEventListener("click", (U) => {
2112
- U.stopPropagation(), this.h.onDelete(e.id);
2111
+ u.title = "Delete", u.addEventListener("click", (T) => {
2112
+ T.stopPropagation(), this.h.onDelete(e.id);
2113
2113
  }), h.append(u);
2114
2114
  }
2115
2115
  l.append(h);
@@ -2120,25 +2120,25 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
2120
2120
  for (const [m, g] of Object.entries(e.reactions)) {
2121
2121
  const I = a("button", `ocw-react-pill${g.includes(this.me) ? " mine" : ""}`, `${m} ${g.length}`);
2122
2122
  I.addEventListener("click", () => {
2123
- var K, P;
2124
- return (P = (K = this.h).onReact) == null ? void 0 : P.call(K, e.id, m, g.includes(this.me));
2123
+ var K, U;
2124
+ return (U = (K = this.h).onReact) == null ? void 0 : U.call(K, e.id, m, g.includes(this.me));
2125
2125
  }), u.append(I);
2126
2126
  }
2127
- const U = a("button", "ocw-react-btn", "+"), v = a("div", "ocw-react-picker");
2127
+ const T = a("button", "ocw-react-btn", "+"), v = a("div", "ocw-react-picker");
2128
2128
  for (const m of Lt) {
2129
2129
  const g = a("button", void 0, m);
2130
2130
  g.addEventListener("click", (I) => {
2131
- var P, B, T, M;
2131
+ var U, P, E, M;
2132
2132
  I.stopPropagation();
2133
- const K = (B = (P = e.reactions) == null ? void 0 : P[m]) == null ? void 0 : B.includes(this.me);
2134
- (M = (T = this.h).onReact) == null || M.call(T, e.id, m, !!K), v.style.display = "none";
2133
+ const K = (P = (U = e.reactions) == null ? void 0 : U[m]) == null ? void 0 : P.includes(this.me);
2134
+ (M = (E = this.h).onReact) == null || M.call(E, e.id, m, !!K), v.style.display = "none";
2135
2135
  }), v.append(g);
2136
2136
  }
2137
- v.style.display = "none", U.addEventListener("click", (m) => {
2137
+ v.style.display = "none", T.addEventListener("click", (m) => {
2138
2138
  m.stopPropagation(), v.style.display = v.style.display === "none" ? "flex" : "none";
2139
2139
  }), document.addEventListener("click", () => {
2140
2140
  v.style.display = "none";
2141
- }, { once: !0 }), u.append(U), h.append(u, v), c.append(h);
2141
+ }, { once: !0 }), u.append(T), h.append(u, v), c.append(h);
2142
2142
  } else e.reactions && Object.keys(e.reactions).length && c.append(a("div", "ocw-react", Object.entries(e.reactions).map(([h, u]) => `${h}${u.length}`).join(" ")));
2143
2143
  const b = a("div", "ocw-time ocw-meta", _t(e.ts));
2144
2144
  if (n && e.status) {
@@ -2160,14 +2160,14 @@ function Ht(s) {
2160
2160
  return "🕓";
2161
2161
  }
2162
2162
  }
2163
- const R = /* @__PURE__ */ new WeakMap();
2163
+ const F = /* @__PURE__ */ new WeakMap();
2164
2164
  function qt(s) {
2165
2165
  var e;
2166
- (e = R.get(s)) == null || e.close(), R.delete(s);
2166
+ (e = F.get(s)) == null || e.close(), F.delete(s);
2167
2167
  }
2168
2168
  function Ot(s) {
2169
- var ae, ce, de, le;
2170
- R.has(s.el) && (R.get(s.el).close(), R.delete(s.el));
2169
+ var ce, de, le, he;
2170
+ F.has(s.el) && (F.get(s.el).close(), F.delete(s.el));
2171
2171
  const e = s.token ?? Ke();
2172
2172
  let t = new gt(e);
2173
2173
  const n = s.subjectId ? `${e}::${s.subjectId}` : e, i = new kt(n);
@@ -2178,8 +2178,8 @@ function Ot(s) {
2178
2178
  if (s.launcher) {
2179
2179
  const p = (s.position ?? "bottom-right").includes("right");
2180
2180
  f = document.createElement("div"), f.style.cssText = `position:fixed;${p ? "right:20px" : "left:20px"};bottom:20px;z-index:9999;display:flex;flex-direction:column;align-items:${p ? "flex-end" : "flex-start"};gap:12px`;
2181
- const y = document.createElement("div"), E = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, D = (_) => {
2182
- y.style.cssText = _ ? [
2181
+ const y = document.createElement("div"), C = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, _ = (D) => {
2182
+ y.style.cssText = D ? [
2183
2183
  "position:fixed",
2184
2184
  "inset:0",
2185
2185
  "width:100%",
@@ -2208,36 +2208,38 @@ function Ot(s) {
2208
2208
  "transform:scale(.95)"
2209
2209
  ].join(";");
2210
2210
  };
2211
- D((E == null ? void 0 : E.matches) ?? !1), E == null || E.addEventListener("change", (_) => D(_.matches)), l = E, w = D, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2212
- const C = document.createElement("button");
2213
- C.style.cssText = [
2211
+ _((C == null ? void 0 : C.matches) ?? !1);
2212
+ const $ = (D) => _(D.matches);
2213
+ C == null || C.addEventListener("change", $), l = C, w = $, s.el.style.cssText = "width:100%;height:100%;overflow:hidden", y.append(s.el);
2214
+ const B = document.createElement("button");
2215
+ B.style.cssText = [
2214
2216
  "width:56px;height:56px;border-radius:50%",
2215
2217
  `background:${s.accent ?? "#4F63F5"}`,
2216
2218
  "color:#fff;border:none;font-size:24px;cursor:pointer",
2217
2219
  "box-shadow:0 4px 16px rgba(0,0,0,.25)",
2218
2220
  "position:relative;flex:none",
2219
2221
  "transition:transform .15s"
2220
- ].join(";"), C.textContent = "💬", C.onmouseenter = () => {
2221
- C.style.transform = "scale(1.08)";
2222
- }, C.onmouseleave = () => {
2223
- C.style.transform = "scale(1)";
2224
- }, b = document.createElement("span"), b.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", C.append(b), f.append(y, C), document.body.append(f);
2225
- const V = (_) => {
2226
- _ ? (y.style.display = "flex", requestAnimationFrame(() => {
2222
+ ].join(";"), B.textContent = "💬", B.onmouseenter = () => {
2223
+ B.style.transform = "scale(1.08)";
2224
+ }, B.onmouseleave = () => {
2225
+ B.style.transform = "scale(1)";
2226
+ }, b = document.createElement("span"), b.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(b), f.append(y, B), document.body.append(f);
2227
+ const W = (D) => {
2228
+ D ? (y.style.display = "flex", requestAnimationFrame(() => {
2227
2229
  y.style.opacity = "1", y.style.transform = "scale(1)";
2228
2230
  })) : (y.style.opacity = "0", y.style.transform = "scale(.95)", setTimeout(() => {
2229
2231
  h || (y.style.display = "none");
2230
2232
  }, 180));
2231
2233
  };
2232
- C.addEventListener("click", () => {
2233
- h = !h, V(h), C.textContent = h ? "✕" : "💬", C.append(b), h && (x = 0, b && (b.style.display = "none"));
2234
- }), document.addEventListener("keydown", (_) => {
2235
- _.key === "Escape" && h && (h = !1, V(!1), C.textContent = "💬", C.append(b));
2234
+ B.addEventListener("click", () => {
2235
+ h = !h, W(h), B.textContent = h ? "✕" : "💬", B.append(b), h && (x = 0, b && (b.style.display = "none"));
2236
+ }), document.addEventListener("keydown", (D) => {
2237
+ D.key === "Escape" && h && (h = !1, W(!1), B.textContent = "💬", B.append(b));
2236
2238
  });
2237
2239
  }
2238
2240
  const u = () => {
2239
2241
  h || (x++, b && (b.textContent = String(x), b.style.display = "flex"));
2240
- }, U = () => {
2242
+ }, T = () => {
2241
2243
  try {
2242
2244
  const d = new AudioContext(), p = d.createOscillator(), y = d.createGain();
2243
2245
  p.connect(y), y.connect(d.destination), p.frequency.setValueAtTime(880, d.currentTime), p.frequency.exponentialRampToValueAtTime(440, d.currentTime + 0.15), y.gain.setValueAtTime(0.3, d.currentTime), y.gain.exponentialRampToValueAtTime(1e-3, d.currentTime + 0.3), p.start(), p.stop(d.currentTime + 0.3);
@@ -2252,49 +2254,49 @@ function Ot(s) {
2252
2254
  let g;
2253
2255
  const I = new At(`ocw-e2e-${s.profileId}`);
2254
2256
  let K = !1;
2255
- const P = [], B = [];
2256
- let T = !1;
2257
+ const U = [], P = [];
2258
+ let E = !1;
2257
2259
  const M = (d, p) => {
2258
2260
  I.sealText(p).then((y) => {
2259
2261
  o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: y });
2260
2262
  });
2261
2263
  }, k = (d, p, y) => {
2262
- I.sealText(p, y).then((E) => {
2263
- o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: E });
2264
+ I.sealText(p, y).then((C) => {
2265
+ o && g.send({ type: "send", conversationId: o, clientMsgId: d, content: C });
2264
2266
  });
2265
2267
  }, A = () => {
2266
- for (; P.length; ) {
2267
- const d = P.shift();
2268
+ for (; U.length; ) {
2269
+ const d = U.shift();
2268
2270
  M(d.clientMsgId, d.text);
2269
2271
  }
2270
- for (; B.length; ) {
2271
- const d = B.shift();
2272
+ for (; P.length; ) {
2273
+ const d = P.shift();
2272
2274
  M(d.clientMsgId, d.text);
2273
2275
  }
2274
- }, G = (d) => {
2276
+ }, Q = (d) => {
2275
2277
  g.send({ type: "fetchPrekey", targetUserId: d });
2276
- }, ke = s.i18n ?? {}, Se = ["ar", "he", "fa", "ur"], Ie = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2277
- Se.includes(Ie) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2278
+ }, Se = s.i18n ?? {}, Ie = ["ar", "he", "fa", "ur"], Ce = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
2279
+ Ie.includes(Ce) && !s.el.dir && (s.el.dir = "rtl", s.el.style.fontFamily = s.el.style.fontFamily || "Tahoma,Arial,system-ui,sans-serif");
2278
2280
  const L = new $t(s.el, e, {
2279
2281
  onSend(d) {
2280
2282
  const p = `cm_${Math.random().toString(36).slice(2)}`, y = { kind: "text", text: d };
2281
- t.addOptimistic(p, y), L.render(t), t.e2e ? I.ready ? M(p, d) : T ? B.push({ clientMsgId: p, text: d }) : (P.push({ clientMsgId: p, text: d }), t.assignedAgentId && G(t.assignedAgentId)) : o ? (i.add({ clientMsgId: p, content: y, ts: Date.now() }), g.send({ type: "send", conversationId: o, clientMsgId: p, content: y })) : v.push({ clientMsgId: p, content: y });
2283
+ t.addOptimistic(p, y), L.render(t), t.e2e ? I.ready ? M(p, d) : E ? P.push({ clientMsgId: p, text: d }) : (U.push({ clientMsgId: p, text: d }), t.assignedAgentId && Q(t.assignedAgentId)) : o ? (i.add({ clientMsgId: p, content: y, ts: Date.now() }), g.send({ type: "send", conversationId: o, clientMsgId: p, content: y })) : v.push({ clientMsgId: p, content: y });
2282
2284
  },
2283
2285
  async onAttach(d) {
2284
2286
  if (!o) return;
2285
- const E = `${s.url.replace(/^ws/, "http").replace(/\/ws$/, "")}/upload?name=${encodeURIComponent(d.name)}`, D = `cm_${Math.random().toString(36).slice(2)}`;
2286
- t.addOptimistic(D, { kind: "text", text: `📎 Uploading ${d.name}…` }), L.render(t);
2287
+ const C = `${s.url.replace(/^ws/, "http").replace(/\/ws$/, "")}/upload?name=${encodeURIComponent(d.name)}`, _ = `cm_${Math.random().toString(36).slice(2)}`;
2288
+ t.addOptimistic(_, { kind: "text", text: `📎 Uploading ${d.name}…` }), L.render(t);
2287
2289
  try {
2288
- const C = await fetch(E, {
2290
+ const $ = await fetch(C, {
2289
2291
  method: "POST",
2290
2292
  headers: { "content-type": d.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
2291
2293
  body: d
2292
2294
  });
2293
- if (!C.ok) throw new Error(`Upload failed: ${C.status}`);
2294
- const { url: V, name: _, mime: Te, size: Ue } = await C.json();
2295
- g.send({ type: "send", conversationId: o, clientMsgId: D, content: { kind: "attachment", url: V, name: _, mime: Te, size: Ue } });
2296
- } catch (C) {
2297
- t.addOptimistic(D, { kind: "text", text: `⚠️ Upload failed: ${C.message}` }), L.render(t);
2295
+ if (!$.ok) throw new Error(`Upload failed: ${$.status}`);
2296
+ const { url: B, name: W, mime: D, size: Ue } = await $.json();
2297
+ g.send({ type: "send", conversationId: o, clientMsgId: _, content: { kind: "attachment", url: B, name: W, mime: D, size: Ue } });
2298
+ } catch ($) {
2299
+ t.addOptimistic(_, { kind: "text", text: `⚠️ Upload failed: ${$.message}` }), L.render(t);
2298
2300
  }
2299
2301
  },
2300
2302
  onInvoke(d, p) {
@@ -2346,8 +2348,8 @@ function Ot(s) {
2346
2348
  body: JSON.stringify({ text: d, targetLang: s.translateLang })
2347
2349
  });
2348
2350
  if (!y.ok) return null;
2349
- const { translated: E } = await y.json();
2350
- return E;
2351
+ const { translated: C } = await y.json();
2352
+ return C;
2351
2353
  } catch {
2352
2354
  return null;
2353
2355
  }
@@ -2357,9 +2359,9 @@ function Ot(s) {
2357
2359
  ...s.subject ? { subject: s.subject } : {},
2358
2360
  ...s.quickReplies ? { quickReplies: s.quickReplies } : {},
2359
2361
  ...s.accent ? { accent: s.accent } : {},
2360
- ...(ae = s.user) != null && ae.name || (ce = s.user) != null && ce.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2361
- i18n: ke
2362
- }), Ce = {
2362
+ ...(ce = s.user) != null && ce.name || (de = s.user) != null && de.avatar ? { userInfo: { ...s.user.name ? { name: s.user.name } : {}, ...s.user.avatar ? { avatar: s.user.avatar } : {} } } : {},
2363
+ i18n: Se
2364
+ }), Ee = {
2363
2365
  type: "open",
2364
2366
  profileId: s.profileId,
2365
2367
  ...s.subjectId ? { subjectId: s.subjectId } : {},
@@ -2367,13 +2369,13 @@ function Ot(s) {
2367
2369
  ...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
2368
2370
  // Pass subject display info so the server can persist it to the Subject record.
2369
2371
  // This is how listingTitle and listingMeta get saved without a separate API call.
2370
- ...(de = s.subject) != null && de.title ? { subjectTitle: s.subject.title } : {},
2371
- ...(le = s.subject) != null && le.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2372
- }, Ee = (d) => {
2372
+ ...(le = s.subject) != null && le.title ? { subjectTitle: s.subject.title } : {},
2373
+ ...(he = s.subject) != null && he.subtitle ? { subjectMeta: s.subject.subtitle } : {}
2374
+ }, Te = (d) => {
2373
2375
  const p = s.user;
2374
2376
  if (!p || !p.name && !p.email && !p.avatar && !p.meta) return;
2375
2377
  const y = [];
2376
- if (p.name && y.push(`Name: ${p.name}`), p.email && y.push(`Email: ${p.email}`), p.avatar && y.push(`Avatar: ${p.avatar}`), p.meta) for (const [E, D] of Object.entries(p.meta)) y.push(`${E}: ${D}`);
2378
+ if (p.name && y.push(`Name: ${p.name}`), p.email && y.push(`Email: ${p.email}`), p.avatar && y.push(`Avatar: ${p.avatar}`), p.meta) for (const [C, _] of Object.entries(p.meta)) y.push(`${C}: ${_}`);
2377
2379
  g.send({ type: "note", conversationId: d, clientMsgId: `ui_${Date.now()}`, text: `[User info]
2378
2380
  ${y.join(`
2379
2381
  `)}` });
@@ -2381,7 +2383,7 @@ ${y.join(`
2381
2383
  g = new bt({
2382
2384
  url: s.url,
2383
2385
  token: e,
2384
- open: Ce,
2386
+ open: Ee,
2385
2387
  getCursor: () => t.highestSeq(),
2386
2388
  onStatusChange: (d) => L.setConnStatus(d),
2387
2389
  onFrame(d) {
@@ -2392,12 +2394,12 @@ ${y.join(`
2392
2394
  for (const y of i.load())
2393
2395
  g.send({ type: "send", conversationId: o, clientMsgId: y.clientMsgId, content: y.content });
2394
2396
  }
2395
- Ae(s.url, e, o, t, L), v.length && m(o), p && d.conversation.lastSeq === 0 && Ee(o);
2397
+ Ae(s.url, e, o, t, L), v.length && m(o), p && d.conversation.lastSeq === 0 && Te(o);
2396
2398
  }
2397
2399
  if (d.type === "ack" && i.remove(d.clientMsgId), d.type === "prekeyBundle") {
2398
- d.bundle && (T = !0, I.x3dhSendTo(d.bundle).then((p) => {
2399
- const y = [...P.splice(0), ...B.splice(0)];
2400
- for (const E of y) k(E.clientMsgId, E.text, p);
2400
+ d.bundle && (E = !0, I.x3dhSendTo(d.bundle).then((p) => {
2401
+ const y = [...U.splice(0), ...P.splice(0)];
2402
+ for (const C of y) k(C.clientMsgId, C.text, p);
2401
2403
  L.render(t);
2402
2404
  }));
2403
2405
  return;
@@ -2418,7 +2420,7 @@ ${y.join(`
2418
2420
  return;
2419
2421
  }
2420
2422
  (async () => {
2421
- if (t.e2e && await I.openFrame(d), t.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (u(), U()), t.e2e && o && !K) {
2423
+ if (t.e2e && await I.openFrame(d), t.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (u(), T()), t.e2e && o && !K) {
2422
2424
  K = !0;
2423
2425
  const p = await I.initX3DH();
2424
2426
  g.send({ type: "uploadPrekeys", ...p });
@@ -2429,10 +2431,10 @@ ${y.join(`
2429
2431
  })();
2430
2432
  }
2431
2433
  }), g.connect(), L.render(t);
2432
- const re = { close: () => {
2433
- g.close(), f == null || f.remove(), L.destroy(), l && w && l.removeEventListener("change", (d) => w(d.matches)), R.delete(s.el);
2434
+ const ae = { close: () => {
2435
+ g.close(), f == null || f.remove(), L.destroy(), l && w && l.removeEventListener("change", w), F.delete(s.el);
2434
2436
  } };
2435
- return R.set(s.el, re), re;
2437
+ return F.set(s.el, ae), ae;
2436
2438
  }
2437
2439
  export {
2438
2440
  gt as ChatStore,