ball2d 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.js CHANGED
@@ -7,17 +7,39 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
7
7
  }, c = (n, r, o) => (o = n == null ? {} : e(i(n)), s(r || !n || !n.__esModule || !a.call(n, "default") ? t(o, "default", {
8
8
  value: n,
9
9
  enumerable: !0
10
- }) : o, n)), l = "/api/v1", u = {
11
- rooms: `${l}/rooms`,
12
- sdkRooms: `${l}/sdk/rooms`,
13
- account: `${l}/account`,
14
- accountConfig: `${l}/account/config`,
15
- profile: `${l}/account/profile`,
16
- notifications: `${l}/account/notifications`,
17
- keys: `${l}/account/keys`,
18
- signal: (e) => `${l}/rooms/${encodeURIComponent(e)}/signal`,
19
- lease: (e) => `${l}/sdk/rooms/${encodeURIComponent(e)}/lease`
20
- }, d = Uint8Array, f = Uint16Array, p = Int32Array, m = new d([
10
+ }) : o, n));
11
+ function l(e) {
12
+ return e === 0 || e === 1 || e === 2;
13
+ }
14
+ function u(e, t) {
15
+ return typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= t;
16
+ }
17
+ function d(e) {
18
+ let { score: t, minutes: n, locked: r, kickRate: i } = e;
19
+ return !u(t, 99) || !u(n, 99) || typeof r != "boolean" || i !== void 0 && !u(i, 6619135) ? null : {
20
+ score: t,
21
+ minutes: n,
22
+ locked: r,
23
+ kickRate: i
24
+ };
25
+ }
26
+ function f(e, t, n) {
27
+ return t !== void 0 && (e.admin || !n && t === e);
28
+ }
29
+ function p(e, t, n) {
30
+ return t !== void 0 && e.admin && t !== e && !n(t);
31
+ }
32
+ var m = "/api/v1", h = {
33
+ rooms: `${m}/rooms`,
34
+ sdkRooms: `${m}/sdk/rooms`,
35
+ account: `${m}/account`,
36
+ accountConfig: `${m}/account/config`,
37
+ profile: `${m}/account/profile`,
38
+ notifications: `${m}/account/notifications`,
39
+ keys: `${m}/account/keys`,
40
+ signal: (e) => `${m}/rooms/${encodeURIComponent(e)}/signal`,
41
+ lease: (e) => `${m}/sdk/rooms/${encodeURIComponent(e)}/lease`
42
+ }, g = Uint8Array, _ = Uint16Array, v = Int32Array, ee = new g([
21
43
  0,
22
44
  0,
23
45
  0,
@@ -50,7 +72,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
50
72
  0,
51
73
  0,
52
74
  0
53
- ]), h = new d([
75
+ ]), y = new g([
54
76
  0,
55
77
  0,
56
78
  0,
@@ -83,7 +105,7 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
83
105
  13,
84
106
  0,
85
107
  0
86
- ]), g = new d([
108
+ ]), b = new g([
87
109
  16,
88
110
  17,
89
111
  18,
@@ -103,49 +125,49 @@ var e = Object.create, t = Object.defineProperty, n = Object.getOwnPropertyDescr
103
125
  14,
104
126
  1,
105
127
  15
106
- ]), _ = function(e, t) {
107
- for (var n = new f(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
108
- for (var i = new p(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
128
+ ]), x = function(e, t) {
129
+ for (var n = new _(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
130
+ for (var i = new v(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
109
131
  return {
110
132
  b: n,
111
133
  r: i
112
134
  };
113
- }, v = _(m, 2), y = v.b, b = v.r;
114
- y[28] = 258, b[258] = 28;
115
- for (var x = _(h, 0), S = x.b, ee = x.r, C = new f(32768), w = 0; w < 32768; ++w) {
116
- var T = (w & 43690) >> 1 | (w & 21845) << 1;
117
- T = (T & 52428) >> 2 | (T & 13107) << 2, T = (T & 61680) >> 4 | (T & 3855) << 4, C[w] = ((T & 65280) >> 8 | (T & 255) << 8) >> 1;
135
+ }, S = x(ee, 2), te = S.b, C = S.r;
136
+ te[28] = 258, C[258] = 28;
137
+ for (var w = x(y, 0), T = w.b, E = w.r, ne = new _(32768), D = 0; D < 32768; ++D) {
138
+ var O = (D & 43690) >> 1 | (D & 21845) << 1;
139
+ O = (O & 52428) >> 2 | (O & 13107) << 2, O = (O & 61680) >> 4 | (O & 3855) << 4, ne[D] = ((O & 65280) >> 8 | (O & 255) << 8) >> 1;
118
140
  }
119
- for (var E = (function(e, t, n) {
120
- for (var r = e.length, i = 0, a = new f(t); i < r; ++i) e[i] && ++a[e[i] - 1];
121
- var o = new f(t);
141
+ for (var k = (function(e, t, n) {
142
+ for (var r = e.length, i = 0, a = new _(t); i < r; ++i) e[i] && ++a[e[i] - 1];
143
+ var o = new _(t);
122
144
  for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
123
145
  var s;
124
146
  if (n) {
125
- s = new f(1 << t);
147
+ s = new _(1 << t);
126
148
  var c = 15 - t;
127
- 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, p = d | (1 << u) - 1; d <= p; ++d) s[C[d] >> c] = l;
128
- } else for (s = new f(r), i = 0; i < r; ++i) e[i] && (s[i] = C[o[e[i] - 1]++] >> 15 - e[i]);
149
+ 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[ne[d] >> c] = l;
150
+ } else for (s = new _(r), i = 0; i < r; ++i) e[i] && (s[i] = ne[o[e[i] - 1]++] >> 15 - e[i]);
129
151
  return s;
130
- }), D = new d(288), w = 0; w < 144; ++w) D[w] = 8;
131
- for (var w = 144; w < 256; ++w) D[w] = 9;
132
- for (var w = 256; w < 280; ++w) D[w] = 7;
133
- for (var w = 280; w < 288; ++w) D[w] = 8;
134
- for (var O = new d(32), w = 0; w < 32; ++w) O[w] = 5;
135
- var te = /*#__PURE__*/ E(D, 9, 0), k = /*#__PURE__*/ E(D, 9, 1), A = /*#__PURE__*/ E(O, 5, 0), j = /*#__PURE__*/ E(O, 5, 1), ne = function(e) {
152
+ }), A = new g(288), D = 0; D < 144; ++D) A[D] = 8;
153
+ for (var D = 144; D < 256; ++D) A[D] = 9;
154
+ for (var D = 256; D < 280; ++D) A[D] = 7;
155
+ for (var D = 280; D < 288; ++D) A[D] = 8;
156
+ for (var j = new g(32), D = 0; D < 32; ++D) j[D] = 5;
157
+ var re = /*#__PURE__*/ k(A, 9, 0), M = /*#__PURE__*/ k(A, 9, 1), ie = /*#__PURE__*/ k(j, 5, 0), N = /*#__PURE__*/ k(j, 5, 1), P = function(e) {
136
158
  for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
137
159
  return t;
138
- }, M = function(e, t, n) {
160
+ }, F = function(e, t, n) {
139
161
  var r = t / 8 | 0;
140
162
  return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
141
- }, re = function(e, t) {
163
+ }, I = function(e, t) {
142
164
  var n = t / 8 | 0;
143
165
  return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
144
- }, ie = function(e) {
166
+ }, L = function(e) {
145
167
  return (e + 7) / 8 | 0;
146
168
  }, ae = function(e, t, n) {
147
- return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new d(e.subarray(t, n));
148
- }, N = [
169
+ return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new g(e.subarray(t, n));
170
+ }, R = [
149
171
  "unexpected EOF",
150
172
  "invalid block type",
151
173
  "invalid length/literal",
@@ -160,119 +182,119 @@ var te = /*#__PURE__*/ E(D, 9, 0), k = /*#__PURE__*/ E(D, 9, 1), A = /*#__PURE__
160
182
  "filename too long",
161
183
  "stream finishing",
162
184
  "invalid zip data"
163
- ], P = function(e, t, n) {
164
- var r = Error(t || N[e]);
165
- if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, P), !n) throw r;
185
+ ], z = function(e, t, n) {
186
+ var r = Error(t || R[e]);
187
+ if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, z), !n) throw r;
166
188
  return r;
167
- }, F = function(e, t, n, r) {
189
+ }, B = function(e, t, n, r) {
168
190
  var i = e.length, a = r ? r.length : 0;
169
- if (!i || t.f && !t.l) return n || new d(0);
191
+ if (!i || t.f && !t.l) return n || new g(0);
170
192
  var o = !n, s = o || t.i != 2, c = t.i;
171
- o && (n = new d(i * 3));
193
+ o && (n = new g(i * 3));
172
194
  var l = function(e) {
173
195
  var t = n.length;
174
196
  if (e > t) {
175
- var r = new d(Math.max(t * 2, e));
197
+ var r = new g(Math.max(t * 2, e));
176
198
  r.set(n), n = r;
177
199
  }
178
- }, u = t.f || 0, f = t.p || 0, p = t.b || 0, _ = t.l, v = t.d, b = t.m, x = t.n, ee = i * 8;
200
+ }, u = t.f || 0, d = t.p || 0, f = t.b || 0, p = t.l, m = t.d, h = t.m, _ = t.n, v = i * 8;
179
201
  do {
180
- if (!_) {
181
- u = M(e, f, 1);
182
- var C = M(e, f + 1, 3);
183
- if (f += 3, !C) {
184
- var w = ie(f) + 4, T = e[w - 4] | e[w - 3] << 8, D = w + T;
185
- if (D > i) {
186
- c && P(0);
202
+ if (!p) {
203
+ u = F(e, d, 1);
204
+ var x = F(e, d + 1, 3);
205
+ if (d += 3, !x) {
206
+ var S = L(d) + 4, C = e[S - 4] | e[S - 3] << 8, w = S + C;
207
+ if (w > i) {
208
+ c && z(0);
187
209
  break;
188
210
  }
189
- s && l(p + T), n.set(e.subarray(w, D), p), t.b = p += T, t.p = f = D * 8, t.f = u;
211
+ s && l(f + C), n.set(e.subarray(S, w), f), t.b = f += C, t.p = d = w * 8, t.f = u;
190
212
  continue;
191
213
  }
192
- if (C == 1) _ = k, v = j, b = 9, x = 5;
193
- else if (C == 2) {
194
- var O = M(e, f, 31) + 257, te = M(e, f + 10, 15) + 4, A = O + M(e, f + 5, 31) + 1;
195
- f += 14;
196
- for (var N = new d(A), F = new d(19), I = 0; I < te; ++I) F[g[I]] = M(e, f + I * 3, 7);
197
- f += te * 3;
198
- for (var L = ne(F), R = (1 << L) - 1, z = E(F, L, 1), I = 0; I < A;) {
199
- var B = z[M(e, f, R)];
200
- f += B & 15;
201
- var w = B >> 4;
202
- if (w < 16) N[I++] = w;
214
+ if (x == 1) p = M, m = N, h = 9, _ = 5;
215
+ else if (x == 2) {
216
+ var E = F(e, d, 31) + 257, ne = F(e, d + 10, 15) + 4, D = E + F(e, d + 5, 31) + 1;
217
+ d += 14;
218
+ for (var O = new g(D), A = new g(19), j = 0; j < ne; ++j) A[b[j]] = F(e, d + j * 3, 7);
219
+ d += ne * 3;
220
+ for (var re = P(A), ie = (1 << re) - 1, R = k(A, re, 1), j = 0; j < D;) {
221
+ var B = R[F(e, d, ie)];
222
+ d += B & 15;
223
+ var S = B >> 4;
224
+ if (S < 16) O[j++] = S;
203
225
  else {
204
- var V = 0, oe = 0;
205
- for (w == 16 ? (oe = 3 + M(e, f, 3), f += 2, V = N[I - 1]) : w == 17 ? (oe = 3 + M(e, f, 7), f += 3) : w == 18 && (oe = 11 + M(e, f, 127), f += 7); oe--;) N[I++] = V;
226
+ var V = 0, H = 0;
227
+ for (S == 16 ? (H = 3 + F(e, d, 3), d += 2, V = O[j - 1]) : S == 17 ? (H = 3 + F(e, d, 7), d += 3) : S == 18 && (H = 11 + F(e, d, 127), d += 7); H--;) O[j++] = V;
206
228
  }
207
229
  }
208
- var se = N.subarray(0, O), H = N.subarray(O);
209
- b = ne(se), x = ne(H), _ = E(se, b, 1), v = E(H, x, 1);
210
- } else P(1);
211
- if (f > ee) {
212
- c && P(0);
230
+ var oe = O.subarray(0, E), U = O.subarray(E);
231
+ h = P(oe), _ = P(U), p = k(oe, h, 1), m = k(U, _, 1);
232
+ } else z(1);
233
+ if (d > v) {
234
+ c && z(0);
213
235
  break;
214
236
  }
215
237
  }
216
- s && l(p + 131072);
217
- for (var U = (1 << b) - 1, W = (1 << x) - 1, G = f;; G = f) {
218
- var V = _[re(e, f) & U], K = V >> 4;
219
- if (f += V & 15, f > ee) {
220
- c && P(0);
238
+ s && l(f + 131072);
239
+ for (var W = (1 << h) - 1, G = (1 << _) - 1, se = d;; se = d) {
240
+ var V = p[I(e, d) & W], K = V >> 4;
241
+ if (d += V & 15, d > v) {
242
+ c && z(0);
221
243
  break;
222
244
  }
223
- if (V || P(2), K < 256) n[p++] = K;
245
+ if (V || z(2), K < 256) n[f++] = K;
224
246
  else if (K == 256) {
225
- G = f, _ = null;
247
+ se = d, p = null;
226
248
  break;
227
249
  } else {
228
250
  var q = K - 254;
229
251
  if (K > 264) {
230
- var I = K - 257, J = m[I];
231
- q = M(e, f, (1 << J) - 1) + y[I], f += J;
252
+ var j = K - 257, J = ee[j];
253
+ q = F(e, d, (1 << J) - 1) + te[j], d += J;
232
254
  }
233
- var Y = v[re(e, f) & W], X = Y >> 4;
234
- Y || P(3), f += Y & 15;
235
- var H = S[X];
255
+ var Y = m[I(e, d) & G], X = Y >> 4;
256
+ Y || z(3), d += Y & 15;
257
+ var U = T[X];
236
258
  if (X > 3) {
237
- var J = h[X];
238
- H += re(e, f) & (1 << J) - 1, f += J;
259
+ var J = y[X];
260
+ U += I(e, d) & (1 << J) - 1, d += J;
239
261
  }
240
- if (f > ee) {
241
- c && P(0);
262
+ if (d > v) {
263
+ c && z(0);
242
264
  break;
243
265
  }
244
- s && l(p + 131072);
245
- var ce = p + q;
246
- if (p < H) {
247
- var Z = a - H, le = Math.min(H, ce);
248
- for (Z + p < 0 && P(3); p < le; ++p) n[p] = r[Z + p];
266
+ s && l(f + 131072);
267
+ var ce = f + q;
268
+ if (f < U) {
269
+ var Z = a - U, le = Math.min(U, ce);
270
+ for (Z + f < 0 && z(3); f < le; ++f) n[f] = r[Z + f];
249
271
  }
250
- for (; p < ce; ++p) n[p] = n[p - H];
272
+ for (; f < ce; ++f) n[f] = n[f - U];
251
273
  }
252
274
  }
253
- t.l = _, t.p = G, t.b = p, t.f = u, _ && (u = 1, t.m = b, t.d = v, t.n = x);
275
+ t.l = p, t.p = se, t.b = f, t.f = u, p && (u = 1, t.m = h, t.d = m, t.n = _);
254
276
  } while (!u);
255
- return p != n.length && o ? ae(n, 0, p) : n.subarray(0, p);
256
- }, I = function(e, t, n) {
277
+ return f != n.length && o ? ae(n, 0, f) : n.subarray(0, f);
278
+ }, V = function(e, t, n) {
257
279
  n <<= t & 7;
258
280
  var r = t / 8 | 0;
259
281
  e[r] |= n, e[r + 1] |= n >> 8;
260
- }, L = function(e, t, n) {
282
+ }, H = function(e, t, n) {
261
283
  n <<= t & 7;
262
284
  var r = t / 8 | 0;
263
285
  e[r] |= n, e[r + 1] |= n >> 8, e[r + 2] |= n >> 16;
264
- }, R = function(e, t) {
286
+ }, oe = function(e, t) {
265
287
  for (var n = [], r = 0; r < e.length; ++r) e[r] && n.push({
266
288
  s: r,
267
289
  f: e[r]
268
290
  });
269
291
  var i = n.length, a = n.slice();
270
292
  if (!i) return {
271
- t: U,
293
+ t: J,
272
294
  l: 0
273
295
  };
274
296
  if (i == 1) {
275
- var o = new d(n[0].s + 1);
297
+ var o = new g(n[0].s + 1);
276
298
  return o[n[0].s] = 1, {
277
299
  t: o,
278
300
  l: 1
@@ -284,48 +306,48 @@ var te = /*#__PURE__*/ E(D, 9, 0), k = /*#__PURE__*/ E(D, 9, 1), A = /*#__PURE__
284
306
  s: -1,
285
307
  f: 25001
286
308
  });
287
- var s = n[0], c = n[1], l = 0, u = 1, p = 2;
309
+ var s = n[0], c = n[1], l = 0, u = 1, d = 2;
288
310
  for (n[0] = {
289
311
  s: -1,
290
312
  f: s.f + c.f,
291
313
  l: s,
292
314
  r: c
293
- }; u != i - 1;) s = n[n[l].f < n[p].f ? l++ : p++], c = n[l != u && n[l].f < n[p].f ? l++ : p++], n[u++] = {
315
+ }; 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++] = {
294
316
  s: -1,
295
317
  f: s.f + c.f,
296
318
  l: s,
297
319
  r: c
298
320
  };
299
- for (var m = a[0].s, r = 1; r < i; ++r) a[r].s > m && (m = a[r].s);
300
- var h = new f(m + 1), g = z(n[u - 1], h, 0);
301
- if (g > t) {
302
- var r = 0, _ = 0, v = g - t, y = 1 << v;
321
+ for (var f = a[0].s, r = 1; r < i; ++r) a[r].s > f && (f = a[r].s);
322
+ var p = new _(f + 1), m = U(n[u - 1], p, 0);
323
+ if (m > t) {
324
+ var r = 0, h = 0, v = m - t, ee = 1 << v;
303
325
  for (a.sort(function(e, t) {
304
- return h[t.s] - h[e.s] || e.f - t.f;
326
+ return p[t.s] - p[e.s] || e.f - t.f;
305
327
  }); r < i; ++r) {
306
- var b = a[r].s;
307
- if (h[b] > t) _ += y - (1 << g - h[b]), h[b] = t;
328
+ var y = a[r].s;
329
+ if (p[y] > t) h += ee - (1 << m - p[y]), p[y] = t;
308
330
  else break;
309
331
  }
310
- for (_ >>= v; _ > 0;) {
311
- var x = a[r].s;
312
- h[x] < t ? _ -= 1 << t - h[x]++ - 1 : ++r;
332
+ for (h >>= v; h > 0;) {
333
+ var b = a[r].s;
334
+ p[b] < t ? h -= 1 << t - p[b]++ - 1 : ++r;
313
335
  }
314
- for (; r >= 0 && _; --r) {
315
- var S = a[r].s;
316
- h[S] == t && (--h[S], ++_);
336
+ for (; r >= 0 && h; --r) {
337
+ var x = a[r].s;
338
+ p[x] == t && (--p[x], ++h);
317
339
  }
318
- g = t;
340
+ m = t;
319
341
  }
320
342
  return {
321
- t: new d(h),
322
- l: g
343
+ t: new g(p),
344
+ l: m
323
345
  };
324
- }, z = function(e, t, n) {
325
- return e.s == -1 ? Math.max(z(e.l, t, n + 1), z(e.r, t, n + 1)) : t[e.s] = n;
326
- }, B = function(e) {
346
+ }, U = function(e, t, n) {
347
+ return e.s == -1 ? Math.max(U(e.l, t, n + 1), U(e.r, t, n + 1)) : t[e.s] = n;
348
+ }, W = function(e) {
327
349
  for (var t = e.length; t && !e[--t];);
328
- for (var n = new f(++t), r = 0, i = e[0], a = 1, o = function(e) {
350
+ for (var n = new _(++t), r = 0, i = e[0], a = 1, o = function(e) {
329
351
  n[r++] = e;
330
352
  }, s = 1; s <= t; ++s) if (e[s] == i && s != t) ++a;
331
353
  else {
@@ -343,44 +365,44 @@ var te = /*#__PURE__*/ E(D, 9, 0), k = /*#__PURE__*/ E(D, 9, 1), A = /*#__PURE__
343
365
  c: n.subarray(0, r),
344
366
  n: t
345
367
  };
346
- }, V = function(e, t) {
368
+ }, G = function(e, t) {
347
369
  for (var n = 0, r = 0; r < t.length; ++r) n += e[r] * t[r];
348
370
  return n;
349
- }, oe = function(e, t, n) {
350
- var r = n.length, i = ie(t + 2);
371
+ }, se = function(e, t, n) {
372
+ var r = n.length, i = L(t + 2);
351
373
  e[i] = r & 255, e[i + 1] = r >> 8, e[i + 2] = e[i] ^ 255, e[i + 3] = e[i + 1] ^ 255;
352
374
  for (var a = 0; a < r; ++a) e[i + a + 4] = n[a];
353
375
  return (i + 4 + r) * 8;
354
- }, se = function(e, t, n, r, i, a, o, s, c, l, u) {
355
- I(t, u++, n), ++i[256];
356
- for (var d = R(i, 15), p = d.t, _ = d.l, v = R(a, 15), y = v.t, b = v.l, x = B(p), S = x.c, ee = x.n, C = B(y), w = C.c, T = C.n, k = new f(19), j = 0; j < S.length; ++j) ++k[S[j] & 31];
357
- for (var j = 0; j < w.length; ++j) ++k[w[j] & 31];
358
- for (var ne = R(k, 7), M = ne.t, re = ne.l, ie = 19; ie > 4 && !M[g[ie - 1]]; --ie);
359
- var ae = l + 5 << 3, N = V(i, D) + V(a, O) + o, P = V(i, p) + V(a, y) + o + 14 + 3 * ie + V(k, M) + 2 * k[16] + 3 * k[17] + 7 * k[18];
360
- if (c >= 0 && ae <= N && ae <= P) return oe(t, u, e.subarray(c, c + l));
361
- var F, z, se, H;
362
- if (I(t, u, 1 + (P < N)), u += 2, P < N) {
363
- F = E(p, _, 0), z = p, se = E(y, b, 0), H = y;
364
- var U = E(M, re, 0);
365
- I(t, u, ee - 257), I(t, u + 5, T - 1), I(t, u + 10, ie - 4), u += 14;
366
- for (var j = 0; j < ie; ++j) I(t, u + 3 * j, M[g[j]]);
367
- u += 3 * ie;
368
- for (var W = [S, w], G = 0; G < 2; ++G) for (var K = W[G], j = 0; j < K.length; ++j) {
369
- var q = K[j] & 31;
370
- I(t, u, U[q]), u += M[q], q > 15 && (I(t, u, K[j] >> 5 & 127), u += K[j] >> 12);
376
+ }, K = function(e, t, n, r, i, a, o, s, c, l, u) {
377
+ V(t, u++, n), ++i[256];
378
+ for (var d = oe(i, 15), f = d.t, p = d.l, m = oe(a, 15), h = m.t, g = m.l, v = W(f), x = v.c, S = v.n, te = W(h), C = te.c, w = te.n, T = new _(19), E = 0; E < x.length; ++E) ++T[x[E] & 31];
379
+ for (var E = 0; E < C.length; ++E) ++T[C[E] & 31];
380
+ for (var ne = oe(T, 7), D = ne.t, O = ne.l, M = 19; M > 4 && !D[b[M - 1]]; --M);
381
+ var N = l + 5 << 3, P = G(i, A) + G(a, j) + o, F = G(i, f) + G(a, h) + o + 14 + 3 * M + G(T, D) + 2 * T[16] + 3 * T[17] + 7 * T[18];
382
+ if (c >= 0 && N <= P && N <= F) return se(t, u, e.subarray(c, c + l));
383
+ var I, L, ae, R;
384
+ if (V(t, u, 1 + (F < P)), u += 2, F < P) {
385
+ I = k(f, p, 0), L = f, ae = k(h, g, 0), R = h;
386
+ var z = k(D, O, 0);
387
+ V(t, u, S - 257), V(t, u + 5, w - 1), V(t, u + 10, M - 4), u += 14;
388
+ for (var E = 0; E < M; ++E) V(t, u + 3 * E, D[b[E]]);
389
+ u += 3 * M;
390
+ for (var B = [x, C], U = 0; U < 2; ++U) for (var K = B[U], E = 0; E < K.length; ++E) {
391
+ var q = K[E] & 31;
392
+ V(t, u, z[q]), u += D[q], q > 15 && (V(t, u, K[E] >> 5 & 127), u += K[E] >> 12);
371
393
  }
372
- } else F = te, z = D, se = A, H = O;
373
- for (var j = 0; j < s; ++j) {
374
- var J = r[j];
394
+ } else I = re, L = A, ae = ie, R = j;
395
+ for (var E = 0; E < s; ++E) {
396
+ var J = r[E];
375
397
  if (J > 255) {
376
398
  var q = J >> 18 & 31;
377
- L(t, u, F[q + 257]), u += z[q + 257], q > 7 && (I(t, u, J >> 23 & 31), u += m[q]);
399
+ H(t, u, I[q + 257]), u += L[q + 257], q > 7 && (V(t, u, J >> 23 & 31), u += ee[q]);
378
400
  var Y = J & 31;
379
- L(t, u, se[Y]), u += H[Y], Y > 3 && (L(t, u, J >> 5 & 8191), u += h[Y]);
380
- } else L(t, u, F[J]), u += z[J];
401
+ H(t, u, ae[Y]), u += R[Y], Y > 3 && (H(t, u, J >> 5 & 8191), u += y[Y]);
402
+ } else H(t, u, I[J]), u += L[J];
381
403
  }
382
- return L(t, u, F[256]), u + z[256];
383
- }, H = /*#__PURE__*/ new p([
404
+ return H(t, u, I[256]), u + L[256];
405
+ }, q = /*#__PURE__*/ new v([
384
406
  65540,
385
407
  131080,
386
408
  131088,
@@ -390,96 +412,96 @@ var te = /*#__PURE__*/ E(D, 9, 0), k = /*#__PURE__*/ E(D, 9, 1), A = /*#__PURE__
390
412
  1048832,
391
413
  2114560,
392
414
  2117632
393
- ]), U = /*#__PURE__*/ new d(0), W = function(e, t, n, r, i, a) {
394
- var o = a.z || e.length, s = new d(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
415
+ ]), J = /*#__PURE__*/ new g(0), Y = function(e, t, n, r, i, a) {
416
+ var o = a.z || e.length, s = new g(r + o + 5 * (1 + Math.ceil(o / 7e3)) + i), c = s.subarray(r, s.length - i), l = a.l, u = (a.r || 0) & 7;
395
417
  if (t) {
396
418
  u && (c[0] = a.r >> 3);
397
- for (var g = H[t - 1], _ = g >> 13, v = g & 8191, y = (1 << n) - 1, x = a.p || new f(32768), S = a.h || new f(y + 1), C = Math.ceil(n / 3), w = 2 * C, T = function(t) {
398
- return (e[t] ^ e[t + 1] << C ^ e[t + 2] << w) & y;
399
- }, E = new p(25e3), D = new f(288), O = new f(32), te = 0, k = 0, A = a.i || 0, j = 0, ne = a.w || 0, M = 0; A + 2 < o; ++A) {
400
- var re = T(A), N = A & 32767, P = S[re];
401
- if (x[N] = P, S[re] = N, ne <= A) {
402
- var F = o - A;
403
- if ((te > 7e3 || j > 24576) && (F > 423 || !l)) {
404
- u = se(e, c, 0, E, D, O, k, j, M, A - M, u), j = te = k = 0, M = A;
405
- for (var I = 0; I < 286; ++I) D[I] = 0;
406
- for (var I = 0; I < 30; ++I) O[I] = 0;
419
+ for (var d = q[t - 1], f = d >> 13, p = d & 8191, m = (1 << n) - 1, h = a.p || new _(32768), b = a.h || new _(m + 1), x = Math.ceil(n / 3), S = 2 * x, te = function(t) {
420
+ return (e[t] ^ e[t + 1] << x ^ e[t + 2] << S) & m;
421
+ }, w = new v(25e3), T = new _(288), ne = new _(32), D = 0, O = 0, k = a.i || 0, A = 0, j = a.w || 0, re = 0; k + 2 < o; ++k) {
422
+ var M = te(k), ie = k & 32767, N = b[M];
423
+ if (h[ie] = N, b[M] = ie, j <= k) {
424
+ var P = o - k;
425
+ if ((D > 7e3 || A > 24576) && (P > 423 || !l)) {
426
+ u = K(e, c, 0, w, T, ne, O, A, re, k - re, u), A = D = O = 0, re = k;
427
+ for (var F = 0; F < 286; ++F) T[F] = 0;
428
+ for (var F = 0; F < 30; ++F) ne[F] = 0;
407
429
  }
408
- var L = 2, R = 0, z = v, B = N - P & 32767;
409
- if (F > 2 && re == T(A - B)) for (var V = Math.min(_, F) - 1, U = Math.min(32767, A), W = Math.min(258, F); B <= U && --z && N != P;) {
410
- if (e[A + L] == e[A + L - B]) {
411
- for (var G = 0; G < W && e[A + G] == e[A + G - B]; ++G);
412
- if (G > L) {
413
- if (L = G, R = B, G > V) break;
414
- for (var K = Math.min(B, G - 2), q = 0, I = 0; I < K; ++I) {
415
- var J = A - B + I & 32767, Y = J - x[J] & 32767;
416
- Y > q && (q = Y, P = J);
430
+ var I = 2, R = 0, z = p, B = ie - N & 32767;
431
+ if (P > 2 && M == te(k - B)) for (var V = Math.min(f, P) - 1, H = Math.min(32767, k), oe = Math.min(258, P); B <= H && --z && ie != N;) {
432
+ if (e[k + I] == e[k + I - B]) {
433
+ for (var U = 0; U < oe && e[k + U] == e[k + U - B]; ++U);
434
+ if (U > I) {
435
+ if (I = U, R = B, U > V) break;
436
+ for (var W = Math.min(B, U - 2), G = 0, F = 0; F < W; ++F) {
437
+ var J = k - B + F & 32767, Y = J - h[J] & 32767;
438
+ Y > G && (G = Y, N = J);
417
439
  }
418
440
  }
419
441
  }
420
- N = P, P = x[N], B += N - P & 32767;
442
+ ie = N, N = h[ie], B += ie - N & 32767;
421
443
  }
422
444
  if (R) {
423
- E[j++] = 268435456 | b[L] << 18 | ee[R];
424
- var X = b[L] & 31, ce = ee[R] & 31;
425
- k += m[X] + h[ce], ++D[257 + X], ++O[ce], ne = A + L, ++te;
426
- } else E[j++] = e[A], ++D[e[A]];
445
+ w[A++] = 268435456 | C[I] << 18 | E[R];
446
+ var X = C[I] & 31, ce = E[R] & 31;
447
+ O += ee[X] + y[ce], ++T[257 + X], ++ne[ce], j = k + I, ++D;
448
+ } else w[A++] = e[k], ++T[e[k]];
427
449
  }
428
450
  }
429
- for (A = Math.max(A, ne); A < o; ++A) E[j++] = e[A], ++D[e[A]];
430
- u = se(e, c, l, E, D, O, k, j, M, A - M, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = S, a.p = x, a.i = A, a.w = ne);
451
+ for (k = Math.max(k, j); k < o; ++k) w[A++] = e[k], ++T[e[k]];
452
+ u = K(e, c, l, w, T, ne, O, A, re, k - re, u), l || (a.r = u & 7 | c[u / 8 | 0] << 3, u -= 7, a.h = b, a.p = h, a.i = k, a.w = j);
431
453
  } else {
432
- for (var A = a.w || 0; A < o + l; A += 65535) {
433
- var Z = A + 65535;
434
- Z >= o && (c[u / 8 | 0] = l, Z = o), u = oe(c, u + 1, e.subarray(A, Z));
454
+ for (var k = a.w || 0; k < o + l; k += 65535) {
455
+ var Z = k + 65535;
456
+ Z >= o && (c[u / 8 | 0] = l, Z = o), u = se(c, u + 1, e.subarray(k, Z));
435
457
  }
436
458
  a.i = o;
437
459
  }
438
- return ae(s, 0, r + ie(u) + i);
439
- }, G = function(e, t, n, r, i) {
460
+ return ae(s, 0, r + L(u) + i);
461
+ }, X = function(e, t, n, r, i) {
440
462
  if (!i && (i = { l: 1 }, t.dictionary)) {
441
- var a = t.dictionary.subarray(-32768), o = new d(a.length + e.length);
463
+ var a = t.dictionary.subarray(-32768), o = new g(a.length + e.length);
442
464
  o.set(a), o.set(e, a.length), e = o, i.w = a.length;
443
465
  }
444
- return W(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);
466
+ return Y(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);
445
467
  };
446
- function K(e, t) {
447
- return G(e, t || {}, 0, 0);
468
+ function ce(e, t) {
469
+ return X(e, t || {}, 0, 0);
448
470
  }
449
- var q = /* @__PURE__ */ function() {
471
+ var Z = /* @__PURE__ */ function() {
450
472
  function e(e, t) {
451
473
  typeof e == "function" && (t = e, e = {}), this.ondata = t;
452
474
  var n = e && e.dictionary && e.dictionary.subarray(-32768);
453
475
  this.s = {
454
476
  i: 0,
455
477
  b: n ? n.length : 0
456
- }, this.o = new d(32768), this.p = new d(0), n && this.o.set(n);
478
+ }, this.o = new g(32768), this.p = new g(0), n && this.o.set(n);
457
479
  }
458
480
  return e.prototype.e = function(e) {
459
- if (this.ondata || P(5), this.d && P(4), !this.p.length) this.p = e;
481
+ if (this.ondata || z(5), this.d && z(4), !this.p.length) this.p = e;
460
482
  else if (e.length) {
461
- var t = new d(this.p.length + e.length);
483
+ var t = new g(this.p.length + e.length);
462
484
  t.set(this.p), t.set(e, this.p.length), this.p = t;
463
485
  }
464
486
  }, e.prototype.c = function(e) {
465
487
  this.s.i = +(this.d = e || !1);
466
- var t = this.s.b, n = F(this.p, this.s, this.o);
488
+ var t = this.s.b, n = B(this.p, this.s, this.o);
467
489
  this.ondata(ae(n, t, this.s.b), this.d), this.o = ae(n, this.s.b - 32768), this.s.b = this.o.length, this.p = ae(this.p, this.s.p / 8 | 0), this.s.p &= 7;
468
490
  }, e.prototype.push = function(e, t) {
469
491
  this.e(e), this.c(t);
470
492
  }, e;
471
- }(), J = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
493
+ }(), le = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
472
494
  try {
473
- J.decode(U, { stream: !0 });
495
+ le.decode(J, { stream: !0 });
474
496
  } catch {}
475
- var Y = 5389, X = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, ce = (e) => Number.isFinite(e) && e >= 1 && e <= 1e5, Z = class {
497
+ var ue = 5389, de = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, fe = (e) => Number.isFinite(e) && e >= 1 && e <= 1e5, pe = class {
476
498
  core;
477
499
  enabled = !1;
478
500
  constructor(e) {
479
501
  if (this.core = e, e.surface_state_capacity() !== 5389) throw Error("Unsupported surface state version");
480
502
  }
481
503
  configure(e) {
482
- if (!X(e.seed, 0, 4294967295) || !ce(e.halfWidth) || !ce(e.halfHeight) || !X(e.moisturePermille, 0, 1e3)) throw Error("Invalid surface configuration");
504
+ if (!de(e.seed, 0, 4294967295) || !fe(e.halfWidth) || !fe(e.halfHeight) || !de(e.moisturePermille, 0, 1e3)) throw Error("Invalid surface configuration");
483
505
  if (!this.core.surface_configure(e.seed, e.halfWidth, e.halfHeight, e.moisturePermille)) throw Error("Surface configuration rejected");
484
506
  this.enabled = !0;
485
507
  }
@@ -487,7 +509,7 @@ var Y = 5389, X = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, ce = (e)
487
509
  this.core.surface_disable(), this.enabled = !1;
488
510
  }
489
511
  setWeather(e) {
490
- if (!X(e.rainMilliMmH, 0, 2e5) || !X(e.temperatureMilliC, -3e4, 6e4) || !X(e.humidityPermille, 0, 1e3) || !X(e.windMilliMS, 0, 6e4)) throw Error("Invalid surface weather");
512
+ if (!de(e.rainMilliMmH, 0, 2e5) || !de(e.temperatureMilliC, -3e4, 6e4) || !de(e.humidityPermille, 0, 1e3) || !de(e.windMilliMS, 0, 6e4)) throw Error("Invalid surface weather");
491
513
  if (!this.core.surface_weather(e.rainMilliMmH, e.temperatureMilliC, e.humidityPermille, e.windMilliMS)) throw Error("Surface is disabled");
492
514
  }
493
515
  sample(e, t) {
@@ -506,22 +528,22 @@ var Y = 5389, X = (e, t, n) => Number.isInteger(e) && e >= t && e <= n, ce = (e)
506
528
  return Array.from(this.buffer());
507
529
  }
508
530
  restore(e) {
509
- if (!Array.isArray(e) || e.length !== 0 && e.length !== 5389 || !e.every((e) => X(e, 0, 4294967295)) || (e.length && this.buffer().set(e), !this.core.surface_restore(e.length))) throw Error("Invalid surface checkpoint");
531
+ if (!Array.isArray(e) || e.length !== 0 && e.length !== 5389 || !e.every((e) => de(e, 0, 4294967295)) || (e.length && this.buffer().set(e), !this.core.surface_restore(e.length))) throw Error("Invalid surface checkpoint");
510
532
  this.enabled = e.length > 0;
511
533
  }
512
534
  buffer() {
513
535
  let e = this.core.surface_state_ptr();
514
- return new Uint32Array(this.core.memory.buffer, e, Y);
536
+ return new Uint32Array(this.core.memory.buffer, e, ue);
515
537
  }
516
- }, le = 131072, ue = 49152, de = new TextEncoder();
538
+ }, me = 131072, he = 49152, Q = new TextEncoder();
517
539
  new TextDecoder("utf-8", { fatal: !0 });
518
- var fe = (e, t) => typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= t;
519
- function pe(e, t) {
520
- if (!fe(t, 65535) || !fe(e.tick, 4294967295) || !Array.isArray(e.surface) || e.surface.length !== 5389) throw Error("Invalid terrain snapshot");
521
- let n = de.encode(JSON.stringify(e));
522
- if (n.length > le) throw Error("Terrain snapshot exceeds size limit");
523
- let r = K(n, { level: 1 });
524
- if (r.length > ue) throw Error("Compressed terrain snapshot exceeds size limit");
540
+ var ge = (e, t) => typeof e == "number" && Number.isInteger(e) && e >= 0 && e <= t;
541
+ function _e(e, t) {
542
+ if (!ge(t, 65535) || !ge(e.tick, 4294967295) || !Array.isArray(e.surface) || e.surface.length !== 5389) throw Error("Invalid terrain snapshot");
543
+ let n = Q.encode(JSON.stringify(e));
544
+ if (n.length > me) throw Error("Terrain snapshot exceeds size limit");
545
+ let r = ce(n, { level: 1 });
546
+ if (r.length > he) throw Error("Compressed terrain snapshot exceeds size limit");
525
547
  let i = "";
526
548
  for (let e of r) i += String.fromCharCode(e);
527
549
  return {
@@ -531,7 +553,7 @@ function pe(e, t) {
531
553
  payload: btoa(i)
532
554
  };
533
555
  }
534
- function me(e) {
556
+ function ve(e) {
535
557
  let t = new AbortController(), n = () => t.abort(e?.reason);
536
558
  e?.aborted ? n() : e?.addEventListener("abort", n, { once: !0 });
537
559
  let r = setTimeout(() => t.abort(new DOMException("Room startup timed out", "TimeoutError")), 15e3);
@@ -553,7 +575,72 @@ function me(e) {
553
575
  }
554
576
  };
555
577
  }
556
- var he = /* @__PURE__ */ new Set([
578
+ async function ye(e, t) {
579
+ let n = `Room creation failed (${e.status})`, r = e.body?.getReader();
580
+ if (!r) return Error(n);
581
+ let i = () => {
582
+ r.cancel().catch(() => {});
583
+ };
584
+ t.addEventListener("abort", i, { once: !0 });
585
+ try {
586
+ if (t.throwIfAborted(), e.status < 400 || e.status >= 500 || e.headers.get("content-type")?.split(";")[0].trim() !== "application/json") return Error(n);
587
+ let i = /* @__PURE__ */ new Uint8Array(2048), a = 0;
588
+ for (;;) {
589
+ let e = await r.read();
590
+ if (t.throwIfAborted(), e.done) break;
591
+ if (a + e.value.byteLength > i.length) return Error(n);
592
+ i.set(e.value, a), a += e.value.byteLength;
593
+ }
594
+ let o = JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(i.subarray(0, a)));
595
+ if (!o || typeof o != "object") return Error(n);
596
+ let s = o.error;
597
+ return typeof s != "string" || !s.trim() || s.length > 300 || /[<>]/.test(s) || [...s].some((e) => e.charCodeAt(0) < 32 || e.charCodeAt(0) === 127) ? Error(n) : Error(`${s.trim()} (${e.status})`);
598
+ } catch {
599
+ return t.throwIfAborted(), Error(n);
600
+ } finally {
601
+ t.removeEventListener("abort", i), i(), r.releaseLock();
602
+ }
603
+ }
604
+ var be = class {
605
+ stream;
606
+ sequence = 0;
607
+ pending = [];
608
+ lastSent = -Infinity;
609
+ constructor(e = crypto.randomUUID()) {
610
+ this.stream = e;
611
+ }
612
+ checkpoint() {
613
+ return {
614
+ stream: this.stream,
615
+ sequence: this.sequence
616
+ };
617
+ }
618
+ capture(e, t) {
619
+ let n = (e.ballKicks ?? []).map((n) => ({
620
+ sequence: ++this.sequence,
621
+ tick: e.tick,
622
+ epoch: t,
623
+ slot: n,
624
+ x: e.data[0],
625
+ y: e.data[1]
626
+ }));
627
+ return this.pending.push(...n), this.pending.length > 8 && this.pending.splice(0, this.pending.length - 8), n;
628
+ }
629
+ drain(e) {
630
+ if (!this.pending.length || e - this.lastSent < 50) return;
631
+ this.lastSent = e;
632
+ let t = this.pending;
633
+ return this.pending = [], {
634
+ type: "match-kicks",
635
+ stream: this.stream,
636
+ events: t
637
+ };
638
+ }
639
+ };
640
+ function xe(e, t) {
641
+ if (t) for (let n of e.peers.values()) n.control?.readyState === "open" && n.control.bufferedAmount < 16384 && e.control(n, t);
642
+ }
643
+ var Se = /* @__PURE__ */ new Set([
557
644
  "noPlayer",
558
645
  "playerName",
559
646
  "roomName",
@@ -562,12 +649,12 @@ var he = /* @__PURE__ */ new Set([
562
649
  "public",
563
650
  "stadium"
564
651
  ]);
565
- function Q(e) {
652
+ function Ce(e) {
566
653
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Room configuration must be an object");
567
654
  for (let t of Object.keys(e)) {
568
655
  if (t === "token") throw Error("External service tokens are not supported. Ball2D join verification is configured on the room.");
569
656
  if (t === "geo") throw Error("Geolocation overrides are not supported. Room country comes from the host connection.");
570
- if (!he.has(t)) throw Error(`Unknown room setting: ${t}`);
657
+ if (!Se.has(t)) throw Error(`Unknown room setting: ${t}`);
571
658
  }
572
659
  let t = { ...e };
573
660
  if (typeof t.roomName != "string" || !t.roomName.trim() || t.roomName.length > 64) throw Error("Room name must contain 1–64 characters");
@@ -586,15 +673,15 @@ function Q(e) {
586
673
  stadium: t.stadium
587
674
  };
588
675
  }
589
- function ge(e) {
676
+ function we(e) {
590
677
  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;
591
678
  }
592
- function _e(e) {
593
- let t = ge(e);
679
+ function Te(e) {
680
+ let t = we(e);
594
681
  if (!t) throw Error("Invalid room code");
595
682
  return `/r/${t}`;
596
683
  }
597
- function ve(e, t, n) {
684
+ function Ee(e, t, n) {
598
685
  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");
599
686
  return {
600
687
  angle: (e % 360 + 360) % 360,
@@ -602,12 +689,12 @@ function ve(e, t, n) {
602
689
  colors: [...n]
603
690
  };
604
691
  }
605
- function ye(e) {
692
+ function De(e) {
606
693
  if (e === void 0) return [null, null];
607
694
  if (!Array.isArray(e) || e.length !== 2) throw Error("Invalid team styles");
608
- return e.map((e) => e === null ? null : ve(e.angle, e.textColor, e.colors));
695
+ return e.map((e) => e === null ? null : Ee(e.angle, e.textColor, e.colors));
609
696
  }
610
- var be = [
697
+ var Oe = [
611
698
  "normal",
612
699
  "bold",
613
700
  "italic",
@@ -615,10 +702,10 @@ var be = [
615
702
  "small-bold",
616
703
  "small-italic"
617
704
  ];
618
- function xe(e, t, n, r) {
705
+ function ke(e, t, n, r) {
619
706
  if (typeof e != "string" || e.length > 1e3) throw Error("Announcement exceeds 1000 characters");
620
707
  if (t != null && (!Number.isInteger(t) || t < 0 || t > 16777215)) throw Error("Invalid announcement color");
621
- if (n != null && !be.includes(n)) throw Error("Invalid announcement style");
708
+ if (n != null && !Oe.includes(n)) throw Error("Invalid announcement style");
622
709
  if (r != null && ![
623
710
  0,
624
711
  1,
@@ -632,10 +719,10 @@ function xe(e, t, n, r) {
632
719
  sound: r ?? 1
633
720
  };
634
721
  }
635
- function Se(e) {
722
+ function Ae(e) {
636
723
  return e === null || typeof e == "string" && Array.from(e).length <= 2 && !/[\p{Cc}\p{Cf}]/u.test(e);
637
724
  }
638
- var Ce = [
725
+ var je = [
639
726
  [
640
727
  "x",
641
728
  0,
@@ -715,11 +802,11 @@ var Ce = [
715
802
  2147483647
716
803
  ]
717
804
  ];
718
- function we(e) {
805
+ function Me(e) {
719
806
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Invalid disc property update");
720
807
  let t = e, n = {};
721
- for (let e = 0; e < Ce.length; e++) {
722
- let [r, , i, a] = Ce[e], o = t[r];
808
+ for (let e = 0; e < je.length; e++) {
809
+ let [r, , i, a] = je[e], o = t[r];
723
810
  if (o == null) continue;
724
811
  if (typeof o != "number" || !Number.isFinite(o)) throw Error(`Invalid disc property: ${r}`);
725
812
  let s = e < 10 ? Math.fround(o) : o | 0;
@@ -728,7 +815,7 @@ function we(e) {
728
815
  }
729
816
  return n;
730
817
  }
731
- var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
818
+ var Ne = "5a27b77ea69c9f5e179f", Pe = /* @__PURE__ */ c((/* @__PURE__ */ o(((e, t) => {
732
819
  (function(n, r) {
733
820
  typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : n.JSON5 = r();
734
821
  })(e, (function() {
@@ -788,9 +875,9 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
788
875
  return e[t] = n, e;
789
876
  }, g = {}.hasOwnProperty, _ = function(e, t) {
790
877
  return g.call(e, t);
791
- }, v = 0, y = Math.random(), b = function(e) {
792
- return `Symbol(${e === void 0 ? "" : e})_${(++v + y).toString(36)}`;
793
- }, x = e(function(e) {
878
+ }, v = 0, ee = Math.random(), y = function(e) {
879
+ return `Symbol(${e === void 0 ? "" : e})_${(++v + ee).toString(36)}`;
880
+ }, b = e(function(e) {
794
881
  var r = "__core-js_shared__", i = t[r] || (t[r] = {});
795
882
  (e.exports = function(e, t) {
796
883
  return i[e] || (i[e] = t === void 0 ? {} : t);
@@ -799,21 +886,21 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
799
886
  mode: "global",
800
887
  copyright: "© 2019 Denis Pushkarev (zloirock.ru)"
801
888
  });
802
- })("native-function-to-string", Function.toString), S = e(function(e) {
803
- var r = b("src"), i = "toString", a = ("" + x).split(i);
889
+ })("native-function-to-string", Function.toString), x = e(function(e) {
890
+ var r = y("src"), i = "toString", a = ("" + b).split(i);
804
891
  n.inspectSource = function(e) {
805
- return x.call(e);
892
+ return b.call(e);
806
893
  }, (e.exports = function(e, n, i, o) {
807
894
  var s = typeof i == "function";
808
895
  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)));
809
896
  })(Function.prototype, i, function() {
810
- return typeof this == "function" && this[r] || x.call(this);
897
+ return typeof this == "function" && this[r] || b.call(this);
811
898
  });
812
- }), ee = function(e) {
899
+ }), S = function(e) {
813
900
  if (typeof e != "function") throw TypeError(e + " is not a function!");
814
901
  return e;
815
- }, C = function(e, t, n) {
816
- if (ee(e), t === void 0) return e;
902
+ }, te = function(e, t, n) {
903
+ if (S(e), t === void 0) return e;
817
904
  switch (n) {
818
905
  case 1: return function(n) {
819
906
  return e.call(t, n);
@@ -828,48 +915,48 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
828
915
  return function() {
829
916
  return e.apply(t, arguments);
830
917
  };
831
- }, w = "prototype", T = function(e, r, i) {
832
- 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, _;
833
- 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 && S(u, p, g, e & T.U), d[p] != g && h(d, p, _), c && f[p] != g && (f[p] = g);
918
+ }, C = "prototype", w = function(e, r, i) {
919
+ var a = e & w.F, o = e & w.G, s = e & w.S, c = e & w.P, l = e & w.B, u = o ? t : s ? t[r] || (t[r] = {}) : (t[r] || {})[C], d = o ? n : n[r] || (n[r] = {}), f = d[C] || (d[C] = {}), p, m, g, _;
920
+ for (p in o && (i = r), i) m = !a && u && u[p] !== void 0, g = (m ? u : i)[p], _ = l && m ? te(g, t) : c && typeof g == "function" ? te(Function.call, g) : g, u && x(u, p, g, e & w.U), d[p] != g && h(d, p, _), c && f[p] != g && (f[p] = g);
834
921
  };
835
- 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;
836
- var E = T, D = Math.ceil, O = Math.floor, te = function(e) {
837
- return isNaN(e = +e) ? 0 : (e > 0 ? O : D)(e);
838
- }, k = function(e) {
922
+ t.core = n, w.F = 1, w.G = 2, w.S = 4, w.P = 8, w.B = 16, w.W = 32, w.U = 64, w.R = 128;
923
+ var T = w, E = Math.ceil, ne = Math.floor, D = function(e) {
924
+ return isNaN(e = +e) ? 0 : (e > 0 ? ne : E)(e);
925
+ }, O = function(e) {
839
926
  if (e == null) throw TypeError("Can't call method on " + e);
840
927
  return e;
841
- }, A = function(e) {
928
+ }, k = function(e) {
842
929
  return function(t, n) {
843
- var r = String(k(t)), i = te(n), a = r.length, o, s;
930
+ var r = String(O(t)), i = D(n), a = r.length, o, s;
844
931
  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);
845
932
  };
846
933
  }(!1);
847
- E(E.P, "String", { codePointAt: function(e) {
848
- return A(this, e);
934
+ T(T.P, "String", { codePointAt: function(e) {
935
+ return k(this, e);
849
936
  } }), n.String.codePointAt;
850
- var j = Math.max, ne = Math.min, M = function(e, t) {
851
- return e = te(e), e < 0 ? j(e + t, 0) : ne(e, t);
852
- }, re = String.fromCharCode, ie = String.fromCodePoint;
853
- E(E.S + E.F * (!!ie && ie.length != 1), "String", { fromCodePoint: function(e) {
937
+ var A = Math.max, j = Math.min, re = function(e, t) {
938
+ return e = D(e), e < 0 ? A(e + t, 0) : j(e, t);
939
+ }, M = String.fromCharCode, ie = String.fromCodePoint;
940
+ T(T.S + T.F * (!!ie && ie.length != 1), "String", { fromCodePoint: function(e) {
854
941
  for (var t = arguments, n = [], r = arguments.length, i = 0, a; r > i;) {
855
- if (a = +t[i++], M(a, 1114111) !== a) throw RangeError(a + " is not a valid code point");
856
- n.push(a < 65536 ? re(a) : re(((a -= 65536) >> 10) + 55296, a % 1024 + 56320));
942
+ if (a = +t[i++], re(a, 1114111) !== a) throw RangeError(a + " is not a valid code point");
943
+ n.push(a < 65536 ? M(a) : M(((a -= 65536) >> 10) + 55296, a % 1024 + 56320));
857
944
  }
858
945
  return n.join("");
859
946
  } }), n.String.fromCodePoint;
860
- var ae = {
947
+ var N = {
861
948
  Space_Separator: /[\u1680\u2000-\u200A\u202F\u205F\u3000]/,
862
949
  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]/,
863
950
  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]/
864
- }, N = {
951
+ }, P = {
865
952
  isSpaceSeparator: function(e) {
866
- return typeof e == "string" && ae.Space_Separator.test(e);
953
+ return typeof e == "string" && N.Space_Separator.test(e);
867
954
  },
868
955
  isIdStartChar: function(e) {
869
- return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "$" || e === "_" || ae.ID_Start.test(e));
956
+ return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e === "$" || e === "_" || N.ID_Start.test(e));
870
957
  },
871
958
  isIdContinueChar: function(e) {
872
- return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "$" || e === "_" || e === "‌" || e === "‍" || ae.ID_Continue.test(e));
959
+ return typeof e == "string" && (e >= "a" && e <= "z" || e >= "A" && e <= "Z" || e >= "0" && e <= "9" || e === "$" || e === "_" || e === "‌" || e === "‍" || N.ID_Continue.test(e));
873
960
  },
874
961
  isDigit: function(e) {
875
962
  return typeof e == "string" && /[0-9]/.test(e);
@@ -877,18 +964,18 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
877
964
  isHexDigit: function(e) {
878
965
  return typeof e == "string" && /[0-9A-Fa-f]/.test(e);
879
966
  }
880
- }, P, F, I, L, R, z, B, V, oe, se = function(e, t) {
881
- P = String(e), F = "start", I = [], L = 0, R = 1, z = 0, B = void 0, V = void 0, oe = void 0;
967
+ }, F, I, L, ae, R, z, B, V, H, oe = function(e, t) {
968
+ F = String(e), I = "start", L = [], ae = 0, R = 1, z = 0, B = void 0, V = void 0, H = void 0;
882
969
  do
883
- B = J(), pe[F]();
970
+ B = J(), pe[I]();
884
971
  while (B.type !== "eof");
885
- return typeof t == "function" ? H({ "": oe }, "", t) : oe;
972
+ return typeof t == "function" ? U({ "": H }, "", t) : H;
886
973
  };
887
- function H(e, t, n) {
974
+ function U(e, t, n) {
888
975
  var r = e[t];
889
976
  if (typeof r == "object" && r) {
890
977
  if (Array.isArray(r)) for (var i = 0; i < r.length; i++) {
891
- var a = String(i), o = H(r, a, n);
978
+ var a = String(i), o = U(r, a, n);
892
979
  o === void 0 ? delete r[a] : Object.defineProperty(r, a, {
893
980
  value: o,
894
981
  writable: !0,
@@ -897,7 +984,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
897
984
  });
898
985
  }
899
986
  else for (var s in r) {
900
- var c = H(r, s, n);
987
+ var c = U(r, s, n);
901
988
  c === void 0 ? delete r[s] : Object.defineProperty(r, s, {
902
989
  value: c,
903
990
  writable: !0,
@@ -908,20 +995,20 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
908
995
  }
909
996
  return n.call(e, t, r);
910
997
  }
911
- var U, W, G, K, q;
998
+ var W, G, se, K, q;
912
999
  function J() {
913
- for (U = "default", W = "", G = !1, K = 1;;) {
1000
+ for (W = "default", G = "", se = !1, K = 1;;) {
914
1001
  q = Y();
915
- var e = ce[U]();
1002
+ var e = ce[W]();
916
1003
  if (e) return e;
917
1004
  }
918
1005
  }
919
1006
  function Y() {
920
- if (P[L]) return String.fromCodePoint(P.codePointAt(L));
1007
+ if (F[ae]) return String.fromCodePoint(F.codePointAt(ae));
921
1008
  }
922
1009
  function X() {
923
1010
  var e = Y();
924
- return e === "\n" ? (R++, z = 0) : e ? z += e.length : z++, e && (L += e.length), e;
1011
+ return e === "\n" ? (R++, z = 0) : e ? z += e.length : z++, e && (ae += e.length), e;
925
1012
  }
926
1013
  var ce = {
927
1014
  default: function() {
@@ -939,23 +1026,23 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
939
1026
  X();
940
1027
  return;
941
1028
  case "/":
942
- X(), U = "comment";
1029
+ X(), W = "comment";
943
1030
  return;
944
1031
  case void 0: return X(), Z("eof");
945
1032
  }
946
- if (N.isSpaceSeparator(q)) {
1033
+ if (P.isSpaceSeparator(q)) {
947
1034
  X();
948
1035
  return;
949
1036
  }
950
- return ce[F]();
1037
+ return ce[I]();
951
1038
  },
952
1039
  comment: function() {
953
1040
  switch (q) {
954
1041
  case "*":
955
- X(), U = "multiLineComment";
1042
+ X(), W = "multiLineComment";
956
1043
  return;
957
1044
  case "/":
958
- X(), U = "singleLineComment";
1045
+ X(), W = "singleLineComment";
959
1046
  return;
960
1047
  }
961
1048
  throw Q(X());
@@ -963,7 +1050,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
963
1050
  multiLineComment: function() {
964
1051
  switch (q) {
965
1052
  case "*":
966
- X(), U = "multiLineCommentAsterisk";
1053
+ X(), W = "multiLineCommentAsterisk";
967
1054
  return;
968
1055
  case void 0: throw Q(X());
969
1056
  }
@@ -975,11 +1062,11 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
975
1062
  X();
976
1063
  return;
977
1064
  case "/":
978
- X(), U = "default";
1065
+ X(), W = "default";
979
1066
  return;
980
1067
  case void 0: throw Q(X());
981
1068
  }
982
- X(), U = "multiLineComment";
1069
+ X(), W = "multiLineComment";
983
1070
  },
984
1071
  singleLineComment: function() {
985
1072
  switch (q) {
@@ -987,7 +1074,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
987
1074
  case "\r":
988
1075
  case "\u2028":
989
1076
  case "\u2029":
990
- X(), U = "default";
1077
+ X(), W = "default";
991
1078
  return;
992
1079
  case void 0: return X(), Z("eof");
993
1080
  }
@@ -1002,13 +1089,13 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1002
1089
  case "f": return X(), le("alse"), Z("boolean", !1);
1003
1090
  case "-":
1004
1091
  case "+":
1005
- X() === "-" && (K = -1), U = "sign";
1092
+ X() === "-" && (K = -1), W = "sign";
1006
1093
  return;
1007
1094
  case ".":
1008
- W = X(), U = "decimalPointLeading";
1095
+ G = X(), W = "decimalPointLeading";
1009
1096
  return;
1010
1097
  case "0":
1011
- W = X(), U = "zero";
1098
+ G = X(), W = "zero";
1012
1099
  return;
1013
1100
  case "1":
1014
1101
  case "2":
@@ -1019,13 +1106,13 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1019
1106
  case "7":
1020
1107
  case "8":
1021
1108
  case "9":
1022
- W = X(), U = "decimalInteger";
1109
+ G = X(), W = "decimalInteger";
1023
1110
  return;
1024
1111
  case "I": return X(), le("nfinity"), Z("numeric", Infinity);
1025
1112
  case "N": return X(), le("aN"), Z("numeric", NaN);
1026
1113
  case "\"":
1027
1114
  case "'":
1028
- G = X() === "\"", W = "", U = "string";
1115
+ se = X() === "\"", G = "", W = "string";
1029
1116
  return;
1030
1117
  }
1031
1118
  throw Q(X());
@@ -1037,9 +1124,9 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1037
1124
  switch (e) {
1038
1125
  case "$":
1039
1126
  case "_": break;
1040
- default: if (!N.isIdStartChar(e)) throw _e();
1127
+ default: if (!P.isIdStartChar(e)) throw _e();
1041
1128
  }
1042
- W += e, U = "identifierName";
1129
+ G += e, W = "identifierName";
1043
1130
  },
1044
1131
  identifierName: function() {
1045
1132
  switch (q) {
@@ -1047,17 +1134,17 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1047
1134
  case "_":
1048
1135
  case "‌":
1049
1136
  case "‍":
1050
- W += X();
1137
+ G += X();
1051
1138
  return;
1052
1139
  case "\\":
1053
- X(), U = "identifierNameEscape";
1140
+ X(), W = "identifierNameEscape";
1054
1141
  return;
1055
1142
  }
1056
- if (N.isIdContinueChar(q)) {
1057
- W += X();
1143
+ if (P.isIdContinueChar(q)) {
1144
+ G += X();
1058
1145
  return;
1059
1146
  }
1060
- return Z("identifier", W);
1147
+ return Z("identifier", G);
1061
1148
  },
1062
1149
  identifierNameEscape: function() {
1063
1150
  if (q !== "u") throw Q(X());
@@ -1068,17 +1155,17 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1068
1155
  case "_":
1069
1156
  case "‌":
1070
1157
  case "‍": break;
1071
- default: if (!N.isIdContinueChar(e)) throw _e();
1158
+ default: if (!P.isIdContinueChar(e)) throw _e();
1072
1159
  }
1073
- W += e, U = "identifierName";
1160
+ G += e, W = "identifierName";
1074
1161
  },
1075
1162
  sign: function() {
1076
1163
  switch (q) {
1077
1164
  case ".":
1078
- W = X(), U = "decimalPointLeading";
1165
+ G = X(), W = "decimalPointLeading";
1079
1166
  return;
1080
1167
  case "0":
1081
- W = X(), U = "zero";
1168
+ G = X(), W = "zero";
1082
1169
  return;
1083
1170
  case "1":
1084
1171
  case "2":
@@ -1089,7 +1176,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1089
1176
  case "7":
1090
1177
  case "8":
1091
1178
  case "9":
1092
- W = X(), U = "decimalInteger";
1179
+ G = X(), W = "decimalInteger";
1093
1180
  return;
1094
1181
  case "I": return X(), le("nfinity"), Z("numeric", K * Infinity);
1095
1182
  case "N": return X(), le("aN"), Z("numeric", NaN);
@@ -1099,15 +1186,15 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1099
1186
  zero: function() {
1100
1187
  switch (q) {
1101
1188
  case ".":
1102
- W += X(), U = "decimalPoint";
1189
+ G += X(), W = "decimalPoint";
1103
1190
  return;
1104
1191
  case "e":
1105
1192
  case "E":
1106
- W += X(), U = "decimalExponent";
1193
+ G += X(), W = "decimalExponent";
1107
1194
  return;
1108
1195
  case "x":
1109
1196
  case "X":
1110
- W += X(), U = "hexadecimal";
1197
+ G += X(), W = "hexadecimal";
1111
1198
  return;
1112
1199
  }
1113
1200
  return Z("numeric", K * 0);
@@ -1115,22 +1202,22 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1115
1202
  decimalInteger: function() {
1116
1203
  switch (q) {
1117
1204
  case ".":
1118
- W += X(), U = "decimalPoint";
1205
+ G += X(), W = "decimalPoint";
1119
1206
  return;
1120
1207
  case "e":
1121
1208
  case "E":
1122
- W += X(), U = "decimalExponent";
1209
+ G += X(), W = "decimalExponent";
1123
1210
  return;
1124
1211
  }
1125
- if (N.isDigit(q)) {
1126
- W += X();
1212
+ if (P.isDigit(q)) {
1213
+ G += X();
1127
1214
  return;
1128
1215
  }
1129
- return Z("numeric", K * Number(W));
1216
+ return Z("numeric", K * Number(G));
1130
1217
  },
1131
1218
  decimalPointLeading: function() {
1132
- if (N.isDigit(q)) {
1133
- W += X(), U = "decimalFraction";
1219
+ if (P.isDigit(q)) {
1220
+ G += X(), W = "decimalFraction";
1134
1221
  return;
1135
1222
  }
1136
1223
  throw Q(X());
@@ -1139,81 +1226,81 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1139
1226
  switch (q) {
1140
1227
  case "e":
1141
1228
  case "E":
1142
- W += X(), U = "decimalExponent";
1229
+ G += X(), W = "decimalExponent";
1143
1230
  return;
1144
1231
  }
1145
- if (N.isDigit(q)) {
1146
- W += X(), U = "decimalFraction";
1232
+ if (P.isDigit(q)) {
1233
+ G += X(), W = "decimalFraction";
1147
1234
  return;
1148
1235
  }
1149
- return Z("numeric", K * Number(W));
1236
+ return Z("numeric", K * Number(G));
1150
1237
  },
1151
1238
  decimalFraction: function() {
1152
1239
  switch (q) {
1153
1240
  case "e":
1154
1241
  case "E":
1155
- W += X(), U = "decimalExponent";
1242
+ G += X(), W = "decimalExponent";
1156
1243
  return;
1157
1244
  }
1158
- if (N.isDigit(q)) {
1159
- W += X();
1245
+ if (P.isDigit(q)) {
1246
+ G += X();
1160
1247
  return;
1161
1248
  }
1162
- return Z("numeric", K * Number(W));
1249
+ return Z("numeric", K * Number(G));
1163
1250
  },
1164
1251
  decimalExponent: function() {
1165
1252
  switch (q) {
1166
1253
  case "+":
1167
1254
  case "-":
1168
- W += X(), U = "decimalExponentSign";
1255
+ G += X(), W = "decimalExponentSign";
1169
1256
  return;
1170
1257
  }
1171
- if (N.isDigit(q)) {
1172
- W += X(), U = "decimalExponentInteger";
1258
+ if (P.isDigit(q)) {
1259
+ G += X(), W = "decimalExponentInteger";
1173
1260
  return;
1174
1261
  }
1175
1262
  throw Q(X());
1176
1263
  },
1177
1264
  decimalExponentSign: function() {
1178
- if (N.isDigit(q)) {
1179
- W += X(), U = "decimalExponentInteger";
1265
+ if (P.isDigit(q)) {
1266
+ G += X(), W = "decimalExponentInteger";
1180
1267
  return;
1181
1268
  }
1182
1269
  throw Q(X());
1183
1270
  },
1184
1271
  decimalExponentInteger: function() {
1185
- if (N.isDigit(q)) {
1186
- W += X();
1272
+ if (P.isDigit(q)) {
1273
+ G += X();
1187
1274
  return;
1188
1275
  }
1189
- return Z("numeric", K * Number(W));
1276
+ return Z("numeric", K * Number(G));
1190
1277
  },
1191
1278
  hexadecimal: function() {
1192
- if (N.isHexDigit(q)) {
1193
- W += X(), U = "hexadecimalInteger";
1279
+ if (P.isHexDigit(q)) {
1280
+ G += X(), W = "hexadecimalInteger";
1194
1281
  return;
1195
1282
  }
1196
1283
  throw Q(X());
1197
1284
  },
1198
1285
  hexadecimalInteger: function() {
1199
- if (N.isHexDigit(q)) {
1200
- W += X();
1286
+ if (P.isHexDigit(q)) {
1287
+ G += X();
1201
1288
  return;
1202
1289
  }
1203
- return Z("numeric", K * Number(W));
1290
+ return Z("numeric", K * Number(G));
1204
1291
  },
1205
1292
  string: function() {
1206
1293
  switch (q) {
1207
1294
  case "\\":
1208
- X(), W += ue();
1295
+ X(), G += ue();
1209
1296
  return;
1210
1297
  case "\"":
1211
- if (G) return X(), Z("string", W);
1212
- W += X();
1298
+ if (se) return X(), Z("string", G);
1299
+ G += X();
1213
1300
  return;
1214
1301
  case "'":
1215
- if (!G) return X(), Z("string", W);
1216
- W += X();
1302
+ if (!se) return X(), Z("string", G);
1303
+ G += X();
1217
1304
  return;
1218
1305
  case "\n":
1219
1306
  case "\r": throw Q(X());
@@ -1223,32 +1310,32 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1223
1310
  break;
1224
1311
  case void 0: throw Q(X());
1225
1312
  }
1226
- W += X();
1313
+ G += X();
1227
1314
  },
1228
1315
  start: function() {
1229
1316
  switch (q) {
1230
1317
  case "{":
1231
1318
  case "[": return Z("punctuator", X());
1232
1319
  }
1233
- U = "value";
1320
+ W = "value";
1234
1321
  },
1235
1322
  beforePropertyName: function() {
1236
1323
  switch (q) {
1237
1324
  case "$":
1238
1325
  case "_":
1239
- W = X(), U = "identifierName";
1326
+ G = X(), W = "identifierName";
1240
1327
  return;
1241
1328
  case "\\":
1242
- X(), U = "identifierNameStartEscape";
1329
+ X(), W = "identifierNameStartEscape";
1243
1330
  return;
1244
1331
  case "}": return Z("punctuator", X());
1245
1332
  case "\"":
1246
1333
  case "'":
1247
- G = X() === "\"", U = "string";
1334
+ se = X() === "\"", W = "string";
1248
1335
  return;
1249
1336
  }
1250
- if (N.isIdStartChar(q)) {
1251
- W += X(), U = "identifierName";
1337
+ if (P.isIdStartChar(q)) {
1338
+ G += X(), W = "identifierName";
1252
1339
  return;
1253
1340
  }
1254
1341
  throw Q(X());
@@ -1258,7 +1345,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1258
1345
  throw Q(X());
1259
1346
  },
1260
1347
  beforePropertyValue: function() {
1261
- U = "value";
1348
+ W = "value";
1262
1349
  },
1263
1350
  afterPropertyValue: function() {
1264
1351
  switch (q) {
@@ -1269,7 +1356,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1269
1356
  },
1270
1357
  beforeArrayValue: function() {
1271
1358
  if (q === "]") return Z("punctuator", X());
1272
- U = "value";
1359
+ W = "value";
1273
1360
  },
1274
1361
  afterArrayValue: function() {
1275
1362
  switch (q) {
@@ -1306,7 +1393,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1306
1393
  case "t": return X(), " ";
1307
1394
  case "v": return X(), "\v";
1308
1395
  case "0":
1309
- if (X(), N.isDigit(Y())) throw Q(X());
1396
+ if (X(), P.isDigit(Y())) throw Q(X());
1310
1397
  return "\0";
1311
1398
  case "x": return X(), de();
1312
1399
  case "u": return X(), fe();
@@ -1329,13 +1416,13 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1329
1416
  }
1330
1417
  function de() {
1331
1418
  var e = "", t = Y();
1332
- if (!N.isHexDigit(t) || (e += X(), t = Y(), !N.isHexDigit(t))) throw Q(X());
1419
+ if (!P.isHexDigit(t) || (e += X(), t = Y(), !P.isHexDigit(t))) throw Q(X());
1333
1420
  return e += X(), String.fromCodePoint(parseInt(e, 16));
1334
1421
  }
1335
1422
  function fe() {
1336
1423
  for (var e = "", t = 4; t-- > 0;) {
1337
1424
  var n = Y();
1338
- if (!N.isHexDigit(n)) throw Q(X());
1425
+ if (!P.isHexDigit(n)) throw Q(X());
1339
1426
  e += X();
1340
1427
  }
1341
1428
  return String.fromCodePoint(parseInt(e, 16));
@@ -1349,7 +1436,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1349
1436
  switch (B.type) {
1350
1437
  case "identifier":
1351
1438
  case "string":
1352
- V = B.value, F = "afterPropertyName";
1439
+ V = B.value, I = "afterPropertyName";
1353
1440
  return;
1354
1441
  case "punctuator":
1355
1442
  he();
@@ -1359,7 +1446,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1359
1446
  },
1360
1447
  afterPropertyName: function() {
1361
1448
  if (B.type === "eof") throw ge();
1362
- F = "beforePropertyValue";
1449
+ I = "beforePropertyValue";
1363
1450
  },
1364
1451
  beforePropertyValue: function() {
1365
1452
  if (B.type === "eof") throw ge();
@@ -1377,7 +1464,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1377
1464
  if (B.type === "eof") throw ge();
1378
1465
  switch (B.value) {
1379
1466
  case ",":
1380
- F = "beforePropertyName";
1467
+ I = "beforePropertyName";
1381
1468
  return;
1382
1469
  case "}": he();
1383
1470
  }
@@ -1386,7 +1473,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1386
1473
  if (B.type === "eof") throw ge();
1387
1474
  switch (B.value) {
1388
1475
  case ",":
1389
- F = "beforeArrayValue";
1476
+ I = "beforeArrayValue";
1390
1477
  return;
1391
1478
  case "]": he();
1392
1479
  }
@@ -1409,9 +1496,9 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1409
1496
  case "numeric":
1410
1497
  case "string": e = B.value;
1411
1498
  }
1412
- if (oe === void 0) oe = e;
1499
+ if (H === void 0) H = e;
1413
1500
  else {
1414
- var t = I[I.length - 1];
1501
+ var t = L[L.length - 1];
1415
1502
  Array.isArray(t) ? t.push(e) : Object.defineProperty(t, V, {
1416
1503
  value: e,
1417
1504
  writable: !0,
@@ -1419,16 +1506,16 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1419
1506
  configurable: !0
1420
1507
  });
1421
1508
  }
1422
- if (typeof e == "object" && e) I.push(e), F = Array.isArray(e) ? "beforeArrayValue" : "beforePropertyName";
1509
+ if (typeof e == "object" && e) L.push(e), I = Array.isArray(e) ? "beforeArrayValue" : "beforePropertyName";
1423
1510
  else {
1424
- var n = I[I.length - 1];
1425
- F = n == null ? "end" : Array.isArray(n) ? "afterArrayValue" : "afterPropertyValue";
1511
+ var n = L[L.length - 1];
1512
+ I = n == null ? "end" : Array.isArray(n) ? "afterArrayValue" : "afterPropertyValue";
1426
1513
  }
1427
1514
  }
1428
1515
  function he() {
1429
- I.pop();
1430
- var e = I[I.length - 1];
1431
- F = e == null ? "end" : Array.isArray(e) ? "afterArrayValue" : "afterPropertyValue";
1516
+ L.pop();
1517
+ var e = L[L.length - 1];
1518
+ I = e == null ? "end" : Array.isArray(e) ? "afterArrayValue" : "afterPropertyValue";
1432
1519
  }
1433
1520
  function Q(e) {
1434
1521
  return be(e === void 0 ? "JSON5: invalid end of input at " + R + ":" + z : "JSON5: invalid character '" + ye(e) + "' at " + R + ":" + z);
@@ -1469,7 +1556,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1469
1556
  return t.lineNumber = R, t.columnNumber = z, t;
1470
1557
  }
1471
1558
  return {
1472
- parse: se,
1559
+ parse: oe,
1473
1560
  stringify: function(e, t, n) {
1474
1561
  var r = [], i = "", a, o, s = "", c;
1475
1562
  if (typeof t == "object" && t && !Array.isArray(t) && (n = t.space, c = t.quote, t = t.replacer), typeof t == "function") o = t;
@@ -1516,7 +1603,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1516
1603
  case "\"":
1517
1604
  t[a]++, r += a;
1518
1605
  continue;
1519
- case "\0": if (N.isDigit(e[i + 1])) {
1606
+ case "\0": if (P.isDigit(e[i + 1])) {
1520
1607
  r += "\\x00";
1521
1608
  continue;
1522
1609
  }
@@ -1564,8 +1651,8 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1564
1651
  function g(e) {
1565
1652
  if (e.length === 0) return m(e, !0);
1566
1653
  var t = String.fromCodePoint(e.codePointAt(0));
1567
- if (!N.isIdStartChar(t)) return m(e, !0);
1568
- for (var n = t.length; n < e.length; n++) if (!N.isIdContinueChar(String.fromCodePoint(e.codePointAt(n)))) return m(e, !0);
1654
+ if (!P.isIdStartChar(t)) return m(e, !0);
1655
+ for (var n = t.length; n < e.length; n++) if (!P.isIdContinueChar(String.fromCodePoint(e.codePointAt(n)))) return m(e, !0);
1569
1656
  return e;
1570
1657
  }
1571
1658
  function _(e) {
@@ -1589,7 +1676,7 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1589
1676
  }
1590
1677
  };
1591
1678
  }));
1592
- })))(), 1), De = {
1679
+ })))(), 1), Fe = {
1593
1680
  ball: 1,
1594
1681
  red: 2,
1595
1682
  blue: 4,
@@ -1603,36 +1690,36 @@ var Te = "5a27b77ea69c9f5e179f", Ee = /* @__PURE__ */ c((/* @__PURE__ */ o(((e,
1603
1690
  c2: 1073741824,
1604
1691
  c3: -2147483648,
1605
1692
  all: 63
1606
- }, Oe = (e) => {
1693
+ }, Ie = (e) => {
1607
1694
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Expected an object");
1608
1695
  return e;
1609
1696
  }, $ = (e, t, n = -4096, r = 4096) => {
1610
1697
  let i = e === void 0 ? t : e;
1611
1698
  if (typeof i != "number" || !Number.isFinite(i) || i < n || i > r) throw Error(`Number must be between ${n} and ${r}`);
1612
1699
  return i;
1613
- }, ke = (e, t = [0, 0]) => {
1700
+ }, Le = (e, t = [0, 0]) => {
1614
1701
  if (e === void 0) return [...t];
1615
1702
  if (!Array.isArray(e) || e.length !== 2) throw Error("Expected [x, y]");
1616
1703
  return [$(e[0], 0), $(e[1], 0)];
1617
- }, Ae = (e, t) => {
1704
+ }, Re = (e, t) => {
1618
1705
  if (e === void 0) return [];
1619
1706
  if (!Array.isArray(e) || e.length > t) throw Error(`Array limit: ${t}`);
1620
1707
  return e;
1621
1708
  };
1622
- function je(e, t) {
1623
- return e === void 0 ? t : typeof e == "number" ? $(e, t, -2147483648, 4294967295) | 0 : Ae(e, 16).reduce((e, t) => {
1624
- if (typeof t != "string" || !Object.hasOwn(De, t)) throw Error("Unknown collision flag");
1625
- return e | De[t];
1709
+ function ze(e, t) {
1710
+ return e === void 0 ? t : typeof e == "number" ? $(e, t, -2147483648, 4294967295) | 0 : Re(e, 16).reduce((e, t) => {
1711
+ if (typeof t != "string" || !Object.hasOwn(Fe, t)) throw Error("Unknown collision flag");
1712
+ return e | Fe[t];
1626
1713
  }, 0);
1627
1714
  }
1628
- function Me(e, t = "FFFFFF") {
1715
+ function Be(e, t = "FFFFFF") {
1629
1716
  if (e === void 0) return t;
1630
1717
  if (e === "transparent") return e;
1631
1718
  if (Array.isArray(e) && e.length === 3) return e.map((e) => Math.round($(e, 0, 0, 255)).toString(16).padStart(2, "0")).join("");
1632
1719
  if (typeof e == "string" && /^[0-9a-f]{6}$/i.test(e)) return e;
1633
1720
  throw Error("Invalid color");
1634
1721
  }
1635
- var Ne = Object.fromEntries(Object.entries({
1722
+ var Ve = Object.fromEntries(Object.entries({
1636
1723
  root: "version physicsMode name width height maxViewWidth cameraFollow spawnDistance canBeStored kickOffReset bg traits vertexes segments goals discs planes joints redSpawnPoints blueSpawnPoints playerPhysics ballPhysics",
1637
1724
  bg: "type width height kickOffRadius cornerRadius goalLine color",
1638
1725
  vertexes: "trait x y bCoef cMask cGroup",
@@ -1642,7 +1729,7 @@ var Ne = Object.fromEntries(Object.entries({
1642
1729
  goals: "trait p0 p1 team",
1643
1730
  joints: "trait d0 d1 length strength color",
1644
1731
  playerPhysics: "trait pos speed gravity radius invMass damping bCoef cGroup cMask color acceleration kickingAcceleration kickingDamping kickStrength kickback"
1645
- }).map(([e, t]) => [e, new Set(t.split(" "))])), Pe = new Set([
1732
+ }).map(([e, t]) => [e, new Set(t.split(" "))])), He = new Set([
1646
1733
  "vertexes",
1647
1734
  "segments",
1648
1735
  "discs",
@@ -1650,15 +1737,15 @@ var Ne = Object.fromEntries(Object.entries({
1650
1737
  "goals",
1651
1738
  "joints",
1652
1739
  "playerPhysics"
1653
- ].flatMap((e) => [...Ne[e]]));
1654
- function Fe(e) {
1740
+ ].flatMap((e) => [...Ve[e]]));
1741
+ function Ue(e) {
1655
1742
  let t = [], n = (e, t) => {
1656
1743
  let n = t.length > 80 ? `${t.slice(0, 80)}…` : t;
1657
1744
  return e + (/^[A-Za-z_$][\w$]*$/.test(n) ? `.${n}` : `[${JSON.stringify(n)}]`);
1658
1745
  }, r = (e, r, i) => {
1659
1746
  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."));
1660
1747
  };
1661
- r(e, Ne.root, "$"), r(e.bg, Ne.bg, "$.bg");
1748
+ r(e, Ve.root, "$"), r(e.bg, Ve.bg, "$.bg");
1662
1749
  for (let t of [
1663
1750
  "vertexes",
1664
1751
  "segments",
@@ -1669,67 +1756,67 @@ function Fe(e) {
1669
1756
  ]) {
1670
1757
  let n = e[t];
1671
1758
  Array.isArray(n) && n.forEach((e, n) => {
1672
- r(e, Ne[t], `$.${t}[${n}]`);
1759
+ r(e, Ve[t], `$.${t}[${n}]`);
1673
1760
  });
1674
1761
  }
1675
- if (r(e.ballPhysics, Ne.discs, "$.ballPhysics"), r(e.playerPhysics, Ne.playerPhysics, "$.playerPhysics"), e.traits && typeof e.traits == "object" && !Array.isArray(e.traits)) for (let [t, i] of Object.entries(e.traits)) r(i, Pe, n("$.traits", t));
1762
+ if (r(e.ballPhysics, Ve.discs, "$.ballPhysics"), r(e.playerPhysics, Ve.playerPhysics, "$.playerPhysics"), e.traits && typeof e.traits == "object" && !Array.isArray(e.traits)) for (let [t, i] of Object.entries(e.traits)) r(i, He, n("$.traits", t));
1676
1763
  return t;
1677
1764
  }
1678
- function Ie(e, t, n, r, i) {
1765
+ function We(e, t, n, r, i) {
1679
1766
  let a = e === "hbs" ? 1 : Math.ceil(2 * Math.SQRT2 * 100 / Math.min(10, i));
1680
1767
  if ((t + 32) * (n + t + 32 + r) * a > 2e6) throw Error("Stadium collision complexity exceeds the room budget");
1681
1768
  }
1682
- function Le(e) {
1769
+ function Ge(e) {
1683
1770
  if (new TextEncoder().encode(e).length > 262144) throw Error("Stadium exceeds 256 KB");
1684
- let t = Oe(Ee.default.parse(e));
1771
+ let t = Ie(Pe.default.parse(e));
1685
1772
  if (t.physicsMode !== void 0 && t.physicsMode !== "hbs" && t.physicsMode !== "substeps") throw Error("Invalid physics mode");
1686
1773
  let n = t.physicsMode === "substeps" ? "substeps" : "hbs";
1687
1774
  if (t.version !== void 0 && t.version !== 1) throw Error("Unsupported stadium version");
1688
- let r = t.traits === void 0 ? {} : Oe(t.traits), i = (e) => {
1689
- let t = Oe(e);
1775
+ let r = t.traits === void 0 ? {} : Ie(t.traits), i = (e) => {
1776
+ let t = Ie(e);
1690
1777
  if (t.trait === void 0) return t;
1691
1778
  if (typeof t.trait != "string" || !Object.hasOwn(r, t.trait)) throw Error("Unknown trait");
1692
1779
  return {
1693
- ...Oe(r[t.trait]),
1780
+ ...Ie(r[t.trait]),
1694
1781
  ...t
1695
1782
  };
1696
1783
  }, a = (e, t = !1) => ({
1697
- pos: ke(e.pos),
1698
- speed: ke(e.speed),
1699
- gravity: ke(e.gravity),
1784
+ pos: Le(e.pos),
1785
+ speed: Le(e.speed),
1786
+ gravity: Le(e.gravity),
1700
1787
  radius: $(e.radius, 10, .5, 100),
1701
1788
  invMass: $(e.invMass, 1, 0, 8192),
1702
1789
  damping: $(e.damping, .99, 0, 8192),
1703
1790
  bCoef: $(e.bCoef, .5, -1, 8192),
1704
- cGroup: je(e.cGroup, t ? 193 : 63),
1705
- cMask: je(e.cMask, 63),
1706
- color: Me(e.color)
1707
- }), o = Ae(t.discs, 63).map((e) => a(i(e)));
1791
+ cGroup: ze(e.cGroup, t ? 193 : 63),
1792
+ cMask: ze(e.cMask, 63),
1793
+ color: Be(e.color)
1794
+ }), o = Re(t.discs, 63).map((e) => a(i(e)));
1708
1795
  if (t.ballPhysics !== "disc0") {
1709
1796
  let e = a(t.ballPhysics === void 0 ? {} : i(t.ballPhysics), !0);
1710
1797
  e.cGroup |= 192, o.unshift(e);
1711
1798
  } else if (!o.length) throw Error("disc0 needs a disc");
1712
- let s = Ae(t.vertexes, 1024).map((e) => i(e)), c = [], l = [], u = Fe(t);
1799
+ let s = Re(t.vertexes, 1024).map((e) => i(e)), c = [], l = [], u = Ue(t);
1713
1800
  for (let e of s) c.push({
1714
1801
  a: [$(e.x, 0), $(e.y, 0)],
1715
1802
  b: [$(e.x, 0), $(e.y, 0)],
1716
1803
  bCoef: $(e.bCoef, 1, -1, 8192),
1717
- cGroup: je(e.cGroup, 32),
1718
- cMask: je(e.cMask, 63),
1804
+ cGroup: ze(e.cGroup, 32),
1805
+ cMask: ze(e.cMask, 63),
1719
1806
  bias: 0,
1720
1807
  color: "transparent",
1721
1808
  vis: !1
1722
1809
  });
1723
1810
  let d = [...c];
1724
- for (let e of Ae(t.segments, 1024)) {
1811
+ for (let e of Re(t.segments, 1024)) {
1725
1812
  let t = i(e), n = $(t.v0, -1, 0, s.length - 1), r = $(t.v1, -1, 0, s.length - 1);
1726
1813
  if (!Number.isInteger(n) || !Number.isInteger(r)) throw Error("Vertex indices must be integers");
1727
1814
  let a = [$(s[n].x, 0), $(s[n].y, 0)], o = [$(s[r].x, 0), $(s[r].y, 0)], u = {
1728
1815
  bCoef: $(t.bCoef, 1, -1, 8192),
1729
- cGroup: je(t.cGroup, 32),
1730
- cMask: je(t.cMask, 63),
1816
+ cGroup: ze(t.cGroup, 32),
1817
+ cMask: ze(t.cMask, 63),
1731
1818
  bias: $(t.bias, 0, -100, 100),
1732
- color: Me(t.color, "000000"),
1819
+ color: Be(t.color, "000000"),
1733
1820
  vis: t.vis !== !1
1734
1821
  }, f = t.curveF === void 0 ? $(t.curve, 0, -359, 359) : 2 * Math.atan2(1, $(t.curveF, 0, -1e8, 1e8)) * 180 / Math.PI;
1735
1822
  if (Math.abs(f) < 1e-4) {
@@ -1743,28 +1830,28 @@ function Le(e) {
1743
1830
  }
1744
1831
  let p = f * Math.PI / 180, m = o[0] - a[0], h = o[1] - a[1];
1745
1832
  if (Math.hypot(m, h) < .001) throw Error("Arc endpoints overlap");
1746
- 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))));
1747
- if (c.length + b > 4096) throw Error("Compiled geometry exceeds 4096 segments");
1748
- let x = {
1833
+ 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]), ee = Math.atan2(a[1] - _[1], a[0] - _[0]), y = Math.ceil(Math.abs(p) / Math.max(1e-8, 2 * Math.acos(Math.max(-1, 1 - .15 / v))));
1834
+ if (c.length + y > 4096) throw Error("Compiled geometry exceeds 4096 segments");
1835
+ let b = {
1749
1836
  a,
1750
1837
  b: o,
1751
1838
  ...u,
1752
1839
  center: _,
1753
1840
  radius: v,
1754
- start: y,
1841
+ start: ee,
1755
1842
  sweep: p,
1756
1843
  major: t.curveF === void 0 ? Math.abs(f) > 180 : Number(t.curveF) <= 0
1757
1844
  };
1758
- l.push(x), d.push(x);
1759
- let S = a;
1760
- for (let e = 1; e <= b; e++) {
1761
- let t = e === b ? o : [_[0] + v * Math.cos(y + p * e / b), _[1] + v * Math.sin(y + p * e / b)];
1845
+ l.push(b), d.push(b);
1846
+ let x = a;
1847
+ for (let e = 1; e <= y; e++) {
1848
+ let t = e === y ? o : [_[0] + v * Math.cos(ee + p * e / y), _[1] + v * Math.sin(ee + p * e / y)];
1762
1849
  c.push({
1763
- a: S,
1850
+ a: x,
1764
1851
  b: t,
1765
1852
  ...u,
1766
1853
  renderOnly: !0
1767
- }), S = t;
1854
+ }), x = t;
1768
1855
  }
1769
1856
  }
1770
1857
  if (c.length > 4096) throw Error("Compiled geometry exceeds 4096 segments");
@@ -1782,8 +1869,8 @@ function Le(e) {
1782
1869
  kickStrength: $(f.kickStrength, 5, -8192, 8192),
1783
1870
  kickback: $(f.kickback, 0, -8192, 8192)
1784
1871
  };
1785
- Ie(n, o.length, c.length, Ae(t.planes, 64).length + Ae(t.joints, 128).length, Math.min(p.radius, ...o.map((e) => e.radius)));
1786
- let m = t.bg === void 0 ? {} : Oe(t.bg);
1872
+ We(n, o.length, c.length, Re(t.planes, 64).length + Re(t.joints, 128).length, Math.min(p.radius, ...o.map((e) => e.radius)));
1873
+ let m = t.bg === void 0 ? {} : Ie(t.bg);
1787
1874
  return {
1788
1875
  version: 1,
1789
1876
  physicsMode: n,
@@ -1799,7 +1886,7 @@ function Le(e) {
1799
1886
  goalLine: $(m.goalLine, 0, 0, 2048),
1800
1887
  width: $(m.width, 0, 0, 2048),
1801
1888
  height: $(m.height, 0, 0, 2048),
1802
- color: Me(m.color, "718C5A"),
1889
+ color: Be(m.color, "718C5A"),
1803
1890
  kickOffRadius: $(m.kickOffRadius, 0, 0, 500)
1804
1891
  },
1805
1892
  discs: o,
@@ -1809,24 +1896,24 @@ function Le(e) {
1809
1896
  player: p,
1810
1897
  spawnDistance: $(t.spawnDistance, 200, 0, 1500),
1811
1898
  kickOffReset: t.kickOffReset === "full" ? "full" : "partial",
1812
- redSpawnPoints: Ae(t.redSpawnPoints, 32).map((e) => ke(e)),
1813
- blueSpawnPoints: Ae(t.blueSpawnPoints, 32).map((e) => ke(e)),
1899
+ redSpawnPoints: Re(t.redSpawnPoints, 32).map((e) => Le(e)),
1900
+ blueSpawnPoints: Re(t.blueSpawnPoints, 32).map((e) => Le(e)),
1814
1901
  warnings: u,
1815
- planes: Ae(t.planes, 64).map((e) => {
1816
- let t = i(e), n = ke(t.normal);
1902
+ planes: Re(t.planes, 64).map((e) => {
1903
+ let t = i(e), n = Le(t.normal);
1817
1904
  if (Math.hypot(...n) < 1e-6) throw Error("Plane normal is zero");
1818
1905
  return {
1819
1906
  normal: n,
1820
1907
  dist: $(t.dist, 0),
1821
1908
  bCoef: $(t.bCoef, 1, -1, 8192),
1822
- cGroup: je(t.cGroup, 32),
1823
- cMask: je(t.cMask, 63)
1909
+ cGroup: ze(t.cGroup, 32),
1910
+ cMask: ze(t.cMask, 63)
1824
1911
  };
1825
1912
  }),
1826
- goals: Ae(t.goals, 16).map((e) => {
1913
+ goals: Re(t.goals, 16).map((e) => {
1827
1914
  let t = i(e);
1828
1915
  if (t.team !== "red" && t.team !== "blue") throw Error("Invalid goal team");
1829
- let n = ke(t.p0), r = ke(t.p1);
1916
+ let n = Le(t.p0), r = Le(t.p1);
1830
1917
  if (Math.hypot(r[0] - n[0], r[1] - n[1]) < 1) throw Error("Goal has zero length");
1831
1918
  return {
1832
1919
  p0: n,
@@ -1834,22 +1921,22 @@ function Le(e) {
1834
1921
  team: t.team === "red" ? 1 : 2
1835
1922
  };
1836
1923
  }),
1837
- joints: Ae(t.joints, 128).map((e) => {
1924
+ joints: Re(t.joints, 128).map((e) => {
1838
1925
  let t = i(e), n = $(t.d0, -1, 0, o.length - 1), r = $(t.d1, -1, 0, o.length - 1);
1839
1926
  if (!Number.isInteger(n) || !Number.isInteger(r) || n === r) throw Error("Invalid joint indices");
1840
- 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] : ke(t.length);
1927
+ 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] : Le(t.length);
1841
1928
  return {
1842
1929
  d0: n,
1843
1930
  d1: r,
1844
1931
  min: $(s[0], 0, 0),
1845
1932
  max: $(s[1], 0, 0),
1846
1933
  strength: t.strength === void 0 || t.strength === "rigid" ? "rigid" : $(t.strength, 0, -8192, 8192),
1847
- color: Me(t.color, "000000")
1934
+ color: Be(t.color, "000000")
1848
1935
  };
1849
1936
  })
1850
1937
  };
1851
1938
  }
1852
- function Re(e = "Emerald Arena", t = 440, n = 220) {
1939
+ function Ke(e = "Emerald Arena", t = 440, n = 220) {
1853
1940
  let r = [
1854
1941
  [-t, -n],
1855
1942
  [t, -n],
@@ -1989,7 +2076,7 @@ function Re(e = "Emerald Arena", t = 440, n = 220) {
1989
2076
  }
1990
2077
  }, null, 2);
1991
2078
  }
1992
- var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2079
+ var qe = `ball2d-core/1/${Ne}`, Je = 32, Ye = class e {
1993
2080
  core;
1994
2081
  terrain;
1995
2082
  stadium;
@@ -2011,10 +2098,10 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2011
2098
  lastGoal = 0;
2012
2099
  kickRate = 2;
2013
2100
  setKickRateLimit(e, t, n) {
2014
- this.kickRate = He(e, t, n), this.core.kick_limits(this.kickRate & 255, this.kickRate >>> 8 & 255, this.kickRate >>> 16);
2101
+ this.kickRate = Xe(e, t, n), this.core.kick_limits(this.kickRate & 255, this.kickRate >>> 8 & 255, this.kickRate >>> 16);
2015
2102
  }
2016
2103
  constructor(e) {
2017
- this.core = e.exports, this.terrain = new Z(this.core);
2104
+ this.core = e.exports, this.terrain = new pe(this.core);
2018
2105
  }
2019
2106
  configureSurface(e) {
2020
2107
  if (this.phase !== "lobby" && this.phase !== "finished") throw Error("Stop the match before configuring its surface");
@@ -2038,9 +2125,9 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2038
2125
  return new Float64Array(this.core.memory.buffer, this.core.data_ptr(), this.core.count() * 18);
2039
2126
  }
2040
2127
  load(e) {
2041
- this.stadium = Le(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;
2128
+ this.stadium = Ge(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;
2042
2129
  for (let e of this.stadium.discs) this.add(e);
2043
- for (let e = 0; e < Be; e++) this.add(this.stadium.player, e + 1);
2130
+ for (let e = 0; e < Je; e++) this.add(this.stadium.player, e + 1);
2044
2131
  for (let e of this.stadium.colliders) if ("center" in e) {
2045
2132
  let t = e;
2046
2133
  this.core.arc(...t.center, t.radius, ...t.a, ...t.b, t.sweep, +t.major, t.bCoef, t.cGroup, t.cMask, t.bias);
@@ -2078,7 +2165,7 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2078
2165
  });
2079
2166
  }
2080
2167
  index(e) {
2081
- if (!Number.isInteger(e) || e < 0 || e >= Be) throw Error("Invalid slot");
2168
+ if (!Number.isInteger(e) || e < 0 || e >= Je) throw Error("Invalid slot");
2082
2169
  return this.stadium.discs.length + e;
2083
2170
  }
2084
2171
  joinPlayer(e) {
@@ -2101,8 +2188,8 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2101
2188
  applyDiscProperties(e, t) {
2102
2189
  let n = this.data;
2103
2190
  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;
2104
- let r = we(t), i = !1;
2105
- for (let [t, a] of Ce) {
2191
+ let r = Me(t), i = !1;
2192
+ for (let [t, a] of je) {
2106
2193
  let o = r[t];
2107
2194
  if (o === void 0) continue;
2108
2195
  let s = a === -1 ? this.colors[e] : n[e * 18 + a];
@@ -2112,9 +2199,9 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2112
2199
  if (r.radius !== void 0) {
2113
2200
  let t = r.radius;
2114
2201
  for (let r = 0; r < this.colors.length; r++) r !== e && (t = Math.min(t, n[r * 18 + 4]));
2115
- Ie(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, t);
2202
+ We(this.stadium.physicsMode, this.stadium.discs.length, this.stadium.segments.length, this.stadium.planes.length + this.stadium.joints.length, t);
2116
2203
  }
2117
- for (let [t, i] of Ce) {
2204
+ for (let [t, i] of je) {
2118
2205
  let a = r[t];
2119
2206
  a !== void 0 && (i === -1 ? this.colors[e] = a : n[e * 18 + i] = a);
2120
2207
  }
@@ -2138,7 +2225,7 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2138
2225
  let r = this.stadium.discs[n];
2139
2226
  (e || n === 0 || this.stadium.kickOffReset === "full") && (this.restoreDiscProperties(n, r), t[n * 18] = r.pos[0], t[n * 18 + 1] = r.pos[1], t[n * 18 + 2] = r.speed[0], t[n * 18 + 3] = r.speed[1]);
2140
2227
  }
2141
- for (let e = 0; e < Be; e++) {
2228
+ for (let e = 0; e < Je; e++) {
2142
2229
  let n = this.index(e);
2143
2230
  this.spawn(n, e, t[n * 18 + 13]);
2144
2231
  }
@@ -2172,7 +2259,7 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2172
2259
  --this.countdown <= 0 && (this.scoreLimit > 0 && Math.max(this.red, this.blue) >= this.scoreLimit || this.timeLimit > 0 && this.elapsed >= this.timeLimit * 60 && this.red !== this.blue ? this.finish() : (this.phase = "playing", this.resetPositions()));
2173
2260
  return;
2174
2261
  }
2175
- for (let t = 0; t < Be; t++) {
2262
+ for (let t = 0; t < Je; t++) {
2176
2263
  let n = this.index(t) * 18, r = this.stadium.player.cMask;
2177
2264
  e[n + 11] = r & -25 | (this.kickoffActive ? r & (this.kickoff === 1 ? 8 : 16) : 0);
2178
2265
  }
@@ -2225,10 +2312,10 @@ var ze = `ball2d-core/1/${Te}`, Be = 32, Ve = class e {
2225
2312
  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");
2226
2313
  let n = 10;
2227
2314
  for (let t = 4; t < e.discs.length; t += 18) n = Math.min(n, e.discs[t]);
2228
- Ie(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];
2315
+ We(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];
2229
2316
  }
2230
2317
  };
2231
- function He(e, t, n) {
2318
+ function Xe(e, t, n) {
2232
2319
  if (![
2233
2320
  e,
2234
2321
  t,
@@ -2236,20 +2323,56 @@ function He(e, t, n) {
2236
2323
  ].every(Number.isInteger)) throw Error("Invalid kick rate limit");
2237
2324
  return Math.max(0, Math.min(255, e)) | Math.max(0, Math.min(255, t)) << 8 | Math.max(0, Math.min(100, n)) << 16;
2238
2325
  }
2239
- function Ue(e) {
2326
+ function Ze(e) {
2240
2327
  let t = new URL(e);
2241
2328
  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");
2242
2329
  return t.origin;
2243
2330
  }
2244
- function We() {
2331
+ function Qe(e) {
2332
+ let t = new URL(e.assets);
2333
+ if (![
2334
+ "http:",
2335
+ "https:",
2336
+ "ball2d:"
2337
+ ].includes(t.protocol) || !t.host || t.username || t.password || t.pathname !== "/" || t.search || t.hash) throw Error("Expected a root asset origin");
2338
+ let n = Ze(e.service), r = Ze(e.public);
2339
+ function i(e, t) {
2340
+ if (!e.startsWith("/") || e.startsWith("//") || e.includes("\\") || [...e].some((e) => e.charCodeAt(0) <= 32 || e.charCodeAt(0) === 127)) throw Error("Expected an absolute application path");
2341
+ let n = decodeURIComponent(e.split(/[?#]/, 1)[0]);
2342
+ if (n.includes("\\") || n.includes("//") || n.split("/").some((e) => e === "." || e === "..")) throw Error("Ambiguous application path");
2343
+ let r = new URL(e, t), i = new URL(t);
2344
+ if (r.protocol !== i.protocol || r.host !== i.host || r.username || r.password) throw Error("Application path escaped its runtime origin");
2345
+ return r;
2346
+ }
2245
2347
  return {
2246
- serviceOrigin: location.origin,
2348
+ serviceOrigin: n,
2349
+ publicOrigin: r,
2350
+ asset: (e) => i(e, t.href),
2351
+ public: (e) => i(e, r),
2352
+ api: (e) => {
2353
+ let t = i(e, n);
2354
+ if (!t.pathname.startsWith(`${m}/`) || t.hash) throw Error("Expected a versioned application API path");
2355
+ return t;
2356
+ }
2357
+ };
2358
+ }
2359
+ function $e() {
2360
+ let e = location.origin;
2361
+ return Qe({
2362
+ assets: e,
2363
+ service: e,
2364
+ public: e
2365
+ });
2366
+ }
2367
+ function et(e = $e()) {
2368
+ return {
2369
+ serviceOrigin: e.serviceOrigin,
2247
2370
  signalingResume: !0,
2248
2371
  createWebSocket: (e) => new WebSocket(e),
2249
2372
  createPeerConnection: (e) => new RTCPeerConnection(e)
2250
2373
  };
2251
2374
  }
2252
- var Ge = [
2375
+ var tt = [
2253
2376
  ["classic", "Classic"],
2254
2377
  ["easy", "Easy"],
2255
2378
  ["small", "Small"],
@@ -2261,30 +2384,35 @@ var Ge = [
2261
2384
  ["big_hockey", "Big Hockey"],
2262
2385
  ["huge", "Huge"]
2263
2386
  ];
2264
- function Ke(e) {
2387
+ function nt(e) {
2265
2388
  let t = /* @__PURE__ */ new Map();
2266
2389
  return async (n) => {
2267
- let r = Ge.find(([e, t]) => e === n || t === n);
2390
+ let r = tt.find(([e, t]) => e === n || t === n);
2268
2391
  if (!r) throw Error("Unknown default stadium");
2269
2392
  let i = t.get(r[0]);
2270
2393
  return i || (i = (async () => {
2271
2394
  let t = await e(`/stadiums/${r[0]}.hbs`);
2272
2395
  if (!t.ok) throw Error("Could not load stadium");
2273
2396
  let n = await t.text();
2274
- return Le(n), n;
2397
+ return Ge(n), n;
2275
2398
  })(), t.set(r[0], i), i.catch(() => t.delete(r[0]))), i;
2276
2399
  };
2277
2400
  }
2278
- function qe() {
2279
- let e = We(), t = (e, t) => fetch(e, t);
2401
+ function rt(e = $e()) {
2402
+ let t = et(e), n = (e, t) => fetch(e, t);
2280
2403
  return {
2281
- network: e,
2282
- request: t,
2283
- loadEngine: (e) => Ve.create(void 0, e),
2284
- loadStadium: Ke((n) => t(new URL(n, e.serviceOrigin)))
2404
+ network: t,
2405
+ publicOrigin: e.publicOrigin,
2406
+ request: n,
2407
+ loadEngine: async (t) => {
2408
+ let r = await n(e.asset(`/core.wasm?v=${Ne}`), { signal: t });
2409
+ if (!r.ok) throw Error("Could not load bundled physics engine");
2410
+ return Ye.create(await r.arrayBuffer(), t);
2411
+ },
2412
+ loadStadium: nt((t) => n(e.asset(t)))
2285
2413
  };
2286
2414
  }
2287
- var Je = {
2415
+ var it = {
2288
2416
  message: {
2289
2417
  burst: 240,
2290
2418
  perSecond: 160
@@ -2297,12 +2425,12 @@ var Je = {
2297
2425
  burst: 4,
2298
2426
  perSecond: 1
2299
2427
  }
2300
- }, Ye = class {
2428
+ }, at = class {
2301
2429
  peers = /* @__PURE__ */ new Map();
2302
2430
  allow(e, t, n = performance.now()) {
2303
2431
  let r = this.peers.get(e);
2304
2432
  r || (r = {}, this.peers.set(e, r));
2305
- let { burst: i, perSecond: a } = Je[t], o = r[t] ?? {
2433
+ let { burst: i, perSecond: a } = it[t], o = r[t] ?? {
2306
2434
  tokens: i,
2307
2435
  at: n
2308
2436
  };
@@ -2314,16 +2442,16 @@ var Je = {
2314
2442
  clear() {
2315
2443
  this.peers.clear();
2316
2444
  }
2317
- }, Xe = 33554432, Ze = new TextEncoder();
2445
+ }, ot = 33554432, st = new TextEncoder();
2318
2446
  new TextDecoder("utf-8", { fatal: !0 });
2319
- function Qe(e) {
2447
+ function ct(e) {
2320
2448
  let t = 2166136261;
2321
2449
  for (let n of e) t = Math.imul(t ^ n, 16777619);
2322
2450
  return t >>> 0;
2323
2451
  }
2324
- function $e(e) {
2452
+ function lt(e) {
2325
2453
  if (e.length > 33554432) throw Error("Replay exceeds 32 MB");
2326
- let t = K(e, { level: 6 }), n = new Uint8Array(16 + t.length), r = new DataView(n.buffer);
2454
+ let t = ce(e, { level: 6 }), n = new Uint8Array(16 + t.length), r = new DataView(n.buffer);
2327
2455
  return n.set([
2328
2456
  66,
2329
2457
  50,
@@ -2333,12 +2461,12 @@ function $e(e) {
2333
2461
  0,
2334
2462
  0,
2335
2463
  0
2336
- ]), r.setUint32(8, e.length, !0), r.setUint32(12, Qe(e), !0), n.set(t, 16), n;
2464
+ ]), r.setUint32(8, e.length, !0), r.setUint32(12, ct(e), !0), n.set(t, 16), n;
2337
2465
  }
2338
- function et(e) {
2466
+ function ut(e) {
2339
2467
  if (typeof e == "string") {
2340
- if (Ze.encode(e).length > 33554432) throw Error("Replay exceeds 32 MB");
2341
- return Ze.encode(e);
2468
+ if (st.encode(e).length > 33554432) throw Error("Replay exceeds 32 MB");
2469
+ return st.encode(e);
2342
2470
  }
2343
2471
  let t = e instanceof Uint8Array ? e : new Uint8Array(e);
2344
2472
  if (t.length > 33554432) throw Error("Replay exceeds 32 MB");
@@ -2346,15 +2474,15 @@ function et(e) {
2346
2474
  if (t.length < 17 || t[4] !== 1 || t[5] || t[6] || t[7]) throw Error("Invalid compressed replay header");
2347
2475
  let n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = n.getUint32(8, !0);
2348
2476
  if (!r || r > 33554432) throw Error("Invalid expanded replay size");
2349
- let i = new Uint8Array(r), a = 0, o = !1, s = new q((e, t) => {
2477
+ let i = new Uint8Array(r), a = 0, o = !1, s = new Z((e, t) => {
2350
2478
  if (a + e.length > r) throw Error("Expanded replay exceeds declared size");
2351
2479
  i.set(e, a), a += e.length, o = t;
2352
2480
  });
2353
2481
  for (let e = 16; e < t.length; e += 1024) s.push(t.subarray(e, e + 1024), e + 1024 >= t.length);
2354
- if (!o || a !== r || Qe(i) !== n.getUint32(12, !0)) throw Error("Compressed replay integrity failure");
2482
+ if (!o || a !== r || ct(i) !== n.getUint32(12, !0)) throw Error("Compressed replay integrity failure");
2355
2483
  return i;
2356
2484
  }
2357
- var tt = [
2485
+ var dt = [
2358
2486
  "input",
2359
2487
  "team",
2360
2488
  "start",
@@ -2366,11 +2494,11 @@ var tt = [
2366
2494
  "join",
2367
2495
  "disc",
2368
2496
  "surface"
2369
- ], nt = new TextEncoder(), rt = new TextDecoder("utf-8", { fatal: !0 });
2370
- function it(e) {
2371
- return $e(at(e));
2497
+ ], ft = new TextEncoder(), pt = new TextDecoder("utf-8", { fatal: !0 });
2498
+ function mt(e) {
2499
+ return lt(ht(e));
2372
2500
  }
2373
- function at(e) {
2501
+ function ht(e) {
2374
2502
  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) => {
2375
2503
  let t = e.state.discs;
2376
2504
  if (!Array.isArray(t) || t.length > 1728 || t.some((e) => !Number.isFinite(e))) throw Error("Invalid checkpoint discs");
@@ -2390,12 +2518,12 @@ function at(e) {
2390
2518
  };
2391
2519
  });
2392
2520
  if (a.length > 721) throw Error("Too many replay checkpoints");
2393
- let o = nt.encode(JSON.stringify(r >= 2 ? {
2521
+ let o = ft.encode(JSON.stringify(r >= 2 ? {
2394
2522
  ...n,
2395
2523
  checkpoints: a
2396
2524
  } : n));
2397
2525
  if (t.length > 5e5 || o.length + 16 > 33554432) throw Error("Replay exceeds bounds");
2398
- let s = t.length * 12 + t.filter((e) => e.kind === "disc").length * 106, c = new Uint8Array(Math.min(Xe, s)), l = new DataView(c.buffer), u = (e) => {
2526
+ let s = t.length * 12 + t.filter((e) => e.kind === "disc").length * 106, c = new Uint8Array(Math.min(ot, s)), l = new DataView(c.buffer), u = (e) => {
2399
2527
  if (d + e > c.length) throw Error("Replay exceeds bounds");
2400
2528
  }, d = 0, f = e.initial.tick, p = (e) => {
2401
2529
  if (!Number.isInteger(e) || e < 0 || e > 4294967295) throw Error("Invalid replay integer");
@@ -2406,15 +2534,15 @@ function at(e) {
2406
2534
  } while (e);
2407
2535
  };
2408
2536
  for (let e of t) {
2409
- let t = tt.indexOf(r < 3 && e.kind === "join" ? "team" : e.kind);
2537
+ let t = dt.indexOf(r < 3 && e.kind === "join" ? "team" : e.kind);
2410
2538
  if (e.kind === "join" && e.value !== 0 || e.kind === "team" && e.value > 2) throw Error("Invalid replay team command");
2411
2539
  if (t < 0 || !Number.isInteger(e.slot) || e.slot < 0 || e.slot > (e.kind === "disc" ? 95 : 31)) throw Error("Invalid replay command");
2412
2540
  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") {
2413
- let t = we(e.properties), n = 0;
2414
- Ce.forEach(([e], r) => {
2541
+ let t = Me(e.properties), n = 0;
2542
+ je.forEach(([e], r) => {
2415
2543
  t[e] !== void 0 && (n |= 1 << r);
2416
2544
  }), p(n);
2417
- for (let [e] of Ce) {
2545
+ for (let [e] of je) {
2418
2546
  let n = t[e];
2419
2547
  n !== void 0 && (u(8), l.setFloat64(d, n, !0), d += 8);
2420
2548
  }
@@ -2441,9 +2569,9 @@ function at(e) {
2441
2569
  }
2442
2570
  return h.set(c.subarray(0, d), _), h;
2443
2571
  }
2444
- function ot(e) {
2445
- let t = et(e);
2446
- if (t[0] !== 66 || t[1] !== 50 || t[2] !== 68 || t[3] !== 80) return JSON.parse(rt.decode(t));
2572
+ function gt(e) {
2573
+ let t = ut(e);
2574
+ if (t[0] !== 66 || t[1] !== 50 || t[2] !== 68 || t[3] !== 80) return JSON.parse(pt.decode(t));
2447
2575
  if (t.length < 16 || ![
2448
2576
  1,
2449
2577
  2,
@@ -2452,7 +2580,7 @@ function ot(e) {
2452
2580
  ].includes(t[4]) || t[5] || t[6] || t[7]) throw Error("Invalid packed replay header");
2453
2581
  let n = new DataView(t.buffer, t.byteOffset, t.byteLength), r = n.getUint32(8, !0), i = n.getUint32(12, !0);
2454
2582
  if (r > t.length - 16 || i > 5e5 || i > (t.length - 16 - r) / 3) throw Error("Invalid packed replay bounds");
2455
- let a = JSON.parse(rt.decode(t.subarray(16, 16 + r)));
2583
+ let a = JSON.parse(pt.decode(t.subarray(16, 16 + r)));
2456
2584
  if (!a || !Number.isSafeInteger(a.initial?.tick) || a.initial.tick < 0) throw Error("Invalid replay initial tick");
2457
2585
  a.commands = [];
2458
2586
  let o = 16 + r, s = a.initial.tick;
@@ -2498,14 +2626,14 @@ function ot(e) {
2498
2626
  };
2499
2627
  for (let e = 0; e < i; e++) {
2500
2628
  if (s += c(), !Number.isSafeInteger(s) || o >= t.length) throw Error("Invalid replay tick");
2501
- let e = t[o++], r = tt[t[4] >= 3 ? e : e >> 5];
2629
+ let e = t[o++], r = dt[t[4] >= 3 ? e : e >> 5];
2502
2630
  if (!r) throw Error("Unknown replay command");
2503
2631
  let i = t[4] >= 3 ? c() : e & 31, l = c();
2504
2632
  if (r === "disc") {
2505
2633
  let e = c();
2506
2634
  if (e > 8191) throw Error("Invalid disc property mask");
2507
2635
  let u = {};
2508
- Ce.forEach(([r], i) => {
2636
+ je.forEach(([r], i) => {
2509
2637
  if (e & 1 << i) {
2510
2638
  if (o + 8 > t.length) throw Error("Truncated disc properties");
2511
2639
  u[r] = n.getFloat64(o, !0), o += 8;
@@ -2515,7 +2643,7 @@ function ot(e) {
2515
2643
  kind: r,
2516
2644
  slot: i,
2517
2645
  value: l,
2518
- properties: we(u)
2646
+ properties: Me(u)
2519
2647
  });
2520
2648
  continue;
2521
2649
  }
@@ -2534,12 +2662,12 @@ function ot(e) {
2534
2662
  if (o !== t.length) throw Error("Trailing replay command data");
2535
2663
  return a;
2536
2664
  }
2537
- function st(e) {
2665
+ function _t(e) {
2538
2666
  let t = JSON.stringify(e), n = 2166136261;
2539
2667
  for (let e = 0; e < t.length; e++) n ^= t.charCodeAt(e), n = Math.imul(n, 16777619);
2540
2668
  return (n >>> 0).toString(16).padStart(8, "0");
2541
2669
  }
2542
- function ct(e, t) {
2670
+ function vt(e, t) {
2543
2671
  switch (t.kind) {
2544
2672
  case "surface":
2545
2673
  if (t.slot !== 0 || t.value !== 0 && t.value !== 1) throw Error("Invalid surface command");
@@ -2586,7 +2714,7 @@ function ct(e, t) {
2586
2714
  case "pause": e.setPaused(!!t.value);
2587
2715
  }
2588
2716
  }
2589
- var lt = class {
2717
+ var yt = class {
2590
2718
  replay;
2591
2719
  playerOrder = [];
2592
2720
  lastInputs = /* @__PURE__ */ new Map();
@@ -2600,7 +2728,7 @@ var lt = class {
2600
2728
  this.playerOrder = t.map((e) => e.slot), this.replay = {
2601
2729
  magic: "B2DR",
2602
2730
  version: 1,
2603
- engine: ze,
2731
+ engine: qe,
2604
2732
  stadium: e.source,
2605
2733
  initial: r,
2606
2734
  commands: [],
@@ -2611,14 +2739,14 @@ var lt = class {
2611
2739
  })),
2612
2740
  styles: [{
2613
2741
  tick: r.tick,
2614
- teams: ye(n)
2742
+ teams: De(n)
2615
2743
  }],
2616
2744
  orders: [{
2617
2745
  tick: r.tick,
2618
2746
  slots: [...this.playerOrder]
2619
2747
  }],
2620
2748
  end: r.tick,
2621
- finalHash: st(r)
2749
+ finalHash: _t(r)
2622
2750
  }, this.bytes = new TextEncoder().encode(JSON.stringify(this.replay)).length;
2623
2751
  for (let t = 0; t < 32; t++) this.lastInputs.set(t, e.data[e.index(t) * 18 + 14]);
2624
2752
  }
@@ -2638,7 +2766,7 @@ var lt = class {
2638
2766
  style(e, t) {
2639
2767
  let n = {
2640
2768
  tick: e,
2641
- teams: ye(t)
2769
+ teams: De(t)
2642
2770
  }, r = this.replay.styles;
2643
2771
  return r.length >= 4096 || !this.reserve(n) ? (this.full = !0, !1) : (r.push(n), !0);
2644
2772
  }
@@ -2653,7 +2781,7 @@ var lt = class {
2653
2781
  command(e) {
2654
2782
  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" ? {
2655
2783
  ...e,
2656
- properties: we(e.properties)
2784
+ properties: Me(e.properties)
2657
2785
  } : { ...e }), !0);
2658
2786
  }
2659
2787
  step(e) {
@@ -2662,26 +2790,26 @@ var lt = class {
2662
2790
  let t = e.snapshot(), n = {
2663
2791
  tick: e.tick,
2664
2792
  state: t,
2665
- hash: st(t)
2793
+ hash: _t(t)
2666
2794
  };
2667
2795
  this.reserve(n) && this.replay.checkpoints.push(n);
2668
2796
  }
2669
2797
  this.replay.end = e.tick;
2670
2798
  }
2671
2799
  pack(e) {
2672
- return this.replay.end = e.tick, this.replay.finalHash = st(e.snapshot()), at(this.replay);
2800
+ return this.replay.end = e.tick, this.replay.finalHash = _t(e.snapshot()), ht(this.replay);
2673
2801
  }
2674
2802
  finish(e) {
2675
- return this.replay.end = e.tick, this.replay.finalHash = st(e.snapshot()), new Blob([it(this.replay)], { type: "application/x-ball2d-replay" });
2803
+ return this.replay.end = e.tick, this.replay.finalHash = _t(e.snapshot()), new Blob([mt(this.replay)], { type: "application/x-ball2d-replay" });
2676
2804
  }
2677
2805
  };
2678
- async function ut(e) {
2806
+ async function bt(e) {
2679
2807
  if (e.size > 33554432) throw Error("Replay exceeds 32 MB");
2680
- return dt(await e.arrayBuffer());
2808
+ return xt(await e.arrayBuffer());
2681
2809
  }
2682
- function dt(e) {
2683
- let t = ot(e);
2684
- if (t.magic !== "B2DR" || t.version !== 1 || t.engine !== ze) throw Error("Unsupported replay engine/version");
2810
+ function xt(e) {
2811
+ let t = gt(e);
2812
+ if (t.magic !== "B2DR" || t.version !== 1 || t.engine !== qe) throw Error("Unsupported replay engine/version");
2685
2813
  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");
2686
2814
  let n = t.initial.tick;
2687
2815
  for (let e of t.commands) {
@@ -2698,12 +2826,12 @@ function dt(e) {
2698
2826
  "disc",
2699
2827
  "surface"
2700
2828
  ].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");
2701
- e.kind === "disc" && (e.properties = we(e.properties)), n = e.tick;
2829
+ e.kind === "disc" && (e.properties = Me(e.properties)), n = e.tick;
2702
2830
  }
2703
2831
  if (!Array.isArray(t.roster) || t.roster.length > 4096) throw Error("Invalid replay roster");
2704
2832
  n = t.initial.tick;
2705
2833
  for (let e of t.roster) {
2706
- 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 && !Se(e.avatar)) throw Error("Invalid roster event");
2834
+ 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 && !Ae(e.avatar)) throw Error("Invalid roster event");
2707
2835
  n = e.tick;
2708
2836
  }
2709
2837
  if (t.styles !== void 0) {
@@ -2711,7 +2839,7 @@ function dt(e) {
2711
2839
  let e = t.initial.tick;
2712
2840
  for (let n of t.styles) {
2713
2841
  if (!n || !Number.isInteger(n.tick) || n.tick < e || n.tick > t.end || n.teams === void 0) throw Error("Invalid replay style");
2714
- n.teams = ye(n.teams), e = n.tick;
2842
+ n.teams = De(n.teams), e = n.tick;
2715
2843
  }
2716
2844
  }
2717
2845
  if (t.orders !== void 0) {
@@ -2729,7 +2857,7 @@ function dt(e) {
2729
2857
  }
2730
2858
  return t;
2731
2859
  }
2732
- var ft = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, pt = class {
2860
+ var St = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, Ct = class {
2733
2861
  io;
2734
2862
  state = "admitted";
2735
2863
  currentEpoch = 0;
@@ -2742,7 +2870,7 @@ var ft = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, pt = class {
2742
2870
  timerVersion = 0;
2743
2871
  transport;
2744
2872
  constructor(e, t) {
2745
- if (this.io = e, !ft(t)) throw RangeError("Invalid membership duration");
2873
+ if (this.io = e, !St(t)) throw RangeError("Invalid membership duration");
2746
2874
  this.membershipDeadline = e.now() + t, this.arm();
2747
2875
  }
2748
2876
  get epoch() {
@@ -2755,7 +2883,7 @@ var ft = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, pt = class {
2755
2883
  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());
2756
2884
  }
2757
2885
  acknowledge(e, t) {
2758
- if (e !== this.currentEpoch || this.state !== "awaiting-ack" || t !== void 0 && !ft(t) || this.checkExpiry() || this.checkAttemptTimeout()) return !1;
2886
+ if (e !== this.currentEpoch || this.state !== "awaiting-ack" || t !== void 0 && !St(t) || this.checkExpiry() || this.checkAttemptTimeout()) return !1;
2759
2887
  t !== void 0 && (this.membershipDeadline = Math.min(this.membershipDeadline, this.io.now() + t));
2760
2888
  let n = this.attemptId;
2761
2889
  if (n === void 0) return !1;
@@ -2766,7 +2894,7 @@ var ft = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, pt = class {
2766
2894
  return this.state = "admitted", this.recoveryDeadline = Infinity, this.phaseDeadline = Infinity, this.attemptId = void 0, this.retry = 0, this.arm(), this.io.onRecovered(r), !0;
2767
2895
  }
2768
2896
  heartbeat(e, t) {
2769
- return e !== this.currentEpoch || this.state !== "admitted" || !ft(t) || this.checkExpiry() ? !1 : (this.membershipDeadline = this.io.now() + t, this.arm(), !0);
2897
+ return e !== this.currentEpoch || this.state !== "admitted" || !St(t) || this.checkExpiry() ? !1 : (this.membershipDeadline = this.io.now() + t, this.arm(), !0);
2770
2898
  }
2771
2899
  cancel() {
2772
2900
  this.terminal() || (this.state = "cancelled", this.clearTimer(), this.retire());
@@ -2837,19 +2965,19 @@ var ft = (e) => Number.isSafeInteger(e) && e > 0 && e <= 9e4, pt = class {
2837
2965
  n.close();
2838
2966
  } catch {}
2839
2967
  }
2840
- }, mt = 2, ht = 9e4, gt = 33;
2841
- function _t(e, t) {
2968
+ }, wt = 2, Tt = 9e4, Et = 33;
2969
+ function Dt(e, t) {
2842
2970
  return typeof e == "object" && !!e && !Array.isArray(e) && Object.keys(e).length === t.length && t.every((t) => Object.hasOwn(e, t));
2843
2971
  }
2844
- var vt = (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), yt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), bt = (e, t) => Number.isSafeInteger(e) && e >= t, xt = (e) => bt(e, 1) && e <= ht, St = (e) => e === "host" || e === "guest";
2845
- function Ct(e) {
2846
- return !_t(e, [
2972
+ var Ot = (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), kt = (e) => typeof e == "string" && /^[0-9a-f]{64}$/.test(e), At = (e, t) => Number.isSafeInteger(e) && e >= t, jt = (e) => At(e, 1) && e <= Tt, Mt = (e) => e === "host" || e === "guest";
2973
+ function Nt(e) {
2974
+ return !Dt(e, [
2847
2975
  "version",
2848
2976
  "roomGeneration",
2849
2977
  "secret",
2850
2978
  "connectionEpoch",
2851
2979
  "membershipValidForMs"
2852
- ]) || e.version !== mt || !vt(e.roomGeneration) || !yt(e.secret) || !bt(e.connectionEpoch, 1) || !xt(e.membershipValidForMs) ? null : {
2980
+ ]) || e.version !== wt || !Ot(e.roomGeneration) || !kt(e.secret) || !At(e.connectionEpoch, 1) || !jt(e.membershipValidForMs) ? null : {
2853
2981
  version: 2,
2854
2982
  roomGeneration: e.roomGeneration,
2855
2983
  secret: e.secret,
@@ -2857,8 +2985,8 @@ function Ct(e) {
2857
2985
  membershipValidForMs: e.membershipValidForMs
2858
2986
  };
2859
2987
  }
2860
- function wt(e) {
2861
- if (!_t(e, [
2988
+ function Pt(e) {
2989
+ if (!Dt(e, [
2862
2990
  "type",
2863
2991
  "version",
2864
2992
  "roomGeneration",
@@ -2872,8 +3000,8 @@ function wt(e) {
2872
3000
  "members",
2873
3001
  "requireVerification",
2874
3002
  "locked"
2875
- ]) || e.type !== "resumed" || e.version !== mt || !vt(e.roomGeneration) || !vt(e.attemptId) || !vt(e.id) || !vt(e.hostId) || !St(e.role) || !bt(e.connectionEpoch, 1) || !xt(e.membershipValidForMs) || !bt(e.rosterRevision, 0) || typeof e.requireVerification != "boolean" || typeof e.locked != "boolean" || !Array.isArray(e.members) || e.members.length < 1 || e.members.length > gt) return null;
2876
- let t = Et(e.members, e.hostId);
3003
+ ]) || e.type !== "resumed" || e.version !== wt || !Ot(e.roomGeneration) || !Ot(e.attemptId) || !Ot(e.id) || !Ot(e.hostId) || !Mt(e.role) || !At(e.connectionEpoch, 1) || !jt(e.membershipValidForMs) || !At(e.rosterRevision, 0) || typeof e.requireVerification != "boolean" || typeof e.locked != "boolean" || !Array.isArray(e.members) || e.members.length < 1 || e.members.length > Et) return null;
3004
+ let t = It(e.members, e.hostId);
2877
3005
  return t?.some((t) => t.id === e.id && t.role === e.role && t.attached && t.connectionEpoch === e.connectionEpoch) ? {
2878
3006
  type: "resumed",
2879
3007
  version: 2,
@@ -2890,8 +3018,8 @@ function wt(e) {
2890
3018
  locked: e.locked
2891
3019
  } : null;
2892
3020
  }
2893
- function Tt(e) {
2894
- if (!_t(e, [
3021
+ function Ft(e) {
3022
+ if (!Dt(e, [
2895
3023
  "type",
2896
3024
  "id",
2897
3025
  "hostId",
@@ -2902,9 +3030,9 @@ function Tt(e) {
2902
3030
  "requireVerification",
2903
3031
  "locked"
2904
3032
  ]) || e.type !== "ready") return null;
2905
- let t = Ct(e.resumeGrant);
3033
+ let t = Nt(e.resumeGrant);
2906
3034
  if (!t) return null;
2907
- let n = wt({
3035
+ let n = Pt({
2908
3036
  type: "resumed",
2909
3037
  version: 2,
2910
3038
  roomGeneration: t.roomGeneration,
@@ -2931,16 +3059,16 @@ function Tt(e) {
2931
3059
  locked: n.locked
2932
3060
  } : null;
2933
3061
  }
2934
- function Et(e, t) {
2935
- if (!Array.isArray(e) || e.length < 1 || e.length > gt) return null;
3062
+ function It(e, t) {
3063
+ if (!Array.isArray(e) || e.length < 1 || e.length > Et) return null;
2936
3064
  let n = [], r = /* @__PURE__ */ new Set();
2937
3065
  for (let t of e) {
2938
- if (!_t(t, [
3066
+ if (!Dt(t, [
2939
3067
  "id",
2940
3068
  "role",
2941
3069
  "attached",
2942
3070
  "connectionEpoch"
2943
- ]) || !vt(t.id) || !St(t.role) || typeof t.attached != "boolean" || !bt(t.connectionEpoch, 1) || r.has(t.id)) return null;
3071
+ ]) || !Ot(t.id) || !Mt(t.role) || typeof t.attached != "boolean" || !At(t.connectionEpoch, 1) || r.has(t.id)) return null;
2944
3072
  r.add(t.id), n.push({
2945
3073
  id: t.id,
2946
3074
  role: t.role,
@@ -2951,15 +3079,15 @@ function Et(e, t) {
2951
3079
  let i = n.filter((e) => e.role === "host");
2952
3080
  return i.length === 1 && i[0].id === t ? n : null;
2953
3081
  }
2954
- function Dt(e) {
2955
- if (!_t(e, [
3082
+ function Lt(e) {
3083
+ if (!Dt(e, [
2956
3084
  "type",
2957
3085
  "roomGeneration",
2958
3086
  "hostId",
2959
3087
  "rosterRevision",
2960
3088
  "members"
2961
- ]) || e.type !== "roster" || !vt(e.roomGeneration) || !vt(e.hostId) || !bt(e.rosterRevision, 0)) return null;
2962
- let t = Et(e.members, e.hostId);
3089
+ ]) || e.type !== "roster" || !Ot(e.roomGeneration) || !Ot(e.hostId) || !At(e.rosterRevision, 0)) return null;
3090
+ let t = It(e.members, e.hostId);
2963
3091
  return t ? {
2964
3092
  type: "roster",
2965
3093
  roomGeneration: e.roomGeneration,
@@ -2968,31 +3096,31 @@ function Dt(e) {
2968
3096
  members: t
2969
3097
  } : null;
2970
3098
  }
2971
- function Ot(e) {
3099
+ function Rt(e) {
2972
3100
  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);
2973
3101
  if (i.length !== 1) return null;
2974
3102
  let a = i[0].currentRoundTripTime;
2975
3103
  return typeof a == "number" && Number.isFinite(a) && a >= 0 ? a * 1e3 : null;
2976
3104
  }
2977
- var kt = 524288, At = 16384, jt = 12;
2978
- function Mt(e, t) {
3105
+ var zt = 524288, Bt = 16384, Vt = 12;
3106
+ function Ht(e, t) {
2979
3107
  let n = JSON.stringify(e);
2980
3108
  if (n === void 0) throw Error("Missing control message");
2981
3109
  let r = new TextEncoder().encode(n);
2982
- if (r.length > kt) throw Error("Control message exceeds 512 KB");
2983
- if (r.length <= At) return [n];
2984
- let i = Math.ceil(r.length / At), a = [];
3110
+ if (r.length > zt) throw Error("Control message exceeds 512 KB");
3111
+ if (r.length <= Bt) return [n];
3112
+ let i = Math.ceil(r.length / Bt), a = [];
2985
3113
  for (let e = 0; e < i; e++) {
2986
- let n = r.subarray(e * At, (e + 1) * At), o = new ArrayBuffer(jt + n.length), s = new DataView(o);
2987
- 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, jt).set(n), a.push(o);
3114
+ let n = r.subarray(e * Bt, (e + 1) * Bt), o = new ArrayBuffer(Vt + n.length), s = new DataView(o);
3115
+ 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, Vt).set(n), a.push(o);
2988
3116
  }
2989
3117
  return a;
2990
3118
  }
2991
- var Nt = class {
3119
+ var Ut = class {
2992
3120
  partial;
2993
3121
  push(e, t = performance.now()) {
2994
3122
  if (typeof e == "string") {
2995
- if (this.partial || new TextEncoder().encode(e).length > At) throw Error("Invalid control message");
3123
+ if (this.partial || new TextEncoder().encode(e).length > Bt) throw Error("Invalid control message");
2996
3124
  return JSON.parse(e);
2997
3125
  }
2998
3126
  if (e.byteLength < 13 || e.byteLength > 16396) throw Error("Control fragment length");
@@ -3013,13 +3141,13 @@ var Nt = class {
3013
3141
  }
3014
3142
  let o = this.partial;
3015
3143
  if (o.id !== r || o.count !== a || o.next !== i || t - o.since > 1e4) throw Error("Control fragment sequence");
3016
- if (o.next++, o.bytes += e.byteLength - jt, o.bytes > kt) throw Error("Control size limit");
3017
- if (o.parts.push(new Uint8Array(e.slice(jt))), o.next !== a) return;
3144
+ if (o.next++, o.bytes += e.byteLength - Vt, o.bytes > zt) throw Error("Control size limit");
3145
+ if (o.parts.push(new Uint8Array(e.slice(Vt))), o.next !== a) return;
3018
3146
  let s = new Uint8Array(o.bytes), c = 0;
3019
3147
  for (let e of o.parts) s.set(e, c), c += e.length;
3020
3148
  return this.partial = void 0, JSON.parse(new TextDecoder("utf-8", { fatal: !0 }).decode(s));
3021
3149
  }
3022
- }, Pt = class extends Error {}, Ft = 1, It = (e) => typeof e == "string" && /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e), Lt = (e) => Number.isSafeInteger(e) && e > 0, Rt = (e) => e?.match(/(?:^|\r?\n)a=ice-ufrag:([^\s]+)/)?.[1], zt = (e) => e.usernameFragment ?? e.candidate?.match(/(?:^| )ufrag ([^ ]+)/)?.[1], Bt = class {
3150
+ }, Wt = class extends Error {}, Gt = 1, Kt = (e) => typeof e == "string" && /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(e), qt = (e) => Number.isSafeInteger(e) && e > 0, Jt = (e) => e?.match(/(?:^|\r?\n)a=ice-ufrag:([^\s]+)/)?.[1], Yt = (e) => e.usernameFragment ?? e.candidate?.match(/(?:^| )ufrag ([^ ]+)/)?.[1], Xt = class {
3023
3151
  room;
3024
3152
  credentials;
3025
3153
  hooks;
@@ -3091,7 +3219,7 @@ var Nt = class {
3091
3219
  }
3092
3220
  }
3093
3221
  get signalingReady() {
3094
- return !this.closed && !!this.id && this.ws.readyState === Ft && this.signalingAdmitted;
3222
+ return !this.closed && !!this.id && this.ws.readyState === Gt && this.signalingAdmitted;
3095
3223
  }
3096
3224
  get signalingAdmitted() {
3097
3225
  return !this.recovery || this.recovery.status === "admitted";
@@ -3108,7 +3236,7 @@ var Nt = class {
3108
3236
  n && (this.verificationRequest = void 0, clearTimeout(n.timer), t && (this.verificationState = null), n.reject(Error(e)));
3109
3237
  }
3110
3238
  setRequireVerification(e) {
3111
- return typeof e == "boolean" ? this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Ft ? 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) => {
3239
+ return typeof e == "boolean" ? this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Gt ? 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) => {
3112
3240
  let r = ++this.verificationSequence, i = setTimeout(() => this.rejectVerification("Verification update was not confirmed."), 1e4);
3113
3241
  this.verificationRequest = {
3114
3242
  id: r,
@@ -3134,7 +3262,7 @@ var Nt = class {
3134
3262
  t && (this.passwordRequest = void 0, clearTimeout(t.timer), t.reject(Error(e)));
3135
3263
  }
3136
3264
  setPassword(e) {
3137
- 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 !== Ft ? 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) => {
3265
+ 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 !== Gt ? 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) => {
3138
3266
  let r = ++this.passwordRequestId, i = setTimeout(() => this.rejectPasswordUpdate("Password update was not confirmed."), 1e4);
3139
3267
  this.passwordRequest = {
3140
3268
  id: r,
@@ -3157,22 +3285,23 @@ var Nt = class {
3157
3285
  banRequest;
3158
3286
  rejectBan(e, t = !0) {
3159
3287
  let n = this.banRequest;
3160
- n && (this.banRequest = void 0, clearTimeout(n.timer), n.reject(t ? new Pt(e) : Error(e)));
3288
+ n && (this.banRequest = void 0, clearTimeout(n.timer), n.reject(t ? new Wt(e) : Error(e)));
3161
3289
  }
3162
- updateBan(e, t) {
3163
- return this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Ft ? 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) => {
3164
- let i = ++this.banSequence, a = setTimeout(() => this.rejectBan("Ban operation was not confirmed."), 1e4);
3290
+ updateBan(e, t, n) {
3291
+ return this.closed || !this.host || !this.signalingAdmitted || this.ws.readyState !== Gt ? Promise.reject(Error("An active room-owner connection is required.")) : this.banRequest ? Promise.reject(Error("A ban operation is already pending.")) : new Promise((r, i) => {
3292
+ let a = ++this.banSequence, o = setTimeout(() => this.rejectBan("Ban operation was not confirmed."), 1e4);
3165
3293
  this.banRequest = {
3166
- id: i,
3167
- resolve: n,
3168
- reject: r,
3169
- timer: a
3294
+ id: a,
3295
+ resolve: r,
3296
+ reject: i,
3297
+ timer: o
3170
3298
  };
3171
3299
  try {
3172
3300
  this.signal({
3173
3301
  type: e,
3174
3302
  id: t,
3175
- requestId: i
3303
+ requestId: a,
3304
+ ...e === "ban" && n !== void 0 ? { reason: n } : {}
3176
3305
  });
3177
3306
  } catch {
3178
3307
  this.rejectBan("Ban operation could not be sent.");
@@ -3187,9 +3316,9 @@ var Nt = class {
3187
3316
  lastHeartbeat = 0;
3188
3317
  controlId = 0;
3189
3318
  controlAssemblers = /* @__PURE__ */ new Map();
3190
- constructor(e, t, n, r = We()) {
3319
+ constructor(e, t, n, r = et()) {
3191
3320
  this.room = e, this.credentials = t, this.hooks = n, this.runtime = r;
3192
- let i = new URL(u.signal(e), Ue(r.serviceOrigin));
3321
+ let i = new URL(h.signal(e), Ze(r.serviceOrigin));
3193
3322
  i.protocol = i.protocol === "https:" ? "wss:" : "ws:", this.ws = r.createWebSocket(i), this.attachSocket(this.ws, () => {
3194
3323
  this.requestSentAt = performance.now(), this.signal({
3195
3324
  type: "hello",
@@ -3197,13 +3326,13 @@ var Nt = class {
3197
3326
  ...r.signalingResume ? { signalingVersion: 2 } : {}
3198
3327
  });
3199
3328
  }, 0), this.timer = setInterval(() => {
3200
- !this.resumeGrant && this.signalingAdmitted && this.ws.readyState === Ft && performance.now() - this.lastHeartbeat >= 3e4 && (this.signal({ type: "heartbeat" }), this.lastHeartbeat = performance.now());
3329
+ !this.resumeGrant && this.signalingAdmitted && this.ws.readyState === Gt && performance.now() - this.lastHeartbeat >= 3e4 && (this.signal({ type: "heartbeat" }), this.lastHeartbeat = performance.now());
3201
3330
  for (let e of this.peers.values()) {
3202
3331
  if (!e.connected && performance.now() - e.created > 2e4) {
3203
- n.status("Direct connection failed. This network pair may require a relay; this game does not use TURN."), this.remove(e.id);
3332
+ n.status("Could not connect directly to this room. Try another network or room.", "error"), this.remove(e.id);
3204
3333
  continue;
3205
3334
  }
3206
- e.lostAt !== void 0 && (performance.now() - e.lostAt > 2e4 ? (n.status("The direct connection could not be recovered. Rejoin the room."), this.remove(e.id)) : this.host && performance.now() - e.lastRestart > 5e3 && this.restartPeer(e.id));
3335
+ e.lostAt !== void 0 && (performance.now() - e.lostAt > 2e4 ? (n.status("The direct connection could not be recovered. Rejoin the room.", "error"), this.remove(e.id)) : this.host && performance.now() - e.lastRestart > 5e3 && this.restartPeer(e.id));
3207
3336
  }
3208
3337
  }, 5e3);
3209
3338
  }
@@ -3215,7 +3344,7 @@ var Nt = class {
3215
3344
  i() && (this.signalQueue = this.signalQueue.then(async () => {
3216
3345
  i() && await this.message(JSON.parse(e.data), r);
3217
3346
  }).catch(() => {
3218
- i() && this.hooks.status("Connection negotiation failed. Try another room or network.");
3347
+ i() && this.hooks.status("Connection negotiation failed. Try another room or network.", "error");
3219
3348
  }));
3220
3349
  }, e.onclose = (e) => {
3221
3350
  if (i()) {
@@ -3224,7 +3353,7 @@ var Nt = class {
3224
3353
  1008,
3225
3354
  1009
3226
3355
  ].includes(e.code)) {
3227
- this.recovery.disconnected(n), this.hooks.status("Signaling interrupted. Reconnecting…");
3356
+ this.recovery.disconnected(n), this.hooks.status("Signaling interrupted. Reconnecting…", "info");
3228
3357
  return;
3229
3358
  }
3230
3359
  if (!this.id || this.recovery || [
@@ -3235,10 +3364,10 @@ var Nt = class {
3235
3364
  this.close(), this.hooks.ended?.(e.reason || "Room connection ended.");
3236
3365
  return;
3237
3366
  }
3238
- this.hooks.status(e.reason || "Signaling disconnected. Established matches can continue; new joins are unavailable.");
3367
+ this.hooks.status(e.reason || "Signaling disconnected. Established matches can continue; new joins are unavailable.", "error");
3239
3368
  }
3240
3369
  }, e.onerror = () => {
3241
- i() && this.hooks.status("Room service is unavailable.");
3370
+ i() && this.hooks.status("Room service is unavailable.", "error");
3242
3371
  };
3243
3372
  }
3244
3373
  startRecovery(e) {
@@ -3247,7 +3376,7 @@ var Nt = class {
3247
3376
  this.close(), this.hooks.ended?.("Room membership expired.");
3248
3377
  return;
3249
3378
  }
3250
- this.resumeGrant = e, this.recovery = new pt({
3379
+ this.resumeGrant = e, this.recovery = new Ct({
3251
3380
  now: () => performance.now(),
3252
3381
  setTimer: (e, t) => setTimeout(e, t),
3253
3382
  clearTimer: (e) => clearTimeout(e),
@@ -3255,7 +3384,7 @@ var Nt = class {
3255
3384
  newAttemptId: () => crypto.randomUUID(),
3256
3385
  createAttempt: (e, t) => {
3257
3386
  this.resumeAttempt = e;
3258
- let n = new URL(u.signal(this.room), Ue(this.runtime.serviceOrigin));
3387
+ let n = new URL(h.signal(this.room), Ze(this.runtime.serviceOrigin));
3259
3388
  n.protocol = n.protocol === "https:" ? "wss:" : "ws:";
3260
3389
  let r = this.runtime.createWebSocket(n);
3261
3390
  return this.ws = r, this.attachSocket(r, () => {
@@ -3281,12 +3410,16 @@ var Nt = class {
3281
3410
  }, t), this.scheduleHeartbeat(t, !0);
3282
3411
  }
3283
3412
  signal(e) {
3284
- !this.closed && this.signalingAdmitted && this.ws.readyState === Ft && this.ws.send(JSON.stringify(e));
3413
+ !this.closed && this.signalingAdmitted && this.ws.readyState === Gt && this.ws.send(JSON.stringify(e));
3285
3414
  }
3286
3415
  async message(e, t = this.socketSerial) {
3287
3416
  if (this.closed || t !== this.socketSerial) return;
3417
+ if (e.type === "terminal") {
3418
+ this.close(), this.hooks.ended?.(typeof e.reason == "string" && e.reason.length <= 123 ? e.reason : "Room connection ended.");
3419
+ return;
3420
+ }
3288
3421
  if (e.type === "resumed") {
3289
- let n = wt(e), r = this.resumeGrant, i = this.resumeAttempt;
3422
+ let n = Pt(e), r = this.resumeGrant, i = this.resumeAttempt;
3290
3423
  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;
3291
3424
  let a = Math.floor(n.membershipValidForMs - (performance.now() - this.requestSentAt));
3292
3425
  if (a <= 0 || !this.recovery.acknowledge(i.epoch, a)) return;
@@ -3294,7 +3427,7 @@ var Nt = class {
3294
3427
  ...r,
3295
3428
  connectionEpoch: n.connectionEpoch,
3296
3429
  membershipValidForMs: a
3297
- }, 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.");
3430
+ }, 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.", "info");
3298
3431
  return;
3299
3432
  }
3300
3433
  if (e.type === "heartbeat" && this.resumeGrant && this.recovery) {
@@ -3306,7 +3439,7 @@ var Nt = class {
3306
3439
  }
3307
3440
  if (this.recovery && !this.signalingAdmitted) return;
3308
3441
  if (e.type === "roster" && this.resumeGrant) {
3309
- let n = Dt(e);
3442
+ let n = Lt(e);
3310
3443
  if (!n || n.roomGeneration !== this.resumeGrant.roomGeneration || n.hostId !== this.hostId || n.rosterRevision <= this.rosterRevision) return;
3311
3444
  let r = n.members.find((e) => e.id === this.id);
3312
3445
  if (!r?.attached || r.connectionEpoch !== this.resumeGrant.connectionEpoch || r.role === "host" !== this.host) {
@@ -3338,7 +3471,7 @@ var Nt = class {
3338
3471
  siteKey: e.siteKey,
3339
3472
  roomId: this.room
3340
3473
  }, t.signal);
3341
- if (t.signal.aborted || this.closed || this.ws.readyState !== Ft) return;
3474
+ if (t.signal.aborted || this.closed || this.ws.readyState !== Gt) return;
3342
3475
  if (typeof n != "string" || n.length === 0 || n.length > 2048) throw Error("Invalid verification response.");
3343
3476
  this.requestSentAt = performance.now(), this.signal({
3344
3477
  type: "hello",
@@ -3354,7 +3487,7 @@ var Nt = class {
3354
3487
  return;
3355
3488
  }
3356
3489
  if (e.type === "passwordUpgradeRequired" && this.host) {
3357
- this.hooks.status("Update the room password or explicitly unlock it to allow new guests.");
3490
+ this.hooks.status("Update the room password or explicitly unlock it to allow new guests.", "error");
3358
3491
  return;
3359
3492
  }
3360
3493
  if (e.type === "passwordUpdated" && e.ok === !1 && this.passwordRequest?.id === e.requestId) {
@@ -3377,7 +3510,7 @@ var Nt = class {
3377
3510
  if (e.type === "ready") {
3378
3511
  if (this.id) return;
3379
3512
  if (this.runtime.signalingResume && e.resumeGrant !== void 0) {
3380
- let t = Tt(e);
3513
+ let t = Ft(e);
3381
3514
  if (!t) {
3382
3515
  this.close(), this.hooks.ended?.("Invalid room admission.");
3383
3516
  return;
@@ -3390,7 +3523,7 @@ var Nt = class {
3390
3523
  }
3391
3524
  if (e.type === "peer" || e.type === "leave") {
3392
3525
  if (this.resumeGrant) {
3393
- if (!It(e.id) || !Lt(e.connectionEpoch) || typeof e.rosterRevision != "number" || !Number.isSafeInteger(e.rosterRevision) || e.rosterRevision <= this.rosterRevision || e.id === this.id) return;
3526
+ if (!Kt(e.id) || !qt(e.connectionEpoch) || typeof e.rosterRevision != "number" || !Number.isSafeInteger(e.rosterRevision) || e.rosterRevision <= this.rosterRevision || e.id === this.id) return;
3394
3527
  let t = this.members.get(e.id);
3395
3528
  if (t && e.connectionEpoch < t.connectionEpoch) return;
3396
3529
  this.rosterRevision = e.rosterRevision, e.type === "peer" ? this.members.set(e.id, {
@@ -3407,23 +3540,23 @@ var Nt = class {
3407
3540
  this.host && !this.peers.has(e.id) && await this.offerPeer(e.id, t);
3408
3541
  return;
3409
3542
  }
3410
- if (e.type !== "signal" || this.resumeGrant && (!It(e.negotiationId) || e.toConnectionEpoch !== this.resumeGrant.connectionEpoch || e.fromConnectionEpoch !== this.members.get(e.from)?.connectionEpoch || !this.members.get(e.from)?.attached)) return;
3543
+ if (e.type !== "signal" || this.resumeGrant && (!Kt(e.negotiationId) || e.toConnectionEpoch !== this.resumeGrant.connectionEpoch || e.fromConnectionEpoch !== this.members.get(e.from)?.connectionEpoch || !this.members.get(e.from)?.attached)) return;
3411
3544
  let n = this.peers.get(e.from);
3412
3545
  if (!n) {
3413
3546
  if (this.host || e.from !== this.hostId || !["offer", "candidate"].includes(e.signal.type)) return;
3414
3547
  n = this.make(e.from);
3415
3548
  }
3416
3549
  if (this.resumeGrant) {
3417
- if (!It(e.negotiationId)) return;
3550
+ if (!Kt(e.negotiationId)) return;
3418
3551
  if (e.signal.type === "offer") {
3419
- if (this.host || !Rt(e.signal.sdp)) return;
3420
- n.negotiationId !== e.negotiationId && (n.candidates = []), this.beginNegotiation(n, e.negotiationId), n.remoteIceUfrag = Rt(e.signal.sdp), n.localIceUfrag = void 0;
3552
+ if (this.host || !Jt(e.signal.sdp)) return;
3553
+ n.negotiationId !== e.negotiationId && (n.candidates = []), this.beginNegotiation(n, e.negotiationId), n.remoteIceUfrag = Jt(e.signal.sdp), n.localIceUfrag = void 0;
3421
3554
  } else if (e.signal.type === "candidate" && !n.negotiationId && !this.host) this.beginNegotiation(n, e.negotiationId);
3422
3555
  else if (n.negotiationId !== e.negotiationId) return;
3423
3556
  if (n.negotiationLocalEpoch !== e.toConnectionEpoch || n.negotiationRemoteEpoch !== e.fromConnectionEpoch) return;
3424
3557
  if (e.signal.type === "answer") {
3425
- if (!Rt(e.signal.sdp)) return;
3426
- n.remoteIceUfrag = Rt(e.signal.sdp);
3558
+ if (!Jt(e.signal.sdp)) return;
3559
+ n.remoteIceUfrag = Jt(e.signal.sdp);
3427
3560
  }
3428
3561
  }
3429
3562
  let r = n, i = r.negotiationId, a = () => this.current(r) && t === this.socketSerial && this.signalingAdmitted && r.negotiationId === i && this.negotiationCurrent(r);
@@ -3434,7 +3567,7 @@ var Nt = class {
3434
3567
  sdp: e.signal.sdp
3435
3568
  }), !a() || (await this.flushCandidates(n, a), !a())) return;
3436
3569
  let t = await n.pc.createAnswer();
3437
- if (!a() || (n.localIceUfrag = Rt(t.sdp), await n.pc.setLocalDescription(t), !a())) return;
3570
+ if (!a() || (n.localIceUfrag = Jt(t.sdp), await n.pc.setLocalDescription(t), !a())) return;
3438
3571
  this.peerSignal(n, {
3439
3572
  type: "answer",
3440
3573
  sdp: this.localSdp(n)
@@ -3447,7 +3580,7 @@ var Nt = class {
3447
3580
  }), !a()) return;
3448
3581
  await this.flushCandidates(n, a), this.noteHealthy(n);
3449
3582
  } else if (e.signal.type === "candidate" && e.signal.candidate) {
3450
- if (this.resumeGrant && (!zt(e.signal.candidate) || n.remoteIceUfrag && zt(e.signal.candidate) !== n.remoteIceUfrag)) return;
3583
+ if (this.resumeGrant && (!Yt(e.signal.candidate) || n.remoteIceUfrag && Yt(e.signal.candidate) !== n.remoteIceUfrag)) return;
3451
3584
  if (!n.pc.remoteDescription) this.queueCandidate(n, e.signal.candidate);
3452
3585
  else try {
3453
3586
  await n.pc.addIceCandidate(e.signal.candidate);
@@ -3460,7 +3593,7 @@ var Nt = class {
3460
3593
  this.members = new Map(e.map((e) => [e.id, e])), this.rosterRevision = t;
3461
3594
  for (let e of [...this.peers.keys()]) this.members.has(e) || this.remove(e, !1);
3462
3595
  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(() => {
3463
- !this.closed && n === this.socketSerial && this.hooks.status("Connection negotiation failed.");
3596
+ !this.closed && n === this.socketSerial && this.hooks.status("Connection negotiation failed.", "error");
3464
3597
  });
3465
3598
  }
3466
3599
  negotiationCurrent(e) {
@@ -3489,7 +3622,7 @@ var Nt = class {
3489
3622
  maxRetransmits: 0
3490
3623
  })), this.resumeGrant && this.beginNegotiation(n, crypto.randomUUID());
3491
3624
  let r = n.negotiationId, i = () => this.current(n) && t === this.socketSerial && this.signalingAdmitted && n.negotiationId === r && this.negotiationCurrent(n), a = await n.pc.createOffer();
3492
- i() && (n.localIceUfrag = Rt(a.sdp), await n.pc.setLocalDescription(a), i() && this.peerSignal(n, {
3625
+ i() && (n.localIceUfrag = Jt(a.sdp), await n.pc.setLocalDescription(a), i() && this.peerSignal(n, {
3493
3626
  type: "offer",
3494
3627
  sdp: this.localSdp(n)
3495
3628
  }));
@@ -3511,32 +3644,32 @@ var Nt = class {
3511
3644
  noteHealthy(e) {
3512
3645
  if (!this.current(e) || e.pc.connectionState !== "connected" || !["connected", "completed"].includes(e.pc.iceConnectionState)) return;
3513
3646
  let t = e.lostAt !== void 0;
3514
- e.lostAt = void 0, e.restarts = 0, t && this.hooks.status("Direct connection restored.");
3647
+ e.lostAt = void 0, e.restarts = 0, t && this.hooks.status("Direct connection restored.", "info");
3515
3648
  }
3516
3649
  async flushCandidates(e, t = () => this.current(e)) {
3517
3650
  let n = e.candidates.splice(0);
3518
3651
  for (let r of n) {
3519
3652
  if (!t()) return;
3520
- if (!this.resumeGrant || e.remoteIceUfrag && zt(r) === e.remoteIceUfrag) try {
3653
+ if (!this.resumeGrant || e.remoteIceUfrag && Yt(r) === e.remoteIceUfrag) try {
3521
3654
  await e.pc.addIceCandidate(r);
3522
3655
  } catch {}
3523
3656
  }
3524
3657
  }
3525
3658
  async restartPeer(e) {
3526
3659
  let t = this.peers.get(e);
3527
- if (this.closed || !this.host || !t || t.restarting || t.restarts >= 2 || t.pc.signalingState !== "stable" || !this.signalingAdmitted || this.ws.readyState !== Ft) return !1;
3660
+ if (this.closed || !this.host || !t || t.restarting || t.restarts >= 2 || t.pc.signalingState !== "stable" || !this.signalingAdmitted || this.ws.readyState !== Gt) return !1;
3528
3661
  let n = this.socketSerial;
3529
3662
  this.resumeGrant && (this.beginNegotiation(t, crypto.randomUUID()), t.localIceUfrag = void 0, t.remoteIceUfrag = void 0, t.candidates = []);
3530
3663
  let r = t.negotiationId, i = () => this.current(t) && n === this.socketSerial && this.signalingAdmitted && t.negotiationId === r && this.negotiationCurrent(t);
3531
3664
  t.restarting = !0, t.lastRestart = performance.now(), t.lostAt ??= t.lastRestart, t.restarts++;
3532
3665
  try {
3533
3666
  let e = await t.pc.createOffer({ iceRestart: !0 });
3534
- return !i() || (t.localIceUfrag = Rt(e.sdp), await t.pc.setLocalDescription(e), !i()) ? !1 : (this.peerSignal(t, {
3667
+ return !i() || (t.localIceUfrag = Jt(e.sdp), await t.pc.setLocalDescription(e), !i()) ? !1 : (this.peerSignal(t, {
3535
3668
  type: "offer",
3536
3669
  sdp: this.localSdp(t)
3537
3670
  }), !0);
3538
3671
  } catch {
3539
- return !this.closed && this.peers.get(e) === t && this.hooks.status("Direct connection recovery is still pending."), !1;
3672
+ return !this.closed && this.peers.get(e) === t && this.hooks.status("Direct connection recovery is still pending.", "info"), !1;
3540
3673
  } finally {
3541
3674
  t.restarting = !1;
3542
3675
  }
@@ -3558,13 +3691,13 @@ var Nt = class {
3558
3691
  this.peers.set(e, n), t.onicecandidate = (e) => {
3559
3692
  if (!this.current(n) || !e.candidate || !this.signalingAdmitted) return;
3560
3693
  let t = e.candidate.toJSON();
3561
- (!this.resumeGrant || n.localIceUfrag && zt(t) === n.localIceUfrag) && this.peerSignal(n, {
3694
+ (!this.resumeGrant || n.localIceUfrag && Yt(t) === n.localIceUfrag) && this.peerSignal(n, {
3562
3695
  type: "candidate",
3563
3696
  candidate: t
3564
3697
  });
3565
3698
  }, t.ondatachannel = (e) => this.bind(n, e.channel);
3566
3699
  let r = () => {
3567
- this.closed || this.peers.get(e) !== n || (t.connectionState === "closed" ? (this.hooks.status("A peer disconnected."), this.remove(e)) : t.connectionState === "connected" && ["connected", "completed"].includes(t.iceConnectionState) ? this.noteHealthy(n) : (["failed", "disconnected"].includes(t.connectionState) || ["failed", "disconnected"].includes(t.iceConnectionState)) && (n.lostAt ??= performance.now(), this.hooks.status("Direct connection interrupted. Attempting recovery…")));
3700
+ this.closed || this.peers.get(e) !== n || (t.connectionState === "closed" ? (this.hooks.status("A peer disconnected.", "info"), this.remove(e)) : t.connectionState === "connected" && ["connected", "completed"].includes(t.iceConnectionState) ? this.noteHealthy(n) : (["failed", "disconnected"].includes(t.connectionState) || ["failed", "disconnected"].includes(t.iceConnectionState)) && (n.lostAt ??= performance.now(), this.hooks.status("Direct connection interrupted. Attempting recovery…", "info")));
3568
3701
  };
3569
3702
  return t.onconnectionstatechange = r, t.oniceconnectionstatechange = r, n;
3570
3703
  }
@@ -3578,10 +3711,10 @@ var Nt = class {
3578
3711
  return;
3579
3712
  }
3580
3713
  t.binaryType = "arraybuffer", t.label === "control" ? e.control = t : e.fast = t, t.onclose = () => {
3581
- !this.closed && this.peers.get(e.id) === e && (this.hooks.status("A peer closed its game channel."), this.remove(e.id));
3714
+ !this.closed && this.peers.get(e.id) === e && (this.hooks.status("A peer closed its game channel.", "info"), this.remove(e.id));
3582
3715
  }, t.onopen = () => {
3583
3716
  this.closed || this.peers.get(e.id) !== e || e.control?.readyState === "open" && e.fast?.readyState === "open" && !e.connected && (e.connected = !0, this.host && (e.admissionTimer = setTimeout(() => {
3584
- this.closed || this.peers.get(e.id) !== e || (this.hooks.status("A peer did not complete room admission."), this.remove(e.id));
3717
+ this.closed || this.peers.get(e.id) !== e || (this.hooks.status("A peer did not complete room admission.", "error"), this.remove(e.id));
3585
3718
  }, 1e4)), this.hooks.open(e));
3586
3719
  }, t.onmessage = (n) => {
3587
3720
  if (!(this.closed || this.peers.get(e.id) !== e)) {
@@ -3592,7 +3725,7 @@ var Nt = class {
3592
3725
  if (this.host && t && !this.hooks.allowStadiumUpload?.(e)) throw Error("Guest control size or permission");
3593
3726
  if (typeof n.data != "string" && !(n.data instanceof ArrayBuffer)) throw Error("Invalid control type");
3594
3727
  let r = this.controlAssemblers.get(e.id);
3595
- r || (r = new Nt(), this.controlAssemblers.set(e.id, r));
3728
+ r || (r = new Ut(), this.controlAssemblers.set(e.id, r));
3596
3729
  let i = r.push(n.data);
3597
3730
  if (i !== void 0) {
3598
3731
  if (this.host && t && (!i || typeof i != "object" || i.type !== "action" || i.action !== "customStadium")) throw Error("Invalid bulk action");
@@ -3601,7 +3734,7 @@ var Nt = class {
3601
3734
  } else if (n.data instanceof ArrayBuffer && n.data.byteLength <= 1200) this.hooks.fast(e, n.data);
3602
3735
  else throw Error();
3603
3736
  } catch {
3604
- this.hooks.status("Invalid peer message rejected."), this.remove(e.id);
3737
+ this.hooks.status("Invalid peer message rejected.", "error"), this.remove(e.id);
3605
3738
  }
3606
3739
  }
3607
3740
  };
@@ -3611,7 +3744,7 @@ var Nt = class {
3611
3744
  }
3612
3745
  control(e, t) {
3613
3746
  if (e.control?.readyState !== "open") return;
3614
- let n = Mt(t, this.controlId++), r = n.reduce((e, t) => e + (typeof t == "string" ? new TextEncoder().encode(t).length : t.byteLength), 0);
3747
+ let n = Ht(t, this.controlId++), r = n.reduce((e, t) => e + (typeof t == "string" ? new TextEncoder().encode(t).length : t.byteLength), 0);
3615
3748
  if (e.control.bufferedAmount + r > 1048576) {
3616
3749
  this.remove(e.id);
3617
3750
  return;
@@ -3636,7 +3769,7 @@ var Nt = class {
3636
3769
  }
3637
3770
  try {
3638
3771
  let t = await e.pc.getStats();
3639
- !this.closed && this.peers.get(e.id) === e && (e.rtt = Ot(t.values()));
3772
+ !this.closed && this.peers.get(e.id) === e && (e.rtt = Rt(t.values()));
3640
3773
  } catch {
3641
3774
  e.rtt = null;
3642
3775
  }
@@ -3646,16 +3779,22 @@ var Nt = class {
3646
3779
  }
3647
3780
  }
3648
3781
  }
3782
+ hostCloseTimer;
3649
3783
  remove(e, t = !0) {
3650
3784
  let n = this.peers.get(e);
3651
- n && (clearTimeout(n.admissionTimer), this.peers.delete(e), this.controlAssemblers.delete(e), n.pc.close(), this.host && t ? this.signal({
3785
+ if (n && (clearTimeout(n.admissionTimer), this.peers.delete(e), this.controlAssemblers.delete(e), n.pc.close(), this.host && t && this.signal({
3652
3786
  type: "evict",
3653
3787
  id: e
3654
- }) : this.host || this.close(), this.hooks.leave(e), this.host || this.hooks.ended?.("The host connection ended."));
3788
+ }), this.hooks.leave(e), !this.host)) {
3789
+ let e = () => {
3790
+ this.close(), this.hooks.ended?.("The host connection ended.");
3791
+ };
3792
+ this.signalingAdmitted && this.ws.readyState === Gt ? this.hostCloseTimer = setTimeout(e, 1e3) : e();
3793
+ }
3655
3794
  }
3656
3795
  close() {
3657
3796
  if (!this.closed) {
3658
- this.resumeGrant && this.signalingAdmitted && this.ws.readyState === Ft && this.signal({
3797
+ clearTimeout(this.hostCloseTimer), this.hostCloseTimer = void 0, this.resumeGrant && this.signalingAdmitted && this.ws.readyState === Gt && this.signal({
3659
3798
  type: "leave",
3660
3799
  connectionEpoch: this.resumeGrant.connectionEpoch
3661
3800
  }), 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");
@@ -3663,14 +3802,14 @@ var Nt = class {
3663
3802
  this.peers.clear(), this.controlAssemblers.clear();
3664
3803
  }
3665
3804
  }
3666
- }, Vt = 5;
3667
- function Ht(e, t) {
3805
+ }, Zt = 5;
3806
+ function Qt(e, t) {
3668
3807
  return e !== t && e - t >>> 0 < 2147483648;
3669
3808
  }
3670
- function Ut(e) {
3809
+ function $t(e) {
3671
3810
  if (e.byteLength !== 14) throw Error("Input length");
3672
3811
  let t = new DataView(e);
3673
- if (t.getUint8(0) !== 1 || t.getUint8(1) !== Vt || t.getUint8(6) > 31 || t.getUint8(7)) throw Error("Input format");
3812
+ if (t.getUint8(0) !== 1 || t.getUint8(1) !== Zt || t.getUint8(6) > 31 || t.getUint8(7)) throw Error("Input format");
3674
3813
  return {
3675
3814
  seq: t.getUint32(2, !0),
3676
3815
  keys: t.getUint8(6),
@@ -3678,7 +3817,7 @@ function Ut(e) {
3678
3817
  epoch: t.getUint16(12, !0)
3679
3818
  };
3680
3819
  }
3681
- function Wt(e, t, n = 0) {
3820
+ function en(e, t, n = 0) {
3682
3821
  if (e.surface?.length) throw Error("Terrain transport is not enabled");
3683
3822
  let r = [];
3684
3823
  for (let t = 0; t < e.discs.length / 18; t++) {
@@ -3700,11 +3839,11 @@ function Wt(e, t, n = 0) {
3700
3839
  let s = new Uint8Array(a), c = [], l = Math.ceil(s.length / 1188);
3701
3840
  for (let t = 0; t < l; t++) {
3702
3841
  let r = s.subarray(t * 1188, (t + 1) * 1188), i = new ArrayBuffer(12 + r.length), a = new DataView(i);
3703
- a.setUint8(0, 2), a.setUint8(1, Vt), a.setUint32(2, e.tick, !0), a.setUint8(6, t), a.setUint8(7, l), a.setUint16(8, n, !0), a.setUint16(10, r.length, !0), new Uint8Array(i, 12).set(r), c.push(i);
3842
+ a.setUint8(0, 2), a.setUint8(1, Zt), a.setUint32(2, e.tick, !0), a.setUint8(6, t), a.setUint8(7, l), a.setUint16(8, n, !0), a.setUint16(10, r.length, !0), new Uint8Array(i, 12).set(r), c.push(i);
3704
3843
  }
3705
3844
  return c;
3706
3845
  }
3707
- var Gt = Object.freeze({ ...De }), Kt = class e {
3846
+ var tn = Object.freeze({ ...Fe }), nn = class e {
3708
3847
  runtime;
3709
3848
  engine;
3710
3849
  network;
@@ -3712,6 +3851,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3712
3851
  roomLink = "";
3713
3852
  roomName = "";
3714
3853
  epoch = 0;
3854
+ kickStream = new be();
3715
3855
  stadiumSelection = 0;
3716
3856
  players = [];
3717
3857
  nextPlayerId = 0;
@@ -3730,7 +3870,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3730
3870
  locked = !1;
3731
3871
  teamStyles = [null, null];
3732
3872
  inputs = /* @__PURE__ */ new Map();
3733
- traffic = new Ye();
3873
+ traffic = new at();
3734
3874
  onRoomLink;
3735
3875
  onPlayerJoin;
3736
3876
  onPlayerTeamChange;
@@ -3773,18 +3913,18 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3773
3913
  constructor(e, t) {
3774
3914
  this.runtime = t, this.engine = e;
3775
3915
  }
3776
- static async create(t, n = qe(), r) {
3777
- let i = Ue(n.network.serviceOrigin);
3778
- if (t = Q(t), t.noPlayer !== void 0 && typeof t.noPlayer != "boolean") throw Error("Invalid noPlayer setting");
3779
- let a = t.noPlayer === !1, o = t.playerName ?? "Host";
3780
- if (a && (typeof o != "string" || !o.trim() || o.length > 24)) throw Error("Invalid host player name");
3781
- let s = me(r), c;
3916
+ static async create(t, n = rt(), r) {
3917
+ let i = Ze(n.network.serviceOrigin), a = Ze(n.publicOrigin ?? i);
3918
+ if (t = Ce(t), t.noPlayer !== void 0 && typeof t.noPlayer != "boolean") throw Error("Invalid noPlayer setting");
3919
+ let o = t.noPlayer === !1, s = t.playerName ?? "Host";
3920
+ if (o && (typeof s != "string" || !s.trim() || s.length > 24)) throw Error("Invalid host player name");
3921
+ let c = ve(r), l;
3782
3922
  try {
3783
- s.signal.throwIfAborted();
3784
- let r = await s.run(n.loadEngine(s.signal));
3785
- r.load(t.stadium ?? Re()), c = new e(r, n);
3786
- let l = c, d = await s.run(n.request(new URL(u.rooms, i), {
3787
- signal: s.signal,
3923
+ c.signal.throwIfAborted();
3924
+ let r = await c.run(n.loadEngine(c.signal));
3925
+ r.load(t.stadium ?? Ke()), l = new e(r, n);
3926
+ let u = l, d = await c.run(n.request(new URL(h.rooms, i), {
3927
+ signal: c.signal,
3788
3928
  method: "POST",
3789
3929
  headers: { "Content-Type": "application/json" },
3790
3930
  body: JSON.stringify({
@@ -3792,56 +3932,58 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3792
3932
  maxPlayers: t.maxPlayers ?? 16,
3793
3933
  password: t.password ?? "",
3794
3934
  private: t.public === !1,
3795
- hostPlayer: a
3935
+ hostPlayer: o
3796
3936
  })
3797
3937
  }));
3798
- if (!d.ok) throw Error(`Room creation failed (${d.status})`);
3799
- let f = await s.run(d.json());
3800
- l.roomId = f.id, l.roomName = t.roomName, l.roomLink = `${i}${_e(f.id)}`;
3938
+ if (!d.ok) throw await c.run(ye(d, c.signal));
3939
+ let f = await c.run(d.json());
3940
+ u.roomId = f.id, u.roomName = t.roomName, u.roomLink = `${a}${Te(f.id)}`;
3801
3941
  let p;
3802
3942
  try {
3803
- await s.run(new Promise((e, t) => {
3804
- p = setTimeout(() => t(Error("Signaling timed out")), 12e3), l.network = new Bt(f.id, { hostToken: f.hostToken }, {
3943
+ await c.run(new Promise((e, t) => {
3944
+ p = setTimeout(() => t(Error("Signaling timed out")), 12e3), u.network = new Xt(f.id, { hostToken: f.hostToken }, {
3805
3945
  ready: (n, r) => {
3806
3946
  if (!r) {
3807
3947
  t(Error("Host authority was not granted"));
3808
3948
  return;
3809
3949
  }
3810
- a && (l.players.push({
3811
- id: l.nextPlayerId++,
3950
+ o && (u.players.push({
3951
+ id: u.nextPlayerId++,
3812
3952
  slot: 0,
3813
3953
  peerId: n,
3814
- name: o.trim(),
3954
+ name: s.trim(),
3815
3955
  team: 0,
3816
3956
  admin: !0
3817
- }), l.engine.joinPlayer(0)), clearTimeout(p), e();
3957
+ }), u.engine.joinPlayer(0)), clearTimeout(p), e();
3818
3958
  },
3819
- allowStadiumUpload: (e) => !!l.players.find((t) => t.peerId === e.id)?.admin && ["lobby", "finished"].includes(l.engine.phase) && l.traffic.allow(e.id, "message"),
3959
+ allowStadiumUpload: (e) => !!u.players.find((t) => t.peerId === e.id)?.admin && ["lobby", "finished"].includes(u.engine.phase) && u.traffic.allow(e.id, "message"),
3820
3960
  open: () => {},
3821
- control: (e, t) => l.control(e, t),
3822
- fast: (e, t) => l.fast(e, t),
3823
- leave: (e) => l.leave(e),
3824
- status: (e) => l.report(e),
3961
+ control: (e, t) => u.control(e, t),
3962
+ fast: (e, t) => u.fast(e, t),
3963
+ leave: (e) => u.leave(e),
3964
+ status: (e, t) => {
3965
+ t === "error" && u.report(e);
3966
+ },
3825
3967
  ended: (e) => {
3826
- clearTimeout(p), t(Error(e)), l.close(), l.report(e);
3968
+ clearTimeout(p), t(Error(e)), u.close(), u.report(e);
3827
3969
  }
3828
3970
  }, n.network);
3829
3971
  }));
3830
3972
  } catch (e) {
3831
- throw l.close(), e;
3973
+ throw u.close(), e;
3832
3974
  } finally {
3833
3975
  clearTimeout(p);
3834
3976
  }
3835
- if (l.closed) throw Error("Room closed during startup");
3836
- l.last = performance.now(), l.loop = setInterval(() => l.advance(), 1e3 / 60);
3837
- let m = l.roomLink;
3838
- return l.linkNotification = setTimeout(() => {
3839
- l.linkNotification = void 0, l.invoke("onRoomLink", l.onRoomLink, m);
3840
- }, 0), c;
3977
+ if (u.closed) throw Error("Room closed during startup");
3978
+ u.last = performance.now(), u.loop = setInterval(() => u.advance(), 1e3 / 60);
3979
+ let m = u.roomLink;
3980
+ return u.linkNotification = setTimeout(() => {
3981
+ u.linkNotification = void 0, u.invoke("onRoomLink", u.onRoomLink, m);
3982
+ }, 0), l;
3841
3983
  } catch (e) {
3842
- throw c?.close(), e;
3984
+ throw l?.close(), e;
3843
3985
  } finally {
3844
- s.dispose();
3986
+ c.dispose();
3845
3987
  }
3846
3988
  }
3847
3989
  advance() {
@@ -3857,30 +3999,29 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3857
3999
  }
3858
4000
  if (this.recorder && !this.recorder.canRecord(this.engine) && this.finishRecording("Recording limit reached"), this.closed || (this.engine.phase !== "lobby" && !this.engine.paused && !this.engine.resumeTicks && this.invoke("onGameTick", this.onGameTick), this.closed)) break;
3859
4001
  let t = this.engine.red, n = this.engine.blue, r = this.engine.phase;
3860
- this.engine.step(), this.recorder?.step(this.engine), this.engine.phase !== r && this.state();
3861
- let i = r === "goal" && this.engine.phase === "playing";
3862
- r === "finished" && this.engine.phase === "lobby" && this.invoke("onGameStop", this.onGameStop, null);
3863
- let a = this.engine.ballKicks.map((e) => {
4002
+ this.engine.step(), this.kickStream.capture(this.engine, this.epoch), this.recorder?.step(this.engine), this.engine.phase !== r && this.state();
4003
+ let i = r === "goal" && this.engine.phase === "playing", a = r === "finished" && this.engine.phase === "lobby", o = this.engine.red > t, s = this.engine.blue > n, c = this.engine.ballKicks.map((e) => {
3864
4004
  let t = this.players.find((t) => t.slot === e);
3865
4005
  return t ? this.playerCopy(t) : null;
3866
- }).filter((e) => !!e), o = r !== "finished" && this.engine.phase === "finished" ? this.getScores() : null;
3867
- o && (this.invoke("onTeamVictory", this.onTeamVictory, { ...o }), this.invoke("onGameVictory", this.onGameVictory, { ...o }));
3868
- for (let e of a) this.invoke("onPlayerBallKick", this.onPlayerBallKick, e);
3869
- 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;
4006
+ }).filter((e) => !!e), l = r !== "finished" && this.engine.phase === "finished" ? this.getScores() : null;
4007
+ a && this.invoke("onGameStop", this.onGameStop, null), l && (this.invoke("onTeamVictory", this.onTeamVictory, { ...l }), this.invoke("onGameVictory", this.onGameVictory, { ...l }));
4008
+ for (let e of c) this.invoke("onPlayerBallKick", this.onPlayerBallKick, e);
4009
+ if (o && this.invoke("onTeamGoal", this.onTeamGoal, 1), s && this.invoke("onTeamGoal", this.onTeamGoal, 2), i && this.invoke("onPositionsReset", this.onPositionsReset), this.closed) break;
3870
4010
  if (this.engine.tick % 2 == 0) {
3871
4011
  let e = this.engine.snapshot();
3872
4012
  if (e.surface?.length) {
3873
4013
  if (this.engine.tick % 6 == 0) {
3874
- let t = pe(e, this.epoch);
4014
+ let t = _e(e, this.epoch);
3875
4015
  for (let e of this.network.peers.values()) e.control?.readyState === "open" && e.control.bufferedAmount < 65536 && this.network.control(e, {
3876
4016
  ...t,
3877
4017
  ack: this.inputs.get(e.id)?.seq ?? 0
3878
4018
  });
3879
4019
  }
3880
- } else for (let t of this.network.peers.values()) for (let n of Wt(e, this.inputs.get(t.id)?.seq ?? 0, this.epoch)) this.network.fast(t, n);
4020
+ } else for (let t of this.network.peers.values()) for (let n of en(e, this.inputs.get(t.id)?.seq ?? 0, this.epoch)) this.network.fast(t, n);
3881
4021
  }
3882
4022
  this.accumulator -= 1e3 / 60;
3883
4023
  }
4024
+ this.closed || xe(this.network, this.kickStream.drain(e));
3884
4025
  } catch (e) {
3885
4026
  this.closed || (this.engine.setPaused(!0), this.report(String(e)));
3886
4027
  }
@@ -3892,7 +4033,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3892
4033
  if (!this.allowed(e) || !t || typeof t != "object") return;
3893
4034
  let n = t, r = this.players.find((t) => t.peerId === e.id);
3894
4035
  if (n.type === "join" && !r) {
3895
- if (n.version !== 1 || n.engine !== ze || typeof n.name != "string" || !n.name.trim() || n.name.length > 24) {
4036
+ if (n.version !== 1 || n.engine !== qe || typeof n.name != "string" || !n.name.trim() || n.name.length > 24) {
3896
4037
  this.network.remove(e.id);
3897
4038
  return;
3898
4039
  }
@@ -3910,9 +4051,10 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3910
4051
  admin: !1
3911
4052
  }, this.players.push(r), this.network.admit(e), this.recorder?.player(this.engine.tick, r.slot, r.name), this.command("join", t, 0), this.network.control(e, {
3912
4053
  type: "welcome",
4054
+ kickStream: this.kickStream.checkpoint(),
3913
4055
  epoch: this.epoch,
3914
4056
  roomName: this.roomName,
3915
- engine: ze,
4057
+ engine: qe,
3916
4058
  slot: t,
3917
4059
  stadium: this.engine.source,
3918
4060
  state: this.engine.snapshot(),
@@ -3932,17 +4074,13 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3932
4074
  });
3933
4075
  }
3934
4076
  if (n.action === "chat" || this.traffic.allow(e.id, "action")) {
3935
- if (n.action === "avatar" && Se(n.avatar)) {
4077
+ if (n.action === "avatar" && Ae(n.avatar)) {
3936
4078
  r.avatar = n.avatar, this.recorder?.player(this.engine.tick, r.slot, r.name, r.avatarOverride ?? r.avatar), this.sync();
3937
4079
  return;
3938
4080
  }
3939
- if (n.action === "team" && (!this.locked || r.admin) && [
3940
- 0,
3941
- 1,
3942
- 2
3943
- ].includes(Number(n.team))) {
4081
+ if (n.action === "team" && l(n.team)) {
3944
4082
  let e = n.slot === void 0 ? r : this.players.find((e) => e.slot === n.slot);
3945
- e && (e === r || r.admin) && this.changeTeam(e.id, Number(n.team), r);
4083
+ f(r, e, this.locked) && this.changeTeam(e.id, n.team, r);
3946
4084
  }
3947
4085
  if (n.action === "defaultStadium" || n.action === "customStadium") {
3948
4086
  let t = (t) => {
@@ -3971,7 +4109,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3971
4109
  if (r.admin) {
3972
4110
  if (n.action === "mute" && typeof n.muted == "boolean") {
3973
4111
  let e = this.players.find((e) => e.slot === n.slot);
3974
- e && e !== r && e.peerId !== this.network.hostId && this.changePlayerMuted(e.id, n.muted, this.playerCopy(r));
4112
+ p(r, e, (e) => e.peerId === this.network.hostId) && this.changePlayerMuted(e.id, n.muted, this.playerCopy(r));
3975
4113
  return;
3976
4114
  }
3977
4115
  if (n.action === "surface" && typeof n.enabled == "boolean" && ["lobby", "finished"].includes(this.engine.phase)) {
@@ -3980,7 +4118,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3980
4118
  }
3981
4119
  if (n.action === "ban" || n.action === "clearBans") {
3982
4120
  let t = this.players.find((e) => e.slot === n.slot);
3983
- if (n.action === "ban" && (!t || t === r || t.peerId === this.network.hostId)) return;
4121
+ if (n.action === "ban" && !p(r, t, (e) => e.peerId === this.network.hostId)) return;
3984
4122
  let i = (t) => {
3985
4123
  !this.closed && this.network.peers.has(e.id) && this.network.control(e, {
3986
4124
  type: "moderationResult",
@@ -3997,25 +4135,25 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
3997
4135
  }
3998
4136
  if (n.action === "teamColors" && (n.team === 1 || n.team === 2)) {
3999
4137
  let e = n.palette;
4000
- this.changeTeamColors(n.team, e === null ? null : ve(e.angle, e.textColor, e.colors));
4138
+ this.changeTeamColors(n.team, e === null ? null : Ee(e.angle, e.textColor, e.colors));
4001
4139
  }
4002
4140
  if (n.action === "kickRate" && Number.isInteger(n.value) && Number(n.value) >= 0 && Number(n.value) <= 6619135) {
4003
4141
  let e = Number(n.value);
4004
4142
  this.changeKickRateLimit(e & 255, e >>> 8 & 255, e >>> 16, this.playerCopy(r));
4005
4143
  }
4006
4144
  if (n.action === "start" && this.beginGame(r), n.action === "stop" && this.endGame(r), n.action === "pause" && (n.paused === void 0 || typeof n.paused == "boolean") && this.changePause(n.paused === void 0 ? !this.engine.paused : n.paused, this.playerCopy(r)), n.action === "settings" && ["lobby", "finished"].includes(this.engine.phase)) {
4007
- let e = Number(n.score), t = Number(n.minutes);
4008
- if (Number.isInteger(e) && e >= 0 && e <= 99 && Number.isInteger(t) && t >= 0 && t <= 99 && (n.kickRate === void 0 || Number.isInteger(n.kickRate) && Number(n.kickRate) >= 0 && Number(n.kickRate) <= 6619135)) {
4009
- if (this.setScoreLimit(e), this.setTimeLimit(t), this.changeTeamsLock(!!n.locked, this.playerCopy(r)), this.closed) return;
4010
- if (n.kickRate !== void 0 && n.kickRate !== this.engine.kickRate) {
4011
- let e = Number(n.kickRate);
4012
- this.changeKickRateLimit(e & 255, e >>> 8 & 255, e >>> 16, this.playerCopy(r));
4145
+ let e = d(n);
4146
+ if (e) {
4147
+ if (this.setScoreLimit(e.score), this.setTimeLimit(e.minutes), this.changeTeamsLock(e.locked, this.playerCopy(r)), this.closed) return;
4148
+ if (e.kickRate !== void 0 && e.kickRate !== this.engine.kickRate) {
4149
+ let t = e.kickRate;
4150
+ this.changeKickRateLimit(t & 255, t >>> 8 & 255, t >>> 16, this.playerCopy(r));
4013
4151
  }
4014
4152
  }
4015
4153
  }
4016
- if (n.action === "kick" && typeof n.slot == "number" && n.slot !== r.slot) {
4154
+ if (n.action === "kick" && typeof n.slot == "number") {
4017
4155
  let e = this.players.find((e) => e.slot === n.slot);
4018
- e && this.removePlayer(e.id, "Removed by host", this.playerCopy(r));
4156
+ p(r, e, (e) => e.peerId === this.network.hostId) && this.removePlayer(e.id, "Removed by host", this.playerCopy(r));
4019
4157
  }
4020
4158
  }
4021
4159
  }
@@ -4025,10 +4163,10 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4025
4163
  if (!this.allowed(e)) return;
4026
4164
  let n = this.players.find((t) => t.peerId === e.id);
4027
4165
  if (!n) return;
4028
- let r = Ut(t);
4166
+ let r = $t(t);
4029
4167
  if (r.epoch !== this.epoch) return;
4030
4168
  let i = this.inputs.get(e.id);
4031
- (!i || Ht(r.seq, i.seq)) && (this.inputs.set(e.id, {
4169
+ (!i || Qt(r.seq, i.seq)) && (this.inputs.set(e.id, {
4032
4170
  seq: r.seq,
4033
4171
  received: performance.now(),
4034
4172
  keys: r.keys
@@ -4043,7 +4181,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4043
4181
  value: n
4044
4182
  };
4045
4183
  if (this.recorder && (!this.recorder.canRecord(this.engine) || !this.recorder.command(r)) && this.finishRecording("Recording limit reached"), this.closed) throw Error("Room is closed");
4046
- ct(this.engine, r);
4184
+ vt(this.engine, r);
4047
4185
  }
4048
4186
  roster() {
4049
4187
  return this.players.map((e) => ({
@@ -4098,7 +4236,8 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4098
4236
  return t ? this.playerCopy(t) : null;
4099
4237
  }
4100
4238
  setTeamColors(e, t, n, r) {
4101
- this.changeTeamColors(e, ve(t, n, r));
4239
+ let i = Ee(t, n, r);
4240
+ i.angle = ((256 * t / 360 | 0) & 255) * (360 / 256), this.changeTeamColors(e, i);
4102
4241
  }
4103
4242
  changeTeamColors(e, t) {
4104
4243
  if (this.closed) throw Error("Room is closed");
@@ -4116,7 +4255,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4116
4255
  }
4117
4256
  setPlayerAvatar(e, t) {
4118
4257
  if (this.closed) throw Error("Room is closed");
4119
- if (!Se(t)) throw Error("Avatar must be null or at most two visible characters.");
4258
+ if (!Ae(t)) throw Error("Avatar must be null or at most two visible characters.");
4120
4259
  let n = this.players.find((t) => t.id === e);
4121
4260
  n && (n.avatarOverride = t, this.recorder?.player(this.engine.tick, n.slot, n.name, t ?? n.avatar), this.sync());
4122
4261
  }
@@ -4167,9 +4306,9 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4167
4306
  let i = this.playerCopy(r), a = t.slice(0, 100);
4168
4307
  if (this.bans.size >= 256 && !this.bans.has(e)) throw Error("Clear existing bans before adding more.");
4169
4308
  try {
4170
- await this.network.updateBan("ban", r.peerId);
4309
+ await this.network.updateBan("ban", r.peerId, a);
4171
4310
  } catch (t) {
4172
- throw t instanceof Pt && this.bans.set(e, r.peerId), t;
4311
+ throw t instanceof Wt && this.bans.set(e, r.peerId), t;
4173
4312
  }
4174
4313
  this.bans.set(e, r.peerId), this.network.remove(r.peerId), this.invoke("onPlayerKicked", this.onPlayerKicked, i, a, !0, n);
4175
4314
  }
@@ -4214,7 +4353,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4214
4353
  }
4215
4354
  sendAnnouncement(e, t, n, r, i) {
4216
4355
  if (this.closed) throw Error("Room is closed");
4217
- let a = xe(e, n, r, i);
4356
+ let a = ke(e, n, r, i);
4218
4357
  if (t != null && (!Number.isSafeInteger(t) || t < 0)) throw Error("Invalid announcement target");
4219
4358
  if (t == null) this.network.broadcast(a);
4220
4359
  else {
@@ -4256,7 +4395,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4256
4395
  }
4257
4396
  changeKickRateLimit(e, t, n, r) {
4258
4397
  if (this.closed) throw Error("Room is closed");
4259
- let i = He(e, t, n);
4398
+ let i = Xe(e, t, n);
4260
4399
  i !== this.engine.kickRate && (this.command("kickRate", 0, i), this.state(), this.invoke("onKickRateLimitSet", this.onKickRateLimitSet, i & 255, i >>> 8 & 255, i >>> 16, r));
4261
4400
  }
4262
4401
  async setPassword(e) {
@@ -4301,7 +4440,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4301
4440
  changeStadium(e, t) {
4302
4441
  if (this.closed) throw Error("Room is closed");
4303
4442
  if (!["lobby", "finished"].includes(this.engine.phase)) return;
4304
- Le(e);
4443
+ Ge(e);
4305
4444
  let n = ++this.stadiumSelection;
4306
4445
  if (this.recorder && this.finishRecording("Stadium changed"), this.closed) throw Error("Room is closed");
4307
4446
  if (["lobby", "finished"].includes(this.engine.phase)) {
@@ -4351,7 +4490,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4351
4490
  };
4352
4491
  }
4353
4492
  get CollisionFlags() {
4354
- return Gt;
4493
+ return tn;
4355
4494
  }
4356
4495
  getDiscCount() {
4357
4496
  return this.closed || this.engine.phase === "lobby" ? 0 : this.engine.stadium.discs.length + this.players.filter((e) => e.team !== 0).length;
@@ -4376,7 +4515,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4376
4515
  n && this.changeDisc(this.engine.index(n.slot), t);
4377
4516
  }
4378
4517
  changeDisc(e, t) {
4379
- let n = we(t), r = this.readDisc(e);
4518
+ let n = Me(t), r = this.readDisc(e);
4380
4519
  if (Object.entries(n).every(([e, t]) => r[e] === t)) return;
4381
4520
  let i = {
4382
4521
  tick: this.engine.tick,
@@ -4386,7 +4525,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4386
4525
  properties: n
4387
4526
  };
4388
4527
  if (this.recorder && (!this.recorder.canRecord(this.engine) || !this.recorder.command(i)) && this.finishRecording("Recording limit reached"), this.closed) throw Error("Room is closed");
4389
- ct(this.engine, i), this.state();
4528
+ vt(this.engine, i), this.state();
4390
4529
  }
4391
4530
  getPlayerDiscProperties(e) {
4392
4531
  if (this.closed || this.engine.phase === "lobby") return null;
@@ -4400,7 +4539,7 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4400
4539
  if (this.closed) throw Error("Room is closed");
4401
4540
  if (this.finishingRecording) throw Error("Recording completion is in progress");
4402
4541
  if (this.recorder) throw Error("Recording is already active");
4403
- this.recorder = new lt(this.engine, this.players.map((e) => ({
4542
+ this.recorder = new yt(this.engine, this.players.map((e) => ({
4404
4543
  slot: e.slot,
4405
4544
  name: e.name,
4406
4545
  avatar: e.avatarOverride ?? e.avatar
@@ -4430,11 +4569,11 @@ var Gt = Object.freeze({ ...De }), Kt = class e {
4430
4569
  }
4431
4570
  }
4432
4571
  };
4433
- function qt(e) {
4572
+ function rn(e) {
4434
4573
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("Room configuration must be an object");
4435
4574
  let t = { ...e }, n = t.maxPlayers ?? 12;
4436
4575
  if (typeof n != "number" || !Number.isFinite(n) || !Number.isInteger(n)) throw Error("maxPlayers must be a finite integer");
4437
- return Q({
4576
+ return Ce({
4438
4577
  ...t,
4439
4578
  roomName: t.roomName ?? "Headless Room",
4440
4579
  playerName: t.playerName ?? "Host",
@@ -4444,7 +4583,7 @@ function qt(e) {
4444
4583
  password: t.password ?? ""
4445
4584
  });
4446
4585
  }
4447
- var Jt = class {
4586
+ var an = class {
4448
4587
  onError;
4449
4588
  pending = [];
4450
4589
  active;
@@ -4498,19 +4637,19 @@ var Jt = class {
4498
4637
  this.active?.reject(e);
4499
4638
  for (let t of this.pending.splice(0)) t.reject(e);
4500
4639
  }
4501
- }, Yt = /* @__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(".");
4502
- function Xt(e, t) {
4640
+ }, on = /* @__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(".");
4641
+ function sn(e, t) {
4503
4642
  let n = Object.create(null);
4504
4643
  t && Object.defineProperty(n, "closed", {
4505
4644
  enumerable: !0,
4506
4645
  value: t
4507
4646
  });
4508
- let r = new Jt((t) => {
4647
+ let r = new an((t) => {
4509
4648
  let n = e.onError?.(String(t));
4510
4649
  n instanceof Promise && n.catch(() => {});
4511
4650
  });
4512
4651
  e.signal.addEventListener("abort", () => r.close(), { once: !0 }), e.signal.aborted && r.close();
4513
- for (let t of Yt) Object.defineProperty(n, t, {
4652
+ for (let t of on) Object.defineProperty(n, t, {
4514
4653
  enumerable: !0,
4515
4654
  value: (...n) => {
4516
4655
  try {
@@ -4594,19 +4733,19 @@ function Xt(e, t) {
4594
4733
  }
4595
4734
  }), Object.preventExtensions(n);
4596
4735
  }
4597
- function Zt(e) {
4598
- return ut(e);
4736
+ function cn(e) {
4737
+ return bt(e);
4599
4738
  }
4600
- function Qt(e) {
4739
+ function ln(e) {
4601
4740
  if (typeof e != "string") throw TypeError("Stadium source must be a string");
4602
- let t = Le(e);
4741
+ let t = Ge(e);
4603
4742
  return Object.freeze({
4604
4743
  name: t.name,
4605
4744
  canBeStored: t.canBeStored,
4606
4745
  warnings: Object.freeze([...t.warnings])
4607
4746
  });
4608
4747
  }
4609
- async function $t(e = {}, t = {}) {
4610
- return Xt(await Kt.create(qt(e), void 0, t.signal));
4748
+ async function un(e = {}, t = {}) {
4749
+ return sn(await nn.create(rn(e), void 0, t.signal));
4611
4750
  }
4612
- export { $t as createRoom, Zt as readReplay, Qt as validateStadium };
4751
+ export { un as createRoom, cn as readReplay, ln as validateStadium };