@lglab/react-qr-code 1.0.1 → 1.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.
- package/README.md +6 -0
- package/dist/index.d.ts +14 -5
- package/dist/index.es.js +578 -520
- package/package.json +5 -5
package/dist/index.es.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsx as I, jsxs as Z } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as T, useCallback as K, useRef as V, useImperativeHandle as _ } 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 L;
|
|
9
9
|
((r) => {
|
|
10
|
-
const
|
|
10
|
+
const c = class c {
|
|
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(
|
|
17
|
-
if (this.version =
|
|
16
|
+
constructor(e, n, o, i) {
|
|
17
|
+
if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < c.MIN_VERSION || e > c.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
|
-
this.size =
|
|
21
|
+
this.size = e * 4 + 17;
|
|
22
22
|
let h = [];
|
|
23
|
-
for (let
|
|
23
|
+
for (let u = 0; u < this.size; u++)
|
|
24
24
|
h.push(!1);
|
|
25
|
-
for (let
|
|
25
|
+
for (let u = 0; u < this.size; u++)
|
|
26
26
|
this.modules.push(h.slice()), this.isFunction.push(h.slice());
|
|
27
27
|
this.drawFunctionPatterns();
|
|
28
|
-
const p = this.addEccAndInterleave(
|
|
28
|
+
const p = this.addEccAndInterleave(o);
|
|
29
29
|
if (this.drawCodewords(p), i == -1) {
|
|
30
|
-
let
|
|
31
|
-
for (let
|
|
32
|
-
this.applyMask(
|
|
33
|
-
const
|
|
34
|
-
|
|
30
|
+
let u = 1e9;
|
|
31
|
+
for (let M = 0; M < 8; M++) {
|
|
32
|
+
this.applyMask(M), this.drawFormatBits(M);
|
|
33
|
+
const f = this.getPenaltyScore();
|
|
34
|
+
f < u && (i = M, u = f), this.applyMask(M);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
t(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
|
|
38
38
|
}
|
|
39
39
|
/*-- Static factory functions (high level) --*/
|
|
40
40
|
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
|
@@ -42,17 +42,17 @@ var T;
|
|
|
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(
|
|
46
|
-
const
|
|
47
|
-
return
|
|
45
|
+
static encodeText(e, n) {
|
|
46
|
+
const o = r.QrSegment.makeSegments(e);
|
|
47
|
+
return c.encodeSegments(o, n);
|
|
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(
|
|
54
|
-
const
|
|
55
|
-
return
|
|
53
|
+
static encodeBinary(e, n) {
|
|
54
|
+
const o = r.QrSegment.makeBytes(e);
|
|
55
|
+
return c.encodeSegments([o], n);
|
|
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 T;
|
|
|
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(
|
|
68
|
-
if (!(
|
|
67
|
+
static encodeSegments(e, n, o = 1, i = 40, h = -1, p = !0) {
|
|
68
|
+
if (!(c.MIN_VERSION <= o && o <= i && i <= c.MAX_VERSION) || h < -1 || h > 7)
|
|
69
69
|
throw new RangeError("Invalid value");
|
|
70
|
-
let
|
|
71
|
-
for (
|
|
72
|
-
const
|
|
73
|
-
if (
|
|
74
|
-
|
|
70
|
+
let u, M;
|
|
71
|
+
for (u = o; ; u++) {
|
|
72
|
+
const g = c.getNumDataCodewords(u, n) * 8, R = d.getTotalBits(e, u);
|
|
73
|
+
if (R <= g) {
|
|
74
|
+
M = R;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
if (
|
|
77
|
+
if (u >= i)
|
|
78
78
|
throw new RangeError("Data too long");
|
|
79
79
|
}
|
|
80
|
-
for (const
|
|
81
|
-
p &&
|
|
82
|
-
let
|
|
83
|
-
for (const
|
|
84
|
-
|
|
85
|
-
for (const
|
|
86
|
-
|
|
80
|
+
for (const g of [c.Ecc.MEDIUM, c.Ecc.QUARTILE, c.Ecc.HIGH])
|
|
81
|
+
p && M <= c.getNumDataCodewords(u, g) * 8 && (n = g);
|
|
82
|
+
let f = [];
|
|
83
|
+
for (const g of e) {
|
|
84
|
+
l(g.mode.modeBits, 4, f), l(g.numChars, g.mode.numCharCountBits(u), f);
|
|
85
|
+
for (const R of g.getData())
|
|
86
|
+
f.push(R);
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
for (let
|
|
92
|
-
|
|
88
|
+
t(f.length == M);
|
|
89
|
+
const E = c.getNumDataCodewords(u, n) * 8;
|
|
90
|
+
t(f.length <= E), l(0, Math.min(4, E - f.length), f), l(0, (8 - f.length % 8) % 8, f), t(f.length % 8 == 0);
|
|
91
|
+
for (let g = 236; f.length < E; g ^= 253)
|
|
92
|
+
l(g, 8, f);
|
|
93
93
|
let A = [];
|
|
94
|
-
for (; A.length * 8 <
|
|
94
|
+
for (; A.length * 8 < f.length; )
|
|
95
95
|
A.push(0);
|
|
96
|
-
return
|
|
96
|
+
return f.forEach((g, R) => A[R >>> 3] |= g << 7 - (R & 7)), new c(u, n, A, 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(
|
|
103
|
-
return 0 <=
|
|
102
|
+
getModule(e, n) {
|
|
103
|
+
return 0 <= e && e < this.size && 0 <= n && n < this.size && this.modules[n][e];
|
|
104
104
|
}
|
|
105
105
|
// Modified to expose modules for easy access
|
|
106
106
|
getModules() {
|
|
@@ -109,24 +109,24 @@ var T;
|
|
|
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 o = 0; o < this.size; o++)
|
|
113
|
+
this.setFunctionModule(6, o, o % 2 == 0), this.setFunctionModule(o, 6, o % 2 == 0);
|
|
114
114
|
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
|
115
|
-
const
|
|
116
|
-
for (let
|
|
117
|
-
for (let i = 0; i <
|
|
118
|
-
|
|
115
|
+
const e = this.getAlignmentPatternPositions(), n = e.length;
|
|
116
|
+
for (let o = 0; o < n; o++)
|
|
117
|
+
for (let i = 0; i < n; i++)
|
|
118
|
+
o == 0 && i == 0 || o == 0 && i == n - 1 || o == n - 1 && i == 0 || this.drawAlignmentPattern(e[o], 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
|
-
drawFormatBits(
|
|
124
|
-
const
|
|
125
|
-
let
|
|
123
|
+
drawFormatBits(e) {
|
|
124
|
+
const n = this.errorCorrectionLevel.formatBits << 3 | e;
|
|
125
|
+
let o = n;
|
|
126
126
|
for (let h = 0; h < 10; h++)
|
|
127
|
-
|
|
128
|
-
const i = (
|
|
129
|
-
|
|
127
|
+
o = o << 1 ^ (o >>> 9) * 1335;
|
|
128
|
+
const i = (n << 10 | o) ^ 21522;
|
|
129
|
+
t(i >>> 15 == 0);
|
|
130
130
|
for (let h = 0; h <= 5; h++)
|
|
131
131
|
this.setFunctionModule(8, h, s(i, h));
|
|
132
132
|
this.setFunctionModule(8, 7, s(i, 6)), this.setFunctionModule(8, 8, s(i, 7)), this.setFunctionModule(7, 8, s(i, 8));
|
|
@@ -143,144 +143,144 @@ var T;
|
|
|
143
143
|
drawVersion() {
|
|
144
144
|
if (this.version < 7)
|
|
145
145
|
return;
|
|
146
|
-
let
|
|
147
|
-
for (let
|
|
148
|
-
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
for (let
|
|
152
|
-
const i = s(
|
|
146
|
+
let e = this.version;
|
|
147
|
+
for (let o = 0; o < 12; o++)
|
|
148
|
+
e = e << 1 ^ (e >>> 11) * 7973;
|
|
149
|
+
const n = this.version << 12 | e;
|
|
150
|
+
t(n >>> 18 == 0);
|
|
151
|
+
for (let o = 0; o < 18; o++) {
|
|
152
|
+
const i = s(n, o), h = this.size - 11 + o % 3, p = Math.floor(o / 3);
|
|
153
153
|
this.setFunctionModule(h, p, i), this.setFunctionModule(p, 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(
|
|
159
|
-
for (let
|
|
158
|
+
drawFinderPattern(e, n) {
|
|
159
|
+
for (let o = -4; o <= 4; o++)
|
|
160
160
|
for (let i = -4; i <= 4; i++) {
|
|
161
|
-
const h = Math.max(Math.abs(i), Math.abs(
|
|
162
|
-
0 <= p && p < this.size && 0 <=
|
|
161
|
+
const h = Math.max(Math.abs(i), Math.abs(o)), p = e + i, u = n + o;
|
|
162
|
+
0 <= p && p < this.size && 0 <= u && u < this.size && this.setFunctionModule(p, u, 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(
|
|
168
|
-
for (let
|
|
167
|
+
drawAlignmentPattern(e, n) {
|
|
168
|
+
for (let o = -2; o <= 2; o++)
|
|
169
169
|
for (let i = -2; i <= 2; i++)
|
|
170
|
-
this.setFunctionModule(
|
|
170
|
+
this.setFunctionModule(e + i, n + o, Math.max(Math.abs(i), Math.abs(o)) != 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(
|
|
175
|
-
this.modules[
|
|
174
|
+
setFunctionModule(e, n, o) {
|
|
175
|
+
this.modules[n][e] = o, this.isFunction[n][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
|
-
addEccAndInterleave(
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
180
|
+
addEccAndInterleave(e) {
|
|
181
|
+
const n = this.version, o = this.errorCorrectionLevel;
|
|
182
|
+
if (e.length != c.getNumDataCodewords(n, o))
|
|
183
183
|
throw new RangeError("Invalid argument");
|
|
184
|
-
const i =
|
|
185
|
-
let
|
|
186
|
-
const
|
|
187
|
-
for (let
|
|
188
|
-
let
|
|
189
|
-
|
|
190
|
-
const
|
|
191
|
-
|
|
184
|
+
const i = c.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][n], h = c.ECC_CODEWORDS_PER_BLOCK[o.ordinal][n], p = Math.floor(c.getNumRawDataModules(n) / 8), u = i - p % i, M = Math.floor(p / i);
|
|
185
|
+
let f = [];
|
|
186
|
+
const E = c.reedSolomonComputeDivisor(h);
|
|
187
|
+
for (let g = 0, R = 0; g < i; g++) {
|
|
188
|
+
let w = e.slice(R, R + M - h + (g < u ? 0 : 1));
|
|
189
|
+
R += w.length;
|
|
190
|
+
const N = c.reedSolomonComputeRemainder(w, E);
|
|
191
|
+
g < u && w.push(0), f.push(w.concat(N));
|
|
192
192
|
}
|
|
193
193
|
let A = [];
|
|
194
|
-
for (let
|
|
195
|
-
|
|
196
|
-
(
|
|
194
|
+
for (let g = 0; g < f[0].length; g++)
|
|
195
|
+
f.forEach((R, w) => {
|
|
196
|
+
(g != M - h || w >= u) && A.push(R[g]);
|
|
197
197
|
});
|
|
198
|
-
return
|
|
198
|
+
return t(A.length == p), A;
|
|
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
|
-
drawCodewords(
|
|
203
|
-
if (
|
|
202
|
+
drawCodewords(e) {
|
|
203
|
+
if (e.length != Math.floor(c.getNumRawDataModules(this.version) / 8))
|
|
204
204
|
throw new RangeError("Invalid argument");
|
|
205
|
-
let
|
|
206
|
-
for (let
|
|
207
|
-
|
|
205
|
+
let n = 0;
|
|
206
|
+
for (let o = this.size - 1; o >= 1; o -= 2) {
|
|
207
|
+
o == 6 && (o = 5);
|
|
208
208
|
for (let i = 0; i < this.size; i++)
|
|
209
209
|
for (let h = 0; h < 2; h++) {
|
|
210
|
-
const p =
|
|
211
|
-
!this.isFunction[
|
|
210
|
+
const p = o - h, M = (o + 1 & 2) == 0 ? this.size - 1 - i : i;
|
|
211
|
+
!this.isFunction[M][p] && n < e.length * 8 && (this.modules[M][p] = s(e[n >>> 3], 7 - (n & 7)), n++);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
t(n == 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
|
|
218
218
|
// before masking. Due to the arithmetic of XOR, calling applyMask() with
|
|
219
219
|
// the same mask value a second time will undo the mask. A final well-formed
|
|
220
220
|
// QR Code needs exactly one (not zero, two, etc.) mask applied.
|
|
221
|
-
applyMask(
|
|
222
|
-
if (
|
|
221
|
+
applyMask(e) {
|
|
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 n = 0; n < this.size; n++)
|
|
225
|
+
for (let o = 0; o < this.size; o++) {
|
|
226
226
|
let i;
|
|
227
|
-
switch (
|
|
227
|
+
switch (e) {
|
|
228
228
|
case 0:
|
|
229
|
-
i = (
|
|
229
|
+
i = (o + n) % 2 == 0;
|
|
230
230
|
break;
|
|
231
231
|
case 1:
|
|
232
|
-
i =
|
|
232
|
+
i = n % 2 == 0;
|
|
233
233
|
break;
|
|
234
234
|
case 2:
|
|
235
|
-
i =
|
|
235
|
+
i = o % 3 == 0;
|
|
236
236
|
break;
|
|
237
237
|
case 3:
|
|
238
|
-
i = (
|
|
238
|
+
i = (o + n) % 3 == 0;
|
|
239
239
|
break;
|
|
240
240
|
case 4:
|
|
241
|
-
i = (Math.floor(
|
|
241
|
+
i = (Math.floor(o / 3) + Math.floor(n / 2)) % 2 == 0;
|
|
242
242
|
break;
|
|
243
243
|
case 5:
|
|
244
|
-
i =
|
|
244
|
+
i = o * n % 2 + o * n % 3 == 0;
|
|
245
245
|
break;
|
|
246
246
|
case 6:
|
|
247
|
-
i = (
|
|
247
|
+
i = (o * n % 2 + o * n % 3) % 2 == 0;
|
|
248
248
|
break;
|
|
249
249
|
case 7:
|
|
250
|
-
i = ((
|
|
250
|
+
i = ((o + n) % 2 + o * n % 3) % 2 == 0;
|
|
251
251
|
break;
|
|
252
252
|
default:
|
|
253
253
|
throw new Error("Unreachable");
|
|
254
254
|
}
|
|
255
|
-
!this.isFunction[
|
|
255
|
+
!this.isFunction[n][o] && i && (this.modules[n][o] = !this.modules[n][o]);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
258
|
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
259
259
|
// This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
|
|
260
260
|
getPenaltyScore() {
|
|
261
|
-
let
|
|
261
|
+
let e = 0;
|
|
262
262
|
for (let h = 0; h < this.size; h++) {
|
|
263
|
-
let p = !1,
|
|
264
|
-
for (let
|
|
265
|
-
this.modules[h][
|
|
266
|
-
|
|
263
|
+
let p = !1, u = 0, M = [0, 0, 0, 0, 0, 0, 0];
|
|
264
|
+
for (let f = 0; f < this.size; f++)
|
|
265
|
+
this.modules[h][f] == p ? (u++, u == 5 ? e += c.PENALTY_N1 : u > 5 && e++) : (this.finderPenaltyAddHistory(u, M), p || (e += this.finderPenaltyCountPatterns(M) * c.PENALTY_N3), p = this.modules[h][f], u = 1);
|
|
266
|
+
e += this.finderPenaltyTerminateAndCount(p, u, M) * c.PENALTY_N3;
|
|
267
267
|
}
|
|
268
268
|
for (let h = 0; h < this.size; h++) {
|
|
269
|
-
let p = !1,
|
|
270
|
-
for (let
|
|
271
|
-
this.modules[
|
|
272
|
-
|
|
269
|
+
let p = !1, u = 0, M = [0, 0, 0, 0, 0, 0, 0];
|
|
270
|
+
for (let f = 0; f < this.size; f++)
|
|
271
|
+
this.modules[f][h] == p ? (u++, u == 5 ? e += c.PENALTY_N1 : u > 5 && e++) : (this.finderPenaltyAddHistory(u, M), p || (e += this.finderPenaltyCountPatterns(M) * c.PENALTY_N3), p = this.modules[f][h], u = 1);
|
|
272
|
+
e += this.finderPenaltyTerminateAndCount(p, u, M) * c.PENALTY_N3;
|
|
273
273
|
}
|
|
274
274
|
for (let h = 0; h < this.size - 1; h++)
|
|
275
275
|
for (let p = 0; p < this.size - 1; p++) {
|
|
276
|
-
const
|
|
277
|
-
|
|
276
|
+
const u = this.modules[h][p];
|
|
277
|
+
u == this.modules[h][p + 1] && u == this.modules[h + 1][p] && u == this.modules[h + 1][p + 1] && (e += c.PENALTY_N2);
|
|
278
278
|
}
|
|
279
|
-
let
|
|
279
|
+
let n = 0;
|
|
280
280
|
for (const h of this.modules)
|
|
281
|
-
|
|
282
|
-
const
|
|
283
|
-
return
|
|
281
|
+
n = h.reduce((p, u) => p + (u ? 1 : 0), n);
|
|
282
|
+
const o = this.size * this.size, i = Math.ceil(Math.abs(n * 20 - o * 10) / o) - 1;
|
|
283
|
+
return t(0 <= i && i <= 9), e += i * c.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 T;
|
|
|
290
290
|
if (this.version == 1)
|
|
291
291
|
return [];
|
|
292
292
|
{
|
|
293
|
-
const
|
|
294
|
-
let
|
|
295
|
-
for (let i = this.size - 7;
|
|
296
|
-
|
|
297
|
-
return
|
|
293
|
+
const e = Math.floor(this.version / 7) + 2, n = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
|
|
294
|
+
let o = [6];
|
|
295
|
+
for (let i = this.size - 7; o.length < e; i -= n)
|
|
296
|
+
o.splice(1, 0, i);
|
|
297
|
+
return o;
|
|
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
|
-
static getNumRawDataModules(
|
|
304
|
-
if (
|
|
303
|
+
static getNumRawDataModules(e) {
|
|
304
|
+
if (e < c.MIN_VERSION || e > c.MAX_VERSION)
|
|
305
305
|
throw new RangeError("Version number out of range");
|
|
306
|
-
let
|
|
307
|
-
if (
|
|
308
|
-
const
|
|
309
|
-
|
|
306
|
+
let n = (16 * e + 128) * e + 64;
|
|
307
|
+
if (e >= 2) {
|
|
308
|
+
const o = Math.floor(e / 7) + 2;
|
|
309
|
+
n -= (25 * o - 10) * o - 55, e >= 7 && (n -= 36);
|
|
310
310
|
}
|
|
311
|
-
return
|
|
311
|
+
return t(208 <= n && n <= 29648), n;
|
|
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(
|
|
317
|
-
return Math.floor(
|
|
316
|
+
static getNumDataCodewords(e, n) {
|
|
317
|
+
return Math.floor(c.getNumRawDataModules(e) / 8) - c.ECC_CODEWORDS_PER_BLOCK[n.ordinal][e] * c.NUM_ERROR_CORRECTION_BLOCKS[n.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
|
-
static reedSolomonComputeDivisor(
|
|
322
|
-
if (
|
|
321
|
+
static reedSolomonComputeDivisor(e) {
|
|
322
|
+
if (e < 1 || e > 255)
|
|
323
323
|
throw new RangeError("Degree out of range");
|
|
324
|
-
let
|
|
325
|
-
for (let i = 0; i <
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
let
|
|
329
|
-
for (let i = 0; i <
|
|
330
|
-
for (let h = 0; h <
|
|
331
|
-
|
|
332
|
-
|
|
324
|
+
let n = [];
|
|
325
|
+
for (let i = 0; i < e - 1; i++)
|
|
326
|
+
n.push(0);
|
|
327
|
+
n.push(1);
|
|
328
|
+
let o = 1;
|
|
329
|
+
for (let i = 0; i < e; i++) {
|
|
330
|
+
for (let h = 0; h < n.length; h++)
|
|
331
|
+
n[h] = c.reedSolomonMultiply(n[h], o), h + 1 < n.length && (n[h] ^= n[h + 1]);
|
|
332
|
+
o = c.reedSolomonMultiply(o, 2);
|
|
333
333
|
}
|
|
334
|
-
return
|
|
334
|
+
return n;
|
|
335
335
|
}
|
|
336
336
|
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
|
337
|
-
static reedSolomonComputeRemainder(
|
|
338
|
-
let
|
|
339
|
-
for (const i of
|
|
340
|
-
const h = i ^
|
|
341
|
-
|
|
337
|
+
static reedSolomonComputeRemainder(e, n) {
|
|
338
|
+
let o = n.map((i) => 0);
|
|
339
|
+
for (const i of e) {
|
|
340
|
+
const h = i ^ o.shift();
|
|
341
|
+
o.push(0), n.forEach((p, u) => o[u] ^= c.reedSolomonMultiply(p, h));
|
|
342
342
|
}
|
|
343
|
-
return
|
|
343
|
+
return o;
|
|
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(
|
|
348
|
-
if (
|
|
347
|
+
static reedSolomonMultiply(e, n) {
|
|
348
|
+
if (e >>> 8 || n >>> 8)
|
|
349
349
|
throw new RangeError("Byte out of range");
|
|
350
|
-
let
|
|
350
|
+
let o = 0;
|
|
351
351
|
for (let i = 7; i >= 0; i--)
|
|
352
|
-
|
|
353
|
-
return
|
|
352
|
+
o = o << 1 ^ (o >>> 7) * 285, o ^= (n >>> i & 1) * e;
|
|
353
|
+
return t(o >>> 8 == 0), o;
|
|
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
|
-
finderPenaltyCountPatterns(
|
|
358
|
-
const
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
return (
|
|
357
|
+
finderPenaltyCountPatterns(e) {
|
|
358
|
+
const n = e[1];
|
|
359
|
+
t(n <= this.size * 3);
|
|
360
|
+
const o = n > 0 && e[2] == n && e[3] == n * 3 && e[4] == n && e[5] == n;
|
|
361
|
+
return (o && e[0] >= n * 4 && e[6] >= n ? 1 : 0) + (o && e[6] >= n * 4 && e[0] >= n ? 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(
|
|
365
|
-
return
|
|
364
|
+
finderPenaltyTerminateAndCount(e, n, o) {
|
|
365
|
+
return e && (this.finderPenaltyAddHistory(n, o), n = 0), n += this.size, this.finderPenaltyAddHistory(n, o), this.finderPenaltyCountPatterns(o);
|
|
366
366
|
}
|
|
367
367
|
// Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
|
|
368
|
-
finderPenaltyAddHistory(
|
|
369
|
-
|
|
368
|
+
finderPenaltyAddHistory(e, n) {
|
|
369
|
+
n[0] == 0 && (e += this.size), n.pop(), n.unshift(e);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
|
-
|
|
372
|
+
c.MIN_VERSION = 1, c.MAX_VERSION = 40, c.PENALTY_N1 = 3, c.PENALTY_N2 = 3, c.PENALTY_N3 = 40, c.PENALTY_N4 = 10, c.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 T;
|
|
|
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
|
+
], c.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,19 +392,19 @@ var T;
|
|
|
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
|
|
398
|
-
if (
|
|
395
|
+
let a = c;
|
|
396
|
+
r.QrCode = a;
|
|
397
|
+
function l(m, e, n) {
|
|
398
|
+
if (e < 0 || e > 31 || m >>> e)
|
|
399
399
|
throw new RangeError("Value out of range");
|
|
400
|
-
for (let
|
|
401
|
-
|
|
400
|
+
for (let o = e - 1; o >= 0; o--)
|
|
401
|
+
n.push(m >>> o & 1);
|
|
402
402
|
}
|
|
403
|
-
function s(
|
|
404
|
-
return (
|
|
403
|
+
function s(m, e) {
|
|
404
|
+
return (m >>> e & 1) != 0;
|
|
405
405
|
}
|
|
406
|
-
function
|
|
407
|
-
if (!
|
|
406
|
+
function t(m) {
|
|
407
|
+
if (!m)
|
|
408
408
|
throw new Error("Assertion error");
|
|
409
409
|
}
|
|
410
410
|
const $ = class $ {
|
|
@@ -412,76 +412,76 @@ var T;
|
|
|
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(
|
|
416
|
-
if (this.mode =
|
|
415
|
+
constructor(e, n, o) {
|
|
416
|
+
if (this.mode = e, this.numChars = n, this.bitData = o, n < 0)
|
|
417
417
|
throw new RangeError("Invalid argument");
|
|
418
|
-
this.bitData =
|
|
418
|
+
this.bitData = o.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
|
-
static makeBytes(
|
|
425
|
-
let
|
|
426
|
-
for (const
|
|
427
|
-
|
|
428
|
-
return new $($.Mode.BYTE,
|
|
424
|
+
static makeBytes(e) {
|
|
425
|
+
let n = [];
|
|
426
|
+
for (const o of e)
|
|
427
|
+
l(o, 8, n);
|
|
428
|
+
return new $($.Mode.BYTE, e.length, n);
|
|
429
429
|
}
|
|
430
430
|
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
431
|
-
static makeNumeric(
|
|
432
|
-
if (!$.isNumeric(
|
|
431
|
+
static makeNumeric(e) {
|
|
432
|
+
if (!$.isNumeric(e))
|
|
433
433
|
throw new RangeError("String contains non-numeric characters");
|
|
434
|
-
let
|
|
435
|
-
for (let
|
|
436
|
-
const i = Math.min(
|
|
437
|
-
|
|
434
|
+
let n = [];
|
|
435
|
+
for (let o = 0; o < e.length; ) {
|
|
436
|
+
const i = Math.min(e.length - o, 3);
|
|
437
|
+
l(parseInt(e.substring(o, o + i), 10), i * 3 + 1, n), o += i;
|
|
438
438
|
}
|
|
439
|
-
return new $($.Mode.NUMERIC,
|
|
439
|
+
return new $($.Mode.NUMERIC, e.length, n);
|
|
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
|
-
static makeAlphanumeric(
|
|
445
|
-
if (!$.isAlphanumeric(
|
|
444
|
+
static makeAlphanumeric(e) {
|
|
445
|
+
if (!$.isAlphanumeric(e))
|
|
446
446
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
447
|
-
let
|
|
448
|
-
for (
|
|
449
|
-
let i = $.ALPHANUMERIC_CHARSET.indexOf(
|
|
450
|
-
i += $.ALPHANUMERIC_CHARSET.indexOf(
|
|
447
|
+
let n = [], o;
|
|
448
|
+
for (o = 0; o + 2 <= e.length; o += 2) {
|
|
449
|
+
let i = $.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)) * 45;
|
|
450
|
+
i += $.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o + 1)), l(i, 11, n);
|
|
451
451
|
}
|
|
452
|
-
return
|
|
452
|
+
return o < e.length && l($.ALPHANUMERIC_CHARSET.indexOf(e.charAt(o)), 6, n), new $($.Mode.ALPHANUMERIC, e.length, n);
|
|
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
|
-
static makeSegments(
|
|
457
|
-
return
|
|
456
|
+
static makeSegments(e) {
|
|
457
|
+
return e == "" ? [] : $.isNumeric(e) ? [$.makeNumeric(e)] : $.isAlphanumeric(e) ? [$.makeAlphanumeric(e)] : [$.makeBytes($.toUtf8ByteArray(e))];
|
|
458
458
|
}
|
|
459
459
|
// Returns a segment representing an Extended Channel Interpretation
|
|
460
460
|
// (ECI) designator with the given assignment value.
|
|
461
|
-
static makeEci(
|
|
462
|
-
let
|
|
463
|
-
if (
|
|
461
|
+
static makeEci(e) {
|
|
462
|
+
let n = [];
|
|
463
|
+
if (e < 0)
|
|
464
464
|
throw new RangeError("ECI assignment value out of range");
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
else if (
|
|
468
|
-
|
|
469
|
-
else if (
|
|
470
|
-
|
|
465
|
+
if (e < 128)
|
|
466
|
+
l(e, 8, n);
|
|
467
|
+
else if (e < 16384)
|
|
468
|
+
l(2, 2, n), l(e, 14, n);
|
|
469
|
+
else if (e < 1e6)
|
|
470
|
+
l(6, 3, n), l(e, 21, n);
|
|
471
471
|
else
|
|
472
472
|
throw new RangeError("ECI assignment value out of range");
|
|
473
|
-
return new $($.Mode.ECI, 0,
|
|
473
|
+
return new $($.Mode.ECI, 0, n);
|
|
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
|
-
static isNumeric(
|
|
478
|
-
return $.NUMERIC_REGEX.test(
|
|
477
|
+
static isNumeric(e) {
|
|
478
|
+
return $.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
|
-
static isAlphanumeric(
|
|
484
|
-
return $.ALPHANUMERIC_REGEX.test(
|
|
483
|
+
static isAlphanumeric(e) {
|
|
484
|
+
return $.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 T;
|
|
|
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(
|
|
494
|
-
let
|
|
495
|
-
for (const i of
|
|
496
|
-
const h = i.mode.numCharCountBits(
|
|
493
|
+
static getTotalBits(e, n) {
|
|
494
|
+
let o = 0;
|
|
495
|
+
for (const i of e) {
|
|
496
|
+
const h = i.mode.numCharCountBits(n);
|
|
497
497
|
if (i.numChars >= 1 << h)
|
|
498
498
|
return 1 / 0;
|
|
499
|
-
|
|
499
|
+
o += 4 + h + i.bitData.length;
|
|
500
500
|
}
|
|
501
|
-
return
|
|
501
|
+
return o;
|
|
502
502
|
}
|
|
503
503
|
// Returns a new array of bytes representing the given string encoded in UTF-8.
|
|
504
|
-
static toUtf8ByteArray(
|
|
505
|
-
|
|
506
|
-
let
|
|
507
|
-
for (let
|
|
508
|
-
|
|
509
|
-
return
|
|
504
|
+
static toUtf8ByteArray(e) {
|
|
505
|
+
e = encodeURI(e);
|
|
506
|
+
let n = [];
|
|
507
|
+
for (let o = 0; o < e.length; o++)
|
|
508
|
+
e.charAt(o) != "%" ? n.push(e.charCodeAt(o)) : (n.push(parseInt(e.substring(o + 1, o + 3), 16)), o += 2);
|
|
509
|
+
return n;
|
|
510
510
|
}
|
|
511
511
|
};
|
|
512
512
|
$.NUMERIC_REGEX = /^[0-9]*$/, $.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, $.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
513
|
-
let
|
|
514
|
-
r.QrSegment =
|
|
515
|
-
})(
|
|
513
|
+
let d = $;
|
|
514
|
+
r.QrSegment = d;
|
|
515
|
+
})(L || (L = {}));
|
|
516
516
|
((r) => {
|
|
517
|
-
((
|
|
517
|
+
((a) => {
|
|
518
518
|
const s = class s {
|
|
519
519
|
// The QR Code can tolerate about 30% erroneous codewords
|
|
520
520
|
/*-- Constructor and fields --*/
|
|
521
|
-
constructor(
|
|
522
|
-
this.ordinal =
|
|
521
|
+
constructor(d, c) {
|
|
522
|
+
this.ordinal = d, this.formatBits = c;
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
525
|
s.LOW = new s(0, 1), s.MEDIUM = new s(1, 0), s.QUARTILE = new s(2, 3), s.HIGH = new s(3, 2);
|
|
526
|
-
let
|
|
527
|
-
|
|
526
|
+
let l = s;
|
|
527
|
+
a.Ecc = l;
|
|
528
528
|
})(r.QrCode || (r.QrCode = {}));
|
|
529
|
-
})(
|
|
529
|
+
})(L || (L = {}));
|
|
530
530
|
((r) => {
|
|
531
|
-
((
|
|
531
|
+
((a) => {
|
|
532
532
|
const s = class s {
|
|
533
533
|
/*-- Constructor and fields --*/
|
|
534
|
-
constructor(
|
|
535
|
-
this.modeBits =
|
|
534
|
+
constructor(d, c) {
|
|
535
|
+
this.modeBits = d, this.numBitsCharCount = c;
|
|
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(d) {
|
|
541
|
+
return this.numBitsCharCount[Math.floor((d + 7) / 17)];
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
544
|
s.NUMERIC = new s(1, [10, 12, 14]), s.ALPHANUMERIC = new s(2, [9, 11, 13]), s.BYTE = new s(4, [8, 16, 16]), s.KANJI = new s(8, [8, 10, 12]), s.ECI = new s(7, [0, 0, 0]);
|
|
545
|
-
let
|
|
546
|
-
|
|
545
|
+
let l = s;
|
|
546
|
+
a.Mode = l;
|
|
547
547
|
})(r.QrSegment || (r.QrSegment = {}));
|
|
548
|
-
})(
|
|
549
|
-
const
|
|
550
|
-
L:
|
|
551
|
-
M:
|
|
552
|
-
Q:
|
|
553
|
-
H:
|
|
554
|
-
},
|
|
548
|
+
})(L || (L = {}));
|
|
549
|
+
const b = L, W = {
|
|
550
|
+
L: b.QrCode.Ecc.LOW,
|
|
551
|
+
M: b.QrCode.Ecc.MEDIUM,
|
|
552
|
+
Q: b.QrCode.Ecc.QUARTILE,
|
|
553
|
+
H: b.QrCode.Ecc.HIGH
|
|
554
|
+
}, J = 128, tt = "M", et = "#FFFFFF", ot = 1, nt = 4, x = 5, D = "#000000", rt = "square", st = "square", it = "square", at = 0.1, C = 7, P = 3, y = [
|
|
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 F = T, _ = {
|
|
|
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
|
+
], X = {
|
|
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 F = T, _ = {
|
|
|
569
569
|
"leaf-sm": [0, 90, -90],
|
|
570
570
|
leaf: [0, 90, -90],
|
|
571
571
|
"leaf-lg": [0, 90, -90]
|
|
572
|
-
},
|
|
572
|
+
}, U = {
|
|
573
573
|
"rounded-sm": 3,
|
|
574
574
|
rounded: 4,
|
|
575
575
|
"rounded-lg": 5,
|
|
@@ -582,7 +582,7 @@ const F = T, _ = {
|
|
|
582
582
|
"outpoint-sm": 3,
|
|
583
583
|
outpoint: 4,
|
|
584
584
|
"outpoint-lg": 5
|
|
585
|
-
},
|
|
585
|
+
}, B = {
|
|
586
586
|
square: 0,
|
|
587
587
|
diamond: 0,
|
|
588
588
|
circle: 3,
|
|
@@ -598,7 +598,7 @@ const F = T, _ = {
|
|
|
598
598
|
"outpoint-sm": 1.5,
|
|
599
599
|
outpoint: 2,
|
|
600
600
|
"outpoint-lg": 2.3
|
|
601
|
-
},
|
|
601
|
+
}, F = [
|
|
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,120 @@ const F = T, _ = {
|
|
|
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
|
-
],
|
|
609
|
+
], lt = (r) => r === "square" || r === "circle" || r === "star" || r === "heart" || r === "diamond", v = (r, a, l) => {
|
|
610
610
|
const s = {
|
|
611
|
-
left: r === 0 ? 0 : a
|
|
612
|
-
right: r === a
|
|
613
|
-
top:
|
|
614
|
-
bottom:
|
|
611
|
+
left: r === 0 ? 0 : l[a][r - 1],
|
|
612
|
+
right: r === l[a].length - 1 ? 0 : l[a][r + 1],
|
|
613
|
+
top: a === 0 ? 0 : l[a - 1][r],
|
|
614
|
+
bottom: a === l.length - 1 ? 0 : l[a + 1][r]
|
|
615
615
|
};
|
|
616
616
|
return {
|
|
617
617
|
...s,
|
|
618
618
|
count: Object.values(s).filter(Boolean).length
|
|
619
619
|
};
|
|
620
|
-
}, O = (r,
|
|
620
|
+
}, O = (r, a, l) => `M${r},${a}h${l}v${l}h-${l}Z`, S = (r, a, l) => `M${r},${a + l / 2}a${l / 2},${l / 2} 0 1,0 ${l},0a${l / 2},${l / 2} 0 1,0 -${l},0Z`, ct = (r, a, l) => `M${r},${a + l / 2}l${l / 2},-${l / 2}l${l / 2},${l / 2}l-${l / 2},${l / 2}Z`, ht = (r, a) => `M ${r} ${a}
|
|
621
621
|
v 1
|
|
622
622
|
h 1
|
|
623
623
|
v -0.5
|
|
624
|
-
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, z = (r,
|
|
624
|
+
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, z = (r, a) => `M ${r + 1} ${a}
|
|
625
625
|
v 1
|
|
626
626
|
h -1
|
|
627
627
|
v -0.5
|
|
628
|
-
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, k = (r,
|
|
628
|
+
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, k = (r, a) => `M ${r} ${a}
|
|
629
629
|
v 1
|
|
630
630
|
h 0.5
|
|
631
631
|
a 0.5 0.5, 0, 0, 0, 0.5 -0.5
|
|
632
632
|
v -0.5
|
|
633
|
-
h -1`,
|
|
633
|
+
h -1`, ut = (r, a) => `M ${r + 1} ${a}
|
|
634
634
|
v 1
|
|
635
635
|
h -0.5
|
|
636
636
|
a 0.5 0.5, 0, 0, 1, -0.5 -0.5
|
|
637
637
|
v -0.5
|
|
638
|
-
h 1`, Y = (r,
|
|
638
|
+
h 1`, Y = (r, a) => `M ${r} ${a}
|
|
639
639
|
v 1
|
|
640
640
|
h 0.5
|
|
641
|
-
a 0.5 0.5, 0, 0, 0, 0 -1`, H = (r,
|
|
641
|
+
a 0.5 0.5, 0, 0, 0, 0 -1`, H = (r, a) => `M ${r + 1} ${a}
|
|
642
642
|
v 1
|
|
643
643
|
h -0.5
|
|
644
|
-
a 0.5 0.5, 0, 0, 1, 0 -1`,
|
|
644
|
+
a 0.5 0.5, 0, 0, 1, 0 -1`, j = (r, a) => `M ${r} ${a + 1}
|
|
645
645
|
h 1
|
|
646
646
|
v -0.5
|
|
647
|
-
a 0.5 0.5, 0, 0, 0, -1 0`,
|
|
647
|
+
a 0.5 0.5, 0, 0, 0, -1 0`, q = (r, a) => `M ${r} ${a}
|
|
648
648
|
h 1
|
|
649
649
|
v 0.5
|
|
650
|
-
a 0.5 0.5, 0, 0, 1, -1 0`,
|
|
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
651
|
x: r,
|
|
652
|
-
y:
|
|
653
|
-
numCells:
|
|
652
|
+
y: a,
|
|
653
|
+
numCells: l
|
|
654
654
|
}) => {
|
|
655
|
-
var s,
|
|
656
|
-
return !!((s =
|
|
657
|
-
},
|
|
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
658
|
x: r,
|
|
659
|
-
y:
|
|
660
|
-
radius:
|
|
659
|
+
y: a,
|
|
660
|
+
radius: l
|
|
661
661
|
}) => {
|
|
662
|
-
const s = P -
|
|
663
|
-
return `M ${r} ${
|
|
664
|
-
},
|
|
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
665
|
x: r,
|
|
666
|
-
y:
|
|
667
|
-
radius:
|
|
666
|
+
y: a,
|
|
667
|
+
radius: l
|
|
668
668
|
}) => {
|
|
669
|
-
const s = P -
|
|
670
|
-
return `M ${r} ${
|
|
671
|
-
},
|
|
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
672
|
x: r,
|
|
673
|
-
y:
|
|
674
|
-
numCells:
|
|
673
|
+
y: a,
|
|
674
|
+
numCells: l
|
|
675
675
|
}) => {
|
|
676
|
-
var s,
|
|
677
|
-
return !!((s =
|
|
678
|
-
},
|
|
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
679
|
x: r,
|
|
680
|
-
y:
|
|
681
|
-
radius:
|
|
680
|
+
y: a,
|
|
681
|
+
radius: l
|
|
682
682
|
}) => {
|
|
683
|
-
const s = C -
|
|
684
|
-
return `M ${r} ${
|
|
685
|
-
},
|
|
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
686
|
x: r,
|
|
687
|
-
y:
|
|
688
|
-
radius:
|
|
687
|
+
y: a,
|
|
688
|
+
radius: l
|
|
689
689
|
}) => {
|
|
690
|
-
const s = C -
|
|
691
|
-
return `M ${r} ${
|
|
692
|
-
},
|
|
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
693
|
x: r,
|
|
694
|
-
y:
|
|
695
|
-
radius:
|
|
694
|
+
y: a,
|
|
695
|
+
radius: l
|
|
696
696
|
}) => {
|
|
697
|
-
const s = C -
|
|
698
|
-
return `M ${r} ${
|
|
699
|
-
},
|
|
700
|
-
color: (r == null ? void 0 : r.color) ||
|
|
701
|
-
style: (r == null ? void 0 : r.style) ||
|
|
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
702
|
randomSize: (r == null ? void 0 : r.randomSize) || !1
|
|
703
|
-
}),
|
|
704
|
-
color: (r == null ? void 0 : r.color) ||
|
|
705
|
-
style: (r == null ? void 0 : r.style) ||
|
|
706
|
-
}),
|
|
707
|
-
color: (r == null ? void 0 : r.color) ||
|
|
708
|
-
style: (r == null ? void 0 : r.style) ||
|
|
709
|
-
}),
|
|
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
710
|
function Nt(r) {
|
|
711
|
-
return r.toFixed(7).replace(
|
|
711
|
+
return r.toFixed(7).replace(Ct, "");
|
|
712
712
|
}
|
|
713
|
-
const
|
|
714
|
-
const
|
|
713
|
+
const G = (r, a, l, s) => {
|
|
714
|
+
const t = l / 2, d = t / 2, c = Math.PI / s;
|
|
715
715
|
let $ = "";
|
|
716
|
-
for (let
|
|
717
|
-
const
|
|
718
|
-
$ += `${
|
|
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} `;
|
|
719
719
|
}
|
|
720
720
|
return $ + "Z";
|
|
721
|
-
}, Q = (r,
|
|
722
|
-
let s = !1,
|
|
721
|
+
}, Q = (r, a, l) => {
|
|
722
|
+
let s = !1, t = 0;
|
|
723
723
|
return [
|
|
724
724
|
"M",
|
|
725
725
|
1,
|
|
@@ -831,104 +831,104 @@ const K = (r, c, a, s) => {
|
|
|
831
831
|
1,
|
|
832
832
|
0.3262506,
|
|
833
833
|
"z"
|
|
834
|
-
].map((
|
|
835
|
-
},
|
|
834
|
+
].map((d) => typeof d == "string" ? (t = 0, s = d.toUpperCase() == d, d) : (t++, d = d * l, s && (d += t % 2 == 1 ? r : a), Nt(d))).join(" ");
|
|
835
|
+
}, It = ({
|
|
836
836
|
modules: r,
|
|
837
|
-
margin:
|
|
838
|
-
settings:
|
|
837
|
+
margin: a,
|
|
838
|
+
settings: l
|
|
839
839
|
}) => {
|
|
840
|
-
const { color: s, style:
|
|
841
|
-
() =>
|
|
842
|
-
[
|
|
843
|
-
),
|
|
844
|
-
return r.forEach((
|
|
845
|
-
|
|
846
|
-
if (
|
|
840
|
+
const { color: s, style: t, randomSize: d } = T(
|
|
841
|
+
() => Rt(l),
|
|
842
|
+
[l]
|
|
843
|
+
), c = [], $ = r.length, m = lt(t) && d, e = K(() => t === "square-sm" ? 0.75 : m ? Math.random() * (1 - 0.75) + 0.75 : 1, [t, m]);
|
|
844
|
+
return r.forEach((n, o) => {
|
|
845
|
+
n.forEach((i, h) => {
|
|
846
|
+
if (mt({ x: h, y: o, numCells: $ }) || ft({ x: h, y: o, numCells: $ }))
|
|
847
847
|
return;
|
|
848
|
-
const p =
|
|
848
|
+
const p = e(), u = 1 * p, M = (1 - 1 * p) / 2, f = h + a + M, E = o + a + M;
|
|
849
849
|
if (i) {
|
|
850
|
-
if (
|
|
851
|
-
|
|
852
|
-
else if (
|
|
853
|
-
|
|
854
|
-
else if (
|
|
855
|
-
|
|
856
|
-
else if (
|
|
857
|
-
|
|
858
|
-
|
|
850
|
+
if (t === "square" || t === "square-sm")
|
|
851
|
+
c.push(O(f, E, u));
|
|
852
|
+
else if (t === "circle")
|
|
853
|
+
c.push(S(f, E, u));
|
|
854
|
+
else if (t === "diamond")
|
|
855
|
+
c.push(ct(f, E, u));
|
|
856
|
+
else if (t === "star")
|
|
857
|
+
c.push(
|
|
858
|
+
G(f + u / 2, E + u / 2, u * 1.1, x)
|
|
859
859
|
);
|
|
860
|
-
else if (
|
|
861
|
-
|
|
862
|
-
else if (
|
|
863
|
-
const { left: A, right:
|
|
864
|
-
|
|
865
|
-
} else if (
|
|
866
|
-
const { left: A, right:
|
|
867
|
-
if (
|
|
868
|
-
|
|
869
|
-
else if (!A && !
|
|
870
|
-
|
|
860
|
+
else if (t === "heart")
|
|
861
|
+
c.push(Q(f, E, u));
|
|
862
|
+
else if (t === "rounded") {
|
|
863
|
+
const { left: A, right: g, top: R, bottom: w, count: N } = v(h, o, r);
|
|
864
|
+
N === 0 ? c.push(S(f, E, 1)) : N > 2 || A && g || R && w ? c.push(O(f, E, 1)) : N === 2 ? A && R ? c.push(k(f, E)) : R && g ? c.push(ut(f, E)) : g && w ? c.push(z(f, E)) : c.push(ht(f, E)) : R ? c.push(q(f, E)) : g ? c.push(H(f, E)) : w ? c.push(j(f, E)) : c.push(Y(f, E));
|
|
865
|
+
} else if (t === "leaf") {
|
|
866
|
+
const { left: A, right: g, top: R, bottom: w, count: N } = v(h, o, r);
|
|
867
|
+
if (N === 0)
|
|
868
|
+
c.push(dt(f, E, u));
|
|
869
|
+
else if (!A && !R) {
|
|
870
|
+
c.push(z(f, E));
|
|
871
871
|
return;
|
|
872
|
-
} else !
|
|
873
|
-
} else if (
|
|
874
|
-
const { left: A, right:
|
|
875
|
-
|
|
876
|
-
} else if (
|
|
877
|
-
const { left: A, right:
|
|
878
|
-
|
|
872
|
+
} else !g && !w ? c.push(k(f, E)) : c.push(O(f, E, 1));
|
|
873
|
+
} else if (t === "vertical-line") {
|
|
874
|
+
const { left: A, right: g, top: R, bottom: w, count: N } = v(h, o, r);
|
|
875
|
+
N === 0 || A && !(R || w) || g && !(R || w) ? c.push(S(f, E, 1)) : R && w ? c.push(O(f, E, 1)) : R && !w ? c.push(q(f, E)) : w && !R && c.push(j(f, E));
|
|
876
|
+
} else if (t === "horizontal-line") {
|
|
877
|
+
const { left: A, right: g, top: R, bottom: w, count: N } = v(h, o, r);
|
|
878
|
+
N === 0 || R && !(A || g) || w && !(A || g) ? c.push(S(f, E, 1)) : A && g ? c.push(O(f, E, 1)) : A && !g ? c.push(Y(f, E)) : g && !A && c.push(H(f, E));
|
|
879
879
|
}
|
|
880
880
|
}
|
|
881
881
|
});
|
|
882
|
-
}), /* @__PURE__ */
|
|
882
|
+
}), /* @__PURE__ */ I(
|
|
883
883
|
"path",
|
|
884
884
|
{
|
|
885
885
|
fill: s,
|
|
886
|
-
d:
|
|
887
|
-
shapeRendering:
|
|
886
|
+
d: c.join(""),
|
|
887
|
+
shapeRendering: t === "square" ? "crispEdges" : "geometricPrecision"
|
|
888
888
|
}
|
|
889
889
|
);
|
|
890
|
-
},
|
|
890
|
+
}, Pt = ({
|
|
891
891
|
modules: r,
|
|
892
|
-
margin:
|
|
893
|
-
settings:
|
|
892
|
+
margin: a,
|
|
893
|
+
settings: l
|
|
894
894
|
}) => {
|
|
895
|
-
const { color: s, style:
|
|
896
|
-
() =>
|
|
897
|
-
[
|
|
898
|
-
),
|
|
895
|
+
const { color: s, style: t } = T(
|
|
896
|
+
() => At(l),
|
|
897
|
+
[l]
|
|
898
|
+
), d = T(
|
|
899
899
|
() => [
|
|
900
|
-
{ x:
|
|
901
|
-
{ x: r.length +
|
|
902
|
-
{ x:
|
|
900
|
+
{ x: a + 2, y: a + 2 },
|
|
901
|
+
{ x: r.length + a - C + 2, y: a + 2 },
|
|
902
|
+
{ x: a + 2, y: r.length + a - C + 2 }
|
|
903
903
|
],
|
|
904
|
-
[
|
|
905
|
-
),
|
|
906
|
-
if (
|
|
907
|
-
return
|
|
908
|
-
const { x:
|
|
909
|
-
return /* @__PURE__ */
|
|
904
|
+
[a, r.length]
|
|
905
|
+
), c = ($, m) => `finder-patterns-inner-${t}-${$}-${m}`;
|
|
906
|
+
if (t === "rounded-sm" || t === "rounded" || t === "rounded-lg" || t === "circle" || t === "square")
|
|
907
|
+
return d.map(($) => {
|
|
908
|
+
const { x: m, y: e } = $;
|
|
909
|
+
return /* @__PURE__ */ I(
|
|
910
910
|
"rect",
|
|
911
911
|
{
|
|
912
|
-
x:
|
|
913
|
-
y:
|
|
912
|
+
x: m,
|
|
913
|
+
y: e,
|
|
914
914
|
width: P,
|
|
915
915
|
height: P,
|
|
916
916
|
fill: s,
|
|
917
|
-
rx:
|
|
917
|
+
rx: B[t]
|
|
918
918
|
},
|
|
919
|
-
|
|
919
|
+
c(m, e)
|
|
920
920
|
);
|
|
921
921
|
});
|
|
922
|
-
if (
|
|
923
|
-
return
|
|
924
|
-
const { x:
|
|
925
|
-
return /* @__PURE__ */
|
|
922
|
+
if (t === "diamond")
|
|
923
|
+
return d.map(($) => {
|
|
924
|
+
const { x: m, y: e } = $, n = Math.sqrt(1.5), o = P / n, i = o - o / n;
|
|
925
|
+
return /* @__PURE__ */ I(
|
|
926
926
|
"rect",
|
|
927
927
|
{
|
|
928
|
-
x:
|
|
929
|
-
y:
|
|
930
|
-
width:
|
|
931
|
-
height:
|
|
928
|
+
x: m + i / 2,
|
|
929
|
+
y: e + i / 2,
|
|
930
|
+
width: o,
|
|
931
|
+
height: o,
|
|
932
932
|
fill: s,
|
|
933
933
|
style: {
|
|
934
934
|
transform: "rotate(45deg)",
|
|
@@ -936,217 +936,275 @@ const K = (r, c, a, s) => {
|
|
|
936
936
|
transformBox: "fill-box"
|
|
937
937
|
}
|
|
938
938
|
},
|
|
939
|
-
|
|
939
|
+
c(m, e)
|
|
940
940
|
);
|
|
941
941
|
});
|
|
942
|
-
if (
|
|
943
|
-
const $ =
|
|
944
|
-
return
|
|
945
|
-
...
|
|
946
|
-
rotation:
|
|
947
|
-
})).map(({ x:
|
|
948
|
-
const
|
|
949
|
-
x:
|
|
950
|
-
y:
|
|
951
|
-
radius:
|
|
942
|
+
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") {
|
|
943
|
+
const $ = t === "leaf-sm" || t === "leaf" || t === "leaf-lg" ? $t : pt;
|
|
944
|
+
return d.map((m, e) => ({
|
|
945
|
+
...m,
|
|
946
|
+
rotation: X[t][e]
|
|
947
|
+
})).map(({ x: m, y: e, rotation: n }) => {
|
|
948
|
+
const o = $({
|
|
949
|
+
x: m,
|
|
950
|
+
y: e,
|
|
951
|
+
radius: B[t]
|
|
952
952
|
});
|
|
953
|
-
return /* @__PURE__ */
|
|
953
|
+
return /* @__PURE__ */ I(
|
|
954
954
|
"path",
|
|
955
955
|
{
|
|
956
956
|
fill: s,
|
|
957
|
-
d:
|
|
957
|
+
d: o,
|
|
958
958
|
style: {
|
|
959
|
-
transform: `rotate(${
|
|
959
|
+
transform: `rotate(${n}deg)`,
|
|
960
960
|
transformOrigin: "center",
|
|
961
961
|
transformBox: "fill-box"
|
|
962
962
|
}
|
|
963
963
|
},
|
|
964
|
-
|
|
964
|
+
c(m, e)
|
|
965
965
|
);
|
|
966
966
|
});
|
|
967
967
|
}
|
|
968
|
-
return
|
|
969
|
-
const
|
|
970
|
-
return /* @__PURE__ */
|
|
968
|
+
return t === "heart" ? d.map(({ x: $, y: m }) => /* @__PURE__ */ I("path", { fill: s, d: Q($, m, P) }, c($, m))) : t === "star" ? d.map(({ x: $, y: m }) => {
|
|
969
|
+
const e = $ + P / 2, n = m + P / 2, o = G(e, n, P * 1.2, x);
|
|
970
|
+
return /* @__PURE__ */ I("path", { fill: s, d: o }, c($, m));
|
|
971
971
|
}) : null;
|
|
972
|
-
},
|
|
972
|
+
}, Tt = ({
|
|
973
973
|
modules: r,
|
|
974
|
-
margin:
|
|
975
|
-
settings:
|
|
974
|
+
margin: a,
|
|
975
|
+
settings: l
|
|
976
976
|
}) => {
|
|
977
|
-
const { style: s, color:
|
|
978
|
-
() =>
|
|
979
|
-
[
|
|
980
|
-
),
|
|
977
|
+
const { style: s, color: t } = T(
|
|
978
|
+
() => wt(l),
|
|
979
|
+
[l]
|
|
980
|
+
), d = [], c = T(
|
|
981
981
|
() => [
|
|
982
|
-
{ x:
|
|
983
|
-
{ x: r.length +
|
|
984
|
-
{ x:
|
|
982
|
+
{ x: a, y: a },
|
|
983
|
+
{ x: r.length + a - C, y: a },
|
|
984
|
+
{ x: a, y: r.length + a - C }
|
|
985
985
|
],
|
|
986
|
-
[
|
|
986
|
+
[a, r.length]
|
|
987
987
|
);
|
|
988
|
-
if (console.log("modules.length", r.length), console.log("coordinates",
|
|
989
|
-
for (const $ of
|
|
990
|
-
const { x:
|
|
991
|
-
s === "rounded-sm" || s === "rounded" || s === "rounded-lg" ?
|
|
992
|
-
|
|
993
|
-
x:
|
|
994
|
-
y:
|
|
995
|
-
radius:
|
|
988
|
+
if (console.log("modules.length", r.length), console.log("coordinates", c), ["rounded-sm", "rounded", "rounded-lg", "circle", "square"].includes(s)) {
|
|
989
|
+
for (const $ of c) {
|
|
990
|
+
const { x: m, y: e } = $;
|
|
991
|
+
s === "rounded-sm" || s === "rounded" || s === "rounded-lg" ? d.push(
|
|
992
|
+
Et({
|
|
993
|
+
x: m,
|
|
994
|
+
y: e,
|
|
995
|
+
radius: U[s]
|
|
996
996
|
})
|
|
997
|
-
) : s === "circle" ?
|
|
998
|
-
`M ${
|
|
999
|
-
) :
|
|
1000
|
-
`M ${
|
|
997
|
+
) : s === "circle" ? d.push(
|
|
998
|
+
`M ${m + C / 2} ${e}a ${C / 2} ${C / 2} 0 1 0 0.01 0zzm 0 1a ${C / 2 - 1} ${C / 2 - 1} 0 1 1 -0.01 0Z`
|
|
999
|
+
) : d.push(
|
|
1000
|
+
`M ${m} ${e}v ${C}h ${C}v -7zM ${m + 1} ${e + 1}h ${C - 2 * 1}v ${C - 2 * 1}h ${-7 + 2 * 1}z`
|
|
1001
1001
|
);
|
|
1002
1002
|
}
|
|
1003
|
-
return /* @__PURE__ */
|
|
1003
|
+
return /* @__PURE__ */ I("path", { fill: t, d: d.join("") });
|
|
1004
1004
|
}
|
|
1005
1005
|
if (s === "inpoint-sm" || s === "inpoint" || s === "inpoint-lg" || s === "outpoint-sm" || s === "outpoint" || s === "outpoint-lg" || s === "leaf-sm" || s === "leaf" || s === "leaf-lg") {
|
|
1006
|
-
const $ = s === "leaf-sm" || s === "leaf" || s === "leaf-lg" ?
|
|
1007
|
-
return
|
|
1008
|
-
...
|
|
1009
|
-
rotation:
|
|
1010
|
-
})).map(({ x:
|
|
1011
|
-
const
|
|
1012
|
-
x:
|
|
1013
|
-
y:
|
|
1014
|
-
radius:
|
|
1006
|
+
const $ = s === "leaf-sm" || s === "leaf" || s === "leaf-lg" ? gt : Mt;
|
|
1007
|
+
return c.map((m, e) => ({
|
|
1008
|
+
...m,
|
|
1009
|
+
rotation: X[s][e]
|
|
1010
|
+
})).map(({ x: m, y: e, rotation: n }) => {
|
|
1011
|
+
const o = $({
|
|
1012
|
+
x: m,
|
|
1013
|
+
y: e,
|
|
1014
|
+
radius: U[s]
|
|
1015
1015
|
});
|
|
1016
|
-
return /* @__PURE__ */
|
|
1016
|
+
return /* @__PURE__ */ I(
|
|
1017
1017
|
"path",
|
|
1018
1018
|
{
|
|
1019
|
-
fill:
|
|
1020
|
-
d:
|
|
1019
|
+
fill: t,
|
|
1020
|
+
d: o,
|
|
1021
1021
|
style: {
|
|
1022
|
-
transform: `rotate(${
|
|
1022
|
+
transform: `rotate(${n}deg)`,
|
|
1023
1023
|
transformOrigin: "center",
|
|
1024
1024
|
transformBox: "fill-box"
|
|
1025
1025
|
}
|
|
1026
1026
|
},
|
|
1027
|
-
`finder-patterns-outer-${s}-${
|
|
1027
|
+
`finder-patterns-outer-${s}-${m}-${e}`
|
|
1028
1028
|
);
|
|
1029
1029
|
});
|
|
1030
1030
|
}
|
|
1031
1031
|
return null;
|
|
1032
|
-
},
|
|
1032
|
+
}, Lt = (r, a) => r.slice().map((l, s) => s < a.y || s >= a.y + a.h ? l : l.map((t, d) => d < a.x || d >= a.x + a.w ? t : !1)), bt = (r, a, l, s) => {
|
|
1033
1033
|
if (s == null)
|
|
1034
1034
|
return null;
|
|
1035
|
-
const
|
|
1035
|
+
const t = r.length + l * 2, d = Math.floor(a * at), c = t / a, $ = (s.width || d) * c, m = (s.height || d) * c, e = s.x == null ? r.length / 2 - $ / 2 : s.x * c, n = s.y == null ? r.length / 2 - m / 2 : s.y * c, o = s.opacity == null ? 1 : s.opacity;
|
|
1036
1036
|
let i = null;
|
|
1037
1037
|
if (s.excavate) {
|
|
1038
|
-
const p = Math.floor(
|
|
1039
|
-
i = { x: p, y:
|
|
1038
|
+
const p = Math.floor(e), u = Math.floor(n), M = Math.ceil($ + e - p), f = Math.ceil(m + n - u);
|
|
1039
|
+
i = { x: p, y: u, w: M, h: f };
|
|
1040
1040
|
}
|
|
1041
1041
|
const h = s.crossOrigin;
|
|
1042
|
-
return { x:
|
|
1043
|
-
},
|
|
1042
|
+
return { x: e, y: n, h: m, w: $, excavation: i, opacity: o, crossOrigin: h };
|
|
1043
|
+
}, Ot = (r) => r != null ? Math.max(Math.floor(r), 0) : nt, vt = ({
|
|
1044
1044
|
value: r,
|
|
1045
|
-
level:
|
|
1046
|
-
minVersion:
|
|
1045
|
+
level: a,
|
|
1046
|
+
minVersion: l,
|
|
1047
1047
|
marginSize: s,
|
|
1048
|
-
imageSettings:
|
|
1049
|
-
size:
|
|
1050
|
-
boostLevel:
|
|
1048
|
+
imageSettings: t,
|
|
1049
|
+
size: d,
|
|
1050
|
+
boostLevel: c
|
|
1051
1051
|
}) => {
|
|
1052
|
-
const $ =
|
|
1053
|
-
const h = (Array.isArray(r) ? r : [r]).reduce((p,
|
|
1054
|
-
return
|
|
1052
|
+
const $ = T(() => {
|
|
1053
|
+
const h = (Array.isArray(r) ? r : [r]).reduce((p, u) => (p.push(...b.QrSegment.makeSegments(u)), p), []);
|
|
1054
|
+
return b.QrCode.encodeSegments(
|
|
1055
1055
|
h,
|
|
1056
|
-
|
|
1057
|
-
|
|
1056
|
+
W[a],
|
|
1057
|
+
l,
|
|
1058
1058
|
void 0,
|
|
1059
1059
|
void 0,
|
|
1060
|
-
|
|
1060
|
+
c
|
|
1061
1061
|
);
|
|
1062
|
-
}, [r,
|
|
1063
|
-
const i = $.getModules(), h =
|
|
1062
|
+
}, [r, a, l, c]), { cells: m, margin: e, numCells: n, calculatedImageSettings: o } = T(() => {
|
|
1063
|
+
const i = $.getModules(), h = Ot(s), p = i.length + h * 2, u = bt(i, d, h, t);
|
|
1064
1064
|
return {
|
|
1065
1065
|
cells: i,
|
|
1066
1066
|
margin: h,
|
|
1067
1067
|
numCells: p,
|
|
1068
|
-
calculatedImageSettings:
|
|
1068
|
+
calculatedImageSettings: u
|
|
1069
1069
|
};
|
|
1070
|
-
}, [$,
|
|
1070
|
+
}, [$, d, t, s]);
|
|
1071
1071
|
return {
|
|
1072
1072
|
qrcode: $,
|
|
1073
|
-
margin:
|
|
1074
|
-
cells:
|
|
1075
|
-
numCells:
|
|
1076
|
-
calculatedImageSettings:
|
|
1073
|
+
margin: e,
|
|
1074
|
+
cells: m,
|
|
1075
|
+
numCells: n,
|
|
1076
|
+
calculatedImageSettings: o
|
|
1077
1077
|
};
|
|
1078
|
-
},
|
|
1078
|
+
}, St = ({ svgRef: r, fileSize: a, fileName: l }) => {
|
|
1079
|
+
if (!r.current) return;
|
|
1080
|
+
const s = r.current.cloneNode(!0);
|
|
1081
|
+
s.setAttribute("width", a.toString()), s.setAttribute("height", a.toString());
|
|
1082
|
+
const t = new XMLSerializer(), d = new Blob([t.serializeToString(s)], {
|
|
1083
|
+
type: "image/svg+xml"
|
|
1084
|
+
}), c = URL.createObjectURL(d), $ = document.createElement("a");
|
|
1085
|
+
$.href = c, $.download = `${l}.svg`, document.body.appendChild($), $.click(), document.body.removeChild($), URL.revokeObjectURL(c);
|
|
1086
|
+
}, yt = ({
|
|
1087
|
+
svgRef: r,
|
|
1088
|
+
fileSize: a,
|
|
1089
|
+
fileName: l,
|
|
1090
|
+
fileFormat: s,
|
|
1091
|
+
imageSettings: t,
|
|
1092
|
+
calculatedImageSettings: d,
|
|
1093
|
+
size: c,
|
|
1094
|
+
numCells: $,
|
|
1095
|
+
margin: m
|
|
1096
|
+
}) => {
|
|
1097
|
+
if (!r.current) return;
|
|
1098
|
+
const e = document.createElement("canvas"), n = e.getContext("2d");
|
|
1099
|
+
if (!n) return;
|
|
1100
|
+
e.width = a, e.height = a;
|
|
1101
|
+
const o = new XMLSerializer().serializeToString(r.current), i = new Blob([o], { type: "image/svg+xml;charset=utf-8" }), h = URL.createObjectURL(i), p = new Image();
|
|
1102
|
+
p.crossOrigin = "anonymous", p.src = h, p.onload = () => {
|
|
1103
|
+
if (n.drawImage(p, 0, 0, a, a), URL.revokeObjectURL(h), t != null && t.src && d) {
|
|
1104
|
+
const u = new Image();
|
|
1105
|
+
u.crossOrigin = "anonymous", u.src = t.src, u.onload = () => {
|
|
1106
|
+
const M = a / c, f = $ / a, E = t.width * M, A = t.x ? (d.x + m) / f : (a - E) / 2, g = t.y ? (d.y + m) / f : (a - E) / 2;
|
|
1107
|
+
n.drawImage(u, A, g, E, E);
|
|
1108
|
+
const R = s === "png" ? "image/png" : "image/jpeg", w = document.createElement("a");
|
|
1109
|
+
w.href = e.toDataURL(R), w.download = `${l}.${s}`, document.body.appendChild(w), w.click(), document.body.removeChild(w);
|
|
1110
|
+
}, u.onerror = (M) => console.error("Error loading logo:", M);
|
|
1111
|
+
} else {
|
|
1112
|
+
const u = s === "png" ? "image/png" : "image/jpeg", M = document.createElement("a");
|
|
1113
|
+
M.href = e.toDataURL(u), M.download = `${l}.${s}`, document.body.appendChild(M), M.click(), document.body.removeChild(M);
|
|
1114
|
+
}
|
|
1115
|
+
}, p.onerror = (u) => console.error("Error loading QR code:", u);
|
|
1116
|
+
}, Ft = (r) => {
|
|
1079
1117
|
const {
|
|
1080
|
-
ref:
|
|
1081
|
-
value:
|
|
1082
|
-
size: s =
|
|
1083
|
-
level:
|
|
1084
|
-
bgColor:
|
|
1085
|
-
minVersion:
|
|
1118
|
+
ref: a,
|
|
1119
|
+
value: l,
|
|
1120
|
+
size: s = J,
|
|
1121
|
+
level: t = tt,
|
|
1122
|
+
bgColor: d = et,
|
|
1123
|
+
minVersion: c = ot,
|
|
1086
1124
|
boostLevel: $,
|
|
1087
|
-
marginSize:
|
|
1088
|
-
finderPatternOuterSettings:
|
|
1089
|
-
finderPatternInnerSettings:
|
|
1090
|
-
dataModulesSettings:
|
|
1125
|
+
marginSize: m,
|
|
1126
|
+
finderPatternOuterSettings: e,
|
|
1127
|
+
finderPatternInnerSettings: n,
|
|
1128
|
+
dataModulesSettings: o,
|
|
1091
1129
|
imageSettings: i,
|
|
1092
1130
|
svgProps: h
|
|
1093
|
-
} = r, { margin:
|
|
1094
|
-
value:
|
|
1095
|
-
level:
|
|
1096
|
-
minVersion:
|
|
1131
|
+
} = r, p = V(null), { margin: u, cells: M, numCells: f, calculatedImageSettings: E } = vt({
|
|
1132
|
+
value: l,
|
|
1133
|
+
level: t,
|
|
1134
|
+
minVersion: c,
|
|
1097
1135
|
boostLevel: $,
|
|
1098
|
-
marginSize:
|
|
1136
|
+
marginSize: m,
|
|
1099
1137
|
imageSettings: i,
|
|
1100
1138
|
size: s
|
|
1101
1139
|
});
|
|
1102
|
-
|
|
1103
|
-
|
|
1140
|
+
_(a, () => ({
|
|
1141
|
+
svg: p.current,
|
|
1142
|
+
download: ({
|
|
1143
|
+
name: R = "qr-code",
|
|
1144
|
+
format: w = "svg",
|
|
1145
|
+
size: N = 500
|
|
1146
|
+
}) => {
|
|
1147
|
+
p.current && (w === "svg" ? St({ svgRef: p, fileSize: N, fileName: R }) : yt({
|
|
1148
|
+
svgRef: p,
|
|
1149
|
+
fileSize: N,
|
|
1150
|
+
fileName: R,
|
|
1151
|
+
fileFormat: w,
|
|
1152
|
+
imageSettings: i,
|
|
1153
|
+
calculatedImageSettings: E,
|
|
1154
|
+
size: s,
|
|
1155
|
+
numCells: f,
|
|
1156
|
+
margin: u
|
|
1157
|
+
}));
|
|
1158
|
+
}
|
|
1159
|
+
}));
|
|
1160
|
+
let A = M, g = null;
|
|
1161
|
+
return i != null && E != null && (E.excavation != null && (A = Lt(M, E.excavation)), g = /* @__PURE__ */ I(
|
|
1104
1162
|
"image",
|
|
1105
1163
|
{
|
|
1106
1164
|
href: i.src,
|
|
1107
|
-
height:
|
|
1108
|
-
width:
|
|
1109
|
-
x:
|
|
1110
|
-
y:
|
|
1165
|
+
height: E.h,
|
|
1166
|
+
width: E.w,
|
|
1167
|
+
x: E.x + u,
|
|
1168
|
+
y: E.y + u,
|
|
1111
1169
|
preserveAspectRatio: "none",
|
|
1112
|
-
opacity:
|
|
1113
|
-
crossOrigin:
|
|
1170
|
+
opacity: E.opacity,
|
|
1171
|
+
crossOrigin: E.crossOrigin
|
|
1114
1172
|
}
|
|
1115
|
-
)), /* @__PURE__ */
|
|
1173
|
+
)), /* @__PURE__ */ Z(
|
|
1116
1174
|
"svg",
|
|
1117
1175
|
{
|
|
1118
1176
|
height: s,
|
|
1119
1177
|
width: s,
|
|
1120
|
-
viewBox: `0 0 ${
|
|
1121
|
-
ref:
|
|
1178
|
+
viewBox: `0 0 ${f} ${f}`,
|
|
1179
|
+
ref: p,
|
|
1122
1180
|
role: "img",
|
|
1123
1181
|
"aria-label": (h == null ? void 0 : h["aria-label"]) || "QR Code",
|
|
1124
1182
|
...h,
|
|
1125
1183
|
children: [
|
|
1126
|
-
/* @__PURE__ */
|
|
1127
|
-
/* @__PURE__ */
|
|
1128
|
-
|
|
1184
|
+
/* @__PURE__ */ I("path", { fill: d, d: `M0,0 h${f}v${f}H0z` }),
|
|
1185
|
+
/* @__PURE__ */ I(
|
|
1186
|
+
Tt,
|
|
1129
1187
|
{
|
|
1130
|
-
modules:
|
|
1131
|
-
margin:
|
|
1132
|
-
settings:
|
|
1188
|
+
modules: A,
|
|
1189
|
+
margin: u,
|
|
1190
|
+
settings: e
|
|
1133
1191
|
}
|
|
1134
1192
|
),
|
|
1135
|
-
/* @__PURE__ */
|
|
1136
|
-
|
|
1193
|
+
/* @__PURE__ */ I(
|
|
1194
|
+
Pt,
|
|
1137
1195
|
{
|
|
1138
|
-
modules:
|
|
1139
|
-
margin:
|
|
1140
|
-
settings:
|
|
1196
|
+
modules: A,
|
|
1197
|
+
margin: u,
|
|
1198
|
+
settings: n
|
|
1141
1199
|
}
|
|
1142
1200
|
),
|
|
1143
|
-
/* @__PURE__ */
|
|
1144
|
-
|
|
1201
|
+
/* @__PURE__ */ I(It, { modules: A, margin: u, settings: o }),
|
|
1202
|
+
g
|
|
1145
1203
|
]
|
|
1146
1204
|
}
|
|
1147
1205
|
);
|
|
1148
1206
|
};
|
|
1149
|
-
|
|
1207
|
+
Ft.displayName = "ReactQRCode";
|
|
1150
1208
|
export {
|
|
1151
|
-
|
|
1209
|
+
Ft as ReactQRCode
|
|
1152
1210
|
};
|