@nanahoshi/mona-ui 0.29.0 → 0.30.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.
Files changed (54) hide show
  1. package/docs/api/i18n.md +13 -0
  2. package/docs/api/locales.md +14 -14
  3. package/docs/api/qr-code.md +287 -0
  4. package/docs/qr-code.md +377 -0
  5. package/fesm2022/nanahoshi-mona-ui-i18n-icu.mjs +1 -0
  6. package/fesm2022/nanahoshi-mona-ui-locales-ar-sa.mjs +1 -0
  7. package/fesm2022/nanahoshi-mona-ui-locales-de-de.mjs +1 -0
  8. package/fesm2022/nanahoshi-mona-ui-locales-es-es.mjs +1 -0
  9. package/fesm2022/nanahoshi-mona-ui-locales-fr-fr.mjs +1 -0
  10. package/fesm2022/nanahoshi-mona-ui-locales-id-id.mjs +1 -0
  11. package/fesm2022/nanahoshi-mona-ui-locales-it-it.mjs +1 -0
  12. package/fesm2022/nanahoshi-mona-ui-locales-ja-jp.mjs +1 -0
  13. package/fesm2022/nanahoshi-mona-ui-locales-ko-kr.mjs +1 -0
  14. package/fesm2022/nanahoshi-mona-ui-locales-pl-pl.mjs +1 -0
  15. package/fesm2022/nanahoshi-mona-ui-locales-pt-br.mjs +1 -0
  16. package/fesm2022/nanahoshi-mona-ui-locales-ru-ru.mjs +1 -0
  17. package/fesm2022/nanahoshi-mona-ui-locales-tr-tr.mjs +1 -0
  18. package/fesm2022/nanahoshi-mona-ui-locales-zh-cn.mjs +1 -0
  19. package/fesm2022/nanahoshi-mona-ui-locales-zh-tw.mjs +1 -0
  20. package/fesm2022/nanahoshi-mona-ui-qr-code.mjs +1671 -0
  21. package/i18n/catalogs/en-US.messages.json +3 -0
  22. package/llms.txt +3 -1
  23. package/locales/ar-sa/ar-sa.messages.json +3 -0
  24. package/locales/de-de/de-de.messages.json +3 -0
  25. package/locales/es-es/es-es.messages.json +3 -0
  26. package/locales/fr-fr/fr-fr.messages.json +3 -0
  27. package/locales/id-id/id-id.messages.json +3 -0
  28. package/locales/it-it/it-it.messages.json +3 -0
  29. package/locales/ja-jp/ja-jp.messages.json +3 -0
  30. package/locales/ko-kr/ko-kr.messages.json +3 -0
  31. package/locales/pl-pl/pl-pl.messages.json +3 -0
  32. package/locales/pt-br/pt-br.messages.json +3 -0
  33. package/locales/ru-ru/ru-ru.messages.json +3 -0
  34. package/locales/tr-tr/tr-tr.messages.json +3 -0
  35. package/locales/zh-cn/zh-cn.messages.json +3 -0
  36. package/locales/zh-tw/zh-tw.messages.json +3 -0
  37. package/package.json +5 -1
  38. package/qr-code/package.json +4 -0
  39. package/types/nanahoshi-mona-ui-i18n.d.ts +4 -0
  40. package/types/nanahoshi-mona-ui-locales-ar-sa.d.ts +3 -0
  41. package/types/nanahoshi-mona-ui-locales-de-de.d.ts +3 -0
  42. package/types/nanahoshi-mona-ui-locales-es-es.d.ts +3 -0
  43. package/types/nanahoshi-mona-ui-locales-fr-fr.d.ts +3 -0
  44. package/types/nanahoshi-mona-ui-locales-id-id.d.ts +3 -0
  45. package/types/nanahoshi-mona-ui-locales-it-it.d.ts +3 -0
  46. package/types/nanahoshi-mona-ui-locales-ja-jp.d.ts +3 -0
  47. package/types/nanahoshi-mona-ui-locales-ko-kr.d.ts +3 -0
  48. package/types/nanahoshi-mona-ui-locales-pl-pl.d.ts +3 -0
  49. package/types/nanahoshi-mona-ui-locales-pt-br.d.ts +3 -0
  50. package/types/nanahoshi-mona-ui-locales-ru-ru.d.ts +3 -0
  51. package/types/nanahoshi-mona-ui-locales-tr-tr.d.ts +3 -0
  52. package/types/nanahoshi-mona-ui-locales-zh-cn.d.ts +3 -0
  53. package/types/nanahoshi-mona-ui-locales-zh-tw.d.ts +3 -0
  54. package/types/nanahoshi-mona-ui-qr-code.d.ts +322 -0
