1import{c as Dn,g as _i,r as At,j as D,s as Ri,b as Oi,t as Di,L as Mi}from"./vendor-react-core-_0sZDOLQ.js";import{B as tn,c as Bi,b as ir}from"./index-j07E1qHv.js";import{C as sr,a as ar}from"./card-DHmBnTdH.js";import{B as vi}from"./badge-BXqwvh8U.js";import{A as Pi,a as Li}from"./alert-C9akKxmM.js";import{t as Dr}from"./index-CDqomOa1.js";import{T as Fi,a as ki,b as Mr,c as Br}from"./tabs-BUF6w8PE.js";import{Q as or,ak as vr,as as Ui,_ as Vi,K as Gi,a4 as Hi,a3 as Wi}from"./vendor-lucide-Ddz0eB7N.js";import{h as Pr}from"./vendor-utils-BRu4i-LD.js";import{m as Mn,A as Xi}from"./vendor-framer-motion-C1oRD-X5.js";import"./vendor-radix-CFmJ1img.js";import"./vendor-supabase-Ca6cp8v2.js";function ji(w,x){for(var h=0;h<x.length;h++){const E=x[h];if(typeof E!="string"&&!Array.isArray(E)){for(const I in E)if(I!=="default"&&!(I in w)){const g=Object.getOwnPropertyDescriptor(E,I);g&&Object.defineProperty(w,I,g.get?g:{enumerable:!0,get:()=>E[I]})}}}return Object.freeze(Object.defineProperty(w,Symbol.toStringTag,{value:"Module"}))}var W;(function(w){w[w.QR_CODE=0]="QR_CODE",w[w.AZTEC=1]="AZTEC",w[w.CODABAR=2]="CODABAR",w[w.CODE_39=3]="CODE_39",w[w.CODE_93=4]="CODE_93",w[w.CODE_128=5]="CODE_128",w[w.DATA_MATRIX=6]="DATA_MATRIX",w[w.MAXICODE=7]="MAXICODE",w[w.ITF=8]="ITF",w[w.EAN_13=9]="EAN_13",w[w.EAN_8=10]="EAN_8",w[w.PDF_417=11]="PDF_417",w[w.RSS_14=12]="RSS_14",w[w.RSS_EXPANDED=13]="RSS_EXPANDED",w[w.UPC_A=14]="UPC_A",w[w.UPC_E=15]="UPC_E",w[w.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(W||(W={}));var Lr=new Map([[W.QR_CODE,"QR_CODE"],[W.AZTEC,"AZTEC"],[W.CODABAR,"CODABAR"],[W.CODE_39,"CODE_39"],[W.CODE_93,"CODE_93"],[W.CODE_128,"CODE_128"],[W.DATA_MATRIX,"DATA_MATRIX"],[W.MAXICODE,"MAXICODE"],[W.ITF,"ITF"],[W.EAN_13,"EAN_13"],[W.EAN_8,"EAN_8"],[W.PDF_417,"PDF_417"],[W.RSS_14,"RSS_14"],[W.RSS_EXPANDED,"RSS_EXPANDED"],[W.UPC_A,"UPC_A"],[W.UPC_E,"UPC_E"],[W.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),Fr;(function(w){w[w.UNKNOWN=0]="UNKNOWN",w[w.URL=1]="URL"})(Fr||(Fr={}));function Yi(w){return Object.values(W).includes(w)}var Bn;(function(w){w[w.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",w[w.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Bn||(Bn={}));var zi=(function(){function w(){}return w.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",w.SCAN_DEFAULT_FPS=2,w.DEFAULT_DISABLE_FLIP=!1,w.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,w.DEFAULT_SUPPORTED_SCAN_TYPE=[Bn.SCAN_TYPE_CAMERA,Bn.SCAN_TYPE_FILE],w})(),Zr=(function(){function w(x,h){this.format=x,this.formatName=h}return w.prototype.toString=function(){return this.formatName},w.create=function(x){if(!Lr.has(x))throw"".concat(x," not in html5QrcodeSupportedFormatsTextMap");return new w(x,Lr.get(x))},w})(),kr=(function(){function w(){}return w.createFromText=function(x){var h={text:x};return{decodedText:x,result:h}},w.createFromQrcodeResult=function(x){return{decodedText:x.text,result:x}},w})(),lr;(function(w){w[w.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",w[w.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",w[w.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(lr||(lr={}));var Zi=(function(){function w(){}return w.createFrom=function(x){return{errorMessage:x,type:lr.UNKWOWN_ERROR}},w})(),Ki=(function(){function w(x){this.verbose=x}return w.prototype.log=function(x){this.verbose&&console.log(x)},w.prototype.warn=function(x){this.verbose&&console.warn(x)},w.prototype.logError=function(x,h){(this.verbose||h===!0)&&console.error(x)},w.prototype.logErrors=function(x){if(x.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(x)},w})();function St(w){return typeof w>"u"||w===null}var nn=(function(){function w(){}return w.codeParseError=function(x){return"QR code parse error, error = ".concat(x)},w.errorGettingUserMedia=function(x){return"Error getting userMedia, error = ".concat(x)},w.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},w.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},w.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},w.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},w.scannerPaused=function(){return"Scanner paused"},w})(),Kr=(function(){function w(){}return w.isMediaStreamConstraintsValid=function(x,h){if(typeof x!="object"){var E=typeof x;return h.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(E,"."),!0),!1}for(var I=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],g=new Set(I),_=Object.keys(x),B=0,L=_;B<L.length;B++){var m=L[B];if(g.has(m))return h.logError("".concat(m," is not supported videoConstaints."),!0),!1}return!0},w}
1)(),An={exports:{}},qi=An.exports,Ur;function Qi(){return Ur||(Ur=1,(function(w,x){(function(h,E){E(x)})(qi,(function(h){function E(u){return u==null}var I=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(u,e){u.__proto__=e}||function(u,e){for(var t in e)e.hasOwnProperty(t)&&(u[t]=e[t])};function g(u,e){I(u,e);function t(){this.constructor=u}u.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function _(u,e){var t=Object.setPrototypeOf;t?t(u,e):u.__proto__=e}function B(u,e){e===void 0&&(e=u.constructor);var t=Error.captureStackTrace;t&&t(u,e)}var L=(function(u){g(e,u);function e(t){var n=this.constructor,r=u.call(this,t)||this;return Object.defineProperty(r,"name",{value:n.name,enumerable:!1}),_(r,n.prototype),B(r),r}return e})(Error);class m extends L{constructor(e=void 0){super(e),this.message=e}getKind(){return this.constructor.kind}}m.kind="Exception";class P extends m{}P.kind="ArgumentException";class O extends m{}O.kind="IllegalArgumentException";class ae{constructor(e){if(this.binarizer=e,e===null)throw new O("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,t){return this.binarizer.getBlackRow(e,t)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,t,n,r){const i=this.binarizer.getLuminanceSource().crop(e,t,n,r);return new ae(this.binarizer.createBinarizer(i))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new ae(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new ae(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class j extends m{static getChecksumInstance(){return new j}}j.kind="ChecksumException";class xe{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class Z{static arraycopy(e,t,n,r,i){for(;i--;)n[r++]=e[t++]}static currentTimeMillis(){return Date.now()}}class ve extends m{}ve.kind="IndexOutOfBoundsException";class ot extends ve{constructor(e=void 0,t=void 0){super(t),this.index=e,this.message=t}}ot.kind="ArrayIndexOutOfBoundsException";class Ie{static fill(e,t){for(let n=0,r=e.length;n<r;n++)e[n]=t}static fillWithin(e,t,n,r){Ie.rangeCheck(e.length,t,n);for(let i=t;i<n;i++)e[i]=r}static rangeCheck(e,t,n){if(t>n)throw new O("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new ot(t);if(n>e)throw new ot(n)}static asList(...e){return e}static create(e,t,n){return Array.from({length:e}).map(i=>Array.from({length:t}).fill(n))}static createInt32Array(e,t,n){return Array.from({length:e}).map(i=>Int32Array.from({length:t}).fill(n))}static equals(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(let n=0,r=e.length;n<r;n++)if(e[n]!==t[n])return!1;return!0}static hashCode(e){if(e===null)return 0;let t=1;for(const n of e)t=31*t+n;return t}static fillUint8Array(e,t){for(let n=0;n!==e.length;n++)e[n]=t}static copyOf(e,t){return e.slice(0,t)}static copyOfUint8Array(e,t){if(e.length<=t){const n=new Uint8Array(t);return n.set(e),n}return e.slice(0,t)}static copyOfRange(e,t,n){const r=n-t,i=new Int32Array(r);return Z.arraycopy(e,t,i,0,r),i}static binarySearch(e,t,n){n===void 0&&(n=Ie.numberComparator);let r=0,i=e.length-1;for(;r<=i;){const s=i+r>>1,a=n(t,e[s]);if(a>0)r=s+1;else if(a<0)i=s-1;else return s}return-r-1}static numberComparator(e,t){return e-t}}class J{static numberOfTrailingZeros(e){let t;if(e===0)return 32;let n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)}static numberOfLeadingZeros(e){if(e===0)return 32;let t=1;return e>>>16||(t+=16,e<<=16),e>>>
124||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t}static toHexString(e){return e.toString(16)}static toBinaryString(e){return String(parseInt(String(e),2))}static bitCount(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63}static truncDivision(e,t){return Math.trunc(e/t)}static parseInt(e,t=void 0){return parseInt(e,t)}}J.MIN_VALUE_32_BITS=-2147483648,J.MAX_VALUE=Number.MAX_SAFE_INTEGER;class ce{constructor(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=ce.makeArray(e):this.bits=t)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(e){if(e>this.bits.length*32){const t=ce.makeArray(e);Z.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}}get(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0}set(e){this.bits[Math.floor(e/32)]|=1<<(e&31)}flip(e){this.bits[Math.floor(e/32)]^=1<<(e&31)}getNextSet(e){const t=this.size;if(e>=t)return t;const n=this.bits;let r=Math.floor(e/32),i=n[r];i&=~((1<<(e&31))-1);const s=n.length;for(;i===0;){if(++r===s)return t;i=n[r]}const a=r*32+J.numberOfTrailingZeros(i);return a>t?t:a}getNextUnset(e){const t=this.size;if(e>=t)return t;const n=this.bits;let r=Math.floor(e/32),i=~n[r];i&=~((1<<(e&31))-1);const s=n.length;for(;i===0;){if(++r===s)return t;i=~n[r]}const a=r*32+J.numberOfTrailingZeros(i);return a>t?t:a}setBulk(e,t){this.bits[Math.floor(e/32)]=t}setRange(e,t){if(t<e||e<0||t>this.size)throw new O;if(t===e)return;t--;const n=Math.floor(e/32),r=Math.floor(t/32),i=this.bits;for(let s=n;s<=r;s++){const a=s>n?0:e&31,l=(2<<(s<r?31:t&31))-(1<<a);i[s]|=l}}clear(){const e=this.bits.length,t=this.bits;for(let n=0;n<e;n++)t[n]=0}isRange(e,t,n){if(t<e||e<0||t>this.size)throw new O;if(t===e)return!0;t--;const r=Math.floor(e/32),i=Math.floor(t/32),s=this.bits;for(let a=r;a<=i;a++){const o=a>r?0:e&31,c=(2<<(a<i?31:t&31))-(1<<o)&4294967295;if((s[a]&c)!==(n?c:0))return!1}return!0}appendBit(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(e,t){if(t<0||t>32)throw new O("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(let n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)}appendBitArray(e){const t=e.size;this.ensureCapacity(this.size+t);for(let n=0;n<t;n++)this.appendBit(e.get(n))}xor(e){if(this.size!==e.size)throw new O("Sizes don't match");const t=this.bits;for(let n=0,r=t.length;n<r;n++)t[n]^=e.bits[n]}toBytes(e,t,n,r){for(let i=0;i<r;i++){let s=0;for(let a=0;a<8;a++)this.get(e)&&(s|=1<<7-a),e++;t[n+i]=s}}getBitArray(){return this.bits}reverse(){const e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),n=t+1,r=this.bits;for(let i=0;i<n;i++){let s=r[i];s=s>>1&1431655765|(s&1431655765)<<1,s=s>>2&858993459|(s&858993459)<<2,s=s>>4&252645135|(s&252645135)<<4,s=s>>8&16711935|(s&16711935)<<8,s=s>>16&65535|(s&65535)<<16,e[t-i]=s}if(this.size!==n*32){const i=n*32-this.size;let s=e[0]>>>i;for(let a=1;a<n;a++){const o=e[a];s|=o<<32-i,e[a-1]=s,s=o>>>i}e[n-1]=s}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof ce))return!1;const t=e;return this.size===t.size&&Ie.equals(this.bits,t.bits)}hashCode(){return 31*this.size+Ie.hashCode(this.bits)}toString(){let e="";for(let t=0,n=this.size;t<n;t++)(t&7)===0&&(e+=" "),e+=this.get(t)?"X":".";return e}clone(){return new ce(this.size,this.bits.slice())}}var Nt;(function(u){u[u.OTHER=0]="OTHER",u[u.PURE_BARCODE=1]="PURE_BARCODE",u[u.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",u[u.TRY_HARDER=3]="TRY_HARDER",u[u.CHARACTER_SET=4]="CHARACTER_SET",u[u.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",u[u.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",u[u.ASSUME_GS1=7]="ASSUME_GS1",u[u.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",u[u.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",u[u.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(Nt||(Nt={}));var we=Nt;class V extends m{static getFormatInstance(){return new V}}V.kind="FormatException";var ge;(function(u){u[u.Cp437=0]="Cp437",u[u.ISO8859_1=1]="ISO8859_1",u[u.ISO8859_2=2]="ISO8859_2",u[u.ISO8859_3=3]="ISO8859_3",u[u.ISO8859_4
1=4]="ISO8859_4",u[u.ISO8859_5=5]="ISO8859_5",u[u.ISO8859_6=6]="ISO8859_6",u[u.ISO8859_7=7]="ISO8859_7",u[u.ISO8859_8=8]="ISO8859_8",u[u.ISO8859_9=9]="ISO8859_9",u[u.ISO8859_10=10]="ISO8859_10",u[u.ISO8859_11=11]="ISO8859_11",u[u.ISO8859_13=12]="ISO8859_13",u[u.ISO8859_14=13]="ISO8859_14",u[u.ISO8859_15=14]="ISO8859_15",u[u.ISO8859_16=15]="ISO8859_16",u[u.SJIS=16]="SJIS",u[u.Cp1250=17]="Cp1250",u[u.Cp1251=18]="Cp1251",u[u.Cp1252=19]="Cp1252",u[u.Cp1256=20]="Cp1256",u[u.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",u[u.UTF8=22]="UTF8",u[u.ASCII=23]="ASCII",u[u.Big5=24]="Big5",u[u.GB18030=25]="GB18030",u[u.EUC_KR=26]="EUC_KR"})(ge||(ge={}));class U{constructor(e,t,n,...r){this.valueIdentifier=e,this.name=n,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=r,U.VALUE_IDENTIFIER_TO_ECI.set(e,this),U.NAME_TO_ECI.set(n,this);const i=this.values;for(let s=0,a=i.length;s!==a;s++){const o=i[s];U.VALUES_TO_ECI.set(o,this)}for(const s of r)U.NAME_TO_ECI.set(s,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(e){if(e<0||e>=900)throw new V("incorect value");const t=U.VALUES_TO_ECI.get(e);if(t===void 0)throw new V("incorect value");return t}static getCharacterSetECIByName(e){const t=U.NAME_TO_ECI.get(e);if(t===void 0)throw new V("incorect value");return t}equals(e){if(!(e instanceof U))return!1;const t=e;return this.getName()===t.getName()}}U.VALUE_IDENTIFIER_TO_ECI=new Map,U.VALUES_TO_ECI=new Map,U.NAME_TO_ECI=new Map,U.Cp437=new U(ge.Cp437,Int32Array.from([0,2]),"Cp437"),U.ISO8859_1=new U(ge.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),U.ISO8859_2=new U(ge.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),U.ISO8859_3=new U(ge.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),U.ISO8859_4=new U(ge.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),U.ISO8859_5=new U(ge.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),U.ISO8859_6=new U(ge.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),U.ISO8859_7=new U(ge.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),U.ISO8859_8=new U(ge.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),U.ISO8859_9=new U(ge.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),U.ISO8859_10=new U(ge.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),U.ISO8859_11=new U(ge.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),U.ISO8859_13=new U(ge.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),U.ISO8859_14=new U(ge.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),U.ISO8859_15=new U(ge.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),U.ISO8859_16=new U(ge.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),U.SJIS=new U(ge.SJIS,20,"SJIS","Shift_JIS"),U.Cp1250=new U(ge.Cp1250,21,"Cp1250","windows-1250"),U.Cp1251=new U(ge.Cp1251,22,"Cp1251","windows-1251"),U.Cp1252=new U(ge.Cp1252,23,"Cp1252","windows-1252"),U.Cp1256=new U(ge.Cp1256,24,"Cp1256","windows-1256"),U.UnicodeBigUnmarked=new U(ge.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),U.UTF8=new U(ge.UTF8,26,"UTF8","UTF-8"),U.ASCII=new U(ge.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),U.Big5=new U(ge.Big5,28,"Big5"),U.GB18030=new U(ge.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),U.EUC_KR=new U(ge.EUC_KR,30,"EUC_KR","EUC-KR");class Xt extends m{}Xt.kind="UnsupportedOperationException";class et{static decode(e,t){const n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)}static shouldDecodeOnFallback(e){return!et.isBrowser()&&e==="ISO-8859-1"}static encode(e,t){const n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(e){return typeof e=="string"?e:e.getName()}static encodingCharacterSet(e){return e instanceof U?e:U.getCharacterSetECIByName(e)}static decodeFallback(e,t){const n=this.encodingCharacterSet(t);if(et.isDecodeFallbackSupported(n)){let r="";for(let i=0,s=e.length;i<s;i++){let a=e[i].toString(16);a.length<2&&(a="0"+a),r+="%"+a}return decodeURIComponent(r)}if(n.equals(U.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new Xt(`Encoding ${this.encodingName(t)} not supported by fallback.`)}static isDecodeFallbackSupported(e){return e.equals(U.UTF8)||e.equals(U.ISO8859_1)||e.equals(U.ASCII)}static encodeFallback(e){const n=btoa(unescape(encodeURIComponent(e))).split(""),r=[];for(let i=0;i<n.length;
1i++)r.push(n[i].charCodeAt(0));return new Uint8Array(r)}}class ${static castAsNonUtf8Char(e,t=null){const n=t?t.getName():this.ISO88591;return et.decode(new Uint8Array([e]),n)}static guessEncoding(e,t){if(t!=null&&t.get(we.CHARACTER_SET)!==void 0)return t.get(we.CHARACTER_SET).toString();const n=e.length;let r=!0,i=!0,s=!0,a=0,o=0,l=0,c=0,f=0,d=0,C=0,p=0,b=0,y=0,N=0;const F=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191;for(let k=0;k<n&&(r||i||s);k++){const v=e[k]&255;s&&(a>0?(v&128)===0?s=!1:a--:(v&128)!==0&&((v&64)===0?s=!1:(a++,(v&32)===0?o++:(a++,(v&16)===0?l++:(a++,(v&8)===0?c++:s=!1))))),r&&(v>127&&v<160?r=!1:v>159&&(v<192||v===215||v===247)&&N++),i&&(f>0?v<64||v===127||v>252?i=!1:f--:v===128||v===160||v>239?i=!1:v>160&&v<224?(d++,p=0,C++,C>b&&(b=C)):v>127?(f++,C=0,p++,p>y&&(y=p)):(C=0,p=0))}return s&&a>0&&(s=!1),i&&f>0&&(i=!1),s&&(F||o+l+c>0)?$.UTF8:i&&($.ASSUME_SHIFT_JIS||b>=3||y>=3)?$.SHIFT_JIS:r&&i?b===2&&d===2||N*10>=n?$.SHIFT_JIS:$.ISO88591:r?$.ISO88591:i?$.SHIFT_JIS:s?$.UTF8:$.PLATFORM_DEFAULT_ENCODING}static format(e,...t){let n=-1;function r(s,a,o,l,c,f){if(s==="%%")return"%";if(t[++n]===void 0)return;s=l?parseInt(l.substr(1)):void 0;let d=c?parseInt(c.substr(1)):void 0,C;switch(f){case"s":C=t[n];break;case"c":C=t[n][0];break;case"f":C=parseFloat(t[n]).toFixed(s);break;case"p":C=parseFloat(t[n]).toPrecision(s);break;case"e":C=parseFloat(t[n]).toExponential(s);break;case"x":C=parseInt(t[n]).toString(d||16);break;case"d":C=parseFloat(parseInt(t[n],d||10).toPrecision(s)).toFixed(0);break}C=typeof C=="object"?JSON.stringify(C):(+C).toString(d);let p=parseInt(o),b=o&&o[0]+""=="0"?"0":" ";for(;C.length<p;)C=a!==void 0?C+b:b+C;return C}let i=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(i,r)}static getBytes(e,t){return et.encode(e,t)}static getCharCode(e,t=0){return e.charCodeAt(t)}static getCharAt(e){return String.fromCharCode(e)}}$.SHIFT_JIS=U.SJIS.getName(),$.GB2312="GB2312",$.ISO88591=U.ISO8859_1.getName(),$.EUC_JP="EUC_JP",$.UTF8=U.UTF8.getName(),$.PLATFORM_DEFAULT_ENCODING=$.UTF8,$.ASSUME_SHIFT_JIS=!1;class Ae{constructor(e=""){this.value=e}enableDecoding(e){return this.encoding=e,this}append(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=$.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this}appendChars(e,t,n){for(let r=t;t<t+n;r++)this.append(e[r]);return this}length(){return this.value.length}charAt(e){return this.value.charAt(e)}deleteCharAt(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)}setCharAt(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)}substring(e,t){return this.value.substring(e,t)}setLengthToZero(){this.value=""}toString(){return this.value}insert(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+t.length)}}class Ue{constructor(e,t,n,r){if(this.width=e,this.height=t,this.rowSize=n,this.bits=r,t==null&&(t=e),this.height=t,e<1||t<1)throw new O("Both dimensions must be greater than 0");n==null&&(n=Math.floor((e+31)/32)),this.rowSize=n,r==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(e){const t=e.length,n=e[0].length,r=new Ue(n,t);for(let i=0;i<t;i++){const s=e[i];for(let a=0;a<n;a++)s[a]&&r.set(a,i)}return r}static parseFromString(e,t,n){if(e===null)throw new O("stringRepresentation cannot be null");const r=new Array(e.length);let i=0,s=0,a=-1,o=0,l=0;for(;l<e.length;)if(e.charAt(l)===` 2`||e.charAt(l)==="\r"){if(i>s){if(a===-1)a=i-s;else if(i-s!==a)throw new O("row lengths do not match");s=i,o++}l++}else if(e.substring(l,l+t.length)===t)l+=t.length,r[i]=!0,i++;else if(e.substring(l,l+n.length)===n)l+=n.length,r[i]=!1,i++;else throw new O("illegal character encountered: "+e.substring(l));if(i>s){if(a===-1)a=i-s;else if(i-s!==a)throw new O("row lengths do not match");o++}const c=new Ue(a,o);for(let f=0;f<i;f++)r[f]&&c.set(Math.floor(f%a),Math.floor(f/a));return c}get(e,t){const n=t*this.rowSize+Math.floor(e/32);return(this.bits[n]>>>(e&31)&1)!==0}set(e,t){const n=t*this.rowSize+Math.floor(e/32);this.bits[n]|=1<<(e&31)&4294967295}unset(e,t){const n=t*this.rowSize+Math.floor(e/32);this.bits[n]&=~(1<<(e&31)&4294967295)}flip(e,t){const n=t*this.rowSize+Math.floor(e/32);this.bits[n]^=1<<(e&31)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new O("input matrix dimensions do not match");const t=new ce(Math.floor(this.width/32)+1),n=this.rowSize,r=this.bits;for(let i=0,s=this.height;i<s;i++){const a=i*n,o=e.getRow(i,t).getBitArray();for(let l=0;l<n;l++)r[a+l]^=o[l]}}clear(){const e=this.bits,t=e.length;for(let n=0;n<t;n++)e[n]=0}setRegion(e,t,n,r){if(t<0||e<0)throw new O("Left and top must be nonnegative");if(r<1||n<1)throw new O("Height and width must be at least 1");const i=e+n,s=t+r;if(s>this.height||i>this.width)throw new O("The region must fit inside the matrix");const a=this.rowSize,o=this.bits;for(let l=t;l<s;l++){const c=l*a;for(let f=e;f<i;f++)o[c+Math.floor(f/32)]|=1<<(f&31)&4294967295}}getRow(e,t){t==null||t.getSize()<this.width?t=new ce(this.width):t.clear();const n=this.rowSize,r=this.bits,i=e*n;for(let s=0;s<n;
2s++)t.setBulk(s*32,r[i+s]);return t}setRow(e,t){Z.arraycopy(t.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)}rotate180(){const e=this.getWidth(),t=this.getHeight();let n=new ce(e),r=new ce(e);for(let i=0,s=Math.floor((t+1)/2);i<s;i++)n=this.getRow(i,n),r=this.getRow(t-1-i,r),n.reverse(),r.reverse(),this.setRow(i,r),this.setRow(t-1-i,n)}getEnclosingRectangle(){const e=this.width,t=this.height,n=this.rowSize,r=this.bits;let i=e,s=t,a=-1,o=-1;for(let l=0;l<t;l++)for(let c=0;c<n;c++){const f=r[l*n+c];if(f!==0){if(l<s&&(s=l),l>o&&(o=l),c*32<i){let d=0;for(;(f<<31-d&4294967295)===0;)d++;c*32+d<i&&(i=c*32+d)}if(c*32+31>a){let d=31;for(;!(f>>>d);)d--;c*32+d>a&&(a=c*32+d)}}}return a<i||o<s?null:Int32Array.from([i,s,a-i+1,o-s+1])}getTopLeftOnBit(){const e=this.rowSize,t=this.bits;let n=0;for(;n<t.length&&t[n]===0;)n++;if(n===t.length)return null;const r=n/e;let i=n%e*32;const s=t[n];let a=0;for(;(s<<31-a&4294967295)===0;)a++;return i+=a,Int32Array.from([i,r])}getBottomRightOnBit(){const e=this.rowSize,t=this.bits;let n=t.length-1;for(;n>=0&&t[n]===0;)n--;if(n<0)return null;const r=Math.floor(n/e);let i=Math.floor(n%e)*32;const s=t[n];let a=31;for(;!(s>>>a);)a--;return i+=a,Int32Array.from([i,r])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){if(!(e instanceof Ue))return!1;const t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&Ie.equals(this.bits,t.bits)}hashCode(){let e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+Ie.hashCode(this.bits),e}toString(e="X ",t=" ",n=` 3`){return this.buildToString(e,t,n)}buildToString(e,t,n){let r=new Ae;for(let i=0,s=this.height;i<s;i++){for(let a=0,o=this.width;a<o;a++)r.append(this.get(a,i)?e:t);r.append(n)}return r.toString()}clone(){return new Ue(this.width,this.height,this.rowSize,this.bits.slice())}}class R extends m{static getNotFoundInstance(){return new R}}R.kind="NotFoundException";class Ve extends xe{constructor(e){super(e),this.luminances=Ve.EMPTY,this.buckets=new Int32Array(Ve.LUMINANCE_BUCKETS)}getBlackRow(e,t){const n=this.getLuminanceSource(),r=n.getWidth();t==null||t.getSize()<r?t=new ce(r):t.clear(),this.initArrays(r);const i=n.getRow(e,this.luminances),s=this.buckets;for(let o=0;o<r;o++)s[(i[o]&255)>>Ve.LUMINANCE_SHIFT]++;const a=Ve.estimateBlackPoint(s);if(r<3)for(let o=0;o<r;o++)(i[o]&255)<a&&t.set(o);else{let o=i[0]&255,l=i[1]&255;for(let c=1;c<r-1;c++){const f=i[c+1]&255;(l*4-o-f)/2<a&&t.set(c),o=l,l=f}}return t}getBlackMatrix(){const e=this.getLuminanceSource(),t=e.getWidth(),n=e.getHeight(),r=new Ue(t,n);this.initArrays(t);const i=this.buckets;for(let o=1;o<5;o++){const l=Math.floor(n*o/5),c=e.getRow(l,this.luminances),f=Math.floor(t*4/5);for(let d=Math.floor(t/5);d<f;d++){const C=c[d]&255;i[C>>Ve.LUMINANCE_SHIFT]++}}const s=Ve.estimateBlackPoint(i),a=e.getMatrix();for(let o=0;o<n;o++){const l=o*t;for(let c=0;c<t;c++)(a[l+c]&255)<s&&r.set(c,o)}return r}createBinarizer(e){return new Ve(e)}initArrays(e){this.luminances.length<e&&(this.luminances=new Uint8ClampedArray(e));const t=this.buckets;for(let n=0;n<Ve.LUMINANCE_BUCKETS;n++)t[n]=0}static estimateBlackPoint(e){const t=e.length;let n=0,r=0,i=0;for(let c=0;c<t;c++)e[c]>i&&(r=c,i=e[c]),e[c]>n&&(n=e[c]);let s=0,a=0;for(let c=0;c<t;c++){const f=c-r,d=e[c]*f*f;d>a&&(s=c,a=d)}if(r>s){const c=r;r=s,s=c}if(s-r<=t/16)throw new R;let o=s-1,l=-1;for(let c=s-1;c>r;c--){const f=c-r,d=f*f*(s-c)*(n-e[c]);d>l&&(o=c,l=d)}return o<<Ve.LUMINANCE_SHIFT}}Ve.LUMINANCE_BITS=5,Ve.LUMINANCE_SHIFT=8-Ve.LUMINANCE_BITS,Ve.LUMINANCE_BUCKETS=1<<Ve.LUMINANCE_BITS,Ve.EMPTY=Uint8ClampedArray.from([0]);class te extends Ve{constructor(e){super(e),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const e=this.getLuminanceSource(),t=e.getWidth(),n=e.getHeight();if(t>=te.MINIMUM_DIMENSION&&n>=te.MINIMUM_DIMENSION){const r=e.getMatrix();let i=t>>te.BLOCK_SIZE_POWER;(t&te.BLOCK_SIZE_MASK)!==0&&i++;let s=n>>te.BLOCK_SIZE_POWER;(n&te.BLOCK_SIZE_MASK)!==0&&s++;const a=te.calculateBlackPoints(r,i,s,t,n),o=new Ue(t,n);te.calculateThresholdForBlock(r,i,s,t,n,a,o),this.matrix=o}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new te(e)}static calculateThresholdForBlock(e,t,n,r,i,s,a){const o=i-te.BLOCK_SIZE,l=r-te.BLOCK_SIZE;for(let c=0;c<n;c++){let f=c<<te.BLOCK_SIZE_POWER;f>o&&(f=o);const d=te.cap(c,2,n-3);for(let C=0;C<t;C++){let p=C<<te.BLOCK_SIZE_POWER;p>l&&(p=l);const b=te.cap(C,2,t-3);let y=0;for(let F=-2;F<=2;F++){const k=s[d+F];y+=k[b-2]+k[b-1]+k[b]+k[b+1]+k[b+2]}const N=y/25;te.thresholdBlock(e,p,f,N,r,a)}}}
3static cap(e,t,n){return e<t?t:e>n?n:e}static thresholdBlock(e,t,n,r,i,s){for(let a=0,o=n*i+t;a<te.BLOCK_SIZE;a++,o+=i)for(let l=0;l<te.BLOCK_SIZE;l++)(e[o+l]&255)<=r&&s.set(t+l,n+a)}static calculateBlackPoints(e,t,n,r,i){const s=i-te.BLOCK_SIZE,a=r-te.BLOCK_SIZE,o=new Array(n);for(let l=0;l<n;l++){o[l]=new Int32Array(t);let c=l<<te.BLOCK_SIZE_POWER;c>s&&(c=s);for(let f=0;f<t;f++){let d=f<<te.BLOCK_SIZE_POWER;d>a&&(d=a);let C=0,p=255,b=0;for(let N=0,F=c*r+d;N<te.BLOCK_SIZE;N++,F+=r){for(let k=0;k<te.BLOCK_SIZE;k++){const v=e[F+k]&255;C+=v,v<p&&(p=v),v>b&&(b=v)}if(b-p>te.MIN_DYNAMIC_RANGE)for(N++,F+=r;N<te.BLOCK_SIZE;N++,F+=r)for(let k=0;k<te.BLOCK_SIZE;k++)C+=e[F+k]&255}let y=C>>te.BLOCK_SIZE_POWER*2;if(b-p<=te.MIN_DYNAMIC_RANGE&&(y=p/2,l>0&&f>0)){const N=(o[l-1][f]+2*o[l][f-1]+o[l-1][f-1])/4;p<N&&(y=N)}o[l][f]=y}}return o}}te.BLOCK_SIZE_POWER=3,te.BLOCK_SIZE=1<<te.BLOCK_SIZE_POWER,te.BLOCK_SIZE_MASK=te.BLOCK_SIZE-1,te.MINIMUM_DIMENSION=te.BLOCK_SIZE*5,te.MIN_DYNAMIC_RANGE=24;class rn{constructor(e,t){this.width=e,this.height=t}getWidth(){return this.width}getHeight(){return this.height}isCropSupported(){return!1}crop(e,t,n,r){throw new Xt("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new Xt("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new Xt("This luminance source does not support rotation by 45 degrees.")}toString(){const e=new Uint8ClampedArray(this.width);let t=new Ae;for(let n=0;n<this.height;n++){const r=this.getRow(n,e);for(let i=0;i<this.width;i++){const s=r[i]&255;let a;s<64?a="#":s<128?a="+":s<192?a=".":a=" ",t.append(a)}t.append(` 4`)}return t.toString()}}class _t extends rn{constructor(e){super(e.getWidth(),e.getHeight()),this.delegate=e}getRow(e,t){const n=this.delegate.getRow(e,t),r=this.getWidth();for(let i=0;i<r;i++)n[i]=255-(n[i]&255);return n}getMatrix(){const e=this.delegate.getMatrix(),t=this.getWidth()*this.getHeight(),n=new Uint8ClampedArray(t);for(let r=0;r<t;r++)n[r]=255-(e[r]&255);return n}isCropSupported(){return this.delegate.isCropSupported()}crop(e,t,n,r){return new _t(this.delegate.crop(e,t,n,r))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new _t(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new _t(this.delegate.rotateCounterClockwise45())}}class Rt extends rn{constructor(e){super(e.width,e.height),this.canvas=e,this.tempCanvasElement=null,this.buffer=Rt.makeBufferFromCanvasImageData(e)}static makeBufferFromCanvasImageData(e){const t=e.getContext("2d").getImageData(0,0,e.width,e.height);return Rt.toGrayscaleBuffer(t.data,e.width,e.height)}static toGrayscaleBuffer(e,t,n){const r=new Uint8ClampedArray(t*n);for(let i=0,s=0,a=e.length;i<a;i+=4,s++){let o;if(e[i+3]===0)o=255;else{const c=e[i],f=e[i+1],d=e[i+2];o=306*c+601*f+117*d+512>>10}r[s]=o}return r}getRow(e,t){if(e<0||e>=this.getHeight())throw new O("Requested row is outside the image: "+e);const n=this.getWidth(),r=e*n;return t===null?t=this.buffer.slice(r,r+n):(t.length<n&&(t=new Uint8ClampedArray(n)),t.set(this.buffer.slice(r,r+n))),t}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(e,t,n,r){return super.crop(e,t,n,r),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const e=this.canvas.ownerDocument.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height,this.tempCanvasElement=e}return this.tempCanvasElement}rotate(e){const t=this.getTempCanvasElement(),n=t.getContext("2d"),r=e*Rt.DEGREE_TO_RADIANS,i=this.canvas.width,s=this.canvas.height,a=Math.ceil(Math.abs(Math.cos(r))*i+Math.abs(Math.sin(r))*s),o=Math.ceil(Math.abs(Math.sin(r))*i+Math.abs(Math.cos(r))*s);return t.width=a,t.height=o,n.translate(a/2,o/2),n.rotate(r),n.drawImage(this.canvas,i/-2,s/-2),this.buffer=Rt.makeBufferFromCanvasImageData(t),this}invert(){return new _t(this)}}Rt.DEGREE_TO_RADIANS=Math.PI/180;class hr{constructor(e,t,n){this.deviceId=e,this.label=t,this.kind="videoinput",this.groupId=n||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var qe=(globalThis||Dn||self||window||void 0)&&(globalThis||Dn||self||window||void 0).__awaiter||function(u,e,t,n){function r(i){return i instanceof t?i:new t(function(s){s(i)})}return new(t||(t=Promise))(function(i,s){function a(c){try{l(n.next(c))}catch(f){s(f)}}function o(c){try{l(n.throw(c))}catch(f){s(f)}}function l(c){c.done?i(c.value):r(c.value).then(a,o)}l((n=n.apply(u,e||[])).next())})};class Ft{constructor(e,t=500,n){this.reader=e,this.timeBetweenScansMillis=t,this._hints=n,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(e){this._timeBetweenDecodingAttempts=e<0?0:e}set hints(e){this._hints=e||null}get hints(){return this._hints}listVideoInputDevices(){return qe(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const e=yield navigator.mediaDevices.enumerateDevices(),t=[];for(const n of e){const r=n.kind==="video"?"videoinput":n.kind;if(r!=="videoinput")continue;const i=n.deviceId||n.id,s=n.label||`Video device ${t.length+1}`,a=n.groupId,o={deviceId:i,label:s,kind:r,groupId:a};t.push(o)}return t})}getVideoInputDevices(){return qe(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(t=>new hr(t.deviceId,t.label))})}findDeviceById(e){return qe(this,void 0,void 0,function*(){const t=yield this.listVideoInputDevices();return t?t.find(n=>n.deviceId===e):null})}decodeFromInputVideoDevice(e,t){return qe(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,t)})}decodeOnceFromVideoDevice(e,t){return qe(this,void 0,void 0,function*(){this.reset();let n;e?n={deviceId:{exact:e}}:n={facingMode:"environment"};const r={video:n};return yield this.decodeOnceFromConstraints(r,t)})}decodeOnceFromConstraints(e,t){return qe(this,void 0,void 0,function*(){const n=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(n,t)})}decodeOnceFromStream(e,t){return qe(this,void 0,void 0,function*(){this.reset();const n=yield this.attachStreamToVideo(e,t);return yield this.decodeOnce(n)})}decodeFromInputVideoDeviceContinuously(e,t,n){return qe(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,t,n)})}decodeFromVideoDevice(e,t,n){return qe(this,void 0,void 0,function*(){let r;e?r={deviceId:{exact:e}}:r={facingMode:"environment"};const i={video:r};return yield this.decodeFromConstraints(i,t,n)})}
4decodeFromConstraints(e,t,n){return qe(this,void 0,void 0,function*(){const r=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(r,t,n)})}decodeFromStream(e,t,n){return qe(this,void 0,void 0,function*(){this.reset();const r=yield this.attachStreamToVideo(e,t);return yield this.decodeContinuously(r,n)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,t){return qe(this,void 0,void 0,function*(){const n=this.prepareVideoElement(t);return this.addVideoSource(n,e),this.videoElement=n,this.stream=e,yield this.playVideoOnLoadAsync(n),n})}playVideoOnLoadAsync(e){return new Promise((t,n)=>this.playVideoOnLoad(e,()=>t()))}playVideoOnLoad(e,t){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return qe(this,void 0,void 0,function*(){if(this.isVideoPlaying(e)){console.warn("Trying to play video that is already playing.");return}try{yield e.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(e,t){const n=document.getElementById(e);if(!n)throw new P(`element with id '${e}' not found`);if(n.nodeName.toLowerCase()!==t.toLowerCase())throw new P(`element with id '${e}' must be an ${t} element`);return n}decodeFromImage(e,t){if(!e&&!t)throw new P("either imageElement with a src set or an url must be provided");return t&&!e?this.decodeFromImageUrl(t):this.decodeFromImageElement(e)}decodeFromVideo(e,t){if(!e&&!t)throw new P("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,t,n){if(e===void 0&&t===void 0)throw new P("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,n):this.decodeFromVideoElementContinuously(e,n)}decodeFromImageElement(e){if(!e)throw new P("An image element must be provided.");this.reset();const t=this.prepareImageElement(e);this.imageElement=t;let n;return this.isImageLoaded(t)?n=this.decodeOnce(t,!1,!0):n=this._decodeOnLoadImage(t),n}decodeFromVideoElement(e){const t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)}decodeFromVideoElementContinuously(e,t){const n=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(n,t)}_decodeFromVideoElementSetup(e){if(!e)throw new P("A video element must be provided.");this.reset();const t=this.prepareVideoElement(e);return this.videoElement=t,t}decodeFromImageUrl(e){if(!e)throw new P("An URL must be provided.");this.reset();const t=this.prepareImageElement();this.imageElement=t;const n=this._decodeOnLoadImage(t);return t.src=e,n}decodeFromVideoUrl(e){if(!e)throw new P("An URL must be provided.");this.reset();const t=this.prepareVideoElement(),n=this.decodeFromVideoElement(t);return t.src=e,n}decodeFromVideoUrlContinuously(e,t){if(!e)throw new P("An URL must be provided.");this.reset();const n=this.prepareVideoElement(),r=this.decodeFromVideoElementContinuously(n,t);return n.src=e,r}_decodeOnLoadImage(e){return new Promise((t,n)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(t,n),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return qe(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,t){return qe(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,t)})}isImageLoaded(e){return!(!e.complete||e.naturalWidth===0)}prepareImageElement(e){let t;return typeof e>"u"&&(t=document.createElement("img"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t}prepareVideoElement(e){let t;return!e&&typeof document<"u"&&(t=document.createElement("video"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t}decodeOnce(e,t=!0,n=!0){this._stopAsyncDecode=!1;const r=(i,s)=>{if(this._stopAsyncDecode){s(new R("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const a=this.decode(e);i(a)}
4catch(a){const o=t&&a instanceof R,c=(a instanceof j||a instanceof V)&&n;if(o||c)return setTimeout(r,this._timeBetweenDecodingAttempts,i,s);s(a)}};return new Promise((i,s)=>r(i,s))}decodeContinuously(e,t){this._stopContinuousDecode=!1;const n=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const r=this.decode(e);t(r,null),setTimeout(n,this.timeBetweenScansMillis)}catch(r){t(null,r);const i=r instanceof j||r instanceof V,s=r instanceof R;(i||s)&&setTimeout(n,this._timeBetweenDecodingAttempts)}};n()}decode(e){const t=this.createBinaryBitmap(e);return this.decodeBitmap(t)}_isHTMLVideoElement(e){return e.videoWidth!==0}drawFrameOnCanvas(e,t,n){t||(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),n||(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}drawImageOnCanvas(e,t,n=this.captureCanvasContext){t||(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),n||(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}createBinaryBitmap(e){this.getCaptureCanvasContext(e),this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);const t=this.getCaptureCanvas(e),n=new Rt(t),r=new te(n);return new ae(r)}getCaptureCanvasContext(e){if(!this.captureCanvasContext){const n=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=n}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){const t=this.createCaptureCanvas(e);this.captureCanvas=t}return this.captureCanvas}decodeBitmap(e){return this.reader.decode(e,this._hints)}createCaptureCanvas(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const t=document.createElement("canvas");let n,r;return typeof e<"u"&&(e instanceof HTMLVideoElement?(n=e.videoWidth,r=e.videoHeight):e instanceof HTMLImageElement&&(n=e.naturalWidth||e.width,r=e.naturalHeight||e.height)),t.style.width=n+"px",t.style.height=r+"px",t.width=n,t.height=r,t}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(e,t){try{e.srcObject=t}catch{e.src=URL.createObjectURL(t)}}cleanVideoSource(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")}}class Qe{constructor(e,t,n=t==null?0:8*t.length,r,i,s=Z.currentTimeMillis()){this.text=e,this.rawBytes=t,this.numBits=n,this.resultPoints=r,this.format=i,this.timestamp=s,this.text=e,this.rawBytes=t,n==null?this.numBits=t==null?0:8*t.length:this.numBits=n,this.resultPoints=r,this.format=i,this.resultMetadata=null,s==null?this.timestamp=Z.currentTimeMillis():this.timestamp=s}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(e,t){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,t)}putAllMetadata(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))}addResultPoints(e){const t=this.resultPoints;if(t===null)this.resultPoints=e;else if(e!==null&&e.length>0){const n=new Array(t.length+e.length);Z.arraycopy(t,0,n,0,t.length),Z.arraycopy(e,0,n,t.length,e.length),this.resultPoints=n}}getTimestamp(){return this.timestamp}toString(){return this.text}}var Ln;
4(function(u){u[u.AZTEC=0]="AZTEC",u[u.CODABAR=1]="CODABAR",u[u.CODE_39=2]="CODE_39",u[u.CODE_93=3]="CODE_93",u[u.CODE_128=4]="CODE_128",u[u.DATA_MATRIX=5]="DATA_MATRIX",u[u.EAN_8=6]="EAN_8",u[u.EAN_13=7]="EAN_13",u[u.ITF=8]="ITF",u[u.MAXICODE=9]="MAXICODE",u[u.PDF_417=10]="PDF_417",u[u.QR_CODE=11]="QR_CODE",u[u.RSS_14=12]="RSS_14",u[u.RSS_EXPANDED=13]="RSS_EXPANDED",u[u.UPC_A=14]="UPC_A",u[u.UPC_E=15]="UPC_E",u[u.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Ln||(Ln={}));var K=Ln,Fn;(function(u){u[u.OTHER=0]="OTHER",u[u.ORIENTATION=1]="ORIENTATION",u[u.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",u[u.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",u[u.ISSUE_NUMBER=4]="ISSUE_NUMBER",u[u.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",u[u.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",u[u.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",u[u.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",u[u.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",u[u.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(Fn||(Fn={}));var Ge=Fn;class sn{constructor(e,t,n,r,i=-1,s=-1){this.rawBytes=e,this.text=t,this.byteSegments=n,this.ecLevel=r,this.structuredAppendSequenceNumber=i,this.structuredAppendParity=s,this.numBits=e==null?0:8*e.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(e){this.numBits=e}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(e){this.errorsCorrected=e}getErasures(){return this.erasures}setErasures(e){this.erasures=e}getOther(){return this.other}setOther(e){this.other=e}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class an{exp(e){return this.expTable[e]}log(e){if(e===0)throw new O;return this.logTable[e]}static addOrSubtract(e,t){return e^t}}class tt{constructor(e,t){if(t.length===0)throw new O;this.field=e;const n=t.length;if(n>1&&t[0]===0){let r=1;for(;r<n&&t[r]===0;)r++;r===n?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(n-r),Z.arraycopy(t,r,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);const t=this.coefficients;let n;if(e===1){n=0;for(let s=0,a=t.length;s!==a;s++){const o=t[s];n=an.addOrSubtract(n,o)}return n}n=t[0];const r=t.length,i=this.field;for(let s=1;s<r;s++)n=an.addOrSubtract(i.multiply(e,n),t[s]);return n}addOrSubtract(e){if(!this.field.equals(e.field))throw new O("GenericGFPolys do not have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;let t=this.coefficients,n=e.coefficients;if(t.length>n.length){const s=t;t=n,n=s}let r=new Int32Array(n.length);const i=n.length-t.length;Z.arraycopy(n,0,r,0,i);for(let s=i;s<n.length;s++)r[s]=an.addOrSubtract(t[s-i],n[s]);return new tt(this.field,r)}multiply(e){if(!this.field.equals(e.field))throw new O("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();const t=this.coefficients,n=t.length,r=e.coefficients,i=r.length,s=new Int32Array(n+i-1),a=this.field;for(let o=0;o<n;o++){const l=t[o];for(let c=0;c<i;c++)s[o+c]=an.addOrSubtract(s[o+c],a.multiply(l,r[c]))}return new tt(a,s)}multiplyScalar(e){if(e===0)return this.field.getZero();if(e===1)return this;const t=this.coefficients.length,n=this.field,r=new Int32Array(t),i=this.coefficients;for(let s=0;s<t;s++)r[s]=n.multiply(i[s],e);return new tt(n,r)}multiplyByMonomial(e,t){if(e<0)throw new O;if(t===0)return this.field.getZero();const n=this.coefficients,r=n.length,i=new Int32Array(r+e),s=this.field;for(let a=0;a<r;a++)i[a]=s.multiply(n[a],t);return new tt(s,i)}divide(e){if(!this.field.equals(e.field))throw new O("GenericGFPolys do n
4ot have same GenericGF field");if(e.isZero())throw new O("Divide by 0");const t=this.field;let n=t.getZero(),r=this;const i=e.getCoefficient(e.getDegree()),s=t.inverse(i);for(;r.getDegree()>=e.getDegree()&&!r.isZero();){const a=r.getDegree()-e.getDegree(),o=t.multiply(r.getCoefficient(r.getDegree()),s),l=e.multiplyByMonomial(a,o),c=t.buildMonomial(a,o);n=n.addOrSubtract(c),r=r.addOrSubtract(l)}return[n,r]}toString(){let e="";for(let t=this.getDegree();t>=0;t--){let n=this.getCoefficient(t);if(n!==0){if(n<0?(e+=" - ",n=-n):e.length>0&&(e+=" + "),t===0||n!==1){const r=this.field.log(n);r===0?e+="1":r===1?e+="a":(e+="a^",e+=r)}t!==0&&(t===1?e+="x":(e+="x^",e+=t))}}return e}}class Cn extends m{}Cn.kind="ArithmeticException";class he extends an{constructor(e,t,n){super(),this.primitive=e,this.size=t,this.generatorBase=n;const r=new Int32Array(t);let i=1;for(let a=0;a<t;a++)r[a]=i,i*=2,i>=t&&(i^=e,i&=t-1);this.expTable=r;const s=new Int32Array(t);for(let a=0;a<t-1;a++)s[r[a]]=a;this.logTable=s,this.zero=new tt(this,Int32Array.from([0])),this.one=new tt(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,t){if(e<0)throw new O;if(t===0)return this.zero;const n=new Int32Array(e+1);return n[0]=t,new tt(this,n)}inverse(e){if(e===0)throw new Cn;return this.expTable[this.size-this.logTable[e]-1]}multiply(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+J.toHexString(this.primitive)+","+this.size+")"}equals(e){return e===this}}he.AZTEC_DATA_12=new he(4201,4096,1),he.AZTEC_DATA_10=new he(1033,1024,1),he.AZTEC_DATA_6=new he(67,64,1),he.AZTEC_PARAM=new he(19,16,1),he.QR_CODE_FIELD_256=new he(285,256,0),he.DATA_MATRIX_FIELD_256=new he(301,256,1),he.AZTEC_DATA_8=he.DATA_MATRIX_FIELD_256,he.MAXICODE_FIELD_64=he.AZTEC_DATA_6;class jt extends m{}jt.kind="ReedSolomonException";class Ct extends m{}Ct.kind="IllegalStateException";class on{constructor(e){this.field=e}decode(e,t){const n=this.field,r=new tt(n,e),i=new Int32Array(t);let s=!0;for(let C=0;C<t;C++){const p=r.evaluateAt(n.exp(C+n.getGeneratorBase()));i[i.length-1-C]=p,p!==0&&(s=!1)}if(s)return;const a=new tt(n,i),o=this.runEuclideanAlgorithm(n.buildMonomial(t,1),a,t),l=o[0],c=o[1],f=this.findErrorLocations(l),d=this.findErrorMagnitudes(c,f);for(let C=0;C<f.length;C++){const p=e.length-1-n.log(f[C]);if(p<0)throw new jt("Bad error location");e[p]=he.addOrSubtract(e[p],d[C])}}runEuclideanAlgorithm(e,t,n){if(e.getDegree()<t.getDegree()){const C=e;e=t,t=C}const r=this.field;let i=e,s=t,a=r.getZero(),o=r.getOne();for(;s.getDegree()>=(n/2|0);){let C=i,p=a;if(i=s,a=o,i.isZero())throw new jt("r_{i-1} was zero");s=C;let b=r.getZero();const y=i.getCoefficient(i.getDegree()),N=r.inverse(y);for(;s.getDegree()>=i.getDegree()&&!s.isZero();){const F=s.getDegree()-i.getDegree(),k=r.multiply(s.getCoefficient(s.getDegree()),N);b=b.addOrSubtract(r.buildMonomial(F,k)),s=s.addOrSubtract(i.multiplyByMonomial(F,k))}if(o=b.multiply(a).addOrSubtract(p),s.getDegree()>=i.getDegree())throw new Ct("Division algorithm failed to reduce polynomial?")}const l=o.getCoefficient(0);if(l===0)throw new jt("sigmaTilde(0) was zero");const c=r.inverse(l),f=o.multiplyScalar(c),d=s.multiplyScalar(c);return[f,d]}findErrorLocations(e){const t=e.getDegree();if(t===1)return Int32Array.from([e.getCoefficient(1)]);const n=new Int32Array(t);let r=0;const i=this.field;for(let s=1;s<i.getSize()&&r<t;s++)e.evaluateAt(s)===0&&(n[r]=i.inverse(s),r++);if(r!==t)throw new jt("Error locator degree does not match number of roots");return n}findErrorMagnitudes(e,t){const n=t.length,r=new Int32Array(n),i=this.field;for(let s=0;s<n;s++){const a=i.inverse(t[s]);let o=1;for(let l=0;l<n;l++)if(s!==l){const c=i.multiply(t[l],a),f=(c&1)===0?c|1:c&-2;o=i.multiply(o,f)}r[s]=i.multiply(e.evaluateAt(a),i.inverse(o)),i.getGeneratorBase()!==0&&(r[s]=i.multiply(r[s],a))}return r}}var Xe;(function(u){u[u.UPPER=0]="UPPER",u[u.LOWER=1]="LOWER",u[u.MIXED=2]="MIXED",u[u.DIGIT=3]="DIGIT",u[u.PUNCT=4]="PUNCT",u[u.BINARY=5]="BINARY"})(Xe||(Xe={}));class be{decode(e){this.ddata=e;let t=e.getBits(),n=this.extractBits(t),r=this.correctBits(n),i=be.convertBoolArrayToByteArray(r),s=be.getEncodedData(r),a=new sn(i,s,null,null);return a.setNumBits(r.length),a}static highLevelDecode(e){return this.getEncodedData(e)}static getEncodedData(e){let t=e.length,n=Xe.UPPER,r=Xe.UPPER,i="",s=0;for(;s<t;)if(r===Xe.BINARY){if(t-s<5)break;let a=be.readCode(e,s,5);if(s+=5,a===0){if(t-s<11)break;a=be.readCode(e,s,11)+31,s+=11}for(let o=0;o<a;o++){if(t-s<8){s=t;break}const l=be.readCode(e,s,8);i+=$.castAsNonUtf8Char(l),s+=8}r=n}else{let a=r===Xe.DIGIT?4:5;if(t-s<a)break;let o=be.readCode(e,s,a);s+=a;let l=be.getCharacter(r,o);
4l.startsWith("CTRL_")?(n=r,r=be.getTable(l.charAt(5)),l.charAt(6)==="L"&&(n=r)):(i+=l,r=n)}return i}static getTable(e){switch(e){case"L":return Xe.LOWER;case"P":return Xe.PUNCT;case"M":return Xe.MIXED;case"D":return Xe.DIGIT;case"B":return Xe.BINARY;case"U":default:return Xe.UPPER}}static getCharacter(e,t){switch(e){case Xe.UPPER:return be.UPPER_TABLE[t];case Xe.LOWER:return be.LOWER_TABLE[t];case Xe.MIXED:return be.MIXED_TABLE[t];case Xe.PUNCT:return be.PUNCT_TABLE[t];case Xe.DIGIT:return be.DIGIT_TABLE[t];default:throw new Ct("Bad table")}}correctBits(e){let t,n;this.ddata.getNbLayers()<=2?(n=6,t=he.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(n=8,t=he.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(n=10,t=he.AZTEC_DATA_10):(n=12,t=he.AZTEC_DATA_12);let r=this.ddata.getNbDatablocks(),i=e.length/n;if(i<r)throw new V;let s=e.length%n,a=new Int32Array(i);for(let d=0;d<i;d++,s+=n)a[d]=be.readCode(e,s,n);try{new on(t).decode(a,i-r)}catch(d){throw new V(d)}let o=(1<<n)-1,l=0;for(let d=0;d<r;d++){let C=a[d];if(C===0||C===o)throw new V;(C===1||C===o-1)&&l++}let c=new Array(r*n-l),f=0;for(let d=0;d<r;d++){let C=a[d];if(C===1||C===o-1)c.fill(C>1,f,f+n-1),f+=n-1;else for(let p=n-1;p>=0;--p)c[f++]=(C&1<<p)!==0}return c}extractBits(e){let t=this.ddata.isCompact(),n=this.ddata.getNbLayers(),r=(t?11:14)+n*4,i=new Int32Array(r),s=new Array(this.totalBitsInLayer(n,t));if(t)for(let a=0;a<i.length;a++)i[a]=a;else{let a=r+1+2*J.truncDivision(J.truncDivision(r,2)-1,15),o=r/2,l=J.truncDivision(a,2);for(let c=0;c<o;c++){let f=c+J.truncDivision(c,15);i[o-c-1]=l-f-1,i[o+c]=l+f+1}}for(let a=0,o=0;a<n;a++){let l=(n-a)*4+(t?9:12),c=a*2,f=r-1-c;for(let d=0;d<l;d++){let C=d*2;for(let p=0;p<2;p++)s[o+C+p]=e.get(i[c+p],i[c+d]),s[o+2*l+C+p]=e.get(i[c+d],i[f-p]),s[o+4*l+C+p]=e.get(i[f-p],i[f-d]),s[o+6*l+C+p]=e.get(i[f-d],i[c+p])}o+=l*8}return s}static readCode(e,t,n){let r=0;for(let i=t;i<t+n;i++)r<<=1,e[i]&&(r|=1);return r}static readByte(e,t){let n=e.length-t;return n>=8?be.readCode(e,t,8):be.readCode(e,t,n)<<8-n}static convertBoolArrayToByteArray(e){let t=new Uint8Array((e.length+7)/8);for(let n=0;n<t.length;n++)t[n]=be.readByte(e,8*n);return t}totalBitsInLayer(e,t){return((t?88:112)+16*e)*e}}be.UPPER_TABLE=["CTRL_PS"," ","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","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],be.LOWER_TABLE=["CTRL_PS"," ","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","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],be.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",` 5`,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],be.PUNCT_TABLE=["","\r",`\r 6`,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],be.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class oe{constructor(){}static round(e){return e===NaN?0:e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,t,n,r){const i=e-n,s=t-r;return Math.sqrt(i*i+s*s)}static sum(e){let t=0;for(let n=0,r=e.length;n!==r;n++){const i=e[n];t+=i}return t}}class En{static floatToIntBits(e){return e}}En.MAX_VALUE=Number.MAX_SAFE_INTEGER;class X{constructor(e,t){this.x=e,this.y=t}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof X){const t=e;return this.x===t.x&&this.y===t.y}return!1}hashCode(){return 31*En.floatToIntBits(this.x)+En.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){const t=this.distance(e[0],e[1]),n=this.distance(e[1],e[2]),r=this.distance(e[0],e[2]);let i,s,a;if(n>=t&&n>=r?(s=e[0],i=e[1],a=e[2]):r>=n&&r>=t?(s=e[1],i=e[0],a=e[2]):(s=e[2],i=e[0],a=e[1]),this.crossProductZ(i,s,a)<0){const o=i;i=a,a=o}e[0]=i,e[1]=s,e[2]=a}static distance(e,t){return oe.distance(e.x,e.y,t.x,t.y)}static crossProductZ(e,t,n){const r=t.x,i=t.y;return(n.x-r)*(e.y-i)-(n.y-i)*(e.x-r)}}class mn{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class ur extends mn{constructor(e,t,n,r,i){super(e,t),this.compact=n,this.nbDatablocks=r,this.nbLayers=i}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class Tt{constructor(e,t,n,r){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),t==null&&(t=Tt.INIT_SIZE),n==null&&(n=e.getWidth()/2|0),r==null&&(r=e.getHeight()/2|0);const i=t/2|0;if(this.leftInit=n-i,this.rightInit=n+i,this.upInit=r-i,this.downInit=r+i,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new R}detect(){let e=this.leftInit,t=this.rightInit,n=this.upInit,r=this.downInit,i=!1,s=!0,a=!1,o=!1,l=!1,c=!1,f=!1;const d=this.width,C=this.height;for(;s;){s=!1;let p=!0;for(;(p||!o)&&t<d;)p=this.containsBlackPoint(n,r,t,!1),p?(t++,s=!0,o=!0):o||t++;if(t>=d){i=!0;break}let b=!0;for(;(b||!l)&&r<C;)b=this.containsBlackPoint(e,t,r,!0),b?(r++,s=!0,l=!0):l||r++;if(r>=C){i=!0;break}let y=!0;for(;(y||!c)&&e>=0;)y=this.containsBlackPoint(n,r,e,!1),y?(e--,s=!0,c=!0):c||e--;if(e<0){i=!0;break}let N=!0;for(;(N||!f)&&n>=0;)N=this.containsBlackPoint(e,t,n,!0),N?(n--,s=!0,f=!0):f||n--;if(n<0){i=!0;break}s&&(a=!0)}if(!i&&a){const p=t-e;let b=null;for(let k=1;b===null&&k<p;k++)b=this.getBlackPointOnSegment(e,r-k,e+k,r);if(b==null)throw new R;let y=null;for(let k=1;y===null&&k<p;k++)y=this.getBlackPointOnSegment(e,n+k,e+k,n);if(y==null)throw new R;let N=null;for(let k=1;N===null&&k<p;k++)N=this.getBlackPointOnSegment(t,n+k,t-k,n);if(N==null)throw new R;let F=null;for(let k=1;F===null&&k<p;k++)F=this.getBlackPointOnSegment(t,r-k,t-k,r);if(F==null)throw new R;return this.centerEdges(F,b,N,y)}else throw new R}getBlackPointOnSegment(e,t,n,r){const i=oe.round(oe.distance(e,t,n,r)),s=(n-e)/i,a=(r-t)/i,o=this.image;for(let l=0;l<i;l++){const c=oe.round(e+l*s),f=oe.round(t+l*a);if(o.get(c,f))return new X(c,f)}return null}centerEdges(e,t,n,r){const i=e.getX(),s=e.getY(),a=t.getX(),o=t.getY(),l=n.getX(),c=n.getY(),f=r.getX(),d=r.getY(),C=Tt.CORR;return i<this.width/2?[new X(f-C,d+C),new X(a+C,o+C),new X(l-C,c-C),new X(i+C,s-C)]:[new X(f+C,d+C),new X(a+C,o-C),new X(l-C,c+C),new X(i-C,s-C)]}containsBlackPoint(e,t,n,r){const i=this.image;if(r){for(let s=e;s<=t;s++)if(i.get(s,n))return!0}else for(let s=e;s<=t;s++)if(i.get(n,s))return!0;return!1}}Tt.INIT_SIZE=10,Tt.CORR=1;class kn{static checkAndNudgePoints(e,t){const n=e.getWidth(),r=e.getHeight();let i=!0;for(let s=0;s<t.length&&i;s+=2){const a=Math.floor(t[s]),o=Math.floor(t[s+1]);if(a<-1||a>n||o<-1||o>r)throw new R;i=!1,a===-1?(t[s]=0,i=!0):a===n&&(t[s]=n-1,i=!0),o===-1?(t[s+1]=0,i=!0):o===r&&(t[s+1]=r-1,i=!0)}i=!0;for(let s=t.length-2;s>=0&&i;s-=2){const a=Math.floor(t[s]),o=Math.floor(t[s+1]);if(a<-1||a>n||o<-1||o>r)throw new R;i=!1,a===-1?(t[s]=0,i=!0):a===n&&(t[s]=n-1,i=!0),o===-1?(t[s+1]=0,i=!0):o===r&&(t[s+1]=r-1,i=!0)}}}class xt{constructor(e,t,n,r,i,s,a,o,l){this.a11=e,this.a21=t,this.a31=n,this.a12=r,this.a22=i,this.a32=s,this.a13=a,this.a23=o,this.a33=l}static quadrilateralToQuadrilateral(e,t,n,r,i,s,a,o,l,c,f,d,C,p,b,y){const N=xt.quadrilateralToSquare(e,t,n,r,i,s,a,o);return xt.squareToQuadrilateral(l,c,f,d,C,p,b,y).times(N)}transformPoints(e){const t=e.length,n=this.a11,r=this.a12,i=this.a13,s=this.a21,a=this.a22,o=this.a23,l=this.a31,c=this.a32,f=this.a33;for(let d=0;d<t;d+=2){const C=e[d],p=e[d+1],b=i*C+o*p+f;e[d]=(n*C+s*p+l)/b,e[d+1]=(r*C+a*p+c)/b}}transformPointsWithValues(e,t){const n=this.a11,r=this.a12,i=this.a13,s=this.a21,a=this.a22,o=this.a23,l=this.a31,c=this.a32,f=this.a33,d=e.length;for(let C=0;C<d;C++){const p=e[C],b=t[C],y=i*p+o*b+f;e[C]=(n*p+s*b+l)/y,t[C]=(r*p+a*b+c)/y}}static squareToQuadrilateral(e,t,n,r,i,s,a,o){const l=e-n+i-a,c=t-r+s-o;if(l===0&&c===0)return new xt(n-e,i-n,e,r-t,s-r,t,0,0,1);
6{const f=n-i,d=a-i,C=r-s,p=o-s,b=f*p-d*C,y=(l*p-d*c)/b,N=(f*c-l*C)/b;return new xt(n-e+y*n,a-e+N*a,e,r-t+y*r,o-t+N*o,t,y,N,1)}}static quadrilateralToSquare(e,t,n,r,i,s,a,o){return xt.squareToQuadrilateral(e,t,n,r,i,s,a,o).buildAdjoint()}buildAdjoint(){return new xt(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(e){return new xt(this.a11*e.a11+this.a21*e.a12+this.a31*e.a13,this.a11*e.a21+this.a21*e.a22+this.a31*e.a23,this.a11*e.a31+this.a21*e.a32+this.a31*e.a33,this.a12*e.a11+this.a22*e.a12+this.a32*e.a13,this.a12*e.a21+this.a22*e.a22+this.a32*e.a23,this.a12*e.a31+this.a22*e.a32+this.a32*e.a33,this.a13*e.a11+this.a23*e.a12+this.a33*e.a13,this.a13*e.a21+this.a23*e.a22+this.a33*e.a23,this.a13*e.a31+this.a23*e.a32+this.a33*e.a33)}}class fr extends kn{sampleGrid(e,t,n,r,i,s,a,o,l,c,f,d,C,p,b,y,N,F,k){const v=xt.quadrilateralToQuadrilateral(r,i,s,a,o,l,c,f,d,C,p,b,y,N,F,k);return this.sampleGridWithTransform(e,t,n,v)}sampleGridWithTransform(e,t,n,r){if(t<=0||n<=0)throw new R;const i=new Ue(t,n),s=new Float32Array(2*t);for(let a=0;a<n;a++){const o=s.length,l=a+.5;for(let c=0;c<o;c+=2)s[c]=c/2+.5,s[c+1]=l;r.transformPoints(s),kn.checkAndNudgePoints(e,s);try{for(let c=0;c<o;c+=2)e.get(Math.floor(s[c]),Math.floor(s[c+1]))&&i.set(c/2,a)}catch{throw new R}}return i}}class Ot{static setGridSampler(e){Ot.gridSampler=e}static getInstance(){return Ot.gridSampler}}Ot.gridSampler=new fr;class Je{constructor(e,t){this.x=e,this.y=t}toResultPoint(){return new X(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class dr{constructor(e){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=e}detect(){return this.detectMirror(!1)}detectMirror(e){let t=this.getMatrixCenter(),n=this.getBullsEyeCorners(t);if(e){let s=n[0];n[0]=n[2],n[2]=s}this.extractParameters(n);let r=this.sampleGrid(this.image,n[this.shift%4],n[(this.shift+1)%4],n[(this.shift+2)%4],n[(this.shift+3)%4]),i=this.getMatrixCornerPoints(n);return new ur(r,i,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(e){if(!this.isValidPoint(e[0])||!this.isValidPoint(e[1])||!this.isValidPoint(e[2])||!this.isValidPoint(e[3]))throw new R;let t=2*this.nbCenterLayers,n=new Int32Array([this.sampleLine(e[0],e[1],t),this.sampleLine(e[1],e[2],t),this.sampleLine(e[2],e[3],t),this.sampleLine(e[3],e[0],t)]);this.shift=this.getRotation(n,t);let r=0;for(let s=0;s<4;s++){let a=n[(this.shift+s)%4];this.compact?(r<<=7,r+=a>>1&127):(r<<=10,r+=(a>>2&992)+(a>>1&31))}let i=this.getCorrectedParameterData(r,this.compact);this.compact?(this.nbLayers=(i>>6)+1,this.nbDataBlocks=(i&63)+1):(this.nbLayers=(i>>11)+1,this.nbDataBlocks=(i&2047)+1)}getRotation(e,t){let n=0;e.forEach((r,i,s)=>{let a=(r>>t-2<<1)+(r&1);n=(n<<3)+a}),n=((n&1)<<11)+(n>>1);for(let r=0;r<4;r++)if(J.bitCount(n^this.EXPECTED_CORNER_BITS[r])<=2)return r;throw new R}getCorrectedParameterData(e,t){let n,r;t?(n=7,r=2):(n=10,r=4);let i=n-r,s=new Int32Array(n);for(let o=n-1;o>=0;--o)s[o]=e&15,e>>=4;try{new on(he.AZTEC_PARAM).decode(s,i)}catch{throw new R}let a=0;for(let o=0;o<r;o++)a=(a<<4)+s[o];return a}getBullsEyeCorners(e){let t=e,n=e,r=e,i=e,s=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let f=this.getFirstDifferent(t,s,1,-1),d=this.getFirstDifferent(n,s,1,1),C=this.getFirstDifferent(r,s,-1,1),p=this.getFirstDifferent(i,s,-1,-1);if(this.nbCenterLayers>2){let b=this.distancePoint(p,f)*this.nbCenterLayers/(this.distancePoint(i,t)*(this.nbCenterLayers+2));if(b<.75||b>1.25||!this.isWhiteOrBlackRectangle(f,d,C,p))break}t=f,n=d,r=C,i=p,s=!s}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new R;this.compact=this.nbCenterLayers===5;let a=new X(t.getX()+.5,t.getY()-.5),o=new X(n.getX()+.5,n.getY()+.5),l=new X(r.getX()-.5,r.getY()+.5),c=new X(i.getX()-.5,i.getY()-.5);return this.expandSquare([a,o,l,c],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,t,n,r;try{let a=new Tt(this.image).detect();e=a[0],t=a[1],n=a[2],r=a[3]}catch{let o=this.image.getWidth()/2,l=this.image.getHeight()/2;e=this.getFirstDifferent(new Je(o+7,l-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new Je(o+7,l+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new Je(o-7,l+7),!1,-1,1).toResultPoint(),r=this.getFirstDifferent(new Je(o-7,l-7),!1,-1,-1).toResultPoint()}let i=oe.round((e.getX()+r.getX()+t.getX()+n.getX())/4),s=oe.round((e.getY()+r.getY()+t.getY()+n.getY())/4);try{let a=new Tt(this.image,15,i,s).detect();e=a[0],t=a[1],n=a[2],r=a[3]}catch{e=this.getFirstDifferent(new Je(i+7,s-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new Je(i+7,s+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new Je(i-7,s+7),!1,-1,1).toResultPoint(),r=this.getFirstDifferent(new Je(i-7,s-7
6),!1,-1,-1).toResultPoint()}return i=oe.round((e.getX()+r.getX()+t.getX()+n.getX())/4),s=oe.round((e.getY()+r.getY()+t.getY()+n.getY())/4),new Je(i,s)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,t,n,r,i){let s=Ot.getInstance(),a=this.getDimension(),o=a/2-this.nbCenterLayers,l=a/2+this.nbCenterLayers;return s.sampleGrid(e,a,a,o,o,l,o,l,l,o,l,t.getX(),t.getY(),n.getX(),n.getY(),r.getX(),r.getY(),i.getX(),i.getY())}sampleLine(e,t,n){let r=0,i=this.distanceResultPoint(e,t),s=i/n,a=e.getX(),o=e.getY(),l=s*(t.getX()-e.getX())/i,c=s*(t.getY()-e.getY())/i;for(let f=0;f<n;f++)this.image.get(oe.round(a+f*l),oe.round(o+f*c))&&(r|=1<<n-f-1);return r}isWhiteOrBlackRectangle(e,t,n,r){let i=3;e=new Je(e.getX()-i,e.getY()+i),t=new Je(t.getX()-i,t.getY()-i),n=new Je(n.getX()+i,n.getY()-i),r=new Je(r.getX()+i,r.getY()+i);let s=this.getColor(r,e);if(s===0)return!1;let a=this.getColor(e,t);return a!==s||(a=this.getColor(t,n),a!==s)?!1:(a=this.getColor(n,r),a===s)}getColor(e,t){let n=this.distancePoint(e,t),r=(t.getX()-e.getX())/n,i=(t.getY()-e.getY())/n,s=0,a=e.getX(),o=e.getY(),l=this.image.get(e.getX(),e.getY()),c=Math.ceil(n);for(let d=0;d<c;d++)a+=r,o+=i,this.image.get(oe.round(a),oe.round(o))!==l&&s++;let f=s/n;return f>.1&&f<.9?0:f<=.1===l?1:-1}getFirstDifferent(e,t,n,r){let i=e.getX()+n,s=e.getY()+r;for(;this.isValid(i,s)&&this.image.get(i,s)===t;)i+=n,s+=r;for(i-=n,s-=r;this.isValid(i,s)&&this.image.get(i,s)===t;)i+=n;for(i-=n;this.isValid(i,s)&&this.image.get(i,s)===t;)s+=r;return s-=r,new Je(i,s)}expandSquare(e,t,n){let r=n/(2*t),i=e[0].getX()-e[2].getX(),s=e[0].getY()-e[2].getY(),a=(e[0].getX()+e[2].getX())/2,o=(e[0].getY()+e[2].getY())/2,l=new X(a+r*i,o+r*s),c=new X(a-r*i,o-r*s);i=e[1].getX()-e[3].getX(),s=e[1].getY()-e[3].getY(),a=(e[1].getX()+e[3].getX())/2,o=(e[1].getY()+e[3].getY())/2;let f=new X(a+r*i,o+r*s),d=new X(a-r*i,o-r*s);return[l,f,c,d]}isValid(e,t){return e>=0&&e<this.image.getWidth()&&t>0&&t<this.image.getHeight()}isValidPoint(e){let t=oe.round(e.getX()),n=oe.round(e.getY());return this.isValid(t,n)}distancePoint(e,t){return oe.distance(e.getX(),e.getY(),t.getX(),t.getY())}distanceResultPoint(e,t){return oe.distance(e.getX(),e.getY(),t.getX(),t.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(J.truncDivision(this.nbLayers-4,8)+1)+15}}class pn{decode(e,t=null){let n=null,r=new dr(e.getBlackMatrix()),i=null,s=null;try{let c=r.detectMirror(!1);i=c.getPoints(),this.reportFoundResultPoints(t,i),s=new be().decode(c)}catch(c){n=c}if(s==null)try{let c=r.detectMirror(!0);i=c.getPoints(),this.reportFoundResultPoints(t,i),s=new be().decode(c)}catch(c){throw n??c}let a=new Qe(s.getText(),s.getRawBytes(),s.getNumBits(),i,K.AZTEC,Z.currentTimeMillis()),o=s.getByteSegments();o!=null&&a.putMetadata(Ge.BYTE_SEGMENTS,o);let l=s.getECLevel();return l!=null&&a.putMetadata(Ge.ERROR_CORRECTION_LEVEL,l),a}reportFoundResultPoints(e,t){if(e!=null){let n=e.get(we.NEED_RESULT_POINT_CALLBACK);n!=null&&t.forEach((r,i,s)=>{n.foundPossibleResultPoint(r)})}}reset(){}}class Qr extends Ft{constructor(e=500){super(new pn,e)}}class Pe{decode(e,t){try{return this.doDecode(e,t)}catch{if(t&&t.get(we.TRY_HARDER)===!0&&e.isRotateSupported()){const i=e.rotateCounterClockwise(),s=this.doDecode(i,t),a=s.getResultMetadata();let o=270;a!==null&&a.get(Ge.ORIENTATION)===!0&&(o=o+a.get(Ge.ORIENTATION)%360),s.putMetadata(Ge.ORIENTATION,o);const l=s.getResultPoints();if(l!==null){const c=i.getHeight();for(let f=0;f<l.length;f++)l[f]=new X(c-l[f].getY()-1,l[f].getX())}return s}else throw new R}}reset(){}doDecode(e,t){const n=e.getWidth(),r=e.getHeight();let i=new ce(n);const s=t&&t.get(we.TRY_HARDER)===!0,a=Math.max(1,r>>(s?8:5));let o;s?o=r:o=15;const l=Math.trunc(r/2);for(let c=0;c<o;c++){const f=Math.trunc((c+1)/2),d=(c&1)===0,C=l+a*(d?f:-f);if(C<0||C>=r)break;try{i=e.getBlackRow(C,i)}catch{continue}for(let p=0;p<2;p++){if(p===1&&(i.reverse(),t&&t.get(we.NEED_RESULT_POINT_CALLBACK)===!0)){const b=new Map;t.forEach((y,N)=>b.set(N,y)),b.delete(we.NEED_RESULT_POINT_CALLBACK),t=b}try{const b=this.decodeRow(C,i,t);
6if(p===1){b.putMetadata(Ge.ORIENTATION,180);const y=b.getResultPoints();y!==null&&(y[0]=new X(n-y[0].getX()-1,y[0].getY()),y[1]=new X(n-y[1].getX()-1,y[1].getY()))}return b}catch{}}}throw new R}static recordPattern(e,t,n){const r=n.length;for(let l=0;l<r;l++)n[l]=0;const i=e.getSize();if(t>=i)throw new R;let s=!e.get(t),a=0,o=t;for(;o<i;){if(e.get(o)!==s)n[a]++;else{if(++a===r)break;n[a]=1,s=!s}o++}if(!(a===r||a===r-1&&o===i))throw new R}static recordPatternInReverse(e,t,n){let r=n.length,i=e.get(t);for(;t>0&&r>=0;)e.get(--t)!==i&&(r--,i=!i);if(r>=0)throw new R;Pe.recordPattern(e,t+1,n)}static patternMatchVariance(e,t,n){const r=e.length;let i=0,s=0;for(let l=0;l<r;l++)i+=e[l],s+=t[l];if(i<s)return Number.POSITIVE_INFINITY;const a=i/s;n*=a;let o=0;for(let l=0;l<r;l++){const c=e[l],f=t[l]*a,d=c>f?c-f:f-c;if(d>n)return Number.POSITIVE_INFINITY;o+=d}return o/i}}class G extends Pe{static findStartPattern(e){const t=e.getSize(),n=e.getNextSet(0);let r=0,i=Int32Array.from([0,0,0,0,0,0]),s=n,a=!1;const o=6;for(let l=n;l<t;l++)if(e.get(l)!==a)i[r]++;else{if(r===o-1){let c=G.MAX_AVG_VARIANCE,f=-1;for(let d=G.CODE_START_A;d<=G.CODE_START_C;d++){const C=Pe.patternMatchVariance(i,G.CODE_PATTERNS[d],G.MAX_INDIVIDUAL_VARIANCE);C<c&&(c=C,f=d)}if(f>=0&&e.isRange(Math.max(0,s-(l-s)/2),s,!1))return Int32Array.from([s,l,f]);s+=i[0]+i[1],i=i.slice(2,i.length-1),i[r-1]=0,i[r]=0,r--}else r++;i[r]=1,a=!a}throw new R}static decodeCode(e,t,n){Pe.recordPattern(e,n,t);let r=G.MAX_AVG_VARIANCE,i=-1;for(let s=0;s<G.CODE_PATTERNS.length;s++){const a=G.CODE_PATTERNS[s],o=this.patternMatchVariance(t,a,G.MAX_INDIVIDUAL_VARIANCE);o<r&&(r=o,i=s)}if(i>=0)return i;throw new R}decodeRow(e,t,n){const r=n&&n.get(we.ASSUME_GS1)===!0,i=G.findStartPattern(t),s=i[2];let a=0;const o=new Uint8Array(20);o[a++]=s;let l;switch(s){case G.CODE_START_A:l=G.CODE_CODE_A;break;case G.CODE_START_B:l=G.CODE_CODE_B;break;case G.CODE_START_C:l=G.CODE_CODE_C;break;default:throw new V}let c=!1,f=!1,d="",C=i[0],p=i[1];const b=Int32Array.from([0,0,0,0,0,0]);let y=0,N=0,F=s,k=0,v=!0,ie=!1,ee=!1;for(;!c;){const en=f;switch(f=!1,y=N,N=G.decodeCode(t,b,p),o[a++]=N,N!==G.CODE_STOP&&(v=!0),N!==G.CODE_STOP&&(k++,F+=k*N),C=p,p+=b.reduce((Si,Ni)=>Si+Ni,0),N){case G.CODE_START_A:case G.CODE_START_B:case G.CODE_START_C:throw new V}switch(l){case G.CODE_CODE_A:if(N<64)ee===ie?d+=String.fromCharCode(32+N):d+=String.fromCharCode(32+N+128),ee=!1;else if(N<96)ee===ie?d+=String.fromCharCode(N-64):d+=String.fromCharCode(N+64),ee=!1;else switch(N!==G.CODE_STOP&&(v=!1),N){case G.CODE_FNC_1:r&&(d.length===0?d+="]C1":d+="�");break;case G.CODE_FNC_2:case G.CODE_FNC_3:break;case G.CODE_FNC_4_A:!ie&&ee?(ie=!0,ee=!1):ie&&ee?(ie=!1,ee=!1):ee=!0;break;case G.CODE_SHIFT:f=!0,l=G.CODE_CODE_B;break;case G.CODE_CODE_B:l=G.CODE_CODE_B;break;case G.CODE_CODE_C:l=G.CODE_CODE_C;break;case G.CODE_STOP:c=!0;break}break;case G.CODE_CODE_B:if(N<96)ee===ie?d+=String.fromCharCode(32+N):d+=String.fromCharCode(32+N+128),ee=!1;else switch(N!==G.CODE_STOP&&(v=!1),N){case G.CODE_FNC_1:r&&(d.length===0?d+="]C1":d+="�");break;case G.CODE_FNC_2:case G.CODE_FNC_3:break;case G.CODE_FNC_4_B:!ie&&ee?(ie=!0,ee=!1):ie&&ee?(ie=!1,ee=!1):ee=!0;break;case G.CODE_SHIFT:f=!0,l=G.CODE_CODE_A;break;case G.CODE_CODE_A:l=G.CODE_CODE_A;break;case G.CODE_CODE_C:l=G.CODE_CODE_C;break;case G.CODE_STOP:c=!0;break}break;case G.CODE_CODE_C:if(N<100)N<10&&(d+="0"),d+=N;else switch(N!==G.CODE_STOP&&(v=!1),N){case G.CODE_FNC_1:r&&(d.length===0?d+="]C1":d+="�");break;case G.CODE_CODE_A:l=G.CODE_CODE_A;break;case G.CODE_CODE_B:l=G.CODE_CODE_B;break;case G.CODE_STOP:c=!0;break}break}en&&(l=l===G.CODE_CODE_A?G.CODE_CODE_B:G.CODE_CODE_A)}const st=p-C;if(p=t.getNextUnset(p),!t.isRange(p,Math.min(t.getSize(),p+(p-C)/2),!1))throw new R;if(F-=k*y,F%103!==y)throw new j;const wt=d.length;if(wt===0)throw new R;wt>0&&v&&(l===G.CODE_CODE_C?d=d.substring(0,wt-2):d=d.substring(0,wt-1));const at=(i[1]+i[0])/2,pe=C+st/2,ze=o.length,lt=new Uint8Array(ze);for(let en=0;en<ze;en++)lt[en]=o[en];const $t=[new X(at,e),new X(pe,e)];return new Qe(d,lt,0,$t,K.CODE_128,new Date().getTime())}}G.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],G.MAX_AVG_VARIANCE=.25,G.MAX_INDIVIDUAL_VARIA
6NCE=.7,G.CODE_SHIFT=98,G.CODE_CODE_C=99,G.CODE_CODE_B=100,G.CODE_CODE_A=101,G.CODE_FNC_1=102,G.CODE_FNC_2=97,G.CODE_FNC_3=96,G.CODE_FNC_4_A=101,G.CODE_FNC_4_B=100,G.CODE_START_A=103,G.CODE_START_B=104,G.CODE_START_C=105,G.CODE_STOP=106;class Le extends Pe{constructor(e=!1,t=!1){super(),this.usingCheckDigit=e,this.extendedMode=t,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(e,t,n){let r=this.counters;r.fill(0),this.decodeRowResult="";let i=Le.findAsteriskPattern(t,r),s=t.getNextSet(i[1]),a=t.getSize(),o,l;do{Le.recordPattern(t,s,r);let b=Le.toNarrowWidePattern(r);if(b<0)throw new R;o=Le.patternToChar(b),this.decodeRowResult+=o,l=s;for(let y of r)s+=y;s=t.getNextSet(s)}while(o!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let c=0;for(let b of r)c+=b;let f=s-l-c;if(s!==a&&f*2<c)throw new R;if(this.usingCheckDigit){let b=this.decodeRowResult.length-1,y=0;for(let N=0;N<b;N++)y+=Le.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(N));if(this.decodeRowResult.charAt(b)!==Le.ALPHABET_STRING.charAt(y%43))throw new j;this.decodeRowResult=this.decodeRowResult.substring(0,b)}if(this.decodeRowResult.length===0)throw new R;let d;this.extendedMode?d=Le.decodeExtended(this.decodeRowResult):d=this.decodeRowResult;let C=(i[1]+i[0])/2,p=l+c/2;return new Qe(d,null,0,[new X(C,e),new X(p,e)],K.CODE_39,new Date().getTime())}static findAsteriskPattern(e,t){let n=e.getSize(),r=e.getNextSet(0),i=0,s=r,a=!1,o=t.length;for(let l=r;l<n;l++)if(e.get(l)!==a)t[i]++;else{if(i===o-1){if(this.toNarrowWidePattern(t)===Le.ASTERISK_ENCODING&&e.isRange(Math.max(0,s-Math.floor((l-s)/2)),s,!1))return[s,l];s+=t[0]+t[1],t.copyWithin(0,2,2+i-1),t[i-1]=0,t[i]=0,i--}else i++;t[i]=1,a=!a}throw new R}static toNarrowWidePattern(e){let t=e.length,n=0,r;do{let i=2147483647;for(let o of e)o<i&&o>n&&(i=o);n=i,r=0;let s=0,a=0;for(let o=0;o<t;o++){let l=e[o];l>n&&(a|=1<<t-1-o,r++,s+=l)}if(r===3){for(let o=0;o<t&&r>0;o++){let l=e[o];if(l>n&&(r--,l*2>=s))return-1}return a}}while(r>3);return-1}static patternToChar(e){for(let t=0;t<Le.CHARACTER_ENCODINGS.length;t++)if(Le.CHARACTER_ENCODINGS[t]===e)return Le.ALPHABET_STRING.charAt(t);if(e===Le.ASTERISK_ENCODING)return"*";throw new R}static decodeExtended(e){let t=e.length,n="";for(let r=0;r<t;r++){let i=e.charAt(r);if(i==="+"||i==="$"||i==="%"||i==="/"){let s=e.charAt(r+1),a="\0";switch(i){case"+":if(s>="A"&&s<="Z")a=String.fromCharCode(s.charCodeAt(0)+32);else throw new V;break;case"$":if(s>="A"&&s<="Z")a=String.fromCharCode(s.charCodeAt(0)-64);else throw new V;break;case"%":if(s>="A"&&s<="E")a=String.fromCharCode(s.charCodeAt(0)-38);else if(s>="F"&&s<="J")a=String.fromCharCode(s.charCodeAt(0)-11);else if(s>="K"&&s<="O")a=String.fromCharCode(s.charCodeAt(0)+16);else if(s>="P"&&s<="T")a=String.fromCharCode(s.charCodeAt(0)+43);else if(s==="U")a="\0";else if(s==="V")a="@";else if(s==="W")a="`";else if(s==="X"||s==="Y"||s==="Z")a="�";else throw new V;break;case"/":if(s>="A"&&s<="O")a=String.fromCharCode(s.charCodeAt(0)-32);else if(s==="Z")a=":";else throw new V;break}n+=a,r++}else n+=i}return n}}Le.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",Le.CHARACTER_ENCODINGS=[52,289,97,352,49,304,112,37,292,100,265,73,328,25,280,88,13,268,76,28,259,67,322,19,274,82,7,262,70,22,385,193,448,145,400,208,133,388,196,168,162,138,42],Le.ASTERISK_ENCODING=148;class Ee extends Pe{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,t,n){let r=this.decodeStart(t),i=this.decodeEnd(t),s=new Ae;Ee.decodeMiddle(t,r[1],i[0],s);let a=s.toString(),o=null;n!=null&&(o=n.get(we.ALLOWED_LENGTHS)),o==null&&(o=Ee.DEFAULT_ALLOWED_LENGTHS);let l=a.length,c=!1,f=0;for(let p of o){if(l===p){c=!0;break}p>f&&(f=p)}if(!c&&l>f&&(c=!0),!c)throw new V;const d=[new X(r[1],e),new X(i[0],e)];return new Qe(a,null,0,d,K.ITF,new Date().getTime())}static decodeMiddle(e,t,n,r){let i=new Int32Array(10),s=new Int32Array(5),a=new Int32Array(5);for(i.fill(0),s.fill(0),a.fill(0);t<n;){Pe.recordPattern(e,t,i);for(let l=0;l<5;l++){let c=2*l;s[l]=i[c],a[l]=i[c+1]}let o=Ee.decodeDigit(s);r.append(o.toString()),o=this.decodeDigit(a),r.append(o.toString()),i.forEac
6h(function(l){t+=l})}}decodeStart(e){let t=Ee.skipWhiteSpace(e),n=Ee.findGuardPattern(e,t,Ee.START_PATTERN);return this.narrowLineWidth=(n[1]-n[0])/4,this.validateQuietZone(e,n[0]),n}validateQuietZone(e,t){let n=this.narrowLineWidth*10;n=n<t?n:t;for(let r=t-1;n>0&&r>=0&&!e.get(r);r--)n--;if(n!==0)throw new R}static skipWhiteSpace(e){const t=e.getSize(),n=e.getNextSet(0);if(n===t)throw new R;return n}decodeEnd(e){e.reverse();try{let t=Ee.skipWhiteSpace(e),n;try{n=Ee.findGuardPattern(e,t,Ee.END_PATTERN_REVERSED[0])}catch(i){i instanceof R&&(n=Ee.findGuardPattern(e,t,Ee.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,n[0]);let r=n[0];return n[0]=e.getSize()-n[1],n[1]=e.getSize()-r,n}finally{e.reverse()}}static findGuardPattern(e,t,n){let r=n.length,i=new Int32Array(r),s=e.getSize(),a=!1,o=0,l=t;i.fill(0);for(let c=t;c<s;c++)if(e.get(c)!==a)i[o]++;else{if(o===r-1){if(Pe.patternMatchVariance(i,n,Ee.MAX_INDIVIDUAL_VARIANCE)<Ee.MAX_AVG_VARIANCE)return[l,c];l+=i[0]+i[1],Z.arraycopy(i,2,i,0,o-1),i[o-1]=0,i[o]=0,o--}else o++;i[o]=1,a=!a}throw new R}static decodeDigit(e){let t=Ee.MAX_AVG_VARIANCE,n=-1,r=Ee.PATTERNS.length;for(let i=0;i<r;i++){let s=Ee.PATTERNS[i],a=Pe.patternMatchVariance(e,s,Ee.MAX_INDIVIDUAL_VARIANCE);a<t?(t=a,n=i):a===t&&(n=-1)}if(n>=0)return n%10;throw new R}}Ee.PATTERNS=[Int32Array.from([1,1,2,2,1]),Int32Array.from([2,1,1,1,2]),Int32Array.from([1,2,1,1,2]),Int32Array.from([2,2,1,1,1]),Int32Array.from([1,1,2,1,2]),Int32Array.from([2,1,2,1,1]),Int32Array.from([1,2,2,1,1]),Int32Array.from([1,1,1,2,2]),Int32Array.from([2,1,1,2,1]),Int32Array.from([1,2,1,2,1]),Int32Array.from([1,1,3,3,1]),Int32Array.from([3,1,1,1,3]),Int32Array.from([1,3,1,1,3]),Int32Array.from([3,3,1,1,1]),Int32Array.from([1,1,3,1,3]),Int32Array.from([3,1,3,1,1]),Int32Array.from([1,3,3,1,1]),Int32Array.from([1,1,1,3,3]),Int32Array.from([3,1,1,3,1]),Int32Array.from([1,3,1,3,1])],Ee.MAX_AVG_VARIANCE=.38,Ee.MAX_INDIVIDUAL_VARIANCE=.5,Ee.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],Ee.START_PATTERN=Int32Array.from([1,1,1,1]),Ee.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Re extends Pe{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let t=!1,n,r=0,i=Int32Array.from([0,0,0]);for(;!t;){i=Int32Array.from([0,0,0]),n=Re.findGuardPattern(e,r,!1,this.START_END_PATTERN,i);let s=n[0];r=n[1];let a=s-(r-s);a>=0&&(t=e.isRange(a,s,!1))}return n}static checkChecksum(e){return Re.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return Re.getStandardUPCEANChecksum(e.substring(0,t-1))===n}static getStandardUPCEANChecksum(e){let t=e.length,n=0;for(let r=t-1;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new V;n+=i}n*=3;for(let r=t-2;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new V;n+=i}return(1e3-n)%10}static decodeEnd(e,t){return Re.findGuardPattern(e,t,!1,Re.START_END_PATTERN,new Int32Array(Re.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,t,n,r){return this.findGuardPattern(e,t,n,r,new Int32Array(r.length))}static findGuardPattern(e,t,n,r,i){let s=e.getSize();t=n?e.getNextUnset(t):e.getNextSet(t);let a=0,o=t,l=r.length,c=n;for(let f=t;f<s;f++)if(e.get(f)!==c)i[a]++;else{if(a===l-1){if(Pe.patternMatchVariance(i,r,Re.MAX_INDIVIDUAL_VARIANCE)<Re.MAX_AVG_VARIANCE)return Int32Array.from([o,f]);o+=i[0]+i[1];let d=i.slice(2,i.length-1);for(let C=0;C<a-1;C++)i[C]=d[C];i[a-1]=0,i[a]=0,a--}else a++;i[a]=1,c=!c}throw new R}static decodeDigit(e,t,n,r){this.recordPattern(e,n,t);let i=this.MAX_AVG_VARIANCE,s=-1,a=r.length;for(let o=0;o<a;o++){let l=r[o],c=Pe.patternMatchVariance(t,l,Re.MAX_INDIVIDUAL_VARIANCE);c<i&&(i=c,s=o)}if(s>=0)return s;throw new R}}Re.MAX_AVG_VARIANCE=.48,Re.MAX_INDIVIDUAL_VARIANCE=.7,Re.START_END_PATTERN=Int32Array.from([1,1,1]),Re.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Re.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Re.L_PATTERNS=[Int32Array.from([3,2,1,1]),Int32Array.from([2,2,2,1]),Int32Array.from([2,1,2,2]),Int32Array.from([1,4,1,1]),Int32Array.from([1,1,3,2]),Int32Array.from([1,2,3,1]),Int32Array.from([1,1,1,4]),Int32Array.from([1,3,1,2]),Int32Array.from([1,2,1,3]),Int32Array.from([3,1,1,2])];class ln{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,n){let r=this.decodeRowStringBuffer,i=this.decodeMiddle(t,n,r),s=r.toString(),a=ln.parseExtensionString(s),o=[new X((n[0]+n[1])/2,e),new X(i,e)],l=new Qe(s,null,0,o,K.UPC_EAN_EXTENSION,new Date().getTime());return a!=null&&l.putAllMetadata(a),l}decodeMiddle(e,t,n){let r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1],a=0;for(let l=0;l<5&&s<i;l++){let c=Re.decodeDigit(e,r,s,Re.L_AND_G_PATTERNS);n+=String.fromCharCode(48+c%10);for(let f of r)s+=f;c>=10&&(a|=1<<4-l),l!==4&&(s=e.getNextSet(s),s=e.getNextUnset(s))}if(n.length!==5)throw new R;let o=this.determineCheckDigit(a);if(ln.extensionChecksum(n.toString())!==o)throw new R;return s}static extensionChecksum(e){let t=e.length,n=0;for(let r=t-2;r>=0;r-=2)n+=e.charAt(r).charCodeAt(0)-48;n*=3;for(let r=t-1;r>=0;r-=2)n+=e.charAt(r).charCodeAt(0)-48;return n*=3,n%10}determineCheckDigit(e){for(let t=0;t<10;t++)if(e===this.CHECK_DIGIT_ENCODINGS[t])return t;throw new R}static parseExtensionString(e){if(e.length!==5)return null;let t=ln.parseExtension5String(e);return t==null?null:new Map([[Ge.SUGGESTED_PRICE,t]])}static parseExtension5String(e){let t;switch(e.charAt(0)){case"0":t="£";break;case"5":t="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}t="";break;default:t="";break}let n=parseInt(e.substring(1)),r=(n/100).toString(),i=n%100,s=i<10?"0"+i:i.toString();return t+r+"."+s}}class Un{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,n){let r=this.decodeRowStringBuffer,i=this.decodeMiddle(t,n,r),s=r.toString(),a=Un.parseExtensionString(s),o=[new X((n[0]+n[1])/2,e),new X(i,e)],l=new Qe(s,null,0,o,K.UPC_EAN_EXTENSION,new Date().getTime());return a!=null&&l.putAllMetadata(a),l}decodeMiddle(e,t,n){let r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1],a=0;for(let o=0;o<2&&s<i;o++){let l=Re.decodeDigit(e,r,s,Re.L_AND_G_PATTERNS);n+=String.fromCharCode(48+l%10);for(let c of r)s+=c;l>=10&&(a|=1<<1-o),o!==1&&(s=e.getNextSet(s),s=e.getNextUnset(s))}if(n.length!==2)throw new R;if(parseInt(n.toString())%4!==a)throw new R;return s}static parseExtensionString(e){return e.length!==2?null:new Map([[Ge.ISSUE_NUMBER,parseInt(e)]])}}class xr{static decodeRow(e,t,n){let r=Re.findGuardPattern(t,n,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new ln().decodeRow(e,t,r)}catch{return new Un().decodeRow(e,t,r)}}}xr.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class ue extends Re{constructor(){super(),this.decodeRowStringBuffer="",ue.L_AND_G_PATTERNS=ue.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let t=ue.L_PATTERNS[e-10],n=new Int32Array(t.length);for(let r=0;r<t.length;r++)n[r]=t[t.length-r-1];ue.L_AND_G_PATTERNS[e]=n}}decodeRow(e,t,n){let r=ue.findStartGuardPattern(t),i=n==null?null:n.get(we.NEED_RESULT_POINT_CALLBACK);if(i!=null){const v=new X((r[0]+r[1])/2,e);i.foundPossibleResultPoint(v)}let s=this.decodeMiddle(t,r,this.decodeRowStringBuffer),a=s.rowOffset,o=s.resultString;if(i!=null){const v=new X(a,e);i.foundPossibleResultPoint(v)}let l=this.decodeEnd(t,a);if(i!=null){const v=new X((l[0]+l[1])/2,e);i.foundPossibleResultPoint(v)}let c=l[1],f=c+(c-l[0]);if(f>=t.getSize()||!t.isRange(c,f,!1))throw new R;let d=o.toString();if(d.length<8)throw new V;if(!ue.checkChecksum(d))throw new j;let C=(r[1]+r[0])/2,p=(l[1]+l[0])/2,b=this.getBarcodeFormat(),y=[new X(C,e),new X(p,e)],N=new Qe(d,null,0,y,b,new Date().getTime()),F=0;try{let v=xr.decodeRow(e,t,l[1]);N.putMetadata(Ge.UPC_EAN_EXTENSION,v.getText()),N.putAllMetadata(v.getResultMetadata()),N.addResultPoints(v.getResultPoints()),F=v.getText().length}catch{}let k=n==null?null:n.get(we.ALLOWED_EAN_EXTENSIONS);if(k!=null){let v=!1;for(let ie in k)if(F.toString()===ie){v=!0;break}if(!v)throw new R}return N}decodeEnd(e,t){return ue.findGuardPattern(e,t,!1,ue.START_END_PATTERN,new Int32Array(ue.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return ue.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return ue.getStandardUPCEANChecksum(e.substring(0,t-1))===n}static getStandardUPCEANChecksum(e){let t=e.length,n=0;for(let r=t-1;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new V;n+=i}n*=3;for(let r=t-2;r>=0;r-=2){let i=e.charAt(r).charCodeAt(0)-48;if(i<0||i>9)throw new V;n+=i}return(1e3-n)%10}}class kt extends ue{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,n){let r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1],a=0;for(let l=0;l<6&&s<i;l++){let c=ue.decodeDigit(e,r,s,ue.L_AND_G_PATTERNS);n+=String.fromCharCode(48+c%10);for(let f of r)s+=f;c>=10&&(a|=1<<5-l)}n=kt.determineFirstDigit(n,a),s=ue.findGuardPattern(e,s,!0,ue.MIDDLE_PATTERN,new Int32Array(ue.MIDDLE_PATTERN.length).fill(0))[1];for(let l=0;l<6&&s<i;l++){let c=ue.decodeDigit(e,r,s,ue.L_PATTERNS);n+=String.fromCharCode(48+c);for(let f of r)s+=f}return{rowOffset:s,resultString:n}}getBarcodeFormat(){return K.EAN_13}static determineFirstDigit(e,t){for(let n=0;n<10;n++)if(t===this.FIRST_DIGIT_ENCODINGS[n])return e=String.fromCharCode(48+n)+e,e;throw new R}}kt.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class gr extends ue{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,n){const r=this.decodeMiddleCounters;r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s=t[1];for(let o=0;o<4&&s<i;o++){let l=ue.decodeDigit(e,r,s,ue.L_PATTERNS);n+=String.fromCharCode(48+l);for(let c of r)s+=c}s=ue.findGuardPattern(e,s,!0,ue.MIDDLE_PATTERN,new Int32Array(ue.MIDDLE_PATTERN.length).fill(0))[1];for(let o=0;o<4&&s<i;o++){let l=ue.decodeDigit(e,r,s,ue.L_PATTERNS);n+=String.fromCharCode(48+l);for(let c of r)s+=c}return{rowOffset:s,resultString:n}}getBarcodeFormat(){return K.EAN_8}}class wr extends ue{constructor(){super(...arguments),this.ean13Reader=new kt}getBarcodeFormat(){return K.UPC_A}decode(e,t){return this.maybeReturnResult(this.ean13Reader.decode(e))}decodeRow(e,t,n){return this.maybeReturnResult(this.ean13Reader.decodeRow(e,t,n))}decodeMiddle(e,t,n){return this.ean13Reader.decodeMiddle(e,t,n)}maybeReturnResult(e){let t=e.getText();if(t.charAt(0)==="0"){let n=new Qe(t.substring(1),null,null,e.getResultPoints(),K.UPC_A);return e.getResultMetadata()!=null&&n.putAllMetadata(e.getResultMetadata()),n}else throw new R}reset(){this.ean13Reader.reset()}}class gt extends ue{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(e,t,n){const r=this.decodeMiddleCounters.map(l=>l);r[0]=0,r[1]=0,r[2]=0,r[3]=0;const i=e.getSize();let s=t[1],a=0;for(let l=0;l<6&&s<i;l++){const c=gt.decodeDigit(e,r,s,gt.L_AND_G_PATTERNS);n+=String.fromCharCode(48+c%10);for(let f of r)s+=f;c>=10&&(a|=1<<5-l)}let o=gt.determineNumSysAndCheckDigit(n,a);return{rowOffset:s,resultString:o}}decodeEnd(e,t){return gt.findGuardPatternWithoutCounters(e,t,!0,gt.MIDDLE_END_PATTERN)}checkChecksum(e){return ue.checkChecksum(gt.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,t){for(let n=0;n<=1;n++)for(let r=0;r<10;r++)if(t===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[n][r]){let i=String.fromCharCode(48+n),s=String.fromCharCode(48+r);return i+e+s}throw R.getNotFoundInstance()}getBarcodeFormat(){return K.UPC_E}static convertUPCEtoUPCA(e){const t=e.slice(1,7).split("").map(i=>i.charCodeAt(0)),n=new Ae;n.append(e.charAt(0));let r=t[5];switch(r){case 0:case 1:case 2:n.appendChars(t,0,2),n.append(r),n.append("0000"),n.appendChars(t,2,3);break;case 3:n.appendChars(t,0,3),n.append("00000"),n.appendChars(t,3,2);break;case 4:n.appendChars(t,0,4),n.append("00000"),n.append(t[4]);break;default:n.appendChars(t,0,5),n.append("0000"),n.append(r);break}return e.length>=8&&n.append(e.charAt(7)),n.toString()}}gt.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),gt.NUMSYS_AND_CHECK_DIGIT_PATTERNS=[Int32Array.from([56,52,50,49,44,38,35,42,41,37]),Int32Array.from([7,11,13,14,19,25,28,21,22,26])];class Vn extends Pe{constructor(e){super();let t=e==null?null:e.get(we.POSSIBLE_FORMATS),n=[];E(t)?(n.push(new kt),n.push(new wr),n.push(new gr),n.push(new gt)):(t.indexOf(K.EA
6N_13)>-1&&n.push(new kt),t.indexOf(K.UPC_A)>-1&&n.push(new wr),t.indexOf(K.EAN_8)>-1&&n.push(new gr),t.indexOf(K.UPC_E)>-1&&n.push(new gt)),this.readers=n}decodeRow(e,t,n){for(let r of this.readers)try{const i=r.decodeRow(e,t,n),s=i.getBarcodeFormat()===K.EAN_13&&i.getText().charAt(0)==="0",a=n==null?null:n.get(we.POSSIBLE_FORMATS),o=a==null||a.includes(K.UPC_A);if(s&&o){const l=i.getRawBytes(),c=new Qe(i.getText().substring(1),l,l?l.length:null,i.getResultPoints(),K.UPC_A);return c.putAllMetadata(i.getResultMetadata()),c}return i}catch{}throw new R}reset(){for(let e of this.readers)e.reset()}}class Ze extends Pe{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,t){for(let n=0;n<t.length;n++)if(Pe.patternMatchVariance(e,t[n],Ze.MAX_INDIVIDUAL_VARIANCE)<Ze.MAX_AVG_VARIANCE)return n;throw new R}static count(e){return oe.sum(new Int32Array(e))}static increment(e,t){let n=0,r=t[0];for(let i=1;i<e.length;i++)t[i]>r&&(r=t[i],n=i);e[n]++}static decrement(e,t){let n=0,r=t[0];for(let i=1;i<e.length;i++)t[i]<r&&(r=t[i],n=i);e[n]--}static isFinderPattern(e){let t=e[0]+e[1],n=t+e[2]+e[3],r=t/n;if(r>=Ze.MIN_FINDER_PATTERN_RATIO&&r<=Ze.MAX_FINDER_PATTERN_RATIO){let i=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER;for(let a of e)a>s&&(s=a),a<i&&(i=a);return s<10*i}return!1}}Ze.MAX_AVG_VARIANCE=.2,Ze.MAX_INDIVIDUAL_VARIANCE=.45,Ze.MIN_FINDER_PATTERN_RATIO=9.5/12,Ze.MAX_FINDER_PATTERN_RATIO=12.5/14;
6class Yt{constructor(e,t){this.value=e,this.checksumPortion=t}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(e){if(!(e instanceof Yt))return!1;const t=e;return this.value===t.value&&this.checksumPortion===t.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class In{constructor(e,t,n,r,i){this.value=e,this.startEnd=t,this.value=e,this.startEnd=t,this.resultPoints=new Array,this.resultPoints.push(new X(n,i)),this.resultPoints.push(new X(r,i))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(e){if(!(e instanceof In))return!1;const t=e;return this.value===t.value}hashCode(){return this.value}}class Et{constructor(){}static getRSSvalue(e,t,n){let r=0;for(let o of e)r+=o;let i=0,s=0,a=e.length;for(let o=0;o<a-1;o++){let l;for(l=1,s|=1<<o;l<e[o];l++,s&=~(1<<o)){let c=Et.combins(r-l-1,a-o-2);if(n&&s===0&&r-l-(a-o-1)>=a-o-1&&(c-=Et.combins(r-l-(a-o),a-o-2)),a-o-1>1){let f=0;for(let d=r-l-(a-o-2);d>t;d--)f+=Et.combins(r-l-d-1,a-o-3);c-=f*(a-1-o)}else r-l>t&&c--;i+=c}r-=l}return i}static combins(e,t){let n,r;e-t>t?(r=t,n=e-t):(r=e-t,n=t);let i=1,s=1;for(let a=e;a>n;a--)i*=a,s<=r&&(i/=s,s++);for(;s<=r;)i/=s,s++;return i}}class Jr{static buildBitArray(e){let t=e.length*2-1;e[e.length-1].getRightChar()==null&&(t-=1);let n=12*t,r=new ce(n),i=0,a=e[0].getRightChar().getValue();for(let o=11;o>=0;--o)(a&1<<o)!=0&&r.set(i),i++;for(let o=1;o<e.length;++o){let l=e[o],c=l.getLeftChar().getValue();for(let f=11;f>=0;--f)(c&1<<f)!=0&&r.set(i),i++;if(l.getRightChar()!=null){let f=l.getRightChar().getValue();for(let d=11;d>=0;--d)(f&1<<d)!=0&&r.set(i),i++}}return r}}class Ut{constructor(e,t){t?this.decodedInformation=null:(this.finished=e,this.decodedInformation=t)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class Gn{constructor(e){this.newPosition=e}getNewPosition(){return this.newPosition}}class nt extends Gn{constructor(e,t){super(e),this.value=t}getValue(){return this.value}isFNC1(){return this.value===nt.FNC1}}nt.FNC1="$";class Vt extends Gn{constructor(e,t,n){super(e),n?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=t}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class ht extends Gn{constructor(e,t,n){if(super(e),t<0||t>10||n<0||n>10)throw new V;this.firstDigit=t,this.secondDigit=n}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===ht.FNC1}isSecondDigitFNC1(){return this.secondDigit===ht.FNC1}isAnyFNC1(){return this.firstDigit===ht.FNC1||this.secondDigit===ht.FNC1}}ht.FNC1=10;class H{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new R;let t=e.substring(0,2);for(let i of H.TWO_DIGIT_DATA_LENGTH)if(i[0]===t)return i[1]===H.VARIABLE_LENGTH?H.processVariableAI(2,i[2],e):H.processFixedAI(2,i[1],e);if(e.length<3)throw new R;let n=e.substring(0,3);for(let i of H.THREE_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===H.VARIABLE_LENGTH?H.processVariableAI(3,i[2],e):H.processFixedAI(3,i[1],e);for(let i of H.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===H.VARIABLE_LENGTH?H.processVariableAI(4,i[2],e):H.processFixedAI(4,i[1],e);if(e.length<4)throw new R;let r=e.substring(0,4);for(let i of H.FOUR_DIGIT_DATA_LENGTH)if(i[0]===r)return i[1]===H.VARIABLE_LENGTH?H.processVariableAI(4,i[2],e):H.processFixedAI(4,i[1],e);throw new R}
6static processFixedAI(e,t,n){if(n.length<e)throw new R;let r=n.substring(0,e);if(n.length<e+t)throw new R;let i=n.substring(e,e+t),s=n.substring(e+t),a="("+r+")"+i,o=H.parseFieldsInGeneralPurpose(s);return o==null?a:a+o}static processVariableAI(e,t,n){let r=n.substring(0,e),i;n.length<e+t?i=n.length:i=e+t;let s=n.substring(e,i),a=n.substring(i),o="("+r+")"+s,l=H.parseFieldsInGeneralPurpose(a);return l==null?o:o+l}}H.VARIABLE_LENGTH=[],H.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",H.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",H.VARIABLE_LENGTH,20],["22",H.VARIABLE_LENGTH,29],["30",H.VARIABLE_LENGTH,8],["37",H.VARIABLE_LENGTH,8],["90",H.VARIABLE_LENGTH,30],["91",H.VARIABLE_LENGTH,30],["92",H.VARIABLE_LENGTH,30],["93",H.VARIABLE_LENGTH,30],["94",H.VARIABLE_LENGTH,30],["95",H.VARIABLE_LENGTH,30],["96",H.VARIABLE_LENGTH,30],["97",H.VARIABLE_LENGTH,3],["98",H.VARIABLE_LENGTH,30],["99",H.VARIABLE_LENGTH,30]],H.THREE_DIGIT_DATA_LENGTH=[["240",H.VARIABLE_LENGTH,30],["241",H.VARIABLE_LENGTH,30],["242",H.VARIABLE_LENGTH,6],["250",H.VARIABLE_LENGTH,30],["251",H.VARIABLE_LENGTH,30],["253",H.VARIABLE_LENGTH,17],["254",H.VARIABLE_LENGTH,20],["400",H.VARIABLE_LENGTH,30],["401",H.VARIABLE_LENGTH,30],["402",17],["403",H.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",H.VARIABLE_LENGTH,20],["421",H.VARIABLE_LENGTH,15],["422",3],["423",H.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],H.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",H.VARIABLE_LENGTH,15],["391",H.VARIABLE_LENGTH,18],["392",H.VARIABLE_LENGTH,15],["393",H.VARIABLE_LENGTH,18],["703",H.VARIABLE_LENGTH,30]],H.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",H.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",H.VARIABLE_LENGTH,20],["8003",H.VARIABLE_LENGTH,30],["8004",H.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",H.VARIABLE_LENGTH,30],["8008",H.VARIABLE_LENGTH,12],["8018",18],["8020",H.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",H.VARIABLE_LENGTH,70],["8200",H.VARIABLE_LENGTH,70]];class zt{constructor(e){this.buffer=new Ae,this.information=e}decodeAllCodes(e,t){let n=t,r=null;do{let i=this.decodeGeneralPurposeField(n,r),s=H.parseFieldsInGeneralPurpose(i.getNewString());if(s!=null&&e.append(s),i.isRemaining()?r=""+i.getRemainingValue():r=null,n===i.getNewPosition())break;n=i.getNewPosition()}while(!0);return e.toString()}isStillNumeric(e){if(e+7>this.information.getSize())return e+4<=this.information.getSize();for(let t=e;t<e+3;++t)if(this.information.get(t))return!0;return this.information.get(e+3)}decodeNumeric(e){if(e+7>this.information.getSize()){let i=this.extractNumericValueFromBitArray(e,4);return i===0?new ht(this.information.getSize(),ht.FNC1,ht.FNC1):new ht(this.information.getSize(),i-1,ht.FNC1)}let t=this.extractNumericValueFromBitArray(e,7),n=(t-8)/11,r=(t-8)%11;return new ht(e+7,n,r)}extractNumericValueFromBitArray(e,t){return zt.extractNumericValueFromBitArray(this.information,e,t)}static extractNumericValueFromBitArray(e,t,n){let r=0;for(let i=0;i<n;++i)e.get(t+i)&&(r|=1<<n-i-1);return r}decodeGeneralPurposeField(e,t){this.buffer.setLengthToZero(),t!=null&&this.buffer.append(t),this.current.setPosition(e);let n=this.parseBlocks();return n!=null&&n.isRemaining()?new Vt(this.current.getPosition(),this.buffer.toString(),n.getRemainingValue()):new Vt(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let e,t;do{let n=this.current.getPosition();if(this.current.isAlpha()?(t=this.parseAlphaBlock(),e=t.isFinished()):this.current.isIsoIec646()?(t=this.parseIsoIec646Block(),e=t.is
6Finished()):(t=this.parseNumericBlock(),e=t.isFinished()),!(n!==this.current.getPosition())&&!e)break}while(!e);return t.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let e=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFirstDigitFNC1()){let t;return e.isSecondDigitFNC1()?t=new Vt(this.current.getPosition(),this.buffer.toString()):t=new Vt(this.current.getPosition(),this.buffer.toString(),e.getSecondDigit()),new Ut(!0,t)}if(this.buffer.append(e.getFirstDigit()),e.isSecondDigitFNC1()){let t=new Vt(this.current.getPosition(),this.buffer.toString());return new Ut(!0,t)}this.buffer.append(e.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new Ut(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let e=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let t=new Vt(this.current.getPosition(),this.buffer.toString());return new Ut(!0,t)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new Ut(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let e=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let t=new Vt(this.current.getPosition(),this.buffer.toString());return new Ut(!0,t)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new Ut(!1)}isStillIsoIec646(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+7>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<116)return!0;if(e+8>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,8);return r>=232&&r<253}decodeIsoIec646(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new nt(e+5,nt.FNC1);if(t>=5&&t<15)return new nt(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<90)return new nt(e+7,""+(n+1));if(n>=90&&n<116)return new nt(e+7,""+(n+7));let r=this.extractNumericValueFromBitArray(e,8),i;switch(r){case 232:i="!";break;case 233:i='"';break;case 234:i="%";break;case 235:i="&";break;case 236:i="'";break;case 237:i="(";break;case 238:i=")";break;case 239:i="*";break;case 240:i="+";break;case 241:i=",";break;case 242:i="-";break;case 243:i=".";break;case 244:i="/";break;case 245:i=":";break;case 246:i=";";break;case 247:i="<";break;case 248:i="=";break;case 249:i=">";break;case 250:i="?";break;case 251:i="_";break;case 252:i=" ";break;default:throw new V}return new nt(e+8,i)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+6>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,6);return n>=16&&n<63}decodeAlphanumeric(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new nt(e+5,nt.FNC1);if(t>=5&&t<15)return new nt(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,6);if(n>=32&&n<58)return new nt(e+6,""+(n+33));let r;switch(n){case 58:r="*";break;case 59:r=",";break;case 60:r="-";break;case 61:r=".";break;case 62:r="/";break;default:throw new Ct("Decoding invalid alphanumeric value: "+n)}return new nt(e+6,r)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<5&&t+e<this.information.getSize();++t)if(t===2){if(!this.information.get(e+2))return!1}else if(this.information.get(e+t))return!1;return!0}isAlphaOr646ToNumericLatch(e){if(e+3>this.information.getSize())return!1;for(let t=e;t<e+3;++t)if(this.information.get(t))return!1;return!0}isNumericToAlphaNumericLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<4&&t+e<this.information.getSize();++t)if(this.information.get(e+t))return!1;return!0}}class Hn{constructor(e){this.information=e,this.generalDecoder=new zt(e)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class rt extends Hn{constructor(e){super(e)}encodeCompressedGtin(e,t){e.append("(01)");let n=e.length();e.append("9"),this.encodeCompressedGtinWithoutAI(e,t,n)}encodeCompressedGtinWithoutAI(e,t,n){for(let r=0;r<4;++r){let i=this.getGeneralDecoder().extractNumericValueFromBitArray(t
6+10*r,10);i/100===0&&e.append("0"),i/10===0&&e.append("0"),e.append(i)}rt.appendCheckDigit(e,n)}static appendCheckDigit(e,t){let n=0;for(let r=0;r<13;r++){let i=e.charAt(r+t).charCodeAt(0)-48;n+=(r&1)===0?3*i:i}n=10-n%10,n===10&&(n=0),e.append(n)}}rt.GTIN_SIZE=40;class Zt extends rt{constructor(e){super(e)}parseInformation(){let e=new Ae;e.append("(01)");let t=e.length(),n=this.getGeneralDecoder().extractNumericValueFromBitArray(Zt.HEADER_SIZE,4);return e.append(n),this.encodeCompressedGtinWithoutAI(e,Zt.HEADER_SIZE+4,t),this.getGeneralDecoder().decodeAllCodes(e,Zt.HEADER_SIZE+44)}}Zt.HEADER_SIZE=4;class bn extends Hn{constructor(e){super(e)}parseInformation(){let e=new Ae;return this.getGeneralDecoder().decodeAllCodes(e,bn.HEADER_SIZE)}}bn.HEADER_SIZE=5;class yn extends rt{constructor(e){super(e)}encodeCompressedWeight(e,t,n){let r=this.getGeneralDecoder().extractNumericValueFromBitArray(t,n);this.addWeightCode(e,r);let i=this.checkWeight(r),s=1e5;for(let a=0;a<5;++a)i/s===0&&e.append("0"),s/=10;e.append(i)}}class mt extends yn{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()!=mt.HEADER_SIZE+yn.GTIN_SIZE+mt.WEIGHT_SIZE)throw new R;let e=new Ae;return this.encodeCompressedGtin(e,mt.HEADER_SIZE),this.encodeCompressedWeight(e,mt.HEADER_SIZE+yn.GTIN_SIZE,mt.WEIGHT_SIZE),e.toString()}}mt.HEADER_SIZE=5,mt.WEIGHT_SIZE=15;class $r extends mt{constructor(e){super(e)}addWeightCode(e,t){e.append("(3103)")}checkWeight(e){return e}}class ei extends mt{constructor(e){super(e)}addWeightCode(e,t){t<1e4?e.append("(3202)"):e.append("(3203)")}checkWeight(e){return e<1e4?e:e-1e4}}class pt extends rt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<pt.HEADER_SIZE+rt.GTIN_SIZE)throw new R;let e=new Ae;this.encodeCompressedGtin(e,pt.HEADER_SIZE);let t=this.getGeneralDecoder().extractNumericValueFromBitArray(pt.HEADER_SIZE+rt.GTIN_SIZE,pt.LAST_DIGIT_SIZE);e.append("(392"),e.append(t),e.append(")");let n=this.getGeneralDecoder().decodeGeneralPurposeField(pt.HEADER_SIZE+rt.GTIN_SIZE+pt.LAST_DIGIT_SIZE,null);return e.append(n.getNewString()),e.toString()}}pt.HEADER_SIZE=8,pt.LAST_DIGIT_SIZE=2;class $e extends rt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<$e.HEADER_SIZE+rt.GTIN_SIZE)throw new R;let e=new Ae;this.encodeCompressedGtin(e,$e.HEADER_SIZE);let t=this.getGeneralDecoder().extractNumericValueFromBitArray($e.HEADER_SIZE+rt.GTIN_SIZE,$e.LAST_DIGIT_SIZE);e.append("(393"),e.append(t),e.append(")");let n=this.getGeneralDecoder().extractNumericValueFromBitArray($e.HEADER_SIZE+rt.GTIN_SIZE+$e.LAST_DIGIT_SIZE,$e.FIRST_THREE_DIGITS_SIZE);n/100==0&&e.append("0"),n/10==0&&e.append("0"),e.append(n);let r=this.getGeneralDecoder().decodeGeneralPurposeField($e.HEADER_SIZE+rt.GTIN_SIZE+$e.LAST_DIGIT_SIZE+$e.FIRST_THREE_DIGITS_SIZE,null);return e.append(r.getNewString()),e.toString()}}$e.HEADER_SIZE=8,$e.LAST_DIGIT_SIZE=2,$e.FIRST_THREE_DIGITS_SIZE=10;class Ne extends yn{constructor(e,t,n){super(e),this.dateCode=n,this.firstAIdigits=t}parseInformation(){if(this.getInformation().getSize()!=Ne.HEADER_SIZE+Ne.GTIN_SIZE+Ne.WEIGHT_SIZE+Ne.DATE_SIZE)throw new R;let e=new Ae;return this.encodeCompressedGtin(e,Ne.HEADER_SIZE),this.encodeCompressedWeight(e,Ne.HEADER_SIZE+Ne.GTIN_SIZE,Ne.WEIGHT_SIZE),this.encodeCompressedDate(e,Ne.HEADER_SIZE+Ne.GTIN_SIZE+Ne.WEIGHT_SIZE),e.toString()}encodeCompressedDate(e,t){let n=this.getGeneralDecoder().extractNumericValueFromBitArray(t,Ne.DATE_SIZE);if(n==38400)return;e.append("("),e.append(this.dateCode),e.append(")");let r=n%32;n/=32;let i=n%12+1;n/=12;let s=n;s/10==0&&e.append("0"),e.append(s),i/10==0&&e.append("0"),e.append(i),r/10==0&&e.append("0"),e.append(r)}addWeightCode(e,t){e.append("("),e.append(this.firstAIdigits),e.append(t/1e5),e.append(")")}checkWeight(e){return e%1e5}}Ne.HEADER_SIZE=8,Ne.WEIGHT_SIZE=20,Ne.DATE_SIZE=16;function Ar(u){try{if(u.get(1))return new Zt(u);if(!u.get(2))return new bn(u);switch(zt.extractNumericValueFromBitArray(u,1,4)){case 4:return new $r(u);case 5:return new ei(u)}switch(zt.extractNumericValueFromBitArray(u,1,5)){case 12:return new pt(u);case 13:return new $e(u)}switch(zt.extractNumericValueFromBitArray(u,1,7)){case 56:return new Ne(u,"310","11");case 57:return new Ne(u,"320","11");case 58:return new Ne(u,"310","13");case 59:return new Ne(u,"320","13");case 60:return new Ne(u,"310","15");case 61:return new Ne(u,"320","15");case 62:return new Ne(u,"310","17");case 63:return new Ne(u,"320","17")}
6}catch(e){throw console.log(e),new Ct("unknown decoder: "+u)}}class Dt{constructor(e,t,n,r){this.leftchar=e,this.rightchar=t,this.finderpattern=n,this.maybeLast=r}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(e,t){return e instanceof Dt?Dt.equalsOrNull(e.leftchar,t.leftchar)&&Dt.equalsOrNull(e.rightchar,t.rightchar)&&Dt.equalsOrNull(e.finderpattern,t.finderpattern):!1}static equalsOrNull(e,t){return e===null?t===null:Dt.equals(e,t)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class Wn{constructor(e,t,n){this.pairs=e,this.rowNumber=t,this.wasReversed=n}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(e){return this.checkEqualitity(this,e)}toString(){return"{ "+this.pairs+" }"}equals(e,t){return e instanceof Wn?this.checkEqualitity(e,t)&&e.wasReversed===t.wasReversed:!1}checkEqualitity(e,t){if(!e||!t)return;let n;return e.forEach((r,i)=>{t.forEach(s=>{r.getLeftChar().getValue()===s.getLeftChar().getValue()&&r.getRightChar().getValue()===s.getRightChar().getValue()&&r.getFinderPatter().getValue()===s.getFinderPatter().getValue()&&(n=!0)})}),n}}class M extends Ze{constructor(e){super(...arguments),this.pairs=new Array(M.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=e===!0}decodeRow(e,t,n){this.pairs.length=0,this.startFromEven=!1;try{return M.constructResult(this.decodeRow2pairs(e,t))}catch(r){this.verbose&&console.log(r)}return this.pairs.length=0,this.startFromEven=!0,M.constructResult(this.decodeRow2pairs(e,t))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,t){let n=!1;for(;!n;)try{this.pairs.push(this.retrieveNextPair(t,this.pairs,e))}catch(i){if(i instanceof R){if(!this.pairs.length)throw new R;n=!0}}if(this.checkChecksum())return this.pairs;let r;if(this.rows.length?r=!0:r=!1,this.storeRow(e,!1),r){let i=this.checkRowsBoolean(!1);if(i!=null||(i=this.checkRowsBoolean(!0),i!=null))return i}throw new R}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let t=null;try{t=this.checkRows(new Array,0)}catch(n){this.verbose&&console.log(n)}return e&&(this.rows=this.rows.reverse()),t}checkRows(e,t){for(let n=t;n<this.rows.length;n++){let r=this.rows[n];this.pairs.length=0;for(let s of e)this.pairs.push(s.getPairs());if(this.pairs.push(r.getPairs()),!M.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let i=new Array(e);i.push(r);try{return this.checkRows(i,n+1)}catch(s){this.verbose&&console.log(s)}}throw new R}static isValidSequence(e){for(let t of M.FINDER_PATTERN_SEQUENCES){if(e.length>t.length)continue;let n=!0;for(let r=0;r<e.length;r++)if(e[r].getFinderPattern().getValue()!=t[r]){n=!1;break}if(n)return!0}return!1}storeRow(e,t){let n=0,r=!1,i=!1;for(;n<this.rows.length;){let s=this.rows[n];if(s.getRowNumber()>e){i=s.isEquivalent(this.pairs);break}r=s.isEquivalent(this.pairs),n++}i||r||M.isPartialRow(this.pairs,this.rows)||(this.rows.push(n,new Wn(this.pairs,e,t)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,t){for(let n of t)if(n.getPairs().length!==e.length){for(let r of n.getPairs())for(let i of e)if(Dt.equals(r,i))break}}static isPartialRow(e,t){for(let n of t){let r=!0;for(let i of e){let s=!1;for(let a of n.getPairs())if(i.equals(a)){s=!0;break}if(!s){r=!1;break}}if(r)return!0}return!1}getRows(){return this.rows}static constructResult(e){let t=Jr.buildBitArray(e),r=Ar(t).parseInformation(),i=e[0].getFinderPattern().getResultPoints(),s=e[e.length-1].getFinderPattern().getResultPoints(),a=[i[0],i[1],s[0],s[1]];return new Qe(r,null,null,a,K.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),t=e.getLeftChar(),n=e.getRightChar();if(n==null)return!1;let r=n.getChecksumPortion(),i=2;
6for(let a=1;a<this.pairs.size();++a){let o=this.pairs.get(a);r+=o.getLeftChar().getChecksumPortion(),i++;let l=o.getRightChar();l!=null&&(r+=l.getChecksumPortion(),i++)}return r%=211,211*(i-4)+r==t.getValue()}static getNextSecondBar(e,t){let n;return e.get(t)?(n=e.getNextUnset(t),n=e.getNextSet(n)):(n=e.getNextSet(t),n=e.getNextUnset(n)),n}retrieveNextPair(e,t,n){let r=t.length%2==0;this.startFromEven&&(r=!r);let i,s=!0,a=-1;do this.findNextPair(e,t,a),i=this.parseFoundFinderPattern(e,n,r),i==null?a=M.getNextSecondBar(e,this.startEnd[0]):s=!1;while(s);let o=this.decodeDataCharacter(e,i,r,!0);if(!this.isEmptyPair(t)&&t[t.length-1].mustBeLast())throw new R;let l;try{l=this.decodeDataCharacter(e,i,r,!1)}catch(c){l=null,this.verbose&&console.log(c)}return new Dt(o,l,i,!0)}isEmptyPair(e){return e.length===0}findNextPair(e,t,n){let r=this.getDecodeFinderCounters();r[0]=0,r[1]=0,r[2]=0,r[3]=0;let i=e.getSize(),s;n>=0?s=n:this.isEmptyPair(t)?s=0:s=t[t.length-1].getFinderPattern().getStartEnd()[1];let a=t.length%2!=0;this.startFromEven&&(a=!a);let o=!1;for(;s<i&&(o=!e.get(s),!!o);)s++;let l=0,c=s;for(let f=s;f<i;f++)if(e.get(f)!=o)r[l]++;else{if(l==3){if(a&&M.reverseCounters(r),M.isFinderPattern(r)){this.startEnd[0]=c,this.startEnd[1]=f;return}a&&M.reverseCounters(r),c+=r[0]+r[1],r[0]=r[2],r[1]=r[3],r[2]=0,r[3]=0,l--}else l++;r[l]=1,o=!o}throw new R}static reverseCounters(e){let t=e.length;for(let n=0;n<t/2;++n){let r=e[n];e[n]=e[t-n-1],e[t-n-1]=r}}parseFoundFinderPattern(e,t,n){let r,i,s;if(n){let l=this.startEnd[0]-1;for(;l>=0&&!e.get(l);)l--;l++,r=this.startEnd[0]-l,i=l,s=this.startEnd[1]}else i=this.startEnd[0],s=e.getNextUnset(this.startEnd[1]+1),r=s-this.startEnd[1];let a=this.getDecodeFinderCounters();Z.arraycopy(a,0,a,1,a.length-1),a[0]=r;let o;try{o=this.parseFinderValue(a,M.FINDER_PATTERNS)}catch{return null}return new In(o,[i,s],i,s,t)}decodeDataCharacter(e,t,n,r){let i=this.getDataCharacterCounters();for(let pe=0;pe<i.length;pe++)i[pe]=0;if(r)M.recordPatternInReverse(e,t.getStartEnd()[0],i);else{M.recordPattern(e,t.getStartEnd()[1],i);for(let pe=0,ze=i.length-1;pe<ze;pe++,ze--){let lt=i[pe];i[pe]=i[ze],i[ze]=lt}}let s=17,a=oe.sum(new Int32Array(i))/s,o=(t.getStartEnd()[1]-t.getStartEnd()[0])/15;if(Math.abs(a-o)/o>.3)throw new R;let l=this.getOddCounts(),c=this.getEvenCounts(),f=this.getOddRoundingErrors(),d=this.getEvenRoundingErrors();for(let pe=0;pe<i.length;pe++){let ze=1*i[pe]/a,lt=ze+.5;if(lt<1){if(ze<.3)throw new R;lt=1}else if(lt>8){if(ze>8.7)throw new R;lt=8}let $t=pe/2;(pe&1)==0?(l[$t]=lt,f[$t]=ze-lt):(c[$t]=lt,d[$t]=ze-lt)}this.adjustOddEvenCounts(s);let C=4*t.getValue()+(n?0:2)+(r?0:1)-1,p=0,b=0;for(let pe=l.length-1;pe>=0;pe--){if(M.isNotA1left(t,n,r)){let ze=M.WEIGHTS[C][2*pe];b+=l[pe]*ze}p+=l[pe]}let y=0;for(let pe=c.length-1;pe>=0;pe--)if(M.isNotA1left(t,n,r)){let ze=M.WEIGHTS[C][2*pe+1];y+=c[pe]*ze}let N=b+y;if((p&1)!=0||p>13||p<4)throw new R;let F=(13-p)/2,k=M.SYMBOL_WIDEST[F],v=9-k,ie=Et.getRSSvalue(l,k,!0),ee=Et.getRSSvalue(c,v,!1),st=M.EVEN_TOTAL_SUBSET[F],wt=M.GSUM[F],at=ie*st+ee+wt;return new Yt(at,N)}static isNotA1left(e,t,n){return!(e.getValue()==0&&t&&n)}adjustOddEvenCounts(e){let t=oe.sum(new Int32Array(this.getOddCounts())),n=oe.sum(new Int32Array(this.getEvenCounts())),r=!1,i=!1;t>13?i=!0:t<4&&(r=!0);let s=!1,a=!1;n>13?a=!0:n<4&&(s=!0);let o=t+n-e,l=(t&1)==1,c=(n&1)==0;if(o==1)if(l){if(c)throw new R;i=!0}else{if(!c)throw new R;a=!0}else if(o==-1)if(l){if(c)throw new R;r=!0}else{if(!c)throw new R;s=!0}else if(o==0){if(l){if(!c)throw new R;t<n?(r=!0,a=!0):(i=!0,s=!0)}else if(c)throw new R}else throw new R;if(r){if(i)throw new R;M.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(i&&M.decrement(this.getOddCounts(),this.getOddRoundingErrors()),s){if(a)throw new R;M.increment(this.getEvenCounts(),this.getOddRoundingErrors())}a&&M.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}M.SYMBOL_WIDEST=[7,5,4,3,1],M.EVEN_TOTAL_SUBSET=[4,20,52,104,204],M.GSUM=[0,348,1388,2948,3988],M.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],M.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,9
61],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],M.FINDER_PAT_A=0,M.FINDER_PAT_B=1,M.FINDER_PAT_C=2,M.FINDER_PAT_D=3,M.FINDER_PAT_E=4,M.FINDER_PAT_F=5,M.FINDER_PATTERN_SEQUENCES=[[M.FINDER_PAT_A,M.FINDER_PAT_A],[M.FINDER_PAT_A,M.FINDER_PAT_B,M.FINDER_PAT_B],[M.FINDER_PAT_A,M.FINDER_PAT_C,M.FINDER_PAT_B,M.FINDER_PAT_D],[M.FINDER_PAT_A,M.FINDER_PAT_E,M.FINDER_PAT_B,M.FINDER_PAT_D,M.FINDER_PAT_C],[M.FINDER_PAT_A,M.FINDER_PAT_E,M.FINDER_PAT_B,M.FINDER_PAT_D,M.FINDER_PAT_D,M.FINDER_PAT_F],[M.FINDER_PAT_A,M.FINDER_PAT_E,M.FINDER_PAT_B,M.FINDER_PAT_D,M.FINDER_PAT_E,M.FINDER_PAT_F,M.FINDER_PAT_F],[M.FINDER_PAT_A,M.FINDER_PAT_A,M.FINDER_PAT_B,M.FINDER_PAT_B,M.FINDER_PAT_C,M.FINDER_PAT_C,M.FINDER_PAT_D,M.FINDER_PAT_D],[M.FINDER_PAT_A,M.FINDER_PAT_A,M.FINDER_PAT_B,M.FINDER_PAT_B,M.FINDER_PAT_C,M.FINDER_PAT_C,M.FINDER_PAT_D,M.FINDER_PAT_E,M.FINDER_PAT_E],[M.FINDER_PAT_A,M.FINDER_PAT_A,M.FINDER_PAT_B,M.FINDER_PAT_B,M.FINDER_PAT_C,M.FINDER_PAT_C,M.FINDER_PAT_D,M.FINDER_PAT_E,M.FINDER_PAT_F,M.FINDER_PAT_F],[M.FINDER_PAT_A,M.FINDER_PAT_A,M.FINDER_PAT_B,M.FINDER_PAT_B,M.FINDER_PAT_C,M.FINDER_PAT_D,M.FINDER_PAT_D,M.FINDER_PAT_E,M.FINDER_PAT_E,M.FINDER_PAT_F,M.FINDER_PAT_F]],M.MAX_PAIRS=11;class ti extends Yt{constructor(e,t,n){super(e,t),this.count=0,this.finderPattern=n}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class Oe extends Ze{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(e,t,n){const r=this.decodePair(t,!1,e,n);Oe.addOrTally(this.possibleLeftPairs,r),t.reverse();let i=this.decodePair(t,!0,e,n);Oe.addOrTally(this.possibleRightPairs,i),t.reverse();for(let s of this.possibleLeftPairs)if(s.getCount()>1){for(let a of this.possibleRightPairs)if(a.getCount()>1&&Oe.checkChecksum(s,a))return Oe.constructResult(s,a)}throw new R}static addOrTally(e,t){if(t==null)return;let n=!1;for(let r of e)if(r.getValue()===t.getValue()){r.incrementCount(),n=!0;break}n||e.push(t)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,t){let n=4537077*e.getValue()+t.getValue(),r=new String(n).toString(),i=new Ae;for(let l=13-r.length;l>0;l--)i.append("0");i.append(r);let s=0;for(let l=0;l<13;l++){let c=i.charAt(l).charCodeAt(0)-48;s+=(l&1)===0?3*c:c}s=10-s%10,s===10&&(s=0),i.append(s.toString());let a=e.getFinderPattern().getResultPoints(),o=t.getFinderPattern().getResultPoints();return new Qe(i.toString(),null,0,[a[0],a[1],o[0],o[1]],K.RSS_14,new Date().getTime())}static checkChecksum(e,t){let n=(e.getChecksumPortion()+16*t.getChecksumPortion())%79,r=9*e.getFinderPattern().getValue()+t.getFinderPattern().getValue();return r>72&&r--,r>8&&r--,n===r}decodePair(e,t,n,r){try{let i=this.findFinderPattern(e,t),s=this.parseFoundFinderPattern(e,n,t,i),a=r==null?null:r.get(we.NEED_RESULT_POINT_CALLBACK);if(a!=null){let c=(i[0]+i[1])/2;t&&(c=e.getSize()-1-c),a.foundPossibleResultPoint(new X(c,n))}let o=this.decodeDataCharacter(e,s,!0),l=this.decodeDataCharacter(e,s,!1);return new ti(1597*o.getValue()+l.getValue(),o.getChecksumPortion()+4*l.getChecksumPortion(),s)}catch{return null}}decodeDataCharacter(e,t,n){let r=this.getDataCharacterCounters();for(let y=0;y<r.length;y++)r[y]=0;if(n)Pe.recordPatternInReverse(e,t.getStartEnd()[0],r);else{Pe.recordPattern(e,t.getStartEnd()[1]+1,r);for(let y=0,N=r.length-1;y<N;y++,N--){let F=r[y];r[y]=r[N],r[N]=F}}let i=n?16:15,s=oe.sum(new Int32Array(r))/i,a=this.getOddCounts(),o=this.getEvenCounts(),l=this.getOddRoundingErrors(),c=this.getEvenRoundingErrors();for(let y=0;y<r.length;y++){let N=r[y]/s,F=Math.floor(N+.5);F<1?F=1:F>8&&(F=8);let k=Math.floor(y/2);(y&1)===0?(a[k]=F,l[k]=N-F):(o[k]=F,c[k]=N-F)}this.adjustOddEvenCounts(n,i);let f=0,d=0;for(let y=a.length-1;y>=0;y--)d*=9,d+=a[y],f+=a[y];let C=0,p=0;for(let y=o.length-1;y>=0;y--)C*=9,C+=o[y],p+=o[y];let b=d+3*C;if(n){if((f&1)!==0||f>12||f<4)throw new R;let y=(12-f)/2,N=Oe.OUTSIDE_ODD_WIDEST[y],F=9-N,k=Et.getRSSvalue(
6a,N,!1),v=Et.getRSSvalue(o,F,!0),ie=Oe.OUTSIDE_EVEN_TOTAL_SUBSET[y],ee=Oe.OUTSIDE_GSUM[y];return new Yt(k*ie+v+ee,b)}else{if((p&1)!==0||p>10||p<4)throw new R;let y=(10-p)/2,N=Oe.INSIDE_ODD_WIDEST[y],F=9-N,k=Et.getRSSvalue(a,N,!0),v=Et.getRSSvalue(o,F,!1),ie=Oe.INSIDE_ODD_TOTAL_SUBSET[y],ee=Oe.INSIDE_GSUM[y];return new Yt(v*ie+k+ee,b)}}findFinderPattern(e,t){let n=this.getDecodeFinderCounters();n[0]=0,n[1]=0,n[2]=0,n[3]=0;let r=e.getSize(),i=!1,s=0;for(;s<r&&(i=!e.get(s),t!==i);)s++;let a=0,o=s;for(let l=s;l<r;l++)if(e.get(l)!==i)n[a]++;else{if(a===3){if(Ze.isFinderPattern(n))return[o,l];o+=n[0]+n[1],n[0]=n[2],n[1]=n[3],n[2]=0,n[3]=0,a--}else a++;n[a]=1,i=!i}throw new R}parseFoundFinderPattern(e,t,n,r){let i=e.get(r[0]),s=r[0]-1;for(;s>=0&&i!==e.get(s);)s--;s++;const a=r[0]-s,o=this.getDecodeFinderCounters(),l=new Int32Array(o.length);Z.arraycopy(o,0,l,1,o.length-1),l[0]=a;const c=this.parseFinderValue(l,Oe.FINDER_PATTERNS);let f=s,d=r[1];return n&&(f=e.getSize()-1-f,d=e.getSize()-1-d),new In(c,[s,r[1]],f,d,t)}adjustOddEvenCounts(e,t){let n=oe.sum(new Int32Array(this.getOddCounts())),r=oe.sum(new Int32Array(this.getEvenCounts())),i=!1,s=!1,a=!1,o=!1;e?(n>12?s=!0:n<4&&(i=!0),r>12?o=!0:r<4&&(a=!0)):(n>11?s=!0:n<5&&(i=!0),r>10?o=!0:r<4&&(a=!0));let l=n+r-t,c=(n&1)===(e?1:0),f=(r&1)===1;if(l===1)if(c){if(f)throw new R;s=!0}else{if(!f)throw new R;o=!0}else if(l===-1)if(c){if(f)throw new R;i=!0}else{if(!f)throw new R;a=!0}else if(l===0){if(c){if(!f)throw new R;n<r?(i=!0,o=!0):(s=!0,a=!0)}else if(f)throw new R}else throw new R;if(i){if(s)throw new R;Ze.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(s&&Ze.decrement(this.getOddCounts(),this.getOddRoundingErrors()),a){if(o)throw new R;Ze.increment(this.getEvenCounts(),this.getOddRoundingErrors())}o&&Ze.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}Oe.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],Oe.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],Oe.OUTSIDE_GSUM=[0,161,961,2015,2715],Oe.INSIDE_GSUM=[0,336,1036,1516],Oe.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],Oe.INSIDE_ODD_WIDEST=[2,4,6,8],Oe.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class Kt extends Pe{constructor(e,t){super(),this.readers=[],this.verbose=t===!0;const n=e?e.get(we.POSSIBLE_FORMATS):null,r=e&&e.get(we.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;n?((n.includes(K.EAN_13)||n.includes(K.UPC_A)||n.includes(K.EAN_8)||n.includes(K.UPC_E))&&this.readers.push(new Vn(e)),n.includes(K.CODE_39)&&this.readers.push(new Le(r)),n.includes(K.CODE_128)&&this.readers.push(new G),n.includes(K.ITF)&&this.readers.push(new Ee),n.includes(K.RSS_14)&&this.readers.push(new Oe),n.includes(K.RSS_EXPANDED)&&this.readers.push(new M(this.verbose))):(this.readers.push(new Vn(e)),this.readers.push(new Le),this.readers.push(new Vn(e)),this.readers.push(new G),this.readers.push(new Ee),this.readers.push(new Oe),this.readers.push(new M(this.verbose)))}decodeRow(e,t,n){for(let r=0;r<this.readers.length;r++)try{return this.readers[r].decodeRow(e,t,n)}catch{}throw new R}reset(){this.readers.forEach(e=>e.reset())}}class ni extends Ft{constructor(e=500,t){super(new Kt(t),e,t)}}class de{constructor(e,t,n){this.ecCodewords=e,this.ecBlocks=[t],n&&this.ecBlocks.push(n)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class fe{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class se{constructor(e,t,n,r,i,s){this.versionNumber=e,this.symbolSizeRows=t,this.symbolSizeColumns=n,this.dataRegionSizeRows=r,this.dataRegionSizeColumns=i,this.ecBlocks=s;let a=0;const o=s.getECCodewords(),l=s.getECBlocks();for(let c of l)a+=c.getCount()*(c.getDataCodewords()+o);this.totalCodewords=a}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}
6static getVersionForDimensions(e,t){if((e&1)!==0||(t&1)!==0)throw new V;for(let n of se.VERSIONS)if(n.symbolSizeRows===e&&n.symbolSizeColumns===t)return n;throw new V}toString(){return""+this.versionNumber}static buildVersions(){return[new se(1,10,10,8,8,new de(5,new fe(1,3))),new se(2,12,12,10,10,new de(7,new fe(1,5))),new se(3,14,14,12,12,new de(10,new fe(1,8))),new se(4,16,16,14,14,new de(12,new fe(1,12))),new se(5,18,18,16,16,new de(14,new fe(1,18))),new se(6,20,20,18,18,new de(18,new fe(1,22))),new se(7,22,22,20,20,new de(20,new fe(1,30))),new se(8,24,24,22,22,new de(24,new fe(1,36))),new se(9,26,26,24,24,new de(28,new fe(1,44))),new se(10,32,32,14,14,new de(36,new fe(1,62))),new se(11,36,36,16,16,new de(42,new fe(1,86))),new se(12,40,40,18,18,new de(48,new fe(1,114))),new se(13,44,44,20,20,new de(56,new fe(1,144))),new se(14,48,48,22,22,new de(68,new fe(1,174))),new se(15,52,52,24,24,new de(42,new fe(2,102))),new se(16,64,64,14,14,new de(56,new fe(2,140))),new se(17,72,72,16,16,new de(36,new fe(4,92))),new se(18,80,80,18,18,new de(48,new fe(4,114))),new se(19,88,88,20,20,new de(56,new fe(4,144))),new se(20,96,96,22,22,new de(68,new fe(4,174))),new se(21,104,104,24,24,new de(56,new fe(6,136))),new se(22,120,120,18,18,new de(68,new fe(6,175))),new se(23,132,132,20,20,new de(62,new fe(8,163))),new se(24,144,144,22,22,new de(62,new fe(8,156),new fe(2,155))),new se(25,8,18,6,16,new de(7,new fe(1,5))),new se(26,8,32,6,14,new de(11,new fe(1,10))),new se(27,12,26,10,24,new de(14,new fe(1,16))),new se(28,12,36,10,16,new de(18,new fe(1,22))),new se(29,16,36,14,16,new de(24,new fe(1,32))),new se(30,16,48,14,22,new de(28,new fe(1,49)))]}}se.VERSIONS=se.buildVersions();class Xn{constructor(e){const t=e.getHeight();if(t<8||t>144||(t&1)!==0)throw new V;this.version=Xn.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new Ue(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){const t=e.getHeight(),n=e.getWidth();return se.getVersionForDimensions(t,n)}readCodewords(){const e=new Int8Array(this.version.getTotalCodewords());let t=0,n=4,r=0;const i=this.mappingBitMatrix.getHeight(),s=this.mappingBitMatrix.getWidth();let a=!1,o=!1,l=!1,c=!1;do if(n===i&&r===0&&!a)e[t++]=this.readCorner1(i,s)&255,n-=2,r+=2,a=!0;else if(n===i-2&&r===0&&(s&3)!==0&&!o)e[t++]=this.readCorner2(i,s)&255,n-=2,r+=2,o=!0;else if(n===i+4&&r===2&&(s&7)===0&&!l)e[t++]=this.readCorner3(i,s)&255,n-=2,r+=2,l=!0;else if(n===i-2&&r===0&&(s&7)===4&&!c)e[t++]=this.readCorner4(i,s)&255,n-=2,r+=2,c=!0;else{do n<i&&r>=0&&!this.readMappingMatrix.get(r,n)&&(e[t++]=this.readUtah(n,r,i,s)&255),n-=2,r+=2;while(n>=0&&r<s);n+=1,r+=3;do n>=0&&r<s&&!this.readMappingMatrix.get(r,n)&&(e[t++]=this.readUtah(n,r,i,s)&255),n+=2,r-=2;while(n<i&&r>=0);n+=3,r+=1}while(n<i||r<s);if(t!==this.version.getTotalCodewords())throw new V;return e}readModule(e,t,n,r){return e<0&&(e+=n,t+=4-(n+4&7)),t<0&&(t+=r,e+=4-(r+4&7)),this.readMappingMatrix.set(t,e),this.mappingBitMatrix.get(t,e)}readUtah(e,t,n,r){let i=0;return this.readModule(e-2,t-2,n,r)&&(i|=1),i<<=1,this.readModule(e-2,t-1,n,r)&&(i|=1),i<<=1,this.readModule(e-1,t-2,n,r)&&(i|=1),i<<=1,this.readModule(e-1,t-1,n,r)&&(i|=1),i<<=1,this.readModule(e-1,t,n,r)&&(i|=1),i<<=1,this.readModule(e,t-2,n,r)&&(i|=1),i<<=1,this.readModule(e,t-1,n,r)&&(i|=1),i<<=1,this.readModule(e,t,n,r)&&(i|=1),i}readCorner1(e,t){let n=0;return this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,1,e,t)&&(n|=1),n<<=1,this.readModule(e-1,2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n<<=1,this.readModule(2,t-1,e,t)&&(n|=1),n<<=1,this.readModule(3,t-1,e,t)&&(n|=1),n}readCorner2(e,t){let n=0;return this.readModule(e-3,0,e,t)&&(n|=1),n<<=1,this.readModule(e-2,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(0,t-4,e,t)&&(n|=1),n<<=1,this.readModule(0,t-3,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n}readCorner3(e,t){let n=0;return this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,t-1,e,t)&&(n|=1),n<<=1,this.readModule(0,t-3,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-3,e,t)&&(n|=1),n<<=1,this.readModule(1,t-2,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n}readCorner4(e,t){let n=0;return this.readModule(e-3,0,e,t)&&(n|=1),n<<=1,this.readModule(e-2,0,e,t)&&(n|=1),n<<=1,this.readModule(e-1,0,e,t)&&(n|=1),n<<=1,this.readModule(0,t-2,e,t)&&(n|=1),n<<=1,this.readModule(0,t-1,e,t)&&(n|=1),n<<=1,this.readModule(1,t-1,e,t)&&(n|=1),n<<=1,this.readModule(2,t-1,e,t)&&(n|=1),n<<=1,this.readModule(3,t-1,e,t)&&(n|=1),n}extractDataRegion(e){const t=this.version.getSymbolSizeRows(),n=this.version.getSymbolSizeColumns();if(e.getHeight()!==t)throw new O("Dimension of bitMatrix must match the version size");const r=this.version.getDataRegionSizeRows(),i=this.version.getDataRegionSizeColumns(),s=t/r|0,a=n/i|0,o=s*r,l=a*i,c=new Ue(l,o);for(let f=0;f<s;++f){const d=f*r;for(let C=0;C<a;++C){const p=C*i;for(let b=0;b<r;++b){const y=f*(r+2)+1+b,N=d+b;for(let F=0;F<i;++F){const k=C*(i+2)+1+F;if(e.get(k,y)){const v=p+F;c.set(v,N)}}}}}return c}}
6class jn{constructor(e,t){this.numDataCodewords=e,this.codewords=t}static getDataBlocks(e,t){const n=t.getECBlocks();let r=0;const i=n.getECBlocks();for(let b of i)r+=b.getCount();const s=new Array(r);let a=0;for(let b of i)for(let y=0;y<b.getCount();y++){const N=b.getDataCodewords(),F=n.getECCodewords()+N;s[a++]=new jn(N,new Uint8Array(F))}const l=s[0].codewords.length-n.getECCodewords(),c=l-1;let f=0;for(let b=0;b<c;b++)for(let y=0;y<a;y++)s[y].codewords[b]=e[f++];const d=t.getVersionNumber()===24,C=d?8:a;for(let b=0;b<C;b++)s[b].codewords[l-1]=e[f++];const p=s[0].codewords.length;for(let b=l;b<p;b++)for(let y=0;y<a;y++){const N=d?(y+8)%a:y,F=d&&N>7?b-1:b;s[N].codewords[F]=e[f++]}if(f!==e.length)throw new O;return s}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class Yn{constructor(e){this.bytes=e,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(e){if(e<1||e>32||e>this.available())throw new O(""+e);let t=0,n=this.bitOffset,r=this.byteOffset;const i=this.bytes;if(n>0){const s=8-n,a=e<s?e:s,o=s-a,l=255>>8-a<<o;t=(i[r]&l)>>o,e-=a,n+=a,n===8&&(n=0,r++)}if(e>0){for(;e>=8;)t=t<<8|i[r]&255,r++,e-=8;if(e>0){const s=8-e,a=255>>s<<s;t=t<<e|(i[r]&a)>>s,n+=e}}return this.bitOffset=n,this.byteOffset=r,t}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var Fe;(function(u){u[u.PAD_ENCODE=0]="PAD_ENCODE",u[u.ASCII_ENCODE=1]="ASCII_ENCODE",u[u.C40_ENCODE=2]="C40_ENCODE",u[u.TEXT_ENCODE=3]="TEXT_ENCODE",u[u.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",u[u.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",u[u.BASE256_ENCODE=6]="BASE256_ENCODE"})(Fe||(Fe={}));class Mt{static decode(e){const t=new Yn(e),n=new Ae,r=new Ae,i=new Array;let s=Fe.ASCII_ENCODE;do if(s===Fe.ASCII_ENCODE)s=this.decodeAsciiSegment(t,n,r);else{switch(s){case Fe.C40_ENCODE:this.decodeC40Segment(t,n);break;case Fe.TEXT_ENCODE:this.decodeTextSegment(t,n);break;case Fe.ANSIX12_ENCODE:this.decodeAnsiX12Segment(t,n);break;case Fe.EDIFACT_ENCODE:this.decodeEdifactSegment(t,n);break;case Fe.BASE256_ENCODE:this.decodeBase256Segment(t,n,i);break;default:throw new V}s=Fe.ASCII_ENCODE}while(s!==Fe.PAD_ENCODE&&t.available()>0);return r.length()>0&&n.append(r.toString()),new sn(e,n.toString(),i.length===0?null:i,null)}static decodeAsciiSegment(e,t,n){let r=!1;do{let i=e.readBits(8);if(i===0)throw new V;if(i<=128)return r&&(i+=128),t.append(String.fromCharCode(i-1)),Fe.ASCII_ENCODE;if(i===129)return Fe.PAD_ENCODE;if(i<=229){const s=i-130;s<10&&t.append("0"),t.append(""+s)}else switch(i){case 230:return Fe.C40_ENCODE;case 231:return Fe.BASE256_ENCODE;case 232:t.append("�");break;case 233:case 234:break;case 235:r=!0;break;case 236:t.append("[)>�05�"),n.insert(0,"��");break;case 237:t.append("[)>�06�"),n.insert(0,"��");break;case 238:return Fe.ANSIX12_ENCODE;case 239:return Fe.TEXT_ENCODE;case 240:return Fe.EDIFACT_ENCODE;case 241:break;default:if(i!==254||e.available()!==0)throw new V;break}}while(e.available()>0);return Fe.ASCII_ENCODE}static decodeC40Segment(e,t){let n=!1;const r=[];let i=0;do{if(e.available()===8)return;const s=e.readBits(8);if(s===254)return;this.parseTwoBytes(s,e.readBits(8),r);for(let a=0;a<3;a++){const o=r[a];switch(i){case 0:if(o<3)i=o+1;else if(o<this.C40_BASIC_SET_CHARS.length){const l=this.C40_BASIC_SET_CHARS[o];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else throw new V;break;case 1:n?(t.append(String.fromCharCode(o+128)),n=!1):t.append(String.fromCharCode(o)),i=0;break;case 2:if(o<this.C40_SHIFT2_SET_CHARS.length){const l=this.C40_SHIFT2_SET_CHARS[o];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else switch(o){case 27:t.append("�");break;case 30:n=!0;break;default:throw new V}i=0;break;case 3:n?(t.append(String.fromCharCode(o+224)),n=!1):t.append(String.fromCharCode(o+96)),i=0;break;default:throw new V}}}while(e.available()>0)}static decodeTextSegment(e,t){let n=!1,r=[],i=0;do{if(e.available()===8)return;const s=e.readBits(8);if(s===254)return;this.parseTwoBytes(s,e.readBits(8),r);for(let a=0;a<3;a++){const o=r[a];switch(i){case 0:if(o<3)i=o+1;else if(o<this.TEXT_BASIC_SET_CHARS.length){const l=this.TEXT_BASIC_SET_CHARS[o];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}else throw new V;break;case 1:n?(t.append(String.fromCharCode(o+128)),n=!1):t.append(String.fromCharCode(o)),i=0;break;case 2:if(o<this.TEXT_SHIFT2_SET_CHARS.length){const l=this.TEXT_SHIFT2_SET_CHARS[o];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l)}
6else switch(o){case 27:t.append("�");break;case 30:n=!0;break;default:throw new V}i=0;break;case 3:if(o<this.TEXT_SHIFT3_SET_CHARS.length){const l=this.TEXT_SHIFT3_SET_CHARS[o];n?(t.append(String.fromCharCode(l.charCodeAt(0)+128)),n=!1):t.append(l),i=0}else throw new V;break;default:throw new V}}}while(e.available()>0)}static decodeAnsiX12Segment(e,t){const n=[];do{if(e.available()===8)return;const r=e.readBits(8);if(r===254)return;this.parseTwoBytes(r,e.readBits(8),n);for(let i=0;i<3;i++){const s=n[i];switch(s){case 0:t.append("\r");break;case 1:t.append("*");break;case 2:t.append(">");break;case 3:t.append(" ");break;default:if(s<14)t.append(String.fromCharCode(s+44));else if(s<40)t.append(String.fromCharCode(s+51));else throw new V;break}}}while(e.available()>0)}static parseTwoBytes(e,t,n){let r=(e<<8)+t-1,i=Math.floor(r/1600);n[0]=i,r-=i*1600,i=Math.floor(r/40),n[1]=i,n[2]=r-i*40}static decodeEdifactSegment(e,t){do{if(e.available()<=16)return;for(let n=0;n<4;n++){let r=e.readBits(6);if(r===31){const i=8-e.getBitOffset();i!==8&&e.readBits(i);return}(r&32)===0&&(r|=64),t.append(String.fromCharCode(r))}}while(e.available()>0)}static decodeBase256Segment(e,t,n){let r=1+e.getByteOffset();const i=this.unrandomize255State(e.readBits(8),r++);let s;if(i===0?s=e.available()/8|0:i<250?s=i:s=250*(i-249)+this.unrandomize255State(e.readBits(8),r++),s<0)throw new V;const a=new Uint8Array(s);for(let o=0;o<s;o++){if(e.available()<8)throw new V;a[o]=this.unrandomize255State(e.readBits(8),r++)}n.push(a);try{t.append(et.decode(a,$.ISO88591))}catch(o){throw new Ct("Platform does not support required encoding: "+o.message)}}static unrandomize255State(e,t){const n=149*t%255+1,r=e-n;return r>=0?r:r+256}}Mt.C40_BASIC_SET_CHARS=["*","*","*"," ","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"],Mt.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Mt.TEXT_BASIC_SET_CHARS=["*","*","*"," ","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"],Mt.TEXT_SHIFT2_SET_CHARS=Mt.C40_SHIFT2_SET_CHARS,Mt.TEXT_SHIFT3_SET_CHARS=["`","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","{","|","}","~","�"];class ri{constructor(){this.rsDecoder=new on(he.DATA_MATRIX_FIELD_256)}decode(e){const t=new Xn(e),n=t.getVersion(),r=t.readCodewords(),i=jn.getDataBlocks(r,n);let s=0;for(let l of i)s+=l.getNumDataCodewords();const a=new Uint8Array(s),o=i.length;for(let l=0;l<o;l++){const c=i[l],f=c.getCodewords(),d=c.getNumDataCodewords();this.correctErrors(f,d);for(let C=0;C<d;C++)a[C*o+l]=f[C]}return Mt.decode(a)}correctErrors(e,t){const n=new Int32Array(e);try{this.rsDecoder.decode(n,e.length-t)}catch{throw new j}for(let r=0;r<t;r++)e[r]=n[r]}}class Be{constructor(e){this.image=e,this.rectangleDetector=new Tt(this.image)}detect(){const e=this.rectangleDetector.detect();let t=this.detectSolid1(e);if(t=this.detectSolid2(t),t[3]=this.correctTopRight(t),!t[3])throw new R;t=this.shiftToModuleCenter(t);const n=t[0],r=t[1],i=t[2],s=t[3];let a=this.transitionsBetween(n,s)+1,o=this.transitionsBetween(i,s)+1;(a&1)===1&&(a+=1),(o&1)===1&&(o+=1),4*a<7*o&&4*o<7*a&&(a=o=Math.max(a,o));let l=Be.sampleGrid(this.image,n,r,i,s,a,o);return new mn(l,[n,r,i,s])}static shiftPoint(e,t,n){let r=(t.getX()-e.getX())/(n+1),i=(t.getY()-e.getY())/(n+1);return new X(e.getX()+r,e.getY()+i)}static moveAway(e,t,n){let r=e.getX(),i=e.getY();return r<t?r-=1:r+=1,i<n?i-=1:i+=1,new X(r,i)}detectSolid1(e){let t=e[0],n=e[1],r=e[3],i=e[2],s=this.transitionsBetween(t,n),a=this.transitionsBetween(n,r),o=this.transitionsBetween(r,i),l=this.transitionsBetween(i,t),c=s,f=[i,t,n,r];return c>a&&(c=a,f[0]=t,f[1]=n,f[2]=r,f[3]=i),c>o&&(c=o,f[0]=n,f[1]=r,f[2]=i,f[3]=t),c>l&&(f[0]=r,f[1]=i,f[2]=t,f[3]=n),f}detectSolid2(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i),a=Be.shiftPoint(n,r,(s+1)*4),o=Be.shiftPoint(r,n,(s+1)*4),l=this.transitionsBetween(a,t),c=this.transitionsBetween(o,i);return l<c?(e[0]=t,e[1]=n,e[2]=r,e[3]=i):(e[0]=n,e[1]=r,e[2]=i,e[3]=t),e}correctTopRight(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i),a=this.transitionsBetween(n,i),o=Be.shiftPoint(t,n,(a+1)*4),l=
6Be.shiftPoint(r,n,(s+1)*4);s=this.transitionsBetween(o,i),a=this.transitionsBetween(l,i);let c=new X(i.getX()+(r.getX()-n.getX())/(s+1),i.getY()+(r.getY()-n.getY())/(s+1)),f=new X(i.getX()+(t.getX()-n.getX())/(a+1),i.getY()+(t.getY()-n.getY())/(a+1));if(!this.isValid(c))return this.isValid(f)?f:null;if(!this.isValid(f))return c;let d=this.transitionsBetween(o,c)+this.transitionsBetween(l,c),C=this.transitionsBetween(o,f)+this.transitionsBetween(l,f);return d>C?c:f}shiftToModuleCenter(e){let t=e[0],n=e[1],r=e[2],i=e[3],s=this.transitionsBetween(t,i)+1,a=this.transitionsBetween(r,i)+1,o=Be.shiftPoint(t,n,a*4),l=Be.shiftPoint(r,n,s*4);s=this.transitionsBetween(o,i)+1,a=this.transitionsBetween(l,i)+1,(s&1)===1&&(s+=1),(a&1)===1&&(a+=1);let c=(t.getX()+n.getX()+r.getX()+i.getX())/4,f=(t.getY()+n.getY()+r.getY()+i.getY())/4;t=Be.moveAway(t,c,f),n=Be.moveAway(n,c,f),r=Be.moveAway(r,c,f),i=Be.moveAway(i,c,f);let d,C;return o=Be.shiftPoint(t,n,a*4),o=Be.shiftPoint(o,i,s*4),d=Be.shiftPoint(n,t,a*4),d=Be.shiftPoint(d,r,s*4),l=Be.shiftPoint(r,i,a*4),l=Be.shiftPoint(l,n,s*4),C=Be.shiftPoint(i,r,a*4),C=Be.shiftPoint(C,t,s*4),[o,d,l,C]}isValid(e){return e.getX()>=0&&e.getX()<this.image.getWidth()&&e.getY()>0&&e.getY()<this.image.getHeight()}static sampleGrid(e,t,n,r,i,s,a){return Ot.getInstance().sampleGrid(e,s,a,.5,.5,s-.5,.5,s-.5,a-.5,.5,a-.5,t.getX(),t.getY(),i.getX(),i.getY(),r.getX(),r.getY(),n.getX(),n.getY())}transitionsBetween(e,t){let n=Math.trunc(e.getX()),r=Math.trunc(e.getY()),i=Math.trunc(t.getX()),s=Math.trunc(t.getY()),a=Math.abs(s-r)>Math.abs(i-n);if(a){let b=n;n=r,r=b,b=i,i=s,s=b}let o=Math.abs(i-n),l=Math.abs(s-r),c=-o/2,f=r<s?1:-1,d=n<i?1:-1,C=0,p=this.image.get(a?r:n,a?n:r);for(let b=n,y=r;b!==i;b+=d){let N=this.image.get(a?y:b,a?b:y);if(N!==p&&(C++,p=N),c+=l,c>0){if(y===s)break;y+=f,c-=o}}return C}}class Bt{constructor(){this.decoder=new ri}decode(e,t=null){let n,r;if(t!=null&&t.has(we.PURE_BARCODE)){const l=Bt.extractPureBits(e.getBlackMatrix());n=this.decoder.decode(l),r=Bt.NO_POINTS}else{const l=new Be(e.getBlackMatrix()).detect();n=this.decoder.decode(l.getBits()),r=l.getPoints()}const i=n.getRawBytes(),s=new Qe(n.getText(),i,8*i.length,r,K.DATA_MATRIX,Z.currentTimeMillis()),a=n.getByteSegments();a!=null&&s.putMetadata(Ge.BYTE_SEGMENTS,a);const o=n.getECLevel();return o!=null&&s.putMetadata(Ge.ERROR_CORRECTION_LEVEL,o),s}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),n=e.getBottomRightOnBit();if(t==null||n==null)throw new R;const r=this.moduleSize(t,e);let i=t[1];const s=n[1];let a=t[0];const l=(n[0]-a+1)/r,c=(s-i+1)/r;if(l<=0||c<=0)throw new R;const f=r/2;i+=f,a+=f;const d=new Ue(l,c);for(let C=0;C<c;C++){const p=i+C*r;for(let b=0;b<l;b++)e.get(a+b*r,p)&&d.set(b,C)}return d}static moduleSize(e,t){const n=t.getWidth();let r=e[0];const i=e[1];for(;r<n&&t.get(r,i);)r++;if(r===n)throw new R;const s=r-e[0];if(s===0)throw new R;return s}}Bt.NO_POINTS=[];class ii extends Ft{constructor(e=500){super(new Bt,e)}}var qt;(function(u){u[u.L=0]="L",u[u.M=1]="M",u[u.Q=2]="Q",u[u.H=3]="H"})(qt||(qt={}));class ye{constructor(e,t,n){this.value=e,this.stringValue=t,this.bits=n,ye.FOR_BITS.set(n,this),ye.FOR_VALUE.set(e,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(e){switch(e){case"L":return ye.L;case"M":return ye.M;case"Q":return ye.Q;case"H":return ye.H;default:throw new P(e+"not available")}}toString(){return this.stringValue}equals(e){if(!(e instanceof ye))return!1;const t=e;return this.value===t.value}static forBits(e){if(e<0||e>=ye.FOR_BITS.size)throw new O;return ye.FOR_BITS.get(e)}}ye.FOR_BITS=new Map,ye.FOR_VALUE=new Map,ye.L=new ye(qt.L,"L",1),ye.M=new ye(qt.M,"M",0),ye.Q=new ye(qt.Q,"Q",3),ye.H=new ye(qt.H,"H",2);class Ke{constructor(e){this.errorCorrectionLevel=ye.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,t){return J.bitCount(e^t)}static decodeFormatInformation(e,t){const n=Ke.doDecodeFormatInformation(e,t);return n!==null?n:Ke.doDecodeFormatInformation(e^Ke.FORMAT_INFO_MASK_QR,t^Ke.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,t){let n=Number.MAX_SAFE_INTEGER,r=0;for(const i of Ke.FORMAT_INFO_DECODE_LOOKUP){const s=i[0];if(s===e||s===t)return new Ke(i[1]);let a=Ke.numBitsDiffering(e,s);a<n&&(r=i[1],n=a),e!==t&&(a=Ke.numBitsDiffering(t,s),a<n&&(r=i[1],n=a))}return n<=3?new Ke(r):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(e){if(!(e instanceof Ke))return!1;const t=e;return this.errorCorrectionLevel===t.errorCorrectionLevel&&this.dataMask===t.dataMask}}Ke.FORMAT_INFO_MASK_QR=21522,Ke.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 T{constructor(e,...t){this.ecCodewordsPerBlock=e,this.ecBlocks=t}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let e=0;const t=this.ecBlocks;for(const n of t)e+=n.getCount();return e}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class A{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class Y{constructor(e,t,...n){this.versionNumber=e,this.alignmentPatternCenters=t,this.ecBlocks=n;let r=0;const i=n[0].getECCodewordsPerBlock(),s=n[0].getECBlocks();for(const a of s)r+=a.getCount()*(a.getDataCodewords()+i);this.totalCodewords=r}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(e){return this.ecBlocks[e.getValue()]}static getProvisionalVersionForDimension(e){if(e%4!==1)throw new V;try{return this.getVersionForNumber((e-17)/4)}catch{throw new V}}static getVersionForNumber(e){if(e<1||e>40)throw new O;return Y.VERSIONS[e-1]}static decodeVersionInformation(e){let t=Number.MAX_SAFE_INTEGER,n=0;for(let r=0;r<Y.VERSION_DECODE_INFO.length;r++){const i=Y.VERSION_DECODE_INFO[r];if(i===e)return Y.getVersionForNumber(r+7);const s=Ke.numBitsDiffering(e,i);s<t&&(n=r+7,t=s)}return t<=3?Y.getVersionForNumber(n):null}buildFunctionPattern(){const e=this.getDimensionForVersion(),t=new Ue(e);t.setRegion(0,0,9,9),t.setRegion(e-8,0,8,9),t.setRegion(0,e-8,9,8);const n=this.alignmentPatternCenters.length;for(let r=0;r<n;r++){const i=this.alignmentPatternCenters[r]-2;for(let s=0;s<n;s++)r===0&&(s===0||s===n-1)||r===n-1&&s===0||t.setRegion(this.alignmentPatternCenters[s]-2,i,5,5)}return t.setRegion(6,9,1,e-17),t.setRegion(9,6,e-17,1),this.versionNumber>6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t}toString(){return""+this.versionNumber}}Y.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]),Y.VERSIONS=[new Y(1,new Int32Array(0),new T(7,new A(1,19)),new T(10,new A(1,16)),new T(13,new A(1,13)),new T(17,new A(1,9))),new Y(2,Int32Array.from([6,18]),new T(10,new A(1,34)),new T(16,new A(1,28)),new T(22,new A(1,22)),new T(28,new A(1,16))),new Y(3,Int32Array.from([6,22]),new T(15,new A(1,55)),new T(26,new A(1,44)),new T(18,new A(2,17)),new T(22,new A(2,13))),new Y(4,Int32Array.from([6,26]),new T(20,new A(1,80)),new T(18,new A(2,32)),new T(26,new A(2,24)),new T(16,new A(4,9))),new Y(5,Int32Array.from([6,30]),new T(26,new A(1,108)),new T(24,new A(2,43)),new T(18,new A(2,15),new A(2,16)),new T(22,new A(2,11),new A(2,12))),new Y(6,Int32Array.from([6,34]),new T(18,new A(2,68)),new T(16,new A(4,27)),new T(24,new A(4,19)),new T(28,new A(4,15))),new Y(7,Int32Array.from([6,22,38]),new T(20,new A(2,78)),new T(18,new A(4,31)),new T(18,new A(2,14),new A(4,15)),new T(26,new A(4,13),new A(1,14))),new Y(8,Int32Array.from([6,24,42]),new T(24,new A(2,97)),new T(22,new A(2,38),new A(2,39)),new T(22,new A(4,18),new A(2,19)),new T(26,new A(4,14),new A(2,15))),new Y(9,Int32Array.from([6,26,46]),new T(30,new A(2,116)),new T(22,new A(3,36),new A(2,37)),new T(20,new A(4,16),new A(4,17)),new T(24,new A(4,12),new A(4,13))),new Y(10,Int32Array.from([6,28,50]),new T(18,new A(2,68),new A(2,69)),new T(26,new A(4,43),new A(1,44)),new T(24,new A(6,19),new A(2,20)),new T(28,new A(6,15),new A(2,16))
6),new Y(11,Int32Array.from([6,30,54]),new T(20,new A(4,81)),new T(30,new A(1,50),new A(4,51)),new T(28,new A(4,22),new A(4,23)),new T(24,new A(3,12),new A(8,13))),new Y(12,Int32Array.from([6,32,58]),new T(24,new A(2,92),new A(2,93)),new T(22,new A(6,36),new A(2,37)),new T(26,new A(4,20),new A(6,21)),new T(28,new A(7,14),new A(4,15))),new Y(13,Int32Array.from([6,34,62]),new T(26,new A(4,107)),new T(22,new A(8,37),new A(1,38)),new T(24,new A(8,20),new A(4,21)),new T(22,new A(12,11),new A(4,12))),new Y(14,Int32Array.from([6,26,46,66]),new T(30,new A(3,115),new A(1,116)),new T(24,new A(4,40),new A(5,41)),new T(20,new A(11,16),new A(5,17)),new T(24,new A(11,12),new A(5,13))),new Y(15,Int32Array.from([6,26,48,70]),new T(22,new A(5,87),new A(1,88)),new T(24,new A(5,41),new A(5,42)),new T(30,new A(5,24),new A(7,25)),new T(24,new A(11,12),new A(7,13))),new Y(16,Int32Array.from([6,26,50,74]),new T(24,new A(5,98),new A(1,99)),new T(28,new A(7,45),new A(3,46)),new T(24,new A(15,19),new A(2,20)),new T(30,new A(3,15),new A(13,16))),new Y(17,Int32Array.from([6,30,54,78]),new T(28,new A(1,107),new A(5,108)),new T(28,new A(10,46),new A(1,47)),new T(28,new A(1,22),new A(15,23)),new T(28,new A(2,14),new A(17,15))),new Y(18,Int32Array.from([6,30,56,82]),new T(30,new A(5,120),new A(1,121)),new T(26,new A(9,43),new A(4,44)),new T(28,new A(17,22),new A(1,23)),new T(28,new A(2,14),new A(19,15))),new Y(19,Int32Array.from([6,30,58,86]),new T(28,new A(3,113),new A(4,114)),new T(26,new A(3,44),new A(11,45)),new T(26,new A(17,21),new A(4,22)),new T(26,new A(9,13),new A(16,14))),new Y(20,Int32Array.from([6,34,62,90]),new T(28,new A(3,107),new A(5,108)),new T(26,new A(3,41),new A(13,42)),new T(30,new A(15,24),new A(5,25)),new T(28,new A(15,15),new A(10,16))),new Y(21,Int32Array.from([6,28,50,72,94]),new T(28,new A(4,116),new A(4,117)),new T(26,new A(17,42)),new T(28,new A(17,22),new A(6,23)),new T(30,new A(19,16),new A(6,17))),new Y(22,Int32Array.from([6,26,50,74,98]),new T(28,new A(2,111),new A(7,112)),new T(28,new A(17,46)),new T(30,new A(7,24),new A(16,25)),new T(24,new A(34,13))),new Y(23,Int32Array.from([6,30,54,78,102]),new T(30,new A(4,121),new A(5,122)),new T(28,new A(4,47),new A(14,48)),new T(30,new A(11,24),new A(14,25)),new T(30,new A(16,15),new A(14,16))),new Y(24,Int32Array.from([6,28,54,80,106]),new T(30,new A(6,117),new A(4,118)),new T(28,new A(6,45),new A(14,46)),new T(30,new A(11,24),new A(16,25)),new T(30,new A(30,16),new A(2,17))),new Y(25,Int32Array.from([6,32,58,84,110]),new T(26,new A(8,106),new A(4,107)),new T(28,new A(8,47),new A(13,48)),new T(30,new A(7,24),new A(22,25)),new T(30,new A(22,15),new A(13,16))),new Y(26,Int32Array.from([6,30,58,86,114]),new T(28,new A(10,114),new A(2,115)),new T(28,new A(19,46),new A(4,47)),new T(28,new A(28,22),new A(6,23)),new T(30,new A(33,16),new A(4,17))),new Y(27,Int32Array.from([6,34,62,90,118]),new T(30,new A(8,122),new A(4,123)),new T(28,new A(22,45),new A(3,46)),new T(30,new A(8,23),new A(26,24)),new T(30,new A(12,15),new A(28,16))),new Y(28,Int32Array.from([6,26,50,74,98,122]),new T(30,new A(3,117),new A(10,118)),new T(28,new A(3,45),new A(23,46)),new T(30,new A(4,24),new A(31,25)),new T(30,new A(11,15),new A(31,16))),new Y(29,Int32Array.from([6,30,54,78,102,126]),new T(30,new A(7,116),new A(7,117)),new T(28,new A(21,45),new A(7,46)),new T(30,new A(1,23),new A(37,24)),new T(30,new A(19,15),new A(26,16))),new Y(30,Int32Array.from([6,26,52,78,104,130]),new T(30,new A(5,115),new A(10,116)),new T(28,new A(19,47),new A(10,48)),new T(30,new A(15,24),new A(25,25)),new T(30,new A(23,15),new A(25,16))),new Y(31,Int32Array.from([6,30,56,82,108,134]),new T(30,new A(13,115),new A(3,116)),new T(28,new A(2,46),new A(29,47)),new T(30,new A(42,24),new A(1,25)),new T(30,new A(23,15),new A(28,16))),new Y(32,Int32Array.from([6,34,60,86,112,138]),new T(30,new A(17,115)),new T(28,new A(10,46),new A(23,47)),new T(30,new A(10,24),new A(35,25)),new T(30,new A(19,15),new A(35,16))),new Y(33,Int32Array.from([6,30,58,86,114,142]),new T(30,new A(17,115),new A(1,116)),new T(28,new A(14,46),new A(21,47)),new T(30,new A(29,24),new A(19,25)),new T(30,new A(11,15),new A(46,16))),new Y(34,Int32Array.from([6,34,62,90,118,146]),new T(30,new A(13,115),new A(6,116)),new T(28,new A(14,46),new A(23,47)),new T(30,new A(44,24),new A(7,25)),new T(30,new A(59,16),new A(1,17))),new Y(35,Int32Array.from([6,30,54,78,102,126,150]),new T(30,new A(12,121),new A(7,122)),new T(28,new A(12,47),new A(26,48)),new T(30,new A(39,24),new A(14,25)),new T(30,new A(22,15),new A(41,16))),new Y(36,Int32Array.from([6,24,50,76,102,128,154]),new T(30,new A(6,121),new A(14,122)),new T(28,new A(6,47),new A(34,48)),new T(30,new A(46,24),new A(10,25)),new T(30,new A(2,15),new A(64,16))
6),new Y(37,Int32Array.from([6,28,54,80,106,132,158]),new T(30,new A(17,122),new A(4,123)),new T(28,new A(29,46),new A(14,47)),new T(30,new A(49,24),new A(10,25)),new T(30,new A(24,15),new A(46,16))),new Y(38,Int32Array.from([6,32,58,84,110,136,162]),new T(30,new A(4,122),new A(18,123)),new T(28,new A(13,46),new A(32,47)),new T(30,new A(48,24),new A(14,25)),new T(30,new A(42,15),new A(32,16))),new Y(39,Int32Array.from([6,26,54,82,110,138,166]),new T(30,new A(20,117),new A(4,118)),new T(28,new A(40,47),new A(7,48)),new T(30,new A(43,24),new A(22,25)),new T(30,new A(10,15),new A(67,16))),new Y(40,Int32Array.from([6,30,58,86,114,142,170]),new T(30,new A(19,118),new A(6,119)),new T(28,new A(18,47),new A(31,48)),new T(30,new A(34,24),new A(34,25)),new T(30,new A(20,15),new A(61,16)))];var He;(function(u){u[u.DATA_MASK_000=0]="DATA_MASK_000",u[u.DATA_MASK_001=1]="DATA_MASK_001",u[u.DATA_MASK_010=2]="DATA_MASK_010",u[u.DATA_MASK_011=3]="DATA_MASK_011",u[u.DATA_MASK_100=4]="DATA_MASK_100",u[u.DATA_MASK_101=5]="DATA_MASK_101",u[u.DATA_MASK_110=6]="DATA_MASK_110",u[u.DATA_MASK_111=7]="DATA_MASK_111"})(He||(He={}));class ut{constructor(e,t){this.value=e,this.isMasked=t}unmaskBitMatrix(e,t){for(let n=0;n<t;n++)for(let r=0;r<t;r++)this.isMasked(n,r)&&e.flip(r,n)}}ut.values=new Map([[He.DATA_MASK_000,new ut(He.DATA_MASK_000,(u,e)=>(u+e&1)===0)],[He.DATA_MASK_001,new ut(He.DATA_MASK_001,(u,e)=>(u&1)===0)],[He.DATA_MASK_010,new ut(He.DATA_MASK_010,(u,e)=>e%3===0)],[He.DATA_MASK_011,new ut(He.DATA_MASK_011,(u,e)=>(u+e)%3===0)],[He.DATA_MASK_100,new ut(He.DATA_MASK_100,(u,e)=>(Math.floor(u/2)+Math.floor(e/3)&1)===0)],[He.DATA_MASK_101,new ut(He.DATA_MASK_101,(u,e)=>u*e%6===0)],[He.DATA_MASK_110,new ut(He.DATA_MASK_110,(u,e)=>u*e%6<3)],[He.DATA_MASK_111,new ut(He.DATA_MASK_111,(u,e)=>(u+e+u*e%3&1)===0)]]);class si{constructor(e){const t=e.getHeight();if(t<21||(t&3)!==1)throw new V;this.bitMatrix=e}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let e=0;for(let i=0;i<6;i++)e=this.copyBit(i,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let i=5;i>=0;i--)e=this.copyBit(8,i,e);const t=this.bitMatrix.getHeight();let n=0;const r=t-7;for(let i=t-1;i>=r;i--)n=this.copyBit(8,i,n);for(let i=t-8;i<t;i++)n=this.copyBit(i,8,n);if(this.parsedFormatInfo=Ke.decodeFormatInformation(e,n),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new V}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const e=this.bitMatrix.getHeight(),t=Math.floor((e-17)/4);if(t<=6)return Y.getVersionForNumber(t);let n=0;const r=e-11;for(let s=5;s>=0;s--)for(let a=e-9;a>=r;a--)n=this.copyBit(a,s,n);let i=Y.decodeVersionInformation(n);if(i!==null&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;n=0;for(let s=5;s>=0;s--)for(let a=e-9;a>=r;a--)n=this.copyBit(s,a,n);if(i=Y.decodeVersionInformation(n),i!==null&&i.getDimensionForVersion()===e)return this.parsedVersion=i,i;throw new V}copyBit(e,t,n){return(this.isMirror?this.bitMatrix.get(t,e):this.bitMatrix.get(e,t))?n<<1|1:n<<1}readCodewords(){const e=this.readFormatInformation(),t=this.readVersion(),n=ut.values.get(e.getDataMask()),r=this.bitMatrix.getHeight();n.unmaskBitMatrix(this.bitMatrix,r);const i=t.buildFunctionPattern();let s=!0;const a=new Uint8Array(t.getTotalCodewords());let o=0,l=0,c=0;for(let f=r-1;f>0;f-=2){f===6&&f--;for(let d=0;d<r;d++){const C=s?r-1-d:d;for(let p=0;p<2;p++)i.get(f-p,C)||(c++,l<<=1,this.bitMatrix.get(f-p,C)&&(l|=1),c===8&&(a[o++]=l,c=0,l=0))}s=!s}if(o!==t.getTotalCodewords())throw new V;return a}remask(){if(this.parsedFormatInfo===null)return;const e=ut.values[this.parsedFormatInfo.getDataMask()],t=this.bitMatrix.getHeight();e.unmaskBitMatrix(this.bitMatrix,t)}setMirror(e){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=e}mirror(){const e=this.bitMatrix;for(let t=0,n=e.getWidth();t<n;t++)for(let r=t+1,i=e.getHeight();r<i;r++)e.get(t,r)!==e.get(r,t)&&(e.flip(r,t),e.flip(t,r))}}
6class zn{constructor(e,t){this.numDataCodewords=e,this.codewords=t}static getDataBlocks(e,t,n){if(e.length!==t.getTotalCodewords())throw new O;const r=t.getECBlocksForLevel(n);let i=0;const s=r.getECBlocks();for(const p of s)i+=p.getCount();const a=new Array(i);let o=0;for(const p of s)for(let b=0;b<p.getCount();b++){const y=p.getDataCodewords(),N=r.getECCodewordsPerBlock()+y;a[o++]=new zn(y,new Uint8Array(N))}const l=a[0].codewords.length;let c=a.length-1;for(;c>=0&&a[c].codewords.length!==l;)c--;c++;const f=l-r.getECCodewordsPerBlock();let d=0;for(let p=0;p<f;p++)for(let b=0;b<o;b++)a[b].codewords[p]=e[d++];for(let p=c;p<o;p++)a[p].codewords[f]=e[d++];const C=a[0].codewords.length;for(let p=f;p<C;p++)for(let b=0;b<o;b++){const y=b<c?p:p+1;a[b].codewords[y]=e[d++]}return a}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var ft;(function(u){u[u.TERMINATOR=0]="TERMINATOR",u[u.NUMERIC=1]="NUMERIC",u[u.ALPHANUMERIC=2]="ALPHANUMERIC",u[u.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",u[u.BYTE=4]="BYTE",u[u.ECI=5]="ECI",u[u.KANJI=6]="KANJI",u[u.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",u[u.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",u[u.HANZI=9]="HANZI"})(ft||(ft={}));class z{constructor(e,t,n,r){this.value=e,this.stringValue=t,this.characterCountBitsForVersions=n,this.bits=r,z.FOR_BITS.set(r,this),z.FOR_VALUE.set(e,this)}static forBits(e){const t=z.FOR_BITS.get(e);if(t===void 0)throw new O;return t}getCharacterCountBits(e){const t=e.getVersionNumber();let n;return t<=9?n=0:t<=26?n=1:n=2,this.characterCountBitsForVersions[n]}getValue(){return this.value}getBits(){return this.bits}equals(e){if(!(e instanceof z))return!1;const t=e;return this.value===t.value}toString(){return this.stringValue}}z.FOR_BITS=new Map,z.FOR_VALUE=new Map,z.TERMINATOR=new z(ft.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),z.NUMERIC=new z(ft.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),z.ALPHANUMERIC=new z(ft.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),z.STRUCTURED_APPEND=new z(ft.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),z.BYTE=new z(ft.BYTE,"BYTE",Int32Array.from([8,16,16]),4),z.ECI=new z(ft.ECI,"ECI",Int32Array.from([0,0,0]),7),z.KANJI=new z(ft.KANJI,"KANJI",Int32Array.from([8,10,12]),8),z.FNC1_FIRST_POSITION=new z(ft.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),z.FNC1_SECOND_POSITION=new z(ft.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),z.HANZI=new z(ft.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class _e{static decode(e,t,n,r){const i=new Yn(e);let s=new Ae;const a=new Array;let o=-1,l=-1;try{let c=null,f=!1,d;do{if(i.available()<4)d=z.TERMINATOR;else{const C=i.readBits(4);d=z.forBits(C)}switch(d){case z.TERMINATOR:break;case z.FNC1_FIRST_POSITION:case z.FNC1_SECOND_POSITION:f=!0;break;case z.STRUCTURED_APPEND:if(i.available()<16)throw new V;o=i.readBits(8),l=i.readBits(8);break;case z.ECI:const C=_e.parseECIValue(i);if(c=U.getCharacterSetECIByValue(C),c===null)throw new V;break;case z.HANZI:const p=i.readBits(4),b=i.readBits(d.getCharacterCountBits(t));p===_e.GB2312_SUBSET&&_e.decodeHanziSegment(i,s,b);break;default:const y=i.readBits(d.getCharacterCountBits(t));switch(d){case z.NUMERIC:_e.decodeNumericSegment(i,s,y);break;case z.ALPHANUMERIC:_e.decodeAlphanumericSegment(i,s,y,f);break;case z.BYTE:_e.decodeByteSegment(i,s,y,c,a,r);break;case z.KANJI:_e.decodeKanjiSegment(i,s,y);break;default:throw new V}break}}while(d!==z.TERMINATOR)}catch{throw new V}return new sn(e,s.toString(),a.length===0?null:a,n===null?null:n.toString(),o,l)}static decodeHanziSegment(e,t,n){if(n*13>e.available())throw new V;const r=new Uint8Array(2*n);let i=0;for(;n>0;){const s=e.readBits(13);let a=s/96<<8&4294967295|s%96;a<959?a+=41377:a+=42657,r[i]=a>>8&255,r[i+1]=a&255,i+=2,n--}try{t.append(et.decode(r,$.GB2312))}catch(s){throw new V(s)}}static decodeKanjiSegment(e,t,n){if(n*13>e.available())throw new V;const r=new Uint8Array(2*n);let i=0;for(;n>0;){const s=e.readBits(13);let a=s/192<<8&4294967295|s%192;a<7936?a+=33088:a+=49472,r[i]=a>>8,r[i+1]=a,i+=2,n--}try{t.append(et.decode(r,$.SHIFT_JIS))}catch(s){throw new V(s)}}static decodeByteSegment(e,t,n,r,i,s){if(8*n>e.available())throw new V;const a=new Uint8Array(n);for(let l=0;l<n;l++)a[l]=e.readBits(8);let o;r===null?o=$.guessEncoding(a,s):o=r.getName();try{t.append(et.decode(a,o))}catch(l){throw new V(l)}i.push(a)}static toAlphaNumericChar(e){if(e>=_e.ALPHANUMERIC_CHARS.length)throw new V;return _e.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,t,n,r){const i=t.length();for(;n>1;){if(e.available()<11)throw new V;const s=e.readBits(11);t.append(_e.toAlphaNumericChar(Math.floor(s/45))),t.append(_e.toAlphaNumericChar(s%45)),n-=2}if(n===1){if(e.available()<6)throw new V;t.append(_e.toAlphaNumericChar(e.readBits(6)))}if(r)for(let s=i;s<t.length();s++)t.charAt(s)==="%"&&(s<t.length()-1&&t.charAt(s+1)==="%"?t.deleteCharAt(s+1):t.setCharAt(s,"�"))}static decodeNumericSegment(e,t,n){for(;n>=3;){if(e.available()<10)throw new V;const r=e.readBits(10);if(r>=1e3)throw new V;t.append(_e.toAlphaNumericChar(Math.floor(r/100))),t.append(_e.toAlphaNumericChar(Math.floor(r/10)%10)),t.append(_e.toAlphaNumericChar(r%10)),n-=3}if(n===2){if(e.available()<7)throw new V;const r=e.readBits(7);if(r>=100)throw new V;t.append(_e.toAlphaNumericChar(Math.floor(r/10))),t.append(_e.toAlphaNumericChar(r%10))}else if(n===1){if(e.available()<4)throw new V;const r=e.readBits(4);if(r>=10)throw new V;t.append(_e.toAlphaNumericChar(r))}}static parseECIValue(e){const t=e.readBits(8);if((t&128)===0)return t&127;
6if((t&192)===128){const n=e.readBits(8);return(t&63)<<8&4294967295|n}if((t&224)===192){const n=e.readBits(16);return(t&31)<<16&4294967295|n}throw new V}}_e.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",_e.GB2312_SUBSET=1;class Cr{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||e===null||e.length<3)return;const t=e[0];e[0]=e[2],e[2]=t}}class ai{constructor(){this.rsDecoder=new on(he.QR_CODE_FIELD_256)}decodeBooleanArray(e,t){return this.decodeBitMatrix(Ue.parseFromBooleanArray(e),t)}decodeBitMatrix(e,t){const n=new si(e);let r=null;try{return this.decodeBitMatrixParser(n,t)}catch(i){r=i}try{n.remask(),n.setMirror(!0),n.readVersion(),n.readFormatInformation(),n.mirror();const i=this.decodeBitMatrixParser(n,t);return i.setOther(new Cr(!0)),i}catch(i){throw r!==null?r:i}}decodeBitMatrixParser(e,t){const n=e.readVersion(),r=e.readFormatInformation().getErrorCorrectionLevel(),i=e.readCodewords(),s=zn.getDataBlocks(i,n,r);let a=0;for(const c of s)a+=c.getNumDataCodewords();const o=new Uint8Array(a);let l=0;for(const c of s){const f=c.getCodewords(),d=c.getNumDataCodewords();this.correctErrors(f,d);for(let C=0;C<d;C++)o[l++]=f[C]}return _e.decode(o,n,r,t)}correctErrors(e,t){const n=new Int32Array(e);try{this.rsDecoder.decode(n,e.length-t)}catch{throw new j}for(let r=0;r<t;r++)e[r]=n[r]}}class Zn extends X{constructor(e,t,n){super(e,t),this.estimatedModuleSize=n}aboutEquals(e,t,n){if(Math.abs(t-this.getY())<=e&&Math.abs(n-this.getX())<=e){const r=Math.abs(e-this.estimatedModuleSize);return r<=1||r<=this.estimatedModuleSize}return!1}combineEstimate(e,t,n){const r=(this.getX()+t)/2,i=(this.getY()+e)/2,s=(this.estimatedModuleSize+n)/2;return new Zn(r,i,s)}}class Tn{constructor(e,t,n,r,i,s,a){this.image=e,this.startX=t,this.startY=n,this.width=r,this.height=i,this.moduleSize=s,this.resultPointCallback=a,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const e=this.startX,t=this.height,n=this.width,r=e+n,i=this.startY+t/2,s=new Int32Array(3),a=this.image;for(let o=0;o<t;o++){const l=i+((o&1)===0?Math.floor((o+1)/2):-Math.floor((o+1)/2));s[0]=0,s[1]=0,s[2]=0;let c=e;for(;c<r&&!a.get(c,l);)c++;let f=0;for(;c<r;){if(a.get(c,l))if(f===1)s[1]++;else if(f===2){if(this.foundPatternCross(s)){const d=this.handlePossibleCenter(s,l,c);if(d!==null)return d}s[0]=s[2],s[1]=1,s[2]=0,f=1}else s[++f]++;else f===1&&f++,s[f]++;c++}if(this.foundPatternCross(s)){const d=this.handlePossibleCenter(s,l,r);if(d!==null)return d}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new R}static centerFromEnd(e,t){return t-e[2]-e[1]/2}foundPatternCross(e){const t=this.moduleSize,n=t/2;for(let r=0;r<3;r++)if(Math.abs(t-e[r])>=n)return!1;return!0}crossCheckVertical(e,t,n,r){const i=this.image,s=i.getHeight(),a=this.crossCheckStateCount;a[0]=0,a[1]=0,a[2]=0;let o=e;for(;o>=0&&i.get(t,o)&&a[1]<=n;)a[1]++,o--;if(o<0||a[1]>n)return NaN;for(;o>=0&&!i.get(t,o)&&a[0]<=n;)a[0]++,o--;if(a[0]>n)return NaN;for(o=e+1;o<s&&i.get(t,o)&&a[1]<=n;)a[1]++,o++;if(o===s||a[1]>n)return NaN;for(;o<s&&!i.get(t,o)&&a[2]<=n;)a[2]++,o++;if(a[2]>n)return NaN;const l=a[0]+a[1]+a[2];return 5*Math.abs(l-r)>=2*r?NaN:this.foundPatternCross(a)?Tn.centerFromEnd(a,o):NaN}handlePossibleCenter(e,t,n){const r=e[0]+e[1]+e[2],i=Tn.centerFromEnd(e,n),s=this.crossCheckVertical(t,i,2*e[1],r);if(!isNaN(s)){const a=(e[0]+e[1]+e[2])/3;for(const l of this.possibleCenters)if(l.aboutEquals(a,s,i))return l.combineEstimate(s,i,a);const o=new Zn(i,s,a);this.possibleCenters.push(o),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(o)}return null}}class Kn extends X{constructor(e,t,n,r){super(e,t),this.estimatedModuleSize=n,this.count=r,r===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,t,n){if(Math.abs(t-this.getY())<=e&&Math.abs(n-this.getX())<=e){const r=Math.abs(e-this.estimatedModuleSize);return r<=1||r<=this.estimatedModuleSize}return!1}combineEstimate(e,t,n){const r=this.count+1,i=(this.count*this.getX()+t)/r,s=(this.count*this.getY()+e)/r,a=(this.count*this.estimatedModuleSize+n)/r;return new Kn(i,s,a,r)}}class oi{constructor(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class We{constructor(e,t){this.image=e,this.resultPointCallback=t,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=t}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(e){const t=e!=null&&e.get(we.TRY_HARDER)!==void 0,n=e!=null&&e.get(we.PURE_BARCODE)!==void 0,r=this.image,i=r.getHeight(),s=r.getW
6idth();let a=Math.floor(3*i/(4*We.MAX_MODULES));(a<We.MIN_SKIP||t)&&(a=We.MIN_SKIP);let o=!1;const l=new Int32Array(5);for(let f=a-1;f<i&&!o;f+=a){l[0]=0,l[1]=0,l[2]=0,l[3]=0,l[4]=0;let d=0;for(let C=0;C<s;C++)if(r.get(C,f))(d&1)===1&&d++,l[d]++;else if((d&1)===0)if(d===4)if(We.foundPatternCross(l)){if(this.handlePossibleCenter(l,f,C,n)===!0)if(a=2,this.hasSkipped===!0)o=this.haveMultiplyConfirmedCenters();else{const b=this.findRowSkip();b>l[2]&&(f+=b-l[2]-a,C=s-1)}else{l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,d=3;continue}d=0,l[0]=0,l[1]=0,l[2]=0,l[3]=0,l[4]=0}else l[0]=l[2],l[1]=l[3],l[2]=l[4],l[3]=1,l[4]=0,d=3;else l[++d]++;else l[d]++;We.foundPatternCross(l)&&this.handlePossibleCenter(l,f,s,n)===!0&&(a=l[0],this.hasSkipped&&(o=this.haveMultiplyConfirmedCenters()))}const c=this.selectBestPatterns();return X.orderBestPatterns(c),new oi(c)}static centerFromEnd(e,t){return t-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let t=0;for(let i=0;i<5;i++){const s=e[i];if(s===0)return!1;t+=s}if(t<7)return!1;const n=t/7,r=n/2;return Math.abs(n-e[0])<r&&Math.abs(n-e[1])<r&&Math.abs(3*n-e[2])<3*r&&Math.abs(n-e[3])<r&&Math.abs(n-e[4])<r}getCrossCheckStateCount(){const e=this.crossCheckStateCount;return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e}crossCheckDiagonal(e,t,n,r){const i=this.getCrossCheckStateCount();let s=0;const a=this.image;for(;e>=s&&t>=s&&a.get(t-s,e-s);)i[2]++,s++;if(e<s||t<s)return!1;for(;e>=s&&t>=s&&!a.get(t-s,e-s)&&i[1]<=n;)i[1]++,s++;if(e<s||t<s||i[1]>n)return!1;for(;e>=s&&t>=s&&a.get(t-s,e-s)&&i[0]<=n;)i[0]++,s++;if(i[0]>n)return!1;const o=a.getHeight(),l=a.getWidth();for(s=1;e+s<o&&t+s<l&&a.get(t+s,e+s);)i[2]++,s++;if(e+s>=o||t+s>=l)return!1;for(;e+s<o&&t+s<l&&!a.get(t+s,e+s)&&i[3]<n;)i[3]++,s++;if(e+s>=o||t+s>=l||i[3]>=n)return!1;for(;e+s<o&&t+s<l&&a.get(t+s,e+s)&&i[4]<n;)i[4]++,s++;if(i[4]>=n)return!1;const c=i[0]+i[1]+i[2]+i[3]+i[4];
vendor: 6,014 bytes, line 6
6return Math.abs(c-r)<2*r&&We.foundPatternCross(i)}crossCheckVertical(e,t,n,r){const i=this.image,s=i.getHeight(),a=this.getCrossCheckStateCount();let o=e;for(;o>=0&&i.get(t,o);)a[2]++,o--;if(o<0)return NaN;for(;o>=0&&!i.get(t,o)&&a[1]<=n;)a[1]++,o--;if(o<0||a[1]>n)return NaN;for(;o>=0&&i.get(t,o)&&a[0]<=n;)a[0]++,o--;if(a[0]>n)return NaN;for(o=e+1;o<s&&i.get(t,o);)a[2]++,o++;if(o===s)return NaN;for(;o<s&&!i.get(t,o)&&a[3]<n;)a[3]++,o++;if(o===s||a[3]>=n)return NaN;for(;o<s&&i.get(t,o)&&a[4]<n;)a[4]++,o++;if(a[4]>=n)return NaN;const l=a[0]+a[1]+a[2]+a[3]+a[4];return 5*Math.abs(l-r)>=2*r?NaN:We.foundPatternCross(a)?We.centerFromEnd(a,o):NaN}crossCheckHorizontal(e,t,n,r){const i=this.image,s=i.getWidth(),a=this.getCrossCheckStateCount();let o=e;for(;o>=0&&i.get(o,t);)a[2]++,o--;if(o<0)return NaN;for(;o>=0&&!i.get(o,t)&&a[1]<=n;)a[1]++,o--;if(o<0||a[1]>n)return NaN;for(;o>=0&&i.get(o,t)&&a[0]<=n;)a[0]++,o--;if(a[0]>n)return NaN;for(o=e+1;o<s&&i.get(o,t);)a[2]++,o++;if(o===s)return NaN;for(;o<s&&!i.get(o,t)&&a[3]<n;)a[3]++,o++;if(o===s||a[3]>=n)return NaN;for(;o<s&&i.get(o,t)&&a[4]<n;)a[4]++,o++;if(a[4]>=n)return NaN;const l=a[0]+a[1]+a[2]+a[3]+a[4];return 5*Math.abs(l-r)>=r?NaN:We.foundPatternCross(a)?We.centerFromEnd(a,o):NaN}handlePossibleCenter(e,t,n,r){const i=e[0]+e[1]+e[2]+e[3]+e[4];let s=We.centerFromEnd(e,n),a=this.crossCheckVertical(t,Math.floor(s),e[2],i);if(!isNaN(a)&&(s=this.crossCheckHorizontal(Math.floor(s),Math.floor(a),e[2],i),!isNaN(s)&&(!r||this.crossCheckDiagonal(Math.floor(a),Math.floor(s),e[2],i)))){const o=i/7;let l=!1;const c=this.possibleCenters;for(let f=0,d=c.length;f<d;f++){const C=c[f];if(C.aboutEquals(o,a,s)){c[f]=C.combineEstimate(a,s,o),l=!0;break}}if(!l){const f=new Kn(s,a,o);c.push(f),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(f)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let t=null;for(const n of this.possibleCenters)if(n.getCount()>=We.CENTER_QUORUM)if(t==null)t=n;else return this.hasSkipped=!0,Math.floor((Math.abs(t.getX()-n.getX())-Math.abs(t.getY()-n.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let e=0,t=0;const n=this.possibleCenters.length;for(const s of this.possibleCenters)s.getCount()>=We.CENTER_QUORUM&&(e++,t+=s.getEstimatedModuleSize());if(e<3)return!1;const r=t/n;let i=0;for(const s of this.possibleCenters)i+=Math.abs(s.getEstimatedModuleSize()-r);return i<=.05*t}selectBestPatterns(){const e=this.possibleCenters.length;if(e<3)throw new R;const t=this.possibleCenters;let n;if(e>3){let r=0,i=0;for(const o of this.possibleCenters){const l=o.getEstimatedModuleSize();r+=l,i+=l*l}n=r/e;let s=Math.sqrt(i/e-n*n);t.sort((o,l)=>{const c=Math.abs(l.getEstimatedModuleSize()-n),f=Math.abs(o.getEstimatedModuleSize()-n);return c<f?-1:c>f?1:0});const a=Math.max(.2*n,s);for(let o=0;o<t.length&&t.length>3;o++){const l=t[o];Math.abs(l.getEstimatedModuleSize()-n)>a&&(t.splice(o,1),o--)}}if(t.length>3){let r=0;for(const i of t)r+=i.getEstimatedModuleSize();n=r/t.length,t.sort((i,s)=>{if(s.getCount()===i.getCount()){const a=Math.abs(s.getEstimatedModuleSize()-n),o=Math.abs(i.getEstimatedModuleSize()-n);return a<o?1:a>o?-1:0}else return s.getCount()-i.getCount()}),t.splice(3)}return[t[0],t[1],t[2]]}}We.CENTER_QUORUM=2,We.MIN_SKIP=3,We.MAX_MODULES=57;class cn{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(we.NEED_RESULT_POINT_CALLBACK);const n=new We(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(n)}processFinderPatternInfo(e){const t=e.getTopLeft(),n=e.getTopRight(),r=e.getBottomLeft(),i=this.calculateModuleSize(t,n,r);if(i<1)throw new R("No pattern found in proccess finder.");const s=cn.computeDimension(t,n,r,i),a=Y.getProvisionalVersionForDimension(s),o=a.getDimensionForVersion()-7;let l=null;if(a.getAlignmentPatternCenters().length>0){const C=n.getX()-t.getX()+r.getX(),p=n.getY()-t.getY()+r.getY(),b=1-3/o,y=Math.floor(t.getX()+b*(C-t.getX())),N=Math.floor(t.getY()+b*(p-t.getY()));for(let F=4;F<=16;F<<=1)try{l=this.findAlignmentInRegion(i,y,N,F);break}catch(k){if(!(k instanceof R))throw k}}const c=cn.createTransform(t,n,r,l,s),f=cn.sampleGrid(this.image,c,s);let d;return l===null?d=[r,t,n]:d=[r,t,n,l],new mn(f,d)}static createTransform(e,t,n,r,i){const s=i-3.5;let a,o,l,c;return r!==null?(a=r.getX(),o=r.getY(),l=s-3,c=l):(a=t.getX()-e.getX()+n.getX(),o=t.getY()-e.getY()+n.getY(),l=s,c=s),xt.quadrilateralToQuadrilateral(3.5,3.5,s,3.5,l,c,3.5,s,e.getX(),e.getY(),t.getX(),t.getY(),a,o,n.getX(),n.getY())}static sampleGrid(e,t,n){return Ot.getInstance().sampleGridWithTransform(e,n,n,t)}static computeDimension(e,t,n,r){const i=oe.round(X.distance(e,t)/r),s=oe.round(X.distance(e,n)/r);let a=Math.floor((i+s)/2)+7;switch(a&3){case 0:a++;break;case 2:a--;break;case 3:throw new R("Dimensions could be not found.")}return a}calculateModuleSize(e,t,n){return(this.calculateModuleSizeOneWay(e,t)+this.calculateModuleSizeOneWay(e,n))/2}calculateModuleSizeOneWay(e,t){const n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY())),r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(n)?r/7:isNaN(r)?n/7:(n+r)/14}sizeOfBlackWhiteBlackRunBothWays(e,t,n,r){let i=this.sizeOfBlackWhiteBlackRun(e,t,n,r),s=1,a=e-(n-e);a<0?(s=e/(e-a),a=0):a>=this.image.getWidth()&&(s=(this.image.getWidth()-1-e)/(a-e),a=this.image.getWidth()-1);let o=Math.floor(t-(r-t)*s);return s=1,o<0?(s=t/(t-o),o=0):o>=this.image.getHeight()&&(s=(this.image.getHeight()-1-t)/(o-t),o=this.image.getHeight()-1),a=Math.floor(e+(a-e)*s),i+=this.sizeOfBlackWhiteBlackRun(e,t,a,o),i-1}sizeOfBlackWhiteBlackRun(e,t,n,r){const i=Math.abs(r-t)>Math.abs(n-e);if(i){let C=e;e=t,t=C,C=n,n=r,r=C}const s=Math.abs(n-e),a=Math.abs(r-t);let o=-s/2;
6const l=e<n?1:-1,c=t<r?1:-1;let f=0;const d=n+l;for(let C=e,p=t;C!==d;C+=l){const b=i?p:C,y=i?C:p;if(f===1===this.image.get(b,y)){if(f===2)return oe.distance(C,p,e,t);f++}if(o+=a,o>0){if(p===r)break;p+=c,o-=s}}return f===2?oe.distance(n+l,r,e,t):NaN}findAlignmentInRegion(e,t,n,r){const i=Math.floor(r*e),s=Math.max(0,t-i),a=Math.min(this.image.getWidth()-1,t+i);if(a-s<e*3)throw new R("Alignment top exceeds estimated module size.");const o=Math.max(0,n-i),l=Math.min(this.image.getHeight()-1,n+i);if(l-o<e*3)throw new R("Alignment bottom exceeds estimated module size.");return new Tn(this.image,s,o,a-s,l-o,e,this.resultPointCallback).find()}}class vt{constructor(){this.decoder=new ai}getDecoder(){return this.decoder}decode(e,t){let n,r;if(t!=null&&t.get(we.PURE_BARCODE)!==void 0){const o=vt.extractPureBits(e.getBlackMatrix());n=this.decoder.decodeBitMatrix(o,t),r=vt.NO_POINTS}else{const o=new cn(e.getBlackMatrix()).detect(t);n=this.decoder.decodeBitMatrix(o.getBits(),t),r=o.getPoints()}n.getOther()instanceof Cr&&n.getOther().applyMirroredCorrection(r);const i=new Qe(n.getText(),n.getRawBytes(),void 0,r,K.QR_CODE,void 0),s=n.getByteSegments();s!==null&&i.putMetadata(Ge.BYTE_SEGMENTS,s);const a=n.getECLevel();return a!==null&&i.putMetadata(Ge.ERROR_CORRECTION_LEVEL,a),n.hasStructuredAppend()&&(i.putMetadata(Ge.STRUCTURED_APPEND_SEQUENCE,n.getStructuredAppendSequenceNumber()),i.putMetadata(Ge.STRUCTURED_APPEND_PARITY,n.getStructuredAppendParity())),i}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),n=e.getBottomRightOnBit();if(t===null||n===null)throw new R;const r=this.moduleSize(t,e);let i=t[1],s=n[1],a=t[0],o=n[0];if(a>=o||i>=s)throw new R;if(s-i!==o-a&&(o=a+(s-i),o>=e.getWidth()))throw new R;const l=Math.round((o-a+1)/r),c=Math.round((s-i+1)/r);if(l<=0||c<=0)throw new R;if(c!==l)throw new R;const f=Math.floor(r/2);i+=f,a+=f;const d=a+Math.floor((l-1)*r)-o;if(d>0){if(d>f)throw new R;a-=d}const C=i+Math.floor((c-1)*r)-s;if(C>0){if(C>f)throw new R;i-=C}const p=new Ue(l,c);for(let b=0;b<c;b++){const y=i+Math.floor(b*r);for(let N=0;N<l;N++)e.get(a+Math.floor(N*r),y)&&p.set(N,b)}return p}static moduleSize(e,t){const n=t.getHeight(),r=t.getWidth();let i=e[0],s=e[1],a=!0,o=0;for(;i<r&&s<n;){if(a!==t.get(i,s)){if(++o===5)break;a=!a}i++,s++}if(i===r||s===n)throw new R;return(i-e[0])/7}}vt.NO_POINTS=new Array;class Q{PDF417Common(){}static getBitCountSum(e){return oe.sum(e)}static toIntArray(e){if(e==null||!e.length)return Q.EMPTY_INT_ARRAY;const t=new Int32Array(e.length);let n=0;for(const r of e)t[n++]=r;return t}static getCodeword(e){const t=Ie.binarySearch(Q.SYMBOL_TABLE,e&262143);return t<0?-1:(Q.CODEWORD_TABLE[t]-1)%Q.NUMBER_OF_CODEWORDS}}Q.NUMBER_OF_CODEWORDS=929,Q.MAX_CODEWORDS_IN_BARCODE=Q.NUMBER_OF_CODEWORDS-1,Q.MIN_ROWS_IN_BARCODE=3,Q.MAX_ROWS_IN_BARCODE=90,Q.MODULES_IN_CODEWORD=17,Q.MODULES_IN_STOP_PATTERN=18,Q.BARS_IN_MODULE=8,Q.EMPTY_INT_ARRAY=new Int32Array([]),Q
vendor: 18,272 bytes, line 6
6.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),
6Q
vendor: 12,860 bytes, line 6
6.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700])
6;class li{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class ne{static detectMultiple(e,t,n){let r=e.getBlackMatrix(),i=ne.detect(n,r);return i.length||(r=r.clone(),r.rotate180(),i=ne.detect(n,r)),new li(r,i)}static detect(e,t){const n=new Array;let r=0,i=0,s=!1;for(;r<t.getHeight();){const a=ne.findVertices(t,r,i);if(a[0]==null&&a[3]==null){if(!s)break;s=!1,i=0;for(const o of n)o[1]!=null&&(r=Math.trunc(Math.max(r,o[1].getY()))),o[3]!=null&&(r=Math.max(r,Math.trunc(o[3].getY())));r+=ne.ROW_STEP;continue}if(s=!0,n.push(a),!e)break;a[2]!=null?(i=Math.trunc(a[2].getX()),r=Math.trunc(a[2].getY())):(i=Math.trunc(a[4].getX()),r=Math.trunc(a[4].getY()))}return n}static findVertices(e,t,n){const r=e.getHeight(),i=e.getWidth(),s=new Array(8);return ne.copyToResult(s,ne.findRowsWithPattern(e,r,i,t,n,ne.START_PATTERN),ne.INDEXES_START_PATTERN),s[4]!=null&&(n=Math.trunc(s[4].getX()),t=Math.trunc(s[4].getY())),ne.copyToResult(s,ne.findRowsWithPattern(e,r,i,t,n,ne.STOP_PATTERN),ne.INDEXES_STOP_PATTERN),s}static copyToResult(e,t,n){for(let r=0;r<n.length;r++)e[n[r]]=t[r]}static findRowsWithPattern(e,t,n,r,i,s){const a=new Array(4);let o=!1;const l=new Int32Array(s.length);for(;r<t;r+=ne.ROW_STEP){let f=ne.findGuardPattern(e,i,r,n,!1,s,l);if(f!=null){for(;r>0;){const d=ne.findGuardPattern(e,i,--r,n,!1,s,l);if(d!=null)f=d;else{r++;break}}a[0]=new X(f[0],r),a[1]=new X(f[1],r),o=!0;break}}let c=r+1;if(o){let f=0,d=Int32Array.from([Math.trunc(a[0].getX()),Math.trunc(a[1].getX())]);for(;c<t;c++){const C=ne.findGuardPattern(e,d[0],c,n,!1,s,l);if(C!=null&&Math.abs(d[0]-C[0])<ne.MAX_PATTERN_DRIFT&&Math.abs(d[1]-C[1])<ne.MAX_PATTERN_DRIFT)d=C,f=0;else{if(f>ne.SKIPPED_ROW_COUNT_MAX)break;f++}}c-=f+1,a[2]=new X(d[0],c),a[3]=new X(d[1],c)}return c-r<ne.BARCODE_MIN_HEIGHT&&Ie.fill(a,null),a}static findGuardPattern(e,t,n,r,i,s,a){Ie.fillWithin(a,0,a.length,0);let o=t,l=0;for(;e.get(o,n)&&o>0&&l++<ne.MAX_PIXEL_DRIFT;)o--;let c=o,f=0,d=s.length;for(let C=i;c<r;c++)if(e.get(c,n)!==C)a[f]++;else{if(f===d-1){if(ne.patternMatchVariance(a,s,ne.MAX_INDIVIDUAL_VARIANCE)<ne.MAX_AVG_VARIANCE)return new Int32Array([o,c]);o+=a[0]+a[1],Z.arraycopy(a,2,a,0,f-1),a[f-1]=0,a[f]=0,f--}else f++;a[f]=1,C=!C}return f===d-1&&ne.patternMatchVariance(a,s,ne.MAX_INDIVIDUAL_VARIANCE)<ne.MAX_AVG_VARIANCE?new Int32Array([o,c-1]):null}static patternMatchVariance(e,t,n){let r=e.length,i=0,s=0;for(let l=0;l<r;l++)i+=e[l],s+=t[l];if(i<s)return 1/0;let a=i/s;n*=a;let o=0;for(let l=0;l<r;l++){let c=e[l],f=t[l]*a,d=c>f?c-f:f-c;if(d>n)return 1/0;o+=d}return o/i}}ne.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),ne.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),ne.MAX_AVG_VARIANCE=.42,ne.MAX_INDIVIDUAL_VARIANCE=.8,ne.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),ne.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),ne.MAX_PIXEL_DRIFT=3,ne.MAX_PATTERN_DRIFT=5,ne.SKIPPED_ROW_COUNT_MAX=25,ne.ROW_STEP=5,ne.BARCODE_MIN_HEIGHT=10;class je{constructor(e,t){if(t.length===0)throw new O;this.field=e;let n=t.length;if(n>1&&t[0]===0){let r=1;for(;r<n&&t[r]===0;)r++;r===n?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(n-r),Z.arraycopy(t,r,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);if(e===1){let r=0;for(let i of this.coefficients)r=this.field.add(r,i);return r}let t=this.coefficients[0],n=this.coefficients.length;for(let r=1;r<n;r++)t=this.field.add(this.field.multiply(e,t),this.coefficients[r]);return t}add(e){if(!this.field.equals(e.field))throw new O("ModulusPolys do not have same ModulusGF field");if(this.isZero())return e;if(e.isZero())return this;let t=this.coefficients,n=e.coefficients;if(t.length>n.length){let s=t;t=n,n=s}let r=new Int32Array(n.length),i=n.length-t.length;Z.arraycopy(n,0,r,0,i);for(let s=i;s<n.length;s++)r[s]=this.field.add(t[s-i],n[s]);return new je(this.field,r)}subtract(e){if(!this.field.equals(e.field))throw new O("ModulusPolys do n
6ot have same ModulusGF field");return e.isZero()?this:this.add(e.negative())}multiply(e){return e instanceof je?this.multiplyOther(e):this.multiplyScalar(e)}multiplyOther(e){if(!this.field.equals(e.field))throw new O("ModulusPolys do not have same ModulusGF field");if(this.isZero()||e.isZero())return new je(this.field,new Int32Array([0]));let t=this.coefficients,n=t.length,r=e.coefficients,i=r.length,s=new Int32Array(n+i-1);for(let a=0;a<n;a++){let o=t[a];for(let l=0;l<i;l++)s[a+l]=this.field.add(s[a+l],this.field.multiply(o,r[l]))}return new je(this.field,s)}negative(){let e=this.coefficients.length,t=new Int32Array(e);for(let n=0;n<e;n++)t[n]=this.field.subtract(0,this.coefficients[n]);return new je(this.field,t)}multiplyScalar(e){if(e===0)return new je(this.field,new Int32Array([0]));if(e===1)return this;let t=this.coefficients.length,n=new Int32Array(t);for(let r=0;r<t;r++)n[r]=this.field.multiply(this.coefficients[r],e);return new je(this.field,n)}multiplyByMonomial(e,t){if(e<0)throw new O;if(t===0)return new je(this.field,new Int32Array([0]));let n=this.coefficients.length,r=new Int32Array(n+e);for(let i=0;i<n;i++)r[i]=this.field.multiply(this.coefficients[i],t);return new je(this.field,r)}toString(){let e=new Ae;for(let t=this.getDegree();t>=0;t--){let n=this.getCoefficient(t);n!==0&&(n<0?(e.append(" - "),n=-n):e.length()>0&&e.append(" + "),(t===0||n!==1)&&e.append(n),t!==0&&(t===1?e.append("x"):(e.append("x^"),e.append(t))))}return e.toString()}}class ci{add(e,t){return(e+t)%this.modulus}subtract(e,t){return(this.modulus+e-t)%this.modulus}exp(e){return this.expTable[e]}log(e){if(e===0)throw new O;return this.logTable[e]}inverse(e){if(e===0)throw new Cn;return this.expTable[this.modulus-this.logTable[e]-1]}multiply(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.modulus-1)]}getSize(){return this.modulus}equals(e){return e===this}}class qn extends ci{constructor(e,t){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let n=1;for(let r=0;r<e;r++)this.expTable[r]=n,n=n*t%e;for(let r=0;r<e-1;r++)this.logTable[this.expTable[r]]=r;this.zero=new je(this,new Int32Array([0])),this.one=new je(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,t){if(e<0)throw new O;if(t===0)return this.zero;let n=new Int32Array(e+1);return n[0]=t,new je(this,n)}}qn.PDF417_GF=new qn(Q.NUMBER_OF_CODEWORDS,3);class Er{constructor(){this.field=qn.PDF417_GF}decode(e,t,n){let r=new je(this.field,e),i=new Int32Array(t),s=!1;for(let p=t;p>0;p--){let b=r.evaluateAt(this.field.exp(p));i[t-p]=b,b!==0&&(s=!0)}if(!s)return 0;let a=this.field.getOne();if(n!=null)for(const p of n){let b=this.field.exp(e.length-1-p),y=new je(this.field,new Int32Array([this.field.subtract(0,b),1]));a=a.multiply(y)}let o=new je(this.field,i),l=this.runEuclideanAlgorithm(this.field.buildMonomial(t,1),o,t),c=l[0],f=l[1],d=this.findErrorLocations(c),C=this.findErrorMagnitudes(f,c,d);for(let p=0;p<d.length;p++){let b=e.length-1-this.field.log(d[p]);if(b<0)throw j.getChecksumInstance();e[b]=this.field.subtract(e[b],C[p])}return d.length}runEuclideanAlgorithm(e,t,n){if(e.getDegree()<t.getDegree()){let d=e;e=t,t=d}let r=e,i=t,s=this.field.getZero(),a=this.field.getOne();for(;i.getDegree()>=Math.round(n/2);){let d=r,C=s;if(r=i,s=a,r.isZero())throw j.getChecksumInstance();i=d;let p=this.field.getZero(),b=r.getCoefficient(r.getDegree()),y=this.field.inverse(b);for(;i.getDegree()>=r.getDegree()&&!i.isZero();){let N=i.getDegree()-r.getDegree(),F=this.field.multiply(i.getCoefficient(i.getDegree()),y);p=p.add(this.field.buildMonomial(N,F)),i=i.subtract(r.multiplyByMonomial(N,F))}a=p.multiply(s).subtract(C).negative()}let o=a.getCoefficient(0);if(o===0)throw j.getChecksumInstance();let l=this.field.inverse(o),c=a.multiply(l),f=i.multiply(l);return[c,f]}findErrorLocations(e){let t=e.getDegree(),n=new Int32Array(t),r=0;for(let i=1;i<this.field.getSize()&&r<t;i++)e.evaluateAt(i)===0&&(n[r]=this.field.inverse(i),r++);if(r!==t)throw j.getChecksumInstance();return n}findErrorMagnitudes(e,t,n){let r=t.getDegree(),i=new Int32Array(r);for(let l=1;l<=r;l++)i[r-l]=this.field.multiply(l,t.getCoefficient(l));let s=new je(this.field,i),a=n.length,o=new Int32Array(a);for(let l=0;l<a;l++){let c=this.field.inverse(n[l]),f=this.field.subtract(0,e.evaluateAt(c)),d=this.field.inverse(s.evaluateAt(c));o[l]=this.field.multiply(f,d)}return o}}class Gt{constructor(e,t,n,r,i){e instanceof Gt?this.constructor_2(e):this.constructor_1(e,t,n,r,i)}constructor_1(e,t,n,r,i){const s=t==null||n==null,a=r==null||i==null;if(s&&a)throw new R;s?(t=new X(0,r.getY()),n=new X(0,i.getY())):a&&(r=new X(e.getWidth()-1,t.getY()),i=new X(e.getWidth()-1,n.getY())),this.image=e,this.topLeft=t,this.bottomLeft=n,this.topRight=r,this.bottomRight=i,this.minX=Math.trunc(Math.min(t.getX(),n.getX())),this.maxX=Math.trunc(Math.max(r.getX(),i.getX())),this.minY=Math.trunc(Math.min(t.getY(),r.getY())),this.maxY=Math.trunc(Math.max(n.getY(),i.getY()))}constructor_2(e){this.image=e.image,this.topLeft=e.getTopLeft(),this.bottomLeft=e.getBottomLeft(),this.topRight=e.getTopRight(),this.bottomRight=e.getBottomRight(),this.minX=e.getMinX(),this.maxX=e.getMaxX(),this.minY=e.getMinY(),this.maxY=e.getMaxY()}static merge(e,t){return e==null?t:t==null?e:new Gt(e.image,e.topLeft,e.bottomLeft,t.topRight,t.bottomRight)}addMissingRows(e,t,n){let r=this.topLeft,i=this.bottomLeft,s=this.topRight,a=this.bottomRight;if(e>0){let o=n?this.topLeft:this.topRight,l=Math.trunc(o.getY()-e);l<0&&(l=0);let c=new X(o.getX(),l);n?r=c:s=c}if(t>0){let o=n?this.bottomLeft:this.bottomRight,l=Math.trunc(o.getY()+t);l>=this.image.getHeight()&&(l=this.image.getHeight()-1);let c=new X(o.getX(),l);n?i=c:a=c}
6return new Gt(this.image,r,i,s,a)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class hi{constructor(e,t,n,r){this.columnCount=e,this.errorCorrectionLevel=r,this.rowCountUpperPart=t,this.rowCountLowerPart=n,this.rowCount=t+n}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class hn{constructor(){this.buffer=""}static form(e,t){let n=-1;function r(s,a,o,l,c,f){if(s==="%%")return"%";if(t[++n]===void 0)return;s=l?parseInt(l.substr(1)):void 0;let d=c?parseInt(c.substr(1)):void 0,C;switch(f){case"s":C=t[n];break;case"c":C=t[n][0];break;case"f":C=parseFloat(t[n]).toFixed(s);break;case"p":C=parseFloat(t[n]).toPrecision(s);break;case"e":C=parseFloat(t[n]).toExponential(s);break;case"x":C=parseInt(t[n]).toString(d||16);break;case"d":C=parseFloat(parseInt(t[n],d||10).toPrecision(s)).toFixed(0);break}C=typeof C=="object"?JSON.stringify(C):(+C).toString(d);let p=parseInt(o),b=o&&o[0]+""=="0"?"0":" ";for(;C.length<p;)C=a!==void 0?C+b:b+C;return C}let i=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(i,r)}format(e,...t){this.buffer+=hn.form(e,t)}toString(){return this.buffer}}class un{constructor(e){this.boundingBox=new Gt(e),this.codewords=new Array(e.getMaxY()-e.getMinY()+1)}getCodewordNearby(e){let t=this.getCodeword(e);if(t!=null)return t;for(let n=1;n<un.MAX_NEARBY_DISTANCE;n++){let r=this.imageRowToCodewordIndex(e)-n;if(r>=0&&(t=this.codewords[r],t!=null)||(r=this.imageRowToCodewordIndex(e)+n,r<this.codewords.length&&(t=this.codewords[r],t!=null)))return t}return null}imageRowToCodewordIndex(e){return e-this.boundingBox.getMinY()}setCodeword(e,t){this.codewords[this.imageRowToCodewordIndex(e)]=t}getCodeword(e){return this.codewords[this.imageRowToCodewordIndex(e)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const e=new hn;let t=0;for(const n of this.codewords){if(n==null){e.format("%3d: | %n",t++);continue}e.format("%3d: %3d|%3d%n",t++,n.getRowNumber(),n.getValue())}return e.toString()}}un.MAX_NEARBY_DISTANCE=5;class fn{constructor(){this.values=new Map}setValue(e){e=Math.trunc(e);let t=this.values.get(e);t==null&&(t=0),t++,this.values.set(e,t)}getValue(){let e=-1,t=new Array;for(const[n,r]of this.values.entries()){const i={getKey:()=>n,getValue:()=>r};i.getValue()>e?(e=i.getValue(),t=[],t.push(i.getKey())):i.getValue()===e&&t.push(i.getKey())}return Q.toIntArray(t)}getConfidence(e){return this.values.get(e)}}class mr extends un{constructor(e,t){super(e),this._isLeft=t}setRowNumbers(){for(let e of this.getCodewords())e!=null&&e.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let t=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(t,e);let n=this.getBoundingBox(),r=this._isLeft?n.getTopLeft():n.getTopRight(),i=this._isLeft?n.getBottomLeft():n.getBottomRight(),s=this.imageRowToCodewordIndex(Math.trunc(r.getY())),a=this.imageRowToCodewordIndex(Math.trunc(i.getY())),o=-1,l=1,c=0;for(let f=s;f<a;f++){if(t[f]==null)continue;let d=t[f],C=d.getRowNumber()-o;if(C===0)c++;else if(C===1)l=Math.max(l,c),c=1,o=d.getRowNumber();else if(C<0||d.getRowNumber()>=e.getRowCount()||C>f)t[f]=null;else{let p;l>2?p=(l-2)*C:p=C;let b=p>=f;for(let y=1;y<=p&&!b;y++)b=t[f-y]!=null;b?t[f]=null:(o=d.getRowNumber(),c=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(e==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let t=new Int32Array(e.getRowCount());for(let n of this.getCodewords())if(n!=null){let r=n.getRowNumber();if(r>=t.length)continue;t[r]++}return t}adjustIncompleteIndicatorColumnRowNumbers(e){let t=this.getBoundingBox(),n=this._isLeft?t.getTopLeft():t.getTopRight(),r=this._isLeft?t.getBottomLeft():t.getBottomRight(),i=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.imageRowToCodewordIndex(Math.trunc(r.getY())),a=this.getCodewords(),o=-1;for(let l=i;l<s;l++){if(a[l]==null)continue;let c=a[l];c.setRowNumberAsRowIndicatorColumn();let f=c.getRowNumber()-o;f===0||(f===1?o=c.getRowNumber():c.getRowNumber()>=e.getRowCount()?a[l]=null:o=c.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),t=new fn,n=new fn,r=new fn,i=new fn;for(let a of e){if(a==null)continue;a.setRowNumberAsRowIndicatorColumn();let o=a.getValue()%30,l=a.getRowNumber();switch(this._isLeft||(l+=2),l%3){case 0:n.setValue(o*3+1);break;case 1:i.setValue(o/3),r.setValue(o%3);break;case 2:t.setValue(o+1);break}}if(t.getValue().length===0||n.getValue().length===0||r.getValue().length===0||i.getValue().length===0||t.getValue()[0]<1||n.getValue()[0]+r.getValue()[0]<Q.MIN_ROWS_IN_BARCODE||n.getValue()[0]+r.getValue()[0]>Q.MAX_ROWS_IN_BARCODE)return null;let s=new hi(t.getValue()[0],n.getValue()[0],r.getValue()[0],i.getValue()[0]);return this.removeIncorrectCodewords(e,s),s}removeIncorrectCodewords(e,t){for(let n=0;n<e.length;n++){let r=e[n];if(e[n]==null)continue;let i=r.getValue()%30,s=r.getRowNumber();if(s>t.getRowCount()){e[n]=null;continue}switch(this._isLeft||(s+=2),s%3){case 0:i*3+1!==t.getRowCountUpperPart()&&(e[n]=null);break;case 1:(Math.trunc(i/3)!==t.getErrorCorrectionLevel()||i%3!==t.getRowCountLowerPart())&&(e[n]=null);break;case 2:i+1!==t.getColumnCount()&&(e[n]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+` 7`+super.toString()}}class dn{constructor(e,t){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=e,this.barcodeColumnCount=e.getColumnCount(),this.boundingBox=t,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let e=Q.MAX_CODEWORDS_IN_BARCODE,t;do t=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e<t);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(e){e!=null&&e.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let e=this.adjustRowNumbersByRow();if(e===0)return 0;for(let t=1;t<this.barcodeColumnCount+1;t++){let n=this.detectionResultColumns[t].getCodewords();for(let r=0;r<n.length;r++)n[r]!=null&&(n[r].hasValidRowNumber()||this.adjustRowNumbers(t,r,n))}return e}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}
7adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let e=this.detectionResultColumns[0].getCodewords(),t=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let n=0;n<e.length;n++)if(e[n]!=null&&t[n]!=null&&e[n].getRowNumber()===t[n].getRowNumber())for(let r=1;r<=this.barcodeColumnCount;r++){let i=this.detectionResultColumns[r].getCodewords()[n];i!=null&&(i.setRowNumber(e[n].getRowNumber()),i.hasValidRowNumber()||(this.detectionResultColumns[r].getCodewords()[n]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let e=0,t=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let n=0;n<t.length;n++){if(t[n]==null)continue;let r=t[n].getRowNumber(),i=0;for(let s=this.barcodeColumnCount+1;s>0&&i<this.ADJUST_ROW_NUMBER_SKIP;s--){let a=this.detectionResultColumns[s].getCodewords()[n];a!=null&&(i=dn.adjustRowNumberIfValid(r,i,a),a.hasValidRowNumber()||e++)}}return e}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let e=0,t=this.detectionResultColumns[0].getCodewords();for(let n=0;n<t.length;n++){if(t[n]==null)continue;let r=t[n].getRowNumber(),i=0;for(let s=1;s<this.barcodeColumnCount+1&&i<this.ADJUST_ROW_NUMBER_SKIP;s++){let a=this.detectionResultColumns[s].getCodewords()[n];a!=null&&(i=dn.adjustRowNumberIfValid(r,i,a),a.hasValidRowNumber()||e++)}}return e}static adjustRowNumberIfValid(e,t,n){return n==null||n.hasValidRowNumber()||(n.isValidRowNumber(e)?(n.setRowNumber(e),t=0):++t),t}adjustRowNumbers(e,t,n){if(!this.detectionResultColumns[e-1])return;let r=n[t],i=this.detectionResultColumns[e-1].getCodewords(),s=i;this.detectionResultColumns[e+1]!=null&&(s=this.detectionResultColumns[e+1].getCodewords());let a=new Array(14);a[2]=i[t],a[3]=s[t],t>0&&(a[0]=n[t-1],a[4]=i[t-1],a[5]=s[t-1]),t>1&&(a[8]=n[t-2],a[10]=i[t-2],a[11]=s[t-2]),t<n.length-1&&(a[1]=n[t+1],a[6]=i[t+1],a[7]=s[t+1]),t<n.length-2&&(a[9]=n[t+2],a[12]=i[t+2],a[13]=s[t+2]);for(let o of a)if(dn.adjustRowNumber(r,o))return}static adjustRowNumber(e,t){return t==null?!1:t.hasValidRowNumber()&&t.getBucket()===e.getBucket()?(e.setRowNumber(t.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(e){this.boundingBox=e}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(e,t){this.detectionResultColumns[e]=t}getDetectionResultColumn(e){return this.detectionResultColumns[e]}toString(){let e=this.detectionResultColumns[0];e==null&&(e=this.detectionResultColumns[this.barcodeColumnCount+1]);let t=new hn;for(let n=0;n<e.getCodewords().length;n++){t.format("CW %3d:",n);for(let r=0;r<this.barcodeColumnCount+2;r++){if(this.detectionResultColumns[r]==null){t.format(" | ");continue}let i=this.detectionResultColumns[r].getCodewords()[n];if(i==null){t.format(" | ");continue}t.format(" %3d|%3d",i.getRowNumber(),i.getValue())}t.format("%n")}return t.toString()}}class xn{constructor(e,t,n,r){this.rowNumber=xn.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(e),this.endX=Math.trunc(t),this.bucket=Math.trunc(n),this.value=Math.trunc(r)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(e){return e!==xn.BARCODE_ROW_UNKNOWN&&this.bucket===e%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(e){this.rowNumber=e}toString(){return this.rowNumber+"|"+this.value}}xn.BARCODE_ROW_UNKNOWN=-1;class it{static initialize(){for(let e=0;e<Q.SYMBOL_TABLE.length;e++){let t=Q.SYMBOL_TABLE[e],n=t&1;for(let r=0;r<Q.BARS_IN_MODULE;r++){let i=0;for(;(t&1)===n;)i+=1,t>>=1;n=t&1,it.RATIOS_TABLE[e]||(it.RATIOS_TABLE[e]=new Array(Q.BARS_IN_MODULE)),it.RATIOS_TABLE[e][Q.BARS_IN_MODULE-r-1]=Math.fround(i/Q.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let t=it.getDecodedCodewordValue(it.sampleBitCounts(e));return t!==-1?t:it.getClosestDecodedValue(e)}static sampleBitCounts(e){let t=oe.sum(e),n=new Int32Array(Q.BARS_IN_MODULE),r=0,i=0;for(let s=0;s<Q.MODULES_IN_CODEWORD;s++){let a=t/(2*Q.MODULES_IN_CODEWORD)+s*t/Q.MODULES_IN_CODEWORD;i+e[r]<=a&&(i+=e[r],r++),n[r]++}return n}static getDecodedCodewordValue(e){let t=it.getBitValue(e);return Q.getCodeword(t)===-1?-1:t}static getBitValue(e){let t=0;for(let n=0;n<e.length;n++)for(let r=0;r<e[n];r++)t=t<<1|(n%2===0?1:0);return Math.trunc(t)}static getClosestDecodedValue(e){let t=oe.sum(e),n=new Array(Q.BARS_IN_MODULE);if(t>1)for(let s=0;s<n.length;s++)n[s]=Math.fround(e[s]/t);let r=En.MAX_VALUE,i=-1;this.bSymbolTableReady||it.initialize();for(let s=0;s<it.RATIOS_TABLE.length;s++){let a=0,o=it.RATIOS_TABLE[s];for(let l=0;l<Q.BARS_IN_MODULE;l++){let c=Math.fround(o[l]-n[l]);if(a+=Math.fround(c*c),a>=r)break}a<r&&(r=a,i=Q.SYMBOL_TABLE[s])}return i}}it.bSymbolTableReady=!1,it.RATIOS_TABLE=new Array(Q.SYMBOL_TABLE.length).map(u=>
7new Array(Q.BARS_IN_MODULE));class pr{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(e){this.segmentIndex=e}getFileId(){return this.fileId}setFileId(e){this.fileId=e}getOptionalData(){return this.optionalData}setOptionalData(e){this.optionalData=e}isLastSegment(){return this.lastSegment}setLastSegment(e){this.lastSegment=e}getSegmentCount(){return this.segmentCount}setSegmentCount(e){this.segmentCount=e}getSender(){return this.sender||null}setSender(e){this.sender=e}getAddressee(){return this.addressee||null}setAddressee(e){this.addressee=e}getFileName(){return this.fileName}setFileName(e){this.fileName=e}getFileSize(){return this.fileSize}setFileSize(e){this.fileSize=e}getChecksum(){return this.checksum}setChecksum(e){this.checksum=e}getTimestamp(){return this.timestamp}setTimestamp(e){this.timestamp=e}}class Ir{static parseLong(e,t=void 0){return parseInt(e,t)}}class br extends m{}br.kind="NullPointerException";class ui{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,t,n){if(e==null)throw new br;if(t<0||t>e.length||n<0||t+n>e.length||t+n<0)throw new ve;if(n===0)return;for(let r=0;r<n;r++)this.write(e[t+r])}flush(){}close(){}}class fi extends m{}class di extends ui{constructor(e=32){if(super(),this.count=0,e<0)throw new O("Negative initial size: "+e);this.buf=new Uint8Array(e)}ensureCapacity(e){e-this.buf.length>0&&this.grow(e)}grow(e){let n=this.buf.length<<1;if(n-e<0&&(n=e),n<0){if(e<0)throw new fi;n=J.MAX_VALUE}this.buf=Ie.copyOfUint8Array(this.buf,n)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,t,n){if(t<0||t>e.length||n<0||t+n-e.length>0)throw new ve;this.ensureCapacity(this.count+n),Z.arraycopy(e,t,this.buf,this.count,n),this.count+=n}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return Ie.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(e){return e?typeof e=="string"?this.toString_string(e):this.toString_number(e):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(e){return new String(this.buf).toString()}toString_number(e){return new String(this.buf).toString()}close(){}}var Ce;(function(u){u[u.ALPHA=0]="ALPHA",u[u.LOWER=1]="LOWER",u[u.MIXED=2]="MIXED",u[u.PUNCT=3]="PUNCT",u[u.ALPHA_SHIFT=4]="ALPHA_SHIFT",u[u.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Ce||(Ce={}));function yr(){if(typeof window<"u")return window.BigInt||null;if(typeof Dn<"u")return Dn.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let Sn;function Pt(u){if(typeof Sn>"u"&&(Sn=yr()),Sn===null)throw new Error("BigInt is not supported!");return Sn(u)}function xi(){let u=[];u[0]=Pt(1);let e=Pt(900);u[1]=e;for(let t=2;t<16;t++)u[t]=u[t-1]*e;return u}class S{static decode(e,t){let n=new Ae(""),r=U.ISO8859_1;n.enableDecoding(r);let i=1,s=e[i++],a=new pr;for(;i<e[0];){switch(s){case S.TEXT_COMPACTION_MODE_LATCH:i=S.textCompaction(e,i,n);break;case S.BYTE_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH_6:i=S.byteCompaction(s,e,r,i,n);break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(e[i++]);break;case S.NUMERIC_COMPACTION_MODE_LATCH:i=S.numericCompaction(e,i,n);break;case S.ECI_CHARSET:U.getCharacterSetECIByValue(e[i++]);break;case S.ECI_GENERAL_PURPOSE:i+=2;break;case S.ECI_USER_DEFINED:i++;break;case S.BEGIN_MACRO_PDF417_CONTROL_BLOCK:i=S.decodeMacroBlock(e,i,a);break;case S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case S.MACRO_PDF417_TERMINATOR:throw new V;default:i--,i=S.textCompaction(e,i,n);break}if(i<e.length)s=e[i++];else throw V.getFormatInstance()}if(n.length()===0)throw V.getFormatInstance();let o=new sn(null,n.toString(),null,t);return o.setOther(a),o}static decodeMacroBlock(e,t,n){if(t+S.NUMBER_OF_SEQUENCE_CODEWORDS>e[0])throw V.getFormatInstance();let r=new Int32Array(S.NUMBER_OF_SEQUENCE_CODEWORDS);for(let a=0;a<S.NUMBER_OF_SEQUENCE_CODEWORDS;a++,t++)r[a]=e[t];n.setSegmentIndex(J.parseInt(S.decodeBase900toBase10(r,S.NUMBER_OF_SEQUENCE_CODEWORDS)));let i=new Ae;t=S.textCompaction(e,t,i),n.setFileId(i.toString());let s=-1;for(e[t]===S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(s=t+1);t<e[0];)switch(e[t]){case S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(t++,e[t]){case S.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let a=new Ae;t=S.textCompaction(e,t+1,a),n.setFileName(a.toString());break;case S.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let o=new Ae;t=S.textCompaction(e,t+1,o),n.setSender(o.toString());break;case S.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let l=new Ae;t=S.textCompaction(e,t+1,l),n.setAddressee(l.toString());break;case S.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let c=new Ae;t=S.numericCompaction(e,t+1,c),n.setSegmentCount(J.parseInt(c.toString()));break;case S.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let f=new Ae;t=S.numericCompaction(e,t+1,f),n.setTimestamp(Ir.parseLong(f.toString()));break;case S.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let d=new Ae;t=S.numericCompaction(e,t+1,d),n.setChecksum(J.parseInt(d.toString()));break;case S.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let C=new Ae;t=S.numericCompaction(e,t+1,C),n.setFileSize(Ir.parseLong(C.toString()));break;default:throw V.getFormatInstance()}break;case S.MACRO_PDF417_TERMINATOR:t++,n.setLastSegment(!0);break;default:throw V.getFormatInstance()}if(s!==-1){let a=t-s;n.isLastSegment()&&a--,n.setOptionalData(Ie.copyOfRange(e,s,s+a))}return t}static textCompaction(e,t,n){let r=new Int32Array((e[0]-t)*2),i=new Int32Array((e[0]-t)*2),s=0,a=!1;for(;t<e[0]&&!a;){let o=e[t++];if(o<S.TEXT_COMPACTION_MODE_LATCH)r[s]=o/30,r[s+1]=o%30,s+=2;else switch(o){case S.TEXT_COMPACTION_MODE_LATCH:r[s++]=S.TEXT_COMPACTION_MODE_LATCH;break;case S.BYTE_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH_6:case S.NUMERIC_COMPACTION_MODE_LATCH:case S.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case S.MACRO_PDF417_TERMINATOR:t--,a=!0;break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r[s]=S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,o=e[t++],i[s]=o,s++;break}}return S.decodeTextCompaction(r,i,s,n),t}static decodeTextCompaction(e,t,n,r){let i=Ce.ALPHA,s=Ce.ALPHA,a=0;for(;a<n;){let o=e[a],l="";switch(i){case Ce.ALPHA:if(o<26)l=String.fromCharCode(65+o);else switch(o){case 26:l=" ";break;case S.LL:i=Ce.LOWER;break;case S.ML:i=Ce.MIXED;break;case S.PS:s=i,i=Ce.PUNCT_SHIFT;break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[a]);break;case S.TEXT_COMPACTION_MODE_LATCH:i=Ce.ALPHA;break}break;case Ce.LOWER:if(o<26)l=String.fromCharCode(97+o);else switch(o){case 26:l=" ";break;case S.AS:s=i,i=Ce.ALPHA_SHIFT;break;case S.ML:i=Ce.MIXED;break;case S.PS:s=i,i=Ce.PUNCT_SHIFT;break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[a]);break;case S.TEXT_COMPACTION_MODE_LATCH:i=Ce.ALPHA;break}break;case Ce.MIXED:if(o<S.PL)l=S.MIXED_CHARS[o];else switch(o){case S.PL:i=Ce.PUNCT;break;case 26:l=" ";break;case S.LL:i=Ce.LOWER;break;case S.AL:i=Ce.ALPHA;break;case S.PS:s=i,i=Ce.PUNCT_SHIFT;break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[a]);break;case S.TEXT_COMPACTION_MODE_LATCH:i=Ce.ALPHA;break}break;case Ce.PUNCT:if(o<S.PAL)l=S.PUNCT_CHARS[o];else switch(o){case S.PAL:i=Ce.ALPHA;break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[a]);break;case S.TEXT_COMPACTION_MODE_LATCH:i=Ce.ALPHA;break}break;case Ce.ALPHA_SHIFT:if(i=s,o<26)l=String.fromCharCode(65+o);else switch(o){case 26:l=" ";break;case S.TEXT_COMPACTION_MODE_LATCH:i=Ce.ALPHA;break}break;case Ce.PUNCT_SHIFT:if(i=s,o<S.PAL)l=S.PUNCT_CHARS[o];else switch(o){case S.PAL:i=Ce.ALPHA;break;case S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(t[a]);break;case S.TEXT_COMPACTION_MODE_LATCH:i=Ce.ALPHA;break}break}l!==""&&r.append(l),a++}}static byteCompaction(e,t,n,r,i){let s=new di,a=0,o=0,l=!1;switch(e){case S.BYTE_COMPACTION_MODE_LATCH:let c=new Int32Array(6),f=t[r++];for(;r<t[0]&&!l;)switch(c[a++]=f,o=900*o+f,f=t[r++],f){case S.TEXT_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH:case S.NUMERIC_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH_6:case S.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case S.MACRO_PDF417_TERMINATOR:r--,l=!0;break;default:if(a%5===0&&a>0){for(let d=0;d<6;++d)s.write(Number(Pt(o)>>Pt(8*(5-d))));o=0,a=0}break}r===t[0]&&f<S.TEXT_COMPACTION_MODE_LATCH&&(c[a++]=f);for(let d=0;d<a;d++)s.write(c[d]);break;case S.BYTE_COMPACTION_MODE_LATCH_6:for(;r<t[0]&&!l;){let d=t[r++];if(d<S.TEXT_COMPACTION_MODE_LATCH)a++,o=900*o+d;else switch(d){case S.TEXT_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH:case S.NUMERIC_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH_6:case S.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case S.MACRO_PDF417_TERMINATOR:r--,l=!0;break}if(a%5===0&&a>0){for(let C=0;C<6;++C)s.write(Number(Pt(o)>>Pt(8*(5-C))));o=0,a=0}}break}return i.append(et.decode(s.toByteArray(),n)),r}static numericCompaction(e,t,n){let r=0,i=!1,s=new Int32Array(S.MAX_NUMERIC_CODEWORDS);for(;t<e[0]&&!i;){let a=e[t++];if(t===e[0]&&(i=!0),a<S.TEXT_COMPACTION_MODE_LATCH)s[r]=a,r++;else switch(a){case S.TEXT_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH:case S.BYTE_COMPACTION_MODE_LATCH_6:case S.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case S.MACRO_PDF417_TERMINATOR:t--,i=!0;break}(r%S.MAX_NUMERIC_CODEWORDS===0||a===S.NUMERIC_COMPACTION_MODE_LATCH||i)&&r>0&&(n.append(S.decodeBase900toBase10(s,r)),r=0)}return t}static decodeBase900toBase10(e,t){let n=Pt(0);for(let i=0;i<t;i++)n+=S.EXP900[t-i-1]*Pt(e[i]);let r=n.toString();if(r.charAt(0)!=="1")throw new V;return r.substring(1)}}S.TEXT_COMPACTION_MODE_LATCH=900,S.BYTE_COMPACTION_MODE_LATCH=901,S.NUMERIC_COMPACTION_MODE_LATCH=902,S.BYTE_COMPACTION_MODE_LATCH_6=924,S.ECI_USER_DEFINED=925,S.ECI_GENERAL_PURPOSE=926,S.ECI_CHARSET=927,S.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,S.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,S.MACRO_PDF417_TERMINATOR=922,S.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,S.MAX_NUMERIC_CODEWORDS=15,S.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,S.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,S.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,S.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,S.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,S.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,S.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,S.PL=25,S.LL=27,S.AS=27,S.ML=28,S.AL=28,S.PS=29,S.PAL=29,S.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,: 8-.$/"|*()?{}
8'`,S.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",S.EXP900=yr()?xi():[],S.NUMBER_OF_SEQUENCE_CODEWORDS=2;class re{constructor(){}static decode(e,t,n,r,i,s,a){let o=new Gt(e,t,n,r,i),l=null,c=null,f;for(let p=!0;;p=!1){if(t!=null&&(l=re.getRowIndicatorColumn(e,o,t,!0,s,a)),r!=null&&(c=re.getRowIndicatorColumn(e,o,r,!1,s,a)),f=re.merge(l,c),f==null)throw R.getNotFoundInstance();let b=f.getBoundingBox();if(p&&b!=null&&(b.getMinY()<o.getMinY()||b.getMaxY()>o.getMaxY()))o=b;else break}f.setBoundingBox(o);let d=f.getBarcodeColumnCount()+1;f.setDetectionResultColumn(0,l),f.setDetectionResultColumn(d,c);let C=l!=null;for(let p=1;p<=d;p++){let b=C?p:d-p;if(f.getDetectionResultColumn(b)!==void 0)continue;let y;b===0||b===d?y=new mr(o,b===0):y=new un(o),f.setDetectionResultColumn(b,y);let N=-1,F=N;for(let k=o.getMinY();k<=o.getMaxY();k++){if(N=re.getStartColumn(f,b,k,C),N<0||N>o.getMaxX()){if(F===-1)continue;N=F}let v=re.detectCodeword(e,o.getMinX(),o.getMaxX(),C,N,k,s,a);v!=null&&(y.setCodeword(k,v),F=N,s=Math.min(s,v.getWidth()),a=Math.max(a,v.getWidth()))}}return re.createDecoderResult(f)}static merge(e,t){if(e==null&&t==null)return null;let n=re.getBarcodeMetadata(e,t);if(n==null)return null;let r=Gt.merge(re.adjustBoundingBox(e),re.adjustBoundingBox(t));return new dn(n,r)}static adjustBoundingBox(e){if(e==null)return null;let t=e.getRowHeights();if(t==null)return null;let n=re.getMax(t),r=0;for(let a of t)if(r+=n-a,a>0)break;let i=e.getCodewords();for(let a=0;r>0&&i[a]==null;a++)r--;let s=0;for(let a=t.length-1;a>=0&&(s+=n-t[a],!(t[a]>0));a--);for(let a=i.length-1;s>0&&i[a]==null;a--)s--;return e.getBoundingBox().addMissingRows(r,s,e.isLeft())}static getMax(e){let t=-1;for(let n of e)t=Math.max(t,n);return t}static getBarcodeMetadata(e,t){let n;if(e==null||(n=e.getBarcodeMetadata())==null)return t==null?null:t.getBarcodeMetadata();let r;return t==null||(r=t.getBarcodeMetadata())==null?n:n.getColumnCount()!==r.getColumnCount()&&n.getErrorCorrectionLevel()!==r.getErrorCorrectionLevel()&&n.getRowCount()!==r.getRowCount()?null:n}static getRowIndicatorColumn(e,t,n,r,i,s){let a=new mr(t,r);for(let o=0;o<2;o++){let l=o===0?1:-1,c=Math.trunc(Math.trunc(n.getX()));for(let f=Math.trunc(Math.trunc(n.getY()));f<=t.getMaxY()&&f>=t.getMinY();f+=l){let d=re.detectCodeword(e,0,e.getWidth(),r,c,f,i,s);d!=null&&(a.setCodeword(f,d),r?c=d.getStartX():c=d.getEndX())}}return a}static adjustCodewordCount(e,t){let n=t[0][1],r=n.getValue(),i=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-re.getNumberOfECCodeWords(e.getBarcodeECLevel());if(r.length===0){if(i<1||i>Q.MAX_CODEWORDS_IN_BARCODE)throw R.getNotFoundInstance();n.setValue(i)}else r[0]!==i&&n.setValue(i)}static createDecoderResult(e){let t=re.createBarcodeMatrix(e);re.adjustCodewordCount(e,t);let n=new Array,r=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),i=[],s=new Array;for(let o=0;o<e.getBarcodeRowCount();o++)for(let l=0;l<e.getBarcodeColumnCount();l++){let c=t[o][l+1].getValue(),f=o*e.getBarcodeColumnCount()+l;c.length===0?n.push(f):c.length===1?r[f]=c[0]:(s.push(f),i.push(c))}let a=new Array(i.length);for(let o=0;o<a.length;o++)a[o]=i[o];return re.createDecoderResultFromAmbiguousValues(e.getBarcodeECLevel(),r,Q.toIntArray(n),Q.toIntArray(s),a)}static createDecoderResultFromAmbiguousValues(e,t,n,r,i){let s=new Int32Array(r.length),a=100;for(;a-- >0;){for(let o=0;o<s.length;o++)t[r[o]]=i[o][s[o]];try{return re.decodeCodewords(t,e,n)}catch(o){if(!(o instanceof j))throw o}if(s.length===0)throw j.getChecksumInstance();for(let o=0;o<s.length;o++)if(s[o]<i[o].length-1){s[o]++;break}else if(s[o]=0,o===s.length-1)throw j.getChecksumInstance()}throw j.getChecksumInstance()}static createBarcodeMatrix(e){let t=Array.from({length:e.getBarcodeRowCount()},()=>new Array(e.getBarcodeColumnCount()+2));for(let r=0;r<t.length;r++)for(let i=0;i<t[r].length;i++)t[r][i]=new fn;let n=0;for(let r of e.getDetectionResultColumns()){if(r!=null){for(let i of r.getCodewords())if(i!=null){let s=i.getRowNumber();if(s>=0){if(s>=t.length)continue;t[s][n].setValue(i.getValue())}}}n++}return t}static isValidBarcodeColumn(e,t){return t>=0&&t<=e.getBarcodeColumnCount()+1}static getStartColumn(e,t,n,r){let i=r?1:-1,s=null;if(re.isValidBarcodeColumn(e,t-i)&&(s=e.getDetectionResultColumn(t-i).getCodeword(n)),s!=null)return r?s.getEndX():s.getStartX();if(s=e.getDetectionResultColumn(t).getCodewordNearby(n),s!=null)return r?s.getStartX():s.getEndX();if(re.isValidBarcodeColumn(e,t-i)&&(s=e.getDetectionResultColumn(t-i).getCodewordNearby(n)),s!=null)return r?s.getEndX():s.getStartX();let a=0;for(;re.isValidBarcodeColumn(e,t-i);){t-=i;for(let o of e.getDetectionResultColumn(t).getCodewords())if(o!=null)return(r?o.getEndX():o.getStartX())+i*a*(o.getEndX()-o.getStartX());a++}return r?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,t,n,r,i,s,a,o){i=re.adjustCodewordStartColumn(e,t,n,r,i,s);let l=re.getModuleBitCount(e,t,n,r,i,s);if(l==null)return null;
vendor: 1,040 bytes, line 8
8let c,f=oe.sum(l);if(r)c=i+f;else{for(let p=0;p<l.length/2;p++){let b=l[p];l[p]=l[l.length-1-p],l[l.length-1-p]=b}c=i,i=c-f}if(!re.checkCodewordSkew(f,a,o))return null;let d=it.getDecodedValue(l),C=Q.getCodeword(d);return C===-1?null:new xn(i,c,re.getCodewordBucketNumber(d),C)}static getModuleBitCount(e,t,n,r,i,s){let a=i,o=new Int32Array(8),l=0,c=r?1:-1,f=r;for(;(r?a<n:a>=t)&&l<o.length;)e.get(a,s)===f?(o[l]++,a+=c):(l++,f=!f);return l===o.length||a===(r?n:t)&&l===o.length-1?o:null}static getNumberOfECCodeWords(e){return 2<<e}static adjustCodewordStartColumn(e,t,n,r,i,s){let a=i,o=r?-1:1;for(let l=0;l<2;l++){for(;(r?a>=t:a<n)&&r===e.get(a,s);){if(Math.abs(i-a)>re.CODEWORD_SKEW_SIZE)return i;a+=o}o=-o,r=!r}return a}static checkCodewordSkew(e,t,n){return t-re.CODEWORD_SKEW_SIZE<=e&&e<=n+re.CODEWORD_SKEW_SIZE}static decodeCodewords(e,t,n){if(e.length===0)throw V.getFormatInstance();let r=1<<t+1,i=re.correctErrors(e,n,r);re.verifyCodewordCount(e,r);let s=S.decode(e,""+t);return s.setErrorsCorrected(i),s.setErasures(n.length),s}
8static correctErrors(e,t,n){if(t!=null&&t.length>n/2+re.MAX_ERRORS||n<0||n>re.MAX_EC_CODEWORDS)throw j.getChecksumInstance();return re.errorCorrection.decode(e,n,t)}static verifyCodewordCount(e,t){if(e.length<4)throw V.getFormatInstance();let n=e[0];if(n>e.length)throw V.getFormatInstance();if(n===0)if(t<e.length)e[0]=e.length-t;else throw V.getFormatInstance()}static getBitCountForCodeword(e){let t=new Int32Array(8),n=0,r=t.length-1;for(;!((e&1)!==n&&(n=e&1,r--,r<0));)t[r]++,e>>=1;return t}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return re.getCodewordBucketNumber(re.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let t=new hn;for(let n=0;n<e.length;n++){t.format("Row %2d: ",n);for(let r=0;r<e[n].length;r++){let i=e[n][r];i.getValue().length===0?t.format(" ",null):t.format("%4d(%2d)",i.getValue()[0],i.getConfidence(i.getValue()[0]))}t.format("%n")}return t.toString()}}re.CODEWORD_SKEW_SIZE=2,re.MAX_ERRORS=3,re.MAX_EC_CODEWORDS=512,re.errorCorrection=new Er;class Ye{decode(e,t=null){let n=Ye.decode(e,t,!1);if(n==null||n.length===0||n[0]==null)throw R.getNotFoundInstance();return n[0]}decodeMultiple(e,t=null){try{return Ye.decode(e,t,!0)}catch(n){throw n instanceof V||n instanceof j?R.getNotFoundInstance():n}}static decode(e,t,n){const r=new Array,i=ne.detectMultiple(e,t,n);for(const s of i.getPoints()){const a=re.decode(i.getBits(),s[4],s[5],s[6],s[7],Ye.getMinCodewordWidth(s),Ye.getMaxCodewordWidth(s)),o=new Qe(a.getText(),a.getRawBytes(),void 0,s,K.PDF_417);o.putMetadata(Ge.ERROR_CORRECTION_LEVEL,a.getECLevel());const l=a.getOther();l!=null&&o.putMetadata(Ge.PDF417_EXTRA_METADATA,l),r.push(o)}return r.map(s=>s)}static getMaxWidth(e,t){return e==null||t==null?0:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMinWidth(e,t){return e==null||t==null?J.MAX_VALUE:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(Ye.getMaxWidth(e[0],e[4]),Ye.getMaxWidth(e[6],e[2])*Q.MODULES_IN_CODEWORD/Q.MODULES_IN_STOP_PATTERN),Math.max(Ye.getMaxWidth(e[1],e[5]),Ye.getMaxWidth(e[7],e[3])*Q.MODULES_IN_CODEWORD/Q.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(Ye.getMinWidth(e[0],e[4]),Ye.getMinWidth(e[6],e[2])*Q.MODULES_IN_CODEWORD/Q.MODULES_IN_STOP_PATTERN),Math.min(Ye.getMinWidth(e[1],e[5]),Ye.getMinWidth(e[7],e[3])*Q.MODULES_IN_CODEWORD/Q.MODULES_IN_STOP_PATTERN)))}reset(){}}class Nn extends m{}Nn.kind="ReaderException";class Tr{constructor(e,t){this.verbose=e===!0,t&&this.setHints(t)}decode(e,t){return t&&this.setHints(t),this.decodeInternal(e)}decodeWithState(e){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(e)}setHints(e){this.hints=e;const t=!E(e)&&e.get(we.TRY_HARDER)===!0,n=E(e)?null:e.get(we.POSSIBLE_FORMATS),r=new Array;if(!E(n)){const i=n.some(s=>s===K.UPC_A||s===K.UPC_E||s===K.EAN_13||s===K.EAN_8||s===K.CODABAR||s===K.CODE_39||s===K.CODE_93||s===K.CODE_128||s===K.ITF||s===K.RSS_14||s===K.RSS_EXPANDED);i&&!t&&r.push(new Kt(e,this.verbose)),n.includes(K.QR_CODE)&&r.push(new vt),n.includes(K.DATA_MATRIX)&&r.push(new Bt),n.includes(K.AZTEC)&&r.push(new pn),n.includes(K.PDF_417)&&r.push(new Ye),i&&t&&r.push(new Kt(e,this.verbose))}r.length===0&&(t||r.push(new Kt(e,this.verbose)),r.push(new vt),r.push(new Bt),r.push(new pn),r.push(new Ye),t&&r.push(new Kt(e,this.verbose))),this.readers=r}reset(){if(this.readers!==null)for(const e of this.readers)e.reset()}decodeInternal(e){if(this.readers===null)throw new Nn("No readers where selected, nothing can be read.");for(const t of this.readers)try{return t.decode(e,this.hints)}catch(n){if(n instanceof Nn)continue}throw new R("No MultiFormat Readers were able to detect the code.")}}class gi extends Ft{constructor(e=null,t=500){const n=new Tr;n.setHints(e),super(n,t)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class wi extends Ft{constructor(e=500){super(new Ye,e)}}class Ai extends Ft{constructor(e=500){super(new vt,e)}}var Qn;(function(u){u[u.ERROR_CORRECTION=0]="ERROR_CORRECTION",u[u.CHARACTER_SET=1]="CHARACTER_SET",u[u.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",u[u.MIN_SIZE=3]="MIN_SIZE",u[u.MAX_SIZE=4]="MAX_SIZE",u[u.MARGIN=5]="MARGIN",u[u.PDF417_COMPACT=6]="PDF417_COMPACT",u[u.PDF417_COMPACTION=7]="PDF417_COMPACTION",u[u.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",u[u.AZTEC_LAYERS=9]="AZTEC_LAYERS",u[u.QR_VERSION=10]="QR_VERSION"})(Qn||(Qn={}));var ke=Qn;class Jn{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new tt(e,Int32Array.from([1])))}buildGenerator(e){const t=this.cachedGenerators;if(e>=t.length){let n=t[t.length-1];const r=this.field;for(let i=t.length;i<=e;i++){const s=n.multiply(new tt(r,Int32Array.from([1,r.exp(i-1+r.getGeneratorBase())])));t.push(s),n=s}}return t[e]}encode(e,t){if(t===0)throw new O("No error correction bytes");const n=e.length-t;if(n<=0)throw new O("No data bytes provided");const r=this.buildGenerator(t),i=new Int32Array(n);Z.arraycopy(e,0,i,0,n);let s=new tt(this.field,i);s=s.multiplyByMonomial(t,1);const o=s.divide(r)[1].getCoefficients(),l=t-o.length;for(let c=0;c<l;c++)e[n+c]=0;Z.arraycopy(o,0,e,n+l,o.length)}}class De{constructor(){}
8static applyMaskPenaltyRule1(e){return De.applyMaskPenaltyRule1Internal(e,!0)+De.applyMaskPenaltyRule1Internal(e,!1)}static applyMaskPenaltyRule2(e){let t=0;const n=e.getArray(),r=e.getWidth(),i=e.getHeight();for(let s=0;s<i-1;s++){const a=n[s];for(let o=0;o<r-1;o++){const l=a[o];l===a[o+1]&&l===n[s+1][o]&&l===n[s+1][o+1]&&t++}}return De.N2*t}static applyMaskPenaltyRule3(e){let t=0;const n=e.getArray(),r=e.getWidth(),i=e.getHeight();for(let s=0;s<i;s++)for(let a=0;a<r;a++){const o=n[s];a+6<r&&o[a]===1&&o[a+1]===0&&o[a+2]===1&&o[a+3]===1&&o[a+4]===1&&o[a+5]===0&&o[a+6]===1&&(De.isWhiteHorizontal(o,a-4,a)||De.isWhiteHorizontal(o,a+7,a+11))&&t++,s+6<i&&n[s][a]===1&&n[s+1][a]===0&&n[s+2][a]===1&&n[s+3][a]===1&&n[s+4][a]===1&&n[s+5][a]===0&&n[s+6][a]===1&&(De.isWhiteVertical(n,a,s-4,s)||De.isWhiteVertical(n,a,s+7,s+11))&&t++}return t*De.N3}static isWhiteHorizontal(e,t,n){t=Math.max(t,0),n=Math.min(n,e.length);for(let r=t;r<n;r++)if(e[r]===1)return!1;return!0}static isWhiteVertical(e,t,n,r){n=Math.max(n,0),r=Math.min(r,e.length);for(let i=n;i<r;i++)if(e[i][t]===1)return!1;return!0}static applyMaskPenaltyRule4(e){let t=0;const n=e.getArray(),r=e.getWidth(),i=e.getHeight();for(let o=0;o<i;o++){const l=n[o];for(let c=0;c<r;c++)l[c]===1&&t++}const s=e.getHeight()*e.getWidth();return Math.floor(Math.abs(t*2-s)*10/s)*De.N4}static getDataMaskBit(e,t,n){let r,i;switch(e){case 0:r=n+t&1;break;case 1:r=n&1;break;case 2:r=t%3;break;case 3:r=(n+t)%3;break;case 4:r=Math.floor(n/2)+Math.floor(t/3)&1;break;case 5:i=n*t,r=(i&1)+i%3;break;case 6:i=n*t,r=(i&1)+i%3&1;break;case 7:i=n*t,r=i%3+(n+t&1)&1;break;default:throw new O("Invalid mask pattern: "+e)}return r===0}static applyMaskPenaltyRule1Internal(e,t){let n=0;const r=t?e.getHeight():e.getWidth(),i=t?e.getWidth():e.getHeight(),s=e.getArray();for(let a=0;a<r;a++){let o=0,l=-1;for(let c=0;c<i;c++){const f=t?s[a][c]:s[c][a];f===l?o++:(o>=5&&(n+=De.N1+(o-5)),o=1,l=f)}o>=5&&(n+=De.N1+(o-5))}return n}}De.N1=3,De.N2=3,De.N3=40,De.N4=10;class _n{constructor(e,t){this.width=e,this.height=t;const n=new Array(t);for(let r=0;r!==t;r++)n[r]=new Uint8Array(e);this.bytes=n}getHeight(){return this.height}getWidth(){return this.width}get(e,t){return this.bytes[t][e]}getArray(){return this.bytes}setNumber(e,t,n){this.bytes[t][e]=n}setBoolean(e,t,n){this.bytes[t][e]=n?1:0}clear(e){for(const t of this.bytes)Ie.fill(t,e)}equals(e){if(!(e instanceof _n))return!1;const t=e;if(this.width!==t.width||this.height!==t.height)return!1;for(let n=0,r=this.height;n<r;++n){const i=this.bytes[n],s=t.bytes[n];for(let a=0,o=this.width;a<o;++a)if(i[a]!==s[a])return!1}return!0}toString(){const e=new Ae;for(let t=0,n=this.height;t<n;++t){const r=this.bytes[t];for(let i=0,s=this.width;i<s;++i)switch(r[i]){case 0:e.append(" 0");break;case 1:e.append(" 1");break;default:e.append(" ");break}e.append(` 9`)}return e.toString()}}class Ht{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const e=new Ae;return e.append(`<< 10`),e.append(" mode: "),e.append(this.mode?this.mode.toString():"null"),e.append(` 11 ecLevel: `),e.append(this.ecLevel?this.ecLevel.toString():"null"),e.append(` 12 version: `),e.append(this.version?this.version.toString():"null"),e.append(` 13 maskPattern: `),e.append(this.maskPattern.toString()),this.matrix?(e.append(` 14 matrix: 15`),e.append(this.matrix.toString())):e.append(` 16 matrix: null 17`),e.append(`>> 18`),e.toString()}setMode(e){this.mode=e}setECLevel(e){this.ecLevel=e}setVersion(e){this.version=e}setMaskPattern(e){this.maskPattern=e}setMatrix(e){this.matrix=e}static isValidMaskPattern(e){return e>=0&&e<Ht.NUM_MASK_PATTERNS}}Ht.NUM_MASK_PATTERNS=8;class me extends m{}me.kind="WriterException";class q{constructor(){}static clearMatrix(e){e.clear(255)}static buildMatrix(e,t,n,r,i){q.clearMatrix(i),q.embedBasicPatterns(n,i),q.embedTypeInfo(t,r,i),q.maybeEmbedVersionInfo(n,i),q.embedDataBits(e,r,i)}static embedBasicPatterns(e,t){q.embedPositionDetectionPatternsAndSeparators(t),q.embedDarkD
18otAtLeftBottomCorner(t),q.maybeEmbedPositionAdjustmentPatterns(e,t),q.embedTimingPatterns(t)}static embedTypeInfo(e,t,n){const r=new ce;q.makeTypeInfoBits(e,t,r);for(let i=0,s=r.getSize();i<s;++i){const a=r.get(r.getSize()-1-i),o=q.TYPE_INFO_COORDINATES[i],l=o[0],c=o[1];if(n.setBoolean(l,c,a),i<8){const f=n.getWidth()-i-1;n.setBoolean(f,8,a)}else{const d=n.getHeight()-7+(i-8);n.setBoolean(8,d,a)}}}static maybeEmbedVersionInfo(e,t){if(e.getVersionNumber()<7)return;const n=new ce;q.makeVersionInfoBits(e,n);let r=17;for(let i=0;i<6;++i)for(let s=0;s<3;++s){const a=n.get(r);r--,t.setBoolean(i,t.getHeight()-11+s,a),t.setBoolean(t.getHeight()-11+s,i,a)}}static embedDataBits(e,t,n){let r=0,i=-1,s=n.getWidth()-1,a=n.getHeight()-1;for(;s>0;){for(s===6&&(s-=1);a>=0&&a<n.getHeight();){for(let o=0;o<2;++o){const l=s-o;if(!q.isEmpty(n.get(l,a)))continue;let c;r<e.getSize()?(c=e.get(r),++r):c=!1,t!==255&&De.getDataMaskBit(t,l,a)&&(c=!c),n.setBoolean(l,a,c)}a+=i}i=-i,a+=i,s-=2}if(r!==e.getSize())throw new me("Not all bits consumed: "+r+"/"+e.getSize())}static findMSBSet(e){return 32-J.numberOfLeadingZeros(e)}static calculateBCHCode(e,t){if(t===0)throw new O("0 polynomial");const n=q.findMSBSet(t);for(e<<=n-1;q.findMSBSet(e)>=n;)e^=t<<q.findMSBSet(e)-n;return e}static makeTypeInfoBits(e,t,n){if(!Ht.isValidMaskPattern(t))throw new me("Invalid mask pattern");const r=e.getBits()<<3|t;n.appendBits(r,5);const i=q.calculateBCHCode(r,q.TYPE_INFO_POLY);n.appendBits(i,10);const s=new ce;if(s.appendBits(q.TYPE_INFO_MASK_PATTERN,15),n.xor(s),n.getSize()!==15)throw new me("should not happen but we got: "+n.getSize())}static makeVersionInfoBits(e,t){t.appendBits(e.getVersionNumber(),6);const n=q.calculateBCHCode(e.getVersionNumber(),q.VERSION_INFO_POLY);if(t.appendBits(n,12),t.getSize()!==18)throw new me("should not happen but we got: "+t.getSize())}static isEmpty(e){return e===255}static embedTimingPatterns(e){for(let t=8;t<e.getWidth()-8;++t){const n=(t+1)%2;q.isEmpty(e.get(t,6))&&e.setNumber(t,6,n),q.isEmpty(e.get(6,t))&&e.setNumber(6,t,n)}}static embedDarkDotAtLeftBottomCorner(e){if(e.get(8,e.getHeight()-8)===0)throw new me;e.setNumber(8,e.getHeight()-8,1)}static embedHorizontalSeparationPattern(e,t,n){for(let r=0;r<8;++r){if(!q.isEmpty(n.get(e+r,t)))throw new me;n.setNumber(e+r,t,0)}}static embedVerticalSeparationPattern(e,t,n){for(let r=0;r<7;++r){if(!q.isEmpty(n.get(e,t+r)))throw new me;n.setNumber(e,t+r,0)}}static embedPositionAdjustmentPattern(e,t,n){for(let r=0;r<5;++r){const i=q.POSITION_ADJUSTMENT_PATTERN[r];for(let s=0;s<5;++s)n.setNumber(e+s,t+r,i[s])}}static embedPositionDetectionPattern(e,t,n){for(let r=0;r<7;++r){const i=q.POSITION_DETECTION_PATTERN[r];for(let s=0;s<7;++s)n.setNumber(e+s,t+r,i[s])}}static embedPositionDetectionPatternsAndSeparators(e){const t=q.POSITION_DETECTION_PATTERN[0].length;q.embedPositionDetectionPattern(0,0,e),q.embedPositionDetectionPattern(e.getWidth()-t,0,e),q.embedPositionDetectionPattern(0,e.getWidth()-t,e);const n=8;q.embedHorizontalSeparationPattern(0,n-1,e),q.embedHorizontalSeparationPattern(e.getWidth()-n,n-1,e),q.embedHorizontalSeparationPattern(0,e.getWidth()-n,e);const r=7;q.embedVerticalSeparationPattern(r,0,e),q.embedVerticalSeparationPattern(e.getHeight()-r-1,0,e),q.embedVerticalSeparationPattern(r,e.getHeight()-r,e)}static maybeEmbedPositionAdjustmentPatterns(e,t){if(e.getVersionNumber()<2)return;const n=e.getVersionNumber()-1,r=q.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[n];for(let i=0,s=r.length;i!==s;i++){const a=r[i];if(a>=0)for(let o=0;o!==s;o++){const l=r[o];l>=0&&q.isEmpty(t.get(l,a))&&q.embedPositionAdjustmentPattern(l-2,a-2,t)}}}}q.POSITION_DETECTION_PATTERN=Array.from([Int32Array.from([1,1,1,1,1,1,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,1,1,1,0,1]),Int32Array.from([1,0,0,0,0,0,1]),Int32Array.from([1,1,1,1,1,1,1])]),q.POSITION_ADJUSTMENT_PATTERN=Array.from([Int32Array.from([1,1,1,1,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,0,1,0,1]),Int32Array.from([1,0,0,0,1]),Int32Array.from([1,1,1,1,1])]),q.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE=Array.from([Int32Array.from([-1,-1,-1,-1,-1,-1,-1]),Int32Array.from([6,18,-1,-1,-1,-1,-1]),Int32Array.from([6,22,-1,-1,-1,-1,-1]),Int32Array.from([6,26,-1,-1,-1,-1,-1]),Int32Array.from([6,30,-1,-1,-1,-1,-1]),Int32Array.from([6,34,-1,-1,-1,-1,-1]),Int32Array.from([6,22,38,-1,-1,-1,-1]),Int32Array.from([6,24,42,-1,-1,-1,-1]),Int32Array.from([6,26,46,-1,-1,-1,-1]),Int32Array.from([6,28,50,-1,-1,-1,-1]),Int32Array.from([6,30,54,-1,-1,-1,-1]),Int32Array.from([6,32,58,-1,-1,-1,-1]),Int32Array.from([6,34,62,-1,-1,-1,-1]),Int32Array.from([6,26,46,66,-1,-1,-1]),Int32Array.from([6,26,48,70,-1,-1,-1]),Int32Array.from([6,26,50,74,-1,-1,-1]),Int32Array.from([6,30,54,78,-1,-1,-1]),Int32Array.from([6,30,56,82,-1,-1,-1]),Int32Array.from([6,30,58,86,-1,-1,-1]),Int32Array.from([6,34,62,90,-1,-1,-1]),Int32Array.from([6,28,50,72,94,-1,-1]),Int32Array.from([6,26,50,74,98,-1,-1]),Int32Array.from([6,30,54,78,102,-1,-1]),Int32Array.from([6,28,54,80,106,-1,-1]),Int32Array.from([6,32,58,84,110,-1,-1]),Int32Array.from([6,30,58,86,114,-1,-1]),Int32Array.from([6,34,62,90,118,-1,-1]),Int32Array.from([6,26,50,74,98,122,-1]),Int32Array.from([6,30,54,78,102,126,-1]),Int32Array.from([6,26,52,78,104,130,-1]),Int32Array.from([6,30,56,82,108,134,-1]),Int32Array.from([6,34,60,86,112,138,-1]),Int32Array.from([6,30,58,86,114,142,-1]),Int32Array.from([6,34,62,90,118,146,-1]),Int32Array.from([6,30,54,78,102,126,150]),Int32Array.from([6,24,50,76,102,128,154]),Int32Array.from([6,28,54,80,106,132,158]),Int32Array.from([6,32,58,84,110,136,162]),Int32Array.from([6,26,54,82,110,138,166]),Int32Array.from([6,30,58,86,114,142,170])]),q.TYPE_INFO_COORDINATES=Array.from([Int32Array.from([8,0]),Int32Array.from([8,1]),Int32Array.from([8,2]),Int32Array.from([8,3]),Int32Array.from([8,4]),Int32Array.from([8,5]),Int32Array.from([8,7]),Int32Array.from([8,8]),Int32Array.from([7,8]),Int32Array.from([5,8]),Int32Array.from([4,8]),Int32Array.from([3,8]),Int32Array.from([2,8]),Int32Array.from([1,8]),Int32Array.from([0,8])]),q.VERSION_INFO_POLY=7973,q.TYPE_INFO_POLY=1335,q.TYPE_INFO_MASK_PATTERN=21522;class Ci{constructor(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Te{constructor(){}
18static calculateMaskPenalty(e){return De.applyMaskPenaltyRule1(e)+De.applyMaskPenaltyRule2(e)+De.applyMaskPenaltyRule3(e)+De.applyMaskPenaltyRule4(e)}static encode(e,t,n=null){let r=Te.DEFAULT_BYTE_MODE_ENCODING;const i=n!==null&&n.get(ke.CHARACTER_SET)!==void 0;i&&(r=n.get(ke.CHARACTER_SET).toString());const s=this.chooseMode(e,r),a=new ce;if(s===z.BYTE&&(i||Te.DEFAULT_BYTE_MODE_ENCODING!==r)){const k=U.getCharacterSetECIByName(r);k!==void 0&&this.appendECI(k,a)}this.appendModeInfo(s,a);const o=new ce;this.appendBytes(e,s,o,r);let l;if(n!==null&&n.get(ke.QR_VERSION)!==void 0){const k=Number.parseInt(n.get(ke.QR_VERSION).toString(),10);l=Y.getVersionForNumber(k);const v=this.calculateBitsNeeded(s,a,o,l);if(!this.willFit(v,l,t))throw new me("Data too big for requested version")}else l=this.recommendVersion(t,s,a,o);const c=new ce;c.appendBitArray(a);const f=s===z.BYTE?o.getSizeInBytes():e.length;this.appendLengthInfo(f,l,s,c),c.appendBitArray(o);const d=l.getECBlocksForLevel(t),C=l.getTotalCodewords()-d.getTotalECCodewords();this.terminateBits(C,c);const p=this.interleaveWithECBytes(c,l.getTotalCodewords(),C,d.getNumBlocks()),b=new Ht;b.setECLevel(t),b.setMode(s),b.setVersion(l);const y=l.getDimensionForVersion(),N=new _n(y,y),F=this.chooseMaskPattern(p,t,l,N);return b.setMaskPattern(F),q.buildMatrix(p,t,l,F,N),b.setMatrix(N),b}static recommendVersion(e,t,n,r){const i=this.calculateBitsNeeded(t,n,r,Y.getVersionForNumber(1)),s=this.chooseVersion(i,e),a=this.calculateBitsNeeded(t,n,r,s);return this.chooseVersion(a,e)}static calculateBitsNeeded(e,t,n,r){return t.getSize()+e.getCharacterCountBits(r)+n.getSize()}static getAlphanumericCode(e){return e<Te.ALPHANUMERIC_TABLE.length?Te.ALPHANUMERIC_TABLE[e]:-1}static chooseMode(e,t=null){if(U.SJIS.getName()===t&&this.isOnlyDoubleByteKanji(e))return z.KANJI;let n=!1,r=!1;for(let i=0,s=e.length;i<s;++i){const a=e.charAt(i);if(Te.isDigit(a))n=!0;else if(this.getAlphanumericCode(a.charCodeAt(0))!==-1)r=!0;else return z.BYTE}return r?z.ALPHANUMERIC:n?z.NUMERIC:z.BYTE}static isOnlyDoubleByteKanji(e){let t;try{t=et.encode(e,U.SJIS)}catch{return!1}const n=t.length;if(n%2!==0)return!1;for(let r=0;r<n;r+=2){const i=t[r]&255;if((i<129||i>159)&&(i<224||i>235))return!1}return!0}static chooseMaskPattern(e,t,n,r){let i=Number.MAX_SAFE_INTEGER,s=-1;for(let a=0;a<Ht.NUM_MASK_PATTERNS;a++){q.buildMatrix(e,t,n,a,r);let o=this.calculateMaskPenalty(r);o<i&&(i=o,s=a)}return s}static chooseVersion(e,t){for(let n=1;n<=40;n++){const r=Y.getVersionForNumber(n);if(Te.willFit(e,r,t))return r}throw new me("Data too big")}static willFit(e,t,n){const r=t.getTotalCodewords(),s=t.getECBlocksForLevel(n).getTotalECCodewords(),a=r-s,o=(e+7)/8;return a>=o}static terminateBits(e,t){const n=e*8;if(t.getSize()>n)throw new me("data bits cannot fit in the QR Code"+t.getSize()+" > "+n);for(let s=0;s<4&&t.getSize()<n;++s)t.appendBit(!1);const r=t.getSize()&7;if(r>0)for(let s=r;s<8;s++)t.appendBit(!1);const i=e-t.getSizeInBytes();for(let s=0;s<i;++s)t.appendBits((s&1)===0?236:17,8);if(t.getSize()!==n)throw new me("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(e,t,n,r,i,s){if(r>=n)throw new me("Block ID too large");const a=e%n,o=n-a,l=Math.floor(e/n),c=l+1,f=Math.floor(t/n),d=f+1,C=l-f,p=c-d;if(C!==p)throw new me("EC bytes mismatch");if(n!==o+a)throw new me("RS blocks mismatch");if(e!==(f+C)*o+(d+p)*a)throw new me("Total bytes mismatch");r<o?(i[0]=f,s[0]=C):(i[0]=d,s[0]=p)}static interleaveWithECBytes(e,t,n,r){if(e.getSizeInBytes()!==n)throw new me("Number of bits and data bytes does not match");let i=0,s=0,a=0;const o=new Array;for(let c=0;c<r;++c){const f=new Int32Array(1),d=new Int32Array(1);Te.getNumDataBytesAndNumECBytesForBlockID(t,n,r,c,f,d);const C=f[0],p=new Uint8Array(C);e.toBytes(8*i,p,0,C);const b=Te.generateECBytes(p,d[0]);o.push(new Ci(p,b)),s=Math.max(s,C),a=Math.max(a,b.length),i+=f[0]}if(n!==i)throw new me("Data bytes does not match offset");const l=new ce;for(let c=0;c<s;++c)for(const f of o){const d=f.getDataBytes();c<d.length&&l.appendBits(d[c],8)}for(let c=0;c<a;++c)for(const f of o){const d=f.getErrorCorrectionBytes();
18c<d.length&&l.appendBits(d[c],8)}if(t!==l.getSizeInBytes())throw new me("Interleaving error: "+t+" and "+l.getSizeInBytes()+" differ.");return l}static generateECBytes(e,t){const n=e.length,r=new Int32Array(n+t);for(let s=0;s<n;s++)r[s]=e[s]&255;new Jn(he.QR_CODE_FIELD_256).encode(r,t);const i=new Uint8Array(t);for(let s=0;s<t;s++)i[s]=r[n+s];return i}static appendModeInfo(e,t){t.appendBits(e.getBits(),4)}static appendLengthInfo(e,t,n,r){const i=n.getCharacterCountBits(t);if(e>=1<<i)throw new me(e+" is bigger than "+((1<<i)-1));r.appendBits(e,i)}static appendBytes(e,t,n,r){switch(t){case z.NUMERIC:Te.appendNumericBytes(e,n);break;case z.ALPHANUMERIC:Te.appendAlphanumericBytes(e,n);break;case z.BYTE:Te.append8BitBytes(e,n,r);break;case z.KANJI:Te.appendKanjiBytes(e,n);break;default:throw new me("Invalid mode: "+t)}}static getDigit(e){return e.charCodeAt(0)-48}static isDigit(e){const t=Te.getDigit(e);return t>=0&&t<=9}static appendNumericBytes(e,t){const n=e.length;let r=0;for(;r<n;){const i=Te.getDigit(e.charAt(r));if(r+2<n){const s=Te.getDigit(e.charAt(r+1)),a=Te.getDigit(e.charAt(r+2));t.appendBits(i*100+s*10+a,10),r+=3}else if(r+1<n){const s=Te.getDigit(e.charAt(r+1));t.appendBits(i*10+s,7),r+=2}else t.appendBits(i,4),r++}}static appendAlphanumericBytes(e,t){const n=e.length;let r=0;for(;r<n;){const i=Te.getAlphanumericCode(e.charCodeAt(r));if(i===-1)throw new me;if(r+1<n){const s=Te.getAlphanumericCode(e.charCodeAt(r+1));if(s===-1)throw new me;t.appendBits(i*45+s,11),r+=2}else t.appendBits(i,6),r++}}static append8BitBytes(e,t,n){let r;try{r=et.encode(e,n)}catch(i){throw new me(i)}for(let i=0,s=r.length;i!==s;i++){const a=r[i];t.appendBits(a,8)}}static appendKanjiBytes(e,t){let n;try{n=et.encode(e,U.SJIS)}catch(i){throw new me(i)}const r=n.length;for(let i=0;i<r;i+=2){const s=n[i]&255,a=n[i+1]&255,o=s<<8&4294967295|a;let l=-1;if(o>=33088&&o<=40956?l=o-33088:o>=57408&&o<=60351&&(l=o-49472),l===-1)throw new me("Invalid byte sequence");const c=(l>>8)*192+(l&255);t.appendBits(c,13)}}static appendECI(e,t){t.appendBits(z.ECI.getBits(),4),t.appendBits(e.getValue(),8)}}Te.ALPHANUMERIC_TABLE=Int32Array.from([-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,36,-1,-1,-1,37,38,-1,-1,-1,-1,39,40,-1,41,42,43,0,1,2,3,4,5,6,7,8,9,44,-1,-1,-1,-1,-1,-1,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,-1,-1,-1,-1,-1]),Te.DEFAULT_BYTE_MODE_ENCODING=U.UTF8.getName();class Wt{write(e,t,n,r=null){if(e.length===0)throw new O("Found empty contents");if(t<0||n<0)throw new O("Requested dimensions are too small: "+t+"x"+n);let i=ye.L,s=Wt.QUIET_ZONE_SIZE;r!==null&&(r.get(ke.ERROR_CORRECTION)!==void 0&&(i=ye.fromString(r.get(ke.ERROR_CORRECTION).toString())),r.get(ke.MARGIN)!==void 0&&(s=Number.parseInt(r.get(ke.MARGIN).toString(),10)));const a=Te.encode(e,i,r);return this.renderResult(a,t,n,s)}writeToDom(e,t,n,r,i=null){typeof e=="string"&&(e=document.querySelector(e));const s=this.write(t,n,r,i);e&&e.appendChild(s)}renderResult(e,t,n,r){const i=e.getMatrix();if(i===null)throw new Ct;const s=i.getWidth(),a=i.getHeight(),o=s+r*2,l=a+r*2,c=Math.max(t,o),f=Math.max(n,l),d=Math.min(Math.floor(c/o),Math.floor(f/l)),C=Math.floor((c-s*d)/2),p=Math.floor((f-a*d)/2),b=this.createSVGElement(c,f);for(let y=0,N=p;y<a;y++,N+=d)for(let F=0,k=C;F<s;F++,k+=d)if(i.get(F,y)===1){const v=this.createSvgRectElement(k,N,d,d);b.appendChild(v)}return b}createSVGElement(e,t){const n=document.createElementNS(Wt.SVG_NS,"svg");return n.setAttributeNS(null,"height",e.toString()),n.setAttributeNS(null,"width",t.toString()),n}createSvgRectElement(e,t,n,r){const i=document.createElementNS(Wt.SVG_NS,"rect");return i.setAttributeNS(null,"x",e.toString()),i.setAttributeNS(null,"y",t.toString()),i.setAttributeNS(null,"height",n.toString()),i.setAttributeNS(null,"width",r.toString()),i.setAttributeNS(null,"fill","#000000"),i}}Wt.QUIET_ZONE_SIZE=4,Wt.SVG_NS="http://www.w3.org/2000/svg";class Qt{encode(e,t,n,r,i){if(e.length===0)throw new O("Found empty contents");if(t!==K.QR_CODE)throw new O("Can only encode QR_CODE, but got "+t);if(n<0||r<0)throw new O(`Requested dimensions are too small: ${n}x${r}`);let s=ye.L,a=Qt.QUIET_ZONE_SIZE;i!==null&&(i.get(ke.ERROR_CORRECTION)!==void 0&&(s=ye.fromString(i.get(ke.ERROR_CORRECTION).toString())),i.get(ke.MARGIN)!==void 0&&(a=Number.parseInt(i.get(ke.MARGIN).toString(),10)));const o=Te.encode(e,s,i);return Qt.renderResult(o,n,r,a)}static renderResult(e,t,n,r){const i=e.getMatrix();if(i===null)throw new Ct;const s=i.getWidth(),a=i.getHeight(),o=s+r*2,l=a+r*2,c=Math.max(t,o),f=Math.max(n,l),d=Math.min(Math.floor(c/o),Math.floor(f/l)),C=Math.floor((c-s*d)/2),p=Math.floor((f-a*d)/2),b=new Ue(c,f);for(let y=0,N=p;y<a;y++,N+=d)for(let F=0,k=C;F<s;F++,k+=d)i.get(F,y)===1&&b.setRegion(k,N,d,d);return b}}Qt.QUIET_ZONE_SIZE=4;class Ei{encode(e,t,n,r,i){let s;switch(t){case K.QR_CODE:s=new Qt;break;default:throw new O("No encoder available for format "+t)}return s.encode(e,t,n,r,i)}}class It extends rn{constructor(e,t,n,r,i,s,a,o){if(super(s,a),this.yuvData=e,this.dataWidth=t,this.dataHeight=n,this.left=r,this.top=i,r+s>t||i+a>n)throw new O("Crop rectangle does not fit within image data.");o&&this.reverseHorizontal(s,a)}getRow(e,t){if(e<0||e>=this.getHeight())throw new O("Requested row is outside the image: "+e);const n=this.getWidth();(t==null||t.length<n)&&(t=new Uint8ClampedArray(n));const r=(e+this.top)*this.dataWidth+this.left;return Z.arraycopy(this.yuvData,r,t,0,n),t}getMatrix(){const e=this.getWidth(),t=this.getHeight();if(e===this.dataWidth&&t===this.dataHeight)return this.yuvData;const n=e*t,r=new Uint8ClampedArray(n);let i=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return Z.arraycopy(this.yuvData,i,r,0,n),r;for(let s=0;s<t;s++){const a=s*e;Z.arraycopy(this.yuvData,i,r,a,e),i+=this.dataWidth}return r}isCropSupported(){return!0}crop(e,t,n,r){return new It(this.yuvData,this.dataWidth,this.dataHeight,this.left+e,this.top+t,n,r,!1)}renderThumbnail(){const e=this.getWidth()/It.THUMBNAIL_SCALE_FACTOR,t=this.getHeight()/It.THUMBNAIL_SCALE_FACTOR,n=new Int32Array(e*t),r=this.yuvData;let i=this.top*this.dataWidth+this.left;for(let s=0;s<t;s++){const a=s*e;for(let o=0;o<e;o++){const l=r[i+o*It.THUMBNAIL_SCALE_FACTOR]&255;n[a+o]=4278190080|l*65793}i+=this.dataWidth*It.THUMBNAIL_SCALE_FACTOR}return n}getThumbnailWidth(){return this.getWidth()/It.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/It.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(e,t){const n=this.yuvData;for(let r=0,i=this.top*this.dataWidth+this.left;r<t;r++,i+=this.dataWidth){const s=i+e/2;for(let a=i,o=i+e-1;a<s;a++,o--){const l=n[a];n[a]=n[o],n[o]=l}}}invert(){return new _t(this)}}It.THUMBNAIL_SCALE_FACTOR=2;class $n extends rn{constructor(e,t,n,r,i,s,a){if(super(t,n),this.dataWidth=r,this.dataHeight=i,this.left=s,this.top=a,e.BYTES_PER_ELEMENT===4){const o=t*n,l=new Uint8ClampedArray(o);for(let c=0;c<o;c++){const f=e[c],d=f>>16&255,C=f>>7&510,p=f&255;l[c]=(d+C+p)/4&255}this.luminances=l}else this.luminances=e;if(r===void 0&&(this.dataWidth=t),i===void 0&&(this.dataHeight=n),s===void 0&&(this.left=0),a===void 0&&(this.top=0),this.left+t>this.dataWidth||this.top+n>this.dataHeight)throw new O("Crop rectangle does not fit within image data.")}getRow(e,t){if(e<0||e>=this.getHeight())throw new O("Requested row is outside the image: "+e);const n=this.getWidth();(t==null||t.length<n)&&(t=new Uint8ClampedArray(n));const r=(e+this.top)*this.dataWidth+this.left;return Z.arraycopy(this.luminances,r,t,0,n),t}getMatrix(){const e=this.getWidth(),t=this.getHeight();if(e===this.dataWidth&&t===this.dataHeight)return this.luminances;const n=e*t,r=new Uint8ClampedArray(n);let i=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return Z.arraycopy(this.luminances,i,r,0,n),r;for(let s=0;s<t;s++){const a=s*e;Z.arraycopy(this.luminances,i,r,a,e),i+=this.dataWidth}return r}isCropSupported(){return!0}crop(e,t,n,r){return new $n(this.luminances,n,r,this.dataWidth,this.dataHeight,this.left+e,this.top+t)}invert(){return new _t(this)}}class Sr extends U{static forName(e){return this.getCharacterSetECIByName(e)}}class er{}er.ISO_8859_1=U.ISO8859_1;class Nr{isCompact(){return this.compact}setCompact(e){this.compact=e}getSize(){return this.size}setSize(e){this.size=e}getLayers(){return this.layers}setLayers(e){this.layers=e}
18getCodeWords(){return this.codeWords}setCodeWords(e){this.codeWords=e}getMatrix(){return this.matrix}setMatrix(e){this.matrix=e}}class _r{static singletonList(e){return[e]}static min(e,t){return e.sort(t)[0]}}class mi{constructor(e){this.previous=e}getPrevious(){return this.previous}}class Jt extends mi{constructor(e,t,n){super(e),this.value=t,this.bitCount=n}appendTo(e,t){e.appendBits(this.value,this.bitCount)}add(e,t){return new Jt(this,e,t)}addBinaryShift(e,t){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new Jt(this,e,t)}toString(){let e=this.value&(1<<this.bitCount)-1;return e|=1<<this.bitCount,"<"+J.toBinaryString(e|1<<this.bitCount).substring(1)+">"}}class tr extends Jt{constructor(e,t,n){super(e,0,0),this.binaryShiftStart=t,this.binaryShiftByteCount=n}appendTo(e,t){for(let n=0;n<this.binaryShiftByteCount;n++)(n===0||n===31&&this.binaryShiftByteCount<=62)&&(e.appendBits(31,5),this.binaryShiftByteCount>62?e.appendBits(this.binaryShiftByteCount-31,16):n===0?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(t[this.binaryShiftStart+n],8)}addBinaryShift(e,t){return new tr(this,e,t)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function pi(u,e,t){return new tr(u,e,t)}function gn(u,e,t){return new Jt(u,e,t)}const Ii=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Lt=0,Rn=1,dt=2,Rr=3,bt=4,bi=new Jt(null,0,0),nr=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function yi(u){for(let e of u)Ie.fill(e,-1);return u[Lt][bt]=0,u[Rn][bt]=0,u[Rn][Lt]=28,u[Rr][bt]=0,u[dt][bt]=0,u[dt][Lt]=15,u}const Or=yi(Ie.createInt32Array(6,6));class yt{constructor(e,t,n,r){this.token=e,this.mode=t,this.binaryShiftByteCount=n,this.bitCount=r}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,t){let n=this.bitCount,r=this.token;if(e!==this.mode){let s=nr[this.mode][e];r=gn(r,s&65535,s>>16),n+=s>>16}let i=e===dt?4:5;return r=gn(r,t,i),new yt(r,e,0,n+i)}shiftAndAppend(e,t){let n=this.token,r=this.mode===dt?4:5;return n=gn(n,Or[this.mode][e],r),n=gn(n,t,5),new yt(n,this.mode,0,this.bitCount+r+5)}addBinaryShiftChar(e){let t=this.token,n=this.mode,r=this.bitCount;if(this.mode===bt||this.mode===dt){let a=nr[n][Lt];t=gn(t,a&65535,a>>16),r+=a>>16,n=Lt}let i=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,s=new yt(t,n,this.binaryShiftByteCount+1,r+i);return s.binaryShiftByteCount===2078&&(s=s.endBinaryShift(e+1)),s}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let t=this.token;return t=pi(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new yt(t,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let t=this.bitCount+(nr[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?t+=yt.calculateBinaryShiftCost(e)-yt.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount}toBitArray(e){let t=[];for(let r=this.endBinaryShift(e.length).token;r!==null;r=r.getPrevious())t.unshift(r);let n=new ce;for(const r of t)r.appendTo(n,e);return n}toString(){return $.format("%s bits=%d bytes=%d",Ii[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}yt.INITIAL_STATE=new yt(bi,Lt,0,0);function Ti(u){const e=$.getCharCode(" "),t=$.getCharCode("."),n=$.getCharCode(",");u[Lt][e]=1;const r=$.getCharCode("Z"),i=$.getCharCode("A");for(let d=i;d<=r;d++)u[Lt][d]=d-i+2;u[Rn][e]=1;const s=$.getCharCode("z"),a=$.getCharCode("a");for(let d=a;d<=s;d++)u[Rn][d]=d-a+2;u[dt][e]=1;const o=$.getCharCode("9"),l=$.getCharCode("0");for(let d=l;d<=o;d++)u[dt][d]=d-l+2;u[dt][n]=12,u[dt][t]=13;const c=["\0"," ","�","�","�","�","�","�","\x07","\b"," ",` 19`,"\v","\f","\r","\x1B","�","�","�","�","@","\\","^","_","`","|","~","�"];for(let d=0;d<c.length;
19d++)u[Rr][$.getCharCode(c[d])]=d;const f=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let d=0;d<f.length;d++)$.getCharCode(f[d])>0&&(u[bt][$.getCharCode(f[d])]=d);return u}const rr=Ti(Ie.createInt32Array(5,256));class wn{constructor(e){this.text=e}encode(){const e=$.getCharCode(" "),t=$.getCharCode(` 20`);let n=_r.singletonList(yt.INITIAL_STATE);for(let i=0;i<this.text.length;i++){let s,a=i+1<this.text.length?this.text[i+1]:0;switch(this.text[i]){case $.getCharCode("\r"):s=a===t?2:0;break;case $.getCharCode("."):s=a===e?3:0;break;case $.getCharCode(","):s=a===e?4:0;break;case $.getCharCode(":"):s=a===e?5:0;break;default:s=0}s>0?(n=wn.updateStateListForPair(n,i,s),i++):n=this.updateStateListForChar(n,i)}return _r.min(n,(i,s)=>i.getBitCount()-s.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,t){const n=[];for(let r of e)this.updateStateForChar(r,t,n);return wn.simplifyStates(n)}updateStateForChar(e,t,n){let r=this.text[t]&255,i=rr[e.getMode()][r]>0,s=null;for(let a=0;a<=bt;a++){let o=rr[a][r];if(o>0){if(s==null&&(s=e.endBinaryShift(t)),!i||a===e.getMode()||a===dt){const l=s.latchAndAppend(a,o);n.push(l)}if(!i&&Or[e.getMode()][a]>=0){const l=s.shiftAndAppend(a,o);n.push(l)}}}if(e.getBinaryShiftByteCount()>0||rr[e.getMode()][r]===0){let a=e.addBinaryShiftChar(t);n.push(a)}}static updateStateListForPair(e,t,n){const r=[];for(let i of e)this.updateStateForPair(i,t,n,r);return this.simplifyStates(r)}static updateStateForPair(e,t,n,r){let i=e.endBinaryShift(t);if(r.push(i.latchAndAppend(bt,n)),e.getMode()!==bt&&r.push(i.shiftAndAppend(bt,n)),n===3||n===4){let s=i.latchAndAppend(dt,16-n).latchAndAppend(dt,1);r.push(s)}if(e.getBinaryShiftByteCount()>0){let s=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);r.push(s)}}static simplifyStates(e){let t=[];for(const n of e){let r=!0;for(const i of t){if(i.isBetterThanOrEqualTo(n)){r=!1;break}n.isBetterThanOrEqualTo(i)&&(t=t.filter(s=>s!==i))}r&&t.push(n)}return t}}class le{constructor(){}static encodeBytes(e){return le.encode(e,le.DEFAULT_EC_PERCENT,le.DEFAULT_AZTEC_LAYERS)}static encode(e,t,n){let r=new wn(e).encode(),i=J.truncDivision(r.getSize()*t,100)+11,s=r.getSize()+i,a,o,l,c,f;if(n!==le.DEFAULT_AZTEC_LAYERS){if(a=n<0,o=Math.abs(n),o>(a?le.MAX_NB_BITS_COMPACT:le.MAX_NB_BITS))throw new O($.format("Illegal value %s for layers",n));l=le.totalBitsInLayer(o,a),c=le.WORD_SIZE[o];let v=l-l%c;if(f=le.stuffBits(r,c),f.getSize()+i>v)throw new O("Data to large for user specified layer");if(a&&f.getSize()>c*64)throw new O("Data to large for user specified layer")}else{c=0,f=null;for(let v=0;;v++){if(v>le.MAX_NB_BITS)throw new O("Data too large for an Aztec code");if(a=v<=3,o=a?v+1:v,l=le.totalBitsInLayer(o,a),s>l)continue;(f==null||c!==le.WORD_SIZE[o])&&(c=le.WORD_SIZE[o],f=le.stuffBits(r,c));let ie=l-l%c;if(!(a&&f.getSize()>c*64)&&f.getSize()+i<=ie)break}}let d=le.generateCheckWords(f,l,c),C=f.getSize()/c,p=le.generateModeMessage(a,o,C),b=(a?11:14)+o*4,y=new Int32Array(b),N;if(a){N=b;for(let v=0;v<y.length;v++)y[v]=v}else{N=b+1+2*J.truncDivision(J.truncDivision(b,2)-1,15);let v=J.truncDivision(b,2),ie=J.truncDivision(N,2);for(let ee=0;ee<v;ee++){let st=ee+J.truncDivision(ee,15);y[v-ee-1]=ie-st-1,y[v+ee]=ie+st+1}}let F=new Ue(N);for(let v=0,ie=0;v<o;v++){let ee=(o-v)*4+(a?9:12);for(let st=0;st<ee;st++){let wt=st*2;for(let at=0;at<2;at++)d.get(ie+wt+at)&&F.set(y[v*2+at],y[v*2+st]),d.get(ie+ee*2+wt+at)&&F.set(y[v*2+st],y[b-1-v*2-at]),d.get(ie+ee*4+wt+at)&&F.set(y[b-1-v*2-at],y[b-1-v*2-st]),d.get(ie+ee*6+wt+at)&&F.set(y[b-1-v*2-st],y[v*2+at])}ie+=ee*8}if(le.drawModeMessage(F,a,N,p),a)le.drawBullsEye(F,J.truncDivision(N,2),5);else{le.drawBullsEye(F,J.truncDivision(N,2),7);for(let v=0,ie=0;v<J.truncDivision(b,2)-1;v+=15,ie+=16)for(let ee=J.truncDivision(N,2)&1;ee<N;ee+=2)F.set(J.truncDivision(N,2)-ie,ee),F.set(J.truncDivision(N,2)+ie,ee),F.set(ee,J.truncDivision(N,2)-ie),F.set(ee,J.truncDivision(N,2)+ie)}let k=new Nr;return k.setCompact(a),k.setSize(N),k.setLayers(o),k.setCodeWords(C),k.setMatrix(F),k}static drawBullsEye(e,t,n){for(let r=0;r<n;r+=2)for(let i=t-r;i<=t+r;i++)e.set(i,t-r),e.set(i,t+r),e.set(t-r,i),e.set(t+r,i);e.set(t-n,t-n),e.set(t-n+1,t-n),e.set(t-n,t-n+1),e.set(t+n,t-n),e.set(t+n,t-n+1),e.set(t+n,t+n-1)}static generateModeMessage(e,t,n){let r=new ce;return e?(r.appendBits(t-1,2),r.appendBits(n-1,6),r=le.generateCheckWords(r,28,4)):(r.appendBits(t-1,5),r.appendBits(n-1,11),r=le.generateCheckWords(r,40,4)),r}static drawModeMessage(e,t,n,r){let i=J.truncDivision(n,2);if(t)for(let s=0;s<7;s++){let a=i-3+s;r.get(s)&&e.set(a,i-5),r.get(s+7)&&e.set(i+5,a),r.get(20-s)&&e.set(a,i+5),r.get(27-s)&&e.set(i-5,a)}else for(let s=0;s<10;s++){let a=i-5+s+J.truncDivision(s,5);r.get(s)&&e.set(a,i-7),r.get(s+10)&&e.set(i+7,a),r.get(29-s)&&e.set(a,i+7),r.get(39-s)&&e.set(i-7,a)}}static generateCheckWords(e,t,n){let r=e.getSize()/n,i=new Jn(le.getGF(n)),s=J.truncDivision(t,n),a=le.bitsToWords(e,n,s);i.encode(a,s-r);let o=t%n,l=new ce;l.appendBits(0,o);for(const c of Array.from(a))l.appendBits(c,n);return l}static bitsToWords(e,t,n){let r=new Int32Array(n),i,s;for(i=0,s=e.getSize()/t;i<s;i++){let a=0;for(let o=0;o<t;o++)a|=e.get(i*t+o)?1<<t-o-1:0;r[i]=a}return r}static getGF(e){switch(e){case 4:return he.AZTEC_PARAM;case 6:return he.AZTEC_DATA_6;case 8:return he.AZTEC_DATA_8;case 10:return he.AZTEC_DATA_10;case 12:return he.AZTEC_DATA_12;default:throw new O("Unsupported word size "+e)}}static stuffBits(e,t){let n=new ce,r=e.getSize(),i=(1<<t)-2;for(let s=0;s<r;s+=t){let a=0;for(let o=0;o<t;o++)(s+o>=r||e.get(s+o))&&(a|=1<<t-1-o);(a&i)===i?(n.appendBits(a&i,t),s--):(a&i)===0?(n.appendBits(a|1,t),s--):n.appendBits(a,t)}return n}static totalBitsInLayer(e,t){return((t?88:112)+16*e)*e}}le.DEFAULT_EC_PERCENT=33,le.DEFAULT_AZTEC_LAYERS=0,le.MAX_NB_BITS=32,le.MAX_NB_BITS_COMPACT=4,le.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class On{encode(e,t,n,r){return this.encodeWithHints(e,t,n,r,null)}encodeWithHints(e,t,n,r,i){let s=er.ISO_8859_1,a=le.DEFAULT_EC_PERCENT,o=le.DEFAULT_AZTEC_LAYERS;return i!=null&&(i.has(ke.CHARACTER_SET)&&(s=Sr.forName(i.get(ke.CHARACTER_SET).toString())),i.has(ke.ERROR_CORRECTION)&&(a=J.parseInt(i.get(ke.ERROR_CORRECTION).toString())),i.has(ke.AZTEC_LAYERS)&&(o=J.parseInt(i.get(ke.AZTEC_LAYERS).toString()))),On.encodeLayers(e,t,n,r,s,a,o)}static encodeLayers(e,t,n,r,i,s,a){if(t!==K.AZTEC)throw new O("C
20an only encode AZTEC, but got "+t);let o=le.encode($.getBytes(e,i),s,a);return On.renderResult(o,n,r)}static renderResult(e,t,n){let r=e.getMatrix();if(r==null)throw new Ct;let i=r.getWidth(),s=r.getHeight(),a=Math.max(t,i),o=Math.max(n,s),l=Math.min(a/i,o/s),c=(a-i*l)/2,f=(o-s*l)/2,d=new Ue(a,o);for(let C=0,p=f;C<s;C++,p+=l)for(let b=0,y=c;b<i;b++,y+=l)r.get(b,C)&&d.setRegion(y,p,l,l);return d}}h.AbstractExpandedDecoder=Hn,h.ArgumentException=P,h.ArithmeticException=Cn,h.AztecCode=Nr,h.AztecCodeReader=pn,h.AztecCodeWriter=On,h.AztecDecoder=be,h.AztecDetector=dr,h.AztecDetectorResult=ur,h.AztecEncoder=le,h.AztecHighLevelEncoder=wn,h.AztecPoint=Je,h.BarcodeFormat=K,h.Binarizer=xe,h.BinaryBitmap=ae,h.BitArray=ce,h.BitMatrix=Ue,h.BitSource=Yn,h.BrowserAztecCodeReader=Qr,h.BrowserBarcodeReader=ni,h.BrowserCodeReader=Ft,h.BrowserDatamatrixCodeReader=ii,h.BrowserMultiFormatReader=gi,h.BrowserPDF417Reader=wi,h.BrowserQRCodeReader=Ai,h.BrowserQRCodeSvgWriter=Wt,h.CharacterSetECI=U,h.ChecksumException=j,h.Code128Reader=G,h.Code39Reader=Le,h.DataMatrixDecodedBitStreamParser=Mt,h.DataMatrixReader=Bt,h.DecodeHintType=we,h.DecoderResult=sn,h.DefaultGridSampler=fr,h.DetectorResult=mn,h.EAN13Reader=kt,h.EncodeHintType=ke,h.Exception=m,h.FormatException=V,h.GenericGF=he,h.GenericGFPoly=tt,h.GlobalHistogramBinarizer=Ve,h.GridSampler=kn,h.GridSamplerInstance=Ot,h.HTMLCanvasElementLuminanceSource=Rt,h.HybridBinarizer=te,h.ITFReader=Ee,h.IllegalArgumentException=O,h.IllegalStateException=Ct,h.InvertedLuminanceSource=_t,h.LuminanceSource=rn,h.MathUtils=oe,h.MultiFormatOneDReader=Kt,h.MultiFormatReader=Tr,h.MultiFormatWriter=Ei,h.NotFoundException=R,h.OneDReader=Pe,h.PDF417DecodedBitStreamParser=S,h.PDF417DecoderErrorCorrection=Er,h.PDF417Reader=Ye,h.PDF417ResultMetadata=pr,h.PerspectiveTransform=xt,h.PlanarYUVLuminanceSource=It,h.QRCodeByteMatrix=_n,h.QRCodeDataMask=ut,h.QRCodeDecodedBitStreamParser=_e,h.QRCodeDecoderErrorCorrectionLevel=ye,h.QRCodeDecoderFormatInformation=Ke,h.QRCodeEncoder=Te,h.QRCodeEncoderQRCode=Ht,h.QRCodeMaskUtil=De,h.QRCodeMatrixUtil=q,h.QRCodeMode=z,h.QRCodeReader=vt,h.QRCodeVersion=Y,h.QRCodeWriter=Qt,h.RGBLuminanceSource=$n,h.RSS14Reader=Oe,h.RSSExpandedReader=M,h.ReaderException=Nn,h.ReedSolomonDecoder=on,h.ReedSolomonEncoder=Jn,h.ReedSolomonException=jt,h.Result=Qe,h.ResultMetadataType=Ge,h.ResultPoint=X,h.StringUtils=$,h.UnsupportedOperationException=Xt,h.VideoInputDevice=hr,h.WhiteRectangleDetector=Tt,h.WriterException=me,h.ZXingArrays=Ie,h.ZXingCharset=Sr,h.ZXingInteger=J,h.ZXingStandardCharsets=er,h.ZXingStringBuilder=Ae,h.ZXingStringEncoding=et,h.ZXingSystem=Z,h.createAbstractExpandedDecoder=Ar,Object.defineProperty(h,"__esModule",{value:!0})}))})(An,An.exports)),An.exports}var Se=Qi();const Ji=_i(Se),$i=ji({__proto__:null,default:Ji},[Se]);var Vr=(function(){function w(x,h,E){if(this.formatMap=new Map([[W.QR_CODE,Se.BarcodeFormat.QR_CODE],[W.AZTEC,Se.BarcodeFormat.AZTEC],[W.CODABAR,Se.BarcodeFormat.CODABAR],[W.CODE_39,Se.BarcodeFormat.CODE_39],[W.CODE_93,Se.BarcodeFormat.CODE_93],[W.CODE_128,Se.BarcodeFormat.CODE_128],[W.DATA_MATRIX,Se.BarcodeFormat.DATA_MATRIX],[W.MAXICODE,Se.BarcodeFormat.MAXICODE],[W.ITF,Se.BarcodeFormat.ITF],[W.EAN_13,Se.BarcodeFormat.EAN_13],[W.EAN_8,Se.BarcodeFormat.EAN_8],[W.PDF_417,Se.BarcodeFormat.PDF_417],[W.RSS_14,Se.BarcodeFormat.RSS_14],[W.RSS_EXPANDED,Se.BarcodeFormat.RSS_EXPANDED],[W.UPC_A,Se.BarcodeFormat.UPC_A],[W.UPC_E,Se.BarcodeFormat.UPC_E],[W.UPC_EAN_EXTENSION,Se.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!$i)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=h,this.logger=E;var I=this.createZXingFormats(x),g=new Map;g.set(Se.DecodeHintType.POSSIBLE_FORMATS,I),g.set(Se.DecodeHintType.TRY_HARDER,!1),this.hints=g}return w.prototype.decodeAsync=function(x){var h=this;return new Promise(function(E,I){try{E(h.decode(x))}catch(g){I(g)}})},w.prototype.decode=function(x){var h=new Se.MultiFormatReader(this.verbose,this.hints),E=new Se.HTMLCanvasElementLuminanceSource(x),I=new Se.BinaryBitmap(new Se.HybridBinarizer(E)),g=h.decode(I);return{text:g.text,format:Zr.create(this.toHtml5QrcodeSupportedFormats(g.format)),debugData:this.createDebugData()}},w.prototype.createReverseFormatMap=function(){var x=new Map;
20return this.formatMap.forEach(function(h,E,I){x.set(h,E)}),x},w.prototype.toHtml5QrcodeSupportedFormats=function(x){if(!this.reverseFormatMap.has(x))throw"reverseFormatMap doesn't have ".concat(x);return this.reverseFormatMap.get(x)},w.prototype.createZXingFormats=function(x){for(var h=[],E=0,I=x;E<I.length;E++){var g=I[E];this.formatMap.has(g)?h.push(this.formatMap.get(g)):this.logger.logError("".concat(g," is not supported by")+"ZXingHtml5QrcodeShim")}return h},w.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},w})(),es=function(w,x,h,E){function I(g){return g instanceof h?g:new h(function(_){_(g)})}return new(h||(h=Promise))(function(g,_){function B(P){try{m(E.next(P))}catch(O){_(O)}}function L(P){try{m(E.throw(P))}catch(O){_(O)}}function m(P){P.done?g(P.value):I(P.value).then(B,L)}m((E=E.apply(w,x||[])).next())})},ts=function(w,x){var h={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},E,I,g,_;return _={next:B(0),throw:B(1),return:B(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function B(m){return function(P){return L([m,P])}}function L(m){if(E)throw new TypeError("Generator is already executing.");for(;_&&(_=0,m[0]&&(h=0)),h;)try{if(E=1,I&&(g=m[0]&2?I.return:m[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,m[1])).done)return g;switch(I=0,g&&(m=[m[0]&2,g.value]),m[0]){case 0:case 1:g=m;break;case 4:return h.label++,{value:m[1],done:!1};case 5:h.label++,I=m[1],m=[0];continue;case 7:m=h.ops.pop(),h.trys.pop();continue;default:if(g=h.trys,!(g=g.length>0&&g[g.length-1])&&(m[0]===6||m[0]===2)){h=0;continue}if(m[0]===3&&(!g||m[1]>g[0]&&m[1]<g[3])){h.label=m[1];break}if(m[0]===6&&h.label<g[1]){h.label=g[1],g=m;break}if(g&&h.label<g[2]){h.label=g[2],h.ops.push(m);break}g[2]&&h.ops.pop(),h.trys.pop();continue}m=x.call(w,h)}catch(P){m=[6,P],I=0}finally{E=g=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},Gr=(function(){function w(x,h,E){if(this.formatMap=new Map([[W.QR_CODE,"qr_code"],[W.AZTEC,"aztec"],[W.CODABAR,"codabar"],[W.CODE_39,"code_39"],[W.CODE_93,"code_93"],[W.CODE_128,"code_128"],[W.DATA_MATRIX,"data_matrix"],[W.ITF,"itf"],[W.EAN_13,"ean_13"],[W.EAN_8,"ean_8"],[W.PDF_417,"pdf417"],[W.UPC_A,"upc_a"],[W.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!w.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=h,this.logger=E;var I=this.createBarcodeDetectorFormats(x);if(this.detector=new BarcodeDetector(I),!this.detector)throw"BarcodeDetector detector not supported"}return w.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var x=new BarcodeDetector({formats:["qr_code"]});return typeof x<"u"},w.prototype.decodeAsync=function(x){return es(this,void 0,void 0,function(){var h,E;return ts(this,function(I){switch(I.label){case 0:return[4,this.detector.detect(x)];case 1:if(h=I.sent(),!h||h.length===0)throw"No barcode or QR code detected.";return E=this.selectLargestBarcode(h),[2,{text:E.rawValue,format:Zr.create(this.toHtml5QrcodeSupportedFormats(E.format)),debugData:this.createDebugData()}]}})})},w.prototype.selectLargestBarcode=function(x){for(var h=null,E=0,I=0,g=x;I<g.length;I++){var _=g[I],B=_.boundingBox.width*_.boundingBox.height;B>E&&(E=B,h=_)}if(!h)throw"No largest barcode found";return h},w.prototype.createBarcodeDetectorFormats=function(x){for(var h=[],E=0,I=x;E<I.length;E++){var g=I[E];this.formatMap.has(g)?h.push(this.formatMap.get(g)):this.logger.warn("".concat(g," is not supported by")+"BarcodeDetectorDelegate")}return{formats:h}},w.prototype.toHtml5QrcodeSupportedFormats=function(x){if(!this.reverseFormatMap.has(x))throw"reverseFormatMap doesn't have ".concat(x);return this.reverseFormatMap.get(x)},w.prototype.createReverseFormatMap=function(){var x=new Map;return this.formatMap.forEach(function(h,E,I){x.set(h,E)}),x},w.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},w})(),Hr=function(w,x,h,E){function I(g){return g instanceof h?g:new h(function(_){_(g)})}return new(h||(h=Promise))(function(g,_){function B(P){try{m(E.next(P))}catch(O){_(O)}}function L(P){try{m(E.throw(P))}catch(O){_(O)}}function m(P){P.done?g(P.value):I(P.value).then(B,L)}m((E=E.apply(w,x||[])).next())})},Wr=function(w,x){var h={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]}
20,trys:[],ops:[]},E,I,g,_;return _={next:B(0),throw:B(1),return:B(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function B(m){return function(P){return L([m,P])}}function L(m){if(E)throw new TypeError("Generator is already executing.");for(;_&&(_=0,m[0]&&(h=0)),h;)try{if(E=1,I&&(g=m[0]&2?I.return:m[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,m[1])).done)return g;switch(I=0,g&&(m=[m[0]&2,g.value]),m[0]){case 0:case 1:g=m;break;case 4:return h.label++,{value:m[1],done:!1};case 5:h.label++,I=m[1],m=[0];continue;case 7:m=h.ops.pop(),h.trys.pop();continue;default:if(g=h.trys,!(g=g.length>0&&g[g.length-1])&&(m[0]===6||m[0]===2)){h=0;continue}if(m[0]===3&&(!g||m[1]>g[0]&&m[1]<g[3])){h.label=m[1];break}if(m[0]===6&&h.label<g[1]){h.label=g[1],g=m;break}if(g&&h.label<g[2]){h.label=g[2],h.ops.push(m);break}g[2]&&h.ops.pop(),h.trys.pop();continue}m=x.call(w,h)}catch(P){m=[6,P],I=0}finally{E=g=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},ns=(function(){function w(x,h,E,I){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=E,h&&Gr.isSupported()?(this.primaryDecoder=new Gr(x,E,I),this.secondaryDecoder=new Vr(x,E,I)):this.primaryDecoder=new Vr(x,E,I)}return w.prototype.decodeAsync=function(x){return Hr(this,void 0,void 0,function(){var h;return Wr(this,function(E){switch(E.label){case 0:h=performance.now(),E.label=1;case 1:return E.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(x)];case 2:return[2,E.sent()];case 3:return this.possiblyLogPerformance(h),[7];case 4:return[2]}})})},w.prototype.decodeRobustlyAsync=function(x){return Hr(this,void 0,void 0,function(){var h,E;return Wr(this,function(I){switch(I.label){case 0:h=performance.now(),I.label=1;case 1:return I.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(x)];case 2:return[2,I.sent()];case 3:if(E=I.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(x)];throw E;case 4:return this.possiblyLogPerformance(h),[7];case 5:return[2]}})})},w.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},w.prototype.possiblyLogPerformance=function(x){if(this.verbose){var h=performance.now()-x;this.executionResults.push(h),this.executions++,this.possiblyFlushPerformanceReport()}},w.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var x=0,h=0,E=this.executionResults;h<E.length;h++){var I=E[h];x+=I}var g=x/this.executionResults.length;console.log("".concat(g," ms for ").concat(this.executionResults.length," last runs.")),this.executions=0,this.executionResults=[]}},w})(),cr=(function(){var w=function(x,h){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,I){E.__proto__=I}||function(E,I){for(var g in I)Object.prototype.hasOwnProperty.call(I,g)&&(E[g]=I[g])},w(x,h)};return function(x,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");w(x,h);function E(){this.constructor=x}x.prototype=h===null?Object.create(h):(E.prototype=h.prototype,new E)}})(),vn=function(w,x,h,E){function I(g){return g instanceof h?g:new h(function(_){_(g)})}return new(h||(h=Promise))(function(g,_){function B(P){try{m(E.next(P))}catch(O){_(O)}}function L(P){try{m(E.throw(P))}catch(O){_(O)}}function m(P){P.done?g(P.value):I(P.value).then(B,L)}m((E=E.apply(w,x||[])).next())})},Pn=function(w,x){var h={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},E,I,g,_;return _={next:B(0),throw:B(1),return:B(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function B(m){return function(P){return L([m,P])}}function L(m){if(E)throw new TypeError("Generator is already executing.");for(;_&&(_=0,m[0]&&(h=0)),h;)try{if(E=1,I&&(g=m[0]&2?I.return:m[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,m[1])).done)return g;switch(I=0,g&&(m=[m[0]&2,g.value]),m[0]){case 0:case 1:g=m;break;case 4:return h.label++,{value:m[1],done:!1};case 5:h.label++,I=m[1],m=[0];continue;case 7:m=h.ops.pop(),h.trys.pop();continue;default:if(g=h.trys,!(g=g.length>0&&g[g.length-1])&&(m[0]===6||m[0]===2)){h=0;continue}if(m[0]===3&&(!g||m[1]>g[0]&&m[1]<g[3])){h.label=m[1];break}if(m[0]===6&&h.label<g[1]){h.label=g[1],g=m;break}if(g&&h.label<g[2]){h.label=g[2],h.ops.push(m);break}g[2]&&h.ops.pop(),h.trys.pop();continue}m=x.call(w,h)}catch(P){m=[6,P],I=0}finally{E=g=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},qr=(function(){function w(x,h){this.name=x,this.track=h}return w.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},w.prototype.apply=function(x){var h={};h[this.name]=x;var E={advanced:[h]};return this.track.applyConstraints(E)},w.prototype.value=function(){var x=this.track.getSettings();if(this.name in x){var h=x[this.name];return h}return null},w})(),rs=(function(w){cr(x,w);function x(h,E){return w.call(this,h,E)||this}return x.prototype.min=function(){return this.getCapabilities().min},x.prototype.max=function(){return this.getCapabilities().max},x.prototype.step=function(){return this.getCapabilities().step},x.prototype.apply=function(h){var E={};E[this.name]=h;var I={advanced:[E]};return this.track.applyConstraints(I)},x.prototype.getCapabilities=function(){this.failIfNotSupported();var h=this.track.getCapabilities(),E=h[this.name];return{min:E.min,max:E.max,step:E.step}},x.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},x})(qr),is=(function(w){cr(x,w);function x(h){return w.call(this,"zoom",h)||this}return x})(rs),ss=(function(w){cr(x,w);function x(h){return w.call(this,"torch",h)||this}return x})(qr),as=(function(){function w(x){this.track=x}return w.prototype.zoomFeature=function(){return new is(this.track)},w.prototype.torchFeature=function(){return new ss(this.track)},w})(),os=(function(){function w(x,h,E){this.isClosed=!1,this.parentElement=x,this.mediaStream=h,this.callbacks=E,this.surface=this.createVideoElement(this.parentElement.clientWidth),x.append(this.surface)}return w.prototype.createVideoElement=function(x){var h=document.createElement("video");return h.style.width="".concat(x,"px"),h.style.display="block",h.muted=!0,h.setAttribute("muted","true"),h.playsInl
20ine=!0,h},w.prototype.setupSurface=function(){var x=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var h=function(){var E=x.surface.clientWidth,I=x.surface.clientHeight;x.callbacks.onRenderSurfaceReady(E,I),x.surface.removeEventListener("playing",h)};this.surface.addEventListener("playing",h),this.surface.srcObject=this.mediaStream,this.surface.play()},w.create=function(x,h,E,I){return vn(this,void 0,void 0,function(){var g,_;return Pn(this,function(B){switch(B.label){case 0:return g=new w(x,h,I),E.aspectRatio?(_={aspectRatio:E.aspectRatio},[4,g.getFirstTrackOrFail().applyConstraints(_)]):[3,2];case 1:B.sent(),B.label=2;case 2:return g.setupSurface(),[2,g]}})})},w.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},w.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},w.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},w.prototype.resume=function(x){this.failIfClosed();var h=this,E=function(){setTimeout(x,200),h.surface.removeEventListener("playing",E)};this.surface.addEventListener("playing",E),this.surface.play()},w.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},w.prototype.getSurface=function(){return this.failIfClosed(),this.surface},w.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},w.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},w.prototype.applyVideoConstraints=function(x){return vn(this,void 0,void 0,function(){return Pn(this,function(h){if("aspectRatio"in x)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(x)]})})},w.prototype.close=function(){if(this.isClosed)return Promise.resolve();var x=this;return new Promise(function(h,E){var I=x.mediaStream.getVideoTracks(),g=I.length,_=0;x.mediaStream.getVideoTracks().forEach(function(B){x.mediaStream.removeTrack(B),B.stop(),++_,_>=g&&(x.isClosed=!0,x.parentElement.removeChild(x.surface),h())})})},w.prototype.getCapabilities=function(){return new as(this.getFirstTrackOrFail())},w})(),ls=(function(){function w(x){this.mediaStream=x}return w.prototype.render=function(x,h,E){return vn(this,void 0,void 0,function(){return Pn(this,function(I){return[2,os.create(x,this.mediaStream,h,E)]})})},w.create=function(x){return vn(this,void 0,void 0,function(){var h,E;return Pn(this,function(I){switch(I.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return h={audio:!1,video:x},[4,navigator.mediaDevices.getUserMedia(h)];case 1:return E=I.sent(),[2,new w(E)]}})})},w})(),Xr=function(w,x,h,E){function I(g){return g instanceof h?g:new h(function(_){_(g)})}return new(h||(h=Promise))(function(g,_){function B(P){try{m(E.next(P))}catch(O){_(O)}}function L(P){try{m(E.throw(P))}catch(O){_(O)}}function m(P){P.done?g(P.value):I(P.value).then(B,L)}m((E=E.apply(w,x||[])).next())})},jr=function(w,x){var h={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]},trys:[],ops:[]},E,I,g,_;return _={next:B(0),throw:B(1),return:B(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function B(m){return function(P){return L([m,P])}}function L(m){if(E)throw new TypeError("Generator is already executing.");for(;_&&(_=0,m[0]&&(h=0)),h;)try{if(E=1,I&&(g=m[0]&2?I.return:m[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,m[1])).done)return g;switch(I=0,g&&(m=[m[0]&2,g.value]),m[0]){case 0:case 1:g=m;break;case 4:return h.label++,{value:m[1],done:!1};case 5:h.label++,I=m[1],m=[0];continue;case 7:m=h.ops.pop(),h.trys.pop();continue;default:if(g=h.trys,!(g=g.length>0&&g[g.length-1])&&(m[0]===6||m[0]===2)){h=0;continue}if(m[0]===3&&(!g||m[1]>g[0]&&m[1]<g[3])){h.label=m[1];break}if(m[0]===6&&h.label<g[1]){h.label=g[1],g=m;break}if(g&&h.label<g[2]){h.label=g[2],h.ops.push(m);break}g[2]&&h.ops.pop(),h.trys.pop();continue}m=x.call(w,h)}catch(P){m=[6,P],I=0}finally{E=g=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},cs=(function(){function w(){}return w.failIfNotSupported=function(){return Xr(this,void 0,void 0,function(){return jr(this,function(x){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new w]})})},w.prototype.create=function(x){return Xr(this,void 0,void 0,function(){return jr(this,function(h){return[2,ls.create(x)]})})},w})(),hs=function(w,x,h,E){function I(g){return g instanceof h?g:new h(function(_){_(g)})}return new(h||(h=Promise))(function(g,_){function B(P){try{m(E.next(P))}catch(O){_(O)}}function L(P){try{m(E.throw(P))}catch(O){_(O)}}function m(P){P.done?g(P.value):I(P.value).then(B,L)}m((E=E.apply(w,x||[])).next())})},us=function(w,x){var h={label:0,sent:function(){if(g[0]&1)throw g[1];return g[1]}
20,trys:[],ops:[]},E,I,g,_;return _={next:B(0),throw:B(1),return:B(2)},typeof Symbol=="function"&&(_[Symbol.iterator]=function(){return this}),_;function B(m){return function(P){return L([m,P])}}function L(m){if(E)throw new TypeError("Generator is already executing.");for(;_&&(_=0,m[0]&&(h=0)),h;)try{if(E=1,I&&(g=m[0]&2?I.return:m[0]?I.throw||((g=I.return)&&g.call(I),0):I.next)&&!(g=g.call(I,m[1])).done)return g;switch(I=0,g&&(m=[m[0]&2,g.value]),m[0]){case 0:case 1:g=m;break;case 4:return h.label++,{value:m[1],done:!1};case 5:h.label++,I=m[1],m=[0];continue;case 7:m=h.ops.pop(),h.trys.pop();continue;default:if(g=h.trys,!(g=g.length>0&&g[g.length-1])&&(m[0]===6||m[0]===2)){h=0;continue}if(m[0]===3&&(!g||m[1]>g[0]&&m[1]<g[3])){h.label=m[1];break}if(m[0]===6&&h.label<g[1]){h.label=g[1],g=m;break}if(g&&h.label<g[2]){h.label=g[2],h.ops.push(m);break}g[2]&&h.ops.pop(),h.trys.pop();continue}m=x.call(w,h)}catch(P){m=[6,P],I=0}finally{E=g=0}if(m[0]&5)throw m[1];return{value:m[0]?m[1]:void 0,done:!0}}},fs=(function(){function w(){}return w.retrieve=function(){if(navigator.mediaDevices)return w.getCamerasFromMediaDevices();var x=MediaStreamTrack;return MediaStreamTrack&&x.getSources?w.getCamerasFromMediaStreamTrack():w.rejectWithError()},w.rejectWithError=function(){var x=nn.unableToQuerySupportedDevices();return w.isHttpsOrLocalhost()||(x=nn.insecureContextCameraQueryError()),Promise.reject(x)},w.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var x=location.host.split(":")[0];return x==="127.0.0.1"||x==="localhost"},w.getCamerasFromMediaDevices=function(){return hs(this,void 0,void 0,function(){var x,h,E,I,g,_,B;return us(this,function(L){switch(L.label){case 0:return x=function(m){for(var P=m.getVideoTracks(),O=0,ae=P;O<ae.length;O++){var j=ae[O];j.enabled=!1,j.stop(),m.removeTrack(j)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return h=L.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(E=L.sent(),I=[],g=0,_=E;g<_.length;g++)B=_[g],B.kind==="videoinput"&&I.push({id:B.deviceId,label:B.label});return x(h),[2,I]}})})},w.getCamerasFromMediaStreamTrack=function(){return new Promise(function(x,h){var E=function(g){for(var _=[],B=0,L=g;B<L.length;B++){var m=L[B];m.kind==="video"&&_.push({id:m.id,label:m.label})}x(_)},I=MediaStreamTrack;I.getSources(E)})},w})(),Me;(function(w){w[w.UNKNOWN=0]="UNKNOWN",w[w.NOT_STARTED=1]="NOT_STARTED",w[w.SCANNING=2]="SCANNING",w[w.PAUSED=3]="PAUSED"})(Me||(Me={}));var ds=(function(){function w(){this.state=Me.NOT_STARTED,this.onGoingTransactionNewState=Me.UNKNOWN}return w.prototype.directTransition=function(x){this.failIfTransitionOngoing(),this.validateTransition(x),this.state=x},w.prototype.startTransition=function(x){return this.failIfTransitionOngoing(),this.validateTransition(x),this.onGoingTransactionNewState=x,this},w.prototype.execute=function(){if(this.onGoingTransactionNewState===Me.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var x=this.onGoingTransactionNewState;this.onGoingTransactionNewState=Me.UNKNOWN,this.directTransition(x)},w.prototype.cancel=function(){if(this.onGoingTransactionNewState===Me.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=Me.UNKNOWN},w.prototype.getState=function(){return this.state},w.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==Me.UNKNOWN)throw"Cannot transition to a new state, already under transition"},w.prototype.validateTransition=function(x){switch(this.state){case Me.UNKNOWN:throw"Transition from unknown is not allowed";case Me.NOT_STARTED:this.failIfNewStateIs(x,[Me.PAUSED]);break;case Me.SCANNING:break;case Me.PAUSED:break}},w.prototype.failIfNewStateIs=function(x,h){for(var E=0,I=h;E<I.length;E++){var g=I[E];if(x===g)throw"Cannot transition from ".concat(this.state," to ").concat(x)}},w})(),xs=(function(){function w(x){this.stateManager=x}return w.prototype.startTransition=function(x){return this.stateManager.startTransition(x)},w.prototype.directTransition=function(x){this.stateManager.directTransition(x)},w.prototype.getState=function(){return this.stateManager.getState()},w.prototype.canScanFile=function(){return this.stateManager.getState()===Me.NOT_STARTED},w.prototype.isScanning=function(){return this.stateManager.getState()!==Me.NOT_STARTED},w.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===Me.SCANNING},w.prototype.isPaused=function(){return this.stateManager.getState()===Me.PAUSED},w})(),gs=(function(){function w(){}return w.create=function(){return new xs(new ds)},w}
20)(),ws=(function(){var w=function(x,h){return w=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,I){E.__proto__=I}||function(E,I){for(var g in I)Object.prototype.hasOwnProperty.call(I,g)&&(E[g]=I[g])},w(x,h)};return function(x,h){if(typeof h!="function"&&h!==null)throw new TypeError("Class extends value "+String(h)+" is not a constructor or null");w(x,h);function E(){this.constructor=x}x.prototype=h===null?Object.create(h):(E.prototype=h.prototype,new E)}})(),ct=(function(w){ws(x,w);function x(){return w!==null&&w.apply(this,arguments)||this}return x.DEFAULT_WIDTH=300,x.DEFAULT_WIDTH_OFFSET=2,x.FILE_SCAN_MIN_HEIGHT=300,x.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,x.MIN_QR_BOX_SIZE=50,x.SHADED_LEFT=1,x.SHADED_RIGHT=2,x.SHADED_TOP=3,x.SHADED_BOTTOM=4,x.SHADED_REGION_ELEMENT_ID="qr-shaded-region",x.VERBOSE=!1,x.BORDER_SHADER_DEFAULT_COLOR="#ffffff",x.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",x})(zi),As=(function(){function w(x,h){this.logger=h,this.fps=ct.SCAN_DEFAULT_FPS,x?(x.fps&&(this.fps=x.fps),this.disableFlip=x.disableFlip===!0,this.qrbox=x.qrbox,this.aspectRatio=x.aspectRatio,this.videoConstraints=x.videoConstraints):this.disableFlip=ct.DEFAULT_DISABLE_FLIP}return w.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?Kr.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},w.prototype.isShadedBoxEnabled=function(){return!St(this.qrbox)},w.create=function(x,h){return new w(x,h)},w})(),Yr=(function(){function w(x,h){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(x))throw"HTML Element with id=".concat(x," not found");this.elementId=x,this.verbose=!1;var E;typeof h=="boolean"?this.verbose=h===!0:h&&(E=h,this.verbose=E.verbose===!0,E.experimentalFeatures),this.logger=new Ki(this.verbose),this.qrcode=new ns(this.getSupportedFormats(h),this.getUseBarCodeDetectorIfSupported(E),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=gs.create()}return w.prototype.start=function(x,h,E,I){var g=this;if(!x)throw"cameraIdOrConfig is required";if(!E||typeof E!="function")throw"qrCodeSuccessCallback is required and should be a function.";var _;I?_=I:_=this.verbose?this.logger.log:function(){};var B=As.create(h,this.logger);this.clearElement();var L=!1;B.videoConstraints&&(B.isMediaStreamConstraintsValid()?L=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var m=L,P=document.getElementById(this.elementId);P.clientWidth?P.clientWidth:ct.DEFAULT_WIDTH,P.style.position="relative",this.shouldScan=!0,this.element=P;var O=this,ae=this.stateManagerProxy.startTransition(Me.SCANNING);return new Promise(function(j,xe){var Z=m?B.videoConstraints:O.createVideoConstraints(x);if(!Z){ae.cancel(),xe("videoConstraints should be defined");return}var ve={};(!m||B.aspectRatio)&&(ve.aspectRatio=B.aspectRatio);var ot={onRenderSurfaceReady:function(Ie,J){O.setupUi(Ie,J,B),O.isScanning=!0,O.foreverScan(B,E,_)}};cs.failIfNotSupported().then(function(Ie){Ie.create(Z).then(function(J){return J.render(g.element,ve,ot).then(function(ce){O.renderedCamera=ce,ae.execute(),j(null)}).catch(function(ce){ae.cancel(),xe(ce)})}).catch(function(J){ae.cancel(),xe(nn.errorGettingUserMedia(J))})}).catch(function(Ie){ae.cancel(),xe(nn.cameraStreamingNotSupported())})})},w.prototype.pause=function(x){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(Me.PAUSED),this.showPausedState(),(St(x)||x!==!0)&&(x=!1),x&&this.renderedCamera&&this.renderedCamera.pause()},w.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var x=this,h=function(){x.stateManagerProxy.directTransition(Me.SCANNING),x.hidePausedState()};if(!this.renderedCamera.isPaused()){h();return}this.renderedCamera.resume(function(){h()})},w.prototype.getState=function(){return this.stateManagerProxy.getState()},w.prototype.stop=function(){var x=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var h=this.stateManagerProxy.startTransition(Me.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var E=function(){if(x.element){var g=document.getElementById(ct.SHADED_REGION_ELEMENT_ID);g&&x.element.removeChild(g)}},I=this;return this.renderedCamera.close().then(function(){return I.renderedCamera=null,I.element&&(I.element.removeChild(I.canvasElement),I.canvasElement=null),E(),I.qrRegion&&(I.qrRegion=null),I.context&&(I.context=null),h.execute(),I.hidePausedState(),I.isScanning=!1,Promise.resolve()})},w.prototype.scanFile=function(x,h){return this.scanFileV2(x,h).then(function(E){return E.decodedText})},w.prototype.scanFileV2=function(x,h){var E=this;if(!x||!(x instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(St(h)&&(h=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(I,g){E.possiblyCloseLastScanImageFile(),E.clearElement(),E.lastScanImageFile=URL.createObjectURL(x);var _=new Image;
20_.onload=function(){var B=_.width,L=_.height,m=document.getElementById(E.elementId),P=m.clientWidth?m.clientWidth:ct.DEFAULT_WIDTH,O=Math.max(m.clientHeight?m.clientHeight:L,ct.FILE_SCAN_MIN_HEIGHT),ae=E.computeCanvasDrawConfig(B,L,P,O);if(h){var j=E.createCanvasElement(P,O,"qr-canvas-visible");j.style.display="inline-block",m.appendChild(j);var xe=j.getContext("2d");if(!xe)throw"Unable to get 2d context from canvas";xe.canvas.width=P,xe.canvas.height=O,xe.drawImage(_,0,0,B,L,ae.x,ae.y,ae.width,ae.height)}var Z=ct.FILE_SCAN_HIDDEN_CANVAS_PADDING,ve=Math.max(_.width,ae.width),ot=Math.max(_.height,ae.height),Ie=ve+2*Z,J=ot+2*Z,ce=E.createCanvasElement(Ie,J);m.appendChild(ce);var Nt=ce.getContext("2d");if(!Nt)throw"Unable to get 2d context from canvas";Nt.canvas.width=Ie,Nt.canvas.height=J,Nt.drawImage(_,0,0,B,L,Z,Z,ve,ot);try{E.qrcode.decodeRobustlyAsync(ce).then(function(we){I(kr.createFromQrcodeResult(we))}).catch(g)}catch(we){g("QR code parse error, error = ".concat(we))}},_.onerror=g,_.onabort=g,_.onstalled=g,_.onsuspend=g,_.src=URL.createObjectURL(x)})},w.prototype.clear=function(){this.clearElement()},w.getCameras=function(){return fs.retrieve()},w.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},w.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},w.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},w.prototype.applyVideoConstraints=function(x){if(x){if(!Kr.isMediaStreamConstraintsValid(x,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(x)},w.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera},w.prototype.getSupportedFormats=function(x){var h=[W.QR_CODE,W.AZTEC,W.CODABAR,W.CODE_39,W.CODE_93,W.CODE_128,W.DATA_MATRIX,W.MAXICODE,W.ITF,W.EAN_13,W.EAN_8,W.PDF_417,W.RSS_14,W.RSS_EXPANDED,W.UPC_A,W.UPC_E,W.UPC_EAN_EXTENSION];if(!x||typeof x=="boolean"||!x.formatsToSupport)return h;if(!Array.isArray(x.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(x.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var E=[],I=0,g=x.formatsToSupport;I<g.length;I++){var _=g[I];Yi(_)?E.push(_):this.logger.warn("Invalid format: ".concat(_," passed in config, ignoring."))}if(E.length===0)throw"None of formatsToSupport match supported values.";return E},w.prototype.getUseBarCodeDetectorIfSupported=function(x){if(St(x))return!0;if(!St(x.useBarCodeDetectorIfSupported))return x.useBarCodeDetectorIfSupported!==!1;if(St(x.experimentalFeatures))return!0;var h=x.experimentalFeatures;return St(h.useBarCodeDetectorIfSupported)?!0:h.useBarCodeDetectorIfSupported!==!1},w.prototype.validateQrboxSize=function(x,h,E){var I=this,g=E.qrbox;this.validateQrboxConfig(g);var _=this.toQrdimensions(x,h,g),B=function(m){if(m<ct.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(ct.MIN_QR_BOX_SIZE,"px.")},L=function(m){return m>x&&(I.logger.warn("`qrbox.width` or `qrbox` is larger than the width of the root element. The width will be truncated to the width of root element."),m=x),m};B(_.width),B(_.height),_.width=L(_.width)},w.prototype.validateQrboxConfig=function(x){if(typeof x!="number"&&typeof x!="function"&&(x.width===void 0||x.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},w.prototype.toQrdimensions=function(x,h,E){if(typeof E=="number")return{width:E,height:E};if(typeof E=="function")try{return E(x,h)}catch(I){throw new Error("qrbox config was passed as a function but it failed with unknown error"+I)}return E},w.prototype.setupUi=function(x,h,E){E.isShadedBoxEnabled()&&this.validateQrboxSize(x,h,E);var I=St(E.qrbox)?{width:x,height:h}:E.qrbox;this.validateQrboxConfig(I);var g=this.toQrdimensions(x,h,I);
20g.height>h&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var _=E.isShadedBoxEnabled()&&g.height<=h,B={x:0,y:0,width:x,height:h},L=_?this.getShadedRegionBounds(x,h,g):B,m=this.createCanvasElement(L.width,L.height),P={willReadFrequently:!0},O=m.getContext("2d",P);O.canvas.width=L.width,O.canvas.height=L.height,this.element.append(m),_&&this.possiblyInsertShadingElement(this.element,x,h,g),this.createScannerPausedUiElement(this.element),this.qrRegion=L,this.context=O,this.canvasElement=m},w.prototype.createScannerPausedUiElement=function(x){var h=document.createElement("div");h.innerText=nn.scannerPaused(),h.style.display="none",h.style.position="absolute",h.style.top="0px",h.style.zIndex="1",h.style.background="rgba(9, 9, 9, 0.46)",h.style.color="#FFECEC",h.style.textAlign="center",h.style.width="100%",x.appendChild(h),this.scannerPausedUiElement=h},w.prototype.scanContext=function(x,h){var E=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(I){return x(I.text,kr.createFromQrcodeResult(I)),E.possiblyUpdateShaders(!0),!0}).catch(function(I){E.possiblyUpdateShaders(!1);var g=nn.codeParseError(I);return h(g,Zi.createFrom(g)),!1})},w.prototype.foreverScan=function(x,h,E){var I=this;if(this.shouldScan&&this.renderedCamera){var g=this.renderedCamera.getSurface(),_=g.videoWidth/g.clientWidth,B=g.videoHeight/g.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var L=this.qrRegion.width*_,m=this.qrRegion.height*B,P=this.qrRegion.x*_,O=this.qrRegion.y*B;this.context.drawImage(g,P,O,L,m,0,0,this.qrRegion.width,this.qrRegion.height);var ae=function(){I.foreverScanTimeout=setTimeout(function(){I.foreverScan(x,h,E)},I.getTimeoutFps(x.fps))};this.scanContext(h,E).then(function(j){!j&&x.disableFlip!==!0?(I.context.translate(I.context.canvas.width,0),I.context.scale(-1,1),I.scanContext(h,E).finally(function(){ae()})):ae()}).catch(function(j){I.logger.logError("Error happend while scanning context",j),ae()})}},w.prototype.createVideoConstraints=function(x){if(typeof x=="string")return{deviceId:{exact:x}};if(typeof x=="object"){var h="facingMode",E="deviceId",I={user:!0,environment:!0},g="exact",_=function(xe){if(xe in I)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(xe,"'")},B=Object.keys(x);if(B.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(B.length," keys");var L=Object.keys(x)[0];if(L!==h&&L!==E)throw"Only '".concat(h,"' and '").concat(E,"' ")+" are supported for 'cameraIdOrConfig'";if(L===h){var m=x.facingMode;if(typeof m=="string"){if(_(m))return{facingMode:m}}else if(typeof m=="object")if(g in m){if(_(m["".concat(g)]))return{facingMode:{exact:m["".concat(g)]}}}else throw"'facingMode' should be string or object with"+" ".concat(g," as key.");else{var P=typeof m;throw"Invalid type of 'facingMode' = ".concat(P)}}else{var O=x.deviceId;if(typeof O=="string")return{deviceId:O};if(typeof O=="object"){if(g in O)return{deviceId:{exact:O["".concat(g)]}};throw"'deviceId' should be string or object with"+" ".concat(g," as key.")}else{var ae=typeof O;throw"Invalid type of 'deviceId' = ".concat(ae)}}}var j=typeof x;throw"Invalid type of 'cameraIdOrConfig' = ".concat(j)},w.prototype.computeCanvasDrawConfig=function(x,h,E,I){if(x<=E&&h<=I){var g=(E-x)/2,_=(I-h)/2;return{x:g,y:_,width:x,height:h}}else{var B=x,L=h;return x>E&&(h=E/x*h,x=E),h>I&&(x=I/h*x,h=I),this.logger.log("Image downsampled from "+"".concat(B,"X").concat(L)+" to ".concat(x,"X").concat(h,".")),this.computeCanvasDrawConfig(x,h,E,I)}},w.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var x=document.getElementById(this.elementId);x&&(x.innerHTML="")},w.prototype.possiblyUpdateShaders=function(x){this.qrMatch!==x&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(h){h.style.backgroundColor=x?ct.BORDER_SHADER_MATCH_COLOR:ct.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=x)},w.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},w.prototype.createCanvasElement=function(x,h,E){var I=x,g=h,_=document.createElement("canvas");return _.style.width="".concat(I,"px"),_.style.height="".concat(g,"px"),_.style.display="none",_.id=St(E)?"qr-canvas":E,_}
20,w.prototype.getShadedRegionBounds=function(x,h,E){if(E.width>x||E.height>h)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(x-E.width)/2,y:(h-E.height)/2,width:E.width,height:E.height}},w.prototype.possiblyInsertShadingElement=function(x,h,E,I){if(!(h-I.width<1||E-I.height<1)){var g=document.createElement("div");g.style.position="absolute";var _=(h-I.width)/2,B=(E-I.height)/2;if(g.style.borderLeft="".concat(_,"px solid rgba(0, 0, 0, 0.48)"),g.style.borderRight="".concat(_,"px solid rgba(0, 0, 0, 0.48)"),g.style.borderTop="".concat(B,"px solid rgba(0, 0, 0, 0.48)"),g.style.borderBottom="".concat(B,"px solid rgba(0, 0, 0, 0.48)"),g.style.boxSizing="border-box",g.style.top="0px",g.style.bottom="0px",g.style.left="0px",g.style.right="0px",g.id="".concat(ct.SHADED_REGION_ELEMENT_ID),h-I.width<11||E-I.height<11)this.hasBorderShaders=!1;else{var L=5,m=40;this.insertShaderBorders(g,m,L,-L,null,0,!0),this.insertShaderBorders(g,m,L,-L,null,0,!1),this.insertShaderBorders(g,m,L,null,-L,0,!0),this.insertShaderBorders(g,m,L,null,-L,0,!1),this.insertShaderBorders(g,L,m+L,-L,null,-L,!0),this.insertShaderBorders(g,L,m+L,null,-L,-L,!0),this.insertShaderBorders(g,L,m+L,-L,null,-L,!1),this.insertShaderBorders(g,L,m+L,null,-L,-L,!1),this.hasBorderShaders=!0}x.append(g)}},w.prototype.insertShaderBorders=function(x,h,E,I,g,_,B){var L=document.createElement("div");L.style.position="absolute",L.style.backgroundColor=ct.BORDER_SHADER_DEFAULT_COLOR,L.style.width="".concat(h,"px"),L.style.height="".concat(E,"px"),I!==null&&(L.style.top="".concat(I,"px")),g!==null&&(L.style.bottom="".concat(g,"px")),B?L.style.left="".concat(_,"px"):L.style.right="".concat(_,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(L),x.appendChild(L)},w.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},w.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},w.prototype.getTimeoutFps=function(x){return 1e3/x},w})(),zr;(function(w){w[w.STATUS_DEFAULT=0]="STATUS_DEFAULT",w[w.STATUS_SUCCESS=1]="STATUS_SUCCESS",w[w.STATUS_WARNING=2]="STATUS_WARNING",w[w.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(zr||(zr={}));function Cs({onScan:w,onError:x}){At.useRef(null);const h=At.useRef(null),[E,I]=At.useState(null),[g,_]=At.useState([]),[B,L]=At.useState(null),[m,P]=At.useState(!1);At.useEffect(()=>{const j=new Yr("qr-reader");return I(j),Yr.getCameras().then(xe=>{if(xe&&xe.length){_(xe);const Z=xe.find(ve=>ve.label.toLowerCase().includes("back"))||xe[0];L(Z.id)}}).catch(xe=>{console.error("Error getting cameras:",xe),x==null||x("Erro ao aceder à câmara")}),()=>{j.isScanning&&j.stop().catch(console.error)}},[]);const O=async()=>{if(!(!E||!B))try{P(!0),await E.start(B,{fps:10,qrbox:{width:250,height:250}},j=>{E.stop().then(()=>{P(!1),w(j)})},j=>{})}catch(j){console.error("Error starting scanner:",j),P(!1),x==null||x("Erro ao iniciar escaneamento")}},ae=async j=>{var Z;const xe=(Z=j.target.files)==null?void 0:Z[0];if(!(!xe||!E))try{const ve=await E.scanFile(xe,!1);w(ve)}catch(ve){console.error("Error scanning file:",ve),x==null||x("Não foi possÃvel ler o QR Code desta imagem")}};return At.useEffect(()=>{B&&!m&&O()},[B]),D.jsx("div",{className:"space-y-4",children:D.jsxs(Fi,{defaultValue:"camera",className:"w-full",children:[D.jsxs(ki,{className:"grid w-full grid-cols-2",children:[D.jsxs(Mr,{value:"camera",children:[D.jsx(or,{className:"w-4 h-4 mr-2"}),"Câmara"]}),D.jsxs(Mr,{value:"upload",children:[D.jsx(vr,{className:"w-4 h-4 mr-2"}),"Upload"]})]}),D.jsxs(Br,{value:"camera",className:"space-y-4",children:[D.jsx("div",{id:"qr-reader",className:"w-full rounded-lg overflow-hidden bg-black",style:{maxWidth:"500px",margin:"0 auto"}}),g.length>1&&D.jsx("div",{className:"text-center",children:D.jsx("select",{className:"px-4 py-2 border rounded-lg",value:B,onChange:j=>L(j.target.value),children:g.map(j=>D.jsx("option",{value:j.id,children:j.label},j.id))})}),D.jsx("p",{className:"text-center text-sm text-gray-600",children:"Posicione o QR Code dentro da área de escaneamento"})]}),D.jsx(Br,{value:"upload",className:"space-y-4",children:D.jsxs("div",{className:"text-center py-12",children:[D.jsx(vr,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),D.jsx("p",{className:"text-gray-600 mb-4",children:"Faça upload de uma imagem com o QR Code do bilhete"}),D.jsx("input",{ref:h,type:"file",accept:"image/*",onChange:ae,className:"hidden"}),D.jsx(tn,{onClick:()=>{var j;return(j=h.current)==null?void 0:j.click()},variant:"outline",children:"Selecionar Imagem"})]})})]})})}function Ds(){var P,O,ae,j,xe;const w=Ri(),[x,h]=At.useState(!1),[E,I]=At.useState(null),[g,_]=At.useState(null),{data:B}=Oi({queryKey:["current-user"],queryFn:()=>ir.auth.me()}),L=Di({mutationFn:async Z=>
20{const ve=await ir.entities.TicketPurchase.filter({ticket_code:Z});if(!ve||ve.length===0)throw new Error("Bilhete não encontrado");const ot=ve[0];if(ot.status==="validated")throw new Error("Bilhete já foi validado anteriormente");if(ot.status!=="paid")throw new Error("Bilhete ainda não foi pago");return await ir.entities.TicketPurchase.update(ot.id,{status:"validated",validated_at:new Date().toISOString(),validated_by:B==null?void 0:B.email}),ot},onSuccess:Z=>{I(Z),_(null),w.invalidateQueries(["admin-ticket-purchases"]),Dr.success("Bilhete validado com sucesso!")},onError:Z=>{_(Z.message),I(null),Dr.error(Z.message)}}),m=Z=>{Z&&(h(!1),L.mutate(Z))};return(B==null?void 0:B.role)!=="admin"?D.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:D.jsxs("div",{className:"text-center",children:[D.jsx(Ui,{className:"w-20 h-20 text-red-600 mx-auto mb-4"}),D.jsx("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Acesso Negado"}),D.jsx("p",{className:"text-gray-600",children:"Apenas administradores podem aceder a esta área"})]})}):D.jsx("main",{className:"min-h-screen bg-gray-50 py-12",children:D.jsxs("div",{className:"container mx-auto px-4 max-w-4xl",children:[D.jsx(Mi,{to:Bi("Admin"),children:D.jsxs(tn,{variant:"ghost",className:"mb-6",children:[D.jsx(Vi,{className:"w-4 h-4 mr-2"}),"Voltar ao Dashboard"]})}),D.jsxs("div",{className:"text-center mb-8",children:[D.jsx(Gi,{className:"w-16 h-16 text-red-600 mx-auto mb-4"}),D.jsx("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Validação de Bilhetes"}),D.jsx("p",{className:"text-gray-600",children:"Escaneie o QR Code do bilhete para validar a entrada"})]}),!x&&!E&&!g&&D.jsx(Mn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},children:D.jsx(sr,{children:D.jsxs(ar,{className:"p-8 text-center",children:[D.jsx(or,{className:"w-20 h-20 text-gray-400 mx-auto mb-6"}),D.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-2",children:"Pronto para escanear"}),D.jsx("p",{className:"text-gray-600 mb-6",children:"Clique no botão abaixo para iniciar o escaneamento de QR Code"}),D.jsxs(tn,{onClick:()=>h(!0),className:"bg-red-600 hover:bg-red-700",size:"lg",children:[D.jsx(or,{className:"w-5 h-5 mr-2"}),"Iniciar Escaneamento"]})]})})}),x&&D.jsx(Mn.div,{initial:{opacity:0}
20,animate:{opacity:1},children:D.jsx(sr,{children:D.jsxs(ar,{className:"p-6",children:[D.jsx(Cs,{onScan:m,onError:Z=>_(Z)}),D.jsx("div",{className:"text-center mt-4",children:D.jsx(tn,{variant:"outline",onClick:()=>h(!1),children:"Cancelar"})})]})})}),D.jsxs(Xi,{children:[g&&D.jsxs(Mn.div,{initial:{opacity:0,y:20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},children:[D.jsxs(Pi,{className:"border-red-200 bg-red-50 mb-6",children:[D.jsx(Hi,{className:"w-5 h-5 text-red-600"}),D.jsx(Li,{className:"text-red-800 ml-2",children:g})]}),D.jsx("div",{className:"text-center",children:D.jsx(tn,{onClick:()=>{_(null),h(!0)},className:"bg-red-600 hover:bg-red-700",children:"Tentar Novamente"})})]}),E&&D.jsx(Mn.div,{initial:{opacity:0,scale:.9},animate:{opacity:1,scale:1},exit:{opacity:0,scale:.9},children:D.jsx(sr,{className:"border-green-200 bg-green-50",children:D.jsxs(ar,{className:"p-8",children:[D.jsxs("div",{className:"text-center mb-6",children:[D.jsx("div",{className:"w-20 h-20 bg-green-600 rounded-full flex items-center justify-center mx-auto mb-4",children:D.jsx(Wi,{className:"w-12 h-12 text-white"})}),D.jsx("h2",{className:"text-2xl font-bold text-green-900 mb-2",children:"Bilhete Validado!"}),D.jsx("p",{className:"text-green-700",children:"Entrada autorizada"})]}),D.jsxs("div",{className:"bg-white rounded-lg p-6 space-y-4",children:[D.jsxs("div",{className:"border-b pb-4",children:[D.jsx("h3",{className:"font-bold text-gray-900 mb-3 text-lg",children:"Detalhes do Jogo"}),D.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Jogo"}),D.jsxs("p",{className:"font-semibold",children:[(P=E.match_details)==null?void 0:P.home_team," vs ",(O=E.match_details)==null?void 0:O.away_team]})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Competição"}),D.jsx("p",{className:"font-semibold",children:(ae=E.match_details)==null?void 0:ae.competition})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Data"}),D.jsx("p",{className:"font-semibold",children:Pr((j=E.match_details)==null?void 0:j.match_date).format("DD/MM/YYYY HH:mm")})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Local"}),D.jsx("p",{className:"font-semibold",children:(xe=E.match_details)==null?void 0:xe.venue})]})]})]}),D.jsxs("div",{className:"border-b pb-4",children:[D.jsx("h3",{className:"font-bold text-gray-900 mb-3 text-lg",children:"Detalhes do Bilhete"}),D.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Tipo"}),D.jsx(vi,{className:"bg-blue-100 text-blue-800",children:E.ticket_type.toUpperCase()})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Setor"}),D.jsx("p",{className:"font-semibold",children:E.sector})]}),E.seat_number&&D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Lugar"}),D.jsx("p",{className:"font-semibold",children:E.seat_number})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Quantidade"}),D.jsxs("p",{className:"font-semibold",children:[E.quantity," bilhete(s)"]})]})]})]}),D.jsxs("div",{children:[D.jsx("h3",{className:"font-bold text-gray-900 mb-3 text-lg",children:"Comprador"}),D.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Nome"}),D.jsx("p",{className:"font-semibold",children:E.buyer_name})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-sm text-gray-600 mb-1",children:"Email"}),D.jsx("p",{className:"font-semibold",children:E.buyer_email})]})]})]}),D.jsxs("div",{className:"bg-gray-50 rounded-lg p-4",children:[D.jsxs("div",{className:"flex items-center justify-between",children:[D.jsx("span",{className:"text-sm text-gray-600",children:"Validado por"}),D.jsx("span",{className:"font-semibold",children:B==null?void 0:B.email})]}),D.jsxs("div",{className:"flex items-center justify-between mt-2",children:[D.jsx("span",{className:"text-sm text-gray-600",children:"Data de validação"}),D.jsx("span",{className:"font-semibold",children:Pr().format("DD/MM/YYYY HH:mm:ss")})]})]})]}),D.jsx("div",{className:"text-center mt-6",children:D.jsx(tn,{onClick:()=>{I(null),h(!0)},className:"bg-red-600 hover:bg-red-700",children:"Validar Próximo Bilhete"})})]})})})]})]})})}export{Ds as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.