@liquid-js/qr-code-styling 4.0.7 → 4.1.0

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.
@@ -2,7 +2,7 @@ import { QRUtil } from "@liquid-js/qrcode-generator/lib/qrcode/QRUtil.js";
2
2
 
3
3
  import { stringToBytes_UTF8 } from "@liquid-js/qrcode-generator/lib/text/stringToBytes_UTF8.js";
4
4
 
5
- import { TypeNumber, ErrorCorrectionLevel, Mode, QRCodeMinimal } from "@liquid-js/qrcode-generator/lib/qrcode/QRCodeMinimal.js";
5
+ import { ErrorCorrectionLevel, TypeNumber, Mode, QRCodeMinimal } from "@liquid-js/qrcode-generator/lib/qrcode/QRCodeMinimal.js";
6
6
 
7
7
  import sharp from "sharp";
8
8
 
@@ -19,12 +19,12 @@ function mergeDeep(target, ...sources) {
19
19
  let source = sources.shift();
20
20
  return void 0 !== source && isObject(target) && isObject(source) ? (target = {
21
21
  ...target
22
- }, Object.keys(source).forEach((key => {
22
+ }, Object.keys(source).forEach(key => {
23
23
  let targetValue = target[key], sourceValue = source[key];
24
24
  Array.isArray(targetValue) && Array.isArray(sourceValue) ? target[key] = sourceValue : isObject(targetValue) && isObject(sourceValue) ? target[key] = mergeDeep({
25
25
  ...targetValue
26
26
  }, sourceValue) : target[key] = sourceValue;
27
- })), mergeDeep(target, ...sources)) : target;
27
+ }), mergeDeep(target, ...sources)) : target;
28
28
  }
29
29
 
30
30
  var GradientType, DotType, CornerDotType, CornerSquareType, ShapeType, ImageMode;
@@ -34,25 +34,25 @@ function sanitizeGradient(gradient_newGradient) {
34
34
  ...gradient_newGradient
35
35
  }).colorStops || !gradient_newGradient.colorStops.length) throw Error("Field 'colorStops' is required in gradient");
36
36
  return gradient_newGradient.rotation = gradient_newGradient.rotation ? Number(gradient_newGradient.rotation) : 0,
37
- gradient_newGradient.colorStops = gradient_newGradient.colorStops.map((colorStop => ({
37
+ gradient_newGradient.colorStops = gradient_newGradient.colorStops.map(colorStop => ({
38
38
  ...colorStop,
39
39
  offset: Number(colorStop.offset)
40
- }))), gradient_newGradient;
40
+ })), gradient_newGradient;
41
41
  }
42
42
 
43
- (GradientType = GradientType || (GradientType = {})).radial = "radial", GradientType.linear = "linear",
44
- (DotType = DotType || (DotType = {})).dot = "dot", DotType.randomDot = "random-dot",
45
- DotType.rounded = "rounded", DotType.extraRounded = "extra-rounded", DotType.verticalLine = "vertical-line",
43
+ (GradientType = GradientType ||= {}).radial = "radial", GradientType.linear = "linear",
44
+ (DotType = DotType ||= {}).dot = "dot", DotType.randomDot = "random-dot", DotType.rounded = "rounded",
45
+ DotType.extraRounded = "extra-rounded", DotType.verticalLine = "vertical-line",
46
46
  DotType.horizontalLine = "horizontal-line", DotType.classy = "classy", DotType.classyRounded = "classy-rounded",
47
47
  DotType.square = "square", DotType.smallSquare = "small-square", DotType.tinySquare = "tiny-square",
48
- DotType.diamond = "diamond", (CornerDotType = CornerDotType || (CornerDotType = {})).dot = "dot",
48
+ DotType.diamond = "diamond", DotType.wave = "wave", (CornerDotType = CornerDotType ||= {}).dot = "dot",
49
49
  CornerDotType.square = "square", CornerDotType.heart = "heart", CornerDotType.extraRounded = "extra-rounded",
50
50
  CornerDotType.classy = "classy", CornerDotType.outpoint = "outpoint", CornerDotType.inpoint = "inpoint",
51
- (CornerSquareType = CornerSquareType || (CornerSquareType = {})).dot = "dot", CornerSquareType.square = "square",
51
+ (CornerSquareType = CornerSquareType ||= {}).dot = "dot", CornerSquareType.square = "square",
52
52
  CornerSquareType.extraRounded = "extra-rounded", CornerSquareType.classy = "classy",
53
- CornerSquareType.outpoint = "outpoint", CornerSquareType.inpoint = "inpoint", (ShapeType = ShapeType || (ShapeType = {})).square = "square",
54
- ShapeType.circle = "circle", (ImageMode = ImageMode || (ImageMode = {})).center = "center",
55
- ImageMode.overlay = "overlay", ImageMode.background = "background";
53
+ CornerSquareType.outpoint = "outpoint", CornerSquareType.inpoint = "inpoint", (ShapeType = ShapeType ||= {}).square = "square",
54
+ ShapeType.circle = "circle", (ImageMode = ImageMode ||= {}).center = "center", ImageMode.overlay = "overlay",
55
+ ImageMode.background = "background";
56
56
 
57
57
  let defaultOptions = {
58
58
  document: void 0,
@@ -123,13 +123,16 @@ function numToAttr(value) {
123
123
  }
124
124
 
125
125
  function svgPath(strings, ...values) {
126
- return strings.reduce(((t, v, i) => {
126
+ return strings.reduce((t, v, i) => {
127
127
  let p = "";
128
128
  return i && (p = values[i - 1]), "number" == typeof p && (p = numToAttr(p)), `${t}${p}${v}`;
129
- }), "").trim().replace(/[\s\n\r]+/gim, " ");
129
+ }, "").trim().replace(/[\s\n\r]+/gim, " ");
130
130
  }
131
131
 
132
132
  class QRCornerDot {
133
+ type;
134
+ document;
135
+ _element;
133
136
  get element() {
134
137
  return this._element;
135
138
  }
@@ -197,9 +200,9 @@ class QRCornerDot {
197
200
  let {size, x, y} = args;
198
201
  this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path");
199
202
  let move = !1, i = 0;
200
- this._element.setAttribute("d", [ "M", 1, .3262506, "c", 0, .0383376, -.0064626, .0758377, -.0193751, .1125001, "s", -.0356247, .076875, -.0681248, .1206252, "c", -.0325, .0437499, -.0762503, .0931247, -.1312501, .1481249, "C", .7262502, .7625008, .6566626, .8279132, .5724999, .9037505, "L", .5, .9687506, "L", .4275001, .9037505, "C", .3433374, .8279132, .2737499, .7625005, .21875, .7075007, "C", .1637501, .6525008, .1199999, .6031258, .0874999, .5593758, "S", .0322876, .4754133, .0193751, .4387506, "S", 0, .3645881, 0, .3262506, "c", 0, -.0783374, .0262499, -.1437498, .07875, -.1962499, "s", .1179124, -.07875, .1962499, -.07875, "c", .0433376, 0, .0845875, .0091625, .12375, .0274999, "S", .4716623, .1229131, .5, .1562506, "c", .0283374, -.0333375, .0620874, -.0591625, .1012502, -.0775, "c", .0391627, -.0183375, .0804126, -.0274999, .12375, -.0274999, "c", .0783374, 0, .1437497, .0262499, .1962501, .07875, "S", 1, .2479131, 1, .3262506, "z" ].map((v => "string" == typeof v ? (i = 0,
201
- move = v.toUpperCase() == v, v) : (i++, v *= size, move && (v += 1 == i % 2 ? x : y),
202
- numToAttr(v)))).join(" "));
203
+ this._element.setAttribute("d", [ "M", 1, .3262506, "c", 0, .0383376, -.0064626, .0758377, -.0193751, .1125001, "s", -.0356247, .076875, -.0681248, .1206252, "c", -.0325, .0437499, -.0762503, .0931247, -.1312501, .1481249, "C", .7262502, .7625008, .6566626, .8279132, .5724999, .9037505, "L", .5, .9687506, "L", .4275001, .9037505, "C", .3433374, .8279132, .2737499, .7625005, .21875, .7075007, "C", .1637501, .6525008, .1199999, .6031258, .0874999, .5593758, "S", .0322876, .4754133, .0193751, .4387506, "S", 0, .3645881, 0, .3262506, "c", 0, -.0783374, .0262499, -.1437498, .07875, -.1962499, "s", .1179124, -.07875, .1962499, -.07875, "c", .0433376, 0, .0845875, .0091625, .12375, .0274999, "S", .4716623, .1229131, .5, .1562506, "c", .0283374, -.0333375, .0620874, -.0591625, .1012502, -.0775, "c", .0391627, -.0183375, .0804126, -.0274999, .12375, -.0274999, "c", .0783374, 0, .1437497, .0262499, .1962501, .07875, "S", 1, .2479131, 1, .3262506, "z" ].map(v => "string" == typeof v ? (i = 0,
204
+ move = v.toUpperCase() == v, v) : (i++, v *= size, move && (v += i % 2 == 1 ? x : y),
205
+ numToAttr(v))).join(" "));
203
206
  }
204
207
  basicRounded(args) {
205
208
  let {size, x, y} = args;
@@ -292,6 +295,10 @@ class QRCornerDot {
292
295
  }
293
296
 
294
297
  class QRCornerSquare {
298
+ type;
299
+ document;
300
+ _element;
301
+ _fill;
295
302
  get element() {
296
303
  return this._element;
297
304
  }
@@ -444,6 +451,9 @@ class QRCornerSquare {
444
451
  }
445
452
 
446
453
  class QRDot {
454
+ type;
455
+ document;
456
+ _element;
447
457
  get element() {
448
458
  return this._element;
449
459
  }
@@ -497,6 +507,10 @@ class QRDot {
497
507
  drawFunction = this.drawTinySquare;
498
508
  break;
499
509
 
510
+ case DotType.wave:
511
+ drawFunction = this.drawWave;
512
+ break;
513
+
500
514
  default:
501
515
  drawFunction = this.drawSquare;
502
516
  }
@@ -567,6 +581,16 @@ class QRDot {
567
581
  }
568
582
  });
569
583
  }
584
+ basicWave(args) {
585
+ let {size, x, y} = args, a1 = 5 * Math.PI / 180, a2 = 65 * Math.PI / 180, c23x = size * (.95 - .65 * Math.cos(a1)), c23y = size * (1 - .65 * Math.sin(a1)), c31x = -size * Math.cos(a2) / 2, c31y = -size * Math.sin(a2) / 2;
586
+ this.rotateFigure({
587
+ ...args,
588
+ draw: () => {
589
+ this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "path"),
590
+ this._element.setAttribute("d", svgPath`M ${x} ${y} c 0 ${.65 * size} ${c23x} ${c23y} ${.95 * size} ${size} c ${c31x} ${c31y} ${size * (1 - .95)} ${-size / 2} ${size * (1 - .95)} ${-size} z`);
591
+ }
592
+ });
593
+ }
570
594
  drawDot({x, y, size}) {
571
595
  this.basicDot({
572
596
  x,
@@ -626,7 +650,7 @@ class QRDot {
626
650
  y,
627
651
  size,
628
652
  rotation: 0
629
- }) : 2 < neighborsCount_rotation || leftNeighbor_rotation && rightNeighbor || topNeighbor && bottomNeighbor_getNeighbor ? this.basicSquare({
653
+ }) : neighborsCount_rotation > 2 || leftNeighbor_rotation && rightNeighbor || topNeighbor && bottomNeighbor_getNeighbor ? this.basicSquare({
630
654
  x,
631
655
  y,
632
656
  size,
@@ -647,7 +671,7 @@ class QRDot {
647
671
  }
648
672
  drawVerticalLine({x, y, size, getNeighbor: bottomNeighbor}) {
649
673
  let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
650
- 0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) || leftNeighbor && !topNeighbor && !bottomNeighbor || rightNeighbor && !topNeighbor && !bottomNeighbor ? this.basicDot({
674
+ leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) === 0 || leftNeighbor && !topNeighbor && !bottomNeighbor || rightNeighbor && !topNeighbor && !bottomNeighbor ? this.basicDot({
651
675
  x,
652
676
  y,
653
677
  size,
@@ -671,7 +695,7 @@ class QRDot {
671
695
  }
672
696
  drawHorizontalLine({x, y, size, getNeighbor: bottomNeighbor}) {
673
697
  let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
674
- 0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) || topNeighbor && !leftNeighbor && !rightNeighbor || bottomNeighbor && !leftNeighbor && !rightNeighbor ? this.basicDot({
698
+ leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) === 0 || topNeighbor && !leftNeighbor && !rightNeighbor || bottomNeighbor && !leftNeighbor && !rightNeighbor ? this.basicDot({
675
699
  x,
676
700
  y,
677
701
  size,
@@ -702,7 +726,7 @@ class QRDot {
702
726
  y,
703
727
  size,
704
728
  rotation: 0
705
- }) : 2 < neighborsCount || leftNeighbor && rightNeighbor || topNeighbor && bottomNeighbor ? this.basicSquare({
729
+ }) : neighborsCount > 2 || leftNeighbor && rightNeighbor || topNeighbor && bottomNeighbor ? this.basicSquare({
706
730
  x,
707
731
  y,
708
732
  size,
@@ -723,7 +747,7 @@ class QRDot {
723
747
  }
724
748
  drawClassy({x, y, size, getNeighbor: bottomNeighbor}) {
725
749
  let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
726
- 0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) ? this.basicCornersRounded({
750
+ leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) === 0 ? this.basicCornersRounded({
727
751
  x,
728
752
  y,
729
753
  size,
@@ -747,7 +771,7 @@ class QRDot {
747
771
  }
748
772
  drawClassyRounded({x, y, size, getNeighbor: bottomNeighbor}) {
749
773
  let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0, topNeighbor = bottomNeighbor ? +bottomNeighbor(0, -1) : 0;
750
- 0 === leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) ? this.basicCornersRounded({
774
+ leftNeighbor + rightNeighbor + topNeighbor + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0) === 0 ? this.basicCornersRounded({
751
775
  x,
752
776
  y,
753
777
  size,
@@ -769,10 +793,37 @@ class QRDot {
769
793
  rotation: -Math.PI / 2
770
794
  });
771
795
  }
796
+ drawWave({x, y, size, getNeighbor: bottomNeighbor}) {
797
+ let leftNeighbor = bottomNeighbor ? +bottomNeighbor(-1, 0) : 0, rightNeighbor = bottomNeighbor ? +bottomNeighbor(1, 0) : 0;
798
+ var rotation = bottomNeighbor ? +bottomNeighbor(0, -1) : 0, neighborsCount = leftNeighbor + rightNeighbor + rotation + (bottomNeighbor = bottomNeighbor ? +bottomNeighbor(0, 1) : 0);
799
+ 0 === neighborsCount ? this.basicDot({
800
+ x,
801
+ y,
802
+ size,
803
+ rotation: 0
804
+ }) : neighborsCount > 2 || leftNeighbor && rightNeighbor || rotation && bottomNeighbor ? this.basicSquare({
805
+ x,
806
+ y,
807
+ size,
808
+ rotation: 0
809
+ }) : 2 === neighborsCount ? (neighborsCount = 0, leftNeighbor && rotation ? neighborsCount = Math.PI / 2 : rotation && rightNeighbor ? neighborsCount = Math.PI : rightNeighbor && bottomNeighbor && (neighborsCount = -Math.PI / 2),
810
+ this.basicCornerExtraRounded({
811
+ x,
812
+ y,
813
+ size,
814
+ rotation: neighborsCount
815
+ })) : 1 === neighborsCount && (rotation = 0, rightNeighbor ? rotation = Math.PI / 2 : bottomNeighbor ? rotation = Math.PI : leftNeighbor && (rotation = -Math.PI / 2),
816
+ this.basicWave({
817
+ x,
818
+ y,
819
+ size,
820
+ rotation
821
+ }));
822
+ }
772
823
  }
773
824
 
774
825
  let browserImageTools = {
775
- toDataURL: url => "string" == typeof url && url.startsWith("data:") ? Promise.resolve(url) : new Promise(((resolve, reject) => {
826
+ toDataURL: url => "string" == typeof url && url.startsWith("data:") ? Promise.resolve(url) : new Promise((resolve, reject) => {
776
827
  if ("string" == typeof url) {
777
828
  const xhr = new XMLHttpRequest;
778
829
  xhr.onload = () => {
@@ -788,16 +839,16 @@ let browserImageTools = {
788
839
  resolve(reader.result);
789
840
  }, reader.readAsDataURL(url);
790
841
  }
791
- })),
792
- getSize: (src, crossOrigin) => new Promise(((resolve, reject) => {
842
+ }),
843
+ getSize: (src, crossOrigin) => new Promise((resolve, reject) => {
793
844
  const image = new Image;
794
845
  "string" === crossOrigin && (image.crossOrigin = crossOrigin), image.onload = () => {
795
846
  resolve({
796
847
  width: image.width,
797
848
  height: image.height
798
849
  });
799
- }, image.onerror = image.onabort = reject, "string" == typeof src ? image.src = src : browserImageTools.toDataURL(src).then((url => image.src = url)).catch(reject);
800
- }))
850
+ }, image.onerror = image.onabort = reject, "string" == typeof src ? image.src = src : browserImageTools.toDataURL(src).then(url => image.src = url).catch(reject);
851
+ })
801
852
  };
802
853
 
803
854
  function parseColor(base) {
@@ -805,7 +856,7 @@ function parseColor(base) {
805
856
  let alpha = 1;
806
857
  if ("#" === (base = base.toLowerCase())[0]) {
807
858
  let size = (base = base.slice(1)).length;
808
- 4 >= size ? (m_parts = [ parseInt(base[0] + base[0], 16), parseInt(base[1] + base[1], 16), parseInt(base[2] + base[2], 16) ],
859
+ size <= 4 ? (m_parts = [ parseInt(base[0] + base[0], 16), parseInt(base[1] + base[1], 16), parseInt(base[2] + base[2], 16) ],
809
860
  4 === size && (alpha = parseInt(base[3] + base[3], 16) / 255)) : (m_parts = [ parseInt(base[0] + base[1], 16), parseInt(base[2] + base[3], 16), parseInt(base[4] + base[5], 16) ],
810
861
  8 === size && (alpha = parseInt(base[6] + base[7], 16) / 255)), m_parts[0] || (m_parts[0] = 0),
811
862
  m_parts[1] || (m_parts[1] = 0), m_parts[2] || (m_parts[2] = 0);
@@ -814,21 +865,35 @@ function parseColor(base) {
814
865
  value: base,
815
866
  alpha
816
867
  };
817
- alpha = 3 < (m_parts = (m_parts = m_parts[2].trim().split(/\s*[,/]\s*|\s+/)).map(((v, i) => "%" === v[v.length - 1] ? (v = parseFloat(v) / 100,
818
- 3 === i ? v : 255 * v) : "none" === v ? 0 : parseFloat(v)))).length ? m_parts.pop() : 1;
868
+ alpha = (m_parts = (m_parts = m_parts[2].trim().split(/\s*[,/]\s*|\s+/)).map((v, i) => "%" === v[v.length - 1] ? (v = parseFloat(v) / 100,
869
+ 3 === i ? v : 255 * v) : "none" === v ? 0 : parseFloat(v))).length > 3 ? m_parts.pop() : 1;
819
870
  }
820
871
  return {
821
- value: "#" + m_parts.map((v => Math.max(0, Math.min(255, v)).toString(16).padStart(2, "0"))).join(""),
872
+ value: "#" + m_parts.map(v => Math.max(0, Math.min(255, v)).toString(16).padStart(2, "0")).join(""),
822
873
  alpha: Math.max(0, Math.min(1, alpha))
823
874
  };
824
875
  }
825
876
 
826
- let squareMask = [ [ 1, 1, 1, 1, 1, 1, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 1, 1, 1, 1, 1, 1 ] ], dotMask = [ [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ] ];
877
+ let squareMask = [ [ 1, 1, 1, 1, 1, 1, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 0, 0, 0, 0, 0, 1 ], [ 1, 1, 1, 1, 1, 1, 1 ] ], cornerSquareTypes = new Set(Object.values(CornerSquareType));
878
+
879
+ let dotMask = [ [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 1, 1, 1, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ], [ 0, 0, 0, 0, 0, 0, 0 ] ], cornerDotTypes = new Set(Object.values(CornerDotType));
827
880
 
828
881
  class QRSVG {
882
+ options;
883
+ _element;
829
884
  get element() {
830
885
  return this._element;
831
886
  }
887
+ defs;
888
+ backgroundMask;
889
+ backgroundMaskGroup;
890
+ dotsMask;
891
+ dotsMaskGroup;
892
+ lightDotsMask;
893
+ lightDotsMaskGroup;
894
+ qr;
895
+ document;
896
+ imageTools;
832
897
  constructor(options) {
833
898
  this.options = options, this.document = options.document, this._element = this.document.createElementNS("http://www.w3.org/2000/svg", "svg");
834
899
  let width = numToAttr(options.width), height = numToAttr(options.height);
@@ -869,28 +934,28 @@ class QRSVG {
869
934
  };
870
935
  } else coverLevel_margin = imageOptions.imageSize * errorCorrectionPercent, alignment_maxWidth_typeNumber = QRUtil.getPatternPosition(alignment_maxWidth_typeNumber),
871
936
  drawImageSize = function({originalHeight, originalWidth, maxHiddenDots: JSCompiler_object_inline_x_16_hideMax_maxHiddenDots, maxHiddenAxisDots: JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper, dotSize, margin}) {
872
- if (0 >= originalHeight || 0 >= originalWidth || 0 >= JSCompiler_object_inline_x_16_hideMax_maxHiddenDots || 0 >= dotSize || 4 * margin ** 2 > JSCompiler_object_inline_x_16_hideMax_maxHiddenDots) return {
937
+ if (originalHeight <= 0 || originalWidth <= 0 || JSCompiler_object_inline_x_16_hideMax_maxHiddenDots <= 0 || dotSize <= 0 || 4 * margin ** 2 > JSCompiler_object_inline_x_16_hideMax_maxHiddenDots) return {
873
938
  height: 0,
874
939
  width: 0,
875
940
  hideYDots: 0,
876
941
  hideXDots: 0
877
942
  };
878
- JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper && 0 == JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper % 2 && (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = Math.max(1, JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper - 1));
879
- var JSCompiler_object_inline_x_14_dimMax = Math.max(originalWidth, originalHeight), JSCompiler_object_inline_y_15_dimMin_hideMin = Math.min(originalWidth, originalHeight), lower_maxH_size = 0;
943
+ JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper && JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper % 2 == 0 && (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = Math.max(1, JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper - 1));
944
+ var JSCompiler_object_inline_x_14_dimMax = Math.max(originalWidth, originalHeight), JSCompiler_object_inline_y_15_dimMin_hideMin = Math.min(originalWidth, originalHeight), lower = 0;
880
945
  JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper || JSCompiler_object_inline_x_16_hideMax_maxHiddenDots) - 2 * margin;
881
946
  do {
882
- let newSize = lower_maxH_size + (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper - lower_maxH_size) / 2, dotsMax = Math.max(1, Math.ceil(newSize + 2 * margin));
883
- 0 == dotsMax % 2 && dotsMax++;
947
+ let newSize = lower + (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper - lower) / 2, dotsMax = Math.max(1, Math.ceil(newSize + 2 * margin));
948
+ dotsMax % 2 == 0 && dotsMax++;
884
949
  let dotsMin = Math.max(1, Math.ceil(newSize * JSCompiler_object_inline_y_15_dimMin_hideMin / JSCompiler_object_inline_x_14_dimMax + 2 * margin));
885
- 0 == dotsMin % 2 && dotsMin++, dotsMax * dotsMin > JSCompiler_object_inline_x_16_hideMax_maxHiddenDots ? JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = newSize : lower_maxH_size = newSize;
886
- } while (.001 < Math.abs(lower_maxH_size - JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper));
887
- return 0 == (JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = Math.max(1, Math.ceil(lower_maxH_size + 2 * margin))) % 2 && JSCompiler_object_inline_x_16_hideMax_maxHiddenDots++,
888
- 0 == (JSCompiler_object_inline_y_15_dimMin_hideMin = Math.max(1, Math.ceil(lower_maxH_size * JSCompiler_object_inline_y_15_dimMin_hideMin / JSCompiler_object_inline_x_14_dimMax + 2 * margin))) % 2 && JSCompiler_object_inline_y_15_dimMin_hideMin++,
950
+ dotsMin % 2 == 0 && dotsMin++, dotsMax * dotsMin > JSCompiler_object_inline_x_16_hideMax_maxHiddenDots ? JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = newSize : lower = newSize;
951
+ } while (Math.abs(lower - JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper) > .001);
952
+ return (JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = Math.max(1, Math.ceil(lower + 2 * margin))) % 2 == 0 && JSCompiler_object_inline_x_16_hideMax_maxHiddenDots++,
953
+ (JSCompiler_object_inline_y_15_dimMin_hideMin = Math.max(1, Math.ceil(lower * JSCompiler_object_inline_y_15_dimMin_hideMin / JSCompiler_object_inline_x_14_dimMax + 2 * margin))) % 2 == 0 && JSCompiler_object_inline_y_15_dimMin_hideMin++,
889
954
  originalWidth > originalHeight ? JSCompiler_object_inline_x_14_dimMax = JSCompiler_object_inline_x_16_hideMax_maxHiddenDots : (JSCompiler_object_inline_x_14_dimMax = JSCompiler_object_inline_y_15_dimMin_hideMin,
890
955
  JSCompiler_object_inline_y_15_dimMin_hideMin = JSCompiler_object_inline_x_16_hideMax_maxHiddenDots),
891
956
  JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = (JSCompiler_object_inline_x_14_dimMax - 2 * margin) * dotSize,
892
- (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper * originalHeight / originalWidth) > (lower_maxH_size = (JSCompiler_object_inline_y_15_dimMin_hideMin - 2 * margin) * dotSize) && (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = lower_maxH_size,
893
- JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = lower_maxH_size * originalWidth / originalHeight),
957
+ (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper * originalHeight / originalWidth) > (lower = (JSCompiler_object_inline_y_15_dimMin_hideMin - 2 * margin) * dotSize) && (JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper = lower,
958
+ JSCompiler_object_inline_x_16_hideMax_maxHiddenDots = lower * originalWidth / originalHeight),
894
959
  {
895
960
  height: Math.round(JSCompiler_object_inline_y_17_maxHiddenAxisDots_maxW_upper + 2 * margin * dotSize),
896
961
  width: Math.round(JSCompiler_object_inline_x_16_hideMax_maxHiddenDots + 2 * margin * dotSize),
@@ -900,19 +965,19 @@ class QRSVG {
900
965
  }({
901
966
  originalWidth: qr_size.width,
902
967
  originalHeight: qr_size.height,
903
- maxHiddenDots: Math.floor(coverLevel_margin * (count * count - 192 - 2 * (count - 16) - 25 * alignment_maxWidth_typeNumber.length ** 2)),
968
+ maxHiddenDots: Math.floor(coverLevel_margin * (count * count - 192 - 2 * (count - 16) - alignment_maxWidth_typeNumber.length ** 2 * 25)),
904
969
  maxHiddenAxisDots: count - 14,
905
970
  dotSize,
906
971
  margin: imageOptions.margin
907
972
  });
908
973
  }
909
- this.drawBackground(), this.options.imageOptions.mode != ImageMode.overlay && this.options.image && 0 < drawImageSize.width && 0 < drawImageSize.height && await this.drawImage({
974
+ this.drawBackground(), this.options.imageOptions.mode != ImageMode.overlay && this.options.image && drawImageSize.width > 0 && drawImageSize.height > 0 && await this.drawImage({
910
975
  width: drawImageSize.width,
911
976
  height: drawImageSize.height,
912
977
  count,
913
978
  dotSize
914
- }), this.drawDots(((i, j) => !(this.options.imageOptions.mode == ImageMode.center && i >= (count - drawImageSize.hideXDots) / 2 && i < (count + drawImageSize.hideXDots) / 2 && j >= (count - drawImageSize.hideYDots) / 2 && j < (count + drawImageSize.hideYDots) / 2 || 8 > i && 8 > j || i >= count - 8 && 8 > j || j >= count - 8 && 8 > i))),
915
- this.options.imageOptions.mode == ImageMode.overlay && this.options.image && 0 < drawImageSize.width && 0 < drawImageSize.height && await this.drawImage({
979
+ }), this.drawDots((i, j) => !(this.options.imageOptions.mode == ImageMode.center && i >= (count - drawImageSize.hideXDots) / 2 && i < (count + drawImageSize.hideXDots) / 2 && j >= (count - drawImageSize.hideYDots) / 2 && j < (count + drawImageSize.hideYDots) / 2 || i < 8 && j < 8 || i >= count - 8 && j < 8 || j >= count - 8 && i < 8)),
980
+ this.options.imageOptions.mode == ImageMode.overlay && this.options.image && drawImageSize.width > 0 && drawImageSize.height > 0 && await this.drawImage({
916
981
  width: drawImageSize.width,
917
982
  height: drawImageSize.height,
918
983
  count,
@@ -967,12 +1032,12 @@ class QRSVG {
967
1032
  for (let j = 0; j < fakeCount_margin; j++) if (i > additionalDots - 1 && i < fakeCount_margin - additionalDots && j > additionalDots - 1 && j < fakeCount_margin - additionalDots) {
968
1033
  let ii = i - additionalDots, jj = j - additionalDots;
969
1034
  alignment && !alignment(ii, jj) ? fakeMatrix[i][j] = void 0 : fakeMatrix[i][j] = !!this.qr.isDark(jj, ii);
970
- } else fakeMatrix[i][j] = options.shape === ShapeType.circle && Math.sqrt((i - center_jAlign) * (i - center_jAlign) + (j - center_jAlign) * (j - center_jAlign)) > center_jAlign ? void 0 : i == additionalDots - 1 || i == fakeCount_margin - additionalDots || j == additionalDots - 1 || j == fakeCount_margin - additionalDots ? (j == additionalDots - 1 && (i < additionalDots + 8 || i > fakeCount_margin - additionalDots - 9) || j == fakeCount_margin - additionalDots && i < additionalDots + 8 || i == additionalDots - 1 && (j < additionalDots + 8 || j > fakeCount_margin - additionalDots - 9) || i == fakeCount_margin - additionalDots && j < additionalDots + 8) && void 0 : this.qr.isDark(0 > j - 2 * additionalDots ? j : j >= count ? j - 2 * additionalDots : j - additionalDots, 0 > i - 2 * additionalDots ? i : i >= count ? i - 2 * additionalDots : i - additionalDots);
1035
+ } else fakeMatrix[i][j] = options.shape === ShapeType.circle && Math.sqrt((i - center_jAlign) * (i - center_jAlign) + (j - center_jAlign) * (j - center_jAlign)) > center_jAlign ? void 0 : i == additionalDots - 1 || i == fakeCount_margin - additionalDots || j == additionalDots - 1 || j == fakeCount_margin - additionalDots ? (j == additionalDots - 1 && (i < additionalDots + 8 || i > fakeCount_margin - additionalDots - 9) || j == fakeCount_margin - additionalDots && i < additionalDots + 8 || i == additionalDots - 1 && (j < additionalDots + 8 || j > fakeCount_margin - additionalDots - 9) || i == fakeCount_margin - additionalDots && j < additionalDots + 8) && void 0 : this.qr.isDark(j - 2 * additionalDots < 0 ? j : j >= count ? j - 2 * additionalDots : j - additionalDots, i - 2 * additionalDots < 0 ? i : i >= count ? i - 2 * additionalDots : i - additionalDots);
971
1036
  }
972
1037
  alignment = QRUtil.getPatternPosition((count - 17) / 4);
973
1038
  for (let i = 0; i < fakeCount_margin; i++) {
974
- count = alignment.find((v => i - additionalDots > v - 3 && i - additionalDots < v + 3));
975
- for (let j = 0; j < fakeCount_margin; j++) center_jAlign = alignment.find((v => j - additionalDots > v - 3 && j - additionalDots < v + 3)),
1039
+ count = alignment.find(v => i - additionalDots > v - 3 && i - additionalDots < v + 3);
1040
+ for (let j = 0; j < fakeCount_margin; j++) center_jAlign = alignment.find(v => j - additionalDots > v - 3 && j - additionalDots < v + 3),
976
1041
  null != fakeMatrix[i][j] && (this.lightDotsMask && (dot = count && center_jAlign && (count != alignment[0] && center_jAlign != alignment[0] || center_jAlign != alignment[0] && center_jAlign != alignment[alignment.length - 1] || count != alignment[0] && count != alignment[alignment.length - 1]) ? markerDot : overlayDot),
977
1042
  fakeMatrix[i][j] ? (dot.draw({
978
1043
  x: minSize_xFakeBeginning + i * dotSize,
@@ -1011,11 +1076,11 @@ class QRSVG {
1011
1076
  let options = this.options;
1012
1077
  if (!this._element) throw Error("Element code is not defined");
1013
1078
  let count = this.qr.getModuleCount(), dotSize = this.options.dotsOptions.size, cornersSquareSize = 7 * dotSize, cornersDotSize = 3 * dotSize, xBeginning = Math.floor((options.width - count * dotSize) / 2), yBeginning = Math.floor((options.height - count * dotSize) / 2);
1014
- [ [ 0, 0, 0 ], [ 1, 0, Math.PI / 2 ], [ 0, 1, -Math.PI / 2 ] ].forEach((([column_cornersDot, row, dot]) => {
1079
+ [ [ 0, 0, 0 ], [ 1, 0, Math.PI / 2 ], [ 0, 1, -Math.PI / 2 ] ].forEach(([column_cornersDot, row, dot]) => {
1015
1080
  let x = xBeginning + column_cornersDot * dotSize * (count - 7), y = yBeginning + row * dotSize * (count - 7);
1016
1081
  var cornersDotMaskGroup_cornersSquareMask = this.dotsMask;
1017
1082
  let cornersSquareMaskGroup = this.dotsMaskGroup;
1018
- var cornersDotMask_cornersSquare_dot = this.dotsMask;
1083
+ var val, cornersDotMask_cornersSquare_dot = this.dotsMask;
1019
1084
  if (cornersDotMaskGroup_cornersSquareMask = this.dotsMaskGroup, (options.cornersSquareOptions?.gradient || options.cornersSquareOptions?.color) && ([cornersDotMaskGroup_cornersSquareMask, cornersSquareMaskGroup] = this.createMask(`mask-corners-square-color-${column_cornersDot}-${row}`),
1020
1085
  this.defs.appendChild(cornersDotMaskGroup_cornersSquareMask), cornersDotMask_cornersSquare_dot = cornersDotMaskGroup_cornersSquareMask,
1021
1086
  cornersDotMaskGroup_cornersSquareMask = cornersSquareMaskGroup, this.createColor({
@@ -1027,14 +1092,14 @@ class QRSVG {
1027
1092
  height: cornersSquareSize,
1028
1093
  width: cornersSquareSize,
1029
1094
  name: `corners-square-color-${column_cornersDot}-${row}`
1030
- })), options.cornersSquareOptions?.type) (cornersDotMask_cornersSquare_dot = new QRCornerSquare(options.cornersSquareOptions.type, this.document)).draw({
1095
+ })), val = options.cornersSquareOptions?.type, val && cornerSquareTypes.has(val)) (cornersDotMask_cornersSquare_dot = new QRCornerSquare(options.cornersSquareOptions.type, this.document)).draw({
1031
1096
  x,
1032
1097
  y,
1033
1098
  size: cornersSquareSize,
1034
1099
  rotation: dot
1035
1100
  }), cornersDotMask_cornersSquare_dot.element && cornersSquareMaskGroup && cornersSquareMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element),
1036
1101
  cornersDotMask_cornersSquare_dot.fill && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.fill); else {
1037
- cornersDotMask_cornersSquare_dot = new QRDot(options.dotsOptions.type, this.document);
1102
+ cornersDotMask_cornersSquare_dot = new QRDot(options.cornersSquareOptions?.type || options.dotsOptions.type, this.document);
1038
1103
  for (let i = 0; i < squareMask.length; i++) for (let j = 0; j < squareMask[i].length; j++) squareMask[i]?.[j] ? (cornersDotMask_cornersSquare_dot.draw({
1039
1104
  x: x + i * dotSize,
1040
1105
  y: y + j * dotSize,
@@ -1046,11 +1111,11 @@ class QRSVG {
1046
1111
  size: dotSize,
1047
1112
  getNeighbor: (xOffset, yOffset) => !squareMask[i + xOffset]?.[j + yOffset] && !dotMask[i + xOffset]?.[j + yOffset]
1048
1113
  }), cornersDotMask_cornersSquare_dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element));
1049
- if (this.lightDotsMask) for (let i = -1; 8 > i; i++) for (let j = -1; 8 > j; j++) -1 != i && 7 != i && -1 != j && 7 != j || (cornersDotMask_cornersSquare_dot.draw({
1114
+ if (this.lightDotsMask) for (let i = -1; i < 8; i++) for (let j = -1; j < 8; j++) -1 != i && 7 != i && -1 != j && 7 != j || (cornersDotMask_cornersSquare_dot.draw({
1050
1115
  x: x + i * dotSize,
1051
1116
  y: y + j * dotSize,
1052
1117
  size: dotSize,
1053
- getNeighbor: (ii, jj) => (jj = j + jj, -1 <= (ii = i + ii) && 7 >= ii && -1 <= jj && 7 >= jj && (-1 == ii || 7 == ii || -1 == jj || 7 == jj))
1118
+ getNeighbor: (ii, jj) => (jj = j + jj, (ii = i + ii) >= -1 && ii <= 7 && jj >= -1 && jj <= 7 && (-1 == ii || 7 == ii || -1 == jj || 7 == jj))
1054
1119
  }), cornersDotMask_cornersSquare_dot.element && this.lightDotsMaskGroup && this.lightDotsMaskGroup.appendChild(cornersDotMask_cornersSquare_dot.element));
1055
1120
  }
1056
1121
  if ((options.cornersDotOptions?.gradient || options.cornersDotOptions?.color) && ([cornersDotMask_cornersSquare_dot, cornersDotMaskGroup_cornersSquareMask] = this.createMask(`mask-corners-dot-color-${column_cornersDot}-${row}`),
@@ -1063,13 +1128,15 @@ class QRSVG {
1063
1128
  height: cornersDotSize,
1064
1129
  width: cornersDotSize,
1065
1130
  name: `corners-dot-color-${column_cornersDot}-${row}`
1066
- })), options.cornersDotOptions?.type) (column_cornersDot = new QRCornerDot(options.cornersDotOptions.type, this.document)).draw({
1131
+ })), function(val) {
1132
+ return !(!val || !cornerDotTypes.has(val));
1133
+ }(options.cornersDotOptions?.type)) (column_cornersDot = new QRCornerDot(options.cornersDotOptions.type, this.document)).draw({
1067
1134
  x: x + 2 * dotSize,
1068
1135
  y: y + 2 * dotSize,
1069
1136
  size: cornersDotSize,
1070
1137
  rotation: dot
1071
1138
  }), column_cornersDot.element && cornersDotMaskGroup_cornersSquareMask && cornersDotMaskGroup_cornersSquareMask.appendChild(column_cornersDot.element); else {
1072
- dot = new QRDot(options.dotsOptions.type, this.document);
1139
+ dot = new QRDot(options.cornersDotOptions?.type || options.dotsOptions.type, this.document);
1073
1140
  for (let i = 0; i < dotMask.length; i++) for (let j = 0; j < dotMask[i].length; j++) dotMask[i]?.[j] && (dot.draw({
1074
1141
  x: x + i * dotSize,
1075
1142
  y: y + j * dotSize,
@@ -1077,7 +1144,7 @@ class QRSVG {
1077
1144
  getNeighbor: (xOffset, yOffset) => !!dotMask[i + xOffset]?.[j + yOffset]
1078
1145
  }), dot.element && cornersDotMaskGroup_cornersSquareMask && cornersDotMaskGroup_cornersSquareMask.appendChild(dot.element));
1079
1146
  }
1080
- }));
1147
+ });
1081
1148
  }
1082
1149
  async drawImage({width: dw_width, height: dh_height, count, dotSize}) {
1083
1150
  var image = this.options, dx = Math.floor((image.width - count * dotSize) / 2), encoding = Math.floor((image.height - count * dotSize) / 2), container_data = image.imageOptions.margin * dotSize;
@@ -1109,7 +1176,7 @@ class QRSVG {
1109
1176
  gradient.setAttribute("r", numToAttr(size / 2)); else {
1110
1177
  size = x + width / 2;
1111
1178
  let y0 = y + height / 2;
1112
- x += width / 2, y += height / 2, 0 <= (additionalRotation_positiveRotation = ((color = ((options.rotation || 0) + additionalRotation_positiveRotation) % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI)) && additionalRotation_positiveRotation <= .25 * Math.PI || additionalRotation_positiveRotation > 1.75 * Math.PI && additionalRotation_positiveRotation <= 2 * Math.PI ? (size -= width / 2,
1179
+ x += width / 2, y += height / 2, (additionalRotation_positiveRotation = ((color = ((options.rotation || 0) + additionalRotation_positiveRotation) % (2 * Math.PI)) + 2 * Math.PI) % (2 * Math.PI)) >= 0 && additionalRotation_positiveRotation <= .25 * Math.PI || additionalRotation_positiveRotation > 1.75 * Math.PI && additionalRotation_positiveRotation <= 2 * Math.PI ? (size -= width / 2,
1113
1180
  y0 -= height / 2 * Math.tan(color), x += width / 2, y += height / 2 * Math.tan(color)) : additionalRotation_positiveRotation > .25 * Math.PI && additionalRotation_positiveRotation <= .75 * Math.PI ? (y0 -= height / 2,
1114
1181
  size -= width / 2 / Math.tan(color), y += height / 2, x += width / 2 / Math.tan(color)) : additionalRotation_positiveRotation > .75 * Math.PI && additionalRotation_positiveRotation <= 1.25 * Math.PI ? (size += width / 2,
1115
1182
  y0 += height / 2 * Math.tan(color), x -= width / 2, y -= height / 2 * Math.tan(color)) : additionalRotation_positiveRotation > 1.25 * Math.PI && additionalRotation_positiveRotation <= 1.75 * Math.PI && (y0 += height / 2,
@@ -1119,14 +1186,14 @@ class QRSVG {
1119
1186
  gradient.setAttribute("x1", numToAttr(size)), gradient.setAttribute("y1", numToAttr(y0)),
1120
1187
  gradient.setAttribute("x2", numToAttr(x)), gradient.setAttribute("y2", numToAttr(y));
1121
1188
  }
1122
- options.colorStops.forEach((parsed_stopCfg => {
1189
+ options.colorStops.forEach(parsed_stopCfg => {
1123
1190
  let stop = this.document.createElementNS("http://www.w3.org/2000/svg", "stop");
1124
1191
  stop.setAttribute("offset", `${numToAttr(100 * parsed_stopCfg.offset)}%`), parsed_stopCfg = parseColor(parsed_stopCfg.color),
1125
- stop.setAttribute("stop-color", parsed_stopCfg.value), 1 > parsed_stopCfg.alpha && stop.setAttribute("stop-opacity", parsed_stopCfg.alpha.toFixed(7)),
1192
+ stop.setAttribute("stop-color", parsed_stopCfg.value), parsed_stopCfg.alpha < 1 && stop.setAttribute("stop-opacity", parsed_stopCfg.alpha.toFixed(7)),
1126
1193
  gradient.appendChild(stop);
1127
- })), rect.setAttribute("fill", `url(#${name})`), this.defs.appendChild(gradient);
1194
+ }), rect.setAttribute("fill", `url(#${name})`), this.defs.appendChild(gradient);
1128
1195
  } else color && (options = parseColor(color), rect.setAttribute("fill", options.value),
1129
- 1 > options.alpha && rect.setAttribute("opacity", options.alpha.toFixed(7)));
1196
+ options.alpha < 1 && rect.setAttribute("opacity", options.alpha.toFixed(7)));
1130
1197
  this._element.appendChild(rect);
1131
1198
  }
1132
1199
  createMask(group_id) {
@@ -1141,6 +1208,12 @@ class QRSVG {
1141
1208
  Object.assign(QRCodeMinimal.stringToBytesFuncs, stringToBytes_UTF8);
1142
1209
 
1143
1210
  let QRCodeStyling$1 = class {
1211
+ options;
1212
+ container;
1213
+ qr;
1214
+ extension;
1215
+ svgDrawingPromise;
1216
+ qrSVG;
1144
1217
  get size() {
1145
1218
  if (this.qrSVG) return {
1146
1219
  width: this.qrSVG.width,
@@ -1192,7 +1265,7 @@ let QRCodeStyling$1 = class {
1192
1265
  if (this.qr) {
1193
1266
  var count = this.qr.getModuleCount();
1194
1267
  this.options.imageOptions.mode == ImageMode.background && this.options.shape != ShapeType.circle && (count += 2),
1195
- 0 == (count = Math.ceil((this.options.shape == ShapeType.circle ? Math.sqrt(2) : 1) * count)) % 2 && --count;
1268
+ (count = Math.ceil((this.options.shape == ShapeType.circle ? Math.sqrt(2) : 1) * count)) % 2 == 0 && --count;
1196
1269
  var margin = this.options.backgroundOptions && this.options.backgroundOptions.margin || 0;
1197
1270
  this.options.imageOptions.mode == ImageMode.background && (margin += this.options.imageOptions.margin || 0),
1198
1271
  count = Math.ceil(this.options.dotsOptions.size * (count + 2 * margin)), this.qrSVG = new QRSVG({
@@ -1200,30 +1273,30 @@ let QRCodeStyling$1 = class {
1200
1273
  width: count,
1201
1274
  height: count,
1202
1275
  errorCorrectionPercent: ErrorCorrectionPercents[this.options.qrOptions.errorCorrectionLevel]
1203
- }), this.svgDrawingPromise = this.qrSVG.drawQR(this.qr).then((() => {
1276
+ }), this.svgDrawingPromise = this.qrSVG.drawQR(this.qr).then(() => {
1204
1277
  this.qrSVG?.element && this.extension?.(this.qrSVG.element, this.options);
1205
- }));
1278
+ });
1206
1279
  }
1207
1280
  }
1208
1281
  };
1209
1282
 
1210
1283
  var FileExtension;
1211
1284
 
1212
- (FileExtension = FileExtension || (FileExtension = {})).svg = "svg", FileExtension.png = "png",
1213
- FileExtension.jpeg = "jpeg", FileExtension.webp = "webp";
1285
+ (FileExtension = FileExtension ||= {}).svg = "svg", FileExtension.png = "png", FileExtension.jpeg = "jpeg",
1286
+ FileExtension.webp = "webp";
1214
1287
 
1215
1288
  class QRCodeStyling extends QRCodeStyling$1 {
1216
1289
  constructor(options) {
1217
1290
  let dom = (new DOMImplementation).createDocument(null, ""), imageCache = new Map, loadImage = async buff => {
1218
1291
  if ("string" == typeof buff) {
1219
1292
  let pr = imageCache.get(buff);
1220
- return pr || (pr = fetch(buff).then((res => res.arrayBuffer().then((buff => Buffer.from(buff))).then((async data => ({
1221
- contentType: res.headers.get("Content-Type") || await fileTypeFromBuffer(data).then((r => r?.mime)),
1293
+ return pr || (pr = fetch(buff).then(res => res.arrayBuffer().then(buff => Buffer.from(buff)).then(async data => ({
1294
+ contentType: res.headers.get("Content-Type") || await fileTypeFromBuffer(data).then(r => r?.mime),
1222
1295
  data
1223
- }))))), imageCache.set(buff, pr), pr);
1296
+ }))), imageCache.set(buff, pr), pr);
1224
1297
  }
1225
1298
  return buff = Buffer.from(buff), {
1226
- contentType: await fileTypeFromBuffer(buff).then((r => r?.mime)),
1299
+ contentType: await fileTypeFromBuffer(buff).then(r => r?.mime),
1227
1300
  data: buff
1228
1301
  };
1229
1302
  };
@@ -1231,7 +1304,7 @@ class QRCodeStyling extends QRCodeStyling$1 {
1231
1304
  ...options,
1232
1305
  document: options.document || dom,
1233
1306
  imageTools: options.imageTools || {
1234
- toDataURL: url => "string" == typeof url && url.startsWith("data:") ? Promise.resolve(url) : loadImage(url).then((({contentType, data}) => `data:${contentType?.replace("application/xml", "image/svg+xml")};base64,${data.toString("base64")}`)),
1307
+ toDataURL: url => "string" == typeof url && url.startsWith("data:") ? Promise.resolve(url) : loadImage(url).then(({contentType, data}) => `data:${contentType?.replace("application/xml", "image/svg+xml")};base64,${data.toString("base64")}`),
1235
1308
  getSize: async data => (({data} = Buffer.isBuffer(options.image) ? {
1236
1309
  data: options.image
1237
1310
  } : await loadImage(data)), {