@roudanio/maze 0.1.7 → 0.2.0

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