@paramms/chat-widget 1.0.15 → 1.0.17
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/chatlist.d.ts +3 -0
- package/dist/chatlist.js +35 -35
- package/dist/chatlist.js.map +1 -1
- package/dist/history.d.ts +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +570 -571
- package/dist/index.js.map +1 -1
- package/dist/protocol/entities.d.ts +8 -0
- package/dist/protocol/frames.d.ts +1 -0
- package/dist/react.d.ts +11 -4
- package/dist/react.js +195 -184
- package/dist/react.js.map +1 -1
- package/dist/uid.js +35 -35
- package/dist/uid.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var Pe = Object.defineProperty;
|
|
2
2
|
var Be = (s, e, t) => e in s ? Pe(s, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : s[e] = t;
|
|
3
|
-
var
|
|
4
|
-
import { p as Ke,
|
|
3
|
+
var a = (s, e, t) => Be(s, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { p as Ke, h as Ae, r as ze } from "./uid.js";
|
|
5
5
|
const jt = (s) => s;
|
|
6
6
|
function Le(s) {
|
|
7
7
|
const e = s.length;
|
|
@@ -13,8 +13,8 @@ function Le(s) {
|
|
|
13
13
|
t += 2;
|
|
14
14
|
else {
|
|
15
15
|
if (i >= 55296 && i <= 56319 && n < e) {
|
|
16
|
-
const
|
|
17
|
-
(
|
|
16
|
+
const r = s.charCodeAt(n);
|
|
17
|
+
(r & 64512) === 56320 && (++n, i = ((i & 1023) << 10) + (r & 1023) + 65536);
|
|
18
18
|
}
|
|
19
19
|
i & 4294901760 ? t += 4 : t += 3;
|
|
20
20
|
}
|
|
@@ -27,24 +27,24 @@ function Le(s) {
|
|
|
27
27
|
}
|
|
28
28
|
function Me(s, e, t) {
|
|
29
29
|
const n = s.length;
|
|
30
|
-
let i = t,
|
|
31
|
-
for (;
|
|
32
|
-
let
|
|
33
|
-
if (
|
|
34
|
-
if (!(
|
|
35
|
-
e[i++] =
|
|
30
|
+
let i = t, r = 0;
|
|
31
|
+
for (; r < n; ) {
|
|
32
|
+
let o = s.charCodeAt(r++);
|
|
33
|
+
if (o & 4294967168)
|
|
34
|
+
if (!(o & 4294965248))
|
|
35
|
+
e[i++] = o >> 6 & 31 | 192;
|
|
36
36
|
else {
|
|
37
|
-
if (
|
|
38
|
-
const l = s.charCodeAt(
|
|
39
|
-
(l & 64512) === 56320 && (++
|
|
37
|
+
if (o >= 55296 && o <= 56319 && r < n) {
|
|
38
|
+
const l = s.charCodeAt(r);
|
|
39
|
+
(l & 64512) === 56320 && (++r, o = ((o & 1023) << 10) + (l & 1023) + 65536);
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
o & 4294901760 ? (e[i++] = o >> 18 & 7 | 240, e[i++] = o >> 12 & 63 | 128, e[i++] = o >> 6 & 63 | 128) : (e[i++] = o >> 12 & 15 | 224, e[i++] = o >> 6 & 63 | 128);
|
|
42
42
|
}
|
|
43
43
|
else {
|
|
44
|
-
e[i++] =
|
|
44
|
+
e[i++] = o;
|
|
45
45
|
continue;
|
|
46
46
|
}
|
|
47
|
-
e[i++] =
|
|
47
|
+
e[i++] = o & 63 | 128;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
const De = new TextEncoder(), _e = 50;
|
|
@@ -55,29 +55,29 @@ 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
|
|
58
|
+
function ye(s, e, t) {
|
|
59
59
|
let n = e;
|
|
60
|
-
const i = n + t,
|
|
61
|
-
let
|
|
60
|
+
const i = n + t, r = [];
|
|
61
|
+
let o = "";
|
|
62
62
|
for (; n < i; ) {
|
|
63
63
|
const l = s[n++];
|
|
64
64
|
if (!(l & 128))
|
|
65
|
-
|
|
65
|
+
r.push(l);
|
|
66
66
|
else if ((l & 224) === 192) {
|
|
67
67
|
const w = s[n++] & 63;
|
|
68
|
-
|
|
68
|
+
r.push((l & 31) << 6 | w);
|
|
69
69
|
} else if ((l & 240) === 224) {
|
|
70
|
-
const w = s[n++] & 63,
|
|
71
|
-
|
|
70
|
+
const w = s[n++] & 63, x = s[n++] & 63;
|
|
71
|
+
r.push((l & 31) << 12 | w << 6 | x);
|
|
72
72
|
} else if ((l & 248) === 240) {
|
|
73
|
-
const w = s[n++] & 63,
|
|
74
|
-
let
|
|
75
|
-
|
|
73
|
+
const w = s[n++] & 63, x = s[n++] & 63, m = s[n++] & 63;
|
|
74
|
+
let f = (l & 7) << 18 | w << 12 | x << 6 | m;
|
|
75
|
+
f > 65535 && (f -= 65536, r.push(f >>> 10 & 1023 | 55296), f = 56320 | f & 1023), r.push(f);
|
|
76
76
|
} else
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
r.push(l);
|
|
78
|
+
r.length >= Re && (o += String.fromCharCode(...r), r.length = 0);
|
|
79
79
|
}
|
|
80
|
-
return
|
|
80
|
+
return r.length > 0 && (o += String.fromCharCode(...r)), o;
|
|
81
81
|
}
|
|
82
82
|
const Fe = new TextDecoder(), je = 200;
|
|
83
83
|
function qe(s, e, t) {
|
|
@@ -85,12 +85,12 @@ 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) :
|
|
88
|
+
return t > je ? qe(s, e, t) : ye(s, e, t);
|
|
89
89
|
}
|
|
90
|
-
class
|
|
90
|
+
class X {
|
|
91
91
|
constructor(e, t) {
|
|
92
|
-
|
|
93
|
-
|
|
92
|
+
a(this, "type");
|
|
93
|
+
a(this, "data");
|
|
94
94
|
this.type = e, this.data = t;
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -110,11 +110,11 @@ 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
|
|
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
|
|
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
|
}
|
|
@@ -129,12 +129,12 @@ function Je({ sec: s, nsec: e }) {
|
|
|
129
129
|
const t = new Uint8Array(4);
|
|
130
130
|
return new DataView(t.buffer).setUint32(0, s), t;
|
|
131
131
|
} else {
|
|
132
|
-
const t = s / 4294967296, n = s & 4294967295, i = new Uint8Array(8),
|
|
133
|
-
return
|
|
132
|
+
const t = s / 4294967296, n = s & 4294967295, i = new Uint8Array(8), r = new DataView(i.buffer);
|
|
133
|
+
return r.setUint32(0, e << 2 | t & 3), r.setUint32(4, n), i;
|
|
134
134
|
}
|
|
135
135
|
else {
|
|
136
136
|
const t = new Uint8Array(12), n = new DataView(t.buffer);
|
|
137
|
-
return n.setUint32(0, e),
|
|
137
|
+
return n.setUint32(0, e), ge(n, 4, s), t;
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
function Ge(s) {
|
|
@@ -157,11 +157,11 @@ function Ze(s) {
|
|
|
157
157
|
case 4:
|
|
158
158
|
return { sec: e.getUint32(0), nsec: 0 };
|
|
159
159
|
case 8: {
|
|
160
|
-
const t = e.getUint32(0), n = e.getUint32(4), i = (t & 3) * 4294967296 + n,
|
|
161
|
-
return { sec: i, nsec:
|
|
160
|
+
const t = e.getUint32(0), n = e.getUint32(4), i = (t & 3) * 4294967296 + n, r = t >>> 2;
|
|
161
|
+
return { sec: i, nsec: r };
|
|
162
162
|
}
|
|
163
163
|
case 12: {
|
|
164
|
-
const t =
|
|
164
|
+
const t = be(e, 4), n = e.getUint32(0);
|
|
165
165
|
return { sec: t, nsec: n };
|
|
166
166
|
}
|
|
167
167
|
default:
|
|
@@ -176,18 +176,18 @@ const tt = {
|
|
|
176
176
|
type: We,
|
|
177
177
|
encode: Qe,
|
|
178
178
|
decode: et
|
|
179
|
-
},
|
|
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
|
|
183
183
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
184
|
-
|
|
184
|
+
a(this, "__brand");
|
|
185
185
|
// built-in extensions
|
|
186
|
-
|
|
187
|
-
|
|
186
|
+
a(this, "builtInEncoders", []);
|
|
187
|
+
a(this, "builtInDecoders", []);
|
|
188
188
|
// custom extensions
|
|
189
|
-
|
|
190
|
-
|
|
189
|
+
a(this, "encoders", []);
|
|
190
|
+
a(this, "decoders", []);
|
|
191
191
|
this.register(tt);
|
|
192
192
|
}
|
|
193
193
|
register({ type: e, encode: t, decode: n }) {
|
|
@@ -202,58 +202,58 @@ const tt = {
|
|
|
202
202
|
for (let n = 0; n < this.builtInEncoders.length; n++) {
|
|
203
203
|
const i = this.builtInEncoders[n];
|
|
204
204
|
if (i != null) {
|
|
205
|
-
const
|
|
206
|
-
if (
|
|
207
|
-
const
|
|
208
|
-
return new
|
|
205
|
+
const r = i(e, t);
|
|
206
|
+
if (r != null) {
|
|
207
|
+
const o = -1 - n;
|
|
208
|
+
return new X(o, r);
|
|
209
209
|
}
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
for (let n = 0; n < this.encoders.length; n++) {
|
|
213
213
|
const i = this.encoders[n];
|
|
214
214
|
if (i != null) {
|
|
215
|
-
const
|
|
216
|
-
if (
|
|
217
|
-
const
|
|
218
|
-
return new
|
|
215
|
+
const r = i(e, t);
|
|
216
|
+
if (r != null) {
|
|
217
|
+
const o = n;
|
|
218
|
+
return new X(o, r);
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
|
-
return e instanceof
|
|
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
|
|
226
|
+
return i ? i(e, t, n) : new X(t, e);
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
|
|
230
|
-
let
|
|
229
|
+
a(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
|
|
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
|
|
238
|
+
class se {
|
|
239
239
|
constructor(e) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
240
|
+
a(this, "extensionCodec");
|
|
241
|
+
a(this, "context");
|
|
242
|
+
a(this, "useBigInt64");
|
|
243
|
+
a(this, "maxDepth");
|
|
244
|
+
a(this, "initialBufferSize");
|
|
245
|
+
a(this, "sortKeys");
|
|
246
|
+
a(this, "forceFloat32");
|
|
247
|
+
a(this, "ignoreUndefined");
|
|
248
|
+
a(this, "forceIntegerToFloat");
|
|
249
|
+
a(this, "pos");
|
|
250
|
+
a(this, "view");
|
|
251
|
+
a(this, "bytes");
|
|
252
|
+
a(this, "entered", !1);
|
|
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
|
|
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 =
|
|
364
|
+
const n = te(e);
|
|
365
365
|
this.writeU8a(n);
|
|
366
366
|
}
|
|
367
367
|
encodeArray(e, t) {
|
|
@@ -395,9 +395,9 @@ class ie {
|
|
|
395
395
|
this.writeU8(223), this.writeU32(i);
|
|
396
396
|
else
|
|
397
397
|
throw new Error(`Too large map object: ${i}`);
|
|
398
|
-
for (const
|
|
399
|
-
const
|
|
400
|
-
this.ignoreUndefined &&
|
|
398
|
+
for (const r of n) {
|
|
399
|
+
const o = e[r];
|
|
400
|
+
this.ignoreUndefined && o === void 0 || (this.encodeString(r), this.doEncode(o, t + 1));
|
|
401
401
|
}
|
|
402
402
|
}
|
|
403
403
|
encodeExtension(e) {
|
|
@@ -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),
|
|
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,19 +471,19 @@ class ie {
|
|
|
471
471
|
}
|
|
472
472
|
}
|
|
473
473
|
function ot(s, e) {
|
|
474
|
-
return new
|
|
474
|
+
return new se(e).encodeSharedRef(s);
|
|
475
475
|
}
|
|
476
|
-
function
|
|
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;
|
|
480
480
|
class ct {
|
|
481
481
|
constructor(e = rt, t = at) {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
482
|
+
a(this, "hit", 0);
|
|
483
|
+
a(this, "miss", 0);
|
|
484
|
+
a(this, "caches");
|
|
485
|
+
a(this, "maxKeyLength");
|
|
486
|
+
a(this, "maxLengthPerKey");
|
|
487
487
|
this.maxKeyLength = e, this.maxLengthPerKey = t, this.caches = [];
|
|
488
488
|
for (let n = 0; n < this.maxKeyLength; n++)
|
|
489
489
|
this.caches.push([]);
|
|
@@ -493,12 +493,12 @@ class ct {
|
|
|
493
493
|
}
|
|
494
494
|
find(e, t, n) {
|
|
495
495
|
const i = this.caches[n - 1];
|
|
496
|
-
e: for (const
|
|
497
|
-
const
|
|
496
|
+
e: for (const r of i) {
|
|
497
|
+
const o = r.bytes;
|
|
498
498
|
for (let l = 0; l < n; l++)
|
|
499
|
-
if (
|
|
499
|
+
if (o[l] !== e[t + l])
|
|
500
500
|
continue e;
|
|
501
|
-
return
|
|
501
|
+
return r.str;
|
|
502
502
|
}
|
|
503
503
|
return null;
|
|
504
504
|
}
|
|
@@ -511,19 +511,19 @@ class ct {
|
|
|
511
511
|
if (i != null)
|
|
512
512
|
return this.hit++, i;
|
|
513
513
|
this.miss++;
|
|
514
|
-
const
|
|
515
|
-
return this.store(
|
|
514
|
+
const r = ye(e, t, n), o = Uint8Array.prototype.slice.call(e, t, t + n);
|
|
515
|
+
return this.store(o, r), r;
|
|
516
516
|
}
|
|
517
517
|
}
|
|
518
|
-
const
|
|
518
|
+
const ne = "array", O = "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);
|
|
522
522
|
};
|
|
523
523
|
class lt {
|
|
524
524
|
constructor() {
|
|
525
|
-
|
|
526
|
-
|
|
525
|
+
a(this, "stack", []);
|
|
526
|
+
a(this, "stackHeadPosition", -1);
|
|
527
527
|
}
|
|
528
528
|
get length() {
|
|
529
529
|
return this.stackHeadPosition + 1;
|
|
@@ -533,7 +533,7 @@ class lt {
|
|
|
533
533
|
}
|
|
534
534
|
pushArrayState(e) {
|
|
535
535
|
const t = this.getUninitializedStateFromPool();
|
|
536
|
-
t.type =
|
|
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();
|
|
@@ -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 ===
|
|
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 ===
|
|
564
|
+
if (e.type === O || 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,38 +571,38 @@ class lt {
|
|
|
571
571
|
this.stack.length = 0, this.stackHeadPosition = -1;
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
const q = -1,
|
|
574
|
+
const q = -1, oe = new DataView(new ArrayBuffer(0)), ht = new Uint8Array(oe.buffer);
|
|
575
575
|
try {
|
|
576
|
-
|
|
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
|
|
582
|
-
class
|
|
581
|
+
const pe = new RangeError("Insufficient data"), pt = new ct();
|
|
582
|
+
class re {
|
|
583
583
|
constructor(e) {
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
this.extensionCodec = (e == null ? void 0 : e.extensionCodec) ??
|
|
584
|
+
a(this, "extensionCodec");
|
|
585
|
+
a(this, "context");
|
|
586
|
+
a(this, "useBigInt64");
|
|
587
|
+
a(this, "rawStrings");
|
|
588
|
+
a(this, "maxStrLength");
|
|
589
|
+
a(this, "maxBinLength");
|
|
590
|
+
a(this, "maxArrayLength");
|
|
591
|
+
a(this, "maxMapLength");
|
|
592
|
+
a(this, "maxExtLength");
|
|
593
|
+
a(this, "keyDecoder");
|
|
594
|
+
a(this, "mapKeyConverter");
|
|
595
|
+
a(this, "totalPos", 0);
|
|
596
|
+
a(this, "pos", 0);
|
|
597
|
+
a(this, "view", oe);
|
|
598
|
+
a(this, "bytes", ht);
|
|
599
|
+
a(this, "headByte", q);
|
|
600
|
+
a(this, "stack", new lt());
|
|
601
|
+
a(this, "entered", !1);
|
|
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) ?? 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;
|
|
603
603
|
}
|
|
604
604
|
clone() {
|
|
605
|
-
return new
|
|
605
|
+
return new re({
|
|
606
606
|
extensionCodec: this.extensionCodec,
|
|
607
607
|
context: this.context,
|
|
608
608
|
useBigInt64: this.useBigInt64,
|
|
@@ -619,14 +619,14 @@ class oe {
|
|
|
619
619
|
this.totalPos = 0, this.headByte = q, this.stack.reset();
|
|
620
620
|
}
|
|
621
621
|
setBuffer(e) {
|
|
622
|
-
const t =
|
|
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
626
|
if (this.headByte === q && !this.hasRemaining(1))
|
|
627
627
|
this.setBuffer(e);
|
|
628
628
|
else {
|
|
629
|
-
const t = this.bytes.subarray(this.pos), n =
|
|
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
|
}
|
|
@@ -689,8 +689,8 @@ class oe {
|
|
|
689
689
|
throw this.createExtraByteError(this.totalPos);
|
|
690
690
|
return n;
|
|
691
691
|
}
|
|
692
|
-
const { headByte: i, pos:
|
|
693
|
-
throw new RangeError(`Insufficient data in parsing ${
|
|
692
|
+
const { headByte: i, pos: r, totalPos: o } = this;
|
|
693
|
+
throw new RangeError(`Insufficient data in parsing ${Z(i)} at ${o} (${r} in the current buffer)`);
|
|
694
694
|
} finally {
|
|
695
695
|
this.entered = !1;
|
|
696
696
|
}
|
|
@@ -709,16 +709,16 @@ class oe {
|
|
|
709
709
|
try {
|
|
710
710
|
this.entered = !0;
|
|
711
711
|
let n = t, i = -1;
|
|
712
|
-
for await (const
|
|
712
|
+
for await (const r of e) {
|
|
713
713
|
if (t && i === 0)
|
|
714
714
|
throw this.createExtraByteError(this.totalPos);
|
|
715
|
-
this.appendBuffer(
|
|
715
|
+
this.appendBuffer(r), n && (i = this.readArraySize(), n = !1, this.complete());
|
|
716
716
|
try {
|
|
717
717
|
for (; yield this.doDecodeSync(), --i !== 0; )
|
|
718
718
|
;
|
|
719
|
-
} catch (
|
|
720
|
-
if (!(
|
|
721
|
-
throw
|
|
719
|
+
} catch (o) {
|
|
720
|
+
if (!(o instanceof RangeError))
|
|
721
|
+
throw o;
|
|
722
722
|
}
|
|
723
723
|
this.totalPos += this.pos;
|
|
724
724
|
}
|
|
@@ -845,12 +845,12 @@ 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: ${
|
|
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 ===
|
|
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
|
|
@@ -858,7 +858,7 @@ class oe {
|
|
|
858
858
|
else if (i.type === O) {
|
|
859
859
|
if (t === "__proto__")
|
|
860
860
|
throw new z("The key __proto__ is not allowed");
|
|
861
|
-
i.key = this.mapKeyConverter(t), i.type =
|
|
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);
|
|
@@ -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: ${
|
|
889
|
+
throw new z(`Unrecognized array type byte: ${Z(e)}`);
|
|
890
890
|
}
|
|
891
891
|
}
|
|
892
892
|
}
|
|
@@ -907,14 +907,14 @@ class oe {
|
|
|
907
907
|
* @throws {@link RangeError}
|
|
908
908
|
*/
|
|
909
909
|
decodeUtf8String(e, t) {
|
|
910
|
-
var
|
|
910
|
+
var r;
|
|
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
|
|
914
|
+
throw pe;
|
|
915
915
|
const n = this.pos + t;
|
|
916
916
|
let i;
|
|
917
|
-
return this.stateIsMapKey() && ((
|
|
917
|
+
return this.stateIsMapKey() && ((r = this.keyDecoder) != null && r.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
920
|
return this.stack.length > 0 ? this.stack.top().type === O : !1;
|
|
@@ -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
|
|
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 =
|
|
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
|
|
1002
|
+
return new re(e).decode(s);
|
|
1003
1003
|
}
|
|
1004
1004
|
const ft = /* @__PURE__ */ new Set([
|
|
1005
1005
|
"auth",
|
|
@@ -1035,33 +1035,33 @@ function yt(s) {
|
|
|
1035
1035
|
}
|
|
1036
1036
|
class gt {
|
|
1037
1037
|
constructor(e) {
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1038
|
+
a(this, "conversationId");
|
|
1039
|
+
a(this, "state", "");
|
|
1040
|
+
a(this, "version", 0);
|
|
1041
|
+
a(this, "hasMoreHistory", !1);
|
|
1042
|
+
a(this, "lastReadByOthers", 0);
|
|
1043
|
+
a(this, "assignedAgentId");
|
|
1044
|
+
a(this, "accent");
|
|
1045
|
+
a(this, "subject");
|
|
1046
|
+
a(this, "name");
|
|
1047
|
+
a(this, "e2e", !1);
|
|
1048
|
+
a(this, "offline", !1);
|
|
1049
|
+
a(this, "offlineMessage", "");
|
|
1050
|
+
a(this, "whiteLabel", !1);
|
|
1051
|
+
a(this, "typing", /* @__PURE__ */ new Set());
|
|
1052
|
+
a(this, "online", /* @__PURE__ */ new Set());
|
|
1053
1053
|
/** Co-browsing: shared whiteboard strokes for this conversation. */
|
|
1054
|
-
|
|
1054
|
+
a(this, "annotations", []);
|
|
1055
1055
|
/** Bumped on any annotation change so the renderer can cheaply detect updates. */
|
|
1056
|
-
|
|
1056
|
+
a(this, "annotationVersion", 0);
|
|
1057
1057
|
/** Live sentiment of the guest's latest message (agent-side only). */
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1058
|
+
a(this, "sentiment");
|
|
1059
|
+
a(this, "sentimentScore");
|
|
1060
|
+
a(this, "actions", []);
|
|
1061
|
+
a(this, "byId", /* @__PURE__ */ new Map());
|
|
1062
|
+
a(this, "keyByClient", /* @__PURE__ */ new Map());
|
|
1063
|
+
a(this, "_maxSeq", 0);
|
|
1064
|
+
a(this, "_sorted", null);
|
|
1065
1065
|
this.me = e;
|
|
1066
1066
|
}
|
|
1067
1067
|
messages() {
|
|
@@ -1106,8 +1106,8 @@ class gt {
|
|
|
1106
1106
|
const n = this.keyByClient.get(e.clientMsgId), i = n ? this.byId.get(n) : void 0;
|
|
1107
1107
|
if (i && n) {
|
|
1108
1108
|
this.byId.delete(n);
|
|
1109
|
-
const
|
|
1110
|
-
this.byId.set(e.messageId,
|
|
1109
|
+
const r = { ...i, id: e.messageId, seq: e.seq, ts: e.ts, status: "sent" };
|
|
1110
|
+
this.byId.set(e.messageId, r), this.keyByClient.set(e.clientMsgId, e.messageId), e.seq > this._maxSeq && (this._maxSeq = e.seq);
|
|
1111
1111
|
}
|
|
1112
1112
|
this._sorted = null;
|
|
1113
1113
|
return;
|
|
@@ -1131,8 +1131,8 @@ class gt {
|
|
|
1131
1131
|
case "reaction": {
|
|
1132
1132
|
const n = this.byId.get(e.messageId);
|
|
1133
1133
|
if (!n) return;
|
|
1134
|
-
const i = { ...n.reactions ?? {} },
|
|
1135
|
-
e.removed ||
|
|
1134
|
+
const i = { ...n.reactions ?? {} }, r = (i[e.emoji] ?? []).filter((o) => o !== e.by);
|
|
1135
|
+
e.removed || r.push(e.by), r.length ? i[e.emoji] = r : delete i[e.emoji], this.byId.set(e.messageId, { ...n, reactions: i }), this._sorted = null;
|
|
1136
1136
|
return;
|
|
1137
1137
|
}
|
|
1138
1138
|
case "edited": {
|
|
@@ -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 =
|
|
1181
|
+
const n = ue(t);
|
|
1182
1182
|
let i = !1;
|
|
1183
|
-
for (const [
|
|
1184
|
-
|
|
1183
|
+
for (const [r, o] of this.byId)
|
|
1184
|
+
o.senderId !== this.me || o.seq <= 0 || o.seq > e || ue(o.status) >= n || (this.byId.set(r, { ...o, status: t }), i = !0);
|
|
1185
1185
|
i && (this._sorted = null);
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
|
-
function
|
|
1188
|
+
function ue(s) {
|
|
1189
1189
|
switch (s) {
|
|
1190
1190
|
case "read":
|
|
1191
1191
|
return 3;
|
|
@@ -1199,13 +1199,13 @@ function pe(s) {
|
|
|
1199
1199
|
}
|
|
1200
1200
|
class bt {
|
|
1201
1201
|
constructor(e) {
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1202
|
+
a(this, "socket", null);
|
|
1203
|
+
a(this, "state", "idle");
|
|
1204
|
+
a(this, "authed", !1);
|
|
1205
|
+
a(this, "attempt", 0);
|
|
1206
|
+
a(this, "outbox", []);
|
|
1207
|
+
a(this, "stopped", !1);
|
|
1208
|
+
a(this, "timer", null);
|
|
1209
1209
|
this.opts = e;
|
|
1210
1210
|
}
|
|
1211
1211
|
connect() {
|
|
@@ -1215,9 +1215,9 @@ class bt {
|
|
|
1215
1215
|
const t = (this.opts.socketFactory ?? mt)(this.opts.url);
|
|
1216
1216
|
t.binaryType = "arraybuffer", this.socket = t, t.onopen = () => {
|
|
1217
1217
|
this.raw({ type: "auth", token: this.opts.token });
|
|
1218
|
-
}, t.onmessage = (
|
|
1219
|
-
const
|
|
1220
|
-
!
|
|
1218
|
+
}, t.onmessage = (r) => {
|
|
1219
|
+
const o = yt(new Uint8Array(r.data));
|
|
1220
|
+
!o || wt(o) || this.handle(o);
|
|
1221
1221
|
}, t.onclose = () => this.onClosed(), t.onerror = () => {
|
|
1222
1222
|
try {
|
|
1223
1223
|
t.close();
|
|
@@ -1274,10 +1274,10 @@ class bt {
|
|
|
1274
1274
|
function mt(s) {
|
|
1275
1275
|
return new WebSocket(s);
|
|
1276
1276
|
}
|
|
1277
|
-
const
|
|
1277
|
+
const fe = 200, vt = 7 * 864e5;
|
|
1278
1278
|
class kt {
|
|
1279
1279
|
constructor(e) {
|
|
1280
|
-
|
|
1280
|
+
a(this, "key");
|
|
1281
1281
|
this.key = `ocw_outbox_${e}`;
|
|
1282
1282
|
}
|
|
1283
1283
|
/** All pending items, oldest first, with stale (>7d) entries dropped. */
|
|
@@ -1285,7 +1285,7 @@ class kt {
|
|
|
1285
1285
|
try {
|
|
1286
1286
|
const e = localStorage.getItem(this.key);
|
|
1287
1287
|
if (!e) return [];
|
|
1288
|
-
const t = JSON.parse(e), n = Date.now() - vt, i = t.filter((
|
|
1288
|
+
const t = JSON.parse(e), n = Date.now() - vt, i = t.filter((r) => r.ts >= n);
|
|
1289
1289
|
return i.length !== t.length && this.save(i), i;
|
|
1290
1290
|
} catch {
|
|
1291
1291
|
return [];
|
|
@@ -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 >
|
|
1297
|
+
t.push(e), this.save(t.length > fe ? t.slice(t.length - fe) : t);
|
|
1298
1298
|
} catch {
|
|
1299
1299
|
}
|
|
1300
1300
|
}
|
|
@@ -1314,13 +1314,13 @@ class kt {
|
|
|
1314
1314
|
}
|
|
1315
1315
|
}
|
|
1316
1316
|
const S = () => globalThis.crypto.subtle;
|
|
1317
|
-
function
|
|
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
|
|
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;
|
|
@@ -1329,11 +1329,11 @@ async function N() {
|
|
|
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
|
|
1333
|
-
return
|
|
1332
|
+
async function _(s) {
|
|
1333
|
+
return J(await S().exportKey("raw", s));
|
|
1334
1334
|
}
|
|
1335
1335
|
async function F(s) {
|
|
1336
|
-
return S().importKey("raw",
|
|
1336
|
+
return S().importKey("raw", ie(s), { name: "ECDH", namedCurve: "P-256" }, !1, []);
|
|
1337
1337
|
}
|
|
1338
1338
|
async function St(s, e) {
|
|
1339
1339
|
const t = await F(e);
|
|
@@ -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:
|
|
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:
|
|
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) {
|
|
@@ -1358,74 +1358,74 @@ async function Et(s) {
|
|
|
1358
1358
|
try {
|
|
1359
1359
|
const i = (t = globalThis.localStorage) == null ? void 0 : t.getItem(s);
|
|
1360
1360
|
if (i) {
|
|
1361
|
-
const { pub:
|
|
1361
|
+
const { pub: r, priv: o } = JSON.parse(i), l = await S().importKey("jwk", r, { name: "ECDH", namedCurve: "P-256" }, !0, []), w = await S().importKey("jwk", o, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]);
|
|
1362
1362
|
return { publicKey: l, privateKey: w };
|
|
1363
1363
|
}
|
|
1364
1364
|
} catch {
|
|
1365
1365
|
}
|
|
1366
1366
|
const e = await N();
|
|
1367
1367
|
try {
|
|
1368
|
-
const i = await S().exportKey("jwk", e.publicKey),
|
|
1369
|
-
(n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv:
|
|
1368
|
+
const i = await S().exportKey("jwk", e.publicKey), r = await S().exportKey("jwk", e.privateKey);
|
|
1369
|
+
(n = globalThis.localStorage) == null || n.setItem(s, JSON.stringify({ pub: i, priv: r }));
|
|
1370
1370
|
} catch {
|
|
1371
1371
|
}
|
|
1372
1372
|
return e;
|
|
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
|
|
1376
|
+
return J(n);
|
|
1377
1377
|
}
|
|
1378
1378
|
async function Ut() {
|
|
1379
1379
|
const s = await N(), 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
|
|
1384
|
-
sigPublicKeyB64: await
|
|
1383
|
+
publicKeyB64: await _(s.publicKey),
|
|
1384
|
+
sigPublicKeyB64: await _(e.publicKey)
|
|
1385
1385
|
};
|
|
1386
1386
|
}
|
|
1387
|
-
async function
|
|
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`);
|
|
1391
1391
|
if (i) {
|
|
1392
|
-
const
|
|
1392
|
+
const r = JSON.parse(i), o = await S().importKey("jwk", r.ecdhPub, { name: "ECDH", namedCurve: "P-256" }, !0, []), l = await S().importKey("jwk", r.ecdhPriv, { name: "ECDH", namedCurve: "P-256" }, !0, ["deriveKey", "deriveBits"]), w = await S().importKey("jwk", r.ecdsaPub, { name: "ECDSA", namedCurve: "P-256" }, !0, ["verify"]), x = await S().importKey("jwk", r.ecdsaPriv, { name: "ECDSA", namedCurve: "P-256" }, !0, ["sign"]);
|
|
1393
1393
|
return {
|
|
1394
|
-
ecdhKP: { publicKey:
|
|
1395
|
-
ecdsaKP: { publicKey: w, privateKey:
|
|
1396
|
-
publicKeyB64: await
|
|
1397
|
-
sigPublicKeyB64: await
|
|
1394
|
+
ecdhKP: { publicKey: o, privateKey: l },
|
|
1395
|
+
ecdsaKP: { publicKey: w, privateKey: x },
|
|
1396
|
+
publicKeyB64: await _(o),
|
|
1397
|
+
sigPublicKeyB64: await _(w)
|
|
1398
1398
|
};
|
|
1399
1399
|
}
|
|
1400
1400
|
} catch {
|
|
1401
1401
|
}
|
|
1402
1402
|
const e = await Ut();
|
|
1403
1403
|
try {
|
|
1404
|
-
const i = await S().exportKey("jwk", e.ecdhKP.publicKey),
|
|
1405
|
-
(n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv:
|
|
1404
|
+
const i = await S().exportKey("jwk", e.ecdhKP.publicKey), r = await S().exportKey("jwk", e.ecdhKP.privateKey), o = await S().exportKey("jwk", e.ecdsaKP.publicKey), l = await S().exportKey("jwk", e.ecdsaKP.privateKey);
|
|
1405
|
+
(n = globalThis.localStorage) == null || n.setItem(`${s}-identity`, JSON.stringify({ ecdhPub: i, ecdhPriv: r, ecdsaPub: o, ecdsaPriv: l }));
|
|
1406
1406
|
} catch {
|
|
1407
1407
|
}
|
|
1408
1408
|
return e;
|
|
1409
1409
|
}
|
|
1410
1410
|
async function Pt(s, e) {
|
|
1411
|
-
const t = await N(), n = await
|
|
1412
|
-
return { sharedKey: await
|
|
1411
|
+
const t = await N(), n = await _(t.publicKey), i = await F(e.identityKey), r = await F(e.signedPrekey), o = e.oneTimePrekey ? await F(e.oneTimePrekey) : null, l = await D(s.privateKey, r), w = await D(t.privateKey, i), x = await D(t.privateKey, r), m = o ? await D(t.privateKey, o) : null, f = ve(l, w, x, ...m ? [m] : []);
|
|
1412
|
+
return { sharedKey: await ke(f), ephemeralPublicKey: n };
|
|
1413
1413
|
}
|
|
1414
1414
|
async function Bt(s, e, t, n, i) {
|
|
1415
|
-
const
|
|
1416
|
-
return
|
|
1415
|
+
const r = await F(t), o = await F(n), l = await D(e.privateKey, r), w = await D(s.privateKey, o), x = await D(e.privateKey, o), m = i ? await D(i.privateKey, o) : null, f = ve(l, w, x, ...m ? [m] : []);
|
|
1416
|
+
return ke(f);
|
|
1417
1417
|
}
|
|
1418
|
-
async function
|
|
1418
|
+
async function D(s, e) {
|
|
1419
1419
|
return S().deriveBits({ name: "ECDH", public: e }, s, 256);
|
|
1420
1420
|
}
|
|
1421
|
-
function
|
|
1422
|
-
const e = s.reduce((i,
|
|
1421
|
+
function ve(...s) {
|
|
1422
|
+
const e = s.reduce((i, r) => i + r.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
|
|
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") },
|
|
@@ -1439,17 +1439,17 @@ const Kt = 20;
|
|
|
1439
1439
|
class At {
|
|
1440
1440
|
constructor(e) {
|
|
1441
1441
|
// Live ECDH mode state
|
|
1442
|
-
|
|
1443
|
-
|
|
1442
|
+
a(this, "kp");
|
|
1443
|
+
a(this, "shared");
|
|
1444
1444
|
// X3DH async mode state
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1445
|
+
a(this, "identityKP");
|
|
1446
|
+
a(this, "signedPreKP");
|
|
1447
|
+
a(this, "signedPrekeyId");
|
|
1448
|
+
a(this, "otpKeys", []);
|
|
1449
1449
|
// one-time prekeys awaiting matching
|
|
1450
|
-
|
|
1450
|
+
a(this, "x3dhShared");
|
|
1451
1451
|
// Queued init messages arriving before we could derive (shouldn't happen, but safe)
|
|
1452
|
-
|
|
1452
|
+
a(this, "pendingX3DH");
|
|
1453
1453
|
this.storageKey = e;
|
|
1454
1454
|
}
|
|
1455
1455
|
get ready() {
|
|
@@ -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),
|
|
1460
|
+
return this.kp = await Et(this.storageKey), _(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
|
|
1470
|
+
this.identityKP = await we(this.storageKey), this.signedPreKP = await N(), this.signedPrekeyId = `spk-${Date.now()}-${Math.random().toString(36).slice(2)}`;
|
|
1471
1471
|
for (let i = 0; i < Kt; i++) this.otpKeys.push(await N());
|
|
1472
|
-
const e = await
|
|
1472
|
+
const e = await _(this.signedPreKP.publicKey), t = await Tt(this.identityKP.ecdsaKP.privateKey, this.signedPreKP.publicKey), n = await Promise.all(this.otpKeys.map((i) => _(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
|
|
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
|
}
|
|
@@ -1505,12 +1505,12 @@ class At {
|
|
|
1505
1505
|
async sealText(e, t) {
|
|
1506
1506
|
const n = this.x3dhShared ?? this.shared;
|
|
1507
1507
|
if (!n) throw new Error("secure channel not ready");
|
|
1508
|
-
const { ct: i, iv:
|
|
1508
|
+
const { ct: i, iv: r } = await It(n, e);
|
|
1509
1509
|
return {
|
|
1510
1510
|
kind: "text",
|
|
1511
1511
|
text: i,
|
|
1512
1512
|
enc: !0,
|
|
1513
|
-
iv:
|
|
1513
|
+
iv: r,
|
|
1514
1514
|
...t ? { x3dhEK: t.ephemeralKey, x3dhSPK: t.spkId, x3dhIK: t.senderIK } : {}
|
|
1515
1515
|
};
|
|
1516
1516
|
}
|
|
@@ -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
|
|
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,11 +1697,11 @@ 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(
|
|
1700
|
+
if (typeof document > "u" || document.getElementById(xe)) return;
|
|
1701
1701
|
const s = document.createElement("style");
|
|
1702
|
-
s.id =
|
|
1702
|
+
s.id = xe, s.textContent = Mt, document.head.appendChild(s);
|
|
1703
1703
|
}
|
|
1704
|
-
function
|
|
1704
|
+
function c(s, e, t) {
|
|
1705
1705
|
const n = document.createElement(s);
|
|
1706
1706
|
return e && (n.className = e), t !== void 0 && (n.textContent = t), n;
|
|
1707
1707
|
}
|
|
@@ -1712,7 +1712,7 @@ function _t(s) {
|
|
|
1712
1712
|
return "";
|
|
1713
1713
|
}
|
|
1714
1714
|
}
|
|
1715
|
-
function
|
|
1715
|
+
function ee(s) {
|
|
1716
1716
|
var e;
|
|
1717
1717
|
switch (s.kind) {
|
|
1718
1718
|
case "text":
|
|
@@ -1732,86 +1732,86 @@ function Z(s) {
|
|
|
1732
1732
|
class $t {
|
|
1733
1733
|
/** Last seq the guest has seen per conversationId — used to compute unread badges. */
|
|
1734
1734
|
constructor(e, t, n, i = {}) {
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1735
|
+
a(this, "scroll");
|
|
1736
|
+
a(this, "chips");
|
|
1737
|
+
a(this, "typing");
|
|
1738
|
+
a(this, "quick");
|
|
1739
|
+
a(this, "formHost");
|
|
1740
|
+
a(this, "csatPanel");
|
|
1741
|
+
a(this, "offlinePanel");
|
|
1742
|
+
a(this, "footer");
|
|
1743
|
+
a(this, "input");
|
|
1744
|
+
a(this, "subjectCard");
|
|
1745
|
+
a(this, "e2eBadge");
|
|
1746
|
+
a(this, "statusBadge");
|
|
1747
|
+
a(this, "headerName");
|
|
1748
|
+
a(this, "connStatus");
|
|
1749
|
+
a(this, "typingTimer", null);
|
|
1750
|
+
a(this, "csatSubmitted", !1);
|
|
1751
1751
|
// ── Co-browsing (shared whiteboard) ─────────────────────────────────────
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1752
|
+
a(this, "cobrowseBtn");
|
|
1753
|
+
a(this, "cobrowseCanvas");
|
|
1754
|
+
a(this, "cobrowseToolbar");
|
|
1755
|
+
a(this, "cobrowseHint");
|
|
1756
|
+
a(this, "cobrowseActive", !1);
|
|
1757
|
+
a(this, "cobrowseColor", "#f5713c");
|
|
1758
|
+
a(this, "lastAnnotationVersion", -1);
|
|
1759
|
+
a(this, "storeRef", null);
|
|
1760
|
+
a(this, "scrollCleanup", null);
|
|
1761
1761
|
// ── Live translation ──────────────────────────────────────────────────-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
var v,
|
|
1762
|
+
a(this, "translationCache", /* @__PURE__ */ new Map());
|
|
1763
|
+
a(this, "showingTranslation", /* @__PURE__ */ new Set());
|
|
1764
|
+
a(this, "subjectBuilt", !1);
|
|
1765
|
+
var v, g, U, b, I, K, 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
|
-
const
|
|
1767
|
+
const r = c("div", "ocw-head"), o = c("div", "ocw-avatar");
|
|
1768
1768
|
if ((v = i.userInfo) != null && v.avatar) {
|
|
1769
1769
|
const k = document.createElement("img");
|
|
1770
|
-
k.src = i.userInfo.avatar, k.alt = i.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover",
|
|
1770
|
+
k.src = i.userInfo.avatar, k.alt = i.userInfo.name ?? "You", k.style.cssText = "width:100%;height:100%;border-radius:50%;object-fit:cover", o.append(k);
|
|
1771
1771
|
} else
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
const l =
|
|
1775
|
-
this.headerName =
|
|
1772
|
+
o.textContent = (g = i.userInfo) != null && g.name ? i.userInfo.name[0].toUpperCase() : "🧑";
|
|
1773
|
+
r.append(o);
|
|
1774
|
+
const l = c("div", "ocw-head-main");
|
|
1775
|
+
this.headerName = c("div", "ocw-head-name", ((U = i.subject) == null ? void 0 : U.ownerLabel) ?? ((b = i.subject) == null ? void 0 : b.title) ?? ""), l.append(this.headerName), (I = i.subject) != null && I.subtitle && l.append(c("div", "ocw-head-meta", i.subject.subtitle)), r.append(l), this.statusBadge = c("span", "ocw-badge", ((K = i.subject) == null ? void 0 : K.status) ?? ""), (P = i.subject) != null && P.status || (this.statusBadge.style.display = "none"), r.append(this.statusBadge), this.e2eBadge = c("span", "ocw-e2e", "🔒 E2E"), this.e2eBadge.style.display = "none", r.append(this.e2eBadge), this.connStatus = c("span", "ocw-conn-status"), this.connStatus.style.display = "none", r.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", () => {
|
|
1776
1776
|
this.cobrowseActive = !this.cobrowseActive, this.updateCobrowseUI();
|
|
1777
|
-
}),
|
|
1778
|
-
const w =
|
|
1779
|
-
w.append(
|
|
1777
|
+
}), r.append(this.cobrowseBtn), r.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");
|
|
1778
|
+
const w = c("div", "ocw-typing-bubble");
|
|
1779
|
+
w.append(c("div", "ocw-typing-dot"), c("div", "ocw-typing-dot"), c("div", "ocw-typing-dot")), this.typing.append(c("div", "ocw-dot", "🧑"), w), this.quick = c("div", "ocw-quick");
|
|
1780
1780
|
for (const k of i.quickReplies ?? []) {
|
|
1781
|
-
const A =
|
|
1781
|
+
const A = c("button", void 0, k);
|
|
1782
1782
|
A.addEventListener("click", () => {
|
|
1783
1783
|
this.h.onSend(k), this.quick.style.display = "none";
|
|
1784
1784
|
}), this.quick.append(A);
|
|
1785
1785
|
}
|
|
1786
|
-
this.formHost =
|
|
1787
|
-
const
|
|
1788
|
-
|
|
1786
|
+
this.formHost = c("div", "ocw-form-host"), this.csatPanel = c("div", "ocw-csat"), this.csatPanel.style.display = "none", this.offlinePanel = c("div", "ocw-offline"), this.offlinePanel.style.display = "none", this.input = c("textarea", void 0), this.input.rows = 1, this.input.placeholder = "Message…";
|
|
1787
|
+
const x = c("button", "ocw-sendbtn", ((E = i.i18n) == null ? void 0 : E.send) ?? "➤");
|
|
1788
|
+
x.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
|
});
|
|
1791
|
-
const
|
|
1792
|
-
|
|
1793
|
-
const
|
|
1794
|
-
|
|
1791
|
+
const m = c("button", "ocw-attach", "📎");
|
|
1792
|
+
m.title = "Attach image or file";
|
|
1793
|
+
const f = document.createElement("input");
|
|
1794
|
+
f.type = "file", f.accept = "image/*,.pdf,.txt,.doc,.docx", f.style.display = "none", m.addEventListener("click", () => f.click()), f.addEventListener("change", () => {
|
|
1795
1795
|
var k;
|
|
1796
|
-
(k =
|
|
1796
|
+
(k = f.files) != null && k[0] && this.h.onAttach && this.h.onAttach(f.files[0]), f.value = "";
|
|
1797
1797
|
});
|
|
1798
|
-
const
|
|
1799
|
-
|
|
1800
|
-
const
|
|
1801
|
-
((M = i.i18n) == null ? void 0 : M.poweredBy) !== void 0 ?
|
|
1798
|
+
const u = c("div", "ocw-input");
|
|
1799
|
+
u.append(m, f, this.input, x);
|
|
1800
|
+
const h = c("div", "ocw-footer");
|
|
1801
|
+
((M = i.i18n) == null ? void 0 : M.poweredBy) !== void 0 ? h.textContent = i.i18n.poweredBy : h.innerHTML = 'Powered by <a href="https://relay.paramms.com" target="_blank" rel="noopener">Relay</a>', this.footer = h, e.append(r, 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");
|
|
1802
1802
|
for (const k of ["#f5713c", "#1c1b1a", "#2563eb", "#16a34a", "#dc2626"]) {
|
|
1803
|
-
const A =
|
|
1803
|
+
const A = c("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
|
|
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
|
|
1811
|
-
|
|
1810
|
+
const T = c("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(
|
|
1814
|
+
}), this.cobrowseToolbar.append(T), this.cobrowseHint = c("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() {
|
|
@@ -1841,28 +1841,28 @@ class $t {
|
|
|
1841
1841
|
this.h.onTyping(!0, e), this.typingTimer && clearTimeout(this.typingTimer), this.typingTimer = setTimeout(() => this.h.onTyping(!1), 2e3);
|
|
1842
1842
|
}
|
|
1843
1843
|
render(e) {
|
|
1844
|
-
var
|
|
1844
|
+
var x, m, f;
|
|
1845
1845
|
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) {
|
|
1846
|
-
const
|
|
1847
|
-
|
|
1846
|
+
const u = (x = this.cfg.subject) == null ? void 0 : x.ownerLabel;
|
|
1847
|
+
u && (this.headerName.textContent = u);
|
|
1848
1848
|
}
|
|
1849
1849
|
this.chips.replaceChildren();
|
|
1850
1850
|
const t = e.visibleActions();
|
|
1851
1851
|
this.chips.style.display = t.length ? "flex" : "none";
|
|
1852
|
-
for (const
|
|
1852
|
+
for (const u of t) this.chips.append(this.chipEl(u));
|
|
1853
1853
|
const n = this.scroll.scrollHeight, i = this.scroll.scrollTop;
|
|
1854
1854
|
if (this.scroll.replaceChildren(), this.subjectCard.childNodes.length && this.scroll.append(this.subjectCard), e.hasMoreHistory) {
|
|
1855
|
-
const
|
|
1856
|
-
|
|
1855
|
+
const u = c("div", "ocw-load-more");
|
|
1856
|
+
u.textContent = "↑ Loading earlier messages…", u.style.pointerEvents = "none", this.scroll.append(u);
|
|
1857
1857
|
}
|
|
1858
|
-
let
|
|
1859
|
-
for (const
|
|
1860
|
-
this.scroll.append(this.messageEl(
|
|
1861
|
-
i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - n + i : this.scroll.scrollTop = this.scroll.scrollHeight,
|
|
1862
|
-
const
|
|
1863
|
-
this.typing.classList.toggle("active",
|
|
1858
|
+
let r = 0;
|
|
1859
|
+
for (const u of e.messages())
|
|
1860
|
+
this.scroll.append(this.messageEl(u, e)), u.senderId !== this.me && u.seq > r && (r = u.seq);
|
|
1861
|
+
i > 20 ? this.scroll.scrollTop = this.scroll.scrollHeight - n + i : this.scroll.scrollTop = this.scroll.scrollHeight, r > 0 && this.h.onReadUpTo(r);
|
|
1862
|
+
const o = [...e.typing];
|
|
1863
|
+
this.typing.classList.toggle("active", o.length > 0);
|
|
1864
1864
|
const l = this.typing.querySelector(".ocw-typing-bubble");
|
|
1865
|
-
l && l.setAttribute("aria-label",
|
|
1865
|
+
l && l.setAttribute("aria-label", o.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", (m = this.root.querySelector(".ocw-input")) == null || m.style.setProperty("display", "none")) : (this.offlinePanel.style.display = "none", (f = this.root.querySelector(".ocw-input")) == null || f.style.removeProperty("display"));
|
|
1866
1866
|
const w = ["resolved", "closed", "sold", "issued", "checked_out"];
|
|
1867
1867
|
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");
|
|
1868
1868
|
}
|
|
@@ -1875,29 +1875,29 @@ class $t {
|
|
|
1875
1875
|
}
|
|
1876
1876
|
buildOfflinePanel(e) {
|
|
1877
1877
|
var l;
|
|
1878
|
-
this.offlinePanel.replaceChildren(), this.offlinePanel.append(
|
|
1879
|
-
const t =
|
|
1878
|
+
this.offlinePanel.replaceChildren(), this.offlinePanel.append(c("div", "ocw-offline-icon", "🌙")), this.offlinePanel.append(c("div", "ocw-offline-title", ((l = this.cfg.i18n) == null ? void 0 : l.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."));
|
|
1879
|
+
const t = c("div", "ocw-offline-form"), n = c("input", "ocw-offline-input");
|
|
1880
1880
|
n.placeholder = "Your name", n.type = "text";
|
|
1881
|
-
const i =
|
|
1881
|
+
const i = c("input", "ocw-offline-input");
|
|
1882
1882
|
i.placeholder = "Your email", i.type = "email";
|
|
1883
|
-
const
|
|
1884
|
-
|
|
1885
|
-
const
|
|
1886
|
-
|
|
1887
|
-
!i.value.trim() || !
|
|
1883
|
+
const r = c("textarea", "ocw-offline-input");
|
|
1884
|
+
r.placeholder = "Your message", r.rows = 3;
|
|
1885
|
+
const o = c("button", "ocw-offline-submit", "Send message");
|
|
1886
|
+
o.addEventListener("click", () => {
|
|
1887
|
+
!i.value.trim() || !r.value.trim() || (this.h.onSend(`[Offline form]
|
|
1888
1888
|
Name: ${n.value || "Anonymous"}
|
|
1889
1889
|
Email: ${i.value}
|
|
1890
|
-
Message: ${
|
|
1891
|
-
}), t.append(n, i,
|
|
1890
|
+
Message: ${r.value}`), this.offlinePanel.replaceChildren(c("div", "ocw-offline-thanks", "✓ Message sent! We'll reply to your email.")));
|
|
1891
|
+
}), t.append(n, i, r, o), this.offlinePanel.append(t);
|
|
1892
1892
|
}
|
|
1893
1893
|
buildCsatPanel() {
|
|
1894
|
-
this.csatPanel.replaceChildren(), this.csatPanel.append(
|
|
1895
|
-
const e =
|
|
1894
|
+
this.csatPanel.replaceChildren(), this.csatPanel.append(c("div", "ocw-csat-title", "How did we do?"));
|
|
1895
|
+
const e = c("div", "ocw-csat-stars"), t = [];
|
|
1896
1896
|
for (let n = 1; n <= 5; n++) {
|
|
1897
|
-
const i =
|
|
1898
|
-
i.dataset.score = String(n), i.addEventListener("mouseenter", () => t.forEach((
|
|
1899
|
-
var
|
|
1900
|
-
this.csatSubmitted = !0, this.csatPanel.replaceChildren(
|
|
1897
|
+
const i = c("button", "ocw-csat-star", "★");
|
|
1898
|
+
i.dataset.score = String(n), i.addEventListener("mouseenter", () => t.forEach((r, o) => r.classList.toggle("lit", o < n))), i.addEventListener("mouseleave", () => t.forEach((r) => r.classList.remove("lit"))), i.addEventListener("click", () => {
|
|
1899
|
+
var r, o;
|
|
1900
|
+
this.csatSubmitted = !0, this.csatPanel.replaceChildren(c("div", "ocw-csat-done", `Thanks for your ${n}★ rating!`)), (o = (r = this.h).onCsat) == null || o.call(r, n);
|
|
1901
1901
|
}), t.push(i), e.append(i);
|
|
1902
1902
|
}
|
|
1903
1903
|
this.csatPanel.append(e);
|
|
@@ -1918,7 +1918,7 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
|
|
|
1918
1918
|
if (!t || e.points.length < 2) return;
|
|
1919
1919
|
const n = this.cobrowseCanvas.width, i = this.cobrowseCanvas.height;
|
|
1920
1920
|
t.strokeStyle = e.color, t.lineWidth = Math.max(1, e.width * Math.min(n, i)), t.lineJoin = "round", t.lineCap = "round", t.beginPath(), t.moveTo(e.points[0].x * n, e.points[0].y * i);
|
|
1921
|
-
for (const
|
|
1921
|
+
for (const r of e.points.slice(1)) t.lineTo(r.x * n, r.y * i);
|
|
1922
1922
|
t.stroke();
|
|
1923
1923
|
}
|
|
1924
1924
|
redrawCobrowse() {
|
|
@@ -1931,41 +1931,41 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
|
|
|
1931
1931
|
}
|
|
1932
1932
|
bindCobrowsePointerEvents() {
|
|
1933
1933
|
let e = !1, t = [];
|
|
1934
|
-
const n = (
|
|
1935
|
-
const l = this.cobrowseCanvas.getBoundingClientRect(), w = l.width > 0 ? (
|
|
1936
|
-
return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0,
|
|
1934
|
+
const n = (o) => {
|
|
1935
|
+
const l = this.cobrowseCanvas.getBoundingClientRect(), w = l.width > 0 ? (o.clientX - l.left) / l.width : 0, x = l.height > 0 ? (o.clientY - l.top) / l.height : 0;
|
|
1936
|
+
return { x: Math.min(1, Math.max(0, w)), y: Math.min(1, Math.max(0, x)) };
|
|
1937
1937
|
}, i = 6e-3;
|
|
1938
|
-
this.cobrowseCanvas.addEventListener("pointerdown", (
|
|
1939
|
-
this.cobrowseActive && (e = !0, t = [n(
|
|
1940
|
-
}), this.cobrowseCanvas.addEventListener("pointermove", (
|
|
1941
|
-
e && (t.push(n(
|
|
1938
|
+
this.cobrowseCanvas.addEventListener("pointerdown", (o) => {
|
|
1939
|
+
this.cobrowseActive && (e = !0, t = [n(o)], this.cobrowseCanvas.setPointerCapture(o.pointerId));
|
|
1940
|
+
}), this.cobrowseCanvas.addEventListener("pointermove", (o) => {
|
|
1941
|
+
e && (t.push(n(o)), this.redrawCobrowse(), this.drawStroke({ points: t, color: this.cobrowseColor, width: i }));
|
|
1942
1942
|
});
|
|
1943
|
-
const
|
|
1943
|
+
const r = (o) => {
|
|
1944
1944
|
var l, w;
|
|
1945
1945
|
if (e) {
|
|
1946
1946
|
e = !1, t.length > 1 && ((w = (l = this.h).onAnnotate) == null || w.call(l, { id: `an_${Date.now()}_${Math.random().toString(36).slice(2)}`, points: t, color: this.cobrowseColor, width: i })), t = [];
|
|
1947
1947
|
try {
|
|
1948
|
-
this.cobrowseCanvas.releasePointerCapture(
|
|
1948
|
+
this.cobrowseCanvas.releasePointerCapture(o.pointerId);
|
|
1949
1949
|
} catch {
|
|
1950
1950
|
}
|
|
1951
1951
|
}
|
|
1952
1952
|
};
|
|
1953
|
-
this.cobrowseCanvas.addEventListener("pointerup",
|
|
1953
|
+
this.cobrowseCanvas.addEventListener("pointerup", r), this.cobrowseCanvas.addEventListener("pointercancel", r);
|
|
1954
1954
|
}
|
|
1955
1955
|
buildSubjectCard(e) {
|
|
1956
1956
|
if (this.subjectBuilt) return;
|
|
1957
1957
|
const t = e.subject, n = this.cfg.subject, i = (t == null ? void 0 : t.title) ?? (n == null ? void 0 : n.title);
|
|
1958
1958
|
if (!i) return;
|
|
1959
|
-
this.subjectBuilt = !0, this.subjectCard.replaceChildren(), this.subjectCard.append(
|
|
1960
|
-
const
|
|
1961
|
-
if (t) for (const [l, w] of Object.entries(t.fields))
|
|
1962
|
-
else for (const l of (n == null ? void 0 : n.tags) ?? [])
|
|
1963
|
-
|
|
1964
|
-
const
|
|
1965
|
-
|
|
1959
|
+
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));
|
|
1960
|
+
const r = c("div", "ocw-tags");
|
|
1961
|
+
if (t) for (const [l, w] of Object.entries(t.fields)) r.append(c("span", "ocw-tag", `${l}: ${w}`));
|
|
1962
|
+
else for (const l of (n == null ? void 0 : n.tags) ?? []) r.append(c("span", "ocw-tag", l));
|
|
1963
|
+
r.childNodes.length && this.subjectCard.append(r);
|
|
1964
|
+
const o = (t == null ? void 0 : t.state) ?? (n == null ? void 0 : n.status);
|
|
1965
|
+
o && (this.statusBadge.textContent = o, this.statusBadge.style.display = "inline-flex");
|
|
1966
1966
|
}
|
|
1967
1967
|
chipEl(e) {
|
|
1968
|
-
const t =
|
|
1968
|
+
const t = c("button", "ocw-chip", e.icon ? `${e.icon} ${e.label}` : e.label);
|
|
1969
1969
|
return t.dataset.actionId = e.id, t.addEventListener("click", async () => {
|
|
1970
1970
|
var n;
|
|
1971
1971
|
e.confirm && !await this.confirm(e.label) || ((n = e.input) != null && n.length ? this.openForm(e) : this.h.onInvoke(e.id));
|
|
@@ -1974,14 +1974,14 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
|
|
|
1974
1974
|
/** In-widget confirmation modal (replaces window.confirm). */
|
|
1975
1975
|
confirm(e) {
|
|
1976
1976
|
return new Promise((t) => {
|
|
1977
|
-
const n =
|
|
1978
|
-
i.append(
|
|
1979
|
-
const
|
|
1980
|
-
n.remove(), t(
|
|
1977
|
+
const n = c("div", "ocw-modal"), i = c("div", "ocw-modal-card");
|
|
1978
|
+
i.append(c("div", "ocw-modal-title", e)), i.append(c("div", "ocw-modal-body", `Confirm “${e}”?`));
|
|
1979
|
+
const r = c("div", "ocw-modal-actions"), o = c("button", "ocw-modal-cancel", "Cancel"), l = c("button", "ocw-modal-ok", "Confirm"), w = (x) => {
|
|
1980
|
+
n.remove(), t(x);
|
|
1981
1981
|
};
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
}),
|
|
1982
|
+
o.addEventListener("click", () => w(!1)), l.addEventListener("click", () => w(!0)), n.addEventListener("click", (x) => {
|
|
1983
|
+
x.target === n && w(!1);
|
|
1984
|
+
}), r.append(o, l), i.append(r), n.append(i), this.root.append(n), l.focus();
|
|
1985
1985
|
});
|
|
1986
1986
|
}
|
|
1987
1987
|
/** Inline form for a form-effect action: typed inputs (date picker, number,
|
|
@@ -1989,163 +1989,163 @@ Message: ${o.value}`), this.offlinePanel.replaceChildren(a("div", "ocw-offline-t
|
|
|
1989
1989
|
openForm(e) {
|
|
1990
1990
|
var l, w;
|
|
1991
1991
|
this.formHost.replaceChildren();
|
|
1992
|
-
const t =
|
|
1993
|
-
t.append(
|
|
1992
|
+
const t = c("div", "ocw-form");
|
|
1993
|
+
t.append(c("div", "ocw-form-title", e.icon ? `${e.icon} ${e.label}` : e.label));
|
|
1994
1994
|
const n = /* @__PURE__ */ new Map();
|
|
1995
|
-
for (const
|
|
1996
|
-
const
|
|
1997
|
-
if (
|
|
1998
|
-
const
|
|
1999
|
-
|
|
2000
|
-
for (const
|
|
2001
|
-
const
|
|
2002
|
-
|
|
1995
|
+
for (const x of e.input ?? []) {
|
|
1996
|
+
const m = c("label", "ocw-form-row");
|
|
1997
|
+
if (m.append(c("span", "ocw-form-lbl", x.label)), x.type === "select" && ((l = x.options) != null && l.length)) {
|
|
1998
|
+
const f = c("select", "ocw-form-input");
|
|
1999
|
+
x.required || f.append(c("option", void 0, "— select —"));
|
|
2000
|
+
for (const u of x.options) {
|
|
2001
|
+
const h = c("option");
|
|
2002
|
+
h.value = u, h.textContent = u, f.append(h);
|
|
2003
2003
|
}
|
|
2004
|
-
|
|
2004
|
+
x.required && (f.required = !0), m.append(f), n.set(x.name, f);
|
|
2005
2005
|
} else {
|
|
2006
|
-
const
|
|
2007
|
-
|
|
2006
|
+
const f = c("input", "ocw-form-input");
|
|
2007
|
+
f.type = x.type === "number" ? "number" : x.type === "date" ? "datetime-local" : "text", x.required && (f.required = !0), m.append(f), n.set(x.name, f);
|
|
2008
2008
|
}
|
|
2009
|
-
t.append(
|
|
2009
|
+
t.append(m);
|
|
2010
2010
|
}
|
|
2011
|
-
const i =
|
|
2012
|
-
|
|
2013
|
-
const
|
|
2014
|
-
for (const [
|
|
2015
|
-
if (
|
|
2016
|
-
|
|
2011
|
+
const i = c("div", "ocw-form-actions"), r = c("button", "ocw-form-cancel", "Cancel"), o = c("button", "ocw-form-submit", "Send");
|
|
2012
|
+
r.addEventListener("click", () => this.formHost.replaceChildren()), o.addEventListener("click", () => {
|
|
2013
|
+
const x = {};
|
|
2014
|
+
for (const [m, f] of n) {
|
|
2015
|
+
if (f.required && !f.value) {
|
|
2016
|
+
f.style.borderColor = "#e5484d";
|
|
2017
2017
|
return;
|
|
2018
2018
|
}
|
|
2019
|
-
|
|
2019
|
+
x[m] = f.type === "number" ? Number(f.value) : f.value;
|
|
2020
2020
|
}
|
|
2021
|
-
this.formHost.replaceChildren(), this.h.onInvoke(e.id,
|
|
2022
|
-
}), i.append(
|
|
2021
|
+
this.formHost.replaceChildren(), this.h.onInvoke(e.id, x);
|
|
2022
|
+
}), i.append(r, o), t.append(i), this.formHost.append(t), (w = n.values().next().value) == null || w.focus();
|
|
2023
2023
|
}
|
|
2024
2024
|
messageEl(e, t) {
|
|
2025
|
-
var
|
|
2025
|
+
var f;
|
|
2026
2026
|
if (e.senderRole === "system") {
|
|
2027
|
-
const
|
|
2028
|
-
return
|
|
2027
|
+
const u = c("div", "ocw-sys");
|
|
2028
|
+
return u.textContent = e.deletedAt ? "message deleted" : ee(e.content), u;
|
|
2029
2029
|
}
|
|
2030
|
-
const n = e.senderId === this.me, i = !!e.internal,
|
|
2031
|
-
!n && !i &&
|
|
2032
|
-
const
|
|
2030
|
+
const n = e.senderId === this.me, i = !!e.internal, r = c("div", `ocw-row ${i ? "ocw-note mine" : n ? "mine" : "theirs"} ${e.senderRole === "bot" ? "ocw-bot" : ""}`);
|
|
2031
|
+
!n && !i && r.append(c("div", "ocw-dot", e.senderRole === "bot" ? "🤖" : "🧑"));
|
|
2032
|
+
const o = c("div"), l = c("div", "ocw-bubble-wrap");
|
|
2033
2033
|
if (e.replyToId) {
|
|
2034
|
-
const
|
|
2035
|
-
|
|
2034
|
+
const u = c("div", "ocw-reply-to", "↩ replying to a message");
|
|
2035
|
+
u.style.cssText = "font-size:11px;color:var(--ocw-mut);margin-bottom:2px;font-style:italic", o.append(u);
|
|
2036
2036
|
}
|
|
2037
|
-
const w =
|
|
2038
|
-
let
|
|
2039
|
-
if (e.deletedAt) w.append(
|
|
2037
|
+
const w = c("div", "ocw-bubble");
|
|
2038
|
+
let x = null;
|
|
2039
|
+
if (e.deletedAt) w.append(c("span", "ocw-deleted", "message deleted"));
|
|
2040
2040
|
else if (e.content.kind === "attachment") {
|
|
2041
|
-
const
|
|
2042
|
-
if ((
|
|
2043
|
-
const
|
|
2044
|
-
|
|
2041
|
+
const u = e.content;
|
|
2042
|
+
if ((f = u.mime) != null && f.startsWith("image/")) {
|
|
2043
|
+
const h = document.createElement("img");
|
|
2044
|
+
h.src = u.url, h.alt = u.name ?? "image", h.style.cssText = "max-width:220px;max-height:160px;border-radius:10px;display:block;cursor:pointer", h.addEventListener("click", () => window.open(u.url, "_blank")), w.append(h);
|
|
2045
2045
|
} else {
|
|
2046
|
-
const
|
|
2047
|
-
|
|
2046
|
+
const h = document.createElement("a");
|
|
2047
|
+
h.href = u.url, h.target = "_blank", h.rel = "noopener", h.style.cssText = "display:flex;align-items:center;gap:8px;color:inherit;text-decoration:none", h.append(c("span", void 0, "📄"), c("span", void 0, u.name ?? "file")), w.append(h);
|
|
2048
2048
|
}
|
|
2049
2049
|
} else if (e.content.kind === "appointment") {
|
|
2050
|
-
const
|
|
2051
|
-
|
|
2052
|
-
const
|
|
2053
|
-
v.href =
|
|
2054
|
-
const
|
|
2055
|
-
|
|
2050
|
+
const u = e.content, h = c("div", "ocw-appt");
|
|
2051
|
+
h.append(c("div", "ocw-appt-title", `📅 ${u.title}`)), h.append(c("div", "ocw-appt-time", new Date(u.startIso).toLocaleString() + " – " + new Date(u.endIso).toLocaleTimeString())), u.location && h.append(c("div", "ocw-appt-loc", `📍 ${u.location}`)), u.description && h.append(c("div", "ocw-appt-desc", u.description));
|
|
2052
|
+
const T = c("div", "ocw-appt-links"), v = document.createElement("a");
|
|
2053
|
+
v.href = u.googleUrl, v.target = "_blank", v.rel = "noopener", v.className = "ocw-appt-btn", v.textContent = "📅 Add to Google Calendar";
|
|
2054
|
+
const g = document.createElement("a");
|
|
2055
|
+
g.href = u.icalUrl, g.download = `${u.title}.ics`, g.className = "ocw-appt-btn ocw-appt-btn-sec", g.textContent = "🍎 Apple / iCal", T.append(v, g), h.append(T), w.append(h);
|
|
2056
2056
|
} else
|
|
2057
|
-
|
|
2058
|
-
if (l.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 &&
|
|
2059
|
-
const
|
|
2060
|
-
if (
|
|
2061
|
-
const
|
|
2062
|
-
|
|
2063
|
-
if (
|
|
2064
|
-
this.showingTranslation.delete(e.id),
|
|
2057
|
+
x = document.createTextNode(ee(e.content)), w.append(x), e.editedAt && w.append(c("span", "ocw-edited", "(edited)"));
|
|
2058
|
+
if (l.append(w), !n && !i && this.h.onTranslate && e.content.kind === "text" && !e.deletedAt && e.seq > 0 && x) {
|
|
2059
|
+
const u = e.content.text;
|
|
2060
|
+
if (u.trim()) {
|
|
2061
|
+
const h = c("button", "ocw-translate-btn", "🌐");
|
|
2062
|
+
h.type = "button", h.title = "Translate", h.addEventListener("click", (T) => {
|
|
2063
|
+
if (T.stopPropagation(), this.showingTranslation.has(e.id)) {
|
|
2064
|
+
this.showingTranslation.delete(e.id), x.textContent = u, h.textContent = "🌐", h.title = "Translate";
|
|
2065
2065
|
return;
|
|
2066
2066
|
}
|
|
2067
2067
|
const v = this.translationCache.get(e.id);
|
|
2068
2068
|
if (v !== void 0) {
|
|
2069
|
-
this.showingTranslation.add(e.id),
|
|
2069
|
+
this.showingTranslation.add(e.id), x.textContent = v, h.textContent = "↩", h.title = "Show original";
|
|
2070
2070
|
return;
|
|
2071
2071
|
}
|
|
2072
|
-
|
|
2073
|
-
if (
|
|
2074
|
-
|
|
2075
|
-
|
|
2072
|
+
h.textContent = "⏳", this.h.onTranslate(u).then((g) => {
|
|
2073
|
+
if (g === null) {
|
|
2074
|
+
h.textContent = "⚠️", h.title = "Translation unavailable", setTimeout(() => {
|
|
2075
|
+
h.textContent = "🌐", h.title = "Translate";
|
|
2076
2076
|
}, 1500);
|
|
2077
2077
|
return;
|
|
2078
2078
|
}
|
|
2079
|
-
this.translationCache.set(e.id,
|
|
2079
|
+
this.translationCache.set(e.id, g), this.showingTranslation.add(e.id), x.textContent = g, h.textContent = "↩", h.title = "Show original";
|
|
2080
2080
|
});
|
|
2081
|
-
}), l.append(
|
|
2081
|
+
}), l.append(h);
|
|
2082
2082
|
}
|
|
2083
2083
|
}
|
|
2084
2084
|
if (n && !e.deletedAt && e.seq > 0 && (this.h.onEdit ?? this.h.onDelete)) {
|
|
2085
|
-
const
|
|
2085
|
+
const u = c("div", "ocw-msg-menu");
|
|
2086
2086
|
if (this.h.onEdit) {
|
|
2087
|
-
const
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
const v =
|
|
2091
|
-
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
const
|
|
2097
|
-
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2102
|
-
const
|
|
2103
|
-
|
|
2104
|
-
}),
|
|
2105
|
-
|
|
2087
|
+
const h = c("button", void 0, "✏️");
|
|
2088
|
+
h.title = "Edit", h.addEventListener("click", (T) => {
|
|
2089
|
+
T.stopPropagation();
|
|
2090
|
+
const v = ee(e.content), g = document.createElement("textarea");
|
|
2091
|
+
g.value = v, g.rows = Math.min(4, Math.ceil(v.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";
|
|
2092
|
+
const U = c("button", "ocw-form-submit", "Save");
|
|
2093
|
+
U.style.cssText = "margin-top:6px;padding:5px 14px;font-size:13px";
|
|
2094
|
+
const b = c("button", "ocw-form-cancel", "Cancel");
|
|
2095
|
+
b.style.cssText = "margin-top:6px;padding:5px 10px;font-size:13px";
|
|
2096
|
+
const I = c("div");
|
|
2097
|
+
I.style.cssText = "display:flex;gap:6px;justify-content:flex-end", I.append(b, U);
|
|
2098
|
+
const K = c("div");
|
|
2099
|
+
K.append(g, I), w.replaceChildren(K), g.focus(), g.select();
|
|
2100
|
+
const P = () => w.replaceChildren(x ?? document.createTextNode(v));
|
|
2101
|
+
b.addEventListener("click", P), U.addEventListener("click", () => {
|
|
2102
|
+
const E = g.value.trim();
|
|
2103
|
+
E && E !== v && this.h.onEdit(e.id, E), P();
|
|
2104
|
+
}), g.addEventListener("keydown", (E) => {
|
|
2105
|
+
E.key === "Enter" && !E.shiftKey && (E.preventDefault(), U.click()), E.key === "Escape" && P();
|
|
2106
2106
|
});
|
|
2107
|
-
}),
|
|
2107
|
+
}), u.append(h);
|
|
2108
2108
|
}
|
|
2109
2109
|
if (this.h.onDelete) {
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
}),
|
|
2110
|
+
const h = c("button", "del", "🗑");
|
|
2111
|
+
h.title = "Delete", h.addEventListener("click", (T) => {
|
|
2112
|
+
T.stopPropagation(), this.h.onDelete(e.id);
|
|
2113
|
+
}), u.append(h);
|
|
2114
2114
|
}
|
|
2115
|
-
l.append(
|
|
2115
|
+
l.append(u);
|
|
2116
2116
|
}
|
|
2117
|
-
if (
|
|
2118
|
-
const
|
|
2117
|
+
if (o.append(l), this.h.onReact && !e.deletedAt && e.seq > 0) {
|
|
2118
|
+
const u = c("div", "ocw-react-wrap"), h = c("div", "ocw-react");
|
|
2119
2119
|
if (e.reactions && Object.keys(e.reactions).length)
|
|
2120
|
-
for (const [
|
|
2121
|
-
const
|
|
2122
|
-
|
|
2123
|
-
var
|
|
2124
|
-
return (
|
|
2125
|
-
}),
|
|
2120
|
+
for (const [g, U] of Object.entries(e.reactions)) {
|
|
2121
|
+
const b = c("button", `ocw-react-pill${U.includes(this.me) ? " mine" : ""}`, `${g} ${U.length}`);
|
|
2122
|
+
b.addEventListener("click", () => {
|
|
2123
|
+
var I, K;
|
|
2124
|
+
return (K = (I = this.h).onReact) == null ? void 0 : K.call(I, e.id, g, U.includes(this.me));
|
|
2125
|
+
}), h.append(b);
|
|
2126
2126
|
}
|
|
2127
|
-
const
|
|
2128
|
-
for (const
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
var
|
|
2132
|
-
|
|
2133
|
-
const
|
|
2134
|
-
(M = (
|
|
2135
|
-
}), v.append(
|
|
2127
|
+
const T = c("button", "ocw-react-btn", "+"), v = c("div", "ocw-react-picker");
|
|
2128
|
+
for (const g of Lt) {
|
|
2129
|
+
const U = c("button", void 0, g);
|
|
2130
|
+
U.addEventListener("click", (b) => {
|
|
2131
|
+
var K, P, E, M;
|
|
2132
|
+
b.stopPropagation();
|
|
2133
|
+
const I = (P = (K = e.reactions) == null ? void 0 : K[g]) == null ? void 0 : P.includes(this.me);
|
|
2134
|
+
(M = (E = this.h).onReact) == null || M.call(E, e.id, g, !!I), v.style.display = "none";
|
|
2135
|
+
}), v.append(U);
|
|
2136
2136
|
}
|
|
2137
|
-
v.style.display = "none",
|
|
2138
|
-
|
|
2137
|
+
v.style.display = "none", T.addEventListener("click", (g) => {
|
|
2138
|
+
g.stopPropagation(), v.style.display = v.style.display === "none" ? "flex" : "none";
|
|
2139
2139
|
}), document.addEventListener("click", () => {
|
|
2140
2140
|
v.style.display = "none";
|
|
2141
|
-
}, { once: !0 }),
|
|
2142
|
-
} else e.reactions && Object.keys(e.reactions).length &&
|
|
2143
|
-
const
|
|
2141
|
+
}, { once: !0 }), h.append(T), u.append(h, v), o.append(u);
|
|
2142
|
+
} else e.reactions && Object.keys(e.reactions).length && o.append(c("div", "ocw-react", Object.entries(e.reactions).map(([u, h]) => `${u}${h.length}`).join(" ")));
|
|
2143
|
+
const m = c("div", "ocw-time ocw-meta", _t(e.ts));
|
|
2144
2144
|
if (n && e.status) {
|
|
2145
|
-
const
|
|
2146
|
-
|
|
2145
|
+
const u = c("span", `ocw-tick${e.status === "read" ? " read" : e.status === "delivered" ? " delivered" : ""}`, Ht(e.status));
|
|
2146
|
+
m.append(u);
|
|
2147
2147
|
}
|
|
2148
|
-
return n && e.seq > 0 && t.lastReadByOthers >= e.seq &&
|
|
2148
|
+
return n && e.seq > 0 && t.lastReadByOthers >= e.seq && m.append(c("span", "ocw-seen", " · Seen")), o.append(m), r.append(o), r;
|
|
2149
2149
|
}
|
|
2150
2150
|
}
|
|
2151
2151
|
function Ht(s) {
|
|
@@ -2160,26 +2160,26 @@ function Ht(s) {
|
|
|
2160
2160
|
return "🕓";
|
|
2161
2161
|
}
|
|
2162
2162
|
}
|
|
2163
|
-
const
|
|
2163
|
+
const H = /* @__PURE__ */ new WeakMap();
|
|
2164
2164
|
function qt(s) {
|
|
2165
2165
|
var e;
|
|
2166
|
-
(e =
|
|
2166
|
+
(e = H.get(s)) == null || e.close(), H.delete(s);
|
|
2167
2167
|
}
|
|
2168
2168
|
function Ot(s) {
|
|
2169
|
-
var
|
|
2170
|
-
|
|
2171
|
-
const e = s.token ?? Ke();
|
|
2172
|
-
let
|
|
2173
|
-
const
|
|
2174
|
-
let o,
|
|
2169
|
+
var ce, de, le, he;
|
|
2170
|
+
H.has(s.el) && (H.get(s.el).close(), H.delete(s.el));
|
|
2171
|
+
const e = s.token ?? Ke(), t = s.apiUrl ? s.apiUrl.replace(/\/+$/, "") : Ae(s.url);
|
|
2172
|
+
let n = new gt(e);
|
|
2173
|
+
const i = s.subjectId ? `${e}::${s.subjectId}` : e, r = new kt(i);
|
|
2174
|
+
let o, l = !1, w = null, x = null;
|
|
2175
2175
|
!s.launcher && !s.el.style.height && s.el.clientHeight === 0 && (s.el.style.width = s.el.style.width || "100%", s.el.style.height = "600px");
|
|
2176
|
-
for (const d of
|
|
2177
|
-
let
|
|
2176
|
+
for (const d of r.load()) n.addOptimistic(d.clientMsgId, d.content);
|
|
2177
|
+
let m = null, f = null, u = 0, h = !s.launcher;
|
|
2178
2178
|
if (s.launcher) {
|
|
2179
2179
|
const p = (s.position ?? "bottom-right").includes("right");
|
|
2180
|
-
|
|
2181
|
-
const y = document.createElement("div"),
|
|
2182
|
-
y.style.cssText =
|
|
2180
|
+
m = document.createElement("div"), m.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"), C = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null, R = ($) => {
|
|
2182
|
+
y.style.cssText = $ ? [
|
|
2183
2183
|
"position:fixed",
|
|
2184
2184
|
"inset:0",
|
|
2185
2185
|
"width:100%",
|
|
@@ -2208,122 +2208,122 @@ function Ot(s) {
|
|
|
2208
2208
|
"transform:scale(.95)"
|
|
2209
2209
|
].join(";");
|
|
2210
2210
|
};
|
|
2211
|
-
|
|
2212
|
-
const
|
|
2213
|
-
C.style.cssText =
|
|
2211
|
+
R((C == null ? void 0 : C.matches) ?? !1);
|
|
2212
|
+
const V = ($) => R($.matches);
|
|
2213
|
+
C == null || C.addEventListener("change", V), w = C, x = V, 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(";"),
|
|
2221
|
-
|
|
2222
|
-
},
|
|
2223
|
-
|
|
2224
|
-
},
|
|
2225
|
-
const
|
|
2226
|
-
|
|
2222
|
+
].join(";"), B.textContent = "💬", B.onmouseenter = () => {
|
|
2223
|
+
B.style.transform = "scale(1.08)";
|
|
2224
|
+
}, B.onmouseleave = () => {
|
|
2225
|
+
B.style.transform = "scale(1)";
|
|
2226
|
+
}, f = document.createElement("span"), f.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(f), m.append(y, B), document.body.append(m);
|
|
2227
|
+
const W = ($) => {
|
|
2228
|
+
$ ? (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
|
-
|
|
2233
|
-
h = !h,
|
|
2234
|
-
}), document.addEventListener("keydown", (
|
|
2235
|
-
|
|
2234
|
+
B.addEventListener("click", () => {
|
|
2235
|
+
h = !h, W(h), B.textContent = h ? "✕" : "💬", B.append(f), h && (u = 0, f && (f.style.display = "none"));
|
|
2236
|
+
}), document.addEventListener("keydown", ($) => {
|
|
2237
|
+
$.key === "Escape" && h && (h = !1, W(!1), B.textContent = "💬", B.append(f));
|
|
2236
2238
|
});
|
|
2237
2239
|
}
|
|
2238
|
-
const
|
|
2239
|
-
h || (
|
|
2240
|
-
},
|
|
2240
|
+
const T = () => {
|
|
2241
|
+
h || (u++, f && (f.textContent = String(u), f.style.display = "flex"));
|
|
2242
|
+
}, v = () => {
|
|
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);
|
|
2244
2246
|
} catch {
|
|
2245
2247
|
}
|
|
2246
|
-
},
|
|
2247
|
-
for (;
|
|
2248
|
-
const p =
|
|
2249
|
-
|
|
2248
|
+
}, g = [], U = (d) => {
|
|
2249
|
+
for (; g.length; ) {
|
|
2250
|
+
const p = g.shift();
|
|
2251
|
+
r.add({ clientMsgId: p.clientMsgId, content: p.content, ts: Date.now() }), b.send({ type: "send", conversationId: d, clientMsgId: p.clientMsgId, content: p.content });
|
|
2250
2252
|
}
|
|
2251
2253
|
};
|
|
2252
|
-
let
|
|
2254
|
+
let b;
|
|
2253
2255
|
const I = new At(`ocw-e2e-${s.profileId}`);
|
|
2254
2256
|
let K = !1;
|
|
2255
|
-
const P = [],
|
|
2256
|
-
let
|
|
2257
|
-
const
|
|
2257
|
+
const P = [], E = [];
|
|
2258
|
+
let M = !1;
|
|
2259
|
+
const k = (d, p) => {
|
|
2258
2260
|
I.sealText(p).then((y) => {
|
|
2259
|
-
o &&
|
|
2261
|
+
o && b.send({ type: "send", conversationId: o, clientMsgId: d, content: y });
|
|
2260
2262
|
});
|
|
2261
|
-
},
|
|
2262
|
-
I.sealText(p, y).then((
|
|
2263
|
-
o &&
|
|
2263
|
+
}, A = (d, p, y) => {
|
|
2264
|
+
I.sealText(p, y).then((C) => {
|
|
2265
|
+
o && b.send({ type: "send", conversationId: o, clientMsgId: d, content: C });
|
|
2264
2266
|
});
|
|
2265
|
-
},
|
|
2267
|
+
}, Q = () => {
|
|
2266
2268
|
for (; P.length; ) {
|
|
2267
2269
|
const d = P.shift();
|
|
2268
|
-
|
|
2270
|
+
k(d.clientMsgId, d.text);
|
|
2269
2271
|
}
|
|
2270
|
-
for (;
|
|
2271
|
-
const d =
|
|
2272
|
-
|
|
2272
|
+
for (; E.length; ) {
|
|
2273
|
+
const d = E.shift();
|
|
2274
|
+
k(d.clientMsgId, d.text);
|
|
2273
2275
|
}
|
|
2274
|
-
},
|
|
2275
|
-
|
|
2276
|
-
},
|
|
2277
|
-
|
|
2276
|
+
}, Se = (d) => {
|
|
2277
|
+
b.send({ type: "fetchPrekey", targetUserId: d });
|
|
2278
|
+
}, Ie = s.i18n ?? {}, Ce = ["ar", "he", "fa", "ur"], Ee = typeof navigator < "u" ? (navigator.language ?? "").slice(0, 2).toLowerCase() : "";
|
|
2279
|
+
Ce.includes(Ee) && !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
|
-
|
|
2283
|
+
n.addOptimistic(p, y), L.render(n), n.e2e ? I.ready ? k(p, d) : M ? E.push({ clientMsgId: p, text: d }) : (P.push({ clientMsgId: p, text: d }), n.assignedAgentId && Se(n.assignedAgentId)) : o ? (r.add({ clientMsgId: p, content: y, ts: Date.now() }), b.send({ type: "send", conversationId: o, clientMsgId: p, content: y })) : g.push({ clientMsgId: p, content: y });
|
|
2282
2284
|
},
|
|
2283
2285
|
async onAttach(d) {
|
|
2284
2286
|
if (!o) return;
|
|
2285
|
-
const
|
|
2286
|
-
|
|
2287
|
+
const p = `${t}/upload?name=${encodeURIComponent(d.name)}`, y = `cm_${Math.random().toString(36).slice(2)}`;
|
|
2288
|
+
n.addOptimistic(y, { kind: "text", text: `📎 Uploading ${d.name}…` }), L.render(n);
|
|
2287
2289
|
try {
|
|
2288
|
-
const C = await fetch(
|
|
2290
|
+
const C = await fetch(p, {
|
|
2289
2291
|
method: "POST",
|
|
2290
2292
|
headers: { "content-type": d.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
|
|
2291
2293
|
body: d
|
|
2292
2294
|
});
|
|
2293
2295
|
if (!C.ok) throw new Error(`Upload failed: ${C.status}`);
|
|
2294
|
-
const { url:
|
|
2295
|
-
|
|
2296
|
+
const { url: R, name: V, mime: B, size: W } = await C.json();
|
|
2297
|
+
b.send({ type: "send", conversationId: o, clientMsgId: y, content: { kind: "attachment", url: R, name: V, mime: B, size: W } });
|
|
2296
2298
|
} catch (C) {
|
|
2297
|
-
|
|
2299
|
+
n.addOptimistic(y, { kind: "text", text: `⚠️ Upload failed: ${C.message}` }), L.render(n);
|
|
2298
2300
|
}
|
|
2299
2301
|
},
|
|
2300
2302
|
onInvoke(d, p) {
|
|
2301
|
-
o &&
|
|
2303
|
+
o && b.send({ type: "invoke", conversationId: o, actionId: d, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...p ? { inputs: p } : {} });
|
|
2302
2304
|
},
|
|
2303
2305
|
onTyping(d, p) {
|
|
2304
|
-
o &&
|
|
2306
|
+
o && b.send({ type: "typing", conversationId: o, isTyping: d, ...p ? { preview: p } : {} });
|
|
2305
2307
|
},
|
|
2306
2308
|
onReadUpTo(d) {
|
|
2307
|
-
o &&
|
|
2309
|
+
o && b.send({ type: "read", conversationId: o, seq: d });
|
|
2308
2310
|
},
|
|
2309
2311
|
onLoadMore() {
|
|
2310
|
-
if (!o || !
|
|
2311
|
-
const d =
|
|
2312
|
-
d &&
|
|
2312
|
+
if (!o || !n.e2e) return;
|
|
2313
|
+
const d = n.messages()[0];
|
|
2314
|
+
d && b.send({ type: "history", conversationId: o, beforeSeq: d.seq, limit: 20 });
|
|
2313
2315
|
},
|
|
2314
2316
|
onEdit(d, p) {
|
|
2315
|
-
o &&
|
|
2317
|
+
o && b.send({ type: "edit", conversationId: o, messageId: d, content: { kind: "text", text: p } });
|
|
2316
2318
|
},
|
|
2317
2319
|
onDelete(d) {
|
|
2318
|
-
o &&
|
|
2320
|
+
o && b.send({ type: "delete", conversationId: o, messageId: d });
|
|
2319
2321
|
},
|
|
2320
2322
|
onReact(d, p, y) {
|
|
2321
|
-
o &&
|
|
2323
|
+
o && b.send({ type: "react", conversationId: o, messageId: d, emoji: p, remove: y });
|
|
2322
2324
|
},
|
|
2323
2325
|
onCsat(d) {
|
|
2324
|
-
|
|
2325
|
-
const p = ze(s.url);
|
|
2326
|
-
fetch(`${p}/conversations/${o}/csat`, {
|
|
2326
|
+
o && fetch(`${t}/conversations/${o}/csat`, {
|
|
2327
2327
|
method: "POST",
|
|
2328
2328
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${e}` },
|
|
2329
2329
|
body: JSON.stringify({ score: d })
|
|
@@ -2331,23 +2331,22 @@ function Ot(s) {
|
|
|
2331
2331
|
});
|
|
2332
2332
|
},
|
|
2333
2333
|
onAnnotate(d) {
|
|
2334
|
-
o &&
|
|
2334
|
+
o && b.send({ type: "annotate", conversationId: o, stroke: d });
|
|
2335
2335
|
},
|
|
2336
2336
|
onAnnotateClear() {
|
|
2337
|
-
o &&
|
|
2337
|
+
o && b.send({ type: "annotate_clear", conversationId: o });
|
|
2338
2338
|
},
|
|
2339
2339
|
...s.translateLang ? {
|
|
2340
2340
|
async onTranslate(d) {
|
|
2341
|
-
const p = s.url.replace(/^ws/, "http").replace(/\/+$/, "");
|
|
2342
2341
|
try {
|
|
2343
|
-
const
|
|
2342
|
+
const p = await fetch(`${t}/translate`, {
|
|
2344
2343
|
method: "POST",
|
|
2345
2344
|
headers: { "content-type": "application/json", authorization: `Bearer ${e}` },
|
|
2346
2345
|
body: JSON.stringify({ text: d, targetLang: s.translateLang })
|
|
2347
2346
|
});
|
|
2348
|
-
if (!
|
|
2349
|
-
const { translated:
|
|
2350
|
-
return
|
|
2347
|
+
if (!p.ok) return null;
|
|
2348
|
+
const { translated: y } = await p.json();
|
|
2349
|
+
return y;
|
|
2351
2350
|
} catch {
|
|
2352
2351
|
return null;
|
|
2353
2352
|
}
|
|
@@ -2357,9 +2356,9 @@ function Ot(s) {
|
|
|
2357
2356
|
...s.subject ? { subject: s.subject } : {},
|
|
2358
2357
|
...s.quickReplies ? { quickReplies: s.quickReplies } : {},
|
|
2359
2358
|
...s.accent ? { accent: s.accent } : {},
|
|
2360
|
-
...(
|
|
2361
|
-
i18n:
|
|
2362
|
-
}),
|
|
2359
|
+
...(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 } : {} } } : {},
|
|
2360
|
+
i18n: Ie
|
|
2361
|
+
}), Te = {
|
|
2363
2362
|
type: "open",
|
|
2364
2363
|
profileId: s.profileId,
|
|
2365
2364
|
...s.subjectId ? { subjectId: s.subjectId } : {},
|
|
@@ -2367,72 +2366,72 @@ function Ot(s) {
|
|
|
2367
2366
|
...typeof document < "u" && document.title ? { pageTitle: document.title } : {},
|
|
2368
2367
|
// Pass subject display info so the server can persist it to the Subject record.
|
|
2369
2368
|
// This is how listingTitle and listingMeta get saved without a separate API call.
|
|
2370
|
-
...(
|
|
2371
|
-
...(
|
|
2372
|
-
},
|
|
2369
|
+
...(le = s.subject) != null && le.title ? { subjectTitle: s.subject.title } : {},
|
|
2370
|
+
...(he = s.subject) != null && he.subtitle ? { subjectMeta: s.subject.subtitle } : {}
|
|
2371
|
+
}, Ue = (d) => {
|
|
2373
2372
|
const p = s.user;
|
|
2374
2373
|
if (!p || !p.name && !p.email && !p.avatar && !p.meta) return;
|
|
2375
2374
|
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 [
|
|
2377
|
-
|
|
2375
|
+
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, R] of Object.entries(p.meta)) y.push(`${C}: ${R}`);
|
|
2376
|
+
b.send({ type: "note", conversationId: d, clientMsgId: `ui_${Date.now()}`, text: `[User info]
|
|
2378
2377
|
${y.join(`
|
|
2379
2378
|
`)}` });
|
|
2380
2379
|
};
|
|
2381
|
-
|
|
2380
|
+
b = new bt({
|
|
2382
2381
|
url: s.url,
|
|
2383
2382
|
token: e,
|
|
2384
|
-
open:
|
|
2385
|
-
getCursor: () =>
|
|
2383
|
+
open: Te,
|
|
2384
|
+
getCursor: () => n.highestSeq(),
|
|
2386
2385
|
onStatusChange: (d) => L.setConnStatus(d),
|
|
2387
2386
|
onFrame(d) {
|
|
2388
2387
|
if (d.type === "opened") {
|
|
2389
2388
|
const p = o === void 0;
|
|
2390
|
-
if (o = d.conversation.id, !
|
|
2391
|
-
|
|
2392
|
-
for (const y of
|
|
2393
|
-
|
|
2389
|
+
if (o = d.conversation.id, !l) {
|
|
2390
|
+
l = !0;
|
|
2391
|
+
for (const y of r.load())
|
|
2392
|
+
b.send({ type: "send", conversationId: o, clientMsgId: y.clientMsgId, content: y.content });
|
|
2394
2393
|
}
|
|
2395
|
-
|
|
2394
|
+
ze(s.url, e, o, n, L, t), g.length && U(o), p && d.conversation.lastSeq === 0 && Ue(o);
|
|
2396
2395
|
}
|
|
2397
|
-
if (d.type === "ack" &&
|
|
2398
|
-
d.bundle && (
|
|
2399
|
-
const y = [...P.splice(0), ...
|
|
2400
|
-
for (const
|
|
2401
|
-
L.render(
|
|
2396
|
+
if (d.type === "ack" && r.remove(d.clientMsgId), d.type === "prekeyBundle") {
|
|
2397
|
+
d.bundle && (M = !0, I.x3dhSendTo(d.bundle).then((p) => {
|
|
2398
|
+
const y = [...P.splice(0), ...E.splice(0)];
|
|
2399
|
+
for (const C of y) A(C.clientMsgId, C.text, p);
|
|
2400
|
+
L.render(n);
|
|
2402
2401
|
}));
|
|
2403
2402
|
return;
|
|
2404
2403
|
}
|
|
2405
|
-
if (d.type === "message" &&
|
|
2404
|
+
if (d.type === "message" && n.e2e) {
|
|
2406
2405
|
const p = zt(d.message.content);
|
|
2407
2406
|
if (p && !I.ready) {
|
|
2408
2407
|
I.x3dhReceiveFrom(p.x3dhIK, p.x3dhEK, p.x3dhSPK).then(async () => {
|
|
2409
|
-
await I.openFrame(d),
|
|
2408
|
+
await I.openFrame(d), n.apply(d), L.render(n);
|
|
2410
2409
|
});
|
|
2411
2410
|
return;
|
|
2412
2411
|
}
|
|
2413
2412
|
}
|
|
2414
2413
|
if (d.type === "peerkey") {
|
|
2415
2414
|
I.onPeerKey(d.key).then(() => {
|
|
2416
|
-
|
|
2415
|
+
Q(), L.render(n);
|
|
2417
2416
|
});
|
|
2418
2417
|
return;
|
|
2419
2418
|
}
|
|
2420
2419
|
(async () => {
|
|
2421
|
-
if (
|
|
2420
|
+
if (n.e2e && await I.openFrame(d), n.apply(d), d.type === "message" && d.message.senderId !== e && !d.message.internal && (T(), v()), n.e2e && o && !K) {
|
|
2422
2421
|
K = !0;
|
|
2423
2422
|
const p = await I.initX3DH();
|
|
2424
|
-
|
|
2423
|
+
b.send({ type: "uploadPrekeys", ...p });
|
|
2425
2424
|
const y = await I.begin();
|
|
2426
|
-
|
|
2425
|
+
b.send({ type: "pubkey", conversationId: o, key: y });
|
|
2427
2426
|
}
|
|
2428
|
-
L.render(
|
|
2427
|
+
L.render(n);
|
|
2429
2428
|
})();
|
|
2430
2429
|
}
|
|
2431
|
-
}),
|
|
2432
|
-
const
|
|
2433
|
-
|
|
2430
|
+
}), b.connect(), L.render(n);
|
|
2431
|
+
const ae = { close: () => {
|
|
2432
|
+
b.close(), m == null || m.remove(), L.destroy(), w && x && w.removeEventListener("change", x), H.delete(s.el);
|
|
2434
2433
|
} };
|
|
2435
|
-
return
|
|
2434
|
+
return H.set(s.el, ae), ae;
|
|
2436
2435
|
}
|
|
2437
2436
|
export {
|
|
2438
2437
|
gt as ChatStore,
|
|
@@ -2442,9 +2441,9 @@ export {
|
|
|
2442
2441
|
$t as Renderer,
|
|
2443
2442
|
jt as asConversationId,
|
|
2444
2443
|
zt as extractX3DHInit,
|
|
2445
|
-
|
|
2444
|
+
Ae as httpBaseFromWsUrl,
|
|
2446
2445
|
Ot as mount,
|
|
2447
|
-
|
|
2446
|
+
ze as restoreHistory,
|
|
2448
2447
|
qt as unmount
|
|
2449
2448
|
};
|
|
2450
2449
|
//# sourceMappingURL=index.js.map
|