@danidoble/webserial 4.2.3 → 4.2.5

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.
@@ -0,0 +1,1341 @@
1
+ const g = (i) => {
2
+ if (i instanceof Uint8Array)
3
+ return i;
4
+ if (Array.isArray(i))
5
+ return new Uint8Array(i);
6
+ if (typeof i == "string")
7
+ return new TextEncoder().encode(i);
8
+ if (i instanceof ArrayBuffer)
9
+ return new Uint8Array(i);
10
+ throw new Error("Unsupported data type");
11
+ }, P = ({
12
+ data: i,
13
+ asString: e = !0
14
+ }) => e ? Array.from(i).map((n) => n.toString(16).padStart(2, "0")).join(" ") : Array.from(i).map((n) => n.toString(16).padStart(2, "0"));
15
+ var F = Object.defineProperty, L = (i, e, n) => e in i ? F(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, S = (i, e, n) => L(i, typeof e != "symbol" ? e + "" : e, n);
16
+ const f = class d {
17
+ build(e) {
18
+ return g(e + d.append);
19
+ }
20
+ static connection() {
21
+ return d.instance.build("CONNECT");
22
+ }
23
+ static connect() {
24
+ return d.connection();
25
+ }
26
+ static credits() {
27
+ return d.instance.build("CREDITS");
28
+ }
29
+ static hi() {
30
+ return d.instance.build("HI");
31
+ }
32
+ static ara() {
33
+ return d.instance.build("ARA");
34
+ }
35
+ static custom(e) {
36
+ return d.instance.build(e);
37
+ }
38
+ };
39
+ S(f, "append", `
40
+ `), S(f, "instance");
41
+ let k = f;
42
+ k.instance = new k();
43
+ var H = Object.defineProperty, B = (i, e, n) => e in i ? H(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, I = (i, e, n) => B(i, typeof e != "symbol" ? e + "" : e, n);
44
+ const b = class c {
45
+ build(e) {
46
+ return c.asHex ? P({ data: e, asString: !1 }) : g(e);
47
+ }
48
+ serialBoardroidSumHex(e) {
49
+ let n = 0;
50
+ for (let a = 0; a < e.length; a++)
51
+ a === 0 || a === 11 || (n += e[a]);
52
+ return n;
53
+ }
54
+ boardroidCheckSum(e) {
55
+ return e[11] = this.serialBoardroidSumHex(e), e;
56
+ }
57
+ static connection({ channel: e = 1 } = {}) {
58
+ const n = c.instance.boardroidCheckSum(
59
+ new Uint8Array([
60
+ 241,
61
+ 5 + e,
62
+ 0,
63
+ 0,
64
+ 0,
65
+ 0,
66
+ 0,
67
+ 0,
68
+ 0,
69
+ 0,
70
+ 242,
71
+ 248
72
+ ])
73
+ );
74
+ return c.instance.build(n);
75
+ }
76
+ static coinPurseConfiguration({
77
+ enable: e = !1,
78
+ high: n = 255,
79
+ low: a = 255
80
+ } = {}) {
81
+ const t = c.instance.boardroidCheckSum(
82
+ new Uint8Array([
83
+ 241,
84
+ 193,
85
+ e ? 1 : 0,
86
+ n,
87
+ a,
88
+ 0,
89
+ 0,
90
+ 0,
91
+ 0,
92
+ 0,
93
+ 242,
94
+ 0
95
+ ])
96
+ );
97
+ return c.instance.build(t);
98
+ }
99
+ static coinPurseDispense({ $50c: e = 0, $1: n = 0, $2: a = 0, $5: t = 0, $10: s = 0 } = {}) {
100
+ if ([e, n, a, t, s].some(
101
+ (u) => isNaN(u) || typeof u == "string"
102
+ ))
103
+ throw new Error("One of the values is not a number");
104
+ if (e < 1 && n < 1 && a < 1 && t < 1 && s < 1)
105
+ throw new Error("No coins to dispense");
106
+ const o = c.instance.boardroidCheckSum(
107
+ new Uint8Array([
108
+ 241,
109
+ 198,
110
+ e,
111
+ n,
112
+ a,
113
+ t,
114
+ s,
115
+ 0,
116
+ 0,
117
+ 0,
118
+ 242,
119
+ 0
120
+ ])
121
+ );
122
+ return c.instance.build(o);
123
+ }
124
+ static coinPurseReadTubes() {
125
+ const e = c.instance.boardroidCheckSum(
126
+ new Uint8Array([
127
+ 241,
128
+ 194,
129
+ 0,
130
+ 0,
131
+ 0,
132
+ 0,
133
+ 0,
134
+ 0,
135
+ 0,
136
+ 0,
137
+ 242,
138
+ 0
139
+ ])
140
+ );
141
+ return c.instance.build(e);
142
+ }
143
+ static banknotePurseICTConfigure({ enable: e = !1, scrow: n = !1 } = {}) {
144
+ const a = e ? 255 : 0, t = n ? 255 : 0, s = c.instance.boardroidCheckSum(
145
+ new Uint8Array([
146
+ 241,
147
+ 192,
148
+ a,
149
+ a,
150
+ t,
151
+ t,
152
+ 0,
153
+ 0,
154
+ 0,
155
+ 0,
156
+ 242,
157
+ 0
158
+ ])
159
+ );
160
+ return c.instance.build(s);
161
+ }
162
+ static banknotePurseOtherConfigure({ enable: e = !1, scrow: n = !1 } = {}) {
163
+ const a = e ? 1 : 0, t = n ? 1 : 0, s = c.instance.boardroidCheckSum(
164
+ new Uint8Array([
165
+ 241,
166
+ 192,
167
+ a,
168
+ t,
169
+ 0,
170
+ 0,
171
+ 0,
172
+ 0,
173
+ 0,
174
+ 0,
175
+ 242,
176
+ 0
177
+ ])
178
+ );
179
+ return c.instance.build(s);
180
+ }
181
+ static banknotePurseICTDispense({
182
+ quantity: e = 1,
183
+ denomination: n = 20
184
+ }) {
185
+ if (e < 1)
186
+ throw new Error("No banknotes to dispense");
187
+ if ([20, 50, 100, 200, 500].indexOf(n) === -1)
188
+ throw new Error("Invalid denomination");
189
+ const a = [20, 50, 100, 200, 500].indexOf(n), t = c.instance.boardroidCheckSum(
190
+ new Uint8Array([
191
+ 241,
192
+ 197,
193
+ a,
194
+ e,
195
+ 0,
196
+ 0,
197
+ 0,
198
+ 0,
199
+ 0,
200
+ 0,
201
+ 242,
202
+ 0
203
+ ])
204
+ );
205
+ return c.instance.build(t);
206
+ }
207
+ static banknotePurseOtherDispense({
208
+ $20: e = 0,
209
+ $50: n = 0,
210
+ $100: a = 0,
211
+ $200: t = 0,
212
+ $500: s = 0,
213
+ $1000: o = 0
214
+ } = {}) {
215
+ if ([e, n, a, t, s, o].some(
216
+ (m) => isNaN(m) || typeof m == "string"
217
+ ))
218
+ throw new Error("One of the values is not a number");
219
+ if (e < 1 && n < 1 && a < 1 && t < 1 && s < 1 && o < 1)
220
+ throw new Error("No banknotes to dispense");
221
+ const u = c.instance.boardroidCheckSum(
222
+ new Uint8Array([
223
+ 241,
224
+ 197,
225
+ e,
226
+ n,
227
+ a,
228
+ t,
229
+ s,
230
+ o,
231
+ 0,
232
+ 0,
233
+ 242,
234
+ 0
235
+ ])
236
+ );
237
+ return c.instance.build(u);
238
+ }
239
+ static banknotePurseAcceptInScrow() {
240
+ const e = c.instance.boardroidCheckSum(
241
+ new Uint8Array([
242
+ 241,
243
+ 196,
244
+ 1,
245
+ 0,
246
+ 0,
247
+ 0,
248
+ 0,
249
+ 0,
250
+ 0,
251
+ 0,
252
+ 242,
253
+ 0
254
+ ])
255
+ );
256
+ return c.instance.build(e);
257
+ }
258
+ static banknotePurseRejectInScrow() {
259
+ const e = c.instance.boardroidCheckSum(
260
+ new Uint8Array([
261
+ 241,
262
+ 196,
263
+ 0,
264
+ 0,
265
+ 0,
266
+ 0,
267
+ 0,
268
+ 0,
269
+ 0,
270
+ 0,
271
+ 242,
272
+ 0
273
+ ])
274
+ );
275
+ return c.instance.build(e);
276
+ }
277
+ static banknotePurseSaveMemory({
278
+ channel: e = null,
279
+ $20: n = null,
280
+ $50: a = null,
281
+ $100: t = null,
282
+ $200: s = null,
283
+ $500: o = null,
284
+ $1000: u = null
285
+ } = {
286
+ channel: null,
287
+ $20: null,
288
+ $50: null,
289
+ $100: null,
290
+ $200: null,
291
+ $500: null,
292
+ $1000: null
293
+ }) {
294
+ if (e === null || n === null || a === null || t === null || s === null || o === null || u === null)
295
+ throw new Error(
296
+ "One of the values is not defined: " + JSON.stringify({
297
+ channel: e,
298
+ $20: n,
299
+ $50: a,
300
+ $100: t,
301
+ $200: s,
302
+ $500: o,
303
+ $1000: u
304
+ })
305
+ );
306
+ const m = c.instance.boardroidCheckSum(
307
+ new Uint8Array([
308
+ 241,
309
+ 200,
310
+ e,
311
+ 0,
312
+ n,
313
+ a,
314
+ t,
315
+ s,
316
+ o,
317
+ u,
318
+ 242,
319
+ 0
320
+ ])
321
+ );
322
+ return c.instance.build(m);
323
+ }
324
+ static banknotePurseReadRecycler() {
325
+ const e = c.instance.boardroidCheckSum(
326
+ new Uint8Array([
327
+ 241,
328
+ 195,
329
+ 0,
330
+ 0,
331
+ 0,
332
+ 0,
333
+ 0,
334
+ 0,
335
+ 0,
336
+ 0,
337
+ 242,
338
+ 181
339
+ ])
340
+ );
341
+ return c.instance.build(e);
342
+ }
343
+ static cardReaderDisable() {
344
+ const e = c.instance.boardroidCheckSum(
345
+ new Uint8Array([
346
+ 241,
347
+ 205,
348
+ 0,
349
+ 0,
350
+ 0,
351
+ 0,
352
+ 0,
353
+ 0,
354
+ 0,
355
+ 0,
356
+ 242,
357
+ 0
358
+ ])
359
+ );
360
+ return c.instance.build(e);
361
+ }
362
+ static cardReaderDispense({
363
+ selection: e = 1,
364
+ second_selection: n = null,
365
+ sensor: a = !0,
366
+ seconds: t = null,
367
+ price: s = 0
368
+ } = {
369
+ selection: 1,
370
+ second_selection: null,
371
+ sensor: !0,
372
+ seconds: null,
373
+ price: 0
374
+ }) {
375
+ const o = s / 256, u = s % 256, m = e + 9;
376
+ let p = 0;
377
+ n && (p = n + 9);
378
+ let E = 0;
379
+ a || (t || (t = 1.5), E = Math.round(t * 6.2));
380
+ const M = c.instance.boardroidCheckSum(
381
+ new Uint8Array([
382
+ 241,
383
+ 205,
384
+ 1,
385
+ m,
386
+ p,
387
+ E,
388
+ o,
389
+ u,
390
+ 0,
391
+ 0,
392
+ 242,
393
+ 0
394
+ ])
395
+ );
396
+ return c.instance.build(M);
397
+ }
398
+ static coolingRelayConfigure({ enable: e = !0 } = {}) {
399
+ const n = c.instance.boardroidCheckSum(
400
+ new Uint8Array([
401
+ 241,
402
+ 204,
403
+ e ? 1 : 0,
404
+ 0,
405
+ 0,
406
+ 0,
407
+ 0,
408
+ 0,
409
+ 0,
410
+ 0,
411
+ 242,
412
+ 0
413
+ ])
414
+ );
415
+ return c.instance.build(n);
416
+ }
417
+ static readTemperature() {
418
+ const e = c.instance.boardroidCheckSum(
419
+ new Uint8Array([
420
+ 241,
421
+ 203,
422
+ 0,
423
+ 0,
424
+ 0,
425
+ 0,
426
+ 0,
427
+ 0,
428
+ 0,
429
+ 0,
430
+ 242,
431
+ 0
432
+ ])
433
+ );
434
+ return c.instance.build(e);
435
+ }
436
+ static dispense({
437
+ selection: e = 1,
438
+ second_selection: n = null,
439
+ sensor: a = !0,
440
+ seconds: t = null
441
+ } = {
442
+ selection: 1,
443
+ second_selection: null,
444
+ sensor: !0,
445
+ seconds: null
446
+ }) {
447
+ e += 9;
448
+ const s = e;
449
+ let o = 0;
450
+ n && (n += 9, o = n);
451
+ let u = 0;
452
+ a || (t || (t = 1.5), u = Math.round(t * 6.2));
453
+ const m = c.instance.boardroidCheckSum(
454
+ new Uint8Array([
455
+ 241,
456
+ 199,
457
+ s,
458
+ o,
459
+ u,
460
+ 0,
461
+ 0,
462
+ 0,
463
+ 0,
464
+ 0,
465
+ 242,
466
+ 0
467
+ ])
468
+ );
469
+ return c.instance.build(m);
470
+ }
471
+ static customCode(e) {
472
+ typeof e[0] == "string" && (e = e.map((a) => parseInt(a, 16)));
473
+ const n = c.instance.boardroidCheckSum(
474
+ new Uint8Array(e)
475
+ );
476
+ return c.instance.build(n);
477
+ }
478
+ };
479
+ I(b, "asHex", !1), I(b, "instance");
480
+ let N = b;
481
+ N.instance = new N();
482
+ var J = Object.defineProperty, G = (i, e, n) => e in i ? J(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, A = (i, e, n) => G(i, typeof e != "symbol" ? e + "" : e, n);
483
+ const w = class r {
484
+ build(e) {
485
+ const n = this.jofemarCheckSum(e);
486
+ return r.asHex ? P({
487
+ data: new Uint8Array(n),
488
+ asString: !1
489
+ }) : g(n);
490
+ }
491
+ calcCheckSums(e) {
492
+ const n = [];
493
+ return n.push(e & 255 | 240), n.push(e & 255 | 15), n;
494
+ }
495
+ jofemarCheckSum(e) {
496
+ let n = 0;
497
+ for (let t = 0; t < e.length; t++)
498
+ n += e[t];
499
+ const a = this.calcCheckSums(n);
500
+ return e.push(a[0]), e.push(a[1]), e.push(3), new Uint8Array(e);
501
+ }
502
+ getTrayAndChannelBySelection(e) {
503
+ if (e = parseInt(e) + 109, e = e.toString(), e.length !== 3)
504
+ throw new Error("Invalid selection");
505
+ const n = (parseInt(e.substring(0, 2)) + 128).toString(16).padStart(2, "0"), a = (parseInt(e.substring(2, 3)) + 128).toString(16).padStart(2, "0");
506
+ return { channel: parseInt(a, 16), tray: parseInt(n, 16) };
507
+ }
508
+ makeDisplayMessage(e = "") {
509
+ e = e.padEnd(32, " ");
510
+ const n = [];
511
+ for (let a = 0; a < 32; a++)
512
+ n.push(e.charCodeAt(a));
513
+ return n;
514
+ }
515
+ makeTimeFormat(e) {
516
+ if (!(e instanceof Date))
517
+ throw new Error("Invalid date, must be an instance of Date");
518
+ const n = e.getHours().toString().padStart(2, "0"), a = e.getMinutes().toString().padStart(2, "0"), t = e.getDate().toString().padStart(2, "0"), s = (e.getMonth() + 1).toString().padStart(2, "0"), o = e.getFullYear().toString().substring(2, 4), u = `${n}:${a} ${t}-${s}-${o}`, m = [];
519
+ for (let p = 0; p < 14; p++)
520
+ m.push(u.charCodeAt(p));
521
+ return m;
522
+ }
523
+ static connection({ channel: e = 1 } = {}) {
524
+ return r.instance.build([
525
+ 2,
526
+ 48,
527
+ 48,
528
+ 128 + e,
529
+ 83,
530
+ 255,
531
+ 255
532
+ ]);
533
+ }
534
+ static dispense({ machineChannel: e = 1, selection: n = 1, cart: a = !1 } = {
535
+ machineChannel: 1,
536
+ selection: 1,
537
+ cart: !1
538
+ }) {
539
+ if (n = parseInt(n), isNaN(n) || n < 1 || n > 130)
540
+ throw new Error("Invalid selection");
541
+ const { channel: t, tray: s } = r.instance.getTrayAndChannelBySelection(n);
542
+ return r.instance.build([
543
+ 2,
544
+ 48,
545
+ 48,
546
+ 128 + e,
547
+ a ? 77 : 86,
548
+ s,
549
+ t
550
+ ]);
551
+ }
552
+ static endCartDispense({ machineChannel: e = 1 } = {}) {
553
+ return r.instance.build([
554
+ 2,
555
+ 48,
556
+ 48,
557
+ 128 + e,
558
+ 77,
559
+ 128,
560
+ 128
561
+ ]);
562
+ }
563
+ static collect({ machineChannel: e = 1 } = {}) {
564
+ return r.instance.build([
565
+ 2,
566
+ 48,
567
+ 48,
568
+ 128 + e,
569
+ 78,
570
+ 255,
571
+ 255
572
+ ]);
573
+ }
574
+ static reset({ machineChannel: e = 1, type: n = "soldOut" } = {}) {
575
+ let a = 128;
576
+ return n === "waiting" ? a = 129 : n === "machine" && (a = 255), r.instance.build([
577
+ 2,
578
+ 48,
579
+ 48,
580
+ 128 + e,
581
+ 82,
582
+ a,
583
+ 255
584
+ ]);
585
+ }
586
+ static status({ machineChannel: e = 1 } = {}) {
587
+ return r.instance.build([
588
+ 2,
589
+ 48,
590
+ 48,
591
+ 128 + e,
592
+ 83,
593
+ 255,
594
+ 255
595
+ ]);
596
+ }
597
+ static lights({ machineChannel: e = 1, type: n = "on" } = {}) {
598
+ const a = n === "on" ? 129 : 128;
599
+ return r.instance.build([
600
+ 2,
601
+ 48,
602
+ 48,
603
+ 128 + e,
604
+ 76,
605
+ a,
606
+ 255
607
+ ]);
608
+ }
609
+ static program({
610
+ machineChannel: e = 1,
611
+ param1: n = 255,
612
+ param2: a = 255
613
+ } = {}) {
614
+ return r.instance.build([
615
+ 2,
616
+ 48,
617
+ 48,
618
+ 128 + e,
619
+ 80,
620
+ n,
621
+ a
622
+ ]);
623
+ }
624
+ static programDisplayLanguage({
625
+ machineChannel: e = 1,
626
+ language: n = "spanish"
627
+ } = {}) {
628
+ const a = { spanish: 48, english: 49, french: 50 };
629
+ if (!a[n]) throw new Error("Invalid language");
630
+ return r.program({
631
+ machineChannel: e,
632
+ param1: 73,
633
+ param2: a[n]
634
+ });
635
+ }
636
+ static programBeeper({
637
+ machineChannel: e = 1,
638
+ enable: n = !0
639
+ }) {
640
+ return r.program({
641
+ machineChannel: e,
642
+ param1: 90,
643
+ param2: n ? 49 : 48
644
+ });
645
+ }
646
+ static programDisableWorkingTemperature({
647
+ machineChannel: e = 1
648
+ }) {
649
+ return r.program({
650
+ machineChannel: e,
651
+ param1: 84,
652
+ param2: 128
653
+ });
654
+ }
655
+ static programDisableThermometer({
656
+ machineChannel: e = 1
657
+ }) {
658
+ return r.programDisableWorkingTemperature({ machineChannel: e });
659
+ }
660
+ static programWorkingTemperature({
661
+ machineChannel: e = 1,
662
+ degrees: n = 0.5,
663
+ machineType: a = "esplus"
664
+ } = {}) {
665
+ typeof n == "string" && (n = parseFloat(n));
666
+ const t = a === "iceplus" ? 6.5 : 32, s = a === "iceplus" ? -25 : 0.5;
667
+ if (isNaN(n) || n < s || n > t || n % 0.5 !== 0)
668
+ throw new Error(
669
+ "Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32"
670
+ );
671
+ let o = n * 2 + 128;
672
+ return a === "iceplus" && (o += 51), o = Math.ceil(o), r.program({ param1: 84, param2: o, machineChannel: e });
673
+ }
674
+ static programIsolationTray({
675
+ machineChannel: e = 1,
676
+ tray: n = 0
677
+ }) {
678
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 0 || n > 12)
679
+ throw new Error("Invalid tray, valid range is 0 to 12");
680
+ const a = n === 0 ? 128 : n + 139;
681
+ return r.program({ param1: 66, param2: a, machineChannel: e });
682
+ }
683
+ static programTimeToStandbyAfterCollect({
684
+ machineChannel: e = 1,
685
+ seconds: n = 15
686
+ } = {}) {
687
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 15 || n > 120)
688
+ throw new Error("Invalid seconds, valid range is 15 to 120");
689
+ const a = 128 + n;
690
+ return r.program({ param1: 70, param2: a, machineChannel: e });
691
+ }
692
+ static programTimeToStandbyWithoutCollect({
693
+ machineChannel: e = 1,
694
+ minutes: n = 1
695
+ } = {}) {
696
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 10)
697
+ throw new Error("Invalid minutes, valid range is 1 to 10");
698
+ const a = 128 + n;
699
+ return r.program({ param1: 72, param2: a, machineChannel: e });
700
+ }
701
+ static programElevatorSpeed({
702
+ machineChannel: e = 1,
703
+ speed: n = "high"
704
+ } = {}) {
705
+ const a = { high: 49, low: 48 };
706
+ if (!a[n])
707
+ throw new Error("Invalid speed, valid speeds are 'high' and 'low'");
708
+ return r.program({
709
+ param1: 118,
710
+ param2: a[n],
711
+ machineChannel: e
712
+ });
713
+ }
714
+ static programTemperatureExpiration({
715
+ machineChannel: e = 1,
716
+ enable: n = !1
717
+ }) {
718
+ return r.program({
719
+ machineChannel: e,
720
+ param1: 99,
721
+ param2: n ? 49 : 48
722
+ });
723
+ }
724
+ static programMachineAddress({
725
+ machineChannel: e = 1,
726
+ address: n = 1
727
+ }) {
728
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 31)
729
+ throw new Error("Invalid address, valid range is 1 to 31");
730
+ return r.program({
731
+ param1: 100,
732
+ param2: 128 + n,
733
+ machineChannel: e
734
+ });
735
+ }
736
+ static programTemperatureBeforeExpiration({
737
+ machineChannel: e = 1,
738
+ degrees: n = 0.5
739
+ }) {
740
+ if (typeof n == "string" && (n = parseFloat(n)), isNaN(n) || n < 0.5 || n > 30 || n % 0.5 !== 0)
741
+ throw new Error(
742
+ "Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30"
743
+ );
744
+ const a = 128 + n * 2;
745
+ return r.program({ param1: 101, param2: a, machineChannel: e });
746
+ }
747
+ static programTimeBeforeExpirationByTemperature({
748
+ machineChannel: e = 1,
749
+ minutes: n = 1
750
+ }) {
751
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 120)
752
+ throw new Error("Invalid minutes, valid range is 1 to 120");
753
+ const a = 128 + n;
754
+ return r.program({ param1: 102, param2: a, machineChannel: e });
755
+ }
756
+ static programTemperatureScale({
757
+ machineChannel: e = 1,
758
+ scale: n = "celsius"
759
+ } = {}) {
760
+ const a = { celsius: 67, fahrenheit: 70 };
761
+ if (!a[n])
762
+ throw new Error(
763
+ "Invalid scale, valid scales are 'celsius' and 'fahrenheit'"
764
+ );
765
+ return r.program({
766
+ param1: 103,
767
+ param2: a[n],
768
+ machineChannel: e
769
+ });
770
+ }
771
+ static programVoltageEngine({
772
+ machineChannel: e = 1,
773
+ selection: n = 1,
774
+ voltage: a = 5
775
+ } = {}) {
776
+ if (typeof a == "string" && (a = parseFloat(a)), typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 130)
777
+ throw new Error("Invalid selection, valid range is 1 to 130");
778
+ if (isNaN(a) || a < 5 || a > 9.5 || a % 0.5 !== 0)
779
+ throw new Error("Invalid voltage, valid range is 5 to 9.5");
780
+ const t = 109 + n, s = 128 + (a - 5) * 2;
781
+ return r.instance.build([
782
+ 2,
783
+ 48,
784
+ 48,
785
+ 128 + e,
786
+ 71,
787
+ t,
788
+ s
789
+ ]);
790
+ }
791
+ static programPushOverProducts({
792
+ machineChannel: e = 1,
793
+ selection: n = 1,
794
+ enable: a = !0
795
+ } = {}) {
796
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 130)
797
+ throw new Error("Invalid selection, valid range is 1 to 130");
798
+ const t = 109 + n, s = a ? 49 : 48;
799
+ return r.instance.build([
800
+ 2,
801
+ 48,
802
+ 48,
803
+ 128 + e,
804
+ 79,
805
+ t,
806
+ s
807
+ ]);
808
+ }
809
+ static programChannelRunningAfterDispense({
810
+ machineChannel: e = 1,
811
+ selection: n = 1,
812
+ seconds: a = 0
813
+ } = {}) {
814
+ if (typeof n == "string" && (n = parseInt(n)), typeof a == "string" && (a = parseFloat(a)), isNaN(n) || n < 1 || n > 130)
815
+ throw new Error("Invalid selection, valid range is 1 to 130");
816
+ if (isNaN(a) || a < 0 || a > 10 || a % 0.1 !== 0)
817
+ throw new Error(
818
+ "Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1"
819
+ );
820
+ const t = 109 + n;
821
+ a = 10 * parseFloat(a.toFixed(1));
822
+ const s = 128 + a;
823
+ return r.instance.build([
824
+ 2,
825
+ 48,
826
+ 48,
827
+ 128 + e,
828
+ 69,
829
+ t,
830
+ s
831
+ ]);
832
+ }
833
+ static checkData({
834
+ machineChannel: e = 1,
835
+ type: n = 255,
836
+ aux: a = 255
837
+ }) {
838
+ return r.instance.build([
839
+ 2,
840
+ 48,
841
+ 48,
842
+ 128 + e,
843
+ 67,
844
+ n,
845
+ a
846
+ ]);
847
+ }
848
+ static getDisplayLanguage({
849
+ machineChannel: e = 1
850
+ }) {
851
+ return r.checkData({ machineChannel: e, type: 73 });
852
+ }
853
+ static getBeeper({
854
+ machineChannel: e = 1
855
+ }) {
856
+ return r.checkData({ machineChannel: e, type: 90 });
857
+ }
858
+ static getWorkingTemperature({
859
+ machineChannel: e = 1
860
+ }) {
861
+ return r.checkData({ machineChannel: e, type: 84 });
862
+ }
863
+ static getIsolationTray({
864
+ machineChannel: e = 1
865
+ }) {
866
+ return r.checkData({ machineChannel: e, type: 66 });
867
+ }
868
+ static getProgramVersion({
869
+ machineChannel: e = 1
870
+ }) {
871
+ return r.checkData({ machineChannel: e, type: 80 });
872
+ }
873
+ static getFaults({
874
+ machineChannel: e = 1
875
+ }) {
876
+ return r.checkData({ machineChannel: e, type: 83 });
877
+ }
878
+ static getMachineId({
879
+ machineChannel: e = 1
880
+ }) {
881
+ return r.checkData({ machineChannel: e, type: 78 });
882
+ }
883
+ static getCurrentTemperature({
884
+ machineChannel: e = 1
885
+ }) {
886
+ return r.checkData({ machineChannel: e, type: 116 });
887
+ }
888
+ static getTimeToStandbyAfterCollect({
889
+ machineChannel: e = 1
890
+ }) {
891
+ return r.checkData({ machineChannel: e, type: 70 });
892
+ }
893
+ static getTimeToStandbyWithoutCollect({
894
+ machineChannel: e = 1
895
+ }) {
896
+ return r.checkData({ machineChannel: e, type: 72 });
897
+ }
898
+ static getElevatorSpeed({
899
+ machineChannel: e = 1
900
+ }) {
901
+ return r.checkData({ machineChannel: e, type: 118 });
902
+ }
903
+ static getTemperatureExpiration({
904
+ machineChannel: e = 1
905
+ }) {
906
+ return r.checkData({ machineChannel: e, type: 99 });
907
+ }
908
+ static getTemperatureBeforeExpiration({
909
+ machineChannel: e = 1
910
+ }) {
911
+ return r.checkData({ machineChannel: e, type: 101 });
912
+ }
913
+ static getTimeBeforeExpirationByTemperature({
914
+ machineChannel: e = 1
915
+ }) {
916
+ return r.checkData({ machineChannel: e, type: 102 });
917
+ }
918
+ static getTemperatureScale({
919
+ machineChannel: e = 1
920
+ }) {
921
+ return r.checkData({ machineChannel: e, type: 103 });
922
+ }
923
+ static getClockRegisters({
924
+ machineChannel: e = 1
925
+ }) {
926
+ return r.checkData({ machineChannel: e, type: 114 });
927
+ }
928
+ static getMachineActivity({
929
+ machineChannel: e = 1
930
+ }) {
931
+ return r.checkData({ machineChannel: e, type: 65 });
932
+ }
933
+ static getVoltageEngine({
934
+ machineChannel: e = 1,
935
+ selection: n = 1
936
+ }) {
937
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 130)
938
+ throw new Error("Invalid selection, valid range is 1 to 130");
939
+ return r.checkData({
940
+ machineChannel: e,
941
+ type: 71,
942
+ aux: 109 + n
943
+ });
944
+ }
945
+ static getChannelPresence({ machineChannel: e = 1, selection: n = 1 } = {}) {
946
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 130)
947
+ throw new Error("Invalid selection, valid range is 1 to 130");
948
+ return r.checkData({
949
+ machineChannel: e,
950
+ type: 67,
951
+ aux: 109 + n
952
+ });
953
+ }
954
+ static getPushOverProducts({ machineChannel: e = 1, selection: n = 1 } = {}) {
955
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 130)
956
+ throw new Error("Invalid selection, valid range is 1 to 130");
957
+ return r.checkData({
958
+ machineChannel: e,
959
+ type: 79,
960
+ aux: 109 + n
961
+ });
962
+ }
963
+ static getChannelRunningAfterDispense({
964
+ machineChannel: e = 1,
965
+ selection: n = 1
966
+ } = {}) {
967
+ if (typeof n == "string" && (n = parseInt(n)), isNaN(n) || n < 1 || n > 130)
968
+ throw new Error("Invalid selection, valid range is 1 to 130");
969
+ return r.checkData({
970
+ machineChannel: e,
971
+ type: 69,
972
+ aux: 109 + n
973
+ });
974
+ }
975
+ static displayConfig({
976
+ machineChannel: e = 1,
977
+ type: n = 128,
978
+ param2: a = []
979
+ } = {}) {
980
+ return r.instance.build([
981
+ 2,
982
+ 48,
983
+ 48,
984
+ 128 + e,
985
+ 68,
986
+ n,
987
+ ...a
988
+ ]);
989
+ }
990
+ static setDisplayStandbyMessage({ machineChannel: e = 1, message: n = "" } = {}) {
991
+ n = n.substring(0, 32);
992
+ const a = r.instance.makeDisplayMessage(n);
993
+ return r.displayConfig({
994
+ machineChannel: e,
995
+ type: 128,
996
+ param2: a
997
+ });
998
+ }
999
+ static setDisplayMessageTemporarily({
1000
+ machineChannel: e = 1,
1001
+ message: n = "",
1002
+ seconds: a = 1
1003
+ }) {
1004
+ if (n = n.substring(0, 32), typeof a == "string" && (a = parseInt(a)), isNaN(a) || a < 1 || a > 125)
1005
+ throw new Error("Invalid seconds, valid range is 1 to 125");
1006
+ const t = r.instance.makeDisplayMessage(n), s = 128 + a;
1007
+ return r.displayConfig({
1008
+ machineChannel: e,
1009
+ type: s,
1010
+ param2: t
1011
+ });
1012
+ }
1013
+ static setDisplayMessageUnlimited({
1014
+ machineChannel: e = 1,
1015
+ message: n = ""
1016
+ }) {
1017
+ n = n.substring(0, 32);
1018
+ const a = r.instance.makeDisplayMessage(n);
1019
+ return r.displayConfig({
1020
+ machineChannel: e,
1021
+ type: 255,
1022
+ param2: a
1023
+ });
1024
+ }
1025
+ static programClock({ machineChannel: e = 1, date: n = /* @__PURE__ */ new Date() } = {}) {
1026
+ if (!(n instanceof Date))
1027
+ throw new Error("Invalid date, must be an instance of Date");
1028
+ return r.instance.build([
1029
+ 2,
1030
+ 48,
1031
+ 48,
1032
+ 128 + e,
1033
+ 114,
1034
+ ...r.instance.makeTimeFormat(n)
1035
+ ]);
1036
+ }
1037
+ static eventsConfig({
1038
+ machineChannel: e = 1,
1039
+ event: n = null,
1040
+ enable: a = !0
1041
+ } = {}) {
1042
+ if (n === null) throw new Error("Invalid event");
1043
+ const t = a ? 49 : 48;
1044
+ return r.instance.build([
1045
+ 2,
1046
+ 48,
1047
+ 48,
1048
+ 128 + e,
1049
+ 65,
1050
+ n,
1051
+ t
1052
+ ]);
1053
+ }
1054
+ static eventEnable({
1055
+ machineChannel: e = 1,
1056
+ event: n = null
1057
+ } = {}) {
1058
+ if (n === null) throw new Error("Invalid event");
1059
+ const a = parseInt(n, 16);
1060
+ if (isNaN(a) || a < 38 || a > 100)
1061
+ throw new Error("Invalid event");
1062
+ return r.eventsConfig({ machineChannel: e, event: n, enable: !0 });
1063
+ }
1064
+ static eventDisable({
1065
+ machineChannel: e = 1,
1066
+ event: n = null
1067
+ } = {}) {
1068
+ if (n === null) throw new Error("Invalid event");
1069
+ const a = parseInt(n, 16);
1070
+ if (isNaN(a) || a < 38 || a > 100)
1071
+ throw new Error("Invalid event");
1072
+ return r.eventsConfig({ machineChannel: e, event: n, enable: !1 });
1073
+ }
1074
+ static sendCustomCode({ code: e = [] } = {}) {
1075
+ if (e.length < 5) throw new Error("Invalid code, minimum length is 5");
1076
+ return r.instance.build(e);
1077
+ }
1078
+ };
1079
+ A(w, "asHex", !1), A(w, "instance");
1080
+ let D = w;
1081
+ D.instance = new D();
1082
+ var j = Object.defineProperty, W = (i, e, n) => e in i ? j(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, T = (i, e, n) => W(i, typeof e != "symbol" ? e + "" : e, n);
1083
+ const y = class h {
1084
+ serialLockerCmdMaker(e) {
1085
+ let n;
1086
+ try {
1087
+ n = new Uint8Array(e.length + 8), n.set(e, 2), n[0] = 2, n[1] = e.length + 4, n[n.length - 2] = 3;
1088
+ let a = 0;
1089
+ for (let o = 1; o < e.length; o++)
1090
+ a += e[o], a *= parseInt(Math.pow(2, o - 1).toString());
1091
+ n[e.length + 2] = a % 256, n[e.length + 3] = 666 * 3 % 256, n[e.length + 4] = 666 * 8 % 256;
1092
+ let t = 0;
1093
+ for (let o = 3; o < e.length + 5; o++)
1094
+ t += n[o];
1095
+ n[e.length + 5] = t % 256;
1096
+ let s = 0;
1097
+ for (let o = 0; o < n.length - 1; o++)
1098
+ s ^= n[o];
1099
+ n[n.length - 1] = s;
1100
+ } catch (a) {
1101
+ throw n = new Uint8Array(0), a instanceof Error ? new Error(`Error generating command: ${a.message}`) : new Error("Error generating command: Unknown error");
1102
+ }
1103
+ return n;
1104
+ }
1105
+ serialLockerHexCmd(e) {
1106
+ const n = this.serialLockerCmdMaker(e), a = [];
1107
+ for (let t = 0; t < n.length; t++) {
1108
+ const s = n[t].toString(16).padStart(2, "0");
1109
+ a.push(s);
1110
+ }
1111
+ return a;
1112
+ }
1113
+ validateCell(e = 1) {
1114
+ let n;
1115
+ if (typeof e == "string" ? n = parseInt(e) : n = e, isNaN(n) || n < 1 || n > 90) throw new Error("Invalid cell number");
1116
+ return n;
1117
+ }
1118
+ serialLockerGetStatusCellCmd({
1119
+ cell: e = 1,
1120
+ channel: n = 1
1121
+ } = {}) {
1122
+ return e = this.validateCell(e), this.build(new Uint8Array([16, n, e]));
1123
+ }
1124
+ serialLockerGetLightScanCmd({ since: e = 0, until: n = 10, channel: a = 1 } = {}) {
1125
+ return this.build(new Uint8Array([32, a, e, n]));
1126
+ }
1127
+ parseCellToColumnRow(e) {
1128
+ const n = Math.floor((e - 1) / 10) + 1;
1129
+ let a = e % 8;
1130
+ return a === 0 && (a = 8), [n, a];
1131
+ }
1132
+ serialLockerGetConfigureCellCmd({
1133
+ enable: e = !0,
1134
+ column: n = 0,
1135
+ row: a = 10,
1136
+ channel: t = 1
1137
+ } = {}) {
1138
+ if (n < 0 || n > 8) throw new Error("Invalid column number");
1139
+ if (a < 0 || a > 10) throw new Error("Invalid row number");
1140
+ let s = 1;
1141
+ return e || (s = 0), this.build(new Uint8Array([48, t, n, a, s]));
1142
+ }
1143
+ serialLockerGetOpenCmd({ cell: e = 1, channel: n = 1 } = {}) {
1144
+ e = this.validateCell(e);
1145
+ const a = 666, t = a % 256, s = Math.floor(a / 3) % 256;
1146
+ return this.build(new Uint8Array([64, n, e, t, s]));
1147
+ }
1148
+ build(e) {
1149
+ return h.asHex ? this.serialLockerHexCmd(e) : g(this.serialLockerCmdMaker(e));
1150
+ }
1151
+ static connection({ channel: e = 1 } = {}) {
1152
+ return h.instance.build(new Uint8Array([0, e]));
1153
+ }
1154
+ static openCell({ cell: e = 1, channel: n = 1 } = {}) {
1155
+ return e = h.instance.validateCell(e), h.instance.serialLockerGetOpenCmd({ cell: e, channel: n });
1156
+ }
1157
+ static statusCell({ cell: e = 1, channel: n = 1 } = {}) {
1158
+ return e = h.instance.validateCell(e), h.instance.serialLockerGetStatusCellCmd({ cell: e, channel: n });
1159
+ }
1160
+ static lightScan({ since: e = 0, until: n = 10, channel: a = 1 } = {}) {
1161
+ if (e < 0 || e > 10) throw new Error("Invalid since number");
1162
+ if (n < 0 || n > 10) throw new Error("Invalid until number");
1163
+ return h.instance.serialLockerGetLightScanCmd({
1164
+ since: e,
1165
+ until: n,
1166
+ channel: a
1167
+ });
1168
+ }
1169
+ static enableCell({ cell: e = 1, channel: n = 1 } = {}) {
1170
+ e = h.instance.validateCell(e);
1171
+ const [a, t] = h.instance.parseCellToColumnRow(e);
1172
+ return h.instance.serialLockerGetConfigureCellCmd({
1173
+ enable: !0,
1174
+ column: a,
1175
+ row: t,
1176
+ channel: n
1177
+ });
1178
+ }
1179
+ static disableCell({ cell: e = 1, channel: n = 1 } = {}) {
1180
+ e = h.instance.validateCell(e);
1181
+ const [a, t] = h.instance.parseCellToColumnRow(e);
1182
+ return h.instance.serialLockerGetConfigureCellCmd({
1183
+ enable: !1,
1184
+ column: a,
1185
+ row: t,
1186
+ channel: n
1187
+ });
1188
+ }
1189
+ };
1190
+ T(y, "asHex", !1), T(y, "instance");
1191
+ let $ = y;
1192
+ $.instance = new $();
1193
+ var V = Object.defineProperty, Q = (i, e, n) => e in i ? V(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, O = (i, e, n) => Q(i, typeof e != "symbol" ? e + "" : e, n);
1194
+ const v = class l {
1195
+ build(e) {
1196
+ return g(e + l.append);
1197
+ }
1198
+ static connection() {
1199
+ const e = JSON.stringify({ action: "CONNECT" });
1200
+ return l.instance.build(e);
1201
+ }
1202
+ static connect() {
1203
+ return l.connection();
1204
+ }
1205
+ static custom(e) {
1206
+ if (typeof e != "string") throw new Error("Invalid string");
1207
+ return l.instance.build(e);
1208
+ }
1209
+ static readQR({ type: e = "production" } = {
1210
+ type: "production"
1211
+ }) {
1212
+ const n = JSON.stringify({
1213
+ action: "READQR",
1214
+ server: e === "production" ? "PROD" : "QA"
1215
+ });
1216
+ return l.instance.build(n);
1217
+ }
1218
+ static forceHide() {
1219
+ const e = JSON.stringify({ action: "FORCEHIDE" });
1220
+ return l.instance.build(e);
1221
+ }
1222
+ static forceShow() {
1223
+ const e = JSON.stringify({ action: "FORCESHOW" });
1224
+ return l.instance.build(e);
1225
+ }
1226
+ static makeSale({
1227
+ amount: e = 0,
1228
+ reference: n = null
1229
+ } = {}) {
1230
+ if (e <= 0) throw new Error("Invalid amount");
1231
+ if (typeof e != "number" && (e = parseFloat(e)), isNaN(e)) throw new Error("Invalid amount");
1232
+ if (n && !/^[A-Z-a-z0-9_\s]+$/g.test(n))
1233
+ throw new Error(
1234
+ "Reference must be alphanumeric and the only symbol allowed is midlescore or underscore (- _) or null"
1235
+ );
1236
+ const a = e.toFixed(2), t = JSON.stringify({
1237
+ action: "PAYMENT",
1238
+ amount: a,
1239
+ reference: n
1240
+ });
1241
+ return l.instance.build(t);
1242
+ }
1243
+ static getVoucher({ folio: e = null } = {}) {
1244
+ if (!e)
1245
+ throw new Error("Folio must be a number");
1246
+ const n = JSON.stringify({ action: "GETVOUCHER", folio: e });
1247
+ return l.instance.build(n);
1248
+ }
1249
+ static info() {
1250
+ const e = JSON.stringify({ action: "DEVICEINFO" });
1251
+ return l.instance.build(e);
1252
+ }
1253
+ static keepAlive() {
1254
+ const e = JSON.stringify({ action: "KEEPALIVE" });
1255
+ return l.instance.build(e);
1256
+ }
1257
+ static restartApp() {
1258
+ const e = JSON.stringify({ action: "RESETAPP" });
1259
+ return l.instance.build(e);
1260
+ }
1261
+ static getConfig() {
1262
+ const e = JSON.stringify({ action: "GETCONFIG" });
1263
+ return l.instance.build(e);
1264
+ }
1265
+ static hideButtons() {
1266
+ const e = JSON.stringify({ action: "HIDEBUTTONS" });
1267
+ return l.instance.build(e);
1268
+ }
1269
+ static showButtons() {
1270
+ const e = JSON.stringify({ action: "SHOWBUTTONS" });
1271
+ return l.instance.build(e);
1272
+ }
1273
+ static demo() {
1274
+ const e = JSON.stringify({ action: "DEMO" });
1275
+ return l.instance.build(e);
1276
+ }
1277
+ static refund({
1278
+ amount: e = 0,
1279
+ folio: n = null,
1280
+ auth: a = null
1281
+ } = {}) {
1282
+ if (e <= 0) throw new Error("Invalid amount");
1283
+ if (typeof e != "number" && (e = parseFloat(e)), isNaN(e)) throw new Error("Invalid amount");
1284
+ if (!n) throw new Error("Folio must be a number");
1285
+ if (!a) throw new Error("Auth must be a number");
1286
+ const t = e.toFixed(2), s = JSON.stringify({
1287
+ action: "REFUND",
1288
+ amount: t,
1289
+ folio: n,
1290
+ auth: a
1291
+ });
1292
+ return l.instance.build(s);
1293
+ }
1294
+ static exit() {
1295
+ const e = JSON.stringify({ action: "EXIT" });
1296
+ return l.instance.build(e);
1297
+ }
1298
+ static init() {
1299
+ const e = JSON.stringify({ action: "INIT" });
1300
+ return l.instance.build(e);
1301
+ }
1302
+ };
1303
+ O(v, "append", `\r
1304
+ `), O(v, "instance");
1305
+ let U = v;
1306
+ U.instance = new U();
1307
+ var Y = Object.defineProperty, q = (i, e, n) => e in i ? Y(i, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : i[e] = n, z = (i, e, n) => q(i, e + "", n);
1308
+ const R = class C {
1309
+ build(e) {
1310
+ return e[3] = this.withChecksum(e), g(e);
1311
+ }
1312
+ withChecksum(e) {
1313
+ let n = 0;
1314
+ return e.forEach((a, t) => {
1315
+ t !== 3 && (n += a);
1316
+ }), n;
1317
+ }
1318
+ static connection(e = 1) {
1319
+ return C.instance.build([160, e, 0, 161]);
1320
+ }
1321
+ static deactivate(e = 1) {
1322
+ return C.connection(e);
1323
+ }
1324
+ static activate() {
1325
+ return C.instance.build([160, 1, 1, 162]);
1326
+ }
1327
+ static custom(e) {
1328
+ return C.instance.build(e);
1329
+ }
1330
+ };
1331
+ z(R, "instance");
1332
+ let x = R;
1333
+ x.instance = new x();
1334
+ export {
1335
+ x as e,
1336
+ k as i,
1337
+ N as l,
1338
+ D as o,
1339
+ U as s,
1340
+ $ as u
1341
+ };