cnf-qrcode
Version:
generate qrcode,support svg base64 utf8
3 lines (2 loc) • 42.8 kB
JavaScript
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("isarray"),require("dijkstrajs"),require("pngjs")):"function"==typeof define&&define.amd?define(["exports","isarray","dijkstrajs","pngjs"],r):(t=t||self,function(){var e=t.cnfQrcode,n=t.cnfQrcode={};r(n,t.isArray$1,t.dijkstra,t.pngjs),n.noConflict=function(){return t.cnfQrcode=e,n}}())}(this,function(t,r,e,n){"use strict";r=r&&r.hasOwnProperty("default")?r.default:r,e=e&&e.hasOwnProperty("default")?e.default:e,n=n&&n.hasOwnProperty("default")?n.default:n;var o="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{},i=[],a=[],u="undefined"!=typeof Uint8Array?Uint8Array:Array,f=!1;function s(){f=!0;for(var t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r=0,e=t.length;r<e;++r)i[r]=t[r],a[t.charCodeAt(r)]=r;a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63}function h(t,r,e){for(var n,o,a=[],u=r;u<e;u+=3)n=(t[u]<<16)+(t[u+1]<<8)+t[u+2],a.push(i[(o=n)>>18&63]+i[o>>12&63]+i[o>>6&63]+i[63&o]);return a.join("")}function c(t){var r;f||s();for(var e=t.length,n=e%3,o="",a=[],u=0,c=e-n;u<c;u+=16383)a.push(h(t,u,u+16383>c?c:u+16383));return 1===n?(r=t[e-1],o+=i[r>>2],o+=i[r<<4&63],o+="=="):2===n&&(r=(t[e-2]<<8)+t[e-1],o+=i[r>>10],o+=i[r>>4&63],o+=i[r<<2&63],o+="="),a.push(o),a.join("")}function l(t,r,e,n,o){var i,a,u=8*o-n-1,f=(1<<u)-1,s=f>>1,h=-7,c=e?o-1:0,l=e?-1:1,g=t[r+c];for(c+=l,i=g&(1<<-h)-1,g>>=-h,h+=u;h>0;i=256*i+t[r+c],c+=l,h-=8);for(a=i&(1<<-h)-1,i>>=-h,h+=n;h>0;a=256*a+t[r+c],c+=l,h-=8);if(0===i)i=1-s;else{if(i===f)return a?NaN:1/0*(g?-1:1);a+=Math.pow(2,n),i-=s}return(g?-1:1)*a*Math.pow(2,i-n)}function g(t,r,e,n,o,i){var a,u,f,s=8*i-o-1,h=(1<<s)-1,c=h>>1,l=23===o?Math.pow(2,-24)-Math.pow(2,-77):0,g=n?0:i-1,p=n?1:-1,d=r<0||0===r&&1/r<0?1:0;for(r=Math.abs(r),isNaN(r)||r===1/0?(u=isNaN(r)?1:0,a=h):(a=Math.floor(Math.log(r)/Math.LN2),r*(f=Math.pow(2,-a))<1&&(a--,f*=2),(r+=a+c>=1?l/f:l*Math.pow(2,1-c))*f>=2&&(a++,f/=2),a+c>=h?(u=0,a=h):a+c>=1?(u=(r*f-1)*Math.pow(2,o),a+=c):(u=r*Math.pow(2,c-1)*Math.pow(2,o),a=0));o>=8;t[e+g]=255&u,g+=p,u/=256,o-=8);for(a=a<<o|u,s+=o;s>0;t[e+g]=255&a,g+=p,a/=256,s-=8);t[e+g-p]|=128*d}var p={}.toString,d=Array.isArray||function(t){return"[object Array]"==p.call(t)};function v(){return y.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function w(t,r){if(v()<r)throw new RangeError("Invalid typed array length");return y.TYPED_ARRAY_SUPPORT?(t=new Uint8Array(r)).__proto__=y.prototype:(null===t&&(t=new y(r)),t.length=r),t}function y(t,r,e){if(!(y.TYPED_ARRAY_SUPPORT||this instanceof y))return new y(t,r,e);if("number"==typeof t){if("string"==typeof r)throw new Error("If encoding is specified then the first argument must be a string");return b(this,t)}return m(this,t,r,e)}function m(t,r,e,n){if("number"==typeof r)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&r instanceof ArrayBuffer?function(t,r,e,n){if(r.byteLength,e<0||r.byteLength<e)throw new RangeError("'offset' is out of bounds");if(r.byteLength<e+(n||0))throw new RangeError("'length' is out of bounds");r=void 0===e&&void 0===n?new Uint8Array(r):void 0===n?new Uint8Array(r,e):new Uint8Array(r,e,n);y.TYPED_ARRAY_SUPPORT?(t=r).__proto__=y.prototype:t=A(t,r);return t}(t,r,e,n):"string"==typeof r?function(t,r,e){"string"==typeof e&&""!==e||(e="utf8");if(!y.isEncoding(e))throw new TypeError('"encoding" must be a valid string encoding');var n=0|T(r,e),o=(t=w(t,n)).write(r,e);o!==n&&(t=t.slice(0,o));return t}(t,r,e):function(t,r){if(B(r)){var e=0|R(r.length);return 0===(t=w(t,e)).length?t:(r.copy(t,0,0,e),t)}if(r){if("undefined"!=typeof ArrayBuffer&&r.buffer instanceof ArrayBuffer||"length"in r)return"number"!=typeof r.length||(n=r.length)!=n?w(t,0):A(t,r);if("Buffer"===r.type&&d(r.data))return A(t,r.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(t,r)}function E(t){if("number"!=typeof t)throw new TypeError('"size" argument must be a number');if(t<0)throw new RangeError('"size" argument must not be negative')}function b(t,r){if(E(r),t=w(t,r<0?0:0|R(r)),!y.TYPED_ARRAY_SUPPORT)for(var e=0;e<r;++e)t[e]=0;return t}function A(t,r){var e=r.length<0?0:0|R(r.length);t=w(t,e);for(var n=0;n<e;n+=1)t[n]=255&r[n];return t}function R(t){if(t>=v())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+v().toString(16)+" bytes");return 0|t}function B(t){return!(null==t||!t._isBuffer)}function T(t,r){if(B(t))return t.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(t)||t instanceof ArrayBuffer))return t.byteLength;"string"!=typeof t&&(t=""+t);var e=t.length;if(0===e)return 0;for(var n=!1;;)switch(r){case"ascii":case"latin1":case"binary":return e;case"utf8":case"utf-8":case void 0:return K(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*e;case"hex":return e>>>1;case"base64":return X(t).length;default:if(n)return K(t).length;r=(""+r).toLowerCase(),n=!0}}function P(t,r,e){var n=!1;if((void 0===r||r<0)&&(r=0),r>this.length)return"";if((void 0===e||e>this.length)&&(e=this.length),e<=0)return"";if((e>>>=0)<=(r>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return F(this,r,e);case"utf8":case"utf-8":return Y(this,r,e);case"ascii":return D(this,r,e);case"latin1":case"binary":return z(this,r,e);case"base64":return O(this,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return j(this,r,e);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function _(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function L(t,r,e,n,o){if(0===t.length)return-1;if("string"==typeof e?(n=e,e=0):e>2147483647?e=2147483647:e<-2147483648&&(e=-2147483648),e=+e,isNaN(e)&&(e=o?0:t.length-1),e<0&&(e=t.length+e),e>=t.length){if(o)return-1;e=t.length-1}else if(e<0){if(!o)return-1;e=0}if("string"==typeof r&&(r=y.from(r,n)),B(r))return 0===r.length?-1:U(t,r,e,n,o);if("number"==typeof r)return r&=255,y.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?o?Uint8Array.prototype.indexOf.call(t,r,e):Uint8Array.prototype.lastIndexOf.call(t,r,e):U(t,[r],e,n,o);throw new TypeError("val must be string, number or Buffer")}function U(t,r,e,n,o){var i,a=1,u=t.length,f=r.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||r.length<2)return-1;a=2,u/=2,f/=2,e/=2}function s(t,r){return 1===a?t[r]:t.readUInt16BE(r*a)}if(o){var h=-1;for(i=e;i<u;i++)if(s(t,i)===s(r,-1===h?0:i-h)){if(-1===h&&(h=i),i-h+1===f)return h*a}else-1!==h&&(i-=i-h),h=-1}else for(e+f>u&&(e=u-f),i=e;i>=0;i--){for(var c=!0,l=0;l<f;l++)if(s(t,i+l)!==s(r,l)){c=!1;break}if(c)return i}return-1}function I(t,r,e,n){e=Number(e)||0;var o=t.length-e;n?(n=Number(n))>o&&(n=o):n=o;var i=r.length;if(i%2!=0)throw new TypeError("Invalid hex string");n>i/2&&(n=i/2);for(var a=0;a<n;++a){var u=parseInt(r.substr(2*a,2),16);if(isNaN(u))return a;t[e+a]=u}return a}function S(t,r,e,n){return tt(K(r,t.length-e),t,e,n)}function M(t,r,e,n){return tt(function(t){for(var r=[],e=0;e<t.length;++e)r.push(255&t.charCodeAt(e));return r}(r),t,e,n)}function C(t,r,e,n){return M(t,r,e,n)}function N(t,r,e,n){return tt(X(r),t,e,n)}function x(t,r,e,n){return tt(function(t,r){for(var e,n,o,i=[],a=0;a<t.length&&!((r-=2)<0);++a)e=t.charCodeAt(a),n=e>>8,o=e%256,i.push(o),i.push(n);return i}(r,t.length-e),t,e,n)}function O(t,r,e){return 0===r&&e===t.length?c(t):c(t.slice(r,e))}function Y(t,r,e){e=Math.min(t.length,e);for(var n=[],o=r;o<e;){var i,a,u,f,s=t[o],h=null,c=s>239?4:s>223?3:s>191?2:1;if(o+c<=e)switch(c){case 1:s<128&&(h=s);break;case 2:128==(192&(i=t[o+1]))&&(f=(31&s)<<6|63&i)>127&&(h=f);break;case 3:i=t[o+1],a=t[o+2],128==(192&i)&&128==(192&a)&&(f=(15&s)<<12|(63&i)<<6|63&a)>2047&&(f<55296||f>57343)&&(h=f);break;case 4:i=t[o+1],a=t[o+2],u=t[o+3],128==(192&i)&&128==(192&a)&&128==(192&u)&&(f=(15&s)<<18|(63&i)<<12|(63&a)<<6|63&u)>65535&&f<1114112&&(h=f)}null===h?(h=65533,c=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),o+=c}return function(t){var r=t.length;if(r<=k)return String.fromCharCode.apply(String,t);var e="",n=0;for(;n<r;)e+=String.fromCharCode.apply(String,t.slice(n,n+=k));return e}(n)}y.TYPED_ARRAY_SUPPORT=void 0===o.TYPED_ARRAY_SUPPORT||o.TYPED_ARRAY_SUPPORT,y.poolSize=8192,y._augment=function(t){return t.__proto__=y.prototype,t},y.from=function(t,r,e){return m(null,t,r,e)},y.TYPED_ARRAY_SUPPORT&&(y.prototype.__proto__=Uint8Array.prototype,y.__proto__=Uint8Array),y.alloc=function(t,r,e){return function(t,r,e,n){return E(r),r<=0?w(t,r):void 0!==e?"string"==typeof n?w(t,r).fill(e,n):w(t,r).fill(e):w(t,r)}(null,t,r,e)},y.allocUnsafe=function(t){return b(null,t)},y.allocUnsafeSlow=function(t){return b(null,t)},y.isBuffer=function(t){return null!=t&&(!!t._isBuffer||rt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&rt(t.slice(0,0))}(t))},y.compare=function(t,r){if(!B(t)||!B(r))throw new TypeError("Arguments must be Buffers");if(t===r)return 0;for(var e=t.length,n=r.length,o=0,i=Math.min(e,n);o<i;++o)if(t[o]!==r[o]){e=t[o],n=r[o];break}return e<n?-1:n<e?1:0},y.isEncoding=function(t){switch(String(t).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},y.concat=function(t,r){if(!d(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return y.alloc(0);var e;if(void 0===r)for(r=0,e=0;e<t.length;++e)r+=t[e].length;var n=y.allocUnsafe(r),o=0;for(e=0;e<t.length;++e){var i=t[e];if(!B(i))throw new TypeError('"list" argument must be an Array of Buffers');i.copy(n,o),o+=i.length}return n},y.byteLength=T,y.prototype._isBuffer=!0,y.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var r=0;r<t;r+=2)_(this,r,r+1);return this},y.prototype.swap32=function(){var t=this.length;if(t%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var r=0;r<t;r+=4)_(this,r,r+3),_(this,r+1,r+2);return this},y.prototype.swap64=function(){var t=this.length;if(t%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var r=0;r<t;r+=8)_(this,r,r+7),_(this,r+1,r+6),_(this,r+2,r+5),_(this,r+3,r+4);return this},y.prototype.toString=function(){var t=0|this.length;return 0===t?"":0===arguments.length?Y(this,0,t):P.apply(this,arguments)},y.prototype.equals=function(t){if(!B(t))throw new TypeError("Argument must be a Buffer");return this===t||0===y.compare(this,t)},y.prototype.inspect=function(){var t="";return this.length>0&&(t=this.toString("hex",0,50).match(/.{2}/g).join(" "),this.length>50&&(t+=" ... ")),"<Buffer "+t+">"},y.prototype.compare=function(t,r,e,n,o){if(!B(t))throw new TypeError("Argument must be a Buffer");if(void 0===r&&(r=0),void 0===e&&(e=t?t.length:0),void 0===n&&(n=0),void 0===o&&(o=this.length),r<0||e>t.length||n<0||o>this.length)throw new RangeError("out of range index");if(n>=o&&r>=e)return 0;if(n>=o)return-1;if(r>=e)return 1;if(this===t)return 0;for(var i=(o>>>=0)-(n>>>=0),a=(e>>>=0)-(r>>>=0),u=Math.min(i,a),f=this.slice(n,o),s=t.slice(r,e),h=0;h<u;++h)if(f[h]!==s[h]){i=f[h],a=s[h];break}return i<a?-1:a<i?1:0},y.prototype.includes=function(t,r,e){return-1!==this.indexOf(t,r,e)},y.prototype.indexOf=function(t,r,e){return L(this,t,r,e,!0)},y.prototype.lastIndexOf=function(t,r,e){return L(this,t,r,e,!1)},y.prototype.write=function(t,r,e,n){if(void 0===r)n="utf8",e=this.length,r=0;else if(void 0===e&&"string"==typeof r)n=r,e=this.length,r=0;else{if(!isFinite(r))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");r|=0,isFinite(e)?(e|=0,void 0===n&&(n="utf8")):(n=e,e=void 0)}var o=this.length-r;if((void 0===e||e>o)&&(e=o),t.length>0&&(e<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var i=!1;;)switch(n){case"hex":return I(this,t,r,e);case"utf8":case"utf-8":return S(this,t,r,e);case"ascii":return M(this,t,r,e);case"latin1":case"binary":return C(this,t,r,e);case"base64":return N(this,t,r,e);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return x(this,t,r,e);default:if(i)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),i=!0}},y.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var k=4096;function D(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(127&t[o]);return n}function z(t,r,e){var n="";e=Math.min(t.length,e);for(var o=r;o<e;++o)n+=String.fromCharCode(t[o]);return n}function F(t,r,e){var n=t.length;(!r||r<0)&&(r=0),(!e||e<0||e>n)&&(e=n);for(var o="",i=r;i<e;++i)o+=H(t[i]);return o}function j(t,r,e){for(var n=t.slice(r,e),o="",i=0;i<n.length;i+=2)o+=String.fromCharCode(n[i]+256*n[i+1]);return o}function W(t,r,e){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+r>e)throw new RangeError("Trying to access beyond buffer length")}function q(t,r,e,n,o,i){if(!B(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(r>o||r<i)throw new RangeError('"value" argument is out of bounds');if(e+n>t.length)throw new RangeError("Index out of range")}function $(t,r,e,n){r<0&&(r=65535+r+1);for(var o=0,i=Math.min(t.length-e,2);o<i;++o)t[e+o]=(r&255<<8*(n?o:1-o))>>>8*(n?o:1-o)}function Q(t,r,e,n){r<0&&(r=4294967295+r+1);for(var o=0,i=Math.min(t.length-e,4);o<i;++o)t[e+o]=r>>>8*(n?o:3-o)&255}function J(t,r,e,n,o,i){if(e+n>t.length)throw new RangeError("Index out of range");if(e<0)throw new RangeError("Index out of range")}function Z(t,r,e,n,o){return o||J(t,0,e,4),g(t,r,e,n,23,4),e+4}function V(t,r,e,n,o){return o||J(t,0,e,8),g(t,r,e,n,52,8),e+8}y.prototype.slice=function(t,r){var e,n=this.length;if((t=~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),(r=void 0===r?n:~~r)<0?(r+=n)<0&&(r=0):r>n&&(r=n),r<t&&(r=t),y.TYPED_ARRAY_SUPPORT)(e=this.subarray(t,r)).__proto__=y.prototype;else{var o=r-t;e=new y(o,void 0);for(var i=0;i<o;++i)e[i]=this[i+t]}return e},y.prototype.readUIntLE=function(t,r,e){t|=0,r|=0,e||W(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n},y.prototype.readUIntBE=function(t,r,e){t|=0,r|=0,e||W(t,r,this.length);for(var n=this[t+--r],o=1;r>0&&(o*=256);)n+=this[t+--r]*o;return n},y.prototype.readUInt8=function(t,r){return r||W(t,1,this.length),this[t]},y.prototype.readUInt16LE=function(t,r){return r||W(t,2,this.length),this[t]|this[t+1]<<8},y.prototype.readUInt16BE=function(t,r){return r||W(t,2,this.length),this[t]<<8|this[t+1]},y.prototype.readUInt32LE=function(t,r){return r||W(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},y.prototype.readUInt32BE=function(t,r){return r||W(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},y.prototype.readIntLE=function(t,r,e){t|=0,r|=0,e||W(t,r,this.length);for(var n=this[t],o=1,i=0;++i<r&&(o*=256);)n+=this[t+i]*o;return n>=(o*=128)&&(n-=Math.pow(2,8*r)),n},y.prototype.readIntBE=function(t,r,e){t|=0,r|=0,e||W(t,r,this.length);for(var n=r,o=1,i=this[t+--n];n>0&&(o*=256);)i+=this[t+--n]*o;return i>=(o*=128)&&(i-=Math.pow(2,8*r)),i},y.prototype.readInt8=function(t,r){return r||W(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},y.prototype.readInt16LE=function(t,r){r||W(t,2,this.length);var e=this[t]|this[t+1]<<8;return 32768&e?4294901760|e:e},y.prototype.readInt16BE=function(t,r){r||W(t,2,this.length);var e=this[t+1]|this[t]<<8;return 32768&e?4294901760|e:e},y.prototype.readInt32LE=function(t,r){return r||W(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},y.prototype.readInt32BE=function(t,r){return r||W(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},y.prototype.readFloatLE=function(t,r){return r||W(t,4,this.length),l(this,t,!0,23,4)},y.prototype.readFloatBE=function(t,r){return r||W(t,4,this.length),l(this,t,!1,23,4)},y.prototype.readDoubleLE=function(t,r){return r||W(t,8,this.length),l(this,t,!0,52,8)},y.prototype.readDoubleBE=function(t,r){return r||W(t,8,this.length),l(this,t,!1,52,8)},y.prototype.writeUIntLE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||q(this,t,r,e,Math.pow(2,8*e)-1,0);var o=1,i=0;for(this[r]=255&t;++i<e&&(o*=256);)this[r+i]=t/o&255;return r+e},y.prototype.writeUIntBE=function(t,r,e,n){(t=+t,r|=0,e|=0,n)||q(this,t,r,e,Math.pow(2,8*e)-1,0);var o=e-1,i=1;for(this[r+o]=255&t;--o>=0&&(i*=256);)this[r+o]=t/i&255;return r+e},y.prototype.writeUInt8=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,1,255,0),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),this[r]=255&t,r+1},y.prototype.writeUInt16LE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):$(this,t,r,!0),r+2},y.prototype.writeUInt16BE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,2,65535,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):$(this,t,r,!1),r+2},y.prototype.writeUInt32LE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=255&t):Q(this,t,r,!0),r+4},y.prototype.writeUInt32BE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,4,4294967295,0),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Q(this,t,r,!1),r+4},y.prototype.writeIntLE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);q(this,t,r,e,o-1,-o)}var i=0,a=1,u=0;for(this[r]=255&t;++i<e&&(a*=256);)t<0&&0===u&&0!==this[r+i-1]&&(u=1),this[r+i]=(t/a>>0)-u&255;return r+e},y.prototype.writeIntBE=function(t,r,e,n){if(t=+t,r|=0,!n){var o=Math.pow(2,8*e-1);q(this,t,r,e,o-1,-o)}var i=e-1,a=1,u=0;for(this[r+i]=255&t;--i>=0&&(a*=256);)t<0&&0===u&&0!==this[r+i+1]&&(u=1),this[r+i]=(t/a>>0)-u&255;return r+e},y.prototype.writeInt8=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,1,127,-128),y.TYPED_ARRAY_SUPPORT||(t=Math.floor(t)),t<0&&(t=255+t+1),this[r]=255&t,r+1},y.prototype.writeInt16LE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8):$(this,t,r,!0),r+2},y.prototype.writeInt16BE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,2,32767,-32768),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>8,this[r+1]=255&t):$(this,t,r,!1),r+2},y.prototype.writeInt32LE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,4,2147483647,-2147483648),y.TYPED_ARRAY_SUPPORT?(this[r]=255&t,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24):Q(this,t,r,!0),r+4},y.prototype.writeInt32BE=function(t,r,e){return t=+t,r|=0,e||q(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),y.TYPED_ARRAY_SUPPORT?(this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=255&t):Q(this,t,r,!1),r+4},y.prototype.writeFloatLE=function(t,r,e){return Z(this,t,r,!0,e)},y.prototype.writeFloatBE=function(t,r,e){return Z(this,t,r,!1,e)},y.prototype.writeDoubleLE=function(t,r,e){return V(this,t,r,!0,e)},y.prototype.writeDoubleBE=function(t,r,e){return V(this,t,r,!1,e)},y.prototype.copy=function(t,r,e,n){if(e||(e=0),n||0===n||(n=this.length),r>=t.length&&(r=t.length),r||(r=0),n>0&&n<e&&(n=e),n===e)return 0;if(0===t.length||0===this.length)return 0;if(r<0)throw new RangeError("targetStart out of bounds");if(e<0||e>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-r<n-e&&(n=t.length-r+e);var o,i=n-e;if(this===t&&e<r&&r<n)for(o=i-1;o>=0;--o)t[o+r]=this[o+e];else if(i<1e3||!y.TYPED_ARRAY_SUPPORT)for(o=0;o<i;++o)t[o+r]=this[o+e];else Uint8Array.prototype.set.call(t,this.subarray(e,e+i),r);return i},y.prototype.fill=function(t,r,e,n){if("string"==typeof t){if("string"==typeof r?(n=r,r=0,e=this.length):"string"==typeof e&&(n=e,e=this.length),1===t.length){var o=t.charCodeAt(0);o<256&&(t=o)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!y.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof t&&(t&=255);if(r<0||this.length<r||this.length<e)throw new RangeError("Out of range index");if(e<=r)return this;var i;if(r>>>=0,e=void 0===e?this.length:e>>>0,t||(t=0),"number"==typeof t)for(i=r;i<e;++i)this[i]=t;else{var a=B(t)?t:K(new y(t,n).toString()),u=a.length;for(i=0;i<e-r;++i)this[i+r]=a[i%u]}return this};var G=/[^+\/0-9A-Za-z-_]/g;function H(t){return t<16?"0"+t.toString(16):t.toString(16)}function K(t,r){var e;r=r||1/0;for(var n=t.length,o=null,i=[],a=0;a<n;++a){if((e=t.charCodeAt(a))>55295&&e<57344){if(!o){if(e>56319){(r-=3)>-1&&i.push(239,191,189);continue}if(a+1===n){(r-=3)>-1&&i.push(239,191,189);continue}o=e;continue}if(e<56320){(r-=3)>-1&&i.push(239,191,189),o=e;continue}e=65536+(o-55296<<10|e-56320)}else o&&(r-=3)>-1&&i.push(239,191,189);if(o=null,e<128){if((r-=1)<0)break;i.push(e)}else if(e<2048){if((r-=2)<0)break;i.push(e>>6|192,63&e|128)}else if(e<65536){if((r-=3)<0)break;i.push(e>>12|224,e>>6&63|128,63&e|128)}else{if(!(e<1114112))throw new Error("Invalid code point");if((r-=4)<0)break;i.push(e>>18|240,e>>12&63|128,e>>6&63|128,63&e|128)}}return i}function X(t){return function(t){var r,e,n,o,i,h;f||s();var c=t.length;if(c%4>0)throw new Error("Invalid string. Length must be a multiple of 4");i="="===t[c-2]?2:"="===t[c-1]?1:0,h=new u(3*c/4-i),n=i>0?c-4:c;var l=0;for(r=0,e=0;r<n;r+=4,e+=3)o=a[t.charCodeAt(r)]<<18|a[t.charCodeAt(r+1)]<<12|a[t.charCodeAt(r+2)]<<6|a[t.charCodeAt(r+3)],h[l++]=o>>16&255,h[l++]=o>>8&255,h[l++]=255&o;return 2===i?(o=a[t.charCodeAt(r)]<<2|a[t.charCodeAt(r+1)]>>4,h[l++]=255&o):1===i&&(o=a[t.charCodeAt(r)]<<10|a[t.charCodeAt(r+1)]<<4|a[t.charCodeAt(r+2)]>>2,h[l++]=o>>8&255,h[l++]=255&o),h}(function(t){if((t=function(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}(t).replace(G,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function tt(t,r,e,n){for(var o=0;o<n&&!(o+e>=r.length||o>=t.length);++o)r[o+e]=t[o];return o}function rt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}var et,nt=y,ot=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];function it(t){if(!t)throw new Error('"version" cannot be null or undefined');if(1>t||40<t)throw new Error('"version" should be in range from 1 to 40');return 4*t+17}function at(t){return ot[t]}function ut(t){for(var r=0;0!==t;)r++,t>>>=1;return r}function ft(){return void 0!==et}function st(t){return et(t)}var ht={bit:1},ct={bit:0},lt={bit:3},gt={bit:2};function pt(t,r){if((e=t)&&void 0!==e.bit&&0<=e.bit&&4>e.bit)return t;var e;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return ht;case"m":case"medium":return ct;case"q":case"quartile":return lt;case"h":case"high":return gt;default:throw new Error("Unknown EC Level: ".concat(t))}}(t)}catch(t){return r}}function dt(){this.buffer=[],this.length=0}function vt(t){if(!t||1>t)throw new Error("BitMatrix size must be defined and greater than 0");this.size=t,this.data=new nt(t*t),this.data.fill(0),this.reservedBit=new nt(t*t),this.reservedBit.fill(0)}function wt(t){for(var r=[],e=function(t){if(1===t)return[];for(var r=Math.floor(t/7)+2,e=it(t),n=145===e?26:2*Math.ceil((e-13)/(2*r-2)),o=[e-7],i=1;i<r-1;i++)o[i]=o[i-1]-n;return o.push(6),o.reverse()}(t),n=e.length,o=0;o<n;o++)for(var i=0;i<n;i++)(0!=o||0!=i)&&(0!=o||i!=n-1)&&(o!=n-1||0!=i)&&r.push([e[o],e[i]]);return r}dt.prototype={get:function(t){var r=Math.floor(t/8);return 1==(1&this.buffer[r]>>>7-t%8)},put:function(t,r){for(var e=0;e<r;e++)this.putBit(1==(1&t>>>r-e-1))},getLengthInBits:function(){return this.length},putBit:function(t){var r=Math.floor(this.length/8);this.buffer.length<=r&&this.buffer.push(0),t&&(this.buffer[r]|=128>>>this.length%8),this.length++}},vt.prototype.set=function(t,r,e,n){var o=t*this.size+r;this.data[o]=e,n&&(this.reservedBit[o]=!0)},vt.prototype.get=function(t,r){return this.data[t*this.size+r]},vt.prototype.xor=function(t,r,e){this.data[t*this.size+r]^=e},vt.prototype.isReserved=function(t,r){return this.reservedBit[t*this.size+r]};var yt=7;var mt={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},Et={N1:3,N2:3,N3:40,N4:10};function bt(t){return null!=(r=t)&&""!==r&&!isNaN(r)&&0<=r&&7>=r?parseInt(t,10):void 0;var r}function At(t){for(var r=t.size,e=0,n=0,o=0,i=null,a=null,u=0;u<r;u++){n=o=0,i=a=null;for(var f,s=0;s<r;s++)(f=t.get(u,s))===i?n++:(5<=n&&(e+=Et.N1+(n-5)),i=f,n=1),(f=t.get(s,u))===a?o++:(5<=o&&(e+=Et.N1+(o-5)),a=f,o=1);5<=n&&(e+=Et.N1+(n-5)),5<=o&&(e+=Et.N1+(o-5))}return e}function Rt(t){for(var r=t.size,e=0,n=0;n<r-1;n++)for(var o,i=0;i<r-1;i++)(4===(o=t.get(n,i)+t.get(n,i+1)+t.get(n+1,i)+t.get(n+1,i+1))||0===o)&&e++;return e*Et.N2}function Bt(t){for(var r=t.size,e=0,n=0,o=0,i=0;i<r;i++){n=o=0;for(var a=0;a<r;a++)n=2047&n<<1|t.get(i,a),10<=a&&(1488===n||93===n)&&e++,o=2047&o<<1|t.get(a,i),10<=a&&(1488===o||93===o)&&e++}return e*Et.N3}function Tt(t){for(var r=0,e=t.data.length,n=0;n<e;n++)r+=t.data[n];return Math.abs(Math.ceil(100*r/e/5)-10)*Et.N4}function Pt(t,r,e){switch(t){case mt.PATTERN000:return 0==(r+e)%2;case mt.PATTERN001:return 0==r%2;case mt.PATTERN010:return 0==e%3;case mt.PATTERN011:return 0==(r+e)%3;case mt.PATTERN100:return 0==(Math.floor(r/2)+Math.floor(e/3))%2;case mt.PATTERN101:return 0==r*e%2+r*e%3;case mt.PATTERN110:return 0==(r*e%2+r*e%3)%2;case mt.PATTERN111:return 0==(r*e%3+(r+e)%2)%2;default:throw new Error("bad maskPattern:".concat(t))}}function _t(t,r){for(var e=r.size,n=0;n<e;n++)for(var o=0;o<e;o++)r.isReserved(o,n)||r.xor(o,n,Pt(t,o,n))}var Lt,Ut,It=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],St=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];function Mt(t,r){return r===ht?St[4*(t-1)+0]:r===ct?St[4*(t-1)+1]:r===lt?St[4*(t-1)+2]:r===gt?St[4*(t-1)+3]:void 0}function Ct(t,r){return 0===t||0===r?0:Lt[Ut[t]+Ut[r]]}function Nt(t,r){var e=new nt(t.length+r.length-1);e.fill(0);for(var n=0;n<t.length;n++)for(var o=0;o<r.length;o++)e[n+o]^=Ct(t[n],r[o]);return e}function xt(t){this.genPoly=void 0,this.degree=t,this.degree&&this.initialize(this.degree)}function Ot(t){return!isNaN(t)&&1<=t&&40>=t}nt.alloc?(Lt=nt.alloc(512),Ut=nt.alloc(256)):(Lt=new nt(512),Ut=new nt(256)),function(){for(var t=1,r=0;255>r;r++)Lt[r]=t,Ut[t]=r,256&(t<<=1)&&(t^=285);for(r=255;512>r;r++)Lt[r]=Lt[r-255]}(),xt.prototype.initialize=function(t){this.degree=t,this.genPoly=function(t){for(var r=new nt([1]),e=0;e<t;e++)r=Nt(r,[1,(n=e,Lt[n])]);var n;return r}(this.degree)},xt.prototype.encode=function(t){if(!this.genPoly)throw new Error("Encoder not initialized");var r=new nt(this.degree);r.fill(0);var e=function(t,r){for(var e=new nt(t);0<=e.length-r.length;){for(var n=e[0],o=0;o<r.length;o++)e[o]^=Ct(r[o],n);for(var i=0;i<e.length&&0===e[i];)i++;e=e.slice(i)}return e}(nt.concat([t,r],t.length+this.degree),this.genPoly),n=this.degree-e.length;if(0<n){var o=new nt(this.degree);return o.fill(0),e.copy(o,n),o}return e};var Yt="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Yt=Yt.replace(/u/g,"\\u");var kt="(?:(?![A-Z0-9 $%*+\\-./:]|".concat(Yt,")(?:.|[\r\n]))+"),Dt=new RegExp(Yt,"g"),zt=/[^A-Z0-9 $%*+\-.\/:]+/g,Ft=new RegExp(kt,"g"),jt=/[0-9]+/g,Wt=new RegExp("[A-Z $%*+\\-./:]+","g"),qt=new RegExp("^".concat(Yt,"$")),$t=/^[0-9]+$/,Qt=/^[A-Z0-9 $%*+\-.\/:]+$/;var Jt={id:"Numeric",bit:1,ccBits:[10,12,14]},Zt={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},Vt={id:"Byte",bit:4,ccBits:[8,16,16]},Gt={id:"Kanji",bit:8,ccBits:[8,10,12]},Ht={bit:-1};function Kt(t,r){if(!t.ccBits)throw new Error("Invalid mode: ".concat(t));if(!Ot(r))throw new Error("Invalid version: ".concat(r));return 1<=r&&10>r?t.ccBits[0]:27>r?t.ccBits[1]:t.ccBits[2]}function Xt(t){return r=t,$t.test(r)?Jt:function(t){return Qt.test(t)}(t)?Zt:function(t){return qt.test(t)}(t)?Gt:Vt;var r}function tr(t){if(t&&t.id)return t.id;throw new Error("Invalid mode")}function rr(t,r){if((e=t)&&e.bit&&e.ccBits)return t;var e;try{return function(t){if("string"!=typeof t)throw new Error("Param is not a string");switch(t.toLowerCase()){case"numeric":return Jt;case"alphanumeric":return Zt;case"kanji":return Gt;case"byte":return Vt;default:throw new Error("Unknown mode: ".concat(t))}}(t)}catch(t){return r}}var er=7973,nr=ut(er);function or(t,r){return Kt(t,r)+4}function ir(t,r){var e=0;return t.forEach(function(t){var n=or(t.mode,r);e+=n+t.getBitsLength()}),e}function ar(t,r,e){if(!Ot(t))throw new Error("Invalid QR Code version");void 0===e&&(e=Vt);var n=8*(at(t)-Mt(t,r));if(e===Ht)return n;var o=n-or(e,t);switch(e){case Jt:return Math.floor(o/10*3);case Zt:return Math.floor(o/11*2);case Gt:return Math.floor(o/13);case Vt:default:return Math.floor(o/8)}}function ur(t,e){var n,o=pt(e,ct);if(r(t)){if(1<t.length)return function(t,r){for(var e=1;40>=e;e++)if(ir(t,e)<=ar(e,r,Ht))return e}(t,o);if(0===t.length)return 1;n=t[0]}else n=t;return function(t,r,e){for(var n=1;40>=n;n++)if(r<=ar(n,e,t))return n}(n.mode,n.getLength(),o)}var fr=1335,sr=21522,hr=ut(fr);function cr(t){this.mode=Jt,this.data=t.toString()}cr.getBitsLength=function(t){return 10*Math.floor(t/3)+(t%3?t%3*3+1:0)},cr.prototype.getLength=function(){return this.data.length},cr.prototype.getBitsLength=function(){return cr.getBitsLength(this.data.length)},cr.prototype.write=function(t){var r,e,n;for(r=0;r+3<=this.data.length;r+=3)e=this.data.substr(r,3),n=parseInt(e,10),t.put(n,10);var o=this.data.length-r;0<o&&(e=this.data.substr(r),n=parseInt(e,10),t.put(n,3*o+1))};var lr=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function gr(t){this.mode=Zt,this.data=t}function pr(t){this.mode=Vt,this.data=new nt(t)}function dr(t){this.mode=Gt,this.data=t}function vr(t){return unescape(encodeURIComponent(t)).length}function wr(t,r,e){for(var n,o=[];null!==(n=t.exec(e));)o.push({data:n[0],index:n.index,mode:r,length:n[0].length});return o}function yr(t){var r,e,n=wr(jt,Jt,t),o=wr(Wt,Zt,t);return ft()?(r=wr(Ft,Vt,t),e=wr(Dt,Gt,t)):(r=wr(zt,Vt,t),e=[]),n.concat(o,r,e).sort(function(t,r){return t.index-r.index}).map(function(t){return{data:t.data,mode:t.mode,length:t.length}})}function mr(t,r){return r===Jt?cr.getBitsLength(t):r===Zt?gr.getBitsLength(t):r===Gt?dr.getBitsLength(t):r===Vt?pr.getBitsLength(t):void 0}function Er(t,r){var e,n=Xt(t);if((e=rr(r,n))!==Vt&&e.bit<n.bit)throw new Error('"'.concat(t,'"')+" cannot be encoded with mode ".concat(tr(e),".\n Suggested mode is: ").concat(tr(n)));return e!==Gt||ft()||(e=Vt),e===Jt?new cr(t):e===Zt?new gr(t):e===Gt?new dr(t):e===Vt?new pr(t):void 0}function br(t){return t.reduce(function(t,r){return"string"==typeof r?t.push(Er(r,null)):r.data&&t.push(Er(r.data,r.mode)),t},[])}function Ar(t,r){for(var n=function(t,r){for(var e={},n={start:{}},o=["start"],i=0;i<t.length;i++){for(var a=t[i],u=[],f=0;f<a.length;f++){var s=a[f],h="".concat(i).concat(f);u.push(h),e[h]={node:s,lastCount:0},n[h]={};for(var c,l=0;l<o.length;l++)e[c=o[l]]&&e[c].node.mode===s.mode?(n[c][h]=mr(e[c].lastCount+s.length,s.mode)-mr(e[c].lastCount,s.mode),e[c].lastCount+=s.length):(e[c]&&(e[c].lastCount=s.length),n[c][h]=mr(s.length,s.mode)+4+Kt(s.mode,r))}o=u}for(l=0;l<o.length;l++)n[o[l]].end=0;return{map:n,table:e}}(function(t){for(var r,e=[],n=0;n<t.length;n++)switch(r=t[n],r.mode){case Jt:e.push([r,{data:r.data,mode:Zt,length:r.length},{data:r.data,mode:Vt,length:r.length}]);break;case Zt:e.push([r,{data:r.data,mode:Vt,length:r.length}]);break;case Gt:e.push([r,{data:r.data,mode:Vt,length:vr(r.data)}]);break;case Vt:e.push([{data:r.data,mode:Vt,length:vr(r.data)}])}return e}(yr(t)),r),o=e.find_path(n.map,"start","end"),i=[],a=1;a<o.length-1;a++)i.push(n.table[o[a]].node);return br(function(t){return t.reduce(function(t,r){var e=0<=t.length-1?t[t.length-1]:null;return e&&e.mode===r.mode?(t[t.length-1].data+=r.data,t):(t.push(r),t)},[])}(i))}function Rr(t,r){for(var e=t.size,n=function(t){var r=it(t);return[[0,0],[r-yt,0],[0,r-yt]]}(r),o=0;o<n.length;o++)for(var i=n[o][0],a=n[o][1],u=-1;7>=u;u++)if(!(-1>=i+u||e<=i+u))for(var f=-1;7>=f;f++)-1>=a+f||e<=a+f||(0<=u&&6>=u&&(0==f||6==f)||0<=f&&6>=f&&(0==u||6==u)||2<=u&&4>=u&&2<=f&&4>=f?t.set(i+u,a+f,!0,!0):t.set(i+u,a+f,!1,!0))}function Br(t,r){for(var e,n,o,i=t.size,a=function(t){if(!Ot(t)||7>t)throw new Error("Invalid QR Code version");for(var r=t<<12;0<=ut(r)-nr;)r^=er<<ut(r)-nr;return t<<12|r}(r),u=0;18>u;u++)e=Math.floor(u/3),n=u%3+i-8-3,o=1==(1&a>>u),t.set(e,n,o,!0),t.set(n,e,o,!0)}function Tr(t,r,e){var n,o,i=t.size,a=function(t,r){for(var e=t.bit<<3|r,n=e<<10;0<=ut(n)-hr;)n^=fr<<ut(n)-hr;return(e<<10|n)^sr}(r,e);for(n=0;15>n;n++)o=1==(1&a>>n),6>n?t.set(n,8,o,!0):8>n?t.set(n+1,8,o,!0):t.set(i-15+n,8,o,!0),8>n?t.set(8,i-n-1,o,!0):9>n?t.set(8,15-n-1+1,o,!0):t.set(8,15-n-1,o,!0);t.set(i-8,8,1,!0)}function Pr(t,r,e){var n=new dt;e.forEach(function(r){n.put(r.mode.bit,4),n.put(r.getLength(),Kt(r.mode,t)),r.write(n)});var o=8*(at(t)-Mt(t,r));for(n.getLengthInBits()+4<=o&&n.put(0,4);0!=n.getLengthInBits()%8;)n.putBit(0);for(var i=(o-n.getLengthInBits())/8,a=0;a<i;a++)n.put(a%2?17:236,8);return function(t,r,e){for(var n,o=at(r),i=Mt(r,e),a=function(t,r){return r===ht?It[4*(t-1)+0]:r===ct?It[4*(t-1)+1]:r===lt?It[4*(t-1)+2]:r===gt?It[4*(t-1)+3]:void 0}(r,e),u=Math.floor(o/a),f=Math.floor((o-i)/a),s=u-f,h=new xt(s),c=0,l=Array(a),g=Array(a),p=0,d=new nt(t.buffer),v=0;v<a;v++)n=v<a-o%a?f:f+1,l[v]=d.slice(c,c+n),g[v]=h.encode(l[v]),c+=n,p=Math.max(p,n);var w,y,m=new nt(o),E=0;for(w=0;w<p;w++)for(y=0;y<a;y++)w<l[y].length&&(m[E++]=l[y][w]);for(w=0;w<s;w++)for(y=0;y<a;y++)m[E++]=g[y][w];return m}(n,t,r)}function _r(t,e,n,o){var i;if(r(t))i=br(t);else{if("string"!=typeof t)throw new Error("Invalid data");var a=e;a||(a=ur(function(t){return br(yr(t))}(t),n));i=Ar(t,a||40)}var u=ur(i,n);if(!u)throw new Error("The amount of data is too big to be stored in a QR Code");if(e){if(e<u)throw new Error("".concat("\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: ").concat(u,".\n"))}else e=u;var f=Pr(e,n,i),s=new vt(it(e));return Rr(s,e),function(t){for(var r,e=t.size,n=8;n<e-8;n++)r=0==n%2,t.set(n,6,r,!0),t.set(6,n,r,!0)}(s),function(t,r){for(var e=wt(r),n=0;n<e.length;n++)for(var o=e[n][0],i=e[n][1],a=-2;2>=a;a++)for(var u=-2;2>=u;u++)-2==a||2==a||-2==u||2==u||0==a&&0==u?t.set(o+a,i+u,!0,!0):t.set(o+a,i+u,!1,!0)}(s,e),Tr(s,n,0),7<=e&&Br(s,e),function(t,r){for(var e=t.size,n=-1,o=e-1,i=7,a=0,u=e-1;0<u;u-=2)for(6==u&&u--;;){for(var f=0;2>f;f++)if(!t.isReserved(o,u-f)){var s=!1;a<r.length&&(s=1==(1&r[a]>>>i)),t.set(o,u-f,s),-1==--i&&(a++,i=7)}if(0>(o+=n)||e<=o){o-=n,n=-n;break}}}(s,f),isNaN(o)&&(o=function(t,r){for(var e=Object.keys(mt).length,n=0,o=1/0,i=0;i<e;i++){r(i),_t(i,t);var a=At(t)+Rt(t)+Bt(t)+Tt(t);_t(i,t),a<o&&(o=a,n=i)}return n}(s,Tr.bind(null,s,n))),_t(o,s),Tr(s,n,o),{modules:s,version:e,errorCorrectionLevel:n,maskPattern:o,segments:i}}function Lr(t,r){if(void 0===t||""===t)throw new Error("No input text");var e,n,o,i,a=ct;return void 0!==r&&(a=pt(r.errorCorrectionLevel,ct),e=Ot(o=r.version)?parseInt(o,10):i,n=bt(r.maskPattern),r.toSJISFunc&&function(t){if("function"!=typeof t)throw new Error('"toSJISFunc" is not a valid function.');et=t}(r.toSJISFunc)),_r(t,e,a,n)}function Ur(t){if("number"==typeof t&&(t=t.toString()),"string"!=typeof t)throw new Error("Color should be defined as hex string");var r=t.slice().replace("#","").split("");if(3>r.length||5===r.length||8<r.length)throw new Error("Invalid hex color: ".concat(t));(3===r.length||4===r.length)&&(r=Array.prototype.concat.apply([],r.map(function(t){return[t,t]}))),6===r.length&&r.push("F","F");var e=parseInt(r.join(""),16);return{r:255&e>>24,g:255&e>>16,b:255&e>>8,a:255&e,hex:"#".concat(r.slice(0,6).join(""))}}function Ir(t){t||(t={}),t.color||(t.color={});var r=void 0===t.margin||null===t.margin||0>t.margin?4:t.margin,e=t.width&&21<=t.width?t.width:void 0,n=t.scale||4;return{width:e,scale:e?4:n,margin:r,color:{dark:Ur(t.color.dark||"#000000ff"),light:Ur(t.color.light||"#ffffffff")},type:t.type,rendererOpts:t.rendererOpts||{}}}function Sr(t,r){return r.width&&r.width>=t+2*r.margin?r.width/(t+2*r.margin):r.scale}function Mr(t,r){var e=t.a/255,n="".concat(r,'="').concat(t.hex,'"');return 1>e?"".concat(n," ").concat(r,'-opacity="').concat(e.toFixed(2).slice(1),'"'):n}function Cr(t,r,e){var n=t+r;return void 0!==e&&(n+=" ".concat(e)),n}gr.getBitsLength=function(t){return 11*Math.floor(t/2)+t%2*6},gr.prototype.getLength=function(){return this.data.length},gr.prototype.getBitsLength=function(){return gr.getBitsLength(this.data.length)},gr.prototype.write=function(t){var r;for(r=0;r+2<=this.data.length;r+=2){var e=45*lr.indexOf(this.data[r]);e+=lr.indexOf(this.data[r+1]),t.put(e,11)}this.data.length%2&&t.put(lr.indexOf(this.data[r]),6)},pr.getBitsLength=function(t){return 8*t},pr.prototype.getLength=function(){return this.data.length},pr.prototype.getBitsLength=function(){return pr.getBitsLength(this.data.length)},pr.prototype.write=function(t){for(var r=0,e=this.data.length;r<e;r++)t.put(this.data[r],8)},dr.getBitsLength=function(t){return 13*t},dr.prototype.getLength=function(){return this.data.length},dr.prototype.getBitsLength=function(){return dr.getBitsLength(this.data.length)},dr.prototype.write=function(t){var r;for(r=0;r<this.data.length;r++){var e=st(this.data[r]);if(33088<=e&&40956>=e)e-=33088;else{if(!(57408<=e&&60351>=e))throw new Error("Invalid SJIS character: ".concat(this.data[r],"\n")+"Make sure your charset is UTF-8");e-=49472}e=192*(255&e>>>8)+(255&e),t.put(e,13)}};var Nr=Object.freeze({render:function(t,r,e){var n=Ir(r),o=t.modules.size,i=t.modules.data,a=o+2*n.margin,u=n.color.light.a?"<path ".concat(Mr(n.color.light,"fill"),' d="M0 0h').concat(a,"v").concat(a,'H0z"/>'):"",f="<path ".concat(Mr(n.color.dark,"stroke"),' d="').concat(function(t,r,e){for(var n="",o=0,i=!1,a=0,u=0;u<t.length;u++){var f=Math.floor(u%r),s=Math.floor(u/r);f||i||(i=!0),t[u]?(a++,!(0<u&&0<f&&t[u-1])&&(n+=i?Cr("M",f+e,.5+s+e):Cr("m",o,0),o=0,i=!1),!(f+1<r&&t[u+1])&&(n+=Cr("h",a),a=0)):o++}return n}(i,o,n.margin),'"/>'),s="".concat('viewBox="0 0 ').concat(a," ").concat(a,'"'),h=n.width?'width="'.concat(n.width,'" height="').concat(n.width,'" '):"",c='<svg xmlns="http://www.w3.org/2000/svg" '.concat(h).concat(s,' shape-rendering="crispEdges">').concat(u).concat(f,"</svg>\n");return"function"==typeof e&&e(null,c),c}}),xr={WW:" ",WB:"▄",BB:"█",BW:"▀"},Or={BB:" ",BW:"▄",WW:"█",WB:"▀"};function Yr(t,r,e){return t&&r?e.BB:t&&!r?e.BW:!t&&r?e.WB:e.WW}var kr=Object.freeze({render:function(t,r,e){var n=Ir(r),o=xr;("#ffffff"===n.color.dark.hex||"#000000"===n.color.light.hex)&&(o=Or);var i=t.modules.size,a=t.modules.data,u="",f=Array(i+2*n.margin+1).join(o.WW);f=Array(n.margin/2+1).join("".concat(f,"\n"));var s=Array(n.margin+1).join(o.WW);u+=f;for(var h=0;h<i;h+=2){u+=s;for(var c=0;c<i;c++)u+=Yr(a[h*i+c],a[(h+1)*i+c],o);u+="".concat(s,"\n")}return u+=f.slice(0,-1),"function"==typeof e&&e(null,u),u}}),Dr=n.PNG;function zr(t,r){var e=Ir(r),n=e.rendererOpts,o=function(t,r){var e=Sr(t,r);return Math.floor((t+2*r.margin)*e)}(t.modules.size,e);n.width=o,n.height=o;var i=new Dr(n);return function(t,r,e){for(var n=r.modules.size,o=r.modules.data,i=Sr(n,e),a=Math.floor((n+2*e.margin)*i),u=e.margin*i,f=[e.color.light,e.color.dark],s=0;s<a;s++)for(var h=0;h<a;h++){var c=4*(s*a+h),l=e.color.light;s>=u&&h>=u&&s<a-u&&h<a-u&&(l=f[o[Math.floor((s-u)/i)*n+Math.floor((h-u)/i)]?1:0]),t[c++]=l.r,t[c++]=l.g,t[c++]=l.b,t[c]=l.a}}(i.data,t,e),i}function Fr(t,r,e){void 0===e&&(e=r,r=void 0);var n=zr(t,r),o=[];n.on("error",e),n.on("data",function(t){o.push(t)}),n.on("end",function(){e(null,y.concat(o))}),n.pack()}var jr=Object.freeze({render:zr,renderToDataURL:function(t,r,e){void 0===e&&(e=r,r=void 0),Fr(t,r,function(t,r){t&&e(t);var n="data:image/png;base64,";n+=r.toString("base64"),e(null,n)})},renderToBuffer:Fr,renderToFileStream:function(t,r,e){zr(r,e).pack().pipe(t)}});function Wr(t,r,e){if(void 0===t)throw new Error("String required as first argument");if(void 0===e&&(e=r,r={}),"function"!=typeof e){if("function"!=typeof Promise||!Promise.prototype||!Promise.prototype.then)throw new Error("Callback required as last argument");r=e||{},e=null}return{opts:r,cb:e}}function qr(t){switch(t){case"svg":return Nr;case"txt":case"utf8":return kr;case"png":case"image/png":default:return jr}}function $r(t,r,e){if(!e.cb)return new Promise(function(n,o){try{var i=Lr(r,e.opts);return t(i,e.opts,function(t,r){return t?o(t):n(r)})}catch(t){o(t)}});try{var n=Lr(r,e.opts);return t(n,e.opts,e.cb)}catch(t){e.cb(t)}}var Qr=Lr;function Jr(t,r,e){var n=Wr(t,r,e);return $r(function(t){switch(t){case"svg":return Nr;case"utf8":default:return kr}}(n.opts.type).render,t,n)}function Zr(t,r,e){var n=Wr(t,r,e);return $r(qr(n.opts.type).renderToDataURL,t,n)}function Vr(t,r,e){var n=Wr(t,r,e);return $r(qr(n.opts.type).renderToBuffer,t,n)}function Gr(t,r,e){var n=Wr(t,r,e),o=n.cb;return n.cb=function(t,r){o(t,"data:image/svg+xml;utf8,".concat(encodeURIComponent(r)))},$r(qr("svg").render,t,n)}function Hr(t,r,e){var n=Wr(t,r,e);return $r(qr("svg").render,t,n)}var Kr={create:Qr,toDataURL:Zr,toBuffer:Vr,getSvgDataURL:Gr,toString:Jr,getSvg:Hr};t.create=Qr,t.default=Kr,t.getSvg=Hr,t.getSvgDataURL=Gr,t.toBuffer=Vr,t.toDataURL=Zr,t.toString=Jr,Object.defineProperty(t,"__esModule",{value:!0})});
//# sourceMappingURL=cnf-qrcode.common.js.map