@qr-platform/qr-code.js
Version:
QRCode.js is a professional JavaScript/TypeScript library for creating customized QR codes, offering a blend of simplicity and sophistication. With versatile styling options—dot shapes, colors, gradients, embedded images, borders, and text—it enables you
1 lines • 82.7 kB
JavaScript
import{Resvg as t}from"@resvg/resvg-js";import{CustomError as e}from"ts-custom-error";import{Image as r}from"image-js";class n extends e{constructor(t=void 0){super(t),this.message=t}getKind(){return this.constructor.kind}}n.kind="Exception";class i extends n{static getNotFoundInstance(){return new i}}var s,o,a,h,l,c,u;i.kind="NotFoundException",function(t){t[t.AZTEC=0]="AZTEC",t[t.CODABAR=1]="CODABAR",t[t.CODE_39=2]="CODE_39",t[t.CODE_93=3]="CODE_93",t[t.CODE_128=4]="CODE_128",t[t.DATA_MATRIX=5]="DATA_MATRIX",t[t.EAN_8=6]="EAN_8",t[t.EAN_13=7]="EAN_13",t[t.ITF=8]="ITF",t[t.MAXICODE=9]="MAXICODE",t[t.PDF_417=10]="PDF_417",t[t.QR_CODE=11]="QR_CODE",t[t.RSS_14=12]="RSS_14",t[t.RSS_EXPANDED=13]="RSS_EXPANDED",t[t.UPC_A=14]="UPC_A",t[t.UPC_E=15]="UPC_E",t[t.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"}(s||(s={}));class w extends n{}w.kind="IllegalArgumentException";class f extends n{}f.kind="IndexOutOfBoundsException";class d extends f{constructor(t,e){super(e),this.index=t,this.message=e}}d.kind="ArrayIndexOutOfBoundsException";class g{static arraycopy(t,e,r,n,i){if(t===r&&e<n)for(n+=i-1,e+=i-1;i--;)r[n--]=t[e--];else for(;i--;)r[n++]=t[e++]}static currentTimeMillis(){return Date.now()}}class I{static fill(t,e){for(let r=0,n=t.length;r<n;r++)t[r]=e}static fillWithin(t,e,r,n){I.rangeCheck(t.length,e,r);for(let i=e;i<r;i++)t[i]=n}static rangeCheck(t,e,r){if(e>r)throw new w("fromIndex("+e+") > toIndex("+r+")");if(e<0)throw new d(e);if(r>t)throw new d(r)}static asList(...t){return t}static create(t,e,r){return Array.from({length:t}).map((t=>Array.from({length:e}).fill(r)))}static createInt32Array(t,e,r){return Array.from({length:t}).map((t=>Int32Array.from({length:e}).fill(r)))}static equals(t,e){if(!t)return!1;if(!e)return!1;if(!t.length)return!1;if(!e.length)return!1;if(t.length!==e.length)return!1;for(let r=0,n=t.length;r<n;r++)if(t[r]!==e[r])return!1;return!0}static hashCode(t){if(null===t)return 0;let e=1;for(const r of t)e=31*e+r;return e}static fillUint8Array(t,e){for(let r=0;r!==t.length;r++)t[r]=e}static copyOf(t,e){return t.slice(0,e)}static copyOfUint8Array(t,e){if(t.length<=e){const r=new Uint8Array(e);return r.set(t),r}return t.slice(0,e)}static copyOfRange(t,e,r){const n=r-e,i=new Int32Array(n);return g.arraycopy(t,e,i,0,n),i}static binarySearch(t,e,r){void 0===r&&(r=I.numberComparator);let n=0,i=t.length-1;for(;n<=i;){const s=i+n>>1,o=r(e,t[s]);if(o>0)n=s+1;else{if(!(o<0))return s;i=s-1}}return-n-1}static numberComparator(t,e){return t-e}}!function(t){t[t.OTHER=0]="OTHER",t[t.PURE_BARCODE=1]="PURE_BARCODE",t[t.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",t[t.TRY_HARDER=3]="TRY_HARDER",t[t.CHARACTER_SET=4]="CHARACTER_SET",t[t.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",t[t.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",t[t.ENABLE_CODE_39_EXTENDED_MODE=7]="ENABLE_CODE_39_EXTENDED_MODE",t[t.ASSUME_GS1=8]="ASSUME_GS1",t[t.RETURN_CODABAR_START_END=9]="RETURN_CODABAR_START_END",t[t.NEED_RESULT_POINT_CALLBACK=10]="NEED_RESULT_POINT_CALLBACK",t[t.ALLOWED_EAN_EXTENSIONS=11]="ALLOWED_EAN_EXTENSIONS"}(o||(o={}));class m extends n{static getFormatInstance(){return new m}}m.kind="FormatException",function(t){t[t.Cp437=0]="Cp437",t[t.ISO8859_1=1]="ISO8859_1",t[t.ISO8859_2=2]="ISO8859_2",t[t.ISO8859_3=3]="ISO8859_3",t[t.ISO8859_4=4]="ISO8859_4",t[t.ISO8859_5=5]="ISO8859_5",t[t.ISO8859_6=6]="ISO8859_6",t[t.ISO8859_7=7]="ISO8859_7",t[t.ISO8859_8=8]="ISO8859_8",t[t.ISO8859_9=9]="ISO8859_9",t[t.ISO8859_10=10]="ISO8859_10",t[t.ISO8859_11=11]="ISO8859_11",t[t.ISO8859_13=12]="ISO8859_13",t[t.ISO8859_14=13]="ISO8859_14",t[t.ISO8859_15=14]="ISO8859_15",t[t.ISO8859_16=15]="ISO8859_16",t[t.SJIS=16]="SJIS",t[t.Cp1250=17]="Cp1250",t[t.Cp1251=18]="Cp1251",t[t.Cp1252=19]="Cp1252",t[t.Cp1256=20]="Cp1256",t[t.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",t[t.UTF8=22]="UTF8",t[t.ASCII=23]="ASCII",t[t.Big5=24]="Big5",t[t.GB18030=25]="GB18030",t[t.EUC_KR=26]="EUC_KR"}(a||(a={}));class A{constructor(t,e,r,...n){this.valueIdentifier=t,this.name=r,this.values="number"==typeof e?Int32Array.from([e]):e,this.otherEncodingNames=n,A.VALUE_IDENTIFIER_TO_ECI.set(t,this),A.NAME_TO_ECI.set(r,this);const i=this.values;for(let t=0,e=i.length;t!==e;t++){const e=i[t];A.VALUES_TO_ECI.set(e,this)}for(const t of n)A.NAME_TO_ECI.set(t,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(t){if(t<0||t>=900)throw new m("incorect value");const e=A.VALUES_TO_ECI.get(t);if(void 0===e)throw new m("incorect value");return e}static getCharacterSetECIByName(t){const e=A.NAME_TO_ECI.get(t);if(void 0===e)throw new m("incorect value");return e}equals(t){if(!(t instanceof A))return!1;const e=t;return this.getName()===e.getName()}}A.VALUE_IDENTIFIER_TO_ECI=new Map,A.VALUES_TO_ECI=new Map,A.NAME_TO_ECI=new Map,A.Cp437=new A(a.Cp437,Int32Array.from([0,2]),"Cp437"),A.ISO8859_1=new A(a.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),A.ISO8859_2=new A(a.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),A.ISO8859_3=new A(a.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),A.ISO8859_4=new A(a.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),A.ISO8859_5=new A(a.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),A.ISO8859_6=new A(a.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),A.ISO8859_7=new A(a.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),A.ISO8859_8=new A(a.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),A.ISO8859_9=new A(a.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),A.ISO8859_10=new A(a.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),A.ISO8859_11=new A(a.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),A.ISO8859_13=new A(a.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),A.ISO8859_14=new A(a.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),A.ISO8859_15=new A(a.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),A.ISO8859_16=new A(a.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),A.SJIS=new A(a.SJIS,20,"SJIS","Shift_JIS"),A.Cp1250=new A(a.Cp1250,21,"Cp1250","windows-1250"),A.Cp1251=new A(a.Cp1251,22,"Cp1251","windows-1251"),A.Cp1252=new A(a.Cp1252,23,"Cp1252","windows-1252"),A.Cp1256=new A(a.Cp1256,24,"Cp1256","windows-1256"),A.UnicodeBigUnmarked=new A(a.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),A.UTF8=new A(a.UTF8,26,"UTF8","UTF-8"),A.ASCII=new A(a.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),A.Big5=new A(a.Big5,28,"Big5"),A.GB18030=new A(a.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),A.EUC_KR=new A(a.EUC_KR,30,"EUC_KR","EUC-KR");class S extends n{}S.kind="UnsupportedOperationException";class C{static decode(t,e){const r=this.encodingName(e);return this.customDecoder?this.customDecoder(t,r):"undefined"==typeof TextDecoder||this.shouldDecodeOnFallback(r)?this.decodeFallback(t,r):new TextDecoder(r).decode(t)}static shouldDecodeOnFallback(t){return!C.isBrowser()&&"ISO-8859-1"===t}static encode(t,e){const r=this.encodingName(e);return this.customEncoder?this.customEncoder(t,r):"undefined"==typeof TextEncoder?this.encodeFallback(t):(new TextEncoder).encode(t)}static isBrowser(){return"undefined"!=typeof window&&"[object Window]"==={}.toString.call(window)}static encodingName(t){return"string"==typeof t?t:t.getName()}static encodingCharacterSet(t){return t instanceof A?t:A.getCharacterSetECIByName(t)}static decodeFallback(t,e){const r=this.encodingCharacterSet(e);if(C.isDecodeFallbackSupported(r)){let e="";for(let r=0,n=t.length;r<n;r++){let n=t[r].toString(16);n.length<2&&(n="0"+n),e+="%"+n}return decodeURIComponent(e)}if(r.equals(A.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(t.buffer));throw new S(`Encoding ${this.encodingName(e)} not supported by fallback.`)}static isDecodeFallbackSupported(t){return t.equals(A.UTF8)||t.equals(A.ISO8859_1)||t.equals(A.ASCII)}static encodeFallback(t){const e=btoa(unescape(encodeURIComponent(t))).split(""),r=[];for(let t=0;t<e.length;t++)r.push(e[t].charCodeAt(0));return new Uint8Array(r)}}class E{static castAsNonUtf8Char(t,e=null){const r=e?e.getName():this.ISO88591;return C.decode(new Uint8Array([t]),r)}static guessEncoding(t,e){if(null!=e&&void 0!==e.get(o.CHARACTER_SET))return e.get(o.CHARACTER_SET).toString();const r=t.length;let n=!0,i=!0,s=!0,a=0,h=0,l=0,c=0,u=0,w=0,f=0,d=0,g=0,I=0,m=0;const A=t.length>3&&239===t[0]&&187===t[1]&&191===t[2];for(let e=0;e<r&&(n||i||s);e++){const r=255&t[e];s&&(a>0?128&r?a--:s=!1:128&r&&(64&r?(a++,32&r?(a++,16&r?(a++,8&r?s=!1:c++):l++):h++):s=!1)),n&&(r>127&&r<160?n=!1:r>159&&(r<192||215===r||247===r)&&m++),i&&(u>0?r<64||127===r||r>252?i=!1:u--:128===r||160===r||r>239?i=!1:r>160&&r<224?(w++,d=0,f++,f>g&&(g=f)):r>127?(u++,f=0,d++,d>I&&(I=d)):(f=0,d=0))}return s&&a>0&&(s=!1),i&&u>0&&(i=!1),s&&(A||h+l+c>0)?E.UTF8:i&&(E.ASSUME_SHIFT_JIS||g>=3||I>=3)?E.SHIFT_JIS:n&&i?2===g&&2===w||10*m>=r?E.SHIFT_JIS:E.ISO88591:n?E.ISO88591:i?E.SHIFT_JIS:s?E.UTF8:E.PLATFORM_DEFAULT_ENCODING}static format(t,...e){let r=-1;return t.replace(/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g,(function(t,n,i,s,o,a){if("%%"===t)return"%";if(void 0===e[++r])return;t=s?parseInt(s.substr(1)):void 0;let h,l=o?parseInt(o.substr(1)):void 0;switch(a){case"s":h=e[r];break;case"c":h=e[r][0];break;case"f":h=parseFloat(e[r]).toFixed(t);break;case"p":h=parseFloat(e[r]).toPrecision(t);break;case"e":h=parseFloat(e[r]).toExponential(t);break;case"x":h=parseInt(e[r]).toString(l||16);break;case"d":h=parseFloat(parseInt(e[r],l||10).toPrecision(t)).toFixed(0)}h="object"==typeof h?JSON.stringify(h):(+h).toString(l);let c=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;h.length<c;)h=void 0!==n?h+u:u+h;return h}))}static getBytes(t,e){return C.encode(t,e)}static getCharCode(t,e=0){return t.charCodeAt(e)}static getCharAt(t){return String.fromCharCode(t)}}E.SHIFT_JIS=A.SJIS.getName(),E.GB2312="GB2312",E.ISO88591=A.ISO8859_1.getName(),E.EUC_JP="EUC_JP",E.UTF8=A.UTF8.getName(),E.PLATFORM_DEFAULT_ENCODING=E.UTF8,E.ASSUME_SHIFT_JIS=!1;class _{constructor(t=""){this.value=t}enableDecoding(t){return this.encoding=t,this}append(t){return"string"==typeof t?this.value+=t.toString():this.encoding?this.value+=E.castAsNonUtf8Char(t,this.encoding):this.value+=String.fromCharCode(t),this}appendChars(t,e,r){for(let n=e;e<e+r;n++)this.append(t[n]);return this}length(){return this.value.length}charAt(t){return this.value.charAt(t)}deleteCharAt(t){this.value=this.value.substr(0,t)+this.value.substring(t+1)}setCharAt(t,e){this.value=this.value.substr(0,t)+e+this.value.substr(t+1)}substring(t,e){return this.value.substring(t,e)}setLengthToZero(){this.value=""}toString(){return this.value}insert(t,e){this.value=this.value.substring(0,t)+e+this.value.substring(t)}}class p{static numberOfTrailingZeros(t){let e;if(0===t)return 32;let r=31;return e=t<<16,0!==e&&(r-=16,t=e),e=t<<8,0!==e&&(r-=8,t=e),e=t<<4,0!==e&&(r-=4,t=e),e=t<<2,0!==e&&(r-=2,t=e),r-(t<<1>>>31)}static numberOfLeadingZeros(t){if(0===t)return 32;let e=1;return t>>>16==0&&(e+=16,t<<=16),t>>>24==0&&(e+=8,t<<=8),t>>>28==0&&(e+=4,t<<=4),t>>>30==0&&(e+=2,t<<=2),e-=t>>>31,e}static toHexString(t){return t.toString(16)}static toBinaryString(t){return String(parseInt(String(t),2))}static bitCount(t){return t=(t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135,t+=t>>>8,63&(t+=t>>>16)}static truncDivision(t,e){return Math.trunc(t/e)}static parseInt(t,e=void 0){return parseInt(t,e)}}p.MIN_VALUE_32_BITS=-2147483648,p.MAX_VALUE=Number.MAX_SAFE_INTEGER;class M{constructor(t,e){void 0===t?(this.size=0,this.bits=new Int32Array(1)):(this.size=t,this.bits=e??M.makeArray(t))}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(t){if(t>32*this.bits.length){const e=M.makeArray(t);g.arraycopy(this.bits,0,e,0,this.bits.length),this.bits=e}}get(t){return!!(this.bits[Math.floor(t/32)]&1<<(31&t))}set(t){this.bits[Math.floor(t/32)]|=1<<(31&t)}flip(t){this.bits[Math.floor(t/32)]^=1<<(31&t)}getNextSet(t){const e=this.size;if(t>=e)return e;const r=this.bits;let n=Math.floor(t/32),i=r[n];i&=~((1<<(31&t))-1);const s=r.length;for(;0===i;){if(++n===s)return e;i=r[n]}const o=32*n+p.numberOfTrailingZeros(i);return o>e?e:o}getNextUnset(t){const e=this.size;if(t>=e)return e;const r=this.bits;let n=Math.floor(t/32),i=~r[n];i&=~((1<<(31&t))-1);const s=r.length;for(;0===i;){if(++n===s)return e;i=~r[n]}const o=32*n+p.numberOfTrailingZeros(i);return o>e?e:o}setBulk(t,e){this.bits[Math.floor(t/32)]=e}setRange(t,e){if(e<t||t<0||e>this.size)throw new w;if(e===t)return;e--;const r=Math.floor(t/32),n=Math.floor(e/32),i=this.bits;for(let s=r;s<=n;s++){const o=(2<<(s<n?31:31&e))-(1<<(s>r?0:31&t));i[s]|=o}}clear(){const t=this.bits.length,e=this.bits;for(let r=0;r<t;r++)e[r]=0}isRange(t,e,r){if(e<t||t<0||e>this.size)throw new w;if(e===t)return!0;e--;const n=Math.floor(t/32),i=Math.floor(e/32),s=this.bits;for(let o=n;o<=i;o++){const a=(2<<(o<i?31:31&e))-(1<<(o>n?0:31&t))&4294967295;if((s[o]&a)!==(r?a:0))return!1}return!0}appendBit(t){this.ensureCapacity(this.size+1),t&&(this.bits[Math.floor(this.size/32)]|=1<<(31&this.size)),this.size++}appendBits(t,e){if(e<0||e>32)throw new w("Num bits must be between 0 and 32");this.ensureCapacity(this.size+e);for(let r=e;r>0;r--)this.appendBit(1==(t>>r-1&1))}appendBitArray(t){const e=t.size;this.ensureCapacity(this.size+e);for(let r=0;r<e;r++)this.appendBit(t.get(r))}xor(t){if(this.size!==t.size)throw new w("Sizes don't match");const e=this.bits;for(let r=0,n=e.length;r<n;r++)e[r]^=t.bits[r]}toBytes(t,e,r,n){for(let i=0;i<n;i++){let n=0;for(let e=0;e<8;e++)this.get(t)&&(n|=1<<7-e),t++;e[r+i]=n}}getBitArray(){return this.bits}reverse(){const t=new Int32Array(this.bits.length),e=Math.floor((this.size-1)/32),r=e+1,n=this.bits;for(let i=0;i<r;i++){let r=n[i];r=r>>1&1431655765|(1431655765&r)<<1,r=r>>2&858993459|(858993459&r)<<2,r=r>>4&252645135|(252645135&r)<<4,r=r>>8&16711935|(16711935&r)<<8,r=r>>16&65535|(65535&r)<<16,t[e-i]=r}if(this.size!==32*r){const e=32*r-this.size;let n=t[0]>>>e;for(let i=1;i<r;i++){const r=t[i];n|=r<<32-e,t[i-1]=n,n=r>>>e}t[r-1]=n}this.bits=t}static makeArray(t){return new Int32Array(Math.floor((t+31)/32))}equals(t){if(!(t instanceof M))return!1;const e=t;return this.size===e.size&&I.equals(this.bits,e.bits)}hashCode(){return 31*this.size+I.hashCode(this.bits)}toString(){let t="";for(let e=0,r=this.size;e<r;e++)7&e||(t+=" "),t+=this.get(e)?"X":".";return t}clone(){return new M(this.size,this.bits.slice())}toArray(){let t=[];for(let e=0,r=this.size;e<r;e++)t.push(this.get(e));return t}}class O{constructor(t,e,r,n){if(this.width=t,this.height=e,this.rowSize=r,this.bits=n,null==e&&(e=t),this.height=e,t<1||e<1)throw new w("Both dimensions must be greater than 0");null==r&&(r=(t+31)/32|0),this.rowSize=r,null==n&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(t){const e=t.length,r=t[0].length,n=new O(r,e);for(let i=0;i<e;i++){const e=t[i];for(let t=0;t<r;t++)e[t]&&n.set(t,i)}return n}static parseFromString(t,e,r){if(null===t)throw new w("stringRepresentation cannot be null");const n=new Array(t.length);let i=0,s=0,o=-1,a=0,h=0;for(;h<t.length;){const l=t.charAt(h);if("\n"===l||"\r"===l){if(i>s){if(-1===o)o=i-s;else if(i-s!==o)throw new w("row lengths do not match");s=i,a++}h++}else if(t.substring(h,h+e.length)===e)h+=e.length,n[i++]=!0;else{if(t.substring(h,h+r.length)!==r)throw new w("illegal character encountered: "+t.substring(h));h+=r.length,n[i++]=!1}}if(i>s){if(-1===o)o=i-s;else if(i-s!==o)throw new w("row lengths do not match");a++}const l=new O(o,a);for(let t=0;t<i;t++)n[t]&&l.set(t%o,Math.floor(t/o));return l}get(t,e){const r=e*this.rowSize+(t>>5);return!!(this.bits[r]>>>(31&t)&1)}set(t,e){const r=e*this.rowSize+(t>>5);this.bits[r]|=1<<(31&t)}unset(t,e){const r=e*this.rowSize+(t>>5);this.bits[r]&=~(1<<(31&t))}flip(t,e){const r=e*this.rowSize+(t>>5);this.bits[r]^=1<<(31&t)}xor(t){if(this.width!==t.getWidth()||this.height!==t.getHeight()||this.rowSize!==t.getRowSize())throw new w("input matrix dimensions do not match");const e=new M(1+(this.width>>5)),r=this.rowSize,n=this.bits;for(let i=0,s=this.height;i<s;i++){const s=i*r,o=t.getRow(i,e).getBitArray();for(let t=0;t<r;t++)n[s+t]^=o[t]}}clear(){const t=this.bits,e=t.length;for(let r=0;r<e;r++)t[r]=0}setRegion(t,e,r,n){if(e<0||t<0)throw new w("Left and top must be nonnegative");if(n<1||r<1)throw new w("Height and width must be at least 1");const i=t+r,s=e+n;if(s>this.height||i>this.width)throw new w("The region must fit inside the matrix");const o=this.rowSize,a=this.bits;for(let r=e;r<s;r++){const e=r*o;for(let r=t;r<i;r++)a[e+(r>>5)]|=1<<(31&r)}}getRow(t,e){null==e||e.getSize()<this.width?e=new M(this.width):e.clear();const r=this.rowSize,n=this.bits,i=t*r;for(let t=0;t<r;t++)e.setBulk(32*t,n[i+t]);return e}setRow(t,e){g.arraycopy(e.getBitArray(),0,this.bits,t*this.rowSize,this.rowSize)}rotate180(){const t=this.getWidth(),e=this.getHeight();let r=new M(t),n=new M(t);for(let t=0,i=Math.floor((e+1)/2);t<i;t++)r=this.getRow(t,r),n=this.getRow(e-1-t,n),r.reverse(),n.reverse(),this.setRow(t,n),this.setRow(e-1-t,r)}getEnclosingRectangle(){const t=this.width,e=this.height,r=this.rowSize,n=this.bits;let i=t,s=e,o=-1,a=-1;for(let t=0;t<e;t++)for(let e=0;e<r;e++){const h=n[t*r+e];if(0!==h){if(t<s&&(s=t),t>a&&(a=t),32*e<i){let t=0;for(;h<<31-t>>>0==0;)t++;32*e+t<i&&(i=32*e+t)}if(32*e+31>o){let t=31;for(;h>>>t==0;)t--;32*e+t>o&&(o=32*e+t)}}}return o<i||a<s?null:Int32Array.from([i,s,o-i+1,a-s+1])}getTopLeftOnBit(){const t=this.rowSize,e=this.bits;let r=0;for(;r<e.length&&0===e[r];)r++;if(r===e.length)return null;const n=Math.floor(r/t);let i=r%t<<5;const s=e[r];let o=0;for(;s<<31-o>>>0==0;)o++;return i+=o,Int32Array.from([i,n])}getBottomRightOnBit(){const t=this.rowSize,e=this.bits;let r=e.length-1;for(;r>=0&&0===e[r];)r--;if(r<0)return null;const n=Math.floor(r/t);let i=r%t<<5;const s=e[r];let o=31;for(;s>>>o==0;)o--;return i+=o,Int32Array.from([i,n])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(t){if(!(t instanceof O))return!1;const e=t;return this.width===e.width&&this.height===e.height&&this.rowSize===e.rowSize&&I.equals(this.bits,e.bits)}hashCode(){let t=this.width;return t=31*t+this.height,t=31*t+this.rowSize,t=31*t+I.hashCode(this.bits),t}toString(t="X ",e=" ",r="\n"){return this.buildToString(t,e,r)}buildToString(t,e,r){const n=new _,i=this.height,s=this.width;if(void 0===i||void 0===s)throw new Error("Matrix dimensions are undefined");for(let o=0;o<i;o++){for(let r=0;r<s;r++)n.append(this.get(r,o)?t:e);n.append(r)}return n.toString()}clone(){return new O(this.width,this.height,this.rowSize,this.bits.slice())}}class N{constructor(t=null,e,r=(null==e?0:8*e.length),n,i,s=g.currentTimeMillis()){this.text=t,this.rawBytes=e,this.numBits=r,this.resultPoints=n,this.format=i,this.timestamp=s,this.text=t,this.rawBytes=e,this.numBits=r??(null==e?0:8*e.length),this.resultPoints=n,this.format=i,this.resultMetadata=new Map,this.timestamp=s??g.currentTimeMillis()}getText(){return this.text?this.text:null}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(t,e){null===this.resultMetadata&&(this.resultMetadata=new Map),this.resultMetadata.set(t,e)}putAllMetadata(t){null!==t&&(null===this.resultMetadata?this.resultMetadata=t:this.resultMetadata=new Map(t))}addResultPoints(t){const e=this.resultPoints;if(null===e)this.resultPoints=t;else if(null!==t&&t.length>0){const r=new Array(e.length+t.length);g.arraycopy(e,0,r,0,e.length),g.arraycopy(t,0,r,e.length,t.length),this.resultPoints=r}}getTimestamp(){return this.timestamp}toString(){return null===this.text?this.resultPoints.toString():this.text}}!function(t){t[t.OTHER=0]="OTHER",t[t.ORIENTATION=1]="ORIENTATION",t[t.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",t[t.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",t[t.ISSUE_NUMBER=4]="ISSUE_NUMBER",t[t.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",t[t.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",t[t.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",t[t.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",t[t.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",t[t.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"}(h||(h={}));class T extends n{static getChecksumInstance(){return new T}}T.kind="ChecksumException";class y extends n{}y.kind="ArithmeticException";class b{exp(t){return this.expTable[t]}log(t){if(0===t)throw new w;return this.logTable[t]}static addOrSubtract(t,e){return t^e}}class R{constructor(t,e){if(0===e.length)throw new w;this.field=t;const r=e.length;if(r>1&&0===e[0]){let t=1;for(;t<r&&0===e[t];)t++;t===r?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(r-t),g.arraycopy(e,t,this.coefficients,0,this.coefficients.length))}else this.coefficients=e}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return 0===this.coefficients[0]}getCoefficient(t){return this.coefficients[this.coefficients.length-1-t]}evaluateAt(t){if(0===t)return this.getCoefficient(0);const e=this.coefficients;let r;if(1===t){r=0;for(let t=0,n=e.length;t!==n;t++){const n=e[t];r=b.addOrSubtract(r,n)}return r}r=e[0];const n=e.length,i=this.field;for(let s=1;s<n;s++)r=b.addOrSubtract(i.multiply(t,r),e[s]);return r}addOrSubtract(t){if(!this.field.equals(t.field))throw new w("GenericGFPolys do not have same GenericGF field");if(this.isZero())return t;if(t.isZero())return this;let e=this.coefficients,r=t.coefficients;if(e.length>r.length){const t=e;e=r,r=t}let n=new Int32Array(r.length);const i=r.length-e.length;g.arraycopy(r,0,n,0,i);for(let t=i;t<r.length;t++)n[t]=b.addOrSubtract(e[t-i],r[t]);return new R(this.field,n)}multiply(t){if(!this.field.equals(t.field))throw new w("GenericGFPolys do not have same GenericGF field");if(this.isZero()||t.isZero())return this.field.getZero();const e=this.coefficients,r=e.length,n=t.coefficients,i=n.length,s=new Int32Array(r+i-1),o=this.field;for(let t=0;t<r;t++){const r=e[t];for(let e=0;e<i;e++)s[t+e]=b.addOrSubtract(s[t+e],o.multiply(r,n[e]))}return new R(o,s)}multiplyScalar(t){if(0===t)return this.field.getZero();if(1===t)return this;const e=this.coefficients.length,r=this.field,n=new Int32Array(e),i=this.coefficients;for(let s=0;s<e;s++)n[s]=r.multiply(i[s],t);return new R(r,n)}multiplyByMonomial(t,e){if(t<0)throw new w;if(0===e)return this.field.getZero();const r=this.coefficients,n=r.length,i=new Int32Array(n+t),s=this.field;for(let t=0;t<n;t++)i[t]=s.multiply(r[t],e);return new R(s,i)}divide(t){if(!this.field.equals(t.field))throw new w("GenericGFPolys do not have same GenericGF field");if(t.isZero())throw new w("Divide by 0");const e=this.field;let r=e.getZero(),n=this;const i=t.getCoefficient(t.getDegree()),s=e.inverse(i);for(;n.getDegree()>=t.getDegree()&&!n.isZero();){const i=n.getDegree()-t.getDegree(),o=e.multiply(n.getCoefficient(n.getDegree()),s),a=t.multiplyByMonomial(i,o),h=e.buildMonomial(i,o);r=r.addOrSubtract(h),n=n.addOrSubtract(a)}return[r,n]}toString(){let t="";for(let e=this.getDegree();e>=0;e--){let r=this.getCoefficient(e);if(0!==r){if(r<0?(t+=" - ",r=-r):t.length>0&&(t+=" + "),0===e||1!==r){const e=this.field.log(r);0===e?t+="1":1===e?t+="a":(t+="a^",t+=e)}0!==e&&(1===e?t+="x":(t+="x^",t+=e))}}return t}}class B extends b{constructor(t,e,r){super(),this.primitive=t,this.size=e,this.generatorBase=r;const n=new Int32Array(e);let i=1;for(let r=0;r<e;r++)n[r]=i,i*=2,i>=e&&(i^=t,i&=e-1);this.expTable=n;const s=new Int32Array(e);for(let t=0;t<e-1;t++)s[n[t]]=t;this.logTable=s,this.zero=new R(this,Int32Array.from([0])),this.one=new R(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(t,e){if(t<0)throw new w;if(0===e)return this.zero;const r=new Int32Array(t+1);return r[0]=e,new R(this,r)}inverse(t){if(0===t)throw new y;return this.expTable[this.size-this.logTable[t]-1]}multiply(t,e){return 0===t||0===e?0:this.expTable[(this.logTable[t]+this.logTable[e])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+p.toHexString(this.primitive)+","+this.size+")"}equals(t){return t===this}}B.AZTEC_DATA_12=new B(4201,4096,1),B.AZTEC_DATA_10=new B(1033,1024,1),B.AZTEC_DATA_6=new B(67,64,1),B.AZTEC_PARAM=new B(19,16,1),B.QR_CODE_FIELD_256=new B(285,256,0),B.DATA_MATRIX_FIELD_256=new B(301,256,1),B.AZTEC_DATA_8=B.DATA_MATRIX_FIELD_256,B.MAXICODE_FIELD_64=B.AZTEC_DATA_6;class D extends n{}D.kind="IllegalStateException";class P extends n{}P.kind="ReedSolomonException";class U{constructor(t){this.field=t}decode(t,e){const r=this.field,n=new R(r,t),i=new Int32Array(e);let s=!0;for(let t=0;t<e;t++){const e=n.evaluateAt(r.exp(t+r.getGeneratorBase()));i[i.length-1-t]=e,0!==e&&(s=!1)}if(s)return;const o=new R(r,i),a=this.runEuclideanAlgorithm(r.buildMonomial(e,1),o,e),h=a[0],l=a[1],c=this.findErrorLocations(h),u=this.findErrorMagnitudes(l,c);for(let e=0;e<c.length;e++){const n=t.length-1-r.log(c[e]);if(n<0)throw new P("Bad error location");t[n]=B.addOrSubtract(t[n],u[e])}}runEuclideanAlgorithm(t,e,r){if(t.getDegree()<e.getDegree()){const r=t;t=e,e=r}const n=this.field;let i=t,s=e,o=n.getZero(),a=n.getOne();for(;s.getDegree()>=(r/2|0);){let t=i,e=o;if(i=s,o=a,i.isZero())throw new P("r_{i-1} was zero");s=t;let r=n.getZero();const h=i.getCoefficient(i.getDegree()),l=n.inverse(h);for(;s.getDegree()>=i.getDegree()&&!s.isZero();){const t=s.getDegree()-i.getDegree(),e=n.multiply(s.getCoefficient(s.getDegree()),l);r=r.addOrSubtract(n.buildMonomial(t,e)),s=s.addOrSubtract(i.multiplyByMonomial(t,e))}if(a=r.multiply(o).addOrSubtract(e),s.getDegree()>=i.getDegree())throw new D("Division algorithm failed to reduce polynomial?")}const h=a.getCoefficient(0);if(0===h)throw new P("sigmaTilde(0) was zero");const l=n.inverse(h);return[a.multiplyScalar(l),s.multiplyScalar(l)]}findErrorLocations(t){const e=t.getDegree();if(1===e)return Int32Array.from([t.getCoefficient(1)]);const r=new Int32Array(e);let n=0;const i=this.field;for(let s=1;s<i.getSize()&&n<e;s++)0===t.evaluateAt(s)&&(r[n]=i.inverse(s),n++);if(n!==e)throw new P("Error locator degree does not match number of roots");return r}findErrorMagnitudes(t,e){const r=e.length,n=new Int32Array(r),i=this.field;for(let s=0;s<r;s++){const o=i.inverse(e[s]);let a=1;for(let t=0;t<r;t++)if(s!==t){const r=i.multiply(e[t],o),n=1&r?-2&r:1|r;a=i.multiply(a,n)}n[s]=i.multiply(t.evaluateAt(o),i.inverse(a)),0!==i.getGeneratorBase()&&(n[s]=i.multiply(n[s],o))}return n}}!function(t){t[t.DATA_MASK_000=0]="DATA_MASK_000",t[t.DATA_MASK_001=1]="DATA_MASK_001",t[t.DATA_MASK_010=2]="DATA_MASK_010",t[t.DATA_MASK_011=3]="DATA_MASK_011",t[t.DATA_MASK_100=4]="DATA_MASK_100",t[t.DATA_MASK_101=5]="DATA_MASK_101",t[t.DATA_MASK_110=6]="DATA_MASK_110",t[t.DATA_MASK_111=7]="DATA_MASK_111"}(l||(l={}));class k{constructor(t,e){this.value=t,this.isMasked=e}unmaskBitMatrix(t,e){for(let r=0;r<e;r++)for(let n=0;n<e;n++)this.isMasked(r,n)&&t.flip(n,r)}}k.values=new Map([[l.DATA_MASK_000,new k(l.DATA_MASK_000,((t,e)=>!(t+e&1)))],[l.DATA_MASK_001,new k(l.DATA_MASK_001,((t,e)=>!(1&t)))],[l.DATA_MASK_010,new k(l.DATA_MASK_010,((t,e)=>e%3==0))],[l.DATA_MASK_011,new k(l.DATA_MASK_011,((t,e)=>(t+e)%3==0))],[l.DATA_MASK_100,new k(l.DATA_MASK_100,((t,e)=>!(Math.floor(t/2)+Math.floor(e/3)&1)))],[l.DATA_MASK_101,new k(l.DATA_MASK_101,((t,e)=>t*e%6==0))],[l.DATA_MASK_110,new k(l.DATA_MASK_110,((t,e)=>t*e%6<3))],[l.DATA_MASK_111,new k(l.DATA_MASK_111,((t,e)=>!(t+e+t*e%3&1)))]]);class v extends n{}v.kind="ArgumentException",function(t){t[t.L=0]="L",t[t.M=1]="M",t[t.Q=2]="Q",t[t.H=3]="H"}(c||(c={}));class F{constructor(t,e,r){this.value=t,this.stringValue=e,this.bits=r,F.FOR_BITS.set(r,this),F.FOR_VALUE.set(t,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(t){switch(t){case"L":return F.L;case"M":return F.M;case"Q":return F.Q;case"H":return F.H;default:throw new v(t+"not available")}}toString(){return this.stringValue}equals(t){if(!(t instanceof F))return!1;const e=t;return this.value===e.value}static forBits(t){if(t<0||t>=F.FOR_BITS.size)throw new w;return F.FOR_BITS.get(t)}}F.FOR_BITS=new Map,F.FOR_VALUE=new Map,F.L=new F(c.L,"L",1),F.M=new F(c.M,"M",0),F.Q=new F(c.Q,"Q",3),F.H=new F(c.H,"H",2);class x{constructor(t){this.errorCorrectionLevel=F.forBits(t>>3&3),this.dataMask=7&t}static numBitsDiffering(t,e){return p.bitCount(t^e)}static decodeFormatInformation(t,e){const r=x.doDecodeFormatInformation(t,e);return null!==r?r:x.doDecodeFormatInformation(t^x.FORMAT_INFO_MASK_QR,e^x.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(t,e){let r=Number.MAX_SAFE_INTEGER,n=0;for(const i of x.FORMAT_INFO_DECODE_LOOKUP){const s=i[0];if(s===t||s===e)return new x(i[1]);let o=x.numBitsDiffering(t,s);o<r&&(n=i[1],r=o),t!==e&&(o=x.numBitsDiffering(e,s),o<r&&(n=i[1],r=o))}return r<=3?new x(n):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(t){if(!(t instanceof x))return!1;const e=t;return this.errorCorrectionLevel===e.errorCorrectionLevel&&this.dataMask===e.dataMask}}x.FORMAT_INFO_MASK_QR=21522,x.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class L{constructor(t,e){this.count=t,this.dataCodewords=e}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class z{constructor(t,...e){this.ecCodewordsPerBlock=t,this.ecBlocks=e}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let t=0;const e=this.ecBlocks;for(const r of e)t+=r.getCount();return t}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class H{constructor(t,e,...r){this.versionNumber=t,this.alignmentPatternCenters=e,this.ecBlocks=r;let n=0;const i=r[0].getECCodewordsPerBlock(),s=r[0].getECBlocks();for(const t of s)n+=t.getCount()*(t.getDataCodewords()+i);this.totalCodewords=n}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(t){return this.ecBlocks[t.getValue()]}static getProvisionalVersionForDimension(t){if(t%4!=1)throw new m;try{return this.getVersionForNumber((t-17)/4)}catch(t){throw new m}}static getVersionForNumber(t){if(t<1||t>40)throw new w;return H.VERSIONS[t-1]}static decodeVersionInformation(t){let e=Number.MAX_SAFE_INTEGER,r=0;for(let n=0;n<H.VERSION_DECODE_INFO.length;n++){const i=H.VERSION_DECODE_INFO[n];if(i===t)return H.getVersionForNumber(n+7);const s=x.numBitsDiffering(t,i);s<e&&(r=n+7,e=s)}return e<=3?H.getVersionForNumber(r):null}buildFunctionPattern(){const t=this.getDimensionForVersion(),e=new O(t);e.setRegion(0,0,9,9),e.setRegion(t-8,0,8,9),e.setRegion(0,t-8,9,8);const r=this.alignmentPatternCenters.length;for(let t=0;t<r;t++){const n=this.alignmentPatternCenters[t]-2;for(let i=0;i<r;i++)0===t&&(0===i||i===r-1)||t===r-1&&0===i||e.setRegion(this.alignmentPatternCenters[i]-2,n,5,5)}return e.setRegion(6,9,1,t-17),e.setRegion(9,6,t-17,1),this.versionNumber>6&&(e.setRegion(t-11,0,3,6),e.setRegion(0,t-11,6,3)),e}toString(){return""+this.versionNumber}}H.VERSION_DECODE_INFO=Int32Array.from([31892,34236,39577,42195,48118,51042,55367,58893,63784,68472,70749,76311,79154,84390,87683,92361,96236,102084,102881,110507,110734,117786,119615,126325,127568,133589,136944,141498,145311,150283,152622,158308,161089,167017]),H.VERSIONS=[new H(1,new Int32Array(0),new z(7,new L(1,19)),new z(10,new L(1,16)),new z(13,new L(1,13)),new z(17,new L(1,9))),new H(2,Int32Array.from([6,18]),new z(10,new L(1,34)),new z(16,new L(1,28)),new z(22,new L(1,22)),new z(28,new L(1,16))),new H(3,Int32Array.from([6,22]),new z(15,new L(1,55)),new z(26,new L(1,44)),new z(18,new L(2,17)),new z(22,new L(2,13))),new H(4,Int32Array.from([6,26]),new z(20,new L(1,80)),new z(18,new L(2,32)),new z(26,new L(2,24)),new z(16,new L(4,9))),new H(5,Int32Array.from([6,30]),new z(26,new L(1,108)),new z(24,new L(2,43)),new z(18,new L(2,15),new L(2,16)),new z(22,new L(2,11),new L(2,12))),new H(6,Int32Array.from([6,34]),new z(18,new L(2,68)),new z(16,new L(4,27)),new z(24,new L(4,19)),new z(28,new L(4,15))),new H(7,Int32Array.from([6,22,38]),new z(20,new L(2,78)),new z(18,new L(4,31)),new z(18,new L(2,14),new L(4,15)),new z(26,new L(4,13),new L(1,14))),new H(8,Int32Array.from([6,24,42]),new z(24,new L(2,97)),new z(22,new L(2,38),new L(2,39)),new z(22,new L(4,18),new L(2,19)),new z(26,new L(4,14),new L(2,15))),new H(9,Int32Array.from([6,26,46]),new z(30,new L(2,116)),new z(22,new L(3,36),new L(2,37)),new z(20,new L(4,16),new L(4,17)),new z(24,new L(4,12),new L(4,13))),new H(10,Int32Array.from([6,28,50]),new z(18,new L(2,68),new L(2,69)),new z(26,new L(4,43),new L(1,44)),new z(24,new L(6,19),new L(2,20)),new z(28,new L(6,15),new L(2,16))),new H(11,Int32Array.from([6,30,54]),new z(20,new L(4,81)),new z(30,new L(1,50),new L(4,51)),new z(28,new L(4,22),new L(4,23)),new z(24,new L(3,12),new L(8,13))),new H(12,Int32Array.from([6,32,58]),new z(24,new L(2,92),new L(2,93)),new z(22,new L(6,36),new L(2,37)),new z(26,new L(4,20),new L(6,21)),new z(28,new L(7,14),new L(4,15))),new H(13,Int32Array.from([6,34,62]),new z(26,new L(4,107)),new z(22,new L(8,37),new L(1,38)),new z(24,new L(8,20),new L(4,21)),new z(22,new L(12,11),new L(4,12))),new H(14,Int32Array.from([6,26,46,66]),new z(30,new L(3,115),new L(1,116)),new z(24,new L(4,40),new L(5,41)),new z(20,new L(11,16),new L(5,17)),new z(24,new L(11,12),new L(5,13))),new H(15,Int32Array.from([6,26,48,70]),new z(22,new L(5,87),new L(1,88)),new z(24,new L(5,41),new L(5,42)),new z(30,new L(5,24),new L(7,25)),new z(24,new L(11,12),new L(7,13))),new H(16,Int32Array.from([6,26,50,74]),new z(24,new L(5,98),new L(1,99)),new z(28,new L(7,45),new L(3,46)),new z(24,new L(15,19),new L(2,20)),new z(30,new L(3,15),new L(13,16))),new H(17,Int32Array.from([6,30,54,78]),new z(28,new L(1,107),new L(5,108)),new z(28,new L(10,46),new L(1,47)),new z(28,new L(1,22),new L(15,23)),new z(28,new L(2,14),new L(17,15))),new H(18,Int32Array.from([6,30,56,82]),new z(30,new L(5,120),new L(1,121)),new z(26,new L(9,43),new L(4,44)),new z(28,new L(17,22),new L(1,23)),new z(28,new L(2,14),new L(19,15))),new H(19,Int32Array.from([6,30,58,86]),new z(28,new L(3,113),new L(4,114)),new z(26,new L(3,44),new L(11,45)),new z(26,new L(17,21),new L(4,22)),new z(26,new L(9,13),new L(16,14))),new H(20,Int32Array.from([6,34,62,90]),new z(28,new L(3,107),new L(5,108)),new z(26,new L(3,41),new L(13,42)),new z(30,new L(15,24),new L(5,25)),new z(28,new L(15,15),new L(10,16))),new H(21,Int32Array.from([6,28,50,72,94]),new z(28,new L(4,116),new L(4,117)),new z(26,new L(17,42)),new z(28,new L(17,22),new L(6,23)),new z(30,new L(19,16),new L(6,17))),new H(22,Int32Array.from([6,26,50,74,98]),new z(28,new L(2,111),new L(7,112)),new z(28,new L(17,46)),new z(30,new L(7,24),new L(16,25)),new z(24,new L(34,13))),new H(23,Int32Array.from([6,30,54,78,102]),new z(30,new L(4,121),new L(5,122)),new z(28,new L(4,47),new L(14,48)),new z(30,new L(11,24),new L(14,25)),new z(30,new L(16,15),new L(14,16))),new H(24,Int32Array.from([6,28,54,80,106]),new z(30,new L(6,117),new L(4,118)),new z(28,new L(6,45),new L(14,46)),new z(30,new L(11,24),new L(16,25)),new z(30,new L(30,16),new L(2,17))),new H(25,Int32Array.from([6,32,58,84,110]),new z(26,new L(8,106),new L(4,107)),new z(28,new L(8,47),new L(13,48)),new z(30,new L(7,24),new L(22,25)),new z(30,new L(22,15),new L(13,16))),new H(26,Int32Array.from([6,30,58,86,114]),new z(28,new L(10,114),new L(2,115)),new z(28,new L(19,46),new L(4,47)),new z(28,new L(28,22),new L(6,23)),new z(30,new L(33,16),new L(4,17))),new H(27,Int32Array.from([6,34,62,90,118]),new z(30,new L(8,122),new L(4,123)),new z(28,new L(22,45),new L(3,46)),new z(30,new L(8,23),new L(26,24)),new z(30,new L(12,15),new L(28,16))),new H(28,Int32Array.from([6,26,50,74,98,122]),new z(30,new L(3,117),new L(10,118)),new z(28,new L(3,45),new L(23,46)),new z(30,new L(4,24),new L(31,25)),new z(30,new L(11,15),new L(31,16))),new H(29,Int32Array.from([6,30,54,78,102,126]),new z(30,new L(7,116),new L(7,117)),new z(28,new L(21,45),new L(7,46)),new z(30,new L(1,23),new L(37,24)),new z(30,new L(19,15),new L(26,16))),new H(30,Int32Array.from([6,26,52,78,104,130]),new z(30,new L(5,115),new L(10,116)),new z(28,new L(19,47),new L(10,48)),new z(30,new L(15,24),new L(25,25)),new z(30,new L(23,15),new L(25,16))),new H(31,Int32Array.from([6,30,56,82,108,134]),new z(30,new L(13,115),new L(3,116)),new z(28,new L(2,46),new L(29,47)),new z(30,new L(42,24),new L(1,25)),new z(30,new L(23,15),new L(28,16))),new H(32,Int32Array.from([6,34,60,86,112,138]),new z(30,new L(17,115)),new z(28,new L(10,46),new L(23,47)),new z(30,new L(10,24),new L(35,25)),new z(30,new L(19,15),new L(35,16))),new H(33,Int32Array.from([6,30,58,86,114,142]),new z(30,new L(17,115),new L(1,116)),new z(28,new L(14,46),new L(21,47)),new z(30,new L(29,24),new L(19,25)),new z(30,new L(11,15),new L(46,16))),new H(34,Int32Array.from([6,34,62,90,118,146]),new z(30,new L(13,115),new L(6,116)),new z(28,new L(14,46),new L(23,47)),new z(30,new L(44,24),new L(7,25)),new z(30,new L(59,16),new L(1,17))),new H(35,Int32Array.from([6,30,54,78,102,126,150]),new z(30,new L(12,121),new L(7,122)),new z(28,new L(12,47),new L(26,48)),new z(30,new L(39,24),new L(14,25)),new z(30,new L(22,15),new L(41,16))),new H(36,Int32Array.from([6,24,50,76,102,128,154]),new z(30,new L(6,121),new L(14,122)),new z(28,new L(6,47),new L(34,48)),new z(30,new L(46,24),new L(10,25)),new z(30,new L(2,15),new L(64,16))),new H(37,Int32Array.from([6,28,54,80,106,132,158]),new z(30,new L(17,122),new L(4,123)),new z(28,new L(29,46),new L(14,47)),new z(30,new L(49,24),new L(10,25)),new z(30,new L(24,15),new L(46,16))),new H(38,Int32Array.from([6,32,58,84,110,136,162]),new z(30,new L(4,122),new L(18,123)),new z(28,new L(13,46),new L(32,47)),new z(30,new L(48,24),new L(14,25)),new z(30,new L(42,15),new L(32,16))),new H(39,Int32Array.from([6,26,54,82,110,138,166]),new z(30,new L(20,117),new L(4,118)),new z(28,new L(40,47),new L(7,48)),new z(30,new L(43,24),new L(22,25)),new z(30,new L(10,15),new L(67,16))),new H(40,Int32Array.from([6,30,58,86,114,142,170]),new z(30,new L(19,118),new L(6,119)),new z(28,new L(18,47),new L(31,48)),new z(30,new L(34,24),new L(34,25)),new z(30,new L(20,15),new L(61,16)))];class K{constructor(t){const e=t.getHeight();if(e<21||1!=(3&e))throw new m;this.bitMatrix=t}readFormatInformation(){if(null!==this.parsedFormatInfo&&void 0!==this.parsedFormatInfo)return this.parsedFormatInfo;let t=0;for(let e=0;e<6;e++)t=this.copyBit(e,8,t);t=this.copyBit(7,8,t),t=this.copyBit(8,8,t),t=this.copyBit(8,7,t);for(let e=5;e>=0;e--)t=this.copyBit(8,e,t);const e=this.bitMatrix.getHeight();let r=0;const n=e-7;for(let t=e-1;t>=n;t--)r=this.copyBit(8,t,r);for(let t=e-8;t<e;t++)r=this.copyBit(t,8,r);if(this.parsedFormatInfo=x.decodeFormatInformation(t,r),null!==this.parsedFormatInfo)return this.parsedFormatInfo;throw new m}readVersion(){if(null!==this.parsedVersion&&void 0!==this.parsedVersion)return this.parsedVersion;const t=this.bitMatrix.getHeight(),e=Math.floor((t-17)/4);if(e<=6)return H.getVersionForNumber(e);let r=0;const n=t-11;for(let e=5;e>=0;e--)for(let i=t-9;i>=n;i--)r=this.copyBit(i,e,r);let i=H.decodeVersionInformation(r);if(null!==i&&i.getDimensionForVersion()===t)return this.parsedVersion=i,i;r=0;for(let e=5;e>=0;e--)for(let i=t-9;i>=n;i--)r=this.copyBit(e,i,r);if(i=H.decodeVersionInformation(r),null!==i&&i.getDimensionForVersion()===t)return this.parsedVersion=i,i;throw new m}copyBit(t,e,r){return(this.isMirror?this.bitMatrix.get(e,t):this.bitMatrix.get(t,e))?r<<1|1:r<<1}readCodewords(){const t=this.readFormatInformation(),e=this.readVersion(),r=k.values.get(t.getDataMask()),n=this.bitMatrix.getHeight();r?.unmaskBitMatrix(this.bitMatrix,n);const i=e.buildFunctionPattern();let s=!0;const o=new Uint8Array(e.getTotalCodewords());let a=0,h=0,l=0;for(let t=n-1;t>0;t-=2){6===t&&t--;for(let e=0;e<n;e++){const r=s?n-1-e:e;for(let e=0;e<2;e++)i.get(t-e,r)||(l++,h<<=1,this.bitMatrix.get(t-e,r)&&(h|=1),8===l&&(o[a++]=h,l=0,h=0))}s=!s}if(a!==e.getTotalCodewords())throw new m;return o}remask(){if(null===this.parsedFormatInfo)return;const t=this.parsedFormatInfo&&k.values.get(this.parsedFormatInfo.getDataMask()),e=this.bitMatrix.getHeight();t?.unmaskBitMatrix(this.bitMatrix,e)}setMirror(t){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=t}mirror(){const t=this.bitMatrix;for(let e=0,r=t.getWidth();e<r;e++)for(let r=e+1,n=t.getHeight();r<n;r++)t.get(e,r)!==t.get(r,e)&&(t.flip(r,e),t.flip(e,r))}}class V{constructor(t,e){this.numDataCodewords=t,this.codewords=e}static getDataBlocks(t,e,r){if(t.length!==e.getTotalCodewords())throw new w;const n=e.getECBlocksForLevel(r);let i=0;const s=n.getECBlocks();for(const t of s)i+=t.getCount();const o=new Array(i);let a=0;for(const t of s)for(let e=0;e<t.getCount();e++){const e=t.getDataCodewords(),r=n.getECCodewordsPerBlock()+e;o[a++]=new V(e,new Uint8Array(r))}const h=o[0].codewords.length;let l=o.length-1;for(;l>=0;){if(o[l].codewords.length===h)break;l--}l++;const c=h-n.getECCodewordsPerBlock();let u=0;for(let e=0;e<c;e++)for(let r=0;r<a;r++)o[r].codewords[e]=t[u++];for(let e=l;e<a;e++)o[e].codewords[c]=t[u++];const f=o[0].codewords.length;for(let e=c;e<f;e++)for(let r=0;r<a;r++){const n=r<l?e:e+1;o[r].codewords[n]=t[u++]}return o}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class G{constructor(t){this.bytes=t,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(t){if(t<1||t>32||t>this.available())throw new w(""+t);let e=0,r=this.bitOffset,n=this.byteOffset;const i=this.bytes;if(r>0){const s=8-r,o=t<s?t:s,a=s-o,h=255>>8-o<<a;e=(i[n]&h)>>a,t-=o,r+=o,8===r&&(r=0,n++)}if(t>0){for(;t>=8;)e=e<<8|255&i[n],n++,t-=8;if(t>0){const s=8-t,o=255>>s<<s;e=e<<t|(i[n]&o)>>s,r+=t}}return this.bitOffset=r,this.byteOffset=n,e}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}class Z{constructor(t,e,r,n,i=-1,s=-1){this.rawBytes=t,this.text=e,this.byteSegments=r,this.ecLevel=n,this.structuredAppendSequenceNumber=i,this.structuredAppendParity=s,this.numBits=null==t?0:8*t.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(t){this.numBits=t}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(t){this.errorsCorrected=t}getErasures(){return this.erasures}setErasures(t){this.erasures=t}getOther(){return this.other}setOther(t){this.other=t}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}!function(t){t[t.TERMINATOR=0]="TERMINATOR",t[t.NUMERIC=1]="NUMERIC",t[t.ALPHANUMERIC=2]="ALPHANUMERIC",t[t.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",t[t.BYTE=4]="BYTE",t[t.ECI=5]="ECI",t[t.KANJI=6]="KANJI",t[t.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",t[t.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",t[t.HANZI=9]="HANZI"}(u||(u={}));class X{constructor(t,e,r,n){this.value=t,this.stringValue=e,this.characterCountBitsForVersions=r,this.bits=n,X.FOR_BITS.set(n,this),X.FOR_VALUE.set(t,this)}static forBits(t){const e=X.FOR_BITS.get(t);if(void 0===e)throw new w;return e}getCharacterCountBits(t){const e=t.getVersionNumber();let r;return r=e<=9?0:e<=26?1:2,this.characterCountBitsForVersions[r]}getValue(){return this.value}getBits(){return this.bits}equals(t){if(!(t instanceof X))return!1;const e=t;return this.value===e.value}toString(){return this.stringValue}}X.FOR_BITS=new Map,X.FOR_VALUE=new Map,X.TERMINATOR=new X(u.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),X.NUMERIC=new X(u.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),X.ALPHANUMERIC=new X(u.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),X.STRUCTURED_APPEND=new X(u.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),X.BYTE=new X(u.BYTE,"BYTE",Int32Array.from([8,16,16]),4),X.ECI=new X(u.ECI,"ECI",Int32Array.from([0,0,0]),7),X.KANJI=new X(u.KANJI,"KANJI",Int32Array.from([8,10,12]),8),X.FNC1_FIRST_POSITION=new X(u.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),X.FNC1_SECOND_POSITION=new X(u.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),X.HANZI=new X(u.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class W{static decode(t,e,r,n){const i=new G(t);let s=new _;const o=new Array;let a=-1,h=-1;try{let t,r=null,l=!1;do{if(i.available()<4)t=X.TERMINATOR;else{const e=i.readBits(4);t=X.forBits(e)}switch(t){case X.TERMINATOR:break;case X.FNC1_FIRST_POSITION:case X.FNC1_SECOND_POSITION:l=!0;break;case X.STRUCTURED_APPEND:if(i.available()<16)throw new m;a=i.readBits(8),h=i.readBits(8);break;case X.ECI:const c=W.parseECIValue(i);if(r=A.getCharacterSetECIByValue(c),null===r)throw new m;break;case X.HANZI:const u=i.readBits(4),w=i.readBits(t.getCharacterCountBits(e));u===W.GB2312_SUBSET&&W.decodeHanziSegment(i,s,w);break;default:const f=i.readBits(t.getCharacterCountBits(e));switch(t){case X.NUMERIC:W.decodeNumericSegment(i,s,f);break;case X.ALPHANUMERIC:W.decodeAlphanumericSegment(i,s,f,l);break;case X.BYTE:W.decodeByteSegment(i,s,f,r,o,n);break;case X.KANJI:W.decodeKanjiSegment(i,s,f);break;default:throw new m}}}while(t!==X.TERMINATOR)}catch(t){throw new m}return new Z(t,s.toString(),0===o.length?null:o,null===r?null:r.toString(),a,h)}static decodeHanziSegment(t,e,r){if(13*r>t.available())throw new m;const n=new Uint8Array(2*r);let i=0;for(;r>0;){const e=t.readBits(13);let s=e/96<<8&4294967295|e%96;s+=s<959?41377:42657,n[i]=s>>8&255,n[i+1]=255&s,i+=2,r--}try{e.append(C.decode(n,E.GB2312))}catch(t){throw new m(t)}}static decodeKanjiSegment(t,e,r){if(13*r>t.available())throw new m;const n=new Uint8Array(2*r);let i=0;for(;r>0;){const e=t.readBits(13);let s=e/192<<8&4294967295|e%192;s+=s<7936?33088:49472,n[i]=s>>8,n[i+1]=s,i+=2,r--}try{e.append(C.decode(n,E.SHIFT_JIS))}catch(t){throw new m(t)}}static decodeByteSegment(t,e,r,n,i,s){if(8*r>t.available())throw new m;const o=new Uint8Array(r);for(let e=0;e<r;e++)o[e]=t.readBits(8);let a;a=null===n?E.guessEncoding(o,s):n.getName();try{e.append(C.decode(o,a))}catch(t){throw new m(t)}i.push(o)}static toAlphaNumericChar(t){if(t>=W.ALPHANUMERIC_CHARS.length)throw new m;return W.ALPHANUMERIC_CHARS[t]}static decodeAlphanumericSegment(t,e,r,n){const i=e.length();for(;r>1;){if(t.available()<11)throw new m;const n=t.readBits(11);e.append(W.toAlphaNumericChar(Math.floor(n/45))),e.append(W.toAlphaNumericChar(n%45)),r-=2}if(1===r){if(t.available()<6)throw new m;e.append(W.toAlphaNumericChar(t.readBits(6)))}if(n)for(let t=i;t<e.length();t++)"%"===e.charAt(t)&&(t<e.length()-1&&"%"===e.charAt(t+1)?e.deleteCharAt(t+1):e.setCharAt(t,String.fromCharCode(29)))}static decodeNumericSegment(t,e,r){for(;r>=3;){if(t.available()<10)throw new m;const n=t.readBits(10);if(n>=1e3)throw new m;e.append(W.toAlphaNumericChar(Math.floor(n/100))),e.append(W.toAlphaNumericChar(Math.floor(n/10)%10)),e.append(W.toAlphaNumericChar(n%10)),r-=3}if(2===r){if(t.available()<7)throw new m;const r=t.readBits(7);if(r>=100)throw new m;e.append(W.toAlphaNumericChar(Math.floor(r/10))),e.append(W.toAlphaNumericChar(r%10))}else if(1===r){if(t.available()<4)throw new m;const r=t.readBits(4);if(r>=10)throw new m;e.append(W.toAlphaNumericChar(r))}}static parseECIValue(t){const e=t.readBits(8);if(!(128&e))return 127&e;if(128==(192&e)){return(63&e)<<8&4294967295|t.readBits(8)}if(192==(224&e)){return(31&e)<<16&4294967295|t.readBits(16)}throw new m}}W.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",W.GB2312_SUBSET=1;class Y{constructor(t){this.mirrored=t}isMirrored(){return this.mirrored}applyMirroredCorrection(t){if(!this.mirrored||null===t||t.length<3)return;const e=t[0];t[0]=t[2],t[2]=e}}class q{constructor(){this.rsDecoder=new U(B.QR_CODE_FIELD_256)}decodeBooleanArray(t,e){return this.decodeBitMatrix(O.parseFromBooleanArray(t),e)}decodeBitMatrix(t,e){const r=new K(t);let n=null;try{return this.decodeBitMatrixParser(r,e)}catch(t){n=t}try{r.remask(),r.setMirror(!0),r.readVersion(),r.readFormatInformation(),r.mirror();const t=this.decodeBitMatrixParser(r,e);return t.setOther(new Y(!0)),t}catch(t){if(null!==n)throw n;throw t}}decodeBitMatrixParser(t,e){const r=t.readVersion(),n=t.readFormatInformation().getErrorCorrectionLevel(),i=t.readCodewords(),s=V.getDataBlocks(i,r,n);let o=0;for(const t of s)o+=t.getNumDataCodewords();const a=new Uint8Array(o);let h=0;for(const t of s){const e=t.getCodewords(),r=t.getNumDataCodewords();this.correctErrors(e,r);for(let t=0;t<r;t++)a[h++]=e[t]}return W.decode(a,r,n,e)}correctErrors(t,e){const r=new Int32Array(t);try{this.rsDecoder.decode(r,t.length-e)}catch(t){throw new T}for(let n=0;n<