vehicle-path 1.0.0 → 1.0.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.
@@ -1,28 +1,28 @@
1
1
  import { useState as L, useMemo as Z, useRef as P, useEffect as b, useCallback as G, createContext as he, useContext as pe } from "react";
2
2
  function j(e, t) {
3
- const n = t.x - e.x, r = t.y - e.y;
4
- return Math.sqrt(n * n + r * r);
3
+ const n = t.x - e.x, s = t.y - e.y;
4
+ return Math.sqrt(n * n + s * s);
5
5
  }
6
6
  function Q(e, t) {
7
- const n = t.x - e.x, r = t.y - e.y, s = Math.sqrt(n * n + r * r);
8
- return s === 0 ? { x: 0, y: 0 } : { x: n / s, y: r / s };
7
+ const n = t.x - e.x, s = t.y - e.y, r = Math.sqrt(n * n + s * s);
8
+ return r === 0 ? { x: 0, y: 0 } : { x: n / r, y: s / r };
9
9
  }
10
10
  function Ie(e, t) {
11
11
  return t * (e === "proportional-40" ? 0.4 : 0.5522);
12
12
  }
13
- function ue(e, t, n, r = !1, s) {
14
- const { wheelbase: c, tangentMode: o } = n;
15
- let i;
16
- s?.fromOffset !== void 0 ? i = ee(e, s.fromOffset, s.fromIsPercentage ?? !1) : i = e.end;
13
+ function ue(e, t, n, s = !1, r) {
14
+ const { wheelbase: c, tangentMode: i } = n;
15
+ let o;
16
+ r?.fromOffset !== void 0 ? o = ee(e, r.fromOffset, r.fromIsPercentage ?? !1) : o = e.end;
17
17
  let f;
18
- s?.toOffset !== void 0 ? f = ee(t, s.toOffset, s.toIsPercentage ?? !1) : f = t.start;
19
- const a = Q(e.start, e.end), u = r ? {
18
+ r?.toOffset !== void 0 ? f = ee(t, r.toOffset, r.toIsPercentage ?? !1) : f = t.start;
19
+ const a = Q(e.start, e.end), u = s ? {
20
20
  // Transition with flip: kurva dimulai dari P (baseP0 - wheelbase in line direction)
21
- x: i.x - a.x * c,
22
- y: i.y - a.y * c
23
- } : i, d = Q(e.start, e.end), m = Q(t.start, t.end), I = j(u, f), h = Ie(o, I), l = r ? { x: u.x - d.x * h, y: u.y - d.y * h } : { x: u.x + d.x * h, y: u.y + d.y * h }, p = {
24
- x: f.x - m.x * h,
25
- y: f.y - m.y * h
21
+ x: o.x - a.x * c,
22
+ y: o.y - a.y * c
23
+ } : o, d = Q(e.start, e.end), g = Q(t.start, t.end), v = j(u, f), h = Ie(i, v), l = s ? { x: u.x - d.x * h, y: u.y - d.y * h } : { x: u.x + d.x * h, y: u.y + d.y * h }, p = {
24
+ x: f.x - g.x * h,
25
+ y: f.y - g.y * h
26
26
  };
27
27
  return { p0: u, p1: l, p2: p, p3: f };
28
28
  }
@@ -33,23 +33,23 @@ function ve(e, t) {
33
33
  };
34
34
  }
35
35
  function ee(e, t, n) {
36
- const r = j(e.start, e.end);
37
- let s;
38
- return n ? s = t / 100 : s = r > 0 ? t / r : 0, s = Math.max(0, Math.min(1, s)), ve(e, s);
36
+ const s = j(e.start, e.end);
37
+ let r;
38
+ return n ? r = t / 100 : r = s > 0 ? t / s : 0, r = Math.max(0, Math.min(1, r)), ve(e, r);
39
39
  }
40
40
  function ne(e, t) {
41
- const { p0: n, p1: r, p2: s, p3: c } = e, o = 1 - t, i = o * o, f = i * o, a = t * t, u = a * t;
41
+ const { p0: n, p1: s, p2: r, p3: c } = e, i = 1 - t, o = i * i, f = o * i, a = t * t, u = a * t;
42
42
  return {
43
- x: f * n.x + 3 * i * t * r.x + 3 * o * a * s.x + u * c.x,
44
- y: f * n.y + 3 * i * t * r.y + 3 * o * a * s.y + u * c.y
43
+ x: f * n.x + 3 * o * t * s.x + 3 * i * a * r.x + u * c.x,
44
+ y: f * n.y + 3 * o * t * s.y + 3 * i * a * r.y + u * c.y
45
45
  };
46
46
  }
47
47
  function xe(e, t = 100) {
48
48
  const n = [{ t: 0, distance: 0 }];
49
- let r = e.p0, s = 0;
49
+ let s = e.p0, r = 0;
50
50
  for (let c = 1; c <= t; c++) {
51
- const o = c / t, i = ne(e, o);
52
- s += j(r, i), n.push({ t: o, distance: s }), r = i;
51
+ const i = c / t, o = ne(e, i);
52
+ r += j(s, o), n.push({ t: i, distance: r }), s = o;
53
53
  }
54
54
  return n;
55
55
  }
@@ -57,65 +57,65 @@ function ye(e, t) {
57
57
  if (t <= 0) return 0;
58
58
  const n = e[e.length - 1].distance;
59
59
  if (t >= n) return 1;
60
- let r = 0, s = e.length - 1;
61
- for (; r < s - 1; ) {
62
- const u = Math.floor((r + s) / 2);
63
- e[u].distance < t ? r = u : s = u;
60
+ let s = 0, r = e.length - 1;
61
+ for (; s < r - 1; ) {
62
+ const u = Math.floor((s + r) / 2);
63
+ e[u].distance < t ? s = u : r = u;
64
64
  }
65
- const c = e[r].distance, o = e[s].distance, i = e[r].t, f = e[s].t;
66
- if (o === c) return i;
67
- const a = (t - c) / (o - c);
68
- return i + a * (f - i);
65
+ const c = e[s].distance, i = e[r].distance, o = e[s].t, f = e[r].t;
66
+ if (i === c) return o;
67
+ const a = (t - c) / (i - c);
68
+ return o + a * (f - o);
69
69
  }
70
70
  function je(e) {
71
71
  return e[e.length - 1].distance;
72
72
  }
73
73
  function Me(e, t = 100) {
74
- let n = 0, r = e.p0;
75
- for (let s = 1; s <= t; s++) {
76
- const c = s / t, o = ne(e, c);
77
- n += j(r, o), r = o;
74
+ let n = 0, s = e.p0;
75
+ for (let r = 1; r <= t; r++) {
76
+ const c = r / t, i = ne(e, c);
77
+ n += j(s, i), s = i;
78
78
  }
79
79
  return n;
80
80
  }
81
- function ze(e, t, n, r) {
82
- const s = j(e.start, e.end);
83
- return t === void 0 ? r / 100 * s : n ? t / 100 * s : t;
81
+ function ze(e, t, n, s) {
82
+ const r = j(e.start, e.end);
83
+ return t === void 0 ? s / 100 * r : n ? t / 100 * r : t;
84
84
  }
85
- function fe(e, t, n, r, s) {
86
- const c = j(e.start, e.end), o = c - s;
87
- if (o <= 0)
85
+ function fe(e, t, n, s, r) {
86
+ const c = j(e.start, e.end), i = c - r;
87
+ if (i <= 0)
88
88
  return c;
89
- let i;
89
+ let o;
90
90
  if (t === void 0)
91
- i = r;
91
+ o = s;
92
92
  else if (n)
93
- i = t;
93
+ o = t;
94
94
  else
95
- return Math.max(s, Math.min(t, c));
96
- return s + i / 100 * o;
95
+ return Math.max(r, Math.min(t, c));
96
+ return r + o / 100 * i;
97
97
  }
98
- function le(e, t, n, r, s) {
99
- const o = j(e.start, e.end) - s;
100
- if (o <= 0)
98
+ function le(e, t, n, s, r) {
99
+ const i = j(e.start, e.end) - r;
100
+ if (i <= 0)
101
101
  return 0;
102
- let i;
102
+ let o;
103
103
  if (t === void 0)
104
- i = r;
104
+ o = s;
105
105
  else if (n)
106
- i = t;
106
+ o = t;
107
107
  else
108
- return Math.max(0, Math.min(t, o));
109
- return i / 100 * o;
108
+ return Math.max(0, Math.min(t, i));
109
+ return o / 100 * i;
110
110
  }
111
111
  function Le(e, t, n) {
112
- const r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
113
- for (const o of e)
114
- s.set(o.id, o), c.set(o.id, j(o.start, o.end)), r.set(o.id, []);
115
- for (let o = 0; o < t.length; o++) {
116
- const i = t[o], f = s.get(i.fromLineId), a = s.get(i.toLineId);
112
+ const s = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map();
113
+ for (const i of e)
114
+ r.set(i.id, i), c.set(i.id, j(i.start, i.end)), s.set(i.id, []);
115
+ for (let i = 0; i < t.length; i++) {
116
+ const o = t[i], f = r.get(o.fromLineId), a = r.get(o.toLineId);
117
117
  if (!f || !a) continue;
118
- const u = fe(f, i.fromOffset, i.fromIsPercentage, 100, n.wheelbase), d = le(a, i.toOffset, i.toIsPercentage, 0, n.wheelbase), m = ue(
118
+ const u = fe(f, o.fromOffset, o.fromIsPercentage, 100, n.wheelbase), d = le(a, o.toOffset, o.toIsPercentage, 0, n.wheelbase), g = ue(
119
119
  f,
120
120
  a,
121
121
  n,
@@ -129,22 +129,22 @@ function Le(e, t, n) {
129
129
  toIsPercentage: !1
130
130
  // Already resolved to absolute
131
131
  }
132
- ), I = Me(m), h = {
133
- curveIndex: o,
134
- fromLineId: i.fromLineId,
135
- toLineId: i.toLineId,
132
+ ), v = Me(g), h = {
133
+ curveIndex: i,
134
+ fromLineId: o.fromLineId,
135
+ toLineId: o.toLineId,
136
136
  fromOffset: u,
137
137
  toOffset: d,
138
- curveLength: I
138
+ curveLength: v
139
139
  };
140
- r.get(i.fromLineId).push(h);
140
+ s.get(o.fromLineId).push(h);
141
141
  }
142
- return { adjacency: r, lines: s, lineLengths: c };
142
+ return { adjacency: s, lines: r, lineLengths: c };
143
143
  }
144
- function de(e, t, n, r, s = !1) {
145
- const { adjacency: c, lines: o, lineLengths: i } = e;
146
- if (!o.get(n)) return null;
147
- const a = i.get(n), u = s ? r / 100 * a : r, d = [], m = /* @__PURE__ */ new Map(), I = (l, p) => `${l}:${Math.round(p)}`;
144
+ function de(e, t, n, s, r = !1) {
145
+ const { adjacency: c, lines: i, lineLengths: o } = e;
146
+ if (!i.get(n)) return null;
147
+ const a = o.get(n), u = r ? s / 100 * a : s, d = [], g = /* @__PURE__ */ new Map(), v = (l, p) => `${l}:${Math.round(p)}`;
148
148
  if (t.lineId === n && u >= t.offset) {
149
149
  const l = u - t.offset;
150
150
  return {
@@ -167,7 +167,7 @@ function de(e, t, n, r, s = !1) {
167
167
  startOffset: t.offset,
168
168
  endOffset: l.fromOffset,
169
169
  length: p
170
- }, g = {
170
+ }, m = {
171
171
  type: "curve",
172
172
  curveIndex: l.curveIndex,
173
173
  startOffset: 0,
@@ -178,72 +178,72 @@ function de(e, t, n, r, s = !1) {
178
178
  lineId: l.toLineId,
179
179
  entryOffset: l.toOffset,
180
180
  totalDistance: S,
181
- path: [M, g]
181
+ path: [M, m]
182
182
  });
183
183
  }
184
184
  for (d.sort((l, p) => l.totalDistance - p.totalDistance); d.length > 0; ) {
185
- const l = d.shift(), p = I(l.lineId, l.entryOffset), S = m.get(p);
185
+ const l = d.shift(), p = v(l.lineId, l.entryOffset), S = g.get(p);
186
186
  if (S !== void 0 && S <= l.totalDistance)
187
187
  continue;
188
- if (m.set(p, l.totalDistance), l.lineId === n) {
189
- const g = Math.abs(u - l.entryOffset);
188
+ if (g.set(p, l.totalDistance), l.lineId === n) {
189
+ const m = Math.abs(u - l.entryOffset);
190
190
  if (u >= l.entryOffset) {
191
- const v = {
191
+ const x = {
192
192
  type: "line",
193
193
  lineId: n,
194
194
  startOffset: l.entryOffset,
195
195
  endOffset: u,
196
- length: g
196
+ length: m
197
197
  };
198
198
  return {
199
- segments: [...l.path, v],
200
- totalDistance: l.totalDistance + g
199
+ segments: [...l.path, x],
200
+ totalDistance: l.totalDistance + m
201
201
  };
202
202
  }
203
203
  }
204
204
  const M = c.get(l.lineId) || [];
205
- for (const g of M) {
206
- if (g.fromOffset < l.entryOffset) continue;
207
- const v = g.fromOffset - l.entryOffset, O = l.totalDistance + v + g.curveLength, C = I(g.toLineId, g.toOffset), E = m.get(C);
208
- if (E !== void 0 && E <= O)
205
+ for (const m of M) {
206
+ if (m.fromOffset < l.entryOffset) continue;
207
+ const x = m.fromOffset - l.entryOffset, O = l.totalDistance + x + m.curveLength, C = v(m.toLineId, m.toOffset), q = g.get(C);
208
+ if (q !== void 0 && q <= O)
209
209
  continue;
210
210
  const D = {
211
211
  type: "line",
212
212
  lineId: l.lineId,
213
213
  startOffset: l.entryOffset,
214
- endOffset: g.fromOffset,
215
- length: v
216
- }, x = {
214
+ endOffset: m.fromOffset,
215
+ length: x
216
+ }, I = {
217
217
  type: "curve",
218
- curveIndex: g.curveIndex,
218
+ curveIndex: m.curveIndex,
219
219
  startOffset: 0,
220
- endOffset: g.curveLength,
221
- length: g.curveLength
220
+ endOffset: m.curveLength,
221
+ length: m.curveLength
222
222
  };
223
223
  d.push({
224
- lineId: g.toLineId,
225
- entryOffset: g.toOffset,
224
+ lineId: m.toLineId,
225
+ entryOffset: m.toOffset,
226
226
  totalDistance: O,
227
- path: [...l.path, D, x]
227
+ path: [...l.path, D, I]
228
228
  });
229
229
  }
230
- d.sort((g, v) => g.totalDistance - v.totalDistance);
230
+ d.sort((m, x) => m.totalDistance - x.totalDistance);
231
231
  }
232
232
  return null;
233
233
  }
234
- function Je(e, t, n, r, s = !1) {
235
- return de(e, t, n, r, s) !== null;
234
+ function Je(e, t, n, s, r = !1) {
235
+ return de(e, t, n, s, r) !== null;
236
236
  }
237
237
  function Ke(e, t, n) {
238
- return (e.adjacency.get(t) || []).filter((s) => s.fromOffset >= n);
238
+ return (e.adjacency.get(t) || []).filter((r) => r.fromOffset >= n);
239
239
  }
240
- function me(e, t) {
240
+ function ge(e, t) {
241
241
  const n = Math.sqrt(
242
242
  Math.pow(e.end.x - e.start.x, 2) + Math.pow(e.end.y - e.start.y, 2)
243
- ), r = n > 0 ? t / n : 0;
243
+ ), s = n > 0 ? t / n : 0;
244
244
  return {
245
- x: e.start.x + (e.end.x - e.start.x) * Math.min(1, Math.max(0, r)),
246
- y: e.start.y + (e.end.y - e.start.y) * Math.min(1, Math.max(0, r))
245
+ x: e.start.x + (e.end.x - e.start.x) * Math.min(1, Math.max(0, s)),
246
+ y: e.start.y + (e.end.y - e.start.y) * Math.min(1, Math.max(0, s))
247
247
  };
248
248
  }
249
249
  function Oe(e) {
@@ -252,42 +252,42 @@ function Oe(e) {
252
252
  );
253
253
  }
254
254
  function Se(e, t, n) {
255
- let r = 0;
256
- for (let s = 0; s < t; s++)
257
- r += e.segments[s].length;
258
- return r += n, r;
255
+ let s = 0;
256
+ for (let r = 0; r < t; r++)
257
+ s += e.segments[r].length;
258
+ return s += n, s;
259
259
  }
260
260
  function Ce(e, t) {
261
261
  let n = 0;
262
- for (let r = 0; r < e.segments.length; r++) {
263
- const s = e.segments[r], c = n + s.length;
262
+ for (let s = 0; s < e.segments.length; s++) {
263
+ const r = e.segments[s], c = n + r.length;
264
264
  if (t < c)
265
265
  return {
266
- segmentIndex: r,
266
+ segmentIndex: s,
267
267
  segmentDistance: t - n
268
268
  };
269
269
  if (t === c)
270
- return r + 1 < e.segments.length ? {
271
- segmentIndex: r + 1,
270
+ return s + 1 < e.segments.length ? {
271
+ segmentIndex: s + 1,
272
272
  segmentDistance: 0
273
273
  } : {
274
- segmentIndex: r,
275
- segmentDistance: s.length
274
+ segmentIndex: s,
275
+ segmentDistance: r.length
276
276
  };
277
- n += s.length;
277
+ n += r.length;
278
278
  }
279
279
  return null;
280
280
  }
281
- function te(e, t, n, r) {
281
+ function te(e, t, n, s) {
282
282
  const c = Se(
283
283
  e,
284
284
  t,
285
285
  n
286
- ) + r;
286
+ ) + s;
287
287
  return Ce(e, c);
288
288
  }
289
- function ge(e, t, n) {
290
- const r = e.execution, s = n.vehicleQueues.get(e.vehicle.id), c = s?.[r.currentCommandIndex];
289
+ function me(e, t, n) {
290
+ const s = e.execution, r = n.vehicleQueues.get(e.vehicle.id), c = r?.[s.currentCommandIndex];
291
291
  if (c && n.onCommandComplete && n.onCommandComplete({
292
292
  vehicleId: e.vehicle.id,
293
293
  command: c,
@@ -301,13 +301,13 @@ function ge(e, t, n) {
301
301
  return {
302
302
  handled: !0,
303
303
  vehicle: { ...e.vehicle, state: "waiting" },
304
- newExecution: r,
304
+ newExecution: s,
305
305
  // Keep execution state for resume
306
306
  isWaiting: !0
307
307
  };
308
- const o = r.currentCommandIndex + 1;
309
- if (s && o < s.length) {
310
- const f = s[o], a = n.graphRef.current;
308
+ const i = s.currentCommandIndex + 1;
309
+ if (r && i < r.length) {
310
+ const f = r[i], a = n.graphRef.current;
311
311
  if (a) {
312
312
  const u = {
313
313
  graph: a,
@@ -320,28 +320,28 @@ function ge(e, t, n) {
320
320
  u
321
321
  );
322
322
  if (d) {
323
- const m = te(
323
+ const g = te(
324
324
  d.path,
325
325
  0,
326
326
  t,
327
327
  n.config.wheelbase
328
- ), I = {
328
+ ), v = {
329
329
  path: d.path,
330
330
  curveDataMap: d.curveDataMap,
331
- currentCommandIndex: o,
331
+ currentCommandIndex: i,
332
332
  rear: {
333
333
  currentSegmentIndex: 0,
334
334
  segmentDistance: t
335
335
  },
336
- front: m ? {
337
- currentSegmentIndex: m.segmentIndex,
338
- segmentDistance: m.segmentDistance
336
+ front: g ? {
337
+ currentSegmentIndex: g.segmentIndex,
338
+ segmentDistance: g.segmentDistance
339
339
  } : {
340
340
  currentSegmentIndex: 0,
341
341
  segmentDistance: t
342
342
  }
343
343
  };
344
- return { handled: !0, vehicle: { ...e.vehicle, state: "moving" }, newExecution: I };
344
+ return { handled: !0, vehicle: { ...e.vehicle, state: "moving" }, newExecution: v };
345
345
  }
346
346
  }
347
347
  }
@@ -352,23 +352,23 @@ function ge(e, t, n) {
352
352
  }
353
353
  function Ge(e, t) {
354
354
  const n = e.execution;
355
- return n ? n.rear.currentSegmentIndex >= n.path.segments.length ? ge(e, n.rear.segmentDistance, t) : { handled: !1, vehicle: e.vehicle } : { handled: !1, vehicle: e.vehicle };
355
+ return n ? n.rear.currentSegmentIndex >= n.path.segments.length ? me(e, n.rear.segmentDistance, t) : { handled: !1, vehicle: e.vehicle } : { handled: !1, vehicle: e.vehicle };
356
356
  }
357
357
  function W(e, t) {
358
- return { position: me(e, t), lineId: e.id, absoluteOffset: t };
358
+ return { position: ge(e, t), lineId: e.id, absoluteOffset: t };
359
359
  }
360
360
  function H(e, t) {
361
361
  const n = ye(e.arcLengthTable, t);
362
362
  return { position: ne(e.bezier, n) };
363
363
  }
364
- function se(e, t, n, r, s, c, o) {
365
- const i = n.segments[t.currentSegmentIndex], f = t.segmentDistance + r;
366
- if (f >= i.length) {
367
- const u = f - i.length, d = t.currentSegmentIndex + 1;
364
+ function re(e, t, n, s, r, c, i) {
365
+ const o = n.segments[t.currentSegmentIndex], f = t.segmentDistance + s;
366
+ if (f >= o.length) {
367
+ const u = f - o.length, d = t.currentSegmentIndex + 1;
368
368
  if (d >= n.segments.length) {
369
- if (o !== void 0 && i.type === "line") {
370
- const l = s.get(i.lineId), p = i.startOffset + f;
371
- if (p <= o) {
369
+ if (i !== void 0 && o.type === "line") {
370
+ const l = r.get(o.lineId), p = o.startOffset + f;
371
+ if (p <= i) {
372
372
  const M = W(l, p);
373
373
  return {
374
374
  axleState: { ...e, ...M },
@@ -376,35 +376,35 @@ function se(e, t, n, r, s, c, o) {
376
376
  completed: !1
377
377
  };
378
378
  }
379
- const S = W(l, o);
379
+ const S = W(l, i);
380
380
  return {
381
381
  axleState: { ...e, ...S },
382
- execution: { ...t, segmentDistance: o - i.startOffset },
382
+ execution: { ...t, segmentDistance: i - o.startOffset },
383
383
  completed: !0
384
384
  };
385
385
  }
386
- const h = i.type === "line" ? W(
387
- s.get(i.lineId),
388
- i.endOffset
386
+ const h = o.type === "line" ? W(
387
+ r.get(o.lineId),
388
+ o.endOffset
389
389
  ) : H(
390
- c.get(i.curveIndex),
391
- i.length
390
+ c.get(o.curveIndex),
391
+ o.length
392
392
  );
393
393
  return {
394
394
  axleState: { ...e, ...h },
395
- execution: { ...t, segmentDistance: i.length },
395
+ execution: { ...t, segmentDistance: o.length },
396
396
  completed: !0
397
397
  };
398
398
  }
399
- const m = n.segments[d], I = m.type === "line" ? W(
400
- s.get(m.lineId),
401
- m.startOffset + u
399
+ const g = n.segments[d], v = g.type === "line" ? W(
400
+ r.get(g.lineId),
401
+ g.startOffset + u
402
402
  ) : H(
403
- c.get(m.curveIndex),
403
+ c.get(g.curveIndex),
404
404
  u
405
405
  );
406
406
  return {
407
- axleState: { ...e, ...I },
407
+ axleState: { ...e, ...v },
408
408
  execution: {
409
409
  currentSegmentIndex: d,
410
410
  segmentDistance: u
@@ -412,11 +412,11 @@ function se(e, t, n, r, s, c, o) {
412
412
  completed: !1
413
413
  };
414
414
  }
415
- const a = i.type === "line" ? W(
416
- s.get(i.lineId),
417
- i.startOffset + f
415
+ const a = o.type === "line" ? W(
416
+ r.get(o.lineId),
417
+ o.startOffset + f
418
418
  ) : H(
419
- c.get(i.curveIndex),
419
+ c.get(o.curveIndex),
420
420
  f
421
421
  );
422
422
  return {
@@ -425,20 +425,20 @@ function se(e, t, n, r, s, c, o) {
425
425
  completed: !1
426
426
  };
427
427
  }
428
- function De(e, t, n, r) {
429
- const s = Math.sqrt(
430
- Math.pow(r.end.x - r.start.x, 2) + Math.pow(r.end.y - r.start.y, 2)
428
+ function we(e, t, n, s) {
429
+ const r = Math.sqrt(
430
+ Math.pow(s.end.x - s.start.x, 2) + Math.pow(s.end.y - s.start.y, 2)
431
431
  );
432
432
  let c = t + n;
433
- c = Math.min(c, s);
434
- const o = me(r, c);
433
+ c = Math.min(c, r);
434
+ const i = ge(s, c);
435
435
  return {
436
436
  lineId: e,
437
- position: o,
437
+ position: i,
438
438
  absoluteOffset: c
439
439
  };
440
440
  }
441
- function we(e, t) {
441
+ function De(e, t) {
442
442
  return {
443
443
  ...e,
444
444
  state: "idle"
@@ -451,40 +451,40 @@ function Te(e) {
451
451
  };
452
452
  }
453
453
  function oe(e, t) {
454
- const n = [], r = /* @__PURE__ */ new Map();
455
- for (const s of e) {
456
- if (!t.get(s.lineId)) continue;
457
- const o = we(s);
458
- n.push(o);
459
- const i = Te(o);
460
- r.set(s.id, i);
454
+ const n = [], s = /* @__PURE__ */ new Map();
455
+ for (const r of e) {
456
+ if (!t.get(r.lineId)) continue;
457
+ const i = De(r);
458
+ n.push(i);
459
+ const o = Te(i);
460
+ s.set(r.id, o);
461
461
  }
462
- return { movingVehicles: n, stateMap: r };
462
+ return { movingVehicles: n, stateMap: s };
463
463
  }
464
- function Pe(e, t, n, r) {
465
- const s = /* @__PURE__ */ new Map();
464
+ function Pe(e, t, n, s) {
465
+ const r = /* @__PURE__ */ new Map();
466
466
  for (const c of e.segments)
467
467
  if (c.type === "curve" && c.curveIndex !== void 0) {
468
- const o = t[c.curveIndex];
469
- if (o) {
470
- const i = n.get(o.fromLineId), f = n.get(o.toLineId);
471
- if (i && f) {
468
+ const i = t[c.curveIndex];
469
+ if (i) {
470
+ const o = n.get(i.fromLineId), f = n.get(i.toLineId);
471
+ if (o && f) {
472
472
  const a = fe(
473
- i,
474
- o.fromOffset,
475
- o.fromIsPercentage,
473
+ o,
474
+ i.fromOffset,
475
+ i.fromIsPercentage,
476
476
  100,
477
- r.wheelbase
477
+ s.wheelbase
478
478
  ), u = le(
479
479
  f,
480
- o.toOffset,
481
- o.toIsPercentage,
480
+ i.toOffset,
481
+ i.toIsPercentage,
482
482
  0,
483
- r.wheelbase
483
+ s.wheelbase
484
484
  ), d = ue(
485
- i,
485
+ o,
486
486
  f,
487
- r,
487
+ s,
488
488
  !1,
489
489
  // willFlip is always false now
490
490
  {
@@ -495,120 +495,124 @@ function Pe(e, t, n, r) {
495
495
  toIsPercentage: !1
496
496
  // Already resolved to absolute
497
497
  }
498
- ), m = xe(d);
499
- s.set(c.curveIndex, { bezier: d, arcLengthTable: m });
498
+ ), g = xe(d);
499
+ r.set(c.curveIndex, { bezier: d, arcLengthTable: g });
500
500
  }
501
501
  }
502
502
  }
503
- return s;
503
+ return r;
504
504
  }
505
505
  function X(e, t, n) {
506
- const { graph: r, linesMap: s, curves: c, config: o } = n, i = s.get(t.targetLineId);
507
- if (!i) return null;
508
- const a = Oe(i) - o.wheelbase;
506
+ const { graph: s, linesMap: r, curves: c, config: i } = n, o = r.get(t.targetLineId);
507
+ if (!o) return null;
508
+ const a = Oe(o) - i.wheelbase;
509
509
  if (a <= 0) return null;
510
510
  const u = t.isPercentage ? t.targetOffset / 100 * a : Math.min(t.targetOffset, a), d = de(
511
- r,
511
+ s,
512
512
  { lineId: e.lineId, offset: e.rear.absoluteOffset },
513
513
  t.targetLineId,
514
514
  u,
515
515
  !1
516
516
  );
517
517
  if (!d) return null;
518
- const m = Pe(d, c, s, o);
519
- return { path: d, curveDataMap: m };
518
+ const g = Pe(d, c, r, i);
519
+ return { path: d, curveDataMap: g };
520
520
  }
521
521
  function Ue({
522
522
  vehicles: e,
523
523
  lines: t,
524
524
  vehicleQueues: n,
525
- velocity: r,
526
- wheelbase: s,
525
+ velocity: s,
526
+ wheelbase: r,
527
527
  tangentMode: c,
528
- curves: o,
529
- eventEmitter: i
528
+ curves: i,
529
+ eventEmitter: o
530
530
  }) {
531
- const [f, a] = L("stopped"), [u, d] = L([]), m = Z(() => ({
532
- wheelbase: s,
531
+ const [f, a] = L("stopped"), [u, d] = L([]), g = Z(() => ({
532
+ wheelbase: r,
533
533
  tangentMode: c
534
- }), [s, c]), I = Z(
535
- () => new Map(t.map((x) => [x.id, x])),
534
+ }), [r, c]), v = Z(
535
+ () => new Map(t.map((I) => [I.id, I])),
536
536
  [t]
537
537
  ), h = P(null), l = P(/* @__PURE__ */ new Map());
538
538
  b(() => {
539
- const { movingVehicles: x, stateMap: y } = oe(e, I);
539
+ const { movingVehicles: I, stateMap: y } = oe(e, v);
540
540
  l.current = y;
541
541
  const w = setTimeout(() => {
542
- d(x);
542
+ d(I);
543
543
  }, 0);
544
544
  return () => clearTimeout(w);
545
- }, [e, I]);
545
+ }, [e, v]);
546
546
  const p = P(null);
547
547
  b(() => {
548
- t.length > 0 && (p.current = Le(t, o, m));
549
- }, [t, o, m]);
548
+ t.length > 0 && (p.current = Le(t, i, g));
549
+ }, [t, i, g]);
550
550
  const S = P(!1), M = P(() => {
551
- }), g = P(0), v = P(/* @__PURE__ */ new Set());
551
+ }), m = P(0), x = P(/* @__PURE__ */ new Set());
552
552
  b(() => {
553
553
  M.current = () => {
554
- const x = r;
554
+ const I = s;
555
555
  let y = !1;
556
556
  for (const [, w] of l.current)
557
557
  w.vehicle.state === "moving" && (y = !0);
558
558
  if (!y) {
559
- S.current = !1, g.current = 0;
559
+ S.current = !1, m.current = 0;
560
560
  return;
561
561
  }
562
- d((w) => w.map((q) => {
563
- const T = l.current.get(q.id);
564
- if (!T || q.state !== "moving" || !T.execution)
565
- return q;
562
+ d((w) => w.map((E) => {
563
+ const T = l.current.get(E.id);
564
+ if (!T || E.state !== "moving" || !T.execution)
565
+ return E;
566
566
  const $ = T.execution;
567
567
  let A;
568
568
  if ($.front.currentSegmentIndex < $.path.segments.length) {
569
569
  const N = $.path.segments[$.front.currentSegmentIndex];
570
570
  if (N.type === "line") {
571
- const V = I.get(N.lineId);
571
+ const V = v.get(N.lineId);
572
572
  V && (A = Math.sqrt(
573
573
  Math.pow(V.end.x - V.start.x, 2) + Math.pow(V.end.y - V.start.y, 2)
574
574
  ));
575
575
  }
576
576
  }
577
- const F = se(
578
- q.rear,
577
+ const F = re(
578
+ E.rear,
579
579
  $.rear,
580
580
  $.path,
581
- x,
582
581
  I,
582
+ v,
583
583
  $.curveDataMap
584
- ), R = se(
585
- q.front,
584
+ ), R = re(
585
+ E.front,
586
586
  $.front,
587
587
  $.path,
588
- x,
589
588
  I,
589
+ v,
590
590
  $.curveDataMap,
591
591
  A
592
592
  );
593
593
  if (F.completed) {
594
594
  const N = {
595
- linesMap: I,
596
- config: m,
595
+ linesMap: v,
596
+ config: g,
597
597
  vehicleQueues: n,
598
- curves: o,
598
+ curves: i,
599
599
  graphRef: p,
600
600
  prepareCommandPath: X,
601
- onCommandComplete: i ? (K) => i.emit("commandComplete", K) : void 0
601
+ onCommandComplete: o ? (K) => o.emit("commandComplete", K) : void 0
602
602
  }, V = {
603
- ...q,
603
+ ...E,
604
604
  rear: F.axleState,
605
605
  front: R.axleState
606
606
  };
607
607
  T.vehicle = V, T.execution.rear = F.execution, T.execution.front = R.execution;
608
- const re = F.execution.segmentDistance, J = ge(T, re, N);
609
- if (T.vehicle = J.vehicle, J.newExecution !== void 0 && (T.execution = J.newExecution), i) {
608
+ const se = F.execution.segmentDistance, J = me(T, se, N);
609
+ if (T.vehicle = J.vehicle, J.newExecution !== void 0 && (T.execution = J.newExecution), o && J.vehicle.state !== "moving" && o.emit("stateChange", {
610
+ vehicleId: E.id,
611
+ from: "moving",
612
+ to: J.vehicle.state
613
+ }), o) {
610
614
  const K = J.vehicle.rear.position, U = J.vehicle.front.position;
611
- i.emit("positionUpdate", {
615
+ o.emit("positionUpdate", {
612
616
  vehicleId: J.vehicle.id,
613
617
  rear: K,
614
618
  front: U,
@@ -622,13 +626,13 @@ function Ue({
622
626
  return J.vehicle;
623
627
  }
624
628
  const z = {
625
- ...q,
629
+ ...E,
626
630
  rear: F.axleState,
627
631
  front: R.axleState
628
632
  };
629
- if (T.vehicle = z, T.execution.rear = F.execution, T.execution.front = R.execution, i) {
633
+ if (T.vehicle = z, T.execution.rear = F.execution, T.execution.front = R.execution, o) {
630
634
  const N = z.rear.position, V = z.front.position;
631
- i.emit("positionUpdate", {
635
+ o.emit("positionUpdate", {
632
636
  vehicleId: z.id,
633
637
  rear: N,
634
638
  front: V,
@@ -642,20 +646,20 @@ function Ue({
642
646
  return z;
643
647
  })), S.current && (h.current = requestAnimationFrame(() => M.current()));
644
648
  };
645
- }, [r, I, o, m, n, i]), b(() => (f === "running" ? (S.current = !0, h.current = requestAnimationFrame(() => M.current())) : S.current = !1, () => {
649
+ }, [s, v, i, g, n, o]), b(() => (f === "running" ? (S.current = !0, h.current = requestAnimationFrame(() => M.current())) : S.current = !1, () => {
646
650
  h.current && cancelAnimationFrame(h.current);
647
651
  }), [f]);
648
652
  const O = G(() => {
649
653
  if (f === "running") return;
650
- const x = p.current;
651
- x && (g.current = 0, v.current.clear(), d((y) => y.map((w) => {
652
- const q = n.get(w.id);
653
- if (!q || q.length === 0)
654
+ const I = p.current;
655
+ I && (m.current = 0, x.current.clear(), d((y) => y.map((w) => {
656
+ const E = n.get(w.id);
657
+ if (!E || E.length === 0)
654
658
  return w;
655
- const T = q[0], A = X(
659
+ const T = E[0], A = X(
656
660
  w,
657
661
  T,
658
- { graph: x, linesMap: I, curves: o, config: m }
662
+ { graph: I, linesMap: v, curves: i, config: g }
659
663
  );
660
664
  if (!A)
661
665
  return console.warn(`No path found for vehicle ${w.id}`), w;
@@ -665,7 +669,7 @@ function Ue({
665
669
  A.path,
666
670
  0,
667
671
  0,
668
- s
672
+ r
669
673
  );
670
674
  F.execution = {
671
675
  path: A.path,
@@ -682,47 +686,59 @@ function Ue({
682
686
  currentSegmentIndex: 0,
683
687
  segmentDistance: 0
684
688
  }
685
- }, F.vehicle = { ...w, state: "moving" };
689
+ }, F.vehicle = { ...w, state: "moving" }, o && w.state !== "moving" && o.emit("stateChange", {
690
+ vehicleId: w.id,
691
+ from: w.state,
692
+ to: "moving"
693
+ });
686
694
  }
687
695
  return { ...w, state: "moving" };
688
696
  })), a("running"));
689
- }, [f, I, o, n, m, s]), C = G(() => {
697
+ }, [f, v, i, n, g, r, o]), C = G(() => {
690
698
  h.current && (cancelAnimationFrame(h.current), h.current = null), a("paused");
691
- }, []), E = G(() => {
699
+ }, []), q = G(() => {
692
700
  h.current && (cancelAnimationFrame(h.current), h.current = null);
693
- const { movingVehicles: x, stateMap: y } = oe(e, I);
694
- l.current = y, d(x), a("stopped");
695
- }, [e, I]), D = G((x) => {
696
- const y = l.current.get(x);
701
+ const { movingVehicles: I, stateMap: y } = oe(e, v);
702
+ l.current = y, d(I), a("stopped");
703
+ }, [e, v]), D = G((I) => {
704
+ const y = l.current.get(I);
697
705
  if (!y || y.vehicle.state !== "waiting")
698
706
  return !1;
699
- const w = n.get(x), q = y.execution;
700
- if (!q) return !1;
701
- const T = q.currentCommandIndex + 1;
707
+ const w = n.get(I), E = y.execution;
708
+ if (!E) return !1;
709
+ const T = E.currentCommandIndex + 1;
702
710
  if (w && T < w.length) {
703
711
  const $ = p.current;
704
712
  if ($) {
705
- const A = w[T], F = { graph: $, linesMap: I, curves: o, config: m }, R = X(y.vehicle, A, F);
713
+ const A = w[T], F = { graph: $, linesMap: v, curves: i, config: g }, R = X(y.vehicle, A, F);
706
714
  if (R) {
707
- const z = te(R.path, 0, 0, s);
715
+ const z = te(R.path, 0, 0, r);
708
716
  return y.execution = {
709
717
  path: R.path,
710
718
  curveDataMap: R.curveDataMap,
711
719
  currentCommandIndex: T,
712
720
  rear: { currentSegmentIndex: 0, segmentDistance: 0 },
713
721
  front: z ? { currentSegmentIndex: z.segmentIndex, segmentDistance: z.segmentDistance } : { currentSegmentIndex: 0, segmentDistance: 0 }
714
- }, y.vehicle = { ...y.vehicle, state: "moving" }, d((N) => N.map((V) => V.id === x ? y.vehicle : V)), f !== "running" && a("running"), !0;
722
+ }, y.vehicle = { ...y.vehicle, state: "moving" }, o && o.emit("stateChange", {
723
+ vehicleId: I,
724
+ from: "waiting",
725
+ to: "moving"
726
+ }), d((N) => N.map((V) => V.id === I ? y.vehicle : V)), f !== "running" && a("running"), !0;
715
727
  }
716
728
  }
717
729
  }
718
- return y.vehicle = { ...y.vehicle, state: "idle" }, y.execution = null, d(($) => $.map((A) => A.id === x ? y.vehicle : A)), !0;
719
- }, [n, I, o, m, s, f]);
730
+ return y.vehicle = { ...y.vehicle, state: "idle" }, y.execution = null, o && o.emit("stateChange", {
731
+ vehicleId: I,
732
+ from: "waiting",
733
+ to: "idle"
734
+ }), d(($) => $.map((A) => A.id === I ? y.vehicle : A)), !0;
735
+ }, [n, v, i, g, r, f, o]);
720
736
  return {
721
737
  movingVehicles: u,
722
738
  playbackState: f,
723
739
  handleRun: O,
724
740
  handlePause: C,
725
- handleReset: E,
741
+ handleReset: q,
726
742
  continueVehicle: D
727
743
  };
728
744
  }
@@ -745,11 +761,11 @@ class $e {
745
761
  * @param data - The event data
746
762
  */
747
763
  emit(t, n) {
748
- this.listeners.get(t)?.forEach((r) => {
764
+ this.listeners.get(t)?.forEach((s) => {
749
765
  try {
750
- r(n);
751
- } catch (s) {
752
- console.error(`Error in event listener for "${t}":`, s);
766
+ s(n);
767
+ } catch (r) {
768
+ console.error(`Error in event listener for "${t}":`, r);
753
769
  }
754
770
  });
755
771
  }
@@ -780,25 +796,25 @@ function We() {
780
796
  return Z(() => new $e(), []);
781
797
  }
782
798
  function Be(e, t, n = []) {
783
- const r = be();
784
- b(() => r.on(e, t), [r, e, ...n]);
799
+ const s = be();
800
+ b(() => s.on(e, t), [s, e, ...n]);
785
801
  }
786
802
  function ie(e) {
787
- const t = [], n = [], r = [], s = e.trim().split(`
803
+ const t = [], n = [], s = [], r = e.trim().split(`
788
804
  `);
789
- for (const c of s) {
790
- const o = c.trim();
791
- if (!o || o.startsWith("#")) continue;
792
- const i = o.match(/^(\w+)\s*:\s*\((\d+),\s*(\d+)\)\s*->\s*\((\d+),\s*(\d+)\)/);
793
- if (i) {
805
+ for (const c of r) {
806
+ const i = c.trim();
807
+ if (!i || i.startsWith("#")) continue;
808
+ const o = i.match(/^(\w+)\s*:\s*\((\d+),\s*(\d+)\)\s*->\s*\((\d+),\s*(\d+)\)/);
809
+ if (o) {
794
810
  t.push({
795
- id: i[1],
796
- start: { x: parseInt(i[2]), y: parseInt(i[3]) },
797
- end: { x: parseInt(i[4]), y: parseInt(i[5]) }
811
+ id: o[1],
812
+ start: { x: parseInt(o[2]), y: parseInt(o[3]) },
813
+ end: { x: parseInt(o[4]), y: parseInt(o[5]) }
798
814
  });
799
815
  continue;
800
816
  }
801
- const f = o.match(/^(\w+)(?:\s+(\d+(?:\.\d+)?)(%?))??\s*->\s*(\w+)(?:\s+(\d+(?:\.\d+)?)(%?))?/);
817
+ const f = i.match(/^(\w+)(?:\s+(\d+(?:\.\d+)?)(%?))??\s*->\s*(\w+)(?:\s+(\d+(?:\.\d+)?)(%?))?/);
802
818
  if (f) {
803
819
  const u = {
804
820
  fromLineId: f[1],
@@ -807,10 +823,10 @@ function ie(e) {
807
823
  f[2] && (u.fromOffset = parseFloat(f[2]), u.fromIsPercentage = f[3] === "%"), f[5] && (u.toOffset = parseFloat(f[5]), u.toIsPercentage = f[6] === "%"), n.push(u);
808
824
  continue;
809
825
  }
810
- const a = o.match(/^(\w+)\s+start\s+(\w+)\s+(\d+(?:\.\d+)?)(%?)/);
826
+ const a = i.match(/^(\w+)\s+start\s+(\w+)\s+(\d+(?:\.\d+)?)(%?)/);
811
827
  if (a) {
812
828
  const u = parseFloat(a[3]), d = a[4] === "%";
813
- r.push({
829
+ s.push({
814
830
  vehicleId: a[1],
815
831
  lineId: a[2],
816
832
  offset: u,
@@ -819,28 +835,28 @@ function ie(e) {
819
835
  continue;
820
836
  }
821
837
  }
822
- return { lines: t, curves: n, vehicles: r };
838
+ return { lines: t, curves: n, vehicles: s };
823
839
  }
824
- function Ee(e) {
840
+ function qe(e) {
825
841
  const t = [];
826
842
  return e.lines.forEach((n) => {
827
843
  t.push(`${n.id} : (${Math.round(n.start.x)}, ${Math.round(n.start.y)}) -> (${Math.round(n.end.x)}, ${Math.round(n.end.y)})`);
828
844
  }), e.lines.length > 0 && e.curves.length > 0 && t.push(""), e.curves.forEach((n) => {
829
- let r = `${n.fromLineId}`;
830
- n.fromOffset !== void 0 && (r += ` ${n.fromOffset}${n.fromIsPercentage ? "%" : ""}`), r += " -> ", r += `${n.toLineId}`, n.toOffset !== void 0 && (r += ` ${n.toOffset}${n.toIsPercentage ? "%" : ""}`), t.push(r);
845
+ let s = `${n.fromLineId}`;
846
+ n.fromOffset !== void 0 && (s += ` ${n.fromOffset}${n.fromIsPercentage ? "%" : ""}`), s += " -> ", s += `${n.toLineId}`, n.toOffset !== void 0 && (s += ` ${n.toOffset}${n.toIsPercentage ? "%" : ""}`), t.push(s);
831
847
  }), (e.lines.length > 0 || e.curves.length > 0) && e.vehicles.length > 0 && t.push(""), e.vehicles.forEach((n) => {
832
- const r = n.isPercentage ? `${n.offset}%` : `${n.offset}`;
833
- t.push(`${n.vehicleId} start ${n.lineId} ${r}`);
848
+ const s = n.isPercentage ? `${n.offset}%` : `${n.offset}`;
849
+ t.push(`${n.vehicleId} start ${n.lineId} ${s}`);
834
850
  }), t.join(`
835
851
  `);
836
852
  }
837
853
  function B(e) {
838
854
  const t = [], n = e.trim().split(`
839
855
  `);
840
- for (const r of n) {
841
- const s = r.trim();
842
- if (!s || s.startsWith("#")) continue;
843
- const c = s.match(/^(\w+)\s+start\s+(\w+)\s+(\d+(?:\.\d+)?)(%?)/);
856
+ for (const s of n) {
857
+ const r = s.trim();
858
+ if (!r || r.startsWith("#")) continue;
859
+ const c = r.match(/^(\w+)\s+start\s+(\w+)\s+(\d+(?:\.\d+)?)(%?)/);
844
860
  c && t.push({
845
861
  vehicleId: c[1],
846
862
  lineId: c[2],
@@ -850,7 +866,7 @@ function B(e) {
850
866
  }
851
867
  return t;
852
868
  }
853
- function qe(e) {
869
+ function Ee(e) {
854
870
  return e.map((t) => {
855
871
  const n = t.isPercentage ? `${t.offset}%` : `${t.offset}`;
856
872
  return `${t.vehicleId} start ${t.lineId} ${n}`;
@@ -860,14 +876,14 @@ function qe(e) {
860
876
  function Y(e) {
861
877
  const t = [], n = e.trim().split(`
862
878
  `);
863
- for (const r of n) {
864
- const s = r.trim();
865
- if (!s || s.startsWith("#")) continue;
866
- const c = s.match(/^(\w+)\s+goto\s+(\w+)\s+(\d+(?:\.\d+)?)(%?)/);
879
+ for (const s of n) {
880
+ const r = s.trim();
881
+ if (!r || r.startsWith("#")) continue;
882
+ const c = r.match(/^(\w+)\s+goto\s+(\w+)\s+(\d+(?:\.\d+)?)(%?)/);
867
883
  if (c) {
868
- const o = s.slice(c[0].length), i = o.includes("--wait");
884
+ const i = r.slice(c[0].length), o = i.includes("--wait");
869
885
  let f;
870
- const a = o.match(/--payload\s+(\{.*\})/);
886
+ const a = i.match(/--payload\s+(\{.*\})/);
871
887
  if (a)
872
888
  try {
873
889
  f = JSON.parse(a[1]);
@@ -879,7 +895,7 @@ function Y(e) {
879
895
  targetLineId: c[2],
880
896
  targetOffset: parseFloat(c[3]),
881
897
  isPercentage: c[4] === "%",
882
- awaitConfirmation: i,
898
+ awaitConfirmation: o,
883
899
  payload: f
884
900
  });
885
901
  }
@@ -888,240 +904,240 @@ function Y(e) {
888
904
  }
889
905
  function Re(e) {
890
906
  return e.map((t) => {
891
- const n = t.isPercentage ? `${t.targetOffset}%` : `${t.targetOffset}`, r = t.awaitConfirmation ? " --wait" : "", s = t.payload !== void 0 ? ` --payload ${JSON.stringify(t.payload)}` : "";
892
- return `${t.vehicleId} goto ${t.targetLineId} ${n}${r}${s}`;
907
+ const n = t.isPercentage ? `${t.targetOffset}%` : `${t.targetOffset}`, s = t.awaitConfirmation ? " --wait" : "", r = t.payload !== void 0 ? ` --payload ${JSON.stringify(t.payload)}` : "";
908
+ return `${t.vehicleId} goto ${t.targetLineId} ${n}${s}${r}`;
893
909
  }).join(`
894
910
  `);
895
911
  }
896
912
  function ke() {
897
- const [e, t] = L([]), [n, r] = L([]), [s, c] = L(""), [o, i] = L(null), [f, a] = L(!1), [u, d] = L(0), m = P(!1), I = P("");
913
+ const [e, t] = L([]), [n, s] = L([]), [r, c] = L(""), [i, o] = L(null), [f, a] = L(!1), [u, d] = L(0), g = P(!1), v = P("");
898
914
  return b(() => {
899
- I.current = s;
900
- }, [s]), b(() => {
901
- if (m.current)
915
+ v.current = r;
916
+ }, [r]), b(() => {
917
+ if (g.current)
902
918
  return;
903
- const h = ie(I.current), l = Ee({
919
+ const h = ie(v.current), l = qe({
904
920
  lines: e,
905
921
  curves: n,
906
922
  vehicles: h.vehicles
907
923
  });
908
- l !== I.current && (m.current = !0, c(l), setTimeout(() => {
909
- m.current = !1;
924
+ l !== v.current && (g.current = !0, c(l), setTimeout(() => {
925
+ g.current = !1;
910
926
  }, 50));
911
927
  }, [e, n]), b(() => {
912
- if (m.current)
928
+ if (g.current)
913
929
  return;
914
930
  const h = setTimeout(() => {
915
931
  a(!0), d((p) => p + 1);
916
932
  }, 0), l = setTimeout(() => {
917
933
  try {
918
- const p = ie(s);
934
+ const p = ie(r);
919
935
  a(!1);
920
936
  const S = JSON.stringify(p.lines) !== JSON.stringify(e), M = JSON.stringify(p.curves) !== JSON.stringify(n);
921
- (S || M) && (m.current = !0, S && t(p.lines), M && r(p.curves), setTimeout(() => {
922
- m.current = !1;
923
- }, 100)), i(null);
937
+ (S || M) && (g.current = !0, S && t(p.lines), M && s(p.curves), setTimeout(() => {
938
+ g.current = !1;
939
+ }, 100)), o(null);
924
940
  } catch (p) {
925
- a(!1), i(p instanceof Error ? p.message : "Invalid scene definition");
941
+ a(!1), o(p instanceof Error ? p.message : "Invalid scene definition");
926
942
  }
927
943
  }, 2e3);
928
944
  return () => {
929
945
  clearTimeout(h), clearTimeout(l);
930
946
  };
931
- }, [s, e, n]), {
947
+ }, [r, e, n]), {
932
948
  lines: e,
933
949
  curves: n,
934
- sceneDefinitionText: s,
935
- sceneError: o,
950
+ sceneDefinitionText: r,
951
+ sceneError: i,
936
952
  isDebouncing: f,
937
953
  debounceKey: u,
938
954
  setLines: t,
939
- setCurves: r,
955
+ setCurves: s,
940
956
  setSceneDefinitionText: c
941
957
  };
942
958
  }
943
959
  function k(e, t, n = 0) {
944
- const r = [], s = [], c = /* @__PURE__ */ new Set();
945
- for (const o of e) {
946
- if (c.has(o.vehicleId)) {
947
- s.push(`Duplicate vehicle ID: ${o.vehicleId}`);
960
+ const s = [], r = [], c = /* @__PURE__ */ new Set();
961
+ for (const i of e) {
962
+ if (c.has(i.vehicleId)) {
963
+ r.push(`Duplicate vehicle ID: ${i.vehicleId}`);
948
964
  continue;
949
965
  }
950
- c.add(o.vehicleId);
951
- const i = t.find((h) => h.id === o.lineId);
952
- if (!i) {
953
- s.push(`Vehicle ${o.vehicleId}: Line "${o.lineId}" not found`);
966
+ c.add(i.vehicleId);
967
+ const o = t.find((h) => h.id === i.lineId);
968
+ if (!o) {
969
+ r.push(`Vehicle ${i.vehicleId}: Line "${i.lineId}" not found`);
954
970
  continue;
955
971
  }
956
- const f = j(i.start, i.end), a = Math.max(0, f - n);
972
+ const f = j(o.start, o.end), a = Math.max(0, f - n);
957
973
  let u;
958
- if (o.isPercentage) {
959
- if (o.offset < 0 || o.offset > 100) {
960
- s.push(`Vehicle ${o.vehicleId}: Offset ${o.offset}% must be between 0% and 100%`);
974
+ if (i.isPercentage) {
975
+ if (i.offset < 0 || i.offset > 100) {
976
+ r.push(`Vehicle ${i.vehicleId}: Offset ${i.offset}% must be between 0% and 100%`);
961
977
  continue;
962
978
  }
963
- u = o.offset / 100 * a;
979
+ u = i.offset / 100 * a;
964
980
  } else {
965
- if (o.offset < 0 || o.offset > f) {
966
- s.push(`Vehicle ${o.vehicleId}: Offset ${o.offset} exceeds line length ${f.toFixed(2)}`);
981
+ if (i.offset < 0 || i.offset > f) {
982
+ r.push(`Vehicle ${i.vehicleId}: Offset ${i.offset} exceeds line length ${f.toFixed(2)}`);
967
983
  continue;
968
984
  }
969
- u = Math.min(o.offset, a);
985
+ u = Math.min(i.offset, a);
970
986
  }
971
- const d = ee(i, u, !1), m = {
972
- lineId: o.lineId,
987
+ const d = ee(o, u, !1), g = {
988
+ lineId: i.lineId,
973
989
  position: d,
974
990
  absoluteOffset: u
975
- }, I = De(
976
- o.lineId,
991
+ }, v = we(
992
+ i.lineId,
977
993
  u,
978
994
  n,
979
- i
995
+ o
980
996
  );
981
- r.push({
982
- id: o.vehicleId,
983
- lineId: o.lineId,
984
- offset: o.offset,
985
- isPercentage: o.isPercentage,
997
+ s.push({
998
+ id: i.vehicleId,
999
+ lineId: i.lineId,
1000
+ offset: i.offset,
1001
+ isPercentage: i.isPercentage,
986
1002
  state: "idle",
987
- rear: m,
988
- front: I
1003
+ rear: g,
1004
+ front: v
989
1005
  });
990
1006
  }
991
- return { vehicles: r, errors: s };
1007
+ return { vehicles: s, errors: r };
992
1008
  }
993
1009
  function Ae(e) {
994
- const t = e.map((r) => {
995
- const s = r.vehicleId.match(/^v(\d+)$/);
996
- return s ? parseInt(s[1]) : 0;
997
- }).filter((r) => r > 0);
1010
+ const t = e.map((s) => {
1011
+ const r = s.vehicleId.match(/^v(\d+)$/);
1012
+ return r ? parseInt(r[1]) : 0;
1013
+ }).filter((s) => s > 0);
998
1014
  return `v${(t.length > 0 ? Math.max(...t) : 0) + 1}`;
999
1015
  }
1000
1016
  function _(e, t, n) {
1001
- const r = [], s = [], c = /* @__PURE__ */ new Map(), o = new Set(t.map((a) => a.id)), i = new Set(n.map((a) => a.id)), f = new Map(n.map((a) => {
1017
+ const s = [], r = [], c = /* @__PURE__ */ new Map(), i = new Set(t.map((a) => a.id)), o = new Set(n.map((a) => a.id)), f = new Map(n.map((a) => {
1002
1018
  const u = a.end.x - a.start.x, d = a.end.y - a.start.y;
1003
1019
  return [a.id, Math.sqrt(u * u + d * d)];
1004
1020
  }));
1005
1021
  for (const a of e) {
1006
- if (!o.has(a.vehicleId)) {
1007
- r.push(`Vehicle "${a.vehicleId}" does not exist`);
1022
+ if (!i.has(a.vehicleId)) {
1023
+ s.push(`Vehicle "${a.vehicleId}" does not exist`);
1008
1024
  continue;
1009
1025
  }
1010
- if (!i.has(a.targetLineId)) {
1011
- r.push(`Line "${a.targetLineId}" does not exist`);
1026
+ if (!o.has(a.targetLineId)) {
1027
+ s.push(`Line "${a.targetLineId}" does not exist`);
1012
1028
  continue;
1013
1029
  }
1014
1030
  const u = f.get(a.targetLineId), d = a.isPercentage ? a.targetOffset / 100 * u : a.targetOffset;
1015
1031
  if (d < 0 || d > u) {
1016
- r.push(`Offset ${a.targetOffset}${a.isPercentage ? "%" : ""} is out of bounds for ${a.targetLineId}`);
1032
+ s.push(`Offset ${a.targetOffset}${a.isPercentage ? "%" : ""} is out of bounds for ${a.targetLineId}`);
1017
1033
  continue;
1018
1034
  }
1019
- s.push(a);
1020
- const m = c.get(a.vehicleId) || [];
1021
- m.push(a), c.set(a.vehicleId, m);
1035
+ r.push(a);
1036
+ const g = c.get(a.vehicleId) || [];
1037
+ g.push(a), c.set(a.vehicleId, g);
1022
1038
  }
1023
- return { commands: s, errors: r, vehicleQueues: c };
1039
+ return { commands: r, errors: s, vehicleQueues: c };
1024
1040
  }
1025
1041
  function Fe(e, t) {
1026
1042
  if (t.length === 0) return null;
1027
1043
  if (e.length === 0)
1028
1044
  return t[0].id;
1029
1045
  const n = /* @__PURE__ */ new Map();
1030
- for (const r of t)
1031
- n.set(r.id, 0);
1032
- for (const r of e) {
1033
- const s = n.get(r.vehicleId) || 0;
1034
- n.set(r.vehicleId, s + 1);
1046
+ for (const s of t)
1047
+ n.set(s.id, 0);
1048
+ for (const s of e) {
1049
+ const r = n.get(s.vehicleId) || 0;
1050
+ n.set(s.vehicleId, r + 1);
1035
1051
  }
1036
1052
  return t[0].id;
1037
1053
  }
1038
1054
  function Qe({ lines: e, wheelbase: t }) {
1039
- const [n, r] = L([]), [s, c] = L(""), [o, i] = L(null), [f, a] = L(!1), [u, d] = L(0), m = P(!1), I = P(e), h = P(e), l = P(t), p = P(t);
1055
+ const [n, s] = L([]), [r, c] = L(""), [i, o] = L(null), [f, a] = L(!1), [u, d] = L(0), g = P(!1), v = P(e), h = P(e), l = P(t), p = P(t);
1040
1056
  b(() => {
1041
- I.current = e;
1057
+ v.current = e;
1042
1058
  }, [e]), b(() => {
1043
1059
  l.current = t;
1044
1060
  }, [t]), b(() => {
1045
- if (m.current)
1061
+ if (g.current)
1046
1062
  return;
1047
1063
  const M = setTimeout(() => {
1048
- a(!0), d((v) => v + 1);
1049
- }, 0), g = setTimeout(() => {
1064
+ a(!0), d((x) => x + 1);
1065
+ }, 0), m = setTimeout(() => {
1050
1066
  try {
1051
- const v = B(s), { vehicles: O, errors: C } = k(
1052
- v,
1053
- I.current,
1067
+ const x = B(r), { vehicles: O, errors: C } = k(
1068
+ x,
1069
+ v.current,
1054
1070
  l.current
1055
1071
  );
1056
- a(!1), C.length > 0 ? (i(C.join(`
1057
- `)), r(O)) : (i(null), r(O));
1058
- } catch (v) {
1059
- a(!1), i(v instanceof Error ? v.message : "Invalid initial movement"), r([]);
1072
+ a(!1), C.length > 0 ? (o(C.join(`
1073
+ `)), s(O)) : (o(null), s(O));
1074
+ } catch (x) {
1075
+ a(!1), o(x instanceof Error ? x.message : "Invalid initial movement"), s([]);
1060
1076
  }
1061
1077
  }, 2e3);
1062
1078
  return () => {
1063
- clearTimeout(M), clearTimeout(g);
1079
+ clearTimeout(M), clearTimeout(m);
1064
1080
  };
1065
- }, [s]), b(() => {
1066
- if (!(JSON.stringify(h.current) !== JSON.stringify(e)) || (h.current = e, m.current || !s.trim()))
1081
+ }, [r]), b(() => {
1082
+ if (!(JSON.stringify(h.current) !== JSON.stringify(e)) || (h.current = e, g.current || !r.trim()))
1067
1083
  return;
1068
- const g = setTimeout(() => {
1084
+ const m = setTimeout(() => {
1069
1085
  try {
1070
- const v = B(s), { vehicles: O, errors: C } = k(
1071
- v,
1086
+ const x = B(r), { vehicles: O, errors: C } = k(
1087
+ x,
1072
1088
  e,
1073
1089
  l.current
1074
1090
  );
1075
- C.length > 0 ? (i(C.join(`
1076
- `)), r(O)) : (i(null), r(O));
1077
- } catch (v) {
1078
- i(v instanceof Error ? v.message : "Invalid initial movement"), r([]);
1091
+ C.length > 0 ? (o(C.join(`
1092
+ `)), s(O)) : (o(null), s(O));
1093
+ } catch (x) {
1094
+ o(x instanceof Error ? x.message : "Invalid initial movement"), s([]);
1079
1095
  }
1080
1096
  }, 0);
1081
- return () => clearTimeout(g);
1082
- }, [e, s]), b(() => {
1083
- if (p.current === t || (p.current = t, m.current || !s.trim()))
1097
+ return () => clearTimeout(m);
1098
+ }, [e, r]), b(() => {
1099
+ if (p.current === t || (p.current = t, g.current || !r.trim()))
1084
1100
  return;
1085
1101
  const M = setTimeout(() => {
1086
1102
  try {
1087
- const g = B(s), { vehicles: v, errors: O } = k(
1088
- g,
1089
- I.current,
1103
+ const m = B(r), { vehicles: x, errors: O } = k(
1104
+ m,
1105
+ v.current,
1090
1106
  t
1091
1107
  );
1092
- O.length > 0 ? (i(O.join(`
1093
- `)), r(v)) : (i(null), r(v));
1094
- } catch (g) {
1095
- i(g instanceof Error ? g.message : "Invalid initial movement"), r([]);
1108
+ O.length > 0 ? (o(O.join(`
1109
+ `)), s(x)) : (o(null), s(x));
1110
+ } catch (m) {
1111
+ o(m instanceof Error ? m.message : "Invalid initial movement"), s([]);
1096
1112
  }
1097
1113
  }, 0);
1098
1114
  return () => clearTimeout(M);
1099
- }, [t, s]);
1115
+ }, [t, r]);
1100
1116
  const S = G(() => {
1101
- const M = B(s), g = Ae(M), v = e.length > 0 ? e[0] : null;
1102
- if (!v) {
1103
- i("No lines available. Please create at least one line first.");
1117
+ const M = B(r), m = Ae(M), x = e.length > 0 ? e[0] : null;
1118
+ if (!x) {
1119
+ o("No lines available. Please create at least one line first.");
1104
1120
  return;
1105
1121
  }
1106
1122
  const O = {
1107
- vehicleId: g,
1108
- lineId: v.id,
1123
+ vehicleId: m,
1124
+ lineId: x.id,
1109
1125
  offset: 0,
1110
1126
  isPercentage: !1
1111
- }, C = [...M, O], E = qe(C), { vehicles: D, errors: x } = k(
1127
+ }, C = [...M, O], q = Ee(C), { vehicles: D, errors: I } = k(
1112
1128
  C,
1113
1129
  e,
1114
1130
  t
1115
1131
  );
1116
- m.current = !0, c(E), x.length > 0 ? i(x.join(`
1117
- `)) : i(null), r(D), setTimeout(() => {
1118
- m.current = !1;
1132
+ g.current = !0, c(q), I.length > 0 ? o(I.join(`
1133
+ `)) : o(null), s(D), setTimeout(() => {
1134
+ g.current = !1;
1119
1135
  }, 50);
1120
- }, [s, e, t]);
1136
+ }, [r, e, t]);
1121
1137
  return {
1122
1138
  vehicles: n,
1123
- initialMovementText: s,
1124
- movementError: o,
1139
+ initialMovementText: r,
1140
+ movementError: i,
1125
1141
  isDebouncing: f,
1126
1142
  debounceKey: u,
1127
1143
  setInitialMovementText: c,
@@ -1129,44 +1145,44 @@ function Qe({ lines: e, wheelbase: t }) {
1129
1145
  };
1130
1146
  }
1131
1147
  function He({ lines: e, vehicles: t }) {
1132
- const [n, r] = L(""), [s, c] = L([]), [o, i] = L(/* @__PURE__ */ new Map()), [f, a] = L(null), [u, d] = L(!1), [m, I] = L(0), h = P(!1), l = P(t), p = P(e);
1148
+ const [n, s] = L(""), [r, c] = L([]), [i, o] = L(/* @__PURE__ */ new Map()), [f, a] = L(null), [u, d] = L(!1), [g, v] = L(0), h = P(!1), l = P(t), p = P(e);
1133
1149
  b(() => {
1134
1150
  l.current = t, p.current = e;
1135
1151
  }, [t, e]), b(() => {
1136
1152
  if (h.current)
1137
1153
  return;
1138
1154
  const M = setTimeout(() => {
1139
- d(!0), I((v) => v + 1);
1140
- }, 0), g = setTimeout(() => {
1155
+ d(!0), v((x) => x + 1);
1156
+ }, 0), m = setTimeout(() => {
1141
1157
  try {
1142
- const v = Y(n), { commands: O, errors: C, vehicleQueues: E } = _(
1143
- v,
1158
+ const x = Y(n), { commands: O, errors: C, vehicleQueues: q } = _(
1159
+ x,
1144
1160
  l.current,
1145
1161
  p.current
1146
1162
  );
1147
1163
  d(!1), C.length > 0 ? a(C.join(`
1148
- `)) : a(null), c(O), i(E);
1149
- } catch (v) {
1150
- d(!1), a(v instanceof Error ? v.message : "Invalid movement sequence"), c([]), i(/* @__PURE__ */ new Map());
1164
+ `)) : a(null), c(O), o(q);
1165
+ } catch (x) {
1166
+ d(!1), a(x instanceof Error ? x.message : "Invalid movement sequence"), c([]), o(/* @__PURE__ */ new Map());
1151
1167
  }
1152
1168
  }, 2e3);
1153
1169
  return () => {
1154
- clearTimeout(M), clearTimeout(g);
1170
+ clearTimeout(M), clearTimeout(m);
1155
1171
  };
1156
1172
  }, [n]), b(() => {
1157
1173
  if (h.current || !n.trim())
1158
1174
  return;
1159
1175
  const M = setTimeout(() => {
1160
1176
  try {
1161
- const g = Y(n), { commands: v, errors: O, vehicleQueues: C } = _(
1162
- g,
1177
+ const m = Y(n), { commands: x, errors: O, vehicleQueues: C } = _(
1178
+ m,
1163
1179
  t,
1164
1180
  e
1165
1181
  );
1166
1182
  O.length > 0 ? a(O.join(`
1167
- `)) : a(null), c(v), i(C);
1168
- } catch (g) {
1169
- a(g instanceof Error ? g.message : "Invalid movement sequence"), c([]), i(/* @__PURE__ */ new Map());
1183
+ `)) : a(null), c(x), o(C);
1184
+ } catch (m) {
1185
+ a(m instanceof Error ? m.message : "Invalid movement sequence"), c([]), o(/* @__PURE__ */ new Map());
1170
1186
  }
1171
1187
  }, 0);
1172
1188
  return () => clearTimeout(M);
@@ -1180,51 +1196,51 @@ function He({ lines: e, vehicles: t }) {
1180
1196
  a("No lines available. Please create at least one line first.");
1181
1197
  return;
1182
1198
  }
1183
- const M = Y(n), g = Fe(M, t);
1184
- if (!g) {
1199
+ const M = Y(n), m = Fe(M, t);
1200
+ if (!m) {
1185
1201
  a("No vehicles available.");
1186
1202
  return;
1187
1203
  }
1188
- const v = e[0], O = {
1189
- vehicleId: g,
1190
- targetLineId: v.id,
1204
+ const x = e[0], O = {
1205
+ vehicleId: m,
1206
+ targetLineId: x.id,
1191
1207
  targetOffset: 100,
1192
1208
  isPercentage: !0
1193
- }, C = [...M, O], E = Re(C), { commands: D, errors: x, vehicleQueues: y } = _(
1209
+ }, C = [...M, O], q = Re(C), { commands: D, errors: I, vehicleQueues: y } = _(
1194
1210
  C,
1195
1211
  t,
1196
1212
  e
1197
1213
  );
1198
- h.current = !0, r(E), x.length > 0 ? a(x.join(`
1199
- `)) : a(null), c(D), i(y), setTimeout(() => {
1214
+ h.current = !0, s(q), I.length > 0 ? a(I.join(`
1215
+ `)) : a(null), c(D), o(y), setTimeout(() => {
1200
1216
  h.current = !1;
1201
1217
  }, 50);
1202
1218
  }, [n, t, e]);
1203
1219
  return {
1204
1220
  movementSequenceText: n,
1205
- gotoCommands: s,
1206
- vehicleQueues: o,
1221
+ gotoCommands: r,
1222
+ vehicleQueues: i,
1207
1223
  sequenceError: f,
1208
1224
  isDebouncing: u,
1209
- debounceKey: m,
1210
- setMovementSequenceText: r,
1225
+ debounceKey: g,
1226
+ setMovementSequenceText: s,
1211
1227
  handleAddGotoCommand: S
1212
1228
  };
1213
1229
  }
1214
1230
  function ce(e, t, n) {
1215
1231
  if (!t || !n) return { x: 0, y: 0 };
1216
- const r = t.getBoundingClientRect();
1232
+ const s = t.getBoundingClientRect();
1217
1233
  return {
1218
- x: e.clientX - r.left,
1219
- y: e.clientY - r.top
1234
+ x: e.clientX - s.left,
1235
+ y: e.clientY - s.top
1220
1236
  };
1221
1237
  }
1222
1238
  function ae(e, t, n = 10) {
1223
- for (const r of t) {
1224
- if (j(e, r.start) < n)
1225
- return { lineId: r.id, endpoint: "start" };
1226
- if (j(e, r.end) < n)
1227
- return { lineId: r.id, endpoint: "end" };
1239
+ for (const s of t) {
1240
+ if (j(e, s.start) < n)
1241
+ return { lineId: s.id, endpoint: "start" };
1242
+ if (j(e, s.end) < n)
1243
+ return { lineId: s.id, endpoint: "end" };
1228
1244
  }
1229
1245
  return null;
1230
1246
  }
@@ -1232,64 +1248,64 @@ function Xe({
1232
1248
  canvasRef: e,
1233
1249
  containerRef: t,
1234
1250
  drawMode: n,
1235
- lines: r,
1236
- curves: s,
1251
+ lines: s,
1252
+ curves: r,
1237
1253
  setLines: c,
1238
- setCurves: o,
1239
- lineCounterRef: i
1254
+ setCurves: i,
1255
+ lineCounterRef: o
1240
1256
  }) {
1241
- const [f, a] = L(!1), [u, d] = L(null), [m, I] = L(null), [h, l] = L(null), [p, S] = L(null), [M, g] = L({ x: 0, y: 0 });
1257
+ const [f, a] = L(!1), [u, d] = L(null), [g, v] = L(null), [h, l] = L(null), [p, S] = L(null), [M, m] = L({ x: 0, y: 0 });
1242
1258
  return {
1243
- handleMouseDown: (E) => {
1244
- const D = ce(E, e.current, t.current), x = ae(D, r);
1259
+ handleMouseDown: (q) => {
1260
+ const D = ce(q, e.current, t.current), I = ae(D, s);
1245
1261
  if (n === "line")
1246
- x || (a(!0), d({ start: D, current: D }));
1262
+ I || (a(!0), d({ start: D, current: D }));
1247
1263
  else if (n === "drag")
1248
- x && l(x);
1264
+ I && l(I);
1249
1265
  else if (n === "curve")
1250
- if (x)
1266
+ if (I)
1251
1267
  if (!p)
1252
- S(x);
1268
+ S(I);
1253
1269
  else {
1254
- if (p.lineId !== x.lineId) {
1270
+ if (p.lineId !== I.lineId) {
1255
1271
  const y = {
1256
1272
  fromLineId: p.lineId,
1257
- toLineId: x.lineId
1273
+ toLineId: I.lineId
1258
1274
  };
1259
- o([...s, y]);
1275
+ i([...r, y]);
1260
1276
  }
1261
1277
  S(null);
1262
1278
  }
1263
1279
  else
1264
1280
  p && S(null);
1265
1281
  },
1266
- handleMouseMove: (E) => {
1267
- const D = ce(E, e.current, t.current);
1268
- if (g(D), f && u)
1282
+ handleMouseMove: (q) => {
1283
+ const D = ce(q, e.current, t.current);
1284
+ if (m(D), f && u)
1269
1285
  d({ ...u, current: D });
1270
1286
  else if (h) {
1271
- const x = r.map((y) => y.id === h.lineId ? h.endpoint === "start" ? { ...y, start: D } : { ...y, end: D } : y);
1272
- c(x);
1287
+ const I = s.map((y) => y.id === h.lineId ? h.endpoint === "start" ? { ...y, start: D } : { ...y, end: D } : y);
1288
+ c(I);
1273
1289
  } else {
1274
- const x = ae(D, r);
1275
- I(x);
1290
+ const I = ae(D, s);
1291
+ v(I);
1276
1292
  }
1277
1293
  },
1278
1294
  handleMouseUp: () => {
1279
1295
  if (f && u) {
1280
1296
  if (j(u.start, u.current) > 20) {
1281
1297
  const D = {
1282
- id: `line${String(i.current).padStart(3, "0")}`,
1298
+ id: `line${String(o.current).padStart(3, "0")}`,
1283
1299
  start: u.start,
1284
1300
  end: u.current
1285
1301
  };
1286
- i.current++, c([...r, D]);
1302
+ o.current++, c([...s, D]);
1287
1303
  }
1288
1304
  d(null), a(!1);
1289
1305
  } else h && l(null);
1290
1306
  },
1291
1307
  tempLine: u,
1292
- hoveredEndpoint: m,
1308
+ hoveredEndpoint: g,
1293
1309
  curveStart: p,
1294
1310
  mousePos: M
1295
1311
  };
@@ -1302,7 +1318,7 @@ export {
1302
1318
  Le as buildGraph,
1303
1319
  Me as calculateBezierArcLength,
1304
1320
  te as calculateFrontAxlePosition,
1305
- De as calculateInitialFrontPosition,
1321
+ we as calculateInitialFrontPosition,
1306
1322
  H as calculatePositionOnCurve,
1307
1323
  W as calculatePositionOnLine,
1308
1324
  Je as canReachTarget,
@@ -1313,19 +1329,19 @@ export {
1313
1329
  ye as distanceToT,
1314
1330
  de as findPath,
1315
1331
  Re as generateGotoCommands,
1316
- Ee as generateSceneDefinition,
1317
- qe as generateVehicleStarts,
1332
+ qe as generateSceneDefinition,
1333
+ Ee as generateVehicleStarts,
1318
1334
  je as getArcLength,
1319
1335
  Se as getCumulativeArcLength,
1320
1336
  Oe as getLineLength,
1321
1337
  ne as getPointOnBezier,
1322
1338
  ve as getPointOnLine,
1323
1339
  ee as getPointOnLineByOffset,
1324
- me as getPositionFromOffset,
1340
+ ge as getPositionFromOffset,
1325
1341
  Ke as getReachableCurves,
1326
- ge as handleArrival,
1342
+ me as handleArrival,
1327
1343
  oe as initializeAllVehicles,
1328
- we as initializeMovingVehicle,
1344
+ De as initializeMovingVehicle,
1329
1345
  Q as normalize,
1330
1346
  Y as parseGotoCommands,
1331
1347
  ie as parseSceneDefinition,
@@ -1334,7 +1350,7 @@ export {
1334
1350
  fe as resolveFromLineOffset,
1335
1351
  ze as resolveOffset,
1336
1352
  le as resolveToLineOffset,
1337
- se as updateAxlePosition,
1353
+ re as updateAxlePosition,
1338
1354
  Xe as useCanvasInteraction,
1339
1355
  We as useCreateVehicleEventEmitter,
1340
1356
  Qe as useInitialMovement,