@lglab/react-qr-code 1.1.0 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -0
- package/dist/index.d.ts +25 -8
- package/dist/index.es.js +690 -617
- package/package.json +23 -4
package/dist/index.es.js
CHANGED
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsx as C, jsxs as V, Fragment as nt } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as L, useCallback as rt, useRef as st, useImperativeHandle as it } from "react";
|
|
3
3
|
/**
|
|
4
4
|
* @license QR Code generator library (TypeScript)
|
|
5
5
|
* Copyright (c) Project Nayuki.
|
|
6
6
|
* SPDX-License-Identifier: MIT
|
|
7
7
|
*/
|
|
8
|
-
var
|
|
8
|
+
var O;
|
|
9
9
|
((r) => {
|
|
10
|
-
const
|
|
10
|
+
const d = class d {
|
|
11
11
|
/*-- Constructor (low level) and fields --*/
|
|
12
12
|
// Creates a new QR Code with the given version number,
|
|
13
13
|
// error correction level, data codeword bytes, and mask number.
|
|
14
14
|
// This is a low-level API that most users should not use directly.
|
|
15
15
|
// A mid-level API is the encodeSegments() function.
|
|
16
|
-
constructor(e,
|
|
17
|
-
if (this.version = e, this.errorCorrectionLevel =
|
|
16
|
+
constructor(e, o, n, i) {
|
|
17
|
+
if (this.version = e, this.errorCorrectionLevel = o, this.modules = [], this.isFunction = [], e < d.MIN_VERSION || e > d.MAX_VERSION)
|
|
18
18
|
throw new RangeError("Version value out of range");
|
|
19
19
|
if (i < -1 || i > 7)
|
|
20
20
|
throw new RangeError("Mask value out of range");
|
|
21
21
|
this.size = e * 4 + 17;
|
|
22
22
|
let h = [];
|
|
23
|
-
for (let
|
|
23
|
+
for (let f = 0; f < this.size; f++)
|
|
24
24
|
h.push(!1);
|
|
25
|
-
for (let
|
|
25
|
+
for (let f = 0; f < this.size; f++)
|
|
26
26
|
this.modules.push(h.slice()), this.isFunction.push(h.slice());
|
|
27
27
|
this.drawFunctionPatterns();
|
|
28
|
-
const
|
|
29
|
-
if (this.drawCodewords(
|
|
30
|
-
let
|
|
31
|
-
for (let
|
|
32
|
-
this.applyMask(
|
|
33
|
-
const
|
|
34
|
-
|
|
28
|
+
const $ = this.addEccAndInterleave(n);
|
|
29
|
+
if (this.drawCodewords($), i == -1) {
|
|
30
|
+
let f = 1e9;
|
|
31
|
+
for (let p = 0; p < 8; p++) {
|
|
32
|
+
this.applyMask(p), this.drawFormatBits(p);
|
|
33
|
+
const M = this.getPenaltyScore();
|
|
34
|
+
M < f && (i = p, f = M), this.applyMask(p);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
t(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
|
|
@@ -42,17 +42,17 @@ var L;
|
|
|
42
42
|
// Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
|
|
43
43
|
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
|
44
44
|
// ecl argument if it can be done without increasing the version.
|
|
45
|
-
static encodeText(e,
|
|
46
|
-
const
|
|
47
|
-
return
|
|
45
|
+
static encodeText(e, o) {
|
|
46
|
+
const n = r.QrSegment.makeSegments(e);
|
|
47
|
+
return d.encodeSegments(n, o);
|
|
48
48
|
}
|
|
49
49
|
// Returns a QR Code representing the given binary data at the given error correction level.
|
|
50
50
|
// This function always encodes using the binary segment mode, not any text mode. The maximum number of
|
|
51
51
|
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
|
52
52
|
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
|
53
|
-
static encodeBinary(e,
|
|
54
|
-
const
|
|
55
|
-
return
|
|
53
|
+
static encodeBinary(e, o) {
|
|
54
|
+
const n = r.QrSegment.makeBytes(e);
|
|
55
|
+
return d.encodeSegments([n], o);
|
|
56
56
|
}
|
|
57
57
|
/*-- Static factory functions (mid level) --*/
|
|
58
58
|
// Returns a QR Code representing the given segments with the given encoding parameters.
|
|
@@ -64,43 +64,43 @@ var L;
|
|
|
64
64
|
// This function allows the user to create a custom sequence of segments that switches
|
|
65
65
|
// between modes (such as alphanumeric and byte) to encode text in less space.
|
|
66
66
|
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
|
67
|
-
static encodeSegments(e,
|
|
68
|
-
if (!(
|
|
67
|
+
static encodeSegments(e, o, n = 1, i = 40, h = -1, $ = !0) {
|
|
68
|
+
if (!(d.MIN_VERSION <= n && n <= i && i <= d.MAX_VERSION) || h < -1 || h > 7)
|
|
69
69
|
throw new RangeError("Invalid value");
|
|
70
|
-
let
|
|
71
|
-
for (
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
|
|
70
|
+
let f, p;
|
|
71
|
+
for (f = n; ; f++) {
|
|
72
|
+
const R = d.getNumDataCodewords(f, o) * 8, w = c.getTotalBits(e, f);
|
|
73
|
+
if (w <= R) {
|
|
74
|
+
p = w;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
77
|
+
if (f >= i)
|
|
78
78
|
throw new RangeError("Data too long");
|
|
79
79
|
}
|
|
80
|
-
for (const
|
|
81
|
-
|
|
82
|
-
let
|
|
83
|
-
for (const
|
|
84
|
-
l(
|
|
85
|
-
for (const
|
|
86
|
-
|
|
80
|
+
for (const R of [d.Ecc.MEDIUM, d.Ecc.QUARTILE, d.Ecc.HIGH])
|
|
81
|
+
$ && p <= d.getNumDataCodewords(f, R) * 8 && (o = R);
|
|
82
|
+
let M = [];
|
|
83
|
+
for (const R of e) {
|
|
84
|
+
l(R.mode.modeBits, 4, M), l(R.numChars, R.mode.numCharCountBits(f), M);
|
|
85
|
+
for (const w of R.getData())
|
|
86
|
+
M.push(w);
|
|
87
87
|
}
|
|
88
|
-
t(
|
|
89
|
-
const E =
|
|
90
|
-
t(
|
|
91
|
-
for (let
|
|
92
|
-
l(
|
|
93
|
-
let
|
|
94
|
-
for (;
|
|
95
|
-
|
|
96
|
-
return
|
|
88
|
+
t(M.length == p);
|
|
89
|
+
const E = d.getNumDataCodewords(f, o) * 8;
|
|
90
|
+
t(M.length <= E), l(0, Math.min(4, E - M.length), M), l(0, (8 - M.length % 8) % 8, M), t(M.length % 8 == 0);
|
|
91
|
+
for (let R = 236; M.length < E; R ^= 253)
|
|
92
|
+
l(R, 8, M);
|
|
93
|
+
let m = [];
|
|
94
|
+
for (; m.length * 8 < M.length; )
|
|
95
|
+
m.push(0);
|
|
96
|
+
return M.forEach((R, w) => m[w >>> 3] |= R << 7 - (w & 7)), new d(f, o, m, h);
|
|
97
97
|
}
|
|
98
98
|
/*-- Accessor methods --*/
|
|
99
99
|
// Returns the color of the module (pixel) at the given coordinates, which is false
|
|
100
100
|
// for light or true for dark. The top left corner has the coordinates (x=0, y=0).
|
|
101
101
|
// If the given coordinates are out of bounds, then false (light) is returned.
|
|
102
|
-
getModule(e,
|
|
103
|
-
return 0 <= e && e < this.size && 0 <=
|
|
102
|
+
getModule(e, o) {
|
|
103
|
+
return 0 <= e && e < this.size && 0 <= o && o < this.size && this.modules[o][e];
|
|
104
104
|
}
|
|
105
105
|
// Modified to expose modules for easy access
|
|
106
106
|
getModules() {
|
|
@@ -109,33 +109,33 @@ var L;
|
|
|
109
109
|
/*-- Private helper methods for constructor: Drawing function modules --*/
|
|
110
110
|
// Reads this object's version field, and draws and marks all function modules.
|
|
111
111
|
drawFunctionPatterns() {
|
|
112
|
-
for (let
|
|
113
|
-
this.setFunctionModule(6,
|
|
112
|
+
for (let n = 0; n < this.size; n++)
|
|
113
|
+
this.setFunctionModule(6, n, n % 2 == 0), this.setFunctionModule(n, 6, n % 2 == 0);
|
|
114
114
|
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
|
115
|
-
const e = this.getAlignmentPatternPositions(),
|
|
116
|
-
for (let
|
|
117
|
-
for (let i = 0; i <
|
|
118
|
-
|
|
115
|
+
const e = this.getAlignmentPatternPositions(), o = e.length;
|
|
116
|
+
for (let n = 0; n < o; n++)
|
|
117
|
+
for (let i = 0; i < o; i++)
|
|
118
|
+
n == 0 && i == 0 || n == 0 && i == o - 1 || n == o - 1 && i == 0 || this.drawAlignmentPattern(e[n], e[i]);
|
|
119
119
|
this.drawFormatBits(0), this.drawVersion();
|
|
120
120
|
}
|
|
121
121
|
// Draws two copies of the format bits (with its own error correction code)
|
|
122
122
|
// based on the given mask and this object's error correction level field.
|
|
123
123
|
drawFormatBits(e) {
|
|
124
|
-
const
|
|
125
|
-
let
|
|
124
|
+
const o = this.errorCorrectionLevel.formatBits << 3 | e;
|
|
125
|
+
let n = o;
|
|
126
126
|
for (let h = 0; h < 10; h++)
|
|
127
|
-
|
|
128
|
-
const i = (
|
|
127
|
+
n = n << 1 ^ (n >>> 9) * 1335;
|
|
128
|
+
const i = (o << 10 | n) ^ 21522;
|
|
129
129
|
t(i >>> 15 == 0);
|
|
130
130
|
for (let h = 0; h <= 5; h++)
|
|
131
|
-
this.setFunctionModule(8, h,
|
|
132
|
-
this.setFunctionModule(8, 7,
|
|
131
|
+
this.setFunctionModule(8, h, a(i, h));
|
|
132
|
+
this.setFunctionModule(8, 7, a(i, 6)), this.setFunctionModule(8, 8, a(i, 7)), this.setFunctionModule(7, 8, a(i, 8));
|
|
133
133
|
for (let h = 9; h < 15; h++)
|
|
134
|
-
this.setFunctionModule(14 - h, 8,
|
|
134
|
+
this.setFunctionModule(14 - h, 8, a(i, h));
|
|
135
135
|
for (let h = 0; h < 8; h++)
|
|
136
|
-
this.setFunctionModule(this.size - 1 - h, 8,
|
|
136
|
+
this.setFunctionModule(this.size - 1 - h, 8, a(i, h));
|
|
137
137
|
for (let h = 8; h < 15; h++)
|
|
138
|
-
this.setFunctionModule(8, this.size - 15 + h,
|
|
138
|
+
this.setFunctionModule(8, this.size - 15 + h, a(i, h));
|
|
139
139
|
this.setFunctionModule(8, this.size - 8, !0);
|
|
140
140
|
}
|
|
141
141
|
// Draws two copies of the version bits (with its own error correction code),
|
|
@@ -144,74 +144,74 @@ var L;
|
|
|
144
144
|
if (this.version < 7)
|
|
145
145
|
return;
|
|
146
146
|
let e = this.version;
|
|
147
|
-
for (let
|
|
147
|
+
for (let n = 0; n < 12; n++)
|
|
148
148
|
e = e << 1 ^ (e >>> 11) * 7973;
|
|
149
|
-
const
|
|
150
|
-
t(
|
|
151
|
-
for (let
|
|
152
|
-
const i =
|
|
153
|
-
this.setFunctionModule(h,
|
|
149
|
+
const o = this.version << 12 | e;
|
|
150
|
+
t(o >>> 18 == 0);
|
|
151
|
+
for (let n = 0; n < 18; n++) {
|
|
152
|
+
const i = a(o, n), h = this.size - 11 + n % 3, $ = Math.floor(n / 3);
|
|
153
|
+
this.setFunctionModule(h, $, i), this.setFunctionModule($, h, i);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
156
|
// Draws a 9*9 finder pattern including the border separator,
|
|
157
157
|
// with the center module at (x, y). Modules can be out of bounds.
|
|
158
|
-
drawFinderPattern(e,
|
|
159
|
-
for (let
|
|
158
|
+
drawFinderPattern(e, o) {
|
|
159
|
+
for (let n = -4; n <= 4; n++)
|
|
160
160
|
for (let i = -4; i <= 4; i++) {
|
|
161
|
-
const h = Math.max(Math.abs(i), Math.abs(
|
|
162
|
-
0 <=
|
|
161
|
+
const h = Math.max(Math.abs(i), Math.abs(n)), $ = e + i, f = o + n;
|
|
162
|
+
0 <= $ && $ < this.size && 0 <= f && f < this.size && this.setFunctionModule($, f, h != 2 && h != 4);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
165
|
// Draws a 5*5 alignment pattern, with the center module
|
|
166
166
|
// at (x, y). All modules must be in bounds.
|
|
167
|
-
drawAlignmentPattern(e,
|
|
168
|
-
for (let
|
|
167
|
+
drawAlignmentPattern(e, o) {
|
|
168
|
+
for (let n = -2; n <= 2; n++)
|
|
169
169
|
for (let i = -2; i <= 2; i++)
|
|
170
|
-
this.setFunctionModule(e + i,
|
|
170
|
+
this.setFunctionModule(e + i, o + n, Math.max(Math.abs(i), Math.abs(n)) != 1);
|
|
171
171
|
}
|
|
172
172
|
// Sets the color of a module and marks it as a function module.
|
|
173
173
|
// Only used by the constructor. Coordinates must be in bounds.
|
|
174
|
-
setFunctionModule(e,
|
|
175
|
-
this.modules[
|
|
174
|
+
setFunctionModule(e, o, n) {
|
|
175
|
+
this.modules[o][e] = n, this.isFunction[o][e] = !0;
|
|
176
176
|
}
|
|
177
177
|
/*-- Private helper methods for constructor: Codewords and masking --*/
|
|
178
178
|
// Returns a new byte string representing the given data with the appropriate error correction
|
|
179
179
|
// codewords appended to it, based on this object's version and error correction level.
|
|
180
180
|
addEccAndInterleave(e) {
|
|
181
|
-
const
|
|
182
|
-
if (e.length !=
|
|
181
|
+
const o = this.version, n = this.errorCorrectionLevel;
|
|
182
|
+
if (e.length != d.getNumDataCodewords(o, n))
|
|
183
183
|
throw new RangeError("Invalid argument");
|
|
184
|
-
const i =
|
|
185
|
-
let
|
|
186
|
-
const E =
|
|
187
|
-
for (let
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
-
const N =
|
|
191
|
-
|
|
184
|
+
const i = d.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][o], h = d.ECC_CODEWORDS_PER_BLOCK[n.ordinal][o], $ = Math.floor(d.getNumRawDataModules(o) / 8), f = i - $ % i, p = Math.floor($ / i);
|
|
185
|
+
let M = [];
|
|
186
|
+
const E = d.reedSolomonComputeDivisor(h);
|
|
187
|
+
for (let R = 0, w = 0; R < i; R++) {
|
|
188
|
+
let A = e.slice(w, w + p - h + (R < f ? 0 : 1));
|
|
189
|
+
w += A.length;
|
|
190
|
+
const N = d.reedSolomonComputeRemainder(A, E);
|
|
191
|
+
R < f && A.push(0), M.push(A.concat(N));
|
|
192
192
|
}
|
|
193
|
-
let
|
|
194
|
-
for (let
|
|
195
|
-
|
|
196
|
-
(
|
|
193
|
+
let m = [];
|
|
194
|
+
for (let R = 0; R < M[0].length; R++)
|
|
195
|
+
M.forEach((w, A) => {
|
|
196
|
+
(R != p - h || A >= f) && m.push(w[R]);
|
|
197
197
|
});
|
|
198
|
-
return t(
|
|
198
|
+
return t(m.length == $), m;
|
|
199
199
|
}
|
|
200
200
|
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
|
201
201
|
// data area of this QR Code. Function modules need to be marked off before this is called.
|
|
202
202
|
drawCodewords(e) {
|
|
203
|
-
if (e.length != Math.floor(
|
|
203
|
+
if (e.length != Math.floor(d.getNumRawDataModules(this.version) / 8))
|
|
204
204
|
throw new RangeError("Invalid argument");
|
|
205
|
-
let
|
|
206
|
-
for (let
|
|
207
|
-
|
|
205
|
+
let o = 0;
|
|
206
|
+
for (let n = this.size - 1; n >= 1; n -= 2) {
|
|
207
|
+
n == 6 && (n = 5);
|
|
208
208
|
for (let i = 0; i < this.size; i++)
|
|
209
209
|
for (let h = 0; h < 2; h++) {
|
|
210
|
-
const
|
|
211
|
-
!this.isFunction[
|
|
210
|
+
const $ = n - h, p = (n + 1 & 2) == 0 ? this.size - 1 - i : i;
|
|
211
|
+
!this.isFunction[p][$] && o < e.length * 8 && (this.modules[p][$] = a(e[o >>> 3], 7 - (o & 7)), o++);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
t(
|
|
214
|
+
t(o == e.length * 8);
|
|
215
215
|
}
|
|
216
216
|
// XORs the codeword modules in this QR Code with the given mask pattern.
|
|
217
217
|
// The function modules must be marked and the codeword bits must be drawn
|
|
@@ -221,38 +221,38 @@ var L;
|
|
|
221
221
|
applyMask(e) {
|
|
222
222
|
if (e < 0 || e > 7)
|
|
223
223
|
throw new RangeError("Mask value out of range");
|
|
224
|
-
for (let
|
|
225
|
-
for (let
|
|
224
|
+
for (let o = 0; o < this.size; o++)
|
|
225
|
+
for (let n = 0; n < this.size; n++) {
|
|
226
226
|
let i;
|
|
227
227
|
switch (e) {
|
|
228
228
|
case 0:
|
|
229
|
-
i = (
|
|
229
|
+
i = (n + o) % 2 == 0;
|
|
230
230
|
break;
|
|
231
231
|
case 1:
|
|
232
|
-
i =
|
|
232
|
+
i = o % 2 == 0;
|
|
233
233
|
break;
|
|
234
234
|
case 2:
|
|
235
|
-
i =
|
|
235
|
+
i = n % 3 == 0;
|
|
236
236
|
break;
|
|
237
237
|
case 3:
|
|
238
|
-
i = (
|
|
238
|
+
i = (n + o) % 3 == 0;
|
|
239
239
|
break;
|
|
240
240
|
case 4:
|
|
241
|
-
i = (Math.floor(
|
|
241
|
+
i = (Math.floor(n / 3) + Math.floor(o / 2)) % 2 == 0;
|
|
242
242
|
break;
|
|
243
243
|
case 5:
|
|
244
|
-
i =
|
|
244
|
+
i = n * o % 2 + n * o % 3 == 0;
|
|
245
245
|
break;
|
|
246
246
|
case 6:
|
|
247
|
-
i = (
|
|
247
|
+
i = (n * o % 2 + n * o % 3) % 2 == 0;
|
|
248
248
|
break;
|
|
249
249
|
case 7:
|
|
250
|
-
i = ((
|
|
250
|
+
i = ((n + o) % 2 + n * o % 3) % 2 == 0;
|
|
251
251
|
break;
|
|
252
252
|
default:
|
|
253
253
|
throw new Error("Unreachable");
|
|
254
254
|
}
|
|
255
|
-
!this.isFunction[
|
|
255
|
+
!this.isFunction[o][n] && i && (this.modules[o][n] = !this.modules[o][n]);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
@@ -260,27 +260,27 @@ var L;
|
|
|
260
260
|
getPenaltyScore() {
|
|
261
261
|
let e = 0;
|
|
262
262
|
for (let h = 0; h < this.size; h++) {
|
|
263
|
-
let
|
|
264
|
-
for (let
|
|
265
|
-
this.modules[h][
|
|
266
|
-
e += this.finderPenaltyTerminateAndCount(
|
|
263
|
+
let $ = !1, f = 0, p = [0, 0, 0, 0, 0, 0, 0];
|
|
264
|
+
for (let M = 0; M < this.size; M++)
|
|
265
|
+
this.modules[h][M] == $ ? (f++, f == 5 ? e += d.PENALTY_N1 : f > 5 && e++) : (this.finderPenaltyAddHistory(f, p), $ || (e += this.finderPenaltyCountPatterns(p) * d.PENALTY_N3), $ = this.modules[h][M], f = 1);
|
|
266
|
+
e += this.finderPenaltyTerminateAndCount($, f, p) * d.PENALTY_N3;
|
|
267
267
|
}
|
|
268
268
|
for (let h = 0; h < this.size; h++) {
|
|
269
|
-
let
|
|
270
|
-
for (let
|
|
271
|
-
this.modules[
|
|
272
|
-
e += this.finderPenaltyTerminateAndCount(
|
|
269
|
+
let $ = !1, f = 0, p = [0, 0, 0, 0, 0, 0, 0];
|
|
270
|
+
for (let M = 0; M < this.size; M++)
|
|
271
|
+
this.modules[M][h] == $ ? (f++, f == 5 ? e += d.PENALTY_N1 : f > 5 && e++) : (this.finderPenaltyAddHistory(f, p), $ || (e += this.finderPenaltyCountPatterns(p) * d.PENALTY_N3), $ = this.modules[M][h], f = 1);
|
|
272
|
+
e += this.finderPenaltyTerminateAndCount($, f, p) * d.PENALTY_N3;
|
|
273
273
|
}
|
|
274
274
|
for (let h = 0; h < this.size - 1; h++)
|
|
275
|
-
for (let
|
|
276
|
-
const
|
|
277
|
-
|
|
275
|
+
for (let $ = 0; $ < this.size - 1; $++) {
|
|
276
|
+
const f = this.modules[h][$];
|
|
277
|
+
f == this.modules[h][$ + 1] && f == this.modules[h + 1][$] && f == this.modules[h + 1][$ + 1] && (e += d.PENALTY_N2);
|
|
278
278
|
}
|
|
279
|
-
let
|
|
279
|
+
let o = 0;
|
|
280
280
|
for (const h of this.modules)
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
return t(0 <= i && i <= 9), e += i *
|
|
281
|
+
o = h.reduce(($, f) => $ + (f ? 1 : 0), o);
|
|
282
|
+
const n = this.size * this.size, i = Math.ceil(Math.abs(o * 20 - n * 10) / n) - 1;
|
|
283
|
+
return t(0 <= i && i <= 9), e += i * d.PENALTY_N4, t(0 <= e && e <= 2568888), e;
|
|
284
284
|
}
|
|
285
285
|
/*-- Private helper functions --*/
|
|
286
286
|
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
@@ -290,86 +290,86 @@ var L;
|
|
|
290
290
|
if (this.version == 1)
|
|
291
291
|
return [];
|
|
292
292
|
{
|
|
293
|
-
const e = Math.floor(this.version / 7) + 2,
|
|
294
|
-
let
|
|
295
|
-
for (let i = this.size - 7;
|
|
296
|
-
|
|
297
|
-
return
|
|
293
|
+
const e = Math.floor(this.version / 7) + 2, o = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
|
|
294
|
+
let n = [6];
|
|
295
|
+
for (let i = this.size - 7; n.length < e; i -= o)
|
|
296
|
+
n.splice(1, 0, i);
|
|
297
|
+
return n;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
// Returns the number of data bits that can be stored in a QR Code of the given version number, after
|
|
301
301
|
// all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
|
|
302
302
|
// The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
|
|
303
303
|
static getNumRawDataModules(e) {
|
|
304
|
-
if (e <
|
|
304
|
+
if (e < d.MIN_VERSION || e > d.MAX_VERSION)
|
|
305
305
|
throw new RangeError("Version number out of range");
|
|
306
|
-
let
|
|
306
|
+
let o = (16 * e + 128) * e + 64;
|
|
307
307
|
if (e >= 2) {
|
|
308
|
-
const
|
|
309
|
-
|
|
308
|
+
const n = Math.floor(e / 7) + 2;
|
|
309
|
+
o -= (25 * n - 10) * n - 55, e >= 7 && (o -= 36);
|
|
310
310
|
}
|
|
311
|
-
return t(208 <=
|
|
311
|
+
return t(208 <= o && o <= 29648), o;
|
|
312
312
|
}
|
|
313
313
|
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
|
314
314
|
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
|
315
315
|
// This stateless pure function could be implemented as a (40*4)-cell lookup table.
|
|
316
|
-
static getNumDataCodewords(e,
|
|
317
|
-
return Math.floor(
|
|
316
|
+
static getNumDataCodewords(e, o) {
|
|
317
|
+
return Math.floor(d.getNumRawDataModules(e) / 8) - d.ECC_CODEWORDS_PER_BLOCK[o.ordinal][e] * d.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][e];
|
|
318
318
|
}
|
|
319
319
|
// Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
|
|
320
320
|
// implemented as a lookup table over all possible parameter values, instead of as an algorithm.
|
|
321
321
|
static reedSolomonComputeDivisor(e) {
|
|
322
322
|
if (e < 1 || e > 255)
|
|
323
323
|
throw new RangeError("Degree out of range");
|
|
324
|
-
let
|
|
324
|
+
let o = [];
|
|
325
325
|
for (let i = 0; i < e - 1; i++)
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
let
|
|
326
|
+
o.push(0);
|
|
327
|
+
o.push(1);
|
|
328
|
+
let n = 1;
|
|
329
329
|
for (let i = 0; i < e; i++) {
|
|
330
|
-
for (let h = 0; h <
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
for (let h = 0; h < o.length; h++)
|
|
331
|
+
o[h] = d.reedSolomonMultiply(o[h], n), h + 1 < o.length && (o[h] ^= o[h + 1]);
|
|
332
|
+
n = d.reedSolomonMultiply(n, 2);
|
|
333
333
|
}
|
|
334
|
-
return
|
|
334
|
+
return o;
|
|
335
335
|
}
|
|
336
336
|
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
|
337
|
-
static reedSolomonComputeRemainder(e,
|
|
338
|
-
let
|
|
337
|
+
static reedSolomonComputeRemainder(e, o) {
|
|
338
|
+
let n = o.map((i) => 0);
|
|
339
339
|
for (const i of e) {
|
|
340
|
-
const h = i ^
|
|
341
|
-
|
|
340
|
+
const h = i ^ n.shift();
|
|
341
|
+
n.push(0), o.forEach(($, f) => n[f] ^= d.reedSolomonMultiply($, h));
|
|
342
342
|
}
|
|
343
|
-
return
|
|
343
|
+
return n;
|
|
344
344
|
}
|
|
345
345
|
// Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
|
|
346
346
|
// are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
|
|
347
|
-
static reedSolomonMultiply(e,
|
|
348
|
-
if (e >>> 8 ||
|
|
347
|
+
static reedSolomonMultiply(e, o) {
|
|
348
|
+
if (e >>> 8 || o >>> 8)
|
|
349
349
|
throw new RangeError("Byte out of range");
|
|
350
|
-
let
|
|
350
|
+
let n = 0;
|
|
351
351
|
for (let i = 7; i >= 0; i--)
|
|
352
|
-
|
|
353
|
-
return t(
|
|
352
|
+
n = n << 1 ^ (n >>> 7) * 285, n ^= (o >>> i & 1) * e;
|
|
353
|
+
return t(n >>> 8 == 0), n;
|
|
354
354
|
}
|
|
355
355
|
// Can only be called immediately after a light run is added, and
|
|
356
356
|
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
|
357
357
|
finderPenaltyCountPatterns(e) {
|
|
358
|
-
const
|
|
359
|
-
t(
|
|
360
|
-
const
|
|
361
|
-
return (
|
|
358
|
+
const o = e[1];
|
|
359
|
+
t(o <= this.size * 3);
|
|
360
|
+
const n = o > 0 && e[2] == o && e[3] == o * 3 && e[4] == o && e[5] == o;
|
|
361
|
+
return (n && e[0] >= o * 4 && e[6] >= o ? 1 : 0) + (n && e[6] >= o * 4 && e[0] >= o ? 1 : 0);
|
|
362
362
|
}
|
|
363
363
|
// Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
|
|
364
|
-
finderPenaltyTerminateAndCount(e,
|
|
365
|
-
return e && (this.finderPenaltyAddHistory(
|
|
364
|
+
finderPenaltyTerminateAndCount(e, o, n) {
|
|
365
|
+
return e && (this.finderPenaltyAddHistory(o, n), o = 0), o += this.size, this.finderPenaltyAddHistory(o, n), this.finderPenaltyCountPatterns(n);
|
|
366
366
|
}
|
|
367
367
|
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
|
368
|
-
finderPenaltyAddHistory(e,
|
|
369
|
-
|
|
368
|
+
finderPenaltyAddHistory(e, o) {
|
|
369
|
+
o[0] == 0 && (e += this.size), o.pop(), o.unshift(e);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
|
|
372
|
+
d.MIN_VERSION = 1, d.MAX_VERSION = 40, d.PENALTY_N1 = 3, d.PENALTY_N2 = 3, d.PENALTY_N3 = 40, d.PENALTY_N4 = 10, d.ECC_CODEWORDS_PER_BLOCK = [
|
|
373
373
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
374
374
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
375
375
|
[-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
|
|
@@ -380,7 +380,7 @@ var L;
|
|
|
380
380
|
// Quartile
|
|
381
381
|
[-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
|
|
382
382
|
// High
|
|
383
|
-
],
|
|
383
|
+
], d.NUM_ERROR_CORRECTION_BLOCKS = [
|
|
384
384
|
// Version: (note that index 0 is for padding, and is set to an illegal value)
|
|
385
385
|
//0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
|
|
386
386
|
[-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
|
|
@@ -392,96 +392,96 @@ var L;
|
|
|
392
392
|
[-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
|
|
393
393
|
// High
|
|
394
394
|
];
|
|
395
|
-
let
|
|
396
|
-
r.QrCode =
|
|
397
|
-
function l(
|
|
398
|
-
if (e < 0 || e > 31 ||
|
|
395
|
+
let s = d;
|
|
396
|
+
r.QrCode = s;
|
|
397
|
+
function l(g, e, o) {
|
|
398
|
+
if (e < 0 || e > 31 || g >>> e)
|
|
399
399
|
throw new RangeError("Value out of range");
|
|
400
|
-
for (let
|
|
401
|
-
|
|
400
|
+
for (let n = e - 1; n >= 0; n--)
|
|
401
|
+
o.push(g >>> n & 1);
|
|
402
402
|
}
|
|
403
|
-
function
|
|
404
|
-
return (
|
|
403
|
+
function a(g, e) {
|
|
404
|
+
return (g >>> e & 1) != 0;
|
|
405
405
|
}
|
|
406
|
-
function t(
|
|
407
|
-
if (!
|
|
406
|
+
function t(g) {
|
|
407
|
+
if (!g)
|
|
408
408
|
throw new Error("Assertion error");
|
|
409
409
|
}
|
|
410
|
-
const
|
|
410
|
+
const u = class u {
|
|
411
411
|
/*-- Constructor (low level) and fields --*/
|
|
412
412
|
// Creates a new QR Code segment with the given attributes and data.
|
|
413
413
|
// The character count (numChars) must agree with the mode and the bit buffer length,
|
|
414
414
|
// but the constraint isn't checked. The given bit buffer is cloned and stored.
|
|
415
|
-
constructor(e,
|
|
416
|
-
if (this.mode = e, this.numChars =
|
|
415
|
+
constructor(e, o, n) {
|
|
416
|
+
if (this.mode = e, this.numChars = o, this.bitData = n, o < 0)
|
|
417
417
|
throw new RangeError("Invalid argument");
|
|
418
|
-
this.bitData =
|
|
418
|
+
this.bitData = n.slice();
|
|
419
419
|
}
|
|
420
420
|
/*-- Static factory functions (mid level) --*/
|
|
421
421
|
// Returns a segment representing the given binary data encoded in
|
|
422
422
|
// byte mode. All input byte arrays are acceptable. Any text string
|
|
423
423
|
// can be converted to UTF-8 bytes and encoded as a byte mode segment.
|
|
424
424
|
static makeBytes(e) {
|
|
425
|
-
let
|
|
426
|
-
for (const
|
|
427
|
-
l(
|
|
428
|
-
return new
|
|
425
|
+
let o = [];
|
|
426
|
+
for (const n of e)
|
|
427
|
+
l(n, 8, o);
|
|
428
|
+
return new u(u.Mode.BYTE, e.length, o);
|
|
429
429
|
}
|
|
430
430
|
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
431
431
|
static makeNumeric(e) {
|
|
432
|
-
if (
|
|
432
|
+
if (!u.isNumeric(e))
|
|
433
433
|
throw new RangeError("String contains non-numeric characters");
|
|
434
|
-
let
|
|
435
|
-
for (let
|
|
436
|
-
const i = Math.min(e.length -
|
|
437
|
-
l(parseInt(e.substring(
|
|
434
|
+
let o = [];
|
|
435
|
+
for (let n = 0; n < e.length; ) {
|
|
436
|
+
const i = Math.min(e.length - n, 3);
|
|
437
|
+
l(parseInt(e.substring(n, n + i), 10), i * 3 + 1, o), n += i;
|
|
438
438
|
}
|
|
439
|
-
return new
|
|
439
|
+
return new u(u.Mode.NUMERIC, e.length, o);
|
|
440
440
|
}
|
|
441
441
|
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
|
442
442
|
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
|
443
443
|
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
444
444
|
static makeAlphanumeric(e) {
|
|
445
|
-
if (
|
|
445
|
+
if (!u.isAlphanumeric(e))
|
|
446
446
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
447
|
-
let
|
|
448
|
-
for (
|
|
449
|
-
let i =
|
|
450
|
-
i +=
|
|
447
|
+
let o = [], n;
|
|
448
|
+
for (n = 0; n + 2 <= e.length; n += 2) {
|
|
449
|
+
let i = u.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)) * 45;
|
|
450
|
+
i += u.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n + 1)), l(i, 11, o);
|
|
451
451
|
}
|
|
452
|
-
return
|
|
452
|
+
return n < e.length && l(u.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)), 6, o), new u(u.Mode.ALPHANUMERIC, e.length, o);
|
|
453
453
|
}
|
|
454
454
|
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
|
455
455
|
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
|
456
456
|
static makeSegments(e) {
|
|
457
|
-
return e == "" ? [] :
|
|
457
|
+
return e == "" ? [] : u.isNumeric(e) ? [u.makeNumeric(e)] : u.isAlphanumeric(e) ? [u.makeAlphanumeric(e)] : [u.makeBytes(u.toUtf8ByteArray(e))];
|
|
458
458
|
}
|
|
459
459
|
// Returns a segment representing an Extended Channel Interpretation
|
|
460
460
|
// (ECI) designator with the given assignment value.
|
|
461
461
|
static makeEci(e) {
|
|
462
|
-
let
|
|
462
|
+
let o = [];
|
|
463
463
|
if (e < 0)
|
|
464
464
|
throw new RangeError("ECI assignment value out of range");
|
|
465
465
|
if (e < 128)
|
|
466
|
-
l(e, 8,
|
|
466
|
+
l(e, 8, o);
|
|
467
467
|
else if (e < 16384)
|
|
468
|
-
l(2, 2,
|
|
468
|
+
l(2, 2, o), l(e, 14, o);
|
|
469
469
|
else if (e < 1e6)
|
|
470
|
-
l(6, 3,
|
|
470
|
+
l(6, 3, o), l(e, 21, o);
|
|
471
471
|
else
|
|
472
472
|
throw new RangeError("ECI assignment value out of range");
|
|
473
|
-
return new
|
|
473
|
+
return new u(u.Mode.ECI, 0, o);
|
|
474
474
|
}
|
|
475
475
|
// Tests whether the given string can be encoded as a segment in numeric mode.
|
|
476
476
|
// A string is encodable iff each character is in the range 0 to 9.
|
|
477
477
|
static isNumeric(e) {
|
|
478
|
-
return
|
|
478
|
+
return u.NUMERIC_REGEX.test(e);
|
|
479
479
|
}
|
|
480
480
|
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
|
481
481
|
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
|
482
482
|
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
483
483
|
static isAlphanumeric(e) {
|
|
484
|
-
return
|
|
484
|
+
return u.ALPHANUMERIC_REGEX.test(e);
|
|
485
485
|
}
|
|
486
486
|
/*-- Methods --*/
|
|
487
487
|
// Returns a new copy of the data bits of this segment.
|
|
@@ -490,68 +490,68 @@ var L;
|
|
|
490
490
|
}
|
|
491
491
|
// (Package-private) Calculates and returns the number of bits needed to encode the given segments at
|
|
492
492
|
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
|
493
|
-
static getTotalBits(e,
|
|
494
|
-
let
|
|
493
|
+
static getTotalBits(e, o) {
|
|
494
|
+
let n = 0;
|
|
495
495
|
for (const i of e) {
|
|
496
|
-
const h = i.mode.numCharCountBits(
|
|
496
|
+
const h = i.mode.numCharCountBits(o);
|
|
497
497
|
if (i.numChars >= 1 << h)
|
|
498
498
|
return 1 / 0;
|
|
499
|
-
|
|
499
|
+
n += 4 + h + i.bitData.length;
|
|
500
500
|
}
|
|
501
|
-
return
|
|
501
|
+
return n;
|
|
502
502
|
}
|
|
503
503
|
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
|
504
504
|
static toUtf8ByteArray(e) {
|
|
505
505
|
e = encodeURI(e);
|
|
506
|
-
let
|
|
507
|
-
for (let
|
|
508
|
-
e.charAt(
|
|
509
|
-
return
|
|
506
|
+
let o = [];
|
|
507
|
+
for (let n = 0; n < e.length; n++)
|
|
508
|
+
e.charAt(n) != "%" ? o.push(e.charCodeAt(n)) : (o.push(parseInt(e.substring(n + 1, n + 3), 16)), n += 2);
|
|
509
|
+
return o;
|
|
510
510
|
}
|
|
511
511
|
};
|
|
512
|
-
|
|
513
|
-
let
|
|
514
|
-
r.QrSegment =
|
|
515
|
-
})(
|
|
512
|
+
u.NUMERIC_REGEX = /^[0-9]*$/, u.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, u.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
513
|
+
let c = u;
|
|
514
|
+
r.QrSegment = c;
|
|
515
|
+
})(O || (O = {}));
|
|
516
516
|
((r) => {
|
|
517
|
-
((
|
|
518
|
-
const
|
|
517
|
+
((s) => {
|
|
518
|
+
const a = class a {
|
|
519
519
|
// The QR Code can tolerate about 30% erroneous codewords
|
|
520
520
|
/*-- Constructor and fields --*/
|
|
521
|
-
constructor(
|
|
522
|
-
this.ordinal =
|
|
521
|
+
constructor(c, d) {
|
|
522
|
+
this.ordinal = c, this.formatBits = d;
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
|
-
|
|
526
|
-
let l =
|
|
527
|
-
|
|
525
|
+
a.LOW = new a(0, 1), a.MEDIUM = new a(1, 0), a.QUARTILE = new a(2, 3), a.HIGH = new a(3, 2);
|
|
526
|
+
let l = a;
|
|
527
|
+
s.Ecc = l;
|
|
528
528
|
})(r.QrCode || (r.QrCode = {}));
|
|
529
|
-
})(
|
|
529
|
+
})(O || (O = {}));
|
|
530
530
|
((r) => {
|
|
531
|
-
((
|
|
532
|
-
const
|
|
531
|
+
((s) => {
|
|
532
|
+
const a = class a {
|
|
533
533
|
/*-- Constructor and fields --*/
|
|
534
|
-
constructor(
|
|
535
|
-
this.modeBits =
|
|
534
|
+
constructor(c, d) {
|
|
535
|
+
this.modeBits = c, this.numBitsCharCount = d;
|
|
536
536
|
}
|
|
537
537
|
/*-- Method --*/
|
|
538
538
|
// (Package-private) Returns the bit width of the character count field for a segment in
|
|
539
539
|
// this mode in a QR Code at the given version number. The result is in the range [0, 16].
|
|
540
|
-
numCharCountBits(
|
|
541
|
-
return this.numBitsCharCount[Math.floor((
|
|
540
|
+
numCharCountBits(c) {
|
|
541
|
+
return this.numBitsCharCount[Math.floor((c + 7) / 17)];
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
|
-
|
|
545
|
-
let l =
|
|
546
|
-
|
|
544
|
+
a.NUMERIC = new a(1, [10, 12, 14]), a.ALPHANUMERIC = new a(2, [9, 11, 13]), a.BYTE = new a(4, [8, 16, 16]), a.KANJI = new a(8, [8, 10, 12]), a.ECI = new a(7, [0, 0, 0]);
|
|
545
|
+
let l = a;
|
|
546
|
+
s.Mode = l;
|
|
547
547
|
})(r.QrSegment || (r.QrSegment = {}));
|
|
548
|
-
})(
|
|
549
|
-
const
|
|
550
|
-
L:
|
|
551
|
-
M:
|
|
552
|
-
Q:
|
|
553
|
-
H:
|
|
554
|
-
},
|
|
548
|
+
})(O || (O = {}));
|
|
549
|
+
const y = O, at = {
|
|
550
|
+
L: y.QrCode.Ecc.LOW,
|
|
551
|
+
M: y.QrCode.Ecc.MEDIUM,
|
|
552
|
+
Q: y.QrCode.Ecc.QUARTILE,
|
|
553
|
+
H: y.QrCode.Ecc.HIGH
|
|
554
|
+
}, lt = 128, ct = "M", ht = 1, ut = 4, W = 5, x = "#000000", dt = "square", ft = "square", $t = "square", pt = "react-qr-code", U = "react-qr-code-gradient", F = "react-qr-code-bg-gradient", mt = 0.1, I = 7, T = 3, B = [
|
|
555
555
|
[1, 1, 1, 1, 1, 1, 1],
|
|
556
556
|
[1, 0, 0, 0, 0, 0, 1],
|
|
557
557
|
[1, 0, 0, 0, 0, 0, 1],
|
|
@@ -559,7 +559,7 @@ const b = L, W = {
|
|
|
559
559
|
[1, 0, 0, 0, 0, 0, 1],
|
|
560
560
|
[1, 0, 0, 0, 0, 0, 1],
|
|
561
561
|
[1, 1, 1, 1, 1, 1, 1]
|
|
562
|
-
],
|
|
562
|
+
], J = {
|
|
563
563
|
"inpoint-sm": [0, 90, -90],
|
|
564
564
|
inpoint: [0, 90, -90],
|
|
565
565
|
"inpoint-lg": [0, 90, -90],
|
|
@@ -569,7 +569,7 @@ const b = L, W = {
|
|
|
569
569
|
"leaf-sm": [0, 90, -90],
|
|
570
570
|
leaf: [0, 90, -90],
|
|
571
571
|
"leaf-lg": [0, 90, -90]
|
|
572
|
-
},
|
|
572
|
+
}, H = {
|
|
573
573
|
"rounded-sm": 3,
|
|
574
574
|
rounded: 4,
|
|
575
575
|
"rounded-lg": 5,
|
|
@@ -582,7 +582,7 @@ const b = L, W = {
|
|
|
582
582
|
"outpoint-sm": 3,
|
|
583
583
|
outpoint: 4,
|
|
584
584
|
"outpoint-lg": 5
|
|
585
|
-
},
|
|
585
|
+
}, Y = {
|
|
586
586
|
square: 0,
|
|
587
587
|
diamond: 0,
|
|
588
588
|
circle: 3,
|
|
@@ -598,7 +598,7 @@ const b = L, W = {
|
|
|
598
598
|
"outpoint-sm": 1.5,
|
|
599
599
|
outpoint: 2,
|
|
600
600
|
"outpoint-lg": 2.3
|
|
601
|
-
},
|
|
601
|
+
}, z = [
|
|
602
602
|
[0, 0, 0, 0, 0, 0, 0],
|
|
603
603
|
[0, 0, 0, 0, 0, 0, 0],
|
|
604
604
|
[0, 0, 1, 1, 1, 0, 0],
|
|
@@ -606,120 +606,28 @@ const b = L, W = {
|
|
|
606
606
|
[0, 0, 1, 1, 1, 0, 0],
|
|
607
607
|
[0, 0, 0, 0, 0, 0, 0],
|
|
608
608
|
[0, 0, 0, 0, 0, 0, 0]
|
|
609
|
-
],
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
};
|
|
609
|
+
], Et = /\.?0+$/;
|
|
610
|
+
function Mt(r) {
|
|
611
|
+
return r.toFixed(7).replace(Et, "");
|
|
612
|
+
}
|
|
613
|
+
const tt = (r) => {
|
|
614
|
+
const s = r % 360 * (Math.PI / 180), l = Math.max(0, Math.min(100, 50 - 50 * Math.cos(s))), a = Math.max(0, Math.min(100, 50 - 50 * Math.sin(s))), t = Math.max(0, Math.min(100, 50 + 50 * Math.cos(s))), c = Math.max(0, Math.min(100, 50 + 50 * Math.sin(s)));
|
|
616
615
|
return {
|
|
617
|
-
|
|
618
|
-
|
|
616
|
+
x1: `${l}%`,
|
|
617
|
+
y1: `${a}%`,
|
|
618
|
+
x2: `${t}%`,
|
|
619
|
+
y2: `${c}%`
|
|
619
620
|
};
|
|
620
|
-
},
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
h -1
|
|
627
|
-
v -0.5
|
|
628
|
-
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, k = (r, a) => `M ${r} ${a}
|
|
629
|
-
v 1
|
|
630
|
-
h 0.5
|
|
631
|
-
a 0.5 0.5, 0, 0, 0, 0.5 -0.5
|
|
632
|
-
v -0.5
|
|
633
|
-
h -1`, ut = (r, a) => `M ${r + 1} ${a}
|
|
634
|
-
v 1
|
|
635
|
-
h -0.5
|
|
636
|
-
a 0.5 0.5, 0, 0, 1, -0.5 -0.5
|
|
637
|
-
v -0.5
|
|
638
|
-
h 1`, Y = (r, a) => `M ${r} ${a}
|
|
639
|
-
v 1
|
|
640
|
-
h 0.5
|
|
641
|
-
a 0.5 0.5, 0, 0, 0, 0 -1`, H = (r, a) => `M ${r + 1} ${a}
|
|
642
|
-
v 1
|
|
643
|
-
h -0.5
|
|
644
|
-
a 0.5 0.5, 0, 0, 1, 0 -1`, j = (r, a) => `M ${r} ${a + 1}
|
|
645
|
-
h 1
|
|
646
|
-
v -0.5
|
|
647
|
-
a 0.5 0.5, 0, 0, 0, -1 0`, q = (r, a) => `M ${r} ${a}
|
|
648
|
-
h 1
|
|
649
|
-
v 0.5
|
|
650
|
-
a 0.5 0.5, 0, 0, 1, -1 0`, dt = (r, a, l) => `M ${r + 1} ${a}h -${l / 2}a ${l / 2.5} ${l / 2.5}, 0, 0, 0, ${-l / 2.5} ${l / 2.5}v ${l / 2}h ${l / 2}a ${l / 2.5} ${l / 2.5}, 0, 0, 0, ${l / 2.5} ${-l / 2.5}`, ft = ({
|
|
651
|
-
x: r,
|
|
652
|
-
y: a,
|
|
653
|
-
numCells: l
|
|
654
|
-
}) => {
|
|
655
|
-
var s, t, d;
|
|
656
|
-
return !!((s = F[r]) != null && s[a] || (t = F[r - l + 7]) != null && t[a] || (d = F[r]) != null && d[a - l + 7]);
|
|
657
|
-
}, $t = ({
|
|
658
|
-
x: r,
|
|
659
|
-
y: a,
|
|
660
|
-
radius: l
|
|
661
|
-
}) => {
|
|
662
|
-
const s = P - l, t = l / 2, d = P - t;
|
|
663
|
-
return `M ${r} ${a + t}v ${s}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${d}v ${-d}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-s}H ${r}z`;
|
|
664
|
-
}, pt = ({
|
|
665
|
-
x: r,
|
|
666
|
-
y: a,
|
|
667
|
-
radius: l
|
|
668
|
-
}) => {
|
|
669
|
-
const s = P - l, t = l / 2, d = P - t;
|
|
670
|
-
return `M ${r} ${a + t}v ${s}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${d}v ${-d}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-s}a ${t} ${t}, 0, 0, 0, ${-t} ${t}`;
|
|
671
|
-
}, mt = ({
|
|
672
|
-
x: r,
|
|
673
|
-
y: a,
|
|
674
|
-
numCells: l
|
|
675
|
-
}) => {
|
|
676
|
-
var s, t, d;
|
|
677
|
-
return !!((s = y[r]) != null && s[a] || (t = y[r - l + 7]) != null && t[a] || (d = y[r]) != null && d[a - l + 7]);
|
|
678
|
-
}, Et = ({
|
|
679
|
-
x: r,
|
|
680
|
-
y: a,
|
|
681
|
-
radius: l
|
|
682
|
-
}) => {
|
|
683
|
-
const s = C - l, t = l / 2;
|
|
684
|
-
return `M ${r} ${a + t}v ${s}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${s}a ${t} ${t}, 0, 0, 0, ${t} ${-t}v ${-s}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-s}a ${t} ${t}, 0, 0, 0, ${-t} ${t}M ${r + t} ${a + 1}h ${s}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${s}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${t - 1}h ${-s}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-s}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${-(t - 1)}`;
|
|
685
|
-
}, gt = ({
|
|
686
|
-
x: r,
|
|
687
|
-
y: a,
|
|
688
|
-
radius: l
|
|
689
|
-
}) => {
|
|
690
|
-
const s = C - l, t = l / 2, d = C - t;
|
|
691
|
-
return `M ${r} ${a + t}v ${s}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${d}v ${-d}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-s}H ${r}zM ${r + t} ${a + 1}h ${s}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${d - 1}h ${-(d - 1)}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-(d - 1)}z`;
|
|
692
|
-
}, Mt = ({
|
|
693
|
-
x: r,
|
|
694
|
-
y: a,
|
|
695
|
-
radius: l
|
|
696
|
-
}) => {
|
|
697
|
-
const s = C - l, t = l / 2, d = C - t;
|
|
698
|
-
return `M ${r} ${a + t}v ${s}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${d}v ${-d}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-s}a ${t} ${t}, 0, 0, 0, ${-t} ${t}M ${r + t} ${a + 1}h ${s}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${d - 1}h ${-(d - 1)}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-s}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${-(t - 1)}`;
|
|
699
|
-
}, Rt = (r) => ({
|
|
700
|
-
color: (r == null ? void 0 : r.color) || D,
|
|
701
|
-
style: (r == null ? void 0 : r.style) || it,
|
|
702
|
-
randomSize: (r == null ? void 0 : r.randomSize) || !1
|
|
703
|
-
}), wt = (r) => ({
|
|
704
|
-
color: (r == null ? void 0 : r.color) || D,
|
|
705
|
-
style: (r == null ? void 0 : r.style) || rt
|
|
706
|
-
}), At = (r) => ({
|
|
707
|
-
color: (r == null ? void 0 : r.color) || D,
|
|
708
|
-
style: (r == null ? void 0 : r.style) || st
|
|
709
|
-
}), Ct = /\.?0+$/;
|
|
710
|
-
function Nt(r) {
|
|
711
|
-
return r.toFixed(7).replace(Ct, "");
|
|
712
|
-
}
|
|
713
|
-
const G = (r, a, l, s) => {
|
|
714
|
-
const t = l / 2, d = t / 2, c = Math.PI / s;
|
|
715
|
-
let $ = "";
|
|
716
|
-
for (let m = 0; m < 2 * s; m++) {
|
|
717
|
-
const e = m * c - Math.PI / 2, n = m % 2 === 0 ? t : d, o = r + n * Math.cos(e), i = a + n * Math.sin(e);
|
|
718
|
-
$ += `${m === 0 ? "M" : "L"} ${o},${i} `;
|
|
621
|
+
}, et = (r, s, l, a) => {
|
|
622
|
+
const t = l / 2, c = t / 2, d = Math.PI / a;
|
|
623
|
+
let u = "";
|
|
624
|
+
for (let g = 0; g < 2 * a; g++) {
|
|
625
|
+
const e = g * d - Math.PI / 2, o = g % 2 === 0 ? t : c, n = r + o * Math.cos(e), i = s + o * Math.sin(e);
|
|
626
|
+
u += `${g === 0 ? "M" : "L"} ${n},${i} `;
|
|
719
627
|
}
|
|
720
|
-
return
|
|
721
|
-
},
|
|
722
|
-
let
|
|
628
|
+
return u + "Z";
|
|
629
|
+
}, ot = (r, s, l) => {
|
|
630
|
+
let a = !1, t = 0;
|
|
723
631
|
return [
|
|
724
632
|
"M",
|
|
725
633
|
1,
|
|
@@ -831,380 +739,545 @@ const G = (r, a, l, s) => {
|
|
|
831
739
|
1,
|
|
832
740
|
0.3262506,
|
|
833
741
|
"z"
|
|
834
|
-
].map((
|
|
835
|
-
},
|
|
742
|
+
].map((c) => typeof c == "string" ? (t = 0, a = c.toUpperCase() == c, c) : (t++, c = c * l, a && (c += t % 2 == 1 ? r : s), Mt(c))).join(" ");
|
|
743
|
+
}, G = {
|
|
744
|
+
"data-testid": "background"
|
|
745
|
+
}, Rt = ({ background: r, numCells: s }) => {
|
|
746
|
+
var a, t;
|
|
747
|
+
if (!r)
|
|
748
|
+
return null;
|
|
749
|
+
if (typeof r == "string")
|
|
750
|
+
return /* @__PURE__ */ C("path", { fill: r, d: `M0,0 h${s}v${s}H0z`, ...G });
|
|
751
|
+
const l = tt((r == null ? void 0 : r.rotation) || 0);
|
|
752
|
+
return /* @__PURE__ */ V(nt, { children: [
|
|
753
|
+
/* @__PURE__ */ C("defs", { children: r.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: F, gradientUnits: "userSpaceOnUse", ...l, children: (a = r.stops) == null ? void 0 : a.map((c, d) => /* @__PURE__ */ C("stop", { offset: c.offset, stopColor: c.color }, d)) }) : /* @__PURE__ */ C(
|
|
754
|
+
"radialGradient",
|
|
755
|
+
{
|
|
756
|
+
id: F,
|
|
757
|
+
gradientUnits: "userSpaceOnUse",
|
|
758
|
+
cx: "50%",
|
|
759
|
+
cy: "50%",
|
|
760
|
+
r: "50%",
|
|
761
|
+
children: (t = r.stops) == null ? void 0 : t.map((c, d) => /* @__PURE__ */ C("stop", { offset: c.offset, stopColor: c.color }, d))
|
|
762
|
+
}
|
|
763
|
+
) }),
|
|
764
|
+
/* @__PURE__ */ C(
|
|
765
|
+
"path",
|
|
766
|
+
{
|
|
767
|
+
fill: `url(#${F})`,
|
|
768
|
+
d: `M0,0 h${s}v${s}H0z`,
|
|
769
|
+
...G
|
|
770
|
+
}
|
|
771
|
+
)
|
|
772
|
+
] });
|
|
773
|
+
}, gt = (r) => r === "square" || r === "circle" || r === "star" || r === "heart" || r === "diamond", wt = (r, s) => r === "square-sm" ? 0.75 : s ? Math.random() * (1 - 0.75) + 0.75 : 1, b = (r, s, l) => {
|
|
774
|
+
const a = {
|
|
775
|
+
left: r === 0 ? !1 : l[s][r - 1],
|
|
776
|
+
right: r === l[s].length - 1 ? !1 : l[s][r + 1],
|
|
777
|
+
top: s === 0 ? !1 : l[s - 1][r],
|
|
778
|
+
bottom: s === l.length - 1 ? !1 : l[s + 1][r]
|
|
779
|
+
};
|
|
780
|
+
return {
|
|
781
|
+
...a,
|
|
782
|
+
count: Object.values(a).filter(Boolean).length
|
|
783
|
+
};
|
|
784
|
+
}, v = (r, s, l) => `M${r},${s}h${l}v${l}h-${l}Z`, D = (r, s, l) => `M${r},${s + l / 2}a${l / 2},${l / 2} 0 1,0 ${l},0a${l / 2},${l / 2} 0 1,0 -${l},0Z`, At = (r, s, l) => `M${r},${s + l / 2}l${l / 2},-${l / 2}l${l / 2},${l / 2}l-${l / 2},${l / 2}Z`, Ct = (r, s) => `M ${r} ${s}
|
|
785
|
+
v 1
|
|
786
|
+
h 1
|
|
787
|
+
v -0.5
|
|
788
|
+
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, q = (r, s) => `M ${r + 1} ${s}
|
|
789
|
+
v 1
|
|
790
|
+
h -1
|
|
791
|
+
v -0.5
|
|
792
|
+
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, j = (r, s) => `M ${r} ${s}
|
|
793
|
+
v 1
|
|
794
|
+
h 0.5
|
|
795
|
+
a 0.5 0.5, 0, 0, 0, 0.5 -0.5
|
|
796
|
+
v -0.5
|
|
797
|
+
h -1`, Nt = (r, s) => `M ${r + 1} ${s}
|
|
798
|
+
v 1
|
|
799
|
+
h -0.5
|
|
800
|
+
a 0.5 0.5, 0, 0, 1, -0.5 -0.5
|
|
801
|
+
v -0.5
|
|
802
|
+
h 1`, X = (r, s) => `M ${r} ${s}
|
|
803
|
+
v 1
|
|
804
|
+
h 0.5
|
|
805
|
+
a 0.5 0.5, 0, 0, 0, 0 -1`, Q = (r, s) => `M ${r + 1} ${s}
|
|
806
|
+
v 1
|
|
807
|
+
h -0.5
|
|
808
|
+
a 0.5 0.5, 0, 0, 1, 0 -1`, Z = (r, s) => `M ${r} ${s + 1}
|
|
809
|
+
h 1
|
|
810
|
+
v -0.5
|
|
811
|
+
a 0.5 0.5, 0, 0, 0, -1 0`, _ = (r, s) => `M ${r} ${s}
|
|
812
|
+
h 1
|
|
813
|
+
v 0.5
|
|
814
|
+
a 0.5 0.5, 0, 0, 1, -1 0`, It = (r, s, l) => `M ${r + 1} ${s}h -${l / 2}a ${l / 2.5} ${l / 2.5}, 0, 0, 0, ${-l / 2.5} ${l / 2.5}v ${l / 2}h ${l / 2}a ${l / 2.5} ${l / 2.5}, 0, 0, 0, ${l / 2.5} ${-l / 2.5}`, Pt = ({
|
|
815
|
+
x: r,
|
|
816
|
+
y: s,
|
|
817
|
+
numCells: l
|
|
818
|
+
}) => {
|
|
819
|
+
var a, t, c;
|
|
820
|
+
return !!((a = z[r]) != null && a[s] || (t = z[r - l + 7]) != null && t[s] || (c = z[r]) != null && c[s - l + 7]);
|
|
821
|
+
}, Tt = ({
|
|
822
|
+
x: r,
|
|
823
|
+
y: s,
|
|
824
|
+
radius: l
|
|
825
|
+
}) => {
|
|
826
|
+
const a = T - l, t = l / 2, c = T - t;
|
|
827
|
+
return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${c}v ${-c}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}H ${r}z`;
|
|
828
|
+
}, Lt = ({
|
|
829
|
+
x: r,
|
|
830
|
+
y: s,
|
|
831
|
+
radius: l
|
|
832
|
+
}) => {
|
|
833
|
+
const a = T - l, t = l / 2, c = T - t;
|
|
834
|
+
return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${c}v ${-c}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${t}`;
|
|
835
|
+
}, Ot = ({
|
|
836
|
+
x: r,
|
|
837
|
+
y: s,
|
|
838
|
+
numCells: l
|
|
839
|
+
}) => {
|
|
840
|
+
var a, t, c;
|
|
841
|
+
return !!((a = B[r]) != null && a[s] || (t = B[r - l + 7]) != null && t[s] || (c = B[r]) != null && c[s - l + 7]);
|
|
842
|
+
}, yt = ({
|
|
843
|
+
x: r,
|
|
844
|
+
y: s,
|
|
845
|
+
radius: l
|
|
846
|
+
}) => {
|
|
847
|
+
const a = I - l, t = l / 2;
|
|
848
|
+
return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${a}a ${t} ${t}, 0, 0, 0, ${t} ${-t}v ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${t}M ${r + t} ${s + 1}h ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${t - 1}h ${-a}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${-(t - 1)}`;
|
|
849
|
+
}, vt = ({
|
|
850
|
+
x: r,
|
|
851
|
+
y: s,
|
|
852
|
+
radius: l
|
|
853
|
+
}) => {
|
|
854
|
+
const a = I - l, t = l / 2, c = I - t;
|
|
855
|
+
return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${c}v ${-c}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}H ${r}zM ${r + t} ${s + 1}h ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${c - 1}h ${-(c - 1)}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-(c - 1)}z`;
|
|
856
|
+
}, St = ({
|
|
857
|
+
x: r,
|
|
858
|
+
y: s,
|
|
859
|
+
radius: l
|
|
860
|
+
}) => {
|
|
861
|
+
const a = I - l, t = l / 2, c = I - t;
|
|
862
|
+
return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${c}v ${-c}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${t}M ${r + t} ${s + 1}h ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${c - 1}h ${-(c - 1)}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${-(t - 1)}`;
|
|
863
|
+
}, Ut = (r) => ({
|
|
864
|
+
color: (r == null ? void 0 : r.color) || x,
|
|
865
|
+
style: (r == null ? void 0 : r.style) || $t,
|
|
866
|
+
randomSize: (r == null ? void 0 : r.randomSize) || !1
|
|
867
|
+
}), bt = (r) => ({
|
|
868
|
+
color: (r == null ? void 0 : r.color) || x,
|
|
869
|
+
style: (r == null ? void 0 : r.style) || dt
|
|
870
|
+
}), Dt = (r) => ({
|
|
871
|
+
color: (r == null ? void 0 : r.color) || x,
|
|
872
|
+
style: (r == null ? void 0 : r.style) || ft
|
|
873
|
+
}), Ft = ({
|
|
836
874
|
modules: r,
|
|
837
|
-
margin:
|
|
838
|
-
settings: l
|
|
875
|
+
margin: s,
|
|
876
|
+
settings: l,
|
|
877
|
+
gradient: a
|
|
839
878
|
}) => {
|
|
840
|
-
const { color:
|
|
841
|
-
() =>
|
|
879
|
+
const { color: t, style: c, randomSize: d } = L(
|
|
880
|
+
() => Ut(l),
|
|
842
881
|
[l]
|
|
843
|
-
),
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
882
|
+
), u = [], g = r.length, e = gt(c) && d, o = rt(
|
|
883
|
+
() => wt(c, e),
|
|
884
|
+
[c, e]
|
|
885
|
+
);
|
|
886
|
+
return r.forEach((n, i) => {
|
|
887
|
+
n.forEach((h, $) => {
|
|
888
|
+
if (Ot({ x: $, y: i, numCells: g }) || Pt({ x: $, y: i, numCells: g }))
|
|
847
889
|
return;
|
|
848
|
-
const
|
|
849
|
-
if (
|
|
850
|
-
if (
|
|
851
|
-
|
|
852
|
-
else if (
|
|
853
|
-
|
|
854
|
-
else if (
|
|
855
|
-
|
|
856
|
-
else if (
|
|
857
|
-
|
|
858
|
-
|
|
890
|
+
const f = o(), p = 1 * f, M = (1 - 1 * f) / 2, E = $ + s + M, m = i + s + M;
|
|
891
|
+
if (h) {
|
|
892
|
+
if (c === "square" || c === "square-sm")
|
|
893
|
+
u.push(v(E, m, p));
|
|
894
|
+
else if (c === "circle")
|
|
895
|
+
u.push(D(E, m, p));
|
|
896
|
+
else if (c === "diamond")
|
|
897
|
+
u.push(At(E, m, p));
|
|
898
|
+
else if (c === "star")
|
|
899
|
+
u.push(
|
|
900
|
+
et(E + p / 2, m + p / 2, p * 1.1, W)
|
|
859
901
|
);
|
|
860
|
-
else if (
|
|
861
|
-
|
|
862
|
-
else if (
|
|
863
|
-
const { left:
|
|
864
|
-
|
|
865
|
-
} else if (
|
|
866
|
-
const { left:
|
|
867
|
-
if (
|
|
868
|
-
|
|
869
|
-
else if (!
|
|
870
|
-
|
|
902
|
+
else if (c === "heart")
|
|
903
|
+
u.push(ot(E, m, p));
|
|
904
|
+
else if (c === "rounded") {
|
|
905
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, i, r);
|
|
906
|
+
P === 0 ? u.push(D(E, m, 1)) : P > 2 || R && w || A && N ? u.push(v(E, m, 1)) : P === 2 ? R && A ? u.push(j(E, m)) : A && w ? u.push(Nt(E, m)) : w && N ? u.push(q(E, m)) : u.push(Ct(E, m)) : A ? u.push(_(E, m)) : w ? u.push(Q(E, m)) : N ? u.push(Z(E, m)) : u.push(X(E, m));
|
|
907
|
+
} else if (c === "leaf") {
|
|
908
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, i, r);
|
|
909
|
+
if (P === 0)
|
|
910
|
+
u.push(It(E, m, p));
|
|
911
|
+
else if (!R && !A) {
|
|
912
|
+
u.push(q(E, m));
|
|
871
913
|
return;
|
|
872
|
-
} else !
|
|
873
|
-
} else if (
|
|
874
|
-
const { left:
|
|
875
|
-
|
|
876
|
-
} else if (
|
|
877
|
-
const { left:
|
|
878
|
-
|
|
914
|
+
} else !w && !N ? u.push(j(E, m)) : u.push(v(E, m, 1));
|
|
915
|
+
} else if (c === "vertical-line") {
|
|
916
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, i, r);
|
|
917
|
+
P === 0 || R && !(A || N) || w && !(A || N) ? u.push(D(E, m, 1)) : A && N ? u.push(v(E, m, 1)) : A && !N ? u.push(_(E, m)) : N && !A && u.push(Z(E, m));
|
|
918
|
+
} else if (c === "horizontal-line") {
|
|
919
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, i, r);
|
|
920
|
+
P === 0 || A && !(R || w) || N && !(R || w) ? u.push(D(E, m, 1)) : R && w ? u.push(v(E, m, 1)) : R && !w ? u.push(X(E, m)) : w && !R && u.push(Q(E, m));
|
|
879
921
|
}
|
|
880
922
|
}
|
|
881
923
|
});
|
|
882
|
-
}), /* @__PURE__ */
|
|
924
|
+
}), /* @__PURE__ */ C(
|
|
883
925
|
"path",
|
|
884
926
|
{
|
|
885
|
-
fill:
|
|
886
|
-
d:
|
|
887
|
-
shapeRendering:
|
|
927
|
+
fill: a ? `url(#${U})` : t,
|
|
928
|
+
d: u.join(""),
|
|
929
|
+
shapeRendering: c === "square" ? "crispEdges" : "geometricPrecision",
|
|
930
|
+
"data-testid": "data-modules"
|
|
888
931
|
}
|
|
889
932
|
);
|
|
890
|
-
},
|
|
933
|
+
}, S = {
|
|
934
|
+
"data-testid": "finder-patterns-inner"
|
|
935
|
+
}, Bt = ({
|
|
891
936
|
modules: r,
|
|
892
|
-
margin:
|
|
893
|
-
settings: l
|
|
937
|
+
margin: s,
|
|
938
|
+
settings: l,
|
|
939
|
+
gradient: a
|
|
894
940
|
}) => {
|
|
895
|
-
const { color:
|
|
896
|
-
() =>
|
|
941
|
+
const { color: t, style: c } = L(
|
|
942
|
+
() => Dt(l),
|
|
897
943
|
[l]
|
|
898
|
-
), d =
|
|
944
|
+
), d = a ? `url(#${U})` : t, u = L(
|
|
899
945
|
() => [
|
|
900
|
-
{ x:
|
|
901
|
-
{ x: r.length +
|
|
902
|
-
{ x:
|
|
946
|
+
{ x: s + 2, y: s + 2 },
|
|
947
|
+
{ x: r.length + s - I + 2, y: s + 2 },
|
|
948
|
+
{ x: s + 2, y: r.length + s - I + 2 }
|
|
903
949
|
],
|
|
904
|
-
[
|
|
905
|
-
),
|
|
906
|
-
if (
|
|
907
|
-
return
|
|
908
|
-
const { x:
|
|
909
|
-
return /* @__PURE__ */
|
|
950
|
+
[s, r.length]
|
|
951
|
+
), g = (e, o) => `finder-patterns-inner-${c}-${e}-${o}`;
|
|
952
|
+
if (c === "rounded-sm" || c === "rounded" || c === "rounded-lg" || c === "circle" || c === "square")
|
|
953
|
+
return u.map((e) => {
|
|
954
|
+
const { x: o, y: n } = e;
|
|
955
|
+
return /* @__PURE__ */ C(
|
|
910
956
|
"rect",
|
|
911
957
|
{
|
|
912
|
-
x:
|
|
913
|
-
y:
|
|
914
|
-
width:
|
|
915
|
-
height:
|
|
916
|
-
fill:
|
|
917
|
-
rx:
|
|
958
|
+
x: o,
|
|
959
|
+
y: n,
|
|
960
|
+
width: T,
|
|
961
|
+
height: T,
|
|
962
|
+
fill: d,
|
|
963
|
+
rx: Y[c],
|
|
964
|
+
...S
|
|
918
965
|
},
|
|
919
|
-
|
|
966
|
+
g(o, n)
|
|
920
967
|
);
|
|
921
968
|
});
|
|
922
|
-
if (
|
|
923
|
-
return
|
|
924
|
-
const { x:
|
|
925
|
-
return /* @__PURE__ */
|
|
969
|
+
if (c === "diamond")
|
|
970
|
+
return u.map((e) => {
|
|
971
|
+
const { x: o, y: n } = e, i = Math.sqrt(1.5), h = T / i, $ = h - h / i;
|
|
972
|
+
return /* @__PURE__ */ C(
|
|
926
973
|
"rect",
|
|
927
974
|
{
|
|
928
|
-
x:
|
|
929
|
-
y:
|
|
930
|
-
width:
|
|
931
|
-
height:
|
|
932
|
-
fill:
|
|
975
|
+
x: o + $ / 2,
|
|
976
|
+
y: n + $ / 2,
|
|
977
|
+
width: h,
|
|
978
|
+
height: h,
|
|
979
|
+
fill: d,
|
|
933
980
|
style: {
|
|
934
981
|
transform: "rotate(45deg)",
|
|
935
982
|
transformOrigin: "center",
|
|
936
983
|
transformBox: "fill-box"
|
|
937
|
-
}
|
|
984
|
+
},
|
|
985
|
+
...S
|
|
938
986
|
},
|
|
939
|
-
|
|
987
|
+
g(o, n)
|
|
940
988
|
);
|
|
941
989
|
});
|
|
942
|
-
if (
|
|
943
|
-
const
|
|
944
|
-
return
|
|
945
|
-
...
|
|
946
|
-
rotation:
|
|
947
|
-
})).map(({ x:
|
|
948
|
-
const
|
|
949
|
-
x:
|
|
950
|
-
y:
|
|
951
|
-
radius:
|
|
990
|
+
if (c === "inpoint-sm" || c === "inpoint" || c === "inpoint-lg" || c === "outpoint-sm" || c === "outpoint" || c === "outpoint-lg" || c === "leaf-sm" || c === "leaf" || c === "leaf-lg") {
|
|
991
|
+
const e = c === "leaf-sm" || c === "leaf" || c === "leaf-lg" ? Tt : Lt;
|
|
992
|
+
return u.map((o, n) => ({
|
|
993
|
+
...o,
|
|
994
|
+
rotation: J[c][n]
|
|
995
|
+
})).map(({ x: o, y: n, rotation: i }) => {
|
|
996
|
+
const h = e({
|
|
997
|
+
x: o,
|
|
998
|
+
y: n,
|
|
999
|
+
radius: Y[c]
|
|
952
1000
|
});
|
|
953
|
-
return /* @__PURE__ */
|
|
1001
|
+
return /* @__PURE__ */ C(
|
|
954
1002
|
"path",
|
|
955
1003
|
{
|
|
956
|
-
fill:
|
|
957
|
-
d:
|
|
1004
|
+
fill: d,
|
|
1005
|
+
d: h,
|
|
958
1006
|
style: {
|
|
959
|
-
transform: `rotate(${
|
|
1007
|
+
transform: `rotate(${i}deg)`,
|
|
960
1008
|
transformOrigin: "center",
|
|
961
1009
|
transformBox: "fill-box"
|
|
962
|
-
}
|
|
1010
|
+
},
|
|
1011
|
+
...S
|
|
963
1012
|
},
|
|
964
|
-
|
|
1013
|
+
g(o, n)
|
|
965
1014
|
);
|
|
966
1015
|
});
|
|
967
1016
|
}
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1017
|
+
if (c === "heart")
|
|
1018
|
+
return u.map(({ x: e, y: o }) => /* @__PURE__ */ C(
|
|
1019
|
+
"path",
|
|
1020
|
+
{
|
|
1021
|
+
fill: d,
|
|
1022
|
+
d: ot(e, o, T),
|
|
1023
|
+
...S
|
|
1024
|
+
},
|
|
1025
|
+
g(e, o)
|
|
1026
|
+
));
|
|
1027
|
+
if (c === "star")
|
|
1028
|
+
return u.map(({ x: e, y: o }) => {
|
|
1029
|
+
const n = e + T / 2, i = o + T / 2, h = et(n, i, T * 1.2, W);
|
|
1030
|
+
return /* @__PURE__ */ C("path", { fill: d, d: h, ...S }, g(e, o));
|
|
1031
|
+
});
|
|
1032
|
+
}, K = {
|
|
1033
|
+
"data-testid": "finder-patterns-outer"
|
|
1034
|
+
}, zt = ({
|
|
973
1035
|
modules: r,
|
|
974
|
-
margin:
|
|
975
|
-
settings: l
|
|
1036
|
+
margin: s,
|
|
1037
|
+
settings: l,
|
|
1038
|
+
gradient: a
|
|
976
1039
|
}) => {
|
|
977
|
-
const { style:
|
|
978
|
-
() =>
|
|
1040
|
+
const { style: t, color: c } = L(
|
|
1041
|
+
() => bt(l),
|
|
979
1042
|
[l]
|
|
980
|
-
), d = [],
|
|
1043
|
+
), d = a ? `url(#${U})` : c, u = [], g = L(
|
|
981
1044
|
() => [
|
|
982
|
-
{ x:
|
|
983
|
-
{ x: r.length +
|
|
984
|
-
{ x:
|
|
1045
|
+
{ x: s, y: s },
|
|
1046
|
+
{ x: r.length + s - I, y: s },
|
|
1047
|
+
{ x: s, y: r.length + s - I }
|
|
985
1048
|
],
|
|
986
|
-
[
|
|
1049
|
+
[s, r.length]
|
|
987
1050
|
);
|
|
988
|
-
if (
|
|
989
|
-
for (const
|
|
990
|
-
const { x:
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
x:
|
|
994
|
-
y:
|
|
995
|
-
radius:
|
|
1051
|
+
if (["rounded-sm", "rounded", "rounded-lg", "circle", "square"].includes(t)) {
|
|
1052
|
+
for (const e of g) {
|
|
1053
|
+
const { x: o, y: n } = e;
|
|
1054
|
+
t === "rounded-sm" || t === "rounded" || t === "rounded-lg" ? u.push(
|
|
1055
|
+
yt({
|
|
1056
|
+
x: o,
|
|
1057
|
+
y: n,
|
|
1058
|
+
radius: H[t]
|
|
996
1059
|
})
|
|
997
|
-
) :
|
|
998
|
-
`M ${
|
|
999
|
-
) :
|
|
1000
|
-
`M ${
|
|
1060
|
+
) : t === "circle" ? u.push(
|
|
1061
|
+
`M ${o + I / 2} ${n}a ${I / 2} ${I / 2} 0 1 0 0.01 0zzm 0 1a ${I / 2 - 1} ${I / 2 - 1} 0 1 1 -0.01 0Z`
|
|
1062
|
+
) : u.push(
|
|
1063
|
+
`M ${o} ${n}v ${I}h ${I}v -7zM ${o + 1} ${n + 1}h ${I - 2 * 1}v ${I - 2 * 1}h ${-7 + 2 * 1}z`
|
|
1001
1064
|
);
|
|
1002
1065
|
}
|
|
1003
|
-
return /* @__PURE__ */
|
|
1066
|
+
return /* @__PURE__ */ C("path", { fill: d, d: u.join(""), ...K });
|
|
1004
1067
|
}
|
|
1005
|
-
if (
|
|
1006
|
-
const
|
|
1007
|
-
return
|
|
1008
|
-
...
|
|
1009
|
-
rotation:
|
|
1010
|
-
})).map(({ x:
|
|
1011
|
-
const
|
|
1012
|
-
x:
|
|
1013
|
-
y:
|
|
1014
|
-
radius:
|
|
1068
|
+
if (t === "inpoint-sm" || t === "inpoint" || t === "inpoint-lg" || t === "outpoint-sm" || t === "outpoint" || t === "outpoint-lg" || t === "leaf-sm" || t === "leaf" || t === "leaf-lg") {
|
|
1069
|
+
const e = t === "leaf-sm" || t === "leaf" || t === "leaf-lg" ? vt : St;
|
|
1070
|
+
return g.map((o, n) => ({
|
|
1071
|
+
...o,
|
|
1072
|
+
rotation: J[t][n]
|
|
1073
|
+
})).map(({ x: o, y: n, rotation: i }) => {
|
|
1074
|
+
const h = e({
|
|
1075
|
+
x: o,
|
|
1076
|
+
y: n,
|
|
1077
|
+
radius: H[t]
|
|
1015
1078
|
});
|
|
1016
|
-
return /* @__PURE__ */
|
|
1079
|
+
return /* @__PURE__ */ C(
|
|
1017
1080
|
"path",
|
|
1018
1081
|
{
|
|
1019
|
-
fill:
|
|
1020
|
-
d:
|
|
1082
|
+
fill: d,
|
|
1083
|
+
d: h,
|
|
1021
1084
|
style: {
|
|
1022
|
-
transform: `rotate(${
|
|
1085
|
+
transform: `rotate(${i}deg)`,
|
|
1023
1086
|
transformOrigin: "center",
|
|
1024
1087
|
transformBox: "fill-box"
|
|
1025
|
-
}
|
|
1088
|
+
},
|
|
1089
|
+
...K
|
|
1026
1090
|
},
|
|
1027
|
-
`finder-patterns-outer-${
|
|
1091
|
+
`finder-patterns-outer-${t}-${o}-${n}`
|
|
1028
1092
|
);
|
|
1029
1093
|
});
|
|
1030
1094
|
}
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
if (
|
|
1095
|
+
}, xt = ({ gradient: r }) => {
|
|
1096
|
+
var l, a;
|
|
1097
|
+
if (!r)
|
|
1098
|
+
return null;
|
|
1099
|
+
const s = tt((r == null ? void 0 : r.rotation) || 0);
|
|
1100
|
+
return /* @__PURE__ */ C("defs", { children: r.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: U, gradientUnits: "userSpaceOnUse", ...s, children: (l = r.stops) == null ? void 0 : l.map((t, c) => /* @__PURE__ */ C("stop", { offset: t.offset, stopColor: t.color }, c)) }) : /* @__PURE__ */ C(
|
|
1101
|
+
"radialGradient",
|
|
1102
|
+
{
|
|
1103
|
+
id: U,
|
|
1104
|
+
gradientUnits: "userSpaceOnUse",
|
|
1105
|
+
cx: "50%",
|
|
1106
|
+
cy: "50%",
|
|
1107
|
+
r: "50%",
|
|
1108
|
+
children: (a = r.stops) == null ? void 0 : a.map((t, c) => /* @__PURE__ */ C("stop", { offset: t.offset, stopColor: t.color }, c))
|
|
1109
|
+
}
|
|
1110
|
+
) });
|
|
1111
|
+
}, kt = (r, s) => r.slice().map((l, a) => a < s.y || a >= s.y + s.h ? l : l.map((t, c) => c < s.x || c >= s.x + s.w ? t : !1)), Ht = (r, s, l, a) => {
|
|
1112
|
+
if (a == null)
|
|
1034
1113
|
return null;
|
|
1035
|
-
const t = r.length + l * 2,
|
|
1114
|
+
const t = r.length + l * 2, c = Math.floor(s * mt), d = t / s, u = (a.width || c) * d, g = (a.height || c) * d, e = a.x == null ? r.length / 2 - u / 2 : a.x * d, o = a.y == null ? r.length / 2 - g / 2 : a.y * d, n = a.opacity == null ? 1 : a.opacity;
|
|
1036
1115
|
let i = null;
|
|
1037
|
-
if (
|
|
1038
|
-
const
|
|
1039
|
-
i = { x:
|
|
1116
|
+
if (a.excavate) {
|
|
1117
|
+
const $ = Math.floor(e), f = Math.floor(o), p = Math.ceil(u + e - $), M = Math.ceil(g + o - f);
|
|
1118
|
+
i = { x: $, y: f, w: p, h: M };
|
|
1040
1119
|
}
|
|
1041
|
-
const h =
|
|
1042
|
-
return { x: e, y:
|
|
1043
|
-
},
|
|
1120
|
+
const h = a.crossOrigin;
|
|
1121
|
+
return { x: e, y: o, h: g, w: u, excavation: i, opacity: n, crossOrigin: h };
|
|
1122
|
+
}, Yt = (r) => r != null ? Math.max(Math.floor(r), 0) : ut, Gt = ({
|
|
1044
1123
|
value: r,
|
|
1045
|
-
level:
|
|
1124
|
+
level: s,
|
|
1046
1125
|
minVersion: l,
|
|
1047
|
-
marginSize:
|
|
1126
|
+
marginSize: a,
|
|
1048
1127
|
imageSettings: t,
|
|
1049
|
-
size:
|
|
1050
|
-
boostLevel:
|
|
1128
|
+
size: c,
|
|
1129
|
+
boostLevel: d
|
|
1051
1130
|
}) => {
|
|
1052
|
-
const
|
|
1053
|
-
const h = (Array.isArray(r) ? r : [r]).reduce((
|
|
1054
|
-
return
|
|
1131
|
+
const u = L(() => {
|
|
1132
|
+
const h = (Array.isArray(r) ? r : [r]).reduce(($, f) => ($.push(...y.QrSegment.makeSegments(f)), $), []);
|
|
1133
|
+
return y.QrCode.encodeSegments(
|
|
1055
1134
|
h,
|
|
1056
|
-
|
|
1135
|
+
at[s],
|
|
1057
1136
|
l,
|
|
1058
1137
|
void 0,
|
|
1059
1138
|
void 0,
|
|
1060
|
-
|
|
1139
|
+
d
|
|
1061
1140
|
);
|
|
1062
|
-
}, [r,
|
|
1063
|
-
const i =
|
|
1141
|
+
}, [r, s, l, d]), { cells: g, margin: e, numCells: o, calculatedImageSettings: n } = L(() => {
|
|
1142
|
+
const i = u.getModules(), h = Yt(a), $ = i.length + h * 2, f = Ht(i, c, h, t);
|
|
1064
1143
|
return {
|
|
1065
1144
|
cells: i,
|
|
1066
1145
|
margin: h,
|
|
1067
|
-
numCells:
|
|
1068
|
-
calculatedImageSettings:
|
|
1146
|
+
numCells: $,
|
|
1147
|
+
calculatedImageSettings: f
|
|
1069
1148
|
};
|
|
1070
|
-
}, [
|
|
1149
|
+
}, [u, c, t, a]);
|
|
1071
1150
|
return {
|
|
1072
|
-
qrcode:
|
|
1151
|
+
qrcode: u,
|
|
1073
1152
|
margin: e,
|
|
1074
|
-
cells:
|
|
1075
|
-
numCells:
|
|
1076
|
-
calculatedImageSettings:
|
|
1153
|
+
cells: g,
|
|
1154
|
+
numCells: o,
|
|
1155
|
+
calculatedImageSettings: n
|
|
1077
1156
|
};
|
|
1078
|
-
},
|
|
1157
|
+
}, qt = ({ svgRef: r, fileSize: s, fileName: l }) => {
|
|
1079
1158
|
if (!r.current) return;
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1082
|
-
const t = new XMLSerializer(),
|
|
1159
|
+
const a = r.current.cloneNode(!0);
|
|
1160
|
+
a.setAttribute("width", s.toString()), a.setAttribute("height", s.toString());
|
|
1161
|
+
const t = new XMLSerializer(), c = new Blob([t.serializeToString(a)], {
|
|
1083
1162
|
type: "image/svg+xml"
|
|
1084
|
-
}),
|
|
1085
|
-
|
|
1086
|
-
},
|
|
1163
|
+
}), d = URL.createObjectURL(c), u = document.createElement("a");
|
|
1164
|
+
u.href = d, u.download = `${l}.svg`, document.body.appendChild(u), u.click(), document.body.removeChild(u), URL.revokeObjectURL(d);
|
|
1165
|
+
}, jt = ({
|
|
1087
1166
|
svgRef: r,
|
|
1088
|
-
fileSize:
|
|
1167
|
+
fileSize: s,
|
|
1089
1168
|
fileName: l,
|
|
1090
|
-
fileFormat:
|
|
1169
|
+
fileFormat: a,
|
|
1091
1170
|
imageSettings: t,
|
|
1092
|
-
calculatedImageSettings:
|
|
1093
|
-
size:
|
|
1094
|
-
numCells:
|
|
1095
|
-
margin:
|
|
1171
|
+
calculatedImageSettings: c,
|
|
1172
|
+
size: d,
|
|
1173
|
+
numCells: u,
|
|
1174
|
+
margin: g
|
|
1096
1175
|
}) => {
|
|
1097
1176
|
if (!r.current) return;
|
|
1098
|
-
const e = document.createElement("canvas"),
|
|
1099
|
-
if (!
|
|
1100
|
-
e.width =
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
if (
|
|
1104
|
-
const
|
|
1105
|
-
|
|
1106
|
-
const
|
|
1107
|
-
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1110
|
-
},
|
|
1177
|
+
const e = document.createElement("canvas"), o = e.getContext("2d");
|
|
1178
|
+
if (!o) return;
|
|
1179
|
+
e.width = s, e.height = s;
|
|
1180
|
+
const n = new XMLSerializer().serializeToString(r.current), i = new Blob([n], { type: "image/svg+xml;charset=utf-8" }), h = URL.createObjectURL(i), $ = new Image();
|
|
1181
|
+
$.crossOrigin = "anonymous", $.src = h, $.onload = () => {
|
|
1182
|
+
if (o.drawImage($, 0, 0, s, s), URL.revokeObjectURL(h), t != null && t.src && c) {
|
|
1183
|
+
const f = new Image();
|
|
1184
|
+
f.crossOrigin = "anonymous", f.src = t.src, f.onload = () => {
|
|
1185
|
+
const p = s / d, M = u / s, E = t.width * p, m = t.x ? (c.x + g) / M : (s - E) / 2, R = t.y ? (c.y + g) / M : (s - E) / 2;
|
|
1186
|
+
o.drawImage(f, m, R, E, E);
|
|
1187
|
+
const w = a === "png" ? "image/png" : "image/jpeg", A = document.createElement("a");
|
|
1188
|
+
A.href = e.toDataURL(w), A.download = `${l}.${a}`, document.body.appendChild(A), A.click(), document.body.removeChild(A);
|
|
1189
|
+
}, f.onerror = (p) => console.error("Error loading logo:", p);
|
|
1111
1190
|
} else {
|
|
1112
|
-
const
|
|
1113
|
-
|
|
1191
|
+
const f = a === "png" ? "image/png" : "image/jpeg", p = document.createElement("a");
|
|
1192
|
+
p.href = e.toDataURL(f), p.download = `${l}.${a}`, document.body.appendChild(p), p.click(), document.body.removeChild(p);
|
|
1114
1193
|
}
|
|
1115
|
-
},
|
|
1116
|
-
},
|
|
1194
|
+
}, $.onerror = (f) => console.error("Error loading QR code:", f);
|
|
1195
|
+
}, Xt = (r) => {
|
|
1117
1196
|
const {
|
|
1118
|
-
ref:
|
|
1197
|
+
ref: s,
|
|
1119
1198
|
value: l,
|
|
1120
|
-
size:
|
|
1121
|
-
level: t =
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1199
|
+
size: a = lt,
|
|
1200
|
+
level: t = ct,
|
|
1201
|
+
background: c,
|
|
1202
|
+
gradient: d,
|
|
1203
|
+
minVersion: u = ht,
|
|
1204
|
+
boostLevel: g,
|
|
1205
|
+
marginSize: e,
|
|
1206
|
+
finderPatternOuterSettings: o,
|
|
1127
1207
|
finderPatternInnerSettings: n,
|
|
1128
|
-
dataModulesSettings:
|
|
1129
|
-
imageSettings:
|
|
1130
|
-
svgProps:
|
|
1131
|
-
} = r,
|
|
1208
|
+
dataModulesSettings: i,
|
|
1209
|
+
imageSettings: h,
|
|
1210
|
+
svgProps: $
|
|
1211
|
+
} = r, f = st(null), { margin: p, cells: M, numCells: E, calculatedImageSettings: m } = Gt({
|
|
1132
1212
|
value: l,
|
|
1133
1213
|
level: t,
|
|
1134
|
-
minVersion:
|
|
1135
|
-
boostLevel:
|
|
1136
|
-
marginSize:
|
|
1137
|
-
imageSettings:
|
|
1138
|
-
size:
|
|
1214
|
+
minVersion: u,
|
|
1215
|
+
boostLevel: g,
|
|
1216
|
+
marginSize: e,
|
|
1217
|
+
imageSettings: h,
|
|
1218
|
+
size: a
|
|
1139
1219
|
});
|
|
1140
|
-
|
|
1141
|
-
svg:
|
|
1220
|
+
it(s, () => ({
|
|
1221
|
+
svg: f.current,
|
|
1142
1222
|
download: ({
|
|
1143
|
-
name:
|
|
1144
|
-
format:
|
|
1145
|
-
size:
|
|
1223
|
+
name: N = pt,
|
|
1224
|
+
format: P = "svg",
|
|
1225
|
+
size: k = 500
|
|
1146
1226
|
}) => {
|
|
1147
|
-
|
|
1148
|
-
svgRef:
|
|
1149
|
-
fileSize:
|
|
1150
|
-
fileName:
|
|
1151
|
-
fileFormat:
|
|
1152
|
-
imageSettings:
|
|
1153
|
-
calculatedImageSettings:
|
|
1154
|
-
size:
|
|
1155
|
-
numCells:
|
|
1156
|
-
margin:
|
|
1227
|
+
f.current && (P === "svg" ? qt({ svgRef: f, fileSize: k, fileName: N }) : jt({
|
|
1228
|
+
svgRef: f,
|
|
1229
|
+
fileSize: k,
|
|
1230
|
+
fileName: N,
|
|
1231
|
+
fileFormat: P,
|
|
1232
|
+
imageSettings: h,
|
|
1233
|
+
calculatedImageSettings: m,
|
|
1234
|
+
size: a,
|
|
1235
|
+
numCells: E,
|
|
1236
|
+
margin: p
|
|
1157
1237
|
}));
|
|
1158
1238
|
}
|
|
1159
1239
|
}));
|
|
1160
|
-
let
|
|
1161
|
-
|
|
1240
|
+
let R = M, w = null;
|
|
1241
|
+
h != null && m != null && (m.excavation != null && (R = kt(M, m.excavation)), w = /* @__PURE__ */ C(
|
|
1162
1242
|
"image",
|
|
1163
1243
|
{
|
|
1164
|
-
href:
|
|
1165
|
-
height:
|
|
1166
|
-
width:
|
|
1167
|
-
x:
|
|
1168
|
-
y:
|
|
1244
|
+
href: h.src,
|
|
1245
|
+
height: m.h,
|
|
1246
|
+
width: m.w,
|
|
1247
|
+
x: m.x + p,
|
|
1248
|
+
y: m.y + p,
|
|
1169
1249
|
preserveAspectRatio: "none",
|
|
1170
|
-
opacity:
|
|
1171
|
-
crossOrigin:
|
|
1250
|
+
opacity: m.opacity,
|
|
1251
|
+
crossOrigin: m.crossOrigin
|
|
1172
1252
|
}
|
|
1173
|
-
))
|
|
1253
|
+
));
|
|
1254
|
+
const A = {
|
|
1255
|
+
modules: R,
|
|
1256
|
+
margin: p,
|
|
1257
|
+
gradient: d
|
|
1258
|
+
};
|
|
1259
|
+
return /* @__PURE__ */ V(
|
|
1174
1260
|
"svg",
|
|
1175
1261
|
{
|
|
1176
|
-
height:
|
|
1177
|
-
width:
|
|
1178
|
-
viewBox: `0 0 ${
|
|
1179
|
-
ref:
|
|
1262
|
+
height: a,
|
|
1263
|
+
width: a,
|
|
1264
|
+
viewBox: `0 0 ${E} ${E}`,
|
|
1265
|
+
ref: f,
|
|
1180
1266
|
role: "img",
|
|
1181
|
-
"aria-label": (
|
|
1182
|
-
|
|
1267
|
+
"aria-label": ($ == null ? void 0 : $["aria-label"]) || "QR Code",
|
|
1268
|
+
...$,
|
|
1183
1269
|
children: [
|
|
1184
|
-
/* @__PURE__ */
|
|
1185
|
-
/* @__PURE__ */
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
settings: e
|
|
1191
|
-
}
|
|
1192
|
-
),
|
|
1193
|
-
/* @__PURE__ */ I(
|
|
1194
|
-
Pt,
|
|
1195
|
-
{
|
|
1196
|
-
modules: A,
|
|
1197
|
-
margin: u,
|
|
1198
|
-
settings: n
|
|
1199
|
-
}
|
|
1200
|
-
),
|
|
1201
|
-
/* @__PURE__ */ I(It, { modules: A, margin: u, settings: o }),
|
|
1202
|
-
g
|
|
1270
|
+
/* @__PURE__ */ C(xt, { gradient: d }),
|
|
1271
|
+
/* @__PURE__ */ C(Rt, { background: c, numCells: E }),
|
|
1272
|
+
/* @__PURE__ */ C(zt, { settings: o, ...A }),
|
|
1273
|
+
/* @__PURE__ */ C(Bt, { settings: n, ...A }),
|
|
1274
|
+
/* @__PURE__ */ C(Ft, { settings: i, ...A }),
|
|
1275
|
+
w
|
|
1203
1276
|
]
|
|
1204
1277
|
}
|
|
1205
1278
|
);
|
|
1206
1279
|
};
|
|
1207
|
-
|
|
1280
|
+
Xt.displayName = "ReactQRCode";
|
|
1208
1281
|
export {
|
|
1209
|
-
|
|
1282
|
+
Xt as ReactQRCode
|
|
1210
1283
|
};
|