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