@roudanio/maze 0.1.3 → 0.1.4
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/maze.iife.js +3 -3
- package/dist/maze.js +626 -634
- package/dist/maze.umd.js +3 -3
- package/package.json +1 -1
package/dist/maze.js
CHANGED
|
@@ -1,98 +1,98 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
1
|
+
var ae, z, He, W, Ee, Be, qe, Ve, pe, _e, me, Xe, K = {}, Ye = [], at = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, ce = Array.isArray;
|
|
2
|
+
function U(t, e) {
|
|
3
3
|
for (var n in e) t[n] = e[n];
|
|
4
4
|
return t;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function Ce(t) {
|
|
7
7
|
t && t.parentNode && t.parentNode.removeChild(t);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
var o, i, s,
|
|
11
|
-
for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] :
|
|
12
|
-
if (arguments.length > 2 && (
|
|
13
|
-
return
|
|
9
|
+
function ct(t, e, n) {
|
|
10
|
+
var o, i, s, a = {};
|
|
11
|
+
for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : a[s] = e[s];
|
|
12
|
+
if (arguments.length > 2 && (a.children = arguments.length > 3 ? ae.call(arguments, 2) : n), typeof t == "function" && t.defaultProps != null) for (s in t.defaultProps) a[s] == null && (a[s] = t.defaultProps[s]);
|
|
13
|
+
return te(t, a, o, i, null);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
var s = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++
|
|
17
|
-
return i == null &&
|
|
15
|
+
function te(t, e, n, o, i) {
|
|
16
|
+
var s = { type: t, props: e, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++He, __i: -1, __u: 0 };
|
|
17
|
+
return i == null && z.vnode != null && z.vnode(s), s;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function ue(t) {
|
|
20
20
|
return t.children;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function ne(t, e) {
|
|
23
23
|
this.props = t, this.context = e;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (e == null) return t.__ ?
|
|
25
|
+
function H(t, e) {
|
|
26
|
+
if (e == null) return t.__ ? H(t.__, t.__i + 1) : null;
|
|
27
27
|
for (var n; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) return n.__e;
|
|
28
|
-
return typeof t.type == "function" ?
|
|
28
|
+
return typeof t.type == "function" ? H(t) : null;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function Ke(t) {
|
|
31
31
|
var e, n;
|
|
32
32
|
if ((t = t.__) != null && t.__c != null) {
|
|
33
33
|
for (t.__e = t.__c.base = null, e = 0; e < t.__k.length; e++) if ((n = t.__k[e]) != null && n.__e != null) {
|
|
34
34
|
t.__e = t.__c.base = n.__e;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return Ke(t);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
(!t.__d && (t.__d = !0) &&
|
|
40
|
+
function ve(t) {
|
|
41
|
+
(!t.__d && (t.__d = !0) && W.push(t) && !se.__r++ || Ee != z.debounceRendering) && ((Ee = z.debounceRendering) || Be)(se);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
for (var t, e, n, o, i, s,
|
|
45
|
-
|
|
43
|
+
function se() {
|
|
44
|
+
for (var t, e, n, o, i, s, a, r = 1; W.length; ) W.length > r && W.sort(qe), t = W.shift(), r = W.length, t.__d && (n = void 0, i = (o = (e = t).__v).__e, s = [], a = [], e.__P && ((n = U({}, o)).__v = o.__v + 1, z.vnode && z.vnode(n), we(e.__P, n, o, e.__n, e.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? H(o), !!(32 & o.__u), a), n.__v = o.__v, n.__.__k[n.__i] = n, Qe(s, n, a), n.__e != i && Ke(n)));
|
|
45
|
+
se.__r = 0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
var u, h, f,
|
|
49
|
-
for (l =
|
|
47
|
+
function Je(t, e, n, o, i, s, a, r, l, c, d) {
|
|
48
|
+
var u, h, f, T, p, _, v = o && o.__k || Ye, m = e.length;
|
|
49
|
+
for (l = ut(n, e, v, l, m), u = 0; u < m; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? K : v[f.__i] || K, f.__i = u, _ = we(t, f, h, i, s, a, r, l, c, d), T = f.__e, f.ref && h.ref != f.ref && (h.ref && ye(h.ref, null, f), d.push(f.ref, f.__c || T, f)), p == null && T != null && (p = T), 4 & f.__u || h.__k === f.__k ? l = Ze(f, l, t) : typeof f.type == "function" && _ !== void 0 ? l = _ : T && (l = T.nextSibling), f.__u &= -7);
|
|
50
50
|
return n.__e = p, l;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
53
|
-
var s,
|
|
54
|
-
for (t.__k = new Array(i), s = 0; s < i; s++) (
|
|
55
|
-
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o =
|
|
52
|
+
function ut(t, e, n, o, i) {
|
|
53
|
+
var s, a, r, l, c, d = n.length, u = d, h = 0;
|
|
54
|
+
for (t.__k = new Array(i), s = 0; s < i; s++) (a = e[s]) != null && typeof a != "boolean" && typeof a != "function" ? (l = s + h, (a = t.__k[s] = typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? te(null, a, null, null, null) : ce(a) ? te(ue, { children: a }, null, null, null) : a.constructor == null && a.__b > 0 ? te(a.type, a.props, a.key, a.ref ? a.ref : null, a.__v) : a).__ = t, a.__b = t.__b + 1, r = null, (c = a.__i = dt(a, n, l, u)) != -1 && (u--, (r = n[c]) && (r.__u |= 2)), r == null || r.__v == null ? (c == -1 && (i > d ? h-- : i < d && h++), typeof a.type != "function" && (a.__u |= 4)) : c != l && (c == l - 1 ? h-- : c == l + 1 ? h++ : (c > l ? h-- : h++, a.__u |= 4))) : t.__k[s] = null;
|
|
55
|
+
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = H(r)), tt(r, r));
|
|
56
56
|
return o;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function Ze(t, e, n) {
|
|
59
59
|
var o, i;
|
|
60
60
|
if (typeof t.type == "function") {
|
|
61
|
-
for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e =
|
|
61
|
+
for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e = Ze(o[i], e, n));
|
|
62
62
|
return e;
|
|
63
63
|
}
|
|
64
|
-
t.__e != e && (e && t.type && !n.contains(e) && (e =
|
|
64
|
+
t.__e != e && (e && t.type && !n.contains(e) && (e = H(t)), n.insertBefore(t.__e, e || null), e = t.__e);
|
|
65
65
|
do
|
|
66
66
|
e = e && e.nextSibling;
|
|
67
67
|
while (e != null && e.nodeType == 8);
|
|
68
68
|
return e;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
71
|
-
var i, s,
|
|
72
|
-
if (l === null && t.key == null || l &&
|
|
70
|
+
function dt(t, e, n, o) {
|
|
71
|
+
var i, s, a = t.key, r = t.type, l = e[n];
|
|
72
|
+
if (l === null && t.key == null || l && a == l.key && r == l.type && (2 & l.__u) == 0) return n;
|
|
73
73
|
if (o > (l != null && (2 & l.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) {
|
|
74
74
|
if (i >= 0) {
|
|
75
|
-
if ((l = e[i]) && (2 & l.__u) == 0 &&
|
|
75
|
+
if ((l = e[i]) && (2 & l.__u) == 0 && a == l.key && r == l.type) return i;
|
|
76
76
|
i--;
|
|
77
77
|
}
|
|
78
78
|
if (s < e.length) {
|
|
79
|
-
if ((l = e[s]) && (2 & l.__u) == 0 &&
|
|
79
|
+
if ((l = e[s]) && (2 & l.__u) == 0 && a == l.key && r == l.type) return s;
|
|
80
80
|
s++;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
return -1;
|
|
84
84
|
}
|
|
85
85
|
function Se(t, e, n) {
|
|
86
|
-
e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" ||
|
|
86
|
+
e[0] == "-" ? t.setProperty(e, n ?? "") : t[e] = n == null ? "" : typeof n != "number" || at.test(e) ? n : n + "px";
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function Q(t, e, n, o, i) {
|
|
89
89
|
var s;
|
|
90
90
|
e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
|
|
91
91
|
else {
|
|
92
92
|
if (typeof o == "string" && (t.style.cssText = o = ""), o) for (e in o) n && e in n || Se(t.style, e, "");
|
|
93
93
|
if (n) for (e in n) o && n[e] == o[e] || Se(t.style, e, n[e]);
|
|
94
94
|
}
|
|
95
|
-
else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(
|
|
95
|
+
else if (e[0] == "o" && e[1] == "n") s = e != (e = e.replace(Ve, "$1")), e = e.toLowerCase() in t || e == "onFocusOut" || e == "onFocusIn" ? e.toLowerCase().slice(2) : e.slice(2), t.l || (t.l = {}), t.l[e + s] = n, n ? o ? n.u = o.u : (n.u = pe, t.addEventListener(e, s ? me : _e, s)) : t.removeEventListener(e, s ? me : _e, s);
|
|
96
96
|
else {
|
|
97
97
|
if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
98
98
|
else if (e != "width" && e != "height" && e != "href" && e != "list" && e != "form" && e != "tabIndex" && e != "download" && e != "rowSpan" && e != "colSpan" && e != "role" && e != "popover" && e in t) try {
|
|
@@ -107,123 +107,123 @@ function ze(t) {
|
|
|
107
107
|
return function(e) {
|
|
108
108
|
if (this.l) {
|
|
109
109
|
var n = this.l[e.type + t];
|
|
110
|
-
if (e.t == null) e.t =
|
|
110
|
+
if (e.t == null) e.t = pe++;
|
|
111
111
|
else if (e.t < n.u) return;
|
|
112
|
-
return n(
|
|
112
|
+
return n(z.event ? z.event(e) : e);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function we(t, e, n, o, i, s,
|
|
117
|
-
var d, u, h, f,
|
|
116
|
+
function we(t, e, n, o, i, s, a, r, l, c) {
|
|
117
|
+
var d, u, h, f, T, p, _, v, m, C, w, b, E, k, S, y, L, N = e.type;
|
|
118
118
|
if (e.constructor != null) return null;
|
|
119
|
-
128 & n.__u && (l = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d =
|
|
119
|
+
128 & n.__u && (l = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = z.__b) && d(e);
|
|
120
120
|
e: if (typeof N == "function") try {
|
|
121
|
-
if (v = e.props, m = "prototype" in N && N.prototype.render,
|
|
121
|
+
if (v = e.props, m = "prototype" in N && N.prototype.render, C = (d = N.contextType) && o[d.__c], w = d ? C ? C.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (m ? e.__c = u = new N(v, w) : (e.__c = u = new ne(v, w), u.constructor = N, u.render = ft), C && C.sub(u), u.props = v, u.state || (u.state = {}), u.context = w, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), m && u.__s == null && (u.__s = u.state), m && N.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = U({}, u.__s)), U(u.__s, N.getDerivedStateFromProps(v, u.__s))), f = u.props, T = u.state, u.__v = e, h) m && N.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), m && u.componentDidMount != null && u.__h.push(u.componentDidMount);
|
|
122
122
|
else {
|
|
123
123
|
if (m && N.getDerivedStateFromProps == null && v !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(v, w), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(v, u.__s, w) === !1 || e.__v == n.__v) {
|
|
124
124
|
for (e.__v != n.__v && (u.props = v, u.state = u.__s, u.__d = !1), e.__e = n.__e, e.__k = n.__k, e.__k.some(function(P) {
|
|
125
125
|
P && (P.__ = e);
|
|
126
|
-
}),
|
|
127
|
-
u._sb = [], u.__h.length &&
|
|
126
|
+
}), b = 0; b < u._sb.length; b++) u.__h.push(u._sb[b]);
|
|
127
|
+
u._sb = [], u.__h.length && a.push(u);
|
|
128
128
|
break e;
|
|
129
129
|
}
|
|
130
130
|
u.componentWillUpdate != null && u.componentWillUpdate(v, u.__s, w), m && u.componentDidUpdate != null && u.__h.push(function() {
|
|
131
|
-
u.componentDidUpdate(f,
|
|
131
|
+
u.componentDidUpdate(f, T, p);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
if (u.context = w, u.props = v, u.__P = t, u.__e = !1,
|
|
135
|
-
for (u.state = u.__s, u.__d = !1,
|
|
134
|
+
if (u.context = w, u.props = v, u.__P = t, u.__e = !1, E = z.__r, k = 0, m) {
|
|
135
|
+
for (u.state = u.__s, u.__d = !1, E && E(e), d = u.render(u.props, u.state, u.context), S = 0; S < u._sb.length; S++) u.__h.push(u._sb[S]);
|
|
136
136
|
u._sb = [];
|
|
137
137
|
} else do
|
|
138
|
-
u.__d = !1,
|
|
139
|
-
while (u.__d && ++
|
|
140
|
-
u.state = u.__s, u.getChildContext != null && (o =
|
|
138
|
+
u.__d = !1, E && E(e), d = u.render(u.props, u.state, u.context), u.state = u.__s;
|
|
139
|
+
while (u.__d && ++k < 25);
|
|
140
|
+
u.state = u.__s, u.getChildContext != null && (o = U(U({}, o), u.getChildContext())), m && !h && u.getSnapshotBeforeUpdate != null && (p = u.getSnapshotBeforeUpdate(f, T)), y = d, d != null && d.type === ue && d.key == null && (y = et(d.props.children)), r = Je(t, ce(y) ? y : [y], e, n, o, i, s, a, r, l, c), u.base = e.__e, e.__u &= -161, u.__h.length && a.push(u), _ && (u.__E = u.__ = null);
|
|
141
141
|
} catch (P) {
|
|
142
142
|
if (e.__v = null, l || s != null) if (P.then) {
|
|
143
143
|
for (e.__u |= l ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
|
|
144
144
|
s[s.indexOf(r)] = null, e.__e = r;
|
|
145
|
-
} else for (
|
|
145
|
+
} else for (L = s.length; L--; ) Ce(s[L]);
|
|
146
146
|
else e.__e = n.__e, e.__k = n.__k;
|
|
147
|
-
|
|
147
|
+
z.__e(P, e, n);
|
|
148
148
|
}
|
|
149
|
-
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e =
|
|
150
|
-
return (d =
|
|
149
|
+
else s == null && e.__v == n.__v ? (e.__k = n.__k, e.__e = n.__e) : r = e.__e = ht(n.__e, e, n, o, i, s, a, l, c);
|
|
150
|
+
return (d = z.diffed) && d(e), 128 & e.__u ? void 0 : r;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
for (var o = 0; o < n.length; o++)
|
|
154
|
-
|
|
152
|
+
function Qe(t, e, n) {
|
|
153
|
+
for (var o = 0; o < n.length; o++) ye(n[o], n[++o], n[++o]);
|
|
154
|
+
z.__c && z.__c(e, t), t.some(function(i) {
|
|
155
155
|
try {
|
|
156
156
|
t = i.__h, i.__h = [], t.some(function(s) {
|
|
157
157
|
s.call(i);
|
|
158
158
|
});
|
|
159
159
|
} catch (s) {
|
|
160
|
-
|
|
160
|
+
z.__e(s, i.__v);
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t :
|
|
164
|
+
function et(t) {
|
|
165
|
+
return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : ce(t) ? t.map(et) : U({}, t);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
var
|
|
167
|
+
function ht(t, e, n, o, i, s, a, r, l) {
|
|
168
|
+
var c, d, u, h, f, T, p, _ = n.props, v = e.props, m = e.type;
|
|
169
169
|
if (m == "svg" ? i = "http://www.w3.org/2000/svg" : m == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
|
|
170
|
-
for (
|
|
171
|
-
t = f, s[
|
|
170
|
+
for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!m && (m ? f.localName == m : f.nodeType == 3)) {
|
|
171
|
+
t = f, s[c] = null;
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
if (t == null) {
|
|
176
176
|
if (m == null) return document.createTextNode(v);
|
|
177
|
-
t = document.createElementNS(i, m, v.is && v), r && (
|
|
177
|
+
t = document.createElementNS(i, m, v.is && v), r && (z.__m && z.__m(e, s), r = !1), s = null;
|
|
178
178
|
}
|
|
179
179
|
if (m == null) _ === v || r && t.data == v || (t.data = v);
|
|
180
180
|
else {
|
|
181
|
-
if (s = s &&
|
|
182
|
-
for (
|
|
183
|
-
if (
|
|
184
|
-
else if (!(
|
|
185
|
-
if (
|
|
186
|
-
|
|
181
|
+
if (s = s && ae.call(t.childNodes), _ = n.props || K, !r && s != null) for (_ = {}, c = 0; c < t.attributes.length; c++) _[(f = t.attributes[c]).name] = f.value;
|
|
182
|
+
for (c in _) if (f = _[c], c != "children") {
|
|
183
|
+
if (c == "dangerouslySetInnerHTML") u = f;
|
|
184
|
+
else if (!(c in v)) {
|
|
185
|
+
if (c == "value" && "defaultValue" in v || c == "checked" && "defaultChecked" in v) continue;
|
|
186
|
+
Q(t, c, null, f, i);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
for (
|
|
189
|
+
for (c in v) f = v[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? T = f : c == "checked" ? p = f : r && typeof f != "function" || _[c] === f || Q(t, c, f, _[c], i);
|
|
190
190
|
if (d) r || u && (d.__html == u.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
|
|
191
|
-
else if (u && (t.innerHTML = ""),
|
|
192
|
-
r || (
|
|
191
|
+
else if (u && (t.innerHTML = ""), Je(e.type == "template" ? t.content : t, ce(h) ? h : [h], e, n, o, m == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, a, s ? s[0] : n.__k && H(n, 0), r, l), s != null) for (c = s.length; c--; ) Ce(s[c]);
|
|
192
|
+
r || (c = "value", m == "progress" && T == null ? t.removeAttribute("value") : T != null && (T !== t[c] || m == "progress" && !T || m == "option" && T != _[c]) && Q(t, c, T, _[c], i), c = "checked", p != null && p != t[c] && Q(t, c, p, _[c], i));
|
|
193
193
|
}
|
|
194
194
|
return t;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function ye(t, e, n) {
|
|
197
197
|
try {
|
|
198
198
|
if (typeof t == "function") {
|
|
199
199
|
var o = typeof t.__u == "function";
|
|
200
200
|
o && t.__u(), o && e == null || (t.__u = t(e));
|
|
201
201
|
} else t.current = e;
|
|
202
202
|
} catch (i) {
|
|
203
|
-
|
|
203
|
+
z.__e(i, n);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function tt(t, e, n) {
|
|
207
207
|
var o, i;
|
|
208
|
-
if (
|
|
208
|
+
if (z.unmount && z.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || ye(o, null, e)), (o = t.__c) != null) {
|
|
209
209
|
if (o.componentWillUnmount) try {
|
|
210
210
|
o.componentWillUnmount();
|
|
211
211
|
} catch (s) {
|
|
212
|
-
|
|
212
|
+
z.__e(s, e);
|
|
213
213
|
}
|
|
214
214
|
o.base = o.__P = null;
|
|
215
215
|
}
|
|
216
|
-
if (o = t.__k) for (i = 0; i < o.length; i++) o[i] &&
|
|
217
|
-
n ||
|
|
216
|
+
if (o = t.__k) for (i = 0; i < o.length; i++) o[i] && tt(o[i], e, n || typeof t.type != "function");
|
|
217
|
+
n || Ce(t.__e), t.__c = t.__ = t.__e = void 0;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function ft(t, e, n) {
|
|
220
220
|
return this.constructor(t, n);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
223
|
-
var o, i, s,
|
|
224
|
-
e == document && (e = document.documentElement),
|
|
222
|
+
function _t(t, e, n) {
|
|
223
|
+
var o, i, s, a;
|
|
224
|
+
e == document && (e = document.documentElement), z.__ && z.__(t, e), i = (o = !1) ? null : e.__k, s = [], a = [], we(e, t = e.__k = ct(ue, null, [t]), i || K, K, e.namespaceURI, i ? null : e.firstChild ? ae.call(e.childNodes) : null, s, i ? i.__e : e.firstChild, o, a), Qe(s, t, a);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function mt(t) {
|
|
227
227
|
function e(n) {
|
|
228
228
|
var o, i;
|
|
229
229
|
return this.getChildContext || (o = /* @__PURE__ */ new Set(), (i = {})[e.__c] = this, this.getChildContext = function() {
|
|
@@ -231,177 +231,177 @@ function _t(t) {
|
|
|
231
231
|
}, this.componentWillUnmount = function() {
|
|
232
232
|
o = null;
|
|
233
233
|
}, this.shouldComponentUpdate = function(s) {
|
|
234
|
-
this.props.value != s.value && o.forEach(function(
|
|
235
|
-
|
|
234
|
+
this.props.value != s.value && o.forEach(function(a) {
|
|
235
|
+
a.__e = !0, ve(a);
|
|
236
236
|
});
|
|
237
237
|
}, this.sub = function(s) {
|
|
238
238
|
o.add(s);
|
|
239
|
-
var
|
|
239
|
+
var a = s.componentWillUnmount;
|
|
240
240
|
s.componentWillUnmount = function() {
|
|
241
|
-
o && o.delete(s),
|
|
241
|
+
o && o.delete(s), a && a.call(s);
|
|
242
242
|
};
|
|
243
243
|
}), n.children;
|
|
244
244
|
}
|
|
245
|
-
return e.__c = "__cC" +
|
|
245
|
+
return e.__c = "__cC" + Xe++, e.__ = t, e.Provider = e.__l = (e.Consumer = function(n, o) {
|
|
246
246
|
return n.children(o);
|
|
247
247
|
}).contextType = e, e;
|
|
248
248
|
}
|
|
249
|
-
|
|
250
|
-
for (var i, s,
|
|
251
|
-
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)),
|
|
249
|
+
ae = Ye.slice, z = { __e: function(t, e, n, o) {
|
|
250
|
+
for (var i, s, a; e = e.__; ) if ((i = e.__c) && !i.__) try {
|
|
251
|
+
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), a = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, o || {}), a = i.__d), a) return i.__E = i;
|
|
252
252
|
} catch (r) {
|
|
253
253
|
t = r;
|
|
254
254
|
}
|
|
255
255
|
throw t;
|
|
256
|
-
} },
|
|
256
|
+
} }, He = 0, ne.prototype.setState = function(t, e) {
|
|
257
257
|
var n;
|
|
258
|
-
n = this.__s != null && this.__s != this.state ? this.__s : this.__s =
|
|
259
|
-
},
|
|
260
|
-
this.__v && (this.__e = !0, t && this.__h.push(t),
|
|
261
|
-
},
|
|
258
|
+
n = this.__s != null && this.__s != this.state ? this.__s : this.__s = U({}, this.state), typeof t == "function" && (t = t(U({}, n), this.props)), t && U(n, t), t != null && this.__v && (e && this._sb.push(e), ve(this));
|
|
259
|
+
}, ne.prototype.forceUpdate = function(t) {
|
|
260
|
+
this.__v && (this.__e = !0, t && this.__h.push(t), ve(this));
|
|
261
|
+
}, ne.prototype.render = ue, W = [], Be = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, qe = function(t, e) {
|
|
262
262
|
return t.__v.__b - e.__v.__b;
|
|
263
|
-
},
|
|
264
|
-
var
|
|
263
|
+
}, se.__r = 0, Ve = /(PointerCapture)$|Capture$/i, pe = 0, _e = ze(!1), me = ze(!0), Xe = 0;
|
|
264
|
+
var vt = 0;
|
|
265
265
|
function g(t, e, n, o, i, s) {
|
|
266
266
|
e || (e = {});
|
|
267
|
-
var
|
|
268
|
-
if ("ref" in l) for (r in l = {}, e) r == "ref" ?
|
|
269
|
-
var
|
|
270
|
-
if (typeof t == "function" && (
|
|
271
|
-
return
|
|
272
|
-
}
|
|
273
|
-
var
|
|
274
|
-
function
|
|
275
|
-
M.__h && M.__h(A, t,
|
|
267
|
+
var a, r, l = e;
|
|
268
|
+
if ("ref" in l) for (r in l = {}, e) r == "ref" ? a = e[r] : l[r] = e[r];
|
|
269
|
+
var c = { type: t, props: l, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --vt, __i: -1, __u: 0, __source: i, __self: s };
|
|
270
|
+
if (typeof t == "function" && (a = t.defaultProps)) for (r in a) l[r] === void 0 && (l[r] = a[r]);
|
|
271
|
+
return z.vnode && z.vnode(c), c;
|
|
272
|
+
}
|
|
273
|
+
var B, A, fe, Ne, J = 0, nt = [], M = z, Le = M.__b, Ae = M.__r, Me = M.diffed, Pe = M.__c, xe = M.unmount, Ie = M.__;
|
|
274
|
+
function de(t, e) {
|
|
275
|
+
M.__h && M.__h(A, t, J || e), J = 0;
|
|
276
276
|
var n = A.__H || (A.__H = { __: [], __h: [] });
|
|
277
277
|
return t >= n.__.length && n.__.push({}), n.__[t];
|
|
278
278
|
}
|
|
279
|
-
function
|
|
280
|
-
return
|
|
279
|
+
function G(t) {
|
|
280
|
+
return J = 1, gt(rt, t);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
var o =
|
|
284
|
-
if (o.t = t, !o.__c && (o.__ = [
|
|
285
|
-
var l = o.__N ? o.__N[0] : o.__[0],
|
|
286
|
-
l !==
|
|
282
|
+
function gt(t, e, n) {
|
|
283
|
+
var o = de(B++, 2);
|
|
284
|
+
if (o.t = t, !o.__c && (o.__ = [rt(void 0, e), function(r) {
|
|
285
|
+
var l = o.__N ? o.__N[0] : o.__[0], c = o.t(l, r);
|
|
286
|
+
l !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
|
|
287
287
|
}], o.__c = A, !A.__f)) {
|
|
288
|
-
var i = function(r, l,
|
|
288
|
+
var i = function(r, l, c) {
|
|
289
289
|
if (!o.__c.__H) return !0;
|
|
290
290
|
var d = o.__c.__H.__.filter(function(h) {
|
|
291
291
|
return !!h.__c;
|
|
292
292
|
});
|
|
293
293
|
if (d.every(function(h) {
|
|
294
294
|
return !h.__N;
|
|
295
|
-
})) return !s || s.call(this, r, l,
|
|
295
|
+
})) return !s || s.call(this, r, l, c);
|
|
296
296
|
var u = o.__c.props !== r;
|
|
297
297
|
return d.forEach(function(h) {
|
|
298
298
|
if (h.__N) {
|
|
299
299
|
var f = h.__[0];
|
|
300
300
|
h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (u = !0);
|
|
301
301
|
}
|
|
302
|
-
}), s && s.call(this, r, l,
|
|
302
|
+
}), s && s.call(this, r, l, c) || u;
|
|
303
303
|
};
|
|
304
304
|
A.__f = !0;
|
|
305
|
-
var s = A.shouldComponentUpdate,
|
|
306
|
-
A.componentWillUpdate = function(r, l,
|
|
305
|
+
var s = A.shouldComponentUpdate, a = A.componentWillUpdate;
|
|
306
|
+
A.componentWillUpdate = function(r, l, c) {
|
|
307
307
|
if (this.__e) {
|
|
308
308
|
var d = s;
|
|
309
|
-
s = void 0, i(r, l,
|
|
309
|
+
s = void 0, i(r, l, c), s = d;
|
|
310
310
|
}
|
|
311
|
-
|
|
311
|
+
a && a.call(this, r, l, c);
|
|
312
312
|
}, A.shouldComponentUpdate = i;
|
|
313
313
|
}
|
|
314
314
|
return o.__N || o.__;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
var n =
|
|
318
|
-
!M.__s &&
|
|
316
|
+
function I(t, e) {
|
|
317
|
+
var n = de(B++, 3);
|
|
318
|
+
!M.__s && ot(n.__H, e) && (n.__ = t, n.u = e, A.__H.__h.push(n));
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
return
|
|
320
|
+
function O(t) {
|
|
321
|
+
return J = 5, q(function() {
|
|
322
322
|
return { current: t };
|
|
323
323
|
}, []);
|
|
324
324
|
}
|
|
325
325
|
function q(t, e) {
|
|
326
|
-
var n =
|
|
327
|
-
return
|
|
326
|
+
var n = de(B++, 7);
|
|
327
|
+
return ot(n.__H, e) && (n.__ = t(), n.__H = e, n.__h = t), n.__;
|
|
328
328
|
}
|
|
329
|
-
function
|
|
330
|
-
return
|
|
329
|
+
function Fe(t, e) {
|
|
330
|
+
return J = 8, q(function() {
|
|
331
331
|
return t;
|
|
332
332
|
}, e);
|
|
333
333
|
}
|
|
334
334
|
function pt(t) {
|
|
335
|
-
var e = A.context[t.__c], n =
|
|
335
|
+
var e = A.context[t.__c], n = de(B++, 9);
|
|
336
336
|
return n.c = t, e ? (n.__ == null && (n.__ = !0, e.sub(A)), e.props.value) : t.__;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
for (var t; t =
|
|
340
|
-
t.__H.__h.forEach(
|
|
338
|
+
function Ct() {
|
|
339
|
+
for (var t; t = nt.shift(); ) if (t.__P && t.__H) try {
|
|
340
|
+
t.__H.__h.forEach(oe), t.__H.__h.forEach(ge), t.__H.__h = [];
|
|
341
341
|
} catch (e) {
|
|
342
342
|
t.__H.__h = [], M.__e(e, t.__v);
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
345
|
M.__b = function(t) {
|
|
346
|
-
A = null,
|
|
346
|
+
A = null, Le && Le(t);
|
|
347
347
|
}, M.__ = function(t, e) {
|
|
348
348
|
t && e.__k && e.__k.__m && (t.__m = e.__k.__m), Ie && Ie(t, e);
|
|
349
349
|
}, M.__r = function(t) {
|
|
350
|
-
Ae && Ae(t),
|
|
350
|
+
Ae && Ae(t), B = 0;
|
|
351
351
|
var e = (A = t.__c).__H;
|
|
352
|
-
e && (
|
|
352
|
+
e && (fe === A ? (e.__h = [], A.__h = [], e.__.forEach(function(n) {
|
|
353
353
|
n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
|
|
354
|
-
})) : (e.__h.forEach(
|
|
354
|
+
})) : (e.__h.forEach(oe), e.__h.forEach(ge), e.__h = [], B = 0)), fe = A;
|
|
355
355
|
}, M.diffed = function(t) {
|
|
356
|
-
|
|
356
|
+
Me && Me(t);
|
|
357
357
|
var e = t.__c;
|
|
358
|
-
e && e.__H && (e.__H.__h.length && (
|
|
358
|
+
e && e.__H && (e.__H.__h.length && (nt.push(e) !== 1 && Ne === M.requestAnimationFrame || ((Ne = M.requestAnimationFrame) || wt)(Ct)), e.__H.__.forEach(function(n) {
|
|
359
359
|
n.u && (n.__H = n.u), n.u = void 0;
|
|
360
|
-
})),
|
|
360
|
+
})), fe = A = null;
|
|
361
361
|
}, M.__c = function(t, e) {
|
|
362
362
|
e.some(function(n) {
|
|
363
363
|
try {
|
|
364
|
-
n.__h.forEach(
|
|
365
|
-
return !o.__ ||
|
|
364
|
+
n.__h.forEach(oe), n.__h = n.__h.filter(function(o) {
|
|
365
|
+
return !o.__ || ge(o);
|
|
366
366
|
});
|
|
367
367
|
} catch (o) {
|
|
368
368
|
e.some(function(i) {
|
|
369
369
|
i.__h && (i.__h = []);
|
|
370
370
|
}), e = [], M.__e(o, n.__v);
|
|
371
371
|
}
|
|
372
|
-
}),
|
|
372
|
+
}), Pe && Pe(t, e);
|
|
373
373
|
}, M.unmount = function(t) {
|
|
374
|
-
|
|
374
|
+
xe && xe(t);
|
|
375
375
|
var e, n = t.__c;
|
|
376
376
|
n && n.__H && (n.__H.__.forEach(function(o) {
|
|
377
377
|
try {
|
|
378
|
-
|
|
378
|
+
oe(o);
|
|
379
379
|
} catch (i) {
|
|
380
380
|
e = i;
|
|
381
381
|
}
|
|
382
382
|
}), n.__H = void 0, e && M.__e(e, n.__v));
|
|
383
383
|
};
|
|
384
|
-
var
|
|
385
|
-
function
|
|
384
|
+
var De = typeof requestAnimationFrame == "function";
|
|
385
|
+
function wt(t) {
|
|
386
386
|
var e, n = function() {
|
|
387
|
-
clearTimeout(o),
|
|
387
|
+
clearTimeout(o), De && cancelAnimationFrame(e), setTimeout(t);
|
|
388
388
|
}, o = setTimeout(n, 100);
|
|
389
|
-
|
|
389
|
+
De && (e = requestAnimationFrame(n));
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function oe(t) {
|
|
392
392
|
var e = A, n = t.__c;
|
|
393
393
|
typeof n == "function" && (t.__c = void 0, n()), A = e;
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function ge(t) {
|
|
396
396
|
var e = A;
|
|
397
397
|
t.__c = t.__(), A = e;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function ot(t, e) {
|
|
400
400
|
return !t || t.length !== e.length || e.some(function(n, o) {
|
|
401
401
|
return n !== t[o];
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function rt(t, e) {
|
|
405
405
|
return typeof e == "function" ? e(t) : e;
|
|
406
406
|
}
|
|
407
407
|
const yt = (t) => ({
|
|
@@ -427,14 +427,14 @@ const yt = (t) => ({
|
|
|
427
427
|
console.error("Failed to reset maze game data:", e);
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
-
}),
|
|
430
|
+
}), it = mt(void 0), Re = {
|
|
431
431
|
currentLevel: 1,
|
|
432
432
|
highestUnlockedLevel: 1,
|
|
433
433
|
currentTier: 1,
|
|
434
434
|
highestUnlockedTier: 1,
|
|
435
435
|
levelScores: {},
|
|
436
436
|
totalScore: 0
|
|
437
|
-
},
|
|
437
|
+
}, Oe = {
|
|
438
438
|
isGameActive: !0,
|
|
439
439
|
levelTransitioning: !1,
|
|
440
440
|
maze: null,
|
|
@@ -448,8 +448,8 @@ const yt = (t) => ({
|
|
|
448
448
|
playerPath: [],
|
|
449
449
|
visitCounts: {}
|
|
450
450
|
}, bt = ({ children: t, config: e }) => {
|
|
451
|
-
const n = yt(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] =
|
|
452
|
-
|
|
451
|
+
const n = yt(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = G(() => o || { ...Re });
|
|
452
|
+
I(() => {
|
|
453
453
|
const u = Object.values(i.levelScores).reduce(
|
|
454
454
|
(h, f) => h + f,
|
|
455
455
|
0
|
|
@@ -458,7 +458,7 @@ const yt = (t) => ({
|
|
|
458
458
|
...h,
|
|
459
459
|
totalScore: u
|
|
460
460
|
}));
|
|
461
|
-
}, [i.levelScores]),
|
|
461
|
+
}, [i.levelScores]), I(() => {
|
|
462
462
|
n.saveGameData(i);
|
|
463
463
|
}, [
|
|
464
464
|
i.currentLevel,
|
|
@@ -468,69 +468,69 @@ const yt = (t) => ({
|
|
|
468
468
|
i.levelScores,
|
|
469
469
|
i.totalScore
|
|
470
470
|
]);
|
|
471
|
-
const [
|
|
472
|
-
...
|
|
473
|
-
}), l =
|
|
474
|
-
|
|
475
|
-
l.current =
|
|
476
|
-
}, [
|
|
477
|
-
const
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
471
|
+
const [a, r] = G({
|
|
472
|
+
...Oe
|
|
473
|
+
}), l = O(a);
|
|
474
|
+
I(() => {
|
|
475
|
+
l.current = a;
|
|
476
|
+
}, [a]);
|
|
477
|
+
const c = q(() => [
|
|
478
|
+
a.playerAtExit ? 1 : 0,
|
|
479
|
+
a.foodCollected === a.totalFoodCount ? 1 : 0,
|
|
480
|
+
a.showClue ? 0 : 1
|
|
481
481
|
], [
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
482
|
+
a.playerAtExit,
|
|
483
|
+
a.foodCollected,
|
|
484
|
+
a.totalFoodCount,
|
|
485
|
+
a.showClue
|
|
486
486
|
]), d = () => {
|
|
487
487
|
n.resetGameData(), s({
|
|
488
|
-
...
|
|
488
|
+
...Re
|
|
489
489
|
}), r({
|
|
490
|
-
...
|
|
490
|
+
...Oe
|
|
491
491
|
});
|
|
492
492
|
};
|
|
493
493
|
return /* @__PURE__ */ g(
|
|
494
|
-
|
|
494
|
+
it.Provider,
|
|
495
495
|
{
|
|
496
496
|
value: {
|
|
497
497
|
gameProgress: i,
|
|
498
498
|
setGameProgress: s,
|
|
499
|
-
gamePlayState:
|
|
499
|
+
gamePlayState: a,
|
|
500
500
|
setGamePlayState: r,
|
|
501
501
|
gamePlayStateRef: l,
|
|
502
|
-
currentScore:
|
|
502
|
+
currentScore: c,
|
|
503
503
|
config: e,
|
|
504
504
|
resetGame: d
|
|
505
505
|
},
|
|
506
506
|
children: t
|
|
507
507
|
}
|
|
508
508
|
);
|
|
509
|
-
},
|
|
510
|
-
const t = pt(
|
|
509
|
+
}, V = () => {
|
|
510
|
+
const t = pt(it);
|
|
511
511
|
if (!t)
|
|
512
512
|
throw new Error("useGameContext must be used within a GameProvider");
|
|
513
513
|
return t;
|
|
514
|
-
},
|
|
514
|
+
}, Z = (t) => q(() => {
|
|
515
515
|
const e = t.map((r) => r.length), n = e.reduce((r, l) => r + l, 0), o = t.length, i = (r) => {
|
|
516
516
|
if (r < 1 || r > n) return 0;
|
|
517
517
|
let l = 0;
|
|
518
|
-
for (let
|
|
519
|
-
if (l += e[
|
|
518
|
+
for (let c = 0; c < e.length; c++)
|
|
519
|
+
if (l += e[c], r <= l) return c + 1;
|
|
520
520
|
return 0;
|
|
521
|
-
}, s = (r) => r < 1 || r > o ? 0 : e.slice(0, r - 1).reduce((l,
|
|
521
|
+
}, s = (r) => r < 1 || r > o ? 0 : e.slice(0, r - 1).reduce((l, c) => l + c, 0) + 1, a = {
|
|
522
522
|
getTotalLevels: () => n,
|
|
523
523
|
getTotalTiers: () => o,
|
|
524
524
|
getTierLevelsRange: (r) => {
|
|
525
525
|
if (r < 1 || r > o) return [0, 0];
|
|
526
|
-
const l = s(r),
|
|
527
|
-
return [l,
|
|
526
|
+
const l = s(r), c = l + e[r - 1] - 1;
|
|
527
|
+
return [l, c];
|
|
528
528
|
},
|
|
529
529
|
getTierByLevel: i,
|
|
530
530
|
getFirstLevelOfTier: s,
|
|
531
531
|
getLevelConfig: (r) => {
|
|
532
532
|
if (r < 1 || r > n) return null;
|
|
533
|
-
const l = i(r),
|
|
533
|
+
const l = i(r), c = s(l), d = r - c;
|
|
534
534
|
return t[l - 1][d];
|
|
535
535
|
},
|
|
536
536
|
getTierConfig: (r) => r < 1 || r > o ? null : t[r - 1],
|
|
@@ -538,44 +538,44 @@ const yt = (t) => ({
|
|
|
538
538
|
isTierUnlocked: (r, l) => r <= l,
|
|
539
539
|
getNextLevelInfo: (r) => {
|
|
540
540
|
if (r >= n) return null;
|
|
541
|
-
const l = r + 1,
|
|
541
|
+
const l = r + 1, c = i(r), d = i(l);
|
|
542
542
|
return {
|
|
543
543
|
nextLevel: l,
|
|
544
544
|
nextTier: d,
|
|
545
|
-
isTierChange: d >
|
|
545
|
+
isTierChange: d > c
|
|
546
546
|
};
|
|
547
547
|
},
|
|
548
548
|
getCurrentTierProgress: (r, l) => {
|
|
549
|
-
const [
|
|
549
|
+
const [c, d] = a.getTierLevelsRange(l), u = r - c + 1, h = d - c + 1;
|
|
550
550
|
return { current: u, total: h };
|
|
551
551
|
},
|
|
552
552
|
isLastLevelInTier: (r) => {
|
|
553
|
-
const l = i(r), [,
|
|
554
|
-
return r ===
|
|
553
|
+
const l = i(r), [, c] = a.getTierLevelsRange(l);
|
|
554
|
+
return r === c;
|
|
555
555
|
},
|
|
556
556
|
getPreviousLevelInfo: (r) => {
|
|
557
557
|
if (r <= 1) return null;
|
|
558
|
-
const l = r - 1,
|
|
558
|
+
const l = r - 1, c = i(r), d = i(l);
|
|
559
559
|
return {
|
|
560
560
|
prevLevel: l,
|
|
561
561
|
prevTier: d,
|
|
562
|
-
isTierChange: d <
|
|
562
|
+
isTierChange: d < c
|
|
563
563
|
};
|
|
564
564
|
}
|
|
565
565
|
};
|
|
566
|
-
return
|
|
566
|
+
return a;
|
|
567
567
|
}, [t]), kt = ({ onTierChange: t, disabled: e }) => {
|
|
568
|
-
const { gameProgress: n, config: o } =
|
|
568
|
+
const { gameProgress: n, config: o } = V(), { i18n: i, levelConfig: s } = o, { currentTier: a, highestUnlockedTier: r } = n, c = Z(s).getTotalTiers();
|
|
569
569
|
return /* @__PURE__ */ g("div", { className: "tier-selector", children: /* @__PURE__ */ g(
|
|
570
570
|
"select",
|
|
571
571
|
{
|
|
572
|
-
value:
|
|
572
|
+
value: a,
|
|
573
573
|
onChange: (d) => {
|
|
574
574
|
d.target && d.target.value && t(Number(d.target.value));
|
|
575
575
|
},
|
|
576
576
|
disabled: e,
|
|
577
577
|
className: "tier-dropdown",
|
|
578
|
-
children: Array.from({ length:
|
|
578
|
+
children: Array.from({ length: c }, (d, u) => u + 1).map((d) => /* @__PURE__ */ g(
|
|
579
579
|
"option",
|
|
580
580
|
{
|
|
581
581
|
value: d,
|
|
@@ -587,16 +587,16 @@ const yt = (t) => ({
|
|
|
587
587
|
}
|
|
588
588
|
) });
|
|
589
589
|
}, Tt = ({ onLevelChange: t, disabled: e }) => {
|
|
590
|
-
const { gameProgress: n, config: o } =
|
|
591
|
-
const [h, f] = d.getTierLevelsRange(
|
|
592
|
-
return Array.from({ length: f - h + 1 }, (
|
|
590
|
+
const { gameProgress: n, config: o } = V(), { i18n: i, levelConfig: s } = o, { currentTier: a, levelScores: r, currentLevel: l, highestUnlockedLevel: c } = n, d = Z(s), u = q(() => {
|
|
591
|
+
const [h, f] = d.getTierLevelsRange(a);
|
|
592
|
+
return Array.from({ length: f - h + 1 }, (T, p) => {
|
|
593
593
|
const _ = h + p, v = r[_] || 0;
|
|
594
594
|
return {
|
|
595
595
|
level: _,
|
|
596
596
|
score: v
|
|
597
597
|
};
|
|
598
598
|
});
|
|
599
|
-
}, [
|
|
599
|
+
}, [a, r]);
|
|
600
600
|
return /* @__PURE__ */ g("div", { className: "level-selector", children: /* @__PURE__ */ g(
|
|
601
601
|
"select",
|
|
602
602
|
{
|
|
@@ -610,28 +610,28 @@ const yt = (t) => ({
|
|
|
610
610
|
"option",
|
|
611
611
|
{
|
|
612
612
|
value: h,
|
|
613
|
-
disabled: h >
|
|
613
|
+
disabled: h > c,
|
|
614
614
|
children: `${i.level} ${h} ${"★".repeat(f)}`
|
|
615
615
|
},
|
|
616
616
|
`level-${h}`
|
|
617
617
|
))
|
|
618
618
|
}
|
|
619
619
|
) });
|
|
620
|
-
},
|
|
620
|
+
}, re = ({
|
|
621
621
|
isOpen: t,
|
|
622
622
|
title: e,
|
|
623
623
|
className: n = "",
|
|
624
624
|
message: o,
|
|
625
625
|
children: i,
|
|
626
626
|
noConfirm: s = !1,
|
|
627
|
-
noCancel:
|
|
627
|
+
noCancel: a = !1,
|
|
628
628
|
confirmText: r = "OK",
|
|
629
629
|
cancelText: l = "Cancel",
|
|
630
|
-
onConfirm:
|
|
630
|
+
onConfirm: c,
|
|
631
631
|
onCancel: d
|
|
632
632
|
}) => {
|
|
633
|
-
const u =
|
|
634
|
-
return
|
|
633
|
+
const u = O(null);
|
|
634
|
+
return I(() => {
|
|
635
635
|
const h = (f) => {
|
|
636
636
|
f.key === "Escape" && d?.();
|
|
637
637
|
};
|
|
@@ -645,8 +645,8 @@ const yt = (t) => ({
|
|
|
645
645
|
children: /* @__PURE__ */ g("div", { className: "maze-dialog " + n, ref: u, children: [
|
|
646
646
|
/* @__PURE__ */ g("div", { className: "maze-dialog-title", children: e }),
|
|
647
647
|
/* @__PURE__ */ g("div", { className: "maze-dialog-content", children: i || /* @__PURE__ */ g("div", { className: "maze-dialog-message", children: o }) }),
|
|
648
|
-
(!
|
|
649
|
-
!
|
|
648
|
+
(!a || !s) && /* @__PURE__ */ g("div", { className: "maze-dialog-buttons", children: [
|
|
649
|
+
!a && /* @__PURE__ */ g(
|
|
650
650
|
"button",
|
|
651
651
|
{
|
|
652
652
|
type: "button",
|
|
@@ -660,7 +660,7 @@ const yt = (t) => ({
|
|
|
660
660
|
{
|
|
661
661
|
type: "button",
|
|
662
662
|
className: "maze-dialog-confirm",
|
|
663
|
-
onClick:
|
|
663
|
+
onClick: c,
|
|
664
664
|
children: r
|
|
665
665
|
}
|
|
666
666
|
)
|
|
@@ -668,7 +668,7 @@ const yt = (t) => ({
|
|
|
668
668
|
] })
|
|
669
669
|
}
|
|
670
670
|
);
|
|
671
|
-
},
|
|
671
|
+
}, $ = {
|
|
672
672
|
container: null,
|
|
673
673
|
// attach Toast container to element, only need to execute once
|
|
674
674
|
attachTo(t) {
|
|
@@ -698,7 +698,7 @@ const yt = (t) => ({
|
|
|
698
698
|
for (; this.container.firstChild; )
|
|
699
699
|
this.container.removeChild(this.container.firstChild);
|
|
700
700
|
}
|
|
701
|
-
},
|
|
701
|
+
}, Et = () => {
|
|
702
702
|
const {
|
|
703
703
|
gameProgress: t,
|
|
704
704
|
setGameProgress: e,
|
|
@@ -706,34 +706,34 @@ const yt = (t) => ({
|
|
|
706
706
|
setGamePlayState: o,
|
|
707
707
|
gamePlayStateRef: i,
|
|
708
708
|
resetGame: s,
|
|
709
|
-
config:
|
|
710
|
-
} =
|
|
711
|
-
const
|
|
712
|
-
|
|
713
|
-
},
|
|
714
|
-
|
|
715
|
-
r.levelGoToast.replace("%LEVEL%",
|
|
709
|
+
config: a
|
|
710
|
+
} = V(), { i18n: r, levelConfig: l } = a, c = Z(l), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = t, T = c.getTotalLevels(), [p, _] = G(!1), [v, m] = G(!1), [C, w] = G(!1), b = (F) => {
|
|
711
|
+
const D = c.getFirstLevelOfTier(F);
|
|
712
|
+
c.isLevelUnlocked(D, h) && (e((j) => ({ ...j, currentTier: F })), E(D));
|
|
713
|
+
}, E = (F) => {
|
|
714
|
+
c.isLevelUnlocked(F, h) && (e((D) => ({ ...D, currentLevel: F })), $.show(
|
|
715
|
+
r.levelGoToast.replace("%LEVEL%", F.toString()),
|
|
716
716
|
"success"
|
|
717
717
|
));
|
|
718
|
-
},
|
|
718
|
+
}, k = () => {
|
|
719
719
|
_(!0);
|
|
720
720
|
}, S = () => {
|
|
721
721
|
_(!1);
|
|
722
|
-
},
|
|
722
|
+
}, y = () => {
|
|
723
723
|
w(!0);
|
|
724
|
-
},
|
|
724
|
+
}, L = () => {
|
|
725
725
|
w(!1);
|
|
726
726
|
}, N = () => {
|
|
727
|
-
|
|
727
|
+
$.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
|
|
728
728
|
...i.current,
|
|
729
729
|
// need to sync with ref
|
|
730
730
|
showClue: !i.current.showClue
|
|
731
731
|
})), w(!1);
|
|
732
732
|
}, P = () => {
|
|
733
733
|
m(!0);
|
|
734
|
-
},
|
|
735
|
-
s(), m(!1),
|
|
736
|
-
},
|
|
734
|
+
}, x = () => {
|
|
735
|
+
s(), m(!1), $.show(r.resetDoneToast);
|
|
736
|
+
}, X = () => {
|
|
737
737
|
m(!1);
|
|
738
738
|
};
|
|
739
739
|
return /* @__PURE__ */ g("div", { class: "game-panel-container", children: [
|
|
@@ -742,14 +742,14 @@ const yt = (t) => ({
|
|
|
742
742
|
/* @__PURE__ */ g(
|
|
743
743
|
kt,
|
|
744
744
|
{
|
|
745
|
-
onTierChange:
|
|
745
|
+
onTierChange: b,
|
|
746
746
|
disabled: d
|
|
747
747
|
}
|
|
748
748
|
),
|
|
749
749
|
/* @__PURE__ */ g(
|
|
750
750
|
Tt,
|
|
751
751
|
{
|
|
752
|
-
onLevelChange:
|
|
752
|
+
onLevelChange: E,
|
|
753
753
|
disabled: d
|
|
754
754
|
}
|
|
755
755
|
)
|
|
@@ -760,14 +760,14 @@ const yt = (t) => ({
|
|
|
760
760
|
className: `settings-clue-button ${u ? "clue-on" : "clue-off"}`,
|
|
761
761
|
disabled: u,
|
|
762
762
|
title: "Toggle Clue",
|
|
763
|
-
onClick:
|
|
763
|
+
onClick: y,
|
|
764
764
|
children: u ? r.clueOn : r.clueOff
|
|
765
765
|
}
|
|
766
766
|
)
|
|
767
767
|
] }),
|
|
768
|
-
/* @__PURE__ */ g("div", { className: "game-settings", children: /* @__PURE__ */ g("span", { className: "game-settings-icon", onClick:
|
|
768
|
+
/* @__PURE__ */ g("div", { className: "game-settings", children: /* @__PURE__ */ g("span", { className: "game-settings-icon", onClick: k, children: "★ " + f }) }),
|
|
769
769
|
/* @__PURE__ */ g(
|
|
770
|
-
|
|
770
|
+
re,
|
|
771
771
|
{
|
|
772
772
|
isOpen: p,
|
|
773
773
|
title: r.settings,
|
|
@@ -776,7 +776,7 @@ const yt = (t) => ({
|
|
|
776
776
|
onCancel: S,
|
|
777
777
|
children: [
|
|
778
778
|
/* @__PURE__ */ g("div", { className: "settings-stats", children: [
|
|
779
|
-
/* @__PURE__ */ g("div", { children: r.levelComplete + `: ${h}/${
|
|
779
|
+
/* @__PURE__ */ g("div", { children: r.levelComplete + `: ${h}/${T}` }),
|
|
780
780
|
/* @__PURE__ */ g("div", { children: r.starsCollected + ": " + f }),
|
|
781
781
|
/* @__PURE__ */ g("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
|
|
782
782
|
] }),
|
|
@@ -796,93 +796,93 @@ const yt = (t) => ({
|
|
|
796
796
|
}
|
|
797
797
|
),
|
|
798
798
|
/* @__PURE__ */ g(
|
|
799
|
-
|
|
799
|
+
re,
|
|
800
800
|
{
|
|
801
801
|
isOpen: v,
|
|
802
802
|
title: r.confirmReset,
|
|
803
803
|
message: r.confirmResetMessage,
|
|
804
804
|
confirmText: r.reset,
|
|
805
805
|
cancelText: r.cancel,
|
|
806
|
-
onConfirm:
|
|
807
|
-
onCancel:
|
|
806
|
+
onConfirm: x,
|
|
807
|
+
onCancel: X
|
|
808
808
|
}
|
|
809
809
|
),
|
|
810
810
|
/* @__PURE__ */ g(
|
|
811
|
-
|
|
811
|
+
re,
|
|
812
812
|
{
|
|
813
|
-
isOpen:
|
|
813
|
+
isOpen: C,
|
|
814
814
|
title: r.confirmClue,
|
|
815
815
|
message: r.confirmClueMessage,
|
|
816
816
|
confirmText: r.confirm,
|
|
817
817
|
cancelText: r.cancel,
|
|
818
818
|
onConfirm: N,
|
|
819
|
-
onCancel:
|
|
819
|
+
onCancel: L
|
|
820
820
|
}
|
|
821
821
|
)
|
|
822
822
|
] });
|
|
823
823
|
};
|
|
824
|
-
function
|
|
824
|
+
function be(t, e) {
|
|
825
825
|
if (!(t instanceof e))
|
|
826
826
|
throw new TypeError("Cannot call a class as a function");
|
|
827
827
|
}
|
|
828
|
-
function
|
|
828
|
+
function St(t, e) {
|
|
829
829
|
for (var n = 0; n < e.length; n++) {
|
|
830
830
|
var o = e[n];
|
|
831
831
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o);
|
|
832
832
|
}
|
|
833
833
|
}
|
|
834
|
-
function
|
|
835
|
-
return e &&
|
|
834
|
+
function ke(t, e, n) {
|
|
835
|
+
return e && St(t.prototype, e), t;
|
|
836
836
|
}
|
|
837
|
-
function
|
|
837
|
+
function $e(t) {
|
|
838
838
|
return +t.replace(/px/, "");
|
|
839
839
|
}
|
|
840
|
-
function
|
|
841
|
-
var e = window.devicePixelRatio, n = getComputedStyle(t), o =
|
|
840
|
+
function zt(t) {
|
|
841
|
+
var e = window.devicePixelRatio, n = getComputedStyle(t), o = $e(n.getPropertyValue("width")), i = $e(n.getPropertyValue("height"));
|
|
842
842
|
t.setAttribute("width", (o * e).toString()), t.setAttribute("height", (i * e).toString());
|
|
843
843
|
}
|
|
844
|
-
function
|
|
844
|
+
function R(t, e) {
|
|
845
845
|
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (e - t) + t;
|
|
846
846
|
return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
|
|
847
847
|
}
|
|
848
|
-
function
|
|
849
|
-
return t[
|
|
848
|
+
function Ue(t) {
|
|
849
|
+
return t[R(0, t.length)];
|
|
850
850
|
}
|
|
851
|
-
var Nt = 125e-5,
|
|
852
|
-
function
|
|
851
|
+
var Nt = 125e-5, Lt = 5e-4, At = 9e-4, Mt = 1e-5, Pt = 6, xt = 80, It = 0.9, Ft = 1.7, Dt = 0.2, Rt = 0.6, Ot = 0.03, $t = 0.07, Ut = 15, Wt = 82, jt = 100, Gt = 250, Ht = 40, Bt = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
|
|
852
|
+
function We(t) {
|
|
853
853
|
var e = 1920;
|
|
854
854
|
return Math.log(t) / Math.log(e);
|
|
855
855
|
}
|
|
856
|
-
var
|
|
856
|
+
var je = /* @__PURE__ */ function() {
|
|
857
857
|
function t(e) {
|
|
858
|
-
|
|
859
|
-
var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors,
|
|
858
|
+
be(this, t);
|
|
859
|
+
var n = e.initialPosition, o = e.direction, i = e.confettiRadius, s = e.confettiColors, a = e.emojis, r = e.emojiSize, l = e.canvasWidth, c = R(It, Ft, 3), d = c * We(l);
|
|
860
860
|
this.confettiSpeed = {
|
|
861
861
|
x: d,
|
|
862
862
|
y: d
|
|
863
|
-
}, this.finalConfettiSpeedX =
|
|
863
|
+
}, this.finalConfettiSpeedX = R(Dt, Rt, 3), this.rotationSpeed = a.length ? 0.01 : R(Ot, $t, 3) * We(l), this.dragForceCoefficient = R(Lt, At, 6), this.radius = {
|
|
864
864
|
x: i,
|
|
865
865
|
y: i
|
|
866
|
-
}, this.initialRadius = i, this.rotationAngle = o === "left" ?
|
|
867
|
-
var u = o === "left" ?
|
|
866
|
+
}, this.initialRadius = i, this.rotationAngle = o === "left" ? R(0, 0.2, 3) : R(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = R(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
|
|
867
|
+
var u = o === "left" ? R(Wt, Ut) * Math.PI / 180 : R(-15, -82) * Math.PI / 180;
|
|
868
868
|
this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
|
|
869
|
-
var h =
|
|
869
|
+
var h = R(-150, 0), f = {
|
|
870
870
|
x: n.x + (o === "left" ? -h : h) * this.absCos,
|
|
871
871
|
y: n.y - h * this.absSin
|
|
872
872
|
};
|
|
873
|
-
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color =
|
|
873
|
+
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = a.length ? null : Ue(s), this.emoji = a.length ? Ue(a) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
|
|
874
874
|
}
|
|
875
|
-
return
|
|
875
|
+
return ke(t, [{
|
|
876
876
|
key: "draw",
|
|
877
877
|
value: function(n) {
|
|
878
|
-
var o = this.currentPosition, i = this.radius, s = this.color,
|
|
879
|
-
s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) :
|
|
878
|
+
var o = this.currentPosition, i = this.radius, s = this.color, a = this.emoji, r = this.rotationAngle, l = this.emojiRotationAngle, c = this.emojiSize, d = window.devicePixelRatio;
|
|
879
|
+
s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : a && (n.font = "".concat(c, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(l), n.textAlign = "center", n.fillText(a, 0, 0), n.restore());
|
|
880
880
|
}
|
|
881
881
|
}, {
|
|
882
882
|
key: "updatePosition",
|
|
883
883
|
value: function(n, o) {
|
|
884
|
-
var i = this.confettiSpeed, s = this.dragForceCoefficient,
|
|
885
|
-
if (i.x >
|
|
884
|
+
var i = this.confettiSpeed, s = this.dragForceCoefficient, a = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, l = this.rotationSpeed, c = this.createdAt, d = this.direction, u = o - c;
|
|
885
|
+
if (i.x > a && (this.confettiSpeed.x -= s * n), this.currentPosition.x += i.x * (d === "left" ? -this.absCos : this.absCos) * n, this.currentPosition.y = this.initialPosition.y - i.y * this.absSin * u + Nt * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : Mt * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
|
|
886
886
|
this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
|
|
887
887
|
return;
|
|
888
888
|
}
|
|
@@ -895,28 +895,28 @@ var Ue = /* @__PURE__ */ function() {
|
|
|
895
895
|
}
|
|
896
896
|
}]), t;
|
|
897
897
|
}();
|
|
898
|
-
function
|
|
898
|
+
function qt() {
|
|
899
899
|
var t = document.createElement("canvas");
|
|
900
900
|
return t.style.position = "fixed", t.style.width = "100%", t.style.height = "100%", t.style.top = "0", t.style.left = "0", t.style.zIndex = "1000", t.style.pointerEvents = "none", document.body.appendChild(t), t;
|
|
901
901
|
}
|
|
902
902
|
function Vt(t) {
|
|
903
|
-
var e = t.confettiRadius, n = e === void 0 ? Pt : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? Ht : Gt) : o, s = t.confettiColors,
|
|
903
|
+
var e = t.confettiRadius, n = e === void 0 ? Pt : e, o = t.confettiNumber, i = o === void 0 ? t.confettiesNumber || (t.emojis ? Ht : Gt) : o, s = t.confettiColors, a = s === void 0 ? Bt : s, r = t.emojis, l = r === void 0 ? t.emojies || [] : r, c = t.emojiSize, d = c === void 0 ? xt : c;
|
|
904
904
|
return t.emojies && console.error("emojies argument is deprecated, please use emojis instead"), t.confettiesNumber && console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"), {
|
|
905
905
|
confettiRadius: n,
|
|
906
906
|
confettiNumber: i,
|
|
907
|
-
confettiColors:
|
|
907
|
+
confettiColors: a,
|
|
908
908
|
emojis: l,
|
|
909
909
|
emojiSize: d
|
|
910
910
|
};
|
|
911
911
|
}
|
|
912
|
-
var
|
|
912
|
+
var Xt = /* @__PURE__ */ function() {
|
|
913
913
|
function t(e) {
|
|
914
914
|
var n = this;
|
|
915
|
-
|
|
915
|
+
be(this, t), this.canvasContext = e, this.shapes = [], this.promise = new Promise(function(o) {
|
|
916
916
|
return n.resolvePromise = o;
|
|
917
917
|
});
|
|
918
918
|
}
|
|
919
|
-
return
|
|
919
|
+
return ke(t, [{
|
|
920
920
|
key: "getBatchCompletePromise",
|
|
921
921
|
value: function() {
|
|
922
922
|
return this.promise;
|
|
@@ -936,27 +936,27 @@ var Yt = /* @__PURE__ */ function() {
|
|
|
936
936
|
}, {
|
|
937
937
|
key: "processShapes",
|
|
938
938
|
value: function(n, o, i) {
|
|
939
|
-
var s = this,
|
|
939
|
+
var s = this, a = n.timeDelta, r = n.currentTime;
|
|
940
940
|
this.shapes = this.shapes.filter(function(l) {
|
|
941
|
-
return l.updatePosition(
|
|
941
|
+
return l.updatePosition(a, r), l.draw(s.canvasContext), i ? l.getIsVisibleOnCanvas(o) : !0;
|
|
942
942
|
});
|
|
943
943
|
}
|
|
944
944
|
}]), t;
|
|
945
|
-
}(),
|
|
945
|
+
}(), Yt = /* @__PURE__ */ function() {
|
|
946
946
|
function t() {
|
|
947
947
|
var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
948
|
-
|
|
948
|
+
be(this, t), this.activeConfettiBatches = [], this.canvas = e.canvas || qt(), this.canvasContext = this.canvas.getContext("2d"), this.requestAnimationFrameRequested = !1, this.lastUpdated = (/* @__PURE__ */ new Date()).getTime(), this.iterationIndex = 0, this.loop = this.loop.bind(this), requestAnimationFrame(this.loop);
|
|
949
949
|
}
|
|
950
|
-
return
|
|
950
|
+
return ke(t, [{
|
|
951
951
|
key: "loop",
|
|
952
952
|
value: function() {
|
|
953
|
-
this.requestAnimationFrameRequested = !1,
|
|
953
|
+
this.requestAnimationFrameRequested = !1, zt(this.canvas);
|
|
954
954
|
var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
|
|
955
|
-
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(
|
|
956
|
-
return
|
|
955
|
+
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(a) {
|
|
956
|
+
return a.processShapes({
|
|
957
957
|
timeDelta: o,
|
|
958
958
|
currentTime: n
|
|
959
|
-
}, i, s), s ? !
|
|
959
|
+
}, i, s), s ? !a.complete() : !0;
|
|
960
960
|
}), this.iterationIndex++, this.queueAnimationFrameIfNeeded(n);
|
|
961
961
|
}
|
|
962
962
|
}, {
|
|
@@ -967,27 +967,27 @@ var Yt = /* @__PURE__ */ function() {
|
|
|
967
967
|
}, {
|
|
968
968
|
key: "addConfetti",
|
|
969
969
|
value: function() {
|
|
970
|
-
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = Vt(n), i = o.confettiRadius, s = o.confettiNumber,
|
|
970
|
+
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = Vt(n), i = o.confettiRadius, s = o.confettiNumber, a = o.confettiColors, r = o.emojis, l = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
|
|
971
971
|
x: 0,
|
|
972
972
|
y: h
|
|
973
|
-
},
|
|
973
|
+
}, T = {
|
|
974
974
|
x: d,
|
|
975
975
|
y: h
|
|
976
|
-
}, p = new
|
|
977
|
-
var v = new
|
|
976
|
+
}, p = new Xt(this.canvasContext), _ = 0; _ < s / 2; _++) {
|
|
977
|
+
var v = new je({
|
|
978
978
|
initialPosition: f,
|
|
979
979
|
direction: "right",
|
|
980
980
|
confettiRadius: i,
|
|
981
|
-
confettiColors:
|
|
981
|
+
confettiColors: a,
|
|
982
982
|
confettiNumber: s,
|
|
983
983
|
emojis: r,
|
|
984
984
|
emojiSize: l,
|
|
985
985
|
canvasWidth: d
|
|
986
|
-
}), m = new
|
|
987
|
-
initialPosition:
|
|
986
|
+
}), m = new je({
|
|
987
|
+
initialPosition: T,
|
|
988
988
|
direction: "left",
|
|
989
989
|
confettiRadius: i,
|
|
990
|
-
confettiColors:
|
|
990
|
+
confettiColors: a,
|
|
991
991
|
confettiNumber: s,
|
|
992
992
|
emojis: r,
|
|
993
993
|
emojiSize: l,
|
|
@@ -1009,87 +1009,87 @@ var Yt = /* @__PURE__ */ function() {
|
|
|
1009
1009
|
}
|
|
1010
1010
|
}]), t;
|
|
1011
1011
|
}();
|
|
1012
|
-
const Kt = new
|
|
1012
|
+
const Kt = new Yt(), Jt = ({ onRetry: t }) => {
|
|
1013
1013
|
const {
|
|
1014
1014
|
config: e,
|
|
1015
1015
|
currentScore: n,
|
|
1016
1016
|
gamePlayState: o,
|
|
1017
1017
|
setGamePlayState: i,
|
|
1018
1018
|
gameProgress: s,
|
|
1019
|
-
setGameProgress:
|
|
1020
|
-
} =
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
}, [
|
|
1024
|
-
const
|
|
1025
|
-
m(!1),
|
|
1026
|
-
},
|
|
1027
|
-
m(!1), i((
|
|
1028
|
-
...
|
|
1019
|
+
setGameProgress: a
|
|
1020
|
+
} = V(), { i18n: r, levelConfig: l } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: T, levelTransitioning: p } = o, { currentLevel: _ } = s, [v, m] = G(!1);
|
|
1021
|
+
I(() => {
|
|
1022
|
+
T && p && (Kt.addConfetti(), $.show(r.levelCompleteToast, "success"), m(!0));
|
|
1023
|
+
}, [T, p]);
|
|
1024
|
+
const C = Z(l), w = C.getTotalLevels(), b = q(() => _ >= w, [_, w]), E = () => {
|
|
1025
|
+
m(!1), $.show(r.levelRestartToast, "info"), t?.();
|
|
1026
|
+
}, k = () => {
|
|
1027
|
+
m(!1), i((y) => ({
|
|
1028
|
+
...y,
|
|
1029
1029
|
isGameActive: !0,
|
|
1030
1030
|
levelTransitioning: !1
|
|
1031
1031
|
}));
|
|
1032
1032
|
}, S = () => {
|
|
1033
1033
|
m(!1);
|
|
1034
|
-
const
|
|
1035
|
-
if (!
|
|
1036
|
-
const { nextLevel:
|
|
1037
|
-
P &&
|
|
1034
|
+
const y = C.getNextLevelInfo(_);
|
|
1035
|
+
if (!y) return;
|
|
1036
|
+
const { nextLevel: L, nextTier: N, isTierChange: P } = y;
|
|
1037
|
+
P && $.show(
|
|
1038
1038
|
r.tierUnlockedToast.replace("%TIER%", N.toString()),
|
|
1039
1039
|
"success"
|
|
1040
|
-
),
|
|
1041
|
-
...
|
|
1042
|
-
currentLevel:
|
|
1040
|
+
), a((x) => ({
|
|
1041
|
+
...x,
|
|
1042
|
+
currentLevel: L,
|
|
1043
1043
|
currentTier: N,
|
|
1044
|
-
highestUnlockedLevel: Math.max(
|
|
1045
|
-
highestUnlockedTier: Math.max(
|
|
1044
|
+
highestUnlockedLevel: Math.max(x.highestUnlockedLevel, L),
|
|
1045
|
+
highestUnlockedTier: Math.max(x.highestUnlockedTier, N),
|
|
1046
1046
|
levelScores: {
|
|
1047
|
-
...
|
|
1048
|
-
[
|
|
1047
|
+
...x.levelScores,
|
|
1048
|
+
[x.currentLevel]: Math.max(
|
|
1049
1049
|
Object.values(n).filter(Boolean).length,
|
|
1050
|
-
|
|
1050
|
+
x.levelScores[x.currentLevel] || 0
|
|
1051
1051
|
)
|
|
1052
1052
|
}
|
|
1053
1053
|
}));
|
|
1054
1054
|
};
|
|
1055
1055
|
return /* @__PURE__ */ g(
|
|
1056
|
-
|
|
1056
|
+
re,
|
|
1057
1057
|
{
|
|
1058
1058
|
className: "level-complete-dialog",
|
|
1059
1059
|
isOpen: v,
|
|
1060
1060
|
title: r.congratulations,
|
|
1061
1061
|
cancelText: r.retry,
|
|
1062
|
-
onCancel:
|
|
1062
|
+
onCancel: E,
|
|
1063
1063
|
noConfirm: !!d,
|
|
1064
1064
|
confirmText: r.continue,
|
|
1065
|
-
onConfirm:
|
|
1065
|
+
onConfirm: k,
|
|
1066
1066
|
children: [
|
|
1067
1067
|
/* @__PURE__ */ g("div", { className: "maze-summary-message", children: [
|
|
1068
|
-
!!
|
|
1068
|
+
!!c && /* @__PURE__ */ g("div", { children: "★ - " + r.findYourExit }),
|
|
1069
1069
|
/* @__PURE__ */ g("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
|
|
1070
1070
|
/* @__PURE__ */ g("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
|
|
1071
1071
|
] }),
|
|
1072
|
-
|
|
1073
|
-
/* @__PURE__ */ g("div", { className: "go-next-level", children:
|
|
1072
|
+
b && /* @__PURE__ */ g("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
|
|
1073
|
+
/* @__PURE__ */ g("div", { className: "go-next-level", children: b ? "OK" : /* @__PURE__ */ g("button", { type: "button", onClick: S, children: r.nextLevel }) }),
|
|
1074
1074
|
!d && /* @__PURE__ */ g("div", { className: "not-all-stars-collected", children: r.continueMessage })
|
|
1075
1075
|
]
|
|
1076
1076
|
}
|
|
1077
1077
|
);
|
|
1078
1078
|
}, Zt = (t, e) => {
|
|
1079
|
-
const n =
|
|
1079
|
+
const n = O({
|
|
1080
1080
|
canvasWidth: 0,
|
|
1081
1081
|
canvasHeight: 0
|
|
1082
1082
|
});
|
|
1083
|
-
return
|
|
1083
|
+
return I(() => {
|
|
1084
1084
|
const o = () => {
|
|
1085
1085
|
const s = t.current;
|
|
1086
1086
|
if (!s) return;
|
|
1087
|
-
const
|
|
1088
|
-
if (!
|
|
1089
|
-
const r =
|
|
1087
|
+
const a = s.parentElement;
|
|
1088
|
+
if (!a) return;
|
|
1089
|
+
const r = a.clientWidth, l = window.devicePixelRatio || 1;
|
|
1090
1090
|
s.style.width = `${r}px`, s.style.height = `${r}px`;
|
|
1091
|
-
const
|
|
1092
|
-
s.width =
|
|
1091
|
+
const c = r * l, d = r * l;
|
|
1092
|
+
s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d }, e?.();
|
|
1093
1093
|
};
|
|
1094
1094
|
o();
|
|
1095
1095
|
let i = null;
|
|
@@ -1101,23 +1101,23 @@ const Kt = new Xt(), Jt = ({ onRetry: t }) => {
|
|
|
1101
1101
|
const {
|
|
1102
1102
|
config: e,
|
|
1103
1103
|
gamePlayState: { maze: n }
|
|
1104
|
-
} =
|
|
1105
|
-
return
|
|
1104
|
+
} = V(), o = O({ cellWidth: 0, cellHeight: 0 });
|
|
1105
|
+
return I(() => {
|
|
1106
1106
|
const i = e.renderConfig.padding, s = () => {
|
|
1107
1107
|
const r = t.current;
|
|
1108
1108
|
if (!r || !n) return;
|
|
1109
|
-
const { rows: l, cols:
|
|
1110
|
-
if (l <= 0 ||
|
|
1111
|
-
const d = (r.width - i * 2) /
|
|
1109
|
+
const { rows: l, cols: c } = n;
|
|
1110
|
+
if (l <= 0 || c <= 0) return;
|
|
1111
|
+
const d = (r.width - i * 2) / c, u = (r.height - i * 2) / l;
|
|
1112
1112
|
o.current = { cellWidth: d, cellHeight: u };
|
|
1113
1113
|
};
|
|
1114
1114
|
s();
|
|
1115
|
-
let
|
|
1116
|
-
return t.current && window.ResizeObserver && (
|
|
1117
|
-
t.current &&
|
|
1115
|
+
let a = null;
|
|
1116
|
+
return t.current && window.ResizeObserver && (a = new ResizeObserver(s), a.observe(t.current)), () => {
|
|
1117
|
+
t.current && a?.disconnect();
|
|
1118
1118
|
};
|
|
1119
1119
|
}, [t, n]), o;
|
|
1120
|
-
},
|
|
1120
|
+
}, ee = {
|
|
1121
1121
|
ArrowUp: [-1, 0],
|
|
1122
1122
|
ArrowDown: [1, 0],
|
|
1123
1123
|
ArrowLeft: [0, -1],
|
|
@@ -1128,51 +1128,54 @@ const Kt = new Xt(), Jt = ({ onRetry: t }) => {
|
|
|
1128
1128
|
setGamePlayState: n,
|
|
1129
1129
|
moveSpeed: o,
|
|
1130
1130
|
// move X grid units per frame, default 0.03
|
|
1131
|
-
|
|
1131
|
+
moveSpeedRef: i,
|
|
1132
|
+
// alternative: ref to move speed for dynamic updates
|
|
1133
|
+
playerRadius: s,
|
|
1132
1134
|
// player radius in grid unit, default 0.2
|
|
1133
|
-
|
|
1134
|
-
getCellSizeInPixels: c,
|
|
1135
|
-
onFoodCollected: r
|
|
1135
|
+
onFoodCollected: a
|
|
1136
1136
|
}) => {
|
|
1137
|
-
const l =
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1137
|
+
const r = () => i?.current ?? o ?? 0.03, l = O(!1), c = O(/* @__PURE__ */ new Set()), d = Fe(
|
|
1138
|
+
(_, v) => {
|
|
1139
|
+
const m = e.current;
|
|
1140
|
+
if (!m.maze)
|
|
1141
|
+
return { canMove: !1, newCell: null };
|
|
1142
|
+
const C = r(), [w, b] = ee[_];
|
|
1143
|
+
if (Ge(
|
|
1144
|
+
v,
|
|
1145
|
+
w,
|
|
1146
|
+
b,
|
|
1147
|
+
s,
|
|
1148
|
+
C,
|
|
1149
|
+
m.maze
|
|
1150
|
+
))
|
|
1151
|
+
return { canMove: !1, newCell: null };
|
|
1152
|
+
const { row: k, col: S } = v, y = k + w * C, L = S + b * C, N = -0.5, P = m.maze.rows, x = m.maze.cols;
|
|
1153
|
+
if (y < N || y >= P || L < N || L >= x)
|
|
1154
|
+
return { canMove: !1, newCell: null };
|
|
1155
|
+
const X = k < 0 ? 0 : Math.floor(k), F = S < 0 ? 0 : Math.floor(S), D = y < 0 ? 0 : Math.floor(y), j = L < 0 ? 0 : Math.floor(L);
|
|
1156
|
+
return D !== X || j !== F ? m.maze.isValid(D, j) ? {
|
|
1157
|
+
canMove: !0,
|
|
1158
|
+
newCell: { row: D, col: j }
|
|
1159
|
+
} : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
|
|
1160
|
+
},
|
|
1161
|
+
[s, r]
|
|
1162
|
+
), u = () => {
|
|
1163
|
+
const _ = e.current, { row: v, col: m } = _.playerCell, C = s * 2, w = _.foodCells.findIndex((k) => Math.sqrt(
|
|
1164
|
+
Math.pow(v - k.row, 2) + Math.pow(m - k.col, 2)
|
|
1165
|
+
) < C);
|
|
1166
|
+
w !== -1 && a && (a(), e.current = {
|
|
1161
1167
|
...e.current,
|
|
1162
1168
|
foodCollected: e.current.foodCollected + 1,
|
|
1163
1169
|
foodCells: e.current.foodCells.filter(
|
|
1164
|
-
(
|
|
1170
|
+
(k, S) => S !== w
|
|
1165
1171
|
)
|
|
1166
1172
|
});
|
|
1167
|
-
const
|
|
1173
|
+
const E = on(
|
|
1168
1174
|
_.playerCell,
|
|
1169
1175
|
_.exitCell,
|
|
1170
|
-
_.maze
|
|
1171
|
-
i,
|
|
1172
|
-
s,
|
|
1173
|
-
c
|
|
1176
|
+
_.maze
|
|
1174
1177
|
);
|
|
1175
|
-
|
|
1178
|
+
E && !e.current.playerAtExit ? (e.current = {
|
|
1176
1179
|
...e.current,
|
|
1177
1180
|
playerAtExit: !0,
|
|
1178
1181
|
isGameActive: !1,
|
|
@@ -1183,119 +1186,127 @@ const Kt = new Xt(), Jt = ({ onRetry: t }) => {
|
|
|
1183
1186
|
n(() => ({ ...e.current }));
|
|
1184
1187
|
},
|
|
1185
1188
|
{ timeout: 10 }
|
|
1186
|
-
)) : !
|
|
1189
|
+
)) : !E && e.current.playerAtExit && (e.current = {
|
|
1187
1190
|
...e.current,
|
|
1188
1191
|
playerAtExit: !1,
|
|
1189
1192
|
isGameActive: !0,
|
|
1190
1193
|
levelTransitioning: !1
|
|
1191
1194
|
});
|
|
1192
1195
|
}, h = (_) => {
|
|
1193
|
-
const v = e.current, m = Math.round(_.row),
|
|
1194
|
-
if ((
|
|
1195
|
-
const
|
|
1196
|
+
const v = e.current, m = Math.round(_.row), C = Math.round(_.col), w = v.playerPath[v.playerPath.length - 1], b = w.row === m && w.col === C, E = Math.abs(w.row - m), k = Math.abs(w.col - C);
|
|
1197
|
+
if ((E === 1 && k === 0 || E === 0 && k === 1) && !b) {
|
|
1198
|
+
const y = `${w.row},${w.col}-${m},${C}`;
|
|
1196
1199
|
e.current = {
|
|
1197
1200
|
...e.current,
|
|
1198
1201
|
playerPath: [
|
|
1199
1202
|
...e.current.playerPath,
|
|
1200
|
-
{ row: m, col:
|
|
1203
|
+
{ row: m, col: C }
|
|
1201
1204
|
],
|
|
1202
1205
|
visitCounts: {
|
|
1203
1206
|
...e.current.visitCounts,
|
|
1204
|
-
[
|
|
1207
|
+
[y]: (e.current.visitCounts[y] || 0) + 1
|
|
1205
1208
|
}
|
|
1206
1209
|
};
|
|
1207
1210
|
}
|
|
1208
1211
|
}, f = () => {
|
|
1209
|
-
if (l.current ||
|
|
1212
|
+
if (l.current || c.current.size === 0) return;
|
|
1210
1213
|
const _ = e.current;
|
|
1211
|
-
!_.playerCell || !Array.from(
|
|
1214
|
+
!_.playerCell || !Array.from(c.current).some(
|
|
1212
1215
|
(m) => {
|
|
1213
|
-
const { canMove:
|
|
1216
|
+
const { canMove: C } = d(
|
|
1214
1217
|
m,
|
|
1215
1218
|
_.playerCell
|
|
1216
1219
|
);
|
|
1217
|
-
return
|
|
1220
|
+
return C;
|
|
1218
1221
|
}
|
|
1219
1222
|
) || (l.current = !0);
|
|
1220
1223
|
};
|
|
1221
|
-
|
|
1222
|
-
const _ = (
|
|
1223
|
-
(
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
k.
|
|
1232
|
-
|
|
1233
|
-
|
|
1224
|
+
I(() => {
|
|
1225
|
+
const _ = (b) => {
|
|
1226
|
+
if (b.key === "ArrowUp" || b.key === "ArrowDown" || b.key === "ArrowLeft" || b.key === "ArrowRight" || b.key === " ") {
|
|
1227
|
+
const E = document.activeElement;
|
|
1228
|
+
if (E && (E.tagName === "INPUT" || E.tagName === "TEXTAREA" || E.getAttribute("contenteditable") === "true")) return;
|
|
1229
|
+
b.preventDefault();
|
|
1230
|
+
}
|
|
1231
|
+
}, v = (b) => {
|
|
1232
|
+
const E = b.key;
|
|
1233
|
+
if (!(E in ee)) return;
|
|
1234
|
+
const k = document.activeElement;
|
|
1235
|
+
k && (k.tagName === "INPUT" || k.tagName === "TEXTAREA" || k.getAttribute("contenteditable") === "true") || (b.preventDefault(), e.current.isGameActive && (c.current.has(E) || (c.current.add(E), l.current || f())));
|
|
1236
|
+
}, m = (b) => {
|
|
1237
|
+
const E = b.key;
|
|
1238
|
+
if (!(E in ee)) return;
|
|
1239
|
+
const k = document.activeElement;
|
|
1240
|
+
k && (k.tagName === "INPUT" || k.tagName === "TEXTAREA" || k.getAttribute("contenteditable") === "true") || (b.preventDefault(), c.current.delete(E), c.current.size === 0 && p());
|
|
1241
|
+
}, C = (b) => {
|
|
1242
|
+
b.preventDefault();
|
|
1243
|
+
const E = e.current;
|
|
1244
|
+
if (!E.isGameActive || !E.maze || l.current)
|
|
1234
1245
|
return;
|
|
1235
|
-
const
|
|
1236
|
-
let
|
|
1237
|
-
S && (S.classList.contains("maze-up") ?
|
|
1246
|
+
const k = b.touches[0], S = document.elementFromPoint(k.clientX, k.clientY);
|
|
1247
|
+
let y = null;
|
|
1248
|
+
S && (S.classList.contains("maze-up") ? y = "ArrowUp" : S.classList.contains("maze-down") ? y = "ArrowDown" : S.classList.contains("maze-left") ? y = "ArrowLeft" : S.classList.contains("maze-right") && (y = "ArrowRight")), y && (c.current.clear(), c.current.add(y), f());
|
|
1238
1249
|
}, w = () => {
|
|
1239
1250
|
p();
|
|
1240
1251
|
};
|
|
1241
1252
|
return window.addEventListener("keydown", _, {
|
|
1242
1253
|
capture: !0
|
|
1243
|
-
}), window.addEventListener("keydown", v), window.addEventListener("keyup", m), t.current?.addEventListener("touchstart",
|
|
1254
|
+
}), window.addEventListener("keydown", v), window.addEventListener("keyup", m), t.current?.addEventListener("touchstart", C, {
|
|
1244
1255
|
passive: !1
|
|
1245
1256
|
}), t.current?.addEventListener("touchend", w), () => {
|
|
1246
1257
|
window.removeEventListener("keydown", _, {
|
|
1247
1258
|
capture: !0
|
|
1248
|
-
}), window.removeEventListener("keydown", v), window.removeEventListener("keyup", m), t.current?.removeEventListener("touchstart",
|
|
1259
|
+
}), window.removeEventListener("keydown", v), window.removeEventListener("keyup", m), t.current?.removeEventListener("touchstart", C), t.current?.removeEventListener("touchend", w);
|
|
1249
1260
|
};
|
|
1250
1261
|
}, []);
|
|
1251
|
-
const
|
|
1252
|
-
if (!l.current ||
|
|
1262
|
+
const T = Fe(() => {
|
|
1263
|
+
if (!l.current || c.current.size === 0)
|
|
1253
1264
|
return e.current.playerCell;
|
|
1254
|
-
const _ = e.current.playerCell;
|
|
1255
|
-
let
|
|
1256
|
-
for (const
|
|
1257
|
-
const { canMove:
|
|
1258
|
-
if (
|
|
1259
|
-
const [
|
|
1260
|
-
|
|
1265
|
+
const _ = r(), v = e.current.playerCell;
|
|
1266
|
+
let m = 0, C = 0, w = 0;
|
|
1267
|
+
for (const Y of c.current) {
|
|
1268
|
+
const { canMove: he } = d(Y, v);
|
|
1269
|
+
if (he) {
|
|
1270
|
+
const [Te, lt] = ee[Y];
|
|
1271
|
+
m += Te, C += lt, w++;
|
|
1261
1272
|
}
|
|
1262
1273
|
}
|
|
1263
|
-
if (
|
|
1274
|
+
if (w === 0)
|
|
1264
1275
|
return e.current.playerCell;
|
|
1265
|
-
const
|
|
1266
|
-
(
|
|
1267
|
-
),
|
|
1268
|
-
(
|
|
1269
|
-
),
|
|
1270
|
-
if (
|
|
1271
|
-
const
|
|
1272
|
-
if (
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1276
|
+
const b = Math.sqrt(m * m + C * C), E = b > 0 ? m / b : 0, k = b > 0 ? C / b : 0, S = Number(
|
|
1277
|
+
(v.row + E * _).toFixed(2)
|
|
1278
|
+
), y = Number(
|
|
1279
|
+
(v.col + k * _).toFixed(2)
|
|
1280
|
+
), L = S - v.row, N = y - v.col, P = Math.sqrt(L * L + N * N);
|
|
1281
|
+
if (P > 0) {
|
|
1282
|
+
const Y = L / P, he = N / P;
|
|
1283
|
+
if (Ge(
|
|
1284
|
+
v,
|
|
1285
|
+
Y,
|
|
1286
|
+
he,
|
|
1287
|
+
s,
|
|
1288
|
+
P,
|
|
1278
1289
|
e.current.maze
|
|
1279
1290
|
))
|
|
1280
1291
|
return e.current.playerCell;
|
|
1281
1292
|
}
|
|
1282
1293
|
e.current.playerCell = {
|
|
1283
|
-
row:
|
|
1284
|
-
col:
|
|
1294
|
+
row: S,
|
|
1295
|
+
col: y
|
|
1285
1296
|
}, u();
|
|
1286
|
-
const
|
|
1287
|
-
return (
|
|
1288
|
-
}, [
|
|
1289
|
-
l.current = !1,
|
|
1297
|
+
const x = v.row < 0 ? 0 : Math.round(v.row), X = v.col < 0 ? 0 : Math.round(v.col), F = S < 0 ? 0 : Math.round(S), D = y < 0 ? 0 : Math.round(y);
|
|
1298
|
+
return (F !== x || D !== X) && h({ row: F, col: D }), e.current.playerCell;
|
|
1299
|
+
}, [r, d]), p = () => {
|
|
1300
|
+
l.current = !1, c.current.clear();
|
|
1290
1301
|
};
|
|
1291
1302
|
return {
|
|
1292
|
-
updatePlayerPos:
|
|
1303
|
+
updatePlayerPos: T,
|
|
1293
1304
|
resetMovingState: p
|
|
1294
1305
|
};
|
|
1295
1306
|
};
|
|
1296
|
-
function
|
|
1297
|
-
const
|
|
1298
|
-
|
|
1307
|
+
function Ge(t, e, n, o, i, s) {
|
|
1308
|
+
const a = t.row + e * i, r = t.col + n * i, l = { row: a, col: r }, c = [], d = t.row < 0 ? 0 : Math.floor(t.row), u = t.col < 0 ? 0 : Math.floor(t.col);
|
|
1309
|
+
c.push({ row: d, col: u });
|
|
1299
1310
|
const h = [
|
|
1300
1311
|
[-1, 0],
|
|
1301
1312
|
// up
|
|
@@ -1314,14 +1325,14 @@ function We(t, e, n, o, i, s) {
|
|
|
1314
1325
|
[1, 1]
|
|
1315
1326
|
// lower right, diagonal
|
|
1316
1327
|
];
|
|
1317
|
-
for (const [f,
|
|
1318
|
-
const p = d + f, _ = u +
|
|
1319
|
-
s.isValid(p, _) &&
|
|
1328
|
+
for (const [f, T] of h) {
|
|
1329
|
+
const p = d + f, _ = u + T;
|
|
1330
|
+
s.isValid(p, _) && c.push({ row: p, col: _ });
|
|
1320
1331
|
}
|
|
1321
|
-
for (const f of
|
|
1322
|
-
const
|
|
1323
|
-
for (const p of
|
|
1324
|
-
if (
|
|
1332
|
+
for (const f of c) {
|
|
1333
|
+
const T = tn(f.row, f.col, s);
|
|
1334
|
+
for (const p of T)
|
|
1335
|
+
if (nn(l, p) < o)
|
|
1325
1336
|
return !0;
|
|
1326
1337
|
}
|
|
1327
1338
|
return !1;
|
|
@@ -1342,158 +1353,140 @@ function tn(t, e, n) {
|
|
|
1342
1353
|
end: { row: t + 0.5, col: e - 0.5 }
|
|
1343
1354
|
}), o;
|
|
1344
1355
|
}
|
|
1345
|
-
function
|
|
1346
|
-
const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row,
|
|
1356
|
+
function nn(t, e) {
|
|
1357
|
+
const { start: n, end: o } = e, i = o.col - n.col, s = o.row - n.row, a = t.col - n.col, r = t.row - n.row, l = i * i + s * s;
|
|
1347
1358
|
if (l === 0)
|
|
1348
|
-
return Math.sqrt(
|
|
1349
|
-
const
|
|
1359
|
+
return Math.sqrt(a * a + r * r);
|
|
1360
|
+
const c = Math.max(
|
|
1350
1361
|
0,
|
|
1351
1362
|
Math.min(
|
|
1352
1363
|
1,
|
|
1353
|
-
(
|
|
1364
|
+
(a * i + r * s) / l
|
|
1354
1365
|
)
|
|
1355
|
-
), d = n.col +
|
|
1366
|
+
), d = n.col + c * i, u = n.row + c * s, h = t.col - d, f = t.row - u;
|
|
1356
1367
|
return Math.sqrt(h * h + f * f);
|
|
1357
1368
|
}
|
|
1358
|
-
function
|
|
1359
|
-
if (
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
if (n.grid[e.row][e.col].walls.bottom) {
|
|
1363
|
-
let l = 0;
|
|
1364
|
-
if (s && i) {
|
|
1365
|
-
const h = s();
|
|
1366
|
-
l = i / h;
|
|
1367
|
-
} else
|
|
1368
|
-
l = (i || 3) / 100;
|
|
1369
|
-
const a = l * 0.5, d = {
|
|
1370
|
-
start: { row: e.row + 0.5 - a, col: e.col - 0.5 },
|
|
1371
|
-
end: { row: e.row + 0.5 - a, col: e.col + 0.5 }
|
|
1372
|
-
};
|
|
1373
|
-
if (rt(
|
|
1374
|
-
t,
|
|
1375
|
-
d
|
|
1376
|
-
) <= o * 1.5)
|
|
1377
|
-
return !0;
|
|
1378
|
-
}
|
|
1379
|
-
return !1;
|
|
1369
|
+
function on(t, e, n) {
|
|
1370
|
+
if (!n.isValid(e.row, e.col)) return !1;
|
|
1371
|
+
const o = t.col >= e.col - 0.5 && t.col <= e.col + 0.5, i = t.row >= e.row + 0.5, s = t.row >= e.row - 0.5;
|
|
1372
|
+
return o && i && s;
|
|
1380
1373
|
}
|
|
1381
|
-
function
|
|
1374
|
+
function rn(t, e, n, o, i) {
|
|
1382
1375
|
if (!t || !e.maze) return;
|
|
1383
|
-
const { canvasWidth: s, canvasHeight:
|
|
1384
|
-
maze:
|
|
1376
|
+
const { canvasWidth: s, canvasHeight: a } = n, { cellWidth: r, cellHeight: l } = o, {
|
|
1377
|
+
maze: c,
|
|
1385
1378
|
playerCell: d,
|
|
1386
1379
|
// row, col, but floating allowed
|
|
1387
1380
|
exitCell: u,
|
|
1388
1381
|
foodCells: h,
|
|
1389
1382
|
showClue: f,
|
|
1390
|
-
playerPath:
|
|
1383
|
+
playerPath: T,
|
|
1391
1384
|
visitCounts: p
|
|
1392
1385
|
} = e, {
|
|
1393
1386
|
padding: _,
|
|
1394
1387
|
wallWidth: v,
|
|
1395
1388
|
// need merge with level config when passed here
|
|
1396
1389
|
wallColor: m,
|
|
1397
|
-
playerColor:
|
|
1390
|
+
playerColor: C,
|
|
1398
1391
|
playerRadius: w,
|
|
1399
|
-
foodColor:
|
|
1400
|
-
backgroundColor:
|
|
1401
|
-
clueColor:
|
|
1392
|
+
foodColor: b,
|
|
1393
|
+
backgroundColor: E,
|
|
1394
|
+
clueColor: k,
|
|
1402
1395
|
exitColor: S,
|
|
1403
|
-
exitWallWidth:
|
|
1404
|
-
exitDashArray:
|
|
1396
|
+
exitWallWidth: y,
|
|
1397
|
+
exitDashArray: L
|
|
1405
1398
|
} = i;
|
|
1406
|
-
t.clearRect(0, 0, s,
|
|
1399
|
+
t.clearRect(0, 0, s, a), t.save(), t.fillStyle = E, t.fillRect(0, 0, s, a), t.restore(), f && dn({
|
|
1407
1400
|
ctx: t,
|
|
1408
|
-
playerPath:
|
|
1401
|
+
playerPath: T,
|
|
1409
1402
|
visitCounts: p,
|
|
1410
1403
|
cellWidth: r,
|
|
1411
1404
|
cellHeight: l,
|
|
1412
1405
|
padding: _,
|
|
1413
|
-
clueColor:
|
|
1414
|
-
}),
|
|
1406
|
+
clueColor: k
|
|
1407
|
+
}), sn({
|
|
1415
1408
|
ctx: t,
|
|
1416
|
-
maze:
|
|
1409
|
+
maze: c,
|
|
1417
1410
|
cellWidth: r,
|
|
1418
1411
|
cellHeight: l,
|
|
1419
1412
|
padding: _,
|
|
1420
1413
|
wallColor: m,
|
|
1421
1414
|
wallWidth: v
|
|
1422
|
-
}),
|
|
1415
|
+
}), an({
|
|
1423
1416
|
ctx: t,
|
|
1424
|
-
maze:
|
|
1417
|
+
maze: c,
|
|
1425
1418
|
exitCell: u,
|
|
1426
1419
|
cellWidth: r,
|
|
1427
1420
|
cellHeight: l,
|
|
1428
1421
|
padding: _,
|
|
1429
1422
|
exitColor: S,
|
|
1430
|
-
exitWallWidth:
|
|
1431
|
-
exitDashArray:
|
|
1432
|
-
}),
|
|
1423
|
+
exitWallWidth: y,
|
|
1424
|
+
exitDashArray: L
|
|
1425
|
+
}), cn({
|
|
1433
1426
|
ctx: t,
|
|
1434
1427
|
foodCells: h,
|
|
1435
1428
|
cellWidth: r,
|
|
1436
1429
|
cellHeight: l,
|
|
1437
1430
|
padding: _,
|
|
1438
|
-
foodColor:
|
|
1439
|
-
}),
|
|
1431
|
+
foodColor: b
|
|
1432
|
+
}), ln({
|
|
1440
1433
|
ctx: t,
|
|
1441
1434
|
playerCell: d,
|
|
1442
1435
|
playerRadius: w,
|
|
1443
1436
|
cellWidth: r,
|
|
1444
1437
|
cellHeight: l,
|
|
1445
1438
|
padding: _,
|
|
1446
|
-
playerColor:
|
|
1439
|
+
playerColor: C
|
|
1447
1440
|
});
|
|
1448
1441
|
}
|
|
1449
|
-
function
|
|
1442
|
+
function sn({
|
|
1450
1443
|
ctx: t,
|
|
1451
1444
|
maze: e,
|
|
1452
1445
|
cellWidth: n,
|
|
1453
1446
|
cellHeight: o,
|
|
1454
1447
|
padding: i,
|
|
1455
1448
|
wallColor: s,
|
|
1456
|
-
wallWidth:
|
|
1449
|
+
wallWidth: a
|
|
1457
1450
|
}) {
|
|
1458
|
-
t.save(), t.strokeStyle = s, t.lineWidth =
|
|
1451
|
+
t.save(), t.strokeStyle = s, t.lineWidth = a, t.lineCap = "round", t.beginPath(), hn(e, n, o, i).forEach((l) => {
|
|
1459
1452
|
t.moveTo(l.x1, l.y1), t.lineTo(l.x2, l.y2);
|
|
1460
1453
|
}), t.stroke(), t.restore();
|
|
1461
1454
|
}
|
|
1462
|
-
function
|
|
1455
|
+
function ln({
|
|
1463
1456
|
ctx: t,
|
|
1464
1457
|
playerCell: e,
|
|
1465
1458
|
playerRadius: n,
|
|
1466
1459
|
cellWidth: o,
|
|
1467
1460
|
cellHeight: i,
|
|
1468
1461
|
padding: s,
|
|
1469
|
-
playerColor:
|
|
1462
|
+
playerColor: a
|
|
1470
1463
|
}) {
|
|
1471
|
-
const { x: r, y: l } =
|
|
1464
|
+
const { x: r, y: l } = le(
|
|
1472
1465
|
e.row,
|
|
1473
1466
|
e.col,
|
|
1474
1467
|
o,
|
|
1475
1468
|
i,
|
|
1476
1469
|
s
|
|
1477
|
-
),
|
|
1478
|
-
t.save(), t.fillStyle =
|
|
1470
|
+
), c = Math.min(o, i) * Math.min(n, 0.5);
|
|
1471
|
+
t.save(), t.fillStyle = a, t.beginPath(), t.arc(r, l, c, 0, Math.PI * 2), t.fill(), t.restore();
|
|
1479
1472
|
}
|
|
1480
|
-
function
|
|
1473
|
+
function an({
|
|
1481
1474
|
ctx: t,
|
|
1482
1475
|
maze: e,
|
|
1483
1476
|
exitCell: n,
|
|
1484
1477
|
cellWidth: o,
|
|
1485
1478
|
cellHeight: i,
|
|
1486
1479
|
padding: s,
|
|
1487
|
-
exitColor:
|
|
1480
|
+
exitColor: a,
|
|
1488
1481
|
exitWallWidth: r,
|
|
1489
1482
|
exitDashArray: l = [8, 12]
|
|
1490
1483
|
}) {
|
|
1491
|
-
const { row:
|
|
1492
|
-
if (!e.isValid(
|
|
1493
|
-
const u =
|
|
1494
|
-
t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r, t.lineCap = "round", t.beginPath(),
|
|
1484
|
+
const { row: c, col: d } = n;
|
|
1485
|
+
if (!e.isValid(c, d)) return;
|
|
1486
|
+
const u = s + d * o, h = s + c * i;
|
|
1487
|
+
t.save(), t.globalCompositeOperation = "destination-out", t.lineWidth = r, t.lineCap = "round", t.beginPath(), t.moveTo(u, h + i), t.lineTo(u + o, h + i), t.stroke(), t.globalCompositeOperation = "source-over", t.strokeStyle = a, t.lineWidth = r, t.setLineDash(l), t.beginPath(), t.moveTo(u, h + i), t.lineTo(u + o, h + i), t.stroke(), t.restore();
|
|
1495
1488
|
}
|
|
1496
|
-
function
|
|
1489
|
+
function cn({
|
|
1497
1490
|
ctx: t,
|
|
1498
1491
|
foodCells: e,
|
|
1499
1492
|
cellWidth: n,
|
|
@@ -1502,54 +1495,54 @@ function an({
|
|
|
1502
1495
|
foodColor: s
|
|
1503
1496
|
}) {
|
|
1504
1497
|
t.fillStyle = s;
|
|
1505
|
-
const
|
|
1498
|
+
const a = Math.min(n, o) * 0.25;
|
|
1506
1499
|
e.forEach((r) => {
|
|
1507
|
-
const { x: l, y:
|
|
1500
|
+
const { x: l, y: c } = le(
|
|
1508
1501
|
r.row,
|
|
1509
1502
|
r.col,
|
|
1510
1503
|
n,
|
|
1511
1504
|
o,
|
|
1512
1505
|
i
|
|
1513
1506
|
);
|
|
1514
|
-
|
|
1507
|
+
un(t, l, c, a * 1.2, 5, a * 0.6);
|
|
1515
1508
|
});
|
|
1516
1509
|
}
|
|
1517
|
-
function
|
|
1510
|
+
function un(t, e, n, o, i, s) {
|
|
1518
1511
|
t.save(), t.beginPath();
|
|
1519
|
-
for (let
|
|
1520
|
-
const r =
|
|
1512
|
+
for (let a = 0; a < i * 2; a++) {
|
|
1513
|
+
const r = a % 2 === 0 ? o : s, l = Math.PI * a / i;
|
|
1521
1514
|
t.lineTo(e + r * Math.sin(l), n + r * Math.cos(l));
|
|
1522
1515
|
}
|
|
1523
1516
|
t.closePath(), t.fill(), t.restore();
|
|
1524
1517
|
}
|
|
1525
|
-
function
|
|
1518
|
+
function dn({
|
|
1526
1519
|
ctx: t,
|
|
1527
1520
|
playerPath: e,
|
|
1528
1521
|
visitCounts: n,
|
|
1529
1522
|
cellWidth: o,
|
|
1530
1523
|
cellHeight: i,
|
|
1531
1524
|
padding: s,
|
|
1532
|
-
clueColor:
|
|
1525
|
+
clueColor: a
|
|
1533
1526
|
}) {
|
|
1534
1527
|
if (!(!e || e.length < 2 || !n)) {
|
|
1535
1528
|
t.save();
|
|
1536
1529
|
for (let r = 1; r < e.length; r++) {
|
|
1537
|
-
const l = e[r - 1],
|
|
1530
|
+
const l = e[r - 1], c = e[r], d = `${l.row},${l.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${l.row},${l.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), T = Math.max(3, o * 0.1) + h * 0.5;
|
|
1538
1531
|
try {
|
|
1539
|
-
t.strokeStyle =
|
|
1532
|
+
t.strokeStyle = a.replace(")", `, ${f})`).replace("rgb(", "rgba(");
|
|
1540
1533
|
} catch {
|
|
1541
1534
|
t.strokeStyle = `rgba(255, 0, 0, ${f})`;
|
|
1542
1535
|
}
|
|
1543
|
-
t.lineWidth =
|
|
1544
|
-
const { x: p, y: _ } =
|
|
1536
|
+
t.lineWidth = T, t.lineCap = "round", t.lineJoin = "round";
|
|
1537
|
+
const { x: p, y: _ } = le(
|
|
1545
1538
|
l.row,
|
|
1546
1539
|
l.col,
|
|
1547
1540
|
o,
|
|
1548
1541
|
i,
|
|
1549
1542
|
s
|
|
1550
|
-
), { x: v, y: m } =
|
|
1551
|
-
|
|
1552
|
-
|
|
1543
|
+
), { x: v, y: m } = le(
|
|
1544
|
+
c.row,
|
|
1545
|
+
c.col,
|
|
1553
1546
|
o,
|
|
1554
1547
|
i,
|
|
1555
1548
|
s
|
|
@@ -1559,48 +1552,48 @@ function un({
|
|
|
1559
1552
|
t.restore();
|
|
1560
1553
|
}
|
|
1561
1554
|
}
|
|
1562
|
-
function
|
|
1555
|
+
function hn(t, e, n, o) {
|
|
1563
1556
|
const i = [];
|
|
1564
1557
|
for (let s = 0; s < t.rows; s++)
|
|
1565
|
-
for (let
|
|
1566
|
-
const r = t.grid[s][
|
|
1558
|
+
for (let a = 0; a < t.cols; a++) {
|
|
1559
|
+
const r = t.grid[s][a], l = o + a * e, c = o + s * n;
|
|
1567
1560
|
r.walls.top && i.push({
|
|
1568
1561
|
x1: l,
|
|
1569
|
-
y1:
|
|
1562
|
+
y1: c,
|
|
1570
1563
|
x2: l + e,
|
|
1571
|
-
y2:
|
|
1564
|
+
y2: c
|
|
1572
1565
|
}), r.walls.right && i.push({
|
|
1573
1566
|
x1: l + e,
|
|
1574
|
-
y1:
|
|
1567
|
+
y1: c,
|
|
1575
1568
|
x2: l + e,
|
|
1576
|
-
y2:
|
|
1569
|
+
y2: c + n
|
|
1577
1570
|
}), r.walls.bottom && i.push({
|
|
1578
1571
|
x1: l,
|
|
1579
|
-
y1:
|
|
1572
|
+
y1: c + n,
|
|
1580
1573
|
x2: l + e,
|
|
1581
|
-
y2:
|
|
1574
|
+
y2: c + n
|
|
1582
1575
|
}), r.walls.left && i.push({
|
|
1583
1576
|
x1: l,
|
|
1584
|
-
y1:
|
|
1577
|
+
y1: c,
|
|
1585
1578
|
x2: l,
|
|
1586
|
-
y2:
|
|
1579
|
+
y2: c + n
|
|
1587
1580
|
});
|
|
1588
1581
|
}
|
|
1589
1582
|
return i;
|
|
1590
1583
|
}
|
|
1591
|
-
function
|
|
1584
|
+
function le(t, e, n, o, i) {
|
|
1592
1585
|
return {
|
|
1593
1586
|
x: i + e * n + n / 2,
|
|
1594
1587
|
y: i + t * o + o / 2
|
|
1595
1588
|
};
|
|
1596
1589
|
}
|
|
1597
|
-
function
|
|
1590
|
+
function fn(t) {
|
|
1598
1591
|
return function() {
|
|
1599
1592
|
let e = t += 1831565813;
|
|
1600
1593
|
return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
|
|
1601
1594
|
};
|
|
1602
1595
|
}
|
|
1603
|
-
class
|
|
1596
|
+
class _n {
|
|
1604
1597
|
// initially all walls exit
|
|
1605
1598
|
constructor(e, n) {
|
|
1606
1599
|
this.row = e, this.col = n;
|
|
@@ -1608,7 +1601,7 @@ class fn {
|
|
|
1608
1601
|
visited = !1;
|
|
1609
1602
|
walls = { top: !0, right: !0, bottom: !0, left: !0 };
|
|
1610
1603
|
}
|
|
1611
|
-
class
|
|
1604
|
+
class mn {
|
|
1612
1605
|
rows;
|
|
1613
1606
|
cols;
|
|
1614
1607
|
grid;
|
|
@@ -1624,8 +1617,8 @@ class _n {
|
|
|
1624
1617
|
* @param entry Optional entry cell position
|
|
1625
1618
|
* @param exit Optional exit cell position
|
|
1626
1619
|
*/
|
|
1627
|
-
constructor(e, n, o, i, s = { row: 0, col: 0 }) {
|
|
1628
|
-
this.rows = e, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random =
|
|
1620
|
+
constructor(e, n, o, i, s = { row: 0, col: 0 }, a = { row: e - 1, col: n - 1 }) {
|
|
1621
|
+
this.rows = e, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = fn(this.seed), this.grid = this.initializeGrid(), this.generate(o, s, a);
|
|
1629
1622
|
}
|
|
1630
1623
|
// Initialize the grid with new MazeCell objects
|
|
1631
1624
|
initializeGrid() {
|
|
@@ -1633,7 +1626,7 @@ class _n {
|
|
|
1633
1626
|
for (let n = 0; n < this.rows; n++) {
|
|
1634
1627
|
e[n] = [];
|
|
1635
1628
|
for (let o = 0; o < this.cols; o++)
|
|
1636
|
-
e[n][o] = new
|
|
1629
|
+
e[n][o] = new _n(n, o);
|
|
1637
1630
|
}
|
|
1638
1631
|
return e;
|
|
1639
1632
|
}
|
|
@@ -1654,8 +1647,8 @@ class _n {
|
|
|
1654
1647
|
// Left
|
|
1655
1648
|
];
|
|
1656
1649
|
for (const s of i) {
|
|
1657
|
-
const
|
|
1658
|
-
this.isValid(
|
|
1650
|
+
const a = e + s.r, r = n + s.c;
|
|
1651
|
+
this.isValid(a, r) && o.push({ row: a, col: r });
|
|
1659
1652
|
}
|
|
1660
1653
|
return o;
|
|
1661
1654
|
}
|
|
@@ -1675,8 +1668,8 @@ class _n {
|
|
|
1675
1668
|
}
|
|
1676
1669
|
// Remove the wall between two adjacent cells
|
|
1677
1670
|
removeWall(e, n, o, i) {
|
|
1678
|
-
const s = this.grid[e][n],
|
|
1679
|
-
e === o + 1 ? (s.walls.top = !1,
|
|
1671
|
+
const s = this.grid[e][n], a = this.grid[o][i];
|
|
1672
|
+
e === o + 1 ? (s.walls.top = !1, a.walls.bottom = !1) : e === o - 1 ? (s.walls.bottom = !1, a.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, a.walls.right = !1) : n === i - 1 && (s.walls.right = !1, a.walls.left = !1);
|
|
1680
1673
|
}
|
|
1681
1674
|
// --- Generation Methods ---
|
|
1682
1675
|
/**
|
|
@@ -1686,7 +1679,7 @@ class _n {
|
|
|
1686
1679
|
* @param entry The entry cell position
|
|
1687
1680
|
* @param exit The exit cell position
|
|
1688
1681
|
*/
|
|
1689
|
-
generate(e, n = { row: 0, col: 0 }) {
|
|
1682
|
+
generate(e, n = { row: 0, col: 0 }, o = { row: this.rows - 1, col: this.cols - 1 }) {
|
|
1690
1683
|
switch (e) {
|
|
1691
1684
|
case "backtracking":
|
|
1692
1685
|
this.generateWithBacktracking();
|
|
@@ -1697,7 +1690,7 @@ class _n {
|
|
|
1697
1690
|
default:
|
|
1698
1691
|
throw new Error(`Unknown maze generation method: ${e}`);
|
|
1699
1692
|
}
|
|
1700
|
-
this.addOpenings(n);
|
|
1693
|
+
this.addOpenings(n, o);
|
|
1701
1694
|
}
|
|
1702
1695
|
// --- Backtracking Algorithm Implementation ---
|
|
1703
1696
|
generateWithBacktracking() {
|
|
@@ -1705,27 +1698,27 @@ class _n {
|
|
|
1705
1698
|
let i = { row: n, col: o };
|
|
1706
1699
|
for (this.grid[n][o].visited = !0, e.push(i); e.length > 0; ) {
|
|
1707
1700
|
i = e[e.length - 1];
|
|
1708
|
-
const { row: s, col:
|
|
1701
|
+
const { row: s, col: a } = i, r = this.getUnvisitedNeighbors(s, a);
|
|
1709
1702
|
if (r.length > 0) {
|
|
1710
|
-
const l = this.randomPick(r), { row:
|
|
1711
|
-
this.removeWall(s,
|
|
1703
|
+
const l = this.randomPick(r), { row: c, col: d } = l;
|
|
1704
|
+
this.removeWall(s, a, c, d), this.grid[c][d].visited = !0, e.push(l);
|
|
1712
1705
|
} else
|
|
1713
1706
|
e.pop();
|
|
1714
1707
|
}
|
|
1715
1708
|
}
|
|
1716
1709
|
// --- Prim's Algorithm Implementation ---
|
|
1717
1710
|
generateWithPrims() {
|
|
1718
|
-
const e = [], n = (s,
|
|
1719
|
-
const r = this.getNeighbors(s,
|
|
1711
|
+
const e = [], n = (s, a) => {
|
|
1712
|
+
const r = this.getNeighbors(s, a);
|
|
1720
1713
|
for (const l of r)
|
|
1721
1714
|
!this.grid[l.row][l.col].visited && !e.some(
|
|
1722
|
-
(
|
|
1715
|
+
(c) => c.row === l.row && c.col === l.col
|
|
1723
1716
|
) && e.push(l);
|
|
1724
1717
|
}, o = this.randomNumber(this.rows), i = this.randomNumber(this.cols);
|
|
1725
1718
|
for (this.grid[o][i].visited = !0, n(o, i); e.length > 0; ) {
|
|
1726
|
-
const s = this.randomNumber(e.length),
|
|
1727
|
-
if (
|
|
1728
|
-
const d = this.randomPick(
|
|
1719
|
+
const s = this.randomNumber(e.length), a = e[s], { row: r, col: l } = a, c = this.getVisitedNeighbors(r, l);
|
|
1720
|
+
if (c.length > 0) {
|
|
1721
|
+
const d = this.randomPick(c);
|
|
1729
1722
|
this.removeWall(r, l, d.row, d.col), this.grid[r][l].visited = !0, n(r, l);
|
|
1730
1723
|
}
|
|
1731
1724
|
e.splice(s, 1);
|
|
@@ -1735,8 +1728,8 @@ class _n {
|
|
|
1735
1728
|
/**
|
|
1736
1729
|
* Adds openings at the entry and exit points of the maze.
|
|
1737
1730
|
*/
|
|
1738
|
-
addOpenings(e) {
|
|
1739
|
-
this.grid[e.row][e.col].walls.top = !1;
|
|
1731
|
+
addOpenings(e, n) {
|
|
1732
|
+
this.grid[e.row][e.col].walls.top = !1, this.isValid(n.row, n.col) && (this.grid[n.row][n.col].walls.bottom = !1);
|
|
1740
1733
|
}
|
|
1741
1734
|
/**
|
|
1742
1735
|
* Generates a random number between 0 and len-1.
|
|
@@ -1751,68 +1744,68 @@ class _n {
|
|
|
1751
1744
|
return e[Math.floor(this.random() * e.length)];
|
|
1752
1745
|
}
|
|
1753
1746
|
}
|
|
1754
|
-
const
|
|
1747
|
+
const vn = (t, e, n) => {
|
|
1755
1748
|
if (!t.isValid(e, n)) return !1;
|
|
1756
1749
|
const o = t.grid[e][n];
|
|
1757
1750
|
return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
|
|
1758
|
-
},
|
|
1751
|
+
}, gn = (t) => t === 1 ? 2 : t >= 2 && t <= 5 ? 3 : t >= 6 && t <= 11 ? 4 : t >= 12 && t <= 15 ? 5 : 6, pn = (t, e) => {
|
|
1759
1752
|
if (!e)
|
|
1760
1753
|
return console.error(`Cannot find Level ${t}'s config.`), null;
|
|
1761
|
-
const { size: n, seed: o, method: i, entry: s, exit:
|
|
1754
|
+
const { size: n, seed: o, method: i, entry: s, exit: a } = e, r = n, l = n, c = s || { row: 0, col: 0 }, d = a || {
|
|
1762
1755
|
row: r - 1,
|
|
1763
1756
|
col: l - 1
|
|
1764
|
-
}, u = new
|
|
1765
|
-
for (let
|
|
1757
|
+
}, u = new mn(r, l, i, o, c, d), h = gn(t), f = [];
|
|
1758
|
+
for (let T = 0; T < h; T++) {
|
|
1766
1759
|
let p;
|
|
1767
1760
|
do
|
|
1768
1761
|
p = {
|
|
1769
1762
|
row: Math.floor(u.random() * r),
|
|
1770
1763
|
col: Math.floor(u.random() * l)
|
|
1771
1764
|
};
|
|
1772
|
-
while (p.row ===
|
|
1765
|
+
while (p.row === c.row && p.col === c.col || p.row === d.row && p.col === d.col || !vn(u, p.row, p.col) || f.some((_) => _.row === p.row && _.col === p.col));
|
|
1773
1766
|
f.push(p);
|
|
1774
1767
|
}
|
|
1775
1768
|
return {
|
|
1776
1769
|
isGameActive: !0,
|
|
1777
1770
|
levelTransitioning: !1,
|
|
1778
1771
|
maze: u,
|
|
1779
|
-
playerCell:
|
|
1772
|
+
playerCell: c,
|
|
1780
1773
|
exitCell: d,
|
|
1781
1774
|
foodCells: f,
|
|
1782
1775
|
playerAtExit: !1,
|
|
1783
1776
|
foodCollected: 0,
|
|
1784
1777
|
totalFoodCount: h,
|
|
1785
1778
|
showClue: !1,
|
|
1786
|
-
playerPath: [
|
|
1787
|
-
visitCounts: { [`${
|
|
1779
|
+
playerPath: [c],
|
|
1780
|
+
visitCounts: { [`${c.row},${c.col}`]: 1 }
|
|
1788
1781
|
};
|
|
1789
1782
|
};
|
|
1790
|
-
function
|
|
1791
|
-
const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } =
|
|
1783
|
+
function Cn() {
|
|
1784
|
+
const { setGamePlayState: t, gamePlayStateRef: e, gameProgress: n, config: o } = V(), i = O(null), s = O(null), a = O(null), { i18n: r, levelConfig: l, renderConfig: c } = o, d = Z(l), u = O(
|
|
1792
1785
|
d.getLevelConfig(n.currentLevel)
|
|
1793
1786
|
);
|
|
1794
|
-
|
|
1795
|
-
i.current &&
|
|
1787
|
+
I(() => {
|
|
1788
|
+
i.current && $.attachTo(i.current);
|
|
1796
1789
|
}, []);
|
|
1797
|
-
const h =
|
|
1790
|
+
const h = O(), f = Zt(a, () => {
|
|
1798
1791
|
h.current?.();
|
|
1799
|
-
}),
|
|
1800
|
-
|
|
1792
|
+
}), T = Qt(a);
|
|
1793
|
+
I(() => {
|
|
1801
1794
|
u.current = d.getLevelConfig(
|
|
1802
1795
|
n.currentLevel
|
|
1803
1796
|
);
|
|
1804
1797
|
}, [n.currentLevel]);
|
|
1805
1798
|
const p = () => {
|
|
1806
|
-
const
|
|
1799
|
+
const C = pn(
|
|
1807
1800
|
n.currentLevel,
|
|
1808
1801
|
u.current
|
|
1809
1802
|
);
|
|
1810
|
-
|
|
1803
|
+
C && t((w) => ({
|
|
1811
1804
|
...w,
|
|
1812
|
-
...
|
|
1805
|
+
...C
|
|
1813
1806
|
}));
|
|
1814
1807
|
};
|
|
1815
|
-
|
|
1808
|
+
I(() => {
|
|
1816
1809
|
p();
|
|
1817
1810
|
}, [n.currentLevel]);
|
|
1818
1811
|
const _ = () => {
|
|
@@ -1821,64 +1814,63 @@ function pn() {
|
|
|
1821
1814
|
containerRef: s,
|
|
1822
1815
|
gamePlayStateRef: e,
|
|
1823
1816
|
setGamePlayState: t,
|
|
1824
|
-
playerRadius:
|
|
1825
|
-
moveSpeed:
|
|
1826
|
-
exitWallWidth: u.current?.exitWallWidth ||
|
|
1827
|
-
getCellSizeInPixels: () => C.current.cellWidth,
|
|
1817
|
+
playerRadius: c.playerRadius,
|
|
1818
|
+
moveSpeed: c.gridMoveSpeed,
|
|
1819
|
+
exitWallWidth: u.current?.exitWallWidth || c?.exitWallWidth,
|
|
1828
1820
|
onFoodCollected: () => {
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
r.foodCollectedToast.replace("%NUM%",
|
|
1821
|
+
const C = e.current.totalFoodCount - e.current.foodCollected - 1;
|
|
1822
|
+
C > 0 ? $.show(
|
|
1823
|
+
r.foodCollectedToast.replace("%NUM%", C.toString()),
|
|
1832
1824
|
"success",
|
|
1833
1825
|
3e3
|
|
1834
|
-
) :
|
|
1826
|
+
) : $.show(r.allFoodCollectedToast, "success");
|
|
1835
1827
|
}
|
|
1836
1828
|
});
|
|
1837
|
-
return
|
|
1829
|
+
return I(() => {
|
|
1838
1830
|
m();
|
|
1839
|
-
}, [n.currentLevel, m]),
|
|
1840
|
-
let
|
|
1841
|
-
const
|
|
1842
|
-
const S =
|
|
1843
|
-
if (!(w &&
|
|
1844
|
-
|
|
1831
|
+
}, [n.currentLevel, m]), I(() => {
|
|
1832
|
+
let C, w = !document.hidden;
|
|
1833
|
+
const b = () => {
|
|
1834
|
+
const S = a.current?.getContext("2d"), y = e.current;
|
|
1835
|
+
if (!(w && y?.isGameActive && S && y?.maze)) {
|
|
1836
|
+
C = requestAnimationFrame(b);
|
|
1845
1837
|
return;
|
|
1846
1838
|
}
|
|
1847
|
-
v(),
|
|
1848
|
-
},
|
|
1849
|
-
const S =
|
|
1850
|
-
if (S &&
|
|
1851
|
-
const
|
|
1852
|
-
|
|
1853
|
-
...
|
|
1854
|
-
wallWidth:
|
|
1839
|
+
v(), E(), C = requestAnimationFrame(b);
|
|
1840
|
+
}, E = () => {
|
|
1841
|
+
const S = a.current?.getContext("2d"), y = e.current;
|
|
1842
|
+
if (S && y?.maze) {
|
|
1843
|
+
const L = u.current?.wallWidth || c?.wallWidth, N = u.current?.exitColor || c?.exitColor, P = u.current?.exitWallWidth || c?.exitWallWidth, x = u.current?.exitDashArray || c?.exitDashArray;
|
|
1844
|
+
rn(S, y, f.current, T.current, {
|
|
1845
|
+
...c,
|
|
1846
|
+
wallWidth: L,
|
|
1855
1847
|
exitColor: N,
|
|
1856
1848
|
exitWallWidth: P,
|
|
1857
|
-
exitDashArray:
|
|
1849
|
+
exitDashArray: x
|
|
1858
1850
|
});
|
|
1859
1851
|
}
|
|
1860
1852
|
};
|
|
1861
|
-
h.current =
|
|
1862
|
-
const
|
|
1863
|
-
const
|
|
1864
|
-
w = !document.hidden && document.visibilityState === "visible" && (!S || S.type !== "blur"), !
|
|
1853
|
+
h.current = E;
|
|
1854
|
+
const k = (S) => {
|
|
1855
|
+
const y = w;
|
|
1856
|
+
w = !document.hidden && document.visibilityState === "visible" && (!S || S.type !== "blur"), !y && w ? e.current?.levelTransitioning === !1 && t({
|
|
1865
1857
|
...e.current,
|
|
1866
1858
|
isGameActive: !0
|
|
1867
|
-
}) :
|
|
1859
|
+
}) : y && !w && t({
|
|
1868
1860
|
...e.current,
|
|
1869
1861
|
isGameActive: !1
|
|
1870
1862
|
});
|
|
1871
1863
|
};
|
|
1872
|
-
return document.addEventListener("visibilitychange",
|
|
1873
|
-
cancelAnimationFrame(
|
|
1864
|
+
return document.addEventListener("visibilitychange", k), window.addEventListener("blur", k), window.addEventListener("focus", k), C = requestAnimationFrame(b), () => {
|
|
1865
|
+
cancelAnimationFrame(C), document.removeEventListener("visibilitychange", k), window.removeEventListener("blur", k), window.removeEventListener("focus", k);
|
|
1874
1866
|
};
|
|
1875
|
-
}, []),
|
|
1876
|
-
|
|
1867
|
+
}, []), I(() => {
|
|
1868
|
+
$.show(r.useArrowKeyTips, "info", 3e3);
|
|
1877
1869
|
}, []), /* @__PURE__ */ g("div", { className: "maze-game-container", ref: i, children: [
|
|
1878
|
-
/* @__PURE__ */ g(
|
|
1870
|
+
/* @__PURE__ */ g(Et, {}),
|
|
1879
1871
|
/* @__PURE__ */ g(Jt, { onRetry: _ }),
|
|
1880
1872
|
/* @__PURE__ */ g("div", { className: "maze-canvas-container", ref: s, children: [
|
|
1881
|
-
/* @__PURE__ */ g("canvas", { ref:
|
|
1873
|
+
/* @__PURE__ */ g("canvas", { ref: a, className: "maze-game-canvas" }),
|
|
1882
1874
|
/* @__PURE__ */ g("div", { className: "maze-touch-area maze-up" }),
|
|
1883
1875
|
/* @__PURE__ */ g("div", { className: "maze-touch-area maze-down" }),
|
|
1884
1876
|
/* @__PURE__ */ g("div", { className: "maze-touch-area maze-left" }),
|
|
@@ -1886,7 +1878,7 @@ function pn() {
|
|
|
1886
1878
|
] })
|
|
1887
1879
|
] });
|
|
1888
1880
|
}
|
|
1889
|
-
const
|
|
1881
|
+
const st = [
|
|
1890
1882
|
// Tier 1 (Levels 1-12) - Beginner
|
|
1891
1883
|
[
|
|
1892
1884
|
// debug
|
|
@@ -2044,7 +2036,7 @@ const it = [
|
|
|
2044
2036
|
{ size: 68, seed: 33341, method: "backtracking" }
|
|
2045
2037
|
// Level 60 - Master
|
|
2046
2038
|
]
|
|
2047
|
-
],
|
|
2039
|
+
], ie = {
|
|
2048
2040
|
lcPrefix: "maze-",
|
|
2049
2041
|
i18n: {
|
|
2050
2042
|
reset: "Reset",
|
|
@@ -2087,7 +2079,7 @@ const it = [
|
|
|
2087
2079
|
useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
|
|
2088
2080
|
},
|
|
2089
2081
|
renderConfig: {
|
|
2090
|
-
gridMoveSpeed: 0.
|
|
2082
|
+
gridMoveSpeed: 0.07,
|
|
2091
2083
|
padding: 10,
|
|
2092
2084
|
wallWidth: 2,
|
|
2093
2085
|
wallColor: "#000000",
|
|
@@ -2103,27 +2095,27 @@ const it = [
|
|
|
2103
2095
|
exitDashArray: [8, 12]
|
|
2104
2096
|
// default dash: 8px dash, 12px gap
|
|
2105
2097
|
},
|
|
2106
|
-
levelConfig:
|
|
2098
|
+
levelConfig: st
|
|
2107
2099
|
};
|
|
2108
2100
|
function wn({ config: t = {} }) {
|
|
2109
|
-
const e = { ...
|
|
2110
|
-
...
|
|
2101
|
+
const e = { ...ie.i18n, ...t.i18n || {} }, n = {
|
|
2102
|
+
...ie.renderConfig,
|
|
2111
2103
|
...t.renderConfig || {}
|
|
2112
|
-
}, o = t.levelConfig ||
|
|
2113
|
-
...
|
|
2104
|
+
}, o = t.levelConfig || st, i = {
|
|
2105
|
+
...ie,
|
|
2114
2106
|
...t,
|
|
2115
2107
|
i18n: e,
|
|
2116
2108
|
levelConfig: o,
|
|
2117
2109
|
renderConfig: n
|
|
2118
2110
|
};
|
|
2119
|
-
return /* @__PURE__ */ g(bt, { config: i, children: /* @__PURE__ */ g(
|
|
2111
|
+
return /* @__PURE__ */ g(bt, { config: i, children: /* @__PURE__ */ g(Cn, {}) });
|
|
2120
2112
|
}
|
|
2121
|
-
const Cn = {
|
|
2122
|
-
root: "https://unpkg.com/@roudanio/maze@0.1.3/dist/",
|
|
2123
|
-
...re
|
|
2124
|
-
};
|
|
2125
|
-
`${JSON.stringify(Cn, null, 2)}`;
|
|
2126
2113
|
const yn = {
|
|
2114
|
+
root: "https://unpkg.com/@roudanio/maze@0.1.4/dist/",
|
|
2115
|
+
...ie
|
|
2116
|
+
};
|
|
2117
|
+
`${JSON.stringify(yn, null, 2)}`;
|
|
2118
|
+
const bn = {
|
|
2127
2119
|
async init(t, e) {
|
|
2128
2120
|
const n = typeof t == "string" ? document.querySelector(t) : t;
|
|
2129
2121
|
if (!n) {
|
|
@@ -2148,17 +2140,17 @@ const yn = {
|
|
|
2148
2140
|
transition: width 1.5s ease-in-out;
|
|
2149
2141
|
transition: width 1.5s ease-in-out;
|
|
2150
2142
|
`, i.append(s), n.append(i);
|
|
2151
|
-
const
|
|
2152
|
-
|
|
2143
|
+
const a = document.createElement("style");
|
|
2144
|
+
a.innerHTML = `
|
|
2153
2145
|
@keyframes loading {
|
|
2154
2146
|
0% { width: 0%; }
|
|
2155
2147
|
100% { width: 99%; }
|
|
2156
|
-
}`, document.head.appendChild(
|
|
2148
|
+
}`, document.head.appendChild(a), await (async (l) => new Promise((c, d) => {
|
|
2157
2149
|
const u = document.createElement("link");
|
|
2158
|
-
u.rel = "stylesheet", u.type = "text/css", u.href = l, u.onload =
|
|
2159
|
-
}))(o + "maze.css"),
|
|
2150
|
+
u.rel = "stylesheet", u.type = "text/css", u.href = l, u.onload = c, u.onerror = d, document.head.appendChild(u);
|
|
2151
|
+
}))(o + "maze.css"), _t(/* @__PURE__ */ g(wn, { config: e }), n);
|
|
2160
2152
|
}
|
|
2161
2153
|
};
|
|
2162
2154
|
export {
|
|
2163
|
-
|
|
2155
|
+
bn as default
|
|
2164
2156
|
};
|