@roudanio/maze 0.2.5 → 0.3.1

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