ball2d 0.1.1 → 0.2.1

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.
Files changed (59) hide show
  1. package/LICENSE +42 -0
  2. package/README.md +193 -138
  3. package/dist/browser.js +1737 -1206
  4. package/dist/core.wasm +0 -0
  5. package/dist/node.js +104 -43358
  6. package/dist/stadiums/big.hbs +515 -85
  7. package/dist/stadiums/big_easy.hbs +515 -85
  8. package/dist/stadiums/big_hockey.hbs +612 -87
  9. package/dist/stadiums/big_rounded.hbs +611 -100
  10. package/dist/stadiums/classic.hbs +515 -85
  11. package/dist/stadiums/easy.hbs +515 -85
  12. package/dist/stadiums/hockey.hbs +612 -87
  13. package/dist/stadiums/huge.hbs +515 -85
  14. package/dist/stadiums/provenance.json +24 -22
  15. package/dist/stadiums/rounded.hbs +611 -100
  16. package/dist/stadiums/small.hbs +515 -85
  17. package/dist/types/announcement.d.ts +1 -0
  18. package/dist/types/browser.d.ts +10 -0
  19. package/dist/types/config.d.ts +9 -0
  20. package/dist/types/disc.d.ts +4 -0
  21. package/dist/types/{core/match-state.d.ts → match-state.d.ts} +2 -0
  22. package/dist/types/node.d.ts +15 -0
  23. package/dist/types/{core/host-types.d.ts → player.d.ts} +3 -1
  24. package/dist/types/{core/replay-types.d.ts → replay.d.ts} +3 -3
  25. package/dist/types/{sdk/types.d.ts → room.d.ts} +9 -4
  26. package/dist/types/stadium.d.ts +5 -0
  27. package/dist/types/team.d.ts +6 -0
  28. package/package.json +28 -6
  29. package/dist/types/client/announcement.d.ts +0 -10
  30. package/dist/types/client/connection-stats.d.ts +0 -11
  31. package/dist/types/client/headless.d.ts +0 -130
  32. package/dist/types/client/host-config.d.ts +0 -11
  33. package/dist/types/client/host-runtime.d.ts +0 -10
  34. package/dist/types/client/network-runtime.d.ts +0 -8
  35. package/dist/types/client/network.d.ts +0 -91
  36. package/dist/types/client/stadium-library.d.ts +0 -4
  37. package/dist/types/client/startup-scope.d.ts +0 -6
  38. package/dist/types/client/traffic.d.ts +0 -9
  39. package/dist/types/core/avatar.d.ts +0 -2
  40. package/dist/types/core/build-id.d.ts +0 -2
  41. package/dist/types/core/control.d.ts +0 -5
  42. package/dist/types/core/disc-properties.d.ts +0 -7
  43. package/dist/types/core/engine.d.ts +0 -68
  44. package/dist/types/core/protocol.d.ts +0 -24
  45. package/dist/types/core/replay-codec.d.ts +0 -6
  46. package/dist/types/core/replay-wire.d.ts +0 -5
  47. package/dist/types/core/replay.d.ts +0 -48
  48. package/dist/types/core/stadium.d.ts +0 -91
  49. package/dist/types/core/team-colors.d.ts +0 -8
  50. package/dist/types/sdk/browser.d.ts +0 -11
  51. package/dist/types/sdk/command-queue.d.ts +0 -11
  52. package/dist/types/sdk/config.d.ts +0 -6
  53. package/dist/types/sdk/node-transport.d.ts +0 -4
  54. package/dist/types/sdk/node.d.ts +0 -18
  55. package/dist/types/sdk/replay.d.ts +0 -4
  56. package/dist/types/sdk/room.d.ts +0 -7
  57. package/dist/types/sdk/stadium.d.ts +0 -9
  58. package/dist/types/shared/room-link.d.ts +0 -6
  59. /package/dist/types/{sdk/create-options.d.ts → creation.d.ts} +0 -0
package/dist/browser.js CHANGED
@@ -1,4 +1,3 @@
1
- //#region \0rolldown/runtime.js
2
1
  var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescriptor, r = Object.getOwnPropertyNames, i = Object.getPrototypeOf, a = Object.prototype.hasOwnProperty, o = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), s = (e, i, o, s) => {
3
2
  if (i && typeof i == "object" || typeof i == "function") for (var c = r(i), l = 0, u = c.length, d; l < u; l++) d = c[l], !a.call(e, d) && d !== o && t(e, d, {
4
3
  get: ((e) => i[e]).bind(null, d),
@@ -8,10 +7,521 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
8
7
  }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
9
8
  value: n,
10
9
  enumerable: !0
11
- }) : o, n));
12
- //#endregion
13
- //#region src/client/startup-scope.ts
14
- function l(e) {
10
+ }) : o, n)), l = Uint8Array, u = Uint16Array, d = Int32Array, f = new l([
11
+ 0,
12
+ 0,
13
+ 0,
14
+ 0,
15
+ 0,
16
+ 0,
17
+ 0,
18
+ 0,
19
+ 1,
20
+ 1,
21
+ 1,
22
+ 1,
23
+ 2,
24
+ 2,
25
+ 2,
26
+ 2,
27
+ 3,
28
+ 3,
29
+ 3,
30
+ 3,
31
+ 4,
32
+ 4,
33
+ 4,
34
+ 4,
35
+ 5,
36
+ 5,
37
+ 5,
38
+ 5,
39
+ 0,
40
+ 0,
41
+ 0,
42
+ 0
43
+ ]), p = new l([
44
+ 0,
45
+ 0,
46
+ 0,
47
+ 0,
48
+ 1,
49
+ 1,
50
+ 2,
51
+ 2,
52
+ 3,
53
+ 3,
54
+ 4,
55
+ 4,
56
+ 5,
57
+ 5,
58
+ 6,
59
+ 6,
60
+ 7,
61
+ 7,
62
+ 8,
63
+ 8,
64
+ 9,
65
+ 9,
66
+ 10,
67
+ 10,
68
+ 11,
69
+ 11,
70
+ 12,
71
+ 12,
72
+ 13,
73
+ 13,
74
+ 0,
75
+ 0
76
+ ]), m = new l([
77
+ 16,
78
+ 17,
79
+ 18,
80
+ 0,
81
+ 8,
82
+ 7,
83
+ 9,
84
+ 6,
85
+ 10,
86
+ 5,
87
+ 11,
88
+ 4,
89
+ 12,
90
+ 3,
91
+ 13,
92
+ 2,
93
+ 14,
94
+ 1,
95
+ 15
96
+ ]), h = function(e, t) {
97
+ for (var n = new u(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
98
+ for (var i = new d(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
99
+ return {
100
+ b: n,
101
+ r: i
102
+ };
103
+ }, g = h(f, 2), _ = g.b, v = g.r;
104
+ _[28] = 258, v[258] = 28;
105
+ for (var y = h(p, 0), ee = y.b, b = y.r, x = new u(32768), S = 0; S < 32768; ++S) {
106
+ var C = (S & 43690) >> 1 | (S & 21845) << 1;
107
+ C = (C & 52428) >> 2 | (C & 13107) << 2, C = (C & 61680) >> 4 | (C & 3855) << 4, x[S] = ((C & 65280) >> 8 | (C & 255) << 8) >> 1;
108
+ }
109
+ for (var w = (function(e, t, n) {
110
+ for (var r = e.length, i = 0, a = new u(t); i < r; ++i) e[i] && ++a[e[i] - 1];
111
+ var o = new u(t);
112
+ for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
113
+ var s;
114
+ if (n) {
115
+ s = new u(1 << t);
116
+ var c = 15 - t;
117
+ for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], d = t - e[i], f = o[e[i] - 1]++ << d, p = f | (1 << d) - 1; f <= p; ++f) s[x[f] >> c] = l;
118
+ } else for (s = new u(r), i = 0; i < r; ++i) e[i] && (s[i] = x[o[e[i] - 1]++] >> 15 - e[i]);
119
+ return s;
120
+ }), T = new l(288), S = 0; S < 144; ++S) T[S] = 8;
121
+ for (var S = 144; S < 256; ++S) T[S] = 9;
122
+ for (var S = 256; S < 280; ++S) T[S] = 7;
123
+ for (var S = 280; S < 288; ++S) T[S] = 8;
124
+ for (var E = new l(32), S = 0; S < 32; ++S) E[S] = 5;
125
+ var te = /*#__PURE__*/ w(T, 9, 0), ne = /*#__PURE__*/ w(T, 9, 1), re = /*#__PURE__*/ w(E, 5, 0), ie = /*#__PURE__*/ w(E, 5, 1), D = function(e) {
126
+ for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
127
+ return t;
128
+ }, O = function(e, t, n) {
129
+ var r = t / 8 | 0;
130
+ return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
131
+ }, ae = function(e, t) {
132
+ var n = t / 8 | 0;
133
+ return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
134
+ }, oe = function(e) {
135
+ return (e + 7) / 8 | 0;
136
+ }, se = function(e, t, n) {
137
+ return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new l(e.subarray(t, n));
138
+ }, k = [
139
+ "unexpected EOF",
140
+ "invalid block type",
141
+ "invalid length/literal",
142
+ "invalid distance",
143
+ "stream finished",
144
+ "no stream handler",
145
+ ,
146
+ "no callback",
147
+ "invalid UTF-8 data",
148
+ "extra field too long",
149
+ "date not in range 1980-2099",
150
+ "filename too long",
151
+ "stream finishing",
152
+ "invalid zip data"
153
+ ], A = function(e, t, n) {
154
+ var r = Error(t || k[e]);
155
+ if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, A), !n) throw r;
156
+ return r;
157
+ }, j = function(e, t, n, r) {
158
+ var i = e.length, a = r ? r.length : 0;
159
+ if (!i || t.f && !t.l) return n || new l(0);
160
+ var o = !n, s = o || t.i != 2, c = t.i;
161
+ o && (n = new l(i * 3));
162
+ var u = function(e) {
163
+ var t = n.length;
164
+ if (e > t) {
165
+ var r = new l(Math.max(t * 2, e));
166
+ r.set(n), n = r;
167
+ }
168
+ }, d = t.f || 0, h = t.p || 0, g = t.b || 0, v = t.l, y = t.d, b = t.m, x = t.n, S = i * 8;
169
+ do {
170
+ if (!v) {
171
+ d = O(e, h, 1);
172
+ var C = O(e, h + 1, 3);
173
+ if (h += 3, !C) {
174
+ var T = oe(h) + 4, E = e[T - 4] | e[T - 3] << 8, te = T + E;
175
+ if (te > i) {
176
+ c && A(0);
177
+ break;
178
+ }
179
+ s && u(g + E), n.set(e.subarray(T, te), g), t.b = g += E, t.p = h = te * 8, t.f = d;
180
+ continue;
181
+ }
182
+ if (C == 1) v = ne, y = ie, b = 9, x = 5;
183
+ else if (C == 2) {
184
+ var re = O(e, h, 31) + 257, k = O(e, h + 10, 15) + 4, j = re + O(e, h + 5, 31) + 1;
185
+ h += 14;
186
+ for (var M = new l(j), N = new l(19), P = 0; P < k; ++P) N[m[P]] = O(e, h + P * 3, 7);
187
+ h += k * 3;
188
+ for (var F = D(N), I = (1 << F) - 1, L = w(N, F, 1), P = 0; P < j;) {
189
+ var R = L[O(e, h, I)];
190
+ h += R & 15;
191
+ var T = R >> 4;
192
+ if (T < 16) M[P++] = T;
193
+ else {
194
+ var z = 0, B = 0;
195
+ for (T == 16 ? (B = 3 + O(e, h, 3), h += 2, z = M[P - 1]) : T == 17 ? (B = 3 + O(e, h, 7), h += 3) : T == 18 && (B = 11 + O(e, h, 127), h += 7); B--;) M[P++] = z;
196
+ }
197
+ }
198
+ var V = M.subarray(0, re), H = M.subarray(re);
199
+ b = D(V), x = D(H), v = w(V, b, 1), y = w(H, x, 1);
200
+ } else A(1);
201
+ if (h > S) {
202
+ c && A(0);
203
+ break;
204
+ }
205
+ }
206
+ s && u(g + 131072);
207
+ for (var U = (1 << b) - 1, W = (1 << x) - 1, G = h;; G = h) {
208
+ var z = v[ae(e, h) & U], K = z >> 4;
209
+ if (h += z & 15, h > S) {
210
+ c && A(0);
211
+ break;
212
+ }
213
+ if (z || A(2), K < 256) n[g++] = K;
214
+ else if (K == 256) {
215
+ G = h, v = null;
216
+ break;
217
+ } else {
218
+ var q = K - 254;
219
+ if (K > 264) {
220
+ var P = K - 257, J = f[P];
221
+ q = O(e, h, (1 << J) - 1) + _[P], h += J;
222
+ }
223
+ var Y = y[ae(e, h) & W], X = Y >> 4;
224
+ Y || A(3), h += Y & 15;
225
+ var H = ee[X];
226
+ if (X > 3) {
227
+ var J = p[X];
228
+ H += ae(e, h) & (1 << J) - 1, h += J;
229
+ }
230
+ if (h > S) {
231
+ c && A(0);
232
+ break;
233
+ }
234
+ s && u(g + 131072);
235
+ var ce = g + q;
236
+ if (g < H) {
237
+ var Z = a - H, le = Math.min(H, ce);
238
+ for (Z + g < 0 && A(3); g < le; ++g) n[g] = r[Z + g];
239
+ }
240
+ for (; g < ce; ++g) n[g] = n[g - H];
241
+ }
242
+ }
243
+ t.l = v, t.p = G, t.b = g, t.f = d, v && (d = 1, t.m = b, t.d = y, t.n = x);
244
+ } while (!d);
245
+ return g != n.length && o ? se(n, 0, g) : n.subarray(0, g);
246
+ }, M = function(e, t, n) {
247
+ n <<= t & 7;
248
+ var r = t / 8 | 0;
249
+ e[r] |= n, e[r + 1] |= n >> 8;
250
+ }, N = function(e, t, n) {
251
+ n <<= t & 7;
252
+ var r = t / 8 | 0;
253
+ e[r] |= n, e[r + 1] |= n >> 8, e[r + 2] |= n >> 16;
254
+ }, P = function(e, t) {
255
+ for (var n = [], r = 0; r < e.length; ++r) e[r] && n.push({
256
+ s: r,
257
+ f: e[r]
258
+ });
259
+ var i = n.length, a = n.slice();
260
+ if (!i) return {
261
+ t: V,
262
+ l: 0
263
+ };
264
+ if (i == 1) {
265
+ var o = new l(n[0].s + 1);
266
+ return o[n[0].s] = 1, {
267
+ t: o,
268
+ l: 1
269
+ };
270
+ }
271
+ n.sort(function(e, t) {
272
+ return e.f - t.f;
273
+ }), n.push({
274
+ s: -1,
275
+ f: 25001
276
+ });
277
+ var s = n[0], c = n[1], d = 0, f = 1, p = 2;
278
+ for (n[0] = {
279
+ s: -1,
280
+ f: s.f + c.f,
281
+ l: s,
282
+ r: c
283
+ }; f != i - 1;) s = n[n[d].f < n[p].f ? d++ : p++], c = n[d != f && n[d].f < n[p].f ? d++ : p++], n[f++] = {
284
+ s: -1,
285
+ f: s.f + c.f,
286
+ l: s,
287
+ r: c
288
+ };
289
+ for (var m = a[0].s, r = 1; r < i; ++r) a[r].s > m && (m = a[r].s);
290
+ var h = new u(m + 1), g = F(n[f - 1], h, 0);
291
+ if (g > t) {
292
+ var r = 0, _ = 0, v = g - t, y = 1 << v;
293
+ for (a.sort(function(e, t) {
294
+ return h[t.s] - h[e.s] || e.f - t.f;
295
+ }); r < i; ++r) {
296
+ var ee = a[r].s;
297
+ if (h[ee] > t) _ += y - (1 << g - h[ee]), h[ee] = t;
298
+ else break;
299
+ }
300
+ for (_ >>= v; _ > 0;) {
301
+ var b = a[r].s;
302
+ h[b] < t ? _ -= 1 << t - h[b]++ - 1 : ++r;
303
+ }
304
+ for (; r >= 0 && _; --r) {
305
+ var x = a[r].s;
306
+ h[x] == t && (--h[x], ++_);
307
+ }
308
+ g = t;
309
+ }
310
+ return {
311
+ t: new l(h),
312
+ l: g
313
+ };
314
+ }, F = function(e, t, n) {
315
+ return e.s == -1 ? Math.max(F(e.l, t, n + 1), F(e.r, t, n + 1)) : t[e.s] = n;
316
+ }, I = function(e) {
317
+ for (var t = e.length; t && !e[--t];);
318
+ for (var n = new u(++t), r = 0, i = e[0], a = 1, o = function(e) {
319
+ n[r++] = e;
320
+ }, s = 1; s <= t; ++s) if (e[s] == i && s != t) ++a;
321
+ else {
322
+ if (!i && a > 2) {
323
+ for (; a > 138; a -= 138) o(32754);
324
+ a > 2 && (o(a > 10 ? a - 11 << 5 | 28690 : a - 3 << 5 | 12305), a = 0);
325
+ } else if (a > 3) {
326
+ for (o(i), --a; a > 6; a -= 6) o(8304);
327
+ a > 2 && (o(a - 3 << 5 | 8208), a = 0);
328
+ }
329
+ for (; a--;) o(i);
330
+ a = 1, i = e[s];
331
+ }
332
+ return {
333
+ c: n.subarray(0, r),
334
+ n: t
335
+ };
336
+ }, L = function(e, t) {
337
+ for (var n = 0, r = 0; r < t.length; ++r) n += e[r] * t[r];
338
+ return n;
339
+ }, R = function(e, t, n) {
340
+ var r = n.length, i = oe(t + 2);
341
+ e[i] = r & 255, e[i + 1] = r >> 8, e[i + 2] = e[i] ^ 255, e[i + 3] = e[i + 1] ^ 255;
342
+ for (var a = 0; a < r; ++a) e[i + a + 4] = n[a];
343
+ return (i + 4 + r) * 8;
344
+ }, z = function(e, t, n, r, i, a, o, s, c, l, d) {
345
+ M(t, d++, n), ++i[256];
346
+ for (var h = P(i, 15), g = h.t, _ = h.l, v = P(a, 15), y = v.t, ee = v.l, b = I(g), x = b.c, S = b.n, C = I(y), ne = C.c, ie = C.n, D = new u(19), O = 0; O < x.length; ++O) ++D[x[O] & 31];
347
+ for (var O = 0; O < ne.length; ++O) ++D[ne[O] & 31];
348
+ for (var ae = P(D, 7), oe = ae.t, se = ae.l, k = 19; k > 4 && !oe[m[k - 1]]; --k);
349
+ var A = l + 5 << 3, j = L(i, T) + L(a, E) + o, F = L(i, g) + L(a, y) + o + 14 + 3 * k + L(D, oe) + 2 * D[16] + 3 * D[17] + 7 * D[18];
350
+ if (c >= 0 && A <= j && A <= F) return R(t, d, e.subarray(c, c + l));
351
+ var z, B, V, H;
352
+ if (M(t, d, 1 + (F < j)), d += 2, F < j) {
353
+ z = w(g, _, 0), B = g, V = w(y, ee, 0), H = y;
354
+ var U = w(oe, se, 0);
355
+ M(t, d, S - 257), M(t, d + 5, ie - 1), M(t, d + 10, k - 4), d += 14;
356
+ for (var O = 0; O < k; ++O) M(t, d + 3 * O, oe[m[O]]);
357
+ d += 3 * k;
358
+ for (var W = [x, ne], G = 0; G < 2; ++G) for (var K = W[G], O = 0; O < K.length; ++O) {
359
+ var q = K[O] & 31;
360
+ M(t, d, U[q]), d += oe[q], q > 15 && (M(t, d, K[O] >> 5 & 127), d += K[O] >> 12);
361
+ }
362
+ } else z = te, B = T, V = re, H = E;
363
+ for (var O = 0; O < s; ++O) {
364
+ var J = r[O];
365
+ if (J > 255) {
366
+ var q = J >> 18 & 31;
367
+ N(t, d, z[q + 257]), d += B[q + 257], q > 7 && (M(t, d, J >> 23 & 31), d += f[q]);
368
+ var Y = J & 31;
369
+ N(t, d, V[Y]), d += H[Y], Y > 3 && (N(t, d, J >> 5 & 8191), d += p[Y]);
370
+ } else N(t, d, z[J]), d += B[J];
371
+ }
372
+ return N(t, d, z[256]), d + B[256];
373
+ }, B = /*#__PURE__*/ new d([
374
+ 65540,
375
+ 131080,
376
+ 131088,
377
+ 131104,
378
+ 262176,
379
+ 1048704,
380
+ 1048832,
381
+ 2114560,
382
+ 2117632
383
+ ]), V = /*#__PURE__*/ new l(0), H = function(e, t, n, r, i, a) {
384
+ var o = a.z || e.length, s = new l(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), m = a.l, h = (a.r || 0) & 7;
385
+ if (t) {
386
+ h && (c[0] = a.r >> 3);
387
+ for (var g = B[t - 1], _ = g >> 13, y = g & 8191, ee = (1 << n) - 1, x = a.p || new u(32768), S = a.h || new u(ee + 1), C = Math.ceil(n / 3), w = 2 * C, T = function(t) {
388
+ return (e[t] ^ e[t + 1] << C ^ e[t + 2] << w) & ee;
389
+ }, E = new d(25e3), te = new u(288), ne = new u(32), re = 0, ie = 0, D = a.i || 0, O = 0, ae = a.w || 0, k = 0; D + 2 < o; ++D) {
390
+ var A = T(D), j = D & 32767, M = S[A];
391
+ if (x[j] = M, S[A] = j, ae <= D) {
392
+ var N = o - D;
393
+ if ((re > 7e3 || O > 24576) && (N > 423 || !m)) {
394
+ h = z(e, c, 0, E, te, ne, ie, O, k, D - k, h), O = re = ie = 0, k = D;
395
+ for (var P = 0; P < 286; ++P) te[P] = 0;
396
+ for (var P = 0; P < 30; ++P) ne[P] = 0;
397
+ }
398
+ var F = 2, I = 0, L = y, V = j - M & 32767;
399
+ if (N > 2 && A == T(D - V)) for (var H = Math.min(_, N) - 1, U = Math.min(32767, D), W = Math.min(258, N); V <= U && --L && j != M;) {
400
+ if (e[D + F] == e[D + F - V]) {
401
+ for (var G = 0; G < W && e[D + G] == e[D + G - V]; ++G);
402
+ if (G > F) {
403
+ if (F = G, I = V, G > H) break;
404
+ for (var K = Math.min(V, G - 2), q = 0, P = 0; P < K; ++P) {
405
+ var J = D - V + P & 32767, Y = J - x[J] & 32767;
406
+ Y > q && (q = Y, M = J);
407
+ }
408
+ }
409
+ }
410
+ j = M, M = x[j], V += j - M & 32767;
411
+ }
412
+ if (I) {
413
+ E[O++] = 268435456 | v[F] << 18 | b[I];
414
+ var X = v[F] & 31, ce = b[I] & 31;
415
+ ie += f[X] + p[ce], ++te[257 + X], ++ne[ce], ae = D + F, ++re;
416
+ } else E[O++] = e[D], ++te[e[D]];
417
+ }
418
+ }
419
+ for (D = Math.max(D, ae); D < o; ++D) E[O++] = e[D], ++te[e[D]];
420
+ h = z(e, c, m, E, te, ne, ie, O, k, D - k, h), m || (a.r = h & 7 | c[h / 8 | 0] << 3, h -= 7, a.h = S, a.p = x, a.i = D, a.w = ae);
421
+ } else {
422
+ for (var D = a.w || 0; D < o + m; D += 65535) {
423
+ var Z = D + 65535;
424
+ Z >= o && (c[h / 8 | 0] = m, Z = o), h = R(c, h + 1, e.subarray(D, Z));
425
+ }
426
+ a.i = o;
427
+ }
428
+ return se(s, 0, r + oe(h) + i);
429
+ }, U = function(e, t, n, r, i) {
430
+ if (!i && (i = { l: 1 }, t.dictionary)) {
431
+ var a = t.dictionary.subarray(-32768), o = new l(a.length + e.length);
432
+ o.set(a), o.set(e, a.length), e = o, i.w = a.length;
433
+ }
434
+ return H(e, t.level == null ? 6 : t.level, t.mem == null ? i.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(e.length))) * 1.5) : 20 : 12 + t.mem, n, r, i);
435
+ };
436
+ function W(e, t) {
437
+ return U(e, t || {}, 0, 0);
438
+ }
439
+ var G = /* @__PURE__ */ function() {
440
+ function e(e, t) {
441
+ typeof e == "function" && (t = e, e = {}), this.ondata = t;
442
+ var n = e && e.dictionary && e.dictionary.subarray(-32768);
443
+ this.s = {
444
+ i: 0,
445
+ b: n ? n.length : 0
446
+ }, this.o = new l(32768), this.p = new l(0), n && this.o.set(n);
447
+ }
448
+ return e.prototype.e = function(e) {
449
+ if (this.ondata || A(5), this.d && A(4), !this.p.length) this.p = e;
450
+ else if (e.length) {
451
+ var t = new l(this.p.length + e.length);
452
+ t.set(this.p), t.set(e, this.p.length), this.p = t;
453
+ }
454
+ }, e.prototype.c = function(e) {
455
+ this.s.i = +(this.d = e || !1);
456
+ var t = this.s.b, n = j(this.p, this.s, this.o);
457
+ this.ondata(se(n, t, this.s.b), this.d), this.o = se(n, this.s.b - 32768), this.s.b = this.o.length, this.p = se(this.p, this.s.p / 8 | 0), this.s.p &= 7;
458
+ }, e.prototype.push = function(e, t) {
459
+ this.e(e), this.c(t);
460
+ }, e;
461
+ }(), K = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
462
+ try {
463
+ K.decode(V, { stream: !0 });
464
+ } catch {}
465
+ var q = 5389, J = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, Y = (e) => Number.isFinite(e) && e >= 1 && e <= 1e5, X = class {
466
+ core;
467
+ enabled = !1;
468
+ constructor(e) {
469
+ if (this.core = e, e.surface_state_capacity() !== 5389) throw Error("Unsupported surface state version");
470
+ }
471
+ configure(e) {
472
+ if (!J(e.seed, 0, 4294967295) || !Y(e.halfWidth) || !Y(e.halfHeight) || !J(e.moisturePermille, 0, 1e3)) throw Error("Invalid surface configuration");
473
+ if (!this.core.surface_configure(e.seed, e.halfWidth, e.halfHeight, e.moisturePermille)) throw Error("Surface configuration rejected");
474
+ this.enabled = !0;
475
+ }
476
+ disable() {
477
+ this.core.surface_disable(), this.enabled = !1;
478
+ }
479
+ setWeather(e) {
480
+ if (!J(e.rainMilliMmH, 0, 2e5) || !J(e.temperatureMilliC, -3e4, 6e4) || !J(e.humidityPermille, 0, 1e3) || !J(e.windMilliMS, 0, 6e4)) throw Error("Invalid surface weather");
481
+ if (!this.core.surface_weather(e.rainMilliMmH, e.temperatureMilliC, e.humidityPermille, e.windMilliMS)) throw Error("Surface is disabled");
482
+ }
483
+ sample(e, t) {
484
+ if (!Number.isFinite(e) || !Number.isFinite(t)) throw Error("Invalid surface position");
485
+ return {
486
+ traction: this.core.surface_sample(e, t, 0),
487
+ rollingDrag: this.core.surface_sample(e, t, 1),
488
+ waterMm: this.core.surface_sample(e, t, 2),
489
+ compaction: this.core.surface_sample(e, t, 3)
490
+ };
491
+ }
492
+ snapshot() {
493
+ let e = this.core.surface_save();
494
+ if (e === 0) return [];
495
+ if (e !== 5389) throw Error("Invalid surface checkpoint size");
496
+ return Array.from(this.buffer());
497
+ }
498
+ restore(e) {
499
+ if (!Array.isArray(e) || e.length !== 0 && e.length !== 5389 || !e.every((e) => J(e, 0, 4294967295)) || (e.length && this.buffer().set(e), !this.core.surface_restore(e.length))) throw Error("Invalid surface checkpoint");
500
+ this.enabled = e.length > 0;
501
+ }
502
+ buffer() {
503
+ let e = this.core.surface_state_ptr();
504
+ return new Uint32Array(this.core.memory.buffer, e, q);
505
+ }
506
+ }, ce = 131072, Z = 49152, le = new TextEncoder();
507
+ new TextDecoder("utf-8", { fatal: !0 });
508
+ var ue = (e, t) => typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= t;
509
+ function de(e, t) {
510
+ if (!ue(t, 65535) || !ue(e.tick, 4294967295) || !Array.isArray(e.surface) || e.surface.length !== 5389) throw Error("Invalid terrain snapshot");
511
+ let n = le.encode(JSON.stringify(e));
512
+ if (n.length > ce) throw Error("Terrain snapshot exceeds size limit");
513
+ let r = W(n, { level: 1 });
514
+ if (r.length > Z) throw Error("Compressed terrain snapshot exceeds size limit");
515
+ let i = "";
516
+ for (let e of r) i += String.fromCharCode(e);
517
+ return {
518
+ type: "terrain-state",
519
+ epoch: t,
520
+ tick: e.tick,
521
+ payload: btoa(i)
522
+ };
523
+ }
524
+ function fe(e) {
15
525
  let t = new AbortController(), n = () => t.abort(e?.reason);
16
526
  e?.aborted ? n() : e?.addEventListener("abort", n, { once: !0 });
17
527
  let r = setTimeout(() => t.abort(new DOMException("Room startup timed out", "TimeoutError")), 15e3);
@@ -33,9 +543,7 @@ function l(e) {
33
543
  }
34
544
  };
35
545
  }
