@minicode-dev/chat 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/README.md +25 -0
  2. package/dist/chunks/{BattleshipGameCard-CAWHxqJE.js → BattleshipGameCard-BFqA0cjT.js} +247 -246
  3. package/dist/chunks/{BattleshipGameCard-CAWHxqJE.js.map → BattleshipGameCard-BFqA0cjT.js.map} +1 -1
  4. package/dist/chunks/{ChatContext-CUiEAMKK.js → ChatContext-dty_KPDX.js} +2 -2
  5. package/dist/chunks/{ChatContext-CUiEAMKK.js.map → ChatContext-dty_KPDX.js.map} +1 -1
  6. package/dist/chunks/TanksGameCard-D0n-lzTs.js +1535 -0
  7. package/dist/chunks/TanksGameCard-D0n-lzTs.js.map +1 -0
  8. package/dist/chunks/TanksLiveGameCard-BmNRXP66.js +849 -0
  9. package/dist/chunks/TanksLiveGameCard-BmNRXP66.js.map +1 -0
  10. package/dist/chunks/WebRtcLab-B7xBlJy1.js +510 -0
  11. package/dist/chunks/WebRtcLab-B7xBlJy1.js.map +1 -0
  12. package/dist/chunks/{connect4Sounds-BDXQAvU1.js → connect4Sounds-BN7d_TM2.js} +654 -618
  13. package/dist/chunks/connect4Sounds-BN7d_TM2.js.map +1 -0
  14. package/dist/chunks/createLiveScene-CtYPcOPo.js +364 -0
  15. package/dist/chunks/createLiveScene-CtYPcOPo.js.map +1 -0
  16. package/dist/chunks/createPeerLink-qei05vpV.js +478 -0
  17. package/dist/chunks/createPeerLink-qei05vpV.js.map +1 -0
  18. package/dist/chunks/createTankScene-CV7Brxmt.js +685 -0
  19. package/dist/chunks/createTankScene-CV7Brxmt.js.map +1 -0
  20. package/dist/chunks/fx-BHsl4S_J.js +1470 -0
  21. package/dist/chunks/fx-BHsl4S_J.js.map +1 -0
  22. package/dist/chunks/gameStatus-Cu1Z8un9.js +69 -0
  23. package/dist/chunks/gameStatus-Cu1Z8un9.js.map +1 -0
  24. package/dist/chunks/signalFaults-Dv2YjjKy.js +36 -0
  25. package/dist/chunks/signalFaults-Dv2YjjKy.js.map +1 -0
  26. package/dist/chunks/tanksSounds-C99OD2xD.js +177 -0
  27. package/dist/chunks/tanksSounds-C99OD2xD.js.map +1 -0
  28. package/dist/index.js +1861 -1829
  29. package/dist/index.js.map +1 -1
  30. package/dist/styles.css +1 -1
  31. package/index.d.ts +61 -0
  32. package/package.json +1 -1
  33. package/dist/chunks/TanksGameCard-BEnXTz_J.js +0 -1705
  34. package/dist/chunks/TanksGameCard-BEnXTz_J.js.map +0 -1
  35. package/dist/chunks/connect4Sounds-BDXQAvU1.js.map +0 -1
  36. package/dist/chunks/createTankScene-BuliAxwR.js +0 -2150
  37. package/dist/chunks/createTankScene-BuliAxwR.js.map +0 -1
