plinkit 1.0.0-dev.0 → 1.0.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,35 +1,35 @@
1
- var Ce = (d, E) => () => (E || (d((E = { exports: {} }).exports, E), d = null), E.exports), Me = class {
1
+ var Ce = (p, B) => () => (B || (p((B = { exports: {} }).exports, B), p = null), B.exports), Me = class {
2
2
  rafId = null;
3
3
  step;
4
- constructor(d) {
5
- this.step = d;
4
+ constructor(p) {
5
+ this.step = p;
6
6
  }
7
7
  start() {
8
8
  if (this.rafId !== null) return;
9
- const d = (E) => {
10
- this.step(E), this.rafId = window.requestAnimationFrame(d);
9
+ const p = (B) => {
10
+ this.step(B), this.rafId = window.requestAnimationFrame(p);
11
11
  };
12
- this.rafId = window.requestAnimationFrame(d);
12
+ this.rafId = window.requestAnimationFrame(p);
13
13
  }
14
14
  stop() {
15
15
  this.rafId !== null && (window.cancelAnimationFrame(this.rafId), this.rafId = null);
16
16
  }
17
17
  };
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);
18
+ function me(p, B) {
19
+ const A = p.bottomPegCount - p.topPegCount + 1, E = p.radius + p.sidePaddingPx, c = (B - E * 2) / Math.max(p.bottomPegCount - 1, 1);
20
20
  return {
21
21
  rows: A,
22
- sidePadding: B,
22
+ sidePadding: E,
23
23
  baseSpacing: c,
24
- targetVerticalStep: c * d.verticalStepRatio
24
+ targetVerticalStep: c * p.verticalStepRatio
25
25
  };
26
26
  }
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 = [];
27
+ function Te(p) {
28
+ const { width: B, height: A, topPegCount: E } = p;
29
+ if (p.bottomPegCount < E) throw new Error("bottomPegCount must be greater than or equal to topPegCount");
30
+ const c = me(p, B), e = B * 0.5, l = p.topPaddingPx, a = Math.max(l + 60, A - p.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
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;
32
+ const t = E + o, i = n + o * h, s = (t - 1) * c.baseSpacing, f = e - s * 0.5;
33
33
  u.push({
34
34
  row: o,
35
35
  count: t,
@@ -52,67 +52,67 @@ function Te(d) {
52
52
  rowAnchors: u
53
53
  };
54
54
  }
55
- function Ae(d, E) {
55
+ function Ae(p, B) {
56
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,
60
- radius: E
57
+ for (const E of p.rowAnchors) for (let c = 0; c < E.count; c++) A.push({
58
+ x: E.startX + c * p.baseSpacing,
59
+ y: E.y,
60
+ radius: B
61
61
  });
62
62
  return A;
63
63
  }
64
- function Ee(d, E, A) {
65
- 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;
64
+ function Be(p, B, A) {
65
+ if (p.rows < 2) return [];
66
+ const E = [], c = (A.spread - 1) * p.baseSpacing, e = (t) => t < p.center ? t - c : t > p.center ? t + c : t, l = p.rowAnchors[0], a = l.leftX, r = l.rightX, h = p.startY - p.minTopY, n = B * 2.5, u = Math.min(p.verticalStep, Math.max(n, h / 3)), o = h >= n ? Math.min(3, Math.floor(h / u)) : 0;
67
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({
68
+ const i = p.startY - t * u + A.yOffset, s = a - t * p.baseSpacing * 0.5, f = r + t * p.baseSpacing * 0.5;
69
+ E.push({
70
70
  x: e(s),
71
71
  y: i,
72
- radius: E
72
+ radius: B
73
73
  }, {
74
74
  x: e(f),
75
75
  y: i,
76
- radius: E
76
+ radius: B
77
77
  });
78
78
  }
79
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({
80
+ const i = p.startY - t * u, s = p.startY - (t + 1) * u, f = a - t * p.baseSpacing * 0.5, m = a - (t + 1) * p.baseSpacing * 0.5, x = r + t * p.baseSpacing * 0.5, P = r + (t + 1) * p.baseSpacing * 0.5;
81
+ E.push({
82
82
  x: e((f + m) / 2),
83
83
  y: (i + s) / 2 + A.yOffset,
84
- radius: E
84
+ radius: B
85
85
  }, {
86
86
  x: e((x + P) / 2),
87
87
  y: (i + s) / 2 + A.yOffset,
88
- radius: E
88
+ radius: B
89
89
  });
90
90
  }
91
- 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({
91
+ for (let t = 0; t < p.rows - 1; t++) {
92
+ const i = p.rowAnchors[t], s = p.rowAnchors[t + 1], f = (i.y + s.y) / 2 + A.yOffset;
93
+ E.push({
94
94
  x: e((i.leftX + s.leftX) / 2),
95
95
  y: f,
96
- radius: E
96
+ radius: B
97
97
  }, {
98
98
  x: e((i.rightX + s.rightX) / 2),
99
99
  y: f,
100
- radius: E
100
+ radius: B
101
101
  });
102
102
  }
103
- return B;
103
+ return E;
104
104
  }
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);
105
+ var Ee = -1, Ie = 8;
106
+ function Le(p) {
107
+ const { mainPegs: B, ballRadius: A, heightPolicy: E } = p;
108
+ if (ke(E), Fe(B), !Number.isFinite(A) || A <= 0) throw new Error("ballRadius must be greater than 0");
109
+ const c = me(B, 600);
110
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);
111
+ const { rows: e, baseSpacing: l, targetVerticalStep: a } = c, r = a * Math.max(e - 1, 0), h = E.topPaddingPx, n = a * 2, u = A * 2 + Ie, o = B.radius + A + Ee, t = Math.max(E.bottomPaddingPx, o + u);
112
112
  return {
113
113
  worldHeight: h + n + r + t,
114
114
  resolvedMainPegs: {
115
- ...E,
115
+ ...B,
116
116
  topPaddingPx: h,
117
117
  bottomPaddingPx: t
118
118
  },
@@ -122,47 +122,47 @@ function Le(d) {
122
122
  requiredBottomPaddingPx: t
123
123
  };
124
124
  }
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;
125
+ function Re(p) {
126
+ const { parentWidthPx: B, viewport: A, worldHeight: E } = p;
127
+ if (De(A), !Number.isFinite(B) || B <= 0) throw new Error("Parent width must be greater than 0");
128
+ if (!Number.isFinite(E) || E <= 0) throw new Error("World height must be greater than 0");
129
+ const c = B;
130
130
  return {
131
131
  displayWidth: c,
132
- displayHeight: c * (B / 600),
132
+ displayHeight: c * (E / 600),
133
133
  worldScale: c / 600
134
134
  };
135
135
  }
136
- function ke(d) {
137
- if (!Number.isFinite(d.topPaddingPx) || d.topPaddingPx < 0) throw new Error("viewport.heightPolicy.topPaddingPx must be >= 0");
138
- if (!Number.isFinite(d.bottomPaddingPx) || d.bottomPaddingPx < 0) throw new Error("viewport.heightPolicy.bottomPaddingPx must be >= 0");
136
+ function ke(p) {
137
+ if (!Number.isFinite(p.topPaddingPx) || p.topPaddingPx < 0) throw new Error("viewport.heightPolicy.topPaddingPx must be >= 0");
138
+ if (!Number.isFinite(p.bottomPaddingPx) || p.bottomPaddingPx < 0) throw new Error("viewport.heightPolicy.bottomPaddingPx must be >= 0");
139
139
  }
140
- function De(d) {
141
- if (!Number.isFinite(d.dprCap) || d.dprCap <= 0) throw new Error("viewport.dprCap must be greater than 0");
140
+ function De(p) {
141
+ if (!Number.isFinite(p.dprCap) || p.dprCap <= 0) throw new Error("viewport.dprCap must be greater than 0");
142
142
  }
143
- function Fe(d) {
144
- if (!Number.isFinite(d.radius) || d.radius <= 0) throw new Error("layout.mainPegs.radius must be greater than 0");
145
- if (!Number.isFinite(d.topPegCount) || d.topPegCount < 1) throw new Error("layout.mainPegs.topPegCount must be >= 1");
146
- if (!Number.isFinite(d.bottomPegCount) || d.bottomPegCount < d.topPegCount) throw new Error("layout.mainPegs.bottomPegCount must be >= topPegCount");
147
- if (!Number.isFinite(d.verticalStepRatio) || d.verticalStepRatio <= 0) throw new Error("layout.mainPegs.verticalStepRatio must be > 0");
148
- if (!Number.isFinite(d.sidePaddingPx) || d.sidePaddingPx < 0) throw new Error("layout.mainPegs.sidePaddingPx must be >= 0");
143
+ function Fe(p) {
144
+ if (!Number.isFinite(p.radius) || p.radius <= 0) throw new Error("layout.mainPegs.radius must be greater than 0");
145
+ if (!Number.isFinite(p.topPegCount) || p.topPegCount < 1) throw new Error("layout.mainPegs.topPegCount must be >= 1");
146
+ if (!Number.isFinite(p.bottomPegCount) || p.bottomPegCount < p.topPegCount) throw new Error("layout.mainPegs.bottomPegCount must be >= topPegCount");
147
+ if (!Number.isFinite(p.verticalStepRatio) || p.verticalStepRatio <= 0) throw new Error("layout.mainPegs.verticalStepRatio must be > 0");
148
+ if (!Number.isFinite(p.sidePaddingPx) || p.sidePaddingPx < 0) throw new Error("layout.mainPegs.sidePaddingPx must be >= 0");
149
149
  }
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();
153
- })(d, function() {
150
+ var be = /* @__PURE__ */ Ce(((p, B) => {
151
+ (function(E, c) {
152
+ typeof p == "object" && typeof B == "object" ? B.exports = c() : typeof define == "function" && define.amd ? define("Matter", [], c) : typeof p == "object" ? p.Matter = c() : E.Matter = c();
153
+ })(p, function() {
154
154
  return (function(A) {
155
- var B = {};
155
+ var E = {};
156
156
  function c(e) {
157
- if (B[e]) return B[e].exports;
158
- var l = B[e] = {
157
+ if (E[e]) return E[e].exports;
158
+ var l = E[e] = {
159
159
  i: e,
160
160
  l: !1,
161
161
  exports: {}
162
162
  };
163
163
  return A[e].call(l.exports, l, l.exports, c), l.l = !0, l.exports;
164
164
  }
165
- return c.m = A, c.c = B, c.d = function(e, l, a) {
165
+ return c.m = A, c.c = E, c.d = function(e, l, a) {
166
166
  c.o(e, l) || Object.defineProperty(e, l, {
167
167
  enumerable: !0,
168
168
  get: a
@@ -190,7 +190,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
190
190
  return Object.prototype.hasOwnProperty.call(e, l);
191
191
  }, c.p = "", c(c.s = 20);
192
192
  })([
193
- (function(A, B) {
193
+ (function(A, E) {
194
194
  var c = {};
195
195
  A.exports = c, (function() {
196
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) {
@@ -325,7 +325,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
325
325
  };
326
326
  })();
327
327
  }),
328
- (function(A, B) {
328
+ (function(A, E) {
329
329
  var c = {};
330
330
  A.exports = c, (function() {
331
331
  c.create = function(e) {
@@ -359,7 +359,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
359
359
  };
360
360
  })();
361
361
  }),
362
- (function(A, B) {
362
+ (function(A, E) {
363
363
  var c = {};
364
364
  A.exports = c, (function() {
365
365
  c.create = function(e, l) {
@@ -437,7 +437,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
437
437
  ];
438
438
  })();
439
439
  }),
440
- (function(A, B, c) {
440
+ (function(A, E, c) {
441
441
  var e = {};
442
442
  A.exports = e;
443
443
  var l = c(2), a = c(0);
@@ -523,9 +523,9 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
523
523
  }), T = l.normalise({
524
524
  x: m.y - f.y,
525
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;
526
+ }), g = Math.sqrt(2 * Math.pow(x, 2)), d = 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
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));
528
+ for (var S = Math.acos(l.dot(P, T)) / w, C = 0; C < w; C++) t.push(l.add(l.rotate(d, S * C), v));
529
529
  }
530
530
  return t;
531
531
  }, e.clockwiseSort = function(r) {
@@ -556,7 +556,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
556
556
  };
557
557
  })();
558
558
  }),
559
- (function(A, B, c) {
559
+ (function(A, E, c) {
560
560
  var e = {};
561
561
  A.exports = e;
562
562
  var l = c(3), a = c(2), r = c(7), h = c(0), n = c(1), u = c(11);
@@ -859,7 +859,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
859
859
  };
860
860
  })();
861
861
  }),
862
- (function(A, B, c) {
862
+ (function(A, E, c) {
863
863
  var e = {};
864
864
  A.exports = e;
865
865
  var l = c(0);
@@ -893,7 +893,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
893
893
  };
894
894
  })();
895
895
  }),
896
- (function(A, B, c) {
896
+ (function(A, E, c) {
897
897
  var e = {};
898
898
  A.exports = e;
899
899
  var l = c(5), a = c(0), r = c(1), h = c(4);
@@ -1063,7 +1063,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1063
1063
  };
1064
1064
  })();
1065
1065
  }),
1066
- (function(A, B, c) {
1066
+ (function(A, E, c) {
1067
1067
  var e = {};
1068
1068
  A.exports = e;
1069
1069
  var l = c(4), a = c(5), r = c(0);
@@ -1095,7 +1095,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1095
1095
  };
1096
1096
  })();
1097
1097
  }),
1098
- (function(A, B, c) {
1098
+ (function(A, E, c) {
1099
1099
  var e = {};
1100
1100
  A.exports = e;
1101
1101
  var l = c(3), a = c(9);
@@ -1137,7 +1137,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1137
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
1138
  var f;
1139
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;
1140
+ var m = s.normal, x = s.tangent, P = s.penetration, T = s.supports, g = f.overlap, d = f.axis, y = d.x, v = d.y, w = o.position.x - u.position.x, S = o.position.y - u.position.y;
1141
1141
  y * w + v * S >= 0 && (y = -y, v = -v), m.x = y, m.y = v, x.x = -v, x.y = y, P.x = y * g, P.y = v * g, s.depth = g;
1142
1142
  var C = e._findSupports(u, o, m, 1), M = 0;
1143
1143
  if (l.contains(u.vertices, C[0]) && (T[M++] = C[0]), l.contains(u.vertices, C[1]) && (T[M++] = C[1]), M < 2) {
@@ -1146,26 +1146,26 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1146
1146
  }
1147
1147
  return M === 0 && (T[M++] = C[0]), s.supportCount = M, s;
1148
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;
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, d = Number.MAX_VALUE, y = 0, v, w, S, C, M, I;
1150
1150
  for (M = 0; M < g; M++) {
1151
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;
1152
1152
  for (I = 1; I < s; I += 1)
1153
1153
  C = o[I].x * L + o[I].y * D, C > O ? O = C : C < k && (k = C);
1154
1154
  for (I = 1; I < f; I += 1)
1155
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))
1156
+ if (w = O - F, S = W - k, v = w < S ? w : S, v < d && (d = v, y = M, v <= 0))
1157
1157
  break;
1158
1158
  }
1159
- u.axis = i[y], u.overlap = p;
1159
+ u.axis = i[y], u.overlap = d;
1160
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;
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], d = g, y = P * (m - d.x) + T * (x - d.y), v, w, S;
1162
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);
1163
+ d = s[S], w = P * (m - d.x) + T * (x - d.y), w < y && (y = w, g = d);
1164
+ return v = s[(f + g.index - 1) % f], y = P * (m - v.x) + T * (x - v.y), d = s[(g.index + 1) % f], P * (m - d.x) + T * (x - d.y) < y ? (r[0] = g, r[1] = d, r) : (r[0] = g, r[1] = v, r);
1165
1165
  };
1166
1166
  })();
1167
1167
  }),
1168
- (function(A, B, c) {
1168
+ (function(A, E, c) {
1169
1169
  var e = {};
1170
1170
  A.exports = e;
1171
1171
  var l = c(16);
@@ -1202,7 +1202,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1202
1202
  };
1203
1203
  })();
1204
1204
  }),
1205
- (function(A, B, c) {
1205
+ (function(A, E, c) {
1206
1206
  var e = {};
1207
1207
  A.exports = e;
1208
1208
  var l = c(3), a = c(2), r = c(7), h = c(1), n = c(11), u = c(0);
@@ -1246,7 +1246,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1246
1246
  if (i && (x = a.add(i.position, f)), s && (P = a.add(s.position, m)), !(!x || !P)) {
1247
1247
  var T = a.sub(x, P), g = a.magnitude(T);
1248
1248
  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;
1249
+ var d = (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, d * y), S = (i ? i.inverseMass : 0) + (s ? s.inverseMass : 0), C = S + ((i ? i.inverseInertia : 0) + (s ? s.inverseInertia : 0)), M, I, R, L, D;
1250
1250
  if (v > 0) {
1251
1251
  var k = a.create();
1252
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);
@@ -1282,7 +1282,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1282
1282
  };
1283
1283
  })();
1284
1284
  }),
1285
- (function(A, B, c) {
1285
+ (function(A, E, c) {
1286
1286
  var e = {};
1287
1287
  A.exports = e;
1288
1288
  var l = c(2), a = c(0);
@@ -1305,7 +1305,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1305
1305
  };
1306
1306
  })();
1307
1307
  }),
1308
- (function(A, B, c) {
1308
+ (function(A, E, c) {
1309
1309
  var e = {};
1310
1310
  A.exports = e;
1311
1311
  var l = c(3), a = c(0), r = c(4), h = c(1), n = c(2);
@@ -1329,7 +1329,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1329
1329
  f = f || {}, s >= 1 && a.warn("Bodies.trapezoid: slope parameter must be < 1."), s *= 0.5;
1330
1330
  var m = (1 - s * 2) * t, x = t * s, P = x + m, T = P + x, g;
1331
1331
  s < 0.5 ? g = "L 0 0 L " + x + " " + -i + " L " + P + " " + -i + " L " + T + " 0" : g = "L 0 0 L " + P + " " + -i + " L " + T + " 0";
1332
- var p = {
1332
+ var d = {
1333
1333
  label: "Trapezoid Body",
1334
1334
  position: {
1335
1335
  x: u,
@@ -1339,9 +1339,9 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1339
1339
  };
1340
1340
  if (f.chamfer) {
1341
1341
  var y = f.chamfer;
1342
- p.vertices = l.chamfer(p.vertices, y.radius, y.quality, y.qualityMin, y.qualityMax), delete f.chamfer;
1342
+ d.vertices = l.chamfer(d.vertices, y.radius, y.quality, y.qualityMin, y.qualityMax), delete f.chamfer;
1343
1343
  }
1344
- return r.create(a.extend({}, p, f));
1344
+ return r.create(a.extend({}, d, f));
1345
1345
  }, e.circle = function(u, o, t, i, s) {
1346
1346
  i = i || {};
1347
1347
  var f = {
@@ -1354,8 +1354,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1354
1354
  }, e.polygon = function(u, o, t, i, s) {
1355
1355
  if (s = s || {}, t < 3) return e.circle(u, o, i, s);
1356
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;
1358
- m += "L " + g.toFixed(3) + " " + p.toFixed(3) + " ";
1357
+ var T = x + P * f, g = Math.cos(T) * i, d = Math.sin(T) * i;
1358
+ m += "L " + g.toFixed(3) + " " + d.toFixed(3) + " ";
1359
1359
  }
1360
1360
  var y = {
1361
1361
  label: "Polygon Body",
@@ -1371,10 +1371,10 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1371
1371
  }
1372
1372
  return r.create(a.extend({}, y, s));
1373
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)
1374
+ var P = a.getDecomp(), T = !!(P && P.quickDecomp), g, d, y, v, w, S, C, M, I, R;
1375
+ for (i = i || {}, d = [], s = typeof s < "u" ? s : !1, f = typeof f < "u" ? f : 0.01, m = typeof m < "u" ? m : 10, x = typeof x < "u" ? x : 0.01, a.isArray(t[0]) || (t = [t]), I = 0; I < t.length; I += 1)
1376
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({
1377
+ y ? w = l.clockwiseSort(w) : w = l.hull(w), d.push({
1378
1378
  position: {
1379
1379
  x: u,
1380
1380
  y: o
@@ -1394,19 +1394,19 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1394
1394
  y: b[1]
1395
1395
  };
1396
1396
  });
1397
- m > 0 && l.area(k) < m || p.push({
1397
+ m > 0 && l.area(k) < m || d.push({
1398
1398
  position: l.centre(k),
1399
1399
  vertices: k
1400
1400
  });
1401
1401
  }
1402
1402
  }
1403
- for (S = 0; S < p.length; S++) p[S] = r.create(a.extend(p[S], i));
1403
+ for (S = 0; S < d.length; S++) d[S] = r.create(a.extend(d[S], i));
1404
1404
  if (s) {
1405
1405
  var F = 5;
1406
- for (S = 0; S < p.length; S++) {
1407
- var O = p[S];
1408
- for (C = S + 1; C < p.length; C++) {
1409
- var W = p[C];
1406
+ for (S = 0; S < d.length; S++) {
1407
+ var O = d[S];
1408
+ for (C = S + 1; C < d.length; C++) {
1409
+ var W = d[C];
1410
1410
  if (h.overlaps(O.bounds, W.bounds)) {
1411
1411
  var G = O.vertices, N = W.vertices;
1412
1412
  for (M = 0; M < O.vertices.length; M++) for (R = 0; R < W.vertices.length; R++) {
@@ -1417,14 +1417,14 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1417
1417
  }
1418
1418
  }
1419
1419
  }
1420
- return p.length > 1 ? (g = r.create(a.extend({ parts: p.slice(0) }, i)), r.setPosition(g, {
1420
+ return d.length > 1 ? (g = r.create(a.extend({ parts: d.slice(0) }, i)), r.setPosition(g, {
1421
1421
  x: u,
1422
1422
  y: o
1423
- }), g) : p[0];
1423
+ }), g) : d[0];
1424
1424
  };
1425
1425
  })();
1426
1426
  }),
1427
- (function(A, B, c) {
1427
+ (function(A, E, c) {
1428
1428
  var e = {};
1429
1429
  A.exports = e;
1430
1430
  var l = c(0), a = c(8);
@@ -1442,11 +1442,11 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1442
1442
  }, e.collisions = function(r) {
1443
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
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;
1445
+ var x = n[f], P = x.bounds, T = x.bounds.max.x, g = x.bounds.max.y, d = x.bounds.min.y, y = x.isStatic || x.isSleeping, v = x.parts.length, w = v === 1;
1446
1446
  for (m = f + 1; m < u; m++) {
1447
1447
  var S = n[m], C = S.bounds;
1448
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)) {
1449
+ if (!(g < C.min.y || d > C.max.y) && !(y && (S.isStatic || S.isSleeping)) && o(x.collisionFilter, S.collisionFilter)) {
1450
1450
  var M = S.parts.length;
1451
1451
  if (w && M === 1) {
1452
1452
  var I = t(x, S, h);
@@ -1471,7 +1471,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1471
1471
  };
1472
1472
  })();
1473
1473
  }),
1474
- (function(A, B, c) {
1474
+ (function(A, E, c) {
1475
1475
  var e = {};
1476
1476
  A.exports = e;
1477
1477
  var l = c(0);
@@ -1530,7 +1530,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1530
1530
  };
1531
1531
  })();
1532
1532
  }),
1533
- (function(A, B, c) {
1533
+ (function(A, E, c) {
1534
1534
  var e = {};
1535
1535
  A.exports = e;
1536
1536
  var l = c(0);
@@ -1621,7 +1621,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1621
1621
  };
1622
1622
  })();
1623
1623
  }),
1624
- (function(A, B) {
1624
+ (function(A, E) {
1625
1625
  var c = {};
1626
1626
  A.exports = c, (function() {
1627
1627
  c.create = function(e) {
@@ -1633,7 +1633,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1633
1633
  };
1634
1634
  })();
1635
1635
  }),
1636
- (function(A, B, c) {
1636
+ (function(A, E, c) {
1637
1637
  var e = {};
1638
1638
  A.exports = e;
1639
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);
@@ -1662,7 +1662,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1662
1662
  }, s);
1663
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
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;
1665
+ var m = t.now(), x = s.world, P = s.detector, T = s.pairs, g = s.timing, d = g.timestamp, y;
1666
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;
1667
1667
  var v = {
1668
1668
  timestamp: g.timestamp,
@@ -1673,7 +1673,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1673
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
1674
  o.postSolveAll(w);
1675
1675
  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", {
1676
+ h.update(T, C, d), s.enableSleeping && l.afterCollisions(T.list), T.collisionStart.length > 0 && n.trigger(s, "collisionStart", {
1677
1677
  pairs: T.collisionStart,
1678
1678
  timestamp: g.timestamp,
1679
1679
  delta: f
@@ -1723,7 +1723,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1723
1723
  };
1724
1724
  })();
1725
1725
  }),
1726
- (function(A, B, c) {
1726
+ (function(A, E, c) {
1727
1727
  var e = {};
1728
1728
  A.exports = e;
1729
1729
  var l = c(3), a = c(0), r = c(1);
@@ -1733,10 +1733,10 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1733
1733
  for (n = 0; n < t; n++)
1734
1734
  u = h[n], u.isActive && (o = u.contactCount, u.collision.parentA.totalContacts += o, u.collision.parentB.totalContacts += o);
1735
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++)
1736
+ var o, t, i, s, f, m, x, P, T = e._positionDampen * (u || 1), g = a.clamp(n / a._baseDelta, 0, 1), d = h.length;
1737
+ for (o = 0; o < d; o++)
1738
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++)
1739
+ for (o = 0; o < d; o++)
1740
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
1741
  }, e.postSolvePosition = function(h) {
1742
1742
  for (var n = e._positionWarming, u = h.length, o = l.translate, t = r.update, i = 0; i < u; i++) {
@@ -1756,10 +1756,10 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1756
1756
  if (!(!t.isActive || t.isSensor)) {
1757
1757
  var i = t.contacts, s = t.contactCount, f = t.collision, m = f.parentA, x = f.parentB, P = f.normal, T = f.tangent;
1758
1758
  for (o = 0; o < s; o++) {
1759
- var g = i[o], p = g.vertex, y = g.normalImpulse, v = g.tangentImpulse;
1759
+ var g = i[o], d = g.vertex, y = g.normalImpulse, v = g.tangentImpulse;
1760
1760
  if (y !== 0 || v !== 0) {
1761
1761
  var w = P.x * y + T.x * v, S = P.y * y + T.y * v;
1762
- m.isStatic || m.isSleeping || (m.positionPrev.x += w * m.inverseMass, m.positionPrev.y += S * m.inverseMass, m.anglePrev += m.inverseInertia * ((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));
1762
+ m.isStatic || m.isSleeping || (m.positionPrev.x += w * m.inverseMass, m.positionPrev.y += S * m.inverseMass, m.anglePrev += m.inverseInertia * ((d.x - m.position.x) * S - (d.y - m.position.y) * w)), x.isStatic || x.isSleeping || (x.positionPrev.x -= w * x.inverseMass, x.positionPrev.y -= S * x.inverseMass, x.anglePrev -= x.inverseInertia * ((d.x - x.position.x) * S - (d.y - x.position.y) * w));
1763
1763
  }
1764
1764
  }
1765
1765
  }
@@ -1767,15 +1767,15 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1767
1767
  }, e.solveVelocity = function(h, n) {
1768
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
1769
  for (T = 0; T < m; T++) {
1770
- var p = h[T];
1771
- 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;
1770
+ var d = h[T];
1771
+ if (!(!d.isActive || d.isSensor)) {
1772
+ var y = d.collision, v = y.parentA, w = y.parentB, S = y.normal.x, C = y.normal.y, M = y.tangent.x, I = y.tangent.y, R = d.inverseMass, L = d.friction * d.frictionStatic * s, D = d.contacts, k = d.contactCount, 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;
1773
1773
  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);
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 = d.separation + ie, ne = Math.min(ce, 1);
1775
1775
  ne = ce < 0 ? 0 : ne;
1776
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;
1777
+ $ < -ue || $ > ue ? (P = $ > 0 ? $ : -$, x = d.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 + d.restitution) * ie * ve;
1779
1779
  if (x *= ve, ie < t) b.normalImpulse = 0;
1780
1780
  else {
1781
1781
  var we = b.normalImpulse;
@@ -1794,7 +1794,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1794
1794
  };
1795
1795
  })();
1796
1796
  }),
1797
- (function(A, B, c) {
1797
+ (function(A, E, c) {
1798
1798
  var e = {};
1799
1799
  A.exports = e;
1800
1800
  var l = c(9), a = c(0);
@@ -1808,22 +1808,22 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1808
1808
  collisionEnd: []
1809
1809
  }, r);
1810
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;
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, d = 0, y = 0, v = 0, w, S, C;
1812
1812
  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);
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[d++] = S, s[m++] = S);
1814
1814
  for (m = 0, f = s.length, C = 0; C < f; C++)
1815
1815
  S = s[C], S.timeUpdated >= n ? s[m++] = S : (t(S, !1, n), S.collision.bodyA.sleepCounter > 0 && S.collision.bodyB.sleepCounter > 0 ? s[m++] = S : (P[y++] = S, delete i[S.id]));
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);
1816
+ s.length !== m && (s.length = m), x.length !== d && (x.length = d), P.length !== y && (P.length = y), T.length !== v && (T.length = v);
1817
1817
  }, e.clear = function(r) {
1818
1818
  return r.table = {}, r.list.length = 0, r.collisionStart.length = 0, r.collisionActive.length = 0, r.collisionEnd.length = 0, r;
1819
1819
  };
1820
1820
  })();
1821
1821
  }),
1822
- (function(A, B, c) {
1822
+ (function(A, E, c) {
1823
1823
  var e = A.exports = c(21);
1824
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");
1825
1825
  }),
1826
- (function(A, B, c) {
1826
+ (function(A, E, c) {
1827
1827
  var e = {};
1828
1828
  A.exports = e;
1829
1829
  var l = c(15), a = c(0);
@@ -1837,21 +1837,21 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1837
1837
  };
1838
1838
  })();
1839
1839
  }),
1840
- (function(A, B, c) {
1840
+ (function(A, E, c) {
1841
1841
  var e = {};
1842
1842
  A.exports = e;
1843
1843
  var l = c(6), a = c(10), r = c(0), h = c(4), n = c(12), u = r.deprecated;
1844
1844
  (function() {
1845
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++) {
1846
+ for (var P = l.create({ label: "Stack" }), T = o, g = t, d, y = 0, v = 0; v < s; v++) {
1847
1847
  for (var w = 0, S = 0; S < i; S++) {
1848
- var C = x(T, g, S, v, p, y);
1848
+ var C = x(T, g, S, v, d, y);
1849
1849
  if (C) {
1850
1850
  var M = C.bounds.max.y - C.bounds.min.y, I = C.bounds.max.x - C.bounds.min.x;
1851
1851
  M > w && (w = M), h.translate(C, {
1852
1852
  x: I * 0.5,
1853
1853
  y: M * 0.5
1854
- }), T = C.bounds.max.x + f, l.addBody(P, C), p = C, y += 1;
1854
+ }), T = C.bounds.max.x + f, l.addBody(P, C), d = C, y += 1;
1855
1855
  } else T += f;
1856
1856
  }
1857
1857
  g += w + m, T = o;
@@ -1859,11 +1859,11 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1859
1859
  return P;
1860
1860
  }, e.chain = function(o, t, i, s, f, m) {
1861
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 = {
1862
+ var T = x[P - 1], g = x[P], d = T.bounds.max.y - T.bounds.min.y, y = T.bounds.max.x - T.bounds.min.x, v = g.bounds.max.y - g.bounds.min.y, w = g.bounds.max.x - g.bounds.min.x, S = {
1863
1863
  bodyA: T,
1864
1864
  pointA: {
1865
1865
  x: y * t,
1866
- y: p * i
1866
+ y: d * i
1867
1867
  },
1868
1868
  bodyB: g,
1869
1869
  pointB: {
@@ -1875,7 +1875,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1875
1875
  }
1876
1876
  return o.label += " Chain", o;
1877
1877
  }, e.mesh = function(o, t, i, s, f) {
1878
- var m = o.bodies, x, P, T, g, p;
1878
+ var m = o.bodies, x, P, T, g, d;
1879
1879
  for (x = 0; x < i; x++) {
1880
1880
  for (P = 1; P < t; P++)
1881
1881
  T = m[P - 1 + x * t], g = m[P + x * t], l.addConstraint(o, a.create(r.extend({
@@ -1886,26 +1886,26 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1886
1886
  T = m[P + (x - 1) * t], g = m[P + x * t], l.addConstraint(o, a.create(r.extend({
1887
1887
  bodyA: T,
1888
1888
  bodyB: g
1889
- }, f))), s && P > 0 && (p = m[P - 1 + (x - 1) * t], l.addConstraint(o, a.create(r.extend({
1890
- bodyA: p,
1889
+ }, f))), s && P > 0 && (d = m[P - 1 + (x - 1) * t], l.addConstraint(o, a.create(r.extend({
1890
+ bodyA: d,
1891
1891
  bodyB: g
1892
- }, f)))), s && P < t - 1 && (p = m[P + 1 + (x - 1) * t], l.addConstraint(o, a.create(r.extend({
1893
- bodyA: p,
1892
+ }, f)))), s && P < t - 1 && (d = m[P + 1 + (x - 1) * t], l.addConstraint(o, a.create(r.extend({
1893
+ bodyA: d,
1894
1894
  bodyB: g
1895
1895
  }, f))));
1896
1896
  }
1897
1897
  return o.label += " Mesh", o;
1898
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) {
1899
+ return e.stack(o, t, i, s, f, m, function(P, T, g, d, y, v) {
1900
1900
  var w = Math.min(s, Math.ceil(i / 2)), S = y ? y.bounds.max.x - y.bounds.min.x : 0;
1901
- if (!(p > w)) {
1902
- p = w - p;
1903
- var C = p, M = i - 1 - p;
1901
+ if (!(d > w)) {
1902
+ d = w - d;
1903
+ var C = d, M = i - 1 - d;
1904
1904
  if (!(g < C || g > M))
1905
1905
  return v === 1 && h.translate(y, {
1906
1906
  x: (g + (i % 2 === 1 ? 1 : -1)) * S,
1907
1907
  y: 0
1908
- }), x(o + (y ? g * S : 0) + g * f, T, g, p, y, v);
1908
+ }), x(o + (y ? g * S : 0) + g * f, T, g, d, y, v);
1909
1909
  }
1910
1910
  });
1911
1911
  }, e.newtonsCradle = function(o, t, i, s, f) {
@@ -1927,7 +1927,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1927
1927
  }
1928
1928
  return m;
1929
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, {
1930
+ var m = h.nextGroup(!0), x = 20, P = -i * 0.5 + x, T = i * 0.5 - x, g = 0, d = l.create({ label: "Car" }), y = n.rectangle(o, t, i, s, {
1931
1931
  collisionFilter: { group: m },
1932
1932
  chamfer: { radius: s * 0.5 },
1933
1933
  density: 2e-4
@@ -1956,7 +1956,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1956
1956
  stiffness: 1,
1957
1957
  length: 0
1958
1958
  });
1959
- return l.addBody(p, y), l.addBody(p, v), l.addBody(p, w), l.addConstraint(p, S), l.addConstraint(p, C), p;
1959
+ return l.addBody(d, y), l.addBody(d, v), l.addBody(d, w), l.addConstraint(d, S), l.addConstraint(d, C), d;
1960
1960
  }, u(e, "car", "Composites.car ➤ moved to car example"), e.softBody = function(o, t, i, s, f, m, x, P, T, g) {
1961
1961
  T = r.extend({ inertia: 1 / 0 }, T), g = r.extend({
1962
1962
  stiffness: 0.2,
@@ -1965,14 +1965,14 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1965
1965
  anchors: !1
1966
1966
  }
1967
1967
  }, g);
1968
- var p = e.stack(o, t, i, s, f, m, function(y, v) {
1968
+ var d = e.stack(o, t, i, s, f, m, function(y, v) {
1969
1969
  return n.circle(y, v, P, T);
1970
1970
  });
1971
- return e.mesh(p, i, s, x, g), p.label = "Soft Body", p;
1971
+ return e.mesh(d, i, s, x, g), d.label = "Soft Body", d;
1972
1972
  }, u(e, "softBody", "Composites.softBody ➤ moved to softBody and cloth examples");
1973
1973
  })();
1974
1974
  }),
1975
- (function(A, B, c) {
1975
+ (function(A, E, c) {
1976
1976
  var e = {};
1977
1977
  A.exports = e;
1978
1978
  var l = c(9), a = c(0), r = a.deprecated;
@@ -1990,16 +1990,16 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
1990
1990
  for (t = 0; t < n.length; t++) {
1991
1991
  var g = n[t];
1992
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);
1996
- var y = e._regionUnion(p, g.region);
1993
+ var d = e._getRegion(h, g);
1994
+ if (!g.region || d.id !== g.region.id || o) {
1995
+ (!g.region || o) && (g.region = d);
1996
+ var y = e._regionUnion(d, g.region);
1997
1997
  for (i = y.startCol; i <= y.endCol; i++) for (s = y.startRow; s <= y.endRow; s++) {
1998
1998
  P = e._getBucketId(i, s), x = m[P];
1999
- 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));
1999
+ var v = i >= d.startCol && i <= d.endCol && s >= d.startRow && s <= d.endRow, w = i >= g.region.startCol && i <= g.region.endCol && s >= g.region.startRow && s <= g.region.endRow;
2000
+ !v && w && w && x && e._bucketRemoveBody(h, x, g), (g.region === d || v && !w || o) && (x || (x = e._createBucket(m, P)), e._bucketAddBody(h, x, g));
2001
2001
  }
2002
- g.region = p, T = !0;
2002
+ g.region = d, T = !0;
2003
2003
  }
2004
2004
  }
2005
2005
  }
@@ -2054,7 +2054,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2054
2054
  };
2055
2055
  })();
2056
2056
  }),
2057
- (function(A, B, c) {
2057
+ (function(A, E, c) {
2058
2058
  var e = {};
2059
2059
  A.exports = e;
2060
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);
@@ -2099,8 +2099,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2099
2099
  else
2100
2100
  for (var T = 0; T < f.length; T++)
2101
2101
  if (P = f[T], i.contains(P.bounds, m.position) && n.canCollide(P.collisionFilter, s.collisionFilter)) for (var g = P.parts.length > 1 ? 1 : 0; g < P.parts.length; g++) {
2102
- var p = P.parts[g];
2103
- if (l.contains(p.vertices, m.position)) {
2102
+ var d = P.parts[g];
2103
+ if (l.contains(d.vertices, m.position)) {
2104
2104
  x.pointA = m.position, x.bodyB = s.body = P, x.pointB = {
2105
2105
  x: m.position.x - P.position.x,
2106
2106
  y: m.position.y - P.position.y
@@ -2122,7 +2122,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2122
2122
  };
2123
2123
  })();
2124
2124
  }),
2125
- (function(A, B, c) {
2125
+ (function(A, E, c) {
2126
2126
  var e = {};
2127
2127
  A.exports = e;
2128
2128
  var l = c(2), a = c(8), r = c(1), h = c(12), n = c(3);
@@ -2130,8 +2130,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2130
2130
  e.collides = function(u, o) {
2131
2131
  for (var t = [], i = o.length, s = u.bounds, f = a.collides, m = r.overlaps, x = 0; x < i; x++) {
2132
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++) {
2134
- var y = P.parts[p];
2133
+ if (m(P.bounds, s)) for (var d = g; d < T; d++) {
2134
+ var y = P.parts[d];
2135
2135
  if (m(y.bounds, s)) {
2136
2136
  var v = f(y, u);
2137
2137
  if (v) {
@@ -2145,8 +2145,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2145
2145
  }, e.ray = function(u, o, t, i) {
2146
2146
  i = i || 1e-100;
2147
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];
2149
- p.body = p.bodyB = p.bodyA;
2148
+ var d = T[g];
2149
+ d.body = d.bodyB = d.bodyA;
2150
2150
  }
2151
2151
  return T;
2152
2152
  }, e.region = function(u, o, t) {
@@ -2170,7 +2170,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2170
2170
  };
2171
2171
  })();
2172
2172
  }),
2173
- (function(A, B, c) {
2173
+ (function(A, E, c) {
2174
2174
  var e = {};
2175
2175
  A.exports = e;
2176
2176
  var l = c(4), a = c(0), r = c(6), h = c(1), n = c(5), u = c(2), o = c(14);
@@ -2181,7 +2181,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2181
2181
  g(a.now());
2182
2182
  }, 1e3 / 60);
2183
2183
  }, i = window.cancelAnimationFrame || window.mozCancelAnimationFrame || window.webkitCancelAnimationFrame || window.msCancelAnimationFrame), e._goodFps = 30, e._goodDelta = 1e3 / 60, e.create = function(g) {
2184
- var p = {
2184
+ var d = {
2185
2185
  engine: null,
2186
2186
  element: null,
2187
2187
  canvas: null,
@@ -2228,7 +2228,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2228
2228
  showInternalEdges: !1,
2229
2229
  showMousePosition: !1
2230
2230
  }
2231
- }, y = a.extend(p, g);
2231
+ }, y = a.extend(d, g);
2232
2232
  return y.canvas && (y.canvas.width = y.options.width || y.canvas.width, y.canvas.height = y.options.height || y.canvas.height), y.mouse = g.mouse, y.engine = g.engine, y.canvas = y.canvas || m(y.options.width, y.options.height), y.context = y.canvas.getContext("2d"), y.textures = {}, y.bounds = y.bounds || {
2233
2233
  min: {
2234
2234
  x: 0,
@@ -2240,18 +2240,18 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2240
2240
  }
2241
2241
  }, y.controller = e, y.options.showBroadphase = !1, y.options.pixelRatio !== 1 && e.setPixelRatio(y, y.options.pixelRatio), a.isElement(y.element) && y.element.appendChild(y.canvas), y;
2242
2242
  }, e.run = function(g) {
2243
- (function p(y) {
2244
- g.frameRequestId = t(p), s(g, y), e.world(g, y), g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0), (g.options.showStats || g.options.showDebug) && e.stats(g, g.context, y), (g.options.showPerformance || g.options.showDebug) && e.performance(g, g.context, y), g.context.setTransform(1, 0, 0, 1, 0, 0);
2243
+ (function d(y) {
2244
+ g.frameRequestId = t(d), s(g, y), e.world(g, y), g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0), (g.options.showStats || g.options.showDebug) && e.stats(g, g.context, y), (g.options.showPerformance || g.options.showDebug) && e.performance(g, g.context, y), g.context.setTransform(1, 0, 0, 1, 0, 0);
2245
2245
  })();
2246
2246
  }, e.stop = function(g) {
2247
2247
  i(g.frameRequestId);
2248
- }, e.setPixelRatio = function(g, p) {
2248
+ }, e.setPixelRatio = function(g, d) {
2249
2249
  var y = g.options, v = g.canvas;
2250
- p === "auto" && (p = x(v)), y.pixelRatio = p, v.setAttribute("data-pixel-ratio", p), v.width = y.width * p, v.height = y.height * p, v.style.width = y.width + "px", v.style.height = y.height + "px";
2251
- }, e.setSize = function(g, p, y) {
2252
- g.options.width = p, g.options.height = y, g.bounds.max.x = g.bounds.min.x + p, g.bounds.max.y = g.bounds.min.y + y, g.options.pixelRatio !== 1 ? e.setPixelRatio(g, g.options.pixelRatio) : (g.canvas.width = p, g.canvas.height = y);
2253
- }, e.lookAt = function(g, p, y, v) {
2254
- v = typeof v < "u" ? v : !0, p = a.isArray(p) ? p : [p], y = y || {
2250
+ d === "auto" && (d = x(v)), y.pixelRatio = d, v.setAttribute("data-pixel-ratio", d), v.width = y.width * d, v.height = y.height * d, v.style.width = y.width + "px", v.style.height = y.height + "px";
2251
+ }, e.setSize = function(g, d, y) {
2252
+ g.options.width = d, g.options.height = y, g.bounds.max.x = g.bounds.min.x + d, g.bounds.max.y = g.bounds.min.y + y, g.options.pixelRatio !== 1 ? e.setPixelRatio(g, g.options.pixelRatio) : (g.canvas.width = d, g.canvas.height = y);
2253
+ }, e.lookAt = function(g, d, y, v) {
2254
+ v = typeof v < "u" ? v : !0, d = a.isArray(d) ? d : [d], y = y || {
2255
2255
  x: 0,
2256
2256
  y: 0
2257
2257
  };
@@ -2264,8 +2264,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2264
2264
  x: -1 / 0,
2265
2265
  y: -1 / 0
2266
2266
  }
2267
- }, S = 0; S < p.length; S += 1) {
2268
- var C = p[S], M = C.bounds ? C.bounds.min : C.min || C.position || C, I = C.bounds ? C.bounds.max : C.max || C.position || C;
2267
+ }, S = 0; S < d.length; S += 1) {
2268
+ var C = d[S], M = C.bounds ? C.bounds.min : C.min || C.position || C, I = C.bounds ? C.bounds.max : C.max || C.position || C;
2269
2269
  M && I && (M.x < w.min.x && (w.min.x = M.x), I.x > w.max.x && (w.max.x = I.x), M.y < w.min.y && (w.min.y = M.y), I.y > w.max.y && (w.max.y = I.y));
2270
2270
  }
2271
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;
@@ -2274,11 +2274,11 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2274
2274
  y: (g.bounds.max.y - g.bounds.min.y) / g.canvas.height
2275
2275
  }), o.setOffset(g.mouse, g.bounds.min));
2276
2276
  }, e.startViewTransform = function(g) {
2277
- var p = g.bounds.max.x - g.bounds.min.x, y = g.bounds.max.y - g.bounds.min.y, v = p / g.options.width, w = y / g.options.height;
2277
+ var d = g.bounds.max.x - g.bounds.min.x, y = g.bounds.max.y - g.bounds.min.y, v = d / g.options.width, w = y / g.options.height;
2278
2278
  g.context.setTransform(g.options.pixelRatio / v, 0, 0, g.options.pixelRatio / w, 0, 0), g.context.translate(-g.bounds.min.x, -g.bounds.min.y);
2279
2279
  }, e.endViewTransform = function(g) {
2280
2280
  g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
2281
- }, e.world = function(g, p) {
2281
+ }, e.world = function(g, d) {
2282
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
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
2284
  for (O = 0; O < R.length; O++) {
@@ -2296,7 +2296,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2296
2296
  } else
2297
2297
  F = L, k = R, g.options.pixelRatio !== 1 && g.context.setTransform(g.options.pixelRatio, 0, 0, g.options.pixelRatio, 0, 0);
2298
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;
2299
- }, e.stats = function(g, p, y) {
2299
+ }, e.stats = function(g, d, y) {
2300
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;
2301
2301
  var k = {
2302
2302
  Part: C,
@@ -2305,32 +2305,32 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2305
2305
  Comp: r.allComposites(w).length,
2306
2306
  Pair: v.pairs.list.length
2307
2307
  };
2308
- p.fillStyle = "#0e0f19", p.fillRect(R, L, M * 5.5, I), p.font = "12px Arial", p.textBaseline = "top", p.textAlign = "right";
2308
+ d.fillStyle = "#0e0f19", d.fillRect(R, L, M * 5.5, I), d.font = "12px Arial", d.textBaseline = "top", d.textAlign = "right";
2309
2309
  for (var F in k) {
2310
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;
2311
+ d.fillStyle = "#aaa", d.fillText(F, R + M, L + 8), d.fillStyle = "#eee", d.fillText(O, R + M, L + 26), R += M;
2312
2312
  }
2313
- }, e.performance = function(g, p) {
2313
+ }, e.performance = function(g, d) {
2314
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) {
2315
+ d.fillStyle = "#0e0f19", d.fillRect(0, 50, H * 5 + V * 6 + 22, Z), e.status(d, Y, K, V, b, w.length, Math.round(X) + " fps", X / e._goodFps, function(z) {
2316
2316
  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) {
2317
+ }), e.status(d, Y + H + V, K, V, b, M.length, D.toFixed(2) + " dt", e._goodDelta / D, function(z) {
2318
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) {
2319
+ }), e.status(d, Y + (H + V) * 2, K, V, b, I.length, L + " upf", Math.pow(a.clamp(W / Q || 1, 0, 1), 4), function(z) {
2320
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) {
2321
+ }), e.status(d, Y + (H + V) * 3, K, V, b, R.length, G.toFixed(2) + " ut", 1 - L * G / e._goodFps, function(z) {
2322
2322
  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) {
2323
+ }), e.status(d, Y + (H + V) * 4, K, V, b, S.length, F.toFixed(2) + " rt", 1 - F / e._goodFps, function(z) {
2324
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) {
2325
+ }), e.status(d, Y + (H + V) * 5, K, V, b, C.length, N.toFixed(2) + " x", N * N * N, function(z) {
2326
2326
  return (C[z] / w[z] / N || 0) - 1;
2327
2327
  });
2328
- }, e.status = function(g, p, y, v, w, S, C, M, I) {
2329
- 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));
2330
- for (var R = 0; R < v; R += 1) g.lineTo(p + R, y + 7 - (R < S ? w * a.clamp(0.4 * I(R), -2, 2) : 0));
2331
- g.stroke(), g.fillStyle = "hsl(" + a.clamp(25 + 95 * M, 0, 120) + ",100%,60%)", g.fillRect(p, y - 7, 4, 4), g.font = "12px Arial", g.textBaseline = "middle", g.textAlign = "right", g.fillStyle = "#eee", g.fillText(C, p + v, y - 5);
2332
- }, e.constraints = function(g, p) {
2333
- for (var y = p, v = 0; v < g.length; v++) {
2328
+ }, e.status = function(g, d, y, v, w, S, C, M, I) {
2329
+ g.strokeStyle = "#888", g.fillStyle = "#444", g.lineWidth = 1, g.fillRect(d, y + 7, v, 1), g.beginPath(), g.moveTo(d, y + 7 - w * a.clamp(0.4 * I(0), -2, 2));
2330
+ for (var R = 0; R < v; R += 1) g.lineTo(d + R, y + 7 - (R < S ? w * a.clamp(0.4 * I(R), -2, 2) : 0));
2331
+ g.stroke(), g.fillStyle = "hsl(" + a.clamp(25 + 95 * M, 0, 120) + ",100%,60%)", g.fillRect(d, y - 7, 4, 4), g.font = "12px Arial", g.textBaseline = "middle", g.textAlign = "right", g.fillStyle = "#eee", g.fillText(C, d + v, y - 5);
2332
+ }, e.constraints = function(g, d) {
2333
+ for (var y = d, v = 0; v < g.length; v++) {
2334
2334
  var w = g[v];
2335
2335
  if (!(!w.render.visible || !w.pointA || !w.pointB)) {
2336
2336
  var S = w.bodyA, C = w.bodyB, M, I;
@@ -2345,12 +2345,12 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2345
2345
  w.render.lineWidth && (y.lineWidth = w.render.lineWidth, y.strokeStyle = w.render.strokeStyle, y.stroke()), w.render.anchors && (y.fillStyle = w.render.strokeStyle, y.beginPath(), y.arc(M.x, M.y, 3, 0, 2 * Math.PI), y.arc(I.x, I.y, 3, 0, 2 * Math.PI), y.closePath(), y.fill());
2346
2346
  }
2347
2347
  }
2348
- }, e.bodies = function(g, p, y) {
2348
+ }, e.bodies = function(g, d, y) {
2349
2349
  var v = y;
2350
2350
  g.engine;
2351
2351
  var w = g.options, S = w.showInternalEdges || !w.wireframes, C, M, I, R;
2352
- for (I = 0; I < p.length; I++)
2353
- if (C = p[I], !!C.render.visible) {
2352
+ for (I = 0; I < d.length; I++)
2353
+ if (C = d[I], !!C.render.visible) {
2354
2354
  for (R = C.parts.length > 1 ? 1 : 0; R < C.parts.length; R++)
2355
2355
  if (M = C.parts[R], !!M.render.visible) {
2356
2356
  if (w.showSleeping && C.isSleeping ? v.globalAlpha = 0.5 * M.render.opacity : M.render.opacity !== 1 && (v.globalAlpha = M.render.opacity), M.render.sprite && M.render.sprite.texture && !w.wireframes) {
@@ -2370,54 +2370,54 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2370
2370
  v.globalAlpha = 1;
2371
2371
  }
2372
2372
  }
2373
- }, e.bodyWireframes = function(g, p, y) {
2373
+ }, e.bodyWireframes = function(g, d, y) {
2374
2374
  var v = y, w = g.options.showInternalEdges, S, C, M, I, R;
2375
- for (v.beginPath(), M = 0; M < p.length; M++)
2376
- if (S = p[M], !!S.render.visible)
2375
+ for (v.beginPath(), M = 0; M < d.length; M++)
2376
+ if (S = d[M], !!S.render.visible)
2377
2377
  for (R = S.parts.length > 1 ? 1 : 0; R < S.parts.length; R++) {
2378
2378
  for (C = S.parts[R], v.moveTo(C.vertices[0].x, C.vertices[0].y), I = 1; I < C.vertices.length; I++)
2379
2379
  !C.vertices[I - 1].isInternal || w ? v.lineTo(C.vertices[I].x, C.vertices[I].y) : v.moveTo(C.vertices[I].x, C.vertices[I].y), C.vertices[I].isInternal && !w && v.moveTo(C.vertices[(I + 1) % C.vertices.length].x, C.vertices[(I + 1) % C.vertices.length].y);
2380
2380
  v.lineTo(C.vertices[0].x, C.vertices[0].y);
2381
2381
  }
2382
2382
  v.lineWidth = 1, v.strokeStyle = g.options.wireframeStrokeStyle, v.stroke();
2383
- }, e.bodyConvexHulls = function(g, p, y) {
2383
+ }, e.bodyConvexHulls = function(g, d, y) {
2384
2384
  var v = y, w, S, C;
2385
- for (v.beginPath(), S = 0; S < p.length; S++)
2386
- if (w = p[S], !(!w.render.visible || w.parts.length === 1)) {
2385
+ for (v.beginPath(), S = 0; S < d.length; S++)
2386
+ if (w = d[S], !(!w.render.visible || w.parts.length === 1)) {
2387
2387
  for (v.moveTo(w.vertices[0].x, w.vertices[0].y), C = 1; C < w.vertices.length; C++) v.lineTo(w.vertices[C].x, w.vertices[C].y);
2388
2388
  v.lineTo(w.vertices[0].x, w.vertices[0].y);
2389
2389
  }
2390
2390
  v.lineWidth = 1, v.strokeStyle = "rgba(255,255,255,0.2)", v.stroke();
2391
- }, e.vertexNumbers = function(g, p, y) {
2391
+ }, e.vertexNumbers = function(g, d, y) {
2392
2392
  var v = y, w, S, C;
2393
- for (w = 0; w < p.length; w++) {
2394
- var M = p[w].parts;
2393
+ for (w = 0; w < d.length; w++) {
2394
+ var M = d[w].parts;
2395
2395
  for (C = M.length > 1 ? 1 : 0; C < M.length; C++) {
2396
2396
  var I = M[C];
2397
2397
  for (S = 0; S < I.vertices.length; S++)
2398
2398
  v.fillStyle = "rgba(255,255,255,0.2)", v.fillText(w + "_" + S, I.position.x + (I.vertices[S].x - I.position.x) * 0.8, I.position.y + (I.vertices[S].y - I.position.y) * 0.8);
2399
2399
  }
2400
2400
  }
2401
- }, e.mousePosition = function(g, p, y) {
2401
+ }, e.mousePosition = function(g, d, y) {
2402
2402
  var v = y;
2403
- v.fillStyle = "rgba(255,255,255,0.8)", v.fillText(p.position.x + " " + p.position.y, p.position.x + 5, p.position.y - 5);
2404
- }, e.bodyBounds = function(g, p, y) {
2403
+ v.fillStyle = "rgba(255,255,255,0.8)", v.fillText(d.position.x + " " + d.position.y, d.position.x + 5, d.position.y - 5);
2404
+ }, e.bodyBounds = function(g, d, y) {
2405
2405
  var v = y;
2406
2406
  g.engine;
2407
2407
  var w = g.options;
2408
2408
  v.beginPath();
2409
- for (var S = 0; S < p.length; S++) if (p[S].render.visible)
2410
- for (var C = p[S].parts, M = C.length > 1 ? 1 : 0; M < C.length; M++) {
2409
+ for (var S = 0; S < d.length; S++) if (d[S].render.visible)
2410
+ for (var C = d[S].parts, M = C.length > 1 ? 1 : 0; M < C.length; M++) {
2411
2411
  var I = C[M];
2412
2412
  v.rect(I.bounds.min.x, I.bounds.min.y, I.bounds.max.x - I.bounds.min.x, I.bounds.max.y - I.bounds.min.y);
2413
2413
  }
2414
2414
  w.wireframes ? v.strokeStyle = "rgba(255,255,255,0.08)" : v.strokeStyle = "rgba(0,0,0,0.1)", v.lineWidth = 1, v.stroke();
2415
- }, e.bodyAxes = function(g, p, y) {
2415
+ }, e.bodyAxes = function(g, d, y) {
2416
2416
  var v = y;
2417
2417
  g.engine;
2418
2418
  var w = g.options, S, C, M, I;
2419
- for (v.beginPath(), C = 0; C < p.length; C++) {
2420
- var R = p[C], L = R.parts;
2419
+ for (v.beginPath(), C = 0; C < d.length; C++) {
2420
+ var R = d[C], L = R.parts;
2421
2421
  if (R.render.visible)
2422
2422
  if (w.showAxes) for (M = L.length > 1 ? 1 : 0; M < L.length; M++)
2423
2423
  for (S = L[M], I = 0; I < S.axes.length; I++) {
@@ -2429,109 +2429,109 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2429
2429
  v.moveTo(S.position.x, S.position.y), v.lineTo((S.vertices[0].x + S.vertices[S.vertices.length - 1].x) / 2, (S.vertices[0].y + S.vertices[S.vertices.length - 1].y) / 2);
2430
2430
  }
2431
2431
  w.wireframes ? (v.strokeStyle = "indianred", v.lineWidth = 1) : (v.strokeStyle = "rgba(255, 255, 255, 0.4)", v.globalCompositeOperation = "overlay", v.lineWidth = 2), v.stroke(), v.globalCompositeOperation = "source-over";
2432
- }, e.bodyPositions = function(g, p, y) {
2432
+ }, e.bodyPositions = function(g, d, y) {
2433
2433
  var v = y;
2434
2434
  g.engine;
2435
2435
  var w = g.options, S, C, M, I;
2436
- for (v.beginPath(), M = 0; M < p.length; M++)
2437
- if (S = p[M], !!S.render.visible)
2436
+ for (v.beginPath(), M = 0; M < d.length; M++)
2437
+ if (S = d[M], !!S.render.visible)
2438
2438
  for (I = 0; I < S.parts.length; I++)
2439
2439
  C = S.parts[I], v.arc(C.position.x, C.position.y, 3, 0, 2 * Math.PI, !1), v.closePath();
2440
- for (w.wireframes ? v.fillStyle = "indianred" : v.fillStyle = "rgba(0,0,0,0.5)", v.fill(), v.beginPath(), M = 0; M < p.length; M++)
2441
- S = p[M], S.render.visible && (v.arc(S.positionPrev.x, S.positionPrev.y, 2, 0, 2 * Math.PI, !1), v.closePath());
2440
+ for (w.wireframes ? v.fillStyle = "indianred" : v.fillStyle = "rgba(0,0,0,0.5)", v.fill(), v.beginPath(), M = 0; M < d.length; M++)
2441
+ S = d[M], S.render.visible && (v.arc(S.positionPrev.x, S.positionPrev.y, 2, 0, 2 * Math.PI, !1), v.closePath());
2442
2442
  v.fillStyle = "rgba(255,165,0,0.8)", v.fill();
2443
- }, e.bodyVelocity = function(g, p, y) {
2443
+ }, e.bodyVelocity = function(g, d, y) {
2444
2444
  var v = y;
2445
2445
  v.beginPath();
2446
- for (var w = 0; w < p.length; w++) {
2447
- var S = p[w];
2446
+ for (var w = 0; w < d.length; w++) {
2447
+ var S = d[w];
2448
2448
  if (S.render.visible) {
2449
2449
  var C = l.getVelocity(S);
2450
2450
  v.moveTo(S.position.x, S.position.y), v.lineTo(S.position.x + C.x, S.position.y + C.y);
2451
2451
  }
2452
2452
  }
2453
2453
  v.lineWidth = 3, v.strokeStyle = "cornflowerblue", v.stroke();
2454
- }, e.bodyIds = function(g, p, y) {
2454
+ }, e.bodyIds = function(g, d, y) {
2455
2455
  var v = y, w, S;
2456
- for (w = 0; w < p.length; w++)
2457
- if (p[w].render.visible) {
2458
- var C = p[w].parts;
2456
+ for (w = 0; w < d.length; w++)
2457
+ if (d[w].render.visible) {
2458
+ var C = d[w].parts;
2459
2459
  for (S = C.length > 1 ? 1 : 0; S < C.length; S++) {
2460
2460
  var M = C[S];
2461
2461
  v.font = "12px Arial", v.fillStyle = "rgba(255,255,255,0.5)", v.fillText(M.id, M.position.x + 10, M.position.y - 10);
2462
2462
  }
2463
2463
  }
2464
- }, e.collisions = function(g, p, y) {
2464
+ }, e.collisions = function(g, d, y) {
2465
2465
  var v = y, w = g.options, S, C, M, I;
2466
- for (v.beginPath(), M = 0; M < p.length; M++)
2467
- if (S = p[M], !!S.isActive)
2466
+ for (v.beginPath(), M = 0; M < d.length; M++)
2467
+ if (S = d[M], !!S.isActive)
2468
2468
  for (C = S.collision, I = 0; I < S.contactCount; I++) {
2469
2469
  var R = S.contacts[I].vertex;
2470
2470
  v.rect(R.x - 1.5, R.y - 1.5, 3.5, 3.5);
2471
2471
  }
2472
- 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
- if (S = p[M], !!S.isActive && (C = S.collision, S.contactCount > 0)) {
2472
+ for (w.wireframes ? v.fillStyle = "rgba(255,255,255,0.7)" : v.fillStyle = "orange", v.fill(), v.beginPath(), M = 0; M < d.length; M++)
2473
+ if (S = d[M], !!S.isActive && (C = S.collision, S.contactCount > 0)) {
2474
2474
  var L = S.contacts[0].vertex.x, D = S.contacts[0].vertex.y;
2475
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);
2476
2476
  }
2477
2477
  w.wireframes ? v.strokeStyle = "rgba(255,165,0,0.7)" : v.strokeStyle = "orange", v.lineWidth = 1, v.stroke();
2478
- }, e.separations = function(g, p, y) {
2478
+ }, e.separations = function(g, d, y) {
2479
2479
  var v = y, w = g.options, S, C, M, I, R;
2480
- for (v.beginPath(), R = 0; R < p.length; R++)
2481
- if (S = p[R], !!S.isActive) {
2480
+ for (v.beginPath(), R = 0; R < d.length; R++)
2481
+ if (S = d[R], !!S.isActive) {
2482
2482
  C = S.collision, M = C.bodyA, I = C.bodyB;
2483
2483
  var L = 1;
2484
2484
  !I.isStatic && !M.isStatic && (L = 0.5), I.isStatic && (L = 0), v.moveTo(I.position.x, I.position.y), v.lineTo(I.position.x - C.penetration.x * L, I.position.y - C.penetration.y * L), L = 1, !I.isStatic && !M.isStatic && (L = 0.5), M.isStatic && (L = 0), v.moveTo(M.position.x, M.position.y), v.lineTo(M.position.x + C.penetration.x * L, M.position.y + C.penetration.y * L);
2485
2485
  }
2486
2486
  w.wireframes ? v.strokeStyle = "rgba(255,165,0,0.5)" : v.strokeStyle = "orange", v.stroke();
2487
- }, e.inspector = function(g, p) {
2487
+ }, e.inspector = function(g, d) {
2488
2488
  g.engine;
2489
2489
  var y = g.selected, v = g.render, w = v.options, S;
2490
2490
  if (w.hasBounds) {
2491
2491
  var C = v.bounds.max.x - v.bounds.min.x, M = v.bounds.max.y - v.bounds.min.y, I = C / v.options.width, R = M / v.options.height;
2492
- p.scale(1 / I, 1 / R), p.translate(-v.bounds.min.x, -v.bounds.min.y);
2492
+ d.scale(1 / I, 1 / R), d.translate(-v.bounds.min.x, -v.bounds.min.y);
2493
2493
  }
2494
2494
  for (var L = 0; L < y.length; L++) {
2495
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) {
2496
+ switch (d.translate(0.5, 0.5), d.lineWidth = 1, d.strokeStyle = "rgba(255,165,0,0.9)", d.setLineDash([1, 2]), D.type) {
2497
2497
  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();
2498
+ S = D.bounds, d.beginPath(), d.rect(Math.floor(S.min.x - 3), Math.floor(S.min.y - 3), Math.floor(S.max.x - S.min.x + 6), Math.floor(S.max.y - S.min.y + 6)), d.closePath(), d.stroke();
2499
2499
  break;
2500
2500
  case "constraint":
2501
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();
2502
+ D.bodyA && (k = D.pointB), d.beginPath(), d.arc(k.x, k.y, 10, 0, 2 * Math.PI), d.closePath(), d.stroke();
2503
2503
  break;
2504
2504
  }
2505
- p.setLineDash([]), p.translate(-0.5, -0.5);
2505
+ d.setLineDash([]), d.translate(-0.5, -0.5);
2506
2506
  }
2507
- g.selectStart !== null && (p.translate(0.5, 0.5), p.lineWidth = 1, p.strokeStyle = "rgba(255,165,0,0.6)", p.fillStyle = "rgba(255,165,0,0.1)", S = g.selectBounds, p.beginPath(), p.rect(Math.floor(S.min.x), Math.floor(S.min.y), Math.floor(S.max.x - S.min.x), Math.floor(S.max.y - S.min.y)), p.closePath(), p.stroke(), p.fill(), p.translate(-0.5, -0.5)), w.hasBounds && p.setTransform(1, 0, 0, 1, 0, 0);
2507
+ g.selectStart !== null && (d.translate(0.5, 0.5), d.lineWidth = 1, d.strokeStyle = "rgba(255,165,0,0.6)", d.fillStyle = "rgba(255,165,0,0.1)", S = g.selectBounds, d.beginPath(), d.rect(Math.floor(S.min.x), Math.floor(S.min.y), Math.floor(S.max.x - S.min.x), Math.floor(S.max.y - S.min.y)), d.closePath(), d.stroke(), d.fill(), d.translate(-0.5, -0.5)), w.hasBounds && d.setTransform(1, 0, 0, 1, 0, 0);
2508
2508
  };
2509
- var s = function(g, p) {
2509
+ var s = function(g, d) {
2510
2510
  var y = g.engine, v = g.timing, w = v.historySize, S = y.timing.timestamp;
2511
- 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);
2511
+ v.delta = d - v.lastTime || e._goodDelta, v.lastTime = d, v.timestampElapsed = S - v.lastTimestamp || 0, v.lastTimestamp = S, v.deltaHistory.unshift(v.delta), v.deltaHistory.length = Math.min(v.deltaHistory.length, w), v.engineDeltaHistory.unshift(y.timing.lastDelta), v.engineDeltaHistory.length = Math.min(v.engineDeltaHistory.length, w), v.timestampElapsedHistory.unshift(v.timestampElapsed), v.timestampElapsedHistory.length = Math.min(v.timestampElapsedHistory.length, w), v.engineUpdatesHistory.unshift(y.timing.lastUpdatesPerFrame), v.engineUpdatesHistory.length = Math.min(v.engineUpdatesHistory.length, w), v.engineElapsedHistory.unshift(y.timing.lastElapsed), v.engineElapsedHistory.length = Math.min(v.engineElapsedHistory.length, w), v.elapsedHistory.unshift(v.lastElapsed), v.elapsedHistory.length = Math.min(v.elapsedHistory.length, w);
2512
2512
  }, f = function(g) {
2513
- for (var p = 0, y = 0; y < g.length; y += 1) p += g[y];
2514
- return p / g.length || 0;
2515
- }, m = function(g, p) {
2513
+ for (var d = 0, y = 0; y < g.length; y += 1) d += g[y];
2514
+ return d / g.length || 0;
2515
+ }, m = function(g, d) {
2516
2516
  var y = document.createElement("canvas");
2517
- return y.width = g, y.height = p, y.oncontextmenu = function() {
2517
+ return y.width = g, y.height = d, y.oncontextmenu = function() {
2518
2518
  return !1;
2519
2519
  }, y.onselectstart = function() {
2520
2520
  return !1;
2521
2521
  }, y;
2522
2522
  }, x = function(g) {
2523
- var p = g.getContext("2d");
2524
- return (window.devicePixelRatio || 1) / (p.webkitBackingStorePixelRatio || p.mozBackingStorePixelRatio || p.msBackingStorePixelRatio || p.oBackingStorePixelRatio || p.backingStorePixelRatio || 1);
2525
- }, P = function(g, p) {
2526
- var y = g.textures[p];
2527
- return y || (y = g.textures[p] = new Image(), y.src = p, y);
2528
- }, T = function(g, p) {
2529
- var y = p;
2530
- /(jpg|gif|png)$/.test(p) && (y = "url(" + p + ")"), g.canvas.style.background = y, g.canvas.style.backgroundSize = "contain", g.currentBackground = p;
2523
+ var d = g.getContext("2d");
2524
+ return (window.devicePixelRatio || 1) / (d.webkitBackingStorePixelRatio || d.mozBackingStorePixelRatio || d.msBackingStorePixelRatio || d.oBackingStorePixelRatio || d.backingStorePixelRatio || 1);
2525
+ }, P = function(g, d) {
2526
+ var y = g.textures[d];
2527
+ return y || (y = g.textures[d] = new Image(), y.src = d, y);
2528
+ }, T = function(g, d) {
2529
+ var y = d;
2530
+ /(jpg|gif|png)$/.test(d) && (y = "url(" + d + ")"), g.canvas.style.background = y, g.canvas.style.backgroundSize = "contain", g.currentBackground = d;
2531
2531
  };
2532
2532
  })();
2533
2533
  }),
2534
- (function(A, B, c) {
2534
+ (function(A, E, c) {
2535
2535
  var e = {};
2536
2536
  A.exports = e;
2537
2537
  var l = c(5), a = c(17), r = c(0);
@@ -2569,7 +2569,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2569
2569
  l.trigger(n, "beforeTick", P), l.trigger(n, "tick", P);
2570
2570
  for (var T = r.now(); i > 0 && n.timeBuffer >= i * e._timeBufferMargin; ) {
2571
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;
2572
+ var g = r.now() - t, d = r.now() - T, y = g + e._elapsedNextEstimate * d / s;
2573
2573
  if (s >= x || y > n.maxFrameTime) {
2574
2574
  n.lastUpdatesDeferred = Math.round(Math.max(0, n.timeBuffer / i - e._timeBufferMargin));
2575
2575
  break;
@@ -2592,7 +2592,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2592
2592
  };
2593
2593
  })();
2594
2594
  }),
2595
- (function(A, B, c) {
2595
+ (function(A, E, c) {
2596
2596
  var e = {};
2597
2597
  A.exports = e;
2598
2598
  var l = c(8), a = c(0).deprecated;
@@ -2602,14 +2602,14 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2602
2602
  }, a(e, "collides", "SAT.collides ➤ replaced by Collision.collides");
2603
2603
  })();
2604
2604
  }),
2605
- (function(A, B, c) {
2605
+ (function(A, E, c) {
2606
2606
  var e = {};
2607
2607
  A.exports = e, c(1);
2608
2608
  var l = c(0);
2609
2609
  (function() {
2610
2610
  e.pathToVertices = function(a, r) {
2611
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;
2612
+ var h, n, u, o, t, i, s, f, m, x, P = [], T, g, d = 0, y = 0, v = 0;
2613
2613
  r = r || 15;
2614
2614
  var w = function(C, M, I) {
2615
2615
  var R = I % 2 === 1 && I > 1;
@@ -2644,8 +2644,8 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2644
2644
  }
2645
2645
  };
2646
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) {
2647
+ for (s = i.concat(); d < u; ) {
2648
+ if (x = a.getPathSegAtLength(d), t = i[x], t != f) {
2649
2649
  for (; s.length && s[0] != t; ) S(s.shift());
2650
2650
  f = t;
2651
2651
  }
@@ -2655,10 +2655,10 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2655
2655
  case "S":
2656
2656
  case "Q":
2657
2657
  case "A":
2658
- o = a.getPointAtLength(p), w(o.x, o.y, 0);
2658
+ o = a.getPointAtLength(d), w(o.x, o.y, 0);
2659
2659
  break;
2660
2660
  }
2661
- p += r;
2661
+ d += r;
2662
2662
  }
2663
2663
  for (h = 0, n = s.length; h < n; ++h) S(s[h]);
2664
2664
  return P;
@@ -2706,7 +2706,7 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2706
2706
  };
2707
2707
  })();
2708
2708
  }),
2709
- (function(A, B, c) {
2709
+ (function(A, E, c) {
2710
2710
  var e = {};
2711
2711
  A.exports = e;
2712
2712
  var l = c(6);
@@ -2717,54 +2717,54 @@ var be = /* @__PURE__ */ Ce(((d, E) => {
2717
2717
  ]);
2718
2718
  });
2719
2719
  })), U = be();
2720
- function Oe(d, E, A) {
2721
- return d < E ? E : d > A ? A : d;
2720
+ function Oe(p, B, A) {
2721
+ return p < B ? B : p > A ? A : p;
2722
2722
  }
2723
- function J(d) {
2724
- const E = d.plugin.ballId;
2725
- return typeof E == "number" ? E : d.id;
2723
+ function J(p) {
2724
+ const B = p.plugin.ballId;
2725
+ return typeof B == "number" ? B : p.id;
2726
2726
  }
2727
- function Ue(d, E, A, B) {
2728
- return Oe(Math.floor((d - E) / A), 0, B - 1);
2727
+ function Ue(p, B, A, E) {
2728
+ return Oe(Math.floor((p - B) / A), 0, E - 1);
2729
2729
  }
2730
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) {
2731
+ function pe(p, B) {
2732
2732
  return {
2733
- x: d,
2734
- y: E,
2733
+ x: p,
2734
+ y: B,
2735
2735
  stuckMs: 0,
2736
2736
  kickCooldownMs: 0,
2737
2737
  kickCount: 0,
2738
- anchorY: E,
2738
+ anchorY: B,
2739
2739
  anchorAgeMs: 0,
2740
2740
  aliveMs: 0
2741
2741
  };
2742
2742
  }
2743
2743
  var Ze = class {
2744
2744
  tracker = /* @__PURE__ */ new Map();
2745
- track(d, E, A) {
2746
- this.tracker.set(d, pe(E, A));
2745
+ track(p, B, A) {
2746
+ this.tracker.set(p, pe(B, A));
2747
2747
  }
2748
- untrack(d) {
2749
- this.tracker.delete(d);
2748
+ untrack(p) {
2749
+ this.tracker.delete(p);
2750
2750
  }
2751
2751
  clear() {
2752
2752
  this.tracker.clear();
2753
2753
  }
2754
- process(d, E, A) {
2755
- const B = [], c = /* @__PURE__ */ new Set(), e = [];
2756
- for (const l of E) {
2754
+ process(p, B, A) {
2755
+ const E = [], c = /* @__PURE__ */ new Set(), e = [];
2756
+ for (const l of B) {
2757
2757
  const a = J(l);
2758
2758
  c.add(a);
2759
- const r = this.tracker.get(a) ?? pe(l.position.x, l.position.y), h = r.aliveMs + d;
2759
+ const r = this.tracker.get(a) ?? pe(l.position.x, l.position.y), h = r.aliveMs + p;
2760
2760
  if (h >= $e || r.kickCount >= Xe) {
2761
- B.push(l), this.tracker.delete(a);
2761
+ E.push(l), this.tracker.delete(a);
2762
2762
  continue;
2763
2763
  }
2764
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;
2765
+ let f = r.anchorY, m = r.anchorAgeMs + p;
2766
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);
2767
+ const x = s && (i < We && o < Ne || m > Ye) ? r.stuckMs + p : Math.max(0, r.stuckMs - p * 2), P = Math.max(0, r.kickCooldownMs - p);
2768
2768
  this.tracker.set(a, {
2769
2769
  x: l.position.x,
2770
2770
  y: l.position.y,
@@ -2782,16 +2782,16 @@ var Ze = class {
2782
2782
  }
2783
2783
  this.applyKicks(e, A);
2784
2784
  for (const l of this.tracker.keys()) c.has(l) || this.tracker.delete(l);
2785
- return B;
2785
+ return E;
2786
2786
  }
2787
- applyKicks(d, E) {
2788
- 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);
2787
+ applyKicks(p, B) {
2788
+ if (p.length === 0) return;
2789
+ p.sort((E, c) => Math.abs(c.ball.position.y - E.ball.position.y) > 0.1 ? c.ball.position.y - E.ball.position.y : c.stuckMs - E.stuckMs);
2790
+ const A = Math.min(ze, p.length);
2791
+ for (let E = 0; E < A; E++) {
2792
+ const { ball: c, id: e } = p[E], l = this.tracker.get(e);
2793
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;
2794
+ const a = c.velocity, r = Math.abs(c.position.x - B.center) / B.halfWidth < Qe ? Math.random() < 0.5 ? 1 : -1 : c.position.x < B.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
2795
  U.Body.setVelocity(c, {
2796
2796
  x: a.x + h,
2797
2797
  y: Math.max(a.y + n, n)
@@ -2809,21 +2809,21 @@ var Ze = class {
2809
2809
  }
2810
2810
  }
2811
2811
  };
2812
- function Je(d) {
2813
- const E = Math.max(0, Math.min(1, d)) * 0.5, A = E ** 1.5;
2812
+ function Je(p) {
2813
+ const B = Math.max(0, Math.min(1, p)) * 0.5, A = B ** 1.5;
2814
2814
  return {
2815
2815
  windStrength: Math.min(A * 8e-7, 3e-7),
2816
2816
  collisionNudge: A * 0.1,
2817
- spawnSigmaRatio: E > 0 ? 0.04 - A * 0.038 : 0
2817
+ spawnSigmaRatio: B > 0 ? 0.04 - A * 0.038 : 0
2818
2818
  };
2819
2819
  }
2820
2820
  var je = 0.4;
2821
- function qe(d, E, A) {
2821
+ function qe(p, B, A) {
2822
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, {
2823
+ for (const E of p) {
2824
+ if (Math.sqrt(E.velocity.x * E.velocity.x + E.velocity.y * E.velocity.y) < je) continue;
2825
+ const c = E.position.x - B;
2826
+ U.Body.applyForce(E, E.position, {
2827
2827
  x: -A * c,
2828
2828
  y: 0
2829
2829
  });
@@ -2831,13 +2831,13 @@ function qe(d, E, A) {
2831
2831
  }
2832
2832
  var te = "plinkit-ball";
2833
2833
  function _e() {
2834
- const d = Math.random(), E = Math.random();
2835
- return Math.sqrt(-2 * Math.log(d || 1e-15)) * Math.cos(2 * Math.PI * E);
2834
+ const p = Math.random(), B = Math.random();
2835
+ return Math.sqrt(-2 * Math.log(p || 1e-15)) * Math.cos(2 * Math.PI * B);
2836
2836
  }
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, {
2837
+ function et(p, B) {
2838
+ const A = Math.max(p.radius + 8, p.height * 0.06);
2839
+ let E;
2840
+ return B && B > 0 ? E = _e() * p.width * B : E = (Math.random() - 0.5) * p.width * 0.08, U.Bodies.circle(p.width * 0.5 + E, A, p.radius, {
2841
2841
  label: te,
2842
2842
  restitution: 0.65,
2843
2843
  frictionAir: 1e-3,
@@ -2859,22 +2859,22 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
2859
2859
  antiStuck = new Ze();
2860
2860
  dist;
2861
2861
  removeCollisionNudge = null;
2862
- constructor(d) {
2862
+ constructor(p) {
2863
2863
  this.engine = U.Engine.create({ gravity: {
2864
2864
  x: 0,
2865
- y: d.gravityY,
2865
+ y: p.gravityY,
2866
2866
  scale: 1e-3
2867
- } }), this.config = d, this.dist = Je(d.houseEdge ?? 0), this.rebuildStaticBodies(d.width, d.height);
2868
- const E = this.dist.collisionNudge;
2869
- if (E > 0) {
2870
- const A = (B) => {
2867
+ } }), this.config = p, this.dist = Je(p.houseEdge ?? 0), this.rebuildStaticBodies(p.width, p.height);
2868
+ const B = this.dist.collisionNudge;
2869
+ if (B > 0) {
2870
+ const A = (E) => {
2871
2871
  const c = this.center, e = this.config.width * 0.5;
2872
- for (const l of B.pairs) {
2872
+ for (const l of E.pairs) {
2873
2873
  const a = l.bodyA.label === "plinkit-ball" ? l.bodyA : l.bodyB.label === "plinkit-ball" ? l.bodyB : null;
2874
2874
  if (!a || a.plugin.settled || !(l.bodyA.label === se || l.bodyB.label === se || l.bodyA.label === re || l.bodyB.label === re)) continue;
2875
2875
  const r = (a.position.x - c) / e;
2876
2876
  U.Body.setVelocity(a, {
2877
- x: a.velocity.x - E * r,
2877
+ x: a.velocity.x - B * r,
2878
2878
  y: a.velocity.y
2879
2879
  });
2880
2880
  }
@@ -2882,59 +2882,65 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
2882
2882
  U.Events.on(this.engine, "collisionEnd", A), this.removeCollisionNudge = () => U.Events.off(this.engine, "collisionEnd", A);
2883
2883
  }
2884
2884
  }
2885
- resize(d, E) {
2885
+ resize(p, B) {
2886
2886
  this.config = {
2887
2887
  ...this.config,
2888
- width: d,
2889
- height: E
2890
- }, this.rebuildStaticBodies(d, E);
2888
+ width: p,
2889
+ height: B
2890
+ }, this.rebuildStaticBodies(p, B);
2891
+ }
2892
+ setBallCost(p) {
2893
+ this.config = {
2894
+ ...this.config,
2895
+ ballCost: p
2896
+ };
2891
2897
  }
2892
2898
  spawnBall() {
2893
- const d = et({
2899
+ const p = et({
2894
2900
  width: this.config.width,
2895
2901
  height: this.config.height,
2896
2902
  radius: this.config.ballRadius
2897
2903
  }, 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);
2904
+ p.plugin.ballId = this.nextBallId, p.plugin.wager = this.config.ballCost, this.nextBallId += 1, this.antiStuck.track(J(p), p.position.x, p.position.y), U.World.add(this.engine.world, p);
2899
2905
  }
2900
2906
  canSpawnBall() {
2901
- const d = this.config.height * tt;
2902
- 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))
2907
+ const p = this.config.height * tt;
2908
+ let B = 0;
2909
+ const A = U.Composite.allBodies(this.engine.world).filter((E) => E.label === te);
2910
+ for (const E of A)
2911
+ if (!E.plugin.settled && E.position.y <= p && (B += 1, B >= it))
2906
2912
  return !1;
2907
2913
  return !0;
2908
2914
  }
2909
- 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);
2915
+ step(p) {
2916
+ U.Engine.update(this.engine, p);
2917
+ const B = U.Composite.allBodies(this.engine.world).filter((e) => e.label === te), A = B.filter((e) => !e.plugin.settled);
2912
2918
  qe(A, this.center, this.dist.windStrength);
2913
- const B = this.antiStuck.process(d, A, {
2919
+ const E = this.antiStuck.process(p, A, {
2914
2920
  center: this.center,
2915
2921
  halfWidth: this.config.width * 0.5,
2916
2922
  worldHeight: this.config.height
2917
- }).map((e) => this.settleBall(e)), c = this.cleanupBalls(E);
2918
- return B.length > 0 ? [...B, ...c] : c;
2923
+ }).map((e) => this.settleBall(e)), c = this.cleanupBalls(B);
2924
+ return E.length > 0 ? [...E, ...c] : c;
2919
2925
  }
2920
2926
  snapshot() {
2921
- const d = this.config.layout.mainPegs.radius;
2927
+ const p = this.config.layout.mainPegs.radius;
2922
2928
  return {
2923
- pegs: this.pegs.map((E) => ({
2924
- x: E.position.x,
2925
- y: E.position.y,
2926
- radius: E.circleRadius ?? d
2929
+ pegs: this.pegs.map((B) => ({
2930
+ x: B.position.x,
2931
+ y: B.position.y,
2932
+ radius: B.circleRadius ?? p
2927
2933
  })),
2928
- guidePegs: this.guidePegs.map((E) => ({
2929
- x: E.position.x,
2930
- y: E.position.y,
2931
- radius: E.circleRadius ?? d
2934
+ guidePegs: this.guidePegs.map((B) => ({
2935
+ x: B.position.x,
2936
+ y: B.position.y,
2937
+ radius: B.circleRadius ?? p
2932
2938
  })),
2933
- balls: U.Composite.allBodies(this.engine.world).filter((E) => E.label === te).map((E) => ({
2934
- id: J(E),
2935
- x: E.position.x,
2936
- y: E.position.y,
2937
- radius: E.circleRadius ?? this.config.ballRadius
2939
+ balls: U.Composite.allBodies(this.engine.world).filter((B) => B.label === te).map((B) => ({
2940
+ id: J(B),
2941
+ x: B.position.x,
2942
+ y: B.position.y,
2943
+ radius: B.circleRadius ?? this.config.ballRadius
2938
2944
  })),
2939
2945
  walls: this.getWallRects(),
2940
2946
  buckets: this.buckets
@@ -2943,32 +2949,32 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
2943
2949
  destroy() {
2944
2950
  this.removeCollisionNudge?.(), U.World.clear(this.engine.world, !1), U.Engine.clear(this.engine);
2945
2951
  }
2946
- cleanupBalls(d) {
2947
- const E = [], A = this.config.height + this.config.ballRadius, B = this.getBucketTop();
2948
- for (const c of d) {
2952
+ cleanupBalls(p) {
2953
+ const B = [], A = this.config.height + this.config.ballRadius, E = this.getBucketTop();
2954
+ for (const c of p) {
2949
2955
  if (c.position.y > A) {
2950
2956
  this.antiStuck.untrack(J(c)), U.World.remove(this.engine.world, c);
2951
2957
  continue;
2952
2958
  }
2953
- if (!c.plugin.settled && c.position.y >= B) {
2954
- E.push(this.settleBall(c));
2959
+ if (!c.plugin.settled && c.position.y >= E) {
2960
+ B.push(this.settleBall(c));
2955
2961
  continue;
2956
2962
  }
2957
2963
  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));
2964
+ !c.plugin.settled && c.position.y >= l && B.push(this.settleBall(c));
2959
2965
  }
2960
- return E;
2966
+ return B;
2961
2967
  }
2962
- rebuildStaticBodies(d, E) {
2968
+ rebuildStaticBodies(p, B) {
2963
2969
  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, [
2964
2970
  this.walls.leftWall,
2965
2971
  this.walls.rightWall,
2966
2972
  this.walls.floor
2967
- ]), 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({
2973
+ ]), this.walls = null), this.center = p * 0.5;
2974
+ const A = Math.max(18, p * 0.02), E = p / this.config.multipliers.length, c = this.config.layout.mainPegs, e = Te({
2969
2975
  ...c,
2970
- width: d,
2971
- height: E
2976
+ width: p,
2977
+ height: B
2972
2978
  });
2973
2979
  this.layoutGeometry = e;
2974
2980
  const l = c.radius, a = this.config.layout.edgeGuides.radius;
@@ -2977,15 +2983,15 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
2977
2983
  label: se,
2978
2984
  restitution: 0.3
2979
2985
  })), 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, {
2986
+ const r = this.getBucketTop(), h = U.Bodies.rectangle(-A * 0.5, B * 0.5, A, B * 2, {
2981
2987
  isStatic: !0,
2982
2988
  label: ae,
2983
2989
  restitution: 0.4
2984
- }), n = U.Bodies.rectangle(d + A * 0.5, E * 0.5, A, E * 2, {
2990
+ }), n = U.Bodies.rectangle(p + A * 0.5, B * 0.5, A, B * 2, {
2985
2991
  isStatic: !0,
2986
2992
  label: ae,
2987
2993
  restitution: 0.4
2988
- }), u = U.Bodies.rectangle(d * 0.5, E + A * 0.5, d, A, {
2994
+ }), u = U.Bodies.rectangle(p * 0.5, B + A * 0.5, p, A, {
2989
2995
  isStatic: !0,
2990
2996
  isSensor: !0,
2991
2997
  label: ae
@@ -2998,7 +3004,7 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
2998
3004
  h,
2999
3005
  n,
3000
3006
  u
3001
- ]), this.guidePegs = Ee(e, a, {
3007
+ ]), this.guidePegs = Be(e, a, {
3002
3008
  spread: this.config.layout.edgeGuides.spread,
3003
3009
  yOffset: this.config.layout.edgeGuides.yOffset
3004
3010
  }).map((t) => U.Bodies.circle(t.x, t.y, t.radius, {
@@ -3006,13 +3012,13 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
3006
3012
  label: re,
3007
3013
  restitution: 0.3
3008
3014
  })), U.World.add(this.engine.world, this.pegs), U.World.add(this.engine.world, this.guidePegs);
3009
- const o = E - r;
3015
+ const o = B - r;
3010
3016
  this.buckets = this.config.multipliers.map((t, i) => ({
3011
3017
  index: i,
3012
3018
  multiplier: t,
3013
- x: B * i,
3019
+ x: E * i,
3014
3020
  y: r,
3015
- width: B,
3021
+ width: E,
3016
3022
  height: o
3017
3023
  }));
3018
3024
  }
@@ -3021,26 +3027,26 @@ var se = "plinkit-peg", re = "plinkit-guide", ae = "plinkit-wall", tt = 0.22, it
3021
3027
  this.walls.leftWall,
3022
3028
  this.walls.rightWall,
3023
3029
  this.walls.floor
3024
- ].map((d) => ({
3025
- x: d.position.x,
3026
- y: d.position.y,
3027
- width: d.bounds.max.x - d.bounds.min.x,
3028
- height: d.bounds.max.y - d.bounds.min.y
3030
+ ].map((p) => ({
3031
+ x: p.position.x,
3032
+ y: p.position.y,
3033
+ width: p.bounds.max.x - p.bounds.min.x,
3034
+ height: p.bounds.max.y - p.bounds.min.y
3029
3035
  })) : [];
3030
3036
  }
3031
3037
  getBucketTop() {
3032
- const d = this.config.layout.mainPegs.radius + this.config.ballRadius - 1;
3033
- return this.pegBaseY > 0 ? Math.min(this.config.height - 6, this.pegBaseY + d) : this.config.height * 0.85;
3038
+ const p = this.config.layout.mainPegs.radius + this.config.ballRadius - 1;
3039
+ return this.pegBaseY > 0 ? Math.min(this.config.height - 6, this.pegBaseY + p) : this.config.height * 0.85;
3034
3040
  }
3035
- 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;
3041
+ settleBall(p) {
3042
+ p.plugin.settled = !0, U.Body.set(p, "isSensor", !0);
3043
+ const B = this.layoutGeometry, A = this.config.layout.mainPegs, E = B?.sidePadding ?? A.radius + A.sidePaddingPx, c = B?.baseSpacing ?? (this.config.width - E * 2) / Math.max(A.bottomPegCount - 1, 1), e = Ue(p.position.x, E, c, this.config.multipliers.length), l = this.config.multipliers[e] ?? 0, a = typeof p.plugin.wager == "number" ? p.plugin.wager : this.config.ballCost;
3038
3044
  return {
3039
- ballId: J(d),
3045
+ ballId: J(p),
3040
3046
  bucketIndex: e,
3041
3047
  multiplier: l,
3042
- wager: this.config.ballCost,
3043
- payout: this.config.ballCost * l
3048
+ wager: a,
3049
+ payout: a * l
3044
3050
  };
3045
3051
  }
3046
3052
  }, st = `
@@ -3105,16 +3111,16 @@ void main() {
3105
3111
  ballTexture = null;
3106
3112
  pegTextureReady = !1;
3107
3113
  ballTextureReady = !1;
3108
- constructor(d, E) {
3109
- this.canvas = d;
3110
- const A = d.getContext("webgl2", {
3114
+ constructor(p, B) {
3115
+ this.canvas = p;
3116
+ const A = p.getContext("webgl2", {
3111
3117
  antialias: !0,
3112
3118
  alpha: !0
3113
3119
  });
3114
3120
  if (!A) throw new Error("WebGL2 is not supported by this browser");
3115
3121
  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);
3122
+ const E = de(this.gl, this.gl.VERTEX_SHADER, st), c = de(this.gl, this.gl.FRAGMENT_SHADER, rt);
3123
+ this.program = ft(this.gl, E, c);
3118
3124
  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
3125
  if (e < 0 || !l || !a || !r || !h || !n || !u || !o) throw new Error("Unable to initialize WebGL program locations");
3120
3126
  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);
@@ -3134,26 +3140,26 @@ void main() {
3134
3140
  1,
3135
3141
  1
3136
3142
  ]), this.gl.STATIC_DRAW), this.gl.enable(this.gl.BLEND), this.gl.blendFunc(this.gl.SRC_ALPHA, this.gl.ONE_MINUS_SRC_ALPHA);
3137
- const i = E?.appearance;
3143
+ const i = B?.appearance;
3138
3144
  i?.pegTextureUrl && this.startTextureLoad(i.pegTextureUrl, i.textureCrossOrigin, "peg"), i?.ballTextureUrl && this.startTextureLoad(i.ballTextureUrl, i.textureCrossOrigin, "ball");
3139
3145
  }
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);
3146
+ resize(p, B, A, E = 1) {
3147
+ this.scale = A * E, this.canvas.width = Math.floor(p * A), this.canvas.height = Math.floor(B * A), this.gl.viewport(0, 0, this.canvas.width, this.canvas.height);
3142
3148
  }
3143
- render(d) {
3149
+ render(p) {
3144
3150
  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");
3151
+ for (const B of p.walls) this.drawRect(B, ee(54, 68, 102));
3152
+ for (const B of p.pegs) this.drawCircle(B.x, B.y, B.radius, ee(141, 226, 255), "peg");
3153
+ for (const B of p.guidePegs) this.drawCircle(B.x, B.y, B.radius, ee(255, 90, 120), "peg");
3154
+ for (const B of p.balls) this.drawCircle(B.x, B.y, B.radius, ee(250, 201, 95), "ball");
3149
3155
  }
3150
3156
  destroy() {
3151
3157
  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
3158
  }
3153
- startTextureLoad(d, E, A) {
3154
- lt(d, E).then((B) => {
3159
+ startTextureLoad(p, B, A) {
3160
+ lt(p, B).then((E) => {
3155
3161
  if (this.destroyed) return;
3156
- const c = ot(this.gl, B);
3162
+ const c = ot(this.gl, E);
3157
3163
  if (this.destroyed) {
3158
3164
  this.gl.deleteTexture(c);
3159
3165
  return;
@@ -3162,52 +3168,52 @@ void main() {
3162
3168
  }).catch(() => {
3163
3169
  });
3164
3170
  }
3165
- drawRect(d, E) {
3166
- 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);
3171
+ drawRect(p, B) {
3172
+ this.gl.uniform2f(this.centerLocation, p.x * this.scale, p.y * this.scale), this.gl.uniform2f(this.sizeLocation, p.width * this.scale * 0.5, p.height * this.scale * 0.5), this.gl.uniform4f(this.colorLocation, B.r, B.g, B.b, B.a), this.gl.uniform1f(this.shapeModeLocation, 0), this.gl.uniform1f(this.useTextureLocation, 0), this.gl.drawArrays(this.gl.TRIANGLES, 0, 6);
3167
3173
  }
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);
3174
+ drawCircle(p, B, A, E, c) {
3175
+ this.gl.uniform2f(this.centerLocation, p * this.scale, B * this.scale), this.gl.uniform2f(this.sizeLocation, A * this.scale, A * this.scale), this.gl.uniform4f(this.colorLocation, E.r, E.g, E.b, E.a), this.gl.uniform1f(this.shapeModeLocation, 1);
3170
3176
  const e = c === "peg" ? this.pegTexture : this.ballTexture, l = c === "peg" ? this.pegTextureReady : this.ballTextureReady;
3171
3177
  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);
3172
3178
  }
3173
3179
  };
3174
- function ee(d, E, A, B = 1) {
3180
+ function ee(p, B, A, E = 1) {
3175
3181
  return {
3176
- r: d / 255,
3177
- g: E / 255,
3182
+ r: p / 255,
3183
+ g: B / 255,
3178
3184
  b: A / 255,
3179
- a: B
3185
+ a: E
3180
3186
  };
3181
3187
  }
3182
- function ot(d, E) {
3183
- const A = d.createTexture();
3188
+ function ot(p, B) {
3189
+ const A = p.createTexture();
3184
3190
  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;
3191
+ return p.bindTexture(p.TEXTURE_2D, A), p.texImage2D(p.TEXTURE_2D, 0, p.RGBA, p.RGBA, p.UNSIGNED_BYTE, B), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_WRAP_S, p.CLAMP_TO_EDGE), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_WRAP_T, p.CLAMP_TO_EDGE), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_MIN_FILTER, p.LINEAR), p.texParameteri(p.TEXTURE_2D, p.TEXTURE_MAG_FILTER, p.LINEAR), p.bindTexture(p.TEXTURE_2D, null), A;
3186
3192
  }
3187
- function lt(d, E) {
3188
- return new Promise((A, B) => {
3193
+ function lt(p, B) {
3194
+ return new Promise((A, E) => {
3189
3195
  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;
3196
+ typeof B == "string" && B.length > 0 && (c.crossOrigin = B), c.onload = () => A(c), c.onerror = () => E(/* @__PURE__ */ new Error(`Failed to load image: ${p}`)), c.src = p;
3191
3197
  });
3192
3198
  }
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"}`);
3199
+ function de(p, B, A) {
3200
+ const E = p.createShader(B);
3201
+ if (!E) throw new Error("Unable to create shader");
3202
+ if (p.shaderSource(E, `#version 300 es
3203
+ ${A}`), p.compileShader(E), !p.getShaderParameter(E, p.COMPILE_STATUS)) {
3204
+ const c = p.getShaderInfoLog(E);
3205
+ throw p.deleteShader(E), new Error(`Shader compile error: ${c ?? "unknown"}`);
3200
3206
  }
3201
- return B;
3207
+ return E;
3202
3208
  }
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
+ function ft(p, B, A) {
3210
+ const E = p.createProgram();
3211
+ if (!E) throw new Error("Unable to create program");
3212
+ if (p.attachShader(E, B), p.attachShader(E, A), p.linkProgram(E), !p.getProgramParameter(E, p.LINK_STATUS)) {
3213
+ const c = p.getProgramInfoLog(E);
3214
+ throw p.deleteProgram(E), new Error(`Program link error: ${c ?? "unknown"}`);
3209
3215
  }
3210
- return d.deleteShader(E), d.deleteShader(A), B;
3216
+ return p.deleteShader(B), p.deleteShader(A), E;
3211
3217
  }
3212
3218
  var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3213
3219
  canvas;
@@ -3228,41 +3234,41 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3228
3234
  showGuidePegs;
3229
3235
  balance;
3230
3236
  lastSpawnAtMs = -1 / 0;
3231
- constructor(d) {
3232
- this.canvas = d.canvas, this.viewport = d.viewport, this.width = 1, this.height = 1, this.callbacks = {
3233
- onBalanceChange: d.onBalanceChange,
3234
- onBallSettled: d.onBallSettled
3235
- }, this.ballCost = d.ballCost, this.showGuidePegs = d.showGuidePegs, this.balance = d.initialBalance, this.onDprChange = () => this.listenDpr();
3236
- const E = Le({
3237
- mainPegs: d.layout.mainPegs,
3238
- ballRadius: d.ballRadius,
3239
- heightPolicy: d.viewport.heightPolicy
3237
+ constructor(p) {
3238
+ this.canvas = p.canvas, this.viewport = p.viewport, this.width = 1, this.height = 1, this.callbacks = {
3239
+ onBalanceChange: p.onBalanceChange,
3240
+ onBallSettled: p.onBallSettled
3241
+ }, this.ballCost = p.ballCost, this.showGuidePegs = p.showGuidePegs, this.balance = p.initialBalance, this.onDprChange = () => this.listenDpr();
3242
+ const B = Le({
3243
+ mainPegs: p.layout.mainPegs,
3244
+ ballRadius: p.ballRadius,
3245
+ heightPolicy: p.viewport.heightPolicy
3240
3246
  }), A = {
3241
- ...d.layout,
3242
- mainPegs: E.resolvedMainPegs
3247
+ ...p.layout,
3248
+ mainPegs: B.resolvedMainPegs
3243
3249
  };
3244
- this.worldHeight = E.worldHeight, this.canvas.style.maxWidth = "100%", this.renderer = new at(this.canvas, { appearance: d.appearance }), this.world = new nt({
3250
+ this.worldHeight = B.worldHeight, this.canvas.style.maxWidth = "100%", this.renderer = new at(this.canvas, { appearance: p.appearance }), this.world = new nt({
3245
3251
  width: 600,
3246
3252
  height: this.worldHeight,
3247
- gravityY: d.gravityY,
3253
+ gravityY: p.gravityY,
3248
3254
  layout: A,
3249
- ballRadius: d.ballRadius,
3250
- multipliers: d.multipliers,
3255
+ ballRadius: p.ballRadius,
3256
+ multipliers: p.multipliers,
3251
3257
  ballCost: this.ballCost,
3252
- houseEdge: d.houseEdge
3258
+ houseEdge: p.houseEdge
3253
3259
  }), 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");
3260
+ const E = this.canvas.parentElement;
3261
+ if (!E) throw new Error("Canvas must have a parent element for viewport sizing");
3256
3262
  this.resizeObserver = new ResizeObserver((c) => {
3257
3263
  const e = c[0];
3258
3264
  if (!e) return;
3259
- const l = e.contentBoxSize?.[0]?.inlineSize, a = l != null && l > 0 ? l : B.getBoundingClientRect().width;
3265
+ const l = e.contentBoxSize?.[0]?.inlineSize, a = l != null && l > 0 ? l : E.getBoundingClientRect().width;
3260
3266
  this.syncViewport(a);
3261
- }), this.resizeObserver.observe(B), this.listenDpr(), this.emitBalanceChange();
3267
+ }), this.resizeObserver.observe(E), this.listenDpr(), this.emitBalanceChange();
3262
3268
  }
3263
3269
  spawnBall() {
3264
- const d = performance.now();
3265
- return d - this.lastSpawnAtMs < ht ? {
3270
+ const p = performance.now();
3271
+ return p - this.lastSpawnAtMs < ht ? {
3266
3272
  ok: !1,
3267
3273
  reason: "SPAWN_COOLDOWN",
3268
3274
  state: this.getStateSnapshot()
@@ -3270,7 +3276,7 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3270
3276
  ok: !1,
3271
3277
  reason: "INSUFFICIENT_BALANCE",
3272
3278
  state: this.getStateSnapshot()
3273
- } : (this.balance -= this.ballCost, this.lastSpawnAtMs = d, this.emitBalanceChange(), this.world.spawnBall(), {
3279
+ } : (this.balance -= this.ballCost, this.lastSpawnAtMs = p, this.emitBalanceChange(), this.world.spawnBall(), {
3274
3280
  ok: !0,
3275
3281
  state: this.getStateSnapshot()
3276
3282
  }) : {
@@ -3280,8 +3286,8 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3280
3286
  };
3281
3287
  }
3282
3288
  resize() {
3283
- const d = this.canvas.parentElement;
3284
- d && this.syncViewport(d.getBoundingClientRect().width);
3289
+ const p = this.canvas.parentElement;
3290
+ p && this.syncViewport(p.getBoundingClientRect().width);
3285
3291
  }
3286
3292
  destroy() {
3287
3293
  this.loop.stop(), this.resizeObserver.disconnect(), this.dprQuery?.removeEventListener("change", this.onDprChange), this.dprQuery = null, this.world.destroy(), this.renderer.destroy();
@@ -3289,17 +3295,21 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3289
3295
  getState() {
3290
3296
  return this.getStateSnapshot();
3291
3297
  }
3292
- frame(d) {
3298
+ setBallCost(p) {
3299
+ if (!Number.isFinite(p) || p < 0) throw new TypeError(`Plinkit.setBallCost: expected a non-negative finite number, got ${p}`);
3300
+ this.ballCost !== p && (this.ballCost = p, this.world.setBallCost(p), this.emitBalanceChange());
3301
+ }
3302
+ frame(p) {
3293
3303
  if (this.lastFrameTime === 0) {
3294
- this.lastFrameTime = d, this.renderSnapshot();
3304
+ this.lastFrameTime = p, this.renderSnapshot();
3295
3305
  return;
3296
3306
  }
3297
- const E = Math.min(ct, d - this.lastFrameTime);
3298
- this.lastFrameTime = d, this.accumulatorMs += E;
3307
+ const B = Math.min(ct, p - this.lastFrameTime);
3308
+ this.lastFrameTime = p, this.accumulatorMs += B;
3299
3309
  let A = 0;
3300
3310
  for (; this.accumulatorMs >= oe && A < ut; ) {
3301
- const B = this.world.step(oe);
3302
- for (const c of B) {
3311
+ const E = this.world.step(oe);
3312
+ for (const c of E) {
3303
3313
  this.balance += c.payout;
3304
3314
  const e = this.getStateSnapshot();
3305
3315
  this.callbacks.onBallSettled?.(c, e), this.callbacks.onBalanceChange?.(e);
@@ -3309,26 +3319,26 @@ var oe = 1e3 / 120, ct = 50, ut = 8, ht = 300, gt = class {
3309
3319
  this.renderSnapshot();
3310
3320
  }
3311
3321
  renderSnapshot() {
3312
- const d = this.world.snapshot();
3313
- this.showGuidePegs || (d.guidePegs = []), this.renderer.render(d);
3322
+ const p = this.world.snapshot();
3323
+ this.showGuidePegs || (p.guidePegs = []), this.renderer.render(p);
3314
3324
  }
3315
3325
  emitBalanceChange() {
3316
3326
  this.callbacks.onBalanceChange?.(this.getStateSnapshot());
3317
3327
  }
3318
- syncViewport(d) {
3319
- const E = Re({
3320
- parentWidthPx: d,
3328
+ syncViewport(p) {
3329
+ const B = Re({
3330
+ parentWidthPx: p,
3321
3331
  viewport: this.viewport,
3322
3332
  worldHeight: this.worldHeight
3323
3333
  });
3324
- 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`;
3334
+ this.width = Math.max(1, B.displayWidth), this.height = Math.max(1, B.displayHeight), this.canvas.style.width = `${this.width}px`, this.canvas.style.height = `${this.height}px`;
3325
3335
  const A = Math.min(window.devicePixelRatio || 1, this.viewport.dprCap);
3326
- this.renderer.resize(this.width, this.height, A, E.worldScale);
3336
+ this.renderer.resize(this.width, this.height, A, B.worldScale);
3327
3337
  }
3328
3338
  listenDpr() {
3329
3339
  this.dprQuery?.removeEventListener("change", this.onDprChange);
3330
- const d = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
3331
- d.addEventListener("change", this.onDprChange), this.dprQuery = d, this.resize();
3340
+ const p = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
3341
+ p.addEventListener("change", this.onDprChange), this.dprQuery = p, this.resize();
3332
3342
  }
3333
3343
  getStateSnapshot() {
3334
3344
  return {