@tapple.io/qr-code-generator 0.9.6 → 0.9.8
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 +10 -10
- package/dist/node.cjs +21 -21
- package/dist/node.mjs +22 -22
- package/package.json +1 -1
package/dist/browser.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _={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]},C={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]},j={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 $%*+-./:",Te={1:[10,12,14],2:[9,11,13],4:[8,16,16]},A={L:1,M:0,Q:3,H:2},I=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],W=[31892,34236,39577,42195],z=[0,7,7,7,7,7,0,0,0,0];function E(e){return e*4+17}function O(e,t){let r=t<10?0:t<27?1:2;return Te[e][r]}var G=(r=>(r.SQUARE="square",r.SQUIRCLE="squircle",r))(G||{}),q=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(q||{}),H=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(H||{}),Y=(r=>(r.SOLID="solid",r.DASHED="dashed",r))(Y||{});var Pe=.09,Ve={EYE_FRAME:.90909};function Be(e,t){let n=t*3,s=t*2,a=n+s,i=Math.max(1,Math.round(e/a)),l=e/i,c=l*(3/5),u=l*(2/5),f=u/2;return{dashArray:`${c} ${u}`,offset:f}}function Z(e,t){let r=t*3,o=t*2,n=r+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,l=a*.4,c=i/2;return{dashArray:`${i} ${l}`,offset:c}}var w={square:{renderSVG(e,t,r,o){return`<rect x="${e}" y="${t}" width="${r}" height="${r}" fill="${o}"/>`}},squircle:{renderSVG(e,t,r,o){let n=r/2,s=n*Ve.EYE_FRAME,a=e+n,i=t+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}"/>`}
|
|
5
|
+
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`}}},v={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`}}},D={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,m=r-s,{dashArray:g,offset:h}=Be(m,s);return`<rect x="${e+d}" y="${t+d}" width="${m}" height="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${g}" stroke-dashoffset="${-h}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,c=t+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,c=t+i,u=i-s/2,f=r*Pe,d=Math.max(0,f-s/2),m=u-d,g=`M${l},${c-u}
|
|
6
6
|
H${l+m}
|
|
7
7
|
A${d},${d} 0 0 1 ${l+u},${c-m}
|
|
8
8
|
V${c+m}
|
|
@@ -11,19 +11,19 @@ var X={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,
|
|
|
11
11
|
A${d},${d} 0 0 1 ${l-u},${c+m}
|
|
12
12
|
V${c-m}
|
|
13
13
|
A${d},${d} 0 0 1 ${l-m},${c-u}
|
|
14
|
-
Z`;if(a==="dashed"){let h=2*m,
|
|
14
|
+
Z`;if(a==="dashed"){let h=2*m,y=.5*Math.PI*d,b=4*h+4*y,{dashArray:x,offset:Le}=Z(b,s);return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${x}" stroke-dashoffset="${Le}"/>`}return`<path d="${g}" fill="none" stroke="${o}" stroke-width="${s}"/>`}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,c=r/2;if(a==="dashed"){let m=c-s/2,g=2*Math.PI*m,{dashArray:h,offset:y}=Z(g,s);return`<circle cx="${i}" cy="${l}" r="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${y}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
15
|
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
16
|
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
17
|
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
-
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}
|
|
18
|
+
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}}};var $=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
19
|
`);super(`QR Code validation failed:
|
|
20
|
-
${r}`),this.name="QRValidationError",this.errors=e}};function Ge(t){let e={...t};return e.backgroundColor===""&&(e.backgroundColor=void 0),e.eyes&&(e.eyes={...e.eyes},e.eyes.shape===""&&(e.eyes.shape=void 0),e.eyes.color===""&&(e.eyes.color=void 0)),e.pupils&&(e.pupils={...e.pupils},e.pupils.color===""&&(e.pupils.color=void 0)),e.dots&&(e.dots={...e.dots},e.dots.shape===""&&(e.dots.shape=void 0),e.dots.color===""&&(e.dots.color=void 0)),e.border&&(e.border={...e.border},e.border.shape===""&&(e.border.shape=void 0),e.border.color===""&&(e.border.color=void 0),e.border.style===""&&(e.border.style=void 0)),e}function We(t){let e={...t};return e.darkChar===""&&(e.darkChar=void 0),e.lightChar===""&&(e.lightChar=void 0),e}function v(t,e,r,o,n=!1){return typeof t!="number"||!isFinite(t)?{field:e,value:t,message:"must be a finite number"}:n&&!Number.isInteger(t)?{field:e,value:t,message:"must be an integer"}:t<r?{field:e,value:t,message:`must be at least ${r}`}:o!==null&&t>o?{field:e,value:t,message:`must be at most ${o}`}:null}function E(t,e){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};let r=t.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/,s=r.match(n);if(s){let[,c,u,f,d]=s,m=parseInt(c,10),g=parseInt(u,10),h=parseInt(f,10);if(m<0||m>255||g<0||g>255||h<0||h>255)return{field:e,value:t,message:"RGB values must be between 0-255"};if(d!==void 0){let p=parseFloat(d);if(isNaN(p)||p<0||p>1)return{field:e,value:t,message:"RGBA alpha value must be between 0-1"}}return null}let a=/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/,i=r.match(a);if(i){let[,c,u,f,d]=i,m=parseInt(c,10),g=parseInt(u,10),h=parseInt(f,10);if(m<0||m>360)return{field:e,value:t,message:"HSL hue must be between 0-360"};if(g<0||g>100||h<0||h>100)return{field:e,value:t,message:"HSL saturation and lightness must be between 0-100%"};if(d!==void 0){let p=parseFloat(d);if(isNaN(p)||p<0||p>1)return{field:e,value:t,message:"HSLA alpha value must be between 0-1"}}return null}return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"].includes(r.toLowerCase())?null:{field:e,value:t,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function F(t,e,r){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};if(!(t in r)){let o=Object.keys(r).join(", ");return{field:e,value:t,message:`must be one of: ${o}`}}return null}function je(t,e){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=t.trim().startsWith("<svg");if(!r.test(t)&&!o)return{field:e,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(t.startsWith("data:")){let n=t.split(",");if(n.length!==2)return{field:e,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!He(s))return{field:e,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!t.includes("</svg>")?{field:e,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function He(t){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(t)&&t.length%4===0}catch{return!1}}function se(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function Q(t){return/^[\d\s\-+()]+$/.test(t)&&t.replace(/\D/g,"").length>=7}function ae(t){try{return new URL(t.startsWith("http")?t:`https://${t}`),!0}catch{return!1}}function ie(t){let e=Ge(t),r=[];if(e.size!==void 0){let o=v(e.size,"size",21,null,!0);o&&r.push(o)}if(e.margin!==void 0){let o=v(e.margin,"margin",0,null,!0);o&&r.push(o)}if(e.backgroundColor!==void 0){let o=E(e.backgroundColor,"backgroundColor");o&&r.push(o)}if(e.eyes?.shape!==void 0){let o=F(e.eyes.shape,"eyes.shape",S);o&&r.push(o)}if(e.eyes?.color!==void 0){let o=E(e.eyes.color,"eyes.color");o&&r.push(o)}if(e.pupils?.color!==void 0){let o=E(e.pupils.color,"pupils.color");o&&r.push(o)}if(e.dots?.shape!==void 0){let o=F(e.dots.shape,"dots.shape",w);o&&r.push(o)}if(e.dots?.color!==void 0){let o=E(e.dots.color,"dots.color");o&&r.push(o)}if(e.dots?.scale!==void 0){let o=v(e.dots.scale,"dots.scale",.75,1.25,!1);o&&r.push(o)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let o=F(e.border.shape,"border.shape",L);o&&r.push(o)}if(e.border?.width!==void 0){let o=v(e.border.width,"border.width",0,null,!0);o&&r.push(o)}if(e.border?.color!==void 0){let o=E(e.border.color,"border.color");o&&r.push(o)}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){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let o=je(e.logo.src,"logo.src");o&&r.push(o)}if(e.logo.scale!==void 0){let o=v(e.logo.scale,"logo.scale",.1,.3,!1);o&&r.push(o)}}if(r.length>0)throw new C(r);return e}function le(t){let e=We(t),r=[];if(e.margin!==void 0){let o=v(e.margin,"margin",0,null,!0);o&&r.push(o)}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 C(r);return e}function U(t){let e=[];if(typeof t=="string"){if(t||e.push({field:"input",value:t,message:"string input cannot be empty"}),e.length>0)throw new C(e);return}if(!t||typeof t!="object"||!("type"in t))throw e.push({field:"input",value:t,message:"must be a string or structured content object with a type property"}),new C(e);let r=t;switch(r.type){case"wifi":{Ye(t.data,e);break}case"vcard":{Xe(t.data,e);break}case"calendar":{Ze(t.data,e);break}case"email":{Ke(t,e);break}case"sms":{Je(t,e);break}case"phone":{et(t,e);break}case"url":{tt(t,e);break}default:e.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(e.length>0)throw new C(e)}function Ye(t,e){if(!t||typeof t!="object"){e.push({field:"wifi.data",value:t,message:"must be an object"});return}let r=t;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&e.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&e.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||e.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&e.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function Xe(t,e){if(!t||typeof t!="object"){e.push({field:"vcard.data",value:t,message:"must be an object"});return}let r=t;(!r.name||typeof r.name!="string"||!r.name.trim())&&e.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!se(r.email))&&e.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!Q(r.phone))&&e.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ae(r.url))&&e.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&e.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Ze(t,e){if(!t||typeof t!="object"){e.push({field:"calendar.data",value:t,message:"must be an object"});return}let r=t;(!r.title||typeof r.title!="string"||!r.title.trim())&&e.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=oe(r.startDate);if(o||e.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=oe(r.endDate);n?o&&n<o&&e.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):e.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Ke(t,e){let r=t;(!r.email||typeof r.email!="string"||!se(r.email))&&e.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&e.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&e.push({field:"email.body",value:r.body,message:"must be a string"})}function Je(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&e.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&e.push({field:"sms.message",value:r.message,message:"must be a string"})}function et(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&e.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function tt(t,e){let r=t;(!r.url||typeof r.url!="string"||!ae(r.url))&&e.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}function oe(t){if(t instanceof Date)return isNaN(t.getTime())?null:t;if(typeof t=="string"){let e=new Date(t);return isNaN(e.getTime())?null:e}return null}var b={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"}},A={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ce(t){if(!t){let{logo:o,...n}=b;return n}let e=ie(t);return{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function ue(t){if(!t)return{...A};let e=le(t);return{margin:e.margin??A.margin,darkChar:e.darkChar??A.darkChar,lightChar:e.lightChar??A.lightChar}}function de(t){return/^\d+$/.test(t)?1:[...t].every(e=>R.includes(e))?2:4}function rt(t){let e=[];for(let r=0;r<t.length;r+=3){let o=t.substring(r,Math.min(r+3,t.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)e.push(n>>a&1)}return e}function nt(t){let e=[];for(let r=0;r<t.length;r+=2)if(r+1<t.length){let o=R.indexOf(t[r])*45+R.indexOf(t[r+1]);for(let n=10;n>=0;n--)e.push(o>>n&1)}else{let o=R.indexOf(t[r]);for(let n=5;n>=0;n--)e.push(o>>n&1)}return e}function ot(t){let e=[],r=new TextEncoder().encode(t);for(let o of r)for(let n=7;n>=0;n--)e.push(o>>n&1);return e}function st(t,e,r,o){let n=[];for(let a=3;a>=0;a--)n.push(e>>a&1);let s=P(e,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...t]}function at(t){let e=[];for(let r=0;r<t.length;r+=8){let o=0;for(let n=0;n<8&&r+n<t.length;n++)o=o<<1|t[r+n];r+8>t.length&&(o<<=8-t.length%8),e.push(o)}return e}function it(t,e){let r=[...t],o=[236,17],n=0;for(;r.length<e;)r.push(o[n]),n=1-n;return r}function fe(t,e,r){let o=de(t),n,s;o===1?(n=rt(t),s=t.length):o===2?(n=nt(t),s=t.length):(n=ot(t),s=new TextEncoder().encode(t).length);let a=st(n,o,s,e),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=at(a);return it(l,r)}function D(t,e){let r=de(t),o=r===4?new TextEncoder().encode(t).length:t.length;for(let l=1;l<=10;l++){let c=P(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=e[l-1])return l}let n=P(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${e[9]} bytes. Current data length: ${t.length} characters (${o} bytes encoded).`)}function me(t,e){if(e)try{if(D(t,I.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${t.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(D(t,I[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${t.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var k=new Array(256),_=new Array(256);function lt(){let t=1;for(let e=0;e<255;e++)k[e]=t,_[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)k[e]=k[e-255]}lt();function he(t,e){return t===0||e===0?0:k[_[t]+_[e]]}function ct(t){let e=[1];for(let r=0;r<t;r++){let o=e.length+1,n=new Array(o).fill(0);for(let s=0;s<e.length;s++)n[s]^=e[s],n[s+1]^=he(e[s],k[r]);e=n}return e}function ge(t,e){let r=ct(e),o=[...t,...new Array(e).fill(0)];for(let n=0;n<t.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=he(r[a],s)}return o.slice(t.length)}function pe(t,e,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=t.slice(c,c+a);o.push(f);let d=ge(f,e);n.push(d),c+=a}for(let u=0;u<i;u++){let f=t.slice(c,c+l);o.push(f);let d=ge(f,e);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function be(t,e){let r=[],o=Math.max(...t.map(s=>s.length));for(let s=0;s<o;s++)for(let a of t)s<a.length&&r.push(a[s]);let n=Math.max(...e.map(s=>s.length));for(let s=0;s<n;s++)for(let a of e)s<a.length&&r.push(a[s]);return r}function ye(t){let e=M(t);return Array.from({length:e},()=>Array(e).fill(!1))}function xe(t){let e=M(t),r=Array.from({length:e},()=>Array(e).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][e-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[e-8+n][s]=!0;for(let n=8;n<e-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*t+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=e-8;n<e;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=e-8;n<e;n++)r[8][n]=!0;let o=O[t-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>e-9||n>e-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(t>=7){for(let n=0;n<6;n++)for(let s=e-11;s<e-8;s++)r[n][s]=!0;for(let n=e-11;n<e-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function G(t,e,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=e+o,a=r+n;if(s<0||s>=t.length||a<0||a>=t.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;t[s][a]=i||l}}function ut(t,e,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;t[e+o][r+n]=s||a}}function $e(t){let e=t.length;for(let r=8;r<e-8;r++)t[6][r]=r%2===0,t[r][6]=r%2===0}function Ce(t){G(t,0,0),G(t,0,t.length-7),G(t,t.length-7,0)}function Ie(t,e){let r=t.length,o=O[e-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||ut(t,n,s)}function ve(t,e){t[4*e+9][8]=!0}function Re(t,e,r){let o=t.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!e[a][i-l]){let c=n<r.length?r[n]:!1;t[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function W(t,e,r){let o=t.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(e[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(t[n][s]=!t[n][s])}}function dt(t){let e=t.length,r=0;for(let a=0;a<e;a++){let i=t[a][0],l=t[0][a],c=1,u=1;for(let f=1;f<e;f++)t[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=t[a][f],c=1),t[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=t[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<e-1;a++)for(let i=0;i<e-1;i++){let l=t[a][i];t[a][i+1]===l&&t[a+1][i]===l&&t[a+1][i+1]===l&&(r+=3)}for(let a=0;a<e;a++){let i=0,l=0;for(let c=0;c<e;c++)i=i<<1&2047|(t[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(t[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=e*e;for(let a=0;a<e;a++)for(let i=0;i<e;i++)t[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Me(t,e,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=t.map(c=>[...c]);W(i,e,a),o(i,r,a);let l=dt(i);l<s&&(s=l,n=a)}return n}function j(t,e,r){let o=t.length,n=B[e]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?t[8][i]=l:i===6?t[8][7]=l:i===7?t[8][8]=l:i===8?t[7][8]=l:t[5-(i-9)][8]=l,i<=6?t[o-1-i][8]=l:t[8][o-8+(i-7)]=l}}function Se(t,e){if(e<7)return;let r=t.length,o=K[e-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;t[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);t[l][c]=s}}function we(t,e){return B[t]<<3|e}function Ee(t,e,r,o,n){let s=ye(t),a=xe(t);Ce(s),$e(s),Ie(s,t),ve(s,t),Re(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??Me(s,a,e,j);return W(s,a,l),j(s,e,l),Se(s,t),{matrix:s,mask:l,formatInfo:n?we(e,l):void 0,unmaskedMatrix:i}}function H(t,e,r){return t<7&&e<7||t<7&&e>=r-7||t>=r-7&&e<7}function ke(t){return[{x:0,y:0},{x:t-7,y:0},{x:0,y:t-7}]}function Oe(t,e){let o=Math.max(.1,Math.min(.3,e));return t*o}function ft(t,e,r,o,n,s,a){let i=S[r]||S.square,l=i.renderSVG(t,e,7*a,o),c=i.renderSVG(t+a,e+a,5*a,s),u=i.renderSVG(t+2*a,e+2*a,3*a,n);return l+c+u}function mt(t,e,r,o){let n=o/2,s=t.trim();if(t.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=t;if(t.includes("data:image/svg")){let m=t.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(t.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${e-n}, ${r-n})">
|
|
20
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function Ne(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function L(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=L(t[r]));return t}function K(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Fe(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return Qe(e,t);case"enum":return ee(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Ue(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"?{field:t,value:e,message:'must be either "solid" or "dashed"'}:null;default:return null}}function J(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Ne(e,o),a=K(s,o,n);a&&r.push(a)}return r}function Fe(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function Qe(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,i,l,c,u]=o,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>255||d<0||d>255||m<0||m>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,i,l,c,u]=n,f=parseInt(i,10),d=parseInt(l,10),m=parseInt(c,10);if(f<0||f>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(d<0||d>100||m<0||m>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let g=parseFloat(u);if(isNaN(g)||g<0||g>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function ee(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Ue(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function te(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function T(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function re(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function X(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ne(e){let t=L(e),o=J(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.shape":{type:"enum",enumObj:w,optional:!0},"eyes.color":{type:"color",optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:v,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.border?.shape!==void 0&&t.border.shape!=="none"){let n=ee(t.border.shape,"border.shape",D);n&&o.push(n)}if(t.logo){let n=K(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new $(o);return t}function oe(e){let t=L(e),o=J(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new $(o);return t}function P(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new $(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new $(t);let r=e;switch(r.type){case"wifi":_e(e.data,t);break;case"vcard":je(e.data,t);break;case"calendar":We(e.data,t);break;case"email":ze(e,t);break;case"sms":Ge(e,t);break;case"phone":qe(e,t);break;case"url":He(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new $(t)}function _e(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function je(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!te(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!T(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!re(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function We(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=X(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=X(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function ze(e,t){let r=e;(!r.email||typeof r.email!="string"||!te(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function Ge(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!T(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function qe(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!T(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function He(e,t){let r=e;(!r.url||typeof r.url!="string"||!re(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},k={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function se(e){if(!e){let{logo:o,...n}=p;return n}let t=ne(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{shape:t.eyes?.shape??p.eyes.shape,color:t.eyes?.color??p.eyes.color},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{shape:t.border?.shape??p.border.shape,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ae(e){if(!e)return{...k};let t=oe(e);return{margin:t.margin??k.margin,darkChar:t.darkChar??k.darkChar,lightChar:t.lightChar??k.lightChar}}function ie(e){return/^\d+$/.test(e)?1:[...e].every(t=>R.includes(t))?2:4}function Ye(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function Ze(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=R.indexOf(e[r])*45+R.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=R.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function Xe(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function Ke(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=O(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function Je(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function et(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function le(e,t,r){let o=ie(e),n,s;o===1?(n=Ye(e),s=e.length):o===2?(n=Ze(e),s=e.length):(n=Xe(e),s=new TextEncoder().encode(e).length);let a=Ke(n,o,s,t),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=Je(a);return et(l,r)}function M(e,t){let r=ie(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=O(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=t[l-1])return l}let n=O(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ce(e,t){if(t)try{if(M(e,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(M(e,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var S=new Array(256),V=new Array(256);function tt(){let e=1;for(let t=0;t<255;t++)S[t]=e,V[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)S[t]=S[t-255]}tt();function de(e,t){return e===0||t===0?0:S[V[e]+V[t]]}function rt(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=de(t[s],S[r]);t=n}return t}function ue(e,t){let r=rt(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=de(r[a],s)}return o.slice(e.length)}function fe(e,t,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=e.slice(c,c+a);o.push(f);let d=ue(f,t);n.push(d),c+=a}for(let u=0;u<i;u++){let f=e.slice(c,c+l);o.push(f);let d=ue(f,t);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function me(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function ge(e){let t=E(e);return Array.from({length:t},()=>Array(t).fill(!1))}function pe(e){let t=E(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=I[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function B(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function nt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function he(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function be(e){B(e,0,0),B(e,0,e.length-7),B(e,e.length-7,0)}function ye(e,t){let r=e.length,o=I[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||nt(e,n,s)}function $e(e,t){e[4*t+9][8]=!0}function xe(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let c=n<r.length?r[n]:!1;e[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function N(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function ot(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],c=1,u=1;for(let f=1;f<t;f++)e[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=e[a][f],c=1),e[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let c=0;c<t;c++)i=i<<1&2047|(e[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Ce(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(c=>[...c]);N(i,t,a),o(i,r,a);let l=ot(i);l<s&&(s=l,n=a)}return n}function F(e,t,r){let o=e.length,n=A[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function Re(e,t){if(t<7)return;let r=e.length,o=W[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function Ee(e,t){return A[e]<<3|t}function we(e,t,r,o,n){let s=ge(e),a=pe(e);be(s),he(s),ye(s,e),$e(s,e),xe(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??Ce(s,a,t,F);return N(s,a,l),F(s,t,l),Re(s,e),{matrix:s,mask:l,formatInfo:n?Ee(t,l):void 0,unmaskedMatrix:i}}function Q(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function ve(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Se(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function st(e,t,r,o,n,s,a){let i=w[r]||w.square,l=i.renderSVG(e,t,7*a,o),c=i.renderSVG(e+a,t+a,5*a,s),u=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+c+u}function at(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let m=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
21
|
<svg width="${o}" height="${o}" viewBox="${c}"${f}>
|
|
22
22
|
${d}
|
|
23
23
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${
|
|
25
|
-
`;for(let i=0;i<
|
|
24
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function it(e,t,r,o,n){let s=e.matrixSize,a="",i=v[r]||v.classic;if(r==="classic"){a=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!Q(l,c,s)){let u=c*t,f=l*t,d=n*t,m=(1-n)*t/2,g=u+m,h=f+m;a+=`M${g},${h}h${d}v${d}h${-d}z`}return a+='"/>',a}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!Q(l,c,s)){let u=c*t,f=l*t,d=n*t,m=(1-n)*t/2,g=u+m,h=f+m,y={qrcode:e.modules,qrSize:s,row:l,col:c};a+=i.renderSVG(g,h,d,o,y)}return a}function Ie(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=t,l=r/e.matrixSize,c=t.border.shape==="none"?0:t.border.width,u=r+2*o+2*c,f=o+c,d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}" width="${u}" height="${u}">`;if(d+=`<rect width="${u}" height="${u}" fill="${n}"/>`,t.border.shape!=="none"&&c>0){let b=D[t.border.shape];if(b){let x={borderWidth:c,borderStyle:t.border.style};d+=b.renderSVG(0,0,u,t.border.color,x)}}t.border.shape!=="none"&&c>0&&(d+=`<rect x="${f}" y="${f}" width="${r}" height="${r}" fill="${n}"/>`),d+=`<g transform="translate(${f}, ${f})">`;let m=ve(e.matrixSize),g="";for(let b of m)g+=st(b.x*l,b.y*l,s.shape,s.color,a.color,n,l);let h=it(e,l,i.shape,i.color,i.scale);d+=g+h+"</g>";let y="";if(t.logo){let b=Se(e.matrixSize,t.logo.scale)*l,x=u/2;y=at(t.logo.src,x,x,b)}return d+=y+"</svg>",d}function Oe(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",a=e.matrixSize+r*2;for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
25
|
+
`;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[i][l]?n:o;s+=o.repeat(r)+`
|
|
26
26
|
`}for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
27
|
-
`;return s}async function
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
27
|
+
`;return s}async function De(e,t){let{output:r,size:o,margin:n,border:s}=t,a=s.shape==="none"?0:s.width,i=o+2*n+2*a;return new Promise((l,c)=>{let u=document.createElement("canvas");u.width=i,u.height=i;let f=u.getContext("2d");if(!f){c(new Error("Failed to get canvas context"));return}let d=new Image,m=null;try{let g=new Blob([e],{type:"image/svg+xml;charset=utf-8"});m=URL.createObjectURL(g)}catch{c(new Error("Failed to create SVG blob for rasterization"));return}d.onload=()=>{if(m&&URL.revokeObjectURL(m),f.drawImage(d,0,0,i,i),r.type==="dataURL"){let g=u.toDataURL("image/png");l(g)}else u.toBlob(g=>{if(!g){c(new Error("Failed to convert PNG to blob"));return}g.arrayBuffer().then(h=>{l(new Uint8Array(h))})},"image/png")},d.onerror=()=>{m&&URL.revokeObjectURL(m),c(new Error("Failed to load SVG for rasterization"))},d.src=m})}async function ke(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await De(e,t)}function U(e){if(typeof e=="string")return e;switch(e.type){case"url":return lt(e.url);case"vcard":return ct(e.data);case"wifi":return ut(e.data);case"calendar":return dt(e.data);case"email":return ft(e.email,e.subject,e.body);case"sms":return mt(e.phone,e.message);case"phone":return gt(e.phone)}}function lt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function ct(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:a}=e.address,i=["","",r||"",o||"",n||"",s||"",a||""];t.push(`ADR:${i.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
28
|
+
`)}function ut(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=Me(e.ssid),n=Me(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function Me(e){return e.replace(/([\\;,":])/g,"\\$1")}function dt(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
29
|
+
`)}function ft(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function mt(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function gt(e){return`tel:${e}`}function pt(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=z[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function Ae(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=ce(e,t),o=C[r],n=M(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${C[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=le(e,n,o[n-1]),a=_[r][n-1],i=j[r][n-1],{dataBlocks:l,ecBlocks:c}=fe(s,a,i),u=me(l,c),f=pt(u,n),{matrix:d,mask:m}=we(n,r,f);return{version:n,matrixSize:E(n),modules:d,mask:m,errorCorrectionLevel:r}}async function ht(e,t){P(e);let r=U(e),o=se(t),n=Ae(r,!!o.logo),s=Ie(n,o);return await ke(s,o)}function bt(e,t){P(e);let r=U(e),o=ae(t),n=Ae(r,!1);return Oe(n,o)}export{H as BorderShape,Y as BorderStyle,q as DotShape,G as EyeFrameShape,$ as QRValidationError,ht as genQrImage,bt as genQrText};
|
package/dist/node.cjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var Qe=Object.create;var I=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var _e=Object.getOwnPropertyNames;var Ue=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var qe=(e,t)=>{for(var r in t)I(e,r,{get:t[r],enumerable:!0})},H=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of _e(t))!We.call(e,n)&&n!==r&&I(e,n,{get:()=>t[n],enumerable:!(o=je(t,n))||o.enumerable});return e};var ze=(e,t,r)=>(r=e!=null?Qe(Ue(e)):{},H(t||!e||!e.__esModule?I(r,"default",{value:e,enumerable:!0}):r,e)),Ge=e=>H(I({},"__esModule",{value:!0}),e);var Mt={};qe(Mt,{BorderShape:()=>N,BorderStyle:()=>B,DotShape:()=>V,EyeFrameShape:()=>P,QRValidationError:()=>y,genQrImage:()=>Ne,genQrText:()=>Be});module.exports=Ge(Mt);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]},x={L:[19,34,55,80,108,136,156,194,232,274],M:[16,28,44,64,86,108,124,154,182,216],Q:[13,22,34,48,62,76,88,110,132,154],H:[9,16,26,36,46,60,66,86,100,122]},Z={L:[[1,19,0,0],[1,34,0,0],[1,55,0,0],[1,80,0,0],[1,108,0,0],[2,68,0,0],[2,78,0,0],[2,97,0,0],[2,116,0,0],[2,68,2,69]],M:[[1,16,0,0],[1,28,0,0],[1,44,0,0],[2,32,0,0],[2,43,0,0],[4,27,0,0],[4,31,0,0],[2,38,2,39],[3,36,2,37],[4,43,1,44]],Q:[[1,13,0,0],[1,22,0,0],[2,17,0,0],[2,24,0,0],[2,15,2,16],[4,19,0,0],[2,14,4,15],[4,18,2,19],[4,16,4,17],[6,19,2,20]],H:[[1,9,0,0],[1,16,0,0],[2,13,0,0],[4,9,0,0],[2,11,2,12],[4,15,0,0],[4,13,1,14],[4,14,2,15],[4,12,4,13],[6,15,2,16]]},C="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",He={1:[10,12,14],2:[9,11,13],4:[8,16,16]},T={L:1,M:0,Q:3,H:2},O=[[],[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],K=[0,7,7,7,7,7,0,0,0,0];function R(e){return e*4+17}function D(e,t){let r=t<10?0:t<27?1:2;return He[e][r]}var P=(r=>(r.SQUARE="square",r.SQUIRCLE="squircle",r))(P||{}),V=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(V||{}),N=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(N||{}),B=(r=>(r.SOLID="solid",r.DASHED="dashed",r))(B||{});var Ye=.09,Ze={EYE_FRAME:.90909};function Xe(e,t){let n=t*3,s=t*2,a=n+s,i=Math.max(1,Math.round(e/a)),l=e/i,c=l*(3/5),u=l*(2/5),f=u/2;return{dashArray:`${c} ${u}`,offset:f}}function J(e,t){let r=t*3,o=t*2,n=r+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,l=a*.4,c=i/2;return{dashArray:`${i} ${l}`,offset:c}}var w={square:{renderSVG(e,t,r,o){return`<rect x="${e}" y="${t}" width="${r}" height="${r}" fill="${o}"/>`}},squircle:{renderSVG(e,t,r,o){let n=r/2,s=n*Ze.EYE_FRAME,a=e+n,i=t+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}"/>`}
|
|
6
|
-
H${l+
|
|
7
|
-
A${d},${d} 0 0 1 ${l+
|
|
8
|
-
V${
|
|
9
|
-
A${d},${d} 0 0 1 ${l+
|
|
10
|
-
H${l-
|
|
11
|
-
A${d},${d} 0 0 1 ${l-
|
|
12
|
-
V${
|
|
13
|
-
A${d},${d} 0 0 1 ${l-
|
|
14
|
-
Z`;if(a==="dashed"){let
|
|
15
|
-
A${
|
|
16
|
-
A${
|
|
17
|
-
A${
|
|
18
|
-
A${
|
|
5
|
+
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`}}},E={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`}}},k={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,g=r-s,{dashArray:m,offset:h}=Xe(g,s);return`<rect x="${e+d}" y="${t+d}" width="${g}" height="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${m}" stroke-dashoffset="${-h}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,c=t+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,c=t+i,u=i-s/2,f=r*Ye,d=Math.max(0,f-s/2),g=u-d,m=`M${l},${c-u}
|
|
6
|
+
H${l+g}
|
|
7
|
+
A${d},${d} 0 0 1 ${l+u},${c-g}
|
|
8
|
+
V${c+g}
|
|
9
|
+
A${d},${d} 0 0 1 ${l+g},${c+u}
|
|
10
|
+
H${l-g}
|
|
11
|
+
A${d},${d} 0 0 1 ${l-u},${c+g}
|
|
12
|
+
V${c-g}
|
|
13
|
+
A${d},${d} 0 0 1 ${l-g},${c-u}
|
|
14
|
+
Z`;if(a==="dashed"){let h=2*g,$=.5*Math.PI*d,b=4*h+4*$,{dashArray:v,offset:Fe}=J(b,s);return`<path d="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${v}" stroke-dashoffset="${Fe}"/>`}return`<path d="${m}" fill="none" stroke="${o}" stroke-width="${s}"/>`}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,c=r/2;if(a==="dashed"){let g=c-s/2,m=2*Math.PI*g,{dashArray:h,offset:$}=J(m,s);return`<circle cx="${i}" cy="${l}" r="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${$}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
|
+
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
|
+
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
|
+
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
+
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}}};var y=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
19
|
`);super(`QR Code validation failed:
|
|
20
|
-
${r}`),this.name="QRValidationError",this.errors=t}};function st(e){let t={...e};return t.backgroundColor===""&&(t.backgroundColor=void 0),t.eyes&&(t.eyes={...t.eyes},t.eyes.shape===""&&(t.eyes.shape=void 0),t.eyes.color===""&&(t.eyes.color=void 0)),t.pupils&&(t.pupils={...t.pupils},t.pupils.color===""&&(t.pupils.color=void 0)),t.dots&&(t.dots={...t.dots},t.dots.shape===""&&(t.dots.shape=void 0),t.dots.color===""&&(t.dots.color=void 0)),t.border&&(t.border={...t.border},t.border.shape===""&&(t.border.shape=void 0),t.border.color===""&&(t.border.color=void 0),t.border.style===""&&(t.border.style=void 0)),t}function at(e){let t={...e};return t.darkChar===""&&(t.darkChar=void 0),t.lightChar===""&&(t.lightChar=void 0),t}function I(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function E(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/,s=r.match(n);if(s){let[,u,c,f,d]=s,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>255||g<0||g>255||p<0||p>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let a=/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/,i=r.match(a);if(i){let[,u,c,f,d]=i,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(g<0||g>100||p<0||p>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"].includes(r.toLowerCase())?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function W(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function it(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2)return{field:t,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!lt(s))return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function lt(e){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(e)&&e.length%4===0}catch{return!1}}function le(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function H(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ue(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function ce(e){let t=st(e),r=[];if(t.size!==void 0){let o=I(t.size,"size",21,null,!0);o&&r.push(o)}if(t.margin!==void 0){let o=I(t.margin,"margin",0,null,!0);o&&r.push(o)}if(t.backgroundColor!==void 0){let o=E(t.backgroundColor,"backgroundColor");o&&r.push(o)}if(t.eyes?.shape!==void 0){let o=W(t.eyes.shape,"eyes.shape",S);o&&r.push(o)}if(t.eyes?.color!==void 0){let o=E(t.eyes.color,"eyes.color");o&&r.push(o)}if(t.pupils?.color!==void 0){let o=E(t.pupils.color,"pupils.color");o&&r.push(o)}if(t.dots?.shape!==void 0){let o=W(t.dots.shape,"dots.shape",w);o&&r.push(o)}if(t.dots?.color!==void 0){let o=E(t.dots.color,"dots.color");o&&r.push(o)}if(t.dots?.scale!==void 0){let o=I(t.dots.scale,"dots.scale",.75,1.25,!1);o&&r.push(o)}if(t.border?.shape!==void 0&&t.border.shape!=="none"){let o=W(t.border.shape,"border.shape",D);o&&r.push(o)}if(t.border?.width!==void 0){let o=I(t.border.width,"border.width",0,null,!0);o&&r.push(o)}if(t.border?.color!==void 0){let o=E(t.border.color,"border.color");o&&r.push(o)}if(t.border?.style!==void 0&&(typeof t.border.style!="string"||t.border.style!=="solid"&&t.border.style!=="dashed")&&r.push({field:"border.style",value:t.border.style,message:'must be either "solid" or "dashed"'}),t.logo){if(!t.logo.src||typeof t.logo.src!="string")r.push({field:"logo.src",value:t.logo.src,message:"must be a non-empty string"});else{let o=it(t.logo.src,"logo.src");o&&r.push(o)}if(t.logo.scale!==void 0){let o=I(t.logo.scale,"logo.scale",.1,.3,!1);o&&r.push(o)}}if(r.length>0)throw new x(r);return t}function de(e){let t=at(e),r=[];if(t.margin!==void 0){let o=I(t.margin,"margin",0,null,!0);o&&r.push(o)}if(t.darkChar!==void 0&&typeof t.darkChar!="string"&&r.push({field:"darkChar",value:t.darkChar,message:"must be a string"}),t.lightChar!==void 0&&typeof t.lightChar!="string"&&r.push({field:"lightChar",value:t.lightChar,message:"must be a string"}),r.length>0)throw new x(r);return t}function Y(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new x(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new x(t);let r=e;switch(r.type){case"wifi":{ut(e.data,t);break}case"vcard":{ct(e.data,t);break}case"calendar":{dt(e.data,t);break}case"email":{ft(e,t);break}case"sms":{mt(e,t);break}case"phone":{gt(e,t);break}case"url":{pt(e,t);break}default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new x(t)}function ut(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function ct(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!le(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!H(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ue(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function dt(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=ie(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=ie(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function ft(e,t){let r=e;(!r.email||typeof r.email!="string"||!le(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function mt(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!H(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function gt(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!H(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function pt(e,t){let r=e;(!r.url||typeof r.url!="string"||!ue(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}function ie(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}var b={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"}},L={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function fe(e){if(!e){let{logo:o,...n}=b;return n}let t=ce(e);return{size:t.size??b.size,margin:t.margin??b.margin,backgroundColor:t.backgroundColor??b.backgroundColor,eyes:{shape:t.eyes?.shape??b.eyes.shape,color:t.eyes?.color??b.eyes.color},pupils:{color:t.pupils?.color??b.pupils.color},dots:{shape:t.dots?.shape??b.dots.shape,color:t.dots?.color??b.dots.color,scale:t.dots?.scale??b.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??b.logo.scale}:void 0,border:{shape:t.border?.shape??b.border.shape,width:t.border?.width??b.border.width,color:t.border?.color??b.border.color,style:t.border?.style??b.border.style},output:t.output??b.output}}function me(e){if(!e)return{...L};let t=de(e);return{margin:t.margin??L.margin,darkChar:t.darkChar??L.darkChar,lightChar:t.lightChar??L.lightChar}}function ge(e){return/^\d+$/.test(e)?1:[...e].every(t=>R.includes(t))?2:4}function ht(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function bt(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=R.indexOf(e[r])*45+R.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=R.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function yt(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function $t(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=A(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function vt(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function xt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function pe(e,t,r){let o=ge(e),n,s;o===1?(n=ht(e),s=e.length):o===2?(n=bt(e),s=e.length):(n=yt(e),s=new TextEncoder().encode(e).length);let a=$t(n,o,s,t),i=Math.min(4,r*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=vt(a);return xt(l,r)}function T(e,t){let r=ge(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let u=A(r,l),c=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+u+c;if(Math.ceil(f/8)<=t[l-1])return l}let n=A(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function he(e,t){if(t)try{if(T(e,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(T(e,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var k=new Array(256),X=new Array(256);function Ct(){let e=1;for(let t=0;t<255;t++)k[t]=e,X[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)k[t]=k[t-255]}Ct();function ye(e,t){return e===0||t===0?0:k[X[e]+X[t]]}function It(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=ye(t[s],k[r]);t=n}return t}function be(e,t){let r=It(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=ye(r[a],s)}return o.slice(e.length)}function $e(e,t,r){let o=[],n=[],[s,a,i,l]=r,u=0;for(let c=0;c<s;c++){let f=e.slice(u,u+a);o.push(f);let d=be(f,t);n.push(d),u+=a}for(let c=0;c<i;c++){let f=e.slice(u,u+l);o.push(f);let d=be(f,t);n.push(d),u+=l}return{dataBlocks:o,ecBlocks:n}}function ve(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function xe(e){let t=M(e);return Array.from({length:t},()=>Array(t).fill(!1))}function Ce(e){let t=M(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=P[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function Z(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function Rt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function Ie(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function Re(e){Z(e,0,0),Z(e,0,e.length-7),Z(e,e.length-7,0)}function Me(e,t){let r=e.length,o=P[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||Rt(e,n,s)}function Se(e,t){e[4*t+9][8]=!0}function we(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let u=n<r.length?r[n]:!1;e[a][i-l]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function K(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function Mt(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],u=1,c=1;for(let f=1;f<t;f++)e[a][f]===i?u++:(u>=5&&(r+=3+(u-5)),i=e[a][f],u=1),e[f][a]===l?c++:(c>=5&&(r+=3+(c-5)),l=e[f][a],c=1);u>=5&&(r+=3+(u-5)),c>=5&&(r+=3+(c-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let u=0;u<t;u++)i=i<<1&2047|(e[a][u]?1:0),u>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[u][a]?1:0),u>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Ee(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(u=>[...u]);K(i,t,a),o(i,r,a);let l=Mt(i);l<s&&(s=l,n=a)}return n}function J(e,t,r){let o=e.length,n=V[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function ke(e,t){if(t<7)return;let r=e.length,o=se[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,u=Math.floor(n/3);e[l][u]=s}}function Oe(e,t){return V[e]<<3|t}function Pe(e,t,r,o,n){let s=xe(e),a=Ce(e);Re(s),Ie(s),Me(s,e),Se(s,e),we(s,a,r);let i=n?s.map(u=>[...u]):void 0,l=o??Ee(s,a,t,J);return K(s,a,l),J(s,t,l),ke(s,e),{matrix:s,mask:l,formatInfo:n?Oe(t,l):void 0,unmaskedMatrix:i}}function ee(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Ae(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function De(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function St(e,t,r,o,n,s,a){let i=S[r]||S.square,l=i.renderSVG(e,t,7*a,o),u=i.renderSVG(e+a,t+a,5*a,s),c=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+u+c}function wt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let m=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),u=l?l[1]:"0 0 100 100",c=i.match(/<svg([\s\S]*?)>/i),f="";if(c){let m=c[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${
|
|
20
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function Ke(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function F(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=F(t[r]));return t}function te(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return Je(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return et(e,t);case"enum":return ne(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:tt(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"?{field:t,value:e,message:'must be either "solid" or "dashed"'}:null;default:return null}}function re(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Ke(e,o),a=te(s,o,n);a&&r.push(a)}return r}function Je(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function et(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,i,l,c,u]=o,f=parseInt(i,10),d=parseInt(l,10),g=parseInt(c,10);if(f<0||f>255||d<0||d>255||g<0||g>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let m=parseFloat(u);if(isNaN(m)||m<0||m>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,i,l,c,u]=n,f=parseInt(i,10),d=parseInt(l,10),g=parseInt(c,10);if(f<0||f>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(d<0||d>100||g<0||g>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let m=parseFloat(u);if(isNaN(m)||m<0||m>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function ne(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function tt(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function oe(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function Q(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function se(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function ee(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function ae(e){let t=F(e),o=re(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.shape":{type:"enum",enumObj:w,optional:!0},"eyes.color":{type:"color",optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:E,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.border?.shape!==void 0&&t.border.shape!=="none"){let n=ne(t.border.shape,"border.shape",k);n&&o.push(n)}if(t.logo){let n=te(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new y(o);return t}function ie(e){let t=F(e),o=re(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new y(o);return t}function j(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new y(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new y(t);let r=e;switch(r.type){case"wifi":rt(e.data,t);break;case"vcard":nt(e.data,t);break;case"calendar":ot(e.data,t);break;case"email":st(e,t);break;case"sms":at(e,t);break;case"phone":it(e,t);break;case"url":lt(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new y(t)}function rt(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function nt(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!oe(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!Q(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!se(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function ot(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=ee(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=ee(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function st(e,t){let r=e;(!r.email||typeof r.email!="string"||!oe(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function at(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function it(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!Q(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function lt(e,t){let r=e;(!r.url||typeof r.url!="string"||!se(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},M={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function le(e){if(!e){let{logo:o,...n}=p;return n}let t=ae(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{shape:t.eyes?.shape??p.eyes.shape,color:t.eyes?.color??p.eyes.color},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{shape:t.border?.shape??p.border.shape,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ce(e){if(!e)return{...M};let t=ie(e);return{margin:t.margin??M.margin,darkChar:t.darkChar??M.darkChar,lightChar:t.lightChar??M.lightChar}}function ue(e){return/^\d+$/.test(e)?1:[...e].every(t=>C.includes(t))?2:4}function ct(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function ut(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=C.indexOf(e[r])*45+C.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=C.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function dt(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function ft(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=D(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function gt(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function mt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function de(e,t,r){let o=ue(e),n,s;o===1?(n=ct(e),s=e.length):o===2?(n=ut(e),s=e.length):(n=dt(e),s=new TextEncoder().encode(e).length);let a=ft(n,o,s,t),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=gt(a);return mt(l,r)}function A(e,t){let r=ue(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=D(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=t[l-1])return l}let n=D(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function fe(e,t){if(t)try{if(A(e,x.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(A(e,x[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var S=new Array(256),_=new Array(256);function pt(){let e=1;for(let t=0;t<255;t++)S[t]=e,_[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)S[t]=S[t-255]}pt();function me(e,t){return e===0||t===0?0:S[_[e]+_[t]]}function ht(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=me(t[s],S[r]);t=n}return t}function ge(e,t){let r=ht(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=me(r[a],s)}return o.slice(e.length)}function pe(e,t,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=e.slice(c,c+a);o.push(f);let d=ge(f,t);n.push(d),c+=a}for(let u=0;u<i;u++){let f=e.slice(c,c+l);o.push(f);let d=ge(f,t);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function he(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function be(e){let t=R(e);return Array.from({length:t},()=>Array(t).fill(!1))}function ye(e){let t=R(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=O[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function U(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function bt(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function $e(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function ve(e){U(e,0,0),U(e,0,e.length-7),U(e,e.length-7,0)}function xe(e,t){let r=e.length,o=O[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||bt(e,n,s)}function Ce(e,t){e[4*t+9][8]=!0}function Re(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let c=n<r.length?r[n]:!1;e[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function W(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function yt(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],c=1,u=1;for(let f=1;f<t;f++)e[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=e[a][f],c=1),e[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let c=0;c<t;c++)i=i<<1&2047|(e[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function we(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(c=>[...c]);W(i,t,a),o(i,r,a);let l=yt(i);l<s&&(s=l,n=a)}return n}function q(e,t,r){let o=e.length,n=T[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function Ee(e,t){if(t<7)return;let r=e.length,o=X[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function Se(e,t){return T[e]<<3|t}function Ie(e,t,r,o,n){let s=be(e),a=ye(e);ve(s),$e(s),xe(s,e),Ce(s,e),Re(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??we(s,a,t,q);return W(s,a,l),q(s,t,l),Ee(s,e),{matrix:s,mask:l,formatInfo:n?Se(t,l):void 0,unmaskedMatrix:i}}function z(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Oe(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function De(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function $t(e,t,r,o,n,s,a){let i=w[r]||w.square,l=i.renderSVG(e,t,7*a,o),c=i.renderSVG(e+a,t+a,5*a,s),u=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+c+u}function vt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let g=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(g){let m=g[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(m);else if(typeof Buffer<"u")i=Buffer.from(m,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(m)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let g=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);g&&(f=" "+g.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
+
<svg width="${o}" height="${o}" viewBox="${c}"${f}>
|
|
22
22
|
${d}
|
|
23
23
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function
|
|
24
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function xt(e,t,r,o,n){let s=e.matrixSize,a="",i=E[r]||E.classic;if(r==="classic"){a=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!z(l,c,s)){let u=c*t,f=l*t,d=n*t,g=(1-n)*t/2,m=u+g,h=f+g;a+=`M${m},${h}h${d}v${d}h${-d}z`}return a+='"/>',a}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!z(l,c,s)){let u=c*t,f=l*t,d=n*t,g=(1-n)*t/2,m=u+g,h=f+g,$={qrcode:e.modules,qrSize:s,row:l,col:c};a+=i.renderSVG(m,h,d,o,$)}return a}function ke(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=t,l=r/e.matrixSize,c=t.border.shape==="none"?0:t.border.width,u=r+2*o+2*c,f=o+c,d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}" width="${u}" height="${u}">`;if(d+=`<rect width="${u}" height="${u}" fill="${n}"/>`,t.border.shape!=="none"&&c>0){let b=k[t.border.shape];if(b){let v={borderWidth:c,borderStyle:t.border.style};d+=b.renderSVG(0,0,u,t.border.color,v)}}t.border.shape!=="none"&&c>0&&(d+=`<rect x="${f}" y="${f}" width="${r}" height="${r}" fill="${n}"/>`),d+=`<g transform="translate(${f}, ${f})">`;let g=Oe(e.matrixSize),m="";for(let b of g)m+=$t(b.x*l,b.y*l,s.shape,s.color,a.color,n,l);let h=xt(e,l,i.shape,i.color,i.scale);d+=m+h+"</g>";let $="";if(t.logo){let b=De(e.matrixSize,t.logo.scale)*l,v=u/2;$=vt(t.logo.src,v,v,b)}return d+=$+"</svg>",d}function Me(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",a=e.matrixSize+r*2;for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
25
25
|
`;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[i][l]?n:o;s+=o.repeat(r)+`
|
|
26
26
|
`}for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
27
|
-
`;return s}var
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
27
|
+
`;return s}var L=null,Ae=!1;async function Ct(){if(L)return L;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 L=(await import("@resvg/resvg-js")).Resvg,L}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Le(e,t){let{output:r,size:o,margin:n,border:s}=t,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,l=await Ct(),f=new l(e,{fitTo:{mode:"width",value:i}}).render().asPng(),d=Buffer.from(f);return r.type==="dataURL"?`data:image/png;base64,${d.toString("base64")}`:d}async function Te(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Le(e,t)}function G(e){if(typeof e=="string")return e;switch(e.type){case"url":return Rt(e.url);case"vcard":return wt(e.data);case"wifi":return Et(e.data);case"calendar":return St(e.data);case"email":return It(e.email,e.subject,e.body);case"sms":return Ot(e.phone,e.message);case"phone":return Dt(e.phone)}}function Rt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function wt(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:a}=e.address,i=["","",r||"",o||"",n||"",s||"",a||""];t.push(`ADR:${i.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
28
|
+
`)}function Et(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=Pe(e.ssid),n=Pe(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function Pe(e){return e.replace(/([\\;,":])/g,"\\$1")}function St(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
29
|
+
`)}function It(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function Ot(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function Dt(e){return`tel:${e}`}function kt(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=K[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function Ve(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=fe(e,t),o=x[r],n=A(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${x[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=de(e,n,o[n-1]),a=Y[r][n-1],i=Z[r][n-1],{dataBlocks:l,ecBlocks:c}=pe(s,a,i),u=he(l,c),f=kt(u,n),{matrix:d,mask:g}=Ie(n,r,f);return{version:n,matrixSize:R(n),modules:d,mask:g,errorCorrectionLevel:r}}async function Ne(e,t){j(e);let r=G(e),o=le(t),n=Ve(r,!!o.logo),s=ke(n,o);return await Te(s,o)}function Be(e,t){j(e);let r=G(e),o=ce(t),n=Ve(r,!1);return Me(n,o)}0&&(module.exports={BorderShape,BorderStyle,DotShape,EyeFrameShape,QRValidationError,genQrImage,genQrText});
|
package/dist/node.mjs
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
var
|
|
1
|
+
var U={L:[7,10,15,20,26,18,20,24,30,18],M:[10,16,26,18,24,16,18,22,22,26],Q:[13,22,18,26,18,24,18,22,20,24],H:[17,28,22,16,22,28,26,26,24,28]},x={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]},W={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]]},C="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ve={1:[10,12,14],2:[9,11,13],4:[8,16,16]},L={L:1,M:0,Q:3,H:2},I=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50]],q=[31892,34236,39577,42195],z=[0,7,7,7,7,7,0,0,0,0];function R(e){return e*4+17}function O(e,t){let r=t<10?0:t<27?1:2;return Ve[e][r]}var G=(r=>(r.SQUARE="square",r.SQUIRCLE="squircle",r))(G||{}),H=(o=>(o.CLASSIC="classic",o.DOTS="dots",o.SQUARE="square",o))(H||{}),Y=(n=>(n.NONE="none",n.SQUARE="square",n.SQUIRCLE="squircle",n.CIRCLE="circle",n))(Y||{}),Z=(r=>(r.SOLID="solid",r.DASHED="dashed",r))(Z||{});var Ne=.09,Be={EYE_FRAME:.90909};function Fe(e,t){let n=t*3,s=t*2,a=n+s,i=Math.max(1,Math.round(e/a)),l=e/i,c=l*(3/5),u=l*(2/5),f=u/2;return{dashArray:`${c} ${u}`,offset:f}}function X(e,t){let r=t*3,o=t*2,n=r+o,s=Math.round(e/n);s=Math.round(s/4)*4,s=Math.max(4,s);let a=e/s,i=a*.6,l=a*.4,c=i/2;return{dashArray:`${i} ${l}`,offset:c}}var w={square:{renderSVG(e,t,r,o){return`<rect x="${e}" y="${t}" width="${r}" height="${r}" fill="${o}"/>`}},squircle:{renderSVG(e,t,r,o){let n=r/2,s=n*Be.EYE_FRAME,a=e+n,i=t+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}"/>`}
|
|
6
|
-
H${l+
|
|
7
|
-
A${d},${d} 0 0 1 ${l+
|
|
8
|
-
V${
|
|
9
|
-
A${d},${d} 0 0 1 ${l+
|
|
10
|
-
H${l-
|
|
11
|
-
A${d},${d} 0 0 1 ${l-
|
|
12
|
-
V${
|
|
13
|
-
A${d},${d} 0 0 1 ${l-
|
|
14
|
-
Z`;if(a==="dashed"){let
|
|
15
|
-
A${
|
|
16
|
-
A${
|
|
17
|
-
A${
|
|
18
|
-
A${
|
|
5
|
+
S${a-s},${i-n} ${a},${i-n}Z`}" fill="${o}"/>`}}},E={classic:{renderSVG(){return""}},dots:{renderSVG(e,t,r,o){let n=e+r/2,s=t+r/2,a=r*.35;return`<circle cx="${n}" cy="${s}" r="${a}" fill="${o}"/>`}},square:{renderSVG(e,t,r,o){let n=r*.7,s=(r-n)/2,a=e+s,i=t+s;return`<rect x="${a}" y="${i}" width="${n}" height="${n}" fill="${o}"/>`}}},D={square:{getDiagonalFactor(){return Math.sqrt(2)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1;if((n?.borderStyle??"solid")==="dashed"){let d=s/2,g=r-s,{dashArray:m,offset:h}=Fe(g,s);return`<rect x="${e+d}" y="${t+d}" width="${g}" height="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${m}" stroke-dashoffset="${-h}"/>`}let i=`M${e},${t}h${r}v${r}h${-r}z`,l=e+s,c=t+s,u=r-s*2,f=`M${l},${c}h${u}v${u}h${-u}z`;return`<path d="${i} ${f}" fill="${o}" fill-rule="evenodd"/>`}},squircle:{getDiagonalFactor(){return Math.pow(2,.25)},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=r/2,l=e+i,c=t+i,u=i-s/2,f=r*Ne,d=Math.max(0,f-s/2),g=u-d,m=`M${l},${c-u}
|
|
6
|
+
H${l+g}
|
|
7
|
+
A${d},${d} 0 0 1 ${l+u},${c-g}
|
|
8
|
+
V${c+g}
|
|
9
|
+
A${d},${d} 0 0 1 ${l+g},${c+u}
|
|
10
|
+
H${l-g}
|
|
11
|
+
A${d},${d} 0 0 1 ${l-u},${c+g}
|
|
12
|
+
V${c-g}
|
|
13
|
+
A${d},${d} 0 0 1 ${l-g},${c-u}
|
|
14
|
+
Z`;if(a==="dashed"){let h=2*g,y=.5*Math.PI*d,b=4*h+4*y,{dashArray:v,offset:Pe}=X(b,s);return`<path d="${m}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${v}" stroke-dashoffset="${Pe}"/>`}return`<path d="${m}" fill="none" stroke="${o}" stroke-width="${s}"/>`}},circle:{getDiagonalFactor(){return 1},renderSVG(e,t,r,o,n){let s=n?.borderWidth??1,a=n?.borderStyle??"solid",i=e+r/2,l=t+r/2,c=r/2;if(a==="dashed"){let g=c-s/2,m=2*Math.PI*g,{dashArray:h,offset:y}=X(m,s);return`<circle cx="${i}" cy="${l}" r="${g}" fill="none" stroke="${o}" stroke-width="${s}" stroke-dasharray="${h}" stroke-dashoffset="${y}"/>`}let u=c-s,f=`M${i},${l-c}
|
|
15
|
+
A${c},${c} 0 1,1 ${i},${l+c}
|
|
16
|
+
A${c},${c} 0 1,1 ${i},${l-c}Z`,d=`M${i},${l-u}
|
|
17
|
+
A${u},${u} 0 1,0 ${i},${l+u}
|
|
18
|
+
A${u},${u} 0 1,0 ${i},${l-u}Z`;return`<path d="${f} ${d}" fill="${o}" fill-rule="evenodd"/>`}}};var $=class extends Error{constructor(t){let r=t.map(o=>` - ${o.field}: ${o.message}`).join(`
|
|
19
19
|
`);super(`QR Code validation failed:
|
|
20
|
-
${r}`),this.name="QRValidationError",this.errors=e}};function We(t){let e={...t};return e.backgroundColor===""&&(e.backgroundColor=void 0),e.eyes&&(e.eyes={...e.eyes},e.eyes.shape===""&&(e.eyes.shape=void 0),e.eyes.color===""&&(e.eyes.color=void 0)),e.pupils&&(e.pupils={...e.pupils},e.pupils.color===""&&(e.pupils.color=void 0)),e.dots&&(e.dots={...e.dots},e.dots.shape===""&&(e.dots.shape=void 0),e.dots.color===""&&(e.dots.color=void 0)),e.border&&(e.border={...e.border},e.border.shape===""&&(e.border.shape=void 0),e.border.color===""&&(e.border.color=void 0),e.border.style===""&&(e.border.style=void 0)),e}function He(t){let e={...t};return e.darkChar===""&&(e.darkChar=void 0),e.lightChar===""&&(e.lightChar=void 0),e}function I(t,e,r,o,n=!1){return typeof t!="number"||!isFinite(t)?{field:e,value:t,message:"must be a finite number"}:n&&!Number.isInteger(t)?{field:e,value:t,message:"must be an integer"}:t<r?{field:e,value:t,message:`must be at least ${r}`}:o!==null&&t>o?{field:e,value:t,message:`must be at most ${o}`}:null}function E(t,e){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};let r=t.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let n=/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/,s=r.match(n);if(s){let[,u,c,f,d]=s,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>255||g<0||g>255||p<0||p>255)return{field:e,value:t,message:"RGB values must be between 0-255"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:e,value:t,message:"RGBA alpha value must be between 0-1"}}return null}let a=/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/,i=r.match(a);if(i){let[,u,c,f,d]=i,m=parseInt(u,10),g=parseInt(c,10),p=parseInt(f,10);if(m<0||m>360)return{field:e,value:t,message:"HSL hue must be between 0-360"};if(g<0||g>100||p<0||p>100)return{field:e,value:t,message:"HSL saturation and lightness must be between 0-100%"};if(d!==void 0){let h=parseFloat(d);if(isNaN(h)||h<0||h>1)return{field:e,value:t,message:"HSLA alpha value must be between 0-1"}}return null}return["aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgrey","darkgreen","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","grey","green","greenyellow","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgrey","lightgreen","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","transparent"].includes(r.toLowerCase())?null:{field:e,value:t,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function F(t,e,r){if(typeof t!="string")return{field:e,value:t,message:"must be a string"};if(!(t in r)){let o=Object.keys(r).join(", ");return{field:e,value:t,message:`must be one of: ${o}`}}return null}function Ye(t,e){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=t.trim().startsWith("<svg");if(!r.test(t)&&!o)return{field:e,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(t.startsWith("data:")){let n=t.split(",");if(n.length!==2)return{field:e,value:"[truncated]",message:"data URL format is invalid (missing comma separator)"};let s=n[1];if(!s||!Xe(s))return{field:e,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!t.includes("</svg>")?{field:e,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function Xe(t){try{return/^[A-Za-z0-9+/]*={0,2}$/.test(t)&&t.length%4===0}catch{return!1}}function ae(t){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t)}function j(t){return/^[\d\s\-+()]+$/.test(t)&&t.replace(/\D/g,"").length>=7}function ie(t){try{return new URL(t.startsWith("http")?t:`https://${t}`),!0}catch{return!1}}function le(t){let e=We(t),r=[];if(e.size!==void 0){let o=I(e.size,"size",21,null,!0);o&&r.push(o)}if(e.margin!==void 0){let o=I(e.margin,"margin",0,null,!0);o&&r.push(o)}if(e.backgroundColor!==void 0){let o=E(e.backgroundColor,"backgroundColor");o&&r.push(o)}if(e.eyes?.shape!==void 0){let o=F(e.eyes.shape,"eyes.shape",S);o&&r.push(o)}if(e.eyes?.color!==void 0){let o=E(e.eyes.color,"eyes.color");o&&r.push(o)}if(e.pupils?.color!==void 0){let o=E(e.pupils.color,"pupils.color");o&&r.push(o)}if(e.dots?.shape!==void 0){let o=F(e.dots.shape,"dots.shape",w);o&&r.push(o)}if(e.dots?.color!==void 0){let o=E(e.dots.color,"dots.color");o&&r.push(o)}if(e.dots?.scale!==void 0){let o=I(e.dots.scale,"dots.scale",.75,1.25,!1);o&&r.push(o)}if(e.border?.shape!==void 0&&e.border.shape!=="none"){let o=F(e.border.shape,"border.shape",A);o&&r.push(o)}if(e.border?.width!==void 0){let o=I(e.border.width,"border.width",0,null,!0);o&&r.push(o)}if(e.border?.color!==void 0){let o=E(e.border.color,"border.color");o&&r.push(o)}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){if(!e.logo.src||typeof e.logo.src!="string")r.push({field:"logo.src",value:e.logo.src,message:"must be a non-empty string"});else{let o=Ye(e.logo.src,"logo.src");o&&r.push(o)}if(e.logo.scale!==void 0){let o=I(e.logo.scale,"logo.scale",.1,.3,!1);o&&r.push(o)}}if(r.length>0)throw new x(r);return e}function ue(t){let e=He(t),r=[];if(e.margin!==void 0){let o=I(e.margin,"margin",0,null,!0);o&&r.push(o)}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 x(r);return e}function _(t){let e=[];if(typeof t=="string"){if(t||e.push({field:"input",value:t,message:"string input cannot be empty"}),e.length>0)throw new x(e);return}if(!t||typeof t!="object"||!("type"in t))throw e.push({field:"input",value:t,message:"must be a string or structured content object with a type property"}),new x(e);let r=t;switch(r.type){case"wifi":{Ze(t.data,e);break}case"vcard":{Ke(t.data,e);break}case"calendar":{Je(t.data,e);break}case"email":{et(t,e);break}case"sms":{tt(t,e);break}case"phone":{rt(t,e);break}case"url":{nt(t,e);break}default:e.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(e.length>0)throw new x(e)}function Ze(t,e){if(!t||typeof t!="object"){e.push({field:"wifi.data",value:t,message:"must be an object"});return}let r=t;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&e.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&e.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||e.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&e.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function Ke(t,e){if(!t||typeof t!="object"){e.push({field:"vcard.data",value:t,message:"must be an object"});return}let r=t;(!r.name||typeof r.name!="string"||!r.name.trim())&&e.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!ae(r.email))&&e.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!j(r.phone))&&e.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ie(r.url))&&e.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&e.push({field:"vcard.address",value:r.address,message:"must be an object"})}function Je(t,e){if(!t||typeof t!="object"){e.push({field:"calendar.data",value:t,message:"must be an object"});return}let r=t;(!r.title||typeof r.title!="string"||!r.title.trim())&&e.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=se(r.startDate);if(o||e.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=se(r.endDate);n?o&&n<o&&e.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):e.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function et(t,e){let r=t;(!r.email||typeof r.email!="string"||!ae(r.email))&&e.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&e.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&e.push({field:"email.body",value:r.body,message:"must be a string"})}function tt(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!j(r.phone))&&e.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&e.push({field:"sms.message",value:r.message,message:"must be a string"})}function rt(t,e){let r=t;(!r.phone||typeof r.phone!="string"||!j(r.phone))&&e.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function nt(t,e){let r=t;(!r.url||typeof r.url!="string"||!ie(r.url))&&e.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}function se(t){if(t instanceof Date)return isNaN(t.getTime())?null:t;if(typeof t=="string"){let e=new Date(t);return isNaN(e.getTime())?null:e}return null}var b={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"}},D={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ce(t){if(!t){let{logo:o,...n}=b;return n}let e=le(t);return{size:e.size??b.size,margin:e.margin??b.margin,backgroundColor:e.backgroundColor??b.backgroundColor,eyes:{shape:e.eyes?.shape??b.eyes.shape,color:e.eyes?.color??b.eyes.color},pupils:{color:e.pupils?.color??b.pupils.color},dots:{shape:e.dots?.shape??b.dots.shape,color:e.dots?.color??b.dots.color,scale:e.dots?.scale??b.dots.scale},logo:e.logo?{src:e.logo.src,scale:e.logo.scale??b.logo.scale}:void 0,border:{shape:e.border?.shape??b.border.shape,width:e.border?.width??b.border.width,color:e.border?.color??b.border.color,style:e.border?.style??b.border.style},output:e.output??b.output}}function de(t){if(!t)return{...D};let e=ue(t);return{margin:e.margin??D.margin,darkChar:e.darkChar??D.darkChar,lightChar:e.lightChar??D.lightChar}}function fe(t){return/^\d+$/.test(t)?1:[...t].every(e=>R.includes(e))?2:4}function ot(t){let e=[];for(let r=0;r<t.length;r+=3){let o=t.substring(r,Math.min(r+3,t.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)e.push(n>>a&1)}return e}function st(t){let e=[];for(let r=0;r<t.length;r+=2)if(r+1<t.length){let o=R.indexOf(t[r])*45+R.indexOf(t[r+1]);for(let n=10;n>=0;n--)e.push(o>>n&1)}else{let o=R.indexOf(t[r]);for(let n=5;n>=0;n--)e.push(o>>n&1)}return e}function at(t){let e=[],r=new TextEncoder().encode(t);for(let o of r)for(let n=7;n>=0;n--)e.push(o>>n&1);return e}function it(t,e,r,o){let n=[];for(let a=3;a>=0;a--)n.push(e>>a&1);let s=P(e,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...t]}function lt(t){let e=[];for(let r=0;r<t.length;r+=8){let o=0;for(let n=0;n<8&&r+n<t.length;n++)o=o<<1|t[r+n];r+8>t.length&&(o<<=8-t.length%8),e.push(o)}return e}function ut(t,e){let r=[...t],o=[236,17],n=0;for(;r.length<e;)r.push(o[n]),n=1-n;return r}function me(t,e,r){let o=fe(t),n,s;o===1?(n=ot(t),s=t.length):o===2?(n=st(t),s=t.length):(n=at(t),s=new TextEncoder().encode(t).length);let a=it(n,o,s,e),i=Math.min(4,r*8-a.length);for(let u=0;u<i;u++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=lt(a);return ut(l,r)}function L(t,e){let r=fe(t),o=r===4?new TextEncoder().encode(t).length:t.length;for(let l=1;l<=10;l++){let u=P(r,l),c=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+u+c;if(Math.ceil(f/8)<=e[l-1])return l}let n=P(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${e[9]} bytes. Current data length: ${t.length} characters (${o} bytes encoded).`)}function ge(t,e){if(e)try{if(L(t,C.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${t.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(L(t,C[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${t.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var k=new Array(256),U=new Array(256);function ct(){let t=1;for(let e=0;e<255;e++)k[e]=t,U[t]=e,t<<=1,t&256&&(t^=285);for(let e=255;e<512;e++)k[e]=k[e-255]}ct();function he(t,e){return t===0||e===0?0:k[U[t]+U[e]]}function dt(t){let e=[1];for(let r=0;r<t;r++){let o=e.length+1,n=new Array(o).fill(0);for(let s=0;s<e.length;s++)n[s]^=e[s],n[s+1]^=he(e[s],k[r]);e=n}return e}function pe(t,e){let r=dt(e),o=[...t,...new Array(e).fill(0)];for(let n=0;n<t.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=he(r[a],s)}return o.slice(t.length)}function be(t,e,r){let o=[],n=[],[s,a,i,l]=r,u=0;for(let c=0;c<s;c++){let f=t.slice(u,u+a);o.push(f);let d=pe(f,e);n.push(d),u+=a}for(let c=0;c<i;c++){let f=t.slice(u,u+l);o.push(f);let d=pe(f,e);n.push(d),u+=l}return{dataBlocks:o,ecBlocks:n}}function ye(t,e){let r=[],o=Math.max(...t.map(s=>s.length));for(let s=0;s<o;s++)for(let a of t)s<a.length&&r.push(a[s]);let n=Math.max(...e.map(s=>s.length));for(let s=0;s<n;s++)for(let a of e)s<a.length&&r.push(a[s]);return r}function $e(t){let e=M(t);return Array.from({length:e},()=>Array(e).fill(!1))}function ve(t){let e=M(t),r=Array.from({length:e},()=>Array(e).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][e-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[e-8+n][s]=!0;for(let n=8;n<e-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*t+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=e-8;n<e;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=e-8;n<e;n++)r[8][n]=!0;let o=O[t-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>e-9||n>e-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(t>=7){for(let n=0;n<6;n++)for(let s=e-11;s<e-8;s++)r[n][s]=!0;for(let n=e-11;n<e-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function G(t,e,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=e+o,a=r+n;if(s<0||s>=t.length||a<0||a>=t.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;t[s][a]=i||l}}function ft(t,e,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;t[e+o][r+n]=s||a}}function xe(t){let e=t.length;for(let r=8;r<e-8;r++)t[6][r]=r%2===0,t[r][6]=r%2===0}function Ce(t){G(t,0,0),G(t,0,t.length-7),G(t,t.length-7,0)}function Ie(t,e){let r=t.length,o=O[e-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||ft(t,n,s)}function Re(t,e){t[4*e+9][8]=!0}function Me(t,e,r){let o=t.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!e[a][i-l]){let u=n<r.length?r[n]:!1;t[a][i-l]=u,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function W(t,e,r){let o=t.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(e[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(t[n][s]=!t[n][s])}}function mt(t){let e=t.length,r=0;for(let a=0;a<e;a++){let i=t[a][0],l=t[0][a],u=1,c=1;for(let f=1;f<e;f++)t[a][f]===i?u++:(u>=5&&(r+=3+(u-5)),i=t[a][f],u=1),t[f][a]===l?c++:(c>=5&&(r+=3+(c-5)),l=t[f][a],c=1);u>=5&&(r+=3+(u-5)),c>=5&&(r+=3+(c-5))}for(let a=0;a<e-1;a++)for(let i=0;i<e-1;i++){let l=t[a][i];t[a][i+1]===l&&t[a+1][i]===l&&t[a+1][i+1]===l&&(r+=3)}for(let a=0;a<e;a++){let i=0,l=0;for(let u=0;u<e;u++)i=i<<1&2047|(t[a][u]?1:0),u>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(t[u][a]?1:0),u>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=e*e;for(let a=0;a<e;a++)for(let i=0;i<e;i++)t[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Se(t,e,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=t.map(u=>[...u]);W(i,e,a),o(i,r,a);let l=mt(i);l<s&&(s=l,n=a)}return n}function H(t,e,r){let o=t.length,n=N[e]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?t[8][i]=l:i===6?t[8][7]=l:i===7?t[8][8]=l:i===8?t[7][8]=l:t[5-(i-9)][8]=l,i<=6?t[o-1-i][8]=l:t[8][o-8+(i-7)]=l}}function we(t,e){if(e<7)return;let r=t.length,o=J[e-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;t[a][i]=s;let l=r-11+n%3,u=Math.floor(n/3);t[l][u]=s}}function Ee(t,e){return N[t]<<3|e}function ke(t,e,r,o,n){let s=$e(t),a=ve(t);Ce(s),xe(s),Ie(s,t),Re(s,t),Me(s,a,r);let i=n?s.map(u=>[...u]):void 0,l=o??Se(s,a,e,H);return W(s,a,l),H(s,e,l),we(s,t),{matrix:s,mask:l,formatInfo:n?Ee(e,l):void 0,unmaskedMatrix:i}}function Y(t,e,r){return t<7&&e<7||t<7&&e>=r-7||t>=r-7&&e<7}function Oe(t){return[{x:0,y:0},{x:t-7,y:0},{x:0,y:t-7}]}function Pe(t,e){let o=Math.max(.1,Math.min(.3,e));return t*o}function gt(t,e,r,o,n,s,a){let i=S[r]||S.square,l=i.renderSVG(t,e,7*a,o),u=i.renderSVG(t+a,e+a,5*a,s),c=i.renderSVG(t+2*a,e+2*a,3*a,n);return l+u+c}function pt(t,e,r,o){let n=o/2,s=t.trim();if(t.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=t;if(t.includes("data:image/svg")){let m=t.match(/data:image\/svg\+xml[^,]*,(.+)/);if(m){let g=m[1];if(t.includes("base64"))try{if(typeof atob<"u")i=atob(g);else if(typeof Buffer<"u")i=Buffer.from(g,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(g)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),u=l?l[1]:"0 0 100 100",c=i.match(/<svg([\s\S]*?)>/i),f="";if(c){let m=c[1].match(/xmlns[^=]*=["'][^"']*["']/gi);m&&(f=" "+m.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${e-n}, ${r-n})">
|
|
21
|
-
<svg width="${o}" height="${o}" viewBox="${
|
|
20
|
+
${r}`),this.name="QRValidationError",this.errors=t}};function Qe(e,t){let r=t.split("."),o=e;for(let n of r)if(o&&typeof o=="object"&&n in o)o=o[n];else return;return o}function T(e){if(typeof e!="object"||e===null)return e;let t=Array.isArray(e)?[...e]:{...e};for(let r in t)t[r]===""?t[r]=void 0:typeof t[r]=="object"&&t[r]!==null&&(t[r]=T(t[r]));return t}function J(e,t,r){if(e===void 0&&r.optional)return null;switch(r.type){case"number":return je(e,t,r.min??0,r.max??null,r.integer??!1);case"color":return _e(e,t);case"enum":return te(e,t,r.enumObj);case"string":return typeof e!="string"?{field:t,value:e,message:"must be a string"}:null;case"boolean":return typeof e!="boolean"?{field:t,value:e,message:"must be a boolean"}:null;case"logoSrc":return typeof e!="string"||!e?{field:t,value:e,message:"must be a non-empty string"}:Ue(e,t);case"borderStyle":return typeof e!="string"||e!=="solid"&&e!=="dashed"?{field:t,value:e,message:'must be either "solid" or "dashed"'}:null;default:return null}}function ee(e,t){let r=[];for(let[o,n]of Object.entries(t)){let s=Qe(e,o),a=J(s,o,n);a&&r.push(a)}return r}function je(e,t,r,o,n=!1){return typeof e!="number"||!isFinite(e)?{field:t,value:e,message:"must be a finite number"}:n&&!Number.isInteger(e)?{field:t,value:e,message:"must be an integer"}:e<r?{field:t,value:e,message:`must be at least ${r}`}:o!==null&&e>o?{field:t,value:e,message:`must be at most ${o}`}:null}function _e(e,t){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};let r=e.trim();if(/^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/.test(r))return null;let o=r.match(/^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)$/);if(o){let[,i,l,c,u]=o,f=parseInt(i,10),d=parseInt(l,10),g=parseInt(c,10);if(f<0||f>255||d<0||d>255||g<0||g>255)return{field:t,value:e,message:"RGB values must be between 0-255"};if(u!==void 0){let m=parseFloat(u);if(isNaN(m)||m<0||m>1)return{field:t,value:e,message:"RGBA alpha value must be between 0-1"}}return null}let n=r.match(/^hsla?\(\s*(\d+)\s*,\s*(\d+)%\s*,\s*(\d+)%\s*(?:,\s*([\d.]+)\s*)?\)$/);if(n){let[,i,l,c,u]=n,f=parseInt(i,10),d=parseInt(l,10),g=parseInt(c,10);if(f<0||f>360)return{field:t,value:e,message:"HSL hue must be between 0-360"};if(d<0||d>100||g<0||g>100)return{field:t,value:e,message:"HSL saturation and lightness must be between 0-100%"};if(u!==void 0){let m=parseFloat(u);if(isNaN(m)||m<0||m>1)return{field:t,value:e,message:"HSLA alpha value must be between 0-1"}}return null}let s=r.toLowerCase();return/^[abcdefghilmnoprstvwy]/.test(s)&&/^(aliceblue|antiquewhite|aqua(marine)?|azure|beige|bisque|black|blanchedalmond|blue(violet)?|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|dark(blue|cyan|goldenrod|gray|grey|green|khaki|magenta|olivegreen|orange|orchid|red|salmon|seagreen|slateblue|slategray|slategrey|turquoise|violet)|deep(pink|skyblue)|dim(gray|grey)|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold(enrod)?|gray|grey|green(yellow)?|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender(blush)?|lawngreen|lemonchiffon|light(blue|coral|cyan|goldenrodyellow|gray|grey|green|pink|salmon|seagreen|skyblue|slategray|slategrey|steelblue|yellow)|lime(green)?|linen|magenta|maroon|medium(aquamarine|blue|orchid|purple|seagreen|slateblue|springgreen|turquoise|violetred)|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive(drab)?|orange(red)?|orchid|pale(goldenrod|green|turquoise|violetred)|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slate(gray|grey)|snow|springgreen|steelblue|tan|teal|thistle|tomato|transparent|turquoise|violet|wheat|white(smoke)?|yellow(green)?)$/.test(s)?null:{field:t,value:e,message:"must be a valid CSS color (hex: #fff or #ffffff, rgb/rgba, hsl/hsla, or named color)"}}function te(e,t,r){if(typeof e!="string")return{field:t,value:e,message:"must be a string"};if(!(e in r)){let o=Object.keys(r).join(", ");return{field:t,value:e,message:`must be one of: ${o}`}}return null}function Ue(e,t){let r=/^data:image\/(png|jpeg|jpg|gif|svg\+xml|webp);base64,/i,o=e.trim().startsWith("<svg");if(!r.test(e)&&!o)return{field:t,value:"[truncated]",message:"must be a data URL (data:image/...;base64,...) or SVG string (<svg...)"};if(e.startsWith("data:")){let n=e.split(",");if(n.length!==2||!n[1]||!/^[A-Za-z0-9+/]*={0,2}$/.test(n[1])||n[1].length%4!==0)return{field:t,value:"[truncated]",message:"data URL contains invalid base64 encoding"}}return o&&!e.includes("</svg>")?{field:t,value:"[truncated]",message:"SVG string is incomplete (missing closing </svg> tag)"}:null}function re(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function P(e){return/^[\d\s\-+()]+$/.test(e)&&e.replace(/\D/g,"").length>=7}function ne(e){try{return new URL(e.startsWith("http")?e:`https://${e}`),!0}catch{return!1}}function K(e){if(e instanceof Date)return isNaN(e.getTime())?null:e;if(typeof e=="string"){let t=new Date(e);return isNaN(t.getTime())?null:t}return null}function oe(e){let t=T(e),o=ee(t,{size:{type:"number",min:21,integer:!0,optional:!0},margin:{type:"number",min:0,integer:!0,optional:!0},backgroundColor:{type:"color",optional:!0},"eyes.shape":{type:"enum",enumObj:w,optional:!0},"eyes.color":{type:"color",optional:!0},"pupils.color":{type:"color",optional:!0},"dots.shape":{type:"enum",enumObj:E,optional:!0},"dots.color":{type:"color",optional:!0},"dots.scale":{type:"number",min:.75,max:1.25,optional:!0},"border.color":{type:"color",optional:!0},"border.width":{type:"number",min:0,integer:!0,optional:!0},"border.style":{type:"borderStyle",optional:!0},"logo.scale":{type:"number",min:.1,max:.3,optional:!0}});if(t.border?.shape!==void 0&&t.border.shape!=="none"){let n=te(t.border.shape,"border.shape",D);n&&o.push(n)}if(t.logo){let n=J(t.logo.src,"logo.src",{type:"logoSrc",optional:!1});n&&o.push(n)}if(o.length>0)throw new $(o);return t}function se(e){let t=T(e),o=ee(t,{margin:{type:"number",min:0,integer:!0,optional:!0},darkChar:{type:"string",optional:!0},lightChar:{type:"string",optional:!0}});if(o.length>0)throw new $(o);return t}function V(e){let t=[];if(typeof e=="string"){if(e||t.push({field:"input",value:e,message:"string input cannot be empty"}),t.length>0)throw new $(t);return}if(!e||typeof e!="object"||!("type"in e))throw t.push({field:"input",value:e,message:"must be a string or structured content object with a type property"}),new $(t);let r=e;switch(r.type){case"wifi":We(e.data,t);break;case"vcard":qe(e.data,t);break;case"calendar":ze(e.data,t);break;case"email":Ge(e,t);break;case"sms":He(e,t);break;case"phone":Ye(e,t);break;case"url":Ze(e,t);break;default:t.push({field:"input.type",value:r.type,message:"must be one of: url, vcard, wifi, calendar, email, sms, phone"})}if(t.length>0)throw new $(t)}function We(e,t){if(!e||typeof e!="object"){t.push({field:"wifi.data",value:e,message:"must be an object"});return}let r=e;if((!r.ssid||typeof r.ssid!="string"||!r.ssid.trim())&&t.push({field:"wifi.ssid",value:r.ssid,message:"is required and must be non-empty"}),(!r.password||typeof r.password!="string")&&t.push({field:"wifi.password",value:r.password,message:"is required and must be a string"}),r.encryption!==void 0){let o=["WPA","WPA2","WEP","nopass"];o.includes(r.encryption)||t.push({field:"wifi.encryption",value:r.encryption,message:`must be one of: ${o.join(", ")}`})}r.hidden!==void 0&&typeof r.hidden!="boolean"&&t.push({field:"wifi.hidden",value:r.hidden,message:"must be a boolean"})}function qe(e,t){if(!e||typeof e!="object"){t.push({field:"vcard.data",value:e,message:"must be an object"});return}let r=e;(!r.name||typeof r.name!="string"||!r.name.trim())&&t.push({field:"vcard.name",value:r.name,message:"is required and must be non-empty"}),r.email!==void 0&&(typeof r.email!="string"||!re(r.email))&&t.push({field:"vcard.email",value:r.email,message:"must be a valid email address"}),r.phone!==void 0&&(typeof r.phone!="string"||!P(r.phone))&&t.push({field:"vcard.phone",value:r.phone,message:"must be a valid phone number (e.g., +1-555-123-4567)"}),r.url!==void 0&&(typeof r.url!="string"||!ne(r.url))&&t.push({field:"vcard.url",value:r.url,message:"must be a valid URL"}),r.address!==void 0&&typeof r.address!="object"&&t.push({field:"vcard.address",value:r.address,message:"must be an object"})}function ze(e,t){if(!e||typeof e!="object"){t.push({field:"calendar.data",value:e,message:"must be an object"});return}let r=e;(!r.title||typeof r.title!="string"||!r.title.trim())&&t.push({field:"calendar.title",value:r.title,message:"is required and must be non-empty"});let o=K(r.startDate);if(o||t.push({field:"calendar.startDate",value:r.startDate,message:"is required and must be a valid Date object or ISO string"}),r.endDate!==void 0){let n=K(r.endDate);n?o&&n<o&&t.push({field:"calendar.endDate",value:r.endDate,message:"must be after startDate"}):t.push({field:"calendar.endDate",value:r.endDate,message:"must be a valid Date object or ISO string"})}}function Ge(e,t){let r=e;(!r.email||typeof r.email!="string"||!re(r.email))&&t.push({field:"email.email",value:r.email,message:"is required and must be a valid email address"}),r.subject!==void 0&&typeof r.subject!="string"&&t.push({field:"email.subject",value:r.subject,message:"must be a string"}),r.body!==void 0&&typeof r.body!="string"&&t.push({field:"email.body",value:r.body,message:"must be a string"})}function He(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!P(r.phone))&&t.push({field:"sms.phone",value:r.phone,message:"is required and must be a valid phone number"}),r.message!==void 0&&typeof r.message!="string"&&t.push({field:"sms.message",value:r.message,message:"must be a string"})}function Ye(e,t){let r=e;(!r.phone||typeof r.phone!="string"||!P(r.phone))&&t.push({field:"phone.phone",value:r.phone,message:"is required and must be a valid phone number"})}function Ze(e,t){let r=e;(!r.url||typeof r.url!="string"||!ne(r.url))&&t.push({field:"url.url",value:r.url,message:"is required and must be a valid URL"})}var p={size:300,margin:24,backgroundColor:"#ffffff",eyes:{shape:"square",color:"#000000"},pupils:{color:"#000000"},dots:{shape:"classic",color:"#000000",scale:1},logo:{scale:.2},border:{shape:"none",width:10,color:"#000000",style:"solid"},output:{format:"png",type:"buffer"}},k={margin:2,darkChar:"\u2588\u2588",lightChar:" "};function ae(e){if(!e){let{logo:o,...n}=p;return n}let t=oe(e);return{size:t.size??p.size,margin:t.margin??p.margin,backgroundColor:t.backgroundColor??p.backgroundColor,eyes:{shape:t.eyes?.shape??p.eyes.shape,color:t.eyes?.color??p.eyes.color},pupils:{color:t.pupils?.color??p.pupils.color},dots:{shape:t.dots?.shape??p.dots.shape,color:t.dots?.color??p.dots.color,scale:t.dots?.scale??p.dots.scale},logo:t.logo?{src:t.logo.src,scale:t.logo.scale??p.logo.scale}:void 0,border:{shape:t.border?.shape??p.border.shape,width:t.border?.width??p.border.width,color:t.border?.color??p.border.color,style:t.border?.style??p.border.style},output:t.output??p.output}}function ie(e){if(!e)return{...k};let t=se(e);return{margin:t.margin??k.margin,darkChar:t.darkChar??k.darkChar,lightChar:t.lightChar??k.lightChar}}function le(e){return/^\d+$/.test(e)?1:[...e].every(t=>C.includes(t))?2:4}function Xe(e){let t=[];for(let r=0;r<e.length;r+=3){let o=e.substring(r,Math.min(r+3,e.length)),n=parseInt(o,10),s=o.length===3?10:o.length===2?7:4;for(let a=s-1;a>=0;a--)t.push(n>>a&1)}return t}function Ke(e){let t=[];for(let r=0;r<e.length;r+=2)if(r+1<e.length){let o=C.indexOf(e[r])*45+C.indexOf(e[r+1]);for(let n=10;n>=0;n--)t.push(o>>n&1)}else{let o=C.indexOf(e[r]);for(let n=5;n>=0;n--)t.push(o>>n&1)}return t}function Je(e){let t=[],r=new TextEncoder().encode(e);for(let o of r)for(let n=7;n>=0;n--)t.push(o>>n&1);return t}function et(e,t,r,o){let n=[];for(let a=3;a>=0;a--)n.push(t>>a&1);let s=O(t,o);for(let a=s-1;a>=0;a--)n.push(r>>a&1);return[...n,...e]}function tt(e){let t=[];for(let r=0;r<e.length;r+=8){let o=0;for(let n=0;n<8&&r+n<e.length;n++)o=o<<1|e[r+n];r+8>e.length&&(o<<=8-e.length%8),t.push(o)}return t}function rt(e,t){let r=[...e],o=[236,17],n=0;for(;r.length<t;)r.push(o[n]),n=1-n;return r}function ce(e,t,r){let o=le(e),n,s;o===1?(n=Xe(e),s=e.length):o===2?(n=Ke(e),s=e.length):(n=Je(e),s=new TextEncoder().encode(e).length);let a=et(n,o,s,t),i=Math.min(4,r*8-a.length);for(let c=0;c<i;c++)a.push(0);for(;a.length%8!==0;)a.push(0);let l=tt(a);return rt(l,r)}function M(e,t){let r=le(e),o=r===4?new TextEncoder().encode(e).length:e.length;for(let l=1;l<=10;l++){let c=O(r,l),u=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,f=4+c+u;if(Math.ceil(f/8)<=t[l-1])return l}let n=O(r,10),s=r===1?Math.ceil(o/3)*10-(o%3===1?6:o%3===2?3:0):r===2?Math.floor(o/2)*11+o%2*6:o*8,a=4+n+s,i=Math.ceil(a/8);throw new Error(`Input too long for QR code version 10. Required capacity: ${i} bytes, Maximum available: ${t[9]} bytes. Current data length: ${e.length} characters (${o} bytes encoded).`)}function ue(e,t){if(t)try{if(M(e,x.H)<=10)return"H"}catch{throw new Error(`Data too large for QR code with logo. Data length: ${e.length} characters. Maximum capacity with logo (EC level H): ~122 bytes (version 10). Logos require high error correction (H) which reduces data capacity. Consider: reducing data length, removing logo, or using multiple QR codes.`)}let r=["H","Q","M","L"];for(let o of r)try{if(M(e,x[o])<=10)return o}catch{continue}throw new Error(`Data too large for QR code version 10 at any error correction level. Data length: ${e.length} characters. Maximum capacity: ~274 bytes (version 10, EC level L). Please reduce input length or split into multiple QR codes.`)}var S=new Array(256),N=new Array(256);function nt(){let e=1;for(let t=0;t<255;t++)S[t]=e,N[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)S[t]=S[t-255]}nt();function fe(e,t){return e===0||t===0?0:S[N[e]+N[t]]}function ot(e){let t=[1];for(let r=0;r<e;r++){let o=t.length+1,n=new Array(o).fill(0);for(let s=0;s<t.length;s++)n[s]^=t[s],n[s+1]^=fe(t[s],S[r]);t=n}return t}function de(e,t){let r=ot(t),o=[...e,...new Array(t).fill(0)];for(let n=0;n<e.length;n++){let s=o[n];if(s!==0)for(let a=0;a<r.length;a++)o[n+a]^=fe(r[a],s)}return o.slice(e.length)}function ge(e,t,r){let o=[],n=[],[s,a,i,l]=r,c=0;for(let u=0;u<s;u++){let f=e.slice(c,c+a);o.push(f);let d=de(f,t);n.push(d),c+=a}for(let u=0;u<i;u++){let f=e.slice(c,c+l);o.push(f);let d=de(f,t);n.push(d),c+=l}return{dataBlocks:o,ecBlocks:n}}function me(e,t){let r=[],o=Math.max(...e.map(s=>s.length));for(let s=0;s<o;s++)for(let a of e)s<a.length&&r.push(a[s]);let n=Math.max(...t.map(s=>s.length));for(let s=0;s<n;s++)for(let a of t)s<a.length&&r.push(a[s]);return r}function pe(e){let t=R(e);return Array.from({length:t},()=>Array(t).fill(!1))}function he(e){let t=R(e),r=Array.from({length:t},()=>Array(t).fill(!1));for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[n][t-8+s]=!0;for(let n=0;n<=7;n++)for(let s=0;s<=7;s++)r[t-8+n][s]=!0;for(let n=8;n<t-8;n++)r[6][n]=!0,r[n][6]=!0;r[4*e+9][8]=!0;for(let n=0;n<6;n++)r[n][8]=!0;r[7][8]=!0,r[8][8]=!0;for(let n=t-8;n<t;n++)r[n][8]=!0;for(let n=0;n<9;n++)r[8][n]=!0;for(let n=t-8;n<t;n++)r[8][n]=!0;let o=I[e-1]||[];for(let n of o)for(let s of o)if(!(n<9&&s<9||n<9&&s>t-9||n>t-9&&s<9))for(let i=-2;i<=2;i++)for(let l=-2;l<=2;l++)r[n+i][s+l]=!0;if(e>=7){for(let n=0;n<6;n++)for(let s=t-11;s<t-8;s++)r[n][s]=!0;for(let n=t-11;n<t-8;n++)for(let s=0;s<6;s++)r[n][s]=!0}return r}function B(e,t,r){for(let o=-1;o<=7;o++)for(let n=-1;n<=7;n++){let s=t+o,a=r+n;if(s<0||s>=e.length||a<0||a>=e.length)continue;let i=o>=0&&o<=6&&n>=0&&n<=6&&(o===0||o===6||n===0||n===6),l=o>=2&&o<=4&&n>=2&&n<=4;e[s][a]=i||l}}function st(e,t,r){for(let o=-2;o<=2;o++)for(let n=-2;n<=2;n++){let s=o===-2||o===2||n===-2||n===2,a=o===0&&n===0;e[t+o][r+n]=s||a}}function be(e){let t=e.length;for(let r=8;r<t-8;r++)e[6][r]=r%2===0,e[r][6]=r%2===0}function ye(e){B(e,0,0),B(e,0,e.length-7),B(e,e.length-7,0)}function $e(e,t){let r=e.length,o=I[t-1]||[];for(let n of o)for(let s of o)n<9&&s<9||n<9&&s>r-9||n>r-9&&s<9||st(e,n,s)}function ve(e,t){e[4*t+9][8]=!0}function xe(e,t,r){let o=e.length,n=0,s=-1,a=o-1;for(let i=o-1;i>0;i-=2)for(i===6&&i--;;){for(let l=0;l<2;l++)if(!t[a][i-l]){let c=n<r.length?r[n]:!1;e[a][i-l]=c,n++}if(a+=s,a<0||o<=a){a-=s,s=-s;break}}}function F(e,t,r){let o=e.length;for(let n=0;n<o;n++)for(let s=0;s<o;s++){if(t[n][s])continue;let a=!1;switch(r){case 0:a=(n+s)%2===0;break;case 1:a=n%2===0;break;case 2:a=s%3===0;break;case 3:a=(n+s)%3===0;break;case 4:a=(Math.floor(n/2)+Math.floor(s/3))%2===0;break;case 5:a=n*s%2+n*s%3===0;break;case 6:a=(n*s%2+n*s%3)%2===0;break;case 7:a=((n+s)%2+n*s%3)%2===0;break}a&&(e[n][s]=!e[n][s])}}function at(e){let t=e.length,r=0;for(let a=0;a<t;a++){let i=e[a][0],l=e[0][a],c=1,u=1;for(let f=1;f<t;f++)e[a][f]===i?c++:(c>=5&&(r+=3+(c-5)),i=e[a][f],c=1),e[f][a]===l?u++:(u>=5&&(r+=3+(u-5)),l=e[f][a],u=1);c>=5&&(r+=3+(c-5)),u>=5&&(r+=3+(u-5))}for(let a=0;a<t-1;a++)for(let i=0;i<t-1;i++){let l=e[a][i];e[a][i+1]===l&&e[a+1][i]===l&&e[a+1][i+1]===l&&(r+=3)}for(let a=0;a<t;a++){let i=0,l=0;for(let c=0;c<t;c++)i=i<<1&2047|(e[a][c]?1:0),c>=10&&(i===1488||i===93)&&(r+=40),l=l<<1&2047|(e[c][a]?1:0),c>=10&&(l===1488||l===93)&&(r+=40)}let o=0,n=t*t;for(let a=0;a<t;a++)for(let i=0;i<t;i++)e[a][i]&&o++;let s=Math.abs(Math.ceil(o*100/n/5)-10);return r+=s*10,r}function Ce(e,t,r,o){let n=0,s=1/0;for(let a=0;a<8;a++){let i=e.map(c=>[...c]);F(i,t,a),o(i,r,a);let l=at(i);l<s&&(s=l,n=a)}return n}function Q(e,t,r){let o=e.length,n=L[t]<<3|r,s=n<<10;for(let i=0;i<5;i++)s&1<<14-i&&(s^=1335<<4-i);let a=(n<<10|s)^21522;for(let i=0;i<15;i++){let l=(a>>14-i&1)===1;i<=5?e[8][i]=l:i===6?e[8][7]=l:i===7?e[8][8]=l:i===8?e[7][8]=l:e[5-(i-9)][8]=l,i<=6?e[o-1-i][8]=l:e[8][o-8+(i-7)]=l}}function Re(e,t){if(t<7)return;let r=e.length,o=q[t-7];for(let n=0;n<18;n++){let s=(o>>n&1)===1,a=Math.floor(n/3),i=r-11+n%3;e[a][i]=s;let l=r-11+n%3,c=Math.floor(n/3);e[l][c]=s}}function we(e,t){return L[e]<<3|t}function Ee(e,t,r,o,n){let s=pe(e),a=he(e);ye(s),be(s),$e(s,e),ve(s,e),xe(s,a,r);let i=n?s.map(c=>[...c]):void 0,l=o??Ce(s,a,t,Q);return F(s,a,l),Q(s,t,l),Re(s,e),{matrix:s,mask:l,formatInfo:n?we(t,l):void 0,unmaskedMatrix:i}}function j(e,t,r){return e<7&&t<7||e<7&&t>=r-7||e>=r-7&&t<7}function Se(e){return[{x:0,y:0},{x:e-7,y:0},{x:0,y:e-7}]}function Ie(e,t){let o=Math.max(.1,Math.min(.3,t));return e*o}function it(e,t,r,o,n,s,a){let i=w[r]||w.square,l=i.renderSVG(e,t,7*a,o),c=i.renderSVG(e+a,t+a,5*a,s),u=i.renderSVG(e+2*a,t+2*a,3*a,n);return l+c+u}function lt(e,t,r,o){let n=o/2,s=e.trim();if(e.includes("data:image/svg")||s.startsWith("<svg")||s.startsWith("<?xml")){let i=e;if(e.includes("data:image/svg")){let g=e.match(/data:image\/svg\+xml[^,]*,(.+)/);if(g){let m=g[1];if(e.includes("base64"))try{if(typeof atob<"u")i=atob(m);else if(typeof Buffer<"u")i=Buffer.from(m,"base64").toString("utf-8");else return""}catch{return""}else try{i=decodeURIComponent(m)}catch{return""}}}let l=i.match(/viewBox=["']([^"']+)["']/),c=l?l[1]:"0 0 100 100",u=i.match(/<svg([\s\S]*?)>/i),f="";if(u){let g=u[1].match(/xmlns[^=]*=["'][^"']*["']/gi);g&&(f=" "+g.join(" "))}let d=i.replace(/<\?xml[^>]*>|<svg[\s\S]*?>|<\/svg>/gi,"");return`<g transform="translate(${t-n}, ${r-n})">
|
|
21
|
+
<svg width="${o}" height="${o}" viewBox="${c}"${f}>
|
|
22
22
|
${d}
|
|
23
23
|
</svg>
|
|
24
|
-
</g>`}else return`<image x="${
|
|
25
|
-
`;for(let i=0;i<
|
|
24
|
+
</g>`}else return`<image x="${t-n}" y="${r-n}" width="${o}" height="${o}" href="${e}" preserveAspectRatio="xMidYMid meet"/>`}function ct(e,t,r,o,n){let s=e.matrixSize,a="",i=E[r]||E.classic;if(r==="classic"){a=`<path fill="${o}" d="`;for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!j(l,c,s)){let u=c*t,f=l*t,d=n*t,g=(1-n)*t/2,m=u+g,h=f+g;a+=`M${m},${h}h${d}v${d}h${-d}z`}return a+='"/>',a}for(let l=0;l<s;l++)for(let c=0;c<s;c++)if(e.modules[l][c]&&!j(l,c,s)){let u=c*t,f=l*t,d=n*t,g=(1-n)*t/2,m=u+g,h=f+g,y={qrcode:e.modules,qrSize:s,row:l,col:c};a+=i.renderSVG(m,h,d,o,y)}return a}function Oe(e,t){let{size:r,margin:o,backgroundColor:n,eyes:s,pupils:a,dots:i}=t,l=r/e.matrixSize,c=t.border.shape==="none"?0:t.border.width,u=r+2*o+2*c,f=o+c,d=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${u} ${u}" width="${u}" height="${u}">`;if(d+=`<rect width="${u}" height="${u}" fill="${n}"/>`,t.border.shape!=="none"&&c>0){let b=D[t.border.shape];if(b){let v={borderWidth:c,borderStyle:t.border.style};d+=b.renderSVG(0,0,u,t.border.color,v)}}t.border.shape!=="none"&&c>0&&(d+=`<rect x="${f}" y="${f}" width="${r}" height="${r}" fill="${n}"/>`),d+=`<g transform="translate(${f}, ${f})">`;let g=Se(e.matrixSize),m="";for(let b of g)m+=it(b.x*l,b.y*l,s.shape,s.color,a.color,n,l);let h=ct(e,l,i.shape,i.color,i.scale);d+=m+h+"</g>";let y="";if(t.logo){let b=Ie(e.matrixSize,t.logo.scale)*l,v=u/2;y=lt(t.logo.src,v,v,b)}return d+=y+"</svg>",d}function De(e,t){let{margin:r,lightChar:o,darkChar:n}=t,s="",a=e.matrixSize+r*2;for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
25
|
+
`;for(let i=0;i<e.matrixSize;i++){s+=o.repeat(r);for(let l=0;l<e.matrixSize;l++)s+=e.modules[i][l]?n:o;s+=o.repeat(r)+`
|
|
26
26
|
`}for(let i=0;i<r;i++)s+=o.repeat(a)+`
|
|
27
|
-
`;return s}var
|
|
28
|
-
`)}function
|
|
29
|
-
`)}function
|
|
27
|
+
`;return s}var A=null,ke=!1;async function ut(){if(A)return A;if(ke)throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js");ke=!0;try{return A=(await import("@resvg/resvg-js")).Resvg,A}catch{throw new Error("PNG generation in Node.js requires @resvg/resvg-js. Install with: npm install @resvg/resvg-js")}}async function Me(e,t){let{output:r,size:o,margin:n,border:s}=t,a=s.shape==="none"?0:s.width,i=o+2*n+2*a,l=await ut(),f=new l(e,{fitTo:{mode:"width",value:i}}).render().asPng(),d=Buffer.from(f);return r.type==="dataURL"?`data:image/png;base64,${d.toString("base64")}`:d}async function Ae(e,t){let{format:r,type:o}=t.output;return r==="svg"?o==="string"?e:`data:image/svg+xml;charset=utf-8,${encodeURIComponent(e)}`:await Me(e,t)}function _(e){if(typeof e=="string")return e;switch(e.type){case"url":return dt(e.url);case"vcard":return ft(e.data);case"wifi":return gt(e.data);case"calendar":return mt(e.data);case"email":return pt(e.email,e.subject,e.body);case"sms":return ht(e.phone,e.message);case"phone":return bt(e.phone)}}function dt(e){return!e.startsWith("http://")&&!e.startsWith("https://")?`https://${e}`:e}function ft(e){let t=["BEGIN:VCARD","VERSION:3.0",`FN:${e.name}`];if(e.phone&&t.push(`TEL:${e.phone}`),e.email&&t.push(`EMAIL:${e.email}`),e.organization&&t.push(`ORG:${e.organization}`),e.url&&t.push(`URL:${e.url}`),e.title&&t.push(`TITLE:${e.title}`),e.note&&t.push(`NOTE:${e.note}`),e.address){let{street:r,city:o,state:n,zip:s,country:a}=e.address,i=["","",r||"",o||"",n||"",s||"",a||""];t.push(`ADR:${i.join(";")}`)}return t.push("END:VCARD"),t.join(`
|
|
28
|
+
`)}function gt(e){let t=e.encryption||"WPA",r=e.hidden?"H:true;":"",o=Le(e.ssid),n=Le(e.password);return`WIFI:T:${t};S:${o};P:${n};${r};`}function Le(e){return e.replace(/([\\;,":])/g,"\\$1")}function mt(e){let t=o=>(typeof o=="string"?new Date(o):o).toISOString().replace(/[-:]/g,"").split(".")[0]+"Z",r=["BEGIN:VCALENDAR","VERSION:2.0","BEGIN:VEVENT",`SUMMARY:${e.title}`,`DTSTART:${t(e.startDate)}`,`DTEND:${t(e.endDate)}`];return e.location&&r.push(`LOCATION:${e.location}`),e.description&&r.push(`DESCRIPTION:${e.description}`),r.push("END:VEVENT","END:VCALENDAR"),r.join(`
|
|
29
|
+
`)}function pt(e,t,r){let o=`mailto:${e}`,n=[];return t&&n.push(`subject=${encodeURIComponent(t)}`),r&&n.push(`body=${encodeURIComponent(r)}`),n.length>0&&(o+=`?${n.join("&")}`),o}function ht(e,t){return t?`sms:${e}:${t}`:`sms:${e}`}function bt(e){return`tel:${e}`}function yt(e,t){let r=[];for(let n of e)for(let s=7;s>=0;s--)r.push((n>>s&1)===1);let o=z[t-1];for(let n=0;n<o;n++)r.push(!1);return r}function Te(e,t){if(!e)throw new Error("QR Code input cannot be empty. Please provide text or structured content to encode.");let r=ue(e,t),o=x[r],n=M(e,o);if(n<1||n>10)throw new Error(`Input data is too large for QR code version 10. Data length: ${e.length} characters. Maximum capacity at EC level ${r}: ~${x[r][9]} bytes. Try reducing input length or removing logo for higher capacity.`);let s=ce(e,n,o[n-1]),a=U[r][n-1],i=W[r][n-1],{dataBlocks:l,ecBlocks:c}=ge(s,a,i),u=me(l,c),f=yt(u,n),{matrix:d,mask:g}=Ee(n,r,f);return{version:n,matrixSize:R(n),modules:d,mask:g,errorCorrectionLevel:r}}async function $t(e,t){V(e);let r=_(e),o=ae(t),n=Te(r,!!o.logo),s=Oe(n,o);return await Ae(s,o)}function vt(e,t){V(e);let r=_(e),o=ie(t),n=Te(r,!1);return De(n,o)}export{Y as BorderShape,Z as BorderStyle,H as DotShape,G as EyeFrameShape,$ as QRValidationError,$t as genQrImage,vt as genQrText};
|