@tapple.io/qr-code-generator 0.9.9 → 0.9.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -35
- package/dist/browser.mjs +10 -27
- package/dist/index.d.ts +19 -22
- package/dist/node.cjs +10 -27
- package/dist/node.mjs +10 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -150,7 +150,7 @@ const ascii = genQrText('Hello', {
|
|
|
150
150
|
### Image Options (PNG & SVG)
|
|
151
151
|
|
|
152
152
|
```typescript
|
|
153
|
-
import { genQrImage,
|
|
153
|
+
import { genQrImage, DotShape, BorderStyle } from '@tapple.io/qr-code-generator';
|
|
154
154
|
|
|
155
155
|
const options = {
|
|
156
156
|
size: 300, // QR matrix size in pixels
|
|
@@ -159,8 +159,9 @@ const options = {
|
|
|
159
159
|
|
|
160
160
|
// Eye (position marker) styling
|
|
161
161
|
eyes: {
|
|
162
|
-
|
|
163
|
-
color: '#0066ff'
|
|
162
|
+
cornerRadius: 0.5, // 0 = square, 0.5 = circle (default: 0.2)
|
|
163
|
+
color: '#0066ff', // Supports all CSS color formats
|
|
164
|
+
strokeWidth: 1.0 // 0.9-1.1, controls border thickness (default: 1.0)
|
|
164
165
|
},
|
|
165
166
|
|
|
166
167
|
// Pupil (center of eyes) styling
|
|
@@ -183,10 +184,10 @@ const options = {
|
|
|
183
184
|
|
|
184
185
|
// Border styling
|
|
185
186
|
border: {
|
|
186
|
-
|
|
187
|
-
width: 10, // Border width in pixels
|
|
187
|
+
cornerRadius: 0.19, // 0 = square, 0.5 = circle, 0.19 = squircle (default: 0.04)
|
|
188
|
+
width: 10, // Border width in pixels (default: 0 = no border)
|
|
188
189
|
color: 'rgba(0, 0, 0, 0.8)', // RGBA with transparency supported
|
|
189
|
-
style:
|
|
190
|
+
style: BorderStyle.SOLID // 'solid' | 'dashed' | 'dotted' | 'double'
|
|
190
191
|
},
|
|
191
192
|
|
|
192
193
|
// Output configuration
|
|
@@ -209,8 +210,9 @@ Complete reference for PNG and SVG rendering options:
|
|
|
209
210
|
| `margin` | number | `24` | >= 0 | Spacing around QR code in pixels |
|
|
210
211
|
| `backgroundColor` | string | `'#ffffff'` | CSS color | Background color (supports hex, rgb/rgba, hsl/hsla, named colors) |
|
|
211
212
|
| **Eyes (Position Markers)** |
|
|
212
|
-
| `eyes.
|
|
213
|
+
| `eyes.cornerRadius` | number | `0.2` | 0 - 0.5 | Corner radius scale: 0 = square, 0.5 = circle |
|
|
213
214
|
| `eyes.color` | string | `'#000000'` | CSS color | Color of eye frames (supports hex, rgb/rgba, hsl/hsla, named colors) |
|
|
215
|
+
| `eyes.strokeWidth` | number | `1.0` | 0.9 - 1.1 | Border thickness scale: 1.0 = standard, 1.1 = 10% thicker, 0.9 = 10% thinner |
|
|
214
216
|
| **Pupils (Eye Centers)** |
|
|
215
217
|
| `pupils.color` | string | `'#000000'` | CSS color | Color of pupil (inner square of eyes) |
|
|
216
218
|
| **Dots (Data Modules)** |
|
|
@@ -221,10 +223,10 @@ Complete reference for PNG and SVG rendering options:
|
|
|
221
223
|
| `logo.src` | string | - | Data URL or SVG string | Image source |
|
|
222
224
|
| `logo.scale` | number | `0.2` | 0.1 - 0.3 | Logo size as percentage of QR width |
|
|
223
225
|
| **Border** |
|
|
224
|
-
| `border.
|
|
225
|
-
| `border.width` | number | `
|
|
226
|
+
| `border.cornerRadius` | number | `0.04` | 0 - 0.5 | Corner radius scale: 0 = square, 0.5 = circle, 0.19 = squircle |
|
|
227
|
+
| `border.width` | number | `0` | >=0 | Border thickness in pixels (0 = no border) |
|
|
226
228
|
| `border.color` | string | `'#000000'` | CSS color | Border color (supports hex, rgb/rgba, hsl/hsla, named colors) |
|
|
227
|
-
| `border.style` | enum | `'solid'` | `'solid'` \| `'dashed'` | Border line style |
|
|
229
|
+
| `border.style` | enum | `'solid'` | `'solid'` \| `'dashed'` \| `'dotted'` \| `'double'` | Border line style |
|
|
228
230
|
| **Output** |
|
|
229
231
|
| `output.format` | enum | `'png'` | `'png'` \| `'svg'` | Output image format |
|
|
230
232
|
| `output.type` | enum | `'buffer'` | `'buffer'` \| `'dataURL'` (png), `'string'` \| `'dataURL'` (svg) | Output type |
|
|
@@ -268,10 +270,10 @@ border: { color: 'red' }
|
|
|
268
270
|
// You can mix different formats in the same QR code
|
|
269
271
|
const qr = await genQrImage('Hello', {
|
|
270
272
|
backgroundColor: 'white',
|
|
271
|
-
eyes: { color: '#0066ff' },
|
|
273
|
+
eyes: { cornerRadius: 0.5, color: '#0066ff' },
|
|
272
274
|
pupils: { color: 'rgb(0, 0, 0)' },
|
|
273
275
|
dots: { color: 'hsl(0, 0%, 20%)' },
|
|
274
|
-
border: {
|
|
276
|
+
border: { cornerRadius: 0.5, width: 10, color: 'rgba(0, 0, 0, 0.5)' }
|
|
275
277
|
});
|
|
276
278
|
```
|
|
277
279
|
|
|
@@ -378,31 +380,23 @@ const qr = await genQrImage({
|
|
|
378
380
|
const qr = await genQrImage('https://en.wikipedia.org/wiki/Denso');
|
|
379
381
|
```
|
|
380
382
|
|
|
381
|
-
##
|
|
383
|
+
## Enums
|
|
382
384
|
|
|
383
|
-
Import
|
|
385
|
+
Import enums for type-safe customization:
|
|
384
386
|
|
|
385
387
|
```typescript
|
|
386
|
-
import {
|
|
387
|
-
|
|
388
|
-
// Eye shapes
|
|
389
|
-
EyeFrameShape.SQUARE
|
|
390
|
-
EyeFrameShape.SQUIRCLE
|
|
388
|
+
import { DotShape, BorderStyle } from '@tapple.io/qr-code-generator';
|
|
391
389
|
|
|
392
390
|
// Dot shapes
|
|
393
|
-
DotShape.CLASSIC
|
|
394
|
-
DotShape.DOTS
|
|
395
|
-
DotShape.SQUARE
|
|
396
|
-
|
|
397
|
-
// Border shapes
|
|
398
|
-
BorderShape.NONE
|
|
399
|
-
BorderShape.SQUARE
|
|
400
|
-
BorderShape.SQUIRCLE
|
|
401
|
-
BorderShape.CIRCLE
|
|
391
|
+
DotShape.CLASSIC // Classic square modules
|
|
392
|
+
DotShape.DOTS // Circular dots
|
|
393
|
+
DotShape.SQUARE // Rounded squares
|
|
402
394
|
|
|
403
395
|
// Border styles
|
|
404
|
-
BorderStyle.SOLID
|
|
405
|
-
BorderStyle.DASHED
|
|
396
|
+
BorderStyle.SOLID // Solid line
|
|
397
|
+
BorderStyle.DASHED // Dashed line
|
|
398
|
+
BorderStyle.DOTTED // Dotted line
|
|
399
|
+
BorderStyle.DOUBLE // Double line (concentric strokes)
|
|
406
400
|
```
|
|
407
401
|
|
|
408
402
|
## Advanced Examples
|
|
@@ -410,14 +404,14 @@ BorderStyle.DASHED
|
|
|
410
404
|
### Custom Styled QR Code
|
|
411
405
|
|
|
412
406
|
```typescript
|
|
413
|
-
import { genQrImage,
|
|
407
|
+
import { genQrImage, DotShape, BorderStyle } from '@tapple.io/qr-code-generator';
|
|
414
408
|
|
|
415
409
|
const styledQR = await genQrImage('https://en.wikipedia.org/wiki/Denso', {
|
|
416
410
|
size: 500,
|
|
417
411
|
margin: 30,
|
|
418
412
|
backgroundColor: '#f8f9fa',
|
|
419
413
|
eyes: {
|
|
420
|
-
|
|
414
|
+
cornerRadius: 0.5,
|
|
421
415
|
color: '#0066ff'
|
|
422
416
|
},
|
|
423
417
|
pupils: {
|
|
@@ -429,10 +423,10 @@ const styledQR = await genQrImage('https://en.wikipedia.org/wiki/Denso', {
|
|
|
429
423
|
scale: 0.9
|
|
430
424
|
},
|
|
431
425
|
border: {
|
|
432
|
-
|
|
426
|
+
cornerRadius: 0.19,
|
|
433
427
|
width: 15,
|
|
434
428
|
color: '#0066ff',
|
|
435
|
-
style:
|
|
429
|
+
style: BorderStyle.SOLID
|
|
436
430
|
},
|
|
437
431
|
output: { format: 'png', type: 'dataURL' }
|
|
438
432
|
});
|
|
@@ -583,7 +577,7 @@ The library includes comprehensive test coverage:
|
|
|
583
577
|
The demo showcases real-time QR code generation with all available options including colors, shapes, borders, logos, and more.
|
|
584
578
|
|
|
585
579
|
**Try it locally:**
|
|
586
|
-
|
|
580
|
+
|
|
587
581
|
```bash
|
|
588
582
|
# Clone the repository
|
|
589
583
|
git clone https://github.com/tappleinc/qr-code-generator.git
|
package/dist/browser.mjs
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
|
|
3
|
-
S${a+s},${i+n} ${a},${i+n}
|
|
4
|
-
S${a-n},${i+s} ${a-n},${i}
|
|
5
|
-
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`}}},w={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`}}},D={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:h}=Be(m,s);return`<rect x="${e+d}" y="${t+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-h}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,c=t+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,c=t+i,u=i-s/2,f=r*Pe,d=Math.max(0,f-s/2),m=u-d,g=`M${l},${c-u}
|
|
6
|
-
H${l+m}
|
|
7
|
-
A${d},${d} 0 0 1 ${l+u},${c-m}
|
|
8
|
-
V${c+m}
|
|
9
|
-
A${d},${d} 0 0 1 ${l+m},${c+u}
|
|
10
|
-
H${l-m}
|
|
11
|
-
A${d},${d} 0 0 1 ${l-u},${c+m}
|
|
12
|
-
V${c-m}
|
|
13
|
-
A${d},${d} 0 0 1 ${l-m},${c-u}
|
|
14
|
-
Z`;if(a==="dashed"){let h=2*m,y=.5*Math.PI*d,b=4*h+4*y,{dashArray:x,offset:Le}=Z(b,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${x}" stroke-dashoffset="${Le}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,c=r/2;if(a==="dashed"){let m=c-s/2,g=2*Math.PI*m,{dashArray:h,offset:y}=Z(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${y}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
|
-
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
|
-
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
|
-
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
-
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}}};var $=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
1
|
+
var U={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},R={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},z={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},w="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ke={1:[10,12,14],2:[9,11,13],4:[8,16,16]},M={L:1,M:0,Q:3,H:2},$=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],_=[31892,34236,39577,42195],j=[0,7,7,7,7,7,0,0,0,0];function C(e){return e*4+17}function S(e,t){let r=t<10?0:t<27?1:2;return ke[e][r]}var W=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(W||{}),G=(n=>(n.SOLID="solid",n.DASHED="dashed",n.DOTTED="dotted",n.DOUBLE="double",n))(G||{});function De(e,t){let n=t*3,s=t*2,i=n+s,a=Math.max(1,Math.round(e/i)),l=e/a,c=l*(3/5),u=l*(2/5),d=u/2;return{dashArray:`${c} ${u}`,offset:d}}function O(e,t,r,o,n){let s=r*n;return`<rect x="${e}" y="${t}" width="${r}" height="${r}" rx="${s}" fill="${o}"/>`}var v={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,i=r*.35;return`<circle cx="${n}" cy="${s}" r="${i}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,i=e+s,a=t+s;return`<rect x="${i}" y="${a}" width="${n}" height="${n}" fill="${o}"/>`}}};function q(e,t,r,o,n,s,i="solid"){let a=r*s,l=n/2,c=r-n;if(i==="dashed"){let{dashArray:u,offset:d}=De(c,n);return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}" stroke-dasharray="${u}" stroke-dashoffset="${-d}"/>`}if(i==="dotted"){let u=n*.1,d=n*1.5;return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}" stroke-dasharray="${u} ${d}" stroke-linecap="round"/>`}if(i==="double"){let u=n*.3,d=n*.3,m=n*.4,f=u/2,g=r-u,b=g*s,h=u+m+d/2,y=r-2*h,I=y*s;return`<rect x="${e+f}" y="${t+f}" width="${g}" height="${g}" rx="${b}" fill="none" stroke="${o}" stroke-width="${u}"/><rect x="${e+h}" y="${t+h}" width="${y}" height="${y}" rx="${I}" fill="none" stroke="${o}" stroke-width="${d}"/>`}return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}"/>`}var x=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
2
|
`);super(`QR Code validation failed:
|
|
20
|
-
${r}`),this.name="QRValidationError",this.errors=t}};function Ne(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function L(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=L(t[r]));return t}function K(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Fe(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return Qe(e,t);case"enum":return ee(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Ue(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"?{field:t,value:e,message:'must be either "solid" or "dashed"'}:null;default:return null}}function J(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Ne(e,o),a=K(s,o,n);a&&r.push(a)}return r}function Fe(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function Qe(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,i,l,c,u]=o,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>255||d<0||d>255||m<0||m>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,i,l,c,u]=n,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(d<0||d>100||m<0||m>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function ee(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Ue(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function te(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function T(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function re(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function X(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ne(e){let t=L(e),o=J(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.shape":{type:"enum",enumObj:v,optional:!0},"eyes.color":{type:"color",optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:w,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.border?.shape!==void 0&&t.border.shape!=="none"){let n=ee(t.border.shape,"border.shape",D);n&&o.push(n)}if(t.logo){let n=K(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new $(o);return t}function oe(e){let t=L(e),o=J(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new $(o);return t}function P(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new $(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new $(t);let r=e;switch(r.type){case"wifi":_e(e.data,t);break;case"vcard":je(e.data,t);break;case"calendar":We(e.data,t);break;case"email":ze(e,t);break;case"sms":Ge(e,t);break;case"phone":qe(e,t);break;case"url":He(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new $(t)}function _e(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function je(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!te(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!T(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!re(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function We(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=X(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=X(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function ze(e,t){let r=e;(!r.email||typeof r.email!="string"||!te(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function Ge(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!T(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function qe(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!T(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function He(e,t){let r=e;(!r.url||typeof r.url!="string"||!re(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},k={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function se(e){if(!e){let{logo:o,...n}=p;return n}let t=ne(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{shape:t.eyes?.shape??p.eyes.shape,color:t.eyes?.color??p.eyes.color},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{shape:t.border?.shape??p.border.shape,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ae(e){if(!e)return{...k};let t=oe(e);return{margin:t.margin??k.margin,darkChar:t.darkChar??k.darkChar,lightChar:t.lightChar??k.lightChar}}function ie(e){return/^\d+$/.test(e)?1:[...e].every(t=>R.includes(t))?2:4}function Ye(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function Ze(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=R.indexOf(e[r])*45+R.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=R.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function Xe(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function Ke(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=O(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function Je(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function et(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function le(e,t,r){let o=ie(e),n,s;o===1?(n=Ye(e),s=e.length):o===2?(n=Ze(e),s=e.length):(n=Xe(e),s=new TextEncoder().encode(e).length);let a=Ke(n,o,s,t),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=Je(a);return et(l,r)}function M(e,t){let r=ie(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=O(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=t[l-1])return l}let n=O(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ce(e,t){if(t)try{if(M(e,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(M(e,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var S=new Array(256),V=new Array(256);function tt(){let e=1;for(let t=0;t<255;t++)S[t]=e,V[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)S[t]=S[t-255]}tt();function de(e,t){return e===0||t===0?0:S[V[e]+V[t]]}function rt(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=de(t[s],S[r]);t=n}return t}function ue(e,t){let r=rt(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=de(r[a],s)}return o.slice(e.length)}function fe(e,t,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=e.slice(c,c+a);o.push(f);let d=ue(f,t);n.push(d),c+=a}for(let u=0;u<i;u++){let f=e.slice(c,c+l);o.push(f);let d=ue(f,t);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function me(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function ge(e){let t=E(e);return Array.from({length:t},()=>Array(t).fill(!1))}function pe(e){let t=E(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=I[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function B(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function nt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function he(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function be(e){B(e,0,0),B(e,0,e.length-7),B(e,e.length-7,0)}function ye(e,t){let r=e.length,o=I[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||nt(e,n,s)}function $e(e,t){e[4*t+9][8]=!0}function xe(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let c=n<r.length?r[n]:!1;e[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function N(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function ot(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],c=1,u=1;for(let f=1;f<t;f++)e[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=e[a][f],c=1),e[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let c=0;c<t;c++)i=i<<1&2047|(e[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Ce(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(c=>[...c]);N(i,t,a),o(i,r,a);let l=ot(i);l<s&&(s=l,n=a)}return n}function F(e,t,r){let o=e.length,n=A[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function Re(e,t){if(t<7)return;let r=e.length,o=W[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function Ee(e,t){return A[e]<<3|t}function ve(e,t,r,o,n){let s=ge(e),a=pe(e);be(s),he(s),ye(s,e),$e(s,e),xe(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??Ce(s,a,t,F);return N(s,a,l),F(s,t,l),Re(s,e),{matrix:s,mask:l,formatInfo:n?Ee(t,l):void 0,unmaskedMatrix:i}}function Q(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function we(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Se(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function st(e,t,r,o,n,s,a){let i=v[r]||v.square,l=i.renderSVG(e,t,7*a,o),c=i.renderSVG(e+a,t+a,5*a,s),u=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+c+u}function at(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${c}"${
|
|
22
|
-
${
|
|
3
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function Me(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function L(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=L(t[r]));return t}function Y(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Le(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return Ae(e,t);case"enum":return Te(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Pe(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"&&e!=="dotted"&&e!=="double"?{field:t,value:e,message:'must be "solid", "dashed", "dotted", or "double"'}:null;default:return null}}function X(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Me(e,o),i=Y(s,o,n);i&&r.push(i)}return r}function Le(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function Ae(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,a,l,c,u]=o,d=parseInt(a,10),m=parseInt(l,10),f=parseInt(c,10);if(d<0||d>255||m<0||m>255||f<0||f>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,a,l,c,u]=n,d=parseInt(a,10),m=parseInt(l,10),f=parseInt(c,10);if(d<0||d>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(m<0||m>100||f<0||f>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function Te(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Pe(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function K(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function A(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function Z(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function H(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function J(e){let t=L(e),o=X(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.cornerRadius":{type:"number",min:0,max:.5,optional:!0},"eyes.color":{type:"color",optional:!0},"eyes.strokeWidth":{type:"number",min:.9,max:1.1,optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:v,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.cornerRadius":{type:"number",min:0,max:.5,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.logo){let n=Y(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new x(o);return t}function ee(e){let t=L(e),o=X(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new x(o);return t}function T(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new x(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new x(t);let r=e;switch(r.type){case"wifi":Be(e.data,t);break;case"vcard":Ve(e.data,t);break;case"calendar":Ne(e.data,t);break;case"email":Fe(e,t);break;case"sms":Qe(e,t);break;case"phone":Ue(e,t);break;case"url":ze(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new x(t)}function Be(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function Ve(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!K(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!A(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!Z(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Ne(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=H(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=H(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Fe(e,t){let r=e;(!r.email||typeof r.email!="string"||!K(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function Qe(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!A(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function Ue(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!A(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function ze(e,t){let r=e;(!r.url||typeof r.url!="string"||!Z(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{cornerRadius:.2,color:"#000000",strokeWidth:1},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{cornerRadius:.04,width:0,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},k={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function te(e){if(!e){let{logo:o,...n}=p;return n}let t=J(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{cornerRadius:t.eyes?.cornerRadius??p.eyes.cornerRadius,color:t.eyes?.color??p.eyes.color,strokeWidth:t.eyes?.strokeWidth??p.eyes.strokeWidth},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{cornerRadius:t.border?.cornerRadius??p.border.cornerRadius,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function re(e){if(!e)return{...k};let t=ee(e);return{margin:t.margin??k.margin,darkChar:t.darkChar??k.darkChar,lightChar:t.lightChar??k.lightChar}}function ne(e){return/^\d+$/.test(e)?1:[...e].every(t=>w.includes(t))?2:4}function _e(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let i=s-1;i>=0;i--)t.push(n>>i&1)}return t}function je(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=w.indexOf(e[r])*45+w.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=w.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function We(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function Ge(e,t,r,o){let n=[];for(let i=3;i>=0;i--)n.push(t>>i&1);let s=S(t,o);for(let i=s-1;i>=0;i--)n.push(r>>i&1);return[...n,...e]}function qe(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function He(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function oe(e,t,r){let o=ne(e),n,s;o===1?(n=_e(e),s=e.length):o===2?(n=je(e),s=e.length):(n=We(e),s=new TextEncoder().encode(e).length);let i=Ge(n,o,s,t),a=Math.min(4,r*8-i.length);for(let c=0;c<a;c++)i.push(0);for(;i.length%8!==0;)i.push(0);let l=qe(i);return He(l,r)}function D(e,t){let r=ne(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=S(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+c+u;if(Math.ceil(d/8)<=t[l-1])return l}let n=S(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,i=4+n+s,a=Math.ceil(i/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${a} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function se(e,t){if(t)try{if(D(e,R.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(D(e,R[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var E=new Array(256),P=new Array(256);function Ye(){let e=1;for(let t=0;t<255;t++)E[t]=e,P[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)E[t]=E[t-255]}Ye();function ae(e,t){return e===0||t===0?0:E[P[e]+P[t]]}function Xe(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=ae(t[s],E[r]);t=n}return t}function ie(e,t){let r=Xe(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let i=0;i<r.length;i++)o[n+i]^=ae(r[i],s)}return o.slice(e.length)}function le(e,t,r){let o=[],n=[],[s,i,a,l]=r,c=0;for(let u=0;u<s;u++){let d=e.slice(c,c+i);o.push(d);let m=ie(d,t);n.push(m),c+=i}for(let u=0;u<a;u++){let d=e.slice(c,c+l);o.push(d);let m=ie(d,t);n.push(m),c+=l}return{dataBlocks:o,ecBlocks:n}}function ce(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let i of e)s<i.length&&r.push(i[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let i of t)s<i.length&&r.push(i[s]);return r}function ue(e){let t=C(e);return Array.from({length:t},()=>Array(t).fill(!1))}function de(e){let t=C(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=$[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let a=-2;a<=2;a++)for(let l=-2;l<=2;l++)r[n+a][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function B(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,i=r+n;if(s<0||s>=e.length||i<0||i>=e.length)continue;let a=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][i]=a||l}}function Ke(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,i=o===0&&n===0;e[t+o][r+n]=s||i}}function me(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function fe(e){B(e,0,0),B(e,0,e.length-7),B(e,e.length-7,0)}function ge(e,t){let r=e.length,o=$[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||Ke(e,n,s)}function pe(e,t){e[4*t+9][8]=!0}function be(e,t,r){let o=e.length,n=0,s=-1,i=o-1;for(let a=o-1;a>0;a-=2)for(a===6&&a--;;){for(let l=0;l<2;l++)if(!t[i][a-l]){let c=n<r.length?r[n]:!1;e[i][a-l]=c,n++}if(i+=s,i<0||o<=i){i-=s,s=-s;break}}}function V(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let i=!1;switch(r){case 0:i=(n+s)%2===0;break;case 1:i=n%2===0;break;case 2:i=s%3===0;break;case 3:i=(n+s)%3===0;break;case 4:i=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:i=n*s%2+n*s%3===0;break;case 6:i=(n*s%2+n*s%3)%2===0;break;case 7:i=((n+s)%2+n*s%3)%2===0;break}i&&(e[n][s]=!e[n][s])}}function Ze(e){let t=e.length,r=0;for(let i=0;i<t;i++){let a=e[i][0],l=e[0][i],c=1,u=1;for(let d=1;d<t;d++)e[i][d]===a?c++:(c>=5&&(r+=3+(c-5)),a=e[i][d],c=1),e[d][i]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[d][i],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let i=0;i<t-1;i++)for(let a=0;a<t-1;a++){let l=e[i][a];e[i][a+1]===l&&e[i+1][a]===l&&e[i+1][a+1]===l&&(r+=3)}for(let i=0;i<t;i++){let a=0,l=0;for(let c=0;c<t;c++)a=a<<1&2047|(e[i][c]?1:0),c>=10&&(a===1488||a===93)&&(r+=40),l=l<<1&2047|(e[c][i]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let i=0;i<t;i++)for(let a=0;a<t;a++)e[i][a]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function he(e,t,r,o){let n=0,s=1/0;for(let i=0;i<8;i++){let a=e.map(c=>[...c]);V(a,t,i),o(a,r,i);let l=Ze(a);l<s&&(s=l,n=i)}return n}function N(e,t,r){let o=e.length,n=M[t]<<3|r,s=n<<10;for(let a=0;a<5;a++)s&1<<14-a&&(s^=1335<<4-a);let i=(n<<10|s)^21522;for(let a=0;a<15;a++){let l=(i>>14-a&1)===1;a<=5?e[8][a]=l:a===6?e[8][7]=l:a===7?e[8][8]=l:a===8?e[7][8]=l:e[5-(a-9)][8]=l,a<=6?e[o-1-a][8]=l:e[8][o-8+(a-7)]=l}}function ye(e,t){if(t<7)return;let r=e.length,o=_[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,i=Math.floor(n/3),a=r-11+n%3;e[i][a]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function xe(e,t){return M[e]<<3|t}function Re(e,t,r,o,n){let s=ue(e),i=de(e);fe(s),me(s),ge(s,e),pe(s,e),be(s,i,r);let a=n?s.map(c=>[...c]):void 0,l=o??he(s,i,t,N);return V(s,i,l),N(s,t,l),ye(s,e),{matrix:s,mask:l,formatInfo:n?xe(t,l):void 0,unmaskedMatrix:a}}function F(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function we(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ce(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function Je(e,t,r,o,n,s,i,a){let c=7-2*o,u=(7-c)/2,d=O(e,t,7*a,n,r),m=O(e+u*a,t+u*a,c*a,i,r),f=O(e+2*a,t+2*a,3*a,s,r);return d+m+f}function et(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let a=e;if(e.includes("data:image/svg")){let f=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(f){let g=f[1];if(e.includes("base64"))try{if(typeof atob<"u")a=atob(g);else if(typeof Buffer<"u")a=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{a=decodeURIComponent(g)}catch{return""}}}let l=a.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=a.match(/<svg([\s\S]*?)>/i),d="";if(u){let f=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);f&&(d=" "+f.join(" "))}let m=a.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
4
|
+
<svg width="${o}" height="${o}" viewBox="${c}"${d}>
|
|
5
|
+
${m}
|
|
23
6
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function
|
|
25
|
-
`;for(let
|
|
26
|
-
`}for(let
|
|
27
|
-
`;return s}async function
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
7
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function tt(e,t,r,o,n){let s=e.matrixSize,i="",a=v[r]||v.classic;if(r==="classic"){i=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!F(l,c,s)){let u=c*t,d=l*t,m=n*t,f=(1-n)*t/2,g=u+f,b=d+f;i+=`M${g},${b}h${m}v${m}h${-m}z`}return i+='"/>',i}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!F(l,c,s)){let u=c*t,d=l*t,m=n*t,f=(1-n)*t/2,g=u+f,b=d+f,h={qrcode:e.modules,qrSize:s,row:l,col:c};i+=a.renderSVG(g,b,m,o,h)}return i}function ve(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:i,dots:a}=t,l=r/e.matrixSize,c=t.border.width,u=r+2*o+2*c,d=o+c,m=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}">`;m+=`<rect width="${u}" height="${u}" fill="${n}"/>`,c>0&&(m+=q(0,0,u,t.border.color,c,t.border.cornerRadius,t.border.style)),c>0&&(m+=`<rect x="${d}" y="${d}" width="${r}" height="${r}" fill="${n}"/>`),m+=`<g transform="translate(${d}, ${d})">`;let f=we(e.matrixSize),g="";for(let y of f)g+=Je(y.x*l,y.y*l,s.cornerRadius,s.strokeWidth,s.color,i.color,n,l);let b=tt(e,l,a.shape,a.color,a.scale);m+=g+b+"</g>";let h="";if(t.logo){let y=Ce(e.matrixSize,t.logo.scale)*l,I=u/2;h=et(t.logo.src,I,I,y)}return m+=h+"</svg>",m}function Ee(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",i=e.matrixSize+r*2;for(let a=0;a<r;a++)s+=o.repeat(i)+`
|
|
8
|
+
`;for(let a=0;a<e.matrixSize;a++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[a][l]?n:o;s+=o.repeat(r)+`
|
|
9
|
+
`}for(let a=0;a<r;a++)s+=o.repeat(i)+`
|
|
10
|
+
`;return s}async function Ie(e,t){let{output:r,size:o,margin:n,border:s}=t,i=s.width,a=o+2*n+2*i;return new Promise((l,c)=>{let u=document.createElement("canvas");u.width=a,u.height=a;let d=u.getContext("2d");if(!d){c(new Error("Failed to get canvas context"));return}let m=new Image,f=null;try{let g=new Blob([e],{type:"image/svg+xml;charset=utf-8"});f=URL.createObjectURL(g)}catch{c(new Error("Failed to create SVG blob for rasterization"));return}m.onload=()=>{if(f&&URL.revokeObjectURL(f),d.drawImage(m,0,0,a,a),r.type==="dataURL"){let g=u.toDataURL("image/png");l(g)}else u.toBlob(g=>{if(!g){c(new Error("Failed to convert PNG to blob"));return}g.arrayBuffer().then(b=>{l(new Uint8Array(b))})},"image/png")},m.onerror=()=>{f&&URL.revokeObjectURL(f),c(new Error("Failed to load SVG for rasterization"))},m.src=f})}async function $e(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Ie(e,t)}function Q(e){if(typeof e=="string")return e;switch(e.type){case"url":return rt(e.url);case"vcard":return nt(e.data);case"wifi":return ot(e.data);case"calendar":return st(e.data);case"email":return it(e.email,e.subject,e.body);case"sms":return at(e.phone,e.message);case"phone":return lt(e.phone)}}function rt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function nt(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:i}=e.address,a=["","",r||"",o||"",n||"",s||"",i||""];t.push(`ADR:${a.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
11
|
+
`)}function ot(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=Se(e.ssid),n=Se(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function Se(e){return e.replace(/([\\;,":])/g,"\\$1")}function st(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
12
|
+
`)}function it(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function at(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function lt(e){return`tel:${e}`}function ct(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=j[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function Oe(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=se(e,t),o=R[r],n=D(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${R[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=oe(e,n,o[n-1]),i=U[r][n-1],a=z[r][n-1],{dataBlocks:l,ecBlocks:c}=le(s,i,a),u=ce(l,c),d=ct(u,n),{matrix:m,mask:f}=Re(n,r,d);return{version:n,matrixSize:C(n),modules:m,mask:f,errorCorrectionLevel:r}}async function ut(e,t){T(e);let r=Q(e),o=te(t),n=Oe(r,!!o.logo),s=ve(n,o);return await $e(s,o)}function dt(e,t){T(e);let r=Q(e),o=re(t),n=Oe(r,!1);return Ee(n,o)}export{G as BorderStyle,W as DotShape,x as QRValidationError,ut as genQrImage,dt as genQrText};
|
package/dist/index.d.ts
CHANGED
|
@@ -6,13 +6,6 @@
|
|
|
6
6
|
* This file contains all types, interfaces, and enums that are part of the public API.
|
|
7
7
|
* Internal types used only within the library are in internal/core/types.ts
|
|
8
8
|
*/
|
|
9
|
-
/**
|
|
10
|
-
* Eye frame (outer 7x7 position marker) shape options
|
|
11
|
-
*/
|
|
12
|
-
export declare enum EyeFrameShape {
|
|
13
|
-
SQUARE = "square",
|
|
14
|
-
SQUIRCLE = "squircle"
|
|
15
|
-
}
|
|
16
9
|
/**
|
|
17
10
|
* Data dot (module) shape options
|
|
18
11
|
*/
|
|
@@ -21,21 +14,14 @@ export declare enum DotShape {
|
|
|
21
14
|
DOTS = "dots",
|
|
22
15
|
SQUARE = "square"
|
|
23
16
|
}
|
|
24
|
-
/**
|
|
25
|
-
* Border shape options
|
|
26
|
-
*/
|
|
27
|
-
export declare enum BorderShape {
|
|
28
|
-
NONE = "none",
|
|
29
|
-
SQUARE = "square",
|
|
30
|
-
SQUIRCLE = "squircle",
|
|
31
|
-
CIRCLE = "circle"
|
|
32
|
-
}
|
|
33
17
|
/**
|
|
34
18
|
* Border style options
|
|
35
19
|
*/
|
|
36
20
|
export declare enum BorderStyle {
|
|
37
21
|
SOLID = "solid",
|
|
38
|
-
DASHED = "dashed"
|
|
22
|
+
DASHED = "dashed",
|
|
23
|
+
DOTTED = "dotted",
|
|
24
|
+
DOUBLE = "double"
|
|
39
25
|
}
|
|
40
26
|
/**
|
|
41
27
|
* vCard contact information
|
|
@@ -142,12 +128,20 @@ export interface ImageOptions {
|
|
|
142
128
|
margin?: number;
|
|
143
129
|
/** Background color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#ffffff') */
|
|
144
130
|
backgroundColor?: string;
|
|
145
|
-
/** Eye (outer frame) styling */
|
|
131
|
+
/** Eye (outer frame) styling - pupils inherit these settings */
|
|
146
132
|
eyes?: {
|
|
147
|
-
/**
|
|
148
|
-
|
|
133
|
+
/** Corner radius scale: 0 = square, 0.5 = circle (default: 0) - pupils inherit this value */
|
|
134
|
+
cornerRadius?: number;
|
|
149
135
|
/** Eye frame color - supports hex (#fff, #ffffff), rgb/rgba, hsl/hsla, or named colors (default: '#000000') */
|
|
150
136
|
color?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Border width scale (0.9 to 1.1, default: 1.0)
|
|
139
|
+
* Controls the thickness of the eye frame border:
|
|
140
|
+
* - 1.0 = standard 1-module border width
|
|
141
|
+
* - 1.1 = 10% thicker border
|
|
142
|
+
* - 0.9 = 10% thinner border
|
|
143
|
+
*/
|
|
144
|
+
strokeWidth?: number;
|
|
151
145
|
};
|
|
152
146
|
/** Pupil (inner core) styling */
|
|
153
147
|
pupils?: {
|
|
@@ -172,8 +166,11 @@ export interface ImageOptions {
|
|
|
172
166
|
};
|
|
173
167
|
/** Border styling (surrounds margin area) */
|
|
174
168
|
border?: {
|
|
175
|
-
/**
|
|
176
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Corner radius scale: 0 = square, 0.5 = circle (default: 0)
|
|
171
|
+
* Example: 0.19 creates squircle-like rounded corners
|
|
172
|
+
*/
|
|
173
|
+
cornerRadius?: number;
|
|
177
174
|
/**
|
|
178
175
|
* Border width in pixels (default: 10)
|
|
179
176
|
* Total output size = size + 2×margin + 2×width
|
package/dist/node.cjs
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
|
|
3
|
-
S${a+s},${i+n} ${a},${i+n}
|
|
4
|
-
S${a-n},${i+s} ${a-n},${i}
|
|
5
|
-
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`}}},E={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`}}},k={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:h}=Xe(m,s);return`<rect x="${e+d}" y="${t+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-h}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,c=t+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,c=t+i,u=i-s/2,f=r*Ye,d=Math.max(0,f-s/2),m=u-d,g=`M${l},${c-u}
|
|
6
|
-
H${l+m}
|
|
7
|
-
A${d},${d} 0 0 1 ${l+u},${c-m}
|
|
8
|
-
V${c+m}
|
|
9
|
-
A${d},${d} 0 0 1 ${l+m},${c+u}
|
|
10
|
-
H${l-m}
|
|
11
|
-
A${d},${d} 0 0 1 ${l-u},${c+m}
|
|
12
|
-
V${c-m}
|
|
13
|
-
A${d},${d} 0 0 1 ${l-m},${c-u}
|
|
14
|
-
Z`;if(a==="dashed"){let h=2*m,$=.5*Math.PI*d,b=4*h+4*$,{dashArray:v,offset:Fe}=J(b,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${v}" stroke-dashoffset="${Fe}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,c=r/2;if(a==="dashed"){let m=c-s/2,g=2*Math.PI*m,{dashArray:h,offset:$}=J(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${$}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
|
-
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
|
-
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
|
-
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
-
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}}};var y=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
1
|
+
"use strict";var Pe=Object.create;var $=Object.defineProperty;var Be=Object.getOwnPropertyDescriptor;var Ne=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Qe=(e,t)=>{for(var r in t)$(e,r,{get:t[r],enumerable:!0})},W=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Ne(t))!je.call(e,n)&&n!==r&&$(e,n,{get:()=>t[n],enumerable:!(o=Be(t,n))||o.enumerable});return e};var Fe=(e,t,r)=>(r=e!=null?Pe(Ve(e)):{},W(t||!e||!e.__esModule?$(r,"default",{value:e,enumerable:!0}):r,e)),ze=e=>W($({},"__esModule",{value:!0}),e);var It={};Qe(It,{BorderStyle:()=>P,DotShape:()=>L,QRValidationError:()=>h,genQrImage:()=>Ae,genQrText:()=>Le});module.exports=ze(It);var G={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},v={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},q={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},R="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",_e={1:[10,12,14],2:[9,11,13],4:[8,16,16]},A={L:1,M:0,Q:3,H:2},S=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],H=[31892,34236,39577,42195],Y=[0,7,7,7,7,7,0,0,0,0];function w(e){return e*4+17}function k(e,t){let r=t<10?0:t<27?1:2;return _e[e][r]}var L=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(L||{}),P=(n=>(n.SOLID="solid",n.DASHED="dashed",n.DOTTED="dotted",n.DOUBLE="double",n))(P||{});function Ue(e,t){let n=t*3,s=t*2,i=n+s,a=Math.max(1,Math.round(e/i)),l=e/a,c=l*(3/5),u=l*(2/5),d=u/2;return{dashArray:`${c} ${u}`,offset:d}}function O(e,t,r,o,n){let s=r*n;return`<rect x="${e}" y="${t}" width="${r}" height="${r}" rx="${s}" fill="${o}"/>`}var C={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,i=r*.35;return`<circle cx="${n}" cy="${s}" r="${i}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,i=e+s,a=t+s;return`<rect x="${i}" y="${a}" width="${n}" height="${n}" fill="${o}"/>`}}};function X(e,t,r,o,n,s,i="solid"){let a=r*s,l=n/2,c=r-n;if(i==="dashed"){let{dashArray:u,offset:d}=Ue(c,n);return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}" stroke-dasharray="${u}" stroke-dashoffset="${-d}"/>`}if(i==="dotted"){let u=n*.1,d=n*1.5;return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}" stroke-dasharray="${u} ${d}" stroke-linecap="round"/>`}if(i==="double"){let u=n*.3,d=n*.3,f=n*.4,m=u/2,g=r-u,x=g*s,b=u+f+d/2,y=r-2*b,I=y*s;return`<rect x="${e+m}" y="${t+m}" width="${g}" height="${g}" rx="${x}" fill="none" stroke="${o}" stroke-width="${u}"/><rect x="${e+b}" y="${t+b}" width="${y}" height="${y}" rx="${I}" fill="none" stroke="${o}" stroke-width="${d}"/>`}return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}"/>`}var h=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
2
|
`);super(`QR Code validation failed:
|
|
20
|
-
${r}`),this.name="QRValidationError",this.errors=t}};function Ke(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function F(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=F(t[r]));return t}function te(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Je(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return et(e,t);case"enum":return ne(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:tt(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"?{field:t,value:e,message:'must be either "solid" or "dashed"'}:null;default:return null}}function re(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Ke(e,o),a=te(s,o,n);a&&r.push(a)}return r}function Je(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function et(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,i,l,c,u]=o,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>255||d<0||d>255||m<0||m>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,i,l,c,u]=n,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(d<0||d>100||m<0||m>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function ne(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function tt(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function oe(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function Q(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function se(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function ee(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ae(e){let t=F(e),o=re(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.shape":{type:"enum",enumObj:w,optional:!0},"eyes.color":{type:"color",optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:E,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.border?.shape!==void 0&&t.border.shape!=="none"){let n=ne(t.border.shape,"border.shape",k);n&&o.push(n)}if(t.logo){let n=te(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new y(o);return t}function ie(e){let t=F(e),o=re(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new y(o);return t}function j(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new y(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new y(t);let r=e;switch(r.type){case"wifi":rt(e.data,t);break;case"vcard":nt(e.data,t);break;case"calendar":ot(e.data,t);break;case"email":st(e,t);break;case"sms":at(e,t);break;case"phone":it(e,t);break;case"url":lt(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new y(t)}function rt(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function nt(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!oe(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!Q(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!se(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function ot(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=ee(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=ee(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function st(e,t){let r=e;(!r.email||typeof r.email!="string"||!oe(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function at(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function it(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function lt(e,t){let r=e;(!r.url||typeof r.url!="string"||!se(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},M={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function le(e){if(!e){let{logo:o,...n}=p;return n}let t=ae(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{shape:t.eyes?.shape??p.eyes.shape,color:t.eyes?.color??p.eyes.color},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{shape:t.border?.shape??p.border.shape,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ce(e){if(!e)return{...M};let t=ie(e);return{margin:t.margin??M.margin,darkChar:t.darkChar??M.darkChar,lightChar:t.lightChar??M.lightChar}}function ue(e){return/^\d+$/.test(e)?1:[...e].every(t=>C.includes(t))?2:4}function ct(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function ut(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=C.indexOf(e[r])*45+C.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=C.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function dt(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function ft(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=D(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function mt(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function gt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function de(e,t,r){let o=ue(e),n,s;o===1?(n=ct(e),s=e.length):o===2?(n=ut(e),s=e.length):(n=dt(e),s=new TextEncoder().encode(e).length);let a=ft(n,o,s,t),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=mt(a);return gt(l,r)}function A(e,t){let r=ue(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=D(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=t[l-1])return l}let n=D(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function fe(e,t){if(t)try{if(A(e,x.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(A(e,x[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var S=new Array(256),_=new Array(256);function pt(){let e=1;for(let t=0;t<255;t++)S[t]=e,_[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)S[t]=S[t-255]}pt();function ge(e,t){return e===0||t===0?0:S[_[e]+_[t]]}function ht(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=ge(t[s],S[r]);t=n}return t}function me(e,t){let r=ht(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=ge(r[a],s)}return o.slice(e.length)}function pe(e,t,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=e.slice(c,c+a);o.push(f);let d=me(f,t);n.push(d),c+=a}for(let u=0;u<i;u++){let f=e.slice(c,c+l);o.push(f);let d=me(f,t);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function he(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function be(e){let t=R(e);return Array.from({length:t},()=>Array(t).fill(!1))}function ye(e){let t=R(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=O[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function U(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function bt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function $e(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function ve(e){U(e,0,0),U(e,0,e.length-7),U(e,e.length-7,0)}function xe(e,t){let r=e.length,o=O[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||bt(e,n,s)}function Ce(e,t){e[4*t+9][8]=!0}function Re(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let c=n<r.length?r[n]:!1;e[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function W(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function yt(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],c=1,u=1;for(let f=1;f<t;f++)e[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=e[a][f],c=1),e[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let c=0;c<t;c++)i=i<<1&2047|(e[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function we(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(c=>[...c]);W(i,t,a),o(i,r,a);let l=yt(i);l<s&&(s=l,n=a)}return n}function q(e,t,r){let o=e.length,n=T[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function Ee(e,t){if(t<7)return;let r=e.length,o=X[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function Se(e,t){return T[e]<<3|t}function Ie(e,t,r,o,n){let s=be(e),a=ye(e);ve(s),$e(s),xe(s,e),Ce(s,e),Re(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??we(s,a,t,q);return W(s,a,l),q(s,t,l),Ee(s,e),{matrix:s,mask:l,formatInfo:n?Se(t,l):void 0,unmaskedMatrix:i}}function z(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Oe(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function De(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function $t(e,t,r,o,n,s,a){let i=w[r]||w.square,l=i.renderSVG(e,t,7*a,o),c=i.renderSVG(e+a,t+a,5*a,s),u=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+c+u}function vt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${c}"${
|
|
22
|
-
${
|
|
3
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function We(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function B(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=B(t[r]));return t}function Z(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Ge(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return qe(e,t);case"enum":return He(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Ye(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"&&e!=="dotted"&&e!=="double"?{field:t,value:e,message:'must be "solid", "dashed", "dotted", or "double"'}:null;default:return null}}function J(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=We(e,o),i=Z(s,o,n);i&&r.push(i)}return r}function Ge(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function qe(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,a,l,c,u]=o,d=parseInt(a,10),f=parseInt(l,10),m=parseInt(c,10);if(d<0||d>255||f<0||f>255||m<0||m>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,a,l,c,u]=n,d=parseInt(a,10),f=parseInt(l,10),m=parseInt(c,10);if(d<0||d>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(f<0||f>100||m<0||m>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function He(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Ye(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function ee(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function N(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function te(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function K(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function re(e){let t=B(e),o=J(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.cornerRadius":{type:"number",min:0,max:.5,optional:!0},"eyes.color":{type:"color",optional:!0},"eyes.strokeWidth":{type:"number",min:.9,max:1.1,optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:C,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.cornerRadius":{type:"number",min:0,max:.5,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.logo){let n=Z(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new h(o);return t}function ne(e){let t=B(e),o=J(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new h(o);return t}function V(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new h(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new h(t);let r=e;switch(r.type){case"wifi":Xe(e.data,t);break;case"vcard":Ke(e.data,t);break;case"calendar":Ze(e.data,t);break;case"email":Je(e,t);break;case"sms":et(e,t);break;case"phone":tt(e,t);break;case"url":rt(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new h(t)}function Xe(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function Ke(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!ee(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!N(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!te(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Ze(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=K(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=K(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Je(e,t){let r=e;(!r.email||typeof r.email!="string"||!ee(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function et(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!N(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function tt(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!N(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function rt(e,t){let r=e;(!r.url||typeof r.url!="string"||!te(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{cornerRadius:.2,color:"#000000",strokeWidth:1},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{cornerRadius:.04,width:0,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},D={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function oe(e){if(!e){let{logo:o,...n}=p;return n}let t=re(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{cornerRadius:t.eyes?.cornerRadius??p.eyes.cornerRadius,color:t.eyes?.color??p.eyes.color,strokeWidth:t.eyes?.strokeWidth??p.eyes.strokeWidth},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{cornerRadius:t.border?.cornerRadius??p.border.cornerRadius,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function se(e){if(!e)return{...D};let t=ne(e);return{margin:t.margin??D.margin,darkChar:t.darkChar??D.darkChar,lightChar:t.lightChar??D.lightChar}}function ie(e){return/^\d+$/.test(e)?1:[...e].every(t=>R.includes(t))?2:4}function nt(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let i=s-1;i>=0;i--)t.push(n>>i&1)}return t}function ot(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=R.indexOf(e[r])*45+R.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=R.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function st(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function it(e,t,r,o){let n=[];for(let i=3;i>=0;i--)n.push(t>>i&1);let s=k(t,o);for(let i=s-1;i>=0;i--)n.push(r>>i&1);return[...n,...e]}function at(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function lt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function ae(e,t,r){let o=ie(e),n,s;o===1?(n=nt(e),s=e.length):o===2?(n=ot(e),s=e.length):(n=st(e),s=new TextEncoder().encode(e).length);let i=it(n,o,s,t),a=Math.min(4,r*8-i.length);for(let c=0;c<a;c++)i.push(0);for(;i.length%8!==0;)i.push(0);let l=at(i);return lt(l,r)}function M(e,t){let r=ie(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=k(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+c+u;if(Math.ceil(d/8)<=t[l-1])return l}let n=k(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,i=4+n+s,a=Math.ceil(i/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${a} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function le(e,t){if(t)try{if(M(e,v.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(M(e,v[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var E=new Array(256),j=new Array(256);function ct(){let e=1;for(let t=0;t<255;t++)E[t]=e,j[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)E[t]=E[t-255]}ct();function ue(e,t){return e===0||t===0?0:E[j[e]+j[t]]}function ut(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=ue(t[s],E[r]);t=n}return t}function ce(e,t){let r=ut(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let i=0;i<r.length;i++)o[n+i]^=ue(r[i],s)}return o.slice(e.length)}function de(e,t,r){let o=[],n=[],[s,i,a,l]=r,c=0;for(let u=0;u<s;u++){let d=e.slice(c,c+i);o.push(d);let f=ce(d,t);n.push(f),c+=i}for(let u=0;u<a;u++){let d=e.slice(c,c+l);o.push(d);let f=ce(d,t);n.push(f),c+=l}return{dataBlocks:o,ecBlocks:n}}function fe(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let i of e)s<i.length&&r.push(i[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let i of t)s<i.length&&r.push(i[s]);return r}function me(e){let t=w(e);return Array.from({length:t},()=>Array(t).fill(!1))}function ge(e){let t=w(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=S[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let a=-2;a<=2;a++)for(let l=-2;l<=2;l++)r[n+a][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function Q(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,i=r+n;if(s<0||s>=e.length||i<0||i>=e.length)continue;let a=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][i]=a||l}}function dt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,i=o===0&&n===0;e[t+o][r+n]=s||i}}function pe(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function he(e){Q(e,0,0),Q(e,0,e.length-7),Q(e,e.length-7,0)}function be(e,t){let r=e.length,o=S[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||dt(e,n,s)}function ye(e,t){e[4*t+9][8]=!0}function xe(e,t,r){let o=e.length,n=0,s=-1,i=o-1;for(let a=o-1;a>0;a-=2)for(a===6&&a--;;){for(let l=0;l<2;l++)if(!t[i][a-l]){let c=n<r.length?r[n]:!1;e[i][a-l]=c,n++}if(i+=s,i<0||o<=i){i-=s,s=-s;break}}}function F(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let i=!1;switch(r){case 0:i=(n+s)%2===0;break;case 1:i=n%2===0;break;case 2:i=s%3===0;break;case 3:i=(n+s)%3===0;break;case 4:i=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:i=n*s%2+n*s%3===0;break;case 6:i=(n*s%2+n*s%3)%2===0;break;case 7:i=((n+s)%2+n*s%3)%2===0;break}i&&(e[n][s]=!e[n][s])}}function ft(e){let t=e.length,r=0;for(let i=0;i<t;i++){let a=e[i][0],l=e[0][i],c=1,u=1;for(let d=1;d<t;d++)e[i][d]===a?c++:(c>=5&&(r+=3+(c-5)),a=e[i][d],c=1),e[d][i]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[d][i],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let i=0;i<t-1;i++)for(let a=0;a<t-1;a++){let l=e[i][a];e[i][a+1]===l&&e[i+1][a]===l&&e[i+1][a+1]===l&&(r+=3)}for(let i=0;i<t;i++){let a=0,l=0;for(let c=0;c<t;c++)a=a<<1&2047|(e[i][c]?1:0),c>=10&&(a===1488||a===93)&&(r+=40),l=l<<1&2047|(e[c][i]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let i=0;i<t;i++)for(let a=0;a<t;a++)e[i][a]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function ve(e,t,r,o){let n=0,s=1/0;for(let i=0;i<8;i++){let a=e.map(c=>[...c]);F(a,t,i),o(a,r,i);let l=ft(a);l<s&&(s=l,n=i)}return n}function z(e,t,r){let o=e.length,n=A[t]<<3|r,s=n<<10;for(let a=0;a<5;a++)s&1<<14-a&&(s^=1335<<4-a);let i=(n<<10|s)^21522;for(let a=0;a<15;a++){let l=(i>>14-a&1)===1;a<=5?e[8][a]=l:a===6?e[8][7]=l:a===7?e[8][8]=l:a===8?e[7][8]=l:e[5-(a-9)][8]=l,a<=6?e[o-1-a][8]=l:e[8][o-8+(a-7)]=l}}function Re(e,t){if(t<7)return;let r=e.length,o=H[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,i=Math.floor(n/3),a=r-11+n%3;e[i][a]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function we(e,t){return A[e]<<3|t}function Ce(e,t,r,o,n){let s=me(e),i=ge(e);he(s),pe(s),be(s,e),ye(s,e),xe(s,i,r);let a=n?s.map(c=>[...c]):void 0,l=o??ve(s,i,t,z);return F(s,i,l),z(s,t,l),Re(s,e),{matrix:s,mask:l,formatInfo:n?we(t,l):void 0,unmaskedMatrix:a}}function _(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Ee(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ie(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function mt(e,t,r,o,n,s,i,a){let c=7-2*o,u=(7-c)/2,d=O(e,t,7*a,n,r),f=O(e+u*a,t+u*a,c*a,i,r),m=O(e+2*a,t+2*a,3*a,s,r);return d+f+m}function gt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let a=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")a=atob(g);else if(typeof Buffer<"u")a=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{a=decodeURIComponent(g)}catch{return""}}}let l=a.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=a.match(/<svg([\s\S]*?)>/i),d="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(d=" "+m.join(" "))}let f=a.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
4
|
+
<svg width="${o}" height="${o}" viewBox="${c}"${d}>
|
|
5
|
+
${f}
|
|
23
6
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function
|
|
25
|
-
`;for(let
|
|
26
|
-
`}for(let
|
|
27
|
-
`;return s}var
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
7
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function pt(e,t,r,o,n){let s=e.matrixSize,i="",a=C[r]||C.classic;if(r==="classic"){i=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!_(l,c,s)){let u=c*t,d=l*t,f=n*t,m=(1-n)*t/2,g=u+m,x=d+m;i+=`M${g},${x}h${f}v${f}h${-f}z`}return i+='"/>',i}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!_(l,c,s)){let u=c*t,d=l*t,f=n*t,m=(1-n)*t/2,g=u+m,x=d+m,b={qrcode:e.modules,qrSize:s,row:l,col:c};i+=a.renderSVG(g,x,f,o,b)}return i}function $e(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:i,dots:a}=t,l=r/e.matrixSize,c=t.border.width,u=r+2*o+2*c,d=o+c,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}">`;f+=`<rect width="${u}" height="${u}" fill="${n}"/>`,c>0&&(f+=X(0,0,u,t.border.color,c,t.border.cornerRadius,t.border.style)),c>0&&(f+=`<rect x="${d}" y="${d}" width="${r}" height="${r}" fill="${n}"/>`),f+=`<g transform="translate(${d}, ${d})">`;let m=Ee(e.matrixSize),g="";for(let y of m)g+=mt(y.x*l,y.y*l,s.cornerRadius,s.strokeWidth,s.color,i.color,n,l);let x=pt(e,l,a.shape,a.color,a.scale);f+=g+x+"</g>";let b="";if(t.logo){let y=Ie(e.matrixSize,t.logo.scale)*l,I=u/2;b=gt(t.logo.src,I,I,y)}return f+=b+"</svg>",f}function Se(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",i=e.matrixSize+r*2;for(let a=0;a<r;a++)s+=o.repeat(i)+`
|
|
8
|
+
`;for(let a=0;a<e.matrixSize;a++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[a][l]?n:o;s+=o.repeat(r)+`
|
|
9
|
+
`}for(let a=0;a<r;a++)s+=o.repeat(i)+`
|
|
10
|
+
`;return s}var T=null,ke=!1;async function ht(){if(T)return T;if(ke)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");ke=!0;try{return T=(await import("@resvg/resvg-js")).Resvg,T}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Oe(e,t){let{output:r,size:o,margin:n,border:s}=t,i=s.width,a=o+2*n+2*i,l=await ht(),d=new l(e,{fitTo:{mode:"width",value:a}}).render().asPng(),f=Buffer.from(d);return r.type==="dataURL"?`data:image/png;base64,${f.toString("base64")}`:f}async function De(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Oe(e,t)}function U(e){if(typeof e=="string")return e;switch(e.type){case"url":return bt(e.url);case"vcard":return yt(e.data);case"wifi":return xt(e.data);case"calendar":return vt(e.data);case"email":return Rt(e.email,e.subject,e.body);case"sms":return wt(e.phone,e.message);case"phone":return Ct(e.phone)}}function bt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function yt(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:i}=e.address,a=["","",r||"",o||"",n||"",s||"",i||""];t.push(`ADR:${a.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
11
|
+
`)}function xt(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=Me(e.ssid),n=Me(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function Me(e){return e.replace(/([\\;,":])/g,"\\$1")}function vt(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
12
|
+
`)}function Rt(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function wt(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function Ct(e){return`tel:${e}`}function Et(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=Y[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function Te(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=le(e,t),o=v[r],n=M(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${v[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=ae(e,n,o[n-1]),i=G[r][n-1],a=q[r][n-1],{dataBlocks:l,ecBlocks:c}=de(s,i,a),u=fe(l,c),d=Et(u,n),{matrix:f,mask:m}=Ce(n,r,d);return{version:n,matrixSize:w(n),modules:f,mask:m,errorCorrectionLevel:r}}async function Ae(e,t){V(e);let r=U(e),o=oe(t),n=Te(r,!!o.logo),s=$e(n,o);return await De(s,o)}function Le(e,t){V(e);let r=U(e),o=se(t),n=Te(r,!1);return Se(n,o)}0&&(module.exports={BorderStyle,DotShape,QRValidationError,genQrImage,genQrText});
|
package/dist/node.mjs
CHANGED
|
@@ -1,29 +1,12 @@
|
|
|
1
|
-
var
|
|
2
|
-
C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
|
|
3
|
-
S${a+s},${i+n} ${a},${i+n}
|
|
4
|
-
S${a-n},${i+s} ${a-n},${i}
|
|
5
|
-
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`}}},E={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`}}},D={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:h}=Fe(m,s);return`<rect x="${e+d}" y="${t+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-h}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,c=t+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,c=t+i,u=i-s/2,f=r*Ne,d=Math.max(0,f-s/2),m=u-d,g=`M${l},${c-u}
|
|
6
|
-
H${l+m}
|
|
7
|
-
A${d},${d} 0 0 1 ${l+u},${c-m}
|
|
8
|
-
V${c+m}
|
|
9
|
-
A${d},${d} 0 0 1 ${l+m},${c+u}
|
|
10
|
-
H${l-m}
|
|
11
|
-
A${d},${d} 0 0 1 ${l-u},${c+m}
|
|
12
|
-
V${c-m}
|
|
13
|
-
A${d},${d} 0 0 1 ${l-m},${c-u}
|
|
14
|
-
Z`;if(a==="dashed"){let h=2*m,y=.5*Math.PI*d,b=4*h+4*y,{dashArray:v,offset:Pe}=X(b,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${v}" stroke-dashoffset="${Pe}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,c=r/2;if(a==="dashed"){let m=c-s/2,g=2*Math.PI*m,{dashArray:h,offset:y}=X(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${y}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
|
-
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
|
-
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
|
-
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
-
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}}};var $=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
1
|
+
var z={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},v={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},_={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},R="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Me={1:[10,12,14],2:[9,11,13],4:[8,16,16]},T={L:1,M:0,Q:3,H:2},$=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],U=[31892,34236,39577,42195],W=[0,7,7,7,7,7,0,0,0,0];function w(e){return e*4+17}function S(e,t){let r=t<10?0:t<27?1:2;return Me[e][r]}var G=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(G||{}),q=(n=>(n.SOLID="solid",n.DASHED="dashed",n.DOTTED="dotted",n.DOUBLE="double",n))(q||{});function Te(e,t){let n=t*3,s=t*2,i=n+s,a=Math.max(1,Math.round(e/i)),l=e/a,c=l*(3/5),u=l*(2/5),d=u/2;return{dashArray:`${c} ${u}`,offset:d}}function k(e,t,r,o,n){let s=r*n;return`<rect x="${e}" y="${t}" width="${r}" height="${r}" rx="${s}" fill="${o}"/>`}var C={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,i=r*.35;return`<circle cx="${n}" cy="${s}" r="${i}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,i=e+s,a=t+s;return`<rect x="${i}" y="${a}" width="${n}" height="${n}" fill="${o}"/>`}}};function H(e,t,r,o,n,s,i="solid"){let a=r*s,l=n/2,c=r-n;if(i==="dashed"){let{dashArray:u,offset:d}=Te(c,n);return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}" stroke-dasharray="${u}" stroke-dashoffset="${-d}"/>`}if(i==="dotted"){let u=n*.1,d=n*1.5;return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}" stroke-dasharray="${u} ${d}" stroke-linecap="round"/>`}if(i==="double"){let u=n*.3,d=n*.3,f=n*.4,m=u/2,g=r-u,x=g*s,h=u+f+d/2,b=r-2*h,I=b*s;return`<rect x="${e+m}" y="${t+m}" width="${g}" height="${g}" rx="${x}" fill="none" stroke="${o}" stroke-width="${u}"/><rect x="${e+h}" y="${t+h}" width="${b}" height="${b}" rx="${I}" fill="none" stroke="${o}" stroke-width="${d}"/>`}return`<rect x="${e+l}" y="${t+l}" width="${c}" height="${c}" rx="${a}" fill="none" stroke="${o}" stroke-width="${n}"/>`}var y=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
2
|
`);super(`QR Code validation failed:
|
|
20
|
-
${r}`),this.name="QRValidationError",this.errors=t}};function Qe(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function T(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=T(t[r]));return t}function J(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return je(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return _e(e,t);case"enum":return te(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Ue(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"?{field:t,value:e,message:'must be either "solid" or "dashed"'}:null;default:return null}}function ee(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Qe(e,o),a=J(s,o,n);a&&r.push(a)}return r}function je(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function _e(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,i,l,c,u]=o,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>255||d<0||d>255||m<0||m>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,i,l,c,u]=n,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(d<0||d>100||m<0||m>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function te(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Ue(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function re(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function P(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ne(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function K(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function oe(e){let t=T(e),o=ee(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.shape":{type:"enum",enumObj:w,optional:!0},"eyes.color":{type:"color",optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:E,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.border?.shape!==void 0&&t.border.shape!=="none"){let n=te(t.border.shape,"border.shape",D);n&&o.push(n)}if(t.logo){let n=J(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new $(o);return t}function se(e){let t=T(e),o=ee(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new $(o);return t}function V(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new $(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new $(t);let r=e;switch(r.type){case"wifi":We(e.data,t);break;case"vcard":qe(e.data,t);break;case"calendar":ze(e.data,t);break;case"email":Ge(e,t);break;case"sms":He(e,t);break;case"phone":Ye(e,t);break;case"url":Ze(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new $(t)}function We(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function qe(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!re(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!P(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ne(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function ze(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=K(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=K(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Ge(e,t){let r=e;(!r.email||typeof r.email!="string"||!re(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function He(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!P(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function Ye(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!P(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function Ze(e,t){let r=e;(!r.url||typeof r.url!="string"||!ne(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},k={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ae(e){if(!e){let{logo:o,...n}=p;return n}let t=oe(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{shape:t.eyes?.shape??p.eyes.shape,color:t.eyes?.color??p.eyes.color},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{shape:t.border?.shape??p.border.shape,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ie(e){if(!e)return{...k};let t=se(e);return{margin:t.margin??k.margin,darkChar:t.darkChar??k.darkChar,lightChar:t.lightChar??k.lightChar}}function le(e){return/^\d+$/.test(e)?1:[...e].every(t=>C.includes(t))?2:4}function Xe(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function Ke(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=C.indexOf(e[r])*45+C.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=C.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function Je(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function et(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=O(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function tt(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function rt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function ce(e,t,r){let o=le(e),n,s;o===1?(n=Xe(e),s=e.length):o===2?(n=Ke(e),s=e.length):(n=Je(e),s=new TextEncoder().encode(e).length);let a=et(n,o,s,t),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=tt(a);return rt(l,r)}function M(e,t){let r=le(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=O(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=t[l-1])return l}let n=O(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ue(e,t){if(t)try{if(M(e,x.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(M(e,x[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var S=new Array(256),N=new Array(256);function nt(){let e=1;for(let t=0;t<255;t++)S[t]=e,N[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)S[t]=S[t-255]}nt();function fe(e,t){return e===0||t===0?0:S[N[e]+N[t]]}function ot(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=fe(t[s],S[r]);t=n}return t}function de(e,t){let r=ot(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=fe(r[a],s)}return o.slice(e.length)}function me(e,t,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=e.slice(c,c+a);o.push(f);let d=de(f,t);n.push(d),c+=a}for(let u=0;u<i;u++){let f=e.slice(c,c+l);o.push(f);let d=de(f,t);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function ge(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function pe(e){let t=R(e);return Array.from({length:t},()=>Array(t).fill(!1))}function he(e){let t=R(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=I[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function B(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function st(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function be(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function ye(e){B(e,0,0),B(e,0,e.length-7),B(e,e.length-7,0)}function $e(e,t){let r=e.length,o=I[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||st(e,n,s)}function ve(e,t){e[4*t+9][8]=!0}function xe(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let c=n<r.length?r[n]:!1;e[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function F(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function at(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],c=1,u=1;for(let f=1;f<t;f++)e[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=e[a][f],c=1),e[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let c=0;c<t;c++)i=i<<1&2047|(e[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Ce(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(c=>[...c]);F(i,t,a),o(i,r,a);let l=at(i);l<s&&(s=l,n=a)}return n}function Q(e,t,r){let o=e.length,n=L[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function Re(e,t){if(t<7)return;let r=e.length,o=q[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function we(e,t){return L[e]<<3|t}function Ee(e,t,r,o,n){let s=pe(e),a=he(e);ye(s),be(s),$e(s,e),ve(s,e),xe(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??Ce(s,a,t,Q);return F(s,a,l),Q(s,t,l),Re(s,e),{matrix:s,mask:l,formatInfo:n?we(t,l):void 0,unmaskedMatrix:i}}function j(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Se(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ie(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function it(e,t,r,o,n,s,a){let i=w[r]||w.square,l=i.renderSVG(e,t,7*a,o),c=i.renderSVG(e+a,t+a,5*a,s),u=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+c+u}function lt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${c}"${
|
|
22
|
-
${
|
|
3
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function Ae(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function A(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=A(t[r]));return t}function X(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Le(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return Pe(e,t);case"enum":return Be(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Ne(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"&&e!=="dotted"&&e!=="double"?{field:t,value:e,message:'must be "solid", "dashed", "dotted", or "double"'}:null;default:return null}}function K(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Ae(e,o),i=X(s,o,n);i&&r.push(i)}return r}function Le(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function Pe(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,a,l,c,u]=o,d=parseInt(a,10),f=parseInt(l,10),m=parseInt(c,10);if(d<0||d>255||f<0||f>255||m<0||m>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,a,l,c,u]=n,d=parseInt(a,10),f=parseInt(l,10),m=parseInt(c,10);if(d<0||d>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(f<0||f>100||m<0||m>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function Be(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Ne(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function Z(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function L(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function J(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function Y(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ee(e){let t=A(e),o=K(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.cornerRadius":{type:"number",min:0,max:.5,optional:!0},"eyes.color":{type:"color",optional:!0},"eyes.strokeWidth":{type:"number",min:.9,max:1.1,optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:C,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.cornerRadius":{type:"number",min:0,max:.5,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.logo){let n=X(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new y(o);return t}function te(e){let t=A(e),o=K(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new y(o);return t}function P(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new y(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new y(t);let r=e;switch(r.type){case"wifi":Ve(e.data,t);break;case"vcard":je(e.data,t);break;case"calendar":Qe(e.data,t);break;case"email":Fe(e,t);break;case"sms":ze(e,t);break;case"phone":_e(e,t);break;case"url":Ue(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new y(t)}function Ve(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function je(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!Z(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!L(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!J(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Qe(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=Y(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=Y(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Fe(e,t){let r=e;(!r.email||typeof r.email!="string"||!Z(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function ze(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!L(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function _e(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!L(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function Ue(e,t){let r=e;(!r.url||typeof r.url!="string"||!J(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{cornerRadius:.2,color:"#000000",strokeWidth:1},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{cornerRadius:.04,width:0,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},O={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function re(e){if(!e){let{logo:o,...n}=p;return n}let t=ee(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{cornerRadius:t.eyes?.cornerRadius??p.eyes.cornerRadius,color:t.eyes?.color??p.eyes.color,strokeWidth:t.eyes?.strokeWidth??p.eyes.strokeWidth},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{cornerRadius:t.border?.cornerRadius??p.border.cornerRadius,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ne(e){if(!e)return{...O};let t=te(e);return{margin:t.margin??O.margin,darkChar:t.darkChar??O.darkChar,lightChar:t.lightChar??O.lightChar}}function oe(e){return/^\d+$/.test(e)?1:[...e].every(t=>R.includes(t))?2:4}function We(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let i=s-1;i>=0;i--)t.push(n>>i&1)}return t}function Ge(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=R.indexOf(e[r])*45+R.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=R.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function qe(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function He(e,t,r,o){let n=[];for(let i=3;i>=0;i--)n.push(t>>i&1);let s=S(t,o);for(let i=s-1;i>=0;i--)n.push(r>>i&1);return[...n,...e]}function Ye(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function Xe(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function se(e,t,r){let o=oe(e),n,s;o===1?(n=We(e),s=e.length):o===2?(n=Ge(e),s=e.length):(n=qe(e),s=new TextEncoder().encode(e).length);let i=He(n,o,s,t),a=Math.min(4,r*8-i.length);for(let c=0;c<a;c++)i.push(0);for(;i.length%8!==0;)i.push(0);let l=Ye(i);return Xe(l,r)}function D(e,t){let r=oe(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=S(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+c+u;if(Math.ceil(d/8)<=t[l-1])return l}let n=S(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,i=4+n+s,a=Math.ceil(i/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${a} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ie(e,t){if(t)try{if(D(e,v.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(D(e,v[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var E=new Array(256),B=new Array(256);function Ke(){let e=1;for(let t=0;t<255;t++)E[t]=e,B[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)E[t]=E[t-255]}Ke();function le(e,t){return e===0||t===0?0:E[B[e]+B[t]]}function Ze(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=le(t[s],E[r]);t=n}return t}function ae(e,t){let r=Ze(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let i=0;i<r.length;i++)o[n+i]^=le(r[i],s)}return o.slice(e.length)}function ce(e,t,r){let o=[],n=[],[s,i,a,l]=r,c=0;for(let u=0;u<s;u++){let d=e.slice(c,c+i);o.push(d);let f=ae(d,t);n.push(f),c+=i}for(let u=0;u<a;u++){let d=e.slice(c,c+l);o.push(d);let f=ae(d,t);n.push(f),c+=l}return{dataBlocks:o,ecBlocks:n}}function ue(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let i of e)s<i.length&&r.push(i[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let i of t)s<i.length&&r.push(i[s]);return r}function de(e){let t=w(e);return Array.from({length:t},()=>Array(t).fill(!1))}function fe(e){let t=w(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=$[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let a=-2;a<=2;a++)for(let l=-2;l<=2;l++)r[n+a][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function N(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,i=r+n;if(s<0||s>=e.length||i<0||i>=e.length)continue;let a=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][i]=a||l}}function Je(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,i=o===0&&n===0;e[t+o][r+n]=s||i}}function me(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function ge(e){N(e,0,0),N(e,0,e.length-7),N(e,e.length-7,0)}function pe(e,t){let r=e.length,o=$[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||Je(e,n,s)}function he(e,t){e[4*t+9][8]=!0}function be(e,t,r){let o=e.length,n=0,s=-1,i=o-1;for(let a=o-1;a>0;a-=2)for(a===6&&a--;;){for(let l=0;l<2;l++)if(!t[i][a-l]){let c=n<r.length?r[n]:!1;e[i][a-l]=c,n++}if(i+=s,i<0||o<=i){i-=s,s=-s;break}}}function V(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let i=!1;switch(r){case 0:i=(n+s)%2===0;break;case 1:i=n%2===0;break;case 2:i=s%3===0;break;case 3:i=(n+s)%3===0;break;case 4:i=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:i=n*s%2+n*s%3===0;break;case 6:i=(n*s%2+n*s%3)%2===0;break;case 7:i=((n+s)%2+n*s%3)%2===0;break}i&&(e[n][s]=!e[n][s])}}function et(e){let t=e.length,r=0;for(let i=0;i<t;i++){let a=e[i][0],l=e[0][i],c=1,u=1;for(let d=1;d<t;d++)e[i][d]===a?c++:(c>=5&&(r+=3+(c-5)),a=e[i][d],c=1),e[d][i]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[d][i],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let i=0;i<t-1;i++)for(let a=0;a<t-1;a++){let l=e[i][a];e[i][a+1]===l&&e[i+1][a]===l&&e[i+1][a+1]===l&&(r+=3)}for(let i=0;i<t;i++){let a=0,l=0;for(let c=0;c<t;c++)a=a<<1&2047|(e[i][c]?1:0),c>=10&&(a===1488||a===93)&&(r+=40),l=l<<1&2047|(e[c][i]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let i=0;i<t;i++)for(let a=0;a<t;a++)e[i][a]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function ye(e,t,r,o){let n=0,s=1/0;for(let i=0;i<8;i++){let a=e.map(c=>[...c]);V(a,t,i),o(a,r,i);let l=et(a);l<s&&(s=l,n=i)}return n}function j(e,t,r){let o=e.length,n=T[t]<<3|r,s=n<<10;for(let a=0;a<5;a++)s&1<<14-a&&(s^=1335<<4-a);let i=(n<<10|s)^21522;for(let a=0;a<15;a++){let l=(i>>14-a&1)===1;a<=5?e[8][a]=l:a===6?e[8][7]=l:a===7?e[8][8]=l:a===8?e[7][8]=l:e[5-(a-9)][8]=l,a<=6?e[o-1-a][8]=l:e[8][o-8+(a-7)]=l}}function xe(e,t){if(t<7)return;let r=e.length,o=U[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,i=Math.floor(n/3),a=r-11+n%3;e[i][a]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function ve(e,t){return T[e]<<3|t}function Re(e,t,r,o,n){let s=de(e),i=fe(e);ge(s),me(s),pe(s,e),he(s,e),be(s,i,r);let a=n?s.map(c=>[...c]):void 0,l=o??ye(s,i,t,j);return V(s,i,l),j(s,t,l),xe(s,e),{matrix:s,mask:l,formatInfo:n?ve(t,l):void 0,unmaskedMatrix:a}}function Q(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function we(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ce(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function tt(e,t,r,o,n,s,i,a){let c=7-2*o,u=(7-c)/2,d=k(e,t,7*a,n,r),f=k(e+u*a,t+u*a,c*a,i,r),m=k(e+2*a,t+2*a,3*a,s,r);return d+f+m}function rt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let a=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")a=atob(g);else if(typeof Buffer<"u")a=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{a=decodeURIComponent(g)}catch{return""}}}let l=a.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=a.match(/<svg([\s\S]*?)>/i),d="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(d=" "+m.join(" "))}let f=a.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
4
|
+
<svg width="${o}" height="${o}" viewBox="${c}"${d}>
|
|
5
|
+
${f}
|
|
23
6
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function
|
|
25
|
-
`;for(let
|
|
26
|
-
`}for(let
|
|
27
|
-
`;return s}var
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
7
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function nt(e,t,r,o,n){let s=e.matrixSize,i="",a=C[r]||C.classic;if(r==="classic"){i=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!Q(l,c,s)){let u=c*t,d=l*t,f=n*t,m=(1-n)*t/2,g=u+m,x=d+m;i+=`M${g},${x}h${f}v${f}h${-f}z`}return i+='"/>',i}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!Q(l,c,s)){let u=c*t,d=l*t,f=n*t,m=(1-n)*t/2,g=u+m,x=d+m,h={qrcode:e.modules,qrSize:s,row:l,col:c};i+=a.renderSVG(g,x,f,o,h)}return i}function Ee(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:i,dots:a}=t,l=r/e.matrixSize,c=t.border.width,u=r+2*o+2*c,d=o+c,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}">`;f+=`<rect width="${u}" height="${u}" fill="${n}"/>`,c>0&&(f+=H(0,0,u,t.border.color,c,t.border.cornerRadius,t.border.style)),c>0&&(f+=`<rect x="${d}" y="${d}" width="${r}" height="${r}" fill="${n}"/>`),f+=`<g transform="translate(${d}, ${d})">`;let m=we(e.matrixSize),g="";for(let b of m)g+=tt(b.x*l,b.y*l,s.cornerRadius,s.strokeWidth,s.color,i.color,n,l);let x=nt(e,l,a.shape,a.color,a.scale);f+=g+x+"</g>";let h="";if(t.logo){let b=Ce(e.matrixSize,t.logo.scale)*l,I=u/2;h=rt(t.logo.src,I,I,b)}return f+=h+"</svg>",f}function Ie(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",i=e.matrixSize+r*2;for(let a=0;a<r;a++)s+=o.repeat(i)+`
|
|
8
|
+
`;for(let a=0;a<e.matrixSize;a++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[a][l]?n:o;s+=o.repeat(r)+`
|
|
9
|
+
`}for(let a=0;a<r;a++)s+=o.repeat(i)+`
|
|
10
|
+
`;return s}var M=null,$e=!1;async function ot(){if(M)return M;if($e)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");$e=!0;try{return M=(await import("@resvg/resvg-js")).Resvg,M}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Se(e,t){let{output:r,size:o,margin:n,border:s}=t,i=s.width,a=o+2*n+2*i,l=await ot(),d=new l(e,{fitTo:{mode:"width",value:a}}).render().asPng(),f=Buffer.from(d);return r.type==="dataURL"?`data:image/png;base64,${f.toString("base64")}`:f}async function ke(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Se(e,t)}function F(e){if(typeof e=="string")return e;switch(e.type){case"url":return st(e.url);case"vcard":return it(e.data);case"wifi":return at(e.data);case"calendar":return lt(e.data);case"email":return ct(e.email,e.subject,e.body);case"sms":return ut(e.phone,e.message);case"phone":return dt(e.phone)}}function st(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function it(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:i}=e.address,a=["","",r||"",o||"",n||"",s||"",i||""];t.push(`ADR:${a.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
11
|
+
`)}function at(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=Oe(e.ssid),n=Oe(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function Oe(e){return e.replace(/([\\;,":])/g,"\\$1")}function lt(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
12
|
+
`)}function ct(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function ut(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function dt(e){return`tel:${e}`}function ft(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=W[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function De(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=ie(e,t),o=v[r],n=D(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${v[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=se(e,n,o[n-1]),i=z[r][n-1],a=_[r][n-1],{dataBlocks:l,ecBlocks:c}=ce(s,i,a),u=ue(l,c),d=ft(u,n),{matrix:f,mask:m}=Re(n,r,d);return{version:n,matrixSize:w(n),modules:f,mask:m,errorCorrectionLevel:r}}async function mt(e,t){P(e);let r=F(e),o=re(t),n=De(r,!!o.logo),s=Ee(n,o);return await ke(s,o)}function gt(e,t){P(e);let r=F(e),o=ne(t),n=De(r,!1);return Ie(n,o)}export{q as BorderStyle,G as DotShape,y as QRValidationError,mt as genQrImage,gt as genQrText};
|