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