@liquid-js/qr-code-styling 3.0.0-2 → 3.0.0-3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- var t,e,r,i,n;!function(t){t.dots="dots",t.randomDots="random-dots",t.rounded="rounded",t.verticalLines="vertical-lines",t.horizontalLines="horizontal-lines",t.classy="classy",t.classyRounded="classy-rounded",t.square="square",t.smallSquare="small-square",t.extraRounded="extra-rounded",t.diamond="diamond"}(t||(t={})),function(t){t.dot="dot",t.square="square",t.heart="heart",t.extraRounded="extra-rounded",t.classy="classy",t.outpoint="outpoint",t.inpoint="inpoint"}(e||(e={})),function(t){t.dot="dot",t.square="square",t.extraRounded="extra-rounded",t.classy="classy",t.outpoint="outpoint",t.inpoint="inpoint"}(r||(r={})),function(t){t.radial="radial",t.linear="linear"}(i||(i={})),function(t){t.square="square",t.circle="circle"}(n||(n={}));const o=Array(41).fill(0).map(((t,e)=>e));var s,a,h;!function(t){t.L="L",t.M="M",t.Q="Q",t.H="H"}(s||(s={})),function(t){t.numeric="Numeric",t.alphanumeric="Alphanumeric",t.byte="Byte",t.kanji="Kanji",t.unicode="Unicode"}(a||(a={})),function(t){t.svg="svg",t.png="png",t.jpeg="jpeg",t.webp="webp"}(h||(h={}));const u={[s.L]:.07,[s.M]:.15,[s.Q]:.25,[s.H]:.3};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var d={exports:{}};!function(t,e){var r=function(){var t=function(t,e){var r=t,i=c[e],n=null,o=0,s=null,a=[],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),d(0,0),d(o-7,0),d(0,o-7),g(),l(),p(t,e),r>=7&&f(t),null==s&&(s=_(r,i,a)),w(s,e)},d=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],s=t[i];if(null==n[o][s])for(var a=-2;a<=2;a+=1)for(var h=-2;h<=2;h+=1)n[o+a][s+h]=-2==a||2==a||-2==h||2==h||0==a&&0==h}},f=function(t){for(var e=y.getBCHTypeNumber(r),i=0;i<18;i+=1){var s=!t&&1==(e>>i&1);n[Math.floor(i/3)][i%3+o-8-3]=s}for(i=0;i<18;i+=1){s=!t&&1==(e>>i&1);n[i%3+o-8-3][Math.floor(i/3)]=s}},p=function(t,e){for(var r=i<<3|e,s=y.getBCHTypeInfo(r),a=0;a<15;a+=1){var h=!t&&1==(s>>a&1);a<6?n[a][8]=h:a<8?n[a+1][8]=h:n[o-15+a][8]=h}for(a=0;a<15;a+=1){h=!t&&1==(s>>a&1);a<8?n[8][o-a-1]=h:a<9?n[8][15-a-1+1]=h:n[8][15-a-1]=h}n[o-8][8]=!t},w=function(t,e){for(var r=-1,i=o-1,s=7,a=0,h=y.getMaskFunction(e),u=o-1;u>0;u-=2)for(6==u&&(u-=1);;){for(var c=0;c<2;c+=1)if(null==n[i][u-c]){var d=!1;a<t.length&&(d=1==(t[a]>>>s&1)),h(i,u-c)&&(d=!d),n[i][u-c]=d,-1==(s-=1)&&(a+=1,s=7)}if((i+=r)<0||o<=i){i-=r,r=-r;break}}},_=function(t,e,r){for(var i=x.getRSBlocks(t,e),n=M(),o=0;o<r.length;o+=1){var s=r[o];n.put(s.getMode(),4),n.put(s.getLength(),y.getLengthInBits(s.getMode(),t)),s.write(n)}var a=0;for(o=0;o<i.length;o+=1)a+=i[o].dataCount;if(n.getLengthInBits()>8*a)throw"code length overflow. ("+n.getLengthInBits()+">"+8*a+")";for(n.getLengthInBits()+4<=8*a&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*a||(n.put(236,8),n.getLengthInBits()>=8*a));)n.put(17,8);return function(t,e){for(var r=0,i=0,n=0,o=new Array(e.length),s=new Array(e.length),a=0;a<e.length;a+=1){var h=e[a].dataCount,u=e[a].totalCount-h;i=Math.max(i,h),n=Math.max(n,u),o[a]=new Array(h);for(var c=0;c<o[a].length;c+=1)o[a][c]=255&t.getBuffer()[c+r];r+=h;var d=y.getErrorCorrectPolynomial(u),l=v(o[a],d.getLength()-1).mod(d);for(s[a]=new Array(d.getLength()-1),c=0;c<s[a].length;c+=1){var g=c+l.getLength()-s[a].length;s[a][c]=g>=0?l.getAt(g):0}}var f=0;for(c=0;c<e.length;c+=1)f+=e[c].totalCount;var p=new Array(f),w=0;for(c=0;c<i;c+=1)for(a=0;a<e.length;a+=1)c<o[a].length&&(p[w]=o[a][c],w+=1);for(c=0;c<n;c+=1)for(a=0;a<e.length;a+=1)c<s[a].length&&(p[w]=s[a][c],w+=1);return p}(n,i)};h.addData=function(t,e){var r=null;switch(e=e||"Byte"){case"Numeric":r=$(t);break;case"Alphanumeric":r=S(t);break;case"Byte":r=A(t);break;case"Kanji":r=k(t);break;default:throw"mode:"+e}a.push(r),s=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=M(),o=0;o<a.length;o++){var s=a[o];n.put(s.getMode(),4),n.put(s.getLength(),y.getLengthInBits(s.getMode(),t)),s.write(n)}var c=0;for(o=0;o<e.length;o++)c+=e[o].dataCount;if(n.getLengthInBits()<=8*c)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,s,a,u,c=h.getModuleCount()*t+2*e,d="";for(u="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",d+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',d+=n.scalable?"":' width="'+c+'px" height="'+c+'px"',d+=' viewBox="0 0 '+c+" "+c+'" ',d+=' preserveAspectRatio="xMinYMin meet"',d+=i.text||r.text?' role="img" aria-labelledby="'+m([i.id,r.id].join(" ").trim())+'"':"",d+=">",d+=i.text?'<title id="'+m(i.id)+'">'+m(i.text)+"</title>":"",d+=r.text?'<description id="'+m(r.id)+'">'+m(r.text)+"</description>":"",d+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',d+='<path d="',s=0;s<h.getModuleCount();s+=1)for(a=s*t+e,o=0;o<h.getModuleCount();o+=1)h.isDark(s,o)&&(d+="M"+(o*t+e)+","+a+u);return d+='" stroke="transparent" fill="black"/>',d+="</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 D(r,r,(function(e,r){if(i<=e&&e<n&&i<=r&&r<n){var o=Math.floor((e-i)/t),s=Math.floor((r-i)/t);return h.isDark(s,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+=m(r),n+='"'),n+="/>"};var m=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,s=1*h.getModuleCount()+2*t,a=t,u=s-t,c={"██":"█","█ ":"▀"," █":"▄"," ":" "},d={"██":"▀","█ ":"▀"," █":" "," ":" "},l="";for(e=0;e<s;e+=2){for(i=Math.floor((e-a)/1),n=Math.floor((e+1-a)/1),r=0;r<s;r+=1)o="█",a<=r&&r<u&&a<=e&&e<u&&h.isDark(i,Math.floor((r-a)/1))&&(o=" "),a<=r&&r<u&&a<=e+1&&e+1<u&&h.isDark(n,Math.floor((r-a)/1))?o+=" ":o+="█",l+=t<1&&e+1>=u?d[o]:c[o];l+="\n"}return s%2&&t>0?l.substring(0,l.length-s-1)+Array(s+1).join("▀"):l.substring(0,l.length-1)}(e);t-=1,e=void 0===e?2*t:e;var r,i,n,o,s=h.getModuleCount()*t+2*e,a=e,u=s-e,c=Array(t+1).join("██"),d=Array(t+1).join(" "),l="",g="";for(r=0;r<s;r+=1){for(n=Math.floor((r-a)/t),g="",i=0;i<s;i+=1)o=1,a<=i&&i<u&&a<=r&&r<u&&h.isDark(n,Math.floor((i-a)/t))&&(o=0),g+=o?c:d;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=C(t),i=function(){var t=r.read();if(-1==t)throw"eof";return t},n=0,o={};;){var s=r.read();if(-1==s)break;var a=i(),h=i()<<8|i();o[String.fromCharCode(s<<8|a)]=h,n+=1}if(n!=e)throw n+" != "+e;return o}(),i="?".charCodeAt(0);return console.log(JSON.stringify(r),i),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 s=r[t.charAt(n)];"number"==typeof s?(255&s)==s?e.push(s):(e.push(s>>>8),e.push(255&s)):e.push(i)}}return e}};var e,r,i,n,o,s=1,a=2,h=4,u=8,c={L:1,M:0,Q:3,H:2},d=0,l=1,g=2,f=3,p=4,w=5,_=6,m=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 d: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 _:return function(t,e){return(t*e%2+t*e%3)%2==0};case m: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=v([1],0),r=0;r<t;r+=1)e=e.multiply(v([1,b.gexp(r)],0));return e},n.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case s:return 10;case a:return 9;case h:case u:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case s:return 12;case a:return 11;case h:return 16;case u:return 10;default:throw"mode:"+t}else{if(!(e<41))throw"type:"+e;switch(t){case s:return 14;case a: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,s=t.isDark(i,n),a=-1;a<=1;a+=1)if(!(i+a<0||e<=i+a))for(var h=-1;h<=1;h+=1)n+h<0||e<=n+h||0==a&&0==h||s==t.isDark(i+a,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),b=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 v(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]^=b.gexp(b.glog(i.getAt(r))+b.glog(t.getAt(n)));return v(e,0)},mod:function(t){if(i.getLength()-t.getLength()<0)return i;for(var e=b.glog(i.getAt(0))-b.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]^=b.gexp(b.glog(t.getAt(n))+e);return v(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 c.L:return t[4*(e-1)+0];case c.M:return t[4*(e-1)+1];case c.Q:return t[4*(e-1)+2];case c.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=[],a=0;a<o;a+=1)for(var h=n[3*a+0],u=n[3*a+1],d=n[3*a+2],l=0;l<h;l+=1)s.push(e(u,d));return s},r}(),M=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},$=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+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},S=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+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},k=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},z=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},C=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|s(t.charCodeAt(0)),n+=6)}var o=i>>>n-8&255;return n-=8,o}},s=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},D=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=s(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(";")}},s=function(t){for(var e=1<<t,r=1+(1<<t),i=t+1,o=a(),s=0;s<e;s+=1)o.add(String.fromCharCode(s));o.add(String.fromCharCode(e)),o.add(String.fromCharCode(r));var h,u,c,d=z(),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()},a=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 s=z();i.write(s);for(var a=function(){var t=0,e=0,r=0,i="",n={},o=function(t){i+=String.fromCharCode(s(63&t))},s=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,s=0;s<n;s+=1)i+="="},n.toString=function(){return i},n}(),h=s.toByteArray(),u=0;u<h.length;u+=1)a.writeByte(h[u]);return a.flush(),"data:image/gif;base64,"+a};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}(d);var l=c(d.exports);const g=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function f(t,...e){if(!e.length)return t;const r=e.shift();return void 0!==r&&g(t)&&g(r)?(t={...t},Object.keys(r).forEach((e=>{const i=t[e],n=r[e];Array.isArray(i)&&Array.isArray(n)?t[e]=n:g(i)&&g(n)?t[e]=f(Object.assign({},i),n):t[e]=n})),f(t,...e)):t}function p(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 w(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=p(e.dotsOptions.gradient)),e.dotsOptions.size=Math.round(Math.max(0,e.dotsOptions.size)||10),e.cornersSquareOptions&&(e.cornersSquareOptions={...e.cornersSquareOptions},e.cornersSquareOptions.gradient&&(e.cornersSquareOptions.gradient=p(e.cornersSquareOptions.gradient))),e.cornersDotOptions&&(e.cornersDotOptions={...e.cornersDotOptions},e.cornersDotOptions.gradient&&(e.cornersDotOptions.gradient=p(e.cornersDotOptions.gradient))),e.backgroundOptions&&(e.backgroundOptions={...e.backgroundOptions},e.backgroundOptions.gradient&&(e.backgroundOptions.gradient=p(e.backgroundOptions.gradient))),e.document||(e.document=document),e}const _={document:void 0,shape:n.square,width:void 0,height:void 0,data:"",qrOptions:{typeNumber:o[0],mode:void 0,errorCorrectionLevel:s.Q},imageOptions:{hideBackgroundDots:!0,imageSize:.4,crossOrigin:void 0,margin:0},dotsOptions:{type:t.square,color:"#000",size:10}},m={width:300,height:300,margin:0};class y{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.square:o=this._drawSquare;break;case e.heart:o=this._drawHeart;break;case e.extraRounded:o=this._drawRounded;break;case e.classy:o=this._drawClassy;break;case e.inpoint:o=this._drawInpoint;break;case e.outpoint:o=this._drawOutpoint;break;case e.dot:default:o=this._drawDot}o.call(this,{x:t,y:r,size:i,rotation:n})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,s=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${s})`)}_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))}})}_basicHeart(t){const{size:e,x:r,y:i}=t;this._element=this._document.createElementNS("http://www.w3.org/2000/svg","path");let n=!1,o=0;this._element.setAttribute("d",["M",.925,.3538125,"c",0,.0325869,-.0054931,.0644619,-.0164688,.095625,"S",.87825,.5147812,.850625,.5519688,"C",.823,.5891563,.7858125,.631125,.7390625,.677875,"S",.6331632,.7802256,.561625,.8446875,"L",.5,.8999375,"l",-.061625,-.05525,"C",.3668368,.7802256,.3076875,.724625,.2609375,.677875,"S",.177,.5891563,.149375,.5519688,"S",.1024444,.4806007,.0914688,.4494375,"S",.075,.3863994,.075,.3538125,"C",.075,.2872256,.0973125,.231625,.1419375,.187,"S",.2421631,.1200625,.30875,.1200625,"c",.0368369,0,.0718994,.0077881,.1051875,.023375,"S",.4759131,.1809756,.5,.2093125,"c",.0240868,-.0283369,.0527744,-.0502881,.0860625,-.065875,"c",.0332882,-.0155869,.0683507,-.023375,.1051875,-.023375,"c",.0665869,0,.1221875,.0223125,.1668125,.0669375,"S",.925,.2872256,.925,.3538125,"z"].map((t=>"string"==typeof t?(o=0,n=t.toUpperCase()==t,t):(o++,t*=e,n&&(t+=o%2==1?r:i),t.toFixed(5)))).join(" "))}_basicRounded(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)),this._element.setAttribute("rx",String(e/4)),this._element.setAttribute("ry",String(e/4))}})}_basicClassy(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 `+4.5*n+"v "+-4.5*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*-n}h `+-2*n+`H ${r}z`)}})}_basicInpoint(t){const{size:e,x:r,y:i}=t,n=e;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+n/2}v `+n/4+`a ${n/4}, ${n/4} 0 0 0 ${n/4}, ${n/4}h `+n/4*3+"v "+-n/4*3+`a ${n/4}, ${n/4} 0 0 0 ${-n/4}, ${-n/4}h `+-n/2+`a ${n/4}, ${n/4} 0 0 0 ${-n/4}, ${n/4}z`)}})}_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})}_drawHeart({x:t,y:e,size:r,rotation:i}){this._basicHeart({x:t-.2*r/2,y:e-.2*r/2,size:1.2*r,rotation:i})}_drawRounded({x:t,y:e,size:r,rotation:i}){this._basicRounded({x:t,y:e,size:r,rotation:i})}_drawClassy({x:t,y:e,size:r,rotation:i}){this._basicClassy({x:t,y:e,size:r,rotation:i})}_drawInpoint({x:t,y:e,size:r,rotation:i}){this._basicInpoint({x:t,y:e,size:r,rotation:i})}_drawOutpoint({x:t,y:e,size:r,rotation:i}){this._basicInpoint({x:t,y:e,size:r,rotation:(i||0)+Math.PI})}}class b{constructor({svg:t,type:e,document:r}){this._svg=t,this._type=e,this._document=r}draw(t,e,i,n){let o;switch(this._type){case r.square:o=this._drawSquare;break;case r.extraRounded:o=this._drawExtraRounded;break;case r.classy:o=this._drawClassy;break;case r.outpoint:o=this._drawOutpoint;break;case r.inpoint:o=this._drawInpoint;break;case r.dot:default:o=this._drawDot}o.call(this,{x:t,y:e,size:i,rotation:n})}_rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,s=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${s})`)}_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}z`+`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}z`)}})}_basicClassy(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 `+4.5*n+"v "+-4.5*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*-n}h `+-2*n+`H ${r}z`+`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 `+3.5*n+"h "+-3.5*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*-n} ${1.5*-n}v `+-3.5*n+"z")}})}_basicInpoint(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 `+4.5*n+"v "+-4.5*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}z`+`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 `+3.5*n+"h "+-3.5*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}z`)}})}_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})}_drawClassy({x:t,y:e,size:r,rotation:i}){this._basicClassy({x:t,y:e,size:r,rotation:i})}_drawInpoint({x:t,y:e,size:r,rotation:i}){this._basicInpoint({x:t,y:e,size:r,rotation:i})}_drawOutpoint({x:t,y:e,size:r,rotation:i}){this._basicInpoint({x:t,y:e,size:r,rotation:(i||0)+Math.PI})}}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.dots:o=this._drawDot;break;case t.randomDots:o=this._drawRandomDot;break;case t.classy:o=this._drawClassy;break;case t.classyRounded:o=this._drawClassyRounded;break;case t.rounded:o=this._drawRounded;break;case t.verticalLines:o=this._drawVerticalLines;break;case t.horizontalLines:o=this._drawHorizontalLines;break;case t.extraRounded:o=this._drawExtraRounded;break;case t.diamond:o=this._drawDiamond;break;case t.smallSquare:o=this._drawSmallSquare;break;case t.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,s=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${s})`)}_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})}_drawRandomDot({x:t,y:e,size:r}){const i=.25*Math.random()+.75;this._basicDot({x:t,y:e,size:r*i,rotation:0})}_drawSquare({x:t,y:e,size:r}){this._basicSquare({x:t,y:e,size:r,rotation:0})}_drawSmallSquare({x:t,y:e,size:r}){const i=r;r=.7*i,t+=.15*i,e+=.15*i,this._basicSquare({x:t,y:e,size:r,rotation:0})}_drawDiamond({x:t,y:e,size:r}){this._basicSquare({x:t,y:e,size:r,rotation:Math.PI/4})}_drawRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0,h=n+o+s+a;if(0!==h)if(h>2||n&&o||s&&a)this._basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&s?i=Math.PI/2:s&&o?i=Math.PI:o&&a&&(i=-Math.PI/2),void this._basicCornerRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return s?i=Math.PI/2:o?i=Math.PI:a&&(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})}_drawVerticalLines({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0;if(0===n+o+s+a||n&&!s&&!a||o&&!s&&!a)this._basicDot({x:t,y:e,size:r,rotation:0});else if(s&&a)this._basicSquare({x:t,y:e,size:r,rotation:0});else if(!s||a)if(!a||s);else{const i=-Math.PI/2;this._basicSideRounded({x:t,y:e,size:r,rotation:i})}else{const i=Math.PI/2;this._basicSideRounded({x:t,y:e,size:r,rotation:i})}}_drawHorizontalLines({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0;if(0===n+o+s+a||s&&!n&&!o||a&&!n&&!o)this._basicDot({x:t,y:e,size:r,rotation:0});else if(n&&o)this._basicSquare({x:t,y:e,size:r,rotation:0});else if(!n||o)if(!o||n);else{const i=Math.PI;this._basicSideRounded({x:t,y:e,size:r,rotation:i})}else{const i=0;this._basicSideRounded({x:t,y:e,size:r,rotation:i})}}_drawExtraRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0,h=n+o+s+a;if(0!==h)if(h>2||n&&o||s&&a)this._basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&s?i=Math.PI/2:s&&o?i=Math.PI:o&&a&&(i=-Math.PI/2),void this._basicCornerExtraRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return s?i=Math.PI/2:o?i=Math.PI:a&&(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,s=i?+i(0,-1):0,a=i?+i(0,1):0;0!==n+o+s+a?n||s?o||a?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,s=i?+i(0,-1):0,a=i?+i(0,1):0;0!==n+o+s+a?n||s?o||a?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 x={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:x.toDataURL(t.image).then((t=>i.src=t)).catch(r)}))};const M=[[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]],S=[[35,49],[28,36],[21,25],[14,16],[7,9],[2,4],[1,1]];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||x,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=parseInt(((e-17)/4).toFixed(0),10),i=this._options.dotsOptions.size;let n={hideXDots:0,hideYDots:0,width:0,height:0};if(this._qr=t,this._options.image){const t=await this._imageTools.getSize(this._options),{imageOptions:o,qrOptions:s}=this._options,a=o.imageSize*u[s.errorCorrectionLevel],h=S.find((t=>t[0]<=r))||[0,0],c=Math.floor(a*(e*e-192-2*(e-16)-25*h[1]));n=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:n,margin:o}){const s={x:0,y:0},a={x:0,y:0};if(t<=0||e<=0||r<=0||n<=0||4*o**2>r)return{height:0,width:0,hideYDots:0,hideXDots:0};i&&i%2==0&&(i=Math.max(1,i-1));const h=Math.max(e,t),u=Math.min(e,t);let c=0,d=(i||r)-2*o;do{const t=c+(d-c)/2;let e=Math.max(1,Math.ceil(t+2*o));e%2==0&&e++;let i=Math.max(1,Math.ceil(t*u/h+2*o));i%2==0&&i++,e*i>r?d=t:c=t}while(Math.abs(c-d)>.001);const l=c;let g=Math.max(1,Math.ceil(l+2*o));g%2==0&&g++;let f=Math.max(1,Math.ceil(l*u/h+2*o));f%2==0&&f++,e>t?(s.x=g,s.y=f):(s.x=f,s.y=g);const p=(s.x-2*o)*n,w=(s.y-2*o)*n;return a.x=p,a.y=p*t/e,a.y>w&&(a.y=w,a.x=w*e/t),{height:Math.round(a.y+2*o*n),width:Math.round(a.x+2*o*n),hideYDots:s.y,hideXDots:s.x}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:c,maxHiddenAxisDots:e-14,dotSize:i,margin:o.margin})}this.drawBackground(),this.drawDots(((t,r)=>!(this._options.imageOptions.hideBackgroundDots&&t>=(e-n.hideXDots)/2&&t<(e+n.hideXDots)/2&&r>=(e-n.hideYDots)/2&&r<(e+n.hideYDots)/2)&&(!(M[t]?.[r]||M[t-e+7]?.[r]||M[t]?.[r-e+7])&&!($[t]?.[r]||$[t-e+7]?.[r]||$[t]?.[r-e+7])))),this.drawCorners(),this._options.image&&n.width>0&&n.height>0&&await this.drawImage({width:n.width,height:n.height,count:e,dotSize:i})}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._backgroundMask,this._backgroundMaskGroup]=this._createMask("mask-background-color"),this._defs.appendChild(this._backgroundMask),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._backgroundMaskGroup.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),o=this._options.dotsOptions.size,s=Math.floor((e.width-r*o)/2),a=Math.floor((e.height-r*o)/2),h=new v({svg:this._element,type:e.dotsOptions.type,document:this._document});[this._dotsMask,this._dotsMaskGroup]=this._createMask("mask-dot-color"),this._defs.appendChild(this._dotsMask);for(let e=0;e<r;e++)for(let i=0;i<r;i++)t&&!t(e,i)||this._qr?.isDark(i,e)&&(h.draw(s+e*o,a+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(i+o,e+n))))),h._element&&this._dotsMask&&this._dotsMaskGroup.appendChild(h._element));let u=s,c=a,d=r;if(e.shape===n.circle){const t=this._options.backgroundOptions&&this._options.backgroundOptions.margin||0,e=Math.floor((i/o-r-2*t)/2),n=r+2*e,l=s-e*o,g=a-e*o;u=l,c=g,d=r+2*e;const f=[],p=Math.floor(n/2);for(let t=0;t<n;t++){f[t]=[];for(let i=0;i<n;i++)t>=e-1&&t<=n-e&&i>=e-1&&i<=n-e||Math.sqrt((t-p)*(t-p)+(i-p)*(i-p))>p?f[t][i]=0:f[t][i]=this._qr.isDark(i-2*e<0?i:i>=r?i-2*e:i-e,t-2*e<0?t:t>=r?t-2*e:t-e)?1:0}for(let t=0;t<n;t++)for(let e=0;e<n;e++)f[t][e]&&(h.draw(l+t*o,g+e*o,o,((r,i)=>!!f[t+r]?.[e+i])),h._element&&this._dotsMask&&this._dotsMaskGroup.appendChild(h._element))}this._createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:u,y:c,height:d*o,width:d*o,name:"dot-color"})}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=this._options.dotsOptions.size,n=7*i,o=3*i,s=Math.floor((e.width-r*i)/2),a=Math.floor((e.height-r*i)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([t,h,u])=>{const c=s+t*i*(r-7),d=a+h*i*(r-7);let l=this._dotsMask,g=this._dotsMaskGroup,f=this._dotsMask,p=this._dotsMaskGroup;if((e.cornersSquareOptions?.gradient||e.cornersSquareOptions?.color)&&([l,g]=this._createMask(`mask-corners-square-color-${t}-${h}`),this._defs.appendChild(l),this._cornersSquareMask=this._cornersDotMask=f=l,this._cornersSquareMaskGroup=this._cornersDotMaskGroup=p=g,this._createColor({options:e.cornersSquareOptions?.gradient,color:e.cornersSquareOptions?.color,additionalRotation:u,x:c,y:d,height:n,width:n,name:`corners-square-color-${t}-${h}`})),e.cornersSquareOptions?.type){const t=new b({svg:this._element,type:e.cornersSquareOptions.type,document:this._document});t.draw(c,d,n,u),t._element&&g&&g.appendChild(t._element)}else{const t=new v({svg:this._element,type:e.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(c+e*i,d+r*i,i,((t,i)=>!!M[e+t]?.[r+i])),t._element&&g&&g.appendChild(t._element))}if((e.cornersDotOptions?.gradient||e.cornersDotOptions?.color)&&([f,p]=this._createMask(`mask-corners-dot-color-${t}-${h}`),this._defs.appendChild(f),this._cornersDotMask=f,this._cornersDotMaskGroup=p,this._createColor({options:e.cornersDotOptions?.gradient,color:e.cornersDotOptions?.color,additionalRotation:u,x:c+2*i,y:d+2*i,height:o,width:o,name:`corners-dot-color-${t}-${h}`})),e.cornersDotOptions?.type){const t=new y({svg:this._element,type:e.cornersDotOptions.type,document:this._document});t.draw(c+2*i,d+2*i,o,u),t._element&&p&&p.appendChild(t._element)}else{const t=new v({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(c+e*i,d+r*i,i,((t,i)=>!!$[e+t]?.[r+i])),t._element&&p&&p.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),s=Math.floor((n.height-r*i)/2),a=n.imageOptions.margin*i,h=o+a+(r*i-t)/2,u=s+a+(r*i-e)/2,c=t-2*a,d=e-2*a,l=await this._imageTools.toDataURL(n.image||"");let g=this._document.createElementNS("http://www.w3.org/2000/svg","image");if(g.setAttributeNS("http://www.w3.org/1999/xlink","xlink: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",`${c}px`),g.setAttribute("height",`${d}px`),this._element.appendChild(g)}_createColor({options:t,color:e,additionalRotation:r,x:n,y:o,height:s,width:a,name:h}){const u=a>s?a:s,c=this._document.createElementNS("http://www.w3.org/2000/svg","rect");if(c.setAttribute("x",String(n)),c.setAttribute("y",String(o)),c.setAttribute("height",String(s)),c.setAttribute("width",String(a)),c.setAttribute("style",`mask:url(#mask-${h})`),t){let e;if(t.type===i.radial)e=this._document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),e.setAttribute("id",h),e.setAttribute("gradientUnits","userSpaceOnUse"),e.setAttribute("fx",String(n+a/2)),e.setAttribute("fy",String(o+s/2)),e.setAttribute("cx",String(n+a/2)),e.setAttribute("cy",String(o+s/2)),e.setAttribute("r",String(u/2));else{const i=((t.rotation||0)+r)%(2*Math.PI),u=(i+2*Math.PI)%(2*Math.PI);let c=n+a/2,d=o+s/2,l=n+a/2,g=o+s/2;u>=0&&u<=.25*Math.PI||u>1.75*Math.PI&&u<=2*Math.PI?(c-=a/2,d-=s/2*Math.tan(i),l+=a/2,g+=s/2*Math.tan(i)):u>.25*Math.PI&&u<=.75*Math.PI?(d-=s/2,c-=a/2/Math.tan(i),g+=s/2,l+=a/2/Math.tan(i)):u>.75*Math.PI&&u<=1.25*Math.PI?(c+=a/2,d+=s/2*Math.tan(i),l-=a/2,g-=s/2*Math.tan(i)):u>1.25*Math.PI&&u<=1.75*Math.PI&&(d+=s/2,c+=a/2/Math.tan(i),g-=s/2,l-=a/2/Math.tan(i)),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)}_createMask(t){const e=this._options,r=this._document.createElementNS("http://www.w3.org/2000/svg","mask");r.setAttribute("id",t),r.setAttribute("maskUnits","userSpaceOnUse"),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("width",String(e.width)),r.setAttribute("height",String(e.height));const i=this._document.createElementNS("http://www.w3.org/2000/svg","g");return i.setAttribute("fill","#fff"),r.appendChild(i),[r,i]}}class k{constructor(t){this._options=t?w(f(_,t)):_,this.update()}static _clearContainer(t){t&&(t.innerHTML="")}_setupSvg(){if(!this._qr)return;const t=Math.ceil((this._options.shape==n.circle?Math.sqrt(2):1)*this._qr.getModuleCount()),e=this._options.backgroundOptions&&this._options.backgroundOptions.margin||0,r=Math.ceil(this._options.dotsOptions.size*(t+2*e)),i=new A({...this._options,width:r,height:r});this._svg=i.getElement(),this._svgDrawingPromise=i.drawQR(this._qr).then((()=>{this._svg&&this._extension?.(i.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){if(k._clearContainer(this._container),this._options=t?w(f(this._options,t)):this._options,!this._options.data)return;this._options.stringToBytesFuncs&&(Object.assign(l.stringToBytesFuncs,this._options.stringToBytesFuncs),delete this._options.stringToBytesFuncs),this._qr=l(this._options.qrOptions.typeNumber,this._options.qrOptions.errorCorrectionLevel);let e=this._options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return a.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return a.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return a.unicode;default:return a.byte}}(this._options.data);e==a.unicode?(l.stringToBytes=l.stringToBytesFuncs["UTF-8"],e=a.byte):l.stringToBytes=l.stringToBytesFuncs.default,this._qr.addData(this._options.data,e),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 z(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}(f(m,e)):m,o=document.createElement("canvas");o.width=r,o.height=i;const s=Math.min(r,i)-2*n;t._setupSvg();const a=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),a=new Image;return new Promise(((t,e)=>{a.onload=()=>{const e=Math.ceil(2*s/Math.min(a.width,a.height));let n;try{n=new OffscreenCanvas(a.width*e,a.height*e)}catch(t){n=document.createElement("canvas"),n.width=a.width*e,n.height=a.height*e}n.getContext("2d")?.drawImage(a,0,0,n.width,n.height),o?.getContext("2d")?.drawImage(n,(r-s)/2,(i-s)/2,s,s),t()},a.onerror=a.onabort=e,a.src=n}))}));return{canvas:o,canvasDrawingPromise:a}}function C(t,e){const r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}const D=Object.freeze({__proto__:null,download:async function(t,e,r){if(!t._qr)throw"QR code is empty";let i=h.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;C("data:image/svg+xml;charset=utf-8,"+encodeURIComponent(e),`${n}.svg`)}else{const e=z(t,r);if(!e)return;const{canvas:o,canvasDrawingPromise:s}=e;await s;C(o.toDataURL(`image/${i}`),`${n}.${i}`)}},downloadURI:C,drawToCanvas:z});export{e as CornerDotType,r as CornerSquareType,t as DotType,s as ErrorCorrectionLevel,u as ErrorCorrectionPercents,h as FileExtension,i as GradientType,a as Mode,k as QRCodeStyling,n as ShapeType,o as TypeNumber,D as browserUtils};
1
+ function t(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var e={exports:{}};!function(t,e){var r=function(){var t=function(t,e){var r=t,i=c[e],n=null,o=0,s=null,a=[],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),d(0,0),d(o-7,0),d(0,o-7),g(),l(),w(t,e),r>=7&&f(t),null==s&&(s=m(r,i,a)),p(s,e)},d=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=b.getPatternPosition(r),e=0;e<t.length;e+=1)for(var i=0;i<t.length;i+=1){var o=t[e],s=t[i];if(null==n[o][s])for(var a=-2;a<=2;a+=1)for(var h=-2;h<=2;h+=1)n[o+a][s+h]=-2==a||2==a||-2==h||2==h||0==a&&0==h}},f=function(t){for(var e=b.getBCHTypeNumber(r),i=0;i<18;i+=1){var s=!t&&1==(e>>i&1);n[Math.floor(i/3)][i%3+o-8-3]=s}for(i=0;i<18;i+=1){s=!t&&1==(e>>i&1);n[i%3+o-8-3][Math.floor(i/3)]=s}},w=function(t,e){for(var r=i<<3|e,s=b.getBCHTypeInfo(r),a=0;a<15;a+=1){var h=!t&&1==(s>>a&1);a<6?n[a][8]=h:a<8?n[a+1][8]=h:n[o-15+a][8]=h}for(a=0;a<15;a+=1){h=!t&&1==(s>>a&1);a<8?n[8][o-a-1]=h:a<9?n[8][15-a-1+1]=h:n[8][15-a-1]=h}n[o-8][8]=!t},p=function(t,e){for(var r=-1,i=o-1,s=7,a=0,h=b.getMaskFunction(e),u=o-1;u>0;u-=2)for(6==u&&(u-=1);;){for(var c=0;c<2;c+=1)if(null==n[i][u-c]){var d=!1;a<t.length&&(d=1==(t[a]>>>s&1)),h(i,u-c)&&(d=!d),n[i][u-c]=d,-1==(s-=1)&&(a+=1,s=7)}if((i+=r)<0||o<=i){i-=r,r=-r;break}}},m=function(t,e,r){for(var i=S.getRSBlocks(t,e),n=$(),o=0;o<r.length;o+=1){var s=r[o];n.put(s.getMode(),4),n.put(s.getLength(),b.getLengthInBits(s.getMode(),t)),s.write(n)}var a=0;for(o=0;o<i.length;o+=1)a+=i[o].dataCount;if(n.getLengthInBits()>8*a)throw"code length overflow. ("+n.getLengthInBits()+">"+8*a+")";for(n.getLengthInBits()+4<=8*a&&n.put(0,4);n.getLengthInBits()%8!=0;)n.putBit(!1);for(;!(n.getLengthInBits()>=8*a||(n.put(236,8),n.getLengthInBits()>=8*a));)n.put(17,8);return function(t,e){for(var r=0,i=0,n=0,o=new Array(e.length),s=new Array(e.length),a=0;a<e.length;a+=1){var h=e[a].dataCount,u=e[a].totalCount-h;i=Math.max(i,h),n=Math.max(n,u),o[a]=new Array(h);for(var c=0;c<o[a].length;c+=1)o[a][c]=255&t.getBuffer()[c+r];r+=h;var d=b.getErrorCorrectPolynomial(u),l=x(o[a],d.getLength()-1).mod(d);for(s[a]=new Array(d.getLength()-1),c=0;c<s[a].length;c+=1){var g=c+l.getLength()-s[a].length;s[a][c]=g>=0?l.getAt(g):0}}var f=0;for(c=0;c<e.length;c+=1)f+=e[c].totalCount;var w=new Array(f),p=0;for(c=0;c<i;c+=1)for(a=0;a<e.length;a+=1)c<o[a].length&&(w[p]=o[a][c],p+=1);for(c=0;c<n;c+=1)for(a=0;a<e.length;a+=1)c<s[a].length&&(w[p]=s[a][c],p+=1);return w}(n,i)};h.addData=function(t,e){var r=null;switch(e=e||"Byte"){case"Numeric":r=M(t);break;case"Alphanumeric":r=A(t);break;case"Byte":r=z(t);break;case"Kanji":r=k(t);break;default:throw"mode:"+e}a.push(r),s=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=S.getRSBlocks(t,i),n=$(),o=0;o<a.length;o++){var s=a[o];n.put(s.getMode(),4),n.put(s.getLength(),b.getLengthInBits(s.getMode(),t)),s.write(n)}var c=0;for(o=0;o<e.length;o++)c+=e[o].dataCount;if(n.getLengthInBits()<=8*c)break}r=t}u(!1,function(){for(var t=0,e=0,r=0;r<8;r+=1){u(!0,r);var i=b.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,s,a,u,c=h.getModuleCount()*t+2*e,d="";for(u="l"+t+",0 0,"+t+" -"+t+",0 0,-"+t+"z ",d+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',d+=n.scalable?"":' width="'+c+'px" height="'+c+'px"',d+=' viewBox="0 0 '+c+" "+c+'" ',d+=' preserveAspectRatio="xMinYMin meet"',d+=i.text||r.text?' role="img" aria-labelledby="'+y([i.id,r.id].join(" ").trim())+'"':"",d+=">",d+=i.text?'<title id="'+y(i.id)+'">'+y(i.text)+"</title>":"",d+=r.text?'<description id="'+y(r.id)+'">'+y(r.text)+"</description>":"",d+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',d+='<path d="',s=0;s<h.getModuleCount();s+=1)for(a=s*t+e,o=0;o<h.getModuleCount();o+=1)h.isDark(s,o)&&(d+="M"+(o*t+e)+","+a+u);return d+='" stroke="transparent" fill="black"/>',d+="</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),s=Math.floor((r-i)/t);return h.isDark(s,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+=y(r),n+='"'),n+="/>"};var y=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,s=1*h.getModuleCount()+2*t,a=t,u=s-t,c={"██":"█","█ ":"▀"," █":"▄"," ":" "},d={"██":"▀","█ ":"▀"," █":" "," ":" "},l="";for(e=0;e<s;e+=2){for(i=Math.floor((e-a)/1),n=Math.floor((e+1-a)/1),r=0;r<s;r+=1)o="█",a<=r&&r<u&&a<=e&&e<u&&h.isDark(i,Math.floor((r-a)/1))&&(o=" "),a<=r&&r<u&&a<=e+1&&e+1<u&&h.isDark(n,Math.floor((r-a)/1))?o+=" ":o+="█",l+=t<1&&e+1>=u?d[o]:c[o];l+="\n"}return s%2&&t>0?l.substring(0,l.length-s-1)+Array(s+1).join("▀"):l.substring(0,l.length-1)}(e);t-=1,e=void 0===e?2*t:e;var r,i,n,o,s=h.getModuleCount()*t+2*e,a=e,u=s-e,c=Array(t+1).join("██"),d=Array(t+1).join(" "),l="",g="";for(r=0;r<s;r+=1){for(n=Math.floor((r-a)/t),g="",i=0;i<s;i+=1)o=1,a<=i&&i<u&&a<=r&&r<u&&h.isDark(n,Math.floor((i-a)/t))&&(o=0),g+=o?c:d;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=D(t),i=function(){var t=r.read();if(-1==t)throw"eof";return t},n=0,o={};;){var s=r.read();if(-1==s)break;var a=i(),h=i()<<8|i();o[String.fromCharCode(s<<8|a)]=h,n+=1}if(n!=e)throw n+" != "+e;return o}(),i="?".charCodeAt(0);return console.log(JSON.stringify(r),i),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 s=r[t.charAt(n)];"number"==typeof s?(255&s)==s?e.push(s):(e.push(s>>>8),e.push(255&s)):e.push(i)}}return e}};var e,r,i,n,o,s=1,a=2,h=4,u=8,c={L:1,M:0,Q:3,H:2},d=0,l=1,g=2,f=3,w=4,p=5,m=6,y=7,b=(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 d: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 w:return function(t,e){return(Math.floor(t/2)+Math.floor(e/3))%2==0};case p: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 y: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=x([1],0),r=0;r<t;r+=1)e=e.multiply(x([1,v.gexp(r)],0));return e},n.getLengthInBits=function(t,e){if(1<=e&&e<10)switch(t){case s:return 10;case a:return 9;case h:case u:return 8;default:throw"mode:"+t}else if(e<27)switch(t){case s:return 12;case a:return 11;case h:return 16;case u:return 10;default:throw"mode:"+t}else{if(!(e<41))throw"type:"+e;switch(t){case s:return 14;case a: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,s=t.isDark(i,n),a=-1;a<=1;a+=1)if(!(i+a<0||e<=i+a))for(var h=-1;h<=1;h+=1)n+h<0||e<=n+h||0==a&&0==h||s==t.isDark(i+a,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),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 x(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 x(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 x(r,0).mod(t)}};return i}var S=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 c.L:return t[4*(e-1)+0];case c.M:return t[4*(e-1)+1];case c.Q:return t[4*(e-1)+2];case c.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=[],a=0;a<o;a+=1)for(var h=n[3*a+0],u=n[3*a+1],d=n[3*a+2],l=0;l<h;l+=1)s.push(e(u,d));return s},r}(),$=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},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+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},A=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+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},z=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},k=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},C=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},D=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|s(t.charCodeAt(0)),n+=6)}var o=i>>>n-8&255;return n-=8,o}},s=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=s(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(";")}},s=function(t){for(var e=1<<t,r=1+(1<<t),i=t+1,o=a(),s=0;s<e;s+=1)o.add(String.fromCharCode(s));o.add(String.fromCharCode(e)),o.add(String.fromCharCode(r));var h,u,c,d=C(),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 w=String.fromCharCode(n[g]);g+=1,o.contains(f+w)?f+=w:(l.write(o.indexOf(f),i),o.size()<4095&&(o.size()==1<<i&&(i+=1),o.add(f+w)),f=w)}return l.write(o.indexOf(f),i),l.write(r,i),l.flush(),d.toByteArray()},a=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 s=C();i.write(s);for(var a=function(){var t=0,e=0,r=0,i="",n={},o=function(t){i+=String.fromCharCode(s(63&t))},s=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,s=0;s<n;s+=1)i+="="},n.toString=function(){return i},n}(),h=s.toByteArray(),u=0;u<h.length;u+=1)a.writeByte(h[u]);return a.flush(),"data:image/gif;base64,"+a};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}(e);var r=t(e.exports);const i=Array(41).fill(0).map(((t,e)=>e));var n,o;!function(t){t.L="L",t.M="M",t.Q="Q",t.H="H"}(n||(n={})),function(t){t.numeric="Numeric",t.alphanumeric="Alphanumeric",t.byte="Byte",t.kanji="Kanji",t.unicode="Unicode"}(o||(o={}));const s=t=>!!t&&"object"==typeof t&&!Array.isArray(t);function a(t,...e){if(!e.length)return t;const r=e.shift();return void 0!==r&&s(t)&&s(r)?(t={...t},Object.keys(r).forEach((e=>{const i=t[e],n=r[e];Array.isArray(i)&&Array.isArray(n)?t[e]=n:s(i)&&s(n)?t[e]=a(Object.assign({},i),n):t[e]=n})),a(t,...e)):t}var h,u,c,d,l;function g(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(t){t.radial="radial",t.linear="linear"}(h||(h={})),function(t){t.dot="dot",t.randomDot="random-dot",t.rounded="rounded",t.verticalLine="vertical-line",t.horizontalLine="horizontal-line",t.classy="classy",t.classyRounded="classy-rounded",t.square="square",t.smallSquare="small-square",t.extraRounded="extra-rounded",t.diamond="diamond"}(u||(u={})),function(t){t.dot="dot",t.square="square",t.heart="heart",t.extraRounded="extra-rounded",t.classy="classy",t.outpoint="outpoint",t.inpoint="inpoint"}(c||(c={})),function(t){t.dot="dot",t.square="square",t.extraRounded="extra-rounded",t.classy="classy",t.outpoint="outpoint",t.inpoint="inpoint"}(d||(d={})),function(t){t.square="square",t.circle="circle"}(l||(l={}));const f={document:void 0,shape:l.square,width:void 0,height:void 0,data:"",qrOptions:{typeNumber:i[0],mode:void 0,errorCorrectionLevel:n.Q},imageOptions:{hideBackgroundDots:!0,imageSize:.4,crossOrigin:void 0,margin:0},dotsOptions:{type:u.square,color:"#000",size:10}};function w(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=g(e.dotsOptions.gradient)),e.dotsOptions.size=Math.round(Math.max(0,e.dotsOptions.size)||10),e.cornersSquareOptions&&(e.cornersSquareOptions={...e.cornersSquareOptions},e.cornersSquareOptions.gradient&&(e.cornersSquareOptions.gradient=g(e.cornersSquareOptions.gradient))),e.cornersDotOptions&&(e.cornersDotOptions={...e.cornersDotOptions},e.cornersDotOptions.gradient&&(e.cornersDotOptions.gradient=g(e.cornersDotOptions.gradient))),e.backgroundOptions&&(e.backgroundOptions={...e.backgroundOptions},e.backgroundOptions.gradient&&(e.backgroundOptions.gradient=g(e.backgroundOptions.gradient))),e.document||(e.document=document),e}const p={[n.L]:.07,[n.M]:.15,[n.Q]:.25,[n.H]:.3};class m{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case c.square:e=this.drawSquare;break;case c.heart:e=this.drawHeart;break;case c.extraRounded:e=this.drawRounded;break;case c.classy:e=this.drawClassy;break;case c.inpoint:e=this.drawInpoint;break;case c.outpoint:e=this.drawOutpoint;break;case c.dot:default:e=this.drawDot}e.call(this,t)}rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,s=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${s})`)}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))}})}basicHeart(t){const{size:e,x:r,y:i}=t;this._element=this.document.createElementNS("http://www.w3.org/2000/svg","path");let n=!1,o=0;this._element.setAttribute("d",["M",.925,.3538125,"c",0,.0325869,-.0054931,.0644619,-.0164688,.095625,"S",.87825,.5147812,.850625,.5519688,"C",.823,.5891563,.7858125,.631125,.7390625,.677875,"S",.6331632,.7802256,.561625,.8446875,"L",.5,.8999375,"l",-.061625,-.05525,"C",.3668368,.7802256,.3076875,.724625,.2609375,.677875,"S",.177,.5891563,.149375,.5519688,"S",.1024444,.4806007,.0914688,.4494375,"S",.075,.3863994,.075,.3538125,"C",.075,.2872256,.0973125,.231625,.1419375,.187,"S",.2421631,.1200625,.30875,.1200625,"c",.0368369,0,.0718994,.0077881,.1051875,.023375,"S",.4759131,.1809756,.5,.2093125,"c",.0240868,-.0283369,.0527744,-.0502881,.0860625,-.065875,"c",.0332882,-.0155869,.0683507,-.023375,.1051875,-.023375,"c",.0665869,0,.1221875,.0223125,.1668125,.0669375,"S",.925,.2872256,.925,.3538125,"z"].map((t=>"string"==typeof t?(o=0,n=t.toUpperCase()==t,t):(o++,t*=e,n&&(t+=o%2==1?r:i),t.toFixed(5)))).join(" "))}basicRounded(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)),this._element.setAttribute("rx",String(e/4)),this._element.setAttribute("ry",String(e/4))}})}basicClassy(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 `+4.5*n+"v "+-4.5*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*-n}h `+-2*n+`H ${r}z`)}})}basicInpoint(t){const{size:e,x:r,y:i}=t,n=e;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+n/2}v `+n/4+`a ${n/4}, ${n/4} 0 0 0 ${n/4}, ${n/4}h `+n/4*3+"v "+-n/4*3+`a ${n/4}, ${n/4} 0 0 0 ${-n/4}, ${-n/4}h `+-n/2+`a ${n/4}, ${n/4} 0 0 0 ${-n/4}, ${n/4}z`)}})}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})}drawHeart({x:t,y:e,size:r,rotation:i}){this.basicHeart({x:t-.2*r/2,y:e-.2*r/2,size:1.2*r,rotation:i})}drawRounded({x:t,y:e,size:r,rotation:i}){this.basicRounded({x:t,y:e,size:r,rotation:i})}drawClassy({x:t,y:e,size:r,rotation:i}){this.basicClassy({x:t,y:e,size:r,rotation:i})}drawInpoint({x:t,y:e,size:r,rotation:i}){this.basicInpoint({x:t,y:e,size:r,rotation:i})}drawOutpoint({x:t,y:e,size:r,rotation:i}){this.basicInpoint({x:t,y:e,size:r,rotation:(i||0)+Math.PI})}}class y{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case d.square:e=this.drawSquare;break;case d.extraRounded:e=this.drawExtraRounded;break;case d.classy:e=this.drawClassy;break;case d.outpoint:e=this.drawOutpoint;break;case d.inpoint:e=this.drawInpoint;break;case d.dot:default:e=this.drawDot}e.call(this,t)}rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,s=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${s})`)}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}z`+`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}z`)}})}basicClassy(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 `+4.5*n+"v "+-4.5*n+`a ${2.5*n} ${2.5*n}, 0, 0, 0, ${2.5*-n} ${2.5*-n}h `+-2*n+`H ${r}z`+`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 `+3.5*n+"h "+-3.5*n+`a ${1.5*n} ${1.5*n}, 0, 0, 1, ${1.5*-n} ${1.5*-n}v `+-3.5*n+"z")}})}basicInpoint(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 `+4.5*n+"v "+-4.5*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}z`+`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 `+3.5*n+"h "+-3.5*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}z`)}})}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})}drawClassy({x:t,y:e,size:r,rotation:i}){this.basicClassy({x:t,y:e,size:r,rotation:i})}drawInpoint({x:t,y:e,size:r,rotation:i}){this.basicInpoint({x:t,y:e,size:r,rotation:i})}drawOutpoint({x:t,y:e,size:r,rotation:i}){this.basicInpoint({x:t,y:e,size:r,rotation:(i||0)+Math.PI})}}class b{get element(){return this._element}constructor(t,e){this.type=t,this.document=e}draw(t){let e;switch(this.type){case u.dot:e=this.drawDot;break;case u.randomDot:e=this.drawRandomDot;break;case u.classy:e=this.drawClassy;break;case u.classyRounded:e=this.drawClassyRounded;break;case u.rounded:e=this.drawRounded;break;case u.verticalLine:e=this.drawVerticalLine;break;case u.horizontalLine:e=this.drawHorizontalLine;break;case u.extraRounded:e=this.drawExtraRounded;break;case u.diamond:e=this.drawDiamond;break;case u.smallSquare:e=this.drawSmallSquare;break;case u.square:default:e=this.drawSquare}e.call(this,t)}rotateFigure({x:t,y:e,size:r,rotation:i=0,draw:n}){const o=t+r/2,s=e+r/2;n(),this._element?.setAttribute("transform",`rotate(${180*i/Math.PI},${o},${s})`)}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})}drawRandomDot({x:t,y:e,size:r}){const i=.25*Math.random()+.75;this.basicDot({x:t,y:e,size:r*i,rotation:0})}drawSquare({x:t,y:e,size:r}){this.basicSquare({x:t,y:e,size:r,rotation:0})}drawSmallSquare({x:t,y:e,size:r}){const i=r;r=.7*i,t+=.15*i,e+=.15*i,this.basicSquare({x:t,y:e,size:r,rotation:0})}drawDiamond({x:t,y:e,size:r}){this.basicSquare({x:t,y:e,size:r,rotation:Math.PI/4})}drawRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0,h=n+o+s+a;if(0!==h)if(h>2||n&&o||s&&a)this.basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&s?i=Math.PI/2:s&&o?i=Math.PI:o&&a&&(i=-Math.PI/2),void this.basicCornerRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return s?i=Math.PI/2:o?i=Math.PI:a&&(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})}drawVerticalLine({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0;if(0===n+o+s+a||n&&!s&&!a||o&&!s&&!a)this.basicDot({x:t,y:e,size:r,rotation:0});else if(s&&a)this.basicSquare({x:t,y:e,size:r,rotation:0});else if(!s||a)if(!a||s);else{const i=-Math.PI/2;this.basicSideRounded({x:t,y:e,size:r,rotation:i})}else{const i=Math.PI/2;this.basicSideRounded({x:t,y:e,size:r,rotation:i})}}drawHorizontalLine({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0;if(0===n+o+s+a||s&&!n&&!o||a&&!n&&!o)this.basicDot({x:t,y:e,size:r,rotation:0});else if(n&&o)this.basicSquare({x:t,y:e,size:r,rotation:0});else if(!n||o)if(!o||n);else{const i=Math.PI;this.basicSideRounded({x:t,y:e,size:r,rotation:i})}else{const i=0;this.basicSideRounded({x:t,y:e,size:r,rotation:i})}}drawExtraRounded({x:t,y:e,size:r,getNeighbor:i}){const n=i?+i(-1,0):0,o=i?+i(1,0):0,s=i?+i(0,-1):0,a=i?+i(0,1):0,h=n+o+s+a;if(0!==h)if(h>2||n&&o||s&&a)this.basicSquare({x:t,y:e,size:r,rotation:0});else{if(2===h){let i=0;return n&&s?i=Math.PI/2:s&&o?i=Math.PI:o&&a&&(i=-Math.PI/2),void this.basicCornerExtraRounded({x:t,y:e,size:r,rotation:i})}if(1===h){let i=0;return s?i=Math.PI/2:o?i=Math.PI:a&&(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,s=i?+i(0,-1):0,a=i?+i(0,1):0;0!==n+o+s+a?n||s?o||a?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,s=i?+i(0,-1):0,a=i?+i(0,1):0;0!==n+o+s+a?n||s?o||a?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 v={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,e)=>new Promise(((r,i)=>{const n=new Image;"string"===e&&(n.crossOrigin=e),n.onload=()=>{r({width:n.width,height:n.height})},n.onerror=n.onabort=i,"string"==typeof t?n.src=t:v.toDataURL(t).then((t=>n.src=t)).catch(i)}))};const x=[[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]],S=[[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]],$=[[35,49],[28,36],[21,25],[14,16],[7,9],[2,4],[1,1]];class M{get element(){return this._element}constructor(t){this.options=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||v}get width(){return this.options.width}get height(){return this.options.height}async drawQR(t){const e=t.getModuleCount(),r=parseInt(((e-17)/4).toFixed(0),10),i=this.options.dotsOptions.size;let n={hideXDots:0,hideYDots:0,width:0,height:0};if(this.qr=t,this.options.image){const t=await this.imageTools.getSize(this.options.image,this.options.imageOptions.crossOrigin),{imageOptions:o,errorCorrectionPercent:s}=this.options,a=o.imageSize*s,h=$.find((t=>t[0]<=r))||[0,0],u=Math.floor(a*(e*e-192-2*(e-16)-25*h[1]));n=function({originalHeight:t,originalWidth:e,maxHiddenDots:r,maxHiddenAxisDots:i,dotSize:n,margin:o}){const s={x:0,y:0},a={x:0,y:0};if(t<=0||e<=0||r<=0||n<=0||4*o**2>r)return{height:0,width:0,hideYDots:0,hideXDots:0};i&&i%2==0&&(i=Math.max(1,i-1));const h=Math.max(e,t),u=Math.min(e,t);let c=0,d=(i||r)-2*o;do{const t=c+(d-c)/2;let e=Math.max(1,Math.ceil(t+2*o));e%2==0&&e++;let i=Math.max(1,Math.ceil(t*u/h+2*o));i%2==0&&i++,e*i>r?d=t:c=t}while(Math.abs(c-d)>.001);const l=c;let g=Math.max(1,Math.ceil(l+2*o));g%2==0&&g++;let f=Math.max(1,Math.ceil(l*u/h+2*o));f%2==0&&f++,e>t?(s.x=g,s.y=f):(s.x=f,s.y=g);const w=(s.x-2*o)*n,p=(s.y-2*o)*n;return a.x=w,a.y=w*t/e,a.y>p&&(a.y=p,a.x=p*e/t),{height:Math.round(a.y+2*o*n),width:Math.round(a.x+2*o*n),hideYDots:s.y,hideXDots:s.x}}({originalWidth:t.width,originalHeight:t.height,maxHiddenDots:u,maxHiddenAxisDots:e-14,dotSize:i,margin:o.margin})}this.drawBackground(),this.drawDots(((t,r)=>!(this.options.imageOptions.hideBackgroundDots&&t>=(e-n.hideXDots)/2&&t<(e+n.hideXDots)/2&&r>=(e-n.hideYDots)/2&&r<(e+n.hideYDots)/2)&&(!(x[t]?.[r]||x[t-e+7]?.[r]||x[t]?.[r-e+7])&&!(S[t]?.[r]||S[t-e+7]?.[r]||S[t]?.[r-e+7])))),this.drawCorners(),this.options.image&&n.width>0&&n.height>0&&await this.drawImage({width:n.width,height:n.height,count:e,dotSize:i})}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.backgroundMask,this.backgroundMaskGroup]=this.createMask("mask-background-color"),this.defs.appendChild(this.backgroundMask),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.backgroundMaskGroup.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=this.options.dotsOptions.size,o=Math.floor((e.width-r*n)/2),s=Math.floor((e.height-r*n)/2),a=new b(e.dotsOptions.type,this.document);[this.dotsMask,this.dotsMaskGroup]=this.createMask("mask-dot-color"),this.defs.appendChild(this.dotsMask);for(let e=0;e<r;e++)for(let i=0;i<r;i++)t&&!t(e,i)||this.qr?.isDark(i,e)&&(a.draw({x:o+e*n,y:s+i*n,size:n,getNeighbor:(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(i+o,e+n)))}),a.element&&this.dotsMask&&this.dotsMaskGroup.appendChild(a.element));let h=o,u=s,c=r;if(e.shape===l.circle){const t=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,e=Math.floor((i/n-r-2*t)/2),d=r+2*e,l=o-e*n,g=s-e*n;h=l,u=g,c=r+2*e;const f=[],w=Math.floor(d/2);for(let t=0;t<d;t++){f[t]=[];for(let i=0;i<d;i++)t>=e-1&&t<=d-e&&i>=e-1&&i<=d-e||Math.sqrt((t-w)*(t-w)+(i-w)*(i-w))>w?f[t][i]=0:f[t][i]=this.qr.isDark(i-2*e<0?i:i>=r?i-2*e:i-e,t-2*e<0?t:t>=r?t-2*e:t-e)?1:0}for(let t=0;t<d;t++)for(let e=0;e<d;e++)f[t][e]&&(a.draw({x:l+t*n,y:g+e*n,size:n,getNeighbor:(r,i)=>!!f[t+r]?.[e+i]}),a.element&&this.dotsMask&&this.dotsMaskGroup.appendChild(a.element))}this.createColor({options:e.dotsOptions?.gradient,color:e.dotsOptions.color,additionalRotation:0,x:h,y:u,height:c*n,width:c*n,name:"dot-color"})}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=this.options.dotsOptions.size,n=7*i,o=3*i,s=Math.floor((e.width-r*i)/2),a=Math.floor((e.height-r*i)/2);[[0,0,0],[1,0,Math.PI/2],[0,1,-Math.PI/2]].forEach((([t,h,u])=>{const c=s+t*i*(r-7),d=a+h*i*(r-7);let l=this.dotsMask,g=this.dotsMaskGroup,f=this.dotsMask,w=this.dotsMaskGroup;if((e.cornersSquareOptions?.gradient||e.cornersSquareOptions?.color)&&([l,g]=this.createMask(`mask-corners-square-color-${t}-${h}`),this.defs.appendChild(l),f=l,w=g,this.createColor({options:e.cornersSquareOptions?.gradient,color:e.cornersSquareOptions?.color,additionalRotation:u,x:c,y:d,height:n,width:n,name:`corners-square-color-${t}-${h}`})),e.cornersSquareOptions?.type){const t=new y(e.cornersSquareOptions.type,this.document);t.draw({x:c,y:d,size:n,rotation:u}),t.element&&g&&g.appendChild(t.element)}else{const t=new b(e.dotsOptions.type,this.document);for(let e=0;e<x.length;e++)for(let r=0;r<x[e].length;r++)x[e]?.[r]&&(t.draw({x:c+e*i,y:d+r*i,size:i,getNeighbor:(t,i)=>!!x[e+t]?.[r+i]}),t.element&&g&&g.appendChild(t.element))}if((e.cornersDotOptions?.gradient||e.cornersDotOptions?.color)&&([f,w]=this.createMask(`mask-corners-dot-color-${t}-${h}`),this.defs.appendChild(f),this.createColor({options:e.cornersDotOptions?.gradient,color:e.cornersDotOptions?.color,additionalRotation:u,x:c+2*i,y:d+2*i,height:o,width:o,name:`corners-dot-color-${t}-${h}`})),e.cornersDotOptions?.type){const t=new m(e.cornersDotOptions.type,this.document);t.draw({x:c+2*i,y:d+2*i,size:o,rotation:u}),t.element&&w&&w.appendChild(t.element)}else{const t=new b(e.dotsOptions.type,this.document);for(let e=0;e<S.length;e++)for(let r=0;r<S[e].length;r++)S[e]?.[r]&&(t.draw({x:c+e*i,y:d+r*i,size:i,getNeighbor:(t,i)=>!!S[e+t]?.[r+i]}),t.element&&w&&w.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),s=Math.floor((n.height-r*i)/2),a=n.imageOptions.margin*i,h=o+a+(r*i-t)/2,u=s+a+(r*i-e)/2,c=t-2*a,d=e-2*a,l=await this.imageTools.toDataURL(n.image||"");let g=this.document.createElementNS("http://www.w3.org/2000/svg","image");if(g.setAttributeNS("http://www.w3.org/1999/xlink","xlink: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",`${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:a}){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("style",`mask:url(#mask-${a})`),t){let e;if(t.type===h.radial)e=this.document.createElementNS("http://www.w3.org/2000/svg","radialGradient"),e.setAttribute("id",a),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 h=((t.rotation||0)+r)%(2*Math.PI),u=(h+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(h),l+=s/2,g+=o/2*Math.tan(h)):u>.25*Math.PI&&u<=.75*Math.PI?(d-=o/2,c-=s/2/Math.tan(h),g+=o/2,l+=s/2/Math.tan(h)):u>.75*Math.PI&&u<=1.25*Math.PI?(c+=s/2,d+=o/2*Math.tan(h),l-=s/2,g-=o/2*Math.tan(h)):u>1.25*Math.PI&&u<=1.75*Math.PI&&(d+=o/2,c+=s/2/Math.tan(h),g-=o/2,l-=s/2/Math.tan(h)),e=this.document.createElementNS("http://www.w3.org/2000/svg","linearGradient"),e.setAttribute("id",a),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(#${a})`),this.defs.appendChild(e)}else e&&c.setAttribute("fill",e);this._element.appendChild(c)}createMask(t){const e=this.options,r=this.document.createElementNS("http://www.w3.org/2000/svg","mask");r.setAttribute("id",t),r.setAttribute("maskUnits","userSpaceOnUse"),r.setAttribute("x","0"),r.setAttribute("y","0"),r.setAttribute("width",String(e.width)),r.setAttribute("height",String(e.height));const i=this.document.createElementNS("http://www.w3.org/2000/svg","g");return i.setAttribute("fill","#fff"),r.appendChild(i),[r,i]}}class A{get size(){if(this.qrSVG)return{width:this.qrSVG.width,height:this.qrSVG.height}}constructor(t){this.options=t?w(a(f,t)):f,this.update()}update(t){if(this.container&&(this.container.innerHTML=""),this.options=t?w(a(this.options,t)):this.options,!this.options.data)return;this.options.stringToBytesFuncs&&(Object.assign(r.stringToBytesFuncs,this.options.stringToBytesFuncs),delete this.options.stringToBytesFuncs),this.qr=r(this.options.qrOptions.typeNumber,this.options.qrOptions.errorCorrectionLevel);let e=this.options.qrOptions.mode||function(t){switch(!0){case/^[0-9]*$/.test(t):return o.numeric;case/^[0-9A-Z $%*+\-./:]*$/.test(t):return o.alphanumeric;case/[^\u0000-\u00ff]/.test(t):return o.unicode;default:return o.byte}}(this.options.data);e==o.unicode?(r.stringToBytes=r.stringToBytesFuncs["UTF-8"],e=o.byte):r.stringToBytes=r.stringToBytesFuncs.default,this.qr.addData(this.options.data,e),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"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";if(this.qrSVG?.element&&this.svgDrawingPromise||this.setupSvg(),await this.svgDrawingPromise,!this.qrSVG?.element)return;let t=(new XMLSerializer).serializeToString(this.qrSVG.element);return t='<?xml version="1.0" standalone="no"?>\r\n'+t,t}setupSvg(){if(!this.qr)return;const t=Math.ceil((this.options.shape==l.circle?Math.sqrt(2):1)*this.qr.getModuleCount()),e=this.options.backgroundOptions&&this.options.backgroundOptions.margin||0,r=Math.ceil(this.options.dotsOptions.size*(t+2*e));this.qrSVG=new M({...this.options,width:r,height:r,errorCorrectionPercent:p[this.options.qrOptions.errorCorrectionLevel]}),this.svgDrawingPromise=this.qrSVG.drawQR(this.qr).then((()=>{this.qrSVG?.element&&this.extension?.(this.qrSVG.element,this.options)}))}}const z={width:300,height:300,margin:0};var k;function C(t,e){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}(a(z,e)):z,o=document.createElement("canvas");o.width=r,o.height=i;const s=Math.min(r,i)-2*n,h=t.serialize().then((t=>{if(!t)return;const e="data:image/svg+xml;base64,"+btoa(t),n=new Image;return new Promise(((t,a)=>{n.onload=()=>{const e=Math.ceil(2*s/Math.min(n.width,n.height));let a;try{a=new OffscreenCanvas(n.width*e,n.height*e)}catch(t){a=document.createElement("canvas"),a.width=n.width*e,a.height=n.height*e}a.getContext("2d")?.drawImage(n,0,0,a.width,a.height),o?.getContext("2d")?.drawImage(a,(r-s)/2,(i-s)/2,s,s),t()},n.onerror=n.onabort=a,n.src=e}))}));return{canvas:o,canvasDrawingPromise:h}}function D(t,e){const r=document.createElement("a");r.download=e,r.href=t,document.body.appendChild(r),r.click(),document.body.removeChild(r)}!function(t){t.svg="svg",t.png="png",t.jpeg="jpeg",t.webp="webp"}(k||(k={}));const q=Object.freeze({__proto__:null,get FileExtension(){return k},download:async function(t,e,r){let i=k.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;D("data:image/svg+xml;charset=utf-8,"+encodeURIComponent(e),`${n}.svg`)}else{const e=C(t,r);if(!e)return;const{canvas:o,canvasDrawingPromise:s}=e;await s;D(o.toDataURL(`image/${i}`),`${n}.${i}`)}},downloadURI:D,drawToCanvas:C});export{c as CornerDotType,d as CornerSquareType,u as DotType,n as ErrorCorrectionLevel,p as ErrorCorrectionPercents,k as FileExtension,h as GradientType,o as Mode,A as QRCodeStyling,l as ShapeType,i as TypeNumber,q as browserUtils};
2
2
  //# sourceMappingURL=qr-code-styling.js.map