Socket
Socket
Sign inDemoInstall

easyqrcodejs-nodejs

Package Overview
Dependencies
113
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.2.0

207

index.js

@@ -6,3 +6,3 @@ /**

*
* Version 4.0.0
* Version 4.2.0
*

@@ -1103,10 +1103,9 @@ * @author [ inthinkcolor@gmail.com ]

this._htOption.width = nWidth * nCount;
this._htOption.height = nHeight * nCount + _htOption.titleHeight;
_htOption.width = nWidth * nCount;
_htOption.height = nHeight * nCount + _htOption.titleHeight;
this._canvas.width = _htOption.width + _htOption.quietZone * 2;
this._canvas.height = _htOption.height + _htOption.quietZone * 2;
this._canvas.width = this._htOption.width + this._htOption.quietZone * 2;
this._canvas.height = this._htOption.height + this._htOption.quietZone * 2;
if (this._htOption._drawer == 'svg') {
if (_htOption._drawer == 'svg') {
this._oContext = new C2S({

@@ -1127,4 +1126,4 @@ document: win.document,

var autoColorDark = "rgba(0, 0, 0, .6)";
var autoColorLight = "rgba(255, 255, 255, .7)";
var autoColorDark = _htOption.autoColorDark;
var autoColorLight = _htOption.autoColorLight;
var notAutoColorLight = "rgba(0,0,0,0)";

@@ -1135,6 +1134,2 @@

if (_htOption.quietZoneColor == 'transparent') {
_htOption.quietZoneColor = '#ffffff';
}
_htOption.logoBackgroundTransparent = false;

@@ -1146,7 +1141,16 @@

_oContext.fillStyle = "#ffffff";
_oContext.fillRect(0, 0, this._canvas.width, this._canvas.height);
if (_htOption.backgroundImage) {
_oContext.fillStyle = _htOption.colorLight;
_oContext.fillRect(0, 0, this._canvas.width, this._canvas.height);
} else {
if (_htOption.quietZoneColor == "rgba(0,0,0,0)" || _htOption.quietZoneColor == "transparent") {
_htOption.quietZoneColor = '#ffffff';
}
_oContext.fillStyle = _htOption.colorLight;
_oContext.fillRect(0, 0, this._canvas.width, this._canvas.height);
}
} else {
_oContext.lineWidth = 0;
_oContext.fillStyle = this._htOption.colorLight;
_oContext.fillStyle = _htOption.colorLight;
_oContext.fillRect(0, 0, this._canvas.width, this._canvas.height);

@@ -1194,3 +1198,2 @@ }

function drawQrcode(oQRCode) {
for (var row = 0; row < nCount; row++) {

@@ -1205,28 +1208,69 @@ for (var col = 0; col < nCount; col++) {

var nowDotScale = _htOption.dotScale;
_oContext.lineWidth = 0;
// Color handler
var dColor;
var lColor;
if (eye) {
dColor = _htOption[eye.type] || _htOption[eye.type.substring(
0, 2)] ||
_htOption.colorDark;
lColor = _htOption.colorLight;
} else {
if (_htOption.backgroundImage) {
lColor = "rgba(0,0,0,0)";
if (row == 6) {
dColor = _htOption.timing_H || _htOption.timing || _htOption.colorDark;
} else if (col == 6) {
dColor = _htOption.timing_V || _htOption.timing ||
_htOption.colorDark;
} else {
if (_htOption.autoColor) {
dColor = _htOption.autoColorDark;
lColor = _htOption.autoColorLight;
} else {
dColor = _htOption.colorDark;
}
}
} else {
if (row == 6) {
dColor = _htOption.timing_H || _htOption.timing || _htOption.colorDark;
} else if (col == 6) {
dColor = _htOption.timing_V || _htOption.timing ||
_htOption.colorDark;
} else {
dColor = _htOption.colorDark;
}
lColor = _htOption.colorLight;
}
}
_oContext.strokeStyle = bIsDark ? dColor :
lColor;
_oContext.fillStyle = bIsDark ? dColor :
lColor;
if (eye) {
// Is eye
bIsDark = eye.isDarkBlock;
var type = eye.type;
if (type == 'AO') {
nowDotScale = _htOption.dotScaleAO;
} else if (type == 'AI') {
nowDotScale = _htOption.dotScaleAI;
} else {
nowDotScale = 1;
}
// PX_XX, PX, colorDark, colorLight
var eyeColorDark = _htOption[type] || _htOption[type.substring(0, 2)] || _htOption.colorDark;
_oContext.lineWidth = 0;
_oContext.strokeStyle = bIsDark ? eyeColorDark : _htOption.colorLight;
_oContext.fillStyle = bIsDark ? eyeColorDark : _htOption.colorLight;
_oContext.fillRect(nLeft, _htOption.titleHeight + nTop, nWidth, nHeight);
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop +
nHeight * (1 - nowDotScale) / 2, nWidth * nowDotScale, nHeight * nowDotScale);
} else {
_oContext.lineWidth = 0;
_oContext.strokeStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
_oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
var nowDotScale = _htOption.dotScale;
if (row == 6) {
// Timing Pattern
nowDotScale = 1;
var timingHColorDark = _htOption.timing_H || _htOption.timing || _htOption.colorDark;
_oContext.fillStyle = bIsDark ? timingHColorDark : _htOption.colorLight;
_oContext.strokeStyle = _oContext.fillStyle;
nowDotScale = _htOption.dotScaleTiming_H;
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop +

@@ -1237,6 +1281,4 @@ nHeight * (1 -

// Timing Pattern
nowDotScale = 1;
var timingVColorDark = _htOption.timing_V || _htOption.timing || _htOption.colorDark;
_oContext.fillStyle = bIsDark ? timingVColorDark : _htOption.colorLight;
_oContext.strokeStyle = _oContext.fillStyle;
nowDotScale = _htOption.dotScaleTiming_V;
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop +

@@ -1249,9 +1291,2 @@ nHeight * (1 -

if (_htOption.autoColor) {
_oContext.strokeStyle = bIsDark ? autoColorDark : autoColorLight;
_oContext.fillStyle = bIsDark ? autoColorDark : autoColorLight;
} else {
_oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
_oContext.strokeStyle = _oContext.fillStyle;
}
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop +

@@ -1262,4 +1297,4 @@ nHeight * (1 -

} else {
_oContext.strokeStyle = _oContext.fillStyle;
_oContext.fillRect(nLeft + nWidth * (1 - nowDotScale) / 2, _htOption.titleHeight + nTop +

@@ -1483,6 +1518,14 @@ nHeight * (1 -

dotScale: 1, // Must be greater than 0, less than or equal to 1. default is 1
dotScale: 1, // For body block, must be greater than 0, less than or equal to 1. default is 1
dotScaleTiming: 1, // Dafault for timing block , must be greater than 0, less than or equal to 1. default is 1
dotScaleTiming_H: undefined, // For horizontal timing block, must be greater than 0, less than or equal to 1. default is 1
dotScaleTiming_V: undefined, // For vertical timing block, must be greater than 0, less than or equal to 1. default is 1
dotScaleA: 1, // Dafault for alignment block, must be greater than 0, less than or equal to 1. default is 1
dotScaleAO: undefined, // For alignment outer block, must be greater than 0, less than or equal to 1. default is 1
dotScaleAI: undefined, // For alignment inner block, must be greater than 0, less than or equal to 1. default is 1
quietZone: 0,
quietZoneColor: 'transparent',
quietZoneColor: "rgba(0,0,0,0)",

@@ -1529,3 +1572,5 @@ title: "",

backgroundImageAlpha: 1, // Background image transparency, value between 0 and 1. default is 1.
autoColor: false,
autoColor: false, // Automatic color adjustment(for data block)
autoColorDark: "rgba(0, 0, 0, .6)", // Automatic color: dark CSS color
autoColorLight: "rgba(255, 255, 255, .7)", // Automatic: color light CSS color

@@ -1585,2 +1630,62 @@ // ==== Event Handler

}
if (this._htOption.dotScaleTiming < 0 || this._htOption.dotScaleTiming > 1) {
console.warn(this._htOption.dotScaleTiming +
" , is invalidate, dotScaleTiming must greater than 0, less than or equal to 1, now reset to 1. "
)
this._htOption.dotScaleTiming = 1;
}
if (this._htOption.dotScaleTiming_H) {
if (this._htOption.dotScaleTiming_H < 0 || this._htOption.dotScaleTiming_H > 1) {
console.warn(this._htOption.dotScaleTiming_H +
" , is invalidate, dotScaleTiming_H must greater than 0, less than or equal to 1, now reset to 1. "
)
this._htOption.dotScaleTiming_H = 1;
}
} else {
this._htOption.dotScaleTiming_H = this._htOption.dotScaleTiming;
}
if (this._htOption.dotScaleTiming_V) {
if (this._htOption.dotScaleTiming_V < 0 || this._htOption.dotScaleTiming_V > 1) {
console.warn(this._htOption.dotScaleTiming_V +
" , is invalidate, dotScaleTiming_V must greater than 0, less than or equal to 1, now reset to 1. "
)
this._htOption.dotScaleTiming_V = 1;
}
} else {
this._htOption.dotScaleTiming_V = this._htOption.dotScaleTiming;
}
if (this._htOption.dotScaleA < 0 || this._htOption.dotScaleA > 1) {
console.warn(this._htOption.dotScaleA +
" , is invalidate, dotScaleA must greater than 0, less than or equal to 1, now reset to 1. "
)
this._htOption.dotScaleA = 1;
}
if (this._htOption.dotScaleAO) {
if (this._htOption.dotScaleAO < 0 || this._htOption.dotScaleAO > 1) {
console.warn(this._htOption.dotScaleAO +
" , is invalidate, dotScaleAO must greater than 0, less than or equal to 1, now reset to 1. "
)
this._htOption.dotScaleAO = 1;
}
} else {
this._htOption.dotScaleAO = this._htOption.dotScaleA;
}
if (this._htOption.dotScaleAI) {
if (this._htOption.dotScaleAI < 0 || this._htOption.dotScaleAI > 1) {
console.warn(this._htOption.dotScaleAI +
" , is invalidate, dotScaleAI must greater than 0, less than or equal to 1, now reset to 1. "
)
this._htOption.dotScaleAI = 1;
}
} else {
this._htOption.dotScaleAI = this._htOption.dotScaleA;
}
if (this._htOption.backgroundImageAlpha < 0 || this._htOption.backgroundImageAlpha > 1) {

@@ -1606,3 +1711,3 @@ console.warn(this._htOption.backgroundImageAlpha +

QRCode.prototype._toSave = function(saveOptions) {
var _oDrawing = new Drawing(this._htOption);
var _oDrawing = new Drawing(Object.assign({}, this._htOption));
_oDrawing.makeOptions = saveOptions;

@@ -1657,3 +1762,3 @@

var _oDrawing = new Drawing(this._htOption);
var _oDrawing = new Drawing(Object.assign({}, this._htOption));
_oDrawing.makeOptions = defOptions;

@@ -1660,0 +1765,0 @@

@@ -6,3 +6,3 @@ /**

*
* Version 4.0.0
* Version 4.2.0
*

@@ -21,2 +21,2 @@ * @author [ inthinkcolor@gmail.com ]

*/
var{createCanvas:createCanvas,loadImage:loadImage,Image:Image}=require("canvas"),jsdom=require("jsdom"),C2S=require("./canvas2svg"),fs=require("fs");const{JSDOM:JSDOM}=jsdom,win=(new JSDOM).window;function QR8bitByte(t,e){this.mode=QRMode.MODE_8BIT_BYTE,this.data=t,this.parsedData=[];for(var o=0,i=this.data.length;o<i;o++){var r=[],n=this.data.charCodeAt(o);e?r[0]=n:n>65536?(r[0]=240|(1835008&n)>>>18,r[1]=128|(258048&n)>>>12,r[2]=128|(4032&n)>>>6,r[3]=128|63&n):n>2048?(r[0]=224|(61440&n)>>>12,r[1]=128|(4032&n)>>>6,r[2]=128|63&n):n>128?(r[0]=192|(1984&n)>>>6,r[1]=128|63&n):r[0]=n,this.parsedData.push(r)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function QRCodeModel(t,e){this.typeNumber=t,this.errorCorrectLevel=e,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}QR8bitByte.prototype={getLength:function(t){return this.parsedData.length},write:function(t){for(var e=0,o=this.parsedData.length;e<o;e++)t.put(this.parsedData[e],8)}},QRCodeModel.prototype={addData:function(t,e){var o=new QR8bitByte(t,e);this.dataList.push(o),this.dataCache=null},isDark:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);return this.modules[t][e][0]},getEye:function(t,e){if(t<0||this.moduleCount<=t||e<0||this.moduleCount<=e)throw new Error(t+","+e);var o=this.modules[t][e];if(o[1]){var i="P"+o[1]+"_"+o[2];return"A"==o[2]&&(i="A"+o[1]),{isDarkBlock:o[0],type:i}}return null},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var o=0;o<this.moduleCount;o++){this.modules[o]=new Array(this.moduleCount);for(var i=0;i<this.moduleCount;i++)this.modules[o][i]=[]}this.setupPositionProbePattern(0,0,"TL"),this.setupPositionProbePattern(this.moduleCount-7,0,"BL"),this.setupPositionProbePattern(0,this.moduleCount-7,"TR"),this.setupPositionAdjustPattern("A"),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),null==this.dataCache&&(this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,e)},setupPositionProbePattern:function(t,e,o){for(var i=-1;i<=7;i++)if(!(t+i<=-1||this.moduleCount<=t+i))for(var r=-1;r<=7;r++)e+r<=-1||this.moduleCount<=e+r||(0<=i&&i<=6&&(0==r||6==r)||0<=r&&r<=6&&(0==i||6==i)||2<=i&&i<=4&&2<=r&&r<=4?(this.modules[t+i][e+r][0]=!0,this.modules[t+i][e+r][2]=o,this.modules[t+i][e+r][1]=-0==i||-0==r||6==i||6==r?"O":"I"):this.modules[t+i][e+r][0]=!1)},getBestMaskPattern:function(){for(var t=0,e=0,o=0;o<8;o++){this.makeImpl(!0,o);var i=QRUtil.getLostPoint(this);(0==o||t>i)&&(t=i,e=o)}return e},createMovieClip:function(t,e,o){var i=t.createEmptyMovieClip(e,o);this.make();for(var r=0;r<this.modules.length;r++)for(var n=1*r,a=0;a<this.modules[r].length;a++){var s=1*a;this.modules[r][a][0]&&(i.beginFill(0,100),i.moveTo(s,n),i.lineTo(s+1,n),i.lineTo(s+1,n+1),i.lineTo(s,n+1),i.endFill())}return i},setupTimingPattern:function(){for(var t=8;t<this.moduleCount-8;t++)null==this.modules[t][6][0]&&(this.modules[t][6][0]=t%2==0);for(var e=8;e<this.moduleCount-8;e++)null==this.modules[6][e][0]&&(this.modules[6][e][0]=e%2==0)},setupPositionAdjustPattern:function(t){for(var e=QRUtil.getPatternPosition(this.typeNumber),o=0;o<e.length;o++)for(var i=0;i<e.length;i++){var r=e[o],n=e[i];if(null==this.modules[r][n][0])for(var a=-2;a<=2;a++)for(var s=-2;s<=2;s++)-2==a||2==a||-2==s||2==s||0==a&&0==s?(this.modules[r+a][n+s][0]=!0,this.modules[r+a][n+s][2]=t,this.modules[r+a][n+s][1]=-2==a||-2==s||2==a||2==s?"O":"I"):this.modules[r+a][n+s][0]=!1}},setupTypeNumber:function(t){for(var e=QRUtil.getBCHTypeNumber(this.typeNumber),o=0;o<18;o++){var i=!t&&1==(e>>o&1);this.modules[Math.floor(o/3)][o%3+this.moduleCount-8-3][0]=i}for(o=0;o<18;o++){i=!t&&1==(e>>o&1);this.modules[o%3+this.moduleCount-8-3][Math.floor(o/3)][0]=i}},setupTypeInfo:function(t,e){for(var o=this.errorCorrectLevel<<3|e,i=QRUtil.getBCHTypeInfo(o),r=0;r<15;r++){var n=!t&&1==(i>>r&1);r<6?this.modules[r][8][0]=n:r<8?this.modules[r+1][8][0]=n:this.modules[this.moduleCount-15+r][8][0]=n}for(r=0;r<15;r++){n=!t&&1==(i>>r&1);r<8?this.modules[8][this.moduleCount-r-1][0]=n:r<9?this.modules[8][15-r-1+1][0]=n:this.modules[8][15-r-1][0]=n}this.modules[this.moduleCount-8][8][0]=!t},mapData:function(t,e){for(var o=-1,i=this.moduleCount-1,r=7,n=0,a=this.moduleCount-1;a>0;a-=2)for(6==a&&a--;;){for(var s=0;s<2;s++)if(null==this.modules[i][a-s][0]){var h=!1;n<t.length&&(h=1==(t[n]>>>r&1)),QRUtil.getMask(e,i,a-s)&&(h=!h),this.modules[i][a-s][0]=h,-1==--r&&(n++,r=7)}if((i+=o)<0||this.moduleCount<=i){i-=o,o=-o;break}}}},QRCodeModel.PAD0=236,QRCodeModel.PAD1=17,QRCodeModel.createData=function(t,e,o){for(var i=QRRSBlock.getRSBlocks(t,e),r=new QRBitBuffer,n=0;n<o.length;n++){var a=o[n];r.put(a.mode,4),r.put(a.getLength(),QRUtil.getLengthInBits(a.mode,t)),a.write(r)}var s=0;for(n=0;n<i.length;n++)s+=i[n].dataCount;if(r.getLengthInBits()>8*s)throw new Error("code length overflow. ("+r.getLengthInBits()+">"+8*s+")");for(r.getLengthInBits()+4<=8*s&&r.put(0,4);r.getLengthInBits()%8!=0;)r.putBit(!1);for(;!(r.getLengthInBits()>=8*s||(r.put(QRCodeModel.PAD0,8),r.getLengthInBits()>=8*s));)r.put(QRCodeModel.PAD1,8);return QRCodeModel.createBytes(r,i)},QRCodeModel.createBytes=function(t,e){for(var o=0,i=0,r=0,n=new Array(e.length),a=new Array(e.length),s=0;s<e.length;s++){var h=e[s].dataCount,l=e[s].totalCount-h;i=Math.max(i,h),r=Math.max(r,l),n[s]=new Array(h);for(var u=0;u<n[s].length;u++)n[s][u]=255&t.buffer[u+o];o+=h;var g=QRUtil.getErrorCorrectPolynomial(l),d=new QRPolynomial(n[s],g.getLength()-1).mod(g);a[s]=new Array(g.getLength()-1);for(u=0;u<a[s].length;u++){var c=u+d.getLength()-a[s].length;a[s][u]=c>=0?d.get(c):0}}var f=0;for(u=0;u<e.length;u++)f+=e[u].totalCount;var p=new Array(f),v=0;for(u=0;u<i;u++)for(s=0;s<e.length;s++)u<n[s].length&&(p[v++]=n[s][u]);for(u=0;u<r;u++)for(s=0;s<e.length;s++)u<a[s].length&&(p[v++]=a[s][u]);return p};for(var QRMode={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},QRErrorCorrectLevel={L:1,M:0,Q:3,H:2},QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},QRUtil={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(t){for(var e=t<<10;QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G15)>=0;)e^=QRUtil.G15<<QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G15);return(t<<10|e)^QRUtil.G15_MASK},getBCHTypeNumber:function(t){for(var e=t<<12;QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G18)>=0;)e^=QRUtil.G18<<QRUtil.getBCHDigit(e)-QRUtil.getBCHDigit(QRUtil.G18);return t<<12|e},getBCHDigit:function(t){for(var e=0;0!=t;)e++,t>>>=1;return e},getPatternPosition:function(t){return QRUtil.PATTERN_POSITION_TABLE[t-1]},getMask:function(t,e,o){switch(t){case QRMaskPattern.PATTERN000:return(e+o)%2==0;case QRMaskPattern.PATTERN001:return e%2==0;case QRMaskPattern.PATTERN010:return o%3==0;case QRMaskPattern.PATTERN011:return(e+o)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(e/2)+Math.floor(o/3))%2==0;case QRMaskPattern.PATTERN101:return e*o%2+e*o%3==0;case QRMaskPattern.PATTERN110:return(e*o%2+e*o%3)%2==0;case QRMaskPattern.PATTERN111:return(e*o%3+(e+o)%2)%2==0;default:throw new Error("bad maskPattern:"+t)}},getErrorCorrectPolynomial:function(t){for(var e=new QRPolynomial([1],0),o=0;o<t;o++)e=e.multiply(new QRPolynomial([1,QRMath.gexp(o)],0));return e},getLengthInBits:function(t,e){if(1<=e&&e<10)switch(t){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:case QRMode.MODE_KANJI:return 8;default:throw new Error("mode:"+t)}else if(e<27)switch(t){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw new Error("mode:"+t)}else{if(!(e<41))throw new Error("type:"+e);switch(t){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw new Error("mode:"+t)}}},getLostPoint:function(t){for(var e=t.getModuleCount(),o=0,i=0;i<e;i++)for(var r=0;r<e;r++){for(var n=0,a=t.isDark(i,r),s=-1;s<=1;s++)if(!(i+s<0||e<=i+s))for(var h=-1;h<=1;h++)r+h<0||e<=r+h||0==s&&0==h||a==t.isDark(i+s,r+h)&&n++;n>5&&(o+=3+n-5)}for(i=0;i<e-1;i++)for(r=0;r<e-1;r++){var l=0;t.isDark(i,r)&&l++,t.isDark(i+1,r)&&l++,t.isDark(i,r+1)&&l++,t.isDark(i+1,r+1)&&l++,0!=l&&4!=l||(o+=3)}for(i=0;i<e;i++)for(r=0;r<e-6;r++)t.isDark(i,r)&&!t.isDark(i,r+1)&&t.isDark(i,r+2)&&t.isDark(i,r+3)&&t.isDark(i,r+4)&&!t.isDark(i,r+5)&&t.isDark(i,r+6)&&(o+=40);for(r=0;r<e;r++)for(i=0;i<e-6;i++)t.isDark(i,r)&&!t.isDark(i+1,r)&&t.isDark(i+2,r)&&t.isDark(i+3,r)&&t.isDark(i+4,r)&&!t.isDark(i+5,r)&&t.isDark(i+6,r)&&(o+=40);var u=0;for(r=0;r<e;r++)for(i=0;i<e;i++)t.isDark(i,r)&&u++;return o+=10*(Math.abs(100*u/e/e-50)/5)}},QRMath={glog:function(t){if(t<1)throw new Error("glog("+t+")");return QRMath.LOG_TABLE[t]},gexp:function(t){for(;t<0;)t+=255;for(;t>=256;)t-=255;return QRMath.EXP_TABLE[t]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<<i;for(i=8;i<256;i++)QRMath.EXP_TABLE[i]=QRMath.EXP_TABLE[i-4]^QRMath.EXP_TABLE[i-5]^QRMath.EXP_TABLE[i-6]^QRMath.EXP_TABLE[i-8];for(i=0;i<255;i++)QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;function QRPolynomial(t,e){if(void 0==t.length)throw new Error(t.length+"/"+e);for(var o=0;o<t.length&&0==t[o];)o++;this.num=new Array(t.length-o+e);for(var i=0;i<t.length-o;i++)this.num[i]=t[i+o]}function QRRSBlock(t,e){this.totalCount=t,this.dataCount=e}function QRBitBuffer(){this.buffer=[],this.length=0}QRPolynomial.prototype={get:function(t){return this.num[t]},getLength:function(){return this.num.length},multiply:function(t){for(var e=new Array(this.getLength()+t.getLength()-1),o=0;o<this.getLength();o++)for(var i=0;i<t.getLength();i++)e[o+i]^=QRMath.gexp(QRMath.glog(this.get(o))+QRMath.glog(t.get(i)));return new QRPolynomial(e,0)},mod:function(t){if(this.getLength()-t.getLength()<0)return this;for(var e=QRMath.glog(this.get(0))-QRMath.glog(t.get(0)),o=new Array(this.getLength()),i=0;i<this.getLength();i++)o[i]=this.get(i);for(i=0;i<t.getLength();i++)o[i]^=QRMath.gexp(QRMath.glog(t.get(i))+e);return new QRPolynomial(o,0).mod(t)}},QRRSBlock.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],QRRSBlock.getRSBlocks=function(t,e){var o=QRRSBlock.getRsBlockTable(t,e);if(void 0==o)throw new Error("bad rs block @ typeNumber:"+t+"/errorCorrectLevel:"+e);for(var i=o.length/3,r=[],n=0;n<i;n++)for(var a=o[3*n+0],s=o[3*n+1],h=o[3*n+2],l=0;l<a;l++)r.push(new QRRSBlock(s,h));return r},QRRSBlock.getRsBlockTable=function(t,e){switch(e){case QRErrorCorrectLevel.L:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+0];case QRErrorCorrectLevel.M:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+1];case QRErrorCorrectLevel.Q:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+2];case QRErrorCorrectLevel.H:return QRRSBlock.RS_BLOCK_TABLE[4*(t-1)+3];default:return}},QRBitBuffer.prototype={get:function(t){var e=Math.floor(t/8);return 1==(this.buffer[e]>>>7-t%8&1)},put:function(t,e){for(var o=0;o<e;o++)this.putBit(1==(t>>>e-o-1&1))},getLengthInBits:function(){return this.length},putBit:function(t){var e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),t&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function _getTypeNumber(t,e){for(var o=e.correctLevel,i=1,r=_getUTF8Length(t),n=0,a=QRCodeLimitLength.length;n<=a;n++){var s=0;switch(o){case QRErrorCorrectLevel.L:s=QRCodeLimitLength[n][0];break;case QRErrorCorrectLevel.M:s=QRCodeLimitLength[n][1];break;case QRErrorCorrectLevel.Q:s=QRCodeLimitLength[n][2];break;case QRErrorCorrectLevel.H:s=QRCodeLimitLength[n][3]}if(r<=s)break;i++}if(i>QRCodeLimitLength.length)throw new Error("Too long data");return 0!=e.version&&(i<=e.version?(i=e.version,e.runVersion=i):(console.warn("QR Code version "+e.version+" too small, run version use "+i),e.runVersion=i)),i}function _getUTF8Length(t){var e=encodeURI(t).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return e.length+(e.length!=t.length?3:0)}var Drawing=function(t){this._bIsPainted=!1,this._htOption=t,this._canvas=createCanvas(200,200),"svg"==this._htOption._drawer?this._oContext={}:this._oContext=this._canvas.getContext("2d"),this._bSupportDataURI=null};function QRCode(t){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRErrorCorrectLevel.H,dotScale:1,quietZone:0,quietZoneColor:"transparent",title:"",titleFont:"bold 16px Arial",titleColor:"#000000",titleBackgroundColor:"#ffffff",titleHeight:0,titleTop:30,subTitle:"",subTitleFont:"14px Arial",subTitleColor:"#4F4F4F",subTitleTop:60,logo:void 0,logoWidth:void 0,logoHeight:void 0,logoBackgroundColor:"#ffffff",logoBackgroundTransparent:!1,PO:void 0,PI:void 0,PO_TL:void 0,PI_TL:void 0,PO_TR:void 0,PI_TR:void 0,PO_BL:void 0,PI_BL:void 0,AO:void 0,AI:void 0,timing:void 0,timing_H:void 0,timing_V:void 0,backgroundImage:void 0,backgroundImageAlpha:1,autoColor:!1,onRenderingStart:void 0,format:"PNG",compressionLevel:6,quality:.75,version:0,binary:!1},"string"==typeof t&&(t={text:t}),t)for(var e in t)this._htOption[e]=t[e];(this._htOption.version<0||this._htOption.version>40)&&(console.warn("QR Code version '"+this._htOption.version+"' is invalidate, reset to 0"),this._htOption.version=0),this._htOption.format=this._htOption.format.toUpperCase(),"PNG"!=this._htOption.format&&"JPG"!=this._htOption.format&&(console.warn("Image format '"+this._htOption.format+"' is invalidate, reset to 'PNG'"),this._htOption.format="PNG"),"PNG"==this._htOption.format&&(this._htOption.compressionLevel<0||this._htOption.compressionLevel>9)?(console.warn(this._htOption.compressionLevel+" is invalidate, PNG compressionLevel must between 0 and 9, now reset to 6. "),this._htOption.compressionLevel=1):(this._htOption.quality<0||this._htOption.quality>1)&&(console.warn(this._htOption.quality+" is invalidate, JPG quality must between 0 and 1, now reset to 0.75. "),this._htOption.quality=.75),(this._htOption.dotScale<0||this._htOption.dotScale>1)&&(console.warn(this._htOption.dotScale+" , is invalidate, dotScale must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScale=1),(this._htOption.backgroundImageAlpha<0||this._htOption.backgroundImageAlpha>1)&&(console.warn(this._htOption.backgroundImageAlpha+" , is invalidate, backgroundImageAlpha must between 0 and 1, now reset to 1. "),this._htOption.backgroundImageAlpha=1),(!this._htOption.drawer||"svg"!=this._htOption.drawer&&"canvas"!=this._htOption.drawer)&&(this._htOption.drawer="canvas"),this._htOption.height=this._htOption.height+this._htOption.titleHeight,this._oQRCode=null,this._oQRCode=new QRCodeModel(_getTypeNumber(this._htOption.text,this._htOption),this._htOption.correctLevel),this._oQRCode.addData(this._htOption.text,this._htOption.binary),this._oQRCode.make()}Drawing.prototype.draw=function(t){var e=this._htOption;e.title||e.subTitle||(e.height-=e.titleHeight,e.titleHeight=0);var o=t.getModuleCount(),i=Math.round(e.width/o),r=Math.round((e.height-e.titleHeight)/o);e.quietZone=Math.round(e.quietZone),this._htOption.width=i*o,this._htOption.height=r*o+e.titleHeight,this._canvas.width=this._htOption.width+2*this._htOption.quietZone,this._canvas.height=this._htOption.height+2*this._htOption.quietZone,"svg"==this._htOption._drawer&&(this._oContext=new C2S({document:win.document,XMLSerializer:win.XMLSerializer,width:this._canvas.width,height:this._canvas.height})),this._oContext.patternQuality="best",this._oContext.quality="best",this._oContext.textDrawingMode="path",this._oContext.antialias="gray";var n=this._oContext,a="rgba(0, 0, 0, .6)",s="rgba(255, 255, 255, .7)";"JPG"==e.format?("transparent"==e.quietZoneColor&&(e.quietZoneColor="#ffffff"),e.logoBackgroundTransparent=!1,a=e.colorDark,s=e.colorLight,e.colorLight,n.fillStyle="#ffffff",n.fillRect(0,0,this._canvas.width,this._canvas.height)):(n.lineWidth=0,n.fillStyle=this._htOption.colorLight,n.fillRect(0,0,this._canvas.width,this._canvas.height));var h=this;function l(){n.lineWidth=0,n.fillStyle=e.quietZoneColor,n.fillRect(0,0,h._canvas.width,e.quietZone),n.fillRect(0,e.quietZone,e.quietZone,h._canvas.height-2*e.quietZone),n.fillRect(h._canvas.width-e.quietZone,e.quietZone,e.quietZone,h._canvas.height-2*e.quietZone),n.fillRect(0,h._canvas.height-e.quietZone,h._canvas.width,e.quietZone)}if(e.backgroundImage){var u=new Image;u.onload=function(){n.globalAlpha=1,n.globalAlpha=e.backgroundImageAlpha,n.drawImage(u,0,e.titleHeight,e.width+2*e.quietZone,e.height+2*e.quietZone-e.titleHeight),n.globalAlpha=1,g.call(h,t)},u.src=e.backgroundImage}else g.call(h,t);function g(t){for(var u=0;u<o;u++)for(var g=0;g<o;g++){var d=g*i+e.quietZone,c=u*r+e.quietZone,f=t.isDark(u,g),p=t.getEye(u,g);if(p){f=p.isDarkBlock;var v=p.type,R=e[v]||e[v.substring(0,2)]||e.colorDark;n.lineWidth=0,n.strokeStyle=f?R:e.colorLight,n.fillStyle=f?R:e.colorLight,n.fillRect(d,e.titleHeight+c,i,r)}else{n.lineWidth=0,n.strokeStyle=f?e.colorDark:e.colorLight,n.fillStyle=f?e.colorDark:e.colorLight;var m=e.dotScale;if(6==u){m=1;var _=e.timing_H||e.timing||e.colorDark;n.fillStyle=f?_:e.colorLight,n.strokeStyle=n.fillStyle,n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m)}else if(6==g){m=1;var C=e.timing_V||e.timing||e.colorDark;n.fillStyle=f?C:e.colorLight,n.strokeStyle=n.fillStyle,n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m)}else e.backgroundImage?(e.autoColor?(n.strokeStyle=f?a:s,n.fillStyle=f?a:s):(n.fillStyle=f?e.colorDark:e.colorLight,n.strokeStyle=n.fillStyle),n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m)):(n.strokeStyle=n.fillStyle,n.fillRect(d+i*(1-m)/2,e.titleHeight+c+r*(1-m)/2,i*m,r*m))}1==e.dotScale||p||(n.strokeStyle=e.colorLight)}if(e.title&&(n.fillStyle=e.titleBackgroundColor,n.fillRect(0,0,h._canvas.width,e.titleHeight+this._htOption.quietZone),n.font=e.titleFont,n.fillStyle=e.titleColor,n.textAlign="center",n.fillText(e.title,h._canvas.width/2,this._htOption.quietZone+this._htOption.titleTop)),e.subTitle&&(n.font=e.subTitleFont,n.fillStyle=e.subTitleColor,n.fillText(e.subTitle,h._canvas.width/2,this._htOption.quietZone+this._htOption.subTitleTop)),e.logo){var Q=new Image;Q.src=e.logo;var L=this;function w(t){var o=Math.round(e.width/3.5),i=Math.round(e.height/3.5);o!==i&&(o=i),e.logoWidth&&(o=Math.round(e.logoWidth)),e.logoHeight&&(i=Math.round(e.logoHeight));var r,a,s=(e.width+2*e.quietZone-o)/2,h=(e.height+e.titleHeight+2*e.quietZone-i)/2;e.logoBackgroundTransparent||(n.fillStyle=e.logoBackgroundColor,n.fillRect(s,h,o,i)),void 0===t.naturalWidth?(r=t.width,a=t.height):(r=t.naturalWidth,a=t.naturalHeight);var u=Math.min(o/r,i/a),g=r*u,d=a*u;n.drawImage(t,s+(o-g)/2,h+(i-d)/2,g,d),L._bIsPainted=!0,e.quietZone>0&&e.quietZoneColor&&l(),L.makeImage()}if(Q.onload=function(){w(Q)},Q.onerror=function(t){console.error(t)},Q.complete)return Q.onload=null,void w(Q)}else this._bIsPainted=!0,e.quietZone>0&&e.quietZoneColor&&l(),this.makeImage()}},Drawing.prototype.makeImage=function(){var t=this.makeOptions,e=this;if("FILE"==t.makeType)if(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"svg"==this._htOption._drawer){let o=this._oContext.getSerializedSvg();fs.writeFile(t.path,o,"utf8",function(t){t&&e.reject(t),e.resolve({})})}else{var o=fs.createWriteStream(t.path);("PNG"==this._htOption.format?this._canvas.createPNGStream({compressionLevel:this._htOption.compressionLevel}):this._canvas.createJPEGStream({quality:this._htOption.quality})).pipe(o),o.on("finish",()=>{e.resolve({})})}else if("URL"==t.makeType)if(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"svg"==this._htOption._drawer){let t=this._oContext.getSerializedSvg();e.resolve(t)}else"PNG"==this._htOption.format?this._canvas.toDataURL((t,o)=>{e.resolve(o)}):this._canvas.toDataURL("image/jpeg",(t,o)=>{e.resolve(o)})},Drawing.prototype.isPainted=function(){return this._bIsPainted},Drawing.prototype.round=function(t){return t?Math.floor(1e3*t)/1e3:t},QRCode.prototype._toSave=function(t){var e=new Drawing(this._htOption);e.makeOptions=t;try{var o=this;return new Promise((t,i)=>{e.resolve=t,e.reject=i,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.saveImage=function(t){return this._htOption._drawer="canvas",t=Object.assign({makeType:"FILE",path:null},t),this._toSave(t)},QRCode.prototype.saveSVG=function(t){return this._htOption._drawer="svg",t=Object.assign({makeType:"FILE",path:null},t),this._toSave(t)},QRCode.prototype._toData=function(t){this._htOption._drawer=t;var e=new Drawing(this._htOption);e.makeOptions={makeType:"URL"};try{var o=this;return new Promise((t,i)=>{e.resolve=t,e.reject=i,e.draw(o._oQRCode)})}catch(t){console.error(t)}},QRCode.prototype.toDataURL=function(){return this._toData("canvas")},QRCode.prototype.toSVGText=function(){return this._toData("svg")},QRCode.CorrectLevel=QRErrorCorrectLevel,module.exports=QRCode;
var{createCanvas:createCanvas,loadImage:loadImage,Image:Image}=require("canvas"),jsdom=require("jsdom"),C2S=require("./canvas2svg"),fs=require("fs");const{JSDOM:JSDOM}=jsdom,win=(new JSDOM).window;function QR8bitByte(data,binary){this.mode=QRMode.MODE_8BIT_BYTE,this.data=data,this.parsedData=[];for(var i=0,l=this.data.length;i<l;i++){var byteArray=[],code=this.data.charCodeAt(i);binary?byteArray[0]=code:code>65536?(byteArray[0]=240|(1835008&code)>>>18,byteArray[1]=128|(258048&code)>>>12,byteArray[2]=128|(4032&code)>>>6,byteArray[3]=128|63&code):code>2048?(byteArray[0]=224|(61440&code)>>>12,byteArray[1]=128|(4032&code)>>>6,byteArray[2]=128|63&code):code>128?(byteArray[0]=192|(1984&code)>>>6,byteArray[1]=128|63&code):byteArray[0]=code,this.parsedData.push(byteArray)}this.parsedData=Array.prototype.concat.apply([],this.parsedData),this.parsedData.length!=this.data.length&&(this.parsedData.unshift(191),this.parsedData.unshift(187),this.parsedData.unshift(239))}function QRCodeModel(typeNumber,errorCorrectLevel){this.typeNumber=typeNumber,this.errorCorrectLevel=errorCorrectLevel,this.modules=null,this.moduleCount=0,this.dataCache=null,this.dataList=[]}QR8bitByte.prototype={getLength:function(buffer){return this.parsedData.length},write:function(buffer){for(var i=0,l=this.parsedData.length;i<l;i++)buffer.put(this.parsedData[i],8)}},QRCodeModel.prototype={addData:function(data,binary){var newData=new QR8bitByte(data,binary);this.dataList.push(newData),this.dataCache=null},isDark:function(row,col){if(row<0||this.moduleCount<=row||col<0||this.moduleCount<=col)throw new Error(row+","+col);return this.modules[row][col][0]},getEye:function(row,col){if(row<0||this.moduleCount<=row||col<0||this.moduleCount<=col)throw new Error(row+","+col);var block=this.modules[row][col];if(block[1]){var type="P"+block[1]+"_"+block[2];return"A"==block[2]&&(type="A"+block[1]),{isDarkBlock:block[0],type:type}}return null},getModuleCount:function(){return this.moduleCount},make:function(){this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(test,maskPattern){this.moduleCount=4*this.typeNumber+17,this.modules=new Array(this.moduleCount);for(var row=0;row<this.moduleCount;row++){this.modules[row]=new Array(this.moduleCount);for(var col=0;col<this.moduleCount;col++)this.modules[row][col]=[]}this.setupPositionProbePattern(0,0,"TL"),this.setupPositionProbePattern(this.moduleCount-7,0,"BL"),this.setupPositionProbePattern(0,this.moduleCount-7,"TR"),this.setupPositionAdjustPattern("A"),this.setupTimingPattern(),this.setupTypeInfo(test,maskPattern),this.typeNumber>=7&&this.setupTypeNumber(test),null==this.dataCache&&(this.dataCache=QRCodeModel.createData(this.typeNumber,this.errorCorrectLevel,this.dataList)),this.mapData(this.dataCache,maskPattern)},setupPositionProbePattern:function(row,col,posName){for(var r=-1;r<=7;r++)if(!(row+r<=-1||this.moduleCount<=row+r))for(var c=-1;c<=7;c++)col+c<=-1||this.moduleCount<=col+c||(0<=r&&r<=6&&(0==c||6==c)||0<=c&&c<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=c&&c<=4?(this.modules[row+r][col+c][0]=!0,this.modules[row+r][col+c][2]=posName,this.modules[row+r][col+c][1]=-0==r||-0==c||6==r||6==c?"O":"I"):this.modules[row+r][col+c][0]=!1)},getBestMaskPattern:function(){for(var minLostPoint=0,pattern=0,i=0;i<8;i++){this.makeImpl(!0,i);var lostPoint=QRUtil.getLostPoint(this);(0==i||minLostPoint>lostPoint)&&(minLostPoint=lostPoint,pattern=i)}return pattern},createMovieClip:function(target_mc,instance_name,depth){var qr_mc=target_mc.createEmptyMovieClip(instance_name,depth);this.make();for(var row=0;row<this.modules.length;row++)for(var y=1*row,col=0;col<this.modules[row].length;col++){var x=1*col;this.modules[row][col][0]&&(qr_mc.beginFill(0,100),qr_mc.moveTo(x,y),qr_mc.lineTo(x+1,y),qr_mc.lineTo(x+1,y+1),qr_mc.lineTo(x,y+1),qr_mc.endFill())}return qr_mc},setupTimingPattern:function(){for(var r=8;r<this.moduleCount-8;r++)null==this.modules[r][6][0]&&(this.modules[r][6][0]=r%2==0);for(var c=8;c<this.moduleCount-8;c++)null==this.modules[6][c][0]&&(this.modules[6][c][0]=c%2==0)},setupPositionAdjustPattern:function(posName){for(var pos=QRUtil.getPatternPosition(this.typeNumber),i=0;i<pos.length;i++)for(var j=0;j<pos.length;j++){var row=pos[i],col=pos[j];if(null==this.modules[row][col][0])for(var r=-2;r<=2;r++)for(var c=-2;c<=2;c++)-2==r||2==r||-2==c||2==c||0==r&&0==c?(this.modules[row+r][col+c][0]=!0,this.modules[row+r][col+c][2]=posName,this.modules[row+r][col+c][1]=-2==r||-2==c||2==r||2==c?"O":"I"):this.modules[row+r][col+c][0]=!1}},setupTypeNumber:function(test){for(var bits=QRUtil.getBCHTypeNumber(this.typeNumber),i=0;i<18;i++){var mod=!test&&1==(bits>>i&1);this.modules[Math.floor(i/3)][i%3+this.moduleCount-8-3][0]=mod}for(i=0;i<18;i++){mod=!test&&1==(bits>>i&1);this.modules[i%3+this.moduleCount-8-3][Math.floor(i/3)][0]=mod}},setupTypeInfo:function(test,maskPattern){for(var data=this.errorCorrectLevel<<3|maskPattern,bits=QRUtil.getBCHTypeInfo(data),i=0;i<15;i++){var mod=!test&&1==(bits>>i&1);i<6?this.modules[i][8][0]=mod:i<8?this.modules[i+1][8][0]=mod:this.modules[this.moduleCount-15+i][8][0]=mod}for(i=0;i<15;i++){mod=!test&&1==(bits>>i&1);i<8?this.modules[8][this.moduleCount-i-1][0]=mod:i<9?this.modules[8][15-i-1+1][0]=mod:this.modules[8][15-i-1][0]=mod}this.modules[this.moduleCount-8][8][0]=!test},mapData:function(data,maskPattern){for(var inc=-1,row=this.moduleCount-1,bitIndex=7,byteIndex=0,col=this.moduleCount-1;col>0;col-=2)for(6==col&&col--;;){for(var c=0;c<2;c++)if(null==this.modules[row][col-c][0]){var dark=!1;byteIndex<data.length&&(dark=1==(data[byteIndex]>>>bitIndex&1)),QRUtil.getMask(maskPattern,row,col-c)&&(dark=!dark),this.modules[row][col-c][0]=dark,-1==--bitIndex&&(byteIndex++,bitIndex=7)}if((row+=inc)<0||this.moduleCount<=row){row-=inc,inc=-inc;break}}}},QRCodeModel.PAD0=236,QRCodeModel.PAD1=17,QRCodeModel.createData=function(typeNumber,errorCorrectLevel,dataList){for(var rsBlocks=QRRSBlock.getRSBlocks(typeNumber,errorCorrectLevel),buffer=new QRBitBuffer,i=0;i<dataList.length;i++){var data=dataList[i];buffer.put(data.mode,4),buffer.put(data.getLength(),QRUtil.getLengthInBits(data.mode,typeNumber)),data.write(buffer)}var totalDataCount=0;for(i=0;i<rsBlocks.length;i++)totalDataCount+=rsBlocks[i].dataCount;if(buffer.getLengthInBits()>8*totalDataCount)throw new Error("code length overflow. ("+buffer.getLengthInBits()+">"+8*totalDataCount+")");for(buffer.getLengthInBits()+4<=8*totalDataCount&&buffer.put(0,4);buffer.getLengthInBits()%8!=0;)buffer.putBit(!1);for(;!(buffer.getLengthInBits()>=8*totalDataCount||(buffer.put(QRCodeModel.PAD0,8),buffer.getLengthInBits()>=8*totalDataCount));)buffer.put(QRCodeModel.PAD1,8);return QRCodeModel.createBytes(buffer,rsBlocks)},QRCodeModel.createBytes=function(buffer,rsBlocks){for(var offset=0,maxDcCount=0,maxEcCount=0,dcdata=new Array(rsBlocks.length),ecdata=new Array(rsBlocks.length),r=0;r<rsBlocks.length;r++){var dcCount=rsBlocks[r].dataCount,ecCount=rsBlocks[r].totalCount-dcCount;maxDcCount=Math.max(maxDcCount,dcCount),maxEcCount=Math.max(maxEcCount,ecCount),dcdata[r]=new Array(dcCount);for(var i=0;i<dcdata[r].length;i++)dcdata[r][i]=255&buffer.buffer[i+offset];offset+=dcCount;var rsPoly=QRUtil.getErrorCorrectPolynomial(ecCount),modPoly=new QRPolynomial(dcdata[r],rsPoly.getLength()-1).mod(rsPoly);ecdata[r]=new Array(rsPoly.getLength()-1);for(i=0;i<ecdata[r].length;i++){var modIndex=i+modPoly.getLength()-ecdata[r].length;ecdata[r][i]=modIndex>=0?modPoly.get(modIndex):0}}var totalCodeCount=0;for(i=0;i<rsBlocks.length;i++)totalCodeCount+=rsBlocks[i].totalCount;var data=new Array(totalCodeCount),index=0;for(i=0;i<maxDcCount;i++)for(r=0;r<rsBlocks.length;r++)i<dcdata[r].length&&(data[index++]=dcdata[r][i]);for(i=0;i<maxEcCount;i++)for(r=0;r<rsBlocks.length;r++)i<ecdata[r].length&&(data[index++]=ecdata[r][i]);return data};for(var QRMode={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},QRErrorCorrectLevel={L:1,M:0,Q:3,H:2},QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},QRUtil={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(data){for(var d=data<<10;QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G15)>=0;)d^=QRUtil.G15<<QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G15);return(data<<10|d)^QRUtil.G15_MASK},getBCHTypeNumber:function(data){for(var d=data<<12;QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18)>=0;)d^=QRUtil.G18<<QRUtil.getBCHDigit(d)-QRUtil.getBCHDigit(QRUtil.G18);return data<<12|d},getBCHDigit:function(data){for(var digit=0;0!=data;)digit++,data>>>=1;return digit},getPatternPosition:function(typeNumber){return QRUtil.PATTERN_POSITION_TABLE[typeNumber-1]},getMask:function(maskPattern,i,j){switch(maskPattern){case QRMaskPattern.PATTERN000:return(i+j)%2==0;case QRMaskPattern.PATTERN001:return i%2==0;case QRMaskPattern.PATTERN010:return j%3==0;case QRMaskPattern.PATTERN011:return(i+j)%3==0;case QRMaskPattern.PATTERN100:return(Math.floor(i/2)+Math.floor(j/3))%2==0;case QRMaskPattern.PATTERN101:return i*j%2+i*j%3==0;case QRMaskPattern.PATTERN110:return(i*j%2+i*j%3)%2==0;case QRMaskPattern.PATTERN111:return(i*j%3+(i+j)%2)%2==0;default:throw new Error("bad maskPattern:"+maskPattern)}},getErrorCorrectPolynomial:function(errorCorrectLength){for(var a=new QRPolynomial([1],0),i=0;i<errorCorrectLength;i++)a=a.multiply(new QRPolynomial([1,QRMath.gexp(i)],0));return a},getLengthInBits:function(mode,type){if(1<=type&&type<10)switch(mode){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:case QRMode.MODE_KANJI:return 8;default:throw new Error("mode:"+mode)}else if(type<27)switch(mode){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw new Error("mode:"+mode)}else{if(!(type<41))throw new Error("type:"+type);switch(mode){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw new Error("mode:"+mode)}}},getLostPoint:function(qrCode){for(var moduleCount=qrCode.getModuleCount(),lostPoint=0,row=0;row<moduleCount;row++)for(var col=0;col<moduleCount;col++){for(var sameCount=0,dark=qrCode.isDark(row,col),r=-1;r<=1;r++)if(!(row+r<0||moduleCount<=row+r))for(var c=-1;c<=1;c++)col+c<0||moduleCount<=col+c||0==r&&0==c||dark==qrCode.isDark(row+r,col+c)&&sameCount++;sameCount>5&&(lostPoint+=3+sameCount-5)}for(row=0;row<moduleCount-1;row++)for(col=0;col<moduleCount-1;col++){var count=0;qrCode.isDark(row,col)&&count++,qrCode.isDark(row+1,col)&&count++,qrCode.isDark(row,col+1)&&count++,qrCode.isDark(row+1,col+1)&&count++,0!=count&&4!=count||(lostPoint+=3)}for(row=0;row<moduleCount;row++)for(col=0;col<moduleCount-6;col++)qrCode.isDark(row,col)&&!qrCode.isDark(row,col+1)&&qrCode.isDark(row,col+2)&&qrCode.isDark(row,col+3)&&qrCode.isDark(row,col+4)&&!qrCode.isDark(row,col+5)&&qrCode.isDark(row,col+6)&&(lostPoint+=40);for(col=0;col<moduleCount;col++)for(row=0;row<moduleCount-6;row++)qrCode.isDark(row,col)&&!qrCode.isDark(row+1,col)&&qrCode.isDark(row+2,col)&&qrCode.isDark(row+3,col)&&qrCode.isDark(row+4,col)&&!qrCode.isDark(row+5,col)&&qrCode.isDark(row+6,col)&&(lostPoint+=40);var darkCount=0;for(col=0;col<moduleCount;col++)for(row=0;row<moduleCount;row++)qrCode.isDark(row,col)&&darkCount++;return lostPoint+=10*(Math.abs(100*darkCount/moduleCount/moduleCount-50)/5)}},QRMath={glog:function(n){if(n<1)throw new Error("glog("+n+")");return QRMath.LOG_TABLE[n]},gexp:function(n){for(;n<0;)n+=255;for(;n>=256;)n-=255;return QRMath.EXP_TABLE[n]},EXP_TABLE:new Array(256),LOG_TABLE:new Array(256)},i=0;i<8;i++)QRMath.EXP_TABLE[i]=1<<i;for(i=8;i<256;i++)QRMath.EXP_TABLE[i]=QRMath.EXP_TABLE[i-4]^QRMath.EXP_TABLE[i-5]^QRMath.EXP_TABLE[i-6]^QRMath.EXP_TABLE[i-8];for(i=0;i<255;i++)QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]]=i;function QRPolynomial(num,shift){if(void 0==num.length)throw new Error(num.length+"/"+shift);for(var offset=0;offset<num.length&&0==num[offset];)offset++;this.num=new Array(num.length-offset+shift);for(var i=0;i<num.length-offset;i++)this.num[i]=num[i+offset]}function QRRSBlock(totalCount,dataCount){this.totalCount=totalCount,this.dataCount=dataCount}function QRBitBuffer(){this.buffer=[],this.length=0}QRPolynomial.prototype={get:function(index){return this.num[index]},getLength:function(){return this.num.length},multiply:function(e){for(var num=new Array(this.getLength()+e.getLength()-1),i=0;i<this.getLength();i++)for(var j=0;j<e.getLength();j++)num[i+j]^=QRMath.gexp(QRMath.glog(this.get(i))+QRMath.glog(e.get(j)));return new QRPolynomial(num,0)},mod:function(e){if(this.getLength()-e.getLength()<0)return this;for(var ratio=QRMath.glog(this.get(0))-QRMath.glog(e.get(0)),num=new Array(this.getLength()),i=0;i<this.getLength();i++)num[i]=this.get(i);for(i=0;i<e.getLength();i++)num[i]^=QRMath.gexp(QRMath.glog(e.get(i))+ratio);return new QRPolynomial(num,0).mod(e)}},QRRSBlock.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],QRRSBlock.getRSBlocks=function(typeNumber,errorCorrectLevel){var rsBlock=QRRSBlock.getRsBlockTable(typeNumber,errorCorrectLevel);if(void 0==rsBlock)throw new Error("bad rs block @ typeNumber:"+typeNumber+"/errorCorrectLevel:"+errorCorrectLevel);for(var length=rsBlock.length/3,list=[],i=0;i<length;i++)for(var count=rsBlock[3*i+0],totalCount=rsBlock[3*i+1],dataCount=rsBlock[3*i+2],j=0;j<count;j++)list.push(new QRRSBlock(totalCount,dataCount));return list},QRRSBlock.getRsBlockTable=function(typeNumber,errorCorrectLevel){switch(errorCorrectLevel){case QRErrorCorrectLevel.L:return QRRSBlock.RS_BLOCK_TABLE[4*(typeNumber-1)+0];case QRErrorCorrectLevel.M:return QRRSBlock.RS_BLOCK_TABLE[4*(typeNumber-1)+1];case QRErrorCorrectLevel.Q:return QRRSBlock.RS_BLOCK_TABLE[4*(typeNumber-1)+2];case QRErrorCorrectLevel.H:return QRRSBlock.RS_BLOCK_TABLE[4*(typeNumber-1)+3];default:return}},QRBitBuffer.prototype={get:function(index){var bufIndex=Math.floor(index/8);return 1==(this.buffer[bufIndex]>>>7-index%8&1)},put:function(num,length){for(var i=0;i<length;i++)this.putBit(1==(num>>>length-i-1&1))},getLengthInBits:function(){return this.length},putBit:function(bit){var bufIndex=Math.floor(this.length/8);this.buffer.length<=bufIndex&&this.buffer.push(0),bit&&(this.buffer[bufIndex]|=128>>>this.length%8),this.length++}};var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];function _getTypeNumber(sText,_htOption){for(var nCorrectLevel=_htOption.correctLevel,nType=1,length=_getUTF8Length(sText),i=0,len=QRCodeLimitLength.length;i<=len;i++){var nLimit=0;switch(nCorrectLevel){case QRErrorCorrectLevel.L:nLimit=QRCodeLimitLength[i][0];break;case QRErrorCorrectLevel.M:nLimit=QRCodeLimitLength[i][1];break;case QRErrorCorrectLevel.Q:nLimit=QRCodeLimitLength[i][2];break;case QRErrorCorrectLevel.H:nLimit=QRCodeLimitLength[i][3]}if(length<=nLimit)break;nType++}if(nType>QRCodeLimitLength.length)throw new Error("Too long data");return 0!=_htOption.version&&(nType<=_htOption.version?(nType=_htOption.version,_htOption.runVersion=nType):(console.warn("QR Code version "+_htOption.version+" too small, run version use "+nType),_htOption.runVersion=nType)),nType}function _getUTF8Length(sText){var replacedText=encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g,"a");return replacedText.length+(replacedText.length!=sText.length?3:0)}var Drawing=function(htOption){this._bIsPainted=!1,this._htOption=htOption,this._canvas=createCanvas(200,200),"svg"==this._htOption._drawer?this._oContext={}:this._oContext=this._canvas.getContext("2d"),this._bSupportDataURI=null};function QRCode(vOption){if(this._htOption={width:256,height:256,typeNumber:4,colorDark:"#000000",colorLight:"#ffffff",correctLevel:QRErrorCorrectLevel.H,dotScale:1,dotScaleTiming:1,dotScaleTiming_H:void 0,dotScaleTiming_V:void 0,dotScaleA:1,dotScaleAO:void 0,dotScaleAI:void 0,quietZone:0,quietZoneColor:"rgba(0,0,0,0)",title:"",titleFont:"bold 16px Arial",titleColor:"#000000",titleBackgroundColor:"#ffffff",titleHeight:0,titleTop:30,subTitle:"",subTitleFont:"14px Arial",subTitleColor:"#4F4F4F",subTitleTop:60,logo:void 0,logoWidth:void 0,logoHeight:void 0,logoBackgroundColor:"#ffffff",logoBackgroundTransparent:!1,PO:void 0,PI:void 0,PO_TL:void 0,PI_TL:void 0,PO_TR:void 0,PI_TR:void 0,PO_BL:void 0,PI_BL:void 0,AO:void 0,AI:void 0,timing:void 0,timing_H:void 0,timing_V:void 0,backgroundImage:void 0,backgroundImageAlpha:1,autoColor:!1,autoColorDark:"rgba(0, 0, 0, .6)",autoColorLight:"rgba(255, 255, 255, .7)",onRenderingStart:void 0,format:"PNG",compressionLevel:6,quality:.75,version:0,binary:!1},"string"==typeof vOption&&(vOption={text:vOption}),vOption)for(var i in vOption)this._htOption[i]=vOption[i];(this._htOption.version<0||this._htOption.version>40)&&(console.warn("QR Code version '"+this._htOption.version+"' is invalidate, reset to 0"),this._htOption.version=0),this._htOption.format=this._htOption.format.toUpperCase(),"PNG"!=this._htOption.format&&"JPG"!=this._htOption.format&&(console.warn("Image format '"+this._htOption.format+"' is invalidate, reset to 'PNG'"),this._htOption.format="PNG"),"PNG"==this._htOption.format&&(this._htOption.compressionLevel<0||this._htOption.compressionLevel>9)?(console.warn(this._htOption.compressionLevel+" is invalidate, PNG compressionLevel must between 0 and 9, now reset to 6. "),this._htOption.compressionLevel=1):(this._htOption.quality<0||this._htOption.quality>1)&&(console.warn(this._htOption.quality+" is invalidate, JPG quality must between 0 and 1, now reset to 0.75. "),this._htOption.quality=.75),(this._htOption.dotScale<0||this._htOption.dotScale>1)&&(console.warn(this._htOption.dotScale+" , is invalidate, dotScale must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScale=1),(this._htOption.dotScaleTiming<0||this._htOption.dotScaleTiming>1)&&(console.warn(this._htOption.dotScaleTiming+" , is invalidate, dotScaleTiming must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScaleTiming=1),this._htOption.dotScaleTiming_H?(this._htOption.dotScaleTiming_H<0||this._htOption.dotScaleTiming_H>1)&&(console.warn(this._htOption.dotScaleTiming_H+" , is invalidate, dotScaleTiming_H must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScaleTiming_H=1):this._htOption.dotScaleTiming_H=this._htOption.dotScaleTiming,this._htOption.dotScaleTiming_V?(this._htOption.dotScaleTiming_V<0||this._htOption.dotScaleTiming_V>1)&&(console.warn(this._htOption.dotScaleTiming_V+" , is invalidate, dotScaleTiming_V must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScaleTiming_V=1):this._htOption.dotScaleTiming_V=this._htOption.dotScaleTiming,(this._htOption.dotScaleA<0||this._htOption.dotScaleA>1)&&(console.warn(this._htOption.dotScaleA+" , is invalidate, dotScaleA must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScaleA=1),this._htOption.dotScaleAO?(this._htOption.dotScaleAO<0||this._htOption.dotScaleAO>1)&&(console.warn(this._htOption.dotScaleAO+" , is invalidate, dotScaleAO must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScaleAO=1):this._htOption.dotScaleAO=this._htOption.dotScaleA,this._htOption.dotScaleAI?(this._htOption.dotScaleAI<0||this._htOption.dotScaleAI>1)&&(console.warn(this._htOption.dotScaleAI+" , is invalidate, dotScaleAI must greater than 0, less than or equal to 1, now reset to 1. "),this._htOption.dotScaleAI=1):this._htOption.dotScaleAI=this._htOption.dotScaleA,(this._htOption.backgroundImageAlpha<0||this._htOption.backgroundImageAlpha>1)&&(console.warn(this._htOption.backgroundImageAlpha+" , is invalidate, backgroundImageAlpha must between 0 and 1, now reset to 1. "),this._htOption.backgroundImageAlpha=1),(!this._htOption.drawer||"svg"!=this._htOption.drawer&&"canvas"!=this._htOption.drawer)&&(this._htOption.drawer="canvas"),this._htOption.height=this._htOption.height+this._htOption.titleHeight,this._oQRCode=null,this._oQRCode=new QRCodeModel(_getTypeNumber(this._htOption.text,this._htOption),this._htOption.correctLevel),this._oQRCode.addData(this._htOption.text,this._htOption.binary),this._oQRCode.make()}Drawing.prototype.draw=function(oQRCode){var _htOption=this._htOption;_htOption.title||_htOption.subTitle||(_htOption.height-=_htOption.titleHeight,_htOption.titleHeight=0);var nCount=oQRCode.getModuleCount(),nWidth=Math.round(_htOption.width/nCount),nHeight=Math.round((_htOption.height-_htOption.titleHeight)/nCount);_htOption.quietZone=Math.round(_htOption.quietZone),_htOption.width=nWidth*nCount,_htOption.height=nHeight*nCount+_htOption.titleHeight,this._canvas.width=_htOption.width+2*_htOption.quietZone,this._canvas.height=_htOption.height+2*_htOption.quietZone,"svg"==_htOption._drawer&&(this._oContext=new C2S({document:win.document,XMLSerializer:win.XMLSerializer,width:this._canvas.width,height:this._canvas.height})),this._oContext.patternQuality="best",this._oContext.quality="best",this._oContext.textDrawingMode="path",this._oContext.antialias="gray";var _oContext=this._oContext;_htOption.autoColorDark,_htOption.autoColorLight;"JPG"==_htOption.format?(_htOption.logoBackgroundTransparent=!1,_htOption.colorDark,_htOption.colorLight,_htOption.colorLight,_htOption.backgroundImage?(_oContext.fillStyle=_htOption.colorLight,_oContext.fillRect(0,0,this._canvas.width,this._canvas.height)):("rgba(0,0,0,0)"!=_htOption.quietZoneColor&&"transparent"!=_htOption.quietZoneColor||(_htOption.quietZoneColor="#ffffff"),_oContext.fillStyle=_htOption.colorLight,_oContext.fillRect(0,0,this._canvas.width,this._canvas.height))):(_oContext.lineWidth=0,_oContext.fillStyle=_htOption.colorLight,_oContext.fillRect(0,0,this._canvas.width,this._canvas.height));var t=this;function drawQuietZoneColor(){_oContext.lineWidth=0,_oContext.fillStyle=_htOption.quietZoneColor,_oContext.fillRect(0,0,t._canvas.width,_htOption.quietZone),_oContext.fillRect(0,_htOption.quietZone,_htOption.quietZone,t._canvas.height-2*_htOption.quietZone),_oContext.fillRect(t._canvas.width-_htOption.quietZone,_htOption.quietZone,_htOption.quietZone,t._canvas.height-2*_htOption.quietZone),_oContext.fillRect(0,t._canvas.height-_htOption.quietZone,t._canvas.width,_htOption.quietZone)}if(_htOption.backgroundImage){var bgImg=new Image;bgImg.onload=function(){_oContext.globalAlpha=1,_oContext.globalAlpha=_htOption.backgroundImageAlpha,_oContext.drawImage(bgImg,0,_htOption.titleHeight,_htOption.width+2*_htOption.quietZone,_htOption.height+2*_htOption.quietZone-_htOption.titleHeight),_oContext.globalAlpha=1,drawQrcode.call(t,oQRCode)},bgImg.src=_htOption.backgroundImage}else drawQrcode.call(t,oQRCode);function drawQrcode(oQRCode){for(var row=0;row<nCount;row++)for(var col=0;col<nCount;col++){var dColor,lColor,nLeft=col*nWidth+_htOption.quietZone,nTop=row*nHeight+_htOption.quietZone,bIsDark=oQRCode.isDark(row,col),eye=oQRCode.getEye(row,col),nowDotScale=_htOption.dotScale;if(_oContext.lineWidth=0,eye?(dColor=_htOption[eye.type]||_htOption[eye.type.substring(0,2)]||_htOption.colorDark,lColor=_htOption.colorLight):_htOption.backgroundImage?(lColor="rgba(0,0,0,0)",6==row?dColor=_htOption.timing_H||_htOption.timing||_htOption.colorDark:6==col?dColor=_htOption.timing_V||_htOption.timing||_htOption.colorDark:_htOption.autoColor?(dColor=_htOption.autoColorDark,lColor=_htOption.autoColorLight):dColor=_htOption.colorDark):(dColor=6==row?_htOption.timing_H||_htOption.timing||_htOption.colorDark:6==col&&(_htOption.timing_V||_htOption.timing)||_htOption.colorDark,lColor=_htOption.colorLight),_oContext.strokeStyle=bIsDark?dColor:lColor,_oContext.fillStyle=bIsDark?dColor:lColor,eye){bIsDark=eye.isDarkBlock;var type=eye.type;nowDotScale="AO"==type?_htOption.dotScaleAO:"AI"==type?_htOption.dotScaleAI:1,_oContext.fillRect(nLeft+nWidth*(1-nowDotScale)/2,_htOption.titleHeight+nTop+nHeight*(1-nowDotScale)/2,nWidth*nowDotScale,nHeight*nowDotScale)}else 6==row?(nowDotScale=_htOption.dotScaleTiming_H,_oContext.fillRect(nLeft+nWidth*(1-nowDotScale)/2,_htOption.titleHeight+nTop+nHeight*(1-nowDotScale)/2,nWidth*nowDotScale,nHeight*nowDotScale)):6==col?(nowDotScale=_htOption.dotScaleTiming_V,_oContext.fillRect(nLeft+nWidth*(1-nowDotScale)/2,_htOption.titleHeight+nTop+nHeight*(1-nowDotScale)/2,nWidth*nowDotScale,nHeight*nowDotScale)):(_htOption.backgroundImage,_oContext.fillRect(nLeft+nWidth*(1-nowDotScale)/2,_htOption.titleHeight+nTop+nHeight*(1-nowDotScale)/2,nWidth*nowDotScale,nHeight*nowDotScale));1==_htOption.dotScale||eye||(_oContext.strokeStyle=_htOption.colorLight)}if(_htOption.title&&(_oContext.fillStyle=_htOption.titleBackgroundColor,_oContext.fillRect(0,0,t._canvas.width,_htOption.titleHeight+this._htOption.quietZone),_oContext.font=_htOption.titleFont,_oContext.fillStyle=_htOption.titleColor,_oContext.textAlign="center",_oContext.fillText(_htOption.title,t._canvas.width/2,this._htOption.quietZone+this._htOption.titleTop)),_htOption.subTitle&&(_oContext.font=_htOption.subTitleFont,_oContext.fillStyle=_htOption.subTitleColor,_oContext.fillText(_htOption.subTitle,t._canvas.width/2,this._htOption.quietZone+this._htOption.subTitleTop)),_htOption.logo){var img=new Image;img.src=_htOption.logo;var _this=this;function generateLogoImg(img){var imgContainerW=Math.round(_htOption.width/3.5),imgContainerH=Math.round(_htOption.height/3.5);imgContainerW!==imgContainerH&&(imgContainerW=imgContainerH),_htOption.logoWidth&&(imgContainerW=Math.round(_htOption.logoWidth)),_htOption.logoHeight&&(imgContainerH=Math.round(_htOption.logoHeight));var nw,nh,imgContainerX=(_htOption.width+2*_htOption.quietZone-imgContainerW)/2,imgContainerY=(_htOption.height+_htOption.titleHeight+2*_htOption.quietZone-imgContainerH)/2;_htOption.logoBackgroundTransparent||(_oContext.fillStyle=_htOption.logoBackgroundColor,_oContext.fillRect(imgContainerX,imgContainerY,imgContainerW,imgContainerH)),void 0===img.naturalWidth?(nw=img.width,nh=img.height):(nw=img.naturalWidth,nh=img.naturalHeight);var imgScale=Math.min(imgContainerW/nw,imgContainerH/nh),imgW=nw*imgScale,imgH=nh*imgScale;_oContext.drawImage(img,imgContainerX+(imgContainerW-imgW)/2,imgContainerY+(imgContainerH-imgH)/2,imgW,imgH),_this._bIsPainted=!0,_htOption.quietZone>0&&_htOption.quietZoneColor&&drawQuietZoneColor(),_this.makeImage()}if(img.onload=function(){generateLogoImg(img)},img.onerror=function(e){console.error(e)},img.complete)return img.onload=null,void generateLogoImg(img)}else this._bIsPainted=!0,_htOption.quietZone>0&&_htOption.quietZoneColor&&drawQuietZoneColor(),this.makeImage()}},Drawing.prototype.makeImage=function(){var makeOptions=this.makeOptions,t=this;if("FILE"==makeOptions.makeType)if(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"svg"==this._htOption._drawer){let data=this._oContext.getSerializedSvg();fs.writeFile(makeOptions.path,data,"utf8",function(err){err&&t.reject(err),t.resolve({})})}else{var out=fs.createWriteStream(makeOptions.path);("PNG"==this._htOption.format?this._canvas.createPNGStream({compressionLevel:this._htOption.compressionLevel}):this._canvas.createJPEGStream({quality:this._htOption.quality})).pipe(out),out.on("finish",()=>{t.resolve({})})}else if("URL"==makeOptions.makeType)if(this._htOption.onRenderingStart&&this._htOption.onRenderingStart(this._htOption),"svg"==this._htOption._drawer){let data=this._oContext.getSerializedSvg();t.resolve(data)}else"PNG"==this._htOption.format?this._canvas.toDataURL((err,data)=>{t.resolve(data)}):this._canvas.toDataURL("image/jpeg",(err,data)=>{t.resolve(data)})},Drawing.prototype.isPainted=function(){return this._bIsPainted},Drawing.prototype.round=function(nNumber){return nNumber?Math.floor(1e3*nNumber)/1e3:nNumber},QRCode.prototype._toSave=function(saveOptions){var _oDrawing=new Drawing(Object.assign({},this._htOption));_oDrawing.makeOptions=saveOptions;try{var t=this;return new Promise((resolve,reject)=>{_oDrawing.resolve=resolve,_oDrawing.reject=reject,_oDrawing.draw(t._oQRCode)})}catch(e){console.error(e)}},QRCode.prototype.saveImage=function(saveOptions){return this._htOption._drawer="canvas",saveOptions=Object.assign({makeType:"FILE",path:null},saveOptions),this._toSave(saveOptions)},QRCode.prototype.saveSVG=function(saveOptions){return this._htOption._drawer="svg",saveOptions=Object.assign({makeType:"FILE",path:null},saveOptions),this._toSave(saveOptions)},QRCode.prototype._toData=function(drawer){this._htOption._drawer=drawer;var _oDrawing=new Drawing(Object.assign({},this._htOption));_oDrawing.makeOptions={makeType:"URL"};try{var t=this;return new Promise((resolve,reject)=>{_oDrawing.resolve=resolve,_oDrawing.reject=reject,_oDrawing.draw(t._oQRCode)})}catch(e){console.error(e)}},QRCode.prototype.toDataURL=function(){return this._toData("canvas")},QRCode.prototype.toSVGText=function(){return this._toData("svg")},QRCode.CorrectLevel=QRErrorCorrectLevel,module.exports=QRCode;
{
"name": "easyqrcodejs-nodejs",
"version": "4.0.0",
"version": "4.2.0",
"description": "NodeJS QRCode generator. Can save image or svg to file, get standard base64 image data url text or get SVG serialized text. Cross-browser QRCode generator for pure javascript. Support Dot style, Logo, Background image, Colorful, Title etc. settings. support binary mode.(Running without DOM on server side)",

@@ -5,0 +5,0 @@ "main": "index.min.js",

@@ -155,8 +155,20 @@ # EasyQRCodeJS-NodeJS

correctLevel : QRCode.CorrectLevel.H, // L, M, Q, H
dotScale: 1 // Must be greater than 0, less than or equal to 1. default is 1
// ====== dotScale
/*
dotScale: 1, // For body block, must be greater than 0, less than or equal to 1. default is 1
dotScaleTiming: 1, // Dafault for timing block , must be greater than 0, less than or equal to 1. default is 1
dotScaleTiming_H: undefined, // For horizontal timing block, must be greater than 0, less than or equal to 1. default is 1
dotScaleTiming_V: undefined, // For vertical timing block, must be greater than 0, less than or equal to 1. default is 1
dotScaleA: 1, // Dafault for alignment block, must be greater than 0, less than or equal to 1. default is 1
dotScaleAO: undefined, // For alignment outer block, must be greater than 0, less than or equal to 1. default is 1
dotScaleAI: undefined, // For alignment inner block, must be greater than 0, less than or equal to 1. default is 1
*/
// ====== Quiet Zone
/*
quietZone: 0,
quietZoneColor: 'transparent',
quietZoneColor: "rgba(0,0,0,0)",
*/

@@ -169,3 +181,3 @@

logoWidth:80, // width. default is automatic width
logoHeight:80 // height. default is automatic height
logoHeight:80, // height. default is automatic height
logoBackgroundColor:'#fffff', // Logo backgroud color, Invalid when `logBgTransparent` is true; default is '#ffffff'

@@ -179,3 +191,5 @@ logoBackgroundTransparent:false, // Whether use transparent image, default is false

backgroundImageAlpha: 1, // Background image transparency, value between 0 and 1. default is 1.
autoColor: false,
autoColor: false, // Automatic color adjustment(for data block)
autoColorDark: "rgba(0, 0, 0, .6)", // Automatic color: dark CSS color
autoColorLight: "rgba(255, 255, 255, .7)", // Automatic color: light CSS color
*/

@@ -258,6 +272,13 @@

| **correctLevel** | N | Enum | `QRCode.CorrectLevel.H` | `QRCode.CorrectLevel.H`<br/>`QRCode.CorrectLevel.Q` <br/> `QRCode.CorrectLevel.M` <br/> `QRCode.CorrectLevel.L`|
| **dotScale** | N | Number | `1.0` |Dot style required Patterns. Ranges: `0-1.0` |
| Dot style| --- | ---|---|---|
| **dotScale** | N | Number | `1.0` |Dot style scale. Ranges: `0-1.0` |
| **dotScaleTiming** | N | Number | `1.0` |Dot style scale for timing. Ranges: `0-1.0` |
| **dotScaleTiming_V** | N | Number | `undefined` |Dot style scale for horizontal timing. Ranges: `0-1.0` |
| **dotScaleTiming_H** | N | Number | `undefined` |Dot style scale for vertical timing. Ranges: `0-1.0` |
| **dotScaleA** | N | Number | `1.0` |Dot style scale for alignment. Ranges: `0-1.0` |
| **dotScaleAO** | N | Number | `undefined` |Dot style scale for alignment outer. Ranges: `0-1.0` |
| **dotScaleAI** | N | Number | `undefined` |Dot style scale for alignment inner. Ranges: `0-1.0` |
| Quiet Zone| --- | ---|---|---|
| **quietZone** | N | Number | `0` | Quiet Zone size |
| **quietZoneColor** | N | String | `transparent` | Background CSS color to Quiet Zone |
| **quietZoneColor** | N | String | `rgba(0,0,0,0)` | Background CSS color to Quiet Zone |
| Logo options| --- | ---|---|---|

@@ -272,3 +293,5 @@ | **logo** | N | String | `undefined` | Logo Image Path or Base64 encoded image. If use relative address, relative to `easy.qrcode.min.js` |

| **backgroundImageAlpha** | N | Number | `1.0` | Background image transparency. Ranges: `0-1.0` |
| **autoColor** | N | Boolean | `false` | Automatic color adjustment |
| **autoColor** | N | Boolean | `false` | Automatic color adjustment(for data block) |
| **autoColorDark** | N | String | `rgba(0, 0, 0, .6)` | Automatic color: dark CSS color |
| **autoColorLight** | N | String | `rgba(255, 255, 255, .7)` | Automatic color: light CSS color |
| Posotion Pattern Color options| --- | ---|---|---|

@@ -326,3 +349,14 @@ | **PO** | N | String | `undefined` | Global Posotion Outer CSS color. if not set, the defaut is `colorDark` |

```
- **saveSVG(ImagesFormatOptions)**
```JS
// Save SVG to file
qrcode.saveSVG({
path: 'qrcode.svg' // file path
}).then(data=>{
console.log("`qrcode.svg` has been Created!");
});
```
- **toDataURL()**

@@ -329,0 +363,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc