@m4l/gclick-realtime 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,25 @@
1
- import { GNSSEnumSignal as M, GNSSEnumMotionStatus as d, ADCPowerEnum as I } from "../../contracts/constants.js";
2
- import { calculateDistanceMeters as K, calculatePolylineDistanceMeters as $, resolveFrameSpeedKph as Y, interpolateCoordinate as H, calculateCourseDegrees as W } from "../shared/helpers.js";
3
- import { createRealTimeDummySimulationConfigFromPreset as Z, REAL_TIME_DUMMY_SIMULATION_PRESETS as z } from "../catalogs/presets.js";
4
- import { REAL_TIME_DUMMY_DEFAULT_SCENARIO_ID as J, REAL_TIME_DUMMY_SCENARIOS as L, REAL_TIME_DUMMY_DEFAULT_PLAYBACK as E } from "../catalogs/scenarios.js";
5
- import h from "../../node_modules/lodash-es/cloneDeep.js";
6
- import { REAL_TIME_DUMMY_ROUTE_TEMPLATES as _ } from "../catalogs/routes.js";
7
- import { REAL_TIME_DUMMY_EXECUTION_PLANS as P } from "../catalogs/plans.js";
8
- import { REAL_TIME_DUMMY_DEVICE_BLUEPRINTS as O } from "../catalogs/blueprints.js";
9
- import U from "../../node_modules/lodash-es/merge.js";
10
- import { REAL_TIME_DUMMY_DEFAULT_ICON_ID as Q, REAL_TIME_DUMMY_BASE_DEVICE_TEMPLATE as ee } from "../catalogs/baseDeviceTemplate.js";
11
- const k = Date.parse("2026-04-21T12:00:00.000Z");
12
- function T(e, t) {
13
- return Object.hasOwn(e, t);
14
- }
15
- function te(e) {
1
+ import { getVptValueWithGuard as Z } from "../../payload/getVptValueWithGuard.js";
2
+ import { GNSSEnumSignal as S, GNSSEnumMotionStatus as d, ADCPowerEnum as E } from "../../contracts/constants.js";
3
+ import { calculateDistanceMeters as N, calculatePolylineDistanceMeters as z, resolveFrameSpeedKph as J, interpolateCoordinate as Q, calculateCourseDegrees as ee } from "../shared/helpers.js";
4
+ import { createRealTimeDummySimulationConfigFromPreset as te, REAL_TIME_DUMMY_SIMULATION_PRESETS as ne } from "../catalogs/presets.js";
5
+ import { REAL_TIME_DUMMY_DEFAULT_SCENARIO_ID as se, REAL_TIME_DUMMY_SCENARIOS as G, REAL_TIME_DUMMY_DEFAULT_PLAYBACK as R } from "../catalogs/scenarios.js";
6
+ import M from "../../node_modules/lodash-es/cloneDeep.js";
7
+ import { REAL_TIME_DUMMY_ROUTE_TEMPLATES as U } from "../catalogs/routes.js";
8
+ import { REAL_TIME_DUMMY_EXECUTION_PLANS as x } from "../catalogs/plans.js";
9
+ import { REAL_TIME_DUMMY_DEVICE_BLUEPRINTS as F } from "../catalogs/blueprints.js";
10
+ import T from "../../node_modules/lodash-es/merge.js";
11
+ import { REAL_TIME_DUMMY_DEFAULT_ICON_ID as oe, REAL_TIME_DUMMY_BASE_DEVICE_TEMPLATE as ie } from "../catalogs/baseDeviceTemplate.js";
12
+ import I from "../../node_modules/lodash-es/unset.js";
13
+ const V = Date.parse("2026-04-21T12:00:00.000Z"), $ = [
14
+ "gnssCourse",
15
+ "gnssLatitude",
16
+ "gnssLongitude",
17
+ "gnssSpeed"
18
+ ];
19
+ function C(e, n) {
20
+ return Object.hasOwn(e, n);
21
+ }
22
+ function ae(e) {
16
23
  if (e)
17
24
  return {
18
25
  bgColor: e.color,
@@ -20,7 +27,7 @@ function te(e) {
20
27
  name: e.name
21
28
  };
22
29
  }
23
- function ne(e) {
30
+ function re(e) {
24
31
  if (e)
25
32
  return {
26
33
  color: e.bgColor,
@@ -28,176 +35,213 @@ function ne(e) {
28
35
  name: e.name
29
36
  };
30
37
  }
31
- function D(e, t) {
38
+ function y(e, n) {
32
39
  if (!e)
33
40
  return e;
34
- const n = Date.parse(e);
35
- return Number.isFinite(n) ? new Date(
36
- t + (n - k)
41
+ const t = Date.parse(e);
42
+ return Number.isFinite(t) ? new Date(
43
+ n + (t - V)
37
44
  ).toISOString() : e;
38
45
  }
39
- function C(e, t) {
40
- return e.reportProfiles?.trackerEvents && (e.reportProfiles.trackerEvents.modemLastEvent = {
41
- ...e.reportProfiles.trackerEvents.modemLastEvent,
42
- date: D(
46
+ function _(e) {
47
+ return typeof e == "object" && e !== null && "value" in e;
48
+ }
49
+ function ce(e, n, t) {
50
+ const o = e.vpts?.vptGnss?.[n];
51
+ _(o) && (o.updatedAt = y(
52
+ o.updatedAt,
53
+ t
54
+ ));
55
+ }
56
+ function le(e, n, t) {
57
+ const o = e.vpts?.vptGnss?.[n];
58
+ _(o) && (o.updatedAt = t);
59
+ }
60
+ function b(e, n, t) {
61
+ return _(e) ? {
62
+ ...e,
63
+ updatedAt: t,
64
+ value: n
65
+ } : n;
66
+ }
67
+ function X(e, n) {
68
+ if (e.reportProfiles?.trackerEvents) {
69
+ const t = y(
43
70
  e.reportProfiles.trackerEvents.modemLastEvent?.date,
44
- t
45
- ) ?? e.reportProfiles.trackerEvents.modemLastEvent?.date ?? new Date(t).toISOString()
46
- }), Object.values(e.vpts?.vptDiX ?? {}).forEach((n) => {
47
- n.diXStatus && (n.diXStatus.updatedAt = D(
48
- n.diXStatus.updatedAt,
49
- t
50
- )), n.diXValue && (n.diXValue.updatedAt = D(
51
- n.diXValue.updatedAt,
52
- t
71
+ n
72
+ );
73
+ e.reportProfiles.trackerEvents.modemLastEvent && t && (e.reportProfiles.trackerEvents.modemLastEvent = {
74
+ ...e.reportProfiles.trackerEvents.modemLastEvent,
75
+ date: t
76
+ });
77
+ }
78
+ if (Object.values(e.vpts?.vptDiX ?? {}).forEach((t) => {
79
+ t.diXStatus && (t.diXStatus.updatedAt = y(
80
+ t.diXStatus.updatedAt,
81
+ n
82
+ )), t.diXValue && (t.diXValue.updatedAt = y(
83
+ t.diXValue.updatedAt,
84
+ n
53
85
  ));
54
- }), Object.values(e.vpts?.vptDoX ?? {}).forEach((n) => {
55
- n.diXValue && (n.diXValue.updatedAt = D(
56
- n.diXValue.updatedAt,
57
- t
86
+ }), Object.values(e.vpts?.vptDoX ?? {}).forEach((t) => {
87
+ t.diXValue && (t.diXValue.updatedAt = y(
88
+ t.diXValue.updatedAt,
89
+ n
58
90
  ));
59
- }), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = D(
91
+ }), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = y(
60
92
  e.vpts.vptGnss.gnssMotionStatus.updatedAt,
61
- t
62
- )), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = D(
93
+ n
94
+ )), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = y(
63
95
  e.vpts.vptGnss.gnssSignal.updatedAt,
64
- t
65
- )), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = D(
96
+ n
97
+ )), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = y(
66
98
  e.vpts.vptIgnition.ignitionValue.updatedAt,
67
- t
68
- )), e.vpts?.vptModem && (e.vpts.vptModem.modemLastConnection = D(
69
- e.vpts.vptModem.modemLastConnection,
70
- t
71
- ) ?? e.vpts.vptModem.modemLastConnection, e.vpts.vptModem.modemLastEvent = D(
72
- e.vpts.vptModem.modemLastEvent,
73
- t
74
- ) ?? e.vpts.vptModem.modemLastEvent), e;
75
- }
76
- function se(e, t) {
77
- const n = h(e);
78
- return C(n.current, t), n;
79
- }
80
- function ie(e, t) {
81
- const n = h(e), i = new Date(t).toISOString();
82
- return n.current.reportProfiles?.trackerEvents && (n.current.reportProfiles.trackerEvents.modemLastEvent = {
83
- ...n.current.reportProfiles.trackerEvents.modemLastEvent,
84
- date: i
85
- }), Object.values(n.current.vpts?.vptDiX ?? {}).forEach((s) => {
86
- s.diXStatus && (s.diXStatus.updatedAt = i), s.diXValue && (s.diXValue.updatedAt = i);
87
- }), Object.values(n.current.vpts?.vptDoX ?? {}).forEach((s) => {
88
- s.diXValue && (s.diXValue.updatedAt = i);
89
- }), n.current.vpts?.vptGnss?.gnssMotionStatus && (n.current.vpts.vptGnss.gnssMotionStatus.updatedAt = i), n.current.vpts?.vptGnss?.gnssSignal && (n.current.vpts.vptGnss.gnssSignal.updatedAt = i), n.current.vpts?.vptIgnition?.ignitionValue && (n.current.vpts.vptIgnition.ignitionValue.updatedAt = i), n.current.vpts?.vptModem && (n.current.vpts.vptModem.modemLastConnection = i, n.current.vpts.vptModem.modemLastEvent = i), n;
90
- }
91
- function oe(e, t) {
92
- const n = h(e);
93
- if (n.type === "delete")
94
- return n;
95
- if (n.type === "new") {
96
- const i = n.payload;
97
- return C(i.current, t), n;
99
+ n
100
+ )), $.forEach((t) => {
101
+ ce(e, t, n);
102
+ }), e.vpts?.vptModem) {
103
+ const t = y(
104
+ e.vpts.vptModem.modemLastConnection,
105
+ n
106
+ ), o = y(
107
+ e.vpts.vptModem.modemLastEvent,
108
+ n
109
+ );
110
+ t && (e.vpts.vptModem.modemLastConnection = t), o && (e.vpts.vptModem.modemLastEvent = o);
98
111
  }
99
- return C(
100
- n.payload.current,
101
- t
102
- ), n;
112
+ return e;
113
+ }
114
+ function ue(e, n) {
115
+ const t = M(e);
116
+ return X(t.current, n), t;
117
+ }
118
+ function de(e, n) {
119
+ const t = M(e), o = new Date(n).toISOString();
120
+ return t.current.reportProfiles?.trackerEvents?.modemLastEvent && (t.current.reportProfiles.trackerEvents.modemLastEvent = {
121
+ ...t.current.reportProfiles.trackerEvents.modemLastEvent,
122
+ date: o
123
+ }), Object.values(t.current.vpts?.vptDiX ?? {}).forEach((s) => {
124
+ s.diXStatus && (s.diXStatus.updatedAt = o), s.diXValue && (s.diXValue.updatedAt = o);
125
+ }), Object.values(t.current.vpts?.vptDoX ?? {}).forEach((s) => {
126
+ s.diXValue && (s.diXValue.updatedAt = o);
127
+ }), t.current.vpts?.vptGnss?.gnssMotionStatus && (t.current.vpts.vptGnss.gnssMotionStatus.updatedAt = o), t.current.vpts?.vptGnss?.gnssSignal && (t.current.vpts.vptGnss.gnssSignal.updatedAt = o), t.current.vpts?.vptIgnition?.ignitionValue && (t.current.vpts.vptIgnition.ignitionValue.updatedAt = o), $.forEach((s) => {
128
+ le(
129
+ t.current,
130
+ s,
131
+ o
132
+ );
133
+ }), t.current.vpts?.vptModem && (t.current.vpts.vptModem.modemLastConnection && (t.current.vpts.vptModem.modemLastConnection = o), t.current.vpts.vptModem.modemLastEvent && (t.current.vpts.vptModem.modemLastEvent = o)), t;
134
+ }
135
+ function pe(e, n) {
136
+ const t = M(e);
137
+ if (t.type === "delete")
138
+ return t;
139
+ if (t.type === "new") {
140
+ const o = t.payload;
141
+ return X(o.current, n), t;
142
+ }
143
+ return X(
144
+ t.payload.current,
145
+ n
146
+ ), t;
103
147
  }
104
- function x(e, t) {
148
+ function K(e, n) {
105
149
  return {
106
- ...E,
150
+ ...R,
107
151
  ...e,
108
- ...t,
152
+ ...n,
109
153
  framesPerTick: Math.max(
110
154
  1,
111
- t?.framesPerTick ?? e?.framesPerTick ?? E.framesPerTick
155
+ n?.framesPerTick ?? e?.framesPerTick ?? R.framesPerTick
112
156
  ),
113
157
  intervalMs: Math.max(
114
158
  1,
115
- t?.intervalMs ?? e?.intervalMs ?? E.intervalMs
159
+ n?.intervalMs ?? e?.intervalMs ?? R.intervalMs
116
160
  ),
117
161
  logicalSampleSeconds: Math.max(
118
162
  1,
119
- t?.logicalSampleSeconds ?? e?.logicalSampleSeconds ?? E.logicalSampleSeconds
163
+ n?.logicalSampleSeconds ?? e?.logicalSampleSeconds ?? R.logicalSampleSeconds
120
164
  )
121
165
  };
122
166
  }
123
- function ae(e) {
124
- if (!T(O, e))
167
+ function me(e) {
168
+ if (!C(F, e))
125
169
  throw new Error(`Unknown dummy blueprint "${e}"`);
126
- return O[e];
170
+ return F[e];
127
171
  }
128
- function re(e) {
129
- if (!T(_, e))
172
+ function ve(e) {
173
+ if (!C(U, e))
130
174
  throw new Error(`Unknown dummy route "${e}"`);
131
- return _[e];
175
+ return U[e];
132
176
  }
133
- function ce(e) {
134
- if (!T(P, e))
177
+ function ge(e) {
178
+ if (!C(x, e))
135
179
  throw new Error(`Unknown dummy plan "${e}"`);
136
- return P[e];
180
+ return x[e];
137
181
  }
138
- function le(e) {
139
- const t = z[e];
140
- if (!t)
182
+ function fe(e) {
183
+ const n = ne[e];
184
+ if (!n)
141
185
  throw new Error(`Unknown dummy simulation preset "${e}"`);
142
- return t;
186
+ return n;
143
187
  }
144
- function ue(e) {
145
- const t = e.reduce(
146
- (n, i, s, o) => {
147
- const a = i.assignment.resourceSerialId;
148
- return o.findIndex((c) => c.assignment.resourceSerialId === a) !== s && !n.includes(a) && n.push(a), n;
188
+ function Me(e) {
189
+ const n = e.reduce(
190
+ (t, o, s, i) => {
191
+ const a = o.assignment.resourceSerialId;
192
+ return i.findIndex((c) => c.assignment.resourceSerialId === a) !== s && !t.includes(a) && t.push(a), t;
149
193
  },
150
194
  []
151
195
  );
152
- if (t.length)
196
+ if (n.length)
153
197
  throw new Error(
154
- `Dummy simulation resolved duplicate device ids: ${t.join(", ")}. Each preset must contribute its own unique resourceSerialId values.`
198
+ `Dummy simulation resolved duplicate device ids: ${n.join(", ")}. Each preset must contribute its own unique resourceSerialId values.`
155
199
  );
156
200
  }
157
- function de(e) {
158
- const t = e?.presetId, n = t ? le(t).simulation : void 0, i = e?.scenarioId ?? n?.scenarioId ?? J;
159
- if (!T(L, i))
160
- throw new Error(`Unknown dummy scenario "${i}"`);
161
- const s = L[i], o = (e?.devices ?? n?.devices ?? s.devices).map(
201
+ function ye(e) {
202
+ const n = e?.presetId, t = n ? fe(n).simulation : void 0, o = e?.scenarioId ?? t?.scenarioId ?? se;
203
+ if (!C(G, o))
204
+ throw new Error(`Unknown dummy scenario "${o}"`);
205
+ const s = G[o], i = (e?.devices ?? t?.devices ?? s.devices).map(
162
206
  (a) => ({
163
207
  assignment: a,
164
- blueprint: ae(a.blueprintId),
165
- plan: ce(a.planId),
166
- route: re(a.routeId)
208
+ blueprint: me(a.blueprintId),
209
+ plan: ge(a.planId),
210
+ route: ve(a.routeId)
167
211
  })
168
212
  );
169
- return ue(o), {
170
- devices: o,
171
- playback: x(
172
- x(s.playback, n?.playback),
213
+ return Me(i), {
214
+ devices: i,
215
+ playback: K(
216
+ K(s.playback, t?.playback),
173
217
  e?.playback
174
218
  )
175
219
  };
176
220
  }
177
- function q(e) {
221
+ function j(e) {
178
222
  switch (e) {
179
- case M.noSignal:
223
+ case S.noSignal:
180
224
  return 2;
181
- case M.acceptable:
225
+ case S.acceptable:
182
226
  return 19;
183
- case M.reliable:
227
+ case S.reliable:
184
228
  default:
185
229
  return 31;
186
230
  }
187
231
  }
188
- function pe(e) {
232
+ function Se(e) {
189
233
  switch (e) {
190
- case M.noSignal:
234
+ case S.noSignal:
191
235
  return {
192
236
  gnssHdop: 4.9,
193
237
  gnssSatellitesInUse: 0
194
238
  };
195
- case M.acceptable:
239
+ case S.acceptable:
196
240
  return {
197
241
  gnssHdop: 1.7,
198
242
  gnssSatellitesInUse: 8
199
243
  };
200
- case M.reliable:
244
+ case S.reliable:
201
245
  default:
202
246
  return {
203
247
  gnssHdop: 0.8,
@@ -205,21 +249,21 @@ function pe(e) {
205
249
  };
206
250
  }
207
251
  }
208
- function A(e, t, n) {
209
- return Math.min(n, Math.max(t, e));
252
+ function P(e, n, t) {
253
+ return Math.min(t, Math.max(n, e));
210
254
  }
211
- function F(e) {
255
+ function q(e) {
212
256
  return Math.round(e * 10) / 10;
213
257
  }
214
- function b(e, t) {
215
- return e <= 0 ? I.lost : t === "12" ? e >= 12.4 ? I.ok : I.low : e >= 24.8 ? I.ok : I.low;
258
+ function w(e, n) {
259
+ return e <= 0 ? E.lost : n === "12" ? e >= 12.4 ? E.ok : E.low : e >= 24.8 ? E.ok : E.low;
216
260
  }
217
- function G(e) {
218
- const t = (e - 24.3) / 3.599999999999998;
219
- return Math.round(A(t, 0, 1) * 100);
261
+ function B(e) {
262
+ const n = (e - 24.3) / 3.599999999999998;
263
+ return Math.round(P(n, 0, 1) * 100);
220
264
  }
221
- function R(e, t) {
222
- const n = [0, 0.04, -0.03, 0.06, -0.02], i = n[t % n.length] ?? 0;
265
+ function k(e, n) {
266
+ const t = [0, 0.04, -0.03, 0.06, -0.02], o = t[n % t.length] ?? 0;
223
267
  let s = e.ignition ? 13.6 : 12.3;
224
268
  switch (e.motionStatus) {
225
269
  case d.off:
@@ -245,153 +289,156 @@ function R(e, t) {
245
289
  s = e.ignition ? 13.6 : 12.3;
246
290
  break;
247
291
  }
248
- e.signal === M.noSignal && (s -= 0.2);
249
- let o = e.ignition ? 26.3 : 25.2;
292
+ e.signal === S.noSignal && (s -= 0.2);
293
+ let i = e.ignition ? 26.3 : 25.2;
250
294
  switch (e.motionStatus) {
251
295
  case d.off:
252
- o = 25;
296
+ i = 25;
253
297
  break;
254
298
  case d.towing:
255
- o = 24.9;
299
+ i = 24.9;
256
300
  break;
257
301
  case d.stopped:
258
- o = e.ignition ? 25.4 : 25;
302
+ i = e.ignition ? 25.4 : 25;
259
303
  break;
260
304
  case d.stoppedRalenti:
261
- o = 26.1;
305
+ i = 26.1;
262
306
  break;
263
307
  case d.stoppedExcesiveRalenti:
264
- o = 25.9;
308
+ i = 25.9;
265
309
  break;
266
310
  case d.maxSpeed:
267
- o = 26.6;
311
+ i = 26.6;
268
312
  break;
269
313
  case d.moving:
270
314
  default:
271
- o = e.ignition ? 26.4 : 25.2;
315
+ i = e.ignition ? 26.4 : 25.2;
272
316
  break;
273
317
  }
274
- e.signal === M.acceptable && (o -= 0.2), e.signal === M.noSignal && (o -= 0.5);
275
- const a = F(A(s + i, 11.8, 13.9)), r = F(A(o + i * 2, 24, 27.9));
318
+ e.signal === S.acceptable && (i -= 0.2), e.signal === S.noSignal && (i -= 0.5);
319
+ const a = q(P(s + o, 11.8, 13.9)), r = q(P(i + o * 2, 24, 27.9));
276
320
  return {
277
- backupChargeLevel: G(r),
278
- backupStatus: b(r, "24"),
321
+ backupChargeLevel: B(r),
322
+ backupStatus: w(r, "24"),
279
323
  backupVolt: r,
280
- mainStatus: b(a, "12"),
324
+ mainStatus: w(a, "12"),
281
325
  mainVolt: a
282
326
  };
283
327
  }
284
- function me(e) {
328
+ function De(e) {
285
329
  return Object.fromEntries(
286
- Object.entries(e.vpts?.vptDiX ?? {}).map(([t, n]) => [t, n.diXValue.value])
330
+ Object.entries(e.vpts?.vptDiX ?? {}).map(([n, t]) => [n, t.diXValue.value])
287
331
  );
288
332
  }
289
- function ve(e) {
333
+ function he(e) {
290
334
  return Object.fromEntries(
291
- Object.entries(e.vpts?.vptDoX ?? {}).map(([t, n]) => [t, n.diXValue.value])
335
+ Object.entries(e.vpts?.vptDoX ?? {}).map(([n, t]) => [n, t.diXValue.value])
292
336
  );
293
337
  }
294
- function X(e, t) {
295
- return e.motionStatus !== void 0 ? e.motionStatus : t.ignition ? e.speedKph >= 55 ? d.maxSpeed : d.moving : d.towing;
338
+ function O(e, n) {
339
+ return e.motionStatus !== void 0 ? e.motionStatus : n.ignition ? e.speedKph >= 55 ? d.maxSpeed : d.moving : d.towing;
296
340
  }
297
- function N(e, t) {
298
- return e.motionStatus !== void 0 ? e.motionStatus : t.ignition ? d.stopped : d.off;
341
+ function Y(e, n) {
342
+ return e.motionStatus !== void 0 ? e.motionStatus : n.ignition ? d.stopped : d.off;
299
343
  }
300
- function j(e, t) {
301
- const n = t.signal ?? e.signal;
344
+ function W(e, n) {
345
+ const t = n.signal ?? e.signal;
302
346
  return {
303
- diX: t.diX ? { ...e.diX, ...t.diX } : { ...e.diX },
304
- doX: t.doX ? { ...e.doX, ...t.doX } : { ...e.doX },
305
- ignition: t.ignition ?? e.ignition,
306
- modemCsq: t.modemCsq ?? (t.signal !== void 0 ? q(n) : e.modemCsq),
307
- signal: n
347
+ diX: n.diX ? { ...e.diX, ...n.diX } : { ...e.diX },
348
+ doX: n.doX ? { ...e.doX, ...n.doX } : { ...e.doX },
349
+ ignition: n.ignition ?? e.ignition,
350
+ modemCsq: n.modemCsq ?? (n.signal !== void 0 ? j(t) : e.modemCsq),
351
+ signal: t
308
352
  };
309
353
  }
310
- function ge(e, t) {
311
- return e.omitDeviceIcon ?? t.omitDeviceIcon ?? !1;
354
+ function Ee(e, n) {
355
+ return e.omitDeviceIcon ?? n.omitDeviceIcon ?? !1;
312
356
  }
313
- function fe(e, t) {
314
- const n = h(ee);
315
- U(n.current, t.currentPatch ?? {}), U(n.settings, t.settingsPatch ?? {}), n.settings.active = e.active ?? t.active ?? n.settings.active, n.settings.alias = e.alias ?? t.alias ?? n.settings.alias;
316
- const i = e.group ?? t.group ?? n.settings.group, s = e.department ?? t.department ?? n.department ?? ne(i);
317
- return n.department = s, n.settings.group = i ?? te(s), n.settings.iconBgColor = e.iconBgColor ?? t.iconBgColor ?? n.settings.iconBgColor, ge(e, t) ? n.deviceIcon = void 0 : (n.deviceIcon ??= {
357
+ function Ie(e, n) {
358
+ const t = M(ie);
359
+ T(t.current, n.currentPatch ?? {}), T(t.current, e.currentPatch ?? {}), T(t.settings, n.settingsPatch ?? {}), t.settings.active = e.active ?? n.active ?? t.settings.active, t.settings.alias = e.alias ?? n.alias ?? t.settings.alias;
360
+ const o = e.group ?? n.group ?? t.settings.group, s = e.department ?? n.department ?? t.department ?? re(o);
361
+ return t.department = s, t.settings.group = o ?? ae(s), t.settings.iconBgColor = e.iconBgColor ?? n.iconBgColor ?? t.settings.iconBgColor, Ee(e, n) ? t.deviceIcon = void 0 : (t.deviceIcon ??= {
318
362
  id: "dummy-device-icon",
319
- iconId: Q
320
- }, n.deviceIcon.iconId = e.iconId ?? t.iconId ?? n.deviceIcon.iconId), n.settings.name = e.name ?? t.name, n.settings.properties?.internal_name && (n.settings.properties.internal_name.value = `${n.settings.name}-${e.resourceSerialId}`), {
321
- ...n,
363
+ iconId: oe
364
+ }, t.deviceIcon.iconId = e.iconId ?? n.iconId ?? t.deviceIcon.iconId), t.settings.name = e.name ?? n.name, t.settings.properties?.internal_name && (t.settings.properties.internal_name.value = `${t.settings.name}-${e.resourceSerialId}`), {
365
+ ...t,
322
366
  resourceSerialId: Number(e.resourceSerialId)
323
367
  };
324
368
  }
325
- function Me(e) {
326
- const t = e.current.vpts?.vptGnss?.gnssSignal?.value ?? M.reliable;
369
+ function Te(e) {
370
+ const n = e.current.vpts?.vptGnss?.gnssSignal?.value ?? S.reliable;
327
371
  return {
328
- diX: me(e.current),
329
- doX: ve(e.current),
372
+ diX: De(e.current),
373
+ doX: he(e.current),
330
374
  ignition: e.current.vpts?.vptIgnition?.ignitionValue.value ?? !0,
331
- modemCsq: e.current.vpts?.vptModem?.modemCsq ?? q(t),
332
- signal: t
375
+ modemCsq: Z(
376
+ e.current.vpts?.vptModem?.modemCsq,
377
+ j(n)
378
+ ),
379
+ signal: n
333
380
  };
334
381
  }
335
- function De(e, t) {
382
+ function Re(e, n) {
336
383
  if (e.playbackOffsetSeconds !== void 0)
337
384
  return Math.max(0, e.playbackOffsetSeconds);
338
- const n = Number(e.resourceSerialId);
339
- return Number.isFinite(n) ? Math.abs(n) % 12 * t.logicalSampleSeconds * 4 : 0;
385
+ const t = Number(e.resourceSerialId);
386
+ return Number.isFinite(t) ? Math.abs(t) % 12 * n.logicalSampleSeconds * 4 : 0;
340
387
  }
341
- function Se(e, t) {
388
+ function be(e, n) {
342
389
  if (e.emissionOffsetMs !== void 0)
343
- return Math.max(0, e.emissionOffsetMs % t.intervalMs);
344
- const n = Number(e.resourceSerialId);
345
- return Number.isFinite(n) ? Math.abs(n * 137 % t.intervalMs) : 0;
390
+ return Math.max(0, e.emissionOffsetMs % n.intervalMs);
391
+ const t = Number(e.resourceSerialId);
392
+ return Number.isFinite(t) ? Math.abs(t * 137 % n.intervalMs) : 0;
346
393
  }
347
- function ye(e) {
394
+ function we(e) {
348
395
  return {
349
- cumulativeDistancesMeters: e.waypoints.reduce((n, i, s, o) => {
396
+ cumulativeDistancesMeters: e.waypoints.reduce((t, o, s, i) => {
350
397
  if (s === 0)
351
- return n.push(0), n;
352
- const a = o[s - 1], r = n[s - 1] ?? 0;
353
- return n.push(r + K(a, i)), n;
398
+ return t.push(0), t;
399
+ const a = i[s - 1], r = t[s - 1] ?? 0;
400
+ return t.push(r + N(a, o)), t;
354
401
  }, []),
355
- totalDistanceMeters: $(e.waypoints),
402
+ totalDistanceMeters: z(e.waypoints),
356
403
  waypoints: e.waypoints
357
404
  };
358
405
  }
359
- function he(e) {
360
- const t = e.waypoints[0], n = e.waypoints[e.waypoints.length - 1];
361
- return !t || !n ? !1 : K(t, n) <= 1;
406
+ function Ce(e) {
407
+ const n = e.waypoints[0], t = e.waypoints[e.waypoints.length - 1];
408
+ return !n || !t ? !1 : N(n, t) <= 1;
362
409
  }
363
- function Ie(e) {
364
- return e.phases.reduce((t, n) => n.type !== "drive" ? t : t + n.speedKph * 1e3 / 3600 * n.durationSeconds, 0);
410
+ function ke(e) {
411
+ return e.phases.reduce((n, t) => t.type !== "drive" ? n : n + t.speedKph * 1e3 / 3600 * t.durationSeconds, 0);
365
412
  }
366
- function Ee(e, t, n) {
367
- const i = Ie(n), s = Math.max(150, t.totalDistanceMeters * 0.03);
368
- if (i > t.totalDistanceMeters + s)
413
+ function Le(e, n, t) {
414
+ const o = ke(t), s = Math.max(150, n.totalDistanceMeters * 0.03);
415
+ if (o > n.totalDistanceMeters + s)
369
416
  throw new Error(
370
- `Dummy plan "${n.planId}" exceeds route "${e.routeId}" by ${Math.round(
371
- i - t.totalDistanceMeters
417
+ `Dummy plan "${t.planId}" exceeds route "${e.routeId}" by ${Math.round(
418
+ o - n.totalDistanceMeters
372
419
  )} meters`
373
420
  );
374
421
  }
375
- function w(e, t, n) {
376
- const i = e.waypoints[0];
377
- if (!i)
422
+ function L(e, n, t) {
423
+ const o = e.waypoints[0];
424
+ if (!o)
378
425
  throw new Error("Dummy route must contain at least one waypoint");
379
426
  if (e.waypoints.length === 1 || e.totalDistanceMeters <= 0)
380
427
  return {
381
- address: i.address,
382
- course: n,
383
- lat: i.lat,
384
- lng: i.lng
428
+ address: o.address,
429
+ course: t,
430
+ lat: o.lat,
431
+ lng: o.lng
385
432
  };
386
433
  const s = Math.min(
387
- Math.max(0, t),
434
+ Math.max(0, n),
388
435
  e.totalDistanceMeters
389
436
  );
390
437
  for (let a = 0; a < e.waypoints.length - 1; a += 1) {
391
438
  const r = e.waypoints[a], c = e.waypoints[a + 1], l = e.cumulativeDistancesMeters[a] ?? 0, v = e.cumulativeDistancesMeters[a + 1] ?? l;
392
439
  if (s > v && a < e.waypoints.length - 2)
393
440
  continue;
394
- const p = Math.max(0, v - l), u = p === 0 ? 0 : (s - l) / p, m = H(r, c, u), g = p === 0 ? n : W(r, c);
441
+ const p = Math.max(0, v - l), u = p === 0 ? 0 : (s - l) / p, m = Q(r, c, u), g = p === 0 ? t : ee(r, c);
395
442
  return {
396
443
  address: u < 0.5 ? r.address : c.address,
397
444
  course: g,
@@ -399,19 +446,19 @@ function w(e, t, n) {
399
446
  lng: m.lng
400
447
  };
401
448
  }
402
- const o = e.waypoints[e.waypoints.length - 1];
449
+ const i = e.waypoints[e.waypoints.length - 1];
403
450
  return {
404
- address: o.address,
405
- course: n,
406
- lat: o.lat,
407
- lng: o.lng
451
+ address: i.address,
452
+ course: t,
453
+ lat: i.lat,
454
+ lng: i.lng
408
455
  };
409
456
  }
410
- function be(e, t, n) {
411
- const i = t.phases.find((c) => c.type !== "delete");
412
- if (!i)
413
- throw new Error(`Dummy plan "${t.planId}" must contain at least one executable phase`);
414
- const s = j(n, i), o = w(e, 0, 0), a = i.type === "drive" ? X(i, s) : N(i, s), r = R(
457
+ function Ae(e, n, t) {
458
+ const o = n.phases.find((c) => c.type !== "delete");
459
+ if (!o)
460
+ throw new Error(`Dummy plan "${n.planId}" must contain at least one executable phase`);
461
+ const s = W(t, o), i = L(e, 0, 0), a = o.type === "drive" ? O(o, s) : Y(o, s), r = k(
415
462
  {
416
463
  ignition: s.ignition,
417
464
  motionStatus: a,
@@ -421,51 +468,51 @@ function be(e, t, n) {
421
468
  );
422
469
  return {
423
470
  cursor: {
424
- currentTimestampMs: k,
471
+ currentTimestampMs: V,
425
472
  frameIndex: 0,
426
- lastCourse: o.course,
473
+ lastCourse: i.course,
427
474
  odometerMeters: 0,
428
475
  routeDistanceMeters: 0
429
476
  },
430
477
  frameState: {
431
- address: o.address,
478
+ address: i.address,
432
479
  backupVolt: r.backupVolt,
433
- course: o.course,
480
+ course: i.course,
434
481
  diX: { ...s.diX },
435
482
  doX: { ...s.doX },
436
483
  ignition: s.ignition,
437
- lat: o.lat,
438
- lng: o.lng,
484
+ lat: i.lat,
485
+ lng: i.lng,
439
486
  mainVolt: r.mainVolt,
440
487
  modemCsq: s.modemCsq,
441
488
  motionStatus: a,
442
489
  odometerMeters: 0,
443
490
  signal: s.signal,
444
- speedKph: i.type === "drive" ? i.speedKph : 0,
445
- timestampMs: k
491
+ speedKph: o.type === "drive" ? o.speedKph : 0,
492
+ timestampMs: V
446
493
  },
447
494
  persistentState: s
448
495
  };
449
496
  }
450
- function Te(e, t, n, i) {
451
- const s = t.reduce((g, f, S) => ((f.type === "new" || f.type === "update") && g.push(S), g), []);
497
+ function Ve(e, n, t, o) {
498
+ const s = n.reduce((g, f, D) => ((f.type === "new" || f.type === "update") && g.push(D), g), []);
452
499
  if (!s.length)
453
500
  return {
454
501
  initialMessageIndex: 1,
455
502
  initialResource: e,
456
- playbackMessages: t
503
+ playbackMessages: n
457
504
  };
458
- const o = De(i, n), a = Math.floor(o / n.logicalSampleSeconds), r = Math.min(a, s.length - 1), c = s[r], l = t[c], v = (l.type === "new", l.payload.current), p = {
505
+ const i = Re(o, t), a = Math.floor(i / t.logicalSampleSeconds), r = Math.min(a, s.length - 1), c = s[r], l = n[c], v = (l.type === "new", l.payload.current), p = {
459
506
  ...e,
460
- current: h(v)
461
- }, u = t.slice(c + 1), m = n.loop ? t.slice(1, c + 1) : [];
507
+ current: M(v)
508
+ }, u = n.slice(c + 1), m = t.loop ? n.slice(1, c + 1) : [];
462
509
  return {
463
510
  initialMessageIndex: 1,
464
511
  initialResource: p,
465
512
  playbackMessages: [
466
513
  {
467
514
  payload: p,
468
- resourceSerialId: i.resourceSerialId,
515
+ resourceSerialId: o.resourceSerialId,
469
516
  type: "new"
470
517
  },
471
518
  ...u,
@@ -473,309 +520,381 @@ function Te(e, t, n, i) {
473
520
  ]
474
521
  };
475
522
  }
476
- function V(e, t) {
477
- const n = new Date(t.timestampMs).toISOString(), i = pe(t.signal), s = h(e);
523
+ function Xe(e, n) {
524
+ const t = n.messagePayloadPatches ?? [];
525
+ if (!t.length)
526
+ return e;
527
+ const o = {
528
+ ...e,
529
+ initialResource: M(e.initialResource),
530
+ messages: e.messages.map((s) => M(s))
531
+ };
532
+ return t.forEach((s) => {
533
+ const i = o.messages[s.messageIndex];
534
+ if (!i)
535
+ throw new Error(
536
+ `Dummy hostile payload patch targeted missing message index ${s.messageIndex} for device ${n.resourceSerialId}.`
537
+ );
538
+ if (i.type === "delete")
539
+ throw new Error(
540
+ `Dummy hostile payload patch cannot target delete message index ${s.messageIndex} for device ${n.resourceSerialId}.`
541
+ );
542
+ T(
543
+ i.payload,
544
+ M(s.payloadPatch)
545
+ ), s.messageIndex === 0 && i.type === "new" && T(
546
+ o.initialResource,
547
+ M(s.payloadPatch)
548
+ );
549
+ }), o;
550
+ }
551
+ function Pe(e, n) {
552
+ const t = n.omittedGnssFields, o = n.omitSyntheticModemTimestamps === !0;
553
+ if (!t?.gnssMotionStatus && !t?.gnssSignal && !o)
554
+ return e;
555
+ const s = {
556
+ ...e,
557
+ initialResource: M(e.initialResource),
558
+ messages: e.messages.map((a) => M(a))
559
+ }, i = (a) => {
560
+ t?.gnssMotionStatus && I(a, "vpts.vptGnss.gnssMotionStatus"), t?.gnssSignal && I(a, "vpts.vptGnss.gnssSignal"), o && (I(a, "reportProfiles.trackerEvents.modemLastEvent"), I(a, "vpts.vptModem.modemLastConnection"), I(a, "vpts.vptModem.modemLastEvent"));
561
+ };
562
+ return i(
563
+ s.initialResource.current
564
+ ), s.messages.forEach((a) => {
565
+ if (a.type !== "delete") {
566
+ if (a.type === "new") {
567
+ i(a.payload.current);
568
+ return;
569
+ }
570
+ i(
571
+ a.payload.current
572
+ );
573
+ }
574
+ }), s;
575
+ }
576
+ function A(e, n) {
577
+ const t = new Date(n.timestampMs).toISOString(), o = Se(n.signal), s = M(e);
478
578
  return s.reportProfiles = {
479
579
  ...s.reportProfiles,
480
580
  trackerEvents: {
481
581
  ...s.reportProfiles?.trackerEvents,
482
582
  modemLastEvent: {
483
- date: n
583
+ date: t
484
584
  }
485
585
  }
486
586
  }, s.vpts = s.vpts ?? {}, s.vpts.vptDiX = Object.fromEntries(
487
- Object.entries(t.diX).map(([o, a]) => [
488
- o,
587
+ Object.entries(n.diX).map(([i, a]) => [
588
+ i,
489
589
  {
490
- diXStatus: { value: !0, updatedAt: n },
491
- diXValue: { value: a, updatedAt: n }
590
+ diXStatus: { value: !0, updatedAt: t },
591
+ diXValue: { value: a, updatedAt: t }
492
592
  }
493
593
  ])
494
594
  ), s.vpts.vptDoX = Object.fromEntries(
495
- Object.entries(t.doX).map(([o, a]) => [
496
- o,
595
+ Object.entries(n.doX).map(([i, a]) => [
596
+ i,
497
597
  {
498
- diXValue: { value: a, updatedAt: n }
598
+ diXValue: { value: a, updatedAt: t }
499
599
  }
500
600
  ])
501
601
  ), s.vpts.vptGnss = {
502
602
  ...s.vpts.vptGnss,
503
- gnssAddress: t.address,
603
+ gnssAddress: n.address,
504
604
  gnssAltitude: 1520,
505
- gnssCourse: Math.round(t.course),
506
- gnssHdop: i.gnssHdop,
507
- gnssLatitude: t.lat,
508
- gnssLongitude: t.lng,
509
- gnssMotionStatus: { value: t.motionStatus, updatedAt: n },
510
- gnssOdometer: Math.round(t.odometerMeters),
511
- gnssSatellitesInUse: i.gnssSatellitesInUse,
512
- gnssSignal: { value: t.signal, updatedAt: n },
513
- gnssSpeed: t.speedKph
605
+ gnssCourse: b(
606
+ s.vpts.vptGnss?.gnssCourse,
607
+ Math.round(n.course),
608
+ t
609
+ ),
610
+ gnssHdop: o.gnssHdop,
611
+ gnssLatitude: b(
612
+ s.vpts.vptGnss?.gnssLatitude,
613
+ n.lat,
614
+ t
615
+ ),
616
+ gnssLongitude: b(
617
+ s.vpts.vptGnss?.gnssLongitude,
618
+ n.lng,
619
+ t
620
+ ),
621
+ gnssMotionStatus: { value: n.motionStatus, updatedAt: t },
622
+ gnssOdometer: Math.round(n.odometerMeters),
623
+ gnssSatellitesInUse: o.gnssSatellitesInUse,
624
+ gnssSignal: { value: n.signal, updatedAt: t },
625
+ gnssSpeed: b(
626
+ s.vpts.vptGnss?.gnssSpeed,
627
+ n.speedKph,
628
+ t
629
+ )
514
630
  }, s.vpts.vptIgnition = {
515
631
  ignitionValue: {
516
- updatedAt: n,
517
- value: t.ignition
632
+ updatedAt: t,
633
+ value: n.ignition
518
634
  }
519
635
  }, s.vpts.vptModem = {
520
636
  callActive: !1,
521
- modemCsq: t.modemCsq,
522
- modemLastConnection: n,
523
- modemLastEvent: n
637
+ modemCsq: n.modemCsq,
638
+ modemLastConnection: t,
639
+ modemLastEvent: t
524
640
  }, s.vpts.vptADCPower = {
525
- backupChargeLevel: G(t.backupVolt),
526
- backupStatus: b(t.backupVolt, "24"),
527
- backupVolt: t.backupVolt,
528
- mainStatus: b(t.mainVolt, "12"),
529
- mainVolt: t.mainVolt
641
+ backupChargeLevel: B(n.backupVolt),
642
+ backupStatus: w(n.backupVolt, "24"),
643
+ backupVolt: n.backupVolt,
644
+ mainStatus: w(n.mainVolt, "12"),
645
+ mainVolt: n.mainVolt
530
646
  }, s;
531
647
  }
532
- function B(e, t) {
533
- return Math.max(1, Math.ceil(e.durationSeconds / t.logicalSampleSeconds));
648
+ function H(e, n) {
649
+ return Math.max(1, Math.ceil(e.durationSeconds / n.logicalSampleSeconds));
534
650
  }
535
- function Re(e, t, n, i, s, o, a, r) {
536
- const c = B(s, a);
651
+ function _e(e, n, t, o, s, i, a, r) {
652
+ const c = H(s, a);
537
653
  for (let l = 0; l < c; l += 1) {
538
- const v = Y(s.speedKph, r.frameIndex + 1), p = v * 1e3 / 3600 * a.logicalSampleSeconds, u = Math.min(
539
- i.totalDistanceMeters,
654
+ const v = J(s.speedKph, r.frameIndex + 1), p = v * 1e3 / 3600 * a.logicalSampleSeconds, u = Math.min(
655
+ o.totalDistanceMeters,
540
656
  r.routeDistanceMeters + p
541
- ), m = u - r.routeDistanceMeters, g = w(i, u, r.lastCourse);
657
+ ), m = u - r.routeDistanceMeters, g = L(o, u, r.lastCourse);
542
658
  r.currentTimestampMs += a.logicalSampleSeconds * 1e3, r.frameIndex += 1, r.lastCourse = g.course, r.odometerMeters += m, r.routeDistanceMeters = u;
543
659
  const f = {
544
660
  address: g.address,
545
661
  backupVolt: 0,
546
662
  course: g.course,
547
- diX: { ...o.diX },
548
- doX: { ...o.doX },
549
- ignition: o.ignition,
663
+ diX: { ...i.diX },
664
+ doX: { ...i.doX },
665
+ ignition: i.ignition,
550
666
  lat: g.lat,
551
667
  lng: g.lng,
552
668
  mainVolt: 0,
553
- modemCsq: o.modemCsq,
554
- motionStatus: X(s, o),
669
+ modemCsq: i.modemCsq,
670
+ motionStatus: O(s, i),
555
671
  odometerMeters: r.odometerMeters,
556
- signal: o.signal,
672
+ signal: i.signal,
557
673
  speedKph: m > 0 ? v : 0,
558
674
  timestampMs: r.currentTimestampMs
559
- }, S = R(f, r.frameIndex);
560
- f.mainVolt = S.mainVolt, f.backupVolt = S.backupVolt, e.push({
675
+ }, D = k(f, r.frameIndex);
676
+ f.mainVolt = D.mainVolt, f.backupVolt = D.backupVolt, e.push({
561
677
  payload: {
562
- current: V(n, f)
678
+ current: A(t, f)
563
679
  },
564
- resourceSerialId: t,
680
+ resourceSerialId: n,
565
681
  type: "update"
566
682
  });
567
683
  }
568
684
  }
569
- function we(e, t, n, i, s, o, a, r) {
570
- const c = B(s, a);
685
+ function Oe(e, n, t, o, s, i, a, r) {
686
+ const c = H(s, a);
571
687
  for (let l = 0; l < c; l += 1) {
572
- const v = w(i, r.routeDistanceMeters, r.lastCourse);
688
+ const v = L(o, r.routeDistanceMeters, r.lastCourse);
573
689
  r.currentTimestampMs += a.logicalSampleSeconds * 1e3, r.frameIndex += 1;
574
690
  const p = {
575
691
  address: v.address,
576
692
  backupVolt: 0,
577
- course: r.lastCourse,
578
- diX: { ...o.diX },
579
- doX: { ...o.doX },
580
- ignition: o.ignition,
693
+ course: s.courseOverrideDegrees ?? r.lastCourse,
694
+ diX: { ...i.diX },
695
+ doX: { ...i.doX },
696
+ ignition: i.ignition,
581
697
  lat: v.lat,
582
698
  lng: v.lng,
583
699
  mainVolt: 0,
584
- modemCsq: o.modemCsq,
585
- motionStatus: N(s, o),
700
+ modemCsq: i.modemCsq,
701
+ motionStatus: Y(s, i),
586
702
  odometerMeters: r.odometerMeters,
587
- signal: o.signal,
703
+ signal: i.signal,
588
704
  speedKph: 0,
589
705
  timestampMs: r.currentTimestampMs
590
- }, u = R(p, r.frameIndex);
706
+ }, u = k(p, r.frameIndex);
591
707
  p.mainVolt = u.mainVolt, p.backupVolt = u.backupVolt, e.push({
592
708
  payload: {
593
- current: V(n, p)
709
+ current: A(t, p)
594
710
  },
595
- resourceSerialId: t,
711
+ resourceSerialId: n,
596
712
  type: "update"
597
713
  });
598
714
  }
599
715
  }
600
- function Ve({
716
+ function Ge({
601
717
  baseCurrent: e,
602
- cursor: t,
603
- messages: n,
604
- persistentState: i,
718
+ cursor: n,
719
+ messages: t,
720
+ persistentState: o,
605
721
  playback: s,
606
- resourceSerialId: o,
722
+ resourceSerialId: i,
607
723
  routeIndex: a,
608
724
  speedKph: r
609
725
  }) {
610
- if (!he(a) || t.routeDistanceMeters >= a.totalDistanceMeters)
726
+ if (!Ce(a) || n.routeDistanceMeters >= a.totalDistanceMeters)
611
727
  return;
612
728
  const c = Math.max(r, 8);
613
- for (; t.routeDistanceMeters < a.totalDistanceMeters; ) {
729
+ for (; n.routeDistanceMeters < a.totalDistanceMeters; ) {
614
730
  const l = c * 1e3 / 3600 * s.logicalSampleSeconds, v = Math.min(
615
731
  a.totalDistanceMeters,
616
- t.routeDistanceMeters + l
617
- ), p = v - t.routeDistanceMeters, u = w(a, v, t.lastCourse);
618
- t.currentTimestampMs += s.logicalSampleSeconds * 1e3, t.frameIndex += 1, t.lastCourse = u.course, t.odometerMeters += p, t.routeDistanceMeters = v;
732
+ n.routeDistanceMeters + l
733
+ ), p = v - n.routeDistanceMeters, u = L(a, v, n.lastCourse);
734
+ n.currentTimestampMs += s.logicalSampleSeconds * 1e3, n.frameIndex += 1, n.lastCourse = u.course, n.odometerMeters += p, n.routeDistanceMeters = v;
619
735
  const m = {
620
736
  address: u.address,
621
737
  backupVolt: 0,
622
738
  course: u.course,
623
- diX: { ...i.diX },
624
- doX: { ...i.doX },
625
- ignition: i.ignition,
739
+ diX: { ...o.diX },
740
+ doX: { ...o.doX },
741
+ ignition: o.ignition,
626
742
  lat: u.lat,
627
743
  lng: u.lng,
628
744
  mainVolt: 0,
629
- modemCsq: i.modemCsq,
630
- motionStatus: X(
745
+ modemCsq: o.modemCsq,
746
+ motionStatus: O(
631
747
  {
632
748
  durationSeconds: s.logicalSampleSeconds,
633
749
  speedKph: c
634
750
  },
635
- i
751
+ o
636
752
  ),
637
- odometerMeters: t.odometerMeters,
638
- signal: i.signal,
753
+ odometerMeters: n.odometerMeters,
754
+ signal: o.signal,
639
755
  speedKph: p > 0 ? c : 0,
640
- timestampMs: t.currentTimestampMs
641
- }, g = R(m, t.frameIndex);
642
- m.mainVolt = g.mainVolt, m.backupVolt = g.backupVolt, n.push({
756
+ timestampMs: n.currentTimestampMs
757
+ }, g = k(m, n.frameIndex);
758
+ m.mainVolt = g.mainVolt, m.backupVolt = g.backupVolt, t.push({
643
759
  payload: {
644
- current: V(e, m)
760
+ current: A(e, m)
645
761
  },
646
- resourceSerialId: o,
762
+ resourceSerialId: i,
647
763
  type: "update"
648
764
  });
649
765
  }
650
766
  }
651
- function ke(e, t) {
652
- const { assignment: n, blueprint: i, plan: s, route: o } = e, a = ye(o);
653
- Ee(o, a, s);
654
- const r = fe(n, i), c = Me(r), { cursor: l, frameState: v, persistentState: p } = be(
767
+ function Ue(e, n) {
768
+ const { assignment: t, blueprint: o, plan: s, route: i } = e, a = we(i);
769
+ Le(i, a, s);
770
+ const r = Ie(t, o), c = Te(r), { cursor: l, frameState: v, persistentState: p } = Ae(
655
771
  a,
656
772
  s,
657
773
  c
658
774
  ), u = {
659
775
  ...r,
660
- current: V(r.current, v)
776
+ current: A(r.current, v)
661
777
  };
662
- let m = p, g = s.phases.find((y) => y.type === "drive")?.speedKph ?? 24;
778
+ let m = p, g = s.phases.find((h) => h.type === "drive")?.speedKph ?? 24;
663
779
  const f = [
664
780
  {
665
781
  payload: u,
666
- resourceSerialId: n.resourceSerialId,
782
+ resourceSerialId: t.resourceSerialId,
667
783
  type: "new"
668
784
  }
669
785
  ];
670
- for (const y of s.phases) {
671
- if (y.type === "delete") {
786
+ for (const h of s.phases) {
787
+ if (h.type === "delete") {
672
788
  f.push({
673
789
  payload: {},
674
- resourceSerialId: n.resourceSerialId,
790
+ resourceSerialId: t.resourceSerialId,
675
791
  type: "delete"
676
792
  });
677
793
  break;
678
794
  }
679
- if (m = j(m, y), y.type === "drive") {
680
- g = y.speedKph, Re(
795
+ if (m = W(m, h), h.type === "drive") {
796
+ g = h.speedKph, _e(
681
797
  f,
682
- n.resourceSerialId,
798
+ t.resourceSerialId,
683
799
  r.current,
684
800
  a,
685
- y,
801
+ h,
686
802
  m,
687
- t,
803
+ n,
688
804
  l
689
805
  );
690
806
  continue;
691
807
  }
692
- we(
808
+ Oe(
693
809
  f,
694
- n.resourceSerialId,
810
+ t.resourceSerialId,
695
811
  r.current,
696
812
  a,
697
- y,
813
+ h,
698
814
  m,
699
- t,
815
+ n,
700
816
  l
701
817
  );
702
818
  }
703
- Ve({
819
+ Ge({
704
820
  baseCurrent: r.current,
705
821
  cursor: l,
706
822
  messages: f,
707
823
  persistentState: m,
708
- playback: t,
709
- resourceSerialId: n.resourceSerialId,
824
+ playback: n,
825
+ resourceSerialId: t.resourceSerialId,
710
826
  routeIndex: a,
711
827
  speedKph: g
712
828
  });
713
- const S = Te(r, f, t, n);
714
- return {
715
- emissionOffsetMs: Se(n, t),
716
- initialMessageIndex: S.initialMessageIndex,
717
- initialResource: S.initialResource,
718
- messages: S.playbackMessages,
719
- resourceSerialId: n.resourceSerialId
720
- };
829
+ const D = Ve(r, f, n, t);
830
+ return Pe(
831
+ Xe({
832
+ emissionOffsetMs: be(t, n),
833
+ initialMessageIndex: D.initialMessageIndex,
834
+ initialResource: D.initialResource,
835
+ messages: D.playbackMessages,
836
+ resourceSerialId: t.resourceSerialId
837
+ }, t),
838
+ t
839
+ );
721
840
  }
722
- function Ce(e, t) {
723
- const n = de(e), i = {
724
- devices: n.devices.map((s) => ke(s, n.playback)),
725
- playback: n.playback
841
+ function xe(e, n) {
842
+ const t = ye(e), o = {
843
+ devices: t.devices.map((s) => Ue(s, t.playback)),
844
+ playback: t.playback
726
845
  };
727
- return t?.wallClockStartAtMs === void 0 ? i : {
728
- ...i,
729
- devices: i.devices.map((s) => ({
846
+ return n?.wallClockStartAtMs === void 0 ? o : {
847
+ ...o,
848
+ devices: o.devices.map((s) => ({
730
849
  ...s,
731
- initialResource: se(
850
+ initialResource: ue(
732
851
  s.initialResource,
733
- t.wallClockStartAtMs
852
+ n.wallClockStartAtMs
734
853
  ),
735
- messages: s.messages.map((o) => oe(
736
- o,
737
- t.wallClockStartAtMs
854
+ messages: s.messages.map((i) => pe(
855
+ i,
856
+ n.wallClockStartAtMs
738
857
  ))
739
858
  }))
740
859
  };
741
860
  }
742
- function Ae(e, t) {
743
- return Ce(e).devices.reduce((i, s) => (i[s.resourceSerialId] = t?.wallClockStartAtMs === void 0 ? s.initialResource : ie(
861
+ function Fe(e, n) {
862
+ return xe(e).devices.reduce((o, s) => (o[s.resourceSerialId] = n?.wallClockStartAtMs === void 0 ? s.initialResource : de(
744
863
  s.initialResource,
745
- t.wallClockStartAtMs
746
- ), i), {});
864
+ n.wallClockStartAtMs
865
+ ), o), {});
747
866
  }
748
- function Xe({
867
+ function Ke({
749
868
  resourceTypeId: e,
750
- simulation: t
869
+ simulation: n
751
870
  }) {
752
- const n = Date.now();
871
+ const t = Date.now();
753
872
  return {
754
- initialHashResources: Ae(t, {
755
- wallClockStartAtMs: n
873
+ initialHashResources: Fe(n, {
874
+ wallClockStartAtMs: t
756
875
  }),
757
876
  resourceTypeId: e,
758
- simulation: t,
877
+ simulation: n,
759
878
  sourceDataMechanism: "dummy",
760
- wallClockStartAtMs: n
879
+ wallClockStartAtMs: t
761
880
  };
762
881
  }
763
- function Ne({
882
+ function et({
764
883
  presetId: e,
765
- resourceTypeId: t,
766
- simulationOverrides: n
884
+ resourceTypeId: n,
885
+ simulationOverrides: t
767
886
  }) {
768
- return Xe({
769
- resourceTypeId: t,
770
- simulation: Z({
771
- overrides: n,
887
+ return Ke({
888
+ resourceTypeId: n,
889
+ simulation: te({
890
+ overrides: t,
772
891
  presetId: e
773
892
  })
774
893
  });
775
894
  }
776
895
  export {
777
- Ce as buildRealTimeDummyRuntimeModel,
778
- Ae as createRealTimeDummyInitialResources,
779
- Xe as createRealTimeDummyResourceTypeConfig,
780
- Ne as createRealTimeDummyResourceTypeConfigFromPreset
896
+ xe as buildRealTimeDummyRuntimeModel,
897
+ Fe as createRealTimeDummyInitialResources,
898
+ Ke as createRealTimeDummyResourceTypeConfig,
899
+ et as createRealTimeDummyResourceTypeConfigFromPreset
781
900
  };