@danidoble/webserial 4.5.0-beta.8 → 4.6.0-beta.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.
Files changed (38) hide show
  1. package/dist/boardroid.js +2 -2
  2. package/dist/{devices-B5N__0E-.js → devices-CzEcntFZ.js} +1 -1
  3. package/dist/hopper.js +1 -1
  4. package/dist/jofemar.js +2 -2
  5. package/dist/jsd.cjs +1 -1
  6. package/dist/jsd.js +1014 -229
  7. package/dist/{kernel-B9Cl3HQU.js → kernel-ClC2wiQo.js} +2 -2
  8. package/dist/kernel.js +2 -2
  9. package/dist/locker.js +2 -2
  10. package/dist/pinpad.cjs +14 -14
  11. package/dist/pinpad.js +1047 -919
  12. package/dist/pinpax.js +2 -2
  13. package/dist/relay.js +2 -2
  14. package/dist/types/lib/commands/jsd/applications/licensing.d.ts +7 -0
  15. package/dist/types/lib/commands/jsd/applications/licensing.d.ts.map +1 -1
  16. package/dist/types/lib/commands/jsd/applications/mdbCardHolder.d.ts +178 -0
  17. package/dist/types/lib/commands/jsd/applications/mdbCardHolder.d.ts.map +1 -0
  18. package/dist/types/lib/commands/jsd/frames/licensing/licensingClient.d.ts +5 -0
  19. package/dist/types/lib/commands/jsd/frames/licensing/licensingClient.d.ts.map +1 -1
  20. package/dist/types/lib/commands/jsd/frames/licensing/opCodes.d.ts +3 -0
  21. package/dist/types/lib/commands/jsd/frames/licensing/opCodes.d.ts.map +1 -1
  22. package/dist/types/lib/commands/jsd/frames/mdb-card-holder/mdbCardHolderClient.d.ts +114 -0
  23. package/dist/types/lib/commands/jsd/frames/mdb-card-holder/mdbCardHolderClient.d.ts.map +1 -0
  24. package/dist/types/lib/commands/jsd/frames/mdb-card-holder/opCodes.d.ts +52 -0
  25. package/dist/types/lib/commands/jsd/frames/mdb-card-holder/opCodes.d.ts.map +1 -0
  26. package/dist/types/lib/commands/jsd/types/LicensingClient.d.ts +13 -0
  27. package/dist/types/lib/commands/jsd/types/LicensingClient.d.ts.map +1 -1
  28. package/dist/types/lib/commands/jsd/types/mdbCardHolder.types.d.ts +200 -0
  29. package/dist/types/lib/commands/jsd/types/mdbCardHolder.types.d.ts.map +1 -0
  30. package/dist/types/lib/commands/jsd/utils/aplications.d.ts +18 -0
  31. package/dist/types/lib/commands/jsd/utils/aplications.d.ts.map +1 -1
  32. package/dist/types/lib/serial/jsd.d.ts +2 -0
  33. package/dist/types/lib/serial/jsd.d.ts.map +1 -1
  34. package/dist/types/lib/serial/pinpad.d.ts +5 -3
  35. package/dist/types/lib/serial/pinpad.d.ts.map +1 -1
  36. package/dist/{webserial-core-DNpHXAr2.js → webserial-core-Bn6Ker2l.js} +3 -3
  37. package/dist/webserial.js +4 -4
  38. package/package.json +6 -6
