@ikonai/sdk-ui 0.0.28 → 0.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2486 @@
1
+ function zt(t) {
2
+ if (t.length < 8)
3
+ throw new Error("Protocol message too short");
4
+ return (t[4] | t[5] << 8 | t[6] << 16 | t[7] << 24) >>> 0;
5
+ }
6
+ function q(t) {
7
+ const e = H(t), s = new DataView(e.buffer, e.byteOffset, e.byteLength);
8
+ if (e.length < 27)
9
+ throw new Error("Protocol payload too short");
10
+ const r = s.getUint32(0, !0), n = s.getUint32(4, !0), i = s.getUint32(8, !0), o = s.getUint32(12, !0), a = s.getUint32(16, !0), I = s.getUint32(20, !0), E = s.getUint8(24), l = s.getUint8(25), c = s.getUint8(26);
11
+ if (27 + I * 4 > e.length)
12
+ throw new Error("Protocol header exceeds payload length");
13
+ const u = [];
14
+ let T = 27;
15
+ for (let f = 0; f < I; f++)
16
+ u.push(s.getUint32(T, !0)), T += 4;
17
+ return {
18
+ length: r,
19
+ opcode: n,
20
+ senderId: i,
21
+ trackId: o,
22
+ sequenceId: a,
23
+ targetIds: u,
24
+ payloadVersion: E,
25
+ payloadType: l,
26
+ flags: c
27
+ };
28
+ }
29
+ function K(t, e, s) {
30
+ const r = H(t), n = q(r);
31
+ if (e !== void 0 && n.opcode !== e)
32
+ throw new Error(`Unexpected opcode ${n.opcode}`);
33
+ if (s !== void 0 && n.payloadVersion !== s)
34
+ throw new Error(`Unexpected payload version ${n.payloadVersion}`);
35
+ if (n.payloadType !== 8)
36
+ throw new Error(`Unexpected payload type ${n.payloadType}`);
37
+ const i = 27 + n.targetIds.length * 4;
38
+ return r.subarray(i, n.length);
39
+ }
40
+ var g = /* @__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))(g || {});
41
+ const Wt = 161, Jt = 162;
42
+ new TextEncoder();
43
+ const qt = new TextDecoder("utf-8", { fatal: !0 });
44
+ class D {
45
+ constructor(e, s, r) {
46
+ this.buffer = e, this.version = s, this.offset = r, this.end = e.length - 1;
47
+ }
48
+ offset;
49
+ end;
50
+ static create(e) {
51
+ const s = H(e);
52
+ if (s.length < 2)
53
+ throw new Error("Teleport payload too short");
54
+ if (s[0] !== Wt || s[s.length - 1] !== Jt)
55
+ throw new Error("Teleport object missing markers");
56
+ const r = { offset: 1 }, n = d(s, r, "InvalidLength");
57
+ return new D(s, n, r.offset);
58
+ }
59
+ next() {
60
+ if (this.offset >= this.end)
61
+ return null;
62
+ if (this.offset + 5 > this.buffer.length)
63
+ throw new Error("Teleport object truncated");
64
+ const e = ee(this.buffer, this.offset);
65
+ this.offset += 4;
66
+ const s = this.buffer[this.offset++], r = s >> 4 & 15;
67
+ if ((s & 15) !== 0)
68
+ throw new Error("Teleport field flags must be zero");
69
+ const n = P(r);
70
+ let i;
71
+ if (n >= 0)
72
+ A(this.buffer, this.offset, n), i = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
73
+ else {
74
+ const o = { offset: this.offset }, a = d(this.buffer, o, "InvalidLength");
75
+ A(this.buffer, o.offset, a), i = this.buffer.subarray(o.offset, o.offset + a), this.offset = o.offset + a;
76
+ }
77
+ return new Qt(e, r, i);
78
+ }
79
+ }
80
+ class w {
81
+ constructor(e, s) {
82
+ this.type = e, this.payload = s;
83
+ }
84
+ asInt32() {
85
+ return this.ensureType(
86
+ 3
87
+ /* Int32 */
88
+ ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getInt32(0, !0);
89
+ }
90
+ asUInt32() {
91
+ return this.ensureType(
92
+ 5
93
+ /* UInt32 */
94
+ ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getUint32(0, !0);
95
+ }
96
+ asInt64() {
97
+ return this.ensureType(
98
+ 4
99
+ /* Int64 */
100
+ ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigInt64(0, !0);
101
+ }
102
+ asUInt64() {
103
+ return this.ensureType(
104
+ 6
105
+ /* UInt64 */
106
+ ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getBigUint64(0, !0);
107
+ }
108
+ asFloat32() {
109
+ return this.ensureType(
110
+ 7
111
+ /* Float32 */
112
+ ), new DataView(this.payload.buffer, this.payload.byteOffset, 4).getFloat32(0, !0);
113
+ }
114
+ asFloat64() {
115
+ return this.ensureType(
116
+ 8
117
+ /* Float64 */
118
+ ), new DataView(this.payload.buffer, this.payload.byteOffset, 8).getFloat64(0, !0);
119
+ }
120
+ asBool() {
121
+ return this.ensureType(
122
+ 2
123
+ /* Bool */
124
+ ), this.payload.length > 0 && this.payload[0] !== 0;
125
+ }
126
+ asBinary() {
127
+ return this.ensureType(
128
+ 13
129
+ /* Binary */
130
+ ), this.payload;
131
+ }
132
+ asUtf8() {
133
+ return this.ensureType(
134
+ 12
135
+ /* String */
136
+ ), this.payload;
137
+ }
138
+ asString() {
139
+ return this.ensureType(
140
+ 12
141
+ /* String */
142
+ ), qt.decode(this.payload);
143
+ }
144
+ asGuid() {
145
+ return this.ensureType(
146
+ 14
147
+ /* Guid */
148
+ ), h.fromBytes(this.payload);
149
+ }
150
+ asObject() {
151
+ return this.ensureType(
152
+ 11
153
+ /* Object */
154
+ ), D.create(this.payload);
155
+ }
156
+ asArray() {
157
+ return this.ensureType(
158
+ 9
159
+ /* Array */
160
+ ), Q.create(this.payload);
161
+ }
162
+ asDictionary() {
163
+ return this.ensureType(
164
+ 10
165
+ /* Dict */
166
+ ), Z.create(this.payload);
167
+ }
168
+ ensureType(e) {
169
+ if (this.type !== e)
170
+ throw new Error(`Teleport value has type ${g[this.type]}, expected ${g[e]}`);
171
+ }
172
+ }
173
+ class Qt extends w {
174
+ constructor(e, s, r) {
175
+ super(s, r), this.fieldId = e;
176
+ }
177
+ get isNull() {
178
+ return this.type === 1;
179
+ }
180
+ }
181
+ class Q {
182
+ payload;
183
+ elementType;
184
+ count;
185
+ offset;
186
+ index = 0;
187
+ constructor(e) {
188
+ if (this.payload = e, e.length === 0)
189
+ throw new Error("Array payload too short");
190
+ const s = e[0];
191
+ if (this.elementType = s >> 4 & 15, (s & 15) !== 0)
192
+ throw new Error("Array flags must be zero");
193
+ const r = { offset: 1 };
194
+ this.count = d(e, r, "ArrayMalformed"), this.offset = r.offset;
195
+ }
196
+ static create(e) {
197
+ return new Q(H(e));
198
+ }
199
+ next() {
200
+ if (this.index >= this.count) {
201
+ if (this.offset !== this.payload.length)
202
+ throw new Error("Array payload contains trailing data");
203
+ return null;
204
+ }
205
+ const e = this.readValue();
206
+ return this.index++, e;
207
+ }
208
+ readValue() {
209
+ switch (this.elementType) {
210
+ case 3:
211
+ case 5:
212
+ case 7:
213
+ case 8:
214
+ case 2:
215
+ case 4:
216
+ case 6:
217
+ case 14: {
218
+ const e = P(this.elementType);
219
+ A(this.payload, this.offset, e);
220
+ const s = this.payload.subarray(this.offset, this.offset + e);
221
+ return this.offset += e, new p(this.elementType, s);
222
+ }
223
+ case 12:
224
+ case 13: {
225
+ const e = { offset: this.offset }, s = d(this.payload, e, "ArrayMalformed");
226
+ A(this.payload, e.offset, s);
227
+ const r = this.payload.subarray(e.offset, e.offset + s);
228
+ return this.offset = e.offset + s, new p(this.elementType, r);
229
+ }
230
+ case 11: {
231
+ const e = { offset: this.offset }, s = d(this.payload, e, "ArrayMalformed");
232
+ A(this.payload, e.offset, s);
233
+ const r = this.payload.subarray(e.offset, e.offset + s);
234
+ return this.offset = e.offset + s, new p(11, r);
235
+ }
236
+ case 9: {
237
+ const e = tt(this.payload, this.offset), s = this.payload.subarray(this.offset, this.offset + e);
238
+ return this.offset += e, new p(9, s);
239
+ }
240
+ case 10: {
241
+ const e = et(this.payload, this.offset), s = this.payload.subarray(this.offset, this.offset + e);
242
+ return this.offset += e, new p(10, s);
243
+ }
244
+ default:
245
+ throw new Error(`Unsupported array element type ${g[this.elementType]}`);
246
+ }
247
+ }
248
+ }
249
+ class p extends w {
250
+ constructor(e, s) {
251
+ super(e, s);
252
+ }
253
+ }
254
+ class Z {
255
+ payload;
256
+ keyType;
257
+ valueType;
258
+ count;
259
+ offset;
260
+ index = 0;
261
+ constructor(e) {
262
+ if (this.payload = e, e.length < 2)
263
+ throw new Error("Dictionary payload too short");
264
+ if (this.keyType = e[0] >> 4 & 15, this.valueType = e[1] >> 4 & 15, (e[0] & 15) !== 0 || (e[1] & 15) !== 0)
265
+ throw new Error("Dictionary key/value flags must be zero");
266
+ lt(this.keyType);
267
+ const s = { offset: 2 };
268
+ this.count = d(e, s, "DictMalformed"), this.offset = s.offset;
269
+ }
270
+ static create(e) {
271
+ return new Z(H(e));
272
+ }
273
+ next() {
274
+ if (this.index >= this.count) {
275
+ if (this.offset !== this.payload.length)
276
+ throw new Error("Dictionary payload contains trailing data");
277
+ return null;
278
+ }
279
+ const e = this.readKey(), s = this.readValue();
280
+ return this.index++, new Zt(e, s);
281
+ }
282
+ readKey() {
283
+ const e = P(this.keyType);
284
+ if (e >= 0) {
285
+ A(this.payload, this.offset, e);
286
+ const s = this.payload.subarray(this.offset, this.offset + e);
287
+ return this.offset += e, new w(this.keyType, s);
288
+ }
289
+ if (this.keyType === 12 || this.keyType === 13) {
290
+ const s = { offset: this.offset }, r = d(this.payload, s, "DictMalformed");
291
+ A(this.payload, s.offset, r);
292
+ const n = this.payload.subarray(s.offset, s.offset + r);
293
+ return this.offset = s.offset + r, new w(this.keyType, n);
294
+ }
295
+ throw new Error("Unsupported dictionary key type");
296
+ }
297
+ readValue() {
298
+ switch (this.valueType) {
299
+ case 12:
300
+ case 13: {
301
+ const e = { offset: this.offset }, s = d(this.payload, e, "DictMalformed");
302
+ A(this.payload, e.offset, s);
303
+ const r = this.payload.subarray(e.offset, e.offset + s);
304
+ return this.offset = e.offset + s, new w(this.valueType, r);
305
+ }
306
+ case 11: {
307
+ const e = { offset: this.offset }, s = d(this.payload, e, "DictMalformed");
308
+ A(this.payload, e.offset, s);
309
+ const r = this.payload.subarray(e.offset, e.offset + s);
310
+ return this.offset = e.offset + s, new w(11, r);
311
+ }
312
+ case 9: {
313
+ const e = tt(this.payload, this.offset), s = this.payload.subarray(this.offset, this.offset + e);
314
+ return this.offset += e, new w(9, s);
315
+ }
316
+ case 10: {
317
+ const e = et(this.payload, this.offset), s = this.payload.subarray(this.offset, this.offset + e);
318
+ return this.offset += e, new w(10, s);
319
+ }
320
+ case 3:
321
+ case 5:
322
+ case 7:
323
+ case 8:
324
+ case 2:
325
+ case 4:
326
+ case 6:
327
+ case 14:
328
+ case 1: {
329
+ const e = P(this.valueType);
330
+ A(this.payload, this.offset, e);
331
+ const s = this.payload.subarray(this.offset, this.offset + e);
332
+ return this.offset += e, new w(this.valueType, s);
333
+ }
334
+ default:
335
+ throw new Error(`Unsupported dictionary value type ${g[this.valueType]}`);
336
+ }
337
+ }
338
+ }
339
+ class Zt {
340
+ constructor(e, s) {
341
+ this.key = e, this.value = s;
342
+ }
343
+ }
344
+ class h {
345
+ constructor(e) {
346
+ this.bytes = e;
347
+ }
348
+ static fromString(e) {
349
+ if (!e)
350
+ throw new Error("Guid string is empty");
351
+ const s = e.replace(/-/g, "");
352
+ if (s.length !== 32)
353
+ throw new Error("Guid string must be 32 hex characters");
354
+ const r = new Uint8Array(16), n = h.parseHexSlice(s, 0, 8), i = h.parseHexSlice(s, 8, 4), o = h.parseHexSlice(s, 12, 4);
355
+ h.writeUInt32LE(r, 0, n), h.writeUInt16LE(r, 4, i), h.writeUInt16LE(r, 6, o);
356
+ for (let a = 0; a < 8; a++)
357
+ r[8 + a] = h.parseHexSlice(s, 16 + a * 2, 2);
358
+ return new h(r);
359
+ }
360
+ static fromBytes(e) {
361
+ if (e.length !== 16)
362
+ throw new Error("Guid byte array must be 16 bytes");
363
+ return new h(Uint8Array.from(e));
364
+ }
365
+ static createZero() {
366
+ return new h(new Uint8Array(16));
367
+ }
368
+ static createRandom() {
369
+ const e = new Uint8Array(16), s = globalThis.crypto;
370
+ if (s?.getRandomValues)
371
+ s.getRandomValues(e);
372
+ else
373
+ for (let r = 0; r < e.length; r++)
374
+ e[r] = Math.floor(Math.random() * 256);
375
+ return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new h(e);
376
+ }
377
+ toString() {
378
+ const e = this.bytes;
379
+ return [
380
+ h.toHex(h.readUInt32LE(e, 0), 8),
381
+ h.toHex(h.readUInt16LE(e, 4), 4),
382
+ h.toHex(h.readUInt16LE(e, 6), 4),
383
+ it(e.subarray(8, 10)),
384
+ it(e.subarray(10, 16))
385
+ ].join("-");
386
+ }
387
+ asBytes() {
388
+ return this.bytes.slice();
389
+ }
390
+ static parseHexSlice(e, s, r) {
391
+ const n = e.substr(s, r), i = Number.parseInt(n, 16);
392
+ if (Number.isNaN(i))
393
+ throw new Error("Guid string contains invalid characters");
394
+ return i >>> 0;
395
+ }
396
+ static writeUInt32LE(e, s, r) {
397
+ const n = r >>> 0;
398
+ e[s] = n & 255, e[s + 1] = n >>> 8 & 255, e[s + 2] = n >>> 16 & 255, e[s + 3] = n >>> 24 & 255;
399
+ }
400
+ static writeUInt16LE(e, s, r) {
401
+ const n = r & 65535;
402
+ e[s] = n & 255, e[s + 1] = n >>> 8 & 255;
403
+ }
404
+ static readUInt32LE(e, s) {
405
+ return (e[s] | e[s + 1] << 8 | e[s + 2] << 16 | e[s + 3] << 24) >>> 0;
406
+ }
407
+ static readUInt16LE(e, s) {
408
+ return (e[s] | e[s + 1] << 8) & 65535;
409
+ }
410
+ static toHex(e, s) {
411
+ return (e >>> 0).toString(16).padStart(s, "0");
412
+ }
413
+ }
414
+ function d(t, e, s) {
415
+ if (e.offset >= t.length)
416
+ throw new Error(s);
417
+ let r = 0, n = 0, i = 0;
418
+ for (; e.offset < t.length; ) {
419
+ const o = t[e.offset++];
420
+ if (i++, r |= (o & 127) << n, (o & 128) === 0) {
421
+ if (i !== te(r))
422
+ throw new Error("Teleport VarUInt is not canonical");
423
+ return r >>> 0;
424
+ }
425
+ if (n += 7, n >= 35)
426
+ throw new Error("Teleport VarUInt exceeds 32-bit range");
427
+ }
428
+ throw new Error(s);
429
+ }
430
+ function te(t) {
431
+ return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
432
+ }
433
+ function P(t) {
434
+ switch (t) {
435
+ case 3:
436
+ case 5:
437
+ case 7:
438
+ return 4;
439
+ case 4:
440
+ case 6:
441
+ case 8:
442
+ return 8;
443
+ case 14:
444
+ return 16;
445
+ case 2:
446
+ return 1;
447
+ case 1:
448
+ return 0;
449
+ default:
450
+ return -1;
451
+ }
452
+ }
453
+ function lt(t) {
454
+ if (t === 9 || t === 11 || t === 10 || t === 1)
455
+ throw new Error("Dictionary keys must be primitive Teleport types");
456
+ }
457
+ function A(t, e, s) {
458
+ if (e < 0 || s < 0 || e + s > t.length)
459
+ throw new Error("Teleport payload exceeds bounds");
460
+ }
461
+ function ee(t, e) {
462
+ return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0;
463
+ }
464
+ function tt(t, e) {
465
+ if (e >= t.length)
466
+ throw new Error("Array payload exceeds bounds");
467
+ const s = t[e], r = s >> 4 & 15;
468
+ if ((s & 15) !== 0)
469
+ throw new Error("Array flags must be zero");
470
+ const n = { offset: e + 1 }, i = d(t, n, "ArrayMalformed"), o = P(r);
471
+ if (o >= 0) {
472
+ const I = o * i;
473
+ return A(t, n.offset, I), n.offset + I - e;
474
+ }
475
+ let a = n.offset;
476
+ for (let I = 0; I < i; I++)
477
+ a = X(r, t, a, "ArrayMalformed");
478
+ return a - e;
479
+ }
480
+ function et(t, e) {
481
+ if (e + 2 > t.length)
482
+ throw new Error("Dictionary payload too short");
483
+ const s = t[e] >> 4 & 15, r = t[e + 1] >> 4 & 15;
484
+ if ((t[e] & 15) !== 0 || (t[e + 1] & 15) !== 0)
485
+ throw new Error("Dictionary key/value flags must be zero");
486
+ lt(s);
487
+ const n = { offset: e + 2 }, i = d(t, n, "DictMalformed");
488
+ let o = n.offset;
489
+ for (let a = 0; a < i; a++)
490
+ o = X(s, t, o, "DictMalformed"), o = X(r, t, o, "DictMalformed");
491
+ return o - e;
492
+ }
493
+ function X(t, e, s, r) {
494
+ const n = P(t);
495
+ if (n >= 0)
496
+ return A(e, s, n), s + n;
497
+ switch (t) {
498
+ case 12:
499
+ case 13: {
500
+ const i = { offset: s }, o = d(e, i, r);
501
+ return A(e, i.offset, o), i.offset + o;
502
+ }
503
+ case 11: {
504
+ const i = { offset: s }, o = d(e, i, r);
505
+ return A(e, i.offset, o), i.offset + o;
506
+ }
507
+ case 9:
508
+ return s + tt(e, s);
509
+ case 10:
510
+ return s + et(e, s);
511
+ default:
512
+ throw new Error(`Unsupported Teleport type ${g[t]}`);
513
+ }
514
+ }
515
+ function it(t) {
516
+ return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
517
+ }
518
+ function H(t) {
519
+ return t instanceof Uint8Array ? t : new Uint8Array(t);
520
+ }
521
+ var It = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Opus = 1] = "Opus", t[t.Mp3 = 2] = "Mp3", t[t.RawPcm16 = 3] = "RawPcm16", t))(It || {}), 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 || {}), Et = /* @__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))(Et || {}), _t = /* @__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))(_t || {}), ft = /* @__PURE__ */ ((t) => (t[t.Face = 0] = "Face", t[t.Hands = 1] = "Hands", t[t.Pose = 2] = "Pose", t[t.All = 3] = "All", t))(ft || {}), ut = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.Machine = 1] = "Machine", t[t.Human = 2] = "Human", t))(ut || {}), ht = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.H264 = 1] = "H264", t[t.Hevc = 2] = "Hevc", t[t.Vp8 = 3] = "Vp8", t))(ht || {}), Tt = /* @__PURE__ */ ((t) => (t[t.Unknown = 0] = "Unknown", t[t.DotNet = 1] = "DotNet", t[t.TypeScript = 2] = "TypeScript", t[t.Cpp = 3] = "Cpp", t))(Tt || {}), m = /* @__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.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.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.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))(m || {});
522
+ const se = 1368629611, re = 2431514951, ne = 2914494629, ie = 3284746250, oe = 4101844078;
523
+ function Nt(t) {
524
+ const e = {};
525
+ return At(e), e;
526
+ }
527
+ function At(t) {
528
+ return t.Description = "", t.Codec = It.Unknown, t.SampleRate = 0, t.Channels = 0, t.BitDepth = 0, t;
529
+ }
530
+ function ae(t, e) {
531
+ const s = e ?? Nt();
532
+ return At(s), le(t, s), s;
533
+ }
534
+ function le(t, e) {
535
+ let s;
536
+ for (; (s = t.next()) !== null; )
537
+ switch (s.fieldId) {
538
+ case se: {
539
+ if (s.isNull) throw new Error();
540
+ e.Description = s.asString();
541
+ break;
542
+ }
543
+ case re: {
544
+ if (s.isNull) throw new Error();
545
+ e.Channels = s.asInt32();
546
+ break;
547
+ }
548
+ case ne: {
549
+ if (s.isNull) throw new Error();
550
+ e.BitDepth = s.asInt32();
551
+ break;
552
+ }
553
+ case ie: {
554
+ if (s.isNull) throw new Error();
555
+ e.Codec = s.asInt32();
556
+ break;
557
+ }
558
+ case oe: {
559
+ if (s.isNull) throw new Error();
560
+ e.SampleRate = s.asInt32();
561
+ break;
562
+ }
563
+ }
564
+ }
565
+ const Ie = 76337612, ce = 185396121, Ee = 388632637, _e = 417197284, fe = 469070965, ue = 470595159, he = 781727218, Te = 834078886, Ne = 1043273762, Ae = 1236999138, Se = 1368629611, de = 1715899485, ye = 1942830531, Ce = 1999510636, we = 2079864626, Ue = 2142346422, Re = 2598291686, De = 2719718823, Le = 2810953526, me = 2840065720, Oe = 2885165957, ge = 3586157513, Pe = 3717933110, be = 4062655306;
566
+ function Fe(t) {
567
+ const e = {};
568
+ return St(e), e;
569
+ }
570
+ function St(t) {
571
+ return t.ContextType = Et.Unknown, t.UserType = ut.Unknown, t.PayloadType = _t.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 = Tt.Unknown, t;
572
+ }
573
+ function pe(t, e) {
574
+ const s = e ?? Fe();
575
+ return St(s), Me(t, s), s;
576
+ }
577
+ function Me(t, e) {
578
+ let s;
579
+ for (; (s = t.next()) !== null; )
580
+ switch (s.fieldId) {
581
+ case Ie: {
582
+ if (s.isNull) throw new Error();
583
+ e.DeviceId = s.asString();
584
+ break;
585
+ }
586
+ case ce: {
587
+ if (s.isNull) throw new Error();
588
+ e.InstallId = s.asString();
589
+ break;
590
+ }
591
+ case Ee: {
592
+ if (s.isNull) throw new Error();
593
+ e.UserAgent = s.asString();
594
+ break;
595
+ }
596
+ case _e: {
597
+ if (s.isNull) throw new Error();
598
+ e.ContextType = s.asInt32();
599
+ break;
600
+ }
601
+ case fe: {
602
+ if (s.isNull) throw new Error();
603
+ e.HasInput = s.asBool();
604
+ break;
605
+ }
606
+ case ue: {
607
+ if (s.isNull) throw new Error();
608
+ e.UserType = s.asInt32();
609
+ break;
610
+ }
611
+ case he: {
612
+ if (s.isNull) throw new Error();
613
+ e.UserId = s.asString();
614
+ break;
615
+ }
616
+ case Te: {
617
+ if (s.isNull) throw new Error();
618
+ e.ProductId = s.asString();
619
+ break;
620
+ }
621
+ case Ne: {
622
+ if (s.isNull) throw new Error();
623
+ e.AuthSessionId = s.asString();
624
+ break;
625
+ }
626
+ case Ae: {
627
+ if (s.isNull) throw new Error();
628
+ e.ReceiveAllMessages = s.asBool();
629
+ break;
630
+ }
631
+ case Se: {
632
+ if (s.isNull) throw new Error();
633
+ e.Description = s.asString();
634
+ break;
635
+ }
636
+ case de: {
637
+ if (s.isNull) throw new Error();
638
+ e.Locale = s.asString();
639
+ break;
640
+ }
641
+ case ye: {
642
+ if (s.isNull) throw new Error();
643
+ e.SdkType = s.asInt32();
644
+ break;
645
+ }
646
+ case Ce: {
647
+ if (s.isNull) throw new Error();
648
+ e.SessionId = s.asInt32();
649
+ break;
650
+ }
651
+ case we: {
652
+ if (s.isNull) throw new Error();
653
+ e.PreciseJoinedAt = s.asUInt64();
654
+ break;
655
+ }
656
+ case Ue: {
657
+ if (s.isNull) throw new Error();
658
+ e.PayloadType = s.asInt32();
659
+ break;
660
+ }
661
+ case Re: {
662
+ if (s.isNull) throw new Error();
663
+ e.VersionId = s.asString();
664
+ break;
665
+ }
666
+ case De: {
667
+ if (s.isNull) throw new Error();
668
+ e.UniqueSessionId = s.asString();
669
+ break;
670
+ }
671
+ case Le: {
672
+ if (s.isNull) throw new Error();
673
+ e.ClientType = s.asInt32();
674
+ break;
675
+ }
676
+ case me: {
677
+ if (s.isNull) throw new Error();
678
+ e.IsReady = s.asBool();
679
+ break;
680
+ }
681
+ case Oe: {
682
+ if (s.isNull) throw new Error();
683
+ e.Parameters = ve(s.asDictionary());
684
+ break;
685
+ }
686
+ case ge: {
687
+ if (s.isNull) throw new Error();
688
+ e.IsInternal = s.asBool();
689
+ break;
690
+ }
691
+ case Pe: {
692
+ if (s.isNull) throw new Error();
693
+ e.ChannelLocale = s.asString();
694
+ break;
695
+ }
696
+ case be: {
697
+ if (s.isNull) throw new Error();
698
+ e.EmbeddedSpaceId = s.asString();
699
+ break;
700
+ }
701
+ }
702
+ }
703
+ function ve(t) {
704
+ const e = /* @__PURE__ */ Object.create(null);
705
+ let s;
706
+ for (; (s = t.next()) !== null; ) {
707
+ const r = s.key.asString();
708
+ e[r] = s.value.asString();
709
+ }
710
+ return e;
711
+ }
712
+ const Ve = 703025676, ke = 814454131, Ge = 972460562, Be = 976255570, xe = 1368629611, He = 1479280922, Ye = 1533537016, je = 2274386296, $e = 2603556958, Ke = 2885165957, Xe = 3568439632;
713
+ function ze(t) {
714
+ const e = {};
715
+ return dt(e), e;
716
+ }
717
+ function dt(t) {
718
+ return t.FunctionId = h.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;
719
+ }
720
+ function We(t, e) {
721
+ const s = e ?? ze();
722
+ return dt(s), Je(t, s), s;
723
+ }
724
+ function Je(t, e) {
725
+ let s;
726
+ for (; (s = t.next()) !== null; )
727
+ switch (s.fieldId) {
728
+ case Ve: {
729
+ if (s.isNull) throw new Error();
730
+ e.ResultTypeName = s.asString();
731
+ break;
732
+ }
733
+ case ke: {
734
+ if (s.isNull) throw new Error();
735
+ e.FunctionName = s.asString();
736
+ break;
737
+ }
738
+ case Ge: {
739
+ if (s.isNull) throw new Error();
740
+ e.EnumerableItemTypeName = s.asString();
741
+ break;
742
+ }
743
+ case Be: {
744
+ if (s.isNull) throw new Error();
745
+ e.FunctionId = s.asGuid();
746
+ break;
747
+ }
748
+ case xe: {
749
+ if (s.isNull) throw new Error();
750
+ e.Description = s.asString();
751
+ break;
752
+ }
753
+ case He: {
754
+ if (s.isNull) throw new Error();
755
+ e.IsCancellable = s.asBool();
756
+ break;
757
+ }
758
+ case Ye: {
759
+ if (s.isNull) throw new Error();
760
+ e.RequiresInstance = s.asBool();
761
+ break;
762
+ }
763
+ case je: {
764
+ if (s.isNull) throw new Error();
765
+ e.LlmInlineResult = s.asBool();
766
+ break;
767
+ }
768
+ case $e: {
769
+ if (s.isNull) throw new Error();
770
+ e.IsEnumerable = s.asBool();
771
+ break;
772
+ }
773
+ case Ke: {
774
+ if (s.isNull) throw new Error();
775
+ e.Parameters = qe(s.asArray());
776
+ break;
777
+ }
778
+ case Xe: {
779
+ if (s.isNull) throw new Error();
780
+ e.LlmCallOnlyOnce = s.asBool();
781
+ break;
782
+ }
783
+ }
784
+ }
785
+ function qe(t) {
786
+ const e = [];
787
+ let s;
788
+ for (; (s = t.next()) !== null; )
789
+ e.push(ls(s.asObject()));
790
+ return e;
791
+ }
792
+ const Qe = 607861992, Ze = 894485888, ts = 972460562, es = 1368629611, ss = 1883521406, rs = 2603556958, ns = 3609695522, is = 4075263697, os = 4257460908;
793
+ function as(t) {
794
+ const e = {};
795
+ return yt(e), e;
796
+ }
797
+ function yt(t) {
798
+ 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;
799
+ }
800
+ function ls(t, e) {
801
+ const s = e ?? as();
802
+ return yt(s), Is(t, s), s;
803
+ }
804
+ function Is(t, e) {
805
+ let s;
806
+ for (; (s = t.next()) !== null; )
807
+ switch (s.fieldId) {
808
+ case Qe: {
809
+ if (s.isNull) throw new Error();
810
+ e.HasDefaultValue = s.asBool();
811
+ break;
812
+ }
813
+ case Ze: {
814
+ if (s.isNull) throw new Error();
815
+ e.DefaultValueJson = s.asString();
816
+ break;
817
+ }
818
+ case ts: {
819
+ if (s.isNull) throw new Error();
820
+ e.EnumerableItemTypeName = s.asString();
821
+ break;
822
+ }
823
+ case es: {
824
+ if (s.isNull) throw new Error();
825
+ e.Description = s.asString();
826
+ break;
827
+ }
828
+ case ss: {
829
+ if (s.isNull) throw new Error();
830
+ e.DefaultValueData = s.asBinary();
831
+ break;
832
+ }
833
+ case rs: {
834
+ if (s.isNull) throw new Error();
835
+ e.IsEnumerable = s.asBool();
836
+ break;
837
+ }
838
+ case ns: {
839
+ if (s.isNull) throw new Error();
840
+ e.TypeName = s.asString();
841
+ break;
842
+ }
843
+ case is: {
844
+ if (s.isNull) throw new Error();
845
+ e.ParameterName = s.asString();
846
+ break;
847
+ }
848
+ case os: {
849
+ if (s.isNull) throw new Error();
850
+ e.ParameterIndex = s.asInt32();
851
+ break;
852
+ }
853
+ }
854
+ }
855
+ const cs = 3167053791, Es = 3342364356, _s = 3612929027;
856
+ function Ct(t) {
857
+ const e = {};
858
+ return wt(e), e;
859
+ }
860
+ function wt(t) {
861
+ return t.Category = "", t.Type = ft.Face, t.FaceBlendshapes = [], t;
862
+ }
863
+ function fs(t, e) {
864
+ const s = e ?? Ct();
865
+ return wt(s), us(t, s), s;
866
+ }
867
+ function us(t, e) {
868
+ let s;
869
+ for (; (s = t.next()) !== null; )
870
+ switch (s.fieldId) {
871
+ case cs: {
872
+ if (s.isNull) throw new Error();
873
+ e.Type = s.asInt32();
874
+ break;
875
+ }
876
+ case Es: {
877
+ if (s.isNull) throw new Error();
878
+ e.FaceBlendshapes = hs(s.asArray());
879
+ break;
880
+ }
881
+ case _s: {
882
+ if (s.isNull) throw new Error();
883
+ e.Category = s.asString();
884
+ break;
885
+ }
886
+ }
887
+ }
888
+ function hs(t) {
889
+ const e = [];
890
+ let s;
891
+ for (; (s = t.next()) !== null; )
892
+ e.push(s.asString());
893
+ return e;
894
+ }
895
+ const Ts = 3612929027;
896
+ function Ut(t) {
897
+ const e = {};
898
+ return Rt(e), e;
899
+ }
900
+ function Rt(t) {
901
+ return t.Category = "", t;
902
+ }
903
+ function Ns(t, e) {
904
+ const s = e ?? Ut();
905
+ return Rt(s), As(t, s), s;
906
+ }
907
+ function As(t, e) {
908
+ let s;
909
+ for (; (s = t.next()) !== null; )
910
+ switch (s.fieldId) {
911
+ case Ts: {
912
+ if (s.isNull) throw new Error();
913
+ e.Category = s.asString();
914
+ break;
915
+ }
916
+ }
917
+ }
918
+ const Ss = 1368629611, ds = 2950031986, ys = 3284746250, Cs = 4065070594;
919
+ function Dt(t) {
920
+ const e = {};
921
+ return Lt(e), e;
922
+ }
923
+ function Lt(t) {
924
+ return t.Description = "", t.Codec = ht.H264, t.Width = 0, t.Height = 0, t;
925
+ }
926
+ function ws(t, e) {
927
+ const s = e ?? Dt();
928
+ return Lt(s), Us(t, s), s;
929
+ }
930
+ function Us(t, e) {
931
+ let s;
932
+ for (; (s = t.next()) !== null; )
933
+ switch (s.fieldId) {
934
+ case Ss: {
935
+ if (s.isNull) throw new Error();
936
+ e.Description = s.asString();
937
+ break;
938
+ }
939
+ case ds: {
940
+ if (s.isNull) throw new Error();
941
+ e.Height = s.asInt32();
942
+ break;
943
+ }
944
+ case ys: {
945
+ if (s.isNull) throw new Error();
946
+ e.Codec = s.asInt32();
947
+ break;
948
+ }
949
+ case Cs: {
950
+ if (s.isNull) throw new Error();
951
+ e.Width = s.asInt32();
952
+ break;
953
+ }
954
+ }
955
+ }
956
+ const Rs = 3, Ds = 65539, Ls = 693643444, ms = 1144553441, Os = 1497620243, gs = 1559330978, Ps = 1999510636, bs = 2277643855, Fs = 2469008121, ps = 3219210453, Ms = 3678477544, vs = 3696445035, Vs = 3707543140, ks = 3712281496, Gs = 3823842552, Bs = 3895362455, xs = 3897397815, Hs = 4225107827;
957
+ function Ys(t) {
958
+ const e = {};
959
+ return mt(e), e;
960
+ }
961
+ function mt(t) {
962
+ return t.Clients = /* @__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.ChannelInstanceId = "", t.FirstUserId = "", t.ChannelUrl = "", t.ChannelId = "", t.PrimaryUserId = "", t.OrganisationName = "", t.SpaceName = "", t.ChannelName = "", t.SessionId = "", t.Functions = /* @__PURE__ */ Object.create(null), t;
963
+ }
964
+ function js(t, e) {
965
+ const s = D.create(t);
966
+ return $s(s, e);
967
+ }
968
+ function $s(t, e) {
969
+ const s = e ?? Ys();
970
+ return mt(s), Ks(t, s), s;
971
+ }
972
+ function Ks(t, e) {
973
+ let s;
974
+ for (; (s = t.next()) !== null; )
975
+ switch (s.fieldId) {
976
+ case Ls: {
977
+ if (s.isNull) throw new Error();
978
+ e.FirstUserId = s.asString();
979
+ break;
980
+ }
981
+ case ms: {
982
+ if (s.isNull) throw new Error();
983
+ e.Clients = zs(s.asDictionary());
984
+ break;
985
+ }
986
+ case Os: {
987
+ if (s.isNull) throw new Error();
988
+ e.TrackingStreams = Ws(s.asDictionary());
989
+ break;
990
+ }
991
+ case gs: {
992
+ if (s.isNull) throw new Error();
993
+ e.ChannelId = s.asString();
994
+ break;
995
+ }
996
+ case Ps: {
997
+ if (s.isNull) throw new Error();
998
+ e.SessionId = s.asString();
999
+ break;
1000
+ }
1001
+ case bs: {
1002
+ if (s.isNull) throw new Error();
1003
+ e.ChannelUrl = s.asString();
1004
+ break;
1005
+ }
1006
+ case Fs: {
1007
+ if (s.isNull) throw new Error();
1008
+ e.ChannelName = s.asString();
1009
+ break;
1010
+ }
1011
+ case ps: {
1012
+ if (s.isNull) throw new Error();
1013
+ e.OrganisationName = s.asString();
1014
+ break;
1015
+ }
1016
+ case Ms: {
1017
+ if (s.isNull) throw new Error();
1018
+ e.Functions = Js(s.asDictionary());
1019
+ break;
1020
+ }
1021
+ case vs: {
1022
+ if (s.isNull) throw new Error();
1023
+ e.UIStreams = qs(s.asDictionary());
1024
+ break;
1025
+ }
1026
+ case Vs: {
1027
+ if (s.isNull) throw new Error();
1028
+ e.SpaceId = s.asString();
1029
+ break;
1030
+ }
1031
+ case ks: {
1032
+ if (s.isNull) throw new Error();
1033
+ e.PrimaryUserId = s.asString();
1034
+ break;
1035
+ }
1036
+ case Gs: {
1037
+ if (s.isNull) throw new Error();
1038
+ e.ChannelInstanceId = s.asString();
1039
+ break;
1040
+ }
1041
+ case Bs: {
1042
+ if (s.isNull) throw new Error();
1043
+ e.AudioStreams = Qs(s.asDictionary());
1044
+ break;
1045
+ }
1046
+ case xs: {
1047
+ if (s.isNull) throw new Error();
1048
+ e.VideoStreams = Zs(s.asDictionary());
1049
+ break;
1050
+ }
1051
+ case Hs: {
1052
+ if (s.isNull) throw new Error();
1053
+ e.SpaceName = s.asString();
1054
+ break;
1055
+ }
1056
+ }
1057
+ }
1058
+ function Xs(t, e) {
1059
+ const s = K(t, Ds, Rs);
1060
+ return js(s, e);
1061
+ }
1062
+ function zs(t) {
1063
+ const e = /* @__PURE__ */ Object.create(null);
1064
+ let s;
1065
+ for (; (s = t.next()) !== null; ) {
1066
+ const r = s.key.asInt32();
1067
+ e[r] = pe(s.value.asObject());
1068
+ }
1069
+ return e;
1070
+ }
1071
+ function Ws(t) {
1072
+ const e = /* @__PURE__ */ Object.create(null);
1073
+ let s;
1074
+ for (; (s = t.next()) !== null; ) {
1075
+ const r = s.key.asString();
1076
+ e[r] = Lr(s.value.asObject());
1077
+ }
1078
+ return e;
1079
+ }
1080
+ function Js(t) {
1081
+ const e = /* @__PURE__ */ Object.create(null);
1082
+ let s;
1083
+ for (; (s = t.next()) !== null; ) {
1084
+ const r = s.key.asInt32();
1085
+ e[r] = tr(s.value.asArray());
1086
+ }
1087
+ return e;
1088
+ }
1089
+ function qs(t) {
1090
+ const e = /* @__PURE__ */ Object.create(null);
1091
+ let s;
1092
+ for (; (s = t.next()) !== null; ) {
1093
+ const r = s.key.asString();
1094
+ e[r] = or(s.value.asObject());
1095
+ }
1096
+ return e;
1097
+ }
1098
+ function Qs(t) {
1099
+ const e = /* @__PURE__ */ Object.create(null);
1100
+ let s;
1101
+ for (; (s = t.next()) !== null; ) {
1102
+ const r = s.key.asString();
1103
+ e[r] = fr(s.value.asObject());
1104
+ }
1105
+ return e;
1106
+ }
1107
+ function Zs(t) {
1108
+ const e = /* @__PURE__ */ Object.create(null);
1109
+ let s;
1110
+ for (; (s = t.next()) !== null; ) {
1111
+ const r = s.key.asString();
1112
+ e[r] = dr(s.value.asObject());
1113
+ }
1114
+ return e;
1115
+ }
1116
+ function tr(t) {
1117
+ const e = [];
1118
+ let s;
1119
+ for (; (s = t.next()) !== null; )
1120
+ e.push(We(s.asObject()));
1121
+ return e;
1122
+ }
1123
+ const er = 161083277, sr = 325678206, rr = 3469892363, nr = 3645544153;
1124
+ function ir(t) {
1125
+ const e = {};
1126
+ return Ot(e), e;
1127
+ }
1128
+ function Ot(t) {
1129
+ return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Ut(), t;
1130
+ }
1131
+ function or(t, e) {
1132
+ const s = e ?? ir();
1133
+ return Ot(s), ar(t, s), s;
1134
+ }
1135
+ function ar(t, e) {
1136
+ let s;
1137
+ for (; (s = t.next()) !== null; )
1138
+ switch (s.fieldId) {
1139
+ case er: {
1140
+ if (s.isNull) throw new Error();
1141
+ e.StreamId = s.asString();
1142
+ break;
1143
+ }
1144
+ case sr: {
1145
+ if (s.isNull) throw new Error();
1146
+ e.ClientSessionId = s.asInt32();
1147
+ break;
1148
+ }
1149
+ case rr: {
1150
+ if (s.isNull) throw new Error();
1151
+ e.TrackId = s.asInt32();
1152
+ break;
1153
+ }
1154
+ case nr: {
1155
+ if (s.isNull) throw new Error();
1156
+ e.Info = Ns(s.asObject());
1157
+ break;
1158
+ }
1159
+ }
1160
+ }
1161
+ const lr = 161083277, Ir = 325678206, cr = 3469892363, Er = 3645544153;
1162
+ function _r(t) {
1163
+ const e = {};
1164
+ return gt(e), e;
1165
+ }
1166
+ function gt(t) {
1167
+ return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Nt(), t;
1168
+ }
1169
+ function fr(t, e) {
1170
+ const s = e ?? _r();
1171
+ return gt(s), ur(t, s), s;
1172
+ }
1173
+ function ur(t, e) {
1174
+ let s;
1175
+ for (; (s = t.next()) !== null; )
1176
+ switch (s.fieldId) {
1177
+ case lr: {
1178
+ if (s.isNull) throw new Error();
1179
+ e.StreamId = s.asString();
1180
+ break;
1181
+ }
1182
+ case Ir: {
1183
+ if (s.isNull) throw new Error();
1184
+ e.ClientSessionId = s.asInt32();
1185
+ break;
1186
+ }
1187
+ case cr: {
1188
+ if (s.isNull) throw new Error();
1189
+ e.TrackId = s.asInt32();
1190
+ break;
1191
+ }
1192
+ case Er: {
1193
+ if (s.isNull) throw new Error();
1194
+ e.Info = ae(s.asObject());
1195
+ break;
1196
+ }
1197
+ }
1198
+ }
1199
+ const hr = 161083277, Tr = 325678206, Nr = 3469892363, Ar = 3645544153;
1200
+ function Sr(t) {
1201
+ const e = {};
1202
+ return Pt(e), e;
1203
+ }
1204
+ function Pt(t) {
1205
+ return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Dt(), t;
1206
+ }
1207
+ function dr(t, e) {
1208
+ const s = e ?? Sr();
1209
+ return Pt(s), yr(t, s), s;
1210
+ }
1211
+ function yr(t, e) {
1212
+ let s;
1213
+ for (; (s = t.next()) !== null; )
1214
+ switch (s.fieldId) {
1215
+ case hr: {
1216
+ if (s.isNull) throw new Error();
1217
+ e.StreamId = s.asString();
1218
+ break;
1219
+ }
1220
+ case Tr: {
1221
+ if (s.isNull) throw new Error();
1222
+ e.ClientSessionId = s.asInt32();
1223
+ break;
1224
+ }
1225
+ case Nr: {
1226
+ if (s.isNull) throw new Error();
1227
+ e.TrackId = s.asInt32();
1228
+ break;
1229
+ }
1230
+ case Ar: {
1231
+ if (s.isNull) throw new Error();
1232
+ e.Info = ws(s.asObject());
1233
+ break;
1234
+ }
1235
+ }
1236
+ }
1237
+ const Cr = 161083277, wr = 325678206, Ur = 3469892363, Rr = 3645544153;
1238
+ function Dr(t) {
1239
+ const e = {};
1240
+ return bt(e), e;
1241
+ }
1242
+ function bt(t) {
1243
+ return t.StreamId = "", t.ClientSessionId = 0, t.TrackId = 0, t.Info = Ct(), t;
1244
+ }
1245
+ function Lr(t, e) {
1246
+ const s = e ?? Dr();
1247
+ return bt(s), mr(t, s), s;
1248
+ }
1249
+ function mr(t, e) {
1250
+ let s;
1251
+ for (; (s = t.next()) !== null; )
1252
+ switch (s.fieldId) {
1253
+ case Cr: {
1254
+ if (s.isNull) throw new Error();
1255
+ e.StreamId = s.asString();
1256
+ break;
1257
+ }
1258
+ case wr: {
1259
+ if (s.isNull) throw new Error();
1260
+ e.ClientSessionId = s.asInt32();
1261
+ break;
1262
+ }
1263
+ case Ur: {
1264
+ if (s.isNull) throw new Error();
1265
+ e.TrackId = s.asInt32();
1266
+ break;
1267
+ }
1268
+ case Rr: {
1269
+ if (s.isNull) throw new Error();
1270
+ e.Info = fs(s.asObject());
1271
+ break;
1272
+ }
1273
+ }
1274
+ }
1275
+ const Or = 1405462580, gr = 2968276160;
1276
+ function Pr(t) {
1277
+ const e = {};
1278
+ return Ft(e), e;
1279
+ }
1280
+ function Ft(t) {
1281
+ return t.MimeType = "", t.Value = new Uint8Array(0), t;
1282
+ }
1283
+ function br(t, e) {
1284
+ const s = e ?? Pr();
1285
+ return Ft(s), Fr(t, s), s;
1286
+ }
1287
+ function Fr(t, e) {
1288
+ let s;
1289
+ for (; (s = t.next()) !== null; )
1290
+ switch (s.fieldId) {
1291
+ case Or: {
1292
+ if (s.isNull) throw new Error();
1293
+ e.Value = s.asBinary();
1294
+ break;
1295
+ }
1296
+ case gr: {
1297
+ if (s.isNull) throw new Error();
1298
+ e.MimeType = s.asString();
1299
+ break;
1300
+ }
1301
+ }
1302
+ }
1303
+ const pr = 1, Mr = 2097188, vr = 979822885, Vr = 2374537704;
1304
+ function kr(t) {
1305
+ const e = {};
1306
+ return pt(e), e;
1307
+ }
1308
+ function pt(t) {
1309
+ return t.StyleId = "", t.Style = /* @__PURE__ */ Object.create(null), t;
1310
+ }
1311
+ function Gr(t, e) {
1312
+ const s = D.create(t);
1313
+ return Br(s, e);
1314
+ }
1315
+ function Br(t, e) {
1316
+ const s = e ?? kr();
1317
+ return pt(s), xr(t, s), s;
1318
+ }
1319
+ function xr(t, e) {
1320
+ let s;
1321
+ for (; (s = t.next()) !== null; )
1322
+ switch (s.fieldId) {
1323
+ case vr: {
1324
+ if (s.isNull) throw new Error();
1325
+ e.StyleId = s.asString();
1326
+ break;
1327
+ }
1328
+ case Vr: {
1329
+ if (s.isNull) throw new Error();
1330
+ e.Style = Yr(s.asDictionary());
1331
+ break;
1332
+ }
1333
+ }
1334
+ }
1335
+ function Hr(t, e) {
1336
+ const s = K(t, Mr, pr);
1337
+ return Gr(s, e);
1338
+ }
1339
+ function Yr(t) {
1340
+ const e = /* @__PURE__ */ Object.create(null);
1341
+ let s;
1342
+ for (; (s = t.next()) !== null; ) {
1343
+ const r = s.key.asString();
1344
+ e[r] = s.value.asString();
1345
+ }
1346
+ return e;
1347
+ }
1348
+ const jr = 1, $r = 2097192, Kr = 2136687806;
1349
+ function Xr(t) {
1350
+ const e = {};
1351
+ return Mt(e), e;
1352
+ }
1353
+ function Mt(t) {
1354
+ return t.Styles = [], t;
1355
+ }
1356
+ function zr(t, e) {
1357
+ const s = D.create(t);
1358
+ return Wr(s, e);
1359
+ }
1360
+ function Wr(t, e) {
1361
+ const s = e ?? Xr();
1362
+ return Mt(s), Jr(t, s), s;
1363
+ }
1364
+ function Jr(t, e) {
1365
+ let s;
1366
+ for (; (s = t.next()) !== null; )
1367
+ switch (s.fieldId) {
1368
+ case Kr: {
1369
+ if (s.isNull) throw new Error();
1370
+ e.Styles = Qr(s.asArray());
1371
+ break;
1372
+ }
1373
+ }
1374
+ }
1375
+ function qr(t, e) {
1376
+ const s = K(t, $r, jr);
1377
+ return zr(s, e);
1378
+ }
1379
+ function Qr(t) {
1380
+ const e = [];
1381
+ let s;
1382
+ for (; (s = t.next()) !== null; )
1383
+ e.push(sn(s.asObject()));
1384
+ return e;
1385
+ }
1386
+ const Zr = 979822885, tn = 2374537704;
1387
+ function en(t) {
1388
+ const e = {};
1389
+ return vt(e), e;
1390
+ }
1391
+ function vt(t) {
1392
+ return t.StyleId = "", t.Style = /* @__PURE__ */ Object.create(null), t;
1393
+ }
1394
+ function sn(t, e) {
1395
+ const s = e ?? en();
1396
+ return vt(s), rn(t, s), s;
1397
+ }
1398
+ function rn(t, e) {
1399
+ let s;
1400
+ for (; (s = t.next()) !== null; )
1401
+ switch (s.fieldId) {
1402
+ case Zr: {
1403
+ if (s.isNull) throw new Error();
1404
+ e.StyleId = s.asString();
1405
+ break;
1406
+ }
1407
+ case tn: {
1408
+ if (s.isNull) throw new Error();
1409
+ e.Style = nn(s.asDictionary());
1410
+ break;
1411
+ }
1412
+ }
1413
+ }
1414
+ function nn(t) {
1415
+ const e = /* @__PURE__ */ Object.create(null);
1416
+ let s;
1417
+ for (; (s = t.next()) !== null; ) {
1418
+ const r = s.key.asString();
1419
+ e[r] = s.value.asString();
1420
+ }
1421
+ return e;
1422
+ }
1423
+ const on = 1, an = 2097190, ln = 425183262, In = 653781469;
1424
+ function cn(t) {
1425
+ const e = {};
1426
+ return Vt(e), e;
1427
+ }
1428
+ function Vt(t) {
1429
+ return t.Json = "", t.Payloads = /* @__PURE__ */ Object.create(null), t;
1430
+ }
1431
+ function En(t, e) {
1432
+ const s = D.create(t);
1433
+ return _n(s, e);
1434
+ }
1435
+ function _n(t, e) {
1436
+ const s = e ?? cn();
1437
+ return Vt(s), fn(t, s), s;
1438
+ }
1439
+ function fn(t, e) {
1440
+ let s;
1441
+ for (; (s = t.next()) !== null; )
1442
+ switch (s.fieldId) {
1443
+ case ln: {
1444
+ if (s.isNull) throw new Error();
1445
+ e.Json = s.asString();
1446
+ break;
1447
+ }
1448
+ case In: {
1449
+ if (s.isNull) throw new Error();
1450
+ e.Payloads = hn(s.asDictionary());
1451
+ break;
1452
+ }
1453
+ }
1454
+ }
1455
+ function un(t, e) {
1456
+ const s = K(t, an, on);
1457
+ return En(s, e);
1458
+ }
1459
+ function hn(t) {
1460
+ const e = /* @__PURE__ */ Object.create(null);
1461
+ let s;
1462
+ for (; (s = t.next()) !== null; ) {
1463
+ const r = s.key.asString();
1464
+ e[r] = br(s.value.asObject());
1465
+ }
1466
+ return e;
1467
+ }
1468
+ function y(t) {
1469
+ return typeof t == "object" && t !== null && !Array.isArray(t);
1470
+ }
1471
+ function kt(t) {
1472
+ const e = {};
1473
+ for (const [s, r] of Object.entries(t))
1474
+ e[s] = r;
1475
+ return e;
1476
+ }
1477
+ function Gt(t, e, s, r) {
1478
+ if (!(t === void 0 && r)) {
1479
+ if (Array.isArray(t)) {
1480
+ const n = [];
1481
+ for (let i = 0; i < t.length; i++) {
1482
+ const o = t[i];
1483
+ if (typeof o != "string")
1484
+ throw new Error(`Invalid styleIds entry at ${e}.styleIds[${i}] for element ${s}`);
1485
+ const a = o.trim();
1486
+ a.length !== 0 && n.push(a);
1487
+ }
1488
+ return n;
1489
+ }
1490
+ if (t != null)
1491
+ throw new Error(`Invalid styleIds for element ${s}`);
1492
+ return [];
1493
+ }
1494
+ }
1495
+ function st(t, e) {
1496
+ if (!t || typeof t != "object")
1497
+ throw new Error(`Invalid UI node at ${e}`);
1498
+ const s = t.Id, r = t.Type, n = t.Props, i = t.Children, o = t.StyleIds;
1499
+ if (typeof s != "string")
1500
+ throw new Error(`Invalid or missing node id at ${e}`);
1501
+ if (typeof r != "string")
1502
+ throw new Error(`Invalid or missing node type for ${s}`);
1503
+ let a = {};
1504
+ if (n != null) {
1505
+ if (!y(n))
1506
+ throw new Error(`Invalid props for node ${s}`);
1507
+ a = kt(n);
1508
+ }
1509
+ let I = [];
1510
+ Array.isArray(i) && (I = i.map(
1511
+ (l, c) => st(l ?? {}, `${e}.children[${c}]`)
1512
+ ));
1513
+ const E = Gt(o, e, s, !1);
1514
+ return {
1515
+ id: s,
1516
+ type: r,
1517
+ props: a,
1518
+ children: I,
1519
+ styleIds: E ?? []
1520
+ };
1521
+ }
1522
+ function Tn(t, e) {
1523
+ if (!y(t))
1524
+ throw new Error(`Invalid text delta at ${e}`);
1525
+ const s = t.NodeId, r = t.PropertyName, n = t.Start, i = t.End, o = t.InsertedText;
1526
+ if (typeof s != "string" || s.length === 0)
1527
+ throw new Error(`Invalid text delta node id at ${e}`);
1528
+ if (typeof r != "string" || r.length === 0)
1529
+ throw new Error(`Invalid text delta property name at ${e}`);
1530
+ if (typeof n != "number" || !Number.isFinite(n))
1531
+ throw new Error(`Invalid text delta start at ${e}`);
1532
+ if (typeof o != "string")
1533
+ throw new Error(`Invalid text delta inserted text at ${e}`);
1534
+ let a;
1535
+ if (typeof i == "number") {
1536
+ if (!Number.isFinite(i))
1537
+ throw new Error(`Invalid text delta end at ${e}`);
1538
+ a = i;
1539
+ } else if (i != null)
1540
+ throw new Error(`Invalid text delta end at ${e}`);
1541
+ return {
1542
+ nodeId: s,
1543
+ propertyName: r,
1544
+ start: n,
1545
+ end: a,
1546
+ insertedText: o
1547
+ };
1548
+ }
1549
+ function Bt(t, e) {
1550
+ if (!y(t))
1551
+ throw new Error(`Invalid UI diff node at ${e}`);
1552
+ const s = t.Id, r = t.Type, n = t.StyleIds;
1553
+ if (typeof s != "string" || s.length === 0)
1554
+ throw new Error(`Invalid diff id at ${e}`);
1555
+ if (typeof r != "string" || r.length === 0)
1556
+ throw new Error(`Invalid diff type for ${s}`);
1557
+ const i = Array.isArray(t.Added) ? t.Added.map(
1558
+ (c, _) => st(c ?? {}, `${e}.added[${_}]`)
1559
+ ) : [], o = [];
1560
+ Array.isArray(t.Removed) && t.Removed.forEach((c, _) => {
1561
+ if (typeof c == "string") {
1562
+ o.push(c);
1563
+ return;
1564
+ }
1565
+ if (y(c) && typeof c.Id == "string") {
1566
+ o.push(c.Id);
1567
+ return;
1568
+ }
1569
+ throw new Error(`Invalid removed node at ${e}.removed[${_}]`);
1570
+ });
1571
+ const a = Array.isArray(t.Updated) ? t.Updated.map(
1572
+ (c, _) => Bt(c ?? {}, `${e}.updated[${_}]`)
1573
+ ) : [], I = /* @__PURE__ */ new Map();
1574
+ if (y(t.ChangedProps))
1575
+ for (const [c, _] of Object.entries(t.ChangedProps)) {
1576
+ if (!y(_))
1577
+ continue;
1578
+ const u = _.New;
1579
+ u === void 0 ? I.set(c, void 0) : y(u) ? I.set(c, kt(u)) : I.set(c, u);
1580
+ }
1581
+ const E = Array.isArray(t.TextUpdates) ? t.TextUpdates.map(
1582
+ (c, _) => Tn(c ?? {}, `${e}.textUpdates[${_}]`)
1583
+ ) : [], l = Gt(n, e, s, !0);
1584
+ return {
1585
+ id: s,
1586
+ type: r,
1587
+ added: i,
1588
+ removed: o,
1589
+ updated: a,
1590
+ changedProps: I,
1591
+ textUpdates: E,
1592
+ ...l !== void 0 ? { styleIds: l } : {}
1593
+ };
1594
+ }
1595
+ function Nn(t) {
1596
+ const e = /* @__PURE__ */ new Map();
1597
+ for (const [s, r] of Object.entries(t))
1598
+ e.set(s, r);
1599
+ return e;
1600
+ }
1601
+ function An(t, e, s) {
1602
+ if (!t || typeof t != "object")
1603
+ throw new C("UI update graph is missing");
1604
+ const r = st(t, "graph");
1605
+ if (r.type !== "root")
1606
+ throw new C('UI update root element must have type "root"');
1607
+ const n = dn(r.props, e);
1608
+ return {
1609
+ type: "full",
1610
+ version: s,
1611
+ root: r,
1612
+ metadata: n
1613
+ };
1614
+ }
1615
+ function Sn(t, e, s) {
1616
+ if (!t || typeof t != "object")
1617
+ throw new C("UI diff payload is missing");
1618
+ if (!y(e))
1619
+ throw new C("UI diff metadata must be an object");
1620
+ const r = e.viewId;
1621
+ if (typeof r != "string" || r.length === 0)
1622
+ throw new C("UI diff metadata is missing viewId");
1623
+ const n = Bt(t, "diff"), i = e.optimisticActionId === null || typeof e.optimisticActionId == "string" ? e.optimisticActionId : void 0, o = typeof e.isOptimistic == "boolean" ? e.isOptimistic : void 0, a = typeof e.isUpdate == "boolean" ? e.isUpdate : void 0, I = z(e.optimisticPatch), E = W(e.optimisticReconcile), l = {
1624
+ viewId: r,
1625
+ ...i !== void 0 ? { optimisticActionId: i } : {},
1626
+ ...o !== void 0 ? { isOptimistic: o } : {},
1627
+ ...a !== void 0 ? { isUpdate: a } : {},
1628
+ ...I ? { optimisticPatch: I } : {},
1629
+ ...E ? { optimisticReconcile: E } : {}
1630
+ };
1631
+ return {
1632
+ type: "diff",
1633
+ version: s,
1634
+ diff: n,
1635
+ metadata: l
1636
+ };
1637
+ }
1638
+ function dn(t, e) {
1639
+ const s = t.viewId;
1640
+ if (typeof s != "string" || s.length === 0)
1641
+ throw new C("UI update root is missing viewId");
1642
+ let r = s, 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 = z(t.optimisticPatch), I = W(t.optimisticReconcile);
1643
+ return y(e) && (typeof e.viewId == "string" && e.viewId.length > 0 && (r = e.viewId), (e.optimisticActionId === null || typeof e.optimisticActionId == "string") && (n = e.optimisticActionId), typeof e.isOptimistic == "boolean" && (i = e.isOptimistic), typeof e.isUpdate == "boolean" && (o = e.isUpdate), e.optimisticPatch !== void 0 && (a = z(e.optimisticPatch)), e.optimisticReconcile !== void 0 && (I = W(e.optimisticReconcile))), {
1644
+ viewId: r,
1645
+ ...n !== void 0 ? { optimisticActionId: n } : {},
1646
+ ...i !== void 0 ? { isOptimistic: i } : {},
1647
+ ...o !== void 0 ? { isUpdate: o } : {},
1648
+ ...a ? { optimisticPatch: a } : {},
1649
+ ...I ? { optimisticReconcile: I } : {}
1650
+ };
1651
+ }
1652
+ function z(t) {
1653
+ if (!y(t))
1654
+ return;
1655
+ const e = t, s = e.id, r = e.actionId, n = e.ordinal, i = e.baseVersion, o = e.supersedes;
1656
+ if (typeof s != "string" || s.length === 0 || typeof r != "string" || r.length === 0 || typeof n != "number" || !Number.isFinite(n) || typeof i != "number" || !Number.isFinite(i))
1657
+ return;
1658
+ let a;
1659
+ if (Array.isArray(o)) {
1660
+ const I = [];
1661
+ for (const E of o)
1662
+ typeof E == "string" && E.length > 0 && I.push(E);
1663
+ a = I;
1664
+ }
1665
+ return {
1666
+ id: s,
1667
+ actionId: r,
1668
+ ordinal: n,
1669
+ baseVersion: i,
1670
+ ...a && a.length > 0 ? { supersedes: a } : {}
1671
+ };
1672
+ }
1673
+ function W(t) {
1674
+ if (!y(t))
1675
+ return;
1676
+ const e = t, s = e.baseVersion, r = e.drop;
1677
+ if (typeof s != "number" || !Number.isFinite(s))
1678
+ return;
1679
+ let n;
1680
+ if (Array.isArray(r)) {
1681
+ const i = [];
1682
+ for (const o of r)
1683
+ typeof o == "string" && o.length > 0 && i.push(o);
1684
+ n = i;
1685
+ }
1686
+ return {
1687
+ baseVersion: s,
1688
+ ...n && n.length > 0 ? { drop: n } : {}
1689
+ };
1690
+ }
1691
+ class C extends Error {
1692
+ constructor(e, s) {
1693
+ super(e), this.causeError = s, this.name = "UiUpdateParseError", s instanceof Error && (this.stack = s.stack);
1694
+ }
1695
+ }
1696
+ function yn(t) {
1697
+ let e;
1698
+ try {
1699
+ e = JSON.parse(t.Json);
1700
+ } catch (o) {
1701
+ throw new C("Failed to parse UIUpdate.Json payload", o);
1702
+ }
1703
+ if (!e || typeof e != "object")
1704
+ throw new C("UI update snapshot must be an object");
1705
+ const { type: s, version: r } = e;
1706
+ if (s !== "full" && s !== "diff")
1707
+ throw new C(`Unknown UI update type: ${String(s)}`);
1708
+ if (typeof r != "number")
1709
+ throw new C("UI update version must be a number");
1710
+ const n = s === "full" ? An(e.graph, e.metadata, r) : Sn(e.diff, e.metadata, r), i = t.Payloads ? Nn(t.Payloads) : /* @__PURE__ */ new Map();
1711
+ return {
1712
+ snapshot: n,
1713
+ payloads: i
1714
+ };
1715
+ }
1716
+ class Cn {
1717
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
1718
+ cache = /* @__PURE__ */ new Map();
1719
+ /**
1720
+ * Get a cached void handler (no payload) for a node/action combination.
1721
+ * Creates and caches the handler if it doesn't exist.
1722
+ */
1723
+ getHandler(e, s, r) {
1724
+ const n = `${e}:${s}`;
1725
+ let i = this.cache.get(n);
1726
+ return i || (i = () => r(s), this.cache.set(n, i)), i;
1727
+ }
1728
+ /**
1729
+ * Get a cached handler that accepts a payload.
1730
+ * Creates and caches the handler if it doesn't exist.
1731
+ */
1732
+ getHandlerWithPayload(e, s, r) {
1733
+ const n = `${e}:${s}:payload`;
1734
+ let i = this.cache.get(n);
1735
+ return i || (i = (o) => r(s, o), this.cache.set(n, i)), i;
1736
+ }
1737
+ /**
1738
+ * Get a cached handler for boolean payloads.
1739
+ */
1740
+ getBooleanHandler(e, s, r) {
1741
+ return this.getHandlerWithPayload(e, s, r);
1742
+ }
1743
+ /**
1744
+ * Get a cached handler for string payloads.
1745
+ */
1746
+ getStringHandler(e, s, r) {
1747
+ return this.getHandlerWithPayload(e, s, r);
1748
+ }
1749
+ /**
1750
+ * Get a cached handler for number payloads.
1751
+ */
1752
+ getNumberHandler(e, s, r) {
1753
+ return this.getHandlerWithPayload(e, s, r);
1754
+ }
1755
+ /**
1756
+ * Get a cached handler for number array payloads.
1757
+ */
1758
+ getNumberArrayHandler(e, s, r) {
1759
+ return this.getHandlerWithPayload(e, s, r);
1760
+ }
1761
+ /**
1762
+ * Get a cached handler for nullable boolean payloads.
1763
+ */
1764
+ getNullableBooleanHandler(e, s, r) {
1765
+ const n = `${e}:${s}:nullable-bool`;
1766
+ let i = this.cache.get(n);
1767
+ return i || (i = (o) => r(s, o ?? null), this.cache.set(n, i)), i;
1768
+ }
1769
+ /**
1770
+ * Invalidate all cached handlers for a specific node.
1771
+ * Call this when a node is removed from the tree.
1772
+ */
1773
+ invalidateNode(e) {
1774
+ const s = `${e}:`;
1775
+ for (const r of this.cache.keys())
1776
+ r.startsWith(s) && this.cache.delete(r);
1777
+ }
1778
+ /**
1779
+ * Invalidate a specific handler.
1780
+ */
1781
+ invalidateHandler(e, s) {
1782
+ this.cache.delete(`${e}:${s}`), this.cache.delete(`${e}:${s}:payload`), this.cache.delete(`${e}:${s}:nullable-bool`);
1783
+ }
1784
+ /**
1785
+ * Clear all cached handlers.
1786
+ */
1787
+ clear() {
1788
+ this.cache.clear();
1789
+ }
1790
+ /**
1791
+ * Get the number of cached handlers (for debugging/testing).
1792
+ */
1793
+ get size() {
1794
+ return this.cache.size;
1795
+ }
1796
+ }
1797
+ class wn {
1798
+ views = /* @__PURE__ */ new Map();
1799
+ listeners = /* @__PURE__ */ new Set();
1800
+ payloads = /* @__PURE__ */ new Map();
1801
+ snapshotMode = !1;
1802
+ snapshot = {
1803
+ views: /* @__PURE__ */ new Map(),
1804
+ payloads: /* @__PURE__ */ new Map(),
1805
+ optimisticPatches: /* @__PURE__ */ new Map(),
1806
+ version: -1
1807
+ };
1808
+ rootViewId;
1809
+ // Per-node subscriptions for granular updates
1810
+ nodeListeners = /* @__PURE__ */ new Map();
1811
+ changedNodeIds = /* @__PURE__ */ new Set();
1812
+ nodeVersions = /* @__PURE__ */ new Map();
1813
+ structureChanged = !1;
1814
+ // Handler cache for stable event handlers
1815
+ handlerCache = new Cn();
1816
+ apply(e) {
1817
+ if (this.snapshotMode) {
1818
+ if (e.snapshot.type !== "full")
1819
+ return !1;
1820
+ this.snapshotMode = !1, this.views.clear(), this.payloads.clear(), this.rootViewId = void 0, this.snapshot = {
1821
+ views: /* @__PURE__ */ new Map(),
1822
+ payloads: /* @__PURE__ */ new Map(),
1823
+ optimisticPatches: /* @__PURE__ */ new Map(),
1824
+ version: -1
1825
+ };
1826
+ }
1827
+ const { snapshot: s, payloads: r } = e, { metadata: n } = s, { viewId: i } = n;
1828
+ let o = this.views.get(i);
1829
+ o || (o = {
1830
+ version: 0,
1831
+ baselineVersion: 0,
1832
+ patches: /* @__PURE__ */ new Map()
1833
+ }, this.views.set(i, o));
1834
+ const a = s.type === "diff" && n.isUpdate === !0;
1835
+ if (s.version < o.version || s.version === o.version && !a)
1836
+ return !1;
1837
+ let I = !1;
1838
+ if (this.rootViewId || (this.rootViewId = i, I = !0, this.structureChanged = !0), n.optimisticReconcile?.drop)
1839
+ for (const l of n.optimisticReconcile.drop)
1840
+ o.patches.delete(l) && (I = !0);
1841
+ if (n.optimisticPatch?.supersedes)
1842
+ for (const l of n.optimisticPatch.supersedes)
1843
+ o.patches.delete(l) && (I = !0);
1844
+ const E = o.composite ?? o.baseline;
1845
+ if (s.type === "full")
1846
+ o.baseline = s.root, o.composite = s.root, o.baselineVersion = n.optimisticReconcile?.baseVersion ?? s.version, o.patches.clear(), o.version = s.version, I = !0, this.structureChanged = !0, s.root && O(s.root, this.changedNodeIds);
1847
+ else if (n.optimisticPatch) {
1848
+ if (!E)
1849
+ return !1;
1850
+ const l = Y(E, s.diff);
1851
+ l !== E && (o.composite = l, I = !0, M(E, l, this.changedNodeIds));
1852
+ const c = n.optimisticPatch, _ = {
1853
+ id: c.id,
1854
+ actionId: c.actionId,
1855
+ ordinal: c.ordinal,
1856
+ baseVersion: c.baseVersion,
1857
+ diff: s.diff
1858
+ };
1859
+ o.patches.set(_.id, _), I = !0, o.version = s.version;
1860
+ } else {
1861
+ const l = o.baseline ?? E;
1862
+ if (!l)
1863
+ return !1;
1864
+ const c = Y(l, s.diff);
1865
+ c !== l ? (o.baseline = c, I = !0) : o.baseline = c, o.baselineVersion = n.optimisticReconcile?.baseVersion ?? s.version;
1866
+ let _ = o.baseline ?? c;
1867
+ const u = [...o.patches.values()].sort((T, f) => T.ordinal - f.ordinal);
1868
+ for (const T of u) {
1869
+ const f = Y(_, T.diff);
1870
+ f !== _ && (I = !0), _ = f, T.baseVersion = o.baselineVersion;
1871
+ }
1872
+ o.composite !== _ && (o.composite = _, I = !0), E && _ ? M(E, _, this.changedNodeIds) : _ && O(_, this.changedNodeIds), o.version = s.version;
1873
+ }
1874
+ for (const [l, c] of r)
1875
+ this.payloads.get(l) !== c && (this.payloads.set(l, c), I = !0);
1876
+ return I ? (this.commitSnapshot(), this.notify(), !0) : (o.version = s.version, !1);
1877
+ }
1878
+ replaceFromWire(e) {
1879
+ const s = {
1880
+ rootViewId: e.rootViewId,
1881
+ views: new Map(e.views),
1882
+ payloads: new Map(e.payloads),
1883
+ optimisticPatches: new Map(e.optimisticPatches),
1884
+ version: e.version
1885
+ };
1886
+ return this.replaceSnapshot(s);
1887
+ }
1888
+ patchFromOp(e) {
1889
+ this.snapshotMode = !0;
1890
+ const s = e.expectedBaseVersion;
1891
+ if (s !== void 0 && this.snapshot.version !== s)
1892
+ return !1;
1893
+ let r = !1, n = null, i = null, o = null;
1894
+ const a = () => (n || (n = new Map(this.snapshot.views)), n), I = () => (i || (i = new Map(this.snapshot.payloads)), i), E = () => (o || (o = new Map(this.snapshot.optimisticPatches)), o);
1895
+ if (e.deleteViews && e.deleteViews.length > 0)
1896
+ for (const _ of e.deleteViews)
1897
+ a().delete(_) && (r = !0, this.structureChanged = !0);
1898
+ if (e.upsertViews && e.upsertViews.length > 0)
1899
+ for (const [_, u] of e.upsertViews) {
1900
+ const T = a(), f = T.get(_);
1901
+ f !== u && (T.set(_, u), r = !0, f ? M(f, u, this.changedNodeIds) : (O(u, this.changedNodeIds), this.structureChanged = !0));
1902
+ }
1903
+ if (e.deletePayloads && e.deletePayloads.length > 0)
1904
+ for (const _ of e.deletePayloads)
1905
+ I().delete(_) && (r = !0);
1906
+ if (e.upsertPayloads && e.upsertPayloads.length > 0)
1907
+ for (const [_, u] of e.upsertPayloads) {
1908
+ const T = I();
1909
+ T.get(_) !== u && (T.set(_, u), r = !0);
1910
+ }
1911
+ if (e.deleteOptimisticPatchesForViews && e.deleteOptimisticPatchesForViews.length > 0)
1912
+ for (const _ of e.deleteOptimisticPatchesForViews)
1913
+ E().delete(_) && (r = !0);
1914
+ if (e.upsertOptimisticPatches && e.upsertOptimisticPatches.length > 0)
1915
+ for (const [_, u] of e.upsertOptimisticPatches) {
1916
+ const T = E(), f = T.get(_);
1917
+ Dn(f, u) || (T.set(_, u), r = !0);
1918
+ }
1919
+ const l = e.rootViewId ?? this.snapshot.rootViewId;
1920
+ l !== this.snapshot.rootViewId && (r = !0, this.structureChanged = !0);
1921
+ const c = e.nextVersion;
1922
+ if (c !== this.snapshot.version && (r = !0), !r)
1923
+ return this.snapshot = { ...this.snapshot, version: c }, !1;
1924
+ for (const _ of this.changedNodeIds)
1925
+ this.nodeVersions.set(_, (this.nodeVersions.get(_) ?? 0) + 1);
1926
+ return this.snapshot = {
1927
+ rootViewId: l,
1928
+ views: n ?? new Map(this.snapshot.views),
1929
+ payloads: i ?? new Map(this.snapshot.payloads),
1930
+ optimisticPatches: o ?? new Map(this.snapshot.optimisticPatches),
1931
+ version: c
1932
+ }, this.notify(), !0;
1933
+ }
1934
+ replaceSnapshot(e) {
1935
+ this.snapshotMode = !0;
1936
+ const s = this.snapshot, r = s.version !== e.version || s.rootViewId !== e.rootViewId || s.views.size !== e.views.size || s.payloads.size !== e.payloads.size || s.optimisticPatches.size !== e.optimisticPatches.size;
1937
+ (s.rootViewId !== e.rootViewId || s.views.size !== e.views.size) && (this.structureChanged = !0);
1938
+ for (const [n, i] of e.views) {
1939
+ const o = s.views.get(n);
1940
+ o ? M(o, i, this.changedNodeIds) : (O(i, this.changedNodeIds), this.structureChanged = !0);
1941
+ }
1942
+ for (const n of this.changedNodeIds)
1943
+ this.nodeVersions.set(n, (this.nodeVersions.get(n) ?? 0) + 1);
1944
+ return this.snapshot = e, r && this.notify(), r;
1945
+ }
1946
+ clear() {
1947
+ (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.snapshot = {
1948
+ views: /* @__PURE__ */ new Map(),
1949
+ payloads: /* @__PURE__ */ new Map(),
1950
+ optimisticPatches: /* @__PURE__ */ new Map(),
1951
+ version: -1
1952
+ }, this.structureChanged = !0, this.notify());
1953
+ }
1954
+ getSnapshot() {
1955
+ return this.snapshot;
1956
+ }
1957
+ subscribe(e) {
1958
+ return this.listeners.add(e), () => {
1959
+ this.listeners.delete(e);
1960
+ };
1961
+ }
1962
+ subscribeNode(e, s) {
1963
+ let r = this.nodeListeners.get(e);
1964
+ return r || (r = /* @__PURE__ */ new Set(), this.nodeListeners.set(e, r)), r.add(s), () => {
1965
+ r.delete(s), r.size === 0 && this.nodeListeners.delete(e);
1966
+ };
1967
+ }
1968
+ getNode(e) {
1969
+ const s = this.snapshot.views.get(e);
1970
+ if (s)
1971
+ return s;
1972
+ for (const r of this.snapshot.views.values()) {
1973
+ const n = xt(r, e);
1974
+ if (n)
1975
+ return n;
1976
+ }
1977
+ }
1978
+ getNodeVersion(e) {
1979
+ return this.nodeVersions.get(e) ?? 0;
1980
+ }
1981
+ notifyNodes() {
1982
+ if (this.changedNodeIds.size === 0 || this.nodeListeners.size === 0) {
1983
+ this.changedNodeIds.clear();
1984
+ return;
1985
+ }
1986
+ for (const e of this.changedNodeIds) {
1987
+ const s = this.nodeListeners.get(e);
1988
+ if (s)
1989
+ for (const r of s)
1990
+ r();
1991
+ }
1992
+ this.changedNodeIds.clear();
1993
+ }
1994
+ commitSnapshot() {
1995
+ const e = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map();
1996
+ for (const [n, i] of this.views)
1997
+ if (i.composite ? e.set(n, i.composite) : i.baseline && e.set(n, i.baseline), i.patches.size > 0) {
1998
+ const o = [...i.patches.values()].sort((a, I) => a.ordinal - I.ordinal);
1999
+ s.set(
2000
+ n,
2001
+ o.map((a) => ({
2002
+ id: a.id,
2003
+ actionId: a.actionId,
2004
+ ordinal: a.ordinal,
2005
+ baseVersion: a.baseVersion
2006
+ }))
2007
+ );
2008
+ }
2009
+ let r = this.rootViewId && this.views.has(this.rootViewId) ? this.views.get(this.rootViewId)?.version : void 0;
2010
+ if (r === void 0)
2011
+ for (const n of this.views.values())
2012
+ r = r === void 0 ? n.version : Math.max(r, n.version);
2013
+ this.snapshot = {
2014
+ rootViewId: this.rootViewId,
2015
+ views: e,
2016
+ payloads: new Map(this.payloads),
2017
+ optimisticPatches: s,
2018
+ version: r
2019
+ };
2020
+ for (const n of this.changedNodeIds)
2021
+ this.nodeVersions.set(n, (this.nodeVersions.get(n) ?? 0) + 1);
2022
+ }
2023
+ notify() {
2024
+ if (this.notifyNodes(), this.structureChanged) {
2025
+ this.structureChanged = !1;
2026
+ for (const e of this.listeners)
2027
+ e();
2028
+ }
2029
+ }
2030
+ }
2031
+ class Un {
2032
+ streams = /* @__PURE__ */ new Map();
2033
+ listeners = /* @__PURE__ */ new Set();
2034
+ apply(e, s) {
2035
+ const n = this.getOrCreateStreamEntry(e).store.apply(s);
2036
+ return n && this.notify(e), n;
2037
+ }
2038
+ applyStoreOp(e) {
2039
+ if (e.type === "ReplaceStreamSnapshot") {
2040
+ const s = this.getOrCreateStreamEntry(e.snapshot.streamId), r = s.category !== e.snapshot.category;
2041
+ return s.category = e.snapshot.category, s.store.replaceFromWire(e.snapshot) || r ? (this.notify(e.snapshot.streamId), !0) : !1;
2042
+ }
2043
+ if (e.type === "PatchStreamSnapshot") {
2044
+ const s = this.getOrCreateStreamEntry(e.streamId), r = e.category !== void 0 && s.category !== e.category;
2045
+ return e.category !== void 0 && (s.category = e.category), s.store.patchFromOp(e) || r ? (this.notify(e.streamId), !0) : !1;
2046
+ }
2047
+ if (e.type === "ClearStream") {
2048
+ const s = this.streams.get(e.streamId);
2049
+ return s ? (s.store.clear(), this.notify(e.streamId), !0) : !1;
2050
+ }
2051
+ return e.type === "RemoveStream" ? this.streams.delete(e.streamId) ? (this.notify(e.streamId), !0) : !1 : e.type === "SetStreamCategory" ? (this.setCategory(e.streamId, e.category), !0) : !1;
2052
+ }
2053
+ applyStoreOps(e) {
2054
+ for (const s of e)
2055
+ this.applyStoreOp(s);
2056
+ }
2057
+ clear(e) {
2058
+ const s = this.streams.get(e);
2059
+ s && (s.store.clear(), this.notify(e));
2060
+ }
2061
+ remove(e) {
2062
+ this.streams.delete(e) && this.notify(e);
2063
+ }
2064
+ setCategory(e, s) {
2065
+ const r = this.getOrCreateStreamEntry(e);
2066
+ r.category !== s && (r.category = s, this.notify(e));
2067
+ }
2068
+ getSnapshot(e) {
2069
+ const s = this.streams.get(e);
2070
+ return s ? {
2071
+ ...s.store.getSnapshot(),
2072
+ streamId: e,
2073
+ category: s.category
2074
+ } : void 0;
2075
+ }
2076
+ getSnapshots() {
2077
+ const e = [];
2078
+ for (const [s, r] of this.streams) {
2079
+ const n = r.store.getSnapshot();
2080
+ e.push({
2081
+ ...n,
2082
+ streamId: s,
2083
+ category: r.category
2084
+ });
2085
+ }
2086
+ return e;
2087
+ }
2088
+ subscribe(e) {
2089
+ return this.listeners.add(e), () => {
2090
+ this.listeners.delete(e);
2091
+ };
2092
+ }
2093
+ getOrCreateStreamEntry(e) {
2094
+ let s = this.streams.get(e);
2095
+ return s || (s = { store: new wn() }, this.streams.set(e, s)), s;
2096
+ }
2097
+ notify(e) {
2098
+ for (const s of this.listeners)
2099
+ s(e);
2100
+ }
2101
+ }
2102
+ function Y(t, e, s) {
2103
+ if (t.id !== e.id)
2104
+ return t;
2105
+ let r = t, n = !1;
2106
+ if (e.textUpdates.length > 0) {
2107
+ const f = mn(t, e.textUpdates);
2108
+ r = f.node, n = f.changed;
2109
+ }
2110
+ let i = !1, o = r.props;
2111
+ if (e.changedProps.size > 0)
2112
+ for (const [f, N] of e.changedProps.entries()) {
2113
+ const S = o[f];
2114
+ if (N === void 0)
2115
+ (S !== void 0 || f in o) && (i || (o = v(o), i = !0), delete o[f]);
2116
+ else if (J(N)) {
2117
+ const L = v(N);
2118
+ b(L, S) || (i || (o = v(o), i = !0), o[f] = L);
2119
+ } else
2120
+ b(N, S) || (i || (o = v(o), i = !0), o[f] = N);
2121
+ }
2122
+ let a = !1, I = r.styleIds;
2123
+ e.styleIds !== void 0 && (Ht(r.styleIds, e.styleIds) || (I = e.styleIds, a = !0));
2124
+ const E = r.children ?? [];
2125
+ let l = E, c = !1;
2126
+ if (e.removed.length > 0) {
2127
+ const f = new Set(e.removed), N = l.filter((S) => !f.has(S.id));
2128
+ N.length !== l.length && (l = N, c = !0);
2129
+ }
2130
+ if (e.updated.length > 0) {
2131
+ const f = new Map(e.updated.map((S) => [S.id, S]));
2132
+ let N;
2133
+ for (let S = 0; S < l.length; S++) {
2134
+ const L = l[S], rt = f.get(L.id);
2135
+ if (!rt)
2136
+ continue;
2137
+ const nt = Y(L, rt);
2138
+ nt !== L && (N || (N = [...l]), N[S] = nt);
2139
+ }
2140
+ N && (l = N, c = !0);
2141
+ }
2142
+ e.added.length > 0 && (l = [...l, ...e.added], c = !0);
2143
+ const _ = r.type !== e.type;
2144
+ return n || i || _ || a || c ? !i && !c && !_ && !a ? r : {
2145
+ id: e.id,
2146
+ type: e.type,
2147
+ props: i ? o : r.props,
2148
+ children: c ? l : E,
2149
+ styleIds: a ? I : r.styleIds
2150
+ } : t;
2151
+ }
2152
+ function O(t, e) {
2153
+ if (e.add(t.id), t.children)
2154
+ for (const s of t.children)
2155
+ O(s, e);
2156
+ }
2157
+ function M(t, e, s) {
2158
+ if (t === e)
2159
+ return;
2160
+ (t.type !== e.type || !Rn(t.props, e.props) || !Ht(t.styleIds, e.styleIds)) && s.add(e.id);
2161
+ const n = t.children ?? [], i = e.children ?? [];
2162
+ if (n !== i) {
2163
+ const o = /* @__PURE__ */ new Map();
2164
+ for (const a of n)
2165
+ o.set(a.id, a);
2166
+ for (const a of i) {
2167
+ const I = o.get(a.id);
2168
+ I ? M(I, a, s) : O(a, s);
2169
+ }
2170
+ n.length !== i.length && s.add(e.id);
2171
+ }
2172
+ }
2173
+ function Rn(t, e) {
2174
+ return b(t, e);
2175
+ }
2176
+ function xt(t, e) {
2177
+ if (t.id === e)
2178
+ return t;
2179
+ if (t.children)
2180
+ for (const s of t.children) {
2181
+ const r = xt(s, e);
2182
+ if (r)
2183
+ return r;
2184
+ }
2185
+ }
2186
+ function Ht(t, e) {
2187
+ return b(t, e);
2188
+ }
2189
+ function Dn(t, e) {
2190
+ if (t === e) return !0;
2191
+ if (!t || !e || t.length !== e.length) return !1;
2192
+ for (let s = 0; s < t.length; s++) {
2193
+ const r = t[s], n = e[s];
2194
+ if (r.id !== n.id || r.actionId !== n.actionId || r.ordinal !== n.ordinal || r.baseVersion !== n.baseVersion)
2195
+ return !1;
2196
+ }
2197
+ return !0;
2198
+ }
2199
+ function Ln(t, e) {
2200
+ if (e.length === 0)
2201
+ return t;
2202
+ const s = [...e].sort((i, o) => i.start - o.start);
2203
+ let r = t, n = 0;
2204
+ for (const i of s) {
2205
+ const o = ot(i.start + n, 0, r.length);
2206
+ if (i.end == null) {
2207
+ const l = r.slice(o), c = On(l, i.insertedText);
2208
+ r = r.slice(0, o) + i.insertedText + l.slice(c), n += i.insertedText.length - c;
2209
+ continue;
2210
+ }
2211
+ const a = i.end + n, I = ot(a, o, r.length), E = I - o;
2212
+ r = r.slice(0, o) + i.insertedText + r.slice(I), n += i.insertedText.length - E;
2213
+ }
2214
+ return r;
2215
+ }
2216
+ function mn(t, e, s) {
2217
+ if (e.length === 0)
2218
+ return { node: t, changed: !1 };
2219
+ const r = /* @__PURE__ */ new Map();
2220
+ for (const n of e) {
2221
+ const i = r.get(n.nodeId);
2222
+ i ? i.push(n) : r.set(n.nodeId, [n]);
2223
+ }
2224
+ return Yt(t, r);
2225
+ }
2226
+ function Yt(t, e, s) {
2227
+ const r = e.get(t.id) ?? [];
2228
+ let n = !1, i = t.props;
2229
+ if (r.length > 0) {
2230
+ const E = /* @__PURE__ */ new Map();
2231
+ for (const l of r) {
2232
+ const c = E.get(l.propertyName);
2233
+ c ? c.push(l) : E.set(l.propertyName, [l]);
2234
+ }
2235
+ for (const [l, c] of E.entries()) {
2236
+ const _ = i[l], T = Ln(typeof _ == "string" ? _ : "", c);
2237
+ n || (i = v(i), n = !0), i[l] = T;
2238
+ }
2239
+ }
2240
+ let o = !1;
2241
+ const a = t.children ?? [];
2242
+ let I = a;
2243
+ if (a.length > 0) {
2244
+ let E;
2245
+ for (let l = 0; l < a.length; l++) {
2246
+ const c = a[l], _ = Yt(c, e);
2247
+ _.changed && (E || (E = [...a]), E[l] = _.node);
2248
+ }
2249
+ E && (I = E, o = !0);
2250
+ }
2251
+ return !n && !o ? { node: t, changed: !1 } : {
2252
+ node: {
2253
+ id: t.id,
2254
+ type: t.type,
2255
+ props: n ? i : t.props,
2256
+ children: o ? I : a,
2257
+ styleIds: t.styleIds
2258
+ },
2259
+ changed: !0
2260
+ };
2261
+ }
2262
+ function ot(t, e, s) {
2263
+ return Math.max(e, Math.min(s, t));
2264
+ }
2265
+ function On(t, e) {
2266
+ const s = Math.min(t.length, e.length);
2267
+ let r = 0;
2268
+ for (; r < s && t.charCodeAt(r) === e.charCodeAt(r); )
2269
+ r++;
2270
+ return r;
2271
+ }
2272
+ function v(t) {
2273
+ const e = {};
2274
+ for (const [s, r] of Object.entries(t))
2275
+ e[s] = r;
2276
+ return e;
2277
+ }
2278
+ function J(t) {
2279
+ return typeof t == "object" && t !== null && !Array.isArray(t);
2280
+ }
2281
+ function b(t, e) {
2282
+ if (Object.is(t, e))
2283
+ return !0;
2284
+ if (Array.isArray(t) && Array.isArray(e)) {
2285
+ if (t.length !== e.length)
2286
+ return !1;
2287
+ for (let s = 0; s < t.length; s++)
2288
+ if (!b(t[s], e[s]))
2289
+ return !1;
2290
+ return !0;
2291
+ }
2292
+ if (J(t) && J(e)) {
2293
+ const s = Object.keys(t), r = Object.keys(e);
2294
+ if (s.length !== r.length)
2295
+ return !1;
2296
+ for (const n of s)
2297
+ if (!b(t[n], e[n]))
2298
+ return !1;
2299
+ return !0;
2300
+ }
2301
+ return !1;
2302
+ }
2303
+ const gn = 16, Pn = 50, R = new Un(), $ = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Map();
2304
+ let jt = gn, $t = Pn, V = [], k = null, G = null, U = 0, j = 0;
2305
+ const B = /* @__PURE__ */ new Map();
2306
+ function bn() {
2307
+ return typeof performance < "u" ? performance.now() : Date.now();
2308
+ }
2309
+ function Fn() {
2310
+ try {
2311
+ return crypto.randomUUID();
2312
+ } catch {
2313
+ return `${Date.now()}_${Math.random().toString(16).slice(2)}`;
2314
+ }
2315
+ }
2316
+ function pn(t) {
2317
+ return {
2318
+ streamId: t.streamId,
2319
+ category: t.category,
2320
+ version: t.version ?? -1,
2321
+ rootViewId: t.rootViewId,
2322
+ views: Array.from(t.views.entries()),
2323
+ payloads: Array.from(t.payloads.entries()),
2324
+ optimisticPatches: Array.from(t.optimisticPatches.entries()).map(([e, s]) => [e, [...s]])
2325
+ };
2326
+ }
2327
+ function Mn(t, e) {
2328
+ if (t === e) return !0;
2329
+ if (!t || !e || t.length !== e.length) return !1;
2330
+ for (let s = 0; s < t.length; s++) {
2331
+ const r = t[s], n = e[s];
2332
+ if (r.id !== n.id || r.actionId !== n.actionId || r.ordinal !== n.ordinal || r.baseVersion !== n.baseVersion)
2333
+ return !1;
2334
+ }
2335
+ return !0;
2336
+ }
2337
+ function vn(t, e, s) {
2338
+ if (!s || s.version === -1)
2339
+ return { type: "ReplaceStreamSnapshot", snapshot: pn(e) };
2340
+ const r = [], n = [];
2341
+ for (const [E, l] of e.views.entries())
2342
+ s.views.get(E) !== l && r.push([E, l]);
2343
+ for (const E of s.views.keys())
2344
+ e.views.has(E) || n.push(E);
2345
+ const i = [], o = [];
2346
+ for (const [E, l] of e.payloads.entries())
2347
+ s.payloads.get(E) !== l && i.push([E, l]);
2348
+ for (const E of s.payloads.keys())
2349
+ e.payloads.has(E) || o.push(E);
2350
+ const a = [], I = [];
2351
+ for (const [E, l] of e.optimisticPatches.entries()) {
2352
+ const c = s.optimisticPatches.get(E);
2353
+ Mn(c, l) || a.push([E, [...l]]);
2354
+ }
2355
+ for (const E of s.optimisticPatches.keys())
2356
+ e.optimisticPatches.has(E) || I.push(E);
2357
+ return {
2358
+ type: "PatchStreamSnapshot",
2359
+ streamId: t,
2360
+ category: e.category,
2361
+ nextVersion: e.version ?? -1,
2362
+ expectedBaseVersion: s.version ?? -1,
2363
+ rootViewId: e.rootViewId,
2364
+ upsertViews: r.length ? r : void 0,
2365
+ deleteViews: n.length ? n : void 0,
2366
+ upsertPayloads: i.length ? i : void 0,
2367
+ deletePayloads: o.length ? o : void 0,
2368
+ upsertOptimisticPatches: a.length ? a : void 0,
2369
+ deleteOptimisticPatchesForViews: I.length ? I : void 0
2370
+ };
2371
+ }
2372
+ function Kt() {
2373
+ k || (k = setTimeout(at, jt)), G || (G = setTimeout(at, $t));
2374
+ }
2375
+ function F(t) {
2376
+ V.push(t), Kt();
2377
+ }
2378
+ function at() {
2379
+ if (k && (clearTimeout(k), k = null), G && (clearTimeout(G), G = null), V.length === 0 && B.size === 0) {
2380
+ U = 0, j = 0;
2381
+ return;
2382
+ }
2383
+ const t = Array.from(B.entries()).map(([s, r]) => ({ trackId: s, version: r })), e = {
2384
+ batchId: Fn(),
2385
+ createdAtMs: bn(),
2386
+ ops: V,
2387
+ ...t.length > 0 ? { acks: t } : {},
2388
+ stats: { uiMessagesConsumed: U, bytesConsumed: j }
2389
+ };
2390
+ V = [], U = 0, j = 0, B.clear(), self.postMessage(e);
2391
+ }
2392
+ function Xt(t) {
2393
+ return `${t.senderId}_${t.trackId}`;
2394
+ }
2395
+ function Vn(t) {
2396
+ const e = Xs(t), s = /* @__PURE__ */ new Set();
2397
+ for (const r of Object.values(e.UIStreams ?? {})) {
2398
+ const n = r.StreamId;
2399
+ s.add(n);
2400
+ const i = r.Info?.Category;
2401
+ R.getSnapshot(n)?.category !== i && (R.setCategory(n, i), F({ type: "SetStreamCategory", streamId: n, category: i }));
2402
+ }
2403
+ for (const r of R.getSnapshots())
2404
+ s.has(r.streamId) || (R.remove(r.streamId), x.delete(r.streamId), F({ type: "RemoveStream", streamId: r.streamId }));
2405
+ }
2406
+ function kn(t) {
2407
+ const e = q(t), s = Xt(e), r = un(t), n = yn(r), i = B.get(e.trackId);
2408
+ if ((i === void 0 || n.snapshot.version > i) && (B.set(e.trackId, n.snapshot.version), Kt()), !R.apply(s, n))
2409
+ return;
2410
+ const a = R.getSnapshot(s);
2411
+ if (!a)
2412
+ return;
2413
+ const I = x.get(s);
2414
+ x.set(s, a), F(vn(s, a, I));
2415
+ }
2416
+ function Gn(t) {
2417
+ const e = Hr(t);
2418
+ if (!e.StyleId)
2419
+ return;
2420
+ const s = {
2421
+ styleId: e.StyleId,
2422
+ css: e.Style?.css,
2423
+ common: e.Style?.common
2424
+ }, r = $.get(s.styleId);
2425
+ r && r.css === s.css && r.common === s.common || ($.set(s.styleId, s), F({ type: "UpsertUiStyle", style: s }));
2426
+ }
2427
+ function Bn(t) {
2428
+ const e = qr(t);
2429
+ if (e.Styles)
2430
+ for (const s of e.Styles) {
2431
+ if (!s.StyleId)
2432
+ continue;
2433
+ const r = {
2434
+ styleId: s.StyleId,
2435
+ css: s.Style?.css,
2436
+ common: s.Style?.common
2437
+ }, n = $.get(r.styleId);
2438
+ n && n.css === r.css && n.common === r.common || ($.set(r.styleId, r), F({ type: "UpsertUiStyle", style: r }));
2439
+ }
2440
+ }
2441
+ function xn(t) {
2442
+ const e = q(t), s = Xt(e);
2443
+ R.clear(s), x.delete(s), F({ type: "ClearStream", streamId: s });
2444
+ }
2445
+ function Hn(t) {
2446
+ const e = new Uint8Array(t);
2447
+ j += e.byteLength;
2448
+ const s = e;
2449
+ switch (zt(s)) {
2450
+ case m.CORE_GLOBAL_STATE:
2451
+ Vn(s), U++;
2452
+ return;
2453
+ case m.UI_UPDATE:
2454
+ try {
2455
+ kn(s);
2456
+ } catch (n) {
2457
+ return n instanceof C, void 0;
2458
+ } finally {
2459
+ U++;
2460
+ }
2461
+ return;
2462
+ case m.UI_STYLES:
2463
+ Gn(s), U++;
2464
+ return;
2465
+ case m.UI_STYLES_BATCH:
2466
+ Bn(s), U++;
2467
+ return;
2468
+ case m.ACTION_UI_CLEAR_STREAM:
2469
+ xn(s), U++;
2470
+ return;
2471
+ default:
2472
+ return;
2473
+ }
2474
+ }
2475
+ self.addEventListener("message", (t) => {
2476
+ const e = t.data;
2477
+ if (e.type === "configure") {
2478
+ typeof e.flushIntervalMs == "number" && Number.isFinite(e.flushIntervalMs) && e.flushIntervalMs >= 0 && (jt = e.flushIntervalMs), typeof e.maxLatencyMs == "number" && Number.isFinite(e.maxLatencyMs) && e.maxLatencyMs >= 0 && ($t = e.maxLatencyMs);
2479
+ return;
2480
+ }
2481
+ if (e.type === "clear") {
2482
+ V = [], x.clear();
2483
+ return;
2484
+ }
2485
+ e.type === "protocol" && Hn(e.message);
2486
+ });