@levischuck/receiptline 0.1.1 → 0.1.2

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 (2) hide show
  1. package/dist/index.js +313 -318
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { decodeBase64 as V, encodeBase64 as O } from "@levischuck/tiny-encodings";
2
- import { qrCode as _, EcLevel as M } from "@levischuck/tiny-qr";
2
+ import { qrCode as _, EcLevel as C } from "@levischuck/tiny-qr";
3
3
  import { toSvgString as it } from "@levischuck/tiny-qr-svg";
4
4
  class H {
5
5
  locked = !1;
@@ -32,9 +32,9 @@ class H {
32
32
  try {
33
33
  await Promise.race([
34
34
  this.lockPromise,
35
- new Promise((a, s) => {
35
+ new Promise((a, r) => {
36
36
  e.signal.addEventListener("abort", () => {
37
- s(new Error(`Lock timeout after ${t}ms`));
37
+ r(new Error(`Lock timeout after ${t}ms`));
38
38
  });
39
39
  })
40
40
  ]);
@@ -63,9 +63,9 @@ class H {
63
63
  switch (e) {
64
64
  case "cp932":
65
65
  case "shiftjis":
66
- i = a.reduce((r, h) => {
66
+ i = a.reduce((s, h) => {
67
67
  const o = h.codePointAt(0);
68
- return o === void 0 ? r : r + (o < 128 || o === 160 || o === 165 || o === 8254 || o > 65376 && o < 65440 ? 1 : 2);
68
+ return o === void 0 ? s : s + (o < 128 || o === 160 || o === 165 || o === 8254 || o > 65376 && o < 65440 ? 1 : 2);
69
69
  }, 0);
70
70
  break;
71
71
  case "cp936":
@@ -74,17 +74,17 @@ class H {
74
74
  case "ksc5601":
75
75
  case "cp950":
76
76
  case "big5":
77
- i = a.reduce((r, h) => {
77
+ i = a.reduce((s, h) => {
78
78
  const o = h.codePointAt(0);
79
- return o === void 0 ? r : r + (o < 128 || o === 160 ? 1 : 2);
79
+ return o === void 0 ? s : s + (o < 128 || o === 160 ? 1 : 2);
80
80
  }, 0);
81
81
  break;
82
82
  case "tis620":
83
- const s = a.reduce((r, h) => {
83
+ const r = a.reduce((s, h) => {
84
84
  const o = h.codePointAt(0);
85
- return o === void 0 || (r.consonant ? o === 3633 || o >= 3636 && o <= 3642 || o === 3655 ? r.vowel ? (r.length += 2, r.consonant = r.vowel = r.tone = !1) : r.vowel = !0 : o >= 3656 && o <= 3659 ? r.tone ? (r.length += 2, r.consonant = r.vowel = r.tone = !1) : r.tone = !0 : o === 3635 || o >= 3660 && o <= 3662 ? r.vowel || r.tone ? (r.length += 2, r.consonant = r.vowel = r.tone = !1) : (r.length += o === 3635 ? 2 : 1, r.consonant = !1) : o >= 3585 && o <= 3630 ? (r.length++, r.vowel = r.tone = !1) : (r.length += 2, r.consonant = r.vowel = r.tone = !1) : o >= 3585 && o <= 3630 ? r.consonant = !0 : r.length++), r;
85
+ return o === void 0 || (s.consonant ? o === 3633 || o >= 3636 && o <= 3642 || o === 3655 ? s.vowel ? (s.length += 2, s.consonant = s.vowel = s.tone = !1) : s.vowel = !0 : o >= 3656 && o <= 3659 ? s.tone ? (s.length += 2, s.consonant = s.vowel = s.tone = !1) : s.tone = !0 : o === 3635 || o >= 3660 && o <= 3662 ? s.vowel || s.tone ? (s.length += 2, s.consonant = s.vowel = s.tone = !1) : (s.length += o === 3635 ? 2 : 1, s.consonant = !1) : o >= 3585 && o <= 3630 ? (s.length++, s.vowel = s.tone = !1) : (s.length += 2, s.consonant = s.vowel = s.tone = !1) : o >= 3585 && o <= 3630 ? s.consonant = !0 : s.length++), s;
86
86
  }, { length: 0, consonant: !1, vowel: !1, tone: !1 });
87
- s.consonant && (s.length++, s.consonant = s.vowel = s.tone = !1), i = s.length;
87
+ r.consonant && (r.length++, r.consonant = r.vowel = r.tone = !1), i = r.length;
88
88
  break;
89
89
  default:
90
90
  i = a.length;
@@ -103,11 +103,11 @@ class H {
103
103
  switch (e) {
104
104
  case "cp932":
105
105
  case "shiftjis":
106
- return i.map((s) => s.replace(/\\/g, "¥").replace(/\u203e/g, "~").replace(/\u301c/g, "~"));
106
+ return i.map((r) => r.replace(/\\/g, "¥").replace(/\u203e/g, "~").replace(/\u301c/g, "~"));
107
107
  case "tis620":
108
- const a = i.reduce((s, r) => {
109
- const h = r.codePointAt(0);
110
- return h === void 0 || (s.consonant ? h === 3633 || h >= 3636 && h <= 3642 || h === 3655 ? s.vowel ? (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : s.vowel = r : h >= 3656 && h <= 3659 ? s.tone ? (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : s.tone = r : h === 3635 || h >= 3660 && h <= 3662 ? s.vowel || s.tone ? (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : (s.result.push(s.consonant + r), s.consonant = "") : h >= 3585 && h <= 3630 ? (s.result.push(s.consonant + s.vowel + s.tone), s.consonant = r, s.vowel = s.tone = "") : (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : h >= 3585 && h <= 3630 ? s.consonant = r : s.result.push(r)), s;
108
+ const a = i.reduce((r, s) => {
109
+ const h = s.codePointAt(0);
110
+ return h === void 0 || (r.consonant ? h === 3633 || h >= 3636 && h <= 3642 || h === 3655 ? r.vowel ? (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : r.vowel = s : h >= 3656 && h <= 3659 ? r.tone ? (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : r.tone = s : h === 3635 || h >= 3660 && h <= 3662 ? r.vowel || r.tone ? (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : (r.result.push(r.consonant + s), r.consonant = "") : h >= 3585 && h <= 3630 ? (r.result.push(r.consonant + r.vowel + r.tone), r.consonant = s, r.vowel = r.tone = "") : (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : h >= 3585 && h <= 3630 ? r.consonant = s : r.result.push(s)), r;
111
111
  }, { result: [], consonant: "", vowel: "", tone: "" });
112
112
  return a.consonant && (a.result.push(a.consonant + a.vowel + a.tone), a.consonant = a.vowel = a.tone = ""), a.result;
113
113
  default:
@@ -329,49 +329,49 @@ const y = {
329
329
  shift: 98,
330
330
  stop: 106
331
331
  };
332
- function E(n, t, e) {
333
- n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[\x00-_])+/, (s) => (s.split("").forEach((r) => e.push((r.charCodeAt(0) + 64) % 96)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (s) => (e.push((s.charCodeAt(0) + 64) % 96), ""));
332
+ function j(n, t, e) {
333
+ n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[\x00-_])+/, (r) => (r.split("").forEach((s) => e.push((s.charCodeAt(0) + 64) % 96)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push((r.charCodeAt(0) + 64) % 96), ""));
334
334
  const i = t.slice(1), a = i.search(/[^ -_]/);
335
- /^\d{4,}/.test(t) ? L(y.atoc, t, e) : a >= 0 && i.charCodeAt(a) < 32 ? (e.push(y.shift, t.charCodeAt(0) - 32), E(y.shift, i, e)) : t.length > 0 && P(y.atob, t, e);
335
+ /^\d{4,}/.test(t) ? L(y.atoc, t, e) : a >= 0 && i.charCodeAt(a) < 32 ? (e.push(y.shift, t.charCodeAt(0) - 32), j(y.shift, i, e)) : t.length > 0 && E(y.atob, t, e);
336
336
  }
337
- function P(n, t, e) {
338
- n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[ -\x7f])+/, (s) => (s.split("").forEach((r) => e.push(r.charCodeAt(0) - 32)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (s) => (e.push(s.charCodeAt(0) - 32), ""));
337
+ function E(n, t, e) {
338
+ n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[ -\x7f])+/, (r) => (r.split("").forEach((s) => e.push(s.charCodeAt(0) - 32)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push(r.charCodeAt(0) - 32), ""));
339
339
  const i = t.slice(1), a = i.search(/[^ -_]/);
340
- /^\d{4,}/.test(t) ? L(y.btoc, t, e) : a >= 0 && i.charCodeAt(a) > 95 ? (e.push(y.shift, t.charCodeAt(0) + 64), P(y.shift, i, e)) : t.length > 0 && E(y.btoa, t, e);
340
+ /^\d{4,}/.test(t) ? L(y.btoc, t, e) : a >= 0 && i.charCodeAt(a) > 95 ? (e.push(y.shift, t.charCodeAt(0) + 64), E(y.shift, i, e)) : t.length > 0 && j(y.btoa, t, e);
341
341
  }
342
342
  function L(n, t, e) {
343
- n !== y.shift && e.push(n), t = t.replace(/^\d{4,}/g, (a) => a.replace(/\d{2}/g, (s) => (e.push(Number(s)), "")));
343
+ n !== y.shift && e.push(n), t = t.replace(/^\d{4,}/g, (a) => a.replace(/\d{2}/g, (r) => (e.push(Number(r)), "")));
344
344
  const i = t.search(/[^ -_]/);
345
- i >= 0 && t.charCodeAt(i) < 32 ? E(y.ctoa, t, e) : t.length > 0 && P(y.ctob, t, e);
345
+ i >= 0 && t.charCodeAt(i) < 32 ? j(y.ctoa, t, e) : t.length > 0 && E(y.ctob, t, e);
346
346
  }
347
- function rt(n) {
347
+ function st(n) {
348
348
  const t = {};
349
349
  let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
350
350
  if (e.length > 0) {
351
351
  t.hri = n.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
352
352
  const i = [], a = e.search(/[^ -_]/);
353
- /^\d{2}$/.test(e) ? i.push(y.startc, Number(e)) : /^\d{4,}/.test(e) ? L(y.startc, e, i) : a >= 0 && e.charCodeAt(a) < 32 ? E(y.starta, e, i) : e.length > 0 && P(y.startb, e, i), i.push(i.reduce((h, o, c) => h + o * c) % 103, y.stop);
354
- const s = n.quietZone ? "a" : "0", r = i.reduce((h, o) => h + y.element[o], s) + s;
355
- t.widths = r.split("").map((h) => parseInt(h, 16) * n.width), t.length = n.width * (i.length * 11 + (n.quietZone ? 22 : 2)), t.height = n.height;
353
+ /^\d{2}$/.test(e) ? i.push(y.startc, Number(e)) : /^\d{4,}/.test(e) ? L(y.startc, e, i) : a >= 0 && e.charCodeAt(a) < 32 ? j(y.starta, e, i) : e.length > 0 && E(y.startb, e, i), i.push(i.reduce((h, o, c) => h + o * c) % 103, y.stop);
354
+ const r = n.quietZone ? "a" : "0", s = i.reduce((h, o) => h + y.element[o], r) + r;
355
+ t.widths = s.split("").map((h) => parseInt(h, 16) * n.width), t.length = n.width * (i.length * 11 + (n.quietZone ? 22 : 2)), t.height = n.height;
356
356
  }
357
357
  return t;
358
358
  }
359
- const C = {
359
+ const M = {
360
360
  escape: "cU,dA,dB,dC,dD,dE,dF,dG,dH,dI,dJ,dK,dL,dM,dN,dO,dP,dQ,dR,dS,dT,dU,dV,dW,dX,dY,dZ,cA,cB,cC,cD,cE, ,sA,sB,sC,$,%,sF,sG,sH,sI,sJ,+,sL,-,.,/,0,1,2,3,4,5,6,7,8,9,sZ,cF,cG,cH,cI,cJ,cV,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,cK,cL,cM,cN,cO,cW,pA,pB,pC,pD,pE,pF,pG,pH,pI,pJ,pK,pL,pM,pN,pO,pP,pQ,pR,pS,pT,pU,pV,pW,pX,pY,pZ,cP,cQ,cR,cS,cT".split(","),
361
361
  code: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%dcsp".split("").reduce((n, t, e) => (n[t] = e, n), {}),
362
362
  element: "131112,111213,111312,111411,121113,121212,121311,111114,131211,141111,211113,211212,211311,221112,221211,231111,112113,112212,112311,122112,132111,111123,111222,111321,121122,131121,212112,212211,211122,211221,221121,222111,112122,112221,122121,123111,121131,311112,311211,321111,112131,113121,211131,121221,312111,311121,122211,111141,1111411".split(","),
363
363
  start: 47,
364
364
  stop: 48
365
365
  };
366
- function st(n) {
366
+ function rt(n) {
367
367
  const t = {};
368
368
  let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
369
369
  if (e.length > 0) {
370
370
  t.hri = n.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
371
- const i = e.split("").reduce((r, h) => r + C.escape[h.charCodeAt(0)], "").split("").map((r) => C.code[r]);
372
- i.push(i.reduceRight((r, h, o) => r + h * ((i.length - 1 - o) % 20 + 1)) % 47), i.push(i.reduceRight((r, h, o) => r + h * ((i.length - 1 - o) % 15 + 1)) % 47), i.unshift(C.start), i.push(C.stop);
373
- const a = n.quietZone ? "a" : "0", s = i.reduce((r, h) => r + C.element[h], a) + a;
374
- t.widths = s.split("").map((r) => parseInt(r, 16) * n.width), t.length = n.width * (i.length * 9 + (n.quietZone ? 21 : 1)), t.height = n.height;
371
+ const i = e.split("").reduce((s, h) => s + M.escape[h.charCodeAt(0)], "").split("").map((s) => M.code[s]);
372
+ i.push(i.reduceRight((s, h, o) => s + h * ((i.length - 1 - o) % 20 + 1)) % 47), i.push(i.reduceRight((s, h, o) => s + h * ((i.length - 1 - o) % 15 + 1)) % 47), i.unshift(M.start), i.push(M.stop);
373
+ const a = n.quietZone ? "a" : "0", r = i.reduce((s, h) => s + M.element[h], a) + a;
374
+ t.widths = r.split("").map((s) => parseInt(s, 16) * n.width), t.length = n.width * (i.length * 9 + (n.quietZone ? 21 : 1)), t.height = n.height;
375
375
  }
376
376
  return t;
377
377
  }
@@ -402,10 +402,10 @@ function ot(n) {
402
402
  let e = n.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
403
403
  if (e.length > 0) {
404
404
  t.hri = n.hri, t.text = e;
405
- const i = n.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((r, h) => r + at[h] + "2", i).slice(0, -1) + i;
406
- t.widths = a.split("").map((r) => parseInt(r, 16) * n.width + 1 >> 1);
407
- const s = [25, 39, 50, 3, 5, 6];
408
- t.length = e.length * s[n.width - 2] - (e.match(/[\d\-$]/g) || []).length * s[n.width + 1] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
405
+ const i = n.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((s, h) => s + at[h] + "2", i).slice(0, -1) + i;
406
+ t.widths = a.split("").map((s) => parseInt(s, 16) * n.width + 1 >> 1);
407
+ const r = [25, 39, 50, 3, 5, 6];
408
+ t.length = e.length * r[n.width - 2] - (e.match(/[\d\-$]/g) || []).length * r[n.width + 1] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
409
409
  }
410
410
  return t;
411
411
  }
@@ -420,12 +420,12 @@ function ht(n) {
420
420
  if (e.length > 0) {
421
421
  t.hri = n.hri, t.text = e;
422
422
  const i = e.split("").map((o) => Number(o)), a = n.quietZone ? "a" : "0";
423
- let s = a + q.start, r = 0;
424
- for (; r < i.length; ) {
425
- const o = q.element[i[r++]], c = q.element[i[r++]];
426
- s += o.split("").reduce((l, u, d) => l + u + c[d], "");
423
+ let r = a + q.start, s = 0;
424
+ for (; s < i.length; ) {
425
+ const o = q.element[i[s++]], c = q.element[i[s++]];
426
+ r += o.split("").reduce((l, u, d) => l + u + c[d], "");
427
427
  }
428
- s += q.stop + a, t.widths = s.split("").map((o) => parseInt(o, 16) * n.width + 1 >> 1);
428
+ r += q.stop + a, t.widths = r.split("").map((o) => parseInt(o, 16) * n.width + 1 >> 1);
429
429
  const h = [16, 25, 32, 17, 26, 34];
430
430
  t.length = e.length * h[n.width - 2] + h[n.width + 1] + n.width * (n.quietZone ? 20 : 0), t.height = n.height;
431
431
  }
@@ -482,10 +482,10 @@ function lt(n) {
482
482
  let e = n.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
483
483
  if (e.length > 0) {
484
484
  e = e.replace(/^\*?([^*]+)\*?$/, "*$1*"), t.hri = n.hri, t.text = e;
485
- const i = n.quietZone ? "a" : "0", a = e.split("").reduce((r, h) => r + ct[h] + "2", i).slice(0, -1) + i;
486
- t.widths = a.split("").map((r) => parseInt(r, 16) * n.width + 1 >> 1);
487
- const s = [29, 45, 58];
488
- t.length = e.length * s[n.width - 2] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
485
+ const i = n.quietZone ? "a" : "0", a = e.split("").reduce((s, h) => s + ct[h] + "2", i).slice(0, -1) + i;
486
+ t.widths = a.split("").map((s) => parseInt(s, 16) * n.width + 1 >> 1);
487
+ const r = [29, 45, 58];
488
+ t.length = e.length * r[n.width - 2] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
489
489
  }
490
490
  return t;
491
491
  }
@@ -520,7 +520,7 @@ function dt(n) {
520
520
  function G(n) {
521
521
  const t = {}, e = n.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((i) => Number(i));
522
522
  if (e.length > 0) {
523
- e[12] = 0, e[12] = (10 - e.reduce((a, s, r) => a + s * (r % 2 * 2 + 1)) % 10) % 10, t.hri = n.hri, t.text = e.join("");
523
+ e[12] = 0, e[12] = (10 - e.reduce((a, r, s) => a + r * (s % 2 * 2 + 1)) % 10) % 10, t.hri = n.hri, t.text = e.join("");
524
524
  let i = (n.quietZone ? "b" : "0") + b.g[0];
525
525
  for (let a = 1; a < 7; a++) i += b[b.p[e[0]][a - 1]][e[a]];
526
526
  i += b.g[1];
@@ -532,13 +532,13 @@ function G(n) {
532
532
  function gt(n) {
533
533
  const t = {}, e = n.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((i) => Number(i));
534
534
  if (e.length > 0) {
535
- e[7] = 0, e[7] = (10 - e.reduce((s, r, h) => s + r * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = n.hri, t.text = e.join("");
535
+ e[7] = 0, e[7] = (10 - e.reduce((r, s, h) => r + s * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = n.hri, t.text = e.join("");
536
536
  const i = n.quietZone ? "7" : "0";
537
537
  let a = i + b.g[0];
538
- for (let s = 0; s < 4; s++) a += b.a[e[s] ?? 0];
538
+ for (let r = 0; r < 4; r++) a += b.a[e[r] ?? 0];
539
539
  a += b.g[1];
540
- for (let s = 4; s < 8; s++) a += b.c[e[s] ?? 0];
541
- a += b.g[0] + i, t.widths = a.split("").map((s) => parseInt(s, 16) * n.width), t.length = n.width * (n.quietZone ? 81 : 67), t.height = n.height;
540
+ for (let r = 4; r < 8; r++) a += b.c[e[r] ?? 0];
541
+ a += b.g[0] + i, t.widths = a.split("").map((r) => parseInt(r, 16) * n.width), t.length = n.width * (n.quietZone ? 81 : 67), t.height = n.height;
542
542
  }
543
543
  return t;
544
544
  }
@@ -555,11 +555,11 @@ function ut(n) {
555
555
  function pt(n) {
556
556
  const t = {}, e = n.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((i) => Number(i));
557
557
  if (e.length > 0) {
558
- e[7] = 0, e[7] = (10 - dt(e).reduce((s, r, h) => s + r * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = n.hri, t.text = e.join("");
558
+ e[7] = 0, e[7] = (10 - dt(e).reduce((r, s, h) => r + s * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = n.hri, t.text = e.join("");
559
559
  const i = n.quietZone ? "7" : "0";
560
560
  let a = i + b.g[0];
561
- for (let s = 1; s < 7; s++) a += b[b.e[e[7] ?? 0][s - 1]][e[s] ?? 0];
562
- a += b.g[2] + i, t.widths = a.split("").map((s) => parseInt(s, 16) * n.width), t.length = n.width * (n.quietZone ? 65 : 51), t.height = n.height;
561
+ for (let r = 1; r < 7; r++) a += b[b.e[e[7] ?? 0][r - 1]][e[r] ?? 0];
562
+ a += b.g[2] + i, t.widths = a.split("").map((r) => parseInt(r, 16) * n.width), t.length = n.width * (n.quietZone ? 65 : 51), t.height = n.height;
563
563
  }
564
564
  return t;
565
565
  }
@@ -584,10 +584,10 @@ function K(n) {
584
584
  t = ot(n);
585
585
  break;
586
586
  case "code93":
587
- t = st(n);
587
+ t = rt(n);
588
588
  break;
589
589
  case "code128":
590
- t = rt(n);
590
+ t = st(n);
591
591
  break;
592
592
  }
593
593
  return t;
@@ -674,25 +674,25 @@ class I extends H {
674
674
  }
675
675
  // print vertical rules:
676
676
  async vr(t, e) {
677
- const i = this.charWidth, a = i / 2, s = (i + i) * e, r = '<path d="' + t.reduce((h, o) => h + `m${i * o + i},${-s}v${s}`, `M${a},0v${s}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
678
- return this.svgContent += `<g transform="translate(${this.lineMargin * i},${this.svgHeight})">${r}</g>`, "";
677
+ const i = this.charWidth, a = i / 2, r = (i + i) * e, s = '<path d="' + t.reduce((h, o) => h + `m${i * o + i},${-r}v${r}`, `M${a},0v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
678
+ return this.svgContent += `<g transform="translate(${this.lineMargin * i},${this.svgHeight})">${s}</g>`, "";
679
679
  }
680
680
  // start rules:
681
681
  async vrstart(t) {
682
- const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((s, r) => s + `h${e * r}h${i}v${e}m0,${-e}h${i}`, `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`).replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
682
+ const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((r, s) => r + `h${e * s}h${i}v${e}m0,${-e}h${i}`, `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`).replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
683
683
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
684
684
  }
685
685
  // stop rules:
686
686
  async vrstop(t) {
687
- const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((s, r) => s + `h${e * r}h${i}v${-e}m0,${e}h${i}`, `M${i},0v${i}q0,${i},${i},${i}`).replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
687
+ const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((r, s) => r + `h${e * s}h${i}v${-e}m0,${e}h${i}`, `M${i},0v${i}q0,${i},${i},${i}`).replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
688
688
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
689
689
  }
690
690
  // print vertical and horizontal rules:
691
691
  async vrhr(t, e, i, a) {
692
- const s = this.charWidth, r = s / 2, h = '<path d="' + t.reduce((c, l) => c + `h${s * l}h${r}v${-s}m0,${s}h${r}`, `M${r},0` + (i > 0 ? `v${r}q0,${r},${r},${r}` : `v${s}h${r}`)).replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${r},0,${r},${-r}v${-r}` : `h${r}v${-s}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
693
- this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(-i, 0)) * s},${this.svgHeight})">${h}</g>`;
694
- const o = '<path d="' + e.reduce((c, l) => c + `h${s * l}h${r}v${s}m0,${-s}h${r}`, `M${r},${s + s}` + (i < 0 ? `v${-r}q0,${-r},${r},${-r}` : `v${-s}h${r}`)).replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${r},0,${r},${r}v${r}` : `h${r}v${s}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
695
- return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(i, 0)) * s},${this.svgHeight})">${o}</g>`, "";
692
+ const r = this.charWidth, s = r / 2, h = '<path d="' + t.reduce((c, l) => c + `h${r * l}h${s}v${-r}m0,${r}h${s}`, `M${s},0` + (i > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`)).replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${s},0,${s},${-s}v${-s}` : `h${s}v${-r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
693
+ this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(-i, 0)) * r},${this.svgHeight})">${h}</g>`;
694
+ const o = '<path d="' + e.reduce((c, l) => c + `h${r * l}h${s}v${r}m0,${-r}h${s}`, `M${s},${r + r}` + (i < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`)).replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${s},0,${s},${s}v${s}` : `h${s}v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
695
+ return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(i, 0)) * r},${this.svgHeight})">${o}</g>`, "";
696
696
  }
697
697
  // set line spacing and feed new line:
698
698
  async vrlf(t) {
@@ -727,11 +727,11 @@ class I extends H {
727
727
  // print text:
728
728
  async text(t, e) {
729
729
  let i = this.textPosition;
730
- const a = this.arrayFrom(t, e).reduce((r, h) => {
730
+ const a = this.arrayFrom(t, e).reduce((s, h) => {
731
731
  const o = this.measureText(h, e) * this.textScale, c = Math.floor((i + o / 2) * this.charWidth / this.textScale);
732
- return i += o, r + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
733
- }, ""), s = Object.keys(this.textAttributes).reduce((r, h) => r + ` ${h}="${this.textAttributes[h]}"`, "");
734
- return this.textElement += `<text${s}>${a}</text>`, this.textPosition += this.measureText(t, e) * this.textScale, "";
732
+ return i += o, s + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
733
+ }, ""), r = Object.keys(this.textAttributes).reduce((s, h) => s + ` ${h}="${this.textAttributes[h]}"`, "");
734
+ return this.textElement += `<text${r}>${a}</text>`, this.textPosition += this.measureText(t, e) * this.textScale, "";
735
735
  }
736
736
  // feed new line:
737
737
  async lf() {
@@ -744,19 +744,19 @@ class I extends H {
744
744
  }
745
745
  // print image:
746
746
  async image(t) {
747
- const e = V(t), i = new DataView(e.buffer), a = i.getUint32(16, !1), s = i.getUint32(20, !1), r = `<image href="data:image/png;base64,${O(e)}" x="0" y="0" width="${a}" height="${s}"/>`, h = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - a) * this.lineAlign / 2);
748
- return this.svgContent += `<g transform="translate(${h},${this.svgHeight})">${r}</g>`, this.svgHeight += s, "";
747
+ const e = V(t), i = new DataView(e.buffer), a = i.getUint32(16, !1), r = i.getUint32(20, !1), s = `<image href="data:image/png;base64,${O(e)}" x="0" y="0" width="${a}" height="${r}"/>`, h = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - a) * this.lineAlign / 2);
748
+ return this.svgContent += `<g transform="translate(${h},${this.svgHeight})">${s}</g>`, this.svgHeight += r, "";
749
749
  }
750
750
  // print QR Code:
751
751
  async qrcode(t, e) {
752
752
  const i = _({
753
753
  data: t.data,
754
- ec: t.level == "l" ? M.L : t.level == "m" ? M.M : t.level == "q" ? M.Q : M.H
755
- }), a = i.width, s = t.cell, r = await it(i, {
756
- moduleSize: s,
754
+ ec: t.level == "l" ? C.L : t.level == "m" ? C.M : t.level == "q" ? C.Q : C.H
755
+ }), a = i.width, r = t.cell, s = await it(i, {
756
+ moduleSize: r,
757
757
  margin: t.quietZone ? 4 : 0,
758
758
  output: "path"
759
- }), h = typeof r == "string" ? r : r.path || r.svg || String(r), o = a * s + (t.quietZone ? 8 : 0), c = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - o) * this.lineAlign / 2), l = Math.floor(this.svgHeight);
759
+ }), h = typeof s == "string" ? s : s.path || s.svg || String(s), o = a * r + (t.quietZone ? 8 : 0), c = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - o) * this.lineAlign / 2), l = Math.floor(this.svgHeight);
760
760
  return this.svgContent += `<g transform="translate(${c},${l})" shape-rendering="crispEdges">
761
761
  <path d="${h}" stroke="transparent" fill="black" shape-rendering="crispEdges" />
762
762
  </g>`, this.svgHeight += o, "";
@@ -765,14 +765,14 @@ class I extends H {
765
765
  async barcode(t, e) {
766
766
  const i = K(t), a = i.height;
767
767
  if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
768
- const s = i.length, r = a + (i.hri ? this.charWidth * 2 + 2 : 0);
768
+ const r = i.length, s = a + (i.hri ? this.charWidth * 2 + 2 : 0);
769
769
  let h = '<path d="';
770
770
  if (i.widths.reduce((c, l, u) => (u % 2 === 1 && (h += `M${c},0h${l}v${a}h${-l}z`), c + l), 0), h += '" fill="#000"/>', i.hri && i.text) {
771
- const c = Math.floor((s - (this.measureText(i.text, e) - 1) * this.charWidth) / 2), l = this.arrayFrom(i.text, e).reduce((u, d, g) => u + `<tspan x="${c + this.charWidth * g}">${d.replace(/[ &<>]/g, (p) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[p] || p)}</tspan>`, "");
772
- h += `<text y="${r}">${l}</text>`;
771
+ const c = Math.floor((r - (this.measureText(i.text, e) - 1) * this.charWidth) / 2), l = this.arrayFrom(i.text, e).reduce((u, d, g) => u + `<tspan x="${c + this.charWidth * g}">${d.replace(/[ &<>]/g, (p) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[p] || p)}</tspan>`, "");
772
+ h += `<text y="${s}">${l}</text>`;
773
773
  }
774
- const o = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - s) * this.lineAlign / 2);
775
- this.svgContent += `<g transform="translate(${o},${this.svgHeight})">${h}</g>`, this.svgHeight += r;
774
+ const o = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - r) * this.lineAlign / 2);
775
+ this.svgContent += `<g transform="translate(${o},${this.svgHeight})">${h}</g>`, this.svgHeight += s;
776
776
  }
777
777
  return "";
778
778
  }
@@ -990,21 +990,21 @@ function bt(n, t) {
990
990
  }
991
991
  function R(n, t = {}) {
992
992
  const e = [];
993
- let i, a, s;
993
+ let i, a, r;
994
994
  if (n && typeof n == "object" && "node" in n) {
995
995
  const l = n;
996
- i = l.node, a = l.xml ?? t.xml, s = l.doctype ?? t.doctype;
996
+ i = l.node, a = l.xml ?? t.xml, r = l.doctype ?? t.doctype;
997
997
  } else
998
- i = n, a = t.xml, s = t.doctype;
998
+ i = n, a = t.xml, r = t.doctype;
999
999
  a && (e.push(a), a.endsWith(`
1000
1000
  `) || e.push(`
1001
- `)), s && (e.push(s), s.endsWith(`
1001
+ `)), r && (e.push(r), r.endsWith(`
1002
1002
  `) || e.push(`
1003
1003
  `));
1004
- const r = t.useCDataForScripts ?? !1, h = t.useCDataForStyles ?? !1, o = t.voidTrailingSlash ?? !0, c = t.attributeNaming ?? "eitherName";
1005
- return j(i, e, "HTML", r, h, o, c), e.join("");
1004
+ const s = t.useCDataForScripts ?? !1, h = t.useCDataForStyles ?? !1, o = t.voidTrailingSlash ?? !0, c = t.attributeNaming ?? "eitherName";
1005
+ return P(i, e, "HTML", s, h, o, c), e.join("");
1006
1006
  }
1007
- function j(n, t, e, i, a, s, r) {
1007
+ function P(n, t, e, i, a, r, s) {
1008
1008
  if (n != null) {
1009
1009
  if (typeof n == "string") {
1010
1010
  t.push(F(n, !1));
@@ -1020,16 +1020,16 @@ function j(n, t, e, i, a, s, r) {
1020
1020
  }
1021
1021
  if (Array.isArray(n)) {
1022
1022
  for (const h of n)
1023
- j(h, t, e, i, a, s, r);
1023
+ P(h, t, e, i, a, r, s);
1024
1024
  return;
1025
1025
  }
1026
1026
  if (typeof n != "function" && typeof n != "symbol" && !(n && typeof n == "object" && "then" in n && typeof n.then == "function") && n && typeof n == "object" && "type" in n && "props" in n) {
1027
- xt(n, t, e, i, a, s, r);
1027
+ xt(n, t, e, i, a, r, s);
1028
1028
  return;
1029
1029
  }
1030
1030
  }
1031
1031
  }
1032
- function xt(n, t, e, i, a, s, r) {
1032
+ function xt(n, t, e, i, a, r, s) {
1033
1033
  var h;
1034
1034
  const o = n.type;
1035
1035
  let c = e;
@@ -1037,7 +1037,7 @@ function xt(n, t, e, i, a, s, r) {
1037
1037
  for (const [d, g] of Object.entries(n.props)) {
1038
1038
  if (d === "children" || g === !1 || g === null || g === void 0)
1039
1039
  continue;
1040
- const p = bt(d, r);
1040
+ const p = bt(d, s);
1041
1041
  if (g === !0)
1042
1042
  t.push(" "), t.push(p);
1043
1043
  else if (d === "style" && typeof g == "object") {
@@ -1049,14 +1049,14 @@ function xt(n, t, e, i, a, s, r) {
1049
1049
  const l = (h = n.props) == null ? void 0 : h.children;
1050
1050
  let u;
1051
1051
  if (l && typeof l == "object" && "then" in l && typeof l.then == "function" ? u = !1 : u = l != null && (Array.isArray(l) && l.length > 0 || !Array.isArray(l) && l !== !1), ft.has(o))
1052
- s ? t.push(" />") : t.push(">");
1052
+ r ? t.push(" />") : t.push(">");
1053
1053
  else if (u) {
1054
1054
  t.push(">");
1055
1055
  const d = l;
1056
- o === "script" && i || o === "style" && a ? (t.push("<![CDATA["), J(d, t, c, i, a, s, r), t.push("]]>")) : o === "script" || o === "style" ? Q(d, t) : j(d, t, c, i, a, s, r), t.push("</"), t.push(o), t.push(">");
1056
+ o === "script" && i || o === "style" && a ? (t.push("<![CDATA["), J(d, t, c, i, a, r, s), t.push("]]>")) : o === "script" || o === "style" ? Q(d, t) : P(d, t, c, i, a, r, s), t.push("</"), t.push(o), t.push(">");
1057
1057
  } else wt.has(o), t.push("></"), t.push(o), t.push(">");
1058
1058
  }
1059
- function J(n, t, e, i, a, s, r, h) {
1059
+ function J(n, t, e, i, a, r, s, h) {
1060
1060
  if (n != null) {
1061
1061
  if (typeof n == "string") {
1062
1062
  t.push(mt(n));
@@ -1068,10 +1068,10 @@ function J(n, t, e, i, a, s, r, h) {
1068
1068
  }
1069
1069
  if (Array.isArray(n)) {
1070
1070
  for (const o of n)
1071
- J(o, t, e, i, a, s, r);
1071
+ J(o, t, e, i, a, r, s);
1072
1072
  return;
1073
1073
  }
1074
- j(n, t, e, i, a, s, r);
1074
+ P(n, t, e, i, a, r, s);
1075
1075
  }
1076
1076
  }
1077
1077
  function Q(n, t) {
@@ -1118,8 +1118,8 @@ async function U(n) {
1118
1118
  const t = n, e = {};
1119
1119
  for (const [i, a] of Object.entries(t.props))
1120
1120
  if (i === "children") {
1121
- const s = await U(a);
1122
- s != null && (e.children = s);
1121
+ const r = await U(a);
1122
+ r != null && (e.children = r);
1123
1123
  } else {
1124
1124
  if (typeof a == "function" || typeof a == "symbol")
1125
1125
  continue;
@@ -1132,10 +1132,10 @@ async function U(n) {
1132
1132
  }
1133
1133
  }
1134
1134
  }
1135
- function At(n, t = {}) {
1135
+ function Wt(n, t = {}) {
1136
1136
  return n && typeof n == "object" && "node" in n ? R(n, t) : n === void 0 ? "" : R(n, t);
1137
1137
  }
1138
- async function Wt(n) {
1138
+ async function At(n) {
1139
1139
  return await U(n);
1140
1140
  }
1141
1141
  function St(...n) {
@@ -1147,21 +1147,21 @@ function St(...n) {
1147
1147
  t.set(i, e), e += i.length;
1148
1148
  return t;
1149
1149
  }
1150
- async function Mt(n) {
1150
+ async function Ct(n) {
1151
1151
  const t = new CompressionStream("deflate"), e = t.writable.getWriter();
1152
1152
  e.write(n), e.close();
1153
1153
  const i = t.readable.getReader(), a = [];
1154
- let s = 0;
1154
+ let r = 0;
1155
1155
  for (; ; ) {
1156
1156
  const { done: o, value: c } = await i.read();
1157
1157
  if (o) break;
1158
- a.push(c), s += c.length;
1158
+ a.push(c), r += c.length;
1159
1159
  }
1160
- const r = new Uint8Array(s);
1160
+ const s = new Uint8Array(r);
1161
1161
  let h = 0;
1162
1162
  for (const o of a)
1163
- r.set(o, h), h += o.length;
1164
- return r;
1163
+ s.set(o, h), h += o.length;
1164
+ return s;
1165
1165
  }
1166
1166
  const X = new Uint32Array(256);
1167
1167
  for (let n = 0; n < 256; n++) {
@@ -1170,7 +1170,7 @@ for (let n = 0; n < 256; n++) {
1170
1170
  t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
1171
1171
  X[n] = t;
1172
1172
  }
1173
- function Ct(n) {
1173
+ function Mt(n) {
1174
1174
  let t = 4294967295;
1175
1175
  for (let e = 0; e < n.length; e++)
1176
1176
  t = X[(t ^ n[e]) & 255] ^ t >>> 8;
@@ -1180,25 +1180,25 @@ const Ht = new TextEncoder();
1180
1180
  function N(n, t) {
1181
1181
  const e = new Uint8Array(8 + t.length + 4), i = new DataView(e.buffer);
1182
1182
  i.setUint32(0, t.length), e.set(Ht.encode(n), 4), e.set(t, 8);
1183
- const a = Ct(e.subarray(4, e.length - 4));
1183
+ const a = Mt(e.subarray(4, e.length - 4));
1184
1184
  return i.setUint32(e.length - 4, a), e;
1185
1185
  }
1186
1186
  function qt(n) {
1187
1187
  return n <= 1 ? 1 : n <= 3 ? 2 : n <= 15 ? 4 : 8;
1188
1188
  }
1189
1189
  function Nt(n, t, e, i) {
1190
- const a = 8 / i, s = Math.ceil(t / a) + 1, r = new Uint8Array(s * e), h = new DataView(r.buffer);
1190
+ const a = 8 / i, r = Math.ceil(t / a) + 1, s = new Uint8Array(r * e), h = new DataView(s.buffer);
1191
1191
  for (let o = 0; o < e; o++) {
1192
- h.setUint8(o * s, 0);
1192
+ h.setUint8(o * r, 0);
1193
1193
  for (let c = 0; c < t; c++) {
1194
- const l = n.getUint8(o * t + c), u = o * s + 1 + Math.floor(c / a), d = (a - 1 - c % a) * i, g = h.getUint8(u);
1194
+ const l = n.getUint8(o * t + c), u = o * r + 1 + Math.floor(c / a), d = (a - 1 - c % a) * i, g = h.getUint8(u);
1195
1195
  h.setUint8(u, g | l << d);
1196
1196
  }
1197
1197
  }
1198
- return r;
1198
+ return s;
1199
1199
  }
1200
- const Ut = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), Et = new TextDecoder();
1201
- function Pt(n) {
1200
+ const Ut = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), jt = new TextDecoder();
1201
+ function Et(n) {
1202
1202
  switch (n) {
1203
1203
  case 0:
1204
1204
  return "greyscale";
@@ -1214,7 +1214,7 @@ function Pt(n) {
1214
1214
  throw new Error(`Invalid color type: ${n}`);
1215
1215
  }
1216
1216
  }
1217
- function jt(n) {
1217
+ function Pt(n) {
1218
1218
  switch (n) {
1219
1219
  case 0:
1220
1220
  return "none";
@@ -1250,17 +1250,17 @@ function zt(n, t) {
1250
1250
  throw new Error(
1251
1251
  `Chunk at offset ${t} extends beyond data (need at least 12 bytes for header)`
1252
1252
  );
1253
- const e = n.getUint32(t, !1), i = new Uint8Array(n.buffer, n.byteOffset + t + 4, 4), a = Et.decode(i), s = 8 + e + 4;
1254
- if (t + s > n.byteLength)
1253
+ const e = n.getUint32(t, !1), i = new Uint8Array(n.buffer, n.byteOffset + t + 4, 4), a = jt.decode(i), r = 8 + e + 4;
1254
+ if (t + r > n.byteLength)
1255
1255
  throw new Error(
1256
- `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${s}, available: ${n.byteLength - t})`
1256
+ `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${r}, available: ${n.byteLength - t})`
1257
1257
  );
1258
- const r = new DataView(n.buffer, n.byteOffset + t + 8, e);
1258
+ const s = new DataView(n.buffer, n.byteOffset + t + 8, e);
1259
1259
  return {
1260
1260
  type: a,
1261
- data: r,
1261
+ data: s,
1262
1262
  offset: t,
1263
- totalSize: s
1263
+ totalSize: r
1264
1264
  };
1265
1265
  }
1266
1266
  function* It(n, t = 0) {
@@ -1278,21 +1278,21 @@ function Ft(n, t, e, i = 0) {
1278
1278
  function Lt(n) {
1279
1279
  if (n.byteLength !== 13)
1280
1280
  throw new Error(`IHDR chunk must be 13 bytes, got ${n.byteLength}`);
1281
- const t = n.getUint32(0, !1), e = n.getUint32(4, !1), i = n.getUint8(8), a = n.getUint8(9), s = n.getUint8(10), r = n.getUint8(11), h = n.getUint8(12);
1281
+ const t = n.getUint32(0, !1), e = n.getUint32(4, !1), i = n.getUint8(8), a = n.getUint8(9), r = n.getUint8(10), s = n.getUint8(11), h = n.getUint8(12);
1282
1282
  if (t === 0)
1283
1283
  throw new Error("IHDR width cannot be zero");
1284
1284
  if (e === 0)
1285
1285
  throw new Error("IHDR height cannot be zero");
1286
- if (s !== 0)
1286
+ if (r !== 0)
1287
1287
  throw new Error(
1288
- `Invalid compression method: ${s}. Only 0 (deflate) is supported.`
1288
+ `Invalid compression method: ${r}. Only 0 (deflate) is supported.`
1289
1289
  );
1290
- if (r !== 0)
1290
+ if (s !== 0)
1291
1291
  throw new Error(
1292
- `Invalid filter method: ${r}. Only 0 (adaptive) is supported.`
1292
+ `Invalid filter method: ${s}. Only 0 (adaptive) is supported.`
1293
1293
  );
1294
1294
  Dt(i, a);
1295
- const o = Pt(a), c = jt(h);
1295
+ const o = Et(a), c = Pt(h);
1296
1296
  return {
1297
1297
  width: t,
1298
1298
  height: e,
@@ -1314,34 +1314,34 @@ function Bt(n) {
1314
1314
  function Tt(n) {
1315
1315
  const t = n instanceof Uint8Array ? n.buffer : n, e = n instanceof Uint8Array ? n.byteOffset : 0, i = n.byteLength, a = new DataView(t, e, i);
1316
1316
  Bt(a);
1317
- const s = Ft(a, "IHDR", Lt, 8);
1318
- if (s === void 0)
1317
+ const r = Ft(a, "IHDR", Lt, 8);
1318
+ if (r === void 0)
1319
1319
  throw new Error("IHDR chunk not found in PNG");
1320
- return s;
1320
+ return r;
1321
1321
  }
1322
1322
  async function Rt(n, t, e, i) {
1323
- const a = new DataView(n.buffer), s = a.byteLength;
1324
- if (s === 0)
1323
+ const a = new DataView(n.buffer), r = a.byteLength;
1324
+ if (r === 0)
1325
1325
  throw new Error("Received empty input");
1326
- if (s !== t * e)
1326
+ if (r !== t * e)
1327
1327
  throw new Error(
1328
- `Input does not match dimensions ${t}x${e}. Only ${s} bytes were given when ${t * e} are expected!`
1328
+ `Input does not match dimensions ${t}x${e}. Only ${r} bytes were given when ${t * e} are expected!`
1329
1329
  );
1330
- let r = 0;
1331
- for (let w = 0; w < s; w++) {
1330
+ let s = 0;
1331
+ for (let w = 0; w < r; w++) {
1332
1332
  const m = a.getUint8(w);
1333
- m > r && (r = m);
1333
+ m > s && (s = m);
1334
1334
  }
1335
- if (i.length <= r)
1335
+ if (i.length <= s)
1336
1336
  throw new Error(
1337
- `Color palette does not have enough colors (${r + 1}). Only ${i.length} were given!`
1337
+ `Color palette does not have enough colors (${s + 1}). Only ${i.length} were given!`
1338
1338
  );
1339
- const h = qt(r), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), l = new DataView(c.buffer);
1339
+ const h = qt(s), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), l = new DataView(c.buffer);
1340
1340
  l.setUint32(0, t), l.setUint32(4, e), l.setUint8(8, h), l.setUint8(9, 3), l.setUint8(10, 0), l.setUint8(11, 0), l.setUint8(12, 0);
1341
1341
  const u = N("IHDR", c), d = new Uint8Array(i.length * 3), g = new DataView(d.buffer);
1342
- for (let w = 0; w <= r; w++)
1342
+ for (let w = 0; w <= s; w++)
1343
1343
  g.setUint8(w * 3, i[w][0]), g.setUint8(w * 3 + 1, i[w][1]), g.setUint8(w * 3 + 2, i[w][2]);
1344
- const p = N("PLTE", d), f = Nt(a, t, e, h), $ = N("IDAT", await Mt(f)), k = N("IEND", new Uint8Array(0));
1344
+ const p = N("PLTE", d), f = Nt(a, t, e, h), $ = N("IDAT", await Ct(f)), k = N("IEND", new Uint8Array(0));
1345
1345
  return St(o, u, p, $, k);
1346
1346
  }
1347
1347
  async function Zt(n, t = {}) {
@@ -1349,8 +1349,8 @@ async function Zt(n, t = {}) {
1349
1349
  const {
1350
1350
  margin: i = 4,
1351
1351
  moduleSize: a = 4,
1352
- backgroundColor: s = [255, 255, 255],
1353
- foregroundColor: r = [0, 0, 0]
1352
+ backgroundColor: r = [255, 255, 255],
1353
+ foregroundColor: s = [0, 0, 0]
1354
1354
  } = t, { matrix: h } = n, o = ((e = h[0]) == null ? void 0 : e.length) ?? 0, c = h.length, l = (o + i * 2) * a, u = (c + i * 2) * a, d = new Uint8Array(l * u);
1355
1355
  d.fill(0);
1356
1356
  for (let g = 0; g < c; g++)
@@ -1362,7 +1362,7 @@ async function Zt(n, t = {}) {
1362
1362
  d[w * l + k] = 1;
1363
1363
  }
1364
1364
  return {
1365
- bytes: await Rt(d, l, u, [s, r]),
1365
+ bytes: await Rt(d, l, u, [r, s]),
1366
1366
  width: l,
1367
1367
  height: u
1368
1368
  };
@@ -1456,11 +1456,11 @@ class Y extends H {
1456
1456
  children: this.contentNodes
1457
1457
  };
1458
1458
  e && (a.lang = e);
1459
- const r = await Wt({
1459
+ const s = await At({
1460
1460
  type: "div",
1461
1461
  props: a
1462
1462
  });
1463
- return At(r);
1463
+ return Wt(s);
1464
1464
  }
1465
1465
  // set print area:
1466
1466
  async area(t, e, i) {
@@ -1488,7 +1488,7 @@ class Y extends H {
1488
1488
  marginLeft: `${this.lineMargin}ch`,
1489
1489
  width: `${t}ch`,
1490
1490
  height: "0",
1491
- display: "block"
1491
+ display: "flex"
1492
1492
  }
1493
1493
  }
1494
1494
  };
@@ -1496,16 +1496,16 @@ class Y extends H {
1496
1496
  }
1497
1497
  // print vertical rules:
1498
1498
  async vr(t, e) {
1499
- const i = this.charWidth, a = i / 2, s = this.charHeight * e, r = t.reduce((l, u) => l + u, 0) + t.length + 1;
1500
- let h = `M${a},0v${s}`;
1499
+ const i = this.charWidth, a = i / 2, r = this.charHeight * e, s = t.reduce((l, u) => l + u, 0) + t.length + 1;
1500
+ let h = `M${a},0v${r}`;
1501
1501
  for (const l of t)
1502
- h += `m${l * i + i},${-s}v${s}`;
1503
- const o = r * i, c = {
1502
+ h += `m${l * i + i},${-r}v${r}`;
1503
+ const o = s * i, c = {
1504
1504
  type: "svg",
1505
1505
  props: {
1506
- width: `${r}ch`,
1507
- height: `${s}`,
1508
- viewBox: `0 0 ${o} ${s}`,
1506
+ width: `${s}ch`,
1507
+ height: `${r}`,
1508
+ viewBox: `0 0 ${o} ${r}`,
1509
1509
  preserveAspectRatio: "none",
1510
1510
  style: {
1511
1511
  position: "absolute",
@@ -1528,21 +1528,21 @@ class Y extends H {
1528
1528
  }
1529
1529
  // start rules:
1530
1530
  async vrstart(t) {
1531
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, s = e * 2, r = this.buildVrStartPath(t), h = {
1531
+ const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, r = e * 2, s = this.buildVrStartPath(t), h = {
1532
1532
  type: "svg",
1533
1533
  props: {
1534
1534
  width: `${i}ch`,
1535
- height: `${s}`,
1536
- viewBox: `0 0 ${a} ${s}`,
1535
+ height: `${r}`,
1536
+ viewBox: `0 0 ${a} ${r}`,
1537
1537
  preserveAspectRatio: "none",
1538
1538
  style: {
1539
- display: "block",
1539
+ display: "flex",
1540
1540
  marginLeft: `${this.lineMargin}ch`
1541
1541
  },
1542
1542
  children: {
1543
1543
  type: "path",
1544
1544
  props: {
1545
- d: r,
1545
+ d: s,
1546
1546
  fill: "none",
1547
1547
  stroke: "black",
1548
1548
  "stroke-width": "2",
@@ -1556,29 +1556,28 @@ class Y extends H {
1556
1556
  buildVrStartPath(t) {
1557
1557
  const e = this.charWidth, i = e / 2;
1558
1558
  let a = `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`;
1559
- for (let s = 0; s < t.length; s++) {
1560
- const r = t[s] ?? 0;
1561
- a += `h${e * r}h${i}v${e}m0,${-e}h${i}`;
1559
+ for (let r = 0; r < t.length; r++) {
1560
+ const s = t[r] ?? 0;
1561
+ a += `h${e * s}h${i}v${e}m0,${-e}h${i}`;
1562
1562
  }
1563
1563
  return a = a.replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`), a;
1564
1564
  }
1565
1565
  // stop rules:
1566
1566
  async vrstop(t) {
1567
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, s = e * 2, r = this.buildVrStopPath(t), h = {
1567
+ const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, r = e * 2, s = this.buildVrStopPath(t), h = {
1568
1568
  type: "svg",
1569
1569
  props: {
1570
1570
  width: `${i}ch`,
1571
- height: `${s}`,
1572
- viewBox: `0 0 ${a} ${s}`,
1571
+ height: `${r}`,
1572
+ viewBox: `0 0 ${a} ${r}`,
1573
1573
  preserveAspectRatio: "none",
1574
1574
  style: {
1575
- display: "block",
1576
1575
  marginLeft: `${this.lineMargin}ch`
1577
1576
  },
1578
1577
  children: {
1579
1578
  type: "path",
1580
1579
  props: {
1581
- d: r,
1580
+ d: s,
1582
1581
  fill: "none",
1583
1582
  stroke: "black",
1584
1583
  "stroke-width": "2",
@@ -1592,23 +1591,23 @@ class Y extends H {
1592
1591
  buildVrStopPath(t) {
1593
1592
  const e = this.charWidth, i = e / 2;
1594
1593
  let a = `M${i},0v${i}q0,${i},${i},${i}`;
1595
- for (let s = 0; s < t.length; s++) {
1596
- const r = t[s] ?? 0;
1597
- a += `h${e * r}h${i}v${-e}m0,${e}h${i}`;
1594
+ for (let r = 0; r < t.length; r++) {
1595
+ const s = t[r] ?? 0;
1596
+ a += `h${e * s}h${i}v${-e}m0,${e}h${i}`;
1598
1597
  }
1599
1598
  return a = a.replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`), a;
1600
1599
  }
1601
1600
  // print vertical and horizontal rules:
1602
1601
  async vrhr(t, e, i, a) {
1603
- const s = this.charWidth, r = s / 2, h = t.reduce((f, $) => f + $, 0) + t.length + 1, o = e.reduce((f, $) => f + $, 0) + e.length + 1, c = Math.max(h, o), l = c * s, u = s * 2;
1604
- let d = `M${r},0` + (i > 0 ? `v${r}q0,${r},${r},${r}` : `v${s}h${r}`);
1602
+ const r = this.charWidth, s = r / 2, h = t.reduce((f, $) => f + $, 0) + t.length + 1, o = e.reduce((f, $) => f + $, 0) + e.length + 1, c = Math.max(h, o), l = c * r, u = r * 2;
1603
+ let d = `M${s},0` + (i > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`);
1605
1604
  for (const f of t)
1606
- d += `h${s * f}h${r}v${-s}m0,${s}h${r}`;
1607
- d = d.replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${r},0,${r},${-r}v${-r}` : `h${r}v${-s}`);
1608
- let g = `M${r},${s + s}` + (i < 0 ? `v${-r}q0,${-r},${r},${-r}` : `v${-s}h${r}`);
1605
+ d += `h${r * f}h${s}v${-r}m0,${r}h${s}`;
1606
+ d = d.replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${s},0,${s},${-s}v${-s}` : `h${s}v${-r}`);
1607
+ let g = `M${s},${r + r}` + (i < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`);
1609
1608
  for (const f of e)
1610
- g += `h${s * f}h${r}v${s}m0,${-s}h${r}`;
1611
- g = g.replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${r},0,${r},${r}v${r}` : `h${r}v${s}`);
1609
+ g += `h${r * f}h${s}v${r}m0,${-r}h${s}`;
1610
+ g = g.replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${s},0,${s},${s}v${s}` : `h${s}v${r}`);
1612
1611
  const p = {
1613
1612
  type: "svg",
1614
1613
  props: {
@@ -1617,7 +1616,6 @@ class Y extends H {
1617
1616
  viewBox: `0 0 ${l} ${u}`,
1618
1617
  preserveAspectRatio: "none",
1619
1618
  style: {
1620
- display: "block",
1621
1619
  marginLeft: `${this.lineMargin + Math.max(-i, 0)}ch`
1622
1620
  },
1623
1621
  children: [
@@ -1664,7 +1662,7 @@ class Y extends H {
1664
1662
  style: {
1665
1663
  flex: "1",
1666
1664
  borderTop: "2px dashed black",
1667
- display: "block"
1665
+ display: "flex"
1668
1666
  }
1669
1667
  }
1670
1668
  }
@@ -1688,7 +1686,7 @@ class Y extends H {
1688
1686
  // scale up text:
1689
1687
  async wh(t) {
1690
1688
  const e = t < 2 ? t + 1 : t - 1, i = t < 3 ? t : t - 1;
1691
- return this.currentStyles.fontSize = `${i}em`, this.currentStyles.display = "block", e !== i && (this.currentStyles.transform = `scaleX(${e / i})`, this.currentStyles.transformOrigin = "left"), this.lineHeight = Math.max(this.lineHeight, i), this.textScale = e, "";
1689
+ return this.currentStyles.fontSize = `${i}em`, this.currentStyles.display = "flex", e !== i && (this.currentStyles.transform = `scaleX(${e / i})`, this.currentStyles.transformOrigin = "left"), this.lineHeight = Math.max(this.lineHeight, i), this.textScale = e, "";
1692
1690
  }
1693
1691
  // cancel text decoration:
1694
1692
  async normal() {
@@ -1696,61 +1694,61 @@ class Y extends H {
1696
1694
  }
1697
1695
  // print text:
1698
1696
  async text(t, e) {
1699
- const i = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, " "), a = this.measureText(t, e), s = {
1697
+ const i = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, " "), a = this.measureText(t, e), r = {
1700
1698
  position: this.currentPosition,
1701
1699
  text: i,
1702
1700
  styles: { ...this.currentStyles },
1703
1701
  scale: this.textScale,
1704
1702
  charWidth: a
1705
1703
  };
1706
- return this.lineSegments.push(s), this.currentPosition += a * this.textScale, "";
1704
+ return this.lineSegments.push(r), this.currentPosition += a * this.textScale, "";
1707
1705
  }
1708
1706
  // feed new line:
1709
1707
  async lf() {
1710
1708
  const t = this.lineHeight * this.charHeight, e = Math.max(t, this.feedMinimum), i = this.lineMargin + this.lineWidth, a = [];
1711
1709
  if (this.lineSegments.length === 0) {
1712
1710
  if (this.pendingVrSvg) {
1713
- const r = {
1711
+ const s = {
1714
1712
  type: "div",
1715
1713
  props: {
1716
1714
  style: {
1717
1715
  position: "relative",
1718
1716
  width: `${this.containerWidth}px`,
1719
1717
  height: `${e}px`,
1720
- display: "block"
1718
+ display: "flex"
1721
1719
  },
1722
1720
  children: this.pendingVrSvg
1723
1721
  }
1724
1722
  };
1725
- this.contentNodes.push(r), this.pendingVrSvg = null, this.estimatedHeight += e;
1723
+ this.contentNodes.push(s), this.pendingVrSvg = null, this.estimatedHeight += e;
1726
1724
  }
1727
1725
  return this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1728
1726
  } else {
1729
- const r = [...this.lineSegments].sort((u, d) => u.position - d.position);
1727
+ const s = [...this.lineSegments].sort((u, d) => u.position - d.position);
1730
1728
  let h = 0;
1731
1729
  const o = (u) => Math.floor(u), c = (u) => `${o(u)}ch`, l = (u) => {
1732
1730
  const d = u.match(/^(\d+(?:\.\d+)?)ch$/);
1733
1731
  return d ? parseFloat(d[1]) : 0;
1734
1732
  };
1735
- for (let u = 0; u < r.length; u++) {
1736
- const d = r[u], g = this.lineMargin + d.position, p = d.charWidth * d.scale;
1733
+ for (let u = 0; u < s.length; u++) {
1734
+ const d = s[u], g = this.lineMargin + d.position, p = d.charWidth * d.scale;
1737
1735
  if (g > h && a.length > 0) {
1738
- const A = g - h, v = a[a.length - 1];
1736
+ const W = g - h, v = a[a.length - 1];
1739
1737
  if (v && v.props && v.props.style && typeof v.props.style == "object" && !Array.isArray(v.props.style)) {
1740
- const W = v.props.style, x = W.flexBasis;
1738
+ const A = v.props.style, x = A.flexBasis;
1741
1739
  if (x) {
1742
- const D = l(x) + A;
1743
- W.flexBasis = c(D);
1740
+ const D = l(x) + W;
1741
+ A.flexBasis = c(D);
1744
1742
  } else
1745
- W.flexBasis = c(A);
1743
+ A.flexBasis = c(W);
1746
1744
  }
1747
1745
  } else if (g > h && a.length === 0) {
1748
- const A = g - h;
1746
+ const W = g - h;
1749
1747
  a.push({
1750
1748
  type: "span",
1751
1749
  props: {
1752
1750
  style: {
1753
- flexBasis: c(A)
1751
+ flexBasis: c(W)
1754
1752
  }
1755
1753
  }
1756
1754
  });
@@ -1786,7 +1784,7 @@ class Y extends H {
1786
1784
  }
1787
1785
  }
1788
1786
  }
1789
- const s = {
1787
+ const r = {
1790
1788
  type: "div",
1791
1789
  props: {
1792
1790
  style: {
@@ -1799,25 +1797,25 @@ class Y extends H {
1799
1797
  }
1800
1798
  };
1801
1799
  if (this.pendingVrSvg) {
1802
- const r = {
1800
+ const s = {
1803
1801
  type: "div",
1804
1802
  props: {
1805
1803
  style: {
1806
1804
  position: "relative",
1807
1805
  width: `${this.containerWidth}px`,
1808
1806
  minHeight: `${e}px`,
1809
- display: "block"
1807
+ display: "flex"
1810
1808
  },
1811
1809
  children: [
1812
1810
  // VR SVG positioned absolutely behind text
1813
1811
  this.pendingVrSvg,
1814
1812
  // Text line positioned relatively on top
1815
1813
  {
1816
- ...s,
1814
+ ...r,
1817
1815
  props: {
1818
- ...s.props,
1816
+ ...r.props,
1819
1817
  style: {
1820
- ...s.props?.style,
1818
+ ...r.props?.style,
1821
1819
  position: "relative"
1822
1820
  }
1823
1821
  }
@@ -1825,9 +1823,9 @@ class Y extends H {
1825
1823
  ]
1826
1824
  }
1827
1825
  };
1828
- this.contentNodes.push(r), this.pendingVrSvg = null;
1826
+ this.contentNodes.push(s), this.pendingVrSvg = null;
1829
1827
  } else
1830
- this.contentNodes.push(s);
1828
+ this.contentNodes.push(r);
1831
1829
  return this.estimatedHeight += e, this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1832
1830
  }
1833
1831
  // insert commands:
@@ -1836,24 +1834,24 @@ class Y extends H {
1836
1834
  }
1837
1835
  // print image:
1838
1836
  async image(t) {
1839
- const e = this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right", i = V(t), a = Tt(i), s = a.width, r = a.height, h = {
1837
+ const e = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", i = V(t), a = Tt(i), r = a.width, s = a.height, h = {
1840
1838
  type: "img",
1841
1839
  props: {
1842
1840
  src: `data:image/png;base64,${t}`,
1843
1841
  style: Vt({
1844
1842
  maxWidth: `${this.lineWidth}ch`
1845
1843
  }),
1846
- width: `${s}`,
1847
- height: `${r}`
1844
+ width: `${r}`,
1845
+ height: `${s}`
1848
1846
  }
1849
1847
  }, o = {
1850
1848
  type: "div",
1851
1849
  props: {
1852
1850
  style: {
1853
- textAlign: e,
1851
+ justifyContent: e,
1854
1852
  paddingLeft: `${this.lineMargin}ch`,
1855
1853
  width: `${this.lineWidth}ch`,
1856
- display: "block"
1854
+ display: "flex"
1857
1855
  },
1858
1856
  children: h
1859
1857
  }
@@ -1862,18 +1860,18 @@ class Y extends H {
1862
1860
  }
1863
1861
  // print QR Code (async version using PNG):
1864
1862
  async qrcode(t, e) {
1865
- const i = _({
1863
+ const i = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", a = _({
1866
1864
  data: t.data,
1867
- ec: t.level === "l" ? M.L : t.level === "m" ? M.M : t.level === "q" ? M.Q : M.H
1868
- }), a = t.cell, s = t.quietZone ? 4 : 0, { bytes: r, width: h, height: o } = await Zt(i, {
1869
- moduleSize: a,
1865
+ ec: t.level === "l" ? C.L : t.level === "m" ? C.M : t.level === "q" ? C.Q : C.H
1866
+ }), r = t.cell, s = t.quietZone ? 4 : 0, { bytes: h, width: o, height: c } = await Zt(a, {
1867
+ moduleSize: r,
1870
1868
  margin: s
1871
- }), l = {
1869
+ }), u = {
1872
1870
  type: "img",
1873
1871
  props: {
1874
- src: `data:image/png;base64,${O(r)}`,
1875
- width: `${h}`,
1876
- height: `${o}`,
1872
+ src: `data:image/png;base64,${O(h)}`,
1873
+ width: `${o}`,
1874
+ height: `${c}`,
1877
1875
  style: {
1878
1876
  imageRendering: "pixelated"
1879
1877
  }
@@ -1882,37 +1880,37 @@ class Y extends H {
1882
1880
  type: "div",
1883
1881
  props: {
1884
1882
  style: {
1885
- textAlign: this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right",
1883
+ justifyContent: i,
1886
1884
  paddingLeft: `${this.lineMargin}ch`,
1887
1885
  width: `${this.lineWidth}ch`,
1888
- display: "block"
1886
+ display: "flex"
1889
1887
  },
1890
- children: [l]
1888
+ children: [u]
1891
1889
  }
1892
1890
  };
1893
- return this.contentNodes.push(d), this.estimatedHeight += o, "";
1891
+ return this.contentNodes.push(d), this.estimatedHeight += c, "";
1894
1892
  }
1895
1893
  // print barcode:
1896
1894
  async barcode(t, e) {
1897
- const i = K(t), a = i.height;
1895
+ const i = K(t), a = i.height, r = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end";
1898
1896
  if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
1899
- const s = i.length, r = a + (i.hri ? this.charHeight + 2 : 0);
1900
- let h = "";
1901
- i.widths.reduce((d, g, p) => (p % 2 === 1 && (h += `M${d},0h${g}v${a}h${-g}z`), d + g), 0);
1902
- const o = [
1897
+ const s = i.length, h = a + (i.hri ? this.charHeight + 2 : 0);
1898
+ let o = "";
1899
+ i.widths.reduce((d, g, p) => (p % 2 === 1 && (o += `M${d},0h${g}v${a}h${-g}z`), d + g), 0);
1900
+ const c = [
1903
1901
  {
1904
1902
  type: "path",
1905
1903
  props: {
1906
- d: h,
1904
+ d: o,
1907
1905
  fill: "black"
1908
1906
  }
1909
1907
  }
1910
1908
  ];
1911
- i.hri && i.text && o.push({
1909
+ i.hri && i.text && c.push({
1912
1910
  type: "text",
1913
1911
  props: {
1914
1912
  x: `${s / 2}`,
1915
- y: `${r}`,
1913
+ y: `${h}`,
1916
1914
  "text-anchor": "middle",
1917
1915
  "font-family": "monospace",
1918
1916
  "font-size": `${this.charWidth * 2}`,
@@ -1920,30 +1918,27 @@ class Y extends H {
1920
1918
  children: i.text
1921
1919
  }
1922
1920
  });
1923
- const c = {
1921
+ const l = {
1924
1922
  type: "svg",
1925
1923
  props: {
1926
1924
  width: `${s}`,
1927
- height: `${r}`,
1928
- viewBox: `0 0 ${s} ${r}`,
1929
- style: {
1930
- display: "block"
1931
- },
1932
- children: o
1925
+ height: `${h}`,
1926
+ viewBox: `0 0 ${s} ${h}`,
1927
+ children: c
1933
1928
  }
1934
1929
  }, u = {
1935
1930
  type: "div",
1936
1931
  props: {
1937
1932
  style: {
1938
- textAlign: this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right",
1933
+ justifyContent: r,
1939
1934
  paddingLeft: `${this.lineMargin}ch`,
1940
1935
  width: `${this.lineWidth}ch`,
1941
- display: "block"
1936
+ display: "flex"
1942
1937
  },
1943
- children: c
1938
+ children: l
1944
1939
  }
1945
1940
  };
1946
- this.contentNodes.push(u), this.estimatedHeight += r;
1941
+ this.contentNodes.push(u), this.estimatedHeight += h;
1947
1942
  }
1948
1943
  return "";
1949
1944
  }
@@ -2166,21 +2161,21 @@ const z = {
2166
2161
  audit: new tt()
2167
2162
  };
2168
2163
  function Ot(n) {
2169
- const t = Object.assign({}, n), e = t.encoding && /^(cp(437|85[28]|86[0356]|1252|93[26]|949|950)|multilingual|shiftjis|gb18030|ksc5601|big5|tis620)$/.test(t.encoding) ? t.encoding : "cp437", i = typeof t.target == "string" ? t.target : void 0, s = (typeof t.target == "object" && t.target !== null ? t.target : void 0) || (i && i in z ? z[i] : z.svg);
2170
- let r;
2171
- return s instanceof Y || s instanceof I || s instanceof tt || s instanceof H ? r = s : r = new I(), {
2164
+ const t = Object.assign({}, n), e = t.encoding && /^(cp(437|85[28]|86[0356]|1252|93[26]|949|950)|multilingual|shiftjis|gb18030|ksc5601|big5|tis620)$/.test(t.encoding) ? t.encoding : "cp437", i = typeof t.target == "string" ? t.target : void 0, r = (typeof t.target == "object" && t.target !== null ? t.target : void 0) || (i && i in z ? z[i] : z.svg);
2165
+ let s;
2166
+ return r instanceof Y || r instanceof I || r instanceof tt || r instanceof H ? s = r : s = new I(), {
2172
2167
  cpl: t.cpl || 48,
2173
2168
  charWidth: t.charWidth || 12,
2174
2169
  encoding: e,
2175
2170
  spacing: !!t.spacing,
2176
2171
  margin: t.margin || 0,
2177
2172
  marginRight: t.marginRight || 0,
2178
- target: r
2173
+ target: s
2179
2174
  };
2180
2175
  }
2181
2176
  function _t(n, t) {
2182
- const e = n.replace(/^[\t ]+|[\t ]+$/g, "").replace(/\\[\\{|}]/g, (i) => "\\x" + i.charCodeAt(1).toString(16)).replace(/^[^|]*[^\t |]\|/, " $&").replace(/\|[^\t |][^|]*$/, "$& ").replace(/^\|(.*)$/, "$1").replace(/^(.*)\|$/, "$1").split("|").map((i, a, s) => {
2183
- let r = {
2177
+ const e = n.replace(/^[\t ]+|[\t ]+$/g, "").replace(/\\[\\{|}]/g, (i) => "\\x" + i.charCodeAt(1).toString(16)).replace(/^[^|]*[^\t |]\|/, " $&").replace(/\|[^\t |][^|]*$/, "$& ").replace(/^\|(.*)$/, "$1").replace(/^(.*)\|$/, "$1").split("|").map((i, a, r) => {
2178
+ let s = {
2184
2179
  align: 1,
2185
2180
  wrap: t.wrap,
2186
2181
  border: t.border,
@@ -2188,8 +2183,8 @@ function _t(n, t) {
2188
2183
  alignment: t.align
2189
2184
  };
2190
2185
  const h = i.replace(/^[\t ]+|[\t ]+$/g, "");
2191
- if (r.align = 1 + Number(/^[\t ]/.test(i)) - Number(/[\t ]$/.test(i)), /^\{[^{}]*\}$/.test(h)) {
2192
- if (r.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2186
+ if (s.align = 1 + Number(/^[\t ]/.test(i)) - Number(/[\t ]$/.test(i)), /^\{[^{}]*\}$/.test(h)) {
2187
+ if (s.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2193
2188
  const l = { a: "align", b: "border", c: "code", i: "image", o: "option", t: "text", w: "width", x: "command", _: "comment" };
2194
2189
  return /^[\t ]*$/.test(c) || c.replace(
2195
2190
  /^[\t ]*([A-Za-z_]\w*)[\t ]*:[\t ]*([^\t ].*?)[\t ]*$/,
@@ -2198,26 +2193,26 @@ function _t(n, t) {
2198
2193
  return o[f] = Z(p.replace(/\\n/g, `
2199
2194
  `)), d;
2200
2195
  }
2201
- ) === c && (r.error = h), o;
2202
- }, {}), s.length === 1) {
2203
- if ("text" in r.property && r.property.text) {
2204
- const o = r.property.text.toLowerCase();
2196
+ ) === c && (s.error = h), o;
2197
+ }, {}), r.length === 1) {
2198
+ if ("text" in s.property && s.property.text) {
2199
+ const o = s.property.text.toLowerCase();
2205
2200
  t.wrap = !/^nowrap$/.test(o);
2206
2201
  }
2207
- if ("border" in r.property && r.property.border) {
2208
- const o = r.property.border.toLowerCase(), c = { line: -1, space: 1, none: 0 }, l = t.border;
2209
- t.border = /^(line|space|none)$/.test(o) ? c[o] ?? 1 : /^\d+$/.test(o) && Number(o) <= 2 ? Number(o) : 1, l >= 0 && t.border < 0 && (r.vr = "+"), l < 0 && t.border >= 0 && (r.vr = "-");
2202
+ if ("border" in s.property && s.property.border) {
2203
+ const o = s.property.border.toLowerCase(), c = { line: -1, space: 1, none: 0 }, l = t.border;
2204
+ t.border = /^(line|space|none)$/.test(o) ? c[o] ?? 1 : /^\d+$/.test(o) && Number(o) <= 2 ? Number(o) : 1, l >= 0 && t.border < 0 && (s.vr = "+"), l < 0 && t.border >= 0 && (s.vr = "-");
2210
2205
  }
2211
- if ("width" in r.property && r.property.width) {
2212
- const o = r.property.width.toLowerCase().split(/[\t ]+|,/);
2206
+ if ("width" in s.property && s.property.width) {
2207
+ const o = s.property.width.toLowerCase().split(/[\t ]+|,/);
2213
2208
  t.width = o.find((c) => /^auto$/.test(c)) ? [] : o.map((c) => /^\*$/.test(c) ? -1 : /^\d+$/.test(c) ? Number(c) : 0);
2214
2209
  }
2215
- if ("align" in r.property && r.property.align) {
2216
- const o = r.property.align.toLowerCase(), c = { left: 0, center: 1, right: 2 };
2210
+ if ("align" in s.property && s.property.align) {
2211
+ const o = s.property.align.toLowerCase(), c = { left: 0, center: 1, right: 2 };
2217
2212
  t.align = /^(left|center|right)$/.test(o) ? c[o] ?? 1 : 1;
2218
2213
  }
2219
- if ("option" in r.property && r.property.option) {
2220
- const o = r.property.option.toLowerCase().split(/[\t ]+|,/);
2214
+ if ("option" in s.property && s.property.option) {
2215
+ const o = s.property.option.toLowerCase().split(/[\t ]+|,/);
2221
2216
  t.option = {
2222
2217
  type: o.find((c) => /^(upc|ean|jan|code39|itf|codabar|nw7|code93|code128|qrcode)$/.test(c)) || "code128",
2223
2218
  width: Number(o.find((c) => /^\d+$/.test(c) && Number(c) >= 2 && Number(c) <= 4) || "2"),
@@ -2228,44 +2223,44 @@ function _t(n, t) {
2228
2223
  quietZone: !1
2229
2224
  };
2230
2225
  }
2231
- if ("code" in r.property && r.property.code && (t.option.type === "qrcode" ? r.code = Object.assign({ data: r.property.code, type: "qrcode" }, t.option) : r.code = Object.assign({ data: r.property.code, type: t.option.type }, t.option)), "image" in r.property && r.property.image) {
2232
- const o = r.property.image.replace(/=.*|[^A-Za-z0-9+/]/g, "");
2226
+ if ("code" in s.property && s.property.code && (t.option.type === "qrcode" ? s.code = Object.assign({ data: s.property.code, type: "qrcode" }, t.option) : s.code = Object.assign({ data: s.property.code, type: t.option.type }, t.option)), "image" in s.property && s.property.image) {
2227
+ const o = s.property.image.replace(/=.*|[^A-Za-z0-9+/]/g, "");
2233
2228
  switch (o.length % 4) {
2234
2229
  case 1:
2235
- r.image = o.slice(0, -1);
2230
+ s.image = o.slice(0, -1);
2236
2231
  break;
2237
2232
  case 2:
2238
- r.image = o + "==";
2233
+ s.image = o + "==";
2239
2234
  break;
2240
2235
  case 3:
2241
- r.image = o + "=";
2236
+ s.image = o + "=";
2242
2237
  break;
2243
2238
  default:
2244
- r.image = o;
2239
+ s.image = o;
2245
2240
  break;
2246
2241
  }
2247
2242
  }
2248
- "command" in r.property && r.property.command && (r.command = r.property.command), "comment" in r.property && r.property.comment && (r.comment = r.property.comment);
2243
+ "command" in s.property && s.property.command && (s.command = s.property.command), "comment" in s.property && s.property.comment && (s.comment = s.property.comment);
2249
2244
  }
2250
2245
  } else if (/[{}]/.test(h))
2251
- r.error = h;
2252
- else if (s.length === 1 && /^-+$|^=+$/.test(h)) {
2246
+ s.error = h;
2247
+ else if (r.length === 1 && /^-+$|^=+$/.test(h)) {
2253
2248
  const o = h.slice(-1);
2254
- r.hr = o === "-" || o === "=" ? o : void 0;
2249
+ s.hr = o === "-" || o === "=" ? o : void 0;
2255
2250
  } else
2256
- r.text = h.replace(/[\x00-\x1f\x7f]|\\x[01][\dA-Fa-f]|\\x7[Ff]/g, "").replace(/\\[-=_"`^~]/g, (o) => "\\x" + o.charCodeAt(1).toString(16)).replace(/\\n/g, `
2251
+ s.text = h.replace(/[\x00-\x1f\x7f]|\\x[01][\dA-Fa-f]|\\x7[Ff]/g, "").replace(/\\[-=_"`^~]/g, (o) => "\\x" + o.charCodeAt(1).toString(16)).replace(/\\n/g, `
2257
2252
  `).replace(/~/g, " ").split(/([_"`\n]|\^+)/).map((o) => Z(o));
2258
- if (r.wrap = t.wrap, r.border = t.border, t.width.length === 0)
2259
- r.width = -1;
2260
- else if ("text" in r)
2261
- r.width = a < t.width.length ? t.width[a] ?? 0 : 0;
2253
+ if (s.wrap = t.wrap, s.border = t.border, t.width.length === 0)
2254
+ s.width = -1;
2255
+ else if ("text" in s)
2256
+ s.width = a < t.width.length ? t.width[a] ?? 0 : 0;
2262
2257
  else if (t.width.find((o) => o < 0))
2263
- r.width = -1;
2258
+ s.width = -1;
2264
2259
  else {
2265
2260
  const o = t.width.filter((c) => c > 0);
2266
- r.width = o.length > 0 ? o.reduce((c, l) => c + l, r.border < 0 ? o.length + 1 : (o.length - 1) * r.border) : 0;
2261
+ s.width = o.length > 0 ? o.reduce((c, l) => c + l, s.border < 0 ? o.length + 1 : (o.length - 1) * s.border) : 0;
2267
2262
  }
2268
- return r.alignment = t.align, r;
2263
+ return s.alignment = t.align, s;
2269
2264
  });
2270
2265
  if (e.every((i) => "text" in i) && t.width.length > 0)
2271
2266
  for (; e.length < t.width.length; )
@@ -2277,7 +2272,7 @@ function Z(n) {
2277
2272
  }
2278
2273
  function Gt(n, t) {
2279
2274
  const e = [];
2280
- let i = n.width, a = 1, s = [], r = !1, h = !1, o = !1, c = 0;
2275
+ let i = n.width, a = 1, r = [], s = !1, h = !1, o = !1, c = 0;
2281
2276
  return n.text.forEach((l, u) => {
2282
2277
  if (u % 2 === 0) {
2283
2278
  let d = t.target.arrayFrom(l, t.encoding);
@@ -2285,20 +2280,20 @@ function Gt(n, t) {
2285
2280
  let g = 0, p = 0;
2286
2281
  for (; p < d.length && (g = t.target.measureText(d[p] ?? "", t.encoding) * (c < 2 ? c + 1 : c - 1), !(g > i)); )
2287
2282
  i -= g, g = 0, p++;
2288
- if (p > 0 && (s.push((r ? "1" : "0") + (h ? "1" : "0") + (o ? "1" : "0") + c), s.push(d.slice(0, p).join("")), a = Math.max(a, c < 3 ? c : c - 1), d = d.slice(p)), g > n.width) {
2283
+ if (p > 0 && (r.push((s ? "1" : "0") + (h ? "1" : "0") + (o ? "1" : "0") + c), r.push(d.slice(0, p).join("")), a = Math.max(a, c < 3 ? c : c - 1), d = d.slice(p)), g > n.width) {
2289
2284
  d = d.slice(1);
2290
2285
  continue;
2291
2286
  }
2292
- (g > i || i === 0) && (e.push({ data: s, margin: i * n.align / 2, height: a }), i = n.width, s = [], a = 1);
2287
+ (g > i || i === 0) && (e.push({ data: r, margin: i * n.align / 2, height: a }), i = n.width, r = [], a = 1);
2293
2288
  }
2294
2289
  } else
2295
2290
  switch (l) {
2296
2291
  case `
2297
2292
  `:
2298
- e.push({ data: s, margin: i * n.align / 2, height: a }), i = n.width, s = [], a = 1;
2293
+ e.push({ data: r, margin: i * n.align / 2, height: a }), i = n.width, r = [], a = 1;
2299
2294
  break;
2300
2295
  case "_":
2301
- r = !r;
2296
+ s = !s;
2302
2297
  break;
2303
2298
  case '"':
2304
2299
  h = !h;
@@ -2311,24 +2306,24 @@ function Gt(n, t) {
2311
2306
  c = c === d ? 0 : d;
2312
2307
  break;
2313
2308
  }
2314
- }), s.length > 0 && e.push({ data: s, margin: i * n.align / 2, height: a }), e;
2309
+ }), r.length > 0 && e.push({ data: r, margin: i * n.align / 2, height: a }), e;
2315
2310
  }
2316
2311
  async function Kt(n, t, e) {
2317
- const i = [], a = n.every((f) => "text" in f), s = n[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2318
- let r = n.filter((f) => f.width !== 0);
2319
- a && (r = r.slice(0, Math.floor(s.border < 0 ? (t.target.cpl - 1) / 2 : (t.target.cpl + s.border) / (s.border + 1))));
2320
- const h = r.filter((f) => f.width > 0), o = r.filter((f) => f.width < 0);
2312
+ const i = [], a = n.every((f) => "text" in f), r = n[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2313
+ let s = n.filter((f) => f.width !== 0);
2314
+ a && (s = s.slice(0, Math.floor(r.border < 0 ? (t.target.cpl - 1) / 2 : (t.target.cpl + r.border) / (r.border + 1))));
2315
+ const h = s.filter((f) => f.width > 0), o = s.filter((f) => f.width < 0);
2321
2316
  let c = h.reduce((f, $) => f + $.width, 0), l = t.target.cpl - c;
2322
- a && r.length > 0 && (l -= s.border < 0 ? r.length + 1 : (r.length - 1) * s.border);
2317
+ a && s.length > 0 && (l -= r.border < 0 ? s.length + 1 : (s.length - 1) * r.border);
2323
2318
  const u = o.length;
2324
2319
  for (; u > l; ) {
2325
2320
  const f = h.reduce(($, k) => $.width > k.width ? $ : k);
2326
2321
  f.width--, l++;
2327
2322
  }
2328
2323
  u > 0 && (o.forEach((f, $) => f.width = Math.floor((l + $) / u)), l = 0);
2329
- const d = Math.floor(l * s.alignment / 2), g = t.target.cpl - l, p = l - d;
2324
+ const d = Math.floor(l * r.alignment / 2), g = t.target.cpl - l, p = l - d;
2330
2325
  if (a) {
2331
- const f = r.map((w) => Gt(w, t)), $ = r.map((w) => w.width);
2326
+ const f = s.map((w) => Gt(w, t)), $ = s.map((w) => w.width);
2332
2327
  switch (e.line) {
2333
2328
  case "ready":
2334
2329
  i.push(
@@ -2336,40 +2331,40 @@ async function Kt(n, t, e) {
2336
2331
  ), e.line = "running";
2337
2332
  break;
2338
2333
  case "horizontal":
2339
- const w = d - e.rules.left, m = g - e.rules.width, A = Math.min(d, e.rules.left), v = Math.min(p, e.rules.right);
2334
+ const w = d - e.rules.left, m = g - e.rules.width, W = Math.min(d, e.rules.left), v = Math.min(p, e.rules.right);
2340
2335
  i.push(
2341
- await t.target.normal() + await t.target.area(A, t.target.cpl - A - v, v) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
2336
+ await t.target.normal() + await t.target.area(W, t.target.cpl - W - v, v) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
2342
2337
  ), e.line = "running";
2343
2338
  break;
2344
2339
  }
2345
2340
  e.rules = { left: d, width: g, right: p, widths: $ };
2346
- const k = s.wrap ? f.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2341
+ const k = r.wrap ? f.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2347
2342
  for (let w = 0; w < k; w++) {
2348
- let m = await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0), A = 0;
2343
+ let m = await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0), W = 0;
2349
2344
  if (e.line === "running") {
2350
- const v = f.reduce((W, x) => w < x.length ? Math.max(W, x[w]?.height ?? 1) : W, 1);
2351
- m += await t.target.normal() + await t.target.absolute(A++) + await t.target.vr($, v);
2345
+ const v = f.reduce((A, x) => w < x.length ? Math.max(A, x[w]?.height ?? 1) : A, 1);
2346
+ m += await t.target.normal() + await t.target.absolute(W++) + await t.target.vr($, v);
2352
2347
  }
2353
2348
  for (let v = 0; v < f.length; v++) {
2354
- const W = f[v];
2355
- if (W) {
2356
- if (m += await t.target.absolute(A), w < W.length) {
2357
- m += await t.target.relative(W[w]?.margin ?? 0);
2358
- const x = W[w]?.data ?? [];
2349
+ const A = f[v];
2350
+ if (A) {
2351
+ if (m += await t.target.absolute(W), w < A.length) {
2352
+ m += await t.target.relative(A[w]?.margin ?? 0);
2353
+ const x = A[w]?.data ?? [];
2359
2354
  for (let S = 0; S < x.length; S += 2) {
2360
2355
  const D = Number(String(x[S])[0]), et = Number(String(x[S])[1]), nt = Number(String(x[S])[2]), B = Number(String(x[S])[3]);
2361
2356
  m += await t.target.normal(), D && (m += await t.target.ul()), et && (m += await t.target.em()), nt && (m += await t.target.iv()), B && (m += await t.target.wh(B)), m += await t.target.text(String(x[S + 1]), t.encoding);
2362
2357
  }
2363
2358
  } else
2364
2359
  m += await t.target.normal() + await t.target.text(" ", t.encoding);
2365
- A += (r[v]?.width ?? 0) + Math.abs(s.border);
2360
+ W += (s[v]?.width ?? 0) + Math.abs(r.border);
2366
2361
  }
2367
2362
  }
2368
2363
  m += await t.target.lf(), i.push(m);
2369
2364
  }
2370
2365
  }
2371
- if ("hr" in s)
2372
- if (s.hr === "=")
2366
+ if ("hr" in r)
2367
+ if (r.hr === "=")
2373
2368
  switch (e.line) {
2374
2369
  case "running":
2375
2370
  case "horizontal":
@@ -2392,8 +2387,8 @@ async function Kt(n, t, e) {
2392
2387
  e.line = "horizontal";
2393
2388
  break;
2394
2389
  }
2395
- if ("vr" in s)
2396
- if (s.vr === "+")
2390
+ if ("vr" in r)
2391
+ if (r.vr === "+")
2397
2392
  e.line = "ready";
2398
2393
  else
2399
2394
  switch (e.line) {
@@ -2407,14 +2402,14 @@ async function Kt(n, t, e) {
2407
2402
  ), e.line = "waiting";
2408
2403
  break;
2409
2404
  }
2410
- return "image" in s && s.image && i.push(
2411
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.image(s.image)
2412
- ), "code" in s && s.code && (s.code.type === "qrcode" ? i.push(
2413
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.qrcode(s.code, t.encoding)
2405
+ return "image" in r && r.image && i.push(
2406
+ await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.image(r.image)
2407
+ ), "code" in r && r.code && (r.code.type === "qrcode" ? i.push(
2408
+ await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.qrcode(r.code, t.encoding)
2414
2409
  ) : i.push(
2415
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.barcode(s.code, t.encoding)
2416
- )), "command" in s && s.command && i.push(
2417
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.command(s.command)
2410
+ await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.barcode(r.code, t.encoding)
2411
+ )), "command" in r && r.command && i.push(
2412
+ await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.command(r.command)
2418
2413
  ), i.join("");
2419
2414
  }
2420
2415
  async function Yt(n, t) {
@@ -2432,23 +2427,23 @@ async function Yt(n, t) {
2432
2427
  };
2433
2428
  let a = await e.target.open(e);
2434
2429
  n[0] === "\uFEFF" && (n = n.slice(1));
2435
- const s = n.normalize().split(/\n|\r\n|\r/), r = [];
2436
- for (const h of s)
2437
- r.push(await Kt(_t(h, i), e, i));
2430
+ const r = n.normalize().split(/\n|\r\n|\r/), s = [];
2431
+ for (const h of r)
2432
+ s.push(await Kt(_t(h, i), e, i));
2438
2433
  switch (i.line) {
2439
2434
  case "ready":
2440
2435
  i.line = "waiting";
2441
2436
  break;
2442
2437
  case "running":
2443
2438
  case "horizontal":
2444
- r.push(
2439
+ s.push(
2445
2440
  await e.target.normal() + await e.target.area(i.rules.left, i.rules.width, i.rules.right) + await e.target.align(0) + await e.target.vrstop(i.rules.widths) + await e.target.vrlf(!1)
2446
2441
  ), i.line = "waiting";
2447
2442
  break;
2448
2443
  default:
2449
2444
  break;
2450
2445
  }
2451
- return a += r.join(""), a += await e.target.close(), {
2446
+ return a += s.join(""), a += await e.target.close(), {
2452
2447
  content: a,
2453
2448
  width: e.target.calculatedWidth(),
2454
2449
  height: Math.round(e.target.calculatedHeight())