@ikonai/sdk-ui 1.0.80 → 1.1.0

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,1474 +0,0 @@
1
- const Tt = {
2
- Compressed: 8
3
- };
4
- function ct(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 e = M(t), r = new DataView(e.buffer, e.byteOffset, e.byteLength);
11
- if (e.length < 27)
12
- throw new Error("Protocol payload too short");
13
- const s = r.getUint32(0, !0), n = r.getUint32(4, !0), a = r.getUint32(8, !0), i = r.getUint32(12, !0), E = r.getUint32(16, !0), _ = r.getUint32(20, !0), o = r.getUint8(24), l = r.getUint8(25), A = r.getUint8(26);
14
- if (27 + _ * 4 > e.length)
15
- throw new Error("Protocol header exceeds payload length");
16
- const R = [];
17
- let P = 27;
18
- for (let L = 0; L < _; L++)
19
- R.push(r.getUint32(P, !0)), P += 4;
20
- return {
21
- length: s,
22
- opcode: n,
23
- senderId: a,
24
- trackId: i,
25
- sequenceId: E,
26
- targetIds: R,
27
- payloadVersion: o,
28
- payloadType: l,
29
- flags: A
30
- };
31
- }
32
- async function rt(t, e, r) {
33
- const s = M(t), n = et(s);
34
- if (e !== void 0 && n.opcode !== e)
35
- throw new Error(`Unexpected opcode ${n.opcode}`);
36
- if (n.payloadType !== 8)
37
- throw new Error(`Unexpected payload type ${n.payloadType}`);
38
- const a = 27 + n.targetIds.length * 4;
39
- let i = s.subarray(a, n.length);
40
- return (n.flags & Tt.Compressed) !== 0 && (i = await Rt(i)), i;
41
- }
42
- async function Rt(t) {
43
- if (typeof DecompressionStream > "u")
44
- throw new Error("DecompressionStream not supported");
45
- const e = new DecompressionStream("gzip"), r = e.writable.getWriter(), s = new Uint8Array(t);
46
- r.write(s), r.close();
47
- const n = e.readable.getReader(), a = [];
48
- let i = 0;
49
- for (; ; ) {
50
- const { done: o, value: l } = await n.read();
51
- if (o) break;
52
- a.push(l), i += l.length;
53
- }
54
- const E = new Uint8Array(i);
55
- let _ = 0;
56
- for (let o = 0; o < a.length; o++)
57
- E.set(a[o], _), _ += a[o].length;
58
- return E;
59
- }
60
- var O = /* @__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))(O || {});
61
- const Ct = 161, Nt = 162;
62
- new TextEncoder();
63
- const St = new TextDecoder("utf-8", { fatal: !0 });
64
- class F {
65
- constructor(e, r, s) {
66
- this.buffer = e, this.version = r, this.offset = s, this.end = e.length - 1;
67
- }
68
- offset;
69
- end;
70
- static create(e) {
71
- const r = M(e);
72
- if (r.length < 2)
73
- throw new Error("Teleport payload too short");
74
- if (r[0] !== Ct || r[r.length - 1] !== Nt)
75
- throw new Error("Teleport object missing markers");
76
- const s = { offset: 1 }, n = I(r, s, "InvalidLength");
77
- return new F(r, n, s.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 e = Dt(this.buffer, this.offset);
85
- this.offset += 4;
86
- const r = this.buffer[this.offset++], s = r >> 4 & 15;
87
- if ((r & 15) !== 0)
88
- throw new Error("Teleport field flags must be zero");
89
- const n = y(s);
90
- let a;
91
- if (n >= 0)
92
- h(this.buffer, this.offset, n), a = this.buffer.subarray(this.offset, this.offset + n), this.offset += n;
93
- else {
94
- const i = { offset: this.offset }, E = I(this.buffer, i, "InvalidLength");
95
- h(this.buffer, i.offset, E), a = this.buffer.subarray(i.offset, i.offset + E), this.offset = i.offset + E;
96
- }
97
- return new mt(e, s, a);
98
- }
99
- }
100
- class C {
101
- constructor(e, r) {
102
- this.type = e, this.payload = r;
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
- ), St.decode(this.payload);
163
- }
164
- asGuid() {
165
- return this.ensureType(
166
- 14
167
- /* Guid */
168
- ), u.fromBytes(this.payload);
169
- }
170
- asObject() {
171
- return this.ensureType(
172
- 11
173
- /* Object */
174
- ), F.create(this.payload);
175
- }
176
- asArray() {
177
- return this.ensureType(
178
- 9
179
- /* Array */
180
- ), x.create(this.payload);
181
- }
182
- asDictionary() {
183
- return this.ensureType(
184
- 10
185
- /* Dict */
186
- ), H.create(this.payload);
187
- }
188
- ensureType(e) {
189
- if (this.type !== e)
190
- throw new Error(`Teleport value has type ${O[this.type]}, expected ${O[e]}`);
191
- }
192
- }
193
- class mt extends C {
194
- constructor(e, r, s) {
195
- super(r, s), this.fieldId = e;
196
- }
197
- get isNull() {
198
- return this.type === 1;
199
- }
200
- }
201
- class x {
202
- payload;
203
- elementType;
204
- count;
205
- offset;
206
- index = 0;
207
- constructor(e) {
208
- if (this.payload = e, e.length === 0)
209
- throw new Error("Array payload too short");
210
- const r = e[0];
211
- if (this.elementType = r >> 4 & 15, (r & 15) !== 0)
212
- throw new Error("Array flags must be zero");
213
- const s = { offset: 1 };
214
- this.count = I(e, s, "ArrayMalformed"), this.offset = s.offset;
215
- }
216
- static create(e) {
217
- return new x(M(e));
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 e = this.readValue();
226
- return this.index++, e;
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 e = y(this.elementType);
239
- h(this.payload, this.offset, e);
240
- const r = this.payload.subarray(this.offset, this.offset + e);
241
- return this.offset += e, new w(this.elementType, r);
242
- }
243
- case 12:
244
- case 13: {
245
- const e = { offset: this.offset }, r = I(this.payload, e, "ArrayMalformed");
246
- h(this.payload, e.offset, r);
247
- const s = this.payload.subarray(e.offset, e.offset + r);
248
- return this.offset = e.offset + r, new w(this.elementType, s);
249
- }
250
- case 11: {
251
- const e = { offset: this.offset }, r = I(this.payload, e, "ArrayMalformed");
252
- h(this.payload, e.offset, r);
253
- const s = this.payload.subarray(e.offset, e.offset + r);
254
- return this.offset = e.offset + r, new w(11, s);
255
- }
256
- case 9: {
257
- const e = W(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
258
- return this.offset += e, new w(9, r);
259
- }
260
- case 10: {
261
- const e = K(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
262
- return this.offset += e, new w(10, r);
263
- }
264
- default:
265
- throw new Error(`Unsupported array element type ${O[this.elementType]}`);
266
- }
267
- }
268
- }
269
- class w extends C {
270
- constructor(e, r) {
271
- super(e, r);
272
- }
273
- }
274
- class H {
275
- payload;
276
- keyType;
277
- valueType;
278
- count;
279
- offset;
280
- index = 0;
281
- constructor(e) {
282
- if (this.payload = e, e.length < 2)
283
- throw new Error("Dictionary payload too short");
284
- if (this.keyType = e[0] >> 4 & 15, this.valueType = e[1] >> 4 & 15, (e[0] & 15) !== 0 || (e[1] & 15) !== 0)
285
- throw new Error("Dictionary key/value flags must be zero");
286
- st(this.keyType);
287
- const r = { offset: 2 };
288
- this.count = I(e, r, "DictMalformed"), this.offset = r.offset;
289
- }
290
- static create(e) {
291
- return new H(M(e));
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 e = this.readKey(), r = this.readValue();
300
- return this.index++, new Lt(e, r);
301
- }
302
- readKey() {
303
- const e = y(this.keyType);
304
- if (e >= 0) {
305
- h(this.payload, this.offset, e);
306
- const r = this.payload.subarray(this.offset, this.offset + e);
307
- return this.offset += e, new C(this.keyType, r);
308
- }
309
- if (this.keyType === 12 || this.keyType === 13) {
310
- const r = { offset: this.offset }, s = I(this.payload, r, "DictMalformed");
311
- h(this.payload, r.offset, s);
312
- const n = this.payload.subarray(r.offset, r.offset + s);
313
- return this.offset = r.offset + s, new C(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 e = { offset: this.offset }, r = I(this.payload, e, "DictMalformed");
322
- h(this.payload, e.offset, r);
323
- const s = this.payload.subarray(e.offset, e.offset + r);
324
- return this.offset = e.offset + r, new C(this.valueType, s);
325
- }
326
- case 11: {
327
- const e = { offset: this.offset }, r = I(this.payload, e, "DictMalformed");
328
- h(this.payload, e.offset, r);
329
- const s = this.payload.subarray(e.offset, e.offset + r);
330
- return this.offset = e.offset + r, new C(11, s);
331
- }
332
- case 9: {
333
- const e = W(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
334
- return this.offset += e, new C(9, r);
335
- }
336
- case 10: {
337
- const e = K(this.payload, this.offset), r = this.payload.subarray(this.offset, this.offset + e);
338
- return this.offset += e, new C(10, r);
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 e = y(this.valueType);
350
- h(this.payload, this.offset, e);
351
- const r = this.payload.subarray(this.offset, this.offset + e);
352
- return this.offset += e, new C(this.valueType, r);
353
- }
354
- default:
355
- throw new Error(`Unsupported dictionary value type ${O[this.valueType]}`);
356
- }
357
- }
358
- }
359
- class Lt {
360
- constructor(e, r) {
361
- this.key = e, this.value = r;
362
- }
363
- }
364
- class u {
365
- constructor(e) {
366
- this.bytes = e;
367
- }
368
- static fromString(e) {
369
- if (!e)
370
- throw new Error("Guid string is empty");
371
- const r = e.replace(/-/g, "");
372
- if (r.length !== 32)
373
- throw new Error("Guid string must be 32 hex characters");
374
- const s = new Uint8Array(16), n = u.parseHexSlice(r, 0, 8), a = u.parseHexSlice(r, 8, 4), i = u.parseHexSlice(r, 12, 4);
375
- u.writeUInt32LE(s, 0, n), u.writeUInt16LE(s, 4, a), u.writeUInt16LE(s, 6, i);
376
- for (let E = 0; E < 8; E++)
377
- s[8 + E] = u.parseHexSlice(r, 16 + E * 2, 2);
378
- return new u(s);
379
- }
380
- static fromBytes(e) {
381
- if (e.length !== 16)
382
- throw new Error("Guid byte array must be 16 bytes");
383
- return new u(Uint8Array.from(e));
384
- }
385
- static createZero() {
386
- return new u(new Uint8Array(16));
387
- }
388
- static createRandom() {
389
- const e = new Uint8Array(16), r = globalThis.crypto;
390
- if (r?.getRandomValues)
391
- r.getRandomValues(e);
392
- else
393
- for (let s = 0; s < e.length; s++)
394
- e[s] = Math.floor(Math.random() * 256);
395
- return e[6] = e[6] & 15 | 64, e[8] = e[8] & 63 | 128, new u(e);
396
- }
397
- toString() {
398
- const e = this.bytes;
399
- return [
400
- u.toHex(u.readUInt32LE(e, 0), 8),
401
- u.toHex(u.readUInt16LE(e, 4), 4),
402
- u.toHex(u.readUInt16LE(e, 6), 4),
403
- j(e.subarray(8, 10)),
404
- j(e.subarray(10, 16))
405
- ].join("-");
406
- }
407
- asBytes() {
408
- return this.bytes.slice();
409
- }
410
- static parseHexSlice(e, r, s) {
411
- const n = e.substr(r, s), a = Number.parseInt(n, 16);
412
- if (Number.isNaN(a))
413
- throw new Error("Guid string contains invalid characters");
414
- return a >>> 0;
415
- }
416
- static writeUInt32LE(e, r, s) {
417
- const n = s >>> 0;
418
- e[r] = n & 255, e[r + 1] = n >>> 8 & 255, e[r + 2] = n >>> 16 & 255, e[r + 3] = n >>> 24 & 255;
419
- }
420
- static writeUInt16LE(e, r, s) {
421
- const n = s & 65535;
422
- e[r] = n & 255, e[r + 1] = n >>> 8 & 255;
423
- }
424
- static readUInt32LE(e, r) {
425
- return (e[r] | e[r + 1] << 8 | e[r + 2] << 16 | e[r + 3] << 24) >>> 0;
426
- }
427
- static readUInt16LE(e, r) {
428
- return (e[r] | e[r + 1] << 8) & 65535;
429
- }
430
- static toHex(e, r) {
431
- return (e >>> 0).toString(16).padStart(r, "0");
432
- }
433
- }
434
- function I(t, e, r) {
435
- if (e.offset >= t.length)
436
- throw new Error(r);
437
- let s = 0, n = 0, a = 0;
438
- for (; e.offset < t.length; ) {
439
- const i = t[e.offset++];
440
- if (a++, s |= (i & 127) << n, (i & 128) === 0) {
441
- if (a !== Ut(s))
442
- throw new Error("Teleport VarUInt is not canonical");
443
- return s >>> 0;
444
- }
445
- if (n += 7, n >= 35)
446
- throw new Error("Teleport VarUInt exceeds 32-bit range");
447
- }
448
- throw new Error(r);
449
- }
450
- function Ut(t) {
451
- return t < 128 ? 1 : t < 16384 ? 2 : t < 2097152 ? 3 : t < 268435456 ? 4 : 5;
452
- }
453
- function y(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 st(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 h(t, e, r) {
478
- if (e < 0 || r < 0 || e + r > t.length)
479
- throw new Error("Teleport payload exceeds bounds");
480
- }
481
- function Dt(t, e) {
482
- return (t[e] | t[e + 1] << 8 | t[e + 2] << 16 | t[e + 3] << 24) >>> 0;
483
- }
484
- function W(t, e) {
485
- if (e >= t.length)
486
- throw new Error("Array payload exceeds bounds");
487
- const r = t[e], s = r >> 4 & 15;
488
- if ((r & 15) !== 0)
489
- throw new Error("Array flags must be zero");
490
- const n = { offset: e + 1 }, a = I(t, n, "ArrayMalformed"), i = y(s);
491
- if (i >= 0) {
492
- const _ = i * a;
493
- return h(t, n.offset, _), n.offset + _ - e;
494
- }
495
- let E = n.offset;
496
- for (let _ = 0; _ < a; _++)
497
- E = Y(s, t, E, "ArrayMalformed");
498
- return E - e;
499
- }
500
- function K(t, e) {
501
- if (e + 2 > t.length)
502
- throw new Error("Dictionary payload too short");
503
- const r = t[e] >> 4 & 15, s = t[e + 1] >> 4 & 15;
504
- if ((t[e] & 15) !== 0 || (t[e + 1] & 15) !== 0)
505
- throw new Error("Dictionary key/value flags must be zero");
506
- st(r);
507
- const n = { offset: e + 2 }, a = I(t, n, "DictMalformed");
508
- let i = n.offset;
509
- for (let E = 0; E < a; E++)
510
- i = Y(r, t, i, "DictMalformed"), i = Y(s, t, i, "DictMalformed");
511
- return i - e;
512
- }
513
- function Y(t, e, r, s) {
514
- const n = y(t);
515
- if (n >= 0)
516
- return h(e, r, n), r + n;
517
- switch (t) {
518
- case 12:
519
- case 13: {
520
- const a = { offset: r }, i = I(e, a, s);
521
- return h(e, a.offset, i), a.offset + i;
522
- }
523
- case 11: {
524
- const a = { offset: r }, i = I(e, a, s);
525
- return h(e, a.offset, i), a.offset + i;
526
- }
527
- case 9:
528
- return r + W(e, r);
529
- case 10:
530
- return r + K(e, r);
531
- default:
532
- throw new Error(`Unsupported Teleport type ${O[t]}`);
533
- }
534
- }
535
- function j(t) {
536
- return Array.from(t).map((e) => e.toString(16).padStart(2, "0")).join("");
537
- }
538
- function M(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 || {}), V = /* @__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_RESET_IDLE = 65560] = "CORE_RESET_IDLE", t[t.CORE_CLIENT_DISCONNECTING = 65561] = "CORE_CLIENT_DISCONNECTING", t[t.CORE_ON_APP_READY = 65562] = "CORE_ON_APP_READY", t[t.CORE_ON_FRONTEND_RELOADED = 65563] = "CORE_ON_FRONTEND_RELOADED", 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.CORE_WEBRTC_VIDEO_CAPTURE = 65572] = "CORE_WEBRTC_VIDEO_CAPTURE", t[t.CORE_WEBRTC_ICE_SERVERS_REQUEST = 65573] = "CORE_WEBRTC_ICE_SERVERS_REQUEST", t[t.CORE_WEBRTC_ICE_SERVERS_RESPONSE = 65574] = "CORE_WEBRTC_ICE_SERVERS_RESPONSE", t[t.CORE_WEBRTC_CLOSE = 65575] = "CORE_WEBRTC_CLOSE", t[t.CORE_RELAY_AGENT_AUTH = 65576] = "CORE_RELAY_AGENT_AUTH", t[t.CORE_RELAY_AGENT_AUTH_RESULT = 65577] = "CORE_RELAY_AGENT_AUTH_RESULT", t[t.CORE_RELAY_HEARTBEAT = 65578] = "CORE_RELAY_HEARTBEAT", t[t.CORE_RELAY_TCP_CONNECTION_OPENED = 65579] = "CORE_RELAY_TCP_CONNECTION_OPENED", t[t.CORE_RELAY_TCP_CONNECTION_CLOSED = 65580] = "CORE_RELAY_TCP_CONNECTION_CLOSED", t[t.CORE_RELAY_TCP_DATA = 65581] = "CORE_RELAY_TCP_DATA", t[t.CORE_RELAY_UDP_DATA = 65582] = "CORE_RELAY_UDP_DATA", t[t.CORE_RELAY_ADD_TUNNEL = 65583] = "CORE_RELAY_ADD_TUNNEL", t[t.CORE_RELAY_TUNNEL_ADDED = 65584] = "CORE_RELAY_TUNNEL_ADDED", t[t.CORE_RELAY_REMOVE_TUNNEL = 65585] = "CORE_RELAY_REMOVE_TUNNEL", t[t.CORE_IKON_SERVER_ENDPOINT_HOST_INFO = 65586] = "CORE_IKON_SERVER_ENDPOINT_HOST_INFO", t[t.CORE_CLIENT_INITIALIZATION = 65587] = "CORE_CLIENT_INITIALIZATION", t[t.CORE_CLIENT_LIFECYCLE_BATCH = 65588] = "CORE_CLIENT_LIFECYCLE_BATCH", t[t.CORE_APP_CONFIG = 65589] = "CORE_APP_CONFIG", 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.ANALYTICS_IKON_RELAY_SERVER_STATS = 524297] = "ANALYTICS_IKON_RELAY_SERVER_STATS", t[t.ANALYTICS_IKON_TURN_SERVER_STATS = 524298] = "ANALYTICS_IKON_TURN_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_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_SPEECH_RECOGNIZED = 1048615] = "ACTION_SPEECH_RECOGNIZED", t[t.ACTION_CALL_RESULT = 1048616] = "ACTION_CALL_RESULT", t[t.ACTION_DOWNLOAD = 1048618] = "ACTION_DOWNLOAD", t[t.ACTION_PLAY_SOUND = 1048621] = "ACTION_PLAY_SOUND", 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_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.ACTION_CALL_ACK = 1048652] = "ACTION_CALL_ACK", t[t.ACTION_TRIGGER_CRON = 1048653] = "ACTION_TRIGGER_CRON", t[t.ACTION_RESULT = 1048654] = "ACTION_RESULT", t[t.UI_RESYNC_REQUEST = 1048655] = "UI_RESYNC_REQUEST", 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_STYLES = 2097188] = "UI_STYLES", t[t.UI_UPDATE = 2097190] = "UI_UPDATE", 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.AUDIO_SHAPE_FRAME = 4194310] = "AUDIO_SHAPE_FRAME", 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.GROUP_APP_LOCAL = 1073741824] = "GROUP_APP_LOCAL", t[t.CONSTANT_GROUP_MASK = 2147418112] = "CONSTANT_GROUP_MASK", t))(V || {});
542
- const Ot = 4194309, yt = 205938238, dt = 1594075008, Pt = 2026534360, wt = 3409001585, gt = 3466650495, Ft = 4007456593, Mt = 4017217601, bt = 4065417427, Bt = 4086360332;
543
- function Gt(t) {
544
- const e = {};
545
- return nt(e), e;
546
- }
547
- function nt(t) {
548
- return t.Samples = new Uint8Array(0), t.Epoch = 0, t.Sequence = 0, t.FrameSizeInInterleavedSamples = 0, t.TimeStampInInterleavedSamples = 0n, t.IsFirst = !1, t.IsLast = !1, t.AverageVolume = 0, t.AudioEventEstimatedDuration = 0, t;
549
- }
550
- function Vt(t, e) {
551
- const r = F.create(t);
552
- return vt(r, e);
553
- }
554
- function vt(t, e) {
555
- const r = e ?? Gt();
556
- return nt(r), kt(t, r), r;
557
- }
558
- function kt(t, e) {
559
- let r;
560
- for (; (r = t.next()) !== null; )
561
- switch (r.fieldId) {
562
- case yt: {
563
- if (r.isNull) throw new Error();
564
- e.AverageVolume = r.asFloat32();
565
- break;
566
- }
567
- case dt: {
568
- if (r.isNull) throw new Error();
569
- e.IsFirst = r.asBool();
570
- break;
571
- }
572
- case Pt: {
573
- if (r.isNull) throw new Error();
574
- e.TimeStampInInterleavedSamples = r.asUInt64();
575
- break;
576
- }
577
- case wt: {
578
- if (r.isNull) throw new Error();
579
- e.Samples = r.asBinary();
580
- break;
581
- }
582
- case gt: {
583
- if (r.isNull) throw new Error();
584
- e.AudioEventEstimatedDuration = r.asFloat32();
585
- break;
586
- }
587
- case Ft: {
588
- if (r.isNull) throw new Error();
589
- e.FrameSizeInInterleavedSamples = r.asUInt32();
590
- break;
591
- }
592
- case Mt: {
593
- if (r.isNull) throw new Error();
594
- e.IsLast = r.asBool();
595
- break;
596
- }
597
- case bt: {
598
- if (r.isNull) throw new Error();
599
- e.Sequence = r.asUInt32();
600
- break;
601
- }
602
- case Bt: {
603
- if (r.isNull) throw new Error();
604
- e.Epoch = r.asUInt32();
605
- break;
606
- }
607
- }
608
- }
609
- async function pt(t, e) {
610
- const r = await rt(t, Ot);
611
- return Vt(r, e);
612
- }
613
- const Yt = 4194305, xt = 161083277, Ht = 265814330, Wt = 1368629611, Kt = 2431514951, zt = 2514959030, Xt = 2745379226, $t = 3282782683, jt = 3284746250, Qt = 4101844078;
614
- function Zt(t) {
615
- const e = {};
616
- return it(e), e;
617
- }
618
- function it(t) {
619
- return t.StreamId = "", t.Description = "", t.SourceType = "", t.Codec = T.Unknown, t.CodecDetails = "", t.SampleRate = 0, t.Channels = 0, t.ShapeSets = void 0, t.CorrelationId = void 0, t;
620
- }
621
- function Jt(t, e) {
622
- const r = F.create(t);
623
- return qt(r, e);
624
- }
625
- function qt(t, e) {
626
- const r = e ?? Zt();
627
- return it(r), te(t, r), r;
628
- }
629
- function te(t, e) {
630
- let r;
631
- for (; (r = t.next()) !== null; )
632
- switch (r.fieldId) {
633
- case xt: {
634
- if (r.isNull) throw new Error();
635
- e.StreamId = r.asString();
636
- break;
637
- }
638
- case Ht: {
639
- if (r.isNull) {
640
- e.ShapeSets = void 0;
641
- break;
642
- }
643
- e.ShapeSets = re(r.asArray());
644
- break;
645
- }
646
- case Wt: {
647
- if (r.isNull) throw new Error();
648
- e.Description = r.asString();
649
- break;
650
- }
651
- case Kt: {
652
- if (r.isNull) throw new Error();
653
- e.Channels = r.asInt32();
654
- break;
655
- }
656
- case zt: {
657
- if (r.isNull) {
658
- e.CorrelationId = void 0;
659
- break;
660
- }
661
- e.CorrelationId = r.asString();
662
- break;
663
- }
664
- case Xt: {
665
- if (r.isNull) throw new Error();
666
- e.CodecDetails = r.asString();
667
- break;
668
- }
669
- case $t: {
670
- if (r.isNull) throw new Error();
671
- e.SourceType = r.asString();
672
- break;
673
- }
674
- case jt: {
675
- if (r.isNull) throw new Error();
676
- e.Codec = r.asInt32();
677
- break;
678
- }
679
- case Qt: {
680
- if (r.isNull) throw new Error();
681
- e.SampleRate = r.asInt32();
682
- break;
683
- }
684
- }
685
- }
686
- async function ee(t, e) {
687
- const r = await rt(t, Yt);
688
- return Jt(r, e);
689
- }
690
- function re(t) {
691
- const e = [];
692
- let r;
693
- for (; (r = t.next()) !== null; )
694
- e.push(Ee(r.asObject()));
695
- return e;
696
- }
697
- const se = 1107713536, ne = 1154362099, ie = 1185721362;
698
- function ae(t) {
699
- const e = {};
700
- return at(e), e;
701
- }
702
- function at(t) {
703
- return t.SetId = 0, t.Name = "", t.ShapeNames = [], t;
704
- }
705
- function Ee(t, e) {
706
- const r = e ?? ae();
707
- return at(r), _e(t, r), r;
708
- }
709
- function _e(t, e) {
710
- let r;
711
- for (; (r = t.next()) !== null; )
712
- switch (r.fieldId) {
713
- case se: {
714
- if (r.isNull) throw new Error();
715
- e.Name = r.asString();
716
- break;
717
- }
718
- case ne: {
719
- if (r.isNull) throw new Error();
720
- e.SetId = r.asUInt32();
721
- break;
722
- }
723
- case ie: {
724
- if (r.isNull) throw new Error();
725
- e.ShapeNames = oe(r.asArray());
726
- break;
727
- }
728
- }
729
- }
730
- function oe(t) {
731
- const e = [];
732
- let r;
733
- for (; (r = t.next()) !== null; )
734
- e.push(r.asString());
735
- return e;
736
- }
737
- class Q {
738
- static getStorageForCapacity(e, r) {
739
- const s = Int32Array.BYTES_PER_ELEMENT * 2, n = r.BYTES_PER_ELEMENT * e;
740
- return new SharedArrayBuffer(s + n);
741
- }
742
- readWrite;
743
- storage;
744
- buf;
745
- constructor(e, r) {
746
- this.buf = e, this.readWrite = new Int32Array(e, 0, 2);
747
- const s = Int32Array.BYTES_PER_ELEMENT * 2, n = (e.byteLength - s) / Float32Array.BYTES_PER_ELEMENT;
748
- this.storage = new r(e, s, n);
749
- }
750
- get capacity() {
751
- return this.storage.length;
752
- }
753
- flush() {
754
- Atomics.store(this.readWrite, 0, 0), Atomics.store(this.readWrite, 1, 0);
755
- }
756
- availableRead() {
757
- const e = Atomics.load(this.readWrite, 0), r = Atomics.load(this.readWrite, 1);
758
- return r >= e ? r - e : this.capacity - (e - r);
759
- }
760
- availableWrite() {
761
- return this.capacity - this.availableRead() - 1;
762
- }
763
- push(e) {
764
- const r = Math.min(this.availableWrite(), e.length);
765
- if (r <= 0)
766
- return 0;
767
- let s = Atomics.load(this.readWrite, 1);
768
- const n = Math.min(r, this.capacity - s);
769
- this.storage.set(e.subarray(0, n), s);
770
- const a = r - n;
771
- return a > 0 && this.storage.set(e.subarray(n, n + a), 0), s = (s + r) % this.capacity, Atomics.store(this.readWrite, 1, s), Atomics.notify(this.readWrite, 1), r;
772
- }
773
- pop(e) {
774
- const r = Math.min(this.availableRead(), e.length);
775
- if (r <= 0)
776
- return 0;
777
- let s = Atomics.load(this.readWrite, 0);
778
- const n = Math.min(r, this.capacity - s);
779
- e.set(this.storage.subarray(s, s + n), 0);
780
- const a = r - n;
781
- return a > 0 && e.set(this.storage.subarray(0, a), n), s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
782
- }
783
- skip(e) {
784
- const r = Math.min(this.availableRead(), e);
785
- if (r <= 0)
786
- return 0;
787
- let s = Atomics.load(this.readWrite, 0);
788
- return s = (s + r) % this.capacity, Atomics.store(this.readWrite, 0, s), r;
789
- }
790
- }
791
- let le = 1;
792
- const Ae = /* @__PURE__ */ new Map(), ue = {
793
- 0: "DEBUG",
794
- 1: "INFO",
795
- 2: "WARN",
796
- 3: "ERROR",
797
- 4: "NONE"
798
- };
799
- function fe(t, e) {
800
- return `[${t}] ${e}`;
801
- }
802
- function B(t, e, r, s) {
803
- const n = (/* @__PURE__ */ new Date()).toISOString(), a = ue[t], i = {
804
- timestamp: n,
805
- level: t,
806
- levelName: a,
807
- component: e,
808
- message: r,
809
- args: s
810
- };
811
- for (const [E, _] of Ae) {
812
- const o = _?.minLevel ?? 2;
813
- if (t >= o)
814
- try {
815
- E(i);
816
- } catch {
817
- }
818
- }
819
- if (le <= t) {
820
- const E = fe(e, r);
821
- switch (t) {
822
- case 0:
823
- console.debug(E, ...s);
824
- break;
825
- case 1:
826
- console.info(E, ...s);
827
- break;
828
- case 2:
829
- console.warn(E, ...s);
830
- break;
831
- case 3:
832
- console.error(E, ...s);
833
- break;
834
- }
835
- }
836
- }
837
- function Et(t) {
838
- return {
839
- debug(e, ...r) {
840
- B(0, t, e, r);
841
- },
842
- info(e, ...r) {
843
- B(1, t, e, r);
844
- },
845
- warn(e, ...r) {
846
- B(2, t, e, r);
847
- },
848
- error(e, ...r) {
849
- B(3, t, e, r);
850
- }
851
- };
852
- }
853
- const G = Et("Capabilities"), he = globalThis;
854
- function Ie() {
855
- if (typeof SharedArrayBuffer > "u")
856
- return G.debug("SharedArrayBuffer not supported: SharedArrayBuffer is undefined"), !1;
857
- if (typeof Atomics > "u")
858
- return G.debug("SharedArrayBuffer not supported: Atomics is undefined"), !1;
859
- if (he.crossOriginIsolated === !1)
860
- return G.debug("SharedArrayBuffer not supported: crossOriginIsolated is false (missing COOP/COEP headers)"), !1;
861
- try {
862
- new SharedArrayBuffer(1);
863
- } catch (t) {
864
- return G.debug(`SharedArrayBuffer not supported: construction failed - ${t instanceof Error ? t.message : String(t)}`), !1;
865
- }
866
- return !0;
867
- }
868
- const _t = 48e3, ot = 2, Te = 1500, ce = 10, Z = 80, Re = 50, J = 64, z = Et("AudioPlaybackWorker"), d = (t, e) => {
869
- self.postMessage(t, e ?? []);
870
- }, Ce = Ie();
871
- let v = "pcm", lt = !0, At = !1, N = _t, S = ot, D = null;
872
- function U(t, e) {
873
- const r = t instanceof Error ? t : new Error(String(t));
874
- d({ type: "error", error: { name: r.name, message: r.message, stack: r.stack }, streamId: e });
875
- }
876
- function X(t) {
877
- const e = et(t);
878
- return `${e.senderId}_${e.trackId}`;
879
- }
880
- class Ne {
881
- mode;
882
- ring = null;
883
- sab = void 0;
884
- streamId;
885
- outputSampleRate;
886
- outputChannels;
887
- closed = !1;
888
- // Pre-allocated batch buffer for PCM mode to avoid per-frame allocations
889
- pcmBatchBuffer = null;
890
- pcmBatchOffset = 0;
891
- lastPcmFlushTimeMs = 0;
892
- constructor(e) {
893
- this.streamId = e, this.mode = "pcm", this.outputSampleRate = N, this.outputChannels = S, this.rebind(v);
894
- }
895
- close() {
896
- this.closed = !0, this.pcmBatchBuffer = null, this.pcmBatchOffset = 0, this.ring = null, this.sab = void 0;
897
- }
898
- setOutputFormat(e, r) {
899
- this.outputSampleRate = e, this.outputChannels = r;
900
- }
901
- rebind(e) {
902
- if (!this.closed) {
903
- if (this.mode = e, e === "sab" && Ce) {
904
- const r = Math.floor(Te * this.outputSampleRate * this.outputChannels / 1e3), s = Q.getStorageForCapacity(r, Float32Array), n = new Q(s, Float32Array);
905
- n.flush(), this.sab = s, this.ring = n;
906
- return;
907
- }
908
- this.sab = void 0, this.ring = null;
909
- }
910
- }
911
- flushPendingPcm(e) {
912
- if (this.closed || this.mode !== "pcm" || this.pcmBatchOffset <= 0)
913
- return;
914
- const r = performance.now(), s = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * Z / 1e3));
915
- if (!(e || this.pcmBatchOffset >= s || this.lastPcmFlushTimeMs > 0 && r - this.lastPcmFlushTimeMs >= Re))
916
- return;
917
- const a = new Float32Array(this.pcmBatchOffset);
918
- a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = r, d({ type: "pcm", streamId: this.streamId, pcm: a }, [a.buffer]);
919
- }
920
- drainPcm() {
921
- this.flushPendingPcm(!0);
922
- }
923
- writePcm(e) {
924
- if (this.closed)
925
- return;
926
- if (this.mode === "sab" && this.ring) {
927
- const n = this.ring, a = this.outputChannels;
928
- let i = e;
929
- const E = Math.floor(Math.max(0, n.capacity - 1) / a) * a;
930
- i.length > E && (i = i.subarray(i.length - E));
931
- const _ = Math.floor(n.availableWrite() / a) * a;
932
- if (_ <= 0)
933
- return;
934
- i.length > _ && (i = i.subarray(i.length - _)), n.push(i);
935
- return;
936
- }
937
- const r = Math.max(1, Math.round(this.outputSampleRate * this.outputChannels * Z / 1e3)), s = this.pcmBatchOffset + e.length;
938
- if (!this.pcmBatchBuffer || this.pcmBatchBuffer.length < s) {
939
- const n = Math.max(s, r * 2), a = new Float32Array(n);
940
- this.pcmBatchBuffer && this.pcmBatchOffset > 0 && a.set(this.pcmBatchBuffer.subarray(0, this.pcmBatchOffset)), this.pcmBatchBuffer = a;
941
- }
942
- this.pcmBatchBuffer.set(e, this.pcmBatchOffset), this.pcmBatchOffset += e.length, this.lastPcmFlushTimeMs === 0 && (this.lastPcmFlushTimeMs = performance.now()), this.flushPendingPcm(!1);
943
- }
944
- getSharedArrayBuffer() {
945
- return this.sab;
946
- }
947
- flush() {
948
- this.closed || (this.pcmBatchOffset = 0, this.lastPcmFlushTimeMs = 0, this.ring?.flush());
949
- }
950
- }
951
- function Se(t) {
952
- switch (t) {
953
- case T.Opus:
954
- return "opus";
955
- case T.Mp3:
956
- return "mp3";
957
- default:
958
- return null;
959
- }
960
- }
961
- let g = null;
962
- function me(t) {
963
- const e = new DataView(t.buffer, t.byteOffset, t.byteLength), r = Math.floor(t.byteLength / 2);
964
- (!g || g.length < r) && (g = new Float32Array(r));
965
- for (let s = 0; s < r; s++)
966
- g[s] = e.getInt16(s * 2, !0) / 32768;
967
- return g.subarray(0, r);
968
- }
969
- class $ {
970
- inputSampleRate;
971
- inputChannels;
972
- sink;
973
- // Pre-allocated grow-only buffers for conversion pipeline
974
- _resampleBuffer = null;
975
- _remixBuffer = null;
976
- _interleavedBuffer = null;
977
- constructor(e) {
978
- this.inputSampleRate = e.inputSampleRate, this.inputChannels = e.inputChannels, this.sink = e.sink;
979
- }
980
- getResampleBuffer(e) {
981
- return (!this._resampleBuffer || this._resampleBuffer.length < e) && (this._resampleBuffer = new Float32Array(e)), this._resampleBuffer;
982
- }
983
- getRemixBuffer(e) {
984
- return (!this._remixBuffer || this._remixBuffer.length < e) && (this._remixBuffer = new Float32Array(e)), this._remixBuffer;
985
- }
986
- getInterleavedBuffer(e) {
987
- return (!this._interleavedBuffer || this._interleavedBuffer.length < e) && (this._interleavedBuffer = new Float32Array(e)), this._interleavedBuffer;
988
- }
989
- reset() {
990
- }
991
- writeConvertedPcm(e, r, s) {
992
- const n = this.convertPcmBuffer(e, r, s);
993
- n.length > 0 && this.sink.writePcm(n);
994
- }
995
- convertAudioData(e) {
996
- const r = e.numberOfFrames, s = e.numberOfChannels, n = e.format, a = typeof n == "string" && n.includes("planar"), i = "f32-planar", E = "f32", _ = () => {
997
- const A = new Array(s);
998
- for (let f = 0; f < s; f++) {
999
- const R = new Float32Array(r);
1000
- e.copyTo(R, { planeIndex: f, format: i }), A[f] = R;
1001
- }
1002
- return be(A, r);
1003
- }, o = () => {
1004
- const A = new Float32Array(r * s);
1005
- return e.copyTo(A, { planeIndex: 0, format: E }), A;
1006
- };
1007
- let l;
1008
- if (a)
1009
- try {
1010
- l = _();
1011
- } catch (A) {
1012
- z.debug(`Failed to read planar audio data, falling back to interleaved copy: ${A}`), l = o();
1013
- }
1014
- else
1015
- l = o();
1016
- return l;
1017
- }
1018
- convertPcmBuffer(e, r, s) {
1019
- if (e.length === 0)
1020
- return e;
1021
- let n = e, a = e.length;
1022
- const i = r;
1023
- if (s !== N) {
1024
- const E = a / i, o = Math.max(1, Math.round(E * N / s)) * i, l = this.getResampleBuffer(o);
1025
- a = Ge(n, l, i, s, N), n = l;
1026
- }
1027
- if (i !== S) {
1028
- const _ = a / i * S, o = this.getRemixBuffer(_);
1029
- a = Ve(n.subarray(0, a), o, i, S), n = o;
1030
- }
1031
- return n.subarray(0, a);
1032
- }
1033
- }
1034
- class Le extends $ {
1035
- feedChunk(e) {
1036
- e.isFirst && this.reset();
1037
- const r = me(e.data);
1038
- this.writeConvertedPcm(r, this.inputChannels, this.inputSampleRate), e.isLast && this.reset();
1039
- }
1040
- close() {
1041
- }
1042
- }
1043
- class Ue extends $ {
1044
- decoder;
1045
- codec;
1046
- constructor(e) {
1047
- super({ inputChannels: e.inputChannels, inputSampleRate: e.inputSampleRate, sink: e.sink }), this.codec = e.codec, this.decoder = new AudioDecoder({
1048
- output: (r) => {
1049
- try {
1050
- const s = this.convertAudioData(r);
1051
- this.writeConvertedPcm(s, r.numberOfChannels, r.sampleRate);
1052
- } catch (s) {
1053
- U(s);
1054
- } finally {
1055
- try {
1056
- r.close();
1057
- } catch {
1058
- }
1059
- }
1060
- },
1061
- error: (r) => {
1062
- U(r);
1063
- }
1064
- }), this.decoder.configure({ codec: e.codec, numberOfChannels: e.inputChannels, sampleRate: e.inputSampleRate });
1065
- }
1066
- feedChunk(e) {
1067
- try {
1068
- if (e.isFirst && this.reset(), this.decoder.state !== "configured")
1069
- return;
1070
- this.decoder.decode(
1071
- new EncodedAudioChunk({
1072
- type: "key",
1073
- timestamp: e.timestampUs,
1074
- duration: e.durationUs,
1075
- data: e.data
1076
- })
1077
- ), e.isLast && this.decoder.flush().catch(() => {
1078
- });
1079
- } catch (r) {
1080
- U(r);
1081
- try {
1082
- this.reset();
1083
- } catch {
1084
- }
1085
- }
1086
- }
1087
- reset() {
1088
- super.reset();
1089
- try {
1090
- this.decoder.reset(), this.decoder.configure({ codec: this.codec, numberOfChannels: this.inputChannels, sampleRate: this.inputSampleRate });
1091
- } catch (e) {
1092
- U(e);
1093
- }
1094
- }
1095
- close() {
1096
- try {
1097
- this.decoder.close();
1098
- } catch {
1099
- }
1100
- }
1101
- }
1102
- class De extends $ {
1103
- decoder = null;
1104
- isReady = !1;
1105
- decoderSampleRate = 48e3;
1106
- pendingChunks = [];
1107
- async initialise(e, r) {
1108
- const { OpusDecoder: s, getOpusModule: n } = await import("./index-Ca9sTcGt.js");
1109
- await n();
1110
- const i = [8e3, 12e3, 16e3, 24e3, 48e3].reduce((E, _) => Math.abs(_ - r) < Math.abs(E - r) ? _ : E);
1111
- this.decoderSampleRate = i, this.decoder = new s({ channels: e, sampleRate: this.decoderSampleRate }), await this.decoder.ready, this.isReady = !0, this.flushPendingChunks();
1112
- }
1113
- flushPendingChunks() {
1114
- if (!this.isReady || !this.decoder) {
1115
- this.pendingChunks.length = 0;
1116
- return;
1117
- }
1118
- const e = this.pendingChunks, r = e.length;
1119
- if (r !== 0) {
1120
- for (let s = 0; s < r; s++)
1121
- this.decodeChunk(e[s]);
1122
- e.length = 0;
1123
- }
1124
- }
1125
- reset() {
1126
- super.reset();
1127
- try {
1128
- this.decoder?.reset();
1129
- } catch {
1130
- }
1131
- }
1132
- decodeChunk(e) {
1133
- if (!(!this.isReady || !this.decoder))
1134
- try {
1135
- if (e.data.byteLength === 0)
1136
- return;
1137
- const s = this.decoder.decodeFrame(e.data), n = s.channelData, a = s.samplesDecoded, i = n.length;
1138
- if (!i || !a)
1139
- return;
1140
- const E = a * i, _ = this.getInterleavedBuffer(E);
1141
- if (i === 2) {
1142
- const o = n[0], l = n[1];
1143
- for (let A = 0, f = 0; A < a; A++)
1144
- _[f++] = o[A], _[f++] = l[A];
1145
- } else if (i === 1)
1146
- _.set(n[0].subarray(0, a));
1147
- else {
1148
- let o = 0;
1149
- for (let l = 0; l < a; l++)
1150
- for (let A = 0; A < i; A++)
1151
- _[o++] = n[A][l];
1152
- }
1153
- this.writeConvertedPcm(_.subarray(0, E), i, this.decoderSampleRate), e.isLast && this.reset();
1154
- } catch (r) {
1155
- U(r), this.reset();
1156
- }
1157
- }
1158
- feedChunk(e) {
1159
- if (!this.isReady || !this.decoder) {
1160
- this.pendingChunks.push(e);
1161
- return;
1162
- }
1163
- e.isFirst && this.reset(), this.decodeChunk(e);
1164
- }
1165
- close() {
1166
- try {
1167
- this.decoder?.destroy();
1168
- } catch {
1169
- }
1170
- this.decoder = null, this.pendingChunks.length = 0;
1171
- }
1172
- }
1173
- const c = /* @__PURE__ */ new Map();
1174
- async function Oe(t) {
1175
- if (t.closed || t.decoder)
1176
- return;
1177
- if (t.codec === T.RawPcm16) {
1178
- t.decoder = new Le({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1179
- return;
1180
- }
1181
- if (t.codec !== T.Opus && t.codec !== T.Mp3)
1182
- throw new Error(`Unsupported audio codec: ${T[t.codec] ?? t.codec}`);
1183
- const e = Se(t.codec);
1184
- if (lt && typeof AudioDecoder < "u" && e !== null)
1185
- try {
1186
- if ((await AudioDecoder.isConfigSupported({ codec: e, numberOfChannels: t.inputChannels, sampleRate: t.inputSampleRate })).supported) {
1187
- const n = new Ue({
1188
- codec: e,
1189
- inputChannels: t.inputChannels,
1190
- inputSampleRate: t.inputSampleRate,
1191
- sink: t.sink
1192
- });
1193
- if (t.closed) {
1194
- n.close();
1195
- return;
1196
- }
1197
- t.decoder = n;
1198
- return;
1199
- }
1200
- } catch (s) {
1201
- z.warn(`WebCodecs AudioDecoder failed, falling back to WASM: ${s instanceof Error ? s.message : String(s)}`);
1202
- }
1203
- if (t.codec === T.Opus) {
1204
- const s = new De({ inputChannels: t.inputChannels, inputSampleRate: t.inputSampleRate, sink: t.sink });
1205
- if (await s.initialise(t.inputChannels, t.inputSampleRate), t.closed) {
1206
- s.close();
1207
- return;
1208
- }
1209
- t.decoder = s;
1210
- return;
1211
- }
1212
- throw new Error(`No available decoder for codec: ${T[t.codec] ?? t.codec}`);
1213
- }
1214
- function ye(t) {
1215
- if (t.closed) {
1216
- t.pendingFrames.splice(0);
1217
- try {
1218
- t.decoder?.close();
1219
- } catch {
1220
- }
1221
- t.decoder = null;
1222
- return;
1223
- }
1224
- if (!t.decoder)
1225
- return;
1226
- const e = t.pendingFrames.splice(0);
1227
- for (const r of e)
1228
- ut(t, r);
1229
- }
1230
- function ut(t, e) {
1231
- if (t.closed || !t.decoder)
1232
- return;
1233
- const r = e.Epoch, s = Number(e.TimeStampInInterleavedSamples), n = e.FrameSizeInInterleavedSamples;
1234
- if (t.currentEpoch !== r && (t.currentEpoch = r, t.epochSet = !1, t.lastArrivalTimeMs = 0, t.jitterMs = 0, t.sink.flush(), t.decoder.reset()), !t.epochSet) {
1235
- t.epochSet = !0;
1236
- const f = t.inputSampleRate * t.inputChannels;
1237
- t.expectedIntervalMs = n * 1e3 / f;
1238
- }
1239
- const a = performance.now();
1240
- if (t.lastArrivalTimeMs > 0) {
1241
- const f = a - t.lastArrivalTimeMs, R = Math.abs(f - t.expectedIntervalMs);
1242
- t.jitterMs = t.jitterMs + (R - t.jitterMs) / ce;
1243
- }
1244
- t.lastArrivalTimeMs = a;
1245
- const i = t.inputSampleRate * t.inputChannels, E = N * S, _ = Math.round(s * E / i), o = Math.round(n * E / i), l = Math.round(s * 1e6 / i), A = Math.round(n * 1e6 / i);
1246
- d({
1247
- type: "frame",
1248
- streamId: t.streamId,
1249
- epoch: r,
1250
- timestampInterleavedSamples: _,
1251
- frameSizeInterleavedSamples: o,
1252
- isFirst: e.IsFirst,
1253
- isLast: e.IsLast,
1254
- jitterMs: t.jitterMs
1255
- }), t.decoder.feedChunk({
1256
- data: e.Samples,
1257
- isFirst: e.IsFirst,
1258
- isLast: e.IsLast,
1259
- timestampUs: l,
1260
- durationUs: A
1261
- });
1262
- }
1263
- async function de(t) {
1264
- const e = X(t), r = await ee(t), s = c.get(e);
1265
- if (s) {
1266
- s.closed = !0, s.pendingFrames.splice(0);
1267
- try {
1268
- s.decoder?.close();
1269
- } catch {
1270
- }
1271
- try {
1272
- s.sink.drainPcm(), s.sink.close();
1273
- } catch {
1274
- }
1275
- c.delete(e);
1276
- }
1277
- const n = new Ne(e), a = {
1278
- streamId: e,
1279
- codec: r.Codec,
1280
- inputSampleRate: r.SampleRate,
1281
- inputChannels: r.Channels,
1282
- sink: n,
1283
- decoder: null,
1284
- pendingFrames: [],
1285
- initTask: null,
1286
- currentEpoch: -1,
1287
- epochSet: !1,
1288
- closed: !1,
1289
- lastArrivalTimeMs: 0,
1290
- jitterMs: 0,
1291
- expectedIntervalMs: 20
1292
- };
1293
- c.set(e, a), d({
1294
- type: "streamBegin",
1295
- streamId: e,
1296
- sharedArrayBuffer: n.getSharedArrayBuffer()
1297
- });
1298
- }
1299
- function Pe() {
1300
- for (const t of c.values())
1301
- d({
1302
- type: "streamBegin",
1303
- streamId: t.streamId,
1304
- sharedArrayBuffer: t.sink.getSharedArrayBuffer()
1305
- });
1306
- }
1307
- function we(t) {
1308
- const e = X(t), r = c.get(e);
1309
- if (r) {
1310
- r.closed = !0, r.pendingFrames.splice(0);
1311
- try {
1312
- r.sink.drainPcm(), r.sink.close();
1313
- } catch {
1314
- }
1315
- try {
1316
- r.decoder?.close();
1317
- } catch {
1318
- }
1319
- r.decoder = null, c.delete(e), d({ type: "streamEnd", streamId: e });
1320
- }
1321
- }
1322
- async function ge(t) {
1323
- const e = X(t), r = c.get(e);
1324
- if (!r || r.closed)
1325
- return;
1326
- const s = await pt(t);
1327
- if (!At) {
1328
- if (!r.decoder) {
1329
- if (r.pendingFrames.length >= J) {
1330
- const n = r.pendingFrames.length - J + 1;
1331
- r.pendingFrames.splice(0, n), z.warn(`Dropped ${n} frames waiting for decoder, streamId=${e.substring(0, 8)}`);
1332
- }
1333
- r.pendingFrames.push(s), r.initTask || (r.initTask = Oe(r).then(() => ye(r)).catch((n) => {
1334
- r.closed || U(n, e);
1335
- }));
1336
- return;
1337
- }
1338
- ut(r, s);
1339
- }
1340
- }
1341
- function Fe(t) {
1342
- switch (ct(t)) {
1343
- case V.AUDIO_STREAM_BEGIN:
1344
- de(t);
1345
- return;
1346
- case V.AUDIO_STREAM_END:
1347
- we(t);
1348
- return;
1349
- case V.AUDIO_FRAME2:
1350
- ge(t);
1351
- return;
1352
- default:
1353
- return;
1354
- }
1355
- }
1356
- function ft() {
1357
- if (D) {
1358
- try {
1359
- D.close();
1360
- } catch {
1361
- }
1362
- D = null;
1363
- }
1364
- }
1365
- function Me() {
1366
- ft();
1367
- for (const t of c.values()) {
1368
- try {
1369
- t.sink.drainPcm(), t.sink.close();
1370
- } catch {
1371
- }
1372
- try {
1373
- t.decoder?.close();
1374
- } catch {
1375
- }
1376
- }
1377
- c.clear();
1378
- }
1379
- self.addEventListener("message", (t) => {
1380
- const e = t.data;
1381
- if (e.type === "configure") {
1382
- v = e.transport, lt = e.preferWebCodecs ?? !0, At = e.webRtcEnabled ?? !1, N = Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 ? e.outputSampleRate : _t, S = Number.isFinite(e.outputChannels) && e.outputChannels > 0 ? e.outputChannels : ot;
1383
- return;
1384
- }
1385
- if (e.type === "attachProtocolPort") {
1386
- ft(), D = e.port, D.addEventListener("message", (r) => {
1387
- const s = r.data;
1388
- s?.type === "protocol" && s.message instanceof ArrayBuffer && Fe(new Uint8Array(s.message));
1389
- }), D.start?.();
1390
- return;
1391
- }
1392
- if (e.type === "rebind") {
1393
- v = e.transport, typeof e.outputSampleRate == "number" && Number.isFinite(e.outputSampleRate) && e.outputSampleRate > 0 && (N = e.outputSampleRate), typeof e.outputChannels == "number" && Number.isFinite(e.outputChannels) && e.outputChannels > 0 && (S = e.outputChannels);
1394
- for (const r of c.values())
1395
- r.sink.setOutputFormat(N, S), r.sink.rebind(v);
1396
- Pe();
1397
- return;
1398
- }
1399
- e.type === "dispose" && Me();
1400
- });
1401
- let m = null;
1402
- function be(t, e) {
1403
- const r = t.length;
1404
- if (r === 1)
1405
- return t[0];
1406
- const s = e * r;
1407
- if ((!m || m.length < s) && (m = new Float32Array(s)), r === 2) {
1408
- const n = t[0], a = t[1];
1409
- for (let i = 0, E = 0; i < e; i++)
1410
- m[E++] = n[i], m[E++] = a[i];
1411
- } else {
1412
- let n = 0;
1413
- for (let a = 0; a < e; a++)
1414
- for (let i = 0; i < r; i++)
1415
- m[n++] = t[i][a];
1416
- }
1417
- return m.subarray(0, s);
1418
- }
1419
- const q = 3;
1420
- function tt(t) {
1421
- if (t === 0)
1422
- return 1;
1423
- const e = Math.PI * t;
1424
- return Math.sin(e) / e;
1425
- }
1426
- function Be(t, e) {
1427
- return t === 0 ? 1 : Math.abs(t) >= e ? 0 : tt(t) * tt(t / e);
1428
- }
1429
- function Ge(t, e, r, s, n) {
1430
- if (s === n)
1431
- return e.set(t), t.length;
1432
- const a = t.length / r, i = Math.max(1, Math.round(a * n / s)), E = s / n, _ = E > 1 ? E : 1, o = Math.ceil(q * _);
1433
- for (let l = 0; l < r; l++)
1434
- for (let A = 0; A < i; A++) {
1435
- const f = A * E, R = Math.floor(f);
1436
- let P = 0, L = 0;
1437
- for (let k = -o + 1; k <= o; k++) {
1438
- const b = R + k;
1439
- if (b < 0 || b >= a)
1440
- continue;
1441
- const ht = (f - b) / _, p = Be(ht, q);
1442
- if (p !== 0) {
1443
- const It = t[b * r + l] ?? 0;
1444
- P += It * p, L += p;
1445
- }
1446
- }
1447
- e[A * r + l] = L > 0 ? P / L : 0;
1448
- }
1449
- return i * r;
1450
- }
1451
- function Ve(t, e, r, s) {
1452
- const n = t.length / r;
1453
- if (r === s)
1454
- return e.set(t), t.length;
1455
- if (r === 1 && s === 2) {
1456
- for (let i = 0; i < n; i++) {
1457
- const E = t[i] ?? 0;
1458
- e[i * 2] = E, e[i * 2 + 1] = E;
1459
- }
1460
- return n * 2;
1461
- }
1462
- if (r === 2 && s === 1) {
1463
- for (let i = 0; i < n; i++) {
1464
- const E = t[i * 2] ?? 0, _ = t[i * 2 + 1] ?? 0;
1465
- e[i] = (E + _) * 0.5;
1466
- }
1467
- return n;
1468
- }
1469
- const a = Math.min(r, s);
1470
- for (let i = 0; i < n; i++)
1471
- for (let E = 0; E < a; E++)
1472
- e[i * s + E] = t[i * r + E] ?? 0;
1473
- return n * s;
1474
- }