import{aK as t,aZ as e,by as r,ae as n,a as i,o,e as s,h as a,w as l,f as c,y as h,F as u,B as d,G as f,i as g,I as w,m,ac as A,a5 as C,p as E,H as _}from"./index-d4baa715.js";import{_ as p}from"./uv-icon.b5ddbe11.js";import{H as I}from"./index.704ebef3.js";import{u as S}from"./useScroll.dcb46f58.js";import{ab as T}from"./images.f0a6f614.js";import{u as R}from"./useInterface.2c7749ae.js";import{M as y}from"./index.b68f4c8d.js";import{_ as N}from"./_plugin-vue_export-helper.1b428a4d.js";import"./uv-icon.vue_vue_type_style_index_0_scoped_23936b10_lang.7145f5b2.js";import"./utils.052a93d2.js";import"./index.dcf9623e.js";function D(t,e){for(var r=0;rn[e]})}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var O,b;(b=O||(O={}))[b.QR_CODE=0]="QR_CODE",b[b.AZTEC=1]="AZTEC",b[b.CODABAR=2]="CODABAR",b[b.CODE_39=3]="CODE_39",b[b.CODE_93=4]="CODE_93",b[b.CODE_128=5]="CODE_128",b[b.DATA_MATRIX=6]="DATA_MATRIX",b[b.MAXICODE=7]="MAXICODE",b[b.ITF=8]="ITF",b[b.EAN_13=9]="EAN_13",b[b.EAN_8=10]="EAN_8",b[b.PDF_417=11]="PDF_417",b[b.RSS_14=12]="RSS_14",b[b.RSS_EXPANDED=13]="RSS_EXPANDED",b[b.UPC_A=14]="UPC_A",b[b.UPC_E=15]="UPC_E",b[b.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION";var M,P,B,v,L=new Map([[O.QR_CODE,"QR_CODE"],[O.AZTEC,"AZTEC"],[O.CODABAR,"CODABAR"],[O.CODE_39,"CODE_39"],[O.CODE_93,"CODE_93"],[O.CODE_128,"CODE_128"],[O.DATA_MATRIX,"DATA_MATRIX"],[O.MAXICODE,"MAXICODE"],[O.ITF,"ITF"],[O.EAN_13,"EAN_13"],[O.EAN_8,"EAN_8"],[O.PDF_417,"PDF_417"],[O.RSS_14,"RSS_14"],[O.RSS_EXPANDED,"RSS_EXPANDED"],[O.UPC_A,"UPC_A"],[O.UPC_E,"UPC_E"],[O.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]);function F(t){return Object.values(O).includes(t)}(P=M||(M={}))[P.UNKNOWN=0]="UNKNOWN",P[P.URL=1]="URL",(v=B||(B={}))[v.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",v[v.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE";var k,x,U=function(){function t(){}return t.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",t.SCAN_DEFAULT_FPS=2,t.DEFAULT_DISABLE_FLIP=!1,t.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,t.DEFAULT_SUPPORTED_SCAN_TYPE=[B.SCAN_TYPE_CAMERA,B.SCAN_TYPE_FILE],t}(),V=function(){function t(t,e){this.format=t,this.formatName=e}return t.prototype.toString=function(){return this.formatName},t.create=function(e){if(!L.has(e))throw"".concat(e," not in html5QrcodeSupportedFormatsTextMap");return new t(e,L.get(e))},t}(),H=function(){function t(){}return t.createFromText=function(t){return{decodedText:t,result:{text:t}}},t.createFromQrcodeResult=function(t){return{decodedText:t.text,result:t}},t}();(x=k||(k={}))[x.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",x[x.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",x[x.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR";var G=function(){function t(){}return t.createFrom=function(t){return{errorMessage:t,type:k.UNKWOWN_ERROR}},t}(),X=function(){function t(t){this.verbose=t}return t.prototype.log=function(t){this.verbose&&console.log(t)},t.prototype.warn=function(t){this.verbose&&console.warn(t)},t.prototype.logError=function(t,e){(this.verbose||!0===e)&&console.error(t)},t.prototype.logErrors=function(t){if(0===t.length)throw"Logger#logError called without arguments";this.verbose&&console.error(t)},t}();function W(t){return null==t}var z=function(){function t(){}return t.codeParseError=function(t){return"QR code parse error, error = ".concat(t)},t.errorGettingUserMedia=function(t){return"Error getting userMedia, error = ".concat(t)},t.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},t.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},t.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},t.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},t.scannerPaused=function(){return"Scanner paused"},t}(),Y=function(){function t(){}return t.isMediaStreamConstraintsValid=function(t,e){if("object"!=typeof t){var r=typeof t;return e.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(r,"."),!0),!1}for(var n=new Set(["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"]),i=0,o=Object.keys(t);ir)throw new d("fromIndex("+e+") > toIndex("+r+")");if(e<0)throw new C(e);if(r>t)throw new C(r)}static asList(...t){return t}static create(t,e,r){return Array.from({length:t}).map((t=>Array.from({length:e}).fill(r)))}static createInt32Array(t,e,r){return Array.from({length:t}).map((t=>Int32Array.from({length:e}).fill(r)))}static equals(t,e){if(!t)return!1;if(!e)return!1;if(!t.length)return!1;if(!e.length)return!1;if(t.length!==e.length)return!1;for(let r=0,n=t.length;r>1,s=r(e,t[o]);if(s>0)n=o+1;else{if(!(s<0))return o;i=o-1}}return-n-1}static numberComparator(t,e){return t-e}}class _{static numberOfTrailingZeros(t){let e;if(0===t)return 32;let r=31;return e=t<<16,0!==e&&(r-=16,t=e),e=t<<8,0!==e&&(r-=8,t=e),e=t<<4,0!==e&&(r-=4,t=e),e=t<<2,0!==e&&(r-=2,t=e),r-(t<<1>>>31)}static numberOfLeadingZeros(t){if(0===t)return 32;let e=1;return t>>>16==0&&(e+=16,t<<=16),t>>>24==0&&(e+=8,t<<=8),t>>>28==0&&(e+=4,t<<=4),t>>>30==0&&(e+=2,t<<=2),e-=t>>>31,e}static toHexString(t){return t.toString(16)}static toBinaryString(t){return String(parseInt(String(t),2))}static bitCount(t){return t=(t=(858993459&(t-=t>>>1&1431655765))+(t>>>2&858993459))+(t>>>4)&252645135,t+=t>>>8,63&(t+=t>>>16)}static truncDivision(t,e){return Math.trunc(t/e)}static parseInt(t,e){return parseInt(t,e)}}_.MIN_VALUE_32_BITS=-2147483648,_.MAX_VALUE=Number.MAX_SAFE_INTEGER;class p{constructor(t,e){void 0===t?(this.size=0,this.bits=new Int32Array(1)):(this.size=t,this.bits=null==e?p.makeArray(t):e)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(t){if(t>32*this.bits.length){const e=p.makeArray(t);m.arraycopy(this.bits,0,e,0,this.bits.length),this.bits=e}}get(t){return 0!=(this.bits[Math.floor(t/32)]&1<<(31&t))}set(t){this.bits[Math.floor(t/32)]|=1<<(31&t)}flip(t){this.bits[Math.floor(t/32)]^=1<<(31&t)}getNextSet(t){const e=this.size;if(t>=e)return e;const r=this.bits;let n=Math.floor(t/32),i=r[n];i&=~((1<<(31&t))-1);const o=r.length;for(;0===i;){if(++n===o)return e;i=r[n]}const s=32*n+_.numberOfTrailingZeros(i);return s>e?e:s}getNextUnset(t){const e=this.size;if(t>=e)return e;const r=this.bits;let n=Math.floor(t/32),i=~r[n];i&=~((1<<(31&t))-1);const o=r.length;for(;0===i;){if(++n===o)return e;i=~r[n]}const s=32*n+_.numberOfTrailingZeros(i);return s>e?e:s}setBulk(t,e){this.bits[Math.floor(t/32)]=e}setRange(t,e){if(ethis.size)throw new d;if(e===t)return;e--;const r=Math.floor(t/32),n=Math.floor(e/32),i=this.bits;for(let o=r;o<=n;o++){const s=(2<<(or?0:31&t));i[o]|=s}}clear(){const t=this.bits.length,e=this.bits;for(let r=0;rthis.size)throw new d;if(e===t)return!0;e--;const n=Math.floor(t/32),i=Math.floor(e/32),o=this.bits;for(let s=n;s<=i;s++){const a=(2<<(sn?0:31&t))&4294967295;if((o[s]&a)!==(r?a:0))return!1}return!0}appendBit(t){this.ensureCapacity(this.size+1),t&&(this.bits[Math.floor(this.size/32)]|=1<<(31&this.size)),this.size++}appendBits(t,e){if(e<0||e>32)throw new d("Num bits must be between 0 and 32");this.ensureCapacity(this.size+e);for(let r=e;r>0;r--)this.appendBit(1==(t>>r-1&1))}appendBitArray(t){const e=t.size;this.ensureCapacity(this.size+e);for(let r=0;r>1&1431655765|(1431655765&r)<<1,r=r>>2&858993459|(858993459&r)<<2,r=r>>4&252645135|(252645135&r)<<4,r=r>>8&16711935|(16711935&r)<<8,r=r>>16&65535|(65535&r)<<16,t[e-i]=r}if(this.size!==32*r){const e=32*r-this.size;let n=t[0]>>>e;for(let i=1;i>>e}t[r-1]=n}this.bits=t}static makeArray(t){return new Int32Array(Math.floor((t+31)/32))}equals(t){if(!(t instanceof p))return!1;const e=t;return this.size===e.size&&E.equals(this.bits,e.bits)}hashCode(){return 31*this.size+E.hashCode(this.bits)}toString(){let t="";for(let e=0,r=this.size;e=900)throw new R("incorect value");const e=y.VALUES_TO_ECI.get(t);if(void 0===e)throw new R("incorect value");return e}static getCharacterSetECIByName(t){const e=y.NAME_TO_ECI.get(t);if(void 0===e)throw new R("incorect value");return e}equals(t){if(!(t instanceof y))return!1;const e=t;return this.getName()===e.getName()}}y.VALUE_IDENTIFIER_TO_ECI=new Map,y.VALUES_TO_ECI=new Map,y.NAME_TO_ECI=new Map,y.Cp437=new y(I.Cp437,Int32Array.from([0,2]),"Cp437"),y.ISO8859_1=new y(I.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),y.ISO8859_2=new y(I.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),y.ISO8859_3=new y(I.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),y.ISO8859_4=new y(I.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),y.ISO8859_5=new y(I.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),y.ISO8859_6=new y(I.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),y.ISO8859_7=new y(I.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),y.ISO8859_8=new y(I.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),y.ISO8859_9=new y(I.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),y.ISO8859_10=new y(I.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),y.ISO8859_11=new y(I.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),y.ISO8859_13=new y(I.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),y.ISO8859_14=new y(I.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),y.ISO8859_15=new y(I.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),y.ISO8859_16=new y(I.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),y.SJIS=new y(I.SJIS,20,"SJIS","Shift_JIS"),y.Cp1250=new y(I.Cp1250,21,"Cp1250","windows-1250"),y.Cp1251=new y(I.Cp1251,22,"Cp1251","windows-1251"),y.Cp1252=new y(I.Cp1252,23,"Cp1252","windows-1252"),y.Cp1256=new y(I.Cp1256,24,"Cp1256","windows-1256"),y.UnicodeBigUnmarked=new y(I.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),y.UTF8=new y(I.UTF8,26,"UTF8","UTF-8"),y.ASCII=new y(I.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),y.Big5=new y(I.Big5,28,"Big5"),y.GB18030=new y(I.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),y.EUC_KR=new y(I.EUC_KR,30,"EUC_KR","EUC-KR");class N extends h{}N.kind="UnsupportedOperationException";class D{static decode(t,e){const r=this.encodingName(e);return this.customDecoder?this.customDecoder(t,r):"undefined"==typeof TextDecoder||this.shouldDecodeOnFallback(r)?this.decodeFallback(t,r):new TextDecoder(r).decode(t)}static shouldDecodeOnFallback(t){return!D.isBrowser()&&"ISO-8859-1"===t}static encode(t,e){const r=this.encodingName(e);return this.customEncoder?this.customEncoder(t,r):"undefined"==typeof TextEncoder?this.encodeFallback(t):(new TextEncoder).encode(t)}static isBrowser(){return"undefined"!=typeof window&&"[object Window]"==={}.toString.call(window)}static encodingName(t){return"string"==typeof t?t:t.getName()}static encodingCharacterSet(t){return t instanceof y?t:y.getCharacterSetECIByName(t)}static decodeFallback(t,e){const r=this.encodingCharacterSet(e);if(D.isDecodeFallbackSupported(r)){let e="";for(let r=0,n=t.length;r3&&239===t[0]&&187===t[1]&&191===t[2];for(let C=0;C0?0==(128&e)?o=!1:s--:0!=(128&e)&&(0==(64&e)?o=!1:(s++,0==(32&e)?a++:(s++,0==(16&e)?l++:(s++,0==(8&e)?c++:o=!1))))),n&&(e>127&&e<160?n=!1:e>159&&(e<192||215===e||247===e)&&m++),i&&(h>0?e<64||127===e||e>252?i=!1:h--:128===e||160===e||e>239?i=!1:e>160&&e<224?(u++,f=0,d++,d>g&&(g=d)):e>127?(h++,d=0,f++,f>w&&(w=f)):(d=0,f=0))}return o&&s>0&&(o=!1),i&&h>0&&(i=!1),o&&(A||a+l+c>0)?O.UTF8:i&&(O.ASSUME_SHIFT_JIS||g>=3||w>=3)?O.SHIFT_JIS:n&&i?2===g&&2===u||10*m>=r?O.SHIFT_JIS:O.ISO88591:n?O.ISO88591:i?O.SHIFT_JIS:o?O.UTF8:O.PLATFORM_DEFAULT_ENCODING}static format(t,...e){let r=-1;function n(t,n,i,o,s,a){if("%%"===t)return"%";if(void 0===e[++r])return;t=o?parseInt(o.substr(1)):void 0;let l,c=s?parseInt(s.substr(1)):void 0;switch(a){case"s":l=e[r];break;case"c":l=e[r][0];break;case"f":l=parseFloat(e[r]).toFixed(t);break;case"p":l=parseFloat(e[r]).toPrecision(t);break;case"e":l=parseFloat(e[r]).toExponential(t);break;case"x":l=parseInt(e[r]).toString(c||16);break;case"d":l=parseFloat(parseInt(e[r],c||10).toPrecision(t)).toFixed(0)}l="object"==typeof l?JSON.stringify(l):(+l).toString(c);let h=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;l.lengtho){if(-1===s)s=i-o;else if(i-o!==s)throw new d("row lengths do not match");o=i,a++}l++}else if(t.substring(l,l+e.length)===e)l+=e.length,n[i]=!0,i++;else{if(t.substring(l,l+r.length)!==r)throw new d("illegal character encountered: "+t.substring(l));l+=r.length,n[i]=!1,i++}if(i>o){if(-1===s)s=i-o;else if(i-o!==s)throw new d("row lengths do not match");a++}const c=new M(s,a);for(let h=0;h>>(31&t)&1)}set(t,e){const r=e*this.rowSize+Math.floor(t/32);this.bits[r]|=1<<(31&t)&4294967295}unset(t,e){const r=e*this.rowSize+Math.floor(t/32);this.bits[r]&=~(1<<(31&t)&4294967295)}flip(t,e){const r=e*this.rowSize+Math.floor(t/32);this.bits[r]^=1<<(31&t)&4294967295}xor(t){if(this.width!==t.getWidth()||this.height!==t.getHeight()||this.rowSize!==t.getRowSize())throw new d("input matrix dimensions do not match");const e=new p(Math.floor(this.width/32)+1),r=this.rowSize,n=this.bits;for(let i=0,o=this.height;ithis.height||i>this.width)throw new d("The region must fit inside the matrix");const s=this.rowSize,a=this.bits;for(let l=e;la&&(a=l),32*ts){let r=31;for(;e>>>r==0;)r--;32*t+r>s&&(s=32*t+r)}}}return s=0&&0===e[r];)r--;if(r<0)return null;const n=Math.floor(r/t);let i=32*Math.floor(r%t);const o=e[r];let s=31;for(;o>>>s==0;)s--;return i+=s,Int32Array.from([i,n])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(t){if(!(t instanceof M))return!1;const e=t;return this.width===e.width&&this.height===e.height&&this.rowSize===e.rowSize&&E.equals(this.bits,e.bits)}hashCode(){let t=this.width;return t=31*t+this.width,t=31*t+this.height,t=31*t+this.rowSize,t=31*t+E.hashCode(this.bits),t}toString(t="X ",e=" ",r="\n"){return this.buildToString(t,e,r)}buildToString(t,e,r){let n=new b;for(let i=0,o=this.height;i>B.LUMINANCE_SHIFT]++;const s=B.estimateBlackPoint(o);if(n<3)for(let a=0;a>B.LUMINANCE_SHIFT]++}const o=B.estimateBlackPoint(i),s=t.getMatrix();for(let a=0;ai&&(n=c,i=t[c]),t[c]>r&&(r=t[c]);let o=0,s=0;for(let c=0;cs&&(o=c,s=r)}if(n>o){const t=n;n=o,o=t}if(o-n<=e/16)throw new P;let a=o-1,l=-1;for(let c=o-1;c>n;c--){const e=c-n,i=e*e*(o-c)*(r-t[c]);i>l&&(a=c,l=i)}return a<=v.MINIMUM_DIMENSION&&r>=v.MINIMUM_DIMENSION){const n=t.getMatrix();let i=e>>v.BLOCK_SIZE_POWER;0!=(e&v.BLOCK_SIZE_MASK)&&i++;let o=r>>v.BLOCK_SIZE_POWER;0!=(r&v.BLOCK_SIZE_MASK)&&o++;const s=v.calculateBlackPoints(n,i,o,e,r),a=new M(e,r);v.calculateThresholdForBlock(n,i,o,e,r,s,a),this.matrix=a}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(t){return new v(t)}static calculateThresholdForBlock(t,e,r,n,i,o,s){const a=i-v.BLOCK_SIZE,l=n-v.BLOCK_SIZE;for(let c=0;ca&&(i=a);const h=v.cap(c,2,r-3);for(let r=0;rl&&(a=l);const c=v.cap(r,2,e-3);let u=0;for(let t=-2;t<=2;t++){const e=o[h+t];u+=e[c-2]+e[c-1]+e[c]+e[c+1]+e[c+2]}const d=u/25;v.thresholdBlock(t,a,i,d,n,s)}}}static cap(t,e,r){return tr?r:t}static thresholdBlock(t,e,r,n,i,o){for(let s=0,a=r*i+e;so&&(r=o);for(let i=0;is&&(e=s);let o=0,c=255,h=0;for(let i=0,s=r*n+e;ih&&(h=r)}if(h-c>v.MIN_DYNAMIC_RANGE)for(i++,s+=n;i>2*v.BLOCK_SIZE_POWER;if(h-c<=v.MIN_DYNAMIC_RANGE&&(u=c/2,l>0&&i>0)){const t=(a[l-1][i]+2*a[l][i-1]+a[l-1][i-1])/4;c>10,n[o]=e}return n}getRow(t,e){if(t<0||t>=this.getHeight())throw new d("Requested row is outside the image: "+t);const r=this.getWidth(),n=t*r;return null===e?e=this.buffer.slice(n,n+r):(e.lengthnew x(t.deviceId,t.label)))}))}findDeviceById(t){return H(this,void 0,void 0,(function*(){const e=yield this.listVideoInputDevices();return e?e.find((e=>e.deviceId===t)):null}))}decodeFromInputVideoDevice(t,e){return H(this,void 0,void 0,(function*(){return yield this.decodeOnceFromVideoDevice(t,e)}))}decodeOnceFromVideoDevice(t,e){return H(this,void 0,void 0,(function*(){let r;this.reset(),r=t?{deviceId:{exact:t}}:{facingMode:"environment"};const n={video:r};return yield this.decodeOnceFromConstraints(n,e)}))}decodeOnceFromConstraints(t,e){return H(this,void 0,void 0,(function*(){const r=yield navigator.mediaDevices.getUserMedia(t);return yield this.decodeOnceFromStream(r,e)}))}decodeOnceFromStream(t,e){return H(this,void 0,void 0,(function*(){this.reset();const r=yield this.attachStreamToVideo(t,e);return yield this.decodeOnce(r)}))}decodeFromInputVideoDeviceContinuously(t,e,r){return H(this,void 0,void 0,(function*(){return yield this.decodeFromVideoDevice(t,e,r)}))}decodeFromVideoDevice(t,e,r){return H(this,void 0,void 0,(function*(){let n;n=t?{deviceId:{exact:t}}:{facingMode:"environment"};const i={video:n};return yield this.decodeFromConstraints(i,e,r)}))}decodeFromConstraints(t,e,r){return H(this,void 0,void 0,(function*(){const n=yield navigator.mediaDevices.getUserMedia(t);return yield this.decodeFromStream(n,e,r)}))}decodeFromStream(t,e,r){return H(this,void 0,void 0,(function*(){this.reset();const n=yield this.attachStreamToVideo(t,e);return yield this.decodeContinuously(n,r)}))}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(t,e){return H(this,void 0,void 0,(function*(){const r=this.prepareVideoElement(e);return this.addVideoSource(r,t),this.videoElement=r,this.stream=t,yield this.playVideoOnLoadAsync(r),r}))}playVideoOnLoadAsync(t){return new Promise(((e,r)=>this.playVideoOnLoad(t,(()=>e()))))}playVideoOnLoad(t,e){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(t),t.addEventListener("ended",this.videoEndedListener),t.addEventListener("canplay",this.videoCanPlayListener),t.addEventListener("playing",e),this.tryPlayVideo(t)}isVideoPlaying(t){return t.currentTime>0&&!t.paused&&!t.ended&&t.readyState>2}tryPlayVideo(t){return H(this,void 0,void 0,(function*(){if(this.isVideoPlaying(t))console.warn("Trying to play video that is already playing.");else try{yield t.play()}catch(e){console.warn("It was not possible to play the video.")}}))}getMediaElement(t,e){const r=document.getElementById(t);if(!r)throw new u(`element with id '${t}' not found`);if(r.nodeName.toLowerCase()!==e.toLowerCase())throw new u(`element with id '${t}' must be an ${e} element`);return r}decodeFromImage(t,e){if(!t&&!e)throw new u("either imageElement with a src set or an url must be provided");return e&&!t?this.decodeFromImageUrl(e):this.decodeFromImageElement(t)}decodeFromVideo(t,e){if(!t&&!e)throw new u("Either an element with a src set or an URL must be provided");return e&&!t?this.decodeFromVideoUrl(e):this.decodeFromVideoElement(t)}decodeFromVideoContinuously(t,e,r){if(void 0===t&&void 0===e)throw new u("Either an element with a src set or an URL must be provided");return e&&!t?this.decodeFromVideoUrlContinuously(e,r):this.decodeFromVideoElementContinuously(t,r)}decodeFromImageElement(t){if(!t)throw new u("An image element must be provided.");this.reset();const e=this.prepareImageElement(t);let r;return this.imageElement=e,r=this.isImageLoaded(e)?this.decodeOnce(e,!1,!0):this._decodeOnLoadImage(e),r}decodeFromVideoElement(t){const e=this._decodeFromVideoElementSetup(t);return this._decodeOnLoadVideo(e)}decodeFromVideoElementContinuously(t,e){const r=this._decodeFromVideoElementSetup(t);return this._decodeOnLoadVideoContinuously(r,e)}_decodeFromVideoElementSetup(t){if(!t)throw new u("A video element must be provided.");this.reset();const e=this.prepareVideoElement(t);return this.videoElement=e,e}decodeFromImageUrl(t){if(!t)throw new u("An URL must be provided.");this.reset();const e=this.prepareImageElement();this.imageElement=e;const r=this._decodeOnLoadImage(e);return e.src=t,r}decodeFromVideoUrl(t){if(!t)throw new u("An URL must be provided.");this.reset();const e=this.prepareVideoElement(),r=this.decodeFromVideoElement(e);return e.src=t,r}decodeFromVideoUrlContinuously(t,e){if(!t)throw new u("An URL must be provided.");this.reset();const r=this.prepareVideoElement(),n=this.decodeFromVideoElementContinuously(r,e);return r.src=t,n}_decodeOnLoadImage(t){return new Promise(((e,r)=>{this.imageLoadedListener=()=>this.decodeOnce(t,!1,!0).then(e,r),t.addEventListener("load",this.imageLoadedListener)}))}_decodeOnLoadVideo(t){return H(this,void 0,void 0,(function*(){return yield this.playVideoOnLoadAsync(t),yield this.decodeOnce(t)}))}_decodeOnLoadVideoContinuously(t,e){return H(this,void 0,void 0,(function*(){yield this.playVideoOnLoadAsync(t),this.decodeContinuously(t,e)}))}isImageLoaded(t){return!!t.complete&&0!==t.naturalWidth}prepareImageElement(t){let e;return void 0===t&&(e=document.createElement("img"),e.width=200,e.height=200),"string"==typeof t&&(e=this.getMediaElement(t,"img")),t instanceof HTMLImageElement&&(e=t),e}prepareVideoElement(t){let e;return t||"undefined"==typeof document||(e=document.createElement("video"),e.width=200,e.height=200),"string"==typeof t&&(e=this.getMediaElement(t,"video")),t instanceof HTMLVideoElement&&(e=t),e.setAttribute("autoplay","true"),e.setAttribute("muted","true"),e.setAttribute("playsinline","true"),e}decodeOnce(t,e=!0,r=!0){this._stopAsyncDecode=!1;const n=(i,o)=>{if(this._stopAsyncDecode)return o(new P("Video stream has ended before any code could be detected.")),void(this._stopAsyncDecode=void 0);try{i(this.decode(t))}catch(s){const t=(s instanceof g||s instanceof R)&&r;if(e&&s instanceof P||t)return setTimeout(n,this._timeBetweenDecodingAttempts,i,o);o(s)}};return new Promise(((t,e)=>n(t,e)))}decodeContinuously(t,e){this._stopContinuousDecode=!1;const r=()=>{if(this._stopContinuousDecode)this._stopContinuousDecode=void 0;else try{const n=this.decode(t);e(n,null),setTimeout(r,this.timeBetweenScansMillis)}catch(n){e(null,n);const t=n instanceof P;(n instanceof g||n instanceof R||t)&&setTimeout(r,this._timeBetweenDecodingAttempts)}};r()}decode(t){const e=this.createBinaryBitmap(t);return this.decodeBitmap(e)}_isHTMLVideoElement(t){return 0!==t.videoWidth}drawFrameOnCanvas(t,e,r){e||(e={sx:0,sy:0,sWidth:t.videoWidth,sHeight:t.videoHeight,dx:0,dy:0,dWidth:t.videoWidth,dHeight:t.videoHeight}),r||(r=this.captureCanvasContext),r.drawImage(t,e.sx,e.sy,e.sWidth,e.sHeight,e.dx,e.dy,e.dWidth,e.dHeight)}drawImageOnCanvas(t,e,r=this.captureCanvasContext){e||(e={sx:0,sy:0,sWidth:t.naturalWidth,sHeight:t.naturalHeight,dx:0,dy:0,dWidth:t.naturalWidth,dHeight:t.naturalHeight}),r||(r=this.captureCanvasContext),r.drawImage(t,e.sx,e.sy,e.sWidth,e.sHeight,e.dx,e.dy,e.dWidth,e.dHeight)}createBinaryBitmap(t){this.getCaptureCanvasContext(t),this._isHTMLVideoElement(t)?this.drawFrameOnCanvas(t):this.drawImageOnCanvas(t);const e=this.getCaptureCanvas(t),r=new k(e),n=new v(r);return new f(n)}getCaptureCanvasContext(t){if(!this.captureCanvasContext){const e=this.getCaptureCanvas(t).getContext("2d");this.captureCanvasContext=e}return this.captureCanvasContext}getCaptureCanvas(t){if(!this.captureCanvas){const e=this.createCaptureCanvas(t);this.captureCanvas=e}return this.captureCanvas}decodeBitmap(t){return this.reader.decode(t,this._hints)}createCaptureCanvas(t){if("undefined"==typeof document)return this._destroyCaptureCanvas(),null;const e=document.createElement("canvas");let r,n;return void 0!==t&&(t instanceof HTMLVideoElement?(r=t.videoWidth,n=t.videoHeight):t instanceof HTMLImageElement&&(r=t.naturalWidth||t.width,n=t.naturalHeight||t.height)),e.style.width=r+"px",e.style.height=n+"px",e.width=r,e.height=n,e}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach((t=>t.stop())),this.stream=void 0),!1===this._stopAsyncDecode&&this.stopAsyncDecode(),!1===this._stopContinuousDecode&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(void 0!==this.videoEndedListener&&this.videoElement.removeEventListener("ended",this.videoEndedListener),void 0!==this.videoPlayingEventListener&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),void 0!==this.videoCanPlayListener&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(void 0!==this.imageLoadedListener&&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(t,e){try{t.srcObject=e}catch(r){t.src=URL.createObjectURL(e)}}cleanVideoSource(t){try{t.srcObject=null}catch(e){t.src=""}this.videoElement.removeAttribute("src")}}class X{constructor(t,e,r=(null==e?0:8*e.length),n,i,o=m.currentTimeMillis()){this.text=t,this.rawBytes=e,this.numBits=r,this.resultPoints=n,this.format=i,this.timestamp=o,this.text=t,this.rawBytes=e,this.numBits=null==r?null==e?0:8*e.length:r,this.resultPoints=n,this.format=i,this.resultMetadata=null,this.timestamp=null==o?m.currentTimeMillis():o}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(t,e){null===this.resultMetadata&&(this.resultMetadata=new Map),this.resultMetadata.set(t,e)}putAllMetadata(t){null!==t&&(null===this.resultMetadata?this.resultMetadata=t:this.resultMetadata=new Map(t))}addResultPoints(t){const e=this.resultPoints;if(null===e)this.resultPoints=t;else if(null!==t&&t.length>0){const r=new Array(e.length+t.length);m.arraycopy(e,0,r,0,e.length),m.arraycopy(t,0,r,e.length,t.length),this.resultPoints=r}}getTimestamp(){return this.timestamp}toString(){return this.text}}(V=U||(U={}))[V.AZTEC=0]="AZTEC",V[V.CODABAR=1]="CODABAR",V[V.CODE_39=2]="CODE_39",V[V.CODE_93=3]="CODE_93",V[V.CODE_128=4]="CODE_128",V[V.DATA_MATRIX=5]="DATA_MATRIX",V[V.EAN_8=6]="EAN_8",V[V.EAN_13=7]="EAN_13",V[V.ITF=8]="ITF",V[V.MAXICODE=9]="MAXICODE",V[V.PDF_417=10]="PDF_417",V[V.QR_CODE=11]="QR_CODE",V[V.RSS_14=12]="RSS_14",V[V.RSS_EXPANDED=13]="RSS_EXPANDED",V[V.UPC_A=14]="UPC_A",V[V.UPC_E=15]="UPC_E",V[V.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION";var W,z,Y=U;(z=W||(W={}))[z.OTHER=0]="OTHER",z[z.ORIENTATION=1]="ORIENTATION",z[z.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",z[z.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",z[z.ISSUE_NUMBER=4]="ISSUE_NUMBER",z[z.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",z[z.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",z[z.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",z[z.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",z[z.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",z[z.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY";var Z,K,q,Q,j,J,$,tt,et,rt,nt,it=W;class ot{constructor(t,e,r,n,i=-1,o=-1){this.rawBytes=t,this.text=e,this.byteSegments=r,this.ecLevel=n,this.structuredAppendSequenceNumber=i,this.structuredAppendParity=o,this.numBits=null==t?0:8*t.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(t){this.numBits=t}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(t){this.errorsCorrected=t}getErasures(){return this.erasures}setErasures(t){this.erasures=t}getOther(){return this.other}setOther(t){this.other=t}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class st{exp(t){return this.expTable[t]}log(t){if(0===t)throw new d;return this.logTable[t]}static addOrSubtract(t,e){return t^e}}class at{constructor(t,e){if(0===e.length)throw new d;this.field=t;const r=e.length;if(r>1&&0===e[0]){let t=1;for(;tr.length){const t=e;e=r,r=t}let n=new Int32Array(r.length);const i=r.length-e.length;m.arraycopy(r,0,n,0,i);for(let o=i;o=t.getDegree()&&!n.isZero();){const i=n.getDegree()-t.getDegree(),s=e.multiply(n.getCoefficient(n.getDegree()),o),a=t.multiplyByMonomial(i,s),l=e.buildMonomial(i,s);r=r.addOrSubtract(l),n=n.addOrSubtract(a)}return[r,n]}toString(){let t="";for(let e=this.getDegree();e>=0;e--){let r=this.getCoefficient(e);if(0!==r){if(r<0?(t+=" - ",r=-r):t.length>0&&(t+=" + "),0===e||1!==r){const e=this.field.log(r);0===e?t+="1":1===e?t+="a":(t+="a^",t+=e)}0!==e&&(1===e?t+="x":(t+="x^",t+=e))}}return t}}class lt extends h{}lt.kind="ArithmeticException";class ct extends st{constructor(t,e,r){super(),this.primitive=t,this.size=e,this.generatorBase=r;const n=new Int32Array(e);let i=1;for(let s=0;s=e&&(i^=t,i&=e-1);this.expTable=n;const o=new Int32Array(e);for(let s=0;s=(r/2|0);){let t=i,e=s;if(i=o,s=a,i.isZero())throw new ht("r_{i-1} was zero");o=t;let r=n.getZero();const l=i.getCoefficient(i.getDegree()),c=n.inverse(l);for(;o.getDegree()>=i.getDegree()&&!o.isZero();){const t=o.getDegree()-i.getDegree(),e=n.multiply(o.getCoefficient(o.getDegree()),c);r=r.addOrSubtract(n.buildMonomial(t,e)),o=o.addOrSubtract(i.multiplyByMonomial(t,e))}if(a=r.multiply(s).addOrSubtract(e),o.getDegree()>=i.getDegree())throw new ut("Division algorithm failed to reduce polynomial?")}const l=a.getCoefficient(0);if(0===l)throw new ht("sigmaTilde(0) was zero");const c=n.inverse(l);return[a.multiplyScalar(c),o.multiplyScalar(c)]}findErrorLocations(t){const e=t.getDegree();if(1===e)return Int32Array.from([t.getCoefficient(1)]);const r=new Int32Array(e);let n=0;const i=this.field;for(let o=1;o1,h,h+r-1),h+=r-1;else for(let e=r-1;e>=0;--e)c[h++]=0!=(t&1<=8?ft.readCode(t,e,8):ft.readCode(t,e,r)<<8-r}static convertBoolArrayToByteArray(t){let e=new Uint8Array((t.length+7)/8);for(let r=0;r","?","[","]","{","}","CTRL_UL"],ft.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class gt{constructor(){}static round(t){return NaN===t?0:t<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:t>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:t+(t<0?-.5:.5)|0}static distance(t,e,r,n){const i=t-r,o=e-n;return Math.sqrt(i*i+o*o)}static sum(t){let e=0;for(let r=0,n=t.length;r!==n;r++)e+=t[r];return e}}class wt{static floatToIntBits(t){return t}}wt.MAX_VALUE=Number.MAX_SAFE_INTEGER;class mt{constructor(t,e){this.x=t,this.y=e}getX(){return this.x}getY(){return this.y}equals(t){if(t instanceof mt){const e=t;return this.x===e.x&&this.y===e.y}return!1}hashCode(){return 31*wt.floatToIntBits(this.x)+wt.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(t){const e=this.distance(t[0],t[1]),r=this.distance(t[1],t[2]),n=this.distance(t[0],t[2]);let i,o,s;if(r>=e&&r>=n?(o=t[0],i=t[1],s=t[2]):n>=r&&n>=e?(o=t[1],i=t[0],s=t[2]):(o=t[2],i=t[0],s=t[1]),this.crossProductZ(i,o,s)<0){const t=i;i=s,s=t}t[0]=i,t[1]=o,t[2]=s}static distance(t,e){return gt.distance(t.x,t.y,e.x,e.y)}static crossProductZ(t,e,r){const n=e.x,i=e.y;return(r.x-n)*(t.y-i)-(r.y-i)*(t.x-n)}}class At{constructor(t,e){this.bits=t,this.points=e}getBits(){return this.bits}getPoints(){return this.points}}class Ct extends At{constructor(t,e,r,n,i){super(t,e),this.compact=r,this.nbDatablocks=n,this.nbLayers=i}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class Et{constructor(t,e,r,n){this.image=t,this.height=t.getHeight(),this.width=t.getWidth(),null==e&&(e=Et.INIT_SIZE),null==r&&(r=t.getWidth()/2|0),null==n&&(n=t.getHeight()/2|0);const i=e/2|0;if(this.leftInit=r-i,this.rightInit=r+i,this.upInit=n-i,this.downInit=n+i,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new P}detect(){let t=this.leftInit,e=this.rightInit,r=this.upInit,n=this.downInit,i=!1,o=!0,s=!1,a=!1,l=!1,c=!1,h=!1;const u=this.width,d=this.height;for(;o;){o=!1;let f=!0;for(;(f||!a)&&e=u){i=!0;break}let g=!0;for(;(g||!l)&&n=d){i=!0;break}let w=!0;for(;(w||!c)&&t>=0;)w=this.containsBlackPoint(r,n,t,!1),w?(t--,o=!0,c=!0):c||t--;if(t<0){i=!0;break}let m=!0;for(;(m||!h)&&r>=0;)m=this.containsBlackPoint(t,e,r,!0),m?(r--,o=!0,h=!0):h||r--;if(r<0){i=!0;break}o&&(s=!0)}if(!i&&s){const i=e-t;let o=null;for(let e=1;null===o&&er||s<-1||s>n)throw new P;i=!1,-1===t?(e[o]=0,i=!0):t===r&&(e[o]=r-1,i=!0),-1===s?(e[o+1]=0,i=!0):s===n&&(e[o+1]=n-1,i=!0)}i=!0;for(let o=e.length-2;o>=0&&i;o-=2){const t=Math.floor(e[o]),s=Math.floor(e[o+1]);if(t<-1||t>r||s<-1||s>n)throw new P;i=!1,-1===t?(e[o]=0,i=!0):t===r&&(e[o]=r-1,i=!0),-1===s?(e[o+1]=0,i=!0):s===n&&(e[o+1]=n-1,i=!0)}}}class pt{constructor(t,e,r,n,i,o,s,a,l){this.a11=t,this.a21=e,this.a31=r,this.a12=n,this.a22=i,this.a32=o,this.a13=s,this.a23=a,this.a33=l}static quadrilateralToQuadrilateral(t,e,r,n,i,o,s,a,l,c,h,u,d,f,g,w){const m=pt.quadrilateralToSquare(t,e,r,n,i,o,s,a);return pt.squareToQuadrilateral(l,c,h,u,d,f,g,w).times(m)}transformPoints(t){const e=t.length,r=this.a11,n=this.a12,i=this.a13,o=this.a21,s=this.a22,a=this.a23,l=this.a31,c=this.a32,h=this.a33;for(let u=0;u>1&127):(n<<=10,n+=(t>>2&992)+(t>>1&31))}let i=this.getCorrectedParameterData(n,this.compact);this.compact?(this.nbLayers=1+(i>>6),this.nbDataBlocks=1+(63&i)):(this.nbLayers=1+(i>>11),this.nbDataBlocks=1+(2047&i))}getRotation(t,e){let r=0;t.forEach(((t,n,i)=>{r=(t>>e-2<<1)+(1&t)+(r<<3)})),r=((1&r)<<11)+(r>>1);for(let n=0;n<4;n++)if(_.bitCount(r^this.EXPECTED_CORNER_BITS[n])<=2)return n;throw new P}getCorrectedParameterData(t,e){let r,n;e?(r=7,n=2):(r=10,n=4);let i=r-n,o=new Int32Array(r);for(let l=r-1;l>=0;--l)o[l]=15&t,t>>=4;try{new dt(ct.AZTEC_PARAM).decode(o,i)}catch(a){throw new P}let s=0;for(let l=0;l2){let r=this.distancePoint(l,t)*this.nbCenterLayers/(this.distancePoint(i,e)*(this.nbCenterLayers+2));if(r<.75||r>1.25||!this.isWhiteOrBlackRectangle(t,s,a,l))break}e=t,r=s,n=a,i=l,o=!o}if(5!==this.nbCenterLayers&&7!==this.nbCenterLayers)throw new P;this.compact=5===this.nbCenterLayers;let s=new mt(e.getX()+.5,e.getY()-.5),a=new mt(r.getX()+.5,r.getY()+.5),l=new mt(n.getX()-.5,n.getY()+.5),c=new mt(i.getX()-.5,i.getY()-.5);return this.expandSquare([s,a,l,c],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let t,e,r,n;try{let i=new Et(this.image).detect();t=i[0],e=i[1],r=i[2],n=i[3]}catch(s){let i=this.image.getWidth()/2,o=this.image.getHeight()/2;t=this.getFirstDifferent(new Tt(i+7,o-7),!1,1,-1).toResultPoint(),e=this.getFirstDifferent(new Tt(i+7,o+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new Tt(i-7,o+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new Tt(i-7,o-7),!1,-1,-1).toResultPoint()}let i=gt.round((t.getX()+n.getX()+e.getX()+r.getX())/4),o=gt.round((t.getY()+n.getY()+e.getY()+r.getY())/4);try{let s=new Et(this.image,15,i,o).detect();t=s[0],e=s[1],r=s[2],n=s[3]}catch(s){t=this.getFirstDifferent(new Tt(i+7,o-7),!1,1,-1).toResultPoint(),e=this.getFirstDifferent(new Tt(i+7,o+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new Tt(i-7,o+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new Tt(i-7,o-7),!1,-1,-1).toResultPoint()}return i=gt.round((t.getX()+n.getX()+e.getX()+r.getX())/4),o=gt.round((t.getY()+n.getY()+e.getY()+r.getY())/4),new Tt(i,o)}getMatrixCornerPoints(t){return this.expandSquare(t,2*this.nbCenterLayers,this.getDimension())}sampleGrid(t,e,r,n,i){let o=St.getInstance(),s=this.getDimension(),a=s/2-this.nbCenterLayers,l=s/2+this.nbCenterLayers;return o.sampleGrid(t,s,s,a,a,l,a,l,l,a,l,e.getX(),e.getY(),r.getX(),r.getY(),n.getX(),n.getY(),i.getX(),i.getY())}sampleLine(t,e,r){let n=0,i=this.distanceResultPoint(t,e),o=i/r,s=t.getX(),a=t.getY(),l=o*(e.getX()-t.getX())/i,c=o*(e.getY()-t.getY())/i;for(let h=0;h.1&&h<.9?0:h<=.1===l?1:-1}getFirstDifferent(t,e,r,n){let i=t.getX()+r,o=t.getY()+n;for(;this.isValid(i,o)&&this.image.get(i,o)===e;)i+=r,o+=n;for(i-=r,o-=n;this.isValid(i,o)&&this.image.get(i,o)===e;)i+=r;for(i-=r;this.isValid(i,o)&&this.image.get(i,o)===e;)o+=n;return o-=n,new Tt(i,o)}expandSquare(t,e,r){let n=r/(2*e),i=t[0].getX()-t[2].getX(),o=t[0].getY()-t[2].getY(),s=(t[0].getX()+t[2].getX())/2,a=(t[0].getY()+t[2].getY())/2,l=new mt(s+n*i,a+n*o),c=new mt(s-n*i,a-n*o);return i=t[1].getX()-t[3].getX(),o=t[1].getY()-t[3].getY(),s=(t[1].getX()+t[3].getX())/2,a=(t[1].getY()+t[3].getY())/2,[l,new mt(s+n*i,a+n*o),c,new mt(s-n*i,a-n*o)]}isValid(t,e){return t>=0&&t0&&e{r.foundPossibleResultPoint(t)}))}}reset(){}}class Nt extends G{constructor(t=500){super(new yt,t)}}class Dt{decode(t,e){try{return this.doDecode(t,e)}catch(r){if(e&&!0===e.get(T.TRY_HARDER)&&t.isRotateSupported()){const r=t.rotateCounterClockwise(),n=this.doDecode(r,e),i=n.getResultMetadata();let o=270;null!==i&&!0===i.get(it.ORIENTATION)&&(o+=i.get(it.ORIENTATION)%360),n.putMetadata(it.ORIENTATION,o);const s=n.getResultPoints();if(null!==s){const t=r.getHeight();for(let e=0;e>(o?8:5));let a;a=o?n:15;const l=Math.trunc(n/2);for(let u=0;u=n)break;try{i=t.getBlackRow(a,i)}catch(c){continue}for(let t=0;t<2;t++){if(1===t&&(i.reverse(),e&&!0===e.get(T.NEED_RESULT_POINT_CALLBACK))){const t=new Map;e.forEach(((e,r)=>t.set(r,e))),t.delete(T.NEED_RESULT_POINT_CALLBACK),e=t}try{const n=this.decodeRow(a,i,e);if(1===t){n.putMetadata(it.ORIENTATION,180);const t=n.getResultPoints();null!==t&&(t[0]=new mt(r-t[0].getX()-1,t[0].getY()),t[1]=new mt(r-t[1].getX()-1,t[1].getY()))}return n}catch(h){}}}throw new P}static recordPattern(t,e,r){const n=r.length;for(let l=0;l=i)throw new P;let o=!t.get(e),s=0,a=e;for(;a0&&n>=0;)t.get(--e)!==i&&(n--,i=!i);if(n>=0)throw new P;Dt.recordPattern(t,e+1,r)}static patternMatchVariance(t,e,r){const n=t.length;let i=0,o=0;for(let l=0;li?n-i:i-n;if(o>r)return Number.POSITIVE_INFINITY;a+=o}return a/i}}class Ot extends Dt{static findStartPattern(t){const e=t.getSize(),r=t.getNextSet(0);let n=0,i=Int32Array.from([0,0,0,0,0,0]),o=r,s=!1;const a=6;for(let l=r;l=0&&t.isRange(Math.max(0,o-(l-o)/2),o,!1))return Int32Array.from([o,l,r]);o+=i[0]+i[1],i=i.slice(2,i.length-1),i[n-1]=0,i[n]=0,n--}else n++;i[n]=1,s=!s}throw new P}static decodeCode(t,e,r){Dt.recordPattern(t,r,e);let n=Ot.MAX_AVG_VARIANCE,i=-1;for(let o=0;o=0)return i;throw new P}decodeRow(t,e,r){const n=r&&!0===r.get(T.ASSUME_GS1),i=Ot.findStartPattern(e),o=i[2];let s=0;const a=new Uint8Array(20);let l;switch(a[s++]=o,o){case Ot.CODE_START_A:l=Ot.CODE_CODE_A;break;case Ot.CODE_START_B:l=Ot.CODE_CODE_B;break;case Ot.CODE_START_C:l=Ot.CODE_CODE_C;break;default:throw new R}let c=!1,h=!1,u="",d=i[0],f=i[1];const w=Int32Array.from([0,0,0,0,0,0]);let m=0,A=0,C=o,E=0,_=!0,p=!1,I=!1;for(;!c;){const t=h;switch(h=!1,m=A,A=Ot.decodeCode(e,w,f),a[s++]=A,A!==Ot.CODE_STOP&&(_=!0),A!==Ot.CODE_STOP&&(E++,C+=E*A),d=f,f+=w.reduce(((t,e)=>t+e),0),A){case Ot.CODE_START_A:case Ot.CODE_START_B:case Ot.CODE_START_C:throw new R}switch(l){case Ot.CODE_CODE_A:if(A<64)u+=I===p?String.fromCharCode(" ".charCodeAt(0)+A):String.fromCharCode(" ".charCodeAt(0)+A+128),I=!1;else if(A<96)u+=I===p?String.fromCharCode(A-64):String.fromCharCode(A+64),I=!1;else switch(A!==Ot.CODE_STOP&&(_=!1),A){case Ot.CODE_FNC_1:n&&(0===u.length?u+="]C1":u+=String.fromCharCode(29));break;case Ot.CODE_FNC_2:case Ot.CODE_FNC_3:break;case Ot.CODE_FNC_4_A:!p&&I?(p=!0,I=!1):p&&I?(p=!1,I=!1):I=!0;break;case Ot.CODE_SHIFT:h=!0,l=Ot.CODE_CODE_B;break;case Ot.CODE_CODE_B:l=Ot.CODE_CODE_B;break;case Ot.CODE_CODE_C:l=Ot.CODE_CODE_C;break;case Ot.CODE_STOP:c=!0}break;case Ot.CODE_CODE_B:if(A<96)u+=I===p?String.fromCharCode(" ".charCodeAt(0)+A):String.fromCharCode(" ".charCodeAt(0)+A+128),I=!1;else switch(A!==Ot.CODE_STOP&&(_=!1),A){case Ot.CODE_FNC_1:n&&(0===u.length?u+="]C1":u+=String.fromCharCode(29));break;case Ot.CODE_FNC_2:case Ot.CODE_FNC_3:break;case Ot.CODE_FNC_4_B:!p&&I?(p=!0,I=!1):p&&I?(p=!1,I=!1):I=!0;break;case Ot.CODE_SHIFT:h=!0,l=Ot.CODE_CODE_A;break;case Ot.CODE_CODE_A:l=Ot.CODE_CODE_A;break;case Ot.CODE_CODE_C:l=Ot.CODE_CODE_C;break;case Ot.CODE_STOP:c=!0}break;case Ot.CODE_CODE_C:if(A<100)A<10&&(u+="0"),u+=A;else switch(A!==Ot.CODE_STOP&&(_=!1),A){case Ot.CODE_FNC_1:n&&(0===u.length?u+="]C1":u+=String.fromCharCode(29));break;case Ot.CODE_CODE_A:l=Ot.CODE_CODE_A;break;case Ot.CODE_CODE_B:l=Ot.CODE_CODE_B;break;case Ot.CODE_STOP:c=!0}}t&&(l=l===Ot.CODE_CODE_A?Ot.CODE_CODE_B:Ot.CODE_CODE_A)}const S=f-d;if(f=e.getNextUnset(f),!e.isRange(f,Math.min(e.getSize(),f+(f-d)/2),!1))throw new P;if(C-=E*m,C%103!==m)throw new g;const y=u.length;if(0===y)throw new P;y>0&&_&&(u=l===Ot.CODE_CODE_C?u.substring(0,y-2):u.substring(0,y-1));const N=(i[1]+i[0])/2,D=d+S/2,O=a.length,b=new Uint8Array(O);for(let g=0;gn&&(i=e);n=i,e=0;let o=0,s=0;for(let a=0;an&&(s|=1<0;i++){let r=t[i];if(r>n&&(e--,2*r>=o))return-1}return s}}while(e>3);return-1}static patternToChar(t){for(let e=0;e="A"&&i<="Z"))throw new R;o=String.fromCharCode(i.charCodeAt(0)+32);break;case"$":if(!(i>="A"&&i<="Z"))throw new R;o=String.fromCharCode(i.charCodeAt(0)-64);break;case"%":if(i>="A"&&i<="E")o=String.fromCharCode(i.charCodeAt(0)-38);else if(i>="F"&&i<="J")o=String.fromCharCode(i.charCodeAt(0)-11);else if(i>="K"&&i<="O")o=String.fromCharCode(i.charCodeAt(0)+16);else if(i>="P"&&i<="T")o=String.fromCharCode(i.charCodeAt(0)+43);else if("U"===i)o="\0";else if("V"===i)o="@";else if("W"===i)o="`";else{if("X"!==i&&"Y"!==i&&"Z"!==i)throw new R;o=""}break;case"/":if(i>="A"&&i<="O")o=String.fromCharCode(i.charCodeAt(0)-32);else{if("Z"!==i)throw new R;o=":"}}r+=o,n++}else r+=e}return r}}bt.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",bt.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],bt.ASTERISK_ENCODING=148;class Mt extends Dt{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(t,e,r){let n=this.decodeStart(e),i=this.decodeEnd(e),o=new b;Mt.decodeMiddle(e,n[1],i[0],o);let s=o.toString(),a=null;null!=r&&(a=r.get(T.ALLOWED_LENGTHS)),null==a&&(a=Mt.DEFAULT_ALLOWED_LENGTHS);let l=s.length,c=!1,h=0;for(let d of a){if(l===d){c=!0;break}d>h&&(h=d)}if(!c&&l>h&&(c=!0),!c)throw new R;const u=[new mt(n[1],t),new mt(i[0],t)];return new X(s,null,0,u,Y.ITF,(new Date).getTime())}static decodeMiddle(t,e,r,n){let i=new Int32Array(10),o=new Int32Array(5),s=new Int32Array(5);for(i.fill(0),o.fill(0),s.fill(0);e0&&n>=0&&!t.get(n);n--)r--;if(0!==r)throw new P}static skipWhiteSpace(t){const e=t.getSize(),r=t.getNextSet(0);if(r===e)throw new P;return r}decodeEnd(t){t.reverse();try{let r,n=Mt.skipWhiteSpace(t);try{r=Mt.findGuardPattern(t,n,Mt.END_PATTERN_REVERSED[0])}catch(e){e instanceof P&&(r=Mt.findGuardPattern(t,n,Mt.END_PATTERN_REVERSED[1]))}this.validateQuietZone(t,r[0]);let i=r[0];return r[0]=t.getSize()-r[1],r[1]=t.getSize()-i,r}finally{t.reverse()}}static findGuardPattern(t,e,r){let n=r.length,i=new Int32Array(n),o=t.getSize(),s=!1,a=0,l=e;i.fill(0);for(let c=e;c=0)return r%10;throw new P}}Mt.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])],Mt.MAX_AVG_VARIANCE=.38,Mt.MAX_INDIVIDUAL_VARIANCE=.5,Mt.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],Mt.START_PATTERN=Int32Array.from([1,1,1,1]),Mt.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Pt extends Dt{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(t){let e,r=!1,n=0,i=Int32Array.from([0,0,0]);for(;!r;){i=Int32Array.from([0,0,0]),e=Pt.findGuardPattern(t,n,!1,this.START_END_PATTERN,i);let o=e[0];n=e[1];let s=o-(n-o);s>=0&&(r=t.isRange(s,o,!1))}return e}static checkChecksum(t){return Pt.checkStandardUPCEANChecksum(t)}static checkStandardUPCEANChecksum(t){let e=t.length;if(0===e)return!1;let r=parseInt(t.charAt(e-1),10);return Pt.getStandardUPCEANChecksum(t.substring(0,e-1))===r}static getStandardUPCEANChecksum(t){let e=t.length,r=0;for(let n=e-1;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new R;r+=e}r*=3;for(let n=e-2;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new R;r+=e}return(1e3-r)%10}static decodeEnd(t,e){return Pt.findGuardPattern(t,e,!1,Pt.START_END_PATTERN,new Int32Array(Pt.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(t,e,r,n){return this.findGuardPattern(t,e,r,n,new Int32Array(n.length))}static findGuardPattern(t,e,r,n,i){let o=t.getSize(),s=0,a=e=r?t.getNextUnset(e):t.getNextSet(e),l=n.length,c=r;for(let h=e;h=0)return o;throw new P}}Pt.MAX_AVG_VARIANCE=.48,Pt.MAX_INDIVIDUAL_VARIANCE=.7,Pt.START_END_PATTERN=Int32Array.from([1,1,1]),Pt.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Pt.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Pt.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 Bt{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(t,e,r){let n=this.decodeRowStringBuffer,i=this.decodeMiddle(e,r,n),o=n.toString(),s=Bt.parseExtensionString(o),a=[new mt((r[0]+r[1])/2,t),new mt(i,t)],l=new X(o,null,0,a,Y.UPC_EAN_EXTENSION,(new Date).getTime());return null!=s&&l.putAllMetadata(s),l}decodeMiddle(t,e,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1],s=0;for(let l=0;l<5&&o=10&&(s|=1<<4-l),4!==l&&(o=t.getNextSet(o),o=t.getNextUnset(o))}if(5!==r.length)throw new P;let a=this.determineCheckDigit(s);if(Bt.extensionChecksum(r.toString())!==a)throw new P;return o}static extensionChecksum(t){let e=t.length,r=0;for(let n=e-2;n>=0;n-=2)r+=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);r*=3;for(let n=e-1;n>=0;n-=2)r+=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);return r*=3,r%10}determineCheckDigit(t){for(let e=0;e<10;e++)if(t===this.CHECK_DIGIT_ENCODINGS[e])return e;throw new P}static parseExtensionString(t){if(5!==t.length)return null;let e=Bt.parseExtension5String(t);return null==e?null:new Map([[it.SUGGESTED_PRICE,e]])}static parseExtension5String(t){let e;switch(t.charAt(0)){case"0":e="£";break;case"5":e="$";break;case"9":switch(t){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}e="";break;default:e=""}let r=parseInt(t.substring(1)),n=r%100;return e+(r/100).toString()+"."+(n<10?"0"+n:n.toString())}}class vt{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(t,e,r){let n=this.decodeRowStringBuffer,i=this.decodeMiddle(e,r,n),o=n.toString(),s=vt.parseExtensionString(o),a=[new mt((r[0]+r[1])/2,t),new mt(i,t)],l=new X(o,null,0,a,Y.UPC_EAN_EXTENSION,(new Date).getTime());return null!=s&&l.putAllMetadata(s),l}decodeMiddle(t,e,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1],s=0;for(let a=0;a<2&&o=10&&(s|=1<<1-a),1!==a&&(o=t.getNextSet(o),o=t.getNextUnset(o))}if(2!==r.length)throw new P;if(parseInt(r.toString())%4!==s)throw new P;return o}static parseExtensionString(t){return 2!==t.length?null:new Map([[it.ISSUE_NUMBER,parseInt(t)]])}}class Lt{static decodeRow(t,e,r){let n=Pt.findGuardPattern(e,r,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return(new Bt).decodeRow(t,e,n)}catch(i){return(new vt).decodeRow(t,e,n)}}}Lt.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Ft extends Pt{constructor(){super(),this.decodeRowStringBuffer="",Ft.L_AND_G_PATTERNS=Ft.L_PATTERNS.map((t=>Int32Array.from(t)));for(let t=10;t<20;t++){let e=Ft.L_PATTERNS[t-10],r=new Int32Array(e.length);for(let t=0;t=e.getSize()||!e.isRange(c,h,!1))throw new P;let u=a.toString();if(u.length<8)throw new R;if(!Ft.checkChecksum(u))throw new g;let d=(n[1]+n[0])/2,f=(l[1]+l[0])/2,w=this.getBarcodeFormat(),m=[new mt(d,t),new mt(f,t)],A=new X(u,null,0,m,w,(new Date).getTime()),C=0;try{let r=Lt.decodeRow(t,e,l[1]);A.putMetadata(it.UPC_EAN_EXTENSION,r.getText()),A.putAllMetadata(r.getResultMetadata()),A.addResultPoints(r.getResultPoints()),C=r.getText().length}catch(_){}let E=null==r?null:r.get(T.ALLOWED_EAN_EXTENSIONS);if(null!=E){let t=!1;for(let e in E)if(C.toString()===e){t=!0;break}if(!t)throw new P}return A}decodeEnd(t,e){return Ft.findGuardPattern(t,e,!1,Ft.START_END_PATTERN,new Int32Array(Ft.START_END_PATTERN.length).fill(0))}static checkChecksum(t){return Ft.checkStandardUPCEANChecksum(t)}static checkStandardUPCEANChecksum(t){let e=t.length;if(0===e)return!1;let r=parseInt(t.charAt(e-1),10);return Ft.getStandardUPCEANChecksum(t.substring(0,e-1))===r}static getStandardUPCEANChecksum(t){let e=t.length,r=0;for(let n=e-1;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new R;r+=e}r*=3;for(let n=e-2;n>=0;n-=2){let e=t.charAt(n).charCodeAt(0)-"0".charCodeAt(0);if(e<0||e>9)throw new R;r+=e}return(1e3-r)%10}}class kt extends Ft{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(t,e,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=t.getSize(),o=e[1],s=0;for(let a=0;a<6&&o=10&&(s|=1<<5-a)}r=kt.determineFirstDigit(r,s),o=Ft.findGuardPattern(t,o,!0,Ft.MIDDLE_PATTERN,new Int32Array(Ft.MIDDLE_PATTERN.length).fill(0))[1];for(let a=0;a<6&&ot));n[0]=0,n[1]=0,n[2]=0,n[3]=0;const i=t.getSize();let o=e[1],s=0;for(let a=0;a<6&&o=10&&(s|=1<<5-a)}return{rowOffset:o,resultString:Vt.determineNumSysAndCheckDigit(r,s)}}decodeEnd(t,e){return Vt.findGuardPatternWithoutCounters(t,e,!0,Vt.MIDDLE_END_PATTERN)}checkChecksum(t){return Ft.checkChecksum(Vt.convertUPCEtoUPCA(t))}static determineNumSysAndCheckDigit(t,e){for(let r=0;r<=1;r++)for(let n=0;n<10;n++)if(e===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[r][n])return String.fromCharCode("0".charCodeAt(0)+r)+t+String.fromCharCode("0".charCodeAt(0)+n);throw P.getNotFoundInstance()}getBarcodeFormat(){return Y.UPC_E}static convertUPCEtoUPCA(t){const e=t.slice(1,7).split("").map((t=>t.charCodeAt(0))),r=new b;r.append(t.charAt(0));let n=e[5];switch(n){case 0:case 1:case 2:r.appendChars(e,0,2),r.append(n),r.append("0000"),r.appendChars(e,2,3);break;case 3:r.appendChars(e,0,3),r.append("00000"),r.appendChars(e,3,2);break;case 4:r.appendChars(e,0,4),r.append("00000"),r.append(e[4]);break;default:r.appendChars(e,0,5),r.append("0000"),r.append(n)}return t.length>=8&&r.append(t.charAt(7)),r.toString()}}Vt.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Vt.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 Ht extends Dt{constructor(t){super();let e=null==t?null:t.get(T.POSSIBLE_FORMATS),n=[];r(e)?(n.push(new kt),n.push(new Ut),n.push(new xt),n.push(new Vt)):(e.indexOf(Y.EAN_13)>-1&&n.push(new kt),e.indexOf(Y.UPC_A)>-1&&n.push(new Ut),e.indexOf(Y.EAN_8)>-1&&n.push(new xt),e.indexOf(Y.UPC_E)>-1&&n.push(new Vt)),this.readers=n}decodeRow(t,e,r){for(let i of this.readers)try{const n=i.decodeRow(t,e,r),o=n.getBarcodeFormat()===Y.EAN_13&&"0"===n.getText().charAt(0),s=null==r?null:r.get(T.POSSIBLE_FORMATS),a=null==s||s.includes(Y.UPC_A);if(o&&a){const t=n.getRawBytes(),e=new X(n.getText().substring(1),t,t?t.length:null,n.getResultPoints(),Y.UPC_A);return e.putAllMetadata(n.getResultMetadata()),e}return n}catch(n){}throw new P}reset(){for(let t of this.readers)t.reset()}}class Gt extends Dt{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(t,e){for(let r=0;rn&&(n=e[i],r=i);t[r]++}static decrement(t,e){let r=0,n=e[0];for(let i=1;i=Gt.MIN_FINDER_PATTERN_RATIO&&r<=Gt.MAX_FINDER_PATTERN_RATIO){let e=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER;for(let n of t)n>r&&(r=n),n=s-a-1&&(t-=zt.combins(n-l-(s-a),s-a-2)),s-a-1>1){let r=0;for(let t=n-l-(s-a-2);t>e;t--)r+=zt.combins(n-l-t-1,s-a-3);t-=r*(s-1-a)}else n-l>e&&t--;i+=t}n-=l}return i}static combins(t,e){let r,n;t-e>e?(n=e,r=t-e):(n=t-e,r=e);let i=1,o=1;for(let s=t;s>r;s--)i*=s,o<=n&&(i/=o,o++);for(;o<=n;)i/=o,o++;return i}}class Yt{static buildBitArray(t){let e=2*t.length-1;null==t[t.length-1].getRightChar()&&(e-=1);let r=new p(12*e),n=0,i=t[0].getRightChar().getValue();for(let o=11;o>=0;--o)0!=(i&1<=0;--t)0!=(i&1<=0;--e)0!=(t&1<10||r<0||r>10)throw new R;this.firstDigit=e,this.secondDigit=r}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return 10*this.firstDigit+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===jt.FNC1}isSecondDigitFNC1(){return this.secondDigit===jt.FNC1}isAnyFNC1(){return this.firstDigit===jt.FNC1||this.secondDigit===jt.FNC1}}jt.FNC1=10;class Jt{constructor(){}static parseFieldsInGeneralPurpose(t){if(!t)return null;if(t.length<2)throw new P;let e=t.substring(0,2);for(let i of Jt.TWO_DIGIT_DATA_LENGTH)if(i[0]===e)return i[1]===Jt.VARIABLE_LENGTH?Jt.processVariableAI(2,i[2],t):Jt.processFixedAI(2,i[1],t);if(t.length<3)throw new P;let r=t.substring(0,3);for(let i of Jt.THREE_DIGIT_DATA_LENGTH)if(i[0]===r)return i[1]===Jt.VARIABLE_LENGTH?Jt.processVariableAI(3,i[2],t):Jt.processFixedAI(3,i[1],t);for(let i of Jt.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(i[0]===r)return i[1]===Jt.VARIABLE_LENGTH?Jt.processVariableAI(4,i[2],t):Jt.processFixedAI(4,i[1],t);if(t.length<4)throw new P;let n=t.substring(0,4);for(let i of Jt.FOUR_DIGIT_DATA_LENGTH)if(i[0]===n)return i[1]===Jt.VARIABLE_LENGTH?Jt.processVariableAI(4,i[2],t):Jt.processFixedAI(4,i[1],t);throw new P}static processFixedAI(t,e,r){if(r.lengththis.information.getSize())return t+4<=this.information.getSize();for(let e=t;ethis.information.getSize()){let e=this.extractNumericValueFromBitArray(t,4);return new jt(this.information.getSize(),0===e?jt.FNC1:e-1,jt.FNC1)}let e=this.extractNumericValueFromBitArray(t,7);return new jt(t+7,(e-8)/11,(e-8)%11)}extractNumericValueFromBitArray(t,e){return $t.extractNumericValueFromBitArray(this.information,t,e)}static extractNumericValueFromBitArray(t,e,r){let n=0;for(let i=0;ithis.information.getSize())return!1;let e=this.extractNumericValueFromBitArray(t,5);if(e>=5&&e<16)return!0;if(t+7>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(t,7);if(r>=64&&r<116)return!0;if(t+8>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(t,8);return n>=232&&n<253}decodeIsoIec646(t){let e=this.extractNumericValueFromBitArray(t,5);if(15===e)return new qt(t+5,qt.FNC1);if(e>=5&&e<15)return new qt(t+5,"0"+(e-5));let r,n=this.extractNumericValueFromBitArray(t,7);if(n>=64&&n<90)return new qt(t+7,""+(n+1));if(n>=90&&n<116)return new qt(t+7,""+(n+7));switch(this.extractNumericValueFromBitArray(t,8)){case 232:r="!";break;case 233:r='"';break;case 234:r="%";break;case 235:r="&";break;case 236:r="'";break;case 237:r="(";break;case 238:r=")";break;case 239:r="*";break;case 240:r="+";break;case 241:r=",";break;case 242:r="-";break;case 243:r=".";break;case 244:r="/";break;case 245:r=":";break;case 246:r=";";break;case 247:r="<";break;case 248:r="=";break;case 249:r=">";break;case 250:r="?";break;case 251:r="_";break;case 252:r=" ";break;default:throw new R}return new qt(t+8,r)}isStillAlpha(t){if(t+5>this.information.getSize())return!1;let e=this.extractNumericValueFromBitArray(t,5);if(e>=5&&e<16)return!0;if(t+6>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(t,6);return r>=16&&r<63}decodeAlphanumeric(t){let e=this.extractNumericValueFromBitArray(t,5);if(15===e)return new qt(t+5,qt.FNC1);if(e>=5&&e<15)return new qt(t+5,"0"+(e-5));let r,n=this.extractNumericValueFromBitArray(t,6);if(n>=32&&n<58)return new qt(t+6,""+(n+33));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 ut("Decoding invalid alphanumeric value: "+n)}return new qt(t+6,r)}isAlphaTo646ToAlphaLatch(t){if(t+1>this.information.getSize())return!1;for(let e=0;e<5&&e+tthis.information.getSize())return!1;for(let e=t;ethis.information.getSize())return!1;for(let e=0;e<4&&e+t{e.forEach((e=>{t.getLeftChar().getValue()===e.getLeftChar().getValue()&&t.getRightChar().getValue()===e.getRightChar().getValue()&&t.getFinderPatter().getValue()===e.getFinderPatter().getValue()&&(r=!0)}))})),r}}class ge extends Gt{constructor(t){super(...arguments),this.pairs=new Array(ge.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=!0===t}decodeRow(t,e,r){this.pairs.length=0,this.startFromEven=!1;try{return ge.constructResult(this.decodeRow2pairs(t,e))}catch(n){this.verbose&&console.log(n)}return this.pairs.length=0,this.startFromEven=!0,ge.constructResult(this.decodeRow2pairs(t,e))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(t,e){let r,n=!1;for(;!n;)try{this.pairs.push(this.retrieveNextPair(e,this.pairs,t))}catch(i){if(i instanceof P){if(!this.pairs.length)throw new P;n=!0}}if(this.checkChecksum())return this.pairs;if(r=!!this.rows.length,this.storeRow(t,!1),r){let t=this.checkRowsBoolean(!1);if(null!=t)return t;if(t=this.checkRowsBoolean(!0),null!=t)return t}throw new P}checkRowsBoolean(t){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,t&&(this.rows=this.rows.reverse());let e=null;try{e=this.checkRows(new Array,0)}catch(r){this.verbose&&console.log(r)}return t&&(this.rows=this.rows.reverse()),e}checkRows(t,e){for(let n=e;ne.length)continue;let r=!0;for(let n=0;nt){i=e.isEquivalent(this.pairs);break}n=e.isEquivalent(this.pairs),r++}i||n||ge.isPartialRow(this.pairs,this.rows)||(this.rows.push(r,new fe(this.pairs,t,e)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(t,e){for(let r of e)if(r.getPairs().length!==t.length)for(let e of r.getPairs())for(let r of t)if(de.equals(e,r))break}static isPartialRow(t,e){for(let r of e){let e=!0;for(let n of t){let t=!1;for(let e of r.getPairs())if(n.equals(e)){t=!0;break}if(!t){e=!1;break}}if(e)return!0}return!1}getRows(){return this.rows}static constructResult(t){let e=ue(Yt.buildBitArray(t)).parseInformation(),r=t[0].getFinderPattern().getResultPoints(),n=t[t.length-1].getFinderPattern().getResultPoints(),i=[r[0],r[1],n[0],n[1]];return new X(e,null,null,i,Y.RSS_EXPANDED,null)}checkChecksum(){let t=this.pairs.get(0),e=t.getLeftChar(),r=t.getRightChar();if(null==r)return!1;let n=r.getChecksumPortion(),i=2;for(let o=1;o=0?r:this.isEmptyPair(e)?0:e[e.length-1].getFinderPattern().getStartEnd()[1];let s=e.length%2!=0;this.startFromEven&&(s=!s);let a=!1;for(;i=0&&!t.get(e);)e--;e++,n=this.startEnd[0]-e,i=e,o=this.startEnd[1]}else i=this.startEnd[0],o=t.getNextUnset(this.startEnd[1]+1),n=o-this.startEnd[1];let s,a=this.getDecodeFinderCounters();m.arraycopy(a,0,a,1,a.length-1),a[0]=n;try{s=this.parseFinderValue(a,ge.FINDER_PATTERNS)}catch(l){return null}return new Wt(s,[i,o],i,o,e)}decodeDataCharacter(t,e,r,n){let i=this.getDataCharacterCounters();for(let T=0;T.3)throw new P;let l=this.getOddCounts(),c=this.getEvenCounts(),h=this.getOddRoundingErrors(),u=this.getEvenRoundingErrors();for(let T=0;T8){if(t>8.7)throw new P;e=8}let r=T/2;0==(1&T)?(l[r]=e,h[r]=t-e):(c[r]=e,u[r]=t-e)}this.adjustOddEvenCounts(o);let d=4*e.getValue()+(r?0:2)+(n?0:1)-1,f=0,g=0;for(let T=l.length-1;T>=0;T--){if(ge.isNotA1left(e,r,n)){let t=ge.WEIGHTS[d][2*T];g+=l[T]*t}f+=l[T]}let w=0;for(let T=c.length-1;T>=0;T--)if(ge.isNotA1left(e,r,n)){let t=ge.WEIGHTS[d][2*T+1];w+=c[T]*t}let m=g+w;if(0!=(1&f)||f>13||f<4)throw new P;let A=(13-f)/2,C=ge.SYMBOL_WIDEST[A],E=9-C,_=zt.getRSSvalue(l,C,!0),p=zt.getRSSvalue(c,E,!1),I=ge.EVEN_TOTAL_SUBSET[A],S=ge.GSUM[A];return new Xt(_*I+p+S,m)}static isNotA1left(t,e,r){return!(0==t.getValue()&&e&&r)}adjustOddEvenCounts(t){let e=gt.sum(new Int32Array(this.getOddCounts())),r=gt.sum(new Int32Array(this.getEvenCounts())),n=!1,i=!1;e>13?i=!0:e<4&&(n=!0);let o=!1,s=!1;r>13?s=!0:r<4&&(o=!0);let a=e+r-t,l=1==(1&e),c=0==(1&r);if(1==a)if(l){if(c)throw new P;i=!0}else{if(!c)throw new P;s=!0}else if(-1==a)if(l){if(c)throw new P;n=!0}else{if(!c)throw new P;o=!0}else{if(0!=a)throw new P;if(l){if(!c)throw new P;e1)for(let t of this.possibleRightPairs)if(t.getCount()>1&&me.checkChecksum(o,t))return me.constructResult(o,t);throw new P}static addOrTally(t,e){if(null==e)return;let r=!1;for(let n of t)if(n.getValue()===e.getValue()){n.incrementCount(),r=!0;break}r||t.push(e)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(t,e){let r=4537077*t.getValue()+e.getValue(),n=new String(r).toString(),i=new b;for(let l=13-n.length;l>0;l--)i.append("0");i.append(n);let o=0;for(let l=0;l<13;l++){let t=i.charAt(l).charCodeAt(0)-"0".charCodeAt(0);o+=0==(1&l)?3*t:t}o=10-o%10,10===o&&(o=0),i.append(o.toString());let s=t.getFinderPattern().getResultPoints(),a=e.getFinderPattern().getResultPoints();return new X(i.toString(),null,0,[s[0],s[1],a[0],a[1]],Y.RSS_14,(new Date).getTime())}static checkChecksum(t,e){let r=(t.getChecksumPortion()+16*e.getChecksumPortion())%79,n=9*t.getFinderPattern().getValue()+e.getFinderPattern().getValue();return n>72&&n--,n>8&&n--,r===n}decodePair(t,e,r,n){try{let i=this.findFinderPattern(t,e),o=this.parseFoundFinderPattern(t,r,e,i),s=null==n?null:n.get(T.NEED_RESULT_POINT_CALLBACK);if(null!=s){let n=(i[0]+i[1])/2;e&&(n=t.getSize()-1-n),s.foundPossibleResultPoint(new mt(n,r))}let a=this.decodeDataCharacter(t,o,!0),l=this.decodeDataCharacter(t,o,!1);return new we(1597*a.getValue()+l.getValue(),a.getChecksumPortion()+4*l.getChecksumPortion(),o)}catch(i){return null}}decodeDataCharacter(t,e,r){let n=this.getDataCharacterCounters();for(let w=0;w8&&(e=8);let r=Math.floor(w/2);0==(1&w)?(s[r]=e,l[r]=t-e):(a[r]=e,c[r]=t-e)}this.adjustOddEvenCounts(r,i);let h=0,u=0;for(let w=s.length-1;w>=0;w--)u*=9,u+=s[w],h+=s[w];let d=0,f=0;for(let w=a.length-1;w>=0;w--)d*=9,d+=a[w],f+=a[w];let g=u+3*d;if(r){if(0!=(1&h)||h>12||h<4)throw new P;let t=(12-h)/2,e=me.OUTSIDE_ODD_WIDEST[t],r=9-e,n=zt.getRSSvalue(s,e,!1),i=zt.getRSSvalue(a,r,!0),o=me.OUTSIDE_EVEN_TOTAL_SUBSET[t],l=me.OUTSIDE_GSUM[t];return new Xt(n*o+i+l,g)}{if(0!=(1&f)||f>10||f<4)throw new P;let t=(10-f)/2,e=me.INSIDE_ODD_WIDEST[t],r=9-e,n=zt.getRSSvalue(s,e,!0),i=zt.getRSSvalue(a,r,!1),o=me.INSIDE_ODD_TOTAL_SUBSET[t],l=me.INSIDE_GSUM[t];return new Xt(i*o+n+l,g)}}findFinderPattern(t,e){let r=this.getDecodeFinderCounters();r[0]=0,r[1]=0,r[2]=0,r[3]=0;let n=t.getSize(),i=!1,o=0;for(;o=0&&i!==t.get(o);)o--;o++;const s=n[0]-o,a=this.getDecodeFinderCounters(),l=new Int32Array(a.length);m.arraycopy(a,0,l,1,a.length-1),l[0]=s;const c=this.parseFinderValue(l,me.FINDER_PATTERNS);let h=o,u=n[1];return r&&(h=t.getSize()-1-h,u=t.getSize()-1-u),new Wt(c,[o,n[1]],h,u,e)}adjustOddEvenCounts(t,e){let r=gt.sum(new Int32Array(this.getOddCounts())),n=gt.sum(new Int32Array(this.getEvenCounts())),i=!1,o=!1,s=!1,a=!1;t?(r>12?o=!0:r<4&&(i=!0),n>12?a=!0:n<4&&(s=!0)):(r>11?o=!0:r<5&&(i=!0),n>10?a=!0:n<4&&(s=!0));let l=r+n-e,c=(1&r)==(t?1:0),h=1==(1&n);if(1===l)if(c){if(h)throw new P;o=!0}else{if(!h)throw new P;a=!0}else if(-1===l)if(c){if(h)throw new P;i=!0}else{if(!h)throw new P;s=!0}else{if(0!==l)throw new P;if(c){if(!h)throw new P;rt.reset()))}}class Ce extends G{constructor(t=500,e){super(new Ae(e),t,e)}}class Ee{constructor(t,e,r){this.ecCodewords=t,this.ecBlocks=[e],r&&this.ecBlocks.push(r)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class _e{constructor(t,e){this.count=t,this.dataCodewords=e}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class pe{constructor(t,e,r,n,i,o){this.versionNumber=t,this.symbolSizeRows=e,this.symbolSizeColumns=r,this.dataRegionSizeRows=n,this.dataRegionSizeColumns=i,this.ecBlocks=o;let s=0;const a=o.getECCodewords(),l=o.getECBlocks();for(let c of l)s+=c.getCount()*(c.getDataCodewords()+a);this.totalCodewords=s}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}static getVersionForDimensions(t,e){if(0!=(1&t)||0!=(1&e))throw new R;for(let r of pe.VERSIONS)if(r.symbolSizeRows===t&&r.symbolSizeColumns===e)return r;throw new R}toString(){return""+this.versionNumber}static buildVersions(){return[new pe(1,10,10,8,8,new Ee(5,new _e(1,3))),new pe(2,12,12,10,10,new Ee(7,new _e(1,5))),new pe(3,14,14,12,12,new Ee(10,new _e(1,8))),new pe(4,16,16,14,14,new Ee(12,new _e(1,12))),new pe(5,18,18,16,16,new Ee(14,new _e(1,18))),new pe(6,20,20,18,18,new Ee(18,new _e(1,22))),new pe(7,22,22,20,20,new Ee(20,new _e(1,30))),new pe(8,24,24,22,22,new Ee(24,new _e(1,36))),new pe(9,26,26,24,24,new Ee(28,new _e(1,44))),new pe(10,32,32,14,14,new Ee(36,new _e(1,62))),new pe(11,36,36,16,16,new Ee(42,new _e(1,86))),new pe(12,40,40,18,18,new Ee(48,new _e(1,114))),new pe(13,44,44,20,20,new Ee(56,new _e(1,144))),new pe(14,48,48,22,22,new Ee(68,new _e(1,174))),new pe(15,52,52,24,24,new Ee(42,new _e(2,102))),new pe(16,64,64,14,14,new Ee(56,new _e(2,140))),new pe(17,72,72,16,16,new Ee(36,new _e(4,92))),new pe(18,80,80,18,18,new Ee(48,new _e(4,114))),new pe(19,88,88,20,20,new Ee(56,new _e(4,144))),new pe(20,96,96,22,22,new Ee(68,new _e(4,174))),new pe(21,104,104,24,24,new Ee(56,new _e(6,136))),new pe(22,120,120,18,18,new Ee(68,new _e(6,175))),new pe(23,132,132,20,20,new Ee(62,new _e(8,163))),new pe(24,144,144,22,22,new Ee(62,new _e(8,156),new _e(2,155))),new pe(25,8,18,6,16,new Ee(7,new _e(1,5))),new pe(26,8,32,6,14,new Ee(11,new _e(1,10))),new pe(27,12,26,10,24,new Ee(14,new _e(1,16))),new pe(28,12,36,10,16,new Ee(18,new _e(1,22))),new pe(29,16,36,14,16,new Ee(24,new _e(1,32))),new pe(30,16,48,14,22,new Ee(28,new _e(1,49)))]}}pe.VERSIONS=pe.buildVersions();class Ie{constructor(t){const e=t.getHeight();if(e<8||e>144||0!=(1&e))throw new R;this.version=Ie.readVersion(t),this.mappingBitMatrix=this.extractDataRegion(t),this.readMappingMatrix=new M(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(t){const e=t.getHeight(),r=t.getWidth();return pe.getVersionForDimensions(e,r)}readCodewords(){const t=new Int8Array(this.version.getTotalCodewords());let e=0,r=4,n=0;const i=this.mappingBitMatrix.getHeight(),o=this.mappingBitMatrix.getWidth();let s=!1,a=!1,l=!1,c=!1;do{if(r!==i||0!==n||s)if(r!==i-2||0!==n||0==(3&o)||a)if(r!==i+4||2!==n||0!=(7&o)||l)if(r!==i-2||0!==n||4!=(7&o)||c){do{r=0&&!this.readMappingMatrix.get(n,r)&&(t[e++]=255&this.readUtah(r,n,i,o)),r-=2,n+=2}while(r>=0&&n=0&&n=0);r+=3,n+=1}else t[e++]=255&this.readCorner4(i,o),r-=2,n+=2,c=!0;else t[e++]=255&this.readCorner3(i,o),r-=2,n+=2,l=!0;else t[e++]=255&this.readCorner2(i,o),r-=2,n+=2,a=!0;else t[e++]=255&this.readCorner1(i,o),r-=2,n+=2,s=!0}while(r7?d-1:d;o[r].codewords[n]=t[c++]}if(c!==t.length)throw new d;return o}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class Te{constructor(t){this.bytes=t,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(t){if(t<1||t>32||t>this.available())throw new d(""+t);let e=0,r=this.bitOffset,n=this.byteOffset;const i=this.bytes;if(r>0){const o=8-r,s=t>8-s<>a,t-=s,r+=s,8===r&&(r=0,n++)}if(t>0){for(;t>=8;)e=e<<8|255&i[n],n++,t-=8;if(t>0){const o=8-t,s=255>>o<>o,r+=t}}return this.bitOffset=r,this.byteOffset=n,e}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}(tt=K||(K={}))[tt.PAD_ENCODE=0]="PAD_ENCODE",tt[tt.ASCII_ENCODE=1]="ASCII_ENCODE",tt[tt.C40_ENCODE=2]="C40_ENCODE",tt[tt.TEXT_ENCODE=3]="TEXT_ENCODE",tt[tt.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",tt[tt.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",tt[tt.BASE256_ENCODE=6]="BASE256_ENCODE";class Re{static decode(t){const e=new Te(t),r=new b,n=new b,i=new Array;let o=K.ASCII_ENCODE;do{if(o===K.ASCII_ENCODE)o=this.decodeAsciiSegment(e,r,n);else{switch(o){case K.C40_ENCODE:this.decodeC40Segment(e,r);break;case K.TEXT_ENCODE:this.decodeTextSegment(e,r);break;case K.ANSIX12_ENCODE:this.decodeAnsiX12Segment(e,r);break;case K.EDIFACT_ENCODE:this.decodeEdifactSegment(e,r);break;case K.BASE256_ENCODE:this.decodeBase256Segment(e,r,i);break;default:throw new R}o=K.ASCII_ENCODE}}while(o!==K.PAD_ENCODE&&e.available()>0);return n.length()>0&&r.append(n.toString()),new ot(t,r.toString(),0===i.length?null:i,null)}static decodeAsciiSegment(t,e,r){let n=!1;do{let i=t.readBits(8);if(0===i)throw new R;if(i<=128)return n&&(i+=128),e.append(String.fromCharCode(i-1)),K.ASCII_ENCODE;if(129===i)return K.PAD_ENCODE;if(i<=229){const t=i-130;t<10&&e.append("0"),e.append(""+t)}else switch(i){case 230:return K.C40_ENCODE;case 231:return K.BASE256_ENCODE;case 232:e.append(String.fromCharCode(29));break;case 233:case 234:case 241:break;case 235:n=!0;break;case 236:e.append("[)>05"),r.insert(0,"");break;case 237:e.append("[)>06"),r.insert(0,"");break;case 238:return K.ANSIX12_ENCODE;case 239:return K.TEXT_ENCODE;case 240:return K.EDIFACT_ENCODE;default:if(254!==i||0!==t.available())throw new R}}while(t.available()>0);return K.ASCII_ENCODE}static decodeC40Segment(t,e){let r=!1;const n=[];let i=0;do{if(8===t.available())return;const o=t.readBits(8);if(254===o)return;this.parseTwoBytes(o,t.readBits(8),n);for(let t=0;t<3;t++){const o=n[t];switch(i){case 0:if(o<3)i=o+1;else{if(!(o0)}static decodeTextSegment(t,e){let r=!1,n=[],i=0;do{if(8===t.available())return;const o=t.readBits(8);if(254===o)return;this.parseTwoBytes(o,t.readBits(8),n);for(let t=0;t<3;t++){const o=n[t];switch(i){case 0:if(o<3)i=o+1;else{if(!(o0)}static decodeAnsiX12Segment(t,e){const r=[];do{if(8===t.available())return;const n=t.readBits(8);if(254===n)return;this.parseTwoBytes(n,t.readBits(8),r);for(let t=0;t<3;t++){const n=r[t];switch(n){case 0:e.append("\r");break;case 1:e.append("*");break;case 2:e.append(">");break;case 3:e.append(" ");break;default:if(n<14)e.append(String.fromCharCode(n+44));else{if(!(n<40))throw new R;e.append(String.fromCharCode(n+51))}}}}while(t.available()>0)}static parseTwoBytes(t,e,r){let n=(t<<8)+e-1,i=Math.floor(n/1600);r[0]=i,n-=1600*i,i=Math.floor(n/40),r[1]=i,r[2]=n-40*i}static decodeEdifactSegment(t,e){do{if(t.available()<=16)return;for(let r=0;r<4;r++){let r=t.readBits(6);if(31===r){const e=8-t.getBitOffset();return void(8!==e&&t.readBits(e))}0==(32&r)&&(r|=64),e.append(String.fromCharCode(r))}}while(t.available()>0)}static decodeBase256Segment(t,e,r){let n=1+t.getByteOffset();const i=this.unrandomize255State(t.readBits(8),n++);let o;if(o=0===i?t.available()/8|0:i<250?i:250*(i-249)+this.unrandomize255State(t.readBits(8),n++),o<0)throw new R;const s=new Uint8Array(o);for(let l=0;l=0?r:r+256}}Re.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"],Re.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Re.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"],Re.TEXT_SHIFT2_SET_CHARS=Re.C40_SHIFT2_SET_CHARS,Re.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","{","|","}","~",String.fromCharCode(127)];class ye{constructor(){this.rsDecoder=new dt(ct.DATA_MATRIX_FIELD_256)}decode(t){const e=new Ie(t),r=e.getVersion(),n=e.readCodewords(),i=Se.getDataBlocks(n,r);let o=0;for(let l of i)o+=l.getNumDataCodewords();const s=new Uint8Array(o),a=i.length;for(let l=0;ls&&(c=s,h[0]=e,h[1]=r,h[2]=n,h[3]=i),c>a&&(c=a,h[0]=r,h[1]=n,h[2]=i,h[3]=e),c>l&&(h[0]=n,h[1]=i,h[2]=e,h[3]=r),h}detectSolid2(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=this.transitionsBetween(e,i),s=Ne.shiftPoint(r,n,4*(o+1)),a=Ne.shiftPoint(n,r,4*(o+1));return this.transitionsBetween(s,e)this.transitionsBetween(a,h)+this.transitionsBetween(l,h)?c:h:c:this.isValid(h)?h:null}shiftToModuleCenter(t){let e=t[0],r=t[1],n=t[2],i=t[3],o=this.transitionsBetween(e,i)+1,s=this.transitionsBetween(n,i)+1,a=Ne.shiftPoint(e,r,4*s),l=Ne.shiftPoint(n,r,4*o);o=this.transitionsBetween(a,i)+1,s=this.transitionsBetween(l,i)+1,1==(1&o)&&(o+=1),1==(1&s)&&(s+=1);let c,h,u=(e.getX()+r.getX()+n.getX()+i.getX())/4,d=(e.getY()+r.getY()+n.getY()+i.getY())/4;return e=Ne.moveAway(e,u,d),r=Ne.moveAway(r,u,d),n=Ne.moveAway(n,u,d),i=Ne.moveAway(i,u,d),a=Ne.shiftPoint(e,r,4*s),a=Ne.shiftPoint(a,i,4*o),c=Ne.shiftPoint(r,e,4*s),c=Ne.shiftPoint(c,n,4*o),l=Ne.shiftPoint(n,i,4*s),l=Ne.shiftPoint(l,r,4*o),h=Ne.shiftPoint(i,n,4*s),h=Ne.shiftPoint(h,e,4*o),[a,c,l,h]}isValid(t){return t.getX()>=0&&t.getX()0&&t.getY()Math.abs(i-r);if(s){let t=r;r=n,n=t,t=i,i=o,o=t}let a=Math.abs(i-r),l=Math.abs(o-n),c=-a/2,h=n0){if(w===o)break;w+=h,c-=a}}return d}}class De{constructor(){this.decoder=new ye}decode(t,e=null){let r,n;if(null!=e&&e.has(T.PURE_BARCODE)){const e=De.extractPureBits(t.getBlackMatrix());r=this.decoder.decode(e),n=De.NO_POINTS}else{const e=new Ne(t.getBlackMatrix()).detect();r=this.decoder.decode(e.getBits()),n=e.getPoints()}const i=r.getRawBytes(),o=new X(r.getText(),i,8*i.length,n,Y.DATA_MATRIX,m.currentTimeMillis()),s=r.getByteSegments();null!=s&&o.putMetadata(it.BYTE_SEGMENTS,s);const a=r.getECLevel();return null!=a&&o.putMetadata(it.ERROR_CORRECTION_LEVEL,a),o}reset(){}static extractPureBits(t){const e=t.getTopLeftOnBit(),r=t.getBottomRightOnBit();if(null==e||null==r)throw new P;const n=this.moduleSize(e,t);let i=e[1];const o=r[1];let s=e[0];const a=(r[0]-s+1)/n,l=(o-i+1)/n;if(a<=0||l<=0)throw new P;const c=n/2;i+=c,s+=c;const h=new M(a,l);for(let u=0;u=be.FOR_BITS.size)throw new d;return be.FOR_BITS.get(t)}}be.FOR_BITS=new Map,be.FOR_VALUE=new Map,be.L=new be(q.L,"L",1),be.M=new be(q.M,"M",0),be.Q=new be(q.Q,"Q",3),be.H=new be(q.H,"H",2);class Me{constructor(t){this.errorCorrectionLevel=be.forBits(t>>3&3),this.dataMask=7&t}static numBitsDiffering(t,e){return _.bitCount(t^e)}static decodeFormatInformation(t,e){const r=Me.doDecodeFormatInformation(t,e);return null!==r?r:Me.doDecodeFormatInformation(t^Me.FORMAT_INFO_MASK_QR,e^Me.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(t,e){let r=Number.MAX_SAFE_INTEGER,n=0;for(const i of Me.FORMAT_INFO_DECODE_LOOKUP){const o=i[0];if(o===t||o===e)return new Me(i[1]);let s=Me.numBitsDiffering(t,o);s40)throw new d;return ve.VERSIONS[t-1]}static decodeVersionInformation(t){let e=Number.MAX_SAFE_INTEGER,r=0;for(let n=0;n6&&(e.setRegion(t-11,0,3,6),e.setRegion(0,t-11,6,3)),e}toString(){return""+this.versionNumber}}ve.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]),ve.VERSIONS=[new ve(1,new Int32Array(0),new Pe(7,new Be(1,19)),new Pe(10,new Be(1,16)),new Pe(13,new Be(1,13)),new Pe(17,new Be(1,9))),new ve(2,Int32Array.from([6,18]),new Pe(10,new Be(1,34)),new Pe(16,new Be(1,28)),new Pe(22,new Be(1,22)),new Pe(28,new Be(1,16))),new ve(3,Int32Array.from([6,22]),new Pe(15,new Be(1,55)),new Pe(26,new Be(1,44)),new Pe(18,new Be(2,17)),new Pe(22,new Be(2,13))),new ve(4,Int32Array.from([6,26]),new Pe(20,new Be(1,80)),new Pe(18,new Be(2,32)),new Pe(26,new Be(2,24)),new Pe(16,new Be(4,9))),new ve(5,Int32Array.from([6,30]),new Pe(26,new Be(1,108)),new Pe(24,new Be(2,43)),new Pe(18,new Be(2,15),new Be(2,16)),new Pe(22,new Be(2,11),new Be(2,12))),new ve(6,Int32Array.from([6,34]),new Pe(18,new Be(2,68)),new Pe(16,new Be(4,27)),new Pe(24,new Be(4,19)),new Pe(28,new Be(4,15))),new ve(7,Int32Array.from([6,22,38]),new Pe(20,new Be(2,78)),new Pe(18,new Be(4,31)),new Pe(18,new Be(2,14),new Be(4,15)),new Pe(26,new Be(4,13),new Be(1,14))),new ve(8,Int32Array.from([6,24,42]),new Pe(24,new Be(2,97)),new Pe(22,new Be(2,38),new Be(2,39)),new Pe(22,new Be(4,18),new Be(2,19)),new Pe(26,new Be(4,14),new Be(2,15))),new ve(9,Int32Array.from([6,26,46]),new Pe(30,new Be(2,116)),new Pe(22,new Be(3,36),new Be(2,37)),new Pe(20,new Be(4,16),new Be(4,17)),new Pe(24,new Be(4,12),new Be(4,13))),new ve(10,Int32Array.from([6,28,50]),new Pe(18,new Be(2,68),new Be(2,69)),new Pe(26,new Be(4,43),new Be(1,44)),new Pe(24,new Be(6,19),new Be(2,20)),new Pe(28,new Be(6,15),new Be(2,16))),new ve(11,Int32Array.from([6,30,54]),new Pe(20,new Be(4,81)),new Pe(30,new Be(1,50),new Be(4,51)),new Pe(28,new Be(4,22),new Be(4,23)),new Pe(24,new Be(3,12),new Be(8,13))),new ve(12,Int32Array.from([6,32,58]),new Pe(24,new Be(2,92),new Be(2,93)),new Pe(22,new Be(6,36),new Be(2,37)),new Pe(26,new Be(4,20),new Be(6,21)),new Pe(28,new Be(7,14),new Be(4,15))),new ve(13,Int32Array.from([6,34,62]),new Pe(26,new Be(4,107)),new Pe(22,new Be(8,37),new Be(1,38)),new Pe(24,new Be(8,20),new Be(4,21)),new Pe(22,new Be(12,11),new Be(4,12))),new ve(14,Int32Array.from([6,26,46,66]),new Pe(30,new Be(3,115),new Be(1,116)),new Pe(24,new Be(4,40),new Be(5,41)),new Pe(20,new Be(11,16),new Be(5,17)),new Pe(24,new Be(11,12),new Be(5,13))),new ve(15,Int32Array.from([6,26,48,70]),new Pe(22,new Be(5,87),new Be(1,88)),new Pe(24,new Be(5,41),new Be(5,42)),new Pe(30,new Be(5,24),new Be(7,25)),new Pe(24,new Be(11,12),new Be(7,13))),new ve(16,Int32Array.from([6,26,50,74]),new Pe(24,new Be(5,98),new Be(1,99)),new Pe(28,new Be(7,45),new Be(3,46)),new Pe(24,new Be(15,19),new Be(2,20)),new Pe(30,new Be(3,15),new Be(13,16))),new ve(17,Int32Array.from([6,30,54,78]),new Pe(28,new Be(1,107),new Be(5,108)),new Pe(28,new Be(10,46),new Be(1,47)),new Pe(28,new Be(1,22),new Be(15,23)),new Pe(28,new Be(2,14),new Be(17,15))),new ve(18,Int32Array.from([6,30,56,82]),new Pe(30,new Be(5,120),new Be(1,121)),new Pe(26,new Be(9,43),new Be(4,44)),new Pe(28,new Be(17,22),new Be(1,23)),new Pe(28,new Be(2,14),new Be(19,15))),new ve(19,Int32Array.from([6,30,58,86]),new Pe(28,new Be(3,113),new Be(4,114)),new Pe(26,new Be(3,44),new Be(11,45)),new Pe(26,new Be(17,21),new Be(4,22)),new Pe(26,new Be(9,13),new Be(16,14))),new ve(20,Int32Array.from([6,34,62,90]),new Pe(28,new Be(3,107),new Be(5,108)),new Pe(26,new Be(3,41),new Be(13,42)),new Pe(30,new Be(15,24),new Be(5,25)),new Pe(28,new Be(15,15),new Be(10,16))),new ve(21,Int32Array.from([6,28,50,72,94]),new Pe(28,new Be(4,116),new Be(4,117)),new Pe(26,new Be(17,42)),new Pe(28,new Be(17,22),new Be(6,23)),new Pe(30,new Be(19,16),new Be(6,17))),new ve(22,Int32Array.from([6,26,50,74,98]),new Pe(28,new Be(2,111),new Be(7,112)),new Pe(28,new Be(17,46)),new Pe(30,new Be(7,24),new Be(16,25)),new Pe(24,new Be(34,13))),new ve(23,Int32Array.from([6,30,54,78,102]),new Pe(30,new Be(4,121),new Be(5,122)),new Pe(28,new Be(4,47),new Be(14,48)),new Pe(30,new Be(11,24),new Be(14,25)),new Pe(30,new Be(16,15),new Be(14,16))),new ve(24,Int32Array.from([6,28,54,80,106]),new Pe(30,new Be(6,117),new Be(4,118)),new Pe(28,new Be(6,45),new Be(14,46)),new Pe(30,new Be(11,24),new Be(16,25)),new Pe(30,new Be(30,16),new Be(2,17))),new ve(25,Int32Array.from([6,32,58,84,110]),new Pe(26,new Be(8,106),new Be(4,107)),new Pe(28,new Be(8,47),new Be(13,48)),new Pe(30,new Be(7,24),new Be(22,25)),new Pe(30,new Be(22,15),new Be(13,16))),new ve(26,Int32Array.from([6,30,58,86,114]),new Pe(28,new Be(10,114),new Be(2,115)),new Pe(28,new Be(19,46),new Be(4,47)),new Pe(28,new Be(28,22),new Be(6,23)),new Pe(30,new Be(33,16),new Be(4,17))),new ve(27,Int32Array.from([6,34,62,90,118]),new Pe(30,new Be(8,122),new Be(4,123)),new Pe(28,new Be(22,45),new Be(3,46)),new Pe(30,new Be(8,23),new Be(26,24)),new Pe(30,new Be(12,15),new Be(28,16))),new ve(28,Int32Array.from([6,26,50,74,98,122]),new Pe(30,new Be(3,117),new Be(10,118)),new Pe(28,new Be(3,45),new Be(23,46)),new Pe(30,new Be(4,24),new Be(31,25)),new Pe(30,new Be(11,15),new Be(31,16))),new ve(29,Int32Array.from([6,30,54,78,102,126]),new Pe(30,new Be(7,116),new Be(7,117)),new Pe(28,new Be(21,45),new Be(7,46)),new Pe(30,new Be(1,23),new Be(37,24)),new Pe(30,new Be(19,15),new Be(26,16))),new ve(30,Int32Array.from([6,26,52,78,104,130]),new Pe(30,new Be(5,115),new Be(10,116)),new Pe(28,new Be(19,47),new Be(10,48)),new Pe(30,new Be(15,24),new Be(25,25)),new Pe(30,new Be(23,15),new Be(25,16))),new ve(31,Int32Array.from([6,30,56,82,108,134]),new Pe(30,new Be(13,115),new Be(3,116)),new Pe(28,new Be(2,46),new Be(29,47)),new Pe(30,new Be(42,24),new Be(1,25)),new Pe(30,new Be(23,15),new Be(28,16))),new ve(32,Int32Array.from([6,34,60,86,112,138]),new Pe(30,new Be(17,115)),new Pe(28,new Be(10,46),new Be(23,47)),new Pe(30,new Be(10,24),new Be(35,25)),new Pe(30,new Be(19,15),new Be(35,16))),new ve(33,Int32Array.from([6,30,58,86,114,142]),new Pe(30,new Be(17,115),new Be(1,116)),new Pe(28,new Be(14,46),new Be(21,47)),new Pe(30,new Be(29,24),new Be(19,25)),new Pe(30,new Be(11,15),new Be(46,16))),new ve(34,Int32Array.from([6,34,62,90,118,146]),new Pe(30,new Be(13,115),new Be(6,116)),new Pe(28,new Be(14,46),new Be(23,47)),new Pe(30,new Be(44,24),new Be(7,25)),new Pe(30,new Be(59,16),new Be(1,17))),new ve(35,Int32Array.from([6,30,54,78,102,126,150]),new Pe(30,new Be(12,121),new Be(7,122)),new Pe(28,new Be(12,47),new Be(26,48)),new Pe(30,new Be(39,24),new Be(14,25)),new Pe(30,new Be(22,15),new Be(41,16))),new ve(36,Int32Array.from([6,24,50,76,102,128,154]),new Pe(30,new Be(6,121),new Be(14,122)),new Pe(28,new Be(6,47),new Be(34,48)),new Pe(30,new Be(46,24),new Be(10,25)),new Pe(30,new Be(2,15),new Be(64,16))),new ve(37,Int32Array.from([6,28,54,80,106,132,158]),new Pe(30,new Be(17,122),new Be(4,123)),new Pe(28,new Be(29,46),new Be(14,47)),new Pe(30,new Be(49,24),new Be(10,25)),new Pe(30,new Be(24,15),new Be(46,16))),new ve(38,Int32Array.from([6,32,58,84,110,136,162]),new Pe(30,new Be(4,122),new Be(18,123)),new Pe(28,new Be(13,46),new Be(32,47)),new Pe(30,new Be(48,24),new Be(14,25)),new Pe(30,new Be(42,15),new Be(32,16))),new ve(39,Int32Array.from([6,26,54,82,110,138,166]),new Pe(30,new Be(20,117),new Be(4,118)),new Pe(28,new Be(40,47),new Be(7,48)),new Pe(30,new Be(43,24),new Be(22,25)),new Pe(30,new Be(10,15),new Be(67,16))),new ve(40,Int32Array.from([6,30,58,86,114,142,170]),new Pe(30,new Be(19,118),new Be(6,119)),new Pe(28,new Be(18,47),new Be(31,48)),new Pe(30,new Be(34,24),new Be(34,25)),new Pe(30,new Be(20,15),new Be(61,16)))],(rt=Q||(Q={}))[rt.DATA_MASK_000=0]="DATA_MASK_000",rt[rt.DATA_MASK_001=1]="DATA_MASK_001",rt[rt.DATA_MASK_010=2]="DATA_MASK_010",rt[rt.DATA_MASK_011=3]="DATA_MASK_011",rt[rt.DATA_MASK_100=4]="DATA_MASK_100",rt[rt.DATA_MASK_101=5]="DATA_MASK_101",rt[rt.DATA_MASK_110=6]="DATA_MASK_110",rt[rt.DATA_MASK_111=7]="DATA_MASK_111";class Le{constructor(t,e){this.value=t,this.isMasked=e}unmaskBitMatrix(t,e){for(let r=0;r0==(t+e&1)))],[Q.DATA_MASK_001,new Le(Q.DATA_MASK_001,((t,e)=>0==(1&t)))],[Q.DATA_MASK_010,new Le(Q.DATA_MASK_010,((t,e)=>e%3==0))],[Q.DATA_MASK_011,new Le(Q.DATA_MASK_011,((t,e)=>(t+e)%3==0))],[Q.DATA_MASK_100,new Le(Q.DATA_MASK_100,((t,e)=>0==(Math.floor(t/2)+Math.floor(e/3)&1)))],[Q.DATA_MASK_101,new Le(Q.DATA_MASK_101,((t,e)=>t*e%6==0))],[Q.DATA_MASK_110,new Le(Q.DATA_MASK_110,((t,e)=>t*e%6<3))],[Q.DATA_MASK_111,new Le(Q.DATA_MASK_111,((t,e)=>0==(t+e+t*e%3&1)))]]);class Fe{constructor(t){const e=t.getHeight();if(e<21||1!=(3&e))throw new R;this.bitMatrix=t}readFormatInformation(){if(null!==this.parsedFormatInfo&&void 0!==this.parsedFormatInfo)return this.parsedFormatInfo;let t=0;for(let i=0;i<6;i++)t=this.copyBit(i,8,t);t=this.copyBit(7,8,t),t=this.copyBit(8,8,t),t=this.copyBit(8,7,t);for(let i=5;i>=0;i--)t=this.copyBit(8,i,t);const e=this.bitMatrix.getHeight();let r=0;const n=e-7;for(let i=e-1;i>=n;i--)r=this.copyBit(8,i,r);for(let i=e-8;i=0;o--)for(let e=t-9;e>=n;e--)r=this.copyBit(e,o,r);let i=ve.decodeVersionInformation(r);if(null!==i&&i.getDimensionForVersion()===t)return this.parsedVersion=i,i;r=0;for(let o=5;o>=0;o--)for(let e=t-9;e>=n;e--)r=this.copyBit(o,e,r);if(i=ve.decodeVersionInformation(r),null!==i&&i.getDimensionForVersion()===t)return this.parsedVersion=i,i;throw new R}copyBit(t,e,r){return(this.isMirror?this.bitMatrix.get(e,t):this.bitMatrix.get(t,e))?r<<1|1:r<<1}readCodewords(){const t=this.readFormatInformation(),e=this.readVersion(),r=Le.values.get(t.getDataMask()),n=this.bitMatrix.getHeight();r.unmaskBitMatrix(this.bitMatrix,n);const i=e.buildFunctionPattern();let o=!0;const s=new Uint8Array(e.getTotalCodewords());let a=0,l=0,c=0;for(let h=n-1;h>0;h-=2){6===h&&h--;for(let t=0;t=0&&s[c].codewords.length!==l;)c--;c++;const h=l-n.getECCodewordsPerBlock();let u=0;for(let d=0;dt.available())throw new R;const n=new Uint8Array(2*r);let i=0;for(;r>0;){const e=t.readBits(13);let o=e/96<<8&4294967295|e%96;o+=o<959?41377:42657,n[i]=o>>8&255,n[i+1]=255&o,i+=2,r--}try{e.append(D.decode(n,O.GB2312))}catch(o){throw new R(o)}}static decodeKanjiSegment(t,e,r){if(13*r>t.available())throw new R;const n=new Uint8Array(2*r);let i=0;for(;r>0;){const e=t.readBits(13);let o=e/192<<8&4294967295|e%192;o+=o<7936?33088:49472,n[i]=o>>8,n[i+1]=o,i+=2,r--}try{e.append(D.decode(n,O.SHIFT_JIS))}catch(o){throw new R(o)}}static decodeByteSegment(t,e,r,n,i,o){if(8*r>t.available())throw new R;const s=new Uint8Array(r);for(let c=0;c=Ue.ALPHANUMERIC_CHARS.length)throw new R;return Ue.ALPHANUMERIC_CHARS[t]}static decodeAlphanumericSegment(t,e,r,n){const i=e.length();for(;r>1;){if(t.available()<11)throw new R;const n=t.readBits(11);e.append(Ue.toAlphaNumericChar(Math.floor(n/45))),e.append(Ue.toAlphaNumericChar(n%45)),r-=2}if(1===r){if(t.available()<6)throw new R;e.append(Ue.toAlphaNumericChar(t.readBits(6)))}if(n)for(let o=i;o=3;){if(t.available()<10)throw new R;const n=t.readBits(10);if(n>=1e3)throw new R;e.append(Ue.toAlphaNumericChar(Math.floor(n/100))),e.append(Ue.toAlphaNumericChar(Math.floor(n/10)%10)),e.append(Ue.toAlphaNumericChar(n%10)),r-=3}if(2===r){if(t.available()<7)throw new R;const r=t.readBits(7);if(r>=100)throw new R;e.append(Ue.toAlphaNumericChar(Math.floor(r/10))),e.append(Ue.toAlphaNumericChar(r%10))}else if(1===r){if(t.available()<4)throw new R;const r=t.readBits(4);if(r>=10)throw new R;e.append(Ue.toAlphaNumericChar(r))}}static parseECIValue(t){const e=t.readBits(8);if(0==(128&e))return 127&e;if(128==(192&e))return(63&e)<<8&4294967295|t.readBits(8);if(192==(224&e))return(31&e)<<16&4294967295|t.readBits(16);throw new R}}Ue.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ue.GB2312_SUBSET=1;class Ve{constructor(t){this.mirrored=t}isMirrored(){return this.mirrored}applyMirroredCorrection(t){if(!this.mirrored||null===t||t.length<3)return;const e=t[0];t[0]=t[2],t[2]=e}}class He{constructor(){this.rsDecoder=new dt(ct.QR_CODE_FIELD_256)}decodeBooleanArray(t,e){return this.decodeBitMatrix(M.parseFromBooleanArray(t),e)}decodeBitMatrix(t,e){const r=new Fe(t);let n=null;try{return this.decodeBitMatrixParser(r,e)}catch(i){n=i}try{r.remask(),r.setMirror(!0),r.readVersion(),r.readFormatInformation(),r.mirror();const t=this.decodeBitMatrixParser(r,e);return t.setOther(new Ve(!0)),t}catch(i){if(null!==n)throw n;throw i}}decodeBitMatrixParser(t,e){const r=t.readVersion(),n=t.readFormatInformation().getErrorCorrectionLevel(),i=t.readCodewords(),o=ke.getDataBlocks(i,r,n);let s=0;for(const c of o)s+=c.getNumDataCodewords();const a=new Uint8Array(s);let l=0;for(const c of o){const t=c.getCodewords(),e=c.getNumDataCodewords();this.correctErrors(t,e);for(let r=0;r=r)return!1;return!0}crossCheckVertical(t,e,r,n){const i=this.image,o=i.getHeight(),s=this.crossCheckStateCount;s[0]=0,s[1]=0,s[2]=0;let a=t;for(;a>=0&&i.get(e,a)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&!i.get(e,a)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=t+1;ar)return NaN;for(;ar)return NaN;const l=s[0]+s[1]+s[2];return 5*Math.abs(l-n)>=2*n?NaN:this.foundPatternCross(s)?Xe.centerFromEnd(s,a):NaN}handlePossibleCenter(t,e,r){const n=t[0]+t[1]+t[2],i=Xe.centerFromEnd(t,r),o=this.crossCheckVertical(e,i,2*t[1],n);if(!isNaN(o)){const e=(t[0]+t[1]+t[2])/3;for(const t of this.possibleCenters)if(t.aboutEquals(e,o,i))return t.combineEstimate(o,i,e);const r=new Ge(i,o,e);this.possibleCenters.push(r),null!==this.resultPointCallback&&void 0!==this.resultPointCallback&&this.resultPointCallback.foundPossibleResultPoint(r)}return null}}class We extends mt{constructor(t,e,r,n){super(t,e),this.estimatedModuleSize=r,this.count=n,void 0===n&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(t,e,r){if(Math.abs(e-this.getY())<=t&&Math.abs(r-this.getX())<=t){const e=Math.abs(t-this.estimatedModuleSize);return e<=1||e<=this.estimatedModuleSize}return!1}combineEstimate(t,e,r){const n=this.count+1,i=(this.count*this.getX()+e)/n,o=(this.count*this.getY()+t)/n,s=(this.count*this.estimatedModuleSize+r)/n;return new We(i,o,s,n)}}class ze{constructor(t){this.bottomLeft=t[0],this.topLeft=t[1],this.topRight=t[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class Ye{constructor(t,e){this.image=t,this.resultPointCallback=e,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=e}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(t){const e=null!=t&&void 0!==t.get(T.TRY_HARDER),r=null!=t&&void 0!==t.get(T.PURE_BARCODE),n=this.image,i=n.getHeight(),o=n.getWidth();let s=Math.floor(3*i/(4*Ye.MAX_MODULES));(sl[2]&&(h+=t-l[2]-s,e=o-1)}t=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,t=3;else l[++t]++;else l[t]++;Ye.foundPatternCross(l)&&!0===this.handlePossibleCenter(l,h,o,r)&&(s=l[0],this.hasSkipped&&(a=this.haveMultiplyConfirmedCenters()))}const c=this.selectBestPatterns();return mt.orderBestPatterns(c),new ze(c)}static centerFromEnd(t,e){return e-t[4]-t[3]-t[2]/2}static foundPatternCross(t){let e=0;for(let i=0;i<5;i++){const r=t[i];if(0===r)return!1;e+=r}if(e<7)return!1;const r=e/7,n=r/2;return Math.abs(r-t[0])=o&&e>=o&&s.get(e-o,t-o);)i[2]++,o++;if(t=o&&e>=o&&!s.get(e-o,t-o)&&i[1]<=r;)i[1]++,o++;if(tr)return!1;for(;t>=o&&e>=o&&s.get(e-o,t-o)&&i[0]<=r;)i[0]++,o++;if(i[0]>r)return!1;const a=s.getHeight(),l=s.getWidth();for(o=1;t+o=a||e+o>=l)return!1;for(;t+o=a||e+o>=l||i[3]>=r)return!1;for(;t+o=r)return!1;const c=i[0]+i[1]+i[2]+i[3]+i[4];return Math.abs(c-n)<2*n&&Ye.foundPatternCross(i)}crossCheckVertical(t,e,r,n){const i=this.image,o=i.getHeight(),s=this.getCrossCheckStateCount();let a=t;for(;a>=0&&i.get(e,a);)s[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(e,a)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&i.get(e,a)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=t+1;a=r)return NaN;for(;a=r)return NaN;const l=s[0]+s[1]+s[2]+s[3]+s[4];return 5*Math.abs(l-n)>=2*n?NaN:Ye.foundPatternCross(s)?Ye.centerFromEnd(s,a):NaN}crossCheckHorizontal(t,e,r,n){const i=this.image,o=i.getWidth(),s=this.getCrossCheckStateCount();let a=t;for(;a>=0&&i.get(a,e);)s[2]++,a--;if(a<0)return NaN;for(;a>=0&&!i.get(a,e)&&s[1]<=r;)s[1]++,a--;if(a<0||s[1]>r)return NaN;for(;a>=0&&i.get(a,e)&&s[0]<=r;)s[0]++,a--;if(s[0]>r)return NaN;for(a=t+1;a=r)return NaN;for(;a=r)return NaN;const l=s[0]+s[1]+s[2]+s[3]+s[4];return 5*Math.abs(l-n)>=n?NaN:Ye.foundPatternCross(s)?Ye.centerFromEnd(s,a):NaN}handlePossibleCenter(t,e,r,n){const i=t[0]+t[1]+t[2]+t[3]+t[4];let o=Ye.centerFromEnd(t,r),s=this.crossCheckVertical(e,Math.floor(o),t[2],i);if(!isNaN(s)&&(o=this.crossCheckHorizontal(Math.floor(o),Math.floor(s),t[2],i),!isNaN(o)&&(!n||this.crossCheckDiagonal(Math.floor(s),Math.floor(o),t[2],i)))){const t=i/7;let e=!1;const r=this.possibleCenters;for(let n=0,i=r.length;n=Ye.CENTER_QUORUM){if(null!=t)return this.hasSkipped=!0,Math.floor((Math.abs(t.getX()-e.getX())-Math.abs(t.getY()-e.getY()))/2);t=e}return 0}haveMultiplyConfirmedCenters(){let t=0,e=0;const r=this.possibleCenters.length;for(const o of this.possibleCenters)o.getCount()>=Ye.CENTER_QUORUM&&(t++,e+=o.getEstimatedModuleSize());if(t<3)return!1;const n=e/r;let i=0;for(const o of this.possibleCenters)i+=Math.abs(o.getEstimatedModuleSize()-n);return i<=.05*e}selectBestPatterns(){const t=this.possibleCenters.length;if(t<3)throw new P;const e=this.possibleCenters;let r;if(t>3){let n=0,i=0;for(const t of this.possibleCenters){const e=t.getEstimatedModuleSize();n+=e,i+=e*e}r=n/t;let o=Math.sqrt(i/t-r*r);e.sort(((t,e)=>{const n=Math.abs(e.getEstimatedModuleSize()-r),i=Math.abs(t.getEstimatedModuleSize()-r);return ni?1:0}));const s=Math.max(.2*r,o);for(let t=0;t3;t++){const n=e[t];Math.abs(n.getEstimatedModuleSize()-r)>s&&(e.splice(t,1),t--)}}if(e.length>3){let t=0;for(const r of e)t+=r.getEstimatedModuleSize();r=t/e.length,e.sort(((t,e)=>{if(e.getCount()===t.getCount()){const n=Math.abs(e.getEstimatedModuleSize()-r),i=Math.abs(t.getEstimatedModuleSize()-r);return ni?-1:0}return e.getCount()-t.getCount()})),e.splice(3)}return[e[0],e[1],e[2]]}}Ye.CENTER_QUORUM=2,Ye.MIN_SKIP=3,Ye.MAX_MODULES=57;class Ze{constructor(t){this.image=t}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(t){this.resultPointCallback=null==t?null:t.get(T.NEED_RESULT_POINT_CALLBACK);const e=new Ye(this.image,this.resultPointCallback).find(t);return this.processFinderPatternInfo(e)}processFinderPatternInfo(t){const e=t.getTopLeft(),r=t.getTopRight(),n=t.getBottomLeft(),i=this.calculateModuleSize(e,r,n);if(i<1)throw new P("No pattern found in proccess finder.");const o=Ze.computeDimension(e,r,n,i),s=ve.getProvisionalVersionForDimension(o),a=s.getDimensionForVersion()-7;let l=null;if(s.getAlignmentPatternCenters().length>0){const t=r.getX()-e.getX()+n.getX(),o=r.getY()-e.getY()+n.getY(),s=1-3/a,c=Math.floor(e.getX()+s*(t-e.getX())),h=Math.floor(e.getY()+s*(o-e.getY()));for(let e=4;e<=16;e<<=1)try{l=this.findAlignmentInRegion(i,c,h,e);break}catch(d){if(!(d instanceof P))throw d}}const c=Ze.createTransform(e,r,n,l,o),h=Ze.sampleGrid(this.image,c,o);let u;return u=null===l?[n,e,r]:[n,e,r,l],new At(h,u)}static createTransform(t,e,r,n,i){const o=i-3.5;let s,a,l,c;return null!==n?(s=n.getX(),a=n.getY(),l=o-3,c=l):(s=e.getX()-t.getX()+r.getX(),a=e.getY()-t.getY()+r.getY(),l=o,c=o),pt.quadrilateralToQuadrilateral(3.5,3.5,o,3.5,l,c,3.5,o,t.getX(),t.getY(),e.getX(),e.getY(),s,a,r.getX(),r.getY())}static sampleGrid(t,e,r){return St.getInstance().sampleGridWithTransform(t,r,r,e)}static computeDimension(t,e,r,n){const i=gt.round(mt.distance(t,e)/n),o=gt.round(mt.distance(t,r)/n);let s=Math.floor((i+o)/2)+7;switch(3&s){case 0:s++;break;case 2:s--;break;case 3:throw new P("Dimensions could be not found.")}return s}calculateModuleSize(t,e,r){return(this.calculateModuleSizeOneWay(t,e)+this.calculateModuleSizeOneWay(t,r))/2}calculateModuleSizeOneWay(t,e){const r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY())),n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY()));return isNaN(r)?n/7:isNaN(n)?r/7:(r+n)/14}sizeOfBlackWhiteBlackRunBothWays(t,e,r,n){let i=this.sizeOfBlackWhiteBlackRun(t,e,r,n),o=1,s=t-(r-t);s<0?(o=t/(t-s),s=0):s>=this.image.getWidth()&&(o=(this.image.getWidth()-1-t)/(s-t),s=this.image.getWidth()-1);let a=Math.floor(e-(n-e)*o);return o=1,a<0?(o=e/(e-a),a=0):a>=this.image.getHeight()&&(o=(this.image.getHeight()-1-e)/(a-e),a=this.image.getHeight()-1),s=Math.floor(t+(s-t)*o),i+=this.sizeOfBlackWhiteBlackRun(t,e,s,a),i-1}sizeOfBlackWhiteBlackRun(t,e,r,n){const i=Math.abs(n-e)>Math.abs(r-t);if(i){let i=t;t=e,e=i,i=r,r=n,n=i}const o=Math.abs(r-t),s=Math.abs(n-e);let a=-o/2;const l=t0){if(f===n)break;f+=c,a-=o}}return 2===h?gt.distance(r+l,n,t,e):NaN}findAlignmentInRegion(t,e,r,n){const i=Math.floor(n*t),o=Math.max(0,e-i),s=Math.min(this.image.getWidth()-1,e+i);if(s-o<3*t)throw new P("Alignment top exceeds estimated module size.");const a=Math.max(0,r-i),l=Math.min(this.image.getHeight()-1,r+i);if(l-a<3*t)throw new P("Alignment bottom exceeds estimated module size.");return new Xe(this.image,o,a,s-o,l-a,t,this.resultPointCallback).find()}}class Ke{constructor(){this.decoder=new He}getDecoder(){return this.decoder}decode(t,e){let r,n;if(null!=e&&void 0!==e.get(T.PURE_BARCODE)){const i=Ke.extractPureBits(t.getBlackMatrix());r=this.decoder.decodeBitMatrix(i,e),n=Ke.NO_POINTS}else{const i=new Ze(t.getBlackMatrix()).detect(e);r=this.decoder.decodeBitMatrix(i.getBits(),e),n=i.getPoints()}r.getOther()instanceof Ve&&r.getOther().applyMirroredCorrection(n);const i=new X(r.getText(),r.getRawBytes(),void 0,n,Y.QR_CODE,void 0),o=r.getByteSegments();null!==o&&i.putMetadata(it.BYTE_SEGMENTS,o);const s=r.getECLevel();return null!==s&&i.putMetadata(it.ERROR_CORRECTION_LEVEL,s),r.hasStructuredAppend()&&(i.putMetadata(it.STRUCTURED_APPEND_SEQUENCE,r.getStructuredAppendSequenceNumber()),i.putMetadata(it.STRUCTURED_APPEND_PARITY,r.getStructuredAppendParity())),i}reset(){}static extractPureBits(t){const e=t.getTopLeftOnBit(),r=t.getBottomRightOnBit();if(null===e||null===r)throw new P;const n=this.moduleSize(e,t);let i=e[1],o=r[1],s=e[0],a=r[0];if(s>=a||i>=o)throw new P;if(o-i!=a-s&&(a=s+(o-i),a>=t.getWidth()))throw new P;const l=Math.round((a-s+1)/n),c=Math.round((o-i+1)/n);if(l<=0||c<=0)throw new P;if(c!==l)throw new P;const h=Math.floor(n/2);i+=h,s+=h;const u=s+Math.floor((l-1)*n)-a;if(u>0){if(u>h)throw new P;s-=u}const d=i+Math.floor((c-1)*n)-o;if(d>0){if(d>h)throw new P;i-=d}const f=new M(l,c);for(let g=0;g0;){const s=je.findGuardPattern(t,i,--n,r,!1,o,l);if(null==s){n++;break}e=s}s[0]=new mt(e[0],n),s[1]=new mt(e[1],n),a=!0;break}}let c=n+1;if(a){let n=0,i=Int32Array.from([Math.trunc(s[0].getX()),Math.trunc(s[1].getX())]);for(;cje.SKIPPED_ROW_COUNT_MAX)break;n++}}c-=n+1,s[2]=new mt(i[0],c),s[3]=new mt(i[1],c)}return c-n0&&l++i?n-i:i-n;if(o>r)return 1/0;a+=o}return a/i}}je.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),je.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),je.MAX_AVG_VARIANCE=.42,je.MAX_INDIVIDUAL_VARIANCE=.8,je.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),je.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),je.MAX_PIXEL_DRIFT=3,je.MAX_PATTERN_DRIFT=5,je.SKIPPED_ROW_COUNT_MAX=25,je.ROW_STEP=5,je.BARCODE_MIN_HEIGHT=10;class Je{constructor(t,e){if(0===e.length)throw new d;this.field=t;let r=e.length;if(r>1&&0===e[0]){let t=1;for(;tr.length){let t=e;e=r,r=t}let n=new Int32Array(r.length),i=r.length-e.length;m.arraycopy(r,0,n,0,i);for(let o=i;o=0;e--){let r=this.getCoefficient(e);0!==r&&(r<0?(t.append(" - "),r=-r):t.length()>0&&t.append(" + "),0!==e&&1===r||t.append(r),0!==e&&(1===e?t.append("x"):(t.append("x^"),t.append(e))))}return t.toString()}}class $e{add(t,e){return(t+e)%this.modulus}subtract(t,e){return(this.modulus+t-e)%this.modulus}exp(t){return this.expTable[t]}log(t){if(0===t)throw new d;return this.logTable[t]}inverse(t){if(0===t)throw new lt;return this.expTable[this.modulus-this.logTable[t]-1]}multiply(t,e){return 0===t||0===e?0:this.expTable[(this.logTable[t]+this.logTable[e])%(this.modulus-1)]}getSize(){return this.modulus}equals(t){return t===this}}class tr extends $e{constructor(t,e){super(),this.modulus=t,this.expTable=new Int32Array(t),this.logTable=new Int32Array(t);let r=1;for(let n=0;n0;f--){let t=n.evaluateAt(this.field.exp(f));i[e-f]=t,0!==t&&(o=!0)}if(!o)return 0;let s=this.field.getOne();if(null!=r)for(const f of r){let e=this.field.exp(t.length-1-f),r=new Je(this.field,new Int32Array([this.field.subtract(0,e),1]));s=s.multiply(r)}let a=new Je(this.field,i),l=this.runEuclideanAlgorithm(this.field.buildMonomial(e,1),a,e),c=l[0],h=l[1],u=this.findErrorLocations(c),d=this.findErrorMagnitudes(h,c,u);for(let f=0;f=Math.round(r/2);){let t=n,e=o;if(n=i,o=s,n.isZero())throw g.getChecksumInstance();i=t;let r=this.field.getZero(),a=n.getCoefficient(n.getDegree()),l=this.field.inverse(a);for(;i.getDegree()>=n.getDegree()&&!i.isZero();){let t=i.getDegree()-n.getDegree(),e=this.field.multiply(i.getCoefficient(i.getDegree()),l);r=r.add(this.field.buildMonomial(t,e)),i=i.subtract(n.multiplyByMonomial(t,e))}s=r.multiply(o).subtract(e).negative()}let a=s.getCoefficient(0);if(0===a)throw g.getChecksumInstance();let l=this.field.inverse(a);return[s.multiply(l),i.multiply(l)]}findErrorLocations(t){let e=t.getDegree(),r=new Int32Array(e),n=0;for(let i=1;i0){let e=r?this.topLeft:this.topRight,i=Math.trunc(e.getY()-t);i<0&&(i=0);let s=new mt(e.getX(),i);r?n=s:o=s}if(e>0){let t=r?this.bottomLeft:this.bottomRight,n=Math.trunc(t.getY()+e);n>=this.image.getHeight()&&(n=this.image.getHeight()-1);let o=new mt(t.getX(),n);r?i=o:s=o}return new rr(this.image,n,i,o,s)}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 nr{constructor(t,e,r,n){this.columnCount=t,this.errorCorrectionLevel=n,this.rowCountUpperPart=e,this.rowCountLowerPart=r,this.rowCount=e+r}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class ir{constructor(){this.buffer=""}static form(t,e){let r=-1;function n(t,n,i,o,s,a){if("%%"===t)return"%";if(void 0===e[++r])return;t=o?parseInt(o.substr(1)):void 0;let l,c=s?parseInt(s.substr(1)):void 0;switch(a){case"s":l=e[r];break;case"c":l=e[r][0];break;case"f":l=parseFloat(e[r]).toFixed(t);break;case"p":l=parseFloat(e[r]).toPrecision(t);break;case"e":l=parseFloat(e[r]).toExponential(t);break;case"x":l=parseInt(e[r]).toString(c||16);break;case"d":l=parseFloat(parseInt(e[r],c||10).toPrecision(t)).toFixed(0)}l="object"==typeof l?JSON.stringify(l):(+l).toString(c);let h=parseInt(i),u=i&&i[0]+""=="0"?"0":" ";for(;l.length=0&&(e=this.codewords[n],null!=e))return e;if(n=this.imageRowToCodewordIndex(t)+r,nr,getValue:()=>n};i.getValue()>t?(t=i.getValue(),e=[],e.push(i.getKey())):i.getValue()===t&&e.push(i.getKey())}return qe.toIntArray(e)}getConfidence(t){return this.values.get(t)}}class ar extends or{constructor(t,e){super(t),this._isLeft=e}setRowNumbers(){for(let t of this.getCodewords())null!=t&&t.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(t){let e=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(e,t);let r=this.getBoundingBox(),n=this._isLeft?r.getTopLeft():r.getTopRight(),i=this._isLeft?r.getBottomLeft():r.getBottomRight(),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.imageRowToCodewordIndex(Math.trunc(i.getY())),a=-1,l=1,c=0;for(let h=o;h=t.getRowCount()||n>h)e[h]=null;else{let t;t=l>2?(l-2)*n:n;let i=t>=h;for(let r=1;r<=t&&!i;r++)i=null!=e[h-r];i?e[h]=null:(a=r.getRowNumber(),c=1)}}}getRowHeights(){let t=this.getBarcodeMetadata();if(null==t)return null;this.adjustIncompleteIndicatorColumnRowNumbers(t);let e=new Int32Array(t.getRowCount());for(let r of this.getCodewords())if(null!=r){let t=r.getRowNumber();if(t>=e.length)continue;e[t]++}return e}adjustIncompleteIndicatorColumnRowNumbers(t){let e=this.getBoundingBox(),r=this._isLeft?e.getTopLeft():e.getTopRight(),n=this._isLeft?e.getBottomLeft():e.getBottomRight(),i=this.imageRowToCodewordIndex(Math.trunc(r.getY())),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),s=this.getCodewords(),a=-1;for(let l=i;l=t.getRowCount()?s[l]=null:a=e.getRowNumber())}}getBarcodeMetadata(){let t=this.getCodewords(),e=new sr,r=new sr,n=new sr,i=new sr;for(let s of t){if(null==s)continue;s.setRowNumberAsRowIndicatorColumn();let t=s.getValue()%30,o=s.getRowNumber();switch(this._isLeft||(o+=2),o%3){case 0:r.setValue(3*t+1);break;case 1:i.setValue(t/3),n.setValue(t%3);break;case 2:e.setValue(t+1)}}if(0===e.getValue().length||0===r.getValue().length||0===n.getValue().length||0===i.getValue().length||e.getValue()[0]<1||r.getValue()[0]+n.getValue()[0]qe.MAX_ROWS_IN_BARCODE)return null;let o=new nr(e.getValue()[0],r.getValue()[0],n.getValue()[0],i.getValue()[0]);return this.removeIncorrectCodewords(t,o),o}removeIncorrectCodewords(t,e){for(let r=0;re.getRowCount())t[r]=null;else switch(this._isLeft||(o+=2),o%3){case 0:3*i+1!==e.getRowCountUpperPart()&&(t[r]=null);break;case 1:Math.trunc(i/3)===e.getErrorCorrectionLevel()&&i%3===e.getRowCountLowerPart()||(t[r]=null);break;case 2:i+1!==e.getColumnCount()&&(t[r]=null)}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+"\n"+super.toString()}}class lr{constructor(t,e){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=t,this.barcodeColumnCount=t.getColumnCount(),this.boundingBox=e,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let t,e=qe.MAX_CODEWORDS_IN_BARCODE;do{t=e,e=this.adjustRowNumbersAndGetCount()}while(e>0&&e0&&i0&&(s[0]=r[e-1],s[4]=i[e-1],s[5]=o[e-1]),e>1&&(s[8]=r[e-2],s[10]=i[e-2],s[11]=o[e-2]),e>=1;r=1&e,hr.RATIOS_TABLE[t]||(hr.RATIOS_TABLE[t]=new Array(qe.BARS_IN_MODULE)),hr.RATIOS_TABLE[t][qe.BARS_IN_MODULE-n-1]=Math.fround(i/qe.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(t){let e=hr.getDecodedCodewordValue(hr.sampleBitCounts(t));return-1!==e?e:hr.getClosestDecodedValue(t)}static sampleBitCounts(t){let e=gt.sum(t),r=new Int32Array(qe.BARS_IN_MODULE),n=0,i=0;for(let o=0;o1)for(let o=0;o=n)break}tnew Array(qe.BARS_IN_MODULE)));class ur{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(t){this.segmentIndex=t}getFileId(){return this.fileId}setFileId(t){this.fileId=t}getOptionalData(){return this.optionalData}setOptionalData(t){this.optionalData=t}isLastSegment(){return this.lastSegment}setLastSegment(t){this.lastSegment=t}getSegmentCount(){return this.segmentCount}setSegmentCount(t){this.segmentCount=t}getSender(){return this.sender||null}setSender(t){this.sender=t}getAddressee(){return this.addressee||null}setAddressee(t){this.addressee=t}getFileName(){return this.fileName}setFileName(t){this.fileName=t}getFileSize(){return this.fileSize}setFileSize(t){this.fileSize=t}getChecksum(){return this.checksum}setChecksum(t){this.checksum=t}getTimestamp(){return this.timestamp}setTimestamp(t){this.timestamp=t}}class dr{static parseLong(t,e){return parseInt(t,e)}}class fr extends h{}fr.kind="NullPointerException";class gr{writeBytes(t){this.writeBytesOffset(t,0,t.length)}writeBytesOffset(t,e,r){if(null==t)throw new fr;if(e<0||e>t.length||r<0||e+r>t.length||e+r<0)throw new A;if(0!==r)for(let n=0;n0&&this.grow(t)}grow(t){let e=this.buf.length<<1;if(e-t<0&&(e=t),e<0){if(t<0)throw new wr;e=_.MAX_VALUE}this.buf=E.copyOfUint8Array(this.buf,e)}write(t){this.ensureCapacity(this.count+1),this.buf[this.count]=t,this.count+=1}writeBytesOffset(t,e,r){if(e<0||e>t.length||r<0||e+r-t.length>0)throw new A;this.ensureCapacity(this.count+r),m.arraycopy(t,e,this.buf,this.count,r),this.count+=r}writeTo(t){t.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return E.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(t){return t?"string"==typeof t?this.toString_string(t):this.toString_number(t):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(t){return new String(this.buf).toString()}toString_number(t){return new String(this.buf).toString()}close(){}}function Ar(){if("undefined"!=typeof window)return window.BigInt||null;if(void 0!==e)return e.BigInt||null;if("undefined"!=typeof self)return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let Cr;function Er(t){if(void 0===Cr&&(Cr=Ar()),null===Cr)throw new Error("BigInt is not supported!");return Cr(t)}function _r(){let t=[];t[0]=Er(1);let e=Er(900);t[1]=e;for(let r=2;r<16;r++)t[r]=t[r-1]*e;return t}!function(t){t[t.ALPHA=0]="ALPHA",t[t.LOWER=1]="LOWER",t[t.MIXED=2]="MIXED",t[t.PUNCT=3]="PUNCT",t[t.ALPHA_SHIFT=4]="ALPHA_SHIFT",t[t.PUNCT_SHIFT=5]="PUNCT_SHIFT"}(J||(J={}));class pr{static decode(t,e){let r=new b(""),n=y.ISO8859_1;r.enableDecoding(n);let i=1,o=t[i++],s=new ur;for(;it[0])throw R.getFormatInstance();let n=new Int32Array(pr.NUMBER_OF_SEQUENCE_CODEWORDS);for(let s=0;s0){for(let t=0;t<6;++t)o.write(Number(Er(a)>>Er(8*(5-t))));a=0,s=0}}n===e[0]&&r0){for(let t=0;t<6;++t)o.write(Number(Er(a)>>Er(8*(5-t))));a=0,s=0}}}return i.append(D.decode(o.toByteArray(),r)),n}static numericCompaction(t,e,r){let n=0,i=!1,o=new Int32Array(pr.MAX_NUMERIC_CODEWORDS);for(;e0&&(r.append(pr.decodeBase900toBase10(o,n)),n=0)}return e}static decodeBase900toBase10(t,e){let r=Er(0);for(let i=0;i@[\\]_`~!\r\t,:\n-.$/\"|*()?{}'",pr.MIXED_CHARS="0123456789&\r\t,:#-.$/+%*=^",pr.EXP900=Ar()?_r():[],pr.NUMBER_OF_SEQUENCE_CODEWORDS=2;class Ir{constructor(){}static decode(t,e,r,n,i,o,s){let a,l=new rr(t,e,r,n,i),c=null,h=null;for(let f=!0;;f=!1){if(null!=e&&(c=Ir.getRowIndicatorColumn(t,l,e,!0,o,s)),null!=n&&(h=Ir.getRowIndicatorColumn(t,l,n,!1,o,s)),a=Ir.merge(c,h),null==a)throw P.getNotFoundInstance();let r=a.getBoundingBox();if(!f||null==r||!(r.getMinY()l.getMaxY()))break;l=r}a.setBoundingBox(l);let u=a.getBarcodeColumnCount()+1;a.setDetectionResultColumn(0,c),a.setDetectionResultColumn(u,h);let d=null!=c;for(let f=1;f<=u;f++){let e,r=d?f:u-f;if(void 0!==a.getDetectionResultColumn(r))continue;e=0===r||r===u?new ar(l,0===r):new or(l),a.setDetectionResultColumn(r,e);let n=-1,i=n;for(let c=l.getMinY();c<=l.getMaxY();c++){if(n=Ir.getStartColumn(a,r,c,d),n<0||n>l.getMaxX()){if(-1===i)continue;n=i}let h=Ir.detectCodeword(t,l.getMinX(),l.getMaxX(),d,n,c,o,s);null!=h&&(e.setCodeword(c,h),i=n,o=Math.min(o,h.getWidth()),s=Math.max(s,h.getWidth()))}}return Ir.createDecoderResult(a)}static merge(t,e){if(null==t&&null==e)return null;let r=Ir.getBarcodeMetadata(t,e);if(null==r)return null;let n=rr.merge(Ir.adjustBoundingBox(t),Ir.adjustBoundingBox(e));return new lr(r,n)}static adjustBoundingBox(t){if(null==t)return null;let e=t.getRowHeights();if(null==e)return null;let r=Ir.getMax(e),n=0;for(let s of e)if(n+=r-s,s>0)break;let i=t.getCodewords();for(let s=0;n>0&&null==i[s];s++)n--;let o=0;for(let s=e.length-1;s>=0&&(o+=r-e[s],!(e[s]>0));s--);for(let s=i.length-1;o>0&&null==i[s];s--)o--;return t.getBoundingBox().addMissingRows(n,o,t.isLeft())}static getMax(t){let e=-1;for(let r of t)e=Math.max(e,r);return e}static getBarcodeMetadata(t,e){let r,n;return null==t||null==(r=t.getBarcodeMetadata())?null==e?null:e.getBarcodeMetadata():null==e||null==(n=e.getBarcodeMetadata())?r:r.getColumnCount()!==n.getColumnCount()&&r.getErrorCorrectionLevel()!==n.getErrorCorrectionLevel()&&r.getRowCount()!==n.getRowCount()?null:r}static getRowIndicatorColumn(t,e,r,n,i,o){let s=new ar(e,n);for(let a=0;a<2;a++){let l=0===a?1:-1,c=Math.trunc(Math.trunc(r.getX()));for(let a=Math.trunc(Math.trunc(r.getY()));a<=e.getMaxY()&&a>=e.getMinY();a+=l){let e=Ir.detectCodeword(t,0,t.getWidth(),n,c,a,i,o);null!=e&&(s.setCodeword(a,e),c=n?e.getStartX():e.getEndX())}}return s}static adjustCodewordCount(t,e){let r=e[0][1],n=r.getValue(),i=t.getBarcodeColumnCount()*t.getBarcodeRowCount()-Ir.getNumberOfECCodeWords(t.getBarcodeECLevel());if(0===n.length){if(i<1||i>qe.MAX_CODEWORDS_IN_BARCODE)throw P.getNotFoundInstance();r.setValue(i)}else n[0]!==i&&r.setValue(i)}static createDecoderResult(t){let e=Ir.createBarcodeMatrix(t);Ir.adjustCodewordCount(t,e);let r=new Array,n=new Int32Array(t.getBarcodeRowCount()*t.getBarcodeColumnCount()),i=[],o=new Array;for(let a=0;a0;){for(let t=0;tnew Array(t.getBarcodeColumnCount()+2)));for(let n=0;n=0){if(n>=e.length)continue;e[n][r].setValue(t.getValue())}}r++}return e}static isValidBarcodeColumn(t,e){return e>=0&&e<=t.getBarcodeColumnCount()+1}static getStartColumn(t,e,r,n){let i=n?1:-1,o=null;if(Ir.isValidBarcodeColumn(t,e-i)&&(o=t.getDetectionResultColumn(e-i).getCodeword(r)),null!=o)return n?o.getEndX():o.getStartX();if(o=t.getDetectionResultColumn(e).getCodewordNearby(r),null!=o)return n?o.getStartX():o.getEndX();if(Ir.isValidBarcodeColumn(t,e-i)&&(o=t.getDetectionResultColumn(e-i).getCodewordNearby(r)),null!=o)return n?o.getEndX():o.getStartX();let s=0;for(;Ir.isValidBarcodeColumn(t,e-i);){e-=i;for(let r of t.getDetectionResultColumn(e).getCodewords())if(null!=r)return(n?r.getEndX():r.getStartX())+i*s*(r.getEndX()-r.getStartX());s++}return n?t.getBoundingBox().getMinX():t.getBoundingBox().getMaxX()}static detectCodeword(t,e,r,n,i,o,s,a){i=Ir.adjustCodewordStartColumn(t,e,r,n,i,o);let l,c=Ir.getModuleBitCount(t,e,r,n,i,o);if(null==c)return null;let h=gt.sum(c);if(n)l=i+h;else{for(let t=0;t=e)&&l=e:sIr.CODEWORD_SKEW_SIZE)return i;s+=a}a=-a,n=!n}return s}static checkCodewordSkew(t,e,r){return e-Ir.CODEWORD_SKEW_SIZE<=t&&t<=r+Ir.CODEWORD_SKEW_SIZE}static decodeCodewords(t,e,r){if(0===t.length)throw R.getFormatInstance();let n=1<r/2+Ir.MAX_ERRORS||r<0||r>Ir.MAX_EC_CODEWORDS)throw g.getChecksumInstance();return Ir.errorCorrection.decode(t,r,e)}static verifyCodewordCount(t,e){if(t.length<4)throw R.getFormatInstance();let r=t[0];if(r>t.length)throw R.getFormatInstance();if(0===r){if(!(e>=1;return e}static getCodewordBucketNumber(t){return t instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(t):this.getCodewordBucketNumber_number(t)}static getCodewordBucketNumber_number(t){return Ir.getCodewordBucketNumber(Ir.getBitCountForCodeword(t))}static getCodewordBucketNumber_Int32Array(t){return(t[0]-t[2]+t[4]-t[6]+9)%9}static toString(t){let e=new ir;for(let r=0;rt))}static getMaxWidth(t,e){return null==t||null==e?0:Math.trunc(Math.abs(t.getX()-e.getX()))}static getMinWidth(t,e){return null==t||null==e?_.MAX_VALUE:Math.trunc(Math.abs(t.getX()-e.getX()))}static getMaxCodewordWidth(t){return Math.floor(Math.max(Math.max(Sr.getMaxWidth(t[0],t[4]),Sr.getMaxWidth(t[6],t[2])*qe.MODULES_IN_CODEWORD/qe.MODULES_IN_STOP_PATTERN),Math.max(Sr.getMaxWidth(t[1],t[5]),Sr.getMaxWidth(t[7],t[3])*qe.MODULES_IN_CODEWORD/qe.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(t){return Math.floor(Math.min(Math.min(Sr.getMinWidth(t[0],t[4]),Sr.getMinWidth(t[6],t[2])*qe.MODULES_IN_CODEWORD/qe.MODULES_IN_STOP_PATTERN),Math.min(Sr.getMinWidth(t[1],t[5]),Sr.getMinWidth(t[7],t[3])*qe.MODULES_IN_CODEWORD/qe.MODULES_IN_STOP_PATTERN)))}reset(){}}class Tr extends h{}Tr.kind="ReaderException";class Rr{constructor(t,e){this.verbose=!0===t,e&&this.setHints(e)}decode(t,e){return e&&this.setHints(e),this.decodeInternal(t)}decodeWithState(t){return null!==this.readers&&void 0!==this.readers||this.setHints(null),this.decodeInternal(t)}setHints(t){this.hints=t;const e=!r(t)&&!0===t.get(T.TRY_HARDER),n=r(t)?null:t.get(T.POSSIBLE_FORMATS),i=new Array;if(!r(n)){const r=n.some((t=>t===Y.UPC_A||t===Y.UPC_E||t===Y.EAN_13||t===Y.EAN_8||t===Y.CODABAR||t===Y.CODE_39||t===Y.CODE_93||t===Y.CODE_128||t===Y.ITF||t===Y.RSS_14||t===Y.RSS_EXPANDED));r&&!e&&i.push(new Ae(t,this.verbose)),n.includes(Y.QR_CODE)&&i.push(new Ke),n.includes(Y.DATA_MATRIX)&&i.push(new De),n.includes(Y.AZTEC)&&i.push(new yt),n.includes(Y.PDF_417)&&i.push(new Sr),r&&e&&i.push(new Ae(t,this.verbose))}0===i.length&&(e||i.push(new Ae(t,this.verbose)),i.push(new Ke),i.push(new De),i.push(new yt),i.push(new Sr),e&&i.push(new Ae(t,this.verbose))),this.readers=i}reset(){if(null!==this.readers)for(const t of this.readers)t.reset()}decodeInternal(t){if(null===this.readers)throw new Tr("No readers where selected, nothing can be read.");for(const r of this.readers)try{return r.decode(t,this.hints)}catch(e){if(e instanceof Tr)continue}throw new P("No MultiFormat Readers were able to detect the code.")}}class yr extends G{constructor(t=null,e=500){const r=new Rr;r.setHints(t),super(r,e)}decodeBitmap(t){return this.reader.decodeWithState(t)}}class Nr extends G{constructor(t=500){super(new Sr,t)}}class Dr extends G{constructor(t=500){super(new Ke,t)}}var Or,br;(br=Or||(Or={}))[br.ERROR_CORRECTION=0]="ERROR_CORRECTION",br[br.CHARACTER_SET=1]="CHARACTER_SET",br[br.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",br[br.MIN_SIZE=3]="MIN_SIZE",br[br.MAX_SIZE=4]="MAX_SIZE",br[br.MARGIN=5]="MARGIN",br[br.PDF417_COMPACT=6]="PDF417_COMPACT",br[br.PDF417_COMPACTION=7]="PDF417_COMPACTION",br[br.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",br[br.AZTEC_LAYERS=9]="AZTEC_LAYERS",br[br.QR_VERSION=10]="QR_VERSION";var Mr=Or;class Pr{constructor(t){this.field=t,this.cachedGenerators=[],this.cachedGenerators.push(new at(t,Int32Array.from([1])))}buildGenerator(t){const e=this.cachedGenerators;if(t>=e.length){let r=e[e.length-1];const n=this.field;for(let i=e.length;i<=t;i++){const t=r.multiply(new at(n,Int32Array.from([1,n.exp(i-1+n.getGeneratorBase())])));e.push(t),r=t}}return e[t]}encode(t,e){if(0===e)throw new d("No error correction bytes");const r=t.length-e;if(r<=0)throw new d("No data bytes provided");const n=this.buildGenerator(e),i=new Int32Array(r);m.arraycopy(t,0,i,0,r);let o=new at(this.field,i);o=o.multiplyByMonomial(e,1);const s=o.divide(n)[1].getCoefficients(),a=e-s.length;for(let l=0;l=5&&(r+=Br.N1+(t-5)),t=1,n=i)}t>=5&&(r+=Br.N1+(t-5))}return r}}Br.N1=3,Br.N2=3,Br.N3=40,Br.N4=10;class vr{constructor(t,e){this.width=t,this.height=e;const r=new Array(e);for(let n=0;n!==e;n++)r[n]=new Uint8Array(t);this.bytes=r}getHeight(){return this.height}getWidth(){return this.width}get(t,e){return this.bytes[e][t]}getArray(){return this.bytes}setNumber(t,e,r){this.bytes[e][t]=r}setBoolean(t,e,r){this.bytes[e][t]=r?1:0}clear(t){for(const e of this.bytes)E.fill(e,t)}equals(t){if(!(t instanceof vr))return!1;const e=t;if(this.width!==e.width)return!1;if(this.height!==e.height)return!1;for(let r=0,n=this.height;r>\n"),t.toString()}setMode(t){this.mode=t}setECLevel(t){this.ecLevel=t}setVersion(t){this.version=t}setMaskPattern(t){this.maskPattern=t}setMatrix(t){this.matrix=t}static isValidMaskPattern(t){return t>=0&&t0;){for(6===o&&(o-=1);s>=0&&s=r;)t^=e<=0)for(let r=0;r!==o;r++){const i=n[r];i>=0&&kr.isEmpty(e.get(i,t))&&kr.embedPositionAdjustmentPattern(i-2,t-2,e)}}}}kr.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])]),kr.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])]),kr.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])]),kr.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])]),kr.VERSION_INFO_POLY=7973,kr.TYPE_INFO_POLY=1335,kr.TYPE_INFO_MASK_PATTERN=21522;class xr{constructor(t,e){this.dataBytes=t,this.errorCorrectionBytes=e}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Ur{constructor(){}static calculateMaskPenalty(t){return Br.applyMaskPenaltyRule1(t)+Br.applyMaskPenaltyRule2(t)+Br.applyMaskPenaltyRule3(t)+Br.applyMaskPenaltyRule4(t)}static encode(t,e,r=null){let n=Ur.DEFAULT_BYTE_MODE_ENCODING;const i=null!==r&&void 0!==r.get(Mr.CHARACTER_SET);i&&(n=r.get(Mr.CHARACTER_SET).toString());const o=this.chooseMode(t,n),s=new p;if(o===xe.BYTE&&(i||Ur.DEFAULT_BYTE_MODE_ENCODING!==n)){const t=y.getCharacterSetECIByName(n);void 0!==t&&this.appendECI(t,s)}this.appendModeInfo(o,s);const a=new p;let l;if(this.appendBytes(t,o,a,n),null!==r&&void 0!==r.get(Mr.QR_VERSION)){const t=Number.parseInt(r.get(Mr.QR_VERSION).toString(),10);l=ve.getVersionForNumber(t);const n=this.calculateBitsNeeded(o,s,a,l);if(!this.willFit(n,l,e))throw new Fr("Data too big for requested version")}else l=this.recommendVersion(e,o,s,a);const c=new p;c.appendBitArray(s);const h=o===xe.BYTE?a.getSizeInBytes():t.length;this.appendLengthInfo(h,l,o,c),c.appendBitArray(a);const u=l.getECBlocksForLevel(e),d=l.getTotalCodewords()-u.getTotalECCodewords();this.terminateBits(d,c);const f=this.interleaveWithECBytes(c,l.getTotalCodewords(),d,u.getNumBlocks()),g=new Lr;g.setECLevel(e),g.setMode(o),g.setVersion(l);const w=l.getDimensionForVersion(),m=new vr(w,w),A=this.chooseMaskPattern(f,e,l,m);return g.setMaskPattern(A),kr.buildMatrix(f,e,l,A,m),g.setMatrix(m),g}static recommendVersion(t,e,r,n){const i=this.calculateBitsNeeded(e,r,n,ve.getVersionForNumber(1)),o=this.chooseVersion(i,t),s=this.calculateBitsNeeded(e,r,n,o);return this.chooseVersion(s,t)}static calculateBitsNeeded(t,e,r,n){return e.getSize()+t.getCharacterCountBits(n)+r.getSize()}static getAlphanumericCode(t){return t159)&&(t<224||t>235))return!1}return!0}static chooseMaskPattern(t,e,r,n){let i=Number.MAX_SAFE_INTEGER,o=-1;for(let s=0;s=(t+7)/8}static terminateBits(t,e){const r=8*t;if(e.getSize()>r)throw new Fr("data bits cannot fit in the QR Code"+e.getSize()+" > "+r);for(let o=0;o<4&&e.getSize()0)for(let o=n;o<8;o++)e.appendBit(!1);const i=t-e.getSizeInBytes();for(let o=0;o=r)throw new Fr("Block ID too large");const s=t%r,a=r-s,l=Math.floor(t/r),c=l+1,h=Math.floor(e/r),u=h+1,d=l-h,f=c-u;if(d!==f)throw new Fr("EC bytes mismatch");if(r!==a+s)throw new Fr("RS blocks mismatch");if(t!==(h+d)*a+(u+f)*s)throw new Fr("Total bytes mismatch");n=1<=0&&e<=9}static appendNumericBytes(t,e){const r=t.length;let n=0;for(;n=33088&&t<=40956?n=t-33088:t>=57408&&t<=60351&&(n=t-49472),-1===n)throw new Fr("Invalid byte sequence");const i=192*(n>>8)+(255&n);e.appendBits(i,13)}}static appendECI(t,e){e.appendBits(xe.ECI.getBits(),4),e.appendBits(t.getValue(),8)}}Ur.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]),Ur.DEFAULT_BYTE_MODE_ENCODING=y.UTF8.getName();class Vr{write(t,e,r,n=null){if(0===t.length)throw new d("Found empty contents");if(e<0||r<0)throw new d("Requested dimensions are too small: "+e+"x"+r);let i=be.L,o=Vr.QUIET_ZONE_SIZE;null!==n&&(void 0!==n.get(Mr.ERROR_CORRECTION)&&(i=be.fromString(n.get(Mr.ERROR_CORRECTION).toString())),void 0!==n.get(Mr.MARGIN)&&(o=Number.parseInt(n.get(Mr.MARGIN).toString(),10)));const s=Ur.encode(t,i,n);return this.renderResult(s,e,r,o)}writeToDom(t,e,r,n,i=null){"string"==typeof t&&(t=document.querySelector(t));const o=this.write(e,r,n,i);t&&t.appendChild(o)}renderResult(t,e,r,n){const i=t.getMatrix();if(null===i)throw new ut;const o=i.getWidth(),s=i.getHeight(),a=o+2*n,l=s+2*n,c=Math.max(e,a),h=Math.max(r,l),u=Math.min(Math.floor(c/a),Math.floor(h/l)),d=Math.floor((c-o*u)/2),f=Math.floor((h-s*u)/2),g=this.createSVGElement(c,h);for(let w=0,m=f;we||i+s>r)throw new d("Crop rectangle does not fit within image data.");a&&this.reverseHorizontal(o,s)}getRow(t,e){if(t<0||t>=this.getHeight())throw new d("Requested row is outside the image: "+t);const r=this.getWidth();(null==e||e.length>16&255,o=r>>7&510,s=255&r;i[e]=(n+o+s)/4&255}this.luminances=i}else this.luminances=t;if(void 0===n&&(this.dataWidth=e),void 0===i&&(this.dataHeight=r),void 0===o&&(this.left=0),void 0===s&&(this.top=0),this.left+e>this.dataWidth||this.top+r>this.dataHeight)throw new d("Crop rectangle does not fit within image data.")}getRow(t,e){if(t<0||t>=this.getHeight())throw new d("Requested row is outside the image: "+t);const r=this.getWidth();(null==e||e.length"}}class jr extends Qr{constructor(t,e,r){super(t,0,0),this.binaryShiftStart=e,this.binaryShiftByteCount=r}appendTo(t,e){for(let r=0;r62?t.appendBits(this.binaryShiftByteCount-31,16):0===r?t.appendBits(Math.min(this.binaryShiftByteCount,31),5):t.appendBits(this.binaryShiftByteCount-31,5)),t.appendBits(e[this.binaryShiftStart+r],8)}addBinaryShift(t,e){return new jr(this,t,e)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Jr(t,e,r){return new jr(t,e,r)}function $r(t,e,r){return new Qr(t,e,r)}const tn=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],en=0,rn=1,nn=2,on=3,sn=4,an=new Qr(null,0,0),ln=[Int32Array.from([0,327708,327710,327709,656318]),Int32Array.from([590318,0,327710,327709,656318]),Int32Array.from([262158,590300,0,590301,932798]),Int32Array.from([327709,327708,656318,0,327710]),Int32Array.from([327711,656380,656382,656381,0])];function cn(t){for(let e of t)E.fill(e,-1);return t[en][sn]=0,t[rn][sn]=0,t[rn][en]=28,t[on][sn]=0,t[nn][sn]=0,t[nn][en]=15,t}const hn=cn(E.createInt32Array(6,6));class un{constructor(t,e,r,n){this.token=t,this.mode=e,this.binaryShiftByteCount=r,this.bitCount=n}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(t,e){let r=this.bitCount,n=this.token;if(t!==this.mode){let e=ln[this.mode][t];n=$r(n,65535&e,e>>16),r+=e>>16}let i=t===nn?4:5;return n=$r(n,e,i),new un(n,t,0,r+i)}shiftAndAppend(t,e){let r=this.token,n=this.mode===nn?4:5;return r=$r(r,hn[this.mode][t],n),r=$r(r,e,5),new un(r,this.mode,0,this.bitCount+n+5)}addBinaryShiftChar(t){let e=this.token,r=this.mode,n=this.bitCount;if(this.mode===sn||this.mode===nn){let t=ln[r][en];e=$r(e,65535&t,t>>16),n+=t>>16,r=en}let i=0===this.binaryShiftByteCount||31===this.binaryShiftByteCount?18:62===this.binaryShiftByteCount?9:8,o=new un(e,r,this.binaryShiftByteCount+1,n+i);return 2078===o.binaryShiftByteCount&&(o=o.endBinaryShift(t+1)),o}endBinaryShift(t){if(0===this.binaryShiftByteCount)return this;let e=this.token;return e=Jr(e,t-this.binaryShiftByteCount,this.binaryShiftByteCount),new un(e,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(t){let e=this.bitCount+(ln[this.mode][t.mode]>>16);return this.binaryShiftByteCountt.binaryShiftByteCount&&t.binaryShiftByteCount>0&&(e+=10),e<=t.bitCount}toBitArray(t){let e=[];for(let n=this.endBinaryShift(t.length).token;null!==n;n=n.getPrevious())e.unshift(n);let r=new p;for(const n of e)n.appendTo(r,t);return r}toString(){return O.format("%s bits=%d bytes=%d",tn[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(t){return t.binaryShiftByteCount>62?21:t.binaryShiftByteCount>31?20:t.binaryShiftByteCount>0?10:0}}function dn(t){const e=O.getCharCode(" "),r=O.getCharCode("."),n=O.getCharCode(",");t[en][e]=1;const i=O.getCharCode("Z"),o=O.getCharCode("A");for(let d=o;d<=i;d++)t[en][d]=d-o+2;t[rn][e]=1;const s=O.getCharCode("z"),a=O.getCharCode("a");for(let d=a;d<=s;d++)t[rn][d]=d-a+2;t[nn][e]=1;const l=O.getCharCode("9"),c=O.getCharCode("0");for(let d=c;d<=l;d++)t[nn][d]=d-c+2;t[nn][n]=12,t[nn][r]=13;const h=["\0"," ","","","","","","","","\b","\t","\n","\v","\f","\r","","","","","","@","\\","^","_","`","|","~",""];for(let d=0;d","?","[","]","{","}"];for(let d=0;d0&&(t[sn][O.getCharCode(u[d])]=d);return t}un.INITIAL_STATE=new un(an,en,0,0);const fn=dn(E.createInt32Array(5,256));class gn{constructor(t){this.text=t}encode(){const t=O.getCharCode(" "),e=O.getCharCode("\n");let r=Kr.singletonList(un.INITIAL_STATE);for(let n=0;n0?(r=gn.updateStateListForPair(r,n,i),n++):r=this.updateStateListForChar(r,n)}return Kr.min(r,((t,e)=>t.getBitCount()-e.getBitCount())).toBitArray(this.text)}updateStateListForChar(t,e){const r=[];for(let n of t)this.updateStateForChar(n,e,r);return gn.simplifyStates(r)}updateStateForChar(t,e,r){let n=255&this.text[e],i=fn[t.getMode()][n]>0,o=null;for(let s=0;s<=sn;s++){let a=fn[s][n];if(a>0){if(null==o&&(o=t.endBinaryShift(e)),!i||s===t.getMode()||s===nn){const t=o.latchAndAppend(s,a);r.push(t)}if(!i&&hn[t.getMode()][s]>=0){const t=o.shiftAndAppend(s,a);r.push(t)}}}if(t.getBinaryShiftByteCount()>0||0===fn[t.getMode()][n]){let n=t.addBinaryShiftChar(e);r.push(n)}}static updateStateListForPair(t,e,r){const n=[];for(let i of t)this.updateStateForPair(i,e,r,n);return this.simplifyStates(n)}static updateStateForPair(t,e,r,n){let i=t.endBinaryShift(e);if(n.push(i.latchAndAppend(sn,r)),t.getMode()!==sn&&n.push(i.shiftAndAppend(sn,r)),3===r||4===r){let t=i.latchAndAppend(nn,16-r).latchAndAppend(nn,1);n.push(t)}if(t.getBinaryShiftByteCount()>0){let r=t.addBinaryShiftChar(e).addBinaryShiftChar(e+1);n.push(r)}}static simplifyStates(t){let e=[];for(const r of t){let t=!0;for(const n of e){if(n.isBetterThanOrEqualTo(r)){t=!1;break}r.isBetterThanOrEqualTo(n)&&(e=e.filter((t=>t!==n)))}t&&e.push(r)}return e}}class wn{constructor(){}static encodeBytes(t){return wn.encode(t,wn.DEFAULT_EC_PERCENT,wn.DEFAULT_AZTEC_LAYERS)}static encode(t,e,r){let n,i,o,s,a,l=new gn(t).encode(),c=_.truncDivision(l.getSize()*e,100)+11,h=l.getSize()+c;if(r!==wn.DEFAULT_AZTEC_LAYERS){if(n=r<0,i=Math.abs(r),i>(n?wn.MAX_NB_BITS_COMPACT:wn.MAX_NB_BITS))throw new d(O.format("Illegal value %s for layers",r));o=wn.totalBitsInLayer(i,n),s=wn.WORD_SIZE[i];let t=o-o%s;if(a=wn.stuffBits(l,s),a.getSize()+c>t)throw new d("Data to large for user specified layer");if(n&&a.getSize()>64*s)throw new d("Data to large for user specified layer")}else{s=0,a=null;for(let t=0;;t++){if(t>wn.MAX_NB_BITS)throw new d("Data too large for an Aztec code");if(n=t<=3,i=n?t+1:t,o=wn.totalBitsInLayer(i,n),h>o)continue;null!=a&&s===wn.WORD_SIZE[i]||(s=wn.WORD_SIZE[i],a=wn.stuffBits(l,s));let e=o-o%s;if(!(n&&a.getSize()>64*s)&&a.getSize()+c<=e)break}}let u,f=wn.generateCheckWords(a,o,s),g=a.getSize()/s,w=wn.generateModeMessage(n,i,g),m=(n?11:14)+4*i,A=new Int32Array(m);if(n){u=m;for(let t=0;t=n||t.get(o+r))&&(s|=1<0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]r&&(r=s,e=o)}if(!e)throw"No largest barcode found";return e},t.prototype.createBarcodeDetectorFormats=function(t){for(var e=[],r=0,n=t;r0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]=n&&(t.isClosed=!0,t.parentElement.removeChild(t.surface),e())}))}))},t.prototype.getCapabilities=function(){return new ut(this.getFirstTrackOrFail())},t}(),ft=function(){function t(t){this.mediaStream=t}return t.prototype.render=function(t,e,r){return st(this,void 0,void 0,(function(){return at(this,(function(n){return[2,dt.create(t,this.mediaStream,e,r)]}))}))},t.create=function(e){return st(this,void 0,void 0,(function(){var r;return at(this,(function(n){switch(n.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return r={audio:!1,video:e},[4,navigator.mediaDevices.getUserMedia(r)];case 1:return[2,new t(n.sent())]}}))}))},t}(),gt=globalThis&&globalThis.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(i,o){function s(t){try{l(n.next(t))}catch(e){o(e)}}function a(t){try{l(n.throw(t))}catch(e){o(e)}}function l(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))},wt=globalThis&&globalThis.__generator||function(t,e){var r,n,i,o,s={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(a){return function(l){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;o&&(o=0,a[0]&&(s=0)),s;)try{if(r=1,n&&(i=2&a[0]?n.return:a[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,a[1])).done)return i;switch(n=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return s.label++,{value:a[1],done:!1};case 5:s.label++,n=a[1],a=[0];continue;case 7:a=s.ops.pop(),s.trys.pop();continue;default:if(!(i=s.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]0&&i[i.length-1])||6!==a[0]&&2!==a[0])){s=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]t&&(n.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."),o=t),o)},t.prototype.validateQrboxConfig=function(t){if("number"!=typeof t&&"function"!=typeof t&&(void 0===t.width||void 0===t.height))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},t.prototype.toQrdimensions=function(t,e,r){if("number"==typeof r)return{width:r,height:r};if("function"==typeof r)try{return r(t,e)}catch(n){throw new Error("qrbox config was passed as a function but it failed with unknown error"+n)}return r},t.prototype.setupUi=function(t,e,r){r.isShadedBoxEnabled()&&this.validateQrboxSize(t,e,r);var n=W(r.qrbox)?{width:t,height:e}:r.qrbox;this.validateQrboxConfig(n);var i=this.toQrdimensions(t,e,n);i.height>e&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var o=r.isShadedBoxEnabled()&&i.height<=e,s={x:0,y:0,width:t,height:e},a=o?this.getShadedRegionBounds(t,e,i):s,l=this.createCanvasElement(a.width,a.height),c=l.getContext("2d",{willReadFrequently:!0});c.canvas.width=a.width,c.canvas.height=a.height,this.element.append(l),o&&this.possiblyInsertShadingElement(this.element,t,e,i),this.createScannerPausedUiElement(this.element),this.qrRegion=a,this.context=c,this.canvasElement=l},t.prototype.createScannerPausedUiElement=function(t){var e=document.createElement("div");e.innerText=z.scannerPaused(),e.style.display="none",e.style.position="absolute",e.style.top="0px",e.style.zIndex="1",e.style.background="rgba(9, 9, 9, 0.46)",e.style.color="#FFECEC",e.style.textAlign="center",e.style.width="100%",t.appendChild(e),this.scannerPausedUiElement=e},t.prototype.scanContext=function(t,e){var r=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then((function(e){return t(e.text,H.createFromQrcodeResult(e)),r.possiblyUpdateShaders(!0),!0})).catch((function(t){r.possiblyUpdateShaders(!1);var n=z.codeParseError(t);return e(n,G.createFrom(n)),!1}))},t.prototype.foreverScan=function(t,e,r){var n=this;if(this.shouldScan&&this.renderedCamera){var i=this.renderedCamera.getSurface(),o=i.videoWidth/i.clientWidth,s=i.videoHeight/i.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var a=this.qrRegion.width*o,l=this.qrRegion.height*s,c=this.qrRegion.x*o,h=this.qrRegion.y*s;this.context.drawImage(i,c,h,a,l,0,0,this.qrRegion.width,this.qrRegion.height);var u=function(){n.foreverScanTimeout=setTimeout((function(){n.foreverScan(t,e,r)}),n.getTimeoutFps(t.fps))};this.scanContext(e,r).then((function(i){i||!0===t.disableFlip?u():(n.context.translate(n.context.canvas.width,0),n.context.scale(-1,1),n.scanContext(e,r).finally((function(){u()})))})).catch((function(t){n.logger.logError("Error happend while scanning context",t),u()}))}},t.prototype.createVideoConstraints=function(t){if("string"==typeof t)return{deviceId:{exact:t}};if("object"==typeof t){var e="facingMode",r="deviceId",n={user:!0,environment:!0},i="exact",o=function(t){if(t in n)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(t,"'")},s=Object.keys(t);if(1!==s.length)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(s.length," keys");var a=Object.keys(t)[0];if(a!==e&&a!==r)throw"Only '".concat(e,"' and '").concat(r,"' ")+" are supported for 'cameraIdOrConfig'";if(a!==e){var l=t.deviceId;if("string"==typeof l)return{deviceId:l};if("object"==typeof l){if(i in l)return{deviceId:{exact:l["".concat(i)]}};throw"'deviceId' should be string or object with"+" ".concat(i," as key.")}throw"Invalid type of 'deviceId' = ".concat(typeof l)}var c=t.facingMode;if("string"==typeof c){if(o(c))return{facingMode:c}}else{if("object"!=typeof c)throw"Invalid type of 'facingMode' = ".concat(typeof c);if(!(i in c))throw"'facingMode' should be string or object with"+" ".concat(i," as key.");if(o(c["".concat(i)]))return{facingMode:{exact:c["".concat(i)]}}}}throw"Invalid type of 'cameraIdOrConfig' = ".concat(typeof t)},t.prototype.computeCanvasDrawConfig=function(t,e,r,n){if(t<=r&&e<=n)return{x:(r-t)/2,y:(n-e)/2,width:t,height:e};var i=t,o=e;return t>r&&(e*=r/t,t=r),e>n&&(t*=n/e,e=n),this.logger.log("Image downsampled from "+"".concat(i,"X").concat(o)+" to ".concat(t,"X").concat(e,".")),this.computeCanvasDrawConfig(t,e,r,n)},t.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var t=document.getElementById(this.elementId);t&&(t.innerHTML="")},t.prototype.possiblyUpdateShaders=function(t){this.qrMatch!==t&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach((function(e){e.style.backgroundColor=t?yt.BORDER_SHADER_MATCH_COLOR:yt.BORDER_SHADER_DEFAULT_COLOR})),this.qrMatch=t)},t.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},t.prototype.createCanvasElement=function(t,e,r){var n=t,i=e,o=document.createElement("canvas");return o.style.width="".concat(n,"px"),o.style.height="".concat(i,"px"),o.style.display="none",o.id=W(r)?"qr-canvas":r,o},t.prototype.getShadedRegionBounds=function(t,e,r){if(r.width>t||r.height>e)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(t-r.width)/2,y:(e-r.height)/2,width:r.width,height:r.height}},t.prototype.possiblyInsertShadingElement=function(t,e,r,n){if(!(e-n.width<1||r-n.height<1)){var i=document.createElement("div");i.style.position="absolute";var o=(e-n.width)/2,s=(r-n.height)/2;if(i.style.borderLeft="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderRight="".concat(o,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderTop="".concat(s,"px solid rgba(0, 0, 0, 0.48)"),i.style.borderBottom="".concat(s,"px solid rgba(0, 0, 0, 0.48)"),i.style.boxSizing="border-box",i.style.top="0px",i.style.bottom="0px",i.style.left="0px",i.style.right="0px",i.id="".concat(yt.SHADED_REGION_ELEMENT_ID),e-n.width<11||r-n.height<11)this.hasBorderShaders=!1;else{var a=40;this.insertShaderBorders(i,a,5,-5,null,0,!0),this.insertShaderBorders(i,a,5,-5,null,0,!1),this.insertShaderBorders(i,a,5,null,-5,0,!0),this.insertShaderBorders(i,a,5,null,-5,0,!1),this.insertShaderBorders(i,5,45,-5,null,-5,!0),this.insertShaderBorders(i,5,45,null,-5,-5,!0),this.insertShaderBorders(i,5,45,-5,null,-5,!1),this.insertShaderBorders(i,5,45,null,-5,-5,!1),this.hasBorderShaders=!0}t.append(i)}},t.prototype.insertShaderBorders=function(t,e,r,n,i,o,s){var a=document.createElement("div");a.style.position="absolute",a.style.backgroundColor=yt.BORDER_SHADER_DEFAULT_COLOR,a.style.width="".concat(e,"px"),a.style.height="".concat(r,"px"),null!==n&&(a.style.top="".concat(n,"px")),null!==i&&(a.style.bottom="".concat(i,"px")),s?a.style.left="".concat(o,"px"):a.style.right="".concat(o,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(a),t.appendChild(a)},t.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},t.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},t.prototype.getTimeoutFps=function(t){return 1e3/t},t}();globalThis&&globalThis.__awaiter,globalThis&&globalThis.__generator,globalThis&&globalThis.__awaiter,globalThis&&globalThis.__generator,(pt=_t||(_t={}))[pt.STATUS_DEFAULT=0]="STATUS_DEFAULT",pt[pt.STATUS_SUCCESS=1]="STATUS_SUCCESS",pt[pt.STATUS_WARNING=2]="STATUS_WARNING",pt[pt.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION";const Ot=N({__name:"index",setup(e){const{toast:r,loading:N,hideLoading:D}=R(),{scrollTop:O}=S(),{qrCodeScan:b,cancelScan:M}=(()=>{let t;const e=async e=>new Promise((async(e,r)=>{try{const r=window.innerWidth||document.documentElement.offsetWidth,i=window.innerHeight||document.documentElement.offsetHeight;t=new Dt("reader");const o=await Dt.getCameras();await t.start(o[o.length-1].id,{fps:1,aspectRatio:i/r},((r,n)=>{e(r),t.stop()})),n()}catch(i){r(i)}}));return{qrCodeScan:(t={})=>{let r;return r=e(),r},cancelScan:()=>{t&&t.stop()}}})(),P=i("");async function B(){if(!P.value)return r({title:"核销码有误"});try{N(),await(e={writeOffCode:P.value},t.post("/order/writeOff",e)),P.value="",D(),r({title:"核销成功"})}catch(n){D()}var e}const v=i();function L(){P.value.length<=0||v.value.show()}function F(){P.value=""}const k=i(!1);async function x(){try{k.value=!0,A({title:"加载中..."}),P.value=await b(),L()}finally{k.value=!1,n()}}function U(){M(),k.value=!1}return(t,e)=>{const r=d,n=C,i=E,A=f(_("uv-icon"),p);return o(),s(u,null,[a(r,null,{default:l((()=>[a(I,{"scroll-top":g(O),"system-bar-area-bg":"#fff","header-area-bg":"#fff"},{default:l((()=>[w(" 订单核销 ")])),_:1},8,["scroll-top"]),a(r,{class:"verification"},{default:l((()=>[a(r,{class:"ver-card"},{default:l((()=>[a(r,{class:"title"},{default:l((()=>[w("核销券码")])),_:1}),a(r,{class:"input row"},{default:l((()=>[a(n,{modelValue:P.value,"onUpdate:modelValue":e[0]||(e[0]=t=>P.value=t),type:"text",placeholder:"请输入核销券码"},null,8,["modelValue"])])),_:1}),a(r,{class:m(["btn-row row animation-button",{disabled:P.value.length<=0}]),onClick:L},{default:l((()=>[w(" 确认核销 ")])),_:1},8,["class"])])),_:1}),a(r,{class:"ver-card"},{default:l((()=>[a(r,{class:"title"},{default:l((()=>[w("二维码核销")])),_:1}),a(r,{class:"qr-scan row"},{default:l((()=>[a(i,{src:g(T),onClick:x},null,8,["src"])])),_:1})])),_:1})])),_:1})])),_:1}),a(y,{ref_key:"modalRef",ref:v,content:"确认要核销此订单吗?",onConfirm:B,onCancel:F},null,512),c("div",{class:"qr-h5",style:h({scale:k.value?1:0})},[c("div",{id:"reader"}),c("div",{class:"cancel",onClick:U},[a(A,{name:"close",color:"#fff",size:"28"})])],4)],64)}}},[["__scopeId","data-v-64e3ed53"]]);export{Ot as default};