astar-visualizer 1.0.4 → 1.0.6
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/README.md +3 -2
- package/dist/astar-visualizer.js +369 -364
- package/dist/astar-visualizer.umd.cjs +5 -5
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/astar-visualizer.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import D, { useState as
|
|
3
|
-
const
|
|
1
|
+
import { jsx as S, jsxs as y } from "react/jsx-runtime";
|
|
2
|
+
import D, { useState as H, useEffect as F } from "react";
|
|
3
|
+
const P = (e) => {
|
|
4
4
|
let t;
|
|
5
|
-
const r = /* @__PURE__ */ new Set(),
|
|
6
|
-
const
|
|
7
|
-
if (!Object.is(
|
|
8
|
-
const
|
|
9
|
-
t =
|
|
5
|
+
const r = /* @__PURE__ */ new Set(), s = (i, m) => {
|
|
6
|
+
const c = typeof i == "function" ? i(t) : i;
|
|
7
|
+
if (!Object.is(c, t)) {
|
|
8
|
+
const l = t;
|
|
9
|
+
t = m ?? (typeof c != "object" || c === null) ? c : Object.assign({}, t, c), r.forEach((n) => n(t, l));
|
|
10
10
|
}
|
|
11
|
-
}, o = () => t,
|
|
11
|
+
}, o = () => t, w = { setState: s, getState: o, getInitialState: () => d, subscribe: (i) => (r.add(i), () => r.delete(i)), destroy: () => {
|
|
12
12
|
r.clear();
|
|
13
|
-
} }, d = t = e(
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
function
|
|
13
|
+
} }, d = t = e(s, o, w);
|
|
14
|
+
return w;
|
|
15
|
+
}, q = (e) => e ? P(e) : P;
|
|
16
|
+
function J(e) {
|
|
17
17
|
return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
|
|
18
18
|
}
|
|
19
|
-
var V = { exports: {} },
|
|
19
|
+
var V = { exports: {} }, L = {}, R = { exports: {} }, A = {};
|
|
20
20
|
/**
|
|
21
21
|
* @license React
|
|
22
22
|
* use-sync-external-store-shim.production.js
|
|
@@ -26,49 +26,49 @@ var V = { exports: {} }, R = {}, L = { exports: {} }, A = {};
|
|
|
26
26
|
* This source code is licensed under the MIT license found in the
|
|
27
27
|
* LICENSE file in the root directory of this source tree.
|
|
28
28
|
*/
|
|
29
|
-
var
|
|
30
|
-
function
|
|
31
|
-
if (
|
|
29
|
+
var I;
|
|
30
|
+
function Y() {
|
|
31
|
+
if (I)
|
|
32
32
|
return A;
|
|
33
|
-
|
|
33
|
+
I = 1;
|
|
34
34
|
var e = D;
|
|
35
|
-
function t(
|
|
36
|
-
return
|
|
35
|
+
function t(m, c) {
|
|
36
|
+
return m === c && (m !== 0 || 1 / m === 1 / c) || m !== m && c !== c;
|
|
37
37
|
}
|
|
38
|
-
var r = typeof Object.is == "function" ? Object.is : t,
|
|
39
|
-
function
|
|
40
|
-
var
|
|
41
|
-
return
|
|
38
|
+
var r = typeof Object.is == "function" ? Object.is : t, s = e.useState, o = e.useEffect, u = e.useLayoutEffect, p = e.useDebugValue;
|
|
39
|
+
function E(m, c) {
|
|
40
|
+
var l = c(), n = s({ inst: { value: l, getSnapshot: c } }), a = n[0].inst, f = n[1];
|
|
41
|
+
return u(
|
|
42
42
|
function() {
|
|
43
|
-
|
|
43
|
+
a.value = l, a.getSnapshot = c, w(a) && f({ inst: a });
|
|
44
44
|
},
|
|
45
|
-
[
|
|
45
|
+
[m, l, c]
|
|
46
46
|
), o(
|
|
47
47
|
function() {
|
|
48
|
-
return
|
|
49
|
-
|
|
48
|
+
return w(a) && f({ inst: a }), m(function() {
|
|
49
|
+
w(a) && f({ inst: a });
|
|
50
50
|
});
|
|
51
51
|
},
|
|
52
|
-
[
|
|
53
|
-
),
|
|
52
|
+
[m]
|
|
53
|
+
), p(l), l;
|
|
54
54
|
}
|
|
55
|
-
function
|
|
56
|
-
var
|
|
57
|
-
|
|
55
|
+
function w(m) {
|
|
56
|
+
var c = m.getSnapshot;
|
|
57
|
+
m = m.value;
|
|
58
58
|
try {
|
|
59
|
-
var
|
|
60
|
-
return !r(
|
|
59
|
+
var l = c();
|
|
60
|
+
return !r(m, l);
|
|
61
61
|
} catch {
|
|
62
62
|
return !0;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
|
-
function d(
|
|
66
|
-
return
|
|
65
|
+
function d(m, c) {
|
|
66
|
+
return c();
|
|
67
67
|
}
|
|
68
|
-
var
|
|
69
|
-
return A.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore :
|
|
68
|
+
var i = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? d : E;
|
|
69
|
+
return A.useSyncExternalStore = e.useSyncExternalStore !== void 0 ? e.useSyncExternalStore : i, A;
|
|
70
70
|
}
|
|
71
|
-
var
|
|
71
|
+
var z = {};
|
|
72
72
|
/**
|
|
73
73
|
* @license React
|
|
74
74
|
* use-sync-external-store-shim.development.js
|
|
@@ -78,62 +78,62 @@ var M = {};
|
|
|
78
78
|
* This source code is licensed under the MIT license found in the
|
|
79
79
|
* LICENSE file in the root directory of this source tree.
|
|
80
80
|
*/
|
|
81
|
-
var
|
|
82
|
-
function
|
|
83
|
-
return
|
|
84
|
-
function e(
|
|
85
|
-
return
|
|
81
|
+
var x;
|
|
82
|
+
function Q() {
|
|
83
|
+
return x || (x = 1, process.env.NODE_ENV !== "production" && function() {
|
|
84
|
+
function e(l, n) {
|
|
85
|
+
return l === n && (l !== 0 || 1 / l === 1 / n) || l !== l && n !== n;
|
|
86
86
|
}
|
|
87
|
-
function t(
|
|
88
|
-
|
|
87
|
+
function t(l, n) {
|
|
88
|
+
i || o.startTransition === void 0 || (i = !0, console.error(
|
|
89
89
|
"You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
|
|
90
90
|
));
|
|
91
|
-
var
|
|
92
|
-
if (!
|
|
93
|
-
var
|
|
94
|
-
|
|
91
|
+
var a = n();
|
|
92
|
+
if (!m) {
|
|
93
|
+
var f = n();
|
|
94
|
+
u(a, f) || (console.error(
|
|
95
95
|
"The result of getSnapshot should be cached to avoid an infinite loop"
|
|
96
|
-
),
|
|
96
|
+
), m = !0);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
inst: { value:
|
|
98
|
+
f = p({
|
|
99
|
+
inst: { value: a, getSnapshot: n }
|
|
100
100
|
});
|
|
101
|
-
var
|
|
102
|
-
return
|
|
101
|
+
var v = f[0].inst, O = f[1];
|
|
102
|
+
return w(
|
|
103
103
|
function() {
|
|
104
|
-
|
|
104
|
+
v.value = a, v.getSnapshot = n, r(v) && O({ inst: v });
|
|
105
105
|
},
|
|
106
|
-
[
|
|
107
|
-
),
|
|
106
|
+
[l, a, n]
|
|
107
|
+
), E(
|
|
108
108
|
function() {
|
|
109
|
-
return r(
|
|
110
|
-
r(
|
|
109
|
+
return r(v) && O({ inst: v }), l(function() {
|
|
110
|
+
r(v) && O({ inst: v });
|
|
111
111
|
});
|
|
112
112
|
},
|
|
113
|
-
[
|
|
114
|
-
), d(
|
|
113
|
+
[l]
|
|
114
|
+
), d(a), a;
|
|
115
115
|
}
|
|
116
|
-
function r(
|
|
117
|
-
var
|
|
118
|
-
|
|
116
|
+
function r(l) {
|
|
117
|
+
var n = l.getSnapshot;
|
|
118
|
+
l = l.value;
|
|
119
119
|
try {
|
|
120
|
-
var
|
|
121
|
-
return !
|
|
120
|
+
var a = n();
|
|
121
|
+
return !u(l, a);
|
|
122
122
|
} catch {
|
|
123
123
|
return !0;
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
|
-
function l
|
|
127
|
-
return
|
|
126
|
+
function s(l, n) {
|
|
127
|
+
return n();
|
|
128
128
|
}
|
|
129
129
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
130
|
-
var o = D,
|
|
131
|
-
|
|
132
|
-
}()),
|
|
130
|
+
var o = D, u = typeof Object.is == "function" ? Object.is : e, p = o.useState, E = o.useEffect, w = o.useLayoutEffect, d = o.useDebugValue, i = !1, m = !1, c = typeof window > "u" || typeof window.document > "u" || typeof window.document.createElement > "u" ? s : t;
|
|
131
|
+
z.useSyncExternalStore = o.useSyncExternalStore !== void 0 ? o.useSyncExternalStore : c, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
132
|
+
}()), z;
|
|
133
133
|
}
|
|
134
|
-
var
|
|
135
|
-
function
|
|
136
|
-
return
|
|
134
|
+
var j;
|
|
135
|
+
function K() {
|
|
136
|
+
return j || (j = 1, process.env.NODE_ENV === "production" ? R.exports = Y() : R.exports = Q()), R.exports;
|
|
137
137
|
}
|
|
138
138
|
/**
|
|
139
139
|
* @license React
|
|
@@ -144,61 +144,61 @@ function F() {
|
|
|
144
144
|
* This source code is licensed under the MIT license found in the
|
|
145
145
|
* LICENSE file in the root directory of this source tree.
|
|
146
146
|
*/
|
|
147
|
-
var
|
|
148
|
-
function
|
|
149
|
-
if (
|
|
150
|
-
return
|
|
151
|
-
|
|
152
|
-
var e = D, t =
|
|
153
|
-
function r(d,
|
|
154
|
-
return d ===
|
|
147
|
+
var G;
|
|
148
|
+
function X() {
|
|
149
|
+
if (G)
|
|
150
|
+
return L;
|
|
151
|
+
G = 1;
|
|
152
|
+
var e = D, t = K();
|
|
153
|
+
function r(d, i) {
|
|
154
|
+
return d === i && (d !== 0 || 1 / d === 1 / i) || d !== d && i !== i;
|
|
155
155
|
}
|
|
156
|
-
var
|
|
157
|
-
return
|
|
158
|
-
var
|
|
159
|
-
if (
|
|
160
|
-
var
|
|
161
|
-
|
|
156
|
+
var s = typeof Object.is == "function" ? Object.is : r, o = t.useSyncExternalStore, u = e.useRef, p = e.useEffect, E = e.useMemo, w = e.useDebugValue;
|
|
157
|
+
return L.useSyncExternalStoreWithSelector = function(d, i, m, c, l) {
|
|
158
|
+
var n = u(null);
|
|
159
|
+
if (n.current === null) {
|
|
160
|
+
var a = { hasValue: !1, value: null };
|
|
161
|
+
n.current = a;
|
|
162
162
|
} else
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
a = n.current;
|
|
164
|
+
n = E(
|
|
165
165
|
function() {
|
|
166
|
-
function
|
|
167
|
-
if (!
|
|
168
|
-
if (
|
|
169
|
-
var
|
|
170
|
-
if (
|
|
171
|
-
return
|
|
166
|
+
function v(g) {
|
|
167
|
+
if (!O) {
|
|
168
|
+
if (O = !0, N = g, g = c(g), l !== void 0 && a.hasValue) {
|
|
169
|
+
var b = a.value;
|
|
170
|
+
if (l(b, g))
|
|
171
|
+
return T = b;
|
|
172
172
|
}
|
|
173
|
-
return
|
|
173
|
+
return T = g;
|
|
174
174
|
}
|
|
175
|
-
if (
|
|
176
|
-
return
|
|
177
|
-
var
|
|
178
|
-
return
|
|
175
|
+
if (b = T, s(N, g))
|
|
176
|
+
return b;
|
|
177
|
+
var _ = c(g);
|
|
178
|
+
return l !== void 0 && l(b, _) ? (N = g, b) : (N = g, T = _);
|
|
179
179
|
}
|
|
180
|
-
var
|
|
180
|
+
var O = !1, N, T, C = m === void 0 ? null : m;
|
|
181
181
|
return [
|
|
182
182
|
function() {
|
|
183
|
-
return
|
|
183
|
+
return v(i());
|
|
184
184
|
},
|
|
185
185
|
C === null ? void 0 : function() {
|
|
186
|
-
return
|
|
186
|
+
return v(C());
|
|
187
187
|
}
|
|
188
188
|
];
|
|
189
189
|
},
|
|
190
|
-
[
|
|
190
|
+
[i, m, c, l]
|
|
191
191
|
);
|
|
192
|
-
var
|
|
193
|
-
return
|
|
192
|
+
var f = o(d, n[0], n[1]);
|
|
193
|
+
return p(
|
|
194
194
|
function() {
|
|
195
|
-
|
|
195
|
+
a.hasValue = !0, a.value = f;
|
|
196
196
|
},
|
|
197
|
-
[
|
|
198
|
-
),
|
|
199
|
-
},
|
|
197
|
+
[f]
|
|
198
|
+
), w(f), f;
|
|
199
|
+
}, L;
|
|
200
200
|
}
|
|
201
|
-
var
|
|
201
|
+
var M = {};
|
|
202
202
|
/**
|
|
203
203
|
* @license React
|
|
204
204
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -209,146 +209,146 @@ var z = {};
|
|
|
209
209
|
* LICENSE file in the root directory of this source tree.
|
|
210
210
|
*/
|
|
211
211
|
var W;
|
|
212
|
-
function
|
|
212
|
+
function Z() {
|
|
213
213
|
return W || (W = 1, process.env.NODE_ENV !== "production" && function() {
|
|
214
|
-
function e(d,
|
|
215
|
-
return d ===
|
|
214
|
+
function e(d, i) {
|
|
215
|
+
return d === i && (d !== 0 || 1 / d === 1 / i) || d !== d && i !== i;
|
|
216
216
|
}
|
|
217
217
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
|
|
218
|
-
var t = D, r =
|
|
219
|
-
|
|
220
|
-
var
|
|
221
|
-
if (
|
|
222
|
-
var
|
|
223
|
-
|
|
218
|
+
var t = D, r = K(), s = typeof Object.is == "function" ? Object.is : e, o = r.useSyncExternalStore, u = t.useRef, p = t.useEffect, E = t.useMemo, w = t.useDebugValue;
|
|
219
|
+
M.useSyncExternalStoreWithSelector = function(d, i, m, c, l) {
|
|
220
|
+
var n = u(null);
|
|
221
|
+
if (n.current === null) {
|
|
222
|
+
var a = { hasValue: !1, value: null };
|
|
223
|
+
n.current = a;
|
|
224
224
|
} else
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
a = n.current;
|
|
226
|
+
n = E(
|
|
227
227
|
function() {
|
|
228
|
-
function
|
|
229
|
-
if (!
|
|
230
|
-
if (
|
|
231
|
-
var
|
|
232
|
-
if (
|
|
233
|
-
return
|
|
228
|
+
function v(g) {
|
|
229
|
+
if (!O) {
|
|
230
|
+
if (O = !0, N = g, g = c(g), l !== void 0 && a.hasValue) {
|
|
231
|
+
var b = a.value;
|
|
232
|
+
if (l(b, g))
|
|
233
|
+
return T = b;
|
|
234
234
|
}
|
|
235
|
-
return
|
|
235
|
+
return T = g;
|
|
236
236
|
}
|
|
237
|
-
if (
|
|
238
|
-
return
|
|
239
|
-
var
|
|
240
|
-
return
|
|
237
|
+
if (b = T, s(N, g))
|
|
238
|
+
return b;
|
|
239
|
+
var _ = c(g);
|
|
240
|
+
return l !== void 0 && l(b, _) ? (N = g, b) : (N = g, T = _);
|
|
241
241
|
}
|
|
242
|
-
var
|
|
242
|
+
var O = !1, N, T, C = m === void 0 ? null : m;
|
|
243
243
|
return [
|
|
244
244
|
function() {
|
|
245
|
-
return
|
|
245
|
+
return v(i());
|
|
246
246
|
},
|
|
247
247
|
C === null ? void 0 : function() {
|
|
248
|
-
return
|
|
248
|
+
return v(C());
|
|
249
249
|
}
|
|
250
250
|
];
|
|
251
251
|
},
|
|
252
|
-
[
|
|
252
|
+
[i, m, c, l]
|
|
253
253
|
);
|
|
254
|
-
var
|
|
255
|
-
return
|
|
254
|
+
var f = o(d, n[0], n[1]);
|
|
255
|
+
return p(
|
|
256
256
|
function() {
|
|
257
|
-
|
|
257
|
+
a.hasValue = !0, a.value = f;
|
|
258
258
|
},
|
|
259
|
-
[
|
|
260
|
-
),
|
|
259
|
+
[f]
|
|
260
|
+
), w(f), f;
|
|
261
261
|
}, typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ < "u" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop == "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
|
|
262
|
-
}()),
|
|
262
|
+
}()), M;
|
|
263
263
|
}
|
|
264
|
-
process.env.NODE_ENV === "production" ? V.exports =
|
|
265
|
-
var
|
|
266
|
-
const
|
|
267
|
-
const
|
|
268
|
-
function
|
|
269
|
-
const
|
|
264
|
+
process.env.NODE_ENV === "production" ? V.exports = X() : V.exports = Z();
|
|
265
|
+
var ee = V.exports;
|
|
266
|
+
const te = /* @__PURE__ */ J(ee), { useDebugValue: re } = D, { useSyncExternalStoreWithSelector: oe } = te;
|
|
267
|
+
const ne = (e) => e;
|
|
268
|
+
function se(e, t = ne, r) {
|
|
269
|
+
const s = oe(
|
|
270
270
|
e.subscribe,
|
|
271
271
|
e.getState,
|
|
272
272
|
e.getServerState || e.getInitialState,
|
|
273
273
|
t,
|
|
274
274
|
r
|
|
275
275
|
);
|
|
276
|
-
return
|
|
276
|
+
return re(s), s;
|
|
277
277
|
}
|
|
278
|
-
const
|
|
279
|
-
const t = typeof e == "function" ?
|
|
278
|
+
const $ = (e) => {
|
|
279
|
+
const t = typeof e == "function" ? q(e) : e, r = (s, o) => se(t, s, o);
|
|
280
280
|
return Object.assign(r, t), r;
|
|
281
|
-
},
|
|
281
|
+
}, ae = (e) => e ? $(e) : $;
|
|
282
282
|
var h = /* @__PURE__ */ ((e) => (e[e.Empty = 0] = "Empty", e[e.Start = 1] = "Start", e[e.End = 2] = "End", e[e.Obstacle = 3] = "Obstacle", e[e.Visited = 4] = "Visited", e[e.Path = 5] = "Path", e))(h || {});
|
|
283
283
|
const k = (e, t) => {
|
|
284
|
-
const r = Math.abs(e.row - t.row),
|
|
285
|
-
return Math.floor(10 * Math.sqrt(r * r +
|
|
286
|
-
},
|
|
284
|
+
const r = Math.abs(e.row - t.row), s = Math.abs(e.col - t.col);
|
|
285
|
+
return Math.floor(10 * Math.sqrt(r * r + s * s));
|
|
286
|
+
}, le = (e, t) => ({
|
|
287
287
|
row: e.row,
|
|
288
288
|
col: e.col,
|
|
289
289
|
g: 0,
|
|
290
290
|
h: k(e, t),
|
|
291
291
|
f: k(e, t),
|
|
292
292
|
parent: null
|
|
293
|
-
}),
|
|
294
|
-
const
|
|
293
|
+
}), ie = (e, t, r) => {
|
|
294
|
+
const s = [
|
|
295
295
|
{ row: e.row - 1, col: e.col },
|
|
296
296
|
{ row: e.row + 1, col: e.col },
|
|
297
297
|
{ row: e.row, col: e.col - 1 },
|
|
298
298
|
{ row: e.row, col: e.col + 1 }
|
|
299
299
|
];
|
|
300
|
-
return r &&
|
|
300
|
+
return r && s.push(
|
|
301
301
|
{ row: e.row - 1, col: e.col - 1 },
|
|
302
302
|
{ row: e.row - 1, col: e.col + 1 },
|
|
303
303
|
{ row: e.row + 1, col: e.col - 1 },
|
|
304
304
|
{ row: e.row + 1, col: e.col + 1 }
|
|
305
|
-
),
|
|
305
|
+
), s.filter((o) => o.row >= 0 && o.row < t.length && o.col >= 0 && o.col < t[0].length && t[o.row][o.col].state !== h.Obstacle).map((o) => ({
|
|
306
306
|
row: o.row,
|
|
307
307
|
col: o.col,
|
|
308
308
|
state: t[o.row][o.col].state
|
|
309
309
|
}));
|
|
310
|
-
},
|
|
311
|
-
const
|
|
312
|
-
return { g:
|
|
313
|
-
},
|
|
310
|
+
}, ce = (e, t, r) => {
|
|
311
|
+
const s = Math.abs(e.row - t.row), o = Math.abs(e.col - t.col), u = e.g + (s === 0 || o === 0 ? 10 : 14), p = k(t, r), E = u + p;
|
|
312
|
+
return { g: u, h: p, f: E };
|
|
313
|
+
}, ue = (e) => {
|
|
314
314
|
const t = [];
|
|
315
315
|
let r = e;
|
|
316
316
|
for (; r; )
|
|
317
317
|
t.push(r), r = r.parent;
|
|
318
318
|
return t.reverse();
|
|
319
|
-
},
|
|
320
|
-
const o = [],
|
|
321
|
-
for (o.push(
|
|
322
|
-
o.sort((d,
|
|
323
|
-
const
|
|
324
|
-
if (
|
|
325
|
-
return
|
|
326
|
-
|
|
327
|
-
const
|
|
328
|
-
for (const d of
|
|
329
|
-
if (
|
|
319
|
+
}, de = (e, t, r, s) => {
|
|
320
|
+
const o = [], u = [], p = le(t, r);
|
|
321
|
+
for (o.push(p); o.length > 0; ) {
|
|
322
|
+
o.sort((d, i) => d.f - i.f);
|
|
323
|
+
const E = o.shift();
|
|
324
|
+
if (E.row === r.row && E.col === r.col)
|
|
325
|
+
return u.push(E), { path: ue(E), visitedNodes: u };
|
|
326
|
+
u.push(E);
|
|
327
|
+
const w = ie(E, e, s);
|
|
328
|
+
for (const d of w) {
|
|
329
|
+
if (u.some((n) => n.row === d.row && n.col === d.col))
|
|
330
330
|
continue;
|
|
331
|
-
const { g:
|
|
332
|
-
(
|
|
331
|
+
const { g: i, h: m, f: c } = ce(E, d, r), l = o.find(
|
|
332
|
+
(n) => n.row === d.row && n.col === d.col
|
|
333
333
|
);
|
|
334
|
-
if (!
|
|
335
|
-
const
|
|
334
|
+
if (!l || i < l.g) {
|
|
335
|
+
const n = {
|
|
336
336
|
row: d.row,
|
|
337
337
|
col: d.col,
|
|
338
|
-
g:
|
|
339
|
-
h:
|
|
340
|
-
f:
|
|
341
|
-
parent:
|
|
338
|
+
g: i,
|
|
339
|
+
h: m,
|
|
340
|
+
f: c,
|
|
341
|
+
parent: E
|
|
342
342
|
};
|
|
343
|
-
|
|
343
|
+
l ? (l.g = i, l.f = c, l.parent = E) : o.push(n);
|
|
344
344
|
}
|
|
345
345
|
}
|
|
346
346
|
}
|
|
347
|
-
return { path: [], visitedNodes:
|
|
348
|
-
},
|
|
347
|
+
return { path: [], visitedNodes: u };
|
|
348
|
+
}, fe = (e) => ({
|
|
349
349
|
cells: Array.from(
|
|
350
350
|
{ length: 8 },
|
|
351
|
-
(t, r) => Array.from({ length: 12 }, (
|
|
351
|
+
(t, r) => Array.from({ length: 12 }, (s, o) => ({
|
|
352
352
|
row: r,
|
|
353
353
|
col: o,
|
|
354
354
|
state: h.Empty
|
|
@@ -363,13 +363,13 @@ const k = (e, t) => {
|
|
|
363
363
|
visitedNodes: [],
|
|
364
364
|
setNumberOfColumns: (t) => {
|
|
365
365
|
e((r) => {
|
|
366
|
-
const
|
|
366
|
+
const s = r.cells.map((o) => t > r.columns ? [
|
|
367
367
|
...o,
|
|
368
368
|
...Array.from(
|
|
369
369
|
{ length: t - r.columns },
|
|
370
|
-
(
|
|
370
|
+
(u, p) => ({
|
|
371
371
|
row: o[0].row,
|
|
372
|
-
col: r.columns +
|
|
372
|
+
col: r.columns + p,
|
|
373
373
|
state: h.Empty
|
|
374
374
|
})
|
|
375
375
|
)
|
|
@@ -377,58 +377,58 @@ const k = (e, t) => {
|
|
|
377
377
|
return {
|
|
378
378
|
...r,
|
|
379
379
|
columns: t,
|
|
380
|
-
cells:
|
|
380
|
+
cells: s
|
|
381
381
|
};
|
|
382
382
|
});
|
|
383
383
|
},
|
|
384
384
|
setNumberOfRows: (t) => {
|
|
385
385
|
e((r) => {
|
|
386
|
-
let
|
|
387
|
-
return t > r.rows ?
|
|
388
|
-
...
|
|
386
|
+
let s = [...r.cells];
|
|
387
|
+
return t > r.rows ? s = [
|
|
388
|
+
...s,
|
|
389
389
|
...Array.from(
|
|
390
390
|
{ length: t - r.rows },
|
|
391
|
-
(o,
|
|
392
|
-
row: r.rows +
|
|
393
|
-
col:
|
|
391
|
+
(o, u) => Array.from({ length: r.columns }, (p, E) => ({
|
|
392
|
+
row: r.rows + u,
|
|
393
|
+
col: E,
|
|
394
394
|
state: h.Empty
|
|
395
395
|
}))
|
|
396
396
|
)
|
|
397
|
-
] :
|
|
397
|
+
] : s = s.slice(0, t), {
|
|
398
398
|
...r,
|
|
399
399
|
rows: t,
|
|
400
|
-
cells:
|
|
400
|
+
cells: s
|
|
401
401
|
};
|
|
402
402
|
});
|
|
403
403
|
},
|
|
404
|
-
setCellState: (t, r,
|
|
404
|
+
setCellState: (t, r, s) => {
|
|
405
405
|
e((o) => {
|
|
406
|
-
const
|
|
407
|
-
(d) => d.map((
|
|
406
|
+
const u = o.cells.map(
|
|
407
|
+
(d) => d.map((i) => ({ ...i }))
|
|
408
408
|
);
|
|
409
|
-
let
|
|
410
|
-
switch (
|
|
409
|
+
let p = o.startTile, E = o.endTile, w = [...o.obstacleTiles];
|
|
410
|
+
switch (s === h.Start && o.startTile && (u[o.startTile.row][o.startTile.col].state = h.Empty, p = null), s === h.End && o.endTile && (u[o.endTile.row][o.endTile.col].state = h.Empty, E = null), u[t][r].state = s, s) {
|
|
411
411
|
case h.Start:
|
|
412
|
-
|
|
412
|
+
p = { row: t, col: r };
|
|
413
413
|
break;
|
|
414
414
|
case h.End:
|
|
415
|
-
|
|
415
|
+
E = { row: t, col: r };
|
|
416
416
|
break;
|
|
417
417
|
case h.Obstacle:
|
|
418
|
-
|
|
418
|
+
w.some((d) => d.row === t && d.col === r) || w.push({ row: t, col: r });
|
|
419
419
|
break;
|
|
420
420
|
case h.Empty:
|
|
421
|
-
|
|
421
|
+
w = w.filter(
|
|
422
422
|
(d) => !(d.row === t && d.col === r)
|
|
423
423
|
);
|
|
424
424
|
break;
|
|
425
425
|
}
|
|
426
426
|
return {
|
|
427
427
|
...o,
|
|
428
|
-
cells:
|
|
429
|
-
startTile:
|
|
430
|
-
endTile:
|
|
431
|
-
obstacleTiles:
|
|
428
|
+
cells: u,
|
|
429
|
+
startTile: p,
|
|
430
|
+
endTile: E,
|
|
431
|
+
obstacleTiles: w
|
|
432
432
|
};
|
|
433
433
|
});
|
|
434
434
|
},
|
|
@@ -436,8 +436,8 @@ const k = (e, t) => {
|
|
|
436
436
|
e((t) => ({
|
|
437
437
|
...t,
|
|
438
438
|
cells: t.cells.map(
|
|
439
|
-
(r) => r.map((
|
|
440
|
-
...
|
|
439
|
+
(r) => r.map((s) => ({
|
|
440
|
+
...s,
|
|
441
441
|
state: h.Empty
|
|
442
442
|
}))
|
|
443
443
|
),
|
|
@@ -450,120 +450,125 @@ const k = (e, t) => {
|
|
|
450
450
|
},
|
|
451
451
|
handleFindPath: (t) => {
|
|
452
452
|
e((r) => {
|
|
453
|
-
const
|
|
454
|
-
if (
|
|
455
|
-
const
|
|
456
|
-
(d) => d.map((
|
|
457
|
-
row:
|
|
458
|
-
col:
|
|
459
|
-
state:
|
|
453
|
+
const s = r.cells.flat().find((u) => u.state === h.Start), o = r.cells.flat().find((u) => u.state === h.End);
|
|
454
|
+
if (s && o) {
|
|
455
|
+
const u = r.cells.map(
|
|
456
|
+
(d) => d.map((i) => ({
|
|
457
|
+
row: i.row,
|
|
458
|
+
col: i.col,
|
|
459
|
+
state: i.state
|
|
460
460
|
}))
|
|
461
|
-
), { path:
|
|
462
|
-
return (async (d,
|
|
463
|
-
for (let
|
|
464
|
-
await new Promise((
|
|
465
|
-
const
|
|
466
|
-
(
|
|
467
|
-
...
|
|
468
|
-
state:
|
|
461
|
+
), { path: p, visitedNodes: E } = de(u, s, o, t);
|
|
462
|
+
return (async (d, i) => {
|
|
463
|
+
for (let m of i)
|
|
464
|
+
await new Promise((c) => setTimeout(c, 100)), e((c) => {
|
|
465
|
+
const l = c.cells.map(
|
|
466
|
+
(n) => n.map((a) => ({
|
|
467
|
+
...a,
|
|
468
|
+
state: m.row === a.row && m.col === a.col && a.state === h.Empty ? h.Visited : a.state
|
|
469
469
|
}))
|
|
470
470
|
);
|
|
471
471
|
return {
|
|
472
|
-
...
|
|
473
|
-
cells:
|
|
474
|
-
visitedNodes: [...
|
|
472
|
+
...c,
|
|
473
|
+
cells: l,
|
|
474
|
+
visitedNodes: [...c.visitedNodes, m]
|
|
475
475
|
};
|
|
476
476
|
});
|
|
477
|
-
for (let
|
|
478
|
-
await new Promise((
|
|
479
|
-
const
|
|
480
|
-
(
|
|
481
|
-
...
|
|
482
|
-
state:
|
|
477
|
+
for (let m of d)
|
|
478
|
+
await new Promise((c) => setTimeout(c, 250)), e((c) => {
|
|
479
|
+
const l = c.cells.map(
|
|
480
|
+
(n) => n.map((a) => ({
|
|
481
|
+
...a,
|
|
482
|
+
state: m.row === a.row && m.col === a.col ? h.Path : a.state
|
|
483
483
|
}))
|
|
484
484
|
);
|
|
485
485
|
return {
|
|
486
|
-
...
|
|
487
|
-
cells:
|
|
488
|
-
path: [...
|
|
486
|
+
...c,
|
|
487
|
+
cells: l,
|
|
488
|
+
path: [...c.path, m]
|
|
489
489
|
};
|
|
490
490
|
});
|
|
491
|
-
})(
|
|
491
|
+
})(p, E), { ...r, path: [], visitedNodes: [] };
|
|
492
492
|
}
|
|
493
493
|
return r;
|
|
494
494
|
});
|
|
495
495
|
},
|
|
496
496
|
setPath: (t) => {
|
|
497
497
|
e((r) => {
|
|
498
|
-
const
|
|
499
|
-
(o) => o.map((
|
|
500
|
-
...
|
|
501
|
-
state: t.some((
|
|
498
|
+
const s = r.cells.map(
|
|
499
|
+
(o) => o.map((u) => ({
|
|
500
|
+
...u,
|
|
501
|
+
state: t.some((p) => p.row === u.row && p.col === u.col) ? h.Path : u.state
|
|
502
502
|
}))
|
|
503
503
|
);
|
|
504
504
|
return {
|
|
505
505
|
...r,
|
|
506
|
-
cells:
|
|
506
|
+
cells: s
|
|
507
507
|
};
|
|
508
508
|
});
|
|
509
509
|
},
|
|
510
510
|
setVisitedNodes: (t) => {
|
|
511
511
|
e((r) => {
|
|
512
|
-
const
|
|
513
|
-
(o) => o.map((
|
|
514
|
-
...
|
|
515
|
-
state: t.some((
|
|
512
|
+
const s = r.cells.map(
|
|
513
|
+
(o) => o.map((u) => ({
|
|
514
|
+
...u,
|
|
515
|
+
state: t.some((p) => p.row === u.row && p.col === u.col) && u.state === h.Empty ? h.Visited : u.state
|
|
516
516
|
}))
|
|
517
517
|
);
|
|
518
518
|
return {
|
|
519
519
|
...r,
|
|
520
|
-
cells:
|
|
520
|
+
cells: s
|
|
521
521
|
};
|
|
522
522
|
});
|
|
523
523
|
}
|
|
524
|
-
}),
|
|
524
|
+
}), he = (e) => ({
|
|
525
525
|
activeButton: h.Start,
|
|
526
526
|
setSelectedButtonState: (t) => e({ activeButton: t }),
|
|
527
527
|
canTravelDiagonally: !0,
|
|
528
528
|
setCanTravelDiagonally: (t) => e({ canTravelDiagonally: t })
|
|
529
|
-
}),
|
|
530
|
-
...
|
|
531
|
-
...
|
|
529
|
+
}), U = ae((e, t, r) => ({
|
|
530
|
+
...fe(e),
|
|
531
|
+
...he(e)
|
|
532
532
|
}));
|
|
533
|
-
const
|
|
534
|
-
var
|
|
535
|
-
const { cells: e, activeButton: t, setCellState: r, setSelectedButtonState:
|
|
536
|
-
|
|
537
|
-
const
|
|
538
|
-
|
|
533
|
+
const me = () => {
|
|
534
|
+
var l;
|
|
535
|
+
const { cells: e, activeButton: t, setCellState: r, setSelectedButtonState: s, visitedNodes: o, path: u } = U(), [p, E] = H({ width: 0, height: 0 }), w = D.useRef(null);
|
|
536
|
+
F(() => {
|
|
537
|
+
const n = () => {
|
|
538
|
+
if (w.current) {
|
|
539
|
+
const a = w.current.getBoundingClientRect();
|
|
540
|
+
E({ width: a.width, height: a.height });
|
|
541
|
+
}
|
|
539
542
|
};
|
|
540
|
-
return window.addEventListener("resize",
|
|
543
|
+
return n(), window.addEventListener("resize", n), () => window.removeEventListener("resize", n);
|
|
541
544
|
}, []);
|
|
542
|
-
const
|
|
543
|
-
switch (r(
|
|
545
|
+
const d = (n, a) => {
|
|
546
|
+
switch (r(n, a, t), t) {
|
|
544
547
|
case h.Start:
|
|
545
|
-
|
|
548
|
+
s(h.End);
|
|
546
549
|
break;
|
|
547
550
|
case h.End:
|
|
548
|
-
|
|
551
|
+
s(h.Obstacle);
|
|
549
552
|
break;
|
|
550
553
|
}
|
|
551
|
-
},
|
|
552
|
-
const
|
|
553
|
-
return
|
|
554
|
-
},
|
|
555
|
-
var
|
|
556
|
-
|
|
557
|
-
|
|
554
|
+
}, i = (n, a) => {
|
|
555
|
+
const f = o.find((v) => v.row === n && v.col === a);
|
|
556
|
+
return f ? { g: f.g, h: f.h, f: f.f } : { g: null, h: null, f: null };
|
|
557
|
+
}, c = (() => {
|
|
558
|
+
var b;
|
|
559
|
+
if (!p.width || !p.height)
|
|
560
|
+
return 20;
|
|
561
|
+
const n = ((b = e[0]) == null ? void 0 : b.length) || 1, a = e.length || 1, f = 20, v = n + a, O = p.width - f - v, N = p.height - f - v, T = O / n, C = N / a, g = Math.min(T, C);
|
|
562
|
+
return Math.max(15, Math.min(g, 60));
|
|
558
563
|
})();
|
|
559
|
-
return /* @__PURE__ */
|
|
564
|
+
return /* @__PURE__ */ S("div", { className: "grid-wrapper", ref: w, children: /* @__PURE__ */ S(
|
|
560
565
|
"div",
|
|
561
566
|
{
|
|
562
567
|
className: "grid-container",
|
|
563
568
|
style: {
|
|
564
569
|
display: "grid",
|
|
565
|
-
gridTemplateColumns: `repeat(${((
|
|
566
|
-
gridTemplateRows: `repeat(${e.length || 1}, ${
|
|
570
|
+
gridTemplateColumns: `repeat(${((l = e[0]) == null ? void 0 : l.length) || 1}, ${c}px)`,
|
|
571
|
+
gridTemplateRows: `repeat(${e.length || 1}, ${c}px)`,
|
|
567
572
|
gap: "1px",
|
|
568
573
|
padding: "8px",
|
|
569
574
|
background: "var(--bg-secondary)",
|
|
@@ -572,21 +577,21 @@ const he = () => {
|
|
|
572
577
|
border: "1px solid var(--border-color)"
|
|
573
578
|
},
|
|
574
579
|
children: e.map(
|
|
575
|
-
(
|
|
576
|
-
const
|
|
577
|
-
let b =
|
|
578
|
-
if (
|
|
579
|
-
const
|
|
580
|
-
|
|
580
|
+
(n, a) => n.map((f, v) => {
|
|
581
|
+
const O = u.some((_) => _.row === f.row && _.col === f.col), N = o.some((_) => _.row === f.row && _.col === f.col), { g: T, h: C, f: g } = i(f.row, f.col);
|
|
582
|
+
let b = pe(f, N);
|
|
583
|
+
if (O) {
|
|
584
|
+
const _ = u.findIndex((B) => B.row === f.row && B.col === f.col);
|
|
585
|
+
_ === 0 ? b = "var(--cell-start)" : _ === u.length - 1 ? b = "var(--cell-end)" : b = "var(--cell-path)";
|
|
581
586
|
}
|
|
582
587
|
return /* @__PURE__ */ y(
|
|
583
588
|
"div",
|
|
584
589
|
{
|
|
585
590
|
className: "grid-cell",
|
|
586
|
-
onClick: () =>
|
|
591
|
+
onClick: () => d(a, v),
|
|
587
592
|
style: {
|
|
588
|
-
width:
|
|
589
|
-
height:
|
|
593
|
+
width: c,
|
|
594
|
+
height: c,
|
|
590
595
|
backgroundColor: b,
|
|
591
596
|
border: "1px solid var(--cell-border)",
|
|
592
597
|
cursor: "pointer",
|
|
@@ -597,39 +602,39 @@ const he = () => {
|
|
|
597
602
|
alignItems: "center",
|
|
598
603
|
borderRadius: "2px"
|
|
599
604
|
},
|
|
600
|
-
onMouseEnter: (
|
|
601
|
-
|
|
605
|
+
onMouseEnter: (_) => {
|
|
606
|
+
f.state === h.Empty && (_.currentTarget.style.backgroundColor = "var(--bg-tertiary)", _.currentTarget.style.transform = "scale(1.02)");
|
|
602
607
|
},
|
|
603
|
-
onMouseLeave: (
|
|
604
|
-
|
|
608
|
+
onMouseLeave: (_) => {
|
|
609
|
+
f.state === h.Empty && (_.currentTarget.style.backgroundColor = b, _.currentTarget.style.transform = "scale(1)");
|
|
605
610
|
},
|
|
606
611
|
children: [
|
|
607
|
-
|
|
612
|
+
N && /* @__PURE__ */ y("div", { className: "cell-values", children: [
|
|
608
613
|
/* @__PURE__ */ y("div", { className: "value-h", children: [
|
|
609
614
|
"h",
|
|
610
|
-
|
|
615
|
+
C
|
|
611
616
|
] }),
|
|
612
617
|
/* @__PURE__ */ y("div", { className: "value-f", children: [
|
|
613
618
|
"f",
|
|
614
|
-
|
|
619
|
+
g
|
|
615
620
|
] }),
|
|
616
621
|
/* @__PURE__ */ y("div", { className: "value-g", children: [
|
|
617
622
|
"g",
|
|
618
|
-
|
|
623
|
+
T
|
|
619
624
|
] })
|
|
620
625
|
] }),
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
626
|
+
f.state === h.Start && /* @__PURE__ */ S("div", { className: "cell-indicator start", children: "●" }),
|
|
627
|
+
f.state === h.End && /* @__PURE__ */ S("div", { className: "cell-indicator end", children: "●" }),
|
|
628
|
+
f.state === h.Obstacle && /* @__PURE__ */ S("div", { className: "cell-indicator obstacle", children: "■" })
|
|
624
629
|
]
|
|
625
630
|
},
|
|
626
|
-
`${a}-${
|
|
631
|
+
`${a}-${v}`
|
|
627
632
|
);
|
|
628
633
|
})
|
|
629
634
|
)
|
|
630
635
|
}
|
|
631
636
|
) });
|
|
632
|
-
},
|
|
637
|
+
}, pe = (e, t) => {
|
|
633
638
|
if (t)
|
|
634
639
|
return e.state === h.Start ? "var(--cell-start)" : e.state === h.End ? "var(--cell-end)" : "var(--cell-visited)";
|
|
635
640
|
switch (e.state) {
|
|
@@ -645,128 +650,128 @@ const he = () => {
|
|
|
645
650
|
return "var(--cell-empty)";
|
|
646
651
|
}
|
|
647
652
|
};
|
|
648
|
-
const
|
|
653
|
+
const ve = () => {
|
|
649
654
|
const {
|
|
650
655
|
activeButton: e,
|
|
651
656
|
setSelectedButtonState: t,
|
|
652
657
|
resetCells: r,
|
|
653
|
-
rows:
|
|
658
|
+
rows: s,
|
|
654
659
|
columns: o,
|
|
655
|
-
setNumberOfRows:
|
|
656
|
-
setNumberOfColumns:
|
|
657
|
-
handleFindPath:
|
|
658
|
-
canTravelDiagonally:
|
|
660
|
+
setNumberOfRows: u,
|
|
661
|
+
setNumberOfColumns: p,
|
|
662
|
+
handleFindPath: E,
|
|
663
|
+
canTravelDiagonally: w,
|
|
659
664
|
setCanTravelDiagonally: d
|
|
660
|
-
} =
|
|
661
|
-
const
|
|
662
|
-
return
|
|
665
|
+
} = U(), [i, m] = H(() => {
|
|
666
|
+
const v = localStorage.getItem("darkMode");
|
|
667
|
+
return v ? JSON.parse(v) : !1;
|
|
663
668
|
});
|
|
664
|
-
|
|
665
|
-
localStorage.setItem("darkMode", JSON.stringify(
|
|
666
|
-
}, [
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
},
|
|
669
|
+
F(() => {
|
|
670
|
+
localStorage.setItem("darkMode", JSON.stringify(i)), document.documentElement.setAttribute("data-theme", i ? "dark" : "light");
|
|
671
|
+
}, [i]);
|
|
672
|
+
const c = () => {
|
|
673
|
+
m(!i);
|
|
674
|
+
}, l = [
|
|
670
675
|
{ label: "Start", state: h.Start },
|
|
671
676
|
{ label: "End", state: h.End },
|
|
672
677
|
{ label: "Obstacle", state: h.Obstacle },
|
|
673
678
|
{ label: "Clear", state: h.Empty },
|
|
674
679
|
{ label: "Reset", state: null }
|
|
675
|
-
],
|
|
676
|
-
|
|
677
|
-
},
|
|
680
|
+
], n = (v) => {
|
|
681
|
+
v === null ? a() : t(v);
|
|
682
|
+
}, a = () => {
|
|
678
683
|
r(), t(h.Start);
|
|
679
|
-
},
|
|
680
|
-
|
|
684
|
+
}, f = () => {
|
|
685
|
+
E(w);
|
|
681
686
|
};
|
|
682
|
-
return /* @__PURE__ */
|
|
687
|
+
return /* @__PURE__ */ S("div", { className: "control-panel", children: /* @__PURE__ */ y("div", { className: "control-grid", children: [
|
|
683
688
|
/* @__PURE__ */ y("div", { className: "control-group tools", children: [
|
|
684
|
-
/* @__PURE__ */
|
|
685
|
-
/* @__PURE__ */
|
|
689
|
+
/* @__PURE__ */ S("h3", { className: "group-title", children: "Tools" }),
|
|
690
|
+
/* @__PURE__ */ S("div", { className: "button-group", children: l.map((v, O) => /* @__PURE__ */ S(
|
|
686
691
|
"button",
|
|
687
692
|
{
|
|
688
|
-
className: `control-button ${
|
|
689
|
-
onClick: () =>
|
|
690
|
-
children:
|
|
693
|
+
className: `control-button ${v.label.toLowerCase()} ${e === v.state ? "active" : ""}`,
|
|
694
|
+
onClick: () => n(v.state),
|
|
695
|
+
children: v.label
|
|
691
696
|
},
|
|
692
|
-
|
|
697
|
+
O
|
|
693
698
|
)) })
|
|
694
699
|
] }),
|
|
695
700
|
/* @__PURE__ */ y("div", { className: "control-group actions", children: [
|
|
696
|
-
/* @__PURE__ */
|
|
701
|
+
/* @__PURE__ */ S("h3", { className: "group-title", children: "Actions" }),
|
|
697
702
|
/* @__PURE__ */ y("div", { className: "button-group", children: [
|
|
698
|
-
/* @__PURE__ */
|
|
703
|
+
/* @__PURE__ */ S(
|
|
699
704
|
"button",
|
|
700
705
|
{
|
|
701
706
|
className: "control-button find-path",
|
|
702
|
-
onClick:
|
|
707
|
+
onClick: f,
|
|
703
708
|
children: "Find Path"
|
|
704
709
|
}
|
|
705
710
|
),
|
|
706
|
-
/* @__PURE__ */
|
|
711
|
+
/* @__PURE__ */ S(
|
|
707
712
|
"button",
|
|
708
713
|
{
|
|
709
|
-
className: `control-button diagonal ${
|
|
710
|
-
onClick: () => d(!
|
|
711
|
-
children:
|
|
714
|
+
className: `control-button diagonal ${w ? "active" : ""}`,
|
|
715
|
+
onClick: () => d(!w),
|
|
716
|
+
children: w ? "Diagonal On" : "Diagonal Off"
|
|
712
717
|
}
|
|
713
718
|
),
|
|
714
|
-
/* @__PURE__ */
|
|
719
|
+
/* @__PURE__ */ S(
|
|
715
720
|
"button",
|
|
716
721
|
{
|
|
717
|
-
className: `control-button theme-toggle ${
|
|
718
|
-
onClick:
|
|
719
|
-
title:
|
|
720
|
-
children:
|
|
722
|
+
className: `control-button theme-toggle ${i ? "active" : ""}`,
|
|
723
|
+
onClick: c,
|
|
724
|
+
title: i ? "Switch to light mode" : "Switch to dark mode",
|
|
725
|
+
children: i ? "☀️ Light" : "🌙 Dark"
|
|
721
726
|
}
|
|
722
727
|
)
|
|
723
728
|
] })
|
|
724
729
|
] }),
|
|
725
730
|
/* @__PURE__ */ y("div", { className: "control-group size", children: [
|
|
726
|
-
/* @__PURE__ */
|
|
731
|
+
/* @__PURE__ */ S("h3", { className: "group-title", children: "Grid Size" }),
|
|
727
732
|
/* @__PURE__ */ y("div", { className: "size-controls", children: [
|
|
728
733
|
/* @__PURE__ */ y("div", { className: "size-control", children: [
|
|
729
|
-
/* @__PURE__ */
|
|
734
|
+
/* @__PURE__ */ S("label", { className: "size-label", children: "Rows" }),
|
|
730
735
|
/* @__PURE__ */ y("div", { className: "size-buttons", children: [
|
|
731
|
-
/* @__PURE__ */
|
|
736
|
+
/* @__PURE__ */ S(
|
|
732
737
|
"button",
|
|
733
738
|
{
|
|
734
739
|
className: "size-button",
|
|
735
|
-
onClick: () =>
|
|
736
|
-
disabled:
|
|
740
|
+
onClick: () => u(Math.max(5, s - 1)),
|
|
741
|
+
disabled: s <= 5,
|
|
737
742
|
children: "−"
|
|
738
743
|
}
|
|
739
744
|
),
|
|
740
|
-
/* @__PURE__ */
|
|
741
|
-
/* @__PURE__ */
|
|
745
|
+
/* @__PURE__ */ S("span", { className: "size-value", children: s }),
|
|
746
|
+
/* @__PURE__ */ S(
|
|
742
747
|
"button",
|
|
743
748
|
{
|
|
744
749
|
className: "size-button",
|
|
745
|
-
onClick: () =>
|
|
746
|
-
disabled:
|
|
750
|
+
onClick: () => u(Math.min(50, s + 1)),
|
|
751
|
+
disabled: s >= 50,
|
|
747
752
|
children: "+"
|
|
748
753
|
}
|
|
749
754
|
)
|
|
750
755
|
] })
|
|
751
756
|
] }),
|
|
752
757
|
/* @__PURE__ */ y("div", { className: "size-control", children: [
|
|
753
|
-
/* @__PURE__ */
|
|
758
|
+
/* @__PURE__ */ S("label", { className: "size-label", children: "Columns" }),
|
|
754
759
|
/* @__PURE__ */ y("div", { className: "size-buttons", children: [
|
|
755
|
-
/* @__PURE__ */
|
|
760
|
+
/* @__PURE__ */ S(
|
|
756
761
|
"button",
|
|
757
762
|
{
|
|
758
763
|
className: "size-button",
|
|
759
|
-
onClick: () =>
|
|
764
|
+
onClick: () => p(Math.max(5, o - 1)),
|
|
760
765
|
disabled: o <= 5,
|
|
761
766
|
children: "−"
|
|
762
767
|
}
|
|
763
768
|
),
|
|
764
|
-
/* @__PURE__ */
|
|
765
|
-
/* @__PURE__ */
|
|
769
|
+
/* @__PURE__ */ S("span", { className: "size-value", children: o }),
|
|
770
|
+
/* @__PURE__ */ S(
|
|
766
771
|
"button",
|
|
767
772
|
{
|
|
768
773
|
className: "size-button",
|
|
769
|
-
onClick: () =>
|
|
774
|
+
onClick: () => p(Math.min(50, o + 1)),
|
|
770
775
|
disabled: o >= 50,
|
|
771
776
|
children: "+"
|
|
772
777
|
}
|
|
@@ -776,16 +781,16 @@ const pe = () => {
|
|
|
776
781
|
] })
|
|
777
782
|
] })
|
|
778
783
|
] }) });
|
|
779
|
-
},
|
|
780
|
-
/* @__PURE__ */
|
|
781
|
-
/* @__PURE__ */
|
|
782
|
-
/* @__PURE__ */
|
|
784
|
+
}, Ee = () => /* @__PURE__ */ S("div", { className: "astar-visualizer-root", children: /* @__PURE__ */ y("div", { className: "app-container", children: [
|
|
785
|
+
/* @__PURE__ */ S("header", { className: "app-header", children: /* @__PURE__ */ S("h1", { className: "app-title", children: "A* Pathfinding" }) }),
|
|
786
|
+
/* @__PURE__ */ S("main", { className: "app-main", children: /* @__PURE__ */ S(me, {}) }),
|
|
787
|
+
/* @__PURE__ */ S("footer", { className: "app-footer", children: /* @__PURE__ */ S(ve, {}) })
|
|
783
788
|
] }) });
|
|
784
|
-
function
|
|
785
|
-
return /* @__PURE__ */
|
|
789
|
+
function ge() {
|
|
790
|
+
return /* @__PURE__ */ S(Ee, {});
|
|
786
791
|
}
|
|
787
792
|
export {
|
|
788
|
-
|
|
793
|
+
ge as AStarVisualizer,
|
|
789
794
|
h as CellState,
|
|
790
|
-
|
|
795
|
+
Ee as Layout
|
|
791
796
|
};
|