@liquid-js/qr-code-styling 5.2.0 → 5.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/figures/dot-elements.d.ts +1 -0
- package/lib/qr-code-styling-node.js +35 -5
- package/lib/qr-code-styling-node.js.map +1 -1
- package/lib/qr-code-styling.js +1 -1
- package/lib/qr-code-styling.js.map +1 -1
- package/lib/tools/resize.d.ts +41 -0
- package/lib/utils/options.d.ts +2 -1
- package/package.json +2 -2
package/lib/qr-code-styling.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{svgPath as t,numToAttr as e,scalePath as r,rotateFigure as i}from"./plugin-utils.js";class s{buffer;length;constructor(){this.buffer=[],this.length=0}getBuffer(){return this.buffer}getLengthInBits(){return this.length}toString(){let t="";for(let e=0;e<this.getLengthInBits();e+=1)t+=this.getBit(e)?"1":"0";return t}getBit(t){return 1==(this.buffer[~~(t/8)]>>>7-t%8&1)}put(t,e){for(let r=0;r<e;r+=1)this.putBit(1==(t>>>e-r-1&1))}putBit(t){this.length==8*this.buffer.length&&this.buffer.push(0),t&&(this.buffer[~~(this.length/8)]|=128>>>this.length%8),this.length+=1}}var o,n=o||={};n[n.L=1]="L",n[n.M=0]="M",n[n.Q=3]="Q",n[n.H=2]="H";class a{constructor(){throw Error("error")}static initialize;static EXP_TABLE;static LOG_TABLE;static glog(t){if(a.LOG_TABLE||a.initialize(),t<1)throw Error("log("+t+")");return a.LOG_TABLE[t]}static gexp(t){for(a.EXP_TABLE||a.initialize();t<0;)t+=255;for(;t>=256;)t-=255;return a.EXP_TABLE[t]}}a.initialize=()=>{a.EXP_TABLE=[],a.LOG_TABLE=[];for(var t=0;t<256;t+=1)a.EXP_TABLE.push(t<8?1<<t:a.EXP_TABLE[t-4]^a.EXP_TABLE[t-5]^a.EXP_TABLE[t-6]^a.EXP_TABLE[t-8]),a.LOG_TABLE.push(0);for(t=0;t<255;t+=1)a.LOG_TABLE[a.EXP_TABLE[t]]=t};class h{num;constructor(t,e=0){let r=0;for(;r<t.length&&0==t[r];)r+=1;this.num=[];let i=t.length-r;for(let e=0;e<i;e+=1)this.num.push(t[r+e]);for(t=0;t<e;t+=1)this.num.push(0)}getAt(t){return this.num[t]}getLength(){return this.num.length}toString(){let t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=this.getAt(e);return t.toString()}toLogString(){let t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=a.glog(this.getAt(e));return t.toString()}multiply(t){let e=[];for(var r=this.getLength()+t.getLength()-1,i=0;i<r;i+=1)e.push(0);for(r=0;r<this.getLength();r+=1)for(i=0;i<t.getLength();i+=1)e[r+i]^=a.gexp(a.glog(this.getAt(r))+a.glog(t.getAt(i)));return new h(e)}mod(t){if(this.getLength()-t.getLength()<0)return this;let e=a.glog(this.getAt(0))-a.glog(t.getAt(0)),r=[];for(var i=0;i<this.getLength();i+=1)r.push(this.getAt(i));for(i=0;i<t.getLength();i+=1)r[i]^=a.gexp(a.glog(t.getAt(i))+e);return new h(r).mod(t)}}var u,d=u||={};d[d.MODE_NUMBER=1]="MODE_NUMBER",d[d.MODE_ALPHA_NUM=2]="MODE_ALPHA_NUM",d[d.MODE_8BIT_BYTE=4]="MODE_8BIT_BYTE",d[d.MODE_KANJI=8]="MODE_KANJI";class l{mode;data;constructor(t,e){this.mode=t,this.data=e}getMode(){return this.mode}getData(){return this.data}getLengthInBits(t){if(1<=t&&t<10)switch(this.mode){case u.MODE_NUMBER:return 10;case u.MODE_ALPHA_NUM:return 9;case u.MODE_8BIT_BYTE:case u.MODE_KANJI:return 8;default:throw Error("mode:"+this.mode)}else if(t<27)switch(this.mode){case u.MODE_NUMBER:return 12;case u.MODE_ALPHA_NUM:return 11;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 10;default:throw Error("mode:"+this.mode)}else{if(!(t<41))throw Error("typeNumber:"+t);switch(this.mode){case u.MODE_NUMBER:return 14;case u.MODE_ALPHA_NUM:return 13;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 12;default:throw Error("mode:"+this.mode)}}}}class c extends l{stringToBytes;constructor(t,e){super(u.MODE_8BIT_BYTE,t),this.stringToBytes=e}write(t){this.stringToBytes(this.getData()).forEach(e=>t.put(e,8))}getLength(){return this.stringToBytes(this.getData()).length}}class g extends l{constructor(t){super(u.MODE_ALPHA_NUM,t)}write(t){let e=this.getData(),r=0;for(;r+1<e.length;)t.put(45*g.getCode(e.charAt(r))+g.getCode(e.charAt(r+1)),11),r+=2;r<e.length&&t.put(g.getCode(e.charAt(r)),6)}getLength(){return this.getData().length}static getCode(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;if("A"<=t&&t<="Z")return t.charCodeAt(0)-65+10;switch(t){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw Error("illegal char :"+t)}}}class p extends l{stringToBytes;constructor(t,e){super(u.MODE_KANJI,t),this.stringToBytes=e}write(t){let e=this.stringToBytes(this.getData()),r=0;for(;r+1<e.length;){let i=(255&e[r])<<8|255&e[r+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw Error("illegal char at "+(r+1)+"/"+i);i-=49472}i=192*(i>>>8&255)+(255&i),t.put(i,13),r+=2}if(r<e.length)throw Error("illegal char at "+(r+1))}getLength(){return this.stringToBytes(this.getData()).length/2}}class m extends l{constructor(t){super(u.MODE_NUMBER,t)}write(t){let e=this.getData(),r=0;for(;r+2<e.length;)t.put(m.strToNum(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?t.put(m.strToNum(e.substring(r,r+1)),4):e.length-r==2&&t.put(m.strToNum(e.substring(r,r+2)),7))}getLength(){return this.getData().length}static strToNum(t){let e=0;for(let r=0;r<t.length;r+=1)e=10*e+m.chatToNum(t.charAt(r));return e}static chatToNum(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw Error("illegal char :"+t)}}var w,$=w||={};$[$.PATTERN000=0]="PATTERN000",$[$.PATTERN001=1]="PATTERN001",$[$.PATTERN010=2]="PATTERN010",$[$.PATTERN011=3]="PATTERN011",$[$.PATTERN100=4]="PATTERN100",$[$.PATTERN101=5]="PATTERN101",$[$.PATTERN110=6]="PATTERN110",$[$.PATTERN111=7]="PATTERN111";class f{constructor(){throw Error("error")}static getPatternPosition(t){return f.PATTERN_POSITION_TABLE[t-1]}static PATTERN_POSITION_TABLE;static MAX_LENGTH;static getMaxLength(t,e,r){switch(r){case o.L:r=0;break;case o.M:r=1;break;case o.Q:r=2;break;case o.H:r=3;break;default:throw Error("e:"+r)}switch(e){case u.MODE_NUMBER:e=0;break;case u.MODE_ALPHA_NUM:e=1;break;case u.MODE_8BIT_BYTE:e=2;break;case u.MODE_KANJI:e=3;break;default:throw Error("m:"+e)}return f.MAX_LENGTH[t-1][r][e]}static getErrorCorrectPolynomial(t){let e=new h([1]);for(let r=0;r<t;r+=1)e=e.multiply(new h([1,a.gexp(r)]));return e}static getMaskFunc(t){switch(t){case w.PATTERN000:return(t,e)=>(t+e)%2==0;case w.PATTERN001:return t=>t%2==0;case w.PATTERN010:return(t,e)=>e%3==0;case w.PATTERN011:return(t,e)=>(t+e)%3==0;case w.PATTERN100:return(t,e)=>(~~(t/2)+~~(e/3))%2==0;case w.PATTERN101:return(t,e)=>t*e%2+t*e%3==0;case w.PATTERN110:return(t,e)=>(t*e%2+t*e%3)%2==0;case w.PATTERN111:return(t,e)=>(t*e%3+(t+e)%2)%2==0;default:throw Error("mask:"+t)}}static getLostPoint(t){let e=t.getModuleCount(),r=0;for(var i=0;i<e;i+=1)for(var s=0;s<e;s+=1){var o=0;let n=t.isDark(i,s);for(let r=-1;r<=1;r+=1)if(!(i+r<0||e<=i+r))for(let a=-1;a<=1;a+=1)s+a<0||e<=s+a||(0!=r||0!=a)&&n==t.isDark(i+r,s+a)&&(o+=1);o>5&&(r+=3+o-5)}for(i=0;i<e-1;i+=1)for(s=0;s<e-1;s+=1)o=0,t.isDark(i,s)&&(o+=1),t.isDark(i+1,s)&&(o+=1),t.isDark(i,s+1)&&(o+=1),t.isDark(i+1,s+1)&&(o+=1),(0==o||4==o)&&(r+=3);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(i,s)&&!t.isDark(i,s+1)&&t.isDark(i,s+2)&&t.isDark(i,s+3)&&t.isDark(i,s+4)&&!t.isDark(i,s+5)&&t.isDark(i,s+6)&&(r+=40);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(s,i)&&!t.isDark(s+1,i)&&t.isDark(s+2,i)&&t.isDark(s+3,i)&&t.isDark(s+4,i)&&!t.isDark(s+5,i)&&t.isDark(s+6,i)&&(r+=40);for(i=0,s=0;s<e;s+=1)for(o=0;o<e;o+=1)t.isDark(o,s)&&(i+=1);return r+Math.abs(100*i/e/e-50)/5*10}static getBCHTypeInfo(t){let e=t<<10;for(;f.getBCHDigit(e)-f.getBCHDigit(f.G15)>=0;)e^=f.G15<<f.getBCHDigit(e)-f.getBCHDigit(f.G15);return(t<<10|e)^f.G15_MASK}static getBCHTypeNumber(t){let e=t<<12;for(;f.getBCHDigit(e)-f.getBCHDigit(f.G18)>=0;)e^=f.G18<<f.getBCHDigit(e)-f.getBCHDigit(f.G18);return t<<12|e}static G15;static G18;static G15_MASK;static getBCHDigit(t){let e=0;for(;0!=t;)e+=1,t>>>=1;return e}}f.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]],f.MAX_LENGTH=[[[41,25,17,10],[34,20,14,8],[27,16,11,7],[17,10,7,4]],[[77,47,32,20],[63,38,26,16],[48,29,20,12],[34,20,14,8]],[[127,77,53,32],[101,61,42,26],[77,47,32,20],[58,35,24,15]],[[187,114,78,48],[149,90,62,38],[111,67,46,28],[82,50,34,21]],[[255,154,106,65],[202,122,84,52],[144,87,60,37],[106,64,44,27]],[[322,195,134,82],[255,154,106,65],[178,108,74,45],[139,84,58,36]],[[370,224,154,95],[293,178,122,75],[207,125,86,53],[154,93,64,39]],[[461,279,192,118],[365,221,152,93],[259,157,108,66],[202,122,84,52]],[[552,335,230,141],[432,262,180,111],[312,189,130,80],[235,143,98,60]],[[652,395,271,167],[513,311,213,131],[364,221,151,93],[288,174,119,74]]],f.G15=1335,f.G18=7973,f.G15_MASK=21522;class M{totalCount;dataCount;static RS_BLOCK_TABLE;constructor(t,e){this.totalCount=t,this.dataCount=e}getDataCount(){return this.dataCount}getTotalCount(){return this.totalCount}static getRSBlocks(t,e){e=(t=M.getRsBlockTable(t,e)).length/3;let r=[];for(let i=0;i<e;i+=1){let e=t[3*i],s=t[3*i+1],o=t[3*i+2];for(let t=0;t<e;t+=1)r.push(new M(s,o))}return r}static getRsBlockTable(t,e){switch(e){case o.L:return M.RS_BLOCK_TABLE[4*(t-1)];case o.M:return M.RS_BLOCK_TABLE[4*(t-1)+1];case o.Q:return M.RS_BLOCK_TABLE[4*(t-1)+2];case o.H:return M.RS_BLOCK_TABLE[4*(t-1)+3]}throw Error("tn:"+t+"/ecl:"+e)}}M.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]];let b=Array(41).fill(0).map((t,e)=>e);var v,A=v||={};A.L="L",A.M="M",A.Q="Q",A.H="H";var y,E=y||={};E.numeric="numeric",E.alphanumeric="alphanumeric",E.byte="byte",E.kanji="kanji",E.unicode="unicode";class z{static stringToBytesFuncs;static PAD0;static PAD1;typeNumber;errorCorrectLevel;qrDataList;modules=[];moduleCount=0;constructor(t=0,e=v.L){this.typeNumber=t,this.errorCorrectLevel=o[e],this.qrDataList=[]}getTypeNumber(){return this.typeNumber}setTypeNumber(t){this.typeNumber=t}getErrorCorrectLevel(){return this.errorCorrectLevel}setErrorCorrectLevel(t){this.errorCorrectLevel=t}clearData(){this.qrDataList=[]}addData(t,e=y.byte){if(t instanceof l)this.qrDataList.push(t);else{if("string"!=typeof t)throw Error(typeof t);switch(e){case y.numeric:this.qrDataList.push(new m(t));break;case y.alphanumeric:this.qrDataList.push(new g(t));break;case y.byte:this.qrDataList.push(new c(t,z.stringToBytesFuncs.default));break;case y.unicode:this.qrDataList.push(new c(t,z.stringToBytesFuncs.UTF8));break;case y.kanji:this.qrDataList.push(new p(t,z.stringToBytesFuncs.SJIS));break;default:throw Error("mode:"+e)}}}isDark(t,e){return null!=this.modules[t][e]&&this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){if(this.typeNumber<1){let e=1;for(;e<40;e++){var t=M.getRSBlocks(e,this.errorCorrectLevel);let r=new s;if(this.qrDataList.forEach(t=>{r.put(t.getMode(),4),r.put(t.getLength(),t.getLengthInBits(e)),t.write(r)}),t=t.reduce((t,e)=>t+e.getDataCount(),0),r.getLengthInBits()<=8*t)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())}getBestMaskPattern(){let t=0,e=0;for(let r=0;r<8;r+=1){this.makeImpl(!0,r);let i=f.getLostPoint(this);(0==r||t>i)&&(t=i,e=r)}return e}makeImpl(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=[];for(let t=0;t<this.moduleCount;t+=1){this.modules.push([]);for(let e=0;e<this.moduleCount;e+=1)this.modules[t].push(null)}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),t=z.createData(this.typeNumber,this.errorCorrectLevel,this.qrDataList),this.mapData(t,e)}mapData(t,e){let r=-1,i=this.moduleCount-1,s=7,o=0;e=f.getMaskFunc(e);for(let n=this.moduleCount-1;n>0;n-=2)for(6==n&&--n;;){for(let r=0;r<2;r+=1)if(null==this.modules[i][n-r]){let a=!1;o<t.length&&(a=1==(t[o]>>>s&1)),e(i,n-r)&&(a=!a),this.modules[i][n-r]=a,--s,-1==s&&(o+=1,s=7)}if(i+=r,i<0||this.moduleCount<=i){i-=r,r=-r;break}}}setupPositionAdjustPattern(){let t=f.getPatternPosition(this.typeNumber);t.forEach(e=>{t.forEach(t=>{if(null==this.modules[e][t])for(let r=-2;r<=2;r+=1)for(let i=-2;i<=2;i+=1)this.modules[e+r][t+i]=-2==r||2==r||-2==i||2==i||0==r&&0==i})})}setupPositionProbePattern(t,e){for(let r=-1;r<=7;r+=1)for(let i=-1;i<=7;i+=1)t+r<=-1||this.moduleCount<=t+r||e+i<=-1||this.moduleCount<=e+i||(this.modules[t+r][e+i]=0<=r&&r<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=i&&i<=4)}setupTimingPattern(){for(var t=8;t<this.moduleCount-8;t+=1)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(t=8;t<this.moduleCount-8;t+=1)null==this.modules[6][t]&&(this.modules[6][t]=t%2==0)}setupTypeNumber(t){let e=f.getBCHTypeNumber(this.typeNumber);for(var r=0;r<18;r+=1)this.modules[~~(r/3)][r%3+this.moduleCount-8-3]=!t&&1==(e>>r&1);for(r=0;r<18;r+=1)this.modules[r%3+this.moduleCount-8-3][~~(r/3)]=!t&&1==(e>>r&1)}setupTypeInfo(t,e){e=f.getBCHTypeInfo(this.errorCorrectLevel<<3|e);for(var r=0;r<15;r+=1){var i=!t&&1==(e>>r&1);r<6?this.modules[r][8]=i:r<8?this.modules[r+1][8]=i:this.modules[this.moduleCount-15+r][8]=i}for(r=0;r<15;r+=1)i=!t&&1==(e>>r&1),r<8?this.modules[8][this.moduleCount-r-1]=i:r<9?this.modules[8][15-r-1+1]=i:this.modules[8][15-r-1]=i;this.modules[this.moduleCount-8][8]=!t}static createData(t,e,r){e=M.getRSBlocks(t,e);let i=new s;if(r.forEach(e=>{i.put(e.getMode(),4),i.put(e.getLength(),e.getLengthInBits(t)),e.write(i)}),r=e.reduce((t,e)=>t+e.getDataCount(),0),i.getLengthInBits()>8*r)throw Error("code length overflow. ("+i.getLengthInBits()+">"+8*r+")");for(i.getLengthInBits()+4<=8*r&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*r)&&(i.put(z.PAD0,8),!(i.getLengthInBits()>=8*r));)i.put(z.PAD1,8);return z.createBytes(i,e)}static createBytes(t,e){function r(t){let e=[];for(let r=0;r<t;r+=1)e.push(0);return e}var i=0,s=0;let o=0;var n=Array(e.length).map(()=>[]);let a=Array(e.length).map(()=>[]);for(var u=0;u<e.length;u+=1){var d=e[u].getDataCount(),l=e[u].getTotalCount()-d;s=Math.max(s,d),o=Math.max(o,l),n[u]=r(d);for(var c=0;c<n[u].length;c+=1)n[u][c]=255&t.getBuffer()[c+i];for(i+=d,l=f.getErrorCorrectPolynomial(l),d=new h(n[u],l.getLength()-1).mod(l),a[u]=r(l.getLength()-1),l=0;l<a[u].length;l+=1)c=l+d.getLength()-a[u].length,a[u][l]=c>=0?d.getAt(c):0}for(t=r(t=e.reduce((t,e)=>t+e.getTotalCount(),0)),i=0,u=0;u<s;u+=1)for(d=0;d<e.length;d+=1)u<n[d].length&&(t[i]=n[d][u],i+=1);for(s=0;s<o;s+=1)for(n=0;n<e.length;n+=1)s<a[n].length&&(t[i]=a[n][s],i+=1);return t}}z.stringToBytesFuncs={default(t){let e=[];for(let r=0;r<t.length;r+=1){let i=t.charCodeAt(r);e.push(255&i)}return e}},z.PAD0=236,z.PAD1=17;let D=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function x(t,...e){if(!e.length)return t;let r=e.shift();return void 0!==r&&D(t)&&D(r)?(t={...t},Object.keys(r).forEach(e=>{let i=t[e],s=r[e];Array.isArray(i)&&Array.isArray(s)?t[e]=s:D(i)&&D(s)?t[e]=x({...i},s):t[e]=s}),x(t,...e)):t}var k,T=k||={};function O(t){if(!(t={...t}).colorStops||!t.colorStops.length)throw Error("Field 'colorStops' is required in gradient");return t.rotation=t.rotation?Number(t.rotation):0,t.colorStops=t.colorStops.map(t=>({...t,offset:Number(t.offset)})),t}T.radial="radial",T.linear="linear";var P,N=P||={};N.dot="dot",N.randomDot="random-dot",N.rounded="rounded",N.extraRounded="extra-rounded",N.verticalLine="vertical-line",N.horizontalLine="horizontal-line",N.classy="classy",N.classyRounded="classy-rounded",N.square="square",N.smallSquare="small-square",N.tinySquare="tiny-square",N.diamond="diamond",N.wave="wave",N.heart="heart",N.star="star",N.weave="weave",N.pentagon="pentagon",N.hexagon="hexagon",N.zebraHorizontal="zebra-horizontal",N.zebraVertical="zebra-vertical",N.blocksHorizontal="blocks-horizontal",N.blocksVertical="blocks-vertical";var C,L=C||={};L.dot="dot",L.square="square",L.heart="heart",L.extraRounded="extra-rounded",L.classy="classy",L.inpoint="inpoint",L.outpoint="outpoint",L.star="star",L.pentagon="pentagon",L.hexagon="hexagon",L.diamond="diamond";var S,B=S||={};B.dot="dot",B.square="square",B.extraRounded="extra-rounded",B.classy="classy",B.inpoint="inpoint",B.outpoint="outpoint",B.centerCircle="center-circle";var _,R=_||={};R.square="square",R.circle="circle";var q,I=q||={};I.center="center",I.overlay="overlay",I.background="background";let H={document:void 0,shape:_.square,width:void 0,height:void 0,size:void 0,data:"",qrOptions:{typeNumber:b[0],mode:void 0,errorCorrectionLevel:v.Q},imageOptions:{mode:q.center,imageSize:.4,crossOrigin:void 0,margin:0,fill:{color:"rgba(255,255,255,1)"}},dotsOptions:{type:P.square,color:"#000",size:10}};function G(t){return(t={...t}).imageOptions={...t.imageOptions,imageSize:Math.min(1,Number(t.imageOptions.imageSize))||1,margin:Number(t.imageOptions.margin),fill:{...t.imageOptions.fill}},t.imageOptions.mode==q.overlay&&(t.imageOptions.margin=0),t.imageOptions.fill.gradient&&(t.imageOptions.fill.gradient=O(t.imageOptions.fill.gradient)),t.dotsOptions={...t.dotsOptions},t.dotsOptions.gradient&&(t.dotsOptions.gradient=O(t.dotsOptions.gradient)),t.dotsOptions.size=Math.round(Math.max(0,t.dotsOptions.size)||10),t.cornersSquareOptions&&(t.cornersSquareOptions={...t.cornersSquareOptions},t.cornersSquareOptions.gradient&&(t.cornersSquareOptions.gradient=O(t.cornersSquareOptions.gradient))),t.cornersDotOptions&&(t.cornersDotOptions={...t.cornersDotOptions},t.cornersDotOptions.gradient&&(t.cornersDotOptions.gradient=O(t.cornersDotOptions.gradient))),t.backgroundOptions&&(t.backgroundOptions={...t.backgroundOptions},t.backgroundOptions.gradient&&(t.backgroundOptions.gradient=O(t.backgroundOptions.gradient))),t.document||(t.document=document),t}let U={[v.L]:.07,[v.M]:.15,[v.Q]:.25,[v.H]:.3};let F={dot:t=>{const{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","circle")).setAttribute("cx",e(i+r/2)),t.setAttribute("cy",e(s+r/2)),t.setAttribute("r",e(r/2)),t},square:(t,{width:r=t.size,height:i=t.size}={})=>{const{x:s,y:o,size:n,document:a}=t;return(t=a.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(s+(n-r)/2)),t.setAttribute("y",e(o+(n-i)/2)),t.setAttribute("width",e(r)),t.setAttribute("height",e(i)),t},sideRounded:(e,{height:r=e.size}={})=>{const{size:i,x:s,y:o,document:n}=e;return(e=n.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${s} ${o+(i-r)/2} v ${r} h ${i/2} a ${r/2} ${r/2} 0 0 0 0 ${-r} z`),e},cornerRounded:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},cornerExtraRounded:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} a ${r} ${r} 0 0 0 ${-r} ${-r} z`),e},classyDot:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r/2} a ${r/2} ${r/2} 0 0 0 ${r/2} ${r/2} h ${r/2} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},wave:e=>{const{size:r,x:i,y:s,document:o}=e;var n=5*Math.PI/180,a=65*Math.PI/180;e=r*(1-.65*Math.sin(n)),n=-r*(.95-.65*Math.cos(n));const h=-r*Math.sin(a)/2;a=r*Math.cos(a)/2;const u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",t`M ${i} ${s+r} c ${.65*r} 0 ${e} ${n} ${r} ${.95*-r} c ${h} ${a} ${-r/2} ${r*(.95-1)} ${-r} ${r*(.95-1)} z`),u},heart:t=>{const{size:e,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",r(["M",1,.31629,"c",-86e-5,.15702,-.10534,.26323,-.21876,.38123,"c",-.06736,.06834,-.18938,.17948,-.28124,.26126,"c",-.09188,-.08178,-.2139,-.19292,-.28124,-.26126,"c",-.11344,-.118,-.2179,-.22422,-.21876,-.38123,"c",-96e-5,-.27136,.33154,-.36842,.5,-.17,"c",.16844,-.19842,.50094,-.10136,.5,.17,"z"],{x:i,y:s,size:e})),t},rounded:t=>{const{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(i)),t.setAttribute("y",e(s)),t.setAttribute("width",e(r)),t.setAttribute("height",e(r)),t.setAttribute("rx",e(r/4)),t.setAttribute("ry",e(r/4)),t},classy:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z`),n},inpoint:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s+r/2} v ${r/4} a ${r/4} ${r/4} 0 0 0 ${r/4} ${r/4} h ${r/4*3} v ${-r/4*3} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${-r/4} h ${-r/2} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${r/4} z`),e},star:(e,{spikes:r=5,outerRadius:i=e.size/2,innerRadius:s=e.size/4}={})=>{const{size:o,x:n,y:a,document:h}=e,u=n+o/2,d=a+o/2,l=Math.PI/r;return(e=h.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",Array(2*r).fill(0).map((e,r)=>t`${0===r?"M":"L"} ${u+(e=r%2==0?i:s)*Math.sin(r*l)} ${d-e*Math.cos(r*l)}`).join(" ")),e},weave:e=>{const{size:r,x:i,y:s,document:o}=e,n=(r-(e=.6*r))/2,a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",t`M ${i+n} ${s} l ${e} 0 l 0 ${n} l ${n} 0 l 0 ${e} l ${-n} 0 l 0 ${n} l ${-e} 0 l 0 ${-n} l ${-n} 0 l 0 ${-e} l ${n} 0 z`),a}},X={[C.dot]:t=>i({...t,draw:F.dot}),[C.square]:t=>i({...t,draw:F.square}),[C.heart]:t=>F.heart(t),[C.extraRounded]:t=>i({...t,draw:F.rounded}),[C.classy]:t=>i({...t,draw:F.classy}),[C.inpoint]:t=>i({...t,draw:F.inpoint}),[C.outpoint]:t=>i({...t,rotation:(t.rotation||0)+Math.PI,draw:F.inpoint}),[C.star]:t=>F.star(t),[C.pentagon]:t=>F.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[C.hexagon]:t=>F.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[C.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>F.square(t,{width:.85*t.size,height:.85*t.size})})};let V={dot:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+r/2} ${s} a ${r/2} ${r/2} 0 1 0 0.1 0 z m 0 ${e} a ${r/2-e} ${r/2-e} 0 1 1 -0.1 0 Z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+r/2} ${s-e} a ${r/2+e} ${r/2+e} 0 1 0 0.1 0 z`),[n,a]},square:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r} z M ${i+e} ${s+e} h ${r-2*e} v ${r-2*e} h ${2*e-r} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i-e} ${s-e} h ${r+2*e} v ${r+2*e} h ${-r-2*e} z`),[n,a]},extraRounded:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*-e} v ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*e} h ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i-e} ${s+2.5*e} v ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*e} h ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*-e} h ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*e} z`),[n,a]},classy:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-3.5*e} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-5.5*e} z`),[n,a]},inpoint:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*-e} z`),[n,a]},centerCircle:e=>{const{x:r,y:i,size:s}=e;var o=s/2.5;const n=r+s/2,a=i+s/2;e=s/7;const h=document.createElementNS("http://www.w3.org/2000/svg","path");return h.setAttribute("clip-rule","evenodd"),h.setAttribute("d",t`M ${r} ${i} h ${s} v ${s} h ${-s} z M ${n-o} ${a} a ${o} ${o} 0 1 0 ${2*o} 0 a ${o} ${o} 0 1 0 ${2*-o} 0 z`),(o=document.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("clip-rule","evenodd"),o.setAttribute("d",t`M ${r-e} ${i-e} h ${s+2*e} v ${s+2*e} h ${-s-2*e} z`),[h,o]}},j={[S.dot]:t=>V.dot(t),[S.square]:t=>V.square(t),[S.extraRounded]:t=>V.extraRounded(t),[S.classy]:t=>i({...t,draw:V.classy}),[S.inpoint]:t=>i({...t,draw:V.inpoint}),[S.outpoint]:({rotation:t,...e})=>i({...e,rotation:(t||0)+Math.PI,draw:V.inpoint}),[S.centerCircle]:t=>V.centerCircle(t)};function K({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:n=F.cornerRounded,end:a=F.sideRounded}={}){let h=o?+o(-1,0):0,u=o?+o(1,0):0,d=o?+o(0,-1):0,l=h+u+d+(o=o?+o(0,1):0);return 0===l?F.dot({x:t,y:e,size:r,document:s}):l>2||h&&u||d&&o?F.square({x:t,y:e,size:r,document:s}):2===l?(a=0,h&&d?a=Math.PI/2:d&&u?a=Math.PI:u&&o&&(a=-Math.PI/2),i({x:t,y:e,size:r,rotation:a,document:s,draw:n})):(n=0,d?n=Math.PI/2:u?n=Math.PI:o&&(n=-Math.PI/2),i({x:t,y:e,size:r,rotation:n,document:s,draw:a}))}function Q({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:n=F.cornerRounded}={}){let a=o?+o(-1,0):0,h=o?+o(1,0):0,u=o?+o(0,-1):0;return a+h+u+(o=o?+o(0,1):0)===0?i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:F.classyDot}):a||u?h||o?F.square({x:t,y:e,size:r,document:s}):i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:n}):i({x:t,y:e,size:r,rotation:-Math.PI/2,document:s,draw:n})}function Y({x:t,y:e,size:r,document:s,getNeighbor:o},{stripe:n=r,rotation:a=0,endpoint:h=F.sideRounded,dot:u=F.dot}={}){let d=o?+o(0,-1):0;return o=o?+o(0,1):0,d&&o?i({x:t,y:e,size:r,rotation:a,document:s,draw:()=>F.square({x:t,y:e,size:r,document:s},{width:n})}):d&&!o?(a+=Math.PI/2,i({x:t,y:e,size:r,rotation:a,document:s,draw:t=>h(t,{height:n})})):o&&!d?(a-=Math.PI/2,i({x:t,y:e,size:r,rotation:a,document:s,draw:t=>h(t,{height:n})})):i({x:t,y:e,size:r,rotation:a,document:s,draw:()=>u({x:t+(r-n)/2,y:e+(r-n)/2,size:n,document:s})})}let J={[P.dot]:t=>F.dot(t),[P.randomDot]:({size:t,x:e,y:r,getPRandom:i,...s})=>{const o=.25*(i=i||Math.random)()+.75;return F.dot({...s,size:t*o,x:e+t*i()*(1-o),y:r+t*i()*(1-o)})},[P.rounded]:t=>K(t),[P.extraRounded]:t=>K(t,{corner:F.cornerExtraRounded}),[P.verticalLine]:t=>Y(t),[P.horizontalLine]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{rotation:-Math.PI/2}),[P.classy]:t=>Q(t),[P.classyRounded]:t=>Q(t,{corner:F.cornerExtraRounded}),[P.square]:t=>F.square(t),[P.smallSquare]:({x:t,y:e,size:r,document:i})=>F.square({x:t+=.15*r,y:e+=.15*r,size:r=.7*r,document:i}),[P.tinySquare]:({x:t,y:e,size:r,document:i})=>F.square({x:t+=.35*r,y:e+=.35*r,size:r=.3*r,document:i}),[P.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>F.square(t,{width:.85*t.size,height:.85*t.size})}),[P.wave]:t=>K(t,{corner:F.cornerExtraRounded,end:F.wave}),[P.heart]:t=>F.heart(t),[P.star]:t=>F.star(t),[P.weave]:t=>F.weave(t),[P.pentagon]:t=>F.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[P.hexagon]:t=>F.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[P.zebraVertical]:t=>Y(t,{stripe:.8*t.size}),[P.zebraHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2}),[P.blocksVertical]:t=>Y(t,{stripe:.8*t.size,endpoint:(e,r)=>{const i=t.size*(1-.25*(t.getPRandom||Math.random)());return F.square({...e,x:t.x-(t.size-i)/2},{...r,width:i})},dot:e=>{var r=t.getPRandom||Math.random;const i=t.size*(1-.25*r());return r=t.y+(t.size-i)*r(),F.square({...e,y:r},{height:i})}}),[P.blocksHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2,endpoint:(t,r)=>{const i=e.size*(1-.25*(e.getPRandom||Math.random)());return F.square({...t,x:e.x-(e.size-i)/2},{...r,width:i})},dot:t=>{var r=e.getPRandom||Math.random;const i=e.size*(1-.25*r());return r=e.y+(e.size-i)*r(),F.square({...t,y:r},{height:i})}})};function W(t,e){let r=J[t]||J[P.square];if(!e?.length)return r;let i=function(t){return e=>{for(let r of t){let t=r.drawDot?.(e);if(t)return t}}}(e);return t=>i(t)||r(t)}let Z={toDataURL:t=>"string"==typeof t&&t.startsWith("data:")?Promise.resolve(t):new Promise((e,r)=>{if("string"==typeof t){const i=new XMLHttpRequest;i.onload=()=>{const t=new FileReader;t.onloadend=()=>{e(t.result)},t.readAsDataURL(i.response)},i.onerror=i.onabort=i.ontimeout=r,i.open("GET",t,!0),i.responseType="blob",i.send()}else{const r=new FileReader;r.onloadend=()=>{e(r.result)},r.readAsDataURL(t)}}),getSize:(t,e)=>new Promise((r,i)=>{const s=new Image;"string"===e&&(s.crossOrigin=e),s.onload=()=>{r({width:s.width,height:s.height})},s.onerror=s.onabort=i,"string"==typeof t?s.src=t:Z.toDataURL(t).then(t=>s.src=t).catch(i)})};function tt(t){var e=[];let r=1;if("#"===(t=t.toLowerCase())[0]){let i=(t=t.slice(1)).length;i<=4?(e=[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)],4===i&&(r=parseInt(t[3]+t[3],16)/255)):(e=[parseInt(t[0]+t[1],16),parseInt(t[2]+t[3],16),parseInt(t[4]+t[5],16)],8===i&&(r=parseInt(t[6]+t[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0)}else{if(!(e=/^((?:rgba?))\s*\(([^)]*)\)/.exec(t)))return{value:t,alpha:r};r=(e=(e=e[2].trim().split(/\s*[,/]\s*|\s+/)).map((t,e)=>"%"===t[t.length-1]?(t=parseFloat(t)/100,3===e?t:255*t):"none"===t?0:parseFloat(t))).length>3?e.pop():1}return{value:"#"+e.map(t=>Math.max(0,Math.min(255,t)).toString(16).padStart(2,"0")).join(""),alpha:Math.max(0,Math.min(1,r))}}function et(t,e,r,i=!0){let s;return()=>{if(null==s){var o=s=0;for(let n=-3;n<4;n++)for(let a=-3;a<4;a++)o++,s|=Number(t[(e+n+t.length<<a)%t.length]?.[(r+a+t.length<<n)%t.length]===i)<<o}return o=s+=1831565813,o=Math.imul(o^o>>>15,1|o),(((o^=o+Math.imul(o^o>>>7,61|o))^o>>>14)>>>0)/4294967296}}let rt=[[1,1,1,1,1,1,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,1,1,1,1,1,1]],it=new Set(Object.values(S));let st=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]],ot=new Set(Object.values(C));class nt{options;_element;_fakeMatrix;get element(){return this._element}defs;backgroundMask;dotsMask;lightDotsMask;qr;document;imageTools;constructor(t){this.options=t,this.document=t.document,this._element=this.document.createElementNS("http://www.w3.org/2000/svg","svg");let r=e(t.size);this._element.setAttribute("width",r),this._element.setAttribute("height",r),this._element.setAttribute("viewBox",`0 0 ${r} ${r}`),this.defs=this.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this.defs),this.imageTools=t.imageTools||Z}get width(){return this.options.size}get height(){return this.options.size}async drawQR(t){let e=t.getModuleCount();var r=parseInt(((e-17)/4).toFixed(0),10);let i=this.options.dotsOptions.size,s={hideXDots:0,hideYDots:0,width:0,height:0};if(this.qr=t,this.options.image){t=await this.imageTools.getSize(this.options.image,this.options.imageOptions.crossOrigin);let{imageOptions:o,errorCorrectionPercent:n}=this.options;if(o.mode==q.background){r=(this.options.size-2*(this.options.backgroundOptions&&this.options.backgroundOptions.margin||0)*i)*o.imageSize;let{width:e,height:n}=t;n=n/e*r,e=r,n>r&&(e=e/n*r,n=r),s={hideXDots:0,hideYDots:0,width:e,height:n}}else{let a=o.imageSize*n;r=f.getPatternPosition(r),s=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:s,margin:o}){if(t<=0||e<=0||r<=0||s<=0||4*o**2>r)return{height:0,width:0,hideYDots:0,hideXDots:0};i&&i%2==0&&(i=Math.max(1,i-1));var n=Math.max(e,t),a=Math.min(e,t),h=0;i=(i||r)-2*o;do{let t=h+(i-h)/2,e=Math.max(1,Math.ceil(t+2*o));e%2==0&&e++;let s=Math.max(1,Math.ceil(t*a/n+2*o));s%2==0&&s++,e*s>r?i=t:h=t}while(Math.abs(h-i)>.001);return(r=Math.max(1,Math.ceil(h+2*o)))%2==0&&r++,(a=Math.max(1,Math.ceil(h*a/n+2*o)))%2==0&&a++,e>t?n=r:(n=a,a=r),r=i=(n-2*o)*s,(i=i*t/e)>(h=(a-2*o)*s)&&(i=h,r=h*e/t),{height:Math.round(i+2*o*s),width:Math.round(r+2*o*s),hideYDots:a,hideXDots:n}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:Math.floor(a*(e*e-192-2*(e-16)-r.length**2*25)),maxHiddenAxisDots:e-14,dotSize:i,margin:o.margin})}}this.drawBackground(),this.options.imageOptions.mode!=q.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawDots((t,r)=>!(this.options.imageOptions.mode==q.center&&t>=(e-s.hideXDots)/2&&t<(e+s.hideXDots)/2&&r>=(e-s.hideYDots)/2&&r<(e+s.hideYDots)/2||t<8&&r<8||t>=e-8&&r<8||r>=e-8&&t<8)),this.options.imageOptions.mode==q.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawCorners()}drawBackground(){let t=this.options;if(this._element&&t.backgroundOptions){this.createColor({options:t.backgroundOptions.gradient,color:t.backgroundOptions.color,additionalRotation:0,x:0,y:0,height:t.size,width:t.size,name:"background-color"});let r=this.document.createElementNS("http://www.w3.org/2000/svg","rect");this.backgroundMask=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),r.setAttribute("x",e(0)),r.setAttribute("y",e(0)),r.setAttribute("width",e(t.size)),r.setAttribute("height",e(t.size)),r.setAttribute("rx",e(t.size/2*(t.backgroundOptions.round||0))),this.backgroundMask.appendChild(r)}}drawDots(t){if(!this.qr)throw Error("QR code is not defined");let e=this.options;var r=this.qr.getModuleCount();if(r>e.size)throw Error("The canvas is too small");let i=this.options.dotsOptions.size;var s=e.size;e.imageOptions.mode==q.background&&(s-=2*i*(e.imageOptions.margin||0));var o=Math.floor((e.size-r*i)/2);let n=W(e.dotsOptions.type,e.plugins);this.dotsMask=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask),e.imageOptions.mode==q.background&&(this.lightDotsMask=this.createMask("mask-light-dot-color"),this.defs.appendChild(this.lightDotsMask));var a=0;let h=0;a=r,e.shape===_.circle?(a=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,h=Math.floor((s/i-r-2*a)/2),a=r+2*h):e.imageOptions.mode==q.background&&(h=1,a=r+2*h),s=o-h*i,o=r+2*h,this._fakeMatrix=Array(a);var u=Math.floor(a/2);for(let i=0;i<a;i++){this._fakeMatrix[i]=Array(a);for(let s=0;s<a;s++)if(i>h-1&&i<a-h&&s>h-1&&s<a-h){let e=i-h,r=s-h;t&&!t(e,r)?this._fakeMatrix[i][s]=void 0:this._fakeMatrix[i][s]=!!this.qr.isDark(r,e)}else this._fakeMatrix[i][s]=e.shape===_.circle&&Math.sqrt((i-u)*(i-u)+(s-u)*(s-u))>u?void 0:i==h-1||i==a-h||s==h-1||s==a-h?(s==h-1&&(i<h+8||i>a-h-9)||s==a-h&&i<h+8||i==h-1&&(s<h+8||s>a-h-9)||i==a-h&&s<h+8)&&void 0:this.qr.isDark(s-2*h<0?s:s>=r?s-2*h:s-h,i-2*h<0?i:i>=r?i-2*h:i-h)}t=f.getPatternPosition((r-17)/4);for(let e=0;e<a;e++){r=t.find(t=>e-h>t-3&&e-h<t+3);for(let o=0;o<a;o++)u=t.find(t=>o-h>t-3&&o-h<t+3),null!=this._fakeMatrix[e][o]&&(this.lightDotsMask&&(n=r&&u&&(r!=t[0]&&u!=t[0]||u!=t[0]&&u!=t[t.length-1]||r!=t[0]&&r!=t[t.length-1])?W(P.square):W(P.tinySquare)),this._fakeMatrix[e][o]?this.dotsMask&&this.dotsMask.appendChild(n({x:s+e*i,y:s+o*i,size:i,document:this.options.document,getNeighbor:(t,r)=>!0===this._fakeMatrix[e+t]?.[o+r],getPRandom:et(this._fakeMatrix,e,o)})):this.lightDotsMask&&this.lightDotsMask&&this.lightDotsMask.appendChild(n({x:s+e*i,y:s+o*i,size:i,document:this.options.document,getNeighbor:(t,r)=>!1===this._fakeMatrix[e+t]?.[o+r],getPRandom:et(this._fakeMatrix,e,o,!1)})))}this.lightDotsMask&&this.createColor({options:e.imageOptions.fill.gradient,color:e.imageOptions.fill.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"light-dot-color"}),this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"dot-color"})}drawCorners(){if(!this.qr)throw Error("QR code is not defined");let t=this.options;if(!this._element)throw Error("Element code is not defined");let e=this.qr.getModuleCount(),r=this.options.dotsOptions.size,i=7*r,s=3*r,o=Math.floor((t.size-e*r)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach(([n,a,h])=>{var u=o+n*r*(e-7);let d=o+a*r*(e-7),l=this.dotsMask,c=this.dotsMask;(t.cornersSquareOptions?.gradient||t.cornersSquareOptions?.color)&&(l=this.createMask(`mask-corners-square-color-${n}-${a}`),this.defs.appendChild(l),c=c=l,this.createColor({options:t.cornersSquareOptions?.gradient,color:t.cornersSquareOptions?.color,additionalRotation:h,x:u,y:d,height:i,width:i,name:`corners-square-color-${n}-${a}`}));var g={x:u,y:d,size:i,document:this.options.document,rotation:h};let p=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerSquare?.(e);if(t)return t}}}(t.plugins)(g):void 0;if(p){let[t,e]=p;l&&l.appendChild(t),this.lightDotsMask&&this.lightDotsMask.appendChild(e)}else if(function(t){return!(!t||!it.has(t))}(t.cornersSquareOptions?.type)){let[e,r]=(j[t.cornersSquareOptions.type]||j[S.square])(g);l&&l.appendChild(e),this.lightDotsMask&&this.lightDotsMask.appendChild(r)}else{g=W(t.cornersSquareOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<rt.length;t++)for(let e=0;e<rt[t].length;e++)rt[t]?.[e]?l&&l.appendChild(g({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!rt[t+r]?.[e+i],getPRandom:et(this._fakeMatrix,u/r+t,d/r+e,!1)})):this.lightDotsMask&&!st[t]?.[e]&&this.lightDotsMask&&this.lightDotsMask.appendChild(g({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!rt[t+r]?.[e+i]&&!st[t+r]?.[e+i],getPRandom:et(this._fakeMatrix,u/r+t,d/r+e,!1)}));if(this.lightDotsMask)for(let t=-1;t<8;t++)for(let e=-1;e<8;e++)(-1==t||7==t||-1==e||7==e)&&this.lightDotsMask&&this.lightDotsMask.appendChild(g({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>(i=e+i,(r=t+r)>=-1&&r<=7&&i>=-1&&i<=7&&(-1==r||7==r||-1==i||7==i)),getPRandom:et(this._fakeMatrix,u/r+t,d/r+e,!1)}))}if((t.cornersDotOptions?.gradient||t.cornersDotOptions?.color)&&(c=this.createMask(`mask-corners-dot-color-${n}-${a}`),this.defs.appendChild(c),this.createColor({options:t.cornersDotOptions?.gradient,color:t.cornersDotOptions?.color,additionalRotation:h,x:u+2*r,y:d+2*r,height:s,width:s,name:`corners-dot-color-${n}-${a}`})),n={x:u+2*r,y:d+2*r,size:s,document:this.document,rotation:h},a=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerDot?.(e);if(t)return t}}}(t.plugins)(n):void 0)c&&c.appendChild(a);else if(function(t){return!(!t||!ot.has(t))}(t.cornersDotOptions?.type))u=X[t.cornersDotOptions.type]||X[C.square],c&&c.appendChild(u(n));else{n=W(t.cornersDotOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<st.length;t++)for(let e=0;e<st[t].length;e++)st[t]?.[e]&&c&&c.appendChild(n({x:u+t*r,y:d+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!st[t+r]?.[e+i],getPRandom:et(this._fakeMatrix,u/r+t,d/r+e,!1)}))}})}async drawImage({width:t,height:r,count:i,dotSize:s}){var o=this.options,n=Math.floor((o.size-i*s)/2),a=o.imageOptions.margin*s;o.imageOptions.mode==q.background&&(a=0);let h=n+a+(i*s-t)/2;if(i=n+a+(i*s-r)/2,t-=2*a,r-=2*a,a=await this.imageTools.toDataURL(o.image||""),(o=this.document.createElementNS("http://www.w3.org/2000/svg","image")).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a||""),a.startsWith("data:image/svg+xml;")){if(s=(a=a.substring(19)).indexOf(","),n=a.substring(0,s),a=a.substring(s+1),"base64"===n)a="function"==typeof atob?atob(a):Buffer.from(a,"base64").toString("utf8");else a="";a&&(a=(new DOMParser).parseFromString(a,"text/xml"),(a=Array.from(a.getElementsByTagName("svg"))).length&&(o=a[0]).setAttribute("overflow","visible"))}o.setAttribute("x",e(h)),o.setAttribute("y",e(i)),o.setAttribute("width",`${e(t)}px`),o.setAttribute("height",`${e(r)}px`),this._element.appendChild(o)}createColor({options:t,color:r,additionalRotation:i,x:s,y:o,height:n,width:a,name:h}){var u=a>n?a:n;s-=this.options.dotsOptions.size,o-=this.options.dotsOptions.size,a+=2*this.options.dotsOptions.size,n+=2*this.options.dotsOptions.size;let d=this.document.createElementNS("http://www.w3.org/2000/svg","rect");if(d.setAttribute("x",e(s)),d.setAttribute("y",e(o)),d.setAttribute("height",e(n)),d.setAttribute("width",e(a)),d.setAttribute("clip-path",`url(#mask-${h})`),t){let l;if(t.type===k.radial)l=this.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),l.setAttribute("id",h),l.setAttribute("gradientUnits","userSpaceOnUse"),l.setAttribute("fx",e(s+a/2)),l.setAttribute("fy",e(o+n/2)),l.setAttribute("cx",e(s+a/2)),l.setAttribute("cy",e(o+n/2)),l.setAttribute("r",e(u/2));else{u=s+a/2;let d=o+n/2;s+=a/2,o+=n/2,(i=((r=((t.rotation||0)+i)%(2*Math.PI))+2*Math.PI)%(2*Math.PI))>=0&&i<=.25*Math.PI||i>1.75*Math.PI&&i<=2*Math.PI?(u-=a/2,d-=n/2*Math.tan(r),s+=a/2,o+=n/2*Math.tan(r)):i>.25*Math.PI&&i<=.75*Math.PI?(d-=n/2,u-=a/2/Math.tan(r),o+=n/2,s+=a/2/Math.tan(r)):i>.75*Math.PI&&i<=1.25*Math.PI?(u+=a/2,d+=n/2*Math.tan(r),s-=a/2,o-=n/2*Math.tan(r)):i>1.25*Math.PI&&i<=1.75*Math.PI&&(d+=n/2,u+=a/2/Math.tan(r),o-=n/2,s-=a/2/Math.tan(r)),l=this.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),l.setAttribute("id",h),l.setAttribute("gradientUnits","userSpaceOnUse"),l.setAttribute("x1",e(u)),l.setAttribute("y1",e(d)),l.setAttribute("x2",e(s)),l.setAttribute("y2",e(o))}t.colorStops.forEach(t=>{let r=this.document.createElementNS("http://www.w3.org/2000/svg","stop");r.setAttribute("offset",`${e(100*t.offset)}%`),t=tt(t.color),r.setAttribute("stop-color",t.value),t.alpha<1&&r.setAttribute("stop-opacity",t.alpha.toFixed(7)),l.appendChild(r)}),d.setAttribute("fill",`url(#${h})`),this.defs.appendChild(l)}else r&&(t=tt(r),d.setAttribute("fill",t.value),t.alpha<1&&d.setAttribute("opacity",t.alpha.toFixed(7)));this._element.appendChild(d)}createMask(t){let e=this.document.createElementNS("http://www.w3.org/2000/svg","clipPath");return e.setAttribute("id",t),e.setAttribute("clipPathUnits","userSpaceOnUse"),e}}Object.assign(z.stringToBytesFuncs,{UTF8:t=>{const e=[];for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e.push(i):i<2048?e.push(192|i>>6,128|63&i):i<55296||i>=57344?e.push(224|i>>12,128|i>>6&63,128|63&i):(r++,i=65536+((1023&i)<<10|1023&t.charCodeAt(r)),e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i))}return e}});class at{options;container;qr;extension;svgDrawingPromise;qrSVG;get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?G(x(H,t)):H,this.update()}update(t){this.container&&(this.container.innerHTML=""),this.options=t?G(x(this.options,t)):this.options,this.options.data&&(this.options.stringToBytesFuncs&&(Object.assign(z.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=new z(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel),t=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return y.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return y.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return y.unicode;default:return y.byte}}(this.options.data),this.qr.addData(this.options.data,t),this.qr.make(),this.setupSvg(),this.append(this.container))}append(t){t&&(this.qrSVG?.element&&t.appendChild(this.qrSVG.element),this.container=t)}applyExtension(t){if(!t)throw Error("Extension function should be defined.");this.extension=t,this.update()}deleteExtension(){this.extension=void 0,this.update()}async serialize(){if(!this.qr)throw Error("QR code is empty");if(this.qrSVG?.element&&this.svgDrawingPromise||this.setupSvg(),await this.svgDrawingPromise,this.qrSVG?.element)return'<?xml version="1.0" standalone="no"?>\r\n'+(new XMLSerializer).serializeToString(this.qrSVG.element)}setupSvg(){if(this.qr){var t=this.qr.getModuleCount();this.options.imageOptions.mode==q.background&&this.options.shape!=_.circle&&(t+=2),(t=Math.ceil((this.options.shape==_.circle?Math.sqrt(2):1)*t))%2==0&&--t;var e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;this.options.imageOptions.mode==q.background&&(e+=this.options.imageOptions.margin||0);var r=Math.ceil(this.options.dotsOptions.size*(t+2*e));this.qrSVG=new nt({...this.options,width:r,height:r,size:r,errorCorrectionPercent:U[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then(()=>{this.qrSVG?.element&&(this.options.plugins?.forEach(t=>t.postProcess?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r})),this.extension?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r}))})}}}let ht={width:300,height:300,margin:0};var ut,dt=ut||={};function lt(t,e){let{width:r,height:i,margin:s}=e?function(t){return(t={...t}).width=Number(t.width),t.height=Number(t.height),t.margin=Number(t.margin),t.margin>Math.min(t.width,t.height)&&(t.margin=Math.min(t.width,t.height)),t}(x(ht,e)):ht,o=document.createElement("canvas");o.width=r,o.height=i;let n=Math.min(r,i)-2*s;return t=t.serialize().then(t=>{if(t){var e="data:image/svg+xml;base64,"+btoa(t),s=new Image;return new Promise((t,a)=>{s.onload=()=>{const e=Math.ceil(2*n/Math.min(s.width,s.height));let a;try{a=new OffscreenCanvas(s.width*e,s.height*e)}catch(t){a=document.createElement("canvas"),a.width=s.width*e,a.height=s.height*e}a.getContext("2d")?.drawImage(s,0,0,a.width,a.height),o?.getContext("2d")?.drawImage(a,(r-n)/2,(i-n)/2,n,n),t()},s.onerror=s.onabort=a,s.src=e})}}),{canvas:o,canvasDrawingPromise:t}}function ct(t,e){let r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}dt.svg="svg",dt.png="png",dt.jpeg="jpeg",dt.webp="webp";let gt=Object.freeze({__proto__:null,get FileExtension(){return ut},download:async function(t,e,r){var i=ut.png;let s="qr";if(e&&(e.name&&(s=e.name),e.extension&&(i=e.extension)),"svg"===i.toLowerCase())(i=await t.serialize())&&ct(i="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i),`${s}.svg`);else if(t=lt(t,r)){var{canvas:o,canvasDrawingPromise:n}=t;await n,ct(t=o.toDataURL(`image/${i}`),`${s}.${i}`)}},downloadURI:ct,drawToCanvas:lt});export{C as CornerDotType,S as CornerSquareType,P as DotType,v as ErrorCorrectionLevel,U as ErrorCorrectionPercents,ut as FileExtension,k as GradientType,q as ImageMode,y as Mode,at as QRCodeStyling,_ as ShapeType,b as TypeNumber,gt as browserUtils};
|
|
1
|
+
import{svgPath as t,numToAttr as e,scalePath as r,rotateFigure as i}from"./plugin-utils.js";class s{buffer;length;constructor(){this.buffer=[],this.length=0}getBuffer(){return this.buffer}getLengthInBits(){return this.length}toString(){let t="";for(let e=0;e<this.getLengthInBits();e+=1)t+=this.getBit(e)?"1":"0";return t}getBit(t){return 1==(this.buffer[~~(t/8)]>>>7-t%8&1)}put(t,e){for(let r=0;r<e;r+=1)this.putBit(1==(t>>>e-r-1&1))}putBit(t){this.length==8*this.buffer.length&&this.buffer.push(0),t&&(this.buffer[~~(this.length/8)]|=128>>>this.length%8),this.length+=1}}var o,n=o||={};n[n.L=1]="L",n[n.M=0]="M",n[n.Q=3]="Q",n[n.H=2]="H";class a{constructor(){throw Error("error")}static initialize;static EXP_TABLE;static LOG_TABLE;static glog(t){if(a.LOG_TABLE||a.initialize(),t<1)throw Error("log("+t+")");return a.LOG_TABLE[t]}static gexp(t){for(a.EXP_TABLE||a.initialize();t<0;)t+=255;for(;t>=256;)t-=255;return a.EXP_TABLE[t]}}a.initialize=()=>{a.EXP_TABLE=[],a.LOG_TABLE=[];for(var t=0;t<256;t+=1)a.EXP_TABLE.push(t<8?1<<t:a.EXP_TABLE[t-4]^a.EXP_TABLE[t-5]^a.EXP_TABLE[t-6]^a.EXP_TABLE[t-8]),a.LOG_TABLE.push(0);for(t=0;t<255;t+=1)a.LOG_TABLE[a.EXP_TABLE[t]]=t};class h{num;constructor(t,e=0){let r=0;for(;r<t.length&&0==t[r];)r+=1;this.num=[];let i=t.length-r;for(let e=0;e<i;e+=1)this.num.push(t[r+e]);for(t=0;t<e;t+=1)this.num.push(0)}getAt(t){return this.num[t]}getLength(){return this.num.length}toString(){let t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=this.getAt(e);return t.toString()}toLogString(){let t="";for(let e=0;e<this.getLength();e+=1)e>0&&(t+=","),t+=a.glog(this.getAt(e));return t.toString()}multiply(t){let e=[];for(var r=this.getLength()+t.getLength()-1,i=0;i<r;i+=1)e.push(0);for(r=0;r<this.getLength();r+=1)for(i=0;i<t.getLength();i+=1)e[r+i]^=a.gexp(a.glog(this.getAt(r))+a.glog(t.getAt(i)));return new h(e)}mod(t){if(this.getLength()-t.getLength()<0)return this;let e=a.glog(this.getAt(0))-a.glog(t.getAt(0)),r=[];for(var i=0;i<this.getLength();i+=1)r.push(this.getAt(i));for(i=0;i<t.getLength();i+=1)r[i]^=a.gexp(a.glog(t.getAt(i))+e);return new h(r).mod(t)}}var u,l=u||={};l[l.MODE_NUMBER=1]="MODE_NUMBER",l[l.MODE_ALPHA_NUM=2]="MODE_ALPHA_NUM",l[l.MODE_8BIT_BYTE=4]="MODE_8BIT_BYTE",l[l.MODE_KANJI=8]="MODE_KANJI";class d{mode;data;constructor(t,e){this.mode=t,this.data=e}getMode(){return this.mode}getData(){return this.data}getLengthInBits(t){if(1<=t&&t<10)switch(this.mode){case u.MODE_NUMBER:return 10;case u.MODE_ALPHA_NUM:return 9;case u.MODE_8BIT_BYTE:case u.MODE_KANJI:return 8;default:throw Error("mode:"+this.mode)}else if(t<27)switch(this.mode){case u.MODE_NUMBER:return 12;case u.MODE_ALPHA_NUM:return 11;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 10;default:throw Error("mode:"+this.mode)}else{if(!(t<41))throw Error("typeNumber:"+t);switch(this.mode){case u.MODE_NUMBER:return 14;case u.MODE_ALPHA_NUM:return 13;case u.MODE_8BIT_BYTE:return 16;case u.MODE_KANJI:return 12;default:throw Error("mode:"+this.mode)}}}}class c extends d{stringToBytes;constructor(t,e){super(u.MODE_8BIT_BYTE,t),this.stringToBytes=e}write(t){this.stringToBytes(this.getData()).forEach(e=>t.put(e,8))}getLength(){return this.stringToBytes(this.getData()).length}}class g extends d{constructor(t){super(u.MODE_ALPHA_NUM,t)}write(t){let e=this.getData(),r=0;for(;r+1<e.length;)t.put(45*g.getCode(e.charAt(r))+g.getCode(e.charAt(r+1)),11),r+=2;r<e.length&&t.put(g.getCode(e.charAt(r)),6)}getLength(){return this.getData().length}static getCode(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;if("A"<=t&&t<="Z")return t.charCodeAt(0)-65+10;switch(t){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw Error("illegal char :"+t)}}}class p extends d{stringToBytes;constructor(t,e){super(u.MODE_KANJI,t),this.stringToBytes=e}write(t){let e=this.stringToBytes(this.getData()),r=0;for(;r+1<e.length;){let i=(255&e[r])<<8|255&e[r+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw Error("illegal char at "+(r+1)+"/"+i);i-=49472}i=192*(i>>>8&255)+(255&i),t.put(i,13),r+=2}if(r<e.length)throw Error("illegal char at "+(r+1))}getLength(){return this.stringToBytes(this.getData()).length/2}}class m extends d{constructor(t){super(u.MODE_NUMBER,t)}write(t){let e=this.getData(),r=0;for(;r+2<e.length;)t.put(m.strToNum(e.substring(r,r+3)),10),r+=3;r<e.length&&(e.length-r==1?t.put(m.strToNum(e.substring(r,r+1)),4):e.length-r==2&&t.put(m.strToNum(e.substring(r,r+2)),7))}getLength(){return this.getData().length}static strToNum(t){let e=0;for(let r=0;r<t.length;r+=1)e=10*e+m.chatToNum(t.charAt(r));return e}static chatToNum(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-48;throw Error("illegal char :"+t)}}var $,w=$||={};w[w.PATTERN000=0]="PATTERN000",w[w.PATTERN001=1]="PATTERN001",w[w.PATTERN010=2]="PATTERN010",w[w.PATTERN011=3]="PATTERN011",w[w.PATTERN100=4]="PATTERN100",w[w.PATTERN101=5]="PATTERN101",w[w.PATTERN110=6]="PATTERN110",w[w.PATTERN111=7]="PATTERN111";class f{constructor(){throw Error("error")}static getPatternPosition(t){return f.PATTERN_POSITION_TABLE[t-1]}static PATTERN_POSITION_TABLE;static MAX_LENGTH;static getMaxLength(t,e,r){switch(r){case o.L:r=0;break;case o.M:r=1;break;case o.Q:r=2;break;case o.H:r=3;break;default:throw Error("e:"+r)}switch(e){case u.MODE_NUMBER:e=0;break;case u.MODE_ALPHA_NUM:e=1;break;case u.MODE_8BIT_BYTE:e=2;break;case u.MODE_KANJI:e=3;break;default:throw Error("m:"+e)}return f.MAX_LENGTH[t-1][r][e]}static getErrorCorrectPolynomial(t){let e=new h([1]);for(let r=0;r<t;r+=1)e=e.multiply(new h([1,a.gexp(r)]));return e}static getMaskFunc(t){switch(t){case $.PATTERN000:return(t,e)=>(t+e)%2==0;case $.PATTERN001:return t=>t%2==0;case $.PATTERN010:return(t,e)=>e%3==0;case $.PATTERN011:return(t,e)=>(t+e)%3==0;case $.PATTERN100:return(t,e)=>(~~(t/2)+~~(e/3))%2==0;case $.PATTERN101:return(t,e)=>t*e%2+t*e%3==0;case $.PATTERN110:return(t,e)=>(t*e%2+t*e%3)%2==0;case $.PATTERN111:return(t,e)=>(t*e%3+(t+e)%2)%2==0;default:throw Error("mask:"+t)}}static getLostPoint(t){let e=t.getModuleCount(),r=0;for(var i=0;i<e;i+=1)for(var s=0;s<e;s+=1){var o=0;let n=t.isDark(i,s);for(let r=-1;r<=1;r+=1)if(!(i+r<0||e<=i+r))for(let a=-1;a<=1;a+=1)s+a<0||e<=s+a||(0!=r||0!=a)&&n==t.isDark(i+r,s+a)&&(o+=1);o>5&&(r+=3+o-5)}for(i=0;i<e-1;i+=1)for(s=0;s<e-1;s+=1)o=0,t.isDark(i,s)&&(o+=1),t.isDark(i+1,s)&&(o+=1),t.isDark(i,s+1)&&(o+=1),t.isDark(i+1,s+1)&&(o+=1),(0==o||4==o)&&(r+=3);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(i,s)&&!t.isDark(i,s+1)&&t.isDark(i,s+2)&&t.isDark(i,s+3)&&t.isDark(i,s+4)&&!t.isDark(i,s+5)&&t.isDark(i,s+6)&&(r+=40);for(i=0;i<e;i+=1)for(s=0;s<e-6;s+=1)t.isDark(s,i)&&!t.isDark(s+1,i)&&t.isDark(s+2,i)&&t.isDark(s+3,i)&&t.isDark(s+4,i)&&!t.isDark(s+5,i)&&t.isDark(s+6,i)&&(r+=40);for(i=0,s=0;s<e;s+=1)for(o=0;o<e;o+=1)t.isDark(o,s)&&(i+=1);return r+Math.abs(100*i/e/e-50)/5*10}static getBCHTypeInfo(t){let e=t<<10;for(;f.getBCHDigit(e)-f.getBCHDigit(f.G15)>=0;)e^=f.G15<<f.getBCHDigit(e)-f.getBCHDigit(f.G15);return(t<<10|e)^f.G15_MASK}static getBCHTypeNumber(t){let e=t<<12;for(;f.getBCHDigit(e)-f.getBCHDigit(f.G18)>=0;)e^=f.G18<<f.getBCHDigit(e)-f.getBCHDigit(f.G18);return t<<12|e}static G15;static G18;static G15_MASK;static getBCHDigit(t){let e=0;for(;0!=t;)e+=1,t>>>=1;return e}}f.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]],f.MAX_LENGTH=[[[41,25,17,10],[34,20,14,8],[27,16,11,7],[17,10,7,4]],[[77,47,32,20],[63,38,26,16],[48,29,20,12],[34,20,14,8]],[[127,77,53,32],[101,61,42,26],[77,47,32,20],[58,35,24,15]],[[187,114,78,48],[149,90,62,38],[111,67,46,28],[82,50,34,21]],[[255,154,106,65],[202,122,84,52],[144,87,60,37],[106,64,44,27]],[[322,195,134,82],[255,154,106,65],[178,108,74,45],[139,84,58,36]],[[370,224,154,95],[293,178,122,75],[207,125,86,53],[154,93,64,39]],[[461,279,192,118],[365,221,152,93],[259,157,108,66],[202,122,84,52]],[[552,335,230,141],[432,262,180,111],[312,189,130,80],[235,143,98,60]],[[652,395,271,167],[513,311,213,131],[364,221,151,93],[288,174,119,74]]],f.G15=1335,f.G18=7973,f.G15_MASK=21522;class b{totalCount;dataCount;static RS_BLOCK_TABLE;constructor(t,e){this.totalCount=t,this.dataCount=e}getDataCount(){return this.dataCount}getTotalCount(){return this.totalCount}static getRSBlocks(t,e){e=(t=b.getRsBlockTable(t,e)).length/3;let r=[];for(let i=0;i<e;i+=1){let e=t[3*i],s=t[3*i+1],o=t[3*i+2];for(let t=0;t<e;t+=1)r.push(new b(s,o))}return r}static getRsBlockTable(t,e){switch(e){case o.L:return b.RS_BLOCK_TABLE[4*(t-1)];case o.M:return b.RS_BLOCK_TABLE[4*(t-1)+1];case o.Q:return b.RS_BLOCK_TABLE[4*(t-1)+2];case o.H:return b.RS_BLOCK_TABLE[4*(t-1)+3]}throw Error("tn:"+t+"/ecl:"+e)}}b.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]];let M=Array(41).fill(0).map((t,e)=>e);var v,A=v||={};A.L="L",A.M="M",A.Q="Q",A.H="H";var y,E=y||={};E.numeric="numeric",E.alphanumeric="alphanumeric",E.byte="byte",E.kanji="kanji",E.unicode="unicode";class z{static stringToBytesFuncs;static PAD0;static PAD1;typeNumber;errorCorrectLevel;qrDataList;modules=[];moduleCount=0;constructor(t=0,e=v.L){this.typeNumber=t,this.errorCorrectLevel=o[e],this.qrDataList=[]}getTypeNumber(){return this.typeNumber}setTypeNumber(t){this.typeNumber=t}getErrorCorrectLevel(){return this.errorCorrectLevel}setErrorCorrectLevel(t){this.errorCorrectLevel=t}clearData(){this.qrDataList=[]}addData(t,e=y.byte){if(t instanceof d)this.qrDataList.push(t);else{if("string"!=typeof t)throw Error(typeof t);switch(e){case y.numeric:this.qrDataList.push(new m(t));break;case y.alphanumeric:this.qrDataList.push(new g(t));break;case y.byte:this.qrDataList.push(new c(t,z.stringToBytesFuncs.default));break;case y.unicode:this.qrDataList.push(new c(t,z.stringToBytesFuncs.UTF8));break;case y.kanji:this.qrDataList.push(new p(t,z.stringToBytesFuncs.SJIS));break;default:throw Error("mode:"+e)}}}isDark(t,e){return null!=this.modules[t][e]&&this.modules[t][e]}getModuleCount(){return this.moduleCount}make(){if(this.typeNumber<1){let e=1;for(;e<40;e++){var t=b.getRSBlocks(e,this.errorCorrectLevel);let r=new s;if(this.qrDataList.forEach(t=>{r.put(t.getMode(),4),r.put(t.getLength(),t.getLengthInBits(e)),t.write(r)}),t=t.reduce((t,e)=>t+e.getDataCount(),0),r.getLengthInBits()<=8*t)break}this.typeNumber=e}this.makeImpl(!1,this.getBestMaskPattern())}getBestMaskPattern(){let t=0,e=0;for(let r=0;r<8;r+=1){this.makeImpl(!0,r);let i=f.getLostPoint(this);(0==r||t>i)&&(t=i,e=r)}return e}makeImpl(t,e){this.moduleCount=4*this.typeNumber+17,this.modules=[];for(let t=0;t<this.moduleCount;t+=1){this.modules.push([]);for(let e=0;e<this.moduleCount;e+=1)this.modules[t].push(null)}this.setupPositionProbePattern(0,0),this.setupPositionProbePattern(this.moduleCount-7,0),this.setupPositionProbePattern(0,this.moduleCount-7),this.setupPositionAdjustPattern(),this.setupTimingPattern(),this.setupTypeInfo(t,e),this.typeNumber>=7&&this.setupTypeNumber(t),t=z.createData(this.typeNumber,this.errorCorrectLevel,this.qrDataList),this.mapData(t,e)}mapData(t,e){let r=-1,i=this.moduleCount-1,s=7,o=0;e=f.getMaskFunc(e);for(let n=this.moduleCount-1;n>0;n-=2)for(6==n&&--n;;){for(let r=0;r<2;r+=1)if(null==this.modules[i][n-r]){let a=!1;o<t.length&&(a=1==(t[o]>>>s&1)),e(i,n-r)&&(a=!a),this.modules[i][n-r]=a,--s,-1==s&&(o+=1,s=7)}if(i+=r,i<0||this.moduleCount<=i){i-=r,r=-r;break}}}setupPositionAdjustPattern(){let t=f.getPatternPosition(this.typeNumber);t.forEach(e=>{t.forEach(t=>{if(null==this.modules[e][t])for(let r=-2;r<=2;r+=1)for(let i=-2;i<=2;i+=1)this.modules[e+r][t+i]=-2==r||2==r||-2==i||2==i||0==r&&0==i})})}setupPositionProbePattern(t,e){for(let r=-1;r<=7;r+=1)for(let i=-1;i<=7;i+=1)t+r<=-1||this.moduleCount<=t+r||e+i<=-1||this.moduleCount<=e+i||(this.modules[t+r][e+i]=0<=r&&r<=6&&(0==i||6==i)||0<=i&&i<=6&&(0==r||6==r)||2<=r&&r<=4&&2<=i&&i<=4)}setupTimingPattern(){for(var t=8;t<this.moduleCount-8;t+=1)null==this.modules[t][6]&&(this.modules[t][6]=t%2==0);for(t=8;t<this.moduleCount-8;t+=1)null==this.modules[6][t]&&(this.modules[6][t]=t%2==0)}setupTypeNumber(t){let e=f.getBCHTypeNumber(this.typeNumber);for(var r=0;r<18;r+=1)this.modules[~~(r/3)][r%3+this.moduleCount-8-3]=!t&&1==(e>>r&1);for(r=0;r<18;r+=1)this.modules[r%3+this.moduleCount-8-3][~~(r/3)]=!t&&1==(e>>r&1)}setupTypeInfo(t,e){e=f.getBCHTypeInfo(this.errorCorrectLevel<<3|e);for(var r=0;r<15;r+=1){var i=!t&&1==(e>>r&1);r<6?this.modules[r][8]=i:r<8?this.modules[r+1][8]=i:this.modules[this.moduleCount-15+r][8]=i}for(r=0;r<15;r+=1)i=!t&&1==(e>>r&1),r<8?this.modules[8][this.moduleCount-r-1]=i:r<9?this.modules[8][15-r-1+1]=i:this.modules[8][15-r-1]=i;this.modules[this.moduleCount-8][8]=!t}static createData(t,e,r){e=b.getRSBlocks(t,e);let i=new s;if(r.forEach(e=>{i.put(e.getMode(),4),i.put(e.getLength(),e.getLengthInBits(t)),e.write(i)}),r=e.reduce((t,e)=>t+e.getDataCount(),0),i.getLengthInBits()>8*r)throw Error("code length overflow. ("+i.getLengthInBits()+">"+8*r+")");for(i.getLengthInBits()+4<=8*r&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(!1);for(;!(i.getLengthInBits()>=8*r)&&(i.put(z.PAD0,8),!(i.getLengthInBits()>=8*r));)i.put(z.PAD1,8);return z.createBytes(i,e)}static createBytes(t,e){function r(t){let e=[];for(let r=0;r<t;r+=1)e.push(0);return e}var i=0,s=0;let o=0;var n=Array(e.length).map(()=>[]);let a=Array(e.length).map(()=>[]);for(var u=0;u<e.length;u+=1){var l=e[u].getDataCount(),d=e[u].getTotalCount()-l;s=Math.max(s,l),o=Math.max(o,d),n[u]=r(l);for(var c=0;c<n[u].length;c+=1)n[u][c]=255&t.getBuffer()[c+i];for(i+=l,d=f.getErrorCorrectPolynomial(d),l=new h(n[u],d.getLength()-1).mod(d),a[u]=r(d.getLength()-1),d=0;d<a[u].length;d+=1)c=d+l.getLength()-a[u].length,a[u][d]=c>=0?l.getAt(c):0}for(t=r(t=e.reduce((t,e)=>t+e.getTotalCount(),0)),i=0,u=0;u<s;u+=1)for(l=0;l<e.length;l+=1)u<n[l].length&&(t[i]=n[l][u],i+=1);for(s=0;s<o;s+=1)for(n=0;n<e.length;n+=1)s<a[n].length&&(t[i]=a[n][s],i+=1);return t}}z.stringToBytesFuncs={default(t){let e=[];for(let r=0;r<t.length;r+=1){let i=t.charCodeAt(r);e.push(255&i)}return e}},z.PAD0=236,z.PAD1=17;let D=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function x(t,...e){if(!e.length)return t;let r=e.shift();return void 0!==r&&D(t)&&D(r)?(t={...t},Object.keys(r).forEach(e=>{let i=t[e],s=r[e];Array.isArray(i)&&Array.isArray(s)?t[e]=s:D(i)&&D(s)?t[e]=x({...i},s):t[e]=s}),x(t,...e)):t}var T,k=T||={};function O(t){if(!(t={...t}).colorStops||!t.colorStops.length)throw Error("Field 'colorStops' is required in gradient");return t.rotation=t.rotation?Number(t.rotation):0,t.colorStops=t.colorStops.map(t=>({...t,offset:Number(t.offset)})),t}k.radial="radial",k.linear="linear";var P,N=P||={};N.dot="dot",N.randomDot="random-dot",N.rounded="rounded",N.extraRounded="extra-rounded",N.verticalLine="vertical-line",N.horizontalLine="horizontal-line",N.classy="classy",N.classyRounded="classy-rounded",N.square="square",N.smallSquare="small-square",N.tinySquare="tiny-square",N.diamond="diamond",N.wave="wave",N.heart="heart",N.star="star",N.weave="weave",N.pentagon="pentagon",N.hexagon="hexagon",N.zebraHorizontal="zebra-horizontal",N.zebraVertical="zebra-vertical",N.blocksHorizontal="blocks-horizontal",N.blocksVertical="blocks-vertical",N.blobs="blobs";var L,C=L||={};C.dot="dot",C.square="square",C.heart="heart",C.extraRounded="extra-rounded",C.classy="classy",C.inpoint="inpoint",C.outpoint="outpoint",C.star="star",C.pentagon="pentagon",C.hexagon="hexagon",C.diamond="diamond";var S,B=S||={};B.dot="dot",B.square="square",B.extraRounded="extra-rounded",B.classy="classy",B.inpoint="inpoint",B.outpoint="outpoint",B.centerCircle="center-circle";var _,q=_||={};q.square="square",q.circle="circle";var R,I=R||={};I.center="center",I.overlay="overlay",I.background="background";let H={document:void 0,shape:_.square,width:void 0,height:void 0,size:void 0,data:"",qrOptions:{typeNumber:M[0],mode:void 0,errorCorrectionLevel:v.Q},imageOptions:{mode:R.center,imageSize:.4,crossOrigin:void 0,margin:0,fill:{color:"rgba(255,255,255,1)"}},dotsOptions:{type:P.square,color:"#000",size:10}};function G(t){return(t={...t}).imageOptions={...t.imageOptions,imageSize:Math.min(1,Number(t.imageOptions.imageSize))||1,margin:Number(t.imageOptions.margin),fill:{...t.imageOptions.fill}},t.imageOptions.mode==R.overlay&&(t.imageOptions.margin=0),t.imageOptions.fill.gradient&&(t.imageOptions.fill.gradient=O(t.imageOptions.fill.gradient)),t.dotsOptions={...t.dotsOptions},t.dotsOptions.gradient&&(t.dotsOptions.gradient=O(t.dotsOptions.gradient)),t.dotsOptions.size=Math.round(Math.max(0,t.dotsOptions.size)||10),t.cornersSquareOptions&&(t.cornersSquareOptions={...t.cornersSquareOptions},t.cornersSquareOptions.gradient&&(t.cornersSquareOptions.gradient=O(t.cornersSquareOptions.gradient))),t.cornersDotOptions&&(t.cornersDotOptions={...t.cornersDotOptions},t.cornersDotOptions.gradient&&(t.cornersDotOptions.gradient=O(t.cornersDotOptions.gradient))),t.backgroundOptions&&(t.backgroundOptions={...t.backgroundOptions},t.backgroundOptions.gradient&&(t.backgroundOptions.gradient=O(t.backgroundOptions.gradient))),t.document||(t.document=document),t}let U={[v.L]:.07,[v.M]:.15,[v.Q]:.25,[v.H]:.3};let F={dot:t=>{const{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","circle")).setAttribute("cx",e(i+r/2)),t.setAttribute("cy",e(s+r/2)),t.setAttribute("r",e(r/2)),t},square:(t,{width:r=t.size,height:i=t.size}={})=>{const{x:s,y:o,size:n,document:a}=t;return(t=a.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(s+(n-r)/2)),t.setAttribute("y",e(o+(n-i)/2)),t.setAttribute("width",e(r)),t.setAttribute("height",e(i)),t},sideRounded:(e,{height:r=e.size}={})=>{const{size:i,x:s,y:o,document:n}=e;return(e=n.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${s} ${o+(i-r)/2} v ${r} h ${i/2} a ${r/2} ${r/2} 0 0 0 0 ${-r} z`),e},cornerRounded:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},cornerExtraRounded:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r} h ${r} a ${r} ${r} 0 0 0 ${-r} ${-r} z`),e},classyDot:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s} v ${r/2} a ${r/2} ${r/2} 0 0 0 ${r/2} ${r/2} h ${r/2} v ${-r/2} a ${r/2} ${r/2} 0 0 0 ${-r/2} ${-r/2} z`),e},wave:e=>{const{size:r,x:i,y:s,document:o}=e;var n=5*Math.PI/180,a=65*Math.PI/180;e=r*(1-.65*Math.sin(n)),n=-r*(.95-.65*Math.cos(n));const h=-r*Math.sin(a)/2;a=r*Math.cos(a)/2;const u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("d",t`M ${i} ${s+r} c ${.65*r} 0 ${e} ${n} ${r} ${.95*-r} c ${h} ${a} ${-r/2} ${r*(.95-1)} ${-r} ${r*(.95-1)} z`),u},heart:t=>{const{size:e,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",r(["M",1,.31629,"c",-86e-5,.15702,-.10534,.26323,-.21876,.38123,"c",-.06736,.06834,-.18938,.17948,-.28124,.26126,"c",-.09188,-.08178,-.2139,-.19292,-.28124,-.26126,"c",-.11344,-.118,-.2179,-.22422,-.21876,-.38123,"c",-96e-5,-.27136,.33154,-.36842,.5,-.17,"c",.16844,-.19842,.50094,-.10136,.5,.17,"z"],{x:i,y:s,size:e})),t},rounded:t=>{const{size:r,x:i,y:s,document:o}=t;return(t=o.createElementNS("http://www.w3.org/2000/svg","rect")).setAttribute("x",e(i)),t.setAttribute("y",e(s)),t.setAttribute("width",e(r)),t.setAttribute("height",e(r)),t.setAttribute("rx",e(r/4)),t.setAttribute("ry",e(r/4)),t},classy:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");return n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z`),n},inpoint:e=>{const{size:r,x:i,y:s,document:o}=e;return(e=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",t`M ${i} ${s+r/2} v ${r/4} a ${r/4} ${r/4} 0 0 0 ${r/4} ${r/4} h ${r/4*3} v ${-r/4*3} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${-r/4} h ${-r/2} a ${r/4} ${r/4} 0 0 0 ${-r/4} ${r/4} z`),e},star:(e,{spikes:r=5,outerRadius:i=e.size/2,innerRadius:s=e.size/4}={})=>{const{size:o,x:n,y:a,document:h}=e,u=n+o/2,l=a+o/2,d=Math.PI/r;return(e=h.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("d",Array(2*r).fill(0).map((e,r)=>t`${0===r?"M":"L"} ${u+(e=r%2==0?i:s)*Math.sin(r*d)} ${l-e*Math.cos(r*d)}`).join(" ")),e},weave:e=>{const{size:r,x:i,y:s,document:o}=e,n=(r-(e=.6*r))/2,a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("d",t`M ${i+n} ${s} l ${e} 0 l 0 ${n} l ${n} 0 l 0 ${e} l ${-n} 0 l 0 ${n} l ${-e} 0 l 0 ${-n} l ${-n} 0 l 0 ${-e} l ${n} 0 z`),a},blob:(e,r)=>{const{size:i,x:s,y:o,document:n}=e;e=i/7;const a=n.createElementNS("http://www.w3.org/2000/svg","path"),h=[t`M ${s} ${o+2.5*e}`];let u=2*e;return"round"==r.bl?(h.push(t`v ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e}`),u=2*e):"out"==r.bl?(h.push(t`v ${5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${2.5*e} ${-2.5*e}`),u=2*e):(h.push(t`v ${2.5*e+u}`),u=4.5*e),"round"==r.br?(h.push(t`h ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${-2.5*e}`),u=-2*e):"out"==r.br?(h.push(t`h ${5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${-2.5*e} ${-2.5*e}`),u=-2*e):(h.push(t`h ${2.5*e+u}`),u=-4.5*e),"round"==r.tr?(h.push(t`v ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${-2.5*e} ${-2.5*e}`),u=-2*e):"out"==r.tr?(h.push(t`v ${-5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${-2.5*e} ${2.5*e}`),u=-2*e):(h.push(t`v ${-2.5*e+u}`),u=-4.5*e),"round"==r.tl?h.push(t`h ${u} a ${2.5*e} ${2.5*e} 0 0 0 ${-2.5*e} ${2.5*e}`):"out"==r.tl?h.push(t`h ${-5*e+u} a ${2.5*e} ${2.5*e} 0 0 1 ${2.5*e} ${2.5*e}`):h.push(t`h ${-2.5*e+u}`),a.setAttribute("d",h.join(" ")+" z"),a}},V={[L.dot]:t=>i({...t,draw:F.dot}),[L.square]:t=>i({...t,draw:F.square}),[L.heart]:t=>F.heart(t),[L.extraRounded]:t=>i({...t,draw:F.rounded}),[L.classy]:t=>i({...t,draw:F.classy}),[L.inpoint]:t=>i({...t,draw:F.inpoint}),[L.outpoint]:t=>i({...t,rotation:(t.rotation||0)+Math.PI,draw:F.inpoint}),[L.star]:t=>F.star(t),[L.pentagon]:t=>F.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[L.hexagon]:t=>F.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[L.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>F.square(t,{width:.85*t.size,height:.85*t.size})})};let X={dot:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i+r/2} ${s} a ${r/2} ${r/2} 0 1 0 0.1 0 z m 0 ${e} a ${r/2-e} ${r/2-e} 0 1 1 -0.1 0 Z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+r/2} ${s-e} a ${r/2+e} ${r/2+e} 0 1 0 0.1 0 z`),[n,a]},square:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s} v ${r} h ${r} v ${-r} z M ${i+e} ${s+e} h ${r-2*e} v ${r-2*e} h ${2*e-r} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i-e} ${s-e} h ${r+2*e} v ${r+2*e} h ${-r-2*e} z`),[n,a]},extraRounded:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*-e} v ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*e} h ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i-e} ${s+2.5*e} v ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*e} h ${2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*-e} h ${-2*e} a ${3.5*e} ${3.5*e} 0 0 0 ${3.5*-e} ${3.5*e} z`),[n,a]},classy:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} H ${i} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-3.5*e} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-5.5*e} z`),[n,a]},inpoint:e=>{const{size:r,x:i,y:s,document:o}=e;e=r/7;const n=o.createElementNS("http://www.w3.org/2000/svg","path");n.setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${i} ${s+2.5*e} v ${2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*e} ${2.5*e} h ${4.5*e} v ${-4.5*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*-e} h ${-2*e} a ${2.5*e} ${2.5*e} 0 0 0 ${2.5*-e} ${2.5*e} z M ${i+2.5*e} ${s+e} h ${2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*e} v ${3.5*e} h ${-3.5*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*-e} ${1.5*-e} v ${-2*e} a ${1.5*e} ${1.5*e} 0 0 1 ${1.5*e} ${1.5*-e} z`);const a=o.createElementNS("http://www.w3.org/2000/svg","path");return a.setAttribute("clip-rule","evenodd"),a.setAttribute("d",t`M ${i+.5*e} ${s-e} h ${4*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*e} v ${5.5*e} h ${-5.5*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*-e} ${3.5*-e} v ${-2*e} a ${3.5*e} ${3.5*e} 0 0 1 ${3.5*e} ${3.5*-e} z`),[n,a]},centerCircle:e=>{const{x:r,y:i,size:s,document:o}=e;var n=s/2.5;const a=r+s/2,h=i+s/2;e=s/7;const u=o.createElementNS("http://www.w3.org/2000/svg","path");return u.setAttribute("clip-rule","evenodd"),u.setAttribute("d",t`M ${r} ${i} h ${s} v ${s} h ${-s} z M ${a-n} ${h} a ${n} ${n} 0 1 0 ${2*n} 0 a ${n} ${n} 0 1 0 ${2*-n} 0 z`),(n=o.createElementNS("http://www.w3.org/2000/svg","path")).setAttribute("clip-rule","evenodd"),n.setAttribute("d",t`M ${r-e} ${i-e} h ${s+2*e} v ${s+2*e} h ${-s-2*e} z`),[u,n]}},j={[S.dot]:t=>X.dot(t),[S.square]:t=>X.square(t),[S.extraRounded]:t=>X.extraRounded(t),[S.classy]:t=>i({...t,draw:X.classy}),[S.inpoint]:t=>i({...t,draw:X.inpoint}),[S.outpoint]:({rotation:t,...e})=>i({...e,rotation:(t||0)+Math.PI,draw:X.inpoint}),[S.centerCircle]:t=>X.centerCircle(t)};function K({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:n=F.cornerRounded,end:a=F.sideRounded}={}){let h=o?+o(-1,0):0,u=o?+o(1,0):0,l=o?+o(0,-1):0,d=h+u+l+(o=o?+o(0,1):0);return 0===d?F.dot({x:t,y:e,size:r,document:s}):d>2||h&&u||l&&o?F.square({x:t,y:e,size:r,document:s}):2===d?(a=0,h&&l?a=Math.PI/2:l&&u?a=Math.PI:u&&o&&(a=-Math.PI/2),i({x:t,y:e,size:r,rotation:a,document:s,draw:n})):(n=0,l?n=Math.PI/2:u?n=Math.PI:o&&(n=-Math.PI/2),i({x:t,y:e,size:r,rotation:n,document:s,draw:a}))}function Q({x:t,y:e,size:r,document:s,getNeighbor:o},{corner:n=F.cornerRounded}={}){let a=o?+o(-1,0):0,h=o?+o(1,0):0,u=o?+o(0,-1):0;return a+h+u+(o=o?+o(0,1):0)===0?i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:F.classyDot}):a||u?h||o?F.square({x:t,y:e,size:r,document:s}):i({x:t,y:e,size:r,rotation:Math.PI/2,document:s,draw:n}):i({x:t,y:e,size:r,rotation:-Math.PI/2,document:s,draw:n})}function Y({x:t,y:e,size:r,document:s,getNeighbor:o},{stripe:n=r,rotation:a=0,endpoint:h=F.sideRounded,dot:u=F.dot}={}){let l=o?+o(0,-1):0;return o=o?+o(0,1):0,l&&o?i({x:t,y:e,size:r,rotation:a,document:s,draw:()=>F.square({x:t,y:e,size:r,document:s},{width:n})}):l&&!o?(a+=Math.PI/2,i({x:t,y:e,size:r,rotation:a,document:s,draw:t=>h(t,{height:n})})):o&&!l?(a-=Math.PI/2,i({x:t,y:e,size:r,rotation:a,document:s,draw:t=>h(t,{height:n})})):i({x:t,y:e,size:r,rotation:a,document:s,draw:()=>u({x:t+(r-n)/2,y:e+(r-n)/2,size:n,document:s})})}let J={[P.dot]:t=>F.dot(t),[P.randomDot]:({size:t,x:e,y:r,getPRandom:i,...s})=>{const o=.25*(i=i||Math.random)()+.75;return F.dot({...s,size:t*o,x:e+t*i()*(1-o),y:r+t*i()*(1-o)})},[P.rounded]:t=>K(t),[P.extraRounded]:t=>K(t,{corner:F.cornerExtraRounded}),[P.verticalLine]:t=>Y(t),[P.horizontalLine]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{rotation:-Math.PI/2}),[P.classy]:t=>Q(t),[P.classyRounded]:t=>Q(t,{corner:F.cornerExtraRounded}),[P.square]:t=>F.square(t),[P.smallSquare]:({x:t,y:e,size:r,document:i})=>F.square({x:t+=.15*r,y:e+=.15*r,size:r=.7*r,document:i}),[P.tinySquare]:({x:t,y:e,size:r,document:i})=>F.square({x:t+=.35*r,y:e+=.35*r,size:r=.3*r,document:i}),[P.diamond]:t=>i({...t,rotation:Math.PI/4,draw:t=>F.square(t,{width:.85*t.size,height:.85*t.size})}),[P.wave]:t=>K(t,{corner:F.cornerExtraRounded,end:F.wave}),[P.heart]:t=>F.heart(t),[P.star]:t=>F.star(t),[P.weave]:t=>F.weave(t),[P.pentagon]:t=>F.star(t,{spikes:2.5,outerRadius:t.size/2,innerRadius:t.size/2}),[P.hexagon]:t=>F.star(t,{spikes:3,outerRadius:t.size/2,innerRadius:t.size/2}),[P.zebraVertical]:t=>Y(t,{stripe:.8*t.size}),[P.zebraHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2}),[P.blocksVertical]:t=>Y(t,{stripe:.8*t.size,endpoint:(e,r)=>{const i=t.size*(1-.25*(t.getPRandom||Math.random)());return F.square({...e,x:t.x-(t.size-i)/2},{...r,width:i})},dot:e=>{var r=t.getPRandom||Math.random;const i=t.size*(1-.25*r());return r=t.y+(t.size-i)*r(),F.square({...e,y:r},{height:i})}}),[P.blocksHorizontal]:({getNeighbor:t,...e})=>Y({...e,getNeighbor:t?(e,r)=>t(r,e):void 0},{stripe:.8*e.size,rotation:-Math.PI/2,endpoint:(t,r)=>{const i=e.size*(1-.25*(e.getPRandom||Math.random)());return F.square({...t,x:e.x-(e.size-i)/2},{...r,width:i})},dot:t=>{var r=e.getPRandom||Math.random;const i=e.size*(1-.25*r());return r=e.y+(e.size-i)*r(),F.square({...t,y:r},{height:i})}}),[P.blobs]:({getNeighbor:t,...e})=>{const r=t?.(-1,-1),i=t?.(0,-1),s=t?.(1,-1),o=t?.(1,0),n=t?.(1,1),a=t?.(0,1),h=t?.(-1,1);t=t?.(-1,0);const u={tl:"square",tr:"square",bl:"square",br:"square"};return!t&&r&&(u.tl="out"),!i&&s&&(u.tr="out"),!o&&n&&(u.br="out"),!a&&h&&(u.bl="out"),t||r||i||(u.tl="round"),i||s||o||(u.tr="round"),o||n||a||(u.br="round"),a||h||t||(u.bl="round"),F.blob(e,u)}};function W(t,e){let r=J[t]||J[P.square];if(!e?.length)return r;let i=function(t){return e=>{for(let r of t){let t=r.drawDot?.(e);if(t)return t}}}(e);return t=>i(t)||r(t)}let Z={toDataURL:t=>"string"==typeof t&&t.startsWith("data:")?Promise.resolve(t):new Promise((e,r)=>{if("string"==typeof t){const i=new XMLHttpRequest;i.onload=()=>{const t=new FileReader;t.onloadend=()=>{e(t.result)},t.readAsDataURL(i.response)},i.onerror=i.onabort=i.ontimeout=r,i.open("GET",t,!0),i.responseType="blob",i.send()}else{const r=new FileReader;r.onloadend=()=>{e(r.result)},r.readAsDataURL(t)}}),getSize:(t,e)=>new Promise((r,i)=>{const s=new Image;"string"===e&&(s.crossOrigin=e),s.onload=()=>{r({width:s.width,height:s.height})},s.onerror=s.onabort=i,"string"==typeof t?s.src=t:Z.toDataURL(t).then(t=>s.src=t).catch(i)})};function tt(t){var e=[];let r=1;if("#"===(t=t.toLowerCase())[0]){let i=(t=t.slice(1)).length;i<=4?(e=[parseInt(t[0]+t[0],16),parseInt(t[1]+t[1],16),parseInt(t[2]+t[2],16)],4===i&&(r=parseInt(t[3]+t[3],16)/255)):(e=[parseInt(t[0]+t[1],16),parseInt(t[2]+t[3],16),parseInt(t[4]+t[5],16)],8===i&&(r=parseInt(t[6]+t[7],16)/255)),e[0]||(e[0]=0),e[1]||(e[1]=0),e[2]||(e[2]=0)}else{if(!(e=/^((?:rgba?))\s*\(([^)]*)\)/.exec(t)))return{value:t,alpha:r};r=(e=(e=e[2].trim().split(/\s*[,/]\s*|\s+/)).map((t,e)=>"%"===t[t.length-1]?(t=parseFloat(t)/100,3===e?t:255*t):"none"===t?0:parseFloat(t))).length>3?e.pop():1}return{value:"#"+e.map(t=>Math.max(0,Math.min(255,t)).toString(16).padStart(2,"0")).join(""),alpha:Math.max(0,Math.min(1,r))}}function et(t,e,r,i=!0){let s;return()=>{if(null==s){var o=s=0;for(let n=-3;n<4;n++)for(let a=-3;a<4;a++)o++,s|=Number(t[(e+n+t.length<<a)%t.length]?.[(r+a+t.length<<n)%t.length]===i)<<o}return o=s+=1831565813,o=Math.imul(o^o>>>15,1|o),(((o^=o+Math.imul(o^o>>>7,61|o))^o>>>14)>>>0)/4294967296}}let rt=[[1,1,1,1,1,1,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,0,0,0,0,0,1],[1,1,1,1,1,1,1]],it=new Set(Object.values(S));let st=[[0,0,0,0,0,0,0],[0,0,0,0,0,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,1,1,1,0,0],[0,0,0,0,0,0,0],[0,0,0,0,0,0,0]],ot=new Set(Object.values(L));class nt{options;_element;_fakeMatrix;get element(){return this._element}defs;backgroundMask;dotsMask;lightDotsMask;qr;document;imageTools;constructor(t){this.options=t,this.document=t.document,this._element=this.document.createElementNS("http://www.w3.org/2000/svg","svg");let r=e(t.size);this._element.setAttribute("width",r),this._element.setAttribute("height",r),this._element.setAttribute("viewBox",`0 0 ${r} ${r}`),this.defs=this.document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this.defs),this.imageTools=t.imageTools||Z}get width(){return this.options.size}get height(){return this.options.size}async drawQR(t){let e=t.getModuleCount();var r=parseInt(((e-17)/4).toFixed(0),10);let i=this.options.dotsOptions.size,s={hideXDots:0,hideYDots:0,width:0,height:0};if(this.qr=t,this.options.image){t=await this.imageTools.getSize(this.options.image,this.options.imageOptions.crossOrigin);let{imageOptions:o,errorCorrectionPercent:n}=this.options;if(o.mode==R.background){r=(this.options.size-2*(this.options.backgroundOptions&&this.options.backgroundOptions.margin||0)*i)*o.imageSize;let{width:e,height:n}=t;n=n/e*r,e=r,n>r&&(e=e/n*r,n=r),s={hideXDots:0,hideYDots:0,width:e,height:n}}else{let a=o.imageSize*n;r=f.getPatternPosition(r),s=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:s,margin:o}){if(t<=0||e<=0||r<=0||s<=0||4*o**2>r)return{height:0,width:0,hideYDots:0,hideXDots:0};i&&i%2==0&&(i=Math.max(1,i-1));var n=Math.max(e,t),a=Math.min(e,t),h=0;i=(i||r)-2*o;do{let t=h+(i-h)/2,e=Math.max(1,Math.ceil(t+2*o));e%2==0&&e++;let s=Math.max(1,Math.ceil(t*a/n+2*o));s%2==0&&s++,e*s>r?i=t:h=t}while(Math.abs(h-i)>.001);return(r=Math.max(1,Math.ceil(h+2*o)))%2==0&&r++,(a=Math.max(1,Math.ceil(h*a/n+2*o)))%2==0&&a++,e>t?n=r:(n=a,a=r),r=i=(n-2*o)*s,(i=i*t/e)>(h=(a-2*o)*s)&&(i=h,r=h*e/t),{height:Math.round(i+2*o*s),width:Math.round(r+2*o*s),hideYDots:a,hideXDots:n}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:Math.floor(a*(e*e-192-2*(e-16)-r.length**2*25)),maxHiddenAxisDots:e-14,dotSize:i,margin:o.margin})}}this.drawBackground(),this.options.imageOptions.mode!=R.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawDots((t,r)=>!(this.options.imageOptions.mode==R.center&&t>=(e-s.hideXDots)/2&&t<(e+s.hideXDots)/2&&r>=(e-s.hideYDots)/2&&r<(e+s.hideYDots)/2||t<8&&r<8||t>=e-8&&r<8||r>=e-8&&t<8)),this.options.imageOptions.mode==R.overlay&&this.options.image&&s.width>0&&s.height>0&&await this.drawImage({width:s.width,height:s.height,count:e,dotSize:i}),this.drawCorners()}drawBackground(){let t=this.options;if(this._element&&t.backgroundOptions){this.createColor({options:t.backgroundOptions.gradient,color:t.backgroundOptions.color,additionalRotation:0,x:0,y:0,height:t.size,width:t.size,name:"background-color"});let r=this.document.createElementNS("http://www.w3.org/2000/svg","rect");this.backgroundMask=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),r.setAttribute("x",e(0)),r.setAttribute("y",e(0)),r.setAttribute("width",e(t.size)),r.setAttribute("height",e(t.size)),r.setAttribute("rx",e(t.size/2*(t.backgroundOptions.round||0))),this.backgroundMask.appendChild(r)}}drawDots(t){if(!this.qr)throw Error("QR code is not defined");let e=this.options;var r=this.qr.getModuleCount();if(r>e.size)throw Error("The canvas is too small");let i=this.options.dotsOptions.size;var s=e.size;e.imageOptions.mode==R.background&&(s-=2*i*(e.imageOptions.margin||0));var o=Math.floor((e.size-r*i)/2);let n=W(e.dotsOptions.type,e.plugins);this.dotsMask=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask),e.imageOptions.mode==R.background&&(this.lightDotsMask=this.createMask("mask-light-dot-color"),this.defs.appendChild(this.lightDotsMask));var a=0;let h=0;a=r,e.shape===_.circle?(a=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,h=Math.floor((s/i-r-2*a)/2),a=r+2*h):e.imageOptions.mode==R.background&&(h=1,a=r+2*h),s=o-h*i,o=r+2*h,this._fakeMatrix=Array(a);var u=Math.floor(a/2);for(let i=0;i<a;i++){this._fakeMatrix[i]=Array(a);for(let s=0;s<a;s++)if(i>h-1&&i<a-h&&s>h-1&&s<a-h){let e=i-h,r=s-h;t&&!t(e,r)?this._fakeMatrix[i][s]=void 0:this._fakeMatrix[i][s]=!!this.qr.isDark(r,e)}else this._fakeMatrix[i][s]=e.shape===_.circle&&Math.sqrt((i-u)*(i-u)+(s-u)*(s-u))>u?void 0:i==h-1||i==a-h||s==h-1||s==a-h?(s==h-1&&(i<h+8||i>a-h-9)||s==a-h&&i<h+8||i==h-1&&(s<h+8||s>a-h-9)||i==a-h&&s<h+8)&&void 0:this.qr.isDark(s-2*h<0?s:s>=r?s-2*h:s-h,i-2*h<0?i:i>=r?i-2*h:i-h)}t=f.getPatternPosition((r-17)/4);for(let e=0;e<a;e++){r=t.find(t=>e-h>t-3&&e-h<t+3);for(let o=0;o<a;o++)u=t.find(t=>o-h>t-3&&o-h<t+3),null!=this._fakeMatrix[e][o]&&(this.lightDotsMask&&(n=r&&u&&(r!=t[0]&&u!=t[0]||u!=t[0]&&u!=t[t.length-1]||r!=t[0]&&r!=t[t.length-1])?W(P.square):W(P.tinySquare)),this._fakeMatrix[e][o]?this.dotsMask&&this.dotsMask.appendChild(n({x:s+e*i,y:s+o*i,size:i,document:this.options.document,getNeighbor:(t,r)=>!0===this._fakeMatrix[e+t]?.[o+r],getPRandom:et(this._fakeMatrix,e,o)})):this.lightDotsMask&&this.lightDotsMask&&this.lightDotsMask.appendChild(n({x:s+e*i,y:s+o*i,size:i,document:this.options.document,getNeighbor:(t,r)=>!1===this._fakeMatrix[e+t]?.[o+r],getPRandom:et(this._fakeMatrix,e,o,!1)})))}this.lightDotsMask&&this.createColor({options:e.imageOptions.fill.gradient,color:e.imageOptions.fill.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"light-dot-color"}),this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:s,y:s,height:o*i,width:o*i,name:"dot-color"})}drawCorners(){if(!this.qr)throw Error("QR code is not defined");let t=this.options;if(!this._element)throw Error("Element code is not defined");let e=this.qr.getModuleCount(),r=this.options.dotsOptions.size,i=7*r,s=3*r,o=Math.floor((t.size-e*r)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach(([n,a,h])=>{var u=o+n*r*(e-7);let l=o+a*r*(e-7),d=this.dotsMask,c=this.dotsMask;(t.cornersSquareOptions?.gradient||t.cornersSquareOptions?.color)&&(d=this.createMask(`mask-corners-square-color-${n}-${a}`),this.defs.appendChild(d),c=c=d,this.createColor({options:t.cornersSquareOptions?.gradient,color:t.cornersSquareOptions?.color,additionalRotation:h,x:u,y:l,height:i,width:i,name:`corners-square-color-${n}-${a}`}));var g={x:u,y:l,size:i,document:this.options.document,rotation:h};let p=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerSquare?.(e);if(t)return t}}}(t.plugins)(g):void 0;if(p){let[t,e]=p;d&&d.appendChild(t),this.lightDotsMask&&this.lightDotsMask.appendChild(e)}else if(function(t){return!(!t||!it.has(t))}(t.cornersSquareOptions?.type)){let[e,r]=(j[t.cornersSquareOptions.type]||j[S.square])(g);d&&d.appendChild(e),this.lightDotsMask&&this.lightDotsMask.appendChild(r)}else{g=W(t.cornersSquareOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<rt.length;t++)for(let e=0;e<rt[t].length;e++)rt[t]?.[e]?d&&d.appendChild(g({x:u+t*r,y:l+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!rt[t+r]?.[e+i],getPRandom:et(this._fakeMatrix,u/r+t,l/r+e,!1)})):this.lightDotsMask&&!st[t]?.[e]&&this.lightDotsMask&&this.lightDotsMask.appendChild(g({x:u+t*r,y:l+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!rt[t+r]?.[e+i]&&!st[t+r]?.[e+i],getPRandom:et(this._fakeMatrix,u/r+t,l/r+e,!1)}));if(this.lightDotsMask)for(let t=-1;t<8;t++)for(let e=-1;e<8;e++)(-1==t||7==t||-1==e||7==e)&&this.lightDotsMask&&this.lightDotsMask.appendChild(g({x:u+t*r,y:l+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>(i=e+i,(r=t+r)>=-1&&r<=7&&i>=-1&&i<=7&&(-1==r||7==r||-1==i||7==i)),getPRandom:et(this._fakeMatrix,u/r+t,l/r+e,!1)}))}if((t.cornersDotOptions?.gradient||t.cornersDotOptions?.color)&&(c=this.createMask(`mask-corners-dot-color-${n}-${a}`),this.defs.appendChild(c),this.createColor({options:t.cornersDotOptions?.gradient,color:t.cornersDotOptions?.color,additionalRotation:h,x:u+2*r,y:l+2*r,height:s,width:s,name:`corners-dot-color-${n}-${a}`})),n={x:u+2*r,y:l+2*r,size:s,document:this.document,rotation:h},a=t.plugins?.length?function(t){return e=>{for(let r of t){let t=r.drawCornerDot?.(e);if(t)return t}}}(t.plugins)(n):void 0)c&&c.appendChild(a);else if(function(t){return!(!t||!ot.has(t))}(t.cornersDotOptions?.type))u=V[t.cornersDotOptions.type]||V[L.square],c&&c.appendChild(u(n));else{n=W(t.cornersDotOptions?.type||t.dotsOptions.type,t.plugins);for(let t=0;t<st.length;t++)for(let e=0;e<st[t].length;e++)st[t]?.[e]&&c&&c.appendChild(n({x:u+t*r,y:l+e*r,size:r,document:this.options.document,getNeighbor:(r,i)=>!!st[t+r]?.[e+i],getPRandom:et(this._fakeMatrix,u/r+t,l/r+e,!1)}))}})}async drawImage({width:t,height:r,count:i,dotSize:s}){var o=this.options,n=Math.floor((o.size-i*s)/2),a=o.imageOptions.margin*s;o.imageOptions.mode==R.background&&(a=0);let h=n+a+(i*s-t)/2;if(i=n+a+(i*s-r)/2,t-=2*a,r-=2*a,a=await this.imageTools.toDataURL(o.image||""),(o=this.document.createElementNS("http://www.w3.org/2000/svg","image")).setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a||""),a.startsWith("data:image/svg+xml;")){if(s=(a=a.substring(19)).indexOf(","),n=a.substring(0,s),a=a.substring(s+1),"base64"===n)a="function"==typeof atob?atob(a):Buffer.from(a,"base64").toString("utf8");else a="";a&&(a=(new DOMParser).parseFromString(a,"text/xml"),(a=Array.from(a.getElementsByTagName("svg"))).length&&(o=a[0]).setAttribute("overflow","visible"))}o.setAttribute("x",e(h)),o.setAttribute("y",e(i)),o.setAttribute("width",`${e(t)}px`),o.setAttribute("height",`${e(r)}px`),this._element.appendChild(o)}createColor({options:t,color:r,additionalRotation:i,x:s,y:o,height:n,width:a,name:h}){var u=a>n?a:n;s-=this.options.dotsOptions.size,o-=this.options.dotsOptions.size,a+=2*this.options.dotsOptions.size,n+=2*this.options.dotsOptions.size;let l=this.document.createElementNS("http://www.w3.org/2000/svg","rect");if(l.setAttribute("x",e(s)),l.setAttribute("y",e(o)),l.setAttribute("height",e(n)),l.setAttribute("width",e(a)),l.setAttribute("clip-path",`url(#mask-${h})`),t){let d;if(t.type===T.radial)d=this.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),d.setAttribute("id",h),d.setAttribute("gradientUnits","userSpaceOnUse"),d.setAttribute("fx",e(s+a/2)),d.setAttribute("fy",e(o+n/2)),d.setAttribute("cx",e(s+a/2)),d.setAttribute("cy",e(o+n/2)),d.setAttribute("r",e(u/2));else{u=s+a/2;let l=o+n/2;s+=a/2,o+=n/2,(i=((r=((t.rotation||0)+i)%(2*Math.PI))+2*Math.PI)%(2*Math.PI))>=0&&i<=.25*Math.PI||i>1.75*Math.PI&&i<=2*Math.PI?(u-=a/2,l-=n/2*Math.tan(r),s+=a/2,o+=n/2*Math.tan(r)):i>.25*Math.PI&&i<=.75*Math.PI?(l-=n/2,u-=a/2/Math.tan(r),o+=n/2,s+=a/2/Math.tan(r)):i>.75*Math.PI&&i<=1.25*Math.PI?(u+=a/2,l+=n/2*Math.tan(r),s-=a/2,o-=n/2*Math.tan(r)):i>1.25*Math.PI&&i<=1.75*Math.PI&&(l+=n/2,u+=a/2/Math.tan(r),o-=n/2,s-=a/2/Math.tan(r)),d=this.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),d.setAttribute("id",h),d.setAttribute("gradientUnits","userSpaceOnUse"),d.setAttribute("x1",e(u)),d.setAttribute("y1",e(l)),d.setAttribute("x2",e(s)),d.setAttribute("y2",e(o))}t.colorStops.forEach(t=>{let r=this.document.createElementNS("http://www.w3.org/2000/svg","stop");r.setAttribute("offset",`${e(100*t.offset)}%`),t=tt(t.color),r.setAttribute("stop-color",t.value),t.alpha<1&&r.setAttribute("stop-opacity",t.alpha.toFixed(7)),d.appendChild(r)}),l.setAttribute("fill",`url(#${h})`),this.defs.appendChild(d)}else r&&(t=tt(r),l.setAttribute("fill",t.value),t.alpha<1&&l.setAttribute("opacity",t.alpha.toFixed(7)));this._element.appendChild(l)}createMask(t){let e=this.document.createElementNS("http://www.w3.org/2000/svg","clipPath");return e.setAttribute("id",t),e.setAttribute("clipPathUnits","userSpaceOnUse"),e}}Object.assign(z.stringToBytesFuncs,{UTF8:t=>{const e=[];for(let r=0;r<t.length;r++){let i=t.charCodeAt(r);i<128?e.push(i):i<2048?e.push(192|i>>6,128|63&i):i<55296||i>=57344?e.push(224|i>>12,128|i>>6&63,128|63&i):(r++,i=65536+((1023&i)<<10|1023&t.charCodeAt(r)),e.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i))}return e}});class at{options;container;qr;extension;svgDrawingPromise;qrSVG;get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?G(x(H,t)):H,this.update()}update(t){this.container&&(this.container.innerHTML=""),this.options=t?G(x(this.options,t)):this.options,this.options.data&&(this.options.stringToBytesFuncs&&(Object.assign(z.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=new z(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel),t=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return y.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return y.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return y.unicode;default:return y.byte}}(this.options.data),this.qr.addData(this.options.data,t),this.qr.make(),this.setupSvg(),this.append(this.container))}append(t){t&&(this.qrSVG?.element&&t.appendChild(this.qrSVG.element),this.container=t)}applyExtension(t){if(!t)throw Error("Extension function should be defined.");this.extension=t,this.update()}deleteExtension(){this.extension=void 0,this.update()}async serialize(){if(!this.qr)throw Error("QR code is empty");if(this.qrSVG?.element&&this.svgDrawingPromise||this.setupSvg(),await this.svgDrawingPromise,this.qrSVG?.element)return'<?xml version="1.0" standalone="no"?>\r\n'+(new XMLSerializer).serializeToString(this.qrSVG.element)}setupSvg(){if(this.qr){var t=this.qr.getModuleCount();this.options.imageOptions.mode==R.background&&this.options.shape!=_.circle&&(t+=2),(t=Math.ceil((this.options.shape==_.circle?Math.sqrt(2):1)*t))%2==0&&--t;var e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0;this.options.imageOptions.mode==R.background&&(e+=this.options.imageOptions.margin||0);var r=Math.ceil(this.options.dotsOptions.size*(t+2*e));this.qrSVG=new nt({...this.options,width:r,height:r,size:r,errorCorrectionPercent:U[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then(()=>{this.qrSVG?.element&&(this.options.plugins?.forEach(t=>t.postProcess?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r})),this.extension?.(this.qrSVG.element,{...this.options,width:r,height:r,size:r}))})}}}let ht={width:300,height:300,margin:0};var ut,lt=ut||={};lt.Lanczos="lanczos",lt.Linear="linear";let dt={[ut.Lanczos]:(t,e)=>e>=t||e<=-t?0:0===e?1:(e*=Math.PI,t*Math.sin(e)*Math.sin(e/t)/(e*e)),[ut.Linear]:(t,e)=>(e=Math.abs(e))<=1?(1-e)*t:0};function ct(t){return"object"==typeof t?(t.baseVal.convertToSpecifiedUnits(t.baseVal.SVG_LENGTHTYPE_PX),t.baseVal.value):t}var gt,pt=gt||={};function mt(t,e){let{width:r,height:i,margin:s}=e?function(t){return(t={...t}).width=Number(t.width),t.height=Number(t.height),t.margin=Number(t.margin),t.margin>Math.min(t.width,t.height)&&(t.margin=Math.min(t.width,t.height)),t}(x(ht,e)):ht,o=document.createElement("canvas");o.width=r,o.height=i;let n=Math.min(r,i)-2*s;return t=t.serialize().then(t=>{if(t){var e=t.match(/viewBox="([^"]+)"/i)[1],a="data:image/svg+xml;base64,"+btoa(t),h=new Image;return new Promise((t,u)=>{h.onload=()=>{const a=Math.ceil(2*n/Math.min(h.width,h.height)),[u,l,d,c]=e.split(/\s+/g).map(parseFloat).map(t=>t*a);var g=(u%1+1)%1;const p=(l%1+1)%1;let m;try{m=new OffscreenCanvas(Math.ceil(d+g+2),Math.ceil(c+p+2))}catch(t){m=document.createElement("canvas"),m.width=Math.ceil(d+g+2),m.height=Math.ceil(c+p+2)}m.getContext("2d")?.drawImage(h,g+1,p+1,d,c),g=function(t,e,r=dt[ut.Lanczos]){let i=ct(t.width);var s=ct(t.height);t=t.getContext("2d");let{width:o,height:n}=e;var a=t.getImageData(0,0,i,s);if(e=t.createImageData(o,n),a.data.length==e.data.length)e=a;else{t=a.data,a=e.data;let A=[];var h=o/i,u=n/s;let y=3;h>.01&&u>.01&&h<1&&u<1&&(y=h<=.2||u<=.2?2:h<=.05||u<=.05?1:3),u=i-1,--s;let E=1/h,z=1/h,D=1/o,x=1/n,T=Math.min(1,h)*Math.min(1,h);h=Math.min(1,h)*Math.min(1,h);for(var l=y,d={},c=l*l*1e3,g=0;g<c;g++){var p=r(l,Math.sqrt(.001*g));d[g]=p<0?0:p}for(r=d,l=n;l--;){(d=(g=(l+.5)*z)-y)<0&&(d=0),p=c=g+y,c!=p&&(c=p+1),c>s&&(c=s),g=l*x-g,p=l*o;let e=o;for(;e--;){var m=(e+.5)*E,$=m-y;$<0&&($=0);let s=m+y;var w=s;s!=w&&(s=w+1),s>u&&(s=u);var f=e*D-m;w=m=0;for(var b=0|d;b<=c;b++)for(var M=(b+g)*(b+g)*h,v=0|$;v<=s;v++)w+=A[m++]=r[1e3*((v+f)*(v+f)*T+M)|0]||0;w=1/w,v=M=b=f=m=0;for(let e=0|d;e<=c;e++){let r=e*i;for(let e=0|$;e<=s;e++){let i=A[m++]*w,s=4*(r+e|0);b+=t[s]*i,M+=t[s+1]*i,v+=t[s+2]*i,f+=t[s+3]*i}}a[$=4*(e+p|0)]=b,a[$+1]=M,a[$+2]=v,a[$+3]=f}}}return e}(m,{width:r-2*s,height:i-2*s}),o?.getContext("2d")?.putImageData(g,s,s),t()},h.onerror=h.onabort=u,h.src=a})}}),{canvas:o,canvasDrawingPromise:t}}function $t(t,e){let r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}pt.svg="svg",pt.png="png",pt.jpeg="jpeg",pt.webp="webp";let wt=Object.freeze({__proto__:null,get FileExtension(){return gt},download:async function(t,e,r){var i=gt.png;let s="qr";if(e&&(e.name&&(s=e.name),e.extension&&(i=e.extension)),"svg"===i.toLowerCase())(i=await t.serialize())&&$t(i="data:image/svg+xml;charset=utf-8,"+encodeURIComponent(i),`${s}.svg`);else if(t=mt(t,r)){var{canvas:o,canvasDrawingPromise:n}=t;await n,$t(t=o.toDataURL(`image/${i}`),`${s}.${i}`)}},downloadURI:$t,drawToCanvas:mt});export{L as CornerDotType,S as CornerSquareType,P as DotType,v as ErrorCorrectionLevel,U as ErrorCorrectionPercents,gt as FileExtension,T as GradientType,R as ImageMode,y as Mode,at as QRCodeStyling,_ as ShapeType,M as TypeNumber,wt as browserUtils};
|
|
2
2
|
//# sourceMappingURL=qr-code-styling.js.map
|