@roudanio/maze 0.2.3 → 0.2.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 +2 -2
- package/dist/maze.js +632 -613
- package/dist/maze.umd.js +2 -2
- package/package.json +1 -1
package/dist/maze.js
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
var
|
|
2
|
-
function
|
|
1
|
+
var ge, M, Qe, X, xe, et, tt, nt, Le, Te, ke, ot, ne = {}, rt = [], Tt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, pe = Array.isArray;
|
|
2
|
+
function H(e, t) {
|
|
3
3
|
for (var n in t) e[n] = t[n];
|
|
4
4
|
return e;
|
|
5
5
|
}
|
|
6
|
-
function
|
|
6
|
+
function Ne(e) {
|
|
7
7
|
e && e.parentNode && e.parentNode.removeChild(e);
|
|
8
8
|
}
|
|
9
|
-
function
|
|
9
|
+
function kt(e, t, n) {
|
|
10
10
|
var o, i, s, l = {};
|
|
11
11
|
for (s in t) s == "key" ? o = t[s] : s == "ref" ? i = t[s] : l[s] = t[s];
|
|
12
|
-
if (arguments.length > 2 && (l.children = arguments.length > 3 ?
|
|
13
|
-
return
|
|
12
|
+
if (arguments.length > 2 && (l.children = arguments.length > 3 ? ge.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (s in e.defaultProps) l[s] == null && (l[s] = e.defaultProps[s]);
|
|
13
|
+
return ue(e, l, o, i, null);
|
|
14
14
|
}
|
|
15
|
-
function
|
|
16
|
-
var s = { type: e, props: t, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++
|
|
15
|
+
function ue(e, t, n, o, i) {
|
|
16
|
+
var s = { type: e, props: t, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++Qe, __i: -1, __u: 0 };
|
|
17
17
|
return i == null && M.vnode != null && M.vnode(s), s;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function we(e) {
|
|
20
20
|
return e.children;
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function de(e, t) {
|
|
23
23
|
this.props = e, this.context = t;
|
|
24
24
|
}
|
|
25
|
-
function
|
|
26
|
-
if (t == null) return e.__ ?
|
|
25
|
+
function J(e, t) {
|
|
26
|
+
if (t == null) return e.__ ? J(e.__, e.__i + 1) : null;
|
|
27
27
|
for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
|
|
28
|
-
return typeof e.type == "function" ?
|
|
28
|
+
return typeof e.type == "function" ? J(e) : null;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function it(e) {
|
|
31
31
|
var t, n;
|
|
32
32
|
if ((e = e.__) != null && e.__c != null) {
|
|
33
33
|
for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) {
|
|
34
34
|
e.__e = e.__c.base = n.__e;
|
|
35
35
|
break;
|
|
36
36
|
}
|
|
37
|
-
return
|
|
37
|
+
return it(e);
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
(!e.__d && (e.__d = !0) &&
|
|
40
|
+
function Se(e) {
|
|
41
|
+
(!e.__d && (e.__d = !0) && X.push(e) && !_e.__r++ || xe != M.debounceRendering) && ((xe = M.debounceRendering) || et)(_e);
|
|
42
42
|
}
|
|
43
|
-
function
|
|
44
|
-
for (var e, t, n, o, i, s, l, r = 1;
|
|
45
|
-
|
|
43
|
+
function _e() {
|
|
44
|
+
for (var e, t, n, o, i, s, l, r = 1; X.length; ) X.length > r && X.sort(tt), e = X.shift(), r = X.length, e.__d && (n = void 0, i = (o = (t = e).__v).__e, s = [], l = [], t.__P && ((n = H({}, o)).__v = o.__v + 1, M.vnode && M.vnode(n), Me(t.__P, n, o, t.__n, t.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? J(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, at(s, n, l), n.__e != i && it(n)));
|
|
45
|
+
_e.__r = 0;
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
var u, h, f,
|
|
49
|
-
for (a =
|
|
50
|
-
return n.__e =
|
|
47
|
+
function st(e, t, n, o, i, s, l, r, a, c, d) {
|
|
48
|
+
var u, h, f, g, _, v, T = o && o.__k || rt, b = t.length;
|
|
49
|
+
for (a = St(n, t, T, a, b), u = 0; u < b; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? ne : T[f.__i] || ne, f.__i = u, v = Me(e, f, h, i, s, l, r, a, c, d), g = f.__e, f.ref && h.ref != f.ref && (h.ref && Ae(h.ref, null, f), d.push(f.ref, f.__c || g, f)), _ == null && g != null && (_ = g), 4 & f.__u || h.__k === f.__k ? a = lt(f, a, e) : typeof f.type == "function" && v !== void 0 ? a = v : g && (a = g.nextSibling), f.__u &= -7);
|
|
50
|
+
return n.__e = _, a;
|
|
51
51
|
}
|
|
52
|
-
function
|
|
52
|
+
function St(e, t, n, o, i) {
|
|
53
53
|
var s, l, r, a, c, d = n.length, u = d, h = 0;
|
|
54
|
-
for (e.__k = new Array(i), s = 0; s < i; s++) (l = t[s]) != null && typeof l != "boolean" && typeof l != "function" ? (a = s + h, (l = e.__k[s] = typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ?
|
|
55
|
-
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o =
|
|
54
|
+
for (e.__k = new Array(i), s = 0; s < i; s++) (l = t[s]) != null && typeof l != "boolean" && typeof l != "function" ? (a = s + h, (l = e.__k[s] = typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? ue(null, l, null, null, null) : pe(l) ? ue(we, { children: l }, null, null, null) : l.constructor == null && l.__b > 0 ? ue(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : l).__ = e, l.__b = e.__b + 1, r = null, (c = l.__i = zt(l, n, a, u)) != -1 && (u--, (r = n[c]) && (r.__u |= 2)), r == null || r.__v == null ? (c == -1 && (i > d ? h-- : i < d && h++), typeof l.type != "function" && (l.__u |= 4)) : c != a && (c == a - 1 ? h-- : c == a + 1 ? h++ : (c > a ? h-- : h++, l.__u |= 4))) : e.__k[s] = null;
|
|
55
|
+
if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = J(r)), ut(r, r));
|
|
56
56
|
return o;
|
|
57
57
|
}
|
|
58
|
-
function
|
|
58
|
+
function lt(e, t, n) {
|
|
59
59
|
var o, i;
|
|
60
60
|
if (typeof e.type == "function") {
|
|
61
|
-
for (o = e.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = e, t =
|
|
61
|
+
for (o = e.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = e, t = lt(o[i], t, n));
|
|
62
62
|
return t;
|
|
63
63
|
}
|
|
64
|
-
e.__e != t && (t && e.type && !n.contains(t) && (t =
|
|
64
|
+
e.__e != t && (t && e.type && !n.contains(t) && (t = J(e)), n.insertBefore(e.__e, t || null), t = e.__e);
|
|
65
65
|
do
|
|
66
66
|
t = t && t.nextSibling;
|
|
67
67
|
while (t != null && t.nodeType == 8);
|
|
68
68
|
return t;
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function zt(e, t, n, o) {
|
|
71
71
|
var i, s, l = e.key, r = e.type, a = t[n];
|
|
72
72
|
if (a === null && e.key == null || a && l == a.key && r == a.type && (2 & a.__u) == 0) return n;
|
|
73
73
|
if (o > (a != null && (2 & a.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < t.length; ) {
|
|
@@ -82,17 +82,17 @@ function kt(e, t, n, o) {
|
|
|
82
82
|
}
|
|
83
83
|
return -1;
|
|
84
84
|
}
|
|
85
|
-
function
|
|
86
|
-
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" ||
|
|
85
|
+
function Re(e, t, n) {
|
|
86
|
+
t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || Tt.test(t) ? n : n + "px";
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function ae(e, t, n, o, i) {
|
|
89
89
|
var s;
|
|
90
90
|
e: if (t == "style") if (typeof n == "string") e.style.cssText = n;
|
|
91
91
|
else {
|
|
92
|
-
if (typeof o == "string" && (e.style.cssText = o = ""), o) for (t in o) n && t in n ||
|
|
93
|
-
if (n) for (t in n) o && n[t] == o[t] ||
|
|
92
|
+
if (typeof o == "string" && (e.style.cssText = o = ""), o) for (t in o) n && t in n || Re(e.style, t, "");
|
|
93
|
+
if (n) for (t in n) o && n[t] == o[t] || Re(e.style, t, n[t]);
|
|
94
94
|
}
|
|
95
|
-
else if (t[0] == "o" && t[1] == "n") s = t != (t = t.replace(
|
|
95
|
+
else if (t[0] == "o" && t[1] == "n") s = t != (t = t.replace(nt, "$1")), t = t.toLowerCase() in e || t == "onFocusOut" || t == "onFocusIn" ? t.toLowerCase().slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + s] = n, n ? o ? n.u = o.u : (n.u = Le, e.addEventListener(t, s ? ke : Te, s)) : e.removeEventListener(t, s ? ke : Te, s);
|
|
96
96
|
else {
|
|
97
97
|
if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
|
|
98
98
|
else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
|
|
@@ -103,54 +103,54 @@ function se(e, t, n, o, i) {
|
|
|
103
103
|
typeof n == "function" || (n == null || n === !1 && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
function
|
|
106
|
+
function Fe(e) {
|
|
107
107
|
return function(t) {
|
|
108
108
|
if (this.l) {
|
|
109
109
|
var n = this.l[t.type + e];
|
|
110
|
-
if (t.t == null) t.t =
|
|
110
|
+
if (t.t == null) t.t = Le++;
|
|
111
111
|
else if (t.t < n.u) return;
|
|
112
112
|
return n(M.event ? M.event(t) : t);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
|
-
function
|
|
117
|
-
var d, u, h, f,
|
|
116
|
+
function Me(e, t, n, o, i, s, l, r, a, c) {
|
|
117
|
+
var d, u, h, f, g, _, v, T, b, C, p, S, w, y, z, N, E, k = t.type;
|
|
118
118
|
if (t.constructor != null) return null;
|
|
119
119
|
128 & n.__u && (a = !!(32 & n.__u), s = [r = t.__e = n.__e]), (d = M.__b) && d(t);
|
|
120
|
-
e: if (typeof
|
|
121
|
-
if (
|
|
120
|
+
e: if (typeof k == "function") try {
|
|
121
|
+
if (T = t.props, b = "prototype" in k && k.prototype.render, C = (d = k.contextType) && o[d.__c], p = d ? C ? C.props.value : d.__ : o, n.__c ? v = (u = t.__c = n.__c).__ = u.__E : (b ? t.__c = u = new k(T, p) : (t.__c = u = new de(T, p), u.constructor = k, u.render = Lt), C && C.sub(u), u.props = T, u.state || (u.state = {}), u.context = p, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), b && u.__s == null && (u.__s = u.state), b && k.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = H({}, u.__s)), H(u.__s, k.getDerivedStateFromProps(T, u.__s))), f = u.props, g = u.state, u.__v = t, h) b && k.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), b && u.componentDidMount != null && u.__h.push(u.componentDidMount);
|
|
122
122
|
else {
|
|
123
|
-
if (
|
|
124
|
-
for (t.__v != n.__v && (u.props =
|
|
123
|
+
if (b && k.getDerivedStateFromProps == null && T !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(T, p), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(T, u.__s, p) === !1 || t.__v == n.__v) {
|
|
124
|
+
for (t.__v != n.__v && (u.props = T, u.state = u.__s, u.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(L) {
|
|
125
125
|
L && (L.__ = t);
|
|
126
|
-
}),
|
|
126
|
+
}), S = 0; S < u._sb.length; S++) u.__h.push(u._sb[S]);
|
|
127
127
|
u._sb = [], u.__h.length && l.push(u);
|
|
128
128
|
break e;
|
|
129
129
|
}
|
|
130
|
-
u.componentWillUpdate != null && u.componentWillUpdate(
|
|
131
|
-
u.componentDidUpdate(f,
|
|
130
|
+
u.componentWillUpdate != null && u.componentWillUpdate(T, u.__s, p), b && u.componentDidUpdate != null && u.__h.push(function() {
|
|
131
|
+
u.componentDidUpdate(f, g, _);
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
if (u.context =
|
|
135
|
-
for (u.state = u.__s, u.__d = !1, w && w(t), d = u.render(u.props, u.state, u.context),
|
|
134
|
+
if (u.context = p, u.props = T, u.__P = e, u.__e = !1, w = M.__r, y = 0, b) {
|
|
135
|
+
for (u.state = u.__s, u.__d = !1, w && w(t), d = u.render(u.props, u.state, u.context), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
|
|
136
136
|
u._sb = [];
|
|
137
137
|
} else do
|
|
138
138
|
u.__d = !1, w && w(t), d = u.render(u.props, u.state, u.context), u.state = u.__s;
|
|
139
139
|
while (u.__d && ++y < 25);
|
|
140
|
-
u.state = u.__s, u.getChildContext != null && (o =
|
|
140
|
+
u.state = u.__s, u.getChildContext != null && (o = H(H({}, o), u.getChildContext())), b && !h && u.getSnapshotBeforeUpdate != null && (_ = u.getSnapshotBeforeUpdate(f, g)), N = d, d != null && d.type === we && d.key == null && (N = ct(d.props.children)), r = st(e, pe(N) ? N : [N], t, n, o, i, s, l, r, a, c), u.base = t.__e, t.__u &= -161, u.__h.length && l.push(u), v && (u.__E = u.__ = null);
|
|
141
141
|
} catch (L) {
|
|
142
142
|
if (t.__v = null, a || s != null) if (L.then) {
|
|
143
143
|
for (t.__u |= a ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
|
|
144
144
|
s[s.indexOf(r)] = null, t.__e = r;
|
|
145
|
-
} else for (
|
|
145
|
+
} else for (E = s.length; E--; ) Ne(s[E]);
|
|
146
146
|
else t.__e = n.__e, t.__k = n.__k;
|
|
147
147
|
M.__e(L, t, n);
|
|
148
148
|
}
|
|
149
|
-
else s == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : r = t.__e =
|
|
149
|
+
else s == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : r = t.__e = Et(n.__e, t, n, o, i, s, l, a, c);
|
|
150
150
|
return (d = M.diffed) && d(t), 128 & t.__u ? void 0 : r;
|
|
151
151
|
}
|
|
152
|
-
function
|
|
153
|
-
for (var o = 0; o < n.length; o++)
|
|
152
|
+
function at(e, t, n) {
|
|
153
|
+
for (var o = 0; o < n.length; o++) Ae(n[o], n[++o], n[++o]);
|
|
154
154
|
M.__c && M.__c(t, e), e.some(function(i) {
|
|
155
155
|
try {
|
|
156
156
|
e = i.__h, i.__h = [], e.some(function(s) {
|
|
@@ -161,39 +161,39 @@ function st(e, t, n) {
|
|
|
161
161
|
}
|
|
162
162
|
});
|
|
163
163
|
}
|
|
164
|
-
function
|
|
165
|
-
return typeof e != "object" || e == null || e.__b && e.__b > 0 ? e :
|
|
164
|
+
function ct(e) {
|
|
165
|
+
return typeof e != "object" || e == null || e.__b && e.__b > 0 ? e : pe(e) ? e.map(ct) : H({}, e);
|
|
166
166
|
}
|
|
167
|
-
function
|
|
168
|
-
var c, d, u, h, f,
|
|
169
|
-
if (
|
|
170
|
-
for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!
|
|
167
|
+
function Et(e, t, n, o, i, s, l, r, a) {
|
|
168
|
+
var c, d, u, h, f, g, _, v = n.props, T = t.props, b = t.type;
|
|
169
|
+
if (b == "svg" ? i = "http://www.w3.org/2000/svg" : b == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
|
|
170
|
+
for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!b && (b ? f.localName == b : f.nodeType == 3)) {
|
|
171
171
|
e = f, s[c] = null;
|
|
172
172
|
break;
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
if (e == null) {
|
|
176
|
-
if (
|
|
177
|
-
e = document.createElementNS(i,
|
|
176
|
+
if (b == null) return document.createTextNode(T);
|
|
177
|
+
e = document.createElementNS(i, b, T.is && T), r && (M.__m && M.__m(t, s), r = !1), s = null;
|
|
178
178
|
}
|
|
179
|
-
if (
|
|
179
|
+
if (b == null) v === T || r && e.data == T || (e.data = T);
|
|
180
180
|
else {
|
|
181
|
-
if (s = s &&
|
|
182
|
-
for (c in
|
|
181
|
+
if (s = s && ge.call(e.childNodes), v = n.props || ne, !r && s != null) for (v = {}, c = 0; c < e.attributes.length; c++) v[(f = e.attributes[c]).name] = f.value;
|
|
182
|
+
for (c in v) if (f = v[c], c != "children") {
|
|
183
183
|
if (c == "dangerouslySetInnerHTML") u = f;
|
|
184
|
-
else if (!(c in
|
|
185
|
-
if (c == "value" && "defaultValue" in
|
|
186
|
-
|
|
184
|
+
else if (!(c in T)) {
|
|
185
|
+
if (c == "value" && "defaultValue" in T || c == "checked" && "defaultChecked" in T) continue;
|
|
186
|
+
ae(e, c, null, f, i);
|
|
187
187
|
}
|
|
188
188
|
}
|
|
189
|
-
for (c in
|
|
189
|
+
for (c in T) f = T[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? g = f : c == "checked" ? _ = f : r && typeof f != "function" || v[c] === f || ae(e, c, f, v[c], i);
|
|
190
190
|
if (d) r || u && (d.__html == u.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = [];
|
|
191
|
-
else if (u && (e.innerHTML = ""),
|
|
192
|
-
r || (c = "value",
|
|
191
|
+
else if (u && (e.innerHTML = ""), st(t.type == "template" ? e.content : e, pe(h) ? h : [h], t, n, o, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, l, s ? s[0] : n.__k && J(n, 0), r, a), s != null) for (c = s.length; c--; ) Ne(s[c]);
|
|
192
|
+
r || (c = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[c] || b == "progress" && !g || b == "option" && g != v[c]) && ae(e, c, g, v[c], i), c = "checked", _ != null && _ != e[c] && ae(e, c, _, v[c], i));
|
|
193
193
|
}
|
|
194
194
|
return e;
|
|
195
195
|
}
|
|
196
|
-
function
|
|
196
|
+
function Ae(e, t, n) {
|
|
197
197
|
try {
|
|
198
198
|
if (typeof e == "function") {
|
|
199
199
|
var o = typeof e.__u == "function";
|
|
@@ -203,9 +203,9 @@ function Ne(e, t, n) {
|
|
|
203
203
|
M.__e(i, n);
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
|
-
function
|
|
206
|
+
function ut(e, t, n) {
|
|
207
207
|
var o, i;
|
|
208
|
-
if (M.unmount && M.unmount(e), (o = e.ref) && (o.current && o.current != e.__e ||
|
|
208
|
+
if (M.unmount && M.unmount(e), (o = e.ref) && (o.current && o.current != e.__e || Ae(o, null, t)), (o = e.__c) != null) {
|
|
209
209
|
if (o.componentWillUnmount) try {
|
|
210
210
|
o.componentWillUnmount();
|
|
211
211
|
} catch (s) {
|
|
@@ -213,17 +213,17 @@ function at(e, t, n) {
|
|
|
213
213
|
}
|
|
214
214
|
o.base = o.__P = null;
|
|
215
215
|
}
|
|
216
|
-
if (o = e.__k) for (i = 0; i < o.length; i++) o[i] &&
|
|
217
|
-
n ||
|
|
216
|
+
if (o = e.__k) for (i = 0; i < o.length; i++) o[i] && ut(o[i], t, n || typeof e.type != "function");
|
|
217
|
+
n || Ne(e.__e), e.__c = e.__ = e.__e = void 0;
|
|
218
218
|
}
|
|
219
|
-
function
|
|
219
|
+
function Lt(e, t, n) {
|
|
220
220
|
return this.constructor(e, n);
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function De(e, t, n) {
|
|
223
223
|
var o, i, s, l;
|
|
224
|
-
t == document && (t = document.documentElement), M.__ && M.__(e, t), i = (o = !1) ? null : t.__k, s = [], l = [],
|
|
224
|
+
t == document && (t = document.documentElement), M.__ && M.__(e, t), i = (o = !1) ? null : t.__k, s = [], l = [], Me(t, e = t.__k = kt(we, null, [e]), i || ne, ne, t.namespaceURI, i ? null : t.firstChild ? ge.call(t.childNodes) : null, s, i ? i.__e : t.firstChild, o, l), at(s, e, l);
|
|
225
225
|
}
|
|
226
|
-
function
|
|
226
|
+
function Nt(e) {
|
|
227
227
|
function t(n) {
|
|
228
228
|
var o, i;
|
|
229
229
|
return this.getChildContext || (o = /* @__PURE__ */ new Set(), (i = {})[t.__c] = this, this.getChildContext = function() {
|
|
@@ -232,7 +232,7 @@ function Et(e) {
|
|
|
232
232
|
o = null;
|
|
233
233
|
}, this.shouldComponentUpdate = function(s) {
|
|
234
234
|
this.props.value != s.value && o.forEach(function(l) {
|
|
235
|
-
l.__e = !0,
|
|
235
|
+
l.__e = !0, Se(l);
|
|
236
236
|
});
|
|
237
237
|
}, this.sub = function(s) {
|
|
238
238
|
o.add(s);
|
|
@@ -242,46 +242,46 @@ function Et(e) {
|
|
|
242
242
|
};
|
|
243
243
|
}), n.children;
|
|
244
244
|
}
|
|
245
|
-
return t.__c = "__cC" +
|
|
245
|
+
return t.__c = "__cC" + ot++, t.__ = e, t.Provider = t.__l = (t.Consumer = function(n, o) {
|
|
246
246
|
return n.children(o);
|
|
247
247
|
}).contextType = t, t;
|
|
248
248
|
}
|
|
249
|
-
|
|
249
|
+
ge = rt.slice, M = { __e: function(e, t, n, o) {
|
|
250
250
|
for (var i, s, l; t = t.__; ) if ((i = t.__c) && !i.__) try {
|
|
251
251
|
if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(e)), l = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, o || {}), l = i.__d), l) return i.__E = i;
|
|
252
252
|
} catch (r) {
|
|
253
253
|
e = r;
|
|
254
254
|
}
|
|
255
255
|
throw e;
|
|
256
|
-
} },
|
|
256
|
+
} }, Qe = 0, de.prototype.setState = function(e, t) {
|
|
257
257
|
var n;
|
|
258
|
-
n = this.__s != null && this.__s != this.state ? this.__s : this.__s =
|
|
259
|
-
},
|
|
260
|
-
this.__v && (this.__e = !0, e && this.__h.push(e),
|
|
261
|
-
},
|
|
258
|
+
n = this.__s != null && this.__s != this.state ? this.__s : this.__s = H({}, this.state), typeof e == "function" && (e = e(H({}, n), this.props)), e && H(n, e), e != null && this.__v && (t && this._sb.push(t), Se(this));
|
|
259
|
+
}, de.prototype.forceUpdate = function(e) {
|
|
260
|
+
this.__v && (this.__e = !0, e && this.__h.push(e), Se(this));
|
|
261
|
+
}, de.prototype.render = we, X = [], et = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, tt = function(e, t) {
|
|
262
262
|
return e.__v.__b - t.__v.__b;
|
|
263
|
-
},
|
|
264
|
-
var
|
|
263
|
+
}, _e.__r = 0, nt = /(PointerCapture)$|Capture$/i, Le = 0, Te = Fe(!1), ke = Fe(!0), ot = 0;
|
|
264
|
+
var Mt = 0;
|
|
265
265
|
function m(e, t, n, o, i, s) {
|
|
266
266
|
t || (t = {});
|
|
267
267
|
var l, r, a = t;
|
|
268
268
|
if ("ref" in a) for (r in a = {}, t) r == "ref" ? l = t[r] : a[r] = t[r];
|
|
269
|
-
var c = { type: e, props: a, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --
|
|
269
|
+
var c = { type: e, props: a, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Mt, __i: -1, __u: 0, __source: i, __self: s };
|
|
270
270
|
if (typeof e == "function" && (l = e.defaultProps)) for (r in l) a[r] === void 0 && (a[r] = l[r]);
|
|
271
271
|
return M.vnode && M.vnode(c), c;
|
|
272
272
|
}
|
|
273
|
-
var
|
|
274
|
-
function
|
|
275
|
-
|
|
273
|
+
var Z, P, ye, Oe, oe = 0, dt = [], F = M, $e = F.__b, Ue = F.__r, Ge = F.diffed, We = F.__c, je = F.unmount, qe = F.__;
|
|
274
|
+
function Ce(e, t) {
|
|
275
|
+
F.__h && F.__h(P, e, oe || t), oe = 0;
|
|
276
276
|
var n = P.__H || (P.__H = { __: [], __h: [] });
|
|
277
277
|
return e >= n.__.length && n.__.push({}), n.__[e];
|
|
278
278
|
}
|
|
279
|
-
function
|
|
280
|
-
return oe = 1,
|
|
279
|
+
function W(e) {
|
|
280
|
+
return oe = 1, At(ft, e);
|
|
281
281
|
}
|
|
282
|
-
function
|
|
283
|
-
var o =
|
|
284
|
-
if (o.t = e, !o.__c && (o.__ = [
|
|
282
|
+
function At(e, t, n) {
|
|
283
|
+
var o = Ce(Z++, 2);
|
|
284
|
+
if (o.t = e, !o.__c && (o.__ = [ft(void 0, t), function(r) {
|
|
285
285
|
var a = o.__N ? o.__N[0] : o.__[0], c = o.t(a, r);
|
|
286
286
|
a !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
|
|
287
287
|
}], o.__c = P, !P.__f)) {
|
|
@@ -313,98 +313,98 @@ function Nt(e, t, n) {
|
|
|
313
313
|
}
|
|
314
314
|
return o.__N || o.__;
|
|
315
315
|
}
|
|
316
|
-
function
|
|
317
|
-
var n =
|
|
318
|
-
!
|
|
316
|
+
function I(e, t) {
|
|
317
|
+
var n = Ce(Z++, 3);
|
|
318
|
+
!F.__s && ht(n.__H, t) && (n.__ = e, n.u = t, P.__H.__h.push(n));
|
|
319
319
|
}
|
|
320
|
-
function
|
|
321
|
-
return oe = 5,
|
|
320
|
+
function R(e) {
|
|
321
|
+
return oe = 5, Q(function() {
|
|
322
322
|
return { current: e };
|
|
323
323
|
}, []);
|
|
324
324
|
}
|
|
325
|
-
function
|
|
326
|
-
var n =
|
|
327
|
-
return
|
|
325
|
+
function Q(e, t) {
|
|
326
|
+
var n = Ce(Z++, 7);
|
|
327
|
+
return ht(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
|
|
328
328
|
}
|
|
329
|
-
function
|
|
330
|
-
return oe = 8,
|
|
329
|
+
function He(e, t) {
|
|
330
|
+
return oe = 8, Q(function() {
|
|
331
331
|
return e;
|
|
332
332
|
}, t);
|
|
333
333
|
}
|
|
334
|
-
function
|
|
335
|
-
var t = P.context[e.__c], n =
|
|
334
|
+
function Pt(e) {
|
|
335
|
+
var t = P.context[e.__c], n = Ce(Z++, 9);
|
|
336
336
|
return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(P)), t.props.value) : e.__;
|
|
337
337
|
}
|
|
338
|
-
function
|
|
339
|
-
for (var e; e =
|
|
340
|
-
e.__H.__h.forEach(
|
|
338
|
+
function It() {
|
|
339
|
+
for (var e; e = dt.shift(); ) if (e.__P && e.__H) try {
|
|
340
|
+
e.__H.__h.forEach(he), e.__H.__h.forEach(ze), e.__H.__h = [];
|
|
341
341
|
} catch (t) {
|
|
342
|
-
e.__H.__h = [],
|
|
342
|
+
e.__H.__h = [], F.__e(t, e.__v);
|
|
343
343
|
}
|
|
344
344
|
}
|
|
345
|
-
|
|
346
|
-
P = null,
|
|
347
|
-
},
|
|
348
|
-
e && t.__k && t.__k.__m && (e.__m = t.__k.__m),
|
|
349
|
-
},
|
|
350
|
-
|
|
345
|
+
F.__b = function(e) {
|
|
346
|
+
P = null, $e && $e(e);
|
|
347
|
+
}, F.__ = function(e, t) {
|
|
348
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), qe && qe(e, t);
|
|
349
|
+
}, F.__r = function(e) {
|
|
350
|
+
Ue && Ue(e), Z = 0;
|
|
351
351
|
var t = (P = e.__c).__H;
|
|
352
|
-
t && (
|
|
352
|
+
t && (ye === P ? (t.__h = [], P.__h = [], t.__.forEach(function(n) {
|
|
353
353
|
n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
|
|
354
|
-
})) : (t.__h.forEach(
|
|
355
|
-
},
|
|
356
|
-
|
|
354
|
+
})) : (t.__h.forEach(he), t.__h.forEach(ze), t.__h = [], Z = 0)), ye = P;
|
|
355
|
+
}, F.diffed = function(e) {
|
|
356
|
+
Ge && Ge(e);
|
|
357
357
|
var t = e.__c;
|
|
358
|
-
t && t.__H && (t.__H.__h.length && (
|
|
358
|
+
t && t.__H && (t.__H.__h.length && (dt.push(t) !== 1 && Oe === F.requestAnimationFrame || ((Oe = F.requestAnimationFrame) || xt)(It)), t.__H.__.forEach(function(n) {
|
|
359
359
|
n.u && (n.__H = n.u), n.u = void 0;
|
|
360
|
-
})),
|
|
361
|
-
},
|
|
360
|
+
})), ye = P = null;
|
|
361
|
+
}, F.__c = function(e, t) {
|
|
362
362
|
t.some(function(n) {
|
|
363
363
|
try {
|
|
364
|
-
n.__h.forEach(
|
|
365
|
-
return !o.__ ||
|
|
364
|
+
n.__h.forEach(he), n.__h = n.__h.filter(function(o) {
|
|
365
|
+
return !o.__ || ze(o);
|
|
366
366
|
});
|
|
367
367
|
} catch (o) {
|
|
368
368
|
t.some(function(i) {
|
|
369
369
|
i.__h && (i.__h = []);
|
|
370
|
-
}), t = [],
|
|
370
|
+
}), t = [], F.__e(o, n.__v);
|
|
371
371
|
}
|
|
372
|
-
}),
|
|
373
|
-
},
|
|
374
|
-
|
|
372
|
+
}), We && We(e, t);
|
|
373
|
+
}, F.unmount = function(e) {
|
|
374
|
+
je && je(e);
|
|
375
375
|
var t, n = e.__c;
|
|
376
376
|
n && n.__H && (n.__H.__.forEach(function(o) {
|
|
377
377
|
try {
|
|
378
|
-
|
|
378
|
+
he(o);
|
|
379
379
|
} catch (i) {
|
|
380
380
|
t = i;
|
|
381
381
|
}
|
|
382
|
-
}), n.__H = void 0, t &&
|
|
382
|
+
}), n.__H = void 0, t && F.__e(t, n.__v));
|
|
383
383
|
};
|
|
384
|
-
var
|
|
385
|
-
function
|
|
384
|
+
var Be = typeof requestAnimationFrame == "function";
|
|
385
|
+
function xt(e) {
|
|
386
386
|
var t, n = function() {
|
|
387
|
-
clearTimeout(o),
|
|
387
|
+
clearTimeout(o), Be && cancelAnimationFrame(t), setTimeout(e);
|
|
388
388
|
}, o = setTimeout(n, 100);
|
|
389
|
-
|
|
389
|
+
Be && (t = requestAnimationFrame(n));
|
|
390
390
|
}
|
|
391
|
-
function
|
|
391
|
+
function he(e) {
|
|
392
392
|
var t = P, n = e.__c;
|
|
393
393
|
typeof n == "function" && (e.__c = void 0, n()), P = t;
|
|
394
394
|
}
|
|
395
|
-
function
|
|
395
|
+
function ze(e) {
|
|
396
396
|
var t = P;
|
|
397
397
|
e.__c = e.__(), P = t;
|
|
398
398
|
}
|
|
399
|
-
function
|
|
399
|
+
function ht(e, t) {
|
|
400
400
|
return !e || e.length !== t.length || t.some(function(n, o) {
|
|
401
401
|
return n !== e[o];
|
|
402
402
|
});
|
|
403
403
|
}
|
|
404
|
-
function
|
|
404
|
+
function ft(e, t) {
|
|
405
405
|
return typeof t == "function" ? t(e) : t;
|
|
406
406
|
}
|
|
407
|
-
const
|
|
407
|
+
const Rt = (e) => ({
|
|
408
408
|
saveGameData(t) {
|
|
409
409
|
try {
|
|
410
410
|
localStorage.setItem(e, JSON.stringify(t));
|
|
@@ -427,14 +427,14 @@ const It = (e) => ({
|
|
|
427
427
|
console.error("Failed to reset maze game data:", t);
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
|
-
}),
|
|
430
|
+
}), mt = Nt(void 0), Ve = {
|
|
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
|
+
}, Ee = {
|
|
438
438
|
isGameActive: !0,
|
|
439
439
|
levelTransitioning: !1,
|
|
440
440
|
maze: null,
|
|
@@ -447,9 +447,9 @@ const It = (e) => ({
|
|
|
447
447
|
showClue: !1,
|
|
448
448
|
playerPath: [],
|
|
449
449
|
visitCounts: {}
|
|
450
|
-
},
|
|
451
|
-
const n =
|
|
452
|
-
|
|
450
|
+
}, Ft = ({ children: e, config: t }) => {
|
|
451
|
+
const n = Rt(t.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = W(() => o || { ...Ve });
|
|
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 It = (e) => ({
|
|
|
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,13 +468,13 @@ const It = (e) => ({
|
|
|
468
468
|
i.levelScores,
|
|
469
469
|
i.totalScore
|
|
470
470
|
]);
|
|
471
|
-
const [l, r] =
|
|
472
|
-
...
|
|
473
|
-
}), a =
|
|
474
|
-
|
|
471
|
+
const [l, r] = W({
|
|
472
|
+
...Ee
|
|
473
|
+
}), a = R(l);
|
|
474
|
+
I(() => {
|
|
475
475
|
a.current = l;
|
|
476
476
|
}, [l]);
|
|
477
|
-
const c =
|
|
477
|
+
const c = Q(() => [
|
|
478
478
|
l.playerAtExit ? 1 : 0,
|
|
479
479
|
l.foodCollected === l.totalFoodCount ? 1 : 0,
|
|
480
480
|
l.showClue ? 0 : 1
|
|
@@ -485,13 +485,13 @@ const It = (e) => ({
|
|
|
485
485
|
l.showClue
|
|
486
486
|
]), d = () => {
|
|
487
487
|
n.resetGameData(), s({
|
|
488
|
-
...
|
|
488
|
+
...Ve
|
|
489
489
|
}), r({
|
|
490
|
-
...
|
|
490
|
+
...Ee
|
|
491
491
|
});
|
|
492
492
|
};
|
|
493
493
|
return /* @__PURE__ */ m(
|
|
494
|
-
|
|
494
|
+
mt.Provider,
|
|
495
495
|
{
|
|
496
496
|
value: {
|
|
497
497
|
gameProgress: i,
|
|
@@ -507,11 +507,11 @@ const It = (e) => ({
|
|
|
507
507
|
}
|
|
508
508
|
);
|
|
509
509
|
}, re = () => {
|
|
510
|
-
const e =
|
|
510
|
+
const e = Pt(mt);
|
|
511
511
|
if (!e)
|
|
512
512
|
throw new Error("useGameContext must be used within a GameProvider");
|
|
513
513
|
return e;
|
|
514
|
-
}, ie = (e) =>
|
|
514
|
+
}, ie = (e) => Q(() => {
|
|
515
515
|
const t = e.map((r) => r.length), n = t.reduce((r, a) => r + a, 0), o = e.length, i = (r) => {
|
|
516
516
|
if (r < 1 || r > n) return 0;
|
|
517
517
|
let a = 0;
|
|
@@ -564,7 +564,7 @@ const It = (e) => ({
|
|
|
564
564
|
}
|
|
565
565
|
};
|
|
566
566
|
return l;
|
|
567
|
-
}, [e]),
|
|
567
|
+
}, [e]), Dt = ({ onTierChange: e, disabled: t }) => {
|
|
568
568
|
const { gameProgress: n, config: o } = re(), { i18n: i, levelConfig: s } = o, { currentTier: l, highestUnlockedTier: r } = n, c = ie(s).getTotalTiers();
|
|
569
569
|
return /* @__PURE__ */ m("div", { className: "tier-selector", children: /* @__PURE__ */ m(
|
|
570
570
|
"select",
|
|
@@ -586,14 +586,14 @@ const It = (e) => ({
|
|
|
586
586
|
))
|
|
587
587
|
}
|
|
588
588
|
) });
|
|
589
|
-
},
|
|
590
|
-
const { gameProgress: n, config: o } = re(), { i18n: i, levelConfig: s } = o, { currentTier: l, levelScores: r, currentLevel: a, highestUnlockedLevel: c } = n, d = ie(s), u =
|
|
589
|
+
}, Ot = ({ onLevelChange: e, disabled: t }) => {
|
|
590
|
+
const { gameProgress: n, config: o } = re(), { i18n: i, levelConfig: s } = o, { currentTier: l, levelScores: r, currentLevel: a, highestUnlockedLevel: c } = n, d = ie(s), u = Q(() => {
|
|
591
591
|
const [h, f] = d.getTierLevelsRange(l);
|
|
592
|
-
return Array.from({ length: f - h + 1 }, (
|
|
593
|
-
const
|
|
592
|
+
return Array.from({ length: f - h + 1 }, (g, _) => {
|
|
593
|
+
const v = h + _, T = r[v] || 0;
|
|
594
594
|
return {
|
|
595
|
-
level:
|
|
596
|
-
score:
|
|
595
|
+
level: v,
|
|
596
|
+
score: T
|
|
597
597
|
};
|
|
598
598
|
});
|
|
599
599
|
}, [l, r]);
|
|
@@ -632,13 +632,13 @@ const It = (e) => ({
|
|
|
632
632
|
onConfirm: u,
|
|
633
633
|
onCancel: h
|
|
634
634
|
}) => {
|
|
635
|
-
const f =
|
|
636
|
-
return
|
|
637
|
-
const
|
|
638
|
-
|
|
635
|
+
const f = R(null);
|
|
636
|
+
return I(() => {
|
|
637
|
+
const g = (_) => {
|
|
638
|
+
_.key === "Escape" && h?.();
|
|
639
639
|
};
|
|
640
|
-
return e && document.addEventListener("keydown",
|
|
641
|
-
document.removeEventListener("keydown",
|
|
640
|
+
return e && document.addEventListener("keydown", g), () => {
|
|
641
|
+
document.removeEventListener("keydown", g);
|
|
642
642
|
};
|
|
643
643
|
}, [e, h]), /* @__PURE__ */ m(
|
|
644
644
|
"div",
|
|
@@ -700,7 +700,7 @@ const It = (e) => ({
|
|
|
700
700
|
for (; this.container.firstChild; )
|
|
701
701
|
this.container.removeChild(this.container.firstChild);
|
|
702
702
|
}
|
|
703
|
-
},
|
|
703
|
+
}, $t = () => {
|
|
704
704
|
const {
|
|
705
705
|
gameProgress: e,
|
|
706
706
|
setGameProgress: t,
|
|
@@ -709,44 +709,44 @@ const It = (e) => ({
|
|
|
709
709
|
gamePlayStateRef: i,
|
|
710
710
|
resetGame: s,
|
|
711
711
|
config: l
|
|
712
|
-
} = re(), { i18n: r, levelConfig: a } = l, c = ie(a), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = e,
|
|
712
|
+
} = re(), { i18n: r, levelConfig: a } = l, c = ie(a), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = e, g = c.getTotalLevels(), [_, v] = W(!1), [T, b] = W(!1), [C, p] = W(!1), S = (O) => {
|
|
713
713
|
const $ = c.getFirstLevelOfTier(O);
|
|
714
|
-
c.isLevelUnlocked($, h) && (t((
|
|
714
|
+
c.isLevelUnlocked($, h) && (t((U) => ({ ...U, currentTier: O })), w($));
|
|
715
715
|
}, w = (O) => {
|
|
716
716
|
c.isLevelUnlocked(O, h) && (t(($) => ({ ...$, currentLevel: O })), q.show(r.levelGoToast.replace("%LEVEL%", O.toString())));
|
|
717
717
|
}, y = () => {
|
|
718
|
-
|
|
719
|
-
}, S = () => {
|
|
720
|
-
_(!1);
|
|
721
|
-
}, N = () => {
|
|
722
|
-
g(!0);
|
|
718
|
+
v(!0);
|
|
723
719
|
}, z = () => {
|
|
724
|
-
|
|
720
|
+
v(!1);
|
|
721
|
+
}, N = () => {
|
|
722
|
+
p(!0);
|
|
725
723
|
}, E = () => {
|
|
724
|
+
p(!1);
|
|
725
|
+
}, k = () => {
|
|
726
726
|
q.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
|
|
727
727
|
...i.current,
|
|
728
728
|
// need to sync with ref
|
|
729
729
|
showClue: !i.current.showClue
|
|
730
|
-
})),
|
|
730
|
+
})), p(!1);
|
|
731
731
|
}, L = () => {
|
|
732
|
-
|
|
732
|
+
b(!0);
|
|
733
733
|
}, A = () => {
|
|
734
|
-
s(),
|
|
735
|
-
},
|
|
736
|
-
|
|
734
|
+
s(), b(!1), q.show(r.resetDoneToast);
|
|
735
|
+
}, x = () => {
|
|
736
|
+
b(!1);
|
|
737
737
|
};
|
|
738
738
|
return /* @__PURE__ */ m("div", { class: "game-panel-container", children: [
|
|
739
739
|
/* @__PURE__ */ m("div", { className: "game-controls", children: [
|
|
740
740
|
/* @__PURE__ */ m("div", { className: "selectors-container", children: [
|
|
741
741
|
/* @__PURE__ */ m(
|
|
742
|
-
|
|
742
|
+
Dt,
|
|
743
743
|
{
|
|
744
|
-
onTierChange:
|
|
744
|
+
onTierChange: S,
|
|
745
745
|
disabled: d
|
|
746
746
|
}
|
|
747
747
|
),
|
|
748
748
|
/* @__PURE__ */ m(
|
|
749
|
-
|
|
749
|
+
Ot,
|
|
750
750
|
{
|
|
751
751
|
onLevelChange: w,
|
|
752
752
|
disabled: d
|
|
@@ -768,14 +768,14 @@ const It = (e) => ({
|
|
|
768
768
|
/* @__PURE__ */ m(
|
|
769
769
|
te,
|
|
770
770
|
{
|
|
771
|
-
isOpen:
|
|
771
|
+
isOpen: _,
|
|
772
772
|
title: r.settings,
|
|
773
773
|
noConfirm: !0,
|
|
774
774
|
cancelText: r.close,
|
|
775
|
-
onCancel:
|
|
775
|
+
onCancel: z,
|
|
776
776
|
children: [
|
|
777
777
|
/* @__PURE__ */ m("div", { className: "settings-stats", children: [
|
|
778
|
-
/* @__PURE__ */ m("div", { children: r.levelComplete + `: ${h}/${
|
|
778
|
+
/* @__PURE__ */ m("div", { children: r.levelComplete + `: ${h}/${g}` }),
|
|
779
779
|
/* @__PURE__ */ m("div", { children: r.starsCollected + ": " + f }),
|
|
780
780
|
/* @__PURE__ */ m("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
|
|
781
781
|
] }),
|
|
@@ -797,81 +797,81 @@ const It = (e) => ({
|
|
|
797
797
|
/* @__PURE__ */ m(
|
|
798
798
|
te,
|
|
799
799
|
{
|
|
800
|
-
isOpen:
|
|
800
|
+
isOpen: T,
|
|
801
801
|
title: r.confirmReset,
|
|
802
802
|
message: r.confirmResetMessage,
|
|
803
803
|
confirmText: r.reset,
|
|
804
804
|
cancelText: r.cancel,
|
|
805
805
|
onConfirm: A,
|
|
806
|
-
onCancel:
|
|
806
|
+
onCancel: x
|
|
807
807
|
}
|
|
808
808
|
),
|
|
809
809
|
/* @__PURE__ */ m(
|
|
810
810
|
te,
|
|
811
811
|
{
|
|
812
|
-
isOpen:
|
|
812
|
+
isOpen: C,
|
|
813
813
|
title: r.confirmClue,
|
|
814
814
|
message: r.confirmClueMessage,
|
|
815
815
|
confirmText: r.confirm,
|
|
816
816
|
cancelText: r.cancel,
|
|
817
|
-
onConfirm:
|
|
818
|
-
onCancel:
|
|
817
|
+
onConfirm: k,
|
|
818
|
+
onCancel: E
|
|
819
819
|
}
|
|
820
820
|
)
|
|
821
821
|
] });
|
|
822
822
|
};
|
|
823
|
-
function
|
|
823
|
+
function Pe(e, t) {
|
|
824
824
|
if (!(e instanceof t))
|
|
825
825
|
throw new TypeError("Cannot call a class as a function");
|
|
826
826
|
}
|
|
827
|
-
function
|
|
827
|
+
function Ut(e, t) {
|
|
828
828
|
for (var n = 0; n < t.length; n++) {
|
|
829
829
|
var o = t[n];
|
|
830
830
|
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, o.key, o);
|
|
831
831
|
}
|
|
832
832
|
}
|
|
833
|
-
function
|
|
834
|
-
return t &&
|
|
833
|
+
function Ie(e, t, n) {
|
|
834
|
+
return t && Ut(e.prototype, t), e;
|
|
835
835
|
}
|
|
836
|
-
function
|
|
836
|
+
function Xe(e) {
|
|
837
837
|
return +e.replace(/px/, "");
|
|
838
838
|
}
|
|
839
|
-
function
|
|
840
|
-
var t = window.devicePixelRatio, n = getComputedStyle(e), o =
|
|
839
|
+
function Gt(e) {
|
|
840
|
+
var t = window.devicePixelRatio, n = getComputedStyle(e), o = Xe(n.getPropertyValue("width")), i = Xe(n.getPropertyValue("height"));
|
|
841
841
|
e.setAttribute("width", (o * t).toString()), e.setAttribute("height", (i * t).toString());
|
|
842
842
|
}
|
|
843
843
|
function j(e, t) {
|
|
844
844
|
var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (t - e) + e;
|
|
845
845
|
return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
|
|
846
846
|
}
|
|
847
|
-
function
|
|
847
|
+
function Ye(e) {
|
|
848
848
|
return e[j(0, e.length)];
|
|
849
849
|
}
|
|
850
|
-
var
|
|
851
|
-
function
|
|
850
|
+
var Wt = 125e-5, jt = 5e-4, qt = 9e-4, Ht = 1e-5, Bt = 6, Vt = 80, Xt = 0.9, Yt = 1.7, Kt = 0.2, Jt = 0.6, Zt = 0.03, Qt = 0.07, en = 15, tn = 82, nn = 100, on = 250, rn = 40, sn = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
|
|
851
|
+
function Ke(e) {
|
|
852
852
|
var t = 1920;
|
|
853
853
|
return Math.log(e) / Math.log(t);
|
|
854
854
|
}
|
|
855
|
-
var
|
|
855
|
+
var Je = /* @__PURE__ */ function() {
|
|
856
856
|
function e(t) {
|
|
857
|
-
|
|
858
|
-
var n = t.initialPosition, o = t.direction, i = t.confettiRadius, s = t.confettiColors, l = t.emojis, r = t.emojiSize, a = t.canvasWidth, c = j(
|
|
857
|
+
Pe(this, e);
|
|
858
|
+
var n = t.initialPosition, o = t.direction, i = t.confettiRadius, s = t.confettiColors, l = t.emojis, r = t.emojiSize, a = t.canvasWidth, c = j(Xt, Yt, 3), d = c * Ke(a);
|
|
859
859
|
this.confettiSpeed = {
|
|
860
860
|
x: d,
|
|
861
861
|
y: d
|
|
862
|
-
}, this.finalConfettiSpeedX = j(
|
|
862
|
+
}, this.finalConfettiSpeedX = j(Kt, Jt, 3), this.rotationSpeed = l.length ? 0.01 : j(Zt, Qt, 3) * Ke(a), this.dragForceCoefficient = j(jt, qt, 6), this.radius = {
|
|
863
863
|
x: i,
|
|
864
864
|
y: i
|
|
865
865
|
}, this.initialRadius = i, this.rotationAngle = o === "left" ? j(0, 0.2, 3) : j(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = j(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
|
|
866
|
-
var u = o === "left" ? j(
|
|
866
|
+
var u = o === "left" ? j(tn, en) * Math.PI / 180 : j(-15, -82) * Math.PI / 180;
|
|
867
867
|
this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
|
|
868
868
|
var h = j(-150, 0), f = {
|
|
869
869
|
x: n.x + (o === "left" ? -h : h) * this.absCos,
|
|
870
870
|
y: n.y - h * this.absSin
|
|
871
871
|
};
|
|
872
|
-
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = l.length ? null :
|
|
872
|
+
this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = l.length ? null : Ye(s), this.emoji = l.length ? Ye(l) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
|
|
873
873
|
}
|
|
874
|
-
return
|
|
874
|
+
return Ie(e, [{
|
|
875
875
|
key: "draw",
|
|
876
876
|
value: function(n) {
|
|
877
877
|
var o = this.currentPosition, i = this.radius, s = this.color, l = this.emoji, r = this.rotationAngle, a = this.emojiRotationAngle, c = this.emojiSize, d = window.devicePixelRatio;
|
|
@@ -881,7 +881,7 @@ var Ye = /* @__PURE__ */ function() {
|
|
|
881
881
|
key: "updatePosition",
|
|
882
882
|
value: function(n, o) {
|
|
883
883
|
var i = this.confettiSpeed, s = this.dragForceCoefficient, l = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, a = this.rotationSpeed, c = this.createdAt, d = this.direction, u = o - c;
|
|
884
|
-
if (i.x > l && (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 +
|
|
884
|
+
if (i.x > l && (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 + Wt * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : Ht * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
|
|
885
885
|
this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
|
|
886
886
|
return;
|
|
887
887
|
}
|
|
@@ -890,16 +890,16 @@ var Ye = /* @__PURE__ */ function() {
|
|
|
890
890
|
}, {
|
|
891
891
|
key: "getIsVisibleOnCanvas",
|
|
892
892
|
value: function(n) {
|
|
893
|
-
return this.currentPosition.y < n +
|
|
893
|
+
return this.currentPosition.y < n + nn;
|
|
894
894
|
}
|
|
895
895
|
}]), e;
|
|
896
896
|
}();
|
|
897
|
-
function
|
|
897
|
+
function ln() {
|
|
898
898
|
var e = document.createElement("canvas");
|
|
899
899
|
return e.style.position = "fixed", e.style.width = "100%", e.style.height = "100%", e.style.top = "0", e.style.left = "0", e.style.zIndex = "1000", e.style.pointerEvents = "none", document.body.appendChild(e), e;
|
|
900
900
|
}
|
|
901
|
-
function
|
|
902
|
-
var t = e.confettiRadius, n = t === void 0 ?
|
|
901
|
+
function an(e) {
|
|
902
|
+
var t = e.confettiRadius, n = t === void 0 ? Bt : t, o = e.confettiNumber, i = o === void 0 ? e.confettiesNumber || (e.emojis ? rn : on) : o, s = e.confettiColors, l = s === void 0 ? sn : s, r = e.emojis, a = r === void 0 ? e.emojies || [] : r, c = e.emojiSize, d = c === void 0 ? Vt : c;
|
|
903
903
|
return e.emojies && console.error("emojies argument is deprecated, please use emojis instead"), e.confettiesNumber && console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"), {
|
|
904
904
|
confettiRadius: n,
|
|
905
905
|
confettiNumber: i,
|
|
@@ -908,14 +908,14 @@ function sn(e) {
|
|
|
908
908
|
emojiSize: d
|
|
909
909
|
};
|
|
910
910
|
}
|
|
911
|
-
var
|
|
911
|
+
var cn = /* @__PURE__ */ function() {
|
|
912
912
|
function e(t) {
|
|
913
913
|
var n = this;
|
|
914
|
-
|
|
914
|
+
Pe(this, e), this.canvasContext = t, this.shapes = [], this.promise = new Promise(function(o) {
|
|
915
915
|
return n.resolvePromise = o;
|
|
916
916
|
});
|
|
917
917
|
}
|
|
918
|
-
return
|
|
918
|
+
return Ie(e, [{
|
|
919
919
|
key: "getBatchCompletePromise",
|
|
920
920
|
value: function() {
|
|
921
921
|
return this.promise;
|
|
@@ -941,15 +941,15 @@ var ln = /* @__PURE__ */ function() {
|
|
|
941
941
|
});
|
|
942
942
|
}
|
|
943
943
|
}]), e;
|
|
944
|
-
}(),
|
|
944
|
+
}(), un = /* @__PURE__ */ function() {
|
|
945
945
|
function e() {
|
|
946
946
|
var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
947
|
-
|
|
947
|
+
Pe(this, e), this.activeConfettiBatches = [], this.canvas = t.canvas || ln(), 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);
|
|
948
948
|
}
|
|
949
|
-
return
|
|
949
|
+
return Ie(e, [{
|
|
950
950
|
key: "loop",
|
|
951
951
|
value: function() {
|
|
952
|
-
this.requestAnimationFrameRequested = !1,
|
|
952
|
+
this.requestAnimationFrameRequested = !1, Gt(this.canvas);
|
|
953
953
|
var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
|
|
954
954
|
this.activeConfettiBatches = this.activeConfettiBatches.filter(function(l) {
|
|
955
955
|
return l.processShapes({
|
|
@@ -966,14 +966,14 @@ var ln = /* @__PURE__ */ function() {
|
|
|
966
966
|
}, {
|
|
967
967
|
key: "addConfetti",
|
|
968
968
|
value: function() {
|
|
969
|
-
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o =
|
|
969
|
+
for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = an(n), i = o.confettiRadius, s = o.confettiNumber, l = o.confettiColors, r = o.emojis, a = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
|
|
970
970
|
x: 0,
|
|
971
971
|
y: h
|
|
972
|
-
},
|
|
972
|
+
}, g = {
|
|
973
973
|
x: d,
|
|
974
974
|
y: h
|
|
975
|
-
},
|
|
976
|
-
var
|
|
975
|
+
}, _ = new cn(this.canvasContext), v = 0; v < s / 2; v++) {
|
|
976
|
+
var T = new Je({
|
|
977
977
|
initialPosition: f,
|
|
978
978
|
direction: "right",
|
|
979
979
|
confettiRadius: i,
|
|
@@ -982,8 +982,8 @@ var ln = /* @__PURE__ */ function() {
|
|
|
982
982
|
emojis: r,
|
|
983
983
|
emojiSize: a,
|
|
984
984
|
canvasWidth: d
|
|
985
|
-
}),
|
|
986
|
-
initialPosition:
|
|
985
|
+
}), b = new Je({
|
|
986
|
+
initialPosition: g,
|
|
987
987
|
direction: "left",
|
|
988
988
|
confettiRadius: i,
|
|
989
989
|
confettiColors: l,
|
|
@@ -992,9 +992,9 @@ var ln = /* @__PURE__ */ function() {
|
|
|
992
992
|
emojiSize: a,
|
|
993
993
|
canvasWidth: d
|
|
994
994
|
});
|
|
995
|
-
|
|
995
|
+
_.addShapes(T, b);
|
|
996
996
|
}
|
|
997
|
-
return this.activeConfettiBatches.push(
|
|
997
|
+
return this.activeConfettiBatches.push(_), this.queueAnimationFrameIfNeeded(), _.getBatchCompletePromise();
|
|
998
998
|
}
|
|
999
999
|
}, {
|
|
1000
1000
|
key: "clearCanvas",
|
|
@@ -1008,7 +1008,7 @@ var ln = /* @__PURE__ */ function() {
|
|
|
1008
1008
|
}
|
|
1009
1009
|
}]), e;
|
|
1010
1010
|
}();
|
|
1011
|
-
const
|
|
1011
|
+
const dn = new un(), be = 3, hn = ({ onRetry: e }) => {
|
|
1012
1012
|
const {
|
|
1013
1013
|
config: t,
|
|
1014
1014
|
currentScore: n,
|
|
@@ -1016,75 +1016,75 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1016
1016
|
setGamePlayState: i,
|
|
1017
1017
|
gameProgress: s,
|
|
1018
1018
|
setGameProgress: l
|
|
1019
|
-
} = re(), { i18n: r, levelConfig: a } = t, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit:
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
}, [
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1019
|
+
} = re(), { i18n: r, levelConfig: a } = t, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: g, levelTransitioning: _ } = o, { currentLevel: v } = s, [T, b] = W(!1);
|
|
1020
|
+
I(() => {
|
|
1021
|
+
g && _ && (dn.addConfetti(), q.show(r.levelCompleteToast), b(!0));
|
|
1022
|
+
}, [g, _]);
|
|
1023
|
+
const C = ie(a), p = C.getTotalLevels(), S = Q(() => v >= p, [v, p]), w = () => {
|
|
1024
|
+
b(!1), q.show(r.levelRestartToast), e?.();
|
|
1025
1025
|
}, y = () => {
|
|
1026
|
-
|
|
1027
|
-
...
|
|
1026
|
+
b(!1), i((E) => ({
|
|
1027
|
+
...E,
|
|
1028
1028
|
isGameActive: !0,
|
|
1029
1029
|
levelTransitioning: !1
|
|
1030
1030
|
}));
|
|
1031
|
-
},
|
|
1032
|
-
|
|
1033
|
-
const
|
|
1034
|
-
if (!
|
|
1035
|
-
const { nextLevel:
|
|
1031
|
+
}, z = () => {
|
|
1032
|
+
b(!1);
|
|
1033
|
+
const E = C.getNextLevelInfo(v);
|
|
1034
|
+
if (!E) return;
|
|
1035
|
+
const { nextLevel: k, nextTier: L, isTierChange: A } = E;
|
|
1036
1036
|
A && q.show(
|
|
1037
1037
|
r.tierUnlockedToast.replace("%TIER%", L.toString())
|
|
1038
|
-
), l((
|
|
1039
|
-
...
|
|
1040
|
-
currentLevel:
|
|
1038
|
+
), l((x) => ({
|
|
1039
|
+
...x,
|
|
1040
|
+
currentLevel: k,
|
|
1041
1041
|
currentTier: L,
|
|
1042
|
-
highestUnlockedLevel: Math.max(
|
|
1043
|
-
highestUnlockedTier: Math.max(
|
|
1042
|
+
highestUnlockedLevel: Math.max(x.highestUnlockedLevel, k),
|
|
1043
|
+
highestUnlockedTier: Math.max(x.highestUnlockedTier, L),
|
|
1044
1044
|
levelScores: {
|
|
1045
|
-
...
|
|
1046
|
-
[
|
|
1045
|
+
...x.levelScores,
|
|
1046
|
+
[x.currentLevel]: Math.max(
|
|
1047
1047
|
Object.values(n).filter(Boolean).length,
|
|
1048
|
-
|
|
1048
|
+
x.levelScores[x.currentLevel] || 0
|
|
1049
1049
|
)
|
|
1050
1050
|
}
|
|
1051
1051
|
}));
|
|
1052
1052
|
}, N = () => {
|
|
1053
|
-
|
|
1054
|
-
const
|
|
1053
|
+
b(!1), l((E) => {
|
|
1054
|
+
const k = Math.max(
|
|
1055
1055
|
Object.values(n).filter(Boolean).length,
|
|
1056
|
-
|
|
1056
|
+
E.levelScores[E.currentLevel] || 0
|
|
1057
1057
|
), L = {
|
|
1058
|
-
...
|
|
1059
|
-
[
|
|
1058
|
+
...E.levelScores,
|
|
1059
|
+
[E.currentLevel]: k
|
|
1060
1060
|
};
|
|
1061
|
-
let A = 0,
|
|
1061
|
+
let A = 0, x = 0;
|
|
1062
1062
|
const O = Object.entries(L).sort(
|
|
1063
|
-
($,
|
|
1063
|
+
($, U) => Number($[0]) - Number(U[0])
|
|
1064
1064
|
);
|
|
1065
|
-
for (const [$,
|
|
1066
|
-
if (
|
|
1067
|
-
A = Number($),
|
|
1065
|
+
for (const [$, U] of O)
|
|
1066
|
+
if (U < be) {
|
|
1067
|
+
A = Number($), x = C.getTierByLevel(A);
|
|
1068
1068
|
break;
|
|
1069
1069
|
}
|
|
1070
|
-
return (A > 0 && A !==
|
|
1071
|
-
...
|
|
1072
|
-
currentLevel: A ||
|
|
1073
|
-
currentTier:
|
|
1070
|
+
return (A > 0 && A !== v || k < be) && q.show(r.notCompleteLevel), (A === 0 || k < be) && e?.(), {
|
|
1071
|
+
...E,
|
|
1072
|
+
currentLevel: A || E.currentLevel,
|
|
1073
|
+
currentTier: x || E.currentTier,
|
|
1074
1074
|
levelScores: L
|
|
1075
1075
|
};
|
|
1076
1076
|
});
|
|
1077
1077
|
};
|
|
1078
|
-
return
|
|
1079
|
-
const
|
|
1080
|
-
|
|
1078
|
+
return I(() => {
|
|
1079
|
+
const E = document.querySelector(".maze-game-container"), k = (L) => {
|
|
1080
|
+
T && ((L.key === " " || L.code === "Space") && E && (E.contains(document.activeElement) || document.activeElement === document.body) && (L.preventDefault(), S ? N() : z()), (L.key === "r" || L.code === "KeyR") && w(), (L.key === "c" || L.code === "KeyC") && y());
|
|
1081
1081
|
};
|
|
1082
|
-
return window.addEventListener("keydown",
|
|
1083
|
-
}, [
|
|
1082
|
+
return window.addEventListener("keydown", k), () => window.removeEventListener("keydown", k);
|
|
1083
|
+
}, [T, S]), /* @__PURE__ */ m(
|
|
1084
1084
|
te,
|
|
1085
1085
|
{
|
|
1086
1086
|
className: "level-complete-dialog",
|
|
1087
|
-
isOpen:
|
|
1087
|
+
isOpen: T,
|
|
1088
1088
|
title: r.congratulations,
|
|
1089
1089
|
cancelText: r.retry + " (R)",
|
|
1090
1090
|
onCancel: w,
|
|
@@ -1098,8 +1098,8 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1098
1098
|
/* @__PURE__ */ m("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
|
|
1099
1099
|
/* @__PURE__ */ m("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
|
|
1100
1100
|
] }),
|
|
1101
|
-
|
|
1102
|
-
/* @__PURE__ */ m("div", { className: "maze-go-next", children:
|
|
1101
|
+
S && /* @__PURE__ */ m("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
|
|
1102
|
+
/* @__PURE__ */ m("div", { className: "maze-go-next", children: S ? /* @__PURE__ */ m(
|
|
1103
1103
|
"button",
|
|
1104
1104
|
{
|
|
1105
1105
|
className: "maze-go-next-btn",
|
|
@@ -1115,7 +1115,7 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1115
1115
|
{
|
|
1116
1116
|
className: "maze-go-next-btn",
|
|
1117
1117
|
type: "button",
|
|
1118
|
-
onClick:
|
|
1118
|
+
onClick: z,
|
|
1119
1119
|
children: [
|
|
1120
1120
|
/* @__PURE__ */ m("span", { children: r.nextLevel }),
|
|
1121
1121
|
/* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
|
|
@@ -1126,18 +1126,21 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1126
1126
|
]
|
|
1127
1127
|
}
|
|
1128
1128
|
);
|
|
1129
|
-
},
|
|
1130
|
-
const n =
|
|
1129
|
+
}, _t = (e, t) => {
|
|
1130
|
+
const n = R({
|
|
1131
1131
|
canvasWidth: 0,
|
|
1132
1132
|
canvasHeight: 0
|
|
1133
1133
|
});
|
|
1134
|
-
return
|
|
1134
|
+
return I(() => {
|
|
1135
1135
|
const o = () => {
|
|
1136
1136
|
const s = e.current;
|
|
1137
1137
|
if (!s) return;
|
|
1138
1138
|
const l = s.parentElement;
|
|
1139
1139
|
if (!l) return;
|
|
1140
|
-
const r = l.clientWidth
|
|
1140
|
+
const r = l.clientWidth;
|
|
1141
|
+
if (r === 0)
|
|
1142
|
+
return;
|
|
1143
|
+
const a = window.devicePixelRatio || 1;
|
|
1141
1144
|
s.style.width = `${r}px`, s.style.height = `${r}px`;
|
|
1142
1145
|
const c = r * a, d = r * a;
|
|
1143
1146
|
s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d }, t?.();
|
|
@@ -1148,9 +1151,9 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1148
1151
|
window.removeEventListener("resize", o), i?.disconnect();
|
|
1149
1152
|
};
|
|
1150
1153
|
}, [e, t]), n;
|
|
1151
|
-
},
|
|
1152
|
-
const o =
|
|
1153
|
-
return
|
|
1154
|
+
}, vt = (e, t, n) => {
|
|
1155
|
+
const o = R({ cellWidth: 0, cellHeight: 0 });
|
|
1156
|
+
return I(() => {
|
|
1154
1157
|
const i = () => {
|
|
1155
1158
|
const l = e.current, r = t.maze;
|
|
1156
1159
|
if (!l || !r) return;
|
|
@@ -1165,12 +1168,12 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1165
1168
|
e.current && s?.disconnect();
|
|
1166
1169
|
};
|
|
1167
1170
|
}, [e, t.maze, n]), o;
|
|
1168
|
-
},
|
|
1171
|
+
}, ce = {
|
|
1169
1172
|
ArrowUp: [-1, 0],
|
|
1170
1173
|
ArrowDown: [1, 0],
|
|
1171
1174
|
ArrowLeft: [0, -1],
|
|
1172
1175
|
ArrowRight: [0, 1]
|
|
1173
|
-
},
|
|
1176
|
+
}, gt = ({
|
|
1174
1177
|
gamePlayStateRef: e,
|
|
1175
1178
|
setGamePlayState: t,
|
|
1176
1179
|
moveSpeed: n,
|
|
@@ -1183,46 +1186,46 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1183
1186
|
onExitReached: l,
|
|
1184
1187
|
onFirstMove: r
|
|
1185
1188
|
}) => {
|
|
1186
|
-
const a = () => o?.current ?? n ?? 0.03, c =
|
|
1187
|
-
(
|
|
1188
|
-
const
|
|
1189
|
-
if (!
|
|
1189
|
+
const a = () => o?.current ?? n ?? 0.03, c = R(!1), d = R(/* @__PURE__ */ new Set()), u = R(!1), h = He(
|
|
1190
|
+
(C, p) => {
|
|
1191
|
+
const S = e.current;
|
|
1192
|
+
if (!S.maze)
|
|
1190
1193
|
return { canMove: !1, newCell: null };
|
|
1191
|
-
const w = a(), [y,
|
|
1192
|
-
if (
|
|
1193
|
-
|
|
1194
|
+
const w = a(), [y, z] = ce[C];
|
|
1195
|
+
if (Ze(
|
|
1196
|
+
p,
|
|
1194
1197
|
y,
|
|
1195
|
-
|
|
1198
|
+
z,
|
|
1196
1199
|
i,
|
|
1197
1200
|
w,
|
|
1198
|
-
|
|
1201
|
+
S.maze
|
|
1199
1202
|
))
|
|
1200
1203
|
return { canMove: !1, newCell: null };
|
|
1201
|
-
const { row:
|
|
1202
|
-
if (L <
|
|
1204
|
+
const { row: E, col: k } = p, L = E + y * w, A = k + z * w, x = -0.5, O = S.maze.rows, $ = S.maze.cols;
|
|
1205
|
+
if (L < x || L >= O || A < x || A >= $)
|
|
1203
1206
|
return { canMove: !1, newCell: null };
|
|
1204
|
-
const
|
|
1205
|
-
return
|
|
1207
|
+
const U = E < 0 ? 0 : Math.floor(E), V = k < 0 ? 0 : Math.floor(k), B = L < 0 ? 0 : Math.floor(L), Y = A < 0 ? 0 : Math.floor(A);
|
|
1208
|
+
return B !== U || Y !== V ? S.maze.isValid(B, Y) ? {
|
|
1206
1209
|
canMove: !0,
|
|
1207
|
-
newCell: { row:
|
|
1210
|
+
newCell: { row: B, col: Y }
|
|
1208
1211
|
} : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
|
|
1209
1212
|
},
|
|
1210
1213
|
[i, a]
|
|
1211
1214
|
), f = () => {
|
|
1212
|
-
const
|
|
1213
|
-
Math.pow(
|
|
1215
|
+
const C = e.current, { row: p, col: S } = C.playerCell, w = i * 2, y = C.foodCells.findIndex((E) => Math.sqrt(
|
|
1216
|
+
Math.pow(p - E.row, 2) + Math.pow(S - E.col, 2)
|
|
1214
1217
|
) < w);
|
|
1215
1218
|
y !== -1 && s && (s(), e.current = {
|
|
1216
1219
|
...e.current,
|
|
1217
1220
|
foodCollected: e.current.foodCollected + 1,
|
|
1218
1221
|
foodCells: e.current.foodCells.filter(
|
|
1219
|
-
(
|
|
1222
|
+
(E, k) => k !== y
|
|
1220
1223
|
)
|
|
1221
1224
|
});
|
|
1222
|
-
const N =
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1225
|
+
const N = _n(
|
|
1226
|
+
C.playerCell,
|
|
1227
|
+
C.exitCell,
|
|
1228
|
+
C.maze
|
|
1226
1229
|
);
|
|
1227
1230
|
N && !e.current.playerAtExit ? (e.current = {
|
|
1228
1231
|
...e.current,
|
|
@@ -1241,15 +1244,15 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1241
1244
|
isGameActive: !0,
|
|
1242
1245
|
levelTransitioning: !1
|
|
1243
1246
|
});
|
|
1244
|
-
},
|
|
1245
|
-
const
|
|
1246
|
-
if ((N === 1 &&
|
|
1247
|
-
const L = `${y.row},${y.col}-${
|
|
1247
|
+
}, g = (C) => {
|
|
1248
|
+
const p = e.current, S = Math.round(C.row), w = Math.round(C.col), y = p.playerPath[p.playerPath.length - 1], z = y.row === S && y.col === w, N = Math.abs(y.row - S), E = Math.abs(y.col - w);
|
|
1249
|
+
if ((N === 1 && E === 0 || N === 0 && E === 1) && !z) {
|
|
1250
|
+
const L = `${y.row},${y.col}-${S},${w}`;
|
|
1248
1251
|
e.current = {
|
|
1249
1252
|
...e.current,
|
|
1250
1253
|
playerPath: [
|
|
1251
1254
|
...e.current.playerPath,
|
|
1252
|
-
{ row:
|
|
1255
|
+
{ row: S, col: w }
|
|
1253
1256
|
],
|
|
1254
1257
|
visitCounts: {
|
|
1255
1258
|
...e.current.visitCounts,
|
|
@@ -1257,70 +1260,70 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1257
1260
|
}
|
|
1258
1261
|
};
|
|
1259
1262
|
}
|
|
1260
|
-
},
|
|
1263
|
+
}, _ = () => {
|
|
1261
1264
|
if (c.current || d.current.size === 0) return;
|
|
1262
|
-
const
|
|
1263
|
-
!
|
|
1264
|
-
(
|
|
1265
|
+
const C = e.current;
|
|
1266
|
+
!C.playerCell || !Array.from(d.current).some(
|
|
1267
|
+
(S) => {
|
|
1265
1268
|
const { canMove: w } = h(
|
|
1266
|
-
|
|
1267
|
-
|
|
1269
|
+
S,
|
|
1270
|
+
C.playerCell
|
|
1268
1271
|
);
|
|
1269
1272
|
return w;
|
|
1270
1273
|
}
|
|
1271
1274
|
) || (!u.current && r && (u.current = !0, r()), c.current = !0);
|
|
1272
1275
|
};
|
|
1273
|
-
|
|
1274
|
-
const
|
|
1276
|
+
I(() => {
|
|
1277
|
+
const C = (w) => {
|
|
1275
1278
|
if (w.key === "ArrowUp" || w.key === "ArrowDown" || w.key === "ArrowLeft" || w.key === "ArrowRight" || w.key === " ") {
|
|
1276
1279
|
const y = document.activeElement;
|
|
1277
1280
|
if (y && (y.tagName === "INPUT" || y.tagName === "TEXTAREA" || y.getAttribute("contenteditable") === "true")) return;
|
|
1278
1281
|
w.preventDefault();
|
|
1279
1282
|
}
|
|
1280
|
-
},
|
|
1283
|
+
}, p = (w) => {
|
|
1281
1284
|
const y = w.key;
|
|
1282
|
-
if (!(y in
|
|
1283
|
-
const
|
|
1284
|
-
|
|
1285
|
-
},
|
|
1285
|
+
if (!(y in ce)) return;
|
|
1286
|
+
const z = document.activeElement;
|
|
1287
|
+
z && (z.tagName === "INPUT" || z.tagName === "TEXTAREA" || z.getAttribute("contenteditable") === "true") || (w.preventDefault(), e.current.isGameActive && (d.current.has(y) || (d.current.add(y), c.current || _())));
|
|
1288
|
+
}, S = (w) => {
|
|
1286
1289
|
const y = w.key;
|
|
1287
|
-
if (!(y in
|
|
1288
|
-
const
|
|
1289
|
-
|
|
1290
|
+
if (!(y in ce)) return;
|
|
1291
|
+
const z = document.activeElement;
|
|
1292
|
+
z && (z.tagName === "INPUT" || z.tagName === "TEXTAREA" || z.getAttribute("contenteditable") === "true") || (w.preventDefault(), d.current.delete(y), d.current.size === 0 && T());
|
|
1290
1293
|
};
|
|
1291
|
-
return window.addEventListener("keydown",
|
|
1294
|
+
return window.addEventListener("keydown", C, {
|
|
1292
1295
|
capture: !0
|
|
1293
|
-
}), window.addEventListener("keydown",
|
|
1294
|
-
window.removeEventListener("keydown",
|
|
1296
|
+
}), window.addEventListener("keydown", p), window.addEventListener("keyup", S), () => {
|
|
1297
|
+
window.removeEventListener("keydown", C, {
|
|
1295
1298
|
capture: !0
|
|
1296
|
-
}), window.removeEventListener("keydown",
|
|
1299
|
+
}), window.removeEventListener("keydown", p), window.removeEventListener("keyup", S);
|
|
1297
1300
|
};
|
|
1298
1301
|
}, []);
|
|
1299
|
-
const
|
|
1302
|
+
const v = He(() => {
|
|
1300
1303
|
if (!c.current || d.current.size === 0)
|
|
1301
1304
|
return e.current.playerCell;
|
|
1302
|
-
const
|
|
1303
|
-
let
|
|
1304
|
-
for (const
|
|
1305
|
-
const { canMove:
|
|
1306
|
-
if (
|
|
1307
|
-
const [
|
|
1308
|
-
|
|
1305
|
+
const C = a(), p = e.current.playerCell;
|
|
1306
|
+
let S = 0, w = 0, y = 0;
|
|
1307
|
+
for (const D of d.current) {
|
|
1308
|
+
const { canMove: G } = h(D, p);
|
|
1309
|
+
if (G) {
|
|
1310
|
+
const [K, se] = ce[D];
|
|
1311
|
+
S += K, w += se, y++;
|
|
1309
1312
|
}
|
|
1310
1313
|
}
|
|
1311
1314
|
if (y === 0)
|
|
1312
1315
|
return e.current.playerCell;
|
|
1313
|
-
const
|
|
1314
|
-
(
|
|
1316
|
+
const z = Math.sqrt(S * S + w * w), N = z > 0 ? S / z : 0, E = z > 0 ? w / z : 0, k = Number(
|
|
1317
|
+
(p.row + N * C).toFixed(2)
|
|
1315
1318
|
), L = Number(
|
|
1316
|
-
(
|
|
1317
|
-
), A =
|
|
1319
|
+
(p.col + E * C).toFixed(2)
|
|
1320
|
+
), A = k - p.row, x = L - p.col, O = Math.sqrt(A * A + x * x);
|
|
1318
1321
|
if (O > 0) {
|
|
1319
|
-
const
|
|
1320
|
-
if (
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1322
|
+
const D = A / O, G = x / O;
|
|
1323
|
+
if (Ze(
|
|
1324
|
+
p,
|
|
1325
|
+
D,
|
|
1326
|
+
G,
|
|
1324
1327
|
i,
|
|
1325
1328
|
O,
|
|
1326
1329
|
e.current.maze
|
|
@@ -1328,23 +1331,23 @@ const cn = new an(), we = 3, un = ({ onRetry: e }) => {
|
|
|
1328
1331
|
return e.current.playerCell;
|
|
1329
1332
|
}
|
|
1330
1333
|
e.current.playerCell = {
|
|
1331
|
-
row:
|
|
1334
|
+
row: k,
|
|
1332
1335
|
col: L
|
|
1333
1336
|
}, f();
|
|
1334
|
-
const $ =
|
|
1335
|
-
return (
|
|
1336
|
-
}, [a, h]),
|
|
1337
|
+
const $ = p.row < 0 ? 0 : Math.round(p.row), U = p.col < 0 ? 0 : Math.round(p.col), V = k < 0 ? 0 : Math.round(k), B = L < 0 ? 0 : Math.round(L);
|
|
1338
|
+
return (V !== $ || B !== U) && g({ row: V, col: B }), e.current.playerCell;
|
|
1339
|
+
}, [a, h]), T = () => {
|
|
1337
1340
|
c.current = !1, d.current.clear();
|
|
1338
1341
|
};
|
|
1339
1342
|
return {
|
|
1340
|
-
updatePlayerPos:
|
|
1341
|
-
resetMovingState:
|
|
1343
|
+
updatePlayerPos: v,
|
|
1344
|
+
resetMovingState: T,
|
|
1342
1345
|
resetFirstMoveState: () => {
|
|
1343
1346
|
u.current = !1;
|
|
1344
1347
|
}
|
|
1345
1348
|
};
|
|
1346
1349
|
};
|
|
1347
|
-
function
|
|
1350
|
+
function Ze(e, t, n, o, i, s) {
|
|
1348
1351
|
const l = e.row + t * i, r = e.col + n * i, a = { row: l, col: r }, c = [], d = e.row < 0 ? 0 : Math.floor(e.row), u = e.col < 0 ? 0 : Math.floor(e.col);
|
|
1349
1352
|
c.push({ row: d, col: u });
|
|
1350
1353
|
const h = [
|
|
@@ -1365,19 +1368,19 @@ function Ke(e, t, n, o, i, s) {
|
|
|
1365
1368
|
[1, 1]
|
|
1366
1369
|
// lower right, diagonal
|
|
1367
1370
|
];
|
|
1368
|
-
for (const [f,
|
|
1369
|
-
const
|
|
1370
|
-
s.isValid(
|
|
1371
|
+
for (const [f, g] of h) {
|
|
1372
|
+
const _ = d + f, v = u + g;
|
|
1373
|
+
s.isValid(_, v) && c.push({ row: _, col: v });
|
|
1371
1374
|
}
|
|
1372
1375
|
for (const f of c) {
|
|
1373
|
-
const
|
|
1374
|
-
for (const
|
|
1375
|
-
if (
|
|
1376
|
+
const g = fn(f.row, f.col, s);
|
|
1377
|
+
for (const _ of g)
|
|
1378
|
+
if (mn(a, _) < o)
|
|
1376
1379
|
return !0;
|
|
1377
1380
|
}
|
|
1378
1381
|
return !1;
|
|
1379
1382
|
}
|
|
1380
|
-
function
|
|
1383
|
+
function fn(e, t, n) {
|
|
1381
1384
|
const o = [], i = n.grid[e][t];
|
|
1382
1385
|
return i.walls.top && o.push({
|
|
1383
1386
|
start: { row: e - 0.5, col: t - 0.5 },
|
|
@@ -1393,7 +1396,7 @@ function dn(e, t, n) {
|
|
|
1393
1396
|
end: { row: e + 0.5, col: t - 0.5 }
|
|
1394
1397
|
}), o;
|
|
1395
1398
|
}
|
|
1396
|
-
function
|
|
1399
|
+
function mn(e, t) {
|
|
1397
1400
|
const { start: n, end: o } = t, i = o.col - n.col, s = o.row - n.row, l = e.col - n.col, r = e.row - n.row, a = i * i + s * s;
|
|
1398
1401
|
if (a === 0)
|
|
1399
1402
|
return Math.sqrt(l * l + r * r);
|
|
@@ -1406,12 +1409,12 @@ function hn(e, t) {
|
|
|
1406
1409
|
), d = n.col + c * i, u = n.row + c * s, h = e.col - d, f = e.row - u;
|
|
1407
1410
|
return Math.sqrt(h * h + f * f);
|
|
1408
1411
|
}
|
|
1409
|
-
function
|
|
1412
|
+
function _n(e, t, n) {
|
|
1410
1413
|
if (!n.isValid(t.row, t.col)) return !1;
|
|
1411
1414
|
const o = e.col >= t.col - 0.5 && e.col <= t.col + 0.5, i = e.row >= t.row + 0.5, s = e.row >= t.row - 0.5;
|
|
1412
1415
|
return o && i && s;
|
|
1413
1416
|
}
|
|
1414
|
-
function
|
|
1417
|
+
function pt(e, t, n, o, i) {
|
|
1415
1418
|
if (!e || !t.maze) return;
|
|
1416
1419
|
const { canvasWidth: s, canvasHeight: l } = n, { cellWidth: r, cellHeight: a } = o, {
|
|
1417
1420
|
maze: c,
|
|
@@ -1420,66 +1423,66 @@ function vt(e, t, n, o, i) {
|
|
|
1420
1423
|
exitCell: u,
|
|
1421
1424
|
foodCells: h,
|
|
1422
1425
|
showClue: f,
|
|
1423
|
-
playerPath:
|
|
1424
|
-
visitCounts:
|
|
1426
|
+
playerPath: g,
|
|
1427
|
+
visitCounts: _
|
|
1425
1428
|
} = t, {
|
|
1426
|
-
padding:
|
|
1427
|
-
wallWidth:
|
|
1429
|
+
padding: v,
|
|
1430
|
+
wallWidth: T,
|
|
1428
1431
|
// need merge with level config when passed here
|
|
1429
|
-
wallColor:
|
|
1430
|
-
playerColor:
|
|
1431
|
-
playerRadius:
|
|
1432
|
-
foodColor:
|
|
1432
|
+
wallColor: b,
|
|
1433
|
+
playerColor: C,
|
|
1434
|
+
playerRadius: p,
|
|
1435
|
+
foodColor: S,
|
|
1433
1436
|
backgroundColor: w,
|
|
1434
1437
|
clueColor: y,
|
|
1435
|
-
exitColor:
|
|
1438
|
+
exitColor: z,
|
|
1436
1439
|
exitWallWidth: N,
|
|
1437
|
-
exitDashArray:
|
|
1440
|
+
exitDashArray: E
|
|
1438
1441
|
} = i;
|
|
1439
|
-
e.clearRect(0, 0, s, l), e.save(), e.fillStyle = w, e.fillRect(0, 0, s, l), e.restore(), f &&
|
|
1442
|
+
e.clearRect(0, 0, s, l), e.save(), e.fillStyle = w, e.fillRect(0, 0, s, l), e.restore(), f && yn({
|
|
1440
1443
|
ctx: e,
|
|
1441
|
-
playerPath:
|
|
1442
|
-
visitCounts:
|
|
1444
|
+
playerPath: g,
|
|
1445
|
+
visitCounts: _,
|
|
1443
1446
|
cellWidth: r,
|
|
1444
1447
|
cellHeight: a,
|
|
1445
|
-
padding:
|
|
1448
|
+
padding: v,
|
|
1446
1449
|
clueColor: y
|
|
1447
|
-
}),
|
|
1450
|
+
}), vn({
|
|
1448
1451
|
ctx: e,
|
|
1449
1452
|
maze: c,
|
|
1450
1453
|
cellWidth: r,
|
|
1451
1454
|
cellHeight: a,
|
|
1452
|
-
padding:
|
|
1453
|
-
wallColor:
|
|
1454
|
-
wallWidth:
|
|
1455
|
-
}),
|
|
1455
|
+
padding: v,
|
|
1456
|
+
wallColor: b,
|
|
1457
|
+
wallWidth: T
|
|
1458
|
+
}), pn({
|
|
1456
1459
|
ctx: e,
|
|
1457
1460
|
maze: c,
|
|
1458
1461
|
exitCell: u,
|
|
1459
1462
|
cellWidth: r,
|
|
1460
1463
|
cellHeight: a,
|
|
1461
|
-
padding:
|
|
1462
|
-
exitColor:
|
|
1464
|
+
padding: v,
|
|
1465
|
+
exitColor: z,
|
|
1463
1466
|
exitWallWidth: N,
|
|
1464
|
-
exitDashArray:
|
|
1465
|
-
}),
|
|
1467
|
+
exitDashArray: E
|
|
1468
|
+
}), wn({
|
|
1466
1469
|
ctx: e,
|
|
1467
1470
|
foodCells: h,
|
|
1468
1471
|
cellWidth: r,
|
|
1469
1472
|
cellHeight: a,
|
|
1470
|
-
padding:
|
|
1471
|
-
foodColor:
|
|
1472
|
-
}),
|
|
1473
|
+
padding: v,
|
|
1474
|
+
foodColor: S
|
|
1475
|
+
}), gn({
|
|
1473
1476
|
ctx: e,
|
|
1474
1477
|
playerCell: d,
|
|
1475
|
-
playerRadius:
|
|
1478
|
+
playerRadius: p,
|
|
1476
1479
|
cellWidth: r,
|
|
1477
1480
|
cellHeight: a,
|
|
1478
|
-
padding:
|
|
1479
|
-
playerColor:
|
|
1481
|
+
padding: v,
|
|
1482
|
+
playerColor: C
|
|
1480
1483
|
});
|
|
1481
1484
|
}
|
|
1482
|
-
function
|
|
1485
|
+
function vn({
|
|
1483
1486
|
ctx: e,
|
|
1484
1487
|
maze: t,
|
|
1485
1488
|
cellWidth: n,
|
|
@@ -1488,11 +1491,11 @@ function mn({
|
|
|
1488
1491
|
wallColor: s,
|
|
1489
1492
|
wallWidth: l
|
|
1490
1493
|
}) {
|
|
1491
|
-
e.save(), e.strokeStyle = s, e.lineWidth = l, e.lineCap = "round", e.beginPath(),
|
|
1494
|
+
e.save(), e.strokeStyle = s, e.lineWidth = l, e.lineCap = "round", e.beginPath(), bn(t, n, o, i).forEach((a) => {
|
|
1492
1495
|
e.moveTo(a.x1, a.y1), e.lineTo(a.x2, a.y2);
|
|
1493
1496
|
}), e.stroke(), e.restore();
|
|
1494
1497
|
}
|
|
1495
|
-
function
|
|
1498
|
+
function gn({
|
|
1496
1499
|
ctx: e,
|
|
1497
1500
|
playerCell: t,
|
|
1498
1501
|
playerRadius: n,
|
|
@@ -1501,7 +1504,7 @@ function _n({
|
|
|
1501
1504
|
padding: s,
|
|
1502
1505
|
playerColor: l
|
|
1503
1506
|
}) {
|
|
1504
|
-
const { x: r, y: a } =
|
|
1507
|
+
const { x: r, y: a } = ve(
|
|
1505
1508
|
t.row,
|
|
1506
1509
|
t.col,
|
|
1507
1510
|
o,
|
|
@@ -1510,7 +1513,7 @@ function _n({
|
|
|
1510
1513
|
), c = Math.min(o, i) * Math.min(n, 0.5);
|
|
1511
1514
|
e.save(), e.fillStyle = l, e.beginPath(), e.arc(r, a, c, 0, Math.PI * 2), e.fill(), e.restore();
|
|
1512
1515
|
}
|
|
1513
|
-
function
|
|
1516
|
+
function pn({
|
|
1514
1517
|
ctx: e,
|
|
1515
1518
|
maze: t,
|
|
1516
1519
|
exitCell: n,
|
|
@@ -1526,7 +1529,7 @@ function vn({
|
|
|
1526
1529
|
const u = s + d * o, h = s + c * i;
|
|
1527
1530
|
e.save(), e.globalCompositeOperation = "destination-out", e.lineWidth = r, e.lineCap = "round", e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.globalCompositeOperation = "source-over", e.strokeStyle = l, e.lineWidth = r, e.setLineDash(a), e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.restore();
|
|
1528
1531
|
}
|
|
1529
|
-
function
|
|
1532
|
+
function wn({
|
|
1530
1533
|
ctx: e,
|
|
1531
1534
|
foodCells: t,
|
|
1532
1535
|
cellWidth: n,
|
|
@@ -1537,17 +1540,17 @@ function gn({
|
|
|
1537
1540
|
e.fillStyle = s;
|
|
1538
1541
|
const l = Math.min(n, o) * 0.25;
|
|
1539
1542
|
t.forEach((r) => {
|
|
1540
|
-
const { x: a, y: c } =
|
|
1543
|
+
const { x: a, y: c } = ve(
|
|
1541
1544
|
r.row,
|
|
1542
1545
|
r.col,
|
|
1543
1546
|
n,
|
|
1544
1547
|
o,
|
|
1545
1548
|
i
|
|
1546
1549
|
);
|
|
1547
|
-
|
|
1550
|
+
Cn(e, a, c, l * 1.2, 5, l * 0.6);
|
|
1548
1551
|
});
|
|
1549
1552
|
}
|
|
1550
|
-
function
|
|
1553
|
+
function Cn(e, t, n, o, i, s) {
|
|
1551
1554
|
e.save(), e.beginPath();
|
|
1552
1555
|
for (let l = 0; l < i * 2; l++) {
|
|
1553
1556
|
const r = l % 2 === 0 ? o : s, a = Math.PI * l / i;
|
|
@@ -1555,7 +1558,7 @@ function pn(e, t, n, o, i, s) {
|
|
|
1555
1558
|
}
|
|
1556
1559
|
e.closePath(), e.fill(), e.restore();
|
|
1557
1560
|
}
|
|
1558
|
-
function
|
|
1561
|
+
function yn({
|
|
1559
1562
|
ctx: e,
|
|
1560
1563
|
playerPath: t,
|
|
1561
1564
|
visitCounts: n,
|
|
@@ -1567,32 +1570,32 @@ function Cn({
|
|
|
1567
1570
|
if (!(!t || t.length < 2 || !n)) {
|
|
1568
1571
|
e.save();
|
|
1569
1572
|
for (let r = 1; r < t.length; r++) {
|
|
1570
|
-
const a = t[r - 1], c = t[r], d = `${a.row},${a.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${a.row},${a.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9),
|
|
1573
|
+
const a = t[r - 1], c = t[r], d = `${a.row},${a.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${a.row},${a.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), g = Math.max(3, o * 0.1) + h * 0.5;
|
|
1571
1574
|
try {
|
|
1572
1575
|
e.strokeStyle = l.replace(")", `, ${f})`).replace("rgb(", "rgba(");
|
|
1573
1576
|
} catch {
|
|
1574
1577
|
e.strokeStyle = `rgba(255, 0, 0, ${f})`;
|
|
1575
1578
|
}
|
|
1576
|
-
e.lineWidth =
|
|
1577
|
-
const { x:
|
|
1579
|
+
e.lineWidth = g, e.lineCap = "round", e.lineJoin = "round";
|
|
1580
|
+
const { x: _, y: v } = ve(
|
|
1578
1581
|
a.row,
|
|
1579
1582
|
a.col,
|
|
1580
1583
|
o,
|
|
1581
1584
|
i,
|
|
1582
1585
|
s
|
|
1583
|
-
), { x:
|
|
1586
|
+
), { x: T, y: b } = ve(
|
|
1584
1587
|
c.row,
|
|
1585
1588
|
c.col,
|
|
1586
1589
|
o,
|
|
1587
1590
|
i,
|
|
1588
1591
|
s
|
|
1589
1592
|
);
|
|
1590
|
-
e.beginPath(), e.moveTo(
|
|
1593
|
+
e.beginPath(), e.moveTo(_, v), e.lineTo(T, b), e.stroke();
|
|
1591
1594
|
}
|
|
1592
1595
|
e.restore();
|
|
1593
1596
|
}
|
|
1594
1597
|
}
|
|
1595
|
-
function
|
|
1598
|
+
function bn(e, t, n, o) {
|
|
1596
1599
|
const i = [];
|
|
1597
1600
|
for (let s = 0; s < e.rows; s++)
|
|
1598
1601
|
for (let l = 0; l < e.cols; l++) {
|
|
@@ -1621,19 +1624,19 @@ function wn(e, t, n, o) {
|
|
|
1621
1624
|
}
|
|
1622
1625
|
return i;
|
|
1623
1626
|
}
|
|
1624
|
-
function
|
|
1627
|
+
function ve(e, t, n, o, i) {
|
|
1625
1628
|
return {
|
|
1626
1629
|
x: i + t * n + n / 2,
|
|
1627
1630
|
y: i + e * o + o / 2
|
|
1628
1631
|
};
|
|
1629
1632
|
}
|
|
1630
|
-
function
|
|
1633
|
+
function Tn(e) {
|
|
1631
1634
|
return function() {
|
|
1632
1635
|
let t = e += 1831565813;
|
|
1633
1636
|
return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
|
|
1634
1637
|
};
|
|
1635
1638
|
}
|
|
1636
|
-
class
|
|
1639
|
+
class kn {
|
|
1637
1640
|
// initially all walls exit
|
|
1638
1641
|
constructor(t, n) {
|
|
1639
1642
|
this.row = t, this.col = n;
|
|
@@ -1641,7 +1644,7 @@ class bn {
|
|
|
1641
1644
|
visited = !1;
|
|
1642
1645
|
walls = { top: !0, right: !0, bottom: !0, left: !0 };
|
|
1643
1646
|
}
|
|
1644
|
-
class
|
|
1647
|
+
class wt {
|
|
1645
1648
|
rows;
|
|
1646
1649
|
cols;
|
|
1647
1650
|
grid;
|
|
@@ -1658,7 +1661,7 @@ class gt {
|
|
|
1658
1661
|
* @param exit Optional exit cell position
|
|
1659
1662
|
*/
|
|
1660
1663
|
constructor(t, n, o, i, s = { row: 0, col: 0 }, l = { row: t - 1, col: n - 1 }) {
|
|
1661
|
-
this.rows = t, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random =
|
|
1664
|
+
this.rows = t, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = Tn(this.seed), this.grid = this.initializeGrid(), this.generate(o, s, l);
|
|
1662
1665
|
}
|
|
1663
1666
|
// Initialize the grid with new MazeCell objects
|
|
1664
1667
|
initializeGrid() {
|
|
@@ -1666,7 +1669,7 @@ class gt {
|
|
|
1666
1669
|
for (let n = 0; n < this.rows; n++) {
|
|
1667
1670
|
t[n] = [];
|
|
1668
1671
|
for (let o = 0; o < this.cols; o++)
|
|
1669
|
-
t[n][o] = new
|
|
1672
|
+
t[n][o] = new kn(n, o);
|
|
1670
1673
|
}
|
|
1671
1674
|
return t;
|
|
1672
1675
|
}
|
|
@@ -1784,26 +1787,26 @@ class gt {
|
|
|
1784
1787
|
return t[Math.floor(this.random() * t.length)];
|
|
1785
1788
|
}
|
|
1786
1789
|
}
|
|
1787
|
-
const
|
|
1790
|
+
const Ct = (e, t, n) => {
|
|
1788
1791
|
if (!e.isValid(t, n)) return !1;
|
|
1789
1792
|
const o = e.grid[t][n];
|
|
1790
1793
|
return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
|
|
1791
|
-
},
|
|
1794
|
+
}, Sn = (e) => e === 1 ? 2 : e >= 2 && e <= 5 ? 3 : e >= 6 && e <= 11 ? 4 : e >= 12 && e <= 15 ? 5 : 6, zn = (e, t) => {
|
|
1792
1795
|
if (!t)
|
|
1793
1796
|
return console.error(`Cannot find Level ${e}'s config.`), null;
|
|
1794
1797
|
const { size: n, seed: o, method: i, entry: s, exit: l } = t, r = n, a = n, c = s || { row: 0, col: 0 }, d = l || {
|
|
1795
1798
|
row: r - 1,
|
|
1796
1799
|
col: a - 1
|
|
1797
|
-
}, u = new
|
|
1798
|
-
for (let
|
|
1799
|
-
let
|
|
1800
|
+
}, u = new wt(r, a, i, o, c, d), h = Sn(e), f = [];
|
|
1801
|
+
for (let g = 0; g < h; g++) {
|
|
1802
|
+
let _;
|
|
1800
1803
|
do
|
|
1801
|
-
|
|
1804
|
+
_ = {
|
|
1802
1805
|
row: Math.floor(u.random() * r),
|
|
1803
1806
|
col: Math.floor(u.random() * a)
|
|
1804
1807
|
};
|
|
1805
|
-
while (
|
|
1806
|
-
f.push(
|
|
1808
|
+
while (_.row === c.row && _.col === c.col || _.row === d.row && _.col === d.col || !Ct(u, _.row, _.col) || f.some((v) => v.row === _.row && v.col === _.col));
|
|
1809
|
+
f.push(_);
|
|
1807
1810
|
}
|
|
1808
1811
|
return {
|
|
1809
1812
|
isGameActive: !0,
|
|
@@ -1819,291 +1822,305 @@ const pt = (e, t, n) => {
|
|
|
1819
1822
|
playerPath: [c],
|
|
1820
1823
|
visitCounts: { [`${c.row},${c.col}`]: 1 }
|
|
1821
1824
|
};
|
|
1822
|
-
},
|
|
1825
|
+
}, En = ({
|
|
1823
1826
|
size: e,
|
|
1824
1827
|
seed: t,
|
|
1825
1828
|
method: n,
|
|
1826
1829
|
foodCount: o,
|
|
1827
|
-
|
|
1830
|
+
foodRace: i,
|
|
1831
|
+
clue: s
|
|
1828
1832
|
}) => {
|
|
1829
|
-
const
|
|
1830
|
-
|
|
1831
|
-
let h
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1838
|
-
(
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1833
|
+
const l = e, r = e, a = { row: 0, col: 0 }, c = { row: l - 1, col: r - 1 }, d = new wt(l, r, n, t, a, c), u = [];
|
|
1834
|
+
if (i)
|
|
1835
|
+
for (let h = 0; h < o; h++) {
|
|
1836
|
+
let f, g = 0;
|
|
1837
|
+
do
|
|
1838
|
+
f = {
|
|
1839
|
+
row: Math.floor(d.random() * l),
|
|
1840
|
+
col: Math.floor(d.random() * r)
|
|
1841
|
+
}, g++;
|
|
1842
|
+
while (g < 50 && (f.row === a.row && f.col === a.col || f.row === c.row && f.col === c.col || !Ct(d, f.row, f.col) || u.some(
|
|
1843
|
+
(_) => _.row === f.row && _.col === f.col
|
|
1844
|
+
)));
|
|
1845
|
+
g < 50 && u.push(f);
|
|
1846
|
+
}
|
|
1842
1847
|
return {
|
|
1843
1848
|
isGameActive: !0,
|
|
1844
1849
|
levelTransitioning: !1,
|
|
1845
|
-
maze:
|
|
1846
|
-
playerCell:
|
|
1847
|
-
exitCell:
|
|
1848
|
-
foodCells:
|
|
1850
|
+
maze: d,
|
|
1851
|
+
playerCell: a,
|
|
1852
|
+
exitCell: c,
|
|
1853
|
+
foodCells: u,
|
|
1849
1854
|
playerAtExit: !1,
|
|
1850
1855
|
foodCollected: 0,
|
|
1851
|
-
totalFoodCount: o,
|
|
1852
|
-
showClue:
|
|
1853
|
-
playerPath: [
|
|
1854
|
-
visitCounts: { [`${
|
|
1856
|
+
totalFoodCount: i ? o : 0,
|
|
1857
|
+
showClue: s,
|
|
1858
|
+
playerPath: [a],
|
|
1859
|
+
visitCounts: { [`${a.row},${a.col}`]: 1 }
|
|
1855
1860
|
};
|
|
1856
1861
|
};
|
|
1857
|
-
function
|
|
1862
|
+
function Ln() {
|
|
1858
1863
|
const {
|
|
1859
1864
|
setGamePlayState: e,
|
|
1860
1865
|
gamePlayState: t,
|
|
1861
1866
|
gamePlayStateRef: n,
|
|
1862
1867
|
gameProgress: o,
|
|
1863
1868
|
config: i
|
|
1864
|
-
} = re(), s =
|
|
1869
|
+
} = re(), s = R(null), l = R(null), { i18n: r, levelConfig: a, renderConfig: c } = i, d = ie(a), u = R(
|
|
1865
1870
|
d.getLevelConfig(o.currentLevel)
|
|
1866
1871
|
);
|
|
1867
|
-
|
|
1872
|
+
I(() => {
|
|
1868
1873
|
s.current && q.attachTo(s.current);
|
|
1869
1874
|
}, []);
|
|
1870
|
-
const h =
|
|
1875
|
+
const h = R(), f = _t(l, () => {
|
|
1871
1876
|
h.current?.();
|
|
1872
|
-
}),
|
|
1877
|
+
}), g = vt(
|
|
1873
1878
|
l,
|
|
1874
1879
|
t,
|
|
1875
1880
|
c.padding
|
|
1876
1881
|
);
|
|
1877
|
-
|
|
1882
|
+
I(() => {
|
|
1878
1883
|
u.current = d.getLevelConfig(
|
|
1879
1884
|
o.currentLevel
|
|
1880
1885
|
);
|
|
1881
1886
|
}, [o.currentLevel]);
|
|
1882
|
-
const
|
|
1883
|
-
const
|
|
1887
|
+
const _ = () => {
|
|
1888
|
+
const C = zn(
|
|
1884
1889
|
o.currentLevel,
|
|
1885
1890
|
u.current
|
|
1886
1891
|
);
|
|
1887
|
-
|
|
1888
|
-
...
|
|
1889
|
-
...
|
|
1892
|
+
C && e((p) => ({
|
|
1893
|
+
...p,
|
|
1894
|
+
...C
|
|
1890
1895
|
}));
|
|
1891
1896
|
};
|
|
1892
|
-
|
|
1893
|
-
|
|
1897
|
+
I(() => {
|
|
1898
|
+
_();
|
|
1894
1899
|
}, [o.currentLevel]);
|
|
1895
|
-
const
|
|
1896
|
-
|
|
1897
|
-
}, { updatePlayerPos:
|
|
1900
|
+
const v = () => {
|
|
1901
|
+
_();
|
|
1902
|
+
}, { updatePlayerPos: T, resetMovingState: b } = gt({
|
|
1898
1903
|
gamePlayStateRef: n,
|
|
1899
1904
|
setGamePlayState: e,
|
|
1900
1905
|
playerRadius: c.playerRadius,
|
|
1901
1906
|
moveSpeed: c.gridMoveSpeed,
|
|
1902
1907
|
onFoodCollected: () => {
|
|
1903
|
-
const
|
|
1904
|
-
|
|
1905
|
-
r.foodCollectedToast.replace("%NUM%",
|
|
1908
|
+
const C = n.current.totalFoodCount - n.current.foodCollected - 1;
|
|
1909
|
+
C > 0 ? q.show(
|
|
1910
|
+
r.foodCollectedToast.replace("%NUM%", C.toString()),
|
|
1906
1911
|
3e3
|
|
1907
1912
|
) : q.show(r.allFoodCollectedToast);
|
|
1908
1913
|
}
|
|
1909
1914
|
});
|
|
1910
|
-
return
|
|
1911
|
-
|
|
1912
|
-
}, [o.currentLevel,
|
|
1913
|
-
let
|
|
1914
|
-
const
|
|
1915
|
-
const
|
|
1916
|
-
if (!(
|
|
1917
|
-
|
|
1915
|
+
return I(() => {
|
|
1916
|
+
b();
|
|
1917
|
+
}, [o.currentLevel, b]), I(() => {
|
|
1918
|
+
let C, p = !document.hidden;
|
|
1919
|
+
const S = () => {
|
|
1920
|
+
const z = l.current?.getContext("2d"), N = n.current;
|
|
1921
|
+
if (!(p && N?.isGameActive && z && N?.maze)) {
|
|
1922
|
+
C = requestAnimationFrame(S);
|
|
1918
1923
|
return;
|
|
1919
1924
|
}
|
|
1920
|
-
|
|
1925
|
+
T(), w(), C = requestAnimationFrame(S);
|
|
1921
1926
|
}, w = () => {
|
|
1922
|
-
const
|
|
1923
|
-
if (
|
|
1924
|
-
const
|
|
1925
|
-
|
|
1927
|
+
const z = l.current?.getContext("2d"), N = n.current;
|
|
1928
|
+
if (z && N?.maze) {
|
|
1929
|
+
const E = u.current?.wallWidth || c?.wallWidth, k = u.current?.exitColor || c?.exitColor, L = u.current?.exitWallWidth || c?.exitWallWidth, A = u.current?.exitDashArray || c?.exitDashArray;
|
|
1930
|
+
pt(z, N, f.current, g.current, {
|
|
1926
1931
|
...c,
|
|
1927
|
-
wallWidth:
|
|
1928
|
-
exitColor:
|
|
1932
|
+
wallWidth: E,
|
|
1933
|
+
exitColor: k,
|
|
1929
1934
|
exitWallWidth: L,
|
|
1930
1935
|
exitDashArray: A
|
|
1931
1936
|
});
|
|
1932
1937
|
}
|
|
1933
1938
|
};
|
|
1934
1939
|
h.current = w;
|
|
1935
|
-
const y = (
|
|
1936
|
-
const N =
|
|
1937
|
-
|
|
1940
|
+
const y = (z) => {
|
|
1941
|
+
const N = p;
|
|
1942
|
+
p = !document.hidden && document.visibilityState === "visible" && (!z || z.type !== "blur"), !N && p ? n.current?.levelTransitioning === !1 && e({
|
|
1938
1943
|
...n.current,
|
|
1939
1944
|
isGameActive: !0
|
|
1940
|
-
}) : N && !
|
|
1945
|
+
}) : N && !p && e({
|
|
1941
1946
|
...n.current,
|
|
1942
1947
|
isGameActive: !1
|
|
1943
1948
|
});
|
|
1944
1949
|
};
|
|
1945
|
-
return document.addEventListener("visibilitychange", y), window.addEventListener("blur", y), window.addEventListener("focus", y),
|
|
1946
|
-
cancelAnimationFrame(
|
|
1950
|
+
return document.addEventListener("visibilitychange", y), window.addEventListener("blur", y), window.addEventListener("focus", y), C = requestAnimationFrame(S), () => {
|
|
1951
|
+
cancelAnimationFrame(C), document.removeEventListener("visibilitychange", y), window.removeEventListener("blur", y), window.removeEventListener("focus", y);
|
|
1947
1952
|
};
|
|
1948
|
-
}, []),
|
|
1953
|
+
}, []), I(() => {
|
|
1949
1954
|
q.show(r.useArrowKeyTips, 3e3);
|
|
1950
1955
|
}, []), /* @__PURE__ */ m("div", { className: "maze-game-container", children: [
|
|
1951
|
-
/* @__PURE__ */ m(
|
|
1952
|
-
/* @__PURE__ */ m(
|
|
1956
|
+
/* @__PURE__ */ m($t, {}),
|
|
1957
|
+
/* @__PURE__ */ m(hn, { onRetry: v }),
|
|
1953
1958
|
/* @__PURE__ */ m("div", { className: "maze-canvas-container", ref: s, children: /* @__PURE__ */ m("canvas", { ref: l, className: "maze-game-canvas" }) })
|
|
1954
1959
|
] });
|
|
1955
1960
|
}
|
|
1956
|
-
const
|
|
1961
|
+
const Nn = (e) => {
|
|
1957
1962
|
const t = Math.floor(e / 60), n = e % 60;
|
|
1958
1963
|
return `${t.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
|
|
1959
|
-
},
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
const r = () => {
|
|
1966
|
-
!s.current && !i.current && (s.current = !0, i.current = setInterval(() => {
|
|
1967
|
-
o((c) => (l.current = e - c + 1, c <= 1 ? (clearInterval(i.current), t(), 0) : c - 1));
|
|
1964
|
+
}, Mn = ({ timer: e }) => {
|
|
1965
|
+
const [t, n] = W(e), o = R(), i = R(!1), s = R(0);
|
|
1966
|
+
return I(() => {
|
|
1967
|
+
const l = () => {
|
|
1968
|
+
!i.current && !o.current && (i.current = !0, o.current = setInterval(() => {
|
|
1969
|
+
n((a) => (s.current = e - a + 1, a <= 1 ? (clearInterval(o.current), window.dispatchEvent(new CustomEvent("maze:timeUp")), 0) : a - 1));
|
|
1968
1970
|
}, 1e3));
|
|
1969
|
-
},
|
|
1970
|
-
clearInterval(
|
|
1971
|
+
}, r = () => {
|
|
1972
|
+
clearInterval(o.current), o.current = void 0, window.dispatchEvent(
|
|
1971
1973
|
new CustomEvent("maze:timeUsed", {
|
|
1972
|
-
detail: { timeUsed:
|
|
1974
|
+
detail: { timeUsed: s.current }
|
|
1973
1975
|
})
|
|
1974
1976
|
);
|
|
1975
1977
|
};
|
|
1976
|
-
return window.addEventListener("maze:firstMove",
|
|
1977
|
-
window.removeEventListener("maze:firstMove",
|
|
1978
|
+
return window.addEventListener("maze:firstMove", l), window.addEventListener("maze:gameSuccess", r), () => {
|
|
1979
|
+
window.removeEventListener("maze:firstMove", l), window.removeEventListener("maze:gameSuccess", r), clearInterval(o.current);
|
|
1978
1980
|
};
|
|
1979
|
-
}, []),
|
|
1980
|
-
|
|
1981
|
+
}, [e]), I(() => {
|
|
1982
|
+
o.current && (clearInterval(o.current), o.current = void 0), n(e), i.current = !1, s.current = 0;
|
|
1981
1983
|
}, [e]), /* @__PURE__ */ m("div", { className: "single-maze-timer", children: /* @__PURE__ */ m(
|
|
1982
1984
|
"span",
|
|
1983
1985
|
{
|
|
1984
|
-
className: `maze-timer-text ${
|
|
1986
|
+
className: `maze-timer-text ${t <= 10 && i.current ? "maze-timer-warning" : ""}`,
|
|
1985
1987
|
children: [
|
|
1986
1988
|
"⏱️ ",
|
|
1987
|
-
|
|
1989
|
+
Nn(t)
|
|
1988
1990
|
]
|
|
1989
1991
|
}
|
|
1990
1992
|
) });
|
|
1991
1993
|
};
|
|
1992
|
-
function
|
|
1994
|
+
function An({ config: e }) {
|
|
1993
1995
|
const {
|
|
1994
1996
|
size: t,
|
|
1995
1997
|
seed: n,
|
|
1996
1998
|
method: o,
|
|
1997
1999
|
foodCount: i,
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
x(
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2000
|
+
foodRace: s,
|
|
2001
|
+
clue: l,
|
|
2002
|
+
renderConfig: r,
|
|
2003
|
+
successCallback: a,
|
|
2004
|
+
failCallback: c,
|
|
2005
|
+
timer: d,
|
|
2006
|
+
i18n: u
|
|
2007
|
+
} = e, [h, f] = W({
|
|
2008
|
+
...Ee
|
|
2009
|
+
}), [g, _] = W(!1), [v, T] = W(!0), [b, C] = W(!1), [p, S] = W(""), w = R(0), y = R(!1), z = R(!1), N = R(null), E = R(null), k = R(h), L = R(), A = _t(N, () => {
|
|
2010
|
+
L.current?.();
|
|
2011
|
+
}), x = vt(N, h, r.padding);
|
|
2012
|
+
I(() => {
|
|
2013
|
+
k.current = h;
|
|
2014
|
+
}, [h]);
|
|
2015
|
+
const { updatePlayerPos: O, resetMovingState: $, resetFirstMoveState: U } = gt({
|
|
2016
|
+
gamePlayStateRef: k,
|
|
2017
|
+
setGamePlayState: f,
|
|
2018
|
+
playerRadius: r.playerRadius,
|
|
2019
|
+
moveSpeed: r.gridMoveSpeed,
|
|
2017
2020
|
onFoodCollected: () => {
|
|
2018
2021
|
console.log("Food collected in single maze");
|
|
2019
2022
|
},
|
|
2020
2023
|
onExitReached: () => {
|
|
2021
|
-
|
|
2024
|
+
if (!y.current) {
|
|
2025
|
+
if (s && k.current.foodCollected < k.current.totalFoodCount) {
|
|
2026
|
+
S(`⭐️ ${u.foodMsg}`), C(!0), requestAnimationFrame(() => {
|
|
2027
|
+
f((D) => ({
|
|
2028
|
+
...D,
|
|
2029
|
+
playerAtExit: !1,
|
|
2030
|
+
isGameActive: !0,
|
|
2031
|
+
levelTransitioning: !1
|
|
2032
|
+
}));
|
|
2033
|
+
});
|
|
2034
|
+
return;
|
|
2035
|
+
}
|
|
2036
|
+
B();
|
|
2037
|
+
}
|
|
2022
2038
|
},
|
|
2023
2039
|
onFirstMove: () => {
|
|
2024
2040
|
window.dispatchEvent(new CustomEvent("maze:firstMove"));
|
|
2025
2041
|
}
|
|
2026
|
-
}),
|
|
2027
|
-
|
|
2028
|
-
...
|
|
2042
|
+
}), V = () => {
|
|
2043
|
+
y.current = !0, S(`⏰ ${u.failMsg}`), C(!0), f({
|
|
2044
|
+
...k.current,
|
|
2029
2045
|
isGameActive: !1
|
|
2030
|
-
})
|
|
2031
|
-
},
|
|
2032
|
-
|
|
2033
|
-
},
|
|
2034
|
-
C(!1),
|
|
2046
|
+
});
|
|
2047
|
+
}, B = () => {
|
|
2048
|
+
y.current = !0, z.current = !0, S(`🎉 ${u.successMsg}`), C(!0), window.dispatchEvent(new CustomEvent("maze:gameSuccess"));
|
|
2049
|
+
}, Y = () => {
|
|
2050
|
+
C(!1), y.current && (T(!1), f((D) => ({
|
|
2035
2051
|
...D,
|
|
2036
2052
|
showClue: !0
|
|
2037
|
-
})),
|
|
2053
|
+
})), z.current ? a?.(w.current) : c?.());
|
|
2038
2054
|
};
|
|
2039
|
-
return
|
|
2055
|
+
return I(() => {
|
|
2040
2056
|
(async () => {
|
|
2041
|
-
|
|
2057
|
+
_(!0);
|
|
2042
2058
|
try {
|
|
2043
|
-
const
|
|
2059
|
+
const G = En({
|
|
2044
2060
|
size: t,
|
|
2045
2061
|
seed: n,
|
|
2046
2062
|
method: o,
|
|
2047
2063
|
foodCount: i,
|
|
2048
|
-
|
|
2064
|
+
foodRace: s,
|
|
2065
|
+
clue: l
|
|
2049
2066
|
});
|
|
2050
|
-
|
|
2051
|
-
} catch (
|
|
2052
|
-
console.error("Error generating single maze:",
|
|
2067
|
+
k.current = G, f(G);
|
|
2068
|
+
} catch (G) {
|
|
2069
|
+
console.error("Error generating single maze:", G);
|
|
2053
2070
|
} finally {
|
|
2054
|
-
|
|
2071
|
+
_(!1);
|
|
2055
2072
|
}
|
|
2056
2073
|
})();
|
|
2057
|
-
}, [e]),
|
|
2074
|
+
}, [e]), I(() => {
|
|
2058
2075
|
let D;
|
|
2059
|
-
const
|
|
2060
|
-
const
|
|
2061
|
-
if (!(
|
|
2062
|
-
D = requestAnimationFrame(
|
|
2076
|
+
const G = !document.hidden, K = () => {
|
|
2077
|
+
const le = N.current?.getContext("2d"), ee = k.current;
|
|
2078
|
+
if (!(G && ee?.isGameActive && le && ee?.maze)) {
|
|
2079
|
+
D = requestAnimationFrame(K);
|
|
2063
2080
|
return;
|
|
2064
2081
|
}
|
|
2065
|
-
|
|
2066
|
-
},
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2082
|
+
O(), se(), D = requestAnimationFrame(K);
|
|
2083
|
+
}, se = () => {
|
|
2084
|
+
const le = N.current?.getContext("2d"), ee = k.current;
|
|
2085
|
+
le && ee?.maze && pt(
|
|
2086
|
+
le,
|
|
2087
|
+
ee,
|
|
2088
|
+
A.current,
|
|
2089
|
+
x.current,
|
|
2090
|
+
r
|
|
2074
2091
|
);
|
|
2075
2092
|
};
|
|
2076
|
-
return
|
|
2093
|
+
return L.current = se, D = requestAnimationFrame(K), () => {
|
|
2077
2094
|
cancelAnimationFrame(D);
|
|
2078
2095
|
};
|
|
2079
|
-
}, []),
|
|
2080
|
-
|
|
2081
|
-
}, [e,
|
|
2082
|
-
const D = (
|
|
2083
|
-
|
|
2096
|
+
}, []), I(() => {
|
|
2097
|
+
$(), U();
|
|
2098
|
+
}, [e, $, U]), I(() => {
|
|
2099
|
+
const D = (G) => {
|
|
2100
|
+
w.current = G.detail.timeUsed;
|
|
2084
2101
|
};
|
|
2085
|
-
return window.addEventListener("maze:timeUsed", D), () => {
|
|
2102
|
+
return window.addEventListener("maze:timeUsed", D), window.addEventListener("maze:timeUp", V), () => {
|
|
2086
2103
|
window.removeEventListener(
|
|
2087
2104
|
"maze:timeUsed",
|
|
2088
2105
|
D
|
|
2089
|
-
);
|
|
2106
|
+
), window.removeEventListener("maze:timeUp", V);
|
|
2090
2107
|
};
|
|
2091
|
-
}, []),
|
|
2092
|
-
/* @__PURE__ */ m(
|
|
2093
|
-
/* @__PURE__ */ m("div", { className: "single-maze-canvas-container", ref:
|
|
2108
|
+
}, []), g ? /* @__PURE__ */ m("div", { className: "single-maze-loading", children: /* @__PURE__ */ m("div", { children: "Generating maze..." }) }) : h ? /* @__PURE__ */ m("div", { className: "maze-game-container", children: [
|
|
2109
|
+
v && /* @__PURE__ */ m(Mn, { timer: d }),
|
|
2110
|
+
/* @__PURE__ */ m("div", { className: "single-maze-canvas-container", ref: E, children: /* @__PURE__ */ m("canvas", { ref: N, className: "maze-game-canvas" }) }),
|
|
2094
2111
|
/* @__PURE__ */ m(
|
|
2095
2112
|
te,
|
|
2096
2113
|
{
|
|
2097
2114
|
isOpen: b,
|
|
2098
|
-
title:
|
|
2115
|
+
title: p,
|
|
2099
2116
|
noConfirm: !0,
|
|
2100
2117
|
cancelText: "OK",
|
|
2101
|
-
onCancel:
|
|
2118
|
+
onCancel: Y
|
|
2102
2119
|
}
|
|
2103
2120
|
)
|
|
2104
2121
|
] }) : /* @__PURE__ */ m("div", { className: "single-maze-error", children: /* @__PURE__ */ m("div", { children: "Failed to generate maze" }) });
|
|
2105
2122
|
}
|
|
2106
|
-
const
|
|
2123
|
+
const yt = [
|
|
2107
2124
|
// Tier 1 (Levels 1-12) - Beginner
|
|
2108
2125
|
[
|
|
2109
2126
|
// debug
|
|
@@ -2261,8 +2278,8 @@ const Ct = [
|
|
|
2261
2278
|
{ size: 68, seed: 33341, method: "backtracking" }
|
|
2262
2279
|
// Level 60 - Master
|
|
2263
2280
|
]
|
|
2264
|
-
],
|
|
2265
|
-
gridMoveSpeed:
|
|
2281
|
+
], Pn = 0.07, bt = {
|
|
2282
|
+
gridMoveSpeed: Pn,
|
|
2266
2283
|
padding: 10,
|
|
2267
2284
|
wallWidth: 2,
|
|
2268
2285
|
wallColor: "#000000",
|
|
@@ -2277,7 +2294,7 @@ const Ct = [
|
|
|
2277
2294
|
// default exit wall width if not specified in level config, should always be a little wider than normal wallWidth
|
|
2278
2295
|
exitDashArray: [8, 12]
|
|
2279
2296
|
// default dash: 8px dash, 12px gap
|
|
2280
|
-
},
|
|
2297
|
+
}, fe = {
|
|
2281
2298
|
lcPrefix: "maze-",
|
|
2282
2299
|
i18n: {
|
|
2283
2300
|
reset: "Reset",
|
|
@@ -2322,20 +2339,22 @@ const Ct = [
|
|
|
2322
2339
|
cluePathDisabled: "Clue Path Disabled",
|
|
2323
2340
|
useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
|
|
2324
2341
|
},
|
|
2325
|
-
renderConfig:
|
|
2326
|
-
levelConfig:
|
|
2327
|
-
},
|
|
2342
|
+
renderConfig: bt,
|
|
2343
|
+
levelConfig: yt
|
|
2344
|
+
}, me = {
|
|
2328
2345
|
i18n: {
|
|
2329
2346
|
successMsg: "Congratulations! You completed the maze!",
|
|
2330
2347
|
failMsg: "Time is up!",
|
|
2331
|
-
|
|
2348
|
+
foodMsg: "Please collect all stars before leaving!"
|
|
2332
2349
|
},
|
|
2333
2350
|
size: 8,
|
|
2334
2351
|
seed: 12345,
|
|
2335
2352
|
method: "backtracking",
|
|
2336
2353
|
clue: !1,
|
|
2337
|
-
foodCount:
|
|
2338
|
-
|
|
2354
|
+
foodCount: 0,
|
|
2355
|
+
foodRace: !1,
|
|
2356
|
+
// false then omit foodCount, make it to 0, true need to force all food collected
|
|
2357
|
+
renderConfig: bt,
|
|
2339
2358
|
timer: 10 * 60,
|
|
2340
2359
|
// 10 minutes
|
|
2341
2360
|
successCallback: () => {
|
|
@@ -2345,48 +2364,48 @@ const Ct = [
|
|
|
2345
2364
|
console.log("⏰ Time is up! Game failed.");
|
|
2346
2365
|
}
|
|
2347
2366
|
};
|
|
2348
|
-
function
|
|
2349
|
-
const t = { ...
|
|
2350
|
-
...
|
|
2367
|
+
function In({ config: e = {} }) {
|
|
2368
|
+
const t = { ...fe.i18n, ...e.i18n || {} }, n = {
|
|
2369
|
+
...fe.renderConfig,
|
|
2351
2370
|
...e.renderConfig || {}
|
|
2352
|
-
}, o = e.levelConfig ||
|
|
2353
|
-
...
|
|
2371
|
+
}, o = e.levelConfig || yt, i = {
|
|
2372
|
+
...fe,
|
|
2354
2373
|
...e,
|
|
2355
2374
|
i18n: t,
|
|
2356
2375
|
levelConfig: o,
|
|
2357
2376
|
renderConfig: n
|
|
2358
2377
|
};
|
|
2359
|
-
return /* @__PURE__ */ m(
|
|
2378
|
+
return /* @__PURE__ */ m(Ft, { config: i, children: /* @__PURE__ */ m(Ln, {}) });
|
|
2360
2379
|
}
|
|
2361
|
-
function
|
|
2380
|
+
function xn({
|
|
2362
2381
|
config: e = {}
|
|
2363
2382
|
}) {
|
|
2364
|
-
const t = { ...
|
|
2365
|
-
...
|
|
2383
|
+
const t = { ...me.i18n, ...e.i18n || {} }, n = {
|
|
2384
|
+
...me.renderConfig,
|
|
2366
2385
|
...e.renderConfig || {}
|
|
2367
2386
|
}, o = {
|
|
2368
|
-
...
|
|
2387
|
+
...me,
|
|
2369
2388
|
...e,
|
|
2370
2389
|
i18n: t,
|
|
2371
2390
|
renderConfig: n
|
|
2372
2391
|
};
|
|
2373
|
-
return /* @__PURE__ */ m(
|
|
2392
|
+
return /* @__PURE__ */ m(An, { config: o });
|
|
2374
2393
|
}
|
|
2375
|
-
const
|
|
2376
|
-
root: "https://unpkg.com/@roudanio/maze@0.2.
|
|
2377
|
-
...
|
|
2394
|
+
const Rn = {
|
|
2395
|
+
root: "https://unpkg.com/@roudanio/maze@0.2.4/dist/",
|
|
2396
|
+
...fe
|
|
2378
2397
|
};
|
|
2379
|
-
`${JSON.stringify(
|
|
2380
|
-
const
|
|
2381
|
-
root: "https://unpkg.com/@roudanio/maze@0.2.
|
|
2382
|
-
...
|
|
2398
|
+
`${JSON.stringify(Rn, null, 2)}`;
|
|
2399
|
+
const Fn = {
|
|
2400
|
+
root: "https://unpkg.com/@roudanio/maze@0.2.4/dist/",
|
|
2401
|
+
...me
|
|
2383
2402
|
};
|
|
2384
2403
|
`${JSON.stringify(
|
|
2385
|
-
|
|
2404
|
+
Fn,
|
|
2386
2405
|
(e, t) => typeof t == "function" ? t.toString() : t,
|
|
2387
2406
|
2
|
|
2388
2407
|
)}`;
|
|
2389
|
-
const
|
|
2408
|
+
const On = {
|
|
2390
2409
|
showNotice() {
|
|
2391
2410
|
console.warn("Cannot find the root element");
|
|
2392
2411
|
const e = document.createElement("div");
|
|
@@ -2427,7 +2446,7 @@ const Fn = {
|
|
|
2427
2446
|
return;
|
|
2428
2447
|
}
|
|
2429
2448
|
let { root: o = location.origin } = t;
|
|
2430
|
-
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "",
|
|
2449
|
+
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", De(/* @__PURE__ */ m(In, { config: t }), n);
|
|
2431
2450
|
},
|
|
2432
2451
|
async initSingle(e, t) {
|
|
2433
2452
|
const n = typeof e == "string" ? document.querySelector(e) : e;
|
|
@@ -2436,9 +2455,9 @@ const Fn = {
|
|
|
2436
2455
|
return;
|
|
2437
2456
|
}
|
|
2438
2457
|
let { root: o = location.origin } = t;
|
|
2439
|
-
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "",
|
|
2458
|
+
o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", De(/* @__PURE__ */ m(xn, { config: t }), n);
|
|
2440
2459
|
}
|
|
2441
2460
|
};
|
|
2442
2461
|
export {
|
|
2443
|
-
|
|
2462
|
+
On as default
|
|
2444
2463
|
};
|