@paramms/chat-widget 1.0.16 → 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 +515 -518
- package/dist/index.js.map +1 -1
- package/dist/react.d.ts +11 -4
- package/dist/react.js +196 -186
- 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;
|
|
@@ -57,27 +57,27 @@ function He(s, e, t) {
|
|
|
57
57
|
const Re = 4096;
|
|
58
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) {
|
|
@@ -89,8 +89,8 @@ function Oe(s, e, t) {
|
|
|
89
89
|
}
|
|
90
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
|
}
|
|
@@ -105,7 +105,7 @@ class z extends Error {
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
}
|
|
108
|
-
const
|
|
108
|
+
const j = 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);
|
|
@@ -129,8 +129,8 @@ 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);
|
|
@@ -157,8 +157,8 @@ 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
164
|
const t = be(e, 4), n = e.getUint32(0);
|
|
@@ -181,13 +181,13 @@ const tt = {
|
|
|
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,20 +202,20 @@ 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 X(
|
|
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 X(
|
|
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
|
}
|
|
@@ -226,7 +226,7 @@ const tt = {
|
|
|
226
226
|
return i ? i(e, t, n) : new X(t, e);
|
|
227
227
|
}
|
|
228
228
|
};
|
|
229
|
-
|
|
229
|
+
a(G, "defaultCodec", new G());
|
|
230
230
|
let Y = G;
|
|
231
231
|
function nt(s) {
|
|
232
232
|
return s instanceof ArrayBuffer || typeof SharedArrayBuffer < "u" && s instanceof SharedArrayBuffer;
|
|
@@ -237,19 +237,19 @@ function te(s) {
|
|
|
237
237
|
const it = 100, st = 2048;
|
|
238
238
|
class se {
|
|
239
239
|
constructor(e) {
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
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
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() {
|
|
@@ -395,9 +395,9 @@ class se {
|
|
|
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) {
|
|
@@ -479,11 +479,11 @@ function Z(s) {
|
|
|
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 ne = "array",
|
|
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;
|
|
@@ -537,7 +537,7 @@ class lt {
|
|
|
537
537
|
}
|
|
538
538
|
pushMapState(e) {
|
|
539
539
|
const t = this.getUninitializedStateFromPool();
|
|
540
|
-
t.type =
|
|
540
|
+
t.type = O, t.readCount = 0, t.size = e, t.map = {};
|
|
541
541
|
}
|
|
542
542
|
getUninitializedStateFromPool() {
|
|
543
543
|
if (this.stackHeadPosition++, this.stackHeadPosition === this.stack.length) {
|
|
@@ -561,7 +561,7 @@ class lt {
|
|
|
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 ===
|
|
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,7 +571,7 @@ class lt {
|
|
|
571
571
|
this.stack.length = 0, this.stackHeadPosition = -1;
|
|
572
572
|
}
|
|
573
573
|
}
|
|
574
|
-
const
|
|
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) {
|
|
@@ -581,25 +581,25 @@ try {
|
|
|
581
581
|
const pe = new RangeError("Insufficient data"), pt = new ct();
|
|
582
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) ?? 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) ??
|
|
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
605
|
return new re({
|
|
@@ -616,14 +616,14 @@ class re {
|
|
|
616
616
|
});
|
|
617
617
|
}
|
|
618
618
|
reinitializeState() {
|
|
619
|
-
this.totalPos = 0, this.headByte =
|
|
619
|
+
this.totalPos = 0, this.headByte = q, this.stack.reset();
|
|
620
620
|
}
|
|
621
621
|
setBuffer(e) {
|
|
622
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 ===
|
|
626
|
+
if (this.headByte === q && !this.hasRemaining(1))
|
|
627
627
|
this.setBuffer(e);
|
|
628
628
|
else {
|
|
629
629
|
const t = this.bytes.subarray(this.pos), n = te(e), i = new Uint8Array(t.length + n.length);
|
|
@@ -689,8 +689,8 @@ class re {
|
|
|
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 ${Z(i)} at ${
|
|
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 re {
|
|
|
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
|
}
|
|
@@ -855,7 +855,7 @@ class re {
|
|
|
855
855
|
t = i.array, n.release(i);
|
|
856
856
|
else
|
|
857
857
|
continue e;
|
|
858
|
-
else if (i.type ===
|
|
858
|
+
else if (i.type === O) {
|
|
859
859
|
if (t === "__proto__")
|
|
860
860
|
throw new z("The key __proto__ is not allowed");
|
|
861
861
|
i.key = this.mapKeyConverter(t), i.type = me;
|
|
@@ -863,7 +863,7 @@ class re {
|
|
|
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 =
|
|
866
|
+
i.key = null, i.type = O;
|
|
867
867
|
continue e;
|
|
868
868
|
}
|
|
869
869
|
}
|
|
@@ -871,10 +871,10 @@ class re {
|
|
|
871
871
|
}
|
|
872
872
|
}
|
|
873
873
|
readHeadByte() {
|
|
874
|
-
return this.headByte ===
|
|
874
|
+
return this.headByte === q && (this.headByte = this.readU8()), this.headByte;
|
|
875
875
|
}
|
|
876
876
|
complete() {
|
|
877
|
-
this.headByte =
|
|
877
|
+
this.headByte = q;
|
|
878
878
|
}
|
|
879
879
|
readArraySize() {
|
|
880
880
|
const e = this.readHeadByte();
|
|
@@ -907,17 +907,17 @@ class re {
|
|
|
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
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
|
-
return this.stack.length > 0 ? this.stack.top().type ===
|
|
920
|
+
return this.stack.length > 0 ? this.stack.top().type === O : !1;
|
|
921
921
|
}
|
|
922
922
|
/**
|
|
923
923
|
* @throws {@link RangeError}
|
|
@@ -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": {
|
|
@@ -1180,8 +1180,8 @@ class gt {
|
|
|
1180
1180
|
markOwnStatus(e, t) {
|
|
1181
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
|
}
|
|
@@ -1199,13 +1199,13 @@ function ue(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();
|
|
@@ -1277,7 +1277,7 @@ function mt(s) {
|
|
|
1277
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 [];
|
|
@@ -1325,18 +1325,18 @@ function ie(s) {
|
|
|
1325
1325
|
for (let i = 0; i < e.length; i++) n[i] = e.charCodeAt(i);
|
|
1326
1326
|
return n;
|
|
1327
1327
|
}
|
|
1328
|
-
async function
|
|
1328
|
+
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
|
|
1332
|
+
async function _(s) {
|
|
1333
1333
|
return J(await S().exportKey("raw", s));
|
|
1334
1334
|
}
|
|
1335
|
-
async function
|
|
1335
|
+
async function F(s) {
|
|
1336
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
|
|
1339
|
+
const t = await F(e);
|
|
1340
1340
|
return S().deriveKey(
|
|
1341
1341
|
{ name: "ECDH", public: t },
|
|
1342
1342
|
s,
|
|
@@ -1358,15 +1358,15 @@ 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
|
-
const e = await
|
|
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;
|
|
@@ -1376,12 +1376,12 @@ async function Tt(s, e) {
|
|
|
1376
1376
|
return J(n);
|
|
1377
1377
|
}
|
|
1378
1378
|
async function Ut() {
|
|
1379
|
-
const s = await
|
|
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
1387
|
async function we(s) {
|
|
@@ -1389,37 +1389,37 @@ async function we(s) {
|
|
|
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
|
|
1412
|
-
return { sharedKey: await ke(
|
|
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 ke(
|
|
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
1421
|
function ve(...s) {
|
|
1422
|
-
const e = s.reduce((i,
|
|
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;
|
|
@@ -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 we(this.storageKey), this.signedPreKP = await
|
|
1471
|
-
for (let i = 0; i < Kt; i++) this.otpKeys.push(await
|
|
1472
|
-
const e = await
|
|
1470
|
+
this.identityKP = await we(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 _(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,
|
|
@@ -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
|
}
|
|
@@ -1701,7 +1701,7 @@ function Dt() {
|
|
|
1701
1701
|
const s = document.createElement("style");
|
|
1702
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
|
}
|
|
@@ -1732,86 +1732,86 @@ function ee(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
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 T =
|
|
1810
|
+
const T = c("button", "ocw-cobrowse-clear", "Clear");
|
|
1811
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(T), this.cobrowseHint =
|
|
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 T =
|
|
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
|
-
|
|
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
2063
|
if (T.stopPropagation(), this.showingTranslation.has(e.id)) {
|
|
2064
|
-
this.showingTranslation.delete(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
|
-
|
|
2087
|
+
const h = c("button", void 0, "✏️");
|
|
2088
|
+
h.title = "Edit", h.addEventListener("click", (T) => {
|
|
2089
2089
|
T.stopPropagation();
|
|
2090
|
-
const v = ee(e.content),
|
|
2091
|
-
|
|
2092
|
-
const
|
|
2093
|
-
|
|
2094
|
-
const
|
|
2095
|
-
|
|
2096
|
-
const
|
|
2097
|
-
|
|
2098
|
-
const
|
|
2099
|
-
|
|
2100
|
-
const P = () => w.replaceChildren(
|
|
2101
|
-
|
|
2102
|
-
const E =
|
|
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
2103
|
E && E !== v && this.h.onEdit(e.id, E), P();
|
|
2104
|
-
}),
|
|
2105
|
-
E.key === "Enter" && !E.shiftKey && (E.preventDefault(),
|
|
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
|
-
|
|
2110
|
+
const h = c("button", "del", "🗑");
|
|
2111
|
+
h.title = "Delete", h.addEventListener("click", (T) => {
|
|
2112
2112
|
T.stopPropagation(), this.h.onDelete(e.id);
|
|
2113
|
-
}),
|
|
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 T =
|
|
2128
|
-
for (const
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
var
|
|
2132
|
-
|
|
2133
|
-
const
|
|
2134
|
-
(M = (E = this.h).onReact) == null || M.call(E, e.id,
|
|
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", T.addEventListener("click", (
|
|
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
2169
|
var ce, de, le, he;
|
|
2170
|
-
|
|
2171
|
-
const e = s.token ?? Ke();
|
|
2172
|
-
let
|
|
2173
|
-
const
|
|
2174
|
-
let o,
|
|
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"), C = typeof window < "u" ? window.matchMedia("(max-width: 479px)") : null,
|
|
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,9 +2208,9 @@ function Ot(s) {
|
|
|
2208
2208
|
"transform:scale(.95)"
|
|
2209
2209
|
].join(";");
|
|
2210
2210
|
};
|
|
2211
|
-
|
|
2212
|
-
const
|
|
2213
|
-
C == null || C.addEventListener("change",
|
|
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
2214
|
const B = document.createElement("button");
|
|
2215
2215
|
B.style.cssText = [
|
|
2216
2216
|
"width:56px;height:56px;border-radius:50%",
|
|
@@ -2223,109 +2223,107 @@ function Ot(s) {
|
|
|
2223
2223
|
B.style.transform = "scale(1.08)";
|
|
2224
2224
|
}, B.onmouseleave = () => {
|
|
2225
2225
|
B.style.transform = "scale(1)";
|
|
2226
|
-
},
|
|
2227
|
-
const W = (
|
|
2228
|
-
|
|
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(() => {
|
|
2229
2229
|
y.style.opacity = "1", y.style.transform = "scale(1)";
|
|
2230
2230
|
})) : (y.style.opacity = "0", y.style.transform = "scale(.95)", setTimeout(() => {
|
|
2231
2231
|
h || (y.style.display = "none");
|
|
2232
2232
|
}, 180));
|
|
2233
2233
|
};
|
|
2234
2234
|
B.addEventListener("click", () => {
|
|
2235
|
-
h = !h, W(h), B.textContent = h ? "✕" : "💬", B.append(
|
|
2236
|
-
}), document.addEventListener("keydown", (
|
|
2237
|
-
|
|
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));
|
|
2238
2238
|
});
|
|
2239
2239
|
}
|
|
2240
|
-
const
|
|
2241
|
-
h || (
|
|
2242
|
-
},
|
|
2240
|
+
const T = () => {
|
|
2241
|
+
h || (u++, f && (f.textContent = String(u), f.style.display = "flex"));
|
|
2242
|
+
}, v = () => {
|
|
2243
2243
|
try {
|
|
2244
2244
|
const d = new AudioContext(), p = d.createOscillator(), y = d.createGain();
|
|
2245
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);
|
|
2246
2246
|
} catch {
|
|
2247
2247
|
}
|
|
2248
|
-
},
|
|
2249
|
-
for (;
|
|
2250
|
-
const p =
|
|
2251
|
-
|
|
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 });
|
|
2252
2252
|
}
|
|
2253
2253
|
};
|
|
2254
|
-
let
|
|
2254
|
+
let b;
|
|
2255
2255
|
const I = new At(`ocw-e2e-${s.profileId}`);
|
|
2256
2256
|
let K = !1;
|
|
2257
|
-
const
|
|
2258
|
-
let
|
|
2259
|
-
const
|
|
2257
|
+
const P = [], E = [];
|
|
2258
|
+
let M = !1;
|
|
2259
|
+
const k = (d, p) => {
|
|
2260
2260
|
I.sealText(p).then((y) => {
|
|
2261
|
-
o &&
|
|
2261
|
+
o && b.send({ type: "send", conversationId: o, clientMsgId: d, content: y });
|
|
2262
2262
|
});
|
|
2263
|
-
},
|
|
2263
|
+
}, A = (d, p, y) => {
|
|
2264
2264
|
I.sealText(p, y).then((C) => {
|
|
2265
|
-
o &&
|
|
2265
|
+
o && b.send({ type: "send", conversationId: o, clientMsgId: d, content: C });
|
|
2266
2266
|
});
|
|
2267
|
-
},
|
|
2268
|
-
for (; U.length; ) {
|
|
2269
|
-
const d = U.shift();
|
|
2270
|
-
M(d.clientMsgId, d.text);
|
|
2271
|
-
}
|
|
2267
|
+
}, Q = () => {
|
|
2272
2268
|
for (; P.length; ) {
|
|
2273
2269
|
const d = P.shift();
|
|
2274
|
-
|
|
2270
|
+
k(d.clientMsgId, d.text);
|
|
2271
|
+
}
|
|
2272
|
+
for (; E.length; ) {
|
|
2273
|
+
const d = E.shift();
|
|
2274
|
+
k(d.clientMsgId, d.text);
|
|
2275
2275
|
}
|
|
2276
|
-
},
|
|
2277
|
-
|
|
2278
|
-
},
|
|
2279
|
-
|
|
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");
|
|
2280
2280
|
const L = new $t(s.el, e, {
|
|
2281
2281
|
onSend(d) {
|
|
2282
2282
|
const p = `cm_${Math.random().toString(36).slice(2)}`, y = { kind: "text", text: d };
|
|
2283
|
-
|
|
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 });
|
|
2284
2284
|
},
|
|
2285
2285
|
async onAttach(d) {
|
|
2286
2286
|
if (!o) return;
|
|
2287
|
-
const
|
|
2288
|
-
|
|
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);
|
|
2289
2289
|
try {
|
|
2290
|
-
const
|
|
2290
|
+
const C = await fetch(p, {
|
|
2291
2291
|
method: "POST",
|
|
2292
2292
|
headers: { "content-type": d.type, ...s.token ? { authorization: `Bearer ${s.token}` } : {} },
|
|
2293
2293
|
body: d
|
|
2294
2294
|
});
|
|
2295
|
-
if (
|
|
2296
|
-
const { url:
|
|
2297
|
-
|
|
2298
|
-
} catch (
|
|
2299
|
-
|
|
2295
|
+
if (!C.ok) throw new Error(`Upload failed: ${C.status}`);
|
|
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 } });
|
|
2298
|
+
} catch (C) {
|
|
2299
|
+
n.addOptimistic(y, { kind: "text", text: `⚠️ Upload failed: ${C.message}` }), L.render(n);
|
|
2300
2300
|
}
|
|
2301
2301
|
},
|
|
2302
2302
|
onInvoke(d, p) {
|
|
2303
|
-
o &&
|
|
2303
|
+
o && b.send({ type: "invoke", conversationId: o, actionId: d, clientInvokeId: `iv_${Math.random().toString(36).slice(2)}`, ...p ? { inputs: p } : {} });
|
|
2304
2304
|
},
|
|
2305
2305
|
onTyping(d, p) {
|
|
2306
|
-
o &&
|
|
2306
|
+
o && b.send({ type: "typing", conversationId: o, isTyping: d, ...p ? { preview: p } : {} });
|
|
2307
2307
|
},
|
|
2308
2308
|
onReadUpTo(d) {
|
|
2309
|
-
o &&
|
|
2309
|
+
o && b.send({ type: "read", conversationId: o, seq: d });
|
|
2310
2310
|
},
|
|
2311
2311
|
onLoadMore() {
|
|
2312
|
-
if (!o || !
|
|
2313
|
-
const d =
|
|
2314
|
-
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 });
|
|
2315
2315
|
},
|
|
2316
2316
|
onEdit(d, p) {
|
|
2317
|
-
o &&
|
|
2317
|
+
o && b.send({ type: "edit", conversationId: o, messageId: d, content: { kind: "text", text: p } });
|
|
2318
2318
|
},
|
|
2319
2319
|
onDelete(d) {
|
|
2320
|
-
o &&
|
|
2320
|
+
o && b.send({ type: "delete", conversationId: o, messageId: d });
|
|
2321
2321
|
},
|
|
2322
2322
|
onReact(d, p, y) {
|
|
2323
|
-
o &&
|
|
2323
|
+
o && b.send({ type: "react", conversationId: o, messageId: d, emoji: p, remove: y });
|
|
2324
2324
|
},
|
|
2325
2325
|
onCsat(d) {
|
|
2326
|
-
|
|
2327
|
-
const p = ze(s.url);
|
|
2328
|
-
fetch(`${p}/conversations/${o}/csat`, {
|
|
2326
|
+
o && fetch(`${t}/conversations/${o}/csat`, {
|
|
2329
2327
|
method: "POST",
|
|
2330
2328
|
headers: { "Content-Type": "application/json", Authorization: `Bearer ${e}` },
|
|
2331
2329
|
body: JSON.stringify({ score: d })
|
|
@@ -2333,23 +2331,22 @@ function Ot(s) {
|
|
|
2333
2331
|
});
|
|
2334
2332
|
},
|
|
2335
2333
|
onAnnotate(d) {
|
|
2336
|
-
o &&
|
|
2334
|
+
o && b.send({ type: "annotate", conversationId: o, stroke: d });
|
|
2337
2335
|
},
|
|
2338
2336
|
onAnnotateClear() {
|
|
2339
|
-
o &&
|
|
2337
|
+
o && b.send({ type: "annotate_clear", conversationId: o });
|
|
2340
2338
|
},
|
|
2341
2339
|
...s.translateLang ? {
|
|
2342
2340
|
async onTranslate(d) {
|
|
2343
|
-
const p = s.url.replace(/^ws/, "http").replace(/\/+$/, "");
|
|
2344
2341
|
try {
|
|
2345
|
-
const
|
|
2342
|
+
const p = await fetch(`${t}/translate`, {
|
|
2346
2343
|
method: "POST",
|
|
2347
2344
|
headers: { "content-type": "application/json", authorization: `Bearer ${e}` },
|
|
2348
2345
|
body: JSON.stringify({ text: d, targetLang: s.translateLang })
|
|
2349
2346
|
});
|
|
2350
|
-
if (!
|
|
2351
|
-
const { translated:
|
|
2352
|
-
return
|
|
2347
|
+
if (!p.ok) return null;
|
|
2348
|
+
const { translated: y } = await p.json();
|
|
2349
|
+
return y;
|
|
2353
2350
|
} catch {
|
|
2354
2351
|
return null;
|
|
2355
2352
|
}
|
|
@@ -2360,8 +2357,8 @@ function Ot(s) {
|
|
|
2360
2357
|
...s.quickReplies ? { quickReplies: s.quickReplies } : {},
|
|
2361
2358
|
...s.accent ? { accent: s.accent } : {},
|
|
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 } : {} } } : {},
|
|
2363
|
-
i18n:
|
|
2364
|
-
}),
|
|
2360
|
+
i18n: Ie
|
|
2361
|
+
}), Te = {
|
|
2365
2362
|
type: "open",
|
|
2366
2363
|
profileId: s.profileId,
|
|
2367
2364
|
...s.subjectId ? { subjectId: s.subjectId } : {},
|
|
@@ -2371,70 +2368,70 @@ function Ot(s) {
|
|
|
2371
2368
|
// This is how listingTitle and listingMeta get saved without a separate API call.
|
|
2372
2369
|
...(le = s.subject) != null && le.title ? { subjectTitle: s.subject.title } : {},
|
|
2373
2370
|
...(he = s.subject) != null && he.subtitle ? { subjectMeta: s.subject.subtitle } : {}
|
|
2374
|
-
},
|
|
2371
|
+
}, Ue = (d) => {
|
|
2375
2372
|
const p = s.user;
|
|
2376
2373
|
if (!p || !p.name && !p.email && !p.avatar && !p.meta) return;
|
|
2377
2374
|
const y = [];
|
|
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,
|
|
2379
|
-
|
|
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]
|
|
2380
2377
|
${y.join(`
|
|
2381
2378
|
`)}` });
|
|
2382
2379
|
};
|
|
2383
|
-
|
|
2380
|
+
b = new bt({
|
|
2384
2381
|
url: s.url,
|
|
2385
2382
|
token: e,
|
|
2386
|
-
open:
|
|
2387
|
-
getCursor: () =>
|
|
2383
|
+
open: Te,
|
|
2384
|
+
getCursor: () => n.highestSeq(),
|
|
2388
2385
|
onStatusChange: (d) => L.setConnStatus(d),
|
|
2389
2386
|
onFrame(d) {
|
|
2390
2387
|
if (d.type === "opened") {
|
|
2391
2388
|
const p = o === void 0;
|
|
2392
|
-
if (o = d.conversation.id, !
|
|
2393
|
-
|
|
2394
|
-
for (const y of
|
|
2395
|
-
|
|
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 });
|
|
2396
2393
|
}
|
|
2397
|
-
|
|
2394
|
+
ze(s.url, e, o, n, L, t), g.length && U(o), p && d.conversation.lastSeq === 0 && Ue(o);
|
|
2398
2395
|
}
|
|
2399
|
-
if (d.type === "ack" &&
|
|
2400
|
-
d.bundle && (
|
|
2401
|
-
const y = [...
|
|
2402
|
-
for (const C of y)
|
|
2403
|
-
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);
|
|
2404
2401
|
}));
|
|
2405
2402
|
return;
|
|
2406
2403
|
}
|
|
2407
|
-
if (d.type === "message" &&
|
|
2404
|
+
if (d.type === "message" && n.e2e) {
|
|
2408
2405
|
const p = zt(d.message.content);
|
|
2409
2406
|
if (p && !I.ready) {
|
|
2410
2407
|
I.x3dhReceiveFrom(p.x3dhIK, p.x3dhEK, p.x3dhSPK).then(async () => {
|
|
2411
|
-
await I.openFrame(d),
|
|
2408
|
+
await I.openFrame(d), n.apply(d), L.render(n);
|
|
2412
2409
|
});
|
|
2413
2410
|
return;
|
|
2414
2411
|
}
|
|
2415
2412
|
}
|
|
2416
2413
|
if (d.type === "peerkey") {
|
|
2417
2414
|
I.onPeerKey(d.key).then(() => {
|
|
2418
|
-
|
|
2415
|
+
Q(), L.render(n);
|
|
2419
2416
|
});
|
|
2420
2417
|
return;
|
|
2421
2418
|
}
|
|
2422
2419
|
(async () => {
|
|
2423
|
-
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) {
|
|
2424
2421
|
K = !0;
|
|
2425
2422
|
const p = await I.initX3DH();
|
|
2426
|
-
|
|
2423
|
+
b.send({ type: "uploadPrekeys", ...p });
|
|
2427
2424
|
const y = await I.begin();
|
|
2428
|
-
|
|
2425
|
+
b.send({ type: "pubkey", conversationId: o, key: y });
|
|
2429
2426
|
}
|
|
2430
|
-
L.render(
|
|
2427
|
+
L.render(n);
|
|
2431
2428
|
})();
|
|
2432
2429
|
}
|
|
2433
|
-
}),
|
|
2430
|
+
}), b.connect(), L.render(n);
|
|
2434
2431
|
const ae = { close: () => {
|
|
2435
|
-
|
|
2432
|
+
b.close(), m == null || m.remove(), L.destroy(), w && x && w.removeEventListener("change", x), H.delete(s.el);
|
|
2436
2433
|
} };
|
|
2437
|
-
return
|
|
2434
|
+
return H.set(s.el, ae), ae;
|
|
2438
2435
|
}
|
|
2439
2436
|
export {
|
|
2440
2437
|
gt as ChatStore,
|
|
@@ -2444,9 +2441,9 @@ export {
|
|
|
2444
2441
|
$t as Renderer,
|
|
2445
2442
|
jt as asConversationId,
|
|
2446
2443
|
zt as extractX3DHInit,
|
|
2447
|
-
|
|
2444
|
+
Ae as httpBaseFromWsUrl,
|
|
2448
2445
|
Ot as mount,
|
|
2449
|
-
|
|
2446
|
+
ze as restoreHistory,
|
|
2450
2447
|
qt as unmount
|
|
2451
2448
|
};
|
|
2452
2449
|
//# sourceMappingURL=index.js.map
|