@tapple.io/qr-code-generator 0.9.2 → 0.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/browser.mjs CHANGED
@@ -1,29 +1,29 @@
1
- var j={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]},M={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]},Y={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]]},S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ve={1:[10,12,14],2:[9,11,13],4:[8,16,16]},B={L:1,M:0,Q:3,H:2},P=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],X=[31892,34236,39577,42195],Z=[0,7,7,7,7,7,0,0,0,0];function R(e){return e*4+17}function L(e,r){let t=r<10?0:r<27?1:2;return ve[e][t]}var K=(t=>(t.SQUARE="square",t.SQUIRCLE="squircle",t))(K||{}),J=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(J||{}),ee=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(ee||{}),te=(t=>(t.SOLID="solid",t.DASHED="dashed",t))(te||{});function y(e,r){let t=r/2;return e<=-t?0:e>=t?255:Math.round((e+t)/r*255)}function F(e,r,t=.01){return y(r-e,t)}function ke(e,r,t,o){let n=Math.abs(e)-t+o,s=Math.abs(r)-t+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function Te(e,r){let n=r*3,s=r*2,a=n+s,i=Math.max(1,Math.round(e/a)),c=e/i,u=c*(3/5),l=c*(2/5),d=l/2;return{dashArray:`${u} ${l}`,offset:d}}function V(e,r){let t=r*3,o=r*2,n=t+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,c=a*.4,u=i/2;return{dashArray:`${i} ${c}`,offset:u}}function N(e,r,t,o,n){return n==="circle"?De(e,r,t,o):n==="squircle"?Be(e,r,t,o):Fe(e,r,t,o)}function De(e,r,t,o){let s=(Math.atan2(r,e)+Math.PI)/(2*Math.PI),a=t/2-o/2,i=2*Math.PI*a,c=o*3,u=o*2,l=Math.floor(i/(c+u)),d=l%2===0?l:l-1,f=Math.max(4,d);return s*f%1<.6}function Be(e,r,t,o){let s=t/2-o/2,a=t*z,i=Math.max(0,a-o/2),c=s-i,u=2*c,l=.5*Math.PI*i,d=4*u+4*l,f=Ne(e,r,c,i,u,l,d),{dashArray:m}=V(d,o),[h,g]=m.split(" ").map(Number),b=h+g;return(f+h/2)%b<h}function Ne(e,r,t,o,n,s,a){if(r<-t)if(e>t){let i=Math.atan2(r- -t,e-t)+Math.PI/2;return t+i*o}else if(e<-t){let i=Math.atan2(r- -t,e- -t)+Math.PI;return t+3*s+3*n+i*o}else return e>=0?e:a+e;else if(r>t)if(e>t){let i=Math.atan2(r-t,e-t);return t+s+n+i*o}else if(e<-t){let i=Math.atan2(r-t,e- -t)-Math.PI/2;return t+2*s+2*n+i*o}else return t+2*s+n+(t-e);else return e>t?t+s+(r- -t):e<-t?t+3*s+2*n+(t-r):e>=0?e:a+e}function Fe(e,r,t,o){let n=t/2,s=Math.abs(e),i=Math.abs(r)>=s?n+e:n+r,c=t-o,u=3,l=2,d=o*(u+l),f=Math.max(1,Math.round(c/d)),m=c/f,h=m*(u/(u+l)),b=(m-h)/2;return(i+b)%m<h}var z=.12,Ve={EYE_FRAME:.90909},E={square:{renderSVG(e,r,t,o){return`<rect x="${e}" y="${r}" width="${t}" height="${t}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(r));return y(a,s)}},squircle:{renderSVG(e,r,t,o){let n=t/2,s=n*Ve.EYE_FRAME,a=e+n,i=r+n;return`<path d="${`M${a},${i-n}
1
+ var j={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]},M={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]},Y={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]]},S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Le={1:[10,12,14],2:[9,11,13],4:[8,16,16]},B={L:1,M:0,Q:3,H:2},v=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],X=[31892,34236,39577,42195],Z=[0,7,7,7,7,7,0,0,0,0];function R(e){return e*4+17}function P(e,r){let t=r<10?0:r<27?1:2;return Le[e][t]}var K=(t=>(t.SQUARE="square",t.SQUIRCLE="squircle",t))(K||{}),J=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(J||{}),ee=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(ee||{}),te=(t=>(t.SOLID="solid",t.DASHED="dashed",t))(te||{});function y(e,r){let t=r/2;return e<=-t?0:e>=t?255:Math.round((e+t)/r*255)}function F(e,r,t=.01){return y(r-e,t)}function ke(e,r,t,o){let n=Math.abs(e)-t+o,s=Math.abs(r)-t+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function Te(e,r){let n=r*3,s=r*2,a=n+s,i=Math.max(1,Math.round(e/a)),c=e/i,u=c*(3/5),l=c*(2/5),m=l/2;return{dashArray:`${u} ${l}`,offset:m}}function V(e,r){let t=r*3,o=r*2,n=t+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,c=a*.4,u=i/2;return{dashArray:`${i} ${c}`,offset:u}}function N(e,r,t,o,n){return n==="circle"?De(e,r,t,o):n==="squircle"?Be(e,r,t,o):Fe(e,r,t,o)}function De(e,r,t,o){let s=(Math.atan2(r,e)+Math.PI)/(2*Math.PI),a=t/2-o/2,i=2*Math.PI*a,c=o*3,u=o*2,l=Math.floor(i/(c+u)),m=l%2===0?l:l-1,f=Math.max(4,m);return s*f%1<.6}function Be(e,r,t,o){let s=t/2-o/2,a=t*z,i=Math.max(0,a-o/2),c=s-i,u=2*c,l=.5*Math.PI*i,m=4*u+4*l,f=Ne(e,r,c,i,u,l,m),{dashArray:d}=V(m,o),[h,g]=d.split(" ").map(Number),b=h+g;return(f+h/2)%b<h}function Ne(e,r,t,o,n,s,a){if(r<-t)if(e>t){let i=Math.atan2(r- -t,e-t)+Math.PI/2;return t+i*o}else if(e<-t){let i=Math.atan2(r- -t,e- -t)+Math.PI;return t+3*s+3*n+i*o}else return e>=0?e:a+e;else if(r>t)if(e>t){let i=Math.atan2(r-t,e-t);return t+s+n+i*o}else if(e<-t){let i=Math.atan2(r-t,e- -t)-Math.PI/2;return t+2*s+2*n+i*o}else return t+2*s+n+(t-e);else return e>t?t+s+(r- -t):e<-t?t+3*s+2*n+(t-r):e>=0?e:a+e}function Fe(e,r,t,o){let n=t/2,s=Math.abs(e),i=Math.abs(r)>=s?n+e:n+r,c=t-o,u=3,l=2,m=o*(u+l),f=Math.max(1,Math.round(c/m)),d=c/f,h=d*(u/(u+l)),b=(d-h)/2;return(i+b)%d<h}var z=.12,Ve={EYE_FRAME:.90909},E={square:{renderSVG(e,r,t,o){return`<rect x="${e}" y="${r}" width="${t}" height="${t}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(r));return y(a,s)}},squircle:{renderSVG(e,r,t,o){let n=t/2,s=n*Ve.EYE_FRAME,a=e+n,i=r+n;return`<path d="${`M${a},${i-n}
2
2
  C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
3
3
  S${a+s},${i+n} ${a},${i+n}
4
4
  S${a-n},${i+s} ${a-n},${i}
5
- S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),c=Math.abs(r),u=i/n,l=c/n;if(i<.001&&c<.001)return 255;let d=Math.pow(u,a)+Math.pow(l,a),f=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(l,2*a-2)),m=(1-d)/f;return y(m,s)}}},I={classic:{renderSVG(){return""},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01;if(t>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:c,col:u}=o,l=o.qrSize||i.length,d=u>0&&i[c][u-1],f=u<l-1&&i[c][u+1],m=c>0&&i[c-1][u],h=c<l-1&&i[c+1][u],g=d?1/0:n+e,b=f?1/0:n-e,$=m?1/0:n+r,C=h?1/0:n-r,D=Math.min(Math.min(g,b),Math.min($,C));return y(D,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(r));return y(a,s)}},dots:{renderSVG(e,r,t,o){let n=e+t/2,s=r+t/2,a=t*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+r*r);return F(a,n,s)}},square:{renderSVG(e,r,t,o){let n=t*.7,s=(t-n)/2,a=e+s,i=r+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,r,t,o){let s=t*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(r));return y(i,a)}}},v={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let f=s/2,m=t-s,{dashArray:h,offset:g}=Te(m,s);return`<rect x="${e+f}" y="${r+f}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${-g}"/>`}let i=`M${e},${r}h${t}v${t}h${-t}z`,c=e+s,u=r+s,l=t-s*2,d=`M${c},${u}h${l}v${l}h${-l}z`;return`<path d="${i} ${d}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=i-Math.abs(e),l=i-Math.abs(r),d=c-Math.abs(e),f=c-Math.abs(r),m=Math.min(u,l),h=Math.min(d,f);if(m>=0&&h<=0){if(s==="dashed"&&!N(e,r,t,n,"square"))return 0;let g=y(m,a),b=255-y(h,a);return Math.min(g,b)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t/2,c=e+i,u=r+i,l=i-s/2,d=t*z,f=Math.max(0,d-s/2),m=l-f,h=`M${c},${u-l}
6
- H${c+m}
7
- A${f},${f} 0 0 1 ${c+l},${u-m}
8
- V${u+m}
9
- A${f},${f} 0 0 1 ${c+m},${u+l}
10
- H${c-m}
11
- A${f},${f} 0 0 1 ${c-l},${u+m}
12
- V${u-m}
13
- A${f},${f} 0 0 1 ${c-m},${u-l}
14
- Z`;if(a==="dashed"){let g=2*m,b=.5*Math.PI*f,$=4*g+4*b,{dashArray:C,offset:D}=V($,s);return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${C}" stroke-dashoffset="${D}"/>`}return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,c=t/2-n/2,u=t*z,l=Math.max(0,u-n/2),d=Math.abs(ke(e,r,c,l)),f=n/2-d;return f>-a?s==="dashed"&&!N(e,r,t,n,"squircle")?0:y(f,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+t/2,c=r+t/2,u=t/2;if(a==="dashed"){let m=u-s/2,h=2*Math.PI*m,{dashArray:g,offset:b}=V(h,s);return`<circle cx="${i}" cy="${c}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${b}"/>`}let l=u-s,d=`M${i},${c-u}
5
+ S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),c=Math.abs(r),u=i/n,l=c/n;if(i<.001&&c<.001)return 255;let m=Math.pow(u,a)+Math.pow(l,a),f=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(l,2*a-2)),d=(1-m)/f;return y(d,s)}}},I={classic:{renderSVG(){return""},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01;if(t>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:c,col:u}=o,l=o.qrSize||i.length,m=u>0&&i[c][u-1],f=u<l-1&&i[c][u+1],d=c>0&&i[c-1][u],h=c<l-1&&i[c+1][u],g=m?1/0:n+e,b=f?1/0:n-e,$=d?1/0:n+r,C=h?1/0:n-r,D=Math.min(Math.min(g,b),Math.min($,C));return y(D,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(r));return y(a,s)}},dots:{renderSVG(e,r,t,o){let n=e+t/2,s=r+t/2,a=t*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+r*r);return F(a,n,s)}},square:{renderSVG(e,r,t,o){let n=t*.7,s=(t-n)/2,a=e+s,i=r+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,r,t,o){let s=t*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(r));return y(i,a)}}},L={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let f=s/2,d=t-s,{dashArray:h,offset:g}=Te(d,s);return`<rect x="${e+f}" y="${r+f}" width="${d}" height="${d}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${-g}"/>`}let i=`M${e},${r}h${t}v${t}h${-t}z`,c=e+s,u=r+s,l=t-s*2,m=`M${c},${u}h${l}v${l}h${-l}z`;return`<path d="${i} ${m}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=i-Math.abs(e),l=i-Math.abs(r),m=c-Math.abs(e),f=c-Math.abs(r),d=Math.min(u,l),h=Math.min(m,f);if(d>=0&&h<=0){if(s==="dashed"&&!N(e,r,t,n,"square"))return 0;let g=y(d,a),b=255-y(h,a);return Math.min(g,b)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t/2,c=e+i,u=r+i,l=i-s/2,m=t*z,f=Math.max(0,m-s/2),d=l-f,h=`M${c},${u-l}
6
+ H${c+d}
7
+ A${f},${f} 0 0 1 ${c+l},${u-d}
8
+ V${u+d}
9
+ A${f},${f} 0 0 1 ${c+d},${u+l}
10
+ H${c-d}
11
+ A${f},${f} 0 0 1 ${c-l},${u+d}
12
+ V${u-d}
13
+ A${f},${f} 0 0 1 ${c-d},${u-l}
14
+ Z`;if(a==="dashed"){let g=2*d,b=.5*Math.PI*f,$=4*g+4*b,{dashArray:C,offset:D}=V($,s);return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${C}" stroke-dashoffset="${D}"/>`}return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,c=t/2-n/2,u=t*z,l=Math.max(0,u-n/2),m=Math.abs(ke(e,r,c,l)),f=n/2-m;return f>-a?s==="dashed"&&!N(e,r,t,n,"squircle")?0:y(f,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+t/2,c=r+t/2,u=t/2;if(a==="dashed"){let d=u-s/2,h=2*Math.PI*d,{dashArray:g,offset:b}=V(h,s);return`<circle cx="${i}" cy="${c}" r="${d}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${b}"/>`}let l=u-s,m=`M${i},${c-u}
15
15
  A${u},${u} 0 1,1 ${i},${c+u}
16
16
  A${u},${u} 0 1,1 ${i},${c-u}Z`,f=`M${i},${c-l}
17
17
  A${l},${l} 0 1,0 ${i},${c+l}
18
- A${l},${l} 0 1,0 ${i},${c-l}Z`;return`<path d="${d} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=Math.sqrt(e*e+r*r);if(u<=i&&u>=c){if(s==="dashed"&&!N(e,r,t,n,"circle"))return 0;let l=F(u,i,a),d=255-F(u,c,a);return Math.min(l,d)}return 0}}};var w=class extends Error{constructor(r){let t=r.map(o=>` - ${o.field}: ${o.message}`).join(`
18
+ A${l},${l} 0 1,0 ${i},${c-l}Z`;return`<path d="${m} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=Math.sqrt(e*e+r*r);if(u<=i&&u>=c){if(s==="dashed"&&!N(e,r,t,n,"circle"))return 0;let l=F(u,i,a),m=255-F(u,c,a);return Math.min(l,m)}return 0}}};var w=class extends Error{constructor(r){let t=r.map(o=>` - ${o.field}: ${o.message}`).join(`
19
19
  `);super(`QR Code validation failed:
20
- ${t}`),this.name="QRValidationError",this.errors=r}};function x(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function O(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function _(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function re(e){let r=[];if(e.size!==void 0){let t=x(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=O(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=_(e.eyes.shape,"eyes.shape",E);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=O(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=O(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=_(e.dots.shape,"dots.shape",I);t&&r.push(t)}if(e.dots?.color!==void 0){let t=O(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=x(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=_(e.border.shape,"border.shape",v);t&&r.push(t)}if(e.border?.width!==void 0){let t=x(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=O(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo&&((!e.logo.src||typeof e.logo.src!="string")&&r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"}),e.logo.scale!==void 0)){let t=x(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}if(r.length>0)throw new w(r)}function ne(e){let r=[];if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new w(r)}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 oe(e){if(!e){let{logo:t,...o}=p;return o}return re(e),{size:e.size??p.size,margin:e.margin??p.margin,backgroundColor:e.backgroundColor??p.backgroundColor,eyes:{shape:e.eyes?.shape??p.eyes.shape,color:e.eyes?.color??p.eyes.color},pupils:{color:e.pupils?.color??p.pupils.color},dots:{shape:e.dots?.shape??p.dots.shape,color:e.dots?.color??p.dots.color,scale:e.dots?.scale??p.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??p.logo.scale}:void 0,border:{shape:e.border?.shape??p.border.shape,width:e.border?.width??p.border.width,color:e.border?.color??p.border.color,style:e.border?.style??p.border.style},output:e.output??p.output}}function se(e){return e?(ne(e),{margin:e.margin??k.margin,darkChar:e.darkChar??k.darkChar,lightChar:e.lightChar??k.lightChar}):{...k}}function ae(e){return/^\d+$/.test(e)?1:[...e].every(r=>S.includes(r))?2:4}function ze(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+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--)r.push(n>>a&1)}return r}function _e(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=S.indexOf(e[t])*45+S.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=S.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function qe(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function Qe(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=L(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function Ue(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function Ge(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function ie(e,r,t){let o=ae(e),n,s;o===1?(n=ze(e),s=e.length):o===2?(n=_e(e),s=e.length):(n=qe(e),s=new TextEncoder().encode(e).length);let a=Qe(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=Ue(a);return Ge(c,t)}function T(e,r){let t=ae(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=L(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+u+l;if(Math.ceil(d/8)<=r[c-1])return c}let n=L(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===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: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ce(e,r){if(r)try{if(T(e,M.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 t=["H","Q","M","L"];for(let o of t)try{if(T(e,M[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 A=new Array(256),q=new Array(256);function We(){let e=1;for(let r=0;r<255;r++)A[r]=e,q[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)A[r]=A[r-255]}We();function le(e,r){return e===0||r===0?0:A[q[e]+q[r]]}function He(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=le(r[s],A[t]);r=n}return r}function ue(e,r){let t=He(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=le(t[a],s)}return o.slice(e.length)}function fe(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let d=e.slice(u,u+a);o.push(d);let f=ue(d,r);n.push(f),u+=a}for(let l=0;l<i;l++){let d=e.slice(u,u+c);o.push(d);let f=ue(d,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function de(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function me(e){let r=R(e);return Array.from({length:r},()=>Array(r).fill(!1))}function he(e){let r=R(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function Q(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+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),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function je(e,r,t){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[r+o][t+n]=s||a}}function ge(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function be(e){Q(e,0,0),Q(e,0,e.length-7),Q(e,e.length-7,0)}function pe(e,r){let t=e.length,o=P[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||je(e,n,s)}function $e(e,r){e[4*r+9][8]=!0}function Ce(e,r,t){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 c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function U(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){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 Ye(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let d=1;d<r;d++)e[a][d]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][d],u=1),e[d][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[d][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function ye(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);U(i,r,a),o(i,t,a);let c=Ye(i);c<s&&(s=c,n=a)}return n}function G(e,r,t){let o=e.length,n=B[r]<<3|t,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 c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Me(e,r){if(r<7)return;let t=e.length,o=X[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function xe(e,r){return B[e]<<3|r}function Se(e,r,t,o,n){let s=me(e),a=he(e);be(s),ge(s),pe(s,e),$e(s,e),Ce(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??ye(s,a,r,G);return U(s,a,c),G(s,r,c),Me(s,e),{matrix:s,mask:c,formatInfo:n?xe(r,c):void 0,unmaskedMatrix:i}}function W(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Re(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ee(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function Xe(e,r,t,o,n,s,a){let i=E[t]||E.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function Ze(e,r,t,o){let n=o/2;if(e.includes("data:image/svg")||e.trim().startsWith("<svg")){let s=e;if(e.includes("data:image/svg")){let u=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(u)try{s=decodeURIComponent(u[1])}catch{return""}}let a=s.match(/viewBox=["']([^"']+)["']/),i=a?a[1]:"0 0 100 100",c=s.replace(/<\?xml[^>]*>|<svg[^>]*>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
21
- <svg width="${o}" height="${o}" viewBox="${i}">
22
- ${c}
20
+ ${t}`),this.name="QRValidationError",this.errors=r}};function x(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function O(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function _(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function re(e){let r=[];if(e.size!==void 0){let t=x(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=O(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=_(e.eyes.shape,"eyes.shape",E);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=O(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=O(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=_(e.dots.shape,"dots.shape",I);t&&r.push(t)}if(e.dots?.color!==void 0){let t=O(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=x(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=_(e.border.shape,"border.shape",L);t&&r.push(t)}if(e.border?.width!==void 0){let t=x(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=O(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo&&((!e.logo.src||typeof e.logo.src!="string")&&r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"}),e.logo.scale!==void 0)){let t=x(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}if(r.length>0)throw new w(r)}function ne(e){let r=[];if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new w(r)}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 oe(e){if(!e){let{logo:t,...o}=p;return o}return re(e),{size:e.size??p.size,margin:e.margin??p.margin,backgroundColor:e.backgroundColor??p.backgroundColor,eyes:{shape:e.eyes?.shape??p.eyes.shape,color:e.eyes?.color??p.eyes.color},pupils:{color:e.pupils?.color??p.pupils.color},dots:{shape:e.dots?.shape??p.dots.shape,color:e.dots?.color??p.dots.color,scale:e.dots?.scale??p.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??p.logo.scale}:void 0,border:{shape:e.border?.shape??p.border.shape,width:e.border?.width??p.border.width,color:e.border?.color??p.border.color,style:e.border?.style??p.border.style},output:e.output??p.output}}function se(e){return e?(ne(e),{margin:e.margin??k.margin,darkChar:e.darkChar??k.darkChar,lightChar:e.lightChar??k.lightChar}):{...k}}function ae(e){return/^\d+$/.test(e)?1:[...e].every(r=>S.includes(r))?2:4}function ze(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+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--)r.push(n>>a&1)}return r}function _e(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=S.indexOf(e[t])*45+S.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=S.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function qe(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function Qe(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=P(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function Ue(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function Ge(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function ie(e,r,t){let o=ae(e),n,s;o===1?(n=ze(e),s=e.length):o===2?(n=_e(e),s=e.length):(n=qe(e),s=new TextEncoder().encode(e).length);let a=Qe(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=Ue(a);return Ge(c,t)}function T(e,r){let t=ae(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=P(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,m=4+u+l;if(Math.ceil(m/8)<=r[c-1])return c}let n=P(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===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: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ce(e,r){if(r)try{if(T(e,M.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 t=["H","Q","M","L"];for(let o of t)try{if(T(e,M[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 A=new Array(256),q=new Array(256);function We(){let e=1;for(let r=0;r<255;r++)A[r]=e,q[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)A[r]=A[r-255]}We();function le(e,r){return e===0||r===0?0:A[q[e]+q[r]]}function He(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=le(r[s],A[t]);r=n}return r}function ue(e,r){let t=He(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=le(t[a],s)}return o.slice(e.length)}function fe(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let m=e.slice(u,u+a);o.push(m);let f=ue(m,r);n.push(f),u+=a}for(let l=0;l<i;l++){let m=e.slice(u,u+c);o.push(m);let f=ue(m,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function me(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function de(e){let r=R(e);return Array.from({length:r},()=>Array(r).fill(!1))}function he(e){let r=R(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=v[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function Q(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+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),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function je(e,r,t){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[r+o][t+n]=s||a}}function ge(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function be(e){Q(e,0,0),Q(e,0,e.length-7),Q(e,e.length-7,0)}function pe(e,r){let t=e.length,o=v[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||je(e,n,s)}function $e(e,r){e[4*r+9][8]=!0}function Ce(e,r,t){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 c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function U(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){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 Ye(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let m=1;m<r;m++)e[a][m]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][m],u=1),e[m][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[m][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function ye(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);U(i,r,a),o(i,t,a);let c=Ye(i);c<s&&(s=c,n=a)}return n}function G(e,r,t){let o=e.length,n=B[r]<<3|t,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 c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Me(e,r){if(r<7)return;let t=e.length,o=X[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function xe(e,r){return B[e]<<3|r}function Se(e,r,t,o,n){let s=de(e),a=he(e);be(s),ge(s),pe(s,e),$e(s,e),Ce(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??ye(s,a,r,G);return U(s,a,c),G(s,r,c),Me(s,e),{matrix:s,mask:c,formatInfo:n?xe(r,c):void 0,unmaskedMatrix:i}}function W(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Re(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ee(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function Xe(e,r,t,o,n,s,a){let i=E[t]||E.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function Ze(e,r,t,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 d=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(d)try{i=decodeURIComponent(d[1])}catch{return""}}let c=i.match(/viewBox=["']([^"']+)["']/),u=c?c[1]:"0 0 100 100",l=i.match(/<svg([^>]*)>/i),m="";if(l){let d=l[1].match(/xmlns[^=]*=["'][^"']*["']/gi);d&&(m=" "+d.join(" "))}let f=i.replace(/<\?xml[^>]*>|<svg[^>]*>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
21
+ <svg width="${o}" height="${o}" viewBox="${u}"${m}>
22
+ ${f}
23
23
  </svg>
24
- </g>`}else return`<image x="${r-n}" y="${t-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function Ke(e,r,t,o,n){let s=e.matrixSize,a="",i=I[t]||I.classic;if(t==="classic"){a=`<path fill="${o}" d="`;for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!W(c,u,s)){let l=u*r,d=c*r,f=n*r,m=(1-n)*r/2,h=l+m,g=d+m;a+=`M${h},${g}h${f}v${f}h${-f}z`}return a+='"/>',a}for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!W(c,u,s)){let l=u*r,d=c*r,f=n*r,m=(1-n)*r/2,h=l+m,g=d+m,b={qrcode:e.modules,qrSize:s,row:c,col:u};a+=i.renderSVG(h,g,f,o,b)}return a}function Ie(e,r){let{size:t,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=r,c=t/e.matrixSize,u=r.border.shape==="none"?0:r.border.width,l=t+2*o+2*u,d=o+u,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" width="${l}" height="${l}">`;if(f+=`<rect width="${l}" height="${l}" fill="${n}"/>`,r.border.shape!=="none"&&u>0){let $=v[r.border.shape];if($){let C={borderWidth:u,borderStyle:r.border.style};f+=$.renderSVG(0,0,l,r.border.color,C)}}r.border.shape!=="none"&&u>0&&(f+=`<rect x="${d}" y="${d}" width="${t}" height="${t}" fill="${n}"/>`),f+=`<g transform="translate(${d}, ${d})">`;let m=Re(e.matrixSize),h="";for(let $ of m)h+=Xe($.x*c,$.y*c,s.shape,s.color,a.color,n,c);let g=Ke(e,c,i.shape,i.color,i.scale);f+=h+g+"</g>";let b="";if(r.logo){let $=Ee(e.matrixSize,r.logo.scale)*c,C=l/2;b=Ze(r.logo.src,C,C,$)}return f+=b+"</svg>",f}function Oe(e,r){let{margin:t,lightChar:o,darkChar:n}=r,s="",a=e.matrixSize+t*2;for(let i=0;i<t;i++)s+=o.repeat(a)+`
24
+ </g>`}else return`<image x="${r-n}" y="${t-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function Ke(e,r,t,o,n){let s=e.matrixSize,a="",i=I[t]||I.classic;if(t==="classic"){a=`<path fill="${o}" d="`;for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!W(c,u,s)){let l=u*r,m=c*r,f=n*r,d=(1-n)*r/2,h=l+d,g=m+d;a+=`M${h},${g}h${f}v${f}h${-f}z`}return a+='"/>',a}for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!W(c,u,s)){let l=u*r,m=c*r,f=n*r,d=(1-n)*r/2,h=l+d,g=m+d,b={qrcode:e.modules,qrSize:s,row:c,col:u};a+=i.renderSVG(h,g,f,o,b)}return a}function Ie(e,r){let{size:t,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=r,c=t/e.matrixSize,u=r.border.shape==="none"?0:r.border.width,l=t+2*o+2*u,m=o+u,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" width="${l}" height="${l}">`;if(f+=`<rect width="${l}" height="${l}" fill="${n}"/>`,r.border.shape!=="none"&&u>0){let $=L[r.border.shape];if($){let C={borderWidth:u,borderStyle:r.border.style};f+=$.renderSVG(0,0,l,r.border.color,C)}}r.border.shape!=="none"&&u>0&&(f+=`<rect x="${m}" y="${m}" width="${t}" height="${t}" fill="${n}"/>`),f+=`<g transform="translate(${m}, ${m})">`;let d=Re(e.matrixSize),h="";for(let $ of d)h+=Xe($.x*c,$.y*c,s.shape,s.color,a.color,n,c);let g=Ke(e,c,i.shape,i.color,i.scale);f+=h+g+"</g>";let b="";if(r.logo){let $=Ee(e.matrixSize,r.logo.scale)*c,C=l/2;b=Ze(r.logo.src,C,C,$)}return f+=b+"</svg>",f}function Oe(e,r){let{margin:t,lightChar:o,darkChar:n}=r,s="",a=e.matrixSize+t*2;for(let i=0;i<t;i++)s+=o.repeat(a)+`
25
25
  `;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(t);for(let c=0;c<e.matrixSize;c++)s+=e.modules[i][c]?n:o;s+=o.repeat(t)+`
26
26
  `}for(let i=0;i<t;i++)s+=o.repeat(a)+`
27
- `;return s}async function we(e,r){let{output:t,size:o,margin:n,border:s}=r,a=s.shape==="none"?0:s.width,i=o+2*n+2*a;return new Promise((c,u)=>{let l=document.createElement("canvas");l.width=i,l.height=i;let d=l.getContext("2d");if(!d){u(new Error("Failed to get canvas context"));return}let f=new Image,m=null;try{let h=new Blob([e],{type:"image/svg+xml;charset=utf-8"});m=URL.createObjectURL(h)}catch{u(new Error("Failed to create SVG blob for rasterization"));return}f.onload=()=>{if(m&&URL.revokeObjectURL(m),d.drawImage(f,0,0,i,i),t.type==="dataURL"){let h=l.toDataURL("image/png");c(h)}else l.toBlob(h=>{if(!h){u(new Error("Failed to convert PNG to blob"));return}h.arrayBuffer().then(g=>{c(new Uint8Array(g))})},"image/png")},f.onerror=()=>{m&&URL.revokeObjectURL(m),u(new Error("Failed to load SVG for rasterization"))},f.src=m})}async function Ae(e,r){let{format:t,type:o}=r.output;return t==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await we(e,r)}function H(e){if(typeof e=="string")return e;switch(e.type){case"url":return Je(e.url);case"vcard":return et(e.data);case"wifi":return tt(e.data);case"calendar":return rt(e.data);case"email":return nt(e.email,e.subject,e.body);case"sms":return ot(e.phone,e.message);case"phone":return st(e.phone)}}function Je(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function et(e){let r=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&r.push(`TEL:${e.phone}`),e.email&&r.push(`EMAIL:${e.email}`),e.organization&&r.push(`ORG:${e.organization}`),e.url&&r.push(`URL:${e.url}`),e.title&&r.push(`TITLE:${e.title}`),e.note&&r.push(`NOTE:${e.note}`),e.address){let{street:t,city:o,state:n,zip:s,country:a}=e.address,i=["","",t||"",o||"",n||"",s||"",a||""];r.push(`ADR:${i.join(";")}`)}return r.push("END:VCARD"),r.join(`
28
- `)}function tt(e){let r=e.encryption||"WPA",t=e.hidden?"H:true;":"",o=Pe(e.ssid),n=Pe(e.password);return`WIFI:T:${r};S:${o};P:${n};${t};`}function Pe(e){return e.replace(/([\\;,":])/g,"\\$1")}function rt(e){let r=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",t=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${r(e.startDate)}`,`DTEND:${r(e.endDate)}`];return e.location&&t.push(`LOCATION:${e.location}`),e.description&&t.push(`DESCRIPTION:${e.description}`),t.push("END:VEVENT","END:VCALENDAR"),t.join(`
29
- `)}function nt(e,r,t){let o=`mailto:${e}`,n=[];return r&&n.push(`subject=${encodeURIComponent(r)}`),t&&n.push(`body=${encodeURIComponent(t)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function ot(e,r){return r?`sms:${e}:${r}`:`sms:${e}`}function st(e){return`tel:${e}`}function at(e,r){let t=[];for(let n of e)for(let s=7;s>=0;s--)t.push((n>>s&1)===1);let o=Z[r-1];for(let n=0;n<o;n++)t.push(!1);return t}function Le(e,r){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let t=ce(e,r),o=M[t],n=T(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 ${t}: ~${M[t][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=ie(e,n,o[n-1]),a=j[t][n-1],i=Y[t][n-1],{dataBlocks:c,ecBlocks:u}=fe(s,a,i),l=de(c,u),d=at(l,n),{matrix:f,mask:m}=Se(n,t,d);return{version:n,matrixSize:R(n),modules:f,mask:m,errorCorrectionLevel:t}}async function it(e,r){let t=H(e),o=oe(r),n=Le(t,!!o.logo),s=Ie(n,o);return await Ae(s,o)}function ct(e,r){let t=H(e),o=se(r),n=Le(t,!1);return Oe(n,o)}export{ee as BorderShape,te as BorderStyle,J as DotShape,K as EyeFrameShape,w as QRValidationError,it as genQrImage,ct as genQrText};
27
+ `;return s}async function we(e,r){let{output:t,size:o,margin:n,border:s}=r,a=s.shape==="none"?0:s.width,i=o+2*n+2*a;return new Promise((c,u)=>{let l=document.createElement("canvas");l.width=i,l.height=i;let m=l.getContext("2d");if(!m){u(new Error("Failed to get canvas context"));return}let f=new Image,d=null;try{let h=new Blob([e],{type:"image/svg+xml;charset=utf-8"});d=URL.createObjectURL(h)}catch{u(new Error("Failed to create SVG blob for rasterization"));return}f.onload=()=>{if(d&&URL.revokeObjectURL(d),m.drawImage(f,0,0,i,i),t.type==="dataURL"){let h=l.toDataURL("image/png");c(h)}else l.toBlob(h=>{if(!h){u(new Error("Failed to convert PNG to blob"));return}h.arrayBuffer().then(g=>{c(new Uint8Array(g))})},"image/png")},f.onerror=()=>{d&&URL.revokeObjectURL(d),u(new Error("Failed to load SVG for rasterization"))},f.src=d})}async function Ae(e,r){let{format:t,type:o}=r.output;return t==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await we(e,r)}function H(e){if(typeof e=="string")return e;switch(e.type){case"url":return Je(e.url);case"vcard":return et(e.data);case"wifi":return tt(e.data);case"calendar":return rt(e.data);case"email":return nt(e.email,e.subject,e.body);case"sms":return ot(e.phone,e.message);case"phone":return st(e.phone)}}function Je(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function et(e){let r=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&r.push(`TEL:${e.phone}`),e.email&&r.push(`EMAIL:${e.email}`),e.organization&&r.push(`ORG:${e.organization}`),e.url&&r.push(`URL:${e.url}`),e.title&&r.push(`TITLE:${e.title}`),e.note&&r.push(`NOTE:${e.note}`),e.address){let{street:t,city:o,state:n,zip:s,country:a}=e.address,i=["","",t||"",o||"",n||"",s||"",a||""];r.push(`ADR:${i.join(";")}`)}return r.push("END:VCARD"),r.join(`
28
+ `)}function tt(e){let r=e.encryption||"WPA",t=e.hidden?"H:true;":"",o=ve(e.ssid),n=ve(e.password);return`WIFI:T:${r};S:${o};P:${n};${t};`}function ve(e){return e.replace(/([\\;,":])/g,"\\$1")}function rt(e){let r=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",t=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${r(e.startDate)}`,`DTEND:${r(e.endDate)}`];return e.location&&t.push(`LOCATION:${e.location}`),e.description&&t.push(`DESCRIPTION:${e.description}`),t.push("END:VEVENT","END:VCALENDAR"),t.join(`
29
+ `)}function nt(e,r,t){let o=`mailto:${e}`,n=[];return r&&n.push(`subject=${encodeURIComponent(r)}`),t&&n.push(`body=${encodeURIComponent(t)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function ot(e,r){return r?`sms:${e}:${r}`:`sms:${e}`}function st(e){return`tel:${e}`}function at(e,r){let t=[];for(let n of e)for(let s=7;s>=0;s--)t.push((n>>s&1)===1);let o=Z[r-1];for(let n=0;n<o;n++)t.push(!1);return t}function Pe(e,r){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let t=ce(e,r),o=M[t],n=T(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 ${t}: ~${M[t][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=ie(e,n,o[n-1]),a=j[t][n-1],i=Y[t][n-1],{dataBlocks:c,ecBlocks:u}=fe(s,a,i),l=me(c,u),m=at(l,n),{matrix:f,mask:d}=Se(n,t,m);return{version:n,matrixSize:R(n),modules:f,mask:d,errorCorrectionLevel:t}}async function it(e,r){let t=H(e),o=oe(r),n=Pe(t,!!o.logo),s=Ie(n,o);return await Ae(s,o)}function ct(e,r){let t=H(e),o=se(r),n=Pe(t,!1);return Oe(n,o)}export{ee as BorderShape,te as BorderStyle,J as DotShape,K as EyeFrameShape,w as QRValidationError,it as genQrImage,ct as genQrText};
package/dist/node.cjs CHANGED
@@ -1,29 +1,29 @@
1
- "use strict";var Ve=Object.create;var P=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty;var Qe=(e,r)=>{for(var t in r)P(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Fe(r))!_e.call(e,n)&&n!==t&&P(e,n,{get:()=>r[n],enumerable:!(o=ze(r,n))||o.enumerable});return e};var Ge=(e,r,t)=>(t=e!=null?Ve(qe(e)):{},ee(r||!e||!e.__esModule?P(t,"default",{value:e,enumerable:!0}):t,e)),Ue=e=>ee(P({},"__esModule",{value:!0}),e);var xt={};Qe(xt,{BorderShape:()=>q,BorderStyle:()=>_,DotShape:()=>F,EyeFrameShape:()=>z,QRValidationError:()=>S,genQrImage:()=>Be,genQrText:()=>Ne});module.exports=Ue(xt);var te={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]},y={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]},re={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 $%*+-./:",We={1:[10,12,14],2:[9,11,13],4:[8,16,16]},V={L:1,M:0,Q:3,H:2},A=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],ne=[31892,34236,39577,42195],oe=[0,7,7,7,7,7,0,0,0,0];function I(e){return e*4+17}function L(e,r){let t=r<10?0:r<27?1:2;return We[e][t]}var z=(t=>(t.SQUARE="square",t.SQUIRCLE="squircle",t))(z||{}),F=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(F||{}),q=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(q||{}),_=(t=>(t.SOLID="solid",t.DASHED="dashed",t))(_||{});function M(e,r){let t=r/2;return e<=-t?0:e>=t?255:Math.round((e+t)/r*255)}function G(e,r,t=.01){return M(r-e,t)}function je(e,r,t,o){let n=Math.abs(e)-t+o,s=Math.abs(r)-t+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function He(e,r){let n=r*3,s=r*2,a=n+s,i=Math.max(1,Math.round(e/a)),c=e/i,u=c*(3/5),l=c*(2/5),d=l/2;return{dashArray:`${u} ${l}`,offset:d}}function U(e,r){let t=r*3,o=r*2,n=t+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,c=a*.4,u=i/2;return{dashArray:`${i} ${c}`,offset:u}}function Q(e,r,t,o,n){return n==="circle"?Ye(e,r,t,o):n==="squircle"?Xe(e,r,t,o):Ke(e,r,t,o)}function Ye(e,r,t,o){let s=(Math.atan2(r,e)+Math.PI)/(2*Math.PI),a=t/2-o/2,i=2*Math.PI*a,c=o*3,u=o*2,l=Math.floor(i/(c+u)),d=l%2===0?l:l-1,f=Math.max(4,d);return s*f%1<.6}function Xe(e,r,t,o){let s=t/2-o/2,a=t*W,i=Math.max(0,a-o/2),c=s-i,u=2*c,l=.5*Math.PI*i,d=4*u+4*l,f=Ze(e,r,c,i,u,l,d),{dashArray:m}=U(d,o),[h,g]=m.split(" ").map(Number),b=h+g;return(f+h/2)%b<h}function Ze(e,r,t,o,n,s,a){if(r<-t)if(e>t){let i=Math.atan2(r- -t,e-t)+Math.PI/2;return t+i*o}else if(e<-t){let i=Math.atan2(r- -t,e- -t)+Math.PI;return t+3*s+3*n+i*o}else return e>=0?e:a+e;else if(r>t)if(e>t){let i=Math.atan2(r-t,e-t);return t+s+n+i*o}else if(e<-t){let i=Math.atan2(r-t,e- -t)-Math.PI/2;return t+2*s+2*n+i*o}else return t+2*s+n+(t-e);else return e>t?t+s+(r- -t):e<-t?t+3*s+2*n+(t-r):e>=0?e:a+e}function Ke(e,r,t,o){let n=t/2,s=Math.abs(e),i=Math.abs(r)>=s?n+e:n+r,c=t-o,u=3,l=2,d=o*(u+l),f=Math.max(1,Math.round(c/d)),m=c/f,h=m*(u/(u+l)),b=(m-h)/2;return(i+b)%m<h}var W=.12,Je={EYE_FRAME:.90909},E={square:{renderSVG(e,r,t,o){return`<rect x="${e}" y="${r}" width="${t}" height="${t}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},squircle:{renderSVG(e,r,t,o){let n=t/2,s=n*Je.EYE_FRAME,a=e+n,i=r+n;return`<path d="${`M${a},${i-n}
1
+ "use strict";var Ve=Object.create;var P=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Fe=Object.getOwnPropertyNames;var qe=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty;var Qe=(e,r)=>{for(var t in r)P(e,t,{get:r[t],enumerable:!0})},ee=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of Fe(r))!_e.call(e,n)&&n!==t&&P(e,n,{get:()=>r[n],enumerable:!(o=ze(r,n))||o.enumerable});return e};var Ge=(e,r,t)=>(t=e!=null?Ve(qe(e)):{},ee(r||!e||!e.__esModule?P(t,"default",{value:e,enumerable:!0}):t,e)),Ue=e=>ee(P({},"__esModule",{value:!0}),e);var xt={};Qe(xt,{BorderShape:()=>q,BorderStyle:()=>_,DotShape:()=>F,EyeFrameShape:()=>z,QRValidationError:()=>S,genQrImage:()=>Be,genQrText:()=>Ne});module.exports=Ue(xt);var te={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]},y={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]},re={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 $%*+-./:",We={1:[10,12,14],2:[9,11,13],4:[8,16,16]},V={L:1,M:0,Q:3,H:2},A=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],ne=[31892,34236,39577,42195],oe=[0,7,7,7,7,7,0,0,0,0];function I(e){return e*4+17}function L(e,r){let t=r<10?0:r<27?1:2;return We[e][t]}var z=(t=>(t.SQUARE="square",t.SQUIRCLE="squircle",t))(z||{}),F=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(F||{}),q=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(q||{}),_=(t=>(t.SOLID="solid",t.DASHED="dashed",t))(_||{});function M(e,r){let t=r/2;return e<=-t?0:e>=t?255:Math.round((e+t)/r*255)}function G(e,r,t=.01){return M(r-e,t)}function je(e,r,t,o){let n=Math.abs(e)-t+o,s=Math.abs(r)-t+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function He(e,r){let n=r*3,s=r*2,a=n+s,i=Math.max(1,Math.round(e/a)),c=e/i,u=c*(3/5),l=c*(2/5),m=l/2;return{dashArray:`${u} ${l}`,offset:m}}function U(e,r){let t=r*3,o=r*2,n=t+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,c=a*.4,u=i/2;return{dashArray:`${i} ${c}`,offset:u}}function Q(e,r,t,o,n){return n==="circle"?Ye(e,r,t,o):n==="squircle"?Xe(e,r,t,o):Ke(e,r,t,o)}function Ye(e,r,t,o){let s=(Math.atan2(r,e)+Math.PI)/(2*Math.PI),a=t/2-o/2,i=2*Math.PI*a,c=o*3,u=o*2,l=Math.floor(i/(c+u)),m=l%2===0?l:l-1,f=Math.max(4,m);return s*f%1<.6}function Xe(e,r,t,o){let s=t/2-o/2,a=t*W,i=Math.max(0,a-o/2),c=s-i,u=2*c,l=.5*Math.PI*i,m=4*u+4*l,f=Ze(e,r,c,i,u,l,m),{dashArray:d}=U(m,o),[h,g]=d.split(" ").map(Number),b=h+g;return(f+h/2)%b<h}function Ze(e,r,t,o,n,s,a){if(r<-t)if(e>t){let i=Math.atan2(r- -t,e-t)+Math.PI/2;return t+i*o}else if(e<-t){let i=Math.atan2(r- -t,e- -t)+Math.PI;return t+3*s+3*n+i*o}else return e>=0?e:a+e;else if(r>t)if(e>t){let i=Math.atan2(r-t,e-t);return t+s+n+i*o}else if(e<-t){let i=Math.atan2(r-t,e- -t)-Math.PI/2;return t+2*s+2*n+i*o}else return t+2*s+n+(t-e);else return e>t?t+s+(r- -t):e<-t?t+3*s+2*n+(t-r):e>=0?e:a+e}function Ke(e,r,t,o){let n=t/2,s=Math.abs(e),i=Math.abs(r)>=s?n+e:n+r,c=t-o,u=3,l=2,m=o*(u+l),f=Math.max(1,Math.round(c/m)),d=c/f,h=d*(u/(u+l)),b=(d-h)/2;return(i+b)%d<h}var W=.12,Je={EYE_FRAME:.90909},E={square:{renderSVG(e,r,t,o){return`<rect x="${e}" y="${r}" width="${t}" height="${t}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},squircle:{renderSVG(e,r,t,o){let n=t/2,s=n*Je.EYE_FRAME,a=e+n,i=r+n;return`<path d="${`M${a},${i-n}
2
2
  C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
3
3
  S${a+s},${i+n} ${a},${i+n}
4
4
  S${a-n},${i+s} ${a-n},${i}
5
- S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),c=Math.abs(r),u=i/n,l=c/n;if(i<.001&&c<.001)return 255;let d=Math.pow(u,a)+Math.pow(l,a),f=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(l,2*a-2)),m=(1-d)/f;return M(m,s)}}},O={classic:{renderSVG(){return""},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01;if(t>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:c,col:u}=o,l=o.qrSize||i.length,d=u>0&&i[c][u-1],f=u<l-1&&i[c][u+1],m=c>0&&i[c-1][u],h=c<l-1&&i[c+1][u],g=d?1/0:n+e,b=f?1/0:n-e,$=m?1/0:n+r,C=h?1/0:n-r,N=Math.min(Math.min(g,b),Math.min($,C));return M(N,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},dots:{renderSVG(e,r,t,o){let n=e+t/2,s=r+t/2,a=t*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+r*r);return G(a,n,s)}},square:{renderSVG(e,r,t,o){let n=t*.7,s=(t-n)/2,a=e+s,i=r+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,r,t,o){let s=t*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(r));return M(i,a)}}},T={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let f=s/2,m=t-s,{dashArray:h,offset:g}=He(m,s);return`<rect x="${e+f}" y="${r+f}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${-g}"/>`}let i=`M${e},${r}h${t}v${t}h${-t}z`,c=e+s,u=r+s,l=t-s*2,d=`M${c},${u}h${l}v${l}h${-l}z`;return`<path d="${i} ${d}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=i-Math.abs(e),l=i-Math.abs(r),d=c-Math.abs(e),f=c-Math.abs(r),m=Math.min(u,l),h=Math.min(d,f);if(m>=0&&h<=0){if(s==="dashed"&&!Q(e,r,t,n,"square"))return 0;let g=M(m,a),b=255-M(h,a);return Math.min(g,b)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t/2,c=e+i,u=r+i,l=i-s/2,d=t*W,f=Math.max(0,d-s/2),m=l-f,h=`M${c},${u-l}
6
- H${c+m}
7
- A${f},${f} 0 0 1 ${c+l},${u-m}
8
- V${u+m}
9
- A${f},${f} 0 0 1 ${c+m},${u+l}
10
- H${c-m}
11
- A${f},${f} 0 0 1 ${c-l},${u+m}
12
- V${u-m}
13
- A${f},${f} 0 0 1 ${c-m},${u-l}
14
- Z`;if(a==="dashed"){let g=2*m,b=.5*Math.PI*f,$=4*g+4*b,{dashArray:C,offset:N}=U($,s);return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${C}" stroke-dashoffset="${N}"/>`}return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,c=t/2-n/2,u=t*W,l=Math.max(0,u-n/2),d=Math.abs(je(e,r,c,l)),f=n/2-d;return f>-a?s==="dashed"&&!Q(e,r,t,n,"squircle")?0:M(f,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+t/2,c=r+t/2,u=t/2;if(a==="dashed"){let m=u-s/2,h=2*Math.PI*m,{dashArray:g,offset:b}=U(h,s);return`<circle cx="${i}" cy="${c}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${b}"/>`}let l=u-s,d=`M${i},${c-u}
5
+ S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),c=Math.abs(r),u=i/n,l=c/n;if(i<.001&&c<.001)return 255;let m=Math.pow(u,a)+Math.pow(l,a),f=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(l,2*a-2)),d=(1-m)/f;return M(d,s)}}},v={classic:{renderSVG(){return""},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01;if(t>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:c,col:u}=o,l=o.qrSize||i.length,m=u>0&&i[c][u-1],f=u<l-1&&i[c][u+1],d=c>0&&i[c-1][u],h=c<l-1&&i[c+1][u],g=m?1/0:n+e,b=f?1/0:n-e,$=d?1/0:n+r,C=h?1/0:n-r,N=Math.min(Math.min(g,b),Math.min($,C));return M(N,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},dots:{renderSVG(e,r,t,o){let n=e+t/2,s=r+t/2,a=t*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+r*r);return G(a,n,s)}},square:{renderSVG(e,r,t,o){let n=t*.7,s=(t-n)/2,a=e+s,i=r+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,r,t,o){let s=t*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(r));return M(i,a)}}},T={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let f=s/2,d=t-s,{dashArray:h,offset:g}=He(d,s);return`<rect x="${e+f}" y="${r+f}" width="${d}" height="${d}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${-g}"/>`}let i=`M${e},${r}h${t}v${t}h${-t}z`,c=e+s,u=r+s,l=t-s*2,m=`M${c},${u}h${l}v${l}h${-l}z`;return`<path d="${i} ${m}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=i-Math.abs(e),l=i-Math.abs(r),m=c-Math.abs(e),f=c-Math.abs(r),d=Math.min(u,l),h=Math.min(m,f);if(d>=0&&h<=0){if(s==="dashed"&&!Q(e,r,t,n,"square"))return 0;let g=M(d,a),b=255-M(h,a);return Math.min(g,b)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t/2,c=e+i,u=r+i,l=i-s/2,m=t*W,f=Math.max(0,m-s/2),d=l-f,h=`M${c},${u-l}
6
+ H${c+d}
7
+ A${f},${f} 0 0 1 ${c+l},${u-d}
8
+ V${u+d}
9
+ A${f},${f} 0 0 1 ${c+d},${u+l}
10
+ H${c-d}
11
+ A${f},${f} 0 0 1 ${c-l},${u+d}
12
+ V${u-d}
13
+ A${f},${f} 0 0 1 ${c-d},${u-l}
14
+ Z`;if(a==="dashed"){let g=2*d,b=.5*Math.PI*f,$=4*g+4*b,{dashArray:C,offset:N}=U($,s);return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${C}" stroke-dashoffset="${N}"/>`}return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,c=t/2-n/2,u=t*W,l=Math.max(0,u-n/2),m=Math.abs(je(e,r,c,l)),f=n/2-m;return f>-a?s==="dashed"&&!Q(e,r,t,n,"squircle")?0:M(f,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+t/2,c=r+t/2,u=t/2;if(a==="dashed"){let d=u-s/2,h=2*Math.PI*d,{dashArray:g,offset:b}=U(h,s);return`<circle cx="${i}" cy="${c}" r="${d}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${b}"/>`}let l=u-s,m=`M${i},${c-u}
15
15
  A${u},${u} 0 1,1 ${i},${c+u}
16
16
  A${u},${u} 0 1,1 ${i},${c-u}Z`,f=`M${i},${c-l}
17
17
  A${l},${l} 0 1,0 ${i},${c+l}
18
- A${l},${l} 0 1,0 ${i},${c-l}Z`;return`<path d="${d} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=Math.sqrt(e*e+r*r);if(u<=i&&u>=c){if(s==="dashed"&&!Q(e,r,t,n,"circle"))return 0;let l=G(u,i,a),d=255-G(u,c,a);return Math.min(l,d)}return 0}}};var S=class extends Error{constructor(r){let t=r.map(o=>` - ${o.field}: ${o.message}`).join(`
18
+ A${l},${l} 0 1,0 ${i},${c-l}Z`;return`<path d="${m} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=Math.sqrt(e*e+r*r);if(u<=i&&u>=c){if(s==="dashed"&&!Q(e,r,t,n,"circle"))return 0;let l=G(u,i,a),m=255-G(u,c,a);return Math.min(l,m)}return 0}}};var S=class extends Error{constructor(r){let t=r.map(o=>` - ${o.field}: ${o.message}`).join(`
19
19
  `);super(`QR Code validation failed:
20
- ${t}`),this.name="QRValidationError",this.errors=r}};function x(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function v(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function j(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function se(e){let r=[];if(e.size!==void 0){let t=x(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=v(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=j(e.eyes.shape,"eyes.shape",E);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=v(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=v(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=j(e.dots.shape,"dots.shape",O);t&&r.push(t)}if(e.dots?.color!==void 0){let t=v(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=x(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=j(e.border.shape,"border.shape",T);t&&r.push(t)}if(e.border?.width!==void 0){let t=x(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=v(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo&&((!e.logo.src||typeof e.logo.src!="string")&&r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"}),e.logo.scale!==void 0)){let t=x(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}if(r.length>0)throw new S(r)}function ae(e){let r=[];if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new S(r)}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 ie(e){if(!e){let{logo:t,...o}=p;return o}return se(e),{size:e.size??p.size,margin:e.margin??p.margin,backgroundColor:e.backgroundColor??p.backgroundColor,eyes:{shape:e.eyes?.shape??p.eyes.shape,color:e.eyes?.color??p.eyes.color},pupils:{color:e.pupils?.color??p.pupils.color},dots:{shape:e.dots?.shape??p.dots.shape,color:e.dots?.color??p.dots.color,scale:e.dots?.scale??p.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??p.logo.scale}:void 0,border:{shape:e.border?.shape??p.border.shape,width:e.border?.width??p.border.width,color:e.border?.color??p.border.color,style:e.border?.style??p.border.style},output:e.output??p.output}}function ce(e){return e?(ae(e),{margin:e.margin??k.margin,darkChar:e.darkChar??k.darkChar,lightChar:e.lightChar??k.lightChar}):{...k}}function ue(e){return/^\d+$/.test(e)?1:[...e].every(r=>R.includes(r))?2:4}function et(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+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--)r.push(n>>a&1)}return r}function tt(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=R.indexOf(e[t])*45+R.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=R.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function rt(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function nt(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=L(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function ot(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function st(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function le(e,r,t){let o=ue(e),n,s;o===1?(n=et(e),s=e.length):o===2?(n=tt(e),s=e.length):(n=rt(e),s=new TextEncoder().encode(e).length);let a=nt(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=ot(a);return st(c,t)}function D(e,r){let t=ue(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=L(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+u+l;if(Math.ceil(d/8)<=r[c-1])return c}let n=L(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===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: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function fe(e,r){if(r)try{if(D(e,y.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 t=["H","Q","M","L"];for(let o of t)try{if(D(e,y[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 w=new Array(256),H=new Array(256);function at(){let e=1;for(let r=0;r<255;r++)w[r]=e,H[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)w[r]=w[r-255]}at();function me(e,r){return e===0||r===0?0:w[H[e]+H[r]]}function it(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=me(r[s],w[t]);r=n}return r}function de(e,r){let t=it(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=me(t[a],s)}return o.slice(e.length)}function he(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let d=e.slice(u,u+a);o.push(d);let f=de(d,r);n.push(f),u+=a}for(let l=0;l<i;l++){let d=e.slice(u,u+c);o.push(d);let f=de(d,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function ge(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function be(e){let r=I(e);return Array.from({length:r},()=>Array(r).fill(!1))}function pe(e){let r=I(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=A[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function Y(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+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),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function ct(e,r,t){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[r+o][t+n]=s||a}}function $e(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function Ce(e){Y(e,0,0),Y(e,0,e.length-7),Y(e,e.length-7,0)}function Me(e,r){let t=e.length,o=A[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||ct(e,n,s)}function ye(e,r){e[4*r+9][8]=!0}function xe(e,r,t){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 c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function X(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){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 ut(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let d=1;d<r;d++)e[a][d]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][d],u=1),e[d][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[d][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function Se(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);X(i,r,a),o(i,t,a);let c=ut(i);c<s&&(s=c,n=a)}return n}function Z(e,r,t){let o=e.length,n=V[r]<<3|t,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 c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Re(e,r){if(r<7)return;let t=e.length,o=ne[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function Ie(e,r){return V[e]<<3|r}function Ee(e,r,t,o,n){let s=be(e),a=pe(e);Ce(s),$e(s),Me(s,e),ye(s,e),xe(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??Se(s,a,r,Z);return X(s,a,c),Z(s,r,c),Re(s,e),{matrix:s,mask:c,formatInfo:n?Ie(r,c):void 0,unmaskedMatrix:i}}function K(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Oe(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function ve(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function lt(e,r,t,o,n,s,a){let i=E[t]||E.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function ft(e,r,t,o){let n=o/2;if(e.includes("data:image/svg")||e.trim().startsWith("<svg")){let s=e;if(e.includes("data:image/svg")){let u=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(u)try{s=decodeURIComponent(u[1])}catch{return""}}let a=s.match(/viewBox=["']([^"']+)["']/),i=a?a[1]:"0 0 100 100",c=s.replace(/<\?xml[^>]*>|<svg[^>]*>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
21
- <svg width="${o}" height="${o}" viewBox="${i}">
22
- ${c}
20
+ ${t}`),this.name="QRValidationError",this.errors=r}};function x(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function O(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function j(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function se(e){let r=[];if(e.size!==void 0){let t=x(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=O(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=j(e.eyes.shape,"eyes.shape",E);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=O(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=O(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=j(e.dots.shape,"dots.shape",v);t&&r.push(t)}if(e.dots?.color!==void 0){let t=O(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=x(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=j(e.border.shape,"border.shape",T);t&&r.push(t)}if(e.border?.width!==void 0){let t=x(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=O(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo&&((!e.logo.src||typeof e.logo.src!="string")&&r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"}),e.logo.scale!==void 0)){let t=x(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}if(r.length>0)throw new S(r)}function ae(e){let r=[];if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new S(r)}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 ie(e){if(!e){let{logo:t,...o}=p;return o}return se(e),{size:e.size??p.size,margin:e.margin??p.margin,backgroundColor:e.backgroundColor??p.backgroundColor,eyes:{shape:e.eyes?.shape??p.eyes.shape,color:e.eyes?.color??p.eyes.color},pupils:{color:e.pupils?.color??p.pupils.color},dots:{shape:e.dots?.shape??p.dots.shape,color:e.dots?.color??p.dots.color,scale:e.dots?.scale??p.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??p.logo.scale}:void 0,border:{shape:e.border?.shape??p.border.shape,width:e.border?.width??p.border.width,color:e.border?.color??p.border.color,style:e.border?.style??p.border.style},output:e.output??p.output}}function ce(e){return e?(ae(e),{margin:e.margin??k.margin,darkChar:e.darkChar??k.darkChar,lightChar:e.lightChar??k.lightChar}):{...k}}function ue(e){return/^\d+$/.test(e)?1:[...e].every(r=>R.includes(r))?2:4}function et(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+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--)r.push(n>>a&1)}return r}function tt(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=R.indexOf(e[t])*45+R.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=R.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function rt(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function nt(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=L(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function ot(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function st(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function le(e,r,t){let o=ue(e),n,s;o===1?(n=et(e),s=e.length):o===2?(n=tt(e),s=e.length):(n=rt(e),s=new TextEncoder().encode(e).length);let a=nt(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=ot(a);return st(c,t)}function D(e,r){let t=ue(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=L(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,m=4+u+l;if(Math.ceil(m/8)<=r[c-1])return c}let n=L(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===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: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function fe(e,r){if(r)try{if(D(e,y.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 t=["H","Q","M","L"];for(let o of t)try{if(D(e,y[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 w=new Array(256),H=new Array(256);function at(){let e=1;for(let r=0;r<255;r++)w[r]=e,H[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)w[r]=w[r-255]}at();function de(e,r){return e===0||r===0?0:w[H[e]+H[r]]}function it(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=de(r[s],w[t]);r=n}return r}function me(e,r){let t=it(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=de(t[a],s)}return o.slice(e.length)}function he(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let m=e.slice(u,u+a);o.push(m);let f=me(m,r);n.push(f),u+=a}for(let l=0;l<i;l++){let m=e.slice(u,u+c);o.push(m);let f=me(m,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function ge(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function be(e){let r=I(e);return Array.from({length:r},()=>Array(r).fill(!1))}function pe(e){let r=I(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=A[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function Y(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+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),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function ct(e,r,t){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[r+o][t+n]=s||a}}function $e(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function Ce(e){Y(e,0,0),Y(e,0,e.length-7),Y(e,e.length-7,0)}function Me(e,r){let t=e.length,o=A[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||ct(e,n,s)}function ye(e,r){e[4*r+9][8]=!0}function xe(e,r,t){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 c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function X(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){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 ut(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let m=1;m<r;m++)e[a][m]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][m],u=1),e[m][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[m][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function Se(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);X(i,r,a),o(i,t,a);let c=ut(i);c<s&&(s=c,n=a)}return n}function Z(e,r,t){let o=e.length,n=V[r]<<3|t,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 c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function Re(e,r){if(r<7)return;let t=e.length,o=ne[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function Ie(e,r){return V[e]<<3|r}function Ee(e,r,t,o,n){let s=be(e),a=pe(e);Ce(s),$e(s),Me(s,e),ye(s,e),xe(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??Se(s,a,r,Z);return X(s,a,c),Z(s,r,c),Re(s,e),{matrix:s,mask:c,formatInfo:n?Ie(r,c):void 0,unmaskedMatrix:i}}function K(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function ve(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Oe(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function lt(e,r,t,o,n,s,a){let i=E[t]||E.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function ft(e,r,t,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 d=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(d)try{i=decodeURIComponent(d[1])}catch{return""}}let c=i.match(/viewBox=["']([^"']+)["']/),u=c?c[1]:"0 0 100 100",l=i.match(/<svg([^>]*)>/i),m="";if(l){let d=l[1].match(/xmlns[^=]*=["'][^"']*["']/gi);d&&(m=" "+d.join(" "))}let f=i.replace(/<\?xml[^>]*>|<svg[^>]*>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
21
+ <svg width="${o}" height="${o}" viewBox="${u}"${m}>
22
+ ${f}
23
23
  </svg>
24
- </g>`}else return`<image x="${r-n}" y="${t-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function dt(e,r,t,o,n){let s=e.matrixSize,a="",i=O[t]||O.classic;if(t==="classic"){a=`<path fill="${o}" d="`;for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!K(c,u,s)){let l=u*r,d=c*r,f=n*r,m=(1-n)*r/2,h=l+m,g=d+m;a+=`M${h},${g}h${f}v${f}h${-f}z`}return a+='"/>',a}for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!K(c,u,s)){let l=u*r,d=c*r,f=n*r,m=(1-n)*r/2,h=l+m,g=d+m,b={qrcode:e.modules,qrSize:s,row:c,col:u};a+=i.renderSVG(h,g,f,o,b)}return a}function we(e,r){let{size:t,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=r,c=t/e.matrixSize,u=r.border.shape==="none"?0:r.border.width,l=t+2*o+2*u,d=o+u,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" width="${l}" height="${l}">`;if(f+=`<rect width="${l}" height="${l}" fill="${n}"/>`,r.border.shape!=="none"&&u>0){let $=T[r.border.shape];if($){let C={borderWidth:u,borderStyle:r.border.style};f+=$.renderSVG(0,0,l,r.border.color,C)}}r.border.shape!=="none"&&u>0&&(f+=`<rect x="${d}" y="${d}" width="${t}" height="${t}" fill="${n}"/>`),f+=`<g transform="translate(${d}, ${d})">`;let m=Oe(e.matrixSize),h="";for(let $ of m)h+=lt($.x*c,$.y*c,s.shape,s.color,a.color,n,c);let g=dt(e,c,i.shape,i.color,i.scale);f+=h+g+"</g>";let b="";if(r.logo){let $=ve(e.matrixSize,r.logo.scale)*c,C=l/2;b=ft(r.logo.src,C,C,$)}return f+=b+"</svg>",f}function Pe(e,r){let{margin:t,lightChar:o,darkChar:n}=r,s="",a=e.matrixSize+t*2;for(let i=0;i<t;i++)s+=o.repeat(a)+`
24
+ </g>`}else return`<image x="${r-n}" y="${t-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function mt(e,r,t,o,n){let s=e.matrixSize,a="",i=v[t]||v.classic;if(t==="classic"){a=`<path fill="${o}" d="`;for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!K(c,u,s)){let l=u*r,m=c*r,f=n*r,d=(1-n)*r/2,h=l+d,g=m+d;a+=`M${h},${g}h${f}v${f}h${-f}z`}return a+='"/>',a}for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!K(c,u,s)){let l=u*r,m=c*r,f=n*r,d=(1-n)*r/2,h=l+d,g=m+d,b={qrcode:e.modules,qrSize:s,row:c,col:u};a+=i.renderSVG(h,g,f,o,b)}return a}function we(e,r){let{size:t,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=r,c=t/e.matrixSize,u=r.border.shape==="none"?0:r.border.width,l=t+2*o+2*u,m=o+u,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" width="${l}" height="${l}">`;if(f+=`<rect width="${l}" height="${l}" fill="${n}"/>`,r.border.shape!=="none"&&u>0){let $=T[r.border.shape];if($){let C={borderWidth:u,borderStyle:r.border.style};f+=$.renderSVG(0,0,l,r.border.color,C)}}r.border.shape!=="none"&&u>0&&(f+=`<rect x="${m}" y="${m}" width="${t}" height="${t}" fill="${n}"/>`),f+=`<g transform="translate(${m}, ${m})">`;let d=ve(e.matrixSize),h="";for(let $ of d)h+=lt($.x*c,$.y*c,s.shape,s.color,a.color,n,c);let g=mt(e,c,i.shape,i.color,i.scale);f+=h+g+"</g>";let b="";if(r.logo){let $=Oe(e.matrixSize,r.logo.scale)*c,C=l/2;b=ft(r.logo.src,C,C,$)}return f+=b+"</svg>",f}function Pe(e,r){let{margin:t,lightChar:o,darkChar:n}=r,s="",a=e.matrixSize+t*2;for(let i=0;i<t;i++)s+=o.repeat(a)+`
25
25
  `;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(t);for(let c=0;c<e.matrixSize;c++)s+=e.modules[i][c]?n:o;s+=o.repeat(t)+`
26
26
  `}for(let i=0;i<t;i++)s+=o.repeat(a)+`
27
- `;return s}var B=null,Ae=!1;async function mt(){if(B)return B;if(Ae)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");Ae=!0;try{return B=(await import("@resvg/resvg-js")).Resvg,B}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Le(e,r){let{output:t,size:o,margin:n,border:s}=r,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,c=await mt(),d=new c(e,{fitTo:{mode:"width",value:i}}).render().asPng(),f=Buffer.from(d);return t.type==="dataURL"?`data:image/png;base64,${f.toString("base64")}`:f}async function Te(e,r){let{format:t,type:o}=r.output;return t==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Le(e,r)}function J(e){if(typeof e=="string")return e;switch(e.type){case"url":return ht(e.url);case"vcard":return gt(e.data);case"wifi":return bt(e.data);case"calendar":return pt(e.data);case"email":return $t(e.email,e.subject,e.body);case"sms":return Ct(e.phone,e.message);case"phone":return Mt(e.phone)}}function ht(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function gt(e){let r=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&r.push(`TEL:${e.phone}`),e.email&&r.push(`EMAIL:${e.email}`),e.organization&&r.push(`ORG:${e.organization}`),e.url&&r.push(`URL:${e.url}`),e.title&&r.push(`TITLE:${e.title}`),e.note&&r.push(`NOTE:${e.note}`),e.address){let{street:t,city:o,state:n,zip:s,country:a}=e.address,i=["","",t||"",o||"",n||"",s||"",a||""];r.push(`ADR:${i.join(";")}`)}return r.push("END:VCARD"),r.join(`
27
+ `;return s}var B=null,Ae=!1;async function dt(){if(B)return B;if(Ae)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");Ae=!0;try{return B=(await import("@resvg/resvg-js")).Resvg,B}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Le(e,r){let{output:t,size:o,margin:n,border:s}=r,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,c=await dt(),m=new c(e,{fitTo:{mode:"width",value:i}}).render().asPng(),f=Buffer.from(m);return t.type==="dataURL"?`data:image/png;base64,${f.toString("base64")}`:f}async function Te(e,r){let{format:t,type:o}=r.output;return t==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Le(e,r)}function J(e){if(typeof e=="string")return e;switch(e.type){case"url":return ht(e.url);case"vcard":return gt(e.data);case"wifi":return bt(e.data);case"calendar":return pt(e.data);case"email":return $t(e.email,e.subject,e.body);case"sms":return Ct(e.phone,e.message);case"phone":return Mt(e.phone)}}function ht(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function gt(e){let r=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&r.push(`TEL:${e.phone}`),e.email&&r.push(`EMAIL:${e.email}`),e.organization&&r.push(`ORG:${e.organization}`),e.url&&r.push(`URL:${e.url}`),e.title&&r.push(`TITLE:${e.title}`),e.note&&r.push(`NOTE:${e.note}`),e.address){let{street:t,city:o,state:n,zip:s,country:a}=e.address,i=["","",t||"",o||"",n||"",s||"",a||""];r.push(`ADR:${i.join(";")}`)}return r.push("END:VCARD"),r.join(`
28
28
  `)}function bt(e){let r=e.encryption||"WPA",t=e.hidden?"H:true;":"",o=ke(e.ssid),n=ke(e.password);return`WIFI:T:${r};S:${o};P:${n};${t};`}function ke(e){return e.replace(/([\\;,":])/g,"\\$1")}function pt(e){let r=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",t=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${r(e.startDate)}`,`DTEND:${r(e.endDate)}`];return e.location&&t.push(`LOCATION:${e.location}`),e.description&&t.push(`DESCRIPTION:${e.description}`),t.push("END:VEVENT","END:VCALENDAR"),t.join(`
29
- `)}function $t(e,r,t){let o=`mailto:${e}`,n=[];return r&&n.push(`subject=${encodeURIComponent(r)}`),t&&n.push(`body=${encodeURIComponent(t)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function Ct(e,r){return r?`sms:${e}:${r}`:`sms:${e}`}function Mt(e){return`tel:${e}`}function yt(e,r){let t=[];for(let n of e)for(let s=7;s>=0;s--)t.push((n>>s&1)===1);let o=oe[r-1];for(let n=0;n<o;n++)t.push(!1);return t}function De(e,r){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let t=fe(e,r),o=y[t],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 ${t}: ~${y[t][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=le(e,n,o[n-1]),a=te[t][n-1],i=re[t][n-1],{dataBlocks:c,ecBlocks:u}=he(s,a,i),l=ge(c,u),d=yt(l,n),{matrix:f,mask:m}=Ee(n,t,d);return{version:n,matrixSize:I(n),modules:f,mask:m,errorCorrectionLevel:t}}async function Be(e,r){let t=J(e),o=ie(r),n=De(t,!!o.logo),s=we(n,o);return await Te(s,o)}function Ne(e,r){let t=J(e),o=ce(r),n=De(t,!1);return Pe(n,o)}0&&(module.exports={BorderShape,BorderStyle,DotShape,EyeFrameShape,QRValidationError,genQrImage,genQrText});
29
+ `)}function $t(e,r,t){let o=`mailto:${e}`,n=[];return r&&n.push(`subject=${encodeURIComponent(r)}`),t&&n.push(`body=${encodeURIComponent(t)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function Ct(e,r){return r?`sms:${e}:${r}`:`sms:${e}`}function Mt(e){return`tel:${e}`}function yt(e,r){let t=[];for(let n of e)for(let s=7;s>=0;s--)t.push((n>>s&1)===1);let o=oe[r-1];for(let n=0;n<o;n++)t.push(!1);return t}function De(e,r){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let t=fe(e,r),o=y[t],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 ${t}: ~${y[t][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=le(e,n,o[n-1]),a=te[t][n-1],i=re[t][n-1],{dataBlocks:c,ecBlocks:u}=he(s,a,i),l=ge(c,u),m=yt(l,n),{matrix:f,mask:d}=Ee(n,t,m);return{version:n,matrixSize:I(n),modules:f,mask:d,errorCorrectionLevel:t}}async function Be(e,r){let t=J(e),o=ie(r),n=De(t,!!o.logo),s=we(n,o);return await Te(s,o)}function Ne(e,r){let t=J(e),o=ce(r),n=De(t,!1);return Pe(n,o)}0&&(module.exports={BorderShape,BorderStyle,DotShape,EyeFrameShape,QRValidationError,genQrImage,genQrText});
package/dist/node.mjs CHANGED
@@ -1,29 +1,29 @@
1
- var Y={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]},y={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]},X={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]]},S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ke={1:[10,12,14],2:[9,11,13],4:[8,16,16]},N={L:1,M:0,Q:3,H:2},P=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],Z=[31892,34236,39577,42195],K=[0,7,7,7,7,7,0,0,0,0];function R(e){return e*4+17}function A(e,r){let t=r<10?0:r<27?1:2;return ke[e][t]}var J=(t=>(t.SQUARE="square",t.SQUIRCLE="squircle",t))(J||{}),ee=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(ee||{}),te=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(te||{}),re=(t=>(t.SOLID="solid",t.DASHED="dashed",t))(re||{});function M(e,r){let t=r/2;return e<=-t?0:e>=t?255:Math.round((e+t)/r*255)}function z(e,r,t=.01){return M(r-e,t)}function De(e,r,t,o){let n=Math.abs(e)-t+o,s=Math.abs(r)-t+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function Be(e,r){let n=r*3,s=r*2,a=n+s,i=Math.max(1,Math.round(e/a)),c=e/i,u=c*(3/5),l=c*(2/5),d=l/2;return{dashArray:`${u} ${l}`,offset:d}}function F(e,r){let t=r*3,o=r*2,n=t+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,c=a*.4,u=i/2;return{dashArray:`${i} ${c}`,offset:u}}function V(e,r,t,o,n){return n==="circle"?Ne(e,r,t,o):n==="squircle"?Ve(e,r,t,o):Fe(e,r,t,o)}function Ne(e,r,t,o){let s=(Math.atan2(r,e)+Math.PI)/(2*Math.PI),a=t/2-o/2,i=2*Math.PI*a,c=o*3,u=o*2,l=Math.floor(i/(c+u)),d=l%2===0?l:l-1,f=Math.max(4,d);return s*f%1<.6}function Ve(e,r,t,o){let s=t/2-o/2,a=t*q,i=Math.max(0,a-o/2),c=s-i,u=2*c,l=.5*Math.PI*i,d=4*u+4*l,f=ze(e,r,c,i,u,l,d),{dashArray:m}=F(d,o),[h,g]=m.split(" ").map(Number),b=h+g;return(f+h/2)%b<h}function ze(e,r,t,o,n,s,a){if(r<-t)if(e>t){let i=Math.atan2(r- -t,e-t)+Math.PI/2;return t+i*o}else if(e<-t){let i=Math.atan2(r- -t,e- -t)+Math.PI;return t+3*s+3*n+i*o}else return e>=0?e:a+e;else if(r>t)if(e>t){let i=Math.atan2(r-t,e-t);return t+s+n+i*o}else if(e<-t){let i=Math.atan2(r-t,e- -t)-Math.PI/2;return t+2*s+2*n+i*o}else return t+2*s+n+(t-e);else return e>t?t+s+(r- -t):e<-t?t+3*s+2*n+(t-r):e>=0?e:a+e}function Fe(e,r,t,o){let n=t/2,s=Math.abs(e),i=Math.abs(r)>=s?n+e:n+r,c=t-o,u=3,l=2,d=o*(u+l),f=Math.max(1,Math.round(c/d)),m=c/f,h=m*(u/(u+l)),b=(m-h)/2;return(i+b)%m<h}var q=.12,qe={EYE_FRAME:.90909},I={square:{renderSVG(e,r,t,o){return`<rect x="${e}" y="${r}" width="${t}" height="${t}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},squircle:{renderSVG(e,r,t,o){let n=t/2,s=n*qe.EYE_FRAME,a=e+n,i=r+n;return`<path d="${`M${a},${i-n}
1
+ var Y={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]},y={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]},X={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]]},S="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",ke={1:[10,12,14],2:[9,11,13],4:[8,16,16]},N={L:1,M:0,Q:3,H:2},P=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],Z=[31892,34236,39577,42195],K=[0,7,7,7,7,7,0,0,0,0];function R(e){return e*4+17}function A(e,r){let t=r<10?0:r<27?1:2;return ke[e][t]}var J=(t=>(t.SQUARE="square",t.SQUIRCLE="squircle",t))(J||{}),ee=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(ee||{}),te=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(te||{}),re=(t=>(t.SOLID="solid",t.DASHED="dashed",t))(re||{});function M(e,r){let t=r/2;return e<=-t?0:e>=t?255:Math.round((e+t)/r*255)}function z(e,r,t=.01){return M(r-e,t)}function De(e,r,t,o){let n=Math.abs(e)-t+o,s=Math.abs(r)-t+o,a=Math.sqrt(Math.max(n,0)**2+Math.max(s,0)**2),i=Math.min(Math.max(n,s),0);return a+i-o}function Be(e,r){let n=r*3,s=r*2,a=n+s,i=Math.max(1,Math.round(e/a)),c=e/i,u=c*(3/5),l=c*(2/5),m=l/2;return{dashArray:`${u} ${l}`,offset:m}}function F(e,r){let t=r*3,o=r*2,n=t+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,c=a*.4,u=i/2;return{dashArray:`${i} ${c}`,offset:u}}function V(e,r,t,o,n){return n==="circle"?Ne(e,r,t,o):n==="squircle"?Ve(e,r,t,o):Fe(e,r,t,o)}function Ne(e,r,t,o){let s=(Math.atan2(r,e)+Math.PI)/(2*Math.PI),a=t/2-o/2,i=2*Math.PI*a,c=o*3,u=o*2,l=Math.floor(i/(c+u)),m=l%2===0?l:l-1,f=Math.max(4,m);return s*f%1<.6}function Ve(e,r,t,o){let s=t/2-o/2,a=t*q,i=Math.max(0,a-o/2),c=s-i,u=2*c,l=.5*Math.PI*i,m=4*u+4*l,f=ze(e,r,c,i,u,l,m),{dashArray:d}=F(m,o),[h,g]=d.split(" ").map(Number),b=h+g;return(f+h/2)%b<h}function ze(e,r,t,o,n,s,a){if(r<-t)if(e>t){let i=Math.atan2(r- -t,e-t)+Math.PI/2;return t+i*o}else if(e<-t){let i=Math.atan2(r- -t,e- -t)+Math.PI;return t+3*s+3*n+i*o}else return e>=0?e:a+e;else if(r>t)if(e>t){let i=Math.atan2(r-t,e-t);return t+s+n+i*o}else if(e<-t){let i=Math.atan2(r-t,e- -t)-Math.PI/2;return t+2*s+2*n+i*o}else return t+2*s+n+(t-e);else return e>t?t+s+(r- -t):e<-t?t+3*s+2*n+(t-r):e>=0?e:a+e}function Fe(e,r,t,o){let n=t/2,s=Math.abs(e),i=Math.abs(r)>=s?n+e:n+r,c=t-o,u=3,l=2,m=o*(u+l),f=Math.max(1,Math.round(c/m)),d=c/f,h=d*(u/(u+l)),b=(d-h)/2;return(i+b)%d<h}var q=.12,qe={EYE_FRAME:.90909},I={square:{renderSVG(e,r,t,o){return`<rect x="${e}" y="${r}" width="${t}" height="${t}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},squircle:{renderSVG(e,r,t,o){let n=t/2,s=n*qe.EYE_FRAME,a=e+n,i=r+n;return`<path d="${`M${a},${i-n}
2
2
  C${a+s},${i-n} ${a+n},${i-s} ${a+n},${i}
3
3
  S${a+s},${i+n} ${a},${i+n}
4
4
  S${a-n},${i+s} ${a-n},${i}
5
- S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),c=Math.abs(r),u=i/n,l=c/n;if(i<.001&&c<.001)return 255;let d=Math.pow(u,a)+Math.pow(l,a),f=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(l,2*a-2)),m=(1-d)/f;return M(m,s)}}},E={classic:{renderSVG(){return""},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01;if(t>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:c,col:u}=o,l=o.qrSize||i.length,d=u>0&&i[c][u-1],f=u<l-1&&i[c][u+1],m=c>0&&i[c-1][u],h=c<l-1&&i[c+1][u],g=d?1/0:n+e,b=f?1/0:n-e,$=m?1/0:n+r,C=h?1/0:n-r,B=Math.min(Math.min(g,b),Math.min($,C));return M(B,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},dots:{renderSVG(e,r,t,o){let n=e+t/2,s=r+t/2,a=t*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+r*r);return z(a,n,s)}},square:{renderSVG(e,r,t,o){let n=t*.7,s=(t-n)/2,a=e+s,i=r+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,r,t,o){let s=t*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(r));return M(i,a)}}},L={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let f=s/2,m=t-s,{dashArray:h,offset:g}=Be(m,s);return`<rect x="${e+f}" y="${r+f}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${-g}"/>`}let i=`M${e},${r}h${t}v${t}h${-t}z`,c=e+s,u=r+s,l=t-s*2,d=`M${c},${u}h${l}v${l}h${-l}z`;return`<path d="${i} ${d}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=i-Math.abs(e),l=i-Math.abs(r),d=c-Math.abs(e),f=c-Math.abs(r),m=Math.min(u,l),h=Math.min(d,f);if(m>=0&&h<=0){if(s==="dashed"&&!V(e,r,t,n,"square"))return 0;let g=M(m,a),b=255-M(h,a);return Math.min(g,b)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t/2,c=e+i,u=r+i,l=i-s/2,d=t*q,f=Math.max(0,d-s/2),m=l-f,h=`M${c},${u-l}
6
- H${c+m}
7
- A${f},${f} 0 0 1 ${c+l},${u-m}
8
- V${u+m}
9
- A${f},${f} 0 0 1 ${c+m},${u+l}
10
- H${c-m}
11
- A${f},${f} 0 0 1 ${c-l},${u+m}
12
- V${u-m}
13
- A${f},${f} 0 0 1 ${c-m},${u-l}
14
- Z`;if(a==="dashed"){let g=2*m,b=.5*Math.PI*f,$=4*g+4*b,{dashArray:C,offset:B}=F($,s);return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${C}" stroke-dashoffset="${B}"/>`}return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,c=t/2-n/2,u=t*q,l=Math.max(0,u-n/2),d=Math.abs(De(e,r,c,l)),f=n/2-d;return f>-a?s==="dashed"&&!V(e,r,t,n,"squircle")?0:M(f,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+t/2,c=r+t/2,u=t/2;if(a==="dashed"){let m=u-s/2,h=2*Math.PI*m,{dashArray:g,offset:b}=F(h,s);return`<circle cx="${i}" cy="${c}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${b}"/>`}let l=u-s,d=`M${i},${c-u}
5
+ S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01,a=4,i=Math.abs(e),c=Math.abs(r),u=i/n,l=c/n;if(i<.001&&c<.001)return 255;let m=Math.pow(u,a)+Math.pow(l,a),f=a/n*Math.sqrt(Math.pow(u,2*a-2)+Math.pow(l,2*a-2)),d=(1-m)/f;return M(d,s)}}},E={classic:{renderSVG(){return""},renderPixel(e,r,t,o){let n=t/2,s=o?.pixelSize??.01;if(t>=.99&&o&&o.qrcode&&o.row!==void 0&&o.col!==void 0){let{qrcode:i,row:c,col:u}=o,l=o.qrSize||i.length,m=u>0&&i[c][u-1],f=u<l-1&&i[c][u+1],d=c>0&&i[c-1][u],h=c<l-1&&i[c+1][u],g=m?1/0:n+e,b=f?1/0:n-e,$=d?1/0:n+r,C=h?1/0:n-r,B=Math.min(Math.min(g,b),Math.min($,C));return M(B,s)}let a=Math.min(n-Math.abs(e),n-Math.abs(r));return M(a,s)}},dots:{renderSVG(e,r,t,o){let n=e+t/2,s=r+t/2,a=t*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`},renderPixel(e,r,t,o){let n=t*.35,s=o?.pixelSize??.01,a=Math.sqrt(e*e+r*r);return z(a,n,s)}},square:{renderSVG(e,r,t,o){let n=t*.7,s=(t-n)/2,a=e+s,i=r+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`},renderPixel(e,r,t,o){let s=t*.7/2,a=o?.pixelSize??.01,i=Math.min(s-Math.abs(e),s-Math.abs(r));return M(i,a)}}},L={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let f=s/2,d=t-s,{dashArray:h,offset:g}=Be(d,s);return`<rect x="${e+f}" y="${r+f}" width="${d}" height="${d}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${-g}"/>`}let i=`M${e},${r}h${t}v${t}h${-t}z`,c=e+s,u=r+s,l=t-s*2,m=`M${c},${u}h${l}v${l}h${-l}z`;return`<path d="${i} ${m}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=i-Math.abs(e),l=i-Math.abs(r),m=c-Math.abs(e),f=c-Math.abs(r),d=Math.min(u,l),h=Math.min(m,f);if(d>=0&&h<=0){if(s==="dashed"&&!V(e,r,t,n,"square"))return 0;let g=M(d,a),b=255-M(h,a);return Math.min(g,b)}return 0}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=t/2,c=e+i,u=r+i,l=i-s/2,m=t*q,f=Math.max(0,m-s/2),d=l-f,h=`M${c},${u-l}
6
+ H${c+d}
7
+ A${f},${f} 0 0 1 ${c+l},${u-d}
8
+ V${u+d}
9
+ A${f},${f} 0 0 1 ${c+d},${u+l}
10
+ H${c-d}
11
+ A${f},${f} 0 0 1 ${c-l},${u+d}
12
+ V${u-d}
13
+ A${f},${f} 0 0 1 ${c-d},${u-l}
14
+ Z`;if(a==="dashed"){let g=2*d,b=.5*Math.PI*f,$=4*g+4*b,{dashArray:C,offset:B}=F($,s);return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${C}" stroke-dashoffset="${B}"/>`}return`<path d="${h}" fill="none" stroke="${o}" stroke-width="${s}"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,c=t/2-n/2,u=t*q,l=Math.max(0,u-n/2),m=Math.abs(De(e,r,c,l)),f=n/2-m;return f>-a?s==="dashed"&&!V(e,r,t,n,"squircle")?0:M(f,a):0}},circle:{getDiagonalFactor(){return 1},renderSVG(e,r,t,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+t/2,c=r+t/2,u=t/2;if(a==="dashed"){let d=u-s/2,h=2*Math.PI*d,{dashArray:g,offset:b}=F(h,s);return`<circle cx="${i}" cy="${c}" r="${d}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${b}"/>`}let l=u-s,m=`M${i},${c-u}
15
15
  A${u},${u} 0 1,1 ${i},${c+u}
16
16
  A${u},${u} 0 1,1 ${i},${c-u}Z`,f=`M${i},${c-l}
17
17
  A${l},${l} 0 1,0 ${i},${c+l}
18
- A${l},${l} 0 1,0 ${i},${c-l}Z`;return`<path d="${d} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=Math.sqrt(e*e+r*r);if(u<=i&&u>=c){if(s==="dashed"&&!V(e,r,t,n,"circle"))return 0;let l=z(u,i,a),d=255-z(u,c,a);return Math.min(l,d)}return 0}}};var v=class extends Error{constructor(r){let t=r.map(o=>` - ${o.field}: ${o.message}`).join(`
18
+ A${l},${l} 0 1,0 ${i},${c-l}Z`;return`<path d="${m} ${f}" fill="${o}" fill-rule="evenodd"/>`},renderPixel(e,r,t,o){let n=o?.borderWidth??1,s=o?.borderStyle??"solid",a=o?.pixelSize??.01,i=t/2,c=i-n,u=Math.sqrt(e*e+r*r);if(u<=i&&u>=c){if(s==="dashed"&&!V(e,r,t,n,"circle"))return 0;let l=z(u,i,a),m=255-z(u,c,a);return Math.min(l,m)}return 0}}};var O=class extends Error{constructor(r){let t=r.map(o=>` - ${o.field}: ${o.message}`).join(`
19
19
  `);super(`QR Code validation failed:
20
- ${t}`),this.name="QRValidationError",this.errors=r}};function x(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function O(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function _(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function ne(e){let r=[];if(e.size!==void 0){let t=x(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=O(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=_(e.eyes.shape,"eyes.shape",I);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=O(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=O(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=_(e.dots.shape,"dots.shape",E);t&&r.push(t)}if(e.dots?.color!==void 0){let t=O(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=x(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=_(e.border.shape,"border.shape",L);t&&r.push(t)}if(e.border?.width!==void 0){let t=x(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=O(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo&&((!e.logo.src||typeof e.logo.src!="string")&&r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"}),e.logo.scale!==void 0)){let t=x(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}if(r.length>0)throw new v(r)}function oe(e){let r=[];if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new v(r)}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"}},T={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function se(e){if(!e){let{logo:t,...o}=p;return o}return ne(e),{size:e.size??p.size,margin:e.margin??p.margin,backgroundColor:e.backgroundColor??p.backgroundColor,eyes:{shape:e.eyes?.shape??p.eyes.shape,color:e.eyes?.color??p.eyes.color},pupils:{color:e.pupils?.color??p.pupils.color},dots:{shape:e.dots?.shape??p.dots.shape,color:e.dots?.color??p.dots.color,scale:e.dots?.scale??p.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??p.logo.scale}:void 0,border:{shape:e.border?.shape??p.border.shape,width:e.border?.width??p.border.width,color:e.border?.color??p.border.color,style:e.border?.style??p.border.style},output:e.output??p.output}}function ae(e){return e?(oe(e),{margin:e.margin??T.margin,darkChar:e.darkChar??T.darkChar,lightChar:e.lightChar??T.lightChar}):{...T}}function ie(e){return/^\d+$/.test(e)?1:[...e].every(r=>S.includes(r))?2:4}function _e(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+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--)r.push(n>>a&1)}return r}function Qe(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=S.indexOf(e[t])*45+S.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=S.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function Ge(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function Ue(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=A(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function We(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function je(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function ce(e,r,t){let o=ie(e),n,s;o===1?(n=_e(e),s=e.length):o===2?(n=Qe(e),s=e.length):(n=Ge(e),s=new TextEncoder().encode(e).length);let a=Ue(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=We(a);return je(c,t)}function k(e,r){let t=ie(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=A(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,d=4+u+l;if(Math.ceil(d/8)<=r[c-1])return c}let n=A(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===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: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ue(e,r){if(r)try{if(k(e,y.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 t=["H","Q","M","L"];for(let o of t)try{if(k(e,y[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 w=new Array(256),Q=new Array(256);function He(){let e=1;for(let r=0;r<255;r++)w[r]=e,Q[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)w[r]=w[r-255]}He();function fe(e,r){return e===0||r===0?0:w[Q[e]+Q[r]]}function Ye(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=fe(r[s],w[t]);r=n}return r}function le(e,r){let t=Ye(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=fe(t[a],s)}return o.slice(e.length)}function de(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let d=e.slice(u,u+a);o.push(d);let f=le(d,r);n.push(f),u+=a}for(let l=0;l<i;l++){let d=e.slice(u,u+c);o.push(d);let f=le(d,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function me(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function he(e){let r=R(e);return Array.from({length:r},()=>Array(r).fill(!1))}function ge(e){let r=R(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function G(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+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),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function Xe(e,r,t){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[r+o][t+n]=s||a}}function be(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function pe(e){G(e,0,0),G(e,0,e.length-7),G(e,e.length-7,0)}function $e(e,r){let t=e.length,o=P[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||Xe(e,n,s)}function Ce(e,r){e[4*r+9][8]=!0}function Me(e,r,t){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 c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function U(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){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 Ze(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let d=1;d<r;d++)e[a][d]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][d],u=1),e[d][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[d][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function ye(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);U(i,r,a),o(i,t,a);let c=Ze(i);c<s&&(s=c,n=a)}return n}function W(e,r,t){let o=e.length,n=N[r]<<3|t,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 c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function xe(e,r){if(r<7)return;let t=e.length,o=Z[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function Se(e,r){return N[e]<<3|r}function Re(e,r,t,o,n){let s=he(e),a=ge(e);pe(s),be(s),$e(s,e),Ce(s,e),Me(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??ye(s,a,r,W);return U(s,a,c),W(s,r,c),xe(s,e),{matrix:s,mask:c,formatInfo:n?Se(r,c):void 0,unmaskedMatrix:i}}function j(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Ie(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ee(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function Ke(e,r,t,o,n,s,a){let i=I[t]||I.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function Je(e,r,t,o){let n=o/2;if(e.includes("data:image/svg")||e.trim().startsWith("<svg")){let s=e;if(e.includes("data:image/svg")){let u=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(u)try{s=decodeURIComponent(u[1])}catch{return""}}let a=s.match(/viewBox=["']([^"']+)["']/),i=a?a[1]:"0 0 100 100",c=s.replace(/<\?xml[^>]*>|<svg[^>]*>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
21
- <svg width="${o}" height="${o}" viewBox="${i}">
22
- ${c}
20
+ ${t}`),this.name="QRValidationError",this.errors=r}};function x(e,r,t,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:r,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:r,value:e,message:"must be an integer"}:e<t?{field:r,value:e,message:`must be at least ${t}`}:o!==null&&e>o?{field:r,value:e,message:`must be at most ${o}`}:null}function v(e,r){return typeof e!="string"?{field:r,value:e,message:"must be a string"}:/^#[0-9A-Fa-f]{6}$/.test(e)?null:{field:r,value:e,message:"must be a valid hex color (e.g., #000000)"}}function _(e,r,t){if(typeof e!="string")return{field:r,value:e,message:"must be a string"};if(!(e in t)){let o=Object.keys(t).join(", ");return{field:r,value:e,message:`must be one of: ${o}`}}return null}function ne(e){let r=[];if(e.size!==void 0){let t=x(e.size,"size",21,null,!0);t&&r.push(t)}if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.backgroundColor!==void 0){let t=v(e.backgroundColor,"backgroundColor");t&&r.push(t)}if(e.eyes?.shape!==void 0){let t=_(e.eyes.shape,"eyes.shape",I);t&&r.push(t)}if(e.eyes?.color!==void 0){let t=v(e.eyes.color,"eyes.color");t&&r.push(t)}if(e.pupils?.color!==void 0){let t=v(e.pupils.color,"pupils.color");t&&r.push(t)}if(e.dots?.shape!==void 0){let t=_(e.dots.shape,"dots.shape",E);t&&r.push(t)}if(e.dots?.color!==void 0){let t=v(e.dots.color,"dots.color");t&&r.push(t)}if(e.dots?.scale!==void 0){let t=x(e.dots.scale,"dots.scale",.75,1.25,!1);t&&r.push(t)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let t=_(e.border.shape,"border.shape",L);t&&r.push(t)}if(e.border?.width!==void 0){let t=x(e.border.width,"border.width",0,null,!0);t&&r.push(t)}if(e.border?.color!==void 0){let t=v(e.border.color,"border.color");t&&r.push(t)}if(e.border?.style!==void 0&&(typeof e.border.style!="string"||e.border.style!=="solid"&&e.border.style!=="dashed")&&r.push({field:"border.style",value:e.border.style,message:'must be either "solid" or "dashed"'}),e.logo&&((!e.logo.src||typeof e.logo.src!="string")&&r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"}),e.logo.scale!==void 0)){let t=x(e.logo.scale,"logo.scale",.1,.3,!1);t&&r.push(t)}if(r.length>0)throw new O(r)}function oe(e){let r=[];if(e.margin!==void 0){let t=x(e.margin,"margin",0,null,!0);t&&r.push(t)}if(e.darkChar!==void 0&&typeof e.darkChar!="string"&&r.push({field:"darkChar",value:e.darkChar,message:"must be a string"}),e.lightChar!==void 0&&typeof e.lightChar!="string"&&r.push({field:"lightChar",value:e.lightChar,message:"must be a string"}),r.length>0)throw new O(r)}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"}},T={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function se(e){if(!e){let{logo:t,...o}=p;return o}return ne(e),{size:e.size??p.size,margin:e.margin??p.margin,backgroundColor:e.backgroundColor??p.backgroundColor,eyes:{shape:e.eyes?.shape??p.eyes.shape,color:e.eyes?.color??p.eyes.color},pupils:{color:e.pupils?.color??p.pupils.color},dots:{shape:e.dots?.shape??p.dots.shape,color:e.dots?.color??p.dots.color,scale:e.dots?.scale??p.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??p.logo.scale}:void 0,border:{shape:e.border?.shape??p.border.shape,width:e.border?.width??p.border.width,color:e.border?.color??p.border.color,style:e.border?.style??p.border.style},output:e.output??p.output}}function ae(e){return e?(oe(e),{margin:e.margin??T.margin,darkChar:e.darkChar??T.darkChar,lightChar:e.lightChar??T.lightChar}):{...T}}function ie(e){return/^\d+$/.test(e)?1:[...e].every(r=>S.includes(r))?2:4}function _e(e){let r=[];for(let t=0;t<e.length;t+=3){let o=e.substring(t,Math.min(t+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--)r.push(n>>a&1)}return r}function Qe(e){let r=[];for(let t=0;t<e.length;t+=2)if(t+1<e.length){let o=S.indexOf(e[t])*45+S.indexOf(e[t+1]);for(let n=10;n>=0;n--)r.push(o>>n&1)}else{let o=S.indexOf(e[t]);for(let n=5;n>=0;n--)r.push(o>>n&1)}return r}function Ge(e){let r=[],t=new TextEncoder().encode(e);for(let o of t)for(let n=7;n>=0;n--)r.push(o>>n&1);return r}function Ue(e,r,t,o){let n=[];for(let a=3;a>=0;a--)n.push(r>>a&1);let s=A(r,o);for(let a=s-1;a>=0;a--)n.push(t>>a&1);return[...n,...e]}function We(e){let r=[];for(let t=0;t<e.length;t+=8){let o=0;for(let n=0;n<8&&t+n<e.length;n++)o=o<<1|e[t+n];t+8>e.length&&(o<<=8-e.length%8),r.push(o)}return r}function je(e,r){let t=[...e],o=[236,17],n=0;for(;t.length<r;)t.push(o[n]),n=1-n;return t}function ce(e,r,t){let o=ie(e),n,s;o===1?(n=_e(e),s=e.length):o===2?(n=Qe(e),s=e.length):(n=Ge(e),s=new TextEncoder().encode(e).length);let a=Ue(n,o,s,r),i=Math.min(4,t*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let c=We(a);return je(c,t)}function k(e,r){let t=ie(e),o=t===4?new TextEncoder().encode(e).length:e.length;for(let c=1;c<=10;c++){let u=A(t,c),l=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===2?Math.floor(o/2)*11+o%2*6:o*8,m=4+u+l;if(Math.ceil(m/8)<=r[c-1])return c}let n=A(t,10),s=t===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):t===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: ${r[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ue(e,r){if(r)try{if(k(e,y.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 t=["H","Q","M","L"];for(let o of t)try{if(k(e,y[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 w=new Array(256),Q=new Array(256);function He(){let e=1;for(let r=0;r<255;r++)w[r]=e,Q[e]=r,e<<=1,e&256&&(e^=285);for(let r=255;r<512;r++)w[r]=w[r-255]}He();function fe(e,r){return e===0||r===0?0:w[Q[e]+Q[r]]}function Ye(e){let r=[1];for(let t=0;t<e;t++){let o=r.length+1,n=new Array(o).fill(0);for(let s=0;s<r.length;s++)n[s]^=r[s],n[s+1]^=fe(r[s],w[t]);r=n}return r}function le(e,r){let t=Ye(r),o=[...e,...new Array(r).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<t.length;a++)o[n+a]^=fe(t[a],s)}return o.slice(e.length)}function me(e,r,t){let o=[],n=[],[s,a,i,c]=t,u=0;for(let l=0;l<s;l++){let m=e.slice(u,u+a);o.push(m);let f=le(m,r);n.push(f),u+=a}for(let l=0;l<i;l++){let m=e.slice(u,u+c);o.push(m);let f=le(m,r);n.push(f),u+=c}return{dataBlocks:o,ecBlocks:n}}function de(e,r){let t=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&t.push(a[s]);let n=Math.max(...r.map(s=>s.length));for(let s=0;s<n;s++)for(let a of r)s<a.length&&t.push(a[s]);return t}function he(e){let r=R(e);return Array.from({length:r},()=>Array(r).fill(!1))}function ge(e){let r=R(e),t=Array.from({length:r},()=>Array(r).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[n][r-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)t[r-8+n][s]=!0;for(let n=8;n<r-8;n++)t[6][n]=!0,t[n][6]=!0;t[4*e+9][8]=!0;for(let n=0;n<6;n++)t[n][8]=!0;t[7][8]=!0,t[8][8]=!0;for(let n=r-8;n<r;n++)t[n][8]=!0;for(let n=0;n<9;n++)t[8][n]=!0;for(let n=r-8;n<r;n++)t[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9))for(let i=-2;i<=2;i++)for(let c=-2;c<=2;c++)t[n+i][s+c]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=r-11;s<r-8;s++)t[n][s]=!0;for(let n=r-11;n<r-8;n++)for(let s=0;s<6;s++)t[n][s]=!0}return t}function G(e,r,t){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=r+o,a=t+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),c=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||c}}function Xe(e,r,t){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[r+o][t+n]=s||a}}function be(e){let r=e.length;for(let t=8;t<r-8;t++)e[6][t]=t%2===0,e[t][6]=t%2===0}function pe(e){G(e,0,0),G(e,0,e.length-7),G(e,e.length-7,0)}function $e(e,r){let t=e.length,o=P[r-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9||Xe(e,n,s)}function Ce(e,r){e[4*r+9][8]=!0}function Me(e,r,t){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 c=0;c<2;c++)if(!r[a][i-c]){let u=n<t.length?t[n]:!1;e[a][i-c]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function U(e,r,t){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(r[n][s])continue;let a=!1;switch(t){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 Ze(e){let r=e.length,t=0;for(let a=0;a<r;a++){let i=e[a][0],c=e[0][a],u=1,l=1;for(let m=1;m<r;m++)e[a][m]===i?u++:(u>=5&&(t+=3+(u-5)),i=e[a][m],u=1),e[m][a]===c?l++:(l>=5&&(t+=3+(l-5)),c=e[m][a],l=1);u>=5&&(t+=3+(u-5)),l>=5&&(t+=3+(l-5))}for(let a=0;a<r-1;a++)for(let i=0;i<r-1;i++){let c=e[a][i];e[a][i+1]===c&&e[a+1][i]===c&&e[a+1][i+1]===c&&(t+=3)}for(let a=0;a<r;a++){let i=0,c=0;for(let u=0;u<r;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(t+=40),c=c<<1&2047|(e[u][a]?1:0),u>=10&&(c===1488||c===93)&&(t+=40)}let o=0,n=r*r;for(let a=0;a<r;a++)for(let i=0;i<r;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return t+=s*10,t}function ye(e,r,t,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);U(i,r,a),o(i,t,a);let c=Ze(i);c<s&&(s=c,n=a)}return n}function W(e,r,t){let o=e.length,n=N[r]<<3|t,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 c=(a>>14-i&1)===1;i<=5?e[8][i]=c:i===6?e[8][7]=c:i===7?e[8][8]=c:i===8?e[7][8]=c:e[5-(i-9)][8]=c,i<=6?e[o-1-i][8]=c:e[8][o-8+(i-7)]=c}}function xe(e,r){if(r<7)return;let t=e.length,o=Z[r-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=t-11+n%3;e[a][i]=s;let c=t-11+n%3,u=Math.floor(n/3);e[c][u]=s}}function Se(e,r){return N[e]<<3|r}function Re(e,r,t,o,n){let s=he(e),a=ge(e);pe(s),be(s),$e(s,e),Ce(s,e),Me(s,a,t);let i=n?s.map(u=>[...u]):void 0,c=o??ye(s,a,r,W);return U(s,a,c),W(s,r,c),xe(s,e),{matrix:s,mask:c,formatInfo:n?Se(r,c):void 0,unmaskedMatrix:i}}function j(e,r,t){return e<7&&r<7||e<7&&r>=t-7||e>=t-7&&r<7}function Ie(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ee(e,r){let o=Math.max(.1,Math.min(.3,r));return e*o}function Ke(e,r,t,o,n,s,a){let i=I[t]||I.square,c=i.renderSVG(e,r,7*a,o),u=i.renderSVG(e+a,r+a,5*a,s),l=i.renderSVG(e+2*a,r+2*a,3*a,n);return c+u+l}function Je(e,r,t,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 d=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(d)try{i=decodeURIComponent(d[1])}catch{return""}}let c=i.match(/viewBox=["']([^"']+)["']/),u=c?c[1]:"0 0 100 100",l=i.match(/<svg([^>]*)>/i),m="";if(l){let d=l[1].match(/xmlns[^=]*=["'][^"']*["']/gi);d&&(m=" "+d.join(" "))}let f=i.replace(/<\?xml[^>]*>|<svg[^>]*>|<\/svg>/gi,"");return`<g transform="translate(${r-n}, ${t-n})">
21
+ <svg width="${o}" height="${o}" viewBox="${u}"${m}>
22
+ ${f}
23
23
  </svg>
24
- </g>`}else return`<image x="${r-n}" y="${t-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function et(e,r,t,o,n){let s=e.matrixSize,a="",i=E[t]||E.classic;if(t==="classic"){a=`<path fill="${o}" d="`;for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!j(c,u,s)){let l=u*r,d=c*r,f=n*r,m=(1-n)*r/2,h=l+m,g=d+m;a+=`M${h},${g}h${f}v${f}h${-f}z`}return a+='"/>',a}for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!j(c,u,s)){let l=u*r,d=c*r,f=n*r,m=(1-n)*r/2,h=l+m,g=d+m,b={qrcode:e.modules,qrSize:s,row:c,col:u};a+=i.renderSVG(h,g,f,o,b)}return a}function Oe(e,r){let{size:t,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=r,c=t/e.matrixSize,u=r.border.shape==="none"?0:r.border.width,l=t+2*o+2*u,d=o+u,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" width="${l}" height="${l}">`;if(f+=`<rect width="${l}" height="${l}" fill="${n}"/>`,r.border.shape!=="none"&&u>0){let $=L[r.border.shape];if($){let C={borderWidth:u,borderStyle:r.border.style};f+=$.renderSVG(0,0,l,r.border.color,C)}}r.border.shape!=="none"&&u>0&&(f+=`<rect x="${d}" y="${d}" width="${t}" height="${t}" fill="${n}"/>`),f+=`<g transform="translate(${d}, ${d})">`;let m=Ie(e.matrixSize),h="";for(let $ of m)h+=Ke($.x*c,$.y*c,s.shape,s.color,a.color,n,c);let g=et(e,c,i.shape,i.color,i.scale);f+=h+g+"</g>";let b="";if(r.logo){let $=Ee(e.matrixSize,r.logo.scale)*c,C=l/2;b=Je(r.logo.src,C,C,$)}return f+=b+"</svg>",f}function ve(e,r){let{margin:t,lightChar:o,darkChar:n}=r,s="",a=e.matrixSize+t*2;for(let i=0;i<t;i++)s+=o.repeat(a)+`
24
+ </g>`}else return`<image x="${r-n}" y="${t-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function et(e,r,t,o,n){let s=e.matrixSize,a="",i=E[t]||E.classic;if(t==="classic"){a=`<path fill="${o}" d="`;for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!j(c,u,s)){let l=u*r,m=c*r,f=n*r,d=(1-n)*r/2,h=l+d,g=m+d;a+=`M${h},${g}h${f}v${f}h${-f}z`}return a+='"/>',a}for(let c=0;c<s;c++)for(let u=0;u<s;u++)if(e.modules[c][u]&&!j(c,u,s)){let l=u*r,m=c*r,f=n*r,d=(1-n)*r/2,h=l+d,g=m+d,b={qrcode:e.modules,qrSize:s,row:c,col:u};a+=i.renderSVG(h,g,f,o,b)}return a}function ve(e,r){let{size:t,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=r,c=t/e.matrixSize,u=r.border.shape==="none"?0:r.border.width,l=t+2*o+2*u,m=o+u,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${l} ${l}" width="${l}" height="${l}">`;if(f+=`<rect width="${l}" height="${l}" fill="${n}"/>`,r.border.shape!=="none"&&u>0){let $=L[r.border.shape];if($){let C={borderWidth:u,borderStyle:r.border.style};f+=$.renderSVG(0,0,l,r.border.color,C)}}r.border.shape!=="none"&&u>0&&(f+=`<rect x="${m}" y="${m}" width="${t}" height="${t}" fill="${n}"/>`),f+=`<g transform="translate(${m}, ${m})">`;let d=Ie(e.matrixSize),h="";for(let $ of d)h+=Ke($.x*c,$.y*c,s.shape,s.color,a.color,n,c);let g=et(e,c,i.shape,i.color,i.scale);f+=h+g+"</g>";let b="";if(r.logo){let $=Ee(e.matrixSize,r.logo.scale)*c,C=l/2;b=Je(r.logo.src,C,C,$)}return f+=b+"</svg>",f}function Oe(e,r){let{margin:t,lightChar:o,darkChar:n}=r,s="",a=e.matrixSize+t*2;for(let i=0;i<t;i++)s+=o.repeat(a)+`
25
25
  `;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(t);for(let c=0;c<e.matrixSize;c++)s+=e.modules[i][c]?n:o;s+=o.repeat(t)+`
26
26
  `}for(let i=0;i<t;i++)s+=o.repeat(a)+`
27
- `;return s}var D=null,we=!1;async function tt(){if(D)return D;if(we)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");we=!0;try{return D=(await import("@resvg/resvg-js")).Resvg,D}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Pe(e,r){let{output:t,size:o,margin:n,border:s}=r,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,c=await tt(),d=new c(e,{fitTo:{mode:"width",value:i}}).render().asPng(),f=Buffer.from(d);return t.type==="dataURL"?`data:image/png;base64,${f.toString("base64")}`:f}async function Ae(e,r){let{format:t,type:o}=r.output;return t==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Pe(e,r)}function H(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 at(e.email,e.subject,e.body);case"sms":return it(e.phone,e.message);case"phone":return ct(e.phone)}}function rt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function nt(e){let r=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&r.push(`TEL:${e.phone}`),e.email&&r.push(`EMAIL:${e.email}`),e.organization&&r.push(`ORG:${e.organization}`),e.url&&r.push(`URL:${e.url}`),e.title&&r.push(`TITLE:${e.title}`),e.note&&r.push(`NOTE:${e.note}`),e.address){let{street:t,city:o,state:n,zip:s,country:a}=e.address,i=["","",t||"",o||"",n||"",s||"",a||""];r.push(`ADR:${i.join(";")}`)}return r.push("END:VCARD"),r.join(`
27
+ `;return s}var D=null,we=!1;async function tt(){if(D)return D;if(we)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");we=!0;try{return D=(await import("@resvg/resvg-js")).Resvg,D}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Pe(e,r){let{output:t,size:o,margin:n,border:s}=r,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,c=await tt(),m=new c(e,{fitTo:{mode:"width",value:i}}).render().asPng(),f=Buffer.from(m);return t.type==="dataURL"?`data:image/png;base64,${f.toString("base64")}`:f}async function Ae(e,r){let{format:t,type:o}=r.output;return t==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Pe(e,r)}function H(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 at(e.email,e.subject,e.body);case"sms":return it(e.phone,e.message);case"phone":return ct(e.phone)}}function rt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function nt(e){let r=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&r.push(`TEL:${e.phone}`),e.email&&r.push(`EMAIL:${e.email}`),e.organization&&r.push(`ORG:${e.organization}`),e.url&&r.push(`URL:${e.url}`),e.title&&r.push(`TITLE:${e.title}`),e.note&&r.push(`NOTE:${e.note}`),e.address){let{street:t,city:o,state:n,zip:s,country:a}=e.address,i=["","",t||"",o||"",n||"",s||"",a||""];r.push(`ADR:${i.join(";")}`)}return r.push("END:VCARD"),r.join(`
28
28
  `)}function ot(e){let r=e.encryption||"WPA",t=e.hidden?"H:true;":"",o=Le(e.ssid),n=Le(e.password);return`WIFI:T:${r};S:${o};P:${n};${t};`}function Le(e){return e.replace(/([\\;,":])/g,"\\$1")}function st(e){let r=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",t=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${r(e.startDate)}`,`DTEND:${r(e.endDate)}`];return e.location&&t.push(`LOCATION:${e.location}`),e.description&&t.push(`DESCRIPTION:${e.description}`),t.push("END:VEVENT","END:VCALENDAR"),t.join(`
29
- `)}function at(e,r,t){let o=`mailto:${e}`,n=[];return r&&n.push(`subject=${encodeURIComponent(r)}`),t&&n.push(`body=${encodeURIComponent(t)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function it(e,r){return r?`sms:${e}:${r}`:`sms:${e}`}function ct(e){return`tel:${e}`}function ut(e,r){let t=[];for(let n of e)for(let s=7;s>=0;s--)t.push((n>>s&1)===1);let o=K[r-1];for(let n=0;n<o;n++)t.push(!1);return t}function Te(e,r){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let t=ue(e,r),o=y[t],n=k(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 ${t}: ~${y[t][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=ce(e,n,o[n-1]),a=Y[t][n-1],i=X[t][n-1],{dataBlocks:c,ecBlocks:u}=de(s,a,i),l=me(c,u),d=ut(l,n),{matrix:f,mask:m}=Re(n,t,d);return{version:n,matrixSize:R(n),modules:f,mask:m,errorCorrectionLevel:t}}async function lt(e,r){let t=H(e),o=se(r),n=Te(t,!!o.logo),s=Oe(n,o);return await Ae(s,o)}function ft(e,r){let t=H(e),o=ae(r),n=Te(t,!1);return ve(n,o)}export{te as BorderShape,re as BorderStyle,ee as DotShape,J as EyeFrameShape,v as QRValidationError,lt as genQrImage,ft as genQrText};
29
+ `)}function at(e,r,t){let o=`mailto:${e}`,n=[];return r&&n.push(`subject=${encodeURIComponent(r)}`),t&&n.push(`body=${encodeURIComponent(t)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function it(e,r){return r?`sms:${e}:${r}`:`sms:${e}`}function ct(e){return`tel:${e}`}function ut(e,r){let t=[];for(let n of e)for(let s=7;s>=0;s--)t.push((n>>s&1)===1);let o=K[r-1];for(let n=0;n<o;n++)t.push(!1);return t}function Te(e,r){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let t=ue(e,r),o=y[t],n=k(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 ${t}: ~${y[t][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=ce(e,n,o[n-1]),a=Y[t][n-1],i=X[t][n-1],{dataBlocks:c,ecBlocks:u}=me(s,a,i),l=de(c,u),m=ut(l,n),{matrix:f,mask:d}=Re(n,t,m);return{version:n,matrixSize:R(n),modules:f,mask:d,errorCorrectionLevel:t}}async function lt(e,r){let t=H(e),o=se(r),n=Te(t,!!o.logo),s=ve(n,o);return await Ae(s,o)}function ft(e,r){let t=H(e),o=ae(r),n=Te(t,!1);return Oe(n,o)}export{te as BorderShape,re as BorderStyle,ee as DotShape,J as EyeFrameShape,O as QRValidationError,lt as genQrImage,ft as genQrText};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tapple.io/qr-code-generator",
3
- "version": "0.9.2",
3
+ "version": "0.9.3",
4
4
  "description": "Lightweight QR code generator with ESM and CommonJS support",
5
5
  "files": [
6
6
  "dist",