1var Ks=Object.defineProperty;var Qs=(g,h,l)=>h in g?Ks(g,h,{enumerable:!0,configurable:!0,writable:!0,value:l}):g[h]=l;var fn=(g,h,l)=>Qs(g,typeof h!="symbol"?h+"":h,l);import{j as A}from"./vendor-ui-DNjgCPRa.js";import{d as Tr,r as ae,f as ns,h as qs,L as Js}from"./vendor-react-DRUUXq_3.js";import{f as $s,D as ei}from"./DashboardHeader-6QyHcTji.js";import{r as nr,a as Ht,B as st,C as jt,b as ss,c as is,d as Kt,G as ti,e as pn,u as as,J as ri,v as os,n as ni,p as si,P as Hn,X as Vn,D as ii,A as ai,Z as oi,E as ci,I as li,ah as ui,S as hi}from"./main-DLPuQ112.js";import{Z as di}from"./zap-VOLlcwuz.js";import{B as Rr}from"./badge-Dg0zGiXB.js";import{W as fi}from"./wifi-B3NmIZYI.js";import{T as xi}from"./triangle-alert-C8l_M04Y.js";import{S as gi,a as mi,b as wi,c as Ai,d as pi}from"./select-D1D0FgJ_.js";import{R as cs}from"./rotate-ccw-CS1JTCXX.js";import{S as Ci}from"./smartphone-UnSTrRwh.js";import{P as Ei}from"./play-Dd0V72SA.js";import{S as mn}from"./search-CS3zqTj_.js";import{T as ls,a as us,b as Vr,c as yt,d as hs,e as St}from"./table-CzmuCYSm.js";import{r as xn}from"./api-CH6ijXmJ.js";import{c as bi,u as Ii,a as Gn,t as Wn,b as yi,d as Si}from"./receiptClaims-m5RsWz2q.js";import{L as _r}from"./loader-circle-xEnGQXuu.js";import{R as Ni}from"./refresh-cw-BTJqnZFn.js";import{E as Ti}from"./eye-BKQajG1W.js";import{P as _i}from"./ProtectedRouteSEO-C16vezue.js";import"./vendor-supabase-DOAAuZ6m.js";import"./settings-Dcxd1AWA.js";import"./user-BHHesttT.js";import"./index-BdQq_4o_.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const Ri=nr("Bug",[["path",{d:"m8 2 1.88 1.88",key:"fmnt4t"}],["path",{d:"M14.12 3.88 16 2",key:"qol33r"}],["path",{d:"M9 7.13v-1a3.003 3.003 0 1 1 6 0v1",key:"d7y7pr"}],["path",{d:"M12 20c-3.3 0-6-2.7-6-6v-3a4 4 0 0 1 4-4h4a4 4 0 0 1 4 4v3c0 3.3-2.7 6-6 6",key:"xs1cw7"}],["path",{d:"M12 20v-9",key:"1qisl0"}],["path",{d:"M6.53 9C4.6 8.8 3 7.1 3 5",key:"32zzws"}],["path",{d:"M6 13H2",key:"82j7cp"}],["path",{d:"M3 21c0-2.1 1.7-3.9 3.8-4",key:"4p0ekp"}],["path",{d:"M20.97 5c0 2.1-1.6 3.8-3.5 4",key:"18gb23"}],["path",{d:"M22 13h-4",key:"1jl80f"}],["path",{d:"M17.2 17c2.1.1 3.8 1.9 3.8 4",key:"k3fwyw"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const rr=nr("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/** 12 * @license lucide-react v0.462.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ds=nr("Focus",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/** 17 * @license lucide-react v0.462.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const Oi=nr("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/** 22 * @license lucide-react v0.462.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const Di=nr("ReceiptText",[["path",{d:"M4 2v20l2-1 2 1 2-1 2 1 2-1 2 1 2-1 2 1V2l-2 1-2-1-2 1-2-1-2 1-2-1-2 1Z",key:"q3az6g"}],["path",{d:"M14 8H8",key:"1l3xfs"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"M13 16H8",key:"wsln4y"}]]);/** 27 * @license lucide-react v0.462.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const vi=nr("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/** 32 * @license lucide-react v0.462.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const Mi=nr("Video",[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]]);class Bi{constructor(h,l){fn(this,"shopId");fn(this,"authClient");
36this.shopId=h,this.authClient=l}async scanQRData(h){h.substring(0,50)+"";try{return this.isApplePassFormat(h)?await this.processApplePass(h):this.isGooglePassFormat(h)?await this.processGooglePass(h):this.isSimplifiedFormat(h)?await this.processSimplifiedFormat(h):{success:!1,error:"dashboard.scan.qrFormatUnrecognizedError"}}catch(l){return console.error("ð PassScanner: Error processing QR code:",l),{success:!1,error:l instanceof Error?l.message:"dashboard.scan.unknownErrorFallback"}}}notFoundError(h){return!!h&&!!this.shopId&&h.toLowerCase()!==this.shopId.toLowerCase()?"dashboard.scan.otherShopPassError":"dashboard.scan.enrollmentAccessError"}isApplePassFormat(h){return h.includes("|")&&h.split("|").length>=3}isGooglePassFormat(h){return h.startsWith("google:")||h.includes("googlepass")}isSimplifiedFormat(h){const l=h.split(":");return l.length===3&&l[0].length>10}async processApplePass(h){var _,D,p,M,v,ee,J;const l=h.split("|");if(l.length<3)return{success:!1,error:"dashboard.scan.applePassFormatInvalidError"};const[w,b,m]=l,S=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;if(!((_=this.authClient)!=null&&_.customerDataManager))return{success:!1,error:"dashboard.scan.authRequiredToastDescription"};try{if(S.test(b)){const Q=await this.authClient.customerDataManager.getEnrollmentFull(b);if(Q){const z={enrollmentId:Q.id,customerName:((D=Q.customer)==null?void 0:D.name)||Q.customerName||"dashboard.scan.unknownCustomerFallback",programName:((p=Q.program)==null?void 0:p.name)||"dashboard.scan.qrProgramFallback",stamps:Q.stampsCount||0,maxStamps:((M=Q.program)==null?void 0:M.stampsRequired)||10};return{success:!0,format:"apple",data:z}}return{success:!1,error:this.notFoundError(w)}}console.warn("Legacy pass format detected, falling back to full list fetch.");const G=(await this.authClient.customerDataManager.getCustomersFull()).find(Q=>Q.id.includes(b.slice(-8)));if(G){const Q={enrollmentId:G.id,customerName:((v=G.customer)==null?void 0:v.name)||"dashboard.scan.unknownCustomerFallback",programName:((ee=G.program)==null?void 0:ee.name)||"dashboard.scan.qrProgramFallback",stamps:G.stampsCount||0,maxStamps:((J=G.program)==null?void 0:J.stampsRequired)||10};return{success:!0,format:"apple",data:Q}}return{success:!1,error:"dashboard.scan.enrollmentAccessError"}}catch(be){return console.error("ð PassScanner: Apple format auth error:",be),{success:!1,error:"dashboard.scan.passAuthFailedError"}}}async processGooglePass(h){return{success:!1,error:"dashboard.scan.googlePassUnsupportedError"}}async processSimplifiedFormat(h){var S,_,D,p;const l=h.split(":");if(l.length!==3)return{success:!1,error:"dashboard.scan.simplifiedFormatInvalidError"};const[w,b,m]=l;if(!((S=this.authClient)!=null&&S.customerDataManager))return{success:!1,error:"dashboard.scan.authRequiredToastDescription"};try{const M=await this.authClient.customerDataManager.getEnrollmentFull(w);if(!M)return{success:!1,error:this.notFoundError(b)};const v={enrollmentId:M.id,customerName:((_=M.customer)==null?void 0:_.name)||M.customerName||"dashboard.scan.unknownCustomerName",programName:((D=M.program)==null?void 0:D.name)||"dashboard.scan.unknownProgramName",stamps:M.stampsCount||0,maxStamps:((p=M.program)==null?void 0:p.stampsRequired)||10};return{success:!0,format:"simple",data:v}}catch(M){return console.error("ð PassScanner: Authenticated client error:",M),{success:!1,error:"dashboard.scan.passAuthFailedError"}}}}var Y;(function(g){g[g.QR_CODE=0]="QR_CODE",g[g.AZTEC=1]="AZTEC",g[g.CODABAR=2]="CODABAR",g[g.CODE_39=3]="CODE_39",g[g.CODE_93=4]="CODE_93",g[g.CODE_128=5]="CODE_128",g[g.DATA_MATRIX=6]="DATA_MATRIX",g[g.MAXICODE=7]="MAXICODE",g[g.ITF=8]="ITF",g[g.EAN_13=9]="EAN_13",g[g.EAN_8=10]="EAN_8",g[g.PDF_417=11]="PDF_417",g[g.RSS_14=12]="RSS_14",g[g.RSS_EXPANDED=13]="RSS_EXPANDED",g[g.UPC_A=14]="UPC_A",g[g.UPC_E=15]="UPC_E",g[g.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Y||(Y={}));var Xn=new Map([[Y.QR_CODE,"QR_CODE"],[Y.AZTEC,"AZTEC"],[Y.CODABAR,"CODABAR"],[Y.CODE_39,"CODE_39"],[Y.CODE_93,"CODE_93"],[Y.CODE_128,"CODE_128"],[Y.DATA_MATRIX,"DATA_MATRIX"],[Y.MAXICODE,"MAXICODE"],[Y.ITF,"ITF"],[Y.EAN_13,"EAN_13"],[Y.EAN_8,"EAN_8"],[Y.PDF_417,"PDF_417"],[Y.RSS_14,"RSS_14"],[Y.RSS_EXPANDED,"RSS_EXPANDED"],[Y.UPC_A,"UPC_A"],[Y.UPC_E,"UPC_E"],[Y.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),Yn;(function(g){g[g.UNKNOWN=0]="UNKNOWN",g[g.URL=1]="URL"})(Yn||(Yn={}));function Pi(g){return Object.values(Y).includes(g)}var Gr;(function(g){g[g.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",g[g.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(Gr||(Gr={}));var Li=function(){function g(){}return g.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",g.SCAN_DEFAULT_FPS=2,g.DEFAULT_DISABLE_FLIP=!1,g.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,g.DEFAULT_SUPPORTED_SCAN_TYPE=[Gr.SCAN_TYPE_CAMERA,Gr.SCAN_TYPE_FILE],g}(),fs=function(){function g(h,l){this.format=h,this.formatName=l}return g.prototype.toString=function(){return this.formatName},g.create=function(h){if(!Xn.has(h))throw"".concat(h," not in html5QrcodeSupportedFormatsTextMap");return new g(h,Xn.get(h))},g}(),zn=function(){function g(){}return g.createFromText=function(h){var l={text:h};return{decodedText:h,result:l}},g.createFromQrcodeResult=function(h){return{decodedText:h.text,result:h}},g}(),wn;(function(g){g[g.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",g[g.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",g[g.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(wn||(wn={}));var Fi=function(){function g(){}return g.createFrom=function(h){return{errorMessage:h,type:wn.UNKWOWN_ERROR}},g}(),ki=function(){function g(h){this.verbose=h}return g.prototype.log=function(h){this.verbose},g.prototype.warn=function(h){this.verbose&&console.warn(h)},g.prototype.logError=function(h,l){(this.verbose||l===!0)&&console.error(h)},g.prototype.logErrors=function(h){if(h.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(h)},g}();function Ut(g){return typeof g>"u"||g===null}var xr=function(){function g(){}return g.codeParseError=function(h){return"QR code parse error, error = ".concat(h)},g.errorGettingUserMedia=function(h){return"Error getting userMedia, error = ".concat(h)},g.onlyDeviceSupportedError=function(){return"The device doesn't support navigator.mediaDevices , only supported cameraIdOrConfig in this case is deviceId parameter (string)."},g.cameraStreamingNotSupported=function(){return"Camera streaming not supported by the browser."},g.unableToQuerySupportedDevices=function(){return"Unable to query supported devices, unknown error."},g.insecureContextCameraQueryError=function(){return"Camera access is only supported in secure context like https or localhost."},g.scannerPaused=function(){return"Scanner paused"},g}(),xs=function(){function g(){}return g.isMediaStreamConstraintsValid=function(h,l){if(typeof h!="object"){var w=typeof h;return l.logError("videoConstraints should be of type object, the "+"object passed is of type ".concat(w,"."),!0),!1}for(var b=["autoGainControl","channelCount","echoCancellation","latency","noiseSuppression","sampleRate","sampleSize","volume"],m=new Set(b),S=Object.keys(h),_=0,D=S;_<D.length;_++){var p=D[_];if(m.has(p))return l.logError("".concat(p," is not supported videoConstaints."),!0),!1}return!0},g}
36(),An={exports:{}};(function(g,h){(function(l,w){w(h)})(Tr,function(l){function w(d){return d==null}var b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,e){d.__proto__=e}||function(d,e){for(var t in e)e.hasOwnProperty(t)&&(d[t]=e[t])};function m(d,e){b(d,e);function t(){this.constructor=d}d.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function S(d,e){var t=Object.setPrototypeOf;t?t(d,e):d.__proto__=e}function _(d,e){e===void 0&&(e=d.constructor);var t=Error.captureStackTrace;t&&t(d,e)}var D=function(d){m(e,d);function e(t){var r=this.constructor,n=d.call(this,t)||this;return Object.defineProperty(n,"name",{value:r.name,enumerable:!1}),S(n,r.prototype),_(n),n}return e}(Error);class p extends D{constructor(e=void 0){super(e),this.message=e}getKind(){return this.constructor.kind}}p.kind="Exception";class M extends p{}M.kind="ArgumentException";class v extends p{}v.kind="IllegalArgumentException";class ee{constructor(e){if(this.binarizer=e,e===null)throw new v("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,t){return this.binarizer.getBlackRow(e,t)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,t,r,n){const s=this.binarizer.getLuminanceSource().crop(e,t,r,n);return new ee(this.binarizer.createBinarizer(s))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new ee(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){const e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new ee(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class J extends p{static getChecksumInstance(){return new J}}J.kind="ChecksumException";class be{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class G{static arraycopy(e,t,r,n,s){for(;s--;)r[n++]=e[t++]}static currentTimeMillis(){return Date.now()}}class Q extends p{}Q.kind="IndexOutOfBoundsException";class z extends Q{constructor(e=void 0,t=void 0){super(t),this.index=e,this.message=t}}z.kind="ArrayIndexOutOfBoundsException";class ${static fill(e,t){for(let r=0,n=e.length;r<n;r++)e[r]=t}static fillWithin(e,t,r,n){$.rangeCheck(e.length,t,r);for(let s=t;s<r;s++)e[s]=n}static rangeCheck(e,t,r){if(t>r)throw new v("fromIndex("+t+") > toIndex("+r+")");if(t<0)throw new z(t);if(r>e)throw new z(r)}static asList(...e){return e}static create(e,t,r){return Array.from({length:e}).map(s=>Array.from({length:t}).fill(r))}static createInt32Array(e,t,r){return Array.from({length:e}).map(s=>Int32Array.from({length:t}).fill(r))}static equals(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(let r=0,n=e.length;r<n;r++)if(e[r]!==t[r])return!1;return!0}static hashCode(e){if(e===null)return 0;let t=1;for(const r of e)t=31*t+r;return t}static fillUint8Array(e,t){for(let r=0;r!==e.length;r++)e[r]=t}static copyOf(e,t){return e.slice(0,t)}static copyOfUint8Array(e,t){if(e.length<=t){const r=new Uint8Array(t);return r.set(e),r}return e.slice(0,t)}static copyOfRange(e,t,r){const n=r-t,s=new Int32Array(n);return G.arraycopy(e,t,s,0,n),s}static binarySearch(e,t,r){r===void 0&&(r=$.numberComparator);let n=0,s=e.length-1;for(;n<=s;){const i=s+n>>1,a=r(t,e[i]);if(a>0)n=i+1;else if(a<0)s=i-1;else return i}return-n-1}static numberComparator(e,t){return e-t}}class W{static numberOfTrailingZeros(e){let t;if(e===0)return 32;let r=31;return t=e<<16,t!==0&&(r-=16,e=t),t=e<<8,t!==0&&(r-=8,e=t),t=e<<4,t!==0&&(r-=4,e=t),t=e<<2,t!==0&&(r-=2,e=t),r-(e<<1>>>31)}static numberOfLeadingZeros(e){if(e===0)return 32;let t=1;return e>>>16||(t+=16,e<<=16),e>>>24||(t+=8,e<<=8),e>>>28||(t+=4,e<<=4),e>>>30||(t+=2,e<<=2),t-=e>>>31,t}static toHexString(e){return e.toString(16)}static toBinaryString(e){return String(parseInt(String(e),2))}static bitCount(e){return e=e-(e>>>1&1431655765),e=(e&858993459)+(e>>>2&858993459),e=e+(e>>>4)&252645135,e=e+(e>>>8),e=e+(e>>>16),e&63}static truncDivision(e,t){return Math.trunc(e/t)}static parseInt(e,t=void 0){return parseInt(e,t)}}W.MIN_VALUE_32_BITS=-2147483648,W.MAX_VALUE=Number.MAX_SAFE_INTEGER;class ce{constructor(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=ce.makeArray(e):this.bits=t)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}
36ensureCapacity(e){if(e>this.bits.length*32){const t=ce.makeArray(e);G.arraycopy(this.bits,0,t,0,this.bits.length),this.bits=t}}get(e){return(this.bits[Math.floor(e/32)]&1<<(e&31))!==0}set(e){this.bits[Math.floor(e/32)]|=1<<(e&31)}flip(e){this.bits[Math.floor(e/32)]^=1<<(e&31)}getNextSet(e){const t=this.size;if(e>=t)return t;const r=this.bits;let n=Math.floor(e/32),s=r[n];s&=~((1<<(e&31))-1);const i=r.length;for(;s===0;){if(++n===i)return t;s=r[n]}const a=n*32+W.numberOfTrailingZeros(s);return a>t?t:a}getNextUnset(e){const t=this.size;if(e>=t)return t;const r=this.bits;let n=Math.floor(e/32),s=~r[n];s&=~((1<<(e&31))-1);const i=r.length;for(;s===0;){if(++n===i)return t;s=~r[n]}const a=n*32+W.numberOfTrailingZeros(s);return a>t?t:a}setBulk(e,t){this.bits[Math.floor(e/32)]=t}setRange(e,t){if(t<e||e<0||t>this.size)throw new v;if(t===e)return;t--;const r=Math.floor(e/32),n=Math.floor(t/32),s=this.bits;for(let i=r;i<=n;i++){const a=i>r?0:e&31,c=(2<<(i<n?31:t&31))-(1<<a);s[i]|=c}}clear(){const e=this.bits.length,t=this.bits;for(let r=0;r<e;r++)t[r]=0}isRange(e,t,r){if(t<e||e<0||t>this.size)throw new v;if(t===e)return!0;t--;const n=Math.floor(e/32),s=Math.floor(t/32),i=this.bits;for(let a=n;a<=s;a++){const o=a>n?0:e&31,u=(2<<(a<s?31:t&31))-(1<<o)&4294967295;if((i[a]&u)!==(r?u:0))return!1}return!0}appendBit(e){this.ensureCapacity(this.size+1),e&&(this.bits[Math.floor(this.size/32)]|=1<<(this.size&31)),this.size++}appendBits(e,t){if(t<0||t>32)throw new v("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(let r=t;r>0;r--)this.appendBit((e>>r-1&1)===1)}appendBitArray(e){const t=e.size;this.ensureCapacity(this.size+t);for(let r=0;r<t;r++)this.appendBit(e.get(r))}xor(e){if(this.size!==e.size)throw new v("Sizes don't match");const t=this.bits;for(let r=0,n=t.length;r<n;r++)t[r]^=e.bits[r]}toBytes(e,t,r,n){for(let s=0;s<n;s++){let i=0;for(let a=0;a<8;a++)this.get(e)&&(i|=1<<7-a),e++;t[r+s]=i}}getBitArray(){return this.bits}reverse(){const e=new Int32Array(this.bits.length),t=Math.floor((this.size-1)/32),r=t+1,n=this.bits;for(let s=0;s<r;s++){let i=n[s];i=i>>1&1431655765|(i&1431655765)<<1,i=i>>2&858993459|(i&858993459)<<2,i=i>>4&252645135|(i&252645135)<<4,i=i>>8&16711935|(i&16711935)<<8,i=i>>16&65535|(i&65535)<<16,e[t-s]=i}if(this.size!==r*32){const s=r*32-this.size;let i=e[0]>>>s;for(let a=1;a<r;a++){const o=e[a];i|=o<<32-s,e[a-1]=i,i=o>>>s}e[r-1]=i}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof ce))return!1;const t=e;return this.size===t.size&&$.equals(this.bits,t.bits)}hashCode(){return 31*this.size+$.hashCode(this.bits)}toString(){let e="";for(let t=0,r=this.size;t<r;t++)t&7||(e+=" "),e+=this.get(t)?"X":".";return e}clone(){return new ce(this.size,this.bits.slice())}}var H;(function(d){d[d.OTHER=0]="OTHER",d[d.PURE_BARCODE=1]="PURE_BARCODE",d[d.POSSIBLE_FORMATS=2]="POSSIBLE_FORMATS",d[d.TRY_HARDER=3]="TRY_HARDER",d[d.CHARACTER_SET=4]="CHARACTER_SET",d[d.ALLOWED_LENGTHS=5]="ALLOWED_LENGTHS",d[d.ASSUME_CODE_39_CHECK_DIGIT=6]="ASSUME_CODE_39_CHECK_DIGIT",d[d.ASSUME_GS1=7]="ASSUME_GS1",d[d.RETURN_CODABAR_START_END=8]="RETURN_CODABAR_START_END",d[d.NEED_RESULT_POINT_CALLBACK=9]="NEED_RESULT_POINT_CALLBACK",d[d.ALLOWED_EAN_EXTENSIONS=10]="ALLOWED_EAN_EXTENSIONS"})(H||(H={}));var K=H;class P extends p{static getFormatInstance(){return new P}}P.kind="FormatException";var oe;(function(d){d[d.Cp437=0]="Cp437",d[d.ISO8859_1=1]="ISO8859_1",d[d.ISO8859_2=2]="ISO8859_2",d[d.ISO8859_3=3]="ISO8859_3",d[d.ISO8859_4=4]="ISO8859_4",d[d.ISO8859_5=5]="ISO8859_5",d[d.ISO8859_6=6]="ISO8859_6",d[d.ISO8859_7=7]="ISO8859_7",d[d.ISO8859_8=8]="ISO8859_8",d[d.ISO8859_9=9]="ISO8859_9",d[d.ISO8859_10=10]="ISO8859_10",d[d.ISO8859_11=11]="ISO8859_11",d[d.ISO8859_13=12]="ISO8859_13",d[d.ISO8859_14=13]="ISO8859_14",d[d.ISO8859_15=14]="ISO8859_15",d[d.ISO8859_16=15]="ISO8859_16",d[d.SJIS=16]="SJIS",d[d.Cp1250=17]="Cp1250",d[d.Cp1251=18]="Cp1251",d[d.Cp1252=19]="Cp1252",d[d.Cp1256=20]="Cp1256",d[d.UnicodeBigUnmarked=21]="UnicodeBigUnmarked",d[d.UTF8=22]="UTF8",d[d.ASCII=23]="ASCII",d[d.Big5=24]="Big5",d[d.GB18030=25]="GB18030",d[d.EUC_KR=26]="EUC_KR"})(oe||(oe={}));class F{constructor(e,t,r,...n){this.valueIdentifier=e,this.name=r,typeof t=="number"?this.values=Int32Array.from([t]):this.values=t,this.otherEncodingNames=n,F.VALUE_IDENTIFIER_TO_ECI.set(e,this),F.NAME_TO_ECI.set(r,this);const s=this.values;for(let i=0,a=s.length;i!==a;i++){const o=s[i];F.VALUES_TO_ECI.set(o,this)}for(const i of n)F.NAME_TO_ECI.set(i,this)}getValueIdentifier(){return this.valueIdentifier}getName(){return this.name}getValue(){return this.values[0]}static getCharacterSetECIByValue(e){if(e<0||e>=900)throw new P("incorect value");const t=F.VALUES_TO_ECI.get(e);if(t===void 0)throw new P("incorect value");return t}static getCharacterSetECIByName(e){const t=F.NAME_TO_ECI.get(e);if(t===void 0)throw new P("incorect value");return t}equals(e){if(!(e instanceof F))return!1;const t=e;return this.getName()===t.getName()}}F.VALUE_IDENTIFIER_TO_ECI=new Map,F.VALUES_TO_ECI=new Map,F.NAME_TO_ECI=new Map,F.Cp437=new F(oe.Cp437,Int32Array.from([0,2]),"Cp437"),F.ISO8859_1=new F(oe.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),F.ISO8859_2=new F(oe.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),F.ISO8859_3=new F(oe.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),F.ISO8859_4
36=new F(oe.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),F.ISO8859_5=new F(oe.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),F.ISO8859_6=new F(oe.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),F.ISO8859_7=new F(oe.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),F.ISO8859_8=new F(oe.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),F.ISO8859_9=new F(oe.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),F.ISO8859_10=new F(oe.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),F.ISO8859_11=new F(oe.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),F.ISO8859_13=new F(oe.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),F.ISO8859_14=new F(oe.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),F.ISO8859_15=new F(oe.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),F.ISO8859_16=new F(oe.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),F.SJIS=new F(oe.SJIS,20,"SJIS","Shift_JIS"),F.Cp1250=new F(oe.Cp1250,21,"Cp1250","windows-1250"),F.Cp1251=new F(oe.Cp1251,22,"Cp1251","windows-1251"),F.Cp1252=new F(oe.Cp1252,23,"Cp1252","windows-1252"),F.Cp1256=new F(oe.Cp1256,24,"Cp1256","windows-1256"),F.UnicodeBigUnmarked=new F(oe.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),F.UTF8=new F(oe.UTF8,26,"UTF8","UTF-8"),F.ASCII=new F(oe.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),F.Big5=new F(oe.Big5,28,"Big5"),F.GB18030=new F(oe.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),F.EUC_KR=new F(oe.EUC_KR,30,"EUC_KR","EUC-KR");class lt extends p{}lt.kind="UnsupportedOperationException";class Se{static decode(e,t){const r=this.encodingName(t);return this.customDecoder?this.customDecoder(e,r):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(r)?this.decodeFallback(e,r):new TextDecoder(r).decode(e)}static shouldDecodeOnFallback(e){return!Se.isBrowser()&&e==="ISO-8859-1"}static encode(e,t){const r=this.encodingName(t);return this.customEncoder?this.customEncoder(e,r):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(e){return typeof e=="string"?e:e.getName()}static encodingCharacterSet(e){return e instanceof F?e:F.getCharacterSetECIByName(e)}static decodeFallback(e,t){const r=this.encodingCharacterSet(t);if(Se.isDecodeFallbackSupported(r)){let n="";for(let s=0,i=e.length;s<i;s++){let a=e[s].toString(16);a.length<2&&(a="0"+a),n+="%"+a}return decodeURIComponent(n)}if(r.equals(F.UnicodeBigUnmarked))return String.fromCharCode.apply(null,new Uint16Array(e.buffer));throw new lt(`Encoding ${this.encodingName(t)} not supported by fallback.`)}static isDecodeFallbackSupported(e){return e.equals(F.UTF8)||e.equals(F.ISO8859_1)||e.equals(F.ASCII)}static encodeFallback(e){const r=btoa(unescape(encodeURIComponent(e))).split(""),n=[];for(let s=0;s<r.length;s++)n.push(r[s].charCodeAt(0));return new Uint8Array(n)}}class te{static castAsNonUtf8Char(e,t=null){const r=t?t.getName():this.ISO88591;return Se.decode(new Uint8Array([e]),r)}static guessEncoding(e,t){if(t!=null&&t.get(K.CHARACTER_SET)!==void 0)return t.get(K.CHARACTER_SET).toString();const r=e.length;let n=!0,s=!0,i=!0,a=0,o=0,c=0,u=0,f=0,x=0,E=0,I=0,y=0,N=0,O=0;const U=e.length>3&&e[0]===239&&e[1]===187&&e[2]===191;for(let j=0;j<r&&(n||s||i);j++){const k=e[j]&255;i&&(a>0?k&128?a--:i=!1:k&128&&(k&64?(a++,k&32?(a++,k&16?(a++,k&8?i=!1:u++):c++):o++):i=!1)),n&&(k>127&&k<160?n=!1:k>159&&(k<192||k===215||k===247)&&O++),s&&(f>0?k<64||k===127||k>252?s=!1:f--:k===128||k===160||k>239?s=!1:k>160&&k<224?(x++,I=0,E++,E>y&&(y=E)):k>127?(f++,E=0,I++,I>N&&(N=I)):(E=0,I=0))}return i&&a>0&&(i=!1),s&&f>0&&(s=!1),i&&(U||o+c+u>0)?te.UTF8:s&&(te.ASSUME_SHIFT_JIS||y>=3||N>=3)?te.SHIFT_JIS:n&&s?y===2&&x===2||O*10>=r?te.SHIFT_JIS:te.ISO88591:n?te.ISO88591:s?te.SHIFT_JIS:i?te.UTF8:te.PLATFORM_DEFAULT_ENCODING}static format(e,...t){let r=-1;function n(i,a,o,c,u,f){if(i==="%%")return"%";if(t[++r]===void 0)return;i=c?parseInt(c.substr(1)):void 0;let x=u?parseInt(u.substr(1)):void 0,E;switch(f){case"s":E=t[r];break;case"c":E=t[r][0];break;case"f":E=parseFloat(t[r]).toFixed(i);break;case"p":E=parseFloat(t[r]).toPrecision(i);break;case"e":E=parseFloat(t[r]).toExponential(i);break;case"x":E=parseInt(t[r]).toString(x||16);break;case"d":E=parseFloat(parseInt(t[r],x||10).toPrecision(i)).toFixed(0);break}E=typeof E=="object"?JSON.stringify(E):(+E).toString(x);let I=parseInt(o),y=o&&o[0]+""=="0"?"0":" ";for(;E.length<I;)E=a!==void 0?E+y:y+E;return E}let s=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(s,n)}static getBytes(e,t){return Se.encode(e,t)}static getCharCode(e,t=0){return e.charCodeAt(t)}static getCharAt(e){return String.fromCharCode(e)}}te.SHIFT_JIS=F.SJIS.getName(),te.GB2312="GB2312",te.ISO88591=F.ISO8859_1.getName(),te.EUC_JP="EUC_JP",te.UTF8=F.UTF8.getName(),te.PLATFORM_DEFAULT_ENCODING=te.UTF8,te.ASSUME_SHIFT_JIS=!1;class pe{constructor(e=""){this.value=e}enableDecoding(e){return this.encoding=e,this}append(e){return typeof e=="string"?this.value+=e.toString():this.encoding?this.value+=te.castAsNonUtf8Char(e,this.encoding):this.value+=String.fromCharCode(e),this}appendChars(e,t,r){for(let n=t;t<t+r;n++)this.append(e[n]);return this}length(){return this.value.length}charAt(e){return this.value.charAt(e)}deleteCharAt(e){this.value=this.value.substr(0,e)+this.value.substring(e+1)}setCharAt(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+1)}substring(e,t){return this.value.substring(e,t)}setLengthToZero(){this.value=""}toString(){return this.value}insert(e,t){this.value=this.value.substr(0,e)+t+this.value.substr(e+t.length)}}class De{constructor(e,t,r,n){if(this.width=e,this.height=t,this.rowSize=r,this.bits=n,t==null&&(t=e),this.height=t,e<1||t<1)throw new v("Both dimensions must be greater than 0");r==null&&(r=Math.floor((e+31)/32)),this.rowSize=r,n==null&&(this.bits=new Int32Array(this.rowSize*this.height))}static parseFromBooleanArray(e){const t=e.length,r=e[0].length,n=new De(r,t);for(let s=0;s<t;s++){const i=e[s];for(let a=0;a<r;a++)i[a]&&n.set(a,s)}return n}static parseFromString(e,t,r){if(e===null)throw new v("stringRepresentation cannot be null");const n=new Array(e.length);let s=0,i=0,a=-1,o=0,c=0;for(;c<e.length;)if(e.charAt(c)===` 37`||e.charAt(c)==="\r"){if(s>i){if(a===-1)a=s-i;else if(s-i!==a)throw new v("row lengths do not match");i=s,o++}c++}else if(e.substring(c,c+t.length)===t)c+=t.length,n[s]=!0,s++;else if(e.substring(c,c+r.length)===r)c+=r.length,n[s]=!1,s++;else throw new v("illegal character encountered: "+e.substring(c));if(s>i){if(a===-1)a=s-i;else if(s-i!==a)throw new v("row lengths do not match");o++}const u=new De(a,o);for(let f=0;f<s;f++)n[f]&&u.set(Math.floor(f%a),Math.floor(f/a));return u}get(e,t){const r=t*this.rowSize+Math.floor(e/32);return(this.bits[r]>>>(e&31)&1)!==0}set(e,t){const r=t*this.rowSize+Math.floor(e/32);this.bits[r]|=1<<(e&31)&4294967295}unset(e,t){const r=t*this.rowSize+Math.floor(e/32);this.bits[r]&=~(1<<(e&31)&4294967295)}flip(e,t){const r=t*this.rowSize+Math.floor(e/32);this.bits[r]^=1<<(e&31)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new v("input matrix dimensions do not match");const t=new ce(Math.floor(this.width/32)+1),r=this.rowSize,n=this.bits;for(let s=0,i=this.height;s<i;s++){const a=s*r,o=e.getRow(s,t).getBitArray();for(let c=0;c<r;c++)n[a+c]^=o[c]}}clear(){const e=this.bits,t=e.length;for(let r=0;r<t;r++)e[r]=0}setRegion(e,t,r,n){if(t<0||e<0)throw new v("Left and top must be nonnegative");if(n<1||r<1)throw new v("Height and width must be at least 1");const s=e+r,i=t+n;if(i>this.height||s>this.width)throw new v("The region must fit inside the matrix");const a=this.rowSize,o=this.bits;for(let c=t;c<i;c++){const u=c*a;for(let f=e;f<s;f++)o[u+Math.floor(f/32)]|=1<<(f&31)&4294967295}}getRow(e,t){t==null||t.getSize()<this.width?t=new ce(this.width):t.clear();const r=this.rowSize,n=this.bits,s=e*r;for(let i=0;i<r;i++)t.setBulk(i*32,n[s+i]);return t}setRow(e,t){G.arraycopy(t.getBitArray(),0,this.bits,e*this.rowSize,this.rowSize)}rotate180(){const e=this.getWidth(),t=this.getHeight();let r=new ce(e),n=new ce(e);for(let s=0,i=Math.floor((t+1)/2);s<i;s++)r=this.getRow(s,r),n=this.getRow(t-1-s,n),r.reverse(),n.reverse(),this.setRow(s,n),this.setRow(t-1-s,r)}getEnclosingRectangle(){const e=this.width,t=this.height,r=this.rowSize,n=this.bits;let s=e,i=t,a=-1,o=-1;for(let c=0;c<t;c++)for(let u=0;u<r;u++){const f=n[c*r+u];if(f!==0){if(c<i&&(i=c),c>o&&(o=c),u*32<s){let x=0;for(;!(f<<31-x&4294967295);)x++;u*32+x<s&&(s=u*32+x)}if(u*32+31>a){let x=31;for(;!(f>>>x);)x--;u*32+x>a&&(a=u*32+x)}}}return a<s||o<i?null:Int32Array.from([s,i,a-s+1,o-i+1])}getTopLeftOnBit(){const e=this.rowSize,t=this.bits;let r=0;for(;r<t.length&&t[r]===0;)r++;if(r===t.length)return null;const n=r/e;let s=r%e*32;const i=t[r];let a=0;for(;!(i<<31-a&4294967295);)a++;return s+=a,Int32Array.from([s,n])}getBottomRightOnBit(){const e=this.rowSize,t=this.bits;let r=t.length-1;for(;r>=0&&t[r]===0;)r--;if(r<0)return null;const n=Math.floor(r/e);let s=Math.floor(r%e)*32;const i=t[r];let a=31;for(;!(i>>>a);)a--;return s+=a,Int32Array.from([s,n])}getWidth(){return this.width}
37getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){if(!(e instanceof De))return!1;const t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&$.equals(this.bits,t.bits)}hashCode(){let e=this.width;return e=31*e+this.width,e=31*e+this.height,e=31*e+this.rowSize,e=31*e+$.hashCode(this.bits),e}toString(e="X ",t=" ",r=` 38`){return this.buildToString(e,t,r)}buildToString(e,t,r){let n=new pe;for(let s=0,i=this.height;s<i;s++){for(let a=0,o=this.width;a<o;a++)n.append(this.get(a,s)?e:t);n.append(r)}return n.toString()}clone(){return new De(this.width,this.height,this.rowSize,this.bits.slice())}}class B extends p{static getNotFoundInstance(){return new B}}B.kind="NotFoundException";class Ve extends be{constructor(e){super(e),this.luminances=Ve.EMPTY,this.buckets=new Int32Array(Ve.LUMINANCE_BUCKETS)}getBlackRow(e,t){const r=this.getLuminanceSource(),n=r.getWidth();t==null||t.getSize()<n?t=new ce(n):t.clear(),this.initArrays(n);const s=r.getRow(e,this.luminances),i=this.buckets;for(let o=0;o<n;o++)i[(s[o]&255)>>Ve.LUMINANCE_SHIFT]++;const a=Ve.estimateBlackPoint(i);if(n<3)for(let o=0;o<n;o++)(s[o]&255)<a&&t.set(o);else{let o=s[0]&255,c=s[1]&255;for(let u=1;u<n-1;u++){const f=s[u+1]&255;(c*4-o-f)/2<a&&t.set(u),o=c,c=f}}return t}getBlackMatrix(){const e=this.getLuminanceSource(),t=e.getWidth(),r=e.getHeight(),n=new De(t,r);this.initArrays(t);const s=this.buckets;for(let o=1;o<5;o++){const c=Math.floor(r*o/5),u=e.getRow(c,this.luminances),f=Math.floor(t*4/5);for(let x=Math.floor(t/5);x<f;x++){const E=u[x]&255;s[E>>Ve.LUMINANCE_SHIFT]++}}const i=Ve.estimateBlackPoint(s),a=e.getMatrix();for(let o=0;o<r;o++){const c=o*t;for(let u=0;u<t;u++)(a[c+u]&255)<i&&n.set(u,o)}return n}createBinarizer(e){return new Ve(e)}initArrays(e){this.luminances.length<e&&(this.luminances=new Uint8ClampedArray(e));const t=this.buckets;for(let r=0;r<Ve.LUMINANCE_BUCKETS;r++)t[r]=0}static estimateBlackPoint(e){const t=e.length;let r=0,n=0,s=0;for(let u=0;u<t;u++)e[u]>s&&(n=u,s=e[u]),e[u]>r&&(r=e[u]);let i=0,a=0;for(let u=0;u<t;u++){const f=u-n,x=e[u]*f*f;x>a&&(i=u,a=x)}if(n>i){const u=n;n=i,i=u}if(i-n<=t/16)throw new B;let o=i-1,c=-1;for(let u=i-1;u>n;u--){const f=u-n,x=f*f*(i-u)*(r-e[u]);x>c&&(o=u,c=x)}return o<<Ve.LUMINANCE_SHIFT}}Ve.LUMINANCE_BITS=5,Ve.LUMINANCE_SHIFT=8-Ve.LUMINANCE_BITS,Ve.LUMINANCE_BUCKETS=1<<Ve.LUMINANCE_BITS,Ve.EMPTY=Uint8ClampedArray.from([0]);class le extends Ve{constructor(e){super(e),this.matrix=null}getBlackMatrix(){if(this.matrix!==null)return this.matrix;const e=this.getLuminanceSource(),t=e.getWidth(),r=e.getHeight();if(t>=le.MINIMUM_DIMENSION&&r>=le.MINIMUM_DIMENSION){const n=e.getMatrix();let s=t>>le.BLOCK_SIZE_POWER;t&le.BLOCK_SIZE_MASK&&s++;let i=r>>le.BLOCK_SIZE_POWER;r&le.BLOCK_SIZE_MASK&&i++;const a=le.calculateBlackPoints(n,s,i,t,r),o=new De(t,r);le.calculateThresholdForBlock(n,s,i,t,r,a,o),this.matrix=o}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new le(e)}static calculateThresholdForBlock(e,t,r,n,s,i,a){const o=s-le.BLOCK_SIZE,c=n-le.BLOCK_SIZE;for(let u=0;u<r;u++){let f=u<<le.BLOCK_SIZE_POWER;f>o&&(f=o);const x=le.cap(u,2,r-3);for(let E=0;E<t;E++){let I=E<<le.BLOCK_SIZE_POWER;I>c&&(I=c);const y=le.cap(E,2,t-3);let N=0;for(let U=-2;U<=2;U++){const j=i[x+U];N+=j[y-2]+j[y-1]+j[y]+j[y+1]+j[y+2]}const O=N/25;le.thresholdBlock(e,I,f,O,n,a)}}}static cap(e,t,r){return e<t?t:e>r?r:e}static thresholdBlock(e,t,r,n,s,i){for(let a=0,o=r*s+t;a<le.BLOCK_SIZE;a++,o+=s)for(let c=0;c<le.BLOCK_SIZE;c++)(e[o+c]&255)<=n&&i.set(t+c,r+a)}static calculateBlackPoints(e,t,r,n,s){const i=s-le.BLOCK_SIZE,a=n-le.BLOCK_SIZE,o=new Array(r);for(let c=0;c<r;c++){o[c]=new Int32Array(t);let u=c<<le.BLOCK_SIZE_POWER;u>i&&(u=i);for(let f=0;f<t;f++){let x=f<<le.BLOCK_SIZE_POWER;x>a&&(x=a);let E=0,I=255,y=0;for(let O=0,U=u*n+x;O<le.BLOCK_SIZE;O++,U+=n){for(let j=0;j<le.BLOCK_SIZE;j++){const k=e[U+j]&255;E+=k,k<I&&(I=k),k>y&&(y=k)}if(y-I>le.MIN_DYNAMIC_RANGE)for(O++,U+=n;O<le.BLOCK_SIZE;O++,U+=n)for(let j=0;j<le.BLOCK_SIZE;j++)E+=e[U+j]&255}let N=E>>le.BLOCK_SIZE_POWER*2;if(y-I<=le.MIN_DYNAMIC_RANGE&&(N=I/2,c>0&&f>0)){const O=(o[c-1][f]+2*o[c][f-1]+o[c-1][f-1])/4;I<O&&(N=O)}o[c][f]=N}}return o}}le.BLOCK_SIZE_POWER=3,le.BLOCK_SIZE=1<<le.BLOCK_SIZE_POWER,le.BLOCK_SIZE_MASK=le.BLOCK_SIZE-1,le.MINIMUM_DIMENSION=le.BLOCK_SIZE*5,le.MIN_DYNAMIC_RANGE=24;class ut{constructor(e,t){this.width=e,this.height=t}getWidth(){return this.width}
38getHeight(){return this.height}isCropSupported(){return!1}crop(e,t,r,n){throw new lt("This luminance source does not support cropping.")}isRotateSupported(){return!1}rotateCounterClockwise(){throw new lt("This luminance source does not support rotation by 90 degrees.")}rotateCounterClockwise45(){throw new lt("This luminance source does not support rotation by 45 degrees.")}toString(){const e=new Uint8ClampedArray(this.width);let t=new pe;for(let r=0;r<this.height;r++){const n=this.getRow(r,e);for(let s=0;s<this.width;s++){const i=n[s]&255;let a;i<64?a="#":i<128?a="+":i<192?a=".":a=" ",t.append(a)}t.append(` 39`)}return t.toString()}}class At extends ut{constructor(e){super(e.getWidth(),e.getHeight()),this.delegate=e}getRow(e,t){const r=this.delegate.getRow(e,t),n=this.getWidth();for(let s=0;s<n;s++)r[s]=255-(r[s]&255);return r}getMatrix(){const e=this.delegate.getMatrix(),t=this.getWidth()*this.getHeight(),r=new Uint8ClampedArray(t);for(let n=0;n<t;n++)r[n]=255-(e[n]&255);return r}isCropSupported(){return this.delegate.isCropSupported()}crop(e,t,r,n){return new At(this.delegate.crop(e,t,r,n))}isRotateSupported(){return this.delegate.isRotateSupported()}invert(){return this.delegate}rotateCounterClockwise(){return new At(this.delegate.rotateCounterClockwise())}rotateCounterClockwise45(){return new At(this.delegate.rotateCounterClockwise45())}}class pt extends ut{constructor(e){super(e.width,e.height),this.canvas=e,this.tempCanvasElement=null,this.buffer=pt.makeBufferFromCanvasImageData(e)}static makeBufferFromCanvasImageData(e){const t=e.getContext("2d").getImageData(0,0,e.width,e.height);return pt.toGrayscaleBuffer(t.data,e.width,e.height)}static toGrayscaleBuffer(e,t,r){const n=new Uint8ClampedArray(t*r);for(let s=0,i=0,a=e.length;s<a;s+=4,i++){let o;if(e[s+3]===0)o=255;else{const u=e[s],f=e[s+1],x=e[s+2];o=306*u+601*f+117*x+512>>10}n[i]=o}return n}getRow(e,t){if(e<0||e>=this.getHeight())throw new v("Requested row is outside the image: "+e);const r=this.getWidth(),n=e*r;return t===null?t=this.buffer.slice(n,n+r):(t.length<r&&(t=new Uint8ClampedArray(r)),t.set(this.buffer.slice(n,n+r))),t}getMatrix(){return this.buffer}isCropSupported(){return!0}crop(e,t,r,n){return super.crop(e,t,r,n),this}isRotateSupported(){return!0}rotateCounterClockwise(){return this.rotate(-90),this}rotateCounterClockwise45(){return this.rotate(-45),this}getTempCanvasElement(){if(this.tempCanvasElement===null){const e=this.canvas.ownerDocument.createElement("canvas");e.width=this.canvas.width,e.height=this.canvas.height,this.tempCanvasElement=e}return this.tempCanvasElement}rotate(e){const t=this.getTempCanvasElement(),r=t.getContext("2d"),n=e*pt.DEGREE_TO_RADIANS,s=this.canvas.width,i=this.canvas.height,a=Math.ceil(Math.abs(Math.cos(n))*s+Math.abs(Math.sin(n))*i),o=Math.ceil(Math.abs(Math.sin(n))*s+Math.abs(Math.cos(n))*i);return t.width=a,t.height=o,r.translate(a/2,o/2),r.rotate(n),r.drawImage(this.canvas,s/-2,i/-2),this.buffer=pt.makeBufferFromCanvasImageData(t),this}invert(){return new At(this)}}pt.DEGREE_TO_RADIANS=Math.PI/180;class sr{constructor(e,t,r){this.deviceId=e,this.label=t,this.kind="videoinput",this.groupId=r||void 0}toJSON(){return{kind:this.kind,groupId:this.groupId,deviceId:this.deviceId,label:this.label}}}var Ke=(globalThis||Tr||self||window||void 0)&&(globalThis||Tr||self||window||void 0).__awaiter||function(d,e,t,r){function n(s){return s instanceof t?s:new t(function(i){i(s)})}return new(t||(t=Promise))(function(s,i){function a(u){try{c(r.next(u))}catch(f){i(f)}}function o(u){try{c(r.throw(u))}catch(f){i(f)}}function c(u){u.done?s(u.value):n(u.value).then(a,o)}c((r=r.apply(d,e||[])).next())})};class Ft{constructor(e,t=500,r){this.reader=e,this.timeBetweenScansMillis=t,this._hints=r,this._stopContinuousDecode=!1,this._stopAsyncDecode=!1,this._timeBetweenDecodingAttempts=0}get hasNavigator(){return typeof navigator<"u"}get isMediaDevicesSuported(){return this.hasNavigator&&!!navigator.mediaDevices}get canEnumerateDevices(){return!!(this.isMediaDevicesSuported&&navigator.mediaDevices.enumerateDevices)}get timeBetweenDecodingAttempts(){return this._timeBetweenDecodingAttempts}set timeBetweenDecodingAttempts(e){this._timeBetweenDecodingAttempts=e<0?0:e}set hints(e){this._hints=e||null}get hints(){return this._hints}listVideoInputDevices(){return Ke(this,void 0,void 0,function*(){if(!this.hasNavigator)throw new Error("Can't enumerate devices, navigator is not present.");if(!this.canEnumerateDevices)throw new Error("Can't enumerate devices, method not supported.");const e=yield navigator.mediaDevices.enumerateDevices(),t=[];for(const r of e){const n=r.kind==="video"?"videoinput":r.kind;if(n!=="videoinput")continue;const s=r.deviceId||r.id,i=r.label||`Video device ${t.length+1}`,a=r.groupId,o={deviceId:s,label:i,kind:n,groupId:a};t.push(o)}return t})}getVideoInputDevices(){return Ke(this,void 0,void 0,function*(){return(yield this.listVideoInputDevices()).map(t=>new sr(t.deviceId,t.label))})}findDeviceById(e){return Ke(this,void 0,void 0,function*(){const t=yield this.listVideoInputDevices();return t?t.find(r=>r.deviceId===e):null})}decodeFromInputVideoDevice(e,t){return Ke(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,t)})}decodeOnceFromVideoDevice(e,t){return Ke(this,void 0,void 0,function*(){this.reset();let r;e?r={deviceId:{exact:e}}:r={facingMode:"environment"};const n={video:r};return yield this.decodeOnceFromConstraints(n,t)})}decodeOnceFromConstraints(e,t){return Ke(this,void 0,void 0,function*(){const r=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(r,t)})}decodeOnceFromStream(e,t){return Ke(this,void 0,void 0,function*(){this.reset();const r=yield this.attachStreamToVideo(e,t);return yield this.decodeOnce(r)})}decodeFromInputVideoDeviceContinuously(e,t,r){return Ke(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,t,r)})}decodeFromVideoDevice(e,t,r){return Ke(this,void 0,void 0,function*(){let n;e?n={deviceId:{exact:e}}:n={facingMode:"environment"};const s={video:n};return yield this.decodeFromConstraints(s,t,r)})}decodeFromConstraints(e,t,r){return Ke(this,void 0,void 0,function*(){const n=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(n,t,r)})}decodeFromStream(e,t,r){return Ke(this,void 0,void 0,function*(){this.reset();const n=yield this.attachStreamToVideo(e,t);return yield this.decodeContinuously(n,r)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,t){return Ke(this,void 0,void 0,function*(){const r=this.prepareVideoElement(t);return this.addVideoSource(r,e),this.videoElement=r,this.stream=e,yield this.playVideoOnLoadAsync(r),r})}playVideoOnLoadAsync(e){return new Promise((t,r)=>this.playVideoOnLoad(e,()=>t()))}playVideoOnLoad(e,t){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return Ke(this,void 0,void 0,function*(){if(this.isVideoPlaying(e)){console.warn("Trying to play video that is already playing.");return}try{yield e.play()}catch{console.warn("It was not possible to play the video.")}})}getMediaElement(e,t){const r=document.getElementById(e);if(!r)throw new M(`element with id '${e}' not found`);if(r.nodeName.toLowerCase()!==t.toLowerCase())throw new M(`element with id '${e}' must be an ${t} element`);return r}decodeFromImage(e,t){if(!e&&!t)throw new M("either imageElement with a src set or an url must be provided");return t&&!e?this.decodeFromImageUrl(t):this.decodeFromImageElement(e)}decodeFromVideo(e,t){if(!e&&!t)throw new M("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,t,r){if(e===void 0&&t===void 0)throw new M("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,r):this.decodeFromVideoElementContinuously(e,r)}decodeFromImageElement(e){if(!e)throw new M("An image element must be provided.");this.reset();const t=this.prepareImageElement(e);this.imageElement=t;let r;return this.isImageLoaded(t)?r=this.decodeOnce(t,!1,!0):r=this._decodeOnLoadImage(t),r}decodeFromVideoElement(e){const t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)}decodeFromVideoElementContinuously(e,t){const r=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(r,t)}_decodeFromVideoElementSetup(e){if(!e)throw new M("A video element must be provided.");this.reset();const t=this.prepareVideoElement(e);return this.videoElement=t,t}decodeFromImageUrl(e){if(!e)throw new M("An URL must be provided.");this.reset();const t=this.prepareImageElement();this.imageElement=t;
39const r=this._decodeOnLoadImage(t);return t.src=e,r}decodeFromVideoUrl(e){if(!e)throw new M("An URL must be provided.");this.reset();const t=this.prepareVideoElement(),r=this.decodeFromVideoElement(t);return t.src=e,r}decodeFromVideoUrlContinuously(e,t){if(!e)throw new M("An URL must be provided.");this.reset();const r=this.prepareVideoElement(),n=this.decodeFromVideoElementContinuously(r,t);return r.src=e,n}_decodeOnLoadImage(e){return new Promise((t,r)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(t,r),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return Ke(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,t){return Ke(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,t)})}isImageLoaded(e){return!(!e.complete||e.naturalWidth===0)}prepareImageElement(e){let t;return typeof e>"u"&&(t=document.createElement("img"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t}prepareVideoElement(e){let t;return!e&&typeof document<"u"&&(t=document.createElement("video"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t}decodeOnce(e,t=!0,r=!0){this._stopAsyncDecode=!1;const n=(s,i)=>{if(this._stopAsyncDecode){i(new B("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{const a=this.decode(e);s(a)}catch(a){const o=t&&a instanceof B,u=(a instanceof J||a instanceof P)&&r;if(o||u)return setTimeout(n,this._timeBetweenDecodingAttempts,s,i);i(a)}};return new Promise((s,i)=>n(s,i))}decodeContinuously(e,t){this._stopContinuousDecode=!1;const r=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{const n=this.decode(e);t(n,null),setTimeout(r,this.timeBetweenScansMillis)}catch(n){t(null,n);const s=n instanceof J||n instanceof P,i=n instanceof B;(s||i)&&setTimeout(r,this._timeBetweenDecodingAttempts)}};r()}decode(e){const t=this.createBinaryBitmap(e);return this.decodeBitmap(t)}_isHTMLVideoElement(e){return e.videoWidth!==0}drawFrameOnCanvas(e,t,r){t||(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),r||(r=this.captureCanvasContext),r.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}drawImageOnCanvas(e,t,r=this.captureCanvasContext){t||(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),r||(r=this.captureCanvasContext),r.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}createBinaryBitmap(e){this.getCaptureCanvasContext(e),this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);const t=this.getCaptureCanvas(e),r=new pt(t),n=new le(r);return new ee(n)}getCaptureCanvasContext(e){if(!this.captureCanvasContext){const r=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=r}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){const t=this.createCaptureCanvas(e);this.captureCanvas=t}return this.captureCanvas}decodeBitmap(e){return this.reader.decode(e,this._hints)}createCaptureCanvas(e){if(typeof document>"u")return this._destroyCaptureCanvas(),null;const t=document.createElement("canvas");let r,n;return typeof e<"u"&&(e instanceof HTMLVideoElement?(r=e.videoWidth,n=e.videoHeight):e instanceof HTMLImageElement&&(r=e.naturalWidth||e.width,n=e.naturalHeight||e.height)),t.style.width=r+"px",t.style.height=n+"px",t.width=r,t.height=n,t}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}
39addVideoSource(e,t){try{e.srcObject=t}catch{e.src=URL.createObjectURL(t)}}cleanVideoSource(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")}}class Je{constructor(e,t,r=t==null?0:8*t.length,n,s,i=G.currentTimeMillis()){this.text=e,this.rawBytes=t,this.numBits=r,this.resultPoints=n,this.format=s,this.timestamp=i,this.text=e,this.rawBytes=t,r==null?this.numBits=t==null?0:8*t.length:this.numBits=r,this.resultPoints=n,this.format=s,this.resultMetadata=null,i==null?this.timestamp=G.currentTimeMillis():this.timestamp=i}getText(){return this.text}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}getResultPoints(){return this.resultPoints}getBarcodeFormat(){return this.format}getResultMetadata(){return this.resultMetadata}putMetadata(e,t){this.resultMetadata===null&&(this.resultMetadata=new Map),this.resultMetadata.set(e,t)}putAllMetadata(e){e!==null&&(this.resultMetadata===null?this.resultMetadata=e:this.resultMetadata=new Map(e))}addResultPoints(e){const t=this.resultPoints;if(t===null)this.resultPoints=e;else if(e!==null&&e.length>0){const r=new Array(t.length+e.length);G.arraycopy(t,0,r,0,t.length),G.arraycopy(e,0,r,t.length,e.length),this.resultPoints=r}}getTimestamp(){return this.timestamp}toString(){return this.text}}var gr;(function(d){d[d.AZTEC=0]="AZTEC",d[d.CODABAR=1]="CODABAR",d[d.CODE_39=2]="CODE_39",d[d.CODE_93=3]="CODE_93",d[d.CODE_128=4]="CODE_128",d[d.DATA_MATRIX=5]="DATA_MATRIX",d[d.EAN_8=6]="EAN_8",d[d.EAN_13=7]="EAN_13",d[d.ITF=8]="ITF",d[d.MAXICODE=9]="MAXICODE",d[d.PDF_417=10]="PDF_417",d[d.QR_CODE=11]="QR_CODE",d[d.RSS_14=12]="RSS_14",d[d.RSS_EXPANDED=13]="RSS_EXPANDED",d[d.UPC_A=14]="UPC_A",d[d.UPC_E=15]="UPC_E",d[d.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(gr||(gr={}));var re=gr,mr;(function(d){d[d.OTHER=0]="OTHER",d[d.ORIENTATION=1]="ORIENTATION",d[d.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",d[d.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",d[d.ISSUE_NUMBER=4]="ISSUE_NUMBER",d[d.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",d[d.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",d[d.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",d[d.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",d[d.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",d[d.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(mr||(mr={}));var Ge=mr;class de{constructor(e,t,r,n,s=-1,i=-1){this.rawBytes=e,this.text=t,this.byteSegments=r,this.ecLevel=n,this.structuredAppendSequenceNumber=s,this.structuredAppendParity=i,this.numBits=e==null?0:8*e.length}getRawBytes(){return this.rawBytes}getNumBits(){return this.numBits}setNumBits(e){this.numBits=e}getText(){return this.text}getByteSegments(){return this.byteSegments}getECLevel(){return this.ecLevel}getErrorsCorrected(){return this.errorsCorrected}setErrorsCorrected(e){this.errorsCorrected=e}getErasures(){return this.erasures}setErasures(e){this.erasures=e}getOther(){return this.other}setOther(e){this.other=e}hasStructuredAppend(){return this.structuredAppendParity>=0&&this.structuredAppendSequenceNumber>=0}getStructuredAppendParity(){return this.structuredAppendParity}getStructuredAppendSequenceNumber(){return this.structuredAppendSequenceNumber}}class We{exp(e){return this.expTable[e]}log(e){if(e===0)throw new v;return this.logTable[e]}static addOrSubtract(e,t){return e^t}}class Me{constructor(e,t){if(t.length===0)throw new v;this.field=e;const r=t.length;if(r>1&&t[0]===0){let n=1;for(;n<r&&t[n]===0;)n++;n===r?this.coefficients=Int32Array.from([0]):(this.coefficients=new Int32Array(r-n),G.arraycopy(t,n,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);const t=this.coefficients;let r;if(e===1){r=0;for(let i=0,a=t.length;i!==a;i++){const o=t[i];r=We.addOrSubtract(r,o)}return r}r=t[0];const n=t.length,s=this.field;for(let i=1;i<n;i++)r=We.addOrSubtract(s.multiply(e,r),t[i]);return r}addOrSubtract(e){if(!this.field.equals(e.field))throw new v("GenericGFPolys do n
39ot have same GenericGF field");if(this.isZero())return e;if(e.isZero())return this;let t=this.coefficients,r=e.coefficients;if(t.length>r.length){const i=t;t=r,r=i}let n=new Int32Array(r.length);const s=r.length-t.length;G.arraycopy(r,0,n,0,s);for(let i=s;i<r.length;i++)n[i]=We.addOrSubtract(t[i-s],r[i]);return new Me(this.field,n)}multiply(e){if(!this.field.equals(e.field))throw new v("GenericGFPolys do not have same GenericGF field");if(this.isZero()||e.isZero())return this.field.getZero();const t=this.coefficients,r=t.length,n=e.coefficients,s=n.length,i=new Int32Array(r+s-1),a=this.field;for(let o=0;o<r;o++){const c=t[o];for(let u=0;u<s;u++)i[o+u]=We.addOrSubtract(i[o+u],a.multiply(c,n[u]))}return new Me(a,i)}multiplyScalar(e){if(e===0)return this.field.getZero();if(e===1)return this;const t=this.coefficients.length,r=this.field,n=new Int32Array(t),s=this.coefficients;for(let i=0;i<t;i++)n[i]=r.multiply(s[i],e);return new Me(r,n)}multiplyByMonomial(e,t){if(e<0)throw new v;if(t===0)return this.field.getZero();const r=this.coefficients,n=r.length,s=new Int32Array(n+e),i=this.field;for(let a=0;a<n;a++)s[a]=i.multiply(r[a],t);return new Me(i,s)}divide(e){if(!this.field.equals(e.field))throw new v("GenericGFPolys do not have same GenericGF field");if(e.isZero())throw new v("Divide by 0");const t=this.field;let r=t.getZero(),n=this;const s=e.getCoefficient(e.getDegree()),i=t.inverse(s);for(;n.getDegree()>=e.getDegree()&&!n.isZero();){const a=n.getDegree()-e.getDegree(),o=t.multiply(n.getCoefficient(n.getDegree()),i),c=e.multiplyByMonomial(a,o),u=t.buildMonomial(a,o);r=r.addOrSubtract(u),n=n.addOrSubtract(c)}return[r,n]}toString(){let e="";for(let t=this.getDegree();t>=0;t--){let r=this.getCoefficient(t);if(r!==0){if(r<0?(e+=" - ",r=-r):e.length>0&&(e+=" + "),t===0||r!==1){const n=this.field.log(r);n===0?e+="1":n===1?e+="a":(e+="a^",e+=n)}t!==0&&(t===1?e+="x":(e+="x^",e+=t))}}return e}}class $e extends p{}$e.kind="ArithmeticException";class ue extends We{constructor(e,t,r){super(),this.primitive=e,this.size=t,this.generatorBase=r;const n=new Int32Array(t);let s=1;for(let a=0;a<t;a++)n[a]=s,s*=2,s>=t&&(s^=e,s&=t-1);this.expTable=n;const i=new Int32Array(t);for(let a=0;a<t-1;a++)i[n[a]]=a;this.logTable=i,this.zero=new Me(this,Int32Array.from([0])),this.one=new Me(this,Int32Array.from([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,t){if(e<0)throw new v;if(t===0)return this.zero;const r=new Int32Array(e+1);return r[0]=t,new Me(this,r)}inverse(e){if(e===0)throw new $e;return this.expTable[this.size-this.logTable[e]-1]}multiply(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.size-1)]}getSize(){return this.size}getGeneratorBase(){return this.generatorBase}toString(){return"GF(0x"+W.toHexString(this.primitive)+","+this.size+")"}equals(e){return e===this}}ue.AZTEC_DATA_12=new ue(4201,4096,1),ue.AZTEC_DATA_10=new ue(1033,1024,1),ue.AZTEC_DATA_6=new ue(67,64,1),ue.AZTEC_PARAM=new ue(19,16,1),ue.QR_CODE_FIELD_256=new ue(285,256,0),ue.DATA_MATRIX_FIELD_256=new ue(301,256,1),ue.AZTEC_DATA_8=ue.DATA_MATRIX_FIELD_256,ue.MAXICODE_FIELD_64=ue.AZTEC_DATA_6;class Rt extends p{}Rt.kind="ReedSolomonException";class Ot extends p{}Ot.kind="IllegalStateException";class wr{constructor(e){this.field=e}decode(e,t){const r=this.field,n=new Me(r,e),s=new Int32Array(t);let i=!0;for(let E=0;E<t;E++){const I=n.evaluateAt(r.exp(E+r.getGeneratorBase()));s[s.length-1-E]=I,I!==0&&(i=!1)}if(i)return;const a=new Me(r,s),o=this.runEuclideanAlgorithm(r.buildMonomial(t,1),a,t),c=o[0],u=o[1],f=this.findErrorLocations(c),x=this.findErrorMagnitudes(u,f);for(let E=0;E<f.length;E++){const I=e.length-1-r.log(f[E]);if(I<0)throw new Rt("Bad error location");e[I]=ue.addOrSubtract(e[I],x[E])}}runEuclideanAlgorithm(e,t,r){if(e.getDegree()<t.getDegree()){const E=e;e=t,t=E}const n=this.field;let s=e,i=t,a=n.getZero(),o=n.getOne();for(;i.getDegree()>=(r/2|0);){let E=s,I=a;if(s=i,a=o,s.isZero())throw new Rt("r_{i-1} was zero");i=E;let y=n.getZero();const N=s.getCoefficient(s.getDegree()),O=n.inverse(N);for(;i.getDegree()>=s.getDegree()&&!i.isZero();){const U=i.getDegree()-s.getDegree(),j=n.multiply(i.getCoefficient(i.getDegree()),O);y=y.addOrSubtract(n.buildMonomial(U,j)),i=i.addOrSubtract(s.multiplyByMonomial(U,j))}if(o=y.multiply(a).addOrSubtract(I),i.getDegree()>=s.getDegree())throw new Ot("Division algorithm failed to reduce polynomial?")}const c=o.getCoefficient(0);if(c===0)throw new Rt("sigmaTilde(0) was zero");const u=n.inverse(c),f=o.multiplyScalar(u),x=i.multiplyScalar(u);return[f,x]}findErrorLocations(e){const t=e.getDegree();if(t===1)return Int32Array.from([e.getCoefficient(1)]);const r=new Int32Array(t);let n=0;const s=this.field;for(let i=1;i<s.getSize()&&n<t;i++)e.evaluateAt(i)===0&&(r[n]=s.inverse(i),n++);if(n!==t)throw new Rt("Error locator degree does not match number of roots");return r}findErrorMagnitudes(e,t){const r=t.length,n=new Int32Array(r),s=this.field;for(let i=0;i<r;i++){const a=s.inverse(t[i]);let o=1;for(let c=0;c<r;c++)if(i!==c){const u=s.multiply(t[c],a),f=u&1?u&-2:u|1;o=s.multiply(o,f)}n[i]=s.multiply(e.evaluateAt(a),s.inverse(o)),s.getGeneratorBase()!==0&&(n[i]=s.multiply(n[i],a))}return n}}var et;(function(d){d[d.UPPER=0]="UPPER",d[d.LOWER=1]="LOWER",d[d.MIXED=2]="MIXED",d[d.DIGIT
vendor: 9,012 bytes, lines 39-41
39=3]="DIGIT",d[d.PUNCT=4]="PUNCT",d[d.BINARY=5]="BINARY"})(et||(et={}));class Re{decode(e){this.ddata=e;let t=e.getBits(),r=this.extractBits(t),n=this.correctBits(r),s=Re.convertBoolArrayToByteArray(n),i=Re.getEncodedData(n),a=new de(s,i,null,null);return a.setNumBits(n.length),a}static highLevelDecode(e){return this.getEncodedData(e)}static getEncodedData(e){let t=e.length,r=et.UPPER,n=et.UPPER,s="",i=0;for(;i<t;)if(n===et.BINARY){if(t-i<5)break;let a=Re.readCode(e,i,5);if(i+=5,a===0){if(t-i<11)break;a=Re.readCode(e,i,11)+31,i+=11}for(let o=0;o<a;o++){if(t-i<8){i=t;break}const c=Re.readCode(e,i,8);s+=te.castAsNonUtf8Char(c),i+=8}n=r}else{let a=n===et.DIGIT?4:5;if(t-i<a)break;let o=Re.readCode(e,i,a);i+=a;let c=Re.getCharacter(n,o);c.startsWith("CTRL_")?(r=n,n=Re.getTable(c.charAt(5)),c.charAt(6)==="L"&&(r=n)):(s+=c,n=r)}return s}static getTable(e){switch(e){case"L":return et.LOWER;case"P":return et.PUNCT;case"M":return et.MIXED;case"D":return et.DIGIT;case"B":return et.BINARY;case"U":default:return et.UPPER}}static getCharacter(e,t){switch(e){case et.UPPER:return Re.UPPER_TABLE[t];case et.LOWER:return Re.LOWER_TABLE[t];case et.MIXED:return Re.MIXED_TABLE[t];case et.PUNCT:return Re.PUNCT_TABLE[t];case et.DIGIT:return Re.DIGIT_TABLE[t];default:throw new Ot("Bad table")}}correctBits(e){let t,r;this.ddata.getNbLayers()<=2?(r=6,t=ue.AZTEC_DATA_6):this.ddata.getNbLayers()<=8?(r=8,t=ue.AZTEC_DATA_8):this.ddata.getNbLayers()<=22?(r=10,t=ue.AZTEC_DATA_10):(r=12,t=ue.AZTEC_DATA_12);let n=this.ddata.getNbDatablocks(),s=e.length/r;if(s<n)throw new P;let i=e.length%r,a=new Int32Array(s);for(let x=0;x<s;x++,i+=r)a[x]=Re.readCode(e,i,r);try{new wr(t).decode(a,s-n)}catch(x){throw new P(x)}let o=(1<<r)-1,c=0;for(let x=0;x<n;x++){let E=a[x];if(E===0||E===o)throw new P;(E===1||E===o-1)&&c++}let u=new Array(n*r-c),f=0;for(let x=0;x<n;x++){let E=a[x];if(E===1||E===o-1)u.fill(E>1,f,f+r-1),f+=r-1;else for(let I=r-1;I>=0;--I)u[f++]=(E&1<<I)!==0}return u}extractBits(e){let t=this.ddata.isCompact(),r=this.ddata.getNbLayers(),n=(t?11:14)+r*4,s=new Int32Array(n),i=new Array(this.totalBitsInLayer(r,t));if(t)for(let a=0;a<s.length;a++)s[a]=a;else{let a=n+1+2*W.truncDivision(W.truncDivision(n,2)-1,15),o=n/2,c=W.truncDivision(a,2);for(let u=0;u<o;u++){let f=u+W.truncDivision(u,15);s[o-u-1]=c-f-1,s[o+u]=c+f+1}}for(let a=0,o=0;a<r;a++){let c=(r-a)*4+(t?9:12),u=a*2,f=n-1-u;for(let x=0;x<c;x++){let E=x*2;for(let I=0;I<2;I++)i[o+E+I]=e.get(s[u+I],s[u+x]),i[o+2*c+E+I]=e.get(s[u+x],s[f-I]),i[o+4*c+E+I]=e.get(s[f-I],s[f-x]),i[o+6*c+E+I]=e.get(s[f-x],s[u+I])}o+=c*8}return i}static readCode(e,t,r){let n=0;for(let s=t;s<t+r;s++)n<<=1,e[s]&&(n|=1);return n}static readByte(e,t){let r=e.length-t;return r>=8?Re.readCode(e,t,8):Re.readCode(e,t,r)<<8-r}static convertBoolArrayToByteArray(e){let t=new Uint8Array((e.length+7)/8);for(let r=0;r<t.length;r++)t[r]=Re.readByte(e,8*r);return t}totalBitsInLayer(e,t){return((t?88:112)+16*e)*e}}Re.UPPER_TABLE=["CTRL_PS"," ","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","CTRL_LL","CTRL_ML","CTRL_DL","CTRL_BS"],Re.LOWER_TABLE=["CTRL_PS"," ","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","CTRL_US","CTRL_ML","CTRL_DL","CTRL_BS"],Re.MIXED_TABLE=["CTRL_PS"," ","\\1","\\2","\\3","\\4","\\5","\\6","\\7","\b"," ",` 40`,"\\13","\f","\r","\\33","\\34","\\35","\\36","\\37","@","\\","^","_","`","|","~","\\177","CTRL_LL","CTRL_UL","CTRL_PL","CTRL_BS"],Re.PUNCT_TABLE=["","\r",`\r 41`,". ",", ",": ","!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}","CTRL_UL"],Re.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class we{constructor(){}static round(e){return e===NaN?0:e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,t,r,n){const s=e-r,i=t-n;return Math.sqrt(s*s+i*i)}static sum(e){let t=0;for(let r=0,n=e.length;r!==n;r++){const s=e[r];t+=s}return t}}class Or{static floatToIntBits(e){return e}}Or.MAX_VALUE=Number.MAX_SAFE_INTEGER;class Z{constructor(e,t){this.x=e,this.y=t}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof Z){const t=e;return this.x===t.x&&this.y===t.y}return!1}hashCode(){return 31*Or.floatToIntBits(this.x)+Or.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){const t=this.distance(e[0],e[1]),r=this.distance(e[1],e[2]),n=this.distance(e[0],e[2]);let s,i,a;if(r>=t&&r>=n?(i=e[0],s=e[1],a=e[2]):n>=r&&n>=t?(i=e[1],s=e[0],a=e[2]):(i=e[2],s=e[0],a=e[1]),this.crossProductZ(s,i,a)<0){const o=s;s=a,a=o}e[0]=s,e[1]=i,e[2]=a}static distance(e,t){return we.distance(e.x,e.y,t.x,t.y)}static crossProductZ(e,t,r){const n=t.x,s=t.y;return(r.x-n)*(e.y-s)-(r.y-s)*(e.x-n)}}class Dr{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class En extends Dr{constructor(e,t,r,n,s){super(e,t),this.compact=r,this.nbDatablocks=n,this.nbLayers=s}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class kt{constructor(e,t,r,n){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),t==null&&(t=kt.INIT_SIZE),r==null&&(r=e.getWidth()/2|0),n==null&&(n=e.getHeight()/2|0);const s=t/2|0;if(this.leftInit=r-s,this.rightInit=r+s,this.upInit=n-s,this.downInit=n+s,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new B}detect(){let e=this.leftInit,t=this.rightInit,r=this.upInit,n=this.downInit,s=!1,i=!0,a=!1,o=!1,c=!1,u=!1,f=!1;const x=this.width,E=this.height;for(;i;){i=!1;let I=!0;for(;(I||!o)&&t<x;)I=this.containsBlackPoint(r,n,t,!1),I?(t++,i=!0,o=!0):o||t++;if(t>=x){s=!0;break}let y=!0;for(;(y||!c)&&n<E;)y=this.containsBlackPoint(e,t,n,!0),y?(n++,i=!0,c=!0):c||n++;if(n>=E){s=!0;break}let N=!0;for(;(N||!u)&&e>=0;)N=this.containsBlackPoint(r,n,e,!1),N?(e--,i=!0,u=!0):u||e--;if(e<0){s=!0;break}let O=!0;for(;(O||!f)&&r>=0;)O=this.containsBlackPoint(e,t,r,!0),O?(r--,i=!0,f=!0):f||r--;if(r<0){s=!0;break}i&&(a=!0)}if(!s&&a){const I=t-e;let y=null;for(let j=1;y===null&&j<I;j++)y=this.getBlackPointOnSegment(e,n-j,e+j,n);if(y==null)throw new B;let N=null;for(let j=1;N===null&&j<I;j++)N=this.getBlackPointOnSegment(e,r+j,e+j,r);if(N==null)throw new B;let O=null;for(let j=1;O===null&&j<I;j++)O=this.getBlackPointOnSegment(t,r+j,t-j,r);if(O==null)throw new B;let U=null;for(let j=1;U===null&&j<I;j++)U=this.getBlackPointOnSegment(t,n-j,t-j,n);if(U==null)throw new B;return this.centerEdges(U,y,O,N)}else throw new B}getBlackPointOnSegment(e,t,r,n){const s=we.round(we.distance(e,t,r,n)),i=(r-e)/s,a=(n-t)/s,o=this.image;for(let c=0;c<s;c++){const u=we.round(e+c*i),f=we.round(t+c*a);if(o.get(u,f))return new Z(u,f)}return null}centerEdges(e,t,r,n){const s=e.getX(),i=e.getY(),a=t.getX(),o=t.getY(),c=r.getX(),u=r.getY(),f=n.getX(),x=n.getY(),E=kt.CORR;return s<this.width/2?[new Z(f-E,x+E),new Z(a+E,o+E),new Z(c-E,u-E),new Z(s+E,i-E)]:[new Z(f+E,x+E),new Z(a+E,o-E),new Z(c-E,u+E),new Z(s-E,i-E)]}containsBlackPoint(e,t,r,n){const s=this.image;if(n){for(let i=e;i<=t;i++)if(s.get(i,r))return!0}else for(let i=e;i<=t;i++)if(s.get(r,i))return!0;return!1}}kt.INIT_SIZE=10,kt.CORR=1;class Yr{static checkAndNudgePoints(e,t){const r=e.getWidth(),n=e.getHeight();let s=!0;for(let i=0;i<t.length&&s;i+=2){const a=Math.floor(t[i]),o=Math.floor(t[i+1]);if(a<-1||a>r||o<-1||o>n)throw new B;s=!1,a===-1?(t[i]=0,s=!0):a===r&&(t[i]=r-1,s=!0),o===-1?(t[i+1]=0,s=!0):o===n&&(t[i+1]=n-1,s=!0)}s=!0;for(let i=t.length-2;i>=0&&s;i-=2){const a=Math.floor(t[i]),o=Math.floor(t[i+1]);if(a<-1||a>r||o<-1||o>n)throw new B;s=!1,a===-1?(t[i]=0,s=!0):a===r&&(t[i]=r-1,s=!0),o===-1?(t[i+1]=0,s=!0):o===n&&(t[i+1]=n-1,s=!0)}}}class Nt{constructor(e,t,r,n,s,i,a,o,c){this.a11=e,this.a21=t,this.a31=r,this.a12=n,this.a22=s,this.a32=i,this.a13=a,this.a23=o,this.a33=c}static quadrilateralToQuadrilateral(e,t,r,n,s,i,a,o,c,u,f,x,E,I,y,N){const O=Nt.quadrilateralToSquare(e,t,r,n,s,i,a,o);return Nt.squareToQuadrilateral(c,u,f,x,E,I,y,N).times(O)}transformPoints(e){const t=e.length,r=this.a11,n=this.a12,s=this.a13,i=this.a21,a=this.a22,o=this.a23,c=this.a31,u=this.a32,f=this.a33;for(let x=0;x<t;x+=2){const E=e[x],I=e[x+1],y=s*E+o*I+f;e[x]=(r*E+i*I+c)/y,e[x+1]=(n*E+a*I+u)/y}}transformPointsWithValues(e,t){const r=this.a11,n=this.a12,s=this.a13,i=this.a21,a=this.a22,o=this.a23,c=this.a31,u=this.a32,f=this.a33,x=e.length;for(let E=0;E<x;E++){const I=e[E],y=t[E],N=s*I+o*y+f;e[E]=(r*I+i*y+c)/N,t[E]=(n*I+a*y+u)/N}}static squareToQuadrilateral(e,t,r,n,s,i,a,o){const c=e-r+s-a,u=t-n+i-o;if(c===0&&u===0)return new Nt(r-e,s-r,e,n-t,i-n,t,0,0,1);{const f=r-s,x=a-s,E=n-i,I=o-i,y=f*I-x*E,N=(c*I-x*u)/y,O=(f*u-c*E)/y;return new Nt(r-e+N*r,a-e+O*a,e,n-t+N*n,o-t+O*o,t,N,O,1)}}static quadrilateralToSquare(e,t,r,n,s,i,a,o){return Nt.squareToQuadrilateral(e,t,r,n,s,i,a,o).buildAdjoint(
41)}buildAdjoint(){return new Nt(this.a22*this.a33-this.a23*this.a32,this.a23*this.a31-this.a21*this.a33,this.a21*this.a32-this.a22*this.a31,this.a13*this.a32-this.a12*this.a33,this.a11*this.a33-this.a13*this.a31,this.a12*this.a31-this.a11*this.a32,this.a12*this.a23-this.a13*this.a22,this.a13*this.a21-this.a11*this.a23,this.a11*this.a22-this.a12*this.a21)}times(e){return new Nt(this.a11*e.a11+this.a21*e.a12+this.a31*e.a13,this.a11*e.a21+this.a21*e.a22+this.a31*e.a23,this.a11*e.a31+this.a21*e.a32+this.a31*e.a33,this.a12*e.a11+this.a22*e.a12+this.a32*e.a13,this.a12*e.a21+this.a22*e.a22+this.a32*e.a23,this.a12*e.a31+this.a22*e.a32+this.a32*e.a33,this.a13*e.a11+this.a23*e.a12+this.a33*e.a13,this.a13*e.a21+this.a23*e.a22+this.a33*e.a23,this.a13*e.a31+this.a23*e.a32+this.a33*e.a33)}}class bn extends Yr{sampleGrid(e,t,r,n,s,i,a,o,c,u,f,x,E,I,y,N,O,U,j){const k=Nt.quadrilateralToQuadrilateral(n,s,i,a,o,c,u,f,x,E,I,y,N,O,U,j);return this.sampleGridWithTransform(e,t,r,k)}sampleGridWithTransform(e,t,r,n){if(t<=0||r<=0)throw new B;const s=new De(t,r),i=new Float32Array(2*t);for(let a=0;a<r;a++){const o=i.length,c=a+.5;for(let u=0;u<o;u+=2)i[u]=u/2+.5,i[u+1]=c;n.transformPoints(i),Yr.checkAndNudgePoints(e,i);try{for(let u=0;u<o;u+=2)e.get(Math.floor(i[u]),Math.floor(i[u+1]))&&s.set(u/2,a)}catch{throw new B}}return s}}class Vt{static setGridSampler(e){Vt.gridSampler=e}static getInstance(){return Vt.gridSampler}}Vt.gridSampler=new bn;class ot{constructor(e,t){this.x=e,this.y=t}toResultPoint(){return new Z(this.getX(),this.getY())}getX(){return this.x}getY(){return this.y}}class In{constructor(e){this.EXPECTED_CORNER_BITS=new Int32Array([3808,476,2107,1799]),this.image=e}detect(){return this.detectMirror(!1)}detectMirror(e){let t=this.getMatrixCenter(),r=this.getBullsEyeCorners(t);if(e){let i=r[0];r[0]=r[2],r[2]=i}this.extractParameters(r);let n=this.sampleGrid(this.image,r[this.shift%4],r[(this.shift+1)%4],r[(this.shift+2)%4],r[(this.shift+3)%4]),s=this.getMatrixCornerPoints(r);return new En(n,s,this.compact,this.nbDataBlocks,this.nbLayers)}extractParameters(e){if(!this.isValidPoint(e[0])||!this.isValidPoint(e[1])||!this.isValidPoint(e[2])||!this.isValidPoint(e[3]))throw new B;let t=2*this.nbCenterLayers,r=new Int32Array([this.sampleLine(e[0],e[1],t),this.sampleLine(e[1],e[2],t),this.sampleLine(e[2],e[3],t),this.sampleLine(e[3],e[0],t)]);this.shift=this.getRotation(r,t);let n=0;for(let i=0;i<4;i++){let a=r[(this.shift+i)%4];this.compact?(n<<=7,n+=a>>1&127):(n<<=10,n+=(a>>2&992)+(a>>1&31))}let s=this.getCorrectedParameterData(n,this.compact);this.compact?(this.nbLayers=(s>>6)+1,this.nbDataBlocks=(s&63)+1):(this.nbLayers=(s>>11)+1,this.nbDataBlocks=(s&2047)+1)}getRotation(e,t){let r=0;e.forEach((n,s,i)=>{let a=(n>>t-2<<1)+(n&1);r=(r<<3)+a}),r=((r&1)<<11)+(r>>1);for(let n=0;n<4;n++)if(W.bitCount(r^this.EXPECTED_CORNER_BITS[n])<=2)return n;throw new B}getCorrectedParameterData(e,t){let r,n;t?(r=7,n=2):(r=10,n=4);let s=r-n,i=new Int32Array(r);for(let o=r-1;o>=0;--o)i[o]=e&15,e>>=4;try{new wr(ue.AZTEC_PARAM).decode(i,s)}catch{throw new B}let a=0;for(let o=0;o<n;o++)a=(a<<4)+i[o];return a}getBullsEyeCorners(e){let t=e,r=e,n=e,s=e,i=!0;for(this.nbCenterLayers=1;this.nbCenterLayers<9;this.nbCenterLayers++){let f=this.getFirstDifferent(t,i,1,-1),x=this.getFirstDifferent(r,i,1,1),E=this.getFirstDifferent(n,i,-1,1),I=this.getFirstDifferent(s,i,-1,-1);if(this.nbCenterLayers>2){let y=this.distancePoint(I,f)*this.nbCenterLayers/(this.distancePoint(s,t)*(this.nbCenterLayers+2));if(y<.75||y>1.25||!this.isWhiteOrBlackRectangle(f,x,E,I))break}t=f,r=x,n=E,s=I,i=!i}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new B;this.compact=this.nbCenterLayers===5;let a=new Z(t.getX()+.5,t.getY()-.5),o=new Z(r.getX()+.5,r.getY()+.5),c=new Z(n.getX()-.5,n.getY()+.5),u=new Z(s.getX()-.5,s.getY()-.5);return this.expandSquare([a,o,c,u],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,t,r,n;try{let a=new kt(this.image).detect();e=a[0],t=a[1],r=a[2],n=a[3]}catch{let o=this.image.getWidth()/2,c=this.image.getHeight()/2;e=this.getFirstDifferent(new ot(o+7,c-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new ot(o+7,c+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new ot(o-7,c+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new ot(o-7,c-7),!1,-1,-1).toResultPoint()}let s=we.round((e.getX()+n.getX()+t.getX()+r.getX())/4),i=we.round((e.getY()+n.getY()+t.getY()+r.getY())/4);try{let a=new kt(this.image,15,s,i).detect();e=a[0],t=a[1],r=a[2],n=a[3]}catch{e=this.getFirstDifferent(new ot(s+7,i-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new ot(s+7,i+7),!1,1,1).toResultPoint(),r=this.getFirstDifferent(new ot(s-7,i+7),!1,-1,1).toResultPoint(),n=this.getFirstDifferent(new ot(s-7,i-7),!1,-1,-1).toResultPoint()}return s=we.round((e.getX()+n.getX()+t.getX()+r.getX())/4),i=we.round((e.getY()+n.getY()+t.getY()+r.getY())/4),new ot(s,i)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,t,r,n,s){let i=Vt.getInstance(),a=this.getDimension(),o=a/2-this.nbCenterLayers,c=a/2+this.nbCenterLayers;return i.sampleGrid(e,a,a,o,o,c,o,c,c,o,c,t.getX(),t.getY(),r.getX(),r.getY(),n.getX(),n.getY(),s.getX(),s.getY())}sampleLine(e,t,r){let n=0,s=this.distanceResultPoint(e,t),i=s/r,a=e.getX(),o=e.getY(),c=i*(t.getX()-e.getX())/s,u=i*(t.getY()-e.getY())/s;for(let f=0;f<r;f++)this.image.get(we.round(a+f*c),we.round(o+f*u))&&(n|=1<<r-f-1);return n}isWhiteOrBlackRectangle(e,t,r,n){let s=3;e=new ot(e.getX()-s,e.getY()+s),t=new ot(t.getX()-s,t.getY()-s),r=new ot(r.getX()+s,r.getY()-s),n=new ot(n.getX()+s,n.getY()+s);let i=this.getColor(n,e);if(i===0)return!1;let a=this.getColor(e,t);return a!==i||(a=this.getColor(t,r),a!==i)?!1:(a=this.getColor(r,n),a===i)}getColor(e,t){let r=this.distancePoint(e,t),n=(t.getX()-e.getX())/r,s=(t.getY()-e.getY())/r,i=0,a=e.getX(),o=e.getY(),c=this.image.get(e.getX(),e.getY()),u=Math.ceil(r);for(let x=0;x<u;x++)a+=n,o+=s,this.image.get(we.round(a),we.round(o))!==c&&i++;let f=i/r;return f>.1&&f<.9?0:f<=.1===c?1:-1}getFirstDifferent(e,t,r,n){let s=e.getX()+r,i=e.getY()+n;for(;this.isValid(s,i)&&this.image.get(s,i)===t;)s+=r,i+=n;for(s-=r,i-=n;this.isValid(s,i)&&this.image.get(s,i)===t;)s+=r;for(s-=r;this.isValid(s,i)&&this.image.get(s,i)===t;)i+=n;return i-=n,new ot(s,i)}expandSquare(e,t,r){let n=r/(2*t),s=e[0].getX()-e[2].getX(),i=e[0].getY()-e[2].getY(),a=(e[0].getX()+e[2].getX())/2,o=(e[0].getY()+e[2].getY())/2,c=new Z(a+n*s,o+n*i),u=new Z(a-n*s,o-n*i);s=e[1].getX()-e[3].getX(),i=e[1].getY()-e[3].getY(),a=(e[1].getX()+e[3].getX())/2,o=(e[1].getY()+e[3].getY())/2;let f=new Z(a+n*s,o+n*i),x=new Z(a-n*s,o-n*i);return[c,f,u,x]}isValid(e,t){return e>=0&&e<this.image.getWidth()&&t>0&&t<this.image.getHeight()}isValidPoint(e){let t=we.round(e.getX()),r=we.round(e.getY());return this.isValid(t,r)}distancePoint(e,t){return we.distance(e.getX(),e.getY(),t.getX(),t.getY())}distanceResultPoint(e,t){return we.distance(e.getX(),e.getY(),t.getX(),t.getY())}getDimension(){return this.compact?4*this.nbLayers+11:this.nbLayers<=4?4*this.nbLayers+15:4*this.nbLayers+2*(W.truncDivision(this.nbLayers-4,8)+1)+15}}class vr{decode(e,t=null){let r=null,n=new In(e.getBlackMatrix()),s=null,i=null;try{let u=n.detectMirror(!1);s=u.getPoints(),this.reportFoundResultPoints(t,s),i=new Re().decode(u)}catch(u){r=u}if(i==null)try{let u=n.detectMirror(!0);s=u.getPoints(),this.reportFoundResultPoints(t,s),i=new Re().decode(u)}catch(u){throw r??u}let a=new Je(i.getText(),i.getRawBytes(),i.getNumBits(),s,re.AZTEC,G.currentTimeMillis()),o=i.getByteSegments();o!=null&&a.putMetadata(Ge.BYTE_SEGMENTS,o);let c=i.getECLevel();return c!=null&&a.putMetadata(Ge.ERROR_CORRECTION_LEVEL,c),a}reportFoundResultPoints(e,t){if(e!=null){let r=e.get(K.NEED_RESULT_POINT_CALLBACK);r!=null&&t.forEach((n,s,i)=>{r.foundPossibleResultPoint(n)})}}reset(){}}class As extends Ft{constructor(e=500){super(new vr,e)}}class Xe{decode(e,t){try{return this.doDecode(e,t)}catch{if(t&&t.get(K.TRY_HARDER)===!0&&e.isRotateSupported()){const s=e.rotateCounterClockwise(),i=this.doDecode(s,t),a=i.getResultMetadata();let o=270;a!==null&&a.get(Ge.ORIENTATION)===!0&&(o=o+a.get(Ge.ORIENTATION)%360),i.putMetadata(Ge.ORIENTATION,o);const c=i.getResultPoints();if(c!==null){const u=s.getHeight();for(let f=0;f<c.length;f++)c[f]=new Z(u-c[f].getY()-1,c[f].getX())}return i}else throw new B}}reset(){}doDecode(e,t){const r=e.getWidth(),n=e.getHeight();let s=new ce(r);const i=t&&t.get(K.TRY_HARDER)===!0,a=Math.max(1,n>>(i?8:5));let o;i?o=n:o=15;const c=Math.trunc(n/2);for(let u=0;u<o;u++){const f=Math.trunc((u+1)/2),x=(u&1)===0,E=c+a*(x?f:-f);if(E<0||E>=n)break;try{s=e.getBlackRow(E,s)}catch{continue}for(let I=0;I<2;I++){if(I===1&&(s.reverse(),t&&t.get(K.NEED_RESULT_POINT_CALLBACK)===!0)){const y=new Map;t.forEach((N,O)=>y.set(O,N)),y.delete(K.NEED_RESULT_POINT_CALLBACK),t=y}try{const y=this.decodeRow(E,s,t);
41if(I===1){y.putMetadata(Ge.ORIENTATION,180);const N=y.getResultPoints();N!==null&&(N[0]=new Z(r-N[0].getX()-1,N[0].getY()),N[1]=new Z(r-N[1].getX()-1,N[1].getY()))}return y}catch{}}}throw new B}static recordPattern(e,t,r){const n=r.length;for(let c=0;c<n;c++)r[c]=0;const s=e.getSize();if(t>=s)throw new B;let i=!e.get(t),a=0,o=t;for(;o<s;){if(e.get(o)!==i)r[a]++;else{if(++a===n)break;r[a]=1,i=!i}o++}if(!(a===n||a===n-1&&o===s))throw new B}static recordPatternInReverse(e,t,r){let n=r.length,s=e.get(t);for(;t>0&&n>=0;)e.get(--t)!==s&&(n--,s=!s);if(n>=0)throw new B;Xe.recordPattern(e,t+1,r)}static patternMatchVariance(e,t,r){const n=e.length;let s=0,i=0;for(let c=0;c<n;c++)s+=e[c],i+=t[c];if(s<i)return Number.POSITIVE_INFINITY;const a=s/i;r*=a;let o=0;for(let c=0;c<n;c++){const u=e[c],f=t[c]*a,x=u>f?u-f:f-u;if(x>r)return Number.POSITIVE_INFINITY;o+=x}return o/s}}class V extends Xe{static findStartPattern(e){const t=e.getSize(),r=e.getNextSet(0);let n=0,s=Int32Array.from([0,0,0,0,0,0]),i=r,a=!1;const o=6;for(let c=r;c<t;c++)if(e.get(c)!==a)s[n]++;else{if(n===o-1){let u=V.MAX_AVG_VARIANCE,f=-1;for(let x=V.CODE_START_A;x<=V.CODE_START_C;x++){const E=Xe.patternMatchVariance(s,V.CODE_PATTERNS[x],V.MAX_INDIVIDUAL_VARIANCE);E<u&&(u=E,f=x)}if(f>=0&&e.isRange(Math.max(0,i-(c-i)/2),i,!1))return Int32Array.from([i,c,f]);i+=s[0]+s[1],s=s.slice(2,s.length-1),s[n-1]=0,s[n]=0,n--}else n++;s[n]=1,a=!a}throw new B}static decodeCode(e,t,r){Xe.recordPattern(e,r,t);let n=V.MAX_AVG_VARIANCE,s=-1;for(let i=0;i<V.CODE_PATTERNS.length;i++){const a=V.CODE_PATTERNS[i],o=this.patternMatchVariance(t,a,V.MAX_INDIVIDUAL_VARIANCE);o<n&&(n=o,s=i)}if(s>=0)return s;throw new B}decodeRow(e,t,r){const n=r&&r.get(K.ASSUME_GS1)===!0,s=V.findStartPattern(t),i=s[2];let a=0;const o=new Uint8Array(20);o[a++]=i;let c;switch(i){case V.CODE_START_A:c=V.CODE_CODE_A;break;case V.CODE_START_B:c=V.CODE_CODE_B;break;case V.CODE_START_C:c=V.CODE_CODE_C;break;default:throw new P}let u=!1,f=!1,x="",E=s[0],I=s[1];const y=Int32Array.from([0,0,0,0,0,0]);let N=0,O=0,U=i,j=0,k=!0,ge=!1,he=!1;for(;!u;){const fr=f;switch(f=!1,N=O,O=V.decodeCode(t,y,I),o[a++]=O,O!==V.CODE_STOP&&(k=!0),O!==V.CODE_STOP&&(j++,U+=j*O),E=I,I+=y.reduce((zs,Zs)=>zs+Zs,0),O){case V.CODE_START_A:case V.CODE_START_B:case V.CODE_START_C:throw new P}switch(c){case V.CODE_CODE_A:if(O<64)he===ge?x+=String.fromCharCode(32+O):x+=String.fromCharCode(32+O+128),he=!1;else if(O<96)he===ge?x+=String.fromCharCode(O-64):x+=String.fromCharCode(O+64),he=!1;else switch(O!==V.CODE_STOP&&(k=!1),O){case V.CODE_FNC_1:n&&(x.length===0?x+="]C1":x+="�");break;case V.CODE_FNC_2:case V.CODE_FNC_3:break;case V.CODE_FNC_4_A:!ge&&he?(ge=!0,he=!1):ge&&he?(ge=!1,he=!1):he=!0;break;case V.CODE_SHIFT:f=!0,c=V.CODE_CODE_B;break;case V.CODE_CODE_B:c=V.CODE_CODE_B;break;case V.CODE_CODE_C:c=V.CODE_CODE_C;break;case V.CODE_STOP:u=!0;break}break;case V.CODE_CODE_B:if(O<96)he===ge?x+=String.fromCharCode(32+O):x+=String.fromCharCode(32+O+128),he=!1;else switch(O!==V.CODE_STOP&&(k=!1),O){case V.CODE_FNC_1:n&&(x.length===0?x+="]C1":x+="�");break;case V.CODE_FNC_2:case V.CODE_FNC_3:break;case V.CODE_FNC_4_B:!ge&&he?(ge=!0,he=!1):ge&&he?(ge=!1,he=!1):he=!0;break;case V.CODE_SHIFT:f=!0,c=V.CODE_CODE_A;break;case V.CODE_CODE_A:c=V.CODE_CODE_A;break;case V.CODE_CODE_C:c=V.CODE_CODE_C;break;case V.CODE_STOP:u=!0;break}break;case V.CODE_CODE_C:if(O<100)O<10&&(x+="0"),x+=O;else switch(O!==V.CODE_STOP&&(k=!1),O){case V.CODE_FNC_1:n&&(x.length===0?x+="]C1":x+="�");break;case V.CODE_CODE_A:c=V.CODE_CODE_A;break;case V.CODE_CODE_B:c=V.CODE_CODE_B;break;case V.CODE_STOP:u=!0;break}break}fr&&(c=c===V.CODE_CODE_A?V.CODE_CODE_B:V.CODE_CODE_A)}const xt=I-E;if(I=t.getNextUnset(I),!t.isRange(I,Math.min(t.getSize(),I+(I-E)/2),!1))throw new B;if(U-=j*N,U%103!==N)throw new J;const _t=x.length;if(_t===0)throw new B;_t>0&&k&&(c===V.CODE_CODE_C?x=x.substring(0,_t-2):x=x.substring(0,_t-1));const gt=(s[1]+s[0])/2,_e=E+xt/2,nt=o.length,mt=new Uint8Array(nt);for(let fr=0;fr<nt;fr++)mt[fr]=o[fr];const dr=[new Z(gt,e),new Z(_e,e)];return new Je(x,mt,0,dr,re.CODE_128,new Date().getTime())}}V.CODE_PATTERNS=[Int32Array.from([2,1,2,2,2,2]),Int32Array.from([2,2,2,1,2,2]),Int32Array.from([2,2,2,2,2,1]),Int32Array.from([1,2,1,2,2,3]),Int32Array.from([1,2,1,3,2,2]),Int32Array.from([1,3,1,2,2,2]),Int32Array.from([1,2,2,2,1,3]),Int32Array.from([1,2,2,3,1,2]),Int32Array.from([1,3,2,2,1,2]),Int32Array.from([2,2,1,2,1,3]),Int32Array.from([2,2,1,3,1,2]),Int32Array.from([2,3,1,2,1,2]),Int32Array.from([1,1,2,2,3,2]),Int32Array.from([1,2,2,1,3,2]),Int32Array.from([1,2,2,2,3,1]),Int32Array.from([1,1,3,2,2,2]),Int32Array.from([1,2,3,1,2,2]),Int32Array.from([1,2,3,2,2,1]),Int32Array.from([2,2,3,2,1,1]),Int32Array.from([2,2,1,1,3,2]),Int32Array.from([2,2,1,2,3,1]),Int32Array.from([2,1,3,2,1,2]),Int32Array.from([2,2,3,1,1,2]),Int32Array.from([3,1,2,1,3,1]),Int32Array.from([3,1,1,2,2,2]),Int32Array.from([3,2,1,1,2,2]),Int32Array.from([3,2,1,2,2,1]),Int32Array.from([3,1,2,2,1,2]),Int32Array.from([3,2,2,1,1,2]),Int32Array.from([3,2,2,2,1,1]),Int32Array.from([2,1,2,1,2,3]),Int32Array.from([2,1,2,3,2,1]),Int32Array.from([2,3,2,1,2,1]),Int32Array.from([1,1,1,3,2,3]),Int32Array.from([1,3,1,1,2,3]),Int32Array.from([1,3,1,3,2,1]),Int32Array.from([1,1,2,3,1,3]),Int32Array.from([1,3,2,1,1,3]),Int32Array.from([1,3,2,3,1,1]),Int32Array.from([2,1,1,3,1,3]),Int32Array.from([2,3,1,1,1,3]),Int32Array.from([2,3,1,3,1,1]),Int32Array.from([1,1,2,1,3,3]),Int32Array.from([1,1,2,3,3,1]),Int32Array.from([1,3,2,1,3,1]),Int32Array.from([1,1,3,1,2,3]),Int32Array.from([1,1,3,3,2,1]),Int32Array.from([1,3,3,1,2,1]),Int32Array.from([3,1,3,1,2,1]),Int32Array.from([2,1,1,3,3,1]),Int32Array.from([2,3,1,1,3,1]),Int32Array.from([2,1,3,1,1,3]),Int32Array.from([2,1,3,3,1,1]),Int32Array.from([2,1,3,1,3,1]),Int32Array.from([3,1,1,1,2,3]),Int32Array.from([3,1,1,3,2,1]),Int32Array.from([3,3,1,1,2,1]),Int32Array.from([3,1,2,1,1,3]),Int32Array.from([3,1,2,3,1,1]),Int32Array.from([3,3,2,1,1,1]),Int32Array.from([3,1,4,1,1,1]),Int32Array.from([2,2,1,4,1,1]),Int32Array.from([4,3,1,1,1,1]),Int32Array.from([1,1,1,2,2,4]),Int32Array.from([1,1,1,4,2,2]),Int32Array.from([1,2,1,1,2,4]),Int32Array.from([1,2,1,4,2,1]),Int32Array.from([1,4,1,1,2,2]),Int32Array.from([1,4,1,2,2,1]),Int32Array.from([1,1,2,2,1,4]),Int32Array.from([1,1,2,4,1,2]),Int32Array.from([1,2,2,1,1,4]),Int32Array.from([1,2,2,4,1,1]),Int32Array.from([1,4,2,1,1,2]),Int32Array.from([1,4,2,2,1,1]),Int32Array.from([2,4,1,2,1,1]),Int32Array.from([2,2,1,1,1,4]),Int32Array.from([4,1,3,1,1,1]),Int32Array.from([2,4,1,1,1,2]),Int32Array.from([1,3,4,1,1,1]),Int32Array.from([1,1,1,2,4,2]),Int32Array.from([1,2,1,1,4,2]),Int32Array.from([1,2,1,2,4,1]),Int32Array.from([1,1,4,2,1,2]),Int32Array.from([1,2,4,1,1,2]),Int32Array.from([1,2,4,2,1,1]),Int32Array.from([4,1,1,2,1,2]),Int32Array.from([4,2,1,1,1,2]),Int32Array.from([4,2,1,2,1,1]),Int32Array.from([2,1,2,1,4,1]),Int32Array.from([2,1,4,1,2,1]),Int32Array.from([4,1,2,1,2,1]),Int32Array.from([1,1,1,1,4,3]),Int32Array.from([1,1,1,3,4,1]),Int32Array.from([1,3,1,1,4,1]),Int32Array.from([1,1,4,1,1,3]),Int32Array.from([1,1,4,3,1,1]),Int32Array.from([4,1,1,1,1,3]),Int32Array.from([4,1,1,3,1,1]),Int32Array.from([1,1,3,1,4,1]),Int32Array.from([1,1,4,1,3,1]),Int32Array.from([3,1,1,1,4,1]),Int32Array.from([4,1,1,1,3,1]),Int32Array.from([2,1,1,4,1,2]),Int32Array.from([2,1,1,2,1,4]),Int32Array.from([2,1,1,2,3,2]),Int32Array.from([2,3,3,1,1,1,2])],V.MAX_AVG_VARIANCE=.25,V.MAX_INDIVIDUAL_VARIA
41NCE=.7,V.CODE_SHIFT=98,V.CODE_CODE_C=99,V.CODE_CODE_B=100,V.CODE_CODE_A=101,V.CODE_FNC_1=102,V.CODE_FNC_2=97,V.CODE_FNC_3=96,V.CODE_FNC_4_A=101,V.CODE_FNC_4_B=100,V.CODE_START_A=103,V.CODE_START_B=104,V.CODE_START_C=105,V.CODE_STOP=106;class Ye extends Xe{constructor(e=!1,t=!1){super(),this.usingCheckDigit=e,this.extendedMode=t,this.decodeRowResult="",this.counters=new Int32Array(9)}decodeRow(e,t,r){let n=this.counters;n.fill(0),this.decodeRowResult="";let s=Ye.findAsteriskPattern(t,n),i=t.getNextSet(s[1]),a=t.getSize(),o,c;do{Ye.recordPattern(t,i,n);let y=Ye.toNarrowWidePattern(n);if(y<0)throw new B;o=Ye.patternToChar(y),this.decodeRowResult+=o,c=i;for(let N of n)i+=N;i=t.getNextSet(i)}while(o!=="*");this.decodeRowResult=this.decodeRowResult.substring(0,this.decodeRowResult.length-1);let u=0;for(let y of n)u+=y;let f=i-c-u;if(i!==a&&f*2<u)throw new B;if(this.usingCheckDigit){let y=this.decodeRowResult.length-1,N=0;for(let O=0;O<y;O++)N+=Ye.ALPHABET_STRING.indexOf(this.decodeRowResult.charAt(O));if(this.decodeRowResult.charAt(y)!==Ye.ALPHABET_STRING.charAt(N%43))throw new J;this.decodeRowResult=this.decodeRowResult.substring(0,y)}if(this.decodeRowResult.length===0)throw new B;let x;this.extendedMode?x=Ye.decodeExtended(this.decodeRowResult):x=this.decodeRowResult;let E=(s[1]+s[0])/2,I=c+u/2;return new Je(x,null,0,[new Z(E,e),new Z(I,e)],re.CODE_39,new Date().getTime())}static findAsteriskPattern(e,t){let r=e.getSize(),n=e.getNextSet(0),s=0,i=n,a=!1,o=t.length;for(let c=n;c<r;c++)if(e.get(c)!==a)t[s]++;else{if(s===o-1){if(this.toNarrowWidePattern(t)===Ye.ASTERISK_ENCODING&&e.isRange(Math.max(0,i-Math.floor((c-i)/2)),i,!1))return[i,c];i+=t[0]+t[1],t.copyWithin(0,2,2+s-1),t[s-1]=0,t[s]=0,s--}else s++;t[s]=1,a=!a}throw new B}static toNarrowWidePattern(e){let t=e.length,r=0,n;do{let s=2147483647;for(let o of e)o<s&&o>r&&(s=o);r=s,n=0;let i=0,a=0;for(let o=0;o<t;o++){let c=e[o];c>r&&(a|=1<<t-1-o,n++,i+=c)}if(n===3){for(let o=0;o<t&&n>0;o++){let c=e[o];if(c>r&&(n--,c*2>=i))return-1}return a}}while(n>3);return-1}static patternToChar(e){for(let t=0;t<Ye.CHARACTER_ENCODINGS.length;t++)if(Ye.CHARACTER_ENCODINGS[t]===e)return Ye.ALPHABET_STRING.charAt(t);if(e===Ye.ASTERISK_ENCODING)return"*";throw new B}static decodeExtended(e){let t=e.length,r="";for(let n=0;n<t;n++){let s=e.charAt(n);if(s==="+"||s==="$"||s==="%"||s==="/"){let i=e.charAt(n+1),a="\0";switch(s){case"+":if(i>="A"&&i<="Z")a=String.fromCharCode(i.charCodeAt(0)+32);else throw new P;break;case"$":if(i>="A"&&i<="Z")a=String.fromCharCode(i.charCodeAt(0)-64);else throw new P;break;case"%":if(i>="A"&&i<="E")a=String.fromCharCode(i.charCodeAt(0)-38);else if(i>="F"&&i<="J")a=String.fromCharCode(i.charCodeAt(0)-11);else if(i>="K"&&i<="O")a=String.fromCharCode(i.charCodeAt(0)+16);else if(i>="P"&&i<="T")a=String.fromCharCode(i.charCodeAt(0)+43);else if(i==="U")a="\0";else if(i==="V")a="@";else if(i==="W")a="`";else if(i==="X"||i==="Y"||i==="Z")a="�";else throw new P;break;case"/":if(i>="A"&&i<="O")a=String.fromCharCode(i.charCodeAt(0)-32);else if(i==="Z")a=":";else throw new P;break}r+=a,n++}else r+=s}return r}}Ye.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",Ye.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],Ye.ASTERISK_ENCODING=148;class Ne extends Xe{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,t,r){let n=this.decodeStart(t),s=this.decodeEnd(t),i=new pe;Ne.decodeMiddle(t,n[1],s[0],i);let a=i.toString(),o=null;r!=null&&(o=r.get(K.ALLOWED_LENGTHS)),o==null&&(o=Ne.DEFAULT_ALLOWED_LENGTHS);let c=a.length,u=!1,f=0;for(let I of o){if(c===I){u=!0;break}I>f&&(f=I)}if(!u&&c>f&&(u=!0),!u)throw new P;const x=[new Z(n[1],e),new Z(s[0],e)];return new Je(a,null,0,x,re.ITF,new Date().getTime())}static decodeMiddle(e,t,r,n){let s=new Int32Array(10),i=new Int32Array(5),a=new Int32Array(5);for(s.fill(0),i.fill(0),a.fill(0);t<r;){Xe.recordPattern(e,t,s);for(let c=0;c<5;c++){let u=2*c;i[c]=s[u],a[c]=s[u+1]}let o=Ne.decodeDigit(i);n.append(o.toString()),o=this.decodeDigit(a),n.append(o.toString()),s.forEac
vendor: 5,185 bytes, line 41
41h(function(c){t+=c})}}decodeStart(e){let t=Ne.skipWhiteSpace(e),r=Ne.findGuardPattern(e,t,Ne.START_PATTERN);return this.narrowLineWidth=(r[1]-r[0])/4,this.validateQuietZone(e,r[0]),r}validateQuietZone(e,t){let r=this.narrowLineWidth*10;r=r<t?r:t;for(let n=t-1;r>0&&n>=0&&!e.get(n);n--)r--;if(r!==0)throw new B}static skipWhiteSpace(e){const t=e.getSize(),r=e.getNextSet(0);if(r===t)throw new B;return r}decodeEnd(e){e.reverse();try{let t=Ne.skipWhiteSpace(e),r;try{r=Ne.findGuardPattern(e,t,Ne.END_PATTERN_REVERSED[0])}catch(s){s instanceof B&&(r=Ne.findGuardPattern(e,t,Ne.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,r[0]);let n=r[0];return r[0]=e.getSize()-r[1],r[1]=e.getSize()-n,r}finally{e.reverse()}}static findGuardPattern(e,t,r){let n=r.length,s=new Int32Array(n),i=e.getSize(),a=!1,o=0,c=t;s.fill(0);for(let u=t;u<i;u++)if(e.get(u)!==a)s[o]++;else{if(o===n-1){if(Xe.patternMatchVariance(s,r,Ne.MAX_INDIVIDUAL_VARIANCE)<Ne.MAX_AVG_VARIANCE)return[c,u];c+=s[0]+s[1],G.arraycopy(s,2,s,0,o-1),s[o-1]=0,s[o]=0,o--}else o++;s[o]=1,a=!a}throw new B}static decodeDigit(e){let t=Ne.MAX_AVG_VARIANCE,r=-1,n=Ne.PATTERNS.length;for(let s=0;s<n;s++){let i=Ne.PATTERNS[s],a=Xe.patternMatchVariance(e,i,Ne.MAX_INDIVIDUAL_VARIANCE);a<t?(t=a,r=s):a===t&&(r=-1)}if(r>=0)return r%10;throw new B}}Ne.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])],Ne.MAX_AVG_VARIANCE=.38,Ne.MAX_INDIVIDUAL_VARIANCE=.5,Ne.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],Ne.START_PATTERN=Int32Array.from([1,1,1,1]),Ne.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Fe extends Xe{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let t=!1,r,n=0,s=Int32Array.from([0,0,0]);for(;!t;){s=Int32Array.from([0,0,0]),r=Fe.findGuardPattern(e,n,!1,this.START_END_PATTERN,s);let i=r[0];n=r[1];let a=i-(n-i);a>=0&&(t=e.isRange(a,i,!1))}return r}static checkChecksum(e){return Fe.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let r=parseInt(e.charAt(t-1),10);return Fe.getStandardUPCEANChecksum(e.substring(0,t-1))===r}static getStandardUPCEANChecksum(e){let t=e.length,r=0;for(let n=t-1;n>=0;n-=2){let s=e.charAt(n).charCodeAt(0)-48;if(s<0||s>9)throw new P;r+=s}r*=3;for(let n=t-2;n>=0;n-=2){let s=e.charAt(n).charCodeAt(0)-48;if(s<0||s>9)throw new P;r+=s}return(1e3-r)%10}static decodeEnd(e,t){return Fe.findGuardPattern(e,t,!1,Fe.START_END_PATTERN,new Int32Array(Fe.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,t,r,n){return this.findGuardPattern(e,t,r,n,new Int32Array(n.length))}static findGuardPattern(e,t,r,n,s){let i=e.getSize();t=r?e.getNextUnset(t):e.getNextSet(t);let a=0,o=t,c=n.length,u=r;for(let f=t;f<i;f++)if(e.get(f)!==u)s[a]++;else{if(a===c-1){if(Xe.patternMatchVariance(s,n,Fe.MAX_INDIVIDUAL_VARIANCE)<Fe.MAX_AVG_VARIANCE)return Int32Array.from([o,f]);o+=s[0]+s[1];let x=s.slice(2,s.length-1);for(let E=0;E<a-1;E++)s[E]=x[E];s[a-1]=0,s[a]=0,a--}else a++;s[a]=1,u=!u}throw new B}static decodeDigit(e,t,r,n){this.recordPattern(e,r,t);let s=this.MAX_AVG_VARIANCE,i=-1,a=n.length;for(let o=0;o<a;o++){let c=n[o],u=Xe.patternMatchVariance(t,c,Fe.MAX_INDIVIDUAL_VARIANCE);u<s&&(s=u,i=o)}if(i>=0)return i;throw new B}}Fe.MAX_AVG_VARIANCE=.48,Fe.MAX_INDIVIDUAL_VARIANCE=.7,Fe.START_END_PATTERN=Int32Array.from([1,1,1]),Fe.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Fe.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Fe.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 Ar{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,r){let n=this.decodeRowStringBuffer,s=this.decodeMiddle(t,r,n),i=n.toString(),a=Ar.parseExtensionString(i),o=[new Z((r[0]+r[1])/2,e),new Z(s,e)],c=new Je(i,null,0,o,re.UPC_EAN_EXTENSION,new Date().getTime());return a!=null&&c.putAllMetadata(a),c}decodeMiddle(e,t,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let s=e.getSize(),i=t[1],a=0;for(let c=0;c<5&&i<s;c++){let u=Fe.decodeDigit(e,n,i,Fe.L_AND_G_PATTERNS);r+=String.fromCharCode(48+u%10);for(let f of n)i+=f;u>=10&&(a|=1<<4-c),c!==4&&(i=e.getNextSet(i),i=e.getNextUnset(i))}if(r.length!==5)throw new B;let o=this.determineCheckDigit(a);if(Ar.extensionChecksum(r.toString())!==o)throw new B;return i}static extensionChecksum(e){let t=e.length,r=0;for(let n=t-2;n>=0;
41n-=2)r+=e.charAt(n).charCodeAt(0)-48;r*=3;for(let n=t-1;n>=0;n-=2)r+=e.charAt(n).charCodeAt(0)-48;return r*=3,r%10}determineCheckDigit(e){for(let t=0;t<10;t++)if(e===this.CHECK_DIGIT_ENCODINGS[t])return t;throw new B}static parseExtensionString(e){if(e.length!==5)return null;let t=Ar.parseExtension5String(e);return t==null?null:new Map([[Ge.SUGGESTED_PRICE,t]])}static parseExtension5String(e){let t;switch(e.charAt(0)){case"0":t="£";break;case"5":t="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}t="";break;default:t="";break}let r=parseInt(e.substring(1)),n=(r/100).toString(),s=r%100,i=s<10?"0"+s:s.toString();return t+n+"."+i}}class zr{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,r){let n=this.decodeRowStringBuffer,s=this.decodeMiddle(t,r,n),i=n.toString(),a=zr.parseExtensionString(i),o=[new Z((r[0]+r[1])/2,e),new Z(s,e)],c=new Je(i,null,0,o,re.UPC_EAN_EXTENSION,new Date().getTime());return a!=null&&c.putAllMetadata(a),c}decodeMiddle(e,t,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let s=e.getSize(),i=t[1],a=0;for(let o=0;o<2&&i<s;o++){let c=Fe.decodeDigit(e,n,i,Fe.L_AND_G_PATTERNS);r+=String.fromCharCode(48+c%10);for(let u of n)i+=u;c>=10&&(a|=1<<1-o),o!==1&&(i=e.getNextSet(i),i=e.getNextUnset(i))}if(r.length!==2)throw new B;if(parseInt(r.toString())%4!==a)throw new B;return i}static parseExtensionString(e){return e.length!==2?null:new Map([[Ge.ISSUE_NUMBER,parseInt(e)]])}}class yn{static decodeRow(e,t,r){let n=Fe.findGuardPattern(t,r,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new Ar().decodeRow(e,t,n)}catch{return new zr().decodeRow(e,t,n)}}}yn.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Ce extends Fe{constructor(){super(),this.decodeRowStringBuffer="",Ce.L_AND_G_PATTERNS=Ce.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let t=Ce.L_PATTERNS[e-10],r=new Int32Array(t.length);for(let n=0;n<t.length;n++)r[n]=t[t.length-n-1];Ce.L_AND_G_PATTERNS[e]=r}}decodeRow(e,t,r){let n=Ce.findStartGuardPattern(t),s=r==null?null:r.get(K.NEED_RESULT_POINT_CALLBACK);if(s!=null){const k=new Z((n[0]+n[1])/2,e);s.foundPossibleResultPoint(k)}let i=this.decodeMiddle(t,n,this.decodeRowStringBuffer),a=i.rowOffset,o=i.resultString;if(s!=null){const k=new Z(a,e);s.foundPossibleResultPoint(k)}let c=this.decodeEnd(t,a);if(s!=null){const k=new Z((c[0]+c[1])/2,e);s.foundPossibleResultPoint(k)}let u=c[1],f=u+(u-c[0]);if(f>=t.getSize()||!t.isRange(u,f,!1))throw new B;let x=o.toString();if(x.length<8)throw new P;if(!Ce.checkChecksum(x))throw new J;let E=(n[1]+n[0])/2,I=(c[1]+c[0])/2,y=this.getBarcodeFormat(),N=[new Z(E,e),new Z(I,e)],O=new Je(x,null,0,N,y,new Date().getTime()),U=0;try{let k=yn.decodeRow(e,t,c[1]);O.putMetadata(Ge.UPC_EAN_EXTENSION,k.getText()),O.putAllMetadata(k.getResultMetadata()),O.addResultPoints(k.getResultPoints()),U=k.getText().length}catch{}let j=r==null?null:r.get(K.ALLOWED_EAN_EXTENSIONS);if(j!=null){let k=!1;for(let ge in j)if(U.toString()===ge){k=!0;break}if(!k)throw new B}return O}decodeEnd(e,t){return Ce.findGuardPattern(e,t,!1,Ce.START_END_PATTERN,new Int32Array(Ce.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return Ce.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let r=parseInt(e.charAt(t-1),10);return Ce.getStandardUPCEANChecksum(e.substring(0,t-1))===r}static getStandardUPCEANChecksum(e){let t=e.length,r=0;for(let n=t-1;n>=0;n-=2){let s=e.charAt(n).charCodeAt(0)-48;if(s<0||s>9)throw new P;r+=s}r*=3;for(let n=t-2;n>=0;n-=2){let s=e.charAt(n).charCodeAt(0)-48;if(s<0||s>9)throw new P;r+=s}return(1e3-r)%10}}class Qt extends Ce{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,r){let n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let s=e.getSize(),i=t[1],a=0;for(let c=0;c<6&&i<s;c++){let u=Ce.decodeDigit(e,n,i,Ce.L_AND_G_PATTERNS);r+=String.fromCharCode(48+u%10);for(let f of n)i+=f;u>=10&&(a|=1<<5-c)}r=Qt.determineFirstDigit(r,a),i=Ce.findGuardPattern(e,i,!0,Ce.MIDDLE_PATTERN,new Int32Array(Ce.MIDDLE_PATTERN.length).fill(0))[1];for(let c=0;c<6&&i<s;c++){let u=Ce.decodeDigit(e,n,i,Ce.L_PATTERNS);r+=String.fromCharCode(48+u);for(let f of n)i+=f}return{rowOffset:i,resultString:r}}getBarcodeFormat(){return re.EAN_13}static determineFirstDigit(e,t){for(let r=0;r<10;r++)if(t===this.FIRST_DIGIT_ENCODINGS[r])return e=String.fromCharCode(48+r)+e,e;throw new B}}Qt.FIRST_DIGIT_ENCODINGS=[0,11,13,14,19,25,28,21,22,26];class Sn extends Ce{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,r){const n=this.decodeMiddleCounters;n[0]=0,n[1]=0,n[2]=0,n[3]=0;let s=e.getSize(),i=t[1];for(let o=0;o<4&&i<s;o++){let c=Ce.decodeDigit(e,n,i,Ce.L_PATTERNS);r+=String.fromCharCode(48+c);for(let u of n)i+=u}i=Ce.findGuardPattern(e,i,!0,Ce.MIDDLE_PATTERN,new Int32Array(Ce.MIDDLE_PATTERN.length).fill(0))[1];for(let o=0;o<4&&i<s;o++){let c=Ce.decodeDigit(e,n,i,Ce.L_PATTERNS);r+=String.fromCharCode(48+c);for(let u of n)i+=u}return{rowOffset:i,resultString:r}}getBarcodeFormat(){return re.EAN_8}}class Nn extends Ce{constructor(){super(...arguments),this.ean13Reader=new Qt}getBarcodeFormat(){return re.UPC_A}decode(e,t){return this.maybeReturnResult(this.ean13Reader.decode(e))}decodeRow(e,t,r){return this.maybeReturnResult(this.ean13Reader.decodeRow(e,t,r))}decodeMiddle(e,t,r){return this.ean13Reader.decodeMiddle(e,t,r)}maybeReturnResult(e){let t=e.getText();if(t.charAt(0)==="0"){let r=new Je(t.substring(1),null,null,e.getResultPoints(),re.UPC_A);return e.getResultMetadata()!=null&&r.putAllMetadata(e.getResultMetadata()),r}else throw new B}reset(){this.ean13Reader.reset()}}class Tt extends Ce{constructor(){super(),this.decodeMiddleCounters=new Int32Array(4)}decodeMiddle(e,t,r){const n=this.decodeMiddleCounters.map(c=>c);n[0]=0,n[1]=0,n[2]=0,n[3]=0;const s=e.getSize();let i=t[1],a=0;for(let c=0;c<6&&i<s;c++){const u=Tt.decodeDigit(e,n,i,Tt.L_AND_G_PATTERNS);r+=String.fromCharCode(48+u%10);for(let f of n)i+=f;u>=10&&(a|=1<<5-c)}let o=Tt.determineNumSysAndCheckDigit(r,a);return{rowOffset:i,resultString:o}}decodeEnd(e,t){return Tt.findGuardPatternWithoutCounters(e,t,!0,Tt.MIDDLE_END_PATTERN)}checkChecksum(e){return Ce.checkChecksum(Tt.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,t){for(let r=0;r<=1;r++)for(let n=0;n<10;n++)if(t===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[r][n]){let s=String.fromCharCode(48+r),i=String.fromCharCode(48+n);return s+e+i}throw B.getNotFoundInstance()}getBarcodeFormat(){return re.UPC_E}static convertUPCEtoUPCA(e){const t=e.slice(1,7).split("").map(s=>s.charCodeAt(0)),r=new pe;r.append(e.charAt(0));let n=t[5];switch(n){case 0:case 1:case 2:r.appendChars(t,0,2),r.append(n),r.append("0000"),r.appendChars(t,2,3);break;case 3:r.appendChars(t,0,3),r.append("00000"),r.appendChars(t,3,2);break;
vendor: 6,230 bytes, line 41
41case 4:r.appendChars(t,0,4),r.append("00000"),r.append(t[4]);break;default:r.appendChars(t,0,5),r.append("0000"),r.append(n);break}return e.length>=8&&r.append(e.charAt(7)),r.toString()}}Tt.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Tt.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 Zr extends Xe{constructor(e){super();let t=e==null?null:e.get(K.POSSIBLE_FORMATS),r=[];w(t)?(r.push(new Qt),r.push(new Nn),r.push(new Sn),r.push(new Tt)):(t.indexOf(re.EAN_13)>-1&&r.push(new Qt),t.indexOf(re.UPC_A)>-1&&r.push(new Nn),t.indexOf(re.EAN_8)>-1&&r.push(new Sn),t.indexOf(re.UPC_E)>-1&&r.push(new Tt)),this.readers=r}decodeRow(e,t,r){for(let n of this.readers)try{const s=n.decodeRow(e,t,r),i=s.getBarcodeFormat()===re.EAN_13&&s.getText().charAt(0)==="0",a=r==null?null:r.get(K.POSSIBLE_FORMATS),o=a==null||a.includes(re.UPC_A);if(i&&o){const c=s.getRawBytes(),u=new Je(s.getText().substring(1),c,c?c.length:null,s.getResultPoints(),re.UPC_A);return u.putAllMetadata(s.getResultMetadata()),u}return s}catch{}throw new B}reset(){for(let e of this.readers)e.reset()}}class it extends Xe{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,t){for(let r=0;r<t.length;r++)if(Xe.patternMatchVariance(e,t[r],it.MAX_INDIVIDUAL_VARIANCE)<it.MAX_AVG_VARIANCE)return r;throw new B}static count(e){return we.sum(new Int32Array(e))}static increment(e,t){let r=0,n=t[0];for(let s=1;s<e.length;s++)t[s]>n&&(n=t[s],r=s);e[r]++}static decrement(e,t){let r=0,n=t[0];for(let s=1;s<e.length;s++)t[s]<n&&(n=t[s],r=s);e[r]--}static isFinderPattern(e){let t=e[0]+e[1],r=t+e[2]+e[3],n=t/r;if(n>=it.MIN_FINDER_PATTERN_RATIO&&n<=it.MAX_FINDER_PATTERN_RATIO){let s=Number.MAX_SAFE_INTEGER,i=Number.MIN_SAFE_INTEGER;for(let a of e)a>i&&(i=a),a<s&&(s=a);return i<10*s}return!1}}it.MAX_AVG_VARIANCE=.2,it.MAX_INDIVIDUAL_VARIANCE=.45,it.MIN_FINDER_PATTERN_RATIO=9.5/12,it.MAX_FINDER_PATTERN_RATIO=12.5/14;class ir{constructor(e,t){this.value=e,this.checksumPortion=t}getValue(){return this.value}getChecksumPortion(){return this.checksumPortion}toString(){return this.value+"("+this.checksumPortion+")"}equals(e){if(!(e instanceof ir))return!1;const t=e;return this.value===t.value&&this.checksumPortion===t.checksumPortion}hashCode(){return this.value^this.checksumPortion}}class Mr{constructor(e,t,r,n,s){this.value=e,this.startEnd=t,this.value=e,this.startEnd=t,this.resultPoints=new Array,this.resultPoints.push(new Z(r,s)),this.resultPoints.push(new Z(n,s))}getValue(){return this.value}getStartEnd(){return this.startEnd}getResultPoints(){return this.resultPoints}equals(e){if(!(e instanceof Mr))return!1;const t=e;return this.value===t.value}hashCode(){return this.value}}class Dt{constructor(){}static getRSSvalue(e,t,r){let n=0;for(let o of e)n+=o;let s=0,i=0,a=e.length;for(let o=0;o<a-1;o++){let c;for(c=1,i|=1<<o;c<e[o];c++,i&=~(1<<o)){let u=Dt.combins(n-c-1,a-o-2);if(r&&i===0&&n-c-(a-o-1)>=a-o-1&&(u-=Dt.combins(n-c-(a-o),a-o-2)),a-o-1>1){let f=0;for(let x=n-c-(a-o-2);x>t;x--)f+=Dt.combins(n-c-x-1,a-o-3);u-=f*(a-1-o)}else n-c>t&&u--;s+=u}n-=c}return s}static combins(e,t){let r,n;e-t>t?(n=t,r=e-t):(n=e-t,r=t);let s=1,i=1;for(let a=e;a>r;a--)s*=a,i<=n&&(s/=i,i++);for(;i<=n;)s/=i,i++;return s}}class ps{static buildBitArray(e){let t=e.length*2-1;e[e.length-1].getRightChar()==null&&(t-=1);let r=12*t,n=new ce(r),s=0,a=e[0].getRightChar().getValue();for(let o=11;o>=0;--o)a&1<<o&&n.set(s),s++;for(let o=1;o<e.length;++o){let c=e[o],u=c.getLeftChar().getValue();for(let f=11;f>=0;--f)u&1<<f&&n.set(s),s++;if(c.getRightChar()!=null){let f=c.getRightChar().getValue();for(let x=11;x>=0;--x)f&1<<x&&n.set(s),s++}}return n}}class qt{constructor(e,t){t?this.decodedInformation=null:(this.finished=e,this.decodedInformation=t)}getDecodedInformation(){return this.decodedInformation}isFinished(){return this.finished}}class Kr{constructor(e){this.newPosition=e}getNewPosition(){return this.newPosition}}class ht extends Kr{constructor(e,t){super(e),this.value=t}getValue(){return this.value}isFNC1(){return this.value===ht.FNC1}}ht.FNC1="$";class Jt extends Kr{constructor(e,t,r){super(e),r?(this.remaining=!0,this.remainingValue=this.remainingValue):(this.remaining=!1,this.remainingValue=0),this.newString=t}getNewString(){return this.newString}isRemaining(){return this.remaining}getRemainingValue(){return this.remainingValue}}class Ct extends Kr{constructor(e,t,r){if(super(e),t<0||t>10||r<0||r>10)throw new P;this.firstDigit=t,this.secondDigit=r}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===Ct.FNC1}isSecondDigitFNC1(){return this.secondDigit===Ct.FNC1}isAnyFNC1(){return this.firstDigit===Ct.FNC1||this.secondDigit===Ct.FNC1}}Ct.FNC1=10;class X{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new B;let t=e.substring(0,2);for(let s of X.TWO_DIGIT_DATA_LENGTH)if(s[0]===t)return s[1]===X.VARIABLE_LENGTH?X.processVariableAI(2,s[2],e):X.processFixedAI(2,s[1],e);if(e.length<3)throw new B;let r=e.substring(0,3);for(let s of X.THREE_DIGIT_DATA_LENGTH)if(s[0]===r)return s[1]===X.VARIABLE_LENGTH?X.processVariableAI(3,s[2],e):X.processFixedAI(3,s[1],e);for(let s of X.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(s[0]===r)return s[1]===X.VARIABLE_LENGTH?X.processVariableAI(4,s[2],e):X.processFixedAI(4,s[1],e);if(e.length<4)throw new B;let n=e.substring(0,4);for(let s of X.FOUR_DIGIT_DATA_LENGTH)if(s[0]===n)return s[1]===X.VARIABLE_LENGTH?X.processVariableAI(4,s[2],e):X.processFixedAI(4,s[1],e);throw new B}
41static processFixedAI(e,t,r){if(r.length<e)throw new B;let n=r.substring(0,e);if(r.length<e+t)throw new B;let s=r.substring(e,e+t),i=r.substring(e+t),a="("+n+")"+s,o=X.parseFieldsInGeneralPurpose(i);return o==null?a:a+o}static processVariableAI(e,t,r){let n=r.substring(0,e),s;r.length<e+t?s=r.length:s=e+t;let i=r.substring(e,s),a=r.substring(s),o="("+n+")"+i,c=X.parseFieldsInGeneralPurpose(a);return c==null?o:o+c}}X.VARIABLE_LENGTH=[],X.TWO_DIGIT_DATA_LENGTH=[["00",18],["01",14],["02",14],["10",X.VARIABLE_LENGTH,20],["11",6],["12",6],["13",6],["15",6],["17",6],["20",2],["21",X.VARIABLE_LENGTH,20],["22",X.VARIABLE_LENGTH,29],["30",X.VARIABLE_LENGTH,8],["37",X.VARIABLE_LENGTH,8],["90",X.VARIABLE_LENGTH,30],["91",X.VARIABLE_LENGTH,30],["92",X.VARIABLE_LENGTH,30],["93",X.VARIABLE_LENGTH,30],["94",X.VARIABLE_LENGTH,30],["95",X.VARIABLE_LENGTH,30],["96",X.VARIABLE_LENGTH,30],["97",X.VARIABLE_LENGTH,3],["98",X.VARIABLE_LENGTH,30],["99",X.VARIABLE_LENGTH,30]],X.THREE_DIGIT_DATA_LENGTH=[["240",X.VARIABLE_LENGTH,30],["241",X.VARIABLE_LENGTH,30],["242",X.VARIABLE_LENGTH,6],["250",X.VARIABLE_LENGTH,30],["251",X.VARIABLE_LENGTH,30],["253",X.VARIABLE_LENGTH,17],["254",X.VARIABLE_LENGTH,20],["400",X.VARIABLE_LENGTH,30],["401",X.VARIABLE_LENGTH,30],["402",17],["403",X.VARIABLE_LENGTH,30],["410",13],["411",13],["412",13],["413",13],["414",13],["420",X.VARIABLE_LENGTH,20],["421",X.VARIABLE_LENGTH,15],["422",3],["423",X.VARIABLE_LENGTH,15],["424",3],["425",3],["426",3]],X.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH=[["310",6],["311",6],["312",6],["313",6],["314",6],["315",6],["316",6],["320",6],["321",6],["322",6],["323",6],["324",6],["325",6],["326",6],["327",6],["328",6],["329",6],["330",6],["331",6],["332",6],["333",6],["334",6],["335",6],["336",6],["340",6],["341",6],["342",6],["343",6],["344",6],["345",6],["346",6],["347",6],["348",6],["349",6],["350",6],["351",6],["352",6],["353",6],["354",6],["355",6],["356",6],["357",6],["360",6],["361",6],["362",6],["363",6],["364",6],["365",6],["366",6],["367",6],["368",6],["369",6],["390",X.VARIABLE_LENGTH,15],["391",X.VARIABLE_LENGTH,18],["392",X.VARIABLE_LENGTH,15],["393",X.VARIABLE_LENGTH,18],["703",X.VARIABLE_LENGTH,30]],X.FOUR_DIGIT_DATA_LENGTH=[["7001",13],["7002",X.VARIABLE_LENGTH,30],["7003",10],["8001",14],["8002",X.VARIABLE_LENGTH,20],["8003",X.VARIABLE_LENGTH,30],["8004",X.VARIABLE_LENGTH,30],["8005",6],["8006",18],["8007",X.VARIABLE_LENGTH,30],["8008",X.VARIABLE_LENGTH,12],["8018",18],["8020",X.VARIABLE_LENGTH,25],["8100",6],["8101",10],["8102",2],["8110",X.VARIABLE_LENGTH,70],["8200",X.VARIABLE_LENGTH,70]];class ar{constructor(e){this.buffer=new pe,this.information=e}decodeAllCodes(e,t){let r=t,n=null;do{let s=this.decodeGeneralPurposeField(r,n),i=X.parseFieldsInGeneralPurpose(s.getNewString());if(i!=null&&e.append(i),s.isRemaining()?n=""+s.getRemainingValue():n=null,r===s.getNewPosition())break;r=s.getNewPosition()}while(!0);return e.toString()}isStillNumeric(e){if(e+7>this.information.getSize())return e+4<=this.information.getSize();for(let t=e;t<e+3;++t)if(this.information.get(t))return!0;return this.information.get(e+3)}decodeNumeric(e){if(e+7>this.information.getSize()){let s=this.extractNumericValueFromBitArray(e,4);return s===0?new Ct(this.information.getSize(),Ct.FNC1,Ct.FNC1):new Ct(this.information.getSize(),s-1,Ct.FNC1)}let t=this.extractNumericValueFromBitArray(e,7),r=(t-8)/11,n=(t-8)%11;return new Ct(e+7,r,n)}extractNumericValueFromBitArray(e,t){return ar.extractNumericValueFromBitArray(this.information,e,t)}static extractNumericValueFromBitArray(e,t,r){let n=0;for(let s=0;s<r;++s)e.get(t+s)&&(n|=1<<r-s-1);return n}decodeGeneralPurposeField(e,t){this.buffer.setLengthToZero(),t!=null&&this.buffer.append(t),this.current.setPosition(e);let r=this.parseBlocks();return r!=null&&r.isRemaining()?new Jt(this.current.getPosition(),this.buffer.toString(),r.getRemainingValue()):new Jt(this.current.getPosition(),this.buffer.toString())}parseBlocks(){let e,t;do{let r=this.current.getPosition();if(this.current.isAlpha()?(t=this.parseAlphaBlock(),e=t.isFinished()):this.current.isIsoIec646()?(t=this.parseIsoIec646Block(),e=t.is
41Finished()):(t=this.parseNumericBlock(),e=t.isFinished()),!(r!==this.current.getPosition())&&!e)break}while(!e);return t.getDecodedInformation()}parseNumericBlock(){for(;this.isStillNumeric(this.current.getPosition());){let e=this.decodeNumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFirstDigitFNC1()){let t;return e.isSecondDigitFNC1()?t=new Jt(this.current.getPosition(),this.buffer.toString()):t=new Jt(this.current.getPosition(),this.buffer.toString(),e.getSecondDigit()),new qt(!0,t)}if(this.buffer.append(e.getFirstDigit()),e.isSecondDigitFNC1()){let t=new Jt(this.current.getPosition(),this.buffer.toString());return new qt(!0,t)}this.buffer.append(e.getSecondDigit())}return this.isNumericToAlphaNumericLatch(this.current.getPosition())&&(this.current.setAlpha(),this.current.incrementPosition(4)),new qt(!1)}parseIsoIec646Block(){for(;this.isStillIsoIec646(this.current.getPosition());){let e=this.decodeIsoIec646(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let t=new Jt(this.current.getPosition(),this.buffer.toString());return new qt(!0,t)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setAlpha()),new qt(!1)}parseAlphaBlock(){for(;this.isStillAlpha(this.current.getPosition());){let e=this.decodeAlphanumeric(this.current.getPosition());if(this.current.setPosition(e.getNewPosition()),e.isFNC1()){let t=new Jt(this.current.getPosition(),this.buffer.toString());return new qt(!0,t)}this.buffer.append(e.getValue())}return this.isAlphaOr646ToNumericLatch(this.current.getPosition())?(this.current.incrementPosition(3),this.current.setNumeric()):this.isAlphaTo646ToAlphaLatch(this.current.getPosition())&&(this.current.getPosition()+5<this.information.getSize()?this.current.incrementPosition(5):this.current.setPosition(this.information.getSize()),this.current.setIsoIec646()),new qt(!1)}isStillIsoIec646(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+7>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,7);if(r>=64&&r<116)return!0;if(e+8>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,8);return n>=232&&n<253}decodeIsoIec646(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new ht(e+5,ht.FNC1);if(t>=5&&t<15)return new ht(e+5,"0"+(t-5));let r=this.extractNumericValueFromBitArray(e,7);if(r>=64&&r<90)return new ht(e+7,""+(r+1));if(r>=90&&r<116)return new ht(e+7,""+(r+7));let n=this.extractNumericValueFromBitArray(e,8),s;switch(n){case 232:s="!";break;case 233:s='"';break;case 234:s="%";break;case 235:s="&";break;case 236:s="'";break;case 237:s="(";break;case 238:s=")";break;case 239:s="*";break;case 240:s="+";break;case 241:s=",";break;case 242:s="-";break;case 243:s=".";break;case 244:s="/";break;case 245:s=":";break;case 246:s=";";break;case 247:s="<";break;case 248:s="=";break;case 249:s=">";break;case 250:s="?";break;case 251:s="_";break;case 252:s=" ";break;default:throw new P}return new ht(e+8,s)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+6>this.information.getSize())return!1;let r=this.extractNumericValueFromBitArray(e,6);return r>=16&&r<63}decodeAlphanumeric(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new ht(e+5,ht.FNC1);if(t>=5&&t<15)return new ht(e+5,"0"+(t-5));let r=this.extractNumericValueFromBitArray(e,6);if(r>=32&&r<58)return new ht(e+6,""+(r+33));let n;switch(r){case 58:n="*";break;case 59:n=",";break;case 60:n="-";break;case 61:n=".";break;case 62:n="/";break;default:throw new Ot("Decoding invalid alphanumeric value: "+r)}return new ht(e+6,n)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<5&&t+e<this.information.getSize();++t)if(t===2){if(!this.information.get(e+2))return!1}else if(this.information.get(e+t))return!1;return!0}isAlphaOr646ToNumericLatch(e){if(e+3>this.information.getSize())return!1;for(let t=e;t<e+3;++t)if(this.information.get(t))return!1;return!0}isNumericToAlphaNumericLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<4&&t+e<this.information.getSize();++t)if(this.information.get(e+t))return!1;return!0}}class Qr{constructor(e){this.information=e,this.generalDecoder=new ar(e)}getInformation(){return this.information}getGeneralDecoder(){return this.generalDecoder}}class dt extends Qr{constructor(e){super(e)}encodeCompressedGtin(e,t){e.append("(01)");let r=e.length();e.append("9"),this.encodeCompressedGtinWithoutAI(e,t,r)}encodeCompressedGtinWithoutAI(e,t,r){for(let n=0;n<4;++n){let s=this.getGeneralDecoder().extractNumericValueFromBitArray(t
vendor: 4,497 bytes, line 41
41+10*n,10);s/100===0&&e.append("0"),s/10===0&&e.append("0"),e.append(s)}dt.appendCheckDigit(e,r)}static appendCheckDigit(e,t){let r=0;for(let n=0;n<13;n++){let s=e.charAt(n+t).charCodeAt(0)-48;r+=n&1?s:3*s}r=10-r%10,r===10&&(r=0),e.append(r)}}dt.GTIN_SIZE=40;class or extends dt{constructor(e){super(e)}parseInformation(){let e=new pe;e.append("(01)");let t=e.length(),r=this.getGeneralDecoder().extractNumericValueFromBitArray(or.HEADER_SIZE,4);return e.append(r),this.encodeCompressedGtinWithoutAI(e,or.HEADER_SIZE+4,t),this.getGeneralDecoder().decodeAllCodes(e,or.HEADER_SIZE+44)}}or.HEADER_SIZE=4;class Br extends Qr{constructor(e){super(e)}parseInformation(){let e=new pe;return this.getGeneralDecoder().decodeAllCodes(e,Br.HEADER_SIZE)}}Br.HEADER_SIZE=5;class Pr extends dt{constructor(e){super(e)}encodeCompressedWeight(e,t,r){let n=this.getGeneralDecoder().extractNumericValueFromBitArray(t,r);this.addWeightCode(e,n);let s=this.checkWeight(n),i=1e5;for(let a=0;a<5;++a)s/i===0&&e.append("0"),i/=10;e.append(s)}}class vt extends Pr{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()!=vt.HEADER_SIZE+Pr.GTIN_SIZE+vt.WEIGHT_SIZE)throw new B;let e=new pe;return this.encodeCompressedGtin(e,vt.HEADER_SIZE),this.encodeCompressedWeight(e,vt.HEADER_SIZE+Pr.GTIN_SIZE,vt.WEIGHT_SIZE),e.toString()}}vt.HEADER_SIZE=5,vt.WEIGHT_SIZE=15;class Cs extends vt{constructor(e){super(e)}addWeightCode(e,t){e.append("(3103)")}checkWeight(e){return e}}class Es extends vt{constructor(e){super(e)}addWeightCode(e,t){t<1e4?e.append("(3202)"):e.append("(3203)")}checkWeight(e){return e<1e4?e:e-1e4}}class Mt extends dt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<Mt.HEADER_SIZE+dt.GTIN_SIZE)throw new B;let e=new pe;this.encodeCompressedGtin(e,Mt.HEADER_SIZE);let t=this.getGeneralDecoder().extractNumericValueFromBitArray(Mt.HEADER_SIZE+dt.GTIN_SIZE,Mt.LAST_DIGIT_SIZE);e.append("(392"),e.append(t),e.append(")");let r=this.getGeneralDecoder().decodeGeneralPurposeField(Mt.HEADER_SIZE+dt.GTIN_SIZE+Mt.LAST_DIGIT_SIZE,null);return e.append(r.getNewString()),e.toString()}}Mt.HEADER_SIZE=8,Mt.LAST_DIGIT_SIZE=2;class ct extends dt{constructor(e){super(e)}parseInformation(){if(this.getInformation().getSize()<ct.HEADER_SIZE+dt.GTIN_SIZE)throw new B;let e=new pe;this.encodeCompressedGtin(e,ct.HEADER_SIZE);let t=this.getGeneralDecoder().extractNumericValueFromBitArray(ct.HEADER_SIZE+dt.GTIN_SIZE,ct.LAST_DIGIT_SIZE);e.append("(393"),e.append(t),e.append(")");let r=this.getGeneralDecoder().extractNumericValueFromBitArray(ct.HEADER_SIZE+dt.GTIN_SIZE+ct.LAST_DIGIT_SIZE,ct.FIRST_THREE_DIGITS_SIZE);r/100==0&&e.append("0"),r/10==0&&e.append("0"),e.append(r);let n=this.getGeneralDecoder().decodeGeneralPurposeField(ct.HEADER_SIZE+dt.GTIN_SIZE+ct.LAST_DIGIT_SIZE+ct.FIRST_THREE_DIGITS_SIZE,null);return e.append(n.getNewString()),e.toString()}}ct.HEADER_SIZE=8,ct.LAST_DIGIT_SIZE=2,ct.FIRST_THREE_DIGITS_SIZE=10;class Be extends Pr{constructor(e,t,r){super(e),this.dateCode=r,this.firstAIdigits=t}parseInformation(){if(this.getInformation().getSize()!=Be.HEADER_SIZE+Be.GTIN_SIZE+Be.WEIGHT_SIZE+Be.DATE_SIZE)throw new B;let e=new pe;return this.encodeCompressedGtin(e,Be.HEADER_SIZE),this.encodeCompressedWeight(e,Be.HEADER_SIZE+Be.GTIN_SIZE,Be.WEIGHT_SIZE),this.encodeCompressedDate(e,Be.HEADER_SIZE+Be.GTIN_SIZE+Be.WEIGHT_SIZE),e.toString()}encodeCompressedDate(e,t){let r=this.getGeneralDecoder().extractNumericValueFromBitArray(t,Be.DATE_SIZE);if(r==38400)return;e.append("("),e.append(this.dateCode),e.append(")");let n=r%32;r/=32;let s=r%12+1;r/=12;let i=r;i/10==0&&e.append("0"),e.append(i),s/10==0&&e.append("0"),e.append(s),n/10==0&&e.append("0"),e.append(n)}addWeightCode(e,t){e.append("("),e.append(this.firstAIdigits),e.append(t/1e5),e.append(")")}checkWeight(e){return e%1e5}}Be.HEADER_SIZE=8,Be.WEIGHT_SIZE=20,Be.DATE_SIZE=16;function Tn(d){try{if(d.get(1))return new or(d);if(!d.get(2))return new Br(d);switch(ar.extractNumericValueFromBitArray(d,1,4)){case 4:return new Cs(d);case 5:return new Es(d)}switch(ar.extractNumericValueFromBitArray(d,1,5)){case 12:return new Mt(d);case 13:return new ct(d)}switch(ar.extractNumericValueFromBitArray(d,1,7)){case 56:return new Be(d,"310","11");case 57:return new Be(d,"320","11");case 58:return new Be(d,"310","13");case 59:return new Be(d,"320","13");case 60:return new Be(d,"310","15");case 61:return new Be(d,"320","15");case 62:return new Be(d,"310","17");case 63:return new Be(d,"320","17")}
41}catch(e){throw new Ot("unknown decoder: "+d)}}class Gt{constructor(e,t,r,n){this.leftchar=e,this.rightchar=t,this.finderpattern=r,this.maybeLast=n}mayBeLast(){return this.maybeLast}getLeftChar(){return this.leftchar}getRightChar(){return this.rightchar}getFinderPattern(){return this.finderpattern}mustBeLast(){return this.rightchar==null}toString(){return"[ "+this.leftchar+", "+this.rightchar+" : "+(this.finderpattern==null?"null":this.finderpattern.getValue())+" ]"}static equals(e,t){return e instanceof Gt?Gt.equalsOrNull(e.leftchar,t.leftchar)&&Gt.equalsOrNull(e.rightchar,t.rightchar)&&Gt.equalsOrNull(e.finderpattern,t.finderpattern):!1}static equalsOrNull(e,t){return e===null?t===null:Gt.equals(e,t)}hashCode(){return this.leftchar.getValue()^this.rightchar.getValue()^this.finderpattern.getValue()}}class qr{constructor(e,t,r){this.pairs=e,this.rowNumber=t,this.wasReversed=r}getPairs(){return this.pairs}getRowNumber(){return this.rowNumber}isReversed(){return this.wasReversed}isEquivalent(e){return this.checkEqualitity(this,e)}toString(){return"{ "+this.pairs+" }"}equals(e,t){return e instanceof qr?this.checkEqualitity(e,t)&&e.wasReversed===t.wasReversed:!1}checkEqualitity(e,t){if(!e||!t)return;let r;return e.forEach((n,s)=>{t.forEach(i=>{n.getLeftChar().getValue()===i.getLeftChar().getValue()&&n.getRightChar().getValue()===i.getRightChar().getValue()&&n.getFinderPatter().getValue()===i.getFinderPatter().getValue()&&(r=!0)})}),r}}class L extends it{constructor(e){super(...arguments),this.pairs=new Array(L.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=e===!0}decodeRow(e,t,r){this.pairs.length=0,this.startFromEven=!1;try{return L.constructResult(this.decodeRow2pairs(e,t))}catch(n){this.verbose}return this.pairs.length=0,this.startFromEven=!0,L.constructResult(this.decodeRow2pairs(e,t))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,t){let r=!1;for(;!r;)try{this.pairs.push(this.retrieveNextPair(t,this.pairs,e))}catch(s){if(s instanceof B){if(!this.pairs.length)throw new B;r=!0}}if(this.checkChecksum())return this.pairs;let n;if(this.rows.length?n=!0:n=!1,this.storeRow(e,!1),n){let s=this.checkRowsBoolean(!1);if(s!=null||(s=this.checkRowsBoolean(!0),s!=null))return s}throw new B}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let t=null;try{t=this.checkRows(new Array,0)}catch(r){this.verbose}return e&&(this.rows=this.rows.reverse()),t}checkRows(e,t){for(let r=t;r<this.rows.length;r++){let n=this.rows[r];this.pairs.length=0;for(let i of e)this.pairs.push(i.getPairs());if(this.pairs.push(n.getPairs()),!L.isValidSequence(this.pairs))continue;if(this.checkChecksum())return this.pairs;let s=new Array(e);s.push(n);try{return this.checkRows(s,r+1)}catch(i){this.verbose}}throw new B}static isValidSequence(e){for(let t of L.FINDER_PATTERN_SEQUENCES){if(e.length>t.length)continue;let r=!0;for(let n=0;n<e.length;n++)if(e[n].getFinderPattern().getValue()!=t[n]){r=!1;break}if(r)return!0}return!1}storeRow(e,t){let r=0,n=!1,s=!1;for(;r<this.rows.length;){let i=this.rows[r];if(i.getRowNumber()>e){s=i.isEquivalent(this.pairs);break}n=i.isEquivalent(this.pairs),r++}s||n||L.isPartialRow(this.pairs,this.rows)||(this.rows.push(r,new qr(this.pairs,e,t)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,t){for(let r of t)if(r.getPairs().length!==e.length){for(let n of r.getPairs())for(let s of e)if(Gt.equals(n,s))break}}static isPartialRow(e,t){for(let r of t){let n=!0;for(let s of e){let i=!1;for(let a of r.getPairs())if(s.equals(a)){i=!0;break}if(!i){n=!1;break}}if(n)return!0}return!1}getRows(){return this.rows}static constructResult(e){let t=ps.buildBitArray(e),n=Tn(t).parseInformation(),s=e[0].getFinderPattern().getResultPoints(),i=e[e.length-1].getFinderPattern().getResultPoints(),a=[s[0],s[1],i[0],i[1]];return new Je(n,null,null,a,re.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),t=e.getLeftChar(),r=e.getRightChar();if(r==null)return!1;let n=r.getChecksumPortion(),s=2;for(let a=1;a<this.pairs.size();++a){let o=this.pairs.get(a);n+=o.getLeftChar().getChecksumPortion(),s++;let c=o.getRightChar();c!=null&&(n+=c.getChecksumPortion(),s++)}return n%=211,211*(s-4)+n==t.getValue()}static getNextSecondBar(e,t){let r;return e.get(t)?(r=e.getNextUnset(t),r=e.getNextSet(r)):(r=e.getNextSet(t),r=e.getNextUnset(r)),r}retrieveNextPair(e,t,r){let n=t.length%2==0;this.startFromEven&&(n=!n);let s,i=!0,a=-1;do this.findNextPair(e,t,a),s=this.parseFoundFinderPattern(e,r,n),s==null?a=L.getNextSecondBar(e,this.startEnd[0]):i=!1;while(i);let o=this.decodeDataCharacter(e,s,n,!0);if(!this.isEmptyPair(t)&&t[t.length-1].mustBeLast())throw new B;let c;try{c=this.decodeDataCharacter(e,s,n,!1)}catch(u){c=null,this.verbose}return new Gt(o,c,s,!0)}isEmptyPair(e){return e.length===0}findNextPair(e,t,r){let n=this.getDecodeFinderCounters();n[0]=0,n[1]=0,n[2]=0,n[3]=0;let s=e.getSize(),i;r>
41=0?i=r:this.isEmptyPair(t)?i=0:i=t[t.length-1].getFinderPattern().getStartEnd()[1];let a=t.length%2!=0;this.startFromEven&&(a=!a);let o=!1;for(;i<s&&(o=!e.get(i),!!o);)i++;let c=0,u=i;for(let f=i;f<s;f++)if(e.get(f)!=o)n[c]++;else{if(c==3){if(a&&L.reverseCounters(n),L.isFinderPattern(n)){this.startEnd[0]=u,this.startEnd[1]=f;return}a&&L.reverseCounters(n),u+=n[0]+n[1],n[0]=n[2],n[1]=n[3],n[2]=0,n[3]=0,c--}else c++;n[c]=1,o=!o}throw new B}static reverseCounters(e){let t=e.length;for(let r=0;r<t/2;++r){let n=e[r];e[r]=e[t-r-1],e[t-r-1]=n}}parseFoundFinderPattern(e,t,r){let n,s,i;if(r){let c=this.startEnd[0]-1;for(;c>=0&&!e.get(c);)c--;c++,n=this.startEnd[0]-c,s=c,i=this.startEnd[1]}else s=this.startEnd[0],i=e.getNextUnset(this.startEnd[1]+1),n=i-this.startEnd[1];let a=this.getDecodeFinderCounters();G.arraycopy(a,0,a,1,a.length-1),a[0]=n;let o;try{o=this.parseFinderValue(a,L.FINDER_PATTERNS)}catch{return null}return new Mr(o,[s,i],s,i,t)}decodeDataCharacter(e,t,r,n){let s=this.getDataCharacterCounters();for(let _e=0;_e<s.length;_e++)s[_e]=0;if(n)L.recordPatternInReverse(e,t.getStartEnd()[0],s);else{L.recordPattern(e,t.getStartEnd()[1],s);for(let _e=0,nt=s.length-1;_e<nt;_e++,nt--){let mt=s[_e];s[_e]=s[nt],s[nt]=mt}}let i=17,a=we.sum(new Int32Array(s))/i,o=(t.getStartEnd()[1]-t.getStartEnd()[0])/15;if(Math.abs(a-o)/o>.3)throw new B;let c=this.getOddCounts(),u=this.getEvenCounts(),f=this.getOddRoundingErrors(),x=this.getEvenRoundingErrors();for(let _e=0;_e<s.length;_e++){let nt=1*s[_e]/a,mt=nt+.5;if(mt<1){if(nt<.3)throw new B;mt=1}else if(mt>8){if(nt>8.7)throw new B;mt=8}let dr=_e/2;_e&1?(u[dr]=mt,x[dr]=nt-mt):(c[dr]=mt,f[dr]=nt-mt)}this.adjustOddEvenCounts(i);let E=4*t.getValue()+(r?0:2)+(n?0:1)-1,I=0,y=0;for(let _e=c.length-1;_e>=0;_e--){if(L.isNotA1left(t,r,n)){let nt=L.WEIGHTS[E][2*_e];y+=c[_e]*nt}I+=c[_e]}let N=0;for(let _e=u.length-1;_e>=0;_e--)if(L.isNotA1left(t,r,n)){let nt=L.WEIGHTS[E][2*_e+1];N+=u[_e]*nt}let O=y+N;if(I&1||I>13||I<4)throw new B;let U=(13-I)/2,j=L.SYMBOL_WIDEST[U],k=9-j,ge=Dt.getRSSvalue(c,j,!0),he=Dt.getRSSvalue(u,k,!1),xt=L.EVEN_TOTAL_SUBSET[U],_t=L.GSUM[U],gt=ge*xt+he+_t;return new ir(gt,O)}static isNotA1left(e,t,r){return!(e.getValue()==0&&t&&r)}adjustOddEvenCounts(e){let t=we.sum(new Int32Array(this.getOddCounts())),r=we.sum(new Int32Array(this.getEvenCounts())),n=!1,s=!1;t>13?s=!0:t<4&&(n=!0);let i=!1,a=!1;r>13?a=!0:r<4&&(i=!0);let o=t+r-e,c=(t&1)==1,u=(r&1)==0;if(o==1)if(c){if(u)throw new B;s=!0}else{if(!u)throw new B;a=!0}else if(o==-1)if(c){if(u)throw new B;n=!0}else{if(!u)throw new B;i=!0}else if(o==0){if(c){if(!u)throw new B;t<r?(n=!0,a=!0):(s=!0,i=!0)}else if(u)throw new B}else throw new B;if(n){if(s)throw new B;L.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(s&&L.decrement(this.getOddCounts(),this.getOddRoundingErrors()),i){if(a)throw new B;L.increment(this.getEvenCounts(),this.getOddRoundingErrors())}a&&L.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}L.SYMBOL_WIDEST=[7,5,4,3,1],L.EVEN_TOTAL_SUBSET=[4,20,52,104,204],L.GSUM=[0,348,1388,2948,3988],L.FINDER_PATTERNS=[Int32Array.from([1,8,4,1]),Int32Array.from([3,6,4,1]),Int32Array.from([3,4,6,1]),Int32Array.from([3,2,8,1]),Int32Array.from([2,6,5,1]),Int32Array.from([2,2,9,1])],L.WEIGHTS=[[1,3,9,27,81,32,96,77],[20,60,180,118,143,7,21,63],[189,145,13,39,117,140,209,205],[193,157,49,147,19,57,171,91],[62,186,136,197,169,85,44,132],[185,133,188,142,4,12,36,108],[113,128,173,97,80,29,87,50],[150,28,84,41,123,158,52,156],[46,138,203,187,139,206,196,166],[76,17,51,153,37,111,122,155],[43,129,176,106,107,110,119,146],[16,48,144,10,30,90,59,177],[109,116,137,200,178,112,125,164],[70,210,208,202,184,130,179,115],[134,191,151,31,93,68,204,190],[148,22,66,198,172,94,71,2],[6,18,54,162,64,192,154,40],[120,149,25,75,14,42,126,167],[79,26,78,23,69,207,199,175],[103,98,83,38,114,131,182,124],[161,61,183,127,170,88,53,159],[55,165,73,8,24,72,5,15],[45,135,194,160,58,174,100,89]],L.FINDER_PAT_A=0,L.FINDER_PAT_B=1,L.FINDER_PAT_C=2,L.FINDER_PAT_D=3,L.FINDER_PAT_E=4,L.FINDER_PAT_F=5,L.FINDER_PATTERN_SEQUENCES=[[L.FINDER_PAT_A,L.FINDER_PAT_A],[L.FINDER_PAT_A,L.FINDER_PAT_B,L.FINDER_PAT_B],[L.FINDER_PAT_A,L.FINDER_PAT_C,L.FINDER_PAT_B,L.FINDER_PAT_D],[L.FINDER_PAT_A,L.FINDER_PAT_E,L.FINDER_PAT_B,L.FINDER_PAT_D,L.FINDER_PAT_C],[L.FINDER_PAT_A,L.FINDER_PAT_E,L.FINDER_PAT_B,L.FINDER_PAT_D,L.FINDER_PAT_D,L.FINDER_PAT_F],[L.FINDER_PAT_A,L.FINDER_PAT_E,L.FINDER_PAT_B,L.FINDER_PAT_D,L.FINDER_PAT_E,L.FINDER_PAT_F,L.FINDER_PAT_F],[L.FINDER_PAT_A,L.FINDER_PAT_A,L.FINDER_PAT_B,L.FINDER_PAT_B,L.FINDER_PAT_C,L.FINDER_PAT_C,L.FINDER_PAT_D,L.FINDER_PAT_D],[L.FINDER_PAT_A,L.FINDER_PAT_A,L.FINDER_PAT_B,L.FINDER_PAT_B,L.FINDER_PAT_C,L.FINDER_PAT_C,L.FINDER_PAT_D,L.FINDER_PAT_E,L.FINDER_PAT_E],[L.FINDER_PAT_A,L.FINDER_PAT_A,L.FINDER_PAT_B,L.FINDER_PAT_B,L.FINDER_PAT_C,L.FINDER_PAT_C,L.FINDER_PAT_D,L.FINDER_PAT_E,L.FINDER_PAT_F,L.FINDER_PAT_F],[L.FINDER_PAT_A,L.FINDER_PAT_A,L.FINDER_PAT_B,L.FINDER_PAT_B,L.FINDER_PAT_C,L.FINDER_PAT_D,L.FINDER_PAT_D,L.FINDER_PAT_E,L.FINDER_PAT_E,L.FINDER_PAT_F,L.FINDER_PAT_F]],L.MAX_PAIRS=11;class bs extends ir{constructor(e,t,r){super(e,t),this.count=0,this.finderPattern=r}getFinderPattern(){return this.finderPattern}getCount(){return this.count}incrementCount(){this.count++}}class ke extends it{constructor(){super(...arguments),this.possibleLeftPairs=[],this.possibleRightPairs=[]}decodeRow(e,t,r){const n=this.decodePair(t,!1,e,r);ke.addOrTally(this.possibleLeftPairs,n),t.reverse();let s=this.decodePair(t,!0,e,r);ke.addOrTally(this.possibleRightPairs,s),t.reverse();for(let i of this.possibleLeftPairs)if(i.getCount()>1){for(let a of this.possibleRightPairs)if(a.getCount()>1&&ke.checkChecksum(i,a))return ke.constructResult(i,a)}throw new B}static addOrTally(e,t){if(t==null)return;let r=!1;for(let n of e)if(n.getValue()===t.getValue()){n.incrementCount(),r=!0;break}r||e.push(t)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,t){let r=4537077*e.getValue()+t.getValue(),n=new String(r).toString(),s=new pe;for(let c=13-n.length;c>0;c--)s.append("0");s.append(n);let i=0;for(let c=0;c<13;
41c++){let u=s.charAt(c).charCodeAt(0)-48;i+=c&1?u:3*u}i=10-i%10,i===10&&(i=0),s.append(i.toString());let a=e.getFinderPattern().getResultPoints(),o=t.getFinderPattern().getResultPoints();return new Je(s.toString(),null,0,[a[0],a[1],o[0],o[1]],re.RSS_14,new Date().getTime())}static checkChecksum(e,t){let r=(e.getChecksumPortion()+16*t.getChecksumPortion())%79,n=9*e.getFinderPattern().getValue()+t.getFinderPattern().getValue();return n>72&&n--,n>8&&n--,r===n}decodePair(e,t,r,n){try{let s=this.findFinderPattern(e,t),i=this.parseFoundFinderPattern(e,r,t,s),a=n==null?null:n.get(K.NEED_RESULT_POINT_CALLBACK);if(a!=null){let u=(s[0]+s[1])/2;t&&(u=e.getSize()-1-u),a.foundPossibleResultPoint(new Z(u,r))}let o=this.decodeDataCharacter(e,i,!0),c=this.decodeDataCharacter(e,i,!1);return new bs(1597*o.getValue()+c.getValue(),o.getChecksumPortion()+4*c.getChecksumPortion(),i)}catch{return null}}decodeDataCharacter(e,t,r){let n=this.getDataCharacterCounters();for(let N=0;N<n.length;N++)n[N]=0;if(r)Xe.recordPatternInReverse(e,t.getStartEnd()[0],n);else{Xe.recordPattern(e,t.getStartEnd()[1]+1,n);for(let N=0,O=n.length-1;N<O;N++,O--){let U=n[N];n[N]=n[O],n[O]=U}}let s=r?16:15,i=we.sum(new Int32Array(n))/s,a=this.getOddCounts(),o=this.getEvenCounts(),c=this.getOddRoundingErrors(),u=this.getEvenRoundingErrors();for(let N=0;N<n.length;N++){let O=n[N]/i,U=Math.floor(O+.5);U<1?U=1:U>8&&(U=8);let j=Math.floor(N/2);N&1?(o[j]=U,u[j]=O-U):(a[j]=U,c[j]=O-U)}this.adjustOddEvenCounts(r,s);let f=0,x=0;for(let N=a.length-1;N>=0;N--)x*=9,x+=a[N],f+=a[N];let E=0,I=0;for(let N=o.length-1;N>=0;N--)E*=9,E+=o[N],I+=o[N];let y=x+3*E;if(r){if(f&1||f>12||f<4)throw new B;let N=(12-f)/2,O=ke.OUTSIDE_ODD_WIDEST[N],U=9-O,j=Dt.getRSSvalue(a,O,!1),k=Dt.getRSSvalue(o,U,!0),ge=ke.OUTSIDE_EVEN_TOTAL_SUBSET[N],he=ke.OUTSIDE_GSUM[N];return new ir(j*ge+k+he,y)}else{if(I&1||I>10||I<4)throw new B;let N=(10-I)/2,O=ke.INSIDE_ODD_WIDEST[N],U=9-O,j=Dt.getRSSvalue(a,O,!0),k=Dt.getRSSvalue(o,U,!1),ge=ke.INSIDE_ODD_TOTAL_SUBSET[N],he=ke.INSIDE_GSUM[N];return new ir(k*ge+j+he,y)}}findFinderPattern(e,t){let r=this.getDecodeFinderCounters();r[0]=0,r[1]=0,r[2]=0,r[3]=0;let n=e.getSize(),s=!1,i=0;for(;i<n&&(s=!e.get(i),t!==s);)i++;let a=0,o=i;for(let c=i;c<n;c++)if(e.get(c)!==s)r[a]++;else{if(a===3){if(it.isFinderPattern(r))return[o,c];o+=r[0]+r[1],r[0]=r[2],r[1]=r[3],r[2]=0,r[3]=0,a--}else a++;r[a]=1,s=!s}throw new B}parseFoundFinderPattern(e,t,r,n){let s=e.get(n[0]),i=n[0]-1;for(;i>=0&&s!==e.get(i);)i--;i++;const a=n[0]-i,o=this.getDecodeFinderCounters(),c=new Int32Array(o.length);G.arraycopy(o,0,c,1,o.length-1),c[0]=a;const u=this.parseFinderValue(c,ke.FINDER_PATTERNS);let f=i,x=n[1];return r&&(f=e.getSize()-1-f,x=e.getSize()-1-x),new Mr(u,[i,n[1]],f,x,t)}adjustOddEvenCounts(e,t){let r=we.sum(new Int32Array(this.getOddCounts())),n=we.sum(new Int32Array(this.getEvenCounts())),s=!1,i=!1,a=!1,o=!1;e?(r>12?i=!0:r<4&&(s=!0),n>12?o=!0:n<4&&(a=!0)):(r>11?i=!0:r<5&&(s=!0),n>10?o=!0:n<4&&(a=!0));let c=r+n-t,u=(r&1)===(e?1:0),f=(n&1)===1;if(c===1)if(u){if(f)throw new B;i=!0}else{if(!f)throw new B;o=!0}else if(c===-1)if(u){if(f)throw new B;s=!0}else{if(!f)throw new B;a=!0}else if(c===0){if(u){if(!f)throw new B;r<n?(s=!0,o=!0):(i=!0,a=!0)}else if(f)throw new B}else throw new B;if(s){if(i)throw new B;it.increment(this.getOddCounts(),this.getOddRoundingErrors())}if(i&&it.decrement(this.getOddCounts(),this.getOddRoundingErrors()),a){if(o)throw new B;it.increment(this.getEvenCounts(),this.getOddRoundingErrors())}o&&it.decrement(this.getEvenCounts(),this.getEvenRoundingErrors())}}ke.OUTSIDE_EVEN_TOTAL_SUBSET=[1,10,34,70,126],ke.INSIDE_ODD_TOTAL_SUBSET=[4,20,48,81],ke.OUTSIDE_GSUM=[0,161,961,2015,2715],ke.INSIDE_GSUM=[0,336,1036,1516],ke.OUTSIDE_ODD_WIDEST=[8,6,4,3,1],ke.INSIDE_ODD_WIDEST=[2,4,6,8],ke.FINDER_PATTERNS=[Int32Array.from([3,8,2,1]),Int32Array.from([3,5,5,1]),Int32Array.from([3,3,7,1]),Int32Array.from([3,1,9,1]),Int32Array.from([2,7,4,1]),Int32Array.from([2,5,6,1]),Int32Array.from([2,3,8,1]),Int32Array.from([1,5,7,1]),Int32Array.from([1,3,9,1])];class cr extends Xe{constructor(e,t){super(),this.readers=[],this.verbose=t===!0;const r=e?e.get(K.POSSIBLE_FORMATS):null,n=e&&e.get(K.ASSUME_CODE_39_CHECK_DIGIT)!==void 0;r?((r.includes(re.EAN_13)||r.includes(re.UPC_A)||r.includes(re.EAN_8)||r.includes(re.UPC_E))&&this.readers.push(new Zr(e)),r.includes(re.CODE_39)&&this.readers.push(new Ye(n)),r.includes(re.CODE_128)&&this.readers.push(new V),r.includes(re.ITF)&&this.readers.push(new Ne),r.includes(re.RSS_14)&&this.readers.push(new ke),r.includes(re.RSS_EXPANDED)&&this.readers.push(new L(this.verbose))):(this.readers.push(new Zr(e)),this.readers.push(new Ye),this.readers.push(new Zr(e)),this.readers.push(new V),this.readers.push(new Ne),this.readers.push(new ke),this.readers.push(new L(this.verbose)))}decodeRow(e,t,r){for(let n=0;n<this.readers.length;n++)try{return this.readers[n].decodeRow(e,t,r)}catch{}throw new B}
41reset(){this.readers.forEach(e=>e.reset())}}class Is extends Ft{constructor(e=500,t){super(new cr(t),e,t)}}class Ie{constructor(e,t,r){this.ecCodewords=e,this.ecBlocks=[t],r&&this.ecBlocks.push(r)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class Ee{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class me{constructor(e,t,r,n,s,i){this.versionNumber=e,this.symbolSizeRows=t,this.symbolSizeColumns=r,this.dataRegionSizeRows=n,this.dataRegionSizeColumns=s,this.ecBlocks=i;let a=0;const o=i.getECCodewords(),c=i.getECBlocks();for(let u of c)a+=u.getCount()*(u.getDataCodewords()+o);this.totalCodewords=a}getVersionNumber(){return this.versionNumber}getSymbolSizeRows(){return this.symbolSizeRows}getSymbolSizeColumns(){return this.symbolSizeColumns}getDataRegionSizeRows(){return this.dataRegionSizeRows}getDataRegionSizeColumns(){return this.dataRegionSizeColumns}getTotalCodewords(){return this.totalCodewords}getECBlocks(){return this.ecBlocks}static getVersionForDimensions(e,t){if(e&1||t&1)throw new P;for(let r of me.VERSIONS)if(r.symbolSizeRows===e&&r.symbolSizeColumns===t)return r;throw new P}toString(){return""+this.versionNumber}static buildVersions(){return[new me(1,10,10,8,8,new Ie(5,new Ee(1,3))),new me(2,12,12,10,10,new Ie(7,new Ee(1,5))),new me(3,14,14,12,12,new Ie(10,new Ee(1,8))),new me(4,16,16,14,14,new Ie(12,new Ee(1,12))),new me(5,18,18,16,16,new Ie(14,new Ee(1,18))),new me(6,20,20,18,18,new Ie(18,new Ee(1,22))),new me(7,22,22,20,20,new Ie(20,new Ee(1,30))),new me(8,24,24,22,22,new Ie(24,new Ee(1,36))),new me(9,26,26,24,24,new Ie(28,new Ee(1,44))),new me(10,32,32,14,14,new Ie(36,new Ee(1,62))),new me(11,36,36,16,16,new Ie(42,new Ee(1,86))),new me(12,40,40,18,18,new Ie(48,new Ee(1,114))),new me(13,44,44,20,20,new Ie(56,new Ee(1,144))),new me(14,48,48,22,22,new Ie(68,new Ee(1,174))),new me(15,52,52,24,24,new Ie(42,new Ee(2,102))),new me(16,64,64,14,14,new Ie(56,new Ee(2,140))),new me(17,72,72,16,16,new Ie(36,new Ee(4,92))),new me(18,80,80,18,18,new Ie(48,new Ee(4,114))),new me(19,88,88,20,20,new Ie(56,new Ee(4,144))),new me(20,96,96,22,22,new Ie(68,new Ee(4,174))),new me(21,104,104,24,24,new Ie(56,new Ee(6,136))),new me(22,120,120,18,18,new Ie(68,new Ee(6,175))),new me(23,132,132,20,20,new Ie(62,new Ee(8,163))),new me(24,144,144,22,22,new Ie(62,new Ee(8,156),new Ee(2,155))),new me(25,8,18,6,16,new Ie(7,new Ee(1,5))),new me(26,8,32,6,14,new Ie(11,new Ee(1,10))),new me(27,12,26,10,24,new Ie(14,new Ee(1,16))),new me(28,12,36,10,16,new Ie(18,new Ee(1,22))),new me(29,16,36,14,16,new Ie(24,new Ee(1,32))),new me(30,16,48,14,22,new Ie(28,new Ee(1,49)))]}}me.VERSIONS=me.buildVersions();class Jr{constructor(e){const t=e.getHeight();if(t<8||t>144||t&1)throw new P;this.version=Jr.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new De(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){const t=e.getHeight(),r=e.getWidth();return me.getVersionForDimensions(t,r)}readCodewords(){const e=new Int8Array(this.version.getTotalCodewords());let t=0,r=4,n=0;const s=this.mappingBitMatrix.getHeight(),i=this.mappingBitMatrix.getWidth();let a=!1,o=!1,c=!1,u=!1;do if(r===s&&n===0&&!a)e[t++]=this.readCorner1(s,i)&255,r-=2,n+=2,a=!0;else if(r===s-2&&n===0&&i&3&&!o)e[t++]=this.readCorner2(s,i)&255,r-=2,n+=2,o=!0;else if(r===s+4&&n===2&&!(i&7)&&!c)e[t++]=this.readCorner3(s,i)&255,r-=2,n+=2,c=!0;else if(r===s-2&&n===0&&(i&7)===4&&!u)e[t++]=this.readCorner4(s,i)&255,r-=2,n+=2,u=!0;else{do r<s&&n>=0&&!this.readMappingMatrix.get(n,r)&&(e[t++]=this.readUtah(r,n,s,i)&255),r-=2,n+=2;while(r>=0&&n<i);r+=1,n+=3;do r>=0&&n<i&&!this.readMappingMatrix.get(n,r)&&(e[t++]=this.readUtah(r,n,s,i)&255),r+=2,n-=2;while(r<s&&n>=0);r+=3,n+=1}while(r<s||n<i);if(t!==this.version.getTotalCodewords())throw new P;return e}readModule(e,t,r,n){return e<0&&(e+=r,t+=4-(r+4&7)),t<0&&(t+=n,e+=4-(n+4&7)),this.readMappingMatrix.set(t,e),this.mappingBitMatrix.get(t,e)}readUtah(e,t,r,n){let s=0;return this.readModule(e-2,t-2,r,n)&&(s|=1),s<<=1,this.readModule(e-2,t-1,r,n)&&(s|=1),s<<=1,this.readModule(e-1,t-2,r,n)&&(s|=1),s<<=1,this.readModule(e-1,t-1,r,n)&&(s|=1),s<<=1,this.readModule(e-1,t,r,n)&&(s|=1),s<<=1,this.readModule(e,t-2,r,n)&&(s|=1),s<<=1,this.readModule(e,t-1,r,n)&&(s|=1),s<<=1,this.readModule(e,t,r,n)&&(s|=1),s}readCorner1(e,t){let r=0;return this.readModule(e-1,0,e,t)&&(r|=1),r<<=1,this.readModule(e-1,1,e,t)&&(r|=1),r<<=1,this.readModule(e-1,2,e,t)&&(r|=1),r<<=1,this.readModule(0,t-2,e,t)&&(r|=1),r<<=1,this.readModule(0,t-1,e,t)&&(r|=1),r<<=1,this.readModule(1,t-1,e,t)&&(r|=1),r<<=1,this.readModule(2,t-1,e,t)&&(r|=1),r<<=1,this.readModule(3,t-1,e,t)&&(r|=1),r}readCorner2(e,t){let r=0;return this.readModule(e-3,0,e,t)&&(r|=1),r<<=1,this.readModule(e-2,0,e,t)&&(r|=1),r<<=1,this.readModule(e-1,0,e,t)&&(r|=1),r<<=1,this.readModule(0,t-4,e,t)&&(r|=1),r<<=1,this.readModule(0,t-3,e,t)&&(r|=1),r<<=1,this.readModule(0,t-2,e,t)&&(r|=1),r<<=1,this.readModule(0,t-1,e,t)&&(r|=1),r<<=1,this.readModule(1,t-1,e,t)&&(r|=1),r}readCorner3(e,t){let r=0;return this.readModule(e-1,0,e,t)&&(r|=1),r<<=1,this.readModule(e-1,t-1,e,t)&&(r|=1),r<<=1,this.readModule(0,t-3,e,t)&&(r|=1),r<<=1,this.readModule(0,t-2,e,t)&&(r|=1),r<<=1,this.readModule(0,t-1,e,t)&&(r|=1),r<<=1,this.readModule(1,t-3,e,t)&&(r|=1),r<<=1,this.readModule(1,t-2,e,t)&&(r|=1),r<<=1,this.readModule(1,t-1,e,t)&&(r|=1),r}readCorner4(e,t){let r=0;return this.readModule(e-3,0,e,t)&&(r|=1),r<<=1,this.readModule(e-2,0,e,t)&&(r|=1),r<<=1,this.readModule(e-1,0,e,t)&&(r|=1),r<<=1,this.readModule(0,t-2,e,t)&&(r|=1),r<<=1,this.readModule(0,t-1,e,t)&&(r|=1),r<<=1,this.readModule(1,t-1,e,t)&&(r|=1),r<<=1,this.readModule(2,t-1,e,t)&&(r|=1),r<<=1,this.readModule(3,t-1,e,t)&&(r|=1),r}extractDataRegion(e){const t=this.version.getSymbolSizeRows(),r=this.version.getSymbolSizeColumns();if(e.getHeight()!==t)throw new v("Dimension of bitMatrix must match the version size");const n=this.version.getDataRegionSizeRows(),s=this.version.getDataRegionSizeColumns(),i=t/n|0,a=r/s|0,o=i*n,c=a*s,u=new De(c,o);for(let f=0;f<i;++f){const x=f*n;for(let E=0;E<a;++E){const I=E*s;for(let y=0;y<n;++y){const N=f*(n+2)+1+y,O=x+y;for(let U=0;U<s;++U){const j=E*(s+2)+1+U;if(e.get(j,N)){const k=I+U;u.set(k,O)}}}}}return u}}
41class $r{constructor(e,t){this.numDataCodewords=e,this.codewords=t}static getDataBlocks(e,t){const r=t.getECBlocks();let n=0;const s=r.getECBlocks();for(let y of s)n+=y.getCount();const i=new Array(n);let a=0;for(let y of s)for(let N=0;N<y.getCount();N++){const O=y.getDataCodewords(),U=r.getECCodewords()+O;i[a++]=new $r(O,new Uint8Array(U))}const c=i[0].codewords.length-r.getECCodewords(),u=c-1;let f=0;for(let y=0;y<u;y++)for(let N=0;N<a;N++)i[N].codewords[y]=e[f++];const x=t.getVersionNumber()===24,E=x?8:a;for(let y=0;y<E;y++)i[y].codewords[c-1]=e[f++];const I=i[0].codewords.length;for(let y=c;y<I;y++)for(let N=0;N<a;N++){const O=x?(N+8)%a:N,U=x&&O>7?y-1:y;i[O].codewords[U]=e[f++]}if(f!==e.length)throw new v;return i}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class en{constructor(e){this.bytes=e,this.byteOffset=0,this.bitOffset=0}getBitOffset(){return this.bitOffset}getByteOffset(){return this.byteOffset}readBits(e){if(e<1||e>32||e>this.available())throw new v(""+e);let t=0,r=this.bitOffset,n=this.byteOffset;const s=this.bytes;if(r>0){const i=8-r,a=e<i?e:i,o=i-a,c=255>>8-a<<o;t=(s[n]&c)>>o,e-=a,r+=a,r===8&&(r=0,n++)}if(e>0){for(;e>=8;)t=t<<8|s[n]&255,n++,e-=8;if(e>0){const i=8-e,a=255>>i<<i;t=t<<e|(s[n]&a)>>i,r+=e}}return this.bitOffset=r,this.byteOffset=n,t}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var ze;(function(d){d[d.PAD_ENCODE=0]="PAD_ENCODE",d[d.ASCII_ENCODE=1]="ASCII_ENCODE",d[d.C40_ENCODE=2]="C40_ENCODE",d[d.TEXT_ENCODE=3]="TEXT_ENCODE",d[d.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",d[d.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",d[d.BASE256_ENCODE=6]="BASE256_ENCODE"})(ze||(ze={}));class Wt{static decode(e){const t=new en(e),r=new pe,n=new pe,s=new Array;let i=ze.ASCII_ENCODE;do if(i===ze.ASCII_ENCODE)i=this.decodeAsciiSegment(t,r,n);else{switch(i){case ze.C40_ENCODE:this.decodeC40Segment(t,r);break;case ze.TEXT_ENCODE:this.decodeTextSegment(t,r);break;case ze.ANSIX12_ENCODE:this.decodeAnsiX12Segment(t,r);break;case ze.EDIFACT_ENCODE:this.decodeEdifactSegment(t,r);break;case ze.BASE256_ENCODE:this.decodeBase256Segment(t,r,s);break;default:throw new P}i=ze.ASCII_ENCODE}while(i!==ze.PAD_ENCODE&&t.available()>0);return n.length()>0&&r.append(n.toString()),new de(e,r.toString(),s.length===0?null:s,null)}static decodeAsciiSegment(e,t,r){let n=!1;do{let s=e.readBits(8);if(s===0)throw new P;if(s<=128)return n&&(s+=128),t.append(String.fromCharCode(s-1)),ze.ASCII_ENCODE;if(s===129)return ze.PAD_ENCODE;if(s<=229){const i=s-130;i<10&&t.append("0"),t.append(""+i)}else switch(s){case 230:return ze.C40_ENCODE;case 231:return ze.BASE256_ENCODE;case 232:t.append("�");break;case 233:case 234:break;case 235:n=!0;break;case 236:t.append("[)>�05�"),r.insert(0,"��");break;case 237:t.append("[)>�06�"),r.insert(0,"��");break;case 238:return ze.ANSIX12_ENCODE;case 239:return ze.TEXT_ENCODE;case 240:return ze.EDIFACT_ENCODE;case 241:break;default:if(s!==254||e.available()!==0)throw new P;break}}while(e.available()>0);return ze.ASCII_ENCODE}static decodeC40Segment(e,t){let r=!1;const n=[];let s=0;do{if(e.available()===8)return;const i=e.readBits(8);if(i===254)return;this.parseTwoBytes(i,e.readBits(8),n);for(let a=0;a<3;a++){const o=n[a];switch(s){case 0:if(o<3)s=o+1;else if(o<this.C40_BASIC_SET_CHARS.length){const c=this.C40_BASIC_SET_CHARS[o];r?(t.append(String.fromCharCode(c.charCodeAt(0)+128)),r=!1):t.append(c)}else throw new P;break;case 1:r?(t.append(String.fromCharCode(o+128)),r=!1):t.append(String.fromCharCode(o)),s=0;break;case 2:if(o<this.C40_SHIFT2_SET_CHARS.length){const c=this.C40_SHIFT2_SET_CHARS[o];r?(t.append(String.fromCharCode(c.charCodeAt(0)+128)),r=!1):t.append(c)}else switch(o){case 27:t.append("�");break;case 30:r=!0;break;default:throw new P}s=0;break;case 3:r?(t.append(String.fromCharCode(o+224)),r=!1):t.append(String.fromCharCode(o+96)),s=0;break;default:throw new P}}}while(e.available()>0)}static decodeTextSegment(e,t){let r=!1,n=[],s=0;do{if(e.available()===8)return;const i=e.readBits(8);if(i===254)return;this.parseTwoBytes(i,e.readBits(8),n);for(let a=0;a<3;a++){const o=n[a];switch(s){case 0:if(o<3)s=o+1;else if(o<this.TEXT_BASIC_SET_CHARS.length){const c=this.TEXT_BASIC_SET_CHARS[o];r?(t.append(String.fromCharCode(c.charCodeAt(0)+128)),r=!1):t.append(c)}else throw new P;break;case 1:r?(t.append(String.fromCharCode(o+128)),r=!1):t.append(String.fromCharCode(o)),s=0;break;case 2:if(o<this.TEXT_SHIFT2_SET_CHARS.length){const c=this.TEXT_SHIFT2_SET_CHARS[o];r?(t.append(String.fromCharCode(c.charCodeAt(0)+128)),r=!1):t.append(c)}
41else switch(o){case 27:t.append("�");break;case 30:r=!0;break;default:throw new P}s=0;break;case 3:if(o<this.TEXT_SHIFT3_SET_CHARS.length){const c=this.TEXT_SHIFT3_SET_CHARS[o];r?(t.append(String.fromCharCode(c.charCodeAt(0)+128)),r=!1):t.append(c),s=0}else throw new P;break;default:throw new P}}}while(e.available()>0)}static decodeAnsiX12Segment(e,t){const r=[];do{if(e.available()===8)return;const n=e.readBits(8);if(n===254)return;this.parseTwoBytes(n,e.readBits(8),r);for(let s=0;s<3;s++){const i=r[s];switch(i){case 0:t.append("\r");break;case 1:t.append("*");break;case 2:t.append(">");break;case 3:t.append(" ");break;default:if(i<14)t.append(String.fromCharCode(i+44));else if(i<40)t.append(String.fromCharCode(i+51));else throw new P;break}}}while(e.available()>0)}static parseTwoBytes(e,t,r){let n=(e<<8)+t-1,s=Math.floor(n/1600);r[0]=s,n-=s*1600,s=Math.floor(n/40),r[1]=s,r[2]=n-s*40}static decodeEdifactSegment(e,t){do{if(e.available()<=16)return;for(let r=0;r<4;r++){let n=e.readBits(6);if(n===31){const s=8-e.getBitOffset();s!==8&&e.readBits(s);return}n&32||(n|=64),t.append(String.fromCharCode(n))}}while(e.available()>0)}static decodeBase256Segment(e,t,r){let n=1+e.getByteOffset();const s=this.unrandomize255State(e.readBits(8),n++);let i;if(s===0?i=e.available()/8|0:s<250?i=s:i=250*(s-249)+this.unrandomize255State(e.readBits(8),n++),i<0)throw new P;const a=new Uint8Array(i);for(let o=0;o<i;o++){if(e.available()<8)throw new P;a[o]=this.unrandomize255State(e.readBits(8),n++)}r.push(a);try{t.append(Se.decode(a,te.ISO88591))}catch(o){throw new Ot("Platform does not support required encoding: "+o.message)}}static unrandomize255State(e,t){const r=149*t%255+1,n=e-r;return n>=0?n:n+256}}Wt.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"],Wt.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],Wt.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"],Wt.TEXT_SHIFT2_SET_CHARS=Wt.C40_SHIFT2_SET_CHARS,Wt.TEXT_SHIFT3_SET_CHARS=["`","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","|","}","~","�"];class ys{constructor(){this.rsDecoder=new wr(ue.DATA_MATRIX_FIELD_256)}decode(e){const t=new Jr(e),r=t.getVersion(),n=t.readCodewords(),s=$r.getDataBlocks(n,r);let i=0;for(let c of s)i+=c.getNumDataCodewords();const a=new Uint8Array(i),o=s.length;for(let c=0;c<o;c++){const u=s[c],f=u.getCodewords(),x=u.getNumDataCodewords();this.correctErrors(f,x);for(let E=0;E<x;E++)a[E*o+c]=f[E]}return Wt.decode(a)}correctErrors(e,t){const r=new Int32Array(e);try{this.rsDecoder.decode(r,e.length-t)}catch{throw new J}for(let n=0;n<t;n++)e[n]=r[n]}}class He{constructor(e){this.image=e,this.rectangleDetector=new kt(this.image)}detect(){const e=this.rectangleDetector.detect();let t=this.detectSolid1(e);if(t=this.detectSolid2(t),t[3]=this.correctTopRight(t),!t[3])throw new B;t=this.shiftToModuleCenter(t);const r=t[0],n=t[1],s=t[2],i=t[3];let a=this.transitionsBetween(r,i)+1,o=this.transitionsBetween(s,i)+1;(a&1)===1&&(a+=1),(o&1)===1&&(o+=1),4*a<7*o&&4*o<7*a&&(a=o=Math.max(a,o));let c=He.sampleGrid(this.image,r,n,s,i,a,o);return new Dr(c,[r,n,s,i])}static shiftPoint(e,t,r){let n=(t.getX()-e.getX())/(r+1),s=(t.getY()-e.getY())/(r+1);return new Z(e.getX()+n,e.getY()+s)}static moveAway(e,t,r){let n=e.getX(),s=e.getY();return n<t?n-=1:n+=1,s<r?s-=1:s+=1,new Z(n,s)}detectSolid1(e){let t=e[0],r=e[1],n=e[3],s=e[2],i=this.transitionsBetween(t,r),a=this.transitionsBetween(r,n),o=this.transitionsBetween(n,s),c=this.transitionsBetween(s,t),u=i,f=[s,t,r,n];return u>a&&(u=a,f[0]=t,f[1]=r,f[2]=n,f[3]=s),u>o&&(u=o,f[0]=r,f[1]=n,f[2]=s,f[3]=t),u>c&&(f[0]=n,f[1]=s,f[2]=t,f[3]=r),f}detectSolid2(e){let t=e[0],r=e[1],n=e[2],s=e[3],i=this.transitionsBetween(t,s),a=He.shiftPoint(r,n,(i+1)*4),o=He.shiftPoint(n,r,(i+1)
41*4),c=this.transitionsBetween(a,t),u=this.transitionsBetween(o,s);return c<u?(e[0]=t,e[1]=r,e[2]=n,e[3]=s):(e[0]=r,e[1]=n,e[2]=s,e[3]=t),e}correctTopRight(e){let t=e[0],r=e[1],n=e[2],s=e[3],i=this.transitionsBetween(t,s),a=this.transitionsBetween(r,s),o=He.shiftPoint(t,r,(a+1)*4),c=He.shiftPoint(n,r,(i+1)*4);i=this.transitionsBetween(o,s),a=this.transitionsBetween(c,s);let u=new Z(s.getX()+(n.getX()-r.getX())/(i+1),s.getY()+(n.getY()-r.getY())/(i+1)),f=new Z(s.getX()+(t.getX()-r.getX())/(a+1),s.getY()+(t.getY()-r.getY())/(a+1));if(!this.isValid(u))return this.isValid(f)?f:null;if(!this.isValid(f))return u;let x=this.transitionsBetween(o,u)+this.transitionsBetween(c,u),E=this.transitionsBetween(o,f)+this.transitionsBetween(c,f);return x>E?u:f}shiftToModuleCenter(e){let t=e[0],r=e[1],n=e[2],s=e[3],i=this.transitionsBetween(t,s)+1,a=this.transitionsBetween(n,s)+1,o=He.shiftPoint(t,r,a*4),c=He.shiftPoint(n,r,i*4);i=this.transitionsBetween(o,s)+1,a=this.transitionsBetween(c,s)+1,(i&1)===1&&(i+=1),(a&1)===1&&(a+=1);let u=(t.getX()+r.getX()+n.getX()+s.getX())/4,f=(t.getY()+r.getY()+n.getY()+s.getY())/4;t=He.moveAway(t,u,f),r=He.moveAway(r,u,f),n=He.moveAway(n,u,f),s=He.moveAway(s,u,f);let x,E;return o=He.shiftPoint(t,r,a*4),o=He.shiftPoint(o,s,i*4),x=He.shiftPoint(r,t,a*4),x=He.shiftPoint(x,n,i*4),c=He.shiftPoint(n,s,a*4),c=He.shiftPoint(c,r,i*4),E=He.shiftPoint(s,n,a*4),E=He.shiftPoint(E,t,i*4),[o,x,c,E]}isValid(e){return e.getX()>=0&&e.getX()<this.image.getWidth()&&e.getY()>0&&e.getY()<this.image.getHeight()}static sampleGrid(e,t,r,n,s,i,a){return Vt.getInstance().sampleGrid(e,i,a,.5,.5,i-.5,.5,i-.5,a-.5,.5,a-.5,t.getX(),t.getY(),s.getX(),s.getY(),n.getX(),n.getY(),r.getX(),r.getY())}transitionsBetween(e,t){let r=Math.trunc(e.getX()),n=Math.trunc(e.getY()),s=Math.trunc(t.getX()),i=Math.trunc(t.getY()),a=Math.abs(i-n)>Math.abs(s-r);if(a){let y=r;r=n,n=y,y=s,s=i,i=y}let o=Math.abs(s-r),c=Math.abs(i-n),u=-o/2,f=n<i?1:-1,x=r<s?1:-1,E=0,I=this.image.get(a?n:r,a?r:n);for(let y=r,N=n;y!==s;y+=x){let O=this.image.get(a?N:y,a?y:N);if(O!==I&&(E++,I=O),u+=c,u>0){if(N===i)break;N+=f,u-=o}}return E}}class Xt{constructor(){this.decoder=new ys}decode(e,t=null){let r,n;if(t!=null&&t.has(K.PURE_BARCODE)){const c=Xt.extractPureBits(e.getBlackMatrix());r=this.decoder.decode(c),n=Xt.NO_POINTS}else{const c=new He(e.getBlackMatrix()).detect();r=this.decoder.decode(c.getBits()),n=c.getPoints()}const s=r.getRawBytes(),i=new Je(r.getText(),s,8*s.length,n,re.DATA_MATRIX,G.currentTimeMillis()),a=r.getByteSegments();a!=null&&i.putMetadata(Ge.BYTE_SEGMENTS,a);const o=r.getECLevel();return o!=null&&i.putMetadata(Ge.ERROR_CORRECTION_LEVEL,o),i}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),r=e.getBottomRightOnBit();if(t==null||r==null)throw new B;const n=this.moduleSize(t,e);let s=t[1];const i=r[1];let a=t[0];const c=(r[0]-a+1)/n,u=(i-s+1)/n;if(c<=0||u<=0)throw new B;const f=n/2;s+=f,a+=f;const x=new De(c,u);for(let E=0;E<u;E++){const I=s+E*n;for(let y=0;y<c;y++)e.get(a+y*n,I)&&x.set(y,E)}return x}
vendor: 7,095 bytes, line 41
41static moduleSize(e,t){const r=t.getWidth();let n=e[0];const s=e[1];for(;n<r&&t.get(n,s);)n++;if(n===r)throw new B;const i=n-e[0];if(i===0)throw new B;return i}}Xt.NO_POINTS=[];class Ss extends Ft{constructor(e=500){super(new Xt,e)}}var lr;(function(d){d[d.L=0]="L",d[d.M=1]="M",d[d.Q=2]="Q",d[d.H=3]="H"})(lr||(lr={}));class Oe{constructor(e,t,r){this.value=e,this.stringValue=t,this.bits=r,Oe.FOR_BITS.set(r,this),Oe.FOR_VALUE.set(e,this)}getValue(){return this.value}getBits(){return this.bits}static fromString(e){switch(e){case"L":return Oe.L;case"M":return Oe.M;case"Q":return Oe.Q;case"H":return Oe.H;default:throw new M(e+"not available")}}toString(){return this.stringValue}equals(e){if(!(e instanceof Oe))return!1;const t=e;return this.value===t.value}static forBits(e){if(e<0||e>=Oe.FOR_BITS.size)throw new v;return Oe.FOR_BITS.get(e)}}Oe.FOR_BITS=new Map,Oe.FOR_VALUE=new Map,Oe.L=new Oe(lr.L,"L",1),Oe.M=new Oe(lr.M,"M",0),Oe.Q=new Oe(lr.Q,"Q",3),Oe.H=new Oe(lr.H,"H",2);class at{constructor(e){this.errorCorrectionLevel=Oe.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,t){return W.bitCount(e^t)}static decodeFormatInformation(e,t){const r=at.doDecodeFormatInformation(e,t);return r!==null?r:at.doDecodeFormatInformation(e^at.FORMAT_INFO_MASK_QR,t^at.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,t){let r=Number.MAX_SAFE_INTEGER,n=0;for(const s of at.FORMAT_INFO_DECODE_LOOKUP){const i=s[0];if(i===e||i===t)return new at(s[1]);let a=at.numBitsDiffering(e,i);a<r&&(n=s[1],r=a),e!==t&&(a=at.numBitsDiffering(t,i),a<r&&(n=s[1],r=a))}return r<=3?new at(n):null}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getDataMask(){return this.dataMask}hashCode(){return this.errorCorrectionLevel.getBits()<<3|this.dataMask}equals(e){if(!(e instanceof at))return!1;const t=e;return this.errorCorrectionLevel===t.errorCorrectionLevel&&this.dataMask===t.dataMask}}at.FORMAT_INFO_MASK_QR=21522,at.FORMAT_INFO_DECODE_LOOKUP=[Int32Array.from([21522,0]),Int32Array.from([20773,1]),Int32Array.from([24188,2]),Int32Array.from([23371,3]),Int32Array.from([17913,4]),Int32Array.from([16590,5]),Int32Array.from([20375,6]),Int32Array.from([19104,7]),Int32Array.from([30660,8]),Int32Array.from([29427,9]),Int32Array.from([32170,10]),Int32Array.from([30877,11]),Int32Array.from([26159,12]),Int32Array.from([25368,13]),Int32Array.from([27713,14]),Int32Array.from([26998,15]),Int32Array.from([5769,16]),Int32Array.from([5054,17]),Int32Array.from([7399,18]),Int32Array.from([6608,19]),Int32Array.from([1890,20]),Int32Array.from([597,21]),Int32Array.from([3340,22]),Int32Array.from([2107,23]),Int32Array.from([13663,24]),Int32Array.from([12392,25]),Int32Array.from([16177,26]),Int32Array.from([14854,27]),Int32Array.from([9396,28]),Int32Array.from([8579,29]),Int32Array.from([11994,30]),Int32Array.from([11245,31])];class T{constructor(e,...t){this.ecCodewordsPerBlock=e,this.ecBlocks=t}getECCodewordsPerBlock(){return this.ecCodewordsPerBlock}getNumBlocks(){let e=0;const t=this.ecBlocks;for(const r of t)e+=r.getCount();return e}getTotalECCodewords(){return this.ecCodewordsPerBlock*this.getNumBlocks()}getECBlocks(){return this.ecBlocks}}class C{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class q{constructor(e,t,...r){this.versionNumber=e,this.alignmentPatternCenters=t,this.ecBlocks=r;let n=0;const s=r[0].getECCodewordsPerBlock(),i=r[0].getECBlocks();for(const a of i)n+=a.getCount()*(a.getDataCodewords()+s);this.totalCodewords=n}getVersionNumber(){return this.versionNumber}getAlignmentPatternCenters(){return this.alignmentPatternCenters}getTotalCodewords(){return this.totalCodewords}getDimensionForVersion(){return 17+4*this.versionNumber}getECBlocksForLevel(e){return this.ecBlocks[e.getValue()]}static getProvisionalVersionForDimension(e){if(e%4!==1)throw new P;try{return this.getVersionForNumber((e-17)/4)}catch{throw new P}}static getVersionForNumber(e){if(e<1||e>40)throw new v;return q.VERSIONS[e-1]}static decodeVersionInformation(e){let t=Number.MAX_SAFE_INTEGER,r=0;for(let n=0;n<q.VERSION_DECODE_INFO.length;n++){const s=q.VERSION_DECODE_INFO[n];if(s===e)return q.getVersionForNumber(n+7);const i=at.numBitsDiffering(e,s);i<t&&(r=n+7,t=i)}return t<=3?q.getVersionForNumber(r):null}buildFunctionPattern(){const e=this.getDimensionForVersion(),t=new De(e);t.setRegion(0,0,9,9),t.setRegion(e-8,0,8,9),t.setRegion(0,e-8,9,8);const r=this.alignmentPatternCenters.length;for(let n=0;n<r;n++){const s=this.alignmentPatternCenters[n]-2;for(let i=0;i<r;i++)n===0&&(i===0||i===r-1)||n===r-1&&i===0||t.setRegion(this.alignmentPatternCenters[i]-2,s,5,5)}return t.setRegion(6,9,1,e-17),t.setRegion(9,6,e-17,1),this.versionNumber>6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t}toString(){return""+this.versionNumber}}q.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]),q.VERSIONS=[new q(1,new Int32Array(0),new T(7,new C(1,19)),new T(10,new C(1,16)),new T(13,new C(1,13)),new T(17,new C(1,9))),new q(2,Int32Array.from([6,18]),new T(10,new C(1,34)),new T(16,new C(1,28)),new T(22,new C(1,22)),new T(28,new C(1,16))),new q(3,Int32Array.from([6,22]),new T(15,new C(1,55)),new T(26,new C(1,44)),new T(18,new C(2,17)),new T(22,new C(2,13))),new q(4,Int32Array.from([6,26]),new T(20,new C(1,80)),new T(18,new C(2,32)),new T(26,new C(2,24)),new T(16,new C(4,9))),new q(5,Int32Array.from([6,30]),new T(26,new C(1,108)),new T(24,new C(2,43)),new T(18,new C(2,15),new C(2,16)),new T(22,new C(2,11),new C(2,12))),new q(6,Int32Array.from([6,34]),new T(18,new C(2,68)),new T(16,new C(4,27)),new T(24,new C(4,19)),new T(28,new C(4,15))),new q(7,Int32Array.from([6,22,38]),new T(20,new C(2,78)),new T(18,new C(4,31)),new T(18,new C(2,14),new C(4,15)),new T(26,new C(4,13),new C(1,14))),new q(8,Int32Array.from([6,24,42]),new T(24,new C(2,97)),new T(22,new C(2,38),new C(2,39)),new T(22,new C(4,18),new C(2,19)),new T(26,new C(4,14),new C(2,15))),new q(9,Int32Array.from([6,26,46]),new T(30,new C(2,116)),new T(22,new C(3,36),new C(2,37)),new T(20,new C(4,16),new C(4,17)),new T(24,new C(4,12),new C(4,13))),new q(10,Int32Array.from([6,28,50]),new T(18,new C(2,68),new C(2,69)),new T(26,new C(4,43),new C(1,44)),new T(24,new C(6,19),new C(2,20)),new T(28,new C(6,15),new C(2,16))),new q(11,Int32Array.from([6,30,54]),new T(20,new C(4,81)),new T(30,new C(1,50),new C(4,51)),new T(28,new C(4,22),new C(4,23)),new T(24,new C(3,12),new C(8,13))),new q(12,Int32Array.from([6,32,58]),new T(24,new C(2,92),new C(2,93)),new T(22,new C(6,36),new C(2,37)),new T(26,new C(4,20),new C(6,21)),new T(28,new C(7,14),new C(4,15))),new q(13,Int32Array.from([6,34,62]),new T(26,new C(4,107)),new T(22,new C(8,37),new C(1,38)),new T(24,new C(8,20),new C(4,21)),new T(22,new C(12,11),new C(4,12))),new q(14,Int32Array.from([6,26,46,66]),new T(30,new C(3,115),new C(1,116)),new T(24,new C(4,40),new C(5,41)
41),new T(20,new C(11,16),new C(5,17)),new T(24,new C(11,12),new C(5,13))),new q(15,Int32Array.from([6,26,48,70]),new T(22,new C(5,87),new C(1,88)),new T(24,new C(5,41),new C(5,42)),new T(30,new C(5,24),new C(7,25)),new T(24,new C(11,12),new C(7,13))),new q(16,Int32Array.from([6,26,50,74]),new T(24,new C(5,98),new C(1,99)),new T(28,new C(7,45),new C(3,46)),new T(24,new C(15,19),new C(2,20)),new T(30,new C(3,15),new C(13,16))),new q(17,Int32Array.from([6,30,54,78]),new T(28,new C(1,107),new C(5,108)),new T(28,new C(10,46),new C(1,47)),new T(28,new C(1,22),new C(15,23)),new T(28,new C(2,14),new C(17,15))),new q(18,Int32Array.from([6,30,56,82]),new T(30,new C(5,120),new C(1,121)),new T(26,new C(9,43),new C(4,44)),new T(28,new C(17,22),new C(1,23)),new T(28,new C(2,14),new C(19,15))),new q(19,Int32Array.from([6,30,58,86]),new T(28,new C(3,113),new C(4,114)),new T(26,new C(3,44),new C(11,45)),new T(26,new C(17,21),new C(4,22)),new T(26,new C(9,13),new C(16,14))),new q(20,Int32Array.from([6,34,62,90]),new T(28,new C(3,107),new C(5,108)),new T(26,new C(3,41),new C(13,42)),new T(30,new C(15,24),new C(5,25)),new T(28,new C(15,15),new C(10,16))),new q(21,Int32Array.from([6,28,50,72,94]),new T(28,new C(4,116),new C(4,117)),new T(26,new C(17,42)),new T(28,new C(17,22),new C(6,23)),new T(30,new C(19,16),new C(6,17))),new q(22,Int32Array.from([6,26,50,74,98]),new T(28,new C(2,111),new C(7,112)),new T(28,new C(17,46)),new T(30,new C(7,24),new C(16,25)),new T(24,new C(34,13))),new q(23,Int32Array.from([6,30,54,78,102]),new T(30,new C(4,121),new C(5,122)),new T(28,new C(4,47),new C(14,48)),new T(30,new C(11,24),new C(14,25)),new T(30,new C(16,15),new C(14,16))),new q(24,Int32Array.from([6,28,54,80,106]),new T(30,new C(6,117),new C(4,118)),new T(28,new C(6,45),new C(14,46)),new T(30,new C(11,24),new C(16,25)),new T(30,new C(30,16),new C(2,17))),new q(25,Int32Array.from([6,32,58,84,110]),new T(26,new C(8,106),new C(4,107)),new T(28,new C(8,47),new C(13,48)),new T(30,new C(7,24),new C(22,25)),new T(30,new C(22,15),new C(13,16))),new q(26,Int32Array.from([6,30,58,86,114]),new T(28,new C(10,114),new C(2,115)),new T(28,new C(19,46),new C(4,47)),new T(28,new C(28,22),new C(6,23)),new T(30,new C(33,16),new C(4,17))),new q(27,Int32Array.from([6,34,62,90,118]),new T(30,new C(8,122),new C(4,123)),new T(28,new C(22,45),new C(3,46)),new T(30,new C(8,23),new C(26,24)),new T(30,new C(12,15),new C(28,16))),new q(28,Int32Array.from([6,26,50,74,98,122]),new T(30,new C(3,117),new C(10,118)),new T(28,new C(3,45),new C(23,46)),new T(30,new C(4,24),new C(31,25)),new T(30,new C(11,15),new C(31,16))),new q(29,Int32Array.from([6,30,54,78,102,126]),new T(30,new C(7,116),new C(7,117)),new T(28,new C(21,45),new C(7,46)),new T(30,new C(1,23),new C(37,24)),new T(30,new C(19,15),new C(26,16))),new q(30,Int32Array.from([6,26,52,78,104,130]),new T(30,new C(5,115),new C(10,116)),new T(28,new C(19,47),new C(10,48)),new T(30,new C(15,24),new C(25,25)),new T(30,new C(23,15),new C(25,16))),new q(31,Int32Array.from([6,30,56,82,108,134]),new T(30,new C(13,115),new C(3,116)),new T(28,new C(2,46),new C(29,47)),new T(30,new C(42,24),new C(1,25)),new T(30,new C(23,15),new C(28,16))),new q(32,Int32Array.from([6,34,60,86,112,138]),new T(30,new C(17,115)),new T(28,new C(10,46),new C(23,47)),new T(30,new C(10,24),new C(35,25)),new T(30,new C(19,15),new C(35,16))),new q(33,Int32Array.from([6,30,58,86,114,142]),new T(30,new C(17,115),new C(1,116)),new T(28,new C(14,46),new C(21,47)),new T(30,new C(29,24),new C(19,25)),new T(30,new C(11,15),new C(46,16))),new q(34,Int32Array.from([6,34,62,90,118,146]),new T(30,new C(13,115),new C(6,116)),new T(28,new C(14,46),new C(23,47)),new T(30,new C(44,24),new C(7,25)),new T(30,new C(59,16),new C(1,17))),new q(35,Int32Array.from([6,30,54,78,102,126,150]),new T(30,new C(12,121),new C(7,122)),new T(28,new C(12,47),new C(26,48)),new T(30,new C(39,24),new C(14,25)),new T(30,new C(22,15),new C(41,16))),new q(36,Int32Array.from([6,24,50,76,102,128,154]),new T(30,new C(6,121),new C(14,122)),new T(28,new C(6,47),new C(34,48)),new T(30,new C(46,24),new C(10,25)),new T(30,new C(2,15),new C(64,16))),new q(37,Int32Array.from([6,28,54,80,106,132,158]),new T(30,new C(17,122),new C(4,123)),new T(28,new C(29,46),new C(14,47)),new T(30,new C(49,24),new C(10,25)),new T(30,new C(24,15),new C(46,16))),new q(38,Int32Array.from([6,32,58,84,110,136,162]),new T(30,new C(4,122),new C(18,123)),new T(28,new C(13,46),new C(32,47)),new T(30,new C(48,24),new C(14,25)),new T(30,new C(42,15),new C(32,16))),new q(39,Int32Array.from([6,26,54,82,110,138,166]),new T(30,new C(20,117),new C(4,118)),new T(28,new C(40,47),new C(7,48)),new T(30,new C(43,24),new C(22,25)),new T(30,new C(10,15),new C(67,16))),new q(40,Int32Array.from([6,30,58,86,114,142,170]),new T(30,new C(19,118),new C(6,119)),new T(28,new C(18,47),new C(31,48)),new T(30,new C(34,24),new C(34,25)),new T(30,new C(20,15),new C(61,16)))];var Qe;(function(d){d[d.DATA_MASK_000=0]="DATA_MASK_000",d[d.DATA_MASK_001=1]="DATA_MASK_001",d[d.DATA_MASK_010=2]="DATA_MASK_010",d[d.DATA_MASK_011=3]="DATA_MASK_011",d[d.DATA_MASK_100=4]="DATA_MASK_100",d[d.DATA_MASK_101=5]="DATA_MASK_101",d[d.DATA_MASK_110=6]="DATA_MASK_110",d[d.DATA_MASK_111=7]="DATA_MASK_111"})(Qe||(Qe={}));class Et{constructor(e,t){this.value=e,this.isMasked=t}unmaskBitMatrix(e,t){for(let r=0;r<t;r++)for(let n=0;n<t;n++)this.isMasked(r,n)&&e.flip(n,r)}}Et.values=new Map([[Qe.DATA_MASK_000,new Et(Qe.DATA_MASK_000,(d,e)=>(d+e&1)===0)],[Qe.DATA_MASK_001,new Et(Qe.DATA_MASK_001,(d,e)=>
41(d&1)===0)],[Qe.DATA_MASK_010,new Et(Qe.DATA_MASK_010,(d,e)=>e%3===0)],[Qe.DATA_MASK_011,new Et(Qe.DATA_MASK_011,(d,e)=>(d+e)%3===0)],[Qe.DATA_MASK_100,new Et(Qe.DATA_MASK_100,(d,e)=>(Math.floor(d/2)+Math.floor(e/3)&1)===0)],[Qe.DATA_MASK_101,new Et(Qe.DATA_MASK_101,(d,e)=>d*e%6===0)],[Qe.DATA_MASK_110,new Et(Qe.DATA_MASK_110,(d,e)=>d*e%6<3)],[Qe.DATA_MASK_111,new Et(Qe.DATA_MASK_111,(d,e)=>(d+e+d*e%3&1)===0)]]);class Ns{constructor(e){const t=e.getHeight();if(t<21||(t&3)!==1)throw new P;this.bitMatrix=e}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let e=0;for(let s=0;s<6;s++)e=this.copyBit(s,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let s=5;s>=0;s--)e=this.copyBit(8,s,e);const t=this.bitMatrix.getHeight();let r=0;const n=t-7;for(let s=t-1;s>=n;s--)r=this.copyBit(8,s,r);for(let s=t-8;s<t;s++)r=this.copyBit(s,8,r);if(this.parsedFormatInfo=at.decodeFormatInformation(e,r),this.parsedFormatInfo!==null)return this.parsedFormatInfo;throw new P}readVersion(){if(this.parsedVersion!==null&&this.parsedVersion!==void 0)return this.parsedVersion;const e=this.bitMatrix.getHeight(),t=Math.floor((e-17)/4);if(t<=6)return q.getVersionForNumber(t);let r=0;const n=e-11;for(let i=5;i>=0;i--)for(let a=e-9;a>=n;a--)r=this.copyBit(a,i,r);let s=q.decodeVersionInformation(r);if(s!==null&&s.getDimensionForVersion()===e)return this.parsedVersion=s,s;r=0;for(let i=5;i>=0;i--)for(let a=e-9;a>=n;a--)r=this.copyBit(i,a,r);if(s=q.decodeVersionInformation(r),s!==null&&s.getDimensionForVersion()===e)return this.parsedVersion=s,s;throw new P}copyBit(e,t,r){return(this.isMirror?this.bitMatrix.get(t,e):this.bitMatrix.get(e,t))?r<<1|1:r<<1}readCodewords(){const e=this.readFormatInformation(),t=this.readVersion(),r=Et.values.get(e.getDataMask()),n=this.bitMatrix.getHeight();r.unmaskBitMatrix(this.bitMatrix,n);const s=t.buildFunctionPattern();let i=!0;const a=new Uint8Array(t.getTotalCodewords());let o=0,c=0,u=0;for(let f=n-1;f>0;f-=2){f===6&&f--;for(let x=0;x<n;x++){const E=i?n-1-x:x;for(let I=0;I<2;I++)s.get(f-I,E)||(u++,c<<=1,this.bitMatrix.get(f-I,E)&&(c|=1),u===8&&(a[o++]=c,u=0,c=0))}i=!i}if(o!==t.getTotalCodewords())throw new P;return a}remask(){if(this.parsedFormatInfo===null)return;const e=Et.values[this.parsedFormatInfo.getDataMask()],t=this.bitMatrix.getHeight();e.unmaskBitMatrix(this.bitMatrix,t)}setMirror(e){this.parsedVersion=null,this.parsedFormatInfo=null,this.isMirror=e}mirror(){const e=this.bitMatrix;for(let t=0,r=e.getWidth();t<r;
41t++)for(let n=t+1,s=e.getHeight();n<s;n++)e.get(t,n)!==e.get(n,t)&&(e.flip(n,t),e.flip(t,n))}}class tn{constructor(e,t){this.numDataCodewords=e,this.codewords=t}static getDataBlocks(e,t,r){if(e.length!==t.getTotalCodewords())throw new v;const n=t.getECBlocksForLevel(r);let s=0;const i=n.getECBlocks();for(const I of i)s+=I.getCount();const a=new Array(s);let o=0;for(const I of i)for(let y=0;y<I.getCount();y++){const N=I.getDataCodewords(),O=n.getECCodewordsPerBlock()+N;a[o++]=new tn(N,new Uint8Array(O))}const c=a[0].codewords.length;let u=a.length-1;for(;u>=0&&a[u].codewords.length!==c;)u--;u++;const f=c-n.getECCodewordsPerBlock();let x=0;for(let I=0;I<f;I++)for(let y=0;y<o;y++)a[y].codewords[I]=e[x++];for(let I=u;I<o;I++)a[I].codewords[f]=e[x++];const E=a[0].codewords.length;for(let I=f;I<E;I++)for(let y=0;y<o;y++){const N=y<u?I:I+1;a[y].codewords[N]=e[x++]}return a}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}var bt;(function(d){d[d.TERMINATOR=0]="TERMINATOR",d[d.NUMERIC=1]="NUMERIC",d[d.ALPHANUMERIC=2]="ALPHANUMERIC",d[d.STRUCTURED_APPEND=3]="STRUCTURED_APPEND",d[d.BYTE=4]="BYTE",d[d.ECI=5]="ECI",d[d.KANJI=6]="KANJI",d[d.FNC1_FIRST_POSITION=7]="FNC1_FIRST_POSITION",d[d.FNC1_SECOND_POSITION=8]="FNC1_SECOND_POSITION",d[d.HANZI=9]="HANZI"})(bt||(bt={}));class ne{constructor(e,t,r,n){this.value=e,this.stringValue=t,this.characterCountBitsForVersions=r,this.bits=n,ne.FOR_BITS.set(n,this),ne.FOR_VALUE.set(e,this)}static forBits(e){const t=ne.FOR_BITS.get(e);if(t===void 0)throw new v;return t}getCharacterCountBits(e){const t=e.getVersionNumber();let r;return t<=9?r=0:t<=26?r=1:r=2,this.characterCountBitsForVersions[r]}getValue(){return this.value}getBits(){return this.bits}equals(e){if(!(e instanceof ne))return!1;const t=e;return this.value===t.value}toString(){return this.stringValue}}ne.FOR_BITS=new Map,ne.FOR_VALUE=new Map,ne.TERMINATOR=new ne(bt.TERMINATOR,"TERMINATOR",Int32Array.from([0,0,0]),0),ne.NUMERIC=new ne(bt.NUMERIC,"NUMERIC",Int32Array.from([10,12,14]),1),ne.ALPHANUMERIC=new ne(bt.ALPHANUMERIC,"ALPHANUMERIC",Int32Array.from([9,11,13]),2),ne.STRUCTURED_APPEND=new ne(bt.STRUCTURED_APPEND,"STRUCTURED_APPEND",Int32Array.from([0,0,0]),3),ne.BYTE=new ne(bt.BYTE,"BYTE",Int32Array.from([8,16,16]),4),ne.ECI=new ne(bt.ECI,"ECI",Int32Array.from([0,0,0]),7),ne.KANJI=new ne(bt.KANJI,"KANJI",Int32Array.from([8,10,12]),8),ne.FNC1_FIRST_POSITION=new ne(bt.FNC1_FIRST_POSITION,"FNC1_FIRST_POSITION",Int32Array.from([0,0,0]),5),ne.FNC1_SECOND_POSITION=new ne(bt.FNC1_SECOND_POSITION,"FNC1_SECOND_POSITION",Int32Array.from([0,0,0]),9),ne.HANZI=new ne(bt.HANZI,"HANZI",Int32Array.from([8,10,12]),13);class Pe{static decode(e,t,r,n){const s=new en(e);let i=new pe;const a=new Array;let o=-1,c=-1;try{let u=null,f=!1,x;do{if(s.available()<4)x=ne.TERMINATOR;else{const E=s.readBits(4);x=ne.forBits(E)}switch(x){case ne.TERMINATOR:break;case ne.FNC1_FIRST_POSITION:case ne.FNC1_SECOND_POSITION:f=!0;break;case ne.STRUCTURED_APPEND:if(s.available()<16)throw new P;o=s.readBits(8),c=s.readBits(8);break;case ne.ECI:const E=Pe.parseECIValue(s);if(u=F.getCharacterSetECIByValue(E),u===null)throw new P;break;case ne.HANZI:const I=s.readBits(4),y=s.readBits(x.getCharacterCountBits(t));I===Pe.GB2312_SUBSET&&Pe.decodeHanziSegment(s,i,y);break;default:const N=s.readBits(x.getCharacterCountBits(t));switch(x){case ne.NUMERIC:Pe.decodeNumericSegment(s,i,N);break;case ne.ALPHANUMERIC:Pe.decodeAlphanumericSegment(s,i,N,f);break;case ne.BYTE:Pe.decodeByteSegment(s,i,N,u,a,n);break;case ne.KANJI:Pe.decodeKanjiSegment(s,i,N);break;default:throw new P}break}}while(x!==ne.TERMINATOR)}catch{throw new P}return new de(e,i.toString(),a.length===0?null:a,r===null?null:r.toString(),o,c)}static decodeHanziSegment(e,t,r){if(r*13>e.available())throw new P;const n=new Uint8Array(2*r);let s=0;for(;r>0;){const i=e.readBits(13);let a=i/96<<8&4294967295|i%96;a<959?a+=41377:a+=42657,n[s]=a>>8&255,n[s+1]=a&255,s+=2,r--}try{t.append(Se.decode(n,te.GB2312))}catch(i){throw new P(i)}}static decodeKanjiSegment(e,t,r){if(r*13>e.available())throw new P;const n=new Uint8Array(2*r);let s=0;for(;r>0;){const i=e.readBits(13);let a=i/192<<8&4294967295|i%192;a<7936?a+=33088:a+=49472,n[s]=a>>8,n[s+1]=a,s+=2,r--}try{t.append(Se.decode(n,te.SHIFT_JIS))}catch(i){throw new P(i)}}static decodeByteSegment(e,t,r,n,s,i){if(8*r>e.available())throw new P;const a=new Uint8Array(r);for(let c=0;c<r;c++)a[c]=e.readBits(8);let o;n===null?o=te.guessEncoding(a,i):o=n.getName();try{t.append(Se.decode(a,o))}catch(c){throw new P(c)}s.push(a)}static toAlphaNumericChar(e){if(e>=Pe.ALPHANUMERIC_CHARS.length)throw new P;return Pe.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,t,r,n){const s=t.length();for(;r>1;){if(e.available()<11)throw new P;const i=e.readBits(11);t.append(Pe.toAlphaNumericChar(Math.floor(i/45))),t.append(Pe.toAlphaNumericChar(i%45)),r-=2}if(r===1){if(e.available()<6)throw new P;t.append(Pe.toAlphaNumericChar(e.readBits(6)))}if(n)for(let i=s;i<t.length();i++)t.charAt(i)==="%"&&(i<t.length()-1&&t.charAt(i+1)==="%"?t.deleteCharAt(i+1):t.setCharAt(i,"�"))}static decodeNumericSegment(e,t,r){for(;r>=3;){if(e.available()<10)throw new P;const n=e.readBits(10);if(n>=1e3)throw new P;t.append(Pe.toAlphaNumericChar(Math.floor(n/100))),t.append(Pe.toAlphaNumericChar(Math.floor(n/10)%10)),t.append(Pe.toAlphaNumericChar(n%10)),r-=3}if(r===2){if(e.available()<7)throw new P;const n=e.readBits(7);if(n>=100)throw new P;t.append(Pe.toAlphaNumericChar(Math.floor(n/10))),t.append(Pe.toAlphaNumericChar(n%10))}else if(r===1){if(e.available()<4)throw new P;const n=e.readBits(4);if(n>=10)throw new P;t.append(Pe.toAlphaNumericChar(n))}}static parseECIValue(e){const t=e.readBits(8);if(!(t&128))return t&127;
41if((t&192)===128){const r=e.readBits(8);return(t&63)<<8&4294967295|r}if((t&224)===192){const r=e.readBits(16);return(t&31)<<16&4294967295|r}throw new P}}Pe.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Pe.GB2312_SUBSET=1;class _n{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||e===null||e.length<3)return;const t=e[0];e[0]=e[2],e[2]=t}}class Ts{constructor(){this.rsDecoder=new wr(ue.QR_CODE_FIELD_256)}decodeBooleanArray(e,t){return this.decodeBitMatrix(De.parseFromBooleanArray(e),t)}decodeBitMatrix(e,t){const r=new Ns(e);let n=null;try{return this.decodeBitMatrixParser(r,t)}catch(s){n=s}try{r.remask(),r.setMirror(!0),r.readVersion(),r.readFormatInformation(),r.mirror();const s=this.decodeBitMatrixParser(r,t);return s.setOther(new _n(!0)),s}catch(s){throw n!==null?n:s}}decodeBitMatrixParser(e,t){const r=e.readVersion(),n=e.readFormatInformation().getErrorCorrectionLevel(),s=e.readCodewords(),i=tn.getDataBlocks(s,r,n);let a=0;for(const u of i)a+=u.getNumDataCodewords();const o=new Uint8Array(a);let c=0;for(const u of i){const f=u.getCodewords(),x=u.getNumDataCodewords();this.correctErrors(f,x);for(let E=0;E<x;E++)o[c++]=f[E]}return Pe.decode(o,r,n,t)}correctErrors(e,t){const r=new Int32Array(e);try{this.rsDecoder.decode(r,e.length-t)}catch{throw new J}for(let n=0;n<t;n++)e[n]=r[n]}}class rn extends Z{constructor(e,t,r){super(e,t),this.estimatedModuleSize=r}aboutEquals(e,t,r){if(Math.abs(t-this.getY())<=e&&Math.abs(r-this.getX())<=e){const n=Math.abs(e-this.estimatedModuleSize);return n<=1||n<=this.estimatedModuleSize}return!1}combineEstimate(e,t,r){const n=(this.getX()+t)/2,s=(this.getY()+e)/2,i=(this.estimatedModuleSize+r)/2;return new rn(n,s,i)}}class Lr{constructor(e,t,r,n,s,i,a){this.image=e,this.startX=t,this.startY=r,this.width=n,this.height=s,this.moduleSize=i,this.resultPointCallback=a,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(3)}find(){const e=this.startX,t=this.height,r=this.width,n=e+r,s=this.startY+t/2,i=new Int32Array(3),a=this.image;for(let o=0;o<t;o++){const c=s+(o&1?-Math.floor((o+1)/2):Math.floor((o+1)/2));i[0]=0,i[1]=0,i[2]=0;let u=e;for(;u<n&&!a.get(u,c);)u++;let f=0;for(;u<n;){if(a.get(u,c))if(f===1)i[1]++;else if(f===2){if(this.foundPatternCross(i)){const x=this.handlePossibleCenter(i,c,u);if(x!==null)return x}i[0]=i[2],i[1]=1,i[2]=0,f=1}else i[++f]++;else f===1&&f++,i[f]++;u++}if(this.foundPatternCross(i)){const x=this.handlePossibleCenter(i,c,n);if(x!==null)return x}}if(this.possibleCenters.length!==0)return this.possibleCenters[0];throw new B}static centerFromEnd(e,t){return t-e[2]-e[1]/2}foundPatternCross(e){const t=this.moduleSize,r=t/2;for(let n=0;n<3;n++)if(Math.abs(t-e[n])>=r)return!1;return!0}crossCheckVertical(e,t,r,n){const s=this.image,i=s.getHeight(),a=this.crossCheckStateCount;a[0]=0,a[1]=0,a[2]=0;let o=e;for(;o>=0&&s.get(t,o)&&a[1]<=r;)a[1]++,o--;if(o<0||a[1]>r)return NaN;for(;o>=0&&!s.get(t,o)&&a[0]<=r;)a[0]++,o--;if(a[0]>r)return NaN;for(o=e+1;o<i&&s.get(t,o)&&a[1]<=r;)a[1]++,o++;if(o===i||a[1]>r)return NaN;for(;o<i&&!s.get(t,o)&&a[2]<=r;)a[2]++,o++;if(a[2]>r)return NaN;const c=a[0]+a[1]+a[2];return 5*Math.abs(c-n)>=2*n?NaN:this.foundPatternCross(a)?Lr.centerFromEnd(a,o):NaN}handlePossibleCenter(e,t,r){const n=e[0]+e[1]+e[2],s=Lr.centerFromEnd(e,r),i=this.crossCheckVertical(t,s,2*e[1],n);if(!isNaN(i)){const a=(e[0]+e[1]+e[2])/3;for(const c of this.possibleCenters)if(c.aboutEquals(a,i,s))return c.combineEstimate(i,s,a);const o=new rn(s,i,a);this.possibleCenters.push(o),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(o)}return null}}class nn extends Z{constructor(e,t,r,n){super(e,t),this.estimatedModuleSize=r,this.count=n,n===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,t,r){if(Math.abs(t-this.getY())<=e&&Math.abs(r-this.getX())<=e){const n=Math.abs(e-this.estimatedModuleSize);return n<=1||n<=this.estimatedModuleSize}return!1}combineEstimate(e,t,r){const n=this.count+1,s=(this.count*this.getX()+t)/n,i=(this.count*this.getY()+e)/n,a=(this.count*this.estimatedModuleSize+r)/n;return new nn(s,i,a,n)}}class _s{constructor(e){this.bottomLeft=e[0],this.topLeft=e[1],this.topRight=e[2]}getBottomLeft(){return this.bottomLeft}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}}class qe{constructor(e,t){this.image=e,this.resultPointCallback=t,this.possibleCenters=[],this.crossCheckStateCount=new Int32Array(5),this.resultPointCallback=t}getImage(){return this.image}getPossibleCenters(){return this.possibleCenters}find(e){const t=e!=null&&e.get(K.TRY_HARDER)!==void 0,r=e!=null&&e.get(K.PURE_BARCODE)!==void 0,n=this.image,s=n.getHeight(),i=n.getWidth();let a=Math.floor(3*s/(4*qe.MAX_MODULES));(a<qe.MIN_SKIP||t)&&(a=qe.MIN_SKIP);let o=!1;const c=new Int32Array(5);for(let f=a-1;f<s&&!o;f+=a){c[0]=0,c[1]=0,c[2]=0,c[3]=0,c[4]=0;let x=0;for(let E=0;E<i;E++)if(n.get(E,f))(x&1)===1&&x++,c[x]++;else if(x&1)c[x]++;
vendor: 2,191 bytes, line 41
41else if(x===4)if(qe.foundPatternCross(c)){if(this.handlePossibleCenter(c,f,E,r)===!0)if(a=2,this.hasSkipped===!0)o=this.haveMultiplyConfirmedCenters();else{const y=this.findRowSkip();y>c[2]&&(f+=y-c[2]-a,E=i-1)}else{c[0]=c[2],c[1]=c[3],c[2]=c[4],c[3]=1,c[4]=0,x=3;continue}x=0,c[0]=0,c[1]=0,c[2]=0,c[3]=0,c[4]=0}else c[0]=c[2],c[1]=c[3],c[2]=c[4],c[3]=1,c[4]=0,x=3;else c[++x]++;qe.foundPatternCross(c)&&this.handlePossibleCenter(c,f,i,r)===!0&&(a=c[0],this.hasSkipped&&(o=this.haveMultiplyConfirmedCenters()))}const u=this.selectBestPatterns();return Z.orderBestPatterns(u),new _s(u)}static centerFromEnd(e,t){return t-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let t=0;for(let s=0;s<5;s++){const i=e[s];if(i===0)return!1;t+=i}if(t<7)return!1;const r=t/7,n=r/2;return Math.abs(r-e[0])<n&&Math.abs(r-e[1])<n&&Math.abs(3*r-e[2])<3*n&&Math.abs(r-e[3])<n&&Math.abs(r-e[4])<n}getCrossCheckStateCount(){const e=this.crossCheckStateCount;return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e}crossCheckDiagonal(e,t,r,n){const s=this.getCrossCheckStateCount();let i=0;const a=this.image;for(;e>=i&&t>=i&&a.get(t-i,e-i);)s[2]++,i++;if(e<i||t<i)return!1;for(;e>=i&&t>=i&&!a.get(t-i,e-i)&&s[1]<=r;)s[1]++,i++;if(e<i||t<i||s[1]>r)return!1;for(;e>=i&&t>=i&&a.get(t-i,e-i)&&s[0]<=r;)s[0]++,i++;if(s[0]>r)return!1;const o=a.getHeight(),c=a.getWidth();for(i=1;e+i<o&&t+i<c&&a.get(t+i,e+i);)s[2]++,i++;if(e+i>=o||t+i>=c)return!1;for(;e+i<o&&t+i<c&&!a.get(t+i,e+i)&&s[3]<r;)s[3]++,i++;if(e+i>=o||t+i>=c||s[3]>=r)return!1;for(;e+i<o&&t+i<c&&a.get(t+i,e+i)&&s[4]<r;)s[4]++,i++;if(s[4]>=r)return!1;const u=s[0]+s[1]+s[2]+s[3]+s[4];return Math.abs(u-n)<2*n&&qe.foundPatternCross(s)}crossCheckVertical(e,t,r,n){const s=this.image,i=s.getHeight(),a=this.getCrossCheckStateCount();let o=e;for(;o>=0&&s.get(t,o);)a[2]++,o--;if(o<0)return NaN;for(;o>=0&&!s.get(t,o)&&a[1]<=r;)a[1]++,o--;if(o<0||a[1]>r)return NaN;for(;o>=0&&s.get(t,o)&&a[0]<=r;)a[0]++,o--;if(a[0]>r)return NaN;for(o=e+1;o<i&&s.get(t,o);)a[2]++,o++;if(o===i)return NaN;for(;o<i&&!s.get(t,o)&&a[3]<r;)a[3]++,o++;if(o===i||a[3]>=r)return NaN;for(;o<i&&s.get(t,o)&&a[4]<r;)a[4]++,o++;if(a[4]>=r)return NaN;const c=a[0]+a[1]+a[2]+a[3]+a[4];return 5*Math.abs(c-n)>
vendor: 5,606 bytes, line 41
41=2*n?NaN:qe.foundPatternCross(a)?qe.centerFromEnd(a,o):NaN}crossCheckHorizontal(e,t,r,n){const s=this.image,i=s.getWidth(),a=this.getCrossCheckStateCount();let o=e;for(;o>=0&&s.get(o,t);)a[2]++,o--;if(o<0)return NaN;for(;o>=0&&!s.get(o,t)&&a[1]<=r;)a[1]++,o--;if(o<0||a[1]>r)return NaN;for(;o>=0&&s.get(o,t)&&a[0]<=r;)a[0]++,o--;if(a[0]>r)return NaN;for(o=e+1;o<i&&s.get(o,t);)a[2]++,o++;if(o===i)return NaN;for(;o<i&&!s.get(o,t)&&a[3]<r;)a[3]++,o++;if(o===i||a[3]>=r)return NaN;for(;o<i&&s.get(o,t)&&a[4]<r;)a[4]++,o++;if(a[4]>=r)return NaN;const c=a[0]+a[1]+a[2]+a[3]+a[4];return 5*Math.abs(c-n)>=n?NaN:qe.foundPatternCross(a)?qe.centerFromEnd(a,o):NaN}handlePossibleCenter(e,t,r,n){const s=e[0]+e[1]+e[2]+e[3]+e[4];let i=qe.centerFromEnd(e,r),a=this.crossCheckVertical(t,Math.floor(i),e[2],s);if(!isNaN(a)&&(i=this.crossCheckHorizontal(Math.floor(i),Math.floor(a),e[2],s),!isNaN(i)&&(!n||this.crossCheckDiagonal(Math.floor(a),Math.floor(i),e[2],s)))){const o=s/7;let c=!1;const u=this.possibleCenters;for(let f=0,x=u.length;f<x;f++){const E=u[f];if(E.aboutEquals(o,a,i)){u[f]=E.combineEstimate(a,i,o),c=!0;break}}if(!c){const f=new nn(i,a,o);u.push(f),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(f)}return!0}return!1}findRowSkip(){if(this.possibleCenters.length<=1)return 0;let t=null;for(const r of this.possibleCenters)if(r.getCount()>=qe.CENTER_QUORUM)if(t==null)t=r;else return this.hasSkipped=!0,Math.floor((Math.abs(t.getX()-r.getX())-Math.abs(t.getY()-r.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let e=0,t=0;const r=this.possibleCenters.length;for(const i of this.possibleCenters)i.getCount()>=qe.CENTER_QUORUM&&(e++,t+=i.getEstimatedModuleSize());if(e<3)return!1;const n=t/r;let s=0;for(const i of this.possibleCenters)s+=Math.abs(i.getEstimatedModuleSize()-n);return s<=.05*t}selectBestPatterns(){const e=this.possibleCenters.length;if(e<3)throw new B;const t=this.possibleCenters;let r;if(e>3){let n=0,s=0;for(const o of this.possibleCenters){const c=o.getEstimatedModuleSize();n+=c,s+=c*c}r=n/e;let i=Math.sqrt(s/e-r*r);t.sort((o,c)=>{const u=Math.abs(c.getEstimatedModuleSize()-r),f=Math.abs(o.getEstimatedModuleSize()-r);return u<f?-1:u>f?1:0});const a=Math.max(.2*r,i);for(let o=0;o<t.length&&t.length>3;o++){const c=t[o];Math.abs(c.getEstimatedModuleSize()-r)>a&&(t.splice(o,1),o--)}}if(t.length>3){let n=0;for(const s of t)n+=s.getEstimatedModuleSize();r=n/t.length,t.sort((s,i)=>{if(i.getCount()===s.getCount()){const a=Math.abs(i.getEstimatedModuleSize()-r),o=Math.abs(s.getEstimatedModuleSize()-r);return a<o?1:a>o?-1:0}else return i.getCount()-s.getCount()}),t.splice(3)}return[t[0],t[1],t[2]]}}qe.CENTER_QUORUM=2,qe.MIN_SKIP=3,qe.MAX_MODULES=57;class pr{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(K.NEED_RESULT_POINT_CALLBACK);const r=new qe(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(r)}processFinderPatternInfo(e){const t=e.getTopLeft(),r=e.getTopRight(),n=e.getBottomLeft(),s=this.calculateModuleSize(t,r,n);if(s<1)throw new B("No pattern found in proccess finder.");const i=pr.computeDimension(t,r,n,s),a=q.getProvisionalVersionForDimension(i),o=a.getDimensionForVersion()-7;let c=null;if(a.getAlignmentPatternCenters().length>0){const E=r.getX()-t.getX()+n.getX(),I=r.getY()-t.getY()+n.getY(),y=1-3/o,N=Math.floor(t.getX()+y*(E-t.getX())),O=Math.floor(t.getY()+y*(I-t.getY()));for(let U=4;U<=16;U<<=1)try{c=this.findAlignmentInRegion(s,N,O,U);break}catch(j){if(!(j instanceof B))throw j}}const u=pr.createTransform(t,r,n,c,i),f=pr.sampleGrid(this.image,u,i);let x;return c===null?x=[n,t,r]:x=[n,t,r,c],new Dr(f,x)}static createTransform(e,t,r,n,s){const i=s-3.5;let a,o,c,u;return n!==null?(a=n.getX(),o=n.getY(),c=i-3,u=c):(a=t.getX()-e.getX()+r.getX(),o=t.getY()-e.getY()+r.getY(),c=i,u=i),Nt.quadrilateralToQuadrilateral(3.5,3.5,i,3.5,c,u,3.5,i,e.getX(),e.getY(),t.getX(),t.getY(),a,o,r.getX(),r.getY())}static sampleGrid(e,t,r){return Vt.getInstance().sampleGridWithTransform(e,r,r,t)}static computeDimension(e,t,r,n){const s=we.round(Z.distance(e,t)/n),i=we.round(Z.distance(e,r)/n);let a=Math.floor((s+i)/2)+7;switch(a&3){case 0:a++;break;case 2:a--;break;case 3:throw new B("Dimensions could be not found.")}return a}calculateModuleSize(e,t,r){return(this.calculateModuleSizeOneWay(e,t)+this.calculateModuleSizeOneWay(e,r))/2}calculateModuleSizeOneWay(e,t){const r=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY())),n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(r)?n/7:isNaN(n)?r/7:(r+n)/14}sizeOfBlackWhiteBlackRunBothWays(e,t,r,n){let s=this.sizeOfBlackWhiteBlackRun(e,t,r,n),i=1,a=e-(r-e);a<0?(i=e/(e-a),a=0):a>=this.image.getWidth()&&(i=(this.image.getWidth()-1-e)/(a-e),a=this.image.getWidth()-1);let o=Math.floor(t-(n-t)*i);return i=1,o<0?(i=t/(t-o),o=0):o>=this.image.getHeight()&&(i=(this.image.getHeight()-1-t)/(o-t),o=this.image.getHeight()-1),a=Math.floor(e+(a-e)*i),s+=this.sizeOfBlackWhiteBlackRun(e,t,a,o),s-1}sizeOfBlackWhiteBlackRun(e,t,r,n){const s=Math.abs(n-t)>Math.abs(r-e);if(s){let E=e;e=t,t=E,E=r,r=n,n=E}const i=Math.abs(r-e),a=Math.abs(n-t);let o=-i/2;const c=e<r?1:-1,u=t<n?1:-1;let f=0;const x=r+c;for(let E=e,I=t;E!==x;E+=c){const y=s?I:E,N=s?E:I;if(f===1===this.image.get(y,N)){if(f===2)return we.distance(E,I,e,t);f++}if(o+=a,o>
410){if(I===n)break;I+=u,o-=i}}return f===2?we.distance(r+c,n,e,t):NaN}findAlignmentInRegion(e,t,r,n){const s=Math.floor(n*e),i=Math.max(0,t-s),a=Math.min(this.image.getWidth()-1,t+s);if(a-i<e*3)throw new B("Alignment top exceeds estimated module size.");const o=Math.max(0,r-s),c=Math.min(this.image.getHeight()-1,r+s);if(c-o<e*3)throw new B("Alignment bottom exceeds estimated module size.");return new Lr(this.image,i,o,a-i,c-o,e,this.resultPointCallback).find()}}class Yt{constructor(){this.decoder=new Ts}getDecoder(){return this.decoder}decode(e,t){let r,n;if(t!=null&&t.get(K.PURE_BARCODE)!==void 0){const o=Yt.extractPureBits(e.getBlackMatrix());r=this.decoder.decodeBitMatrix(o,t),n=Yt.NO_POINTS}else{const o=new pr(e.getBlackMatrix()).detect(t);r=this.decoder.decodeBitMatrix(o.getBits(),t),n=o.getPoints()}r.getOther()instanceof _n&&r.getOther().applyMirroredCorrection(n);const s=new Je(r.getText(),r.getRawBytes(),void 0,n,re.QR_CODE,void 0),i=r.getByteSegments();i!==null&&s.putMetadata(Ge.BYTE_SEGMENTS,i);const a=r.getECLevel();return a!==null&&s.putMetadata(Ge.ERROR_CORRECTION_LEVEL,a),r.hasStructuredAppend()&&(s.putMetadata(Ge.STRUCTURED_APPEND_SEQUENCE,r.getStructuredAppendSequenceNumber()),s.putMetadata(Ge.STRUCTURED_APPEND_PARITY,r.getStructuredAppendParity())),s}reset(){}static extractPureBits(e){const t=e.getTopLeftOnBit(),r=e.getBottomRightOnBit();if(t===null||r===null)throw new B;const n=this.moduleSize(t,e);let s=t[1],i=r[1],a=t[0],o=r[0];if(a>=o||s>=i)throw new B;if(i-s!==o-a&&(o=a+(i-s),o>=e.getWidth()))throw new B;const c=Math.round((o-a+1)/n),u=Math.round((i-s+1)/n);if(c<=0||u<=0)throw new B;if(u!==c)throw new B;const f=Math.floor(n/2);s+=f,a+=f;const x=a+Math.floor((c-1)*n)-o;if(x>0){if(x>f)throw new B;a-=x}const E=s+Math.floor((u-1)*n)-i;if(E>0){if(E>f)throw new B;s-=E}const I=new De(c,u);for(let y=0;y<u;y++){const N=s+Math.floor(y*n);for(let O=0;O<c;O++)e.get(a+Math.floor(O*n),N)&&I.set(O,y)}return I}static moduleSize(e,t){const r=t.getHeight(),n=t.getWidth();let s=e[0],i=e[1],a=!0,o=0;for(;s<n&&i<r;){if(a!==t.get(s,i)){if(++o===5)break;a=!a}s++,i++}if(s===n||i===r)throw new B;return(s-e[0])/7}}Yt.NO_POINTS=new Array;class ie{PDF417Common(){}static getBitCountSum(e){return we.sum(e)}static toIntArray(e){if(e==null||!e.length)return ie.EMPTY_INT_ARRAY;const t=new Int32Array(e.length);let r=0;for(const n of e)t[r++]=n;return t}static getCodeword(e){const t=$.binarySearch(ie.SYMBOL_TABLE,e&262143);return t<0?-1:(ie.CODEWORD_TABLE[t]-1)%ie.NUMBER_OF_CODEWORDS}}ie.NUMBER_OF_CODEWORDS=929,ie.MAX_CODEWORDS_IN_BARCODE=ie.NUMBER_OF_CODEWORDS-1,ie.MIN_ROWS_IN_BARCODE=3,ie.MAX_ROWS_IN_BARCODE=90,ie.MODULES_IN_CODEWORD=17,ie.MODULES_IN_STOP_PATTERN=18,ie.BARS_IN_MODULE=8,ie.EMPTY_INT_ARRAY=new Int32Array([]),ie
vendor: 18,272 bytes, line 41
41.SYMBOL_TABLE=Int32Array.from([66142,66170,66206,66236,66290,66292,66350,66382,66396,66454,66470,66476,66594,66600,66614,66626,66628,66632,66640,66654,66662,66668,66682,66690,66718,66720,66748,66758,66776,66798,66802,66804,66820,66824,66832,66846,66848,66876,66880,66936,66950,66956,66968,66992,67006,67022,67036,67042,67044,67048,67062,67118,67150,67164,67214,67228,67256,67294,67322,67350,67366,67372,67398,67404,67416,67438,67474,67476,67490,67492,67496,67510,67618,67624,67650,67656,67664,67678,67686,67692,67706,67714,67716,67728,67742,67744,67772,67782,67788,67800,67822,67826,67828,67842,67848,67870,67872,67900,67904,67960,67974,67992,68016,68030,68046,68060,68066,68068,68072,68086,68104,68112,68126,68128,68156,68160,68216,68336,68358,68364,68376,68400,68414,68448,68476,68494,68508,68536,68546,68548,68552,68560,68574,68582,68588,68654,68686,68700,68706,68708,68712,68726,68750,68764,68792,68802,68804,68808,68816,68830,68838,68844,68858,68878,68892,68920,68976,68990,68994,68996,69e3,69008,69022,69024,69052,69062,69068,69080,69102,69106,69108,69142,69158,69164,69190,69208,69230,69254,69260,69272,69296,69310,69326,69340,69386,69394,69396,69410,69416,69430,69442,69444,69448,69456,69470,69478,69484,69554,69556,69666,69672,69698,69704,69712,69726,69754,69762,69764,69776,69790,69792,69820,69830,69836,69848,69870,69874,69876,69890,69918,69920,69948,69952,70008,70022,70040,70064,70078,70094,70108,70114,70116,70120,70134,70152,70174,70176,70264,70384,70412,70448,70462,70496,70524,70542,70556,70584,70594,70600,70608,70622,70630,70636,70664,70672,70686,70688,70716,70720,70776,70896,71136,71180,71192,71216,71230,71264,71292,71360,71416,71452,71480,71536,71550,71554,71556,71560,71568,71582,71584,71612,71622,71628,71640,71662,71726,71732,71758,71772,71778,71780,71784,71798,71822,71836,71864,71874,71880,71888,71902,71910,71916,71930,71950,71964,71992,72048,72062,72066,72068,72080,72094,72096,72124,72134,72140,72152,72174,72178,72180,72206,72220,72248,72304,72318,72416,72444,72456,72464,72478,72480,72508,72512,72568,72588,72600,72624,72638,72654,72668,72674,72676,72680,72694,72726,72742,72748,72774,72780,72792,72814,72838,72856,72880,72894,72910,72924,72930,72932,72936,72950,72966,72972,72984,73008,73022,73056,73084,73102,73116,73144,73156,73160,73168,73182,73190,73196,73210,73226,73234,73236,73250,73252,73256,73270,73282,73284,73296,73310,73318,73324,73346,73348,73352,73360,73374,73376,73404,73414,73420,73432,73454,73498,73518,73522,73524,73550,73564,73570,73572,73576,73590,73800,73822,73858,73860,73872,73886,73888,73916,73944,73970,73972,73992,74014,74016,74044,74048,74104,74118,74136,74160,74174,74210,74212,74216,74230,74244,74256,74270,74272,74360,74480,74502,74508,74544,74558,74592,74620,74638,74652,74680,74690,74696,74704,74726,74732,74782,74784,74812,74992,75232,75288,75326,75360,75388,75456,75512,75576,75632,75646,75650,75652,75664,75678,75680,75708,75718,75724,75736,75758,75808,75836,75840,75896,76016,76256,76736,76824,76848,76862,76896,76924,76992,77048,77296,77340,77368,77424,77438,77536,77564,77572,77576,77584,77600,77628,77632,77688,77702,77708,77720,77744,77758,77774,77788,77870,77902,77916,77922,77928,77966,77980,78008,78018,78024,78032,78046,78060,78074,78094,78136,78192,78206,78210,78212,78224,78238,78240,78268,78278,78284,78296,78322,78324,78350,78364,78448,78462,78560,78588,78600,78622,78624,78652,78656,78712,78726,78744,78768,78782,78798,78812,78818,78820,78824,78838,78862,78876,78904,78960,78974,79072,79100,79296,79352,79368,79376,79390,79392,79420,79424,79480,79600,79628,79640,79664,79678,79712,79740,79772,79800,79810,79812,79816,79824,79838,79846,79852,79894,79910,79916,79942,79948,79960,79982,79988,80006,80024,80048,80062,80078,80092,80098,80100,80104,80134,80140,80176,80190,80224,80252,80270,80284,80312,80328,80336,80350,80358,80364,80378,80390,80396,80408,80432,80446,80480,80508,80576,80632,80654,80668,80696,80752,80766,80776,80784,80798,80800,80828,80844,80856,80878,80882,80884,80914,80916,80930,80932,80936,80950,80962,80968,80976,80990,80998,81004,81026,81028,81040,81054,81056,81084,81094,81100,81112,81134,81154,81156,81160,81168,81182,81184,81212,81216,81272,81286,81292,81304,81328,81342,81358,81372,81380,81384,81398,81434,81454,81458,81460,81486,81500,81506,81508,81512,81526,81550,81564,81592,81602,81604,81608,81616,81630,81638,81644,81702,81708,81722,81734,81740,81752,81774,81778,81780,82050,82078,82080,82108,82180,82184,82192,82206,82208,82236,82240,82296,82316,82328,82352,82366,82402,82404,82408,82440,82448,82462,82464,82492,82496,82552,82672,82694,82700,82712,82736,82750,82784,82812,82830,82882,82884,82888,82896,82918,82924,82952,82960,82974,82976,83004,83008,83064,83184,83424,83468,83480,83504,83518,83552,83580,83648,83704,83740,83768,83824,83838,83842,83844,83848,83856,83872,83900,83910,83916,83928,83950,83984,84e3,84028,84032,84088,84208,84448,84928,85040,85054,85088,85116,85184,85240,85488,85560,85616,85630,85728,85756,85764,85768,85776,85790,85792,85820,85824,85880,85894,85900,85912,85936,85966,85980,86048,86080,86136,86256,86496,86976,88160,88188,88256,88312,88560,89056,89200,89214,89312,89340,89536,89592,89608,89616,89632,89664,89720,89840,89868,89880,89904,89952,89980,89998,90012,90040,90190,90204,90254,90268,90296,90306,90308,90312,90334,90382,90396,90424,90480,90494,90500,90504,90512,90526,90528,90556,90566,90572,90584,90610,90612,90638,90652,90680,90736,90750,90848,90876,90884,90888,90896,90910,90912,90940,90944,91e3,91014,91020,91032,91056,91070,91086,91100,91106,91108,91112,91126,91150,91164,91192,91248,91262,91360,91388,91584,91640,91664,91678,91680,91708,91712,91768,91888,91928,91952,91966,92e3,92028,92046,92060,92088,92098,92100,92104,92112,92126,92134,92140,92188,92216,92272,92384,92412,92608,92664,93168,93200,93214,93216,93244,93248,93304,93424,93664,93720,93744,93758,93792,93820,93888,93944,93980,94008,94064,94078,94084,94088,94096,94110,94112,94140,94150,94156,94168,94246,94252,94278,94284,94296,94318,94342,94348,94360,94384,94398,94414,94428,94440,94470,94476,94488,94512,94526,94560,94588,94606,94620,94648,94658,94660,94664,94672,94686,94694,94700,94714,94726,94732,94744,94768,94782,94816,94844,94912,94968,94990,95004,95032,95088,95102,95112,95120,95134,95136,95164,95180,95192,95214,95218,95220,95244,95256,95280,95294,95328,95356,95424,95480,95728,95758,95772,95800,95856,95870,95968,95996,96008,96016,96030,96032,96060,96064,96120,96152,96176,96190,96220,96226,96228,96232,96290,96292,96296,96310,96322,96324,96328,96336,96350,96358,96364,96386,96388,96392,96400,96414,96416,96444,96454,96460,96472,96494,96498,96500,96514,96516,96520,96528,96542,96544,96572,96576,96632,96646,96652,96664,96688,96702,96718,96732,96738,96740,96744,96758,96772,96776,96784,96798,96800,96828,96832,96888,97008,97030,97036,97048,97072,97086,97120,97148,97166,97180,97208,97220,97224,97232,97246,97254,97260,97326,97330,97332,97358,97372,97378,97380,97384,97398,97422,97436,97464,97474,97476,97480,97488,97502,97510,97516,97550,97564,97592,97648,97666,97668,97672,97680,97694,97696,97724,97734,97740,97752,97774,97830,97836,97850,97862,97868,97880,97902,97906,97908,97926,97932,97944,97968,97998,98012,98018,98020,98024,98038,98618,98674,98676,98838,98854,98874,98892,98904,98926,98930,98932,98968,99006,99042,99044,99048,99062,99166,99194,99246,99286,99350,99366,99372,99386,99398,99416,99438,99442,99444,99462,99504,99518,99534,99548,99554,99556,99560,99574,99590,99596,99608,99632,99646,99680,99708,99726,99740,99768,99778,99780,99784,99792,99806,99814,99820,99834,99858,99860,99874,99880,99894,99906,99920,99934,99962,99970,99972,99976,99984,99998,1e5,100028,100038,100044,100056,100078,100082,100084,100142,100174,100188,100246,100262,100268,100306,100308,100390,100396,100410,100422,100428,100440,100462,100466,100468,100486,100504,100528,100542,100558,100572,100578,100580,100584,100598,100620,100656,100670,100704,100732,100750,100792,100802,100808,100816,100830,100838,100844,100858,100888,100912,100926,100960,100988,101056,101112,101148,101176,101232,101246,101250,101252,101256,101264,101278,101280,101308,101318,101324,101336,101358,101362,101364,101410,101412,101416,101430,101442,101448,101456,101470,101478,101498,101506,101508,101520,101534,101536,101564,101580,101618,101620,101636,101640,101648,101662,101664,101692,101696,101752,101766,101784,101838,101858,101860,101864,101934,101938,101940,101966,101980,101986,101988,101992,102030,102044,102072,102082,102084,102088,102096,102138,102166,102182,102188,102214,102220,102232,102254,102282,102290,102292,102306,102308,102312,102326,102444,102458,102470,102476,102488,102514,102516,102534,102552,102576,102590,102606,102620,102626,102632,102646,102662,102668,102704,102718,102752,102780,102798,102812,102840,102850,102856,102864,102878,102886,102892,102906,102936,102974,103008,103036,103104,103160,103224,103280,103294,103298,103300,103312,103326,103328,103356,103366,103372,103384,103406,103410,103412,103472,103486,103520,103548,103616,103672,103920,103992,104048,104062,104160,104188,104194,104196,104200,104208,104224,104252,104256,104312,104326,104332,104344,104368,104382,104398,104412,104418,104420,104424,104482,104484,104514,104520,104528,104542,104550,104570,104578,104580,104592,104606,104608,104636,104652,104690,104692,104706,104712,104734,104736,104764,104768,104824,104838,104856,104910,104930,104932,104936,104968,104976,104990,104992,105020,105024,105080,105200,105240,105278,105312,105372,105410,105412,105416,105424,105446,105518,105524,105550,105564,105570,105572,105576,105614,105628,105656,105666,105672,105680,105702,105722,105742,105756,105784,105840,105854,105858,105860,105864,105872,105888,105932,105970,105972,106006,106022,106028,106054,106060,106072,106100,106118,106124,106136,106160,106174,106190,106210,106212,106216,106250,106258,106260,106274,106276,106280,106306,106308,106312,106320,106334,106348,106394,106414,106418,106420,106566,106572,106610,106612,106630,106636,106648,106672,106686,106722,106724,106728,106742,106758,106764,106776,106800,106814,106848,106876,106894,106908,106936,106946,106948,106952,106960,106974,106982,106988,107032,107056,107070,107104,107132,107200,107256,107292,107320,107376,107390,107394,107396,107400,107408,107422,107424,107452,107462,107468,107480,107502,107506,107508,107544,107568,107582,107616,107644,107712,107768,108016,108060,108088,108144,108158,108256,108284,108290,108292,108296,108304,108318,108320,108348,108352,108408,108422,108428,108440,108464,108478,108494,108508,108514,108516,108520,108592,108640,108668,108736,108792,109040,109536,109680,109694,109792,109820,110016,110072,110084,110088,110096,110112,110140,110144,110200,110320,110342,110348,110360,110384,110398,110432,110460,110478,110492,110520,110532,110536,110544,110558,110658,110686,110714,110722,110724,110728,110736,110750,110752,110780,110796,110834,110836,110850,110852,110856,110864,110878,110880,110908,110912,110968,110982,111e3,111054,111074,111076,111080,111108,111112,111120,111134,111136,111164,111168,111224,111344,111372,111422,111456,111516,111554,111556,111560,111568,111590,111632,111646,111648,111676,111680,111736,111856,112096,112152,112224,112252,112320,112440,112514,112516,112520,112528,112542,112544,112588,112686,112718,112732,112782,112796,112824,112834,112836,112840,112848,112870,112890,112910,112924,112952,113008,113022,113026,113028,113032,113040,113054,113056,113100,113138,113140,113166,113180,113208,113264,113278,113376,113404,113416,113424,113440,113468,113472,113560,113614,113634,113636,113640,113686,113702,113708,113734,113740,113752,113778,113780,113798,113804,113816,113840,113854,113870,113890,113892,113896,113926,113932,113944,113968,113982,114016,114044,114076,114114,114116,114120,114128,114150,114170,114194,114196,114210,114212,114216,114242,114244,114248,114256,114270,114278,114306,114308,114312,114320,114334,114336,114364,114380,114420,114458,114478,114482,114484,114510,114524,114530,114532,114536,114842,114866,114868,114970,114994,114996,115042,115044,115048,115062,115130,115226,115250,115252,115278,115292,115298,115300,115304,115318,115342,115394,115396,115400,115408,115422,115430,115436,115450,115478,115494,115514,115526,115532,115570,115572,115738,115758,115762,115764,115790,115804,115810,115812,115816,115830,115854,115868,115896,115906,115912,115920,115934,115942,115948,115962,115996,116024,116080,116094,116098,116100,116104,116112,116126,116128,116156,116166,116172,116184,116206,116210,116212,116246,116262,116268,116282,116294,116300,116312,116334,116338,116340,116358,116364,116376,116400,116414,116430,116444,116450,116452,116456,116498,116500,116514,116520,116534,116546,116548,116552,116560,116574,116582,116588,116602,116654,116694,116714,116762,116782,116786,116788,116814,116828,116834,116836,116840,116854,116878,116892,116920,116930,116936,116944,116958,116966,116972,116986,117006,117048,117104,117118,117122,117124,117136,117150,117152,117180,117190,117196,117208,117230,117234,117236,117304,117360,117374,117472,117500,117506,117508,117512,117520,117536,117564,117568,117624,117638,117644,117656,117680,117694,117710,117724,117730,117732,117736,117750,117782,117798,117804,117818,117830,117848,117874,117876,117894,117936,117950,117966,117986,117988,117992,118022,118028,118040,118064,118078,118112,118140,118172,118210,118212,118216,118224,118238,118246,118266,118306,118312,118338,118352,118366,118374,118394,118402,118404,118408,118416,118430,118432,118460,118476,118514,118516,118574,118578,118580,118606,118620,118626,118628,118632,118678,118694,118700,118730,118738,118740,118830,118834,118836,118862,118876,118882,118884,118888,118902,118926,118940,118968,118978,118980,118984,118992,119006,119014,119020,119034,119068,119096,119152,119166,119170,119172,119176,119184,119198,119200,119228,119238,119244,119256,119278,119282,119284,119324,119352,119408,119422,119520,119548,119554,119556,119560,119568,119582,119584,119612,119616,119672,119686,119692,119704,119728,119742,119758,119772,119778,119780,119784,119798,119920,119934,120032,120060,120256,120312,120324,120328,120336,120352,120384,120440,120560,120582,120588,120600,120624,120638,120672,120700,120718,120732,120760,120770,120772,120776,120784,120798,120806,120812,120870,120876,120890,120902,120908,120920,120946,120948,120966,120972,120984,121008,121022,121038,121058,121060,121064,121078,121100,121112,121136,121150,121184,121212,121244,121282,121284,121288,121296,121318,121338,121356,121368,121392,121406,121440,121468,121536,121592,121656,121730,121732,121736,121744,121758,121760,121804,121842,121844,121890,121922,121924,121928,121936,121950,121958,121978,121986,121988,121992,122e3,122014,122016,122044,122060,122098,122100,122116,122120,122128,122142,122144,122172,122176,122232,122246,122264,122318,122338,122340,122344,122414,122418,122420,122446,122460,122466,122468,122472,122510,122524,122552,122562,122564,122568,122576,122598,122618,122646,122662,122668,122694,122700,122712,122738,122740,122762,122770,122772,122786,122788,122792,123018,123026,123028,123042,123044,123048,123062,123098,123146,123154,123156,123170,123172,123176,123190,123202,123204,123208,123216,123238,123244,123258,123290,123314,123316,123402,123410,123412,123426,123428,123432,123446,123458,123464,123472,123486,123494,123500,123514,123522,123524,123528,123536,123552,123580,123590,123596,123608,123630,123634,123636,123674,123698,123700,123740,123746,123748,123752,123834,123914,123922,123924,123938,123944,123958,123970,123976,123984,123998,124006,124012,124026,124034,124036,124048,124062,124064,124092,124102,124108,124120,124142,124146,124148,124162,124164,124168,124176,124190,124192,124220,124224,124280,124294,124300,124312,124336,124350,124366,124380,124386,124388,124392,124406,124442,124462,124466,124468,124494,124508,124514,124520,124558,124572,124600,124610,124612,124616,124624,124646,124666,124694,124710,124716,124730,124742,124748,124760,124786,124788,124818,124820,124834,124836,124840,124854,124946,124948,124962,124964,124968,124982,124994,124996,125e3,125008,125022,125030,125036,125050,125058,125060,125064,125072,125086,125088,125116,125126,125132,125144,125166,125170,125172,125186,125188,125192,125200,125216,125244,125248,125304,125318,125324,125336,125360,125374,125390,125404,125410,125412,125416,125430,125444,125448,125456,125472,125504,125560,125680,125702,125708,125720,125744,125758,125792,125820,125838,125852,125880,125890,125892,125896,125904,125918,125926,125932,125978,125998,126002,126004,126030,126044,126050,126052,126056,126094,126108,126136,126146,126148,126152,126160,126182,126202,126222,126236,126264,126320,126334,126338,126340,126344,126352,126366,126368,126412,126450,126452,126486,126502,126508,126522,126534,126540,126552,126574,126578,126580,126598,126604,126616,126640,126654,126670,126684,126690,126692,126696,126738,126754,126756,126760,126774,126786,126788,126792,126800,126814,126822,126828,126842,126894,126898,126900,126934,127126,127142,127148,127162,127178,127186,127188,127254,127270,127276,127290,127302,127308,127320,127342,127346,127348,127370,127378,127380,127394,127396,127400,127450,127510,127526,127532,127546,127558,127576,127598,127602,127604,127622,127628,127640,127664,127678,127694,127708,127714,127716,127720,127734,127754,127762,127764,127778,127784,127810,127812,127816,127824,127838,127846,127866,127898,127918,127922,127924,128022,128038,128044,128058,128070,128076,128088,128110,128114,128116,128134,128140,128152,128176,128190,128206,128220,128226,128228,128232,128246,128262,128268,128280,128304,128318,128352,128380,128398,128412,128440,128450,128452,128456,128464,128478,128486,128492,128506,128522,128530,128532,128546,128548,128552,128566,128578,128580,128584,128592,128606,128614,128634,128642,128644,128648,128656,128670,128672,128700,128716,128754,128756,128794,128814,128818,128820,128846,128860,128866,128868,128872,128886,128918,128934,128940,128954,128978,128980,129178,129198,129202,129204,129238,129258,129306,129326,129330,129332,129358,129372,129378,129380,129384,129398,129430,129446,129452,129466,129482,129490,129492,129562,129582,129586,129588,129614,129628,129634,129636,129640,129654,129678,129692,129720,129730,129732,129736,129744,129758,129766,129772,129814,129830,129836,129850,129862,129868,129880,129902,129906,129908,129930,129938,129940,129954,129956,129960,129974,130010]),
41ie
vendor: 12,860 bytes, line 41
41.CODEWORD_TABLE=Int32Array.from([2627,1819,2622,2621,1813,1812,2729,2724,2723,2779,2774,2773,902,896,908,868,865,861,859,2511,873,871,1780,835,2493,825,2491,842,837,844,1764,1762,811,810,809,2483,807,2482,806,2480,815,814,813,812,2484,817,816,1745,1744,1742,1746,2655,2637,2635,2626,2625,2623,2628,1820,2752,2739,2737,2728,2727,2725,2730,2785,2783,2778,2777,2775,2780,787,781,747,739,736,2413,754,752,1719,692,689,681,2371,678,2369,700,697,694,703,1688,1686,642,638,2343,631,2341,627,2338,651,646,643,2345,654,652,1652,1650,1647,1654,601,599,2322,596,2321,594,2319,2317,611,610,608,606,2324,603,2323,615,614,612,1617,1616,1614,1612,616,1619,1618,2575,2538,2536,905,901,898,909,2509,2507,2504,870,867,864,860,2512,875,872,1781,2490,2489,2487,2485,1748,836,834,832,830,2494,827,2492,843,841,839,845,1765,1763,2701,2676,2674,2653,2648,2656,2634,2633,2631,2629,1821,2638,2636,2770,2763,2761,2750,2745,2753,2736,2735,2733,2731,1848,2740,2738,2786,2784,591,588,576,569,566,2296,1590,537,534,526,2276,522,2274,545,542,539,548,1572,1570,481,2245,466,2242,462,2239,492,485,482,2249,496,494,1534,1531,1528,1538,413,2196,406,2191,2188,425,419,2202,415,2199,432,430,427,1472,1467,1464,433,1476,1474,368,367,2160,365,2159,362,2157,2155,2152,378,377,375,2166,372,2165,369,2162,383,381,379,2168,1419,1418,1416,1414,385,1411,384,1423,1422,1420,1424,2461,802,2441,2439,790,786,783,794,2409,2406,2403,750,742,738,2414,756,753,1720,2367,2365,2362,2359,1663,693,691,684,2373,680,2370,702,699,696,704,1690,1687,2337,2336,2334,2332,1624,2329,1622,640,637,2344,634,2342,630,2340,650,648,645,2346,655,653,1653,1651,1649,1655,2612,2597,2595,2571,2568,2565,2576,2534,2529,2526,1787,2540,2537,907,904,900,910,2503,2502,2500,2498,1768,2495,1767,2510,2508,2506,869,866,863,2513,876,874,1782,2720,2713,2711,2697,2694,2691,2702,2672,2670,2664,1828,2678,2675,2647,2646,2644,2642,1823,2639,1822,2654,2652,2650,2657,2771,1855,2765,2762,1850,1849,2751,2749,2747,2754,353,2148,344,342,336,2142,332,2140,345,1375,1373,306,2130,299,2128,295,2125,319,314,311,2132,1354,1352,1349,1356,262,257,2101,253,2096,2093,274,273,267,2107,263,2104,280,278,275,1316,1311,1308,1320,1318,2052,202,2050,2044,2040,219,2063,212,2060,208,2055,224,221,2066,1260,1258,1252,231,1248,229,1266,1264,1261,1268,155,1998,153,1996,1994,1991,1988,165,164,2007,162,2006,159,2003,2e3,172,171,169,2012,166,2010,1186,1184,1182,1179,175,1176,173,1192,1191,1189,1187,176,1194,1193,2313,2307,2305,592,589,2294,2292,2289,578,572,568,2297,580,1591,2272,2267,2264,1547,538,536,529,2278,525,2275,547,544,541,1574,1571,2237,2235,2229,1493,2225,1489,478,2247,470,2244,465,2241,493,488,484,2250,498,495,1536,1533,1530,1539,2187,2186,2184,2182,1432,2179,1430,2176,1427,414,412,2197,409,2195,405,2193,2190,426,424,421,2203,418,2201,431,429,1473,1471,1469,1466,434,1477,1475,2478,2472,2470,2459,2457,2454,2462,803,2437,2432,2429,1726,2443,2440,792,789,785,2401,2399,2393,1702,2389,1699,2411,2408,2405,745,741,2415,758,755,1721,2358,2357,2355,2353,1661,2350,1660,2347,1657,2368,2366,2364,2361,1666,690,687,2374,683,2372,701,698,705,1691,1689,2619,2617,2610,2608,2605,2613,2593,2588,2585,1803,2599,2596,2563,2561,2555,1797,2551,1795,2573,2570,2567,2577,2525,2524,2522,2520,1786,2517,1785,2514,1783,2535,2533,2531,2528,1788,2541,2539,906,903,911,2721,1844,2715,2712,1838,1836,2699,2696,2693,2703,1827,1826,1824,2673,2671,2669,2666,1829,2679,2677,1858,1857,2772,1854,1853,1851,1856,2766,2764,143,1987,139,1986,135,133,131,1984,128,1983,125,1981,138,137,136,1985,1133,1132,1130,112,110,1974,107,1973,104,1971,1969,122,121,119,117,1977,114,1976,124,1115,1114,1112,1110,1117,1116,84,83,1953,81,1952,78,1950,1948,1945,94,93,91,1959,88,1958,85,1955,99,97,95,1961,1086,1085,1083,1081,1078,100,1090,1089,1087,1091,49,47,1917,44,1915,1913,1910,1907,59,1926,56,1925,53,1922,1919,66,64,1931,61,1929,1042,1040,1038,71,1035,70,1032,68,1048,1047,1045,1043,1050,1049,12,10,1869,1867,1864,1861,21,1880,19,1877,1874,1871,28,1888,25,1886,22,1883,982,980,977,974,32,30,991,989,987,984,34,995,994,992,2151,2150,2147,2146,2144,356,355,354,2149,2139,2138,2136,2134,1359,343,341,338,2143,335,2141,348,347,346,1376,1374,2124,2123,2121,2119,1326,2116,1324,310,308,305,2131,302,2129,298,2127,320,318,316,313,2133,322,321,1355,1353,1351,1357,2092,2091,2089,2087,1276,2084,1274,2081,1271,259,2102,256,2100,252,2098,2095,272,269,2108,266,2106,281,279,277,1317,1315,1313,1310,282,1321,1319,2039,2037,2035,2032,1203,2029,1200,1197,207,2053,205,2051,201,2049,2046,2043,220,218,2064,215,2062,211,2059,228,226,223,2069,1259,1257,1254,232,1251,230,1267,1265,1263,2316,2315,2312,2311,2309,2314,2304,2303,2301,2299,1593,2308,2306,590,2288,2287,2285,2283,1578,2280,1577,2295,2293,2291,579,577,574,571,2298,582,581,1592,2263,2262,2260,2258,1545,2255,1544,2252,1541,2273,2271,2269,2266,1550,535,532,2279,528,2277,546,543,549,1575,1573,2224,2222,2220,1486,2217,1485,2214,1482,1479,2238,2236,2234,2231,1496,2228,1492,480,477,2248,473,2246,469,2243,490,487,2251,497,1537,1535,1532,2477,2476,2474,2479,2469,2468,2466,2464,1730,2473,2471,2453,2452,2450,2448,1729,2445,1728,2460,2458,2456,2463,805,804,2428,2427,2425,2423,1725,2420,1724,2417,1722,2438,2436,2434,2431,1727,2444,2442,793,791,788,795,2388,2386,2384,1697,2381,1696,2378,1694,1692,2402,2400,2398,2395,1703,2392,1701,2412,2410,2407,751,748,744,2416,759,757,1807,2620,2618,1806,1805,2611,2609,2607,2614,1802,1801,1799,2594,2592,2590,2587,1804,2600,2598,1794,1793,1791,1789,2564,2562,2560,2557,1798,2554,1796,2574,2572,2569,2578,1847,1846,2722,1843,1842,1840,1845,2716,2714,1835,1834,1832,1830,1839,1837,2700,2698,2695,2704,1817,1811,1810,897,862,1777,829,826,838,1760,1758,808,2481,1741,1740,1738,1743,2624,1818,2726,2776,782,740,737,1715,686,679,695,1682,1680,639,628,2339,647,644,1645,1643,1640,1648,602,600,597,595,2320,593,2318,609,607,604,1611,1610,1608,1606,613,1615,1613,2328,926,924,892,886,899,857,850,2505,1778,824,823,821,819,2488,818,2486,833,831,828,840,1761,1759,2649,2632,2630,2746,2734,2732,2782,2781,570,567,1587,531,527,523,540,1566,1564,476,467,463,2240,486,483,1524,1521,1518,1529,411,403,2192,399,2189,423,416,1462,1457,1454,428,1468,1465,2210,366,363,2158,360,2156,357,2153,376,373,370,2163,1410,1409,1407,1405,382,1402,380,1417,1415,1412,1421,2175,2174,777,774,771,784,732,725,722,2404,743,1716,676,674,668,2363,665,2360,685,1684,1681,626,624,622,2335,620,2333,617,2330,641,635,649,1646,1644,1642,2566,928,925,2530,2527,894,891,888,2501,2499,2496,858,856,854,851,1779,2692,2668,2665,2645,2643,2640,2651,2768,2759,2757,2744,2743,2741,2748,352,1382,340,337,333,1371,1369,307,300,296,2126,315,312,1347,1342,1350,261,258,250,2097,246,2094,271,268,264,1306,1301,1298,276,1312,1309,2115,203,2048,195,2045,191,2041,213,209,2056,1246,1244,1238,225,1234,222,1256,1253,1249,1262,2080,2079,154,1997,150,1995,147,1992,1989,163,160,2004,156,2001,1175,1174,1172,1170,1167,170,1164,167,1185,1183,1180,1177,174,1190,1188,2025,2024,2022,587,586,564,559,556,2290,573,1588,520,518,512,2268,508,2265,530,1568,1565,461,457,2233,450,2230,446,2226,479,471,489,1526,1523,1520,397,395,2185,392,2183,389,2180,2177,410,2194,402,422,1463,1461,1459,1456,1470,2455,799,2433,2430,779,776,773,2397,2394,2390,734,728,724,746,1717,2356,2354,2351,2348,1658,677,675,673,670,667,688,1685,1683,2606,2589,2586,2559,2556,2552,927,2523,2521,2518,2515,1784,2532,895,893,890,2718,2709,2707,2689,2687,2684,2663,2662,2660,2658,1825,2667,2769,1852,2760,2758,142,141,1139,1138,134,132,129,126,1982,1129,1128,1126,1131,113,111,108,105,1972,101,1970,120,118,115,1109,1108,1106,1104,123,1113,1111,82,79,1951,75,1949,72,1946,92,89,86,1956,1077,1076,1074,1072,98,1069,96,1084,1082,1079,1088,1968,1967,48,45,1916,42,1914,39,1911,1908,60,57,54,1923,50,1920,1031,1030,1028,1026,67,1023,65,1020,62,1041,1039,1036,1033,69,1046,1044,1944,1943,1941,11,9,1868,7,1865,1862,1859,20,1878,16,1875,13,1872,970,968,966,963,29,960,26,23,983,981,978,975,33,971,31,990,988,985,1906,1904,1902,993,351,2145,1383,331,330,328,326,2137,323,2135,339,1372,1370,294,293,291,289,2122,286,2120,283,2117,309,303,317,1348,1346,1344,245,244,242,2090,239,2088,236,2085,2082,260,2099,249,270,1307,1305,1303,1300,1314,189,2038,186,2036,183,2033,2030,2026,206,198,2047,194,216,1247,1245,1243,1240,227,1237,1255,2310,2302,2300,2286,2284,2281,565,563,561,558,575,1589,2261,2259,2256,2253,1542,521,519,517,514,2270,511,533,1569,1567,2223,2221,2218,2215,1483,2211,1480,459,456,453,2232,449,474,491,1527,1525,1522,2475,2467,2465,2451,2449,2446,801,800,2426,2424,2421,2418,1723,2435,780,778,775,2387,2385,2382,2379,1695,2375,1693,2396,735,733,730,727,749,1718,2616,2615,2604,2603,2601,2584,2583,2581,2579,1800,2591,2550,2549,2547,2545,1792,2542,1790,2558,929,2719,1841,2710,2708,1833,1831,2690,2688,2686,1815,1809,1808,1774,1756,1754,1737,1736,1734,1739,1816,1711,1676,1674,633,629,1638,1636,1633,1641,598,1605,1604,1602,1600,605,1609,1607,2327,887,853,1775,822,820,1757,1755,1584,524,1560,1558,468,464,1514,1511,1508,1519,408,404,400,1452,1447,1444,417,1458,1455,2208,364,361,358,2154,1401,1400,1398,1396,374,1393,371,1408,1406,1403,1413,2173,2172,772,726,723,1712,672,669,666,682,1678,1675,625,623,621,618,2331,636,632,1639,1637,1635,920,918,884,880,889,849,848,847,846,2497,855,852,1776,2641,2742,2787,1380,334,1367,1365,301,297,1340,1338,1335,1343,255,251,247,1296,1291,1288,265,1302,1299,2113,204,196,192,2042,1232,1230,1224,214,1220,210,1242,1239,1235,1250,2077,2075,151,148,1993,144,1990,1163,1162,1160,1158,1155,161,1152,157,1173,1171,1168,1165,168,1181,1178,2021,2020,2018,2023,585,560,557,1585,516,509,1562,1559,458,447,2227,472,1516,1513,1510,398,396,393,390,2181,386,2178,407,1453,1451,1449,1446,420,1460,2209,769,764,720,712,2391,729,1713,664,663,661,659,2352,656,2349,671,1679,1677,2553,922,919,2519,2516,885,883,881,2685,2661,2659,2767,2756,2755,140,1137,1136,130,127,1125,1124,1122,1127,109,106,102,1103,1102,1100,1098,116,1107,1105,1980,80,76,73,1947,1068,1067,1065,1063,90,1060,87,1075,1073,1070,1080,1966,1965,46,43,40,1912,36,1909,1019,1018,1016,1014,58,1011,55,1008,51,1029,1027,1024,1021,63,1037,1034,1940,1939,1937,1942,8,1866,4,1863,1,1860,956,954,952,949,946,17,14,969,967,964,961,27,957,24,979,976,972,1901,1900,1898,1896,986,1905,1903,350,349,1381,329,327,324,1368,1366,292,290,287,284,2118,304,1341,1339,1337,1345,243,240,237,2086,233,2083,254,1297,1295,1293,1290,1304,2114,190,187,184,2034,180,2031,177,2027,199,1233,1231,1229,1226,217,1223,1241,2078,2076,584,555,554,552,550,2282,562,1586,507,506,504,502,2257,499,2254,515,1563,1561,445,443,441,2219,438,2216,435,2212,460,454,475,1517,1515,1512,2447,798,797,2422,2419,770,768,766,2383,2380,2376,721,719,717,714,731,1714,2602,2582,2580,2548,2546,2543,923,921,2717,2706,2705,2683,2682,2680,1771,1752,1750,1733,1732,1731,1735,1814,1707,1670,1668,1631,1629,1626,1634,1599,1598,1596,1594,1603,1601,2326,1772,1753,1751,1581,1554,1552,1504,1501,1498,1509,1442,1437,1434,401,1448,1445,2206,1392,1391,1389,1387,1384,359,1399,1397,1394,1404,2171,2170,1708,1672,1669,619,1632,1630,1628,1773,1378,1363,1361,1333,1328,1336,1286,1281,1278,248,1292,1289,2111,1218,1216,1210,197,1206,193,1228,1225,1221,1236,2073,2071,1151,1150,1148,1146,152,1143,149,1140,145,1161,1159,1156,1153,158,1169,1166,2017,2016,2014,2019,1582,510,1556,1553,452,448,1506,1500,394,391,387,1443,1441,1439,1436,1450,2207,765,716,713,1709,662,660,657,1673,1671,916,914,879,878,877,882,1135,1134,1121,1120,1118,1123,1097,1096,1094,1092,103,1101,1099,1979,1059,1058,1056,1054,77,1051,74,1066,1064,1061,1071,1964,1963,1007,1006,1004,1002,999,41,996,37,1017,1015,1012,1009,52,1025,1022,1936,1935,1933,1938,942,940,938,935,932,5,2,955,953,950,947,18,943,15,965,962,958,1895,1894,1892,1890,973,1899,1897,1379,325,1364,1362,288,285,1334,1332,1330,241,238,234,1287,1285,1283,1280,1294,2112,188,185,181,178,2028,1219,1217,1215,1212,200,1209,1227,2074,2072,583,553,551,1583,505,503,500,513,1557,1555,444,442,439,436,2213,455,451,1507,1505,1502,796,763,762,760,767,711,710,708,706,2377,718,715,1710,2544,917,915,2681,1627,1597,1595,2325,1769,1749,1747,1499,1438,1435,2204,1390,1388,1385,1395,2169,2167,1704,1665,1662,1625,1623,1620,1770,1329,1282,1279,2109,1214,1207,1222,2068,2065,1149,1147,1144,1141,146,1157,1154,2013,2011,2008,2015,1579,1549,1546,1495,1487,1433,1431,1428,1425,388,1440,2205,1705,658,1667,1664,1119,1095,1093,1978,1057,1055,1052,1062,1962,1960,1005,1003,1e3,997,38,1013,1010,1932,1930,1927,1934,941,939,936,933,6,930,3,951,948,944,1889,1887,1884,1881,959,1893,1891,35,1377,1360,1358,1327,1325,1322,1331,1277,1275,1272,1269,235,1284,2110,1205,1204,1201,1198,182,1195,179,1213,2070,2067,1580,501,1551,1548,440,437,1497,1494,1490,1503,761,709,707,1706,913,912,2198,1386,2164,2161,1621,1766,2103,1208,2058,2054,1145,1142,2005,2002,1999,2009,1488,1429,1426,2200,1698,1659,1656,1975,1053,1957,1954,1001,998,1924,1921,1918,1928,937,934,931,1879,1876,1873,1870,945,1885,1882,1323,1273,1270,2105,1202,1199,1196,1211,2061,2057,1576,1543,1540,1484,1481,1478,1491,1700])
41;class Rs{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class fe{static detectMultiple(e,t,r){let n=e.getBlackMatrix(),s=fe.detect(r,n);return s.length||(n=n.clone(),n.rotate180(),s=fe.detect(r,n)),new Rs(n,s)}static detect(e,t){const r=new Array;let n=0,s=0,i=!1;for(;n<t.getHeight();){const a=fe.findVertices(t,n,s);if(a[0]==null&&a[3]==null){if(!i)break;i=!1,s=0;for(const o of r)o[1]!=null&&(n=Math.trunc(Math.max(n,o[1].getY()))),o[3]!=null&&(n=Math.max(n,Math.trunc(o[3].getY())));n+=fe.ROW_STEP;continue}if(i=!0,r.push(a),!e)break;a[2]!=null?(s=Math.trunc(a[2].getX()),n=Math.trunc(a[2].getY())):(s=Math.trunc(a[4].getX()),n=Math.trunc(a[4].getY()))}return r}static findVertices(e,t,r){const n=e.getHeight(),s=e.getWidth(),i=new Array(8);return fe.copyToResult(i,fe.findRowsWithPattern(e,n,s,t,r,fe.START_PATTERN),fe.INDEXES_START_PATTERN),i[4]!=null&&(r=Math.trunc(i[4].getX()),t=Math.trunc(i[4].getY())),fe.copyToResult(i,fe.findRowsWithPattern(e,n,s,t,r,fe.STOP_PATTERN),fe.INDEXES_STOP_PATTERN),i}static copyToResult(e,t,r){for(let n=0;n<r.length;n++)e[r[n]]=t[n]}static findRowsWithPattern(e,t,r,n,s,i){const a=new Array(4);let o=!1;const c=new Int32Array(i.length);for(;n<t;n+=fe.ROW_STEP){let f=fe.findGuardPattern(e,s,n,r,!1,i,c);if(f!=null){for(;n>0;){const x=fe.findGuardPattern(e,s,--n,r,!1,i,c);if(x!=null)f=x;else{n++;break}}a[0]=new Z(f[0],n),a[1]=new Z(f[1],n),o=!0;break}}let u=n+1;if(o){let f=0,x=Int32Array.from([Math.trunc(a[0].getX()),Math.trunc(a[1].getX())]);for(;u<t;u++){const E=fe.findGuardPattern(e,x[0],u,r,!1,i,c);if(E!=null&&Math.abs(x[0]-E[0])<fe.MAX_PATTERN_DRIFT&&Math.abs(x[1]-E[1])<fe.MAX_PATTERN_DRIFT)x=E,f=0;else{if(f>fe.SKIPPED_ROW_COUNT_MAX)break;f++}}u-=f+1,a[2]=new Z(x[0],u),a[3]=new Z(x[1],u)}return u-n<fe.BARCODE_MIN_HEIGHT&&$.fill(a,null),a}static findGuardPattern(e,t,r,n,s,i,a){$.fillWithin(a,0,a.length,0);let o=t,c=0;for(;e.get(o,r)&&o>0&&c++<fe.MAX_PIXEL_DRIFT;)o--;let u=o,f=0,x=i.length;for(let E=s;u<n;u++)if(e.get(u,r)!==E)a[f]++;else{if(f===x-1){if(fe.patternMatchVariance(a,i,fe.MAX_INDIVIDUAL_VARIA
vendor: 9,843 bytes, line 41
41NCE)<fe.MAX_AVG_VARIANCE)return new Int32Array([o,u]);o+=a[0]+a[1],G.arraycopy(a,2,a,0,f-1),a[f-1]=0,a[f]=0,f--}else f++;a[f]=1,E=!E}return f===x-1&&fe.patternMatchVariance(a,i,fe.MAX_INDIVIDUAL_VARIANCE)<fe.MAX_AVG_VARIANCE?new Int32Array([o,u-1]):null}static patternMatchVariance(e,t,r){let n=e.length,s=0,i=0;for(let c=0;c<n;c++)s+=e[c],i+=t[c];if(s<i)return 1/0;let a=s/i;r*=a;let o=0;for(let c=0;c<n;c++){let u=e[c],f=t[c]*a,x=u>f?u-f:f-u;if(x>r)return 1/0;o+=x}return o/s}}fe.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),fe.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),fe.MAX_AVG_VARIANCE=.42,fe.MAX_INDIVIDUAL_VARIANCE=.8,fe.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),fe.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),fe.MAX_PIXEL_DRIFT=3,fe.MAX_PATTERN_DRIFT=5,fe.SKIPPED_ROW_COUNT_MAX=25,fe.ROW_STEP=5,fe.BARCODE_MIN_HEIGHT=10;class tt{constructor(e,t){if(t.length===0)throw new v;this.field=e;let r=t.length;if(r>1&&t[0]===0){let n=1;for(;n<r&&t[n]===0;)n++;n===r?this.coefficients=new Int32Array([0]):(this.coefficients=new Int32Array(r-n),G.arraycopy(t,n,this.coefficients,0,this.coefficients.length))}else this.coefficients=t}getCoefficients(){return this.coefficients}getDegree(){return this.coefficients.length-1}isZero(){return this.coefficients[0]===0}getCoefficient(e){return this.coefficients[this.coefficients.length-1-e]}evaluateAt(e){if(e===0)return this.getCoefficient(0);if(e===1){let n=0;for(let s of this.coefficients)n=this.field.add(n,s);return n}let t=this.coefficients[0],r=this.coefficients.length;for(let n=1;n<r;n++)t=this.field.add(this.field.multiply(e,t),this.coefficients[n]);return t}add(e){if(!this.field.equals(e.field))throw new v("ModulusPolys do not have same ModulusGF field");if(this.isZero())return e;if(e.isZero())return this;let t=this.coefficients,r=e.coefficients;if(t.length>r.length){let i=t;t=r,r=i}let n=new Int32Array(r.length),s=r.length-t.length;G.arraycopy(r,0,n,0,s);for(let i=s;i<r.length;i++)n[i]=this.field.add(t[i-s],r[i]);return new tt(this.field,n)}subtract(e){if(!this.field.equals(e.field))throw new v("ModulusPolys do not have same ModulusGF field");return e.isZero()?this:this.add(e.negative())}multiply(e){return e instanceof tt?this.multiplyOther(e):this.multiplyScalar(e)}multiplyOther(e){if(!this.field.equals(e.field))throw new v("ModulusPolys do not have same ModulusGF field");if(this.isZero()||e.isZero())return new tt(this.field,new Int32Array([0]));let t=this.coefficients,r=t.length,n=e.coefficients,s=n.length,i=new Int32Array(r+s-1);for(let a=0;a<r;a++){let o=t[a];for(let c=0;c<s;c++)i[a+c]=this.field.add(i[a+c],this.field.multiply(o,n[c]))}return new tt(this.field,i)}negative(){let e=this.coefficients.length,t=new Int32Array(e);for(let r=0;r<e;r++)t[r]=this.field.subtract(0,this.coefficients[r]);return new tt(this.field,t)}multiplyScalar(e){if(e===0)return new tt(this.field,new Int32Array([0]));if(e===1)return this;let t=this.coefficients.length,r=new Int32Array(t);for(let n=0;n<t;n++)r[n]=this.field.multiply(this.coefficients[n],e);return new tt(this.field,r)}multiplyByMonomial(e,t){if(e<0)throw new v;if(t===0)return new tt(this.field,new Int32Array([0]));let r=this.coefficients.length,n=new Int32Array(r+e);for(let s=0;s<r;s++)n[s]=this.field.multiply(this.coefficients[s],t);return new tt(this.field,n)}toString(){let e=new pe;for(let t=this.getDegree();t>=0;t--){let r=this.getCoefficient(t);r!==0&&(r<0?(e.append(" - "),r=-r):e.length()>0&&e.append(" + "),(t===0||r!==1)&&e.append(r),t!==0&&(t===1?e.append("x"):(e.append("x^"),e.append(t))))}return e.toString()}}class Os{add(e,t){return(e+t)%this.modulus}subtract(e,t){return(this.modulus+e-t)%this.modulus}exp(e){return this.expTable[e]}log(e){if(e===0)throw new v;return this.logTable[e]}inverse(e){if(e===0)throw new $e;return this.expTable[this.modulus-this.logTable[e]-1]}multiply(e,t){return e===0||t===0?0:this.expTable[(this.logTable[e]+this.logTable[t])%(this.modulus-1)]}getSize(){return this.modulus}equals(e){return e===this}}class sn extends Os{constructor(e,t){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let r=1;for(let n=0;n<e;n++)this.expTable[n]=r,r=r*t%e;for(let n=0;n<e-1;n++)this.logTable[this.expTable[n]]=n;this.zero=new tt(this,new Int32Array([0])),this.one=new tt(this,new Int32Array([1]))}getZero(){return this.zero}getOne(){return this.one}buildMonomial(e,t){if(e<0)throw new v;if(t===0)return this.zero;let r=new Int32Array(e+1);return r[0]=t,new tt(this,r)}}sn.PDF417_GF=new sn(ie.NUMBER_OF_CODEWORDS,3);class Rn{constructor(){this.field=sn.PDF417_GF}decode(e,t,r){let n=new tt(this.field,e),s=new Int32Array(t),i=!1;for(let I=t;I>0;I--){let y=n.evaluateAt(this.field.exp(I));s[t-I]=y,y!==0&&(i=!0)}if(!i)return 0;let a=this.field.getOne();if(r!=null)for(const I of r){let y=this.field.exp(e.length-1-I),N=new tt(this.field,new Int32Array([this.field.subtract(0,y),1]));a=a.multiply(N)}let o=new tt(this.field,s),c=this.runEuclideanAlgorithm(this.field.buildMonomial(t,1),o,t),u=c[0],f=c[1],x=this.findErrorLocations(u),E=this.findErrorMagnitudes(f,u,x);for(let I=0;I<x.length;I++){let y=e.length-1-this.field.log(x[I]);if(y<0)throw J.getChecksumInstance();e[y]=this.field.subtract(e[y],E[I])}return x.length}runEuclideanAlgorithm(e,t,r){if(e.getDegree()<t.getDegree()){let x=e;e=t,t=x}let n=e,s=t,i=this.field.getZero(),a=this.field.getOne();for(;s.getDegree()>=Math.round(r/2);){let x=n,E=i;if(n=s,i=a,n.isZero())throw J.getChecksumInstance();s=x;let I=this.field.getZero(),y=n.getCoefficient(n.getDegree()),N=this.field.inverse(y);for(;s.getDegree()>=n.getDegree()&&!s.isZero();){let O=s.getDegree()-n.getDegree(),U=this.field.multiply(s.getCoefficient(s.getDegree()),N);I=I.add(this.field.buildMonomial(O,U)),s=s.subtract(n.multiplyByMonomial(O,U))}a=I.multiply(i).subtract(E).negative()}let o=a.getCoefficient(0);if(o===0)throw J.getChecksumInstance();let c=this.field.inverse(o),u=a.multiply(c),f=s.multiply(c);return[u,f]}findErrorLocations(e){let t=e.getDegree(),r=new Int32Array(t),n=0;for(let s=1;s<this.field.getSize()&&n<t;s++)e.evaluateAt(s)===0&&(r[n]=this.field.inverse(s),n++);if(n!==t)throw J.getChecksumInstance();return r}findErrorMagnitudes(e,t,r){let n=t.getDegree(),s=new Int32Array(n);for(let c=1;c<=n;c++)s[n-c]=this.field.multiply(c,t.getCoefficient(c));let i=new tt(this.field,s),a=r.length,o=new Int32Array(a);for(let c=0;c<a;c++){let u=this.field.inverse(r[c]),f=this.field.subtract(0,e.evaluateAt(u)),x=this.field.inverse(i.evaluateAt(u));o[c]=this.field.multiply(f,x)}return o}}class $t{constructor(e,t,r,n,s){e instanceof $t?this.constructor_2(e):this.constructor_1(e,t,r,n,s)}constructor_1(e,t,r,n,s){const i=t==null||r==null,a=n==null||s==null;if(i&&a)throw new B;i?(t=new Z(0,n.getY()),r=new Z(0,s.getY())):a&&(n=new Z(e.getWidth()-1,t.getY()),s=new Z(e.getWidth()-1,r.getY())),this.image=e,this.topLeft=t,this.bottomLeft=r,this.topRight=n,this.bottomRight=s,this.minX=Math.trunc(Math.min(t.getX(),r.getX())),this.maxX=Math.trunc(Math.max(n.getX(),s.getX())),this.minY=Math.trunc(Math.min(t.getY(),n.getY())),this.maxY=Math.trunc(Math.max(r.getY(),s.getY()))}constructor_2(e){this.image=e.image,this.topLeft=e.getTopLeft(),this.bottomLeft=e.getBottomLeft(),this.topRight=e.getTopRight(),this.bottomRight=e.getBottomRight(),this.minX=e.getMinX(),this.maxX=e.getMaxX(),this.minY=e.getMinY(),this.maxY=e.getMaxY()}static merge(e,t){return e==null?t:t==null?e:new $t(e.image,e.topLeft,e.bottomLeft,t.topRight,t.bottomRight)}addMissingRows(e,t,r){let n=this.topLeft,s=this.bottomLeft,i=this.topRight,a=this.bottomRight;if(e>0){let o=r?this.topLeft:this.topRight,c=Math.trunc(o.getY()-e);c<0&&(c=0);let u=new Z(o.getX(),c);r?n=u:i=u}if(t>0){let o=r?this.bottomLeft:this.bottomRight,c=Math.trunc(o.getY()+t);c>=this.image.getHeight()&&(c=this.image.getHeight()-1);let u=new Z(o.getX(),c);r?s=u:a=u}return new $t(this.image,n,s,i,a)}getMinX(){return this.minX}getMaxX(){return this.maxX}getMinY(){return this.minY}getMaxY(){return this.maxY}getTopLeft(){return this.topLeft}getTopRight(){return this.topRight}getBottomLeft(){return this.bottomLeft}getBottomRight(){return this.bottomRight}}class Ds{constructor(e,t,r,n){this.columnCount=e,this.errorCorrectionLevel=n,this.rowCountUpperPart=t,this.rowCountLowerPart=r,this.rowCount=t+r}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Cr{constructor(){this.buffer=""}static form(e,t){let r=-1;function n(i,a,o,c,u,f){if(i==="%%")return"%";if(t[++r]===void 0)return;i=c?parseInt(c.substr(1)):void 0;let x=u?parseInt(u.substr(1)):void 0,E;switch(f){case"s":E=t[r];break;case"c":E=t[r][0];break;case"f":E=parseFloat(t[r]).toFixed(i);break;case"p":E=parseFloat(t[r]).toPrecision(i);break;case"e":E=parseFloat(t[r]).toExponential(i);break;case"x":E=parseInt(t[r]).toString(x||16);break;case"d":E=parseFloat(parseInt(t[r],x||10).toPrecision(i)).toFixed(0);break}E=typeof E=="object"?JSON.stringify(E):(+E).toString(x);let I=parseInt(o),y=o&&o[0]+""=="0"?"0":" ";for(;E.length<I;)E=a!==void 0?E+y:y+E;return E}let s=/%(-)?(0?[0-9]+)?([.][0-9]+)?([#][0-9]+)?([scfpexd%])/g;return e.replace(s,n)}format(e,...t){this.buffer+=Cr.form(e,t)}toString(){return this.buffer}}class Er{constructor(e){this.boundingBox=new $t(e),this.codewords=new Array(e.getMaxY()-e.getMinY()+1)}getCodewordNearby(e){let t=this.getCodeword(e);if(t!=null)return t;for(let r=1;r<Er.MAX_NEARBY_DISTANCE;r++){let n=this.imageRowToCodewordIndex(e)-r;if(n>=0&&(t=this.codewords[n],t!=null)||(n=this.imageRowToCodewordIndex(e)+r,n<this.codewords.length&&(t=this.codewords[n],t!=null)))return t}return null}imageRowToCodewordIndex(e){return e-this.boundingBox.getMinY()}
41setCodeword(e,t){this.codewords[this.imageRowToCodewordIndex(e)]=t}getCodeword(e){return this.codewords[this.imageRowToCodewordIndex(e)]}getBoundingBox(){return this.boundingBox}getCodewords(){return this.codewords}toString(){const e=new Cr;let t=0;for(const r of this.codewords){if(r==null){e.format("%3d: | %n",t++);continue}e.format("%3d: %3d|%3d%n",t++,r.getRowNumber(),r.getValue())}return e.toString()}}Er.MAX_NEARBY_DISTANCE=5;class br{constructor(){this.values=new Map}setValue(e){e=Math.trunc(e);let t=this.values.get(e);t==null&&(t=0),t++,this.values.set(e,t)}getValue(){let e=-1,t=new Array;for(const[r,n]of this.values.entries()){const s={getKey:()=>r,getValue:()=>n};s.getValue()>e?(e=s.getValue(),t=[],t.push(s.getKey())):s.getValue()===e&&t.push(s.getKey())}return ie.toIntArray(t)}getConfidence(e){return this.values.get(e)}}class On extends Er{constructor(e,t){super(e),this._isLeft=t}setRowNumbers(){for(let e of this.getCodewords())e!=null&&e.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let t=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(t,e);let r=this.getBoundingBox(),n=this._isLeft?r.getTopLeft():r.getTopRight(),s=this._isLeft?r.getBottomLeft():r.getBottomRight(),i=this.imageRowToCodewordIndex(Math.trunc(n.getY())),a=this.imageRowToCodewordIndex(Math.trunc(s.getY())),o=-1,c=1,u=0;for(let f=i;f<a;f++){if(t[f]==null)continue;let x=t[f],E=x.getRowNumber()-o;if(E===0)u++;else if(E===1)c=Math.max(c,u),u=1,o=x.getRowNumber();else if(E<0||x.getRowNumber()>=e.getRowCount()||E>f)t[f]=null;else{let I;c>2?I=(c-2)*E:I=E;let y=I>=f;for(let N=1;N<=I&&!y;N++)y=t[f-N]!=null;y?t[f]=null:(o=x.getRowNumber(),u=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(e==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let t=new Int32Array(e.getRowCount());for(let r of this.getCodewords())if(r!=null){let n=r.getRowNumber();if(n>=t.length)continue;t[n]++}return t}adjustIncompleteIndicatorColumnRowNumbers(e){let t=this.getBoundingBox(),r=this._isLeft?t.getTopLeft():t.getTopRight(),n=this._isLeft?t.getBottomLeft():t.getBottomRight(),s=this.imageRowToCodewordIndex(Math.trunc(r.getY())),i=this.imageRowToCodewordIndex(Math.trunc(n.getY())),a=this.getCodewords(),o=-1;for(let c=s;c<i;c++){if(a[c]==null)continue;let u=a[c];u.setRowNumberAsRowIndicatorColumn();let f=u.getRowNumber()-o;f===0||(f===1?o=u.getRowNumber():u.getRowNumber()>=e.getRowCount()?a[c]=null:o=u.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),t=new br,r=new br,n=new br,s=new br;for(let a of e){if(a==null)continue;a.setRowNumberAsRowIndicatorColumn();let o=a.getValue()%30,c=a.getRowNumber();switch(this._isLeft||(c+=2),c%3){case 0:r.setValue(o*3+1);break;case 1:s.setValue(o/3),n.setValue(o%3);break;case 2:t.setValue(o+1);break}}if(t.getValue().length===0||r.getValue().length===0||n.getValue().length===0||s.getValue().length===0||t.getValue()[0]<1||r.getValue()[0]+n.getValue()[0]<ie.MIN_ROWS_IN_BARCODE||r.getValue()[0]+n.getValue()[0]>ie.MAX_ROWS_IN_BARCODE)return null;let i=new Ds(t.getValue()[0],r.getValue()[0],n.getValue()[0],s.getValue()[0]);return this.removeIncorrectCodewords(e,i),i}removeIncorrectCodewords(e,t){for(let r=0;r<e.length;r++){let n=e[r];if(e[r]==null)continue;let s=n.getValue()%30,i=n.getRowNumber();if(i>t.getRowCount()){e[r]=null;continue}switch(this._isLeft||(i+=2),i%3){case 0:s*3+1!==t.getRowCountUpperPart()&&(e[r]=null);break;case 1:(Math.trunc(s/3)!==t.getErrorCorrectionLevel()||s%3!==t.getRowCountLowerPart())&&(e[r]=null);break;case 2:s+1!==t.getColumnCount()&&(e[r]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+` 42`+super.toString()}}class Ir{constructor(e,t){this.ADJUST_ROW_NUMBER_SKIP=2,this.barcodeMetadata=e,this.barcodeColumnCount=e.getColumnCount(),this.boundingBox=t,this.detectionResultColumns=new Array(this.barcodeColumnCount+2)}getDetectionResultColumns(){this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[0]),this.adjustIndicatorColumnRowNumbers(this.detectionResultColumns[this.barcodeColumnCount+1]);let e=ie.MAX_CODEWORDS_IN_BARCODE,t;do t=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e<t);return this.detectionResultColumns}adjustIndicatorColumnRowNumbers(e){e!=null&&e.adjustCompleteIndicatorColumnRowNumbers(this.barcodeMetadata)}adjustRowNumbersAndGetCount(){let e=this.adjustRowNumbersByRow();if(e===0)return 0;for(let t=1;t<this.barcodeColumnCount+1;t++){let r=this.detectionResultColumns[t].getCodewords();for(let n=0;n<r.length;n++)r[n]!=null&&(r[n].hasValidRowNumber()||this.adjustRowNumbers(t,n,r))}return e}adjustRowNumbersByRow(){return this.adjustRowNumbersFromBothRI(),this.adjustRowNumbersFromLRI()+this.adjustRowNumbersFromRRI()}
42adjustRowNumbersFromBothRI(){if(this.detectionResultColumns[0]==null||this.detectionResultColumns[this.barcodeColumnCount+1]==null)return;let e=this.detectionResultColumns[0].getCodewords(),t=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let r=0;r<e.length;r++)if(e[r]!=null&&t[r]!=null&&e[r].getRowNumber()===t[r].getRowNumber())for(let n=1;n<=this.barcodeColumnCount;n++){let s=this.detectionResultColumns[n].getCodewords()[r];s!=null&&(s.setRowNumber(e[r].getRowNumber()),s.hasValidRowNumber()||(this.detectionResultColumns[n].getCodewords()[r]=null))}}adjustRowNumbersFromRRI(){if(this.detectionResultColumns[this.barcodeColumnCount+1]==null)return 0;let e=0,t=this.detectionResultColumns[this.barcodeColumnCount+1].getCodewords();for(let r=0;r<t.length;r++){if(t[r]==null)continue;let n=t[r].getRowNumber(),s=0;for(let i=this.barcodeColumnCount+1;i>0&&s<this.ADJUST_ROW_NUMBER_SKIP;i--){let a=this.detectionResultColumns[i].getCodewords()[r];a!=null&&(s=Ir.adjustRowNumberIfValid(n,s,a),a.hasValidRowNumber()||e++)}}return e}adjustRowNumbersFromLRI(){if(this.detectionResultColumns[0]==null)return 0;let e=0,t=this.detectionResultColumns[0].getCodewords();for(let r=0;r<t.length;r++){if(t[r]==null)continue;let n=t[r].getRowNumber(),s=0;for(let i=1;i<this.barcodeColumnCount+1&&s<this.ADJUST_ROW_NUMBER_SKIP;i++){let a=this.detectionResultColumns[i].getCodewords()[r];a!=null&&(s=Ir.adjustRowNumberIfValid(n,s,a),a.hasValidRowNumber()||e++)}}return e}static adjustRowNumberIfValid(e,t,r){return r==null||r.hasValidRowNumber()||(r.isValidRowNumber(e)?(r.setRowNumber(e),t=0):++t),t}adjustRowNumbers(e,t,r){if(!this.detectionResultColumns[e-1])return;let n=r[t],s=this.detectionResultColumns[e-1].getCodewords(),i=s;this.detectionResultColumns[e+1]!=null&&(i=this.detectionResultColumns[e+1].getCodewords());let a=new Array(14);a[2]=s[t],a[3]=i[t],t>0&&(a[0]=r[t-1],a[4]=s[t-1],a[5]=i[t-1]),t>1&&(a[8]=r[t-2],a[10]=s[t-2],a[11]=i[t-2]),t<r.length-1&&(a[1]=r[t+1],a[6]=s[t+1],a[7]=i[t+1]),t<r.length-2&&(a[9]=r[t+2],a[12]=s[t+2],a[13]=i[t+2]);for(let o of a)if(Ir.adjustRowNumber(n,o))return}static adjustRowNumber(e,t){return t==null?!1:t.hasValidRowNumber()&&t.getBucket()===e.getBucket()?(e.setRowNumber(t.getRowNumber()),!0):!1}getBarcodeColumnCount(){return this.barcodeColumnCount}getBarcodeRowCount(){return this.barcodeMetadata.getRowCount()}getBarcodeECLevel(){return this.barcodeMetadata.getErrorCorrectionLevel()}setBoundingBox(e){this.boundingBox=e}getBoundingBox(){return this.boundingBox}setDetectionResultColumn(e,t){this.detectionResultColumns[e]=t}getDetectionResultColumn(e){return this.detectionResultColumns[e]}toString(){let e=this.detectionResultColumns[0];e==null&&(e=this.detectionResultColumns[this.barcodeColumnCount+1]);let t=new Cr;for(let r=0;r<e.getCodewords().length;r++){t.format("CW %3d:",r);for(let n=0;n<this.barcodeColumnCount+2;n++){if(this.detectionResultColumns[n]==null){t.format(" | ");continue}let s=this.detectionResultColumns[n].getCodewords()[r];if(s==null){t.format(" | ");continue}t.format(" %3d|%3d",s.getRowNumber(),s.getValue())}t.format("%n")}return t.toString()}}class yr{constructor(e,t,r,n){this.rowNumber=yr.BARCODE_ROW_UNKNOWN,this.startX=Math.trunc(e),this.endX=Math.trunc(t),this.bucket=Math.trunc(r),this.value=Math.trunc(n)}hasValidRowNumber(){return this.isValidRowNumber(this.rowNumber)}isValidRowNumber(e){return e!==yr.BARCODE_ROW_UNKNOWN&&this.bucket===e%3*3}setRowNumberAsRowIndicatorColumn(){this.rowNumber=Math.trunc(Math.trunc(this.value/30)*3+Math.trunc(this.bucket/3))}getWidth(){return this.endX-this.startX}getStartX(){return this.startX}getEndX(){return this.endX}getBucket(){return this.bucket}getValue(){return this.value}getRowNumber(){return this.rowNumber}setRowNumber(e){this.rowNumber=e}toString(){return this.rowNumber+"|"+this.value}}yr.BARCODE_ROW_UNKNOWN=-1;class ft{static initialize(){for(let e=0;e<ie.SYMBOL_TABLE.length;e++){let t=ie.SYMBOL_TABLE[e],r=t&1;for(let n=0;n<ie.BARS_IN_MODULE;n++){let s=0;for(;(t&1)===r;)s+=1,t>>=1;r=t&1,ft.RATIOS_TABLE[e]||(ft.RATIOS_TABLE[e]=new Array(ie.BARS_IN_MODULE)),ft.RATIOS_TABLE[e][ie.BARS_IN_MODULE-n-1]=Math.fround(s/ie.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let t=ft.getDecodedCodewordValue(ft.sampleBitCounts(e));return t!==-1?t:ft.getClosestDecodedValue(e)}static sampleBitCounts(e){let t=we.sum(e),r=new Int32Array(ie.BARS_IN_MODULE),n=0,s=0;for(let i=0;i<ie.MODULES_IN_CODEWORD;i++){let a=t/(2*ie.MODULES_IN_CODEWORD)+i*t/ie.MODULES_IN_CODEWORD;s+e[n]<=a&&(s+=e[n],n++),r[n]++}
vendor: 12,714 bytes, lines 42-43
42return r}static getDecodedCodewordValue(e){let t=ft.getBitValue(e);return ie.getCodeword(t)===-1?-1:t}static getBitValue(e){let t=0;for(let r=0;r<e.length;r++)for(let n=0;n<e[r];n++)t=t<<1|(r%2===0?1:0);return Math.trunc(t)}static getClosestDecodedValue(e){let t=we.sum(e),r=new Array(ie.BARS_IN_MODULE);if(t>1)for(let i=0;i<r.length;i++)r[i]=Math.fround(e[i]/t);let n=Or.MAX_VALUE,s=-1;this.bSymbolTableReady||ft.initialize();for(let i=0;i<ft.RATIOS_TABLE.length;i++){let a=0,o=ft.RATIOS_TABLE[i];for(let c=0;c<ie.BARS_IN_MODULE;c++){let u=Math.fround(o[c]-r[c]);if(a+=Math.fround(u*u),a>=n)break}a<n&&(n=a,s=ie.SYMBOL_TABLE[i])}return s}}ft.bSymbolTableReady=!1,ft.RATIOS_TABLE=new Array(ie.SYMBOL_TABLE.length).map(d=>new Array(ie.BARS_IN_MODULE));class Dn{constructor(){this.segmentCount=-1,this.fileSize=-1,this.timestamp=-1,this.checksum=-1}getSegmentIndex(){return this.segmentIndex}setSegmentIndex(e){this.segmentIndex=e}getFileId(){return this.fileId}setFileId(e){this.fileId=e}getOptionalData(){return this.optionalData}setOptionalData(e){this.optionalData=e}isLastSegment(){return this.lastSegment}setLastSegment(e){this.lastSegment=e}getSegmentCount(){return this.segmentCount}setSegmentCount(e){this.segmentCount=e}getSender(){return this.sender||null}setSender(e){this.sender=e}getAddressee(){return this.addressee||null}setAddressee(e){this.addressee=e}getFileName(){return this.fileName}setFileName(e){this.fileName=e}getFileSize(){return this.fileSize}setFileSize(e){this.fileSize=e}getChecksum(){return this.checksum}setChecksum(e){this.checksum=e}getTimestamp(){return this.timestamp}setTimestamp(e){this.timestamp=e}}class vn{static parseLong(e,t=void 0){return parseInt(e,t)}}class Mn extends p{}Mn.kind="NullPointerException";class vs{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,t,r){if(e==null)throw new Mn;if(t<0||t>e.length||r<0||t+r>e.length||t+r<0)throw new Q;if(r===0)return;for(let n=0;n<r;n++)this.write(e[t+n])}flush(){}close(){}}class Ms extends p{}class Bs extends vs{constructor(e=32){if(super(),this.count=0,e<0)throw new v("Negative initial size: "+e);this.buf=new Uint8Array(e)}ensureCapacity(e){e-this.buf.length>0&&this.grow(e)}grow(e){let r=this.buf.length<<1;if(r-e<0&&(r=e),r<0){if(e<0)throw new Ms;r=W.MAX_VALUE}this.buf=$.copyOfUint8Array(this.buf,r)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,t,r){if(t<0||t>e.length||r<0||t+r-e.length>0)throw new Q;this.ensureCapacity(this.count+r),G.arraycopy(e,t,this.buf,this.count,r),this.count+=r}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return $.copyOfUint8Array(this.buf,this.count)}size(){return this.count}toString(e){return e?typeof e=="string"?this.toString_string(e):this.toString_number(e):this.toString_void()}toString_void(){return new String(this.buf).toString()}toString_string(e){return new String(this.buf).toString()}toString_number(e){return new String(this.buf).toString()}close(){}}var ye;(function(d){d[d.ALPHA=0]="ALPHA",d[d.LOWER=1]="LOWER",d[d.MIXED=2]="MIXED",d[d.PUNCT=3]="PUNCT",d[d.ALPHA_SHIFT=4]="ALPHA_SHIFT",d[d.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(ye||(ye={}));function Bn(){if(typeof window<"u")return window.BigInt||null;if(typeof Tr<"u")return Tr.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let Fr;function zt(d){if(typeof Fr>"u"&&(Fr=Bn()),Fr===null)throw new Error("BigInt is not supported!");return Fr(d)}function Ps(){let d=[];d[0]=zt(1);let e=zt(900);d[1]=e;for(let t=2;t<16;t++)d[t]=d[t-1]*e;return d}class R{static decode(e,t){let r=new pe(""),n=F.ISO8859_1;r.enableDecoding(n);let s=1,i=e[s++],a=new Dn;for(;s<e[0];){switch(i){case R.TEXT_COMPACTION_MODE_LATCH:s=R.textCompaction(e,s,r);break;case R.BYTE_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH_6:s=R.byteCompaction(i,e,n,s,r);break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:r.append(e[s++]);break;case R.NUMERIC_COMPACTION_MODE_LATCH:s=R.numericCompaction(e,s,r);break;case R.ECI_CHARSET:F.getCharacterSetECIByValue(e[s++]);break;case R.ECI_GENERAL_PURPOSE:s+=2;break;case R.ECI_USER_DEFINED:s++;break;case R.BEGIN_MACRO_PDF417_CONTROL_BLOCK:s=R.decodeMacroBlock(e,s,a);break;case R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case R.MACRO_PDF417_TERMINATOR:throw new P;default:s--,s=R.textCompaction(e,s,r);break}if(s<e.length)i=e[s++];else throw P.getFormatInstance()}if(r.length()===0)throw P.getFormatInstance();let o=new de(null,r.toString(),null,t);return o.setOther(a),o}static decodeMacroBlock(e,t,r){if(t+R.NUMBER_OF_SEQUENCE_CODEWORDS>e[0])throw P.getFormatInstance();let n=new Int32Array(R.NUMBER_OF_SEQUENCE_CODEWORDS);for(let a=0;a<R.NUMBER_OF_SEQUENCE_CODEWORDS;a++,t++)n[a]=e[t];r.setSegmentIndex(W.parseInt(R.decodeBase900toBase10(n,R.NUMBER_OF_SEQUENCE_CODEWORDS)));let s=new pe;t=R.textCompaction(e,t,s),r.setFileId(s.toString());let i=-1;for(e[t]===R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD&&(i=t+1);t<e[0];)switch(e[t]){case R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:switch(t++,e[t]){case R.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME:let a=new pe;t=R.textCompaction(e,t+1,a),r.setFileName(a.toString());break;case R.MACRO_PDF417_OPTIONAL_FIELD_SENDER:let o=new pe;t=R.textCompaction(e,t+1,o),r.setSender(o.toString());break;case R.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE:let c=new pe;t=R.textCompaction(e,t+1,c),r.setAddressee(c.toString());break;case R.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT:let u=new pe;t=R.numericCompaction(e,t+1,u),r.setSegmentCount(W.parseInt(u.toString()));break;case R.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP:let f=new pe;t=R.numericCompaction(e,t+1,f),r.setTimestamp(vn.parseLong(f.toString()));break;case R.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM:let x=new pe;t=R.numericCompaction(e,t+1,x),r.setChecksum(W.parseInt(x.toString()));break;case R.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE:let E=new pe;t=R.numericCompaction(e,t+1,E),r.setFileSize(vn.parseLong(E.toString()));break;default:throw P.getFormatInstance()}break;case R.MACRO_PDF417_TERMINATOR:t++,r.setLastSegment(!0);break;default:throw P.getFormatInstance()}if(i!==-1){let a=t-i;r.isLastSegment()&&a--,r.setOptionalData($.copyOfRange(e,i,i+a))}return t}static textCompaction(e,t,r){let n=new Int32Array((e[0]-t)*2),s=new Int32Array((e[0]-t)*2),i=0,a=!1;for(;t<e[0]&&!a;){let o=e[t++];if(o<R.TEXT_COMPACTION_MODE_LATCH)n[i]=o/30,n[i+1]=o%30,i+=2;else switch(o){case R.TEXT_COMPACTION_MODE_LATCH:n[i++]=R.TEXT_COMPACTION_MODE_LATCH;break;case R.BYTE_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH_6:case R.NUMERIC_COMPACTION_MODE_LATCH:case R.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case R.MACRO_PDF417_TERMINATOR:t--,a=!0;break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n[i]=R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE,o=e[t++],s[i]=o,i++;break}}return R.decodeTextCompaction(n,s,i,r),t}static decodeTextCompaction(e,t,r,n){let s=ye.ALPHA,i=ye.ALPHA,a=0;for(;a<r;){let o=e[a],c="";switch(s){case ye.ALPHA:if(o<26)c=String.fromCharCode(65+o);else switch(o){case 26:c=" ";break;case R.LL:s=ye.LOWER;break;case R.ML:s=ye.MIXED;break;case R.PS:i=s,s=ye.PUNCT_SHIFT;break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(t[a]);break;case R.TEXT_COMPACTION_MODE_LATCH:s=ye.ALPHA;break}break;case ye.LOWER:if(o<26)c=String.fromCharCode(97+o);else switch(o){case 26:c=" ";break;case R.AS:i=s,s=ye.ALPHA_SHIFT;break;case R.ML:s=ye.MIXED;break;case R.PS:i=s,s=ye.PUNCT_SHIFT;break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(t[a]);break;case R.TEXT_COMPACTION_MODE_LATCH:s=ye.ALPHA;break}break;case ye.MIXED:if(o<R.PL)c=R.MIXED_CHARS[o];else switch(o){case R.PL:s=ye.PUNCT;break;case 26:c=" ";break;case R.LL:s=ye.LOWER;break;case R.AL:s=ye.ALPHA;break;case R.PS:i=s,s=ye.PUNCT_SHIFT;break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(t[a]);break;case R.TEXT_COMPACTION_MODE_LATCH:s=ye.ALPHA;break}break;case ye.PUNCT:if(o<R.PAL)c=R.PUNCT_CHARS[o];else switch(o){case R.PAL:s=ye.ALPHA;break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(t[a]);break;case R.TEXT_COMPACTION_MODE_LATCH:s=ye.ALPHA;break}break;case ye.ALPHA_SHIFT:if(s=i,o<26)c=String.fromCharCode(65+o);else switch(o){case 26:c=" ";break;case R.TEXT_COMPACTION_MODE_LATCH:s=ye.ALPHA;break}break;case ye.PUNCT_SHIFT:if(s=i,o<R.PAL)c=R.PUNCT_CHARS[o];else switch(o){case R.PAL:s=ye.ALPHA;break;case R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE:n.append(t[a]);break;case R.TEXT_COMPACTION_MODE_LATCH:s=ye.ALPHA;break}break}c!==""&&n.append(c),a++}}static byteCompaction(e,t,r,n,s){let i=new Bs,a=0,o=0,c=!1;switch(e){case R.BYTE_COMPACTION_MODE_LATCH:let u=new Int32Array(6),f=t[n++];for(;n<t[0]&&!c;)switch(u[a++]=f,o=900*o+f,f=t[n++],f){case R.TEXT_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH:case R.NUMERIC_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH_6:case R.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case R.MACRO_PDF417_TERMINATOR:n--,c=!0;break;default:if(a%5===0&&a>0){for(let x=0;x<6;++x)i.write(Number(zt(o)>>zt(8*(5-x))));o=0,a=0}break}n===t[0]&&f<R.TEXT_COMPACTION_MODE_LATCH&&(u[a++]=f);for(let x=0;x<a;x++)i.write(u[x]);break;case R.BYTE_COMPACTION_MODE_LATCH_6:for(;n<t[0]&&!c;){let x=t[n++];if(x<R.TEXT_COMPACTION_MODE_LATCH)a++,o=900*o+x;else switch(x){case R.TEXT_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH:case R.NUMERIC_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH_6:case R.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case R.MACRO_PDF417_TERMINATOR:n--,c=!0;break}if(a%5===0&&a>0){for(let E=0;E<6;++E)i.write(Number(zt(o)>>zt(8*(5-E))));o=0,a=0}}break}return s.append(Se.decode(i.toByteArray(),r)),n}static numericCompaction(e,t,r){let n=0,s=!1,i=new Int32Array(R.MAX_NUMERIC_CODEWORDS);for(;t<e[0]&&!s;){let a=e[t++];if(t===e[0]&&(s=!0),a<R.TEXT_COMPACTION_MODE_LATCH)i[n]=a,n++;else switch(a){case R.TEXT_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH:case R.BYTE_COMPACTION_MODE_LATCH_6:case R.BEGIN_MACRO_PDF417_CONTROL_BLOCK:case R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD:case R.MACRO_PDF417_TERMINATOR:t--,s=!0;break}(n%R.MAX_NUMERIC_CODEWORDS===0||a===R.NUMERIC_COMPACTION_MODE_LATCH||s)&&n>0&&(r.append(R.decodeBase900toBase10(i,n)),n=0)}return t}static decodeBase900toBase10(e,t){let r=zt(0);for(let s=0;s<t;s++)r+=R.EXP900[t-s-1]*zt(e[s]);let n=r.toString();if(n.charAt(0)!=="1")throw new P;return n.substring(1)}}R.TEXT_COMPACTION_MODE_LATCH=900,R.BYTE_COMPACTION_MODE_LATCH=901,R.NUMERIC_COMPACTION_MODE_LATCH=902,R.BYTE_COMPACTION_MODE_LATCH_6=924,R.ECI_USER_DEFINED=925,R.ECI_GENERAL_PURPOSE=926,R.ECI_CHARSET=927,R.BEGIN_MACRO_PDF417_CONTROL_BLOCK=928,R.BEGIN_MACRO_PDF417_OPTIONAL_FIELD=923,R.MACRO_PDF417_TERMINATOR=922,R.MODE_SHIFT_TO_BYTE_COMPACTION_MODE=913,R.MAX_NUMERIC_CODEWORDS=15,R.MACRO_PDF417_OPTIONAL_FIELD_FILE_NAME=0,R.MACRO_PDF417_OPTIONAL_FIELD_SEGMENT_COUNT=1,R.MACRO_PDF417_OPTIONAL_FIELD_TIME_STAMP=2,R.MACRO_PDF417_OPTIONAL_FIELD_SENDER=3,R.MACRO_PDF417_OPTIONAL_FIELD_ADDRESSEE=4,R.MACRO_PDF417_OPTIONAL_FIELD_FILE_SIZE=5,R.MACRO_PDF417_OPTIONAL_FIELD_CHECKSUM=6,R.PL=25,R.LL=27,R.AS=27,R.ML=28,R.AL=28,R.PS=29,R.PAL=29,R.PUNCT_CHARS=`;<>@[\\]_\`~!\r ,: 43-.$/"|*()?{}'`,R.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",R.EXP900=Bn()?Ps():[],R.NUMBER_OF_SEQUENCE_CODEWORDS=2;class xe{constructor(){}static decode(e,t,r,n,s,i,a){let o=new $t(e,t,r,n,s),c=null,u=null,f;for(let I=!0;;I=!1){if(t!=null&&(c=xe.getRowIndicatorColumn(e,o,t,!0,i,a)),n!=null&&(u=xe.getRowIndicatorColumn(e,o,n,!1,i,a)),f=xe.merge(c,u),f==null)throw B.getNotFoundInstance();let y=f.getBoundingBox();if(I&&y!=null&&(y.getMinY()<o.getMinY()||y.getMaxY()>o.getMaxY()))o=y;else break}f.setBoundingBox(o);let x=f.getBarcodeColumnCount()+1;f.setDetectionResultColumn(0,c),f.setDetectionResultColumn(x,u);let E=c!=null;for(let I=1;I<=x;I++){let y=E?I:x-I;if(f.getDetectionResultColumn(y)!==void 0)continue;let N;y===0||y===x?N=new On(o,y===0):N=new Er(o),f.setDetectionResultColumn(y,N);let O=-1,U=O;for(let j=o.getMinY();j<=o.getMaxY();j++){if(O=xe.getStartColumn(f,y,j,E),O<0||O>o.getMaxX()){if(U===-1)continue;O=U}let k=xe.detectCodeword(e,o.getMinX(),o.getMaxX(),E,O,j,i,a);k!=null&&(N.setCodeword(j,k),U=O,i=Math.min(i,k.getWidth()),a=Math.max(a,k.getWidth()))}}return xe.createDecoderResult(f)}static merge(e,t){if(e==null&&t==null)return null;let r=xe.getBarcodeMetadata(e,t);if(r==null)return null;let n=$t.merge(xe.adjustBoundingBox(e),xe.adjustBoundingBox(t));return new Ir(r,n)}static adjustBoundingBox(e){if(e==null)return null;let t=e.getRowHeights();if(t==null)return null;let r=xe.getMax(t),n=0;for(let a of t)if(n+=r-a,a>0)break;let s=e.getCodewords();for(let a=0;n>0&&s[a]==null;a++)n--;let i=0;for(let a=t.length-1;a>
43=0&&(i+=r-t[a],!(t[a]>0));a--);for(let a=s.length-1;i>0&&s[a]==null;a--)i--;return e.getBoundingBox().addMissingRows(n,i,e.isLeft())}static getMax(e){let t=-1;for(let r of e)t=Math.max(t,r);return t}static getBarcodeMetadata(e,t){let r;if(e==null||(r=e.getBarcodeMetadata())==null)return t==null?null:t.getBarcodeMetadata();let n;return t==null||(n=t.getBarcodeMetadata())==null?r:r.getColumnCount()!==n.getColumnCount()&&r.getErrorCorrectionLevel()!==n.getErrorCorrectionLevel()&&r.getRowCount()!==n.getRowCount()?null:r}static getRowIndicatorColumn(e,t,r,n,s,i){let a=new On(t,n);for(let o=0;o<2;o++){let c=o===0?1:-1,u=Math.trunc(Math.trunc(r.getX()));for(let f=Math.trunc(Math.trunc(r.getY()));f<=t.getMaxY()&&f>=t.getMinY();f+=c){let x=xe.detectCodeword(e,0,e.getWidth(),n,u,f,s,i);x!=null&&(a.setCodeword(f,x),n?u=x.getStartX():u=x.getEndX())}}return a}static adjustCodewordCount(e,t){let r=t[0][1],n=r.getValue(),s=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-xe.getNumberOfECCodeWords(e.getBarcodeECLevel());if(n.length===0){if(s<1||s>ie.MAX_CODEWORDS_IN_BARCODE)throw B.getNotFoundInstance();r.setValue(s)}else n[0]!==s&&r.setValue(s)}static createDecoderResult(e){let t=xe.createBarcodeMatrix(e);xe.adjustCodewordCount(e,t);let r=new Array,n=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),s=[],i=new Array;for(let o=0;o<e.getBarcodeRowCount();o++)for(let c=0;c<e.getBarcodeColumnCount();c++){let u=t[o][c+1].getValue(),f=o*e.getBarcodeColumnCount()+c;u.length===0?r.push(f):u.length===1?n[f]=u[0]:(i.push(f),s.push(u))}let a=new Array(s.length);for(let o=0;o<a.length;o++)a[o]=s[o];return xe.createDecoderResultFromAmbiguousValues(e.getBarcodeECLevel(),n,ie.toIntArray(r),ie.toIntArray(i),a)}static createDecoderResultFromAmbiguousValues(e,t,r,n,s){let i=new Int32Array(n.length),a=100;for(;a-- >0;){for(let o=0;o<i.length;o++)t[n[o]]=s[o][i[o]];try{return xe.decodeCodewords(t,e,r)}catch(o){if(!(o instanceof J))throw o}if(i.length===0)throw J.getChecksumInstance();for(let o=0;o<i.length;o++)if(i[o]<s[o].length-1){i[o]++;break}else if(i[o]=0,o===i.length-1)throw J.getChecksumInstance()}throw J.getChecksumInstance()}static createBarcodeMatrix(e){let t=Array.from({length:e.getBarcodeRowCount()},()=>new Array(e.getBarcodeColumnCount()+2));for(let n=0;n<t.length;n++)for(let s=0;s<t[n].length;s++)t[n][s]=new br;let r=0;for(let n of e.getDetectionResultColumns()){if(n!=null){for(let s of n.getCodewords())if(s!=null){let i=s.getRowNumber();if(i>=0){if(i>=t.length)continue;t[i][r].setValue(s.getValue())}}}r++}return t}static isValidBarcodeColumn(e,t){return t>=0&&t<=e.getBarcodeColumnCount()+1}static getStartColumn(e,t,r,n){let s=n?1:-1,i=null;if(xe.isValidBarcodeColumn(e,t-s)&&(i=e.getDetectionResultColumn(t-s).getCodeword(r)),i!=null)return n?i.getEndX():i.getStartX();if(i=e.getDetectionResultColumn(t).getCodewordNearby(r),i!=null)return n?i.getStartX():i.getEndX();if(xe.isValidBarcodeColumn(e,t-s)&&(i=e.getDetectionResultColumn(t-s).getCodewordNearby(r)),i!=null)return n?i.getEndX():i.getStartX();let a=0;for(;xe.isValidBarcodeColumn(e,t-s);){t-=s;for(let o of e.getDetectionResultColumn(t).getCodewords())if(o!=null)return(n?o.getEndX():o.getStartX())+s*a*(o.getEndX()-o.getStartX());a++}return n?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,t,r,n,s,i,a,o){s=xe.adjustCodewordStartColumn(e,t,r,n,s,i);let c=xe.getModuleBitCount(e,t,r,n,s,i);if(c==null)return null;let u,f=we.sum(c);if(n)u=s+f;else{for(let I=0;I<c.length/2;I++){let y=c[I];c[I]=c[c.length-1-I],c[c.length-1-I]=y}u=s,s=u-f}if(!xe.checkCodewordSkew(f,a,o))return null;let x=ft.getDecodedValue(c),E=ie.getCodeword(x);return E===-1?null:new yr(s,u,xe.getCodewordBucketNumber(x),E)}static getModuleBitCount(e,t,r,n,s,i){let a=s,o=new Int32Array(8),c=0,u=n?1:-1,f=n;for(;(n?a<r:a>=t)&&c<o.length;)e.get(a,i)===f?(o[c]++,a+=u):(c++,f=!f);return c===o.length||a===(n?r:t)&&c===o.length-1?o:null}static getNumberOfECCodeWords(e){return 2<<e}static adjustCodewordStartColumn(e,t,r,n,s,i){let a=s,o=n?-1:1;for(let c=0;c<2;c++){for(;(n?a>=t:a<r)&&n===e.get(a,i);){if(Math.abs(s-a)>xe.CODEWORD_SKEW_SIZE)return s;a+=o}o=-o,n=!n}return a}static checkCodewordSkew(e,t,r){return t-xe.CODEWORD_SKEW_SIZE<=e&&e<=r+xe.CODEWORD_SKEW_SIZE}static decodeCodewords(e,t,r){if(e.length===0)throw P.getFormatInstance();let n=1<<t+1,s=xe.correctErrors(e,r,n);xe.verifyCodewordCount(e,n);let i=R.decode(e,""+t);return i.setErrorsCorrected(s),i.setErasures(r.length),i}static correctErrors(e,t,r){if(t!=null&&t.length>r/2+xe.MAX_ERRORS||r<0||r>xe.MAX_EC_CODEWORDS)throw J.getChecksumInstance();return xe.errorCorrection.decode(e,r,t)}static verifyCodewordCount(e,t){if(e.length<4)throw P.getFormatInstance();let r=e[0];if(r>e.length)throw P.getFormatInstance();if(r===0)if(t<e.length)e[0]=e.length-t;else throw P.getFormatInstance()}static getBitCountForCodeword(e){let t=new Int32Array(8),r=0,n=t.length-1;for(;!((e&1)!==r&&(r=e&1,n--,n<0));)t[n]++,e>>=1;return t}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return xe.getCodewordBucketNumber(xe.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let t=new Cr;
43for(let r=0;r<e.length;r++){t.format("Row %2d: ",r);for(let n=0;n<e[r].length;n++){let s=e[r][n];s.getValue().length===0?t.format(" ",null):t.format("%4d(%2d)",s.getValue()[0],s.getConfidence(s.getValue()[0]))}t.format("%n")}return t.toString()}}xe.CODEWORD_SKEW_SIZE=2,xe.MAX_ERRORS=3,xe.MAX_EC_CODEWORDS=512,xe.errorCorrection=new Rn;class rt{decode(e,t=null){let r=rt.decode(e,t,!1);if(r==null||r.length===0||r[0]==null)throw B.getNotFoundInstance();return r[0]}decodeMultiple(e,t=null){try{return rt.decode(e,t,!0)}catch(r){throw r instanceof P||r instanceof J?B.getNotFoundInstance():r}}static decode(e,t,r){const n=new Array,s=fe.detectMultiple(e,t,r);for(const i of s.getPoints()){const a=xe.decode(s.getBits(),i[4],i[5],i[6],i[7],rt.getMinCodewordWidth(i),rt.getMaxCodewordWidth(i)),o=new Je(a.getText(),a.getRawBytes(),void 0,i,re.PDF_417);o.putMetadata(Ge.ERROR_CORRECTION_LEVEL,a.getECLevel());const c=a.getOther();c!=null&&o.putMetadata(Ge.PDF417_EXTRA_METADATA,c),n.push(o)}return n.map(i=>i)}static getMaxWidth(e,t){return e==null||t==null?0:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMinWidth(e,t){return e==null||t==null?W.MAX_VALUE:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(rt.getMaxWidth(e[0],e[4]),rt.getMaxWidth(e[6],e[2])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN),Math.max(rt.getMaxWidth(e[1],e[5]),rt.getMaxWidth(e[7],e[3])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(rt.getMinWidth(e[0],e[4]),rt.getMinWidth(e[6],e[2])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN),Math.min(rt.getMinWidth(e[1],e[5]),rt.getMinWidth(e[7],e[3])*ie.MODULES_IN_CODEWORD/ie.MODULES_IN_STOP_PATTERN)))}reset(){}}class kr extends p{}kr.kind="ReaderException";class Pn{constructor(e,t){this.verbose=e===!0,t&&this.setHints(t)}decode(e,t){return t&&this.setHints(t),this.decodeInternal(e)}decodeWithState(e){return(this.readers===null||this.readers===void 0)&&this.setHints(null),this.decodeInternal(e)}setHints(e){this.hints=e;const t=!w(e)&&e.get(K.TRY_HARDER)===!0,r=w(e)?null:e.get(K.POSSIBLE_FORMATS),n=new Array;if(!w(r)){const s=r.some(i=>i===re.UPC_A||i===re.UPC_E||i===re.EAN_13||i===re.EAN_8||i===re.CODABAR||i===re.CODE_39||i===re.CODE_93||i===re.CODE_128||i===re.ITF||i===re.RSS_14||i===re.RSS_EXPANDED);s&&!t&&n.push(new cr(e,this.verbose)),r.includes(re.QR_CODE)&&n.push(new Yt),r.includes(re.DATA_MATRIX)&&n.push(new Xt),r.includes(re.AZTEC)&&n.push(new vr),r.includes(re.PDF_417)&&n.push(new rt),s&&t&&n.push(new cr(e,this.verbose))}n.length===0&&(t||n.push(new cr(e,this.verbose)),n.push(new Yt),n.push(new Xt),n.push(new vr),n.push(new rt),t&&n.push(new cr(e,this.verbose))),this.readers=n}reset(){if(this.readers!==null)for(const e of this.readers)e.reset()}decodeInternal(e){if(this.readers===null)throw new kr("No readers where selected, nothing can be read.");for(const t of this.readers)try{return t.decode(e,this.hints)}catch(r){if(r instanceof kr)continue}throw new B("No MultiFormat Readers were able to detect the code.")}}class Ls extends Ft{constructor(e=null,t=500){const r=new Pn;r.setHints(e),super(r,t)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class Fs extends Ft{constructor(e=500){super(new rt,e)}}class ks extends Ft{constructor(e=500){super(new Yt,e)}}var an;(function(d){d[d.ERROR_CORRECTION=0]="ERROR_CORRECTION",d[d.CHARACTER_SET=1]="CHARACTER_SET",d[d.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",d[d.MIN_SIZE=3]="MIN_SIZE",d[d.MAX_SIZE=4]="MAX_SIZE",d[d.MARGIN=5]="MARGIN",d[d.PDF417_COMPACT=6]="PDF417_COMPACT",d[d.PDF417_COMPACTION=7]="PDF417_COMPACTION",d[d.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",d[d.AZTEC_LAYERS=9]="AZTEC_LAYERS",d[d.QR_VERSION=10]="QR_VERSION"})(an||(an={}));var Ze=an;class on{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new Me(e,Int32Array.from([1])))}buildGenerator(e){const t=this.cachedGenerators;if(e>=t.length){let r=t[t.length-1];const n=this.field;for(let s=t.length;s<=e;s++){const i=r.multiply(new Me(n,Int32Array.from([1,n.exp(s-1+n.getGeneratorBase())])));t.push(i),r=i}}return t[e]}encode(e,t){if(t===0)throw new v("No error correction bytes");const r=e.length-t;if(r<=0)throw new v("No data bytes provided");const n=this.buildGenerator(t),s=new Int32Array(r);G.arraycopy(e,0,s,0,r);let i=new Me(this.field,s);i=i.multiplyByMonomial(t,1);const o=i.divide(n)[1].getCoefficients(),c=t-o.length;for(let u=0;u<c;u++)e[r+u]=0;G.arraycopy(o,0,e,r+c,o.length)}}
43class Ue{constructor(){}static applyMaskPenaltyRule1(e){return Ue.applyMaskPenaltyRule1Internal(e,!0)+Ue.applyMaskPenaltyRule1Internal(e,!1)}static applyMaskPenaltyRule2(e){let t=0;const r=e.getArray(),n=e.getWidth(),s=e.getHeight();for(let i=0;i<s-1;i++){const a=r[i];for(let o=0;o<n-1;o++){const c=a[o];c===a[o+1]&&c===r[i+1][o]&&c===r[i+1][o+1]&&t++}}return Ue.N2*t}static applyMaskPenaltyRule3(e){let t=0;const r=e.getArray(),n=e.getWidth(),s=e.getHeight();for(let i=0;i<s;i++)for(let a=0;a<n;a++){const o=r[i];a+6<n&&o[a]===1&&o[a+1]===0&&o[a+2]===1&&o[a+3]===1&&o[a+4]===1&&o[a+5]===0&&o[a+6]===1&&(Ue.isWhiteHorizontal(o,a-4,a)||Ue.isWhiteHorizontal(o,a+7,a+11))&&t++,i+6<s&&r[i][a]===1&&r[i+1][a]===0&&r[i+2][a]===1&&r[i+3][a]===1&&r[i+4][a]===1&&r[i+5][a]===0&&r[i+6][a]===1&&(Ue.isWhiteVertical(r,a,i-4,i)||Ue.isWhiteVertical(r,a,i+7,i+11))&&t++}return t*Ue.N3}static isWhiteHorizontal(e,t,r){t=Math.max(t,0),r=Math.min(r,e.length);for(let n=t;n<r;n++)if(e[n]===1)return!1;return!0}static isWhiteVertical(e,t,r,n){r=Math.max(r,0),n=Math.min(n,e.length);for(let s=r;s<n;s++)if(e[s][t]===1)return!1;return!0}static applyMaskPenaltyRule4(e){let t=0;const r=e.getArray(),n=e.getWidth(),s=e.getHeight();for(let o=0;o<s;o++){const c=r[o];for(let u=0;u<n;u++)c[u]===1&&t++}const i=e.getHeight()*e.getWidth();return Math.floor(Math.abs(t*2-i)*10/i)*Ue.N4}static getDataMaskBit(e,t,r){let n,s;switch(e){case 0:n=r+t&1;break;case 1:n=r&1;break;case 2:n=t%3;break;case 3:n=(r+t)%3;break;case 4:n=Math.floor(r/2)+Math.floor(t/3)&1;break;case 5:s=r*t,n=(s&1)+s%3;break;case 6:s=r*t,n=(s&1)+s%3&1;break;case 7:s=r*t,n=s%3+(r+t&1)&1;break;default:throw new v("Invalid mask pattern: "+e)}return n===0}static applyMaskPenaltyRule1Internal(e,t){let r=0;const n=t?e.getHeight():e.getWidth(),s=t?e.getWidth():e.getHeight(),i=e.getArray();for(let a=0;a<n;a++){let o=0,c=-1;for(let u=0;u<s;u++){const f=t?i[a][u]:i[u][a];f===c?o++:(o>=5&&(r+=Ue.N1+(o-5)),o=1,c=f)}o>=5&&(r+=Ue.N1+(o-5))}return r}}Ue.N1=3,Ue.N2=3,Ue.N3=40,Ue.N4=10;class Ur{constructor(e,t){this.width=e,this.height=t;const r=new Array(t);for(let n=0;n!==t;n++)r[n]=new Uint8Array(e);this.bytes=r}getHeight(){return this.height}getWidth(){return this.width}get(e,t){return this.bytes[t][e]}getArray(){return this.bytes}setNumber(e,t,r){this.bytes[t][e]=r}setBoolean(e,t,r){this.bytes[t][e]=r?1:0}clear(e){for(const t of this.bytes)$.fill(t,e)}equals(e){if(!(e instanceof Ur))return!1;const t=e;if(this.width!==t.width||this.height!==t.height)return!1;for(let r=0,n=this.height;r<n;++r){const s=this.bytes[r],i=t.bytes[r];for(let a=0,o=this.width;a<o;++a)if(s[a]!==i[a])return!1}return!0}toString(){const e=new pe;for(let t=0,r=this.height;t<r;++t){const n=this.bytes[t];for(let s=0,i=this.width;s<i;++s)switch(n[s]){case 0:e.append(" 0");break;case 1:e.append(" 1");break;default:e.append(" ");break}e.append(` 44`)}return e.toString()}}class er{constructor(){this.maskPattern=-1}getMode(){return this.mode}getECLevel(){return this.ecLevel}getVersion(){return this.version}getMaskPattern(){return this.maskPattern}getMatrix(){return this.matrix}toString(){const e=new pe;return e.append(`<< 45`),e.append(" mode: "),e.append(this.mode?this.mode.toString():"null"),e.append(` 46 ecLevel: `),e.append(this.ecLevel?this.ecLevel.toString():"null"),e.append(` 47 version: `),e.append(this.version?this.version.toString():"null"),e.append(` 48 maskPattern: `),e.append(this.maskPattern.toString()),this.matrix?(e.append(` 49 matrix: 50`),e.append(this.matrix.toString())):e.append(` 51 matrix: null 52`),e.append(`>> 53`),e.toString()}setMode(e){this.mode=e}setECLevel(e){this.ecLevel=e}setVersion(e){this.version=e}setMaskPattern(e){this.maskPattern=e}setMatrix(e){this.matrix=e}static isValidMaskPattern(e){return e>=0&&e<er.NUM_MASK_PATTERNS}}er.NUM_MASK_PATTERNS=8;class Te extends p{}Te.kind="WriterException";class se{constructor(){}static clearMatrix(e){e.clear(255)}static buildMatrix(e,t,r,n,s){se.clearMatrix(s),se.embedBasicPatterns(r,s),se.embedTypeInfo(t,n,s),se.maybeEmbedVersionInfo(r,s),se.embedDataBits(e,n,s)}static embedBasicPatterns(e,t){se.embedPositionDetectionPatternsAndSeparators(t),se.embedDarkD
vendor: 13,261 bytes, line 53
53otAtLeftBottomCorner(t),se.maybeEmbedPositionAdjustmentPatterns(e,t),se.embedTimingPatterns(t)}static embedTypeInfo(e,t,r){const n=new ce;se.makeTypeInfoBits(e,t,n);for(let s=0,i=n.getSize();s<i;++s){const a=n.get(n.getSize()-1-s),o=se.TYPE_INFO_COORDINATES[s],c=o[0],u=o[1];if(r.setBoolean(c,u,a),s<8){const f=r.getWidth()-s-1;r.setBoolean(f,8,a)}else{const x=r.getHeight()-7+(s-8);r.setBoolean(8,x,a)}}}static maybeEmbedVersionInfo(e,t){if(e.getVersionNumber()<7)return;const r=new ce;se.makeVersionInfoBits(e,r);let n=6*3-1;for(let s=0;s<6;++s)for(let i=0;i<3;++i){const a=r.get(n);n--,t.setBoolean(s,t.getHeight()-11+i,a),t.setBoolean(t.getHeight()-11+i,s,a)}}static embedDataBits(e,t,r){let n=0,s=-1,i=r.getWidth()-1,a=r.getHeight()-1;for(;i>0;){for(i===6&&(i-=1);a>=0&&a<r.getHeight();){for(let o=0;o<2;++o){const c=i-o;if(!se.isEmpty(r.get(c,a)))continue;let u;n<e.getSize()?(u=e.get(n),++n):u=!1,t!==255&&Ue.getDataMaskBit(t,c,a)&&(u=!u),r.setBoolean(c,a,u)}a+=s}s=-s,a+=s,i-=2}if(n!==e.getSize())throw new Te("Not all bits consumed: "+n+"/"+e.getSize())}static findMSBSet(e){return 32-W.numberOfLeadingZeros(e)}static calculateBCHCode(e,t){if(t===0)throw new v("0 polynomial");const r=se.findMSBSet(t);for(e<<=r-1;se.findMSBSet(e)>=r;)e^=t<<se.findMSBSet(e)-r;return e}static makeTypeInfoBits(e,t,r){if(!er.isValidMaskPattern(t))throw new Te("Invalid mask pattern");const n=e.getBits()<<3|t;r.appendBits(n,5);const s=se.calculateBCHCode(n,se.TYPE_INFO_POLY);r.appendBits(s,10);const i=new ce;if(i.appendBits(se.TYPE_INFO_MASK_PATTERN,15),r.xor(i),r.getSize()!==15)throw new Te("should not happen but we got: "+r.getSize())}static makeVersionInfoBits(e,t){t.appendBits(e.getVersionNumber(),6);const r=se.calculateBCHCode(e.getVersionNumber(),se.VERSION_INFO_POLY);if(t.appendBits(r,12),t.getSize()!==18)throw new Te("should not happen but we got: "+t.getSize())}static isEmpty(e){return e===255}static embedTimingPatterns(e){for(let t=8;t<e.getWidth()-8;++t){const r=(t+1)%2;se.isEmpty(e.get(t,6))&&e.setNumber(t,6,r),se.isEmpty(e.get(6,t))&&e.setNumber(6,t,r)}}static embedDarkDotAtLeftBottomCorner(e){if(e.get(8,e.getHeight()-8)===0)throw new Te;e.setNumber(8,e.getHeight()-8,1)}static embedHorizontalSeparationPattern(e,t,r){for(let n=0;n<8;++n){if(!se.isEmpty(r.get(e+n,t)))throw new Te;r.setNumber(e+n,t,0)}}static embedVerticalSeparationPattern(e,t,r){for(let n=0;n<7;++n){if(!se.isEmpty(r.get(e,t+n)))throw new Te;r.setNumber(e,t+n,0)}}static embedPositionAdjustmentPattern(e,t,r){for(let n=0;n<5;++n){const s=se.POSITION_ADJUSTMENT_PATTERN[n];for(let i=0;i<5;++i)r.setNumber(e+i,t+n,s[i])}}static embedPositionDetectionPattern(e,t,r){for(let n=0;n<7;++n){const s=se.POSITION_DETECTION_PATTERN[n];for(let i=0;i<7;++i)r.setNumber(e+i,t+n,s[i])}}static embedPositionDetectionPatternsAndSeparators(e){const t=se.POSITION_DETECTION_PATTERN[0].length;se.embedPositionDetectionPattern(0,0,e),se.embedPositionDetectionPattern(e.getWidth()-t,0,e),se.embedPositionDetectionPattern(0,e.getWidth()-t,e);const r=8;se.embedHorizontalSeparationPattern(0,r-1,e),se.embedHorizontalSeparationPattern(e.getWidth()-r,r-1,e),se.embedHorizontalSeparationPattern(0,e.getWidth()-r,e);const n=7;se.embedVerticalSeparationPattern(n,0,e),se.embedVerticalSeparationPattern(e.getHeight()-n-1,0,e),se.embedVerticalSeparationPattern(n,e.getHeight()-n,e)}static maybeEmbedPositionAdjustmentPatterns(e,t){if(e.getVersionNumber()<2)return;const r=e.getVersionNumber()-1,n=se.POSITION_ADJUSTMENT_PATTERN_COORDINATE_TABLE[r];for(let s=0,i=n.length;s!==i;s++){const a=n[s];if(a>=0)for(let o=0;o!==i;o++){const c=n[o];c>=0&&se.isEmpty(t.get(c,a))&&se.embedPositionAdjustmentPattern(c-2,a-2,t)}}}}se.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])]),se.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])]),se.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])]),se.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])]),se.VERSION_INFO_POLY=7973,se.TYPE_INFO_POLY=1335,se.TYPE_INFO_MASK_PATTERN=21522;class Us{constructor(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class ve{constructor(){}static calculateMaskPenalty(e){return Ue.applyMaskPenaltyRule1(e)+Ue.applyMaskPenaltyRule2(e)+Ue.applyMaskPenaltyRule3(e)+Ue.applyMaskPenaltyRule4(e)}static encode(e,t,r=null){let n=ve.DEFAULT_BYTE_MODE_ENCODING;const s=r!==null&&r.get(Ze.CHARACTER_SET)!==void 0;s&&(n=r.get(Ze.CHARACTER_SET).toString());const i=this.chooseMode(e,n),a=new ce;if(i===ne.BYTE&&(s||ve.DEFAULT_BYTE_MODE_ENCODING!==n)){const j=F.getCharacterSetECIByName(n);j!==void 0&&this.appendECI(j,a)}this.appendModeInfo(i,a);const o=new ce;this.appendBytes(e,i,o,n);let c;if(r!==null&&r.get(Ze.QR_VERSION)!==void 0){const j=Number.parseInt(r.get(Ze.QR_VERSION).toString(),10);c=q.getVersionForNumber(j);const k=this.calculateBitsNeeded(i,a,o,c);if(!this.willFit(k,c,t))throw new Te("Data too big for requested version")}else c=this.recommendVersion(t,i,a,o);const u=new ce;u.appendBitArray(a);const f=i===ne.BYTE?o.getSizeInBytes():e.length;this.appendLengthInfo(f,c,i,u),u.appendBitArray(o);const x=c.getECBlocksForLevel(t),E=c.getTotalCodewords()-x.getTotalECCodewords();this.terminateBits(E,u);const I=this.interleaveWithECBytes(u,c.getTotalCodewords(),E,x.getNumBlocks()),y=new er;y.setECLevel(t),y.setMode(i),y.setVersion(c);const N=c.getDimensionForVersion(),O=new Ur(N,N),U=this.chooseMaskPattern(I,t,c,O);return y.setMaskPattern(U),se.buildMatrix(I,t,c,U,O),y.setMatrix(O),y}static recommendVersion(e,t,r,n){const s=this.calculateBitsNeeded(t,r,n,q.getVersionForNumber(1)),i=this.chooseVersion(s,e),a=this.calculateBitsNeeded(t,r,n,i);return this.chooseVersion(a,e)}static calculateBitsNeeded(e,t,r,n){return t.getSize()+e.getCharacterCountBits(n)+r.getSize()}static getAlphanumericCode(e){return e<ve.ALPHANUMERIC_TABLE.length?ve.ALPHANUMERIC_TABLE[e]:-1}static chooseMode(e,t=null){if(F.SJIS.getName()===t&&this.isOnlyDoubleByteKanji(e))return ne.KANJI;let r=!1,n=!1;for(let s=0,i=e.length;s<i;++s){const a=e.charAt(s);if(ve.isDigit(a))r=!0;else if(this.getAlphanumericCode(a.charCodeAt(0))!==-1)n=!0;else return ne.BYTE}return n?ne.ALPHANUMERIC:r?ne.NUMERIC:ne.BYTE}static isOnlyDoubleByteKanji(e){let t;try{t=Se.encode(e,F.SJIS)}catch{return!1}const r=t.length;if(r%2!==0)return!1;for(let n=0;n<r;n+=2){const s=t[n]&255;if((s<129||s>159)&&(s<224||s>235))return!1}return!0}static chooseMaskPattern(e,t,r,n){let s=Number.MAX_SAFE_INTEGER,i=-1;for(let a=0;a<er.NUM_MASK_PATTERNS;a++){se.buildMatrix(e,t,r,a,n);let o=this.calculateMaskPenalty(n);o<s&&(s=o,i=a)}return i}static chooseVersion(e,t){for(let r=1;r<=40;r++){const n=q.getVersionForNumber(r);if(ve.willFit(e,n,t))return n}throw new Te("Data too big")}static willFit(e,t,r){const n=t.getTotalCodewords(),i=t.getECBlocksForLevel(r).getTotalECCodewords(),a=n-i,o=(e+7)/8;return a>=o}static terminateBits(e,t){const r=e*8;if(t.getSize()>r)throw new Te("data bits cannot fit in the QR Code"+t.getSize()+" > "+r);for(let i=0;i<4&&t.getSize()<r;++i)t.appendBit(!1);const n=t.getSize()&7;if(n>0)for(let i=n;i<8;i++)t.appendBit(!1);const s=e-t.getSizeInBytes();for(let i=0;i<s;++i)t.appendBits(i&1?17:236,8);if(t.getSize()!==r)throw new Te("Bits size does not equal capacity")}static getNumDataBytesAndNumECBytesForBlockID(e,t,r,n,s,i){if(n>=r)throw new Te("Block ID too large");const a=e%r,o=r-a,c=Math.floor(e/r),u=c+1,f=Math.floor(t/r),x=f+1,E=c-f,I=u-x;if(E!==I)throw new Te("EC bytes mismatch");if(r!==o+a)throw new Te("RS blocks mismatch");if(e!==(f+E)*o+(x+I)*a)throw new Te("Total bytes mismatch");n<o?(s[0]=f,i[0]=E):(s[0]=x,i[0]=I)}static interleaveWithECBytes(e,t,r,n){if(e.getSizeInBytes()!==r)throw new Te("Number of bits and data bytes does not match");let s=0,i=0,a=0;const o=new Array;for(let u=0;u<n;++u){const f=new Int32Array(1),x=new Int32Array(1);ve.getNumDataBytesAndNumECBytesForBlockID(t,r,n,u,f,x);const E=f[0],I=new Uint8Array(E);e.toBytes(8*s,I,0,E);const y=ve.generateECBytes(I,x[0]);o.push(new Us(I,y)),i=Math.max(i,E),a=Math.max(a,y.length),s+=f[0]}if(r!==s)throw new Te("Data bytes does not match offset");const c=new ce;for(let u=0;u<i;++u)for(const f of o){const x=f.getDataBytes();u<x.length&&c.appendBits(x[u],8)}for(let u=0;u<a;++u)for(const f of o){const x=f.getErrorCorrectionBytes();u<x.length&&c.appendBits(x[u],8)}if(t!==c.getSizeInBytes())throw new Te("Interleaving error: "+t+" and "+c.getSizeInBytes()+" differ.");return c}static generateECBytes(e,t){const r=e.length,n=new Int32Array(r+t);for(let i=0;i<r;i++)n[i]=e[i]&255;new on(ue.QR_CODE_FIELD_256).encode(n,t);const s=new Uint8Array(t);for(let i=0;i<t;i++)s[i]=n[r+i];return s}static appendModeInfo(e,t){t.appendBits(e.getBits(),4)}static appendLengthInfo(e,t,r,n){const s=r.getCharacterCountBits(t);if(e>=1<<s)throw new Te(e+" is bigger than "+((1<<s)-1));n.appendBits(e,s)}static appendBytes(e,t,r,n){switch(t){case ne.NUMERIC:ve.appendNumericBytes(e,r);break;case ne.ALPHANUMERIC:ve.appendAlphanumericBytes(e,r);break;case ne.BYTE:ve.append8BitBytes(e,r,n);break;case ne.KANJI:ve.appendKanjiBytes(e,r);break;default:throw new Te("Invalid mode: "+t)}}static getDigit(e){return e.charCodeAt(0)-48}static isDigit(e){const t=ve.getDigit(e);return t>=0&&t<=9}static appendNumericBytes(e,t){const r=e.length;let n=0;for(;n<r;){const s=ve.getDigit(e.charAt(n));if(n+2<r){const i=ve.getDigit(e.charAt(n+1)),a=ve.getDigit(e.charAt(n+2));t.appendBits(s*100+i*10+a,10),n+=3}else if(n+1<r){const i=ve.getDigit(e.charAt(n+1));t.appendBits(s*10+i,7),n+=2}else t.appendBits(s,4),n++}}static appendAlphanumericBytes(e,t){const r=e.length;let n=0;for(;n<r;){const s=ve.getAlphanumericCode(e.charCodeAt(n));if(s===-1)throw new Te;if(n+1<r){const i=ve.getAlphanumericCode(e.charCodeAt(n+1));if(i===-1)throw new Te;t.appendBits(s*45+i,11),n+=2}else t.appendBits(s,6),n++}}static append8BitBytes(e,t,r){let n;try{n=Se.encode(e,r)}catch(s){throw new Te(s)}for(let s=0,i=n.length;s!==i;s++){const a=n[s];t.appendBits(a,8)}}static appendKanjiBytes(e,t){let r;try{r=Se.encode(e,F.SJIS)}catch(s){throw new Te(s)}const n=r.length;for(let s=0;s<n;s+=2){const i=r[s]&255,a=r[s+1]&255,o=i<<8&4294967295|a;let c=-1;if(o>=33088&&o<=40956?c=o-33088:o>=57408&&o<=60351&&(c=o-49472),c===-1)throw new Te("Invalid byte sequence");const u=(c>>8)*192+(c&255);t.appendBits(u,13)}}static appendECI(e,t){t.appendBits(ne.ECI.getBits(),4),t.appendBits(e.getValue(),8)}}ve.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]),ve.DEFAULT_BYTE_MODE_ENCODING=F.UTF8.getName();class tr{write(e,t,r,n=null){if(e.length===0)throw new v("Found empty contents");if(t<0||r<0)throw new v("Requested dimensions are too small: "+t+"x"+r);let s=Oe.L,i=tr.QUIET_ZONE_SIZE;
53n!==null&&(n.get(Ze.ERROR_CORRECTION)!==void 0&&(s=Oe.fromString(n.get(Ze.ERROR_CORRECTION).toString())),n.get(Ze.MARGIN)!==void 0&&(i=Number.parseInt(n.get(Ze.MARGIN).toString(),10)));const a=ve.encode(e,s,n);return this.renderResult(a,t,r,i)}writeToDom(e,t,r,n,s=null){typeof e=="string"&&(e=document.querySelector(e));const i=this.write(t,r,n,s);e&&e.appendChild(i)}renderResult(e,t,r,n){const s=e.getMatrix();if(s===null)throw new Ot;const i=s.getWidth(),a=s.getHeight(),o=i+n*2,c=a+n*2,u=Math.max(t,o),f=Math.max(r,c),x=Math.min(Math.floor(u/o),Math.floor(f/c)),E=Math.floor((u-i*x)/2),I=Math.floor((f-a*x)/2),y=this.createSVGElement(u,f);for(let N=0,O=I;N<a;N++,O+=x)for(let U=0,j=E;U<i;U++,j+=x)if(s.get(U,N)===1){const k=this.createSvgRectElement(j,O,x,x);y.appendChild(k)}return y}createSVGElement(e,t){const r=document.createElementNS(tr.SVG_NS,"svg");return r.setAttributeNS(null,"height",e.toString()),r.setAttributeNS(null,"width",t.toString()),r}createSvgRectElement(e,t,r,n){const s=document.createElementNS(tr.SVG_NS,"rect");return s.setAttributeNS(null,"x",e.toString()),s.setAttributeNS(null,"y",t.toString()),s.setAttributeNS(null,"height",r.toString()),s.setAttributeNS(null,"width",n.toString()),s.setAttributeNS(null,"fill","#000000"),s}}tr.QUIET_ZONE_SIZE=4,tr.SVG_NS="http://www.w3.org/2000/svg";class ur{encode(e,t,r,n,s){if(e.length===0)throw new v("Found empty contents");if(t!==re.QR_CODE)throw new v("Can only encode QR_CODE, but got "+t);if(r<0||n<0)throw new v(`Requested dimensions are too small: ${r}x${n}`);let i=Oe.L,a=ur.QUIET_ZONE_SIZE;
53s!==null&&(s.get(Ze.ERROR_CORRECTION)!==void 0&&(i=Oe.fromString(s.get(Ze.ERROR_CORRECTION).toString())),s.get(Ze.MARGIN)!==void 0&&(a=Number.parseInt(s.get(Ze.MARGIN).toString(),10)));const o=ve.encode(e,i,s);return ur.renderResult(o,r,n,a)}static renderResult(e,t,r,n){const s=e.getMatrix();if(s===null)throw new Ot;const i=s.getWidth(),a=s.getHeight(),o=i+n*2,c=a+n*2,u=Math.max(t,o),f=Math.max(r,c),x=Math.min(Math.floor(u/o),Math.floor(f/c)),E=Math.floor((u-i*x)/2),I=Math.floor((f-a*x)/2),y=new De(u,f);for(let N=0,O=I;N<a;N++,O+=x)for(let U=0,j=E;U<i;U++,j+=x)s.get(U,N)===1&&y.setRegion(j,O,x,x);return y}}ur.QUIET_ZONE_SIZE=4;class js{encode(e,t,r,n,s){let i;switch(t){case re.QR_CODE:i=new ur;break;default:throw new v("No encoder available for format "+t)}return i.encode(e,t,r,n,s)}}class Bt extends ut{constructor(e,t,r,n,s,i,a,o){if(super(i,a),this.yuvData=e,this.dataWidth=t,this.dataHeight=r,this.left=n,this.top=s,n+i>t||s+a>r)throw new v("Crop rectangle does not fit within image data.");o&&this.reverseHorizontal(i,a)}getRow(e,t){if(e<0||e>=this.getHeight())throw new v("Requested row is outside the image: "+e);const r=this.getWidth();(t==null||t.length<r)&&(t=new Uint8ClampedArray(r));const n=(e+this.top)*this.dataWidth+this.left;return G.arraycopy(this.yuvData,n,t,0,r),t}getMatrix(){const e=this.getWidth(),t=this.getHeight();if(e===this.dataWidth&&t===this.dataHeight)return this.yuvData;const r=e*t,n=new Uint8ClampedArray(r);let s=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return G.arraycopy(this.yuvData,s,n,0,r),n;for(let i=0;i<t;i++){const a=i*e;G.arraycopy(this.yuvData,s,n,a,e),s+=this.dataWidth}return n}isCropSupported(){return!0}crop(e,t,r,n){return new Bt(this.yuvData,this.dataWidth,this.dataHeight,this.left+e,this.top+t,r,n,!1)}renderThumbnail(){const e=this.getWidth()/Bt.THUMBNAIL_SCALE_FACTOR,t=this.getHeight()/Bt.THUMBNAIL_SCALE_FACTOR,r=new Int32Array(e*t),n=this.yuvData;let s=this.top*this.dataWidth+this.left;for(let i=0;i<t;i++){const a=i*e;for(let o=0;o<e;o++){const c=n[s+o*Bt.THUMBNAIL_SCALE_FACTOR]&255;r[a+o]=4278190080|c*65793}s+=this.dataWidth*Bt.THUMBNAIL_SCALE_FACTOR}return r}getThumbnailWidth(){return this.getWidth()/Bt.THUMBNAIL_SCALE_FACTOR}getThumbnailHeight(){return this.getHeight()/Bt.THUMBNAIL_SCALE_FACTOR}reverseHorizontal(e,t){const r=this.yuvData;for(let n=0,s=this.top*this.dataWidth+this.left;n<t;n++,s+=this.dataWidth){const i=s+e/2;for(let a=s,o=s+e-1;a<i;a++,o--){const c=r[a];r[a]=r[o],r[o]=c}}}invert(){return new At(this)}}Bt.THUMBNAIL_SCALE_FACTOR=2;class cn extends ut{constructor(e,t,r,n,s,i,a){if(super(t,r),this.dataWidth=n,this.dataHeight=s,this.left=i,this.top=a,e.BYTES_PER_ELEMENT===4){const o=t*r,c=new Uint8ClampedArray(o);for(let u=0;u<o;u++){const f=e[u],x=f>>16&255,E=f>>7&510,I=f&255;c[u]=(x+E+I)/4&255}this.luminances=c}else this.luminances=e;if(n===void 0&&(this.dataWidth=t),s===void 0&&(this.dataHeight=r),i===void 0&&(this.left=0),a===void 0&&(this.top=0),this.left+t>this.dataWidth||this.top+r>this.dataHeight)throw new v("Crop rectangle does not fit within image data.")}getRow(e,t){if(e<0||e>=this.getHeight())throw new v("Requested row is outside the image: "+e);const r=this.getWidth();(t==null||t.length<r)&&(t=new Uint8ClampedArray(r));const n=(e+this.top)*this.dataWidth+this.left;return G.arraycopy(this.luminances,n,t,0,r),t}getMatrix(){const e=this.getWidth(),t=this.getHeight();if(e===this.dataWidth&&t===this.dataHeight)return this.luminances;const r=e*t,n=new Uint8ClampedArray(r);let s=this.top*this.dataWidth+this.left;if(e===this.dataWidth)return G.arraycopy(this.luminances,s,n,0,r),n;for(let i=0;i<t;i++){const a=i*e;G.arraycopy(this.luminances,s,n,a,e),s+=this.dataWidth}return n}isCropSupported(){return!0}crop(e,t,r,n){return new cn(this.luminances,r,n,this.dataWidth,this.dataHeight,this.left+e,this.top+t)}invert(){return new At(this)}}class Ln extends F{static forName(e){return this.getCharacterSetECIByName(e)}}class ln{}ln.ISO_8859_1=F.ISO8859_1;class Fn{isCompact(){return this.compact}setCompact(e){this.compact=e}getSize(){return this.size}setSize(e){this.size=e}getLayers(){return this.layers}setLayers(e){this.layers=e}
53getCodeWords(){return this.codeWords}setCodeWords(e){this.codeWords=e}getMatrix(){return this.matrix}setMatrix(e){this.matrix=e}}class kn{static singletonList(e){return[e]}static min(e,t){return e.sort(t)[0]}}class Hs{constructor(e){this.previous=e}getPrevious(){return this.previous}}class hr extends Hs{constructor(e,t,r){super(e),this.value=t,this.bitCount=r}appendTo(e,t){e.appendBits(this.value,this.bitCount)}add(e,t){return new hr(this,e,t)}addBinaryShift(e,t){return console.warn("addBinaryShift on SimpleToken, this simply returns a copy of this token"),new hr(this,e,t)}toString(){let e=this.value&(1<<this.bitCount)-1;return e|=1<<this.bitCount,"<"+W.toBinaryString(e|1<<this.bitCount).substring(1)+">"}}class un extends hr{constructor(e,t,r){super(e,0,0),this.binaryShiftStart=t,this.binaryShiftByteCount=r}appendTo(e,t){for(let r=0;r<this.binaryShiftByteCount;r++)(r===0||r===31&&this.binaryShiftByteCount<=62)&&(e.appendBits(31,5),this.binaryShiftByteCount>62?e.appendBits(this.binaryShiftByteCount-31,16):r===0?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(t[this.binaryShiftStart+r],8)}addBinaryShift(e,t){return new un(this,e,t)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function Vs(d,e,t){return new un(d,e,t)}function Sr(d,e,t){return new hr(d,e,t)}const Gs=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],Zt=0,jr=1,It=2,Un=3,Pt=4,Ws=new hr(null,0,0),hn=[Int32Array.from([0,(5<<16)+28,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(9<<16)+480+14,0,(5<<16)+30,(5<<16)+29,656318]),Int32Array.from([(4<<16)+14,(9<<16)+448+28,0,(9<<16)+448+29,932798]),Int32Array.from([(5<<16)+29,(5<<16)+28,656318,0,(5<<16)+30]),Int32Array.from([(5<<16)+31,656380,656382,656381,0])];function Xs(d){for(let e of d)$.fill(e,-1);return d[Zt][Pt]=0,d[jr][Pt]=0,d[jr][Zt]=28,d[Un][Pt]=0,d[It][Pt]=0,d[It][Zt]=15,d}const jn=Xs($.createInt32Array(6,6));class Lt{constructor(e,t,r,n){this.token=e,this.mode=t,this.binaryShiftByteCount=r,this.bitCount=n}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,t){let r=this.bitCount,n=this.token;if(e!==this.mode){let i=hn[this.mode][e];n=Sr(n,i&65535,i>>16),r+=i>>16}let s=e===It?4:5;return n=Sr(n,t,s),new Lt(n,e,0,r+s)}shiftAndAppend(e,t){let r=this.token,n=this.mode===It?4:5;return r=Sr(r,jn[this.mode][e],n),r=Sr(r,t,5),new Lt(r,this.mode,0,this.bitCount+n+5)}addBinaryShiftChar(e){let t=this.token,r=this.mode,n=this.bitCount;if(this.mode===Pt||this.mode===It){let a=hn[r][Zt];t=Sr(t,a&65535,a>>16),n+=a>>16,r=Zt}let s=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,i=new Lt(t,r,this.binaryShiftByteCount+1,n+s);return i.binaryShiftByteCount===2078&&(i=i.endBinaryShift(e+1)),i}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let t=this.token;return t=Vs(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new Lt(t,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let t=this.bitCount+(hn[this.mode][e.mode]>>16);return this.binaryShiftByteCount<e.binaryShiftByteCount?t+=Lt.calculateBinaryShiftCost(e)-Lt.calculateBinaryShiftCost(this):this.binaryShiftByteCount>e.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount}toBitArray(e){let t=[];for(let n=this.endBinaryShift(e.length).token;n!==null;n=n.getPrevious())t.unshift(n);let r=new ce;for(const n of t)n.appendTo(r,e);return r}toString(){return te.format("%s bits=%d bytes=%d",Gs[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}Lt.INITIAL_STATE=new Lt(Ws,Zt,0,0);function Ys(d){const e=te.getCharCode(" "),t=te.getCharCode("."),r=te.getCharCode(",");d[Zt][e]=1;const n=te.getCharCode("Z"),s=te.getCharCode("A");for(let x=s;x<=n;x++)d[Zt][x]=x-s+2;d[jr][e]=1;const i=te.getCharCode("z"),a=te.getCharCode("a");for(let x=a;x<=i;x++)d[jr][x]=x-a+2;d[It][e]=1;const o=te.getCharCode("9"),c=te.getCharCode("0");for(let x=c;x<=o;x++)d[It][x]=x-c+2;d[It][r]=12,d[It][t]=13;const u=["\0"," ","�","�","�","�","�","�","\x07","\b"," ",` 54`,"\v","\f","\r","\x1B","�","�","�","�","@","\\","^","_","`","|","~","�"];for(let x=0;x<u.length;x++)d[Un][te.getCharCode(u[x])]=x;const f=["\0","\r","\0","\0","\0","\0","!","'","#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","[","]","{","}"];for(let x=0;x<f.length;x++)te.getCharCode(f[x])>0&&(d[Pt][te.getCharCode(f[x])]=x);return d}const dn=Ys($.createInt32Array(5,256));class Nr{constructor(e){this.text=e}encode(){const e=te.getCharCode(" "),t=te.getCharCode(` 55`);let r=kn.singletonList(Lt.INITIAL_STATE);for(let s=0;s<this.text.length;s++){let i,a=s+1<this.text.length?this.text[s+1]:0;switch(this.text[s]){case te.getCharCode("\r"):i=a===t?2:0;break;case te.getCharCode("."):i=a===e?3:0;break;case te.getCharCode(","):i=a===e?4:0;break;case te.getCharCode(":"):i=a===e?5:0;break;default:i=0}i>0?(r=Nr.updateStateListForPair(r,s,i),s++):r=this.updateStateListForChar(r,
55s)}return kn.min(r,(s,i)=>s.getBitCount()-i.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,t){const r=[];for(let n of e)this.updateStateForChar(n,t,r);return Nr.simplifyStates(r)}updateStateForChar(e,t,r){let n=this.text[t]&255,s=dn[e.getMode()][n]>0,i=null;for(let a=0;a<=Pt;a++){let o=dn[a][n];if(o>0){if(i==null&&(i=e.endBinaryShift(t)),!s||a===e.getMode()||a===It){const c=i.latchAndAppend(a,o);r.push(c)}if(!s&&jn[e.getMode()][a]>=0){const c=i.shiftAndAppend(a,o);r.push(c)}}}if(e.getBinaryShiftByteCount()>0||dn[e.getMode()][n]===0){let a=e.addBinaryShiftChar(t);r.push(a)}}static updateStateListForPair(e,t,r){const n=[];for(let s of e)this.updateStateForPair(s,t,r,n);return this.simplifyStates(n)}static updateStateForPair(e,t,r,n){let s=e.endBinaryShift(t);if(n.push(s.latchAndAppend(Pt,r)),e.getMode()!==Pt&&n.push(s.shiftAndAppend(Pt,r)),r===3||r===4){let i=s.latchAndAppend(It,16-r).latchAndAppend(It,1);n.push(i)}if(e.getBinaryShiftByteCount()>0){let i=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);n.push(i)}}static simplifyStates(e){let t=[];for(const r of e){let n=!0;for(const s of t){if(s.isBetterThanOrEqualTo(r)){n=!1;break}r.isBetterThanOrEqualTo(s)&&(t=t.filter(i=>i!==s))}n&&t.push(r)}return t}}class Ae{constructor(){}static encodeBytes(e){return Ae.encode(e,Ae.DEFAULT_EC_PERCENT,Ae.DEFAULT_AZTEC_LAYERS)}static encode(e,t,r){let n=new Nr(e).encode(),s=W.truncDivision(n.getSize()*t,100)+11,i=n.getSize()+s,a,o,c,u,f;if(r!==Ae.DEFAULT_AZTEC_LAYERS){if(a=r<0,o=Math.abs(r),o>(a?Ae.MAX_NB_BITS_COMPACT:Ae.MAX_NB_BITS))throw new v(te.format("Illegal value %s for layers",r));c=Ae.totalBitsInLayer(o,a),u=Ae.WORD_SIZE[o];let k=c-c%u;if(f=Ae.stuffBits(n,u),f.getSize()+s>k)throw new v("Data to large for user specified layer");if(a&&f.getSize()>u*64)throw new v("Data to large for user specified layer")}else{u=0,f=null;for(let k=0;;k++){if(k>Ae.MAX_NB_BITS)throw new v("Data too large for an Aztec code");if(a=k<=3,o=a?k+1:k,c=Ae.totalBitsInLayer(o,a),i>c)continue;(f==null||u!==Ae.WORD_SIZE[o])&&(u=Ae.WORD_SIZE[o],f=Ae.stuffBits(n,u));let ge=c-c%u;if(!(a&&f.getSize()>u*64)&&f.getSize()+s<=ge)break}}let x=Ae.generateCheckWords(f,c,u),E=f.getSize()/u,I=Ae.generateModeMessage(a,o,E),y=(a?11:14)+o*4,N=new Int32Array(y),O;if(a){O=y;for(let k=0;k<N.length;k++)N[k]=k}else{O=y+1+2*W.truncDivision(W.truncDivision(y,2)-1,15);let k=W.truncDivision(y,2),ge=W.truncDivision(O,2);for(let he=0;he<k;he++){let xt=he+W.truncDivision(he,15);N[k-he-1]=ge-xt-1,N[k+he]=ge+xt+1}}let U=new De(O);for(let k=0,ge=0;k<o;k++){let he=(o-k)*4+(a?9:12);for(let xt=0;xt<he;xt++){let _t=xt*2;for(let gt=0;gt<2;gt++)x.get(ge+_t+gt)&&U.set(N[k*2+gt],N[k*2+xt]),x.get(ge+he*2+_t+gt)&&U.set(N[k*2+xt],N[y-1-k*2-gt]),x.get(ge+he*4+_t+gt)&&U.set(N[y-1-k*2-gt],N[y-1-k*2-xt]),x.get(ge+he*6+_t+gt)&&U.set(N[y-1-k*2-xt],N[k*2+gt])}ge+=he*8}if(Ae.drawModeMessage(U,a,O,I),a)Ae.drawBullsEye(U,W.truncDivision(O,2),5);else{Ae.drawBullsEye(U,W.truncDivision(O,2),7);for(let k=0,ge=0;k<W.truncDivision(y,2)-1;k+=15,ge+=16)for(let he=W.truncDivision(O,2)&1;he<O;he+=2)U.set(W.truncDivision(O,2)-ge,he),U.set(W.truncDivision(O,2)+ge,he),U.set(he,W.truncDivision(O,2)-ge),U.set(he,W.truncDivision(O,2)+ge)}let j=new Fn;return j.setCompact(a),j.setSize(O),j.setLayers(o),j.setCodeWords(E),j.setMatrix(U),j}static drawBullsEye(e,t,r){for(let n=0;n<r;n+=2)for(let s=t-n;s<=t+n;s++)e.set(s,t-n),e.set(s,t+n),e.set(t-n,s),e.set(t+n,s);e.set(t-r,t-r),e.set(t-r+1,t-r),e.set(t-r,t-r+1),e.set(t+r,t-r),e.set(t+r,t-r+1),e.set(t+r,t+r-1)}static generateModeMessage(e,t,r){let n=new ce;return e?(n.appendBits(t-1,2),n.appendBits(r-1,6),n=Ae.generateCheckWords(n,28,4)):(n.appendBits(t-1,5),n.appendBits(r-1,11),n=Ae.generateCheckWords(n,40,4)),n}static drawModeMessage(e,t,r,n){let s=W.truncDivision(r,2);if(t)for(let i=0;i<7;i++){let a=s-3+i;n.get(i)&&e.set(a,s-5),n.get(i+7)&&e.set(s+5,a),n.get(20-i)&&e.set(a,s+5),n.get(27-i)&&e.set(s-5,a)}else for(let i=0;i<10;i++){let a=s-5+i+W.truncDivision(i,5);n.get(i)&&e.set(a,s-7),n.get(i+10)&&e.set(s+7,a),n.get(29-i)&&e.set(a,s+7),n.get(39-i)&&e.set(s-7,a)}}static generateCheckWords(e,t,r){let n=e.getSize()/r,s=new on(Ae.getGF(r)),i=W.truncDivision(t,r),a=Ae.bitsToWords(e,r,i);s.encode(a,i-n);let o=t%r,c=new ce;c.appendBits(0,o);for(const u of Array.from(a))c.appendBits(u,r);return c}static bitsToWords(e,t,r){let n=new Int32Array(r),s,i;for(s=0,i=e.getSize()/t;s<i;s++){let a=0;for(let o=0;o<t;o++)a|=e.get(s*t+o)?1<<t-o-1:0;n[s]=a}return n}static getGF(e){switch(e){case 4:return ue.AZTEC_PARAM;case 6:return ue.AZTEC_DATA_6;case 8:return ue.AZTEC_DATA_8;case 10:return ue.AZTEC_DATA_10;case 12:return ue.AZTEC_DATA_12;default:throw new v("Unsupported word size "+e)}}static stuffBits(e,t){let r=new ce,n=e.getSize(),s=(1<<t)-2;for(let i=0;i<n;i+=t){let a=0;for(let o=0;o<t;o++)(i+o>=n||e.get(i+o))&&(a|=1<<t-1-o);(a&s)===s?(r.appendBits(a&s,t),i--):a&s?r.appendBits(a,t):(r.appendBits(a|1,t),i--)}return r}static totalBitsInLayer(e,t){return((t?88:112)+16*e)*e}}Ae.DEFAULT_EC_PERCENT=33,Ae.DEFAULT_AZTEC_LAYERS=0,Ae.MAX_NB_BITS=32,Ae.MAX_NB_BITS_COMPACT=4,Ae.WORD_SIZE=Int32Array.from([4,6,6,8,8,8,8,8,8,10,10,10,10,10,10,10,10,10,10,10,10,10,10,12,12,12,12,12,12,12,12,12,12]);class Hr{encode(e,t,r,n){return this.encodeWithHints(e,t,r,n,null)}encodeWithHints(e,t,r,n,s){let i=ln.ISO_8859_1,a=Ae.DEFAULT_EC_PERCENT,o=Ae.DEFAULT_AZTEC_LAYERS;return s!=null&&(s.has(Ze.CHARACTER_SET)&&(i=Ln.forName(s.get(Ze.CHARACTER_SET).toString())),s.has(Ze.ERROR_CORRECTION)&&(a=W.parseInt(s.get(Ze.ER
55ROR_CORRECTION).toString())),s.has(Ze.AZTEC_LAYERS)&&(o=W.parseInt(s.get(Ze.AZTEC_LAYERS).toString()))),Hr.encodeLayers(e,t,r,n,i,a,o)}static encodeLayers(e,t,r,n,s,i,a){if(t!==re.AZTEC)throw new v("Can only encode AZTEC, but got "+t);let o=Ae.encode(te.getBytes(e,s),i,a);return Hr.renderResult(o,r,n)}static renderResult(e,t,r){let n=e.getMatrix();if(n==null)throw new Ot;let s=n.getWidth(),i=n.getHeight(),a=Math.max(t,s),o=Math.max(r,i),c=Math.min(a/s,o/i),u=(a-s*c)/2,f=(o-i*c)/2,x=new De(a,o);for(let E=0,I=f;E<i;E++,I+=c)for(let y=0,N=u;y<s;y++,N+=c)n.get(y,E)&&x.setRegion(N,I,c,c);return x}}l.AbstractExpandedDecoder=Qr,l.ArgumentException=M,l.ArithmeticException=$e,l.AztecCode=Fn,l.AztecCodeReader=vr,l.AztecCodeWriter=Hr,l.AztecDecoder=Re,l.AztecDetector=In,l.AztecDetectorResult=En,l.AztecEncoder=Ae,l.AztecHighLevelEncoder=Nr,l.AztecPoint=ot,l.BarcodeFormat=re,l.Binarizer=be,l.BinaryBitmap=ee,l.BitArray=ce,l.BitMatrix=De,l.BitSource=en,l.BrowserAztecCodeReader=As,l.BrowserBarcodeReader=Is,l.BrowserCodeReader=Ft,l.BrowserDatamatrixCodeReader=Ss,l.BrowserMultiFormatReader=Ls,l.BrowserPDF417Reader=Fs,l.BrowserQRCodeReader=ks,l.BrowserQRCodeSvgWriter=tr,l.CharacterSetECI=F,l.ChecksumException=J,l.Code128Reader=V,l.Code39Reader=Ye,l.DataMatrixDecodedBitStreamParser=Wt,l.DataMatrixReader=Xt,l.DecodeHintType=K,l.DecoderResult=de,l.DefaultGridSampler=bn,l.DetectorResult=Dr,l.EAN13Reader=Qt,l.EncodeHintType=Ze,l.Exception=p,l.FormatException=P,l.GenericGF=ue,l.GenericGFPoly=Me,l.GlobalHistogramBinarizer=Ve,l.GridSampler=Yr,l.GridSamplerInstance=Vt,l.HTMLCanvasElementLuminanceSource=pt,l.HybridBinarizer=le,l.ITFReader=Ne,l.IllegalArgumentException=v,l.IllegalStateException=Ot,l.InvertedLuminanceSource=At,l.LuminanceSource=ut,l.MathUtils=we,l.MultiFormatOneDReader=cr,l.MultiFormatReader=Pn,l.MultiFormatWriter=js,l.NotFoundException=B,l.OneDReader=Xe,l.PDF417DecodedBitStreamParser=R,l.PDF417DecoderErrorCorrection=Rn,l.PDF417Reader=rt,l.PDF417ResultMetadata=Dn,l.PerspectiveTransform=Nt,l.PlanarYUVLuminanceSource=Bt,l.QRCodeByteMatrix=Ur,l.QRCodeDataMask=Et,l.QRCodeDecodedBitStreamParser=Pe,l.QRCodeDecoderErrorCorrectionLevel=Oe,l.QRCodeDecoderFormatInformation=at,l.QRCodeEncoder=ve,l.QRCodeEncoderQRCode=er,l.QRCodeMaskUtil=Ue,l.QRCodeMatrixUtil=se,l.QRCodeMode=ne,l.QRCodeReader=Yt,l.QRCodeVersion=q,l.QRCodeWriter=ur,l.RGBLuminanceSource=cn,l.RSS14Reader=ke,l.RSSExpandedReader=L,l.ReaderException=kr,l.ReedSolomonDecoder=wr,l.ReedSolomonEncoder=on,l.ReedSolomonException=Rt,l.Result=Je,l.ResultMetadataType=Ge,l.ResultPoint=Z,l.StringUtils=te,l.UnsupportedOperationException=lt,l.VideoInputDevice=sr,l.WhiteRectangleDetector=kt,l.WriterException=Te,l.ZXingArrays=$,l.ZXingCharset=Ln,l.ZXingInteger=W,l.ZXingStandardCharsets=ln,l.ZXingStringBuilder=pe,l.ZXingStringEncoding=Se,l.ZXingSystem=G,l.createAbstractExpandedDecoder=Tn,Object.defineProperty(l,"__esModule",{value:!0})})})(An,An.exports);var Le=An.exports;const Ui=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));var Zn=function(){function g(h,l,w){if(this.formatMap=new Map([[Y.QR_CODE,Le.BarcodeFormat.QR_CODE],[Y.AZTEC,Le.BarcodeFormat.AZTEC],[Y.CODABAR,Le.BarcodeFormat.CODABAR],[Y.CODE_39,Le.BarcodeFormat.CODE_39],[Y.CODE_93,Le.BarcodeFormat.CODE_93],[Y.CODE_128,Le.BarcodeFormat.CODE_128],[Y.DATA_MATRIX,Le.BarcodeFormat.DATA_MATRIX],[Y.MAXICODE,Le.BarcodeFormat.MAXICODE],[Y.ITF,Le.BarcodeFormat.ITF],[Y.EAN_13,Le.BarcodeFormat.EAN_13],[Y.EAN_8,Le.BarcodeFormat.EAN_8],[Y.PDF_417,Le.BarcodeFormat.PDF_417],[Y.RSS_14,Le.BarcodeFormat.RSS_14],[Y.RSS_EXPANDED,Le.BarcodeFormat.RSS_EXPANDED],[Y.UPC_A,Le.BarcodeFormat.UPC_A],[Y.UPC_E,Le.BarcodeFormat.UPC_E],[Y.UPC_EAN_EXTENSION,Le.BarcodeFormat.UPC_EAN_EXTENSION]]),this.reverseFormatMap=this.createReverseFormatMap(),!Ui)throw"Use html5qrcode.min.js without edit, ZXing not found.";this.verbose=l,this.logger=w;var b=this.createZXingFormats(h),m=new Map;m.set(Le.DecodeHintType.POSSIBLE_FORMATS,b),m.set(Le.DecodeHintType.TRY_HARDER,!1),this.hints=m}return g.prototype.decodeAsync=function(h){var l=this;return new Promise(function(w,b){try{w(l.decode(h))}catch(m){b(m)}})},g.prototype.decode=function(h){var l=new Le.MultiFormatReader(this.verbose,this.hints),w=new Le.HTMLCanvasElementLuminanceSource(h),b=new Le.BinaryBitmap(new Le.HybridBinarizer(w)),m=l.decode(b);return{text:m.text,format:fs.create(this.toHtml5QrcodeSupportedFormats(m.format)),debugData:this.createDebugData()}},g.prototype.createReverseFormatMap=function(){var h=new Map;
55return this.formatMap.forEach(function(l,w,b){h.set(l,w)}),h},g.prototype.toHtml5QrcodeSupportedFormats=function(h){if(!this.reverseFormatMap.has(h))throw"reverseFormatMap doesn't have ".concat(h);return this.reverseFormatMap.get(h)},g.prototype.createZXingFormats=function(h){for(var l=[],w=0,b=h;w<b.length;w++){var m=b[w];this.formatMap.has(m)?l.push(this.formatMap.get(m)):this.logger.logError("".concat(m," is not supported by")+"ZXingHtml5QrcodeShim")}return l},g.prototype.createDebugData=function(){return{decoderName:"zxing-js"}},g}(),ji=function(g,h,l,w){function b(m){return m instanceof l?m:new l(function(S){S(m)})}return new(l||(l=Promise))(function(m,S){function _(M){try{p(w.next(M))}catch(v){S(v)}}function D(M){try{p(w.throw(M))}catch(v){S(v)}}function p(M){M.done?m(M.value):b(M.value).then(_,D)}p((w=w.apply(g,h||[])).next())})},Hi=function(g,h){var l={label:0,sent:function(){if(m[0]&1)throw m[1];return m[1]},trys:[],ops:[]},w,b,m,S;return S={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function _(p){return function(M){return D([p,M])}}function D(p){if(w)throw new TypeError("Generator is already executing.");for(;S&&(S=0,p[0]&&(l=0)),l;)try{if(w=1,b&&(m=p[0]&2?b.return:p[0]?b.throw||((m=b.return)&&m.call(b),0):b.next)&&!(m=m.call(b,p[1])).done)return m;switch(b=0,m&&(p=[p[0]&2,m.value]),p[0]){case 0:case 1:m=p;break;case 4:return l.label++,{value:p[1],done:!1};case 5:l.label++,b=p[1],p=[0];continue;case 7:p=l.ops.pop(),l.trys.pop();continue;default:if(m=l.trys,!(m=m.length>0&&m[m.length-1])&&(p[0]===6||p[0]===2)){l=0;continue}if(p[0]===3&&(!m||p[1]>m[0]&&p[1]<m[3])){l.label=p[1];break}if(p[0]===6&&l.label<m[1]){l.label=m[1],m=p;break}if(m&&l.label<m[2]){l.label=m[2],l.ops.push(p);break}m[2]&&l.ops.pop(),l.trys.pop();continue}p=h.call(g,l)}catch(M){p=[6,M],b=0}finally{w=m=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Kn=function(){function g(h,l,w){if(this.formatMap=new Map([[Y.QR_CODE,"qr_code"],[Y.AZTEC,"aztec"],[Y.CODABAR,"codabar"],[Y.CODE_39,"code_39"],[Y.CODE_93,"code_93"],[Y.CODE_128,"code_128"],[Y.DATA_MATRIX,"data_matrix"],[Y.ITF,"itf"],[Y.EAN_13,"ean_13"],[Y.EAN_8,"ean_8"],[Y.PDF_417,"pdf417"],[Y.UPC_A,"upc_a"],[Y.UPC_E,"upc_e"]]),this.reverseFormatMap=this.createReverseFormatMap(),!g.isSupported())throw"Use html5qrcode.min.js without edit, Use BarcodeDetectorDelegate only if it isSupported();";this.verbose=l,this.logger=w;var b=this.createBarcodeDetectorFormats(h);if(this.detector=new BarcodeDetector(b),!this.detector)throw"BarcodeDetector detector not supported"}return g.isSupported=function(){if(!("BarcodeDetector"in window))return!1;var h=new BarcodeDetector({formats:["qr_code"]});return typeof h<"u"},g.prototype.decodeAsync=function(h){return ji(this,void 0,void 0,function(){var l,w;return Hi(this,function(b){switch(b.label){case 0:return[4,this.detector.detect(h)];case 1:if(l=b.sent(),!l||l.length===0)throw"No barcode or QR code detected.";return w=this.selectLargestBarcode(l),[2,{text:w.rawValue,format:fs.create(this.toHtml5QrcodeSupportedFormats(w.format)),debugData:this.createDebugData()}]}})})},g.prototype.selectLargestBarcode=function(h){for(var l=null,w=0,b=0,m=h;b<m.length;b++){var S=m[b],_=S.boundingBox.width*S.boundingBox.height;_>w&&(w=_,l=S)}if(!l)throw"No largest barcode found";return l},g.prototype.createBarcodeDetectorFormats=function(h){for(var l=[],w=0,b=h;w<b.length;w++){var m=b[w];this.formatMap.has(m)?l.push(this.formatMap.get(m)):this.logger.warn("".concat(m," is not supported by")+"BarcodeDetectorDelegate")}return{formats:l}},g.prototype.toHtml5QrcodeSupportedFormats=function(h){if(!this.reverseFormatMap.has(h))throw"reverseFormatMap doesn't have ".concat(h);return this.reverseFormatMap.get(h)},g.prototype.createReverseFormatMap=function(){var h=new Map;return this.formatMap.forEach(function(l,w,b){h.set(l,w)}),h},g.prototype.createDebugData=function(){return{decoderName:"BarcodeDetector"}},g}(),Qn=function(g,h,l,w){function b(m){return m instanceof l?m:new l(function(S){S(m)})}return new(l||(l=Promise))(function(m,S){function _(M){try{p(w.next(M))}catch(v){S(v)}}function D(M){try{p(w.throw(M))}catch(v){S(v)}}function p(M){M.done?m(M.value):b(M.value).then(_,D)}p((w=w.apply(g,h||[])).next())})},qn=function(g,h){var l={label:0,sent:function(){if(m[0]&1)throw m[1];return m[1]},trys:[],ops:[]},w,b,m,S;return S={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function _(p){return function(M){return D([p,M])}}function D(p){if(w)throw new TypeError("Generator is already executing.");for(;S&&(S=0,p[0]&&(l=0)),l;)try{if(w=1,b&&(m=p[0]&2?b.return:p[0]?b.throw||((m=b.return)&&m.call(b),
550):b.next)&&!(m=m.call(b,p[1])).done)return m;switch(b=0,m&&(p=[p[0]&2,m.value]),p[0]){case 0:case 1:m=p;break;case 4:return l.label++,{value:p[1],done:!1};case 5:l.label++,b=p[1],p=[0];continue;case 7:p=l.ops.pop(),l.trys.pop();continue;default:if(m=l.trys,!(m=m.length>0&&m[m.length-1])&&(p[0]===6||p[0]===2)){l=0;continue}if(p[0]===3&&(!m||p[1]>m[0]&&p[1]<m[3])){l.label=p[1];break}if(p[0]===6&&l.label<m[1]){l.label=m[1],m=p;break}if(m&&l.label<m[2]){l.label=m[2],l.ops.push(p);break}m[2]&&l.ops.pop(),l.trys.pop();continue}p=h.call(g,l)}catch(M){p=[6,M],b=0}finally{w=m=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Vi=function(){function g(h,l,w,b){this.EXECUTIONS_TO_REPORT_PERFORMANCE=100,this.executions=0,this.executionResults=[],this.wasPrimaryDecoderUsedInLastDecode=!1,this.verbose=w,l&&Kn.isSupported()?(this.primaryDecoder=new Kn(h,w,b),this.secondaryDecoder=new Zn(h,w,b)):this.primaryDecoder=new Zn(h,w,b)}return g.prototype.decodeAsync=function(h){return Qn(this,void 0,void 0,function(){var l;return qn(this,function(w){switch(w.label){case 0:l=performance.now(),w.label=1;case 1:return w.trys.push([1,,3,4]),[4,this.getDecoder().decodeAsync(h)];case 2:return[2,w.sent()];case 3:return this.possiblyLogPerformance(l),[7];case 4:return[2]}})})},g.prototype.decodeRobustlyAsync=function(h){return Qn(this,void 0,void 0,function(){var l,w;return qn(this,function(b){switch(b.label){case 0:l=performance.now(),b.label=1;case 1:return b.trys.push([1,3,4,5]),[4,this.primaryDecoder.decodeAsync(h)];case 2:return[2,b.sent()];case 3:if(w=b.sent(),this.secondaryDecoder)return[2,this.secondaryDecoder.decodeAsync(h)];throw w;case 4:return this.possiblyLogPerformance(l),[7];case 5:return[2]}})})},g.prototype.getDecoder=function(){return this.secondaryDecoder?this.wasPrimaryDecoderUsedInLastDecode===!1?(this.wasPrimaryDecoderUsedInLastDecode=!0,this.primaryDecoder):(this.wasPrimaryDecoderUsedInLastDecode=!1,this.secondaryDecoder):this.primaryDecoder},g.prototype.possiblyLogPerformance=function(h){if(this.verbose){var l=performance.now()-h;this.executionResults.push(l),this.executions++,this.possiblyFlushPerformanceReport()}},g.prototype.possiblyFlushPerformanceReport=function(){if(!(this.executions<this.EXECUTIONS_TO_REPORT_PERFORMANCE)){for(var h=0,l=0,w=this.executionResults;l<w.length;l++){var b=w[l];h+=b}var m=h/this.executionResults.length;"".concat(m," ms for ").concat(this.executionResults.length," last runs."),this.executions=0,this.executionResults=[]}},g}(),Cn=function(){var g=function(h,l){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,b){w.__proto__=b}||function(w,b){for(var m in b)Object.prototype.hasOwnProperty.call(b,m)&&(w[m]=b[m])},g(h,l)};return function(h,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");g(h,l);function w(){this.constructor=h}h.prototype=l===null?Object.create(l):(w.prototype=l.prototype,new w)}}(),Wr=function(g,h,l,w){function b(m){return m instanceof l?m:new l(function(S){S(m)})}return new(l||(l=Promise))(function(m,S){function _(M){try{p(w.next(M))}catch(v){S(v)}}function D(M){try{p(w.throw(M))}catch(v){S(v)}}function p(M){M.done?m(M.value):b(M.value).then(_,D)}p((w=w.apply(g,h||[])).next())})},Xr=function(g,h){var l={label:0,sent:function(){if(m[0]&1)throw m[1];return m[1]},trys:[],ops:[]},w,b,m,S;return S={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function _(p){return function(M){return D([p,M])}}function D(p){if(w)throw new TypeError("Generator is already executing.");for(;S&&(S=0,p[0]&&(l=0)),l;)try{if(w=1,b&&(m=p[0]&2?b.return:p[0]?b.throw||((m=b.return)&&m.call(b),0):b.next)&&!(m=m.call(b,p[1])).done)return m;switch(b=0,m&&(p=[p[0]&2,m.value]),p[0]){case 0:case 1:m=p;break;case 4:return l.label++,{value:p[1],done:!1};case 5:l.label++,b=p[1],p=[0];continue;case 7:p=l.ops.pop(),l.trys.pop();continue;default:if(m=l.trys,!(m=m.length>0&&m[m.length-1])&&(p[0]===6||p[0]===2)){l=0;continue}if(p[0]===3&&(!m||p[1]>m[0]&&p[1]<m[3])){l.label=p[1];break}if(p[0]===6&&l.label<m[1]){l.label=m[1],m=p;break}if(m&&l.label<m[2]){l.label=m[2],l.ops.push(p);break}m[2]&&l.ops.pop(),l.trys.pop();continue}p=h.call(g,l)}catch(M){p=[6,M],b=0}finally{w=m=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},gs=function(){function g(h,l){this.name=h,this.track=l}return g.prototype.isSupported=function(){return this.track.getCapabilities?this.name in this.track.getCapabilities():!1},g.prototype.apply=function(h){var l={};l[this.name]=h;var w={advanced:[l]};return this.track.applyConstraints(w)},g.prototype.value=function(){var h=this.track.getSettings();if(this.name in h){var l=h[this.name];return l}return null},g}(),Gi=function(g){Cn(h,g);function h(l,w){return g.call(this,l,w)||this}return h.prototype.min=function(){return this.getCapabilities().min},h.prototype.max=function(){return this.getCapabilities().max},h.prototype.step=function(){return this.getCapabilities().step},h.prototype.apply=function(l){var w={};w[this.name]=l;var b={advanced:[w]};return this.track.applyConstraints(b)},h.prototype.getCapabilities=function(){this.failIfNotSupported();var l=this.track.getCapabilities(),w=l[this.name];return{min:w.min,max:w.max,step:w.step}},h.prototype.failIfNotSupported=function(){if(!this.isSupported())throw new Error("".concat(this.name," capability not supported"))},h}(gs),Wi=function(g){Cn(h,g);function h(l){return g.call(this,"zoom",l)||this}return h}(Gi),Xi=function(g){Cn(h,g);function h(l){return g.call(this,"torch",l)||this}return h}(gs),Yi=function(){function g(h){this.track=h}return g.prototype.zoomFeature=function(){return new Wi(this.track)},g.prototype.torchFeature=function(){return new Xi(this.track)},g}(),zi=function(){function g(h,l,w){this.isClosed=!1,this.parentElement=h,this.mediaStream=l,this.callbacks=w,this.surface=this.createVideoElement(this.parentElement.clientWidth),h.append(this.surface)}return g.prototype.createVideoElement=function(h){var l=document.createElement("video");return l.style.width="".concat(h,"px"),l.style.display="block",l.muted=!0,l.setAttribute("muted","true"),l.playsInl
55ine=!0,l},g.prototype.setupSurface=function(){var h=this;this.surface.onabort=function(){throw"RenderedCameraImpl video surface onabort() called"},this.surface.onerror=function(){throw"RenderedCameraImpl video surface onerror() called"};var l=function(){var w=h.surface.clientWidth,b=h.surface.clientHeight;h.callbacks.onRenderSurfaceReady(w,b),h.surface.removeEventListener("playing",l)};this.surface.addEventListener("playing",l),this.surface.srcObject=this.mediaStream,this.surface.play()},g.create=function(h,l,w,b){return Wr(this,void 0,void 0,function(){var m,S;return Xr(this,function(_){switch(_.label){case 0:return m=new g(h,l,b),w.aspectRatio?(S={aspectRatio:w.aspectRatio},[4,m.getFirstTrackOrFail().applyConstraints(S)]):[3,2];case 1:_.sent(),_.label=2;case 2:return m.setupSurface(),[2,m]}})})},g.prototype.failIfClosed=function(){if(this.isClosed)throw"The RenderedCamera has already been closed."},g.prototype.getFirstTrackOrFail=function(){if(this.failIfClosed(),this.mediaStream.getVideoTracks().length===0)throw"No video tracks found";return this.mediaStream.getVideoTracks()[0]},g.prototype.pause=function(){this.failIfClosed(),this.surface.pause()},g.prototype.resume=function(h){this.failIfClosed();var l=this,w=function(){setTimeout(h,200),l.surface.removeEventListener("playing",w)};this.surface.addEventListener("playing",w),this.surface.play()},g.prototype.isPaused=function(){return this.failIfClosed(),this.surface.paused},g.prototype.getSurface=function(){return this.failIfClosed(),this.surface},g.prototype.getRunningTrackCapabilities=function(){return this.getFirstTrackOrFail().getCapabilities()},g.prototype.getRunningTrackSettings=function(){return this.getFirstTrackOrFail().getSettings()},g.prototype.applyVideoConstraints=function(h){return Wr(this,void 0,void 0,function(){return Xr(this,function(l){if("aspectRatio"in h)throw"Changing 'aspectRatio' in run-time is not yet supported.";return[2,this.getFirstTrackOrFail().applyConstraints(h)]})})},g.prototype.close=function(){if(this.isClosed)return Promise.resolve();var h=this;return new Promise(function(l,w){var b=h.mediaStream.getVideoTracks(),m=b.length,S=0;h.mediaStream.getVideoTracks().forEach(function(_){h.mediaStream.removeTrack(_),_.stop(),++S,S>=m&&(h.isClosed=!0,h.parentElement.removeChild(h.surface),l())})})},g.prototype.getCapabilities=function(){return new Yi(this.getFirstTrackOrFail())},g}(),Zi=function(){function g(h){this.mediaStream=h}return g.prototype.render=function(h,l,w){return Wr(this,void 0,void 0,function(){return Xr(this,function(b){return[2,zi.create(h,this.mediaStream,l,w)]})})},g.create=function(h){return Wr(this,void 0,void 0,function(){var l,w;return Xr(this,function(b){switch(b.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return l={audio:!1,video:h},[4,navigator.mediaDevices.getUserMedia(l)];case 1:return w=b.sent(),[2,new g(w)]}})})},g}(),Jn=function(g,h,l,w){function b(m){return m instanceof l?m:new l(function(S){S(m)})}return new(l||(l=Promise))(function(m,S){function _(M){try{p(w.next(M))}catch(v){S(v)}}function D(M){try{p(w.throw(M))}catch(v){S(v)}}function p(M){M.done?m(M.value):b(M.value).then(_,D)}p((w=w.apply(g,h||[])).next())})},$n=function(g,h){var l={label:0,sent:function(){if(m[0]&1)throw m[1];return m[1]},trys:[],ops:[]},w,b,m,S;return S={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function _(p){return function(M){return D([p,M])}}function D(p){if(w)throw new TypeError("Generator is already executing.");for(;S&&(S=0,p[0]&&(l=0)),l;)try{if(w=1,b&&(m=p[0]&2?b.return:p[0]?b.throw||((m=b.return)&&m.call(b),0):b.next)&&!(m=m.call(b,p[1])).done)return m;switch(b=0,m&&(p=[p[0]&2,m.value]),p[0]){case 0:case 1:m=p;break;case 4:return l.label++,{value:p[1],done:!1};case 5:l.label++,b=p[1],p=[0];continue;case 7:p=l.ops.pop(),l.trys.pop();continue;default:if(m=l.trys,!(m=m.length>0&&m[m.length-1])&&(p[0]===6||p[0]===2)){l=0;continue}if(p[0]===3&&(!m||p[1]>m[0]&&p[1]<m[3])){l.label=p[1];break}if(p[0]===6&&l.label<m[1]){l.label=m[1],m=p;break}if(m&&l.label<m[2]){l.label=m[2],l.ops.push(p);break}m[2]&&l.ops.pop(),l.trys.pop();continue}p=h.call(g,l)}catch(M){p=[6,M],b=0}finally{w=m=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Ki=function(){function g(){}return g.failIfNotSupported=function(){return Jn(this,void 0,void 0,function(){return $n(this,function(h){if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return[2,new g]})})},g.prototype.create=function(h){return Jn(this,void 0,void 0,function(){return $n(this,function(l){return[2,Zi.create(h)]})})},g}(),Qi=function(g,h,l,w){function b(m){return m instanceof l?m:new l(function(S){S(m)})}return new(l||(l=Promise))(function(m,S){function _(M){try{p(w.next(M))}catch(v){S(v)}}function D(M){try{p(w.throw(M))}catch(v){S(v)}}function p(M){M.done?m(M.value):b(M.value).then(_,D)}p((w=w.apply(g,h||[])).next())})},qi=function(g,h){var l={label:0,sent:function(){if(m[0]&1)throw m[1];return m[1]},trys:[],ops:[]},w,b,m,S;return S={next:_(0),throw:_(1),return:_(2)},typeof Symbol=="function"&&(S[Symbol.iterator]=function(){return this}),S;function _(p){return function(M){return D([p,M])}}function D(p){if(w)throw new TypeError("Generator is already executing.");for(;S&&(S=0,p[0]&&(l=0)),l;)try{if(w=1,b&&(m=p[0]&2?b.return:p[0]?b.throw||((m=b.return)&&m.call(b),
550):b.next)&&!(m=m.call(b,p[1])).done)return m;switch(b=0,m&&(p=[p[0]&2,m.value]),p[0]){case 0:case 1:m=p;break;case 4:return l.label++,{value:p[1],done:!1};case 5:l.label++,b=p[1],p=[0];continue;case 7:p=l.ops.pop(),l.trys.pop();continue;default:if(m=l.trys,!(m=m.length>0&&m[m.length-1])&&(p[0]===6||p[0]===2)){l=0;continue}if(p[0]===3&&(!m||p[1]>m[0]&&p[1]<m[3])){l.label=p[1];break}if(p[0]===6&&l.label<m[1]){l.label=m[1],m=p;break}if(m&&l.label<m[2]){l.label=m[2],l.ops.push(p);break}m[2]&&l.ops.pop(),l.trys.pop();continue}p=h.call(g,l)}catch(M){p=[6,M],b=0}finally{w=m=0}if(p[0]&5)throw p[1];return{value:p[0]?p[1]:void 0,done:!0}}},Ji=function(){function g(){}return g.retrieve=function(){if(navigator.mediaDevices)return g.getCamerasFromMediaDevices();var h=MediaStreamTrack;return MediaStreamTrack&&h.getSources?g.getCamerasFromMediaStreamTrack():g.rejectWithError()},g.rejectWithError=function(){var h=xr.unableToQuerySupportedDevices();return g.isHttpsOrLocalhost()||(h=xr.insecureContextCameraQueryError()),Promise.reject(h)},g.isHttpsOrLocalhost=function(){if(location.protocol==="https:")return!0;var h=location.host.split(":")[0];return h==="127.0.0.1"||h==="localhost"},g.getCamerasFromMediaDevices=function(){return Qi(this,void 0,void 0,function(){var h,l,w,b,m,S,_;return qi(this,function(D){switch(D.label){case 0:return h=function(p){for(var M=p.getVideoTracks(),v=0,ee=M;v<ee.length;v++){var J=ee[v];J.enabled=!1,J.stop(),p.removeTrack(J)}},[4,navigator.mediaDevices.getUserMedia({audio:!1,video:!0})];case 1:return l=D.sent(),[4,navigator.mediaDevices.enumerateDevices()];case 2:for(w=D.sent(),b=[],m=0,S=w;m<S.length;m++)_=S[m],_.kind==="videoinput"&&b.push({id:_.deviceId,label:_.label});return h(l),[2,b]}})})},g.getCamerasFromMediaStreamTrack=function(){return new Promise(function(h,l){var w=function(m){for(var S=[],_=0,D=m;_<D.length;_++){var p=D[_];p.kind==="video"&&S.push({id:p.id,label:p.label})}h(S)},b=MediaStreamTrack;b.getSources(w)})},g}(),je;(function(g){g[g.UNKNOWN=0]="UNKNOWN",g[g.NOT_STARTED=1]="NOT_STARTED",g[g.SCANNING=2]="SCANNING",g[g.PAUSED=3]="PAUSED"})(je||(je={}));var $i=function(){function g(){this.state=je.NOT_STARTED,this.onGoingTransactionNewState=je.UNKNOWN}return g.prototype.directTransition=function(h){this.failIfTransitionOngoing(),this.validateTransition(h),this.state=h},g.prototype.startTransition=function(h){return this.failIfTransitionOngoing(),this.validateTransition(h),this.onGoingTransactionNewState=h,this},g.prototype.execute=function(){if(this.onGoingTransactionNewState===je.UNKNOWN)throw"Transaction is already cancelled, cannot execute().";var h=this.onGoingTransactionNewState;this.onGoingTransactionNewState=je.UNKNOWN,this.directTransition(h)},g.prototype.cancel=function(){if(this.onGoingTransactionNewState===je.UNKNOWN)throw"Transaction is already cancelled, cannot cancel().";this.onGoingTransactionNewState=je.UNKNOWN},g.prototype.getState=function(){return this.state},g.prototype.failIfTransitionOngoing=function(){if(this.onGoingTransactionNewState!==je.UNKNOWN)throw"Cannot transition to a new state, already under transition"},g.prototype.validateTransition=function(h){switch(this.state){case je.UNKNOWN:throw"Transition from unknown is not allowed";case je.NOT_STARTED:this.failIfNewStateIs(h,[je.PAUSED]);break;case je.SCANNING:break;case je.PAUSED:break}},g.prototype.failIfNewStateIs=function(h,l){for(var w=0,b=l;w<b.length;w++){var m=b[w];if(h===m)throw"Cannot transition from ".concat(this.state," to ").concat(h)}},g}(),ea=function(){function g(h){this.stateManager=h}return g.prototype.startTransition=function(h){return this.stateManager.startTransition(h)},g.prototype.directTransition=function(h){this.stateManager.directTransition(h)},g.prototype.getState=function(){return this.stateManager.getState()},g.prototype.canScanFile=function(){return this.stateManager.getState()===je.NOT_STARTED},g.prototype.isScanning=function(){return this.stateManager.getState()!==je.NOT_STARTED},g.prototype.isStrictlyScanning=function(){return this.stateManager.getState()===je.SCANNING},g.prototype.isPaused=function(){return this.stateManager.getState()===je.PAUSED},g}(),ta=function(){function g(){}return g.create=function(){return new ea(new $i)},g}(),ra=function(){var g=function(h,l){return g=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(w,b){w.__proto__=b}||function(w,b){for(var m in b)Object.prototype.hasOwnProperty.call(b,m)&&(w[m]=b[m])},g(h,l)};return function(h,l){if(typeof l!="function"&&l!==null)throw new TypeError("Class extends value "+String(l)+" is not a constructor or null");g(h,l);function w(){this.constructor=h}
55h.prototype=l===null?Object.create(l):(w.prototype=l.prototype,new w)}}(),wt=function(g){ra(h,g);function h(){return g!==null&&g.apply(this,arguments)||this}return h.DEFAULT_WIDTH=300,h.DEFAULT_WIDTH_OFFSET=2,h.FILE_SCAN_MIN_HEIGHT=300,h.FILE_SCAN_HIDDEN_CANVAS_PADDING=100,h.MIN_QR_BOX_SIZE=50,h.SHADED_LEFT=1,h.SHADED_RIGHT=2,h.SHADED_TOP=3,h.SHADED_BOTTOM=4,h.SHADED_REGION_ELEMENT_ID="qr-shaded-region",h.VERBOSE=!1,h.BORDER_SHADER_DEFAULT_COLOR="#ffffff",h.BORDER_SHADER_MATCH_COLOR="rgb(90, 193, 56)",h}(Li),na=function(){function g(h,l){this.logger=l,this.fps=wt.SCAN_DEFAULT_FPS,h?(h.fps&&(this.fps=h.fps),this.disableFlip=h.disableFlip===!0,this.qrbox=h.qrbox,this.aspectRatio=h.aspectRatio,this.videoConstraints=h.videoConstraints):this.disableFlip=wt.DEFAULT_DISABLE_FLIP}return g.prototype.isMediaStreamConstraintsValid=function(){return this.videoConstraints?xs.isMediaStreamConstraintsValid(this.videoConstraints,this.logger):(this.logger.logError("Empty videoConstraints",!0),!1)},g.prototype.isShadedBoxEnabled=function(){return!Ut(this.qrbox)},g.create=function(h,l){return new g(h,l)},g}(),es=function(){function g(h,l){if(this.element=null,this.canvasElement=null,this.scannerPausedUiElement=null,this.hasBorderShaders=null,this.borderShaders=null,this.qrMatch=null,this.renderedCamera=null,this.qrRegion=null,this.context=null,this.lastScanImageFile=null,this.isScanning=!1,!document.getElementById(h))throw"HTML Element with id=".concat(h," not found");this.elementId=h,this.verbose=!1;var w;typeof l=="boolean"?this.verbose=l===!0:l&&(w=l,this.verbose=w.verbose===!0,w.experimentalFeatures),this.logger=new ki(this.verbose),this.qrcode=new Vi(this.getSupportedFormats(l),this.getUseBarCodeDetectorIfSupported(w),this.verbose,this.logger),this.foreverScanTimeout,this.shouldScan=!0,this.stateManagerProxy=ta.create()}return g.prototype.start=function(h,l,w,b){var m=this;if(!h)throw"cameraIdOrConfig is required";if(!w||typeof w!="function")throw"qrCodeSuccessCallback is required and should be a function.";var S;b?S=b:S=this.verbose?this.logger.log:function(){};var _=na.create(l,this.logger);this.clearElement();var D=!1;_.videoConstraints&&(_.isMediaStreamConstraintsValid()?D=!0:this.logger.logError("'videoConstraints' is not valid 'MediaStreamConstraints, it will be ignored.'",!0));var p=D,M=document.getElementById(this.elementId);M.clientWidth?M.clientWidth:wt.DEFAULT_WIDTH,M.style.position="relative",this.shouldScan=!0,this.element=M;var v=this,ee=this.stateManagerProxy.startTransition(je.SCANNING);return new Promise(function(J,be){var G=p?_.videoConstraints:v.createVideoConstraints(h);if(!G){ee.cancel(),be("videoConstraints should be defined");return}var Q={};(!p||_.aspectRatio)&&(Q.aspectRatio=_.aspectRatio);var z={onRenderSurfaceReady:function($,W){v.setupUi($,W,_),v.isScanning=!0,v.foreverScan(_,w,S)}};Ki.failIfNotSupported().then(function($){$.create(G).then(function(W){return W.render(m.element,Q,z).then(function(ce){v.renderedCamera=ce,ee.execute(),J(null)}).catch(function(ce){ee.cancel(),be(ce)})}).catch(function(W){ee.cancel(),be(xr.errorGettingUserMedia(W))})}).catch(function($){ee.cancel(),be(xr.cameraStreamingNotSupported())})})},g.prototype.pause=function(h){if(!this.stateManagerProxy.isStrictlyScanning())throw"Cannot pause, scanner is not scanning.";this.stateManagerProxy.directTransition(je.PAUSED),this.showPausedState(),(Ut(h)||h!==!0)&&(h=!1),h&&this.renderedCamera&&this.renderedCamera.pause()},g.prototype.resume=function(){if(!this.stateManagerProxy.isPaused())throw"Cannot result, scanner is not paused.";if(!this.renderedCamera)throw"renderedCamera doesn't exist while trying resume()";var h=this,l=function(){h.stateManagerProxy.directTransition(je.SCANNING),h.hidePausedState()};if(!this.renderedCamera.isPaused()){l();return}this.renderedCamera.resume(function(){l()})},g.prototype.getState=function(){return this.stateManagerProxy.getState()},g.prototype.stop=function(){var h=this;if(!this.stateManagerProxy.isScanning())throw"Cannot stop, scanner is not running or paused.";var l=this.stateManagerProxy.startTransition(je.NOT_STARTED);this.shouldScan=!1,this.foreverScanTimeout&&clearTimeout(this.foreverScanTimeout);var w=function(){if(h.element){var m=document.getElementById(wt.SHADED_REGION_ELEMENT_ID);m&&h.element.removeChild(m)}},b=this;return this.renderedCamera.close().then(function(){return b.renderedCamera=null,b.element&&(b.element.removeChild(b.canvasElement),b.canvasElement=null),w(),b.qrRegion&&(b.qrRegion=null),b.context&&(b.context=null),l.execute(),b.hidePausedState(),b.isScanning=!1,Promise.resolve()})},g.prototype.scanFile=function(h,l){return this.scanFileV2(h,l).then(function(w){return w.decodedText})},g.prototype.scanFileV2=function(h,l){var w=this;if(!h||!(h instanceof File))throw"imageFile argument is mandatory and should be instance of File. Use 'event.target.files[0]'.";if(Ut(l)&&(l=!0),!this.stateManagerProxy.canScanFile())throw"Cannot start file scan - ongoing camera scan";return new Promise(function(b,m){w.possiblyCloseLastScanImageFile(),w.clearElement(),w.lastScanImageFile=URL.createObjectURL(h);var S=new Image;S.onload=function(){var _=S.width,D=S.height,p=document.getElementById(w.elementId),M=p.clientWidth?p.clientWidth:wt.DEFAULT_WIDTH,v=Math.max(p.clientHeight?p.clientHeight:D,wt.FILE_SCAN_MIN_HEIGHT),ee=w.computeCanvasDrawConfig(_,D,M,v);if(l){var J=w.createCanvasElement(M,v,"qr-canvas-visible");J.style.display="inline-block",p.appendChild(J);var be=J.getContext("2d");if(!be)throw"Unable to get 2d context from canvas";be.canvas.width=M,be.canvas.height=v,be.drawImage(S,0,0,_,D,ee.x,ee.y,ee.width,ee.height)}var G=wt.FILE_SCAN_HIDDEN_CANVAS_PADDING,Q=Math.max(S.width,ee.width),z=Math.max(S.height,ee.height),$=Q+2*G,W=z+2*G,ce=w.createCanvasElement($,W);p.appendChild(ce);var H=ce.getContext("2d");if(!H)throw"Unable to get 2d context from canvas";H.canvas.width=$,H.canvas.height=W,H.drawImage(S,0,0,_,D,G,G,Q,z);try{w.qrcode.decodeRobustlyAsync(ce).then(function(K){b(zn.createFromQrcodeResult(K))}).catch(m)}catch(K){m("QR code parse error, error = ".concat(K))}},S.onerror=m,S.onabort=m,S.onstalled=m,S.onsuspend=m,S.src=URL.createObjectURL(h)})},g.prototype.clear=function(){this.clearElement()},g.getCameras=function(){return Ji.retrieve()},g.prototype.getRunningTrackCapabilities=function(){return this.getRenderedCameraOrFail().getRunningTrackCapabilities()},g.prototype.getRunningTrackSettings=function(){return this.getRenderedCameraOrFail().getRunningTrackSettings()},g.prototype.getRunningTrackCameraCapabilities=function(){return this.getRenderedCameraOrFail().getCapabilities()},g.prototype.applyVideoConstraints=function(h){if(h){if(!xs.isMediaStreamConstraintsValid(h,this.logger))throw"invalid videoConstaints passed, check logs for more details"}else throw"videoConstaints is required argument.";return this.getRenderedCameraOrFail().applyVideoConstraints(h)},g.prototype.getRenderedCameraOrFail=function(){if(this.renderedCamera==null)throw"Scanning is not in running state, call this API only when QR code scanning using camera is in running state.";return this.renderedCamera}
55,g.prototype.getSupportedFormats=function(h){var l=[Y.QR_CODE,Y.AZTEC,Y.CODABAR,Y.CODE_39,Y.CODE_93,Y.CODE_128,Y.DATA_MATRIX,Y.MAXICODE,Y.ITF,Y.EAN_13,Y.EAN_8,Y.PDF_417,Y.RSS_14,Y.RSS_EXPANDED,Y.UPC_A,Y.UPC_E,Y.UPC_EAN_EXTENSION];if(!h||typeof h=="boolean"||!h.formatsToSupport)return l;if(!Array.isArray(h.formatsToSupport))throw"configOrVerbosityFlag.formatsToSupport should be undefined or an array.";if(h.formatsToSupport.length===0)throw"Atleast 1 formatsToSupport is needed.";for(var w=[],b=0,m=h.formatsToSupport;b<m.length;b++){var S=m[b];Pi(S)?w.push(S):this.logger.warn("Invalid format: ".concat(S," passed in config, ignoring."))}if(w.length===0)throw"None of formatsToSupport match supported values.";return w},g.prototype.getUseBarCodeDetectorIfSupported=function(h){if(Ut(h))return!0;if(!Ut(h.useBarCodeDetectorIfSupported))return h.useBarCodeDetectorIfSupported!==!1;if(Ut(h.experimentalFeatures))return!0;var l=h.experimentalFeatures;return Ut(l.useBarCodeDetectorIfSupported)?!0:l.useBarCodeDetectorIfSupported!==!1},g.prototype.validateQrboxSize=function(h,l,w){var b=this,m=w.qrbox;this.validateQrboxConfig(m);var S=this.toQrdimensions(h,l,m),_=function(p){if(p<wt.MIN_QR_BOX_SIZE)throw"minimum size of 'config.qrbox' dimension value is"+" ".concat(wt.MIN_QR_BOX_SIZE,"px.")},D=function(p){return p>h&&(b.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."),p=h),p};_(S.width),_(S.height),S.width=D(S.width)},g.prototype.validateQrboxConfig=function(h){if(typeof h!="number"&&typeof h!="function"&&(h.width===void 0||h.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},g.prototype.toQrdimensions=function(h,l,w){if(typeof w=="number")return{width:w,height:w};if(typeof w=="function")try{return w(h,l)}catch(b){throw new Error("qrbox config was passed as a function but it failed with unknown error"+b)}return w},g.prototype.setupUi=function(h,l,w){w.isShadedBoxEnabled()&&this.validateQrboxSize(h,l,w);var b=Ut(w.qrbox)?{width:h,height:l}:w.qrbox;this.validateQrboxConfig(b);var m=this.toQrdimensions(h,l,b);m.height>l&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var S=w.isShadedBoxEnabled()&&m.height<=l,_={x:0,y:0,width:h,height:l},D=S?this.getShadedRegionBounds(h,l,m):_,p=this.createCanvasElement(D.width,D.height),M={willReadFrequently:!0},v=p.getContext("2d",M);v.canvas.width=D.width,v.canvas.height=D.height,this.element.append(p),S&&this.possiblyInsertShadingElement(this.element,h,l,m),this.createScannerPausedUiElement(this.element),this.qrRegion=D,this.context=v,this.canvasElement=p},g.prototype.createScannerPausedUiElement=function(h){var l=document.createElement("div");l.innerText=xr.scannerPaused(),l.style.display="none",l.style.position="absolute",l.style.top="0px",l.style.zIndex="1",l.style.background="rgba(9, 9, 9, 0.46)",l.style.color="#FFECEC",l.style.textAlign="center",l.style.width="100%",h.appendChild(l),this.scannerPausedUiElement=l},g.prototype.scanContext=function(h,l){var w=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(b){return h(b.text,zn.createFromQrcodeResult(b)),w.possiblyUpdateShaders(!0),!0}).catch(function(b){w.possiblyUpdateShaders(!1);var m=xr.codeParseError(b);return l(m,Fi.createFrom(m)),!1})},g.prototype.foreverScan=function(h,l,w){var b=this;if(this.shouldScan&&this.renderedCamera){var m=this.renderedCamera.getSurface(),S=m.videoWidth/m.clientWidth,_=m.videoHeight/m.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var D=this.qrRegion.width*S,p=this.qrRegion.height*_,M=this.qrRegion.x*S,v=this.qrRegion.y*_;this.context.drawImage(m,M,v,D,p,0,0,this.qrRegion.width,this.qrRegion.height);var ee=function(){b.foreverScanTimeout=setTimeout(function(){b.foreverScan(h,l,w)},b.getTimeoutFps(h.fps))};this.scanContext(l,w).then(function(J){!J&&h.disableFlip!==!0?(b.context.translate(b.context.canvas.width,0),b.context.scale(-1,1),b.scanContext(l,w).finally(function(){ee()})):ee()}).catch(function(J){b.logger.logError("Error happend while scanning context",J),ee()})}},g.prototype.createVideoConstraints=function(h){if(typeof h=="string")return{deviceId:{exact:h}};if(typeof h=="object"){var l="facingMode",w="deviceId",b={user:!0,environment:!0},m="exact",S=function(be){if(be in b)return!0;
55throw"config has invalid 'facingMode' value = "+"'".concat(be,"'")},_=Object.keys(h);if(_.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(_.length," keys");var D=Object.keys(h)[0];if(D!==l&&D!==w)throw"Only '".concat(l,"' and '").concat(w,"' ")+" are supported for 'cameraIdOrConfig'";if(D===l){var p=h.facingMode;if(typeof p=="string"){if(S(p))return{facingMode:p}}else if(typeof p=="object")if(m in p){if(S(p["".concat(m)]))return{facingMode:{exact:p["".concat(m)]}}}else throw"'facingMode' should be string or object with"+" ".concat(m," as key.");else{var M=typeof p;throw"Invalid type of 'facingMode' = ".concat(M)}}else{var v=h.deviceId;if(typeof v=="string")return{deviceId:v};if(typeof v=="object"){if(m in v)return{deviceId:{exact:v["".concat(m)]}};throw"'deviceId' should be string or object with"+" ".concat(m," as key.")}else{var ee=typeof v;throw"Invalid type of 'deviceId' = ".concat(ee)}}}var J=typeof h;throw"Invalid type of 'cameraIdOrConfig' = ".concat(J)},g.prototype.computeCanvasDrawConfig=function(h,l,w,b){if(h<=w&&l<=b){var m=(w-h)/2,S=(b-l)/2;return{x:m,y:S,width:h,height:l}}else{var _=h,D=l;return h>w&&(l=w/h*l,h=w),l>b&&(h=b/l*h,l=b),this.logger.log("Image downsampled from "+"".concat(_,"X").concat(D)+" to ".concat(h,"X").concat(l,".")),this.computeCanvasDrawConfig(h,l,w,b)}},g.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var h=document.getElementById(this.elementId);h&&(h.innerHTML="")},g.prototype.possiblyUpdateShaders=function(h){this.qrMatch!==h&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(l){l.style.backgroundColor=h?wt.BORDER_SHADER_MATCH_COLOR:wt.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=h)},g.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},g.prototype.createCanvasElement=function(h,l,w){var b=h,m=l,S=document.createElement("canvas");return S.style.width="".concat(b,"px"),S.style.height="".concat(m,"px"),S.style.display="none",S.id=Ut(w)?"qr-canvas":w,S},g.prototype.getShadedRegionBounds=function(h,l,w){if(w.width>h||w.height>l)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(h-w.width)/2,y:(l-w.height)/2,width:w.width,height:w.height}},g.prototype.possiblyInsertShadingElement=function(h,l,w,b){if(!(l-b.width<1||w-b.height<1)){var m=document.createElement("div");m.style.position="absolute";var S=(l-b.width)/2,_=(w-b.height)/2;if(m.style.borderLeft="".concat(S,"px solid rgba(0, 0, 0, 0.48)"),m.style.borderRight="".concat(S,"px solid rgba(0, 0, 0, 0.48)"),m.style.borderTop="".concat(_,"px solid rgba(0, 0, 0, 0.48)"),m.style.borderBottom="".concat(_,"px solid rgba(0, 0, 0, 0.48)"),m.style.boxSizing="border-box",m.style.top="0px",m.style.bottom="0px",m.style.left="0px",m.style.right="0px",m.id="".concat(wt.SHADED_REGION_ELEMENT_ID),l-b.width<11||w-b.height<11)this.hasBorderShaders=!1;else{var D=5,p=40;this.insertShaderBorders(m,p,D,-D,null,0,!0),this.insertShaderBorders(m,p,D,-D,null,0,!1),this.insertShaderBorders(m,p,D,null,-D,0,!0),this.insertShaderBorders(m,p,D,null,-D,0,!1),this.insertShaderBorders(m,D,p+D,-D,null,-D,!0),this.insertShaderBorders(m,D,p+D,null,-D,-D,!0),this.insertShaderBorders(m,D,p+D,-D,null,-D,!1),this.insertShaderBorders(m,D,p+D,null,-D,-D,!1),this.hasBorderShaders=!0}h.append(m)}},g.prototype.insertShaderBorders=function(h,l,w,b,m,S,_){var D=document.createElement("div");D.style.position="absolute",D.style.backgroundColor=wt.BORDER_SHADER_DEFAULT_COLOR,D.style.width="".concat(l,"px"),D.style.height="".concat(w,"px"),b!==null&&(D.style.top="".concat(b,"px")),m!==null&&(D.style.bottom="".concat(m,"px")),_?D.style.left="".concat(S,"px"):D.style.right="".concat(S,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(D),h.appendChild(D)},g.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},g.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},g.prototype.getTimeoutFps=function(h){return 1e3/h},g}(),ts;(function(g){g[g.STATUS_DEFAULT=0]="STATUS_DEFAULT",g[g.STATUS_SUCCESS=1]="STATUS_SUCCESS",g[g.STATUS_WARNING=2]="STATUS_WARNING",g[g.STATUS_REQUESTING_PERMISSION=3]="STATUS_REQUESTING_PERMISSION"})(ts||(ts={}));const ms=async g=>{try{const h=g.srcObject;if(!h)return{supportsFocus:!1,focusModes:[],supportsDistance:!1};const l=h.getVideoTracks()[0];if(!l)return{supportsFocus:!1,focusModes:[],supportsDistance:!1};const w=l.getCapabilities();return{supportsFocus:!!w.focusMode,focusModes:w.focusMode||[],supportsDistance:!!w.focusDistance}}catch{return{supportsFocus:!1,focusModes:[],supportsDistance:!1}}},rs=async g=>{try{const h=g.srcObject;if(!h)return!1;const l=h.getVideoTracks()[0];if(!l)return!1;const w=await ms(g);return w.supportsFocus?w.focusModes.includes("single-shot")?(await l.applyConstraints({advanced:[{focusMode:"single-shot"}]}),w.focusModes.includes("continuous")&&setTimeout(async()=>{try{await l.applyConstraints({advanced:[{focusMode:"continuous"}]})}catch{}},800),!0):w.focusModes.includes("continuous")?(await l.applyConstraints({advanced:[{focusMode:"continuous"}]}),!0):!1:!1}catch{return!1}},sa=async g=>{try{const h=g.srcObject;if(!h)return!1;const l=h.getVideoTracks()[0];if(!l)return!1;const w=await ms(g);return!w.supportsFocus||!w.focusModes.includes("continuous")?!1:(await l.applyConstraints({advanced:[{focusMode:"continuous"}]}),!0)}catch{return!1}},ia=(g,h=!1)=>g.length?h?(g.find(w=>/back|environment|rear/i.test(w.label))??g[0]).deviceId:g[0].deviceId:null,gn=()=>/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)||window.innerWidth<=768,ws=ae.forwardRef(({onDecode:g,onError:h,className:l,debug:w=!1,cameraConfig:b},m)=>{var ce;const{t:S}=Ht(),_="html5-qr-reader",D=ae.useRef(null),[p,M]=ae.useState("initializing"),[v,ee]=ae.useState(null),[J,be]=ae.useState(b||{}),[G,Q]=ae.useState(!1);ae.useImperativeHandle(m,()=>({start:async()=>{p!=="ready"&&p!=="stopped"||await z(J)},switchCamera:async H=>{p==="active"&&D.current&&await D.current.stop(),be(H),await z(H)},stop:()=>
55{if(!(p==="stopped"||!D.current)){M("stopped");try{D.current.stop().then(()=>{var H;(H=D.current)==null||H.clear()}).catch(H=>{H.message&&H.message.includes("not running")||w&&console.error("ð± Html5QrScanner: Stop error:",H)})}catch{}}},captureFrame:async()=>{try{const H=document.querySelector(`#${_} video`);if(!H)return null;const K=document.createElement("canvas"),P=K.getContext("2d");if(!P)return null;K.width=H.videoWidth,K.height=H.videoHeight,P.drawImage(H,0,0);const oe=await new Promise(Se=>{K.toBlob(te=>{Se(te)},"image/png")}),F=new File([oe],"frame.png",{type:"image/png"}),lt=new es("temp-manual-scan");try{const Se=await lt.scanFile(F,!1);return Se}catch(Se){return null}finally{lt.clear()}}catch(H){return w&&console.error("ð± Html5QrScanner: Manual capture error:",H),null}},getCameraInfo:async()=>await $(),triggerFocus:async()=>{const H=document.querySelector(`#${_} video`);return H?(Q(!0),setTimeout(()=>Q(!1),600),await rs(H)):!1}}));const z=async H=>{M("starting");try{let K;H.deviceId?(K={deviceId:{exact:H.deviceId}},w&&H.deviceId):H.facingMode?(K={facingMode:H.facingMode},w&&H.facingMode):K={facingMode:gn()?"environment":"user"},D.current||(D.current=new es(_)),await D.current.start(K,{fps:10,qrbox:250},P=>{M("active"),g(P)},P=>{w&&!P.includes("No MultiFormat Readers")&&P.includes("NotFoundException")}),M("active"),setTimeout(()=>{$();const P=document.querySelector(`#${_} video`);P&&sa(P).catch(()=>{})},1e3)}catch(K){w&&console.error("ð± Html5QrScanner: Start error:",K),M("error"),h==null||h(K)}},$=async()=>{try{const K=(await navigator.mediaDevices.enumerateDevices()).filter(F=>F.kind==="videoinput"),P=document.querySelector(`#${_} video`),oe={availableCameras:K.length,cameras:K.map(F=>({id:F.deviceId,label:F.label,facingMode:F.label.toLowerCase().includes("back")||F.label.toLowerCase().includes("environment")?"environment":"user"})),selectedCameraId:ia(K,gn()),currentCameraConfig:J,isMobileDevice:gn(),scannerState:p,hasVideoElement:!!P,videoSize:P?`${P.videoWidth}x${P.videoHeight}`:"N/A"};return ee(oe),oe}catch(H){return w&&console.error("ð± Html5QrScanner: Camera info error:",H),null}};ae.useEffect(()=>(M("ready"),w&&$(),()=>{if(D.current)try{D.current.stop().then(()=>{var H;(H=D.current)==null||H.clear()}).catch(H=>{var K;(K=H.message)!=null&&K.includes("not running")||w&&console.error("ð± Html5QrScanner: Cleanup error:",H)})}catch{}}),[w]);const W=async()=>{if(p!=="active")return;const H=document.querySelector(`#${_} video`);H&&(Q(!0),await rs(H),setTimeout(()=>Q(!1),600))};return A.jsxs("div",{className:`bg-muted rounded-lg overflow-hidden ${l??""}`,children:[A.jsxs("div",{className:"w-full relative",children:[A.jsx("div",{id:_,className:"w-full min-h-[400px] flex items-center justify-center bg-black my-[30px]"}),p==="active"&&A.jsxs("div",{onClick:W,className:"absolute inset-0 cursor-pointer","aria-label":S("dashboard.scan.tapToFocusHint"),children:[A.jsxs("div",{className:"absolute top-4 left-1/2 transform -translate-x-1/2 flex items-center gap-2 bg-muted/80 px-3 py-2 rounded-full",children:[A.jsx(ds,{className:"w-4 h-4 text-primary"}),A.jsx("span",{className:"text-xs text-primary font-medium",children:S("dashboard.scan.tapToFocusHint")})]}),G&&A.jsxs("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:[A.jsx("div",{className:"w-24 h-24 rounded-full border-4 border-primary/70 animate-ping"}),A.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/20 border-2 border-primary absolute animate-pulse"})]})]})]}),A.jsxs("div",{className:"text-center py-2 text-sm text-muted-foreground",children:[p==="initializing"&&S("dashboard.scan.scannerStatusInitializing"),p==="ready"&&S("dashboard.scan.scannerStatusReady"),p==="starting"&&S("dashboard.scan.scannerStatusStarting"),p==="active"&&S("dashboard.scan.scannerStatusActive"),p==="stopped"&&S("dashboard.scan.scannerStatusStopped"),p==="error"&&S("dashboard.scan.scannerStatusError")]}),w&&A.jsxs("div",{className:"absolute top-2 left-2 bg-black/90 text-white text-xs p-3 rounded max-w-xs",children:[A.jsx("div",{className:"font-bold mb-1",children:"Debug Info:"}),A.jsxs("div",{children:["State: ",p]}),A.jsx("div",{children:"API: Html5Qrcode (low-level)"}),v&&A.jsxs(A.Fragment,{children:[A.jsxs("div",{children:["Cameras: ",v.availableCameras]}),A.jsxs("div",{children:["Selected: ",(ce=v.selectedCameraId)==null?void 0:ce.substring(0,8),"..."]}),A.jsxs("div",{children:["Video: ",v.hasVideoElement?"Present":"Missing"]}),v.videoSize&&A.jsxs("div",{children:["Size: ",v.videoSize]})]})]}),A.jsx("div",{id:"temp-manual-scan",className:"hidden"})]})});ws.displayName="Html5QrScanner";const aa=({scannerRef:g,onManualScanResult:h,isProcessing:l=!1,debug:w=!1})=>{const{t:b}=Ht(),[m,S]=ae.useState(!1),_=async()=>
55{if(!(!g.current||l||m)){S(!0);try{const D=await g.current.captureFrame();h(D)}catch(D){w&&console.error("ð± ManualScanButton: Manual scan error:",D),h(null)}finally{S(!1)}}};return A.jsx(st,{onClick:_,disabled:l||m,variant:"brandOutline",children:m?A.jsxs(A.Fragment,{children:[A.jsx(rr,{className:"w-4 h-4 mr-2 animate-pulse"}),b("dashboard.scan.manualScanButtonCapturing")]}):A.jsxs(A.Fragment,{children:[A.jsx(di,{className:"w-4 h-4 mr-2"}),b("dashboard.scan.manualScanButtonLabel")]})})},oa=({isScanning:g,hasCameraAccess:h,lastQRData:l,errorLog:w,scanAttempts:b,cameraInfo:m})=>{const{t:S}=Ht(),_=p=>p===null?"bg-muted":p?"bg-green-500":"bg-red-500",D=p=>S(p===null?"dashboard.scan.debugStatusCheckingText":p?"dashboard.scan.debugStatusActiveText":"dashboard.scan.debugStatusUnavailableText");return A.jsxs(jt,{className:"bg-card border-border",children:[A.jsx(ss,{children:A.jsxs(is,{className:"text-foreground font-geist font-medium flex items-center",children:[A.jsx(Ri,{className:"w-5 h-5 mr-2"}),"Debug Information"]})}),A.jsxs(Kt,{className:"space-y-4",children:[A.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[A.jsxs("div",{className:"flex items-center space-x-2",children:[A.jsx(rr,{className:"w-4 h-4 text-muted-foreground"}),A.jsx("span",{className:"text-sm text-muted-foreground",children:S("dashboard.scan.debugCameraLabel")}),A.jsx(Rr,{className:`${_(h)} text-white`,children:D(h)})]}),A.jsxs("div",{className:"flex items-center space-x-2",children:[A.jsx(fi,{className:"w-4 h-4 text-muted-foreground"}),A.jsx("span",{className:"text-sm text-muted-foreground",children:S("dashboard.scan.debugScannerLabel")}),A.jsx(Rr,{className:`${g?"bg-green-500":"bg-red-500"} text-white`,children:S(g?"dashboard.scan.debugScannerRunningText":"dashboard.scan.debugScannerStoppedText")})]})]}),m&&A.jsxs("div",{className:"bg-muted p-3 rounded border border-border",children:[A.jsxs("div",{className:"flex items-center text-sm text-muted-foreground mb-2",children:[A.jsx(Mi,{className:"w-4 h-4 mr-2"}),S("dashboard.scan.debugCameraDetailsHeading")]}),A.jsxs("div",{className:"text-xs text-foreground space-y-1",children:[A.jsxs("div",{children:[S("dashboard.scan.debugAvailableCamerasLabel"),m.availableCameras||0]}),A.jsxs("div",{children:[S("dashboard.scan.debugScannerStateLabel"),m.scannerState||S("dashboard.scan.unknownScannerState")]}),A.jsxs("div",{children:[S("dashboard.scan.debugStartedLabel"),m.scannerState==="active"?S("dashboard.scan.debugYesText"):S("dashboard.scan.debugNoText")]}),m.cameras&&m.cameras.length>0&&A.jsxs("div",{className:"mt-2",children:[A.jsx("div",{className:"font-medium",children:S("dashboard.scan.debugCamerasListHeading")}),m.cameras.map((p,M)=>A.jsxs("div",{className:"ml-2 text-xs",children:[M+1,". ",p.label||p.id]},M))]})]})]}),A.jsxs("div",{className:"bg-muted p-3 rounded border border-border",children:[A.jsxs("div",{className:"flex items-center text-sm text-muted-foreground mb-2",children:[A.jsx(Oi,{className:"w-4 h-4 mr-2"}),S("dashboard.scan.debugScanStatsHeading")]}),A.jsxs("div",{className:"text-xs text-foreground space-y-1",children:[A.jsxs("div",{children:[S("dashboard.scan.debugScanAttemptsLabel"),b]}),A.jsxs("div",{children:[S("dashboard.scan.debugLastQrCodeLabel"),l?`${l.substring(0,40)}...`:S("dashboard.scan.debugNoneFallback")]}),A.jsxs("div",{children:[S("dashboard.scan.debugErrorLogCountLabel"),w.length]})]})]}),w.length>0&&A.jsxs("div",{className:"bg-red-900/20 p-3 rounded border border-red-500/30",children:[A.jsxs("div",{className:"flex items-center text-red-400 mb-2",children:[A.jsx(xi,{className:"w-4 h-4 mr-2"}),A.jsx("span",{className:"text-sm font-medium",children:S("dashboard.scan.debugErrorLogHeading")})]}),A.jsx("div",{className:"space-y-1 max-h-32 overflow-y-auto",children:w.slice(-5).map((p,M)=>A.jsx("div",{className:"text-xs text-red-300 font-mono",children:p},M))})]}),A.jsxs("div",{className:"bg-muted p-3 rounded border border-border",children:[A.jsx("div",{className:"text-sm text-muted-foreground mb-2",children:S("dashboard.scan.debugPerformanceHeading")}),A.jsxs("div",{className:"text-xs text-foreground",children:[A.jsxs("div",{children:["Timestamp: ",new Date().toLocaleTimeString()]}),A.jsxs("div",{children:["User Agent: ",navigator.userAgent.includes("Mobile")?"Mobile":"Desktop"]})]})]})]})]})},ca=({onCameraChange:g,disabled:h=!1,debug:l=!1})=>{const{t:w}=Ht(),[b,m]=ae.useState([]),[S,_]=ae.useState("environment"),[D,p]=ae.useState(!1),M=ti();ae.useEffect(()=>{(async()=>{await v();const Q=M?"environment":"user";_(Q),g({facingMode:Q})})()},[M]);const v=async()=>{try{const Q=(await navigator.mediaDevices.enumerateDevices()).filter($=>$.kind==="videoinput"),z=Q.map($=>({deviceId:$.deviceId,label:$.label||`Camera ${Q.indexOf($)+1}`,facingMode:ee($.label)}));m(z)}catch(G){l&&console.error("ð± CameraSelector: Error loading cameras:",G)}},ee=G=>{const Q=G.toLowerCase();return Q.includes("back")||Q.includes("environment")||Q.includes("rear")?"environment":Q.includes("front")||Q.includes("user")||Q.includes("face")?"user":"environment"},J=async G=>{if(p(!0),_(G),M)g({facingMode:G});else{const Q=b.find(z=>z.deviceId===G);Q&&g({deviceId:Q.deviceId})}setTimeout(()=>{p(!1)},500)};if(M)return A.jsxs("div",{className:"flex flex-col items-center space-y-2 w-full",children:[A.jsx(st,{onClick:()=>J(S==="environment"?"user":"environment"),disabled:h||D,variant:"outline",className:"border-border text-foreground hover:bg-accent/50 w-full",children:D?A.jsx(cs,{className:"w-4 h-4 animate-spin"}):A.jsxs(A.Fragment,{children:[S==="environment"?A.jsx(Ci,{className:"w-4 h-4 mr-2"}):A.jsx(rr,{className:"w-4 h-4 mr-2"}),w(S==="environment"?"dashboard.scan.switchCameraButtonBack":"dashboard.scan.switchCameraButtonFront")]})}),l&&A.jsxs("span",{className:"text-xs text-foreground",children:["Mode: ",S]})]});if(b.length<=1)return null;const be=S;return A.jsxs("div",{className:"flex flex-col items-center space-y-2 w-full",children:[A.jsxs(gi,{value:be,onValueChange:J,disabled:h||D,
55children:[A.jsx(mi,{className:"w-full border-border text-foreground bg-card hover:bg-accent",children:A.jsx(wi,{placeholder:w("dashboard.scan.cameraSelectPlaceholder")})}),A.jsx(Ai,{className:"bg-card border-border",children:b.map(G=>A.jsx(pi,{value:G.deviceId,className:"text-foreground hover:bg-accent focus:bg-accent",children:A.jsxs("div",{className:"flex items-center",children:[A.jsx(rr,{className:"w-4 h-4 mr-2"}),G.label,G.facingMode&&A.jsxs("span",{className:"ml-2 text-xs opacity-70",children:["(",G.facingMode==="environment"?w("dashboard.scan.cameraFacingBack"):w("dashboard.scan.cameraFacingFront"),")"]})]})},G.deviceId))})]}),l&&A.jsxs("span",{className:"text-xs text-foreground",children:["Cameras: ",b.length]})]})},la=()=>{const[g,h]=ae.useState(null),[l,w]=ae.useState("unknown");ae.useEffect(()=>{if(!navigator.mediaDevices||!navigator.mediaDevices.getUserMedia){console.warn("ð± useCameraAccess: MediaDevices API not available"),h(!1),w("denied");return}let m=null;const S=()=>{if(!m)return;const D=m.state;w(D),h(D!=="denied")};return(async()=>{if("permissions"in navigator)try{m=await navigator.permissions.query({name:"camera"}),w(m.state),m.state,m.state==="denied"?h(!1):h(!0),m.addEventListener("change",S);return}catch(D){console.warn("ð± useCameraAccess: Permissions API not supported:",D)}h(!0),w("prompt")})(),()=>{m&&m.removeEventListener("change",S)}},[]);const b=ae.useCallback(async()=>{h(null);try{return(await navigator.mediaDevices.getUserMedia({video:{facingMode:"environment"}})).getTracks().forEach(S=>S.stop()),h(!0),w("granted"),!0}catch(m){return console.warn("ð± useCameraAccess: Camera access denied via retry:",m),h(!1),w("denied"),!1}},[]);return{hasAccess:g,permissionState:l,retryAccess:b}},ua=3e3,ha=({autoStart:g=!1,manualStart:h=!1})=>{const{t:l}=Ht(),w=ns(),{isAuthenticated:b,userId:m}=pn(),{toast:S}=as(),_=ae.useRef(null),{shopId:D}=ri(),p=ae.useRef(!1),M=ae.useRef(null),v=os(),[ee,J]=ae.useState(!1),[be,G]=ae.useState(h),[Q,z]=ae.useState(!1),[$,W]=ae.useState(""),[ce,H]=ae.useState([]),[K,P]=ae.useState(0),[oe,F]=ae.useState(!1),[lt,Se]=ae.useState(null),[te,pe]=ae.useState({}),{hasAccess:De,permissionState:B,retryAccess:Ve}=la();ae.useEffect(()=>{g&&!h&&De&&!ee&&!oe&&pt()},[g,h,De]);const le=async()=>{try{const de=await Ve();S(de?{title:l("dashboard.scan.cameraActivatedToastTitle"),description:l("dashboard.scan.cameraActivatedToastDescription")}:{title:l("dashboard.scan.cameraErrorToastTitle"),description:l("dashboard.scan.cameraAccessNotGrantedDescription"),variant:"destructive"})}catch{S({title:l("dashboard.scan.cameraErrorToastTitle"),description:l("dashboard.scan.cameraAccessErrorDescription"),variant:"destructive"})}},ut=de=>{const We=new Date().toLocaleTimeString();H(Me=>[...Me,`${We}: ${de}`])},At=async()=>{if(_.current&&Q)try{const de=await _.current.getCameraInfo();Se(de)}catch(de){console.error("ð± QRScanner: Failed to get camera info:",de)}},pt=async()=>{if(_.current&&!ee){G(!1);try{await _.current.start(),J(!0),At()}catch(de){console.error("ð± QRScanner: Start error:",de);const We=de instanceof Error?de.message:l("dashboard.scan.unknownErrorFallback");ut(`Start failed: ${We}`);let Me=l("dashboard.scan.startCameraErrorDefault");We.includes("Keine Kamera gefunden")?Me=l("dashboard.scan.startCameraErrorNoCamera"):We.includes("Permission")&&(Me=l("dashboard.scan.startCameraErrorPermission")),S({title:l("dashboard.scan.cameraErrorToastTitle"),description:Me,variant:"destructive"}),G(!0)}}},sr=()=>{if(_.current&&ee)try{_.current.stop(),J(!1),h&&G(!0),At()}catch{J(!1),h&&G(!0)}},Ke=async(de,We=!1)=>{if(p.current)return;const Me=M.current;if(!(!We&&Me&&Me.data===de&&Date.now()-Me.at<ua)){if(p.current=!0,de.substring(0,50)+"",W(de),P($e=>$e+1),F(!0),!b||!m){const $e="No user logged in";console.error("ð± QRScanner:",$e),ut($e),p.current=!1,F(!1);return}if(!v){const $e="No authenticated client available";console.error("ð± QRScanner:",$e),ut($e),S({title:l("dashboard.scan.authRequiredToastTitle"),description:l("dashboard.scan.authRequiredToastDescription"),variant:"destructive"}),p.current=!1,F(!1);return}try{const ue=await new Bi(D??m,v).scanQRData(de);if(ue.success&&ue.data)ue.data,S({title:l("dashboard.scan.passRecognizedToastTitle"),description:`${l(ue.data.customerName)}
55 - ${l(ue.data.programName)}`}),sr(),w(`/dashboard/stamp-management/${ue.data.enrollmentId}`,{state:{scanMode:"scan"}});else{const Rt=ue.error?l(ue.error):l("dashboard.scan.unknownErrorFallback");M.current={data:de,at:Date.now()},ut(`Scan failed: ${Rt}`),S({title:l("dashboard.scan.qrCodeErrorToastTitle"),description:Rt,variant:"destructive"})}}catch($e){const ue=$e instanceof Error?$e.message:"Unknown error";console.error("ð± QRScanner: Processing error:",$e),M.current={data:de,at:Date.now()},ut(`Processing error: ${ue}`),S({title:l("dashboard.scan.errorTitle"),description:l("dashboard.scan.processingErrorToastDescription"),variant:"destructive"})}finally{p.current=!1,F(!1)}}},Ft=async de=>{await Ke(de)},Je=async de=>{de?await Ke(de,!0):(ut("Manual scan failed - no QR code detected"),S({title:l("dashboard.scan.manualScanFailedToastTitle"),description:l("dashboard.scan.manualScanFailedToastDescription"),variant:"destructive"}))},gr=de=>{console.error("ð± QRScanner: QR Scanner error:",de),ut(`Scanner error: ${de.message}`),S({title:l("dashboard.scan.scannerErrorToastTitle"),description:l("dashboard.scan.scannerErrorToastDescription"),variant:"destructive"})},re=async de=>{if(pe(de),_.current&&ee)try{await _.current.switchCamera(de),At(),setTimeout(()=>{var We;(We=_.current)==null||We.triggerFocus()},1e3)}catch(We){console.error("ð± QRScanner: Camera switch error:",We),ut(`Camera switch failed: ${We instanceof Error?We.message:"Unknown error"}`),S({title:l("dashboard.scan.cameraSwitchFailedToastTitle"),description:l("dashboard.scan.cameraSwitchFailedToastDescription"),variant:"destructive"})}},mr=async()=>{if(!_.current||!ee)return;const de=await _.current.triggerFocus();S({title:l(de?"dashboard.scan.refocusSuccessToastTitle":"dashboard.scan.refocusHintToastTitle"),description:l(de?"dashboard.scan.refocusSuccessDescription":"dashboard.scan.refocusUnsupportedDescription")})},Ge=()=>{sr(),H([]),P(0),W(""),Se(null),pe({}),h&&G(!0),setTimeout(()=>{},500)};return De===null?A.jsxs("div",{className:"max-w-4xl mx-auto",children:[A.jsx("h1",{className:"text-3xl font-bold text-foreground font-geist mb-8 text-center",children:l("dashboard.scan.cameraCheckingHeading")}),A.jsx(jt,{className:"bg-card border-border",children:A.jsxs(Kt,{className:"p-8 text-center",children:[A.jsx("div",{className:"text-muted-foreground",children:l("dashboard.scan.cameraCheckingText")}),A.jsxs("div",{className:"mt-4 text-sm text-muted-foreground/70",children:[l("dashboard.scan.cameraCheckingStatusLabel"),B]})]})})]}):A.jsxs("div",{className:"max-w-4xl mx-auto space-y-6 w-full px-2",children:[be&&De?A.jsx(jt,{className:"bg-card border-border",children:A.jsxs(Kt,{className:"p-8 text-center space-y-6",children:[A.jsx("div",{className:"flex justify-center",children:A.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center",children:A.jsx(rr,{className:"w-10 h-10 text-muted-foreground"})})}),A.jsx(st,{size:"lg",onClick:pt,className:"bg-primary text-primary-foreground hover:bg-primary/90 w-full max-w-md text-lg py-6",disabled:oe,children:l("dashboard.scan.startScanningButton")})]})}):null,!be&&De===!1?A.jsxs(jt,{className:"bg-card border-border",children:[A.jsxs(ss,{className:"text-center",children:[A.jsxs(is,{className:"text-foreground font-geist font-medium flex items-center justify-center",children:[A.jsx(ni,{className:"w-5 h-5 mr-2"}),l("dashboard.scan.cameraAccessRequiredHeading")]}),A.jsx(si,{className:"text-muted-foreground",children:l("dashboard.scan.cameraAccessRequiredDescription")})]}),A.jsxs(Kt,{className:"text-center space-y-4",children:[A.jsxs("div",{className:"text-muted-foreground text-sm space-y-2",children:[A.jsx("p",{className:"font-medium",children:l("dashboard.scan.cameraActivateStepsIntro")}),A.jsxs("div",{className:"text-left max-w-md mx-auto space-y-1",children:[A.jsxs("p",{children:["ð± ",A.jsx("strong",{children:l("dashboard.scan.mobileStepLabel")})," ",l("dashboard.scan.mobileStepText")]}),A.jsxs("p",{children:["ð» ",A.jsx("strong",{children:l("dashboard.scan.desktopStepLabel")})," ",l("dashboard.scan.desktopStepText")]}),A.jsx("p",{children:l("dashboard.scan.reloadStepText")})]}),Q&&A.jsxs("div",{className:"mt-2 text-xs text-muted-foreground
55/60",children:["Permission Status: ",B]})]}),A.jsx("div",{className:"space-y-3",children:A.jsxs(st,{onClick:le,className:"bg-primary text-primary-foreground hover:bg-primary/90",children:[A.jsx(rr,{className:"w-4 h-4 mr-2"}),l("dashboard.common.retry")]})})]})]}):null,A.jsx("div",{style:{display:be?"none":"block"},children:A.jsx(jt,{className:"bg-card border-border",children:A.jsxs(Kt,{children:[A.jsx("div",{className:"mb-6 flex justify-center",children:A.jsx(ws,{ref:_,onDecode:Ft,onError:gr,debug:Q,cameraConfig:te,className:"max-w-lg w-full relative"})}),A.jsxs("div",{className:"text-center space-y-4",children:[A.jsx("div",{className:"flex justify-center",children:A.jsxs(st,{onClick:ee?sr:pt,className:"bg-primary text-primary-foreground hover:bg-primary/90 w-full max-w-lg",disabled:oe,children:[ee?A.jsx(vi,{className:"w-4 h-4 mr-2"}):A.jsx(Ei,{className:"w-4 h-4 mr-2"}),l(ee?"dashboard.scan.scannerStopButton":"dashboard.scan.scannerStartButton")]})}),A.jsx("div",{className:"flex justify-center",children:A.jsx("div",{className:"w-full max-w-lg",children:A.jsx(ca,{onCameraChange:re,disabled:oe,debug:Q})})}),A.jsxs("div",{className:"flex justify-center flex-wrap gap-2",children:[A.jsxs(st,{onClick:mr,variant:"outline",disabled:!ee||oe,title:l("dashboard.scan.focusButtonTitle"),children:[A.jsx(ds,{className:"w-4 h-4 mr-2"}),l("dashboard.scan.focusButton")]}),A.jsx(aa,{scannerRef:_,onManualScanResult:Je,isProcessing:oe,debug:Q}),A.jsxs(st,{onClick:Ge,variant:"outline",children:[A.jsx(cs,{className:"w-4 h-4 mr-2"}),l("dashboard.scan.resetButton")]})]}),A.jsx("div",{className:"text-sm text-muted-foreground",children:oe?A.jsx("span",{className:"text-primary",children:l("dashboard.scan.processingHint")}):ee?null:A.jsx("span",{children:l("dashboard.scan.startScanningHint")})})]})]})})}),Q&&A.jsx(oa,{isScanning:ee,hasCameraAccess:De,lastQRData:$,errorLog:ce,scanAttempts:K,cameraInfo:lt}),A.jsx("div",{className:"text-center text-muted-foreground"})]})},da=({activeMode:g,onModeChange:h,reviewCount:l=0,showReview:w=!1})=>{const{t:b}=Ht();return A.jsxs("div",{className:"flex gap-2 p-1 bg-muted border border-border rounded-lg mb-6",children:[A.jsxs(st,{onClick:()=>h("search"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 ${g==="search"?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground hover:bg-accent/50"}`,variant:g==="search"?"default":"ghost",children:[A.jsx(mn,{className:"w-4 h-4 flex-shrink-0"}),A.jsxs("span",{className:"truncate",children:[A.jsx("span",{className:"md:hidden",children:b("dashboard.scan.searchTabShort")}),A.jsx("span",{className:"hidden md:inline",children:b("dashboard.scan.searchTabLong")})]})]}),A.jsxs(st,{onClick:()=>h("scan"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 ${g==="scan"?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground hover:bg-accent/50"}`,variant:g==="scan"?"default":"ghost",children:[A.jsx(rr,{className:"w-4 h-4 flex-shrink-0"}),A.jsxs("span",{className:"truncate",children:[A.jsx("span",{className:"md:hidden",children:b("dashboard.scan.scanTabShort")}),A.jsx("span",{className:"hidden md:inline",children:b("dashboard.scan.scanTabLong")})]})]}),w&&A.jsxs(st,{onClick:()=>h("review"),className:`flex-1 flex items-center justify-center gap-2 px-3 py-2 ${g==="review"?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground hover:bg-accent/50"}`,variant:g==="review"?"default":"ghost",children:[A.jsx(Di,{className:"w-4 h-4 flex-shrink-0"}),A.jsxs("span",{className:"truncate",children:[A.jsx("span",{className:"md:hidden",children:b("dashboard.scan.reviewTabShort")}),A.jsx("span",{className:"hidden md:inline",children:b("dashboard.scan.reviewTabLong")})]}),l>0&&A.jsx(Rr,{className:"bg-destructive text-destructive-foreground text-xs ml-1",children:l>99?"99+":l})]})]})},fa=()=>{const{getToken:g}=pn(),{toast:h}=as(),{t:l}=Ht(),[w,b]=ae.useState([]),[m,S]=ae.useState(!0),[_,D]=ae.useState(null),[p,M]=ae.useState(null),v=ae.useCallback(async()=>{S(!0);try{b((await xn.queue(g,{status:"needs_review"})).map(bi))}catch(z){console.error("[ReceiptReviewQueue] load error",z),h({title:l("dashboard.receipts.errorTitle"),description:l("dashboard.receipts.loadErrorToastDescription"),variant:"destructive"})}finally{S(!1)}}
55,[h]);ae.useEffect(()=>{v()},[v]);const{url:ee,loading:J}=Ii(g,_!=null&&_.has_photo?_.receipt_id:null),be=z=>D(z),G=()=>D(null),Q=async(z,$)=>{M(z.external_claim_id);try{const W=$==="approve"?await xn.approve(g,z.external_claim_id):await xn.reject(g,z.external_claim_id);h({title:l("dashboard.receipts.successTitle"),description:$==="approve"?(W==null?void 0:W.newStampCount)!=null?l("dashboard.receipts.creditedToastDescriptionWithCount",{count:W.newStampCount}):l("dashboard.receipts.creditedToastDescription"):l("dashboard.receipts.rejectedToastDescription")}),b(ce=>ce.filter(H=>H.external_claim_id!==z.external_claim_id)),(_==null?void 0:_.external_claim_id)===z.external_claim_id&&G()}catch(W){console.error("[ReceiptReviewQueue] decide error",W),h({title:l("dashboard.receipts.errorTitle"),description:l($==="approve"?"dashboard.receipts.approveFailedToastDescription":"dashboard.receipts.rejectFailedToastDescription"),variant:"destructive"})}finally{M(null)}};return m?A.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground py-8 justify-center",children:[A.jsx(_r,{className:"w-4 h-4 animate-spin"})," ",l("dashboard.receipts.loadingReceiptsText")]}):A.jsxs("div",{children:[A.jsxs("div",{className:"flex items-center justify-between mb-4",children:[A.jsx("p",{className:"text-sm text-muted-foreground",children:w.length===0?l("dashboard.receipts.queueEmptyText"):l("dashboard.receipts.queuePendingText",{count:w.length})}),A.jsxs(st,{variant:"outline",size:"sm",onClick:v,children:[A.jsx(Ni,{className:"w-4 h-4 mr-2"}),l("dashboard.receipts.refreshButton")]})]}),w.length>0&&A.jsx(jt,{className:"bg-card border-border",children:A.jsx(Kt,{className:"p-0",children:A.jsxs(ls,{children:[A.jsx(us,{children:A.jsxs(Vr,{className:"border-border",children:[A.jsx(yt,{className:"text-muted-foreground",children:l("dashboard.receipts.merchantColumnHeader")}),A.jsx(yt,{className:"text-muted-foreground",children:l("dashboard.receipts.customerColumnHeader")}),A.jsx(yt,{className:"text-muted-foreground",children:l("dashboard.receipts.dateColumnHeader")}),A.jsx(yt,{className:"text-muted-foreground",children:l("dashboard.receipts.totalColumnHeader")}),A.jsx(yt,{className:"text-muted-foreground",children:l("dashboard.receipts.productsColumnHeader")}),A.jsx(yt,{className:"text-muted-foreground",children:l("dashboard.receipts.ratingColumnHeader")}),A.jsx(yt,{className:"text-muted-foreground text-right",children:l("dashboard.receipts.actionColumnHeader")})]})}),A.jsx(hs,{children:w.map(z=>{var W;const $=((W=z.product_match)==null?void 0:W.matched_tags)??[];return A.jsxs(Vr,{className:"border-border",children:[A.jsx(St,{className:"text-foreground",children:z.merchant||"â"}),A.jsxs(St,{children:[A.jsx("div",{className:"text-foreground",children:z.customer_name||l("dashboard.receipts.unknownCustomer")}),A.jsx("div",{className:"text-xs text-muted-foreground",children:Gn(z,l).join(" · ")})]}),A.jsx(St,{className:"text-muted-foreground",children:z.purchased_at?l("dashboard.receipts.receiptDateShort",{val:new Date(z.purchased_at)}):"â"}),A.jsx(St,{className:"text-foreground",children:z.total?`${z.total} ${z.currency??""}`.trim():"â"}),A.jsx(St,{children:z.product_match===null?A.jsx("span",{className:"text-xs text-muted-foreground",children:l("dashboard.receipts.notMatchedText")}):$.length>0?A.jsx(Rr,{variant:"secondary",children:$.join(", ")}):A.jsx("span",{className:"text-xs text-muted-foreground",children:l("dashboard.receipts.noHitsText")})}),A.jsx(St,{children:Wn(z.trust_score,l)}),A.jsx(St,{className:"text-right",children:A.jsxs("div",{className:"flex gap-1 justify-end",children:[A.jsx(st,{variant:"outline",size:"sm",onClick:()=>be(z),children:A.jsx(Ti,{className:"w-4 h-4"})}),A.jsx(st,{variant:"outline",size:"sm",disabled:p===z.external_claim_id,onClick:()=>Q(z,"approve"),title:l("dashboard.receipts.approveButtonLabel"),children:p===z.external_claim_id?A.jsx(_r,{className:"w-4 h-4 animate-spin"}):A.jsx(Hn,{className:"w-4 h-4"})}),A.jsx(st,{variant:"outline",size:"sm",disabled:p===z.external_claim_id,onClick:()=>Q(z,"reject"),title:l("dashboard.receipts.rejectButtonLabel"),children:A.jsx(Vn,{className:"w-4 h-4"})})]})})]},z.external_claim_id)})})]})})}),A.jsx(ii,{open:!!_,onOpenChange:z=>!z&&G(),children:A.jsxs(ai,{className:"max-w-5xl max-h-[90vh] flex flex-col overflow-hidden gap-0 bg-card border-border",children:[A.jsxs(oi,{className:"shrink-0 border-b border-border pb-4",children:[A.jsx(ci,{className:"font-geist font-medium pr-8",children:(_==null?void 0:_.merchant)||l("dashboard.receipts.receiptDialogFallbackTitle")}),_&&A.jsx("p",{className:"text-sm text-muted-foreground",children:[_.customer_name||l("dashboard.receipts.unknownCustomer"),...Gn(_,l)].join(" · ")})]}),_&&A.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto pt-5 space-y-6 md:space-y-0 md:grid md:grid-cols-2 md:grid-rows-1 md:gap-6 md:overflow-hidden",children:[A.jsxs("div",{className:"md:min-h-0 md:flex md:flex-col",children:[A.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:l("dashboard.receipts.photoHeading")}),J?A.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[A.jsx(_r,{className:"w-4 h-4 animate-spin"})," ",l("dashboard.receipts.loadingPhotoText")]}):ee?A.jsx(yi,{src:ee,alt:l("dashboard.receipts.photoAltFallback"),
55className:"max-h-[60vh] md:max-h-none md:flex-1 md:min-h-0",t:l}):A.jsx("p",{className:"text-sm text-muted-foreground",children:l("dashboard.receipts.noPhotoText")})]}),A.jsxs("div",{className:"space-y-4 md:min-h-0 md:overflow-y-auto",children:[A.jsxs("div",{children:[A.jsx("h4",{className:"text-sm font-medium text-foreground mb-2",children:l("dashboard.receipts.cartHeading")}),A.jsxs("div",{className:"space-y-1",children:[(_.line_items??[]).map((z,$)=>{var ce,H,K;const W=(K=(H=(ce=_.product_match)==null?void 0:ce.items)==null?void 0:H[$])==null?void 0:K.tag;return A.jsxs("div",{className:"flex justify-between text-sm",children:[A.jsxs("span",{className:"text-muted-foreground",children:[z.description,W&&A.jsx(Rr,{variant:"secondary",className:"ml-2 text-xs",children:W})]}),A.jsx("span",{className:"text-foreground",children:z.amount})]},$)}),A.jsxs("div",{className:"flex justify-between text-sm border-t border-border pt-1 mt-1",children:[A.jsx("span",{className:"text-foreground font-medium",children:l("dashboard.receipts.cartTotalLabel")}),A.jsxs("span",{className:"text-foreground font-medium",children:[_.total," ",_.currency]})]})]})]}),A.jsxs("div",{children:[A.jsxs("h4",{className:"text-sm font-medium text-foreground mb-2",children:[l("dashboard.receipts.ratingHeading")," ",Wn(_.trust_score,l)]}),A.jsxs("div",{className:"space-y-1",children:[Object.entries(_.trust_components??{}).map(([z,$])=>A.jsxs("div",{className:"flex justify-between text-xs",children:[A.jsx("span",{className:"text-muted-foreground",children:l(Si[z]??z)}),A.jsx("span",{className:$===0?"text-destructive":"text-foreground",children:l($===0?"dashboard.receipts.signalFailedText":"dashboard.receipts.signalPassedText")})]},z)),!_.trust_components&&A.jsx("p",{className:"text-xs text-muted-foreground",children:l("dashboard.receipts.noSignalsText")})]})]}),A.jsxs("div",{className:"flex gap-2 pt-2",children:[A.jsxs(st,{className:"flex-1",disabled:p===_.external_claim_id,onClick:()=>Q(_,"approve"),children:[A.jsx(Hn,{className:"w-4 h-4 mr-2"}),l("dashboard.receipts.approveButtonLabel")]}),A.jsxs(st,{variant:"outline",className:"flex-1",disabled:p===_.external_claim_id,onClick:()=>Q(_,"reject"),children:[A.jsx(Vn,{className:"w-4 h-4 mr-2"}),l("dashboard.receipts.rejectButtonLabel")]})]})]})]})]})})]})},xa=()=>{const g=ns(),{t:h}=Ht(),{userId:l}=pn(),w=os(),b=50,[m,S]=ae.useState(""),[_,D]=ae.useState(""),[p,M]=ae.useState([]),[v,ee]=ae.useState(!1),[J,be]=ae.useState(!0),[G,Q]=ae.useState(!1);ae.useEffect(()=>{const H=setTimeout(()=>D(m.trim()),250);return()=>clearTimeout(H)},[m]);const z=ae.useRef(0),$=h("dashboard.scan.unknownCustomerName"),W=h("dashboard.scan.unknownProgramName");ae.useEffect(()=>{if(!l||!w)return;const H=++z.current;(async()=>{Q(!0);try{const K=await w.customerDataManager.getCustomersPage({limit:b,search:_||void 0});if(H!==z.current)return;M(K.items.map(P=>{var oe,F,lt,Se,te;return{id:((oe=P.customer)==null?void 0:oe.id)||"",name:P.customerName||((F=P.customer)==null?void 0:F.name)||$,email:((lt=P.customer)==null?void 0:lt.email)||"",program_name:((Se=P.program)==null?void 0:Se.name)||W,stamps_count:P.stampsCount||0,enrollment_id:P.id,customer_number:P.customerNumber,program_type:((te=P.program)==null?void 0:te.programType)||"stamp_collection"}})),ee(K.nextCursor!==null)}catch(K){if(H!==z.current)return;console.error("â Error fetching customers:",K),M([]),ee(!1)}finally{H===z.current&&(Q(!1),be(!1))}})()},[l,w,_]);const ce=H=>{g(`/dashboard/stamp-management/${H}`,{state:{scanMode:"search"}})};return J?A.jsx(jt,{className:"bg-card border-border",children:A.jsxs(Kt,{className:"p-8 text-center",children:[A.jsx(_r,{className:"w-8 h-8 animate-spin mx-auto text-bonice-baby"}),A.jsx("p",{className:"mt-4 text-muted-foreground",children:h("dashboard.scan.customerSearchLoadingText")})]})}):A.jsx(jt,{className:"bg-card border-border",children:A.jsxs(Kt,{className:"p-6",children:[A.jsxs("div",{className:"relative mb-6",children:[G?A.jsx(_r,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-5 h-5 animate-spin"}):A.jsx(mn,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-muted-foreground w-5 h-5"}),A.jsx(li,{type:"text",placeholder:h("dashboard.scan.customerSearchPlaceholder"),value:m,onChange:H=>S(H.target.value),className:"pl-10 bg-card border-border text-foreground placeholder:text-muted-foreground"})]}),p.length===0?A.jsx("div",{className:"text-center py-12 text-muted-foreground",children:m.trim()?A.jsxs(A.Fragment,{children:[A.jsx(mn,{className:"w-12 h-12 mx-auto mb-4 opacity-50"}),A.jsx("p",{className:"text-lg font-medium",children:h("dashboard.scan.noResultsHeading")}),A.jsx("p",{className:"text-sm mt-2 opacity-70",children:h("dashboard.scan.noResultsHint")})]}):A.jsxs(A.Fragment,{children:[A.jsx("p",{className:"text-lg font-medium",children:h("dashboard.scan.emptyCustomersHeading")}),A.jsx("p",{className:"text-sm mt-2 opacity-70",children:h("dashboard.scan.emptyCustomersHint")})]})}):A.jsx("div",{className:"overflow-x-auto",children:A.jsxs(ls,{children:[A.jsx(us,{children:A.jsxs(Vr,{className:"border-border hover:bg-accent/50",children:[A.jsx(yt,{className:"text-foreground font-geist font-medium",children:h("dashboard.scan.nameColumnHeader")}),A.jsx(yt,{className:"text-foreground font-geist font-medium",children:h("dashboard.scan.emailColumnHeader")}),A.jsx(yt,{className:"text-foreground font-geist font-medium",children:h("dashboard.scan.customerNumberColumnHeader")}),A.jsx(yt,{className:"text-foreground font-geist font-medium",children:h("dashboard.scan.programColumnHeader")}),A.jsx(yt,{className:"text-foreground font-geist font-medium text-right",children:h("dashboard.scan.stampsPointsColumnHeader")})]})}),A.jsx(hs,{children:p.map(H=>A.jsxs(Vr,{onClick:()=>ce(H.enrollment_id),className:"border-border hover:bg-accent/50 cursor-pointer transition-colors",children:[A.jsx(St,{className:"text-foreground font-medium",children:H.name}),A.jsx(St,{className:"text-muted-foreground",children:H.email}),A.jsx(St,{className:"text-muted-foreground",children:H.customer_number?String(H.customer_number).length>4?String(H.customer_number):String(H.customer_number).padStart(4,"0"):"-"}),A.jsx(St,{className:"text-muted-foreground",children:H.program_name}),A.jsx(St,{className:"text-foreground text-right font-semibold",children:H.program_type==="membership"?"-":(H.program_type==="points",H.stamps_count)})]},H.enrollment_id))})]})}),A.jsx("div",{className:"mt-4 text-sm text-muted-foreground text-center",children:v?h("dashboard.scan.resultsNarrowSearch",{shown:p.length}):h("dashboard.scan.resultsFound",{count:p.length})})]})})},ja=()=>{const{t:g}=Ht(),h=qs(),[l,w]=ae.useState("scan"),{needsReview:b}=$s(),{isAdmin:m,isTester:S}=ui(),_=m||S;return ae.useEffect(()=>{var D;(D=h.state)!=null&&D.scanMode&&w(h.state.scanMode)},[h.state]),A.jsxs("div",{className:"min-h-screen w-full overflow-x-hidden",children:[A.jsx(_i,{}),A.jsx(hi,{title:g("dashboard.scan.seoTitle"),description:g("dashboard.scan.seoDescription"),noindex:!0}),A.jsx(ei,{currentPage:"scan"}),A.jsxs("main",{className:"px-4 md:px-6 py-6 md:py-8 w-full",children:[A.jsx("h1",{className:"text-3xl font-bold text-foreground font-geist mb-8",children:g("dashboard.scan.pageHeading")}),A.jsxs("div",{className:"max-w-4xl mx-auto",children:[A.jsx("div",{role:"note",className:"mb-6 rounded-lg border border-border bg-muted/50 px-4 py-3 text-sm text-muted-foreground",children:g("dashboard.scan.scanHint")}),A.jsx(da,{activeMode:l,onModeChange:w,reviewCount:b,showReview:m}),l==="search"?A.jsx(xa,{}):l==="review"&&m?A.jsx(fa,{}):A.jsx(ha,{manualStart:!0})]}),_&&A.jsx(jt,{className:"mt-8 bg-card border-bonice-baby p-4",children:A.jsxs("div",{className:"flex flex-col md:flex-row items-start md:items-center justify-between gap-4",children:[A.jsxs("div",{children:[A.jsx("h2",{className:"text-lg font-semibold text-foreground font-geist",children:g("dashboard.scan.nf
55cTestTitle")}),A.jsx("p",{className:"text-sm text-muted-foreground",children:g("dashboard.scan.nfcTestDescription")})]}),A.jsx(st,{asChild:!0,variant:"outline",size:"sm",children:A.jsx(Js,{to:"/nfc",children:g("dashboard.scan.nfcTestButton")})})]})})]})]})};export{ja as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.