@liquid-js/qr-code-styling 1.7.0 → 1.8.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.
@@ -1,2 +1,2 @@
1
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.QRCodeStyling=e():t.QRCodeStyling=e()}(self,(()=>(()=>{var t={192:(t,e)=>{var r,i,n=function(){var t=function(t,e){var r=t,i=a[e],n=null,o=0,h=null,w=[],m={},v=function(t,e){n=function(t){for(var e=new Array(t),r=0;r<t;r+=1){e[r]=new Array(t);for(var i=0;i<t;i+=1)e[r][i]=null}return e}(o=4*r+17),y(0,0),y(o-7,0),y(0,o-7),x(),b(),M(t,e),r>=7&&S(t),null==h&&(h=C(r,i,w)),A(h,e)},y=function(t,e){for(var r=-1;r<=7;r+=1)if(!(t+r<=-1||o<=t+r))for(var i=-1;i<=7;i+=1)e+i<=-1||o<=e+i||(n[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)},b=function(){for(var t=8;t<o-8;t+=1)null==n[t][6]&&(n[t][6]=t%2==0);for(var e=8;e<o-8;e+=1)null==n[6][e]&&(n[6][e]=e%2==0)},x=function(){for(var t=s.getPatternPosition(r),e=0;e<t.length;e+=1)for(var i=0;i<t.length;i+=1){var o=t[e],a=t[i];if(null==n[o][a])for(var h=-2;h<=2;h+=1)for(var u=-2;u<=2;u+=1)n[o+h][a+u]=-2==h||2==h||-2==u||2==u||0==h&&0==u}},S=function(t){for(var e=s.getBCHTypeNumber(r),i=0;i<18;i+=1){var a=!t&&1==(e>>i&1);n[Math.floor(i/3)][i%3+o-8-3]=a}for(i=0;i<18;i+=1)a=!t&&1==(e>>i&1),n[i%3+o-8-3][Math.floor(i/3)]=a},M=function(t,e){for(var r=i<<3|e,a=s.getBCHTypeInfo(r),h=0;h<15;h+=1){var u=!t&&1==(a>>h&1);h<6?n[h][8]=u:h<8?n[h+1][8]=u:n[o-15+h][8]=u}for(h=0;h<15;h+=1)u=!t&&1==(a>>h&1),h<8?n[8][o-h-1]=u:h<9?n[8][15-h-1+1]=u:n[8][15-h-1]=u;n[o-8][8]=!t},A=function(t,e){for(var r=-1,i=o-1,a=7,h=0,u=s.getMaskFunction(e),c=o-1;c>0;c-=2)for(6==c&&(c-=1);;){for(var d=0;d<2;d+=1)if(null==n[i][c-d]){var l=!1;h<t.length&&(l=1==(t[h]>>>a&1)),u(i,c-d)&&(l=!l),n[i][c-d]=l,-1==(a-=1)&&(h+=1,a=7)}if((i+=r)<0||o<=i){i-=r,r=-r;break}}},C=function(t,e,r){for(var i=c.getRSBlocks(t,e),n=d(),o=0;o<r.length;o+=1){var a=r[o];n.put(a.getMode(),4),n.put(a.getLength(),s.getLengthInBits(a.getMode(),t)),a.write(n)}var h=0;for(o=0;o<i.length;o+=1)h+=i[o].dataCount;if(n.getLengthInBits()>8*h)throw"code length overflow. ("+n.getLengthInBits()+">"+8*h+")";for(n.getLengthInBits()+4<=8*h&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*h||(n.put(236,8),n.getLengthInBits()>=8*h));)n.put(17,8);return function(t,e){for(var r=0,i=0,n=0,o=new Array(e.length),a=new Array(e.length),h=0;h<e.length;h+=1){var c=e[h].dataCount,d=e[h].totalCount-c;i=Math.max(i,c),n=Math.max(n,d),o[h]=new Array(c);for(var l=0;l<o[h].length;l+=1)o[h][l]=255&t.getBuffer()[l+r];r+=c;var g=s.getErrorCorrectPolynomial(d),f=u(o[h],g.getLength()-1).mod(g);for(a[h]=new Array(g.getLength()-1),l=0;l<a[h].length;l+=1){var p=l+f.getLength()-a[h].length;a[h][l]=p>=0?f.getAt(p):0}}var w=0;for(l=0;l<e.length;l+=1)w+=e[l].totalCount;var m=new Array(w),_=0;for(l=0;l<i;l+=1)for(h=0;h<e.length;h+=1)l<o[h].length&&(m[_]=o[h][l],_+=1);for(l=0;l<n;l+=1)for(h=0;h<e.length;h+=1)l<a[h].length&&(m[_]=a[h][l],_+=1);return m}(n,i)};m.addData=function(t,e){var r=null;switch(e=e||"Byte"){case"Numeric":r=l(t);break;case"Alphanumeric":r=g(t);break;case"Byte":r=f(t);break;case"Kanji":r=p(t);break;default:throw"mode:"+e}w.push(r),h=null},m.isDark=function(t,e){if(t<0||o<=t||e<0||o<=e)throw t+","+e;return n[t][e]},m.getModuleCount=function(){return o},m.make=function(){if(r<1){for(var t=1;t<40;t++){for(var e=c.getRSBlocks(t,i),n=d(),o=0;o<w.length;o++){var a=w[o];n.put(a.getMode(),4),n.put(a.getLength(),s.getLengthInBits(a.getMode(),t)),a.write(n)}var h=0;for(o=0;o<e.length;o++)h+=e[o].dataCount;if(n.getLengthInBits()<=8*h)break}r=t}v(!1,function(){for(var t=0,e=0,r=0;r<8;r+=1){v(!0,r);var i=s.getLostPoint(m);(0==r||t>i)&&(t=i,e=r)}return e}())},m.createTableTag=function(t,e){t=t||2;var r="";r+='<table style="',r+=" border-width: 0px; border-style: none;",r+=" border-collapse: collapse;",r+=" padding: 0px; margin: "+(e=void 0===e?4*t:e)+"px;",r+='">',r+="<tbody>";for(var i=0;i<m.getModuleCount();i+=1){r+="<tr>";for(var n=0;n<m.getModuleCount();n+=1)r+='<td style="',r+=" border-width: 0px; border-style: none;",r+=" border-collapse: collapse;",r+=" padding: 0px; margin: 0px;",r+=" width: "+t+"px;",r+=" height: "+t+"px;",r+=" background-color: ",r+=m.isDark(i,n)?"#000000":"#ffffff",r+=";",r+='"/>';r+="</tr>"}return(r+="</tbody>")+"</table>"},m.createSvgTag=function(t,e,r,i){var n={};"object"==typeof arguments[0]&&(t=(n=arguments[0]).cellSize,e=n.margin,r=n.alt,i=n.title),t=t||2,e=void 0===e?4*t:e,(r="string"==typeof r?{text:r}:r||{}).text=r.text||null,r.id=r.text?r.id||"qrcode-description":null,(i="string"==typeof i?{text:i}:i||{}).text=i.text||null,i.id=i.text?i.id||"qrcode-title":null;var o,a,s,h,u=m.getModuleCount()*t+2*e,c="";for(h="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",c+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',c+=n.scalable?"":' width="'+u+'px" height="'+u+'px"',c+=' viewBox="0 0 '+u+" "+u+'" ',c+=' preserveAspectRatio="xMinYMin meet"',c+=i.text||r.text?' role="img" aria-labelledby="'+$([i.id,r.id].join(" ").trim())+'"':"",c+=">",c+=i.text?'<title id="'+$(i.id)+'">'+$(i.text)+"</title>":"",c+=r.text?'<description id="'+$(r.id)+'">'+$(r.text)+"</description>":"",c+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',c+='<path d="',a=0;a<m.getModuleCount();a+=1)for(s=a*t+e,o=0;o<m.getModuleCount();o+=1)m.isDark(a,o)&&(c+="M"+(o*t+e)+","+s+h);return(c+='" stroke="transparent" fill="black"/>')+"</svg>"},m.createDataURL=function(t,e){t=t||2,e=void 0===e?4*t:e;var r=m.getModuleCount()*t+2*e,i=e,n=r-e;return _(r,r,(function(e,r){if(i<=e&&e<n&&i<=r&&r<n){var o=Math.floor((e-i)/t),a=Math.floor((r-i)/t);return m.isDark(a,o)?0:1}return 1}))},m.createImgTag=function(t,e,r){t=t||2,e=void 0===e?4*t:e;var i=m.getModuleCount()*t+2*e,n="";return n+="<img",n+=' src="',n+=m.createDataURL(t,e),n+='"',n+=' width="',n+=i,n+='"',n+=' height="',n+=i,n+='"',r&&(n+=' alt="',n+=$(r),n+='"'),n+"/>"};var $=function(t){for(var e="",r=0;r<t.length;r+=1){var i=t.charAt(r);switch(i){case"<":e+="&lt;";break;case">":e+="&gt;";break;case"&":e+="&amp;";break;case'"':e+="&quot;";break;default:e+=i}}return e};return m.createASCII=function(t,e){if((t=t||1)<2)return function(t){t=void 0===t?2:t;var e,r,i,n,o,a=1*m.getModuleCount()+2*t,s=t,h=a-t,u={"██":"█","█ ":"▀"," █":"▄"," ":" "},c={"██":"▀","█ ":"▀"," █":" "," ":" "},d="";for(e=0;e<a;e+=2){for(i=Math.floor((e-s)/1),n=Math.floor((e+1-s)/1),r=0;r<a;r+=1)o="█",s<=r&&r<h&&s<=e&&e<h&&m.isDark(i,Math.floor((r-s)/1))&&(o=" "),s<=r&&r<h&&s<=e+1&&e+1<h&&m.isDark(n,Math.floor((r-s)/1))?o+=" ":o+="█",d+=t<1&&e+1>=h?c[o]:u[o];d+="\n"}return a%2&&t>0?d.substring(0,d.length-a-1)+Array(a+1).join("▀"):d.substring(0,d.length-1)}(e);t-=1,e=void 0===e?2*t:e;var r,i,n,o,a=m.getModuleCount()*t+2*e,s=e,h=a-e,u=Array(t+1).join("██"),c=Array(t+1).join(" "),d="",l="";for(r=0;r<a;r+=1){for(n=Math.floor((r-s)/t),l="",i=0;i<a;i+=1)o=1,s<=i&&i<h&&s<=r&&r<h&&m.isDark(n,Math.floor((i-s)/t))&&(o=0),l+=o?u:c;for(n=0;n<t;n+=1)d+=l+"\n"}return d.substring(0,d.length-1)},m.renderTo2dContext=function(t,e){e=e||2;for(var r=m.getModuleCount(),i=0;i<r;i++)for(var n=0;n<r;n++)t.fillStyle=m.isDark(i,n)?"black":"white",t.fillRect(i*e,n*e,e,e)},m};t.stringToBytes=(t.stringToBytesFuncs={default:function(t){for(var e=[],r=0;r<t.length;r+=1){var i=t.charCodeAt(r);e.push(255&i)}return e}}).default,t.createStringToBytes=function(t,e){var r=function(){for(var r=m(t),i=function(){var t=r.read();if(-1==t)throw"eof";return t},n=0,o={};;){var a=r.read();if(-1==a)break;var s=i(),h=i()<<8|i();o[String.fromCharCode(a<<8|s)]=h,n+=1}if(n!=e)throw n+" != "+e;return o}(),i="?".charCodeAt(0);return function(t){for(var e=[],n=0;n<t.length;n+=1){var o=t.charCodeAt(n);if(o<128)e.push(o);else{var a=r[t.charAt(n)];"number"==typeof a?(255&a)==a?e.push(a):(e.push(a>>>8),e.push(255&a)):e.push(i)}}return e}};var e,r,i,n,o,a={L:1,M:0,Q:3,H:2},s=(e=[[],[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]],r=1335,i=7973,o=function(t){for(var e=0;0!=t;)e+=1,t>>>=1;return e},(n={}).getBCHTypeInfo=function(t){for(var e=t<<10;o(e)-o(r)>=0;)e^=r<<o(e)-o(r);return 21522^(t<<10|e)},n.getBCHTypeNumber=function(t){for(var e=t<<12;o(e)-o(i)>=0;)e^=i<<o(e)-o(i);return t<<12|e},n.getPatternPosition=function(t){return e[t-1]},n.getMaskFunction=function(t){switch(t){case 0:return function(t,e){return(t+e)%2==0};case 1:return function(t,e){return t%2==0};case 2:return function(t,e){return e%3==0};case 3:return function(t,e){return(t+e)%3==0};case 4:return function(t,e){return(Math.floor(t/2)+Math.floor(e/3))%2==0};case 5:return function(t,e){return t*e%2+t*e%3==0};case 6:return function(t,e){return(t*e%2+t*e%3)%2==0};case 7:return function(t,e){return(t*e%3+(t+e)%2)%2==0};default:throw"bad maskPattern:"+t}},n.getErrorCorrectPolynomial=function(t){for(var e=u([1],0),r=0;r<t;r+=1)e=e.multiply(u([1,h.gexp(r)],0));return e},n.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case 1:return 10;case 2:return 9;case 4:case 8:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case 1:return 12;case 2:return 11;case 4:return 16;case 8:return 10;default:throw"mode:"+t}else{if(!(e<41))throw"type:"+e;switch(t){case 1:return 14;case 2:return 13;case 4:return 16;case 8:return 12;default:throw"mode:"+t}}},n.getLostPoint=function(t){for(var e=t.getModuleCount(),r=0,i=0;i<e;i+=1)for(var n=0;n<e;n+=1){for(var o=0,a=t.isDark(i,n),s=-1;s<=1;s+=1)if(!(i+s<0||e<=i+s))for(var h=-1;h<=1;h+=1)n+h<0||e<=n+h||0==s&&0==h||a==t.isDark(i+s,n+h)&&(o+=1);o>5&&(r+=3+o-5)}for(i=0;i<e-1;i+=1)for(n=0;n<e-1;n+=1){var u=0;t.isDark(i,n)&&(u+=1),t.isDark(i+1,n)&&(u+=1),t.isDark(i,n+1)&&(u+=1),t.isDark(i+1,n+1)&&(u+=1),0!=u&&4!=u||(r+=3)}for(i=0;i<e;i+=1)for(n=0;n<e-6;n+=1)t.isDark(i,n)&&!t.isDark(i,n+1)&&t.isDark(i,n+2)&&t.isDark(i,n+3)&&t.isDark(i,n+4)&&!t.isDark(i,n+5)&&t.isDark(i,n+6)&&(r+=40);for(n=0;n<e;n+=1)for(i=0;i<e-6;i+=1)t.isDark(i,n)&&!t.isDark(i+1,n)&&t.isDark(i+2,n)&&t.isDark(i+3,n)&&t.isDark(i+4,n)&&!t.isDark(i+5,n)&&t.isDark(i+6,n)&&(r+=40);var c=0;for(n=0;n<e;n+=1)for(i=0;i<e;i+=1)t.isDark(i,n)&&(c+=1);return r+Math.abs(100*c/e/e-50)/5*10},n),h=function(){for(var t=new Array(256),e=new Array(256),r=0;r<8;r+=1)t[r]=1<<r;for(r=8;r<256;r+=1)t[r]=t[r-4]^t[r-5]^t[r-6]^t[r-8];for(r=0;r<255;r+=1)e[t[r]]=r;return{glog:function(t){if(t<1)throw"glog("+t+")";return e[t]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return t[e]}}}();function u(t,e){if(void 0===t.length)throw t.length+"/"+e;var r=function(){for(var r=0;r<t.length&&0==t[r];)r+=1;for(var i=new Array(t.length-r+e),n=0;n<t.length-r;n+=1)i[n]=t[n+r];return i}(),i={getAt:function(t){return r[t]},getLength:function(){return r.length},multiply:function(t){for(var e=new Array(i.getLength()+t.getLength()-1),r=0;r<i.getLength();r+=1)for(var n=0;n<t.getLength();n+=1)e[r+n]^=h.gexp(h.glog(i.getAt(r))+h.glog(t.getAt(n)));return u(e,0)},mod:function(t){if(i.getLength()-t.getLength()<0)return i;for(var e=h.glog(i.getAt(0))-h.glog(t.getAt(0)),r=new Array(i.getLength()),n=0;n<i.getLength();n+=1)r[n]=i.getAt(n);for(n=0;n<t.getLength();n+=1)r[n]^=h.gexp(h.glog(t.getAt(n))+e);return u(r,0).mod(t)}};return i}var c=function(){var t=[[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]],e=function(t,e){var r={};return r.totalCount=t,r.dataCount=e,r},r={getRSBlocks:function(r,i){var n=function(e,r){switch(r){case a.L:return t[4*(e-1)+0];case a.M:return t[4*(e-1)+1];case a.Q:return t[4*(e-1)+2];case a.H:return t[4*(e-1)+3];default:return}}(r,i);if(void 0===n)throw"bad rs block @ typeNumber:"+r+"/errorCorrectionLevel:"+i;for(var o=n.length/3,s=[],h=0;h<o;h+=1)for(var u=n[3*h+0],c=n[3*h+1],d=n[3*h+2],l=0;l<u;l+=1)s.push(e(c,d));return s}};return r}(),d=function(){var t=[],e=0,r={getBuffer:function(){return t},getAt:function(e){var r=Math.floor(e/8);return 1==(t[r]>>>7-e%8&1)},put:function(t,e){for(var i=0;i<e;i+=1)r.putBit(1==(t>>>e-i-1&1))},getLengthInBits:function(){return e},putBit:function(r){var i=Math.floor(e/8);t.length<=i&&t.push(0),r&&(t[i]|=128>>>e%8),e+=1}};return r},l=function(t){var e=t,r={getMode:function(){return 1},getLength:function(t){return e.length},write:function(t){for(var r=e,n=0;n+2<r.length;)t.put(i(r.substring(n,n+3)),10),n+=3;n<r.length&&(r.length-n==1?t.put(i(r.substring(n,n+1)),4):r.length-n==2&&t.put(i(r.substring(n,n+2)),7))}},i=function(t){for(var e=0,r=0;r<t.length;r+=1)e=10*e+n(t.charAt(r));return e},n=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+t};return r},g=function(t){var e=t,r={getMode:function(){return 2},getLength:function(t){return e.length},write:function(t){for(var r=e,n=0;n+1<r.length;)t.put(45*i(r.charAt(n))+i(r.charAt(n+1)),11),n+=2;n<r.length&&t.put(i(r.charAt(n)),6)}},i=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-"0".charCodeAt(0);if("A"<=t&&t<="Z")return t.charCodeAt(0)-"A".charCodeAt(0)+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"illegal char :"+t}};return r},f=function(e){var r=t.stringToBytes(e);return{getMode:function(){return 4},getLength:function(t){return r.length},write:function(t){for(var e=0;e<r.length;e+=1)t.put(r[e],8)}}},p=function(e){var r=t.stringToBytesFuncs.SJIS;if(!r)throw"sjis not supported.";!function(t,e){var i=r("友");if(2!=i.length||38726!=(i[0]<<8|i[1]))throw"sjis not supported."}();var i=r(e),n={getMode:function(){return 8},getLength:function(t){return~~(i.length/2)},write:function(t){for(var e=i,r=0;r+1<e.length;){var n=(255&e[r])<<8|255&e[r+1];if(33088<=n&&n<=40956)n-=33088;else{if(!(57408<=n&&n<=60351))throw"illegal char at "+(r+1)+"/"+n;n-=49472}n=192*(n>>>8&255)+(255&n),t.put(n,13),r+=2}if(r<e.length)throw"illegal char at "+(r+1)}};return n},w=function(){var t=[],e={writeByte:function(e){t.push(255&e)},writeShort:function(t){e.writeByte(t),e.writeByte(t>>>8)},writeBytes:function(t,r,i){r=r||0,i=i||t.length;for(var n=0;n<i;n+=1)e.writeByte(t[n+r])},writeString:function(t){for(var r=0;r<t.length;r+=1)e.writeByte(t.charCodeAt(r))},toByteArray:function(){return t},toString:function(){var e="";e+="[";for(var r=0;r<t.length;r+=1)r>0&&(e+=","),e+=t[r];return e+"]"}};return e},m=function(t){var e=t,r=0,i=0,n=0,o={read:function(){for(;n<8;){if(r>=e.length){if(0==n)return-1;throw"unexpected end of file./"+n}var t=e.charAt(r);if(r+=1,"="==t)return n=0,-1;t.match(/^\s$/)||(i=i<<6|a(t.charCodeAt(0)),n+=6)}var o=i>>>n-8&255;return n-=8,o}},a=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw"c:"+t};return o},_=function(t,e,r){for(var i=function(t,e){var r=t,i=e,n=new Array(t*e),o={setPixel:function(t,e,i){n[e*r+t]=i},write:function(t){t.writeString("GIF87a"),t.writeShort(r),t.writeShort(i),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(","),t.writeShort(0),t.writeShort(0),t.writeShort(r),t.writeShort(i),t.writeByte(0);var e=a(2);t.writeByte(2);for(var n=0;e.length-n>255;)t.writeByte(255),t.writeBytes(e,n,255),n+=255;t.writeByte(e.length-n),t.writeBytes(e,n,e.length-n),t.writeByte(0),t.writeString(";")}},a=function(t){for(var e=1<<t,r=1+(1<<t),i=t+1,o=s(),a=0;a<e;a+=1)o.add(String.fromCharCode(a));o.add(String.fromCharCode(e)),o.add(String.fromCharCode(r));var h,u,c,d=w(),l=(h=d,u=0,c=0,{write:function(t,e){if(t>>>e!=0)throw"length over";for(;u+e>=8;)h.writeByte(255&(t<<u|c)),e-=8-u,t>>>=8-u,c=0,u=0;c|=t<<u,u+=e},flush:function(){u>0&&h.writeByte(c)}});l.write(e,i);var g=0,f=String.fromCharCode(n[g]);for(g+=1;g<n.length;){var p=String.fromCharCode(n[g]);g+=1,o.contains(f+p)?f+=p:(l.write(o.indexOf(f),i),o.size()<4095&&(o.size()==1<<i&&(i+=1),o.add(f+p)),f=p)}return l.write(o.indexOf(f),i),l.write(r,i),l.flush(),d.toByteArray()},s=function(){var t={},e=0,r={add:function(i){if(r.contains(i))throw"dup key:"+i;t[i]=e,e+=1},size:function(){return e},indexOf:function(e){return t[e]},contains:function(e){return void 0!==t[e]}};return r};return o}(t,e),n=0;n<e;n+=1)for(var o=0;o<t;o+=1)i.setPixel(o,n,r(o,n));var a=w();i.write(a);for(var s=function(){var t=0,e=0,r=0,i="",n={},o=function(t){i+=String.fromCharCode(a(63&t))},a=function(t){if(t<0);else{if(t<26)return 65+t;if(t<52)return t-26+97;if(t<62)return t-52+48;if(62==t)return 43;if(63==t)return 47}throw"n:"+t};return n.writeByte=function(i){for(t=t<<8|255&i,e+=8,r+=1;e>=6;)o(t>>>e-6),e-=6},n.flush=function(){if(e>0&&(o(t<<6-e),t=0,e=0),r%3!=0)for(var n=3-r%3,a=0;a<n;a+=1)i+="="},n.toString=function(){return i},n}(),h=a.toByteArray(),u=0;u<h.length;u+=1)s.writeByte(h[u]);return s.flush(),"data:image/gif;base64,"+s};return t}();n.stringToBytesFuncs["UTF-8"]=function(t){return function(t){for(var e=[],r=0;r<t.length;r++){var 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}(t)},void 0===(i="function"==typeof(r=function(){return n})?r.apply(e,[]):r)||(t.exports=i)}},e={};function r(i){var n=e[i];if(void 0!==n)return n.exports;var o=e[i]={exports:{}};return t[i](o,o.exports,r),o.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.d(i,{default:()=>z});var t={};r.r(t),r.d(t,{CornerDotType:()=>n,CornerSquareType:()=>o,DotType:()=>e,ErrorCorrectionLevel:()=>c,FileExtension:()=>l,GradientType:()=>a,Mode:()=>d,ShapeType:()=>s,TypeNumber:()=>u});var e,n,o,a,s,h={};r.r(h),r.d(h,{download:()=>O,downloadURI:()=>P,drawToCanvas:()=>q}),function(t){t.dots="dots",t.rounded="rounded",t.classy="classy",t.classyRounded="classy-rounded",t.square="square",t.extraRounded="extra-rounded"}(e||(e={})),function(t){t.dot="dot",t.square="square"}(n||(n={})),function(t){t.dot="dot",t.square="square",t.extraRounded="extra-rounded"}(o||(o={})),function(t){t.radial="radial",t.linear="linear"}(a||(a={})),function(t){t.square="square",t.circle="circle"}(s||(s={}));const u=Array(41).fill(0).map(((t,e)=>e));var c,d,l;!function(t){t.L="L",t.M="M",t.Q="Q",t.H="H"}(c||(c={})),function(t){t.numeric="Numeric",t.alphanumeric="Alphanumeric",t.byte="Byte",t.kanji="Kanji"}(d||(d={})),function(t){t.svg="svg",t.png="png",t.jpeg="jpeg",t.webp="webp"}(l||(l={}));const g={[c.L]:.07,[c.M]:.15,[c.Q]:.25,[c.H]:.3};var f=r(192),p=r.n(f);const w=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function m(t,...e){if(!e.length)return t;const r=e.shift();return void 0!==r&&w(t)&&w(r)?(t={...t},Object.keys(r).forEach((e=>{const i=t[e],n=r[e];Array.isArray(i)&&Array.isArray(n)?t[e]=n:w(i)&&w(n)?t[e]=m(Object.assign({},i),n):t[e]=n})),m(t,...e)):t}function _(t){const e={...t};if(!e.colorStops||!e.colorStops.length)throw"Field 'colorStops' is required in gradient";return e.rotation?e.rotation=Number(e.rotation):e.rotation=0,e.colorStops=e.colorStops.map((t=>({...t,offset:Number(t.offset)}))),e}function v(t){const e={...t};return e.imageOptions={...e.imageOptions,hideBackgroundDots:Boolean(e.imageOptions.hideBackgroundDots),imageSize:Math.min(1,Number(e.imageOptions.imageSize))||1,margin:Number(e.imageOptions.margin)},e.dotsOptions={...e.dotsOptions},e.dotsOptions.gradient&&(e.dotsOptions.gradient=_(e.dotsOptions.gradient)),e.cornersSquareOptions&&(e.cornersSquareOptions={...e.cornersSquareOptions},e.cornersSquareOptions.gradient&&(e.cornersSquareOptions.gradient=_(e.cornersSquareOptions.gradient))),e.cornersDotOptions&&(e.cornersDotOptions={...e.cornersDotOptions},e.cornersDotOptions.gradient&&(e.cornersDotOptions.gradient=_(e.cornersDotOptions.gradient))),e.backgroundOptions&&(e.backgroundOptions={...e.backgroundOptions},e.backgroundOptions.gradient&&(e.backgroundOptions.gradient=_(e.backgroundOptions.gradient))),e.document||(e.document=document),e}const y={document:void 0,shape:s.square,width:void 0,height:void 0,data:"",qrOptions:{typeNumber:u[0],mode:void 0,errorCorrectionLevel:c.Q},imageOptions:{hideBackgroundDots:!0,imageSize:.4,crossOrigin:void 0,margin:0},dotsOptions:{type:e.square,color:"#000"}},b={width:300,height:300,margin:10};class x{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(t,e,r,i){let o;switch(this._type){case n.square:o=this._drawSquare;break;case n.dot:default:o=this._drawDot}o.call(this,{x:t,y:e,size:r,rotation:i})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,a=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${a})`)}_basicDot(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(r+e/2)),this._element.setAttribute("cy",String(i+e/2)),this._element.setAttribute("r",String(e/2))}})}_basicSquare(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(r)),this._element.setAttribute("y",String(i)),this._element.setAttribute("width",String(e)),this._element.setAttribute("height",String(e))}})}_drawDot({x:t,y:e,size:r,rotation:i}){this._basicDot({x:t,y:e,size:r,rotation:i})}_drawSquare({x:t,y:e,size:r,rotation:i}){this._basicSquare({x:t,y:e,size:r,rotation:i})}}class S{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(t,e,r,i){let n;switch(this._type){case o.square:n=this._drawSquare;break;case o.extraRounded:n=this._drawExtraRounded;break;case o.dot:default:n=this._drawDot}n.call(this,{x:t,y:e,size:r,rotation:i})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,a=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${a})`)}_basicDot(t){const{size:e,x:r,y:i}=t,n=e/7;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${r+e/2} ${i}a ${e/2} ${e/2} 0 1 0 0.1 0zm 0 ${n}a ${e/2-n} ${e/2-n} 0 1 1 -0.1 0Z`)}})}_basicSquare(t){const{size:e,x:r,y:i}=t,n=e/7;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h ${e}v `+-e+"z"+`M ${r+n} ${i+n}h `+(e-2*n)+"v "+(e-2*n)+"h "+(2*n-e)+"z")}})}_basicExtraRounded(t){const{size:e,x:r,y:i}=t,n=e/7;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${r} ${i+2.5*n}v `+2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*n} ${2.5*n}h `+2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*n} ${2.5*-n}v `+-2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*-n}h `+-2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*n}`+`M ${r+2.5*n} ${i+n}h `+2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*n} ${1.5*n}v `+2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*-n} ${1.5*n}h `+-2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*-n} ${1.5*-n}v `+-2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*n} ${1.5*-n}`)}})}_drawDot({x:t,y:e,size:r,rotation:i}){this._basicDot({x:t,y:e,size:r,rotation:i})}_drawSquare({x:t,y:e,size:r,rotation:i}){this._basicSquare({x:t,y:e,size:r,rotation:i})}_drawExtraRounded({x:t,y:e,size:r,rotation:i}){this._basicExtraRounded({x:t,y:e,size:r,rotation:i})}}class M{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(t,r,i,n){let o;switch(this._type){case e.dots:o=this._drawDot;break;case e.classy:o=this._drawClassy;break;case e.classyRounded:o=this._drawClassyRounded;break;case e.rounded:o=this._drawRounded;break;case e.extraRounded:o=this._drawExtraRounded;break;case e.square:default:o=this._drawSquare}o.call(this,{x:t,y:r,size:i,getNeighbor:n})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,a=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${a})`)}_basicDot(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(r+e/2)),this._element.setAttribute("cy",String(i+e/2)),this._element.setAttribute("r",String(e/2))}})}_basicSquare(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(r)),this._element.setAttribute("y",String(i)),this._element.setAttribute("width",String(e)),this._element.setAttribute("height",String(e))}})}_basicSideRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h `+e/2+`a ${e/2} ${e/2}, 0, 0, 0, 0 ${-e}`)}})}_basicCornerRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h ${e}v `+-e/2+`a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2}`)}})}_basicCornerExtraRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h ${e}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}`)}})}_basicCornersRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v `+e/2+`a ${e/2} ${e/2}, 0, 0, 0, ${e/2} ${e/2}h `+e/2+"v "+-e/2+`a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2}`)}})}_drawDot({x:t,y:e,size:r}){this._basicDot({x:t,y:e,size:r,rotation:0})}_drawSquare({x:t,y:e,size:r}){this._basicSquare({x:t,y:e,size:r,rotation:0})}_drawRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0,h=n+o+a+s;if(0!==h)if(h>2||n&&o||a&&s)this._basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&a?i=Math.PI/2:a&&o?i=Math.PI:o&&s&&(i=-Math.PI/2),void this._basicCornerRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return a?i=Math.PI/2:o?i=Math.PI:s&&(i=-Math.PI/2),void this._basicSideRounded({x:t,y:e,size:r,rotation:i})}}else this._basicDot({x:t,y:e,size:r,rotation:0})}_drawExtraRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0,h=n+o+a+s;if(0!==h)if(h>2||n&&o||a&&s)this._basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&a?i=Math.PI/2:a&&o?i=Math.PI:o&&s&&(i=-Math.PI/2),void this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return a?i=Math.PI/2:o?i=Math.PI:s&&(i=-Math.PI/2),void this._basicSideRounded({x:t,y:e,size:r,rotation:i})}}else this._basicDot({x:t,y:e,size:r,rotation:0})}_drawClassy({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0;0!==n+o+a+s?n||a?o||s?this._basicSquare({x:t,y:e,size:r,rotation:0}):this._basicCornerRounded({x:t,y:e,size:r,rotation:Math.PI/2}):this._basicCornerRounded({x:t,y:e,size:r,rotation:-Math.PI/2}):this._basicCornersRounded({x:t,y:e,size:r,rotation:Math.PI/2})}_drawClassyRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0;0!==n+o+a+s?n||a?o||s?this._basicSquare({x:t,y:e,size:r,rotation:0}):this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:Math.PI/2}):this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:-Math.PI/2}):this._basicCornersRounded({x:t,y:e,size:r,rotation:Math.PI/2})}}const A={toDataURL:t=>new Promise(((e,r)=>{if("string"==typeof t){const i=new XMLHttpRequest;i.onload=function(){const t=new FileReader;t.onloadend=function(){e(t.result)},t.readAsDataURL(i.response)},i.onerror=i.onabort=i.ontimeout=r,i.open("GET",t),i.responseType="blob",i.send()}else{const r=new FileReader;r.onloadend=function(){e(r.result)},r.readAsDataURL(t)}})),getSize:t=>new Promise(((e,r)=>{if(!t.image)return r("Image is not defined");const i=new Image;"string"==typeof t.imageOptions.crossOrigin&&(i.crossOrigin=t.imageOptions.crossOrigin),i.onload=()=>{e({width:i.width,height:i.height})},i.onerror=i.onabort=r,"string"==typeof t.image?i.src=t.image:A.toDataURL(t.image).then((t=>i.src=t)).catch(r)}))},C=[[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]],$=[[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]];class D{constructor(t){this._document=t.document,this._element=this._document.createElementNS("http://www.w3.org/2000/svg","svg"),this._element.setAttribute("width",String(t.width)),this._element.setAttribute("height",String(t.height)),this._element.setAttribute("viewBox",`0 0 ${t.width} ${t.height}`),this._defs=this._document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this._defs),this._imageTools=t.imageTools||A,this._options=t}get width(){return this._options.width}get height(){return this._options.height}getElement(){return this._element}async drawQR(t){const e=t.getModuleCount(),r=Math.min(this._options.width,this._options.height),i=this._options.shape===s.circle?r/Math.sqrt(2):r,n=Math.floor(i/e);let o={hideXDots:0,hideYDots:0,width:0,height:0};if(this._qr=t,this._options.image){const t=await this._imageTools.getSize(this._options),{imageOptions:r,qrOptions:i}=this._options,a=r.imageSize*g[i.errorCorrectionLevel],s=Math.floor(a*e*e);o=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:n}){const o={x:0,y:0},a={x:0,y:0};if(t<=0||e<=0||r<=0||n<=0)return{height:0,width:0,hideYDots:0,hideXDots:0};const s=t/e;return o.x=Math.floor(Math.sqrt(r/s)),o.x<=0&&(o.x=1),i&&i<o.x&&(o.x=i),o.x%2==0&&o.x--,a.x=o.x*n,o.y=1+2*Math.ceil((o.x*s-1)/2),a.y=Math.round(a.x*s),(o.y*o.x>r||i&&i<o.y)&&(i&&i<o.y?(o.y=i,o.y%2==0&&o.x--):o.y-=2,a.y=o.y*n,o.x=1+2*Math.ceil((o.y/s-1)/2),a.x=Math.round(a.y/s)),{height:a.y,width:a.x,hideYDots:o.y,hideXDots:o.x}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:s,maxHiddenAxisDots:e-14,dotSize:n})}this.drawBackground(),this.drawDots(((t,r)=>!(this._options.imageOptions.hideBackgroundDots&&t>=(e-o.hideXDots)/2&&t<(e+o.hideXDots)/2&&r>=(e-o.hideYDots)/2&&r<(e+o.hideYDots)/2||C[t]?.[r]||C[t-e+7]?.[r]||C[t]?.[r-e+7]||$[t]?.[r]||$[t-e+7]?.[r]||$[t]?.[r-e+7]))),this.drawCorners(),this._options.image&&await this.drawImage({width:o.width,height:o.height,count:e,dotSize:n})}drawBackground(){const t=this._element,e=this._options;if(t&&e.backgroundOptions){const t=e.backgroundOptions.gradient,r=e.backgroundOptions.color;this._createColor({options:t,color:r,additionalRotation:0,x:0,y:0,height:e.height,width:e.width,name:"background-color"});const i=Math.min(e.width,e.height),n=this._document.createElementNS("http://www.w3.org/2000/svg","rect");this._backgroundClipPath=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._backgroundClipPath.setAttribute("id","clip-path-background-color"),this._defs.appendChild(this._backgroundClipPath),n.setAttribute("x",String((e.width-i)/2)),n.setAttribute("y",String((e.height-i)/2)),n.setAttribute("width",String(i)),n.setAttribute("height",String(i)),n.setAttribute("rx",String(i/2*(e.backgroundOptions.round||0))),this._backgroundClipPath.appendChild(n)}}drawDots(t){if(!this._qr)throw"QR code is not defined";const e=this._options,r=this._qr.getModuleCount();if(r>e.width||r>e.height)throw"The canvas is too small.";const i=Math.min(e.width,e.height),n=e.shape===s.circle?i/Math.sqrt(2):i,o=Math.floor(n/r),a=Math.floor((e.width-r*o)/2),h=Math.floor((e.height-r*o)/2),u=new M({svg:this._element,type:e.dotsOptions.type,document:this._document});this._dotsClipPath=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._dotsClipPath.setAttribute("id","clip-path-dot-color"),this._defs.appendChild(this._dotsClipPath),this._createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:0,y:0,height:e.height,width:e.width,name:"dot-color"});for(let e=0;e<r;e++)for(let i=0;i<r;i++)t&&!t(e,i)||this._qr?.isDark(e,i)&&(u.draw(a+e*o,h+i*o,o,((n,o)=>!(e+n<0||i+o<0||e+n>=r||i+o>=r)&&!(t&&!t(e+n,i+o))&&!!this._qr&&this._qr.isDark(e+n,i+o))),u._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(u._element));if(e.shape===s.circle){const t=Math.floor((i/o-r)/2),e=r+2*t,n=a-t*o,s=h-t*o,c=[],d=Math.floor(e/2);for(let i=0;i<e;i++){c[i]=[];for(let n=0;n<e;n++)i>=t-1&&i<=e-t&&n>=t-1&&n<=e-t||Math.sqrt((i-d)*(i-d)+(n-d)*(n-d))>d?c[i][n]=0:c[i][n]=this._qr.isDark(n-2*t<0?n:n>=r?n-2*t:n-t,i-2*t<0?i:i>=r?i-2*t:i-t)?1:0}for(let t=0;t<e;t++)for(let r=0;r<e;r++)c[t][r]&&(u.draw(n+t*o,s+r*o,o,((e,i)=>!!c[t+e]?.[r+i])),u._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(u._element))}}drawCorners(){if(!this._qr)throw"QR code is not defined";const t=this._element,e=this._options;if(!t)throw"Element code is not defined";const r=this._qr.getModuleCount(),i=Math.min(e.width,e.height),n=e.shape===s.circle?i/Math.sqrt(2):i,o=Math.floor(n/r),a=7*o,h=3*o,u=Math.floor((e.width-r*o)/2),c=Math.floor((e.height-r*o)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([t,i,n])=>{const s=u+t*o*(r-7),d=c+i*o*(r-7);let l=this._dotsClipPath,g=this._dotsClipPath;if((e.cornersSquareOptions?.gradient||e.cornersSquareOptions?.color)&&(l=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),l.setAttribute("id",`clip-path-corners-square-color-${t}-${i}`),this._defs.appendChild(l),this._cornersSquareClipPath=this._cornersDotClipPath=g=l,this._createColor({options:e.cornersSquareOptions?.gradient,color:e.cornersSquareOptions?.color,additionalRotation:n,x:s,y:d,height:a,width:a,name:`corners-square-color-${t}-${i}`})),e.cornersSquareOptions?.type){const t=new S({svg:this._element,type:e.cornersSquareOptions.type,document:this._document});t.draw(s,d,a,n),t._element&&l&&l.appendChild(t._element)}else{const t=new M({svg:this._element,type:e.dotsOptions.type,document:this._document});for(let e=0;e<C.length;e++)for(let r=0;r<C[e].length;r++)C[e]?.[r]&&(t.draw(s+e*o,d+r*o,o,((t,i)=>!!C[e+t]?.[r+i])),t._element&&l&&l.appendChild(t._element))}if((e.cornersDotOptions?.gradient||e.cornersDotOptions?.color)&&(g=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),g.setAttribute("id",`clip-path-corners-dot-color-${t}-${i}`),this._defs.appendChild(g),this._cornersDotClipPath=g,this._createColor({options:e.cornersDotOptions?.gradient,color:e.cornersDotOptions?.color,additionalRotation:n,x:s+2*o,y:d+2*o,height:h,width:h,name:`corners-dot-color-${t}-${i}`})),e.cornersDotOptions?.type){const t=new x({svg:this._element,type:e.cornersDotOptions.type,document:this._document});t.draw(s+2*o,d+2*o,h,n),t._element&&g&&g.appendChild(t._element)}else{const t=new M({svg:this._element,type:e.dotsOptions.type,document:this._document});for(let e=0;e<$.length;e++)for(let r=0;r<$[e].length;r++)$[e]?.[r]&&(t.draw(s+e*o,d+r*o,o,((t,i)=>!!$[e+t]?.[r+i])),t._element&&g&&g.appendChild(t._element))}}))}async drawImage({width:t,height:e,count:r,dotSize:i}){const n=this._options,o=Math.floor((n.width-r*i)/2),a=Math.floor((n.height-r*i)/2),s=n.imageOptions.margin*i,h=o+s+(r*i-t)/2,u=a+s+(r*i-e)/2,c=t-2*s,d=e-2*s,l=await this._imageTools.toDataURL(n.image||"");let g=this._document.createElementNS("http://www.w3.org/2000/svg","image");if(g.setAttribute("href",l||""),l.startsWith("data:image/svg+xml;")){let t=l.substring(19);const e=t.indexOf(","),r=t.substring(0,e);if(t=t.substring(e+1),t="base64"===r?"function"==typeof atob?atob(t):Buffer.from(t,"base64").toString("utf8"):"",t){const e=(new DOMParser).parseFromString(t,"text/xml"),r=Array.from(e.getElementsByTagName("svg"));r.length&&(g=r[0])}}g.setAttribute("x",String(h)),g.setAttribute("y",String(u)),g.setAttribute("width",`${c}px`),g.setAttribute("height",`${d}px`),this._element.appendChild(g)}_createColor({options:t,color:e,additionalRotation:r,x:i,y:n,height:o,width:s,name:h}){const u=s>o?s:o,c=this._document.createElementNS("http://www.w3.org/2000/svg","rect");if(c.setAttribute("x",String(i)),c.setAttribute("y",String(n)),c.setAttribute("height",String(o)),c.setAttribute("width",String(s)),c.setAttribute("clip-path",`url('#clip-path-${h}')`),t){let e;if(t.type===a.radial)e=this._document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),e.setAttribute("id",h),e.setAttribute("gradientUnits","userSpaceOnUse"),e.setAttribute("fx",String(i+s/2)),e.setAttribute("fy",String(n+o/2)),e.setAttribute("cx",String(i+s/2)),e.setAttribute("cy",String(n+o/2)),e.setAttribute("r",String(u/2));else{const a=((t.rotation||0)+r)%(2*Math.PI),u=(a+2*Math.PI)%(2*Math.PI);let c=i+s/2,d=n+o/2,l=i+s/2,g=n+o/2;u>=0&&u<=.25*Math.PI||u>1.75*Math.PI&&u<=2*Math.PI?(c-=s/2,d-=o/2*Math.tan(a),l+=s/2,g+=o/2*Math.tan(a)):u>.25*Math.PI&&u<=.75*Math.PI?(d-=o/2,c-=s/2/Math.tan(a),g+=o/2,l+=s/2/Math.tan(a)):u>.75*Math.PI&&u<=1.25*Math.PI?(c+=s/2,d+=o/2*Math.tan(a),l-=s/2,g-=o/2*Math.tan(a)):u>1.25*Math.PI&&u<=1.75*Math.PI&&(d+=o/2,c+=s/2/Math.tan(a),g-=o/2,l-=s/2/Math.tan(a)),e=this._document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),e.setAttribute("id",h),e.setAttribute("gradientUnits","userSpaceOnUse"),e.setAttribute("x1",String(Math.round(c))),e.setAttribute("y1",String(Math.round(d))),e.setAttribute("x2",String(Math.round(l))),e.setAttribute("y2",String(Math.round(g)))}t.colorStops.forEach((({offset:t,color:r})=>{const i=this._document.createElementNS("http://www.w3.org/2000/svg","stop");i.setAttribute("offset",100*t+"%"),i.setAttribute("stop-color",r),e.appendChild(i)})),c.setAttribute("fill",`url('#${h}')`),this._defs.appendChild(e)}else e&&c.setAttribute("fill",e);this._element.appendChild(c)}}class k{constructor(t){this._options=t?v(m(y,t)):y,this.update()}static _clearContainer(t){t&&(t.innerHTML="")}_setupSvg(){if(!this._qr)return;this._options.width=this._options.height=10*this._qr.getModuleCount();const t=new D(this._options);this._svg=t.getElement(),this._svgDrawingPromise=t.drawQR(this._qr).then((()=>{this._svg&&this._extension?.(t.getElement(),this._options)}))}async _getElement(){if(!this._qr)throw"QR code is empty";return this._svg&&this._svgDrawingPromise||this._setupSvg(),await this._svgDrawingPromise,this._svg}update(t){k._clearContainer(this._container),this._options=t?v(m(this._options,t)):this._options,this._options.data&&(this._qr=p()(this._options.qrOptions.typeNumber,this._options.qrOptions.errorCorrectionLevel),this._qr.addData(this._options.data,this._options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return d.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return d.alphanumeric;default:return d.byte}}(this._options.data)),this._qr.make(),this._setupSvg(),this.append(this._container))}append(t){if(t){if("function"!=typeof t.appendChild)throw"Container should be a single DOM node";this._svg&&t.appendChild(this._svg),this._container=t}}applyExtension(t){if(!t)throw"Extension function should be defined.";this._extension=t,this.update()}deleteExtension(){this._extension=void 0,this.update()}async serialize(){if(!this._qr)throw"QR code is empty";const t=await this._getElement();if(!t)return;let e=(new XMLSerializer).serializeToString(t);return e='<?xml version="1.0" standalone="no"?>\r\n'+e,e}}function q(t,e){if(!t._qr)return;const{width:r,height:i,margin:n}=e?function(t){const e={...t};return e.width=Number(e.width),e.height=Number(e.height),e.margin=Number(e.margin),e.margin>Math.min(e.width,e.height)&&(e.margin=Math.min(e.width,e.height)),e}(m(b,e)):b,o=document.createElement("canvas");o.width=r,o.height=i;const a=Math.min(r,i)-2*n;t._setupSvg();const s=t._svgDrawingPromise?.then((async()=>{if(!t._svg)return;const e=await t.serialize();if(!e)return;const n="data:image/svg+xml;base64,"+btoa(e),s=new Image;return new Promise(((t,e)=>{s.onload=()=>{o?.getContext("2d")?.drawImage(s,(r-a)/2,(i-a)/2,a,a),t()},s.onerror=s.onabort=e,s.src=n}))}));return{canvas:o,canvasDrawingPromise:s}}async function O(t,e,r){if(!t._qr)throw"QR code is empty";let i=l.png,n="qr";if("string"==typeof e?(i=e,console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")):"object"==typeof e&&null!==e&&(e.name&&(n=e.name),e.extension&&(i=e.extension)),"svg"===i.toLowerCase()){let e=await t.serialize();e='<?xml version="1.0" standalone="no"?>\r\n'+e,P("data:image/svg+xml;charset=utf-8,"+encodeURIComponent(e),`${n}.svg`)}else{const e=q(t,r);if(!e)return;const{canvas:o,canvasDrawingPromise:a}=e;await a,P(o.toDataURL(`image/${i}`),`${n}.${i}`)}}function P(t,e){const r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}const z={QRCodeStyling:k,browserUtils:h,types:t}})(),i.default})()));
2
- //# sourceMappingURL=qr-code-styling.js.map
1
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).QRCodeStyling={})}(this,(function(t){"use strict";var e,r,i,n,o;t.DotType=void 0,(e=t.DotType||(t.DotType={})).dots="dots",e.rounded="rounded",e.classy="classy",e.classyRounded="classy-rounded",e.square="square",e.extraRounded="extra-rounded",t.CornerDotType=void 0,(r=t.CornerDotType||(t.CornerDotType={})).dot="dot",r.square="square",t.CornerSquareType=void 0,(i=t.CornerSquareType||(t.CornerSquareType={})).dot="dot",i.square="square",i.extraRounded="extra-rounded",t.GradientType=void 0,(n=t.GradientType||(t.GradientType={})).radial="radial",n.linear="linear",t.ShapeType=void 0,(o=t.ShapeType||(t.ShapeType={})).square="square",o.circle="circle";const a=Array(41).fill(0).map(((t,e)=>e));var s,h,u;t.ErrorCorrectionLevel=void 0,(s=t.ErrorCorrectionLevel||(t.ErrorCorrectionLevel={})).L="L",s.M="M",s.Q="Q",s.H="H",t.Mode=void 0,(h=t.Mode||(t.Mode={})).numeric="Numeric",h.alphanumeric="Alphanumeric",h.byte="Byte",h.kanji="Kanji",t.FileExtension=void 0,(u=t.FileExtension||(t.FileExtension={})).svg="svg",u.png="png",u.jpeg="jpeg",u.webp="webp";const d={[t.ErrorCorrectionLevel.L]:.07,[t.ErrorCorrectionLevel.M]:.15,[t.ErrorCorrectionLevel.Q]:.25,[t.ErrorCorrectionLevel.H]:.3};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var l={exports:{}};!function(t,e){var r=function(){var t=function(t,e){var r=t,i=d[e],n=null,o=0,a=null,s=[],h={},u=function(t,e){n=function(t){for(var e=new Array(t),r=0;r<t;r+=1){e[r]=new Array(t);for(var i=0;i<t;i+=1)e[r][i]=null}return e}(o=4*r+17),c(0,0),c(o-7,0),c(0,o-7),g(),l(),p(t,e),r>=7&&f(t),null==a&&(a=m(r,i,s)),w(a,e)},c=function(t,e){for(var r=-1;r<=7;r+=1)if(!(t+r<=-1||o<=t+r))for(var i=-1;i<=7;i+=1)e+i<=-1||o<=e+i||(n[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)},l=function(){for(var t=8;t<o-8;t+=1)null==n[t][6]&&(n[t][6]=t%2==0);for(var e=8;e<o-8;e+=1)null==n[6][e]&&(n[6][e]=e%2==0)},g=function(){for(var t=y.getPatternPosition(r),e=0;e<t.length;e+=1)for(var i=0;i<t.length;i+=1){var o=t[e],a=t[i];if(null==n[o][a])for(var s=-2;s<=2;s+=1)for(var h=-2;h<=2;h+=1)n[o+s][a+h]=-2==s||2==s||-2==h||2==h||0==s&&0==h}},f=function(t){for(var e=y.getBCHTypeNumber(r),i=0;i<18;i+=1){var a=!t&&1==(e>>i&1);n[Math.floor(i/3)][i%3+o-8-3]=a}for(i=0;i<18;i+=1){a=!t&&1==(e>>i&1);n[i%3+o-8-3][Math.floor(i/3)]=a}},p=function(t,e){for(var r=i<<3|e,a=y.getBCHTypeInfo(r),s=0;s<15;s+=1){var h=!t&&1==(a>>s&1);s<6?n[s][8]=h:s<8?n[s+1][8]=h:n[o-15+s][8]=h}for(s=0;s<15;s+=1){h=!t&&1==(a>>s&1);s<8?n[8][o-s-1]=h:s<9?n[8][15-s-1+1]=h:n[8][15-s-1]=h}n[o-8][8]=!t},w=function(t,e){for(var r=-1,i=o-1,a=7,s=0,h=y.getMaskFunction(e),u=o-1;u>0;u-=2)for(6==u&&(u-=1);;){for(var d=0;d<2;d+=1)if(null==n[i][u-d]){var c=!1;s<t.length&&(c=1==(t[s]>>>a&1)),h(i,u-d)&&(c=!c),n[i][u-d]=c,-1==(a-=1)&&(s+=1,a=7)}if((i+=r)<0||o<=i){i-=r,r=-r;break}}},m=function(t,e,r){for(var i=x.getRSBlocks(t,e),n=S(),o=0;o<r.length;o+=1){var a=r[o];n.put(a.getMode(),4),n.put(a.getLength(),y.getLengthInBits(a.getMode(),t)),a.write(n)}var s=0;for(o=0;o<i.length;o+=1)s+=i[o].dataCount;if(n.getLengthInBits()>8*s)throw"code length overflow. ("+n.getLengthInBits()+">"+8*s+")";for(n.getLengthInBits()+4<=8*s&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*s||(n.put(236,8),n.getLengthInBits()>=8*s));)n.put(17,8);return function(t,e){for(var r=0,i=0,n=0,o=new Array(e.length),a=new Array(e.length),s=0;s<e.length;s+=1){var h=e[s].dataCount,u=e[s].totalCount-h;i=Math.max(i,h),n=Math.max(n,u),o[s]=new Array(h);for(var d=0;d<o[s].length;d+=1)o[s][d]=255&t.getBuffer()[d+r];r+=h;var c=y.getErrorCorrectPolynomial(u),l=b(o[s],c.getLength()-1).mod(c);for(a[s]=new Array(c.getLength()-1),d=0;d<a[s].length;d+=1){var g=d+l.getLength()-a[s].length;a[s][d]=g>=0?l.getAt(g):0}}var f=0;for(d=0;d<e.length;d+=1)f+=e[d].totalCount;var p=new Array(f),w=0;for(d=0;d<i;d+=1)for(s=0;s<e.length;s+=1)d<o[s].length&&(p[w]=o[s][d],w+=1);for(d=0;d<n;d+=1)for(s=0;s<e.length;s+=1)d<a[s].length&&(p[w]=a[s][d],w+=1);return p}(n,i)};h.addData=function(t,e){var r=null;switch(e=e||"Byte"){case"Numeric":r=C(t);break;case"Alphanumeric":r=M(t);break;case"Byte":r=A(t);break;case"Kanji":r=D(t);break;default:throw"mode:"+e}s.push(r),a=null},h.isDark=function(t,e){if(t<0||o<=t||e<0||o<=e)throw t+","+e;return n[t][e]},h.getModuleCount=function(){return o},h.make=function(){if(r<1){for(var t=1;t<40;t++){for(var e=x.getRSBlocks(t,i),n=S(),o=0;o<s.length;o++){var a=s[o];n.put(a.getMode(),4),n.put(a.getLength(),y.getLengthInBits(a.getMode(),t)),a.write(n)}var d=0;for(o=0;o<e.length;o++)d+=e[o].dataCount;if(n.getLengthInBits()<=8*d)break}r=t}u(!1,function(){for(var t=0,e=0,r=0;r<8;r+=1){u(!0,r);var i=y.getLostPoint(h);(0==r||t>i)&&(t=i,e=r)}return e}())},h.createTableTag=function(t,e){t=t||2;var r="";r+='<table style="',r+=" border-width: 0px; border-style: none;",r+=" border-collapse: collapse;",r+=" padding: 0px; margin: "+(e=void 0===e?4*t:e)+"px;",r+='">',r+="<tbody>";for(var i=0;i<h.getModuleCount();i+=1){r+="<tr>";for(var n=0;n<h.getModuleCount();n+=1)r+='<td style="',r+=" border-width: 0px; border-style: none;",r+=" border-collapse: collapse;",r+=" padding: 0px; margin: 0px;",r+=" width: "+t+"px;",r+=" height: "+t+"px;",r+=" background-color: ",r+=h.isDark(i,n)?"#000000":"#ffffff",r+=";",r+='"/>';r+="</tr>"}return r+="</tbody>",r+="</table>"},h.createSvgTag=function(t,e,r,i){var n={};"object"==typeof arguments[0]&&(t=(n=arguments[0]).cellSize,e=n.margin,r=n.alt,i=n.title),t=t||2,e=void 0===e?4*t:e,(r="string"==typeof r?{text:r}:r||{}).text=r.text||null,r.id=r.text?r.id||"qrcode-description":null,(i="string"==typeof i?{text:i}:i||{}).text=i.text||null,i.id=i.text?i.id||"qrcode-title":null;var o,a,s,u,d=h.getModuleCount()*t+2*e,c="";for(u="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",c+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',c+=n.scalable?"":' width="'+d+'px" height="'+d+'px"',c+=' viewBox="0 0 '+d+" "+d+'" ',c+=' preserveAspectRatio="xMinYMin meet"',c+=i.text||r.text?' role="img" aria-labelledby="'+_([i.id,r.id].join(" ").trim())+'"':"",c+=">",c+=i.text?'<title id="'+_(i.id)+'">'+_(i.text)+"</title>":"",c+=r.text?'<description id="'+_(r.id)+'">'+_(r.text)+"</description>":"",c+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',c+='<path d="',a=0;a<h.getModuleCount();a+=1)for(s=a*t+e,o=0;o<h.getModuleCount();o+=1)h.isDark(a,o)&&(c+="M"+(o*t+e)+","+s+u);return c+='" stroke="transparent" fill="black"/>',c+="</svg>"},h.createDataURL=function(t,e){t=t||2,e=void 0===e?4*t:e;var r=h.getModuleCount()*t+2*e,i=e,n=r-e;return q(r,r,(function(e,r){if(i<=e&&e<n&&i<=r&&r<n){var o=Math.floor((e-i)/t),a=Math.floor((r-i)/t);return h.isDark(a,o)?0:1}return 1}))},h.createImgTag=function(t,e,r){t=t||2,e=void 0===e?4*t:e;var i=h.getModuleCount()*t+2*e,n="";return n+="<img",n+=' src="',n+=h.createDataURL(t,e),n+='"',n+=' width="',n+=i,n+='"',n+=' height="',n+=i,n+='"',r&&(n+=' alt="',n+=_(r),n+='"'),n+="/>"};var _=function(t){for(var e="",r=0;r<t.length;r+=1){var i=t.charAt(r);switch(i){case"<":e+="&lt;";break;case">":e+="&gt;";break;case"&":e+="&amp;";break;case'"':e+="&quot;";break;default:e+=i}}return e};return h.createASCII=function(t,e){if((t=t||1)<2)return function(t){t=void 0===t?2:t;var e,r,i,n,o,a=1*h.getModuleCount()+2*t,s=t,u=a-t,d={"██":"█","█ ":"▀"," █":"▄"," ":" "},c={"██":"▀","█ ":"▀"," █":" "," ":" "},l="";for(e=0;e<a;e+=2){for(i=Math.floor((e-s)/1),n=Math.floor((e+1-s)/1),r=0;r<a;r+=1)o="█",s<=r&&r<u&&s<=e&&e<u&&h.isDark(i,Math.floor((r-s)/1))&&(o=" "),s<=r&&r<u&&s<=e+1&&e+1<u&&h.isDark(n,Math.floor((r-s)/1))?o+=" ":o+="█",l+=t<1&&e+1>=u?c[o]:d[o];l+="\n"}return a%2&&t>0?l.substring(0,l.length-a-1)+Array(a+1).join("▀"):l.substring(0,l.length-1)}(e);t-=1,e=void 0===e?2*t:e;var r,i,n,o,a=h.getModuleCount()*t+2*e,s=e,u=a-e,d=Array(t+1).join("██"),c=Array(t+1).join(" "),l="",g="";for(r=0;r<a;r+=1){for(n=Math.floor((r-s)/t),g="",i=0;i<a;i+=1)o=1,s<=i&&i<u&&s<=r&&r<u&&h.isDark(n,Math.floor((i-s)/t))&&(o=0),g+=o?d:c;for(n=0;n<t;n+=1)l+=g+"\n"}return l.substring(0,l.length-1)},h.renderTo2dContext=function(t,e){e=e||2;for(var r=h.getModuleCount(),i=0;i<r;i++)for(var n=0;n<r;n++)t.fillStyle=h.isDark(i,n)?"black":"white",t.fillRect(i*e,n*e,e,e)},h};t.stringToBytes=(t.stringToBytesFuncs={default:function(t){for(var e=[],r=0;r<t.length;r+=1){var i=t.charCodeAt(r);e.push(255&i)}return e}}).default,t.createStringToBytes=function(t,e){var r=function(){for(var r=k(t),i=function(){var t=r.read();if(-1==t)throw"eof";return t},n=0,o={};;){var a=r.read();if(-1==a)break;var s=i(),h=i()<<8|i();o[String.fromCharCode(a<<8|s)]=h,n+=1}if(n!=e)throw n+" != "+e;return o}(),i="?".charCodeAt(0);return function(t){for(var e=[],n=0;n<t.length;n+=1){var o=t.charCodeAt(n);if(o<128)e.push(o);else{var a=r[t.charAt(n)];"number"==typeof a?(255&a)==a?e.push(a):(e.push(a>>>8),e.push(255&a)):e.push(i)}}return e}};var e,r,i,n,o,a=1,s=2,h=4,u=8,d={L:1,M:0,Q:3,H:2},c=0,l=1,g=2,f=3,p=4,w=5,m=6,_=7,y=(e=[[],[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]],r=1335,i=7973,o=function(t){for(var e=0;0!=t;)e+=1,t>>>=1;return e},(n={}).getBCHTypeInfo=function(t){for(var e=t<<10;o(e)-o(r)>=0;)e^=r<<o(e)-o(r);return 21522^(t<<10|e)},n.getBCHTypeNumber=function(t){for(var e=t<<12;o(e)-o(i)>=0;)e^=i<<o(e)-o(i);return t<<12|e},n.getPatternPosition=function(t){return e[t-1]},n.getMaskFunction=function(t){switch(t){case c:return function(t,e){return(t+e)%2==0};case l:return function(t,e){return t%2==0};case g:return function(t,e){return e%3==0};case f:return function(t,e){return(t+e)%3==0};case p:return function(t,e){return(Math.floor(t/2)+Math.floor(e/3))%2==0};case w:return function(t,e){return t*e%2+t*e%3==0};case m:return function(t,e){return(t*e%2+t*e%3)%2==0};case _:return function(t,e){return(t*e%3+(t+e)%2)%2==0};default:throw"bad maskPattern:"+t}},n.getErrorCorrectPolynomial=function(t){for(var e=b([1],0),r=0;r<t;r+=1)e=e.multiply(b([1,v.gexp(r)],0));return e},n.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case a:return 10;case s:return 9;case h:case u:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case a:return 12;case s:return 11;case h:return 16;case u:return 10;default:throw"mode:"+t}else{if(!(e<41))throw"type:"+e;switch(t){case a:return 14;case s:return 13;case h:return 16;case u:return 12;default:throw"mode:"+t}}},n.getLostPoint=function(t){for(var e=t.getModuleCount(),r=0,i=0;i<e;i+=1)for(var n=0;n<e;n+=1){for(var o=0,a=t.isDark(i,n),s=-1;s<=1;s+=1)if(!(i+s<0||e<=i+s))for(var h=-1;h<=1;h+=1)n+h<0||e<=n+h||0==s&&0==h||a==t.isDark(i+s,n+h)&&(o+=1);o>5&&(r+=3+o-5)}for(i=0;i<e-1;i+=1)for(n=0;n<e-1;n+=1){var u=0;t.isDark(i,n)&&(u+=1),t.isDark(i+1,n)&&(u+=1),t.isDark(i,n+1)&&(u+=1),t.isDark(i+1,n+1)&&(u+=1),0!=u&&4!=u||(r+=3)}for(i=0;i<e;i+=1)for(n=0;n<e-6;n+=1)t.isDark(i,n)&&!t.isDark(i,n+1)&&t.isDark(i,n+2)&&t.isDark(i,n+3)&&t.isDark(i,n+4)&&!t.isDark(i,n+5)&&t.isDark(i,n+6)&&(r+=40);for(n=0;n<e;n+=1)for(i=0;i<e-6;i+=1)t.isDark(i,n)&&!t.isDark(i+1,n)&&t.isDark(i+2,n)&&t.isDark(i+3,n)&&t.isDark(i+4,n)&&!t.isDark(i+5,n)&&t.isDark(i+6,n)&&(r+=40);var d=0;for(n=0;n<e;n+=1)for(i=0;i<e;i+=1)t.isDark(i,n)&&(d+=1);return r+=Math.abs(100*d/e/e-50)/5*10},n),v=function(){for(var t=new Array(256),e=new Array(256),r=0;r<8;r+=1)t[r]=1<<r;for(r=8;r<256;r+=1)t[r]=t[r-4]^t[r-5]^t[r-6]^t[r-8];for(r=0;r<255;r+=1)e[t[r]]=r;var i={glog:function(t){if(t<1)throw"glog("+t+")";return e[t]},gexp:function(e){for(;e<0;)e+=255;for(;e>=256;)e-=255;return t[e]}};return i}();function b(t,e){if(void 0===t.length)throw t.length+"/"+e;var r=function(){for(var r=0;r<t.length&&0==t[r];)r+=1;for(var i=new Array(t.length-r+e),n=0;n<t.length-r;n+=1)i[n]=t[n+r];return i}(),i={getAt:function(t){return r[t]},getLength:function(){return r.length},multiply:function(t){for(var e=new Array(i.getLength()+t.getLength()-1),r=0;r<i.getLength();r+=1)for(var n=0;n<t.getLength();n+=1)e[r+n]^=v.gexp(v.glog(i.getAt(r))+v.glog(t.getAt(n)));return b(e,0)},mod:function(t){if(i.getLength()-t.getLength()<0)return i;for(var e=v.glog(i.getAt(0))-v.glog(t.getAt(0)),r=new Array(i.getLength()),n=0;n<i.getLength();n+=1)r[n]=i.getAt(n);for(n=0;n<t.getLength();n+=1)r[n]^=v.gexp(v.glog(t.getAt(n))+e);return b(r,0).mod(t)}};return i}var x=function(){var t=[[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]],e=function(t,e){var r={};return r.totalCount=t,r.dataCount=e,r},r={};return r.getRSBlocks=function(r,i){var n=function(e,r){switch(r){case d.L:return t[4*(e-1)+0];case d.M:return t[4*(e-1)+1];case d.Q:return t[4*(e-1)+2];case d.H:return t[4*(e-1)+3];default:return}}(r,i);if(void 0===n)throw"bad rs block @ typeNumber:"+r+"/errorCorrectionLevel:"+i;for(var o=n.length/3,a=[],s=0;s<o;s+=1)for(var h=n[3*s+0],u=n[3*s+1],c=n[3*s+2],l=0;l<h;l+=1)a.push(e(u,c));return a},r}(),S=function(){var t=[],e=0,r={getBuffer:function(){return t},getAt:function(e){var r=Math.floor(e/8);return 1==(t[r]>>>7-e%8&1)},put:function(t,e){for(var i=0;i<e;i+=1)r.putBit(1==(t>>>e-i-1&1))},getLengthInBits:function(){return e},putBit:function(r){var i=Math.floor(e/8);t.length<=i&&t.push(0),r&&(t[i]|=128>>>e%8),e+=1}};return r},C=function(t){var e=a,r=t,i={getMode:function(){return e},getLength:function(t){return r.length},write:function(t){for(var e=r,i=0;i+2<e.length;)t.put(n(e.substring(i,i+3)),10),i+=3;i<e.length&&(e.length-i==1?t.put(n(e.substring(i,i+1)),4):e.length-i==2&&t.put(n(e.substring(i,i+2)),7))}},n=function(t){for(var e=0,r=0;r<t.length;r+=1)e=10*e+o(t.charAt(r));return e},o=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-"0".charCodeAt(0);throw"illegal char :"+t};return i},M=function(t){var e=s,r=t,i={getMode:function(){return e},getLength:function(t){return r.length},write:function(t){for(var e=r,i=0;i+1<e.length;)t.put(45*n(e.charAt(i))+n(e.charAt(i+1)),11),i+=2;i<e.length&&t.put(n(e.charAt(i)),6)}},n=function(t){if("0"<=t&&t<="9")return t.charCodeAt(0)-"0".charCodeAt(0);if("A"<=t&&t<="Z")return t.charCodeAt(0)-"A".charCodeAt(0)+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"illegal char :"+t}};return i},A=function(e){var r=h,i=t.stringToBytes(e),n={getMode:function(){return r},getLength:function(t){return i.length},write:function(t){for(var e=0;e<i.length;e+=1)t.put(i[e],8)}};return n},D=function(e){var r=u,i=t.stringToBytesFuncs.SJIS;if(!i)throw"sjis not supported.";!function(t,e){var r=i("友");if(2!=r.length||38726!=(r[0]<<8|r[1]))throw"sjis not supported."}();var n=i(e),o={getMode:function(){return r},getLength:function(t){return~~(n.length/2)},write:function(t){for(var e=n,r=0;r+1<e.length;){var i=(255&e[r])<<8|255&e[r+1];if(33088<=i&&i<=40956)i-=33088;else{if(!(57408<=i&&i<=60351))throw"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"illegal char at "+(r+1)}};return o},$=function(){var t=[],e={writeByte:function(e){t.push(255&e)},writeShort:function(t){e.writeByte(t),e.writeByte(t>>>8)},writeBytes:function(t,r,i){r=r||0,i=i||t.length;for(var n=0;n<i;n+=1)e.writeByte(t[n+r])},writeString:function(t){for(var r=0;r<t.length;r+=1)e.writeByte(t.charCodeAt(r))},toByteArray:function(){return t},toString:function(){var e="";e+="[";for(var r=0;r<t.length;r+=1)r>0&&(e+=","),e+=t[r];return e+="]"}};return e},k=function(t){var e=t,r=0,i=0,n=0,o={read:function(){for(;n<8;){if(r>=e.length){if(0==n)return-1;throw"unexpected end of file./"+n}var t=e.charAt(r);if(r+=1,"="==t)return n=0,-1;t.match(/^\s$/)||(i=i<<6|a(t.charCodeAt(0)),n+=6)}var o=i>>>n-8&255;return n-=8,o}},a=function(t){if(65<=t&&t<=90)return t-65;if(97<=t&&t<=122)return t-97+26;if(48<=t&&t<=57)return t-48+52;if(43==t)return 62;if(47==t)return 63;throw"c:"+t};return o},q=function(t,e,r){for(var i=function(t,e){var r=t,i=e,n=new Array(t*e),o={setPixel:function(t,e,i){n[e*r+t]=i},write:function(t){t.writeString("GIF87a"),t.writeShort(r),t.writeShort(i),t.writeByte(128),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(0),t.writeByte(255),t.writeByte(255),t.writeByte(255),t.writeString(","),t.writeShort(0),t.writeShort(0),t.writeShort(r),t.writeShort(i),t.writeByte(0);var e=a(2);t.writeByte(2);for(var n=0;e.length-n>255;)t.writeByte(255),t.writeBytes(e,n,255),n+=255;t.writeByte(e.length-n),t.writeBytes(e,n,e.length-n),t.writeByte(0),t.writeString(";")}},a=function(t){for(var e=1<<t,r=1+(1<<t),i=t+1,o=s(),a=0;a<e;a+=1)o.add(String.fromCharCode(a));o.add(String.fromCharCode(e)),o.add(String.fromCharCode(r));var h,u,d,c=$(),l=(h=c,u=0,d=0,{write:function(t,e){if(t>>>e!=0)throw"length over";for(;u+e>=8;)h.writeByte(255&(t<<u|d)),e-=8-u,t>>>=8-u,d=0,u=0;d|=t<<u,u+=e},flush:function(){u>0&&h.writeByte(d)}});l.write(e,i);var g=0,f=String.fromCharCode(n[g]);for(g+=1;g<n.length;){var p=String.fromCharCode(n[g]);g+=1,o.contains(f+p)?f+=p:(l.write(o.indexOf(f),i),o.size()<4095&&(o.size()==1<<i&&(i+=1),o.add(f+p)),f=p)}return l.write(o.indexOf(f),i),l.write(r,i),l.flush(),c.toByteArray()},s=function(){var t={},e=0,r={add:function(i){if(r.contains(i))throw"dup key:"+i;t[i]=e,e+=1},size:function(){return e},indexOf:function(e){return t[e]},contains:function(e){return void 0!==t[e]}};return r};return o}(t,e),n=0;n<e;n+=1)for(var o=0;o<t;o+=1)i.setPixel(o,n,r(o,n));var a=$();i.write(a);for(var s=function(){var t=0,e=0,r=0,i="",n={},o=function(t){i+=String.fromCharCode(a(63&t))},a=function(t){if(t<0);else{if(t<26)return 65+t;if(t<52)return t-26+97;if(t<62)return t-52+48;if(62==t)return 43;if(63==t)return 47}throw"n:"+t};return n.writeByte=function(i){for(t=t<<8|255&i,e+=8,r+=1;e>=6;)o(t>>>e-6),e-=6},n.flush=function(){if(e>0&&(o(t<<6-e),t=0,e=0),r%3!=0)for(var n=3-r%3,a=0;a<n;a+=1)i+="="},n.toString=function(){return i},n}(),h=a.toByteArray(),u=0;u<h.length;u+=1)s.writeByte(h[u]);return s.flush(),"data:image/gif;base64,"+s};return t}();r.stringToBytesFuncs["UTF-8"]=function(t){return function(t){for(var e=[],r=0;r<t.length;r++){var 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}(t)},t.exports=r}(l);var g=c(l.exports);const f=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function p(t,...e){if(!e.length)return t;const r=e.shift();return void 0!==r&&f(t)&&f(r)?(t={...t},Object.keys(r).forEach((e=>{const i=t[e],n=r[e];Array.isArray(i)&&Array.isArray(n)?t[e]=n:f(i)&&f(n)?t[e]=p(Object.assign({},i),n):t[e]=n})),p(t,...e)):t}function w(t){const e={...t};if(!e.colorStops||!e.colorStops.length)throw"Field 'colorStops' is required in gradient";return e.rotation?e.rotation=Number(e.rotation):e.rotation=0,e.colorStops=e.colorStops.map((t=>({...t,offset:Number(t.offset)}))),e}function m(t){const e={...t};return e.imageOptions={...e.imageOptions,hideBackgroundDots:Boolean(e.imageOptions.hideBackgroundDots),imageSize:Math.min(1,Number(e.imageOptions.imageSize))||1,margin:Number(e.imageOptions.margin)},e.dotsOptions={...e.dotsOptions},e.dotsOptions.gradient&&(e.dotsOptions.gradient=w(e.dotsOptions.gradient)),e.cornersSquareOptions&&(e.cornersSquareOptions={...e.cornersSquareOptions},e.cornersSquareOptions.gradient&&(e.cornersSquareOptions.gradient=w(e.cornersSquareOptions.gradient))),e.cornersDotOptions&&(e.cornersDotOptions={...e.cornersDotOptions},e.cornersDotOptions.gradient&&(e.cornersDotOptions.gradient=w(e.cornersDotOptions.gradient))),e.backgroundOptions&&(e.backgroundOptions={...e.backgroundOptions},e.backgroundOptions.gradient&&(e.backgroundOptions.gradient=w(e.backgroundOptions.gradient))),e.document||(e.document=document),e}const _={document:void 0,shape:t.ShapeType.square,width:void 0,height:void 0,data:"",qrOptions:{typeNumber:a[0],mode:void 0,errorCorrectionLevel:t.ErrorCorrectionLevel.Q},imageOptions:{hideBackgroundDots:!0,imageSize:.4,crossOrigin:void 0,margin:0},dotsOptions:{type:t.DotType.square,color:"#000"}},y={width:300,height:300,margin:10};class v{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(e,r,i,n){let o;switch(this._type){case t.CornerDotType.square:o=this._drawSquare;break;case t.CornerDotType.dot:default:o=this._drawDot}o.call(this,{x:e,y:r,size:i,rotation:n})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,a=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${a})`)}_basicDot(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(r+e/2)),this._element.setAttribute("cy",String(i+e/2)),this._element.setAttribute("r",String(e/2))}})}_basicSquare(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(r)),this._element.setAttribute("y",String(i)),this._element.setAttribute("width",String(e)),this._element.setAttribute("height",String(e))}})}_drawDot({x:t,y:e,size:r,rotation:i}){this._basicDot({x:t,y:e,size:r,rotation:i})}_drawSquare({x:t,y:e,size:r,rotation:i}){this._basicSquare({x:t,y:e,size:r,rotation:i})}}class b{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(e,r,i,n){let o;switch(this._type){case t.CornerSquareType.square:o=this._drawSquare;break;case t.CornerSquareType.extraRounded:o=this._drawExtraRounded;break;case t.CornerSquareType.dot:default:o=this._drawDot}o.call(this,{x:e,y:r,size:i,rotation:n})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,a=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${a})`)}_basicDot(t){const{size:e,x:r,y:i}=t,n=e/7;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${r+e/2} ${i}a ${e/2} ${e/2} 0 1 0 0.1 0zm 0 ${n}a ${e/2-n} ${e/2-n} 0 1 1 -0.1 0Z`)}})}_basicSquare(t){const{size:e,x:r,y:i}=t,n=e/7;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h ${e}v `+-e+"z"+`M ${r+n} ${i+n}h `+(e-2*n)+"v "+(e-2*n)+"h "+(2*n-e)+"z")}})}_basicExtraRounded(t){const{size:e,x:r,y:i}=t,n=e/7;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("clip-rule","evenodd"),this._element.setAttribute("d",`M ${r} ${i+2.5*n}v `+2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*n} ${2.5*n}h `+2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*n} ${2.5*-n}v `+-2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*-n}h `+-2*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*n}`+`M ${r+2.5*n} ${i+n}h `+2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*n} ${1.5*n}v `+2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*-n} ${1.5*n}h `+-2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*-n} ${1.5*-n}v `+-2*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*n} ${1.5*-n}`)}})}_drawDot({x:t,y:e,size:r,rotation:i}){this._basicDot({x:t,y:e,size:r,rotation:i})}_drawSquare({x:t,y:e,size:r,rotation:i}){this._basicSquare({x:t,y:e,size:r,rotation:i})}_drawExtraRounded({x:t,y:e,size:r,rotation:i}){this._basicExtraRounded({x:t,y:e,size:r,rotation:i})}}class x{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(e,r,i,n){let o;switch(this._type){case t.DotType.dots:o=this._drawDot;break;case t.DotType.classy:o=this._drawClassy;break;case t.DotType.classyRounded:o=this._drawClassyRounded;break;case t.DotType.rounded:o=this._drawRounded;break;case t.DotType.extraRounded:o=this._drawExtraRounded;break;case t.DotType.square:default:o=this._drawSquare}o.call(this,{x:e,y:r,size:i,getNeighbor:n})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,a=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${a})`)}_basicDot(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","circle"),this._element.setAttribute("cx",String(r+e/2)),this._element.setAttribute("cy",String(i+e/2)),this._element.setAttribute("r",String(e/2))}})}_basicSquare(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","rect"),this._element.setAttribute("x",String(r)),this._element.setAttribute("y",String(i)),this._element.setAttribute("width",String(e)),this._element.setAttribute("height",String(e))}})}_basicSideRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h `+e/2+`a ${e/2} ${e/2}, 0, 0, 0, 0 ${-e}`)}})}_basicCornerRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h ${e}v `+-e/2+`a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2}`)}})}_basicCornerExtraRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v ${e}h ${e}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}`)}})}_basicCornersRounded(t){const{size:e,x:r,y:i}=t;this._rotateFigure({...t,draw:()=>{this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path"),this._element.setAttribute("d",`M ${r} ${i}v `+e/2+`a ${e/2} ${e/2}, 0, 0, 0, ${e/2} ${e/2}h `+e/2+"v "+-e/2+`a ${e/2} ${e/2}, 0, 0, 0, ${-e/2} ${-e/2}`)}})}_drawDot({x:t,y:e,size:r}){this._basicDot({x:t,y:e,size:r,rotation:0})}_drawSquare({x:t,y:e,size:r}){this._basicSquare({x:t,y:e,size:r,rotation:0})}_drawRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0,h=n+o+a+s;if(0!==h)if(h>2||n&&o||a&&s)this._basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&a?i=Math.PI/2:a&&o?i=Math.PI:o&&s&&(i=-Math.PI/2),void this._basicCornerRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return a?i=Math.PI/2:o?i=Math.PI:s&&(i=-Math.PI/2),void this._basicSideRounded({x:t,y:e,size:r,rotation:i})}}else this._basicDot({x:t,y:e,size:r,rotation:0})}_drawExtraRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0,h=n+o+a+s;if(0!==h)if(h>2||n&&o||a&&s)this._basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&a?i=Math.PI/2:a&&o?i=Math.PI:o&&s&&(i=-Math.PI/2),void this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return a?i=Math.PI/2:o?i=Math.PI:s&&(i=-Math.PI/2),void this._basicSideRounded({x:t,y:e,size:r,rotation:i})}}else this._basicDot({x:t,y:e,size:r,rotation:0})}_drawClassy({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0;0!==n+o+a+s?n||a?o||s?this._basicSquare({x:t,y:e,size:r,rotation:0}):this._basicCornerRounded({x:t,y:e,size:r,rotation:Math.PI/2}):this._basicCornerRounded({x:t,y:e,size:r,rotation:-Math.PI/2}):this._basicCornersRounded({x:t,y:e,size:r,rotation:Math.PI/2})}_drawClassyRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,a=i?+i(0,-1):0,s=i?+i(0,1):0;0!==n+o+a+s?n||a?o||s?this._basicSquare({x:t,y:e,size:r,rotation:0}):this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:Math.PI/2}):this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:-Math.PI/2}):this._basicCornersRounded({x:t,y:e,size:r,rotation:Math.PI/2})}}const S={toDataURL:t=>new Promise(((e,r)=>{if("string"==typeof t){const i=new XMLHttpRequest;i.onload=function(){const t=new FileReader;t.onloadend=function(){e(t.result)},t.readAsDataURL(i.response)},i.onerror=i.onabort=i.ontimeout=r,i.open("GET",t),i.responseType="blob",i.send()}else{const r=new FileReader;r.onloadend=function(){e(r.result)},r.readAsDataURL(t)}})),getSize:t=>new Promise(((e,r)=>{if(!t.image)return r("Image is not defined");const i=new Image;"string"==typeof t.imageOptions.crossOrigin&&(i.crossOrigin=t.imageOptions.crossOrigin),i.onload=()=>{e({width:i.width,height:i.height})},i.onerror=i.onabort=r,"string"==typeof t.image?i.src=t.image:S.toDataURL(t.image).then((t=>i.src=t)).catch(r)}))},C=[[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]],M=[[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]];class A{constructor(t){this._document=t.document,this._element=this._document.createElementNS("http://www.w3.org/2000/svg","svg"),this._element.setAttribute("width",String(t.width)),this._element.setAttribute("height",String(t.height)),this._element.setAttribute("viewBox",`0 0 ${t.width} ${t.height}`),this._defs=this._document.createElementNS("http://www.w3.org/2000/svg","defs"),this._element.appendChild(this._defs),this._imageTools=t.imageTools||S,this._options=t}get width(){return this._options.width}get height(){return this._options.height}getElement(){return this._element}async drawQR(e){const r=e.getModuleCount(),i=Math.min(this._options.width,this._options.height),n=this._options.shape===t.ShapeType.circle?i/Math.sqrt(2):i,o=Math.floor(n/r);let a={hideXDots:0,hideYDots:0,width:0,height:0};if(this._qr=e,this._options.image){const t=await this._imageTools.getSize(this._options),{imageOptions:e,qrOptions:i}=this._options,n=e.imageSize*d[i.errorCorrectionLevel],s=Math.floor(n*r*r);a=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:n}){const o={x:0,y:0},a={x:0,y:0};if(t<=0||e<=0||r<=0||n<=0)return{height:0,width:0,hideYDots:0,hideXDots:0};const s=t/e;return o.x=Math.floor(Math.sqrt(r/s)),o.x<=0&&(o.x=1),i&&i<o.x&&(o.x=i),o.x%2==0&&o.x--,a.x=o.x*n,o.y=1+2*Math.ceil((o.x*s-1)/2),a.y=Math.round(a.x*s),(o.y*o.x>r||i&&i<o.y)&&(i&&i<o.y?(o.y=i,o.y%2==0&&o.x--):o.y-=2,a.y=o.y*n,o.x=1+2*Math.ceil((o.y/s-1)/2),a.x=Math.round(a.y/s)),{height:a.y,width:a.x,hideYDots:o.y,hideXDots:o.x}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:s,maxHiddenAxisDots:r-14,dotSize:o})}this.drawBackground(),this.drawDots(((t,e)=>!(this._options.imageOptions.hideBackgroundDots&&t>=(r-a.hideXDots)/2&&t<(r+a.hideXDots)/2&&e>=(r-a.hideYDots)/2&&e<(r+a.hideYDots)/2)&&(!(C[t]?.[e]||C[t-r+7]?.[e]||C[t]?.[e-r+7])&&!(M[t]?.[e]||M[t-r+7]?.[e]||M[t]?.[e-r+7])))),this.drawCorners(),this._options.image&&await this.drawImage({width:a.width,height:a.height,count:r,dotSize:o})}drawBackground(){const t=this._element,e=this._options;if(t&&e.backgroundOptions){const t=e.backgroundOptions.gradient,r=e.backgroundOptions.color;this._createColor({options:t,color:r,additionalRotation:0,x:0,y:0,height:e.height,width:e.width,name:"background-color"});const i=Math.min(e.width,e.height),n=this._document.createElementNS("http://www.w3.org/2000/svg","rect");this._backgroundClipPath=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._backgroundClipPath.setAttribute("id","clip-path-background-color"),this._defs.appendChild(this._backgroundClipPath),n.setAttribute("x",String((e.width-i)/2)),n.setAttribute("y",String((e.height-i)/2)),n.setAttribute("width",String(i)),n.setAttribute("height",String(i)),n.setAttribute("rx",String(i/2*(e.backgroundOptions.round||0))),this._backgroundClipPath.appendChild(n)}}drawDots(e){if(!this._qr)throw"QR code is not defined";const r=this._options,i=this._qr.getModuleCount();if(i>r.width||i>r.height)throw"The canvas is too small.";const n=Math.min(r.width,r.height),o=r.shape===t.ShapeType.circle?n/Math.sqrt(2):n,a=Math.floor(o/i),s=Math.floor((r.width-i*a)/2),h=Math.floor((r.height-i*a)/2),u=new x({svg:this._element,type:r.dotsOptions.type,document:this._document});this._dotsClipPath=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),this._dotsClipPath.setAttribute("id","clip-path-dot-color"),this._defs.appendChild(this._dotsClipPath),this._createColor({options:r.dotsOptions?.gradient,color:r.dotsOptions.color,additionalRotation:0,x:0,y:0,height:r.height,width:r.width,name:"dot-color"});for(let t=0;t<i;t++)for(let r=0;r<i;r++)e&&!e(t,r)||this._qr?.isDark(t,r)&&(u.draw(s+t*a,h+r*a,a,((n,o)=>!(t+n<0||r+o<0||t+n>=i||r+o>=i)&&(!(e&&!e(t+n,r+o))&&(!!this._qr&&this._qr.isDark(t+n,r+o))))),u._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(u._element));if(r.shape===t.ShapeType.circle){const t=Math.floor((n/a-i)/2),e=i+2*t,r=s-t*a,o=h-t*a,d=[],c=Math.floor(e/2);for(let r=0;r<e;r++){d[r]=[];for(let n=0;n<e;n++)r>=t-1&&r<=e-t&&n>=t-1&&n<=e-t||Math.sqrt((r-c)*(r-c)+(n-c)*(n-c))>c?d[r][n]=0:d[r][n]=this._qr.isDark(n-2*t<0?n:n>=i?n-2*t:n-t,r-2*t<0?r:r>=i?r-2*t:r-t)?1:0}for(let t=0;t<e;t++)for(let i=0;i<e;i++)d[t][i]&&(u.draw(r+t*a,o+i*a,a,((e,r)=>!!d[t+e]?.[i+r])),u._element&&this._dotsClipPath&&this._dotsClipPath.appendChild(u._element))}}drawCorners(){if(!this._qr)throw"QR code is not defined";const e=this._element,r=this._options;if(!e)throw"Element code is not defined";const i=this._qr.getModuleCount(),n=Math.min(r.width,r.height),o=r.shape===t.ShapeType.circle?n/Math.sqrt(2):n,a=Math.floor(o/i),s=7*a,h=3*a,u=Math.floor((r.width-i*a)/2),d=Math.floor((r.height-i*a)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([t,e,n])=>{const o=u+t*a*(i-7),c=d+e*a*(i-7);let l=this._dotsClipPath,g=this._dotsClipPath;if((r.cornersSquareOptions?.gradient||r.cornersSquareOptions?.color)&&(l=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),l.setAttribute("id",`clip-path-corners-square-color-${t}-${e}`),this._defs.appendChild(l),this._cornersSquareClipPath=this._cornersDotClipPath=g=l,this._createColor({options:r.cornersSquareOptions?.gradient,color:r.cornersSquareOptions?.color,additionalRotation:n,x:o,y:c,height:s,width:s,name:`corners-square-color-${t}-${e}`})),r.cornersSquareOptions?.type){const t=new b({svg:this._element,type:r.cornersSquareOptions.type,document:this._document});t.draw(o,c,s,n),t._element&&l&&l.appendChild(t._element)}else{const t=new x({svg:this._element,type:r.dotsOptions.type,document:this._document});for(let e=0;e<C.length;e++)for(let r=0;r<C[e].length;r++)C[e]?.[r]&&(t.draw(o+e*a,c+r*a,a,((t,i)=>!!C[e+t]?.[r+i])),t._element&&l&&l.appendChild(t._element))}if((r.cornersDotOptions?.gradient||r.cornersDotOptions?.color)&&(g=this._document.createElementNS("http://www.w3.org/2000/svg","clipPath"),g.setAttribute("id",`clip-path-corners-dot-color-${t}-${e}`),this._defs.appendChild(g),this._cornersDotClipPath=g,this._createColor({options:r.cornersDotOptions?.gradient,color:r.cornersDotOptions?.color,additionalRotation:n,x:o+2*a,y:c+2*a,height:h,width:h,name:`corners-dot-color-${t}-${e}`})),r.cornersDotOptions?.type){const t=new v({svg:this._element,type:r.cornersDotOptions.type,document:this._document});t.draw(o+2*a,c+2*a,h,n),t._element&&g&&g.appendChild(t._element)}else{const t=new x({svg:this._element,type:r.dotsOptions.type,document:this._document});for(let e=0;e<M.length;e++)for(let r=0;r<M[e].length;r++)M[e]?.[r]&&(t.draw(o+e*a,c+r*a,a,((t,i)=>!!M[e+t]?.[r+i])),t._element&&g&&g.appendChild(t._element))}}))}async drawImage({width:t,height:e,count:r,dotSize:i}){const n=this._options,o=Math.floor((n.width-r*i)/2),a=Math.floor((n.height-r*i)/2),s=n.imageOptions.margin*i,h=o+s+(r*i-t)/2,u=a+s+(r*i-e)/2,d=t-2*s,c=e-2*s,l=await this._imageTools.toDataURL(n.image||"");let g=this._document.createElementNS("http://www.w3.org/2000/svg","image");if(g.setAttribute("href",l||""),l.startsWith("data:image/svg+xml;")){let t=l.substring(19);const e=t.indexOf(","),r=t.substring(0,e);if(t=t.substring(e+1),"base64"===r)t="function"==typeof atob?atob(t):Buffer.from(t,"base64").toString("utf8");else t="";if(t){const e=(new DOMParser).parseFromString(t,"text/xml"),r=Array.from(e.getElementsByTagName("svg"));r.length&&(g=r[0])}}g.setAttribute("x",String(h)),g.setAttribute("y",String(u)),g.setAttribute("width",`${d}px`),g.setAttribute("height",`${c}px`),this._element.appendChild(g)}_createColor({options:e,color:r,additionalRotation:i,x:n,y:o,height:a,width:s,name:h}){const u=s>a?s:a,d=this._document.createElementNS("http://www.w3.org/2000/svg","rect");if(d.setAttribute("x",String(n)),d.setAttribute("y",String(o)),d.setAttribute("height",String(a)),d.setAttribute("width",String(s)),d.setAttribute("clip-path",`url('#clip-path-${h}')`),e){let r;if(e.type===t.GradientType.radial)r=this._document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),r.setAttribute("id",h),r.setAttribute("gradientUnits","userSpaceOnUse"),r.setAttribute("fx",String(n+s/2)),r.setAttribute("fy",String(o+a/2)),r.setAttribute("cx",String(n+s/2)),r.setAttribute("cy",String(o+a/2)),r.setAttribute("r",String(u/2));else{const t=((e.rotation||0)+i)%(2*Math.PI),u=(t+2*Math.PI)%(2*Math.PI);let d=n+s/2,c=o+a/2,l=n+s/2,g=o+a/2;u>=0&&u<=.25*Math.PI||u>1.75*Math.PI&&u<=2*Math.PI?(d-=s/2,c-=a/2*Math.tan(t),l+=s/2,g+=a/2*Math.tan(t)):u>.25*Math.PI&&u<=.75*Math.PI?(c-=a/2,d-=s/2/Math.tan(t),g+=a/2,l+=s/2/Math.tan(t)):u>.75*Math.PI&&u<=1.25*Math.PI?(d+=s/2,c+=a/2*Math.tan(t),l-=s/2,g-=a/2*Math.tan(t)):u>1.25*Math.PI&&u<=1.75*Math.PI&&(c+=a/2,d+=s/2/Math.tan(t),g-=a/2,l-=s/2/Math.tan(t)),r=this._document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),r.setAttribute("id",h),r.setAttribute("gradientUnits","userSpaceOnUse"),r.setAttribute("x1",String(Math.round(d))),r.setAttribute("y1",String(Math.round(c))),r.setAttribute("x2",String(Math.round(l))),r.setAttribute("y2",String(Math.round(g)))}e.colorStops.forEach((({offset:t,color:e})=>{const i=this._document.createElementNS("http://www.w3.org/2000/svg","stop");i.setAttribute("offset",100*t+"%"),i.setAttribute("stop-color",e),r.appendChild(i)})),d.setAttribute("fill",`url('#${h}')`),this._defs.appendChild(r)}else r&&d.setAttribute("fill",r);this._element.appendChild(d)}}class D{constructor(t){this._options=t?m(p(_,t)):_,this.update()}static _clearContainer(t){t&&(t.innerHTML="")}_setupSvg(){if(!this._qr)return;this._options.width=this._options.height=10*this._qr.getModuleCount();const t=new A(this._options);this._svg=t.getElement(),this._svgDrawingPromise=t.drawQR(this._qr).then((()=>{this._svg&&this._extension?.(t.getElement(),this._options)}))}async _getElement(){if(!this._qr)throw"QR code is empty";return this._svg&&this._svgDrawingPromise||this._setupSvg(),await this._svgDrawingPromise,this._svg}update(e){D._clearContainer(this._container),this._options=e?m(p(this._options,e)):this._options,this._options.data&&(this._qr=g(this._options.qrOptions.typeNumber,this._options.qrOptions.errorCorrectionLevel),this._qr.addData(this._options.data,this._options.qrOptions.mode||function(e){switch(!0){case/^[0-9]*$/.test(e):return t.Mode.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(e):return t.Mode.alphanumeric;default:return t.Mode.byte}}(this._options.data)),this._qr.make(),this._setupSvg(),this.append(this._container))}append(t){if(t){if("function"!=typeof t.appendChild)throw"Container should be a single DOM node";this._svg&&t.appendChild(this._svg),this._container=t}}applyExtension(t){if(!t)throw"Extension function should be defined.";this._extension=t,this.update()}deleteExtension(){this._extension=void 0,this.update()}async serialize(){if(!this._qr)throw"QR code is empty";const t=await this._getElement();if(!t)return;let e=(new XMLSerializer).serializeToString(t);return e='<?xml version="1.0" standalone="no"?>\r\n'+e,e}}function $(t,e){if(!t._qr)return;const{width:r,height:i,margin:n}=e?function(t){const e={...t};return e.width=Number(e.width),e.height=Number(e.height),e.margin=Number(e.margin),e.margin>Math.min(e.width,e.height)&&(e.margin=Math.min(e.width,e.height)),e}(p(y,e)):y,o=document.createElement("canvas");o.width=r,o.height=i;const a=Math.min(r,i)-2*n;t._setupSvg();const s=t._svgDrawingPromise?.then((async()=>{if(!t._svg)return;const e=await t.serialize();if(!e)return;const n="data:image/svg+xml;base64,"+btoa(e),s=new Image;return new Promise(((t,e)=>{s.onload=()=>{o?.getContext("2d")?.drawImage(s,(r-a)/2,(i-a)/2,a,a),t()},s.onerror=s.onabort=e,s.src=n}))}));return{canvas:o,canvasDrawingPromise:s}}function k(t,e){const r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}var q={QRCodeStyling:D,browserUtils:Object.freeze({__proto__:null,download:async function(e,r,i){if(!e._qr)throw"QR code is empty";let n=t.FileExtension.png,o="qr";if("string"==typeof r?(n=r,console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")):"object"==typeof r&&null!==r&&(r.name&&(o=r.name),r.extension&&(n=r.extension)),"svg"===n.toLowerCase()){let t=await e.serialize();t='<?xml version="1.0" standalone="no"?>\r\n'+t;k("data:image/svg+xml;charset=utf-8,"+encodeURIComponent(t),`${o}.svg`)}else{const t=$(e,i);if(!t)return;const{canvas:r,canvasDrawingPromise:a}=t;await a;k(r.toDataURL(`image/${n}`),`${o}.${n}`)}},downloadURI:k,drawToCanvas:$})};t.ErrorCorrectionPercents=d,t.QRCodeStyling=D,t.TypeNumber=a,t.default=q,Object.defineProperty(t,"__esModule",{value:!0})}));
2
+ //# sourceMappingURL=qr-code-styling.js.map