@@ -0,0 +1,1535 @@
1
+ import { _ as e, d as t, f as n, g as r, h as i, m as a, o, p as s, v as c, y as l } from "./connect4Sounds-BN7d_TM2.js";
2
+ import { t as u } from "./ChatContext-dty_KPDX.js";
3
+ import { c as d, f, l as p, t as m } from "./gameStatus-Cu1Z8un9.js";
4
+ import { t as h } from "./webglSupport-2WjPEPZ_.js";
5
+ import { a as g, i as _, n as v, o as y, r as b, t as ee } from "./tanksSounds-C99OD2xD.js";
6
+ import { memo as x, useCallback as S, useContext as C, useEffect as w, useRef as T, useState as E, useSyncExternalStore as D } from "react";
7
+ import { ChevronDown as te, Crosshair as O, Flag as ne, Layers as k, RotateCcw as re, Swords as ie, Video as A, Wind as ae, X as oe } from "lucide-react";
8
+ import { Fragment as j, jsx as M, jsxs as N } from "react/jsx-runtime";
9
+ // src/games/tanks/logic/selectors.js
10
+ var P = 2500;
11
+ function se(e) {
12
+ let t = new Float32Array(e.length);
13
+ for (let n = 0; n < e.length; n += 1) t[n] = e[n] / l;
14
+ return t;
15
+ }
16
+ function F(e) {
17
+ return {
18
+ x: e.x * P / l,
19
+ z: e.z * P / l
20
+ };
21
+ }
22
+ function ce(e) {
23
+ let t = new Float32Array(e.heights.length);
24
+ for (let n = 0; n < t.length; n += 1) t[n] = e.heights[n] / l;
25
+ return {
26
+ size: c / l,
27
+ grid: 81,
28
+ heights: t,
29
+ obstacles: e.obstacles.map((e) => ({
30
+ id: e.id,
31
+ kind: e.kind,
32
+ x: e.x / l,
33
+ z: e.z / l,
34
+ y: e.y / l,
35
+ w: e.w / l,
36
+ d: e.d / l,
37
+ h: e.h / l
38
+ })),
39
+ decor: e.decor.map((e) => ({
40
+ id: e.id,
41
+ kind: e.kind,
42
+ x: e.x / l,
43
+ z: e.z / l,
44
+ scale: e.scale / 100
45
+ })),
46
+ tanks: e.tanks.map((e) => ({
47
+ id: e.id,
48
+ x: e.x / l,
49
+ y: e.y / l,
50
+ z: e.z / l,
51
+ hullYaw: e.hullYaw,
52
+ yaw: e.yaw,
53
+ pitch: e.pitch,
54
+ hp: e.hp,
55
+ fuel: e.fuel / l,
56
+ ammo: { ...e.ammo },
57
+ alive: e.hp > 0
58
+ })),
59
+ wind: F(i(e.seed, e.ply)),
60
+ turnPlayerId: e.phase === "playing" ? e.players[e.turnIndex] : null
61
+ };
62
+ }
63
+ function I(t, n, { yaw: o, pitch: c, power: l, ammo: u, maxTicks: d = 600 } = {}) {
64
+ let f = t.players.indexOf(n);
65
+ return f >= 0 && [
66
+ [o, e.yaw],
67
+ [c, e.pitch],
68
+ [l, e.power]
69
+ ].every(([e, [t, n]]) => Number.isInteger(e) && e >= t && e <= n) && typeof u == "string" && Object.hasOwn(r, u) ? se(a(s(t.tanks[f], {
70
+ yaw: o,
71
+ pitch: c,
72
+ power: l,
73
+ ammo: u
74
+ }), {
75
+ wind: i(t.seed, t.ply),
76
+ heights: t.heights,
77
+ tanks: t.tanks,
78
+ obstacles: t.obstacles,
79
+ maxTicks: d
80
+ }).samples) : /* @__PURE__ */ new Float32Array();
81
+ }
82
+ // src/games/tanks/view.js
83
+ var L = 20, le = Object.freeze(["green", "red"]);
84
+ function R(e) {
85
+ let t = ce(e.logic), n = e.logic.players;
86
+ return {
87
+ ...t,
88
+ tanks: t.tanks.map((e) => ({
89
+ ...e,
90
+ color: le[n.indexOf(e.id)] ?? "green"
91
+ })),
92
+ activeId: t.turnPlayerId
93
+ };
94
+ }
95
+ var ue = (e) => ({
96
+ x: e.x / l,
97
+ y: e.y / l,
98
+ z: e.z / l
99
+ });
100
+ function de(e, t) {
101
+ let n = e.logic?.lastTurn;
102
+ if (!n || n.type !== "turn") return null;
103
+ let r = t?.tanks ?? [];
104
+ return {
105
+ tankId: n.playerId,
106
+ movePath: n.movePath.map(ue),
107
+ yaw: n.input.yaw,
108
+ pitch: n.input.pitch,
109
+ ammo: n.input.ammo,
110
+ shots: n.shots.map((e) => ({
111
+ role: e.role,
112
+ startMs: e.startTick * L,
113
+ samples: se(e.samples),
114
+ impact: {
115
+ ...ue(e.impact),
116
+ kind: e.impact.kind,
117
+ tankId: e.impact.tankId
118
+ },
119
+ radius: e.radius / l
120
+ })),
121
+ craters: n.craters.map((e) => ({
122
+ x: e.x / l,
123
+ z: e.z / l,
124
+ radius: e.radius / l,
125
+ depth: e.depth / l
126
+ })),
127
+ damage: { ...n.damage },
128
+ destroyed: e.logic.tanks.filter((e) => e.hp === 0 && (r.find((t) => t.id === e.id)?.hp ?? 1) > 0).map((e) => e.id),
129
+ world: R(e)
130
+ };
131
+ }
132
+ function fe(e, t, n) {
133
+ try {
134
+ return I(e.logic, t, n);
135
+ } catch {
136
+ return null;
137
+ }
138
+ }
139
+ function pe(e, t) {
140
+ return (Math.round(Math.atan2(t.z - e.z, t.x - e.x) * 180 / Math.PI) % 360 + 360) % 360;
141
+ }
142
+ var me = 60, he = 9, ge = 120, z = Math.PI / 180, B = 7, V = 4.4, _e = 100, H = {
143
+ green: {
144
+ hull: "#4f8a3c",
145
+ dark: "#2f5a24",
146
+ turret: "#6aa851"
147
+ },
148
+ red: {
149
+ hull: "#b8423a",
150
+ dark: "#7a2620",
151
+ turret: "#d45a4f"
152
+ }
153
+ }, ve = {
154
+ hull: "#2b2a28",
155
+ dark: "#151413",
156
+ turret: "#3a3835"
157
+ }, U = {
158
+ low: {
159
+ terrain: 2,
160
+ dpr: 1,
161
+ particles: .5
162
+ },
163
+ medium: {
164
+ terrain: 3,
165
+ dpr: 1.5,
166
+ particles: .75
167
+ },
168
+ high: {
169
+ terrain: 4,
170
+ dpr: 2,
171
+ particles: 1
172
+ }
173
+ }, W = [
174
+ [0, [
175
+ 52,
176
+ 96,
177
+ 48
178
+ ]],
179
+ [.25, [
180
+ 86,
181
+ 130,
182
+ 58
183
+ ]],
184
+ [.5, [
185
+ 128,
186
+ 134,
187
+ 72
188
+ ]],
189
+ [.68, [
190
+ 126,
191
+ 100,
192
+ 68
193
+ ]],
194
+ [.85, [
195
+ 128,
196
+ 124,
197
+ 118
198
+ ]],
199
+ [1, [
200
+ 190,
201
+ 188,
202
+ 182
203
+ ]]
204
+ ], G = (e, t, n) => Math.min(n, Math.max(t, e)), K = (e, t = 0) => Number.isFinite(e) ? e : t, q = (e) => e < .5 ? 2 * e * e : 1 - (-2 * e + 2) ** 2 / 2;
205
+ function J(e, t, n, { zoom: r = 1, cx: i, cz: a, pad: o = 8, origin: s = "corner" } = {}) {
206
+ let c = Math.max(1, K(n, 160)), l = c / 2, u = s === "corner" ? l : 0, d = Math.max(1, Math.min(e, t) - o * 2) / c * Math.max(1, K(r, 1)), f = (e, t) => t >= l ? u : G(K(e, u), u - l + t, u + l - t), p = f(i, e / 2 / d), m = f(a, t / 2 / d);
207
+ return {
208
+ scale: d,
209
+ ox: e / 2 - p * d,
210
+ oy: t / 2 - m * d,
211
+ size: c,
212
+ minX: u - l,
213
+ minZ: u - l
214
+ };
215
+ }
216
+ function Y(e, t, n) {
217
+ return {
218
+ x: n.ox + e * n.scale,
219
+ y: n.oy + t * n.scale
220
+ };
221
+ }
222
+ function ye(e) {
223
+ return {
224
+ x: Math.cos(e * z),
225
+ z: Math.sin(e * z)
226
+ };
227
+ }
228
+ function be(e) {
229
+ return e * z;
230
+ }
231
+ function xe(e, t) {
232
+ let n = ((t - e) % 360 + 540) % 360 - 180;
233
+ return n === -180 ? 180 : n;
234
+ }
235
+ function Se(e, t, n) {
236
+ return e + xe(e, t) * n;
237
+ }
238
+ function Ce(e, t, n, r) {
239
+ if (!e || t < 2) return 0;
240
+ let i = G(K(n), 0, t - 1), a = G(K(r), 0, t - 1), o = Math.min(t - 2, Math.floor(i)), s = Math.min(t - 2, Math.floor(a)), c = i - o, l = a - s, u = s * t + o, d = e[u] * (1 - c) + e[u + 1] * c, f = e[u + t] * (1 - c) + e[u + t + 1] * c;
241
+ return K(d * (1 - l) + f * l);
242
+ }
243
+ function X(e, t = 1) {
244
+ let n = G(K(e), 0, 1), r = 1;
245
+ for (; r < W.length - 1 && W[r][0] < n;) r += 1;
246
+ let [i, a] = W[r - 1], [o, s] = W[r], c = o > i ? (n - i) / (o - i) : 0;
247
+ return a.map((e, n) => G(Math.round((e + (s[n] - e) * c) * t), 0, 255));
248
+ }
249
+ function we(e, t, n, { size: r = 160, contourStep: i = 3 } = {}) {
250
+ let a = new Uint8ClampedArray(n * n * 4);
251
+ if (!e || t < 2 || n < 2) return a;
252
+ let o = Infinity, s = -Infinity;
253
+ for (let n = 0; n < t * t; n += 1) {
254
+ let t = K(e[n]);
255
+ t < o && (o = t), t > s && (s = t);
256
+ }
257
+ let c = s - o, l = (t - 1) / (n - 1), u = r / (t - 1), d = [
258
+ -.55,
259
+ .75,
260
+ -.55
261
+ ], f = Math.hypot(...d), p = (n, r) => Ce(e, t, n, r);
262
+ for (let e = 0; e < n; e += 1) for (let t = 0; t < n; t += 1) {
263
+ let r = t * l, s = e * l, m = p(r, s), h = p(r - .5, s), g = p(r + .5, s), _ = p(r, s - .5), v = p(r, s + .5), y = (g - h) / u, b = (v - _) / u, ee = Math.hypot(y, 1, b), x = G(.45 + .65 * ((-y * d[0] + d[1] - b * d[2]) / (ee * f)), .35, 1.2), S = (h + g + _ + v - 4 * m) / u;
264
+ if (x *= 1 - G(S * .6, 0, .35), i > 0 && c > i) {
265
+ let e = Math.floor(m / i);
266
+ (e !== Math.floor(g / i) || e !== Math.floor(v / i)) && (x *= .88);
267
+ }
268
+ let [C, w, T] = X(c > .001 ? (m - o) / c : .3, x), E = (e * n + t) * 4;
269
+ a[E] = C, a[E + 1] = w, a[E + 2] = T, a[E + 3] = 255;
270
+ }
271
+ return a;
272
+ }
273
+ function Te(e) {
274
+ let t = G(K(e), 0, 1), [n, r, i] = t < .5 ? [
275
+ [
276
+ 90,
277
+ 200,
278
+ 255
279
+ ],
280
+ [
281
+ 255,
282
+ 214,
283
+ 90
284
+ ],
285
+ t * 2
286
+ ] : [
287
+ [
288
+ 255,
289
+ 214,
290
+ 90
291
+ ],
292
+ [
293
+ 255,
294
+ 90,
295
+ 60
296
+ ],
297
+ (t - .5) * 2
298
+ ], a = n.map((e, t) => Math.round(e + (r[t] - e) * i));
299
+ return `rgb(${a[0]},${a[1]},${a[2]})`;
300
+ }
301
+ function Ee(e, t) {
302
+ let n = (e || []).filter((e) => e && Number.isFinite(e.x) && Number.isFinite(e.z));
303
+ if (!n.length) return null;
304
+ if (n.length === 1) return {
305
+ x: n[0].x,
306
+ y: K(n[0].y),
307
+ z: n[0].z,
308
+ heading: null
309
+ };
310
+ let r = [0];
311
+ for (let e = 1; e < n.length; e += 1) r.push(r[e - 1] + Math.hypot(n[e].x - n[e - 1].x, n[e].z - n[e - 1].z));
312
+ let i = r[r.length - 1], a = G(K(t), 0, 1) * i, o = 1;
313
+ for (; o < n.length - 1 && r[o] < a;) o += 1;
314
+ let s = n[o - 1], c = n[o], l = r[o] - r[o - 1], u = l > 0 ? G((a - r[o - 1]) / l, 0, 1) : 1, d = l > 0 ? Math.atan2(c.z - s.z, c.x - s.x) / z : null;
315
+ return {
316
+ x: s.x + (c.x - s.x) * u,
317
+ y: K(s.y) + (K(c.y) - K(s.y)) * u,
318
+ z: s.z + (c.z - s.z) * u,
319
+ heading: d
320
+ };
321
+ }
322
+ function De(e) {
323
+ let t = 0;
324
+ for (let n = 1; n < (e?.length || 0); n += 1) t += Math.hypot(e[n].x - e[n - 1].x, e[n].z - e[n - 1].z);
325
+ return t;
326
+ }
327
+ function Oe(e, t) {
328
+ let n = Math.floor((e?.length || 0) / 3);
329
+ if (!n) return null;
330
+ let r = G(K(t), 0, n - 1), i = Math.min(n - 2, Math.floor(r));
331
+ if (i < 0) return {
332
+ x: e[0],
333
+ y: e[1],
334
+ z: e[2]
335
+ };
336
+ let a = r - i, o = i * 3;
337
+ return {
338
+ x: e[o] + (e[o + 3] - e[o]) * a,
339
+ y: e[o + 1] + (e[o + 4] - e[o + 1]) * a,
340
+ z: e[o + 2] + (e[o + 5] - e[o + 2]) * a
341
+ };
342
+ }
343
+ function ke(e, t = 380) {
344
+ let n = 0, r = !1;
345
+ return (e || []).map((e, i) => {
346
+ let a = e || {}, o = Math.floor((a.samples?.length || 0) / 3), s = Number.isFinite(a.startMs) ? Math.max(0, a.startMs) : i ? n + t : 0, c = s + Math.max(0, o - 1) * 40, l = r && s > 0;
347
+ return a.impact?.kind === "split" && (r = !0), n = Math.max(n, c), {
348
+ shot: a,
349
+ index: i,
350
+ count: o,
351
+ startMs: s,
352
+ endMs: c,
353
+ bomblet: l
354
+ };
355
+ });
356
+ }
357
+ function Ae(e) {
358
+ if (!e) return null;
359
+ if (Array.isArray(e)) return e.filter((e) => e && Number.isFinite(e.x) && Number.isFinite(e.z)).map((e) => ({
360
+ x: e.x,
361
+ y: K(e.y),
362
+ z: e.z
363
+ }));
364
+ if (typeof e.length == "number") {
365
+ let t = [];
366
+ for (let n = 0; n + 2 < e.length; n += 3) t.push({
367
+ x: e[n],
368
+ y: e[n + 1],
369
+ z: e[n + 2]
370
+ });
371
+ return t;
372
+ }
373
+ return null;
374
+ }
375
+ function je(e, { reducedMotion: t = !1, onEvent: n, origin: r = "corner" } = {}) {
376
+ let i = typeof document < "u" ? document : null, a = typeof window < "u" ? window : null, o = i ? i.createElement("canvas") : null, s = null;
377
+ if (o) {
378
+ o.className = "tanks-scene-2d", o.style.cssText = "display:block;width:100%;height:100%;touch-action:none";
379
+ try {
380
+ e?.appendChild(o), s = o.getContext("2d");
381
+ } catch {
382
+ s = null;
383
+ }
384
+ }
385
+ let c = t ? 2 : 1, l = null, u = "high", d = "overview", f = null, p = null, m = {
386
+ heights: null,
387
+ grid: 0,
388
+ factor: 0,
389
+ canvas: null
390
+ }, h = [], g = [], _ = [], v = [], y = [], b = [], ee = [], x = null, S = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Set(), w = (e) => S.get(String(e)), T = /* @__PURE__ */ new Set(), E = 0, D = 0, te = 1, O = 0, ne = 0, k = !1, re = Promise.resolve(), ie = () => !!i?.hidden, A = (e, t) => {
391
+ try {
392
+ n?.({
393
+ type: e,
394
+ ...t
395
+ });
396
+ } catch {}
397
+ }, ae = () => U[u] || U.high, oe = () => {
398
+ let e = K(l?.size, 160);
399
+ if (d === "overview" || !l) return J(E, D, e, { origin: r });
400
+ let t = w(l.activeId) || j(l.activeId);
401
+ return J(E, D, e, {
402
+ origin: r,
403
+ zoom: 2,
404
+ cx: t?.x,
405
+ cz: t?.z
406
+ });
407
+ }, j = (e) => l?.tanks?.find((t) => String(t.id) === String(e)) || null, M = (e, t) => {
408
+ if (!l?.heights) return 0;
409
+ let n = K(l.size, 160), i = r === "corner" ? 0 : -n / 2, a = l.grid || Math.round(Math.sqrt(l.heights.length));
410
+ return Ce(l.heights, a, (e - i) / n * (a - 1), (t - i) / n * (a - 1));
411
+ }, N = () => T.size > 0 || g.length || _.length || v.length || y.length || b.length || !!(x && x.left > 0), P = () => {
412
+ O || k || ie() || !a?.requestAnimationFrame || (O = a.requestAnimationFrame(se));
413
+ };
414
+ function se(e) {
415
+ if (O = 0, k) return;
416
+ let t = ne ? G(e - ne, 0, 50) : 16;
417
+ ne = e, ce(t), Z(), N() && !ie() ? P() : ne = 0;
418
+ }
419
+ let F = (e, t) => new Promise((n) => {
420
+ k ? n() : (T.add({
421
+ elapsed: 0,
422
+ duration: Math.max(1, e / c),
423
+ step: t,
424
+ resolve: n
425
+ }), P());
426
+ });
427
+ function ce(e) {
428
+ T.forEach((t) => {
429
+ t.elapsed += e;
430
+ let n = Math.min(1, t.elapsed / t.duration);
431
+ try {
432
+ t.step?.(n, e);
433
+ } catch {}
434
+ n >= 1 && (T.delete(t), t.resolve());
435
+ });
436
+ let n = e / 1e3, r = l?.wind || {};
437
+ if (g = g.filter((t) => (t.life -= e, t.x += t.vx * n, t.z += t.vz * n, t.vx *= .94, t.vz *= .94, t.life > 0)), y = y.filter((t) => (t.life -= e, t.x += K(r.x) * .25 * n, t.z += K(r.z) * .25 * n, t.r += 1.2 * n, t.life > 0)), _ = _.filter((t) => (t.life -= e) > 0), v = v.filter((t) => (t.life -= e) > 0), b = b.filter((t) => (t.life -= e) > 0), x?.left > 0 && (x.left -= e, x.next -= e, x.next <= 0 && !t)) {
438
+ x.next = 450;
439
+ let e = w(x.id) || j(x.id);
440
+ e && (_.push({
441
+ x: e.x,
442
+ z: e.z,
443
+ r0: 3,
444
+ r1: 14,
445
+ life: 900,
446
+ max: 900,
447
+ color: "255,214,90"
448
+ }), I(e.x, e.z, 8, [
449
+ "#ffd65a",
450
+ "#ffffff",
451
+ "#7fd36b",
452
+ "#ff7a5c"
453
+ ], 14));
454
+ }
455
+ }
456
+ function I(e, t, n, r, i = 10) {
457
+ let a = Math.floor(me * ae().particles) - g.length;
458
+ for (let o = 0; o < Math.min(n, a); o += 1) {
459
+ let n = Math.random() * Math.PI * 2, a = i * (.4 + Math.random() * .8), s = 500 + Math.random() * 600;
460
+ g.push({
461
+ x: e,
462
+ z: t,
463
+ vx: Math.cos(n) * a,
464
+ vz: Math.sin(n) * a,
465
+ life: s,
466
+ max: s,
467
+ color: r[o % r.length],
468
+ size: .5 + Math.random() * .8
469
+ });
470
+ }
471
+ }
472
+ function L(e, t, n, r) {
473
+ let i = Math.max(2, K(n, 4));
474
+ _.push({
475
+ x: e,
476
+ z: t,
477
+ r0: i * .2,
478
+ r1: i * (r ? 1.8 : 1.2),
479
+ life: 700,
480
+ max: 700,
481
+ color: "255,190,90"
482
+ }), r && _.push({
483
+ x: e,
484
+ z: t,
485
+ r0: i * .5,
486
+ r1: i * 2.6,
487
+ life: 1100,
488
+ max: 1100,
489
+ color: "255,120,60"
490
+ }), v.push({
491
+ x: e,
492
+ z: t,
493
+ r: i * (r ? 1.6 : 1),
494
+ life: 220,
495
+ max: 220
496
+ }), I(e, t, r ? 30 : 16, [
497
+ "#ffd27a",
498
+ "#ff8a3c",
499
+ "#6b5a48",
500
+ "#3b332c"
501
+ ], r ? 22 : 14);
502
+ for (let n = 0; n < (r ? 6 : 3); n += 1) {
503
+ let n = 1200 + Math.random() * 800;
504
+ y.push({
505
+ x: e + (Math.random() - .5) * i,
506
+ z: t + (Math.random() - .5) * i,
507
+ r: i * .4,
508
+ life: n,
509
+ max: n
510
+ });
511
+ }
512
+ }
513
+ function le() {
514
+ let e = l?.heights;
515
+ if (!e || !i) return null;
516
+ let t = l.grid || Math.round(Math.sqrt(e.length)), n = ae().terrain;
517
+ if (m.canvas && m.heights === e && m.grid === t && m.factor === n) return m.canvas;
518
+ let r = Math.min(400, (t - 1) * n + 1), a = we(e, t, r, { size: K(l.size, 160) }), o = m.canvas && m.canvas.width === r ? m.canvas : i.createElement("canvas");
519
+ o.width = r, o.height = r;
520
+ let s = o.getContext("2d");
521
+ if (!s) return null;
522
+ let c = s.createImageData(r, r);
523
+ return c.data.set(a), s.putImageData(c, 0, 0), m = {
524
+ heights: e,
525
+ grid: t,
526
+ factor: n,
527
+ canvas: o
528
+ }, o;
529
+ }
530
+ function R(e, t, n, r, i) {
531
+ let a = Math.min(i, n / 2, r / 2);
532
+ s.beginPath(), s.moveTo(e + a, t), s.arcTo(e + n, t, e + n, t + r, a), s.arcTo(e + n, t + r, e, t + r, a), s.arcTo(e, t + r, e, t, a), s.arcTo(e, t, e + n, t, a), s.closePath();
533
+ }
534
+ function ue(e) {
535
+ (l.obstacles || []).forEach((t) => {
536
+ if (!Number.isFinite(t?.x) || !Number.isFinite(t?.z)) return;
537
+ let n = Math.max(2, K(t.w, 4) * e.scale), r = Math.max(2, K(t.d, 4) * e.scale), i = Y(t.x, t.z, e), a = G(K(t.h, 3) * e.scale * .25, 1, 10);
538
+ s.fillStyle = "rgba(0,0,0,0.35)", R(i.x - n / 2 + a, i.y - r / 2 + a, n, r, 3), s.fill(), s.fillStyle = t.kind === "wall" ? "#8d8a82" : t.kind === "crate" ? "#8a6a3e" : "#9a958a", R(i.x - n / 2, i.y - r / 2, n, r, 3), s.fill(), s.strokeStyle = "rgba(0,0,0,0.45)", s.lineWidth = 1, s.stroke();
539
+ });
540
+ }
541
+ function de(e) {
542
+ (l.decor || []).forEach((t) => {
543
+ if (!Number.isFinite(t?.x) || !Number.isFinite(t?.z)) return;
544
+ let n = Y(t.x, t.z, e), r = K(t.scale, 1);
545
+ if (t.kind === "tree") {
546
+ let t = Math.max(2, 1.6 * r * e.scale);
547
+ s.fillStyle = "rgba(0,0,0,0.3)", s.beginPath(), s.arc(n.x + t * .35, n.y + t * .35, t, 0, Math.PI * 2), s.fill(), s.fillStyle = "#2f6b2a", s.beginPath(), s.arc(n.x, n.y, t, 0, Math.PI * 2), s.fill(), s.fillStyle = "rgba(140,200,110,0.35)", s.beginPath(), s.arc(n.x - t * .3, n.y - t * .3, t * .45, 0, Math.PI * 2), s.fill();
548
+ } else {
549
+ let t = Math.max(1.5, .8 * r * e.scale);
550
+ s.fillStyle = "#7c7a74", s.beginPath(), s.arc(n.x, n.y, t, 0, Math.PI * 2), s.fill();
551
+ }
552
+ });
553
+ }
554
+ function fe(e) {
555
+ h.forEach((t) => {
556
+ let n = Y(t.x, t.z, e), r = Math.max(2, K(t.radius, 3) * e.scale), i = s.createRadialGradient(n.x, n.y, 0, n.x, n.y, r);
557
+ i.addColorStop(0, "rgba(25,20,15,0.6)"), i.addColorStop(.7, "rgba(45,35,25,0.35)"), i.addColorStop(1, "rgba(45,35,25,0)"), s.fillStyle = i, s.beginPath(), s.arc(n.x, n.y, r, 0, Math.PI * 2), s.fill();
558
+ });
559
+ }
560
+ function pe(e) {
561
+ if (!p || p.length < 2) return;
562
+ let t = 1, n = p.map((e) => {
563
+ let n = Math.max(0, e.y - M(e.x, e.z));
564
+ return t = Math.max(t, n), n;
565
+ });
566
+ s.save(), s.setLineDash([5, 4]), s.lineWidth = 2, s.lineCap = "round";
567
+ for (let r = 1; r < p.length; r += 1) {
568
+ let i = Y(p[r - 1].x, p[r - 1].z, e), a = Y(p[r].x, p[r].z, e);
569
+ s.strokeStyle = Te(n[r] / t), s.beginPath(), s.moveTo(i.x, i.y), s.lineTo(a.x, a.y), s.stroke();
570
+ }
571
+ s.setLineDash([]);
572
+ let r = Y(p[p.length - 1].x, p[p.length - 1].z, e);
573
+ s.strokeStyle = "rgba(255,255,255,0.9)", s.lineWidth = 1.5, s.beginPath(), s.arc(r.x, r.y, 5, 0, Math.PI * 2), s.stroke(), s.beginPath(), s.moveTo(r.x - 8, r.y), s.lineTo(r.x + 8, r.y), s.moveTo(r.x, r.y - 8), s.lineTo(r.x, r.y + 8), s.stroke(), s.restore();
574
+ }
575
+ function z(e, t) {
576
+ if (!Number.isFinite(e?.x) || !Number.isFinite(e?.z)) return;
577
+ let n = w(e.id) || e, r = String(e.id) === String(l.activeId), i = C.has(String(e.id)) || e.alive === !1, a = l.tanks.indexOf(e), o = i ? ve : H[e.color] || (a === 1 ? H.red : H.green), c = r && f && !w(e.id) && Number.isFinite(f.yaw) ? f.yaw : K(n.yaw, K(n.hullYaw)), u = Y(n.x, n.z, t), d = Math.max(14, B * t.scale), p = Math.max(9, V * t.scale);
578
+ r && !i && (s.strokeStyle = "rgba(255,255,255,0.75)", s.setLineDash([3, 3]), s.lineWidth = 1.5, s.beginPath(), s.arc(u.x, u.y, d * .85, 0, Math.PI * 2), s.stroke(), s.setLineDash([])), x && String(x.id) === String(e.id) && (s.strokeStyle = "rgba(255,214,90,0.9)", s.lineWidth = 3, s.beginPath(), s.arc(u.x, u.y, d, 0, Math.PI * 2), s.stroke()), s.save(), s.translate(u.x, u.y), s.save(), s.rotate(be(K(n.hullYaw))), s.fillStyle = "rgba(0,0,0,0.35)", R(-d / 2 + 2, -p / 2 + 2, d, p, 3), s.fill(), s.fillStyle = o.dark, R(-d / 2, -p / 2, d, p, 3), s.fill(), s.fillStyle = o.hull, R(-d / 2 + 1, -p / 2 + p * .2, d - 2, p * .6, 2), s.fill(), s.restore(), s.rotate(be(c)), s.strokeStyle = o.dark, s.lineWidth = Math.max(2, p * .22), s.lineCap = "round", s.beginPath(), s.moveTo(0, 0), s.lineTo(d * .85, 0), s.stroke(), s.fillStyle = o.turret, s.beginPath(), s.arc(0, 0, p * .36, 0, Math.PI * 2), s.fill(), s.strokeStyle = "rgba(0,0,0,0.5)", s.lineWidth = 1, s.stroke(), s.restore();
579
+ let m = K(e.maxHp, K(l.maxHp, _e)) || _e, h = G(K(e.hp, m) / m, 0, 1), g = Math.max(24, d * 1.1), _ = u.y - d * .9 - 6;
580
+ s.fillStyle = "rgba(0,0,0,0.6)", s.fillRect(u.x - g / 2 - 1, _ - 1, g + 2, 6), s.fillStyle = i ? "#555" : h > .5 ? "#6bd35b" : h > .25 ? "#f2c14e" : "#f05a4f", s.fillRect(u.x - g / 2, _, g * h, 4);
581
+ }
582
+ function W(e, { samples: t, f: n }) {
583
+ let r = Oe(t, n);
584
+ if (!r) return;
585
+ let i = Math.max(0, Math.floor(n) - 18);
586
+ s.lineCap = "round";
587
+ let a = null;
588
+ for (let r = i; r <= Math.floor(n); r += 1) {
589
+ let n = Oe(t, r), o = Y(n.x, n.z, e);
590
+ a && (s.strokeStyle = `rgba(255,240,200,${(r - i) / 19 * .7})`, s.lineWidth = 1.5, s.beginPath(), s.moveTo(a.x, a.y), s.lineTo(o.x, o.y), s.stroke()), a = o;
591
+ }
592
+ let o = Math.max(0, r.y - M(r.x, r.z)), c = Y(r.x, r.z, e), l = Math.min(o * .35 * e.scale, 40);
593
+ s.fillStyle = "rgba(0,0,0,0.35)", s.beginPath(), s.ellipse(c.x + l, c.y + l, 3, 2, 0, 0, Math.PI * 2), s.fill(), a && (s.strokeStyle = "rgba(255,240,200,0.7)", s.beginPath(), s.moveTo(a.x, a.y), s.lineTo(c.x, c.y), s.stroke());
594
+ let u = G(2.5 + o * .06, 2.5, 7);
595
+ s.fillStyle = "#fff3c4", s.beginPath(), s.arc(c.x, c.y, u, 0, Math.PI * 2), s.fill(), s.strokeStyle = "#3a2a12", s.lineWidth = 1, s.stroke();
596
+ }
597
+ function X(e) {
598
+ v.forEach((t) => {
599
+ let n = Y(t.x, t.z, e), r = Math.max(4, t.r * e.scale), i = s.createRadialGradient(n.x, n.y, 0, n.x, n.y, r);
600
+ i.addColorStop(0, `rgba(255,250,220,${t.life / t.max})`), i.addColorStop(1, "rgba(255,160,60,0)"), s.fillStyle = i, s.beginPath(), s.arc(n.x, n.y, r, 0, Math.PI * 2), s.fill();
601
+ }), y.forEach((t) => {
602
+ let n = Y(t.x, t.z, e);
603
+ s.fillStyle = `rgba(60,58,55,${t.life / t.max * .45})`, s.beginPath(), s.arc(n.x, n.y, Math.max(2, t.r * e.scale), 0, Math.PI * 2), s.fill();
604
+ }), _.forEach((t) => {
605
+ let n = 1 - t.life / t.max, r = Y(t.x, t.z, e);
606
+ s.strokeStyle = `rgba(${t.color},${1 - n})`, s.lineWidth = 2 + (1 - n) * 2, s.beginPath(), s.arc(r.x, r.y, Math.max(1, (t.r0 + (t.r1 - t.r0) * n) * e.scale), 0, Math.PI * 2), s.stroke();
607
+ }), g.forEach((t) => {
608
+ let n = Y(t.x, t.z, e);
609
+ s.globalAlpha = G(t.life / t.max, 0, 1), s.fillStyle = t.color;
610
+ let r = Math.max(1.5, t.size * e.scale);
611
+ s.fillRect(n.x - r / 2, n.y - r / 2, r, r);
612
+ }), s.globalAlpha = 1, s.textAlign = "center", s.font = "bold 14px system-ui, sans-serif", b.forEach((t) => {
613
+ let n = 1 - t.life / t.max, r = Y(t.x, t.z, e);
614
+ s.globalAlpha = G(1.4 - n * 1.4, 0, 1), s.lineWidth = 3, s.strokeStyle = "rgba(0,0,0,0.7)", s.strokeText(t.text, r.x, r.y - 18 - n * 26), s.fillStyle = t.color, s.fillText(t.text, r.x, r.y - 18 - n * 26);
615
+ }), s.globalAlpha = 1;
616
+ }
617
+ function je() {
618
+ let e = l.wind || {}, t = K(e.x), n = K(e.z), r = Math.hypot(t, n), i = E - 34;
619
+ if (s.fillStyle = "rgba(0,0,0,0.45)", s.beginPath(), s.arc(i, 34, 24, 0, Math.PI * 2), s.fill(), s.strokeStyle = "#e8f1ff", s.fillStyle = "#e8f1ff", s.lineWidth = 2, r > .01) {
620
+ let e = G(6 + r * 2, 8, 18), a = t / r, o = n / r;
621
+ s.beginPath(), s.moveTo(i - a * e, 34 - o * e), s.lineTo(i + a * e, 34 + o * e), s.stroke(), s.beginPath(), s.moveTo(i + a * (e + 4), 34 + o * (e + 4)), s.lineTo(i + a * e - o * 5, 34 + o * e + a * 5), s.lineTo(i + a * e + o * 5, 34 + o * e - a * 5), s.closePath(), s.fill();
622
+ } else s.beginPath(), s.arc(i, 34, 3, 0, Math.PI * 2), s.fill();
623
+ if (s.font = "11px system-ui, sans-serif", s.textAlign = "center", s.fillText(`${r.toFixed(1)} m/s`, i, 72), f && (Number.isFinite(f.pitch) || Number.isFinite(f.power))) {
624
+ s.textAlign = "left";
625
+ let e = [];
626
+ Number.isFinite(f.pitch) && e.push(`${Math.round(f.pitch)}°`), Number.isFinite(f.power) && e.push(`${Math.round(f.power)}%`);
627
+ let t = e.join(" · ");
628
+ s.fillStyle = "rgba(0,0,0,0.45)", s.fillRect(8, 8, s.measureText(t).width + 12, 20), s.fillStyle = "#e8f1ff", s.fillText(t, 14, 22);
629
+ }
630
+ }
631
+ function Z() {
632
+ if (s && E && D && !k) try {
633
+ if (s.setTransform(te, 0, 0, te, 0, 0), s.fillStyle = "#18211a", s.fillRect(0, 0, E, D), !l) return;
634
+ let e = oe(), t = Y(e.minX, e.minZ, e), n = e.size * e.scale, r = le();
635
+ r ? (s.imageSmoothingEnabled = !0, s.drawImage(r, t.x, t.y, n, n)) : (s.fillStyle = "#4c7a3e", s.fillRect(t.x, t.y, n, n)), s.strokeStyle = "rgba(0,0,0,0.5)", s.lineWidth = 1, s.strokeRect(t.x, t.y, n, n), fe(e), ue(e), de(e), pe(e), (l.tanks || []).forEach((t) => z(t, e)), ee.forEach((t) => W(e, t)), X(e), je();
636
+ } catch {}
637
+ }
638
+ async function Me(e) {
639
+ if (k || !e) return;
640
+ let n = e.tankId, r = j(n), i = (e.movePath || []).filter((e) => e && Number.isFinite(e.x) && Number.isFinite(e.z)), a = r || i[0] || {
641
+ x: 0,
642
+ z: 0
643
+ }, o = {
644
+ x: a.x,
645
+ y: K(a.y),
646
+ z: a.z,
647
+ hullYaw: K(r?.hullYaw),
648
+ yaw: K(r?.yaw, K(r?.hullYaw)),
649
+ pitch: K(r?.pitch)
650
+ };
651
+ if (S.set(String(n), o), i.length > 1 && De(i) > .05) {
652
+ let e = De(i), r = 0;
653
+ if (A("engine_start", { tankId: n }), await F(t ? 50 : 350), A("move_start", { tankId: n }), await F(G(e / he * 1e3, 400, 3500), (e, n) => {
654
+ let a = Ee(i, q(e));
655
+ if (a && (a.heading != null && (o.yaw += xe(o.hullYaw, a.heading), o.hullYaw = a.heading), o.x = a.x, o.y = a.y, o.z = a.z, r += n || 0, r > 110 && !t)) {
656
+ r = 0;
657
+ let e = ye(o.hullYaw);
658
+ I(a.x - e.x * 3, a.z - e.z * 3, 1, ["#8c7a5c"], 2);
659
+ }
660
+ }), A("move_end", { tankId: n }), k) return;
661
+ }
662
+ let s = K(e.yaw, o.yaw), c = Math.abs(xe(o.yaw, s));
663
+ if (c > 1) {
664
+ let e = o.yaw;
665
+ if (A("turret_start", { tankId: n }), await F(G(c / ge * 1e3, 200, 1500), (t) => {
666
+ o.yaw = Se(e, s, q(t));
667
+ }), A("turret_end", { tankId: n }), k) return;
668
+ }
669
+ o.yaw = s, o.pitch = K(e.pitch, o.pitch);
670
+ let l = e.damage || {}, u = /* @__PURE__ */ new Set(), d = [...e.craters || []].filter((e) => Number.isFinite(e?.x) && Number.isFinite(e?.z)), f = ye(o.yaw), p = {
671
+ x: o.x + f.x * B * .85,
672
+ z: o.z + f.z * B * .85
673
+ }, m = ke(e.shots).map((e) => ({
674
+ ...e,
675
+ state: "waiting",
676
+ f: 0
677
+ })), g = (e) => {
678
+ e.state = "flying", e.bomblet || (A("fire", {
679
+ tankId: n,
680
+ shot: e.index
681
+ }), v.push({
682
+ x: p.x,
683
+ z: p.z,
684
+ r: 2.5,
685
+ life: 160,
686
+ max: 160
687
+ }), y.push({
688
+ x: p.x,
689
+ z: p.z,
690
+ r: 1,
691
+ life: 900,
692
+ max: 900
693
+ }), e.count >= 2 && A("projectile_start", {
694
+ tankId: n,
695
+ shot: e.index
696
+ }));
697
+ }, _ = (e) => {
698
+ e.state = "done";
699
+ let { shot: t, index: n } = e, r = e.count ? Oe(t.samples, e.count - 1) : p, i = t.impact && Number.isFinite(t.impact.x) ? t.impact : {
700
+ ...r,
701
+ kind: "terrain"
702
+ };
703
+ if (A("impact", {
704
+ kind: i.kind,
705
+ tankId: i.tankId,
706
+ shot: n
707
+ }), i.kind === "split") v.push({
708
+ x: i.x,
709
+ z: i.z,
710
+ r: 1.5,
711
+ life: 140,
712
+ max: 140
713
+ }), I(i.x, i.z, 4, ["#ffe9a8", "#cfcfcf"], 6);
714
+ else if (i.kind !== "out") {
715
+ if (L(i.x, i.z, t.radius, !1), i.kind === "tank" && i.tankId != null) {
716
+ A("tank_hit", {
717
+ tankId: i.tankId,
718
+ shot: n
719
+ });
720
+ let e = l[i.tankId];
721
+ if (Number.isFinite(e) && e > 0 && !u.has(String(i.tankId))) {
722
+ u.add(String(i.tankId));
723
+ let t = w(i.tankId) || j(i.tankId) || i;
724
+ b.push({
725
+ x: t.x,
726
+ z: t.z,
727
+ text: `-${Math.round(e)}`,
728
+ color: "#ff6b5a",
729
+ life: 1400,
730
+ max: 1400
731
+ });
732
+ }
733
+ }
734
+ for (let e = d.length - 1; e >= 0; --e) {
735
+ let t = d[e];
736
+ Math.hypot(t.x - i.x, t.z - i.z) <= K(t.radius, 3) + 1.5 && h.push(...d.splice(e, 1));
737
+ }
738
+ }
739
+ };
740
+ if (m.length) {
741
+ let e = Math.max(...m.map((e) => e.endMs)) + 380;
742
+ if (await F(e, (t) => {
743
+ let n = t * e;
744
+ m.forEach((e) => {
745
+ e.state === "waiting" && n >= e.startMs && g(e), e.state === "flying" && (e.f = G((n - e.startMs) / 40, 0, Math.max(0, e.count - 1)), n >= e.endMs && _(e));
746
+ }), ee = m.filter((e) => e.state === "flying" && e.count >= 2).map((e) => ({
747
+ samples: e.shot.samples,
748
+ f: e.f
749
+ }));
750
+ }), ee = [], k) return;
751
+ }
752
+ h.push(...d), Object.entries(l).forEach(([e, t]) => {
753
+ if (u.has(e) || !Number.isFinite(t) || t <= 0) return;
754
+ let n = w(e) || j(e);
755
+ n && b.push({
756
+ x: n.x,
757
+ z: n.z,
758
+ text: `-${Math.round(t)}`,
759
+ color: "#ff6b5a",
760
+ life: 1400,
761
+ max: 1400
762
+ });
763
+ });
764
+ let x = e.destroyed || [];
765
+ if (x.forEach((e) => {
766
+ let t = w(e) || j(e);
767
+ A("big_explosion", { tankId: e }), t && L(t.x, t.z, 6, !0), A("destroyed", { tankId: e }), C.add(String(e));
768
+ }), x.length) {
769
+ let e = 0;
770
+ await F(1600, (t, n) => {
771
+ e += n || 0, !(e < 140) && (e = 0, x.forEach((e) => {
772
+ let t = w(e) || j(e);
773
+ t && y.push({
774
+ x: t.x + (Math.random() - .5) * 2,
775
+ z: t.z + (Math.random() - .5) * 2,
776
+ r: 1.2,
777
+ life: 1600,
778
+ max: 1600
779
+ });
780
+ }));
781
+ });
782
+ } else await F(500);
783
+ k || (e.world && Ne(e.world, !0), S.delete(String(n)), P(), Z());
784
+ }
785
+ function Ne(e, t) {
786
+ e && (!t && l && e.heights !== l.heights && (h = []), l = e, (e.tanks || []).forEach((e) => {
787
+ e.alive !== !1 && !(Number(e.hp) <= 0) && C.delete(String(e.id));
788
+ }));
789
+ }
790
+ function Q() {
791
+ if (!o || k) return;
792
+ let t = e?.getBoundingClientRect?.() || {
793
+ width: e?.clientWidth || 0,
794
+ height: e?.clientHeight || 0
795
+ };
796
+ E = Math.max(0, Math.floor(t.width)), D = Math.max(0, Math.floor(t.height)), te = Math.min(ae().dpr, a?.devicePixelRatio || 1), o.width = Math.max(1, Math.round(E * te)), o.height = Math.max(1, Math.round(D * te)), Z();
797
+ }
798
+ let Pe = () => {
799
+ ie() ? (O && a?.cancelAnimationFrame && a.cancelAnimationFrame(O), O = 0, ne = 0) : P();
800
+ };
801
+ i?.addEventListener("visibilitychange", Pe);
802
+ let Fe = null;
803
+ return a?.ResizeObserver && e ? (Fe = new a.ResizeObserver(() => Q()), Fe.observe(e)) : a?.addEventListener("resize", Q), Q(), {
804
+ setWorld(e) {
805
+ Ne(e, !1), Z();
806
+ },
807
+ setAim(e) {
808
+ f = e ? {
809
+ yaw: e.yaw,
810
+ pitch: e.pitch,
811
+ power: e.power
812
+ } : null, Z();
813
+ },
814
+ setPreview(e) {
815
+ p = Ae(e), Z();
816
+ },
817
+ playTurn(e) {
818
+ let t = re.then(() => Me(e)).catch(() => {});
819
+ return re = t, t;
820
+ },
821
+ setCameraMode(e) {
822
+ d = e || "overview", Z();
823
+ },
824
+ setQuality(e) {
825
+ U[e] && e !== u && (u = e, Q());
826
+ },
827
+ celebrate(e) {
828
+ x = e == null ? null : {
829
+ id: e,
830
+ left: 3e3,
831
+ next: 0
832
+ }, x && P(), Z();
833
+ },
834
+ resize: Q,
835
+ dispose() {
836
+ if (!k) {
837
+ k = !0, O && a?.cancelAnimationFrame && a.cancelAnimationFrame(O), O = 0, T.forEach((e) => e.resolve()), T.clear(), Fe?.disconnect(), a?.removeEventListener("resize", Q), i?.removeEventListener("visibilitychange", Pe), g = [], _ = [], v = [], y = [], b = [], h = [], ee = [], m = {
838
+ heights: null,
839
+ grid: 0,
840
+ factor: 0,
841
+ canvas: null
842
+ }, S.clear();
843
+ try {
844
+ o?.remove();
845
+ } catch {}
846
+ s = null;
847
+ }
848
+ }
849
+ };
850
+ }
851
+ // src/games/tanks/TanksGameCard.jsx
852
+ var Z = 60, Me = 6e4, Ne = {
853
+ standard: "Estándar",
854
+ heavy: "Pesada",
855
+ cluster: "Racimo"
856
+ }, Q = (e, [t, n]) => Math.max(t, Math.min(n, Math.round(e))), Pe = (e) => (Math.round(e) % 360 + 360) % 360, Fe = () => typeof matchMedia == "function" && matchMedia("(prefers-reduced-motion: reduce)").matches;
857
+ function Ie() {
858
+ let e = C(u)?.transport ?? null, t = S((t) => {
859
+ let n = e?.onStatus?.(t);
860
+ return typeof n == "function" ? n : () => {};
861
+ }, [e]), n = D(t, () => e?.getStatus?.() ?? null, () => null);
862
+ return f() === "connected" || n === "connected";
863
+ }
864
+ function Le(e, ...n) {
865
+ return Promise.resolve(t.getState()[e]?.(...n)).catch((e) => {
866
+ throw e;
867
+ });
868
+ }
869
+ function Re({ sync: e, connected: t, onResync: n, onAdoptOffer: r }) {
870
+ return e?.status === "requesting" ? /* @__PURE__ */ M("div", {
871
+ className: "chat-game-sync",
872
+ role: "status",
873
+ children: "Sincronizando partida…"
874
+ }) : /* @__PURE__ */ N("div", {
875
+ className: "chat-game-sync",
876
+ role: "alert",
877
+ children: [
878
+ e?.message && /* @__PURE__ */ M("span", { children: e.message }),
879
+ e?.status === "incompatible" && e.offer && /* @__PURE__ */ M("button", {
880
+ type: "button",
881
+ className: "chat-game-action chat-game-action--primary",
882
+ disabled: !t,
883
+ onClick: r,
884
+ children: "Usar estado del anfitrión"
885
+ }),
886
+ /* @__PURE__ */ M("button", {
887
+ type: "button",
888
+ className: "chat-game-action",
889
+ disabled: !t,
890
+ onClick: n,
891
+ children: "Reintentar sincronización"
892
+ })
893
+ ]
894
+ });
895
+ }
896
+ function ze({ label: e, hp: t, color: n, active: r }) {
897
+ return /* @__PURE__ */ N("div", {
898
+ className: `tk-hp tk-hp--${n}${r ? " is-active" : ""}`,
899
+ children: [
900
+ /* @__PURE__ */ M("span", {
901
+ className: "tk-hp-label",
902
+ children: e
903
+ }),
904
+ /* @__PURE__ */ M("span", {
905
+ className: "tk-hp-track",
906
+ role: "meter",
907
+ "aria-valuemin": 0,
908
+ "aria-valuemax": 100,
909
+ "aria-valuenow": t,
910
+ "aria-label": `Vida de ${e}`,
911
+ children: /* @__PURE__ */ M("span", {
912
+ className: "tk-hp-fill",
913
+ style: { width: `${t}%` }
914
+ })
915
+ }),
916
+ /* @__PURE__ */ M("strong", { children: t })
917
+ ]
918
+ });
919
+ }
920
+ function Be(e, t, n, r) {
921
+ let i = T(null), [a, o] = E("loading"), [s, c] = E(!1), l = T(r);
922
+ l.current = r;
923
+ let u = n || s;
924
+ return w(() => {
925
+ let n = e.current;
926
+ if (!t || !n) return;
927
+ let r = !1, a = null, s = {
928
+ reducedMotion: Fe(),
929
+ onEvent: (e) => {
930
+ e?.type === "context_lost" ? c(!0) : l.current?.(e);
931
+ }
932
+ }, d = (e, t) => {
933
+ a = e, i.current = e, o(t);
934
+ }, f = () => {
935
+ try {
936
+ d(je(n, s), "2d");
937
+ } catch {
938
+ o("none");
939
+ }
940
+ };
941
+ return o("loading"), u || !h() ? f() : import("./createTankScene-CV7Brxmt.js").then(({ createTankScene: e }) => {
942
+ if (!r) try {
943
+ d(e(n, s), "3d");
944
+ } catch {
945
+ f();
946
+ }
947
+ }).catch(() => {
948
+ r || f();
949
+ }), () => {
950
+ r = !0;
951
+ try {
952
+ a?.dispose();
953
+ } catch {}
954
+ i.current = null, g();
955
+ };
956
+ }, [
957
+ e,
958
+ t,
959
+ u
960
+ ]), {
961
+ sceneRef: i,
962
+ mode: a,
963
+ use2d: u,
964
+ setForced2d: c
965
+ };
966
+ }
967
+ function Ve({ game: e, currentUserId: t }) {
968
+ let n = e.logic?.tanks.map((e) => e.hp) ?? [100, 100];
969
+ return /* @__PURE__ */ N("section", {
970
+ className: "chat-game-card chat-game-card--history tk-card tk-card--history",
971
+ "aria-label": "Partida de Tanques de guerra",
972
+ children: [
973
+ /* @__PURE__ */ M("header", {
974
+ className: "chat-game-header",
975
+ children: /* @__PURE__ */ N("div", {
976
+ className: "chat-game-heading",
977
+ children: [/* @__PURE__ */ M("span", {
978
+ className: "chat-game-eyebrow",
979
+ children: "MINIJUEGOS · 2 JUGADORES"
980
+ }), /* @__PURE__ */ N("h3", { children: ["Tanques de guerra ", /* @__PURE__ */ M(ie, {
981
+ size: 13,
982
+ "aria-hidden": "true"
983
+ })] })]
984
+ })
985
+ }),
986
+ /* @__PURE__ */ M("p", {
987
+ className: "chat-game-status",
988
+ role: "status",
989
+ children: m(e, t)
990
+ }),
991
+ e.logic && /* @__PURE__ */ N("p", {
992
+ className: "tk-history-score",
993
+ children: [
994
+ "Verde ",
995
+ n[0],
996
+ " · Rojo ",
997
+ n[1],
998
+ " HP"
999
+ ]
1000
+ })
1001
+ ]
1002
+ });
1003
+ }
1004
+ function He({ game: t, gameKey: i, currentUserId: a, variant: s, onMinimize: c, onDismiss: l }) {
1005
+ let u = Ie(), f = T(null), [h, g] = E(!1), [x, S] = E(null), [C, D] = E(!1), [P, se] = E("overview"), [F, ce] = E(""), [I, L] = E(!1), [ue, me] = E(() => Date.now()), he = T("init"), ge = T(0), z = [
1006
+ "active",
1007
+ "won",
1008
+ "draw",
1009
+ "conflict",
1010
+ "closed"
1011
+ ].includes(t.status) && !!t.logic, { sceneRef: B, mode: V, use2d: _e } = Be(f, z, h, (e) => v(e, `${he.current}:${e.type}:${ge.current += 1}`)), H = String(a ?? t.ownId), ve = t.logic?.players ?? [t.hostId, t.guestId], U = ve.indexOf(H), W = p(H, t.guestId), G = U >= 0, K = d(t), q = n(t) && !C, J = (e, ...t) => {
1012
+ ce(""), Le(e, ...t).catch((e) => ce(e?.message || "No se pudo enviar."));
1013
+ };
1014
+ w(() => {
1015
+ _();
1016
+ }, []);
1017
+ let Y = T({
1018
+ eventId: void 0,
1019
+ logic: null,
1020
+ scene: null
1021
+ }), ye = T(Promise.resolve());
1022
+ w(() => {
1023
+ let e = B.current;
1024
+ if (!e || !t.logic) return;
1025
+ let n = Y.current, r = t.lastAction?.eventId ?? null;
1026
+ if (n.scene !== e) {
1027
+ Y.current = {
1028
+ eventId: r,
1029
+ logic: t.logic,
1030
+ scene: e
1031
+ }, e.setWorld(R(t));
1032
+ return;
1033
+ }
1034
+ if (n.logic === t.logic) return;
1035
+ let i = n.logic, a = r !== n.eventId && t.lastAction?.entry?.[0] === 1;
1036
+ Y.current = {
1037
+ eventId: r,
1038
+ logic: t.logic,
1039
+ scene: e
1040
+ };
1041
+ let o = a ? de(t, i) : null, s = R(t);
1042
+ ye.current = ye.current.then(async () => {
1043
+ if (B.current === e) {
1044
+ if (!o) e.setWorld(s);
1045
+ else {
1046
+ he.current = r, o.destroyed.length && y("big_explosion", 15e3), D(!0), se("overview");
1047
+ try {
1048
+ await e.playTurn(o);
1049
+ } catch {
1050
+ e.setWorld(s);
1051
+ }
1052
+ B.current === e && D(!1);
1053
+ }
1054
+ }
1055
+ });
1056
+ }, [
1057
+ t,
1058
+ V,
1059
+ B
1060
+ ]);
1061
+ let be = T(K);
1062
+ w(() => {
1063
+ !be.current && ["won", "draw"].includes(t.status) && ye.current.then(() => {
1064
+ B.current?.celebrate?.(t.winnerId ?? null), G && b(p(t.winnerId, H) ? "victory" : "defeat", `${t.gameId}:end`);
1065
+ });
1066
+ }, [
1067
+ t.status,
1068
+ t.winnerId,
1069
+ t.gameId,
1070
+ H,
1071
+ G,
1072
+ B
1073
+ ]), w(() => {
1074
+ if (!n(t) || !t.logic) {
1075
+ S(null);
1076
+ return;
1077
+ }
1078
+ let e = t.logic.tanks[U], r = t.logic.tanks[1 - U];
1079
+ S({
1080
+ move: 0,
1081
+ yaw: pe(e, r),
1082
+ pitch: 45,
1083
+ power: 60,
1084
+ ammo: "standard"
1085
+ });
1086
+ }, [
1087
+ t.ply,
1088
+ t.status,
1089
+ t.pendingEvent,
1090
+ U
1091
+ ]), w(() => {
1092
+ let e = B.current;
1093
+ e && t.logic && (!x || !q ? e.setPreview(null) : (e.setAim(x), e.setPreview(fe(t, H, x))));
1094
+ }, [
1095
+ x,
1096
+ q,
1097
+ V
1098
+ ]), w(() => {
1099
+ B.current?.setCameraMode?.(P);
1100
+ }, [
1101
+ P,
1102
+ V,
1103
+ B
1104
+ ]);
1105
+ let xe = T({
1106
+ ply: -1,
1107
+ at: 0
1108
+ });
1109
+ !C && t.status === "active" && xe.current.ply !== t.ply && (xe.current = {
1110
+ ply: t.ply,
1111
+ at: Date.now()
1112
+ }), w(() => {
1113
+ if (t.status !== "active" && t.status !== "invited") return;
1114
+ let e = setInterval(() => me(Date.now()), 1e3);
1115
+ return () => clearInterval(e);
1116
+ }, [t.status]);
1117
+ let Se = Math.max(0, Z - Math.floor((ue - xe.current.at) / 1e3)), Ce = T(-1);
1118
+ w(() => {
1119
+ !q || Se > 0 || Ce.current === t.ply || document.visibilityState !== "visible" || (Ce.current = t.ply, J("tkSkip", i));
1120
+ }, [
1121
+ q,
1122
+ Se,
1123
+ t.ply,
1124
+ i
1125
+ ]);
1126
+ let X = (e) => S((t) => t && {
1127
+ ...t,
1128
+ ...e
1129
+ }), we = () => {
1130
+ q && x && u && J("tkTurn", i, x);
1131
+ }, Te = T(null), Ee = (e) => {
1132
+ q && x && (Te.current = {
1133
+ x: e.clientX,
1134
+ y: e.clientY,
1135
+ yaw: x.yaw,
1136
+ pitch: x.pitch
1137
+ }, e.currentTarget.setPointerCapture?.(e.pointerId));
1138
+ }, De = (t) => {
1139
+ if (!Te.current) return;
1140
+ let n = Te.current;
1141
+ X({
1142
+ yaw: Pe(n.yaw - (t.clientX - n.x) * .4),
1143
+ pitch: Q(n.pitch - (t.clientY - n.y) * .25, e.pitch)
1144
+ });
1145
+ }, Oe = () => {
1146
+ Te.current = null;
1147
+ }, ke = (t) => {
1148
+ if (!q || !x) return;
1149
+ let n = t.shiftKey ? 10 : 2, r = {
1150
+ ArrowLeft: () => X({ yaw: Pe(x.yaw + n) }),
1151
+ ArrowRight: () => X({ yaw: Pe(x.yaw - n) }),
1152
+ ArrowUp: () => X({ pitch: Q(x.pitch + 1, e.pitch) }),
1153
+ ArrowDown: () => X({ pitch: Q(x.pitch - 1, e.pitch) }),
1154
+ "+": () => X({ power: Q(x.power + 2, e.power) }),
1155
+ "=": () => X({ power: Q(x.power + 2, e.power) }),
1156
+ "-": () => X({ power: Q(x.power - 2, e.power) }),
1157
+ Enter: we,
1158
+ " ": we
1159
+ }[t.key];
1160
+ r && (t.preventDefault(), r());
1161
+ }, Ae = ve[1 - U] ?? (W ? t.hostId : t.guestId), je = () => J("invite", {
1162
+ roomId: t.roomId,
1163
+ opponentId: Ae,
1164
+ gameType: "tanks",
1165
+ firstPlayerId: t.firstPlayerId === t.hostId ? t.guestId : t.hostId,
1166
+ rematchOf: t.gameId
1167
+ }), Fe = !u && !K ? "Sin conexión · esperando reconexión" : t.pending ? "Enviando…" : m(t, a), Ve = t.logic?.tanks ?? [], He = Ve[U], $ = t.logic ? R(t).wind : null, Ue = $ ? Math.hypot($.x, $.z) : 0, We = $ ? Math.round(Math.atan2($.z, $.x) * 180 / Math.PI) : 0, Ge = t.status === "invited" && !W && Date.now() - Date.parse(t.createdAt) > Me;
1168
+ return /* @__PURE__ */ N("section", {
1169
+ className: `chat-game-card tk-card${q ? " chat-game-card--my-turn" : ""}${s ? ` chat-game-card--${s}` : ""}`,
1170
+ "aria-label": "Partida de Tanques de guerra",
1171
+ children: [
1172
+ /* @__PURE__ */ N("header", {
1173
+ className: "chat-game-header",
1174
+ children: [
1175
+ /* @__PURE__ */ N("div", {
1176
+ className: "chat-game-heading",
1177
+ children: [/* @__PURE__ */ M("span", {
1178
+ className: "chat-game-eyebrow",
1179
+ children: "MINIJUEGOS · 2 JUGADORES"
1180
+ }), /* @__PURE__ */ N("h3", { children: ["Tanques de guerra ", /* @__PURE__ */ M(ie, {
1181
+ size: 13,
1182
+ "aria-hidden": "true"
1183
+ })] })]
1184
+ }),
1185
+ s === "panel" && /* @__PURE__ */ M(o, { manager: ee() }),
1186
+ c && /* @__PURE__ */ M("button", {
1187
+ className: "chat-game-close",
1188
+ type: "button",
1189
+ "aria-label": "Minimizar tablero",
1190
+ title: "Minimizar tablero",
1191
+ onClick: c,
1192
+ children: /* @__PURE__ */ M(te, {
1193
+ size: 16,
1194
+ "aria-hidden": "true"
1195
+ })
1196
+ }),
1197
+ G && !K && /* @__PURE__ */ M("button", {
1198
+ className: "chat-game-close",
1199
+ type: "button",
1200
+ "aria-label": "Finalizar partida para ambos jugadores",
1201
+ title: "Finalizar partida para ambos",
1202
+ disabled: !u,
1203
+ onClick: () => J("act", i, "game_end"),
1204
+ children: /* @__PURE__ */ M(oe, {
1205
+ size: 16,
1206
+ "aria-hidden": "true"
1207
+ })
1208
+ }),
1209
+ l && /* @__PURE__ */ M("button", {
1210
+ className: "chat-game-close",
1211
+ type: "button",
1212
+ "aria-label": "Cerrar tablero y volver al chat",
1213
+ title: "Cerrar tablero",
1214
+ onClick: l,
1215
+ children: /* @__PURE__ */ M(oe, {
1216
+ size: 16,
1217
+ "aria-hidden": "true"
1218
+ })
1219
+ })
1220
+ ]
1221
+ }),
1222
+ /* @__PURE__ */ M("p", {
1223
+ className: "chat-game-status",
1224
+ role: "status",
1225
+ children: Fe
1226
+ }),
1227
+ t.status === "invited" && /* @__PURE__ */ N("div", {
1228
+ className: "tk-invite",
1229
+ children: [
1230
+ /* @__PURE__ */ M("p", { children: "Duelo de artillería por turnos: mueve tu tanque, apunta la torreta, elige la potencia y destruye al rival. 100 HP cada uno." }),
1231
+ W && /* @__PURE__ */ N("div", {
1232
+ className: "chat-game-actions",
1233
+ children: [/* @__PURE__ */ M("button", {
1234
+ type: "button",
1235
+ className: "chat-game-action chat-game-action--primary",
1236
+ disabled: !u || t.pending,
1237
+ onClick: () => J("act", i, "game_accept"),
1238
+ children: "Aceptar duelo"
1239
+ }), /* @__PURE__ */ M("button", {
1240
+ type: "button",
1241
+ className: "chat-game-action",
1242
+ disabled: !u || t.pending,
1243
+ onClick: () => J("act", i, "game_decline"),
1244
+ children: "Rechazar"
1245
+ })]
1246
+ }),
1247
+ Ge && /* @__PURE__ */ M("p", {
1248
+ className: "tk-hint",
1249
+ children: "¿No responde? Tu contacto puede necesitar actualizar la app para jugar a Tanques."
1250
+ })
1251
+ ]
1252
+ }),
1253
+ z && /* @__PURE__ */ N("div", {
1254
+ className: "tk-stage-wrap",
1255
+ children: [
1256
+ /* @__PURE__ */ M("div", {
1257
+ ref: f,
1258
+ className: `tk-stage${q ? " is-aiming" : ""}`,
1259
+ tabIndex: 0,
1260
+ role: "application",
1261
+ "aria-label": "Campo de batalla. Flechas para apuntar, más y menos para la potencia, Enter para disparar.",
1262
+ onPointerDown: Ee,
1263
+ onPointerMove: De,
1264
+ onPointerUp: Oe,
1265
+ onPointerCancel: Oe,
1266
+ onKeyDown: ke
1267
+ }),
1268
+ V === "loading" && /* @__PURE__ */ M("div", {
1269
+ className: "tk-stage-note",
1270
+ role: "status",
1271
+ children: "Cargando campo de batalla…"
1272
+ }),
1273
+ V === "none" && /* @__PURE__ */ M("div", {
1274
+ className: "tk-stage-note",
1275
+ role: "alert",
1276
+ children: "No se pudo dibujar el campo de batalla."
1277
+ }),
1278
+ /* @__PURE__ */ N("div", {
1279
+ className: "tk-hud",
1280
+ children: [
1281
+ /* @__PURE__ */ M(ze, {
1282
+ label: U === 0 ? "Tú" : "Verde",
1283
+ hp: Ve[0]?.hp ?? 100,
1284
+ color: le[0],
1285
+ active: t.turnId === ve[0]
1286
+ }),
1287
+ /* @__PURE__ */ M(ze, {
1288
+ label: U === 1 ? "Tú" : "Rojo",
1289
+ hp: Ve[1]?.hp ?? 100,
1290
+ color: le[1],
1291
+ active: t.turnId === ve[1]
1292
+ }),
1293
+ /* @__PURE__ */ N("div", {
1294
+ className: "tk-hud-meta",
1295
+ children: [
1296
+ $ && /* @__PURE__ */ N("span", {
1297
+ title: "Viento",
1298
+ children: [
1299
+ /* @__PURE__ */ M(ae, {
1300
+ size: 12,
1301
+ "aria-hidden": "true"
1302
+ }),
1303
+ /* @__PURE__ */ M("i", {
1304
+ className: "tk-wind-arrow",
1305
+ style: { transform: `rotate(${We}deg)` },
1306
+ "aria-hidden": "true",
1307
+ children: "➜"
1308
+ }),
1309
+ Ue.toFixed(1),
1310
+ " m/s²"
1311
+ ]
1312
+ }),
1313
+ t.logic && /* @__PURE__ */ N("span", { children: [
1314
+ "Disparo ",
1315
+ Math.min(t.logic.shots + 1, t.logic.maxShots),
1316
+ "/",
1317
+ t.logic.maxShots
1318
+ ] }),
1319
+ t.status === "active" && !C && /* @__PURE__ */ N("span", {
1320
+ className: Se <= 10 ? "tk-timer is-low" : "tk-timer",
1321
+ children: [Se, "s"]
1322
+ })
1323
+ ]
1324
+ })
1325
+ ]
1326
+ }),
1327
+ /* @__PURE__ */ N("div", {
1328
+ className: "tk-stage-tools",
1329
+ children: [/* @__PURE__ */ N("button", {
1330
+ type: "button",
1331
+ className: "chat-game-action",
1332
+ "aria-pressed": P === "aim",
1333
+ onClick: () => se(P === "aim" ? "overview" : "aim"),
1334
+ title: "Cambiar cámara",
1335
+ children: [/* @__PURE__ */ M(A, {
1336
+ size: 14,
1337
+ "aria-hidden": "true"
1338
+ }), P === "aim" ? "Vista general" : "Cámara de apuntado"]
1339
+ }), V !== "loading" && /* @__PURE__ */ N("button", {
1340
+ type: "button",
1341
+ className: "chat-game-action",
1342
+ "aria-pressed": _e,
1343
+ onClick: () => g(!_e),
1344
+ title: "Cambiar vista",
1345
+ children: [/* @__PURE__ */ M(k, {
1346
+ size: 14,
1347
+ "aria-hidden": "true"
1348
+ }), _e ? "Vista 3D" : "Vista 2D"]
1349
+ })]
1350
+ })
1351
+ ]
1352
+ }),
1353
+ q && x && He && /* @__PURE__ */ N("div", {
1354
+ className: "tk-controls",
1355
+ "aria-label": "Controles del disparo",
1356
+ children: [
1357
+ /* @__PURE__ */ N("label", {
1358
+ className: "tk-control",
1359
+ children: [/* @__PURE__ */ N("span", { children: [
1360
+ "Mover ",
1361
+ /* @__PURE__ */ N("strong", { children: [(x.move * .5).toFixed(1), " m"] }),
1362
+ " ",
1363
+ /* @__PURE__ */ N("small", { children: [
1364
+ "combustible ",
1365
+ Math.floor(He.fuel / 1e5),
1366
+ " m"
1367
+ ] })
1368
+ ] }), /* @__PURE__ */ M("input", {
1369
+ type: "range",
1370
+ min: e.move[0],
1371
+ max: e.move[1],
1372
+ value: x.move,
1373
+ onChange: (e) => X({ move: Number(e.target.value) }),
1374
+ "aria-valuetext": `${(x.move * .5).toFixed(1)} metros`
1375
+ })]
1376
+ }),
1377
+ /* @__PURE__ */ N("label", {
1378
+ className: "tk-control",
1379
+ children: [/* @__PURE__ */ N("span", { children: ["Torreta ", /* @__PURE__ */ N("strong", { children: [x.yaw, "°"] })] }), /* @__PURE__ */ M("input", {
1380
+ type: "range",
1381
+ min: e.yaw[0],
1382
+ max: e.yaw[1],
1383
+ value: x.yaw,
1384
+ onChange: (e) => X({ yaw: Number(e.target.value) }),
1385
+ "aria-valuetext": `${x.yaw} grados`
1386
+ })]
1387
+ }),
1388
+ /* @__PURE__ */ N("label", {
1389
+ className: "tk-control",
1390
+ children: [/* @__PURE__ */ N("span", { children: ["Elevación ", /* @__PURE__ */ N("strong", { children: [x.pitch, "°"] })] }), /* @__PURE__ */ M("input", {
1391
+ type: "range",
1392
+ min: e.pitch[0],
1393
+ max: e.pitch[1],
1394
+ value: x.pitch,
1395
+ onChange: (e) => X({ pitch: Number(e.target.value) }),
1396
+ "aria-valuetext": `${x.pitch} grados`
1397
+ })]
1398
+ }),
1399
+ /* @__PURE__ */ N("label", {
1400
+ className: "tk-control",
1401
+ children: [/* @__PURE__ */ N("span", { children: ["Potencia ", /* @__PURE__ */ M("strong", { children: x.power })] }), /* @__PURE__ */ M("input", {
1402
+ type: "range",
1403
+ min: e.power[0],
1404
+ max: e.power[1],
1405
+ value: x.power,
1406
+ onChange: (e) => X({ power: Number(e.target.value) }),
1407
+ "aria-valuetext": `Potencia ${x.power}`
1408
+ })]
1409
+ }),
1410
+ /* @__PURE__ */ M("div", {
1411
+ className: "tk-ammo",
1412
+ role: "radiogroup",
1413
+ "aria-label": "Munición",
1414
+ children: Object.keys(r).map((e) => {
1415
+ let t = r[e].cost === 0 ? "∞" : He.ammo[e] ?? 0;
1416
+ return /* @__PURE__ */ N("button", {
1417
+ type: "button",
1418
+ role: "radio",
1419
+ "aria-checked": x.ammo === e,
1420
+ disabled: t === 0,
1421
+ className: `tk-ammo-item${x.ammo === e ? " is-selected" : ""}`,
1422
+ onClick: () => X({ ammo: e }),
1423
+ children: [
1424
+ Ne[e],
1425
+ " ",
1426
+ /* @__PURE__ */ M("small", { children: t })
1427
+ ]
1428
+ }, e);
1429
+ })
1430
+ }),
1431
+ /* @__PURE__ */ N("button", {
1432
+ type: "button",
1433
+ className: "tk-fire",
1434
+ disabled: !u || t.pending,
1435
+ onClick: we,
1436
+ children: [/* @__PURE__ */ M(O, {
1437
+ size: 18,
1438
+ "aria-hidden": "true"
1439
+ }), "DISPARAR"]
1440
+ })
1441
+ ]
1442
+ }),
1443
+ t.status === "conflict" && /* @__PURE__ */ N(j, { children: [t.error && /* @__PURE__ */ M("p", {
1444
+ className: "chat-game-error",
1445
+ role: "alert",
1446
+ children: t.error
1447
+ }), /* @__PURE__ */ M(Re, {
1448
+ sync: t.sync,
1449
+ connected: u,
1450
+ onResync: () => J("requestResync", i),
1451
+ onAdoptOffer: () => J("adoptResyncOffer", i)
1452
+ })] }),
1453
+ t.status !== "conflict" && t.error && /* @__PURE__ */ M("p", {
1454
+ className: "chat-game-error",
1455
+ role: "alert",
1456
+ children: t.error
1457
+ }),
1458
+ F && /* @__PURE__ */ M("p", {
1459
+ className: "chat-game-error",
1460
+ role: "alert",
1461
+ children: F
1462
+ }),
1463
+ t.pendingEvent && !t.pending && /* @__PURE__ */ M("div", {
1464
+ className: "chat-game-actions",
1465
+ children: /* @__PURE__ */ M("button", {
1466
+ type: "button",
1467
+ className: "chat-game-action chat-game-action--primary",
1468
+ disabled: !u,
1469
+ onClick: () => J("retry", i),
1470
+ children: "Reintentar envío"
1471
+ })
1472
+ }),
1473
+ t.status === "active" && G && /* @__PURE__ */ M("div", {
1474
+ className: "chat-game-actions tk-secondary",
1475
+ children: I ? /* @__PURE__ */ N(j, { children: [/* @__PURE__ */ M("button", {
1476
+ type: "button",
1477
+ className: "chat-game-action chat-game-action--danger",
1478
+ onClick: () => {
1479
+ L(!1), J("tkResign", i);
1480
+ },
1481
+ children: "Confirmar rendición"
1482
+ }), /* @__PURE__ */ M("button", {
1483
+ type: "button",
1484
+ className: "chat-game-action",
1485
+ onClick: () => L(!1),
1486
+ children: "Cancelar"
1487
+ })] }) : /* @__PURE__ */ N("button", {
1488
+ type: "button",
1489
+ className: "chat-game-action",
1490
+ disabled: !u || !!t.pendingEvent,
1491
+ onClick: () => L(!0),
1492
+ children: [/* @__PURE__ */ M(ne, {
1493
+ size: 14,
1494
+ "aria-hidden": "true"
1495
+ }), "Rendirse"]
1496
+ })
1497
+ }),
1498
+ [
1499
+ "won",
1500
+ "draw",
1501
+ "closed"
1502
+ ].includes(t.status) && G && /* @__PURE__ */ M("div", {
1503
+ className: "chat-game-actions",
1504
+ children: /* @__PURE__ */ N("button", {
1505
+ type: "button",
1506
+ className: "chat-game-action chat-game-action--primary",
1507
+ disabled: !u,
1508
+ onClick: je,
1509
+ children: [/* @__PURE__ */ M(re, {
1510
+ size: 14,
1511
+ "aria-hidden": "true"
1512
+ }), "Revancha"]
1513
+ })
1514
+ })
1515
+ ]
1516
+ });
1517
+ }
1518
+ function $({ gameKey: e, currentUserId: n, variant: r = "panel", onMinimize: i, onDismiss: a }) {
1519
+ let o = t((t) => t.games[e]);
1520
+ return o ? r === "history" ? /* @__PURE__ */ M(Ve, {
1521
+ game: o,
1522
+ currentUserId: n
1523
+ }) : /* @__PURE__ */ M(He, {
1524
+ game: o,
1525
+ gameKey: e,
1526
+ currentUserId: n,
1527
+ variant: r,
1528
+ onMinimize: i,
1529
+ onDismiss: a
1530
+ }) : null;
1531
+ }
1532
+ var Ue = x($);
1533
+ export { Ue as default };
1534
+
1535
+ //# sourceMappingURL=TanksGameCard-D0n-lzTs.js.map