@roudanio/maze 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/maze.js CHANGED
@@ -1,440 +1,440 @@
1
- var fe, A, Je, X, Pe, Ze, Qe, et, Se, we, 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
- for (var n in e) t[n] = e[n];
4
- return t;
1
+ var ge, M, Qe, X, xe, et, tt, nt, Le, Te, ke, ot, ne = {}, rt = [], Tt = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, pe = Array.isArray;
2
+ function H(e, t) {
3
+ for (var n in t) e[n] = t[n];
4
+ return e;
5
5
  }
6
- function ze(t) {
7
- t && t.parentNode && t.parentNode.removeChild(t);
6
+ function Ne(e) {
7
+ e && e.parentNode && e.parentNode.removeChild(e);
8
8
  }
9
- function Tt(t, e, n) {
10
- var o, i, s, a = {};
11
- for (s in e) s == "key" ? o = e[s] : s == "ref" ? i = e[s] : a[s] = e[s];
12
- if (arguments.length > 2 && (a.children = arguments.length > 3 ? 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);
9
+ function kt(e, t, n) {
10
+ var o, i, s, l = {};
11
+ for (s in t) s == "key" ? o = t[s] : s == "ref" ? i = t[s] : l[s] = t[s];
12
+ if (arguments.length > 2 && (l.children = arguments.length > 3 ? ge.call(arguments, 2) : n), typeof e == "function" && e.defaultProps != null) for (s in e.defaultProps) l[s] == null && (l[s] = e.defaultProps[s]);
13
+ return ue(e, l, o, i, null);
14
14
  }
15
- function 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
- return i == null && A.vnode != null && A.vnode(s), s;
15
+ function ue(e, t, n, o, i) {
16
+ var s = { type: e, props: t, key: n, ref: o, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: i ?? ++Qe, __i: -1, __u: 0 };
17
+ return i == null && M.vnode != null && M.vnode(s), s;
18
18
  }
19
- function _e(t) {
20
- return t.children;
19
+ function we(e) {
20
+ return e.children;
21
21
  }
22
- function ae(t, e) {
23
- this.props = t, this.context = e;
22
+ function de(e, t) {
23
+ this.props = e, this.context = t;
24
24
  }
25
- function K(t, e) {
26
- if (e == null) return t.__ ? K(t.__, t.__i + 1) : null;
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" ? K(t) : null;
25
+ function J(e, t) {
26
+ if (t == null) return e.__ ? J(e.__, e.__i + 1) : null;
27
+ for (var n; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) return n.__e;
28
+ return typeof e.type == "function" ? J(e) : null;
29
29
  }
30
- function ot(t) {
31
- var e, n;
32
- if ((t = t.__) != null && t.__c != null) {
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
- t.__e = t.__c.base = n.__e;
30
+ function it(e) {
31
+ var t, n;
32
+ if ((e = e.__) != null && e.__c != null) {
33
+ for (e.__e = e.__c.base = null, t = 0; t < e.__k.length; t++) if ((n = e.__k[t]) != null && n.__e != null) {
34
+ e.__e = e.__c.base = n.__e;
35
35
  break;
36
36
  }
37
- return ot(t);
37
+ return it(e);
38
38
  }
39
39
  }
40
- function be(t) {
41
- (!t.__d && (t.__d = !0) && X.push(t) && !de.__r++ || Pe != A.debounceRendering) && ((Pe = A.debounceRendering) || Ze)(de);
40
+ function Se(e) {
41
+ (!e.__d && (e.__d = !0) && X.push(e) && !_e.__r++ || xe != M.debounceRendering) && ((xe = M.debounceRendering) || et)(_e);
42
42
  }
43
- function 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;
43
+ function _e() {
44
+ for (var e, t, n, o, i, s, l, r = 1; X.length; ) X.length > r && X.sort(tt), e = X.shift(), r = X.length, e.__d && (n = void 0, i = (o = (t = e).__v).__e, s = [], l = [], t.__P && ((n = H({}, o)).__v = o.__v + 1, M.vnode && M.vnode(n), Me(t.__P, n, o, t.__n, t.__P.namespaceURI, 32 & o.__u ? [i] : null, s, i ?? J(o), !!(32 & o.__u), l), n.__v = o.__v, n.__.__k[n.__i] = n, at(s, n, l), n.__e != i && it(n)));
45
+ _e.__r = 0;
46
46
  }
47
- function rt(t, e, n, o, i, s, a, r, l, c, d) {
48
- var u, h, f, k, p, _, b = o && o.__k || nt, C = e.length;
49
- for (l = kt(n, e, b, l, C), u = 0; u < C; 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;
47
+ function st(e, t, n, o, i, s, l, r, a, c, d) {
48
+ var u, h, f, g, _, v, T = o && o.__k || rt, b = t.length;
49
+ for (a = St(n, t, T, a, b), u = 0; u < b; u++) (f = n.__k[u]) != null && (h = f.__i == -1 ? ne : T[f.__i] || ne, f.__i = u, v = Me(e, f, h, i, s, l, r, a, c, d), g = f.__e, f.ref && h.ref != f.ref && (h.ref && Ae(h.ref, null, f), d.push(f.ref, f.__c || g, f)), _ == null && g != null && (_ = g), 4 & f.__u || h.__k === f.__k ? a = lt(f, a, e) : typeof f.type == "function" && v !== void 0 ? a = v : g && (a = g.nextSibling), f.__u &= -7);
50
+ return n.__e = _, a;
51
51
  }
52
- function kt(t, e, n, o, i) {
53
- var s, a, r, l, c, d = n.length, u = d, h = 0;
54
- for (t.__k = new Array(i), s = 0; s < i; s++) (a = e[s]) != null && typeof a != "boolean" && typeof a != "function" ? (l = s + h, (a = t.__k[s] = typeof a == "string" || typeof a == "number" || typeof a == "bigint" || a.constructor == String ? 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));
52
+ function St(e, t, n, o, i) {
53
+ var s, l, r, a, c, d = n.length, u = d, h = 0;
54
+ for (e.__k = new Array(i), s = 0; s < i; s++) (l = t[s]) != null && typeof l != "boolean" && typeof l != "function" ? (a = s + h, (l = e.__k[s] = typeof l == "string" || typeof l == "number" || typeof l == "bigint" || l.constructor == String ? ue(null, l, null, null, null) : pe(l) ? ue(we, { children: l }, null, null, null) : l.constructor == null && l.__b > 0 ? ue(l.type, l.props, l.key, l.ref ? l.ref : null, l.__v) : l).__ = e, l.__b = e.__b + 1, r = null, (c = l.__i = zt(l, n, a, u)) != -1 && (u--, (r = n[c]) && (r.__u |= 2)), r == null || r.__v == null ? (c == -1 && (i > d ? h-- : i < d && h++), typeof l.type != "function" && (l.__u |= 4)) : c != a && (c == a - 1 ? h-- : c == a + 1 ? h++ : (c > a ? h-- : h++, l.__u |= 4))) : e.__k[s] = null;
55
+ if (u) for (s = 0; s < d; s++) (r = n[s]) != null && (2 & r.__u) == 0 && (r.__e == o && (o = J(r)), ut(r, r));
56
56
  return o;
57
57
  }
58
- function it(t, e, n) {
58
+ function lt(e, t, n) {
59
59
  var o, i;
60
- if (typeof t.type == "function") {
61
- for (o = t.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = t, e = it(o[i], e, n));
62
- return e;
60
+ if (typeof e.type == "function") {
61
+ for (o = e.__k, i = 0; o && i < o.length; i++) o[i] && (o[i].__ = e, t = lt(o[i], t, n));
62
+ return t;
63
63
  }
64
- t.__e != e && (e && t.type && !n.contains(e) && (e = K(t)), n.insertBefore(t.__e, e || null), e = t.__e);
64
+ e.__e != t && (t && e.type && !n.contains(t) && (t = J(e)), n.insertBefore(e.__e, t || null), t = e.__e);
65
65
  do
66
- e = e && e.nextSibling;
67
- while (e != null && e.nodeType == 8);
68
- return e;
66
+ t = t && t.nextSibling;
67
+ while (t != null && t.nodeType == 8);
68
+ return t;
69
69
  }
70
- function St(t, e, n, o) {
71
- var i, s, a = t.key, r = t.type, l = e[n];
72
- if (l === null && t.key == null || l && a == l.key && r == l.type && (2 & l.__u) == 0) return n;
73
- if (o > (l != null && (2 & l.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < e.length; ) {
70
+ function zt(e, t, n, o) {
71
+ var i, s, l = e.key, r = e.type, a = t[n];
72
+ if (a === null && e.key == null || a && l == a.key && r == a.type && (2 & a.__u) == 0) return n;
73
+ if (o > (a != null && (2 & a.__u) == 0 ? 1 : 0)) for (i = n - 1, s = n + 1; i >= 0 || s < t.length; ) {
74
74
  if (i >= 0) {
75
- if ((l = e[i]) && (2 & l.__u) == 0 && a == l.key && r == l.type) return i;
75
+ if ((a = t[i]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return i;
76
76
  i--;
77
77
  }
78
- if (s < e.length) {
79
- if ((l = e[s]) && (2 & l.__u) == 0 && a == l.key && r == l.type) return s;
78
+ if (s < t.length) {
79
+ if ((a = t[s]) && (2 & a.__u) == 0 && l == a.key && r == a.type) return s;
80
80
  s++;
81
81
  }
82
82
  }
83
83
  return -1;
84
84
  }
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";
85
+ function Re(e, t, n) {
86
+ t[0] == "-" ? e.setProperty(t, n ?? "") : e[t] = n == null ? "" : typeof n != "number" || Tt.test(t) ? n : n + "px";
87
87
  }
88
- function re(t, e, n, o, i) {
88
+ function ae(e, t, n, o, i) {
89
89
  var s;
90
- e: if (e == "style") if (typeof n == "string") t.style.cssText = n;
90
+ e: if (t == "style") if (typeof n == "string") e.style.cssText = n;
91
91
  else {
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]);
92
+ if (typeof o == "string" && (e.style.cssText = o = ""), o) for (t in o) n && t in n || Re(e.style, t, "");
93
+ if (n) for (t in n) o && n[t] == o[t] || Re(e.style, t, n[t]);
94
94
  }
95
- else if (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 : we, s)) : t.removeEventListener(e, s ? ye : we, s);
95
+ else if (t[0] == "o" && t[1] == "n") s = t != (t = t.replace(nt, "$1")), t = t.toLowerCase() in e || t == "onFocusOut" || t == "onFocusIn" ? t.toLowerCase().slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + s] = n, n ? o ? n.u = o.u : (n.u = Le, e.addEventListener(t, s ? ke : Te, s)) : e.removeEventListener(t, s ? ke : Te, s);
96
96
  else {
97
- if (i == "http://www.w3.org/2000/svg") e = e.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
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 {
99
- t[e] = n ?? "";
97
+ if (i == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
98
+ else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
99
+ e[t] = n ?? "";
100
100
  break e;
101
101
  } catch {
102
102
  }
103
- typeof n == "function" || (n == null || n === !1 && e[4] != "-" ? t.removeAttribute(e) : t.setAttribute(e, e == "popover" && n == 1 ? "" : n));
103
+ typeof n == "function" || (n == null || n === !1 && t[4] != "-" ? e.removeAttribute(t) : e.setAttribute(t, t == "popover" && n == 1 ? "" : n));
104
104
  }
105
105
  }
106
- function xe(t) {
107
- return function(e) {
106
+ function Fe(e) {
107
+ return function(t) {
108
108
  if (this.l) {
109
- var n = this.l[e.type + t];
110
- if (e.t == null) e.t = Se++;
111
- else if (e.t < n.u) return;
112
- return n(A.event ? A.event(e) : e);
109
+ var n = this.l[t.type + e];
110
+ if (t.t == null) t.t = Le++;
111
+ else if (t.t < n.u) return;
112
+ return n(M.event ? M.event(t) : t);
113
113
  }
114
114
  };
115
115
  }
116
- function Ee(t, e, n, o, i, s, a, r, l, c) {
117
- var d, u, h, f, k, p, _, b, C, M, w, z, S, E, L, y, g, v = e.type;
118
- if (e.constructor != null) return null;
119
- 128 & n.__u && (l = !!(32 & n.__u), s = [r = e.__e = n.__e]), (d = A.__b) && d(e);
120
- e: if (typeof v == "function") try {
121
- if (b = e.props, C = "prototype" in v && v.prototype.render, M = (d = v.contextType) && o[d.__c], w = d ? M ? M.props.value : d.__ : o, n.__c ? _ = (u = e.__c = n.__c).__ = u.__E : (C ? e.__c = u = new v(b, w) : (e.__c = u = new ae(b, w), u.constructor = v, u.render = Et), M && M.sub(u), u.props = b, u.state || (u.state = {}), u.context = w, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), C && u.__s == null && (u.__s = u.state), C && 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) C && v.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), C && u.componentDidMount != null && u.__h.push(u.componentDidMount);
116
+ function Me(e, t, n, o, i, s, l, r, a, c) {
117
+ var d, u, h, f, g, _, v, T, b, C, p, S, w, y, z, N, E, k = t.type;
118
+ if (t.constructor != null) return null;
119
+ 128 & n.__u && (a = !!(32 & n.__u), s = [r = t.__e = n.__e]), (d = M.__b) && d(t);
120
+ e: if (typeof k == "function") try {
121
+ if (T = t.props, b = "prototype" in k && k.prototype.render, C = (d = k.contextType) && o[d.__c], p = d ? C ? C.props.value : d.__ : o, n.__c ? v = (u = t.__c = n.__c).__ = u.__E : (b ? t.__c = u = new k(T, p) : (t.__c = u = new de(T, p), u.constructor = k, u.render = Lt), C && C.sub(u), u.props = T, u.state || (u.state = {}), u.context = p, u.__n = o, h = u.__d = !0, u.__h = [], u._sb = []), b && u.__s == null && (u.__s = u.state), b && k.getDerivedStateFromProps != null && (u.__s == u.state && (u.__s = H({}, u.__s)), H(u.__s, k.getDerivedStateFromProps(T, u.__s))), f = u.props, g = u.state, u.__v = t, h) b && k.getDerivedStateFromProps == null && u.componentWillMount != null && u.componentWillMount(), b && u.componentDidMount != null && u.__h.push(u.componentDidMount);
122
122
  else {
123
- if (C && v.getDerivedStateFromProps == null && b !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(b, w), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(b, u.__s, w) === !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
- u._sb = [], u.__h.length && a.push(u);
123
+ if (b && k.getDerivedStateFromProps == null && T !== f && u.componentWillReceiveProps != null && u.componentWillReceiveProps(T, p), !u.__e && u.shouldComponentUpdate != null && u.shouldComponentUpdate(T, u.__s, p) === !1 || t.__v == n.__v) {
124
+ for (t.__v != n.__v && (u.props = T, u.state = u.__s, u.__d = !1), t.__e = n.__e, t.__k = n.__k, t.__k.some(function(L) {
125
+ L && (L.__ = t);
126
+ }), S = 0; S < u._sb.length; S++) u.__h.push(u._sb[S]);
127
+ u._sb = [], u.__h.length && l.push(u);
128
128
  break e;
129
129
  }
130
- u.componentWillUpdate != null && u.componentWillUpdate(b, u.__s, w), C && u.componentDidUpdate != null && u.__h.push(function() {
131
- u.componentDidUpdate(f, k, p);
130
+ u.componentWillUpdate != null && u.componentWillUpdate(T, u.__s, p), b && u.componentDidUpdate != null && u.__h.push(function() {
131
+ u.componentDidUpdate(f, g, _);
132
132
  });
133
133
  }
134
- if (u.context = w, u.props = b, u.__P = t, u.__e = !1, S = A.__r, E = 0, C) {
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]);
134
+ if (u.context = p, u.props = T, u.__P = e, u.__e = !1, w = M.__r, y = 0, b) {
135
+ for (u.state = u.__s, u.__d = !1, w && w(t), d = u.render(u.props, u.state, u.context), z = 0; z < u._sb.length; z++) u.__h.push(u._sb[z]);
136
136
  u._sb = [];
137
137
  } else do
138
- 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())), C && !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
- for (e.__u |= l ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
144
- s[s.indexOf(r)] = null, e.__e = r;
145
- } else for (g = s.length; g--; ) ze(s[g]);
146
- else e.__e = n.__e, e.__k = n.__k;
147
- A.__e(T, e, n);
138
+ u.__d = !1, w && w(t), d = u.render(u.props, u.state, u.context), u.state = u.__s;
139
+ while (u.__d && ++y < 25);
140
+ u.state = u.__s, u.getChildContext != null && (o = H(H({}, o), u.getChildContext())), b && !h && u.getSnapshotBeforeUpdate != null && (_ = u.getSnapshotBeforeUpdate(f, g)), N = d, d != null && d.type === we && d.key == null && (N = ct(d.props.children)), r = st(e, pe(N) ? N : [N], t, n, o, i, s, l, r, a, c), u.base = t.__e, t.__u &= -161, u.__h.length && l.push(u), v && (u.__E = u.__ = null);
141
+ } catch (L) {
142
+ if (t.__v = null, a || s != null) if (L.then) {
143
+ for (t.__u |= a ? 160 : 128; r && r.nodeType == 8 && r.nextSibling; ) r = r.nextSibling;
144
+ s[s.indexOf(r)] = null, t.__e = r;
145
+ } else for (E = s.length; E--; ) Ne(s[E]);
146
+ else t.__e = n.__e, t.__k = n.__k;
147
+ M.__e(L, t, n);
148
148
  }
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
- return (d = A.diffed) && d(e), 128 & e.__u ? void 0 : r;
149
+ else s == null && t.__v == n.__v ? (t.__k = n.__k, t.__e = n.__e) : r = t.__e = Et(n.__e, t, n, o, i, s, l, a, c);
150
+ return (d = M.diffed) && d(t), 128 & t.__u ? void 0 : r;
151
151
  }
152
- function st(t, e, n) {
153
- for (var o = 0; o < n.length; o++) Le(n[o], n[++o], n[++o]);
154
- A.__c && A.__c(e, t), t.some(function(i) {
152
+ function at(e, t, n) {
153
+ for (var o = 0; o < n.length; o++) Ae(n[o], n[++o], n[++o]);
154
+ M.__c && M.__c(t, e), e.some(function(i) {
155
155
  try {
156
- t = i.__h, i.__h = [], t.some(function(s) {
156
+ e = i.__h, i.__h = [], e.some(function(s) {
157
157
  s.call(i);
158
158
  });
159
159
  } catch (s) {
160
- A.__e(s, i.__v);
160
+ M.__e(s, i.__v);
161
161
  }
162
162
  });
163
163
  }
164
- function at(t) {
165
- return typeof t != "object" || t == null || t.__b && t.__b > 0 ? t : me(t) ? t.map(at) : H({}, t);
164
+ function ct(e) {
165
+ return typeof e != "object" || e == null || e.__b && e.__b > 0 ? e : pe(e) ? e.map(ct) : H({}, e);
166
166
  }
167
- function zt(t, e, n, o, i, s, a, r, l) {
168
- var c, d, u, h, f, k, p, _ = n.props, b = e.props, C = e.type;
169
- if (C == "svg" ? i = "http://www.w3.org/2000/svg" : C == "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 == !!C && (C ? f.localName == C : f.nodeType == 3)) {
171
- t = f, s[c] = null;
167
+ function Et(e, t, n, o, i, s, l, r, a) {
168
+ var c, d, u, h, f, g, _, v = n.props, T = t.props, b = t.type;
169
+ if (b == "svg" ? i = "http://www.w3.org/2000/svg" : b == "math" ? i = "http://www.w3.org/1998/Math/MathML" : i || (i = "http://www.w3.org/1999/xhtml"), s != null) {
170
+ for (c = 0; c < s.length; c++) if ((f = s[c]) && "setAttribute" in f == !!b && (b ? f.localName == b : f.nodeType == 3)) {
171
+ e = f, s[c] = null;
172
172
  break;
173
173
  }
174
174
  }
175
- if (t == null) {
176
- if (C == null) return document.createTextNode(b);
177
- t = document.createElementNS(i, C, b.is && b), r && (A.__m && A.__m(e, s), r = !1), s = null;
175
+ if (e == null) {
176
+ if (b == null) return document.createTextNode(T);
177
+ e = document.createElementNS(i, b, T.is && T), r && (M.__m && M.__m(t, s), r = !1), s = null;
178
178
  }
179
- if (C == null) _ === b || r && t.data == b || (t.data = b);
179
+ if (b == null) v === T || r && e.data == T || (e.data = T);
180
180
  else {
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") {
181
+ if (s = s && ge.call(e.childNodes), v = n.props || ne, !r && s != null) for (v = {}, c = 0; c < e.attributes.length; c++) v[(f = e.attributes[c]).name] = f.value;
182
+ for (c in v) if (f = v[c], c != "children") {
183
183
  if (c == "dangerouslySetInnerHTML") u = f;
184
- else if (!(c in b)) {
185
- if (c == "value" && "defaultValue" in b || c == "checked" && "defaultChecked" in b) continue;
186
- re(t, c, null, f, i);
184
+ else if (!(c in T)) {
185
+ if (c == "value" && "defaultValue" in T || c == "checked" && "defaultChecked" in T) continue;
186
+ ae(e, c, null, f, i);
187
187
  }
188
188
  }
189
- for (c in 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
- if (d) r || u && (d.__html == u.__html || d.__html == t.innerHTML) || (t.innerHTML = d.__html), e.__k = [];
191
- else if (u && (t.innerHTML = ""), rt(e.type == "template" ? t.content : t, me(h) ? h : [h], e, n, o, C == "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", C == "progress" && k == null ? t.removeAttribute("value") : k != null && (k !== t[c] || C == "progress" && !k || C == "option" && k != _[c]) && re(t, c, k, _[c], i), c = "checked", p != null && p != t[c] && re(t, c, p, _[c], i));
189
+ for (c in T) f = T[c], c == "children" ? h = f : c == "dangerouslySetInnerHTML" ? d = f : c == "value" ? g = f : c == "checked" ? _ = f : r && typeof f != "function" || v[c] === f || ae(e, c, f, v[c], i);
190
+ if (d) r || u && (d.__html == u.__html || d.__html == e.innerHTML) || (e.innerHTML = d.__html), t.__k = [];
191
+ else if (u && (e.innerHTML = ""), st(t.type == "template" ? e.content : e, pe(h) ? h : [h], t, n, o, b == "foreignObject" ? "http://www.w3.org/1999/xhtml" : i, s, l, s ? s[0] : n.__k && J(n, 0), r, a), s != null) for (c = s.length; c--; ) Ne(s[c]);
192
+ r || (c = "value", b == "progress" && g == null ? e.removeAttribute("value") : g != null && (g !== e[c] || b == "progress" && !g || b == "option" && g != v[c]) && ae(e, c, g, v[c], i), c = "checked", _ != null && _ != e[c] && ae(e, c, _, v[c], i));
193
193
  }
194
- return t;
194
+ return e;
195
195
  }
196
- function Le(t, e, n) {
196
+ function Ae(e, t, n) {
197
197
  try {
198
- if (typeof t == "function") {
199
- var o = typeof t.__u == "function";
200
- o && t.__u(), o && e == null || (t.__u = t(e));
201
- } else t.current = e;
198
+ if (typeof e == "function") {
199
+ var o = typeof e.__u == "function";
200
+ o && e.__u(), o && t == null || (e.__u = e(t));
201
+ } else e.current = t;
202
202
  } catch (i) {
203
- A.__e(i, n);
203
+ M.__e(i, n);
204
204
  }
205
205
  }
206
- function lt(t, e, n) {
206
+ function ut(e, t, n) {
207
207
  var o, i;
208
- if (A.unmount && A.unmount(t), (o = t.ref) && (o.current && o.current != t.__e || Le(o, null, e)), (o = t.__c) != null) {
208
+ if (M.unmount && M.unmount(e), (o = e.ref) && (o.current && o.current != e.__e || Ae(o, null, t)), (o = e.__c) != null) {
209
209
  if (o.componentWillUnmount) try {
210
210
  o.componentWillUnmount();
211
211
  } catch (s) {
212
- A.__e(s, e);
212
+ M.__e(s, t);
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] && lt(o[i], e, n || typeof t.type != "function");
217
- n || ze(t.__e), t.__c = t.__ = t.__e = void 0;
216
+ if (o = e.__k) for (i = 0; i < o.length; i++) o[i] && ut(o[i], t, n || typeof e.type != "function");
217
+ n || Ne(e.__e), e.__c = e.__ = e.__e = void 0;
218
218
  }
219
- function Et(t, e, n) {
220
- return this.constructor(t, n);
219
+ function Lt(e, t, n) {
220
+ return this.constructor(e, n);
221
221
  }
222
- function Re(t, e, n) {
223
- var o, i, 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);
222
+ function De(e, t, n) {
223
+ var o, i, s, l;
224
+ t == document && (t = document.documentElement), M.__ && M.__(e, t), i = (o = !1) ? null : t.__k, s = [], l = [], Me(t, e = t.__k = kt(we, null, [e]), i || ne, ne, t.namespaceURI, i ? null : t.firstChild ? ge.call(t.childNodes) : null, s, i ? i.__e : t.firstChild, o, l), at(s, e, l);
225
225
  }
226
- function Lt(t) {
227
- function e(n) {
226
+ function Nt(e) {
227
+ function t(n) {
228
228
  var o, i;
229
- return this.getChildContext || (o = /* @__PURE__ */ new Set(), (i = {})[e.__c] = this, this.getChildContext = function() {
229
+ return this.getChildContext || (o = /* @__PURE__ */ new Set(), (i = {})[t.__c] = this, this.getChildContext = function() {
230
230
  return i;
231
231
  }, this.componentWillUnmount = function() {
232
232
  o = null;
233
233
  }, this.shouldComponentUpdate = function(s) {
234
- this.props.value != s.value && o.forEach(function(a) {
235
- a.__e = !0, be(a);
234
+ this.props.value != s.value && o.forEach(function(l) {
235
+ l.__e = !0, Se(l);
236
236
  });
237
237
  }, this.sub = function(s) {
238
238
  o.add(s);
239
- var a = s.componentWillUnmount;
239
+ var l = s.componentWillUnmount;
240
240
  s.componentWillUnmount = function() {
241
- o && o.delete(s), a && a.call(s);
241
+ o && o.delete(s), l && l.call(s);
242
242
  };
243
243
  }), n.children;
244
244
  }
245
- return e.__c = "__cC" + tt++, e.__ = t, e.Provider = e.__l = (e.Consumer = function(n, o) {
245
+ return t.__c = "__cC" + ot++, t.__ = e, t.Provider = t.__l = (t.Consumer = function(n, o) {
246
246
  return n.children(o);
247
- }).contextType = e, e;
247
+ }).contextType = t, t;
248
248
  }
249
- fe = nt.slice, A = { __e: function(t, e, n, o) {
250
- for (var i, s, a; e = e.__; ) if ((i = e.__c) && !i.__) try {
251
- if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(t)), a = i.__d), i.componentDidCatch != null && (i.componentDidCatch(t, o || {}), a = i.__d), a) return i.__E = i;
249
+ ge = rt.slice, M = { __e: function(e, t, n, o) {
250
+ for (var i, s, l; t = t.__; ) if ((i = t.__c) && !i.__) try {
251
+ if ((s = i.constructor) && s.getDerivedStateFromError != null && (i.setState(s.getDerivedStateFromError(e)), l = i.__d), i.componentDidCatch != null && (i.componentDidCatch(e, o || {}), l = i.__d), l) return i.__E = i;
252
252
  } catch (r) {
253
- t = r;
253
+ e = r;
254
254
  }
255
- throw t;
256
- } }, Je = 0, ae.prototype.setState = function(t, e) {
255
+ throw e;
256
+ } }, Qe = 0, de.prototype.setState = function(e, t) {
257
257
  var n;
258
- n = this.__s != null && this.__s != this.state ? this.__s : this.__s = 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
- return t.__v.__b - e.__v.__b;
263
- }, de.__r = 0, et = /(PointerCapture)$|Capture$/i, Se = 0, we = xe(!1), ye = xe(!0), tt = 0;
264
- var Nt = 0;
265
- function m(t, e, n, o, i, s) {
266
- e || (e = {});
267
- var a, r, l = e;
268
- if ("ref" in l) for (r in l = {}, e) r == "ref" ? a = e[r] : l[r] = e[r];
269
- var c = { type: t, props: l, key: n, ref: a, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Nt, __i: -1, __u: 0, __source: i, __self: s };
270
- if (typeof t == "function" && (a = t.defaultProps)) for (r in a) l[r] === void 0 && (l[r] = a[r]);
271
- return A.vnode && A.vnode(c), c;
272
- }
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
- return t >= n.__.length && n.__.push({}), n.__[t];
278
- }
279
- function U(t) {
280
- return te = 1, Mt(dt, t);
281
- }
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
- var l = o.__N ? o.__N[0] : o.__[0], c = o.t(l, r);
286
- l !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
287
- }], o.__c = x, !x.__f)) {
288
- var i = function(r, l, c) {
258
+ n = this.__s != null && this.__s != this.state ? this.__s : this.__s = H({}, this.state), typeof e == "function" && (e = e(H({}, n), this.props)), e && H(n, e), e != null && this.__v && (t && this._sb.push(t), Se(this));
259
+ }, de.prototype.forceUpdate = function(e) {
260
+ this.__v && (this.__e = !0, e && this.__h.push(e), Se(this));
261
+ }, de.prototype.render = we, X = [], et = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, tt = function(e, t) {
262
+ return e.__v.__b - t.__v.__b;
263
+ }, _e.__r = 0, nt = /(PointerCapture)$|Capture$/i, Le = 0, Te = Fe(!1), ke = Fe(!0), ot = 0;
264
+ var Mt = 0;
265
+ function m(e, t, n, o, i, s) {
266
+ t || (t = {});
267
+ var l, r, a = t;
268
+ if ("ref" in a) for (r in a = {}, t) r == "ref" ? l = t[r] : a[r] = t[r];
269
+ var c = { type: e, props: a, key: n, ref: l, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --Mt, __i: -1, __u: 0, __source: i, __self: s };
270
+ if (typeof e == "function" && (l = e.defaultProps)) for (r in l) a[r] === void 0 && (a[r] = l[r]);
271
+ return M.vnode && M.vnode(c), c;
272
+ }
273
+ var Z, P, ye, Oe, oe = 0, dt = [], F = M, $e = F.__b, Ue = F.__r, Ge = F.diffed, We = F.__c, je = F.unmount, qe = F.__;
274
+ function Ce(e, t) {
275
+ F.__h && F.__h(P, e, oe || t), oe = 0;
276
+ var n = P.__H || (P.__H = { __: [], __h: [] });
277
+ return e >= n.__.length && n.__.push({}), n.__[e];
278
+ }
279
+ function W(e) {
280
+ return oe = 1, At(ft, e);
281
+ }
282
+ function At(e, t, n) {
283
+ var o = Ce(Z++, 2);
284
+ if (o.t = e, !o.__c && (o.__ = [ft(void 0, t), function(r) {
285
+ var a = o.__N ? o.__N[0] : o.__[0], c = o.t(a, r);
286
+ a !== c && (o.__N = [c, o.__[1]], o.__c.setState({}));
287
+ }], o.__c = P, !P.__f)) {
288
+ var i = function(r, a, c) {
289
289
  if (!o.__c.__H) return !0;
290
290
  var d = o.__c.__H.__.filter(function(h) {
291
291
  return !!h.__c;
292
292
  });
293
293
  if (d.every(function(h) {
294
294
  return !h.__N;
295
- })) return !s || s.call(this, r, l, c);
295
+ })) return !s || s.call(this, r, a, c);
296
296
  var u = o.__c.props !== r;
297
297
  return d.forEach(function(h) {
298
298
  if (h.__N) {
299
299
  var f = h.__[0];
300
300
  h.__ = h.__N, h.__N = void 0, f !== h.__[0] && (u = !0);
301
301
  }
302
- }), s && s.call(this, r, l, c) || u;
302
+ }), s && s.call(this, r, a, c) || u;
303
303
  };
304
- x.__f = !0;
305
- var s = x.shouldComponentUpdate, a = x.componentWillUpdate;
306
- x.componentWillUpdate = function(r, l, c) {
304
+ P.__f = !0;
305
+ var s = P.shouldComponentUpdate, l = P.componentWillUpdate;
306
+ P.componentWillUpdate = function(r, a, c) {
307
307
  if (this.__e) {
308
308
  var d = s;
309
- s = void 0, i(r, l, c), s = d;
309
+ s = void 0, i(r, a, c), s = d;
310
310
  }
311
- a && a.call(this, r, l, c);
312
- }, x.shouldComponentUpdate = i;
311
+ l && l.call(this, r, a, c);
312
+ }, P.shouldComponentUpdate = i;
313
313
  }
314
314
  return o.__N || o.__;
315
315
  }
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));
316
+ function I(e, t) {
317
+ var n = Ce(Z++, 3);
318
+ !F.__s && ht(n.__H, t) && (n.__ = e, n.u = t, P.__H.__h.push(n));
319
319
  }
320
- function O(t) {
321
- return te = 5, Z(function() {
322
- return { current: t };
320
+ function R(e) {
321
+ return oe = 5, Q(function() {
322
+ return { current: e };
323
323
  }, []);
324
324
  }
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.__;
325
+ function Q(e, t) {
326
+ var n = Ce(Z++, 7);
327
+ return ht(n.__H, t) && (n.__ = e(), n.__H = t, n.__h = e), n.__;
328
328
  }
329
- function je(t, e) {
330
- return te = 8, Z(function() {
331
- return t;
332
- }, e);
329
+ function He(e, t) {
330
+ return oe = 8, Q(function() {
331
+ return e;
332
+ }, t);
333
333
  }
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.__;
334
+ function Pt(e) {
335
+ var t = P.context[e.__c], n = Ce(Z++, 9);
336
+ return n.c = e, t ? (n.__ == null && (n.__ = !0, t.sub(P)), t.props.value) : e.__;
337
337
  }
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
- } catch (e) {
342
- t.__H.__h = [], F.__e(e, t.__v);
338
+ function It() {
339
+ for (var e; e = dt.shift(); ) if (e.__P && e.__H) try {
340
+ e.__H.__h.forEach(he), e.__H.__h.forEach(ze), e.__H.__h = [];
341
+ } catch (t) {
342
+ e.__H.__h = [], F.__e(t, e.__v);
343
343
  }
344
344
  }
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) {
345
+ F.__b = function(e) {
346
+ P = null, $e && $e(e);
347
+ }, F.__ = function(e, t) {
348
+ e && t.__k && t.__k.__m && (e.__m = t.__k.__m), qe && qe(e, t);
349
+ }, F.__r = function(e) {
350
+ Ue && Ue(e), Z = 0;
351
+ var t = (P = e.__c).__H;
352
+ t && (ye === P ? (t.__h = [], P.__h = [], t.__.forEach(function(n) {
353
353
  n.__N && (n.__ = n.__N), n.u = n.__N = void 0;
354
- })) : (e.__h.forEach(le), e.__h.forEach(Te), e.__h = [], J = 0)), pe = x;
355
- }, F.diffed = function(t) {
356
- $e && $e(t);
357
- var e = t.__c;
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) {
354
+ })) : (t.__h.forEach(he), t.__h.forEach(ze), t.__h = [], Z = 0)), ye = P;
355
+ }, F.diffed = function(e) {
356
+ Ge && Ge(e);
357
+ var t = e.__c;
358
+ t && t.__H && (t.__H.__h.length && (dt.push(t) !== 1 && Oe === F.requestAnimationFrame || ((Oe = F.requestAnimationFrame) || xt)(It)), t.__H.__.forEach(function(n) {
359
359
  n.u && (n.__H = n.u), n.u = void 0;
360
- })), pe = x = null;
361
- }, F.__c = function(t, e) {
362
- e.some(function(n) {
360
+ })), ye = P = null;
361
+ }, F.__c = function(e, t) {
362
+ t.some(function(n) {
363
363
  try {
364
- n.__h.forEach(le), n.__h = n.__h.filter(function(o) {
365
- return !o.__ || Te(o);
364
+ n.__h.forEach(he), n.__h = n.__h.filter(function(o) {
365
+ return !o.__ || ze(o);
366
366
  });
367
367
  } catch (o) {
368
- e.some(function(i) {
368
+ t.some(function(i) {
369
369
  i.__h && (i.__h = []);
370
- }), e = [], F.__e(o, n.__v);
370
+ }), t = [], F.__e(o, n.__v);
371
371
  }
372
- }), Ue && Ue(t, e);
373
- }, F.unmount = function(t) {
374
- Ge && Ge(t);
375
- var e, n = t.__c;
372
+ }), We && We(e, t);
373
+ }, F.unmount = function(e) {
374
+ je && je(e);
375
+ var t, n = e.__c;
376
376
  n && n.__H && (n.__H.__.forEach(function(o) {
377
377
  try {
378
- le(o);
378
+ he(o);
379
379
  } catch (i) {
380
- e = i;
380
+ t = i;
381
381
  }
382
- }), n.__H = void 0, e && F.__e(e, n.__v));
382
+ }), n.__H = void 0, t && F.__e(t, n.__v));
383
383
  };
384
- var qe = typeof requestAnimationFrame == "function";
385
- function It(t) {
386
- var e, n = function() {
387
- clearTimeout(o), qe && cancelAnimationFrame(e), setTimeout(t);
384
+ var Be = typeof requestAnimationFrame == "function";
385
+ function xt(e) {
386
+ var t, n = function() {
387
+ clearTimeout(o), Be && cancelAnimationFrame(t), setTimeout(e);
388
388
  }, o = setTimeout(n, 100);
389
- qe && (e = requestAnimationFrame(n));
389
+ Be && (t = requestAnimationFrame(n));
390
390
  }
391
- function le(t) {
392
- var e = x, n = t.__c;
393
- typeof n == "function" && (t.__c = void 0, n()), x = e;
391
+ function he(e) {
392
+ var t = P, n = e.__c;
393
+ typeof n == "function" && (e.__c = void 0, n()), P = t;
394
394
  }
395
- function Te(t) {
396
- var e = x;
397
- t.__c = t.__(), x = e;
395
+ function ze(e) {
396
+ var t = P;
397
+ e.__c = e.__(), P = t;
398
398
  }
399
- function ut(t, e) {
400
- return !t || t.length !== e.length || e.some(function(n, o) {
401
- return n !== t[o];
399
+ function ht(e, t) {
400
+ return !e || e.length !== t.length || t.some(function(n, o) {
401
+ return n !== e[o];
402
402
  });
403
403
  }
404
- function dt(t, e) {
405
- return typeof e == "function" ? e(t) : e;
404
+ function ft(e, t) {
405
+ return typeof t == "function" ? t(e) : t;
406
406
  }
407
- const xt = (t) => ({
408
- saveGameData(e) {
407
+ const Rt = (e) => ({
408
+ saveGameData(t) {
409
409
  try {
410
- localStorage.setItem(t, JSON.stringify(e));
410
+ localStorage.setItem(e, JSON.stringify(t));
411
411
  } catch (n) {
412
412
  console.error("Failed to save maze game data:", n);
413
413
  }
414
414
  },
415
415
  loadGameData() {
416
416
  try {
417
- const e = localStorage.getItem(t);
418
- return e ? JSON.parse(e) : null;
419
- } catch (e) {
420
- return console.error("Failed to load maze game data:", e), null;
417
+ const t = localStorage.getItem(e);
418
+ return t ? JSON.parse(t) : null;
419
+ } catch (t) {
420
+ return console.error("Failed to load maze game data:", t), null;
421
421
  }
422
422
  },
423
423
  resetGameData() {
424
424
  try {
425
- localStorage.removeItem(t);
426
- } catch (e) {
427
- console.error("Failed to reset maze game data:", e);
425
+ localStorage.removeItem(e);
426
+ } catch (t) {
427
+ console.error("Failed to reset maze game data:", t);
428
428
  }
429
429
  }
430
- }), ht = Lt(void 0), He = {
430
+ }), mt = Nt(void 0), Ve = {
431
431
  currentLevel: 1,
432
432
  highestUnlockedLevel: 1,
433
433
  currentTier: 1,
434
434
  highestUnlockedTier: 1,
435
435
  levelScores: {},
436
436
  totalScore: 0
437
- }, ke = {
437
+ }, Ee = {
438
438
  isGameActive: !0,
439
439
  levelTransitioning: !1,
440
440
  maze: null,
@@ -447,9 +447,9 @@ const xt = (t) => ({
447
447
  showClue: !1,
448
448
  playerPath: [],
449
449
  visitCounts: {}
450
- }, Rt = ({ children: t, config: e }) => {
451
- const n = xt(e.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = U(() => o || { ...He });
452
- R(() => {
450
+ }, Ft = ({ children: e, config: t }) => {
451
+ const n = Rt(t.lcPrefix + "progress"), o = n.loadGameData(), [i, s] = W(() => o || { ...Ve });
452
+ I(() => {
453
453
  const u = Object.values(i.levelScores).reduce(
454
454
  (h, f) => h + f,
455
455
  0
@@ -458,7 +458,7 @@ const xt = (t) => ({
458
458
  ...h,
459
459
  totalScore: u
460
460
  }));
461
- }, [i.levelScores]), R(() => {
461
+ }, [i.levelScores]), I(() => {
462
462
  n.saveGameData(i);
463
463
  }, [
464
464
  i.currentLevel,
@@ -468,112 +468,112 @@ const xt = (t) => ({
468
468
  i.levelScores,
469
469
  i.totalScore
470
470
  ]);
471
- const [a, r] = U({
472
- ...ke
473
- }), l = O(a);
474
- R(() => {
475
- l.current = a;
476
- }, [a]);
477
- const c = Z(() => [
478
- a.playerAtExit ? 1 : 0,
479
- a.foodCollected === a.totalFoodCount ? 1 : 0,
480
- a.showClue ? 0 : 1
471
+ const [l, r] = W({
472
+ ...Ee
473
+ }), a = R(l);
474
+ I(() => {
475
+ a.current = l;
476
+ }, [l]);
477
+ const c = Q(() => [
478
+ l.playerAtExit ? 1 : 0,
479
+ l.foodCollected === l.totalFoodCount ? 1 : 0,
480
+ l.showClue ? 0 : 1
481
481
  ], [
482
- a.playerAtExit,
483
- a.foodCollected,
484
- a.totalFoodCount,
485
- a.showClue
482
+ l.playerAtExit,
483
+ l.foodCollected,
484
+ l.totalFoodCount,
485
+ l.showClue
486
486
  ]), d = () => {
487
487
  n.resetGameData(), s({
488
- ...He
488
+ ...Ve
489
489
  }), r({
490
- ...ke
490
+ ...Ee
491
491
  });
492
492
  };
493
493
  return /* @__PURE__ */ m(
494
- ht.Provider,
494
+ mt.Provider,
495
495
  {
496
496
  value: {
497
497
  gameProgress: i,
498
498
  setGameProgress: s,
499
- gamePlayState: a,
499
+ gamePlayState: l,
500
500
  setGamePlayState: r,
501
- gamePlayStateRef: l,
501
+ gamePlayStateRef: a,
502
502
  currentScore: c,
503
- config: e,
503
+ config: t,
504
504
  resetGame: d
505
505
  },
506
- children: t
506
+ children: e
507
507
  }
508
508
  );
509
- }, ne = () => {
510
- const t = At(ht);
511
- if (!t)
509
+ }, re = () => {
510
+ const e = Pt(mt);
511
+ if (!e)
512
512
  throw new Error("useGameContext must be used within a GameProvider");
513
- return t;
514
- }, oe = (t) => Z(() => {
515
- const e = t.map((r) => r.length), n = e.reduce((r, l) => r + l, 0), o = t.length, i = (r) => {
513
+ return e;
514
+ }, ie = (e) => Q(() => {
515
+ const t = e.map((r) => r.length), n = t.reduce((r, a) => r + a, 0), o = e.length, i = (r) => {
516
516
  if (r < 1 || r > n) return 0;
517
- let l = 0;
518
- for (let c = 0; c < e.length; c++)
519
- if (l += e[c], r <= l) return c + 1;
517
+ let a = 0;
518
+ for (let c = 0; c < t.length; c++)
519
+ if (a += t[c], r <= a) return c + 1;
520
520
  return 0;
521
- }, s = (r) => r < 1 || r > o ? 0 : e.slice(0, r - 1).reduce((l, c) => l + c, 0) + 1, a = {
521
+ }, s = (r) => r < 1 || r > o ? 0 : t.slice(0, r - 1).reduce((a, c) => a + c, 0) + 1, l = {
522
522
  getTotalLevels: () => n,
523
523
  getTotalTiers: () => o,
524
524
  getTierLevelsRange: (r) => {
525
525
  if (r < 1 || r > o) return [0, 0];
526
- const l = s(r), c = l + e[r - 1] - 1;
527
- return [l, c];
526
+ const a = s(r), c = a + t[r - 1] - 1;
527
+ return [a, c];
528
528
  },
529
529
  getTierByLevel: i,
530
530
  getFirstLevelOfTier: s,
531
531
  getLevelConfig: (r) => {
532
532
  if (r < 1 || r > n) return null;
533
- const l = i(r), c = s(l), d = r - c;
534
- return t[l - 1][d];
533
+ const a = i(r), c = s(a), d = r - c;
534
+ return e[a - 1][d];
535
535
  },
536
- getTierConfig: (r) => r < 1 || r > o ? null : t[r - 1],
537
- isLevelUnlocked: (r, l) => r <= l,
538
- isTierUnlocked: (r, l) => r <= l,
536
+ getTierConfig: (r) => r < 1 || r > o ? null : e[r - 1],
537
+ isLevelUnlocked: (r, a) => r <= a,
538
+ isTierUnlocked: (r, a) => r <= a,
539
539
  getNextLevelInfo: (r) => {
540
540
  if (r >= n) return null;
541
- const l = r + 1, c = i(r), d = i(l);
541
+ const a = r + 1, c = i(r), d = i(a);
542
542
  return {
543
- nextLevel: l,
543
+ nextLevel: a,
544
544
  nextTier: d,
545
545
  isTierChange: d > c
546
546
  };
547
547
  },
548
- getCurrentTierProgress: (r, l) => {
549
- const [c, d] = a.getTierLevelsRange(l), u = r - c + 1, h = d - c + 1;
548
+ getCurrentTierProgress: (r, a) => {
549
+ const [c, d] = l.getTierLevelsRange(a), u = r - c + 1, h = d - c + 1;
550
550
  return { current: u, total: h };
551
551
  },
552
552
  isLastLevelInTier: (r) => {
553
- const l = i(r), [, c] = a.getTierLevelsRange(l);
553
+ const a = i(r), [, c] = l.getTierLevelsRange(a);
554
554
  return r === c;
555
555
  },
556
556
  getPreviousLevelInfo: (r) => {
557
557
  if (r <= 1) return null;
558
- const l = r - 1, c = i(r), d = i(l);
558
+ const a = r - 1, c = i(r), d = i(a);
559
559
  return {
560
- prevLevel: l,
560
+ prevLevel: a,
561
561
  prevTier: d,
562
562
  isTierChange: d < c
563
563
  };
564
564
  }
565
565
  };
566
- return a;
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();
566
+ return l;
567
+ }, [e]), Dt = ({ onTierChange: e, disabled: t }) => {
568
+ const { gameProgress: n, config: o } = re(), { i18n: i, levelConfig: s } = o, { currentTier: l, highestUnlockedTier: r } = n, c = ie(s).getTotalTiers();
569
569
  return /* @__PURE__ */ m("div", { className: "tier-selector", children: /* @__PURE__ */ m(
570
570
  "select",
571
571
  {
572
- value: a,
572
+ value: l,
573
573
  onChange: (d) => {
574
- d.target && d.target.value && t(Number(d.target.value));
574
+ d.target && d.target.value && e(Number(d.target.value));
575
575
  },
576
- disabled: e,
576
+ disabled: t,
577
577
  className: "tier-dropdown",
578
578
  children: Array.from({ length: c }, (d, u) => u + 1).map((d) => /* @__PURE__ */ m(
579
579
  "option",
@@ -586,25 +586,25 @@ const xt = (t) => ({
586
586
  ))
587
587
  }
588
588
  ) });
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
- const [h, f] = d.getTierLevelsRange(a);
592
- return Array.from({ length: f - h + 1 }, (k, p) => {
593
- const _ = h + p, b = r[_] || 0;
589
+ }, Ot = ({ onLevelChange: e, disabled: t }) => {
590
+ const { gameProgress: n, config: o } = re(), { i18n: i, levelConfig: s } = o, { currentTier: l, levelScores: r, currentLevel: a, highestUnlockedLevel: c } = n, d = ie(s), u = Q(() => {
591
+ const [h, f] = d.getTierLevelsRange(l);
592
+ return Array.from({ length: f - h + 1 }, (g, _) => {
593
+ const v = h + _, T = r[v] || 0;
594
594
  return {
595
- level: _,
596
- score: b
595
+ level: v,
596
+ score: T
597
597
  };
598
598
  });
599
- }, [a, r]);
599
+ }, [l, r]);
600
600
  return /* @__PURE__ */ m("div", { className: "level-selector", children: /* @__PURE__ */ m(
601
601
  "select",
602
602
  {
603
- value: l,
603
+ value: a,
604
604
  onChange: (h) => {
605
- h.target && h.target.value && t(Number(h.target.value));
605
+ h.target && h.target.value && e(Number(h.target.value));
606
606
  },
607
- disabled: e,
607
+ disabled: t,
608
608
  className: "level-dropdown",
609
609
  children: u.map(({ level: h, score: f }) => /* @__PURE__ */ m(
610
610
  "option",
@@ -617,44 +617,44 @@ const xt = (t) => ({
617
617
  ))
618
618
  }
619
619
  ) });
620
- }, Q = ({
621
- isOpen: t,
622
- title: e,
620
+ }, te = ({
621
+ isOpen: e,
622
+ title: t,
623
623
  className: n = "",
624
624
  message: o,
625
625
  children: i,
626
626
  noConfirm: s = !1,
627
- noCancel: a = !1,
627
+ noCancel: l = !1,
628
628
  confirmText: r = "OK",
629
- cancelText: l = "Cancel",
629
+ cancelText: a = "Cancel",
630
630
  confirmClass: c = "",
631
631
  cancelClass: d = "",
632
632
  onConfirm: u,
633
633
  onCancel: h
634
634
  }) => {
635
- const f = O(null);
636
- return R(() => {
637
- const k = (p) => {
638
- p.key === "Escape" && h?.();
635
+ const f = R(null);
636
+ return I(() => {
637
+ const g = (_) => {
638
+ _.key === "Escape" && h?.();
639
639
  };
640
- return t && document.addEventListener("keydown", k), () => {
641
- document.removeEventListener("keydown", k);
640
+ return e && document.addEventListener("keydown", g), () => {
641
+ document.removeEventListener("keydown", g);
642
642
  };
643
- }, [t, h]), /* @__PURE__ */ m(
643
+ }, [e, h]), /* @__PURE__ */ m(
644
644
  "div",
645
645
  {
646
- className: `maze-dialog-overlay ${t ? "maze-dialog-visible" : ""}`,
646
+ className: `maze-dialog-overlay ${e ? "maze-dialog-visible" : ""}`,
647
647
  children: /* @__PURE__ */ m("div", { className: "maze-dialog " + n, ref: f, children: [
648
- /* @__PURE__ */ m("div", { className: "maze-dialog-title", children: e }),
648
+ /* @__PURE__ */ m("div", { className: "maze-dialog-title", children: t }),
649
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(
650
+ (!l || !s) && /* @__PURE__ */ m("div", { className: "maze-dialog-buttons", children: [
651
+ !l && /* @__PURE__ */ m(
652
652
  "button",
653
653
  {
654
654
  type: "button",
655
655
  className: "maze-dialog-cancel " + d,
656
656
  onClick: h,
657
- children: l
657
+ children: a
658
658
  }
659
659
  ),
660
660
  !s && /* @__PURE__ */ m(
@@ -670,17 +670,17 @@ const xt = (t) => ({
670
670
  ] })
671
671
  }
672
672
  );
673
- }, j = {
673
+ }, q = {
674
674
  container: null,
675
675
  // attach Toast container to element, only need to execute once
676
- attachTo(t) {
677
- return this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = document.createElement("div"), this.container.className = "toast-container position-bottom", t.appendChild(this.container), this.container;
676
+ attachTo(e) {
677
+ return this.container && this.container.parentNode && this.container.parentNode.removeChild(this.container), this.container = document.createElement("div"), this.container.className = "toast-container position-bottom", e.appendChild(this.container), this.container;
678
678
  },
679
679
  // current toast element
680
680
  currentToast: null,
681
681
  currentTimer: null,
682
682
  // use it in any component
683
- show(t, e = 2e3) {
683
+ show(e, t = 2e3) {
684
684
  if (!this.container) {
685
685
  console.warn(
686
686
  "NativeToast: container not initialized, please call attachTo first"
@@ -689,66 +689,66 @@ const xt = (t) => ({
689
689
  }
690
690
  this.currentToast && this.container.contains(this.currentToast) && (this.container.removeChild(this.currentToast), this.currentToast = null), this.currentTimer && (clearTimeout(this.currentTimer), this.currentTimer = null);
691
691
  const n = document.createElement("div");
692
- n.className = "toast-message toast-visible", n.textContent = t, this.container.appendChild(n), this.currentToast = n, this.currentTimer = setTimeout(() => {
692
+ n.className = "toast-message toast-visible", n.textContent = e, this.container.appendChild(n), this.currentToast = n, this.currentTimer = setTimeout(() => {
693
693
  n.classList.remove("toast-visible"), setTimeout(() => {
694
694
  this.container && this.container.contains(n) && (this.container.removeChild(n), this.currentToast === n && (this.currentToast = null));
695
695
  }, 300), this.currentTimer = null;
696
- }, e);
696
+ }, t);
697
697
  },
698
698
  clearAll() {
699
699
  if (this.container)
700
700
  for (; this.container.firstChild; )
701
701
  this.container.removeChild(this.container.firstChild);
702
702
  }
703
- }, Ot = () => {
703
+ }, $t = () => {
704
704
  const {
705
- gameProgress: t,
706
- setGameProgress: e,
705
+ gameProgress: e,
706
+ setGameProgress: t,
707
707
  gamePlayState: n,
708
708
  setGamePlayState: o,
709
709
  gamePlayStateRef: i,
710
710
  resetGame: s,
711
- config: a
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, C] = U(!1), [M, w] = 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())));
717
- }, E = () => {
718
- _(!0);
719
- }, L = () => {
720
- _(!1);
711
+ config: l
712
+ } = re(), { i18n: r, levelConfig: a } = l, c = ie(a), { levelTransitioning: d, showClue: u } = n, { highestUnlockedLevel: h, totalScore: f } = e, g = c.getTotalLevels(), [_, v] = W(!1), [T, b] = W(!1), [C, p] = W(!1), S = (O) => {
713
+ const $ = c.getFirstLevelOfTier(O);
714
+ c.isLevelUnlocked($, h) && (t((U) => ({ ...U, currentTier: O })), w($));
715
+ }, w = (O) => {
716
+ c.isLevelUnlocked(O, h) && (t(($) => ({ ...$, currentLevel: O })), q.show(r.levelGoToast.replace("%LEVEL%", O.toString())));
721
717
  }, y = () => {
722
- w(!0);
723
- }, g = () => {
724
- w(!1);
725
- }, v = () => {
726
- j.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
718
+ v(!0);
719
+ }, z = () => {
720
+ v(!1);
721
+ }, N = () => {
722
+ p(!0);
723
+ }, E = () => {
724
+ p(!1);
725
+ }, k = () => {
726
+ q.show(u ? r.cluePathDisabled : r.cluePathEnabled), o(() => ({
727
727
  ...i.current,
728
728
  // need to sync with ref
729
729
  showClue: !i.current.showClue
730
- })), w(!1);
731
- }, T = () => {
732
- C(!0);
733
- }, N = () => {
734
- s(), C(!1), j.show(r.resetDoneToast);
735
- }, P = () => {
736
- C(!1);
730
+ })), p(!1);
731
+ }, L = () => {
732
+ b(!0);
733
+ }, A = () => {
734
+ s(), b(!1), q.show(r.resetDoneToast);
735
+ }, x = () => {
736
+ b(!1);
737
737
  };
738
738
  return /* @__PURE__ */ m("div", { class: "game-panel-container", children: [
739
739
  /* @__PURE__ */ m("div", { className: "game-controls", children: [
740
740
  /* @__PURE__ */ m("div", { className: "selectors-container", children: [
741
741
  /* @__PURE__ */ m(
742
- Ft,
742
+ Dt,
743
743
  {
744
- onTierChange: z,
744
+ onTierChange: S,
745
745
  disabled: d
746
746
  }
747
747
  ),
748
748
  /* @__PURE__ */ m(
749
- Dt,
749
+ Ot,
750
750
  {
751
- onLevelChange: S,
751
+ onLevelChange: w,
752
752
  disabled: d
753
753
  }
754
754
  )
@@ -759,23 +759,23 @@ const xt = (t) => ({
759
759
  className: `settings-clue-button ${u ? "clue-on" : "clue-off"}`,
760
760
  disabled: u,
761
761
  title: "Toggle Clue",
762
- onClick: y,
762
+ onClick: N,
763
763
  children: u ? r.clueOn : r.clueOff
764
764
  }
765
765
  )
766
766
  ] }),
767
- /* @__PURE__ */ m("div", { className: "game-settings", children: /* @__PURE__ */ m("span", { className: "game-settings-icon", onClick: E, children: "★ " + f }) }),
767
+ /* @__PURE__ */ m("div", { className: "game-settings", children: /* @__PURE__ */ m("span", { className: "game-settings-icon", onClick: y, children: "★ " + f }) }),
768
768
  /* @__PURE__ */ m(
769
- Q,
769
+ te,
770
770
  {
771
- isOpen: p,
771
+ isOpen: _,
772
772
  title: r.settings,
773
773
  noConfirm: !0,
774
774
  cancelText: r.close,
775
- onCancel: L,
775
+ onCancel: z,
776
776
  children: [
777
777
  /* @__PURE__ */ m("div", { className: "settings-stats", children: [
778
- /* @__PURE__ */ m("div", { children: r.levelComplete + `: ${h}/${k}` }),
778
+ /* @__PURE__ */ m("div", { children: r.levelComplete + `: ${h}/${g}` }),
779
779
  /* @__PURE__ */ m("div", { children: r.starsCollected + ": " + f }),
780
780
  /* @__PURE__ */ m("div", { children: r.avgStarPerLevel + ": " + (f / h).toFixed(2) })
781
781
  ] }),
@@ -785,7 +785,7 @@ const xt = (t) => ({
785
785
  {
786
786
  className: "settings-reset-button",
787
787
  title: "Reset Game",
788
- onClick: T,
788
+ onClick: L,
789
789
  children: r.reset
790
790
  }
791
791
  ),
@@ -795,127 +795,127 @@ const xt = (t) => ({
795
795
  }
796
796
  ),
797
797
  /* @__PURE__ */ m(
798
- Q,
798
+ te,
799
799
  {
800
- isOpen: b,
800
+ isOpen: T,
801
801
  title: r.confirmReset,
802
802
  message: r.confirmResetMessage,
803
803
  confirmText: r.reset,
804
804
  cancelText: r.cancel,
805
- onConfirm: N,
806
- onCancel: P
805
+ onConfirm: A,
806
+ onCancel: x
807
807
  }
808
808
  ),
809
809
  /* @__PURE__ */ m(
810
- Q,
810
+ te,
811
811
  {
812
- isOpen: M,
812
+ isOpen: C,
813
813
  title: r.confirmClue,
814
814
  message: r.confirmClueMessage,
815
815
  confirmText: r.confirm,
816
816
  cancelText: r.cancel,
817
- onConfirm: v,
818
- onCancel: g
817
+ onConfirm: k,
818
+ onCancel: E
819
819
  }
820
820
  )
821
821
  ] });
822
822
  };
823
- function Ne(t, e) {
824
- if (!(t instanceof e))
823
+ function Pe(e, t) {
824
+ if (!(e instanceof t))
825
825
  throw new TypeError("Cannot call a class as a function");
826
826
  }
827
- function $t(t, e) {
828
- for (var n = 0; n < e.length; n++) {
829
- var o = e[n];
830
- o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(t, o.key, o);
827
+ function Ut(e, t) {
828
+ for (var n = 0; n < t.length; n++) {
829
+ var o = t[n];
830
+ o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, o.key, o);
831
831
  }
832
832
  }
833
- function Me(t, e, n) {
834
- return e && $t(t.prototype, e), t;
833
+ function Ie(e, t, n) {
834
+ return t && Ut(e.prototype, t), e;
835
835
  }
836
- function Be(t) {
837
- return +t.replace(/px/, "");
836
+ function Xe(e) {
837
+ return +e.replace(/px/, "");
838
838
  }
839
- function Ut(t) {
840
- var e = window.devicePixelRatio, n = getComputedStyle(t), o = Be(n.getPropertyValue("width")), i = Be(n.getPropertyValue("height"));
841
- t.setAttribute("width", (o * e).toString()), t.setAttribute("height", (i * e).toString());
839
+ function Gt(e) {
840
+ var t = window.devicePixelRatio, n = getComputedStyle(e), o = Xe(n.getPropertyValue("width")), i = Xe(n.getPropertyValue("height"));
841
+ e.setAttribute("width", (o * t).toString()), e.setAttribute("height", (i * t).toString());
842
842
  }
843
- function W(t, e) {
844
- var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (e - t) + t;
843
+ function j(e, t) {
844
+ var n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : 0, o = Math.random() * (t - e) + e;
845
845
  return Math.floor(o * Math.pow(10, n)) / Math.pow(10, n);
846
846
  }
847
- function Ve(t) {
848
- return t[W(0, t.length)];
847
+ function Ye(e) {
848
+ return e[j(0, e.length)];
849
849
  }
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
- var e = 1920;
853
- return Math.log(t) / Math.log(e);
850
+ var Wt = 125e-5, jt = 5e-4, qt = 9e-4, Ht = 1e-5, Bt = 6, Vt = 80, Xt = 0.9, Yt = 1.7, Kt = 0.2, Jt = 0.6, Zt = 0.03, Qt = 0.07, en = 15, tn = 82, nn = 100, on = 250, rn = 40, sn = ["#fcf403", "#62fc03", "#f4fc03", "#03e7fc", "#03fca5", "#a503fc", "#fc03ad", "#fc03c2"];
851
+ function Ke(e) {
852
+ var t = 1920;
853
+ return Math.log(e) / Math.log(t);
854
854
  }
855
- var Ye = /* @__PURE__ */ function() {
856
- function t(e) {
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);
855
+ var Je = /* @__PURE__ */ function() {
856
+ function e(t) {
857
+ Pe(this, e);
858
+ var n = t.initialPosition, o = t.direction, i = t.confettiRadius, s = t.confettiColors, l = t.emojis, r = t.emojiSize, a = t.canvasWidth, c = j(Xt, Yt, 3), d = c * Ke(a);
859
859
  this.confettiSpeed = {
860
860
  x: d,
861
861
  y: d
862
- }, this.finalConfettiSpeedX = W(Yt, Kt, 3), this.rotationSpeed = a.length ? 0.01 : W(Jt, Zt, 3) * Xe(l), this.dragForceCoefficient = W(Wt, jt, 6), this.radius = {
862
+ }, this.finalConfettiSpeedX = j(Kt, Jt, 3), this.rotationSpeed = l.length ? 0.01 : j(Zt, Qt, 3) * Ke(a), this.dragForceCoefficient = j(jt, qt, 6), this.radius = {
863
863
  x: i,
864
864
  y: i
865
- }, 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;
865
+ }, this.initialRadius = i, this.rotationAngle = o === "left" ? j(0, 0.2, 3) : j(-0.2, 0, 3), this.emojiSize = r, this.emojiRotationAngle = j(0, 2 * Math.PI), this.radiusYUpdateDirection = "down";
866
+ var u = o === "left" ? j(tn, en) * Math.PI / 180 : j(-15, -82) * Math.PI / 180;
867
867
  this.absCos = Math.abs(Math.cos(u)), this.absSin = Math.abs(Math.sin(u));
868
- var h = W(-150, 0), f = {
868
+ var h = j(-150, 0), f = {
869
869
  x: n.x + (o === "left" ? -h : h) * this.absCos,
870
870
  y: n.y - h * this.absSin
871
871
  };
872
- this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = a.length ? null : Ve(s), this.emoji = a.length ? Ve(a) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
872
+ this.currentPosition = Object.assign({}, f), this.initialPosition = Object.assign({}, f), this.color = l.length ? null : Ye(s), this.emoji = l.length ? Ye(l) : null, this.createdAt = (/* @__PURE__ */ new Date()).getTime(), this.direction = o;
873
873
  }
874
- return Me(t, [{
874
+ return Ie(e, [{
875
875
  key: "draw",
876
876
  value: function(n) {
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;
878
- s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : a && (n.font = "".concat(c, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(l), n.textAlign = "center", n.fillText(a, 0, 0), n.restore());
877
+ var o = this.currentPosition, i = this.radius, s = this.color, l = this.emoji, r = this.rotationAngle, a = this.emojiRotationAngle, c = this.emojiSize, d = window.devicePixelRatio;
878
+ s ? (n.fillStyle = s, n.beginPath(), n.ellipse(o.x * d, o.y * d, i.x * d, i.y * d, r, 0, 2 * Math.PI), n.fill()) : l && (n.font = "".concat(c, "px serif"), n.save(), n.translate(d * o.x, d * o.y), n.rotate(a), n.textAlign = "center", n.fillText(l, 0, 0), n.restore());
879
879
  }
880
880
  }, {
881
881
  key: "updatePosition",
882
882
  value: function(n, o) {
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 + Gt * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : qt * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
883
+ var i = this.confettiSpeed, s = this.dragForceCoefficient, l = this.finalConfettiSpeedX, r = this.radiusYUpdateDirection, a = this.rotationSpeed, c = this.createdAt, d = this.direction, u = o - c;
884
+ if (i.x > l && (this.confettiSpeed.x -= s * n), this.currentPosition.x += i.x * (d === "left" ? -this.absCos : this.absCos) * n, this.currentPosition.y = this.initialPosition.y - i.y * this.absSin * u + Wt * Math.pow(u, 2) / 2, this.rotationSpeed -= this.emoji ? 1e-4 : Ht * n, this.rotationSpeed < 0 && (this.rotationSpeed = 0), this.emoji) {
885
885
  this.emojiRotationAngle += this.rotationSpeed * n % (2 * Math.PI);
886
886
  return;
887
887
  }
888
- r === "down" ? (this.radius.y -= n * l, this.radius.y <= 0 && (this.radius.y = 0, this.radiusYUpdateDirection = "up")) : (this.radius.y += n * l, this.radius.y >= this.initialRadius && (this.radius.y = this.initialRadius, this.radiusYUpdateDirection = "down"));
888
+ r === "down" ? (this.radius.y -= n * a, this.radius.y <= 0 && (this.radius.y = 0, this.radiusYUpdateDirection = "up")) : (this.radius.y += n * a, this.radius.y >= this.initialRadius && (this.radius.y = this.initialRadius, this.radiusYUpdateDirection = "down"));
889
889
  }
890
890
  }, {
891
891
  key: "getIsVisibleOnCanvas",
892
892
  value: function(n) {
893
- return this.currentPosition.y < n + tn;
893
+ return this.currentPosition.y < n + nn;
894
894
  }
895
- }]), t;
895
+ }]), e;
896
896
  }();
897
- function sn() {
898
- var t = document.createElement("canvas");
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;
897
+ function ln() {
898
+ var e = document.createElement("canvas");
899
+ return e.style.position = "fixed", e.style.width = "100%", e.style.height = "100%", e.style.top = "0", e.style.left = "0", e.style.zIndex = "1000", e.style.pointerEvents = "none", document.body.appendChild(e), e;
900
900
  }
901
- function 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
- 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"), {
901
+ function an(e) {
902
+ var t = e.confettiRadius, n = t === void 0 ? Bt : t, o = e.confettiNumber, i = o === void 0 ? e.confettiesNumber || (e.emojis ? rn : on) : o, s = e.confettiColors, l = s === void 0 ? sn : s, r = e.emojis, a = r === void 0 ? e.emojies || [] : r, c = e.emojiSize, d = c === void 0 ? Vt : c;
903
+ return e.emojies && console.error("emojies argument is deprecated, please use emojis instead"), e.confettiesNumber && console.error("confettiesNumber argument is deprecated, please use confettiNumber instead"), {
904
904
  confettiRadius: n,
905
905
  confettiNumber: i,
906
- confettiColors: a,
907
- emojis: l,
906
+ confettiColors: l,
907
+ emojis: a,
908
908
  emojiSize: d
909
909
  };
910
910
  }
911
- var ln = /* @__PURE__ */ function() {
912
- function t(e) {
911
+ var cn = /* @__PURE__ */ function() {
912
+ function e(t) {
913
913
  var n = this;
914
- Ne(this, t), this.canvasContext = e, this.shapes = [], this.promise = new Promise(function(o) {
914
+ Pe(this, e), this.canvasContext = t, this.shapes = [], this.promise = new Promise(function(o) {
915
915
  return n.resolvePromise = o;
916
916
  });
917
917
  }
918
- return Me(t, [{
918
+ return Ie(e, [{
919
919
  key: "getBatchCompletePromise",
920
920
  value: function() {
921
921
  return this.promise;
@@ -935,27 +935,27 @@ var ln = /* @__PURE__ */ function() {
935
935
  }, {
936
936
  key: "processShapes",
937
937
  value: function(n, o, i) {
938
- var s = this, a = n.timeDelta, r = n.currentTime;
939
- this.shapes = this.shapes.filter(function(l) {
940
- return l.updatePosition(a, r), l.draw(s.canvasContext), i ? l.getIsVisibleOnCanvas(o) : !0;
938
+ var s = this, l = n.timeDelta, r = n.currentTime;
939
+ this.shapes = this.shapes.filter(function(a) {
940
+ return a.updatePosition(l, r), a.draw(s.canvasContext), i ? a.getIsVisibleOnCanvas(o) : !0;
941
941
  });
942
942
  }
943
- }]), t;
944
- }(), cn = /* @__PURE__ */ function() {
945
- function t() {
946
- var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
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);
943
+ }]), e;
944
+ }(), un = /* @__PURE__ */ function() {
945
+ function e() {
946
+ var t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
947
+ Pe(this, e), this.activeConfettiBatches = [], this.canvas = t.canvas || ln(), this.canvasContext = this.canvas.getContext("2d"), this.requestAnimationFrameRequested = !1, this.lastUpdated = (/* @__PURE__ */ new Date()).getTime(), this.iterationIndex = 0, this.loop = this.loop.bind(this), requestAnimationFrame(this.loop);
948
948
  }
949
- return Me(t, [{
949
+ return Ie(e, [{
950
950
  key: "loop",
951
951
  value: function() {
952
- this.requestAnimationFrameRequested = !1, Ut(this.canvas);
952
+ this.requestAnimationFrameRequested = !1, Gt(this.canvas);
953
953
  var n = (/* @__PURE__ */ new Date()).getTime(), o = n - this.lastUpdated, i = this.canvas.offsetHeight, s = this.iterationIndex % 10 === 0;
954
- this.activeConfettiBatches = this.activeConfettiBatches.filter(function(a) {
955
- return a.processShapes({
954
+ this.activeConfettiBatches = this.activeConfettiBatches.filter(function(l) {
955
+ return l.processShapes({
956
956
  timeDelta: o,
957
957
  currentTime: n
958
- }, i, s), s ? !a.complete() : !0;
958
+ }, i, s), s ? !l.complete() : !0;
959
959
  }), this.iterationIndex++, this.queueAnimationFrameIfNeeded(n);
960
960
  }
961
961
  }, {
@@ -966,35 +966,35 @@ var ln = /* @__PURE__ */ function() {
966
966
  }, {
967
967
  key: "addConfetti",
968
968
  value: function() {
969
- for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = 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 = {
969
+ for (var n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, o = an(n), i = o.confettiRadius, s = o.confettiNumber, l = o.confettiColors, r = o.emojis, a = o.emojiSize, c = this.canvas.getBoundingClientRect(), d = c.width, u = c.height, h = u * 5 / 7, f = {
970
970
  x: 0,
971
971
  y: h
972
- }, k = {
972
+ }, g = {
973
973
  x: d,
974
974
  y: h
975
- }, p = new ln(this.canvasContext), _ = 0; _ < s / 2; _++) {
976
- var b = new Ye({
975
+ }, _ = new cn(this.canvasContext), v = 0; v < s / 2; v++) {
976
+ var T = new Je({
977
977
  initialPosition: f,
978
978
  direction: "right",
979
979
  confettiRadius: i,
980
- confettiColors: a,
980
+ confettiColors: l,
981
981
  confettiNumber: s,
982
982
  emojis: r,
983
- emojiSize: l,
983
+ emojiSize: a,
984
984
  canvasWidth: d
985
- }), C = new Ye({
986
- initialPosition: k,
985
+ }), b = new Je({
986
+ initialPosition: g,
987
987
  direction: "left",
988
988
  confettiRadius: i,
989
- confettiColors: a,
989
+ confettiColors: l,
990
990
  confettiNumber: s,
991
991
  emojis: r,
992
- emojiSize: l,
992
+ emojiSize: a,
993
993
  canvasWidth: d
994
994
  });
995
- p.addShapes(b, C);
995
+ _.addShapes(T, b);
996
996
  }
997
- return this.activeConfettiBatches.push(p), this.queueAnimationFrameIfNeeded(), p.getBatchCompletePromise();
997
+ return this.activeConfettiBatches.push(_), this.queueAnimationFrameIfNeeded(), _.getBatchCompletePromise();
998
998
  }
999
999
  }, {
1000
1000
  key: "clearCanvas",
@@ -1006,91 +1006,91 @@ var ln = /* @__PURE__ */ function() {
1006
1006
  value: function() {
1007
1007
  this.canvas.remove();
1008
1008
  }
1009
- }]), t;
1009
+ }]), e;
1010
1010
  }();
1011
- const un = new cn(), Ce = 3, dn = ({ onRetry: t }) => {
1011
+ const dn = new un(), be = 3, hn = ({ onRetry: e }) => {
1012
1012
  const {
1013
- config: e,
1013
+ config: t,
1014
1014
  currentScore: n,
1015
1015
  gamePlayState: o,
1016
1016
  setGamePlayState: i,
1017
1017
  gameProgress: s,
1018
- setGameProgress: a
1019
- } = ne(), { i18n: r, levelConfig: l } = e, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: k, levelTransitioning: p } = o, { currentLevel: _ } = s, [b, C] = U(!1);
1020
- R(() => {
1021
- k && p && (un.addConfetti(), j.show(r.levelCompleteToast), C(!0));
1022
- }, [k, p]);
1023
- const M = oe(l), w = M.getTotalLevels(), z = Z(() => _ >= w, [_, w]), S = () => {
1024
- C(!1), j.show(r.levelRestartToast), t?.();
1025
- }, E = () => {
1026
- C(!1), i((g) => ({
1027
- ...g,
1018
+ setGameProgress: l
1019
+ } = re(), { i18n: r, levelConfig: a } = t, [c, d, u] = n, { foodCollected: h, totalFoodCount: f, playerAtExit: g, levelTransitioning: _ } = o, { currentLevel: v } = s, [T, b] = W(!1);
1020
+ I(() => {
1021
+ g && _ && (dn.addConfetti(), q.show(r.levelCompleteToast), b(!0));
1022
+ }, [g, _]);
1023
+ const C = ie(a), p = C.getTotalLevels(), S = Q(() => v >= p, [v, p]), w = () => {
1024
+ b(!1), q.show(r.levelRestartToast), e?.();
1025
+ }, y = () => {
1026
+ b(!1), i((E) => ({
1027
+ ...E,
1028
1028
  isGameActive: !0,
1029
1029
  levelTransitioning: !1
1030
1030
  }));
1031
- }, L = () => {
1032
- C(!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),
1031
+ }, z = () => {
1032
+ b(!1);
1033
+ const E = C.getNextLevelInfo(v);
1034
+ if (!E) return;
1035
+ const { nextLevel: k, nextTier: L, isTierChange: A } = E;
1036
+ A && q.show(
1037
+ r.tierUnlockedToast.replace("%TIER%", L.toString())
1038
+ ), l((x) => ({
1039
+ ...x,
1040
+ currentLevel: k,
1041
+ currentTier: L,
1042
+ highestUnlockedLevel: Math.max(x.highestUnlockedLevel, k),
1043
+ highestUnlockedTier: Math.max(x.highestUnlockedTier, L),
1044
1044
  levelScores: {
1045
- ...P.levelScores,
1046
- [P.currentLevel]: Math.max(
1045
+ ...x.levelScores,
1046
+ [x.currentLevel]: Math.max(
1047
1047
  Object.values(n).filter(Boolean).length,
1048
- P.levelScores[P.currentLevel] || 0
1048
+ x.levelScores[x.currentLevel] || 0
1049
1049
  )
1050
1050
  }
1051
1051
  }));
1052
- }, y = () => {
1053
- C(!1), a((g) => {
1054
- const v = Math.max(
1052
+ }, N = () => {
1053
+ b(!1), l((E) => {
1054
+ const k = Math.max(
1055
1055
  Object.values(n).filter(Boolean).length,
1056
- g.levelScores[g.currentLevel] || 0
1057
- ), T = {
1058
- ...g.levelScores,
1059
- [g.currentLevel]: v
1056
+ E.levelScores[E.currentLevel] || 0
1057
+ ), L = {
1058
+ ...E.levelScores,
1059
+ [E.currentLevel]: k
1060
1060
  };
1061
- let N = 0, P = 0;
1062
- const D = Object.entries(T).sort(
1063
- (I, $) => Number(I[0]) - Number($[0])
1061
+ let A = 0, x = 0;
1062
+ const O = Object.entries(L).sort(
1063
+ ($, U) => Number($[0]) - Number(U[0])
1064
1064
  );
1065
- for (const [I, $] of D)
1066
- if ($ < Ce) {
1067
- N = Number(I), P = M.getTierByLevel(N);
1065
+ for (const [$, U] of O)
1066
+ if (U < be) {
1067
+ A = Number($), x = C.getTierByLevel(A);
1068
1068
  break;
1069
1069
  }
1070
- return (N > 0 && N !== _ || v < Ce) && j.show(r.notCompleteLevel), (N === 0 || v < Ce) && t?.(), {
1071
- ...g,
1072
- currentLevel: N || g.currentLevel,
1073
- currentTier: P || g.currentTier,
1074
- levelScores: T
1070
+ return (A > 0 && A !== v || k < be) && q.show(r.notCompleteLevel), (A === 0 || k < be) && e?.(), {
1071
+ ...E,
1072
+ currentLevel: A || E.currentLevel,
1073
+ currentTier: x || E.currentTier,
1074
+ levelScores: L
1075
1075
  };
1076
1076
  });
1077
1077
  };
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());
1078
+ return I(() => {
1079
+ const E = document.querySelector(".maze-game-container"), k = (L) => {
1080
+ T && ((L.key === " " || L.code === "Space") && E && (E.contains(document.activeElement) || document.activeElement === document.body) && (L.preventDefault(), S ? N() : z()), (L.key === "r" || L.code === "KeyR") && w(), (L.key === "c" || L.code === "KeyC") && y());
1081
1081
  };
1082
- return window.addEventListener("keydown", v), () => window.removeEventListener("keydown", v);
1083
- }, [b, z]), /* @__PURE__ */ m(
1084
- Q,
1082
+ return window.addEventListener("keydown", k), () => window.removeEventListener("keydown", k);
1083
+ }, [T, S]), /* @__PURE__ */ m(
1084
+ te,
1085
1085
  {
1086
1086
  className: "level-complete-dialog",
1087
- isOpen: b,
1087
+ isOpen: T,
1088
1088
  title: r.congratulations,
1089
1089
  cancelText: r.retry + " (R)",
1090
- onCancel: S,
1090
+ onCancel: w,
1091
1091
  noConfirm: !!d,
1092
1092
  confirmText: r.continue + " (C)",
1093
- onConfirm: E,
1093
+ onConfirm: y,
1094
1094
  confirmClass: "maze-continue-btn",
1095
1095
  children: [
1096
1096
  /* @__PURE__ */ m("div", { className: "maze-summary-message", children: [
@@ -1098,13 +1098,13 @@ const un = new cn(), Ce = 3, dn = ({ onRetry: t }) => {
1098
1098
  /* @__PURE__ */ m("div", { children: u ? "★ - " + r.withoutClue : "☆ - " + r.withClue }),
1099
1099
  /* @__PURE__ */ m("div", { children: (d ? "★ - " + r.collectAllStars : "☆ - " + r.notCollectAllStars) + ` (${h}/${f})` })
1100
1100
  ] }),
1101
- z && /* @__PURE__ */ m("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
1102
- /* @__PURE__ */ m("div", { className: "maze-go-next", children: z ? /* @__PURE__ */ m(
1101
+ S && /* @__PURE__ */ m("div", { className: "all-levels-completed", children: r.allLevelsCompleted }),
1102
+ /* @__PURE__ */ m("div", { className: "maze-go-next", children: S ? /* @__PURE__ */ m(
1103
1103
  "button",
1104
1104
  {
1105
1105
  className: "maze-go-next-btn",
1106
1106
  type: "button",
1107
- onClick: y,
1107
+ onClick: N,
1108
1108
  children: [
1109
1109
  /* @__PURE__ */ m("span", { children: r.lastOK }),
1110
1110
  /* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
@@ -1115,7 +1115,7 @@ const un = new cn(), Ce = 3, dn = ({ onRetry: t }) => {
1115
1115
  {
1116
1116
  className: "maze-go-next-btn",
1117
1117
  type: "button",
1118
- onClick: L,
1118
+ onClick: z,
1119
1119
  children: [
1120
1120
  /* @__PURE__ */ m("span", { children: r.nextLevel }),
1121
1121
  /* @__PURE__ */ m("span", { className: "spacebar-tip", children: `(${r.spacebarTip})` })
@@ -1126,239 +1126,229 @@ const un = new cn(), Ce = 3, dn = ({ onRetry: t }) => {
1126
1126
  ]
1127
1127
  }
1128
1128
  );
1129
- }, ft = (t, e) => {
1130
- const n = O({
1129
+ }, _t = (e, t) => {
1130
+ const n = R({
1131
1131
  canvasWidth: 0,
1132
1132
  canvasHeight: 0
1133
1133
  });
1134
- return R(() => {
1134
+ return I(() => {
1135
1135
  const o = () => {
1136
- const s = t.current;
1136
+ const s = e.current;
1137
1137
  if (!s) return;
1138
- const a = s.parentElement;
1139
- if (!a) return;
1140
- const r = a.clientWidth, l = window.devicePixelRatio || 1;
1138
+ const l = s.parentElement;
1139
+ if (!l) return;
1140
+ const r = l.clientWidth;
1141
+ if (r === 0)
1142
+ return;
1143
+ const a = window.devicePixelRatio || 1;
1141
1144
  s.style.width = `${r}px`, s.style.height = `${r}px`;
1142
- const c = r * l, d = r * l;
1143
- s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d }, e?.();
1145
+ const c = r * a, d = r * a;
1146
+ s.width = c, s.height = d, n.current = { canvasWidth: c, canvasHeight: d }, t?.();
1144
1147
  };
1145
1148
  o();
1146
1149
  let i = null;
1147
- return window.ResizeObserver && t.current && (i = new ResizeObserver(o), i.observe(t.current.parentElement)), window.addEventListener("resize", o), () => {
1150
+ return window.ResizeObserver && e.current && (i = new ResizeObserver(o), i.observe(e.current.parentElement)), window.addEventListener("resize", o), () => {
1148
1151
  window.removeEventListener("resize", o), i?.disconnect();
1149
1152
  };
1150
- }, [t, e]), n;
1151
- }, mt = (t, e, n) => {
1152
- const o = O({ cellWidth: 0, cellHeight: 0 });
1153
- return R(() => {
1153
+ }, [e, t]), n;
1154
+ }, vt = (e, t, n) => {
1155
+ const o = R({ cellWidth: 0, cellHeight: 0 });
1156
+ return I(() => {
1154
1157
  const i = () => {
1155
- const a = t.current, r = e.maze;
1156
- if (!a || !r) return;
1157
- const { rows: l, cols: c } = r;
1158
- if (l <= 0 || c <= 0) return;
1159
- const d = (a.width - n * 2) / c, u = (a.height - n * 2) / l;
1158
+ const l = e.current, r = t.maze;
1159
+ if (!l || !r) return;
1160
+ const { rows: a, cols: c } = r;
1161
+ if (a <= 0 || c <= 0) return;
1162
+ const d = (l.width - n * 2) / c, u = (l.height - n * 2) / a;
1160
1163
  o.current = { cellWidth: d, cellHeight: u };
1161
1164
  };
1162
1165
  i();
1163
1166
  let s = null;
1164
- return t.current && window.ResizeObserver && (s = new ResizeObserver(i), s.observe(t.current)), () => {
1165
- t.current && s?.disconnect();
1167
+ return e.current && window.ResizeObserver && (s = new ResizeObserver(i), s.observe(e.current)), () => {
1168
+ e.current && s?.disconnect();
1166
1169
  };
1167
- }, [t, e.maze, n]), o;
1168
- }, ie = {
1170
+ }, [e, t.maze, n]), o;
1171
+ }, ce = {
1169
1172
  ArrowUp: [-1, 0],
1170
1173
  ArrowDown: [1, 0],
1171
1174
  ArrowLeft: [0, -1],
1172
1175
  ArrowRight: [0, 1]
1173
- }, _t = ({
1174
- containerRef: t,
1176
+ }, gt = ({
1175
1177
  gamePlayStateRef: e,
1176
- setGamePlayState: n,
1177
- moveSpeed: o,
1178
+ setGamePlayState: t,
1179
+ moveSpeed: n,
1178
1180
  // move X grid units per frame, default 0.03
1179
- moveSpeedRef: i,
1181
+ moveSpeedRef: o,
1180
1182
  // alternative: ref to move speed for dynamic updates
1181
- playerRadius: s,
1183
+ playerRadius: i,
1182
1184
  // player radius in grid unit, default 0.2
1183
- onFoodCollected: a,
1184
- onExitReached: r,
1185
- onFirstMove: l
1185
+ onFoodCollected: s,
1186
+ onExitReached: l,
1187
+ onFirstMove: r
1186
1188
  }) => {
1187
- const c = () => i?.current ?? o ?? 0.03, d = O(!1), u = O(/* @__PURE__ */ new Set()), h = O(!1), f = je(
1188
- (w, z) => {
1189
+ const a = () => o?.current ?? n ?? 0.03, c = R(!1), d = R(/* @__PURE__ */ new Set()), u = R(!1), h = He(
1190
+ (C, p) => {
1189
1191
  const S = e.current;
1190
1192
  if (!S.maze)
1191
1193
  return { canMove: !1, newCell: null };
1192
- const E = c(), [L, y] = ie[w];
1193
- if (Ke(
1194
- z,
1195
- L,
1194
+ const w = a(), [y, z] = ce[C];
1195
+ if (Ze(
1196
+ p,
1196
1197
  y,
1197
- s,
1198
- E,
1198
+ z,
1199
+ i,
1200
+ w,
1199
1201
  S.maze
1200
1202
  ))
1201
1203
  return { canMove: !1, newCell: null };
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 >= $)
1204
+ const { row: E, col: k } = p, L = E + y * w, A = k + z * w, x = -0.5, O = S.maze.rows, $ = S.maze.cols;
1205
+ if (L < x || L >= O || A < x || A >= $)
1204
1206
  return { canMove: !1, newCell: null };
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) ? {
1207
+ const U = E < 0 ? 0 : Math.floor(E), V = k < 0 ? 0 : Math.floor(k), B = L < 0 ? 0 : Math.floor(L), Y = A < 0 ? 0 : Math.floor(A);
1208
+ return B !== U || Y !== V ? S.maze.isValid(B, Y) ? {
1207
1209
  canMove: !0,
1208
- newCell: { row: G, col: q }
1210
+ newCell: { row: B, col: Y }
1209
1211
  } : { canMove: !1, newCell: null } : { canMove: !0, newCell: null };
1210
1212
  },
1211
- [s, c]
1212
- ), k = () => {
1213
- const w = e.current, { row: z, col: S } = w.playerCell, E = s * 2, L = w.foodCells.findIndex((v) => Math.sqrt(
1214
- Math.pow(z - v.row, 2) + Math.pow(S - v.col, 2)
1215
- ) < E);
1216
- L !== -1 && a && (a(), e.current = {
1213
+ [i, a]
1214
+ ), f = () => {
1215
+ const C = e.current, { row: p, col: S } = C.playerCell, w = i * 2, y = C.foodCells.findIndex((E) => Math.sqrt(
1216
+ Math.pow(p - E.row, 2) + Math.pow(S - E.col, 2)
1217
+ ) < w);
1218
+ y !== -1 && s && (s(), e.current = {
1217
1219
  ...e.current,
1218
1220
  foodCollected: e.current.foodCollected + 1,
1219
1221
  foodCells: e.current.foodCells.filter(
1220
- (v, T) => T !== L
1222
+ (E, k) => k !== y
1221
1223
  )
1222
1224
  });
1223
- const g = mn(
1224
- w.playerCell,
1225
- w.exitCell,
1226
- w.maze
1225
+ const N = _n(
1226
+ C.playerCell,
1227
+ C.exitCell,
1228
+ C.maze
1227
1229
  );
1228
- g && !e.current.playerAtExit ? (e.current = {
1230
+ N && !e.current.playerAtExit ? (e.current = {
1229
1231
  ...e.current,
1230
1232
  playerAtExit: !0,
1231
1233
  isGameActive: !1,
1232
1234
  // pause render loop and controls
1233
1235
  levelTransitioning: !0
1234
- }, r && r(), requestIdleCallback(
1236
+ }, l && l(), requestIdleCallback(
1235
1237
  () => {
1236
- n(() => ({ ...e.current }));
1238
+ t(() => ({ ...e.current }));
1237
1239
  },
1238
1240
  { timeout: 10 }
1239
- )) : !g && e.current.playerAtExit && (e.current = {
1241
+ )) : !N && e.current.playerAtExit && (e.current = {
1240
1242
  ...e.current,
1241
1243
  playerAtExit: !1,
1242
1244
  isGameActive: !0,
1243
1245
  levelTransitioning: !1
1244
1246
  });
1245
- }, p = (w) => {
1246
- const z = e.current, S = Math.round(w.row), E = Math.round(w.col), L = z.playerPath?.[z.playerPath.length - 1], y = L?.row === S && L?.col === E, g = Math.abs(L?.row ?? 0 - S), v = Math.abs(L?.col ?? 0 - E);
1247
- if ((g === 1 && v === 0 || g === 0 && v === 1) && !y) {
1248
- const N = `${L?.row},${L?.col}-${S},${E}`;
1247
+ }, g = (C) => {
1248
+ const p = e.current, S = Math.round(C.row), w = Math.round(C.col), y = p.playerPath[p.playerPath.length - 1], z = y.row === S && y.col === w, N = Math.abs(y.row - S), E = Math.abs(y.col - w);
1249
+ if ((N === 1 && E === 0 || N === 0 && E === 1) && !z) {
1250
+ const L = `${y.row},${y.col}-${S},${w}`;
1249
1251
  e.current = {
1250
1252
  ...e.current,
1251
1253
  playerPath: [
1252
- ...e.current.playerPath ?? [],
1253
- { row: S, col: E }
1254
+ ...e.current.playerPath,
1255
+ { row: S, col: w }
1254
1256
  ],
1255
1257
  visitCounts: {
1256
1258
  ...e.current.visitCounts,
1257
- [N]: (e.current.visitCounts?.[N] || 0) + 1
1259
+ [L]: (e.current.visitCounts[L] || 0) + 1
1258
1260
  }
1259
1261
  };
1260
1262
  }
1261
1263
  }, _ = () => {
1262
- if (d.current || u.current.size === 0) return;
1263
- const w = e.current;
1264
- !w.playerCell || !Array.from(u.current).some(
1264
+ if (c.current || d.current.size === 0) return;
1265
+ const C = e.current;
1266
+ !C.playerCell || !Array.from(d.current).some(
1265
1267
  (S) => {
1266
- const { canMove: E } = f(
1268
+ const { canMove: w } = h(
1267
1269
  S,
1268
- w.playerCell
1270
+ C.playerCell
1269
1271
  );
1270
- return E;
1272
+ return w;
1271
1273
  }
1272
- ) || (!h.current && l && (h.current = !0, l()), d.current = !0);
1274
+ ) || (!u.current && r && (u.current = !0, r()), c.current = !0);
1273
1275
  };
1274
- R(() => {
1275
- const w = (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();
1276
+ I(() => {
1277
+ const C = (w) => {
1278
+ if (w.key === "ArrowUp" || w.key === "ArrowDown" || w.key === "ArrowLeft" || w.key === "ArrowRight" || w.key === " ") {
1279
+ const y = document.activeElement;
1280
+ if (y && (y.tagName === "INPUT" || y.tagName === "TEXTAREA" || y.getAttribute("contenteditable") === "true")) return;
1281
+ w.preventDefault();
1280
1282
  }
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 && C());
1291
- }, E = (y) => {
1292
- y.preventDefault();
1293
- const g = e.current;
1294
- if (!g.isGameActive || !g.maze || d.current)
1295
- return;
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), _());
1299
- }, L = () => {
1300
- C();
1283
+ }, p = (w) => {
1284
+ const y = w.key;
1285
+ if (!(y in ce)) return;
1286
+ const z = document.activeElement;
1287
+ z && (z.tagName === "INPUT" || z.tagName === "TEXTAREA" || z.getAttribute("contenteditable") === "true") || (w.preventDefault(), e.current.isGameActive && (d.current.has(y) || (d.current.add(y), c.current || _())));
1288
+ }, S = (w) => {
1289
+ const y = w.key;
1290
+ if (!(y in ce)) return;
1291
+ const z = document.activeElement;
1292
+ z && (z.tagName === "INPUT" || z.tagName === "TEXTAREA" || z.getAttribute("contenteditable") === "true") || (w.preventDefault(), d.current.delete(y), d.current.size === 0 && T());
1301
1293
  };
1302
- return window.addEventListener("keydown", w, {
1294
+ return window.addEventListener("keydown", C, {
1303
1295
  capture: !0
1304
- }), window.addEventListener("keydown", z), window.addEventListener("keyup", S), t.current?.addEventListener("touchstart", E, {
1305
- passive: !1
1306
- }), t.current?.addEventListener("touchend", L), () => {
1307
- window.removeEventListener("keydown", w, {
1296
+ }), window.addEventListener("keydown", p), window.addEventListener("keyup", S), () => {
1297
+ window.removeEventListener("keydown", C, {
1308
1298
  capture: !0
1309
- }), window.removeEventListener("keydown", z), window.removeEventListener("keyup", S), t.current?.removeEventListener("touchstart", E), t.current?.removeEventListener("touchend", L);
1299
+ }), window.removeEventListener("keydown", p), window.removeEventListener("keyup", S);
1310
1300
  };
1311
1301
  }, []);
1312
- const b = je(() => {
1313
- if (!d.current || u.current.size === 0)
1302
+ const v = He(() => {
1303
+ if (!c.current || d.current.size === 0)
1314
1304
  return e.current.playerCell;
1315
- const w = 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++;
1305
+ const C = a(), p = e.current.playerCell;
1306
+ let S = 0, w = 0, y = 0;
1307
+ for (const D of d.current) {
1308
+ const { canMove: G } = h(D, p);
1309
+ if (G) {
1310
+ const [K, se] = ce[D];
1311
+ S += K, w += se, y++;
1322
1312
  }
1323
1313
  }
1324
- if (L === 0)
1314
+ if (y === 0)
1325
1315
  return e.current.playerCell;
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 * w).toFixed(2)
1328
- ), N = Number(
1329
- (z.col + v * w).toFixed(2)
1330
- ), P = T - z.row, D = N - z.col, I = Math.sqrt(P * P + D * D);
1331
- if (I > 0) {
1332
- const Y = P / I, ge = D / I;
1333
- if (Ke(
1334
- z,
1335
- Y,
1336
- ge,
1337
- s,
1338
- I,
1316
+ const z = Math.sqrt(S * S + w * w), N = z > 0 ? S / z : 0, E = z > 0 ? w / z : 0, k = Number(
1317
+ (p.row + N * C).toFixed(2)
1318
+ ), L = Number(
1319
+ (p.col + E * C).toFixed(2)
1320
+ ), A = k - p.row, x = L - p.col, O = Math.sqrt(A * A + x * x);
1321
+ if (O > 0) {
1322
+ const D = A / O, G = x / O;
1323
+ if (Ze(
1324
+ p,
1325
+ D,
1326
+ G,
1327
+ i,
1328
+ O,
1339
1329
  e.current.maze
1340
1330
  ))
1341
1331
  return e.current.playerCell;
1342
1332
  }
1343
1333
  e.current.playerCell = {
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]), C = () => {
1350
- d.current = !1, u.current.clear();
1334
+ row: k,
1335
+ col: L
1336
+ }, f();
1337
+ const $ = p.row < 0 ? 0 : Math.round(p.row), U = p.col < 0 ? 0 : Math.round(p.col), V = k < 0 ? 0 : Math.round(k), B = L < 0 ? 0 : Math.round(L);
1338
+ return (V !== $ || B !== U) && g({ row: V, col: B }), e.current.playerCell;
1339
+ }, [a, h]), T = () => {
1340
+ c.current = !1, d.current.clear();
1351
1341
  };
1352
1342
  return {
1353
- updatePlayerPos: b,
1354
- resetMovingState: C,
1343
+ updatePlayerPos: v,
1344
+ resetMovingState: T,
1355
1345
  resetFirstMoveState: () => {
1356
- h.current = !1;
1346
+ u.current = !1;
1357
1347
  }
1358
1348
  };
1359
1349
  };
1360
- function Ke(t, e, n, o, i, s) {
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);
1350
+ function Ze(e, t, n, o, i, s) {
1351
+ const l = e.row + t * i, r = e.col + n * i, a = { row: l, col: r }, c = [], d = e.row < 0 ? 0 : Math.floor(e.row), u = e.col < 0 ? 0 : Math.floor(e.col);
1362
1352
  c.push({ row: d, col: u });
1363
1353
  const h = [
1364
1354
  [-1, 0],
@@ -1378,283 +1368,283 @@ function Ke(t, e, n, o, i, s) {
1378
1368
  [1, 1]
1379
1369
  // lower right, diagonal
1380
1370
  ];
1381
- for (const [f, k] of h) {
1382
- const p = d + f, _ = u + k;
1383
- s.isValid(p, _) && c.push({ row: p, col: _ });
1371
+ for (const [f, g] of h) {
1372
+ const _ = d + f, v = u + g;
1373
+ s.isValid(_, v) && c.push({ row: _, col: v });
1384
1374
  }
1385
1375
  for (const f of c) {
1386
- const k = hn(f.row, f.col, s);
1387
- for (const p of k)
1388
- if (fn(l, p) < o)
1376
+ const g = fn(f.row, f.col, s);
1377
+ for (const _ of g)
1378
+ if (mn(a, _) < o)
1389
1379
  return !0;
1390
1380
  }
1391
1381
  return !1;
1392
1382
  }
1393
- function hn(t, e, n) {
1394
- const o = [], i = n.grid[t][e];
1383
+ function fn(e, t, n) {
1384
+ const o = [], i = n.grid[e][t];
1395
1385
  return i.walls.top && o.push({
1396
- start: { row: t - 0.5, col: e - 0.5 },
1397
- end: { row: t - 0.5, col: e + 0.5 }
1386
+ start: { row: e - 0.5, col: t - 0.5 },
1387
+ end: { row: e - 0.5, col: t + 0.5 }
1398
1388
  }), i.walls.right && o.push({
1399
- start: { row: t - 0.5, col: e + 0.5 },
1400
- end: { row: t + 0.5, col: e + 0.5 }
1389
+ start: { row: e - 0.5, col: t + 0.5 },
1390
+ end: { row: e + 0.5, col: t + 0.5 }
1401
1391
  }), i.walls.bottom && o.push({
1402
- start: { row: t + 0.5, col: e - 0.5 },
1403
- end: { row: t + 0.5, col: e + 0.5 }
1392
+ start: { row: e + 0.5, col: t - 0.5 },
1393
+ end: { row: e + 0.5, col: t + 0.5 }
1404
1394
  }), i.walls.left && o.push({
1405
- start: { row: t - 0.5, col: e - 0.5 },
1406
- end: { row: t + 0.5, col: e - 0.5 }
1395
+ start: { row: e - 0.5, col: t - 0.5 },
1396
+ end: { row: e + 0.5, col: t - 0.5 }
1407
1397
  }), o;
1408
1398
  }
1409
- function fn(t, e) {
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;
1411
- if (l === 0)
1412
- return Math.sqrt(a * a + r * r);
1399
+ function mn(e, t) {
1400
+ const { start: n, end: o } = t, i = o.col - n.col, s = o.row - n.row, l = e.col - n.col, r = e.row - n.row, a = i * i + s * s;
1401
+ if (a === 0)
1402
+ return Math.sqrt(l * l + r * r);
1413
1403
  const c = Math.max(
1414
1404
  0,
1415
1405
  Math.min(
1416
1406
  1,
1417
- (a * i + r * s) / l
1407
+ (l * i + r * s) / a
1418
1408
  )
1419
- ), d = n.col + c * i, u = n.row + c * s, h = t.col - d, f = t.row - u;
1409
+ ), d = n.col + c * i, u = n.row + c * s, h = e.col - d, f = e.row - u;
1420
1410
  return Math.sqrt(h * h + f * f);
1421
1411
  }
1422
- function mn(t, e, n) {
1423
- if (!n.isValid(e.row, e.col)) return !1;
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;
1412
+ function _n(e, t, n) {
1413
+ if (!n.isValid(t.row, t.col)) return !1;
1414
+ const o = e.col >= t.col - 0.5 && e.col <= t.col + 0.5, i = e.row >= t.row + 0.5, s = e.row >= t.row - 0.5;
1425
1415
  return o && i && s;
1426
1416
  }
1427
- function vt(t, e, n, o, i) {
1428
- if (!t || !e.maze) return;
1429
- const { canvasWidth: s, canvasHeight: a } = n, { cellWidth: r, cellHeight: l } = o, {
1417
+ function pt(e, t, n, o, i) {
1418
+ if (!e || !t.maze) return;
1419
+ const { canvasWidth: s, canvasHeight: l } = n, { cellWidth: r, cellHeight: a } = o, {
1430
1420
  maze: c,
1431
1421
  playerCell: d,
1432
1422
  // row, col, but floating allowed
1433
1423
  exitCell: u,
1434
1424
  foodCells: h,
1435
1425
  showClue: f,
1436
- playerPath: k,
1437
- visitCounts: p
1438
- } = e, {
1439
- padding: _,
1440
- wallWidth: b,
1426
+ playerPath: g,
1427
+ visitCounts: _
1428
+ } = t, {
1429
+ padding: v,
1430
+ wallWidth: T,
1441
1431
  // need merge with level config when passed here
1442
- wallColor: C,
1443
- playerColor: M,
1444
- playerRadius: w,
1445
- foodColor: z,
1446
- backgroundColor: S,
1447
- clueColor: E,
1448
- exitColor: L,
1449
- exitWallWidth: y,
1450
- exitDashArray: g
1432
+ wallColor: b,
1433
+ playerColor: C,
1434
+ playerRadius: p,
1435
+ foodColor: S,
1436
+ backgroundColor: w,
1437
+ clueColor: y,
1438
+ exitColor: z,
1439
+ exitWallWidth: N,
1440
+ exitDashArray: E
1451
1441
  } = i;
1452
- t.clearRect(0, 0, s, a), t.save(), t.fillStyle = S, t.fillRect(0, 0, s, a), t.restore(), f && wn({
1453
- ctx: t,
1454
- playerPath: k ?? [],
1455
- visitCounts: p ?? {},
1442
+ e.clearRect(0, 0, s, l), e.save(), e.fillStyle = w, e.fillRect(0, 0, s, l), e.restore(), f && yn({
1443
+ ctx: e,
1444
+ playerPath: g,
1445
+ visitCounts: _,
1456
1446
  cellWidth: r,
1457
- cellHeight: l,
1458
- padding: _,
1459
- clueColor: E
1460
- }), _n({
1461
- ctx: t,
1447
+ cellHeight: a,
1448
+ padding: v,
1449
+ clueColor: y
1450
+ }), vn({
1451
+ ctx: e,
1462
1452
  maze: c,
1463
1453
  cellWidth: r,
1464
- cellHeight: l,
1465
- padding: _,
1466
- wallColor: C,
1467
- wallWidth: b
1468
- }), gn({
1469
- ctx: t,
1454
+ cellHeight: a,
1455
+ padding: v,
1456
+ wallColor: b,
1457
+ wallWidth: T
1458
+ }), pn({
1459
+ ctx: e,
1470
1460
  maze: c,
1471
1461
  exitCell: u,
1472
1462
  cellWidth: r,
1473
- cellHeight: l,
1474
- padding: _,
1475
- exitColor: L,
1476
- exitWallWidth: y,
1477
- exitDashArray: g
1478
- }), pn({
1479
- ctx: t,
1463
+ cellHeight: a,
1464
+ padding: v,
1465
+ exitColor: z,
1466
+ exitWallWidth: N,
1467
+ exitDashArray: E
1468
+ }), wn({
1469
+ ctx: e,
1480
1470
  foodCells: h,
1481
1471
  cellWidth: r,
1482
- cellHeight: l,
1483
- padding: _,
1484
- foodColor: z
1485
- }), vn({
1486
- ctx: t,
1472
+ cellHeight: a,
1473
+ padding: v,
1474
+ foodColor: S
1475
+ }), gn({
1476
+ ctx: e,
1487
1477
  playerCell: d,
1488
- playerRadius: w,
1478
+ playerRadius: p,
1489
1479
  cellWidth: r,
1490
- cellHeight: l,
1491
- padding: _,
1492
- playerColor: M
1480
+ cellHeight: a,
1481
+ padding: v,
1482
+ playerColor: C
1493
1483
  });
1494
1484
  }
1495
- function _n({
1496
- ctx: t,
1497
- maze: e,
1485
+ function vn({
1486
+ ctx: e,
1487
+ maze: t,
1498
1488
  cellWidth: n,
1499
1489
  cellHeight: o,
1500
1490
  padding: i,
1501
1491
  wallColor: s,
1502
- wallWidth: a
1492
+ wallWidth: l
1503
1493
  }) {
1504
- t.save(), t.strokeStyle = s, t.lineWidth = a, t.lineCap = "round", t.beginPath(), yn(e, n, o, i).forEach((l) => {
1505
- t.moveTo(l.x1, l.y1), t.lineTo(l.x2, l.y2);
1506
- }), t.stroke(), t.restore();
1494
+ e.save(), e.strokeStyle = s, e.lineWidth = l, e.lineCap = "round", e.beginPath(), bn(t, n, o, i).forEach((a) => {
1495
+ e.moveTo(a.x1, a.y1), e.lineTo(a.x2, a.y2);
1496
+ }), e.stroke(), e.restore();
1507
1497
  }
1508
- function vn({
1509
- ctx: t,
1510
- playerCell: e,
1498
+ function gn({
1499
+ ctx: e,
1500
+ playerCell: t,
1511
1501
  playerRadius: n,
1512
1502
  cellWidth: o,
1513
1503
  cellHeight: i,
1514
1504
  padding: s,
1515
- playerColor: a
1505
+ playerColor: l
1516
1506
  }) {
1517
- const { x: r, y: l } = he(
1518
- e.row,
1519
- e.col,
1507
+ const { x: r, y: a } = ve(
1508
+ t.row,
1509
+ t.col,
1520
1510
  o,
1521
1511
  i,
1522
1512
  s
1523
1513
  ), c = Math.min(o, i) * Math.min(n, 0.5);
1524
- t.save(), t.fillStyle = a, t.beginPath(), t.arc(r, l, c, 0, Math.PI * 2), t.fill(), t.restore();
1514
+ e.save(), e.fillStyle = l, e.beginPath(), e.arc(r, a, c, 0, Math.PI * 2), e.fill(), e.restore();
1525
1515
  }
1526
- function gn({
1527
- ctx: t,
1528
- maze: e,
1516
+ function pn({
1517
+ ctx: e,
1518
+ maze: t,
1529
1519
  exitCell: n,
1530
1520
  cellWidth: o,
1531
1521
  cellHeight: i,
1532
1522
  padding: s,
1533
- exitColor: a,
1523
+ exitColor: l,
1534
1524
  exitWallWidth: r,
1535
- exitDashArray: l = [8, 12]
1525
+ exitDashArray: a = [8, 12]
1536
1526
  }) {
1537
1527
  const { row: c, col: d } = n;
1538
- if (!e.isValid(c, d)) return;
1528
+ if (!t.isValid(c, d)) return;
1539
1529
  const u = s + d * o, h = s + c * i;
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();
1530
+ e.save(), e.globalCompositeOperation = "destination-out", e.lineWidth = r, e.lineCap = "round", e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.globalCompositeOperation = "source-over", e.strokeStyle = l, e.lineWidth = r, e.setLineDash(a), e.beginPath(), e.moveTo(u, h + i), e.lineTo(u + o, h + i), e.stroke(), e.restore();
1541
1531
  }
1542
- function pn({
1543
- ctx: t,
1544
- foodCells: e,
1532
+ function wn({
1533
+ ctx: e,
1534
+ foodCells: t,
1545
1535
  cellWidth: n,
1546
1536
  cellHeight: o,
1547
1537
  padding: i,
1548
1538
  foodColor: s
1549
1539
  }) {
1550
- t.fillStyle = s;
1551
- const a = Math.min(n, o) * 0.25;
1552
- e.forEach((r) => {
1553
- const { x: l, y: c } = he(
1540
+ e.fillStyle = s;
1541
+ const l = Math.min(n, o) * 0.25;
1542
+ t.forEach((r) => {
1543
+ const { x: a, y: c } = ve(
1554
1544
  r.row,
1555
1545
  r.col,
1556
1546
  n,
1557
1547
  o,
1558
1548
  i
1559
1549
  );
1560
- Cn(t, l, c, a * 1.2, 5, a * 0.6);
1550
+ Cn(e, a, c, l * 1.2, 5, l * 0.6);
1561
1551
  });
1562
1552
  }
1563
- function Cn(t, e, n, o, i, s) {
1564
- t.save(), t.beginPath();
1565
- for (let a = 0; a < i * 2; a++) {
1566
- const r = a % 2 === 0 ? o : s, l = Math.PI * a / i;
1567
- t.lineTo(e + r * Math.sin(l), n + r * Math.cos(l));
1553
+ function Cn(e, t, n, o, i, s) {
1554
+ e.save(), e.beginPath();
1555
+ for (let l = 0; l < i * 2; l++) {
1556
+ const r = l % 2 === 0 ? o : s, a = Math.PI * l / i;
1557
+ e.lineTo(t + r * Math.sin(a), n + r * Math.cos(a));
1568
1558
  }
1569
- t.closePath(), t.fill(), t.restore();
1559
+ e.closePath(), e.fill(), e.restore();
1570
1560
  }
1571
- function wn({
1572
- ctx: t,
1573
- playerPath: e,
1561
+ function yn({
1562
+ ctx: e,
1563
+ playerPath: t,
1574
1564
  visitCounts: n,
1575
1565
  cellWidth: o,
1576
1566
  cellHeight: i,
1577
1567
  padding: s,
1578
- clueColor: a
1568
+ clueColor: l
1579
1569
  }) {
1580
- if (!(!e || e.length < 2 || !n)) {
1581
- t.save();
1582
- for (let r = 1; r < e.length; r++) {
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;
1570
+ if (!(!t || t.length < 2 || !n)) {
1571
+ e.save();
1572
+ for (let r = 1; r < t.length; r++) {
1573
+ const a = t[r - 1], c = t[r], d = `${a.row},${a.col}-${c.row},${c.col}`, u = `${c.row},${c.col}-${a.row},${a.col}`, h = (n[d] || 0) + (n[u] || 0), f = Math.min(0.2 + h * 0.1, 0.9), g = Math.max(3, o * 0.1) + h * 0.5;
1584
1574
  try {
1585
- t.strokeStyle = a.replace(")", `, ${f})`).replace("rgb(", "rgba(");
1575
+ e.strokeStyle = l.replace(")", `, ${f})`).replace("rgb(", "rgba(");
1586
1576
  } catch {
1587
- t.strokeStyle = `rgba(255, 0, 0, ${f})`;
1577
+ e.strokeStyle = `rgba(255, 0, 0, ${f})`;
1588
1578
  }
1589
- t.lineWidth = k, t.lineCap = "round", t.lineJoin = "round";
1590
- const { x: p, y: _ } = he(
1591
- l.row,
1592
- l.col,
1579
+ e.lineWidth = g, e.lineCap = "round", e.lineJoin = "round";
1580
+ const { x: _, y: v } = ve(
1581
+ a.row,
1582
+ a.col,
1593
1583
  o,
1594
1584
  i,
1595
1585
  s
1596
- ), { x: b, y: C } = he(
1586
+ ), { x: T, y: b } = ve(
1597
1587
  c.row,
1598
1588
  c.col,
1599
1589
  o,
1600
1590
  i,
1601
1591
  s
1602
1592
  );
1603
- t.beginPath(), t.moveTo(p, _), t.lineTo(b, C), t.stroke();
1593
+ e.beginPath(), e.moveTo(_, v), e.lineTo(T, b), e.stroke();
1604
1594
  }
1605
- t.restore();
1595
+ e.restore();
1606
1596
  }
1607
1597
  }
1608
- function yn(t, e, n, o) {
1598
+ function bn(e, t, n, o) {
1609
1599
  const i = [];
1610
- for (let s = 0; s < t.rows; s++)
1611
- for (let a = 0; a < t.cols; a++) {
1612
- const r = t.grid[s][a], l = o + a * e, c = o + s * n;
1600
+ for (let s = 0; s < e.rows; s++)
1601
+ for (let l = 0; l < e.cols; l++) {
1602
+ const r = e.grid[s][l], a = o + l * t, c = o + s * n;
1613
1603
  r.walls.top && i.push({
1614
- x1: l,
1604
+ x1: a,
1615
1605
  y1: c,
1616
- x2: l + e,
1606
+ x2: a + t,
1617
1607
  y2: c
1618
1608
  }), r.walls.right && i.push({
1619
- x1: l + e,
1609
+ x1: a + t,
1620
1610
  y1: c,
1621
- x2: l + e,
1611
+ x2: a + t,
1622
1612
  y2: c + n
1623
1613
  }), r.walls.bottom && i.push({
1624
- x1: l,
1614
+ x1: a,
1625
1615
  y1: c + n,
1626
- x2: l + e,
1616
+ x2: a + t,
1627
1617
  y2: c + n
1628
1618
  }), r.walls.left && i.push({
1629
- x1: l,
1619
+ x1: a,
1630
1620
  y1: c,
1631
- x2: l,
1621
+ x2: a,
1632
1622
  y2: c + n
1633
1623
  });
1634
1624
  }
1635
1625
  return i;
1636
1626
  }
1637
- function he(t, e, n, o, i) {
1627
+ function ve(e, t, n, o, i) {
1638
1628
  return {
1639
- x: i + e * n + n / 2,
1640
- y: i + t * o + o / 2
1629
+ x: i + t * n + n / 2,
1630
+ y: i + e * o + o / 2
1641
1631
  };
1642
1632
  }
1643
- function bn(t) {
1633
+ function Tn(e) {
1644
1634
  return function() {
1645
- let e = t += 1831565813;
1646
- return e = Math.imul(e ^ e >>> 15, e | 1), e ^= e + Math.imul(e ^ e >>> 7, e | 61), ((e ^ e >>> 14) >>> 0) / 4294967296;
1635
+ let t = e += 1831565813;
1636
+ return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
1647
1637
  };
1648
1638
  }
1649
- class Tn {
1639
+ class kn {
1650
1640
  // initially all walls exit
1651
- constructor(e, n) {
1652
- this.row = e, this.col = n;
1641
+ constructor(t, n) {
1642
+ this.row = t, this.col = n;
1653
1643
  }
1654
1644
  visited = !1;
1655
1645
  walls = { top: !0, right: !0, bottom: !0, left: !0 };
1656
1646
  }
1657
- class gt {
1647
+ class wt {
1658
1648
  rows;
1659
1649
  cols;
1660
1650
  grid;
@@ -1670,25 +1660,25 @@ class gt {
1670
1660
  * @param entry Optional entry cell position
1671
1661
  * @param exit Optional exit cell position
1672
1662
  */
1673
- constructor(e, n, o, i, s = { row: 0, col: 0 }, a = { row: e - 1, col: n - 1 }) {
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);
1663
+ constructor(t, n, o, i, s = { row: 0, col: 0 }, l = { row: t - 1, col: n - 1 }) {
1664
+ this.rows = t, this.cols = n, this.seed = i ?? Math.floor(Math.random() * 1e6), this.random = Tn(this.seed), this.grid = this.initializeGrid(), this.generate(o, s, l);
1675
1665
  }
1676
1666
  // Initialize the grid with new MazeCell objects
1677
1667
  initializeGrid() {
1678
- const e = [];
1668
+ const t = [];
1679
1669
  for (let n = 0; n < this.rows; n++) {
1680
- e[n] = [];
1670
+ t[n] = [];
1681
1671
  for (let o = 0; o < this.cols; o++)
1682
- e[n][o] = new Tn(n, o);
1672
+ t[n][o] = new kn(n, o);
1683
1673
  }
1684
- return e;
1674
+ return t;
1685
1675
  }
1686
1676
  // Check if coordinates are within the grid boundaries
1687
- isValid(e, n) {
1688
- return e >= 0 && e < this.rows && n >= 0 && n < this.cols;
1677
+ isValid(t, n) {
1678
+ return t >= 0 && t < this.rows && n >= 0 && n < this.cols;
1689
1679
  }
1690
1680
  // Get all valid neighbors (top, right, bottom, left)
1691
- getNeighbors(e, n) {
1681
+ getNeighbors(t, n) {
1692
1682
  const o = [], i = [
1693
1683
  { r: -1, c: 0 },
1694
1684
  // Top
@@ -1700,29 +1690,29 @@ class gt {
1700
1690
  // Left
1701
1691
  ];
1702
1692
  for (const s of i) {
1703
- const a = e + s.r, r = n + s.c;
1704
- this.isValid(a, r) && o.push({ row: a, col: r });
1693
+ const l = t + s.r, r = n + s.c;
1694
+ this.isValid(l, r) && o.push({ row: l, col: r });
1705
1695
  }
1706
1696
  return o;
1707
1697
  }
1708
1698
  // Get only neighbors that haven't been visited yet
1709
- getUnvisitedNeighbors(e, n) {
1710
- return this.getNeighbors(e, n).filter(
1699
+ getUnvisitedNeighbors(t, n) {
1700
+ return this.getNeighbors(t, n).filter(
1711
1701
  (o) => !this.grid[o.row][o.col].visited
1712
1702
  );
1713
1703
  }
1714
1704
  /**
1715
1705
  * Gets neighbors that have already been visited (part of the maze path).
1716
1706
  */
1717
- getVisitedNeighbors(e, n) {
1718
- return this.getNeighbors(e, n).filter(
1707
+ getVisitedNeighbors(t, n) {
1708
+ return this.getNeighbors(t, n).filter(
1719
1709
  (o) => this.grid[o.row][o.col].visited
1720
1710
  );
1721
1711
  }
1722
1712
  // Remove the wall between two adjacent cells
1723
- removeWall(e, n, o, i) {
1724
- const s = this.grid[e][n], a = this.grid[o][i];
1725
- e === o + 1 ? (s.walls.top = !1, a.walls.bottom = !1) : e === o - 1 ? (s.walls.bottom = !1, a.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, a.walls.right = !1) : n === i - 1 && (s.walls.right = !1, a.walls.left = !1);
1713
+ removeWall(t, n, o, i) {
1714
+ const s = this.grid[t][n], l = this.grid[o][i];
1715
+ t === o + 1 ? (s.walls.top = !1, l.walls.bottom = !1) : t === o - 1 ? (s.walls.bottom = !1, l.walls.top = !1) : n === i + 1 ? (s.walls.left = !1, l.walls.right = !1) : n === i - 1 && (s.walls.right = !1, l.walls.left = !1);
1726
1716
  }
1727
1717
  // --- Generation Methods ---
1728
1718
  /**
@@ -1732,8 +1722,8 @@ class gt {
1732
1722
  * @param entry The entry cell position
1733
1723
  * @param exit The exit cell position
1734
1724
  */
1735
- generate(e, n = { row: 0, col: 0 }, o = { row: this.rows - 1, col: this.cols - 1 }) {
1736
- switch (e) {
1725
+ generate(t, n = { row: 0, col: 0 }, o = { row: this.rows - 1, col: this.cols - 1 }) {
1726
+ switch (t) {
1737
1727
  case "backtracking":
1738
1728
  this.generateWithBacktracking();
1739
1729
  break;
@@ -1741,82 +1731,82 @@ class gt {
1741
1731
  this.generateWithPrims();
1742
1732
  break;
1743
1733
  default:
1744
- throw new Error(`Unknown maze generation method: ${e}`);
1734
+ throw new Error(`Unknown maze generation method: ${t}`);
1745
1735
  }
1746
1736
  this.addOpenings(n, o);
1747
1737
  }
1748
1738
  // --- Backtracking Algorithm Implementation ---
1749
1739
  generateWithBacktracking() {
1750
- const e = [], n = this.randomNumber(this.rows), o = this.randomNumber(this.cols);
1740
+ const t = [], n = this.randomNumber(this.rows), o = this.randomNumber(this.cols);
1751
1741
  let i = { row: n, col: o };
1752
- for (this.grid[n][o].visited = !0, e.push(i); e.length > 0; ) {
1753
- i = e[e.length - 1];
1754
- const { row: s, col: a } = i, r = this.getUnvisitedNeighbors(s, a);
1742
+ for (this.grid[n][o].visited = !0, t.push(i); t.length > 0; ) {
1743
+ i = t[t.length - 1];
1744
+ const { row: s, col: l } = i, r = this.getUnvisitedNeighbors(s, l);
1755
1745
  if (r.length > 0) {
1756
- const l = this.randomPick(r), { row: c, col: d } = l;
1757
- this.removeWall(s, a, c, d), this.grid[c][d].visited = !0, e.push(l);
1746
+ const a = this.randomPick(r), { row: c, col: d } = a;
1747
+ this.removeWall(s, l, c, d), this.grid[c][d].visited = !0, t.push(a);
1758
1748
  } else
1759
- e.pop();
1749
+ t.pop();
1760
1750
  }
1761
1751
  }
1762
1752
  // --- Prim's Algorithm Implementation ---
1763
1753
  generateWithPrims() {
1764
- const e = [], n = (s, a) => {
1765
- const r = this.getNeighbors(s, a);
1766
- for (const l of r)
1767
- !this.grid[l.row][l.col].visited && !e.some(
1768
- (c) => c.row === l.row && c.col === l.col
1769
- ) && e.push(l);
1754
+ const t = [], n = (s, l) => {
1755
+ const r = this.getNeighbors(s, l);
1756
+ for (const a of r)
1757
+ !this.grid[a.row][a.col].visited && !t.some(
1758
+ (c) => c.row === a.row && c.col === a.col
1759
+ ) && t.push(a);
1770
1760
  }, o = this.randomNumber(this.rows), i = this.randomNumber(this.cols);
1771
- for (this.grid[o][i].visited = !0, n(o, i); e.length > 0; ) {
1772
- const s = this.randomNumber(e.length), a = e[s], { row: r, col: l } = a, c = this.getVisitedNeighbors(r, l);
1761
+ for (this.grid[o][i].visited = !0, n(o, i); t.length > 0; ) {
1762
+ const s = this.randomNumber(t.length), l = t[s], { row: r, col: a } = l, c = this.getVisitedNeighbors(r, a);
1773
1763
  if (c.length > 0) {
1774
1764
  const d = this.randomPick(c);
1775
- this.removeWall(r, l, d.row, d.col), this.grid[r][l].visited = !0, n(r, l);
1765
+ this.removeWall(r, a, d.row, d.col), this.grid[r][a].visited = !0, n(r, a);
1776
1766
  }
1777
- e.splice(s, 1);
1767
+ t.splice(s, 1);
1778
1768
  }
1779
1769
  }
1780
1770
  // --- Helper Methods ---
1781
1771
  /**
1782
1772
  * Adds openings at the entry and exit points of the maze.
1783
1773
  */
1784
- addOpenings(e, n) {
1785
- this.grid[e.row][e.col].walls.top = !1, this.isValid(n.row, n.col) && (this.grid[n.row][n.col].walls.bottom = !1);
1774
+ addOpenings(t, n) {
1775
+ this.grid[t.row][t.col].walls.top = !1, this.isValid(n.row, n.col) && (this.grid[n.row][n.col].walls.bottom = !1);
1786
1776
  }
1787
1777
  /**
1788
1778
  * Generates a random number between 0 and len-1.
1789
1779
  */
1790
- randomNumber(e) {
1791
- return Math.floor(this.random() * e);
1780
+ randomNumber(t) {
1781
+ return Math.floor(this.random() * t);
1792
1782
  }
1793
1783
  /**
1794
1784
  * Randomly picks an item from a list.
1795
1785
  */
1796
- randomPick(e) {
1797
- return e[Math.floor(this.random() * e.length)];
1786
+ randomPick(t) {
1787
+ return t[Math.floor(this.random() * t.length)];
1798
1788
  }
1799
1789
  }
1800
- const pt = (t, e, n) => {
1801
- if (!t.isValid(e, n)) return !1;
1802
- const o = t.grid[e][n];
1790
+ const Ct = (e, t, n) => {
1791
+ if (!e.isValid(t, n)) return !1;
1792
+ const o = e.grid[t][n];
1803
1793
  return !o.walls.top || !o.walls.right || !o.walls.bottom || !o.walls.left;
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) => {
1805
- if (!e)
1806
- return console.error(`Cannot find Level ${t}'s config.`), null;
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 || {
1794
+ }, Sn = (e) => e === 1 ? 2 : e >= 2 && e <= 5 ? 3 : e >= 6 && e <= 11 ? 4 : e >= 12 && e <= 15 ? 5 : 6, zn = (e, t) => {
1795
+ if (!t)
1796
+ return console.error(`Cannot find Level ${e}'s config.`), null;
1797
+ const { size: n, seed: o, method: i, entry: s, exit: l } = t, r = n, a = n, c = s || { row: 0, col: 0 }, d = l || {
1808
1798
  row: r - 1,
1809
- col: l - 1
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;
1799
+ col: a - 1
1800
+ }, u = new wt(r, a, i, o, c, d), h = Sn(e), f = [];
1801
+ for (let g = 0; g < h; g++) {
1802
+ let _;
1813
1803
  do
1814
- p = {
1804
+ _ = {
1815
1805
  row: Math.floor(u.random() * r),
1816
- col: Math.floor(u.random() * l)
1806
+ col: Math.floor(u.random() * a)
1817
1807
  };
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);
1808
+ while (_.row === c.row && _.col === c.col || _.row === d.row && _.col === d.col || !Ct(u, _.row, _.col) || f.some((v) => v.row === _.row && v.col === _.col));
1809
+ f.push(_);
1820
1810
  }
1821
1811
  return {
1822
1812
  isGameActive: !0,
@@ -1832,282 +1822,305 @@ const pt = (t, e, n) => {
1832
1822
  playerPath: [c],
1833
1823
  visitCounts: { [`${c.row},${c.col}`]: 1 }
1834
1824
  };
1835
- }, zn = ({
1836
- size: t,
1837
- seed: e,
1825
+ }, En = ({
1826
+ size: e,
1827
+ seed: t,
1838
1828
  method: n,
1839
- foodCount: o
1829
+ foodCount: o,
1830
+ foodRace: i,
1831
+ clue: s
1840
1832
  }) => {
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
- }
1833
+ const l = e, r = e, a = { row: 0, col: 0 }, c = { row: l - 1, col: r - 1 }, d = new wt(l, r, n, t, a, c), u = [];
1834
+ if (i)
1835
+ for (let h = 0; h < o; h++) {
1836
+ let f, g = 0;
1837
+ do
1838
+ f = {
1839
+ row: Math.floor(d.random() * l),
1840
+ col: Math.floor(d.random() * r)
1841
+ }, g++;
1842
+ while (g < 50 && (f.row === a.row && f.col === a.col || f.row === c.row && f.col === c.col || !Ct(d, f.row, f.col) || u.some(
1843
+ (_) => _.row === f.row && _.col === f.col
1844
+ )));
1845
+ g < 50 && u.push(f);
1846
+ }
1854
1847
  return {
1855
1848
  isGameActive: !0,
1856
1849
  levelTransitioning: !1,
1857
- maze: l,
1850
+ maze: d,
1858
1851
  playerCell: a,
1859
- exitCell: r,
1860
- foodCells: c,
1852
+ exitCell: c,
1853
+ foodCells: u,
1861
1854
  playerAtExit: !1,
1862
1855
  foodCollected: 0,
1863
- totalFoodCount: o
1856
+ totalFoodCount: i ? o : 0,
1857
+ showClue: s,
1858
+ playerPath: [a],
1859
+ visitCounts: { [`${a.row},${a.col}`]: 1 }
1864
1860
  };
1865
1861
  };
1866
- function En() {
1862
+ function Ln() {
1867
1863
  const {
1868
- setGamePlayState: t,
1869
- gamePlayState: e,
1864
+ setGamePlayState: e,
1865
+ gamePlayState: t,
1870
1866
  gamePlayStateRef: n,
1871
1867
  gameProgress: o,
1872
1868
  config: i
1873
- } = ne(), s = O(null), a = O(null), { i18n: r, levelConfig: l, renderConfig: c } = i, d = oe(l), u = O(
1869
+ } = re(), s = R(null), l = R(null), { i18n: r, levelConfig: a, renderConfig: c } = i, d = ie(a), u = R(
1874
1870
  d.getLevelConfig(o.currentLevel)
1875
1871
  );
1876
- R(() => {
1877
- s.current && j.attachTo(s.current);
1872
+ I(() => {
1873
+ s.current && q.attachTo(s.current);
1878
1874
  }, []);
1879
- const h = O(), f = ft(a, () => {
1875
+ const h = R(), f = _t(l, () => {
1880
1876
  h.current?.();
1881
- }), k = mt(
1882
- a,
1883
- e,
1877
+ }), g = vt(
1878
+ l,
1879
+ t,
1884
1880
  c.padding
1885
1881
  );
1886
- R(() => {
1882
+ I(() => {
1887
1883
  u.current = d.getLevelConfig(
1888
1884
  o.currentLevel
1889
1885
  );
1890
1886
  }, [o.currentLevel]);
1891
- const p = () => {
1892
- const M = Sn(
1887
+ const _ = () => {
1888
+ const C = zn(
1893
1889
  o.currentLevel,
1894
1890
  u.current
1895
1891
  );
1896
- M && t((w) => ({
1897
- ...w,
1898
- ...M
1892
+ C && e((p) => ({
1893
+ ...p,
1894
+ ...C
1899
1895
  }));
1900
1896
  };
1901
- R(() => {
1902
- p();
1897
+ I(() => {
1898
+ _();
1903
1899
  }, [o.currentLevel]);
1904
- const _ = () => {
1905
- p();
1906
- }, { updatePlayerPos: b, resetMovingState: C } = _t({
1907
- containerRef: s,
1900
+ const v = () => {
1901
+ _();
1902
+ }, { updatePlayerPos: T, resetMovingState: b } = gt({
1908
1903
  gamePlayStateRef: n,
1909
- setGamePlayState: t,
1904
+ setGamePlayState: e,
1910
1905
  playerRadius: c.playerRadius,
1911
1906
  moveSpeed: c.gridMoveSpeed,
1912
1907
  onFoodCollected: () => {
1913
- const M = n.current.totalFoodCount - n.current.foodCollected - 1;
1914
- M > 0 ? j.show(
1915
- r.foodCollectedToast.replace("%NUM%", M.toString()),
1908
+ const C = n.current.totalFoodCount - n.current.foodCollected - 1;
1909
+ C > 0 ? q.show(
1910
+ r.foodCollectedToast.replace("%NUM%", C.toString()),
1916
1911
  3e3
1917
- ) : j.show(r.allFoodCollectedToast);
1912
+ ) : q.show(r.allFoodCollectedToast);
1918
1913
  }
1919
1914
  });
1920
- return R(() => {
1921
- C();
1922
- }, [o.currentLevel, C]), R(() => {
1923
- let M, w = !document.hidden;
1924
- const z = () => {
1925
- const L = a.current?.getContext("2d"), y = n.current;
1926
- if (!(w && y?.isGameActive && L && y?.maze)) {
1927
- M = requestAnimationFrame(z);
1915
+ return I(() => {
1916
+ b();
1917
+ }, [o.currentLevel, b]), I(() => {
1918
+ let C, p = !document.hidden;
1919
+ const S = () => {
1920
+ const z = l.current?.getContext("2d"), N = n.current;
1921
+ if (!(p && N?.isGameActive && z && N?.maze)) {
1922
+ C = requestAnimationFrame(S);
1928
1923
  return;
1929
1924
  }
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, {
1925
+ T(), w(), C = requestAnimationFrame(S);
1926
+ }, w = () => {
1927
+ const z = l.current?.getContext("2d"), N = n.current;
1928
+ if (z && N?.maze) {
1929
+ const E = u.current?.wallWidth || c?.wallWidth, k = u.current?.exitColor || c?.exitColor, L = u.current?.exitWallWidth || c?.exitWallWidth, A = u.current?.exitDashArray || c?.exitDashArray;
1930
+ pt(z, N, f.current, g.current, {
1936
1931
  ...c,
1937
- wallWidth: g,
1938
- exitColor: v,
1939
- exitWallWidth: T,
1940
- exitDashArray: N
1932
+ wallWidth: E,
1933
+ exitColor: k,
1934
+ exitWallWidth: L,
1935
+ exitDashArray: A
1941
1936
  });
1942
1937
  }
1943
1938
  };
1944
- h.current = S;
1945
- const E = (L) => {
1946
- const y = w;
1947
- w = !document.hidden && document.visibilityState === "visible" && (!L || L.type !== "blur"), !y && w ? n.current?.levelTransitioning === !1 && t({
1939
+ h.current = w;
1940
+ const y = (z) => {
1941
+ const N = p;
1942
+ p = !document.hidden && document.visibilityState === "visible" && (!z || z.type !== "blur"), !N && p ? n.current?.levelTransitioning === !1 && e({
1948
1943
  ...n.current,
1949
1944
  isGameActive: !0
1950
- }) : y && !w && t({
1945
+ }) : N && !p && e({
1951
1946
  ...n.current,
1952
1947
  isGameActive: !1
1953
1948
  });
1954
1949
  };
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);
1950
+ return document.addEventListener("visibilitychange", y), window.addEventListener("blur", y), window.addEventListener("focus", y), C = requestAnimationFrame(S), () => {
1951
+ cancelAnimationFrame(C), document.removeEventListener("visibilitychange", y), window.removeEventListener("blur", y), window.removeEventListener("focus", y);
1957
1952
  };
1958
- }, []), R(() => {
1959
- j.show(r.useArrowKeyTips, 3e3);
1953
+ }, []), I(() => {
1954
+ q.show(r.useArrowKeyTips, 3e3);
1960
1955
  }, []), /* @__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" })
1969
- ] })
1956
+ /* @__PURE__ */ m($t, {}),
1957
+ /* @__PURE__ */ m(hn, { onRetry: v }),
1958
+ /* @__PURE__ */ m("div", { className: "maze-canvas-container", ref: s, children: /* @__PURE__ */ m("canvas", { ref: l, className: "maze-game-canvas" }) })
1970
1959
  ] });
1971
1960
  }
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);
1961
+ const Nn = (e) => {
1962
+ const t = Math.floor(e / 60), n = e % 60;
1963
+ return `${t.toString().padStart(2, "0")}:${n.toString().padStart(2, "0")}`;
1964
+ }, Mn = ({ timer: e }) => {
1965
+ const [t, n] = W(e), o = R(), i = R(!1), s = R(0);
1966
+ return I(() => {
1967
+ const l = () => {
1968
+ !i.current && !o.current && (i.current = !0, o.current = setInterval(() => {
1969
+ n((a) => (s.current = e - a + 1, a <= 1 ? (clearInterval(o.current), window.dispatchEvent(new CustomEvent("maze:timeUp")), 0) : a - 1));
1984
1970
  }, 1e3));
1985
1971
  }, r = () => {
1986
- clearInterval(i.current), i.current = void 0;
1972
+ clearInterval(o.current), o.current = void 0, window.dispatchEvent(
1973
+ new CustomEvent("maze:timeUsed", {
1974
+ detail: { timeUsed: s.current }
1975
+ })
1976
+ );
1987
1977
  };
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);
1978
+ return window.addEventListener("maze:firstMove", l), window.addEventListener("maze:gameSuccess", r), () => {
1979
+ window.removeEventListener("maze:firstMove", l), window.removeEventListener("maze:gameSuccess", r), clearInterval(o.current);
1990
1980
  };
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(
1981
+ }, [e]), I(() => {
1982
+ o.current && (clearInterval(o.current), o.current = void 0), n(e), i.current = !1, s.current = 0;
1983
+ }, [e]), /* @__PURE__ */ m("div", { className: "single-maze-timer", children: /* @__PURE__ */ m(
1994
1984
  "span",
1995
1985
  {
1996
- className: `maze-timer-text ${n <= 10 && s.current ? "maze-timer-warning" : ""}`,
1986
+ className: `maze-timer-text ${t <= 10 && i.current ? "maze-timer-warning" : ""}`,
1997
1987
  children: [
1998
1988
  "⏱️ ",
1999
- Ln(n)
1989
+ Nn(t)
2000
1990
  ]
2001
1991
  }
2002
1992
  ) });
2003
1993
  };
2004
- function Mn({ config: t }) {
1994
+ function An({ config: e }) {
2005
1995
  const {
2006
- size: e,
1996
+ size: t,
2007
1997
  seed: n,
2008
1998
  method: o,
2009
1999
  foodCount: i,
2010
- renderConfig: s,
2000
+ foodRace: s,
2001
+ clue: l,
2002
+ renderConfig: r,
2011
2003
  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), [C, M] = U(""), w = O(null), z = O(null), S = O(d), E = O(), L = ft(w, () => {
2018
- E.current?.();
2019
- }), y = mt(w, 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,
2004
+ failCallback: c,
2005
+ timer: d,
2006
+ i18n: u
2007
+ } = e, [h, f] = W({
2008
+ ...Ee
2009
+ }), [g, _] = W(!1), [v, T] = W(!0), [b, C] = W(!1), [p, S] = W(""), w = R(0), y = R(!1), z = R(!1), N = R(null), E = R(null), k = R(h), L = R(), A = _t(N, () => {
2010
+ L.current?.();
2011
+ }), x = vt(N, h, r.padding);
2012
+ I(() => {
2013
+ k.current = h;
2014
+ }, [h]);
2015
+ const { updatePlayerPos: O, resetMovingState: $, resetFirstMoveState: U } = gt({
2016
+ gamePlayStateRef: k,
2017
+ setGamePlayState: f,
2018
+ playerRadius: r.playerRadius,
2019
+ moveSpeed: r.gridMoveSpeed,
2029
2020
  onFoodCollected: () => {
2030
2021
  console.log("Food collected in single maze");
2031
2022
  },
2032
2023
  onExitReached: () => {
2033
- k || P();
2024
+ if (!y.current) {
2025
+ if (s && k.current.foodCollected < k.current.totalFoodCount) {
2026
+ S(`⭐️ ${u.foodMsg}`), C(!0), requestAnimationFrame(() => {
2027
+ f((D) => ({
2028
+ ...D,
2029
+ playerAtExit: !1,
2030
+ isGameActive: !0,
2031
+ levelTransitioning: !1
2032
+ }));
2033
+ });
2034
+ return;
2035
+ }
2036
+ B();
2037
+ }
2034
2038
  },
2035
2039
  onFirstMove: () => {
2036
2040
  window.dispatchEvent(new CustomEvent("maze:firstMove"));
2037
2041
  }
2038
- }), N = () => {
2039
- p(!0), M(`⏰ ${c.failMsg}`), b(!0), u((I) => ({
2040
- ...I,
2042
+ }), V = () => {
2043
+ y.current = !0, S(`⏰ ${u.failMsg}`), C(!0), f({
2044
+ ...k.current,
2041
2045
  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);
2046
+ });
2047
+ }, B = () => {
2048
+ y.current = !0, z.current = !0, S(`🎉 ${u.successMsg}`), C(!0), window.dispatchEvent(new CustomEvent("maze:gameSuccess"));
2049
+ }, Y = () => {
2050
+ C(!1), y.current && (T(!1), f((D) => ({
2051
+ ...D,
2052
+ showClue: !0
2053
+ })), z.current ? a?.(w.current) : c?.());
2047
2054
  };
2048
- return R(() => {
2055
+ return I(() => {
2049
2056
  (async () => {
2050
- f(!0);
2057
+ _(!0);
2051
2058
  try {
2052
- const $ = zn({
2053
- size: e,
2059
+ const G = En({
2060
+ size: t,
2054
2061
  seed: n,
2055
2062
  method: o,
2056
- foodCount: i
2063
+ foodCount: i,
2064
+ foodRace: s,
2065
+ clue: l
2057
2066
  });
2058
- S.current = $, u($);
2059
- } catch ($) {
2060
- console.error("Error generating single maze:", $);
2067
+ k.current = G, f(G);
2068
+ } catch (G) {
2069
+ console.error("Error generating single maze:", G);
2061
2070
  } finally {
2062
- f(!1);
2071
+ _(!1);
2063
2072
  }
2064
2073
  })();
2065
- }, [t]), R(() => {
2066
- let I;
2067
- const $ = !document.hidden, B = () => {
2068
- const G = w.current?.getContext("2d"), q = S.current;
2069
- if (!($ && q?.isGameActive && G && q?.maze)) {
2070
- I = requestAnimationFrame(B);
2074
+ }, [e]), I(() => {
2075
+ let D;
2076
+ const G = !document.hidden, K = () => {
2077
+ const le = N.current?.getContext("2d"), ee = k.current;
2078
+ if (!(G && ee?.isGameActive && le && ee?.maze)) {
2079
+ D = requestAnimationFrame(K);
2071
2080
  return;
2072
2081
  }
2073
- g(), V(), I = requestAnimationFrame(B);
2074
- }, V = () => {
2075
- const G = w.current?.getContext("2d"), q = S.current;
2076
- G && q?.maze && vt(
2077
- G,
2078
- q,
2079
- L.current,
2080
- y.current,
2081
- s
2082
+ O(), se(), D = requestAnimationFrame(K);
2083
+ }, se = () => {
2084
+ const le = N.current?.getContext("2d"), ee = k.current;
2085
+ le && ee?.maze && pt(
2086
+ le,
2087
+ ee,
2088
+ A.current,
2089
+ x.current,
2090
+ r
2082
2091
  );
2083
2092
  };
2084
- return E.current = V, I = requestAnimationFrame(B), () => {
2085
- cancelAnimationFrame(I);
2093
+ return L.current = se, D = requestAnimationFrame(K), () => {
2094
+ cancelAnimationFrame(D);
2086
2095
  };
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: w, 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
- ] }),
2096
+ }, []), I(() => {
2097
+ $(), U();
2098
+ }, [e, $, U]), I(() => {
2099
+ const D = (G) => {
2100
+ w.current = G.detail.timeUsed;
2101
+ };
2102
+ return window.addEventListener("maze:timeUsed", D), window.addEventListener("maze:timeUp", V), () => {
2103
+ window.removeEventListener(
2104
+ "maze:timeUsed",
2105
+ D
2106
+ ), window.removeEventListener("maze:timeUp", V);
2107
+ };
2108
+ }, []), g ? /* @__PURE__ */ m("div", { className: "single-maze-loading", children: /* @__PURE__ */ m("div", { children: "Generating maze..." }) }) : h ? /* @__PURE__ */ m("div", { className: "maze-game-container", children: [
2109
+ v && /* @__PURE__ */ m(Mn, { timer: d }),
2110
+ /* @__PURE__ */ m("div", { className: "single-maze-canvas-container", ref: E, children: /* @__PURE__ */ m("canvas", { ref: N, className: "maze-game-canvas" }) }),
2098
2111
  /* @__PURE__ */ m(
2099
- Q,
2112
+ te,
2100
2113
  {
2101
- isOpen: _,
2102
- title: C,
2114
+ isOpen: b,
2115
+ title: p,
2103
2116
  noConfirm: !0,
2104
2117
  cancelText: "OK",
2105
- onCancel: D
2118
+ onCancel: Y
2106
2119
  }
2107
2120
  )
2108
2121
  ] }) : /* @__PURE__ */ m("div", { className: "single-maze-error", children: /* @__PURE__ */ m("div", { children: "Failed to generate maze" }) });
2109
2122
  }
2110
- const Ct = [
2123
+ const yt = [
2111
2124
  // Tier 1 (Levels 1-12) - Beginner
2112
2125
  [
2113
2126
  // debug
@@ -2265,8 +2278,8 @@ const Ct = [
2265
2278
  { size: 68, seed: 33341, method: "backtracking" }
2266
2279
  // Level 60 - Master
2267
2280
  ]
2268
- ], An = 0.07, wt = {
2269
- gridMoveSpeed: An,
2281
+ ], Pn = 0.07, bt = {
2282
+ gridMoveSpeed: Pn,
2270
2283
  padding: 10,
2271
2284
  wallWidth: 2,
2272
2285
  wallColor: "#000000",
@@ -2281,7 +2294,7 @@ const Ct = [
2281
2294
  // default exit wall width if not specified in level config, should always be a little wider than normal wallWidth
2282
2295
  exitDashArray: [8, 12]
2283
2296
  // default dash: 8px dash, 12px gap
2284
- }, ce = {
2297
+ }, fe = {
2285
2298
  lcPrefix: "maze-",
2286
2299
  i18n: {
2287
2300
  reset: "Reset",
@@ -2326,19 +2339,22 @@ const Ct = [
2326
2339
  cluePathDisabled: "Clue Path Disabled",
2327
2340
  useArrowKeyTips: "Use arrow keys to navigate the maze. Press'C' to toggle path clue."
2328
2341
  },
2329
- renderConfig: wt,
2330
- levelConfig: Ct
2331
- }, ue = {
2342
+ renderConfig: bt,
2343
+ levelConfig: yt
2344
+ }, me = {
2332
2345
  i18n: {
2333
2346
  successMsg: "Congratulations! You completed the maze!",
2334
2347
  failMsg: "Time is up!",
2335
- restart: "Restart"
2348
+ foodMsg: "Please collect all stars before leaving!"
2336
2349
  },
2337
2350
  size: 8,
2338
2351
  seed: 12345,
2339
2352
  method: "backtracking",
2340
- foodCount: 3,
2341
- renderConfig: wt,
2353
+ clue: !1,
2354
+ foodCount: 0,
2355
+ foodRace: !1,
2356
+ // false then omit foodCount, make it to 0, true need to force all food collected
2357
+ renderConfig: bt,
2342
2358
  timer: 10 * 60,
2343
2359
  // 10 minutes
2344
2360
  successCallback: () => {
@@ -2348,56 +2364,56 @@ const Ct = [
2348
2364
  console.log("⏰ Time is up! Game failed.");
2349
2365
  }
2350
2366
  };
2351
- function Pn({ config: t = {} }) {
2352
- const e = { ...ce.i18n, ...t.i18n || {} }, n = {
2353
- ...ce.renderConfig,
2354
- ...t.renderConfig || {}
2355
- }, o = t.levelConfig || Ct, i = {
2356
- ...ce,
2357
- ...t,
2358
- i18n: e,
2367
+ function In({ config: e = {} }) {
2368
+ const t = { ...fe.i18n, ...e.i18n || {} }, n = {
2369
+ ...fe.renderConfig,
2370
+ ...e.renderConfig || {}
2371
+ }, o = e.levelConfig || yt, i = {
2372
+ ...fe,
2373
+ ...e,
2374
+ i18n: t,
2359
2375
  levelConfig: o,
2360
2376
  renderConfig: n
2361
2377
  };
2362
- return /* @__PURE__ */ m(Rt, { config: i, children: /* @__PURE__ */ m(En, {}) });
2378
+ return /* @__PURE__ */ m(Ft, { config: i, children: /* @__PURE__ */ m(Ln, {}) });
2363
2379
  }
2364
- function In({
2365
- config: t = {}
2380
+ function xn({
2381
+ config: e = {}
2366
2382
  }) {
2367
- const e = { ...ue.i18n, ...t.i18n || {} }, n = {
2368
- ...ue.renderConfig,
2369
- ...t.renderConfig || {}
2383
+ const t = { ...me.i18n, ...e.i18n || {} }, n = {
2384
+ ...me.renderConfig,
2385
+ ...e.renderConfig || {}
2370
2386
  }, o = {
2371
- ...ue,
2372
- ...t,
2373
- i18n: e,
2387
+ ...me,
2388
+ ...e,
2389
+ i18n: t,
2374
2390
  renderConfig: n
2375
2391
  };
2376
- return /* @__PURE__ */ m(Mn, { config: o });
2392
+ return /* @__PURE__ */ m(An, { config: o });
2377
2393
  }
2378
- const xn = {
2379
- root: "https://unpkg.com/@roudanio/maze@0.2.2/dist/",
2380
- ...ce
2381
- };
2382
- `${JSON.stringify(xn, null, 2)}`;
2383
2394
  const Rn = {
2384
- root: "https://unpkg.com/@roudanio/maze@0.2.2/dist/",
2385
- ...ue
2395
+ root: "https://unpkg.com/@roudanio/maze@0.2.4/dist/",
2396
+ ...fe
2397
+ };
2398
+ `${JSON.stringify(Rn, null, 2)}`;
2399
+ const Fn = {
2400
+ root: "https://unpkg.com/@roudanio/maze@0.2.4/dist/",
2401
+ ...me
2386
2402
  };
2387
2403
  `${JSON.stringify(
2388
- Rn,
2389
- (t, e) => typeof e == "function" ? e.toString() : e,
2404
+ Fn,
2405
+ (e, t) => typeof t == "function" ? t.toString() : t,
2390
2406
  2
2391
2407
  )}`;
2392
- const Fn = {
2408
+ const On = {
2393
2409
  showNotice() {
2394
2410
  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);
2411
+ const e = document.createElement("div");
2412
+ e.style.textAlign = "center", e.style.padding = "20px", e.innerHTML = "Cannot find the root element", document.body.append(e);
2397
2413
  },
2398
- addLoadingIndicator(t) {
2399
- const e = document.createElement("div"), n = document.createElement("div");
2400
- e.style.cssText = `
2414
+ addLoadingIndicator(e) {
2415
+ const t = document.createElement("div"), n = document.createElement("div");
2416
+ t.style.cssText = `
2401
2417
  height: 30px;
2402
2418
  width: 100%;
2403
2419
  border: solid 2px #999;
@@ -2408,7 +2424,7 @@ const Fn = {
2408
2424
  background: #999;
2409
2425
  animation: loading 1.5s ease-in-out;
2410
2426
  transition: width 1.5s ease-in-out;
2411
- `, e.append(n), t.append(e);
2427
+ `, t.append(n), e.append(t);
2412
2428
  const o = document.createElement("style");
2413
2429
  o.innerHTML = `
2414
2430
  @keyframes loading {
@@ -2416,32 +2432,32 @@ const Fn = {
2416
2432
  100% { width: 99%; }
2417
2433
  }`, document.head.appendChild(o);
2418
2434
  },
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) => {
2435
+ async loadCSS(e) {
2436
+ const t = document.createElement("link");
2437
+ return t.rel = "stylesheet", t.href = "https://fonts.googleapis.com/css2?family=Roboto:ital,wght@0,100..900;1,100..900&display=swap", document.head.appendChild(t), new Promise((n, o) => {
2422
2438
  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);
2439
+ i.rel = "stylesheet", i.type = "text/css", i.href = e, i.onload = n, i.onerror = o, document.head.appendChild(i);
2424
2440
  });
2425
2441
  },
2426
- async init(t, e) {
2427
- const n = typeof t == "string" ? document.querySelector(t) : t;
2442
+ async init(e, t) {
2443
+ const n = typeof e == "string" ? document.querySelector(e) : e;
2428
2444
  if (!n) {
2429
2445
  this.showNotice();
2430
2446
  return;
2431
2447
  }
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);
2448
+ let { root: o = location.origin } = t;
2449
+ o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", De(/* @__PURE__ */ m(In, { config: t }), n);
2434
2450
  },
2435
- async initSingle(t, e) {
2436
- const n = typeof t == "string" ? document.querySelector(t) : t;
2451
+ async initSingle(e, t) {
2452
+ const n = typeof e == "string" ? document.querySelector(e) : e;
2437
2453
  if (!n) {
2438
2454
  this.showNotice();
2439
2455
  return;
2440
2456
  }
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);
2457
+ let { root: o = location.origin } = t;
2458
+ o.at(-1) !== "/" && (o += "/"), this.addLoadingIndicator(n), await this.loadCSS(o + "maze.css"), n.innerHTML = "", De(/* @__PURE__ */ m(xn, { config: t }), n);
2443
2459
  }
2444
2460
  };
2445
2461
  export {
2446
- Fn as default
2462
+ On as default
2447
2463
  };