plinkit 1.0.0-dev.3 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,452 +1,305 @@
1
- var Be = (d, E) => () => (E || (d((E = { exports: {} }).exports, E), d = null), E.exports), Ee = 35, Ae = 24, Ie = 0.08, Le = 6, Re = 0.85, pe = 0.7, ke = 0.16, be = 0.92, De = 256, Ue = 1e3, Fe = class {
2
- ctx = null;
3
- masterGain = null;
4
- buffers = /* @__PURE__ */ new Map();
5
- lastHitByBall = /* @__PURE__ */ new Map();
6
- activePegVoices = 0;
7
- muted;
8
- volume;
9
- destroyed = !1;
10
- unlockedOnce = !1;
11
- pendingUiTap = !1;
12
- gestureCleanup = null;
13
- visibilityCleanup = null;
14
- config;
15
- constructor(d) {
16
- this.config = d, this.muted = d.muted, this.volume = me(d.masterVolume), this.installGestureUnlock(), this.installVisibilityHandler();
17
- }
18
- setMuted(d) {
19
- this.muted = d, this.masterGain && (this.masterGain.gain.value = d ? 0 : this.volume), d || this.tryUnlock();
20
- }
21
- isMuted() {
22
- return this.muted;
23
- }
24
- setVolume(d) {
25
- this.volume = me(d), this.masterGain && !this.muted && (this.masterGain.gain.value = this.volume);
26
- }
27
- resume() {
28
- this.tryUnlock();
29
- }
30
- playPegHit(d, E) {
31
- if (this.destroyed || this.muted || !this.unlockedOnce) return;
32
- const T = this.ctx;
33
- if (!T) return;
34
- const A = T.currentTime * 1e3, f = this.lastHitByBall.get(d);
35
- if (f !== void 0 && A - f < Ee || (this.lastHitByBall.set(d, A), this.maybeCleanupLastHits(A), this.activePegVoices >= Ae)) return;
36
- const e = Math.max(Ie, Math.min(1, E / Le));
37
- this.playSample("peg", e, !0);
38
- }
39
- playBucketHit() {
40
- this.playSample("bucket", Re, !1);
41
- }
42
- playUiTap() {
43
- if (!(this.destroyed || this.muted)) {
44
- if (this.ensureContext(), this.unlockedOnce) {
45
- this.playSample("uiTap", pe, !1);
46
- return;
47
- }
48
- this.pendingUiTap = !0, this.tryUnlock();
49
- }
50
- }
51
- playSample(d, E, T) {
52
- if (this.destroyed || this.muted || !this.unlockedOnce) return;
53
- const A = this.ctx, f = this.masterGain;
54
- if (!A || !f) return;
55
- const e = this.buffers.get(d);
56
- if (!e) return;
57
- const o = A.createBufferSource();
58
- o.buffer = e, o.playbackRate.value = be + Math.random() * ke;
59
- const a = A.createGain();
60
- a.gain.value = E, o.connect(a), a.connect(f), T && (this.activePegVoices += 1), o.onended = () => {
61
- T && (this.activePegVoices = Math.max(0, this.activePegVoices - 1)), o.disconnect(), a.disconnect();
62
- }, o.start();
63
- }
64
- destroy() {
65
- this.destroyed || (this.destroyed = !0, this.gestureCleanup?.(), this.gestureCleanup = null, this.visibilityCleanup?.(), this.visibilityCleanup = null, this.buffers.clear(), this.lastHitByBall.clear(), this.ctx && (this.ctx.close().catch(ae), this.ctx = null, this.masterGain = null));
66
- }
67
- ensureContext() {
68
- if (this.destroyed || this.ctx || typeof window > "u") return;
69
- const d = window.AudioContext ?? window.webkitAudioContext;
70
- d && (this.ctx = new d(), this.masterGain = this.ctx.createGain(), this.masterGain.gain.value = this.muted ? 0 : this.volume, this.masterGain.connect(this.ctx.destination), this.loadBuffers());
71
- }
72
- tryUnlock() {
73
- if (this.destroyed) return;
74
- this.ensureContext();
75
- const d = this.ctx;
76
- if (d) {
77
- if (d.state === "running") {
78
- this.markUnlocked();
79
- return;
80
- }
81
- d.resume().then(() => this.markUnlocked()).catch(ae);
82
- }
83
- }
84
- markUnlocked() {
85
- this.destroyed || this.unlockedOnce || (this.unlockedOnce = !0, this.playSilentPing(), this.gestureCleanup?.(), this.gestureCleanup = null, this.pendingUiTap && (this.pendingUiTap = !1, this.playSample("uiTap", pe, !1)));
86
- }
87
- playSilentPing() {
88
- const d = this.ctx;
89
- if (d)
90
- try {
91
- const E = d.createBuffer(1, 1, Math.max(22050, d.sampleRate)), T = d.createBufferSource();
92
- T.buffer = E;
93
- const A = d.createGain();
94
- A.gain.value = 1e-5, T.connect(A), A.connect(d.destination);
95
- try {
96
- T.start(0);
97
- } catch {
98
- }
99
- try {
100
- T.stop(0);
101
- } catch {
102
- }
103
- } catch {
104
- }
105
- }
106
- installGestureUnlock() {
107
- if (typeof window > "u") return;
108
- const d = {
109
- passive: !0,
110
- capture: !0
111
- }, E = !0, T = () => this.tryUnlock();
112
- window.addEventListener("pointerdown", T, d), window.addEventListener("pointerup", T, d), window.addEventListener("touchstart", T, d), window.addEventListener("touchend", T, d), window.addEventListener("keydown", T, E), this.gestureCleanup = () => {
113
- window.removeEventListener("pointerdown", T, d), window.removeEventListener("pointerup", T, d), window.removeEventListener("touchstart", T, d), window.removeEventListener("touchend", T, d), window.removeEventListener("keydown", T, E);
114
- };
115
- }
116
- installVisibilityHandler() {
117
- if (typeof document > "u") return;
118
- const d = () => {
119
- this.destroyed || document.hidden || this.unlockedOnce && this.ctx?.resume().catch(ae);
120
- };
121
- document.addEventListener("visibilitychange", d), this.visibilityCleanup = () => document.removeEventListener("visibilitychange", d);
122
- }
123
- async loadBuffers() {
124
- const d = [];
125
- this.config.pegHitUrl && d.push(this.loadBuffer("peg", this.config.pegHitUrl)), this.config.bucketHitUrl && d.push(this.loadBuffer("bucket", this.config.bucketHitUrl)), this.config.uiTapUrl && d.push(this.loadBuffer("uiTap", this.config.uiTapUrl)), await Promise.allSettled(d);
126
- }
127
- async loadBuffer(d, E) {
128
- const T = this.ctx;
129
- if (T)
130
- try {
131
- const A = await fetch(E);
132
- if (!A.ok) return;
133
- const f = await A.arrayBuffer(), e = await T.decodeAudioData(f);
134
- this.destroyed || this.buffers.set(d, e);
135
- } catch {
136
- }
137
- }
138
- maybeCleanupLastHits(d) {
139
- if (!(this.lastHitByBall.size <= De))
140
- for (const [E, T] of this.lastHitByBall) d - T > Ue && this.lastHitByBall.delete(E);
141
- }
142
- };
143
- function me(d) {
144
- return !Number.isFinite(d) || d < 0 ? 0 : d > 1 ? 1 : d;
145
- }
146
- function ae() {
147
- }
148
- var Oe = class {
1
+ var Ce = (p, B) => () => (B || (p((B = { exports: {} }).exports, B), p = null), B.exports), Me = class {
149
2
  rafId = null;
150
3
  step;
151
- constructor(d) {
152
- this.step = d;
4
+ constructor(p) {
5
+ this.step = p;
153
6
  }
154
7
  start() {
155
8
  if (this.rafId !== null) return;
156
- const d = (E) => {
157
- this.step(E), this.rafId = window.requestAnimationFrame(d);
9
+ const p = (B) => {
10
+ this.step(B), this.rafId = window.requestAnimationFrame(p);
158
11
  };
159
- this.rafId = window.requestAnimationFrame(d);
12
+ this.rafId = window.requestAnimationFrame(p);
160
13
  }
161
14
  stop() {
162
15
  this.rafId !== null && (window.cancelAnimationFrame(this.rafId), this.rafId = null);
163
16
  }
164
17
  };
165
- function Se(d, E) {
166
- const T = d.bottomPegCount - d.topPegCount + 1, A = d.radius + d.sidePaddingPx, f = (E - A * 2) / Math.max(d.bottomPegCount - 1, 1);
18
+ function me(p, B) {
19
+ const A = p.bottomPegCount - p.topPegCount + 1, E = p.radius + p.sidePaddingPx, c = (B - E * 2) / Math.max(p.bottomPegCount - 1, 1);
167
20
  return {
168
- rows: T,
169
- sidePadding: A,
170
- baseSpacing: f,
171
- targetVerticalStep: f * d.verticalStepRatio
21
+ rows: A,
22
+ sidePadding: E,
23
+ baseSpacing: c,
24
+ targetVerticalStep: c * p.verticalStepRatio
172
25
  };
173
26
  }
174
- function He(d) {
175
- const { width: E, height: T, topPegCount: A } = d;
176
- if (d.bottomPegCount < A) throw new Error("bottomPegCount must be greater than or equal to topPegCount");
177
- const f = Se(d, E), e = E * 0.5, o = d.topPaddingPx, a = Math.max(o + 60, T - d.bottomPaddingPx), r = f.rows > 1 ? (a - o) / (f.rows - 1) : 0, c = Math.min(f.targetVerticalStep, r), n = a - c * Math.max(f.rows - 1, 0), h = [];
178
- for (let l = 0; l < f.rows; l++) {
179
- const t = A + l, i = n + l * c, s = (t - 1) * f.baseSpacing, u = e - s * 0.5;
27
+ function Te(p) {
28
+ const { width: B, height: A, topPegCount: E } = p;
29
+ if (p.bottomPegCount < E) throw new Error("bottomPegCount must be greater than or equal to topPegCount");
30
+ const c = me(p, B), e = B * 0.5, o = p.topPaddingPx, r = Math.max(o + 60, A - p.bottomPaddingPx), a = c.rows > 1 ? (r - o) / (c.rows - 1) : 0, u = Math.min(c.targetVerticalStep, a), n = r - u * Math.max(c.rows - 1, 0), h = [];
31
+ for (let l = 0; l < c.rows; l++) {
32
+ const t = E + l, i = n + l * u, s = (t - 1) * c.baseSpacing, f = e - s * 0.5;
180
33
  h.push({
181
34
  row: l,
182
35
  count: t,
183
36
  y: i,
184
- startX: u,
37
+ startX: f,
185
38
  rowWidth: s,
186
- leftX: u,
187
- rightX: u + s
39
+ leftX: f,
40
+ rightX: f + s
188
41
  });
189
42
  }
190
43
  return {
191
- rows: f.rows,
44
+ rows: c.rows,
192
45
  center: e,
193
46
  minTopY: o,
194
- bottomY: a,
195
- sidePadding: f.sidePadding,
196
- baseSpacing: f.baseSpacing,
197
- verticalStep: c,
47
+ bottomY: r,
48
+ sidePadding: c.sidePadding,
49
+ baseSpacing: c.baseSpacing,
50
+ verticalStep: u,
198
51
  startY: n,
199
52
  rowAnchors: h
200
53
  };
201
54
  }
202
- function Ve(d, E) {
203
- const T = [];
204
- for (const A of d.rowAnchors) for (let f = 0; f < A.count; f++) T.push({
205
- x: A.startX + f * d.baseSpacing,
206
- y: A.y,
207
- radius: E
55
+ function Ae(p, B) {
56
+ const A = [];
57
+ for (const E of p.rowAnchors) for (let c = 0; c < E.count; c++) A.push({
58
+ x: E.startX + c * p.baseSpacing,
59
+ y: E.y,
60
+ radius: B
208
61
  });
209
- return T;
62
+ return A;
210
63
  }
211
- function Ne(d, E, T) {
212
- if (d.rows < 2) return [];
213
- const A = [], f = (T.spread - 1) * d.baseSpacing, e = (t) => t < d.center ? t - f : t > d.center ? t + f : t, o = d.rowAnchors[0], a = o.leftX, r = o.rightX, c = d.startY - d.minTopY, n = E * 2.5, h = Math.min(d.verticalStep, Math.max(n, c / 3)), l = c >= n ? Math.min(3, Math.floor(c / h)) : 0;
64
+ function Be(p, B, A) {
65
+ if (p.rows < 2) return [];
66
+ const E = [], c = (A.spread - 1) * p.baseSpacing, e = (t) => t < p.center ? t - c : t > p.center ? t + c : t, o = p.rowAnchors[0], r = o.leftX, a = o.rightX, u = p.startY - p.minTopY, n = B * 2.5, h = Math.min(p.verticalStep, Math.max(n, u / 3)), l = u >= n ? Math.min(3, Math.floor(u / h)) : 0;
214
67
  for (let t = 1; t <= l; t++) {
215
- const i = d.startY - t * h + T.yOffset, s = a - t * d.baseSpacing * 0.5, u = r + t * d.baseSpacing * 0.5;
216
- A.push({
68
+ const i = p.startY - t * h + A.yOffset, s = r - t * p.baseSpacing * 0.5, f = a + t * p.baseSpacing * 0.5;
69
+ E.push({
217
70
  x: e(s),
218
71
  y: i,
219
- radius: E
72
+ radius: B
220
73
  }, {
221
- x: e(u),
74
+ x: e(f),
222
75
  y: i,
223
- radius: E
76
+ radius: B
224
77
  });
225
78
  }
226
79
  for (let t = 0; t < l; t++) {
227
- const i = d.startY - t * h, s = d.startY - (t + 1) * h, u = a - t * d.baseSpacing * 0.5, m = a - (t + 1) * d.baseSpacing * 0.5, x = r + t * d.baseSpacing * 0.5, P = r + (t + 1) * d.baseSpacing * 0.5;
228
- A.push({
229
- x: e((u + m) / 2),
230
- y: (i + s) / 2 + T.yOffset,
231
- radius: E
80
+ const i = p.startY - t * h, s = p.startY - (t + 1) * h, f = r - t * p.baseSpacing * 0.5, m = r - (t + 1) * p.baseSpacing * 0.5, x = a + t * p.baseSpacing * 0.5, P = a + (t + 1) * p.baseSpacing * 0.5;
81
+ E.push({
82
+ x: e((f + m) / 2),
83
+ y: (i + s) / 2 + A.yOffset,
84
+ radius: B
232
85
  }, {
233
86
  x: e((x + P) / 2),
234
- y: (i + s) / 2 + T.yOffset,
235
- radius: E
87
+ y: (i + s) / 2 + A.yOffset,
88
+ radius: B
236
89
  });
237
90
  }
238
- for (let t = 0; t < d.rows - 1; t++) {
239
- const i = d.rowAnchors[t], s = d.rowAnchors[t + 1], u = (i.y + s.y) / 2 + T.yOffset;
240
- A.push({
91
+ for (let t = 0; t < p.rows - 1; t++) {
92
+ const i = p.rowAnchors[t], s = p.rowAnchors[t + 1], f = (i.y + s.y) / 2 + A.yOffset;
93
+ E.push({
241
94
  x: e((i.leftX + s.leftX) / 2),
242
- y: u,
243
- radius: E
95
+ y: f,
96
+ radius: B
244
97
  }, {
245
98
  x: e((i.rightX + s.rightX) / 2),
246
- y: u,
247
- radius: E
99
+ y: f,
100
+ radius: B
248
101
  });
249
102
  }
250
- return A;
103
+ return E;
251
104
  }
252
- var We = -1, Ge = 8;
253
- function ze(d) {
254
- const { mainPegs: E, ballRadius: T, heightPolicy: A } = d;
255
- if (Ke(A), $e(E), !Number.isFinite(T) || T <= 0) throw new Error("ballRadius must be greater than 0");
256
- const f = Se(E, 600);
257
- if (f.baseSpacing <= 0) throw new Error("mainPegs produce non-positive base spacing; reduce sidePaddingPx or peg counts");
258
- const { rows: e, baseSpacing: o, targetVerticalStep: a } = f, r = a * Math.max(e - 1, 0), c = A.topPaddingPx, n = a * 2, h = T * 2 + Ge, l = E.radius + T + We, t = Math.max(A.bottomPaddingPx, l + h);
105
+ var Ee = -1, Ie = 8;
106
+ function Le(p) {
107
+ const { mainPegs: B, ballRadius: A, heightPolicy: E } = p;
108
+ if (ke(E), be(B), !Number.isFinite(A) || A <= 0) throw new Error("ballRadius must be greater than 0");
109
+ const c = me(B, 600);
110
+ if (c.baseSpacing <= 0) throw new Error("mainPegs produce non-positive base spacing; reduce sidePaddingPx or peg counts");
111
+ const { rows: e, baseSpacing: o, targetVerticalStep: r } = c, a = r * Math.max(e - 1, 0), u = E.topPaddingPx, n = r * 2, h = A * 2 + Ie, l = B.radius + A + Ee, t = Math.max(E.bottomPaddingPx, l + h);
259
112
  return {
260
- worldHeight: c + n + r + t,
113
+ worldHeight: u + n + a + t,
261
114
  resolvedMainPegs: {
262
- ...E,
263
- topPaddingPx: c,
115
+ ...B,
116
+ topPaddingPx: u,
264
117
  bottomPaddingPx: t
265
118
  },
266
119
  rows: e,
267
120
  baseSpacing: o,
268
- verticalStep: a,
121
+ verticalStep: r,
269
122
  requiredBottomPaddingPx: t
270
123
  };
271
124
  }
272
- function Xe(d) {
273
- const { parentWidthPx: E, viewport: T, worldHeight: A } = d;
274
- if (Ye(T), !Number.isFinite(E) || E <= 0) throw new Error("Parent width must be greater than 0");
275
- if (!Number.isFinite(A) || A <= 0) throw new Error("World height must be greater than 0");
276
- const f = E;
125
+ function Re(p) {
126
+ const { parentWidthPx: B, viewport: A, worldHeight: E } = p;
127
+ if (De(A), !Number.isFinite(B) || B <= 0) throw new Error("Parent width must be greater than 0");
128
+ if (!Number.isFinite(E) || E <= 0) throw new Error("World height must be greater than 0");
129
+ const c = B;
277
130
  return {
278
- displayWidth: f,
279
- displayHeight: f * (A / 600),
280
- worldScale: f / 600
131
+ displayWidth: c,
132
+ displayHeight: c * (E / 600),
133
+ worldScale: c / 600
281
134
  };
282
135
  }
283
- function Ke(d) {
284
- if (!Number.isFinite(d.topPaddingPx) || d.topPaddingPx < 0) throw new Error("viewport.heightPolicy.topPaddingPx must be >= 0");
285
- if (!Number.isFinite(d.bottomPaddingPx) || d.bottomPaddingPx < 0) throw new Error("viewport.heightPolicy.bottomPaddingPx must be >= 0");
136
+ function ke(p) {
137
+ if (!Number.isFinite(p.topPaddingPx) || p.topPaddingPx < 0) throw new Error("viewport.heightPolicy.topPaddingPx must be >= 0");
138
+ if (!Number.isFinite(p.bottomPaddingPx) || p.bottomPaddingPx < 0) throw new Error("viewport.heightPolicy.bottomPaddingPx must be >= 0");
286
139
  }
287
- function Ye(d) {
288
- if (!Number.isFinite(d.dprCap) || d.dprCap <= 0) throw new Error("viewport.dprCap must be greater than 0");
140
+ function De(p) {
141
+ if (!Number.isFinite(p.dprCap) || p.dprCap <= 0) throw new Error("viewport.dprCap must be greater than 0");
289
142
  }
290
- function $e(d) {
291
- if (!Number.isFinite(d.radius) || d.radius <= 0) throw new Error("layout.mainPegs.radius must be greater than 0");
292
- if (!Number.isFinite(d.topPegCount) || d.topPegCount < 1) throw new Error("layout.mainPegs.topPegCount must be >= 1");
293
- if (!Number.isFinite(d.bottomPegCount) || d.bottomPegCount < d.topPegCount) throw new Error("layout.mainPegs.bottomPegCount must be >= topPegCount");
294
- if (!Number.isFinite(d.verticalStepRatio) || d.verticalStepRatio <= 0) throw new Error("layout.mainPegs.verticalStepRatio must be > 0");
295
- if (!Number.isFinite(d.sidePaddingPx) || d.sidePaddingPx < 0) throw new Error("layout.mainPegs.sidePaddingPx must be >= 0");
143
+ function be(p) {
144
+ if (!Number.isFinite(p.radius) || p.radius <= 0) throw new Error("layout.mainPegs.radius must be greater than 0");
145
+ if (!Number.isFinite(p.topPegCount) || p.topPegCount < 1) throw new Error("layout.mainPegs.topPegCount must be >= 1");
146
+ if (!Number.isFinite(p.bottomPegCount) || p.bottomPegCount < p.topPegCount) throw new Error("layout.mainPegs.bottomPegCount must be >= topPegCount");
147
+ if (!Number.isFinite(p.verticalStepRatio) || p.verticalStepRatio <= 0) throw new Error("layout.mainPegs.verticalStepRatio must be > 0");
148
+ if (!Number.isFinite(p.sidePaddingPx) || p.sidePaddingPx < 0) throw new Error("layout.mainPegs.sidePaddingPx must be >= 0");
296
149
  }
297
- var Qe = /* @__PURE__ */ Be(((d, E) => {
298
- (function(A, f) {
299
- typeof d == "object" && typeof E == "object" ? E.exports = f() : typeof define == "function" && define.amd ? define("Matter", [], f) : typeof d == "object" ? d.Matter = f() : A.Matter = f();
300
- })(d, function() {
301
- return (function(T) {
302
- var A = {};
303
- function f(e) {
304
- if (A[e]) return A[e].exports;
305
- var o = A[e] = {
150
+ var Fe = /* @__PURE__ */ Ce(((p, B) => {
151
+ (function(E, c) {
152
+ typeof p == "object" && typeof B == "object" ? B.exports = c() : typeof define == "function" && define.amd ? define("Matter", [], c) : typeof p == "object" ? p.Matter = c() : E.Matter = c();
153
+ })(p, function() {
154
+ return (function(A) {
155
+ var E = {};
156
+ function c(e) {
157
+ if (E[e]) return E[e].exports;
158
+ var o = E[e] = {
306
159
  i: e,
307
160
  l: !1,
308
161
  exports: {}
309
162
  };
310
- return T[e].call(o.exports, o, o.exports, f), o.l = !0, o.exports;
163
+ return A[e].call(o.exports, o, o.exports, c), o.l = !0, o.exports;
311
164
  }
312
- return f.m = T, f.c = A, f.d = function(e, o, a) {
313
- f.o(e, o) || Object.defineProperty(e, o, {
165
+ return c.m = A, c.c = E, c.d = function(e, o, r) {
166
+ c.o(e, o) || Object.defineProperty(e, o, {
314
167
  enumerable: !0,
315
- get: a
168
+ get: r
316
169
  });
317
- }, f.r = function(e) {
170
+ }, c.r = function(e) {
318
171
  typeof Symbol < "u" && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e, "__esModule", { value: !0 });
319
- }, f.t = function(e, o) {
320
- if (o & 1 && (e = f(e)), o & 8 || o & 4 && typeof e == "object" && e && e.__esModule) return e;
321
- var a = /* @__PURE__ */ Object.create(null);
322
- if (f.r(a), Object.defineProperty(a, "default", {
172
+ }, c.t = function(e, o) {
173
+ if (o & 1 && (e = c(e)), o & 8 || o & 4 && typeof e == "object" && e && e.__esModule) return e;
174
+ var r = /* @__PURE__ */ Object.create(null);
175
+ if (c.r(r), Object.defineProperty(r, "default", {
323
176
  enumerable: !0,
324
177
  value: e
325
- }), o & 2 && typeof e != "string") for (var r in e) f.d(a, r, function(c) {
326
- return e[c];
327
- }.bind(null, r));
328
- return a;
329
- }, f.n = function(e) {
178
+ }), o & 2 && typeof e != "string") for (var a in e) c.d(r, a, function(u) {
179
+ return e[u];
180
+ }.bind(null, a));
181
+ return r;
182
+ }, c.n = function(e) {
330
183
  var o = e && e.__esModule ? function() {
331
184
  return e.default;
332
185
  } : function() {
333
186
  return e;
334
187
  };
335
- return f.d(o, "a", o), o;
336
- }, f.o = function(e, o) {
188
+ return c.d(o, "a", o), o;
189
+ }, c.o = function(e, o) {
337
190
  return Object.prototype.hasOwnProperty.call(e, o);
338
- }, f.p = "", f(f.s = 20);
191
+ }, c.p = "", c(c.s = 20);
339
192
  })([
340
- (function(T, A) {
341
- var f = {};
342
- T.exports = f, (function() {
343
- f._baseDelta = 1e3 / 60, f._nextId = 0, f._seed = 0, f._nowStartTime = +/* @__PURE__ */ new Date(), f._warnedOnce = {}, f._decomp = null, f.extend = function(o, a) {
344
- var r, c;
345
- typeof a == "boolean" ? (r = 2, c = a) : (r = 1, c = !0);
346
- for (var n = r; n < arguments.length; n++) {
193
+ (function(A, E) {
194
+ var c = {};
195
+ A.exports = c, (function() {
196
+ c._baseDelta = 1e3 / 60, c._nextId = 0, c._seed = 0, c._nowStartTime = +/* @__PURE__ */ new Date(), c._warnedOnce = {}, c._decomp = null, c.extend = function(o, r) {
197
+ var a, u;
198
+ typeof r == "boolean" ? (a = 2, u = r) : (a = 1, u = !0);
199
+ for (var n = a; n < arguments.length; n++) {
347
200
  var h = arguments[n];
348
- if (h) for (var l in h) c && h[l] && h[l].constructor === Object && (!o[l] || o[l].constructor === Object) ? (o[l] = o[l] || {}, f.extend(o[l], c, h[l])) : o[l] = h[l];
201
+ if (h) for (var l in h) u && h[l] && h[l].constructor === Object && (!o[l] || o[l].constructor === Object) ? (o[l] = o[l] || {}, c.extend(o[l], u, h[l])) : o[l] = h[l];
349
202
  }
350
203
  return o;
351
- }, f.clone = function(o, a) {
352
- return f.extend({}, a, o);
353
- }, f.keys = function(o) {
204
+ }, c.clone = function(o, r) {
205
+ return c.extend({}, r, o);
206
+ }, c.keys = function(o) {
354
207
  if (Object.keys) return Object.keys(o);
355
- var a = [];
356
- for (var r in o) a.push(r);
357
- return a;
358
- }, f.values = function(o) {
359
- var a = [];
208
+ var r = [];
209
+ for (var a in o) r.push(a);
210
+ return r;
211
+ }, c.values = function(o) {
212
+ var r = [];
360
213
  if (Object.keys) {
361
- for (var r = Object.keys(o), c = 0; c < r.length; c++) a.push(o[r[c]]);
362
- return a;
214
+ for (var a = Object.keys(o), u = 0; u < a.length; u++) r.push(o[a[u]]);
215
+ return r;
363
216
  }
364
- for (var n in o) a.push(o[n]);
365
- return a;
366
- }, f.get = function(o, a, r, c) {
367
- a = a.split(".").slice(r, c);
368
- for (var n = 0; n < a.length; n += 1) o = o[a[n]];
217
+ for (var n in o) r.push(o[n]);
218
+ return r;
219
+ }, c.get = function(o, r, a, u) {
220
+ r = r.split(".").slice(a, u);
221
+ for (var n = 0; n < r.length; n += 1) o = o[r[n]];
369
222
  return o;
370
- }, f.set = function(o, a, r, c, n) {
371
- var h = a.split(".").slice(c, n);
372
- return f.get(o, a, 0, -1)[h[h.length - 1]] = r, r;
373
- }, f.shuffle = function(o) {
374
- for (var a = o.length - 1; a > 0; a--) {
375
- var r = Math.floor(f.random() * (a + 1)), c = o[a];
376
- o[a] = o[r], o[r] = c;
223
+ }, c.set = function(o, r, a, u, n) {
224
+ var h = r.split(".").slice(u, n);
225
+ return c.get(o, r, 0, -1)[h[h.length - 1]] = a, a;
226
+ }, c.shuffle = function(o) {
227
+ for (var r = o.length - 1; r > 0; r--) {
228
+ var a = Math.floor(c.random() * (r + 1)), u = o[r];
229
+ o[r] = o[a], o[a] = u;
377
230
  }
378
231
  return o;
379
- }, f.choose = function(o) {
380
- return o[Math.floor(f.random() * o.length)];
381
- }, f.isElement = function(o) {
232
+ }, c.choose = function(o) {
233
+ return o[Math.floor(c.random() * o.length)];
234
+ }, c.isElement = function(o) {
382
235
  return typeof HTMLElement < "u" ? o instanceof HTMLElement : !!(o && o.nodeType && o.nodeName);
383
- }, f.isArray = function(o) {
236
+ }, c.isArray = function(o) {
384
237
  return Object.prototype.toString.call(o) === "[object Array]";
385
- }, f.isFunction = function(o) {
238
+ }, c.isFunction = function(o) {
386
239
  return typeof o == "function";
387
- }, f.isPlainObject = function(o) {
240
+ }, c.isPlainObject = function(o) {
388
241
  return typeof o == "object" && o.constructor === Object;
389
- }, f.isString = function(o) {
242
+ }, c.isString = function(o) {
390
243
  return toString.call(o) === "[object String]";
391
- }, f.clamp = function(o, a, r) {
392
- return o < a ? a : o > r ? r : o;
393
- }, f.sign = function(o) {
244
+ }, c.clamp = function(o, r, a) {
245
+ return o < r ? r : o > a ? a : o;
246
+ }, c.sign = function(o) {
394
247
  return o < 0 ? -1 : 1;
395
- }, f.now = function() {
248
+ }, c.now = function() {
396
249
  if (typeof window < "u" && window.performance) {
397
250
  if (window.performance.now) return window.performance.now();
398
251
  if (window.performance.webkitNow) return window.performance.webkitNow();
399
252
  }
400
- return Date.now ? Date.now() : /* @__PURE__ */ new Date() - f._nowStartTime;
401
- }, f.random = function(o, a) {
402
- return o = typeof o < "u" ? o : 0, a = typeof a < "u" ? a : 1, o + e() * (a - o);
253
+ return Date.now ? Date.now() : /* @__PURE__ */ new Date() - c._nowStartTime;
254
+ }, c.random = function(o, r) {
255
+ return o = typeof o < "u" ? o : 0, r = typeof r < "u" ? r : 1, o + e() * (r - o);
403
256
  };
404
257
  var e = function() {
405
- return f._seed = (f._seed * 9301 + 49297) % 233280, f._seed / 233280;
258
+ return c._seed = (c._seed * 9301 + 49297) % 233280, c._seed / 233280;
406
259
  };
407
- f.colorToNumber = function(o) {
260
+ c.colorToNumber = function(o) {
408
261
  return o = o.replace("#", ""), o.length == 3 && (o = o.charAt(0) + o.charAt(0) + o.charAt(1) + o.charAt(1) + o.charAt(2) + o.charAt(2)), parseInt(o, 16);
409
- }, f.logLevel = 1, f.log = function() {
410
- console && f.logLevel > 0 && f.logLevel <= 3 && console.log.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
411
- }, f.info = function() {
412
- console && f.logLevel > 0 && f.logLevel <= 2 && console.info.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
413
- }, f.warn = function() {
414
- console && f.logLevel > 0 && f.logLevel <= 3 && console.warn.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
415
- }, f.warnOnce = function() {
262
+ }, c.logLevel = 1, c.log = function() {
263
+ console && c.logLevel > 0 && c.logLevel <= 3 && console.log.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
264
+ }, c.info = function() {
265
+ console && c.logLevel > 0 && c.logLevel <= 2 && console.info.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
266
+ }, c.warn = function() {
267
+ console && c.logLevel > 0 && c.logLevel <= 3 && console.warn.apply(console, ["matter-js:"].concat(Array.prototype.slice.call(arguments)));
268
+ }, c.warnOnce = function() {
416
269
  var o = Array.prototype.slice.call(arguments).join(" ");
417
- f._warnedOnce[o] || (f.warn(o), f._warnedOnce[o] = !0);
418
- }, f.deprecated = function(o, a, r) {
419
- o[a] = f.chain(function() {
420
- f.warnOnce("🔅 deprecated 🔅", r);
421
- }, o[a]);
422
- }, f.nextId = function() {
423
- return f._nextId++;
424
- }, f.indexOf = function(o, a) {
425
- if (o.indexOf) return o.indexOf(a);
426
- for (var r = 0; r < o.length; r++) if (o[r] === a) return r;
270
+ c._warnedOnce[o] || (c.warn(o), c._warnedOnce[o] = !0);
271
+ }, c.deprecated = function(o, r, a) {
272
+ o[r] = c.chain(function() {
273
+ c.warnOnce("🔅 deprecated 🔅", a);
274
+ }, o[r]);
275
+ }, c.nextId = function() {
276
+ return c._nextId++;
277
+ }, c.indexOf = function(o, r) {
278
+ if (o.indexOf) return o.indexOf(r);
279
+ for (var a = 0; a < o.length; a++) if (o[a] === r) return a;
427
280
  return -1;
428
- }, f.map = function(o, a) {
429
- if (o.map) return o.map(a);
430
- for (var r = [], c = 0; c < o.length; c += 1) r.push(a(o[c]));
431
- return r;
432
- }, f.topologicalSort = function(o) {
433
- var a = [], r = [], c = [];
434
- for (var n in o) !r[n] && !c[n] && f._topologicalSort(n, r, c, o, a);
281
+ }, c.map = function(o, r) {
282
+ if (o.map) return o.map(r);
283
+ for (var a = [], u = 0; u < o.length; u += 1) a.push(r(o[u]));
435
284
  return a;
436
- }, f._topologicalSort = function(o, a, r, c, n) {
437
- var h = c[o] || [];
438
- r[o] = !0;
285
+ }, c.topologicalSort = function(o) {
286
+ var r = [], a = [], u = [];
287
+ for (var n in o) !a[n] && !u[n] && c._topologicalSort(n, a, u, o, r);
288
+ return r;
289
+ }, c._topologicalSort = function(o, r, a, u, n) {
290
+ var h = u[o] || [];
291
+ a[o] = !0;
439
292
  for (var l = 0; l < h.length; l += 1) {
440
293
  var t = h[l];
441
- r[t] || a[t] || f._topologicalSort(t, a, r, c, n);
294
+ a[t] || r[t] || c._topologicalSort(t, r, a, u, n);
442
295
  }
443
- r[o] = !1, a[o] = !0, n.push(o);
444
- }, f.chain = function() {
445
- for (var o = [], a = 0; a < arguments.length; a += 1) {
446
- var r = arguments[a];
447
- r._chained ? o.push.apply(o, r._chained) : o.push(r);
296
+ a[o] = !1, r[o] = !0, n.push(o);
297
+ }, c.chain = function() {
298
+ for (var o = [], r = 0; r < arguments.length; r += 1) {
299
+ var a = arguments[r];
300
+ a._chained ? o.push.apply(o, a._chained) : o.push(a);
448
301
  }
449
- var c = function() {
302
+ var u = function() {
450
303
  for (var n, h = new Array(arguments.length), l = 0, t = arguments.length; l < t; l++) h[l] = arguments[l];
451
304
  for (l = 0; l < o.length; l += 1) {
452
305
  var i = o[l].apply(n, h);
@@ -454,15 +307,15 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
454
307
  }
455
308
  return n;
456
309
  };
457
- return c._chained = o, c;
458
- }, f.chainPathBefore = function(o, a, r) {
459
- return f.set(o, a, f.chain(r, f.get(o, a)));
460
- }, f.chainPathAfter = function(o, a, r) {
461
- return f.set(o, a, f.chain(f.get(o, a), r));
462
- }, f.setDecomp = function(o) {
463
- f._decomp = o;
464
- }, f.getDecomp = function() {
465
- var o = f._decomp;
310
+ return u._chained = o, u;
311
+ }, c.chainPathBefore = function(o, r, a) {
312
+ return c.set(o, r, c.chain(a, c.get(o, r)));
313
+ }, c.chainPathAfter = function(o, r, a) {
314
+ return c.set(o, r, c.chain(c.get(o, r), a));
315
+ }, c.setDecomp = function(o) {
316
+ c._decomp = o;
317
+ }, c.getDecomp = function() {
318
+ var o = c._decomp;
466
319
  try {
467
320
  !o && typeof window < "u" && (o = window.decomp), !o && typeof global < "u" && (o = global.decomp);
468
321
  } catch {
@@ -472,10 +325,10 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
472
325
  };
473
326
  })();
474
327
  }),
475
- (function(T, A) {
476
- var f = {};
477
- T.exports = f, (function() {
478
- f.create = function(e) {
328
+ (function(A, E) {
329
+ var c = {};
330
+ A.exports = c, (function() {
331
+ c.create = function(e) {
479
332
  var o = {
480
333
  min: {
481
334
  x: 0,
@@ -486,55 +339,55 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
486
339
  y: 0
487
340
  }
488
341
  };
489
- return e && f.update(o, e), o;
490
- }, f.update = function(e, o, a) {
342
+ return e && c.update(o, e), o;
343
+ }, c.update = function(e, o, r) {
491
344
  e.min.x = 1 / 0, e.max.x = -1 / 0, e.min.y = 1 / 0, e.max.y = -1 / 0;
492
- for (var r = 0; r < o.length; r++) {
493
- var c = o[r];
494
- c.x > e.max.x && (e.max.x = c.x), c.x < e.min.x && (e.min.x = c.x), c.y > e.max.y && (e.max.y = c.y), c.y < e.min.y && (e.min.y = c.y);
345
+ for (var a = 0; a < o.length; a++) {
346
+ var u = o[a];
347
+ u.x > e.max.x && (e.max.x = u.x), u.x < e.min.x && (e.min.x = u.x), u.y > e.max.y && (e.max.y = u.y), u.y < e.min.y && (e.min.y = u.y);
495
348
  }
496
- a && (a.x > 0 ? e.max.x += a.x : e.min.x += a.x, a.y > 0 ? e.max.y += a.y : e.min.y += a.y);
497
- }, f.contains = function(e, o) {
349
+ r && (r.x > 0 ? e.max.x += r.x : e.min.x += r.x, r.y > 0 ? e.max.y += r.y : e.min.y += r.y);
350
+ }, c.contains = function(e, o) {
498
351
  return o.x >= e.min.x && o.x <= e.max.x && o.y >= e.min.y && o.y <= e.max.y;
499
- }, f.overlaps = function(e, o) {
352
+ }, c.overlaps = function(e, o) {
500
353
  return e.min.x <= o.max.x && e.max.x >= o.min.x && e.max.y >= o.min.y && e.min.y <= o.max.y;
501
- }, f.translate = function(e, o) {
354
+ }, c.translate = function(e, o) {
502
355
  e.min.x += o.x, e.max.x += o.x, e.min.y += o.y, e.max.y += o.y;
503
- }, f.shift = function(e, o) {
504
- var a = e.max.x - e.min.x, r = e.max.y - e.min.y;
505
- e.min.x = o.x, e.max.x = o.x + a, e.min.y = o.y, e.max.y = o.y + r;
356
+ }, c.shift = function(e, o) {
357
+ var r = e.max.x - e.min.x, a = e.max.y - e.min.y;
358
+ e.min.x = o.x, e.max.x = o.x + r, e.min.y = o.y, e.max.y = o.y + a;
506
359
  };
507
360
  })();
508
361
  }),
509
- (function(T, A) {
510
- var f = {};
511
- T.exports = f, (function() {
512
- f.create = function(e, o) {
362
+ (function(A, E) {
363
+ var c = {};
364
+ A.exports = c, (function() {
365
+ c.create = function(e, o) {
513
366
  return {
514
367
  x: e || 0,
515
368
  y: o || 0
516
369
  };
517
- }, f.clone = function(e) {
370
+ }, c.clone = function(e) {
518
371
  return {
519
372
  x: e.x,
520
373
  y: e.y
521
374
  };
522
- }, f.magnitude = function(e) {
375
+ }, c.magnitude = function(e) {
523
376
  return Math.sqrt(e.x * e.x + e.y * e.y);
524
- }, f.magnitudeSquared = function(e) {
377
+ }, c.magnitudeSquared = function(e) {
525
378
  return e.x * e.x + e.y * e.y;
526
- }, f.rotate = function(e, o, a) {
527
- var r = Math.cos(o), c = Math.sin(o);
528
- a || (a = {});
529
- var n = e.x * r - e.y * c;
530
- return a.y = e.x * c + e.y * r, a.x = n, a;
531
- }, f.rotateAbout = function(e, o, a, r) {
532
- var c = Math.cos(o), n = Math.sin(o);
379
+ }, c.rotate = function(e, o, r) {
380
+ var a = Math.cos(o), u = Math.sin(o);
533
381
  r || (r = {});
534
- var h = a.x + ((e.x - a.x) * c - (e.y - a.y) * n);
535
- return r.y = a.y + ((e.x - a.x) * n + (e.y - a.y) * c), r.x = h, r;
536
- }, f.normalise = function(e) {
537
- var o = f.magnitude(e);
382
+ var n = e.x * a - e.y * u;
383
+ return r.y = e.x * u + e.y * a, r.x = n, r;
384
+ }, c.rotateAbout = function(e, o, r, a) {
385
+ var u = Math.cos(o), n = Math.sin(o);
386
+ a || (a = {});
387
+ var h = r.x + ((e.x - r.x) * u - (e.y - r.y) * n);
388
+ return a.y = r.y + ((e.x - r.x) * n + (e.y - r.y) * u), a.x = h, a;
389
+ }, c.normalise = function(e) {
390
+ var o = c.magnitude(e);
538
391
  return o === 0 ? {
539
392
  x: 0,
540
393
  y: 0
@@ -542,175 +395,175 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
542
395
  x: e.x / o,
543
396
  y: e.y / o
544
397
  };
545
- }, f.dot = function(e, o) {
398
+ }, c.dot = function(e, o) {
546
399
  return e.x * o.x + e.y * o.y;
547
- }, f.cross = function(e, o) {
400
+ }, c.cross = function(e, o) {
548
401
  return e.x * o.y - e.y * o.x;
549
- }, f.cross3 = function(e, o, a) {
550
- return (o.x - e.x) * (a.y - e.y) - (o.y - e.y) * (a.x - e.x);
551
- }, f.add = function(e, o, a) {
552
- return a || (a = {}), a.x = e.x + o.x, a.y = e.y + o.y, a;
553
- }, f.sub = function(e, o, a) {
554
- return a || (a = {}), a.x = e.x - o.x, a.y = e.y - o.y, a;
555
- }, f.mult = function(e, o) {
402
+ }, c.cross3 = function(e, o, r) {
403
+ return (o.x - e.x) * (r.y - e.y) - (o.y - e.y) * (r.x - e.x);
404
+ }, c.add = function(e, o, r) {
405
+ return r || (r = {}), r.x = e.x + o.x, r.y = e.y + o.y, r;
406
+ }, c.sub = function(e, o, r) {
407
+ return r || (r = {}), r.x = e.x - o.x, r.y = e.y - o.y, r;
408
+ }, c.mult = function(e, o) {
556
409
  return {
557
410
  x: e.x * o,
558
411
  y: e.y * o
559
412
  };
560
- }, f.div = function(e, o) {
413
+ }, c.div = function(e, o) {
561
414
  return {
562
415
  x: e.x / o,
563
416
  y: e.y / o
564
417
  };
565
- }, f.perp = function(e, o) {
418
+ }, c.perp = function(e, o) {
566
419
  return o = o === !0 ? -1 : 1, {
567
420
  x: o * -e.y,
568
421
  y: o * e.x
569
422
  };
570
- }, f.neg = function(e) {
423
+ }, c.neg = function(e) {
571
424
  return {
572
425
  x: -e.x,
573
426
  y: -e.y
574
427
  };
575
- }, f.angle = function(e, o) {
428
+ }, c.angle = function(e, o) {
576
429
  return Math.atan2(o.y - e.y, o.x - e.x);
577
- }, f._temp = [
578
- f.create(),
579
- f.create(),
580
- f.create(),
581
- f.create(),
582
- f.create(),
583
- f.create()
430
+ }, c._temp = [
431
+ c.create(),
432
+ c.create(),
433
+ c.create(),
434
+ c.create(),
435
+ c.create(),
436
+ c.create()
584
437
  ];
585
438
  })();
586
439
  }),
587
- (function(T, A, f) {
440
+ (function(A, E, c) {
588
441
  var e = {};
589
- T.exports = e;
590
- var o = f(2), a = f(0);
442
+ A.exports = e;
443
+ var o = c(2), r = c(0);
591
444
  (function() {
592
- e.create = function(r, c) {
593
- for (var n = [], h = 0; h < r.length; h++) {
594
- var l = r[h], t = {
445
+ e.create = function(a, u) {
446
+ for (var n = [], h = 0; h < a.length; h++) {
447
+ var l = a[h], t = {
595
448
  x: l.x,
596
449
  y: l.y,
597
450
  index: h,
598
- body: c,
451
+ body: u,
599
452
  isInternal: !1
600
453
  };
601
454
  n.push(t);
602
455
  }
603
456
  return n;
604
- }, e.fromPath = function(r, c) {
457
+ }, e.fromPath = function(a, u) {
605
458
  var n = /L?\s*([-\d.e]+)[\s,]*([-\d.e]+)*/gi, h = [];
606
- return r.replace(n, function(l, t, i) {
459
+ return a.replace(n, function(l, t, i) {
607
460
  h.push({
608
461
  x: parseFloat(t),
609
462
  y: parseFloat(i)
610
463
  });
611
- }), e.create(h, c);
612
- }, e.centre = function(r) {
613
- for (var c = e.area(r, !0), n = {
464
+ }), e.create(h, u);
465
+ }, e.centre = function(a) {
466
+ for (var u = e.area(a, !0), n = {
614
467
  x: 0,
615
468
  y: 0
616
- }, h, l, t, i = 0; i < r.length; i++)
617
- t = (i + 1) % r.length, h = o.cross(r[i], r[t]), l = o.mult(o.add(r[i], r[t]), h), n = o.add(n, l);
618
- return o.div(n, 6 * c);
619
- }, e.mean = function(r) {
620
- for (var c = {
469
+ }, h, l, t, i = 0; i < a.length; i++)
470
+ t = (i + 1) % a.length, h = o.cross(a[i], a[t]), l = o.mult(o.add(a[i], a[t]), h), n = o.add(n, l);
471
+ return o.div(n, 6 * u);
472
+ }, e.mean = function(a) {
473
+ for (var u = {
621
474
  x: 0,
622
475
  y: 0
623
- }, n = 0; n < r.length; n++)
624
- c.x += r[n].x, c.y += r[n].y;
625
- return o.div(c, r.length);
626
- }, e.area = function(r, c) {
627
- for (var n = 0, h = r.length - 1, l = 0; l < r.length; l++)
628
- n += (r[h].x - r[l].x) * (r[h].y + r[l].y), h = l;
629
- return c ? n / 2 : Math.abs(n) / 2;
630
- }, e.inertia = function(r, c) {
631
- for (var n = 0, h = 0, l = r, t, i, s = 0; s < l.length; s++)
476
+ }, n = 0; n < a.length; n++)
477
+ u.x += a[n].x, u.y += a[n].y;
478
+ return o.div(u, a.length);
479
+ }, e.area = function(a, u) {
480
+ for (var n = 0, h = a.length - 1, l = 0; l < a.length; l++)
481
+ n += (a[h].x - a[l].x) * (a[h].y + a[l].y), h = l;
482
+ return u ? n / 2 : Math.abs(n) / 2;
483
+ }, e.inertia = function(a, u) {
484
+ for (var n = 0, h = 0, l = a, t, i, s = 0; s < l.length; s++)
632
485
  i = (s + 1) % l.length, t = Math.abs(o.cross(l[i], l[s])), n += t * (o.dot(l[i], l[i]) + o.dot(l[i], l[s]) + o.dot(l[s], l[s])), h += t;
633
- return c / 6 * (n / h);
634
- }, e.translate = function(r, c, n) {
486
+ return u / 6 * (n / h);
487
+ }, e.translate = function(a, u, n) {
635
488
  n = typeof n < "u" ? n : 1;
636
- var h = r.length, l = c.x * n, t = c.y * n, i;
489
+ var h = a.length, l = u.x * n, t = u.y * n, i;
637
490
  for (i = 0; i < h; i++)
638
- r[i].x += l, r[i].y += t;
639
- return r;
640
- }, e.rotate = function(r, c, n) {
641
- if (c !== 0) {
642
- var h = Math.cos(c), l = Math.sin(c), t = n.x, i = n.y, s = r.length, u, m, x, P;
491
+ a[i].x += l, a[i].y += t;
492
+ return a;
493
+ }, e.rotate = function(a, u, n) {
494
+ if (u !== 0) {
495
+ var h = Math.cos(u), l = Math.sin(u), t = n.x, i = n.y, s = a.length, f, m, x, P;
643
496
  for (P = 0; P < s; P++)
644
- u = r[P], m = u.x - t, x = u.y - i, u.x = t + (m * h - x * l), u.y = i + (m * l + x * h);
645
- return r;
497
+ f = a[P], m = f.x - t, x = f.y - i, f.x = t + (m * h - x * l), f.y = i + (m * l + x * h);
498
+ return a;
646
499
  }
647
- }, e.contains = function(r, c) {
648
- for (var n = c.x, h = c.y, l = r.length, t = r[l - 1], i, s = 0; s < l; s++) {
649
- if (i = r[s], (n - t.x) * (i.y - t.y) + (h - t.y) * (t.x - i.x) > 0) return !1;
500
+ }, e.contains = function(a, u) {
501
+ for (var n = u.x, h = u.y, l = a.length, t = a[l - 1], i, s = 0; s < l; s++) {
502
+ if (i = a[s], (n - t.x) * (i.y - t.y) + (h - t.y) * (t.x - i.x) > 0) return !1;
650
503
  t = i;
651
504
  }
652
505
  return !0;
653
- }, e.scale = function(r, c, n, h) {
654
- if (c === 1 && n === 1) return r;
655
- h = h || e.centre(r);
656
- for (var l, t, i = 0; i < r.length; i++)
657
- l = r[i], t = o.sub(l, h), r[i].x = h.x + t.x * c, r[i].y = h.y + t.y * n;
658
- return r;
659
- }, e.chamfer = function(r, c, n, h, l) {
660
- typeof c == "number" ? c = [c] : c = c || [8], n = typeof n < "u" ? n : -1, h = h || 2, l = l || 14;
661
- for (var t = [], i = 0; i < r.length; i++) {
662
- var s = r[i - 1 >= 0 ? i - 1 : r.length - 1], u = r[i], m = r[(i + 1) % r.length], x = c[i < c.length ? i : c.length - 1];
506
+ }, e.scale = function(a, u, n, h) {
507
+ if (u === 1 && n === 1) return a;
508
+ h = h || e.centre(a);
509
+ for (var l, t, i = 0; i < a.length; i++)
510
+ l = a[i], t = o.sub(l, h), a[i].x = h.x + t.x * u, a[i].y = h.y + t.y * n;
511
+ return a;
512
+ }, e.chamfer = function(a, u, n, h, l) {
513
+ typeof u == "number" ? u = [u] : u = u || [8], n = typeof n < "u" ? n : -1, h = h || 2, l = l || 14;
514
+ for (var t = [], i = 0; i < a.length; i++) {
515
+ var s = a[i - 1 >= 0 ? i - 1 : a.length - 1], f = a[i], m = a[(i + 1) % a.length], x = u[i < u.length ? i : u.length - 1];
663
516
  if (x === 0) {
664
- t.push(u);
517
+ t.push(f);
665
518
  continue;
666
519
  }
667
520
  var P = o.normalise({
668
- x: u.y - s.y,
669
- y: s.x - u.x
670
- }), B = o.normalise({
671
- x: m.y - u.y,
672
- y: u.x - m.x
673
- }), g = Math.sqrt(2 * Math.pow(x, 2)), p = o.mult(a.clone(P), x), y = o.normalise(o.mult(o.add(P, B), 0.5)), v = o.sub(u, o.mult(y, g)), w = n;
674
- n === -1 && (w = Math.pow(x, 0.32) * 1.75), w = a.clamp(w, h, l), w % 2 === 1 && (w += 1);
675
- for (var S = Math.acos(o.dot(P, B)) / w, C = 0; C < w; C++) t.push(o.add(o.rotate(p, S * C), v));
521
+ x: f.y - s.y,
522
+ y: s.x - f.x
523
+ }), T = o.normalise({
524
+ x: m.y - f.y,
525
+ y: f.x - m.x
526
+ }), g = Math.sqrt(2 * Math.pow(x, 2)), d = o.mult(r.clone(P), x), y = o.normalise(o.mult(o.add(P, T), 0.5)), v = o.sub(f, o.mult(y, g)), w = n;
527
+ n === -1 && (w = Math.pow(x, 0.32) * 1.75), w = r.clamp(w, h, l), w % 2 === 1 && (w += 1);
528
+ for (var S = Math.acos(o.dot(P, T)) / w, C = 0; C < w; C++) t.push(o.add(o.rotate(d, S * C), v));
676
529
  }
677
530
  return t;
678
- }, e.clockwiseSort = function(r) {
679
- var c = e.mean(r);
680
- return r.sort(function(n, h) {
681
- return o.angle(c, n) - o.angle(c, h);
682
- }), r;
683
- }, e.isConvex = function(r) {
684
- var c = 0, n = r.length, h, l, t, i;
531
+ }, e.clockwiseSort = function(a) {
532
+ var u = e.mean(a);
533
+ return a.sort(function(n, h) {
534
+ return o.angle(u, n) - o.angle(u, h);
535
+ }), a;
536
+ }, e.isConvex = function(a) {
537
+ var u = 0, n = a.length, h, l, t, i;
685
538
  if (n < 3) return null;
686
539
  for (h = 0; h < n; h++)
687
- if (l = (h + 1) % n, t = (h + 2) % n, i = (r[l].x - r[h].x) * (r[t].y - r[l].y), i -= (r[l].y - r[h].y) * (r[t].x - r[l].x), i < 0 ? c |= 1 : i > 0 && (c |= 2), c === 3) return !1;
688
- return c !== 0 ? !0 : null;
689
- }, e.hull = function(r) {
690
- var c = [], n = [], h, l;
691
- for (r = r.slice(0), r.sort(function(t, i) {
540
+ if (l = (h + 1) % n, t = (h + 2) % n, i = (a[l].x - a[h].x) * (a[t].y - a[l].y), i -= (a[l].y - a[h].y) * (a[t].x - a[l].x), i < 0 ? u |= 1 : i > 0 && (u |= 2), u === 3) return !1;
541
+ return u !== 0 ? !0 : null;
542
+ }, e.hull = function(a) {
543
+ var u = [], n = [], h, l;
544
+ for (a = a.slice(0), a.sort(function(t, i) {
692
545
  var s = t.x - i.x;
693
546
  return s !== 0 ? s : t.y - i.y;
694
- }), l = 0; l < r.length; l += 1) {
695
- for (h = r[l]; n.length >= 2 && o.cross3(n[n.length - 2], n[n.length - 1], h) <= 0; ) n.pop();
547
+ }), l = 0; l < a.length; l += 1) {
548
+ for (h = a[l]; n.length >= 2 && o.cross3(n[n.length - 2], n[n.length - 1], h) <= 0; ) n.pop();
696
549
  n.push(h);
697
550
  }
698
- for (l = r.length - 1; l >= 0; l -= 1) {
699
- for (h = r[l]; c.length >= 2 && o.cross3(c[c.length - 2], c[c.length - 1], h) <= 0; ) c.pop();
700
- c.push(h);
551
+ for (l = a.length - 1; l >= 0; l -= 1) {
552
+ for (h = a[l]; u.length >= 2 && o.cross3(u[u.length - 2], u[u.length - 1], h) <= 0; ) u.pop();
553
+ u.push(h);
701
554
  }
702
- return c.pop(), n.pop(), c.concat(n);
555
+ return u.pop(), n.pop(), u.concat(n);
703
556
  };
704
557
  })();
705
558
  }),
706
- (function(T, A, f) {
559
+ (function(A, E, c) {
707
560
  var e = {};
708
- T.exports = e;
709
- var o = f(3), a = f(2), r = f(7), c = f(0), n = f(1), h = f(11);
561
+ A.exports = e;
562
+ var o = c(3), r = c(2), a = c(7), u = c(0), n = c(1), h = c(11);
710
563
  (function() {
711
564
  e._timeCorrection = !0, e._inertiaScale = 4, e._nextCollidingGroupId = 1, e._nextNonCollidingGroupId = -1, e._nextCategory = 1, e._baseDelta = 1e3 / 60, e.create = function(t) {
712
565
  var i = {
713
- id: c.nextId(),
566
+ id: u.nextId(),
714
567
  type: "body",
715
568
  label: "Body",
716
569
  parts: [],
@@ -786,7 +639,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
786
639
  inertia: 0,
787
640
  deltaTime: 16.666666666666668,
788
641
  _original: null
789
- }, s = c.extend(i, t);
642
+ }, s = u.extend(i, t);
790
643
  return l(s, t), s;
791
644
  }, e.nextGroup = function(t) {
792
645
  return t ? e._nextNonCollidingGroupId-- : e._nextCollidingGroupId++;
@@ -796,7 +649,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
796
649
  var l = function(t, i) {
797
650
  i = i || {}, e.set(t, {
798
651
  bounds: t.bounds || n.create(t.vertices),
799
- positionPrev: t.positionPrev || a.clone(t.position),
652
+ positionPrev: t.positionPrev || r.clone(t.position),
800
653
  anglePrev: t.anglePrev || t.angle,
801
654
  vertices: t.vertices,
802
655
  parts: t.parts || [t],
@@ -809,26 +662,26 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
809
662
  mass: i.mass || t.mass,
810
663
  inertia: i.inertia || t.inertia
811
664
  });
812
- var s = t.isStatic ? "#14151f" : c.choose([
665
+ var s = t.isStatic ? "#14151f" : u.choose([
813
666
  "#f19648",
814
667
  "#f5d259",
815
668
  "#f55a3c",
816
669
  "#063e7b",
817
670
  "#ececd1"
818
- ]), u = t.isStatic ? "#555" : "#ccc", m = t.isStatic && t.render.fillStyle === null ? 1 : 0;
819
- t.render.fillStyle = t.render.fillStyle || s, t.render.strokeStyle = t.render.strokeStyle || u, t.render.lineWidth = t.render.lineWidth || m, t.render.sprite.xOffset += -(t.bounds.min.x - t.position.x) / (t.bounds.max.x - t.bounds.min.x), t.render.sprite.yOffset += -(t.bounds.min.y - t.position.y) / (t.bounds.max.y - t.bounds.min.y);
671
+ ]), f = t.isStatic ? "#555" : "#ccc", m = t.isStatic && t.render.fillStyle === null ? 1 : 0;
672
+ t.render.fillStyle = t.render.fillStyle || s, t.render.strokeStyle = t.render.strokeStyle || f, t.render.lineWidth = t.render.lineWidth || m, t.render.sprite.xOffset += -(t.bounds.min.x - t.position.x) / (t.bounds.max.x - t.bounds.min.x), t.render.sprite.yOffset += -(t.bounds.min.y - t.position.y) / (t.bounds.max.y - t.bounds.min.y);
820
673
  };
821
674
  e.set = function(t, i, s) {
822
- var u;
823
- typeof i == "string" && (u = i, i = {}, i[u] = s);
824
- for (u in i)
825
- if (Object.prototype.hasOwnProperty.call(i, u))
826
- switch (s = i[u], u) {
675
+ var f;
676
+ typeof i == "string" && (f = i, i = {}, i[f] = s);
677
+ for (f in i)
678
+ if (Object.prototype.hasOwnProperty.call(i, f))
679
+ switch (s = i[f], f) {
827
680
  case "isStatic":
828
681
  e.setStatic(t, s);
829
682
  break;
830
683
  case "isSleeping":
831
- r.set(t, s);
684
+ a.set(t, s);
832
685
  break;
833
686
  case "mass":
834
687
  e.setMass(t, s);
@@ -867,20 +720,20 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
867
720
  e.setCentre(t, s);
868
721
  break;
869
722
  default:
870
- t[u] = s;
723
+ t[f] = s;
871
724
  }
872
725
  }, e.setStatic = function(t, i) {
873
726
  for (var s = 0; s < t.parts.length; s++) {
874
- var u = t.parts[s];
875
- i ? (u.isStatic || (u._original = {
876
- restitution: u.restitution,
877
- friction: u.friction,
878
- mass: u.mass,
879
- inertia: u.inertia,
880
- density: u.density,
881
- inverseMass: u.inverseMass,
882
- inverseInertia: u.inverseInertia
883
- }), u.restitution = 0, u.friction = 1, u.mass = u.inertia = u.density = 1 / 0, u.inverseMass = u.inverseInertia = 0, u.positionPrev.x = u.position.x, u.positionPrev.y = u.position.y, u.anglePrev = u.angle, u.angularVelocity = 0, u.speed = 0, u.angularSpeed = 0, u.motion = 0) : u._original && (u.restitution = u._original.restitution, u.friction = u._original.friction, u.mass = u._original.mass, u.inertia = u._original.inertia, u.density = u._original.density, u.inverseMass = u._original.inverseMass, u.inverseInertia = u._original.inverseInertia, u._original = null), u.isStatic = i;
727
+ var f = t.parts[s];
728
+ i ? (f.isStatic || (f._original = {
729
+ restitution: f.restitution,
730
+ friction: f.friction,
731
+ mass: f.mass,
732
+ inertia: f.inertia,
733
+ density: f.density,
734
+ inverseMass: f.inverseMass,
735
+ inverseInertia: f.inverseInertia
736
+ }), f.restitution = 0, f.friction = 1, f.mass = f.inertia = f.density = 1 / 0, f.inverseMass = f.inverseInertia = 0, f.positionPrev.x = f.position.x, f.positionPrev.y = f.position.y, f.anglePrev = f.angle, f.angularVelocity = 0, f.speed = 0, f.angularSpeed = 0, f.motion = 0) : f._original && (f.restitution = f._original.restitution, f.friction = f._original.friction, f.mass = f._original.mass, f.inertia = f._original.inertia, f.density = f._original.density, f.inverseMass = f._original.inverseMass, f.inverseInertia = f._original.inverseInertia, f._original = null), f.isStatic = i;
884
737
  }
885
738
  }, e.setMass = function(t, i) {
886
739
  t.inertia = t.inertia / (t.mass / 6) * (i / 6), t.inverseInertia = 1 / t.inertia, t.mass = i, t.inverseMass = 1 / t.mass, t.density = t.mass / t.area;
@@ -893,18 +746,18 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
893
746
  var s = o.centre(t.vertices);
894
747
  o.translate(t.vertices, s, -1), e.setInertia(t, e._inertiaScale * o.inertia(t.vertices, t.mass)), o.translate(t.vertices, t.position), n.update(t.bounds, t.vertices, t.velocity);
895
748
  }, e.setParts = function(t, i, s) {
896
- var u;
897
- for (i = i.slice(0), t.parts.length = 0, t.parts.push(t), t.parent = t, u = 0; u < i.length; u++) {
898
- var m = i[u];
749
+ var f;
750
+ for (i = i.slice(0), t.parts.length = 0, t.parts.push(t), t.parent = t, f = 0; f < i.length; f++) {
751
+ var m = i[f];
899
752
  m !== t && (m.parent = t, t.parts.push(m));
900
753
  }
901
754
  if (t.parts.length !== 1) {
902
755
  if (s = typeof s < "u" ? s : !0, s) {
903
756
  var x = [];
904
- for (u = 0; u < i.length; u++) x = x.concat(i[u].vertices);
757
+ for (f = 0; f < i.length; f++) x = x.concat(i[f].vertices);
905
758
  o.clockwiseSort(x);
906
- var P = o.hull(x), B = o.centre(P);
907
- e.setVertices(t, P), o.translate(t.vertices, B);
759
+ var P = o.hull(x), T = o.centre(P);
760
+ e.setVertices(t, P), o.translate(t.vertices, T);
908
761
  }
909
762
  var g = e._totalProperties(t);
910
763
  t.area = g.area, t.parent = t, t.position.x = g.centre.x, t.position.y = g.centre.y, t.positionPrev.x = g.centre.x, t.positionPrev.y = g.centre.y, e.setMass(t, g.mass), e.setInertia(t, g.inertia), e.setPosition(t, g.centre);
@@ -912,22 +765,22 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
912
765
  }, e.setCentre = function(t, i, s) {
913
766
  s ? (t.positionPrev.x += i.x, t.positionPrev.y += i.y, t.position.x += i.x, t.position.y += i.y) : (t.positionPrev.x = i.x - (t.position.x - t.positionPrev.x), t.positionPrev.y = i.y - (t.position.y - t.positionPrev.y), t.position.x = i.x, t.position.y = i.y);
914
767
  }, e.setPosition = function(t, i, s) {
915
- var u = a.sub(i, t.position);
916
- s ? (t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.velocity.x = u.x, t.velocity.y = u.y, t.speed = a.magnitude(u)) : (t.positionPrev.x += u.x, t.positionPrev.y += u.y);
768
+ var f = r.sub(i, t.position);
769
+ s ? (t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.velocity.x = f.x, t.velocity.y = f.y, t.speed = r.magnitude(f)) : (t.positionPrev.x += f.x, t.positionPrev.y += f.y);
917
770
  for (var m = 0; m < t.parts.length; m++) {
918
771
  var x = t.parts[m];
919
- x.position.x += u.x, x.position.y += u.y, o.translate(x.vertices, u), n.update(x.bounds, x.vertices, t.velocity);
772
+ x.position.x += f.x, x.position.y += f.y, o.translate(x.vertices, f), n.update(x.bounds, x.vertices, t.velocity);
920
773
  }
921
774
  }, e.setAngle = function(t, i, s) {
922
- var u = i - t.angle;
923
- s ? (t.anglePrev = t.angle, t.angularVelocity = u, t.angularSpeed = Math.abs(u)) : t.anglePrev += u;
775
+ var f = i - t.angle;
776
+ s ? (t.anglePrev = t.angle, t.angularVelocity = f, t.angularSpeed = Math.abs(f)) : t.anglePrev += f;
924
777
  for (var m = 0; m < t.parts.length; m++) {
925
778
  var x = t.parts[m];
926
- x.angle += u, o.rotate(x.vertices, u, t.position), h.rotate(x.axes, u), n.update(x.bounds, x.vertices, t.velocity), m > 0 && a.rotateAbout(x.position, u, t.position, x.position);
779
+ x.angle += f, o.rotate(x.vertices, f, t.position), h.rotate(x.axes, f), n.update(x.bounds, x.vertices, t.velocity), m > 0 && r.rotateAbout(x.position, f, t.position, x.position);
927
780
  }
928
781
  }, e.setVelocity = function(t, i) {
929
782
  var s = t.deltaTime / e._baseDelta;
930
- t.positionPrev.x = t.position.x - i.x * s, t.positionPrev.y = t.position.y - i.y * s, t.velocity.x = (t.position.x - t.positionPrev.x) / s, t.velocity.y = (t.position.y - t.positionPrev.y) / s, t.speed = a.magnitude(t.velocity);
783
+ t.positionPrev.x = t.position.x - i.x * s, t.positionPrev.y = t.position.y - i.y * s, t.velocity.x = (t.position.x - t.positionPrev.x) / s, t.velocity.y = (t.position.y - t.positionPrev.y) / s, t.speed = r.magnitude(t.velocity);
931
784
  }, e.getVelocity = function(t) {
932
785
  var i = e._baseDelta / t.deltaTime;
933
786
  return {
@@ -935,9 +788,9 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
935
788
  y: (t.position.y - t.positionPrev.y) * i
936
789
  };
937
790
  }, e.getSpeed = function(t) {
938
- return a.magnitude(e.getVelocity(t));
791
+ return r.magnitude(e.getVelocity(t));
939
792
  }, e.setSpeed = function(t, i) {
940
- e.setVelocity(t, a.mult(a.normalise(e.getVelocity(t)), i));
793
+ e.setVelocity(t, r.mult(r.normalise(e.getVelocity(t)), i));
941
794
  }, e.setAngularVelocity = function(t, i) {
942
795
  var s = t.deltaTime / e._baseDelta;
943
796
  t.anglePrev = t.angle - i * s, t.angularVelocity = (t.angle - t.anglePrev) / s, t.angularSpeed = Math.abs(t.angularVelocity);
@@ -946,49 +799,49 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
946
799
  }, e.getAngularSpeed = function(t) {
947
800
  return Math.abs(e.getAngularVelocity(t));
948
801
  }, e.setAngularSpeed = function(t, i) {
949
- e.setAngularVelocity(t, c.sign(e.getAngularVelocity(t)) * i);
802
+ e.setAngularVelocity(t, u.sign(e.getAngularVelocity(t)) * i);
950
803
  }, e.translate = function(t, i, s) {
951
- e.setPosition(t, a.add(t.position, i), s);
952
- }, e.rotate = function(t, i, s, u) {
953
- if (!s) e.setAngle(t, t.angle + i, u);
804
+ e.setPosition(t, r.add(t.position, i), s);
805
+ }, e.rotate = function(t, i, s, f) {
806
+ if (!s) e.setAngle(t, t.angle + i, f);
954
807
  else {
955
- var m = Math.cos(i), x = Math.sin(i), P = t.position.x - s.x, B = t.position.y - s.y;
808
+ var m = Math.cos(i), x = Math.sin(i), P = t.position.x - s.x, T = t.position.y - s.y;
956
809
  e.setPosition(t, {
957
- x: s.x + (P * m - B * x),
958
- y: s.y + (P * x + B * m)
959
- }, u), e.setAngle(t, t.angle + i, u);
810
+ x: s.x + (P * m - T * x),
811
+ y: s.y + (P * x + T * m)
812
+ }, f), e.setAngle(t, t.angle + i, f);
960
813
  }
961
- }, e.scale = function(t, i, s, u) {
814
+ }, e.scale = function(t, i, s, f) {
962
815
  var m = 0, x = 0;
963
- u = u || t.position;
816
+ f = f || t.position;
964
817
  for (var P = 0; P < t.parts.length; P++) {
965
- var B = t.parts[P];
966
- o.scale(B.vertices, i, s, u), B.axes = h.fromVertices(B.vertices), B.area = o.area(B.vertices), e.setMass(B, t.density * B.area), o.translate(B.vertices, {
967
- x: -B.position.x,
968
- y: -B.position.y
969
- }), e.setInertia(B, e._inertiaScale * o.inertia(B.vertices, B.mass)), o.translate(B.vertices, {
970
- x: B.position.x,
971
- y: B.position.y
972
- }), P > 0 && (m += B.area, x += B.inertia), B.position.x = u.x + (B.position.x - u.x) * i, B.position.y = u.y + (B.position.y - u.y) * s, n.update(B.bounds, B.vertices, t.velocity);
818
+ var T = t.parts[P];
819
+ o.scale(T.vertices, i, s, f), T.axes = h.fromVertices(T.vertices), T.area = o.area(T.vertices), e.setMass(T, t.density * T.area), o.translate(T.vertices, {
820
+ x: -T.position.x,
821
+ y: -T.position.y
822
+ }), e.setInertia(T, e._inertiaScale * o.inertia(T.vertices, T.mass)), o.translate(T.vertices, {
823
+ x: T.position.x,
824
+ y: T.position.y
825
+ }), P > 0 && (m += T.area, x += T.inertia), T.position.x = f.x + (T.position.x - f.x) * i, T.position.y = f.y + (T.position.y - f.y) * s, n.update(T.bounds, T.vertices, t.velocity);
973
826
  }
974
827
  t.parts.length > 1 && (t.area = m, t.isStatic || (e.setMass(t, t.density * m), e.setInertia(t, x))), t.circleRadius && (i === s ? t.circleRadius *= i : t.circleRadius = null);
975
828
  }, e.update = function(t, i) {
976
829
  i = (typeof i < "u" ? i : 1e3 / 60) * t.timeScale;
977
- var s = i * i, u = e._timeCorrection ? i / (t.deltaTime || i) : 1, m = 1 - t.frictionAir * (i / c._baseDelta), x = (t.position.x - t.positionPrev.x) * u, P = (t.position.y - t.positionPrev.y) * u;
978
- t.velocity.x = x * m + t.force.x / t.mass * s, t.velocity.y = P * m + t.force.y / t.mass * s, t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.position.x += t.velocity.x, t.position.y += t.velocity.y, t.deltaTime = i, t.angularVelocity = (t.angle - t.anglePrev) * m * u + t.torque / t.inertia * s, t.anglePrev = t.angle, t.angle += t.angularVelocity;
979
- for (var B = 0; B < t.parts.length; B++) {
980
- var g = t.parts[B];
981
- o.translate(g.vertices, t.velocity), B > 0 && (g.position.x += t.velocity.x, g.position.y += t.velocity.y), t.angularVelocity !== 0 && (o.rotate(g.vertices, t.angularVelocity, t.position), h.rotate(g.axes, t.angularVelocity), B > 0 && a.rotateAbout(g.position, t.angularVelocity, t.position, g.position)), n.update(g.bounds, g.vertices, t.velocity);
830
+ var s = i * i, f = e._timeCorrection ? i / (t.deltaTime || i) : 1, m = 1 - t.frictionAir * (i / u._baseDelta), x = (t.position.x - t.positionPrev.x) * f, P = (t.position.y - t.positionPrev.y) * f;
831
+ t.velocity.x = x * m + t.force.x / t.mass * s, t.velocity.y = P * m + t.force.y / t.mass * s, t.positionPrev.x = t.position.x, t.positionPrev.y = t.position.y, t.position.x += t.velocity.x, t.position.y += t.velocity.y, t.deltaTime = i, t.angularVelocity = (t.angle - t.anglePrev) * m * f + t.torque / t.inertia * s, t.anglePrev = t.angle, t.angle += t.angularVelocity;
832
+ for (var T = 0; T < t.parts.length; T++) {
833
+ var g = t.parts[T];
834
+ o.translate(g.vertices, t.velocity), T > 0 && (g.position.x += t.velocity.x, g.position.y += t.velocity.y), t.angularVelocity !== 0 && (o.rotate(g.vertices, t.angularVelocity, t.position), h.rotate(g.axes, t.angularVelocity), T > 0 && r.rotateAbout(g.position, t.angularVelocity, t.position, g.position)), n.update(g.bounds, g.vertices, t.velocity);
982
835
  }
983
836
  }, e.updateVelocities = function(t) {
984
837
  var i = e._baseDelta / t.deltaTime, s = t.velocity;
985
838
  s.x = (t.position.x - t.positionPrev.x) * i, s.y = (t.position.y - t.positionPrev.y) * i, t.speed = Math.sqrt(s.x * s.x + s.y * s.y), t.angularVelocity = (t.angle - t.anglePrev) * i, t.angularSpeed = Math.abs(t.angularVelocity);
986
839
  }, e.applyForce = function(t, i, s) {
987
- var u = {
840
+ var f = {
988
841
  x: i.x - t.position.x,
989
842
  y: i.y - t.position.y
990
843
  };
991
- t.force.x += s.x, t.force.y += s.y, t.torque += u.x * s.y - u.y * s.x;
844
+ t.force.x += s.x, t.force.y += s.y, t.torque += f.x * s.y - f.y * s.x;
992
845
  }, e._totalProperties = function(t) {
993
846
  for (var i = {
994
847
  mass: 0,
@@ -999,55 +852,55 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
999
852
  y: 0
1000
853
  }
1001
854
  }, s = t.parts.length === 1 ? 0 : 1; s < t.parts.length; s++) {
1002
- var u = t.parts[s], m = u.mass !== 1 / 0 ? u.mass : 1;
1003
- i.mass += m, i.area += u.area, i.inertia += u.inertia, i.centre = a.add(i.centre, a.mult(u.position, m));
855
+ var f = t.parts[s], m = f.mass !== 1 / 0 ? f.mass : 1;
856
+ i.mass += m, i.area += f.area, i.inertia += f.inertia, i.centre = r.add(i.centre, r.mult(f.position, m));
1004
857
  }
1005
- return i.centre = a.div(i.centre, i.mass), i;
858
+ return i.centre = r.div(i.centre, i.mass), i;
1006
859
  };
1007
860
  })();
1008
861
  }),
1009
- (function(T, A, f) {
862
+ (function(A, E, c) {
1010
863
  var e = {};
1011
- T.exports = e;
1012
- var o = f(0);
864
+ A.exports = e;
865
+ var o = c(0);
1013
866
  (function() {
1014
- e.on = function(a, r, c) {
1015
- for (var n = r.split(" "), h, l = 0; l < n.length; l++)
1016
- h = n[l], a.events = a.events || {}, a.events[h] = a.events[h] || [], a.events[h].push(c);
1017
- return c;
1018
- }, e.off = function(a, r, c) {
1019
- if (!r) {
1020
- a.events = {};
867
+ e.on = function(r, a, u) {
868
+ for (var n = a.split(" "), h, l = 0; l < n.length; l++)
869
+ h = n[l], r.events = r.events || {}, r.events[h] = r.events[h] || [], r.events[h].push(u);
870
+ return u;
871
+ }, e.off = function(r, a, u) {
872
+ if (!a) {
873
+ r.events = {};
1021
874
  return;
1022
875
  }
1023
- typeof r == "function" && (c = r, r = o.keys(a.events).join(" "));
1024
- for (var n = r.split(" "), h = 0; h < n.length; h++) {
1025
- var l = a.events[n[h]], t = [];
1026
- if (c && l)
1027
- for (var i = 0; i < l.length; i++) l[i] !== c && t.push(l[i]);
1028
- a.events[n[h]] = t;
876
+ typeof a == "function" && (u = a, a = o.keys(r.events).join(" "));
877
+ for (var n = a.split(" "), h = 0; h < n.length; h++) {
878
+ var l = r.events[n[h]], t = [];
879
+ if (u && l)
880
+ for (var i = 0; i < l.length; i++) l[i] !== u && t.push(l[i]);
881
+ r.events[n[h]] = t;
1029
882
  }
1030
- }, e.trigger = function(a, r, c) {
1031
- var n, h, l, t, i = a.events;
883
+ }, e.trigger = function(r, a, u) {
884
+ var n, h, l, t, i = r.events;
1032
885
  if (i && o.keys(i).length > 0) {
1033
- c || (c = {}), n = r.split(" ");
886
+ u || (u = {}), n = a.split(" ");
1034
887
  for (var s = 0; s < n.length; s++)
1035
888
  if (h = n[s], l = i[h], l) {
1036
- t = o.clone(c, !1), t.name = h, t.source = a;
1037
- for (var u = 0; u < l.length; u++) l[u].apply(a, [t]);
889
+ t = o.clone(u, !1), t.name = h, t.source = r;
890
+ for (var f = 0; f < l.length; f++) l[f].apply(r, [t]);
1038
891
  }
1039
892
  }
1040
893
  };
1041
894
  })();
1042
895
  }),
1043
- (function(T, A, f) {
896
+ (function(A, E, c) {
1044
897
  var e = {};
1045
- T.exports = e;
1046
- var o = f(5), a = f(0), r = f(1), c = f(4);
898
+ A.exports = e;
899
+ var o = c(5), r = c(0), a = c(1), u = c(4);
1047
900
  (function() {
1048
901
  e.create = function(n) {
1049
- return a.extend({
1050
- id: a.nextId(),
902
+ return r.extend({
903
+ id: r.nextId(),
1051
904
  type: "composite",
1052
905
  parent: null,
1053
906
  isModified: !1,
@@ -1075,7 +928,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1075
928
  switch (i.type) {
1076
929
  case "body":
1077
930
  if (i.parent !== i) {
1078
- a.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");
931
+ r.warn("Composite.add: skipped adding a compound body part (you must add its parent instead)");
1079
932
  break;
1080
933
  }
1081
934
  e.addBody(n, i);
@@ -1116,7 +969,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1116
969
  }, e.addComposite = function(n, h) {
1117
970
  return n.composites.push(h), h.parent = n, e.setModified(n, !0, !0, !1), n;
1118
971
  }, e.removeComposite = function(n, h, l) {
1119
- var t = a.indexOf(n.composites, h);
972
+ var t = r.indexOf(n.composites, h);
1120
973
  if (t !== -1) {
1121
974
  var i = e.allBodies(h);
1122
975
  e.removeCompositeAt(n, t);
@@ -1129,7 +982,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1129
982
  }, e.addBody = function(n, h) {
1130
983
  return n.bodies.push(h), e.setModified(n, !0, !0, !1), n;
1131
984
  }, e.removeBody = function(n, h, l) {
1132
- var t = a.indexOf(n.bodies, h);
985
+ var t = r.indexOf(n.bodies, h);
1133
986
  if (t !== -1 && (e.removeBodyAt(n, t), h.sleepCounter = 0), l) for (var i = 0; i < n.composites.length; i++) e.removeBody(n.composites[i], h, !0);
1134
987
  return n;
1135
988
  }, e.removeBodyAt = function(n, h) {
@@ -1137,7 +990,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1137
990
  }, e.addConstraint = function(n, h) {
1138
991
  return n.constraints.push(h), e.setModified(n, !0, !0, !1), n;
1139
992
  }, e.removeConstraint = function(n, h, l) {
1140
- var t = a.indexOf(n.constraints, h);
993
+ var t = r.indexOf(n.constraints, h);
1141
994
  if (t !== -1 && e.removeConstraintAt(n, t), l) for (var i = 0; i < n.composites.length; i++) e.removeConstraint(n.composites[i], h, !0);
1142
995
  return n;
1143
996
  }, e.removeConstraintAt = function(n, h) {
@@ -1178,27 +1031,27 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1178
1031
  }, e.move = function(n, h, l) {
1179
1032
  return e.remove(n, h), e.add(l, h), n;
1180
1033
  }, e.rebase = function(n) {
1181
- for (var h = e.allBodies(n).concat(e.allConstraints(n)).concat(e.allComposites(n)), l = 0; l < h.length; l++) h[l].id = a.nextId();
1034
+ for (var h = e.allBodies(n).concat(e.allConstraints(n)).concat(e.allComposites(n)), l = 0; l < h.length; l++) h[l].id = r.nextId();
1182
1035
  return n;
1183
1036
  }, e.translate = function(n, h, l) {
1184
- for (var t = l ? e.allBodies(n) : n.bodies, i = 0; i < t.length; i++) c.translate(t[i], h);
1037
+ for (var t = l ? e.allBodies(n) : n.bodies, i = 0; i < t.length; i++) u.translate(t[i], h);
1185
1038
  return n;
1186
1039
  }, e.rotate = function(n, h, l, t) {
1187
- for (var i = Math.cos(h), s = Math.sin(h), u = t ? e.allBodies(n) : n.bodies, m = 0; m < u.length; m++) {
1188
- var x = u[m], P = x.position.x - l.x, B = x.position.y - l.y;
1189
- c.setPosition(x, {
1190
- x: l.x + (P * i - B * s),
1191
- y: l.y + (P * s + B * i)
1192
- }), c.rotate(x, h);
1040
+ for (var i = Math.cos(h), s = Math.sin(h), f = t ? e.allBodies(n) : n.bodies, m = 0; m < f.length; m++) {
1041
+ var x = f[m], P = x.position.x - l.x, T = x.position.y - l.y;
1042
+ u.setPosition(x, {
1043
+ x: l.x + (P * i - T * s),
1044
+ y: l.y + (P * s + T * i)
1045
+ }), u.rotate(x, h);
1193
1046
  }
1194
1047
  return n;
1195
1048
  }, e.scale = function(n, h, l, t, i) {
1196
- for (var s = i ? e.allBodies(n) : n.bodies, u = 0; u < s.length; u++) {
1197
- var m = s[u], x = m.position.x - t.x, P = m.position.y - t.y;
1198
- c.setPosition(m, {
1049
+ for (var s = i ? e.allBodies(n) : n.bodies, f = 0; f < s.length; f++) {
1050
+ var m = s[f], x = m.position.x - t.x, P = m.position.y - t.y;
1051
+ u.setPosition(m, {
1199
1052
  x: t.x + x * h,
1200
1053
  y: t.y + P * l
1201
- }), c.scale(m, h, l);
1054
+ }), u.scale(m, h, l);
1202
1055
  }
1203
1056
  return n;
1204
1057
  }, e.bounds = function(n) {
@@ -1206,18 +1059,18 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1206
1059
  var i = h[t];
1207
1060
  l.push(i.bounds.min, i.bounds.max);
1208
1061
  }
1209
- return r.create(l);
1062
+ return a.create(l);
1210
1063
  };
1211
1064
  })();
1212
1065
  }),
1213
- (function(T, A, f) {
1066
+ (function(A, E, c) {
1214
1067
  var e = {};
1215
- T.exports = e;
1216
- var o = f(4), a = f(5), r = f(0);
1068
+ A.exports = e;
1069
+ var o = c(4), r = c(5), a = c(0);
1217
1070
  (function() {
1218
- e._motionWakeThreshold = 0.18, e._motionSleepThreshold = 0.08, e._minBias = 0.9, e.update = function(c, n) {
1219
- for (var h = n / r._baseDelta, l = e._motionSleepThreshold, t = 0; t < c.length; t++) {
1220
- var i = c[t], s = o.getSpeed(i), u = o.getAngularSpeed(i), m = s * s + u * u;
1071
+ e._motionWakeThreshold = 0.18, e._motionSleepThreshold = 0.08, e._minBias = 0.9, e.update = function(u, n) {
1072
+ for (var h = n / a._baseDelta, l = e._motionSleepThreshold, t = 0; t < u.length; t++) {
1073
+ var i = u[t], s = o.getSpeed(i), f = o.getAngularSpeed(i), m = s * s + f * f;
1221
1074
  if (i.force.x !== 0 || i.force.y !== 0) {
1222
1075
  e.set(i, !1);
1223
1076
  continue;
@@ -1225,29 +1078,29 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1225
1078
  var x = Math.min(i.motion, m), P = Math.max(i.motion, m);
1226
1079
  i.motion = e._minBias * x + (1 - e._minBias) * P, i.sleepThreshold > 0 && i.motion < l ? (i.sleepCounter += 1, i.sleepCounter >= i.sleepThreshold / h && e.set(i, !0)) : i.sleepCounter > 0 && (i.sleepCounter -= 1);
1227
1080
  }
1228
- }, e.afterCollisions = function(c) {
1229
- for (var n = e._motionSleepThreshold, h = 0; h < c.length; h++) {
1230
- var l = c[h];
1081
+ }, e.afterCollisions = function(u) {
1082
+ for (var n = e._motionSleepThreshold, h = 0; h < u.length; h++) {
1083
+ var l = u[h];
1231
1084
  if (l.isActive) {
1232
1085
  var t = l.collision, i = t.bodyA.parent, s = t.bodyB.parent;
1233
1086
  if (!(i.isSleeping && s.isSleeping || i.isStatic || s.isStatic) && (i.isSleeping || s.isSleeping)) {
1234
- var u = i.isSleeping && !i.isStatic ? i : s, m = u === i ? s : i;
1235
- !u.isStatic && m.motion > n && e.set(u, !1);
1087
+ var f = i.isSleeping && !i.isStatic ? i : s, m = f === i ? s : i;
1088
+ !f.isStatic && m.motion > n && e.set(f, !1);
1236
1089
  }
1237
1090
  }
1238
1091
  }
1239
- }, e.set = function(c, n) {
1240
- var h = c.isSleeping;
1241
- n ? (c.isSleeping = !0, c.sleepCounter = c.sleepThreshold, c.positionImpulse.x = 0, c.positionImpulse.y = 0, c.positionPrev.x = c.position.x, c.positionPrev.y = c.position.y, c.anglePrev = c.angle, c.speed = 0, c.angularSpeed = 0, c.motion = 0, h || a.trigger(c, "sleepStart")) : (c.isSleeping = !1, c.sleepCounter = 0, h && a.trigger(c, "sleepEnd"));
1092
+ }, e.set = function(u, n) {
1093
+ var h = u.isSleeping;
1094
+ n ? (u.isSleeping = !0, u.sleepCounter = u.sleepThreshold, u.positionImpulse.x = 0, u.positionImpulse.y = 0, u.positionPrev.x = u.position.x, u.positionPrev.y = u.position.y, u.anglePrev = u.angle, u.speed = 0, u.angularSpeed = 0, u.motion = 0, h || r.trigger(u, "sleepStart")) : (u.isSleeping = !1, u.sleepCounter = 0, h && r.trigger(u, "sleepEnd"));
1242
1095
  };
1243
1096
  })();
1244
1097
  }),
1245
- (function(T, A, f) {
1098
+ (function(A, E, c) {
1246
1099
  var e = {};
1247
- T.exports = e;
1248
- var o = f(3), a = f(9);
1100
+ A.exports = e;
1101
+ var o = c(3), r = c(9);
1249
1102
  (function() {
1250
- var r = [], c = {
1103
+ var a = [], u = {
1251
1104
  overlap: 0,
1252
1105
  axis: null
1253
1106
  }, n = {
@@ -1279,80 +1132,80 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1279
1132
  supportCount: 0
1280
1133
  };
1281
1134
  }, e.collides = function(h, l, t) {
1282
- if (e._overlapAxes(c, h.vertices, l.vertices, h.axes), c.overlap <= 0 || (e._overlapAxes(n, l.vertices, h.vertices, l.axes), n.overlap <= 0)) return null;
1283
- var i = t && t.table[a.id(h, l)], s;
1135
+ if (e._overlapAxes(u, h.vertices, l.vertices, h.axes), u.overlap <= 0 || (e._overlapAxes(n, l.vertices, h.vertices, l.axes), n.overlap <= 0)) return null;
1136
+ var i = t && t.table[r.id(h, l)], s;
1284
1137
  i ? s = i.collision : (s = e.create(h, l), s.collided = !0, s.bodyA = h.id < l.id ? h : l, s.bodyB = h.id < l.id ? l : h, s.parentA = s.bodyA.parent, s.parentB = s.bodyB.parent), h = s.bodyA, l = s.bodyB;
1285
- var u;
1286
- c.overlap < n.overlap ? u = c : u = n;
1287
- var m = s.normal, x = s.tangent, P = s.penetration, B = s.supports, g = u.overlap, p = u.axis, y = p.x, v = p.y, w = l.position.x - h.position.x, S = l.position.y - h.position.y;
1138
+ var f;
1139
+ u.overlap < n.overlap ? f = u : f = n;
1140
+ var m = s.normal, x = s.tangent, P = s.penetration, T = s.supports, g = f.overlap, d = f.axis, y = d.x, v = d.y, w = l.position.x - h.position.x, S = l.position.y - h.position.y;
1288
1141
  y * w + v * S >= 0 && (y = -y, v = -v), m.x = y, m.y = v, x.x = -v, x.y = y, P.x = y * g, P.y = v * g, s.depth = g;
1289
1142
  var C = e._findSupports(h, l, m, 1), M = 0;
1290
- if (o.contains(h.vertices, C[0]) && (B[M++] = C[0]), o.contains(h.vertices, C[1]) && (B[M++] = C[1]), M < 2) {
1143
+ if (o.contains(h.vertices, C[0]) && (T[M++] = C[0]), o.contains(h.vertices, C[1]) && (T[M++] = C[1]), M < 2) {
1291
1144
  var I = e._findSupports(l, h, m, -1);
1292
- o.contains(l.vertices, I[0]) && (B[M++] = I[0]), M < 2 && o.contains(l.vertices, I[1]) && (B[M++] = I[1]);
1145
+ o.contains(l.vertices, I[0]) && (T[M++] = I[0]), M < 2 && o.contains(l.vertices, I[1]) && (T[M++] = I[1]);
1293
1146
  }
1294
- return M === 0 && (B[M++] = C[0]), s.supportCount = M, s;
1147
+ return M === 0 && (T[M++] = C[0]), s.supportCount = M, s;
1295
1148
  }, e._overlapAxes = function(h, l, t, i) {
1296
- var s = l.length, u = t.length, m = l[0].x, x = l[0].y, P = t[0].x, B = t[0].y, g = i.length, p = Number.MAX_VALUE, y = 0, v, w, S, C, M, I;
1149
+ var s = l.length, f = t.length, m = l[0].x, x = l[0].y, P = t[0].x, T = t[0].y, g = i.length, d = Number.MAX_VALUE, y = 0, v, w, S, C, M, I;
1297
1150
  for (M = 0; M < g; M++) {
1298
- var R = i[M], L = R.x, b = R.y, k = m * L + x * b, D = P * L + B * b, F = k, H = D;
1151
+ var R = i[M], L = R.x, D = R.y, k = m * L + x * D, b = P * L + T * D, O = k, W = b;
1299
1152
  for (I = 1; I < s; I += 1)
1300
- C = l[I].x * L + l[I].y * b, C > F ? F = C : C < k && (k = C);
1301
- for (I = 1; I < u; I += 1)
1302
- C = t[I].x * L + t[I].y * b, C > H ? H = C : C < D && (D = C);
1303
- if (w = F - D, S = H - k, v = w < S ? w : S, v < p && (p = v, y = M, v <= 0))
1153
+ C = l[I].x * L + l[I].y * D, C > O ? O = C : C < k && (k = C);
1154
+ for (I = 1; I < f; I += 1)
1155
+ C = t[I].x * L + t[I].y * D, C > W ? W = C : C < b && (b = C);
1156
+ if (w = O - b, S = W - k, v = w < S ? w : S, v < d && (d = v, y = M, v <= 0))
1304
1157
  break;
1305
1158
  }
1306
- h.axis = i[y], h.overlap = p;
1159
+ h.axis = i[y], h.overlap = d;
1307
1160
  }, e._findSupports = function(h, l, t, i) {
1308
- var s = l.vertices, u = s.length, m = h.position.x, x = h.position.y, P = t.x * i, B = t.y * i, g = s[0], p = g, y = P * (m - p.x) + B * (x - p.y), v, w, S;
1309
- for (S = 1; S < u; S += 1)
1310
- p = s[S], w = P * (m - p.x) + B * (x - p.y), w < y && (y = w, g = p);
1311
- return v = s[(u + g.index - 1) % u], y = P * (m - v.x) + B * (x - v.y), p = s[(g.index + 1) % u], P * (m - p.x) + B * (x - p.y) < y ? (r[0] = g, r[1] = p, r) : (r[0] = g, r[1] = v, r);
1161
+ var s = l.vertices, f = s.length, m = h.position.x, x = h.position.y, P = t.x * i, T = t.y * i, g = s[0], d = g, y = P * (m - d.x) + T * (x - d.y), v, w, S;
1162
+ for (S = 1; S < f; S += 1)
1163
+ d = s[S], w = P * (m - d.x) + T * (x - d.y), w < y && (y = w, g = d);
1164
+ return v = s[(f + g.index - 1) % f], y = P * (m - v.x) + T * (x - v.y), d = s[(g.index + 1) % f], P * (m - d.x) + T * (x - d.y) < y ? (a[0] = g, a[1] = d, a) : (a[0] = g, a[1] = v, a);
1312
1165
  };
1313
1166
  })();
1314
1167
  }),
1315
- (function(T, A, f) {
1168
+ (function(A, E, c) {
1316
1169
  var e = {};
1317
- T.exports = e;
1318
- var o = f(16);
1170
+ A.exports = e;
1171
+ var o = c(16);
1319
1172
  (function() {
1320
- e.create = function(a, r) {
1321
- var c = a.bodyA, n = a.bodyB, h = {
1322
- id: e.id(c, n),
1323
- bodyA: c,
1173
+ e.create = function(r, a) {
1174
+ var u = r.bodyA, n = r.bodyB, h = {
1175
+ id: e.id(u, n),
1176
+ bodyA: u,
1324
1177
  bodyB: n,
1325
- collision: a,
1178
+ collision: r,
1326
1179
  contacts: [o.create(), o.create()],
1327
1180
  contactCount: 0,
1328
1181
  separation: 0,
1329
1182
  isActive: !0,
1330
- isSensor: c.isSensor || n.isSensor,
1331
- timeCreated: r,
1332
- timeUpdated: r,
1183
+ isSensor: u.isSensor || n.isSensor,
1184
+ timeCreated: a,
1185
+ timeUpdated: a,
1333
1186
  inverseMass: 0,
1334
1187
  friction: 0,
1335
1188
  frictionStatic: 0,
1336
1189
  restitution: 0,
1337
1190
  slop: 0
1338
1191
  };
1339
- return e.update(h, a, r), h;
1340
- }, e.update = function(a, r, c) {
1341
- var n = r.supports, h = r.supportCount, l = a.contacts, t = r.parentA, i = r.parentB;
1342
- a.isActive = !0, a.timeUpdated = c, a.collision = r, a.separation = r.depth, a.inverseMass = t.inverseMass + i.inverseMass, a.friction = t.friction < i.friction ? t.friction : i.friction, a.frictionStatic = t.frictionStatic > i.frictionStatic ? t.frictionStatic : i.frictionStatic, a.restitution = t.restitution > i.restitution ? t.restitution : i.restitution, a.slop = t.slop > i.slop ? t.slop : i.slop, a.contactCount = h, r.pair = a;
1343
- var s = n[0], u = l[0], m = n[1], x = l[1];
1344
- (x.vertex === s || u.vertex === m) && (l[1] = u, l[0] = u = x, x = l[1]), u.vertex = s, x.vertex = m;
1345
- }, e.setActive = function(a, r, c) {
1346
- r ? (a.isActive = !0, a.timeUpdated = c) : (a.isActive = !1, a.contactCount = 0);
1347
- }, e.id = function(a, r) {
1348
- return a.id < r.id ? a.id.toString(36) + ":" + r.id.toString(36) : r.id.toString(36) + ":" + a.id.toString(36);
1192
+ return e.update(h, r, a), h;
1193
+ }, e.update = function(r, a, u) {
1194
+ var n = a.supports, h = a.supportCount, l = r.contacts, t = a.parentA, i = a.parentB;
1195
+ r.isActive = !0, r.timeUpdated = u, r.collision = a, r.separation = a.depth, r.inverseMass = t.inverseMass + i.inverseMass, r.friction = t.friction < i.friction ? t.friction : i.friction, r.frictionStatic = t.frictionStatic > i.frictionStatic ? t.frictionStatic : i.frictionStatic, r.restitution = t.restitution > i.restitution ? t.restitution : i.restitution, r.slop = t.slop > i.slop ? t.slop : i.slop, r.contactCount = h, a.pair = r;
1196
+ var s = n[0], f = l[0], m = n[1], x = l[1];
1197
+ (x.vertex === s || f.vertex === m) && (l[1] = f, l[0] = f = x, x = l[1]), f.vertex = s, x.vertex = m;
1198
+ }, e.setActive = function(r, a, u) {
1199
+ a ? (r.isActive = !0, r.timeUpdated = u) : (r.isActive = !1, r.contactCount = 0);
1200
+ }, e.id = function(r, a) {
1201
+ return r.id < a.id ? r.id.toString(36) + ":" + a.id.toString(36) : a.id.toString(36) + ":" + r.id.toString(36);
1349
1202
  };
1350
1203
  })();
1351
1204
  }),
1352
- (function(T, A, f) {
1205
+ (function(A, E, c) {
1353
1206
  var e = {};
1354
- T.exports = e;
1355
- var o = f(3), a = f(2), r = f(7), c = f(1), n = f(11), h = f(0);
1207
+ A.exports = e;
1208
+ var o = c(3), r = c(2), a = c(7), u = c(1), n = c(11), h = c(0);
1356
1209
  (function() {
1357
1210
  e._warming = 0.4, e._torqueDampen = 1, e._minLength = 1e-6, e.create = function(l) {
1358
1211
  var t = l;
@@ -1363,8 +1216,8 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1363
1216
  x: 0,
1364
1217
  y: 0
1365
1218
  });
1366
- var i = t.bodyA ? a.add(t.bodyA.position, t.pointA) : t.pointA, s = t.bodyB ? a.add(t.bodyB.position, t.pointB) : t.pointB, u = a.magnitude(a.sub(i, s));
1367
- t.length = typeof t.length < "u" ? t.length : u, t.id = t.id || h.nextId(), t.label = t.label || "Constraint", t.type = "constraint", t.stiffness = t.stiffness || (t.length > 0 ? 1 : 0.7), t.damping = t.damping || 0, t.angularStiffness = t.angularStiffness || 0, t.angleA = t.bodyA ? t.bodyA.angle : t.angleA, t.angleB = t.bodyB ? t.bodyB.angle : t.angleB, t.plugin = {};
1219
+ var i = t.bodyA ? r.add(t.bodyA.position, t.pointA) : t.pointA, s = t.bodyB ? r.add(t.bodyB.position, t.pointB) : t.pointB, f = r.magnitude(r.sub(i, s));
1220
+ t.length = typeof t.length < "u" ? t.length : f, t.id = t.id || h.nextId(), t.label = t.label || "Constraint", t.type = "constraint", t.stiffness = t.stiffness || (t.length > 0 ? 1 : 0.7), t.damping = t.damping || 0, t.angularStiffness = t.angularStiffness || 0, t.angleA = t.bodyA ? t.bodyA.angle : t.angleA, t.angleB = t.bodyB ? t.bodyB.angle : t.angleB, t.plugin = {};
1368
1221
  var m = {
1369
1222
  visible: !0,
1370
1223
  lineWidth: 2,
@@ -1380,35 +1233,35 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1380
1233
  }
1381
1234
  }, e.solveAll = function(l, t) {
1382
1235
  for (var i = h.clamp(t / h._baseDelta, 0, 1), s = 0; s < l.length; s += 1) {
1383
- var u = l[s], m = !u.bodyA || u.bodyA && u.bodyA.isStatic, x = !u.bodyB || u.bodyB && u.bodyB.isStatic;
1236
+ var f = l[s], m = !f.bodyA || f.bodyA && f.bodyA.isStatic, x = !f.bodyB || f.bodyB && f.bodyB.isStatic;
1384
1237
  (m || x) && e.solve(l[s], i);
1385
1238
  }
1386
1239
  for (s = 0; s < l.length; s += 1)
1387
- u = l[s], m = !u.bodyA || u.bodyA && u.bodyA.isStatic, x = !u.bodyB || u.bodyB && u.bodyB.isStatic, !m && !x && e.solve(l[s], i);
1240
+ f = l[s], m = !f.bodyA || f.bodyA && f.bodyA.isStatic, x = !f.bodyB || f.bodyB && f.bodyB.isStatic, !m && !x && e.solve(l[s], i);
1388
1241
  }, e.solve = function(l, t) {
1389
- var i = l.bodyA, s = l.bodyB, u = l.pointA, m = l.pointB;
1242
+ var i = l.bodyA, s = l.bodyB, f = l.pointA, m = l.pointB;
1390
1243
  if (!(!i && !s)) {
1391
- i && !i.isStatic && (a.rotate(u, i.angle - l.angleA, u), l.angleA = i.angle), s && !s.isStatic && (a.rotate(m, s.angle - l.angleB, m), l.angleB = s.angle);
1392
- var x = u, P = m;
1393
- if (i && (x = a.add(i.position, u)), s && (P = a.add(s.position, m)), !(!x || !P)) {
1394
- var B = a.sub(x, P), g = a.magnitude(B);
1244
+ i && !i.isStatic && (r.rotate(f, i.angle - l.angleA, f), l.angleA = i.angle), s && !s.isStatic && (r.rotate(m, s.angle - l.angleB, m), l.angleB = s.angle);
1245
+ var x = f, P = m;
1246
+ if (i && (x = r.add(i.position, f)), s && (P = r.add(s.position, m)), !(!x || !P)) {
1247
+ var T = r.sub(x, P), g = r.magnitude(T);
1395
1248
  g < e._minLength && (g = e._minLength);
1396
- var p = (g - l.length) / g, y = l.stiffness >= 1 || l.length === 0 ? l.stiffness * t : l.stiffness * t * t, v = l.damping * t, w = a.mult(B, p * y), S = (i ? i.inverseMass : 0) + (s ? s.inverseMass : 0), C = S + ((i ? i.inverseInertia : 0) + (s ? s.inverseInertia : 0)), M, I, R, L, b;
1249
+ var d = (g - l.length) / g, y = l.stiffness >= 1 || l.length === 0 ? l.stiffness * t : l.stiffness * t * t, v = l.damping * t, w = r.mult(T, d * y), S = (i ? i.inverseMass : 0) + (s ? s.inverseMass : 0), C = S + ((i ? i.inverseInertia : 0) + (s ? s.inverseInertia : 0)), M, I, R, L, D;
1397
1250
  if (v > 0) {
1398
- var k = a.create();
1399
- R = a.div(B, g), b = a.sub(s && a.sub(s.position, s.positionPrev) || k, i && a.sub(i.position, i.positionPrev) || k), L = a.dot(R, b);
1251
+ var k = r.create();
1252
+ R = r.div(T, g), D = r.sub(s && r.sub(s.position, s.positionPrev) || k, i && r.sub(i.position, i.positionPrev) || k), L = r.dot(R, D);
1400
1253
  }
1401
- i && !i.isStatic && (I = i.inverseMass / S, i.constraintImpulse.x -= w.x * I, i.constraintImpulse.y -= w.y * I, i.position.x -= w.x * I, i.position.y -= w.y * I, v > 0 && (i.positionPrev.x -= v * R.x * L * I, i.positionPrev.y -= v * R.y * L * I), M = a.cross(u, w) / C * e._torqueDampen * i.inverseInertia * (1 - l.angularStiffness), i.constraintImpulse.angle -= M, i.angle -= M), s && !s.isStatic && (I = s.inverseMass / S, s.constraintImpulse.x += w.x * I, s.constraintImpulse.y += w.y * I, s.position.x += w.x * I, s.position.y += w.y * I, v > 0 && (s.positionPrev.x += v * R.x * L * I, s.positionPrev.y += v * R.y * L * I), M = a.cross(m, w) / C * e._torqueDampen * s.inverseInertia * (1 - l.angularStiffness), s.constraintImpulse.angle += M, s.angle += M);
1254
+ i && !i.isStatic && (I = i.inverseMass / S, i.constraintImpulse.x -= w.x * I, i.constraintImpulse.y -= w.y * I, i.position.x -= w.x * I, i.position.y -= w.y * I, v > 0 && (i.positionPrev.x -= v * R.x * L * I, i.positionPrev.y -= v * R.y * L * I), M = r.cross(f, w) / C * e._torqueDampen * i.inverseInertia * (1 - l.angularStiffness), i.constraintImpulse.angle -= M, i.angle -= M), s && !s.isStatic && (I = s.inverseMass / S, s.constraintImpulse.x += w.x * I, s.constraintImpulse.y += w.y * I, s.position.x += w.x * I, s.position.y += w.y * I, v > 0 && (s.positionPrev.x += v * R.x * L * I, s.positionPrev.y += v * R.y * L * I), M = r.cross(m, w) / C * e._torqueDampen * s.inverseInertia * (1 - l.angularStiffness), s.constraintImpulse.angle += M, s.angle += M);
1402
1255
  }
1403
1256
  }
1404
1257
  }, e.postSolveAll = function(l) {
1405
1258
  for (var t = 0; t < l.length; t++) {
1406
1259
  var i = l[t], s = i.constraintImpulse;
1407
1260
  if (!(i.isStatic || s.x === 0 && s.y === 0 && s.angle === 0)) {
1408
- r.set(i, !1);
1409
- for (var u = 0; u < i.parts.length; u++) {
1410
- var m = i.parts[u];
1411
- o.translate(m.vertices, s), u > 0 && (m.position.x += s.x, m.position.y += s.y), s.angle !== 0 && (o.rotate(m.vertices, s.angle, i.position), n.rotate(m.axes, s.angle), u > 0 && a.rotateAbout(m.position, s.angle, i.position, m.position)), c.update(m.bounds, m.vertices, i.velocity);
1261
+ a.set(i, !1);
1262
+ for (var f = 0; f < i.parts.length; f++) {
1263
+ var m = i.parts[f];
1264
+ o.translate(m.vertices, s), f > 0 && (m.position.x += s.x, m.position.y += s.y), s.angle !== 0 && (o.rotate(m.vertices, s.angle, i.position), n.rotate(m.axes, s.angle), f > 0 && r.rotateAbout(m.position, s.angle, i.position, m.position)), u.update(m.bounds, m.vertices, i.velocity);
1412
1265
  }
1413
1266
  s.angle *= e._warming, s.x *= e._warming, s.y *= e._warming;
1414
1267
  }
@@ -1424,42 +1277,42 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1424
1277
  y: (l.bodyB ? l.bodyB.position.y : 0) + (l.pointB ? l.pointB.y : 0)
1425
1278
  };
1426
1279
  }, e.currentLength = function(l) {
1427
- var t = (l.bodyA ? l.bodyA.position.x : 0) + (l.pointA ? l.pointA.x : 0), i = (l.bodyA ? l.bodyA.position.y : 0) + (l.pointA ? l.pointA.y : 0), s = (l.bodyB ? l.bodyB.position.x : 0) + (l.pointB ? l.pointB.x : 0), u = (l.bodyB ? l.bodyB.position.y : 0) + (l.pointB ? l.pointB.y : 0), m = t - s, x = i - u;
1280
+ var t = (l.bodyA ? l.bodyA.position.x : 0) + (l.pointA ? l.pointA.x : 0), i = (l.bodyA ? l.bodyA.position.y : 0) + (l.pointA ? l.pointA.y : 0), s = (l.bodyB ? l.bodyB.position.x : 0) + (l.pointB ? l.pointB.x : 0), f = (l.bodyB ? l.bodyB.position.y : 0) + (l.pointB ? l.pointB.y : 0), m = t - s, x = i - f;
1428
1281
  return Math.sqrt(m * m + x * x);
1429
1282
  };
1430
1283
  })();
1431
1284
  }),
1432
- (function(T, A, f) {
1285
+ (function(A, E, c) {
1433
1286
  var e = {};
1434
- T.exports = e;
1435
- var o = f(2), a = f(0);
1287
+ A.exports = e;
1288
+ var o = c(2), r = c(0);
1436
1289
  (function() {
1437
- e.fromVertices = function(r) {
1438
- for (var c = {}, n = 0; n < r.length; n++) {
1439
- var h = (n + 1) % r.length, l = o.normalise({
1440
- x: r[h].y - r[n].y,
1441
- y: r[n].x - r[h].x
1290
+ e.fromVertices = function(a) {
1291
+ for (var u = {}, n = 0; n < a.length; n++) {
1292
+ var h = (n + 1) % a.length, l = o.normalise({
1293
+ x: a[h].y - a[n].y,
1294
+ y: a[n].x - a[h].x
1442
1295
  }), t = l.y === 0 ? 1 / 0 : l.x / l.y;
1443
- t = t.toFixed(3).toString(), c[t] = l;
1296
+ t = t.toFixed(3).toString(), u[t] = l;
1444
1297
  }
1445
- return a.values(c);
1446
- }, e.rotate = function(r, c) {
1447
- if (c !== 0)
1448
- for (var n = Math.cos(c), h = Math.sin(c), l = 0; l < r.length; l++) {
1449
- var t = r[l], i = t.x * n - t.y * h;
1298
+ return r.values(u);
1299
+ }, e.rotate = function(a, u) {
1300
+ if (u !== 0)
1301
+ for (var n = Math.cos(u), h = Math.sin(u), l = 0; l < a.length; l++) {
1302
+ var t = a[l], i = t.x * n - t.y * h;
1450
1303
  t.y = t.x * h + t.y * n, t.x = i;
1451
1304
  }
1452
1305
  };
1453
1306
  })();
1454
1307
  }),
1455
- (function(T, A, f) {
1308
+ (function(A, E, c) {
1456
1309
  var e = {};
1457
- T.exports = e;
1458
- var o = f(3), a = f(0), r = f(4), c = f(1), n = f(2);
1310
+ A.exports = e;
1311
+ var o = c(3), r = c(0), a = c(4), u = c(1), n = c(2);
1459
1312
  (function() {
1460
1313
  e.rectangle = function(h, l, t, i, s) {
1461
1314
  s = s || {};
1462
- var u = {
1315
+ var f = {
1463
1316
  label: "Rectangle Body",
1464
1317
  position: {
1465
1318
  x: h,
@@ -1469,14 +1322,14 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1469
1322
  };
1470
1323
  if (s.chamfer) {
1471
1324
  var m = s.chamfer;
1472
- u.vertices = o.chamfer(u.vertices, m.radius, m.quality, m.qualityMin, m.qualityMax), delete s.chamfer;
1473
- }
1474
- return r.create(a.extend({}, u, s));
1475
- }, e.trapezoid = function(h, l, t, i, s, u) {
1476
- u = u || {}, s >= 1 && a.warn("Bodies.trapezoid: slope parameter must be < 1."), s *= 0.5;
1477
- var m = (1 - s * 2) * t, x = t * s, P = x + m, B = P + x, g;
1478
- s < 0.5 ? g = "L 0 0 L " + x + " " + -i + " L " + P + " " + -i + " L " + B + " 0" : g = "L 0 0 L " + P + " " + -i + " L " + B + " 0";
1479
- var p = {
1325
+ f.vertices = o.chamfer(f.vertices, m.radius, m.quality, m.qualityMin, m.qualityMax), delete s.chamfer;
1326
+ }
1327
+ return a.create(r.extend({}, f, s));
1328
+ }, e.trapezoid = function(h, l, t, i, s, f) {
1329
+ f = f || {}, s >= 1 && r.warn("Bodies.trapezoid: slope parameter must be < 1."), s *= 0.5;
1330
+ var m = (1 - s * 2) * t, x = t * s, P = x + m, T = P + x, g;
1331
+ s < 0.5 ? g = "L 0 0 L " + x + " " + -i + " L " + P + " " + -i + " L " + T + " 0" : g = "L 0 0 L " + P + " " + -i + " L " + T + " 0";
1332
+ var d = {
1480
1333
  label: "Trapezoid Body",
1481
1334
  position: {
1482
1335
  x: h,
@@ -1484,25 +1337,25 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1484
1337
  },
1485
1338
  vertices: o.fromPath(g)
1486
1339
  };
1487
- if (u.chamfer) {
1488
- var y = u.chamfer;
1489
- p.vertices = o.chamfer(p.vertices, y.radius, y.quality, y.qualityMin, y.qualityMax), delete u.chamfer;
1340
+ if (f.chamfer) {
1341
+ var y = f.chamfer;
1342
+ d.vertices = o.chamfer(d.vertices, y.radius, y.quality, y.qualityMin, y.qualityMax), delete f.chamfer;
1490
1343
  }
1491
- return r.create(a.extend({}, p, u));
1344
+ return a.create(r.extend({}, d, f));
1492
1345
  }, e.circle = function(h, l, t, i, s) {
1493
1346
  i = i || {};
1494
- var u = {
1347
+ var f = {
1495
1348
  label: "Circle Body",
1496
1349
  circleRadius: t
1497
1350
  };
1498
1351
  s = s || 25;
1499
1352
  var m = Math.ceil(Math.max(10, Math.min(s, t)));
1500
- return m % 2 === 1 && (m += 1), e.polygon(h, l, m, t, a.extend({}, u, i));
1353
+ return m % 2 === 1 && (m += 1), e.polygon(h, l, m, t, r.extend({}, f, i));
1501
1354
  }, e.polygon = function(h, l, t, i, s) {
1502
1355
  if (s = s || {}, t < 3) return e.circle(h, l, i, s);
1503
- for (var u = 2 * Math.PI / t, m = "", x = u * 0.5, P = 0; P < t; P += 1) {
1504
- var B = x + P * u, g = Math.cos(B) * i, p = Math.sin(B) * i;
1505
- m += "L " + g.toFixed(3) + " " + p.toFixed(3) + " ";
1356
+ for (var f = 2 * Math.PI / t, m = "", x = f * 0.5, P = 0; P < t; P += 1) {
1357
+ var T = x + P * f, g = Math.cos(T) * i, d = Math.sin(T) * i;
1358
+ m += "L " + g.toFixed(3) + " " + d.toFixed(3) + " ";
1506
1359
  }
1507
1360
  var y = {
1508
1361
  label: "Polygon Body",
@@ -1516,12 +1369,12 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1516
1369
  var v = s.chamfer;
1517
1370
  y.vertices = o.chamfer(y.vertices, v.radius, v.quality, v.qualityMin, v.qualityMax), delete s.chamfer;
1518
1371
  }
1519
- return r.create(a.extend({}, y, s));
1520
- }, e.fromVertices = function(h, l, t, i, s, u, m, x) {
1521
- var P = a.getDecomp(), B = !!(P && P.quickDecomp), g, p, y, v, w, S, C, M, I, R;
1522
- for (i = i || {}, p = [], s = typeof s < "u" ? s : !1, u = typeof u < "u" ? u : 0.01, m = typeof m < "u" ? m : 10, x = typeof x < "u" ? x : 0.01, a.isArray(t[0]) || (t = [t]), I = 0; I < t.length; I += 1)
1523
- if (w = t[I], y = o.isConvex(w), v = !y, v && !B && a.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."), y || !B)
1524
- y ? w = o.clockwiseSort(w) : w = o.hull(w), p.push({
1372
+ return a.create(r.extend({}, y, s));
1373
+ }, e.fromVertices = function(h, l, t, i, s, f, m, x) {
1374
+ var P = r.getDecomp(), T = !!(P && P.quickDecomp), g, d, y, v, w, S, C, M, I, R;
1375
+ for (i = i || {}, d = [], s = typeof s < "u" ? s : !1, f = typeof f < "u" ? f : 0.01, m = typeof m < "u" ? m : 10, x = typeof x < "u" ? x : 0.01, r.isArray(t[0]) || (t = [t]), I = 0; I < t.length; I += 1)
1376
+ if (w = t[I], y = o.isConvex(w), v = !y, v && !T && r.warnOnce("Bodies.fromVertices: Install the 'poly-decomp' library and use Common.setDecomp or provide 'decomp' as a global to decompose concave vertices."), y || !T)
1377
+ y ? w = o.clockwiseSort(w) : w = o.hull(w), d.push({
1525
1378
  position: {
1526
1379
  x: h,
1527
1380
  y: l
@@ -1529,81 +1382,81 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1529
1382
  vertices: w
1530
1383
  });
1531
1384
  else {
1532
- var L = w.map(function(U) {
1533
- return [U.x, U.y];
1385
+ var L = w.map(function(F) {
1386
+ return [F.x, F.y];
1534
1387
  });
1535
- P.makeCCW(L), u !== !1 && P.removeCollinearPoints(L, u), x !== !1 && P.removeDuplicatePoints && P.removeDuplicatePoints(L, x);
1536
- var b = P.quickDecomp(L);
1537
- for (S = 0; S < b.length; S++) {
1538
- var k = b[S].map(function(U) {
1388
+ P.makeCCW(L), f !== !1 && P.removeCollinearPoints(L, f), x !== !1 && P.removeDuplicatePoints && P.removeDuplicatePoints(L, x);
1389
+ var D = P.quickDecomp(L);
1390
+ for (S = 0; S < D.length; S++) {
1391
+ var k = D[S].map(function(F) {
1539
1392
  return {
1540
- x: U[0],
1541
- y: U[1]
1393
+ x: F[0],
1394
+ y: F[1]
1542
1395
  };
1543
1396
  });
1544
- m > 0 && o.area(k) < m || p.push({
1397
+ m > 0 && o.area(k) < m || d.push({
1545
1398
  position: o.centre(k),
1546
1399
  vertices: k
1547
1400
  });
1548
1401
  }
1549
1402
  }
1550
- for (S = 0; S < p.length; S++) p[S] = r.create(a.extend(p[S], i));
1403
+ for (S = 0; S < d.length; S++) d[S] = a.create(r.extend(d[S], i));
1551
1404
  if (s) {
1552
- var D = 5;
1553
- for (S = 0; S < p.length; S++) {
1554
- var F = p[S];
1555
- for (C = S + 1; C < p.length; C++) {
1556
- var H = p[C];
1557
- if (c.overlaps(F.bounds, H.bounds)) {
1558
- var G = F.vertices, V = H.vertices;
1559
- for (M = 0; M < F.vertices.length; M++) for (R = 0; R < H.vertices.length; R++) {
1560
- var Q = n.magnitudeSquared(n.sub(G[(M + 1) % G.length], V[R])), X = n.magnitudeSquared(n.sub(G[M], V[(R + 1) % V.length]));
1561
- Q < D && X < D && (G[M].isInternal = !0, V[R].isInternal = !0);
1405
+ var b = 5;
1406
+ for (S = 0; S < d.length; S++) {
1407
+ var O = d[S];
1408
+ for (C = S + 1; C < d.length; C++) {
1409
+ var W = d[C];
1410
+ if (u.overlaps(O.bounds, W.bounds)) {
1411
+ var G = O.vertices, N = W.vertices;
1412
+ for (M = 0; M < O.vertices.length; M++) for (R = 0; R < W.vertices.length; R++) {
1413
+ var Q = n.magnitudeSquared(n.sub(G[(M + 1) % G.length], N[R])), X = n.magnitudeSquared(n.sub(G[M], N[(R + 1) % N.length]));
1414
+ Q < b && X < b && (G[M].isInternal = !0, N[R].isInternal = !0);
1562
1415
  }
1563
1416
  }
1564
1417
  }
1565
1418
  }
1566
1419
  }
1567
- return p.length > 1 ? (g = r.create(a.extend({ parts: p.slice(0) }, i)), r.setPosition(g, {
1420
+ return d.length > 1 ? (g = a.create(r.extend({ parts: d.slice(0) }, i)), a.setPosition(g, {
1568
1421
  x: h,
1569
1422
  y: l
1570
- }), g) : p[0];
1423
+ }), g) : d[0];
1571
1424
  };
1572
1425
  })();
1573
1426
  }),
1574
- (function(T, A, f) {
1427
+ (function(A, E, c) {
1575
1428
  var e = {};
1576
- T.exports = e;
1577
- var o = f(0), a = f(8);
1429
+ A.exports = e;
1430
+ var o = c(0), r = c(8);
1578
1431
  (function() {
1579
- e.create = function(r) {
1432
+ e.create = function(a) {
1580
1433
  return o.extend({
1581
1434
  bodies: [],
1582
1435
  collisions: [],
1583
1436
  pairs: null
1584
- }, r);
1585
- }, e.setBodies = function(r, c) {
1586
- r.bodies = c.slice(0);
1587
- }, e.clear = function(r) {
1588
- r.bodies = [], r.collisions = [];
1589
- }, e.collisions = function(r) {
1590
- var c = r.pairs, n = r.bodies, h = n.length, l = e.canCollide, t = a.collides, i = r.collisions, s = 0, u, m;
1591
- for (n.sort(e._compareBoundsX), u = 0; u < h; u++) {
1592
- var x = n[u], P = x.bounds, B = x.bounds.max.x, g = x.bounds.max.y, p = x.bounds.min.y, y = x.isStatic || x.isSleeping, v = x.parts.length, w = v === 1;
1593
- for (m = u + 1; m < h; m++) {
1437
+ }, a);
1438
+ }, e.setBodies = function(a, u) {
1439
+ a.bodies = u.slice(0);
1440
+ }, e.clear = function(a) {
1441
+ a.bodies = [], a.collisions = [];
1442
+ }, e.collisions = function(a) {
1443
+ var u = a.pairs, n = a.bodies, h = n.length, l = e.canCollide, t = r.collides, i = a.collisions, s = 0, f, m;
1444
+ for (n.sort(e._compareBoundsX), f = 0; f < h; f++) {
1445
+ var x = n[f], P = x.bounds, T = x.bounds.max.x, g = x.bounds.max.y, d = x.bounds.min.y, y = x.isStatic || x.isSleeping, v = x.parts.length, w = v === 1;
1446
+ for (m = f + 1; m < h; m++) {
1594
1447
  var S = n[m], C = S.bounds;
1595
- if (C.min.x > B) break;
1596
- if (!(g < C.min.y || p > C.max.y) && !(y && (S.isStatic || S.isSleeping)) && l(x.collisionFilter, S.collisionFilter)) {
1448
+ if (C.min.x > T) break;
1449
+ if (!(g < C.min.y || d > C.max.y) && !(y && (S.isStatic || S.isSleeping)) && l(x.collisionFilter, S.collisionFilter)) {
1597
1450
  var M = S.parts.length;
1598
1451
  if (w && M === 1) {
1599
- var I = t(x, S, c);
1452
+ var I = t(x, S, u);
1600
1453
  I && (i[s++] = I);
1601
1454
  } else
1602
- for (var R = v > 1 ? 1 : 0, L = M > 1 ? 1 : 0, b = R; b < v; b++)
1603
- for (var k = x.parts[b], P = k.bounds, D = L; D < M; D++) {
1604
- var F = S.parts[D], C = F.bounds;
1455
+ for (var R = v > 1 ? 1 : 0, L = M > 1 ? 1 : 0, D = R; D < v; D++)
1456
+ for (var k = x.parts[D], P = k.bounds, b = L; b < M; b++) {
1457
+ var O = S.parts[b], C = O.bounds;
1605
1458
  if (!(P.min.x > C.max.x || P.max.x < C.min.x || P.max.y < C.min.y || P.min.y > C.max.y)) {
1606
- var I = t(k, F, c);
1459
+ var I = t(k, O, u);
1607
1460
  I && (i[s++] = I);
1608
1461
  }
1609
1462
  }
@@ -1611,137 +1464,137 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1611
1464
  }
1612
1465
  }
1613
1466
  return i.length !== s && (i.length = s), i;
1614
- }, e.canCollide = function(r, c) {
1615
- return r.group === c.group && r.group !== 0 ? r.group > 0 : (r.mask & c.category) !== 0 && (c.mask & r.category) !== 0;
1616
- }, e._compareBoundsX = function(r, c) {
1617
- return r.bounds.min.x - c.bounds.min.x;
1467
+ }, e.canCollide = function(a, u) {
1468
+ return a.group === u.group && a.group !== 0 ? a.group > 0 : (a.mask & u.category) !== 0 && (u.mask & a.category) !== 0;
1469
+ }, e._compareBoundsX = function(a, u) {
1470
+ return a.bounds.min.x - u.bounds.min.x;
1618
1471
  };
1619
1472
  })();
1620
1473
  }),
1621
- (function(T, A, f) {
1474
+ (function(A, E, c) {
1622
1475
  var e = {};
1623
- T.exports = e;
1624
- var o = f(0);
1476
+ A.exports = e;
1477
+ var o = c(0);
1625
1478
  (function() {
1626
- e.create = function(a) {
1627
- var r = {};
1628
- return a || o.log("Mouse.create: element was undefined, defaulting to document.body", "warn"), r.element = a || document.body, r.absolute = {
1479
+ e.create = function(r) {
1480
+ var a = {};
1481
+ return r || o.log("Mouse.create: element was undefined, defaulting to document.body", "warn"), a.element = r || document.body, a.absolute = {
1629
1482
  x: 0,
1630
1483
  y: 0
1631
- }, r.position = {
1484
+ }, a.position = {
1632
1485
  x: 0,
1633
1486
  y: 0
1634
- }, r.mousedownPosition = {
1487
+ }, a.mousedownPosition = {
1635
1488
  x: 0,
1636
1489
  y: 0
1637
- }, r.mouseupPosition = {
1490
+ }, a.mouseupPosition = {
1638
1491
  x: 0,
1639
1492
  y: 0
1640
- }, r.offset = {
1493
+ }, a.offset = {
1641
1494
  x: 0,
1642
1495
  y: 0
1643
- }, r.scale = {
1496
+ }, a.scale = {
1644
1497
  x: 1,
1645
1498
  y: 1
1646
- }, r.wheelDelta = 0, r.button = -1, r.pixelRatio = parseInt(r.element.getAttribute("data-pixel-ratio"), 10) || 1, r.sourceEvents = {
1499
+ }, a.wheelDelta = 0, a.button = -1, a.pixelRatio = parseInt(a.element.getAttribute("data-pixel-ratio"), 10) || 1, a.sourceEvents = {
1647
1500
  mousemove: null,
1648
1501
  mousedown: null,
1649
1502
  mouseup: null,
1650
1503
  mousewheel: null
1651
- }, r.mousemove = function(c) {
1652
- var n = e._getRelativeMousePosition(c, r.element, r.pixelRatio);
1653
- c.changedTouches && (r.button = 0, c.preventDefault()), r.absolute.x = n.x, r.absolute.y = n.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y, r.sourceEvents.mousemove = c;
1654
- }, r.mousedown = function(c) {
1655
- var n = e._getRelativeMousePosition(c, r.element, r.pixelRatio);
1656
- c.changedTouches ? (r.button = 0, c.preventDefault()) : r.button = c.button, r.absolute.x = n.x, r.absolute.y = n.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y, r.mousedownPosition.x = r.position.x, r.mousedownPosition.y = r.position.y, r.sourceEvents.mousedown = c;
1657
- }, r.mouseup = function(c) {
1658
- var n = e._getRelativeMousePosition(c, r.element, r.pixelRatio);
1659
- c.changedTouches && c.preventDefault(), r.button = -1, r.absolute.x = n.x, r.absolute.y = n.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y, r.mouseupPosition.x = r.position.x, r.mouseupPosition.y = r.position.y, r.sourceEvents.mouseup = c;
1660
- }, r.mousewheel = function(c) {
1661
- r.wheelDelta = Math.max(-1, Math.min(1, c.wheelDelta || -c.detail)), c.preventDefault(), r.sourceEvents.mousewheel = c;
1662
- }, e.setElement(r, r.element), r;
1663
- }, e.setElement = function(a, r) {
1664
- a.element = r, r.addEventListener("mousemove", a.mousemove, { passive: !0 }), r.addEventListener("mousedown", a.mousedown, { passive: !0 }), r.addEventListener("mouseup", a.mouseup, { passive: !0 }), r.addEventListener("wheel", a.mousewheel, { passive: !1 }), r.addEventListener("touchmove", a.mousemove, { passive: !1 }), r.addEventListener("touchstart", a.mousedown, { passive: !1 }), r.addEventListener("touchend", a.mouseup, { passive: !1 });
1665
- }, e.clearSourceEvents = function(a) {
1666
- a.sourceEvents.mousemove = null, a.sourceEvents.mousedown = null, a.sourceEvents.mouseup = null, a.sourceEvents.mousewheel = null, a.wheelDelta = 0;
1667
- }, e.setOffset = function(a, r) {
1668
- a.offset.x = r.x, a.offset.y = r.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y;
1669
- }, e.setScale = function(a, r) {
1670
- a.scale.x = r.x, a.scale.y = r.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y;
1671
- }, e._getRelativeMousePosition = function(a, r, c) {
1672
- var n = r.getBoundingClientRect(), h = document.documentElement || document.body.parentNode || document.body, l = window.pageXOffset !== void 0 ? window.pageXOffset : h.scrollLeft, t = window.pageYOffset !== void 0 ? window.pageYOffset : h.scrollTop, i = a.changedTouches, s, u;
1673
- return i ? (s = i[0].pageX - n.left - l, u = i[0].pageY - n.top - t) : (s = a.pageX - n.left - l, u = a.pageY - n.top - t), {
1674
- x: s / (r.clientWidth / (r.width || r.clientWidth) * c),
1675
- y: u / (r.clientHeight / (r.height || r.clientHeight) * c)
1504
+ }, a.mousemove = function(u) {
1505
+ var n = e._getRelativeMousePosition(u, a.element, a.pixelRatio);
1506
+ u.changedTouches && (a.button = 0, u.preventDefault()), a.absolute.x = n.x, a.absolute.y = n.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y, a.sourceEvents.mousemove = u;
1507
+ }, a.mousedown = function(u) {
1508
+ var n = e._getRelativeMousePosition(u, a.element, a.pixelRatio);
1509
+ u.changedTouches ? (a.button = 0, u.preventDefault()) : a.button = u.button, a.absolute.x = n.x, a.absolute.y = n.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y, a.mousedownPosition.x = a.position.x, a.mousedownPosition.y = a.position.y, a.sourceEvents.mousedown = u;
1510
+ }, a.mouseup = function(u) {
1511
+ var n = e._getRelativeMousePosition(u, a.element, a.pixelRatio);
1512
+ u.changedTouches && u.preventDefault(), a.button = -1, a.absolute.x = n.x, a.absolute.y = n.y, a.position.x = a.absolute.x * a.scale.x + a.offset.x, a.position.y = a.absolute.y * a.scale.y + a.offset.y, a.mouseupPosition.x = a.position.x, a.mouseupPosition.y = a.position.y, a.sourceEvents.mouseup = u;
1513
+ }, a.mousewheel = function(u) {
1514
+ a.wheelDelta = Math.max(-1, Math.min(1, u.wheelDelta || -u.detail)), u.preventDefault(), a.sourceEvents.mousewheel = u;
1515
+ }, e.setElement(a, a.element), a;
1516
+ }, e.setElement = function(r, a) {
1517
+ r.element = a, a.addEventListener("mousemove", r.mousemove, { passive: !0 }), a.addEventListener("mousedown", r.mousedown, { passive: !0 }), a.addEventListener("mouseup", r.mouseup, { passive: !0 }), a.addEventListener("wheel", r.mousewheel, { passive: !1 }), a.addEventListener("touchmove", r.mousemove, { passive: !1 }), a.addEventListener("touchstart", r.mousedown, { passive: !1 }), a.addEventListener("touchend", r.mouseup, { passive: !1 });
1518
+ }, e.clearSourceEvents = function(r) {
1519
+ r.sourceEvents.mousemove = null, r.sourceEvents.mousedown = null, r.sourceEvents.mouseup = null, r.sourceEvents.mousewheel = null, r.wheelDelta = 0;
1520
+ }, e.setOffset = function(r, a) {
1521
+ r.offset.x = a.x, r.offset.y = a.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y;
1522
+ }, e.setScale = function(r, a) {
1523
+ r.scale.x = a.x, r.scale.y = a.y, r.position.x = r.absolute.x * r.scale.x + r.offset.x, r.position.y = r.absolute.y * r.scale.y + r.offset.y;
1524
+ }, e._getRelativeMousePosition = function(r, a, u) {
1525
+ var n = a.getBoundingClientRect(), h = document.documentElement || document.body.parentNode || document.body, l = window.pageXOffset !== void 0 ? window.pageXOffset : h.scrollLeft, t = window.pageYOffset !== void 0 ? window.pageYOffset : h.scrollTop, i = r.changedTouches, s, f;
1526
+ return i ? (s = i[0].pageX - n.left - l, f = i[0].pageY - n.top - t) : (s = r.pageX - n.left - l, f = r.pageY - n.top - t), {
1527
+ x: s / (a.clientWidth / (a.width || a.clientWidth) * u),
1528
+ y: f / (a.clientHeight / (a.height || a.clientHeight) * u)
1676
1529
  };
1677
1530
  };
1678
1531
  })();
1679
1532
  }),
1680
- (function(T, A, f) {
1533
+ (function(A, E, c) {
1681
1534
  var e = {};
1682
- T.exports = e;
1683
- var o = f(0);
1535
+ A.exports = e;
1536
+ var o = c(0);
1684
1537
  (function() {
1685
- e._registry = {}, e.register = function(a) {
1686
- if (e.isPlugin(a) || o.warn("Plugin.register:", e.toString(a), "does not implement all required fields."), a.name in e._registry) {
1687
- var r = e._registry[a.name], c = e.versionParse(a.version).number, n = e.versionParse(r.version).number;
1688
- c > n ? (o.warn("Plugin.register:", e.toString(r), "was upgraded to", e.toString(a)), e._registry[a.name] = a) : c < n ? o.warn("Plugin.register:", e.toString(r), "can not be downgraded to", e.toString(a)) : a !== r && o.warn("Plugin.register:", e.toString(a), "is already registered to different plugin object");
1689
- } else e._registry[a.name] = a;
1690
- return a;
1691
- }, e.resolve = function(a) {
1692
- return e._registry[e.dependencyParse(a).name];
1693
- }, e.toString = function(a) {
1694
- return typeof a == "string" ? a : (a.name || "anonymous") + "@" + (a.version || a.range || "0.0.0");
1695
- }, e.isPlugin = function(a) {
1696
- return a && a.name && a.version && a.install;
1697
- }, e.isUsed = function(a, r) {
1698
- return a.used.indexOf(r) > -1;
1699
- }, e.isFor = function(a, r) {
1700
- var c = a.for && e.dependencyParse(a.for);
1701
- return !a.for || r.name === c.name && e.versionSatisfies(r.version, c.range);
1702
- }, e.use = function(a, r) {
1703
- if (a.uses = (a.uses || []).concat(r || []), a.uses.length === 0) {
1704
- o.warn("Plugin.use:", e.toString(a), "does not specify any dependencies to install.");
1538
+ e._registry = {}, e.register = function(r) {
1539
+ if (e.isPlugin(r) || o.warn("Plugin.register:", e.toString(r), "does not implement all required fields."), r.name in e._registry) {
1540
+ var a = e._registry[r.name], u = e.versionParse(r.version).number, n = e.versionParse(a.version).number;
1541
+ u > n ? (o.warn("Plugin.register:", e.toString(a), "was upgraded to", e.toString(r)), e._registry[r.name] = r) : u < n ? o.warn("Plugin.register:", e.toString(a), "can not be downgraded to", e.toString(r)) : r !== a && o.warn("Plugin.register:", e.toString(r), "is already registered to different plugin object");
1542
+ } else e._registry[r.name] = r;
1543
+ return r;
1544
+ }, e.resolve = function(r) {
1545
+ return e._registry[e.dependencyParse(r).name];
1546
+ }, e.toString = function(r) {
1547
+ return typeof r == "string" ? r : (r.name || "anonymous") + "@" + (r.version || r.range || "0.0.0");
1548
+ }, e.isPlugin = function(r) {
1549
+ return r && r.name && r.version && r.install;
1550
+ }, e.isUsed = function(r, a) {
1551
+ return r.used.indexOf(a) > -1;
1552
+ }, e.isFor = function(r, a) {
1553
+ var u = r.for && e.dependencyParse(r.for);
1554
+ return !r.for || a.name === u.name && e.versionSatisfies(a.version, u.range);
1555
+ }, e.use = function(r, a) {
1556
+ if (r.uses = (r.uses || []).concat(a || []), r.uses.length === 0) {
1557
+ o.warn("Plugin.use:", e.toString(r), "does not specify any dependencies to install.");
1705
1558
  return;
1706
1559
  }
1707
- for (var c = e.dependencies(a), n = o.topologicalSort(c), h = [], l = 0; l < n.length; l += 1)
1708
- if (n[l] !== a.name) {
1560
+ for (var u = e.dependencies(r), n = o.topologicalSort(u), h = [], l = 0; l < n.length; l += 1)
1561
+ if (n[l] !== r.name) {
1709
1562
  var t = e.resolve(n[l]);
1710
1563
  if (!t) {
1711
1564
  h.push("❌ " + n[l]);
1712
1565
  continue;
1713
1566
  }
1714
- e.isUsed(a, t.name) || (e.isFor(t, a) || (o.warn("Plugin.use:", e.toString(t), "is for", t.for, "but installed on", e.toString(a) + "."), t._warned = !0), t.install ? t.install(a) : (o.warn("Plugin.use:", e.toString(t), "does not specify an install function."), t._warned = !0), t._warned ? (h.push("🔶 " + e.toString(t)), delete t._warned) : h.push("✅ " + e.toString(t)), a.used.push(t.name));
1567
+ e.isUsed(r, t.name) || (e.isFor(t, r) || (o.warn("Plugin.use:", e.toString(t), "is for", t.for, "but installed on", e.toString(r) + "."), t._warned = !0), t.install ? t.install(r) : (o.warn("Plugin.use:", e.toString(t), "does not specify an install function."), t._warned = !0), t._warned ? (h.push("🔶 " + e.toString(t)), delete t._warned) : h.push("✅ " + e.toString(t)), r.used.push(t.name));
1715
1568
  }
1716
1569
  h.length > 0 && o.info(h.join(" "));
1717
- }, e.dependencies = function(a, r) {
1718
- var c = e.dependencyParse(a), n = c.name;
1719
- if (r = r || {}, !(n in r)) {
1720
- a = e.resolve(a) || a, r[n] = o.map(a.uses || [], function(l) {
1570
+ }, e.dependencies = function(r, a) {
1571
+ var u = e.dependencyParse(r), n = u.name;
1572
+ if (a = a || {}, !(n in a)) {
1573
+ r = e.resolve(r) || r, a[n] = o.map(r.uses || [], function(l) {
1721
1574
  e.isPlugin(l) && e.register(l);
1722
1575
  var t = e.dependencyParse(l), i = e.resolve(l);
1723
- return i && !e.versionSatisfies(i.version, t.range) ? (o.warn("Plugin.dependencies:", e.toString(i), "does not satisfy", e.toString(t), "used by", e.toString(c) + "."), i._warned = !0, a._warned = !0) : i || (o.warn("Plugin.dependencies:", e.toString(l), "used by", e.toString(c), "could not be resolved."), a._warned = !0), t.name;
1576
+ return i && !e.versionSatisfies(i.version, t.range) ? (o.warn("Plugin.dependencies:", e.toString(i), "does not satisfy", e.toString(t), "used by", e.toString(u) + "."), i._warned = !0, r._warned = !0) : i || (o.warn("Plugin.dependencies:", e.toString(l), "used by", e.toString(u), "could not be resolved."), r._warned = !0), t.name;
1724
1577
  });
1725
- for (var h = 0; h < r[n].length; h += 1) e.dependencies(r[n][h], r);
1726
- return r;
1578
+ for (var h = 0; h < a[n].length; h += 1) e.dependencies(a[n][h], a);
1579
+ return a;
1727
1580
  }
1728
- }, e.dependencyParse = function(a) {
1729
- return o.isString(a) ? (/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/.test(a) || o.warn("Plugin.dependencyParse:", a, "is not a valid dependency string."), {
1730
- name: a.split("@")[0],
1731
- range: a.split("@")[1] || "*"
1581
+ }, e.dependencyParse = function(r) {
1582
+ return o.isString(r) ? (/^[\w-]+(@(\*|[\^~]?\d+\.\d+\.\d+(-[0-9A-Za-z-+]+)?))?$/.test(r) || o.warn("Plugin.dependencyParse:", r, "is not a valid dependency string."), {
1583
+ name: r.split("@")[0],
1584
+ range: r.split("@")[1] || "*"
1732
1585
  }) : {
1733
- name: a.name,
1734
- range: a.range || a.version
1586
+ name: r.name,
1587
+ range: r.range || r.version
1735
1588
  };
1736
- }, e.versionParse = function(a) {
1737
- var r = /^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;
1738
- r.test(a) || o.warn("Plugin.versionParse:", a, "is not a valid version or range.");
1739
- var c = r.exec(a), n = Number(c[4]), h = Number(c[5]), l = Number(c[6]);
1589
+ }, e.versionParse = function(r) {
1590
+ var a = /^(\*)|(\^|~|>=|>)?\s*((\d+)\.(\d+)\.(\d+))(-[0-9A-Za-z-+]+)?$/;
1591
+ a.test(r) || o.warn("Plugin.versionParse:", r, "is not a valid version or range.");
1592
+ var u = a.exec(r), n = Number(u[4]), h = Number(u[5]), l = Number(u[6]);
1740
1593
  return {
1741
- isRange: !!(c[1] || c[2]),
1742
- version: c[3],
1743
- range: a,
1744
- operator: c[1] || c[2] || "",
1594
+ isRange: !!(u[1] || u[2]),
1595
+ version: u[3],
1596
+ range: r,
1597
+ operator: u[1] || u[2] || "",
1745
1598
  major: n,
1746
1599
  minor: h,
1747
1600
  patch: l,
@@ -1750,28 +1603,28 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1750
1603
  h,
1751
1604
  l
1752
1605
  ],
1753
- prerelease: c[7],
1606
+ prerelease: u[7],
1754
1607
  number: n * 1e8 + h * 1e4 + l
1755
1608
  };
1756
- }, e.versionSatisfies = function(a, r) {
1757
- r = r || "*";
1758
- var c = e.versionParse(r), n = e.versionParse(a);
1759
- if (c.isRange) {
1760
- if (c.operator === "*" || a === "*") return !0;
1761
- if (c.operator === ">") return n.number > c.number;
1762
- if (c.operator === ">=") return n.number >= c.number;
1763
- if (c.operator === "~") return n.major === c.major && n.minor === c.minor && n.patch >= c.patch;
1764
- if (c.operator === "^")
1765
- return c.major > 0 ? n.major === c.major && n.number >= c.number : c.minor > 0 ? n.minor === c.minor && n.patch >= c.patch : n.patch === c.patch;
1766
- }
1767
- return a === r || a === "*";
1609
+ }, e.versionSatisfies = function(r, a) {
1610
+ a = a || "*";
1611
+ var u = e.versionParse(a), n = e.versionParse(r);
1612
+ if (u.isRange) {
1613
+ if (u.operator === "*" || r === "*") return !0;
1614
+ if (u.operator === ">") return n.number > u.number;
1615
+ if (u.operator === ">=") return n.number >= u.number;
1616
+ if (u.operator === "~") return n.major === u.major && n.minor === u.minor && n.patch >= u.patch;
1617
+ if (u.operator === "^")
1618
+ return u.major > 0 ? n.major === u.major && n.number >= u.number : u.minor > 0 ? n.minor === u.minor && n.patch >= u.patch : n.patch === u.patch;
1619
+ }
1620
+ return r === a || r === "*";
1768
1621
  };
1769
1622
  })();
1770
1623
  }),
1771
- (function(T, A) {
1772
- var f = {};
1773
- T.exports = f, (function() {
1774
- f.create = function(e) {
1624
+ (function(A, E) {
1625
+ var c = {};
1626
+ A.exports = c, (function() {
1627
+ c.create = function(e) {
1775
1628
  return {
1776
1629
  vertex: e,
1777
1630
  normalImpulse: 0,
@@ -1780,14 +1633,14 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1780
1633
  };
1781
1634
  })();
1782
1635
  }),
1783
- (function(T, A, f) {
1636
+ (function(A, E, c) {
1784
1637
  var e = {};
1785
- T.exports = e;
1786
- var o = f(7), a = f(18), r = f(13), c = f(19), n = f(5), h = f(6), l = f(10), t = f(0), i = f(4);
1638
+ A.exports = e;
1639
+ var o = c(7), r = c(18), a = c(13), u = c(19), n = c(5), h = c(6), l = c(10), t = c(0), i = c(4);
1787
1640
  (function() {
1788
1641
  e._deltaMax = 1e3 / 60, e.create = function(s) {
1789
1642
  s = s || {};
1790
- var u = t.extend({
1643
+ var f = t.extend({
1791
1644
  positionIterations: 6,
1792
1645
  velocityIterations: 4,
1793
1646
  constraintIterations: 2,
@@ -1807,284 +1660,284 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
1807
1660
  lastUpdatesPerFrame: 0
1808
1661
  }
1809
1662
  }, s);
1810
- return u.world = s.world || h.create({ label: "World" }), u.pairs = s.pairs || c.create(), u.detector = s.detector || r.create(), u.detector.pairs = u.pairs, u.grid = { buckets: [] }, u.world.gravity = u.gravity, u.broadphase = u.grid, u.metrics = {}, u;
1811
- }, e.update = function(s, u) {
1812
- var m = t.now(), x = s.world, P = s.detector, B = s.pairs, g = s.timing, p = g.timestamp, y;
1813
- u > e._deltaMax && t.warnOnce("Matter.Engine.update: delta argument is recommended to be less than or equal to", e._deltaMax.toFixed(3), "ms."), u = typeof u < "u" ? u : t._baseDelta, u *= g.timeScale, g.timestamp += u, g.lastDelta = u;
1663
+ return f.world = s.world || h.create({ label: "World" }), f.pairs = s.pairs || u.create(), f.detector = s.detector || a.create(), f.detector.pairs = f.pairs, f.grid = { buckets: [] }, f.world.gravity = f.gravity, f.broadphase = f.grid, f.metrics = {}, f;
1664
+ }, e.update = function(s, f) {
1665
+ var m = t.now(), x = s.world, P = s.detector, T = s.pairs, g = s.timing, d = g.timestamp, y;
1666
+ f > e._deltaMax && t.warnOnce("Matter.Engine.update: delta argument is recommended to be less than or equal to", e._deltaMax.toFixed(3), "ms."), f = typeof f < "u" ? f : t._baseDelta, f *= g.timeScale, g.timestamp += f, g.lastDelta = f;
1814
1667
  var v = {
1815
1668
  timestamp: g.timestamp,
1816
- delta: u
1669
+ delta: f
1817
1670
  };
1818
1671
  n.trigger(s, "beforeUpdate", v);
1819
1672
  var w = h.allBodies(x), S = h.allConstraints(x);
1820
- for (x.isModified && (r.setBodies(P, w), h.setModified(x, !1, !1, !0)), s.enableSleeping && o.update(w, u), e._bodiesApplyGravity(w, s.gravity), u > 0 && e._bodiesUpdate(w, u), n.trigger(s, "beforeSolve", v), l.preSolveAll(w), y = 0; y < s.constraintIterations; y++) l.solveAll(S, u);
1673
+ for (x.isModified && (a.setBodies(P, w), h.setModified(x, !1, !1, !0)), s.enableSleeping && o.update(w, f), e._bodiesApplyGravity(w, s.gravity), f > 0 && e._bodiesUpdate(w, f), n.trigger(s, "beforeSolve", v), l.preSolveAll(w), y = 0; y < s.constraintIterations; y++) l.solveAll(S, f);
1821
1674
  l.postSolveAll(w);
1822
- var C = r.collisions(P);
1823
- c.update(B, C, p), s.enableSleeping && o.afterCollisions(B.list), B.collisionStart.length > 0 && n.trigger(s, "collisionStart", {
1824
- pairs: B.collisionStart,
1675
+ var C = a.collisions(P);
1676
+ u.update(T, C, d), s.enableSleeping && o.afterCollisions(T.list), T.collisionStart.length > 0 && n.trigger(s, "collisionStart", {
1677
+ pairs: T.collisionStart,
1825
1678
  timestamp: g.timestamp,
1826
- delta: u
1679
+ delta: f
1827
1680
  });
1828
1681
  var M = t.clamp(20 / s.positionIterations, 0, 1);
1829
- for (a.preSolvePosition(B.list), y = 0; y < s.positionIterations; y++) a.solvePosition(B.list, u, M);
1830
- for (a.postSolvePosition(w), l.preSolveAll(w), y = 0; y < s.constraintIterations; y++) l.solveAll(S, u);
1831
- for (l.postSolveAll(w), a.preSolveVelocity(B.list), y = 0; y < s.velocityIterations; y++) a.solveVelocity(B.list, u);
1832
- return e._bodiesUpdateVelocities(w), B.collisionActive.length > 0 && n.trigger(s, "collisionActive", {
1833
- pairs: B.collisionActive,
1682
+ for (r.preSolvePosition(T.list), y = 0; y < s.positionIterations; y++) r.solvePosition(T.list, f, M);
1683
+ for (r.postSolvePosition(w), l.preSolveAll(w), y = 0; y < s.constraintIterations; y++) l.solveAll(S, f);
1684
+ for (l.postSolveAll(w), r.preSolveVelocity(T.list), y = 0; y < s.velocityIterations; y++) r.solveVelocity(T.list, f);
1685
+ return e._bodiesUpdateVelocities(w), T.collisionActive.length > 0 && n.trigger(s, "collisionActive", {
1686
+ pairs: T.collisionActive,
1834
1687
  timestamp: g.timestamp,
1835
- delta: u
1836
- }), B.collisionEnd.length > 0 && n.trigger(s, "collisionEnd", {
1837
- pairs: B.collisionEnd,
1688
+ delta: f
1689
+ }), T.collisionEnd.length > 0 && n.trigger(s, "collisionEnd", {
1690
+ pairs: T.collisionEnd,
1838
1691
  timestamp: g.timestamp,
1839
- delta: u
1692
+ delta: f
1840
1693
  }), e._bodiesClearForces(w), n.trigger(s, "afterUpdate", v), s.timing.lastElapsed = t.now() - m, s;
1841
- }, e.merge = function(s, u) {
1842
- if (t.extend(s, u), u.world) {
1843
- s.world = u.world, e.clear(s);
1694
+ }, e.merge = function(s, f) {
1695
+ if (t.extend(s, f), f.world) {
1696
+ s.world = f.world, e.clear(s);
1844
1697
  for (var m = h.allBodies(s.world), x = 0; x < m.length; x++) {
1845
1698
  var P = m[x];
1846
1699
  o.set(P, !1), P.id = t.nextId();
1847
1700
  }
1848
1701
  }
1849
1702
  }, e.clear = function(s) {
1850
- c.clear(s.pairs), r.clear(s.detector);
1703
+ u.clear(s.pairs), a.clear(s.detector);
1851
1704
  }, e._bodiesClearForces = function(s) {
1852
- for (var u = s.length, m = 0; m < u; m++) {
1705
+ for (var f = s.length, m = 0; m < f; m++) {
1853
1706
  var x = s[m];
1854
1707
  x.force.x = 0, x.force.y = 0, x.torque = 0;
1855
1708
  }
1856
- }, e._bodiesApplyGravity = function(s, u) {
1857
- var m = typeof u.scale < "u" ? u.scale : 1e-3, x = s.length;
1858
- if (!(u.x === 0 && u.y === 0 || m === 0))
1709
+ }, e._bodiesApplyGravity = function(s, f) {
1710
+ var m = typeof f.scale < "u" ? f.scale : 1e-3, x = s.length;
1711
+ if (!(f.x === 0 && f.y === 0 || m === 0))
1859
1712
  for (var P = 0; P < x; P++) {
1860
- var B = s[P];
1861
- B.isStatic || B.isSleeping || (B.force.y += B.mass * u.y * m, B.force.x += B.mass * u.x * m);
1713
+ var T = s[P];
1714
+ T.isStatic || T.isSleeping || (T.force.y += T.mass * f.y * m, T.force.x += T.mass * f.x * m);
1862
1715
  }
1863
- }, e._bodiesUpdate = function(s, u) {
1716
+ }, e._bodiesUpdate = function(s, f) {
1864
1717
  for (var m = s.length, x = 0; x < m; x++) {
1865
1718
  var P = s[x];
1866
- P.isStatic || P.isSleeping || i.update(P, u);
1719
+ P.isStatic || P.isSleeping || i.update(P, f);
1867
1720
  }
1868
1721
  }, e._bodiesUpdateVelocities = function(s) {
1869
- for (var u = s.length, m = 0; m < u; m++) i.updateVelocities(s[m]);
1722
+ for (var f = s.length, m = 0; m < f; m++) i.updateVelocities(s[m]);
1870
1723
  };
1871
1724
  })();
1872
1725
  }),
1873
- (function(T, A, f) {
1726
+ (function(A, E, c) {
1874
1727
  var e = {};
1875
- T.exports = e;
1876
- var o = f(3), a = f(0), r = f(1);
1728
+ A.exports = e;
1729
+ var o = c(3), r = c(0), a = c(1);
1877
1730
  (function() {
1878
- e._restingThresh = 2, e._restingThreshTangent = Math.sqrt(6), e._positionDampen = 0.9, e._positionWarming = 0.8, e._frictionNormalMultiplier = 5, e._frictionMaxStatic = Number.MAX_VALUE, e.preSolvePosition = function(c) {
1879
- var n, h, l, t = c.length;
1731
+ e._restingThresh = 2, e._restingThreshTangent = Math.sqrt(6), e._positionDampen = 0.9, e._positionWarming = 0.8, e._frictionNormalMultiplier = 5, e._frictionMaxStatic = Number.MAX_VALUE, e.preSolvePosition = function(u) {
1732
+ var n, h, l, t = u.length;
1880
1733
  for (n = 0; n < t; n++)
1881
- h = c[n], h.isActive && (l = h.contactCount, h.collision.parentA.totalContacts += l, h.collision.parentB.totalContacts += l);
1882
- }, e.solvePosition = function(c, n, h) {
1883
- var l, t, i, s, u, m, x, P, B = e._positionDampen * (h || 1), g = a.clamp(n / a._baseDelta, 0, 1), p = c.length;
1884
- for (l = 0; l < p; l++)
1885
- t = c[l], !(!t.isActive || t.isSensor) && (i = t.collision, s = i.parentA, u = i.parentB, m = i.normal, t.separation = i.depth + m.x * (u.positionImpulse.x - s.positionImpulse.x) + m.y * (u.positionImpulse.y - s.positionImpulse.y));
1886
- for (l = 0; l < p; l++)
1887
- t = c[l], !(!t.isActive || t.isSensor) && (i = t.collision, s = i.parentA, u = i.parentB, m = i.normal, P = t.separation - t.slop * g, (s.isStatic || u.isStatic) && (P *= 2), s.isStatic || s.isSleeping || (x = B / s.totalContacts, s.positionImpulse.x += m.x * P * x, s.positionImpulse.y += m.y * P * x), u.isStatic || u.isSleeping || (x = B / u.totalContacts, u.positionImpulse.x -= m.x * P * x, u.positionImpulse.y -= m.y * P * x));
1888
- }, e.postSolvePosition = function(c) {
1889
- for (var n = e._positionWarming, h = c.length, l = o.translate, t = r.update, i = 0; i < h; i++) {
1890
- var s = c[i], u = s.positionImpulse, m = u.x, x = u.y, P = s.velocity;
1734
+ h = u[n], h.isActive && (l = h.contactCount, h.collision.parentA.totalContacts += l, h.collision.parentB.totalContacts += l);
1735
+ }, e.solvePosition = function(u, n, h) {
1736
+ var l, t, i, s, f, m, x, P, T = e._positionDampen * (h || 1), g = r.clamp(n / r._baseDelta, 0, 1), d = u.length;
1737
+ for (l = 0; l < d; l++)
1738
+ t = u[l], !(!t.isActive || t.isSensor) && (i = t.collision, s = i.parentA, f = i.parentB, m = i.normal, t.separation = i.depth + m.x * (f.positionImpulse.x - s.positionImpulse.x) + m.y * (f.positionImpulse.y - s.positionImpulse.y));
1739
+ for (l = 0; l < d; l++)
1740
+ t = u[l], !(!t.isActive || t.isSensor) && (i = t.collision, s = i.parentA, f = i.parentB, m = i.normal, P = t.separation - t.slop * g, (s.isStatic || f.isStatic) && (P *= 2), s.isStatic || s.isSleeping || (x = T / s.totalContacts, s.positionImpulse.x += m.x * P * x, s.positionImpulse.y += m.y * P * x), f.isStatic || f.isSleeping || (x = T / f.totalContacts, f.positionImpulse.x -= m.x * P * x, f.positionImpulse.y -= m.y * P * x));
1741
+ }, e.postSolvePosition = function(u) {
1742
+ for (var n = e._positionWarming, h = u.length, l = o.translate, t = a.update, i = 0; i < h; i++) {
1743
+ var s = u[i], f = s.positionImpulse, m = f.x, x = f.y, P = s.velocity;
1891
1744
  if (s.totalContacts = 0, m !== 0 || x !== 0) {
1892
- for (var B = 0; B < s.parts.length; B++) {
1893
- var g = s.parts[B];
1894
- l(g.vertices, u), t(g.bounds, g.vertices, P), g.position.x += m, g.position.y += x;
1745
+ for (var T = 0; T < s.parts.length; T++) {
1746
+ var g = s.parts[T];
1747
+ l(g.vertices, f), t(g.bounds, g.vertices, P), g.position.x += m, g.position.y += x;
1895
1748
  }
1896
- s.positionPrev.x += m, s.positionPrev.y += x, m * P.x + x * P.y < 0 ? (u.x = 0, u.y = 0) : (u.x *= n, u.y *= n);
1749
+ s.positionPrev.x += m, s.positionPrev.y += x, m * P.x + x * P.y < 0 ? (f.x = 0, f.y = 0) : (f.x *= n, f.y *= n);
1897
1750
  }
1898
1751
  }
1899
- }, e.preSolveVelocity = function(c) {
1900
- var n = c.length, h, l;
1752
+ }, e.preSolveVelocity = function(u) {
1753
+ var n = u.length, h, l;
1901
1754
  for (h = 0; h < n; h++) {
1902
- var t = c[h];
1755
+ var t = u[h];
1903
1756
  if (!(!t.isActive || t.isSensor)) {
1904
- var i = t.contacts, s = t.contactCount, u = t.collision, m = u.parentA, x = u.parentB, P = u.normal, B = u.tangent;
1757
+ var i = t.contacts, s = t.contactCount, f = t.collision, m = f.parentA, x = f.parentB, P = f.normal, T = f.tangent;
1905
1758
  for (l = 0; l < s; l++) {
1906
- var g = i[l], p = g.vertex, y = g.normalImpulse, v = g.tangentImpulse;
1759
+ var g = i[l], d = g.vertex, y = g.normalImpulse, v = g.tangentImpulse;
1907
1760
  if (y !== 0 || v !== 0) {
1908
- var w = P.x * y + B.x * v, S = P.y * y + B.y * v;
1909
- m.isStatic || m.isSleeping || (m.positionPrev.x += w * m.inverseMass, m.positionPrev.y += S * m.inverseMass, m.anglePrev += m.inverseInertia * ((p.x - m.position.x) * S - (p.y - m.position.y) * w)), x.isStatic || x.isSleeping || (x.positionPrev.x -= w * x.inverseMass, x.positionPrev.y -= S * x.inverseMass, x.anglePrev -= x.inverseInertia * ((p.x - x.position.x) * S - (p.y - x.position.y) * w));
1761
+ var w = P.x * y + T.x * v, S = P.y * y + T.y * v;
1762
+ m.isStatic || m.isSleeping || (m.positionPrev.x += w * m.inverseMass, m.positionPrev.y += S * m.inverseMass, m.anglePrev += m.inverseInertia * ((d.x - m.position.x) * S - (d.y - m.position.y) * w)), x.isStatic || x.isSleeping || (x.positionPrev.x -= w * x.inverseMass, x.positionPrev.y -= S * x.inverseMass, x.anglePrev -= x.inverseInertia * ((d.x - x.position.x) * S - (d.y - x.position.y) * w));
1910
1763
  }
1911
1764
  }
1912
1765
  }
1913
1766
  }
1914
- }, e.solveVelocity = function(c, n) {
1915
- var h = n / a._baseDelta, l = h * h * h, t = -e._restingThresh * h, i = e._restingThreshTangent, s = e._frictionNormalMultiplier * h, u = e._frictionMaxStatic, m = c.length, x, P, B, g;
1916
- for (B = 0; B < m; B++) {
1917
- var p = c[B];
1918
- if (!(!p.isActive || p.isSensor)) {
1919
- var y = p.collision, v = y.parentA, w = y.parentB, S = y.normal.x, C = y.normal.y, M = y.tangent.x, I = y.tangent.y, R = p.inverseMass, L = p.friction * p.frictionStatic * s, b = p.contacts, k = p.contactCount, D = 1 / k, F = v.position.x - v.positionPrev.x, H = v.position.y - v.positionPrev.y, G = v.angle - v.anglePrev, V = w.position.x - w.positionPrev.x, Q = w.position.y - w.positionPrev.y, X = w.angle - w.anglePrev;
1767
+ }, e.solveVelocity = function(u, n) {
1768
+ var h = n / r._baseDelta, l = h * h * h, t = -e._restingThresh * h, i = e._restingThreshTangent, s = e._frictionNormalMultiplier * h, f = e._frictionMaxStatic, m = u.length, x, P, T, g;
1769
+ for (T = 0; T < m; T++) {
1770
+ var d = u[T];
1771
+ if (!(!d.isActive || d.isSensor)) {
1772
+ var y = d.collision, v = y.parentA, w = y.parentB, S = y.normal.x, C = y.normal.y, M = y.tangent.x, I = y.tangent.y, R = d.inverseMass, L = d.friction * d.frictionStatic * s, D = d.contacts, k = d.contactCount, b = 1 / k, O = v.position.x - v.positionPrev.x, W = v.position.y - v.positionPrev.y, G = v.angle - v.anglePrev, N = w.position.x - w.positionPrev.x, Q = w.position.y - w.positionPrev.y, X = w.angle - w.anglePrev;
1920
1773
  for (g = 0; g < k; g++) {
1921
- var U = b[g], W = U.vertex, N = W.x - v.position.x, J = W.y - v.position.y, K = W.x - w.position.x, Y = W.y - w.position.y, z = F - J * G, we = H + N * G, Pe = V - Y * X, Ce = Q + K * X, ue = z - Pe, fe = we - Ce, se = S * ue + C * fe, $ = M * ue + I * fe, ce = p.separation + se, re = Math.min(ce, 1);
1922
- re = ce < 0 ? 0 : re;
1923
- var he = re * L;
1924
- $ < -he || $ > he ? (P = $ > 0 ? $ : -$, x = p.friction * ($ > 0 ? 1 : -1) * l, x < -P ? x = -P : x > P && (x = P)) : (x = $, P = u);
1925
- var ge = N * C - J * S, de = K * C - Y * S, ve = D / (R + v.inverseInertia * ge * ge + w.inverseInertia * de * de), j = (1 + p.restitution) * se * ve;
1926
- if (x *= ve, se < t) U.normalImpulse = 0;
1774
+ var F = D[g], H = F.vertex, V = H.x - v.position.x, J = H.y - v.position.y, Y = H.x - w.position.x, K = H.y - w.position.y, z = O - J * G, xe = W + V * G, ye = N - K * X, Se = Q + Y * X, le = z - ye, fe = xe - Se, se = S * le + C * fe, $ = M * le + I * fe, ce = d.separation + se, ae = Math.min(ce, 1);
1775
+ ae = ce < 0 ? 0 : ae;
1776
+ var ue = ae * L;
1777
+ $ < -ue || $ > ue ? (P = $ > 0 ? $ : -$, x = d.friction * ($ > 0 ? 1 : -1) * l, x < -P ? x = -P : x > P && (x = P)) : (x = $, P = f);
1778
+ var he = V * C - J * S, ge = Y * C - K * S, ve = b / (R + v.inverseInertia * he * he + w.inverseInertia * ge * ge), j = (1 + d.restitution) * se * ve;
1779
+ if (x *= ve, se < t) F.normalImpulse = 0;
1927
1780
  else {
1928
- var Me = U.normalImpulse;
1929
- U.normalImpulse += j, U.normalImpulse > 0 && (U.normalImpulse = 0), j = U.normalImpulse - Me;
1781
+ var we = F.normalImpulse;
1782
+ F.normalImpulse += j, F.normalImpulse > 0 && (F.normalImpulse = 0), j = F.normalImpulse - we;
1930
1783
  }
1931
- if ($ < -i || $ > i) U.tangentImpulse = 0;
1784
+ if ($ < -i || $ > i) F.tangentImpulse = 0;
1932
1785
  else {
1933
- var Te = U.tangentImpulse;
1934
- U.tangentImpulse += x, U.tangentImpulse < -P && (U.tangentImpulse = -P), U.tangentImpulse > P && (U.tangentImpulse = P), x = U.tangentImpulse - Te;
1786
+ var Pe = F.tangentImpulse;
1787
+ F.tangentImpulse += x, F.tangentImpulse < -P && (F.tangentImpulse = -P), F.tangentImpulse > P && (F.tangentImpulse = P), x = F.tangentImpulse - Pe;
1935
1788
  }
1936
1789
  var q = S * j + M * x, _ = C * j + I * x;
1937
- v.isStatic || v.isSleeping || (v.positionPrev.x += q * v.inverseMass, v.positionPrev.y += _ * v.inverseMass, v.anglePrev += (N * _ - J * q) * v.inverseInertia), w.isStatic || w.isSleeping || (w.positionPrev.x -= q * w.inverseMass, w.positionPrev.y -= _ * w.inverseMass, w.anglePrev -= (K * _ - Y * q) * w.inverseInertia);
1790
+ v.isStatic || v.isSleeping || (v.positionPrev.x += q * v.inverseMass, v.positionPrev.y += _ * v.inverseMass, v.anglePrev += (V * _ - J * q) * v.inverseInertia), w.isStatic || w.isSleeping || (w.positionPrev.x -= q * w.inverseMass, w.positionPrev.y -= _ * w.inverseMass, w.anglePrev -= (Y * _ - K * q) * w.inverseInertia);
1938
1791
  }
1939
1792
  }
1940
1793
  }
1941
1794
  };
1942
1795
  })();
1943
1796
  }),
1944
- (function(T, A, f) {
1797
+ (function(A, E, c) {
1945
1798
  var e = {};
1946
- T.exports = e;
1947
- var o = f(9), a = f(0);
1799
+ A.exports = e;
1800
+ var o = c(9), r = c(0);
1948
1801
  (function() {
1949
- e.create = function(r) {
1950
- return a.extend({
1802
+ e.create = function(a) {
1803
+ return r.extend({
1951
1804
  table: {},
1952
1805
  list: [],
1953
1806
  collisionStart: [],
1954
1807
  collisionActive: [],
1955
1808
  collisionEnd: []
1956
- }, r);
1957
- }, e.update = function(r, c, n) {
1958
- var h = o.update, l = o.create, t = o.setActive, i = r.table, s = r.list, u = s.length, m = u, x = r.collisionStart, P = r.collisionEnd, B = r.collisionActive, g = c.length, p = 0, y = 0, v = 0, w, S, C;
1809
+ }, a);
1810
+ }, e.update = function(a, u, n) {
1811
+ var h = o.update, l = o.create, t = o.setActive, i = a.table, s = a.list, f = s.length, m = f, x = a.collisionStart, P = a.collisionEnd, T = a.collisionActive, g = u.length, d = 0, y = 0, v = 0, w, S, C;
1959
1812
  for (C = 0; C < g; C++)
1960
- w = c[C], S = w.pair, S ? (S.isActive && (B[v++] = S), h(S, w, n)) : (S = l(w, n), i[S.id] = S, x[p++] = S, s[m++] = S);
1961
- for (m = 0, u = s.length, C = 0; C < u; C++)
1813
+ w = u[C], S = w.pair, S ? (S.isActive && (T[v++] = S), h(S, w, n)) : (S = l(w, n), i[S.id] = S, x[d++] = S, s[m++] = S);
1814
+ for (m = 0, f = s.length, C = 0; C < f; C++)
1962
1815
  S = s[C], S.timeUpdated >= n ? s[m++] = S : (t(S, !1, n), S.collision.bodyA.sleepCounter > 0 && S.collision.bodyB.sleepCounter > 0 ? s[m++] = S : (P[y++] = S, delete i[S.id]));
1963
- s.length !== m && (s.length = m), x.length !== p && (x.length = p), P.length !== y && (P.length = y), B.length !== v && (B.length = v);
1964
- }, e.clear = function(r) {
1965
- return r.table = {}, r.list.length = 0, r.collisionStart.length = 0, r.collisionActive.length = 0, r.collisionEnd.length = 0, r;
1816
+ s.length !== m && (s.length = m), x.length !== d && (x.length = d), P.length !== y && (P.length = y), T.length !== v && (T.length = v);
1817
+ }, e.clear = function(a) {
1818
+ return a.table = {}, a.list.length = 0, a.collisionStart.length = 0, a.collisionActive.length = 0, a.collisionEnd.length = 0, a;
1966
1819
  };
1967
1820
  })();
1968
1821
  }),
1969
- (function(T, A, f) {
1970
- var e = T.exports = f(21);
1971
- e.Axes = f(11), e.Bodies = f(12), e.Body = f(4), e.Bounds = f(1), e.Collision = f(8), e.Common = f(0), e.Composite = f(6), e.Composites = f(22), e.Constraint = f(10), e.Contact = f(16), e.Detector = f(13), e.Engine = f(17), e.Events = f(5), e.Grid = f(23), e.Mouse = f(14), e.MouseConstraint = f(24), e.Pair = f(9), e.Pairs = f(19), e.Plugin = f(15), e.Query = f(25), e.Render = f(26), e.Resolver = f(18), e.Runner = f(27), e.SAT = f(28), e.Sleeping = f(7), e.Svg = f(29), e.Vector = f(2), e.Vertices = f(3), e.World = f(30), e.Engine.run = e.Runner.run, e.Common.deprecated(e.Engine, "run", "Engine.run ➤ use Matter.Runner.run(engine) instead");
1822
+ (function(A, E, c) {
1823
+ var e = A.exports = c(21);
1824
+ e.Axes = c(11), e.Bodies = c(12), e.Body = c(4), e.Bounds = c(1), e.Collision = c(8), e.Common = c(0), e.Composite = c(6), e.Composites = c(22), e.Constraint = c(10), e.Contact = c(16), e.Detector = c(13), e.Engine = c(17), e.Events = c(5), e.Grid = c(23), e.Mouse = c(14), e.MouseConstraint = c(24), e.Pair = c(9), e.Pairs = c(19), e.Plugin = c(15), e.Query = c(25), e.Render = c(26), e.Resolver = c(18), e.Runner = c(27), e.SAT = c(28), e.Sleeping = c(7), e.Svg = c(29), e.Vector = c(2), e.Vertices = c(3), e.World = c(30), e.Engine.run = e.Runner.run, e.Common.deprecated(e.Engine, "run", "Engine.run ➤ use Matter.Runner.run(engine) instead");
1972
1825
  }),
1973
- (function(T, A, f) {
1826
+ (function(A, E, c) {
1974
1827
  var e = {};
1975
- T.exports = e;
1976
- var o = f(15), a = f(0);
1828
+ A.exports = e;
1829
+ var o = c(15), r = c(0);
1977
1830
  (function() {
1978
1831
  e.name = "matter-js", e.version = "0.20.0", e.uses = [], e.used = [], e.use = function() {
1979
1832
  o.use(e, Array.prototype.slice.call(arguments));
1980
- }, e.before = function(r, c) {
1981
- return r = r.replace(/^Matter./, ""), a.chainPathBefore(e, r, c);
1982
- }, e.after = function(r, c) {
1983
- return r = r.replace(/^Matter./, ""), a.chainPathAfter(e, r, c);
1833
+ }, e.before = function(a, u) {
1834
+ return a = a.replace(/^Matter./, ""), r.chainPathBefore(e, a, u);
1835
+ }, e.after = function(a, u) {
1836
+ return a = a.replace(/^Matter./, ""), r.chainPathAfter(e, a, u);
1984
1837
  };
1985
1838
  })();
1986
1839
  }),
1987
- (function(T, A, f) {
1840
+ (function(A, E, c) {
1988
1841
  var e = {};
1989
- T.exports = e;
1990
- var o = f(6), a = f(10), r = f(0), c = f(4), n = f(12), h = r.deprecated;
1842
+ A.exports = e;
1843
+ var o = c(6), r = c(10), a = c(0), u = c(4), n = c(12), h = a.deprecated;
1991
1844
  (function() {
1992
- e.stack = function(l, t, i, s, u, m, x) {
1993
- for (var P = o.create({ label: "Stack" }), B = l, g = t, p, y = 0, v = 0; v < s; v++) {
1845
+ e.stack = function(l, t, i, s, f, m, x) {
1846
+ for (var P = o.create({ label: "Stack" }), T = l, g = t, d, y = 0, v = 0; v < s; v++) {
1994
1847
  for (var w = 0, S = 0; S < i; S++) {
1995
- var C = x(B, g, S, v, p, y);
1848
+ var C = x(T, g, S, v, d, y);
1996
1849
  if (C) {
1997
1850
  var M = C.bounds.max.y - C.bounds.min.y, I = C.bounds.max.x - C.bounds.min.x;
1998
- M > w && (w = M), c.translate(C, {
1851
+ M > w && (w = M), u.translate(C, {
1999
1852
  x: I * 0.5,
2000
1853
  y: M * 0.5
2001
- }), B = C.bounds.max.x + u, o.addBody(P, C), p = C, y += 1;
2002
- } else B += u;
1854
+ }), T = C.bounds.max.x + f, o.addBody(P, C), d = C, y += 1;
1855
+ } else T += f;
2003
1856
  }
2004
- g += w + m, B = l;
1857
+ g += w + m, T = l;
2005
1858
  }
2006
1859
  return P;
2007
- }, e.chain = function(l, t, i, s, u, m) {
1860
+ }, e.chain = function(l, t, i, s, f, m) {
2008
1861
  for (var x = l.bodies, P = 1; P < x.length; P++) {
2009
- var B = x[P - 1], g = x[P], p = B.bounds.max.y - B.bounds.min.y, y = B.bounds.max.x - B.bounds.min.x, v = g.bounds.max.y - g.bounds.min.y, w = g.bounds.max.x - g.bounds.min.x, S = {
2010
- bodyA: B,
1862
+ var T = x[P - 1], g = x[P], d = T.bounds.max.y - T.bounds.min.y, y = T.bounds.max.x - T.bounds.min.x, v = g.bounds.max.y - g.bounds.min.y, w = g.bounds.max.x - g.bounds.min.x, S = {
1863
+ bodyA: T,
2011
1864
  pointA: {
2012
1865
  x: y * t,
2013
- y: p * i
1866
+ y: d * i
2014
1867
  },
2015
1868
  bodyB: g,
2016
1869
  pointB: {
2017
1870
  x: w * s,
2018
- y: v * u
1871
+ y: v * f
2019
1872
  }
2020
- }, C = r.extend(S, m);
2021
- o.addConstraint(l, a.create(C));
1873
+ }, C = a.extend(S, m);
1874
+ o.addConstraint(l, r.create(C));
2022
1875
  }
2023
1876
  return l.label += " Chain", l;
2024
- }, e.mesh = function(l, t, i, s, u) {
2025
- var m = l.bodies, x, P, B, g, p;
1877
+ }, e.mesh = function(l, t, i, s, f) {
1878
+ var m = l.bodies, x, P, T, g, d;
2026
1879
  for (x = 0; x < i; x++) {
2027
1880
  for (P = 1; P < t; P++)
2028
- B = m[P - 1 + x * t], g = m[P + x * t], o.addConstraint(l, a.create(r.extend({
2029
- bodyA: B,
1881
+ T = m[P - 1 + x * t], g = m[P + x * t], o.addConstraint(l, r.create(a.extend({
1882
+ bodyA: T,
2030
1883
  bodyB: g
2031
- }, u)));
1884
+ }, f)));
2032
1885
  if (x > 0) for (P = 0; P < t; P++)
2033
- B = m[P + (x - 1) * t], g = m[P + x * t], o.addConstraint(l, a.create(r.extend({
2034
- bodyA: B,
1886
+ T = m[P + (x - 1) * t], g = m[P + x * t], o.addConstraint(l, r.create(a.extend({
1887
+ bodyA: T,
2035
1888
  bodyB: g
2036
- }, u))), s && P > 0 && (p = m[P - 1 + (x - 1) * t], o.addConstraint(l, a.create(r.extend({
2037
- bodyA: p,
1889
+ }, f))), s && P > 0 && (d = m[P - 1 + (x - 1) * t], o.addConstraint(l, r.create(a.extend({
1890
+ bodyA: d,
2038
1891
  bodyB: g
2039
- }, u)))), s && P < t - 1 && (p = m[P + 1 + (x - 1) * t], o.addConstraint(l, a.create(r.extend({
2040
- bodyA: p,
1892
+ }, f)))), s && P < t - 1 && (d = m[P + 1 + (x - 1) * t], o.addConstraint(l, r.create(a.extend({
1893
+ bodyA: d,
2041
1894
  bodyB: g
2042
- }, u))));
1895
+ }, f))));
2043
1896
  }
2044
1897
  return l.label += " Mesh", l;
2045
- }, e.pyramid = function(l, t, i, s, u, m, x) {
2046
- return e.stack(l, t, i, s, u, m, function(P, B, g, p, y, v) {
1898
+ }, e.pyramid = function(l, t, i, s, f, m, x) {
1899
+ return e.stack(l, t, i, s, f, m, function(P, T, g, d, y, v) {
2047
1900
  var w = Math.min(s, Math.ceil(i / 2)), S = y ? y.bounds.max.x - y.bounds.min.x : 0;
2048
- if (!(p > w)) {
2049
- p = w - p;
2050
- var C = p, M = i - 1 - p;
1901
+ if (!(d > w)) {
1902
+ d = w - d;
1903
+ var C = d, M = i - 1 - d;
2051
1904
  if (!(g < C || g > M))
2052
- return v === 1 && c.translate(y, {
1905
+ return v === 1 && u.translate(y, {
2053
1906
  x: (g + (i % 2 === 1 ? 1 : -1)) * S,
2054
1907
  y: 0
2055
- }), x(l + (y ? g * S : 0) + g * u, B, g, p, y, v);
1908
+ }), x(l + (y ? g * S : 0) + g * f, T, g, d, y, v);
2056
1909
  }
2057
1910
  });
2058
- }, e.newtonsCradle = function(l, t, i, s, u) {
1911
+ }, e.newtonsCradle = function(l, t, i, s, f) {
2059
1912
  for (var m = o.create({ label: "Newtons Cradle" }), x = 0; x < i; x++) {
2060
- var P = 1.9, B = n.circle(l + x * (s * P), t + u, s, {
1913
+ var P = 1.9, T = n.circle(l + x * (s * P), t + f, s, {
2061
1914
  inertia: 1 / 0,
2062
1915
  restitution: 1,
2063
1916
  friction: 0,
2064
1917
  frictionAir: 1e-4,
2065
1918
  slop: 1
2066
- }), g = a.create({
1919
+ }), g = r.create({
2067
1920
  pointA: {
2068
1921
  x: l + x * (s * P),
2069
1922
  y: t
2070
1923
  },
2071
- bodyB: B
1924
+ bodyB: T
2072
1925
  });
2073
- o.addBody(m, B), o.addConstraint(m, g);
1926
+ o.addBody(m, T), o.addConstraint(m, g);
2074
1927
  }
2075
1928
  return m;
2076
- }, h(e, "newtonsCradle", "Composites.newtonsCradle ➤ moved to newtonsCradle example"), e.car = function(l, t, i, s, u) {
2077
- var m = c.nextGroup(!0), x = 20, P = -i * 0.5 + x, B = i * 0.5 - x, g = 0, p = o.create({ label: "Car" }), y = n.rectangle(l, t, i, s, {
1929
+ }, h(e, "newtonsCradle", "Composites.newtonsCradle ➤ moved to newtonsCradle example"), e.car = function(l, t, i, s, f) {
1930
+ var m = u.nextGroup(!0), x = 20, P = -i * 0.5 + x, T = i * 0.5 - x, g = 0, d = o.create({ label: "Car" }), y = n.rectangle(l, t, i, s, {
2078
1931
  collisionFilter: { group: m },
2079
1932
  chamfer: { radius: s * 0.5 },
2080
1933
  density: 2e-4
2081
- }), v = n.circle(l + P, t + g, u, {
1934
+ }), v = n.circle(l + P, t + g, f, {
2082
1935
  collisionFilter: { group: m },
2083
1936
  friction: 0.8
2084
- }), w = n.circle(l + B, t + g, u, {
1937
+ }), w = n.circle(l + T, t + g, f, {
2085
1938
  collisionFilter: { group: m },
2086
1939
  friction: 0.8
2087
- }), S = a.create({
1940
+ }), S = r.create({
2088
1941
  bodyB: y,
2089
1942
  pointB: {
2090
1943
  x: P,
@@ -2093,122 +1946,122 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2093
1946
  bodyA: v,
2094
1947
  stiffness: 1,
2095
1948
  length: 0
2096
- }), C = a.create({
1949
+ }), C = r.create({
2097
1950
  bodyB: y,
2098
1951
  pointB: {
2099
- x: B,
1952
+ x: T,
2100
1953
  y: g
2101
1954
  },
2102
1955
  bodyA: w,
2103
1956
  stiffness: 1,
2104
1957
  length: 0
2105
1958
  });
2106
- return o.addBody(p, y), o.addBody(p, v), o.addBody(p, w), o.addConstraint(p, S), o.addConstraint(p, C), p;
2107
- }, h(e, "car", "Composites.car ➤ moved to car example"), e.softBody = function(l, t, i, s, u, m, x, P, B, g) {
2108
- B = r.extend({ inertia: 1 / 0 }, B), g = r.extend({
1959
+ return o.addBody(d, y), o.addBody(d, v), o.addBody(d, w), o.addConstraint(d, S), o.addConstraint(d, C), d;
1960
+ }, h(e, "car", "Composites.car ➤ moved to car example"), e.softBody = function(l, t, i, s, f, m, x, P, T, g) {
1961
+ T = a.extend({ inertia: 1 / 0 }, T), g = a.extend({
2109
1962
  stiffness: 0.2,
2110
1963
  render: {
2111
1964
  type: "line",
2112
1965
  anchors: !1
2113
1966
  }
2114
1967
  }, g);
2115
- var p = e.stack(l, t, i, s, u, m, function(y, v) {
2116
- return n.circle(y, v, P, B);
1968
+ var d = e.stack(l, t, i, s, f, m, function(y, v) {
1969
+ return n.circle(y, v, P, T);
2117
1970
  });
2118
- return e.mesh(p, i, s, x, g), p.label = "Soft Body", p;
1971
+ return e.mesh(d, i, s, x, g), d.label = "Soft Body", d;
2119
1972
  }, h(e, "softBody", "Composites.softBody ➤ moved to softBody and cloth examples");
2120
1973
  })();
2121
1974
  }),
2122
- (function(T, A, f) {
1975
+ (function(A, E, c) {
2123
1976
  var e = {};
2124
- T.exports = e;
2125
- var o = f(9), a = f(0), r = a.deprecated;
1977
+ A.exports = e;
1978
+ var o = c(9), r = c(0), a = r.deprecated;
2126
1979
  (function() {
2127
- e.create = function(c) {
2128
- return a.extend({
1980
+ e.create = function(u) {
1981
+ return r.extend({
2129
1982
  buckets: {},
2130
1983
  pairs: {},
2131
1984
  pairsList: [],
2132
1985
  bucketWidth: 48,
2133
1986
  bucketHeight: 48
2134
- }, c);
2135
- }, e.update = function(c, n, h, l) {
2136
- var t, i, s, u = h.world, m = c.buckets, x, P, B = !1;
1987
+ }, u);
1988
+ }, e.update = function(u, n, h, l) {
1989
+ var t, i, s, f = h.world, m = u.buckets, x, P, T = !1;
2137
1990
  for (t = 0; t < n.length; t++) {
2138
1991
  var g = n[t];
2139
- if (!(g.isSleeping && !l) && !(u.bounds && (g.bounds.max.x < u.bounds.min.x || g.bounds.min.x > u.bounds.max.x || g.bounds.max.y < u.bounds.min.y || g.bounds.min.y > u.bounds.max.y))) {
2140
- var p = e._getRegion(c, g);
2141
- if (!g.region || p.id !== g.region.id || l) {
2142
- (!g.region || l) && (g.region = p);
2143
- var y = e._regionUnion(p, g.region);
1992
+ if (!(g.isSleeping && !l) && !(f.bounds && (g.bounds.max.x < f.bounds.min.x || g.bounds.min.x > f.bounds.max.x || g.bounds.max.y < f.bounds.min.y || g.bounds.min.y > f.bounds.max.y))) {
1993
+ var d = e._getRegion(u, g);
1994
+ if (!g.region || d.id !== g.region.id || l) {
1995
+ (!g.region || l) && (g.region = d);
1996
+ var y = e._regionUnion(d, g.region);
2144
1997
  for (i = y.startCol; i <= y.endCol; i++) for (s = y.startRow; s <= y.endRow; s++) {
2145
1998
  P = e._getBucketId(i, s), x = m[P];
2146
- var v = i >= p.startCol && i <= p.endCol && s >= p.startRow && s <= p.endRow, w = i >= g.region.startCol && i <= g.region.endCol && s >= g.region.startRow && s <= g.region.endRow;
2147
- !v && w && w && x && e._bucketRemoveBody(c, x, g), (g.region === p || v && !w || l) && (x || (x = e._createBucket(m, P)), e._bucketAddBody(c, x, g));
1999
+ var v = i >= d.startCol && i <= d.endCol && s >= d.startRow && s <= d.endRow, w = i >= g.region.startCol && i <= g.region.endCol && s >= g.region.startRow && s <= g.region.endRow;
2000
+ !v && w && w && x && e._bucketRemoveBody(u, x, g), (g.region === d || v && !w || l) && (x || (x = e._createBucket(m, P)), e._bucketAddBody(u, x, g));
2148
2001
  }
2149
- g.region = p, B = !0;
2002
+ g.region = d, T = !0;
2150
2003
  }
2151
2004
  }
2152
2005
  }
2153
- B && (c.pairsList = e._createActivePairsList(c));
2154
- }, r(e, "update", "Grid.update ➤ replaced by Matter.Detector"), e.clear = function(c) {
2155
- c.buckets = {}, c.pairs = {}, c.pairsList = [];
2156
- }, r(e, "clear", "Grid.clear ➤ replaced by Matter.Detector"), e._regionUnion = function(c, n) {
2157
- var h = Math.min(c.startCol, n.startCol), l = Math.max(c.endCol, n.endCol), t = Math.min(c.startRow, n.startRow), i = Math.max(c.endRow, n.endRow);
2006
+ T && (u.pairsList = e._createActivePairsList(u));
2007
+ }, a(e, "update", "Grid.update ➤ replaced by Matter.Detector"), e.clear = function(u) {
2008
+ u.buckets = {}, u.pairs = {}, u.pairsList = [];
2009
+ }, a(e, "clear", "Grid.clear ➤ replaced by Matter.Detector"), e._regionUnion = function(u, n) {
2010
+ var h = Math.min(u.startCol, n.startCol), l = Math.max(u.endCol, n.endCol), t = Math.min(u.startRow, n.startRow), i = Math.max(u.endRow, n.endRow);
2158
2011
  return e._createRegion(h, l, t, i);
2159
- }, e._getRegion = function(c, n) {
2160
- var h = n.bounds, l = Math.floor(h.min.x / c.bucketWidth), t = Math.floor(h.max.x / c.bucketWidth), i = Math.floor(h.min.y / c.bucketHeight), s = Math.floor(h.max.y / c.bucketHeight);
2012
+ }, e._getRegion = function(u, n) {
2013
+ var h = n.bounds, l = Math.floor(h.min.x / u.bucketWidth), t = Math.floor(h.max.x / u.bucketWidth), i = Math.floor(h.min.y / u.bucketHeight), s = Math.floor(h.max.y / u.bucketHeight);
2161
2014
  return e._createRegion(l, t, i, s);
2162
- }, e._createRegion = function(c, n, h, l) {
2015
+ }, e._createRegion = function(u, n, h, l) {
2163
2016
  return {
2164
- id: c + "," + n + "," + h + "," + l,
2165
- startCol: c,
2017
+ id: u + "," + n + "," + h + "," + l,
2018
+ startCol: u,
2166
2019
  endCol: n,
2167
2020
  startRow: h,
2168
2021
  endRow: l
2169
2022
  };
2170
- }, e._getBucketId = function(c, n) {
2171
- return "C" + c + "R" + n;
2172
- }, e._createBucket = function(c, n) {
2173
- return c[n] = [];
2174
- }, e._bucketAddBody = function(c, n, h) {
2175
- var l = c.pairs, t = o.id, i = n.length, s;
2023
+ }, e._getBucketId = function(u, n) {
2024
+ return "C" + u + "R" + n;
2025
+ }, e._createBucket = function(u, n) {
2026
+ return u[n] = [];
2027
+ }, e._bucketAddBody = function(u, n, h) {
2028
+ var l = u.pairs, t = o.id, i = n.length, s;
2176
2029
  for (s = 0; s < i; s++) {
2177
- var u = n[s];
2178
- if (!(h.id === u.id || h.isStatic && u.isStatic)) {
2179
- var m = t(h, u), x = l[m];
2030
+ var f = n[s];
2031
+ if (!(h.id === f.id || h.isStatic && f.isStatic)) {
2032
+ var m = t(h, f), x = l[m];
2180
2033
  x ? x[2] += 1 : l[m] = [
2181
2034
  h,
2182
- u,
2035
+ f,
2183
2036
  1
2184
2037
  ];
2185
2038
  }
2186
2039
  }
2187
2040
  n.push(h);
2188
- }, e._bucketRemoveBody = function(c, n, h) {
2189
- var l = c.pairs, t = o.id, i;
2190
- n.splice(a.indexOf(n, h), 1);
2041
+ }, e._bucketRemoveBody = function(u, n, h) {
2042
+ var l = u.pairs, t = o.id, i;
2043
+ n.splice(r.indexOf(n, h), 1);
2191
2044
  var s = n.length;
2192
2045
  for (i = 0; i < s; i++) {
2193
- var u = l[t(h, n[i])];
2194
- u && (u[2] -= 1);
2046
+ var f = l[t(h, n[i])];
2047
+ f && (f[2] -= 1);
2195
2048
  }
2196
- }, e._createActivePairsList = function(c) {
2197
- var n, h = c.pairs, l = a.keys(h), t = l.length, i = [], s;
2049
+ }, e._createActivePairsList = function(u) {
2050
+ var n, h = u.pairs, l = r.keys(h), t = l.length, i = [], s;
2198
2051
  for (s = 0; s < t; s++)
2199
2052
  n = h[l[s]], n[2] > 0 ? i.push(n) : delete h[l[s]];
2200
2053
  return i;
2201
2054
  };
2202
2055
  })();
2203
2056
  }),
2204
- (function(T, A, f) {
2057
+ (function(A, E, c) {
2205
2058
  var e = {};
2206
- T.exports = e;
2207
- var o = f(3), a = f(7), r = f(14), c = f(5), n = f(13), h = f(10), l = f(6), t = f(0), i = f(1);
2059
+ A.exports = e;
2060
+ var o = c(3), r = c(7), a = c(14), u = c(5), n = c(13), h = c(10), l = c(6), t = c(0), i = c(1);
2208
2061
  (function() {
2209
- e.create = function(s, u) {
2210
- var m = (s ? s.mouse : null) || (u ? u.mouse : null);
2211
- m || (s && s.render && s.render.canvas ? m = r.create(s.render.canvas) : u && u.element ? m = r.create(u.element) : (m = r.create(), t.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));
2062
+ e.create = function(s, f) {
2063
+ var m = (s ? s.mouse : null) || (f ? f.mouse : null);
2064
+ m || (s && s.render && s.render.canvas ? m = a.create(s.render.canvas) : f && f.element ? m = a.create(f.element) : (m = a.create(), t.warn("MouseConstraint.create: options.mouse was undefined, options.element was undefined, may not function as expected")));
2212
2065
  var x = h.create({
2213
2066
  label: "Mouse Constraint",
2214
2067
  pointA: m.position,
@@ -2234,24 +2087,24 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2234
2087
  mask: 4294967295,
2235
2088
  group: 0
2236
2089
  }
2237
- }, B = t.extend(P, u);
2238
- return c.on(s, "beforeUpdate", function() {
2090
+ }, T = t.extend(P, f);
2091
+ return u.on(s, "beforeUpdate", function() {
2239
2092
  var g = l.allBodies(s.world);
2240
- e.update(B, g), e._triggerEvents(B);
2241
- }), B;
2242
- }, e.update = function(s, u) {
2093
+ e.update(T, g), e._triggerEvents(T);
2094
+ }), T;
2095
+ }, e.update = function(s, f) {
2243
2096
  var m = s.mouse, x = s.constraint, P = s.body;
2244
2097
  if (m.button === 0) {
2245
- if (x.bodyB) a.set(x.bodyB, !1), x.pointA = m.position;
2098
+ if (x.bodyB) r.set(x.bodyB, !1), x.pointA = m.position;
2246
2099
  else
2247
- for (var B = 0; B < u.length; B++)
2248
- if (P = u[B], i.contains(P.bounds, m.position) && n.canCollide(P.collisionFilter, s.collisionFilter)) for (var g = P.parts.length > 1 ? 1 : 0; g < P.parts.length; g++) {
2249
- var p = P.parts[g];
2250
- if (o.contains(p.vertices, m.position)) {
2100
+ for (var T = 0; T < f.length; T++)
2101
+ if (P = f[T], i.contains(P.bounds, m.position) && n.canCollide(P.collisionFilter, s.collisionFilter)) for (var g = P.parts.length > 1 ? 1 : 0; g < P.parts.length; g++) {
2102
+ var d = P.parts[g];
2103
+ if (o.contains(d.vertices, m.position)) {
2251
2104
  x.pointA = m.position, x.bodyB = s.body = P, x.pointB = {
2252
2105
  x: m.position.x - P.position.x,
2253
2106
  y: m.position.y - P.position.y
2254
- }, x.angleB = P.angle, a.set(P, !1), c.trigger(s, "startdrag", {
2107
+ }, x.angleB = P.angle, r.set(P, !1), u.trigger(s, "startdrag", {
2255
2108
  mouse: m,
2256
2109
  body: P
2257
2110
  });
@@ -2259,28 +2112,28 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2259
2112
  }
2260
2113
  }
2261
2114
  } else
2262
- x.bodyB = s.body = null, x.pointB = null, P && c.trigger(s, "enddrag", {
2115
+ x.bodyB = s.body = null, x.pointB = null, P && u.trigger(s, "enddrag", {
2263
2116
  mouse: m,
2264
2117
  body: P
2265
2118
  });
2266
2119
  }, e._triggerEvents = function(s) {
2267
- var u = s.mouse, m = u.sourceEvents;
2268
- m.mousemove && c.trigger(s, "mousemove", { mouse: u }), m.mousedown && c.trigger(s, "mousedown", { mouse: u }), m.mouseup && c.trigger(s, "mouseup", { mouse: u }), r.clearSourceEvents(u);
2120
+ var f = s.mouse, m = f.sourceEvents;
2121
+ m.mousemove && u.trigger(s, "mousemove", { mouse: f }), m.mousedown && u.trigger(s, "mousedown", { mouse: f }), m.mouseup && u.trigger(s, "mouseup", { mouse: f }), a.clearSourceEvents(f);
2269
2122
  };
2270
2123
  })();
2271
2124
  }),
2272
- (function(T, A, f) {
2125
+ (function(A, E, c) {
2273
2126
  var e = {};
2274
- T.exports = e;
2275
- var o = f(2), a = f(8), r = f(1), c = f(12), n = f(3);
2127
+ A.exports = e;
2128
+ var o = c(2), r = c(8), a = c(1), u = c(12), n = c(3);
2276
2129
  (function() {
2277
2130
  e.collides = function(h, l) {
2278
- for (var t = [], i = l.length, s = h.bounds, u = a.collides, m = r.overlaps, x = 0; x < i; x++) {
2279
- var P = l[x], B = P.parts.length, g = B === 1 ? 0 : 1;
2280
- if (m(P.bounds, s)) for (var p = g; p < B; p++) {
2281
- var y = P.parts[p];
2131
+ for (var t = [], i = l.length, s = h.bounds, f = r.collides, m = a.overlaps, x = 0; x < i; x++) {
2132
+ var P = l[x], T = P.parts.length, g = T === 1 ? 0 : 1;
2133
+ if (m(P.bounds, s)) for (var d = g; d < T; d++) {
2134
+ var y = P.parts[d];
2282
2135
  if (m(y.bounds, s)) {
2283
- var v = u(y, h);
2136
+ var v = f(y, h);
2284
2137
  if (v) {
2285
2138
  t.push(v);
2286
2139
  break;
@@ -2291,23 +2144,23 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2291
2144
  return t;
2292
2145
  }, e.ray = function(h, l, t, i) {
2293
2146
  i = i || 1e-100;
2294
- for (var s = o.angle(l, t), u = o.magnitude(o.sub(l, t)), m = (t.x + l.x) * 0.5, x = (t.y + l.y) * 0.5, P = c.rectangle(m, x, u, i, { angle: s }), B = e.collides(P, h), g = 0; g < B.length; g += 1) {
2295
- var p = B[g];
2296
- p.body = p.bodyB = p.bodyA;
2147
+ for (var s = o.angle(l, t), f = o.magnitude(o.sub(l, t)), m = (t.x + l.x) * 0.5, x = (t.y + l.y) * 0.5, P = u.rectangle(m, x, f, i, { angle: s }), T = e.collides(P, h), g = 0; g < T.length; g += 1) {
2148
+ var d = T[g];
2149
+ d.body = d.bodyB = d.bodyA;
2297
2150
  }
2298
- return B;
2151
+ return T;
2299
2152
  }, e.region = function(h, l, t) {
2300
2153
  for (var i = [], s = 0; s < h.length; s++) {
2301
- var u = h[s], m = r.overlaps(u.bounds, l);
2302
- (m && !t || !m && t) && i.push(u);
2154
+ var f = h[s], m = a.overlaps(f.bounds, l);
2155
+ (m && !t || !m && t) && i.push(f);
2303
2156
  }
2304
2157
  return i;
2305
2158
  }, e.point = function(h, l) {
2306
2159
  for (var t = [], i = 0; i < h.length; i++) {
2307
2160
  var s = h[i];
2308
- if (r.contains(s.bounds, l)) for (var u = s.parts.length === 1 ? 0 : 1; u < s.parts.length; u++) {
2309
- var m = s.parts[u];
2310
- if (r.contains(m.bounds, l) && n.contains(m.vertices, l)) {
2161
+ if (a.contains(s.bounds, l)) for (var f = s.parts.length === 1 ? 0 : 1; f < s.parts.length; f++) {
2162
+ var m = s.parts[f];
2163
+ if (a.contains(m.bounds, l) && n.contains(m.vertices, l)) {
2311
2164
  t.push(s);
2312
2165
  break;
2313
2166
  }
@@ -2317,18 +2170,18 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2317
2170
  };
2318
2171
  })();
2319
2172
  }),
2320
- (function(T, A, f) {
2173
+ (function(A, E, c) {
2321
2174
  var e = {};
2322
- T.exports = e;
2323
- var o = f(4), a = f(0), r = f(6), c = f(1), n = f(5), h = f(2), l = f(14);
2175
+ A.exports = e;
2176
+ var o = c(4), r = c(0), a = c(6), u = c(1), n = c(5), h = c(2), l = c(14);
2324
2177
  (function() {
2325
2178
  var t, i;
2326
2179
  typeof window < "u" && (t = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.msRequestAnimationFrame || function(g) {
2327
2180
  window.setTimeout(function() {
2328
- g(a.now());
2181
+ g(r.now());
2329
2182
  }, 1e3 / 60);
2330
2183
  }, i = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame), e._goodFps = 30, e._goodDelta = 1e3 / 60, e.create = function(g) {
2331
- var p = {
2184
+ var d = {
2332
2185
  engine: null,
2333
2186
  element: null,
2334
2187
  canvas: null,
@@ -2375,7 +2228,7 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2375
2228
  showInternalEdges: !1,
2376
2229
  showMousePosition: !1
2377
2230
  }
2378
- }, y = a.extend(p, g);
2231
+ }, y = r.extend(d, g);
2379
2232
  return y.canvas && (y.canvas.width = y.options.width || y.canvas.width, y.canvas.height = y.options.height || y.canvas.height), y.mouse = g.mouse, y.engine = g.engine, y.canvas = y.canvas || m(y.options.width, y.options.height), y.context = y.canvas.getContext("2d"), y.textures = {}, y.bounds = y.bounds || {
2380
2233
  min: {
2381
2234
  x: 0,
@@ -2385,20 +2238,20 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2385
2238
  x: y.canvas.width,
2386
2239
  y: y.canvas.height
2387
2240
  }
2388
- }, y.controller = e, y.options.showBroadphase = !1, y.options.pixelRatio !== 1 && e.setPixelRatio(y, y.options.pixelRatio), a.isElement(y.element) && y.element.appendChild(y.canvas), y;
2241
+ }, y.controller = e, y.options.showBroadphase = !1, y.options.pixelRatio !== 1 && e.setPixelRatio(y, y.options.pixelRatio), r.isElement(y.element) && y.element.appendChild(y.canvas), y;
2389
2242
  }, e.run = function(g) {
2390
- (function p(y) {
2391
- g.frameRequestId = t(p), s(g, y), e.world(g, y), g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0), (g.options.showStats || g.options.showDebug) && e.stats(g, g.context, y), (g.options.showPerformance || g.options.showDebug) && e.performance(g, g.context, y), g.context.setTransform(1, 0, 0, 1, 0, 0);
2243
+ (function d(y) {
2244
+ g.frameRequestId = t(d), s(g, y), e.world(g, y), g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0), (g.options.showStats || g.options.showDebug) && e.stats(g, g.context, y), (g.options.showPerformance || g.options.showDebug) && e.performance(g, g.context, y), g.context.setTransform(1, 0, 0, 1, 0, 0);
2392
2245
  })();
2393
2246
  }, e.stop = function(g) {
2394
2247
  i(g.frameRequestId);
2395
- }, e.setPixelRatio = function(g, p) {
2248
+ }, e.setPixelRatio = function(g, d) {
2396
2249
  var y = g.options, v = g.canvas;
2397
- p === "auto" && (p = x(v)), y.pixelRatio = p, v.setAttribute("data-pixel-ratio", p), v.width = y.width * p, v.height = y.height * p, v.style.width = y.width + "px", v.style.height = y.height + "px";
2398
- }, e.setSize = function(g, p, y) {
2399
- g.options.width = p, g.options.height = y, g.bounds.max.x = g.bounds.min.x + p, g.bounds.max.y = g.bounds.min.y + y, g.options.pixelRatio !== 1 ? e.setPixelRatio(g, g.options.pixelRatio) : (g.canvas.width = p, g.canvas.height = y);
2400
- }, e.lookAt = function(g, p, y, v) {
2401
- v = typeof v < "u" ? v : !0, p = a.isArray(p) ? p : [p], y = y || {
2250
+ d === "auto" && (d = x(v)), y.pixelRatio = d, v.setAttribute("data-pixel-ratio", d), v.width = y.width * d, v.height = y.height * d, v.style.width = y.width + "px", v.style.height = y.height + "px";
2251
+ }, e.setSize = function(g, d, y) {
2252
+ g.options.width = d, g.options.height = y, g.bounds.max.x = g.bounds.min.x + d, g.bounds.max.y = g.bounds.min.y + y, g.options.pixelRatio !== 1 ? e.setPixelRatio(g, g.options.pixelRatio) : (g.canvas.width = d, g.canvas.height = y);
2253
+ }, e.lookAt = function(g, d, y, v) {
2254
+ v = typeof v < "u" ? v : !0, d = r.isArray(d) ? d : [d], y = y || {
2402
2255
  x: 0,
2403
2256
  y: 0
2404
2257
  };
@@ -2411,73 +2264,73 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2411
2264
  x: -1 / 0,
2412
2265
  y: -1 / 0
2413
2266
  }
2414
- }, S = 0; S < p.length; S += 1) {
2415
- var C = p[S], M = C.bounds ? C.bounds.min : C.min || C.position || C, I = C.bounds ? C.bounds.max : C.max || C.position || C;
2267
+ }, S = 0; S < d.length; S += 1) {
2268
+ var C = d[S], M = C.bounds ? C.bounds.min : C.min || C.position || C, I = C.bounds ? C.bounds.max : C.max || C.position || C;
2416
2269
  M && I && (M.x < w.min.x && (w.min.x = M.x), I.x > w.max.x && (w.max.x = I.x), M.y < w.min.y && (w.min.y = M.y), I.y > w.max.y && (w.max.y = I.y));
2417
2270
  }
2418
- var R = w.max.x - w.min.x + 2 * y.x, L = w.max.y - w.min.y + 2 * y.y, b = g.canvas.height, k = g.canvas.width / b, D = R / L, F = 1, H = 1;
2419
- D > k ? H = D / k : F = k / D, g.options.hasBounds = !0, g.bounds.min.x = w.min.x, g.bounds.max.x = w.min.x + R * F, g.bounds.min.y = w.min.y, g.bounds.max.y = w.min.y + L * H, v && (g.bounds.min.x += R * 0.5 - R * F * 0.5, g.bounds.max.x += R * 0.5 - R * F * 0.5, g.bounds.min.y += L * 0.5 - L * H * 0.5, g.bounds.max.y += L * 0.5 - L * H * 0.5), g.bounds.min.x -= y.x, g.bounds.max.x -= y.x, g.bounds.min.y -= y.y, g.bounds.max.y -= y.y, g.mouse && (l.setScale(g.mouse, {
2271
+ var R = w.max.x - w.min.x + 2 * y.x, L = w.max.y - w.min.y + 2 * y.y, D = g.canvas.height, k = g.canvas.width / D, b = R / L, O = 1, W = 1;
2272
+ b > k ? W = b / k : O = k / b, g.options.hasBounds = !0, g.bounds.min.x = w.min.x, g.bounds.max.x = w.min.x + R * O, g.bounds.min.y = w.min.y, g.bounds.max.y = w.min.y + L * W, v && (g.bounds.min.x += R * 0.5 - R * O * 0.5, g.bounds.max.x += R * 0.5 - R * O * 0.5, g.bounds.min.y += L * 0.5 - L * W * 0.5, g.bounds.max.y += L * 0.5 - L * W * 0.5), g.bounds.min.x -= y.x, g.bounds.max.x -= y.x, g.bounds.min.y -= y.y, g.bounds.max.y -= y.y, g.mouse && (l.setScale(g.mouse, {
2420
2273
  x: (g.bounds.max.x - g.bounds.min.x) / g.canvas.width,
2421
2274
  y: (g.bounds.max.y - g.bounds.min.y) / g.canvas.height
2422
2275
  }), l.setOffset(g.mouse, g.bounds.min));
2423
2276
  }, e.startViewTransform = function(g) {
2424
- var p = g.bounds.max.x - g.bounds.min.x, y = g.bounds.max.y - g.bounds.min.y, v = p / g.options.width, w = y / g.options.height;
2277
+ var d = g.bounds.max.x - g.bounds.min.x, y = g.bounds.max.y - g.bounds.min.y, v = d / g.options.width, w = y / g.options.height;
2425
2278
  g.context.setTransform(g.options.pixelRatio / v, 0, 0, g.options.pixelRatio / w, 0, 0), g.context.translate(-g.bounds.min.x, -g.bounds.min.y);
2426
2279
  }, e.endViewTransform = function(g) {
2427
2280
  g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
2428
- }, e.world = function(g, p) {
2429
- var y = a.now(), v = g.engine, w = v.world, S = g.canvas, C = g.context, M = g.options, I = g.timing, R = r.allBodies(w), L = r.allConstraints(w), b = M.wireframes ? M.wireframeBackground : M.background, k = [], D = [], F, H = { timestamp: v.timing.timestamp };
2430
- if (n.trigger(g, "beforeRender", H), g.currentBackground !== b && B(g, b), C.globalCompositeOperation = "source-in", C.fillStyle = "transparent", C.fillRect(0, 0, S.width, S.height), C.globalCompositeOperation = "source-over", M.hasBounds) {
2431
- for (F = 0; F < R.length; F++) {
2432
- var G = R[F];
2433
- c.overlaps(G.bounds, g.bounds) && k.push(G);
2281
+ }, e.world = function(g, d) {
2282
+ var y = r.now(), v = g.engine, w = v.world, S = g.canvas, C = g.context, M = g.options, I = g.timing, R = a.allBodies(w), L = a.allConstraints(w), D = M.wireframes ? M.wireframeBackground : M.background, k = [], b = [], O, W = { timestamp: v.timing.timestamp };
2283
+ if (n.trigger(g, "beforeRender", W), g.currentBackground !== D && T(g, D), C.globalCompositeOperation = "source-in", C.fillStyle = "transparent", C.fillRect(0, 0, S.width, S.height), C.globalCompositeOperation = "source-over", M.hasBounds) {
2284
+ for (O = 0; O < R.length; O++) {
2285
+ var G = R[O];
2286
+ u.overlaps(G.bounds, g.bounds) && k.push(G);
2434
2287
  }
2435
- for (F = 0; F < L.length; F++) {
2436
- var V = L[F], Q = V.bodyA, X = V.bodyB, U = V.pointA, W = V.pointB;
2437
- Q && (U = h.add(Q.position, V.pointA)), X && (W = h.add(X.position, V.pointB)), !(!U || !W) && (c.contains(g.bounds, U) || c.contains(g.bounds, W)) && D.push(V);
2288
+ for (O = 0; O < L.length; O++) {
2289
+ var N = L[O], Q = N.bodyA, X = N.bodyB, F = N.pointA, H = N.pointB;
2290
+ Q && (F = h.add(Q.position, N.pointA)), X && (H = h.add(X.position, N.pointB)), !(!F || !H) && (u.contains(g.bounds, F) || u.contains(g.bounds, H)) && b.push(N);
2438
2291
  }
2439
2292
  e.startViewTransform(g), g.mouse && (l.setScale(g.mouse, {
2440
2293
  x: (g.bounds.max.x - g.bounds.min.x) / g.options.width,
2441
2294
  y: (g.bounds.max.y - g.bounds.min.y) / g.options.height
2442
2295
  }), l.setOffset(g.mouse, g.bounds.min));
2443
2296
  } else
2444
- D = L, k = R, g.options.pixelRatio !== 1 && g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
2445
- !M.wireframes || v.enableSleeping && M.showSleeping ? e.bodies(g, k, C) : (M.showConvexHulls && e.bodyConvexHulls(g, k, C), e.bodyWireframes(g, k, C)), M.showBounds && e.bodyBounds(g, k, C), (M.showAxes || M.showAngleIndicator) && e.bodyAxes(g, k, C), M.showPositions && e.bodyPositions(g, k, C), M.showVelocity && e.bodyVelocity(g, k, C), M.showIds && e.bodyIds(g, k, C), M.showSeparations && e.separations(g, v.pairs.list, C), M.showCollisions && e.collisions(g, v.pairs.list, C), M.showVertexNumbers && e.vertexNumbers(g, k, C), M.showMousePosition && e.mousePosition(g, g.mouse, C), e.constraints(D, C), M.hasBounds && e.endViewTransform(g), n.trigger(g, "afterRender", H), I.lastElapsed = a.now() - y;
2446
- }, e.stats = function(g, p, y) {
2447
- for (var v = g.engine, w = v.world, S = r.allBodies(w), C = 0, M = 55, I = 44, R = 0, L = 0, b = 0; b < S.length; b += 1) C += S[b].parts.length;
2297
+ b = L, k = R, g.options.pixelRatio !== 1 && g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
2298
+ !M.wireframes || v.enableSleeping && M.showSleeping ? e.bodies(g, k, C) : (M.showConvexHulls && e.bodyConvexHulls(g, k, C), e.bodyWireframes(g, k, C)), M.showBounds && e.bodyBounds(g, k, C), (M.showAxes || M.showAngleIndicator) && e.bodyAxes(g, k, C), M.showPositions && e.bodyPositions(g, k, C), M.showVelocity && e.bodyVelocity(g, k, C), M.showIds && e.bodyIds(g, k, C), M.showSeparations && e.separations(g, v.pairs.list, C), M.showCollisions && e.collisions(g, v.pairs.list, C), M.showVertexNumbers && e.vertexNumbers(g, k, C), M.showMousePosition && e.mousePosition(g, g.mouse, C), e.constraints(b, C), M.hasBounds && e.endViewTransform(g), n.trigger(g, "afterRender", W), I.lastElapsed = r.now() - y;
2299
+ }, e.stats = function(g, d, y) {
2300
+ for (var v = g.engine, w = v.world, S = a.allBodies(w), C = 0, M = 55, I = 44, R = 0, L = 0, D = 0; D < S.length; D += 1) C += S[D].parts.length;
2448
2301
  var k = {
2449
2302
  Part: C,
2450
2303
  Body: S.length,
2451
- Cons: r.allConstraints(w).length,
2452
- Comp: r.allComposites(w).length,
2304
+ Cons: a.allConstraints(w).length,
2305
+ Comp: a.allComposites(w).length,
2453
2306
  Pair: v.pairs.list.length
2454
2307
  };
2455
- p.fillStyle = "#0e0f19", p.fillRect(R, L, M * 5.5, I), p.font = "12px Arial", p.textBaseline = "top", p.textAlign = "right";
2456
- for (var D in k) {
2457
- var F = k[D];
2458
- p.fillStyle = "#aaa", p.fillText(D, R + M, L + 8), p.fillStyle = "#eee", p.fillText(F, R + M, L + 26), R += M;
2459
- }
2460
- }, e.performance = function(g, p) {
2461
- var y = g.engine, v = g.timing, w = v.deltaHistory, S = v.elapsedHistory, C = v.timestampElapsedHistory, M = v.engineDeltaHistory, I = v.engineUpdatesHistory, R = v.engineElapsedHistory, L = y.timing.lastUpdatesPerFrame, b = y.timing.lastDelta, k = u(w), D = u(S), F = u(M), H = u(I), G = u(R), V = u(C) / k || 0, Q = Math.round(k / b), X = 1e3 / k || 0, U = 4, W = 12, N = 60, J = 34, K = 10, Y = 69;
2462
- p.fillStyle = "#0e0f19", p.fillRect(0, 50, W * 5 + N * 6 + 22, J), e.status(p, K, Y, N, U, w.length, Math.round(X) + " fps", X / e._goodFps, function(z) {
2308
+ d.fillStyle = "#0e0f19", d.fillRect(R, L, M * 5.5, I), d.font = "12px Arial", d.textBaseline = "top", d.textAlign = "right";
2309
+ for (var b in k) {
2310
+ var O = k[b];
2311
+ d.fillStyle = "#aaa", d.fillText(b, R + M, L + 8), d.fillStyle = "#eee", d.fillText(O, R + M, L + 26), R += M;
2312
+ }
2313
+ }, e.performance = function(g, d) {
2314
+ var y = g.engine, v = g.timing, w = v.deltaHistory, S = v.elapsedHistory, C = v.timestampElapsedHistory, M = v.engineDeltaHistory, I = v.engineUpdatesHistory, R = v.engineElapsedHistory, L = y.timing.lastUpdatesPerFrame, D = y.timing.lastDelta, k = f(w), b = f(S), O = f(M), W = f(I), G = f(R), N = f(C) / k || 0, Q = Math.round(k / D), X = 1e3 / k || 0, F = 4, H = 12, V = 60, J = 34, Y = 10, K = 69;
2315
+ d.fillStyle = "#0e0f19", d.fillRect(0, 50, H * 5 + V * 6 + 22, J), e.status(d, Y, K, V, F, w.length, Math.round(X) + " fps", X / e._goodFps, function(z) {
2463
2316
  return w[z] / k - 1;
2464
- }), e.status(p, K + W + N, Y, N, U, M.length, b.toFixed(2) + " dt", e._goodDelta / b, function(z) {
2465
- return M[z] / F - 1;
2466
- }), e.status(p, K + (W + N) * 2, Y, N, U, I.length, L + " upf", Math.pow(a.clamp(H / Q || 1, 0, 1), 4), function(z) {
2467
- return I[z] / H - 1;
2468
- }), e.status(p, K + (W + N) * 3, Y, N, U, R.length, G.toFixed(2) + " ut", 1 - L * G / e._goodFps, function(z) {
2317
+ }), e.status(d, Y + H + V, K, V, F, M.length, D.toFixed(2) + " dt", e._goodDelta / D, function(z) {
2318
+ return M[z] / O - 1;
2319
+ }), e.status(d, Y + (H + V) * 2, K, V, F, I.length, L + " upf", Math.pow(r.clamp(W / Q || 1, 0, 1), 4), function(z) {
2320
+ return I[z] / W - 1;
2321
+ }), e.status(d, Y + (H + V) * 3, K, V, F, R.length, G.toFixed(2) + " ut", 1 - L * G / e._goodFps, function(z) {
2469
2322
  return R[z] / G - 1;
2470
- }), e.status(p, K + (W + N) * 4, Y, N, U, S.length, D.toFixed(2) + " rt", 1 - D / e._goodFps, function(z) {
2471
- return S[z] / D - 1;
2472
- }), e.status(p, K + (W + N) * 5, Y, N, U, C.length, V.toFixed(2) + " x", V * V * V, function(z) {
2473
- return (C[z] / w[z] / V || 0) - 1;
2323
+ }), e.status(d, Y + (H + V) * 4, K, V, F, S.length, b.toFixed(2) + " rt", 1 - b / e._goodFps, function(z) {
2324
+ return S[z] / b - 1;
2325
+ }), e.status(d, Y + (H + V) * 5, K, V, F, C.length, N.toFixed(2) + " x", N * N * N, function(z) {
2326
+ return (C[z] / w[z] / N || 0) - 1;
2474
2327
  });
2475
- }, e.status = function(g, p, y, v, w, S, C, M, I) {
2476
- g.strokeStyle = "#888", g.fillStyle = "#444", g.lineWidth = 1, g.fillRect(p, y + 7, v, 1), g.beginPath(), g.moveTo(p, y + 7 - w * a.clamp(0.4 * I(0), -2, 2));
2477
- for (var R = 0; R < v; R += 1) g.lineTo(p + R, y + 7 - (R < S ? w * a.clamp(0.4 * I(R), -2, 2) : 0));
2478
- g.stroke(), g.fillStyle = "hsl(" + a.clamp(25 + 95 * M, 0, 120) + ",100%,60%)", g.fillRect(p, y - 7, 4, 4), g.font = "12px Arial", g.textBaseline = "middle", g.textAlign = "right", g.fillStyle = "#eee", g.fillText(C, p + v, y - 5);
2479
- }, e.constraints = function(g, p) {
2480
- for (var y = p, v = 0; v < g.length; v++) {
2328
+ }, e.status = function(g, d, y, v, w, S, C, M, I) {
2329
+ g.strokeStyle = "#888", g.fillStyle = "#444", g.lineWidth = 1, g.fillRect(d, y + 7, v, 1), g.beginPath(), g.moveTo(d, y + 7 - w * r.clamp(0.4 * I(0), -2, 2));
2330
+ for (var R = 0; R < v; R += 1) g.lineTo(d + R, y + 7 - (R < S ? w * r.clamp(0.4 * I(R), -2, 2) : 0));
2331
+ g.stroke(), g.fillStyle = "hsl(" + r.clamp(25 + 95 * M, 0, 120) + ",100%,60%)", g.fillRect(d, y - 7, 4, 4), g.font = "12px Arial", g.textBaseline = "middle", g.textAlign = "right", g.fillStyle = "#eee", g.fillText(C, d + v, y - 5);
2332
+ }, e.constraints = function(g, d) {
2333
+ for (var y = d, v = 0; v < g.length; v++) {
2481
2334
  var w = g[v];
2482
2335
  if (!(!w.render.visible || !w.pointA || !w.pointB)) {
2483
2336
  var S = w.bodyA, C = w.bodyB, M, I;
@@ -2485,24 +2338,24 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2485
2338
  y.beginPath(), y.arc(M.x, M.y, 3, 0, 2 * Math.PI), y.closePath();
2486
2339
  else {
2487
2340
  if (C ? I = h.add(C.position, w.pointB) : I = w.pointB, y.beginPath(), y.moveTo(M.x, M.y), w.render.type === "spring")
2488
- for (var R = h.sub(I, M), L = h.perp(h.normalise(R)), b = Math.ceil(a.clamp(w.length / 5, 12, 20)), k, D = 1; D < b; D += 1)
2489
- k = D % 2 === 0 ? 1 : -1, y.lineTo(M.x + R.x * (D / b) + L.x * k * 4, M.y + R.y * (D / b) + L.y * k * 4);
2341
+ for (var R = h.sub(I, M), L = h.perp(h.normalise(R)), D = Math.ceil(r.clamp(w.length / 5, 12, 20)), k, b = 1; b < D; b += 1)
2342
+ k = b % 2 === 0 ? 1 : -1, y.lineTo(M.x + R.x * (b / D) + L.x * k * 4, M.y + R.y * (b / D) + L.y * k * 4);
2490
2343
  y.lineTo(I.x, I.y);
2491
2344
  }
2492
2345
  w.render.lineWidth && (y.lineWidth = w.render.lineWidth, y.strokeStyle = w.render.strokeStyle, y.stroke()), w.render.anchors && (y.fillStyle = w.render.strokeStyle, y.beginPath(), y.arc(M.x, M.y, 3, 0, 2 * Math.PI), y.arc(I.x, I.y, 3, 0, 2 * Math.PI), y.closePath(), y.fill());
2493
2346
  }
2494
2347
  }
2495
- }, e.bodies = function(g, p, y) {
2348
+ }, e.bodies = function(g, d, y) {
2496
2349
  var v = y;
2497
2350
  g.engine;
2498
2351
  var w = g.options, S = w.showInternalEdges || !w.wireframes, C, M, I, R;
2499
- for (I = 0; I < p.length; I++)
2500
- if (C = p[I], !!C.render.visible) {
2352
+ for (I = 0; I < d.length; I++)
2353
+ if (C = d[I], !!C.render.visible) {
2501
2354
  for (R = C.parts.length > 1 ? 1 : 0; R < C.parts.length; R++)
2502
2355
  if (M = C.parts[R], !!M.render.visible) {
2503
2356
  if (w.showSleeping && C.isSleeping ? v.globalAlpha = 0.5 * M.render.opacity : M.render.opacity !== 1 && (v.globalAlpha = M.render.opacity), M.render.sprite && M.render.sprite.texture && !w.wireframes) {
2504
- var L = M.render.sprite, b = P(g, L.texture);
2505
- v.translate(M.position.x, M.position.y), v.rotate(M.angle), v.drawImage(b, b.width * -L.xOffset * L.xScale, b.height * -L.yOffset * L.yScale, b.width * L.xScale, b.height * L.yScale), v.rotate(-M.angle), v.translate(-M.position.x, -M.position.y);
2357
+ var L = M.render.sprite, D = P(g, L.texture);
2358
+ v.translate(M.position.x, M.position.y), v.rotate(M.angle), v.drawImage(D, D.width * -L.xOffset * L.xScale, D.height * -L.yOffset * L.yScale, D.width * L.xScale, D.height * L.yScale), v.rotate(-M.angle), v.translate(-M.position.x, -M.position.y);
2506
2359
  } else {
2507
2360
  if (M.circleRadius)
2508
2361
  v.beginPath(), v.arc(M.position.x, M.position.y, M.circleRadius, 0, 2 * Math.PI);
@@ -2517,174 +2370,174 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2517
2370
  v.globalAlpha = 1;
2518
2371
  }
2519
2372
  }
2520
- }, e.bodyWireframes = function(g, p, y) {
2373
+ }, e.bodyWireframes = function(g, d, y) {
2521
2374
  var v = y, w = g.options.showInternalEdges, S, C, M, I, R;
2522
- for (v.beginPath(), M = 0; M < p.length; M++)
2523
- if (S = p[M], !!S.render.visible)
2375
+ for (v.beginPath(), M = 0; M < d.length; M++)
2376
+ if (S = d[M], !!S.render.visible)
2524
2377
  for (R = S.parts.length > 1 ? 1 : 0; R < S.parts.length; R++) {
2525
2378
  for (C = S.parts[R], v.moveTo(C.vertices[0].x, C.vertices[0].y), I = 1; I < C.vertices.length; I++)
2526
2379
  !C.vertices[I - 1].isInternal || w ? v.lineTo(C.vertices[I].x, C.vertices[I].y) : v.moveTo(C.vertices[I].x, C.vertices[I].y), C.vertices[I].isInternal && !w && v.moveTo(C.vertices[(I + 1) % C.vertices.length].x, C.vertices[(I + 1) % C.vertices.length].y);
2527
2380
  v.lineTo(C.vertices[0].x, C.vertices[0].y);
2528
2381
  }
2529
2382
  v.lineWidth = 1, v.strokeStyle = g.options.wireframeStrokeStyle, v.stroke();
2530
- }, e.bodyConvexHulls = function(g, p, y) {
2383
+ }, e.bodyConvexHulls = function(g, d, y) {
2531
2384
  var v = y, w, S, C;
2532
- for (v.beginPath(), S = 0; S < p.length; S++)
2533
- if (w = p[S], !(!w.render.visible || w.parts.length === 1)) {
2385
+ for (v.beginPath(), S = 0; S < d.length; S++)
2386
+ if (w = d[S], !(!w.render.visible || w.parts.length === 1)) {
2534
2387
  for (v.moveTo(w.vertices[0].x, w.vertices[0].y), C = 1; C < w.vertices.length; C++) v.lineTo(w.vertices[C].x, w.vertices[C].y);
2535
2388
  v.lineTo(w.vertices[0].x, w.vertices[0].y);
2536
2389
  }
2537
2390
  v.lineWidth = 1, v.strokeStyle = "rgba(255,255,255,0.2)", v.stroke();
2538
- }, e.vertexNumbers = function(g, p, y) {
2391
+ }, e.vertexNumbers = function(g, d, y) {
2539
2392
  var v = y, w, S, C;
2540
- for (w = 0; w < p.length; w++) {
2541
- var M = p[w].parts;
2393
+ for (w = 0; w < d.length; w++) {
2394
+ var M = d[w].parts;
2542
2395
  for (C = M.length > 1 ? 1 : 0; C < M.length; C++) {
2543
2396
  var I = M[C];
2544
2397
  for (S = 0; S < I.vertices.length; S++)
2545
2398
  v.fillStyle = "rgba(255,255,255,0.2)", v.fillText(w + "_" + S, I.position.x + (I.vertices[S].x - I.position.x) * 0.8, I.position.y + (I.vertices[S].y - I.position.y) * 0.8);
2546
2399
  }
2547
2400
  }
2548
- }, e.mousePosition = function(g, p, y) {
2401
+ }, e.mousePosition = function(g, d, y) {
2549
2402
  var v = y;
2550
- v.fillStyle = "rgba(255,255,255,0.8)", v.fillText(p.position.x + " " + p.position.y, p.position.x + 5, p.position.y - 5);
2551
- }, e.bodyBounds = function(g, p, y) {
2403
+ v.fillStyle = "rgba(255,255,255,0.8)", v.fillText(d.position.x + " " + d.position.y, d.position.x + 5, d.position.y - 5);
2404
+ }, e.bodyBounds = function(g, d, y) {
2552
2405
  var v = y;
2553
2406
  g.engine;
2554
2407
  var w = g.options;
2555
2408
  v.beginPath();
2556
- for (var S = 0; S < p.length; S++) if (p[S].render.visible)
2557
- for (var C = p[S].parts, M = C.length > 1 ? 1 : 0; M < C.length; M++) {
2409
+ for (var S = 0; S < d.length; S++) if (d[S].render.visible)
2410
+ for (var C = d[S].parts, M = C.length > 1 ? 1 : 0; M < C.length; M++) {
2558
2411
  var I = C[M];
2559
2412
  v.rect(I.bounds.min.x, I.bounds.min.y, I.bounds.max.x - I.bounds.min.x, I.bounds.max.y - I.bounds.min.y);
2560
2413
  }
2561
2414
  w.wireframes ? v.strokeStyle = "rgba(255,255,255,0.08)" : v.strokeStyle = "rgba(0,0,0,0.1)", v.lineWidth = 1, v.stroke();
2562
- }, e.bodyAxes = function(g, p, y) {
2415
+ }, e.bodyAxes = function(g, d, y) {
2563
2416
  var v = y;
2564
2417
  g.engine;
2565
2418
  var w = g.options, S, C, M, I;
2566
- for (v.beginPath(), C = 0; C < p.length; C++) {
2567
- var R = p[C], L = R.parts;
2419
+ for (v.beginPath(), C = 0; C < d.length; C++) {
2420
+ var R = d[C], L = R.parts;
2568
2421
  if (R.render.visible)
2569
2422
  if (w.showAxes) for (M = L.length > 1 ? 1 : 0; M < L.length; M++)
2570
2423
  for (S = L[M], I = 0; I < S.axes.length; I++) {
2571
- var b = S.axes[I];
2572
- v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x + b.x * 20, S.position.y + b.y * 20);
2424
+ var D = S.axes[I];
2425
+ v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x + D.x * 20, S.position.y + D.y * 20);
2573
2426
  }
2574
2427
  else for (M = L.length > 1 ? 1 : 0; M < L.length; M++)
2575
2428
  for (S = L[M], I = 0; I < S.axes.length; I++)
2576
2429
  v.moveTo(S.position.x, S.position.y), v.lineTo((S.vertices[0].x + S.vertices[S.vertices.length - 1].x) / 2, (S.vertices[0].y + S.vertices[S.vertices.length - 1].y) / 2);
2577
2430
  }
2578
2431
  w.wireframes ? (v.strokeStyle = "indianred", v.lineWidth = 1) : (v.strokeStyle = "rgba(255, 255, 255, 0.4)", v.globalCompositeOperation = "overlay", v.lineWidth = 2), v.stroke(), v.globalCompositeOperation = "source-over";
2579
- }, e.bodyPositions = function(g, p, y) {
2432
+ }, e.bodyPositions = function(g, d, y) {
2580
2433
  var v = y;
2581
2434
  g.engine;
2582
2435
  var w = g.options, S, C, M, I;
2583
- for (v.beginPath(), M = 0; M < p.length; M++)
2584
- if (S = p[M], !!S.render.visible)
2436
+ for (v.beginPath(), M = 0; M < d.length; M++)
2437
+ if (S = d[M], !!S.render.visible)
2585
2438
  for (I = 0; I < S.parts.length; I++)
2586
2439
  C = S.parts[I], v.arc(C.position.x, C.position.y, 3, 0, 2 * Math.PI, !1), v.closePath();
2587
- for (w.wireframes ? v.fillStyle = "indianred" : v.fillStyle = "rgba(0,0,0,0.5)", v.fill(), v.beginPath(), M = 0; M < p.length; M++)
2588
- S = p[M], S.render.visible && (v.arc(S.positionPrev.x, S.positionPrev.y, 2, 0, 2 * Math.PI, !1), v.closePath());
2440
+ for (w.wireframes ? v.fillStyle = "indianred" : v.fillStyle = "rgba(0,0,0,0.5)", v.fill(), v.beginPath(), M = 0; M < d.length; M++)
2441
+ S = d[M], S.render.visible && (v.arc(S.positionPrev.x, S.positionPrev.y, 2, 0, 2 * Math.PI, !1), v.closePath());
2589
2442
  v.fillStyle = "rgba(255,165,0,0.8)", v.fill();
2590
- }, e.bodyVelocity = function(g, p, y) {
2443
+ }, e.bodyVelocity = function(g, d, y) {
2591
2444
  var v = y;
2592
2445
  v.beginPath();
2593
- for (var w = 0; w < p.length; w++) {
2594
- var S = p[w];
2446
+ for (var w = 0; w < d.length; w++) {
2447
+ var S = d[w];
2595
2448
  if (S.render.visible) {
2596
2449
  var C = o.getVelocity(S);
2597
2450
  v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x + C.x, S.position.y + C.y);
2598
2451
  }
2599
2452
  }
2600
2453
  v.lineWidth = 3, v.strokeStyle = "cornflowerblue", v.stroke();
2601
- }, e.bodyIds = function(g, p, y) {
2454
+ }, e.bodyIds = function(g, d, y) {
2602
2455
  var v = y, w, S;
2603
- for (w = 0; w < p.length; w++)
2604
- if (p[w].render.visible) {
2605
- var C = p[w].parts;
2456
+ for (w = 0; w < d.length; w++)
2457
+ if (d[w].render.visible) {
2458
+ var C = d[w].parts;
2606
2459
  for (S = C.length > 1 ? 1 : 0; S < C.length; S++) {
2607
2460
  var M = C[S];
2608
2461
  v.font = "12px Arial", v.fillStyle = "rgba(255,255,255,0.5)", v.fillText(M.id, M.position.x + 10, M.position.y - 10);
2609
2462
  }
2610
2463
  }
2611
- }, e.collisions = function(g, p, y) {
2464
+ }, e.collisions = function(g, d, y) {
2612
2465
  var v = y, w = g.options, S, C, M, I;
2613
- for (v.beginPath(), M = 0; M < p.length; M++)
2614
- if (S = p[M], !!S.isActive)
2466
+ for (v.beginPath(), M = 0; M < d.length; M++)
2467
+ if (S = d[M], !!S.isActive)
2615
2468
  for (C = S.collision, I = 0; I < S.contactCount; I++) {
2616
2469
  var R = S.contacts[I].vertex;
2617
2470
  v.rect(R.x - 1.5, R.y - 1.5, 3.5, 3.5);
2618
2471
  }
2619
- for (w.wireframes ? v.fillStyle = "rgba(255,255,255,0.7)" : v.fillStyle = "orange", v.fill(), v.beginPath(), M = 0; M < p.length; M++)
2620
- if (S = p[M], !!S.isActive && (C = S.collision, S.contactCount > 0)) {
2621
- var L = S.contacts[0].vertex.x, b = S.contacts[0].vertex.y;
2622
- S.contactCount === 2 && (L = (S.contacts[0].vertex.x + S.contacts[1].vertex.x) / 2, b = (S.contacts[0].vertex.y + S.contacts[1].vertex.y) / 2), C.bodyB === C.supports[0].body || C.bodyA.isStatic === !0 ? v.moveTo(L - C.normal.x * 8, b - C.normal.y * 8) : v.moveTo(L + C.normal.x * 8, b + C.normal.y * 8), v.lineTo(L, b);
2472
+ for (w.wireframes ? v.fillStyle = "rgba(255,255,255,0.7)" : v.fillStyle = "orange", v.fill(), v.beginPath(), M = 0; M < d.length; M++)
2473
+ if (S = d[M], !!S.isActive && (C = S.collision, S.contactCount > 0)) {
2474
+ var L = S.contacts[0].vertex.x, D = S.contacts[0].vertex.y;
2475
+ S.contactCount === 2 && (L = (S.contacts[0].vertex.x + S.contacts[1].vertex.x) / 2, D = (S.contacts[0].vertex.y + S.contacts[1].vertex.y) / 2), C.bodyB === C.supports[0].body || C.bodyA.isStatic === !0 ? v.moveTo(L - C.normal.x * 8, D - C.normal.y * 8) : v.moveTo(L + C.normal.x * 8, D + C.normal.y * 8), v.lineTo(L, D);
2623
2476
  }
2624
2477
  w.wireframes ? v.strokeStyle = "rgba(255,165,0,0.7)" : v.strokeStyle = "orange", v.lineWidth = 1, v.stroke();
2625
- }, e.separations = function(g, p, y) {
2478
+ }, e.separations = function(g, d, y) {
2626
2479
  var v = y, w = g.options, S, C, M, I, R;
2627
- for (v.beginPath(), R = 0; R < p.length; R++)
2628
- if (S = p[R], !!S.isActive) {
2480
+ for (v.beginPath(), R = 0; R < d.length; R++)
2481
+ if (S = d[R], !!S.isActive) {
2629
2482
  C = S.collision, M = C.bodyA, I = C.bodyB;
2630
2483
  var L = 1;
2631
2484
  !I.isStatic && !M.isStatic && (L = 0.5), I.isStatic && (L = 0), v.moveTo(I.position.x, I.position.y), v.lineTo(I.position.x - C.penetration.x * L, I.position.y - C.penetration.y * L), L = 1, !I.isStatic && !M.isStatic && (L = 0.5), M.isStatic && (L = 0), v.moveTo(M.position.x, M.position.y), v.lineTo(M.position.x + C.penetration.x * L, M.position.y + C.penetration.y * L);
2632
2485
  }
2633
2486
  w.wireframes ? v.strokeStyle = "rgba(255,165,0,0.5)" : v.strokeStyle = "orange", v.stroke();
2634
- }, e.inspector = function(g, p) {
2487
+ }, e.inspector = function(g, d) {
2635
2488
  g.engine;
2636
2489
  var y = g.selected, v = g.render, w = v.options, S;
2637
2490
  if (w.hasBounds) {
2638
2491
  var C = v.bounds.max.x - v.bounds.min.x, M = v.bounds.max.y - v.bounds.min.y, I = C / v.options.width, R = M / v.options.height;
2639
- p.scale(1 / I, 1 / R), p.translate(-v.bounds.min.x, -v.bounds.min.y);
2492
+ d.scale(1 / I, 1 / R), d.translate(-v.bounds.min.x, -v.bounds.min.y);
2640
2493
  }
2641
2494
  for (var L = 0; L < y.length; L++) {
2642
- var b = y[L].data;
2643
- switch (p.translate(0.5, 0.5), p.lineWidth = 1, p.strokeStyle = "rgba(255,165,0,0.9)", p.setLineDash([1, 2]), b.type) {
2495
+ var D = y[L].data;
2496
+ switch (d.translate(0.5, 0.5), d.lineWidth = 1, d.strokeStyle = "rgba(255,165,0,0.9)", d.setLineDash([1, 2]), D.type) {
2644
2497
  case "body":
2645
- S = b.bounds, p.beginPath(), p.rect(Math.floor(S.min.x - 3), Math.floor(S.min.y - 3), Math.floor(S.max.x - S.min.x + 6), Math.floor(S.max.y - S.min.y + 6)), p.closePath(), p.stroke();
2498
+ S = D.bounds, d.beginPath(), d.rect(Math.floor(S.min.x - 3), Math.floor(S.min.y - 3), Math.floor(S.max.x - S.min.x + 6), Math.floor(S.max.y - S.min.y + 6)), d.closePath(), d.stroke();
2646
2499
  break;
2647
2500
  case "constraint":
2648
- var k = b.pointA;
2649
- b.bodyA && (k = b.pointB), p.beginPath(), p.arc(k.x, k.y, 10, 0, 2 * Math.PI), p.closePath(), p.stroke();
2501
+ var k = D.pointA;
2502
+ D.bodyA && (k = D.pointB), d.beginPath(), d.arc(k.x, k.y, 10, 0, 2 * Math.PI), d.closePath(), d.stroke();
2650
2503
  break;
2651
2504
  }
2652
- p.setLineDash([]), p.translate(-0.5, -0.5);
2505
+ d.setLineDash([]), d.translate(-0.5, -0.5);
2653
2506
  }
2654
- g.selectStart !== null && (p.translate(0.5, 0.5), p.lineWidth = 1, p.strokeStyle = "rgba(255,165,0,0.6)", p.fillStyle = "rgba(255,165,0,0.1)", S = g.selectBounds, p.beginPath(), p.rect(Math.floor(S.min.x), Math.floor(S.min.y), Math.floor(S.max.x - S.min.x), Math.floor(S.max.y - S.min.y)), p.closePath(), p.stroke(), p.fill(), p.translate(-0.5, -0.5)), w.hasBounds && p.setTransform(1, 0, 0, 1, 0, 0);
2507
+ g.selectStart !== null && (d.translate(0.5, 0.5), d.lineWidth = 1, d.strokeStyle = "rgba(255,165,0,0.6)", d.fillStyle = "rgba(255,165,0,0.1)", S = g.selectBounds, d.beginPath(), d.rect(Math.floor(S.min.x), Math.floor(S.min.y), Math.floor(S.max.x - S.min.x), Math.floor(S.max.y - S.min.y)), d.closePath(), d.stroke(), d.fill(), d.translate(-0.5, -0.5)), w.hasBounds && d.setTransform(1, 0, 0, 1, 0, 0);
2655
2508
  };
2656
- var s = function(g, p) {
2509
+ var s = function(g, d) {
2657
2510
  var y = g.engine, v = g.timing, w = v.historySize, S = y.timing.timestamp;
2658
- v.delta = p - v.lastTime || e._goodDelta, v.lastTime = p, v.timestampElapsed = S - v.lastTimestamp || 0, v.lastTimestamp = S, v.deltaHistory.unshift(v.delta), v.deltaHistory.length = Math.min(v.deltaHistory.length, w), v.engineDeltaHistory.unshift(y.timing.lastDelta), v.engineDeltaHistory.length = Math.min(v.engineDeltaHistory.length, w), v.timestampElapsedHistory.unshift(v.timestampElapsed), v.timestampElapsedHistory.length = Math.min(v.timestampElapsedHistory.length, w), v.engineUpdatesHistory.unshift(y.timing.lastUpdatesPerFrame), v.engineUpdatesHistory.length = Math.min(v.engineUpdatesHistory.length, w), v.engineElapsedHistory.unshift(y.timing.lastElapsed), v.engineElapsedHistory.length = Math.min(v.engineElapsedHistory.length, w), v.elapsedHistory.unshift(v.lastElapsed), v.elapsedHistory.length = Math.min(v.elapsedHistory.length, w);
2659
- }, u = function(g) {
2660
- for (var p = 0, y = 0; y < g.length; y += 1) p += g[y];
2661
- return p / g.length || 0;
2662
- }, m = function(g, p) {
2511
+ v.delta = d - v.lastTime || e._goodDelta, v.lastTime = d, v.timestampElapsed = S - v.lastTimestamp || 0, v.lastTimestamp = S, v.deltaHistory.unshift(v.delta), v.deltaHistory.length = Math.min(v.deltaHistory.length, w), v.engineDeltaHistory.unshift(y.timing.lastDelta), v.engineDeltaHistory.length = Math.min(v.engineDeltaHistory.length, w), v.timestampElapsedHistory.unshift(v.timestampElapsed), v.timestampElapsedHistory.length = Math.min(v.timestampElapsedHistory.length, w), v.engineUpdatesHistory.unshift(y.timing.lastUpdatesPerFrame), v.engineUpdatesHistory.length = Math.min(v.engineUpdatesHistory.length, w), v.engineElapsedHistory.unshift(y.timing.lastElapsed), v.engineElapsedHistory.length = Math.min(v.engineElapsedHistory.length, w), v.elapsedHistory.unshift(v.lastElapsed), v.elapsedHistory.length = Math.min(v.elapsedHistory.length, w);
2512
+ }, f = function(g) {
2513
+ for (var d = 0, y = 0; y < g.length; y += 1) d += g[y];
2514
+ return d / g.length || 0;
2515
+ }, m = function(g, d) {
2663
2516
  var y = document.createElement("canvas");
2664
- return y.width = g, y.height = p, y.oncontextmenu = function() {
2517
+ return y.width = g, y.height = d, y.oncontextmenu = function() {
2665
2518
  return !1;
2666
2519
  }, y.onselectstart = function() {
2667
2520
  return !1;
2668
2521
  }, y;
2669
2522
  }, x = function(g) {
2670
- var p = g.getContext("2d");
2671
- return (window.devicePixelRatio || 1) / (p.webkitBackingStorePixelRatio || p.mozBackingStorePixelRatio || p.msBackingStorePixelRatio || p.oBackingStorePixelRatio || p.backingStorePixelRatio || 1);
2672
- }, P = function(g, p) {
2673
- var y = g.textures[p];
2674
- return y || (y = g.textures[p] = new Image(), y.src = p, y);
2675
- }, B = function(g, p) {
2676
- var y = p;
2677
- /(jpg|gif|png)$/.test(p) && (y = "url(" + p + ")"), g.canvas.style.background = y, g.canvas.style.backgroundSize = "contain", g.currentBackground = p;
2523
+ var d = g.getContext("2d");
2524
+ return (window.devicePixelRatio || 1) / (d.webkitBackingStorePixelRatio || d.mozBackingStorePixelRatio || d.msBackingStorePixelRatio || d.oBackingStorePixelRatio || d.backingStorePixelRatio || 1);
2525
+ }, P = function(g, d) {
2526
+ var y = g.textures[d];
2527
+ return y || (y = g.textures[d] = new Image(), y.src = d, y);
2528
+ }, T = function(g, d) {
2529
+ var y = d;
2530
+ /(jpg|gif|png)$/.test(d) && (y = "url(" + d + ")"), g.canvas.style.background = y, g.canvas.style.backgroundSize = "contain", g.currentBackground = d;
2678
2531
  };
2679
2532
  })();
2680
2533
  }),
2681
- (function(T, A, f) {
2534
+ (function(A, E, c) {
2682
2535
  var e = {};
2683
- T.exports = e;
2684
- var o = f(5), a = f(17), r = f(0);
2536
+ A.exports = e;
2537
+ var o = c(5), r = c(17), a = c(0);
2685
2538
  (function() {
2686
2539
  e._maxFrameDelta = 1e3 / 15, e._frameDeltaFallback = 1e3 / 60, e._timeBufferMargin = 1.5, e._elapsedNextEstimate = 1, e._smoothingLowerBound = 0.1, e._smoothingUpperBound = 0.9, e.create = function(n) {
2687
- var h = r.extend({
2540
+ var h = a.extend({
2688
2541
  delta: 16.666666666666668,
2689
2542
  frameDelta: null,
2690
2543
  frameDeltaSmoothing: !0,
@@ -2705,24 +2558,24 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2705
2558
  n.frameRequestId = e._onNextFrame(n, l), t && n.enabled && e.tick(n, h, t);
2706
2559
  })(), n;
2707
2560
  }, e.tick = function(n, h, l) {
2708
- var t = r.now(), i = n.delta, s = 0, u = l - n.timeLastTick;
2709
- if ((!u || !n.timeLastTick || u > Math.max(e._maxFrameDelta, n.maxFrameTime)) && (u = n.frameDelta || e._frameDeltaFallback), n.frameDeltaSmoothing) {
2710
- n.frameDeltaHistory.push(u), n.frameDeltaHistory = n.frameDeltaHistory.slice(-n.frameDeltaHistorySize);
2561
+ var t = a.now(), i = n.delta, s = 0, f = l - n.timeLastTick;
2562
+ if ((!f || !n.timeLastTick || f > Math.max(e._maxFrameDelta, n.maxFrameTime)) && (f = n.frameDelta || e._frameDeltaFallback), n.frameDeltaSmoothing) {
2563
+ n.frameDeltaHistory.push(f), n.frameDeltaHistory = n.frameDeltaHistory.slice(-n.frameDeltaHistorySize);
2711
2564
  var m = n.frameDeltaHistory.slice(0).sort();
2712
- u = c(n.frameDeltaHistory.slice(m.length * e._smoothingLowerBound, m.length * e._smoothingUpperBound)) || u;
2565
+ f = u(n.frameDeltaHistory.slice(m.length * e._smoothingLowerBound, m.length * e._smoothingUpperBound)) || f;
2713
2566
  }
2714
- n.frameDeltaSnapping && (u = 1e3 / Math.round(1e3 / u)), n.frameDelta = u, n.timeLastTick = l, n.timeBuffer += n.frameDelta, n.timeBuffer = r.clamp(n.timeBuffer, 0, n.frameDelta + i * e._timeBufferMargin), n.lastUpdatesDeferred = 0;
2567
+ n.frameDeltaSnapping && (f = 1e3 / Math.round(1e3 / f)), n.frameDelta = f, n.timeLastTick = l, n.timeBuffer += n.frameDelta, n.timeBuffer = a.clamp(n.timeBuffer, 0, n.frameDelta + i * e._timeBufferMargin), n.lastUpdatesDeferred = 0;
2715
2568
  var x = n.maxUpdates || Math.ceil(n.maxFrameTime / i), P = { timestamp: h.timing.timestamp };
2716
2569
  o.trigger(n, "beforeTick", P), o.trigger(n, "tick", P);
2717
- for (var B = r.now(); i > 0 && n.timeBuffer >= i * e._timeBufferMargin; ) {
2718
- o.trigger(n, "beforeUpdate", P), a.update(h, i), o.trigger(n, "afterUpdate", P), n.timeBuffer -= i, s += 1;
2719
- var g = r.now() - t, p = r.now() - B, y = g + e._elapsedNextEstimate * p / s;
2570
+ for (var T = a.now(); i > 0 && n.timeBuffer >= i * e._timeBufferMargin; ) {
2571
+ o.trigger(n, "beforeUpdate", P), r.update(h, i), o.trigger(n, "afterUpdate", P), n.timeBuffer -= i, s += 1;
2572
+ var g = a.now() - t, d = a.now() - T, y = g + e._elapsedNextEstimate * d / s;
2720
2573
  if (s >= x || y > n.maxFrameTime) {
2721
2574
  n.lastUpdatesDeferred = Math.round(Math.max(0, n.timeBuffer / i - e._timeBufferMargin));
2722
2575
  break;
2723
2576
  }
2724
2577
  }
2725
- h.timing.lastUpdatesPerFrame = s, o.trigger(n, "afterTick", P), n.frameDeltaHistory.length >= 100 && (n.lastUpdatesDeferred && Math.round(n.frameDelta / i) > x ? r.warnOnce("Matter.Runner: runner reached runner.maxUpdates, see docs.") : n.lastUpdatesDeferred && r.warnOnce("Matter.Runner: runner reached runner.maxFrameTime, see docs."), typeof n.isFixed < "u" && r.warnOnce("Matter.Runner: runner.isFixed is now redundant, see docs."), (n.deltaMin || n.deltaMax) && r.warnOnce("Matter.Runner: runner.deltaMin and runner.deltaMax were removed, see docs."), n.fps !== 0 && r.warnOnce("Matter.Runner: runner.fps was replaced by runner.delta, see docs."));
2578
+ h.timing.lastUpdatesPerFrame = s, o.trigger(n, "afterTick", P), n.frameDeltaHistory.length >= 100 && (n.lastUpdatesDeferred && Math.round(n.frameDelta / i) > x ? a.warnOnce("Matter.Runner: runner reached runner.maxUpdates, see docs.") : n.lastUpdatesDeferred && a.warnOnce("Matter.Runner: runner reached runner.maxFrameTime, see docs."), typeof n.isFixed < "u" && a.warnOnce("Matter.Runner: runner.isFixed is now redundant, see docs."), (n.deltaMin || n.deltaMax) && a.warnOnce("Matter.Runner: runner.deltaMin and runner.deltaMax were removed, see docs."), n.fps !== 0 && a.warnOnce("Matter.Runner: runner.fps was replaced by runner.delta, see docs."));
2726
2579
  }, e.stop = function(n) {
2727
2580
  e._cancelNextFrame(n);
2728
2581
  }, e._onNextFrame = function(n, h) {
@@ -2733,40 +2586,40 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2733
2586
  if (typeof window < "u" && window.cancelAnimationFrame) window.cancelAnimationFrame(n.frameRequestId);
2734
2587
  else throw new Error("Matter.Runner: missing required global window.cancelAnimationFrame.");
2735
2588
  };
2736
- var c = function(n) {
2589
+ var u = function(n) {
2737
2590
  for (var h = 0, l = n.length, t = 0; t < l; t += 1) h += n[t];
2738
2591
  return h / l || 0;
2739
2592
  };
2740
2593
  })();
2741
2594
  }),
2742
- (function(T, A, f) {
2595
+ (function(A, E, c) {
2743
2596
  var e = {};
2744
- T.exports = e;
2745
- var o = f(8), a = f(0).deprecated;
2597
+ A.exports = e;
2598
+ var o = c(8), r = c(0).deprecated;
2746
2599
  (function() {
2747
- e.collides = function(r, c) {
2748
- return o.collides(r, c);
2749
- }, a(e, "collides", "SAT.collides ➤ replaced by Collision.collides");
2600
+ e.collides = function(a, u) {
2601
+ return o.collides(a, u);
2602
+ }, r(e, "collides", "SAT.collides ➤ replaced by Collision.collides");
2750
2603
  })();
2751
2604
  }),
2752
- (function(T, A, f) {
2605
+ (function(A, E, c) {
2753
2606
  var e = {};
2754
- T.exports = e, f(1);
2755
- var o = f(0);
2607
+ A.exports = e, c(1);
2608
+ var o = c(0);
2756
2609
  (function() {
2757
- e.pathToVertices = function(a, r) {
2610
+ e.pathToVertices = function(r, a) {
2758
2611
  typeof window < "u" && !("SVGPathSeg" in window) && o.warn("Svg.pathToVertices: SVGPathSeg not defined, a polyfill is required.");
2759
- var c, n, h, l, t, i, s, u, m, x, P = [], B, g, p = 0, y = 0, v = 0;
2760
- r = r || 15;
2612
+ var u, n, h, l, t, i, s, f, m, x, P = [], T, g, d = 0, y = 0, v = 0;
2613
+ a = a || 15;
2761
2614
  var w = function(C, M, I) {
2762
2615
  var R = I % 2 === 1 && I > 1;
2763
2616
  if (!m || C != m.x || M != m.y) {
2764
- m && R ? (B = m.x, g = m.y) : (B = 0, g = 0);
2617
+ m && R ? (T = m.x, g = m.y) : (T = 0, g = 0);
2765
2618
  var L = {
2766
- x: B + C,
2619
+ x: T + C,
2767
2620
  y: g + M
2768
2621
  };
2769
- (R || !m) && (m = L), P.push(L), y = B + C, v = g + M;
2622
+ (R || !m) && (m = L), P.push(L), y = T + C, v = g + M;
2770
2623
  }
2771
2624
  }, S = function(C) {
2772
2625
  var M = C.pathSegTypeAsLetter.toUpperCase();
@@ -2790,11 +2643,11 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2790
2643
  w(y, v, C.pathSegType);
2791
2644
  }
2792
2645
  };
2793
- for (e._svgPathToAbsolute(a), h = a.getTotalLength(), i = [], c = 0; c < a.pathSegList.numberOfItems; c += 1) i.push(a.pathSegList.getItem(c));
2794
- for (s = i.concat(); p < h; ) {
2795
- if (x = a.getPathSegAtLength(p), t = i[x], t != u) {
2646
+ for (e._svgPathToAbsolute(r), h = r.getTotalLength(), i = [], u = 0; u < r.pathSegList.numberOfItems; u += 1) i.push(r.pathSegList.getItem(u));
2647
+ for (s = i.concat(); d < h; ) {
2648
+ if (x = r.getPathSegAtLength(d), t = i[x], t != f) {
2796
2649
  for (; s.length && s[0] != t; ) S(s.shift());
2797
- u = t;
2650
+ f = t;
2798
2651
  }
2799
2652
  switch (t.pathSegTypeAsLetter.toUpperCase()) {
2800
2653
  case "C":
@@ -2802,189 +2655,189 @@ var Qe = /* @__PURE__ */ Be(((d, E) => {
2802
2655
  case "S":
2803
2656
  case "Q":
2804
2657
  case "A":
2805
- l = a.getPointAtLength(p), w(l.x, l.y, 0);
2658
+ l = r.getPointAtLength(d), w(l.x, l.y, 0);
2806
2659
  break;
2807
2660
  }
2808
- p += r;
2661
+ d += a;
2809
2662
  }
2810
- for (c = 0, n = s.length; c < n; ++c) S(s[c]);
2663
+ for (u = 0, n = s.length; u < n; ++u) S(s[u]);
2811
2664
  return P;
2812
- }, e._svgPathToAbsolute = function(a) {
2813
- for (var r, c, n, h, l, t, i = a.pathSegList, s = 0, u = 0, m = i.numberOfItems, x = 0; x < m; ++x) {
2814
- var P = i.getItem(x), B = P.pathSegTypeAsLetter;
2815
- if (/[MLHVCSQTA]/.test(B))
2816
- "x" in P && (s = P.x), "y" in P && (u = P.y);
2665
+ }, e._svgPathToAbsolute = function(r) {
2666
+ for (var a, u, n, h, l, t, i = r.pathSegList, s = 0, f = 0, m = i.numberOfItems, x = 0; x < m; ++x) {
2667
+ var P = i.getItem(x), T = P.pathSegTypeAsLetter;
2668
+ if (/[MLHVCSQTA]/.test(T))
2669
+ "x" in P && (s = P.x), "y" in P && (f = P.y);
2817
2670
  else
2818
- switch ("x1" in P && (n = s + P.x1), "x2" in P && (l = s + P.x2), "y1" in P && (h = u + P.y1), "y2" in P && (t = u + P.y2), "x" in P && (s += P.x), "y" in P && (u += P.y), B) {
2671
+ switch ("x1" in P && (n = s + P.x1), "x2" in P && (l = s + P.x2), "y1" in P && (h = f + P.y1), "y2" in P && (t = f + P.y2), "x" in P && (s += P.x), "y" in P && (f += P.y), T) {
2819
2672
  case "m":
2820
- i.replaceItem(a.createSVGPathSegMovetoAbs(s, u), x);
2673
+ i.replaceItem(r.createSVGPathSegMovetoAbs(s, f), x);
2821
2674
  break;
2822
2675
  case "l":
2823
- i.replaceItem(a.createSVGPathSegLinetoAbs(s, u), x);
2676
+ i.replaceItem(r.createSVGPathSegLinetoAbs(s, f), x);
2824
2677
  break;
2825
2678
  case "h":
2826
- i.replaceItem(a.createSVGPathSegLinetoHorizontalAbs(s), x);
2679
+ i.replaceItem(r.createSVGPathSegLinetoHorizontalAbs(s), x);
2827
2680
  break;
2828
2681
  case "v":
2829
- i.replaceItem(a.createSVGPathSegLinetoVerticalAbs(u), x);
2682
+ i.replaceItem(r.createSVGPathSegLinetoVerticalAbs(f), x);
2830
2683
  break;
2831
2684
  case "c":
2832
- i.replaceItem(a.createSVGPathSegCurvetoCubicAbs(s, u, n, h, l, t), x);
2685
+ i.replaceItem(r.createSVGPathSegCurvetoCubicAbs(s, f, n, h, l, t), x);
2833
2686
  break;
2834
2687
  case "s":
2835
- i.replaceItem(a.createSVGPathSegCurvetoCubicSmoothAbs(s, u, l, t), x);
2688
+ i.replaceItem(r.createSVGPathSegCurvetoCubicSmoothAbs(s, f, l, t), x);
2836
2689
  break;
2837
2690
  case "q":
2838
- i.replaceItem(a.createSVGPathSegCurvetoQuadraticAbs(s, u, n, h), x);
2691
+ i.replaceItem(r.createSVGPathSegCurvetoQuadraticAbs(s, f, n, h), x);
2839
2692
  break;
2840
2693
  case "t":
2841
- i.replaceItem(a.createSVGPathSegCurvetoQuadraticSmoothAbs(s, u), x);
2694
+ i.replaceItem(r.createSVGPathSegCurvetoQuadraticSmoothAbs(s, f), x);
2842
2695
  break;
2843
2696
  case "a":
2844
- i.replaceItem(a.createSVGPathSegArcAbs(s, u, P.r1, P.r2, P.angle, P.largeArcFlag, P.sweepFlag), x);
2697
+ i.replaceItem(r.createSVGPathSegArcAbs(s, f, P.r1, P.r2, P.angle, P.largeArcFlag, P.sweepFlag), x);
2845
2698
  break;
2846
2699
  case "z":
2847
2700
  case "Z":
2848
- s = r, u = c;
2701
+ s = a, f = u;
2849
2702
  break;
2850
2703
  }
2851
- (B == "M" || B == "m") && (r = s, c = u);
2704
+ (T == "M" || T == "m") && (a = s, u = f);
2852
2705
  }
2853
2706
  };
2854
2707
  })();
2855
2708
  }),
2856
- (function(T, A, f) {
2709
+ (function(A, E, c) {
2857
2710
  var e = {};
2858
- T.exports = e;
2859
- var o = f(6);
2860
- f(0), (function() {
2711
+ A.exports = e;
2712
+ var o = c(6);
2713
+ c(0), (function() {
2861
2714
  e.create = o.create, e.add = o.add, e.remove = o.remove, e.clear = o.clear, e.addComposite = o.addComposite, e.addBody = o.addBody, e.addConstraint = o.addConstraint;
2862
2715
  })();
2863
2716
  })
2864
2717
  ]);
2865
2718
  });
2866
- })), O = Qe();
2867
- function Ze(d, E, T) {
2868
- return d < E ? E : d > T ? T : d;
2719
+ })), U = Fe();
2720
+ function Oe(p, B, A) {
2721
+ return p < B ? B : p > A ? A : p;
2869
2722
  }
2870
- function Z(d) {
2871
- const E = d.plugin.ballId;
2872
- return typeof E == "number" ? E : d.id;
2723
+ function Z(p) {
2724
+ const B = p.plugin.ballId;
2725
+ return typeof B == "number" ? B : p.id;
2873
2726
  }
2874
- function Je(d, E, T, A) {
2875
- return Ze(Math.floor((d - E) / T), 0, A - 1);
2727
+ function Ue(p, B, A, E) {
2728
+ return Oe(Math.floor((p - B) / A), 0, E - 1);
2876
2729
  }
2877
- var je = 0.18, qe = 0.12, _e = 420, et = 0.12, tt = 180, it = 2, nt = 5, st = 600, rt = 2, at = 25e3, ot = 0.15;
2878
- function xe(d, E) {
2730
+ var We = 0.18, Ne = 0.12, Ve = 420, He = 0.12, Ge = 180, ze = 2, Xe = 5, Ye = 600, Ke = 2, $e = 25e3, Qe = 0.15;
2731
+ function pe(p, B) {
2879
2732
  return {
2880
- x: d,
2881
- y: E,
2733
+ x: p,
2734
+ y: B,
2882
2735
  stuckMs: 0,
2883
2736
  kickCooldownMs: 0,
2884
2737
  kickCount: 0,
2885
- anchorY: E,
2738
+ anchorY: B,
2886
2739
  anchorAgeMs: 0,
2887
2740
  aliveMs: 0
2888
2741
  };
2889
2742
  }
2890
- var lt = class {
2743
+ var Ze = class {
2891
2744
  tracker = /* @__PURE__ */ new Map();
2892
- track(d, E, T) {
2893
- this.tracker.set(d, xe(E, T));
2745
+ track(p, B, A) {
2746
+ this.tracker.set(p, pe(B, A));
2894
2747
  }
2895
- untrack(d) {
2896
- this.tracker.delete(d);
2748
+ untrack(p) {
2749
+ this.tracker.delete(p);
2897
2750
  }
2898
2751
  clear() {
2899
2752
  this.tracker.clear();
2900
2753
  }
2901
- process(d, E, T) {
2902
- const A = [], f = /* @__PURE__ */ new Set(), e = [];
2903
- for (const o of E) {
2904
- const a = Z(o);
2905
- f.add(a);
2906
- const r = this.tracker.get(a) ?? xe(o.position.x, o.position.y), c = r.aliveMs + d;
2907
- if (c >= at || r.kickCount >= nt) {
2908
- A.push(o), this.tracker.delete(a);
2754
+ process(p, B, A) {
2755
+ const E = [], c = /* @__PURE__ */ new Set(), e = [];
2756
+ for (const o of B) {
2757
+ const r = Z(o);
2758
+ c.add(r);
2759
+ const a = this.tracker.get(r) ?? pe(o.position.x, o.position.y), u = a.aliveMs + p;
2760
+ if (u >= $e || a.kickCount >= Xe) {
2761
+ E.push(o), this.tracker.delete(r);
2909
2762
  continue;
2910
2763
  }
2911
- const n = o.position.x - r.x, h = o.position.y - r.y, l = Math.sqrt(n * n + h * h), t = o.velocity, i = Math.sqrt(t.x * t.x + t.y * t.y), s = o.position.y > T.worldHeight * et;
2912
- let u = r.anchorY, m = r.anchorAgeMs + d;
2913
- o.position.y > u + rt && (u = o.position.y, m = 0);
2914
- const x = s && (i < je && l < qe || m > st) ? r.stuckMs + d : Math.max(0, r.stuckMs - d * 2), P = Math.max(0, r.kickCooldownMs - d);
2915
- this.tracker.set(a, {
2764
+ const n = o.position.x - a.x, h = o.position.y - a.y, l = Math.sqrt(n * n + h * h), t = o.velocity, i = Math.sqrt(t.x * t.x + t.y * t.y), s = o.position.y > A.worldHeight * He;
2765
+ let f = a.anchorY, m = a.anchorAgeMs + p;
2766
+ o.position.y > f + Ke && (f = o.position.y, m = 0);
2767
+ const x = s && (i < We && l < Ne || m > Ye) ? a.stuckMs + p : Math.max(0, a.stuckMs - p * 2), P = Math.max(0, a.kickCooldownMs - p);
2768
+ this.tracker.set(r, {
2916
2769
  x: o.position.x,
2917
2770
  y: o.position.y,
2918
2771
  stuckMs: x,
2919
2772
  kickCooldownMs: P,
2920
- kickCount: r.kickCount,
2921
- anchorY: u,
2773
+ kickCount: a.kickCount,
2774
+ anchorY: f,
2922
2775
  anchorAgeMs: m,
2923
- aliveMs: c
2924
- }), x >= _e && P <= 0 && e.push({
2776
+ aliveMs: u
2777
+ }), x >= Ve && P <= 0 && e.push({
2925
2778
  ball: o,
2926
- id: a,
2779
+ id: r,
2927
2780
  stuckMs: x
2928
2781
  });
2929
2782
  }
2930
- this.applyKicks(e, T);
2931
- for (const o of this.tracker.keys()) f.has(o) || this.tracker.delete(o);
2932
- return A;
2783
+ this.applyKicks(e, A);
2784
+ for (const o of this.tracker.keys()) c.has(o) || this.tracker.delete(o);
2785
+ return E;
2933
2786
  }
2934
- applyKicks(d, E) {
2935
- if (d.length === 0) return;
2936
- d.sort((A, f) => Math.abs(f.ball.position.y - A.ball.position.y) > 0.1 ? f.ball.position.y - A.ball.position.y : f.stuckMs - A.stuckMs);
2937
- const T = Math.min(it, d.length);
2938
- for (let A = 0; A < T; A++) {
2939
- const { ball: f, id: e } = d[A], o = this.tracker.get(e);
2787
+ applyKicks(p, B) {
2788
+ if (p.length === 0) return;
2789
+ p.sort((E, c) => Math.abs(c.ball.position.y - E.ball.position.y) > 0.1 ? c.ball.position.y - E.ball.position.y : c.stuckMs - E.stuckMs);
2790
+ const A = Math.min(ze, p.length);
2791
+ for (let E = 0; E < A; E++) {
2792
+ const { ball: c, id: e } = p[E], o = this.tracker.get(e);
2940
2793
  if (!o) continue;
2941
- const a = f.velocity, r = Math.abs(f.position.x - E.center) / E.halfWidth < ot ? Math.random() < 0.5 ? 1 : -1 : f.position.x < E.center ? 1 : -1, c = r * (0.35 + Math.random() * 0.35) + (Math.random() - 0.5) * 0.25, n = 1.1 + Math.random() * 0.5;
2942
- O.Body.setVelocity(f, {
2943
- x: a.x + c,
2944
- y: Math.max(a.y + n, n)
2945
- }), O.Body.translate(f, {
2946
- x: r * (0.2 + Math.random() * 0.4),
2794
+ const r = c.velocity, a = Math.abs(c.position.x - B.center) / B.halfWidth < Qe ? Math.random() < 0.5 ? 1 : -1 : c.position.x < B.center ? 1 : -1, u = a * (0.35 + Math.random() * 0.35) + (Math.random() - 0.5) * 0.25, n = 1.1 + Math.random() * 0.5;
2795
+ U.Body.setVelocity(c, {
2796
+ x: r.x + u,
2797
+ y: Math.max(r.y + n, n)
2798
+ }), U.Body.translate(c, {
2799
+ x: a * (0.2 + Math.random() * 0.4),
2947
2800
  y: 0.25 + Math.random() * 0.35
2948
2801
  }), this.tracker.set(e, {
2949
2802
  ...o,
2950
- x: f.position.x,
2951
- y: f.position.y,
2803
+ x: c.position.x,
2804
+ y: c.position.y,
2952
2805
  stuckMs: 0,
2953
- kickCooldownMs: tt,
2806
+ kickCooldownMs: Ge,
2954
2807
  kickCount: o.kickCount + 1
2955
2808
  });
2956
2809
  }
2957
2810
  }
2958
2811
  };
2959
- function ut(d) {
2960
- const E = Math.max(0, Math.min(1, d)) * 0.5, T = E ** 1.5;
2812
+ function Je(p) {
2813
+ const B = Math.max(0, Math.min(1, p)), A = B ** 1.3;
2961
2814
  return {
2962
- windStrength: Math.min(T * 8e-7, 3e-7),
2963
- collisionNudge: T * 0.1,
2964
- spawnSigmaRatio: E > 0 ? 0.04 - T * 0.038 : 0
2815
+ windStrength: A * 4e-7,
2816
+ collisionNudge: A * 0.13,
2817
+ spawnSigmaRatio: B > 0 ? 0.04 - A * 0.035 : 0
2965
2818
  };
2966
2819
  }
2967
- var ft = 0.4;
2968
- function ct(d, E, T) {
2969
- if (!(T <= 0))
2970
- for (const A of d) {
2971
- if (Math.sqrt(A.velocity.x * A.velocity.x + A.velocity.y * A.velocity.y) < ft) continue;
2972
- const f = A.position.x - E;
2973
- O.Body.applyForce(A, A.position, {
2974
- x: -T * f,
2820
+ var je = 0.4;
2821
+ function qe(p, B, A) {
2822
+ if (!(A <= 0))
2823
+ for (const E of p) {
2824
+ if (Math.sqrt(E.velocity.x * E.velocity.x + E.velocity.y * E.velocity.y) < je) continue;
2825
+ const c = E.position.x - B;
2826
+ U.Body.applyForce(E, E.position, {
2827
+ x: -A * c,
2975
2828
  y: 0
2976
2829
  });
2977
2830
  }
2978
2831
  }
2979
2832
  var ne = "plinkit-ball";
2980
- function ht() {
2981
- const d = Math.random(), E = Math.random();
2982
- return Math.sqrt(-2 * Math.log(d || 1e-15)) * Math.cos(2 * Math.PI * E);
2833
+ function _e() {
2834
+ const p = Math.random(), B = Math.random();
2835
+ return Math.sqrt(-2 * Math.log(p || 1e-15)) * Math.cos(2 * Math.PI * B);
2983
2836
  }
2984
- function gt(d, E) {
2985
- const T = Math.max(d.radius + 8, d.height * 0.06);
2986
- let A;
2987
- return E && E > 0 ? A = ht() * d.width * E : A = (Math.random() - 0.5) * d.width * 0.08, O.Bodies.circle(d.width * 0.5 + A, T, d.radius, {
2837
+ function et(p, B) {
2838
+ const A = Math.max(p.radius + 8, p.height * 0.06);
2839
+ let E;
2840
+ return B && B > 0 ? E = _e() * p.width * B : E = (Math.random() - 0.5) * p.width * 0.08, U.Bodies.circle(p.width * 0.5 + E, A, p.radius, {
2988
2841
  label: ne,
2989
2842
  restitution: 0.65,
2990
2843
  frictionAir: 1e-3,
@@ -2992,7 +2845,7 @@ function gt(d, E) {
2992
2845
  frictionStatic: 0
2993
2846
  });
2994
2847
  }
2995
- var ee = "plinkit-peg", te = "plinkit-guide", oe = "plinkit-wall", dt = 0.22, vt = 4, pt = class {
2848
+ var ee = "plinkit-peg", te = "plinkit-guide", re = "plinkit-wall", tt = 0.22, it = 4, nt = class {
2996
2849
  engine;
2997
2850
  config;
2998
2851
  pegs = [];
@@ -3003,188 +2856,188 @@ var ee = "plinkit-peg", te = "plinkit-guide", oe = "plinkit-wall", dt = 0.22, vt
3003
2856
  pegBaseY = 0;
3004
2857
  center = 0;
3005
2858
  layoutGeometry = null;
3006
- antiStuck = new lt();
2859
+ antiStuck = new Ze();
3007
2860
  dist;
3008
2861
  removeCollisionNudge = null;
3009
2862
  removeCollisionStart = null;
3010
- constructor(d) {
3011
- this.engine = O.Engine.create({ gravity: {
2863
+ constructor(p) {
2864
+ this.engine = U.Engine.create({ gravity: {
3012
2865
  x: 0,
3013
- y: d.gravityY,
2866
+ y: p.gravityY,
3014
2867
  scale: 1e-3
3015
- } }), this.config = d, this.dist = ut(d.houseEdge ?? 0), this.rebuildStaticBodies(d.width, d.height);
3016
- const E = this.dist.collisionNudge;
3017
- if (E > 0) {
3018
- const T = (A) => {
3019
- const f = this.center, e = this.config.width * 0.5;
3020
- for (const o of A.pairs) {
3021
- const a = o.bodyA.label === "plinkit-ball" ? o.bodyA : o.bodyB.label === "plinkit-ball" ? o.bodyB : null;
3022
- if (!a || a.plugin.settled || !(o.bodyA.label === ee || o.bodyB.label === ee || o.bodyA.label === te || o.bodyB.label === te)) continue;
3023
- const r = (a.position.x - f) / e;
3024
- O.Body.setVelocity(a, {
3025
- x: a.velocity.x - E * r,
3026
- y: a.velocity.y
2868
+ } }), this.config = p, this.dist = Je(p.houseEdge ?? 0), this.rebuildStaticBodies(p.width, p.height);
2869
+ const B = this.dist.collisionNudge;
2870
+ if (B > 0) {
2871
+ const A = (E) => {
2872
+ const c = this.center, e = this.config.width * 0.5;
2873
+ for (const o of E.pairs) {
2874
+ const r = o.bodyA.label === "plinkit-ball" ? o.bodyA : o.bodyB.label === "plinkit-ball" ? o.bodyB : null;
2875
+ if (!r || r.plugin.settled || !(o.bodyA.label === ee || o.bodyB.label === ee || o.bodyA.label === te || o.bodyB.label === te)) continue;
2876
+ const a = (r.position.x - c) / e;
2877
+ U.Body.setVelocity(r, {
2878
+ x: r.velocity.x - B * a,
2879
+ y: r.velocity.y
3027
2880
  });
3028
2881
  }
3029
2882
  };
3030
- O.Events.on(this.engine, "collisionEnd", T), this.removeCollisionNudge = () => O.Events.off(this.engine, "collisionEnd", T);
2883
+ U.Events.on(this.engine, "collisionEnd", A), this.removeCollisionNudge = () => U.Events.off(this.engine, "collisionEnd", A);
3031
2884
  }
3032
- if (d.onCollision) {
3033
- const T = d.onCollision, A = (f) => {
3034
- for (const e of f.pairs) {
2885
+ if (p.onCollision) {
2886
+ const A = p.onCollision, E = (c) => {
2887
+ for (const e of c.pairs) {
3035
2888
  const o = e.bodyA.label === "plinkit-ball" ? e.bodyA : e.bodyB.label === "plinkit-ball" ? e.bodyB : null;
3036
2889
  if (!o || o.plugin.settled) continue;
3037
- const a = e.bodyA === o ? e.bodyB.label : e.bodyA.label;
3038
- let r = null;
3039
- if (a === ee ? r = "peg" : a === te && (r = "guide"), !r) continue;
3040
- const c = Math.hypot(o.velocity.x, o.velocity.y);
3041
- T({
2890
+ const r = e.bodyA === o ? e.bodyB.label : e.bodyA.label;
2891
+ let a = null;
2892
+ if (r === ee ? a = "peg" : r === te && (a = "guide"), !a) continue;
2893
+ const u = Math.hypot(o.velocity.x, o.velocity.y);
2894
+ A({
3042
2895
  ballId: Z(o),
3043
- target: r,
3044
- speed: c
2896
+ target: a,
2897
+ speed: u
3045
2898
  });
3046
2899
  }
3047
2900
  };
3048
- O.Events.on(this.engine, "collisionStart", A), this.removeCollisionStart = () => O.Events.off(this.engine, "collisionStart", A);
2901
+ U.Events.on(this.engine, "collisionStart", E), this.removeCollisionStart = () => U.Events.off(this.engine, "collisionStart", E);
3049
2902
  }
3050
2903
  }
3051
- resize(d, E) {
2904
+ resize(p, B) {
3052
2905
  this.config = {
3053
2906
  ...this.config,
3054
- width: d,
3055
- height: E
3056
- }, this.rebuildStaticBodies(d, E);
2907
+ width: p,
2908
+ height: B
2909
+ }, this.rebuildStaticBodies(p, B);
3057
2910
  }
3058
- setBallCost(d) {
2911
+ setBallCost(p) {
3059
2912
  this.config = {
3060
2913
  ...this.config,
3061
- ballCost: d
2914
+ ballCost: p
3062
2915
  };
3063
2916
  }
3064
2917
  spawnBall() {
3065
- const d = gt({
2918
+ const p = et({
3066
2919
  width: this.config.width,
3067
2920
  height: this.config.height,
3068
2921
  radius: this.config.ballRadius
3069
2922
  }, this.dist.spawnSigmaRatio);
3070
- d.plugin.ballId = this.nextBallId, d.plugin.wager = this.config.ballCost, this.nextBallId += 1, this.antiStuck.track(Z(d), d.position.x, d.position.y), O.World.add(this.engine.world, d);
2923
+ p.plugin.ballId = this.nextBallId, p.plugin.wager = this.config.ballCost, this.nextBallId += 1, this.antiStuck.track(Z(p), p.position.x, p.position.y), U.World.add(this.engine.world, p);
3071
2924
  }
3072
2925
  canSpawnBall() {
3073
- const d = this.config.height * dt;
3074
- let E = 0;
3075
- const T = O.Composite.allBodies(this.engine.world).filter((A) => A.label === ne);
3076
- for (const A of T)
3077
- if (!A.plugin.settled && A.position.y <= d && (E += 1, E >= vt))
2926
+ const p = this.config.height * tt;
2927
+ let B = 0;
2928
+ const A = U.Composite.allBodies(this.engine.world).filter((E) => E.label === ne);
2929
+ for (const E of A)
2930
+ if (!E.plugin.settled && E.position.y <= p && (B += 1, B >= it))
3078
2931
  return !1;
3079
2932
  return !0;
3080
2933
  }
3081
- step(d) {
3082
- O.Engine.update(this.engine, d);
3083
- const E = O.Composite.allBodies(this.engine.world).filter((e) => e.label === ne), T = E.filter((e) => !e.plugin.settled);
3084
- ct(T, this.center, this.dist.windStrength);
3085
- const A = this.antiStuck.process(d, T, {
2934
+ step(p) {
2935
+ U.Engine.update(this.engine, p);
2936
+ const B = U.Composite.allBodies(this.engine.world).filter((e) => e.label === ne), A = B.filter((e) => !e.plugin.settled);
2937
+ qe(A, this.center, this.dist.windStrength);
2938
+ const E = this.antiStuck.process(p, A, {
3086
2939
  center: this.center,
3087
2940
  halfWidth: this.config.width * 0.5,
3088
2941
  worldHeight: this.config.height
3089
- }).map((e) => this.settleBall(e)), f = this.cleanupBalls(E);
3090
- return A.length > 0 ? [...A, ...f] : f;
2942
+ }).map((e) => this.settleBall(e)), c = this.cleanupBalls(B);
2943
+ return E.length > 0 ? [...E, ...c] : c;
3091
2944
  }
3092
2945
  snapshot() {
3093
- const d = this.config.layout.mainPegs.radius;
2946
+ const p = this.config.layout.mainPegs.radius;
3094
2947
  return {
3095
- pegs: this.pegs.map((E) => ({
3096
- x: E.position.x,
3097
- y: E.position.y,
3098
- radius: E.circleRadius ?? d
2948
+ pegs: this.pegs.map((B) => ({
2949
+ x: B.position.x,
2950
+ y: B.position.y,
2951
+ radius: B.circleRadius ?? p
3099
2952
  })),
3100
- guidePegs: this.guidePegs.map((E) => ({
3101
- x: E.position.x,
3102
- y: E.position.y,
3103
- radius: E.circleRadius ?? d
2953
+ guidePegs: this.guidePegs.map((B) => ({
2954
+ x: B.position.x,
2955
+ y: B.position.y,
2956
+ radius: B.circleRadius ?? p
3104
2957
  })),
3105
- balls: O.Composite.allBodies(this.engine.world).filter((E) => E.label === ne).map((E) => ({
3106
- id: Z(E),
3107
- x: E.position.x,
3108
- y: E.position.y,
3109
- radius: E.circleRadius ?? this.config.ballRadius
2958
+ balls: U.Composite.allBodies(this.engine.world).filter((B) => B.label === ne).map((B) => ({
2959
+ id: Z(B),
2960
+ x: B.position.x,
2961
+ y: B.position.y,
2962
+ radius: B.circleRadius ?? this.config.ballRadius
3110
2963
  })),
3111
2964
  walls: this.getWallRects(),
3112
2965
  buckets: this.buckets
3113
2966
  };
3114
2967
  }
3115
2968
  destroy() {
3116
- this.removeCollisionNudge?.(), this.removeCollisionStart?.(), O.World.clear(this.engine.world, !1), O.Engine.clear(this.engine);
2969
+ this.removeCollisionNudge?.(), this.removeCollisionStart?.(), U.World.clear(this.engine.world, !1), U.Engine.clear(this.engine);
3117
2970
  }
3118
- cleanupBalls(d) {
3119
- const E = [], T = this.config.height + this.config.ballRadius, A = this.getBucketTop();
3120
- for (const f of d) {
3121
- if (f.position.y > T) {
3122
- this.antiStuck.untrack(Z(f)), O.World.remove(this.engine.world, f);
2971
+ cleanupBalls(p) {
2972
+ const B = [], A = this.config.height + this.config.ballRadius, E = this.getBucketTop();
2973
+ for (const c of p) {
2974
+ if (c.position.y > A) {
2975
+ this.antiStuck.untrack(Z(c)), U.World.remove(this.engine.world, c);
3123
2976
  continue;
3124
2977
  }
3125
- if (!f.plugin.settled && f.position.y >= A) {
3126
- E.push(this.settleBall(f));
2978
+ if (!c.plugin.settled && c.position.y >= E) {
2979
+ B.push(this.settleBall(c));
3127
2980
  continue;
3128
2981
  }
3129
- const e = f.circleRadius ?? this.config.ballRadius, o = this.config.height - e - 1;
3130
- !f.plugin.settled && f.position.y >= o && E.push(this.settleBall(f));
2982
+ const e = c.circleRadius ?? this.config.ballRadius, o = this.config.height - e - 1;
2983
+ !c.plugin.settled && c.position.y >= o && B.push(this.settleBall(c));
3131
2984
  }
3132
- return E;
2985
+ return B;
3133
2986
  }
3134
- rebuildStaticBodies(d, E) {
3135
- this.antiStuck.clear(), this.pegs.length > 0 && (O.World.remove(this.engine.world, this.pegs), this.pegs = []), this.guidePegs.length > 0 && (O.World.remove(this.engine.world, this.guidePegs), this.guidePegs = []), this.walls && (O.World.remove(this.engine.world, [
2987
+ rebuildStaticBodies(p, B) {
2988
+ this.antiStuck.clear(), this.pegs.length > 0 && (U.World.remove(this.engine.world, this.pegs), this.pegs = []), this.guidePegs.length > 0 && (U.World.remove(this.engine.world, this.guidePegs), this.guidePegs = []), this.walls && (U.World.remove(this.engine.world, [
3136
2989
  this.walls.leftWall,
3137
2990
  this.walls.rightWall,
3138
2991
  this.walls.floor
3139
- ]), this.walls = null), this.center = d * 0.5;
3140
- const T = Math.max(18, d * 0.02), A = d / this.config.multipliers.length, f = this.config.layout.mainPegs, e = He({
3141
- ...f,
3142
- width: d,
3143
- height: E
2992
+ ]), this.walls = null), this.center = p * 0.5;
2993
+ const A = Math.max(18, p * 0.02), E = p / this.config.multipliers.length, c = this.config.layout.mainPegs, e = Te({
2994
+ ...c,
2995
+ width: p,
2996
+ height: B
3144
2997
  });
3145
2998
  this.layoutGeometry = e;
3146
- const o = f.radius, a = this.config.layout.edgeGuides.radius;
3147
- this.pegs = Ve(e, o).map((t) => O.Bodies.circle(t.x, t.y, t.radius, {
2999
+ const o = c.radius, r = this.config.layout.edgeGuides.radius;
3000
+ this.pegs = Ae(e, o).map((t) => U.Bodies.circle(t.x, t.y, t.radius, {
3148
3001
  isStatic: !0,
3149
3002
  label: ee,
3150
3003
  restitution: 0.3
3151
3004
  })), this.pegBaseY = this.pegs.reduce((t, i) => Math.max(t, i.position.y), 0);
3152
- const r = this.getBucketTop(), c = O.Bodies.rectangle(-T * 0.5, E * 0.5, T, E * 2, {
3005
+ const a = this.getBucketTop(), u = U.Bodies.rectangle(-A * 0.5, B * 0.5, A, B * 2, {
3153
3006
  isStatic: !0,
3154
- label: oe,
3007
+ label: re,
3155
3008
  restitution: 0.4
3156
- }), n = O.Bodies.rectangle(d + T * 0.5, E * 0.5, T, E * 2, {
3009
+ }), n = U.Bodies.rectangle(p + A * 0.5, B * 0.5, A, B * 2, {
3157
3010
  isStatic: !0,
3158
- label: oe,
3011
+ label: re,
3159
3012
  restitution: 0.4
3160
- }), h = O.Bodies.rectangle(d * 0.5, E + T * 0.5, d, T, {
3013
+ }), h = U.Bodies.rectangle(p * 0.5, B + A * 0.5, p, A, {
3161
3014
  isStatic: !0,
3162
3015
  isSensor: !0,
3163
- label: oe
3016
+ label: re
3164
3017
  });
3165
3018
  this.walls = {
3166
- leftWall: c,
3019
+ leftWall: u,
3167
3020
  rightWall: n,
3168
3021
  floor: h
3169
- }, O.World.add(this.engine.world, [
3170
- c,
3022
+ }, U.World.add(this.engine.world, [
3023
+ u,
3171
3024
  n,
3172
3025
  h
3173
- ]), this.guidePegs = Ne(e, a, {
3026
+ ]), this.guidePegs = Be(e, r, {
3174
3027
  spread: this.config.layout.edgeGuides.spread,
3175
3028
  yOffset: this.config.layout.edgeGuides.yOffset
3176
- }).map((t) => O.Bodies.circle(t.x, t.y, t.radius, {
3029
+ }).map((t) => U.Bodies.circle(t.x, t.y, t.radius, {
3177
3030
  isStatic: !0,
3178
3031
  label: te,
3179
3032
  restitution: 0.3
3180
- })), O.World.add(this.engine.world, this.pegs), O.World.add(this.engine.world, this.guidePegs);
3181
- const l = E - r;
3033
+ })), U.World.add(this.engine.world, this.pegs), U.World.add(this.engine.world, this.guidePegs);
3034
+ const l = B - a;
3182
3035
  this.buckets = this.config.multipliers.map((t, i) => ({
3183
3036
  index: i,
3184
3037
  multiplier: t,
3185
- x: A * i,
3186
- y: r,
3187
- width: A,
3038
+ x: E * i,
3039
+ y: a,
3040
+ width: E,
3188
3041
  height: l
3189
3042
  }));
3190
3043
  }
@@ -3193,29 +3046,29 @@ var ee = "plinkit-peg", te = "plinkit-guide", oe = "plinkit-wall", dt = 0.22, vt
3193
3046
  this.walls.leftWall,
3194
3047
  this.walls.rightWall,
3195
3048
  this.walls.floor
3196
- ].map((d) => ({
3197
- x: d.position.x,
3198
- y: d.position.y,
3199
- width: d.bounds.max.x - d.bounds.min.x,
3200
- height: d.bounds.max.y - d.bounds.min.y
3049
+ ].map((p) => ({
3050
+ x: p.position.x,
3051
+ y: p.position.y,
3052
+ width: p.bounds.max.x - p.bounds.min.x,
3053
+ height: p.bounds.max.y - p.bounds.min.y
3201
3054
  })) : [];
3202
3055
  }
3203
3056
  getBucketTop() {
3204
- const d = this.config.layout.mainPegs.radius + this.config.ballRadius - 1;
3205
- return this.pegBaseY > 0 ? Math.min(this.config.height - 6, this.pegBaseY + d) : this.config.height * 0.85;
3057
+ const p = this.config.layout.mainPegs.radius + this.config.ballRadius - 1;
3058
+ return this.pegBaseY > 0 ? Math.min(this.config.height - 6, this.pegBaseY + p) : this.config.height * 0.85;
3206
3059
  }
3207
- settleBall(d) {
3208
- d.plugin.settled = !0, O.Body.set(d, "isSensor", !0);
3209
- const E = this.layoutGeometry, T = this.config.layout.mainPegs, A = E?.sidePadding ?? T.radius + T.sidePaddingPx, f = E?.baseSpacing ?? (this.config.width - A * 2) / Math.max(T.bottomPegCount - 1, 1), e = Je(d.position.x, A, f, this.config.multipliers.length), o = this.config.multipliers[e] ?? 0, a = typeof d.plugin.wager == "number" ? d.plugin.wager : this.config.ballCost;
3060
+ settleBall(p) {
3061
+ p.plugin.settled = !0, U.Body.set(p, "isSensor", !0);
3062
+ const B = this.layoutGeometry, A = this.config.layout.mainPegs, E = B?.sidePadding ?? A.radius + A.sidePaddingPx, c = B?.baseSpacing ?? (this.config.width - E * 2) / Math.max(A.bottomPegCount - 1, 1), e = Ue(p.position.x, E, c, this.config.multipliers.length), o = this.config.multipliers[e] ?? 0, r = typeof p.plugin.wager == "number" ? p.plugin.wager : this.config.ballCost;
3210
3063
  return {
3211
- ballId: Z(d),
3064
+ ballId: Z(p),
3212
3065
  bucketIndex: e,
3213
3066
  multiplier: o,
3214
- wager: a,
3215
- payout: a * o
3067
+ wager: r,
3068
+ payout: r * o
3216
3069
  };
3217
3070
  }
3218
- }, mt = `
3071
+ }, st = `
3219
3072
  precision highp float;
3220
3073
  in vec2 a_position;
3221
3074
  uniform vec2 u_resolution;
@@ -3231,7 +3084,7 @@ void main() {
3231
3084
  v_local = a_position;
3232
3085
  v_uv = a_position * 0.5 + 0.5;
3233
3086
  }
3234
- `, xt = `
3087
+ `, at = `
3235
3088
  precision highp float;
3236
3089
  uniform vec4 u_color;
3237
3090
  uniform float u_shapeMode;
@@ -3258,7 +3111,7 @@ void main() {
3258
3111
  outColor = vec4(u_color.rgb, u_color.a * a);
3259
3112
  }
3260
3113
  }
3261
- `, yt = class {
3114
+ `, rt = class {
3262
3115
  canvas;
3263
3116
  gl;
3264
3117
  program;
@@ -3277,19 +3130,19 @@ void main() {
3277
3130
  ballTexture = null;
3278
3131
  pegTextureReady = !1;
3279
3132
  ballTextureReady = !1;
3280
- constructor(d, E) {
3281
- this.canvas = d;
3282
- const T = d.getContext("webgl2", {
3133
+ constructor(p, B) {
3134
+ this.canvas = p;
3135
+ const A = p.getContext("webgl2", {
3283
3136
  antialias: !0,
3284
3137
  alpha: !0
3285
3138
  });
3286
- if (!T) throw new Error("WebGL2 is not supported by this browser");
3287
- this.gl = T;
3288
- const A = ye(this.gl, this.gl.VERTEX_SHADER, mt), f = ye(this.gl, this.gl.FRAGMENT_SHADER, xt);
3289
- this.program = Pt(this.gl, A, f);
3290
- const e = this.gl.getAttribLocation(this.program, "a_position"), o = this.gl.getUniformLocation(this.program, "u_resolution"), a = this.gl.getUniformLocation(this.program, "u_center"), r = this.gl.getUniformLocation(this.program, "u_size"), c = this.gl.getUniformLocation(this.program, "u_color"), n = this.gl.getUniformLocation(this.program, "u_shapeMode"), h = this.gl.getUniformLocation(this.program, "u_useTexture"), l = this.gl.getUniformLocation(this.program, "u_texture");
3291
- if (e < 0 || !o || !a || !r || !c || !n || !h || !l) throw new Error("Unable to initialize WebGL program locations");
3292
- this.positionLocation = e, this.resolutionLocation = o, this.centerLocation = a, this.sizeLocation = r, this.colorLocation = c, this.shapeModeLocation = n, this.useTextureLocation = h, this.textureLocation = l, this.gl.useProgram(this.program), this.gl.uniform1i(this.textureLocation, 0);
3139
+ if (!A) throw new Error("WebGL2 is not supported by this browser");
3140
+ this.gl = A;
3141
+ const E = de(this.gl, this.gl.VERTEX_SHADER, st), c = de(this.gl, this.gl.FRAGMENT_SHADER, at);
3142
+ this.program = ft(this.gl, E, c);
3143
+ const e = this.gl.getAttribLocation(this.program, "a_position"), o = this.gl.getUniformLocation(this.program, "u_resolution"), r = this.gl.getUniformLocation(this.program, "u_center"), a = this.gl.getUniformLocation(this.program, "u_size"), u = this.gl.getUniformLocation(this.program, "u_color"), n = this.gl.getUniformLocation(this.program, "u_shapeMode"), h = this.gl.getUniformLocation(this.program, "u_useTexture"), l = this.gl.getUniformLocation(this.program, "u_texture");
3144
+ if (e < 0 || !o || !r || !a || !u || !n || !h || !l) throw new Error("Unable to initialize WebGL program locations");
3145
+ this.positionLocation = e, this.resolutionLocation = o, this.centerLocation = r, this.sizeLocation = a, this.colorLocation = u, this.shapeModeLocation = n, this.useTextureLocation = h, this.textureLocation = l, this.gl.useProgram(this.program), this.gl.uniform1i(this.textureLocation, 0);
3293
3146
  const t = this.gl.createBuffer();
3294
3147
  if (!t) throw new Error("Unable to create WebGL buffer");
3295
3148
  this.positionBuffer = t, this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.positionBuffer), this.gl.bufferData(this.gl.ARRAY_BUFFER, new Float32Array([
@@ -3306,82 +3159,82 @@ void main() {
3306
3159
  1,
3307
3160
  1
3308
3161
  ]), this.gl.STATIC_DRAW), this.gl.enable(this.gl.BLEND), this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
3309
- const i = E?.appearance;
3162
+ const i = B?.appearance;
3310
3163
  i?.pegTextureUrl && this.startTextureLoad(i.pegTextureUrl, i.textureCrossOrigin, "peg"), i?.ballTextureUrl && this.startTextureLoad(i.ballTextureUrl, i.textureCrossOrigin, "ball");
3311
3164
  }
3312
- resize(d, E, T, A = 1) {
3313
- this.scale = T * A, this.canvas.width = Math.floor(d * T), this.canvas.height = Math.floor(E * T), this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
3165
+ resize(p, B, A, E = 1) {
3166
+ this.scale = A * E, this.canvas.width = Math.floor(p * A), this.canvas.height = Math.floor(B * A), this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
3314
3167
  }
3315
- render(d) {
3168
+ render(p) {
3316
3169
  this.gl.clearColor(0, 0, 0, 0), this.gl.clear(this.gl.COLOR_BUFFER_BIT), this.gl.useProgram(this.program), this.gl.bindBuffer(this.gl.ARRAY_BUFFER, this.positionBuffer), this.gl.enableVertexAttribArray(this.positionLocation), this.gl.vertexAttribPointer(this.positionLocation, 2, this.gl.FLOAT, !1, 0, 0), this.gl.uniform2f(this.resolutionLocation, this.canvas.width, this.canvas.height), this.gl.uniform1i(this.textureLocation, 0);
3317
- for (const E of d.walls) this.drawRect(E, ie(54, 68, 102));
3318
- for (const E of d.pegs) this.drawCircle(E.x, E.y, E.radius, ie(141, 226, 255), "peg");
3319
- for (const E of d.guidePegs) this.drawCircle(E.x, E.y, E.radius, ie(255, 90, 120), "peg");
3320
- for (const E of d.balls) this.drawCircle(E.x, E.y, E.radius, ie(250, 201, 95), "ball");
3170
+ for (const B of p.walls) this.drawRect(B, ie(54, 68, 102));
3171
+ for (const B of p.pegs) this.drawCircle(B.x, B.y, B.radius, ie(141, 226, 255), "peg");
3172
+ for (const B of p.guidePegs) this.drawCircle(B.x, B.y, B.radius, ie(255, 90, 120), "peg");
3173
+ for (const B of p.balls) this.drawCircle(B.x, B.y, B.radius, ie(250, 201, 95), "ball");
3321
3174
  }
3322
3175
  destroy() {
3323
3176
  this.destroyed = !0, this.gl.bindBuffer(this.gl.ARRAY_BUFFER, null), this.pegTexture && (this.gl.deleteTexture(this.pegTexture), this.pegTexture = null), this.ballTexture && (this.gl.deleteTexture(this.ballTexture), this.ballTexture = null), this.pegTextureReady = !1, this.ballTextureReady = !1, this.gl.deleteBuffer(this.positionBuffer), this.gl.deleteProgram(this.program);
3324
3177
  }
3325
- startTextureLoad(d, E, T) {
3326
- wt(d, E).then((A) => {
3178
+ startTextureLoad(p, B, A) {
3179
+ lt(p, B).then((E) => {
3327
3180
  if (this.destroyed) return;
3328
- const f = St(this.gl, A);
3181
+ const c = ot(this.gl, E);
3329
3182
  if (this.destroyed) {
3330
- this.gl.deleteTexture(f);
3183
+ this.gl.deleteTexture(c);
3331
3184
  return;
3332
3185
  }
3333
- T === "peg" ? (this.pegTexture && this.gl.deleteTexture(this.pegTexture), this.pegTexture = f, this.pegTextureReady = !0) : (this.ballTexture && this.gl.deleteTexture(this.ballTexture), this.ballTexture = f, this.ballTextureReady = !0);
3186
+ A === "peg" ? (this.pegTexture && this.gl.deleteTexture(this.pegTexture), this.pegTexture = c, this.pegTextureReady = !0) : (this.ballTexture && this.gl.deleteTexture(this.ballTexture), this.ballTexture = c, this.ballTextureReady = !0);
3334
3187
  }).catch(() => {
3335
3188
  });
3336
3189
  }
3337
- drawRect(d, E) {
3338
- this.gl.uniform2f(this.centerLocation, d.x * this.scale, d.y * this.scale), this.gl.uniform2f(this.sizeLocation, d.width * this.scale * 0.5, d.height * this.scale * 0.5), this.gl.uniform4f(this.colorLocation, E.r, E.g, E.b, E.a), this.gl.uniform1f(this.shapeModeLocation, 0), this.gl.uniform1f(this.useTextureLocation, 0), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
3190
+ drawRect(p, B) {
3191
+ this.gl.uniform2f(this.centerLocation, p.x * this.scale, p.y * this.scale), this.gl.uniform2f(this.sizeLocation, p.width * this.scale * 0.5, p.height * this.scale * 0.5), this.gl.uniform4f(this.colorLocation, B.r, B.g, B.b, B.a), this.gl.uniform1f(this.shapeModeLocation, 0), this.gl.uniform1f(this.useTextureLocation, 0), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
3339
3192
  }
3340
- drawCircle(d, E, T, A, f) {
3341
- this.gl.uniform2f(this.centerLocation, d * this.scale, E * this.scale), this.gl.uniform2f(this.sizeLocation, T * this.scale, T * this.scale), this.gl.uniform4f(this.colorLocation, A.r, A.g, A.b, A.a), this.gl.uniform1f(this.shapeModeLocation, 1);
3342
- const e = f === "peg" ? this.pegTexture : this.ballTexture, o = f === "peg" ? this.pegTextureReady : this.ballTextureReady;
3193
+ drawCircle(p, B, A, E, c) {
3194
+ this.gl.uniform2f(this.centerLocation, p * this.scale, B * this.scale), this.gl.uniform2f(this.sizeLocation, A * this.scale, A * this.scale), this.gl.uniform4f(this.colorLocation, E.r, E.g, E.b, E.a), this.gl.uniform1f(this.shapeModeLocation, 1);
3195
+ const e = c === "peg" ? this.pegTexture : this.ballTexture, o = c === "peg" ? this.pegTextureReady : this.ballTextureReady;
3343
3196
  e && o ? (this.gl.activeTexture(this.gl.TEXTURE0), this.gl.bindTexture(this.gl.TEXTURE_2D, e), this.gl.uniform1f(this.useTextureLocation, 1)) : this.gl.uniform1f(this.useTextureLocation, 0), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
3344
3197
  }
3345
3198
  };
3346
- function ie(d, E, T, A = 1) {
3199
+ function ie(p, B, A, E = 1) {
3347
3200
  return {
3348
- r: d / 255,
3349
- g: E / 255,
3350
- b: T / 255,
3351
- a: A
3201
+ r: p / 255,
3202
+ g: B / 255,
3203
+ b: A / 255,
3204
+ a: E
3352
3205
  };
3353
3206
  }
3354
- function St(d, E) {
3355
- const T = d.createTexture();
3356
- if (!T) throw new Error("Unable to create WebGL texture");
3357
- return d.bindTexture(d.TEXTURE_2D, T), d.texImage2D(d.TEXTURE_2D, 0, d.RGBA, d.RGBA, d.UNSIGNED_BYTE, E), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_WRAP_S, d.CLAMP_TO_EDGE), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_WRAP_T, d.CLAMP_TO_EDGE), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MIN_FILTER, d.LINEAR), d.texParameteri(d.TEXTURE_2D, d.TEXTURE_MAG_FILTER, d.LINEAR), d.bindTexture(d.TEXTURE_2D, null), T;
3207
+ function ot(p, B) {
3208
+ const A = p.createTexture();
3209
+ if (!A) throw new Error("Unable to create WebGL texture");
3210
+ return p.bindTexture(p.TEXTURE_2D, A), p.texImage2D(p.TEXTURE_2D, 0, p.RGBA, p.RGBA, p.UNSIGNED_BYTE, B), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_WRAP_S, p.CLAMP_TO_EDGE), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_WRAP_T, p.CLAMP_TO_EDGE), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_MIN_FILTER, p.LINEAR), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_MAG_FILTER, p.LINEAR), p.bindTexture(p.TEXTURE_2D, null), A;
3358
3211
  }
3359
- function wt(d, E) {
3360
- return new Promise((T, A) => {
3361
- const f = new Image();
3362
- typeof E == "string" && E.length > 0 && (f.crossOrigin = E), f.onload = () => T(f), f.onerror = () => A(/* @__PURE__ */ new Error(`Failed to load image: ${d}`)), f.src = d;
3212
+ function lt(p, B) {
3213
+ return new Promise((A, E) => {
3214
+ const c = new Image();
3215
+ typeof B == "string" && B.length > 0 && (c.crossOrigin = B), c.onload = () => A(c), c.onerror = () => E(/* @__PURE__ */ new Error(`Failed to load image: ${p}`)), c.src = p;
3363
3216
  });
3364
3217
  }
3365
- function ye(d, E, T) {
3366
- const A = d.createShader(E);
3367
- if (!A) throw new Error("Unable to create shader");
3368
- if (d.shaderSource(A, `#version 300 es
3369
- ${T}`), d.compileShader(A), !d.getShaderParameter(A, d.COMPILE_STATUS)) {
3370
- const f = d.getShaderInfoLog(A);
3371
- throw d.deleteShader(A), new Error(`Shader compile error: ${f ?? "unknown"}`);
3372
- }
3373
- return A;
3218
+ function de(p, B, A) {
3219
+ const E = p.createShader(B);
3220
+ if (!E) throw new Error("Unable to create shader");
3221
+ if (p.shaderSource(E, `#version 300 es
3222
+ ${A}`), p.compileShader(E), !p.getShaderParameter(E, p.COMPILE_STATUS)) {
3223
+ const c = p.getShaderInfoLog(E);
3224
+ throw p.deleteShader(E), new Error(`Shader compile error: ${c ?? "unknown"}`);
3225
+ }
3226
+ return E;
3374
3227
  }
3375
- function Pt(d, E, T) {
3376
- const A = d.createProgram();
3377
- if (!A) throw new Error("Unable to create program");
3378
- if (d.attachShader(A, E), d.attachShader(A, T), d.linkProgram(A), !d.getProgramParameter(A, d.LINK_STATUS)) {
3379
- const f = d.getProgramInfoLog(A);
3380
- throw d.deleteProgram(A), new Error(`Program link error: ${f ?? "unknown"}`);
3381
- }
3382
- return d.deleteShader(E), d.deleteShader(T), A;
3228
+ function ft(p, B, A) {
3229
+ const E = p.createProgram();
3230
+ if (!E) throw new Error("Unable to create program");
3231
+ if (p.attachShader(E, B), p.attachShader(E, A), p.linkProgram(E), !p.getProgramParameter(E, p.LINK_STATUS)) {
3232
+ const c = p.getProgramInfoLog(E);
3233
+ throw p.deleteProgram(E), new Error(`Program link error: ${c ?? "unknown"}`);
3234
+ }
3235
+ return p.deleteShader(B), p.deleteShader(A), E;
3383
3236
  }
3384
- var le = 1e3 / 120, Ct = 50, Mt = 8, Tt = 300, Bt = class {
3237
+ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3385
3238
  canvas;
3386
3239
  viewport;
3387
3240
  renderer;
@@ -3400,49 +3253,43 @@ var le = 1e3 / 120, Ct = 50, Mt = 8, Tt = 300, Bt = class {
3400
3253
  showGuidePegs;
3401
3254
  balance;
3402
3255
  lastSpawnAtMs = -1 / 0;
3403
- audio;
3404
- constructor(d) {
3405
- this.canvas = d.canvas, this.viewport = d.viewport, this.width = 1, this.height = 1, this.callbacks = {
3406
- onBalanceChange: d.onBalanceChange,
3407
- onBallSettled: d.onBallSettled
3408
- }, this.ballCost = d.ballCost, this.showGuidePegs = d.showGuidePegs, this.balance = d.initialBalance, this.onDprChange = () => this.listenDpr(), this.audio = d.audio ? new Fe({
3409
- pegHitUrl: d.audio.pegHitUrl,
3410
- bucketHitUrl: d.audio.bucketHitUrl,
3411
- uiTapUrl: d.audio.uiTapUrl,
3412
- masterVolume: d.audio.masterVolume ?? 1,
3413
- muted: d.audio.muted ?? !1
3414
- }) : null;
3415
- const E = ze({
3416
- mainPegs: d.layout.mainPegs,
3417
- ballRadius: d.ballRadius,
3418
- heightPolicy: d.viewport.heightPolicy
3419
- }), T = {
3420
- ...d.layout,
3421
- mainPegs: E.resolvedMainPegs
3256
+ constructor(p) {
3257
+ this.canvas = p.canvas, this.viewport = p.viewport, this.width = 1, this.height = 1, this.callbacks = {
3258
+ onBalanceChange: p.onBalanceChange,
3259
+ onBallSettled: p.onBallSettled,
3260
+ onCollision: p.onCollision
3261
+ }, this.ballCost = p.ballCost, this.showGuidePegs = p.showGuidePegs, this.balance = p.initialBalance, this.onDprChange = () => this.listenDpr();
3262
+ const B = Le({
3263
+ mainPegs: p.layout.mainPegs,
3264
+ ballRadius: p.ballRadius,
3265
+ heightPolicy: p.viewport.heightPolicy
3266
+ }), A = {
3267
+ ...p.layout,
3268
+ mainPegs: B.resolvedMainPegs
3422
3269
  };
3423
- this.worldHeight = E.worldHeight, this.canvas.style.maxWidth = "100%", this.renderer = new yt(this.canvas, { appearance: d.appearance }), this.world = new pt({
3270
+ this.worldHeight = B.worldHeight, this.canvas.style.maxWidth = "100%", this.renderer = new rt(this.canvas, { appearance: p.appearance }), this.world = new nt({
3424
3271
  width: 600,
3425
3272
  height: this.worldHeight,
3426
- gravityY: d.gravityY,
3427
- layout: T,
3428
- ballRadius: d.ballRadius,
3429
- multipliers: d.multipliers,
3273
+ gravityY: p.gravityY,
3274
+ layout: A,
3275
+ ballRadius: p.ballRadius,
3276
+ multipliers: p.multipliers,
3430
3277
  ballCost: this.ballCost,
3431
- houseEdge: d.houseEdge,
3432
- onCollision: this.audio ? (f) => this.handleCollision(f) : void 0
3433
- }), this.resize(), this.loop = new Oe((f) => this.frame(f)), this.loop.start();
3434
- const A = this.canvas.parentElement;
3435
- if (!A) throw new Error("Canvas must have a parent element for viewport sizing");
3436
- this.resizeObserver = new ResizeObserver((f) => {
3437
- const e = f[0];
3278
+ houseEdge: p.houseEdge,
3279
+ onCollision: this.callbacks.onCollision ? (c) => this.handleCollision(c) : void 0
3280
+ }), this.resize(), this.loop = new Me((c) => this.frame(c)), this.loop.start();
3281
+ const E = this.canvas.parentElement;
3282
+ if (!E) throw new Error("Canvas must have a parent element for viewport sizing");
3283
+ this.resizeObserver = new ResizeObserver((c) => {
3284
+ const e = c[0];
3438
3285
  if (!e) return;
3439
- const o = e.contentBoxSize?.[0]?.inlineSize, a = o != null && o > 0 ? o : A.getBoundingClientRect().width;
3440
- this.syncViewport(a);
3441
- }), this.resizeObserver.observe(A), this.listenDpr(), this.emitBalanceChange();
3286
+ const o = e.contentBoxSize?.[0]?.inlineSize, r = o != null && o > 0 ? o : E.getBoundingClientRect().width;
3287
+ this.syncViewport(r);
3288
+ }), this.resizeObserver.observe(E), this.listenDpr(), this.emitBalanceChange();
3442
3289
  }
3443
3290
  spawnBall() {
3444
- const d = performance.now();
3445
- return d - this.lastSpawnAtMs < Tt ? {
3291
+ const p = performance.now();
3292
+ return p - this.lastSpawnAtMs < ht ? {
3446
3293
  ok: !1,
3447
3294
  reason: "SPAWN_COOLDOWN",
3448
3295
  state: this.getStateSnapshot()
@@ -3450,7 +3297,7 @@ var le = 1e3 / 120, Ct = 50, Mt = 8, Tt = 300, Bt = class {
3450
3297
  ok: !1,
3451
3298
  reason: "INSUFFICIENT_BALANCE",
3452
3299
  state: this.getStateSnapshot()
3453
- } : (this.balance -= this.ballCost, this.lastSpawnAtMs = d, this.emitBalanceChange(), this.audio?.resume(), this.world.spawnBall(), {
3300
+ } : (this.balance -= this.ballCost, this.lastSpawnAtMs = p, this.emitBalanceChange(), this.world.spawnBall(), {
3454
3301
  ok: !0,
3455
3302
  state: this.getStateSnapshot()
3456
3303
  }) : {
@@ -3460,74 +3307,62 @@ var le = 1e3 / 120, Ct = 50, Mt = 8, Tt = 300, Bt = class {
3460
3307
  };
3461
3308
  }
3462
3309
  resize() {
3463
- const d = this.canvas.parentElement;
3464
- d && this.syncViewport(d.getBoundingClientRect().width);
3310
+ const p = this.canvas.parentElement;
3311
+ p && this.syncViewport(p.getBoundingClientRect().width);
3465
3312
  }
3466
3313
  destroy() {
3467
- this.loop.stop(), this.resizeObserver.disconnect(), this.dprQuery?.removeEventListener("change", this.onDprChange), this.dprQuery = null, this.world.destroy(), this.renderer.destroy(), this.audio?.destroy();
3314
+ this.loop.stop(), this.resizeObserver.disconnect(), this.dprQuery?.removeEventListener("change", this.onDprChange), this.dprQuery = null, this.world.destroy(), this.renderer.destroy();
3468
3315
  }
3469
3316
  getState() {
3470
3317
  return this.getStateSnapshot();
3471
3318
  }
3472
- setBallCost(d) {
3473
- if (!Number.isFinite(d) || d < 0) throw new TypeError(`Plinkit.setBallCost: expected a non-negative finite number, got ${d}`);
3474
- this.ballCost !== d && (this.ballCost = d, this.world.setBallCost(d), this.emitBalanceChange());
3475
- }
3476
- setMuted(d) {
3477
- this.audio?.setMuted(d);
3478
- }
3479
- isMuted() {
3480
- return this.audio?.isMuted() ?? !0;
3481
- }
3482
- setVolume(d) {
3483
- this.audio?.setVolume(d);
3484
- }
3485
- playUiTap() {
3486
- this.audio?.playUiTap();
3319
+ setBallCost(p) {
3320
+ if (!Number.isFinite(p) || p < 0) throw new TypeError(`Plinkit.setBallCost: expected a non-negative finite number, got ${p}`);
3321
+ this.ballCost !== p && (this.ballCost = p, this.world.setBallCost(p), this.emitBalanceChange());
3487
3322
  }
3488
- handleCollision(d) {
3489
- this.audio?.playPegHit(d.ballId, d.speed);
3323
+ handleCollision(p) {
3324
+ this.callbacks.onCollision?.(p, this.getStateSnapshot());
3490
3325
  }
3491
- frame(d) {
3326
+ frame(p) {
3492
3327
  if (this.lastFrameTime === 0) {
3493
- this.lastFrameTime = d, this.renderSnapshot();
3328
+ this.lastFrameTime = p, this.renderSnapshot();
3494
3329
  return;
3495
3330
  }
3496
- const E = Math.min(Ct, d - this.lastFrameTime);
3497
- this.lastFrameTime = d, this.accumulatorMs += E;
3498
- let T = 0;
3499
- for (; this.accumulatorMs >= le && T < Mt; ) {
3500
- const A = this.world.step(le);
3501
- for (const f of A) {
3502
- this.balance += f.payout;
3331
+ const B = Math.min(ct, p - this.lastFrameTime);
3332
+ this.lastFrameTime = p, this.accumulatorMs += B;
3333
+ let A = 0;
3334
+ for (; this.accumulatorMs >= oe && A < ut; ) {
3335
+ const E = this.world.step(oe);
3336
+ for (const c of E) {
3337
+ this.balance += c.payout;
3503
3338
  const e = this.getStateSnapshot();
3504
- this.callbacks.onBallSettled?.(f, e), this.callbacks.onBalanceChange?.(e), this.audio?.playBucketHit();
3339
+ this.callbacks.onBallSettled?.(c, e), this.callbacks.onBalanceChange?.(e);
3505
3340
  }
3506
- this.accumulatorMs -= le, T += 1;
3341
+ this.accumulatorMs -= oe, A += 1;
3507
3342
  }
3508
3343
  this.renderSnapshot();
3509
3344
  }
3510
3345
  renderSnapshot() {
3511
- const d = this.world.snapshot();
3512
- this.showGuidePegs || (d.guidePegs = []), this.renderer.render(d);
3346
+ const p = this.world.snapshot();
3347
+ this.showGuidePegs || (p.guidePegs = []), this.renderer.render(p);
3513
3348
  }
3514
3349
  emitBalanceChange() {
3515
3350
  this.callbacks.onBalanceChange?.(this.getStateSnapshot());
3516
3351
  }
3517
- syncViewport(d) {
3518
- const E = Xe({
3519
- parentWidthPx: d,
3352
+ syncViewport(p) {
3353
+ const B = Re({
3354
+ parentWidthPx: p,
3520
3355
  viewport: this.viewport,
3521
3356
  worldHeight: this.worldHeight
3522
3357
  });
3523
- this.width = Math.max(1, E.displayWidth), this.height = Math.max(1, E.displayHeight), this.canvas.style.width = `${this.width}px`, this.canvas.style.height = `${this.height}px`;
3524
- const T = Math.min(window.devicePixelRatio || 1, this.viewport.dprCap);
3525
- this.renderer.resize(this.width, this.height, T, E.worldScale);
3358
+ this.width = Math.max(1, B.displayWidth), this.height = Math.max(1, B.displayHeight), this.canvas.style.width = `${this.width}px`, this.canvas.style.height = `${this.height}px`;
3359
+ const A = Math.min(window.devicePixelRatio || 1, this.viewport.dprCap);
3360
+ this.renderer.resize(this.width, this.height, A, B.worldScale);
3526
3361
  }
3527
3362
  listenDpr() {
3528
3363
  this.dprQuery?.removeEventListener("change", this.onDprChange);
3529
- const d = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
3530
- d.addEventListener("change", this.onDprChange), this.dprQuery = d, this.resize();
3364
+ const p = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
3365
+ p.addEventListener("change", this.onDprChange), this.dprQuery = p, this.resize();
3531
3366
  }
3532
3367
  getStateSnapshot() {
3533
3368
  return {
@@ -3537,5 +3372,5 @@ var le = 1e3 / 120, Ct = 50, Mt = 8, Tt = 300, Bt = class {
3537
3372
  }
3538
3373
  };
3539
3374
  export {
3540
- Bt as Plinkit
3375
+ gt as Plinkit
3541
3376
  };