36
- //#endregion
37
- //#region src/client/host-config.ts
38
- var u = /* @__PURE__ */ new Set([
546
+ var pe = /* @__PURE__ */ new Set([
39
547
  "noPlayer",
40
548
  "playerName",
41
549
  "roomName",
@@ -44,12 +552,12 @@ var u = /* @__PURE__ */ new Set([
44
552
  "public",
45
553
  "stadium"
46
554
  ]);
47
- function d(e) {
555
+ function me(e) {
48
556
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Room configuration must be an object");
49
557
  for (let t of Object.keys(e)) {
50
558
  if (t === "token") throw Error("External service tokens are not supported. Ball2D join verification is configured on the room.");
51
559
  if (t === "geo") throw Error("Geolocation overrides are not supported. Room country comes from the host connection.");
52
- if (!u.has(t)) throw Error(`Unknown room setting: ${t}`);
560
+ if (!pe.has(t)) throw Error(`Unknown room setting: ${t}`);
53
561
  }
54
562
  let t = { ...e };
55
563
  if (typeof t.roomName != "string" || !t.roomName.trim() || t.roomName.length > 64) throw Error("Room name must contain 1–64 characters");
@@ -68,19 +576,15 @@ function d(e) {
68
576
  stadium: t.stadium
69
577
  };
70
578
  }
71
- //#endregion
72
- //#region src/shared/room-link.ts
73
- function f(e) {
579
+ function he(e) {
74
580
  return /^(?:[0-9a-f]{10}|[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})$/i.test(e) ? e.toLowerCase() : null;
75
581
  }
76
- function p(e) {
77
- let t = f(e);
582
+ function Q(e) {
583
+ let t = he(e);
78
584
  if (!t) throw Error("Invalid room code");
79
585
  return `/r/${t}`;
80
586
  }
81
- //#endregion
82
- //#region src/core/team-colors.ts
83
- function m(e, t, n) {
587
+ function ge(e, t, n) {
84
588
  if (!Number.isFinite(e) || !Number.isInteger(t) || t < 0 || t > 16777215 || !Array.isArray(n) || n.length < 1 || n.length > 3 || n.some((e) => !Number.isInteger(e) || e < 0 || e > 16777215)) throw Error("Invalid team colors");
85
589
  return {
86
590
  angle: (e % 360 + 360) % 360,
@@ -88,14 +592,12 @@ function m(e, t, n) {
88
592
  colors: [...n]
89
593
  };
90
594
  }
91
- function h(e) {
595
+ function _e(e) {
92
596
  if (e === void 0) return [null, null];
93
597
  if (!Array.isArray(e) || e.length !== 2) throw Error("Invalid team styles");
94
- return e.map((e) => e === null ? null : m(e.angle, e.textColor, e.colors));
598
+ return e.map((e) => e === null ? null : ge(e.angle, e.textColor, e.colors));
95
599
  }
96
- //#endregion
97
- //#region src/client/announcement.ts
98
- var g = [
600
+ var ve = [
99
601
  "normal",
100
602
  "bold",
101
603
  "italic",
@@ -103,10 +605,10 @@ var g = [
103
605
  "small-bold",
104
606
  "small-italic"
105
607
  ];
106
- function _(e, t, n, r) {
608
+ function ye(e, t, n, r) {
107
609
  if (typeof e != "string" || e.length > 1e3) throw Error("Announcement exceeds 1000 characters");
108
610
  if (t != null && (!Number.isInteger(t) || t < 0 || t > 16777215)) throw Error("Invalid announcement color");
109
- if (n != null && !g.includes(n)) throw Error("Invalid announcement style");
611
+ if (n != null && !ve.includes(n)) throw Error("Invalid announcement style");
110
612
  if (r != null && ![
111
613
  0,
112
614
  1,
@@ -120,14 +622,10 @@ function _(e, t, n, r) {
120
622
  sound: r ?? 1
121
623
  };
122
624
  }
123
- //#endregion
124
- //#region src/core/avatar.ts
125
- function v(e) {
625
+ function be(e) {
126
626
  return e === null || typeof e == "string" && Array.from(e).length <= 2 && !/[\p{Cc}\p{Cf}]/u.test(e);
127
627
  }
128
- //#endregion
129
- //#region src/core/disc-properties.ts
130
- var y = [
628
+ var xe = [
131
629
  [
132
630
  "x",
133
631
  0,
@@ -207,11 +705,11 @@ var y = [
207
705
  2147483647
208
706
  ]
209
707
  ];
210
- function b(e) {
708
+ function Se(e) {
211
709
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Invalid disc property update");
212
710
  let t = e, n = {};
213
- for (let e = 0; e < y.length; e++) {
214
- let [r, , i, a] = y[e], o = t[r];
711
+ for (let e = 0; e < xe.length; e++) {
712
+ let [r, , i, a] = xe[e], o = t[r];
215
713
  if (o == null) continue;
216
714
  if (typeof o != "number" || !Number.isFinite(o)) throw Error(`Invalid disc property: ${r}`);
217
715
  let s = e < 10 ? Math.fround(o) : o | 0;
@@ -220,9 +718,7 @@ function b(e) {
220
718
  }
221
719
  return n;
222
720
  }
223
- //#endregion
224
- //#region src/core/build-id.ts
225
- var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
721
+ var Ce = "edb227eac070ad86a151", we = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
226
722
  (function(n, r) {
227
723
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : n.JSON5 = r();
228
724
  })(e, (function() {
@@ -282,9 +778,9 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
282
778
  return e[t] = n, e;
283
779
  }, g = {}.hasOwnProperty, _ = function(e, t) {
284
780
  return g.call(e, t);
285
- }, v = 0, y = Math.random(), b = function(e) {
781
+ }, v = 0, y = Math.random(), ee = function(e) {
286
782
  return `Symbol(${e === void 0 ? "" : e})_${(++v + y).toString(36)}`;
287
- }, x = e(function(e) {
783
+ }, b = e(function(e) {
288
784
  var r = "__core-js_shared__", i = t[r] || (t[r] = {});
289
785
  (e.exports = function(e, t) {
290
786
  return i[e] || (i[e] = t === void 0 ? {} : t);
@@ -293,21 +789,21 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
293
789
  mode: "global",
294
790
  copyright: "© 2019 Denis Pushkarev (zloirock.ru)"
295
791
  });
296
- })("native-function-to-string", Function.toString), S = e(function(e) {
297
- var r = b("src"), i = "toString", a = ("" + x).split(i);
792
+ })("native-function-to-string", Function.toString), x = e(function(e) {
793
+ var r = ee("src"), i = "toString", a = ("" + b).split(i);
298
794
  n.inspectSource = function(e) {
299
- return x.call(e);
795
+ return b.call(e);
300
796
  }, (e.exports = function(e, n, i, o) {
301
797
  var s = typeof i == "function";
302
798
  s && (_(i, "name") || h(i, "name", n)), e[n] !== i && (s && (_(i, r) || h(i, r, e[n] ? "" + e[n] : a.join(String(n)))), e === t ? e[n] = i : o ? e[n] ? e[n] = i : h(e, n, i) : (delete e[n], h(e, n, i)));
303
799
  })(Function.prototype, i, function() {
304
- return typeof this == "function" && this[r] || x.call(this);
800
+ return typeof this == "function" && this[r] || b.call(this);
305
801
  });
306
- }), C = function(e) {
802
+ }), S = function(e) {
307
803
  if (typeof e != "function") throw TypeError(e + " is not a function!");
308
804
  return e;
309
- }, w = function(e, t, n) {
310
- if (C(e), t === void 0) return e;
805
+ }, C = function(e, t, n) {
806
+ if (S(e), t === void 0) return e;
311
807
  switch (n) {
312
808
  case 1: return function(n) {
313
809
  return e.call(t, n);
@@ -322,48 +818,48 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
322
818
  return function() {
323
819
  return e.apply(t, arguments);
324
820
  };
325
- }, T = "prototype", E = function(e, r, i) {
326
- var a = e & E.F, o = e & E.G, s = e & E.S, c = e & E.P, l = e & E.B, u = o ? t : s ? t[r] || (t[r] = {}) : (t[r] || {})[T], d = o ? n : n[r] || (n[r] = {}), f = d[T] || (d[T] = {}), p, m, g, _;
327
- for (p in o && (i = r), i) m = !a && u && u[p] !== void 0, g = (m ? u : i)[p], _ = l && m ? w(g, t) : c && typeof g == "function" ? w(Function.call, g) : g, u && S(u, p, g, e & E.U), d[p] != g && h(d, p, _), c && f[p] != g && (f[p] = g);
821
+ }, w = "prototype", T = function(e, r, i) {
822
+ var a = e & T.F, o = e & T.G, s = e & T.S, c = e & T.P, l = e & T.B, u = o ? t : s ? t[r] || (t[r] = {}) : (t[r] || {})[w], d = o ? n : n[r] || (n[r] = {}), f = d[w] || (d[w] = {}), p, m, g, _;
823
+ for (p in o && (i = r), i) m = !a && u && u[p] !== void 0, g = (m ? u : i)[p], _ = l && m ? C(g, t) : c && typeof g == "function" ? C(Function.call, g) : g, u && x(u, p, g, e & T.U), d[p] != g && h(d, p, _), c && f[p] != g && (f[p] = g);
328
824
  };
329
- t.core = n, E.F = 1, E.G = 2, E.S = 4, E.P = 8, E.B = 16, E.W = 32, E.U = 64, E.R = 128;
330
- var D = E, O = Math.ceil, k = Math.floor, A = function(e) {
331
- return isNaN(e = +e) ? 0 : (e > 0 ? k : O)(e);
332
- }, j = function(e) {
825
+ t.core = n, T.F = 1, T.G = 2, T.S = 4, T.P = 8, T.B = 16, T.W = 32, T.U = 64, T.R = 128;
826
+ var E = T, te = Math.ceil, ne = Math.floor, re = function(e) {
827
+ return isNaN(e = +e) ? 0 : (e > 0 ? ne : te)(e);
828
+ }, ie = function(e) {
333
829
  if (e == null) throw TypeError("Can't call method on " + e);
334
830
  return e;
335
- }, M = function(e) {
831
+ }, D = function(e) {
336
832
  return function(t, n) {
337
- var r = String(j(t)), i = A(n), a = r.length, o, s;
833
+ var r = String(ie(t)), i = re(n), a = r.length, o, s;
338
834
  return i < 0 || i >= a ? e ? "" : void 0 : (o = r.charCodeAt(i), o < 55296 || o > 56319 || i + 1 === a || (s = r.charCodeAt(i + 1)) < 56320 || s > 57343 ? e ? r.charAt(i) : o : e ? r.slice(i, i + 2) : (o - 55296 << 10) + (s - 56320) + 65536);
339
835
  };
340
836
  }(!1);
341
- D(D.P, "String", { codePointAt: function(e) {
342
- return M(this, e);
837
+ E(E.P, "String", { codePointAt: function(e) {
838
+ return D(this, e);
343
839
  } }), n.String.codePointAt;
344
- var N = Math.max, P = Math.min, F = function(e, t) {
345
- return e = A(e), e < 0 ? N(e + t, 0) : P(e, t);
346
- }, ee = String.fromCharCode, I = String.fromCodePoint;
347
- D(D.S + D.F * (!!I && I.length != 1), "String", { fromCodePoint: function(e) {
840
+ var O = Math.max, ae = Math.min, oe = function(e, t) {
841
+ return e = re(e), e < 0 ? O(e + t, 0) : ae(e, t);
842
+ }, se = String.fromCharCode, k = String.fromCodePoint;
843
+ E(E.S + E.F * (!!k && k.length != 1), "String", { fromCodePoint: function(e) {
348
844
  for (var t = arguments, n = [], r = arguments.length, i = 0, a; r > i;) {
349
- if (a = +t[i++], F(a, 1114111) !== a) throw RangeError(a + " is not a valid code point");
350
- n.push(a < 65536 ? ee(a) : ee(((a -= 65536) >> 10) + 55296, a % 1024 + 56320));
845
+ if (a = +t[i++], oe(a, 1114111) !== a) throw RangeError(a + " is not a valid code point");
846
+ n.push(a < 65536 ? se(a) : se(((a -= 65536) >> 10) + 55296, a % 1024 + 56320));
351
847
  }
352
848
  return n.join("");
353
849
  } }), n.String.fromCodePoint;
354
- var L = {
850
+ var A = {
355
851
  Space_Separator: /[\u1680\u2000-\u200A\u202F\u205F\u3000]/,
356
852
  ID_Start: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E\u066F\u0671-\u06D3\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0980\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC\u09DD\u09DF-\u09E1\u09F0\u09F1\u09FC\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0\u0AE1\u0AF9\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3D\u0B5C\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C58-\u0C5A\u0C60\u0C61\u0C80\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0\u0CE1\u0CF1\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D54-\u0D56\u0D5F-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32\u0E33\u0E40-\u0E46\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB0\u0EB2\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u1884\u1887-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191E\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u1A00-\u1A16\u1A20-\u1A54\u1AA7\u1B05-\u1B33\u1B45-\u1B4B\u1B83-\u1BA0\u1BAE\u1BAF\u1BBA-\u1BE5\u1C00-\u1C23\u1C4D-\u1C4F\u1C5A-\u1C7D\u1C80-\u1C88\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF5\u1CF6\u1D00-\u1DBF\u1E00-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CEE\u2CF2\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2E2F\u3005-\u3007\u3021-\u3029\u3031-\u3035\u3038-\u303C\u3041-\u3096\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA61F\uA62A\uA62B\uA640-\uA66E\uA67F-\uA69D\uA6A0-\uA6EF\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA801\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA840-\uA873\uA882-\uA8B3\uA8F2-\uA8F7\uA8FB\uA8FD\uA90A-\uA925\uA930-\uA946\uA960-\uA97C\uA984-\uA9B2\uA9CF\uA9E0-\uA9E4\uA9E6-\uA9EF\uA9FA-\uA9FE\uAA00-\uAA28\uAA40-\uAA42\uAA44-\uAA4B\uAA60-\uAA76\uAA7A\uAA7E-\uAAAF\uAAB1\uAAB5\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADD\uAAE0-\uAAEA\uAAF2-\uAAF4\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABE2\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE74\uFE76-\uFEFC\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDE80-\uDE9C\uDEA0-\uDED0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF75\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00\uDE10-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE4\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC03-\uDC37\uDC83-\uDCAF\uDCD0-\uDCE8\uDD03-\uDD26\uDD50-\uDD72\uDD76\uDD83-\uDDB2\uDDC1-\uDDC4\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE2B\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEDE\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3D\uDF50\uDF5D-\uDF61]|\uD805[\uDC00-\uDC34\uDC47-\uDC4A\uDC80-\uDCAF\uDCC4\uDCC5\uDCC7\uDD80-\uDDAE\uDDD8-\uDDDB\uDE00-\uDE2F\uDE44\uDE80-\uDEAA\uDF00-\uDF19]|\uD806[\uDCA0-\uDCDF\uDCFF\uDE00\uDE0B-\uDE32\uDE3A\uDE50\uDE5C-\uDE83\uDE86-\uDE89\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC2E\uDC40\uDC72-\uDC8F\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD30\uDD46]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDED0-\uDEED\uDF00-\uDF2F\uDF40-\uDF43\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50\uDF93-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB]|\uD83A[\uDC00-\uDCC4\uDD00-\uDD43]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]/,
357
853
  ID_Continue: /[\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u0487\u048A-\u052F\u0531-\u0556\u0559\u0561-\u0587\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05F0-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08BD\u08D4-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09FC\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BEF\u0C00-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D57\u0D5F-\u0D63\u0D66-\u0D6F\u0D7A-\u0D7F\u0D82\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E87\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA\u0EAB\u0EAD-\u0EB9\u0EBB-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F29\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u180B-\u180D\u1810-\u1819\u1820-\u1877\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19D9\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1ABD\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1CD0-\u1CD2\u1CD4-\u1CF9\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u203F\u2040\u2054\u2071\u207F\u2090-\u209C\u20D0-\u20DC\u20E1\u20E5-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2160-\u2188\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312E\u3131-\u318E\u31A0-\u31BA\u31F0-\u31FF\u3400-\u4DB5\u4E00-\u9FEA\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA66F\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7AE\uA7B0-\uA7B7\uA7F7-\uA827\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD\uA900-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB65\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE33\uFE34\uFE4D-\uFE4F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF3F\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD40-\uDD74\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0\uDF00-\uDF1F\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC60-\uDC76\uDC80-\uDC9E\uDCE0-\uDCF2\uDCF4\uDCF5\uDD00-\uDD15\uDD20-\uDD39\uDD80-\uDDB7\uDDBE\uDDBF\uDE00-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE33\uDE38-\uDE3A\uDE3F\uDE60-\uDE7C\uDE80-\uDE9C\uDEC0-\uDEC7\uDEC9-\uDEE6\uDF00-\uDF35\uDF40-\uDF55\uDF60-\uDF72\uDF80-\uDF91]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2]|\uD804[\uDC00-\uDC46\uDC66-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDCA-\uDDCC\uDDD0-\uDDDA\uDDDC\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3C-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB7\uDEC0-\uDEC9\uDF00-\uDF19\uDF1D-\uDF2B\uDF30-\uDF39]|\uD806[\uDCA0-\uDCE9\uDCFF\uDE00-\uDE3E\uDE47\uDE50-\uDE83\uDE86-\uDE99\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC59\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDF00-\uDF44\uDF50-\uDF7E\uDF8F-\uDF9F\uDFE0\uDFE1]|\uD821[\uDC00-\uDFEC]|\uD822[\uDC00-\uDEF2]|\uD82C[\uDC00-\uDD1E\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A]|\uD83A[\uDC00-\uDCC4\uDCD0-\uDCD6\uDD00-\uDD4A\uDD50-\uDD59]|\uD83B[\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uDB40[\uDD00-\uDDEF]/
358
- }, R = {
854
+ }, j = {
359
855
  isSpaceSeparator: function(e) {
360
- return typeof e == "string" && L.Space_Separator.test(e);
856
+ return typeof e == "string" && A.Space_Separator.test(e);
361
857
  },
362
858
  isIdStartChar: function(e) {
363
- return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "$" || e === "_" || L.ID_Start.test(e));
859
+ return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "$" || e === "_" || A.ID_Start.test(e));
364
860
  },
365
861
  isIdContinueChar: function(e) {
366
- return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "$" || e === "_" || e === "‌" || e === "‍" || L.ID_Continue.test(e));
862
+ return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "$" || e === "_" || e === "‌" || e === "‍" || A.ID_Continue.test(e));
367
863
  },
368
864
  isDigit: function(e) {
369
865
  return typeof e == "string" && /[0-9]/.test(e);
@@ -371,18 +867,18 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
371
867
  isHexDigit: function(e) {
372
868
  return typeof e == "string" && /[0-9A-Fa-f]/.test(e);
373
869
  }
374
- }, z, B, V, te, H, U, W, G, ne, re = function(e, t) {
375
- z = String(e), B = "start", V = [], te = 0, H = 1, U = 0, W = void 0, G = void 0, ne = void 0;
870
+ }, M, N, P, F, I, L, R, z, B, V = function(e, t) {
871
+ M = String(e), N = "start", P = [], F = 0, I = 1, L = 0, R = void 0, z = void 0, B = void 0;
376
872
  do
377
- W = se(), pe[B]();
378
- while (W.type !== "eof");
379
- return typeof t == "function" ? ie({ "": ne }, "", t) : ne;
873
+ R = J(), pe[N]();
874
+ while (R.type !== "eof");
875
+ return typeof t == "function" ? H({ "": B }, "", t) : B;
380
876
  };
381
- function ie(e, t, n) {
877
+ function H(e, t, n) {
382
878
  var r = e[t];
383
879
  if (typeof r == "object" && r) {
384
880
  if (Array.isArray(r)) for (var i = 0; i < r.length; i++) {
385
- var a = String(i), o = ie(r, a, n);
881
+ var a = String(i), o = H(r, a, n);
386
882
  o === void 0 ? delete r[a] : Object.defineProperty(r, a, {
387
883
  value: o,
388
884
  writable: !0,
@@ -391,7 +887,7 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
391
887
  });
392
888
  }
393
889
  else for (var s in r) {
394
- var c = ie(r, s, n);
890
+ var c = H(r, s, n);
395
891
  c === void 0 ? delete r[s] : Object.defineProperty(r, s, {
396
892
  value: c,
397
893
  writable: !0,
@@ -402,24 +898,24 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
402
898
  }
403
899
  return n.call(e, t, r);
404
900
  }
405
- var K, q, ae, oe, J;
406
- function se() {
407
- for (K = "default", q = "", ae = !1, oe = 1;;) {
408
- J = ce();
409
- var e = le[K]();
901
+ var U, W, G, K, q;
902
+ function J() {
903
+ for (U = "default", W = "", G = !1, K = 1;;) {
904
+ q = Y();
905
+ var e = ce[U]();
410
906
  if (e) return e;
411
907
  }
412
908
  }
413
- function ce() {
414
- if (z[te]) return String.fromCodePoint(z.codePointAt(te));
415
- }
416
909
  function Y() {
417
- var e = ce();
418
- return e === "\n" ? (H++, U = 0) : e ? U += e.length : U++, e && (te += e.length), e;
910
+ if (M[F]) return String.fromCodePoint(M.codePointAt(F));
419
911
  }
420
- var le = {
912
+ function X() {
913
+ var e = Y();
914
+ return e === "\n" ? (I++, L = 0) : e ? L += e.length : L++, e && (F += e.length), e;
915
+ }
916
+ var ce = {
421
917
  default: function() {
422
- switch (J) {
918
+ switch (q) {
423
919
  case " ":
424
920
  case "\v":
425
921
  case "\f":
@@ -430,79 +926,79 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
430
926
  case "\r":
431
927
  case "\u2028":
432
928
  case "\u2029":
433
- Y();
929
+ X();
434
930
  return;
435
931
  case "/":
436
- Y(), K = "comment";
932
+ X(), U = "comment";
437
933
  return;
438
- case void 0: return Y(), X("eof");
934
+ case void 0: return X(), Z("eof");
439
935
  }
440
- if (R.isSpaceSeparator(J)) {
441
- Y();
936
+ if (j.isSpaceSeparator(q)) {
937
+ X();
442
938
  return;
443
939
  }
444
- return le[B]();
940
+ return ce[N]();
445
941
  },
446
942
  comment: function() {
447
- switch (J) {
943
+ switch (q) {
448
944
  case "*":
449
- Y(), K = "multiLineComment";
945
+ X(), U = "multiLineComment";
450
946
  return;
451
947
  case "/":
452
- Y(), K = "singleLineComment";
948
+ X(), U = "singleLineComment";
453
949
  return;
454
950
  }
455
- throw Q(Y());
951
+ throw Q(X());
456
952
  },
457
953
  multiLineComment: function() {
458
- switch (J) {
954
+ switch (q) {
459
955
  case "*":
460
- Y(), K = "multiLineCommentAsterisk";
956
+ X(), U = "multiLineCommentAsterisk";
461
957
  return;
462
- case void 0: throw Q(Y());
958
+ case void 0: throw Q(X());
463
959
  }
464
- Y();
960
+ X();
465
961
  },
466
962
  multiLineCommentAsterisk: function() {
467
- switch (J) {
963
+ switch (q) {
468
964
  case "*":
469
- Y();
965
+ X();
470
966
  return;
471
967
  case "/":
472
- Y(), K = "default";
968
+ X(), U = "default";
473
969
  return;
474
- case void 0: throw Q(Y());
970
+ case void 0: throw Q(X());
475
971
  }
476
- Y(), K = "multiLineComment";
972
+ X(), U = "multiLineComment";
477
973
  },
478
974
  singleLineComment: function() {
479
- switch (J) {
975
+ switch (q) {
480
976
  case "\n":
481
977
  case "\r":
482
978
  case "\u2028":
483
979
  case "\u2029":
484
- Y(), K = "default";
980
+ X(), U = "default";
485
981
  return;
486
- case void 0: return Y(), X("eof");
982
+ case void 0: return X(), Z("eof");
487
983
  }
488
- Y();
984
+ X();
489
985
  },
490
986
  value: function() {
491
- switch (J) {
987
+ switch (q) {
492
988
  case "{":
493
- case "[": return X("punctuator", Y());
494
- case "n": return Y(), Z("ull"), X("null", null);
495
- case "t": return Y(), Z("rue"), X("boolean", !0);
496
- case "f": return Y(), Z("alse"), X("boolean", !1);
989
+ case "[": return Z("punctuator", X());
990
+ case "n": return X(), le("ull"), Z("null", null);
991
+ case "t": return X(), le("rue"), Z("boolean", !0);
992
+ case "f": return X(), le("alse"), Z("boolean", !1);
497
993
  case "-":
498
994
  case "+":
499
- Y() === "-" && (oe = -1), K = "sign";
995
+ X() === "-" && (K = -1), U = "sign";
500
996
  return;
501
997
  case ".":
502
- q = Y(), K = "decimalPointLeading";
998
+ W = X(), U = "decimalPointLeading";
503
999
  return;
504
1000
  case "0":
505
- q = Y(), K = "zero";
1001
+ W = X(), U = "zero";
506
1002
  return;
507
1003
  case "1":
508
1004
  case "2":
@@ -513,66 +1009,66 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
513
1009
  case "7":
514
1010
  case "8":
515
1011
  case "9":
516
- q = Y(), K = "decimalInteger";
1012
+ W = X(), U = "decimalInteger";
517
1013
  return;
518
- case "I": return Y(), Z("nfinity"), X("numeric", Infinity);
519
- case "N": return Y(), Z("aN"), X("numeric", NaN);
1014
+ case "I": return X(), le("nfinity"), Z("numeric", Infinity);
1015
+ case "N": return X(), le("aN"), Z("numeric", NaN);
520
1016
  case "\"":
521
1017
  case "'":
522
- ae = Y() === "\"", q = "", K = "string";
1018
+ G = X() === "\"", W = "", U = "string";
523
1019
  return;
524
1020
  }
525
- throw Q(Y());
1021
+ throw Q(X());
526
1022
  },
527
1023
  identifierNameStartEscape: function() {
528
- if (J !== "u") throw Q(Y());
529
- Y();
1024
+ if (q !== "u") throw Q(X());
1025
+ X();
530
1026
  var e = fe();
531
1027
  switch (e) {
532
1028
  case "$":
533
1029
  case "_": break;
534
- default: if (!R.isIdStartChar(e)) throw $();
1030
+ default: if (!j.isIdStartChar(e)) throw _e();
535
1031
  }
536
- q += e, K = "identifierName";
1032
+ W += e, U = "identifierName";
537
1033
  },
538
1034
  identifierName: function() {
539
- switch (J) {
1035
+ switch (q) {
540
1036
  case "$":
541
1037
  case "_":
542
1038
  case "‌":
543
1039
  case "‍":
544
- q += Y();
1040
+ W += X();
545
1041
  return;
546
1042
  case "\\":
547
- Y(), K = "identifierNameEscape";
1043
+ X(), U = "identifierNameEscape";
548
1044
  return;
549
1045
  }
550
- if (R.isIdContinueChar(J)) {
551
- q += Y();
1046
+ if (j.isIdContinueChar(q)) {
1047
+ W += X();
552
1048
  return;
553
1049
  }
554
- return X("identifier", q);
1050
+ return Z("identifier", W);
555
1051
  },
556
1052
  identifierNameEscape: function() {
557
- if (J !== "u") throw Q(Y());
558
- Y();
1053
+ if (q !== "u") throw Q(X());
1054
+ X();
559
1055
  var e = fe();
560
1056
  switch (e) {
561
1057
  case "$":
562
1058
  case "_":
563
1059
  case "‌":
564
1060
  case "‍": break;
565
- default: if (!R.isIdContinueChar(e)) throw $();
1061
+ default: if (!j.isIdContinueChar(e)) throw _e();
566
1062
  }
567
- q += e, K = "identifierName";
1063
+ W += e, U = "identifierName";
568
1064
  },
569
1065
  sign: function() {
570
- switch (J) {
1066
+ switch (q) {
571
1067
  case ".":
572
- q = Y(), K = "decimalPointLeading";
1068
+ W = X(), U = "decimalPointLeading";
573
1069
  return;
574
1070
  case "0":
575
- q = Y(), K = "zero";
1071
+ W = X(), U = "zero";
576
1072
  return;
577
1073
  case "1":
578
1074
  case "2":
@@ -583,231 +1079,231 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
583
1079
  case "7":
584
1080
  case "8":
585
1081
  case "9":
586
- q = Y(), K = "decimalInteger";
1082
+ W = X(), U = "decimalInteger";
587
1083
  return;
588
- case "I": return Y(), Z("nfinity"), X("numeric", oe * Infinity);
589
- case "N": return Y(), Z("aN"), X("numeric", NaN);
1084
+ case "I": return X(), le("nfinity"), Z("numeric", K * Infinity);
1085
+ case "N": return X(), le("aN"), Z("numeric", NaN);
590
1086
  }
591
- throw Q(Y());
1087
+ throw Q(X());
592
1088
  },
593
1089
  zero: function() {
594
- switch (J) {
1090
+ switch (q) {
595
1091
  case ".":
596
- q += Y(), K = "decimalPoint";
1092
+ W += X(), U = "decimalPoint";
597
1093
  return;
598
1094
  case "e":
599
1095
  case "E":
600
- q += Y(), K = "decimalExponent";
1096
+ W += X(), U = "decimalExponent";
601
1097
  return;
602
1098
  case "x":
603
1099
  case "X":
604
- q += Y(), K = "hexadecimal";
1100
+ W += X(), U = "hexadecimal";
605
1101
  return;
606
1102
  }
607
- return X("numeric", oe * 0);
1103
+ return Z("numeric", K * 0);
608
1104
  },
609
1105
  decimalInteger: function() {
610
- switch (J) {
1106
+ switch (q) {
611
1107
  case ".":
612
- q += Y(), K = "decimalPoint";
1108
+ W += X(), U = "decimalPoint";
613
1109
  return;
614
1110
  case "e":
615
1111
  case "E":
616
- q += Y(), K = "decimalExponent";
1112
+ W += X(), U = "decimalExponent";
617
1113
  return;
618
1114
  }
619
- if (R.isDigit(J)) {
620
- q += Y();
1115
+ if (j.isDigit(q)) {
1116
+ W += X();
621
1117
  return;
622
1118
  }
623
- return X("numeric", oe * Number(q));
1119
+ return Z("numeric", K * Number(W));
624
1120
  },
625
1121
  decimalPointLeading: function() {
626
- if (R.isDigit(J)) {
627
- q += Y(), K = "decimalFraction";
1122
+ if (j.isDigit(q)) {
1123
+ W += X(), U = "decimalFraction";
628
1124
  return;
629
1125
  }
630
- throw Q(Y());
1126
+ throw Q(X());
631
1127
  },
632
1128
  decimalPoint: function() {
633
- switch (J) {
1129
+ switch (q) {
634
1130
  case "e":
635
1131
  case "E":
636
- q += Y(), K = "decimalExponent";
1132
+ W += X(), U = "decimalExponent";
637
1133
  return;
638
1134
  }
639
- if (R.isDigit(J)) {
640
- q += Y(), K = "decimalFraction";
1135
+ if (j.isDigit(q)) {
1136
+ W += X(), U = "decimalFraction";
641
1137
  return;
642
1138
  }
643
- return X("numeric", oe * Number(q));
1139
+ return Z("numeric", K * Number(W));
644
1140
  },
645
1141
  decimalFraction: function() {
646
- switch (J) {
1142
+ switch (q) {
647
1143
  case "e":
648
1144
  case "E":
649
- q += Y(), K = "decimalExponent";
1145
+ W += X(), U = "decimalExponent";
650
1146
  return;
651
1147
  }
652
- if (R.isDigit(J)) {
653
- q += Y();
1148
+ if (j.isDigit(q)) {
1149
+ W += X();
654
1150
  return;
655
1151
  }
656
- return X("numeric", oe * Number(q));
1152
+ return Z("numeric", K * Number(W));
657
1153
  },
658
1154
  decimalExponent: function() {
659
- switch (J) {
1155
+ switch (q) {
660
1156
  case "+":
661
1157
  case "-":
662
- q += Y(), K = "decimalExponentSign";
1158
+ W += X(), U = "decimalExponentSign";
663
1159
  return;
664
1160
  }
665
- if (R.isDigit(J)) {
666
- q += Y(), K = "decimalExponentInteger";
1161
+ if (j.isDigit(q)) {
1162
+ W += X(), U = "decimalExponentInteger";
667
1163
  return;
668
1164
  }
669
- throw Q(Y());
1165
+ throw Q(X());
670
1166
  },
671
1167
  decimalExponentSign: function() {
672
- if (R.isDigit(J)) {
673
- q += Y(), K = "decimalExponentInteger";
1168
+ if (j.isDigit(q)) {
1169
+ W += X(), U = "decimalExponentInteger";
674
1170
  return;
675
1171
  }
676
- throw Q(Y());
1172
+ throw Q(X());
677
1173
  },
678
1174
  decimalExponentInteger: function() {
679
- if (R.isDigit(J)) {
680
- q += Y();
1175
+ if (j.isDigit(q)) {
1176
+ W += X();
681
1177
  return;
682
1178
  }
683
- return X("numeric", oe * Number(q));
1179
+ return Z("numeric", K * Number(W));
684
1180
  },
685
1181
  hexadecimal: function() {
686
- if (R.isHexDigit(J)) {
687
- q += Y(), K = "hexadecimalInteger";
1182
+ if (j.isHexDigit(q)) {
1183
+ W += X(), U = "hexadecimalInteger";
688
1184
  return;
689
1185
  }
690
- throw Q(Y());
1186
+ throw Q(X());
691
1187
  },
692
1188
  hexadecimalInteger: function() {
693
- if (R.isHexDigit(J)) {
694
- q += Y();
1189
+ if (j.isHexDigit(q)) {
1190
+ W += X();
695
1191
  return;
696
1192
  }
697
- return X("numeric", oe * Number(q));
1193
+ return Z("numeric", K * Number(W));
698
1194
  },
699
1195
  string: function() {
700
- switch (J) {
1196
+ switch (q) {
701
1197
  case "\\":
702
- Y(), q += ue();
1198
+ X(), W += ue();
703
1199
  return;
704
1200
  case "\"":
705
- if (ae) return Y(), X("string", q);
706
- q += Y();
1201
+ if (G) return X(), Z("string", W);
1202
+ W += X();
707
1203
  return;
708
1204
  case "'":
709
- if (!ae) return Y(), X("string", q);
710
- q += Y();
1205
+ if (!G) return X(), Z("string", W);
1206
+ W += X();
711
1207
  return;
712
1208
  case "\n":
713
- case "\r": throw Q(Y());
1209
+ case "\r": throw Q(X());
714
1210
  case "\u2028":
715
1211
  case "\u2029":
716
- _e(J);
1212
+ ve(q);
717
1213
  break;
718
- case void 0: throw Q(Y());
1214
+ case void 0: throw Q(X());
719
1215
  }
720
- q += Y();
1216
+ W += X();
721
1217
  },
722
1218
  start: function() {
723
- switch (J) {
1219
+ switch (q) {
724
1220
  case "{":
725
- case "[": return X("punctuator", Y());
1221
+ case "[": return Z("punctuator", X());
726
1222
  }
727
- K = "value";
1223
+ U = "value";
728
1224
  },
729
1225
  beforePropertyName: function() {
730
- switch (J) {
1226
+ switch (q) {
731
1227
  case "$":
732
1228
  case "_":
733
- q = Y(), K = "identifierName";
1229
+ W = X(), U = "identifierName";
734
1230
  return;
735
1231
  case "\\":
736
- Y(), K = "identifierNameStartEscape";
1232
+ X(), U = "identifierNameStartEscape";
737
1233
  return;
738
- case "}": return X("punctuator", Y());
1234
+ case "}": return Z("punctuator", X());
739
1235
  case "\"":
740
1236
  case "'":
741
- ae = Y() === "\"", K = "string";
1237
+ G = X() === "\"", U = "string";
742
1238
  return;
743
1239
  }
744
- if (R.isIdStartChar(J)) {
745
- q += Y(), K = "identifierName";
1240
+ if (j.isIdStartChar(q)) {
1241
+ W += X(), U = "identifierName";
746
1242
  return;
747
1243
  }
748
- throw Q(Y());
1244
+ throw Q(X());
749
1245
  },
750
1246
  afterPropertyName: function() {
751
- if (J === ":") return X("punctuator", Y());
752
- throw Q(Y());
1247
+ if (q === ":") return Z("punctuator", X());
1248
+ throw Q(X());
753
1249
  },
754
1250
  beforePropertyValue: function() {
755
- K = "value";
1251
+ U = "value";
756
1252
  },
757
1253
  afterPropertyValue: function() {
758
- switch (J) {
1254
+ switch (q) {
759
1255
  case ",":
760
- case "}": return X("punctuator", Y());
1256
+ case "}": return Z("punctuator", X());
761
1257
  }
762
- throw Q(Y());
1258
+ throw Q(X());
763
1259
  },
764
1260
  beforeArrayValue: function() {
765
- if (J === "]") return X("punctuator", Y());
766
- K = "value";
1261
+ if (q === "]") return Z("punctuator", X());
1262
+ U = "value";
767
1263
  },
768
1264
  afterArrayValue: function() {
769
- switch (J) {
1265
+ switch (q) {
770
1266
  case ",":
771
- case "]": return X("punctuator", Y());
1267
+ case "]": return Z("punctuator", X());
772
1268
  }
773
- throw Q(Y());
1269
+ throw Q(X());
774
1270
  },
775
1271
  end: function() {
776
- throw Q(Y());
1272
+ throw Q(X());
777
1273
  }
778
1274
  };
779
- function X(e, t) {
1275
+ function Z(e, t) {
780
1276
  return {
781
1277
  type: e,
782
1278
  value: t,
783
- line: H,
784
- column: U
1279
+ line: I,
1280
+ column: L
785
1281
  };
786
1282
  }
787
- function Z(e) {
1283
+ function le(e) {
788
1284
  for (var t = 0, n = e; t < n.length; t += 1) {
789
1285
  var r = n[t];
790
- if (ce() !== r) throw Q(Y());
791
- Y();
1286
+ if (Y() !== r) throw Q(X());
1287
+ X();
792
1288
  }
793
1289
  }
794
1290
  function ue() {
795
- switch (ce()) {
796
- case "b": return Y(), "\b";
797
- case "f": return Y(), "\f";
798
- case "n": return Y(), "\n";
799
- case "r": return Y(), "\r";
800
- case "t": return Y(), " ";
801
- case "v": return Y(), "\v";
1291
+ switch (Y()) {
1292
+ case "b": return X(), "\b";
1293
+ case "f": return X(), "\f";
1294
+ case "n": return X(), "\n";
1295
+ case "r": return X(), "\r";
1296
+ case "t": return X(), " ";
1297
+ case "v": return X(), "\v";
802
1298
  case "0":
803
- if (Y(), R.isDigit(ce())) throw Q(Y());
1299
+ if (X(), j.isDigit(Y())) throw Q(X());
804
1300
  return "\0";
805
- case "x": return Y(), de();
806
- case "u": return Y(), fe();
1301
+ case "x": return X(), de();
1302
+ case "u": return X(), fe();
807
1303
  case "\n":
808
1304
  case "\u2028":
809
- case "\u2029": return Y(), "";
810
- case "\r": return Y(), ce() === "\n" && Y(), "";
1305
+ case "\u2029": return X(), "";
1306
+ case "\r": return X(), Y() === "\n" && X(), "";
811
1307
  case "1":
812
1308
  case "2":
813
1309
  case "3":
@@ -816,34 +1312,34 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
816
1312
  case "6":
817
1313
  case "7":
818
1314
  case "8":
819
- case "9": throw Q(Y());
820
- case void 0: throw Q(Y());
1315
+ case "9": throw Q(X());
1316
+ case void 0: throw Q(X());
821
1317
  }
822
- return Y();
1318
+ return X();
823
1319
  }
824
1320
  function de() {
825
- var e = "", t = ce();
826
- if (!R.isHexDigit(t) || (e += Y(), t = ce(), !R.isHexDigit(t))) throw Q(Y());
827
- return e += Y(), String.fromCodePoint(parseInt(e, 16));
1321
+ var e = "", t = Y();
1322
+ if (!j.isHexDigit(t) || (e += X(), t = Y(), !j.isHexDigit(t))) throw Q(X());
1323
+ return e += X(), String.fromCodePoint(parseInt(e, 16));
828
1324
  }
829
1325
  function fe() {
830
1326
  for (var e = "", t = 4; t-- > 0;) {
831
- var n = ce();
832
- if (!R.isHexDigit(n)) throw Q(Y());
833
- e += Y();
1327
+ var n = Y();
1328
+ if (!j.isHexDigit(n)) throw Q(X());
1329
+ e += X();
834
1330
  }
835
1331
  return String.fromCodePoint(parseInt(e, 16));
836
1332
  }
837
1333
  var pe = {
838
1334
  start: function() {
839
- if (W.type === "eof") throw ge();
1335
+ if (R.type === "eof") throw ge();
840
1336
  me();
841
1337
  },
842
1338
  beforePropertyName: function() {
843
- switch (W.type) {
1339
+ switch (R.type) {
844
1340
  case "identifier":
845
1341
  case "string":
846
- G = W.value, B = "afterPropertyName";
1342
+ z = R.value, N = "afterPropertyName";
847
1343
  return;
848
1344
  case "punctuator":
849
1345
  he();
@@ -852,35 +1348,35 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
852
1348
  }
853
1349
  },
854
1350
  afterPropertyName: function() {
855
- if (W.type === "eof") throw ge();
856
- B = "beforePropertyValue";
1351
+ if (R.type === "eof") throw ge();
1352
+ N = "beforePropertyValue";
857
1353
  },
858
1354
  beforePropertyValue: function() {
859
- if (W.type === "eof") throw ge();
1355
+ if (R.type === "eof") throw ge();
860
1356
  me();
861
1357
  },
862
1358
  beforeArrayValue: function() {
863
- if (W.type === "eof") throw ge();
864
- if (W.type === "punctuator" && W.value === "]") {
1359
+ if (R.type === "eof") throw ge();
1360
+ if (R.type === "punctuator" && R.value === "]") {
865
1361
  he();
866
1362
  return;
867
1363
  }
868
1364
  me();
869
1365
  },
870
1366
  afterPropertyValue: function() {
871
- if (W.type === "eof") throw ge();
872
- switch (W.value) {
1367
+ if (R.type === "eof") throw ge();
1368
+ switch (R.value) {
873
1369
  case ",":
874
- B = "beforePropertyName";
1370
+ N = "beforePropertyName";
875
1371
  return;
876
1372
  case "}": he();
877
1373
  }
878
1374
  },
879
1375
  afterArrayValue: function() {
880
- if (W.type === "eof") throw ge();
881
- switch (W.value) {
1376
+ if (R.type === "eof") throw ge();
1377
+ switch (R.value) {
882
1378
  case ",":
883
- B = "beforeArrayValue";
1379
+ N = "beforeArrayValue";
884
1380
  return;
885
1381
  case "]": he();
886
1382
  }
@@ -889,9 +1385,9 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
889
1385
  };
890
1386
  function me() {
891
1387
  var e;
892
- switch (W.type) {
1388
+ switch (R.type) {
893
1389
  case "punctuator":
894
- switch (W.value) {
1390
+ switch (R.value) {
895
1391
  case "{":
896
1392
  e = {};
897
1393
  break;
@@ -901,42 +1397,42 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
901
1397
  case "null":
902
1398
  case "boolean":
903
1399
  case "numeric":
904
- case "string": e = W.value;
1400
+ case "string": e = R.value;
905
1401
  }
906
- if (ne === void 0) ne = e;
1402
+ if (B === void 0) B = e;
907
1403
  else {
908
- var t = V[V.length - 1];
909
- Array.isArray(t) ? t.push(e) : Object.defineProperty(t, G, {
1404
+ var t = P[P.length - 1];
1405
+ Array.isArray(t) ? t.push(e) : Object.defineProperty(t, z, {
910
1406
  value: e,
911
1407
  writable: !0,
912
1408
  enumerable: !0,
913
1409
  configurable: !0
914
1410
  });
915
1411
  }
916
- if (typeof e == "object" && e) V.push(e), B = Array.isArray(e) ? "beforeArrayValue" : "beforePropertyName";
1412
+ if (typeof e == "object" && e) P.push(e), N = Array.isArray(e) ? "beforeArrayValue" : "beforePropertyName";
917
1413
  else {
918
- var n = V[V.length - 1];
919
- B = n == null ? "end" : Array.isArray(n) ? "afterArrayValue" : "afterPropertyValue";
1414
+ var n = P[P.length - 1];
1415
+ N = n == null ? "end" : Array.isArray(n) ? "afterArrayValue" : "afterPropertyValue";
920
1416
  }
921
1417
  }
922
1418
  function he() {
923
- V.pop();
924
- var e = V[V.length - 1];
925
- B = e == null ? "end" : Array.isArray(e) ? "afterArrayValue" : "afterPropertyValue";
1419
+ P.pop();
1420
+ var e = P[P.length - 1];
1421
+ N = e == null ? "end" : Array.isArray(e) ? "afterArrayValue" : "afterPropertyValue";
926
1422
  }
927
1423
  function Q(e) {
928
- return ye(e === void 0 ? "JSON5: invalid end of input at " + H + ":" + U : "JSON5: invalid character '" + ve(e) + "' at " + H + ":" + U);
1424
+ return be(e === void 0 ? "JSON5: invalid end of input at " + I + ":" + L : "JSON5: invalid character '" + ye(e) + "' at " + I + ":" + L);
929
1425
  }
930
1426
  function ge() {
931
- return ye("JSON5: invalid end of input at " + H + ":" + U);
932
- }
933
- function $() {
934
- return U -= 5, ye("JSON5: invalid identifier character at " + H + ":" + U);
1427
+ return be("JSON5: invalid end of input at " + I + ":" + L);
935
1428
  }
936
- function _e(e) {
937
- console.warn("JSON5: '" + ve(e) + "' in strings is not valid ECMAScript; consider escaping");
1429
+ function _e() {
1430
+ return L -= 5, be("JSON5: invalid identifier character at " + I + ":" + L);
938
1431
  }
939
1432
  function ve(e) {
1433
+ console.warn("JSON5: '" + ye(e) + "' in strings is not valid ECMAScript; consider escaping");
1434
+ }
1435
+ function ye(e) {
940
1436
  var t = {
941
1437
  "'": "\\'",
942
1438
  "\"": "\\\"",
@@ -958,12 +1454,12 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
958
1454
  }
959
1455
  return e;
960
1456
  }
961
- function ye(e) {
1457
+ function be(e) {
962
1458
  var t = SyntaxError(e);
963
- return t.lineNumber = H, t.columnNumber = U, t;
1459
+ return t.lineNumber = I, t.columnNumber = L, t;
964
1460
  }
965
1461
  return {
966
- parse: re,
1462
+ parse: V,
967
1463
  stringify: function(e, t, n) {
968
1464
  var r = [], i = "", a, o, s = "", c;
969
1465
  if (typeof t == "object" && t && !Array.isArray(t) && (n = t.space, c = t.quote, t = t.replacer), typeof t == "function") o = t;
@@ -1010,7 +1506,7 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
1010
1506
  case "\"":
1011
1507
  t[a]++, r += a;
1012
1508
  continue;
1013
- case "\0": if (R.isDigit(e[i + 1])) {
1509
+ case "\0": if (j.isDigit(e[i + 1])) {
1014
1510
  r += "\\x00";
1015
1511
  continue;
1016
1512
  }
@@ -1058,8 +1554,8 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
1058
1554
  function g(e) {
1059
1555
  if (e.length === 0) return m(e, !0);
1060
1556
  var t = String.fromCodePoint(e.codePointAt(0));
1061
- if (!R.isIdStartChar(t)) return m(e, !0);
1062
- for (var n = t.length; n < e.length; n++) if (!R.isIdContinueChar(String.fromCodePoint(e.codePointAt(n)))) return m(e, !0);
1557
+ if (!j.isIdStartChar(t)) return m(e, !0);
1558
+ for (var n = t.length; n < e.length; n++) if (!j.isIdContinueChar(String.fromCodePoint(e.codePointAt(n)))) return m(e, !0);
1063
1559
  return e;
1064
1560
  }
1065
1561
  function _(e) {
@@ -1083,7 +1579,7 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
1083
1579
  }
1084
1580
  };
1085
1581
  }));
1086
- })))(), 1), C = {
1582
+ })))(), 1), Te = {
1087
1583
  ball: 1,
1088
1584
  red: 2,
1089
1585
  blue: 4,
@@ -1097,36 +1593,36 @@ var x = "3de72bdcf92ccb0d235a", S = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t)
1097
1593
  c2: 1073741824,
1098
1594
  c3: -2147483648,
1099
1595
  all: 63
1100
- }, w = (e) => {
1596
+ }, Ee = (e) => {
1101
1597
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Expected an object");
1102
1598
  return e;
1103
- }, T = (e, t, n = -4096, r = 4096) => {
1599
+ }, $ = (e, t, n = -4096, r = 4096) => {
1104
1600
  let i = e === void 0 ? t : e;
1105
1601
  if (typeof i != "number" || !Number.isFinite(i) || i < n || i > r) throw Error(`Number must be between ${n} and ${r}`);
1106
1602
  return i;
1107
- }, E = (e, t = [0, 0]) => {
1603
+ }, De = (e, t = [0, 0]) => {
1108
1604
  if (e === void 0) return [...t];
1109
1605
  if (!Array.isArray(e) || e.length !== 2) throw Error("Expected [x, y]");
1110
- return [T(e[0], 0), T(e[1], 0)];
1111
- }, D = (e, t) => {
1606
+ return [$(e[0], 0), $(e[1], 0)];
1607
+ }, Oe = (e, t) => {
1112
1608
  if (e === void 0) return [];
1113
1609
  if (!Array.isArray(e) || e.length > t) throw Error(`Array limit: ${t}`);
1114
1610
  return e;
1115
1611
  };
1116
- function O(e, t) {
1117
- return e === void 0 ? t : typeof e == "number" ? T(e, t, -2147483648, 4294967295) | 0 : D(e, 16).reduce((e, t) => {
1118
- if (typeof t != "string" || !Object.hasOwn(C, t)) throw Error("Unknown collision flag");
1119
- return e | C[t];
1612
+ function ke(e, t) {
1613
+ return e === void 0 ? t : typeof e == "number" ? $(e, t, -2147483648, 4294967295) | 0 : Oe(e, 16).reduce((e, t) => {
1614
+ if (typeof t != "string" || !Object.hasOwn(Te, t)) throw Error("Unknown collision flag");
1615
+ return e | Te[t];
1120
1616
  }, 0);
1121
1617
  }
1122
- function k(e, t = "FFFFFF") {
1618
+ function Ae(e, t = "FFFFFF") {
1123
1619
  if (e === void 0) return t;
1124
1620
  if (e === "transparent") return e;
1125
- if (Array.isArray(e) && e.length === 3) return e.map((e) => Math.round(T(e, 0, 0, 255)).toString(16).padStart(2, "0")).join("");
1621
+ if (Array.isArray(e) && e.length === 3) return e.map((e) => Math.round($(e, 0, 0, 255)).toString(16).padStart(2, "0")).join("");
1126
1622
  if (typeof e == "string" && /^[0-9a-f]{6}$/i.test(e)) return e;
1127
1623
  throw Error("Invalid color");
1128
1624
  }
1129
- var A = Object.fromEntries(Object.entries({
1625
+ var je = Object.fromEntries(Object.entries({
1130
1626
  root: "version physicsMode name width height maxViewWidth cameraFollow spawnDistance canBeStored kickOffReset bg traits vertexes segments goals discs planes joints redSpawnPoints blueSpawnPoints playerPhysics ballPhysics",
1131
1627
  bg: "type width height kickOffRadius cornerRadius goalLine color",
1132
1628
  vertexes: "trait x y bCoef cMask cGroup",
@@ -1136,7 +1632,7 @@ var A = Object.fromEntries(Object.entries({
1136
1632
  goals: "trait p0 p1 team",
1137
1633
  joints: "trait d0 d1 length strength color",
1138
1634
  playerPhysics: "trait pos speed gravity radius invMass damping bCoef cGroup cMask color acceleration kickingAcceleration kickingDamping kickStrength kickback"
1139
- }).map(([e, t]) => [e, new Set(t.split(" "))])), j = new Set([
1635
+ }).map(([e, t]) => [e, new Set(t.split(" "))])), Me = new Set([
1140
1636
  "vertexes",
1141
1637
  "segments",
1142
1638
  "discs",
@@ -1144,15 +1640,15 @@ var A = Object.fromEntries(Object.entries({
1144
1640
  "goals",
1145
1641
  "joints",
1146
1642
  "playerPhysics"
1147
- ].flatMap((e) => [...A[e]]));
1148
- function M(e) {
1643
+ ].flatMap((e) => [...je[e]]));
1644
+ function Ne(e) {
1149
1645
  let t = [], n = (e, t) => {
1150
1646
  let n = t.length > 80 ? t.slice(0, 80) + "…" : t;
1151
1647
  return e + (/^[A-Za-z_$][\w$]*$/.test(n) ? "." + n : "[" + JSON.stringify(n) + "]");
1152
1648
  }, r = (e, r, i) => {
1153
1649
  if (e && typeof e == "object" && !Array.isArray(e)) for (let a of Object.keys(e)) r.has(a) || (t.length < 64 ? t.push("Unsupported stadium field: " + n(i, a)) : t.length === 64 && t.push("Additional unsupported stadium fields omitted."));
1154
1650
  };
1155
- r(e, A.root, "$"), r(e.bg, A.bg, "$.bg");
1651
+ r(e, je.root, "$"), r(e.bg, je.bg, "$.bg");
1156
1652
  for (let t of [
1157
1653
  "vertexes",
1158
1654
  "segments",
@@ -1162,68 +1658,68 @@ function M(e) {
1162
1658
  "joints"
1163
1659
  ]) {
1164
1660
  let n = e[t];
1165
- Array.isArray(n) && n.forEach((e, n) => r(e, A[t], "$." + t + "[" + n + "]"));
1661
+ Array.isArray(n) && n.forEach((e, n) => r(e, je[t], "$." + t + "[" + n + "]"));
1166
1662
  }
1167
- if (r(e.ballPhysics, A.discs, "$.ballPhysics"), r(e.playerPhysics, A.playerPhysics, "$.playerPhysics"), e.traits && typeof e.traits == "object" && !Array.isArray(e.traits)) for (let [t, i] of Object.entries(e.traits)) r(i, j, n("$.traits", t));
1663
+ if (r(e.ballPhysics, je.discs, "$.ballPhysics"), r(e.playerPhysics, je.playerPhysics, "$.playerPhysics"), e.traits && typeof e.traits == "object" && !Array.isArray(e.traits)) for (let [t, i] of Object.entries(e.traits)) r(i, Me, n("$.traits", t));
1168
1664
  return t;
1169
1665
  }
1170
- function N(e, t, n, r, i) {
1666
+ function Pe(e, t, n, r, i) {
1171
1667
  let a = e === "hbs" ? 1 : Math.ceil(2 * Math.SQRT2 * 100 / Math.min(10, i));
1172
1668
  if ((t + 32) * (n + t + 32 + r) * a > 2e6) throw Error("Stadium collision complexity exceeds the room budget");
1173
1669
  }
1174
- function P(e) {
1670
+ function Fe(e) {
1175
1671
  if (new TextEncoder().encode(e).length > 262144) throw Error("Stadium exceeds 256 KB");
1176
- let t = w(S.default.parse(e));
1672
+ let t = Ee(we.default.parse(e));
1177
1673
  if (t.physicsMode !== void 0 && t.physicsMode !== "hbs" && t.physicsMode !== "substeps") throw Error("Invalid physics mode");
1178
1674
  let n = t.physicsMode === "substeps" ? "substeps" : "hbs";
1179
1675
  if (t.version !== void 0 && t.version !== 1) throw Error("Unsupported stadium version");
1180
- let r = t.traits === void 0 ? {} : w(t.traits), i = (e) => {
1181
- let t = w(e);
1676
+ let r = t.traits === void 0 ? {} : Ee(t.traits), i = (e) => {
1677
+ let t = Ee(e);
1182
1678
  if (t.trait === void 0) return t;
1183
1679
  if (typeof t.trait != "string" || !Object.hasOwn(r, t.trait)) throw Error("Unknown trait");
1184
1680
  return {
1185
- ...w(r[t.trait]),
1681
+ ...Ee(r[t.trait]),
1186
1682
  ...t
1187
1683
  };
1188
1684
  }, a = (e, t = !1) => ({
1189
- pos: E(e.pos),
1190
- speed: E(e.speed),
1191
- gravity: E(e.gravity),
1192
- radius: T(e.radius, 10, .5, 100),
1193
- invMass: T(e.invMass, 1, 0, 8192),
1194
- damping: T(e.damping, .99, 0, 8192),
1195
- bCoef: T(e.bCoef, .5, -1, 8192),
1196
- cGroup: O(e.cGroup, t ? 193 : 63),
1197
- cMask: O(e.cMask, 63),
1198
- color: k(e.color)
1199
- }), o = D(t.discs, 63).map((e) => a(i(e)));
1685
+ pos: De(e.pos),
1686
+ speed: De(e.speed),
1687
+ gravity: De(e.gravity),
1688
+ radius: $(e.radius, 10, .5, 100),
1689
+ invMass: $(e.invMass, 1, 0, 8192),
1690
+ damping: $(e.damping, .99, 0, 8192),
1691
+ bCoef: $(e.bCoef, .5, -1, 8192),
1692
+ cGroup: ke(e.cGroup, t ? 193 : 63),
1693
+ cMask: ke(e.cMask, 63),
1694
+ color: Ae(e.color)
1695
+ }), o = Oe(t.discs, 63).map((e) => a(i(e)));
1200
1696
  if (t.ballPhysics !== "disc0") {
1201
1697
  let e = a(t.ballPhysics === void 0 ? {} : i(t.ballPhysics), !0);
1202
1698
  e.cGroup |= 192, o.unshift(e);
1203
1699
  } else if (!o.length) throw Error("disc0 needs a disc");
1204
- let s = D(t.vertexes, 1024).map((e) => i(e)), c = [], l = [], u = M(t);
1700
+ let s = Oe(t.vertexes, 1024).map((e) => i(e)), c = [], l = [], u = Ne(t);
1205
1701
  for (let e of s) c.push({
1206
- a: [T(e.x, 0), T(e.y, 0)],
1207
- b: [T(e.x, 0), T(e.y, 0)],
1208
- bCoef: T(e.bCoef, 1, -1, 8192),
1209
- cGroup: O(e.cGroup, 32),
1210
- cMask: O(e.cMask, 63),
1702
+ a: [$(e.x, 0), $(e.y, 0)],
1703
+ b: [$(e.x, 0), $(e.y, 0)],
1704
+ bCoef: $(e.bCoef, 1, -1, 8192),
1705
+ cGroup: ke(e.cGroup, 32),
1706
+ cMask: ke(e.cMask, 63),
1211
1707
  bias: 0,
1212
1708
  color: "transparent",
1213
1709
  vis: !1
1214
1710
  });
1215
1711
  let d = [...c];
1216
- for (let e of D(t.segments, 1024)) {
1217
- let t = i(e), n = T(t.v0, -1, 0, s.length - 1), r = T(t.v1, -1, 0, s.length - 1);
1712
+ for (let e of Oe(t.segments, 1024)) {
1713
+ let t = i(e), n = $(t.v0, -1, 0, s.length - 1), r = $(t.v1, -1, 0, s.length - 1);
1218
1714
  if (!Number.isInteger(n) || !Number.isInteger(r)) throw Error("Vertex indices must be integers");
1219
- let a = [T(s[n].x, 0), T(s[n].y, 0)], o = [T(s[r].x, 0), T(s[r].y, 0)], u = {
1220
- bCoef: T(t.bCoef, 1, -1, 8192),
1221
- cGroup: O(t.cGroup, 32),
1222
- cMask: O(t.cMask, 63),
1223
- bias: T(t.bias, 0, -100, 100),
1224
- color: k(t.color, "000000"),
1715
+ let a = [$(s[n].x, 0), $(s[n].y, 0)], o = [$(s[r].x, 0), $(s[r].y, 0)], u = {
1716
+ bCoef: $(t.bCoef, 1, -1, 8192),
1717
+ cGroup: ke(t.cGroup, 32),
1718
+ cMask: ke(t.cMask, 63),
1719
+ bias: $(t.bias, 0, -100, 100),
1720
+ color: Ae(t.color, "000000"),
1225
1721
  vis: t.vis !== !1
1226
- }, f = t.curveF === void 0 ? T(t.curve, 0, -359, 359) : 2 * Math.atan2(1, T(t.curveF, 0, -1e8, 1e8)) * 180 / Math.PI;
1722
+ }, f = t.curveF === void 0 ? $(t.curve, 0, -359, 359) : 2 * Math.atan2(1, $(t.curveF, 0, -1e8, 1e8)) * 180 / Math.PI;
1227
1723
  if (Math.abs(f) < 1e-4) {
1228
1724
  let e = {
1229
1725
  a,
@@ -1235,9 +1731,9 @@ function P(e) {
1235
1731
  }
1236
1732
  let p = f * Math.PI / 180, m = o[0] - a[0], h = o[1] - a[1];
1237
1733
  if (Math.hypot(m, h) < .001) throw Error("Arc endpoints overlap");
1238
- let g = 1 / (2 * Math.tan(p / 2)), _ = [(a[0] + o[0]) / 2 - h * g, (a[1] + o[1]) / 2 + m * g], v = Math.hypot(a[0] - _[0], a[1] - _[1]), y = Math.atan2(a[1] - _[1], a[0] - _[0]), b = Math.ceil(Math.abs(p) / Math.max(1e-8, 2 * Math.acos(Math.max(-1, 1 - .15 / v))));
1239
- if (c.length + b > 4096) throw Error("Compiled geometry exceeds 4096 segments");
1240
- let x = {
1734
+ let g = 1 / (2 * Math.tan(p / 2)), _ = [(a[0] + o[0]) / 2 - h * g, (a[1] + o[1]) / 2 + m * g], v = Math.hypot(a[0] - _[0], a[1] - _[1]), y = Math.atan2(a[1] - _[1], a[0] - _[0]), ee = Math.ceil(Math.abs(p) / Math.max(1e-8, 2 * Math.acos(Math.max(-1, 1 - .15 / v))));
1735
+ if (c.length + ee > 4096) throw Error("Compiled geometry exceeds 4096 segments");
1736
+ let b = {
1241
1737
  a,
1242
1738
  b: o,
1243
1739
  ...u,
@@ -1247,16 +1743,16 @@ function P(e) {
1247
1743
  sweep: p,
1248
1744
  major: t.curveF === void 0 ? Math.abs(f) > 180 : Number(t.curveF) <= 0
1249
1745
  };
1250
- l.push(x), d.push(x);
1251
- let S = a;
1252
- for (let e = 1; e <= b; e++) {
1253
- let t = e === b ? o : [_[0] + v * Math.cos(y + p * e / b), _[1] + v * Math.sin(y + p * e / b)];
1746
+ l.push(b), d.push(b);
1747
+ let x = a;
1748
+ for (let e = 1; e <= ee; e++) {
1749
+ let t = e === ee ? o : [_[0] + v * Math.cos(y + p * e / ee), _[1] + v * Math.sin(y + p * e / ee)];
1254
1750
  c.push({
1255
- a: S,
1751
+ a: x,
1256
1752
  b: t,
1257
1753
  ...u,
1258
1754
  renderOnly: !0
1259
- }), S = t;
1755
+ }), x = t;
1260
1756
  }
1261
1757
  }
1262
1758
  if (c.length > 4096) throw Error("Compiled geometry exceeds 4096 segments");
@@ -1268,57 +1764,57 @@ function P(e) {
1268
1764
  damping: f.damping ?? .96,
1269
1765
  cGroup: f.cGroup ?? 0
1270
1766
  }),
1271
- acceleration: T(f.acceleration, .1, -8192, 8192),
1272
- kickingAcceleration: T(f.kickingAcceleration, .07, -8192, 8192),
1273
- kickingDamping: T(f.kickingDamping, .96, 0, 8192),
1274
- kickStrength: T(f.kickStrength, 5, -8192, 8192),
1275
- kickback: T(f.kickback, 0, -8192, 8192)
1767
+ acceleration: $(f.acceleration, .1, -8192, 8192),
1768
+ kickingAcceleration: $(f.kickingAcceleration, .07, -8192, 8192),
1769
+ kickingDamping: $(f.kickingDamping, .96, 0, 8192),
1770
+ kickStrength: $(f.kickStrength, 5, -8192, 8192),
1771
+ kickback: $(f.kickback, 0, -8192, 8192)
1276
1772
  };
1277
- N(n, o.length, c.length, D(t.planes, 64).length + D(t.joints, 128).length, Math.min(p.radius, ...o.map((e) => e.radius)));
1278
- let m = t.bg === void 0 ? {} : w(t.bg);
1773
+ Pe(n, o.length, c.length, Oe(t.planes, 64).length + Oe(t.joints, 128).length, Math.min(p.radius, ...o.map((e) => e.radius)));
1774
+ let m = t.bg === void 0 ? {} : Ee(t.bg);
1279
1775
  return {
1280
1776
  version: 1,
1281
1777
  physicsMode: n,
1282
1778
  name: typeof t.name == "string" ? t.name.slice(0, 64) : "Untitled stadium",
1283
1779
  canBeStored: t.canBeStored !== !1,
1284
- width: T(t.width, 520, 100, 2048),
1285
- height: T(t.height, 300, 80, 2048),
1286
- maxViewWidth: T(t.maxViewWidth, 0, 0, 4096),
1780
+ width: $(t.width, 520, 100, 2048),
1781
+ height: $(t.height, 300, 80, 2048),
1782
+ maxViewWidth: $(t.maxViewWidth, 0, 0, 4096),
1287
1783
  cameraFollow: t.cameraFollow === "player" ? "player" : "ball",
1288
1784
  bg: {
1289
1785
  type: m.type === "grass" ? "grass" : m.type === "hockey" ? "hockey" : "none",
1290
- cornerRadius: T(m.cornerRadius, 0, 0, 500),
1291
- goalLine: T(m.goalLine, 0, 0, 2048),
1292
- width: T(m.width, 0, 0, 2048),
1293
- height: T(m.height, 0, 0, 2048),
1294
- color: k(m.color, "718C5A"),
1295
- kickOffRadius: T(m.kickOffRadius, 0, 0, 500)
1786
+ cornerRadius: $(m.cornerRadius, 0, 0, 500),
1787
+ goalLine: $(m.goalLine, 0, 0, 2048),
1788
+ width: $(m.width, 0, 0, 2048),
1789
+ height: $(m.height, 0, 0, 2048),
1790
+ color: Ae(m.color, "718C5A"),
1791
+ kickOffRadius: $(m.kickOffRadius, 0, 0, 500)
1296
1792
  },
1297
1793
  discs: o,
1298
1794
  segments: c,
1299
1795
  arcs: l,
1300
1796
  colliders: d,
1301
1797
  player: p,
1302
- spawnDistance: T(t.spawnDistance, 200, 0, 1500),
1798
+ spawnDistance: $(t.spawnDistance, 200, 0, 1500),
1303
1799
  kickOffReset: t.kickOffReset === "full" ? "full" : "partial",
1304
- redSpawnPoints: D(t.redSpawnPoints, 32).map((e) => E(e)),
1305
- blueSpawnPoints: D(t.blueSpawnPoints, 32).map((e) => E(e)),
1800
+ redSpawnPoints: Oe(t.redSpawnPoints, 32).map((e) => De(e)),
1801
+ blueSpawnPoints: Oe(t.blueSpawnPoints, 32).map((e) => De(e)),
1306
1802
  warnings: u,
1307
- planes: D(t.planes, 64).map((e) => {
1308
- let t = i(e), n = E(t.normal);
1803
+ planes: Oe(t.planes, 64).map((e) => {
1804
+ let t = i(e), n = De(t.normal);
1309
1805
  if (Math.hypot(...n) < 1e-6) throw Error("Plane normal is zero");
1310
1806
  return {
1311
1807
  normal: n,
1312
- dist: T(t.dist, 0),
1313
- bCoef: T(t.bCoef, 1, -1, 8192),
1314
- cGroup: O(t.cGroup, 32),
1315
- cMask: O(t.cMask, 63)
1808
+ dist: $(t.dist, 0),
1809
+ bCoef: $(t.bCoef, 1, -1, 8192),
1810
+ cGroup: ke(t.cGroup, 32),
1811
+ cMask: ke(t.cMask, 63)
1316
1812
  };
1317
1813
  }),
1318
- goals: D(t.goals, 16).map((e) => {
1814
+ goals: Oe(t.goals, 16).map((e) => {
1319
1815
  let t = i(e);
1320
1816
  if (t.team !== "red" && t.team !== "blue") throw Error("Invalid goal team");
1321
- let n = E(t.p0), r = E(t.p1);
1817
+ let n = De(t.p0), r = De(t.p1);
1322
1818
  if (Math.hypot(r[0] - n[0], r[1] - n[1]) < 1) throw Error("Goal has zero length");
1323
1819
  return {
1324
1820
  p0: n,
@@ -1326,22 +1822,22 @@ function P(e) {
1326
1822
  team: t.team === "red" ? 1 : 2
1327
1823
  };
1328
1824
  }),
1329
- joints: D(t.joints, 128).map((e) => {
1330
- let t = i(e), n = T(t.d0, -1, 0, o.length - 1), r = T(t.d1, -1, 0, o.length - 1);
1825
+ joints: Oe(t.joints, 128).map((e) => {
1826
+ let t = i(e), n = $(t.d0, -1, 0, o.length - 1), r = $(t.d1, -1, 0, o.length - 1);
1331
1827
  if (!Number.isInteger(n) || !Number.isInteger(r) || n === r) throw Error("Invalid joint indices");
1332
- let a = Math.hypot(o[r].pos[0] - o[n].pos[0], o[r].pos[1] - o[n].pos[1]), s = t.length == null ? [a, a] : typeof t.length == "number" ? [t.length, t.length] : E(t.length);
1828
+ let a = Math.hypot(o[r].pos[0] - o[n].pos[0], o[r].pos[1] - o[n].pos[1]), s = t.length == null ? [a, a] : typeof t.length == "number" ? [t.length, t.length] : De(t.length);
1333
1829
  return {
1334
1830
  d0: n,
1335
1831
  d1: r,
1336
- min: T(s[0], 0, 0),
1337
- max: T(s[1], 0, 0),
1338
- strength: t.strength === void 0 || t.strength === "rigid" ? "rigid" : T(t.strength, 0, -8192, 8192),
1339
- color: k(t.color, "000000")
1832
+ min: $(s[0], 0, 0),
1833
+ max: $(s[1], 0, 0),
1834
+ strength: t.strength === void 0 || t.strength === "rigid" ? "rigid" : $(t.strength, 0, -8192, 8192),
1835
+ color: Ae(t.color, "000000")
1340
1836
  };
1341
1837
  })
1342
1838
  };
1343
1839
  }
1344
- function F(e = "Emerald Arena", t = 440, n = 220) {
1840
+ function Ie(e = "Emerald Arena", t = 440, n = 220) {
1345
1841
  let r = [
1346
1842
  [-t, -n],
1347
1843
  [t, -n],
@@ -1481,8 +1977,9 @@ function F(e = "Emerald Arena", t = 440, n = 220) {
1481
1977
  }
1482
1978
  }, null, 2);
1483
1979
  }
1484
- var ee = `ball2d-core/1/${x}`, I = class e {
1980
+ var Le = `ball2d-core/1/${Ce}`, Re = class e {
1485
1981
  core;
1982
+ terrain;
1486
1983
  stadium;
1487
1984
  source = "";
1488
1985
  colors = [];
@@ -1502,21 +1999,34 @@ var ee = `ball2d-core/1/${x}`, I = class e {
1502
1999
  lastGoal = 0;
1503
2000
  kickRate = 2;
1504
2001
  setKickRateLimit(e, t, n) {
1505
- this.kickRate = L(e, t, n), this.core.kick_limits(this.kickRate & 255, this.kickRate >>> 8 & 255, this.kickRate >>> 16);
2002
+ this.kickRate = ze(e, t, n), this.core.kick_limits(this.kickRate & 255, this.kickRate >>> 8 & 255, this.kickRate >>> 16);
1506
2003
  }
1507
2004
  constructor(e) {
1508
- this.core = e.exports;
2005
+ this.core = e.exports, this.terrain = new X(this.core);
2006
+ }
2007
+ configureSurface(e) {
2008
+ if (this.phase !== "lobby" && this.phase !== "finished") throw Error("Stop the match before configuring its surface");
2009
+ e === null ? this.terrain.disable() : this.terrain.configure(e);
2010
+ }
2011
+ setSurfaceWeather(e) {
2012
+ this.terrain.setWeather(e);
2013
+ }
2014
+ sampleSurface(e, t) {
2015
+ return this.terrain.sample(e, t);
2016
+ }
2017
+ get surfaceEnabled() {
2018
+ return this.terrain.enabled;
1509
2019
  }
1510
2020
  static async create(t, n) {
1511
- let r = t ?? await (await fetch("/core.wasm?v=3de72bdcf92ccb0d235a", { signal: n })).arrayBuffer();
1512
- if (Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", r))).map((e) => e.toString(16).padStart(2, "0")).join("") !== "18e0600cd78f6896249e672d14fefbc34e88826b1febf0b794dc5367f176e338") throw Error("Physics build changed. Refresh the page to load a matching version.");
2021
+ let r = t ?? await (await fetch("/core.wasm?v=edb227eac070ad86a151", { signal: n })).arrayBuffer();
2022
+ if (Array.from(new Uint8Array(await crypto.subtle.digest("SHA-256", r))).map((e) => e.toString(16).padStart(2, "0")).join("") !== "1229b1b4ba3892d6073fb85b3b6231282c2d81ee270808cb0acda874d49cb87e") throw Error("Physics build changed. Refresh the page to load a matching version.");
1513
2023
  return new e(await WebAssembly.instantiate(await WebAssembly.compile(r)));
1514
2024
  }
1515
2025
  get data() {
1516
2026
  return new Float64Array(this.core.memory.buffer, this.core.data_ptr(), this.core.count() * 18);
1517
2027
  }
1518
2028
  load(e) {
1519
- this.stadium = P(e), this.source = e, this.core.reset(), this.colors = [], this.core.physics_mode(+(this.stadium.physicsMode === "substeps")), this.tick = 0, this.elapsed = 0, this.red = this.blue = 0, this.phase = "lobby", this.paused = !1, this.resumeTicks = 0, this.countdown = 0, this.kickoffActive = !0;
2029
+ this.stadium = Fe(e), this.source = e, this.core.reset(), this.terrain.disable(), this.colors = [], this.core.physics_mode(+(this.stadium.physicsMode === "substeps")), this.tick = 0, this.elapsed = 0, this.red = this.blue = 0, this.phase = "lobby", this.paused = !1, this.resumeTicks = 0, this.countdown = 0, this.kickoffActive = !0;
1520
2030
  for (let e of this.stadium.discs) this.add(e);
1521
2031
  for (let e = 0; e < 32; e++) this.add(this.stadium.player, e + 1);
1522
2032
  for (let e of this.stadium.colliders) if ("center" in e) {
@@ -1577,8 +2087,8 @@ var ee = `ball2d-core/1/${x}`, I = class e {
1577
2087
  applyDiscProperties(e, t) {
1578
2088
  let n = this.data;
1579
2089
  if (this.phase === "lobby" || !Number.isInteger(e) || e < 0 || e >= this.colors.length || n[e * 18 + 12] > 0 && n[e * 18 + 13] === 0) return !1;
1580
- let r = b(t), i = !1;
1581
- for (let [t, a] of y) {
2090
+ let r = Se(t), i = !1;
2091
+ for (let [t, a] of xe) {
1582
2092
  let o = r[t];
1583
2093
  if (o === void 0) continue;
1584
2094
  let s = a === -1 ? this.colors[e] : n[e * 18 + a];
@@ -1588,9 +2098,9 @@ var ee = `ball2d-core/1/${x}`, I = class e {
1588
2098
  if (r.radius !== void 0) {
1589
2099
  let t = r.radius;
1590
2100
  for (let r = 0; r < this.colors.length; r++) r !== e && (t = Math.min(t, n[r * 18 + 4]));
1591
- N(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, t);
2101
+ Pe(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, t);
1592
2102
  }
1593
- for (let [t, i] of y) {
2103
+ for (let [t, i] of xe) {
1594
2104
  let a = r[t];
1595
2105
  a !== void 0 && (i === -1 ? this.colors[e] = a : n[e * 18 + i] = a);
1596
2106
  }
@@ -1664,8 +2174,13 @@ var ee = `ball2d-core/1/${x}`, I = class e {
1664
2174
  }
1665
2175
  this.timeLimit > 0 && this.elapsed >= this.timeLimit * 60 && this.red !== this.blue && this.finish();
1666
2176
  }
2177
+ snapshotSurface() {
2178
+ return this.terrain.snapshot();
2179
+ }
1667
2180
  snapshot() {
2181
+ let e = this.snapshotSurface();
1668
2182
  return {
2183
+ ...e.length ? { surface: e } : {},
1669
2184
  tick: this.tick,
1670
2185
  elapsed: this.elapsed,
1671
2186
  red: this.red,
@@ -1696,569 +2211,105 @@ var ee = `ball2d-core/1/${x}`, I = class e {
1696
2211
  for (let n = 0; n < e.discs.length; n += 18) if (e.discs[n + 4] < .5 || e.discs[n + 4] > 100 || e.discs[n + 5] < 0 || e.discs[n + 5] > 8192 || e.discs[n + 6] < 0 || e.discs[n + 6] > 8192 || e.discs[n + 7] < -1 || e.discs[n + 7] > 8192 || !t(e.discs[n + 10], 2147483647, -2147483648) || !t(e.discs[n + 11], 2147483647, -2147483648) || !t(e.discs[n + 13], 2) || !t(e.discs[n + 14], 31) || !t(e.discs[n + 15], 2047) || e.discs[n + 12] > 0 && (!Number.isInteger(e.discs[n + 17]) || e.discs[n + 17] < -255 || e.discs[n + 17] > 25500)) throw Error("Invalid disc properties");
1697
2212
  let n = 10;
1698
2213
  for (let t = 4; t < e.discs.length; t += 18) n = Math.min(n, e.discs[t]);
1699
- N(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, n), this.setKickRateLimit(e.kickRate & 255, e.kickRate >>> 8 & 255, e.kickRate >>> 16), this.tick = e.tick, this.elapsed = e.elapsed, this.red = e.red, this.blue = e.blue, this.phase = e.phase, this.paused = e.paused, this.resumeTicks = e.resumeTicks, this.countdown = e.countdown, this.kickoff = e.kickoff, this.kickoffActive = e.kickoffActive, this.scoreLimit = e.scoreLimit, this.timeLimit = e.timeLimit, this.data.set(e.discs), this.colors = [...e.colors];
2214
+ Pe(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, n), this.terrain.restore(e.surface === void 0 ? [] : e.surface), this.setKickRateLimit(e.kickRate & 255, e.kickRate >>> 8 & 255, e.kickRate >>> 16), this.tick = e.tick, this.elapsed = e.elapsed, this.red = e.red, this.blue = e.blue, this.phase = e.phase, this.paused = e.paused, this.resumeTicks = e.resumeTicks, this.countdown = e.countdown, this.kickoff = e.kickoff, this.kickoffActive = e.kickoffActive, this.scoreLimit = e.scoreLimit, this.timeLimit = e.timeLimit, this.data.set(e.discs), this.colors = [...e.colors];
1700
2215
  }
1701
2216
  };
1702
- function L(e, t, n) {
2217
+ function ze(e, t, n) {
1703
2218
  if (![
1704
2219
  e,
1705
2220
  t,
1706
2221
  n
1707
2222
  ].every(Number.isInteger)) throw Error("Invalid kick rate limit");
1708
2223
  return Math.max(0, Math.min(255, e)) | Math.max(0, Math.min(255, t)) << 8 | Math.max(0, Math.min(100, n)) << 16;
1709
- }
1710
- //#endregion
1711
- //#region src/client/network-runtime.ts
1712
- function R(e) {
1713
- let t = new URL(e);
1714
- if (!["http:", "https:"].includes(t.protocol) || t.username || t.password || t.pathname !== "/" || t.search || t.hash) throw Error("Expected an HTTP(S) service origin without credentials or a path");
1715
- return t.origin;
1716
- }
1717
- function z() {
1718
- return {
1719
- serviceOrigin: location.origin,
1720
- createWebSocket: (e) => new WebSocket(e),
1721
- createPeerConnection: (e) => new RTCPeerConnection(e)
1722
- };
1723
- }
1724
- //#endregion
1725
- //#region src/client/stadium-library.ts
1726
- var B = [
1727
- ["classic", "Classic"],
1728
- ["easy", "Easy"],
1729
- ["small", "Small"],
1730
- ["big", "Big"],
1731
- ["rounded", "Rounded"],
1732
- ["hockey", "Hockey"],
1733
- ["big_easy", "Big Easy"],
1734
- ["big_rounded", "Big Rounded"],
1735
- ["big_hockey", "Big Hockey"],
1736
- ["huge", "Huge"]
1737
- ];
1738
- function V(e) {
1739
- let t = /* @__PURE__ */ new Map();
1740
- return async (n) => {
1741
- let r = B.find(([e, t]) => e === n || t === n);
1742
- if (!r) throw Error("Unknown default stadium");
1743
- let i = t.get(r[0]);
1744
- return i || (i = (async () => {
1745
- let t = await e(`/stadiums/${r[0]}.hbs`);
1746
- if (!t.ok) throw Error("Could not load stadium");
1747
- let n = await t.text();
1748
- return P(n), n;
1749
- })(), t.set(r[0], i), i.catch(() => t.delete(r[0]))), i;
1750
- };
1751
- }
1752
- //#endregion
1753
- //#region src/client/host-runtime.ts
1754
- function te() {
1755
- let e = z(), t = (e, t) => fetch(e, t);
1756
- return {
1757
- network: e,
1758
- request: t,
1759
- loadEngine: (e) => I.create(void 0, e),
1760
- loadStadium: V((n) => t(new URL(n, e.serviceOrigin)))
1761
- };
1762
- }
1763
- //#endregion
1764
- //#region src/client/traffic.ts
1765
- var H = {
1766
- message: {
1767
- burst: 240,
1768
- perSecond: 160
1769
- },
1770
- action: {
1771
- burst: 12,
1772
- perSecond: 6
1773
- },
1774
- chat: {
1775
- burst: 4,
1776
- perSecond: 1
1777
- }
1778
- }, U = class {
1779
- peers = /* @__PURE__ */ new Map();
1780
- allow(e, t, n = performance.now()) {
1781
- let r = this.peers.get(e);
1782
- r || (r = {}, this.peers.set(e, r));
1783
- let { burst: i, perSecond: a } = H[t], o = r[t] ?? {
1784
- tokens: i,
1785
- at: n
1786
- };
1787
- return o.tokens = Math.min(i, o.tokens + Math.max(0, n - o.at) * a / 1e3), o.at = Math.max(o.at, n), r[t] = o, o.tokens < 1 ? !1 : (o.tokens--, !0);
1788
- }
1789
- delete(e) {
1790
- this.peers.delete(e);
1791
- }
1792
- clear() {
1793
- this.peers.clear();
1794
- }
1795
- }, W = Uint8Array, G = Uint16Array, ne = Int32Array, re = new W([
1796
- 0,
1797
- 0,
1798
- 0,
1799
- 0,
1800
- 0,
1801
- 0,
1802
- 0,
1803
- 0,
1804
- 1,
1805
- 1,
1806
- 1,
1807
- 1,
1808
- 2,
1809
- 2,
1810
- 2,
1811
- 2,
1812
- 3,
1813
- 3,
1814
- 3,
1815
- 3,
1816
- 4,
1817
- 4,
1818
- 4,
1819
- 4,
1820
- 5,
1821
- 5,
1822
- 5,
1823
- 5,
1824
- 0,
1825
- 0,
1826
- 0,
1827
- 0
1828
- ]), ie = new W([
1829
- 0,
1830
- 0,
1831
- 0,
1832
- 0,
1833
- 1,
1834
- 1,
1835
- 2,
1836
- 2,
1837
- 3,
1838
- 3,
1839
- 4,
1840
- 4,
1841
- 5,
1842
- 5,
1843
- 6,
1844
- 6,
1845
- 7,
1846
- 7,
1847
- 8,
1848
- 8,
1849
- 9,
1850
- 9,
1851
- 10,
1852
- 10,
1853
- 11,
1854
- 11,
1855
- 12,
1856
- 12,
1857
- 13,
1858
- 13,
1859
- 0,
1860
- 0
1861
- ]), K = new W([
1862
- 16,
1863
- 17,
1864
- 18,
1865
- 0,
1866
- 8,
1867
- 7,
1868
- 9,
1869
- 6,
1870
- 10,
1871
- 5,
1872
- 11,
1873
- 4,
1874
- 12,
1875
- 3,
1876
- 13,
1877
- 2,
1878
- 14,
1879
- 1,
1880
- 15
1881
- ]), q = function(e, t) {
1882
- for (var n = new G(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
1883
- for (var i = new ne(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
1884
- return {
1885
- b: n,
1886
- r: i
1887
- };
1888
- }, ae = q(re, 2), oe = ae.b, J = ae.r;
1889
- oe[28] = 258, J[258] = 28;
1890
- for (var se = q(ie, 0), ce = se.b, Y = se.r, le = new G(32768), X = 0; X < 32768; ++X) {
1891
- var Z = (X & 43690) >> 1 | (X & 21845) << 1;
1892
- Z = (Z & 52428) >> 2 | (Z & 13107) << 2, Z = (Z & 61680) >> 4 | (Z & 3855) << 4, le[X] = ((Z & 65280) >> 8 | (Z & 255) << 8) >> 1;
1893
- }
1894
- for (var ue = (function(e, t, n) {
1895
- for (var r = e.length, i = 0, a = new G(t); i < r; ++i) e[i] && ++a[e[i] - 1];
1896
- var o = new G(t);
1897
- for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
1898
- var s;
1899
- if (n) {
1900
- s = new G(1 << t);
1901
- var c = 15 - t;
1902
- for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, f = d | (1 << u) - 1; d <= f; ++d) s[le[d] >> c] = l;
1903
- } else for (s = new G(r), i = 0; i < r; ++i) e[i] && (s[i] = le[o[e[i] - 1]++] >> 15 - e[i]);
1904
- return s;
1905
- }), de = new W(288), X = 0; X < 144; ++X) de[X] = 8;
1906
- for (var X = 144; X < 256; ++X) de[X] = 9;
1907
- for (var X = 256; X < 280; ++X) de[X] = 7;
1908
- for (var X = 280; X < 288; ++X) de[X] = 8;
1909
- for (var fe = new W(32), X = 0; X < 32; ++X) fe[X] = 5;
1910
- var pe = /*#__PURE__*/ ue(de, 9, 0), me = /*#__PURE__*/ ue(de, 9, 1), he = /*#__PURE__*/ ue(fe, 5, 0), Q = /*#__PURE__*/ ue(fe, 5, 1), ge = function(e) {
1911
- for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
1912
- return t;
1913
- }, $ = function(e, t, n) {
1914
- var r = t / 8 | 0;
1915
- return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
1916
- }, _e = function(e, t) {
1917
- var n = t / 8 | 0;
1918
- return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
1919
- }, ve = function(e) {
1920
- return (e + 7) / 8 | 0;
1921
- }, ye = function(e, t, n) {
1922
- return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new W(e.subarray(t, n));
1923
- }, be = [
1924
- "unexpected EOF",
1925
- "invalid block type",
1926
- "invalid length/literal",
1927
- "invalid distance",
1928
- "stream finished",
1929
- "no stream handler",
1930
- ,
1931
- "no callback",
1932
- "invalid UTF-8 data",
1933
- "extra field too long",
1934
- "date not in range 1980-2099",
1935
- "filename too long",
1936
- "stream finishing",
1937
- "invalid zip data"
1938
- ], xe = function(e, t, n) {
1939
- var r = Error(t || be[e]);
1940
- if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, xe), !n) throw r;
1941
- return r;
1942
- }, Se = function(e, t, n, r) {
1943
- var i = e.length, a = r ? r.length : 0;
1944
- if (!i || t.f && !t.l) return n || new W(0);
1945
- var o = !n, s = o || t.i != 2, c = t.i;
1946
- o && (n = new W(i * 3));
1947
- var l = function(e) {
1948
- var t = n.length;
1949
- if (e > t) {
1950
- var r = new W(Math.max(t * 2, e));
1951
- r.set(n), n = r;
1952
- }
1953
- }, u = t.f || 0, d = t.p || 0, f = t.b || 0, p = t.l, m = t.d, h = t.m, g = t.n, _ = i * 8;
1954
- do {
1955
- if (!p) {
1956
- u = $(e, d, 1);
1957
- var v = $(e, d + 1, 3);
1958
- if (d += 3, !v) {
1959
- var y = ve(d) + 4, b = e[y - 4] | e[y - 3] << 8, x = y + b;
1960
- if (x > i) {
1961
- c && xe(0);
1962
- break;
1963
- }
1964
- s && l(f + b), n.set(e.subarray(y, x), f), t.b = f += b, t.p = d = x * 8, t.f = u;
1965
- continue;
1966
- }
1967
- if (v == 1) p = me, m = Q, h = 9, g = 5;
1968
- else if (v == 2) {
1969
- var S = $(e, d, 31) + 257, C = $(e, d + 10, 15) + 4, w = S + $(e, d + 5, 31) + 1;
1970
- d += 14;
1971
- for (var T = new W(w), E = new W(19), D = 0; D < C; ++D) E[K[D]] = $(e, d + D * 3, 7);
1972
- d += C * 3;
1973
- for (var O = ge(E), k = (1 << O) - 1, A = ue(E, O, 1), D = 0; D < w;) {
1974
- var j = A[$(e, d, k)];
1975
- d += j & 15;
1976
- var y = j >> 4;
1977
- if (y < 16) T[D++] = y;
1978
- else {
1979
- var M = 0, N = 0;
1980
- for (y == 16 ? (N = 3 + $(e, d, 3), d += 2, M = T[D - 1]) : y == 17 ? (N = 3 + $(e, d, 7), d += 3) : y == 18 && (N = 11 + $(e, d, 127), d += 7); N--;) T[D++] = M;
1981
- }
1982
- }
1983
- var P = T.subarray(0, S), F = T.subarray(S);
1984
- h = ge(P), g = ge(F), p = ue(P, h, 1), m = ue(F, g, 1);
1985
- } else xe(1);
1986
- if (d > _) {
1987
- c && xe(0);
1988
- break;
1989
- }
1990
- }
1991
- s && l(f + 131072);
1992
- for (var ee = (1 << h) - 1, I = (1 << g) - 1, L = d;; L = d) {
1993
- var M = p[_e(e, d) & ee], R = M >> 4;
1994
- if (d += M & 15, d > _) {
1995
- c && xe(0);
1996
- break;
1997
- }
1998
- if (M || xe(2), R < 256) n[f++] = R;
1999
- else if (R == 256) {
2000
- L = d, p = null;
2001
- break;
2002
- } else {
2003
- var z = R - 254;
2004
- if (R > 264) {
2005
- var D = R - 257, B = re[D];
2006
- z = $(e, d, (1 << B) - 1) + oe[D], d += B;
2007
- }
2008
- var V = m[_e(e, d) & I], te = V >> 4;
2009
- V || xe(3), d += V & 15;
2010
- var F = ce[te];
2011
- if (te > 3) {
2012
- var B = ie[te];
2013
- F += _e(e, d) & (1 << B) - 1, d += B;
2014
- }
2015
- if (d > _) {
2016
- c && xe(0);
2017
- break;
2018
- }
2019
- s && l(f + 131072);
2020
- var H = f + z;
2021
- if (f < F) {
2022
- var U = a - F, G = Math.min(F, H);
2023
- for (U + f < 0 && xe(3); f < G; ++f) n[f] = r[U + f];
2024
- }
2025
- for (; f < H; ++f) n[f] = n[f - F];
2026
- }
2027
- }
2028
- t.l = p, t.p = L, t.b = f, t.f = u, p && (u = 1, t.m = h, t.d = m, t.n = g);
2029
- } while (!u);
2030
- return f != n.length && o ? ye(n, 0, f) : n.subarray(0, f);
2031
- }, Ce = function(e, t, n) {
2032
- n <<= t & 7;
2033
- var r = t / 8 | 0;
2034
- e[r] |= n, e[r + 1] |= n >> 8;
2035
- }, we = function(e, t, n) {
2036
- n <<= t & 7;
2037
- var r = t / 8 | 0;
2038
- e[r] |= n, e[r + 1] |= n >> 8, e[r + 2] |= n >> 16;
2039
- }, Te = function(e, t) {
2040
- for (var n = [], r = 0; r < e.length; ++r) e[r] && n.push({
2041
- s: r,
2042
- f: e[r]
2043
- });
2044
- var i = n.length, a = n.slice();
2045
- if (!i) return {
2046
- t: Me,
2047
- l: 0
2048
- };
2049
- if (i == 1) {
2050
- var o = new W(n[0].s + 1);
2051
- return o[n[0].s] = 1, {
2052
- t: o,
2053
- l: 1
2054
- };
2055
- }
2056
- n.sort(function(e, t) {
2057
- return e.f - t.f;
2058
- }), n.push({
2059
- s: -1,
2060
- f: 25001
2061
- });
2062
- var s = n[0], c = n[1], l = 0, u = 1, d = 2;
2063
- for (n[0] = {
2064
- s: -1,
2065
- f: s.f + c.f,
2066
- l: s,
2067
- r: c
2068
- }; u != i - 1;) s = n[n[l].f < n[d].f ? l++ : d++], c = n[l != u && n[l].f < n[d].f ? l++ : d++], n[u++] = {
2069
- s: -1,
2070
- f: s.f + c.f,
2071
- l: s,
2072
- r: c
2073
- };
2074
- for (var f = a[0].s, r = 1; r < i; ++r) a[r].s > f && (f = a[r].s);
2075
- var p = new G(f + 1), m = Ee(n[u - 1], p, 0);
2076
- if (m > t) {
2077
- var r = 0, h = 0, g = m - t, _ = 1 << g;
2078
- for (a.sort(function(e, t) {
2079
- return p[t.s] - p[e.s] || e.f - t.f;
2080
- }); r < i; ++r) {
2081
- var v = a[r].s;
2082
- if (p[v] > t) h += _ - (1 << m - p[v]), p[v] = t;
2083
- else break;
2084
- }
2085
- for (h >>= g; h > 0;) {
2086
- var y = a[r].s;
2087
- p[y] < t ? h -= 1 << t - p[y]++ - 1 : ++r;
2088
- }
2089
- for (; r >= 0 && h; --r) {
2090
- var b = a[r].s;
2091
- p[b] == t && (--p[b], ++h);
2092
- }
2093
- m = t;
2094
- }
2224
+ }
2225
+ function Be(e) {
2226
+ let t = new URL(e);
2227
+ if (!["http:", "https:"].includes(t.protocol) || t.username || t.password || t.pathname !== "/" || t.search || t.hash) throw Error("Expected an HTTP(S) service origin without credentials or a path");
2228
+ return t.origin;
2229
+ }
2230
+ function Ve() {
2095
2231
  return {
2096
- t: new W(p),
2097
- l: m
2232
+ serviceOrigin: location.origin,
2233
+ signalingResume: !0,
2234
+ createWebSocket: (e) => new WebSocket(e),
2235
+ createPeerConnection: (e) => new RTCPeerConnection(e)
2098
2236
  };
2099
- }, Ee = function(e, t, n) {
2100
- return e.s == -1 ? Math.max(Ee(e.l, t, n + 1), Ee(e.r, t, n + 1)) : t[e.s] = n;
2101
- }, De = function(e) {
2102
- for (var t = e.length; t && !e[--t];);
2103
- for (var n = new G(++t), r = 0, i = e[0], a = 1, o = function(e) {
2104
- n[r++] = e;
2105
- }, s = 1; s <= t; ++s) if (e[s] == i && s != t) ++a;
2106
- else {
2107
- if (!i && a > 2) {
2108
- for (; a > 138; a -= 138) o(32754);
2109
- a > 2 && (o(a > 10 ? a - 11 << 5 | 28690 : a - 3 << 5 | 12305), a = 0);
2110
- } else if (a > 3) {
2111
- for (o(i), --a; a > 6; a -= 6) o(8304);
2112
- a > 2 && (o(a - 3 << 5 | 8208), a = 0);
2113
- }
2114
- for (; a--;) o(i);
2115
- a = 1, i = e[s];
2116
- }
2237
+ }
2238
+ var He = [
2239
+ ["classic", "Classic"],
2240
+ ["easy", "Easy"],
2241
+ ["small", "Small"],
2242
+ ["big", "Big"],
2243
+ ["rounded", "Rounded"],
2244
+ ["hockey", "Hockey"],
2245
+ ["big_easy", "Big Easy"],
2246
+ ["big_rounded", "Big Rounded"],
2247
+ ["big_hockey", "Big Hockey"],
2248
+ ["huge", "Huge"]
2249
+ ];
2250
+ function Ue(e) {
2251
+ let t = /* @__PURE__ */ new Map();
2252
+ return async (n) => {
2253
+ let r = He.find(([e, t]) => e === n || t === n);
2254
+ if (!r) throw Error("Unknown default stadium");
2255
+ let i = t.get(r[0]);
2256
+ return i || (i = (async () => {
2257
+ let t = await e(`/stadiums/${r[0]}.hbs`);
2258
+ if (!t.ok) throw Error("Could not load stadium");
2259
+ let n = await t.text();
2260
+ return Fe(n), n;
2261
+ })(), t.set(r[0], i), i.catch(() => t.delete(r[0]))), i;
2262
+ };
2263
+ }
2264
+ function We() {
2265
+ let e = Ve(), t = (e, t) => fetch(e, t);
2117
2266
  return {
2118
- c: n.subarray(0, r),
2119
- n: t
2267
+ network: e,
2268
+ request: t,
2269
+ loadEngine: (e) => Re.create(void 0, e),
2270
+ loadStadium: Ue((n) => t(new URL(n, e.serviceOrigin)))
2120
2271
  };
2121
- }, Oe = function(e, t) {
2122
- for (var n = 0, r = 0; r < t.length; ++r) n += e[r] * t[r];
2123
- return n;
2124
- }, ke = function(e, t, n) {
2125
- var r = n.length, i = ve(t + 2);
2126
- e[i] = r & 255, e[i + 1] = r >> 8, e[i + 2] = e[i] ^ 255, e[i + 3] = e[i + 1] ^ 255;
2127
- for (var a = 0; a < r; ++a) e[i + a + 4] = n[a];
2128
- return (i + 4 + r) * 8;
2129
- }, Ae = function(e, t, n, r, i, a, o, s, c, l, u) {
2130
- Ce(t, u++, n), ++i[256];
2131
- for (var d = Te(i, 15), f = d.t, p = d.l, m = Te(a, 15), h = m.t, g = m.l, _ = De(f), v = _.c, y = _.n, b = De(h), x = b.c, S = b.n, C = new G(19), w = 0; w < v.length; ++w) ++C[v[w] & 31];
2132
- for (var w = 0; w < x.length; ++w) ++C[x[w] & 31];
2133
- for (var T = Te(C, 7), E = T.t, D = T.l, O = 19; O > 4 && !E[K[O - 1]]; --O);
2134
- var k = l + 5 << 3, A = Oe(i, de) + Oe(a, fe) + o, j = Oe(i, f) + Oe(a, h) + o + 14 + 3 * O + Oe(C, E) + 2 * C[16] + 3 * C[17] + 7 * C[18];
2135
- if (c >= 0 && k <= A && k <= j) return ke(t, u, e.subarray(c, c + l));
2136
- var M, N, P, F;
2137
- if (Ce(t, u, 1 + (j < A)), u += 2, j < A) {
2138
- M = ue(f, p, 0), N = f, P = ue(h, g, 0), F = h;
2139
- var ee = ue(E, D, 0);
2140
- Ce(t, u, y - 257), Ce(t, u + 5, S - 1), Ce(t, u + 10, O - 4), u += 14;
2141
- for (var w = 0; w < O; ++w) Ce(t, u + 3 * w, E[K[w]]);
2142
- u += 3 * O;
2143
- for (var I = [v, x], L = 0; L < 2; ++L) for (var R = I[L], w = 0; w < R.length; ++w) {
2144
- var z = R[w] & 31;
2145
- Ce(t, u, ee[z]), u += E[z], z > 15 && (Ce(t, u, R[w] >> 5 & 127), u += R[w] >> 12);
2146
- }
2147
- } else M = pe, N = de, P = he, F = fe;
2148
- for (var w = 0; w < s; ++w) {
2149
- var B = r[w];
2150
- if (B > 255) {
2151
- var z = B >> 18 & 31;
2152
- we(t, u, M[z + 257]), u += N[z + 257], z > 7 && (Ce(t, u, B >> 23 & 31), u += re[z]);
2153
- var V = B & 31;
2154
- we(t, u, P[V]), u += F[V], V > 3 && (we(t, u, B >> 5 & 8191), u += ie[V]);
2155
- } else we(t, u, M[B]), u += N[B];
2156
- }
2157
- return we(t, u, M[256]), u + N[256];
2158
- }, je = /*#__PURE__*/ new ne([
2159
- 65540,
2160
- 131080,
2161
- 131088,
2162
- 131104,
2163
- 262176,
2164
- 1048704,
2165
- 1048832,
2166
- 2114560,
2167
- 2117632
2168
- ]), Me = /*#__PURE__*/ new W(0), Ne = function(e, t, n, r, i, a) {
2169
- var o = a.z || e.length, s = new W(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
2170
- if (t) {
2171
- u && (c[0] = a.r >> 3);
2172
- for (var d = je[t - 1], f = d >> 13, p = d & 8191, m = (1 << n) - 1, h = a.p || new G(32768), g = a.h || new G(m + 1), _ = Math.ceil(n / 3), v = 2 * _, y = function(t) {
2173
- return (e[t] ^ e[t + 1] << _ ^ e[t + 2] << v) & m;
2174
- }, b = new ne(25e3), x = new G(288), S = new G(32), C = 0, w = 0, T = a.i || 0, E = 0, D = a.w || 0, O = 0; T + 2 < o; ++T) {
2175
- var k = y(T), A = T & 32767, j = g[k];
2176
- if (h[A] = j, g[k] = A, D <= T) {
2177
- var M = o - T;
2178
- if ((C > 7e3 || E > 24576) && (M > 423 || !l)) {
2179
- u = Ae(e, c, 0, b, x, S, w, E, O, T - O, u), E = C = w = 0, O = T;
2180
- for (var N = 0; N < 286; ++N) x[N] = 0;
2181
- for (var N = 0; N < 30; ++N) S[N] = 0;
2182
- }
2183
- var P = 2, F = 0, ee = p, I = A - j & 32767;
2184
- if (M > 2 && k == y(T - I)) for (var L = Math.min(f, M) - 1, R = Math.min(32767, T), z = Math.min(258, M); I <= R && --ee && A != j;) {
2185
- if (e[T + P] == e[T + P - I]) {
2186
- for (var B = 0; B < z && e[T + B] == e[T + B - I]; ++B);
2187
- if (B > P) {
2188
- if (P = B, F = I, B > L) break;
2189
- for (var V = Math.min(I, B - 2), te = 0, N = 0; N < V; ++N) {
2190
- var H = T - I + N & 32767, U = H - h[H] & 32767;
2191
- U > te && (te = U, j = H);
2192
- }
2193
- }
2194
- }
2195
- A = j, j = h[A], I += A - j & 32767;
2196
- }
2197
- if (F) {
2198
- b[E++] = 268435456 | J[P] << 18 | Y[F];
2199
- var K = J[P] & 31, q = Y[F] & 31;
2200
- w += re[K] + ie[q], ++x[257 + K], ++S[q], D = T + P, ++C;
2201
- } else b[E++] = e[T], ++x[e[T]];
2202
- }
2203
- }
2204
- for (T = Math.max(T, D); T < o; ++T) b[E++] = e[T], ++x[e[T]];
2205
- u = Ae(e, c, l, b, x, S, w, E, O, T - O, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = g, a.p = h, a.i = T, a.w = D);
2206
- } else {
2207
- for (var T = a.w || 0; T < o + l; T += 65535) {
2208
- var ae = T + 65535;
2209
- ae >= o && (c[u / 8 | 0] = l, ae = o), u = ke(c, u + 1, e.subarray(T, ae));
2210
- }
2211
- a.i = o;
2272
+ }
2273
+ var Ge = {
2274
+ message: {
2275
+ burst: 240,
2276
+ perSecond: 160
2277
+ },
2278
+ action: {
2279
+ burst: 12,
2280
+ perSecond: 6
2281
+ },
2282
+ chat: {
2283
+ burst: 4,
2284
+ perSecond: 1
2212
2285
  }
2213
- return ye(s, 0, r + ve(u) + i);
2214
- }, Pe = function(e, t, n, r, i) {
2215
- if (!i && (i = { l: 1 }, t.dictionary)) {
2216
- var a = t.dictionary.subarray(-32768), o = new W(a.length + e.length);
2217
- o.set(a), o.set(e, a.length), e = o, i.w = a.length;
2286
+ }, Ke = class {
2287
+ peers = /* @__PURE__ */ new Map();
2288
+ allow(e, t, n = performance.now()) {
2289
+ let r = this.peers.get(e);
2290
+ r || (r = {}, this.peers.set(e, r));
2291
+ let { burst: i, perSecond: a } = Ge[t], o = r[t] ?? {
2292
+ tokens: i,
2293
+ at: n
2294
+ };
2295
+ return o.tokens = Math.min(i, o.tokens + Math.max(0, n - o.at) * a / 1e3), o.at = Math.max(o.at, n), r[t] = o, o.tokens < 1 ? !1 : (o.tokens--, !0);
2218
2296
  }
2219
- return Ne(e, t.level == null ? 6 : t.level, t.mem == null ? i.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(e.length))) * 1.5) : 20 : 12 + t.mem, n, r, i);
2220
- };
2221
- function Fe(e, t) {
2222
- return Pe(e, t || {}, 0, 0);
2223
- }
2224
- var Ie = /* @__PURE__ */ function() {
2225
- function e(e, t) {
2226
- typeof e == "function" && (t = e, e = {}), this.ondata = t;
2227
- var n = e && e.dictionary && e.dictionary.subarray(-32768);
2228
- this.s = {
2229
- i: 0,
2230
- b: n ? n.length : 0
2231
- }, this.o = new W(32768), this.p = new W(0), n && this.o.set(n);
2297
+ delete(e) {
2298
+ this.peers.delete(e);
2232
2299
  }
2233
- return e.prototype.e = function(e) {
2234
- if (this.ondata || xe(5), this.d && xe(4), !this.p.length) this.p = e;
2235
- else if (e.length) {
2236
- var t = new W(this.p.length + e.length);
2237
- t.set(this.p), t.set(e, this.p.length), this.p = t;
2238
- }
2239
- }, e.prototype.c = function(e) {
2240
- this.s.i = +(this.d = e || !1);
2241
- var t = this.s.b, n = Se(this.p, this.s, this.o);
2242
- this.ondata(ye(n, t, this.s.b), this.d), this.o = ye(n, this.s.b - 32768), this.s.b = this.o.length, this.p = ye(this.p, this.s.p / 8 | 0), this.s.p &= 7;
2243
- }, e.prototype.push = function(e, t) {
2244
- this.e(e), this.c(t);
2245
- }, e;
2246
- }(), Le = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
2247
- try {
2248
- Le.decode(Me, { stream: !0 });
2249
- } catch {}
2250
- //#endregion
2251
- //#region src/core/replay-codec.ts
2252
- var Re = 33554432, ze = new TextEncoder();
2300
+ clear() {
2301
+ this.peers.clear();
2302
+ }
2303
+ }, qe = 33554432, Je = new TextEncoder();
2253
2304
  new TextDecoder("utf-8", { fatal: !0 });
2254
- function Be(e) {
2305
+ function Ye(e) {
2255
2306
  let t = 2166136261;
2256
2307
  for (let n of e) t = Math.imul(t ^ n, 16777619);
2257
2308
  return t >>> 0;
2258
2309
  }
2259
- function Ve(e) {
2310
+ function Xe(e) {
2260
2311
  if (e.length > 33554432) throw Error("Replay exceeds 32 MB");
2261
- let t = Fe(e, { level: 6 }), n = new Uint8Array(16 + t.length), r = new DataView(n.buffer);
2312
+ let t = W(e, { level: 6 }), n = new Uint8Array(16 + t.length), r = new DataView(n.buffer);
2262
2313
  return n.set([
2263
2314
  66,
2264
2315
  50,
@@ -2268,12 +2319,12 @@ function Ve(e) {
2268
2319
  0,
2269
2320
  0,
2270
2321
  0
2271
- ]), r.setUint32(8, e.length, !0), r.setUint32(12, Be(e), !0), n.set(t, 16), n;
2322
+ ]), r.setUint32(8, e.length, !0), r.setUint32(12, Ye(e), !0), n.set(t, 16), n;
2272
2323
  }
2273
- function He(e) {
2324
+ function Ze(e) {
2274
2325
  if (typeof e == "string") {
2275
- if (ze.encode(e).length > 33554432) throw Error("Replay exceeds 32 MB");
2276
- return ze.encode(e);
2326
+ if (Je.encode(e).length > 33554432) throw Error("Replay exceeds 32 MB");
2327
+ return Je.encode(e);
2277
2328
  }
2278
2329
  let t = e instanceof Uint8Array ? e : new Uint8Array(e);
2279
2330
  if (t.length > 33554432) throw Error("Replay exceeds 32 MB");
@@ -2281,17 +2332,15 @@ function He(e) {
2281
2332
  if (t.length < 17 || t[4] !== 1 || t[5] || t[6] || t[7]) throw Error("Invalid compressed replay header");
2282
2333
  let n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = n.getUint32(8, !0);
2283
2334
  if (!r || r > 33554432) throw Error("Invalid expanded replay size");
2284
- let i = new Uint8Array(r), a = 0, o = !1, s = new Ie((e, t) => {
2335
+ let i = new Uint8Array(r), a = 0, o = !1, s = new G((e, t) => {
2285
2336
  if (a + e.length > r) throw Error("Expanded replay exceeds declared size");
2286
2337
  i.set(e, a), a += e.length, o = t;
2287
2338
  });
2288
2339
  for (let e = 16; e < t.length; e += 1024) s.push(t.subarray(e, e + 1024), e + 1024 >= t.length);
2289
- if (!o || a !== r || Be(i) !== n.getUint32(12, !0)) throw Error("Compressed replay integrity failure");
2340
+ if (!o || a !== r || Ye(i) !== n.getUint32(12, !0)) throw Error("Compressed replay integrity failure");
2290
2341
  return i;
2291
2342
  }
2292
- //#endregion
2293
- //#region src/core/replay-wire.ts
2294
- var Ue = [
2343
+ var Qe = [
2295
2344
  "input",
2296
2345
  "team",
2297
2346
  "start",
@@ -2301,30 +2350,38 @@ var Ue = [
2301
2350
  "timeLimit",
2302
2351
  "kickRate",
2303
2352
  "join",
2304
- "disc"
2305
- ], We = new TextEncoder(), Ge = new TextDecoder("utf-8", { fatal: !0 });
2306
- function Ke(e) {
2307
- return Ve(qe(e));
2353
+ "disc",
2354
+ "surface"
2355
+ ], $e = new TextEncoder(), et = new TextDecoder("utf-8", { fatal: !0 });
2356
+ function tt(e) {
2357
+ return Xe(nt(e));
2308
2358
  }
2309
- function qe(e) {
2310
- let { commands: t, ...n } = e, r = t.some((e) => e.kind === "disc") ? 3 : e.checkpoints.length ? 2 : 1, i = 0, a = e.checkpoints.map((e) => {
2359
+ function nt(e) {
2360
+ let { commands: t, ...n } = e, r = t.some((e) => e.kind === "surface") || e.initial.surface !== void 0 || e.checkpoints.some((e) => e.state.surface !== void 0) ? 4 : t.some((e) => e.kind === "disc") ? 3 : e.checkpoints.length ? 2 : 1, i = 0, a = e.checkpoints.map((e) => {
2311
2361
  let t = e.state.discs;
2312
2362
  if (!Array.isArray(t) || t.length > 1728 || t.some((e) => !Number.isFinite(e))) throw Error("Invalid checkpoint discs");
2313
- return i += t.length * 8, {
2363
+ i += t.length * 8;
2364
+ let n = e.state.surface;
2365
+ if (n !== void 0) {
2366
+ if (!Array.isArray(n) || n.length !== 0 && n.length !== 5389 || n.some((e) => !Number.isInteger(e) || e < 0 || e > 4294967295)) throw Error("Invalid checkpoint surface");
2367
+ i += n.length * 4;
2368
+ }
2369
+ return {
2314
2370
  ...e,
2315
2371
  state: {
2316
2372
  ...e.state,
2317
- discs: t.length
2373
+ discs: t.length,
2374
+ ...n === void 0 ? {} : { surface: n.length }
2318
2375
  }
2319
2376
  };
2320
2377
  });
2321
2378
  if (a.length > 721) throw Error("Too many replay checkpoints");
2322
- let o = We.encode(JSON.stringify(r >= 2 ? {
2379
+ let o = $e.encode(JSON.stringify(r >= 2 ? {
2323
2380
  ...n,
2324
2381
  checkpoints: a
2325
2382
  } : n));
2326
2383
  if (t.length > 5e5 || o.length + 16 > 33554432) throw Error("Replay exceeds bounds");
2327
- let s = t.length * 12 + t.filter((e) => e.kind === "disc").length * 106, c = new Uint8Array(Math.min(Re, s)), l = new DataView(c.buffer), u = (e) => {
2384
+ let s = t.length * 12 + t.filter((e) => e.kind === "disc").length * 106, c = new Uint8Array(Math.min(qe, s)), l = new DataView(c.buffer), u = (e) => {
2328
2385
  if (d + e > c.length) throw Error("Replay exceeds bounds");
2329
2386
  }, d = 0, f = e.initial.tick, p = (e) => {
2330
2387
  if (!Number.isInteger(e) || e < 0 || e > 4294967295) throw Error("Invalid replay integer");
@@ -2335,15 +2392,15 @@ function qe(e) {
2335
2392
  } while (e);
2336
2393
  };
2337
2394
  for (let e of t) {
2338
- let t = Ue.indexOf(r < 3 && e.kind === "join" ? "team" : e.kind);
2395
+ let t = Qe.indexOf(r < 3 && e.kind === "join" ? "team" : e.kind);
2339
2396
  if (e.kind === "join" && e.value !== 0 || e.kind === "team" && e.value > 2) throw Error("Invalid replay team command");
2340
2397
  if (t < 0 || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > (e.kind === "disc" ? 95 : 31)) throw Error("Invalid replay command");
2341
- if (p(e.tick - f), u(1), c[d++] = r === 3 ? t : t << 5 | e.slot, r === 3 && p(e.slot), p(r < 3 && e.kind === "join" ? 3 : e.value), e.kind === "disc") {
2342
- let t = b(e.properties), n = 0;
2343
- y.forEach(([e], r) => {
2398
+ if (p(e.tick - f), u(1), c[d++] = r >= 3 ? t : t << 5 | e.slot, r >= 3 && p(e.slot), p(r < 3 && e.kind === "join" ? 3 : e.value), e.kind === "disc") {
2399
+ let t = Se(e.properties), n = 0;
2400
+ xe.forEach(([e], r) => {
2344
2401
  t[e] !== void 0 && (n |= 1 << r);
2345
2402
  }), p(n);
2346
- for (let [e] of y) {
2403
+ for (let [e] of xe) {
2347
2404
  let n = t[e];
2348
2405
  n !== void 0 && (u(8), l.setFloat64(d, n, !0), d += 8);
2349
2406
  }
@@ -2364,40 +2421,52 @@ function qe(e) {
2364
2421
  0
2365
2422
  ]), g.setUint32(8, o.length, !0), g.setUint32(12, t.length, !0), h.set(o, 16);
2366
2423
  let _ = 16 + o.length;
2367
- for (let t of e.checkpoints) for (let e of t.state.discs) g.setFloat64(_, e, !0), _ += 8;
2424
+ for (let t of e.checkpoints) {
2425
+ for (let e of t.state.discs) g.setFloat64(_, e, !0), _ += 8;
2426
+ for (let e of t.state.surface ?? []) g.setUint32(_, e, !0), _ += 4;
2427
+ }
2368
2428
  return h.set(c.subarray(0, d), _), h;
2369
2429
  }
2370
- function Je(e) {
2371
- let t = He(e);
2372
- if (t[0] !== 66 || t[1] !== 50 || t[2] !== 68 || t[3] !== 80) return JSON.parse(Ge.decode(t));
2430
+ function rt(e) {
2431
+ let t = Ze(e);
2432
+ if (t[0] !== 66 || t[1] !== 50 || t[2] !== 68 || t[3] !== 80) return JSON.parse(et.decode(t));
2373
2433
  if (t.length < 16 || ![
2374
2434
  1,
2375
2435
  2,
2376
- 3
2436
+ 3,
2437
+ 4
2377
2438
  ].includes(t[4]) || t[5] || t[6] || t[7]) throw Error("Invalid packed replay header");
2378
2439
  let n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = n.getUint32(8, !0), i = n.getUint32(12, !0);
2379
2440
  if (r > t.length - 16 || i > 5e5 || i > (t.length - 16 - r) / 3) throw Error("Invalid packed replay bounds");
2380
- let a = JSON.parse(Ge.decode(t.subarray(16, 16 + r)));
2441
+ let a = JSON.parse(et.decode(t.subarray(16, 16 + r)));
2381
2442
  if (!a || !Number.isSafeInteger(a.initial?.tick) || a.initial.tick < 0) throw Error("Invalid replay initial tick");
2382
2443
  a.commands = [];
2383
2444
  let o = 16 + r, s = a.initial.tick;
2384
2445
  if (t[4] >= 2) {
2385
2446
  if (!Array.isArray(a.checkpoints) || a.checkpoints.length > 721) throw Error("Invalid packed checkpoints");
2386
2447
  let e = 0;
2387
- for (let t of a.checkpoints) {
2388
- let n = t?.state?.discs;
2389
- if (typeof n != "number" || !Number.isInteger(n) || n < 0 || n > 1728) throw Error("Invalid checkpoint disc count");
2390
- e += n * 8;
2448
+ for (let n of a.checkpoints) {
2449
+ let r = n?.state?.discs;
2450
+ if (typeof r != "number" || !Number.isInteger(r) || r < 0 || r > 1728) throw Error("Invalid checkpoint disc count");
2451
+ if (e += r * 8, t[4] >= 4 && n.state.surface !== void 0) {
2452
+ let t = n.state.surface;
2453
+ if (t !== 0 && t !== 5389) throw Error("Invalid checkpoint surface count");
2454
+ e += t * 4;
2455
+ }
2391
2456
  }
2392
2457
  if (e > t.length - o - i * 3) throw Error("Truncated checkpoint discs");
2393
2458
  for (let e of a.checkpoints) {
2394
- let t = e.state.discs, r = Array(t);
2395
- for (let e = 0; e < t; e++) {
2459
+ let r = e.state.discs, i = Array(r);
2460
+ for (let e = 0; e < r; e++) {
2396
2461
  let t = n.getFloat64(o, !0);
2397
2462
  if (!Number.isFinite(t)) throw Error("Nonfinite checkpoint disc");
2398
- r[e] = t, o += 8;
2463
+ i[e] = t, o += 8;
2464
+ }
2465
+ if (e.state.discs = i, t[4] >= 4 && e.state.surface !== void 0) {
2466
+ let t = e.state.surface, r = Array(t);
2467
+ for (let e = 0; e < t; e++) r[e] = n.getUint32(o, !0), o += 4;
2468
+ e.state.surface = r;
2399
2469
  }
2400
- e.state.discs = r;
2401
2470
  }
2402
2471
  }
2403
2472
  let c = () => {
@@ -2415,14 +2484,14 @@ function Je(e) {
2415
2484
  };
2416
2485
  for (let e = 0; e < i; e++) {
2417
2486
  if (s += c(), !Number.isSafeInteger(s) || o >= t.length) throw Error("Invalid replay tick");
2418
- let e = t[o++], r = Ue[t[4] === 3 ? e : e >> 5];
2487
+ let e = t[o++], r = Qe[t[4] >= 3 ? e : e >> 5];
2419
2488
  if (!r) throw Error("Unknown replay command");
2420
- let i = t[4] === 3 ? c() : e & 31, l = c();
2489
+ let i = t[4] >= 3 ? c() : e & 31, l = c();
2421
2490
  if (r === "disc") {
2422
2491
  let e = c();
2423
2492
  if (e > 8191) throw Error("Invalid disc property mask");
2424
2493
  let u = {};
2425
- y.forEach(([r], i) => {
2494
+ xe.forEach(([r], i) => {
2426
2495
  if (e & 1 << i) {
2427
2496
  if (o + 8 > t.length) throw Error("Truncated disc properties");
2428
2497
  u[r] = n.getFloat64(o, !0), o += 8;
@@ -2432,7 +2501,7 @@ function Je(e) {
2432
2501
  kind: r,
2433
2502
  slot: i,
2434
2503
  value: l,
2435
- properties: b(u)
2504
+ properties: Se(u)
2436
2505
  });
2437
2506
  continue;
2438
2507
  }
@@ -2451,15 +2520,27 @@ function Je(e) {
2451
2520
  if (o !== t.length) throw Error("Trailing replay command data");
2452
2521
  return a;
2453
2522
  }
2454
- //#endregion
2455
- //#region src/core/replay.ts
2456
- function Ye(e) {
2523
+ function it(e) {
2457
2524
  let t = JSON.stringify(e), n = 2166136261;
2458
2525
  for (let e = 0; e < t.length; e++) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
2459
2526
  return (n >>> 0).toString(16).padStart(8, "0");
2460
2527
  }
2461
- function Xe(e, t) {
2528
+ function at(e, t) {
2462
2529
  switch (t.kind) {
2530
+ case "surface":
2531
+ if (t.slot !== 0 || t.value !== 0 && t.value !== 1) throw Error("Invalid surface command");
2532
+ e.configureSurface(t.value ? {
2533
+ seed: 42,
2534
+ halfWidth: e.stadium.bg.width || e.stadium.width,
2535
+ halfHeight: e.stadium.bg.height || e.stadium.height,
2536
+ moisturePermille: 1e3
2537
+ } : null), t.value && e.setSurfaceWeather({
2538
+ rainMilliMmH: 2e5,
2539
+ temperatureMilliC: 2e4,
2540
+ humidityPermille: 1e3,
2541
+ windMilliMS: 0
2542
+ });
2543
+ break;
2463
2544
  case "disc":
2464
2545
  e.applyDiscProperties(t.slot, t.properties);
2465
2546
  break;
@@ -2490,7 +2571,7 @@ function Xe(e, t) {
2490
2571
  case "pause": e.setPaused(!!t.value);
2491
2572
  }
2492
2573
  }
2493
- var Ze = class {
2574
+ var ot = class {
2494
2575
  replay;
2495
2576
  playerOrder = [];
2496
2577
  lastInputs = /* @__PURE__ */ new Map();
@@ -2504,7 +2585,7 @@ var Ze = class {
2504
2585
  this.playerOrder = t.map((e) => e.slot), this.replay = {
2505
2586
  magic: "B2DR",
2506
2587
  version: 1,
2507
- engine: ee,
2588
+ engine: Le,
2508
2589
  stadium: e.source,
2509
2590
  initial: r,
2510
2591
  commands: [],
@@ -2515,14 +2596,14 @@ var Ze = class {
2515
2596
  })),
2516
2597
  styles: [{
2517
2598
  tick: r.tick,
2518
- teams: h(n)
2599
+ teams: _e(n)
2519
2600
  }],
2520
2601
  orders: [{
2521
2602
  tick: r.tick,
2522
2603
  slots: [...this.playerOrder]
2523
2604
  }],
2524
2605
  end: r.tick,
2525
- finalHash: Ye(r)
2606
+ finalHash: it(r)
2526
2607
  }, this.bytes = new TextEncoder().encode(JSON.stringify(this.replay)).length;
2527
2608
  for (let t = 0; t < 32; t++) this.lastInputs.set(t, e.data[e.index(t) * 18 + 14]);
2528
2609
  }
@@ -2542,7 +2623,7 @@ var Ze = class {
2542
2623
  style(e, t) {
2543
2624
  let n = {
2544
2625
  tick: e,
2545
- teams: h(t)
2626
+ teams: _e(t)
2546
2627
  }, r = this.replay.styles;
2547
2628
  return r.length >= 4096 || !this.reserve(n) ? (this.full = !0, !1) : (r.push(n), !0);
2548
2629
  }
@@ -2557,7 +2638,7 @@ var Ze = class {
2557
2638
  command(e) {
2558
2639
  return e.kind === "input" && this.lastInputs.get(e.slot) === e.value ? !0 : this.replay.commands.length >= 5e5 || !this.reserve(e) ? (this.full = !0, !1) : (e.kind === "input" && this.lastInputs.set(e.slot, e.value), (e.kind === "team" || e.kind === "join") && this.lastInputs.set(e.slot, 0), e.kind === "start" && this.lastInputs.clear(), this.replay.commands.push(e.kind === "disc" ? {
2559
2640
  ...e,
2560
- properties: b(e.properties)
2641
+ properties: Se(e.properties)
2561
2642
  } : { ...e }), !0);
2562
2643
  }
2563
2644
  step(e) {
@@ -2566,26 +2647,26 @@ var Ze = class {
2566
2647
  let t = e.snapshot(), n = {
2567
2648
  tick: e.tick,
2568
2649
  state: t,
2569
- hash: Ye(t)
2650
+ hash: it(t)
2570
2651
  };
2571
2652
  this.reserve(n) && this.replay.checkpoints.push(n);
2572
2653
  }
2573
2654
  this.replay.end = e.tick;
2574
2655
  }
2575
2656
  pack(e) {
2576
- return this.replay.end = e.tick, this.replay.finalHash = Ye(e.snapshot()), qe(this.replay);
2657
+ return this.replay.end = e.tick, this.replay.finalHash = it(e.snapshot()), nt(this.replay);
2577
2658
  }
2578
2659
  finish(e) {
2579
- return this.replay.end = e.tick, this.replay.finalHash = Ye(e.snapshot()), new Blob([Ke(this.replay)], { type: "application/x-ball2d-replay" });
2660
+ return this.replay.end = e.tick, this.replay.finalHash = it(e.snapshot()), new Blob([tt(this.replay)], { type: "application/x-ball2d-replay" });
2580
2661
  }
2581
2662
  };
2582
- async function Qe(e) {
2663
+ async function st(e) {
2583
2664
  if (e.size > 33554432) throw Error("Replay exceeds 32 MB");
2584
- return $e(await e.arrayBuffer());
2665
+ return ct(await e.arrayBuffer());
2585
2666
  }
2586
- function $e(e) {
2587
- let t = Je(e);
2588
- if (t.magic !== "B2DR" || t.version !== 1 || t.engine !== ee) throw Error("Unsupported replay engine/version");
2667
+ function ct(e) {
2668
+ let t = rt(e);
2669
+ if (t.magic !== "B2DR" || t.version !== 1 || t.engine !== Le) throw Error("Unsupported replay engine/version");
2589
2670
  if (!Array.isArray(t.commands) || t.commands.length > 5e5 || !Array.isArray(t.checkpoints) || t.checkpoints.length > 721 || !Number.isInteger(t.end) || t.end < t.initial.tick || t.end - t.initial.tick > 216e3) throw Error("Invalid replay bounds");
2590
2671
  let n = t.initial.tick;
2591
2672
  for (let e of t.commands) {
@@ -2599,14 +2680,15 @@ function $e(e) {
2599
2680
  "timeLimit",
2600
2681
  "kickRate",
2601
2682
  "join",
2602
- "disc"
2603
- ].includes(e.kind) || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > (e.kind === "disc" ? 95 : 31) || !Number.isInteger(e.value) || e.value < 0 || e.value > (e.kind === "disc" || e.kind === "join" ? 0 : e.kind === "kickRate" ? 6619135 : e.kind === "timeLimit" ? 5940 : e.kind === "scoreLimit" ? 99 : e.kind === "team" ? 2 : e.kind === "pause" ? 1 : 31)) throw Error("Invalid replay command");
2604
- e.kind === "disc" && (e.properties = b(e.properties)), n = e.tick;
2683
+ "disc",
2684
+ "surface"
2685
+ ].includes(e.kind) || e.kind === "surface" && e.slot !== 0 || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > (e.kind === "disc" ? 95 : 31) || !Number.isInteger(e.value) || e.value < 0 || e.value > (e.kind === "disc" || e.kind === "join" ? 0 : e.kind === "kickRate" ? 6619135 : e.kind === "timeLimit" ? 5940 : e.kind === "scoreLimit" ? 99 : e.kind === "team" ? 2 : e.kind === "pause" || e.kind === "surface" ? 1 : 31)) throw Error("Invalid replay command");
2686
+ e.kind === "disc" && (e.properties = Se(e.properties)), n = e.tick;
2605
2687
  }
2606
2688
  if (!Array.isArray(t.roster) || t.roster.length > 4096) throw Error("Invalid replay roster");
2607
2689
  n = t.initial.tick;
2608
2690
  for (let e of t.roster) {
2609
- if (!Number.isInteger(e.tick) || e.tick < n || e.tick > t.end || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > 31 || e.name !== null && (typeof e.name != "string" || e.name.length > 24) || e.avatar !== void 0 && !v(e.avatar)) throw Error("Invalid roster event");
2691
+ if (!Number.isInteger(e.tick) || e.tick < n || e.tick > t.end || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > 31 || e.name !== null && (typeof e.name != "string" || e.name.length > 24) || e.avatar !== void 0 && !be(e.avatar)) throw Error("Invalid roster event");
2610
2692
  n = e.tick;
2611
2693
  }
2612
2694
  if (t.styles !== void 0) {
@@ -2614,7 +2696,7 @@ function $e(e) {
2614
2696
  let e = t.initial.tick;
2615
2697
  for (let n of t.styles) {
2616
2698
  if (!n || !Number.isInteger(n.tick) || n.tick < e || n.tick > t.end || n.teams === void 0) throw Error("Invalid replay style");
2617
- n.teams = h(n.teams), e = n.tick;
2699
+ n.teams = _e(n.teams), e = n.tick;
2618
2700
  }
2619
2701
  }
2620
2702
  if (t.orders !== void 0) {
@@ -2632,35 +2714,266 @@ function $e(e) {
2632
2714
  }
2633
2715
  return t;
2634
2716
  }
2635
- //#endregion
2636
- //#region src/client/connection-stats.ts
2637
- function et(e) {
2717
+ var lt = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, ut = class {
2718
+ io;
2719
+ state = "admitted";
2720
+ currentEpoch = 0;
2721
+ membershipDeadline;
2722
+ recoveryDeadline = Infinity;
2723
+ phaseDeadline = Infinity;
2724
+ attemptId;
2725
+ retry = 0;
2726
+ timer;
2727
+ timerVersion = 0;
2728
+ transport;
2729
+ constructor(e, t) {
2730
+ if (this.io = e, !lt(t)) throw RangeError("Invalid membership duration");
2731
+ this.membershipDeadline = e.now() + t, this.arm();
2732
+ }
2733
+ get epoch() {
2734
+ return this.currentEpoch;
2735
+ }
2736
+ get status() {
2737
+ return this.state;
2738
+ }
2739
+ disconnected(e) {
2740
+ e !== this.currentEpoch || this.terminal() || this.checkExpiry() || (this.state === "admitted" ? (this.recoveryDeadline = Math.min(this.io.now() + 3e4, this.membershipDeadline), this.attemptId = this.io.newAttemptId(), this.retry = 0, this.wait()) : (this.state === "connecting" || this.state === "awaiting-ack") && this.wait());
2741
+ }
2742
+ acknowledge(e, t) {
2743
+ if (e !== this.currentEpoch || this.state !== "awaiting-ack" || t !== void 0 && !lt(t) || this.checkExpiry() || this.checkAttemptTimeout()) return !1;
2744
+ t !== void 0 && (this.membershipDeadline = Math.min(this.membershipDeadline, this.io.now() + t));
2745
+ let n = {
2746
+ attemptId: this.attemptId,
2747
+ epoch: e
2748
+ };
2749
+ return this.state = "admitted", this.recoveryDeadline = Infinity, this.phaseDeadline = Infinity, this.attemptId = void 0, this.retry = 0, this.arm(), this.io.onRecovered(n), !0;
2750
+ }
2751
+ heartbeat(e, t) {
2752
+ return e !== this.currentEpoch || this.state !== "admitted" || !lt(t) || this.checkExpiry() ? !1 : (this.membershipDeadline = this.io.now() + t, this.arm(), !0);
2753
+ }
2754
+ cancel() {
2755
+ this.terminal() || (this.state = "cancelled", this.clearTimer(), this.retire());
2756
+ }
2757
+ terminal() {
2758
+ return this.state === "expired" || this.state === "cancelled";
2759
+ }
2760
+ retire() {
2761
+ let e = this.transport;
2762
+ this.transport = void 0;
2763
+ try {
2764
+ e?.close();
2765
+ } catch {}
2766
+ }
2767
+ clearTimer() {
2768
+ this.timerVersion++, this.timer !== void 0 && this.io.clearTimer(this.timer), this.timer = void 0;
2769
+ }
2770
+ checkExpiry() {
2771
+ if (this.terminal()) return !0;
2772
+ let e = this.io.now(), t = e >= this.membershipDeadline;
2773
+ return !t && e < this.recoveryDeadline ? !1 : (this.state = "expired", this.clearTimer(), this.retire(), this.io.onExpired(t ? "membership" : "recovery"), !0);
2774
+ }
2775
+ checkAttemptTimeout() {
2776
+ return (this.state === "connecting" || this.state === "awaiting-ack") && this.io.now() >= this.phaseDeadline && (this.wait(), !0);
2777
+ }
2778
+ wait() {
2779
+ this.state = "waiting", this.retire();
2780
+ let e = this.io.random(), t = Number.isFinite(e) ? Math.max(0, Math.min(1, e)) : .5, n = Math.min(4e3, 250 * 2 ** Math.min(this.retry++, 4));
2781
+ this.phaseDeadline = this.io.now() + n * (.75 + t * .25), this.arm();
2782
+ }
2783
+ arm() {
2784
+ if (this.clearTimer(), this.terminal()) return;
2785
+ let e = this.timerVersion, t = Math.min(this.membershipDeadline, this.recoveryDeadline, this.phaseDeadline);
2786
+ this.timer = this.io.setTimer(() => {
2787
+ if (!(e !== this.timerVersion || this.checkExpiry())) {
2788
+ if (this.timer = void 0, this.io.now() < this.phaseDeadline) {
2789
+ this.arm();
2790
+ return;
2791
+ }
2792
+ this.state === "waiting" ? this.attempt() : this.state === "connecting" || this.state === "awaiting-ack" ? this.wait() : this.arm();
2793
+ }
2794
+ }, Math.max(0, t - this.io.now()));
2795
+ }
2796
+ attempt() {
2797
+ if (this.checkExpiry()) return;
2798
+ this.state = "connecting";
2799
+ let e = ++this.currentEpoch;
2800
+ this.phaseDeadline = this.io.now() + 5e3, this.arm();
2801
+ let t;
2802
+ try {
2803
+ t = this.io.createAttempt({
2804
+ attemptId: this.attemptId,
2805
+ epoch: e
2806
+ }, {
2807
+ opened: () => {
2808
+ e !== this.currentEpoch || this.state !== "connecting" || this.checkExpiry() || this.checkAttemptTimeout() || (this.state = "awaiting-ack");
2809
+ },
2810
+ closed: () => this.disconnected(e)
2811
+ });
2812
+ } catch {
2813
+ e === this.currentEpoch && this.disconnected(e);
2814
+ return;
2815
+ }
2816
+ if (e === this.currentEpoch && (this.state === "connecting" || this.state === "awaiting-ack" || this.state === "admitted")) this.transport = t;
2817
+ else try {
2818
+ t.close();
2819
+ } catch {}
2820
+ }
2821
+ };
2822
+ function dt(e, t) {
2823
+ return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === t.length && t.every((t) => Object.hasOwn(e, t));
2824
+ }
2825
+ var ft = (e) => typeof e == "string" && /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(e), pt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), mt = (e, t) => Number.isSafeInteger(e) && e >= t, ht = (e) => mt(e, 1) && e <= 9e4, gt = (e) => e === "host" || e === "guest";
2826
+ function _t(e) {
2827
+ return !dt(e, [
2828
+ "version",
2829
+ "roomGeneration",
2830
+ "secret",
2831
+ "connectionEpoch",
2832
+ "membershipValidForMs"
2833
+ ]) || e.version !== 2 || !ft(e.roomGeneration) || !pt(e.secret) || !mt(e.connectionEpoch, 1) || !ht(e.membershipValidForMs) ? null : {
2834
+ version: 2,
2835
+ roomGeneration: e.roomGeneration,
2836
+ secret: e.secret,
2837
+ connectionEpoch: e.connectionEpoch,
2838
+ membershipValidForMs: e.membershipValidForMs
2839
+ };
2840
+ }
2841
+ function vt(e) {
2842
+ if (!dt(e, [
2843
+ "type",
2844
+ "version",
2845
+ "roomGeneration",
2846
+ "attemptId",
2847
+ "id",
2848
+ "hostId",
2849
+ "role",
2850
+ "connectionEpoch",
2851
+ "membershipValidForMs",
2852
+ "rosterRevision",
2853
+ "members",
2854
+ "requireVerification",
2855
+ "locked"
2856
+ ]) || e.type !== "resumed" || e.version !== 2 || !ft(e.roomGeneration) || !ft(e.attemptId) || !ft(e.id) || !ft(e.hostId) || !gt(e.role) || !mt(e.connectionEpoch, 1) || !ht(e.membershipValidForMs) || !mt(e.rosterRevision, 0) || typeof e.requireVerification != "boolean" || typeof e.locked != "boolean" || !Array.isArray(e.members) || e.members.length < 1 || e.members.length > 33) return null;
2857
+ let t = bt(e.members, e.hostId);
2858
+ return !t || !t.some((t) => t.id === e.id && t.role === e.role && t.attached && t.connectionEpoch === e.connectionEpoch) ? null : {
2859
+ type: "resumed",
2860
+ version: 2,
2861
+ roomGeneration: e.roomGeneration,
2862
+ attemptId: e.attemptId,
2863
+ id: e.id,
2864
+ hostId: e.hostId,
2865
+ role: e.role,
2866
+ connectionEpoch: e.connectionEpoch,
2867
+ membershipValidForMs: e.membershipValidForMs,
2868
+ rosterRevision: e.rosterRevision,
2869
+ members: t,
2870
+ requireVerification: e.requireVerification,
2871
+ locked: e.locked
2872
+ };
2873
+ }
2874
+ function yt(e) {
2875
+ if (!dt(e, [
2876
+ "type",
2877
+ "id",
2878
+ "hostId",
2879
+ "role",
2880
+ "resumeGrant",
2881
+ "rosterRevision",
2882
+ "members",
2883
+ "requireVerification",
2884
+ "locked"
2885
+ ]) || e.type !== "ready") return null;
2886
+ let t = _t(e.resumeGrant);
2887
+ if (!t) return null;
2888
+ let n = vt({
2889
+ type: "resumed",
2890
+ version: 2,
2891
+ roomGeneration: t.roomGeneration,
2892
+ attemptId: t.roomGeneration,
2893
+ id: e.id,
2894
+ hostId: e.hostId,
2895
+ role: e.role,
2896
+ connectionEpoch: t.connectionEpoch,
2897
+ membershipValidForMs: t.membershipValidForMs,
2898
+ rosterRevision: e.rosterRevision,
2899
+ members: e.members,
2900
+ requireVerification: e.requireVerification,
2901
+ locked: e.locked
2902
+ });
2903
+ return n ? {
2904
+ type: "ready",
2905
+ id: n.id,
2906
+ hostId: n.hostId,
2907
+ role: n.role,
2908
+ resumeGrant: t,
2909
+ rosterRevision: n.rosterRevision,
2910
+ members: n.members,
2911
+ requireVerification: n.requireVerification,
2912
+ locked: n.locked
2913
+ } : null;
2914
+ }
2915
+ function bt(e, t) {
2916
+ if (!Array.isArray(e) || e.length < 1 || e.length > 33) return null;
2917
+ let n = [], r = /* @__PURE__ */ new Set();
2918
+ for (let t of e) {
2919
+ if (!dt(t, [
2920
+ "id",
2921
+ "role",
2922
+ "attached",
2923
+ "connectionEpoch"
2924
+ ]) || !ft(t.id) || !gt(t.role) || typeof t.attached != "boolean" || !mt(t.connectionEpoch, 1) || r.has(t.id)) return null;
2925
+ r.add(t.id), n.push({
2926
+ id: t.id,
2927
+ role: t.role,
2928
+ attached: t.attached,
2929
+ connectionEpoch: t.connectionEpoch
2930
+ });
2931
+ }
2932
+ let i = n.filter((e) => e.role === "host");
2933
+ return i.length === 1 && i[0].id === t ? n : null;
2934
+ }
2935
+ function xt(e) {
2936
+ if (!dt(e, [
2937
+ "type",
2938
+ "roomGeneration",
2939
+ "hostId",
2940
+ "rosterRevision",
2941
+ "members"
2942
+ ]) || e.type !== "roster" || !ft(e.roomGeneration) || !ft(e.hostId) || !mt(e.rosterRevision, 0)) return null;
2943
+ let t = bt(e.members, e.hostId);
2944
+ return t ? {
2945
+ type: "roster",
2946
+ roomGeneration: e.roomGeneration,
2947
+ hostId: e.hostId,
2948
+ rosterRevision: e.rosterRevision,
2949
+ members: t
2950
+ } : null;
2951
+ }
2952
+ function St(e) {
2638
2953
  let t = [...e], n = new Set(t.filter((e) => e.type === "transport" && e.selectedCandidatePairId).map((e) => e.selectedCandidatePairId)), r = t.filter((e) => e.type === "candidate-pair" && e.state === "succeeded"), i = n.size ? r.filter((e) => n.has(e.id)) : r.filter((e) => e.nominated === !0);
2639
2954
  if (i.length !== 1) return null;
2640
2955
  let a = i[0].currentRoundTripTime;
2641
2956
  return typeof a == "number" && Number.isFinite(a) && a >= 0 ? a * 1e3 : null;
2642
2957
  }
2643
- //#endregion
2644
- //#region src/core/control.ts
2645
- var tt = 524288, nt = 16384, rt = 12;
2646
- function it(e, t) {
2958
+ var Ct = 524288, wt = 16384, Tt = 12;
2959
+ function Et(e, t) {
2647
2960
  let n = JSON.stringify(e);
2648
2961
  if (n === void 0) throw Error("Missing control message");
2649
2962
  let r = new TextEncoder().encode(n);
2650
- if (r.length > tt) throw Error("Control message exceeds 512 KB");
2651
- if (r.length <= nt) return [n];
2652
- let i = Math.ceil(r.length / nt), a = [];
2963
+ if (r.length > Ct) throw Error("Control message exceeds 512 KB");
2964
+ if (r.length <= wt) return [n];
2965
+ let i = Math.ceil(r.length / wt), a = [];
2653
2966
  for (let e = 0; e < i; e++) {
2654
- let n = r.subarray(e * nt, (e + 1) * nt), o = new ArrayBuffer(rt + n.length), s = new DataView(o);
2655
- s.setUint16(0, 45635), s.setUint8(2, 1), s.setUint32(4, t, !0), s.setUint16(8, e, !0), s.setUint16(10, i, !0), new Uint8Array(o, rt).set(n), a.push(o);
2967
+ let n = r.subarray(e * wt, (e + 1) * wt), o = new ArrayBuffer(Tt + n.length), s = new DataView(o);
2968
+ s.setUint16(0, 45635), s.setUint8(2, 1), s.setUint32(4, t, !0), s.setUint16(8, e, !0), s.setUint16(10, i, !0), new Uint8Array(o, Tt).set(n), a.push(o);
2656
2969
  }
2657
2970
  return a;
2658
2971
  }
2659
- var at = class {
2972
+ var Dt = class {
2660
2973
  partial;
2661
2974
  push(e, t = performance.now()) {
2662
2975
  if (typeof e == "string") {
2663
- if (this.partial || new TextEncoder().encode(e).length > nt) throw Error("Invalid control message");
2976
+ if (this.partial || new TextEncoder().encode(e).length > wt) throw Error("Invalid control message");
2664
2977
  return JSON.parse(e);
2665
2978
  }
2666
2979
  if (e.byteLength < 13 || e.byteLength > 16396) throw Error("Control fragment length");
@@ -2681,13 +2994,13 @@ var at = class {
2681
2994
  }
2682
2995
  let o = this.partial;
2683
2996
  if (o.id !== r || o.count !== a || o.next !== i || t - o.since > 1e4) throw Error("Control fragment sequence");
2684
- if (o.next++, o.bytes += e.byteLength - rt, o.bytes > tt) throw Error("Control size limit");
2685
- if (o.parts.push(new Uint8Array(e.slice(rt))), o.next !== a) return;
2997
+ if (o.next++, o.bytes += e.byteLength - Tt, o.bytes > Ct) throw Error("Control size limit");
2998
+ if (o.parts.push(new Uint8Array(e.slice(Tt))), o.next !== a) return;
2686
2999
  let s = new Uint8Array(o.bytes), c = 0;
2687
3000
  for (let e of o.parts) s.set(e, c), c += e.length;
2688
3001
  return this.partial = void 0, JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(s));
2689
3002
  }
2690
- }, ot = class extends Error {}, st = 1, ct = class {
3003
+ }, Ot = class extends Error {}, kt = 1, At = (e) => typeof e == "string" && /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e), jt = (e) => Number.isSafeInteger(e) && e > 0, Mt = (e) => e?.match(/(?:^|\r?\n)a=ice-ufrag:([^\s]+)/)?.[1], Nt = (e) => e.usernameFragment ?? e.candidate?.match(/(?:^| )ufrag ([^ ]+)/)?.[1], Pt = class {
2691
3004
  room;
2692
3005
  credentials;
2693
3006
  hooks;
@@ -2702,6 +3015,67 @@ var at = class {
2702
3015
  bytesSent = 0;
2703
3016
  bytesReceived = 0;
2704
3017
  pollingStats = !1;
3018
+ resumeGrant;
3019
+ recovery;
3020
+ resumeAttempt;
3021
+ socketSerial = 0;
3022
+ requestSentAt = 0;
3023
+ rosterRevision = -1;
3024
+ members = /* @__PURE__ */ new Map();
3025
+ lockedState = null;
3026
+ get locked() {
3027
+ return this.lockedState;
3028
+ }
3029
+ heartbeatSequence = 0;
3030
+ heartbeatRequest;
3031
+ heartbeatTimer;
3032
+ heartbeatTimerVersion = 0;
3033
+ heartbeatDeadline = 0;
3034
+ cancelHeartbeat() {
3035
+ clearTimeout(this.heartbeatTimer), this.heartbeatTimer = void 0, this.heartbeatTimerVersion++, this.heartbeatRequest = void 0;
3036
+ }
3037
+ armHeartbeat(e) {
3038
+ clearTimeout(this.heartbeatTimer);
3039
+ let t = ++this.heartbeatTimerVersion;
3040
+ this.heartbeatTimer = setTimeout(() => {
3041
+ t === this.heartbeatTimerVersion && (this.heartbeatTimer = void 0, this.sendHeartbeat());
3042
+ }, e);
3043
+ }
3044
+ scheduleHeartbeat(e, t) {
3045
+ this.cancelHeartbeat();
3046
+ let n = performance.now() + e;
3047
+ this.heartbeatDeadline = t ? n : Math.min(this.heartbeatDeadline, n);
3048
+ let r = this.heartbeatDeadline - performance.now();
3049
+ r > 0 && this.signalingReady && this.armHeartbeat(Math.max(1, Math.floor(Math.min(3e4, r / 3))));
3050
+ }
3051
+ sendHeartbeat() {
3052
+ let e = this.heartbeatDeadline - performance.now();
3053
+ if (!this.signalingReady || !this.resumeGrant || !this.recovery || e <= 0) return;
3054
+ let t = this.heartbeatRequest ??= {
3055
+ id: ++this.heartbeatSequence,
3056
+ sentAt: performance.now(),
3057
+ localEpoch: this.recovery.epoch,
3058
+ transmissions: 0,
3059
+ retryDelay: Math.max(1, Math.floor(Math.min(5e3, e / 3)))
3060
+ };
3061
+ if (!(t.transmissions >= 3)) {
3062
+ t.transmissions++;
3063
+ try {
3064
+ this.signal({
3065
+ type: "heartbeat",
3066
+ requestId: t.id,
3067
+ connectionEpoch: this.resumeGrant.connectionEpoch
3068
+ });
3069
+ } catch {}
3070
+ this.heartbeatRequest === t && this.signalingReady && t.transmissions < 3 && t.retryDelay < e && this.armHeartbeat(t.retryDelay);
3071
+ }
3072
+ }
3073
+ get signalingReady() {
3074
+ return !this.closed && !!this.id && this.ws.readyState === kt && this.signalingAdmitted;
3075
+ }
3076
+ get signalingAdmitted() {
3077
+ return !this.recovery || this.recovery.status === "admitted";
3078
+ }
2705
3079
  verificationState = null;
2706
3080
  get requireVerification() {
2707
3081
  return this.verificationState;
@@ -2714,7 +3088,7 @@ var at = class {
2714
3088
  n && (this.verificationRequest = void 0, clearTimeout(n.timer), t && (this.verificationState = null), n.reject(Error(e)));
2715
3089
  }
2716
3090
  setRequireVerification(e) {
2717
- return typeof e == "boolean" ? this.closed || !this.host || this.ws.readyState !== st ? Promise.reject(Error("An active room-owner connection is required.")) : this.verificationRequest ? Promise.reject(Error("A verification update is already pending.")) : new Promise((t, n) => {
3091
+ return typeof e == "boolean" ? this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== kt ? Promise.reject(Error("An active room-owner connection is required.")) : this.verificationRequest ? Promise.reject(Error("A verification update is already pending.")) : new Promise((t, n) => {
2718
3092
  let r = ++this.verificationSequence, i = setTimeout(() => this.rejectVerification("Verification update was not confirmed."), 1e4);
2719
3093
  this.verificationRequest = {
2720
3094
  id: r,
@@ -2740,7 +3114,7 @@ var at = class {
2740
3114
  t && (this.passwordRequest = void 0, clearTimeout(t.timer), t.reject(Error(e)));
2741
3115
  }
2742
3116
  setPassword(e) {
2743
- return e !== null && (typeof e != "string" || e.length > 64) ? Promise.reject(Error("Password must contain at most 64 characters.")) : this.closed || !this.host || this.ws.readyState !== st ? Promise.reject(Error("An active room-owner connection is required.")) : this.passwordRequest ? Promise.reject(Error("A password update is already pending.")) : new Promise((t, n) => {
3117
+ return e !== null && (typeof e != "string" || e.length > 64) ? Promise.reject(Error("Password must contain at most 64 characters.")) : this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== kt ? Promise.reject(Error("An active room-owner connection is required.")) : this.passwordRequest ? Promise.reject(Error("A password update is already pending.")) : new Promise((t, n) => {
2744
3118
  let r = ++this.passwordRequestId, i = setTimeout(() => this.rejectPasswordUpdate("Password update was not confirmed."), 1e4);
2745
3119
  this.passwordRequest = {
2746
3120
  id: r,
@@ -2763,10 +3137,10 @@ var at = class {
2763
3137
  banRequest;
2764
3138
  rejectBan(e, t = !0) {
2765
3139
  let n = this.banRequest;
2766
- n && (this.banRequest = void 0, clearTimeout(n.timer), n.reject(t ? new ot(e) : Error(e)));
3140
+ n && (this.banRequest = void 0, clearTimeout(n.timer), n.reject(t ? new Ot(e) : Error(e)));
2767
3141
  }
2768
3142
  updateBan(e, t) {
2769
- return this.closed || !this.host || this.ws.readyState !== st ? Promise.reject(Error("An active room-owner connection is required.")) : this.banRequest ? Promise.reject(Error("A ban operation is already pending.")) : new Promise((n, r) => {
3143
+ return this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== kt ? Promise.reject(Error("An active room-owner connection is required.")) : this.banRequest ? Promise.reject(Error("A ban operation is already pending.")) : new Promise((n, r) => {
2770
3144
  let i = ++this.banSequence, a = setTimeout(() => this.rejectBan("Ban operation was not confirmed."), 1e4);
2771
3145
  this.banRequest = {
2772
3146
  id: i,
@@ -2793,28 +3167,17 @@ var at = class {
2793
3167
  lastHeartbeat = 0;
2794
3168
  controlId = 0;
2795
3169
  controlAssemblers = /* @__PURE__ */ new Map();
2796
- constructor(e, t, n, r = z()) {
3170
+ constructor(e, t, n, r = Ve()) {
2797
3171
  this.room = e, this.credentials = t, this.hooks = n, this.runtime = r;
2798
- let i = new URL(`/api/rooms/${encodeURIComponent(e)}/signal`, R(r.serviceOrigin));
2799
- i.protocol = i.protocol === "https:" ? "wss:" : "ws:", this.ws = r.createWebSocket(i), this.ws.onopen = () => this.signal({
2800
- type: "hello",
2801
- ...t
2802
- }), this.ws.onmessage = (e) => {
2803
- this.signalQueue = this.signalQueue.then(() => this.message(JSON.parse(e.data))).catch(() => {
2804
- this.closed || n.status("Connection negotiation failed. Try another room or network.");
3172
+ let i = new URL(`/api/rooms/${encodeURIComponent(e)}/signal`, Be(r.serviceOrigin));
3173
+ i.protocol = i.protocol === "https:" ? "wss:" : "ws:", this.ws = r.createWebSocket(i), this.attachSocket(this.ws, () => {
3174
+ this.requestSentAt = performance.now(), this.signal({
3175
+ type: "hello",
3176
+ ...t,
3177
+ ...r.signalingResume ? { signalingVersion: 2 } : {}
2805
3178
  });
2806
- }, this.ws.onclose = (e) => {
2807
- if (this.challenge?.abort(), this.rejectVerification("Signaling disconnected before verification confirmation."), this.rejectBan("Signaling disconnected before ban confirmation."), this.rejectPasswordUpdate("Signaling disconnected before password confirmation."), !this.closed && (!this.id || [
2808
- 1001,
2809
- 1008,
2810
- 1009
2811
- ].includes(e.code))) {
2812
- this.close(), this.hooks.ended?.(e.reason || "Room connection ended.");
2813
- return;
2814
- }
2815
- this.closed || n.status(e.reason || "Signaling disconnected. Established matches can continue; new joins are unavailable.");
2816
- }, this.ws.onerror = () => n.status("Room service is unavailable."), this.timer = setInterval(() => {
2817
- this.ws.readyState === st && performance.now() - this.lastHeartbeat >= 3e4 && (this.signal({ type: "heartbeat" }), this.lastHeartbeat = performance.now());
3179
+ }, 0), this.timer = setInterval(() => {
3180
+ !this.resumeGrant && this.signalingAdmitted && this.ws.readyState === kt && performance.now() - this.lastHeartbeat >= 3e4 && (this.signal({ type: "heartbeat" }), this.lastHeartbeat = performance.now());
2818
3181
  for (let e of this.peers.values()) {
2819
3182
  if (!e.connected && performance.now() - e.created > 2e4) {
2820
3183
  n.status("Direct connection failed. This network pair may require a relay; this game does not use TURN."), this.remove(e.id);
@@ -2824,11 +3187,114 @@ var at = class {
2824
3187
  }
2825
3188
  }, 5e3);
2826
3189
  }
2827
- signal(e) {
2828
- !this.closed && this.ws.readyState === st && this.ws.send(JSON.stringify(e));
3190
+ attachSocket(e, t, n) {
3191
+ let r = ++this.socketSerial, i = () => !this.closed && this.ws === e && this.socketSerial === r;
3192
+ e.onopen = () => {
3193
+ i() && t();
3194
+ }, e.onmessage = (e) => {
3195
+ i() && (this.signalQueue = this.signalQueue.then(async () => {
3196
+ i() && await this.message(JSON.parse(e.data), r);
3197
+ }).catch(() => {
3198
+ i() && this.hooks.status("Connection negotiation failed. Try another room or network.");
3199
+ }));
3200
+ }, e.onclose = (e) => {
3201
+ if (i()) {
3202
+ if (this.socketSerial++, this.challenge?.abort(), this.cancelHeartbeat(), this.rejectVerification("Signaling disconnected before verification confirmation."), this.rejectBan("Signaling disconnected before ban confirmation."), this.rejectPasswordUpdate("Signaling disconnected before password confirmation."), this.recovery && this.resumeGrant && ![
3203
+ 1e3,
3204
+ 1008,
3205
+ 1009
3206
+ ].includes(e.code)) {
3207
+ this.recovery.disconnected(n), this.hooks.status("Signaling interrupted. Reconnecting…");
3208
+ return;
3209
+ }
3210
+ if (!this.id || this.recovery || [
3211
+ 1001,
3212
+ 1008,
3213
+ 1009
3214
+ ].includes(e.code)) {
3215
+ this.close(), this.hooks.ended?.(e.reason || "Room connection ended.");
3216
+ return;
3217
+ }
3218
+ this.hooks.status(e.reason || "Signaling disconnected. Established matches can continue; new joins are unavailable.");
3219
+ }
3220
+ }, e.onerror = () => {
3221
+ i() && this.hooks.status("Room service is unavailable.");
3222
+ };
2829
3223
  }
2830
- async message(e) {
2831
- if (this.closed) return;
3224
+ startRecovery(e) {
3225
+ let t = Math.floor(e.membershipValidForMs - (performance.now() - this.requestSentAt));
3226
+ if (t <= 0) {
3227
+ this.close(), this.hooks.ended?.("Room membership expired.");
3228
+ return;
3229
+ }
3230
+ this.resumeGrant = e, this.recovery = new ut({
3231
+ now: () => performance.now(),
3232
+ setTimer: (e, t) => setTimeout(e, t),
3233
+ clearTimer: (e) => clearTimeout(e),
3234
+ random: () => Math.random(),
3235
+ newAttemptId: () => crypto.randomUUID(),
3236
+ createAttempt: (e, t) => {
3237
+ this.resumeAttempt = e;
3238
+ let n = new URL(`/api/rooms/${encodeURIComponent(this.room)}/signal`, Be(this.runtime.serviceOrigin));
3239
+ n.protocol = n.protocol === "https:" ? "wss:" : "ws:";
3240
+ let r = this.runtime.createWebSocket(n);
3241
+ return this.ws = r, this.attachSocket(r, () => {
3242
+ t.opened(), this.recovery?.status === "awaiting-ack" && (this.requestSentAt = performance.now(), r.send(JSON.stringify({
3243
+ type: "resume",
3244
+ version: 2,
3245
+ roomGeneration: this.resumeGrant.roomGeneration,
3246
+ peerId: this.id,
3247
+ secret: this.resumeGrant.secret,
3248
+ attemptId: e.attemptId,
3249
+ expectedEpoch: this.resumeGrant.connectionEpoch
3250
+ })));
3251
+ }, e.epoch), { close: () => {
3252
+ this.ws === r && this.socketSerial++, r.onopen = null, r.onmessage = null, r.onclose = null, r.onerror = null, r.close();
3253
+ } };
3254
+ },
3255
+ onExpired: () => {
3256
+ this.close(), this.hooks.ended?.("Room signaling recovery expired.");
3257
+ },
3258
+ onRecovered: () => {}
3259
+ }, t), this.scheduleHeartbeat(t, !0);
3260
+ }
3261
+ signal(e) {
3262
+ !this.closed && this.signalingAdmitted && this.ws.readyState === kt && this.ws.send(JSON.stringify(e));
3263
+ }
3264
+ async message(e, t = this.socketSerial) {
3265
+ if (this.closed || t !== this.socketSerial) return;
3266
+ if (e.type === "resumed") {
3267
+ let n = vt(e), r = this.resumeGrant, i = this.resumeAttempt;
3268
+ if (!n || !r || !i || !this.recovery || n.roomGeneration !== r.roomGeneration || n.attemptId !== i.attemptId || n.id !== this.id || n.hostId !== this.hostId || n.role === "host" !== this.host || n.connectionEpoch <= r.connectionEpoch || n.rosterRevision < this.rosterRevision || n.members.some((e) => e.connectionEpoch < (this.members.get(e.id)?.connectionEpoch ?? 0))) return;
3269
+ let a = Math.floor(n.membershipValidForMs - (performance.now() - this.requestSentAt));
3270
+ if (a <= 0 || !this.recovery.acknowledge(i.epoch, a)) return;
3271
+ this.resumeGrant = {
3272
+ ...r,
3273
+ connectionEpoch: n.connectionEpoch,
3274
+ membershipValidForMs: a
3275
+ }, this.resumeAttempt = void 0, this.scheduleHeartbeat(a, !1), this.verificationState = n.requireVerification, this.lockedState = n.locked, this.reconcile(n.members, n.rosterRevision, t), this.hooks.status("Room signaling restored.");
3276
+ return;
3277
+ }
3278
+ if (e.type === "heartbeat" && this.resumeGrant && this.recovery) {
3279
+ let t = this.heartbeatRequest;
3280
+ if (!t || e.requestId !== t.id || e.connectionEpoch !== this.resumeGrant.connectionEpoch || !Number.isSafeInteger(e.membershipValidForMs) || e.membershipValidForMs < 1 || e.membershipValidForMs > 9e4) return;
3281
+ let n = Math.floor(e.membershipValidForMs - (performance.now() - t.sentAt));
3282
+ n > 0 && this.recovery.heartbeat(t.localEpoch, n) && this.scheduleHeartbeat(n, !0);
3283
+ return;
3284
+ }
3285
+ if (this.recovery && !this.signalingAdmitted) return;
3286
+ if (e.type === "roster" && this.resumeGrant) {
3287
+ let n = xt(e);
3288
+ if (!n || n.roomGeneration !== this.resumeGrant.roomGeneration || n.hostId !== this.hostId || n.rosterRevision <= this.rosterRevision) return;
3289
+ let r = n.members.find((e) => e.id === this.id);
3290
+ if (!r || !r.attached || r.connectionEpoch !== this.resumeGrant.connectionEpoch || r.role === "host" !== this.host) {
3291
+ this.close(), this.hooks.ended?.("Room membership ended.");
3292
+ return;
3293
+ }
3294
+ if (n.members.some((e) => e.connectionEpoch < (this.members.get(e.id)?.connectionEpoch ?? 0))) return;
3295
+ this.reconcile(n.members, n.rosterRevision, t);
3296
+ return;
3297
+ }
2832
3298
  if (e.type === "verificationUpdated" && this.verificationRequest && this.verificationRequest.id === e.requestId) {
2833
3299
  if (e.ok !== !0 || typeof e.required != "boolean") this.rejectVerification(typeof e.error == "string" ? e.error : "Verification update failed.", e.ok !== !1);
2834
3300
  else {
@@ -2850,12 +3316,13 @@ var at = class {
2850
3316
  siteKey: e.siteKey,
2851
3317
  roomId: this.room
2852
3318
  }, t.signal);
2853
- if (t.signal.aborted || this.closed || this.ws.readyState !== st) return;
3319
+ if (t.signal.aborted || this.closed || this.ws.readyState !== kt) return;
2854
3320
  if (typeof n != "string" || n.length === 0 || n.length > 2048) throw Error("Invalid verification response.");
2855
- this.signal({
3321
+ this.requestSentAt = performance.now(), this.signal({
2856
3322
  type: "hello",
2857
3323
  ...this.credentials,
2858
- verificationToken: n
3324
+ verificationToken: n,
3325
+ ...this.runtime.signalingResume ? { signalingVersion: 2 } : {}
2859
3326
  });
2860
3327
  } catch (e) {
2861
3328
  this.closed || (this.close(), this.hooks.ended?.(e instanceof Error ? e.message : "Room verification failed."));
@@ -2864,6 +3331,14 @@ var at = class {
2864
3331
  }
2865
3332
  return;
2866
3333
  }
3334
+ if (e.type === "passwordUpgradeRequired" && this.host) {
3335
+ this.hooks.status("Update the room password or explicitly unlock it to allow new guests.");
3336
+ return;
3337
+ }
3338
+ if (e.type === "passwordUpdated" && e.ok === !1 && this.passwordRequest?.id === e.requestId) {
3339
+ this.rejectPasswordUpdate(typeof e.error == "string" ? e.error : "Password update failed.");
3340
+ return;
3341
+ }
2867
3342
  if (e.type === "passwordUpdated" && typeof e.locked == "boolean" && this.passwordRequest && this.passwordRequest.id === e.requestId) {
2868
3343
  let t = this.passwordRequest;
2869
3344
  this.passwordRequest = void 0, clearTimeout(t.timer), t.resolve(e.locked);
@@ -2878,69 +3353,124 @@ var at = class {
2878
3353
  return;
2879
3354
  }
2880
3355
  if (e.type === "ready") {
2881
- this.id = e.id, this.host = e.role === "host", this.hostId = e.hostId, this.verificationState = typeof e.requireVerification == "boolean" ? e.requireVerification : null, this.hooks.ready(this.id, this.host);
2882
- return;
2883
- }
2884
- if (e.type === "peer" && this.host) {
2885
- let t = this.make(e.id);
2886
- this.bind(t, t.pc.createDataChannel("control", { ordered: !0 })), this.bind(t, t.pc.createDataChannel("realtime", {
2887
- ordered: !1,
2888
- maxRetransmits: 0
2889
- }));
2890
- let n = await t.pc.createOffer();
2891
- if (!this.current(t) || (await t.pc.setLocalDescription(n), !this.current(t))) return;
2892
- this.signal({
2893
- type: "signal",
2894
- to: t.id,
2895
- signal: {
2896
- type: "offer",
2897
- sdp: t.pc.localDescription.sdp
3356
+ if (this.id) return;
3357
+ if (this.runtime.signalingResume && e.resumeGrant !== void 0) {
3358
+ let t = yt(e);
3359
+ if (!t) {
3360
+ this.close(), this.hooks.ended?.("Invalid room admission.");
3361
+ return;
2898
3362
  }
2899
- });
3363
+ if (this.id = t.id, this.host = t.role === "host", this.hostId = t.hostId, this.verificationState = t.requireVerification, this.lockedState = t.locked, this.startRecovery(t.resumeGrant), this.closed) return;
3364
+ this.members = new Map(t.members.map((e) => [e.id, e])), this.rosterRevision = t.rosterRevision;
3365
+ } else this.id = e.id, this.host = e.role === "host", this.hostId = e.hostId, this.verificationState = typeof e.requireVerification == "boolean" ? e.requireVerification : null;
3366
+ this.hooks.ready(this.id, this.host), this.resumeGrant && this.reconcile([...this.members.values()], this.rosterRevision, t);
2900
3367
  return;
2901
3368
  }
2902
- if (e.type === "leave") {
2903
- this.remove(e.id);
3369
+ if (e.type === "peer" || e.type === "leave") {
3370
+ if (this.resumeGrant) {
3371
+ if (!At(e.id) || !jt(e.connectionEpoch) || !Number.isSafeInteger(e.rosterRevision) || e.rosterRevision <= this.rosterRevision || e.id === this.id) return;
3372
+ let t = this.members.get(e.id);
3373
+ if (t && e.connectionEpoch < t.connectionEpoch) return;
3374
+ this.rosterRevision = e.rosterRevision, e.type === "peer" ? this.members.set(e.id, {
3375
+ id: e.id,
3376
+ role: e.id === this.hostId ? "host" : "guest",
3377
+ attached: !0,
3378
+ connectionEpoch: e.connectionEpoch
3379
+ }) : this.members.delete(e.id);
3380
+ }
3381
+ if (e.type === "leave") {
3382
+ this.remove(e.id, !1);
3383
+ return;
3384
+ }
3385
+ this.host && !this.peers.has(e.id) && await this.offerPeer(e.id, t);
2904
3386
  return;
2905
3387
  }
2906
- if (e.type !== "signal") return;
2907
- let t = this.peers.get(e.from);
2908
- if (!t) {
3388
+ if (e.type !== "signal" || this.resumeGrant && (!At(e.negotiationId) || e.toConnectionEpoch !== this.resumeGrant.connectionEpoch || e.fromConnectionEpoch !== this.members.get(e.from)?.connectionEpoch || !this.members.get(e.from)?.attached)) return;
3389
+ let n = this.peers.get(e.from);
3390
+ if (!n) {
2909
3391
  if (this.host || e.from !== this.hostId || !["offer", "candidate"].includes(e.signal.type)) return;
2910
- t = this.make(e.from);
3392
+ n = this.make(e.from);
3393
+ }
3394
+ if (this.resumeGrant) {
3395
+ if (e.signal.type === "offer") {
3396
+ if (this.host || !Mt(e.signal.sdp)) return;
3397
+ n.negotiationId !== e.negotiationId && (n.candidates = []), this.beginNegotiation(n, e.negotiationId), n.remoteIceUfrag = Mt(e.signal.sdp), n.localIceUfrag = void 0;
3398
+ } else if (e.signal.type === "candidate" && !n.negotiationId && !this.host) this.beginNegotiation(n, e.negotiationId);
3399
+ else if (n.negotiationId !== e.negotiationId) return;
3400
+ if (n.negotiationLocalEpoch !== e.toConnectionEpoch || n.negotiationRemoteEpoch !== e.fromConnectionEpoch) return;
3401
+ if (e.signal.type === "answer") {
3402
+ if (!Mt(e.signal.sdp)) return;
3403
+ n.remoteIceUfrag = Mt(e.signal.sdp);
3404
+ }
2911
3405
  }
3406
+ let r = n.negotiationId, i = () => this.current(n) && t === this.socketSerial && this.signalingAdmitted && n.negotiationId === r && this.negotiationCurrent(n);
2912
3407
  if (e.signal.type === "offer") {
2913
3408
  if (this.host) throw Error("Only the host can offer");
2914
- if (await t.pc.setRemoteDescription({
3409
+ if (await n.pc.setRemoteDescription({
2915
3410
  type: "offer",
2916
3411
  sdp: e.signal.sdp
2917
- }), !this.current(t) || (await this.flushCandidates(t), !this.current(t))) return;
2918
- let n = await t.pc.createAnswer();
2919
- if (!this.current(t) || (await t.pc.setLocalDescription(n), !this.current(t))) return;
2920
- this.signal({
2921
- type: "signal",
2922
- to: t.id,
2923
- signal: {
2924
- type: "answer",
2925
- sdp: t.pc.localDescription.sdp
2926
- }
3412
+ }), !i() || (await this.flushCandidates(n, i), !i())) return;
3413
+ let t = await n.pc.createAnswer();
3414
+ if (!i() || (n.localIceUfrag = Mt(t.sdp), await n.pc.setLocalDescription(t), !i())) return;
3415
+ this.peerSignal(n, {
3416
+ type: "answer",
3417
+ sdp: n.pc.localDescription.sdp
2927
3418
  });
2928
3419
  } else if (e.signal.type === "answer") {
2929
3420
  if (!this.host) throw Error("Only guests can answer");
2930
- if (await t.pc.setRemoteDescription({
3421
+ if (await n.pc.setRemoteDescription({
2931
3422
  type: "answer",
2932
3423
  sdp: e.signal.sdp
2933
- }), !this.current(t)) return;
2934
- await this.flushCandidates(t), this.noteHealthy(t);
3424
+ }), !i()) return;
3425
+ await this.flushCandidates(n, i), this.noteHealthy(n);
2935
3426
  } else if (e.signal.type === "candidate" && e.signal.candidate) {
2936
- if (!t.pc.remoteDescription) this.queueCandidate(t, e.signal.candidate);
3427
+ if (this.resumeGrant && (!Nt(e.signal.candidate) || n.remoteIceUfrag && Nt(e.signal.candidate) !== n.remoteIceUfrag)) return;
3428
+ if (!n.pc.remoteDescription) this.queueCandidate(n, e.signal.candidate);
2937
3429
  else try {
2938
- await t.pc.addIceCandidate(e.signal.candidate);
3430
+ await n.pc.addIceCandidate(e.signal.candidate);
2939
3431
  } catch {
2940
- this.queueCandidate(t, e.signal.candidate);
3432
+ i() && this.queueCandidate(n, e.signal.candidate);
2941
3433
  }
2942
3434
  }
2943
3435
  }
3436
+ reconcile(e, t, n) {
3437
+ this.members = new Map(e.map((e) => [e.id, e])), this.rosterRevision = t;
3438
+ for (let e of [...this.peers.keys()]) this.members.has(e) || this.remove(e, !1);
3439
+ if (this.host) for (let t of e) t.id !== this.id && t.attached && !this.peers.has(t.id) && this.offerPeer(t.id, n).catch(() => {
3440
+ !this.closed && n === this.socketSerial && this.hooks.status("Connection negotiation failed.");
3441
+ });
3442
+ }
3443
+ negotiationCurrent(e) {
3444
+ return !this.resumeGrant || e.negotiationLocalEpoch === this.resumeGrant.connectionEpoch && e.negotiationRemoteEpoch === this.members.get(e.id)?.connectionEpoch && this.members.get(e.id)?.attached === !0;
3445
+ }
3446
+ beginNegotiation(e, t) {
3447
+ e.negotiationId = t, e.negotiationLocalEpoch = this.resumeGrant?.connectionEpoch, e.negotiationRemoteEpoch = this.members.get(e.id)?.connectionEpoch;
3448
+ }
3449
+ peerSignal(e, t) {
3450
+ let n = this.resumeGrant, r = this.members.get(e.id);
3451
+ (!n || r?.attached && e.negotiationId && this.signalingAdmitted && e.negotiationLocalEpoch === n.connectionEpoch && e.negotiationRemoteEpoch === r.connectionEpoch) && this.signal({
3452
+ type: "signal",
3453
+ to: e.id,
3454
+ signal: t,
3455
+ ...n ? {
3456
+ fromConnectionEpoch: n.connectionEpoch,
3457
+ toConnectionEpoch: r.connectionEpoch,
3458
+ negotiationId: e.negotiationId
3459
+ } : {}
3460
+ });
3461
+ }
3462
+ async offerPeer(e, t) {
3463
+ let n = this.make(e);
3464
+ this.bind(n, n.pc.createDataChannel("control", { ordered: !0 })), this.bind(n, n.pc.createDataChannel("realtime", {
3465
+ ordered: !1,
3466
+ maxRetransmits: 0
3467
+ })), this.resumeGrant && this.beginNegotiation(n, crypto.randomUUID());
3468
+ let r = n.negotiationId, i = () => this.current(n) && t === this.socketSerial && this.signalingAdmitted && n.negotiationId === r && this.negotiationCurrent(n), a = await n.pc.createOffer();
3469
+ i() && (n.localIceUfrag = Mt(a.sdp), await n.pc.setLocalDescription(a), i() && this.peerSignal(n, {
3470
+ type: "offer",
3471
+ sdp: n.pc.localDescription.sdp
3472
+ }));
3473
+ }
2944
3474
  current(e) {
2945
3475
  return !this.closed && this.peers.get(e.id) === e;
2946
3476
  }
@@ -2955,28 +3485,27 @@ var at = class {
2955
3485
  let t = e.lostAt !== void 0;
2956
3486
  e.lostAt = void 0, e.restarts = 0, t && this.hooks.status("Direct connection restored.");
2957
3487
  }
2958
- async flushCandidates(e) {
2959
- let t = e.candidates.splice(0);
2960
- for (let n of t) {
2961
- if (!this.current(e)) return;
2962
- try {
2963
- await e.pc.addIceCandidate(n);
3488
+ async flushCandidates(e, t = () => this.current(e)) {
3489
+ let n = e.candidates.splice(0);
3490
+ for (let r of n) {
3491
+ if (!t()) return;
3492
+ if (!this.resumeGrant || e.remoteIceUfrag && Nt(r) === e.remoteIceUfrag) try {
3493
+ await e.pc.addIceCandidate(r);
2964
3494
  } catch {}
2965
3495
  }
2966
3496
  }
2967
3497
  async restartPeer(e) {
2968
3498
  let t = this.peers.get(e);
2969
- if (this.closed || !this.host || !t || t.restarting || t.restarts >= 2 || t.pc.signalingState !== "stable" || this.ws.readyState !== st) return !1;
3499
+ if (this.closed || !this.host || !t || t.restarting || t.restarts >= 2 || t.pc.signalingState !== "stable" || !this.signalingAdmitted || this.ws.readyState !== kt) return !1;
3500
+ let n = this.socketSerial;
3501
+ this.resumeGrant && (this.beginNegotiation(t, crypto.randomUUID()), t.localIceUfrag = void 0, t.remoteIceUfrag = void 0, t.candidates = []);
3502
+ let r = t.negotiationId, i = () => this.current(t) && n === this.socketSerial && this.signalingAdmitted && t.negotiationId === r && this.negotiationCurrent(t);
2970
3503
  t.restarting = !0, t.lastRestart = performance.now(), t.lostAt ??= t.lastRestart, t.restarts++;
2971
3504
  try {
2972
- let n = await t.pc.createOffer({ iceRestart: !0 });
2973
- return this.closed || this.peers.get(e) !== t || (await t.pc.setLocalDescription(n), this.closed || this.peers.get(e) !== t) ? !1 : (this.signal({
2974
- type: "signal",
2975
- to: t.id,
2976
- signal: {
2977
- type: "offer",
2978
- sdp: t.pc.localDescription.sdp
2979
- }
3505
+ let e = await t.pc.createOffer({ iceRestart: !0 });
3506
+ return !i() || (t.localIceUfrag = Mt(e.sdp), await t.pc.setLocalDescription(e), !i()) ? !1 : (this.peerSignal(t, {
3507
+ type: "offer",
3508
+ sdp: t.pc.localDescription.sdp
2980
3509
  }), !0);
2981
3510
  } catch {
2982
3511
  return !this.closed && this.peers.get(e) === t && this.hooks.status("Direct connection recovery is still pending."), !1;
@@ -2998,14 +3527,12 @@ var at = class {
2998
3527
  restarts: 0,
2999
3528
  restarting: !1
3000
3529
  };
3001
- this.peers.set(e, n), t.onicecandidate = (t) => {
3002
- this.closed || this.peers.get(e) !== n || t.candidate && this.signal({
3003
- type: "signal",
3004
- to: e,
3005
- signal: {
3006
- type: "candidate",
3007
- candidate: t.candidate.toJSON()
3008
- }
3530
+ this.peers.set(e, n), t.onicecandidate = (e) => {
3531
+ if (!this.current(n) || !e.candidate || !this.signalingAdmitted) return;
3532
+ let t = e.candidate.toJSON();
3533
+ (!this.resumeGrant || n.localIceUfrag && Nt(t) === n.localIceUfrag) && this.peerSignal(n, {
3534
+ type: "candidate",
3535
+ candidate: t
3009
3536
  });
3010
3537
  }, t.ondatachannel = (e) => this.bind(n, e.channel);
3011
3538
  let r = () => {
@@ -3037,7 +3564,7 @@ var at = class {
3037
3564
  if (this.host && t && !this.hooks.allowStadiumUpload?.(e)) throw Error("Guest control size or permission");
3038
3565
  if (typeof n.data != "string" && !(n.data instanceof ArrayBuffer)) throw Error("Invalid control type");
3039
3566
  let r = this.controlAssemblers.get(e.id);
3040
- r || (r = new at(), this.controlAssemblers.set(e.id, r));
3567
+ r || (r = new Dt(), this.controlAssemblers.set(e.id, r));
3041
3568
  let i = r.push(n.data);
3042
3569
  if (i !== void 0) {
3043
3570
  if (this.host && t && (!i || typeof i != "object" || i.type !== "action" || i.action !== "customStadium")) throw Error("Invalid bulk action");
@@ -3056,7 +3583,7 @@ var at = class {
3056
3583
  }
3057
3584
  control(e, t) {
3058
3585
  if (e.control?.readyState !== "open") return;
3059
- let n = it(t, this.controlId++), r = n.reduce((e, t) => e + (typeof t == "string" ? new TextEncoder().encode(t).length : t.byteLength), 0);
3586
+ let n = Et(t, this.controlId++), r = n.reduce((e, t) => e + (typeof t == "string" ? new TextEncoder().encode(t).length : t.byteLength), 0);
3060
3587
  if (e.control.bufferedAmount + r > 1048576) {
3061
3588
  this.remove(e.id);
3062
3589
  return;
@@ -3081,7 +3608,7 @@ var at = class {
3081
3608
  }
3082
3609
  try {
3083
3610
  let t = await e.pc.getStats();
3084
- !this.closed && this.peers.get(e.id) === e && (e.rtt = et(t.values()));
3611
+ !this.closed && this.peers.get(e.id) === e && (e.rtt = St(t.values()));
3085
3612
  } catch {
3086
3613
  e.rtt = null;
3087
3614
  }
@@ -3091,23 +3618,28 @@ var at = class {
3091
3618
  }
3092
3619
  }
3093
3620
  }
3094
- remove(e) {
3095
- let t = this.peers.get(e);
3096
- t && (clearTimeout(t.admissionTimer), this.peers.delete(e), this.controlAssemblers.delete(e), t.pc.close(), this.host ? this.signal({
3621
+ remove(e, t = !0) {
3622
+ let n = this.peers.get(e);
3623
+ n && (clearTimeout(n.admissionTimer), this.peers.delete(e), this.controlAssemblers.delete(e), n.pc.close(), this.host && t ? this.signal({
3097
3624
  type: "evict",
3098
3625
  id: e
3099
- }) : this.close(), this.hooks.leave(e), this.host || this.hooks.ended?.("The host connection ended."));
3626
+ }) : this.host || this.close(), this.hooks.leave(e), this.host || this.hooks.ended?.("The host connection ended."));
3100
3627
  }
3101
3628
  close() {
3102
- this.challenge?.abort(), this.rejectVerification("Room closed before verification confirmation."), this.verificationState = null, this.rejectBan("Room closed before ban confirmation."), this.rejectPasswordUpdate("Room closed before password confirmation."), this.closed = !0, clearInterval(this.timer), this.ws.close(1e3, "Left room");
3103
- for (let e of this.peers.values()) clearTimeout(e.admissionTimer), e.pc.close();
3104
- this.peers.clear(), this.controlAssemblers.clear();
3629
+ if (!this.closed) {
3630
+ this.resumeGrant && this.signalingAdmitted && this.ws.readyState === kt && this.signal({
3631
+ type: "leave",
3632
+ connectionEpoch: this.resumeGrant.connectionEpoch
3633
+ }), this.recovery?.cancel(), this.resumeGrant = void 0, this.resumeAttempt = void 0, this.cancelHeartbeat(), this.socketSerial++, this.challenge?.abort(), this.rejectVerification("Room closed before verification confirmation."), this.verificationState = null, this.rejectBan("Room closed before ban confirmation."), this.rejectPasswordUpdate("Room closed before password confirmation."), this.closed = !0, clearInterval(this.timer), this.ws.close(1e3, "Left room");
3634
+ for (let e of this.peers.values()) clearTimeout(e.admissionTimer), e.pc.close();
3635
+ this.peers.clear(), this.controlAssemblers.clear();
3636
+ }
3105
3637
  }
3106
3638
  };
3107
- function lt(e, t) {
3639
+ function Ft(e, t) {
3108
3640
  return e !== t && e - t >>> 0 < 2147483648;
3109
3641
  }
3110
- function ut(e) {
3642
+ function It(e) {
3111
3643
  if (e.byteLength !== 14) throw Error("Input length");
3112
3644
  let t = new DataView(e);
3113
3645
  if (t.getUint8(0) !== 1 || t.getUint8(1) !== 5 || t.getUint8(6) > 31 || t.getUint8(7)) throw Error("Input format");
@@ -3118,7 +3650,8 @@ function ut(e) {
3118
3650
  epoch: t.getUint16(12, !0)
3119
3651
  };
3120
3652
  }
3121
- function dt(e, t, n = 0) {
3653
+ function Lt(e, t, n = 0) {
3654
+ if (e.surface?.length) throw Error("Terrain transport is not enabled");
3122
3655
  let r = [];
3123
3656
  for (let t = 0; t < e.discs.length / 18; t++) {
3124
3657
  let n = t * 18, i = e.discs, a = i[n + 5] > 0 || i[n + 2] !== 0 || i[n + 3] !== 0 || i[n + 8] !== 0 || i[n + 9] !== 0 || i[n] !== i[n + 16] || i[n + 1] !== i[n + 17];
@@ -3143,9 +3676,7 @@ function dt(e, t, n = 0) {
3143
3676
  }
3144
3677
  return c;
3145
3678
  }
3146
- //#endregion
3147
- //#region src/client/headless.ts
3148
- var ft = Object.freeze({ ...C }), pt = class e {
3679
+ var Rt = Object.freeze({ ...Te }), zt = class e {
3149
3680
  runtime;
3150
3681
  engine;
3151
3682
  network;
@@ -3171,10 +3702,11 @@ var ft = Object.freeze({ ...C }), pt = class e {
3171
3702
  locked = !1;
3172
3703
  teamStyles = [null, null];
3173
3704
  inputs = /* @__PURE__ */ new Map();
3174
- traffic = new U();
3705
+ traffic = new Ke();
3175
3706
  onRoomLink;
3176
3707
  onPlayerJoin;
3177
3708
  onPlayerTeamChange;
3709
+ onPlayerMuteChange;
3178
3710
  onPlayerAdminChange;
3179
3711
  onGameStart;
3180
3712
  onGameStop;
@@ -3213,16 +3745,16 @@ var ft = Object.freeze({ ...C }), pt = class e {
3213
3745
  constructor(e, t) {
3214
3746
  this.runtime = t, this.engine = e;
3215
3747
  }
3216
- static async create(t, n = te(), r) {
3217
- let i = R(n.network.serviceOrigin);
3218
- if (t = d(t), t.noPlayer !== void 0 && typeof t.noPlayer != "boolean") throw Error("Invalid noPlayer setting");
3748
+ static async create(t, n = We(), r) {
3749
+ let i = Be(n.network.serviceOrigin);
3750
+ if (t = me(t), t.noPlayer !== void 0 && typeof t.noPlayer != "boolean") throw Error("Invalid noPlayer setting");
3219
3751
  let a = t.noPlayer === !1, o = t.playerName ?? "Host";
3220
3752
  if (a && (typeof o != "string" || !o.trim() || o.length > 24)) throw Error("Invalid host player name");
3221
- let s = l(r), c;
3753
+ let s = fe(r), c;
3222
3754
  try {
3223
3755
  s.signal.throwIfAborted();
3224
3756
  let r = await s.run(n.loadEngine(s.signal));
3225
- r.load(t.stadium ?? F()), c = new e(r, n);
3757
+ r.load(t.stadium ?? Ie()), c = new e(r, n);
3226
3758
  let l = c, u = await s.run(n.request(new URL("/api/rooms", i), {
3227
3759
  signal: s.signal,
3228
3760
  method: "POST",
@@ -3237,11 +3769,11 @@ var ft = Object.freeze({ ...C }), pt = class e {
3237
3769
  }));
3238
3770
  if (!u.ok) throw Error(`Room creation failed (${u.status})`);
3239
3771
  let d = await s.run(u.json());
3240
- l.roomId = d.id, l.roomName = t.roomName, l.roomLink = `${i}${p(d.id)}`;
3772
+ l.roomId = d.id, l.roomName = t.roomName, l.roomLink = `${i}${Q(d.id)}`;
3241
3773
  let f;
3242
3774
  try {
3243
3775
  await s.run(new Promise((e, t) => {
3244
- f = setTimeout(() => t(Error("Signaling timed out")), 12e3), l.network = new ct(d.id, { hostToken: d.hostToken }, {
3776
+ f = setTimeout(() => t(Error("Signaling timed out")), 12e3), l.network = new Pt(d.id, { hostToken: d.hostToken }, {
3245
3777
  ready: (n, r) => {
3246
3778
  if (!r) {
3247
3779
  t(Error("Host authority was not granted"));
@@ -3274,9 +3806,9 @@ var ft = Object.freeze({ ...C }), pt = class e {
3274
3806
  }
3275
3807
  if (l.closed) throw Error("Room closed during startup");
3276
3808
  l.last = performance.now(), l.loop = setInterval(() => l.advance(), 1e3 / 60);
3277
- let m = l.roomLink;
3809
+ let p = l.roomLink;
3278
3810
  return l.linkNotification = setTimeout(() => {
3279
- l.linkNotification = void 0, l.invoke("onRoomLink", l.onRoomLink, m);
3811
+ l.linkNotification = void 0, l.invoke("onRoomLink", l.onRoomLink, p);
3280
3812
  }, 0), c;
3281
3813
  } catch (e) {
3282
3814
  throw c?.close(), e;
@@ -3309,7 +3841,15 @@ var ft = Object.freeze({ ...C }), pt = class e {
3309
3841
  if (this.engine.red > t && this.invoke("onTeamGoal", this.onTeamGoal, 1), this.engine.blue > n && this.invoke("onTeamGoal", this.onTeamGoal, 2), i && this.invoke("onPositionsReset", this.onPositionsReset), this.closed) break;
3310
3842
  if (this.engine.tick % 2 == 0) {
3311
3843
  let e = this.engine.snapshot();
3312
- for (let t of this.network.peers.values()) for (let n of dt(e, this.inputs.get(t.id)?.seq ?? 0, this.epoch)) this.network.fast(t, n);
3844
+ if (e.surface?.length) {
3845
+ if (this.engine.tick % 6 == 0) {
3846
+ let t = de(e, this.epoch);
3847
+ for (let e of this.network.peers.values()) e.control?.readyState === "open" && e.control.bufferedAmount < 65536 && this.network.control(e, {
3848
+ ...t,
3849
+ ack: this.inputs.get(e.id)?.seq ?? 0
3850
+ });
3851
+ }
3852
+ } else for (let t of this.network.peers.values()) for (let n of Lt(e, this.inputs.get(t.id)?.seq ?? 0, this.epoch)) this.network.fast(t, n);
3313
3853
  }
3314
3854
  this.accumulator -= 1e3 / 60;
3315
3855
  }
@@ -3324,7 +3864,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3324
3864
  if (!this.allowed(e) || !t || typeof t != "object") return;
3325
3865
  let n = t, r = this.players.find((t) => t.peerId === e.id);
3326
3866
  if (n.type === "join" && !r) {
3327
- if (n.version !== 1 || n.engine !== ee || typeof n.name != "string" || !n.name.trim() || n.name.length > 24) {
3867
+ if (n.version !== 1 || n.engine !== Le || typeof n.name != "string" || !n.name.trim() || n.name.length > 24) {
3328
3868
  this.network.remove(e.id);
3329
3869
  return;
3330
3870
  }
@@ -3344,7 +3884,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3344
3884
  type: "welcome",
3345
3885
  epoch: this.epoch,
3346
3886
  roomName: this.roomName,
3347
- engine: ee,
3887
+ engine: Le,
3348
3888
  slot: t,
3349
3889
  stadium: this.engine.source,
3350
3890
  state: this.engine.snapshot(),
@@ -3356,15 +3896,15 @@ var ft = Object.freeze({ ...C }), pt = class e {
3356
3896
  }
3357
3897
  if (r && n.type === "action") {
3358
3898
  if (n.action === "chat" && typeof n.text == "string" && n.text.length <= 200) {
3359
- if (!n.text.trim() || !this.traffic.allow(e.id, "chat") || (this.invoke("onPlayerActivity", this.onPlayerActivity, this.playerCopy(r)), this.closed || !this.players.includes(r))) return;
3360
- this.invoke("onPlayerChat", this.onPlayerChat, this.playerCopy(r), n.text) !== !1 && this.network.broadcast({
3899
+ if (r.muted || !n.text.trim() || !this.traffic.allow(e.id, "chat") || (this.invoke("onPlayerActivity", this.onPlayerActivity, this.playerCopy(r)), this.closed || !this.players.includes(r))) return;
3900
+ this.invoke("onPlayerChat", this.onPlayerChat, this.playerCopy(r), n.text) !== !1 && !this.closed && this.players.includes(r) && !r.muted && this.network.broadcast({
3361
3901
  type: "chat",
3362
3902
  name: r.name,
3363
3903
  text: n.text
3364
3904
  });
3365
3905
  }
3366
3906
  if (n.action === "chat" || this.traffic.allow(e.id, "action")) {
3367
- if (n.action === "avatar" && v(n.avatar)) {
3907
+ if (n.action === "avatar" && be(n.avatar)) {
3368
3908
  r.avatar = n.avatar, this.recorder?.player(this.engine.tick, r.slot, r.name, r.avatarOverride ?? r.avatar), this.sync();
3369
3909
  return;
3370
3910
  }
@@ -3401,6 +3941,15 @@ var ft = Object.freeze({ ...C }), pt = class e {
3401
3941
  return;
3402
3942
  }
3403
3943
  if (r.admin) {
3944
+ if (n.action === "mute" && typeof n.muted == "boolean") {
3945
+ let e = this.players.find((e) => e.slot === n.slot);
3946
+ e && e !== r && e.peerId !== this.network.hostId && this.changePlayerMuted(e.id, n.muted, this.playerCopy(r));
3947
+ return;
3948
+ }
3949
+ if (n.action === "surface" && typeof n.enabled == "boolean" && ["lobby", "finished"].includes(this.engine.phase)) {
3950
+ this.setSurfaceEnabled(n.enabled);
3951
+ return;
3952
+ }
3404
3953
  if (n.action === "ban" || n.action === "clearBans") {
3405
3954
  let t = this.players.find((e) => e.slot === n.slot);
3406
3955
  if (n.action === "ban" && (!t || t === r || t.peerId === this.network.hostId)) return;
@@ -3419,7 +3968,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3419
3968
  }
3420
3969
  if (n.action === "teamColors" && (n.team === 1 || n.team === 2)) {
3421
3970
  let e = n.palette;
3422
- this.changeTeamColors(n.team, e === null ? null : m(e.angle, e.textColor, e.colors));
3971
+ this.changeTeamColors(n.team, e === null ? null : ge(e.angle, e.textColor, e.colors));
3423
3972
  }
3424
3973
  if (n.action === "kickRate" && Number.isInteger(n.value) && Number(n.value) >= 0 && Number(n.value) <= 6619135) {
3425
3974
  let e = Number(n.value);
@@ -3447,10 +3996,10 @@ var ft = Object.freeze({ ...C }), pt = class e {
3447
3996
  if (!this.allowed(e)) return;
3448
3997
  let n = this.players.find((t) => t.peerId === e.id);
3449
3998
  if (!n) return;
3450
- let r = ut(t);
3999
+ let r = It(t);
3451
4000
  if (r.epoch !== this.epoch) return;
3452
4001
  let i = this.inputs.get(e.id);
3453
- (!i || lt(r.seq, i.seq)) && (this.inputs.set(e.id, {
4002
+ (!i || Ft(r.seq, i.seq)) && (this.inputs.set(e.id, {
3454
4003
  seq: r.seq,
3455
4004
  received: performance.now(),
3456
4005
  keys: r.keys
@@ -3465,7 +4014,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3465
4014
  value: n
3466
4015
  };
3467
4016
  if (this.recorder && (!this.recorder.canRecord(this.engine) || !this.recorder.command(r)) && this.finishRecording("Recording limit reached"), this.closed) throw Error("Room is closed");
3468
- Xe(this.engine, r);
4017
+ at(this.engine, r);
3469
4018
  }
3470
4019
  roster() {
3471
4020
  return this.players.map((e) => ({
@@ -3474,7 +4023,8 @@ var ft = Object.freeze({ ...C }), pt = class e {
3474
4023
  slot: e.slot,
3475
4024
  name: e.name,
3476
4025
  team: e.team,
3477
- admin: e.admin
4026
+ admin: e.admin,
4027
+ muted: !!e.muted
3478
4028
  }));
3479
4029
  }
3480
4030
  sync() {
@@ -3503,6 +4053,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3503
4053
  let t = this.engine.index(e.slot) * 18, n = !this.closed && this.engine.phase !== "lobby" && this.engine.data[t + 13] > 0, { slot: r, avatarOverride: i, ...a } = e;
3504
4054
  return {
3505
4055
  ...a,
4056
+ muted: !!e.muted,
3506
4057
  avatar: e.avatarOverride ?? e.avatar ?? null,
3507
4058
  position: n ? {
3508
4059
  x: this.engine.data[t],
@@ -3518,7 +4069,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3518
4069
  return t ? this.playerCopy(t) : null;
3519
4070
  }
3520
4071
  setTeamColors(e, t, n, r) {
3521
- this.changeTeamColors(e, m(t, n, r));
4072
+ this.changeTeamColors(e, ge(t, n, r));
3522
4073
  }
3523
4074
  changeTeamColors(e, t) {
3524
4075
  if (this.closed) throw Error("Room is closed");
@@ -3536,7 +4087,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3536
4087
  }
3537
4088
  setPlayerAvatar(e, t) {
3538
4089
  if (this.closed) throw Error("Room is closed");
3539
- if (!v(t)) throw Error("Avatar must be null or at most two visible characters.");
4090
+ if (!be(t)) throw Error("Avatar must be null or at most two visible characters.");
3540
4091
  let n = this.players.find((t) => t.id === e);
3541
4092
  n && (n.avatarOverride = t, this.recorder?.player(this.engine.tick, n.slot, n.name, t ?? n.avatar), this.sync());
3542
4093
  }
@@ -3558,6 +4109,15 @@ var ft = Object.freeze({ ...C }), pt = class e {
3558
4109
  let n = this.players.find((t) => t.id === e);
3559
4110
  n && n.admin !== !!t && (n.admin = !!t, this.sync(), this.invoke("onPlayerAdminChange", this.onPlayerAdminChange, this.playerCopy(n), null));
3560
4111
  }
4112
+ setPlayerMuted(e, t) {
4113
+ this.changePlayerMuted(e, t, null);
4114
+ }
4115
+ changePlayerMuted(e, t, n) {
4116
+ if (this.closed) throw Error("Room is closed");
4117
+ if (!Number.isInteger(e) || typeof t != "boolean") throw Error("Invalid player mute");
4118
+ let r = this.players.find((t) => t.id === e);
4119
+ r && r.peerId !== this.network.hostId && !!r.muted !== t && (r.muted = t, this.sync(), this.invoke("onPlayerMuteChange", this.onPlayerMuteChange, this.playerCopy(r), n));
4120
+ }
3561
4121
  setTeamsLock(e) {
3562
4122
  this.changeTeamsLock(e, null);
3563
4123
  }
@@ -3580,7 +4140,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3580
4140
  try {
3581
4141
  await this.network.updateBan("ban", r.peerId);
3582
4142
  } catch (t) {
3583
- throw t instanceof ot && this.bans.set(e, r.peerId), t;
4143
+ throw t instanceof Ot && this.bans.set(e, r.peerId), t;
3584
4144
  }
3585
4145
  this.bans.set(e, r.peerId), this.network.remove(r.peerId), this.invoke("onPlayerKicked", this.onPlayerKicked, i, a, !0, n);
3586
4146
  }
@@ -3625,7 +4185,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3625
4185
  }
3626
4186
  sendAnnouncement(e, t, n, r, i) {
3627
4187
  if (this.closed) throw Error("Room is closed");
3628
- let a = _(e, n, r, i);
4188
+ let a = ye(e, n, r, i);
3629
4189
  if (t != null && (!Number.isSafeInteger(t) || t < 0)) throw Error("Invalid announcement target");
3630
4190
  if (t == null) this.network.broadcast(a);
3631
4191
  else {
@@ -3656,12 +4216,18 @@ var ft = Object.freeze({ ...C }), pt = class e {
3656
4216
  if (this.closed) throw Error("Room is closed");
3657
4217
  this.engine.phase !== "lobby" && (e = !!e, this.engine.paused !== e && (this.command("pause", 0, +e), this.state(), e ? this.invoke("onGamePause", this.onGamePause, t) : this.invoke("onGameUnpause", this.onGameUnpause, t), this.invoke("onGamePauseChange", this.onGamePauseChange, e)));
3658
4218
  }
4219
+ setSurfaceEnabled(e) {
4220
+ if (this.closed) throw Error("Room is closed");
4221
+ if (typeof e != "boolean") throw Error("Surface enabled must be a boolean");
4222
+ if (!["lobby", "finished"].includes(this.engine.phase)) throw Error("Stop the match before changing its surface");
4223
+ !!this.engine.snapshotSurface().length !== e && (this.command("surface", 0, +e), this.state(), this.sync());
4224
+ }
3659
4225
  setKickRateLimit(e = 2, t = 0, n = 0) {
3660
4226
  this.changeKickRateLimit(e, t, n, null);
3661
4227
  }
3662
4228
  changeKickRateLimit(e, t, n, r) {
3663
4229
  if (this.closed) throw Error("Room is closed");
3664
- let i = L(e, t, n);
4230
+ let i = ze(e, t, n);
3665
4231
  i !== this.engine.kickRate && (this.command("kickRate", 0, i), this.state(), this.invoke("onKickRateLimitSet", this.onKickRateLimitSet, i & 255, i >>> 8 & 255, i >>> 16, r));
3666
4232
  }
3667
4233
  async setPassword(e) {
@@ -3706,7 +4272,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3706
4272
  changeStadium(e, t) {
3707
4273
  if (this.closed) throw Error("Room is closed");
3708
4274
  if (!["lobby", "finished"].includes(this.engine.phase)) return;
3709
- P(e);
4275
+ Fe(e);
3710
4276
  let n = ++this.stadiumSelection;
3711
4277
  if (this.recorder && this.finishRecording("Stadium changed"), this.closed) throw Error("Room is closed");
3712
4278
  if (["lobby", "finished"].includes(this.engine.phase)) {
@@ -3756,7 +4322,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3756
4322
  };
3757
4323
  }
3758
4324
  get CollisionFlags() {
3759
- return ft;
4325
+ return Rt;
3760
4326
  }
3761
4327
  getDiscCount() {
3762
4328
  return this.closed || this.engine.phase === "lobby" ? 0 : this.engine.stadium.discs.length + this.players.filter((e) => e.team !== 0).length;
@@ -3781,7 +4347,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3781
4347
  n && this.changeDisc(this.engine.index(n.slot), t);
3782
4348
  }
3783
4349
  changeDisc(e, t) {
3784
- let n = b(t), r = this.readDisc(e);
4350
+ let n = Se(t), r = this.readDisc(e);
3785
4351
  if (Object.entries(n).every(([e, t]) => r[e] === t)) return;
3786
4352
  let i = {
3787
4353
  tick: this.engine.tick,
@@ -3791,7 +4357,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3791
4357
  properties: n
3792
4358
  };
3793
4359
  if (this.recorder && (!this.recorder.canRecord(this.engine) || !this.recorder.command(i)) && this.finishRecording("Recording limit reached"), this.closed) throw Error("Room is closed");
3794
- Xe(this.engine, i), this.state();
4360
+ at(this.engine, i), this.state();
3795
4361
  }
3796
4362
  getPlayerDiscProperties(e) {
3797
4363
  if (this.closed || this.engine.phase === "lobby") return null;
@@ -3805,7 +4371,7 @@ var ft = Object.freeze({ ...C }), pt = class e {
3805
4371
  if (this.closed) throw Error("Room is closed");
3806
4372
  if (this.finishingRecording) throw Error("Recording completion is in progress");
3807
4373
  if (this.recorder) throw Error("Recording is already active");
3808
- this.recorder = new Ze(this.engine, this.players.map((e) => ({
4374
+ this.recorder = new ot(this.engine, this.players.map((e) => ({
3809
4375
  slot: e.slot,
3810
4376
  name: e.name,
3811
4377
  avatar: e.avatarOverride ?? e.avatar
@@ -3835,13 +4401,11 @@ var ft = Object.freeze({ ...C }), pt = class e {
3835
4401
  }
3836
4402
  }
3837
4403
  };
3838
- //#endregion
3839
- //#region src/sdk/config.ts
3840
- function mt(e) {
4404
+ function Bt(e) {
3841
4405
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Room configuration must be an object");
3842
4406
  let t = { ...e }, n = t.maxPlayers ?? 12;
3843
4407
  if (typeof n != "number" || !Number.isFinite(n) || !Number.isInteger(n)) throw Error("maxPlayers must be a finite integer");
3844
- return d({
4408
+ return me({
3845
4409
  ...t,
3846
4410
  roomName: t.roomName ?? "Headless Room",
3847
4411
  playerName: t.playerName ?? "Host",
@@ -3851,9 +4415,7 @@ function mt(e) {
3851
4415
  password: t.password ?? ""
3852
4416
  });
3853
4417
  }
3854
- //#endregion
3855
- //#region src/sdk/command-queue.ts
3856
- var ht = class {
4418
+ var Vt = class {
3857
4419
  onError;
3858
4420
  pending = [];
3859
4421
  active;
@@ -3906,44 +4468,19 @@ var ht = class {
3906
4468
  this.active?.reject(e);
3907
4469
  for (let t of this.pending.splice(0)) t.reject(e);
3908
4470
  }
3909
- }, gt = [
3910
- "sendChat",
3911
- "sendAnnouncement",
3912
- "setPlayerAdmin",
3913
- "setPlayerTeam",
3914
- "kickPlayer",
3915
- "clearBan",
3916
- "clearBans",
3917
- "setScoreLimit",
3918
- "setTimeLimit",
3919
- "setCustomStadium",
3920
- "setDefaultStadium",
3921
- "setTeamsLock",
3922
- "setTeamColors",
3923
- "startGame",
3924
- "stopGame",
3925
- "pauseGame",
3926
- "setPassword",
3927
- "setRequireVerification",
3928
- "setRequireRecaptcha",
3929
- "reorderPlayers",
3930
- "setKickRateLimit",
3931
- "setPlayerAvatar",
3932
- "setDiscProperties",
3933
- "setPlayerDiscProperties"
3934
- ];
3935
- function _t(e, t) {
4471
+ }, Ht = /* @__PURE__ */ "sendChat.sendAnnouncement.setPlayerAdmin.setPlayerMuted.setPlayerTeam.kickPlayer.clearBan.clearBans.setScoreLimit.setTimeLimit.setCustomStadium.setDefaultStadium.setTeamsLock.setTeamColors.startGame.stopGame.pauseGame.setPassword.setRequireVerification.setRequireRecaptcha.reorderPlayers.setKickRateLimit.setSurfaceEnabled.setPlayerAvatar.setDiscProperties.setPlayerDiscProperties".split(".");
4472
+ function Ut(e, t) {
3936
4473
  let n = Object.create(null);
3937
4474
  t && Object.defineProperty(n, "closed", {
3938
4475
  enumerable: !0,
3939
4476
  value: t
3940
4477
  });
3941
- let r = new ht((t) => {
4478
+ let r = new Vt((t) => {
3942
4479
  let n = e.onError?.(String(t));
3943
4480
  n instanceof Promise && n.catch(() => {});
3944
4481
  });
3945
4482
  e.signal.addEventListener("abort", () => r.close(), { once: !0 }), e.signal.aborted && r.close();
3946
- for (let t of gt) Object.defineProperty(n, t, {
4483
+ for (let t of Ht) Object.defineProperty(n, t, {
3947
4484
  enumerable: !0,
3948
4485
  value: (...n) => {
3949
4486
  try {
@@ -3990,6 +4527,7 @@ function _t(e, t) {
3990
4527
  "onPlayerChat",
3991
4528
  "onPlayerTeamChange",
3992
4529
  "onPlayerAdminChange",
4530
+ "onPlayerMuteChange",
3993
4531
  "onPlayerKicked",
3994
4532
  "onPlayerActivity",
3995
4533
  "onPlayerBallKick",
@@ -4026,26 +4564,19 @@ function _t(e, t) {
4026
4564
  }
4027
4565
  }), Object.preventExtensions(n);
4028
4566
  }
4029
- //#endregion
4030
- //#region src/sdk/replay.ts
4031
- function vt(e) {
4032
- return Qe(e);
4567
+ function Wt(e) {
4568
+ return st(e);
4033
4569
  }
4034
- //#endregion
4035
- //#region src/sdk/stadium.ts
4036
- function yt(e) {
4570
+ function Gt(e) {
4037
4571
  if (typeof e != "string") throw TypeError("Stadium source must be a string");
4038
- let t = P(e);
4572
+ let t = Fe(e);
4039
4573
  return Object.freeze({
4040
4574
  name: t.name,
4041
4575
  canBeStored: t.canBeStored,
4042
4576
  warnings: Object.freeze([...t.warnings])
4043
4577
  });
4044
4578
  }
4045
- //#endregion
4046
- //#region src/sdk/browser.ts
4047
- async function bt(e = {}, t = {}) {
4048
- return _t(await pt.create(mt(e), void 0, t.signal));
4579
+ async function Kt(e = {}, t = {}) {
4580
+ return Ut(await zt.create(Bt(e), void 0, t.signal));
4049
4581
  }
4050
- //#endregion
4051
- export { bt as createRoom, vt as readReplay, yt as validateStadium };
4582
+ export { Kt as createRoom, Wt as readReplay, Gt as validateStadium };