package/dist/jsd.js CHANGED
@@ -1,6 +1,6 @@
1
- import { v as O } from "./webserial-core-DNpHXAr2.js";
2
- import { D as N } from "./devices-B5N__0E-.js";
3
- class T {
1
+ import { v as M } from "./webserial-core-Bn6Ker2l.js";
2
+ import { D as q } from "./devices-CzEcntFZ.js";
3
+ class N {
4
4
  /**
5
5
  * Byte order configuration
6
6
  * - true: Big Endian (high byte first) - Current JSD firmware
@@ -48,7 +48,7 @@ class T {
48
48
  };
49
49
  }
50
50
  }
51
- class b {
51
+ class L {
52
52
  /**
53
53
  * Application ID for Vision Machines (Snacks, PPEs, Supplies, Medicines, etc.)
54
54
  * Each Jofemar application has its specific protocol and application number
@@ -83,12 +83,12 @@ class b {
83
83
  * @returns Array of numbers representing the packet.
84
84
  */
85
85
  buildPacket(e, t, s) {
86
- const n = t ? t.split("").map((h) => h.charCodeAt(0)) : [], a = 6 + n.length, i = this.toLittleEndian(a), c = this.toLittleEndian(s), o = this.toLittleEndian(e);
86
+ const n = t ? t.split("").map((u) => u.charCodeAt(0)) : [], a = 6 + n.length, i = this.toLittleEndian(a), r = this.toLittleEndian(s), o = this.toLittleEndian(e);
87
87
  return {
88
88
  bytes: [
89
89
  ...i,
90
90
  // NumBytes (total chain length)
91
- ...c,
91
+ ...r,
92
92
  // App ID (402 for Vision)
93
93
  ...o,
94
94
  // Opcode (e.g., 100 for machine status)
@@ -116,11 +116,11 @@ class b {
116
116
  * @returns Array of numbers representing the ACK packet.
117
117
  */
118
118
  buildAckPacket(e) {
119
- const n = [192, 2, e], [a, i] = T.calculate(n), c = [2, e, a, i];
120
- return [192, ...this.escapeBytes(c), 192];
119
+ const n = [192, 2, e], [a, i] = N.calculate(n), r = [2, e, a, i];
120
+ return [192, ...this.escapeBytes(r), 192];
121
121
  }
122
122
  }
123
- class k extends b {
123
+ class w extends L {
124
124
  packetIdCounter = 1;
125
125
  _name = "rs232";
126
126
  get packetId() {
@@ -141,11 +141,11 @@ class k extends b {
141
141
  * @returns Array of numbers representing the packet.
142
142
  */
143
143
  buildPacket(e, t, s) {
144
- const i = this.getNextPacketId(), { bytes: c } = super.buildPacket(e, t, s), o = [192, 1, i, ...c], [h, d] = T.calculate(o), l = [1, i, ...c, h, d];
145
- return { bytes: [192, ...this.escapeBytes(l), 192], packetId: i };
144
+ const i = this.getNextPacketId(), { bytes: r } = super.buildPacket(e, t, s), o = [192, 1, i, ...r], [u, l] = N.calculate(o), h = [1, i, ...r, u, l];
145
+ return { bytes: [192, ...this.escapeBytes(h), 192], packetId: i };
146
146
  }
147
147
  }
148
- const r = {
148
+ const c = {
149
149
  requestMachineStatus: 100,
150
150
  requestStatusChannel: 101,
151
151
  requestStatusSelection: 102,
@@ -197,15 +197,16 @@ const r = {
197
197
  jsdErrorLicenseTemporarilyBlocked: 300,
198
198
  jsdErrorLicenseNotActive: 301,
199
199
  jsdErrorCommandNotExecutable: 302
200
- }, C = (p) => Object.keys(r).find((t) => r[t] === p) || "Unknown", f = {
200
+ }, A = (m) => Object.keys(c).find((t) => c[t] === m) || "Unknown", I = {
201
+ PERIFERIC_MDB_CARD: 302,
201
202
  VISION: 402,
202
203
  LICENSING: 600,
203
204
  MANIFESTS_AND_LOGS: 601,
204
205
  SIMULATOR_VISION: 1e4
205
- }, L = (p) => [f.VISION, f.SIMULATOR_VISION].includes(p), F = (p) => [f.LICENSING].includes(p), w = (p) => [f.MANIFESTS_AND_LOGS].includes(p);
206
- class u {
206
+ }, R = (m) => [I.VISION, I.SIMULATOR_VISION].includes(m), x = (m) => [I.LICENSING].includes(m), B = (m) => [I.MANIFESTS_AND_LOGS].includes(m);
207
+ class d {
207
208
  transport;
208
- static APP_ID = f.VISION;
209
+ static APP_ID = I.VISION;
209
210
  // Manifest & Logs Application ID
210
211
  constructor(e) {
211
212
  this.transport = e;
@@ -221,7 +222,7 @@ class u {
221
222
  transport: e,
222
223
  packetId: t
223
224
  }) {
224
- return e._overridePacketId(t || 255), new u(e).requestJSDVersion();
225
+ return e._overridePacketId(t || 255), new d(e).requestJSDVersion();
225
226
  }
226
227
  /**
227
228
  * Opcode 100: Request machine status.
@@ -231,7 +232,7 @@ class u {
231
232
  */
232
233
  requestMachineStatus({ machine: e }) {
233
234
  const t = `${e}`;
234
- return this.transport.buildPacket(r.requestMachineStatus, t, u.APP_ID);
235
+ return this.transport.buildPacket(c.requestMachineStatus, t, d.APP_ID);
235
236
  }
236
237
  /**
237
238
  * Opcode 101: Request status of a specific channel.
@@ -243,7 +244,7 @@ class u {
243
244
  */
244
245
  requestStatusChannel({ machine: e, tray: t, channel: s }) {
245
246
  const n = `${e},${t},${s}`;
246
- return this.transport.buildPacket(r.requestStatusChannel, n, u.APP_ID);
247
+ return this.transport.buildPacket(c.requestStatusChannel, n, d.APP_ID);
247
248
  }
248
249
  /**
249
250
  * Opcode 102: Request status of a specific selection.
@@ -253,7 +254,7 @@ class u {
253
254
  */
254
255
  requestStatusSelection({ selection: e }) {
255
256
  const t = `${e}`;
256
- return this.transport.buildPacket(r.requestStatusSelection, t, u.APP_ID);
257
+ return this.transport.buildPacket(c.requestStatusSelection, t, d.APP_ID);
257
258
  }
258
259
  /**
259
260
  * Configure dispense parameters for a selection.
@@ -269,7 +270,7 @@ class u {
269
270
  timePostRun: s
270
271
  }) {
271
272
  const n = `${e},${t},${s}`;
272
- return this.transport.buildPacket(r.configureSelectionDispense, n, u.APP_ID);
273
+ return this.transport.buildPacket(c.configureSelectionDispense, n, d.APP_ID);
273
274
  }
274
275
  /**
275
276
  * Get current dispense configuration for a selection.
@@ -279,7 +280,7 @@ class u {
279
280
  */
280
281
  getSelectionDispenseConfig({ machine: e }) {
281
282
  const t = `${e}`;
282
- return this.transport.buildPacket(r.configureSelectionDispense, t, u.APP_ID);
283
+ return this.transport.buildPacket(c.configureSelectionDispense, t, d.APP_ID);
283
284
  }
284
285
  /**
285
286
  * Request to add a channel to a selection.
@@ -292,7 +293,7 @@ class u {
292
293
  */
293
294
  addChannelToSelection({ selection: e, machine: t, tray: s, channel: n }) {
294
295
  const a = `${e},${t},${s},${n}`;
295
- return this.transport.buildPacket(r.addChannelToSelection, a, u.APP_ID);
296
+ return this.transport.buildPacket(c.addChannelToSelection, a, d.APP_ID);
296
297
  }
297
298
  /**
298
299
  * Get channels linked to a selection.
@@ -302,7 +303,7 @@ class u {
302
303
  */
303
304
  getChannelsLinkedToSelection({ selection: e }) {
304
305
  const t = `${e}`;
305
- return this.transport.buildPacket(r.addChannelToSelection, t, u.APP_ID);
306
+ return this.transport.buildPacket(c.addChannelToSelection, t, d.APP_ID);
306
307
  }
307
308
  /**
308
309
  * Request machine identification.
@@ -312,7 +313,7 @@ class u {
312
313
  */
313
314
  requestMachineIdentification({ machine: e }) {
314
315
  const t = `${e}`;
315
- return this.transport.buildPacket(r.requestMachineIdentification, t, u.APP_ID);
316
+ return this.transport.buildPacket(c.requestMachineIdentification, t, d.APP_ID);
316
317
  }
317
318
  /**
318
319
  * Format temperature to +05.0 or -03.5
@@ -337,7 +338,7 @@ class u {
337
338
  enable: s
338
339
  }) {
339
340
  const n = this.formatTemperature(t), i = `${e},${n},${s ? 1 : 0}`;
340
- return this.transport.buildPacket(r.programWorkingTemperature, i, u.APP_ID);
341
+ return this.transport.buildPacket(c.programWorkingTemperature, i, d.APP_ID);
341
342
  }
342
343
  /**
343
344
  * Get working temperature.
@@ -347,7 +348,7 @@ class u {
347
348
  */
348
349
  getWorkingTemperature({ machine: e }) {
349
350
  const t = `${e}`;
350
- return this.transport.buildPacket(r.programWorkingTemperature, t, u.APP_ID);
351
+ return this.transport.buildPacket(c.programWorkingTemperature, t, d.APP_ID);
351
352
  }
352
353
  /**
353
354
  * Program waiting timings.
@@ -363,14 +364,14 @@ class u {
363
364
  afterPickup: s
364
365
  }) {
365
366
  const n = `${e},${t},${s}`;
366
- return this.transport.buildPacket(r.programWaitingTimings, n, u.APP_ID);
367
+ return this.transport.buildPacket(c.programWaitingTimings, n, d.APP_ID);
367
368
  }
368
369
  /**
369
370
  * Get waiting timings.
370
371
  * @returns The generated packet as a number array.
371
372
  */
372
373
  getWaitingTimings() {
373
- return this.transport.buildPacket(r.programWaitingTimings, "", u.APP_ID);
374
+ return this.transport.buildPacket(c.programWaitingTimings, "", d.APP_ID);
374
375
  }
375
376
  /**
376
377
  * Reset sold-out status for all channels in a machine.
@@ -380,7 +381,7 @@ class u {
380
381
  */
381
382
  resetSoldOutChannels({ machine: e }) {
382
383
  const t = `${e}`;
383
- return this.transport.buildPacket(r.resetSoldOutChannels, t, u.APP_ID);
384
+ return this.transport.buildPacket(c.resetSoldOutChannels, t, d.APP_ID);
384
385
  }
385
386
  /**
386
387
  * Program time waiting after pickup.
@@ -390,14 +391,14 @@ class u {
390
391
  */
391
392
  programTimeWaitingAfterPickup({ time: e }) {
392
393
  const t = `${e}`;
393
- return this.transport.buildPacket(r.programTimeWaitingAfterPickup, t, u.APP_ID);
394
+ return this.transport.buildPacket(c.programTimeWaitingAfterPickup, t, d.APP_ID);
394
395
  }
395
396
  /**
396
397
  * Get time waiting after pickup.
397
398
  * @returns The generated packet as a number array.
398
399
  */
399
400
  getTimeWaitingAfterPickup() {
400
- return this.transport.buildPacket(r.programTimeWaitingAfterPickup, "", u.APP_ID);
401
+ return this.transport.buildPacket(c.programTimeWaitingAfterPickup, "", d.APP_ID);
401
402
  }
402
403
  /**
403
404
  * Opcode 110: Request JSD firmware version.
@@ -405,7 +406,7 @@ class u {
405
406
  * @returns The generated packet as a number array.
406
407
  */
407
408
  requestJSDVersion() {
408
- return this.transport.buildPacket(r.requestJSDVersion, "", u.APP_ID);
409
+ return this.transport.buildPacket(c.requestJSDVersion, "", d.APP_ID);
409
410
  }
410
411
  /**
411
412
  * Opcode 111: Request or clear machine faults.
@@ -420,7 +421,7 @@ class u {
420
421
  "report-inactive": 1,
421
422
  "clear-inactive": 2
422
423
  }[t]}`;
423
- return this.transport.buildPacket(r.requestFaultMachine, n, u.APP_ID);
424
+ return this.transport.buildPacket(c.requestFaultMachine, n, d.APP_ID);
424
425
  }
425
426
  /**
426
427
  * Request report of active faults.
@@ -454,7 +455,7 @@ class u {
454
455
  */
455
456
  manageJSDDispensingQueue({ type: e }) {
456
457
  const t = `${e}`;
457
- return this.transport.buildPacket(r.manageJSDDispensingQueue, t, u.APP_ID);
458
+ return this.transport.buildPacket(c.manageJSDDispensingQueue, t, d.APP_ID);
458
459
  }
459
460
  /**
460
461
  * Request JSD dispensing queue status.
@@ -487,8 +488,8 @@ class u {
487
488
  typeAdjustElevator: n,
488
489
  timeAdjustElevator: a
489
490
  }) {
490
- const d = `${e},${t ? 1 : 0},${s ? 1 : 0},${n === "lower" ? 0 : 1},${a}`;
491
- return this.transport.buildPacket(r.defineSpecialCharacteristicsSelection, d, u.APP_ID);
491
+ const l = `${e},${t ? 1 : 0},${s ? 1 : 0},${n === "lower" ? 0 : 1},${a}`;
492
+ return this.transport.buildPacket(c.defineSpecialCharacteristicsSelection, l, d.APP_ID);
492
493
  }
493
494
  /**
494
495
  * Get special characteristics for a selection.
@@ -498,7 +499,7 @@ class u {
498
499
  */
499
500
  getSpecialCharacteristicsSelection({ selection: e }) {
500
501
  const t = `${e}`;
501
- return this.transport.buildPacket(r.defineSpecialCharacteristicsSelection, t, u.APP_ID);
502
+ return this.transport.buildPacket(c.defineSpecialCharacteristicsSelection, t, d.APP_ID);
502
503
  }
503
504
  /**
504
505
  * Configure perishable products settings for a machine.
@@ -515,8 +516,8 @@ class u {
515
516
  temperatureLimit: s,
516
517
  minutesToExpiry: n
517
518
  }) {
518
- const a = t ? 1 : 0, i = this.formatTemperature(s), c = `${e},${a},${i},${n}`;
519
- return this.transport.buildPacket(r.configurePerishableProducts, c, u.APP_ID);
519
+ const a = t ? 1 : 0, i = this.formatTemperature(s), r = `${e},${a},${i},${n}`;
520
+ return this.transport.buildPacket(c.configurePerishableProducts, r, d.APP_ID);
520
521
  }
521
522
  /**
522
523
  * Request active faults for a machine.
@@ -526,7 +527,7 @@ class u {
526
527
  */
527
528
  requestActiveFaults({ machine: e }) {
528
529
  const t = `${e}`;
529
- return this.transport.buildPacket(r.requestActiveFaults, t, u.APP_ID);
530
+ return this.transport.buildPacket(c.requestActiveFaults, t, d.APP_ID);
530
531
  }
531
532
  /**
532
533
  * Configure extended dispense status data.
@@ -538,14 +539,14 @@ class u {
538
539
  enable: e
539
540
  }) {
540
541
  const s = `${e ? 1 : 0}`;
541
- return this.transport.buildPacket(r.configureExtendedDispenseStatusData, s, u.APP_ID);
542
+ return this.transport.buildPacket(c.configureExtendedDispenseStatusData, s, d.APP_ID);
542
543
  }
543
544
  /**
544
545
  * Get extended dispense status data configuration.
545
546
  * @returns The generated packet as a number array.
546
547
  */
547
548
  getExtendedDispenseStatusDataConfig() {
548
- return this.transport.buildPacket(r.configureExtendedDispenseStatusData, "", u.APP_ID);
549
+ return this.transport.buildPacket(c.configureExtendedDispenseStatusData, "", d.APP_ID);
549
550
  }
550
551
  /**
551
552
  * Request the status of the tray positioning phototransistors.
@@ -556,9 +557,9 @@ class u {
556
557
  requestStatusTrayPositioningPhototransistors({ machine: e }) {
557
558
  const t = `${e}`;
558
559
  return this.transport.buildPacket(
559
- r.requestStatusTrayPositioningPhototransistors,
560
+ c.requestStatusTrayPositioningPhototransistors,
560
561
  t,
561
- u.APP_ID
562
+ d.APP_ID
562
563
  );
563
564
  }
564
565
  /**
@@ -580,8 +581,8 @@ class u {
580
581
  speed: a,
581
582
  timePostRun: i
582
583
  }) {
583
- const c = `${e},${t},${s},${n},${a},${i}`;
584
- return this.transport.buildPacket(r.dispenseFromChannel, c, u.APP_ID);
584
+ const r = `${e},${t},${s},${n},${a},${i}`;
585
+ return this.transport.buildPacket(c.dispenseFromChannel, r, d.APP_ID);
585
586
  }
586
587
  /**
587
588
  * Get dispense status from channel thought token.
@@ -591,7 +592,7 @@ class u {
591
592
  */
592
593
  getDispenseStatusFromChannel({ token: e }) {
593
594
  const t = `${e}`;
594
- return this.transport.buildPacket(r.dispenseFromChannel, t, u.APP_ID);
595
+ return this.transport.buildPacket(c.dispenseFromChannel, t, d.APP_ID);
595
596
  }
596
597
  /**
597
598
  * Request dispense from selection.
@@ -602,7 +603,7 @@ class u {
602
603
  */
603
604
  dispenseFromSelection({ token: e, selection: t }) {
604
605
  const s = `${e},${t}`;
605
- return this.transport.buildPacket(r.dispenseFromSelection, s, u.APP_ID);
606
+ return this.transport.buildPacket(c.dispenseFromSelection, s, d.APP_ID);
606
607
  }
607
608
  /**
608
609
  * Get dispense status from selection thought token.
@@ -612,7 +613,7 @@ class u {
612
613
  */
613
614
  getDispenseStatusFromSelection({ token: e }) {
614
615
  const t = `${e}`;
615
- return this.transport.buildPacket(r.dispenseFromSelection, t, u.APP_ID);
616
+ return this.transport.buildPacket(c.dispenseFromSelection, t, d.APP_ID);
616
617
  }
617
618
  /**
618
619
  /**
@@ -624,7 +625,7 @@ class u {
624
625
  */
625
626
  controlLights({ machine: e, turnOn: t }) {
626
627
  const n = `${e},${t ? 1 : 0}`;
627
- return this.transport.buildPacket(r.controlLights, n, u.APP_ID);
628
+ return this.transport.buildPacket(c.controlLights, n, d.APP_ID);
628
629
  }
629
630
  /**
630
631
  /**
@@ -635,7 +636,7 @@ class u {
635
636
  */
636
637
  resetFaultsAndSelfTest({ machine: e }) {
637
638
  const t = `${e}`;
638
- return this.transport.buildPacket(r.resetFaultsAndSelfTest, t, u.APP_ID);
639
+ return this.transport.buildPacket(c.resetFaultsAndSelfTest, t, d.APP_ID);
639
640
  }
640
641
  /**
641
642
  /**
@@ -646,7 +647,7 @@ class u {
646
647
  */
647
648
  performCollectCycle({ machine: e }) {
648
649
  const t = `${e}`;
649
- return this.transport.buildPacket(r.performCollectCycle, t, u.APP_ID);
650
+ return this.transport.buildPacket(c.performCollectCycle, t, d.APP_ID);
650
651
  }
651
652
  /**
652
653
  /**
@@ -670,12 +671,12 @@ class u {
670
671
  channel: n,
671
672
  speed: a,
672
673
  timePostRun: i,
673
- fragileOrHeavy: c,
674
+ fragileOrHeavy: r,
674
675
  typeAdjustElevator: o,
675
- timeAdjustElevator: h
676
+ timeAdjustElevator: u
676
677
  }) {
677
- const I = `${e},${t},${s},${n},${a},${i},${c ? 1 : 0},${o === "lower" ? 0 : 1},${h}`;
678
- return this.transport.buildPacket(r.dispenseFromChannelExtended, I, u.APP_ID);
678
+ const C = `${e},${t},${s},${n},${a},${i},${r ? 1 : 0},${o === "lower" ? 0 : 1},${u}`;
679
+ return this.transport.buildPacket(c.dispenseFromChannelExtended, C, d.APP_ID);
679
680
  }
680
681
  /**
681
682
  /**
@@ -686,7 +687,7 @@ class u {
686
687
  */
687
688
  getDispenseStatusFromChannelExtended({ token: e }) {
688
689
  const t = `${e}`;
689
- return this.transport.buildPacket(r.dispenseFromChannelExtended, t, u.APP_ID);
690
+ return this.transport.buildPacket(c.dispenseFromChannelExtended, t, d.APP_ID);
690
691
  }
691
692
  /**
692
693
  * Request for a complete JSD reset.
@@ -696,23 +697,23 @@ class u {
696
697
  * @returns The generated packet as a number array.
697
698
  */
698
699
  restartingTheJSDKnowingThatItIsDangerous() {
699
- return this.transport.buildPacket(r.restartingTheJSDKnowingThatItIsDangerous, "", u.APP_ID);
700
+ return this.transport.buildPacket(c.restartingTheJSDKnowingThatItIsDangerous, "", d.APP_ID);
700
701
  }
701
702
  }
702
- function q(p) {
703
- if (p.length > 5)
704
- throw new Error(`Token must be max 5 characters, got ${p.length}`);
705
- return p;
703
+ function $(m) {
704
+ if (m.length > 5)
705
+ throw new Error(`Token must be max 5 characters, got ${m.length}`);
706
+ return m;
706
707
  }
707
- function _() {
708
- let p;
708
+ function T() {
709
+ let m;
709
710
  do {
710
711
  const e = new Uint8Array(2);
711
- p = parseInt(crypto.getRandomValues(e).toString().replaceAll(",", "")).toString(36);
712
- } while (p.length > 5);
713
- return q(p);
712
+ m = parseInt(crypto.getRandomValues(e).toString().replaceAll(",", "")).toString(36);
713
+ } while (m.length > 5);
714
+ return $(m);
714
715
  }
715
- const E = {
716
+ const _ = {
716
717
  status: "NO-CONNECTED",
717
718
  machineInService: !1,
718
719
  doorOpen: !1,
@@ -720,18 +721,18 @@ const E = {
720
721
  hasLightsOn: !1,
721
722
  temperature: ""
722
723
  };
723
- class M {
724
+ class j {
724
725
  _commands;
725
726
  jsd;
726
- APP_ID = f.VISION;
727
+ APP_ID = I.VISION;
727
728
  _machineStatus = [
728
- { ...E },
729
- { ...E },
730
- { ...E },
731
- { ...E }
729
+ { ..._ },
730
+ { ..._ },
731
+ { ..._ },
732
+ { ..._ }
732
733
  ];
733
734
  constructor(e, t) {
734
- this._commands = new u(t), this.jsd = e;
735
+ this._commands = new d(t), this.jsd = e;
735
736
  }
736
737
  _performingChannelAssignment = {
737
738
  enabled: !1,
@@ -1153,23 +1154,23 @@ class M {
1153
1154
  }) {
1154
1155
  if (!this.isAvailableToDispense({ machine: e }))
1155
1156
  throw new Error(`Machine ${e} is not available to dispense`);
1156
- const c = this._getMachineIndex(e), o = _(), h = this.cmd.dispenseFromChannel({
1157
+ const r = this._getMachineIndex(e), o = T(), u = this.cmd.dispenseFromChannel({
1157
1158
  token: o,
1158
- machine: c,
1159
+ machine: r,
1159
1160
  tray: t,
1160
1161
  channel: s,
1161
1162
  speed: n,
1162
1163
  timePostRun: a
1163
1164
  });
1164
- return await this.send(h, { alias: "dispenseFromChannel" }), this._dispensingTokens[o] = {
1165
+ return await this.send(u, { alias: "dispenseFromChannel" }), this._dispensingTokens[o] = {
1165
1166
  cart: !!i,
1166
1167
  resolve: () => {
1167
1168
  delete this._dispensingTokens[o];
1168
1169
  },
1169
1170
  reject: () => {
1170
1171
  }
1171
- }, new Promise((d, l) => {
1172
- this._dispensingTokens[o].resolve = d, this._dispensingTokens[o].reject = l;
1172
+ }, new Promise((l, h) => {
1173
+ this._dispensingTokens[o].resolve = l, this._dispensingTokens[o].reject = h;
1173
1174
  });
1174
1175
  }
1175
1176
  /**
@@ -1183,11 +1184,11 @@ class M {
1183
1184
  * @returns Promise resolving when the command is sent.
1184
1185
  */
1185
1186
  async dispense({ machine: e, selection: t, speed: s, timePostRun: n, cart: a = !1 }) {
1186
- const { tray: i, channel: c } = this._getTrayChannelFromSelection(t);
1187
+ const { tray: i, channel: r } = this._getTrayChannelFromSelection(t);
1187
1188
  return this.dispenseFromChannel({
1188
1189
  machine: e,
1189
1190
  tray: i,
1190
- channel: c,
1191
+ channel: r,
1191
1192
  speed: s || 5,
1192
1193
  timePostRun: n || 0,
1193
1194
  cart: !!a
@@ -1212,20 +1213,20 @@ class M {
1212
1213
  n.map((o) => this.dispense({ machine: o.machine, selection: o.selection, cart: !0 }))
1213
1214
  ), i = [...new Set(n.map((o) => o.machine))];
1214
1215
  await new Promise((o) => {
1215
- const h = setInterval(() => {
1216
+ const u = setInterval(() => {
1216
1217
  i.every(
1217
- (l) => this.getMachineStatus(l)?.availabilityToDispense === "AVAILABLE-TO-DISPENSE"
1218
- ) && (clearInterval(h), o(!0));
1218
+ (h) => this.getMachineStatus(h)?.availabilityToDispense === "AVAILABLE-TO-DISPENSE"
1219
+ ) && (clearInterval(u), o(!0));
1219
1220
  }, 300);
1220
1221
  });
1221
1222
  for (const o of i)
1222
1223
  this._machineStatus[this._getMachineIndex(o)]?.availabilityToDispense === "WAITING-COLLECTION" && this.emit("waiting-collection", { machine: o !== null ? o + 1 : null });
1223
- const c = n.map((o, h) => ({
1224
+ const r = n.map((o, u) => ({
1224
1225
  machine: o.machine,
1225
1226
  selection: o.selection,
1226
- dispensed: a[h]
1227
+ dispensed: a[u]
1227
1228
  }));
1228
- s = s.concat(c);
1229
+ s = s.concat(r);
1229
1230
  } catch (a) {
1230
1231
  console.error("Error sending dispense command:", a);
1231
1232
  }
@@ -1249,7 +1250,7 @@ class M {
1249
1250
  * @returns Promise resolving when the command is sent.
1250
1251
  */
1251
1252
  async dispenseFromSelection({ selection: e, cart: t = !1 }) {
1252
- const s = _(), n = this.cmd.dispenseFromSelection({ token: s, selection: e });
1253
+ const s = T(), n = this.cmd.dispenseFromSelection({ token: s, selection: e });
1253
1254
  return await this.send(n, { alias: "dispenseFromSelection" }), this._dispensingTokens[s] = {
1254
1255
  cart: !!t,
1255
1256
  resolve: () => {
@@ -1340,31 +1341,31 @@ class M {
1340
1341
  speed: n,
1341
1342
  timePostRun: a,
1342
1343
  fragileOrHeavy: i,
1343
- typeAdjustElevator: c,
1344
+ typeAdjustElevator: r,
1344
1345
  timeAdjustElevator: o,
1345
- cart: h = !1
1346
+ cart: u = !1
1346
1347
  }) {
1347
1348
  if (!this.isAvailableToDispense({ machine: e }))
1348
1349
  throw new Error(`Machine ${e} is not available to dispense`);
1349
- const d = this._getMachineIndex(e), l = _(), m = this.cmd.dispenseFromChannelExtended({
1350
- token: l,
1351
- machine: d,
1350
+ const l = this._getMachineIndex(e), h = T(), g = this.cmd.dispenseFromChannelExtended({
1351
+ token: h,
1352
+ machine: l,
1352
1353
  tray: t,
1353
1354
  channel: s,
1354
1355
  speed: n,
1355
1356
  timePostRun: a,
1356
1357
  fragileOrHeavy: i,
1357
- typeAdjustElevator: c,
1358
+ typeAdjustElevator: r,
1358
1359
  timeAdjustElevator: o
1359
1360
  });
1360
- return await this.send(m, { alias: "dispenseFromChannelExtended" }), this._dispensingTokens[l] = {
1361
- cart: !!h,
1361
+ return await this.send(g, { alias: "dispenseFromChannelExtended" }), this._dispensingTokens[h] = {
1362
+ cart: !!u,
1362
1363
  resolve: () => {
1363
1364
  },
1364
1365
  reject: () => {
1365
1366
  }
1366
- }, new Promise((I, D) => {
1367
- this._dispensingTokens[l].resolve = I, this._dispensingTokens[l].reject = D;
1367
+ }, new Promise((C, P) => {
1368
+ this._dispensingTokens[h].resolve = C, this._dispensingTokens[h].reject = P;
1368
1369
  });
1369
1370
  }
1370
1371
  /**
@@ -1387,82 +1388,82 @@ class M {
1387
1388
  }
1388
1389
  serialMessage(e) {
1389
1390
  switch (e.opcode) {
1390
- case r.responseFormatCmdWrong:
1391
+ case c.responseFormatCmdWrong:
1391
1392
  this._responseFormatCmdWrong(e);
1392
1393
  break;
1393
- case r.responseMachineStatus:
1394
+ case c.responseMachineStatus:
1394
1395
  this._responseMachineStatus(e);
1395
1396
  break;
1396
- case r.responseStatusChannel:
1397
+ case c.responseStatusChannel:
1397
1398
  this._responseStatusChannel(e);
1398
1399
  break;
1399
- case r.responseStatusSelection:
1400
+ case c.responseStatusSelection:
1400
1401
  this._responseStatusSelection(e);
1401
1402
  break;
1402
- case r.responseDispenseStatus:
1403
+ case c.responseDispenseStatus:
1403
1404
  this._responseDispenseStatus(e);
1404
1405
  break;
1405
- case r.responseConfigurationSelectionDispense:
1406
+ case c.responseConfigurationSelectionDispense:
1406
1407
  this._responseConfigurationSelectionDispense(e);
1407
1408
  break;
1408
- case r.responseConfigurationChannelsLinkedToSelection:
1409
+ case c.responseConfigurationChannelsLinkedToSelection:
1409
1410
  this._responseConfigurationChannelsLinkedToSelection(e);
1410
1411
  break;
1411
- case r.responseMachineIdentification:
1412
+ case c.responseMachineIdentification:
1412
1413
  this._responseMachineIdentification(e);
1413
1414
  break;
1414
- case r.responseCurrentTemperature:
1415
+ case c.responseCurrentTemperature:
1415
1416
  this._responseCurrentTemperature(e);
1416
1417
  break;
1417
- case r.responseReportEventsAlarmsAndFaults:
1418
+ case c.responseReportEventsAlarmsAndFaults:
1418
1419
  this._responseReportEventsAlarmsAndFaults(e);
1419
1420
  break;
1420
- case r.responseNewTimingWaitingForProductCollection:
1421
+ case c.responseNewTimingWaitingForProductCollection:
1421
1422
  this._responseNewTimingWaitingForProductCollection(e);
1422
1423
  break;
1423
- case r.responsePerformingProductCollectionCycle:
1424
+ case c.responsePerformingProductCollectionCycle:
1424
1425
  this._responsePerformingProductCollectionCycle(e);
1425
1426
  break;
1426
- case r.responseResetMachineSoldOutChannels:
1427
+ case c.responseResetMachineSoldOutChannels:
1427
1428
  this._responseResetMachineSoldOutChannels(e);
1428
1429
  break;
1429
- case r.responseNewTimingWaitingAfterProductCollection:
1430
+ case c.responseNewTimingWaitingAfterProductCollection:
1430
1431
  this._responseNewTimingWaitingAfterProductCollection(e);
1431
1432
  break;
1432
- case r.responseJSDVersion:
1433
+ case c.responseJSDVersion:
1433
1434
  this._responseJSDVersion(e);
1434
1435
  break;
1435
- case r.responseActiveFaults:
1436
+ case c.responseActiveFaults:
1436
1437
  this._responseActiveFaults(e);
1437
1438
  break;
1438
- case r.responseJSDDispensingQueue:
1439
+ case c.responseJSDDispensingQueue:
1439
1440
  this._responseJSDDispensingQueue(e);
1440
1441
  break;
1441
- case r.responseSpecialCharacteristicsSelection:
1442
+ case c.responseSpecialCharacteristicsSelection:
1442
1443
  this._responseSpecialCharacteristicsSelection(e);
1443
1444
  break;
1444
- case r.responsePerishableProducts:
1445
+ case c.responsePerishableProducts:
1445
1446
  this._responsePerishableProducts(e);
1446
1447
  break;
1447
- case r.responseActiveFaultsList:
1448
+ case c.responseActiveFaultsList:
1448
1449
  this._responseActiveFaultsList(e);
1449
1450
  break;
1450
- case r.responseJSDResetStatus:
1451
+ case c.responseJSDResetStatus:
1451
1452
  this._responseJSDResetStatus(e);
1452
1453
  break;
1453
- case r.responseExtendedDispenseStatusData:
1454
+ case c.responseExtendedDispenseStatusData:
1454
1455
  this._responseExtendedDispenseStatusData(e);
1455
1456
  break;
1456
- case r.responseTraysPositioningPhototransistorsStatus:
1457
+ case c.responseTraysPositioningPhototransistorsStatus:
1457
1458
  this._responseTraysPositioningPhototransistorsStatus(e);
1458
1459
  break;
1459
- case r.jsdErrorLicenseTemporarilyBlocked:
1460
+ case c.jsdErrorLicenseTemporarilyBlocked:
1460
1461
  this._responseJsdErrorLicenseTemporarilyBlocked(e);
1461
1462
  break;
1462
- case r.jsdErrorLicenseNotActive:
1463
+ case c.jsdErrorLicenseNotActive:
1463
1464
  this._responseJsdErrorLicenseNotActive(e);
1464
1465
  break;
1465
- case r.jsdErrorCommandNotExecutable:
1466
+ case c.jsdErrorCommandNotExecutable:
1466
1467
  this._responseJsdErrorCommandNotExecutable(e);
1467
1468
  break;
1468
1469
  }
@@ -1471,7 +1472,7 @@ class M {
1471
1472
  this.jsd.dispatch(`vision:${e}`, ...t);
1472
1473
  }
1473
1474
  _responseFormatCmdWrong(e) {
1474
- const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = C(t);
1475
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = A(t);
1475
1476
  this.emit("wrong-cmd", {
1476
1477
  opcodeName: n,
1477
1478
  opcode: t,
@@ -1501,29 +1502,29 @@ class M {
1501
1502
  }
1502
1503
  }
1503
1504
  _responseMachineStatus(e) {
1504
- const [t, s, n, a, i, c, o] = e.params, h = {
1505
+ const [t, s, n, a, i, r, o] = e.params, u = {
1505
1506
  0: "AVAILABLE-TO-DISPENSE",
1506
1507
  1: "NOT-AVAILABLE-TO-DISPENSE",
1507
1508
  2: "ALREADY-DISPENSING",
1508
1509
  3: "WAITING-COLLECTION",
1509
1510
  4: "ELEVATOR-COLLECTION-POSITION",
1510
1511
  5: "UNCOLLECTED"
1511
- }, d = {
1512
+ }, l = {
1512
1513
  status: this._getMachineStatusName(parseInt(s, 10)),
1513
1514
  machineInService: parseInt(n, 10) === 1,
1514
1515
  doorOpen: parseInt(a, 10) === 0,
1515
- availabilityToDispense: h[i] || "NOT-AVAILABLE-TO-DISPENSE",
1516
- hasLightsOn: isNaN(parseInt(c, 10)) ? !1 : parseInt(c, 10) === 1,
1516
+ availabilityToDispense: u[i] || "NOT-AVAILABLE-TO-DISPENSE",
1517
+ hasLightsOn: isNaN(parseInt(r, 10)) ? !1 : parseInt(r, 10) === 1,
1517
1518
  temperature: o || ""
1518
1519
  };
1519
- this.setMachineStatus(parseInt(t, 10), d), this.emit("machine-status", {
1520
+ this.setMachineStatus(parseInt(t, 10), l), this.emit("machine-status", {
1520
1521
  machine: parseInt(t, 10) + 1,
1521
- ...d
1522
+ ...l
1522
1523
  }), this.emit("door", {
1523
- open: d.doorOpen,
1524
+ open: l.doorOpen,
1524
1525
  machine: parseInt(t, 10) + 1
1525
1526
  }), this.emit("connection", {
1526
- connected: d.status === "CONNECTED",
1527
+ connected: l.status === "CONNECTED",
1527
1528
  machine: parseInt(t, 10) + 1
1528
1529
  });
1529
1530
  }
@@ -1542,23 +1543,23 @@ class M {
1542
1543
  }
1543
1544
  }
1544
1545
  _responseStatusChannel(e) {
1545
- const [t, s, n, a] = e.params, i = this._statusChannelName(parseInt(a, 10)), c = this._getSelectionFromTrayChannel(Number(s), Number(n)), o = ["AVAILABLE", "SOLD-OUT"].includes(i);
1546
+ const [t, s, n, a] = e.params, i = this._statusChannelName(parseInt(a, 10)), r = this._getSelectionFromTrayChannel(Number(s), Number(n)), o = ["AVAILABLE", "SOLD-OUT"].includes(i);
1546
1547
  if (this._performingChannelAssignment.enabled) {
1547
1548
  this._performingChannelAssignment.selections.push({
1548
- selection: c,
1549
+ selection: r,
1549
1550
  active: o,
1550
1551
  machine: Number(t) + 1
1551
1552
  }), this._performingChannelAssignment.currentSelection = this._performingChannelAssignment.selections.length;
1552
- const h = this._performingChannelAssignment.currentSelection / 80 * 100;
1553
+ const u = this._performingChannelAssignment.currentSelection / 80 * 100;
1553
1554
  this.emit("channels-progress", {
1554
- progress: Math.min(100, Math.round(h * 100) / 100),
1555
+ progress: Math.min(100, Math.round(u * 100) / 100),
1555
1556
  current: this._performingChannelAssignment.currentSelection,
1556
1557
  verified: this._performingChannelAssignment.selections.length
1557
1558
  }), this._performingChannelAssignment.selections.length >= 80 && (this.emit("channels", this._performingChannelAssignment.selections), this._performingChannelAssignment.enabled = !1);
1558
1559
  } else
1559
1560
  this.emit("channel-status", {
1560
1561
  machine: Number(t) + 1,
1561
- selection: c,
1562
+ selection: r,
1562
1563
  active: o
1563
1564
  });
1564
1565
  }
@@ -1601,8 +1602,8 @@ class M {
1601
1602
  11: "DISPENSED-CAN-MULTIPLE",
1602
1603
  12: "DISPENSE-CANCELLED",
1603
1604
  13: "PRODUCT-EXPIRED"
1604
- }, c = Object.values(i).filter(
1605
- (D) => [
1605
+ }, r = Object.values(i).filter(
1606
+ (P) => [
1606
1607
  "NO-PERFORMED",
1607
1608
  "TOKEN-NOT-FOUND",
1608
1609
  "QUEUE-FULL",
@@ -1612,7 +1613,7 @@ class M {
1612
1613
  "DISPENSE-CANCELLED",
1613
1614
  "PRODUCT-EXPIRED",
1614
1615
  "UNCOLLECTED"
1615
- ].includes(D)
1616
+ ].includes(P)
1616
1617
  ), o = {
1617
1618
  0: "NONE",
1618
1619
  1: "DOOR-OPEN",
@@ -1630,20 +1631,20 @@ class M {
1630
1631
  13: "NO-VISION",
1631
1632
  14: "PRODUCT-PERISHABLE-EXPIRED",
1632
1633
  20: "DECIDE"
1633
- }, h = i[parseInt(s, 10)] || "UNKNOWN", [d, l, m] = n && n.trim() !== "" ? n.split(".").map((D) => parseInt(D, 10)) : [null, null, null], I = a ? o[parseInt(a, 10)] || "UNKNOWN" : null;
1634
- this._dispensingTokens[t] && (this._dispensingTokens[t].cart === !1 && h === "WAITING-COLLECTION" ? (this._dispensingTokens[t].resolve(!0), delete this._dispensingTokens[t], this.emit("waiting-collection", { machine: d !== null ? d + 1 : null })) : this._dispensingTokens[t].cart === !0 && h === "DISPENSED-CAN-MULTIPLE" ? (this._dispensingTokens[t].resolve(!0), delete this._dispensingTokens[t]) : c.includes(h) && (this._dispensingTokens[t].resolve(!1), delete this._dispensingTokens[t])), h === "IN-PROGRESS" && this.emit("dispensing", {
1634
+ }, u = i[parseInt(s, 10)] || "UNKNOWN", [l, h, g] = n && n.trim() !== "" ? n.split(".").map((P) => parseInt(P, 10)) : [null, null, null], C = a ? o[parseInt(a, 10)] || "UNKNOWN" : null;
1635
+ this._dispensingTokens[t] && (this._dispensingTokens[t].cart === !1 && u === "WAITING-COLLECTION" ? (this._dispensingTokens[t].resolve(!0), delete this._dispensingTokens[t], this.emit("waiting-collection", { machine: l !== null ? l + 1 : null })) : this._dispensingTokens[t].cart === !0 && u === "DISPENSED-CAN-MULTIPLE" ? (this._dispensingTokens[t].resolve(!0), delete this._dispensingTokens[t]) : r.includes(u) && (this._dispensingTokens[t].resolve(!1), delete this._dispensingTokens[t])), u === "IN-PROGRESS" && this.emit("dispensing", {
1635
1636
  token: t,
1636
- machine: d !== null ? d + 1 : null,
1637
- tray: l !== null ? l : null,
1638
- channel: m !== null ? m : null,
1639
- selection: m !== null && l !== null ? this._getSelectionFromTrayChannel(l, m) : null
1637
+ machine: l !== null ? l + 1 : null,
1638
+ tray: h !== null ? h : null,
1639
+ channel: g !== null ? g : null,
1640
+ selection: g !== null && h !== null ? this._getSelectionFromTrayChannel(h, g) : null
1640
1641
  }), this.emit("dispense-status", {
1641
1642
  token: t,
1642
- status: h,
1643
- machine: d !== null ? d + 1 : null,
1644
- tray: l !== null ? l : null,
1645
- channel: m !== null ? m : null,
1646
- extendedStatus: I
1643
+ status: u,
1644
+ machine: l !== null ? l + 1 : null,
1645
+ tray: h !== null ? h : null,
1646
+ channel: g !== null ? g : null,
1647
+ extendedStatus: C
1647
1648
  });
1648
1649
  }
1649
1650
  _responseConfigurationSelectionDispense(e) {
@@ -1659,17 +1660,17 @@ class M {
1659
1660
  0: "OK",
1660
1661
  1: "ALREADY-DEFINED",
1661
1662
  2: "OUT-OF-RANGE"
1662
- }, c = s.map((o) => {
1663
- const [h, d, l] = o.split(":");
1663
+ }, r = s.map((o) => {
1664
+ const [u, l, h] = o.split(":");
1664
1665
  return {
1665
- machine: parseInt(h, 10) + 1,
1666
- tray: parseInt(d, 10),
1667
- channel: parseInt(l, 10)
1666
+ machine: parseInt(u, 10) + 1,
1667
+ tray: parseInt(l, 10),
1668
+ channel: parseInt(h, 10)
1668
1669
  };
1669
1670
  });
1670
1671
  this.emit("channels-linked-to-selection", {
1671
1672
  selection: Number(t),
1672
- linkedChannels: c,
1673
+ linkedChannels: r,
1673
1674
  status: a ? i[parseInt(a, 10)] || "UNKNOWN" : null
1674
1675
  });
1675
1676
  }
@@ -1689,9 +1690,9 @@ class M {
1689
1690
  n,
1690
1691
  a,
1691
1692
  i
1692
- ] = e.params, c = parseInt(t, 10) + 1, o = parseInt(i, 10) === 1 ? "ON" : "OFF";
1693
+ ] = e.params, r = parseInt(t, 10) + 1, o = parseInt(i, 10) === 1 ? "ON" : "OFF";
1693
1694
  this.emit("current-temperature", {
1694
- machine: c,
1695
+ machine: r,
1695
1696
  workingTemperature: s,
1696
1697
  currentTemperatureInsideMachine: n,
1697
1698
  currentTemperatureAir: a,
@@ -1765,14 +1766,14 @@ class M {
1765
1766
  });
1766
1767
  }
1767
1768
  _responseActiveFaults(e) {
1768
- const [t, s, n, a, i, c, o] = e.params;
1769
+ const [t, s, n, a, i, r, o] = e.params;
1769
1770
  this.emit("active-faults", {
1770
1771
  machine: parseInt(t, 10) + 1,
1771
1772
  status: parseInt(s, 10) === 1 ? "ACTIVE" : "CLEARED",
1772
1773
  fault: parseInt(n, 10),
1773
1774
  appearancesNumber: parseInt(a, 10),
1774
1775
  partialNumberActivated: parseInt(i, 10),
1775
- minutesActive: parseInt(c, 10),
1776
+ minutesActive: parseInt(r, 10),
1776
1777
  date: o
1777
1778
  });
1778
1779
  }
@@ -1842,31 +1843,31 @@ class M {
1842
1843
  });
1843
1844
  }
1844
1845
  _responseTraysPositioningPhototransistorsStatus(e) {
1845
- const [t, s, n, a, i, c, o, h, d] = e.params, l = {
1846
+ const [t, s, n, a, i, r, o, u, l] = e.params, h = {
1846
1847
  0: "OK",
1847
1848
  C: "SHORT-CIRCUIT",
1848
1849
  N: "TRAY-NOT-DETECTED"
1849
- }, m = {
1850
+ }, g = {
1850
1851
  machine: parseInt(t, 10) + 1,
1851
1852
  trays: {
1852
- 11: l[s] || null,
1853
- 12: l[n] || null,
1854
- 13: l[a] || null,
1855
- 14: l[i] || null,
1856
- 15: l[c] || null,
1857
- 16: l[o] || null,
1858
- 17: l[h] || null,
1859
- 18: l[d] || null
1853
+ 11: h[s] || null,
1854
+ 12: h[n] || null,
1855
+ 13: h[a] || null,
1856
+ 14: h[i] || null,
1857
+ 15: h[r] || null,
1858
+ 16: h[o] || null,
1859
+ 17: h[u] || null,
1860
+ 18: h[l] || null
1860
1861
  }
1861
1862
  };
1862
- this.emit("trays-positioning-phototransistors-status", m);
1863
+ this.emit("trays-positioning-phototransistors-status", g);
1863
1864
  }
1864
1865
  _responseJsdErrorLicenseTemporarilyBlocked(e) {
1865
1866
  const [t, ...s] = e.params;
1866
1867
  this.emit("jsd-license-error", {
1867
1868
  type: "expired-license",
1868
1869
  opcode: parseInt(t, 10),
1869
- actionName: C(parseInt(t, 10)),
1870
+ actionName: A(parseInt(t, 10)),
1870
1871
  params: s
1871
1872
  });
1872
1873
  }
@@ -1875,7 +1876,7 @@ class M {
1875
1876
  this.emit("jsd-license-error", {
1876
1877
  type: "app-number-not-licensed",
1877
1878
  opcode: parseInt(t, 10),
1878
- actionName: C(parseInt(t, 10)),
1879
+ actionName: A(parseInt(t, 10)),
1879
1880
  params: s
1880
1881
  });
1881
1882
  }
@@ -1884,12 +1885,12 @@ class M {
1884
1885
  this.emit("jsd-license-error", {
1885
1886
  type: "price-control-active-direct-dispense-not-allowed",
1886
1887
  opcode: parseInt(t, 10),
1887
- actionName: C(parseInt(t, 10)),
1888
+ actionName: A(parseInt(t, 10)),
1888
1889
  params: s
1889
1890
  });
1890
1891
  }
1891
1892
  }
1892
- const g = {
1893
+ const y = {
1893
1894
  requestLogsEvents: 101,
1894
1895
  requestLogsByDate: 102,
1895
1896
  requestForSendingManifest: 110,
@@ -1898,10 +1899,10 @@ const g = {
1898
1899
  responseLineLogEvent: 201,
1899
1900
  responseManifestDataBlock: 210,
1900
1901
  responseManifestCompleted: 211
1901
- }, x = (p) => Object.keys(g).find((t) => g[t] === p) || "Unknown";
1902
- class P {
1902
+ }, U = (m) => Object.keys(y).find((t) => y[t] === m) || "Unknown";
1903
+ class E {
1903
1904
  transport;
1904
- static APP_ID = f.MANIFESTS_AND_LOGS;
1905
+ static APP_ID = I.MANIFESTS_AND_LOGS;
1905
1906
  // Manifest & Logs Application ID
1906
1907
  constructor(e) {
1907
1908
  this.transport = e;
@@ -1913,7 +1914,7 @@ class P {
1913
1914
  */
1914
1915
  requestLogsEvents(e = !1) {
1915
1916
  const s = `${e ? "+" : "0"}`;
1916
- return this.transport.buildPacket(g.requestLogsEvents, s, P.APP_ID);
1917
+ return this.transport.buildPacket(y.requestLogsEvents, s, E.APP_ID);
1917
1918
  }
1918
1919
  /**
1919
1920
  * Opcode 102: Request logs by date range.
@@ -1923,7 +1924,7 @@ class P {
1923
1924
  */
1924
1925
  requestLogsByDate(e, t) {
1925
1926
  const s = `${e},${t}`;
1926
- return this.transport.buildPacket(g.requestLogsByDate, s, P.APP_ID);
1927
+ return this.transport.buildPacket(y.requestLogsByDate, s, E.APP_ID);
1927
1928
  }
1928
1929
  /**
1929
1930
  * Opcode 110: Request for sending manifest.
@@ -1933,7 +1934,7 @@ class P {
1933
1934
  */
1934
1935
  requestForSendingManifest(e, t) {
1935
1936
  const s = `${e},${t}`;
1936
- return this.transport.buildPacket(g.requestForSendingManifest, s, P.APP_ID);
1937
+ return this.transport.buildPacket(y.requestForSendingManifest, s, E.APP_ID);
1937
1938
  }
1938
1939
  /**
1939
1940
  * Opcode 111: Send manifest data block.
@@ -1943,19 +1944,19 @@ class P {
1943
1944
  */
1944
1945
  sendManifestDataBlock(e, t) {
1945
1946
  const s = Array.from(t).map((a) => a.toString(2).padStart(8, "0")).join(" "), n = `${e},${s}`;
1946
- return this.transport.buildPacket(g.sendManifestDataBlock, n, P.APP_ID);
1947
+ return this.transport.buildPacket(y.sendManifestDataBlock, n, E.APP_ID);
1947
1948
  }
1948
1949
  }
1949
- class R {
1950
+ class W {
1950
1951
  _commands;
1951
1952
  jsd;
1952
- APP_ID = f.MANIFESTS_AND_LOGS;
1953
+ APP_ID = I.MANIFESTS_AND_LOGS;
1953
1954
  _logs = {
1954
1955
  status: "idle",
1955
1956
  data: []
1956
1957
  };
1957
1958
  constructor(e, t) {
1958
- this._commands = new P(t), this.jsd = e;
1959
+ this._commands = new E(t), this.jsd = e;
1959
1960
  }
1960
1961
  async send(e, t) {
1961
1962
  return this.jsd._lastApplicationCode = this.APP_ID, this.jsd._toQueue(e, {
@@ -2004,9 +2005,9 @@ class R {
2004
2005
  * @returns Promise resolving when the command is sent.
2005
2006
  */
2006
2007
  async requestLogsByDate({ since: e, until: t }) {
2007
- const s = (c) => {
2008
- const o = String(c.getMonth() + 1).padStart(2, "0"), h = String(c.getDate()).padStart(2, "0"), d = String(c.getHours()).padStart(2, "0"), l = String(c.getMinutes()).padStart(2, "0"), m = String(c.getSeconds()).padStart(2, "0");
2009
- return `${o}/${h}/${d}/${l}/${m}`;
2008
+ const s = (r) => {
2009
+ const o = String(r.getMonth() + 1).padStart(2, "0"), u = String(r.getDate()).padStart(2, "0"), l = String(r.getHours()).padStart(2, "0"), h = String(r.getMinutes()).padStart(2, "0"), g = String(r.getSeconds()).padStart(2, "0");
2010
+ return `${o}/${u}/${l}/${h}/${g}`;
2010
2011
  }, n = s(e), a = s(t), i = this.cmd.requestLogsByDate(n, a);
2011
2012
  return await this.send(i, { alias: "requestLogsByDate" });
2012
2013
  }
@@ -2034,16 +2035,16 @@ class R {
2034
2035
  }
2035
2036
  serialMessage(e) {
2036
2037
  switch (e.opcode) {
2037
- case g.responseCmdWrong:
2038
+ case y.responseCmdWrong:
2038
2039
  this._responseCmdWrong(e);
2039
2040
  break;
2040
- case g.responseLineLogEvent:
2041
+ case y.responseLineLogEvent:
2041
2042
  this._responseLineLogEvent(e);
2042
2043
  break;
2043
- case g.responseManifestDataBlock:
2044
+ case y.responseManifestDataBlock:
2044
2045
  this._responseManifestDataBlock(e);
2045
2046
  break;
2046
- case g.responseManifestCompleted:
2047
+ case y.responseManifestCompleted:
2047
2048
  this._responseManifestCompleted(e);
2048
2049
  break;
2049
2050
  }
@@ -2052,7 +2053,7 @@ class R {
2052
2053
  this.jsd.dispatch(`manifest:${e}`, ...t);
2053
2054
  }
2054
2055
  _responseCmdWrong(e) {
2055
- const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = x(t);
2056
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = U(t);
2056
2057
  this.emit("wrong-cmd", {
2057
2058
  opcodeName: n,
2058
2059
  opcode: t,
@@ -2098,16 +2099,20 @@ const S = {
2098
2099
  requestFeatureStatus: 100,
2099
2100
  requestTemporaryLicenseStatus: 101,
2100
2101
  requestSeedData: 102,
2102
+ //requestReserved103: 103,
2103
+ requestJsdIdentification: 104,
2101
2104
  requestLicenseActivation: 150,
2102
- // 110
2103
2105
  responseCmdWrong: 200,
2104
2106
  responseFeatureStatus: 201,
2105
2107
  responseSeedData: 202,
2106
- responseTemporaryLicenseStatus: 203
2107
- }, B = (p) => Object.keys(S).find((t) => S[t] === p) || "Unknown";
2108
- class y {
2108
+ responseTemporaryLicenseStatus: 203,
2109
+ //responseReserved204: 204,
2110
+ responseLicensingReport: 205,
2111
+ responseJsdIdentification: 206
2112
+ }, J = (m) => Object.keys(S).find((t) => S[t] === m) || "Unknown";
2113
+ class b {
2109
2114
  transport;
2110
- static APP_ID = f.LICENSING;
2115
+ static APP_ID = I.LICENSING;
2111
2116
  // Manifest & Logs Application ID
2112
2117
  constructor(e) {
2113
2118
  this.transport = e;
@@ -2119,21 +2124,21 @@ class y {
2119
2124
  */
2120
2125
  requestFeatureStatus(e) {
2121
2126
  const t = `${e}`;
2122
- return this.transport.buildPacket(S.requestFeatureStatus, t, y.APP_ID);
2127
+ return this.transport.buildPacket(S.requestFeatureStatus, t, b.APP_ID);
2123
2128
  }
2124
2129
  /**
2125
2130
  * Opcode 101: Request temporary license status.
2126
2131
  * @returns The generated packet as a number array.
2127
2132
  */
2128
2133
  requestTemporaryLicenseStatus() {
2129
- return this.transport.buildPacket(S.requestTemporaryLicenseStatus, "", y.APP_ID);
2134
+ return this.transport.buildPacket(S.requestTemporaryLicenseStatus, "", b.APP_ID);
2130
2135
  }
2131
2136
  /**
2132
2137
  * Opcode 102: Request seed data for license generation.
2133
2138
  * @returns The generated packet as a number array.
2134
2139
  */
2135
2140
  requestSeedData() {
2136
- return this.transport.buildPacket(S.requestSeedData, "", y.APP_ID);
2141
+ return this.transport.buildPacket(S.requestSeedData, "", b.APP_ID);
2137
2142
  }
2138
2143
  /**
2139
2144
  * Opcode 110: Request license activation.
@@ -2142,15 +2147,22 @@ class y {
2142
2147
  */
2143
2148
  requestLicenseActivation(e) {
2144
2149
  const t = `${e}`;
2145
- return this.transport.buildPacket(S.requestLicenseActivation, t, y.APP_ID);
2150
+ return this.transport.buildPacket(S.requestLicenseActivation, t, b.APP_ID);
2151
+ }
2152
+ /**
2153
+ * Opcode 104: Request JSD identification information.
2154
+ * @returns The generated packet as a number array.
2155
+ */
2156
+ requestJsdIdentification() {
2157
+ return this.transport.buildPacket(S.requestJsdIdentification, "", b.APP_ID);
2146
2158
  }
2147
2159
  }
2148
- class $ {
2160
+ class K {
2149
2161
  _commands;
2150
2162
  jsd;
2151
- APP_ID = f.LICENSING;
2163
+ APP_ID = I.LICENSING;
2152
2164
  constructor(e, t) {
2153
- this._commands = new y(t), this.jsd = e;
2165
+ this._commands = new b(t), this.jsd = e;
2154
2166
  }
2155
2167
  async send(e, t) {
2156
2168
  return this.jsd._lastApplicationCode = this.APP_ID, this.jsd._toQueue(e, {
@@ -2198,6 +2210,14 @@ class $ {
2198
2210
  const t = this._base64ToUint8Array(e), s = String.fromCharCode(...t), n = this.cmd.requestLicenseActivation(s);
2199
2211
  return this.send(n, { alias: "requestLicenseActivation" });
2200
2212
  }
2213
+ /**
2214
+ * Request JSD identification information.
2215
+ * @returns Promise resolving when the command is sent.
2216
+ */
2217
+ async requestJsdIdentification() {
2218
+ const e = this.cmd.requestJsdIdentification();
2219
+ return this.send(e, { alias: "requestJsdIdentification" });
2220
+ }
2201
2221
  _base64ToUint8Array(e) {
2202
2222
  if (Uint8Array.fromBase64)
2203
2223
  return Uint8Array.fromBase64(e);
@@ -2220,13 +2240,19 @@ class $ {
2220
2240
  case S.responseTemporaryLicenseStatus:
2221
2241
  this._responseTemporaryLicenseStatus(e);
2222
2242
  break;
2243
+ case S.responseLicensingReport:
2244
+ this._responseLisensingReport(e);
2245
+ break;
2246
+ case S.responseJsdIdentification:
2247
+ this._responseJsdIdentification(e);
2248
+ break;
2223
2249
  }
2224
2250
  }
2225
2251
  emit(e, ...t) {
2226
2252
  this.jsd.dispatch(`licensing:${e}`, ...t);
2227
2253
  }
2228
2254
  _responseCmdWrong(e) {
2229
- const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = B(t);
2255
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = J(t);
2230
2256
  this.emit("wrong-cmd", {
2231
2257
  opcodeName: n,
2232
2258
  opcode: t,
@@ -2277,8 +2303,764 @@ class $ {
2277
2303
  expired: t === "2"
2278
2304
  });
2279
2305
  }
2306
+ _responseLisensingReport(e) {
2307
+ const [t, s] = e.params, n = {
2308
+ 1: "File with incorrect format",
2309
+ 2: "Identification mismatch, the file does not correspond to the JSD",
2310
+ 3: "Sequense error, The file belong to device, but the license counter does not match. This occurs if the same license file is used wrice or if wro license files have been generated with the same seed and one of them has already been loaded."
2311
+ };
2312
+ this.emit("report", {
2313
+ isSuccess: t === "1",
2314
+ status: t === "0" ? "failure" : "success",
2315
+ reason: n[s] || "Unknown"
2316
+ });
2317
+ }
2318
+ _responseJsdIdentification(e) {
2319
+ const [t, s] = e.params;
2320
+ this.emit("identification", {
2321
+ idJSuite: t,
2322
+ uid: s
2323
+ });
2324
+ }
2325
+ }
2326
+ const p = {
2327
+ requestStatus: 100,
2328
+ requestIdentification: 101,
2329
+ requestConfiguration: 102,
2330
+ requestFunctionalitiesConfiguration: 103,
2331
+ requestEnable: 104,
2332
+ requestBalanceData: 105,
2333
+ requestSaleApproval: 106,
2334
+ requestSaleCancellation: 107,
2335
+ requestSaleSuccessConfirmation: 108,
2336
+ requestSaleFailureConfirmation: 109,
2337
+ requestEndSession: 110,
2338
+ requestCashRecord: 111,
2339
+ requestSelectionRequestDenied: 112,
2340
+ requestRevalue: 113,
2341
+ responseCmdWrong: 200,
2342
+ responseCondition: 201,
2343
+ responseIdentification: 202,
2344
+ responseConfiguration: 203,
2345
+ responseFeatureConfiguration: 204,
2346
+ responseAuthorization: 205,
2347
+ responseBalanceStatement: 206,
2348
+ responseSaleApproval: 207,
2349
+ responseSaleCancellation: 208,
2350
+ responseSaleSuccessConfirmation: 209,
2351
+ responseSaleFailureConfirmation: 210,
2352
+ responseEndSession: 211,
2353
+ responseSelectionRequest: 212,
2354
+ responseRevalue: 213,
2355
+ responseDisplayMessage: 214,
2356
+ jsdErrorLicenseTemporarilyBlocked: 300,
2357
+ jsdErrorLicenseNotActive: 301,
2358
+ jsdErrorCommandNotExecutable: 302
2359
+ }, k = (m) => Object.keys(p).find((t) => p[t] === m) || "Unknown";
2360
+ class f {
2361
+ transport;
2362
+ static APP_ID = I.PERIFERIC_MDB_CARD;
2363
+ // MDB Card Holder Application ID
2364
+ constructor(e) {
2365
+ this.transport = e;
2366
+ }
2367
+ /**
2368
+ * Opcode 100: Request for status of the MDB Card Holder device.
2369
+ * @param deviceNumber The device number to request status for. Defaults to 1.
2370
+ * @returns The generated packet as a number array.
2371
+ */
2372
+ requestStatus(e = 1) {
2373
+ const t = `${e}`;
2374
+ return this.transport.buildPacket(p.requestStatus, t, f.APP_ID);
2375
+ }
2376
+ /**
2377
+ * Opcode 101: Request for identification of the MDB Card Holder device.
2378
+ * @param deviceNumber The device number to request identification for. Defaults to 1.
2379
+ * @returns The generated packet as a number array.
2380
+ */
2381
+ requestIdentification(e = 1) {
2382
+ const t = `${e}`;
2383
+ return this.transport.buildPacket(p.requestIdentification, t, f.APP_ID);
2384
+ }
2385
+ /**
2386
+ * Opcode 102: Request for configuration of the MDB Card Holder device.
2387
+ * @param deviceNumber The device number to request configuration for. Defaults to 1.
2388
+ * @returns The generated packet as a number array.
2389
+ */
2390
+ requestConfiguration(e = 1) {
2391
+ const t = `${e}`;
2392
+ return this.transport.buildPacket(p.requestConfiguration, t, f.APP_ID);
2393
+ }
2394
+ /**
2395
+ * Opcode 103: Request for functionalities configuration of the MDB Card Holder device.
2396
+ * @param deviceNumber The device number to request functionalities configuration for. Defaults to 1.
2397
+ * @param alwaysIdle Whether the device should always be idle (true) or not (false).
2398
+ * @param remoteVend Whether remote vend is enabled (true) or not (false).
2399
+ * @returns The generated packet as a number array.
2400
+ */
2401
+ requestFunctionalitiesConfiguration(e = 1, t, s) {
2402
+ const n = `${e},${t ? 1 : 0},${s ? 1 : 0}`;
2403
+ return this.transport.buildPacket(p.requestFunctionalitiesConfiguration, n, f.APP_ID);
2404
+ }
2405
+ /**
2406
+ * Opcode 103: Request for functionalities configuration of the MDB Card Holder device.
2407
+ * @param deviceNumber The device number to request functionalities configuration for. Defaults to 1.
2408
+ * @param alwaysIdle Whether the device should always be idle (true) or not (false).
2409
+ * @param remoteVend Whether remote vend is enabled (true) or not (false).
2410
+ * @returns The generated packet as a number array.
2411
+ */
2412
+ requestGetFunctionalitiesConfiguration(e = 1) {
2413
+ const t = `${e}`;
2414
+ return this.transport.buildPacket(p.requestFunctionalitiesConfiguration, t, f.APP_ID);
2415
+ }
2416
+ /**
2417
+ * Opcode 104: Request to enable or disable the MDB Card Holder device.
2418
+ * @param deviceNumber The device number to request enable for. Defaults to 1.
2419
+ * @param enable Whether to enable (true) or disable (false) the device.
2420
+ * @returns The generated packet as a number array.
2421
+ */
2422
+ requestEnable(e = 1, t) {
2423
+ const s = `${e},${t ? 1 : 0}`;
2424
+ return this.transport.buildPacket(p.requestEnable, s, f.APP_ID);
2425
+ }
2426
+ /**
2427
+ * Opcode 105: Request for balance data of the MDB Card Holder device.
2428
+ * @param deviceNumber The device number to request balance data for. Defaults to 1.
2429
+ * @returns The generated packet as a number array.
2430
+ */
2431
+ requestBalanceData(e = 1) {
2432
+ const t = `${e}`;
2433
+ return this.transport.buildPacket(p.requestBalanceData, t, f.APP_ID);
2434
+ }
2435
+ /**
2436
+ * Opcode 106: Request for sale approval of the MDB Card Holder device.
2437
+ * @param deviceNumber The device number to request sale approval for. Defaults to 1.
2438
+ * @param amount The amount for the sale approval.
2439
+ * @param productId The product ID for the sale approval. Defaults to null.
2440
+ * @returns The generated packet as a number array.
2441
+ */
2442
+ requestSaleApproval(e = 1, t, s = null) {
2443
+ const n = s ? `1|${s.toString()}` : "0", a = `${e},${t.toFixed(2)},${n}`;
2444
+ return this.transport.buildPacket(p.requestSaleApproval, a, f.APP_ID);
2445
+ }
2446
+ /**
2447
+ * Opcode 107: Request for sale cancellation of the MDB Card Holder device.
2448
+ * @param deviceNumber The device number to request sale cancellation for. Defaults to 1.
2449
+ * @returns The generated packet as a number array.
2450
+ */
2451
+ requestSaleCancellation(e = 1) {
2452
+ const t = `${e}`;
2453
+ return this.transport.buildPacket(p.requestSaleCancellation, t, f.APP_ID);
2454
+ }
2455
+ /**
2456
+ * Opcode 108: Request for sale success confirmation of the MDB Card Holder device.
2457
+ * @param deviceNumber The device number to request sale success confirmation for. Defaults to 1.
2458
+ * @returns The generated packet as a number array.
2459
+ */
2460
+ requestSaleSuccessConfirmation(e = 1) {
2461
+ const t = `${e}`;
2462
+ return this.transport.buildPacket(p.requestSaleSuccessConfirmation, t, f.APP_ID);
2463
+ }
2464
+ /**
2465
+ * Opcode 109: Request for sale failure confirmation of the MDB Card Holder device.
2466
+ * @param deviceNumber The device number to request sale failure confirmation for. Defaults to 1.
2467
+ * @returns The generated packet as a number array.
2468
+ */
2469
+ requestSaleFailureConfirmation(e = 1) {
2470
+ const t = `${e}`;
2471
+ return this.transport.buildPacket(p.requestSaleFailureConfirmation, t, f.APP_ID);
2472
+ }
2473
+ /**
2474
+ * Opcode 110: Request to end session of the MDB Card Holder device.
2475
+ * @param deviceNumber The device number to request end session for. Defaults to 1.
2476
+ * @returns The generated packet as a number array.
2477
+ */
2478
+ requestEndSession(e = 1) {
2479
+ const t = `${e}`;
2480
+ return this.transport.buildPacket(p.requestEndSession, t, f.APP_ID);
2481
+ }
2482
+ /**
2483
+ * Opcode 111: Request for cash record of the MDB Card Holder device.
2484
+ * @param deviceNumber The device number to request cash record for. Defaults to 1.
2485
+ * @param amount The amount for the cash record.
2486
+ * @param productId The product ID for the cash record. Defaults to null.
2487
+ * @returns The generated packet as a number array.
2488
+ */
2489
+ requestCashRecord(e = 1, t, s = null) {
2490
+ const n = s ? `1|${s.toString()}` : "0", a = `${e},${t.toFixed(2)},${n}`;
2491
+ return this.transport.buildPacket(p.requestCashRecord, a, f.APP_ID);
2492
+ }
2493
+ /**
2494
+ * Opcode 112: Request for selection request denied of the MDB Card Holder device.
2495
+ * @param deviceNumber The device number to request selection request denied for. Defaults to 1.
2496
+ * @param reasonCode The reason code for the selection request denial.
2497
+ * @returns The generated packet as a number array.
2498
+ */
2499
+ requestSelectionRequestDenied(e = 1, t) {
2500
+ const s = `${e},${t}`;
2501
+ return this.transport.buildPacket(p.requestSelectionRequestDenied, s, f.APP_ID);
2502
+ }
2503
+ /**
2504
+ * Opcode 113: Request for revalue of the MDB Card Holder device.
2505
+ * @param deviceNumber The device number to request revalue for. Defaults to 1.
2506
+ * @param amount The amount for the revalue.
2507
+ * @returns The generated packet as a number array.
2508
+ */
2509
+ requestRevalue(e = 1, t) {
2510
+ const s = `${e},${t.toFixed(2)}`;
2511
+ return this.transport.buildPacket(p.requestRevalue, s, f.APP_ID);
2512
+ }
2513
+ }
2514
+ const D = {
2515
+ 1: "inactive",
2516
+ 2: "disabled",
2517
+ 3: "enabled",
2518
+ 4: "on hold",
2519
+ 5: "selling",
2520
+ 6: "reevaluate"
2521
+ }, F = {
2522
+ connectionStatus: "disconnected",
2523
+ status: "inactive",
2524
+ info: {
2525
+ manufacturerCode: null,
2526
+ serialNumber: null,
2527
+ model: null,
2528
+ softwareVersion: null
2529
+ },
2530
+ countryCurrencyCode: null,
2531
+ abilities: {
2532
+ reloadFunds: !1,
2533
+ restoreFunds: !1,
2534
+ multipleSales: !1,
2535
+ hasDisplay: !1,
2536
+ recordCashSales: !1
2537
+ },
2538
+ alwaysIdle: {
2539
+ available: !1,
2540
+ enabled: !1
2541
+ },
2542
+ remoteVend: {
2543
+ available: !1,
2544
+ enabled: !1
2545
+ },
2546
+ balance: {
2547
+ tokenStatus: null,
2548
+ customer: 0,
2549
+ maxCardRecharge: 0,
2550
+ paymentMethod: {
2551
+ isKnown: !1,
2552
+ id: null
2553
+ },
2554
+ userGroup: null
2555
+ }
2556
+ };
2557
+ class Q {
2558
+ _commands;
2559
+ jsd;
2560
+ APP_ID = I.PERIFERIC_MDB_CARD;
2561
+ _config = {
2562
+ no1: { ...F },
2563
+ no2: { ...F }
2564
+ };
2565
+ constructor(e, t) {
2566
+ this._commands = new f(t), this.jsd = e;
2567
+ }
2568
+ async send(e, t) {
2569
+ return this.jsd._lastApplicationCode = this.APP_ID, this.jsd._toQueue(e, {
2570
+ alias: t.alias,
2571
+ waitResponse: t.waitResponse || !1,
2572
+ timeout: t.timeout || 500
2573
+ });
2574
+ }
2575
+ get cmd() {
2576
+ return this._commands;
2577
+ }
2578
+ config(e = 1) {
2579
+ if (!this._config[`no${e}`])
2580
+ throw new Error(`Configuration for device number ${e} not found.`);
2581
+ return this._config[`no${e}`];
2582
+ }
2583
+ /**
2584
+ * Opcode 100: Request for status of the MDB Card Holder device.
2585
+ * @param options.deviceNumber The device number to request status for. Defaults to 1.
2586
+ * @returns Promise resolving when the command is sent.
2587
+ */
2588
+ async requestStatus({ deviceNumber: e } = {}) {
2589
+ const t = this.cmd.requestStatus(e);
2590
+ return this.send(t, { alias: "requestStatus" });
2591
+ }
2592
+ /**
2593
+ * Opcode 101: Request for identification of the MDB Card Holder device.
2594
+ * @param options.deviceNumber The device number to request identification for. Defaults to 1.
2595
+ * @returns Promise resolving when the command is sent.
2596
+ */
2597
+ async requestIdentification({ deviceNumber: e } = {}) {
2598
+ const t = this.cmd.requestIdentification(e);
2599
+ return this.send(t, { alias: "requestIdentification" });
2600
+ }
2601
+ /**
2602
+ * Opcode 102: Request for configuration of the MDB Card Holder device.
2603
+ * @param options.deviceNumber The device number to request configuration for. Defaults to 1.
2604
+ * @returns Promise resolving when the command is sent.
2605
+ */
2606
+ async requestConfiguration({ deviceNumber: e } = {}) {
2607
+ const t = this.cmd.requestConfiguration(e);
2608
+ return this.send(t, { alias: "requestConfiguration" });
2609
+ }
2610
+ /**
2611
+ * Opcode 103: Request for functionalities configuration of the MDB Card Holder device.
2612
+ * @param options.deviceNumber The device number to request functionalities configuration for. Defaults to 1.
2613
+ * @param options.alwaysIdle Whether the device should always be idle (true) or not (false).
2614
+ * @param options.remoteVend Whether remote vend is enabled (true) or not (false).
2615
+ * @returns Promise resolving when the command is sent.
2616
+ */
2617
+ async requestSetFunctionalitiesConfiguration({
2618
+ deviceNumber: e,
2619
+ alwaysIdle: t,
2620
+ remoteVend: s
2621
+ } = {
2622
+ alwaysIdle: !1,
2623
+ remoteVend: !1
2624
+ }) {
2625
+ if (this.config(e).status !== "disabled")
2626
+ throw new Error("Functionalities configuration can only be set when the card holder is disabled.");
2627
+ const n = this.cmd.requestFunctionalitiesConfiguration(e, t, s);
2628
+ return this.send(n, { alias: "requestSetFunctionalitiesConfiguration" });
2629
+ }
2630
+ /**
2631
+ * Opcode 103: Request for functionalities configuration of the MDB Card Holder device.
2632
+ * @param options.deviceNumber The device number to request functionalities configuration for. Defaults to 1.
2633
+ * @returns Promise resolving when the command is sent.
2634
+ */
2635
+ async requestGetFunctionalitiesConfiguration({
2636
+ deviceNumber: e
2637
+ } = {}) {
2638
+ const t = this.cmd.requestGetFunctionalitiesConfiguration(e);
2639
+ return this.send(t, { alias: "requestGetFunctionalitiesConfiguration" });
2640
+ }
2641
+ /**
2642
+ * Opcode 104: Request to enable or disable the MDB Card Holder device.
2643
+ * @param options.deviceNumber The device number to request enable for. Defaults to 1.
2644
+ * @param options.enable Whether to enable (true) or disable (false) the device.
2645
+ * @returns Promise resolving when the command is sent.
2646
+ */
2647
+ async requestEnable({ deviceNumber: e, enable: t } = {
2648
+ enable: !0
2649
+ }) {
2650
+ const s = this.cmd.requestEnable(e, t);
2651
+ return this.send(s, { alias: "requestEnable" });
2652
+ }
2653
+ /**
2654
+ * Opcode 105: Request for balance data of the MDB Card Holder device.
2655
+ * @param options.deviceNumber The device number to request balance data for. Defaults to 1.
2656
+ * @returns Promise resolving when the command is sent.
2657
+ */
2658
+ async requestBalanceData({ deviceNumber: e } = {}) {
2659
+ const t = this.cmd.requestBalanceData(e);
2660
+ return this.send(t, { alias: "requestBalanceData" });
2661
+ }
2662
+ /**
2663
+ * Opcode 106: Request for sale approval of the MDB Card Holder device.
2664
+ * @param options.deviceNumber The device number to request sale approval for. Defaults to 1.
2665
+ * @param options.amount The amount for the sale approval.
2666
+ * @param options.productId The product ID for the sale approval. Defaults to null.
2667
+ * @returns Promise resolving when the command is sent.
2668
+ */
2669
+ async requestSaleApproval({ deviceNumber: e, amount: t, productId: s } = {
2670
+ amount: 0
2671
+ }) {
2672
+ if (t <= 0)
2673
+ throw new Error("Amount must be greater than 0 for sale approval.");
2674
+ if (t > 65535)
2675
+ throw new Error("Amount must be less than or equal to 65535 for sale approval.");
2676
+ if (s) {
2677
+ if (typeof s != "number")
2678
+ throw new Error("Product ID must be a number for sale approval if you specify it.");
2679
+ if (s > 65535)
2680
+ throw new Error("Product ID must be less than or equal to 65535 for sale approval.");
2681
+ }
2682
+ const n = this.config(e);
2683
+ if (n.status !== "on hold")
2684
+ throw n.status === "enabled" && (!n.alwaysIdle.available || !n.alwaysIdle.enabled) ? new Error("Sale approval cannot be requested when the card holder is enabled but not always idle.") : new Error("Sale approval can only be requested when the card holder is on hold.");
2685
+ const a = this.cmd.requestSaleApproval(e, t, s);
2686
+ return this.send(a, { alias: "requestSaleApproval" });
2687
+ }
2688
+ /**
2689
+ * Opcode 107: Request for sale cancellation of the MDB Card Holder device.
2690
+ * @param options.deviceNumber The device number to request sale cancellation for. Defaults to 1.
2691
+ * @returns Promise resolving when the command is sent.
2692
+ */
2693
+ async requestSaleCancellation({ deviceNumber: e } = {}) {
2694
+ const t = this.cmd.requestSaleCancellation(e);
2695
+ return this.send(t, { alias: "requestSaleCancellation" });
2696
+ }
2697
+ /**
2698
+ * Opcode 108: Request for sale success confirmation of the MDB Card Holder device.
2699
+ * @param options.deviceNumber The device number to request sale success confirmation for. Defaults to 1.
2700
+ * @returns Promise resolving when the command is sent.
2701
+ */
2702
+ async requestSaleSuccessConfirmation({ deviceNumber: e } = {}) {
2703
+ const t = this.cmd.requestSaleSuccessConfirmation(e);
2704
+ return this.send(t, { alias: "requestSaleSuccessConfirmation" });
2705
+ }
2706
+ /**
2707
+ * Opcode 109: Request for sale failure confirmation of the MDB Card Holder device.
2708
+ * @param options.deviceNumber The device number to request sale failure confirmation for. Defaults to 1.
2709
+ * @returns Promise resolving when the command is sent.
2710
+ */
2711
+ async requestSaleFailureConfirmation({ deviceNumber: e } = {}) {
2712
+ const t = this.cmd.requestSaleFailureConfirmation(e);
2713
+ return this.send(t, { alias: "requestSaleFailureConfirmation" });
2714
+ }
2715
+ /**
2716
+ * Opcode 110: Request to end session of the MDB Card Holder device.
2717
+ * @param options.deviceNumber The device number to request end session for. Defaults to 1.
2718
+ * @returns Promise resolving when the command is sent.
2719
+ */
2720
+ async requestEndSession({ deviceNumber: e } = {}) {
2721
+ const t = this.cmd.requestEndSession(e);
2722
+ return this.send(t, { alias: "requestEndSession" });
2723
+ }
2724
+ /**
2725
+ * Opcode 111: Request for cash record of the MDB Card Holder device.
2726
+ * @param options.deviceNumber The device number to request cash record for. Defaults to 1.
2727
+ * @param options.amount The amount for the cash record.
2728
+ * @param options.productId The product ID for the cash record. Defaults to null.
2729
+ * @returns Promise resolving when the command is sent.
2730
+ */
2731
+ async requestCashRecord({ deviceNumber: e, amount: t, productId: s } = {
2732
+ amount: 0
2733
+ }) {
2734
+ if (t <= 0)
2735
+ throw new Error("Amount must be greater than 0 for cash record.");
2736
+ if (t > 65535)
2737
+ throw new Error("Amount must be less than or equal to 65535 for cash record.");
2738
+ if (s) {
2739
+ if (typeof s != "number")
2740
+ throw new Error("Product ID must be a number for cash record if you specify it.");
2741
+ if (s > 65535)
2742
+ throw new Error("Product ID must be less than or equal to 65535 for cash record.");
2743
+ }
2744
+ const n = this.cmd.requestCashRecord(e, t, s);
2745
+ return this.send(n, { alias: "requestCashRecord" });
2746
+ }
2747
+ /**
2748
+ * Opcode 112: Request for selection request denied of the MDB Card Holder device.
2749
+ * @param options.deviceNumber The device number to request selection request denied for. Defaults to 1.
2750
+ * @param options.reasonCode The reason code for the selection request denial.
2751
+ * @returns Promise resolving when the command is sent.
2752
+ */
2753
+ async requestSelectionRequestDenied({ deviceNumber: e, reasonCode: t } = {
2754
+ reasonCode: "unknown"
2755
+ }) {
2756
+ const s = {
2757
+ unknown: 0,
2758
+ "product-not-available": 1,
2759
+ "out-of-stock": 2,
2760
+ "faulty-selection": 3,
2761
+ "no-ingredients": 4,
2762
+ "selection-locked": 5,
2763
+ "inhibited-selection": 6,
2764
+ "expired-product": 7,
2765
+ temperature: 8,
2766
+ "occupied-machine": 9,
2767
+ "insufficient-credit": 10,
2768
+ "temporarily-occupied-machine": 255
2769
+ }, n = this.cmd.requestSelectionRequestDenied(e, s[t] ?? 0);
2770
+ return this.send(n, { alias: "requestSelectionRequestDenied" });
2771
+ }
2772
+ /**
2773
+ * Opcode 113: Request for revalue of the MDB Card Holder device.
2774
+ * @param options.deviceNumber The device number to request revalue for. Defaults to 1.
2775
+ * @param options.amount The amount for the revalue.
2776
+ * @returns Promise resolving when the command is sent.
2777
+ */
2778
+ async requestRevalue({ deviceNumber: e, amount: t } = { amount: 0 }) {
2779
+ const s = this.cmd.requestRevalue(e, t);
2780
+ return this.send(s, { alias: "requestRevalue" });
2781
+ }
2782
+ serialMessage(e) {
2783
+ switch (e.opcode) {
2784
+ case p.responseCmdWrong:
2785
+ this._responseCmdWrong(e);
2786
+ break;
2787
+ case p.responseCondition:
2788
+ this._responseCondition(e);
2789
+ break;
2790
+ case p.responseIdentification:
2791
+ this._responseIdentification(e);
2792
+ break;
2793
+ case p.responseConfiguration:
2794
+ this._responseConfiguration(e);
2795
+ break;
2796
+ case p.responseFeatureConfiguration:
2797
+ this._responseFeatureConfiguration(e);
2798
+ break;
2799
+ case p.responseAuthorization:
2800
+ this._responseAuthorization(e);
2801
+ break;
2802
+ case p.responseBalanceStatement:
2803
+ this._responseBalanceStatement(e);
2804
+ break;
2805
+ case p.responseSaleApproval:
2806
+ this._responseSaleApproval(e);
2807
+ break;
2808
+ case p.responseSaleCancellation:
2809
+ this._responseSaleCancellation(e);
2810
+ break;
2811
+ case p.responseSaleSuccessConfirmation:
2812
+ this._responseSaleSuccessConfirmation(e);
2813
+ break;
2814
+ case p.responseSaleFailureConfirmation:
2815
+ this._responseSaleFailureConfirmation(e);
2816
+ break;
2817
+ case p.responseEndSession:
2818
+ this._responseEndSession(e);
2819
+ break;
2820
+ case p.responseSelectionRequest:
2821
+ this._responseSelectionRequest(e);
2822
+ break;
2823
+ case p.responseRevalue:
2824
+ this._responseRevalue(e);
2825
+ break;
2826
+ case p.responseDisplayMessage:
2827
+ this._responseDisplayMessage(e);
2828
+ break;
2829
+ case p.jsdErrorLicenseTemporarilyBlocked:
2830
+ this._responseJsdErrorLicenseTemporarilyBlocked(e);
2831
+ break;
2832
+ case p.jsdErrorLicenseNotActive:
2833
+ this._responseJsdErrorLicenseNotActive(e);
2834
+ break;
2835
+ case p.jsdErrorCommandNotExecutable:
2836
+ this._responseJsdErrorCommandNotExecutable(e);
2837
+ break;
2838
+ }
2839
+ }
2840
+ emit(e, ...t) {
2841
+ this.jsd.dispatch(`mdbCardHolder:${e}`, ...t);
2842
+ }
2843
+ _responseCmdWrong(e) {
2844
+ const t = parseInt(e.params[0], 10), s = e.params.slice(1), n = k(t);
2845
+ this.emit("wrong-cmd", {
2846
+ opcodeName: n,
2847
+ opcode: t,
2848
+ params: s
2849
+ });
2850
+ }
2851
+ _responseCondition(e) {
2852
+ const [t, s, n] = e.params, a = {
2853
+ 0: "disconnected",
2854
+ 1: "connected",
2855
+ 2: "loss of communication"
2856
+ }, i = this.config(parseInt(t, 10));
2857
+ i.status = D[n], i.connectionStatus = a[s], this.emit("condition-status", {
2858
+ deviceNumber: parseInt(t, 10),
2859
+ connectionStatus: i.connectionStatus,
2860
+ cardHolderStatus: i.status
2861
+ });
2862
+ }
2863
+ _responseIdentification(e) {
2864
+ const [t, s, n, a, i] = e.params, r = this.config(parseInt(t, 10));
2865
+ r.info.manufacturerCode = s, r.info.serialNumber = n, r.info.model = a, r.info.softwareVersion = i, this.emit("identification", {
2866
+ deviceNumber: parseInt(t, 10),
2867
+ manufacturerCode: s,
2868
+ serialNumber: n,
2869
+ model: a,
2870
+ softwareVersion: i
2871
+ });
2872
+ }
2873
+ _responseConfiguration(e) {
2874
+ const [
2875
+ t,
2876
+ s,
2877
+ n,
2878
+ a,
2879
+ i,
2880
+ r,
2881
+ o
2882
+ ] = e.params, u = this.config(parseInt(t, 10));
2883
+ u.countryCurrencyCode = s, u.abilities.reloadFunds = n === "1", u.abilities.restoreFunds = a === "1", u.abilities.multipleSales = i === "1", u.abilities.hasDisplay = r === "1", u.abilities.recordCashSales = o === "1", this.emit("configuration-data", {
2884
+ deviceNumber: parseInt(t, 10),
2885
+ countryCurrencyCode: s,
2886
+ canReloadFunds: n === "1",
2887
+ canRestoreFunds: a === "1",
2888
+ canMakeMultipleSales: i === "1",
2889
+ hasDisplay: r === "1",
2890
+ canRecorCashSales: o === "1"
2891
+ });
2892
+ }
2893
+ _responseFeatureConfiguration(e) {
2894
+ const [t, s, n] = e.params, [a, i] = s.split("|").map((l) => l === "1"), [r, o] = n.split("|").map((l) => l === "1"), u = this.config(parseInt(t, 10));
2895
+ u.alwaysIdle.available = a, u.alwaysIdle.enabled = i, u.remoteVend.available = r, u.remoteVend.enabled = o, this.emit("feature-configuration", {
2896
+ deviceNumber: parseInt(t, 10),
2897
+ alwaysIdle: {
2898
+ available: a,
2899
+ enabled: i
2900
+ },
2901
+ remoteVend: {
2902
+ available: r,
2903
+ enabled: o
2904
+ }
2905
+ });
2906
+ }
2907
+ _responseAuthorization(e) {
2908
+ const [t, s] = e.params, n = s.split("|"), [a, i] = n[0] === "0" ? [!1, n[1]] : [!0, null], r = parseInt(t, 10);
2909
+ i && D[i] && (this.config(r).status = D[i]), this.emit("authorization", {
2910
+ deviceNumber: r,
2911
+ success: a,
2912
+ reason: i
2913
+ });
2914
+ }
2915
+ _responseBalanceStatement(e) {
2916
+ const [t, s, n, a, i, r] = e.params, o = i.split("|"), u = parseInt(t, 10), l = this.config(u);
2917
+ l.balance.tokenStatus = s === "0" ? "idle" : "active", l.balance.customer = parseFloat(n), l.balance.maxCardRecharge = parseFloat(a), l.balance.paymentMethod.isKnown = o[0] === "1", l.balance.paymentMethod.id = o[1] || null, l.balance.userGroup = r, this.emit("balance-statement", {
2918
+ deviceNumber: u,
2919
+ tokenBalanceStatus: s === "0" ? "idle" : "active",
2920
+ customerBalance: parseFloat(n),
2921
+ maxCardRecharge: parseFloat(a),
2922
+ paymentMethod: {
2923
+ isKnown: o[0] === "1",
2924
+ id: o[1] || null
2925
+ },
2926
+ groupWhichCardBelongs: r
2927
+ });
2928
+ }
2929
+ _responseSaleApproval(e) {
2930
+ const [t, s] = e.params, n = s.split("|"), a = {
2931
+ 0: "unable to execute",
2932
+ 1: "petition initiated",
2933
+ 2: "sale denied",
2934
+ 3: "sale approved"
2935
+ }, i = parseInt(t, 10), r = this.config(i), o = {
2936
+ deviceNumber: i,
2937
+ status: a[n[0]]
2938
+ };
2939
+ n[0] === "0" && n.length > 1 && (r.status = D[n[1]], o.currentCardHolderStatus = r.status), n[0] === "3" && n.length > 1 && (o.amountCharged = parseFloat(n[1])), this.emit("sale-approval", o);
2940
+ }
2941
+ _responseSaleCancellation(e) {
2942
+ const [t, s] = e.params, n = s.split("|"), a = parseInt(t, 10), i = this.config(a);
2943
+ n[0] === "0" && n.length > 1 && (i.status = D[n[1]]), this.emit("sale-cancellation", {
2944
+ deviceNumber: a,
2945
+ status: n[0] === "1" ? "success" : "failure",
2946
+ currentCardHolderStatus: n.length > 1 ? i.status : null
2947
+ });
2948
+ }
2949
+ _responseSaleSuccessConfirmation(e) {
2950
+ const [t, s] = e.params, n = s.split("|"), a = {
2951
+ 0: "unable to execute",
2952
+ 1: "petition initiated",
2953
+ 2: "the card has been updated"
2954
+ }, i = parseInt(t, 10), r = this.config(i);
2955
+ n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("sale-success-confirmation", {
2956
+ deviceNumber: i,
2957
+ status: a[n[0]],
2958
+ currentCardHolderStatus: n.length > 1 ? r.status : null
2959
+ });
2960
+ }
2961
+ _responseSaleFailureConfirmation(e) {
2962
+ const [t, s] = e.params, n = s.split("|"), a = {
2963
+ 0: "unable to execute",
2964
+ 1: "petition initiated",
2965
+ 2: "refund error",
2966
+ 3: "refund made"
2967
+ }, i = parseInt(t, 10), r = this.config(i);
2968
+ n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("sale-failure-confirmation", {
2969
+ deviceNumber: i,
2970
+ status: a[n[0]],
2971
+ currentCardHolderStatus: n.length > 1 ? r.status : null
2972
+ });
2973
+ }
2974
+ _responseEndSession(e) {
2975
+ const [t, s] = e.params, n = s.split("|"), a = {
2976
+ 0: "unable to execute",
2977
+ 1: "petition initiated"
2978
+ }, i = parseInt(t, 10), r = this.config(i);
2979
+ n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("end-session", {
2980
+ deviceNumber: i,
2981
+ status: a[n[0]],
2982
+ currentCardHolderStatus: n.length > 1 ? r.status : null
2983
+ });
2984
+ }
2985
+ _responseSelectionRequest(e) {
2986
+ const [t, s, n, a, i, r] = e.params, o = a.split("|"), u = r ? r.split("|") : [], l = {
2987
+ 0: "default",
2988
+ 1: "sugar-free",
2989
+ 2: "intermediate",
2990
+ 3: "intermediate",
2991
+ 4: "intermediate",
2992
+ 5: "intermediate",
2993
+ 6: "intermediate",
2994
+ 7: "sugar-max"
2995
+ }, h = parseInt(t, 10), g = this.config(h);
2996
+ g.balance.tokenStatus = s === "0" ? "idle" : "active", g.balance.customer = parseFloat(n), g.balance.paymentMethod.isKnown = o[0] === "1", g.balance.paymentMethod.id = o[1] || null, this.emit("selection-request", {
2997
+ deviceNumber: parseInt(t, 10),
2998
+ tokenBalanceStatus: s === "0" ? "idle" : "active",
2999
+ customerBalance: parseFloat(n),
3000
+ paymentMethod: {
3001
+ isKnown: o[0] === "1",
3002
+ id: o[1] || null
3003
+ },
3004
+ product: {
3005
+ id: i ? parseInt(i, 10) : null,
3006
+ withLid: u[0] === "1",
3007
+ sugarLevel: l[u[1]] || "default"
3008
+ }
3009
+ });
3010
+ }
3011
+ _responseRevalue(e) {
3012
+ const [t, s] = e.params, n = s.split("|"), a = {
3013
+ 0: "unable to execute",
3014
+ 1: "petition initiated",
3015
+ 2: "revalue denied",
3016
+ 3: "revalue approved"
3017
+ }, i = parseInt(t, 10), r = this.config(i);
3018
+ n[0] === "0" && n.length > 1 && (r.status = D[n[1]]), this.emit("revalue", {
3019
+ deviceNumber: i,
3020
+ status: a[n[0]],
3021
+ currentCardHolderStatus: n.length > 1 ? r.status : null
3022
+ });
3023
+ }
3024
+ _responseDisplayMessage(e) {
3025
+ const [t, s, n] = e.params, [a, i] = n.split("|");
3026
+ this.emit("display-message", {
3027
+ deviceNumber: parseInt(t, 10),
3028
+ displayTimeSeconds: parseInt(s, 10) / 10,
3029
+ message: {
3030
+ line1: a,
3031
+ line2: i
3032
+ }
3033
+ });
3034
+ }
3035
+ _responseJsdErrorLicenseTemporarilyBlocked(e) {
3036
+ const [t, ...s] = e.params;
3037
+ this.emit("jsd-license-error", {
3038
+ type: "expired-license",
3039
+ opcode: parseInt(t, 10),
3040
+ actionName: k(parseInt(t, 10)),
3041
+ params: s
3042
+ });
3043
+ }
3044
+ _responseJsdErrorLicenseNotActive(e) {
3045
+ const [t, ...s] = e.params;
3046
+ this.emit("jsd-license-error", {
3047
+ type: "app-number-not-licensed",
3048
+ opcode: parseInt(t, 10),
3049
+ actionName: k(parseInt(t, 10)),
3050
+ params: s
3051
+ });
3052
+ }
3053
+ _responseJsdErrorCommandNotExecutable(e) {
3054
+ const [t, ...s] = e.params;
3055
+ this.emit("jsd-license-error", {
3056
+ type: "price-control-active-direct-dispense-not-allowed",
3057
+ opcode: parseInt(t, 10),
3058
+ actionName: k(parseInt(t, 10)),
3059
+ params: s
3060
+ });
3061
+ }
2280
3062
  }
2281
- class U {
3063
+ class G {
2282
3064
  /**
2283
3065
  * Reverse Transparency (Byte Destuffing).
2284
3066
  * Converts 0xDB,0xDC -> 0xC0 and 0xDB,0xDD -> 0xDB.
@@ -2309,8 +3091,8 @@ class U {
2309
3091
  const s = this.unescapeBytes(t);
2310
3092
  if (s.length < 1)
2311
3093
  return console.error("Frame too short"), "Frame too short";
2312
- const n = s[0], a = s[1], i = s.slice(2, -2), c = s[s.length - 2], o = s[s.length - 1], h = [192, n, a, ...i], [d, l] = T.calculate(h);
2313
- if (d !== c || l !== o)
3094
+ const n = s[0], a = s[1], i = s.slice(2, -2), r = s[s.length - 2], o = s[s.length - 1], u = [192, n, a, ...i], [l, h] = N.calculate(u);
3095
+ if (l !== r || h !== o)
2314
3096
  return console.error("CRC mismatch"), "CRC mismatch";
2315
3097
  if (n === 2) return { type: "ACK", id: a };
2316
3098
  if (n === 3) return { type: "NACK", id: a };
@@ -2318,19 +3100,19 @@ class U {
2318
3100
  return console.warn("Unknown code"), "Unknown code";
2319
3101
  if (i.length < 6)
2320
3102
  return console.error("JConnect header too short"), "JConnect header too short";
2321
- const m = i[0] | i[1] << 8, I = i[2] | i[3] << 8, D = i[4] | i[5] << 8, v = i.slice(6), A = String.fromCharCode(...v);
3103
+ const g = i[0] | i[1] << 8, C = i[2] | i[3] << 8, P = i[4] | i[5] << 8, O = i.slice(6), v = String.fromCharCode(...O);
2322
3104
  return {
2323
3105
  type: "DATA",
2324
- opcode: D,
2325
- appId: I,
2326
- noBytes: m,
2327
- params: A ? A.split(",") : [],
3106
+ opcode: P,
3107
+ appId: C,
3108
+ noBytes: g,
3109
+ params: v ? v.split(",") : [],
2328
3110
  id: a,
2329
- rawAscii: A
3111
+ rawAscii: v
2330
3112
  };
2331
3113
  }
2332
3114
  }
2333
- class j {
3115
+ class H {
2334
3116
  delimiter;
2335
3117
  buffer;
2336
3118
  /**
@@ -2381,11 +3163,12 @@ class j {
2381
3163
  this.buffer.length > 0 && (e.enqueue(this.buffer), this.buffer = new Uint8Array(0));
2382
3164
  }
2383
3165
  }
2384
- class K extends O {
3166
+ class Y extends M {
2385
3167
  _transport;
2386
3168
  vision;
2387
3169
  manifest;
2388
3170
  licensing;
3171
+ mdbCardHolder;
2389
3172
  _queue = [];
2390
3173
  _timeoutPacketId = 0;
2391
3174
  _runningQueue = !1;
@@ -2397,10 +3180,10 @@ class K extends O {
2397
3180
  socket: n = !1,
2398
3181
  transport: a = "rs232"
2399
3182
  } = {}) {
2400
- const i = new Uint8Array([192]), c = () => new TransformStream(new j(i));
2401
- if (super({ filters: e, config_port: t, no_device: s, socket: n, transformStream: c }), this.__internal__.device.type = "jsd", this.__internal__.time.response_general = 500, this.__internal__.time.response_engines = 500, N.getCustom(this.typeDevice, s))
3183
+ const i = new Uint8Array([192]), r = () => new TransformStream(new H(i));
3184
+ if (super({ filters: e, config_port: t, no_device: s, socket: n, transformStream: r }), this.__internal__.device.type = "jsd", this.__internal__.time.response_general = 500, this.__internal__.time.response_engines = 500, q.getCustom(this.typeDevice, s))
2402
3185
  throw new Error(`Device ${this.typeDevice} ${s} already exists`);
2403
- N.add(this), this.#t(), this.getResponseAsUint8Array(), this._transport = a === "rs232" ? new k() : new b(), this.vision = new M(this, this._transport), this.manifest = new R(this, this._transport), this.licensing = new $(this, this._transport), this.#e();
3186
+ q.add(this), this.#t(), this.getResponseAsUint8Array(), this._transport = a === "rs232" ? new w() : new L(), this.vision = new j(this, this._transport), this.manifest = new W(this, this._transport), this.licensing = new K(this, this._transport), this.mdbCardHolder = new Q(this, this._transport), this.#e();
2404
3187
  }
2405
3188
  #e() {
2406
3189
  this.on("serial:connected", async () => {
@@ -2416,6 +3199,8 @@ class K extends O {
2416
3199
  "licensing:feature-status",
2417
3200
  "licensing:seed",
2418
3201
  "licensing:temporary-license-status",
3202
+ "licensing:report",
3203
+ "licensing:identification",
2419
3204
  "manifest:wrong-cmd",
2420
3205
  "manifest:log",
2421
3206
  "manifest:block",
@@ -2455,10 +3240,10 @@ class K extends O {
2455
3240
  this.serialRegisterAvailableListener(t);
2456
3241
  }
2457
3242
  serialSetConnectionConstant() {
2458
- const e = this._transport ? this._transport : new k();
3243
+ const e = this._transport ? this._transport : new w();
2459
3244
  let t = 255;
2460
3245
  this._transport && (t = e.packetId, this._transport._overridePacketId(t + 1));
2461
- const { bytes: s } = u.connection({ transport: e, packetId: t });
3246
+ const { bytes: s } = d.connection({ transport: e, packetId: t });
2462
3247
  return s;
2463
3248
  }
2464
3249
  send(e, t) {
@@ -2512,7 +3297,7 @@ class K extends O {
2512
3297
  serialMessage(e) {
2513
3298
  const t = Array.from(structuredClone(e));
2514
3299
  if (t.length === 0) return;
2515
- const s = U.parseFrame(t);
3300
+ const s = G.parseFrame(t);
2516
3301
  if (typeof s == "string")
2517
3302
  this.dispatch("serial:jsd-error", s);
2518
3303
  else if (s.type === "ACK")
@@ -2522,7 +3307,7 @@ class K extends O {
2522
3307
  else if (s.type === "DATA") {
2523
3308
  this.ack(s.id), typeof s.appId > "u" && (s.appId = this._lastApplicationCode);
2524
3309
  const n = s.appId;
2525
- L(n) && this.vision.serialMessage(s), w(n) && this.manifest.serialMessage(s), F(n) && this.licensing.serialMessage(s), this.dispatch("serial:jsd-data", s);
3310
+ R(n) && this.vision.serialMessage(s), B(n) && this.manifest.serialMessage(s), x(n) && this.licensing.serialMessage(s), this.dispatch("serial:jsd-data", s);
2526
3311
  }
2527
3312
  this.dispatch("serial:message", {
2528
3313
  raw: e,
@@ -2532,5 +3317,5 @@ class K extends O {
2532
3317
  }
2533
3318
  }
2534
3319
  export {
2535
- K as JSD
3320
+ Y as JSD
2536
3321
  };