@ikonai/sdk-ui 1.0.41 → 1.0.43

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.
@@ -1,2832 +0,0 @@
1
- const ee = {
2
- Compressed: 8
3
- };
4
- function se(t) {
5
- if (t.length < 8)
6
- throw new Error("Protocol message too short");
7
- return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
8
- }
9
- function et(t) {
10
- const s = $(t), e = new DataView(s.buffer, s.byteOffset, s.byteLength);
11
- if (s.length < 27)
12
- throw new Error("Protocol payload too short");
13
- const r = e.getUint32(0, !0), n = e.getUint32(4, !0), i = e.getUint32(8, !0), o = e.getUint32(12, !0), a = e.getUint32(16, !0), E = e.getUint32(20, !0), l = e.getUint8(24), I = e.getUint8(25), _ = e.getUint8(26);
14
- if (27 + E * 4 > s.length)
15
- throw new Error("Protocol header exceeds payload length");
16
- const N = [];
17
- let u = 27;
18
- for (let y = 0; y < E; y++)
19
- N.push(e.getUint32(u, !0)), u += 4;
20
- return {
21
- length: r,
22
- opcode: n,
23
- senderId: i,
24
- trackId: o,
25
- sequenceId: a,
26
- targetIds: N,
27
- payloadVersion: l,
28
- payloadType: I,
29
- flags: _
30
- };
31
- }
32
- async function K(t, s, e) {
33
- const r = $(t), n = et(r);
34
- if (s !== void 0 && n.opcode !== s)
35
- throw new Error(`Unexpected opcode ${n.opcode}`);
36
- if (n.payloadType !== 8)
37
- throw new Error(`Unexpected payload type ${n.payloadType}`);
38
- const i = 27 + n.targetIds.length * 4;
39
- let o = r.subarray(i, n.length);
40
- return (n.flags & ee.Compressed) !== 0 && (o = await re(o)), o;
41
- }
42
- async function re(t) {
43
- if (typeof DecompressionStream > "u")
44
- throw new Error("DecompressionStream not supported");
45
- const s = new DecompressionStream("gzip"), e = s.writable.getWriter(), r = new Uint8Array(t);
46
- e.write(r), e.close();
47
- const n = s.readable.getReader(), i = [];
48
- let o = 0;
49
- for (; ; ) {
50
- const { done: l, value: I } = await n.read();
51
- if (l) break;
52
- i.push(I), o += I.length;
53
- }
54
- const a = new Uint8Array(o);
55
- let E = 0;
56
- for (let l = 0; l < i.length; l++)
57
- a.set(i[l], E), E += i[l].length;
58
- return a;
59
- }
60
- var v = /* @__PURE__ */ ((t) => (t[t.Null = 1] = "Null", t[t.Bool = 2] = "Bool", t[t.Int32 = 3] = "Int32", t[t.Int64 = 4] = "Int64", t[t.UInt32 = 5] = "UInt32", t[t.UInt64 = 6] = "UInt64", t[t.Float32 = 7] = "Float32", t[t.Float64 = 8] = "Float64", t[t.Array = 9] = "Array", t[t.Dict = 10] = "Dict", t[t.Object = 11] = "Object", t[t.String = 12] = "String", t[t.Binary = 13] = "Binary", t[t.Guid = 14] = "Guid", t))(v || {});
61
- const ne = 161, ie = 162;
62
- new TextEncoder();
63
- const oe = new TextDecoder("utf-8", { fatal: !0 });
64
- class O {
65
- constructor(s, e, r) {
66
- this.buffer = s, this.version = e, this.offset = r, this.end = s.length - 1;
67
- }
68
- offset;
69
- end;
70
- static create(s) {
71
- const e = $(s);
72
- if (e.length < 2)
73
- throw new Error("Teleport payload too short");
74
- if (e[0] !== ne || e[e.length - 1] !== ie)
75
- throw new Error("Teleport object missing markers");
76
- const r = { offset: 1 }, n = D(e, r, "InvalidLength");
77
- return new O(e, n, r.offset);
78
- }
79
- next() {
80
- if (this.offset >= this.end)
81
- return null;
82
- if (this.offset + 5 > this.buffer.length)
83
- throw new Error("Teleport object truncated");
84
- const s = Ee(this.buffer, this.offset);
85
- this.offset += 4;
86
- const e = this.buffer[this.offset++], r = e >> 4 & 15;
87
- if ((e & 15) !== 0)
88
- throw new Error("Teleport field flags must be zero");
89
- const n = M(r);
90
- let i;
91
- if (n >= 0)
92
- d(this.buffer, this.offset, n), i = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
93
- else {
94
- const o = { offset: this.offset }, a = D(this.buffer, o, "InvalidLength");
95
- d(this.buffer, o.offset, a), i = this.buffer.subarray(o.offset, o.offset + a), this.offset = o.offset + a;
96
- }
97
- return new ae(s, r, i);
98
- }
99
- }
100
- class U {
101
- constructor(s, e) {
102
- this.type = s, this.payload = e;
103
- }
104
- asInt32() {
105
- return this.ensureType(
106
- 3
107
- /* Int32 */
108
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getInt32(0, !0);
109
- }
110
- asUInt32() {
111
- return this.ensureType(
112
- 5
113
- /* UInt32 */
114
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getUint32(0, !0);
115
- }
116
- asInt64() {
117
- return this.ensureType(
118
- 4
119
- /* Int64 */
120
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigInt64(0, !0);
121
- }
122
- asUInt64() {
123
- return this.ensureType(
124
- 6
125
- /* UInt64 */
126
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigUint64(0, !0);
127
- }
128
- asFloat32() {
129
- return this.ensureType(
130
- 7
131
- /* Float32 */
132
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getFloat32(0, !0);
133
- }
134
- asFloat64() {
135
- return this.ensureType(
136
- 8
137
- /* Float64 */
138
- ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getFloat64(0, !0);
139
- }
140
- asBool() {
141
- return this.ensureType(
142
- 2
143
- /* Bool */
144
- ), this.payload.length > 0 && this.payload[0] !== 0;
145
- }
146
- asBinary() {
147
- return this.ensureType(
148
- 13
149
- /* Binary */
150
- ), this.payload;
151
- }
152
- asUtf8() {
153
- return this.ensureType(
154
- 12
155
- /* String */
156
- ), this.payload;
157
- }
158
- asString() {
159
- return this.ensureType(
160
- 12
161
- /* String */
162
- ), oe.decode(this.payload);
163
- }
164
- asGuid() {
165
- return this.ensureType(
166
- 14
167
- /* Guid */
168
- ), T.fromBytes(this.payload);
169
- }
170
- asObject() {
171
- return this.ensureType(
172
- 11
173
- /* Object */
174
- ), O.create(this.payload);
175
- }
176
- asArray() {
177
- return this.ensureType(
178
- 9
179
- /* Array */
180
- ), st.create(this.payload);
181
- }
182
- asDictionary() {
183
- return this.ensureType(
184
- 10
185
- /* Dict */
186
- ), rt.create(this.payload);
187
- }
188
- ensureType(s) {
189
- if (this.type !== s)
190
- throw new Error(`Teleport value has type ${v[this.type]}, expected ${v[s]}`);
191
- }
192
- }
193
- class ae extends U {
194
- constructor(s, e, r) {
195
- super(e, r), this.fieldId = s;
196
- }
197
- get isNull() {
198
- return this.type === 1;
199
- }
200
- }
201
- class st {
202
- payload;
203
- elementType;
204
- count;
205
- offset;
206
- index = 0;
207
- constructor(s) {
208
- if (this.payload = s, s.length === 0)
209
- throw new Error("Array payload too short");
210
- const e = s[0];
211
- if (this.elementType = e >> 4 & 15, (e & 15) !== 0)
212
- throw new Error("Array flags must be zero");
213
- const r = { offset: 1 };
214
- this.count = D(s, r, "ArrayMalformed"), this.offset = r.offset;
215
- }
216
- static create(s) {
217
- return new st($(s));
218
- }
219
- next() {
220
- if (this.index >= this.count) {
221
- if (this.offset !== this.payload.length)
222
- throw new Error("Array payload contains trailing data");
223
- return null;
224
- }
225
- const s = this.readValue();
226
- return this.index++, s;
227
- }
228
- readValue() {
229
- switch (this.elementType) {
230
- case 3:
231
- case 5:
232
- case 7:
233
- case 8:
234
- case 2:
235
- case 4:
236
- case 6:
237
- case 14: {
238
- const s = M(this.elementType);
239
- d(this.payload, this.offset, s);
240
- const e = this.payload.subarray(this.offset, this.offset + s);
241
- return this.offset += s, new V(this.elementType, e);
242
- }
243
- case 12:
244
- case 13: {
245
- const s = { offset: this.offset }, e = D(this.payload, s, "ArrayMalformed");
246
- d(this.payload, s.offset, e);
247
- const r = this.payload.subarray(s.offset, s.offset + e);
248
- return this.offset = s.offset + e, new V(this.elementType, r);
249
- }
250
- case 11: {
251
- const s = { offset: this.offset }, e = D(this.payload, s, "ArrayMalformed");
252
- d(this.payload, s.offset, e);
253
- const r = this.payload.subarray(s.offset, s.offset + e);
254
- return this.offset = s.offset + e, new V(11, r);
255
- }
256
- case 9: {
257
- const s = nt(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + s);
258
- return this.offset += s, new V(9, e);
259
- }
260
- case 10: {
261
- const s = it(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + s);
262
- return this.offset += s, new V(10, e);
263
- }
264
- default:
265
- throw new Error(`Unsupported array element type ${v[this.elementType]}`);
266
- }
267
- }
268
- }
269
- class V extends U {
270
- constructor(s, e) {
271
- super(s, e);
272
- }
273
- }
274
- class rt {
275
- payload;
276
- keyType;
277
- valueType;
278
- count;
279
- offset;
280
- index = 0;
281
- constructor(s) {
282
- if (this.payload = s, s.length < 2)
283
- throw new Error("Dictionary payload too short");
284
- if (this.keyType = s[0] >> 4 & 15, this.valueType = s[1] >> 4 & 15, (s[0] & 15) !== 0 || (s[1] & 15) !== 0)
285
- throw new Error("Dictionary key/value flags must be zero");
286
- Et(this.keyType);
287
- const e = { offset: 2 };
288
- this.count = D(s, e, "DictMalformed"), this.offset = e.offset;
289
- }
290
- static create(s) {
291
- return new rt($(s));
292
- }
293
- next() {
294
- if (this.index >= this.count) {
295
- if (this.offset !== this.payload.length)
296
- throw new Error("Dictionary payload contains trailing data");
297
- return null;
298
- }
299
- const s = this.readKey(), e = this.readValue();
300
- return this.index++, new le(s, e);
301
- }
302
- readKey() {
303
- const s = M(this.keyType);
304
- if (s >= 0) {
305
- d(this.payload, this.offset, s);
306
- const e = this.payload.subarray(this.offset, this.offset + s);
307
- return this.offset += s, new U(this.keyType, e);
308
- }
309
- if (this.keyType === 12 || this.keyType === 13) {
310
- const e = { offset: this.offset }, r = D(this.payload, e, "DictMalformed");
311
- d(this.payload, e.offset, r);
312
- const n = this.payload.subarray(e.offset, e.offset + r);
313
- return this.offset = e.offset + r, new U(this.keyType, n);
314
- }
315
- throw new Error("Unsupported dictionary key type");
316
- }
317
- readValue() {
318
- switch (this.valueType) {
319
- case 12:
320
- case 13: {
321
- const s = { offset: this.offset }, e = D(this.payload, s, "DictMalformed");
322
- d(this.payload, s.offset, e);
323
- const r = this.payload.subarray(s.offset, s.offset + e);
324
- return this.offset = s.offset + e, new U(this.valueType, r);
325
- }
326
- case 11: {
327
- const s = { offset: this.offset }, e = D(this.payload, s, "DictMalformed");
328
- d(this.payload, s.offset, e);
329
- const r = this.payload.subarray(s.offset, s.offset + e);
330
- return this.offset = s.offset + e, new U(11, r);
331
- }
332
- case 9: {
333
- const s = nt(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + s);
334
- return this.offset += s, new U(9, e);
335
- }
336
- case 10: {
337
- const s = it(this.payload, this.offset), e = this.payload.subarray(this.offset, this.offset + s);
338
- return this.offset += s, new U(10, e);
339
- }
340
- case 3:
341
- case 5:
342
- case 7:
343
- case 8:
344
- case 2:
345
- case 4:
346
- case 6:
347
- case 14:
348
- case 1: {
349
- const s = M(this.valueType);
350
- d(this.payload, this.offset, s);
351
- const e = this.payload.subarray(this.offset, this.offset + s);
352
- return this.offset += s, new U(this.valueType, e);
353
- }
354
- default:
355
- throw new Error(`Unsupported dictionary value type ${v[this.valueType]}`);
356
- }
357
- }
358
- }
359
- class le {
360
- constructor(s, e) {
361
- this.key = s, this.value = e;
362
- }
363
- }
364
- class T {
365
- constructor(s) {
366
- this.bytes = s;
367
- }
368
- static fromString(s) {
369
- if (!s)
370
- throw new Error("Guid string is empty");
371
- const e = s.replace(/-/g, "");
372
- if (e.length !== 32)
373
- throw new Error("Guid string must be 32 hex characters");
374
- const r = new Uint8Array(16), n = T.parseHexSlice(e, 0, 8), i = T.parseHexSlice(e, 8, 4), o = T.parseHexSlice(e, 12, 4);
375
- T.writeUInt32LE(r, 0, n), T.writeUInt16LE(r, 4, i), T.writeUInt16LE(r, 6, o);
376
- for (let a = 0; a < 8; a++)
377
- r[8 + a] = T.parseHexSlice(e, 16 + a * 2, 2);
378
- return new T(r);
379
- }
380
- static fromBytes(s) {
381
- if (s.length !== 16)
382
- throw new Error("Guid byte array must be 16 bytes");
383
- return new T(Uint8Array.from(s));
384
- }
385
- static createZero() {
386
- return new T(new Uint8Array(16));
387
- }
388
- static createRandom() {
389
- const s = new Uint8Array(16), e = globalThis.crypto;
390
- if (e?.getRandomValues)
391
- e.getRandomValues(s);
392
- else
393
- for (let r = 0; r < s.length; r++)
394
- s[r] = Math.floor(Math.random() * 256);
395
- return s[6] = s[6] & 15 | 64, s[8] = s[8] & 63 | 128, new T(s);
396
- }
397
- toString() {
398
- const s = this.bytes;
399
- return [
400
- T.toHex(T.readUInt32LE(s, 0), 8),
401
- T.toHex(T.readUInt16LE(s, 4), 4),
402
- T.toHex(T.readUInt16LE(s, 6), 4),
403
- at(s.subarray(8, 10)),
404
- at(s.subarray(10, 16))
405
- ].join("-");
406
- }
407
- asBytes() {
408
- return this.bytes.slice();
409
- }
410
- static parseHexSlice(s, e, r) {
411
- const n = s.substr(e, r), i = Number.parseInt(n, 16);
412
- if (Number.isNaN(i))
413
- throw new Error("Guid string contains invalid characters");
414
- return i >>> 0;
415
- }
416
- static writeUInt32LE(s, e, r) {
417
- const n = r >>> 0;
418
- s[e] = n & 255, s[e + 1] = n >>> 8 & 255, s[e + 2] = n >>> 16 & 255, s[e + 3] = n >>> 24 & 255;
419
- }
420
- static writeUInt16LE(s, e, r) {
421
- const n = r & 65535;
422
- s[e] = n & 255, s[e + 1] = n >>> 8 & 255;
423
- }
424
- static readUInt32LE(s, e) {
425
- return (s[e] | s[e + 1] << 8 | s[e + 2] << 16 | s[e + 3] << 24) >>> 0;
426
- }
427
- static readUInt16LE(s, e) {
428
- return (s[e] | s[e + 1] << 8) & 65535;
429
- }
430
- static toHex(s, e) {
431
- return (s >>> 0).toString(16).padStart(e, "0");
432
- }
433
- }
434
- function D(t, s, e) {
435
- if (s.offset >= t.length)
436
- throw new Error(e);
437
- let r = 0, n = 0, i = 0;
438
- for (; s.offset < t.length; ) {
439
- const o = t[s.offset++];
440
- if (i++, r |= (o & 127) << n, (o & 128) === 0) {
441
- if (i !== Ie(r))
442
- throw new Error("Teleport VarUInt is not canonical");
443
- return r >>> 0;
444
- }
445
- if (n += 7, n >= 35)
446
- throw new Error("Teleport VarUInt exceeds 32-bit range");
447
- }
448
- throw new Error(e);
449
- }
450
- function Ie(t) {
451
- return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
452
- }
453
- function M(t) {
454
- switch (t) {
455
- case 3:
456
- case 5:
457
- case 7:
458
- return 4;
459
- case 4:
460
- case 6:
461
- case 8:
462
- return 8;
463
- case 14:
464
- return 16;
465
- case 2:
466
- return 1;
467
- case 1:
468
- return 0;
469
- default:
470
- return -1;
471
- }
472
- }
473
- function Et(t) {
474
- if (t === 9 || t === 11 || t === 10 || t === 1)
475
- throw new Error("Dictionary keys must be primitive Teleport types");
476
- }
477
- function d(t, s, e) {
478
- if (s < 0 || e < 0 || s + e > t.length)
479
- throw new Error("Teleport payload exceeds bounds");
480
- }
481
- function Ee(t, s) {
482
- return (t[s] | t[s + 1] << 8 | t[s + 2] << 16 | t[s + 3] << 24) >>> 0;
483
- }
484
- function nt(t, s) {
485
- if (s >= t.length)
486
- throw new Error("Array payload exceeds bounds");
487
- const e = t[s], r = e >> 4 & 15;
488
- if ((e & 15) !== 0)
489
- throw new Error("Array flags must be zero");
490
- const n = { offset: s + 1 }, i = D(t, n, "ArrayMalformed"), o = M(r);
491
- if (o >= 0) {
492
- const E = o * i;
493
- return d(t, n.offset, E), n.offset + E - s;
494
- }
495
- let a = n.offset;
496
- for (let E = 0; E < i; E++)
497
- a = q(r, t, a, "ArrayMalformed");
498
- return a - s;
499
- }
500
- function it(t, s) {
501
- if (s + 2 > t.length)
502
- throw new Error("Dictionary payload too short");
503
- const e = t[s] >> 4 & 15, r = t[s + 1] >> 4 & 15;
504
- if ((t[s] & 15) !== 0 || (t[s + 1] & 15) !== 0)
505
- throw new Error("Dictionary key/value flags must be zero");
506
- Et(e);
507
- const n = { offset: s + 2 }, i = D(t, n, "DictMalformed");
508
- let o = n.offset;
509
- for (let a = 0; a < i; a++)
510
- o = q(e, t, o, "DictMalformed"), o = q(r, t, o, "DictMalformed");
511
- return o - s;
512
- }
513
- function q(t, s, e, r) {
514
- const n = M(t);
515
- if (n >= 0)
516
- return d(s, e, n), e + n;
517
- switch (t) {
518
- case 12:
519
- case 13: {
520
- const i = { offset: e }, o = D(s, i, r);
521
- return d(s, i.offset, o), i.offset + o;
522
- }
523
- case 11: {
524
- const i = { offset: e }, o = D(s, i, r);
525
- return d(s, i.offset, o), i.offset + o;
526
- }
527
- case 9:
528
- return e + nt(s, e);
529
- case 10:
530
- return e + it(s, e);
531
- default:
532
- throw new Error(`Unsupported Teleport type ${v[t]}`);
533
- }
534
- }
535
- function at(t) {
536
- return Array.from(t).map((s) => s.toString(16).padStart(2, "0")).join("");
537
- }
538
- function $(t) {
539
- return t instanceof Uint8Array ? t : new Uint8Array(t);
540
- }
541
- var _t = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(_t || {}), ct = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.MobileWeb = 1] = "MobileWeb", t[t.MobileApp = 2] = "MobileApp", t[t.DesktopWeb = 3] = "DesktopWeb", t[t.DesktopApp = 4] = "DesktopApp", t))(ct || {}), ft = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Backend = 2] = "Backend", t[t.Server = 4] = "Server", t[t.Plugin = 8] = "Plugin", t[t.Browser = 16] = "Browser", t))(ft || {}), ht = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.MessagePack = 1] = "MessagePack", t[t.MemoryPack = 2] = "MemoryPack", t[t.Json = 4] = "Json", t[t.Teleport = 8] = "Teleport", t[t.All = 15] = "All", t))(ht || {}), ut = /* @__PURE__ */ ((t) => (t[t.Face = 0] = "Face", t[t.Hands = 1] = "Hands", t[t.Pose = 2] = "Pose", t[t.All = 3] = "All", t))(ut || {}), Tt = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Machine = 1] = "Machine", t[t.Human = 2] = "Human", t))(Tt || {}), At = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Vp8 = 2] = "Vp8", t[t.Vp9 = 3] = "Vp9", t[t.Av1 = 4] = "Av1", t))(At || {}), Nt = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.DotNet = 1] = "DotNet", t[t.TypeScript = 2] = "TypeScript", t[t.Cpp = 3] = "Cpp", t))(Nt || {}), St = /* @__PURE__ */ ((t) => (t[t.Local = 0] = "Local", t[t.Cloud = 1] = "Cloud", t))(St || {}), dt = /* @__PURE__ */ ((t) => (t[t.Bundle = 0] = "Bundle", t[t.GitSource = 1] = "GitSource", t))(dt || {}), P = /* @__PURE__ */ ((t) => (t[t.NONE = 0] = "NONE", t[t.CONSTANT_GROUP_BITS = 15] = "CONSTANT_GROUP_BITS", t[t.CONSTANT_GROUP_OFFSET = 16] = "CONSTANT_GROUP_OFFSET", t[t.GROUP_CORE = 65536] = "GROUP_CORE", t[t.CORE_AUTH_RESPONSE = 65537] = "CORE_AUTH_RESPONSE", t[t.CORE_AUTH_TICKET = 65538] = "CORE_AUTH_TICKET", t[t.CORE_GLOBAL_STATE = 65539] = "CORE_GLOBAL_STATE", t[t.CORE_ON_SERVER_STATUS_PING = 65540] = "CORE_ON_SERVER_STATUS_PING", t[t.CORE_ON_USER_JOINED = 65541] = "CORE_ON_USER_JOINED", t[t.CORE_ON_USER_LEFT = 65542] = "CORE_ON_USER_LEFT", t[t.CORE_ON_CLIENT_JOINED = 65543] = "CORE_ON_CLIENT_JOINED", t[t.CORE_ON_CLIENT_LEFT = 65544] = "CORE_ON_CLIENT_LEFT", t[t.CORE_ON_SERVER_STARTED = 65545] = "CORE_ON_SERVER_STARTED", t[t.CORE_ON_SERVER_STOPPED = 65546] = "CORE_ON_SERVER_STOPPED", t[t.CORE_ON_SERVER_STOPPING = 65547] = "CORE_ON_SERVER_STOPPING", t[t.CORE_ON_CLIENT_READY = 65548] = "CORE_ON_CLIENT_READY", t[t.CORE_CLIENT_READY = 65549] = "CORE_CLIENT_READY", t[t.CORE_SERVER_INIT = 65550] = "CORE_SERVER_INIT", t[t.CORE_ON_PLUGIN_RELOADED = 65551] = "CORE_ON_PLUGIN_RELOADED", t[t.CORE_SERVER_START = 65552] = "CORE_SERVER_START", t[t.CORE_SERVER_STOP = 65553] = "CORE_SERVER_STOP", t[t.CORE_ON_HOSTED_SERVER_EXIT = 65554] = "CORE_ON_HOSTED_SERVER_EXIT", t[t.CORE_DYNAMIC_CONFIG = 65555] = "CORE_DYNAMIC_CONFIG", t[t.CORE_PROXY_RPC_AUTH_TICKET = 65556] = "CORE_PROXY_RPC_AUTH_TICKET", t[t.CORE_SERVER_INIT2 = 65557] = "CORE_SERVER_INIT2", t[t.CORE_UPDATE_CLIENT_CONTEXT = 65558] = "CORE_UPDATE_CLIENT_CONTEXT", t[t.CORE_BACKGROUND_WORK_ACTIVE = 65559] = "CORE_BACKGROUND_WORK_ACTIVE", t[t.CORE_WEBRTC_OFFER = 65566] = "CORE_WEBRTC_OFFER", t[t.CORE_WEBRTC_ANSWER = 65567] = "CORE_WEBRTC_ANSWER", t[t.CORE_WEBRTC_ICE_CANDIDATE = 65568] = "CORE_WEBRTC_ICE_CANDIDATE", t[t.CORE_WEBRTC_READY = 65569] = "CORE_WEBRTC_READY", t[t.CORE_WEBRTC_AUDIO_SEGMENT = 65570] = "CORE_WEBRTC_AUDIO_SEGMENT", t[t.CORE_WEBRTC_TRACK_MAP = 65571] = "CORE_WEBRTC_TRACK_MAP", t[t.GROUP_KEEPALIVE = 131072] = "GROUP_KEEPALIVE", t[t.KEEPALIVE_REQUEST = 131073] = "KEEPALIVE_REQUEST", t[t.KEEPALIVE_RESPONSE = 131074] = "KEEPALIVE_RESPONSE", t[t.GROUP_EVENTS = 262144] = "GROUP_EVENTS", t[t.EVENTS_PROFILE_UPDATE = 262145] = "EVENTS_PROFILE_UPDATE", t[t.EVENTS_CHANNEL_COMPLETE = 262146] = "EVENTS_CHANNEL_COMPLETE", t[t.EVENTS_SPEECH_PLAYBACK_COMPLETE = 262147] = "EVENTS_SPEECH_PLAYBACK_COMPLETE", t[t.GROUP_ANALYTICS = 524288] = "GROUP_ANALYTICS", t[t.ANALYTICS_LOGS = 524289] = "ANALYTICS_LOGS", t[t.ANALYTICS_EVENTS = 524290] = "ANALYTICS_EVENTS", t[t.ANALYTICS_USAGES = 524291] = "ANALYTICS_USAGES", t[t.ANALYTICS_USAGE = 524292] = "ANALYTICS_USAGE", t[t.ANALYTICS_SPECIAL_LOG = 524293] = "ANALYTICS_SPECIAL_LOG", t[t.ANALYTICS_PROCESSING_UPDATE = 524294] = "ANALYTICS_PROCESSING_UPDATE", t[t.ANALYTICS_REACTIVE_PROCESSING_UPDATE = 524295] = "ANALYTICS_REACTIVE_PROCESSING_UPDATE", t[t.ANALYTICS_IKON_PROXY_SERVER_STATS = 524296] = "ANALYTICS_IKON_PROXY_SERVER_STATS", t[t.GROUP_ACTIONS = 1048576] = "GROUP_ACTIONS", t[t.ACTION_CALL = 1048577] = "ACTION_CALL", t[t.ACTION_ACTIVE = 1048578] = "ACTION_ACTIVE", t[t.ACTION_TEXT_OUTPUT = 1048579] = "ACTION_TEXT_OUTPUT", t[t.ACTION_TEXT_OUTPUT_DELTA = 1048580] = "ACTION_TEXT_OUTPUT_DELTA", t[t.ACTION_TEXT_OUTPUT_DELTA_FULL = 1048581] = "ACTION_TEXT_OUTPUT_DELTA_FULL", t[t.ACTION_SET_STATE = 1048582] = "ACTION_SET_STATE", t[t.ACTION_TAP = 1048583] = "ACTION_TAP", t[t.ACTION_PAN = 1048584] = "ACTION_PAN", t[t.ACTION_ZOOM = 1048585] = "ACTION_ZOOM", t[t.ACTION_FILE_UPLOAD_BEGIN = 1048586] = "ACTION_FILE_UPLOAD_BEGIN", t[t.ACTION_FILE_UPLOAD_DATA = 1048587] = "ACTION_FILE_UPLOAD_DATA", t[t.ACTION_FILE_UPLOAD_ACK = 1048588] = "ACTION_FILE_UPLOAD_ACK", t[t.ACTION_FILE_UPLOAD_END = 1048589] = "ACTION_FILE_UPLOAD_END", t[t.ACTION_FILE_UPLOAD_RESULT = 1048590] = "ACTION_FILE_UPLOAD_RESULT", t[t.ACTION_OPEN_CHANNEL = 1048591] = "ACTION_OPEN_CHANNEL", t[t.ACTION_OPEN_EXTERNAL_URL = 1048592] = "ACTION_OPEN_EXTERNAL_URL", t[t.ACTION_UI_OPEN_VIEW = 1048593] = "ACTION_UI_OPEN_VIEW", t[t.ACTION_UI_CLOSE_VIEW = 1048594] = "ACTION_UI_CLOSE_VIEW", t[t.ACTION_UI_BLOCKING_BEGIN = 1048595] = "ACTION_UI_BLOCKING_BEGIN", t[t.ACTION_UI_BLOCKING_END = 1048596] = "ACTION_UI_BLOCKING_END", t[t.ACTION_UI_UPDATE_TEXT_DELTA = 1048597] = "ACTION_UI_UPDATE_TEXT_DELTA", t[t.ACTION_UI_DELETE_CONTAINER = 1048598] = "ACTION_UI_DELETE_CONTAINER", t[t.ACTION_UPDATE_GFX_SHADER = 1048599] = "ACTION_UPDATE_GFX_SHADER", t[t.ACTION_FUNCTION_REGISTER = 1048600] = "ACTION_FUNCTION_REGISTER", t[t.ACTION_FUNCTION_CALL = 1048601] = "ACTION_FUNCTION_CALL", t[t.ACTION_FUNCTION_RESULT = 1048602] = "ACTION_FUNCTION_RESULT", t[t.ACTION_GENERATE_ANSWER = 1048603] = "ACTION_GENERATE_ANSWER", t[t.ACTION_REGENERATE_ANSWER = 1048604] = "ACTION_REGENERATE_ANSWER", t[t.ACTION_CLEAR_CHAT_MESSAGE_HISTORY = 1048605] = "ACTION_CLEAR_CHAT_MESSAGE_HISTORY", t[t.ACTION_CLEAR_STATE = 1048606] = "ACTION_CLEAR_STATE", t[t.ACTION_RELOAD_CHANNELS = 1048607] = "ACTION_RELOAD_CHANNELS", t[t.ACTION_RELOAD_PROFILE = 1048608] = "ACTION_RELOAD_PROFILE", t[t.ACTION_CLASSIFICATION_RESULT = 1048609] = "ACTION_CLASSIFICATION_RESULT", t[t.ACTION_AUDIO_STOP = 1048610] = "ACTION_AUDIO_STOP", t[t.ACTION_CALL_TEXT = 1048611] = "ACTION_CALL_TEXT", t[t.ACTION_RELOAD_APPLICATION = 1048612] = "ACTION_RELOAD_APPLICATION", t[t.ACTION_CANCEL_GENERATION = 1048613] = "ACTION_CANCEL_GENERATION", t[t.ACTION_UI_SET_CONTAINER_STABLE = 1048614] = "ACTION_UI_SET_CONTAINER_STABLE", t[t.ACTION_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", t[t.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", t[t.ACTION_RELOAD_PROVIDER = 1048617] = "ACTION_RELOAD_PROVIDER", t[t.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", t[t.ACTION_SCROLL_TO_CONTAINER = 1048619] = "ACTION_SCROLL_TO_CONTAINER", t[t.ACTION_UI_CLEAR_STREAM = 1048620] = "ACTION_UI_CLEAR_STREAM", t[t.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", t[t.ACTION_ENTER_FULLSCREEN = 1048622] = "ACTION_ENTER_FULLSCREEN", t[t.ACTION_STOP_SOUND = 1048623] = "ACTION_STOP_SOUND", t[t.ACTION_START_RECORDING = 1048624] = "ACTION_START_RECORDING", t[t.ACTION_STOP_RECORDING = 1048625] = "ACTION_STOP_RECORDING", t[t.ACTION_OPTIMISTIC_CLIENT_CALLS = 1048626] = "ACTION_OPTIMISTIC_CLIENT_CALLS", t[t.ACTION_FUNCTION_ENUMERATION_ITEM = 1048627] = "ACTION_FUNCTION_ENUMERATION_ITEM", t[t.ACTION_FUNCTION_ENUMERATION_END = 1048628] = "ACTION_FUNCTION_ENUMERATION_END", t[t.ACTION_FUNCTION_CANCEL = 1048629] = "ACTION_FUNCTION_CANCEL", t[t.ACTION_FUNCTION_DISPOSE = 1048630] = "ACTION_FUNCTION_DISPOSE", t[t.ACTION_FUNCTION_ERROR = 1048631] = "ACTION_FUNCTION_ERROR", t[t.ACTION_FUNCTION_ACK = 1048632] = "ACTION_FUNCTION_ACK", t[t.ACTION_FUNCTION_AWAITING_APPROVAL = 1048633] = "ACTION_FUNCTION_AWAITING_APPROVAL", t[t.ACTION_FUNCTION_APPROVAL_REQUIRED = 1048634] = "ACTION_FUNCTION_APPROVAL_REQUIRED", t[t.ACTION_FUNCTION_APPROVAL_RESPONSE = 1048635] = "ACTION_FUNCTION_APPROVAL_RESPONSE", t[t.UI_UPDATE_ACK = 1048636] = "UI_UPDATE_ACK", t[t.ACTION_CALL2 = 1048637] = "ACTION_CALL2", t[t.ACTION_FUNCTION_REGISTER_BATCH = 1048638] = "ACTION_FUNCTION_REGISTER_BATCH", t[t.ACTION_TRIGGER_GIT_PULL = 1048639] = "ACTION_TRIGGER_GIT_PULL", t[t.ACTION_FILE_UPLOAD_CALLBACK = 1048640] = "ACTION_FILE_UPLOAD_CALLBACK", t[t.ACTION_CUSTOM_USER_MESSAGE = 1048641] = "ACTION_CUSTOM_USER_MESSAGE", t[t.ACTION_URL_CHANGED = 1048642] = "ACTION_URL_CHANGED", t[t.ACTION_FILE_UPLOAD_PRE_START2 = 1048643] = "ACTION_FILE_UPLOAD_PRE_START2", t[t.ACTION_FILE_UPLOAD_PRE_START_RESPONSE2 = 1048644] = "ACTION_FILE_UPLOAD_PRE_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_START2 = 1048645] = "ACTION_FILE_UPLOAD_START2", t[t.ACTION_FILE_UPLOAD_START_RESPONSE2 = 1048646] = "ACTION_FILE_UPLOAD_START_RESPONSE2", t[t.ACTION_FILE_UPLOAD_DATA2 = 1048647] = "ACTION_FILE_UPLOAD_DATA2", t[t.ACTION_FILE_UPLOAD_ACK2 = 1048648] = "ACTION_FILE_UPLOAD_ACK2", t[t.ACTION_FILE_UPLOAD_END2 = 1048649] = "ACTION_FILE_UPLOAD_END2", t[t.ACTION_FILE_UPLOAD_COMPLETE2 = 1048650] = "ACTION_FILE_UPLOAD_COMPLETE2", t[t.ACTION_FUNCTION_ENUMERATION_ITEM_BATCH = 1048651] = "ACTION_FUNCTION_ENUMERATION_ITEM_BATCH", t[t.GROUP_UI = 2097152] = "GROUP_UI", t[t.UI_STREAM_BEGIN = 2097153] = "UI_STREAM_BEGIN", t[t.UI_STREAM_END = 2097154] = "UI_STREAM_END", t[t.UI_CONTAINER_BEGIN = 2097155] = "UI_CONTAINER_BEGIN", t[t.UI_CONTAINER_END = 2097156] = "UI_CONTAINER_END", t[t.UI_SECTION_BEGIN = 2097157] = "UI_SECTION_BEGIN", t[t.UI_SECTION_END = 2097158] = "UI_SECTION_END", t[t.UI_LIST_BEGIN = 2097159] = "UI_LIST_BEGIN", t[t.UI_LIST_ITEM = 2097160] = "UI_LIST_ITEM", t[t.UI_LIST_END = 2097161] = "UI_LIST_END", t[t.UI_TEXT = 2097162] = "UI_TEXT", t[t.UI_HEADER = 2097163] = "UI_HEADER", t[t.UI_SEPARATOR = 2097164] = "UI_SEPARATOR", t[t.UI_BUTTON = 2097165] = "UI_BUTTON", t[t.UI_ICON_BUTTON = 2097166] = "UI_ICON_BUTTON", t[t.UI_IMAGE = 2097167] = "UI_IMAGE", t[t.UI_FILE = 2097168] = "UI_FILE", t[t.UI_BADGE = 2097169] = "UI_BADGE", t[t.UI_CONTENT_LINK = 2097170] = "UI_CONTENT_LINK", t[t.UI_MAP = 2097171] = "UI_MAP", t[t.UI_VEGA_CHART = 2097172] = "UI_VEGA_CHART", t[t.UI_ICON = 2097173] = "UI_ICON", t[t.UI_FILE_UPLOAD_SECTION_BEGIN = 2097174] = "UI_FILE_UPLOAD_SECTION_BEGIN", t[t.UI_FILE_UPLOAD_SECTION_END = 2097175] = "UI_FILE_UPLOAD_SECTION_END", t[t.UI_MATERIAL_SYMBOL = 2097176] = "UI_MATERIAL_SYMBOL", t[t.UI_BUTTON_BEGIN = 2097177] = "UI_BUTTON_BEGIN", t[t.UI_BUTTON_END = 2097178] = "UI_BUTTON_END", t[t.UI_CONTAINER_DELETE = 2097179] = "UI_CONTAINER_DELETE", t[t.UI_INPUT_TEXT = 2097180] = "UI_INPUT_TEXT", t[t.UI_PROGRESS_BAR = 2097181] = "UI_PROGRESS_BAR", t[t.UI_UPDATE_BEGIN = 2097182] = "UI_UPDATE_BEGIN", t[t.UI_UPDATE_END = 2097183] = "UI_UPDATE_END", t[t.UI_AUTOCOMPLETE = 2097184] = "UI_AUTOCOMPLETE", t[t.UI_CHECKBOX = 2097185] = "UI_CHECKBOX", t[t.UI_QS = 2097186] = "UI_QS", t[t.UI_ELEMENT = 2097187] = "UI_ELEMENT", t[t.UI_STYLES = 2097188] = "UI_STYLES", t[t.UI_SVG = 2097189] = "UI_SVG", t[t.UI_UPDATE = 2097190] = "UI_UPDATE", t[t.UI_INIT = 2097191] = "UI_INIT", t[t.UI_STYLES_BATCH = 2097192] = "UI_STYLES_BATCH", t[t.UI_STYLES_DELETE = 2097193] = "UI_STYLES_DELETE", t[t.GROUP_COMMON = 4128768] = "GROUP_COMMON", t[t.GROUP_AUDIO = 4194304] = "GROUP_AUDIO", t[t.AUDIO_STREAM_BEGIN = 4194305] = "AUDIO_STREAM_BEGIN", t[t.AUDIO_STREAM_END = 4194306] = "AUDIO_STREAM_END", t[t.AUDIO_FRAME = 4194307] = "AUDIO_FRAME", t[t.AUDIO_FRAME_VOLUME = 4194308] = "AUDIO_FRAME_VOLUME", t[t.AUDIO_FRAME2 = 4194309] = "AUDIO_FRAME2", t[t.GROUP_VIDEO = 8388608] = "GROUP_VIDEO", t[t.VIDEO_STREAM_BEGIN = 8388609] = "VIDEO_STREAM_BEGIN", t[t.VIDEO_STREAM_END = 8388610] = "VIDEO_STREAM_END", t[t.VIDEO_FRAME = 8388611] = "VIDEO_FRAME", t[t.VIDEO_REQUEST_IDR_FRAME = 8388612] = "VIDEO_REQUEST_IDR_FRAME", t[t.VIDEO_INVALIDATE_FRAME = 8388613] = "VIDEO_INVALIDATE_FRAME", t[t.GROUP_TRACKING = 16777216] = "GROUP_TRACKING", t[t.TRACKING_STREAM_BEGIN = 16777217] = "TRACKING_STREAM_BEGIN", t[t.TRACKING_STREAM_END = 16777218] = "TRACKING_STREAM_END", t[t.TRACKING_FRAME = 16777219] = "TRACKING_FRAME", t[t.GROUP_SCENE = 33554432] = "GROUP_SCENE", t[t.SCENE_MESH = 33554433] = "SCENE_MESH", t[t.SCENE_ARRAY = 33554434] = "SCENE_ARRAY", t[t.GROUP_ALL = 67043328] = "GROUP_ALL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(P || {});
542
- const _e = 161083277, ce = 265814330, fe = 1368629611, he = 2431514951, ue = 2745379226, Te = 3282782683, Ae = 3284746250, Ne = 4101844078;
543
- function Ct(t) {
544
- const s = {};
545
- return yt(s), s;
546
- }
547
- function yt(t) {
548
- return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = _t.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t;
549
- }
550
- function Se(t, s) {
551
- const e = s ?? Ct();
552
- return yt(e), de(t, e), e;
553
- }
554
- function de(t, s) {
555
- let e;
556
- for (; (e = t.next()) !== null; )
557
- switch (e.fieldId) {
558
- case _e: {
559
- if (e.isNull) throw new Error();
560
- s.StreamId = e.asString();
561
- break;
562
- }
563
- case ce: {
564
- if (e.isNull) {
565
- s.ShapeSets = void 0;
566
- break;
567
- }
568
- s.ShapeSets = Ce(e.asArray());
569
- break;
570
- }
571
- case fe: {
572
- if (e.isNull) throw new Error();
573
- s.Description = e.asString();
574
- break;
575
- }
576
- case he: {
577
- if (e.isNull) throw new Error();
578
- s.Channels = e.asInt32();
579
- break;
580
- }
581
- case ue: {
582
- if (e.isNull) throw new Error();
583
- s.CodecDetails = e.asString();
584
- break;
585
- }
586
- case Te: {
587
- if (e.isNull) throw new Error();
588
- s.SourceType = e.asString();
589
- break;
590
- }
591
- case Ae: {
592
- if (e.isNull) throw new Error();
593
- s.Codec = e.asInt32();
594
- break;
595
- }
596
- case Ne: {
597
- if (e.isNull) throw new Error();
598
- s.SampleRate = e.asInt32();
599
- break;
600
- }
601
- }
602
- }
603
- function Ce(t) {
604
- const s = [];
605
- let e;
606
- for (; (e = t.next()) !== null; )
607
- s.push(Ue(e.asObject()));
608
- return s;
609
- }
610
- const ye = 1107713536, De = 1154362099, we = 1185721362;
611
- function Re(t) {
612
- const s = {};
613
- return Dt(s), s;
614
- }
615
- function Dt(t) {
616
- return t.SetId = 0, t.Name = "", t.ShapeNames = [], t;
617
- }
618
- function Ue(t, s) {
619
- const e = s ?? Re();
620
- return Dt(e), Le(t, e), e;
621
- }
622
- function Le(t, s) {
623
- let e;
624
- for (; (e = t.next()) !== null; )
625
- switch (e.fieldId) {
626
- case ye: {
627
- if (e.isNull) throw new Error();
628
- s.Name = e.asString();
629
- break;
630
- }
631
- case De: {
632
- if (e.isNull) throw new Error();
633
- s.SetId = e.asUInt32();
634
- break;
635
- }
636
- case we: {
637
- if (e.isNull) throw new Error();
638
- s.ShapeNames = me(e.asArray());
639
- break;
640
- }
641
- }
642
- }
643
- function me(t) {
644
- const s = [];
645
- let e;
646
- for (; (e = t.next()) !== null; )
647
- s.push(e.asString());
648
- return s;
649
- }
650
- const Oe = 76337612, Pe = 185396121, ge = 250031587, be = 388632637, Fe = 417197284, ve = 469070965, Me = 470595159, pe = 594855258, ke = 781727218, Ve = 834078886, Ge = 1043273762, Be = 1236999138, xe = 1286979607, He = 1368629611, Ye = 1715899485, Ke = 1942830531, $e = 1999510636, Xe = 2033288346, je = 2079864626, We = 2142346422, ze = 2232517119, Je = 2598291686, qe = 2719718823, Qe = 2810953526, Ze = 2840065720, ts = 2885165957, es = 3542818975, ss = 3586157513, rs = 3717933110, ns = 4062655306;
651
- function is(t) {
652
- const s = {};
653
- return wt(s), s;
654
- }
655
- function wt(t) {
656
- return t.ContextType = ft.Unknown, t.UserType = Tt.Unknown, t.PayloadType = ht.Unknown, t.Description = "", t.UserId = "", t.DeviceId = "", t.ProductId = "", t.VersionId = "", t.InstallId = "", t.Locale = "", t.SessionId = -1, t.IsInternal = !1, t.IsReady = !1, t.HasInput = !1, t.ChannelLocale = "", t.EmbeddedSpaceId = "", t.AuthSessionId = "", t.ReceiveAllMessages = !1, t.PreciseJoinedAt = 0n, t.UserAgent = "", t.ClientType = ct.Unknown, t.UniqueSessionId = "", t.Parameters = /* @__PURE__ */ Object.create(null), t.SdkType = Nt.Unknown, t.ViewportWidth = 0, t.ViewportHeight = 0, t.Theme = "", t.Timezone = "", t.IsTouchDevice = !1, t.InitialPath = "", t;
657
- }
658
- function os(t, s) {
659
- const e = s ?? is();
660
- return wt(e), as(t, e), e;
661
- }
662
- function as(t, s) {
663
- let e;
664
- for (; (e = t.next()) !== null; )
665
- switch (e.fieldId) {
666
- case Oe: {
667
- if (e.isNull) throw new Error();
668
- s.DeviceId = e.asString();
669
- break;
670
- }
671
- case Pe: {
672
- if (e.isNull) throw new Error();
673
- s.InstallId = e.asString();
674
- break;
675
- }
676
- case ge: {
677
- if (e.isNull) throw new Error();
678
- s.Theme = e.asString();
679
- break;
680
- }
681
- case be: {
682
- if (e.isNull) throw new Error();
683
- s.UserAgent = e.asString();
684
- break;
685
- }
686
- case Fe: {
687
- if (e.isNull) throw new Error();
688
- s.ContextType = e.asInt32();
689
- break;
690
- }
691
- case ve: {
692
- if (e.isNull) throw new Error();
693
- s.HasInput = e.asBool();
694
- break;
695
- }
696
- case Me: {
697
- if (e.isNull) throw new Error();
698
- s.UserType = e.asInt32();
699
- break;
700
- }
701
- case pe: {
702
- if (e.isNull) throw new Error();
703
- s.InitialPath = e.asString();
704
- break;
705
- }
706
- case ke: {
707
- if (e.isNull) throw new Error();
708
- s.UserId = e.asString();
709
- break;
710
- }
711
- case Ve: {
712
- if (e.isNull) throw new Error();
713
- s.ProductId = e.asString();
714
- break;
715
- }
716
- case Ge: {
717
- if (e.isNull) throw new Error();
718
- s.AuthSessionId = e.asString();
719
- break;
720
- }
721
- case Be: {
722
- if (e.isNull) throw new Error();
723
- s.ReceiveAllMessages = e.asBool();
724
- break;
725
- }
726
- case xe: {
727
- if (e.isNull) throw new Error();
728
- s.ViewportHeight = e.asInt32();
729
- break;
730
- }
731
- case He: {
732
- if (e.isNull) throw new Error();
733
- s.Description = e.asString();
734
- break;
735
- }
736
- case Ye: {
737
- if (e.isNull) throw new Error();
738
- s.Locale = e.asString();
739
- break;
740
- }
741
- case Ke: {
742
- if (e.isNull) throw new Error();
743
- s.SdkType = e.asInt32();
744
- break;
745
- }
746
- case $e: {
747
- if (e.isNull) throw new Error();
748
- s.SessionId = e.asInt32();
749
- break;
750
- }
751
- case Xe: {
752
- if (e.isNull) throw new Error();
753
- s.ViewportWidth = e.asInt32();
754
- break;
755
- }
756
- case je: {
757
- if (e.isNull) throw new Error();
758
- s.PreciseJoinedAt = e.asUInt64();
759
- break;
760
- }
761
- case We: {
762
- if (e.isNull) throw new Error();
763
- s.PayloadType = e.asInt32();
764
- break;
765
- }
766
- case ze: {
767
- if (e.isNull) throw new Error();
768
- s.IsTouchDevice = e.asBool();
769
- break;
770
- }
771
- case Je: {
772
- if (e.isNull) throw new Error();
773
- s.VersionId = e.asString();
774
- break;
775
- }
776
- case qe: {
777
- if (e.isNull) throw new Error();
778
- s.UniqueSessionId = e.asString();
779
- break;
780
- }
781
- case Qe: {
782
- if (e.isNull) throw new Error();
783
- s.ClientType = e.asInt32();
784
- break;
785
- }
786
- case Ze: {
787
- if (e.isNull) throw new Error();
788
- s.IsReady = e.asBool();
789
- break;
790
- }
791
- case ts: {
792
- if (e.isNull) throw new Error();
793
- s.Parameters = ls(e.asDictionary());
794
- break;
795
- }
796
- case es: {
797
- if (e.isNull) throw new Error();
798
- s.Timezone = e.asString();
799
- break;
800
- }
801
- case ss: {
802
- if (e.isNull) throw new Error();
803
- s.IsInternal = e.asBool();
804
- break;
805
- }
806
- case rs: {
807
- if (e.isNull) throw new Error();
808
- s.ChannelLocale = e.asString();
809
- break;
810
- }
811
- case ns: {
812
- if (e.isNull) throw new Error();
813
- s.EmbeddedSpaceId = e.asString();
814
- break;
815
- }
816
- }
817
- }
818
- function ls(t) {
819
- const s = /* @__PURE__ */ Object.create(null);
820
- let e;
821
- for (; (e = t.next()) !== null; ) {
822
- const r = e.key.asString();
823
- s[r] = e.value.asString();
824
- }
825
- return s;
826
- }
827
- const Is = 703025676, Es = 814454131, _s = 972460562, cs = 976255570, fs = 1368629611, hs = 1479280922, us = 1533537016, Ts = 1909301063, As = 2274386296, Ns = 2603556958, Ss = 2885165957, ds = 3568439632;
828
- function Cs(t) {
829
- const s = {};
830
- return Rt(s), s;
831
- }
832
- function Rt(t) {
833
- return t.FunctionId = T.fromBytes(new Uint8Array(16)), t.FunctionName = "", t.Parameters = [], t.ResultTypeName = "", t.IsEnumerable = !1, t.EnumerableItemTypeName = "", t.IsCancellable = !1, t.Description = "", t.LlmInlineResult = !1, t.LlmCallOnlyOnce = !1, t.RequiresInstance = !1, t.Versions = [], t;
834
- }
835
- function ys(t, s) {
836
- const e = s ?? Cs();
837
- return Rt(e), Ds(t, e), e;
838
- }
839
- function Ds(t, s) {
840
- let e;
841
- for (; (e = t.next()) !== null; )
842
- switch (e.fieldId) {
843
- case Is: {
844
- if (e.isNull) throw new Error();
845
- s.ResultTypeName = e.asString();
846
- break;
847
- }
848
- case Es: {
849
- if (e.isNull) throw new Error();
850
- s.FunctionName = e.asString();
851
- break;
852
- }
853
- case _s: {
854
- if (e.isNull) throw new Error();
855
- s.EnumerableItemTypeName = e.asString();
856
- break;
857
- }
858
- case cs: {
859
- if (e.isNull) throw new Error();
860
- s.FunctionId = e.asGuid();
861
- break;
862
- }
863
- case fs: {
864
- if (e.isNull) throw new Error();
865
- s.Description = e.asString();
866
- break;
867
- }
868
- case hs: {
869
- if (e.isNull) throw new Error();
870
- s.IsCancellable = e.asBool();
871
- break;
872
- }
873
- case us: {
874
- if (e.isNull) throw new Error();
875
- s.RequiresInstance = e.asBool();
876
- break;
877
- }
878
- case Ts: {
879
- if (e.isNull) throw new Error();
880
- s.Versions = ws(e.asArray());
881
- break;
882
- }
883
- case As: {
884
- if (e.isNull) throw new Error();
885
- s.LlmInlineResult = e.asBool();
886
- break;
887
- }
888
- case Ns: {
889
- if (e.isNull) throw new Error();
890
- s.IsEnumerable = e.asBool();
891
- break;
892
- }
893
- case Ss: {
894
- if (e.isNull) throw new Error();
895
- s.Parameters = Rs(e.asArray());
896
- break;
897
- }
898
- case ds: {
899
- if (e.isNull) throw new Error();
900
- s.LlmCallOnlyOnce = e.asBool();
901
- break;
902
- }
903
- }
904
- }
905
- function ws(t) {
906
- const s = [];
907
- let e;
908
- for (; (e = t.next()) !== null; )
909
- s.push(e.asString());
910
- return s;
911
- }
912
- function Rs(t) {
913
- const s = [];
914
- let e;
915
- for (; (e = t.next()) !== null; )
916
- s.push(ps(e.asObject()));
917
- return s;
918
- }
919
- const Us = 607861992, Ls = 894485888, ms = 972460562, Os = 1368629611, Ps = 1883521406, gs = 2603556958, bs = 3609695522, Fs = 4075263697, vs = 4257460908;
920
- function Ms(t) {
921
- const s = {};
922
- return Ut(s), s;
923
- }
924
- function Ut(t) {
925
- return t.ParameterIndex = 0, t.ParameterName = "", t.TypeName = "", t.HasDefaultValue = !1, t.DefaultValueJson = "", t.DefaultValueData = new Uint8Array(0), t.IsEnumerable = !1, t.EnumerableItemTypeName = "", t.Description = "", t;
926
- }
927
- function ps(t, s) {
928
- const e = s ?? Ms();
929
- return Ut(e), ks(t, e), e;
930
- }
931
- function ks(t, s) {
932
- let e;
933
- for (; (e = t.next()) !== null; )
934
- switch (e.fieldId) {
935
- case Us: {
936
- if (e.isNull) throw new Error();
937
- s.HasDefaultValue = e.asBool();
938
- break;
939
- }
940
- case Ls: {
941
- if (e.isNull) throw new Error();
942
- s.DefaultValueJson = e.asString();
943
- break;
944
- }
945
- case ms: {
946
- if (e.isNull) throw new Error();
947
- s.EnumerableItemTypeName = e.asString();
948
- break;
949
- }
950
- case Os: {
951
- if (e.isNull) throw new Error();
952
- s.Description = e.asString();
953
- break;
954
- }
955
- case Ps: {
956
- if (e.isNull) throw new Error();
957
- s.DefaultValueData = e.asBinary();
958
- break;
959
- }
960
- case gs: {
961
- if (e.isNull) throw new Error();
962
- s.IsEnumerable = e.asBool();
963
- break;
964
- }
965
- case bs: {
966
- if (e.isNull) throw new Error();
967
- s.TypeName = e.asString();
968
- break;
969
- }
970
- case Fs: {
971
- if (e.isNull) throw new Error();
972
- s.ParameterName = e.asString();
973
- break;
974
- }
975
- case vs: {
976
- if (e.isNull) throw new Error();
977
- s.ParameterIndex = e.asInt32();
978
- break;
979
- }
980
- }
981
- }
982
- const Vs = 3167053791, Gs = 3342364356, Bs = 3612929027;
983
- function Lt(t) {
984
- const s = {};
985
- return mt(s), s;
986
- }
987
- function mt(t) {
988
- return t.Category = "", t.Type = ut.Face, t.FaceBlendshapes = [], t;
989
- }
990
- function xs(t, s) {
991
- const e = s ?? Lt();
992
- return mt(e), Hs(t, e), e;
993
- }
994
- function Hs(t, s) {
995
- let e;
996
- for (; (e = t.next()) !== null; )
997
- switch (e.fieldId) {
998
- case Vs: {
999
- if (e.isNull) throw new Error();
1000
- s.Type = e.asInt32();
1001
- break;
1002
- }
1003
- case Gs: {
1004
- if (e.isNull) throw new Error();
1005
- s.FaceBlendshapes = Ys(e.asArray());
1006
- break;
1007
- }
1008
- case Bs: {
1009
- if (e.isNull) throw new Error();
1010
- s.Category = e.asString();
1011
- break;
1012
- }
1013
- }
1014
- }
1015
- function Ys(t) {
1016
- const s = [];
1017
- let e;
1018
- for (; (e = t.next()) !== null; )
1019
- s.push(e.asString());
1020
- return s;
1021
- }
1022
- const Ks = 3612929027;
1023
- function Ot(t) {
1024
- const s = {};
1025
- return Pt(s), s;
1026
- }
1027
- function Pt(t) {
1028
- return t.Category = "", t;
1029
- }
1030
- function $s(t, s) {
1031
- const e = s ?? Ot();
1032
- return Pt(e), Xs(t, e), e;
1033
- }
1034
- function Xs(t, s) {
1035
- let e;
1036
- for (; (e = t.next()) !== null; )
1037
- switch (e.fieldId) {
1038
- case Ks: {
1039
- if (e.isNull) throw new Error();
1040
- s.Category = e.asString();
1041
- break;
1042
- }
1043
- }
1044
- }
1045
- const js = 161083277, Ws = 164808083, zs = 1368629611, Js = 2745379226, qs = 2950031986, Qs = 3282782683, Zs = 3284746250, tr = 4065070594;
1046
- function gt(t) {
1047
- const s = {};
1048
- return bt(s), s;
1049
- }
1050
- function bt(t) {
1051
- return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = At.H264, t.CodecDetails = "", t.Width = 0, t.Height = 0, t.Framerate = 30, t;
1052
- }
1053
- function er(t, s) {
1054
- const e = s ?? gt();
1055
- return bt(e), sr(t, e), e;
1056
- }
1057
- function sr(t, s) {
1058
- let e;
1059
- for (; (e = t.next()) !== null; )
1060
- switch (e.fieldId) {
1061
- case js: {
1062
- if (e.isNull) throw new Error();
1063
- s.StreamId = e.asString();
1064
- break;
1065
- }
1066
- case Ws: {
1067
- if (e.isNull) throw new Error();
1068
- s.Framerate = e.asFloat64();
1069
- break;
1070
- }
1071
- case zs: {
1072
- if (e.isNull) throw new Error();
1073
- s.Description = e.asString();
1074
- break;
1075
- }
1076
- case Js: {
1077
- if (e.isNull) throw new Error();
1078
- s.CodecDetails = e.asString();
1079
- break;
1080
- }
1081
- case qs: {
1082
- if (e.isNull) throw new Error();
1083
- s.Height = e.asInt32();
1084
- break;
1085
- }
1086
- case Qs: {
1087
- if (e.isNull) throw new Error();
1088
- s.SourceType = e.asString();
1089
- break;
1090
- }
1091
- case Zs: {
1092
- if (e.isNull) throw new Error();
1093
- s.Codec = e.asInt32();
1094
- break;
1095
- }
1096
- case tr: {
1097
- if (e.isNull) throw new Error();
1098
- s.Width = e.asInt32();
1099
- break;
1100
- }
1101
- }
1102
- }
1103
- const rr = 65539, nr = 693643444, ir = 1144553441, or = 1497620243, ar = 1559330978, lr = 1976546434, Ir = 1999510636, Er = 2271236852, _r = 2277643855, cr = 2469008121, fr = 3042922213, hr = 3064612128, ur = 3219210453, Tr = 3504054055, Ar = 3678477544, Nr = 3696445035, Sr = 3707543140, dr = 3712281496, Cr = 3895362455, yr = 3897397815, Dr = 4225107827;
1104
- function wr(t) {
1105
- const s = {};
1106
- return Ft(s), s;
1107
- }
1108
- function Ft(t) {
1109
- return t.Clients = /* @__PURE__ */ Object.create(null), t.Functions = /* @__PURE__ */ Object.create(null), t.UIStreams = /* @__PURE__ */ Object.create(null), t.AudioStreams = /* @__PURE__ */ Object.create(null), t.VideoStreams = /* @__PURE__ */ Object.create(null), t.TrackingStreams = /* @__PURE__ */ Object.create(null), t.SpaceId = "", t.ChannelId = "", t.SessionId = "", t.ChannelUrl = "", t.SessionChannelUrl = "", t.FirstUserId = "", t.PrimaryUserId = "", t.OrganisationName = "", t.SpaceName = "", t.ChannelName = "", t.ServerRunType = St.Local, t.AppSourceType = dt.Bundle, t.PublicAccess = !1, t.DebugMode = !1, t;
1110
- }
1111
- function Rr(t, s) {
1112
- const e = O.create(t);
1113
- return Ur(e, s);
1114
- }
1115
- function Ur(t, s) {
1116
- const e = s ?? wr();
1117
- return Ft(e), Lr(t, e), e;
1118
- }
1119
- function Lr(t, s) {
1120
- let e;
1121
- for (; (e = t.next()) !== null; )
1122
- switch (e.fieldId) {
1123
- case nr: {
1124
- if (e.isNull) throw new Error();
1125
- s.FirstUserId = e.asString();
1126
- break;
1127
- }
1128
- case ir: {
1129
- if (e.isNull) throw new Error();
1130
- s.Clients = Or(e.asDictionary());
1131
- break;
1132
- }
1133
- case or: {
1134
- if (e.isNull) throw new Error();
1135
- s.TrackingStreams = Pr(e.asDictionary());
1136
- break;
1137
- }
1138
- case ar: {
1139
- if (e.isNull) throw new Error();
1140
- s.ChannelId = e.asString();
1141
- break;
1142
- }
1143
- case lr: {
1144
- if (e.isNull) throw new Error();
1145
- s.AppSourceType = e.asInt32();
1146
- break;
1147
- }
1148
- case Ir: {
1149
- if (e.isNull) throw new Error();
1150
- s.SessionId = e.asString();
1151
- break;
1152
- }
1153
- case Er: {
1154
- if (e.isNull) throw new Error();
1155
- s.SessionChannelUrl = e.asString();
1156
- break;
1157
- }
1158
- case _r: {
1159
- if (e.isNull) throw new Error();
1160
- s.ChannelUrl = e.asString();
1161
- break;
1162
- }
1163
- case cr: {
1164
- if (e.isNull) throw new Error();
1165
- s.ChannelName = e.asString();
1166
- break;
1167
- }
1168
- case fr: {
1169
- if (e.isNull) throw new Error();
1170
- s.PublicAccess = e.asBool();
1171
- break;
1172
- }
1173
- case hr: {
1174
- if (e.isNull) throw new Error();
1175
- s.ServerRunType = e.asInt32();
1176
- break;
1177
- }
1178
- case ur: {
1179
- if (e.isNull) throw new Error();
1180
- s.OrganisationName = e.asString();
1181
- break;
1182
- }
1183
- case Tr: {
1184
- if (e.isNull) throw new Error();
1185
- s.DebugMode = e.asBool();
1186
- break;
1187
- }
1188
- case Ar: {
1189
- if (e.isNull) throw new Error();
1190
- s.Functions = gr(e.asDictionary());
1191
- break;
1192
- }
1193
- case Nr: {
1194
- if (e.isNull) throw new Error();
1195
- s.UIStreams = br(e.asDictionary());
1196
- break;
1197
- }
1198
- case Sr: {
1199
- if (e.isNull) throw new Error();
1200
- s.SpaceId = e.asString();
1201
- break;
1202
- }
1203
- case dr: {
1204
- if (e.isNull) throw new Error();
1205
- s.PrimaryUserId = e.asString();
1206
- break;
1207
- }
1208
- case Cr: {
1209
- if (e.isNull) throw new Error();
1210
- s.AudioStreams = Fr(e.asDictionary());
1211
- break;
1212
- }
1213
- case yr: {
1214
- if (e.isNull) throw new Error();
1215
- s.VideoStreams = vr(e.asDictionary());
1216
- break;
1217
- }
1218
- case Dr: {
1219
- if (e.isNull) throw new Error();
1220
- s.SpaceName = e.asString();
1221
- break;
1222
- }
1223
- }
1224
- }
1225
- async function mr(t, s) {
1226
- const e = await K(t, rr);
1227
- return Rr(e, s);
1228
- }
1229
- function Or(t) {
1230
- const s = /* @__PURE__ */ Object.create(null);
1231
- let e;
1232
- for (; (e = t.next()) !== null; ) {
1233
- const r = e.key.asInt32();
1234
- s[r] = os(e.value.asObject());
1235
- }
1236
- return s;
1237
- }
1238
- function Pr(t) {
1239
- const s = /* @__PURE__ */ Object.create(null);
1240
- let e;
1241
- for (; (e = t.next()) !== null; ) {
1242
- const r = e.key.asString();
1243
- s[r] = In(e.value.asObject());
1244
- }
1245
- return s;
1246
- }
1247
- function gr(t) {
1248
- const s = /* @__PURE__ */ Object.create(null);
1249
- let e;
1250
- for (; (e = t.next()) !== null; ) {
1251
- const r = e.key.asInt32();
1252
- s[r] = Mr(e.value.asArray());
1253
- }
1254
- return s;
1255
- }
1256
- function br(t) {
1257
- const s = /* @__PURE__ */ Object.create(null);
1258
- let e;
1259
- for (; (e = t.next()) !== null; ) {
1260
- const r = e.key.asString();
1261
- s[r] = xr(e.value.asObject());
1262
- }
1263
- return s;
1264
- }
1265
- function Fr(t) {
1266
- const s = /* @__PURE__ */ Object.create(null);
1267
- let e;
1268
- for (; (e = t.next()) !== null; ) {
1269
- const r = e.key.asString();
1270
- s[r] = Wr(e.value.asObject());
1271
- }
1272
- return s;
1273
- }
1274
- function vr(t) {
1275
- const s = /* @__PURE__ */ Object.create(null);
1276
- let e;
1277
- for (; (e = t.next()) !== null; ) {
1278
- const r = e.key.asString();
1279
- s[r] = en(e.value.asObject());
1280
- }
1281
- return s;
1282
- }
1283
- function Mr(t) {
1284
- const s = [];
1285
- let e;
1286
- for (; (e = t.next()) !== null; )
1287
- s.push(ys(e.asObject()));
1288
- return s;
1289
- }
1290
- const pr = 161083277, kr = 325678206, Vr = 3469892363, Gr = 3645544153;
1291
- function Br(t) {
1292
- const s = {};
1293
- return vt(s), s;
1294
- }
1295
- function vt(t) {
1296
- return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Ot(), t;
1297
- }
1298
- function xr(t, s) {
1299
- const e = s ?? Br();
1300
- return vt(e), Hr(t, e), e;
1301
- }
1302
- function Hr(t, s) {
1303
- let e;
1304
- for (; (e = t.next()) !== null; )
1305
- switch (e.fieldId) {
1306
- case pr: {
1307
- if (e.isNull) throw new Error();
1308
- s.StreamId = e.asString();
1309
- break;
1310
- }
1311
- case kr: {
1312
- if (e.isNull) throw new Error();
1313
- s.ClientSessionId = e.asInt32();
1314
- break;
1315
- }
1316
- case Vr: {
1317
- if (e.isNull) throw new Error();
1318
- s.TrackId = e.asInt32();
1319
- break;
1320
- }
1321
- case Gr: {
1322
- if (e.isNull) throw new Error();
1323
- s.Info = $s(e.asObject());
1324
- break;
1325
- }
1326
- }
1327
- }
1328
- const Yr = 161083277, Kr = 325678206, $r = 3469892363, Xr = 3645544153;
1329
- function jr(t) {
1330
- const s = {};
1331
- return Mt(s), s;
1332
- }
1333
- function Mt(t) {
1334
- return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Ct(), t;
1335
- }
1336
- function Wr(t, s) {
1337
- const e = s ?? jr();
1338
- return Mt(e), zr(t, e), e;
1339
- }
1340
- function zr(t, s) {
1341
- let e;
1342
- for (; (e = t.next()) !== null; )
1343
- switch (e.fieldId) {
1344
- case Yr: {
1345
- if (e.isNull) throw new Error();
1346
- s.StreamId = e.asString();
1347
- break;
1348
- }
1349
- case Kr: {
1350
- if (e.isNull) throw new Error();
1351
- s.ClientSessionId = e.asInt32();
1352
- break;
1353
- }
1354
- case $r: {
1355
- if (e.isNull) throw new Error();
1356
- s.TrackId = e.asInt32();
1357
- break;
1358
- }
1359
- case Xr: {
1360
- if (e.isNull) throw new Error();
1361
- s.Info = Se(e.asObject());
1362
- break;
1363
- }
1364
- }
1365
- }
1366
- const Jr = 161083277, qr = 325678206, Qr = 3469892363, Zr = 3645544153;
1367
- function tn(t) {
1368
- const s = {};
1369
- return pt(s), s;
1370
- }
1371
- function pt(t) {
1372
- return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = gt(), t;
1373
- }
1374
- function en(t, s) {
1375
- const e = s ?? tn();
1376
- return pt(e), sn(t, e), e;
1377
- }
1378
- function sn(t, s) {
1379
- let e;
1380
- for (; (e = t.next()) !== null; )
1381
- switch (e.fieldId) {
1382
- case Jr: {
1383
- if (e.isNull) throw new Error();
1384
- s.StreamId = e.asString();
1385
- break;
1386
- }
1387
- case qr: {
1388
- if (e.isNull) throw new Error();
1389
- s.ClientSessionId = e.asInt32();
1390
- break;
1391
- }
1392
- case Qr: {
1393
- if (e.isNull) throw new Error();
1394
- s.TrackId = e.asInt32();
1395
- break;
1396
- }
1397
- case Zr: {
1398
- if (e.isNull) throw new Error();
1399
- s.Info = er(e.asObject());
1400
- break;
1401
- }
1402
- }
1403
- }
1404
- const rn = 161083277, nn = 325678206, on = 3469892363, an = 3645544153;
1405
- function ln(t) {
1406
- const s = {};
1407
- return kt(s), s;
1408
- }
1409
- function kt(t) {
1410
- return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Lt(), t;
1411
- }
1412
- function In(t, s) {
1413
- const e = s ?? ln();
1414
- return kt(e), En(t, e), e;
1415
- }
1416
- function En(t, s) {
1417
- let e;
1418
- for (; (e = t.next()) !== null; )
1419
- switch (e.fieldId) {
1420
- case rn: {
1421
- if (e.isNull) throw new Error();
1422
- s.StreamId = e.asString();
1423
- break;
1424
- }
1425
- case nn: {
1426
- if (e.isNull) throw new Error();
1427
- s.ClientSessionId = e.asInt32();
1428
- break;
1429
- }
1430
- case on: {
1431
- if (e.isNull) throw new Error();
1432
- s.TrackId = e.asInt32();
1433
- break;
1434
- }
1435
- case an: {
1436
- if (e.isNull) throw new Error();
1437
- s.Info = xs(e.asObject());
1438
- break;
1439
- }
1440
- }
1441
- }
1442
- const _n = 1405462580, cn = 2968276160;
1443
- function fn(t) {
1444
- const s = {};
1445
- return Vt(s), s;
1446
- }
1447
- function Vt(t) {
1448
- return t.MimeType = "", t.Value = new Uint8Array(0), t;
1449
- }
1450
- function hn(t, s) {
1451
- const e = s ?? fn();
1452
- return Vt(e), un(t, e), e;
1453
- }
1454
- function un(t, s) {
1455
- let e;
1456
- for (; (e = t.next()) !== null; )
1457
- switch (e.fieldId) {
1458
- case _n: {
1459
- if (e.isNull) throw new Error();
1460
- s.Value = e.asBinary();
1461
- break;
1462
- }
1463
- case cn: {
1464
- if (e.isNull) throw new Error();
1465
- s.MimeType = e.asString();
1466
- break;
1467
- }
1468
- }
1469
- }
1470
- const Tn = 2097188, An = 979822885, Nn = 2374537704;
1471
- function Sn(t) {
1472
- const s = {};
1473
- return Gt(s), s;
1474
- }
1475
- function Gt(t) {
1476
- return t.StyleId = "", t.Style = /* @__PURE__ */ Object.create(null), t;
1477
- }
1478
- function dn(t, s) {
1479
- const e = O.create(t);
1480
- return Cn(e, s);
1481
- }
1482
- function Cn(t, s) {
1483
- const e = s ?? Sn();
1484
- return Gt(e), yn(t, e), e;
1485
- }
1486
- function yn(t, s) {
1487
- let e;
1488
- for (; (e = t.next()) !== null; )
1489
- switch (e.fieldId) {
1490
- case An: {
1491
- if (e.isNull) throw new Error();
1492
- s.StyleId = e.asString();
1493
- break;
1494
- }
1495
- case Nn: {
1496
- if (e.isNull) throw new Error();
1497
- s.Style = wn(e.asDictionary());
1498
- break;
1499
- }
1500
- }
1501
- }
1502
- async function Dn(t, s) {
1503
- const e = await K(t, Tn);
1504
- return dn(e, s);
1505
- }
1506
- function wn(t) {
1507
- const s = /* @__PURE__ */ Object.create(null);
1508
- let e;
1509
- for (; (e = t.next()) !== null; ) {
1510
- const r = e.key.asString();
1511
- s[r] = e.value.asString();
1512
- }
1513
- return s;
1514
- }
1515
- const Rn = 2097192, Un = 2136687806;
1516
- function Ln(t) {
1517
- const s = {};
1518
- return Bt(s), s;
1519
- }
1520
- function Bt(t) {
1521
- return t.Styles = [], t;
1522
- }
1523
- function mn(t, s) {
1524
- const e = O.create(t);
1525
- return On(e, s);
1526
- }
1527
- function On(t, s) {
1528
- const e = s ?? Ln();
1529
- return Bt(e), Pn(t, e), e;
1530
- }
1531
- function Pn(t, s) {
1532
- let e;
1533
- for (; (e = t.next()) !== null; )
1534
- switch (e.fieldId) {
1535
- case Un: {
1536
- if (e.isNull) throw new Error();
1537
- s.Styles = bn(e.asArray());
1538
- break;
1539
- }
1540
- }
1541
- }
1542
- async function gn(t, s) {
1543
- const e = await K(t, Rn);
1544
- return mn(e, s);
1545
- }
1546
- function bn(t) {
1547
- const s = [];
1548
- let e;
1549
- for (; (e = t.next()) !== null; )
1550
- s.push(pn(e.asObject()));
1551
- return s;
1552
- }
1553
- const Fn = 979822885, vn = 2374537704;
1554
- function Mn(t) {
1555
- const s = {};
1556
- return xt(s), s;
1557
- }
1558
- function xt(t) {
1559
- return t.StyleId = "", t.Style = /* @__PURE__ */ Object.create(null), t;
1560
- }
1561
- function pn(t, s) {
1562
- const e = s ?? Mn();
1563
- return xt(e), kn(t, e), e;
1564
- }
1565
- function kn(t, s) {
1566
- let e;
1567
- for (; (e = t.next()) !== null; )
1568
- switch (e.fieldId) {
1569
- case Fn: {
1570
- if (e.isNull) throw new Error();
1571
- s.StyleId = e.asString();
1572
- break;
1573
- }
1574
- case vn: {
1575
- if (e.isNull) throw new Error();
1576
- s.Style = Vn(e.asDictionary());
1577
- break;
1578
- }
1579
- }
1580
- }
1581
- function Vn(t) {
1582
- const s = /* @__PURE__ */ Object.create(null);
1583
- let e;
1584
- for (; (e = t.next()) !== null; ) {
1585
- const r = e.key.asString();
1586
- s[r] = e.value.asString();
1587
- }
1588
- return s;
1589
- }
1590
- const Gn = 2097193, Bn = 1415642792;
1591
- function xn(t) {
1592
- const s = {};
1593
- return Ht(s), s;
1594
- }
1595
- function Ht(t) {
1596
- return t.StyleIds = [], t;
1597
- }
1598
- function Hn(t, s) {
1599
- const e = O.create(t);
1600
- return Yn(e, s);
1601
- }
1602
- function Yn(t, s) {
1603
- const e = s ?? xn();
1604
- return Ht(e), Kn(t, e), e;
1605
- }
1606
- function Kn(t, s) {
1607
- let e;
1608
- for (; (e = t.next()) !== null; )
1609
- switch (e.fieldId) {
1610
- case Bn: {
1611
- if (e.isNull) throw new Error();
1612
- s.StyleIds = Xn(e.asArray());
1613
- break;
1614
- }
1615
- }
1616
- }
1617
- async function $n(t, s) {
1618
- const e = await K(t, Gn);
1619
- return Hn(e, s);
1620
- }
1621
- function Xn(t) {
1622
- const s = [];
1623
- let e;
1624
- for (; (e = t.next()) !== null; )
1625
- s.push(e.asString());
1626
- return s;
1627
- }
1628
- const jn = 2097190, Wn = 425183262, zn = 653781469;
1629
- function Jn(t) {
1630
- const s = {};
1631
- return Yt(s), s;
1632
- }
1633
- function Yt(t) {
1634
- return t.Json = "", t.Payloads = /* @__PURE__ */ Object.create(null), t;
1635
- }
1636
- function qn(t, s) {
1637
- const e = O.create(t);
1638
- return Qn(e, s);
1639
- }
1640
- function Qn(t, s) {
1641
- const e = s ?? Jn();
1642
- return Yt(e), Zn(t, e), e;
1643
- }
1644
- function Zn(t, s) {
1645
- let e;
1646
- for (; (e = t.next()) !== null; )
1647
- switch (e.fieldId) {
1648
- case Wn: {
1649
- if (e.isNull) throw new Error();
1650
- s.Json = e.asString();
1651
- break;
1652
- }
1653
- case zn: {
1654
- if (e.isNull) throw new Error();
1655
- s.Payloads = ei(e.asDictionary());
1656
- break;
1657
- }
1658
- }
1659
- }
1660
- async function ti(t, s) {
1661
- const e = await K(t, jn);
1662
- return qn(e, s);
1663
- }
1664
- function ei(t) {
1665
- const s = /* @__PURE__ */ Object.create(null);
1666
- let e;
1667
- for (; (e = t.next()) !== null; ) {
1668
- const r = e.key.asString();
1669
- s[r] = hn(e.value.asObject());
1670
- }
1671
- return s;
1672
- }
1673
- function C(t) {
1674
- return typeof t == "object" && t !== null && !Array.isArray(t);
1675
- }
1676
- function Kt(t) {
1677
- const s = {}, e = Object.keys(t);
1678
- for (let r = 0; r < e.length; r++) {
1679
- const n = e[r];
1680
- s[n] = t[n];
1681
- }
1682
- return s;
1683
- }
1684
- function $t(t, s, e, r) {
1685
- if (!(t === void 0 && r)) {
1686
- if (Array.isArray(t)) {
1687
- const n = [];
1688
- for (let i = 0; i < t.length; i++) {
1689
- const o = t[i];
1690
- if (typeof o != "string")
1691
- throw new Error(`Invalid styleIds entry at ${s}.styleIds[${i}] for element ${e}`);
1692
- const a = o.trim();
1693
- a.length !== 0 && n.push(a);
1694
- }
1695
- return n;
1696
- }
1697
- if (t != null)
1698
- throw new Error(`Invalid styleIds for element ${e}`);
1699
- return [];
1700
- }
1701
- }
1702
- function ot(t, s) {
1703
- if (!t || typeof t != "object")
1704
- throw new Error(`Invalid UI node at ${s}`);
1705
- const e = t.Id, r = t.Type, n = t.Props, i = t.Children, o = t.StyleIds;
1706
- if (typeof e != "string")
1707
- throw new Error(`Invalid or missing node id at ${s}`);
1708
- if (typeof r != "string")
1709
- throw new Error(`Invalid or missing node type for ${e}`);
1710
- let a = {};
1711
- if (n != null) {
1712
- if (!C(n))
1713
- throw new Error(`Invalid props for node ${e}`);
1714
- a = Kt(n);
1715
- }
1716
- let E = [];
1717
- Array.isArray(i) && (E = i.map(
1718
- (_, c) => ot(_ ?? {}, `${s}.children[${c}]`)
1719
- ));
1720
- const l = $t(o, s, e, !1), I = typeof t.SourceMarker == "string" ? t.SourceMarker : void 0;
1721
- return {
1722
- id: e,
1723
- type: r,
1724
- props: a,
1725
- children: E,
1726
- styleIds: l ?? [],
1727
- ...I ? { sourceMarker: I } : {}
1728
- };
1729
- }
1730
- function si(t, s) {
1731
- if (!C(t))
1732
- throw new Error(`Invalid text delta at ${s}`);
1733
- const e = t.NodeId, r = t.PropertyName, n = t.Start, i = t.End, o = t.InsertedText;
1734
- if (typeof e != "string" || e.length === 0)
1735
- throw new Error(`Invalid text delta node id at ${s}`);
1736
- if (typeof r != "string" || r.length === 0)
1737
- throw new Error(`Invalid text delta property name at ${s}`);
1738
- if (typeof n != "number" || !Number.isFinite(n))
1739
- throw new Error(`Invalid text delta start at ${s}`);
1740
- if (typeof o != "string")
1741
- throw new Error(`Invalid text delta inserted text at ${s}`);
1742
- let a;
1743
- if (typeof i == "number") {
1744
- if (!Number.isFinite(i))
1745
- throw new Error(`Invalid text delta end at ${s}`);
1746
- a = i;
1747
- } else if (i != null)
1748
- throw new Error(`Invalid text delta end at ${s}`);
1749
- return {
1750
- nodeId: e,
1751
- propertyName: r,
1752
- start: n,
1753
- end: a,
1754
- insertedText: o
1755
- };
1756
- }
1757
- function ri(t, s) {
1758
- if (!C(t))
1759
- throw new Error(`Invalid child insert at ${s}`);
1760
- const e = t.Index, r = t.Node;
1761
- if (typeof e != "number" || !Number.isFinite(e))
1762
- throw new Error(`Invalid child insert index at ${s}`);
1763
- if (!C(r))
1764
- throw new Error(`Invalid child insert node at ${s}`);
1765
- return {
1766
- index: e,
1767
- node: ot(r, `${s}.node`)
1768
- };
1769
- }
1770
- function ni(t, s) {
1771
- if (!C(t))
1772
- throw new Error(`Invalid child move at ${s}`);
1773
- const e = t.NodeId, r = t.FromIndex, n = t.ToIndex;
1774
- if (typeof e != "string" || e.length === 0)
1775
- throw new Error(`Invalid child move nodeId at ${s}`);
1776
- if (typeof r != "number" || !Number.isFinite(r))
1777
- throw new Error(`Invalid child move fromIndex at ${s}`);
1778
- if (typeof n != "number" || !Number.isFinite(n))
1779
- throw new Error(`Invalid child move toIndex at ${s}`);
1780
- return {
1781
- nodeId: e,
1782
- fromIndex: r,
1783
- toIndex: n
1784
- };
1785
- }
1786
- function ii(t, s) {
1787
- if (!C(t))
1788
- throw new Error(`Invalid child remove at ${s}`);
1789
- const e = t.NodeId, r = t.Index;
1790
- if (typeof e != "string" || e.length === 0)
1791
- throw new Error(`Invalid child remove nodeId at ${s}`);
1792
- if (typeof r != "number" || !Number.isFinite(r))
1793
- throw new Error(`Invalid child remove index at ${s}`);
1794
- return {
1795
- nodeId: e,
1796
- index: r
1797
- };
1798
- }
1799
- function oi(t, s) {
1800
- if (!C(t))
1801
- throw new Error(`Invalid node change at ${s}`);
1802
- const e = t.nodeId;
1803
- if (typeof e != "string" || e.length === 0)
1804
- throw new Error(`Invalid node change nodeId at ${s}`);
1805
- const r = Array.isArray(t.inserts) ? t.inserts.map(
1806
- (I, _) => ri(I ?? {}, `${s}.inserts[${_}]`)
1807
- ) : void 0, n = Array.isArray(t.moves) ? t.moves.map(
1808
- (I, _) => ni(I ?? {}, `${s}.moves[${_}]`)
1809
- ) : void 0, i = Array.isArray(t.removals) ? t.removals.map(
1810
- (I, _) => ii(I ?? {}, `${s}.removals[${_}]`)
1811
- ) : void 0;
1812
- let o;
1813
- if (C(t.changedProps)) {
1814
- o = /* @__PURE__ */ new Map();
1815
- for (const [I, _] of Object.entries(t.changedProps)) {
1816
- if (!C(_))
1817
- continue;
1818
- const c = _.New;
1819
- c === void 0 ? o.set(I, void 0) : C(c) ? o.set(I, Kt(c)) : o.set(I, c);
1820
- }
1821
- }
1822
- const a = Array.isArray(t.textUpdates) ? t.textUpdates.map(
1823
- (I, _) => si(I ?? {}, `${s}.textUpdates[${_}]`)
1824
- ) : void 0, E = t.styleIds, l = E !== void 0 ? $t(E, s, e, !0) : void 0;
1825
- return {
1826
- nodeId: e,
1827
- ...r && r.length > 0 ? { inserts: r } : {},
1828
- ...n && n.length > 0 ? { moves: n } : {},
1829
- ...i && i.length > 0 ? { removals: i } : {},
1830
- ...o && o.size > 0 ? { changedProps: o } : {},
1831
- ...a && a.length > 0 ? { textUpdates: a } : {},
1832
- ...l !== void 0 ? { styleIds: l } : {}
1833
- };
1834
- }
1835
- function ai(t) {
1836
- const s = /* @__PURE__ */ new Map();
1837
- for (const [e, r] of Object.entries(t))
1838
- s.set(e, r);
1839
- return s;
1840
- }
1841
- function li(t, s, e) {
1842
- if (!t || typeof t != "object")
1843
- throw new w("UI update graph is missing");
1844
- const r = ot(t, "graph");
1845
- if (r.type !== "root")
1846
- throw new w('UI update root element must have type "root"');
1847
- const n = Ei(r.props, s);
1848
- return {
1849
- type: "full",
1850
- version: e,
1851
- root: r,
1852
- metadata: n
1853
- };
1854
- }
1855
- function Ii(t, s, e) {
1856
- if (!Array.isArray(t))
1857
- throw new w("UI diff changes must be an array");
1858
- if (!C(s))
1859
- throw new w("UI diff metadata must be an object");
1860
- const r = s.viewId;
1861
- if (typeof r != "string" || r.length === 0)
1862
- throw new w("UI diff metadata is missing viewId");
1863
- const n = t.map(
1864
- (_, c) => oi(_ ?? {}, `changes[${c}]`)
1865
- ), i = s.optimisticActionId === null || typeof s.optimisticActionId == "string" ? s.optimisticActionId : void 0, o = typeof s.isOptimistic == "boolean" ? s.isOptimistic : void 0, a = typeof s.isUpdate == "boolean" ? s.isUpdate : void 0, E = Q(s.optimisticPatch), l = Z(s.optimisticReconcile), I = {
1866
- viewId: r,
1867
- ...i !== void 0 ? { optimisticActionId: i } : {},
1868
- ...o !== void 0 ? { isOptimistic: o } : {},
1869
- ...a !== void 0 ? { isUpdate: a } : {},
1870
- ...E ? { optimisticPatch: E } : {},
1871
- ...l ? { optimisticReconcile: l } : {}
1872
- };
1873
- return {
1874
- type: "diff",
1875
- version: e,
1876
- changes: n,
1877
- metadata: I
1878
- };
1879
- }
1880
- function Ei(t, s) {
1881
- const e = t.viewId;
1882
- if (typeof e != "string" || e.length === 0)
1883
- throw new w("UI update root is missing viewId");
1884
- let r = e, n = t.optimisticActionId === null || typeof t.optimisticActionId == "string" ? t.optimisticActionId : void 0, i = typeof t.isOptimistic == "boolean" ? t.isOptimistic : void 0, o = typeof t.isUpdate == "boolean" ? t.isUpdate : void 0, a = Q(t.optimisticPatch), E = Z(t.optimisticReconcile);
1885
- return C(s) && (typeof s.viewId == "string" && s.viewId.length > 0 && (r = s.viewId), (s.optimisticActionId === null || typeof s.optimisticActionId == "string") && (n = s.optimisticActionId), typeof s.isOptimistic == "boolean" && (i = s.isOptimistic), typeof s.isUpdate == "boolean" && (o = s.isUpdate), s.optimisticPatch !== void 0 && (a = Q(s.optimisticPatch)), s.optimisticReconcile !== void 0 && (E = Z(s.optimisticReconcile))), {
1886
- viewId: r,
1887
- ...n !== void 0 ? { optimisticActionId: n } : {},
1888
- ...i !== void 0 ? { isOptimistic: i } : {},
1889
- ...o !== void 0 ? { isUpdate: o } : {},
1890
- ...a ? { optimisticPatch: a } : {},
1891
- ...E ? { optimisticReconcile: E } : {}
1892
- };
1893
- }
1894
- function Q(t) {
1895
- if (!C(t))
1896
- return;
1897
- const s = t, e = s.id, r = s.actionId, n = s.ordinal, i = s.baseVersion, o = s.supersedes;
1898
- if (typeof e != "string" || e.length === 0 || typeof r != "string" || r.length === 0 || typeof n != "number" || !Number.isFinite(n) || typeof i != "number" || !Number.isFinite(i))
1899
- return;
1900
- let a;
1901
- if (Array.isArray(o)) {
1902
- const E = [];
1903
- for (const l of o)
1904
- typeof l == "string" && l.length > 0 && E.push(l);
1905
- a = E;
1906
- }
1907
- return {
1908
- id: e,
1909
- actionId: r,
1910
- ordinal: n,
1911
- baseVersion: i,
1912
- ...a && a.length > 0 ? { supersedes: a } : {}
1913
- };
1914
- }
1915
- function Z(t) {
1916
- if (!C(t))
1917
- return;
1918
- const s = t, e = s.baseVersion, r = s.drop;
1919
- if (typeof e != "number" || !Number.isFinite(e))
1920
- return;
1921
- let n;
1922
- if (Array.isArray(r)) {
1923
- const i = [];
1924
- for (const o of r)
1925
- typeof o == "string" && o.length > 0 && i.push(o);
1926
- n = i;
1927
- }
1928
- return {
1929
- baseVersion: e,
1930
- ...n && n.length > 0 ? { drop: n } : {}
1931
- };
1932
- }
1933
- class w extends Error {
1934
- constructor(s, e) {
1935
- super(s), this.causeError = e, this.name = "UiUpdateParseError", e instanceof Error && (this.stack = e.stack);
1936
- }
1937
- }
1938
- function _i(t) {
1939
- let s;
1940
- try {
1941
- s = JSON.parse(t.Json);
1942
- } catch (o) {
1943
- throw new w("Failed to parse UIUpdate.Json payload", o);
1944
- }
1945
- if (!s || typeof s != "object")
1946
- throw new w("UI update snapshot must be an object");
1947
- const { type: e, version: r } = s;
1948
- if (e !== "full" && e !== "diff")
1949
- throw new w(`Unknown UI update type: ${String(e)}`);
1950
- if (typeof r != "number")
1951
- throw new w("UI update version must be a number");
1952
- const n = e === "full" ? li(s.graph, s.metadata, r) : Ii(s.changes, s.metadata, r), i = t.Payloads ? ai(t.Payloads) : /* @__PURE__ */ new Map();
1953
- return {
1954
- snapshot: n,
1955
- payloads: i
1956
- };
1957
- }
1958
- class ci {
1959
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1960
- cache = /* @__PURE__ */ new Map();
1961
- /**
1962
- * Get a cached void handler (no payload) for a node/action combination.
1963
- * Creates and caches the handler if it doesn't exist.
1964
- */
1965
- getHandler(s, e, r) {
1966
- const n = `${s}:${e}`;
1967
- let i = this.cache.get(n);
1968
- return i || (i = () => r(e), this.cache.set(n, i)), i;
1969
- }
1970
- /**
1971
- * Get a cached handler that accepts a payload.
1972
- * Creates and caches the handler if it doesn't exist.
1973
- */
1974
- getHandlerWithPayload(s, e, r) {
1975
- const n = `${s}:${e}:payload`;
1976
- let i = this.cache.get(n);
1977
- return i || (i = (o) => r(e, o), this.cache.set(n, i)), i;
1978
- }
1979
- /**
1980
- * Get a cached handler for boolean payloads.
1981
- */
1982
- getBooleanHandler(s, e, r) {
1983
- return this.getHandlerWithPayload(s, e, r);
1984
- }
1985
- /**
1986
- * Get a cached handler for string payloads.
1987
- */
1988
- getStringHandler(s, e, r) {
1989
- return this.getHandlerWithPayload(s, e, r);
1990
- }
1991
- /**
1992
- * Get a cached handler for number payloads.
1993
- */
1994
- getNumberHandler(s, e, r) {
1995
- return this.getHandlerWithPayload(s, e, r);
1996
- }
1997
- /**
1998
- * Get a cached handler for number array payloads.
1999
- */
2000
- getNumberArrayHandler(s, e, r) {
2001
- return this.getHandlerWithPayload(s, e, r);
2002
- }
2003
- /**
2004
- * Get a cached handler for nullable boolean payloads.
2005
- */
2006
- getNullableBooleanHandler(s, e, r) {
2007
- const n = `${s}:${e}:nullable-bool`;
2008
- let i = this.cache.get(n);
2009
- return i || (i = (o) => r(e, o ?? null), this.cache.set(n, i)), i;
2010
- }
2011
- /**
2012
- * Invalidate all cached handlers for a specific node.
2013
- * Call this when a node is removed from the tree.
2014
- */
2015
- invalidateNode(s) {
2016
- const e = `${s}:`;
2017
- for (const r of this.cache.keys())
2018
- r.startsWith(e) && this.cache.delete(r);
2019
- }
2020
- /**
2021
- * Invalidate a specific handler.
2022
- */
2023
- invalidateHandler(s, e) {
2024
- this.cache.delete(`${s}:${e}`), this.cache.delete(`${s}:${e}:payload`), this.cache.delete(`${s}:${e}:nullable-bool`);
2025
- }
2026
- /**
2027
- * Clear all cached handlers.
2028
- */
2029
- clear() {
2030
- this.cache.clear();
2031
- }
2032
- /**
2033
- * Get the number of cached handlers (for debugging/testing).
2034
- */
2035
- get size() {
2036
- return this.cache.size;
2037
- }
2038
- }
2039
- class fi {
2040
- views = /* @__PURE__ */ new Map();
2041
- listeners = /* @__PURE__ */ new Set();
2042
- payloads = /* @__PURE__ */ new Map();
2043
- snapshotMode = !1;
2044
- snapshot = {
2045
- views: /* @__PURE__ */ new Map(),
2046
- payloads: /* @__PURE__ */ new Map(),
2047
- optimisticPatches: /* @__PURE__ */ new Map(),
2048
- version: -1
2049
- };
2050
- rootViewId;
2051
- // Per-node subscriptions for granular updates
2052
- nodeListeners = /* @__PURE__ */ new Map();
2053
- changedNodeIds = /* @__PURE__ */ new Set();
2054
- nodeVersions = /* @__PURE__ */ new Map();
2055
- structureChanged = !1;
2056
- // Dirty flags for lazy snapshot rebuilding - start true to ensure first snapshot builds correctly
2057
- viewsDirty = !0;
2058
- patchesDirty = !0;
2059
- payloadsDirty = !0;
2060
- // Handler cache for stable event handlers
2061
- handlerCache = new ci();
2062
- getSortedPatches(s) {
2063
- const e = this.buildPatchCacheKey(s.patches);
2064
- if (s.sortedPatchesCacheKey === e && s.sortedPatchesCache)
2065
- return s.sortedPatchesCache;
2066
- const r = [...s.patches.values()].sort((n, i) => n.ordinal - i.ordinal);
2067
- return s.sortedPatchesCache = r, s.sortedPatchesCacheKey = e, r;
2068
- }
2069
- buildPatchCacheKey(s) {
2070
- if (s.size === 0) return "";
2071
- let e = "";
2072
- for (const [r, n] of s)
2073
- e += e ? `,${r}:${n.ordinal}` : `${r}:${n.ordinal}`;
2074
- return e;
2075
- }
2076
- invalidatePatchCache(s) {
2077
- s.sortedPatchesCache = void 0, s.sortedPatchesCacheKey = void 0;
2078
- }
2079
- apply(s) {
2080
- if (this.snapshotMode) {
2081
- if (s.snapshot.type !== "full")
2082
- return !1;
2083
- this.snapshotMode = !1, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.viewsDirty = !0, this.patchesDirty = !0, this.payloadsDirty = !0, this.snapshot = {
2084
- views: /* @__PURE__ */ new Map(),
2085
- payloads: /* @__PURE__ */ new Map(),
2086
- optimisticPatches: /* @__PURE__ */ new Map(),
2087
- version: -1
2088
- };
2089
- }
2090
- const { snapshot: e, payloads: r } = s, { metadata: n } = e, { viewId: i } = n;
2091
- let o = this.views.get(i);
2092
- o || (o = {
2093
- version: 0,
2094
- baselineVersion: 0,
2095
- patches: /* @__PURE__ */ new Map()
2096
- }, this.views.set(i, o));
2097
- const a = e.type === "diff" && n.isUpdate === !0;
2098
- if (e.version < o.version || e.version === o.version && !a)
2099
- return !1;
2100
- let E = !1;
2101
- if (this.rootViewId || (this.rootViewId = i, E = !0, this.structureChanged = !0), n.optimisticReconcile?.drop)
2102
- for (const I of n.optimisticReconcile.drop)
2103
- o.patches.delete(I) && (E = !0, this.patchesDirty = !0, this.invalidatePatchCache(o));
2104
- if (n.optimisticPatch?.supersedes)
2105
- for (const I of n.optimisticPatch.supersedes)
2106
- o.patches.delete(I) && (E = !0, this.patchesDirty = !0, this.invalidatePatchCache(o));
2107
- const l = o.composite ?? o.baseline;
2108
- if (e.type === "full")
2109
- o.baseline = e.root, o.composite = e.root, o.baselineVersion = n.optimisticReconcile?.baseVersion ?? e.version, o.patches.clear(), this.invalidatePatchCache(o), o.version = e.version, E = !0, this.viewsDirty = !0, this.patchesDirty = !0, this.structureChanged = !0, e.root && b(e.root, this.changedNodeIds);
2110
- else if (n.optimisticPatch) {
2111
- if (!l)
2112
- return !1;
2113
- const I = J(l, e.changes);
2114
- I !== l && (o.composite = I, E = !0, this.viewsDirty = !0, j(l, I, this.changedNodeIds));
2115
- const _ = n.optimisticPatch, c = {
2116
- id: _.id,
2117
- actionId: _.actionId,
2118
- ordinal: _.ordinal,
2119
- baseVersion: _.baseVersion,
2120
- changes: e.changes
2121
- };
2122
- o.patches.set(c.id, c), this.invalidatePatchCache(o), E = !0, this.patchesDirty = !0, o.version = e.version;
2123
- } else {
2124
- const I = o.baseline ?? l;
2125
- if (!I)
2126
- return !1;
2127
- const _ = J(I, e.changes);
2128
- _ !== I ? (o.baseline = _, E = !0, this.viewsDirty = !0) : o.baseline = _, o.baselineVersion = n.optimisticReconcile?.baseVersion ?? e.version;
2129
- let c = o.baseline ?? _;
2130
- const N = this.getSortedPatches(o);
2131
- for (const u of N) {
2132
- const y = J(c, u.changes);
2133
- y !== c && (E = !0, this.viewsDirty = !0), c = y, u.baseVersion = o.baselineVersion;
2134
- }
2135
- o.composite !== c && (o.composite = c, E = !0, this.viewsDirty = !0), l && c ? j(l, c, this.changedNodeIds) : c && b(c, this.changedNodeIds), o.version = e.version;
2136
- }
2137
- for (const [I, _] of r)
2138
- this.payloads.get(I) !== _ && (this.payloads.set(I, _), E = !0, this.payloadsDirty = !0);
2139
- return E ? (this.commitSnapshot(), this.notify(), !0) : (o.version = e.version, !1);
2140
- }
2141
- replaceFromWire(s) {
2142
- const e = {
2143
- rootViewId: s.rootViewId,
2144
- views: new Map(s.views),
2145
- payloads: new Map(s.payloads),
2146
- optimisticPatches: new Map(s.optimisticPatches),
2147
- version: s.version
2148
- };
2149
- return this.replaceSnapshot(e);
2150
- }
2151
- patchFromOp(s) {
2152
- this.snapshotMode = !0;
2153
- const e = s.expectedBaseVersion;
2154
- if (e !== void 0 && this.snapshot.version !== e)
2155
- return !1;
2156
- let r = !1, n = null, i = null, o = null;
2157
- const a = () => (n || (n = new Map(this.snapshot.views)), n), E = () => (i || (i = new Map(this.snapshot.payloads)), i), l = () => (o || (o = new Map(this.snapshot.optimisticPatches)), o);
2158
- if (s.deleteViews && s.deleteViews.length > 0)
2159
- for (const c of s.deleteViews)
2160
- a().delete(c) && (r = !0, this.structureChanged = !0);
2161
- if (s.upsertViews && s.upsertViews.length > 0)
2162
- for (const [c, N] of s.upsertViews) {
2163
- const u = a(), y = u.get(c);
2164
- y !== N && (u.set(c, N), r = !0, y ? j(y, N, this.changedNodeIds) : (b(N, this.changedNodeIds), this.structureChanged = !0));
2165
- }
2166
- if (s.deletePayloads && s.deletePayloads.length > 0)
2167
- for (const c of s.deletePayloads)
2168
- E().delete(c) && (r = !0);
2169
- if (s.upsertPayloads && s.upsertPayloads.length > 0)
2170
- for (const [c, N] of s.upsertPayloads) {
2171
- const u = E();
2172
- u.get(c) !== N && (u.set(c, N), r = !0);
2173
- }
2174
- if (s.deleteOptimisticPatchesForViews && s.deleteOptimisticPatchesForViews.length > 0)
2175
- for (const c of s.deleteOptimisticPatchesForViews)
2176
- l().delete(c) && (r = !0);
2177
- if (s.upsertOptimisticPatches && s.upsertOptimisticPatches.length > 0)
2178
- for (const [c, N] of s.upsertOptimisticPatches) {
2179
- const u = l(), y = u.get(c);
2180
- Ai(y, N) || (u.set(c, N), r = !0);
2181
- }
2182
- const I = s.rootViewId ?? this.snapshot.rootViewId;
2183
- I !== this.snapshot.rootViewId && (r = !0, this.structureChanged = !0);
2184
- const _ = s.nextVersion;
2185
- if (_ !== this.snapshot.version && (r = !0), !r)
2186
- return this.snapshot = { ...this.snapshot, version: _ }, !1;
2187
- for (const c of this.changedNodeIds)
2188
- this.nodeVersions.set(c, (this.nodeVersions.get(c) ?? 0) + 1);
2189
- return this.snapshot = {
2190
- rootViewId: I,
2191
- views: n ?? new Map(this.snapshot.views),
2192
- payloads: i ?? new Map(this.snapshot.payloads),
2193
- optimisticPatches: o ?? new Map(this.snapshot.optimisticPatches),
2194
- version: _
2195
- }, this.notify(), !0;
2196
- }
2197
- replaceSnapshot(s) {
2198
- this.snapshotMode = !0;
2199
- const e = this.snapshot, r = e.version !== s.version || e.rootViewId !== s.rootViewId || e.views.size !== s.views.size || e.payloads.size !== s.payloads.size || e.optimisticPatches.size !== s.optimisticPatches.size;
2200
- (e.rootViewId !== s.rootViewId || e.views.size !== s.views.size) && (this.structureChanged = !0);
2201
- for (const [n, i] of s.views) {
2202
- const o = e.views.get(n);
2203
- o ? j(o, i, this.changedNodeIds) : (b(i, this.changedNodeIds), this.structureChanged = !0);
2204
- }
2205
- for (const n of this.changedNodeIds)
2206
- this.nodeVersions.set(n, (this.nodeVersions.get(n) ?? 0) + 1);
2207
- return this.snapshot = s, r && this.notify(), r;
2208
- }
2209
- clear() {
2210
- (this.snapshot.rootViewId === void 0 || this.snapshot.rootViewId.length === 0) && this.snapshot.views.size === 0 && this.snapshot.payloads.size === 0 && this.snapshot.optimisticPatches.size === 0 || (this.snapshotMode = !0, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.viewsDirty = !0, this.patchesDirty = !0, this.payloadsDirty = !0, this.snapshot = {
2211
- views: /* @__PURE__ */ new Map(),
2212
- payloads: /* @__PURE__ */ new Map(),
2213
- optimisticPatches: /* @__PURE__ */ new Map(),
2214
- version: -1
2215
- }, this.structureChanged = !0, this.notify());
2216
- }
2217
- getSnapshot() {
2218
- return this.snapshot;
2219
- }
2220
- subscribe(s) {
2221
- return this.listeners.add(s), () => {
2222
- this.listeners.delete(s);
2223
- };
2224
- }
2225
- subscribeNode(s, e) {
2226
- let r = this.nodeListeners.get(s);
2227
- return r || (r = /* @__PURE__ */ new Set(), this.nodeListeners.set(s, r)), r.add(e), () => {
2228
- r && (r.delete(e), r.size === 0 && this.nodeListeners.delete(s));
2229
- };
2230
- }
2231
- getNode(s) {
2232
- const e = this.snapshot.views.get(s);
2233
- if (e)
2234
- return e;
2235
- for (const r of this.snapshot.views.values()) {
2236
- const n = Wt(r, s);
2237
- if (n)
2238
- return n;
2239
- }
2240
- }
2241
- getNodeVersion(s) {
2242
- return this.nodeVersions.get(s) ?? 0;
2243
- }
2244
- notifyNodes() {
2245
- if (this.changedNodeIds.size === 0 || this.nodeListeners.size === 0) {
2246
- this.changedNodeIds.clear();
2247
- return;
2248
- }
2249
- for (const s of this.changedNodeIds) {
2250
- const e = this.nodeListeners.get(s);
2251
- if (e)
2252
- for (const r of e)
2253
- r();
2254
- }
2255
- this.changedNodeIds.clear();
2256
- }
2257
- commitSnapshot() {
2258
- let s, e, r;
2259
- if (this.viewsDirty) {
2260
- const i = /* @__PURE__ */ new Map();
2261
- for (const [o, a] of this.views)
2262
- a.composite ? i.set(o, a.composite) : a.baseline && i.set(o, a.baseline);
2263
- s = i, this.viewsDirty = !1;
2264
- } else
2265
- s = this.snapshot.views;
2266
- if (this.patchesDirty) {
2267
- const i = /* @__PURE__ */ new Map();
2268
- for (const [o, a] of this.views)
2269
- if (a.patches.size > 0) {
2270
- const E = this.getSortedPatches(a);
2271
- i.set(
2272
- o,
2273
- E.map((l) => ({
2274
- id: l.id,
2275
- actionId: l.actionId,
2276
- ordinal: l.ordinal,
2277
- baseVersion: l.baseVersion
2278
- }))
2279
- );
2280
- }
2281
- e = i, this.patchesDirty = !1;
2282
- } else
2283
- e = this.snapshot.optimisticPatches;
2284
- this.payloadsDirty ? (r = new Map(this.payloads), this.payloadsDirty = !1) : r = this.snapshot.payloads;
2285
- let n = this.rootViewId && this.views.has(this.rootViewId) ? this.views.get(this.rootViewId)?.version : void 0;
2286
- if (n === void 0)
2287
- for (const i of this.views.values())
2288
- n = n === void 0 ? i.version : Math.max(n, i.version);
2289
- this.snapshot = {
2290
- rootViewId: this.rootViewId,
2291
- views: s,
2292
- payloads: r,
2293
- optimisticPatches: e,
2294
- version: n
2295
- };
2296
- for (const i of this.changedNodeIds)
2297
- this.nodeVersions.set(i, (this.nodeVersions.get(i) ?? 0) + 1);
2298
- }
2299
- notify() {
2300
- if (this.notifyNodes(), this.structureChanged) {
2301
- this.structureChanged = !1;
2302
- for (const s of this.listeners)
2303
- s();
2304
- }
2305
- }
2306
- }
2307
- class hi {
2308
- streams = /* @__PURE__ */ new Map();
2309
- listeners = /* @__PURE__ */ new Set();
2310
- apply(s, e) {
2311
- const n = this.getOrCreateStreamEntry(s).store.apply(e);
2312
- return n && this.notify(s), n;
2313
- }
2314
- applyStoreOp(s) {
2315
- if (s.type === "ReplaceStreamSnapshot") {
2316
- const e = this.getOrCreateStreamEntry(s.snapshot.streamId), r = e.category !== s.snapshot.category;
2317
- return e.category = s.snapshot.category, e.store.replaceFromWire(s.snapshot) || r ? (this.notify(s.snapshot.streamId), !0) : !1;
2318
- }
2319
- if (s.type === "PatchStreamSnapshot") {
2320
- const e = this.getOrCreateStreamEntry(s.streamId), r = s.category !== void 0 && e.category !== s.category;
2321
- return s.category !== void 0 && (e.category = s.category), e.store.patchFromOp(s) || r ? (this.notify(s.streamId), !0) : !1;
2322
- }
2323
- if (s.type === "ClearStream") {
2324
- const e = this.streams.get(s.streamId);
2325
- return e ? (e.store.clear(), this.notify(s.streamId), !0) : !1;
2326
- }
2327
- return s.type === "RemoveStream" ? this.streams.delete(s.streamId) ? (this.notify(s.streamId), !0) : !1 : s.type === "SetStreamCategory" ? (this.setCategory(s.streamId, s.category), !0) : !1;
2328
- }
2329
- applyStoreOps(s) {
2330
- for (const e of s)
2331
- this.applyStoreOp(e);
2332
- }
2333
- clear(s) {
2334
- const e = this.streams.get(s);
2335
- e && (e.store.clear(), this.notify(s));
2336
- }
2337
- remove(s) {
2338
- this.streams.delete(s) && this.notify(s);
2339
- }
2340
- setCategory(s, e) {
2341
- const r = this.getOrCreateStreamEntry(s);
2342
- r.category !== e && (r.category = e, this.notify(s));
2343
- }
2344
- getSnapshot(s) {
2345
- const e = this.streams.get(s);
2346
- return e ? {
2347
- ...e.store.getSnapshot(),
2348
- streamId: s,
2349
- category: e.category
2350
- } : void 0;
2351
- }
2352
- getSnapshots() {
2353
- const s = [];
2354
- for (const [e, r] of this.streams) {
2355
- const n = r.store.getSnapshot();
2356
- s.push({
2357
- ...n,
2358
- streamId: e,
2359
- category: r.category
2360
- });
2361
- }
2362
- return s;
2363
- }
2364
- subscribe(s) {
2365
- return this.listeners.add(s), () => {
2366
- this.listeners.delete(s);
2367
- };
2368
- }
2369
- getOrCreateStreamEntry(s) {
2370
- let e = this.streams.get(s);
2371
- return e || (e = { store: new fi() }, this.streams.set(s, e)), e;
2372
- }
2373
- notify(s) {
2374
- for (const e of this.listeners)
2375
- e(s);
2376
- }
2377
- }
2378
- function J(t, s, e) {
2379
- if (s.length === 0)
2380
- return t;
2381
- const r = /* @__PURE__ */ new Map();
2382
- for (const n of s)
2383
- r.set(n.nodeId, n);
2384
- return Xt(t, r);
2385
- }
2386
- function Xt(t, s, e) {
2387
- const r = s.get(t.id);
2388
- let n = t, i = !1;
2389
- if (r?.textUpdates && r.textUpdates.length > 0) {
2390
- const f = Si(t, r.textUpdates);
2391
- n = f.node, i = f.changed;
2392
- }
2393
- let o = !1, a = n.props;
2394
- if (r?.changedProps && r.changedProps.size > 0)
2395
- for (const [f, S] of r.changedProps.entries()) {
2396
- const h = a[f];
2397
- if (S === void 0)
2398
- (h !== void 0 || f in a) && (o || (a = G(a), o = !0), delete a[f]);
2399
- else if (tt(S)) {
2400
- const A = G(S);
2401
- p(A, h) || (o || (a = G(a), o = !0), a[f] = A);
2402
- } else
2403
- p(S, h) || (o || (a = G(a), o = !0), a[f] = S);
2404
- }
2405
- let E = !1, l = n.styleIds;
2406
- r?.styleIds !== void 0 && (zt(n.styleIds, r.styleIds) || (l = r.styleIds, E = !0));
2407
- const I = n.children ?? [];
2408
- let _ = I, c = !1;
2409
- if (r?.removals && r.removals.length > 0 || r?.moves && r.moves.length > 0 || r?.inserts && r.inserts.length > 0) {
2410
- const f = _.slice();
2411
- if (r?.removals && r.removals.length > 0) {
2412
- const S = [...r.removals].sort((h, A) => A.index - h.index);
2413
- for (const h of S)
2414
- if (h.index >= 0 && h.index < f.length && f[h.index].id === h.nodeId)
2415
- f.splice(h.index, 1);
2416
- else {
2417
- const A = f.findIndex((R) => R.id === h.nodeId);
2418
- A >= 0 && f.splice(A, 1);
2419
- }
2420
- c = !0;
2421
- }
2422
- if (r?.moves && r.moves.length > 0) {
2423
- const S = [...r.moves].sort((A, R) => A.toIndex - R.toIndex), h = /* @__PURE__ */ new Map();
2424
- for (const A of S) {
2425
- const R = f.findIndex((z) => z.id === A.nodeId);
2426
- R >= 0 && (h.set(A.nodeId, f[R]), f.splice(R, 1));
2427
- }
2428
- for (const A of S) {
2429
- const R = h.get(A.nodeId);
2430
- if (R) {
2431
- const z = Math.min(A.toIndex, f.length);
2432
- f.splice(z, 0, R);
2433
- }
2434
- }
2435
- c = !0;
2436
- }
2437
- if (r?.inserts && r.inserts.length > 0) {
2438
- const S = [...r.inserts].sort((h, A) => h.index - A.index);
2439
- for (const h of S) {
2440
- const A = Math.min(h.index, f.length);
2441
- f.splice(A, 0, h.node);
2442
- }
2443
- c = !0;
2444
- }
2445
- _ = f;
2446
- }
2447
- let u;
2448
- for (let f = 0; f < _.length; f++) {
2449
- const S = _[f], h = Xt(S, s);
2450
- h !== S && (u || (u = _.slice()), u[f] = h);
2451
- }
2452
- return u && (_ = u, c = !0), i || o || E || c ? !o && !c && !E ? n : {
2453
- id: t.id,
2454
- type: t.type,
2455
- props: o ? a : n.props,
2456
- children: c ? _ : I,
2457
- styleIds: E ? l : n.styleIds,
2458
- ...t.sourceMarker ? { sourceMarker: t.sourceMarker } : {}
2459
- } : t;
2460
- }
2461
- function b(t, s) {
2462
- if (s.add(t.id), t.children)
2463
- for (const e of t.children)
2464
- b(e, s);
2465
- }
2466
- const X = [];
2467
- function ui(t) {
2468
- for (; X.length <= t; )
2469
- X.push(/* @__PURE__ */ new Map());
2470
- return X[t].clear(), X[t];
2471
- }
2472
- function j(t, s, e) {
2473
- jt(t, s, e, 0);
2474
- }
2475
- function jt(t, s, e, r) {
2476
- if (t === s)
2477
- return;
2478
- (t.type !== s.type || !Ti(t.props, s.props) || !zt(t.styleIds, s.styleIds)) && e.add(s.id);
2479
- const i = t.children ?? [], o = s.children ?? [];
2480
- if (i !== o) {
2481
- const a = ui(r);
2482
- for (const l of i)
2483
- a.set(l.id, l);
2484
- let E = !1;
2485
- for (let l = 0; l < o.length; l++) {
2486
- const I = o[l], _ = a.get(I.id);
2487
- _ ? (jt(_, I, e, r + 1), !E && l < i.length && i[l].id !== I.id && (E = !0)) : (b(I, e), E = !0);
2488
- }
2489
- (i.length !== o.length || E) && e.add(s.id);
2490
- }
2491
- }
2492
- function Ti(t, s) {
2493
- return p(t, s);
2494
- }
2495
- function Wt(t, s) {
2496
- if (t.id === s)
2497
- return t;
2498
- if (t.children)
2499
- for (const e of t.children) {
2500
- const r = Wt(e, s);
2501
- if (r)
2502
- return r;
2503
- }
2504
- }
2505
- function zt(t, s) {
2506
- return p(t, s);
2507
- }
2508
- function Ai(t, s) {
2509
- if (t === s) return !0;
2510
- if (!t || !s || t.length !== s.length) return !1;
2511
- for (let e = 0; e < t.length; e++) {
2512
- const r = t[e], n = s[e];
2513
- if (r.id !== n.id || r.actionId !== n.actionId || r.ordinal !== n.ordinal || r.baseVersion !== n.baseVersion)
2514
- return !1;
2515
- }
2516
- return !0;
2517
- }
2518
- function Ni(t, s) {
2519
- if (s.length === 0)
2520
- return t;
2521
- const e = [...s].sort((i, o) => i.start - o.start);
2522
- let r = t, n = 0;
2523
- for (const i of e) {
2524
- const o = lt(i.start + n, 0, r.length);
2525
- if (i.end == null) {
2526
- const I = r.slice(o), _ = di(I, i.insertedText);
2527
- r = r.slice(0, o) + i.insertedText + I.slice(_), n += i.insertedText.length - _;
2528
- continue;
2529
- }
2530
- const a = i.end + n, E = lt(a, o, r.length), l = E - o;
2531
- r = r.slice(0, o) + i.insertedText + r.slice(E), n += i.insertedText.length - l;
2532
- }
2533
- return r;
2534
- }
2535
- function Si(t, s, e) {
2536
- if (s.length === 0)
2537
- return { node: t, changed: !1 };
2538
- const r = /* @__PURE__ */ new Map();
2539
- for (const n of s) {
2540
- const i = r.get(n.nodeId);
2541
- i ? i.push(n) : r.set(n.nodeId, [n]);
2542
- }
2543
- return Jt(t, r);
2544
- }
2545
- function Jt(t, s, e) {
2546
- const r = s.get(t.id) ?? [];
2547
- let n = !1, i = t.props;
2548
- if (r.length > 0) {
2549
- const l = /* @__PURE__ */ new Map();
2550
- for (const I of r) {
2551
- const _ = l.get(I.propertyName);
2552
- _ ? _.push(I) : l.set(I.propertyName, [I]);
2553
- }
2554
- for (const [I, _] of l.entries()) {
2555
- const c = i[I], u = Ni(typeof c == "string" ? c : "", _);
2556
- n || (i = G(i), n = !0), i[I] = u;
2557
- }
2558
- }
2559
- let o = !1;
2560
- const a = t.children ?? [];
2561
- let E = a;
2562
- if (a.length > 0) {
2563
- let l;
2564
- for (let I = 0; I < a.length; I++) {
2565
- const _ = a[I], c = Jt(_, s);
2566
- c.changed && (l || (l = [...a]), l[I] = c.node);
2567
- }
2568
- l && (E = l, o = !0);
2569
- }
2570
- return !n && !o ? { node: t, changed: !1 } : {
2571
- node: {
2572
- id: t.id,
2573
- type: t.type,
2574
- props: n ? i : t.props,
2575
- children: o ? E : a,
2576
- styleIds: t.styleIds,
2577
- ...t.sourceMarker ? { sourceMarker: t.sourceMarker } : {}
2578
- },
2579
- changed: !0
2580
- };
2581
- }
2582
- function lt(t, s, e) {
2583
- return Math.max(s, Math.min(e, t));
2584
- }
2585
- function di(t, s) {
2586
- const e = Math.min(t.length, s.length);
2587
- let r = 0;
2588
- for (; r < e && t.charCodeAt(r) === s.charCodeAt(r); )
2589
- r++;
2590
- return r;
2591
- }
2592
- function G(t) {
2593
- const s = {}, e = Object.keys(t);
2594
- for (let r = 0; r < e.length; r++) {
2595
- const n = e[r];
2596
- s[n] = t[n];
2597
- }
2598
- return s;
2599
- }
2600
- function tt(t) {
2601
- return typeof t == "object" && t !== null && !Array.isArray(t);
2602
- }
2603
- function p(t, s) {
2604
- if (Object.is(t, s))
2605
- return !0;
2606
- if (Array.isArray(t) && Array.isArray(s)) {
2607
- if (t.length !== s.length)
2608
- return !1;
2609
- for (let e = 0; e < t.length; e++)
2610
- if (!p(t[e], s[e]))
2611
- return !1;
2612
- return !0;
2613
- }
2614
- if (tt(t) && tt(s)) {
2615
- const e = Object.keys(t), r = Object.keys(s);
2616
- if (e.length !== r.length)
2617
- return !1;
2618
- for (const n of e)
2619
- if (!p(t[n], s[n]))
2620
- return !1;
2621
- return !0;
2622
- }
2623
- return !1;
2624
- }
2625
- const Ci = 16, yi = 50, m = new hi(), k = /* @__PURE__ */ new Map(), Y = /* @__PURE__ */ new Map();
2626
- let qt = Ci, Qt = yi, B = [], x = null, H = null, L = 0, W = 0;
2627
- const F = /* @__PURE__ */ new Map();
2628
- function Di() {
2629
- return typeof performance < "u" ? performance.now() : Date.now();
2630
- }
2631
- function wi() {
2632
- try {
2633
- return crypto.randomUUID();
2634
- } catch {
2635
- return `${Date.now()}_${Math.random().toString(16).slice(2)}`;
2636
- }
2637
- }
2638
- function Ri(t) {
2639
- const s = [];
2640
- for (const n of t.views)
2641
- s.push(n);
2642
- const e = [];
2643
- for (const n of t.payloads)
2644
- e.push(n);
2645
- const r = [];
2646
- for (const [n, i] of t.optimisticPatches)
2647
- r.push([n, i.slice()]);
2648
- return {
2649
- streamId: t.streamId,
2650
- category: t.category,
2651
- version: t.version ?? -1,
2652
- rootViewId: t.rootViewId,
2653
- views: s,
2654
- payloads: e,
2655
- optimisticPatches: r
2656
- };
2657
- }
2658
- function Ui(t, s) {
2659
- if (t === s) return !0;
2660
- if (!t || !s || t.length !== s.length) return !1;
2661
- for (let e = 0; e < t.length; e++) {
2662
- const r = t[e], n = s[e];
2663
- if (r.id !== n.id || r.actionId !== n.actionId || r.ordinal !== n.ordinal || r.baseVersion !== n.baseVersion)
2664
- return !1;
2665
- }
2666
- return !0;
2667
- }
2668
- function Li(t, s, e) {
2669
- if (!e || e.version === -1)
2670
- return { type: "ReplaceStreamSnapshot", snapshot: Ri(s) };
2671
- let r, n;
2672
- for (const [l, I] of s.views)
2673
- e.views.get(l) !== I && (r ??= []).push([l, I]);
2674
- for (const l of e.views.keys())
2675
- s.views.has(l) || (n ??= []).push(l);
2676
- let i, o;
2677
- for (const [l, I] of s.payloads)
2678
- e.payloads.get(l) !== I && (i ??= []).push([l, I]);
2679
- for (const l of e.payloads.keys())
2680
- s.payloads.has(l) || (o ??= []).push(l);
2681
- let a, E;
2682
- for (const [l, I] of s.optimisticPatches) {
2683
- const _ = e.optimisticPatches.get(l);
2684
- Ui(_, I) || (a ??= []).push([l, I.slice()]);
2685
- }
2686
- for (const l of e.optimisticPatches.keys())
2687
- s.optimisticPatches.has(l) || (E ??= []).push(l);
2688
- return {
2689
- type: "PatchStreamSnapshot",
2690
- streamId: t,
2691
- category: s.category,
2692
- nextVersion: s.version ?? -1,
2693
- expectedBaseVersion: e.version ?? -1,
2694
- rootViewId: s.rootViewId,
2695
- upsertViews: r,
2696
- deleteViews: n,
2697
- upsertPayloads: i,
2698
- deletePayloads: o,
2699
- upsertOptimisticPatches: a,
2700
- deleteOptimisticPatchesForViews: E
2701
- };
2702
- }
2703
- function Zt() {
2704
- x || (x = setTimeout(It, qt)), H || (H = setTimeout(It, Qt));
2705
- }
2706
- function g(t) {
2707
- B.push(t), Zt();
2708
- }
2709
- function It() {
2710
- if (x && (clearTimeout(x), x = null), H && (clearTimeout(H), H = null), B.length === 0 && F.size === 0) {
2711
- L = 0, W = 0;
2712
- return;
2713
- }
2714
- const t = [];
2715
- for (const [e, r] of F)
2716
- t.push({ trackId: e, version: r.version, senderId: r.senderId });
2717
- const s = {
2718
- batchId: wi(),
2719
- createdAtMs: Di(),
2720
- ops: B,
2721
- ...t.length > 0 ? { acks: t } : {},
2722
- stats: { uiMessagesConsumed: L, bytesConsumed: W }
2723
- };
2724
- B = [], L = 0, W = 0, F.clear(), self.postMessage(s);
2725
- }
2726
- function te(t) {
2727
- return `${t.senderId}_${t.trackId}`;
2728
- }
2729
- async function mi(t) {
2730
- const s = await mr(t), e = /* @__PURE__ */ new Set();
2731
- for (const r of Object.values(s.UIStreams ?? {})) {
2732
- const n = r.StreamId;
2733
- e.add(n);
2734
- const i = r.Info?.Category;
2735
- m.getSnapshot(n)?.category !== i && (m.setCategory(n, i), g({ type: "SetStreamCategory", streamId: n, category: i }));
2736
- }
2737
- for (const r of m.getSnapshots())
2738
- e.has(r.streamId) || (m.remove(r.streamId), Y.delete(r.streamId), g({ type: "RemoveStream", streamId: r.streamId }));
2739
- }
2740
- async function Oi(t) {
2741
- const s = et(t), e = te(s), r = await ti(t), n = _i(r), i = F.get(s.trackId);
2742
- if ((i === void 0 || n.snapshot.version > i.version) && (F.set(s.trackId, { version: n.snapshot.version, senderId: s.senderId }), Zt()), !m.apply(e, n))
2743
- return;
2744
- const a = m.getSnapshot(e);
2745
- if (!a)
2746
- return;
2747
- const E = Y.get(e);
2748
- Y.set(e, a), g(Li(e, a, E));
2749
- }
2750
- async function Pi(t) {
2751
- const s = await Dn(t);
2752
- if (!s.StyleId)
2753
- return;
2754
- const e = {
2755
- styleId: s.StyleId,
2756
- css: s.Style?.css,
2757
- common: s.Style?.common
2758
- }, r = k.get(e.styleId);
2759
- r && r.css === e.css && r.common === e.common || (k.set(e.styleId, e), g({ type: "UpsertUiStyle", style: e }));
2760
- }
2761
- async function gi(t) {
2762
- const s = await gn(t);
2763
- if (s.Styles)
2764
- for (const e of s.Styles) {
2765
- if (!e.StyleId)
2766
- continue;
2767
- const r = {
2768
- styleId: e.StyleId,
2769
- css: e.Style?.css,
2770
- common: e.Style?.common
2771
- }, n = k.get(r.styleId);
2772
- n && n.css === r.css && n.common === r.common || (k.set(r.styleId, r), g({ type: "UpsertUiStyle", style: r }));
2773
- }
2774
- }
2775
- function bi(t) {
2776
- const s = et(t), e = te(s);
2777
- m.clear(e), Y.delete(e), g({ type: "ClearStream", streamId: e });
2778
- }
2779
- async function Fi(t) {
2780
- const s = await $n(t);
2781
- if (!(!s.StyleIds || s.StyleIds.length === 0))
2782
- for (const e of s.StyleIds)
2783
- k.delete(e) && g({ type: "RemoveUiStyle", styleId: e });
2784
- }
2785
- async function vi(t) {
2786
- const s = new Uint8Array(t);
2787
- W += s.byteLength;
2788
- const e = s;
2789
- switch (se(e)) {
2790
- case P.CORE_GLOBAL_STATE:
2791
- await mi(e), L++;
2792
- return;
2793
- case P.UI_UPDATE:
2794
- try {
2795
- await Oi(e);
2796
- } catch (n) {
2797
- return n instanceof w, void 0;
2798
- } finally {
2799
- L++;
2800
- }
2801
- return;
2802
- case P.UI_STYLES:
2803
- await Pi(e), L++;
2804
- return;
2805
- case P.UI_STYLES_BATCH:
2806
- await gi(e), L++;
2807
- return;
2808
- case P.UI_STYLES_DELETE:
2809
- await Fi(e), L++;
2810
- return;
2811
- case P.ACTION_UI_CLEAR_STREAM:
2812
- bi(e), L++;
2813
- return;
2814
- default:
2815
- return;
2816
- }
2817
- }
2818
- self.addEventListener("message", (t) => {
2819
- const s = t.data;
2820
- if (s.type === "configure") {
2821
- typeof s.flushIntervalMs == "number" && Number.isFinite(s.flushIntervalMs) && s.flushIntervalMs >= 0 && (qt = s.flushIntervalMs), typeof s.maxLatencyMs == "number" && Number.isFinite(s.maxLatencyMs) && s.maxLatencyMs >= 0 && (Qt = s.maxLatencyMs);
2822
- return;
2823
- }
2824
- if (s.type === "clear") {
2825
- B = [], Y.clear(), F.clear(), k.clear();
2826
- for (const e of m.getSnapshots())
2827
- m.remove(e.streamId);
2828
- return;
2829
- }
2830
- s.type === "protocol" && vi(s.message).catch(() => {
2831
- });
2832
- });