plinkit 1.0.0-dev.0 → 1.0.0-dev.2

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