@@ -0,0 +1,1671 @@
1
+ import { DOCUMENT, isPlatformBrowser } from "@angular/common";
2
+ import * as i0 from "@angular/core";
3
+ import { Component, ElementRef, PLATFORM_ID, computed, effect, inject, input, isDevMode } from "@angular/core";
4
+ import { MonaI18nService } from "@nanahoshi/mona-ui/i18n";
5
+ import { parseColor, toCssValue } from "@nanahoshi/mona-ui/internal";
6
+ import { twMerge } from "tailwind-merge";
7
+ const QR_CODE_DEFAULT_MESSAGES = { label: "QR code" };
8
+ const BLACK = {
9
+ a: 255,
10
+ b: 0,
11
+ g: 0,
12
+ r: 0
13
+ };
14
+ const WHITE = {
15
+ a: 255,
16
+ b: 255,
17
+ g: 255,
18
+ r: 255
19
+ };
20
+ function resolveQrCodeColor(host, value, fallback) {
21
+ const document = host.ownerDocument;
22
+ const probe = document.createElement("span");
23
+ probe.style.display = "none";
24
+ probe.style.color = value;
25
+ if (!probe.style.color) return fallback;
26
+ host.appendChild(probe);
27
+ const computed = document.defaultView?.getComputedStyle(probe).color || probe.style.color;
28
+ probe.remove();
29
+ const color = parseColor(computed, document);
30
+ if (!color || color.r === null || color.g === null || color.b === null) return fallback;
31
+ return {
32
+ a: color.a ?? 255,
33
+ b: color.b,
34
+ g: color.g,
35
+ r: color.r
36
+ };
37
+ }
38
+ const DOWNLOAD_URL_LIFETIME_MS = 4e4;
39
+ const DEFAULT_FILE_NAME = "qr-code";
40
+ function downloadBlob(document, blob, fileName) {
41
+ const url = URL.createObjectURL(blob);
42
+ const anchor = document.createElement("a");
43
+ anchor.href = url;
44
+ anchor.download = fileName;
45
+ anchor.style.display = "none";
46
+ document.body.appendChild(anchor);
47
+ try {
48
+ anchor.click();
49
+ } finally {
50
+ anchor.remove();
51
+ setTimeout(() => URL.revokeObjectURL(url), DOWNLOAD_URL_LIFETIME_MS);
52
+ }
53
+ }
54
+ function qrCodeFileName(fileName, format) {
55
+ const extension = `.${format}`;
56
+ let name = (fileName ?? "").replace(/[\x00-\x1f\x7f/\\?%*:|"<>]/g, "_").replace(/^[.\s]+|[.\s]+$/g, "");
57
+ if (name.toLowerCase().endsWith(extension)) name = name.slice(0, -extension.length).replace(/[.\s]+$/, "");
58
+ return `${name || DEFAULT_FILE_NAME}${extension}`;
59
+ }
60
+ var QrCodeExportError = class extends Error {
61
+ constructor(code, message, options) {
62
+ super(message, options);
63
+ this.name = "QrCodeExportError";
64
+ this.code = code;
65
+ Object.setPrototypeOf(this, new.target.prototype);
66
+ }
67
+ };
68
+ const EC_CODEWORDS_PER_BLOCK = {
69
+ L: [
70
+ 0,
71
+ 7,
72
+ 10,
73
+ 15,
74
+ 20,
75
+ 26,
76
+ 18,
77
+ 20,
78
+ 24,
79
+ 30,
80
+ 18,
81
+ 20,
82
+ 24,
83
+ 26,
84
+ 30,
85
+ 22,
86
+ 24,
87
+ 28,
88
+ 30,
89
+ 28,
90
+ 28,
91
+ 28,
92
+ 28,
93
+ 30,
94
+ 30,
95
+ 26,
96
+ 28,
97
+ 30,
98
+ 30,
99
+ 30,
100
+ 30,
101
+ 30,
102
+ 30,
103
+ 30,
104
+ 30,
105
+ 30,
106
+ 30,
107
+ 30,
108
+ 30,
109
+ 30,
110
+ 30
111
+ ],
112
+ M: [
113
+ 0,
114
+ 10,
115
+ 16,
116
+ 26,
117
+ 18,
118
+ 24,
119
+ 16,
120
+ 18,
121
+ 22,
122
+ 22,
123
+ 26,
124
+ 30,
125
+ 22,
126
+ 22,
127
+ 24,
128
+ 24,
129
+ 28,
130
+ 28,
131
+ 26,
132
+ 26,
133
+ 26,
134
+ 26,
135
+ 28,
136
+ 28,
137
+ 28,
138
+ 28,
139
+ 28,
140
+ 28,
141
+ 28,
142
+ 28,
143
+ 28,
144
+ 28,
145
+ 28,
146
+ 28,
147
+ 28,
148
+ 28,
149
+ 28,
150
+ 28,
151
+ 28,
152
+ 28,
153
+ 28
154
+ ],
155
+ Q: [
156
+ 0,
157
+ 13,
158
+ 22,
159
+ 18,
160
+ 26,
161
+ 18,
162
+ 24,
163
+ 18,
164
+ 22,
165
+ 20,
166
+ 24,
167
+ 28,
168
+ 26,
169
+ 24,
170
+ 20,
171
+ 30,
172
+ 24,
173
+ 28,
174
+ 28,
175
+ 26,
176
+ 30,
177
+ 28,
178
+ 30,
179
+ 30,
180
+ 30,
181
+ 30,
182
+ 28,
183
+ 30,
184
+ 30,
185
+ 30,
186
+ 30,
187
+ 30,
188
+ 30,
189
+ 30,
190
+ 30,
191
+ 30,
192
+ 30,
193
+ 30,
194
+ 30,
195
+ 30,
196
+ 30
197
+ ],
198
+ H: [
199
+ 0,
200
+ 17,
201
+ 28,
202
+ 22,
203
+ 16,
204
+ 22,
205
+ 28,
206
+ 26,
207
+ 26,
208
+ 24,
209
+ 28,
210
+ 24,
211
+ 28,
212
+ 22,
213
+ 24,
214
+ 24,
215
+ 30,
216
+ 28,
217
+ 28,
218
+ 26,
219
+ 28,
220
+ 30,
221
+ 24,
222
+ 30,
223
+ 30,
224
+ 30,
225
+ 30,
226
+ 30,
227
+ 30,
228
+ 30,
229
+ 30,
230
+ 30,
231
+ 30,
232
+ 30,
233
+ 30,
234
+ 30,
235
+ 30,
236
+ 30,
237
+ 30,
238
+ 30,
239
+ 30
240
+ ]
241
+ };
242
+ const EC_BLOCKS = {
243
+ L: [
244
+ 0,
245
+ 1,
246
+ 1,
247
+ 1,
248
+ 1,
249
+ 1,
250
+ 2,
251
+ 2,
252
+ 2,
253
+ 2,
254
+ 4,
255
+ 4,
256
+ 4,
257
+ 4,
258
+ 4,
259
+ 6,
260
+ 6,
261
+ 6,
262
+ 6,
263
+ 7,
264
+ 8,
265
+ 8,
266
+ 9,
267
+ 9,
268
+ 10,
269
+ 12,
270
+ 12,
271
+ 12,
272
+ 13,
273
+ 14,
274
+ 15,
275
+ 16,
276
+ 17,
277
+ 18,
278
+ 19,
279
+ 19,
280
+ 20,
281
+ 21,
282
+ 22,
283
+ 24,
284
+ 25
285
+ ],
286
+ M: [
287
+ 0,
288
+ 1,
289
+ 1,
290
+ 1,
291
+ 2,
292
+ 2,
293
+ 4,
294
+ 4,
295
+ 4,
296
+ 5,
297
+ 5,
298
+ 5,
299
+ 8,
300
+ 9,
301
+ 9,
302
+ 10,
303
+ 10,
304
+ 11,
305
+ 13,
306
+ 14,
307
+ 16,
308
+ 17,
309
+ 17,
310
+ 18,
311
+ 20,
312
+ 21,
313
+ 23,
314
+ 25,
315
+ 26,
316
+ 28,
317
+ 29,
318
+ 31,
319
+ 33,
320
+ 35,
321
+ 37,
322
+ 38,
323
+ 40,
324
+ 43,
325
+ 45,
326
+ 47,
327
+ 49
328
+ ],
329
+ Q: [
330
+ 0,
331
+ 1,
332
+ 1,
333
+ 2,
334
+ 2,
335
+ 4,
336
+ 4,
337
+ 6,
338
+ 6,
339
+ 8,
340
+ 8,
341
+ 8,
342
+ 10,
343
+ 12,
344
+ 16,
345
+ 12,
346
+ 17,
347
+ 16,
348
+ 18,
349
+ 21,
350
+ 20,
351
+ 23,
352
+ 23,
353
+ 25,
354
+ 27,
355
+ 29,
356
+ 34,
357
+ 34,
358
+ 35,
359
+ 38,
360
+ 40,
361
+ 43,
362
+ 45,
363
+ 48,
364
+ 51,
365
+ 53,
366
+ 56,
367
+ 59,
368
+ 62,
369
+ 65,
370
+ 68
371
+ ],
372
+ H: [
373
+ 0,
374
+ 1,
375
+ 1,
376
+ 2,
377
+ 4,
378
+ 4,
379
+ 4,
380
+ 5,
381
+ 6,
382
+ 8,
383
+ 8,
384
+ 11,
385
+ 11,
386
+ 16,
387
+ 16,
388
+ 18,
389
+ 16,
390
+ 19,
391
+ 21,
392
+ 25,
393
+ 25,
394
+ 25,
395
+ 34,
396
+ 30,
397
+ 32,
398
+ 35,
399
+ 37,
400
+ 40,
401
+ 42,
402
+ 45,
403
+ 48,
404
+ 51,
405
+ 54,
406
+ 57,
407
+ 60,
408
+ 63,
409
+ 66,
410
+ 70,
411
+ 74,
412
+ 77,
413
+ 81
414
+ ]
415
+ };
416
+ const FORMAT_LEVEL_BITS = {
417
+ L: 1,
418
+ M: 0,
419
+ Q: 3,
420
+ H: 2
421
+ };
422
+ function symbolSize(version) {
423
+ return version * 4 + 17;
424
+ }
425
+ function rawDataModules(version) {
426
+ const size = symbolSize(version);
427
+ let modules = size * size - 192 - 2 * (size - 16) - 31;
428
+ const alignmentCount = alignmentPatternCenters(version).length;
429
+ if (alignmentCount > 0) {
430
+ const patterns = alignmentCount * alignmentCount - 3;
431
+ const onTiming = 2 * (alignmentCount - 2);
432
+ modules -= patterns * 25 - onTiming * 5;
433
+ }
434
+ if (version >= 7) modules -= 36;
435
+ return modules;
436
+ }
437
+ function alignmentPatternCenters(version) {
438
+ if (version === 1) return [];
439
+ const count = Math.floor(version / 7) + 2;
440
+ const last = symbolSize(version) - 7;
441
+ const step = version === 32 ? 26 : Math.ceil((last - 6) / (count - 1) / 2) * 2;
442
+ const centers = [6];
443
+ for (let index = count - 2; index >= 0; index--) centers.push(last - index * step);
444
+ return centers;
445
+ }
446
+ function blockLayout(version, level) {
447
+ const blocks = EC_BLOCKS[level][version];
448
+ const ecCodewordsPerBlock = EC_CODEWORDS_PER_BLOCK[level][version];
449
+ const totalCodewords = Math.floor(rawDataModules(version) / 8);
450
+ return {
451
+ blocks,
452
+ dataCodewords: totalCodewords - blocks * ecCodewordsPerBlock,
453
+ ecCodewordsPerBlock,
454
+ misdecodeProtection: misdecodeProtection(version, level),
455
+ totalCodewords
456
+ };
457
+ }
458
+ function dataCapacityBits(version, level) {
459
+ return blockLayout(version, level).dataCodewords * 8;
460
+ }
461
+ function misdecodeProtection(version, level) {
462
+ if (version === 1) return level === "L" ? 3 : level === "M" ? 2 : 1;
463
+ if (version === 2 && level === "L") return 2;
464
+ if (version === 3 && level === "L") return 1;
465
+ return 0;
466
+ }
467
+ const FORMAT_GENERATOR = 1335;
468
+ const FORMAT_XOR_MASK = 21522;
469
+ const VERSION_GENERATOR = 7973;
470
+ const PENALTY_RUN = 3;
471
+ const PENALTY_BLOCK = 3;
472
+ const PENALTY_FINDER_LIKE = 40;
473
+ const PENALTY_BALANCE = 10;
474
+ const MASKS = [
475
+ (x, y) => (x + y) % 2 === 0,
476
+ (_, y) => y % 2 === 0,
477
+ (x) => x % 3 === 0,
478
+ (x, y) => (x + y) % 3 === 0,
479
+ (x, y) => (Math.floor(y / 2) + Math.floor(x / 3)) % 2 === 0,
480
+ (x, y) => x * y % 2 + x * y % 3 === 0,
481
+ (x, y) => (x * y % 2 + x * y % 3) % 2 === 0,
482
+ (x, y) => ((x + y) % 2 + x * y % 3) % 2 === 0
483
+ ];
484
+ const FINDER_LIKE_PATTERNS = [[
485
+ 1,
486
+ 0,
487
+ 1,
488
+ 1,
489
+ 1,
490
+ 0,
491
+ 1,
492
+ 0,
493
+ 0,
494
+ 0,
495
+ 0
496
+ ], [
497
+ 0,
498
+ 0,
499
+ 0,
500
+ 0,
501
+ 1,
502
+ 0,
503
+ 1,
504
+ 1,
505
+ 1,
506
+ 0,
507
+ 1
508
+ ]];
509
+ function buildQrCodeMatrix(version, errorCorrection, codewords, forcedMask) {
510
+ const size = symbolSize(version);
511
+ const modules = new Uint8Array(size * size);
512
+ const reserved = new Uint8Array(size * size);
513
+ const codewordIndices = new Int16Array(size * size).fill(-1);
514
+ const set = (x, y, dark) => {
515
+ modules[y * size + x] = dark ? 1 : 0;
516
+ reserved[y * size + x] = 1;
517
+ };
518
+ drawFunctionPatterns(size, version, set);
519
+ placeCodewords(size, codewords, modules, reserved, codewordIndices);
520
+ let mask = forcedMask ?? -1;
521
+ if (mask < 0) {
522
+ let lowestPenalty = Infinity;
523
+ MASKS.forEach((_, candidate) => {
524
+ drawFormatBits(size, errorCorrection, candidate, set);
525
+ applyMask(size, candidate, modules, reserved);
526
+ const penalty = maskPenalty(size, modules);
527
+ applyMask(size, candidate, modules, reserved);
528
+ if (penalty < lowestPenalty) {
529
+ lowestPenalty = penalty;
530
+ mask = candidate;
531
+ }
532
+ });
533
+ }
534
+ drawFormatBits(size, errorCorrection, mask, set);
535
+ applyMask(size, mask, modules, reserved);
536
+ return {
537
+ codewordIndices,
538
+ errorCorrection,
539
+ mask,
540
+ modules,
541
+ reserved,
542
+ size,
543
+ version
544
+ };
545
+ }
546
+ function applyMask(size, mask, modules, reserved) {
547
+ const predicate = MASKS[mask];
548
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
549
+ const index = y * size + x;
550
+ if (!reserved[index] && predicate(x, y)) modules[index] ^= 1;
551
+ }
552
+ }
553
+ function drawFormatBits(size, errorCorrection, mask, set) {
554
+ const data = FORMAT_LEVEL_BITS[errorCorrection] << 3 | mask;
555
+ const bits = (data << 10 | bchRemainder(data, FORMAT_GENERATOR, 10)) ^ FORMAT_XOR_MASK;
556
+ const bit = (index) => (bits >>> index & 1) === 1;
557
+ for (let index = 0; index <= 5; index++) set(8, index, bit(index));
558
+ set(8, 7, bit(6));
559
+ set(8, 8, bit(7));
560
+ set(7, 8, bit(8));
561
+ for (let index = 9; index < 15; index++) set(14 - index, 8, bit(index));
562
+ for (let index = 0; index < 8; index++) set(size - 1 - index, 8, bit(index));
563
+ for (let index = 8; index < 15; index++) set(8, size - 15 + index, bit(index));
564
+ set(8, size - 8, true);
565
+ }
566
+ function drawFunctionPatterns(size, version, set) {
567
+ for (let index = 0; index < size; index++) {
568
+ set(6, index, index % 2 === 0);
569
+ set(index, 6, index % 2 === 0);
570
+ }
571
+ for (const [centerX, centerY] of [
572
+ [3, 3],
573
+ [size - 4, 3],
574
+ [3, size - 4]
575
+ ]) for (let dy = -4; dy <= 4; dy++) for (let dx = -4; dx <= 4; dx++) {
576
+ const x = centerX + dx;
577
+ const y = centerY + dy;
578
+ if (x >= 0 && x < size && y >= 0 && y < size) {
579
+ const ring = Math.max(Math.abs(dx), Math.abs(dy));
580
+ set(x, y, ring !== 2 && ring !== 4);
581
+ }
582
+ }
583
+ const centers = alignmentPatternCenters(version);
584
+ const last = centers.length - 1;
585
+ centers.forEach((centerY, row) => {
586
+ centers.forEach((centerX, column) => {
587
+ if (row === 0 && column === 0 || row === 0 && column === last || row === last && column === 0) return;
588
+ for (let dy = -2; dy <= 2; dy++) for (let dx = -2; dx <= 2; dx++) set(centerX + dx, centerY + dy, Math.max(Math.abs(dx), Math.abs(dy)) !== 1);
589
+ });
590
+ });
591
+ drawFormatBits(size, "L", 0, set);
592
+ if (version >= 7) {
593
+ const bits = version << 12 | bchRemainder(version, VERSION_GENERATOR, 12);
594
+ for (let index = 0; index < 18; index++) {
595
+ const dark = (bits >>> index & 1) === 1;
596
+ const along = size - 11 + index % 3;
597
+ const across = Math.floor(index / 3);
598
+ set(along, across, dark);
599
+ set(across, along, dark);
600
+ }
601
+ }
602
+ }
603
+ function bchRemainder(value, generator, degree) {
604
+ let remainder = value;
605
+ for (let step = 0; step < degree; step++) remainder = remainder << 1 ^ (remainder >>> degree - 1) * generator;
606
+ return remainder & (1 << degree) - 1;
607
+ }
608
+ function maskPenalty(size, modules) {
609
+ let penalty = 0;
610
+ let dark = 0;
611
+ const line = new Uint8Array(size);
612
+ for (let direction = 0; direction < 2; direction++) for (let outer = 0; outer < size; outer++) {
613
+ for (let inner = 0; inner < size; inner++) line[inner] = direction === 0 ? modules[outer * size + inner] : modules[inner * size + outer];
614
+ penalty += runPenalty(line) + finderLikePenalty(line);
615
+ }
616
+ for (let y = 0; y < size; y++) for (let x = 0; x < size; x++) {
617
+ const color = modules[y * size + x];
618
+ dark += color;
619
+ if (x < size - 1 && y < size - 1 && color === modules[y * size + x + 1] && color === modules[(y + 1) * size + x] && color === modules[(y + 1) * size + x + 1]) penalty += PENALTY_BLOCK;
620
+ }
621
+ const total = size * size;
622
+ penalty += Math.floor(Math.abs(dark * 20 - total * 10) / total) * PENALTY_BALANCE;
623
+ return penalty;
624
+ }
625
+ function finderLikePenalty(line) {
626
+ let penalty = 0;
627
+ const at = (index) => index >= 0 && index < line.length ? line[index] : 0;
628
+ for (let start = -4; start + 11 <= line.length + 4; start++) for (const pattern of FINDER_LIKE_PATTERNS) if (pattern.every((color, offset) => at(start + offset) === color)) penalty += PENALTY_FINDER_LIKE;
629
+ return penalty;
630
+ }
631
+ function placeCodewords(size, codewords, modules, reserved, codewordIndices) {
632
+ const totalBits = codewords.length * 8;
633
+ let bitIndex = 0;
634
+ for (let right = size - 1; right >= 1; right -= 2) {
635
+ if (right === 6) right = 5;
636
+ const upward = (right + 1 & 2) === 0;
637
+ for (let step = 0; step < size; step++) {
638
+ const y = upward ? size - 1 - step : step;
639
+ for (let offset = 0; offset < 2; offset++) {
640
+ const index = y * size + right - offset;
641
+ if (reserved[index] || bitIndex >= totalBits) continue;
642
+ const codeword = bitIndex >>> 3;
643
+ modules[index] = codewords[codeword] >>> 7 - (bitIndex & 7) & 1;
644
+ codewordIndices[index] = codeword;
645
+ bitIndex++;
646
+ }
647
+ }
648
+ }
649
+ }
650
+ function runPenalty(line) {
651
+ let penalty = 0;
652
+ let runLength = 1;
653
+ for (let index = 1; index <= line.length; index++) {
654
+ if (index < line.length && line[index] === line[index - 1]) {
655
+ runLength++;
656
+ continue;
657
+ }
658
+ if (runLength >= 5) penalty += PENALTY_RUN + runLength - 5;
659
+ runLength = 1;
660
+ }
661
+ return penalty;
662
+ }
663
+ const FIELD_POLYNOMIAL = 285;
664
+ const EXP = /* @__PURE__ */ new Uint8Array(512);
665
+ const LOG = /* @__PURE__ */ new Uint8Array(256);
666
+ {
667
+ let value = 1;
668
+ for (let power = 0; power < 255; power++) {
669
+ EXP[power] = value;
670
+ LOG[value] = power;
671
+ value <<= 1;
672
+ if (value & 256) value ^= FIELD_POLYNOMIAL;
673
+ }
674
+ for (let power = 255; power < 512; power++) EXP[power] = EXP[power - 255];
675
+ }
676
+ const generatorCache = /* @__PURE__ */ new Map();
677
+ function gfMultiply(a, b) {
678
+ return a === 0 || b === 0 ? 0 : EXP[LOG[a] + LOG[b]];
679
+ }
680
+ function generatorPolynomial(degree) {
681
+ const cached = generatorCache.get(degree);
682
+ if (cached) return cached;
683
+ const coefficients = new Uint8Array(degree);
684
+ coefficients[degree - 1] = 1;
685
+ let root = 1;
686
+ for (let step = 0; step < degree; step++) {
687
+ for (let index = 0; index < degree; index++) {
688
+ coefficients[index] = gfMultiply(coefficients[index], root);
689
+ if (index + 1 < degree) coefficients[index] ^= coefficients[index + 1];
690
+ }
691
+ root = gfMultiply(root, 2);
692
+ }
693
+ generatorCache.set(degree, coefficients);
694
+ return coefficients;
695
+ }
696
+ function reedSolomonRemainder(data, degree) {
697
+ const generator = generatorPolynomial(degree);
698
+ const remainder = new Uint8Array(degree);
699
+ for (const byte of data) {
700
+ const factor = byte ^ remainder[0];
701
+ remainder.copyWithin(0, 1);
702
+ remainder[degree - 1] = 0;
703
+ for (let index = 0; index < degree; index++) remainder[index] ^= gfMultiply(generator[index], factor);
704
+ }
705
+ return remainder;
706
+ }
707
+ const ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
708
+ const MODES = [
709
+ "numeric",
710
+ "alphanumeric",
711
+ "byte"
712
+ ];
713
+ const MODE_INDICATORS = {
714
+ alphanumeric: 2,
715
+ byte: 4,
716
+ numeric: 1
717
+ };
718
+ const SCALED_CHARACTER_COST = {
719
+ alphanumeric: 33,
720
+ byte: 48,
721
+ numeric: 20
722
+ };
723
+ const ALPHANUMERIC_VALUES = new Map([...ALPHANUMERIC_CHARSET].map((character, index) => [character.charCodeAt(0), index]));
724
+ const utf8Encoder = new TextEncoder();
725
+ var QrCodeBitBuffer = class {
726
+ #bits = [];
727
+ get length() {
728
+ return this.#bits.length;
729
+ }
730
+ append(value, length) {
731
+ for (let bit = length - 1; bit >= 0; bit--) this.#bits.push(value >>> bit & 1);
732
+ }
733
+ toBytes() {
734
+ const bytes = new Uint8Array(Math.ceil(this.#bits.length / 8));
735
+ this.#bits.forEach((bit, index) => {
736
+ bytes[index >>> 3] |= bit << 7 - (index & 7);
737
+ });
738
+ return bytes;
739
+ }
740
+ };
741
+ function characterCountBits(mode, version) {
742
+ const tier = version <= 9 ? 0 : version <= 26 ? 1 : 2;
743
+ switch (mode) {
744
+ case "numeric": return [
745
+ 10,
746
+ 12,
747
+ 14
748
+ ][tier];
749
+ case "alphanumeric": return [
750
+ 9,
751
+ 11,
752
+ 13
753
+ ][tier];
754
+ case "byte": return [
755
+ 8,
756
+ 16,
757
+ 16
758
+ ][tier];
759
+ }
760
+ }
761
+ function encodeText(text, encoding) {
762
+ if (encoding === "utf-8") return { bytes: utf8Encoder.encode(text) };
763
+ const bytes = new Uint8Array(text.length);
764
+ for (let index = 0; index < text.length; index++) {
765
+ const code = text.charCodeAt(index);
766
+ if (code > 255) {
767
+ const codePoint = text.codePointAt(index) ?? code;
768
+ return { error: {
769
+ character: String.fromCodePoint(codePoint),
770
+ code: "unsupported-character",
771
+ index
772
+ } };
773
+ }
774
+ bytes[index] = code;
775
+ }
776
+ return { bytes };
777
+ }
778
+ function segmentBytes(bytes, version) {
779
+ if (bytes.length === 0) return [];
780
+ const headerCost = (mode) => (4 + characterCountBits(mode, version)) * 6;
781
+ const previous = [];
782
+ let costs = MODES.map((mode) => headerCost(mode));
783
+ for (let index = 0; index < bytes.length; index++) {
784
+ const byte = bytes[index];
785
+ const next = [
786
+ Infinity,
787
+ Infinity,
788
+ Infinity
789
+ ];
790
+ const from = (/* @__PURE__ */ new Int8Array(3)).fill(-1);
791
+ MODES.forEach((mode, modeIndex) => {
792
+ if (!fitsMode(byte, mode)) return;
793
+ MODES.forEach((_, fromIndex) => {
794
+ const cost = fromIndex === modeIndex ? costs[fromIndex] : Math.ceil(costs[fromIndex] / 6) * 6 + headerCost(mode);
795
+ if (cost < next[modeIndex]) {
796
+ next[modeIndex] = cost;
797
+ from[modeIndex] = fromIndex;
798
+ }
799
+ });
800
+ next[modeIndex] += SCALED_CHARACTER_COST[mode];
801
+ });
802
+ previous.push(from);
803
+ costs = next;
804
+ }
805
+ let modeIndex = costs.indexOf(Math.min(...costs));
806
+ const modes = new Array(bytes.length);
807
+ for (let index = bytes.length - 1; index >= 0; index--) {
808
+ modes[index] = modeIndex;
809
+ modeIndex = previous[index][modeIndex];
810
+ }
811
+ const segments = [];
812
+ let start = 0;
813
+ for (let index = 1; index <= bytes.length; index++) if (index === bytes.length || modes[index] !== modes[start]) {
814
+ segments.push({
815
+ bytes: bytes.subarray(start, index),
816
+ mode: MODES[modes[start]]
817
+ });
818
+ start = index;
819
+ }
820
+ return segments;
821
+ }
822
+ function segmentationBits(segmentation, version) {
823
+ let bits = segmentation.eci === null ? 0 : 12;
824
+ for (const segment of segmentation.segments) bits += 4 + characterCountBits(segment.mode, version) + segmentDataBits(segment);
825
+ return bits;
826
+ }
827
+ function writeSegments(buffer, segmentation, version) {
828
+ if (segmentation.eci !== null) {
829
+ buffer.append(7, 4);
830
+ buffer.append(segmentation.eci, 8);
831
+ }
832
+ for (const segment of segmentation.segments) {
833
+ buffer.append(MODE_INDICATORS[segment.mode], 4);
834
+ buffer.append(segment.bytes.length, characterCountBits(segment.mode, version));
835
+ writeSegmentData(buffer, segment);
836
+ }
837
+ }
838
+ function fitsMode(byte, mode) {
839
+ switch (mode) {
840
+ case "numeric": return byte >= 48 && byte <= 57;
841
+ case "alphanumeric": return ALPHANUMERIC_VALUES.has(byte);
842
+ case "byte": return true;
843
+ }
844
+ }
845
+ function segmentDataBits(segment) {
846
+ const count = segment.bytes.length;
847
+ switch (segment.mode) {
848
+ case "numeric": return Math.floor(count / 3) * 10 + [
849
+ 0,
850
+ 4,
851
+ 7
852
+ ][count % 3];
853
+ case "alphanumeric": return Math.floor(count / 2) * 11 + count % 2 * 6;
854
+ case "byte": return count * 8;
855
+ }
856
+ }
857
+ function writeSegmentData(buffer, segment) {
858
+ const { bytes } = segment;
859
+ switch (segment.mode) {
860
+ case "numeric":
861
+ for (let index = 0; index < bytes.length; index += 3) {
862
+ const group = bytes.subarray(index, index + 3);
863
+ const value = group.reduce((total, byte) => total * 10 + (byte - 48), 0);
864
+ buffer.append(value, [
865
+ 0,
866
+ 4,
867
+ 7,
868
+ 10
869
+ ][group.length]);
870
+ }
871
+ return;
872
+ case "alphanumeric":
873
+ for (let index = 0; index < bytes.length; index += 2) {
874
+ const first = ALPHANUMERIC_VALUES.get(bytes[index]) ?? 0;
875
+ if (index + 1 < bytes.length) buffer.append(first * 45 + (ALPHANUMERIC_VALUES.get(bytes[index + 1]) ?? 0), 11);
876
+ else buffer.append(first, 6);
877
+ }
878
+ return;
879
+ case "byte":
880
+ for (const byte of bytes) buffer.append(byte, 8);
881
+ return;
882
+ }
883
+ }
884
+ const PAD_BYTES = [236, 17];
885
+ function encodeQrCode(text, options) {
886
+ const { encoding, errorCorrection } = options;
887
+ const { bytes, error } = encodeText(text, encoding);
888
+ if (error) return { error };
889
+ const eci = encoding === "utf-8" && bytes.some((byte) => byte >= 128) ? 26 : null;
890
+ let requiredBits = 0;
891
+ for (let version = Math.max(1, options.minVersion ?? 1); version <= 40; version++) {
892
+ const segmentation = {
893
+ eci,
894
+ segments: segmentBytes(bytes, version)
895
+ };
896
+ requiredBits = segmentationBits(segmentation, version);
897
+ if (requiredBits <= dataCapacityBits(version, errorCorrection)) {
898
+ const codewords = buildCodewords(segmentation, version, errorCorrection);
899
+ return { matrix: buildQrCodeMatrix(version, errorCorrection, codewords, options.mask) };
900
+ }
901
+ }
902
+ return { error: {
903
+ availableBits: dataCapacityBits(40, errorCorrection),
904
+ code: "too-long",
905
+ requiredBits
906
+ } };
907
+ }
908
+ function buildCodewords(segmentation, version, errorCorrection) {
909
+ const layout = blockLayout(version, errorCorrection);
910
+ const capacityBits = layout.dataCodewords * 8;
911
+ const buffer = new QrCodeBitBuffer();
912
+ writeSegments(buffer, segmentation, version);
913
+ buffer.append(0, Math.min(4, capacityBits - buffer.length));
914
+ buffer.append(0, (8 - buffer.length % 8) % 8);
915
+ const data = new Uint8Array(layout.dataCodewords);
916
+ data.set(buffer.toBytes());
917
+ for (let index = buffer.length / 8; index < data.length; index++) data[index] = PAD_BYTES[(index - buffer.length / 8) % 2];
918
+ const longBlocks = layout.totalCodewords % layout.blocks;
919
+ const shortBlocks = layout.blocks - longBlocks;
920
+ const shortDataLength = Math.floor(layout.totalCodewords / layout.blocks) - layout.ecCodewordsPerBlock;
921
+ const dataBlocks = [];
922
+ const ecBlocks = [];
923
+ let offset = 0;
924
+ for (let block = 0; block < layout.blocks; block++) {
925
+ const length = shortDataLength + (block < shortBlocks ? 0 : 1);
926
+ const blockData = data.subarray(offset, offset + length);
927
+ dataBlocks.push(blockData);
928
+ ecBlocks.push(reedSolomonRemainder(blockData, layout.ecCodewordsPerBlock));
929
+ offset += length;
930
+ }
931
+ const codewords = new Uint8Array(layout.totalCodewords);
932
+ let position = 0;
933
+ for (let index = 0; index <= shortDataLength; index++) for (const block of dataBlocks) if (index < block.length) codewords[position++] = block[index];
934
+ for (let index = 0; index < layout.ecCodewordsPerBlock; index++) for (const block of ecBlocks) codewords[position++] = block[index];
935
+ return codewords;
936
+ }
937
+ function codewordBlocks(version, errorCorrection) {
938
+ const layout = blockLayout(version, errorCorrection);
939
+ const longBlocks = layout.totalCodewords % layout.blocks;
940
+ const shortBlocks = layout.blocks - longBlocks;
941
+ const shortDataLength = Math.floor(layout.totalCodewords / layout.blocks) - layout.ecCodewordsPerBlock;
942
+ const blocks = new Uint8Array(layout.totalCodewords);
943
+ let position = 0;
944
+ for (let index = 0; index <= shortDataLength; index++) for (let block = 0; block < layout.blocks; block++) if (index < shortDataLength + (block < shortBlocks ? 0 : 1)) blocks[position++] = block;
945
+ for (let index = 0; index < layout.ecCodewordsPerBlock; index++) for (let block = 0; block < layout.blocks; block++) blocks[position++] = block;
946
+ return blocks;
947
+ }
948
+ const DEFAULT_IMAGE_OVERLAY_SIZE = .2;
949
+ const SWISS_OVERLAY_SIZE = 7 / 46;
950
+ const SWISS_FRAME_SHARE = .5 / 7;
951
+ function buildQrCodeScene(matrix, quietZone, overlay) {
952
+ const symbolSize = matrix.size;
953
+ const size = symbolSize + quietZone * 2;
954
+ const modules = matrix.modules.slice();
955
+ let sceneOverlay = null;
956
+ let overlayExceedsCorrection = false;
957
+ if (overlay) {
958
+ const swiss = overlay.type === "swiss";
959
+ const share = swiss ? SWISS_OVERLAY_SIZE : imageOverlayShare(overlay.size);
960
+ const padding = swiss ? 0 : 1;
961
+ const clearCells = Math.min(oddCeiling(share * symbolSize + padding), symbolSize - 18);
962
+ const clearStart = (symbolSize - clearCells) / 2;
963
+ const drawnSize = Math.min(share * symbolSize, clearCells - padding);
964
+ const center = quietZone + symbolSize / 2;
965
+ const box = {
966
+ size: drawnSize,
967
+ x: center - drawnSize / 2,
968
+ y: center - drawnSize / 2
969
+ };
970
+ const clear = {
971
+ size: clearCells,
972
+ x: quietZone + clearStart,
973
+ y: quietZone + clearStart
974
+ };
975
+ overlayExceedsCorrection = hidesTooMuch(matrix, clearStart, clearCells);
976
+ for (let y = clearStart; y < clearStart + clearCells; y++) modules.fill(0, y * symbolSize + clearStart, y * symbolSize + clearStart + clearCells);
977
+ sceneOverlay = overlay.type === "swiss" ? swissOverlay(box, clear) : {
978
+ box,
979
+ clear,
980
+ kind: "image",
981
+ src: overlay.src
982
+ };
983
+ }
984
+ return {
985
+ modules,
986
+ modulesPath: modulesPath(modules, symbolSize, quietZone),
987
+ overlay: sceneOverlay,
988
+ overlayExceedsCorrection,
989
+ quietZone,
990
+ size,
991
+ symbolSize
992
+ };
993
+ }
994
+ function hidesTooMuch(matrix, clearStart, clearCells) {
995
+ const layout = blockLayout(matrix.version, matrix.errorCorrection);
996
+ const blockOf = codewordBlocks(matrix.version, matrix.errorCorrection);
997
+ const hidden = /* @__PURE__ */ new Set();
998
+ for (let y = clearStart; y < clearStart + clearCells; y++) for (let x = clearStart; x < clearStart + clearCells; x++) {
999
+ const codeword = matrix.codewordIndices[y * matrix.size + x];
1000
+ if (codeword >= 0) hidden.add(codeword);
1001
+ }
1002
+ const perBlock = new Array(layout.blocks).fill(0);
1003
+ hidden.forEach((codeword) => perBlock[blockOf[codeword]]++);
1004
+ const correctable = Math.floor((layout.ecCodewordsPerBlock - layout.misdecodeProtection) / 2);
1005
+ return perBlock.some((count) => count > correctable);
1006
+ }
1007
+ function imageOverlayShare(size) {
1008
+ return size !== void 0 && Number.isFinite(size) && size > 0 ? Math.min(size, 1) : DEFAULT_IMAGE_OVERLAY_SIZE;
1009
+ }
1010
+ function modulesPath(modules, symbolSize, quietZone) {
1011
+ const parts = [];
1012
+ for (let y = 0; y < symbolSize; y++) {
1013
+ let x = 0;
1014
+ while (x < symbolSize) {
1015
+ if (!modules[y * symbolSize + x]) {
1016
+ x++;
1017
+ continue;
1018
+ }
1019
+ const start = x;
1020
+ while (x < symbolSize && modules[y * symbolSize + x]) x++;
1021
+ parts.push(`M${start + quietZone} ${y + quietZone}h${x - start}v1h${start - x}z`);
1022
+ }
1023
+ }
1024
+ return parts.join("");
1025
+ }
1026
+ function oddCeiling(value) {
1027
+ const ceiling = Math.ceil(value);
1028
+ return ceiling % 2 === 1 ? ceiling : ceiling + 1;
1029
+ }
1030
+ function swissOverlay(box, clear) {
1031
+ const frame = box.size * SWISS_FRAME_SHARE;
1032
+ const badge = {
1033
+ size: box.size - frame * 2,
1034
+ x: box.x + frame,
1035
+ y: box.y + frame
1036
+ };
1037
+ const center = box.x + box.size / 2;
1038
+ const arm = badge.size * 3 / 32;
1039
+ const reach = badge.size * 10 / 32;
1040
+ const near = center - arm;
1041
+ const far = center + arm;
1042
+ const start = center - reach;
1043
+ const end = center + reach;
1044
+ return {
1045
+ badge,
1046
+ box,
1047
+ clear,
1048
+ cross: [
1049
+ [near, start],
1050
+ [far, start],
1051
+ [far, near],
1052
+ [end, near],
1053
+ [end, far],
1054
+ [far, far],
1055
+ [far, end],
1056
+ [near, end],
1057
+ [near, far],
1058
+ [start, far],
1059
+ [start, near],
1060
+ [near, near]
1061
+ ],
1062
+ kind: "swiss"
1063
+ };
1064
+ }
1065
+ function polygonPath(points) {
1066
+ const round = (value) => Math.round(value * 1e3) / 1e3;
1067
+ return `M${points.map(([x, y]) => `${round(x)} ${round(y)}`).join("L")}Z`;
1068
+ }
1069
+ const PDF_POINTS_PER_PX = .75;
1070
+ const MAX_PNG_SIZE = 16384;
1071
+ const IMAGE_LOAD_TIMEOUT_MS = 15e3;
1072
+ const PDF_IMAGE_PIXELS_PER_POINT = 4;
1073
+ const MIME_TYPES = {
1074
+ pdf: "application/pdf",
1075
+ png: "image/png",
1076
+ svg: "image/svg+xml"
1077
+ };
1078
+ async function exportQrCodeScene(scene, request) {
1079
+ return {
1080
+ blob: await exportBlob(scene, request),
1081
+ format: request.format,
1082
+ mimeType: MIME_TYPES[request.format],
1083
+ size: request.size
1084
+ };
1085
+ }
1086
+ function renderQrCodeSvg(scene, options) {
1087
+ const { background, foreground } = options;
1088
+ const parts = [`<svg xmlns="http://www.w3.org/2000/svg" width="${options.size}" height="${options.size}" viewBox="0 0 ${scene.size} ${scene.size}" shape-rendering="crispEdges" role="img">`, `<title>${escapeXml(options.label)}</title>`];
1089
+ if (background.a > 0) parts.push(`<rect width="${scene.size}" height="${scene.size}"${svgFill(background)}/>`);
1090
+ if (scene.modulesPath) parts.push(`<path d="${scene.modulesPath}"${svgFill(foreground)}/>`);
1091
+ const overlay = scene.overlay;
1092
+ if (overlay?.kind === "swiss") parts.push(svgRect(overlay.box, background), svgRect(overlay.badge, foreground), `<path d="${polygonPath(overlay.cross)}"${svgFill(background)}/>`);
1093
+ else if (overlay?.kind === "image" && options.imageHref) {
1094
+ const { box } = overlay;
1095
+ parts.push(`<image href="${escapeXml(options.imageHref)}" x="${round(box.x)}" y="${round(box.y)}" width="${round(box.size)}" height="${round(box.size)}" preserveAspectRatio="xMidYMid meet"/>`);
1096
+ }
1097
+ parts.push("</svg>");
1098
+ return parts.join("");
1099
+ }
1100
+ function toCssColor(color) {
1101
+ return `rgb(${color.r} ${color.g} ${color.b} / ${round(color.a / 255)})`;
1102
+ }
1103
+ function canvasToBlob(canvas) {
1104
+ return new Promise((resolve, reject) => {
1105
+ try {
1106
+ canvas.toBlob((blob) => {
1107
+ if (blob) resolve(blob);
1108
+ else reject(new QrCodeExportError("png-rasterization-failed", "The browser couldn't encode the PNG."));
1109
+ }, "image/png");
1110
+ } catch (error) {
1111
+ reject(new QrCodeExportError("resource-load-failed", "The overlay image comes from another origin that doesn't allow reading it (CORS).", { cause: error }));
1112
+ }
1113
+ });
1114
+ }
1115
+ function escapeXml(text) {
1116
+ return text.replace(/[<>&"']/g, (character) => `&#${character.charCodeAt(0)};`);
1117
+ }
1118
+ async function exportBlob(scene, request) {
1119
+ switch (request.format) {
1120
+ case "svg": {
1121
+ const overlay = scene.overlay;
1122
+ const imageHref = overlay?.kind === "image" ? await readAsDataUrl(overlay.src, request.document) : null;
1123
+ const svg = renderQrCodeSvg(scene, {
1124
+ ...request,
1125
+ imageHref
1126
+ });
1127
+ return new Blob([svg], { type: MIME_TYPES.svg });
1128
+ }
1129
+ case "png": return exportPng(scene, request);
1130
+ case "pdf": return exportPdf(scene, request);
1131
+ }
1132
+ }
1133
+ async function exportPdf(scene, request) {
1134
+ let jsPdfModule;
1135
+ try {
1136
+ jsPdfModule = await import("jspdf");
1137
+ } catch (error) {
1138
+ throw new QrCodeExportError("pdf-generation-failed", "Exporting a QR code as a PDF needs the jspdf package. Install it alongside Mona UI.", { cause: error });
1139
+ }
1140
+ const overlay = scene.overlay;
1141
+ const image = overlay?.kind === "image" ? await loadImage(overlay.src, request.document) : null;
1142
+ try {
1143
+ const page = request.size * PDF_POINTS_PER_PX;
1144
+ const unit = page / scene.size;
1145
+ const pdf = new jsPdfModule.jsPDF({
1146
+ compress: true,
1147
+ format: [page, page],
1148
+ orientation: "portrait",
1149
+ unit: "pt"
1150
+ });
1151
+ const setFill = (color) => {
1152
+ pdf.setFillColor(color.r, color.g, color.b);
1153
+ pdf.setGState(new jsPdfModule.GState({ opacity: color.a / 255 }));
1154
+ };
1155
+ const fillBox = (box, color) => {
1156
+ if (color.a > 0) {
1157
+ setFill(color);
1158
+ pdf.rect(box.x * unit, box.y * unit, box.size * unit, box.size * unit, "F");
1159
+ }
1160
+ };
1161
+ fillBox({
1162
+ size: scene.size,
1163
+ x: 0,
1164
+ y: 0
1165
+ }, request.background);
1166
+ const runs = moduleRuns(scene);
1167
+ if (runs.length > 0 && request.foreground.a > 0) {
1168
+ setFill(request.foreground);
1169
+ for (const [x, y, length] of runs) {
1170
+ pdf.moveTo(x * unit, y * unit);
1171
+ pdf.lineTo((x + length) * unit, y * unit);
1172
+ pdf.lineTo((x + length) * unit, (y + 1) * unit);
1173
+ pdf.lineTo(x * unit, (y + 1) * unit);
1174
+ pdf.close();
1175
+ }
1176
+ pdf.fill();
1177
+ }
1178
+ if (overlay?.kind === "swiss") {
1179
+ fillBox(overlay.box, request.background);
1180
+ fillBox(overlay.badge, request.foreground);
1181
+ if (request.background.a > 0) {
1182
+ setFill(request.background);
1183
+ tracePolygon(overlay.cross, unit, pdf);
1184
+ pdf.fill();
1185
+ }
1186
+ } else if (overlay?.kind === "image" && image) {
1187
+ const fitted = fitImage({
1188
+ size: Math.max(1, Math.round(overlay.box.size * unit * PDF_IMAGE_PIXELS_PER_POINT)),
1189
+ x: 0,
1190
+ y: 0
1191
+ }, image);
1192
+ const canvas = request.document.createElement("canvas");
1193
+ canvas.width = Math.max(1, Math.round(fitted.width));
1194
+ canvas.height = Math.max(1, Math.round(fitted.height));
1195
+ canvas.getContext("2d")?.drawImage(image, 0, 0, canvas.width, canvas.height);
1196
+ const box = fitImage(overlay.box, image);
1197
+ pdf.setGState(new jsPdfModule.GState({ opacity: 1 }));
1198
+ pdf.addImage(canvas.toDataURL("image/png"), "PNG", box.x * unit, box.y * unit, box.width * unit, box.height * unit);
1199
+ }
1200
+ return pdf.output("blob");
1201
+ } catch (error) {
1202
+ if (error instanceof QrCodeExportError) throw error;
1203
+ const tainted = error instanceof DOMException && error.name === "SecurityError";
1204
+ throw new QrCodeExportError(tainted ? "resource-load-failed" : "pdf-generation-failed", tainted ? "The overlay image comes from another origin that doesn't allow reading it (CORS)." : "jsPDF failed to write the page.", { cause: error });
1205
+ }
1206
+ }
1207
+ async function exportPng(scene, request) {
1208
+ const size = Math.round(request.size);
1209
+ if (size < scene.size || size > 16384) throw new QrCodeExportError("invalid-size", `A PNG of this code is between ${scene.size} and ${MAX_PNG_SIZE} pixels wide, one pixel per module at least; got ${size}.`);
1210
+ const canvas = request.document.createElement("canvas");
1211
+ canvas.width = size;
1212
+ canvas.height = size;
1213
+ const context = canvas.getContext("2d");
1214
+ if (!context) throw new QrCodeExportError("png-rasterization-failed", "The browser has no 2D canvas to draw the PNG on.");
1215
+ const modulePixels = Math.floor(size / scene.size);
1216
+ const offset = Math.floor((size - modulePixels * scene.size) / 2);
1217
+ const fill = (color, draw) => {
1218
+ if (color.a > 0) {
1219
+ context.fillStyle = toCssColor(color);
1220
+ draw();
1221
+ }
1222
+ };
1223
+ const fillBox = (box, color) => fill(color, () => context.fillRect(box.x, box.y, box.size, box.size));
1224
+ fill(request.background, () => context.fillRect(0, 0, size, size));
1225
+ context.setTransform(modulePixels, 0, 0, modulePixels, offset, offset);
1226
+ fill(request.foreground, () => context.fill(new Path2D(scene.modulesPath)));
1227
+ const overlay = scene.overlay;
1228
+ if (overlay?.kind === "swiss") {
1229
+ fillBox(overlay.box, request.background);
1230
+ fillBox(overlay.badge, request.foreground);
1231
+ fill(request.background, () => context.fill(new Path2D(polygonPath(overlay.cross))));
1232
+ } else if (overlay?.kind === "image") {
1233
+ const image = await loadImage(overlay.src, request.document);
1234
+ const box = fitImage(overlay.box, image);
1235
+ context.drawImage(image, box.x, box.y, box.width, box.height);
1236
+ }
1237
+ return canvasToBlob(canvas);
1238
+ }
1239
+ function fitImage(box, image) {
1240
+ const naturalWidth = image.naturalWidth || 1;
1241
+ const naturalHeight = image.naturalHeight || 1;
1242
+ const scale = box.size / Math.max(naturalWidth, naturalHeight);
1243
+ const width = naturalWidth * scale;
1244
+ const height = naturalHeight * scale;
1245
+ return {
1246
+ height,
1247
+ width,
1248
+ x: box.x + (box.size - width) / 2,
1249
+ y: box.y + (box.size - height) / 2
1250
+ };
1251
+ }
1252
+ function loadImage(src, document) {
1253
+ return new Promise((resolve, reject) => {
1254
+ const image = document.createElement("img");
1255
+ const fail = (message) => {
1256
+ clearTimeout(timeout);
1257
+ reject(new QrCodeExportError("resource-load-failed", message));
1258
+ };
1259
+ const timeout = setTimeout(() => fail(`The overlay image didn't load within ${IMAGE_LOAD_TIMEOUT_MS} ms.`), IMAGE_LOAD_TIMEOUT_MS);
1260
+ image.crossOrigin = "anonymous";
1261
+ image.onload = () => {
1262
+ clearTimeout(timeout);
1263
+ resolve(image);
1264
+ };
1265
+ image.onerror = () => fail("The overlay image didn't load, or its origin doesn't allow reading it (CORS).");
1266
+ image.src = src;
1267
+ });
1268
+ }
1269
+ function moduleRuns(scene) {
1270
+ const runs = [];
1271
+ const { modules, quietZone, symbolSize } = scene;
1272
+ for (let y = 0; y < symbolSize; y++) {
1273
+ let x = 0;
1274
+ while (x < symbolSize) {
1275
+ if (!modules[y * symbolSize + x]) {
1276
+ x++;
1277
+ continue;
1278
+ }
1279
+ const start = x;
1280
+ while (x < symbolSize && modules[y * symbolSize + x]) x++;
1281
+ runs.push([
1282
+ start + quietZone,
1283
+ y + quietZone,
1284
+ x - start
1285
+ ]);
1286
+ }
1287
+ }
1288
+ return runs;
1289
+ }
1290
+ async function readAsDataUrl(src, document) {
1291
+ if (src.startsWith("data:")) return src;
1292
+ const view = document.defaultView;
1293
+ try {
1294
+ const response = await fetch(new URL(src, document.baseURI), { mode: "cors" });
1295
+ if (!response.ok) throw new Error(`HTTP ${response.status}`);
1296
+ const blob = await response.blob();
1297
+ return await new Promise((resolve, reject) => {
1298
+ const reader = new ((view?.FileReader) ?? FileReader)();
1299
+ reader.onload = () => resolve(String(reader.result));
1300
+ reader.onerror = () => reject(reader.error);
1301
+ reader.readAsDataURL(blob);
1302
+ });
1303
+ } catch (error) {
1304
+ throw new QrCodeExportError("resource-load-failed", "The overlay image didn't load, or its origin doesn't allow reading it (CORS).", { cause: error });
1305
+ }
1306
+ }
1307
+ function round(value) {
1308
+ return Math.round(value * 1e3) / 1e3;
1309
+ }
1310
+ function svgFill(color) {
1311
+ const hex = `#${[
1312
+ color.r,
1313
+ color.g,
1314
+ color.b
1315
+ ].map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
1316
+ return color.a < 255 ? ` fill="${hex}" fill-opacity="${round(color.a / 255)}"` : ` fill="${hex}"`;
1317
+ }
1318
+ function svgRect(box, color) {
1319
+ if (color.a === 0) return "";
1320
+ return `<rect x="${round(box.x)}" y="${round(box.y)}" width="${round(box.size)}" height="${round(box.size)}"${svgFill(color)}/>`;
1321
+ }
1322
+ function tracePolygon(points, unit, pdf) {
1323
+ points.forEach(([x, y], index) => {
1324
+ if (index === 0) pdf.moveTo(x * unit, y * unit);
1325
+ else pdf.lineTo(x * unit, y * unit);
1326
+ });
1327
+ pdf.close();
1328
+ }
1329
+ const QR_CODE_HOST_CLASSES = `
1330
+ inline-block aspect-square max-w-full shrink-0 align-middle
1331
+ forced-color-adjust-none
1332
+ [&>svg]:block [&>svg]:size-full
1333
+ `;
1334
+ function validateQrCodeValue(value, options) {
1335
+ const encoding = options?.encoding ?? "utf-8";
1336
+ const errorCorrection = options?.errorCorrection ?? "M";
1337
+ const { bytes, error } = encodeText(String(value ?? ""), encoding);
1338
+ if (error) return error;
1339
+ const requiredBits = segmentationBits({
1340
+ eci: encoding === "utf-8" && bytes.some((byte) => byte >= 128) ? 26 : null,
1341
+ segments: segmentBytes(bytes, 40)
1342
+ }, 40);
1343
+ const availableBits = dataCapacityBits(40, errorCorrection);
1344
+ return requiredBits > availableBits ? {
1345
+ availableBits,
1346
+ code: "too-long",
1347
+ requiredBits
1348
+ } : null;
1349
+ }
1350
+ function describeQrCodeValueError(error) {
1351
+ switch (error.code) {
1352
+ case "unsupported-character": return `The encoding can't store "${error.character}" at index ${error.index}. Use encoding "utf-8".`;
1353
+ case "too-long": return `The value needs ${error.requiredBits} bits, more than the ${error.availableBits} the largest QR code holds at this error correction level. Shorten it or lower errorCorrection.`;
1354
+ }
1355
+ }
1356
+ const FALLBACK_EXPORT_SIZE = 200;
1357
+ const DEFAULT_QUIET_ZONE = 4;
1358
+ const MIN_OVERLAY_VERSION = 2;
1359
+ var QrCodeComponent = class QrCodeComponent {
1360
+ #document;
1361
+ #elementRef;
1362
+ #encoded;
1363
+ #i18n;
1364
+ #platformId;
1365
+ #quietZone;
1366
+ constructor() {
1367
+ this.#document = inject(DOCUMENT);
1368
+ this.#elementRef = inject(ElementRef);
1369
+ this.#encoded = computed(() => {
1370
+ const text = String(this.value() ?? "");
1371
+ if (!text) return null;
1372
+ return encodeQrCode(text, {
1373
+ encoding: this.encoding(),
1374
+ errorCorrection: this.errorCorrection(),
1375
+ minVersion: this.overlay() ? MIN_OVERLAY_VERSION : void 0
1376
+ });
1377
+ }, ...ngDevMode ? [{ debugName: "#encoded" }] : /* istanbul ignore next */ []);
1378
+ this.#i18n = inject(MonaI18nService);
1379
+ this.#platformId = inject(PLATFORM_ID);
1380
+ this.#quietZone = computed(() => {
1381
+ const quietZone = this.quietZone();
1382
+ return Number.isFinite(quietZone) ? Math.max(0, Math.round(quietZone)) : DEFAULT_QUIET_ZONE;
1383
+ }, ...ngDevMode ? [{ debugName: "#quietZone" }] : /* istanbul ignore next */ []);
1384
+ this.classes = computed(() => twMerge(QR_CODE_HOST_CLASSES, this.userClass()), ...ngDevMode ? [{ debugName: "classes" }] : /* istanbul ignore next */ []);
1385
+ this.crossPath = computed(() => {
1386
+ const overlay = this.scene()?.overlay;
1387
+ return overlay?.kind === "swiss" ? polygonPath(overlay.cross) : "";
1388
+ }, ...ngDevMode ? [{ debugName: "crossPath" }] : /* istanbul ignore next */ []);
1389
+ this.cssSize = computed(() => toCssValue(this.size()), ...ngDevMode ? [{ debugName: "cssSize" }] : /* istanbul ignore next */ []);
1390
+ this.imageOverlay = computed(() => {
1391
+ const overlay = this.scene()?.overlay;
1392
+ return overlay?.kind === "image" ? overlay : null;
1393
+ }, ...ngDevMode ? [{ debugName: "imageOverlay" }] : /* istanbul ignore next */ []);
1394
+ this.label = computed(() => this.ariaLabel() || this.messages().label, ...ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []);
1395
+ this.messages = this.#i18n.componentMessages("qrCode", QR_CODE_DEFAULT_MESSAGES);
1396
+ this.scene = computed(() => {
1397
+ const matrix = this.#encoded()?.matrix;
1398
+ return matrix ? buildQrCodeScene(matrix, this.#quietZone(), this.overlay()) : null;
1399
+ }, ...ngDevMode ? [{ debugName: "scene" }] : /* istanbul ignore next */ []);
1400
+ this.swissOverlay = computed(() => {
1401
+ const overlay = this.scene()?.overlay;
1402
+ return overlay?.kind === "swiss" ? overlay : null;
1403
+ }, ...ngDevMode ? [{ debugName: "swissOverlay" }] : /* istanbul ignore next */ []);
1404
+ this.viewBox = computed(() => {
1405
+ const size = this.scene()?.size ?? 0;
1406
+ return `0 0 ${size} ${size}`;
1407
+ }, ...ngDevMode ? [{ debugName: "viewBox" }] : /* istanbul ignore next */ []);
1408
+ this.ariaLabel = input("", {
1409
+ ...ngDevMode ? { debugName: "ariaLabel" } : /* istanbul ignore next */ {},
1410
+ alias: "aria-label"
1411
+ });
1412
+ this.background = input("#ffffff", ...ngDevMode ? [{ debugName: "background" }] : /* istanbul ignore next */ []);
1413
+ this.color = input("#000000", ...ngDevMode ? [{ debugName: "color" }] : /* istanbul ignore next */ []);
1414
+ this.encoding = input("utf-8", ...ngDevMode ? [{ debugName: "encoding" }] : /* istanbul ignore next */ []);
1415
+ this.error = computed(() => this.#encoded()?.error ?? null, ...ngDevMode ? [{ debugName: "error" }] : /* istanbul ignore next */ []);
1416
+ this.errorCorrection = input("M", ...ngDevMode ? [{ debugName: "errorCorrection" }] : /* istanbul ignore next */ []);
1417
+ this.overlay = input(null, ...ngDevMode ? [{ debugName: "overlay" }] : /* istanbul ignore next */ []);
1418
+ this.quietZone = input(DEFAULT_QUIET_ZONE, ...ngDevMode ? [{ debugName: "quietZone" }] : /* istanbul ignore next */ []);
1419
+ this.size = input(200, ...ngDevMode ? [{ debugName: "size" }] : /* istanbul ignore next */ []);
1420
+ this.userClass = input("", {
1421
+ ...ngDevMode ? { debugName: "userClass" } : /* istanbul ignore next */ {},
1422
+ alias: "class"
1423
+ });
1424
+ this.value = input("", ...ngDevMode ? [{ debugName: "value" }] : /* istanbul ignore next */ []);
1425
+ if (isDevMode()) {
1426
+ effect(() => {
1427
+ const error = this.error();
1428
+ if (error) console.warn(`mona-qr-code: ${describeQrCodeValueError(error)}`);
1429
+ });
1430
+ effect(() => {
1431
+ if (this.scene()?.overlayExceedsCorrection) console.warn(`mona-qr-code: The overlay hides more of the code than error correction level "${this.errorCorrection()}" can recover, so it may not scan. Raise errorCorrection or make the overlay smaller.`);
1432
+ });
1433
+ }
1434
+ }
1435
+ async downloadQrCode(options) {
1436
+ const result = await this.exportQrCode(options);
1437
+ downloadBlob(this.#document, result.blob, qrCodeFileName(options.fileName, options.format));
1438
+ return result;
1439
+ }
1440
+ async exportQrCode(options) {
1441
+ if (!isPlatformBrowser(this.#platformId)) throw new QrCodeExportError("unsupported-environment", "QR codes can only be exported in a browser.");
1442
+ const scene = this.scene();
1443
+ if (!scene) {
1444
+ const error = this.error();
1445
+ throw new QrCodeExportError("not-ready", error ? describeQrCodeValueError(error) : "There's no value to encode.");
1446
+ }
1447
+ const size = options.size ?? this.#renderedSize();
1448
+ if (!Number.isFinite(size) || size <= 0) throw new QrCodeExportError("invalid-size", `The export size has to be a positive number; got ${size}.`);
1449
+ const host = this.#elementRef.nativeElement;
1450
+ return exportQrCodeScene(scene, {
1451
+ background: resolveQrCodeColor(host, this.background(), WHITE),
1452
+ document: this.#document,
1453
+ foreground: resolveQrCodeColor(host, this.color(), BLACK),
1454
+ format: options.format,
1455
+ label: this.label(),
1456
+ size
1457
+ });
1458
+ }
1459
+ #renderedSize() {
1460
+ const width = this.#elementRef.nativeElement.getBoundingClientRect().width;
1461
+ if (width > 0) return width;
1462
+ const size = this.size();
1463
+ return typeof size === "number" && size > 0 ? size : FALLBACK_EXPORT_SIZE;
1464
+ }
1465
+ static {
1466
+ this.ɵfac = i0.ɵɵngDeclareFactory({
1467
+ minVersion: "12.0.0",
1468
+ version: "22.2.6",
1469
+ ngImport: i0,
1470
+ type: QrCodeComponent,
1471
+ deps: [],
1472
+ target: i0.ɵɵFactoryTarget.Component
1473
+ });
1474
+ }
1475
+ static {
1476
+ this.ɵcmp = i0.ɵɵngDeclareComponent({
1477
+ minVersion: "17.0.0",
1478
+ version: "22.2.6",
1479
+ type: QrCodeComponent,
1480
+ isStandalone: true,
1481
+ selector: "mona-qr-code",
1482
+ inputs: {
1483
+ ariaLabel: {
1484
+ classPropertyName: "ariaLabel",
1485
+ publicName: "aria-label",
1486
+ isSignal: true,
1487
+ isRequired: false,
1488
+ transformFunction: null
1489
+ },
1490
+ background: {
1491
+ classPropertyName: "background",
1492
+ publicName: "background",
1493
+ isSignal: true,
1494
+ isRequired: false,
1495
+ transformFunction: null
1496
+ },
1497
+ color: {
1498
+ classPropertyName: "color",
1499
+ publicName: "color",
1500
+ isSignal: true,
1501
+ isRequired: false,
1502
+ transformFunction: null
1503
+ },
1504
+ encoding: {
1505
+ classPropertyName: "encoding",
1506
+ publicName: "encoding",
1507
+ isSignal: true,
1508
+ isRequired: false,
1509
+ transformFunction: null
1510
+ },
1511
+ errorCorrection: {
1512
+ classPropertyName: "errorCorrection",
1513
+ publicName: "errorCorrection",
1514
+ isSignal: true,
1515
+ isRequired: false,
1516
+ transformFunction: null
1517
+ },
1518
+ overlay: {
1519
+ classPropertyName: "overlay",
1520
+ publicName: "overlay",
1521
+ isSignal: true,
1522
+ isRequired: false,
1523
+ transformFunction: null
1524
+ },
1525
+ quietZone: {
1526
+ classPropertyName: "quietZone",
1527
+ publicName: "quietZone",
1528
+ isSignal: true,
1529
+ isRequired: false,
1530
+ transformFunction: null
1531
+ },
1532
+ size: {
1533
+ classPropertyName: "size",
1534
+ publicName: "size",
1535
+ isSignal: true,
1536
+ isRequired: false,
1537
+ transformFunction: null
1538
+ },
1539
+ userClass: {
1540
+ classPropertyName: "userClass",
1541
+ publicName: "class",
1542
+ isSignal: true,
1543
+ isRequired: false,
1544
+ transformFunction: null
1545
+ },
1546
+ value: {
1547
+ classPropertyName: "value",
1548
+ publicName: "value",
1549
+ isSignal: true,
1550
+ isRequired: false,
1551
+ transformFunction: null
1552
+ }
1553
+ },
1554
+ host: { properties: {
1555
+ "class": "classes()",
1556
+ "style.width": "cssSize()",
1557
+ "attr.role": "scene() ? 'img' : null",
1558
+ "attr.aria-label": "scene() ? label() : null"
1559
+ } },
1560
+ exportAs: ["monaQrCode"],
1561
+ ngImport: i0,
1562
+ template: "@if (scene(); as scene) {\n <svg [attr.viewBox]=\"viewBox()\" aria-hidden=\"true\" focusable=\"false\" shape-rendering=\"crispEdges\">\n <rect [attr.width]=\"scene.size\" [attr.height]=\"scene.size\" [style.fill]=\"background()\" />\n <path [attr.d]=\"scene.modulesPath\" [style.fill]=\"color()\" />\n @if (swissOverlay(); as swiss) {\n <rect\n [attr.x]=\"swiss.box.x\"\n [attr.y]=\"swiss.box.y\"\n [attr.width]=\"swiss.box.size\"\n [attr.height]=\"swiss.box.size\"\n [style.fill]=\"background()\" />\n <rect\n [attr.x]=\"swiss.badge.x\"\n [attr.y]=\"swiss.badge.y\"\n [attr.width]=\"swiss.badge.size\"\n [attr.height]=\"swiss.badge.size\"\n [style.fill]=\"color()\" />\n <path [attr.d]=\"crossPath()\" [style.fill]=\"background()\" />\n }\n @if (imageOverlay(); as image) {\n <image\n [attr.href]=\"image.src\"\n [attr.x]=\"image.box.x\"\n [attr.y]=\"image.box.y\"\n [attr.width]=\"image.box.size\"\n [attr.height]=\"image.box.size\"\n preserveAspectRatio=\"xMidYMid meet\" />\n }\n </svg>\n}\n"
1563
+ });
1564
+ }
1565
+ };
1566
+ i0.ɵɵngDeclareClassMetadata({
1567
+ minVersion: "12.0.0",
1568
+ version: "22.2.6",
1569
+ ngImport: i0,
1570
+ type: QrCodeComponent,
1571
+ decorators: [{
1572
+ type: Component,
1573
+ args: [{
1574
+ selector: "mona-qr-code",
1575
+ exportAs: "monaQrCode",
1576
+ host: {
1577
+ "[class]": "classes()",
1578
+ "[style.width]": "cssSize()",
1579
+ "[attr.role]": "scene() ? 'img' : null",
1580
+ "[attr.aria-label]": "scene() ? label() : null"
1581
+ },
1582
+ template: "@if (scene(); as scene) {\n <svg [attr.viewBox]=\"viewBox()\" aria-hidden=\"true\" focusable=\"false\" shape-rendering=\"crispEdges\">\n <rect [attr.width]=\"scene.size\" [attr.height]=\"scene.size\" [style.fill]=\"background()\" />\n <path [attr.d]=\"scene.modulesPath\" [style.fill]=\"color()\" />\n @if (swissOverlay(); as swiss) {\n <rect\n [attr.x]=\"swiss.box.x\"\n [attr.y]=\"swiss.box.y\"\n [attr.width]=\"swiss.box.size\"\n [attr.height]=\"swiss.box.size\"\n [style.fill]=\"background()\" />\n <rect\n [attr.x]=\"swiss.badge.x\"\n [attr.y]=\"swiss.badge.y\"\n [attr.width]=\"swiss.badge.size\"\n [attr.height]=\"swiss.badge.size\"\n [style.fill]=\"color()\" />\n <path [attr.d]=\"crossPath()\" [style.fill]=\"background()\" />\n }\n @if (imageOverlay(); as image) {\n <image\n [attr.href]=\"image.src\"\n [attr.x]=\"image.box.x\"\n [attr.y]=\"image.box.y\"\n [attr.width]=\"image.box.size\"\n [attr.height]=\"image.box.size\"\n preserveAspectRatio=\"xMidYMid meet\" />\n }\n </svg>\n}\n"
1583
+ }]
1584
+ }],
1585
+ ctorParameters: () => [],
1586
+ propDecorators: {
1587
+ ariaLabel: [{
1588
+ type: i0.Input,
1589
+ args: [{
1590
+ isSignal: true,
1591
+ alias: "aria-label",
1592
+ required: false
1593
+ }]
1594
+ }],
1595
+ background: [{
1596
+ type: i0.Input,
1597
+ args: [{
1598
+ isSignal: true,
1599
+ alias: "background",
1600
+ required: false
1601
+ }]
1602
+ }],
1603
+ color: [{
1604
+ type: i0.Input,
1605
+ args: [{
1606
+ isSignal: true,
1607
+ alias: "color",
1608
+ required: false
1609
+ }]
1610
+ }],
1611
+ encoding: [{
1612
+ type: i0.Input,
1613
+ args: [{
1614
+ isSignal: true,
1615
+ alias: "encoding",
1616
+ required: false
1617
+ }]
1618
+ }],
1619
+ errorCorrection: [{
1620
+ type: i0.Input,
1621
+ args: [{
1622
+ isSignal: true,
1623
+ alias: "errorCorrection",
1624
+ required: false
1625
+ }]
1626
+ }],
1627
+ overlay: [{
1628
+ type: i0.Input,
1629
+ args: [{
1630
+ isSignal: true,
1631
+ alias: "overlay",
1632
+ required: false
1633
+ }]
1634
+ }],
1635
+ quietZone: [{
1636
+ type: i0.Input,
1637
+ args: [{
1638
+ isSignal: true,
1639
+ alias: "quietZone",
1640
+ required: false
1641
+ }]
1642
+ }],
1643
+ size: [{
1644
+ type: i0.Input,
1645
+ args: [{
1646
+ isSignal: true,
1647
+ alias: "size",
1648
+ required: false
1649
+ }]
1650
+ }],
1651
+ userClass: [{
1652
+ type: i0.Input,
1653
+ args: [{
1654
+ isSignal: true,
1655
+ alias: "class",
1656
+ required: false
1657
+ }]
1658
+ }],
1659
+ value: [{
1660
+ type: i0.Input,
1661
+ args: [{
1662
+ isSignal: true,
1663
+ alias: "value",
1664
+ required: false
1665
+ }]
1666
+ }]
1667
+ }
1668
+ });
1669
+ export { QR_CODE_DEFAULT_MESSAGES, QrCodeComponent, QrCodeExportError, validateQrCodeValue };
1670
+
1671
+ //# sourceMappingURL=nanahoshi-mona-ui-qr-code.mjs.map