var r0=Object.create;var ca=Object.defineProperty;var i0=Object.getOwnPropertyDescriptor;var s0=Object.getOwnPropertyNames;var o0=Object.getPrototypeOf,a0=Object.prototype.hasOwnProperty;var Se=(r,a)=>()=>{try{return a||r((a={exports:{}}).exports,a),a.exports}catch(s){throw a=0,s}};var l0=(r,a,s,f)=>{if(a&&typeof a=="object"||typeof a=="function")for(let d of s0(a))!a0.call(r,d)&&d!==s&&ca(r,d,{get:()=>a[d],enumerable:!(f=i0(a,d))||f.enumerable});return r};var Br=(r,a,s)=>(s=r!=null?r0(o0(r)):{},l0(a||!r||!r.__esModule?ca(s,"default",{value:r,enumerable:!0}):s,r));var ua=Se((Rd,fa)=>{fa.exports=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then}});var En=Se(Ln=>{var Ns,c0=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];Ln.getSymbolSize=function(a){if(!a)throw new Error('"version" cannot be null or undefined');if(a<1||a>40)throw new Error('"version" should be in range from 1 to 40');return a*4+17};Ln.getSymbolTotalCodewords=function(a){return c0[a]};Ln.getBCHDigit=function(r){let a=0;for(;r!==0;)a++,r>>>=1;return a};Ln.setToSJISFunction=function(a){if(typeof a!="function")throw new Error('"toSJISFunc" is not a valid function.');Ns=a};Ln.isKanjiModeEnabled=function(){return typeof Ns<"u"};Ln.toSJIS=function(a){return Ns(a)}});var Ii=Se(Lt=>{Lt.L={bit:1};Lt.M={bit:0};Lt.Q={bit:3};Lt.H={bit:2};function f0(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"l":case"low":return Lt.L;case"m":case"medium":return Lt.M;case"q":case"quartile":return Lt.Q;case"h":case"high":return Lt.H;default:throw new Error("Unknown EC Level: "+r)}}Lt.isValid=function(a){return a&&typeof a.bit<"u"&&a.bit>=0&&a.bit<4};Lt.from=function(a,s){if(Lt.isValid(a))return a;try{return f0(a)}catch{return s}}});var ga=Se((Bd,da)=>{function ha(){this.buffer=[],this.length=0}ha.prototype={get:function(r){let a=Math.floor(r/8);return(this.buffer[a]>>>7-r%8&1)===1},put:function(r,a){for(let s=0;s>>a-s-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(r){let a=Math.floor(this.length/8);this.buffer.length<=a&&this.buffer.push(0),r&&(this.buffer[a]|=128>>>this.length%8),this.length++}};da.exports=ha});var wa=Se((Ld,xa)=>{function Lr(r){if(!r||r<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=r,this.data=new Uint8Array(r*r),this.reservedBit=new Uint8Array(r*r)}Lr.prototype.set=function(r,a,s,f){let d=r*this.size+a;this.data[d]=s,f&&(this.reservedBit[d]=!0)};Lr.prototype.get=function(r,a){return this.data[r*this.size+a]};Lr.prototype.xor=function(r,a,s){this.data[r*this.size+a]^=s};Lr.prototype.isReserved=function(r,a){return this.reservedBit[r*this.size+a]};xa.exports=Lr});var pa=Se(bi=>{var u0=En().getSymbolSize;bi.getRowColCoords=function(a){if(a===1)return[];let s=Math.floor(a/7)+2,f=u0(a),d=f===145?26:Math.ceil((f-13)/(2*s-2))*2,h=[f-7];for(let p=1;p{var h0=En().getSymbolSize,Aa=7;Ea.getPositions=function(a){let s=h0(a);return[[0,0],[s-Aa,0],[0,s-Aa]]}});var Ca=Se(Pe=>{Pe.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var kn={N1:3,N2:3,N3:40,N4:10};Pe.isValid=function(a){return a!=null&&a!==""&&!isNaN(a)&&a>=0&&a<=7};Pe.from=function(a){return Pe.isValid(a)?parseInt(a,10):void 0};Pe.getPenaltyN1=function(a){let s=a.size,f=0,d=0,h=0,p=null,A=null;for(let y=0;y=5&&(f+=kn.N1+(d-5)),p=_,d=1),_=a.get(x,y),_===A?h++:(h>=5&&(f+=kn.N1+(h-5)),A=_,h=1)}d>=5&&(f+=kn.N1+(d-5)),h>=5&&(f+=kn.N1+(h-5))}return f};Pe.getPenaltyN2=function(a){let s=a.size,f=0;for(let d=0;d=10&&(d===1488||d===93)&&f++,h=h<<1&2047|a.get(A,p),A>=10&&(h===1488||h===93)&&f++}return f*kn.N3};Pe.getPenaltyN4=function(a){let s=0,f=a.data.length;for(let h=0;h{var mn=Ii(),Si=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Ti=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];Ms.getBlocksCount=function(a,s){switch(s){case mn.L:return Si[(a-1)*4+0];case mn.M:return Si[(a-1)*4+1];case mn.Q:return Si[(a-1)*4+2];case mn.H:return Si[(a-1)*4+3];default:return}};Ms.getTotalCodewordsCount=function(a,s){switch(s){case mn.L:return Ti[(a-1)*4+0];case mn.M:return Ti[(a-1)*4+1];case mn.Q:return Ti[(a-1)*4+2];case mn.H:return Ti[(a-1)*4+3];default:return}}});var _a=Se(Mi=>{var kr=new Uint8Array(512),Ni=new Uint8Array(256);(function(){let a=1;for(let s=0;s<255;s++)kr[s]=a,Ni[a]=s,a<<=1,a&256&&(a^=285);for(let s=255;s<512;s++)kr[s]=kr[s-255]})();Mi.log=function(a){if(a<1)throw new Error("log("+a+")");return Ni[a]};Mi.exp=function(a){return kr[a]};Mi.mul=function(a,s){return a===0||s===0?0:kr[Ni[a]+Ni[s]]}});var ya=Se(Pr=>{var Rs=_a();Pr.mul=function(a,s){let f=new Uint8Array(a.length+s.length-1);for(let d=0;d=0;){let d=f[0];for(let p=0;p{var Ia=ya();function Ds(r){this.genPoly=void 0,this.degree=r,this.degree&&this.initialize(this.degree)}Ds.prototype.initialize=function(a){this.degree=a,this.genPoly=Ia.generateECPolynomial(this.degree)};Ds.prototype.encode=function(a){if(!this.genPoly)throw new Error("Encoder not initialized");let s=new Uint8Array(a.length+this.degree);s.set(a);let f=Ia.mod(s,this.genPoly),d=this.degree-f.length;if(d>0){let h=new Uint8Array(this.degree);return h.set(f,d),h}return f};ba.exports=Ds});var vs=Se(Ta=>{Ta.isValid=function(a){return!isNaN(a)&&a>=1&&a<=40}});var Bs=Se(an=>{var Na="[0-9]+",g0="[A-Z $%*+\\-./:]+",Fr="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";Fr=Fr.replace(/u/g,"\\u");var x0="(?:(?![A-Z0-9 $%*+\\-./:]|"+Fr+`)(?:.|[\r ]))+`;an.KANJI=new RegExp(Fr,"g");an.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g");an.BYTE=new RegExp(x0,"g");an.NUMERIC=new RegExp(Na,"g");an.ALPHANUMERIC=new RegExp(g0,"g");var w0=new RegExp("^"+Fr+"$"),p0=new RegExp("^"+Na+"$"),A0=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");an.testKanji=function(a){return w0.test(a)};an.testNumeric=function(a){return p0.test(a)};an.testAlphanumeric=function(a){return A0.test(a)}});var Cn=Se(Qe=>{var E0=vs(),Ls=Bs();Qe.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]};Qe.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]};Qe.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]};Qe.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]};Qe.MIXED={bit:-1};Qe.getCharCountIndicator=function(a,s){if(!a.ccBits)throw new Error("Invalid mode: "+a);if(!E0.isValid(s))throw new Error("Invalid version: "+s);return s>=1&&s<10?a.ccBits[0]:s<27?a.ccBits[1]:a.ccBits[2]};Qe.getBestModeForData=function(a){return Ls.testNumeric(a)?Qe.NUMERIC:Ls.testAlphanumeric(a)?Qe.ALPHANUMERIC:Ls.testKanji(a)?Qe.KANJI:Qe.BYTE};Qe.toString=function(a){if(a&&a.id)return a.id;throw new Error("Invalid mode")};Qe.isValid=function(a){return a&&a.bit&&a.ccBits};function m0(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return Qe.NUMERIC;case"alphanumeric":return Qe.ALPHANUMERIC;case"kanji":return Qe.KANJI;case"byte":return Qe.BYTE;default:throw new Error("Unknown mode: "+r)}}Qe.from=function(a,s){if(Qe.isValid(a))return a;try{return m0(a)}catch{return s}}});var va=Se(Pn=>{var Oi=En(),C0=Os(),Ma=Ii(),_n=Cn(),ks=vs(),Ra=7973,Oa=Oi.getBCHDigit(Ra);function _0(r,a,s){for(let f=1;f<=40;f++)if(a<=Pn.getCapacity(f,s,r))return f}function Da(r,a){return _n.getCharCountIndicator(r,a)+4}function y0(r,a){let s=0;return r.forEach(function(f){let d=Da(f.mode,a);s+=d+f.getBitsLength()}),s}function I0(r,a){for(let s=1;s<=40;s++)if(y0(r,s)<=Pn.getCapacity(s,a,_n.MIXED))return s}Pn.from=function(a,s){return ks.isValid(a)?parseInt(a,10):s};Pn.getCapacity=function(a,s,f){if(!ks.isValid(a))throw new Error("Invalid QR Code version");typeof f>"u"&&(f=_n.BYTE);let d=Oi.getSymbolTotalCodewords(a),h=C0.getTotalCodewordsCount(a,s),p=(d-h)*8;if(f===_n.MIXED)return p;let A=p-Da(f,a);switch(f){case _n.NUMERIC:return Math.floor(A/10*3);case _n.ALPHANUMERIC:return Math.floor(A/11*2);case _n.KANJI:return Math.floor(A/13);case _n.BYTE:default:return Math.floor(A/8)}};Pn.getBestVersionForData=function(a,s){let f,d=Ma.from(s,Ma.M);if(Array.isArray(a)){if(a.length>1)return I0(a,d);if(a.length===0)return 1;f=a[0]}else f=a;return _0(f.mode,f.getLength(),d)};Pn.getEncodedBits=function(a){if(!ks.isValid(a)||a<7)throw new Error("Invalid QR Code version");let s=a<<12;for(;Oi.getBCHDigit(s)-Oa>=0;)s^=Ra<{var Ps=En(),La=1335,b0=21522,Ba=Ps.getBCHDigit(La);ka.getEncodedBits=function(a,s){let f=a.bit<<3|s,d=f<<10;for(;Ps.getBCHDigit(d)-Ba>=0;)d^=La<{var S0=Cn();function ir(r){this.mode=S0.NUMERIC,this.data=r.toString()}ir.getBitsLength=function(a){return 10*Math.floor(a/3)+(a%3?a%3*3+1:0)};ir.prototype.getLength=function(){return this.data.length};ir.prototype.getBitsLength=function(){return ir.getBitsLength(this.data.length)};ir.prototype.write=function(a){let s,f,d;for(s=0;s+3<=this.data.length;s+=3)f=this.data.substr(s,3),d=parseInt(f,10),a.put(d,10);let h=this.data.length-s;h>0&&(f=this.data.substr(s),d=parseInt(f,10),a.put(d,h*3+1))};Fa.exports=ir});var Ha=Se((Qd,za)=>{var T0=Cn(),Fs=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function sr(r){this.mode=T0.ALPHANUMERIC,this.data=r}sr.getBitsLength=function(a){return 11*Math.floor(a/2)+6*(a%2)};sr.prototype.getLength=function(){return this.data.length};sr.prototype.getBitsLength=function(){return sr.getBitsLength(this.data.length)};sr.prototype.write=function(a){let s;for(s=0;s+2<=this.data.length;s+=2){let f=Fs.indexOf(this.data[s])*45;f+=Fs.indexOf(this.data[s+1]),a.put(f,11)}this.data.length%2&&a.put(Fs.indexOf(this.data[s]),6)};za.exports=sr});var Xa=Se((Kd,Va)=>{var N0=Cn();function or(r){this.mode=N0.BYTE,typeof r=="string"?this.data=new TextEncoder().encode(r):this.data=new Uint8Array(r)}or.getBitsLength=function(a){return a*8};or.prototype.getLength=function(){return this.data.length};or.prototype.getBitsLength=function(){return or.getBitsLength(this.data.length)};or.prototype.write=function(r){for(let a=0,s=this.data.length;a{var M0=Cn(),O0=En();function ar(r){this.mode=M0.KANJI,this.data=r}ar.getBitsLength=function(a){return a*13};ar.prototype.getLength=function(){return this.data.length};ar.prototype.getBitsLength=function(){return ar.getBitsLength(this.data.length)};ar.prototype.write=function(r){let a;for(a=0;a=33088&&s<=40956)s-=33088;else if(s>=57408&&s<=60351)s-=49472;else throw new Error("Invalid SJIS character: "+this.data[a]+` Make sure your charset is UTF-8`);s=(s>>>8&255)*192+(s&255),r.put(s,13)}};Ga.exports=ar});var Ya=Se((Jd,Us)=>{"use strict";var Ur={single_source_shortest_paths:function(r,a,s){var f={},d={};d[a]=0;var h=Ur.PriorityQueue.make();h.push(a,0);for(var p,A,y,x,_,v,R,N,V;!h.empty();){p=h.pop(),A=p.value,x=p.cost,_=r[A]||{};for(y in _)_.hasOwnProperty(y)&&(v=_[y],R=x+v,N=d[y],V=typeof d[y]>"u",(V||N>R)&&(d[y]=R,h.push(y,R),f[y]=A))}if(typeof s<"u"&&typeof d[s]>"u"){var K=["Could not find a path from ",a," to ",s,"."].join("");throw new Error(K)}return f},extract_shortest_path_from_predecessor_list:function(r,a){for(var s=[],f=a,d;f;)s.push(f),d=r[f],f=r[f];return s.reverse(),s},find_path:function(r,a,s){var f=Ur.single_source_shortest_paths(r,a,s);return Ur.extract_shortest_path_from_predecessor_list(f,s)},PriorityQueue:{make:function(r){var a=Ur.PriorityQueue,s={},f;r=r||{};for(f in a)a.hasOwnProperty(f)&&(s[f]=a[f]);return s.queue=[],s.sorter=r.sorter||a.default_sorter,s},default_sorter:function(r,a){return r.cost-a.cost},push:function(r,a){var s={value:r,cost:a};this.queue.push(s),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};typeof Us<"u"&&(Us.exports=Ur)});var el=Se(lr=>{var Me=Cn(),Qa=Ua(),Ka=Ha(),qa=Xa(),Ja=ja(),zr=Bs(),Ri=En(),R0=Ya();function Wa(r){return unescape(encodeURIComponent(r)).length}function Hr(r,a,s){let f=[],d;for(;(d=r.exec(s))!==null;)f.push({data:d[0],index:d.index,mode:a,length:d[0].length});return f}function $a(r){let a=Hr(zr.NUMERIC,Me.NUMERIC,r),s=Hr(zr.ALPHANUMERIC,Me.ALPHANUMERIC,r),f,d;return Ri.isKanjiModeEnabled()?(f=Hr(zr.BYTE,Me.BYTE,r),d=Hr(zr.KANJI,Me.KANJI,r)):(f=Hr(zr.BYTE_KANJI,Me.BYTE,r),d=[]),a.concat(s,f,d).sort(function(p,A){return p.index-A.index}).map(function(p){return{data:p.data,mode:p.mode,length:p.length}})}function zs(r,a){switch(a){case Me.NUMERIC:return Qa.getBitsLength(r);case Me.ALPHANUMERIC:return Ka.getBitsLength(r);case Me.KANJI:return Ja.getBitsLength(r);case Me.BYTE:return qa.getBitsLength(r)}}function D0(r){return r.reduce(function(a,s){let f=a.length-1>=0?a[a.length-1]:null;return f&&f.mode===s.mode?(a[a.length-1].data+=s.data,a):(a.push(s),a)},[])}function v0(r){let a=[];for(let s=0;s{var vi=En(),Hs=Ii(),L0=ga(),k0=wa(),P0=pa(),F0=ma(),Gs=Ca(),js=Os(),U0=Sa(),Di=va(),z0=Pa(),H0=Cn(),Vs=el();function V0(r,a){let s=r.size,f=F0.getPositions(a);for(let d=0;d=0&&A<=6&&(y===0||y===6)||y>=0&&y<=6&&(A===0||A===6)||A>=2&&A<=4&&y>=2&&y<=4?r.set(h+A,p+y,!0,!0):r.set(h+A,p+y,!1,!0))}}function X0(r){let a=r.size;for(let s=8;s>A&1)===1,r.set(d,h,p,!0),r.set(h,d,p,!0)}function Xs(r,a,s){let f=r.size,d=z0.getEncodedBits(a,s),h,p;for(h=0;h<15;h++)p=(d>>h&1)===1,h<6?r.set(h,8,p,!0):h<8?r.set(h+1,8,p,!0):r.set(f-15+h,8,p,!0),h<8?r.set(8,f-h-1,p,!0):h<9?r.set(8,15-h-1+1,p,!0):r.set(8,15-h-1,p,!0);r.set(f-8,8,1,!0)}function Y0(r,a){let s=r.size,f=-1,d=s-1,h=7,p=0;for(let A=s-1;A>0;A-=2)for(A===6&&A--;;){for(let y=0;y<2;y++)if(!r.isReserved(d,A-y)){let x=!1;p>>h&1)===1),r.set(d,A-y,x),h--,h===-1&&(p++,h=7)}if(d+=f,d<0||s<=d){d-=f,f=-f;break}}}function W0(r,a,s){let f=new L0;s.forEach(function(y){f.put(y.mode.bit,4),f.put(y.getLength(),H0.getCharCountIndicator(y.mode,r)),y.write(f)});let d=vi.getSymbolTotalCodewords(r),h=js.getTotalCodewordsCount(r,a),p=(d-h)*8;for(f.getLengthInBits()+4<=p&&f.put(0,4);f.getLengthInBits()%8!==0;)f.putBit(0);let A=(p-f.getLengthInBits())/8;for(let y=0;y=7&&j0(y,a),Y0(y,p),isNaN(f)&&(f=Gs.getBestMask(y,Xs.bind(null,y,s))),Gs.applyMask(f,y),Xs(y,s,f),{modules:y,version:a,errorCorrectionLevel:s,maskPattern:f,segments:d}}tl.create=function(a,s){if(typeof a>"u"||a==="")throw new Error("No input text");let f=Hs.M,d,h;return typeof s<"u"&&(f=Hs.from(s.errorCorrectionLevel,Hs.M),d=Di.from(s.version),h=Gs.from(s.maskPattern),s.toSJISFunc&&vi.setToSJISFunction(s.toSJISFunc)),Q0(a,d,f,h)}});var Ys=Se(Fn=>{function rl(r){if(typeof r=="number"&&(r=r.toString()),typeof r!="string")throw new Error("Color should be defined as hex string");let a=r.slice().replace("#","").split("");if(a.length<3||a.length===5||a.length>8)throw new Error("Invalid hex color: "+r);(a.length===3||a.length===4)&&(a=Array.prototype.concat.apply([],a.map(function(f){return[f,f]}))),a.length===6&&a.push("F","F");let s=parseInt(a.join(""),16);return{r:s>>24&255,g:s>>16&255,b:s>>8&255,a:s&255,hex:"#"+a.slice(0,6).join("")}}Fn.getOptions=function(a){a||(a={}),a.color||(a.color={});let s=typeof a.margin>"u"||a.margin===null||a.margin<0?4:a.margin,f=a.width&&a.width>=21?a.width:void 0,d=a.scale||4;return{width:f,scale:f?4:d,margin:s,color:{dark:rl(a.color.dark||"#000000ff"),light:rl(a.color.light||"#ffffffff")},type:a.type,rendererOpts:a.rendererOpts||{}}};Fn.getScale=function(a,s){return s.width&&s.width>=a+s.margin*2?s.width/(a+s.margin*2):s.scale};Fn.getImageWidth=function(a,s){let f=Fn.getScale(a,s);return Math.floor((a+s.margin*2)*f)};Fn.qrToImageData=function(a,s,f){let d=s.modules.size,h=s.modules.data,p=Fn.getScale(d,f),A=Math.floor((d+f.margin*2)*p),y=f.margin*p,x=[f.color.light,f.color.dark];for(let _=0;_=y&&v>=y&&_{var Ws=Ys();function K0(r,a,s){r.clearRect(0,0,a.width,a.height),a.style||(a.style={}),a.height=s,a.width=s,a.style.height=s+"px",a.style.width=s+"px"}function q0(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}Bi.render=function(a,s,f){let d=f,h=s;typeof d>"u"&&(!s||!s.getContext)&&(d=s,s=void 0),s||(h=q0()),d=Ws.getOptions(d);let p=Ws.getImageWidth(a.modules.size,d),A=h.getContext("2d"),y=A.createImageData(p,p);return Ws.qrToImageData(y.data,a,d),K0(A,h,p),A.putImageData(y,0,0),h};Bi.renderToDataURL=function(a,s,f){let d=f;typeof d>"u"&&(!s||!s.getContext)&&(d=s,s=void 0),d||(d={});let h=Bi.render(a,s,d),p=d.type||"image/png",A=d.rendererOpts||{};return h.toDataURL(p,A.quality)}});var al=Se(ol=>{var J0=Ys();function sl(r,a){let s=r.a/255,f=a+'="'+r.hex+'"';return s<1?f+" "+a+'-opacity="'+s.toFixed(2).slice(1)+'"':f}function Zs(r,a,s){let f=r+a;return typeof s<"u"&&(f+=" "+s),f}function $0(r,a,s){let f="",d=0,h=!1,p=0;for(let A=0;A0&&y>0&&r[A-1]||(f+=h?Zs("M",y+s,.5+x+s):Zs("m",d,0),d=0,h=!1),y+1':"",x="',_='viewBox="0 0 '+A+" "+A+'"',R=''+y+x+` `;return typeof f=="function"&&f(null,R),R}});var cl=Se(Vr=>{var ef=ua(),Qs=nl(),ll=il(),tf=al();function Ks(r,a,s,f,d){let h=[].slice.call(arguments,1),p=h.length,A=typeof h[p-1]=="function";if(!A&&!ef())throw new Error("Callback required as last argument");if(A){if(p<2)throw new Error("Too few arguments provided");p===2?(d=s,s=a,a=f=void 0):p===3&&(a.getContext&&typeof d>"u"?(d=f,f=void 0):(d=f,f=s,s=a,a=void 0))}else{if(p<1)throw new Error("Too few arguments provided");return p===1?(s=a,a=f=void 0):p===2&&!a.getContext&&(f=s,s=a,a=void 0),new Promise(function(y,x){try{let _=Qs.create(s,f);y(r(_,a,f))}catch(_){x(_)}})}try{let y=Qs.create(s,f);d(null,r(y,a,f))}catch(y){d(y)}}Vr.create=Qs.create;Vr.toCanvas=Ks.bind(null,ll.render);Vr.toDataURL=Ks.bind(null,ll.renderToDataURL);Vr.toString=Ks.bind(null,function(r,a,s){return tf.render(r,s)})});var xl=Se((Fi,gl)=>{(function(r,a){typeof Fi=="object"&&typeof gl<"u"?a(Fi):typeof define=="function"&&define.amd?define(["exports"],a):(r=typeof globalThis<"u"?globalThis:r||self,a(r.ZXing={}))})(Fi,(function(r){"use strict";function a(E){return E==null}var s=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(E,e){E.__proto__=e}||function(E,e){for(var t in e)e.hasOwnProperty(t)&&(E[t]=e[t])};function f(E,e){s(E,e);function t(){this.constructor=E}E.prototype=e===null?Object.create(e):(t.prototype=e.prototype,new t)}function d(E,e){var t=Object.setPrototypeOf;t?t(E,e):E.__proto__=e}function h(E,e){e===void 0&&(e=E.constructor);var t=Error.captureStackTrace;t&&t(E,e)}var p=(function(E){f(e,E);function e(t){var n=this.constructor,i=E.call(this,t)||this;return Object.defineProperty(i,"name",{value:n.name,enumerable:!1}),d(i,n.prototype),h(i),i}return e})(Error);class A extends p{constructor(e=void 0){super(e),this.message=e}getKind(){return this.constructor.kind}}A.kind="Exception";class y extends A{}y.kind="ArgumentException";class x extends A{}x.kind="IllegalArgumentException";class _{constructor(e){if(this.binarizer=e,e===null)throw new x("Binarizer must be non-null.")}getWidth(){return this.binarizer.getWidth()}getHeight(){return this.binarizer.getHeight()}getBlackRow(e,t){return this.binarizer.getBlackRow(e,t)}getBlackMatrix(){return(this.matrix===null||this.matrix===void 0)&&(this.matrix=this.binarizer.getBlackMatrix()),this.matrix}isCropSupported(){return this.binarizer.getLuminanceSource().isCropSupported()}crop(e,t,n,i){let o=this.binarizer.getLuminanceSource().crop(e,t,n,i);return new _(this.binarizer.createBinarizer(o))}isRotateSupported(){return this.binarizer.getLuminanceSource().isRotateSupported()}rotateCounterClockwise(){let e=this.binarizer.getLuminanceSource().rotateCounterClockwise();return new _(this.binarizer.createBinarizer(e))}rotateCounterClockwise45(){let e=this.binarizer.getLuminanceSource().rotateCounterClockwise45();return new _(this.binarizer.createBinarizer(e))}toString(){try{return this.getBlackMatrix().toString()}catch{return""}}}class v extends A{static getChecksumInstance(){return new v}}v.kind="ChecksumException";class R{constructor(e){this.source=e}getLuminanceSource(){return this.source}getWidth(){return this.source.getWidth()}getHeight(){return this.source.getHeight()}}class N{static arraycopy(e,t,n,i,o){for(;o--;)n[i++]=e[t++]}static currentTimeMillis(){return Date.now()}}class V extends A{}V.kind="IndexOutOfBoundsException";class K extends V{constructor(e=void 0,t=void 0){super(t),this.index=e,this.message=t}}K.kind="ArrayIndexOutOfBoundsException";class H{static fill(e,t){for(let n=0,i=e.length;nn)throw new x("fromIndex("+t+") > toIndex("+n+")");if(t<0)throw new K(t);if(n>e)throw new K(n)}static asList(...e){return e}static create(e,t,n){return Array.from({length:e}).map(o=>Array.from({length:t}).fill(n))}static createInt32Array(e,t,n){return Array.from({length:e}).map(o=>Int32Array.from({length:t}).fill(n))}static equals(e,t){if(!e||!t||!e.length||!t.length||e.length!==t.length)return!1;for(let n=0,i=e.length;n>1,c=n(t,e[l]);if(c>0)i=l+1;else if(c<0)o=l-1;else return l}return-i-1}static numberComparator(e,t){return e-t}}class U{static numberOfTrailingZeros(e){let t;if(e===0)return 32;let n=31;return t=e<<16,t!==0&&(n-=16,e=t),t=e<<8,t!==0&&(n-=8,e=t),t=e<<4,t!==0&&(n-=4,e=t),t=e<<2,t!==0&&(n-=2,e=t),n-(e<<1>>>31)}static numberOfLeadingZeros(e){if(e===0)return 32;let t=1;return e>>>16||(t+=16,e<<=16),e>>>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)}}U.MIN_VALUE_32_BITS=-2147483648,U.MAX_VALUE=Number.MAX_SAFE_INTEGER;class W{constructor(e,t){e===void 0?(this.size=0,this.bits=new Int32Array(1)):(this.size=e,t==null?this.bits=W.makeArray(e):this.bits=t)}getSize(){return this.size}getSizeInBytes(){return Math.floor((this.size+7)/8)}ensureCapacity(e){if(e>this.bits.length*32){let t=W.makeArray(e);N.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){let t=this.size;if(e>=t)return t;let n=this.bits,i=Math.floor(e/32),o=n[i];o&=~((1<<(e&31))-1);let l=n.length;for(;o===0;){if(++i===l)return t;o=n[i]}let c=i*32+U.numberOfTrailingZeros(o);return c>t?t:c}getNextUnset(e){let t=this.size;if(e>=t)return t;let n=this.bits,i=Math.floor(e/32),o=~n[i];o&=~((1<<(e&31))-1);let l=n.length;for(;o===0;){if(++i===l)return t;o=~n[i]}let c=i*32+U.numberOfTrailingZeros(o);return c>t?t:c}setBulk(e,t){this.bits[Math.floor(e/32)]=t}setRange(e,t){if(tthis.size)throw new x;if(t===e)return;t--;let n=Math.floor(e/32),i=Math.floor(t/32),o=this.bits;for(let l=n;l<=i;l++){let c=l>n?0:e&31,g=(2<<(lthis.size)throw new x;if(t===e)return!0;t--;let i=Math.floor(e/32),o=Math.floor(t/32),l=this.bits;for(let c=i;c<=o;c++){let u=c>i?0:e&31,w=(2<<(c32)throw new x("Num bits must be between 0 and 32");this.ensureCapacity(this.size+t);for(let n=t;n>0;n--)this.appendBit((e>>n-1&1)===1)}appendBitArray(e){let t=e.size;this.ensureCapacity(this.size+t);for(let n=0;n>1&1431655765|(l&1431655765)<<1,l=l>>2&858993459|(l&858993459)<<2,l=l>>4&252645135|(l&252645135)<<4,l=l>>8&16711935|(l&16711935)<<8,l=l>>16&65535|(l&65535)<<16,e[t-o]=l}if(this.size!==n*32){let o=n*32-this.size,l=e[0]>>>o;for(let c=1;c>>o}e[n-1]=l}this.bits=e}static makeArray(e){return new Int32Array(Math.floor((e+31)/32))}equals(e){if(!(e instanceof W))return!1;let t=e;return this.size===t.size&&H.equals(this.bits,t.bits)}hashCode(){return 31*this.size+H.hashCode(this.bits)}toString(){let e="";for(let t=0,n=this.size;t=900)throw new L("incorect value");let t=O.VALUES_TO_ECI.get(e);if(t===void 0)throw new L("incorect value");return t}static getCharacterSetECIByName(e){let t=O.NAME_TO_ECI.get(e);if(t===void 0)throw new L("incorect value");return t}equals(e){if(!(e instanceof O))return!1;let t=e;return this.getName()===t.getName()}}O.VALUE_IDENTIFIER_TO_ECI=new Map,O.VALUES_TO_ECI=new Map,O.NAME_TO_ECI=new Map,O.Cp437=new O(Y.Cp437,Int32Array.from([0,2]),"Cp437"),O.ISO8859_1=new O(Y.ISO8859_1,Int32Array.from([1,3]),"ISO-8859-1","ISO88591","ISO8859_1"),O.ISO8859_2=new O(Y.ISO8859_2,4,"ISO-8859-2","ISO88592","ISO8859_2"),O.ISO8859_3=new O(Y.ISO8859_3,5,"ISO-8859-3","ISO88593","ISO8859_3"),O.ISO8859_4=new O(Y.ISO8859_4,6,"ISO-8859-4","ISO88594","ISO8859_4"),O.ISO8859_5=new O(Y.ISO8859_5,7,"ISO-8859-5","ISO88595","ISO8859_5"),O.ISO8859_6=new O(Y.ISO8859_6,8,"ISO-8859-6","ISO88596","ISO8859_6"),O.ISO8859_7=new O(Y.ISO8859_7,9,"ISO-8859-7","ISO88597","ISO8859_7"),O.ISO8859_8=new O(Y.ISO8859_8,10,"ISO-8859-8","ISO88598","ISO8859_8"),O.ISO8859_9=new O(Y.ISO8859_9,11,"ISO-8859-9","ISO88599","ISO8859_9"),O.ISO8859_10=new O(Y.ISO8859_10,12,"ISO-8859-10","ISO885910","ISO8859_10"),O.ISO8859_11=new O(Y.ISO8859_11,13,"ISO-8859-11","ISO885911","ISO8859_11"),O.ISO8859_13=new O(Y.ISO8859_13,15,"ISO-8859-13","ISO885913","ISO8859_13"),O.ISO8859_14=new O(Y.ISO8859_14,16,"ISO-8859-14","ISO885914","ISO8859_14"),O.ISO8859_15=new O(Y.ISO8859_15,17,"ISO-8859-15","ISO885915","ISO8859_15"),O.ISO8859_16=new O(Y.ISO8859_16,18,"ISO-8859-16","ISO885916","ISO8859_16"),O.SJIS=new O(Y.SJIS,20,"SJIS","Shift_JIS"),O.Cp1250=new O(Y.Cp1250,21,"Cp1250","windows-1250"),O.Cp1251=new O(Y.Cp1251,22,"Cp1251","windows-1251"),O.Cp1252=new O(Y.Cp1252,23,"Cp1252","windows-1252"),O.Cp1256=new O(Y.Cp1256,24,"Cp1256","windows-1256"),O.UnicodeBigUnmarked=new O(Y.UnicodeBigUnmarked,25,"UnicodeBigUnmarked","UTF-16BE","UnicodeBig"),O.UTF8=new O(Y.UTF8,26,"UTF8","UTF-8"),O.ASCII=new O(Y.ASCII,Int32Array.from([27,170]),"ASCII","US-ASCII"),O.Big5=new O(Y.Big5,28,"Big5"),O.GB18030=new O(Y.GB18030,29,"GB18030","GB2312","EUC_CN","GBK"),O.EUC_KR=new O(Y.EUC_KR,30,"EUC_KR","EUC-KR");class le extends A{}le.kind="UnsupportedOperationException";class re{static decode(e,t){let n=this.encodingName(t);return this.customDecoder?this.customDecoder(e,n):typeof TextDecoder>"u"||this.shouldDecodeOnFallback(n)?this.decodeFallback(e,n):new TextDecoder(n).decode(e)}static shouldDecodeOnFallback(e){return!re.isBrowser()&&e==="ISO-8859-1"}static encode(e,t){let n=this.encodingName(t);return this.customEncoder?this.customEncoder(e,n):typeof TextEncoder>"u"?this.encodeFallback(e):new TextEncoder().encode(e)}static isBrowser(){return typeof window<"u"&&{}.toString.call(window)==="[object Window]"}static encodingName(e){return typeof e=="string"?e:e.getName()}static encodingCharacterSet(e){return e instanceof O?e:O.getCharacterSetECIByName(e)}static decodeFallback(e,t){let n=this.encodingCharacterSet(t);if(re.isDecodeFallbackSupported(n)){let i="";for(let o=0,l=e.length;o3&&e[0]===239&&e[1]===187&&e[2]===191;for(let Q=0;Q0?(j&128)===0?l=!1:c--:(j&128)!==0&&((j&64)===0?l=!1:(c++,(j&32)===0?u++:(c++,(j&16)===0?g++:(c++,(j&8)===0?w++:l=!1))))),i&&(j>127&&j<160?i=!1:j>159&&(j<192||j===215||j===247)&&F++),o&&(m>0?j<64||j===127||j>252?o=!1:m--:j===128||j===160||j>239?o=!1:j>160&&j<224?(C++,S=0,b++,b>T&&(T=b)):j>127?(m++,b=0,S++,S>D&&(D=S)):(b=0,S=0))}return l&&c>0&&(l=!1),o&&m>0&&(o=!1),l&&(Z||u+g+w>0)?k.UTF8:o&&(k.ASSUME_SHIFT_JIS||T>=3||D>=3)?k.SHIFT_JIS:i&&o?T===2&&C===2||F*10>=n?k.SHIFT_JIS:k.ISO88591:i?k.ISO88591:o?k.SHIFT_JIS:l?k.UTF8:k.PLATFORM_DEFAULT_ENCODING}static format(e,...t){let n=-1;function i(l,c,u,g,w,m){if(l==="%%")return"%";if(t[++n]===void 0)return;l=g?parseInt(g.substr(1)):void 0;let C=w?parseInt(w.substr(1)):void 0,b;switch(m){case"s":b=t[n];break;case"c":b=t[n][0];break;case"f":b=parseFloat(t[n]).toFixed(l);break;case"p":b=parseFloat(t[n]).toPrecision(l);break;case"e":b=parseFloat(t[n]).toExponential(l);break;case"x":b=parseInt(t[n]).toString(C||16);break;case"d":b=parseFloat(parseInt(t[n],C||10).toPrecision(l)).toFixed(0);break}b=typeof b=="object"?JSON.stringify(b):(+b).toString(C);let S=parseInt(u),T=u&&u[0]+""=="0"?"0":" ";for(;b.lengthl){if(c===-1)c=o-l;else if(o-l!==c)throw new x("row lengths do not match");l=o,u++}g++}else if(e.substring(g,g+t.length)===t)g+=t.length,i[o]=!0,o++;else if(e.substring(g,g+n.length)===n)g+=n.length,i[o]=!1,o++;else throw new x("illegal character encountered: "+e.substring(g));if(o>l){if(c===-1)c=o-l;else if(o-l!==c)throw new x("row lengths do not match");u++}let w=new $(c,u);for(let m=0;m>>(e&31)&1)!==0}set(e,t){let n=t*this.rowSize+Math.floor(e/32);this.bits[n]|=1<<(e&31)&4294967295}unset(e,t){let n=t*this.rowSize+Math.floor(e/32);this.bits[n]&=~(1<<(e&31)&4294967295)}flip(e,t){let n=t*this.rowSize+Math.floor(e/32);this.bits[n]^=1<<(e&31)&4294967295}xor(e){if(this.width!==e.getWidth()||this.height!==e.getHeight()||this.rowSize!==e.getRowSize())throw new x("input matrix dimensions do not match");let t=new W(Math.floor(this.width/32)+1),n=this.rowSize,i=this.bits;for(let o=0,l=this.height;othis.height||o>this.width)throw new x("The region must fit inside the matrix");let c=this.rowSize,u=this.bits;for(let g=t;gu&&(u=g),w*32c){let C=31;for(;!(m>>>C);)C--;w*32+C>c&&(c=w*32+C)}}}return c=0&&t[n]===0;)n--;if(n<0)return null;let i=Math.floor(n/e),o=Math.floor(n%e)*32,l=t[n],c=31;for(;!(l>>>c);)c--;return o+=c,Int32Array.from([o,i])}getWidth(){return this.width}getHeight(){return this.height}getRowSize(){return this.rowSize}equals(e){if(!(e instanceof $))return!1;let t=e;return this.width===t.width&&this.height===t.height&&this.rowSize===t.rowSize&&H.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+H.hashCode(this.bits),e}toString(e="X ",t=" ",n=` `){return this.buildToString(e,t,n)}buildToString(e,t,n){let i=new G;for(let o=0,l=this.height;o>ue.LUMINANCE_SHIFT]++;let c=ue.estimateBlackPoint(l);if(i<3)for(let u=0;u>ue.LUMINANCE_SHIFT]++}}let l=ue.estimateBlackPoint(o),c=e.getMatrix();for(let u=0;uo&&(i=w,o=e[w]),e[w]>n&&(n=e[w]);let l=0,c=0;for(let w=0;wc&&(l=w,c=C)}if(i>l){let w=i;i=l,l=w}if(l-i<=t/16)throw new M;let u=l-1,g=-1;for(let w=l-1;w>i;w--){let m=w-i,C=m*m*(l-w)*(n-e[w]);C>g&&(u=w,g=C)}return u<=q.MINIMUM_DIMENSION&&n>=q.MINIMUM_DIMENSION){let i=e.getMatrix(),o=t>>q.BLOCK_SIZE_POWER;(t&q.BLOCK_SIZE_MASK)!==0&&o++;let l=n>>q.BLOCK_SIZE_POWER;(n&q.BLOCK_SIZE_MASK)!==0&&l++;let c=q.calculateBlackPoints(i,o,l,t,n),u=new $(t,n);q.calculateThresholdForBlock(i,o,l,t,n,c,u),this.matrix=u}else this.matrix=super.getBlackMatrix();return this.matrix}createBinarizer(e){return new q(e)}static calculateThresholdForBlock(e,t,n,i,o,l,c){let u=o-q.BLOCK_SIZE,g=i-q.BLOCK_SIZE;for(let w=0;wu&&(m=u);let C=q.cap(w,2,n-3);for(let b=0;bg&&(S=g);let T=q.cap(b,2,t-3),D=0;for(let Z=-2;Z<=2;Z++){let Q=l[C+Z];D+=Q[T-2]+Q[T-1]+Q[T]+Q[T+1]+Q[T+2]}let F=D/25;q.thresholdBlock(e,S,m,F,i,c)}}}static cap(e,t,n){return en?n:e}static thresholdBlock(e,t,n,i,o,l){for(let c=0,u=n*o+t;cl&&(w=l);for(let m=0;mc&&(C=c);let b=0,S=255,T=0;for(let F=0,Z=w*i+C;FT&&(T=j)}if(T-S>q.MIN_DYNAMIC_RANGE)for(F++,Z+=i;F>q.BLOCK_SIZE_POWER*2;if(T-S<=q.MIN_DYNAMIC_RANGE&&(D=S/2,g>0&&m>0)){let F=(u[g-1][m]+2*u[g][m-1]+u[g-1][m-1])/4;S>10}i[l]=u}return i}getRow(e,t){if(e<0||e>=this.getHeight())throw new x("Requested row is outside the image: "+e);let n=this.getWidth(),i=e*n;return t===null?t=this.buffer.slice(i,i+n):(t.lengthnew Cr(t.deviceId,t.label))})}findDeviceById(e){return $e(this,void 0,void 0,function*(){let t=yield this.listVideoInputDevices();return t?t.find(n=>n.deviceId===e):null})}decodeFromInputVideoDevice(e,t){return $e(this,void 0,void 0,function*(){return yield this.decodeOnceFromVideoDevice(e,t)})}decodeOnceFromVideoDevice(e,t){return $e(this,void 0,void 0,function*(){this.reset();let n;e?n={deviceId:{exact:e}}:n={facingMode:"environment"};let i={video:n};return yield this.decodeOnceFromConstraints(i,t)})}decodeOnceFromConstraints(e,t){return $e(this,void 0,void 0,function*(){let n=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeOnceFromStream(n,t)})}decodeOnceFromStream(e,t){return $e(this,void 0,void 0,function*(){this.reset();let n=yield this.attachStreamToVideo(e,t);return yield this.decodeOnce(n)})}decodeFromInputVideoDeviceContinuously(e,t,n){return $e(this,void 0,void 0,function*(){return yield this.decodeFromVideoDevice(e,t,n)})}decodeFromVideoDevice(e,t,n){return $e(this,void 0,void 0,function*(){let i;e?i={deviceId:{exact:e}}:i={facingMode:"environment"};let o={video:i};return yield this.decodeFromConstraints(o,t,n)})}decodeFromConstraints(e,t,n){return $e(this,void 0,void 0,function*(){let i=yield navigator.mediaDevices.getUserMedia(e);return yield this.decodeFromStream(i,t,n)})}decodeFromStream(e,t,n){return $e(this,void 0,void 0,function*(){this.reset();let i=yield this.attachStreamToVideo(e,t);return yield this.decodeContinuously(i,n)})}stopAsyncDecode(){this._stopAsyncDecode=!0}stopContinuousDecode(){this._stopContinuousDecode=!0}attachStreamToVideo(e,t){return $e(this,void 0,void 0,function*(){let n=this.prepareVideoElement(t);return this.addVideoSource(n,e),this.videoElement=n,this.stream=e,yield this.playVideoOnLoadAsync(n),n})}playVideoOnLoadAsync(e){return new Promise((t,n)=>this.playVideoOnLoad(e,()=>t()))}playVideoOnLoad(e,t){this.videoEndedListener=()=>this.stopStreams(),this.videoCanPlayListener=()=>this.tryPlayVideo(e),e.addEventListener("ended",this.videoEndedListener),e.addEventListener("canplay",this.videoCanPlayListener),e.addEventListener("playing",t),this.tryPlayVideo(e)}isVideoPlaying(e){return e.currentTime>0&&!e.paused&&!e.ended&&e.readyState>2}tryPlayVideo(e){return $e(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){let n=document.getElementById(e);if(!n)throw new y(`element with id '${e}' not found`);if(n.nodeName.toLowerCase()!==t.toLowerCase())throw new y(`element with id '${e}' must be an ${t} element`);return n}decodeFromImage(e,t){if(!e&&!t)throw new y("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 y("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrl(t):this.decodeFromVideoElement(e)}decodeFromVideoContinuously(e,t,n){if(e===void 0&&t===void 0)throw new y("Either an element with a src set or an URL must be provided");return t&&!e?this.decodeFromVideoUrlContinuously(t,n):this.decodeFromVideoElementContinuously(e,n)}decodeFromImageElement(e){if(!e)throw new y("An image element must be provided.");this.reset();let t=this.prepareImageElement(e);this.imageElement=t;let n;return this.isImageLoaded(t)?n=this.decodeOnce(t,!1,!0):n=this._decodeOnLoadImage(t),n}decodeFromVideoElement(e){let t=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideo(t)}decodeFromVideoElementContinuously(e,t){let n=this._decodeFromVideoElementSetup(e);return this._decodeOnLoadVideoContinuously(n,t)}_decodeFromVideoElementSetup(e){if(!e)throw new y("A video element must be provided.");this.reset();let t=this.prepareVideoElement(e);return this.videoElement=t,t}decodeFromImageUrl(e){if(!e)throw new y("An URL must be provided.");this.reset();let t=this.prepareImageElement();this.imageElement=t;let n=this._decodeOnLoadImage(t);return t.src=e,n}decodeFromVideoUrl(e){if(!e)throw new y("An URL must be provided.");this.reset();let t=this.prepareVideoElement(),n=this.decodeFromVideoElement(t);return t.src=e,n}decodeFromVideoUrlContinuously(e,t){if(!e)throw new y("An URL must be provided.");this.reset();let n=this.prepareVideoElement(),i=this.decodeFromVideoElementContinuously(n,t);return n.src=e,i}_decodeOnLoadImage(e){return new Promise((t,n)=>{this.imageLoadedListener=()=>this.decodeOnce(e,!1,!0).then(t,n),e.addEventListener("load",this.imageLoadedListener)})}_decodeOnLoadVideo(e){return $e(this,void 0,void 0,function*(){return yield this.playVideoOnLoadAsync(e),yield this.decodeOnce(e)})}_decodeOnLoadVideoContinuously(e,t){return $e(this,void 0,void 0,function*(){yield this.playVideoOnLoadAsync(e),this.decodeContinuously(e,t)})}isImageLoaded(e){return!(!e.complete||e.naturalWidth===0)}prepareImageElement(e){let t;return typeof e>"u"&&(t=document.createElement("img"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"img")),e instanceof HTMLImageElement&&(t=e),t}prepareVideoElement(e){let t;return!e&&typeof document<"u"&&(t=document.createElement("video"),t.width=200,t.height=200),typeof e=="string"&&(t=this.getMediaElement(e,"video")),e instanceof HTMLVideoElement&&(t=e),t.setAttribute("autoplay","true"),t.setAttribute("muted","true"),t.setAttribute("playsinline","true"),t}decodeOnce(e,t=!0,n=!0){this._stopAsyncDecode=!1;let i=(o,l)=>{if(this._stopAsyncDecode){l(new M("Video stream has ended before any code could be detected.")),this._stopAsyncDecode=void 0;return}try{let c=this.decode(e);o(c)}catch(c){let u=t&&c instanceof M,w=(c instanceof v||c instanceof L)&&n;if(u||w)return setTimeout(i,this._timeBetweenDecodingAttempts,o,l);l(c)}};return new Promise((o,l)=>i(o,l))}decodeContinuously(e,t){this._stopContinuousDecode=!1;let n=()=>{if(this._stopContinuousDecode){this._stopContinuousDecode=void 0;return}try{let i=this.decode(e);t(i,null),setTimeout(n,this.timeBetweenScansMillis)}catch(i){t(null,i);let o=i instanceof v||i instanceof L,l=i instanceof M;(o||l)&&setTimeout(n,this._timeBetweenDecodingAttempts)}};n()}decode(e){let t=this.createBinaryBitmap(e);return this.decodeBitmap(t)}_isHTMLVideoElement(e){return e.videoWidth!==0}drawFrameOnCanvas(e,t,n){t||(t={sx:0,sy:0,sWidth:e.videoWidth,sHeight:e.videoHeight,dx:0,dy:0,dWidth:e.videoWidth,dHeight:e.videoHeight}),n||(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}drawImageOnCanvas(e,t,n=this.captureCanvasContext){t||(t={sx:0,sy:0,sWidth:e.naturalWidth,sHeight:e.naturalHeight,dx:0,dy:0,dWidth:e.naturalWidth,dHeight:e.naturalHeight}),n||(n=this.captureCanvasContext),n.drawImage(e,t.sx,t.sy,t.sWidth,t.sHeight,t.dx,t.dy,t.dWidth,t.dHeight)}createBinaryBitmap(e){let t=this.getCaptureCanvasContext(e);this._isHTMLVideoElement(e)?this.drawFrameOnCanvas(e):this.drawImageOnCanvas(e);let n=this.getCaptureCanvas(e),i=new zt(n),o=new q(i);return new _(o)}getCaptureCanvasContext(e){if(!this.captureCanvasContext){let n=this.getCaptureCanvas(e).getContext("2d");this.captureCanvasContext=n}return this.captureCanvasContext}getCaptureCanvas(e){if(!this.captureCanvas){let 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;let t=document.createElement("canvas"),n,i;return typeof e<"u"&&(e instanceof HTMLVideoElement?(n=e.videoWidth,i=e.videoHeight):e instanceof HTMLImageElement&&(n=e.naturalWidth||e.width,i=e.naturalHeight||e.height)),t.style.width=n+"px",t.style.height=i+"px",t.width=n,t.height=i,t}stopStreams(){this.stream&&(this.stream.getVideoTracks().forEach(e=>e.stop()),this.stream=void 0),this._stopAsyncDecode===!1&&this.stopAsyncDecode(),this._stopContinuousDecode===!1&&this.stopContinuousDecode()}reset(){this.stopStreams(),this._destroyVideoElement(),this._destroyImageElement(),this._destroyCaptureCanvas()}_destroyVideoElement(){this.videoElement&&(typeof this.videoEndedListener<"u"&&this.videoElement.removeEventListener("ended",this.videoEndedListener),typeof this.videoPlayingEventListener<"u"&&this.videoElement.removeEventListener("playing",this.videoPlayingEventListener),typeof this.videoCanPlayListener<"u"&&this.videoElement.removeEventListener("loadedmetadata",this.videoCanPlayListener),this.cleanVideoSource(this.videoElement),this.videoElement=void 0)}_destroyImageElement(){this.imageElement&&(this.imageLoadedListener!==void 0&&this.imageElement.removeEventListener("load",this.imageLoadedListener),this.imageElement.src=void 0,this.imageElement.removeAttribute("src"),this.imageElement=void 0)}_destroyCaptureCanvas(){this.captureCanvasContext=void 0,this.captureCanvas=void 0}addVideoSource(e,t){try{e.srcObject=t}catch{e.src=URL.createObjectURL(t)}}cleanVideoSource(e){try{e.srcObject=null}catch{e.src=""}this.videoElement.removeAttribute("src")}}class Ye{constructor(e,t,n=t==null?0:8*t.length,i,o,l=N.currentTimeMillis()){this.text=e,this.rawBytes=t,this.numBits=n,this.resultPoints=i,this.format=o,this.timestamp=l,this.text=e,this.rawBytes=t,n==null?this.numBits=t==null?0:8*t.length:this.numBits=n,this.resultPoints=i,this.format=o,this.resultMetadata=null,l==null?this.timestamp=N.currentTimeMillis():this.timestamp=l}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){let t=this.resultPoints;if(t===null)this.resultPoints=e;else if(e!==null&&e.length>0){let n=new Array(t.length+e.length);N.arraycopy(t,0,n,0,t.length),N.arraycopy(e,0,n,t.length,e.length),this.resultPoints=n}}getTimestamp(){return this.timestamp}toString(){return this.text}}var Wn;(function(E){E[E.AZTEC=0]="AZTEC",E[E.CODABAR=1]="CODABAR",E[E.CODE_39=2]="CODE_39",E[E.CODE_93=3]="CODE_93",E[E.CODE_128=4]="CODE_128",E[E.DATA_MATRIX=5]="DATA_MATRIX",E[E.EAN_8=6]="EAN_8",E[E.EAN_13=7]="EAN_13",E[E.ITF=8]="ITF",E[E.MAXICODE=9]="MAXICODE",E[E.PDF_417=10]="PDF_417",E[E.QR_CODE=11]="QR_CODE",E[E.RSS_14=12]="RSS_14",E[E.RSS_EXPANDED=13]="RSS_EXPANDED",E[E.UPC_A=14]="UPC_A",E[E.UPC_E=15]="UPC_E",E[E.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(Wn||(Wn={}));var oe=Wn,as;(function(E){E[E.OTHER=0]="OTHER",E[E.ORIENTATION=1]="ORIENTATION",E[E.BYTE_SEGMENTS=2]="BYTE_SEGMENTS",E[E.ERROR_CORRECTION_LEVEL=3]="ERROR_CORRECTION_LEVEL",E[E.ISSUE_NUMBER=4]="ISSUE_NUMBER",E[E.SUGGESTED_PRICE=5]="SUGGESTED_PRICE",E[E.POSSIBLE_COUNTRY=6]="POSSIBLE_COUNTRY",E[E.UPC_EAN_EXTENSION=7]="UPC_EAN_EXTENSION",E[E.PDF417_EXTRA_METADATA=8]="PDF417_EXTRA_METADATA",E[E.STRUCTURED_APPEND_SEQUENCE=9]="STRUCTURED_APPEND_SEQUENCE",E[E.STRUCTURED_APPEND_PARITY=10]="STRUCTURED_APPEND_PARITY"})(as||(as={}));var et=as;class _r{constructor(e,t,n,i,o=-1,l=-1){this.rawBytes=e,this.text=t,this.byteSegments=n,this.ecLevel=i,this.structuredAppendSequenceNumber=o,this.structuredAppendParity=l,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 yr{exp(e){return this.expTable[e]}log(e){if(e===0)throw new x;return this.logTable[e]}static addOrSubtract(e,t){return e^t}}class wt{constructor(e,t){if(t.length===0)throw new x;this.field=e;let n=t.length;if(n>1&&t[0]===0){let i=1;for(;in.length){let l=t;t=n,n=l}let i=new Int32Array(n.length),o=n.length-t.length;N.arraycopy(n,0,i,0,o);for(let l=o;l=e.getDegree()&&!i.isZero();){let c=i.getDegree()-e.getDegree(),u=t.multiply(i.getCoefficient(i.getDegree()),l),g=e.multiplyByMonomial(c,u),w=t.buildMonomial(c,u);n=n.addOrSubtract(w),i=i.addOrSubtract(g)}return[n,i]}toString(){let e="";for(let t=this.getDegree();t>=0;t--){let n=this.getCoefficient(t);if(n!==0){if(n<0?(e+=" - ",n=-n):e.length>0&&(e+=" + "),t===0||n!==1){let i=this.field.log(n);i===0?e+="1":i===1?e+="a":(e+="a^",e+=i)}t!==0&&(t===1?e+="x":(e+="x^",e+=t))}}return e}}class ui extends A{}ui.kind="ArithmeticException";class ye extends yr{constructor(e,t,n){super(),this.primitive=e,this.size=t,this.generatorBase=n;let i=new Int32Array(t),o=1;for(let c=0;c=t&&(o^=e,o&=t-1);this.expTable=i;let l=new Int32Array(t);for(let c=0;c=(n/2|0);){let b=o,S=c;if(o=l,c=u,o.isZero())throw new Zn("r_{i-1} was zero");l=b;let T=i.getZero(),D=o.getCoefficient(o.getDegree()),F=i.inverse(D);for(;l.getDegree()>=o.getDegree()&&!l.isZero();){let Z=l.getDegree()-o.getDegree(),Q=i.multiply(l.getCoefficient(l.getDegree()),F);T=T.addOrSubtract(i.buildMonomial(Z,Q)),l=l.addOrSubtract(o.multiplyByMonomial(Z,Q))}if(u=T.multiply(c).addOrSubtract(S),l.getDegree()>=o.getDegree())throw new Wt("Division algorithm failed to reduce polynomial?")}let g=u.getCoefficient(0);if(g===0)throw new Zn("sigmaTilde(0) was zero");let w=i.inverse(g),m=u.multiplyScalar(w),C=l.multiplyScalar(w);return[m,C]}findErrorLocations(e){let t=e.getDegree();if(t===1)return Int32Array.from([e.getCoefficient(1)]);let n=new Int32Array(t),i=0,o=this.field;for(let l=1;l1,m,m+n-1),m+=n-1;else for(let S=n-1;S>=0;--S)w[m++]=(b&1<=8?Le.readCode(e,t,8):Le.readCode(e,t,n)<<8-n}static convertBoolArrayToByteArray(e){let t=new Uint8Array((e.length+7)/8);for(let n=0;n","?","[","]","{","}","CTRL_UL"],Le.DIGIT_TABLE=["CTRL_PS"," ","0","1","2","3","4","5","6","7","8","9",",",".","CTRL_UL","CTRL_US"];class Ce{constructor(){}static round(e){return e===NaN?0:e<=Number.MIN_SAFE_INTEGER?Number.MIN_SAFE_INTEGER:e>=Number.MAX_SAFE_INTEGER?Number.MAX_SAFE_INTEGER:e+(e<0?-.5:.5)|0}static distance(e,t,n,i){let o=e-n,l=t-i;return Math.sqrt(o*o+l*l)}static sum(e){let t=0;for(let n=0,i=e.length;n!==i;n++){let o=e[n];t+=o}return t}}class hi{static floatToIntBits(e){return e}}hi.MAX_VALUE=Number.MAX_SAFE_INTEGER;class ie{constructor(e,t){this.x=e,this.y=t}getX(){return this.x}getY(){return this.y}equals(e){if(e instanceof ie){let t=e;return this.x===t.x&&this.y===t.y}return!1}hashCode(){return 31*hi.floatToIntBits(this.x)+hi.floatToIntBits(this.y)}toString(){return"("+this.x+","+this.y+")"}static orderBestPatterns(e){let t=this.distance(e[0],e[1]),n=this.distance(e[1],e[2]),i=this.distance(e[0],e[2]),o,l,c;if(n>=t&&n>=i?(l=e[0],o=e[1],c=e[2]):i>=n&&i>=t?(l=e[1],o=e[0],c=e[2]):(l=e[2],o=e[0],c=e[1]),this.crossProductZ(o,l,c)<0){let u=o;o=c,c=u}e[0]=o,e[1]=l,e[2]=c}static distance(e,t){return Ce.distance(e.x,e.y,t.x,t.y)}static crossProductZ(e,t,n){let i=t.x,o=t.y;return(n.x-i)*(e.y-o)-(n.y-o)*(e.x-i)}}class di{constructor(e,t){this.bits=e,this.points=t}getBits(){return this.bits}getPoints(){return this.points}}class Xo extends di{constructor(e,t,n,i,o){super(e,t),this.compact=n,this.nbDatablocks=i,this.nbLayers=o}getNbLayers(){return this.nbLayers}getNbDatablocks(){return this.nbDatablocks}isCompact(){return this.compact}}class on{constructor(e,t,n,i){this.image=e,this.height=e.getHeight(),this.width=e.getWidth(),t==null&&(t=on.INIT_SIZE),n==null&&(n=e.getWidth()/2|0),i==null&&(i=e.getHeight()/2|0);let o=t/2|0;if(this.leftInit=n-o,this.rightInit=n+o,this.upInit=i-o,this.downInit=i+o,this.upInit<0||this.leftInit<0||this.downInit>=this.height||this.rightInit>=this.width)throw new M}detect(){let e=this.leftInit,t=this.rightInit,n=this.upInit,i=this.downInit,o=!1,l=!0,c=!1,u=!1,g=!1,w=!1,m=!1,C=this.width,b=this.height;for(;l;){l=!1;let S=!0;for(;(S||!u)&&t=C){o=!0;break}let T=!0;for(;(T||!g)&&i=b){o=!0;break}let D=!0;for(;(D||!w)&&e>=0;)D=this.containsBlackPoint(n,i,e,!1),D?(e--,l=!0,w=!0):w||e--;if(e<0){o=!0;break}let F=!0;for(;(F||!m)&&n>=0;)F=this.containsBlackPoint(e,t,n,!0),F?(n--,l=!0,m=!0):m||n--;if(n<0){o=!0;break}l&&(c=!0)}if(!o&&c){let S=t-e,T=null;for(let Q=1;T===null&&Qn||u<-1||u>i)throw new M;o=!1,c===-1?(t[l]=0,o=!0):c===n&&(t[l]=n-1,o=!0),u===-1?(t[l+1]=0,o=!0):u===i&&(t[l+1]=i-1,o=!0)}o=!0;for(let l=t.length-2;l>=0&&o;l-=2){let c=Math.floor(t[l]),u=Math.floor(t[l+1]);if(c<-1||c>n||u<-1||u>i)throw new M;o=!1,c===-1?(t[l]=0,o=!0):c===n&&(t[l]=n-1,o=!0),u===-1?(t[l+1]=0,o=!0):u===i&&(t[l+1]=i-1,o=!0)}}}class Vt{constructor(e,t,n,i,o,l,c,u,g){this.a11=e,this.a21=t,this.a31=n,this.a12=i,this.a22=o,this.a32=l,this.a13=c,this.a23=u,this.a33=g}static quadrilateralToQuadrilateral(e,t,n,i,o,l,c,u,g,w,m,C,b,S,T,D){let F=Vt.quadrilateralToSquare(e,t,n,i,o,l,c,u);return Vt.squareToQuadrilateral(g,w,m,C,b,S,T,D).times(F)}transformPoints(e){let t=e.length,n=this.a11,i=this.a12,o=this.a13,l=this.a21,c=this.a22,u=this.a23,g=this.a31,w=this.a32,m=this.a33;for(let C=0;C>1&127):(i<<=10,i+=(c>>2&992)+(c>>1&31))}let o=this.getCorrectedParameterData(i,this.compact);this.compact?(this.nbLayers=(o>>6)+1,this.nbDataBlocks=(o&63)+1):(this.nbLayers=(o>>11)+1,this.nbDataBlocks=(o&2047)+1)}getRotation(e,t){let n=0;e.forEach((i,o,l)=>{let c=(i>>t-2<<1)+(i&1);n=(n<<3)+c}),n=((n&1)<<11)+(n>>1);for(let i=0;i<4;i++)if(U.bitCount(n^this.EXPECTED_CORNER_BITS[i])<=2)return i;throw new M}getCorrectedParameterData(e,t){let n,i;t?(n=7,i=2):(n=10,i=4);let o=n-i,l=new Int32Array(n);for(let u=n-1;u>=0;--u)l[u]=e&15,e>>=4;try{new Ir(ye.AZTEC_PARAM).decode(l,o)}catch{throw new M}let c=0;for(let u=0;u2){let T=this.distancePoint(S,m)*this.nbCenterLayers/(this.distancePoint(o,t)*(this.nbCenterLayers+2));if(T<.75||T>1.25||!this.isWhiteOrBlackRectangle(m,C,b,S))break}t=m,n=C,i=b,o=S,l=!l}if(this.nbCenterLayers!==5&&this.nbCenterLayers!==7)throw new M;this.compact=this.nbCenterLayers===5;let c=new ie(t.getX()+.5,t.getY()-.5),u=new ie(n.getX()+.5,n.getY()+.5),g=new ie(i.getX()-.5,i.getY()+.5),w=new ie(o.getX()-.5,o.getY()-.5);return this.expandSquare([c,u,g,w],2*this.nbCenterLayers-3,2*this.nbCenterLayers)}getMatrixCenter(){let e,t,n,i;try{let c=new on(this.image).detect();e=c[0],t=c[1],n=c[2],i=c[3]}catch{let u=this.image.getWidth()/2,g=this.image.getHeight()/2;e=this.getFirstDifferent(new dt(u+7,g-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new dt(u+7,g+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new dt(u-7,g+7),!1,-1,1).toResultPoint(),i=this.getFirstDifferent(new dt(u-7,g-7),!1,-1,-1).toResultPoint()}let o=Ce.round((e.getX()+i.getX()+t.getX()+n.getX())/4),l=Ce.round((e.getY()+i.getY()+t.getY()+n.getY())/4);try{let c=new on(this.image,15,o,l).detect();e=c[0],t=c[1],n=c[2],i=c[3]}catch{e=this.getFirstDifferent(new dt(o+7,l-7),!1,1,-1).toResultPoint(),t=this.getFirstDifferent(new dt(o+7,l+7),!1,1,1).toResultPoint(),n=this.getFirstDifferent(new dt(o-7,l+7),!1,-1,1).toResultPoint(),i=this.getFirstDifferent(new dt(o-7,l-7),!1,-1,-1).toResultPoint()}return o=Ce.round((e.getX()+i.getX()+t.getX()+n.getX())/4),l=Ce.round((e.getY()+i.getY()+t.getY()+n.getY())/4),new dt(o,l)}getMatrixCornerPoints(e){return this.expandSquare(e,2*this.nbCenterLayers,this.getDimension())}sampleGrid(e,t,n,i,o){let l=hn.getInstance(),c=this.getDimension(),u=c/2-this.nbCenterLayers,g=c/2+this.nbCenterLayers;return l.sampleGrid(e,c,c,u,u,g,u,g,g,u,g,t.getX(),t.getY(),n.getX(),n.getY(),i.getX(),i.getY(),o.getX(),o.getY())}sampleLine(e,t,n){let i=0,o=this.distanceResultPoint(e,t),l=o/n,c=e.getX(),u=e.getY(),g=l*(t.getX()-e.getX())/o,w=l*(t.getY()-e.getY())/o;for(let m=0;m.1&&m<.9?0:m<=.1===g?1:-1}getFirstDifferent(e,t,n,i){let o=e.getX()+n,l=e.getY()+i;for(;this.isValid(o,l)&&this.image.get(o,l)===t;)o+=n,l+=i;for(o-=n,l-=i;this.isValid(o,l)&&this.image.get(o,l)===t;)o+=n;for(o-=n;this.isValid(o,l)&&this.image.get(o,l)===t;)l+=i;return l-=i,new dt(o,l)}expandSquare(e,t,n){let i=n/(2*t),o=e[0].getX()-e[2].getX(),l=e[0].getY()-e[2].getY(),c=(e[0].getX()+e[2].getX())/2,u=(e[0].getY()+e[2].getY())/2,g=new ie(c+i*o,u+i*l),w=new ie(c-i*o,u-i*l);o=e[1].getX()-e[3].getX(),l=e[1].getY()-e[3].getY(),c=(e[1].getX()+e[3].getX())/2,u=(e[1].getY()+e[3].getY())/2;let m=new ie(c+i*o,u+i*l),C=new ie(c-i*o,u-i*l);return[g,m,w,C]}isValid(e,t){return e>=0&&e0&&t{n.foundPossibleResultPoint(i)})}}reset(){}}class S1 extends Ht{constructor(e=500){super(new gi,e)}}class Ze{decode(e,t){try{return this.doDecode(e,t)}catch{if(t&&t.get(z.TRY_HARDER)===!0&&e.isRotateSupported()){let o=e.rotateCounterClockwise(),l=this.doDecode(o,t),c=l.getResultMetadata(),u=270;c!==null&&c.get(et.ORIENTATION)===!0&&(u=u+c.get(et.ORIENTATION)%360),l.putMetadata(et.ORIENTATION,u);let g=l.getResultPoints();if(g!==null){let w=o.getHeight();for(let m=0;m>(l?8:5)),u;l?u=i:u=15;let g=Math.trunc(i/2);for(let w=0;w=i)break;try{o=e.getBlackRow(b,o)}catch{continue}for(let S=0;S<2;S++){if(S===1&&(o.reverse(),t&&t.get(z.NEED_RESULT_POINT_CALLBACK)===!0)){let T=new Map;t.forEach((D,F)=>T.set(F,D)),T.delete(z.NEED_RESULT_POINT_CALLBACK),t=T}try{let T=this.decodeRow(b,o,t);if(S===1){T.putMetadata(et.ORIENTATION,180);let D=T.getResultPoints();D!==null&&(D[0]=new ie(n-D[0].getX()-1,D[0].getY()),D[1]=new ie(n-D[1].getX()-1,D[1].getY()))}return T}catch{}}}throw new M}static recordPattern(e,t,n){let i=n.length;for(let g=0;g=o)throw new M;let l=!e.get(t),c=0,u=t;for(;u0&&i>=0;)e.get(--t)!==o&&(i--,o=!o);if(i>=0)throw new M;Ze.recordPattern(e,t+1,n)}static patternMatchVariance(e,t,n){let i=e.length,o=0,l=0;for(let g=0;gm?w-m:m-w;if(C>n)return Number.POSITIVE_INFINITY;u+=C}return u/o}}class J extends Ze{static findStartPattern(e){let t=e.getSize(),n=e.getNextSet(0),i=0,o=Int32Array.from([0,0,0,0,0,0]),l=n,c=!1,u=6;for(let g=n;g=0&&e.isRange(Math.max(0,l-(g-l)/2),l,!1))return Int32Array.from([l,g,m]);l+=o[0]+o[1],o=o.slice(2,o.length-1),o[i-1]=0,o[i]=0,i--}else i++;o[i]=1,c=!c}throw new M}static decodeCode(e,t,n){Ze.recordPattern(e,n,t);let i=J.MAX_AVG_VARIANCE,o=-1;for(let l=0;l=0)return o;throw new M}decodeRow(e,t,n){let i=n&&n.get(z.ASSUME_GS1)===!0,o=J.findStartPattern(t),l=o[2],c=0,u=new Uint8Array(20);u[c++]=l;let g;switch(l){case J.CODE_START_A:g=J.CODE_CODE_A;break;case J.CODE_START_B:g=J.CODE_CODE_B;break;case J.CODE_START_C:g=J.CODE_CODE_C;break;default:throw new L}let w=!1,m=!1,C="",b=o[0],S=o[1],T=Int32Array.from([0,0,0,0,0,0]),D=0,F=0,Z=l,Q=0,j=!0,we=!1,he=!1;for(;!w;){let rr=m;switch(m=!1,D=F,F=J.decodeCode(t,T,S),u[c++]=F,F!==J.CODE_STOP&&(j=!0),F!==J.CODE_STOP&&(Q++,Z+=Q*F),b=S,S+=T.reduce((t0,n0)=>t0+n0,0),F){case J.CODE_START_A:case J.CODE_START_B:case J.CODE_START_C:throw new L}switch(g){case J.CODE_CODE_A:if(F<64)he===we?C+=String.fromCharCode(32+F):C+=String.fromCharCode(32+F+128),he=!1;else if(F<96)he===we?C+=String.fromCharCode(F-64):C+=String.fromCharCode(F+64),he=!1;else switch(F!==J.CODE_STOP&&(j=!1),F){case J.CODE_FNC_1:i&&(C.length===0?C+="]C1":C+="");break;case J.CODE_FNC_2:case J.CODE_FNC_3:break;case J.CODE_FNC_4_A:!we&&he?(we=!0,he=!1):we&&he?(we=!1,he=!1):he=!0;break;case J.CODE_SHIFT:m=!0,g=J.CODE_CODE_B;break;case J.CODE_CODE_B:g=J.CODE_CODE_B;break;case J.CODE_CODE_C:g=J.CODE_CODE_C;break;case J.CODE_STOP:w=!0;break}break;case J.CODE_CODE_B:if(F<96)he===we?C+=String.fromCharCode(32+F):C+=String.fromCharCode(32+F+128),he=!1;else switch(F!==J.CODE_STOP&&(j=!1),F){case J.CODE_FNC_1:i&&(C.length===0?C+="]C1":C+="");break;case J.CODE_FNC_2:case J.CODE_FNC_3:break;case J.CODE_FNC_4_B:!we&&he?(we=!0,he=!1):we&&he?(we=!1,he=!1):he=!0;break;case J.CODE_SHIFT:m=!0,g=J.CODE_CODE_A;break;case J.CODE_CODE_A:g=J.CODE_CODE_A;break;case J.CODE_CODE_C:g=J.CODE_CODE_C;break;case J.CODE_STOP:w=!0;break}break;case J.CODE_CODE_C:if(F<100)F<10&&(C+="0"),C+=F;else switch(F!==J.CODE_STOP&&(j=!1),F){case J.CODE_FNC_1:i&&(C.length===0?C+="]C1":C+="");break;case J.CODE_CODE_A:g=J.CODE_CODE_A;break;case J.CODE_CODE_B:g=J.CODE_CODE_B;break;case J.CODE_STOP:w=!0;break}break}rr&&(g=g===J.CODE_CODE_A?J.CODE_CODE_B:J.CODE_CODE_A)}let mt=S-b;if(S=t.getNextUnset(S),!t.isRange(S,Math.min(t.getSize(),S+(S-b)/2),!1))throw new M;if(Z-=Q*D,Z%103!==D)throw new v;let Gt=C.length;if(Gt===0)throw new M;Gt>0&&j&&(g===J.CODE_CODE_C?C=C.substring(0,Gt-2):C=C.substring(0,Gt-1));let Ct=(o[1]+o[0])/2,Be=b+mt/2,ct=u.length,bt=new Uint8Array(ct);for(let rr=0;rrn&&(o=u);n=o,i=0;let l=0,c=0;for(let u=0;un&&(c|=1<0;u++){let g=e[u];if(g>n&&(i--,g*2>=l))return-1}return c}}while(i>3);return-1}static patternToChar(e){for(let t=0;t="A"&&l<="Z")c=String.fromCharCode(l.charCodeAt(0)+32);else throw new L;break;case"$":if(l>="A"&&l<="Z")c=String.fromCharCode(l.charCodeAt(0)-64);else throw new L;break;case"%":if(l>="A"&&l<="E")c=String.fromCharCode(l.charCodeAt(0)-38);else if(l>="F"&&l<="J")c=String.fromCharCode(l.charCodeAt(0)-11);else if(l>="K"&&l<="O")c=String.fromCharCode(l.charCodeAt(0)+16);else if(l>="P"&&l<="T")c=String.fromCharCode(l.charCodeAt(0)+43);else if(l==="U")c="\0";else if(l==="V")c="@";else if(l==="W")c="`";else if(l==="X"||l==="Y"||l==="Z")c="\x7F";else throw new L;break;case"/":if(l>="A"&&l<="O")c=String.fromCharCode(l.charCodeAt(0)-32);else if(l==="Z")c=":";else throw new L;break}n+=c,i++}else n+=o}return n}}Ke.ALPHABET_STRING="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%",Ke.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],Ke.ASTERISK_ENCODING=148;class De extends Ze{constructor(){super(...arguments),this.narrowLineWidth=-1}decodeRow(e,t,n){let i=this.decodeStart(t),o=this.decodeEnd(t),l=new G;De.decodeMiddle(t,i[1],o[0],l);let c=l.toString(),u=null;n!=null&&(u=n.get(z.ALLOWED_LENGTHS)),u==null&&(u=De.DEFAULT_ALLOWED_LENGTHS);let g=c.length,w=!1,m=0;for(let S of u){if(g===S){w=!0;break}S>m&&(m=S)}if(!w&&g>m&&(w=!0),!w)throw new L;let C=[new ie(i[1],e),new ie(o[0],e)];return new Ye(c,null,0,C,oe.ITF,new Date().getTime())}static decodeMiddle(e,t,n,i){let o=new Int32Array(10),l=new Int32Array(5),c=new Int32Array(5);for(o.fill(0),l.fill(0),c.fill(0);t0&&i>=0&&!e.get(i);i--)n--;if(n!==0)throw new M}static skipWhiteSpace(e){let t=e.getSize(),n=e.getNextSet(0);if(n===t)throw new M;return n}decodeEnd(e){e.reverse();try{let t=De.skipWhiteSpace(e),n;try{n=De.findGuardPattern(e,t,De.END_PATTERN_REVERSED[0])}catch(o){o instanceof M&&(n=De.findGuardPattern(e,t,De.END_PATTERN_REVERSED[1]))}this.validateQuietZone(e,n[0]);let i=n[0];return n[0]=e.getSize()-n[1],n[1]=e.getSize()-i,n}finally{e.reverse()}}static findGuardPattern(e,t,n){let i=n.length,o=new Int32Array(i),l=e.getSize(),c=!1,u=0,g=t;o.fill(0);for(let w=t;w=0)return n%10;throw new M}}De.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])],De.MAX_AVG_VARIANCE=.38,De.MAX_INDIVIDUAL_VARIANCE=.5,De.DEFAULT_ALLOWED_LENGTHS=[6,8,10,12,14],De.START_PATTERN=Int32Array.from([1,1,1,1]),De.END_PATTERN_REVERSED=[Int32Array.from([1,1,2]),Int32Array.from([1,1,3])];class Xe extends Ze{constructor(){super(...arguments),this.decodeRowStringBuffer=""}static findStartGuardPattern(e){let t=!1,n,i=0,o=Int32Array.from([0,0,0]);for(;!t;){o=Int32Array.from([0,0,0]),n=Xe.findGuardPattern(e,i,!1,this.START_END_PATTERN,o);let l=n[0];i=n[1];let c=l-(i-l);c>=0&&(t=e.isRange(c,l,!1))}return n}static checkChecksum(e){return Xe.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return Xe.getStandardUPCEANChecksum(e.substring(0,t-1))===n}static getStandardUPCEANChecksum(e){let t=e.length,n=0;for(let i=t-1;i>=0;i-=2){let o=e.charAt(i).charCodeAt(0)-48;if(o<0||o>9)throw new L;n+=o}n*=3;for(let i=t-2;i>=0;i-=2){let o=e.charAt(i).charCodeAt(0)-48;if(o<0||o>9)throw new L;n+=o}return(1e3-n)%10}static decodeEnd(e,t){return Xe.findGuardPattern(e,t,!1,Xe.START_END_PATTERN,new Int32Array(Xe.START_END_PATTERN.length).fill(0))}static findGuardPatternWithoutCounters(e,t,n,i){return this.findGuardPattern(e,t,n,i,new Int32Array(i.length))}static findGuardPattern(e,t,n,i,o){let l=e.getSize();t=n?e.getNextUnset(t):e.getNextSet(t);let c=0,u=t,g=i.length,w=n;for(let m=t;m=0)return l;throw new M}}Xe.MAX_AVG_VARIANCE=.48,Xe.MAX_INDIVIDUAL_VARIANCE=.7,Xe.START_END_PATTERN=Int32Array.from([1,1,1]),Xe.MIDDLE_PATTERN=Int32Array.from([1,1,1,1,1]),Xe.END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Xe.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 br{constructor(){this.CHECK_DIGIT_ENCODINGS=[24,20,18,17,12,6,3,10,9,5],this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,n){let i=this.decodeRowStringBuffer,o=this.decodeMiddle(t,n,i),l=i.toString(),c=br.parseExtensionString(l),u=[new ie((n[0]+n[1])/2,e),new ie(o,e)],g=new Ye(l,null,0,u,oe.UPC_EAN_EXTENSION,new Date().getTime());return c!=null&&g.putAllMetadata(c),g}decodeMiddle(e,t,n){let i=this.decodeMiddleCounters;i[0]=0,i[1]=0,i[2]=0,i[3]=0;let o=e.getSize(),l=t[1],c=0;for(let g=0;g<5&&l=10&&(c|=1<<4-g),g!==4&&(l=e.getNextSet(l),l=e.getNextUnset(l))}if(n.length!==5)throw new M;let u=this.determineCheckDigit(c);if(br.extensionChecksum(n.toString())!==u)throw new M;return l}static extensionChecksum(e){let t=e.length,n=0;for(let i=t-2;i>=0;i-=2)n+=e.charAt(i).charCodeAt(0)-48;n*=3;for(let i=t-1;i>=0;i-=2)n+=e.charAt(i).charCodeAt(0)-48;return n*=3,n%10}determineCheckDigit(e){for(let t=0;t<10;t++)if(e===this.CHECK_DIGIT_ENCODINGS[t])return t;throw new M}static parseExtensionString(e){if(e.length!==5)return null;let t=br.parseExtension5String(e);return t==null?null:new Map([[et.SUGGESTED_PRICE,t]])}static parseExtension5String(e){let t;switch(e.charAt(0)){case"0":t="\xA3";break;case"5":t="$";break;case"9":switch(e){case"90000":return null;case"99991":return"0.00";case"99990":return"Used"}t="";break;default:t="";break}let n=parseInt(e.substring(1)),i=(n/100).toString(),o=n%100,l=o<10?"0"+o:o.toString();return t+i+"."+l}}class cs{constructor(){this.decodeMiddleCounters=Int32Array.from([0,0,0,0]),this.decodeRowStringBuffer=""}decodeRow(e,t,n){let i=this.decodeRowStringBuffer,o=this.decodeMiddle(t,n,i),l=i.toString(),c=cs.parseExtensionString(l),u=[new ie((n[0]+n[1])/2,e),new ie(o,e)],g=new Ye(l,null,0,u,oe.UPC_EAN_EXTENSION,new Date().getTime());return c!=null&&g.putAllMetadata(c),g}decodeMiddle(e,t,n){let i=this.decodeMiddleCounters;i[0]=0,i[1]=0,i[2]=0,i[3]=0;let o=e.getSize(),l=t[1],c=0;for(let u=0;u<2&&l=10&&(c|=1<<1-u),u!==1&&(l=e.getNextSet(l),l=e.getNextUnset(l))}if(n.length!==2)throw new M;if(parseInt(n.toString())%4!==c)throw new M;return l}static parseExtensionString(e){return e.length!==2?null:new Map([[et.ISSUE_NUMBER,parseInt(e)]])}}class Yo{static decodeRow(e,t,n){let i=Xe.findGuardPattern(t,n,!1,this.EXTENSION_START_PATTERN,new Int32Array(this.EXTENSION_START_PATTERN.length).fill(0));try{return new br().decodeRow(e,t,i)}catch{return new cs().decodeRow(e,t,i)}}}Yo.EXTENSION_START_PATTERN=Int32Array.from([1,1,2]);class Ie extends Xe{constructor(){super(),this.decodeRowStringBuffer="",Ie.L_AND_G_PATTERNS=Ie.L_PATTERNS.map(e=>Int32Array.from(e));for(let e=10;e<20;e++){let t=Ie.L_PATTERNS[e-10],n=new Int32Array(t.length);for(let i=0;i=t.getSize()||!t.isRange(w,m,!1))throw new M;let C=u.toString();if(C.length<8)throw new L;if(!Ie.checkChecksum(C))throw new v;let b=(i[1]+i[0])/2,S=(g[1]+g[0])/2,T=this.getBarcodeFormat(),D=[new ie(b,e),new ie(S,e)],F=new Ye(C,null,0,D,T,new Date().getTime()),Z=0;try{let j=Yo.decodeRow(e,t,g[1]);F.putMetadata(et.UPC_EAN_EXTENSION,j.getText()),F.putAllMetadata(j.getResultMetadata()),F.addResultPoints(j.getResultPoints()),Z=j.getText().length}catch{}let Q=n==null?null:n.get(z.ALLOWED_EAN_EXTENSIONS);if(Q!=null){let j=!1;for(let we in Q)if(Z.toString()===we){j=!0;break}if(!j)throw new M}return F}decodeEnd(e,t){return Ie.findGuardPattern(e,t,!1,Ie.START_END_PATTERN,new Int32Array(Ie.START_END_PATTERN.length).fill(0))}static checkChecksum(e){return Ie.checkStandardUPCEANChecksum(e)}static checkStandardUPCEANChecksum(e){let t=e.length;if(t===0)return!1;let n=parseInt(e.charAt(t-1),10);return Ie.getStandardUPCEANChecksum(e.substring(0,t-1))===n}static getStandardUPCEANChecksum(e){let t=e.length,n=0;for(let i=t-1;i>=0;i-=2){let o=e.charAt(i).charCodeAt(0)-48;if(o<0||o>9)throw new L;n+=o}n*=3;for(let i=t-2;i>=0;i-=2){let o=e.charAt(i).charCodeAt(0)-48;if(o<0||o>9)throw new L;n+=o}return(1e3-n)%10}}class Mn extends Ie{constructor(){super(),this.decodeMiddleCounters=Int32Array.from([0,0,0,0])}decodeMiddle(e,t,n){let i=this.decodeMiddleCounters;i[0]=0,i[1]=0,i[2]=0,i[3]=0;let o=e.getSize(),l=t[1],c=0;for(let g=0;g<6&&l=10&&(c|=1<<5-g)}n=Mn.determineFirstDigit(n,c),l=Ie.findGuardPattern(e,l,!0,Ie.MIDDLE_PATTERN,new Int32Array(Ie.MIDDLE_PATTERN.length).fill(0))[1];for(let g=0;g<6&&lg);i[0]=0,i[1]=0,i[2]=0,i[3]=0;let o=e.getSize(),l=t[1],c=0;for(let g=0;g<6&&l=10&&(c|=1<<5-g)}let u=Xt.determineNumSysAndCheckDigit(n,c);return{rowOffset:l,resultString:u}}decodeEnd(e,t){return Xt.findGuardPatternWithoutCounters(e,t,!0,Xt.MIDDLE_END_PATTERN)}checkChecksum(e){return Ie.checkChecksum(Xt.convertUPCEtoUPCA(e))}static determineNumSysAndCheckDigit(e,t){for(let n=0;n<=1;n++)for(let i=0;i<10;i++)if(t===this.NUMSYS_AND_CHECK_DIGIT_PATTERNS[n][i]){let o=String.fromCharCode(48+n),l=String.fromCharCode(48+i);return o+e+l}throw M.getNotFoundInstance()}getBarcodeFormat(){return oe.UPC_E}static convertUPCEtoUPCA(e){let t=e.slice(1,7).split("").map(o=>o.charCodeAt(0)),n=new G;n.append(e.charAt(0));let i=t[5];switch(i){case 0:case 1:case 2:n.appendChars(t,0,2),n.append(i),n.append("0000"),n.appendChars(t,2,3);break;case 3:n.appendChars(t,0,3),n.append("00000"),n.appendChars(t,3,2);break;case 4:n.appendChars(t,0,4),n.append("00000"),n.append(t[4]);break;default:n.appendChars(t,0,5),n.append("0000"),n.append(i);break}return e.length>=8&&n.append(e.charAt(7)),n.toString()}}Xt.MIDDLE_END_PATTERN=Int32Array.from([1,1,1,1,1,1]),Xt.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 fs extends Ze{constructor(e){super();let t=e==null?null:e.get(z.POSSIBLE_FORMATS),n=[];a(t)?(n.push(new Mn),n.push(new Zo),n.push(new Wo),n.push(new Xt)):(t.indexOf(oe.EAN_13)>-1&&n.push(new Mn),t.indexOf(oe.UPC_A)>-1&&n.push(new Zo),t.indexOf(oe.EAN_8)>-1&&n.push(new Wo),t.indexOf(oe.UPC_E)>-1&&n.push(new Xt)),this.readers=n}decodeRow(e,t,n){for(let i of this.readers)try{let o=i.decodeRow(e,t,n),l=o.getBarcodeFormat()===oe.EAN_13&&o.getText().charAt(0)==="0",c=n==null?null:n.get(z.POSSIBLE_FORMATS),u=c==null||c.includes(oe.UPC_A);if(l&&u){let g=o.getRawBytes(),w=new Ye(o.getText().substring(1),g,g?g.length:null,o.getResultPoints(),oe.UPC_A);return w.putAllMetadata(o.getResultMetadata()),w}return o}catch{}throw new M}reset(){for(let e of this.readers)e.reset()}}class ut extends Ze{constructor(){super(),this.decodeFinderCounters=new Int32Array(4),this.dataCharacterCounters=new Int32Array(8),this.oddRoundingErrors=new Array(4),this.evenRoundingErrors=new Array(4),this.oddCounts=new Array(this.dataCharacterCounters.length/2),this.evenCounts=new Array(this.dataCharacterCounters.length/2)}getDecodeFinderCounters(){return this.decodeFinderCounters}getDataCharacterCounters(){return this.dataCharacterCounters}getOddRoundingErrors(){return this.oddRoundingErrors}getEvenRoundingErrors(){return this.evenRoundingErrors}getOddCounts(){return this.oddCounts}getEvenCounts(){return this.evenCounts}parseFinderValue(e,t){for(let n=0;ni&&(i=t[o],n=o);e[n]++}static decrement(e,t){let n=0,i=t[0];for(let o=1;o=ut.MIN_FINDER_PATTERN_RATIO&&i<=ut.MAX_FINDER_PATTERN_RATIO){let o=Number.MAX_SAFE_INTEGER,l=Number.MIN_SAFE_INTEGER;for(let c of e)c>l&&(l=c),c=c-u-1&&(w-=Zt.combins(i-g-(c-u),c-u-2)),c-u-1>1){let m=0;for(let C=i-g-(c-u-2);C>t;C--)m+=Zt.combins(i-g-C-1,c-u-3);w-=m*(c-1-u)}else i-g>t&&w--;o+=w}i-=g}return o}static combins(e,t){let n,i;e-t>t?(i=t,n=e-t):(i=e-t,n=t);let o=1,l=1;for(let c=e;c>n;c--)o*=c,l<=i&&(o/=l,l++);for(;l<=i;)o/=l,l++;return o}}class T1{static buildBitArray(e){let t=e.length*2-1;e[e.length-1].getRightChar()==null&&(t-=1);let n=12*t,i=new W(n),o=0,c=e[0].getRightChar().getValue();for(let u=11;u>=0;--u)(c&1<=0;--m)(w&1<=0;--C)(m&1<10||n<0||n>10)throw new L;this.firstDigit=t,this.secondDigit=n}getFirstDigit(){return this.firstDigit}getSecondDigit(){return this.secondDigit}getValue(){return this.firstDigit*10+this.secondDigit}isFirstDigitFNC1(){return this.firstDigit===Rt.FNC1}isSecondDigitFNC1(){return this.secondDigit===Rt.FNC1}isAnyFNC1(){return this.firstDigit===Rt.FNC1||this.secondDigit===Rt.FNC1}}Rt.FNC1=10;class ne{constructor(){}static parseFieldsInGeneralPurpose(e){if(!e)return null;if(e.length<2)throw new M;let t=e.substring(0,2);for(let o of ne.TWO_DIGIT_DATA_LENGTH)if(o[0]===t)return o[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(2,o[2],e):ne.processFixedAI(2,o[1],e);if(e.length<3)throw new M;let n=e.substring(0,3);for(let o of ne.THREE_DIGIT_DATA_LENGTH)if(o[0]===n)return o[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(3,o[2],e):ne.processFixedAI(3,o[1],e);for(let o of ne.THREE_DIGIT_PLUS_DIGIT_DATA_LENGTH)if(o[0]===n)return o[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(4,o[2],e):ne.processFixedAI(4,o[1],e);if(e.length<4)throw new M;let i=e.substring(0,4);for(let o of ne.FOUR_DIGIT_DATA_LENGTH)if(o[0]===i)return o[1]===ne.VARIABLE_LENGTH?ne.processVariableAI(4,o[2],e):ne.processFixedAI(4,o[1],e);throw new M}static processFixedAI(e,t,n){if(n.lengththis.information.getSize())return e+4<=this.information.getSize();for(let t=e;tthis.information.getSize()){let o=this.extractNumericValueFromBitArray(e,4);return o===0?new Rt(this.information.getSize(),Rt.FNC1,Rt.FNC1):new Rt(this.information.getSize(),o-1,Rt.FNC1)}let t=this.extractNumericValueFromBitArray(e,7),n=(t-8)/11,i=(t-8)%11;return new Rt(e+7,n,i)}extractNumericValueFromBitArray(e,t){return Kn.extractNumericValueFromBitArray(this.information,e,t)}static extractNumericValueFromBitArray(e,t,n){let i=0;for(let o=0;othis.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+7>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<116)return!0;if(e+8>this.information.getSize())return!1;let i=this.extractNumericValueFromBitArray(e,8);return i>=232&&i<253}decodeIsoIec646(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new pt(e+5,pt.FNC1);if(t>=5&&t<15)return new pt(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,7);if(n>=64&&n<90)return new pt(e+7,""+(n+1));if(n>=90&&n<116)return new pt(e+7,""+(n+7));let i=this.extractNumericValueFromBitArray(e,8),o;switch(i){case 232:o="!";break;case 233:o='"';break;case 234:o="%";break;case 235:o="&";break;case 236:o="'";break;case 237:o="(";break;case 238:o=")";break;case 239:o="*";break;case 240:o="+";break;case 241:o=",";break;case 242:o="-";break;case 243:o=".";break;case 244:o="/";break;case 245:o=":";break;case 246:o=";";break;case 247:o="<";break;case 248:o="=";break;case 249:o=">";break;case 250:o="?";break;case 251:o="_";break;case 252:o=" ";break;default:throw new L}return new pt(e+8,o)}isStillAlpha(e){if(e+5>this.information.getSize())return!1;let t=this.extractNumericValueFromBitArray(e,5);if(t>=5&&t<16)return!0;if(e+6>this.information.getSize())return!1;let n=this.extractNumericValueFromBitArray(e,6);return n>=16&&n<63}decodeAlphanumeric(e){let t=this.extractNumericValueFromBitArray(e,5);if(t===15)return new pt(e+5,pt.FNC1);if(t>=5&&t<15)return new pt(e+5,"0"+(t-5));let n=this.extractNumericValueFromBitArray(e,6);if(n>=32&&n<58)return new pt(e+6,""+(n+33));let i;switch(n){case 58:i="*";break;case 59:i=",";break;case 60:i="-";break;case 61:i=".";break;case 62:i="/";break;default:throw new Wt("Decoding invalid alphanumeric value: "+n)}return new pt(e+6,i)}isAlphaTo646ToAlphaLatch(e){if(e+1>this.information.getSize())return!1;for(let t=0;t<5&&t+ethis.information.getSize())return!1;for(let t=e;tthis.information.getSize())return!1;for(let t=0;t<4&&t+e{t.forEach(l=>{i.getLeftChar().getValue()===l.getLeftChar().getValue()&&i.getRightChar().getValue()===l.getRightChar().getValue()&&i.getFinderPatter().getValue()===l.getFinderPatter().getValue()&&(n=!0)})}),n}}class X extends ut{constructor(e){super(...arguments),this.pairs=new Array(X.MAX_PAIRS),this.rows=new Array,this.startEnd=[2],this.verbose=e===!0}decodeRow(e,t,n){this.pairs.length=0,this.startFromEven=!1;try{return X.constructResult(this.decodeRow2pairs(e,t))}catch(i){this.verbose&&console.log(i)}return this.pairs.length=0,this.startFromEven=!0,X.constructResult(this.decodeRow2pairs(e,t))}reset(){this.pairs.length=0,this.rows.length=0}decodeRow2pairs(e,t){let n=!1;for(;!n;)try{this.pairs.push(this.retrieveNextPair(t,this.pairs,e))}catch(o){if(o instanceof M){if(!this.pairs.length)throw new M;n=!0}}if(this.checkChecksum())return this.pairs;let i;if(this.rows.length?i=!0:i=!1,this.storeRow(e,!1),i){let o=this.checkRowsBoolean(!1);if(o!=null||(o=this.checkRowsBoolean(!0),o!=null))return o}throw new M}checkRowsBoolean(e){if(this.rows.length>25)return this.rows.length=0,null;this.pairs.length=0,e&&(this.rows=this.rows.reverse());let t=null;try{t=this.checkRows(new Array,0)}catch(n){this.verbose&&console.log(n)}return e&&(this.rows=this.rows.reverse()),t}checkRows(e,t){for(let n=t;nt.length)continue;let n=!0;for(let i=0;ie){o=l.isEquivalent(this.pairs);break}i=l.isEquivalent(this.pairs),n++}o||i||X.isPartialRow(this.pairs,this.rows)||(this.rows.push(n,new ds(this.pairs,e,t)),this.removePartialRows(this.pairs,this.rows))}removePartialRows(e,t){for(let n of t)if(n.getPairs().length!==e.length){for(let i of n.getPairs())for(let o of e)if(dn.equals(i,o))break}}static isPartialRow(e,t){for(let n of t){let i=!0;for(let o of e){let l=!1;for(let c of n.getPairs())if(o.equals(c)){l=!0;break}if(!l){i=!1;break}}if(i)return!0}return!1}getRows(){return this.rows}static constructResult(e){let t=T1.buildBitArray(e),i=Qo(t).parseInformation(),o=e[0].getFinderPattern().getResultPoints(),l=e[e.length-1].getFinderPattern().getResultPoints(),c=[o[0],o[1],l[0],l[1]];return new Ye(i,null,null,c,oe.RSS_EXPANDED,null)}checkChecksum(){let e=this.pairs.get(0),t=e.getLeftChar(),n=e.getRightChar();if(n==null)return!1;let i=n.getChecksumPortion(),o=2;for(let c=1;c=0?l=n:this.isEmptyPair(t)?l=0:l=t[t.length-1].getFinderPattern().getStartEnd()[1];let c=t.length%2!=0;this.startFromEven&&(c=!c);let u=!1;for(;l=0&&!e.get(g);)g--;g++,i=this.startEnd[0]-g,o=g,l=this.startEnd[1]}else o=this.startEnd[0],l=e.getNextUnset(this.startEnd[1]+1),i=l-this.startEnd[1];let c=this.getDecodeFinderCounters();N.arraycopy(c,0,c,1,c.length-1),c[0]=i;let u;try{u=this.parseFinderValue(c,X.FINDER_PATTERNS)}catch{return null}return new xi(u,[o,l],o,l,t)}decodeDataCharacter(e,t,n,i){let o=this.getDataCharacterCounters();for(let Be=0;Be.3)throw new M;let g=this.getOddCounts(),w=this.getEvenCounts(),m=this.getOddRoundingErrors(),C=this.getEvenRoundingErrors();for(let Be=0;Be8){if(ct>8.7)throw new M;bt=8}let nr=Be/2;(Be&1)==0?(g[nr]=bt,m[nr]=ct-bt):(w[nr]=bt,C[nr]=ct-bt)}this.adjustOddEvenCounts(l);let b=4*t.getValue()+(n?0:2)+(i?0:1)-1,S=0,T=0;for(let Be=g.length-1;Be>=0;Be--){if(X.isNotA1left(t,n,i)){let ct=X.WEIGHTS[b][2*Be];T+=g[Be]*ct}S+=g[Be]}let D=0;for(let Be=w.length-1;Be>=0;Be--)if(X.isNotA1left(t,n,i)){let ct=X.WEIGHTS[b][2*Be+1];D+=w[Be]*ct}let F=T+D;if((S&1)!=0||S>13||S<4)throw new M;let Z=(13-S)/2,Q=X.SYMBOL_WIDEST[Z],j=9-Q,we=Zt.getRSSvalue(g,Q,!0),he=Zt.getRSSvalue(w,j,!1),mt=X.EVEN_TOTAL_SUBSET[Z],Gt=X.GSUM[Z],Ct=we*mt+he+Gt;return new Qn(Ct,F)}static isNotA1left(e,t,n){return!(e.getValue()==0&&t&&n)}adjustOddEvenCounts(e){let t=Ce.sum(new Int32Array(this.getOddCounts())),n=Ce.sum(new Int32Array(this.getEvenCounts())),i=!1,o=!1;t>13?o=!0:t<4&&(i=!0);let l=!1,c=!1;n>13?c=!0:n<4&&(l=!0);let u=t+n-e,g=(t&1)==1,w=(n&1)==0;if(u==1)if(g){if(w)throw new M;o=!0}else{if(!w)throw new M;c=!0}else if(u==-1)if(g){if(w)throw new M;i=!0}else{if(!w)throw new M;l=!0}else if(u==0){if(g){if(!w)throw new M;t1){for(let c of this.possibleRightPairs)if(c.getCount()>1&&Ge.checkChecksum(l,c))return Ge.constructResult(l,c)}throw new M}static addOrTally(e,t){if(t==null)return;let n=!1;for(let i of e)if(i.getValue()===t.getValue()){i.incrementCount(),n=!0;break}n||e.push(t)}reset(){this.possibleLeftPairs.length=0,this.possibleRightPairs.length=0}static constructResult(e,t){let n=4537077*e.getValue()+t.getValue(),i=new String(n).toString(),o=new G;for(let g=13-i.length;g>0;g--)o.append("0");o.append(i);let l=0;for(let g=0;g<13;g++){let w=o.charAt(g).charCodeAt(0)-48;l+=(g&1)===0?3*w:w}l=10-l%10,l===10&&(l=0),o.append(l.toString());let c=e.getFinderPattern().getResultPoints(),u=t.getFinderPattern().getResultPoints();return new Ye(o.toString(),null,0,[c[0],c[1],u[0],u[1]],oe.RSS_14,new Date().getTime())}static checkChecksum(e,t){let n=(e.getChecksumPortion()+16*t.getChecksumPortion())%79,i=9*e.getFinderPattern().getValue()+t.getFinderPattern().getValue();return i>72&&i--,i>8&&i--,n===i}decodePair(e,t,n,i){try{let o=this.findFinderPattern(e,t),l=this.parseFoundFinderPattern(e,n,t,o),c=i==null?null:i.get(z.NEED_RESULT_POINT_CALLBACK);if(c!=null){let w=(o[0]+o[1])/2;t&&(w=e.getSize()-1-w),c.foundPossibleResultPoint(new ie(w,n))}let u=this.decodeDataCharacter(e,l,!0),g=this.decodeDataCharacter(e,l,!1);return new O1(1597*u.getValue()+g.getValue(),u.getChecksumPortion()+4*g.getChecksumPortion(),l)}catch{return null}}decodeDataCharacter(e,t,n){let i=this.getDataCharacterCounters();for(let D=0;D8&&(Z=8);let Q=Math.floor(D/2);(D&1)===0?(c[Q]=Z,g[Q]=F-Z):(u[Q]=Z,w[Q]=F-Z)}this.adjustOddEvenCounts(n,o);let m=0,C=0;for(let D=c.length-1;D>=0;D--)C*=9,C+=c[D],m+=c[D];let b=0,S=0;for(let D=u.length-1;D>=0;D--)b*=9,b+=u[D],S+=u[D];let T=C+3*b;if(n){if((m&1)!==0||m>12||m<4)throw new M;let D=(12-m)/2,F=Ge.OUTSIDE_ODD_WIDEST[D],Z=9-F,Q=Zt.getRSSvalue(c,F,!1),j=Zt.getRSSvalue(u,Z,!0),we=Ge.OUTSIDE_EVEN_TOTAL_SUBSET[D],he=Ge.OUTSIDE_GSUM[D];return new Qn(Q*we+j+he,T)}else{if((S&1)!==0||S>10||S<4)throw new M;let D=(10-S)/2,F=Ge.INSIDE_ODD_WIDEST[D],Z=9-F,Q=Zt.getRSSvalue(c,F,!0),j=Zt.getRSSvalue(u,Z,!1),we=Ge.INSIDE_ODD_TOTAL_SUBSET[D],he=Ge.INSIDE_GSUM[D];return new Qn(j*we+Q+he,T)}}findFinderPattern(e,t){let n=this.getDecodeFinderCounters();n[0]=0,n[1]=0,n[2]=0,n[3]=0;let i=e.getSize(),o=!1,l=0;for(;l=0&&o!==e.get(l);)l--;l++;let c=i[0]-l,u=this.getDecodeFinderCounters(),g=new Int32Array(u.length);N.arraycopy(u,0,g,1,u.length-1),g[0]=c;let w=this.parseFinderValue(g,Ge.FINDER_PATTERNS),m=l,C=i[1];return n&&(m=e.getSize()-1-m,C=e.getSize()-1-C),new xi(w,[l,i[1]],m,C,t)}adjustOddEvenCounts(e,t){let n=Ce.sum(new Int32Array(this.getOddCounts())),i=Ce.sum(new Int32Array(this.getEvenCounts())),o=!1,l=!1,c=!1,u=!1;e?(n>12?l=!0:n<4&&(o=!0),i>12?u=!0:i<4&&(c=!0)):(n>11?l=!0:n<5&&(o=!0),i>10?u=!0:i<4&&(c=!0));let g=n+i-t,w=(n&1)===(e?1:0),m=(i&1)===1;if(g===1)if(w){if(m)throw new M;l=!0}else{if(!m)throw new M;u=!0}else if(g===-1)if(w){if(m)throw new M;o=!0}else{if(!m)throw new M;c=!0}else if(g===0){if(w){if(!m)throw new M;ne.reset())}}class R1 extends Ht{constructor(e=500,t){super(new Jn(t),e,t)}}class Ne{constructor(e,t,n){this.ecCodewords=e,this.ecBlocks=[t],n&&this.ecBlocks.push(n)}getECCodewords(){return this.ecCodewords}getECBlocks(){return this.ecBlocks}}class be{constructor(e,t){this.count=e,this.dataCodewords=t}getCount(){return this.count}getDataCodewords(){return this.dataCodewords}}class pe{constructor(e,t,n,i,o,l){this.versionNumber=e,this.symbolSizeRows=t,this.symbolSizeColumns=n,this.dataRegionSizeRows=i,this.dataRegionSizeColumns=o,this.ecBlocks=l;let c=0,u=l.getECCodewords(),g=l.getECBlocks();for(let w of g)c+=w.getCount()*(w.getDataCodewords()+u);this.totalCodewords=c}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)!==0||(t&1)!==0)throw new L;for(let n of pe.VERSIONS)if(n.symbolSizeRows===e&&n.symbolSizeColumns===t)return n;throw new L}toString(){return""+this.versionNumber}static buildVersions(){return[new pe(1,10,10,8,8,new Ne(5,new be(1,3))),new pe(2,12,12,10,10,new Ne(7,new be(1,5))),new pe(3,14,14,12,12,new Ne(10,new be(1,8))),new pe(4,16,16,14,14,new Ne(12,new be(1,12))),new pe(5,18,18,16,16,new Ne(14,new be(1,18))),new pe(6,20,20,18,18,new Ne(18,new be(1,22))),new pe(7,22,22,20,20,new Ne(20,new be(1,30))),new pe(8,24,24,22,22,new Ne(24,new be(1,36))),new pe(9,26,26,24,24,new Ne(28,new be(1,44))),new pe(10,32,32,14,14,new Ne(36,new be(1,62))),new pe(11,36,36,16,16,new Ne(42,new be(1,86))),new pe(12,40,40,18,18,new Ne(48,new be(1,114))),new pe(13,44,44,20,20,new Ne(56,new be(1,144))),new pe(14,48,48,22,22,new Ne(68,new be(1,174))),new pe(15,52,52,24,24,new Ne(42,new be(2,102))),new pe(16,64,64,14,14,new Ne(56,new be(2,140))),new pe(17,72,72,16,16,new Ne(36,new be(4,92))),new pe(18,80,80,18,18,new Ne(48,new be(4,114))),new pe(19,88,88,20,20,new Ne(56,new be(4,144))),new pe(20,96,96,22,22,new Ne(68,new be(4,174))),new pe(21,104,104,24,24,new Ne(56,new be(6,136))),new pe(22,120,120,18,18,new Ne(68,new be(6,175))),new pe(23,132,132,20,20,new Ne(62,new be(8,163))),new pe(24,144,144,22,22,new Ne(62,new be(8,156),new be(2,155))),new pe(25,8,18,6,16,new Ne(7,new be(1,5))),new pe(26,8,32,6,14,new Ne(11,new be(1,10))),new pe(27,12,26,10,24,new Ne(14,new be(1,16))),new pe(28,12,36,10,16,new Ne(18,new be(1,22))),new pe(29,16,36,14,16,new Ne(24,new be(1,32))),new pe(30,16,48,14,22,new Ne(28,new be(1,49)))]}}pe.VERSIONS=pe.buildVersions();class gs{constructor(e){let t=e.getHeight();if(t<8||t>144||(t&1)!==0)throw new L;this.version=gs.readVersion(e),this.mappingBitMatrix=this.extractDataRegion(e),this.readMappingMatrix=new $(this.mappingBitMatrix.getWidth(),this.mappingBitMatrix.getHeight())}getVersion(){return this.version}static readVersion(e){let t=e.getHeight(),n=e.getWidth();return pe.getVersionForDimensions(t,n)}readCodewords(){let e=new Int8Array(this.version.getTotalCodewords()),t=0,n=4,i=0,o=this.mappingBitMatrix.getHeight(),l=this.mappingBitMatrix.getWidth(),c=!1,u=!1,g=!1,w=!1;do if(n===o&&i===0&&!c)e[t++]=this.readCorner1(o,l)&255,n-=2,i+=2,c=!0;else if(n===o-2&&i===0&&(l&3)!==0&&!u)e[t++]=this.readCorner2(o,l)&255,n-=2,i+=2,u=!0;else if(n===o+4&&i===2&&(l&7)===0&&!g)e[t++]=this.readCorner3(o,l)&255,n-=2,i+=2,g=!0;else if(n===o-2&&i===0&&(l&7)===4&&!w)e[t++]=this.readCorner4(o,l)&255,n-=2,i+=2,w=!0;else{do n=0&&!this.readMappingMatrix.get(i,n)&&(e[t++]=this.readUtah(n,i,o,l)&255),n-=2,i+=2;while(n>=0&&i=0&&i=0);n+=3,i+=1}while(n7?T-1:T;l[F].codewords[Z]=e[m++]}if(m!==e.length)throw new x;return l}getNumDataCodewords(){return this.numDataCodewords}getCodewords(){return this.codewords}}class ws{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 x(""+e);let t=0,n=this.bitOffset,i=this.byteOffset,o=this.bytes;if(n>0){let l=8-n,c=e>8-c<>u,e-=c,n+=c,n===8&&(n=0,i++)}if(e>0){for(;e>=8;)t=t<<8|o[i]&255,i++,e-=8;if(e>0){let l=8-e,c=255>>l<>l,n+=e}}return this.bitOffset=n,this.byteOffset=i,t}available(){return 8*(this.bytes.length-this.byteOffset)-this.bitOffset}}var qe;(function(E){E[E.PAD_ENCODE=0]="PAD_ENCODE",E[E.ASCII_ENCODE=1]="ASCII_ENCODE",E[E.C40_ENCODE=2]="C40_ENCODE",E[E.TEXT_ENCODE=3]="TEXT_ENCODE",E[E.ANSIX12_ENCODE=4]="ANSIX12_ENCODE",E[E.EDIFACT_ENCODE=5]="EDIFACT_ENCODE",E[E.BASE256_ENCODE=6]="BASE256_ENCODE"})(qe||(qe={}));class gn{static decode(e){let t=new ws(e),n=new G,i=new G,o=new Array,l=qe.ASCII_ENCODE;do if(l===qe.ASCII_ENCODE)l=this.decodeAsciiSegment(t,n,i);else{switch(l){case qe.C40_ENCODE:this.decodeC40Segment(t,n);break;case qe.TEXT_ENCODE:this.decodeTextSegment(t,n);break;case qe.ANSIX12_ENCODE:this.decodeAnsiX12Segment(t,n);break;case qe.EDIFACT_ENCODE:this.decodeEdifactSegment(t,n);break;case qe.BASE256_ENCODE:this.decodeBase256Segment(t,n,o);break;default:throw new L}l=qe.ASCII_ENCODE}while(l!==qe.PAD_ENCODE&&t.available()>0);return i.length()>0&&n.append(i.toString()),new _r(e,n.toString(),o.length===0?null:o,null)}static decodeAsciiSegment(e,t,n){let i=!1;do{let o=e.readBits(8);if(o===0)throw new L;if(o<=128)return i&&(o+=128),t.append(String.fromCharCode(o-1)),qe.ASCII_ENCODE;if(o===129)return qe.PAD_ENCODE;if(o<=229){let l=o-130;l<10&&t.append("0"),t.append(""+l)}else switch(o){case 230:return qe.C40_ENCODE;case 231:return qe.BASE256_ENCODE;case 232:t.append("");break;case 233:case 234:break;case 235:i=!0;break;case 236:t.append("[)>05"),n.insert(0,"");break;case 237:t.append("[)>06"),n.insert(0,"");break;case 238:return qe.ANSIX12_ENCODE;case 239:return qe.TEXT_ENCODE;case 240:return qe.EDIFACT_ENCODE;case 241:break;default:if(o!==254||e.available()!==0)throw new L;break}}while(e.available()>0);return qe.ASCII_ENCODE}static decodeC40Segment(e,t){let n=!1,i=[],o=0;do{if(e.available()===8)return;let l=e.readBits(8);if(l===254)return;this.parseTwoBytes(l,e.readBits(8),i);for(let c=0;c<3;c++){let u=i[c];switch(o){case 0:if(u<3)o=u+1;else if(u0)}static decodeTextSegment(e,t){let n=!1,i=[],o=0;do{if(e.available()===8)return;let l=e.readBits(8);if(l===254)return;this.parseTwoBytes(l,e.readBits(8),i);for(let c=0;c<3;c++){let u=i[c];switch(o){case 0:if(u<3)o=u+1;else if(u0)}static decodeAnsiX12Segment(e,t){let n=[];do{if(e.available()===8)return;let i=e.readBits(8);if(i===254)return;this.parseTwoBytes(i,e.readBits(8),n);for(let o=0;o<3;o++){let l=n[o];switch(l){case 0:t.append("\r");break;case 1:t.append("*");break;case 2:t.append(">");break;case 3:t.append(" ");break;default:if(l<14)t.append(String.fromCharCode(l+44));else if(l<40)t.append(String.fromCharCode(l+51));else throw new L;break}}}while(e.available()>0)}static parseTwoBytes(e,t,n){let i=(e<<8)+t-1,o=Math.floor(i/1600);n[0]=o,i-=o*1600,o=Math.floor(i/40),n[1]=o,n[2]=i-o*40}static decodeEdifactSegment(e,t){do{if(e.available()<=16)return;for(let n=0;n<4;n++){let i=e.readBits(6);if(i===31){let o=8-e.getBitOffset();o!==8&&e.readBits(o);return}(i&32)===0&&(i|=64),t.append(String.fromCharCode(i))}}while(e.available()>0)}static decodeBase256Segment(e,t,n){let i=1+e.getByteOffset(),o=this.unrandomize255State(e.readBits(8),i++),l;if(o===0?l=e.available()/8|0:o<250?l=o:l=250*(o-249)+this.unrandomize255State(e.readBits(8),i++),l<0)throw new L;let c=new Uint8Array(l);for(let u=0;u=0?i:i+256}}gn.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"],gn.C40_SHIFT2_SET_CHARS=["!",'"',"#","$","%","&","'","(",")","*","+",",","-",".","/",":",";","<","=",">","?","@","[","\\","]","^","_"],gn.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"],gn.TEXT_SHIFT2_SET_CHARS=gn.C40_SHIFT2_SET_CHARS,gn.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","{","|","}","~","\x7F"];class D1{constructor(){this.rsDecoder=new Ir(ye.DATA_MATRIX_FIELD_256)}decode(e){let t=new gs(e),n=t.getVersion(),i=t.readCodewords(),o=xs.getDataBlocks(i,n),l=0;for(let g of o)l+=g.getNumDataCodewords();let c=new Uint8Array(l),u=o.length;for(let g=0;gc&&(w=c,m[0]=t,m[1]=n,m[2]=i,m[3]=o),w>u&&(w=u,m[0]=n,m[1]=i,m[2]=o,m[3]=t),w>g&&(m[0]=i,m[1]=o,m[2]=t,m[3]=n),m}detectSolid2(e){let t=e[0],n=e[1],i=e[2],o=e[3],l=this.transitionsBetween(t,o),c=We.shiftPoint(n,i,(l+1)*4),u=We.shiftPoint(i,n,(l+1)*4),g=this.transitionsBetween(c,t),w=this.transitionsBetween(u,o);return gb?w:m}shiftToModuleCenter(e){let t=e[0],n=e[1],i=e[2],o=e[3],l=this.transitionsBetween(t,o)+1,c=this.transitionsBetween(i,o)+1,u=We.shiftPoint(t,n,c*4),g=We.shiftPoint(i,n,l*4);l=this.transitionsBetween(u,o)+1,c=this.transitionsBetween(g,o)+1,(l&1)===1&&(l+=1),(c&1)===1&&(c+=1);let w=(t.getX()+n.getX()+i.getX()+o.getX())/4,m=(t.getY()+n.getY()+i.getY()+o.getY())/4;t=We.moveAway(t,w,m),n=We.moveAway(n,w,m),i=We.moveAway(i,w,m),o=We.moveAway(o,w,m);let C,b;return u=We.shiftPoint(t,n,c*4),u=We.shiftPoint(u,o,l*4),C=We.shiftPoint(n,t,c*4),C=We.shiftPoint(C,i,l*4),g=We.shiftPoint(i,o,c*4),g=We.shiftPoint(g,n,l*4),b=We.shiftPoint(o,i,c*4),b=We.shiftPoint(b,t,l*4),[u,C,g,b]}isValid(e){return e.getX()>=0&&e.getX()0&&e.getY()Math.abs(o-n);if(c){let T=n;n=i,i=T,T=o,o=l,l=T}let u=Math.abs(o-n),g=Math.abs(l-i),w=-u/2,m=i0){if(D===l)break;D+=m,w-=u}}return b}}class xn{constructor(){this.decoder=new D1}decode(e,t=null){let n,i;if(t!=null&&t.has(z.PURE_BARCODE)){let g=xn.extractPureBits(e.getBlackMatrix());n=this.decoder.decode(g),i=xn.NO_POINTS}else{let g=new We(e.getBlackMatrix()).detect();n=this.decoder.decode(g.getBits()),i=g.getPoints()}let o=n.getRawBytes(),l=new Ye(n.getText(),o,8*o.length,i,oe.DATA_MATRIX,N.currentTimeMillis()),c=n.getByteSegments();c!=null&&l.putMetadata(et.BYTE_SEGMENTS,c);let u=n.getECLevel();return u!=null&&l.putMetadata(et.ERROR_CORRECTION_LEVEL,u),l}reset(){}static extractPureBits(e){let t=e.getTopLeftOnBit(),n=e.getBottomRightOnBit();if(t==null||n==null)throw new M;let i=this.moduleSize(t,e),o=t[1],l=n[1],c=t[0],g=(n[0]-c+1)/i,w=(l-o+1)/i;if(g<=0||w<=0)throw new M;let m=i/2;o+=m,c+=m;let C=new $(g,w);for(let b=0;b=ke.FOR_BITS.size)throw new x;return ke.FOR_BITS.get(e)}}ke.FOR_BITS=new Map,ke.FOR_VALUE=new Map,ke.L=new ke($n.L,"L",1),ke.M=new ke($n.M,"M",0),ke.Q=new ke($n.Q,"Q",3),ke.H=new ke($n.H,"H",2);class ht{constructor(e){this.errorCorrectionLevel=ke.forBits(e>>3&3),this.dataMask=e&7}static numBitsDiffering(e,t){return U.bitCount(e^t)}static decodeFormatInformation(e,t){let n=ht.doDecodeFormatInformation(e,t);return n!==null?n:ht.doDecodeFormatInformation(e^ht.FORMAT_INFO_MASK_QR,t^ht.FORMAT_INFO_MASK_QR)}static doDecodeFormatInformation(e,t){let n=Number.MAX_SAFE_INTEGER,i=0;for(let o of ht.FORMAT_INFO_DECODE_LOOKUP){let l=o[0];if(l===e||l===t)return new ht(o[1]);let c=ht.numBitsDiffering(e,l);c40)throw new x;return se.VERSIONS[e-1]}static decodeVersionInformation(e){let t=Number.MAX_SAFE_INTEGER,n=0;for(let i=0;i6&&(t.setRegion(e-11,0,3,6),t.setRegion(0,e-11,6,3)),t}toString(){return""+this.versionNumber}}se.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]),se.VERSIONS=[new se(1,new Int32Array(0),new B(7,new I(1,19)),new B(10,new I(1,16)),new B(13,new I(1,13)),new B(17,new I(1,9))),new se(2,Int32Array.from([6,18]),new B(10,new I(1,34)),new B(16,new I(1,28)),new B(22,new I(1,22)),new B(28,new I(1,16))),new se(3,Int32Array.from([6,22]),new B(15,new I(1,55)),new B(26,new I(1,44)),new B(18,new I(2,17)),new B(22,new I(2,13))),new se(4,Int32Array.from([6,26]),new B(20,new I(1,80)),new B(18,new I(2,32)),new B(26,new I(2,24)),new B(16,new I(4,9))),new se(5,Int32Array.from([6,30]),new B(26,new I(1,108)),new B(24,new I(2,43)),new B(18,new I(2,15),new I(2,16)),new B(22,new I(2,11),new I(2,12))),new se(6,Int32Array.from([6,34]),new B(18,new I(2,68)),new B(16,new I(4,27)),new B(24,new I(4,19)),new B(28,new I(4,15))),new se(7,Int32Array.from([6,22,38]),new B(20,new I(2,78)),new B(18,new I(4,31)),new B(18,new I(2,14),new I(4,15)),new B(26,new I(4,13),new I(1,14))),new se(8,Int32Array.from([6,24,42]),new B(24,new I(2,97)),new B(22,new I(2,38),new I(2,39)),new B(22,new I(4,18),new I(2,19)),new B(26,new I(4,14),new I(2,15))),new se(9,Int32Array.from([6,26,46]),new B(30,new I(2,116)),new B(22,new I(3,36),new I(2,37)),new B(20,new I(4,16),new I(4,17)),new B(24,new I(4,12),new I(4,13))),new se(10,Int32Array.from([6,28,50]),new B(18,new I(2,68),new I(2,69)),new B(26,new I(4,43),new I(1,44)),new B(24,new I(6,19),new I(2,20)),new B(28,new I(6,15),new I(2,16))),new se(11,Int32Array.from([6,30,54]),new B(20,new I(4,81)),new B(30,new I(1,50),new I(4,51)),new B(28,new I(4,22),new I(4,23)),new B(24,new I(3,12),new I(8,13))),new se(12,Int32Array.from([6,32,58]),new B(24,new I(2,92),new I(2,93)),new B(22,new I(6,36),new I(2,37)),new B(26,new I(4,20),new I(6,21)),new B(28,new I(7,14),new I(4,15))),new se(13,Int32Array.from([6,34,62]),new B(26,new I(4,107)),new B(22,new I(8,37),new I(1,38)),new B(24,new I(8,20),new I(4,21)),new B(22,new I(12,11),new I(4,12))),new se(14,Int32Array.from([6,26,46,66]),new B(30,new I(3,115),new I(1,116)),new B(24,new I(4,40),new I(5,41)),new B(20,new I(11,16),new I(5,17)),new B(24,new I(11,12),new I(5,13))),new se(15,Int32Array.from([6,26,48,70]),new B(22,new I(5,87),new I(1,88)),new B(24,new I(5,41),new I(5,42)),new B(30,new I(5,24),new I(7,25)),new B(24,new I(11,12),new I(7,13))),new se(16,Int32Array.from([6,26,50,74]),new B(24,new I(5,98),new I(1,99)),new B(28,new I(7,45),new I(3,46)),new B(24,new I(15,19),new I(2,20)),new B(30,new I(3,15),new I(13,16))),new se(17,Int32Array.from([6,30,54,78]),new B(28,new I(1,107),new I(5,108)),new B(28,new I(10,46),new I(1,47)),new B(28,new I(1,22),new I(15,23)),new B(28,new I(2,14),new I(17,15))),new se(18,Int32Array.from([6,30,56,82]),new B(30,new I(5,120),new I(1,121)),new B(26,new I(9,43),new I(4,44)),new B(28,new I(17,22),new I(1,23)),new B(28,new I(2,14),new I(19,15))),new se(19,Int32Array.from([6,30,58,86]),new B(28,new I(3,113),new I(4,114)),new B(26,new I(3,44),new I(11,45)),new B(26,new I(17,21),new I(4,22)),new B(26,new I(9,13),new I(16,14))),new se(20,Int32Array.from([6,34,62,90]),new B(28,new I(3,107),new I(5,108)),new B(26,new I(3,41),new I(13,42)),new B(30,new I(15,24),new I(5,25)),new B(28,new I(15,15),new I(10,16))),new se(21,Int32Array.from([6,28,50,72,94]),new B(28,new I(4,116),new I(4,117)),new B(26,new I(17,42)),new B(28,new I(17,22),new I(6,23)),new B(30,new I(19,16),new I(6,17))),new se(22,Int32Array.from([6,26,50,74,98]),new B(28,new I(2,111),new I(7,112)),new B(28,new I(17,46)),new B(30,new I(7,24),new I(16,25)),new B(24,new I(34,13))),new se(23,Int32Array.from([6,30,54,78,102]),new B(30,new I(4,121),new I(5,122)),new B(28,new I(4,47),new I(14,48)),new B(30,new I(11,24),new I(14,25)),new B(30,new I(16,15),new I(14,16))),new se(24,Int32Array.from([6,28,54,80,106]),new B(30,new I(6,117),new I(4,118)),new B(28,new I(6,45),new I(14,46)),new B(30,new I(11,24),new I(16,25)),new B(30,new I(30,16),new I(2,17))),new se(25,Int32Array.from([6,32,58,84,110]),new B(26,new I(8,106),new I(4,107)),new B(28,new I(8,47),new I(13,48)),new B(30,new I(7,24),new I(22,25)),new B(30,new I(22,15),new I(13,16))),new se(26,Int32Array.from([6,30,58,86,114]),new B(28,new I(10,114),new I(2,115)),new B(28,new I(19,46),new I(4,47)),new B(28,new I(28,22),new I(6,23)),new B(30,new I(33,16),new I(4,17))),new se(27,Int32Array.from([6,34,62,90,118]),new B(30,new I(8,122),new I(4,123)),new B(28,new I(22,45),new I(3,46)),new B(30,new I(8,23),new I(26,24)),new B(30,new I(12,15),new I(28,16))),new se(28,Int32Array.from([6,26,50,74,98,122]),new B(30,new I(3,117),new I(10,118)),new B(28,new I(3,45),new I(23,46)),new B(30,new I(4,24),new I(31,25)),new B(30,new I(11,15),new I(31,16))),new se(29,Int32Array.from([6,30,54,78,102,126]),new B(30,new I(7,116),new I(7,117)),new B(28,new I(21,45),new I(7,46)),new B(30,new I(1,23),new I(37,24)),new B(30,new I(19,15),new I(26,16))),new se(30,Int32Array.from([6,26,52,78,104,130]),new B(30,new I(5,115),new I(10,116)),new B(28,new I(19,47),new I(10,48)),new B(30,new I(15,24),new I(25,25)),new B(30,new I(23,15),new I(25,16))),new se(31,Int32Array.from([6,30,56,82,108,134]),new B(30,new I(13,115),new I(3,116)),new B(28,new I(2,46),new I(29,47)),new B(30,new I(42,24),new I(1,25)),new B(30,new I(23,15),new I(28,16))),new se(32,Int32Array.from([6,34,60,86,112,138]),new B(30,new I(17,115)),new B(28,new I(10,46),new I(23,47)),new B(30,new I(10,24),new I(35,25)),new B(30,new I(19,15),new I(35,16))),new se(33,Int32Array.from([6,30,58,86,114,142]),new B(30,new I(17,115),new I(1,116)),new B(28,new I(14,46),new I(21,47)),new B(30,new I(29,24),new I(19,25)),new B(30,new I(11,15),new I(46,16))),new se(34,Int32Array.from([6,34,62,90,118,146]),new B(30,new I(13,115),new I(6,116)),new B(28,new I(14,46),new I(23,47)),new B(30,new I(44,24),new I(7,25)),new B(30,new I(59,16),new I(1,17))),new se(35,Int32Array.from([6,30,54,78,102,126,150]),new B(30,new I(12,121),new I(7,122)),new B(28,new I(12,47),new I(26,48)),new B(30,new I(39,24),new I(14,25)),new B(30,new I(22,15),new I(41,16))),new se(36,Int32Array.from([6,24,50,76,102,128,154]),new B(30,new I(6,121),new I(14,122)),new B(28,new I(6,47),new I(34,48)),new B(30,new I(46,24),new I(10,25)),new B(30,new I(2,15),new I(64,16))),new se(37,Int32Array.from([6,28,54,80,106,132,158]),new B(30,new I(17,122),new I(4,123)),new B(28,new I(29,46),new I(14,47)),new B(30,new I(49,24),new I(10,25)),new B(30,new I(24,15),new I(46,16))),new se(38,Int32Array.from([6,32,58,84,110,136,162]),new B(30,new I(4,122),new I(18,123)),new B(28,new I(13,46),new I(32,47)),new B(30,new I(48,24),new I(14,25)),new B(30,new I(42,15),new I(32,16))),new se(39,Int32Array.from([6,26,54,82,110,138,166]),new B(30,new I(20,117),new I(4,118)),new B(28,new I(40,47),new I(7,48)),new B(30,new I(43,24),new I(22,25)),new B(30,new I(10,15),new I(67,16))),new se(40,Int32Array.from([6,30,58,86,114,142,170]),new B(30,new I(19,118),new I(6,119)),new B(28,new I(18,47),new I(31,48)),new B(30,new I(34,24),new I(34,25)),new B(30,new I(20,15),new I(61,16)))];var tt;(function(E){E[E.DATA_MASK_000=0]="DATA_MASK_000",E[E.DATA_MASK_001=1]="DATA_MASK_001",E[E.DATA_MASK_010=2]="DATA_MASK_010",E[E.DATA_MASK_011=3]="DATA_MASK_011",E[E.DATA_MASK_100=4]="DATA_MASK_100",E[E.DATA_MASK_101=5]="DATA_MASK_101",E[E.DATA_MASK_110=6]="DATA_MASK_110",E[E.DATA_MASK_111=7]="DATA_MASK_111"})(tt||(tt={}));class Dt{constructor(e,t){this.value=e,this.isMasked=t}unmaskBitMatrix(e,t){for(let n=0;n(E+e&1)===0)],[tt.DATA_MASK_001,new Dt(tt.DATA_MASK_001,(E,e)=>(E&1)===0)],[tt.DATA_MASK_010,new Dt(tt.DATA_MASK_010,(E,e)=>e%3===0)],[tt.DATA_MASK_011,new Dt(tt.DATA_MASK_011,(E,e)=>(E+e)%3===0)],[tt.DATA_MASK_100,new Dt(tt.DATA_MASK_100,(E,e)=>(Math.floor(E/2)+Math.floor(e/3)&1)===0)],[tt.DATA_MASK_101,new Dt(tt.DATA_MASK_101,(E,e)=>E*e%6===0)],[tt.DATA_MASK_110,new Dt(tt.DATA_MASK_110,(E,e)=>E*e%6<3)],[tt.DATA_MASK_111,new Dt(tt.DATA_MASK_111,(E,e)=>(E+e+E*e%3&1)===0)]]);class B1{constructor(e){let t=e.getHeight();if(t<21||(t&3)!==1)throw new L;this.bitMatrix=e}readFormatInformation(){if(this.parsedFormatInfo!==null&&this.parsedFormatInfo!==void 0)return this.parsedFormatInfo;let e=0;for(let o=0;o<6;o++)e=this.copyBit(o,8,e);e=this.copyBit(7,8,e),e=this.copyBit(8,8,e),e=this.copyBit(8,7,e);for(let o=5;o>=0;o--)e=this.copyBit(8,o,e);let t=this.bitMatrix.getHeight(),n=0,i=t-7;for(let o=t-1;o>=i;o--)n=this.copyBit(8,o,n);for(let o=t-8;o=0;l--)for(let c=e-9;c>=i;c--)n=this.copyBit(c,l,n);let o=se.decodeVersionInformation(n);if(o!==null&&o.getDimensionForVersion()===e)return this.parsedVersion=o,o;n=0;for(let l=5;l>=0;l--)for(let c=e-9;c>=i;c--)n=this.copyBit(l,c,n);if(o=se.decodeVersionInformation(n),o!==null&&o.getDimensionForVersion()===e)return this.parsedVersion=o,o;throw new L}copyBit(e,t,n){return(this.isMirror?this.bitMatrix.get(t,e):this.bitMatrix.get(e,t))?n<<1|1:n<<1}readCodewords(){let e=this.readFormatInformation(),t=this.readVersion(),n=Dt.values.get(e.getDataMask()),i=this.bitMatrix.getHeight();n.unmaskBitMatrix(this.bitMatrix,i);let o=t.buildFunctionPattern(),l=!0,c=new Uint8Array(t.getTotalCodewords()),u=0,g=0,w=0;for(let m=i-1;m>0;m-=2){m===6&&m--;for(let C=0;C=0&&c[w].codewords.length!==g;)w--;w++;let m=g-i.getECCodewordsPerBlock(),C=0;for(let S=0;Se.available())throw new L;let i=new Uint8Array(2*n),o=0;for(;n>0;){let l=e.readBits(13),c=l/96<<8&4294967295|l%96;c<959?c+=41377:c+=42657,i[o]=c>>8&255,i[o+1]=c&255,o+=2,n--}try{t.append(re.decode(i,k.GB2312))}catch(l){throw new L(l)}}static decodeKanjiSegment(e,t,n){if(n*13>e.available())throw new L;let i=new Uint8Array(2*n),o=0;for(;n>0;){let l=e.readBits(13),c=l/192<<8&4294967295|l%192;c<7936?c+=33088:c+=49472,i[o]=c>>8,i[o+1]=c,o+=2,n--}try{t.append(re.decode(i,k.SHIFT_JIS))}catch(l){throw new L(l)}}static decodeByteSegment(e,t,n,i,o,l){if(8*n>e.available())throw new L;let c=new Uint8Array(n);for(let g=0;g=Ve.ALPHANUMERIC_CHARS.length)throw new L;return Ve.ALPHANUMERIC_CHARS[e]}static decodeAlphanumericSegment(e,t,n,i){let o=t.length();for(;n>1;){if(e.available()<11)throw new L;let l=e.readBits(11);t.append(Ve.toAlphaNumericChar(Math.floor(l/45))),t.append(Ve.toAlphaNumericChar(l%45)),n-=2}if(n===1){if(e.available()<6)throw new L;t.append(Ve.toAlphaNumericChar(e.readBits(6)))}if(i)for(let l=o;l=3;){if(e.available()<10)throw new L;let i=e.readBits(10);if(i>=1e3)throw new L;t.append(Ve.toAlphaNumericChar(Math.floor(i/100))),t.append(Ve.toAlphaNumericChar(Math.floor(i/10)%10)),t.append(Ve.toAlphaNumericChar(i%10)),n-=3}if(n===2){if(e.available()<7)throw new L;let i=e.readBits(7);if(i>=100)throw new L;t.append(Ve.toAlphaNumericChar(Math.floor(i/10))),t.append(Ve.toAlphaNumericChar(i%10))}else if(n===1){if(e.available()<4)throw new L;let i=e.readBits(4);if(i>=10)throw new L;t.append(Ve.toAlphaNumericChar(i))}}static parseECIValue(e){let t=e.readBits(8);if((t&128)===0)return t&127;if((t&192)===128){let n=e.readBits(8);return(t&63)<<8&4294967295|n}if((t&224)===192){let n=e.readBits(16);return(t&31)<<16&4294967295|n}throw new L}}Ve.ALPHANUMERIC_CHARS="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:",Ve.GB2312_SUBSET=1;class Ko{constructor(e){this.mirrored=e}isMirrored(){return this.mirrored}applyMirroredCorrection(e){if(!this.mirrored||e===null||e.length<3)return;let t=e[0];e[0]=e[2],e[2]=t}}class L1{constructor(){this.rsDecoder=new Ir(ye.QR_CODE_FIELD_256)}decodeBooleanArray(e,t){return this.decodeBitMatrix($.parseFromBooleanArray(e),t)}decodeBitMatrix(e,t){let n=new B1(e),i=null;try{return this.decodeBitMatrixParser(n,t)}catch(o){i=o}try{n.remask(),n.setMirror(!0),n.readVersion(),n.readFormatInformation(),n.mirror();let o=this.decodeBitMatrixParser(n,t);return o.setOther(new Ko(!0)),o}catch(o){throw i!==null?i:o}}decodeBitMatrixParser(e,t){let n=e.readVersion(),i=e.readFormatInformation().getErrorCorrectionLevel(),o=e.readCodewords(),l=ps.getDataBlocks(o,n,i),c=0;for(let w of l)c+=w.getNumDataCodewords();let u=new Uint8Array(c),g=0;for(let w of l){let m=w.getCodewords(),C=w.getNumDataCodewords();this.correctErrors(m,C);for(let b=0;b=n)return!1;return!0}crossCheckVertical(e,t,n,i){let o=this.image,l=o.getHeight(),c=this.crossCheckStateCount;c[0]=0,c[1]=0,c[2]=0;let u=e;for(;u>=0&&o.get(t,u)&&c[1]<=n;)c[1]++,u--;if(u<0||c[1]>n)return NaN;for(;u>=0&&!o.get(t,u)&&c[0]<=n;)c[0]++,u--;if(c[0]>n)return NaN;for(u=e+1;un)return NaN;for(;un)return NaN;let g=c[0]+c[1]+c[2];return 5*Math.abs(g-i)>=2*i?NaN:this.foundPatternCross(c)?Ai.centerFromEnd(c,u):NaN}handlePossibleCenter(e,t,n){let i=e[0]+e[1]+e[2],o=Ai.centerFromEnd(e,n),l=this.crossCheckVertical(t,o,2*e[1],i);if(!isNaN(l)){let c=(e[0]+e[1]+e[2])/3;for(let g of this.possibleCenters)if(g.aboutEquals(c,l,o))return g.combineEstimate(l,o,c);let u=new As(o,l,c);this.possibleCenters.push(u),this.resultPointCallback!==null&&this.resultPointCallback!==void 0&&this.resultPointCallback.foundPossibleResultPoint(u)}return null}}class Es extends ie{constructor(e,t,n,i){super(e,t),this.estimatedModuleSize=n,this.count=i,i===void 0&&(this.count=1)}getEstimatedModuleSize(){return this.estimatedModuleSize}getCount(){return this.count}aboutEquals(e,t,n){if(Math.abs(t-this.getY())<=e&&Math.abs(n-this.getX())<=e){let i=Math.abs(e-this.estimatedModuleSize);return i<=1||i<=this.estimatedModuleSize}return!1}combineEstimate(e,t,n){let i=this.count+1,o=(this.count*this.getX()+t)/i,l=(this.count*this.getY()+e)/i,c=(this.count*this.estimatedModuleSize+n)/i;return new Es(o,l,c,i)}}class k1{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 nt{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){let t=e!=null&&e.get(z.TRY_HARDER)!==void 0,n=e!=null&&e.get(z.PURE_BARCODE)!==void 0,i=this.image,o=i.getHeight(),l=i.getWidth(),c=Math.floor(3*o/(4*nt.MAX_MODULES));(cg[2]&&(m+=T-g[2]-c,b=l-1)}else{g[0]=g[2],g[1]=g[3],g[2]=g[4],g[3]=1,g[4]=0,C=3;continue}C=0,g[0]=0,g[1]=0,g[2]=0,g[3]=0,g[4]=0}else g[0]=g[2],g[1]=g[3],g[2]=g[4],g[3]=1,g[4]=0,C=3;else g[++C]++;else g[C]++;nt.foundPatternCross(g)&&this.handlePossibleCenter(g,m,l,n)===!0&&(c=g[0],this.hasSkipped&&(u=this.haveMultiplyConfirmedCenters()))}let w=this.selectBestPatterns();return ie.orderBestPatterns(w),new k1(w)}static centerFromEnd(e,t){return t-e[4]-e[3]-e[2]/2}static foundPatternCross(e){let t=0;for(let o=0;o<5;o++){let l=e[o];if(l===0)return!1;t+=l}if(t<7)return!1;let n=t/7,i=n/2;return Math.abs(n-e[0])=l&&t>=l&&c.get(t-l,e-l);)o[2]++,l++;if(e=l&&t>=l&&!c.get(t-l,e-l)&&o[1]<=n;)o[1]++,l++;if(en)return!1;for(;e>=l&&t>=l&&c.get(t-l,e-l)&&o[0]<=n;)o[0]++,l++;if(o[0]>n)return!1;let u=c.getHeight(),g=c.getWidth();for(l=1;e+l=u||t+l>=g)return!1;for(;e+l=u||t+l>=g||o[3]>=n)return!1;for(;e+l=n)return!1;let w=o[0]+o[1]+o[2]+o[3]+o[4];return Math.abs(w-i)<2*i&&nt.foundPatternCross(o)}crossCheckVertical(e,t,n,i){let o=this.image,l=o.getHeight(),c=this.getCrossCheckStateCount(),u=e;for(;u>=0&&o.get(t,u);)c[2]++,u--;if(u<0)return NaN;for(;u>=0&&!o.get(t,u)&&c[1]<=n;)c[1]++,u--;if(u<0||c[1]>n)return NaN;for(;u>=0&&o.get(t,u)&&c[0]<=n;)c[0]++,u--;if(c[0]>n)return NaN;for(u=e+1;u=n)return NaN;for(;u=n)return NaN;let g=c[0]+c[1]+c[2]+c[3]+c[4];return 5*Math.abs(g-i)>=2*i?NaN:nt.foundPatternCross(c)?nt.centerFromEnd(c,u):NaN}crossCheckHorizontal(e,t,n,i){let o=this.image,l=o.getWidth(),c=this.getCrossCheckStateCount(),u=e;for(;u>=0&&o.get(u,t);)c[2]++,u--;if(u<0)return NaN;for(;u>=0&&!o.get(u,t)&&c[1]<=n;)c[1]++,u--;if(u<0||c[1]>n)return NaN;for(;u>=0&&o.get(u,t)&&c[0]<=n;)c[0]++,u--;if(c[0]>n)return NaN;for(u=e+1;u=n)return NaN;for(;u=n)return NaN;let g=c[0]+c[1]+c[2]+c[3]+c[4];return 5*Math.abs(g-i)>=i?NaN:nt.foundPatternCross(c)?nt.centerFromEnd(c,u):NaN}handlePossibleCenter(e,t,n,i){let o=e[0]+e[1]+e[2]+e[3]+e[4],l=nt.centerFromEnd(e,n),c=this.crossCheckVertical(t,Math.floor(l),e[2],o);if(!isNaN(c)&&(l=this.crossCheckHorizontal(Math.floor(l),Math.floor(c),e[2],o),!isNaN(l)&&(!i||this.crossCheckDiagonal(Math.floor(c),Math.floor(l),e[2],o)))){let u=o/7,g=!1,w=this.possibleCenters;for(let m=0,C=w.length;m=nt.CENTER_QUORUM)if(t==null)t=n;else return this.hasSkipped=!0,Math.floor((Math.abs(t.getX()-n.getX())-Math.abs(t.getY()-n.getY()))/2);return 0}haveMultiplyConfirmedCenters(){let e=0,t=0,n=this.possibleCenters.length;for(let l of this.possibleCenters)l.getCount()>=nt.CENTER_QUORUM&&(e++,t+=l.getEstimatedModuleSize());if(e<3)return!1;let i=t/n,o=0;for(let l of this.possibleCenters)o+=Math.abs(l.getEstimatedModuleSize()-i);return o<=.05*t}selectBestPatterns(){let e=this.possibleCenters.length;if(e<3)throw new M;let t=this.possibleCenters,n;if(e>3){let i=0,o=0;for(let u of this.possibleCenters){let g=u.getEstimatedModuleSize();i+=g,o+=g*g}n=i/e;let l=Math.sqrt(o/e-n*n);t.sort((u,g)=>{let w=Math.abs(g.getEstimatedModuleSize()-n),m=Math.abs(u.getEstimatedModuleSize()-n);return wm?1:0});let c=Math.max(.2*n,l);for(let u=0;u3;u++){let g=t[u];Math.abs(g.getEstimatedModuleSize()-n)>c&&(t.splice(u,1),u--)}}if(t.length>3){let i=0;for(let o of t)i+=o.getEstimatedModuleSize();n=i/t.length,t.sort((o,l)=>{if(l.getCount()===o.getCount()){let c=Math.abs(l.getEstimatedModuleSize()-n),u=Math.abs(o.getEstimatedModuleSize()-n);return cu?-1:0}else return l.getCount()-o.getCount()}),t.splice(3)}return[t[0],t[1],t[2]]}}nt.CENTER_QUORUM=2,nt.MIN_SKIP=3,nt.MAX_MODULES=57;class Sr{constructor(e){this.image=e}getImage(){return this.image}getResultPointCallback(){return this.resultPointCallback}detect(e){this.resultPointCallback=e==null?null:e.get(z.NEED_RESULT_POINT_CALLBACK);let n=new nt(this.image,this.resultPointCallback).find(e);return this.processFinderPatternInfo(n)}processFinderPatternInfo(e){let t=e.getTopLeft(),n=e.getTopRight(),i=e.getBottomLeft(),o=this.calculateModuleSize(t,n,i);if(o<1)throw new M("No pattern found in proccess finder.");let l=Sr.computeDimension(t,n,i,o),c=se.getProvisionalVersionForDimension(l),u=c.getDimensionForVersion()-7,g=null;if(c.getAlignmentPatternCenters().length>0){let b=n.getX()-t.getX()+i.getX(),S=n.getY()-t.getY()+i.getY(),T=1-3/u,D=Math.floor(t.getX()+T*(b-t.getX())),F=Math.floor(t.getY()+T*(S-t.getY()));for(let Z=4;Z<=16;Z<<=1)try{g=this.findAlignmentInRegion(o,D,F,Z);break}catch(Q){if(!(Q instanceof M))throw Q}}let w=Sr.createTransform(t,n,i,g,l),m=Sr.sampleGrid(this.image,w,l),C;return g===null?C=[i,t,n]:C=[i,t,n,g],new di(m,C)}static createTransform(e,t,n,i,o){let l=o-3.5,c,u,g,w;return i!==null?(c=i.getX(),u=i.getY(),g=l-3,w=g):(c=t.getX()-e.getX()+n.getX(),u=t.getY()-e.getY()+n.getY(),g=l,w=l),Vt.quadrilateralToQuadrilateral(3.5,3.5,l,3.5,g,w,3.5,l,e.getX(),e.getY(),t.getX(),t.getY(),c,u,n.getX(),n.getY())}static sampleGrid(e,t,n){return hn.getInstance().sampleGridWithTransform(e,n,n,t)}static computeDimension(e,t,n,i){let o=Ce.round(ie.distance(e,t)/i),l=Ce.round(ie.distance(e,n)/i),c=Math.floor((o+l)/2)+7;switch(c&3){case 0:c++;break;case 2:c--;break;case 3:throw new M("Dimensions could be not found.")}return c}calculateModuleSize(e,t,n){return(this.calculateModuleSizeOneWay(e,t)+this.calculateModuleSizeOneWay(e,n))/2}calculateModuleSizeOneWay(e,t){let n=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(e.getX()),Math.floor(e.getY()),Math.floor(t.getX()),Math.floor(t.getY())),i=this.sizeOfBlackWhiteBlackRunBothWays(Math.floor(t.getX()),Math.floor(t.getY()),Math.floor(e.getX()),Math.floor(e.getY()));return isNaN(n)?i/7:isNaN(i)?n/7:(n+i)/14}sizeOfBlackWhiteBlackRunBothWays(e,t,n,i){let o=this.sizeOfBlackWhiteBlackRun(e,t,n,i),l=1,c=e-(n-e);c<0?(l=e/(e-c),c=0):c>=this.image.getWidth()&&(l=(this.image.getWidth()-1-e)/(c-e),c=this.image.getWidth()-1);let u=Math.floor(t-(i-t)*l);return l=1,u<0?(l=t/(t-u),u=0):u>=this.image.getHeight()&&(l=(this.image.getHeight()-1-t)/(u-t),u=this.image.getHeight()-1),c=Math.floor(e+(c-e)*l),o+=this.sizeOfBlackWhiteBlackRun(e,t,c,u),o-1}sizeOfBlackWhiteBlackRun(e,t,n,i){let o=Math.abs(i-t)>Math.abs(n-e);if(o){let b=e;e=t,t=b,b=n,n=i,i=b}let l=Math.abs(n-e),c=Math.abs(i-t),u=-l/2,g=e0){if(S===i)break;S+=w,u-=l}}return m===2?Ce.distance(n+g,i,e,t):NaN}findAlignmentInRegion(e,t,n,i){let o=Math.floor(i*e),l=Math.max(0,t-o),c=Math.min(this.image.getWidth()-1,t+o);if(c-l=u||o>=l)throw new M;if(l-o!==u-c&&(u=c+(l-o),u>=e.getWidth()))throw new M;let g=Math.round((u-c+1)/i),w=Math.round((l-o+1)/i);if(g<=0||w<=0)throw new M;if(w!==g)throw new M;let m=Math.floor(i/2);o+=m,c+=m;let C=c+Math.floor((g-1)*i)-u;if(C>0){if(C>m)throw new M;c-=C}let b=o+Math.floor((w-1)*i)-l;if(b>0){if(b>m)throw new M;o-=b}let S=new $(g,w);for(let T=0;T0;){let C=de.findGuardPattern(e,o,--i,n,!1,l,g);if(C!=null)m=C;else{i++;break}}c[0]=new ie(m[0],i),c[1]=new ie(m[1],i),u=!0;break}}let w=i+1;if(u){let m=0,C=Int32Array.from([Math.trunc(c[0].getX()),Math.trunc(c[1].getX())]);for(;wde.SKIPPED_ROW_COUNT_MAX)break;m++}}w-=m+1,c[2]=new ie(C[0],w),c[3]=new ie(C[1],w)}return w-i0&&g++m?w-m:m-w;if(C>n)return 1/0;u+=C}return u/o}}de.INDEXES_START_PATTERN=Int32Array.from([0,4,1,5]),de.INDEXES_STOP_PATTERN=Int32Array.from([6,2,7,3]),de.MAX_AVG_VARIANCE=.42,de.MAX_INDIVIDUAL_VARIANCE=.8,de.START_PATTERN=Int32Array.from([8,1,1,1,1,1,1,3]),de.STOP_PATTERN=Int32Array.from([7,1,1,3,1,1,1,2,1]),de.MAX_PIXEL_DRIFT=3,de.MAX_PATTERN_DRIFT=5,de.SKIPPED_ROW_COUNT_MAX=25,de.ROW_STEP=5,de.BARCODE_MIN_HEIGHT=10;class at{constructor(e,t){if(t.length===0)throw new x;this.field=e;let n=t.length;if(n>1&&t[0]===0){let i=1;for(;in.length){let l=t;t=n,n=l}let i=new Int32Array(n.length),o=n.length-t.length;N.arraycopy(n,0,i,0,o);for(let l=o;l=0;t--){let n=this.getCoefficient(t);n!==0&&(n<0?(e.append(" - "),n=-n):e.length()>0&&e.append(" + "),(t===0||n!==1)&&e.append(n),t!==0&&(t===1?e.append("x"):(e.append("x^"),e.append(t))))}return e.toString()}}class F1{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 x;return this.logTable[e]}inverse(e){if(e===0)throw new ui;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 ms extends F1{constructor(e,t){super(),this.modulus=e,this.expTable=new Int32Array(e),this.logTable=new Int32Array(e);let n=1;for(let i=0;i0;S--){let T=i.evaluateAt(this.field.exp(S));o[t-S]=T,T!==0&&(l=!0)}if(!l)return 0;let c=this.field.getOne();if(n!=null)for(let S of n){let T=this.field.exp(e.length-1-S),D=new at(this.field,new Int32Array([this.field.subtract(0,T),1]));c=c.multiply(D)}let u=new at(this.field,o),g=this.runEuclideanAlgorithm(this.field.buildMonomial(t,1),u,t),w=g[0],m=g[1],C=this.findErrorLocations(w),b=this.findErrorMagnitudes(m,w,C);for(let S=0;S=Math.round(n/2);){let C=i,b=l;if(i=o,l=c,i.isZero())throw v.getChecksumInstance();o=C;let S=this.field.getZero(),T=i.getCoefficient(i.getDegree()),D=this.field.inverse(T);for(;o.getDegree()>=i.getDegree()&&!o.isZero();){let F=o.getDegree()-i.getDegree(),Z=this.field.multiply(o.getCoefficient(o.getDegree()),D);S=S.add(this.field.buildMonomial(F,Z)),o=o.subtract(i.multiplyByMonomial(F,Z))}c=S.multiply(l).subtract(b).negative()}let u=c.getCoefficient(0);if(u===0)throw v.getChecksumInstance();let g=this.field.inverse(u),w=c.multiply(g),m=o.multiply(g);return[w,m]}findErrorLocations(e){let t=e.getDegree(),n=new Int32Array(t),i=0;for(let o=1;o0){let u=n?this.topLeft:this.topRight,g=Math.trunc(u.getY()-e);g<0&&(g=0);let w=new ie(u.getX(),g);n?i=w:l=w}if(t>0){let u=n?this.bottomLeft:this.bottomRight,g=Math.trunc(u.getY()+t);g>=this.image.getHeight()&&(g=this.image.getHeight()-1);let w=new ie(u.getX(),g);n?o=w:c=w}return new Dn(this.image,i,o,l,c)}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 U1{constructor(e,t,n,i){this.columnCount=e,this.errorCorrectionLevel=i,this.rowCountUpperPart=t,this.rowCountLowerPart=n,this.rowCount=t+n}getColumnCount(){return this.columnCount}getErrorCorrectionLevel(){return this.errorCorrectionLevel}getRowCount(){return this.rowCount}getRowCountUpperPart(){return this.rowCountUpperPart}getRowCountLowerPart(){return this.rowCountLowerPart}}class Tr{constructor(){this.buffer=""}static form(e,t){let n=-1;function i(l,c,u,g,w,m){if(l==="%%")return"%";if(t[++n]===void 0)return;l=g?parseInt(g.substr(1)):void 0;let C=w?parseInt(w.substr(1)):void 0,b;switch(m){case"s":b=t[n];break;case"c":b=t[n][0];break;case"f":b=parseFloat(t[n]).toFixed(l);break;case"p":b=parseFloat(t[n]).toPrecision(l);break;case"e":b=parseFloat(t[n]).toExponential(l);break;case"x":b=parseInt(t[n]).toString(C||16);break;case"d":b=parseFloat(parseInt(t[n],C||10).toPrecision(l)).toFixed(0);break}b=typeof b=="object"?JSON.stringify(b):(+b).toString(C);let S=parseInt(u),T=u&&u[0]+""=="0"?"0":" ";for(;b.length=0&&(t=this.codewords[i],t!=null)||(i=this.imageRowToCodewordIndex(e)+n,in,getValue:()=>i};o.getValue()>e?(e=o.getValue(),t=[],t.push(o.getKey())):o.getValue()===e&&t.push(o.getKey())}return fe.toIntArray(t)}getConfidence(e){return this.values.get(e)}}class Jo extends Nr{constructor(e,t){super(e),this._isLeft=t}setRowNumbers(){for(let e of this.getCodewords())e?.setRowNumberAsRowIndicatorColumn()}adjustCompleteIndicatorColumnRowNumbers(e){let t=this.getCodewords();this.setRowNumbers(),this.removeIncorrectCodewords(t,e);let n=this.getBoundingBox(),i=this._isLeft?n.getTopLeft():n.getTopRight(),o=this._isLeft?n.getBottomLeft():n.getBottomRight(),l=this.imageRowToCodewordIndex(Math.trunc(i.getY())),c=this.imageRowToCodewordIndex(Math.trunc(o.getY())),u=-1,g=1,w=0;for(let m=l;m=e.getRowCount()||b>m)t[m]=null;else{let S;g>2?S=(g-2)*b:S=b;let T=S>=m;for(let D=1;D<=S&&!T;D++)T=t[m-D]!=null;T?t[m]=null:(u=C.getRowNumber(),w=1)}}}getRowHeights(){let e=this.getBarcodeMetadata();if(e==null)return null;this.adjustIncompleteIndicatorColumnRowNumbers(e);let t=new Int32Array(e.getRowCount());for(let n of this.getCodewords())if(n!=null){let i=n.getRowNumber();if(i>=t.length)continue;t[i]++}return t}adjustIncompleteIndicatorColumnRowNumbers(e){let t=this.getBoundingBox(),n=this._isLeft?t.getTopLeft():t.getTopRight(),i=this._isLeft?t.getBottomLeft():t.getBottomRight(),o=this.imageRowToCodewordIndex(Math.trunc(n.getY())),l=this.imageRowToCodewordIndex(Math.trunc(i.getY())),c=this.getCodewords(),u=-1;for(let g=o;g=e.getRowCount()?c[g]=null:u=w.getRowNumber())}}getBarcodeMetadata(){let e=this.getCodewords(),t=new Mr,n=new Mr,i=new Mr,o=new Mr;for(let c of e){if(c==null)continue;c.setRowNumberAsRowIndicatorColumn();let u=c.getValue()%30,g=c.getRowNumber();switch(this._isLeft||(g+=2),g%3){case 0:n.setValue(u*3+1);break;case 1:o.setValue(u/3),i.setValue(u%3);break;case 2:t.setValue(u+1);break}}if(t.getValue().length===0||n.getValue().length===0||i.getValue().length===0||o.getValue().length===0||t.getValue()[0]<1||n.getValue()[0]+i.getValue()[0]fe.MAX_ROWS_IN_BARCODE)return null;let l=new U1(t.getValue()[0],n.getValue()[0],i.getValue()[0],o.getValue()[0]);return this.removeIncorrectCodewords(e,l),l}removeIncorrectCodewords(e,t){for(let n=0;nt.getRowCount()){e[n]=null;continue}switch(this._isLeft||(l+=2),l%3){case 0:o*3+1!==t.getRowCountUpperPart()&&(e[n]=null);break;case 1:(Math.trunc(o/3)!==t.getErrorCorrectionLevel()||o%3!==t.getRowCountLowerPart())&&(e[n]=null);break;case 2:o+1!==t.getColumnCount()&&(e[n]=null);break}}}isLeft(){return this._isLeft}toString(){return"IsLeft: "+this._isLeft+` `+super.toString()}}class Or{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=fe.MAX_CODEWORDS_IN_BARCODE,t;do t=e,e=this.adjustRowNumbersAndGetCount();while(e>0&&e0&&o0&&(c[0]=n[t-1],c[4]=o[t-1],c[5]=l[t-1]),t>1&&(c[8]=n[t-2],c[10]=o[t-2],c[11]=l[t-2]),t>=1;n=t&1,Et.RATIOS_TABLE[e]||(Et.RATIOS_TABLE[e]=new Array(fe.BARS_IN_MODULE)),Et.RATIOS_TABLE[e][fe.BARS_IN_MODULE-i-1]=Math.fround(o/fe.MODULES_IN_CODEWORD)}}this.bSymbolTableReady=!0}static getDecodedValue(e){let t=Et.getDecodedCodewordValue(Et.sampleBitCounts(e));return t!==-1?t:Et.getClosestDecodedValue(e)}static sampleBitCounts(e){let t=Ce.sum(e),n=new Int32Array(fe.BARS_IN_MODULE),i=0,o=0;for(let l=0;l1)for(let l=0;l=i)break}cE=new Array(fe.BARS_IN_MODULE));class $o{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 ea{static parseLong(e,t=void 0){return parseInt(e,t)}}class ta extends A{}ta.kind="NullPointerException";class z1{writeBytes(e){this.writeBytesOffset(e,0,e.length)}writeBytesOffset(e,t,n){if(e==null)throw new ta;if(t<0||t>e.length||n<0||t+n>e.length||t+n<0)throw new V;if(n===0)return;for(let i=0;i0&&this.grow(e)}grow(e){let n=this.buf.length<<1;if(n-e<0&&(n=e),n<0){if(e<0)throw new H1;n=U.MAX_VALUE}this.buf=H.copyOfUint8Array(this.buf,n)}write(e){this.ensureCapacity(this.count+1),this.buf[this.count]=e,this.count+=1}writeBytesOffset(e,t,n){if(t<0||t>e.length||n<0||t+n-e.length>0)throw new V;this.ensureCapacity(this.count+n),N.arraycopy(e,t,this.buf,this.count,n),this.count+=n}writeTo(e){e.writeBytesOffset(this.buf,0,this.count)}reset(){this.count=0}toByteArray(){return H.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 Re;(function(E){E[E.ALPHA=0]="ALPHA",E[E.LOWER=1]="LOWER",E[E.MIXED=2]="MIXED",E[E.PUNCT=3]="PUNCT",E[E.ALPHA_SHIFT=4]="ALPHA_SHIFT",E[E.PUNCT_SHIFT=5]="PUNCT_SHIFT"})(Re||(Re={}));function na(){if(typeof window<"u")return window.BigInt||null;if(typeof global<"u")return global.BigInt||null;if(typeof self<"u")return self.BigInt||null;throw new Error("Can't search globals for BigInt!")}let Ei;function pn(E){if(typeof Ei>"u"&&(Ei=na()),Ei===null)throw new Error("BigInt is not supported!");return Ei(E)}function X1(){let E=[];E[0]=pn(1);let e=pn(900);E[1]=e;for(let t=2;t<16;t++)E[t]=E[t-1]*e;return E}class P{static decode(e,t){let n=new G(""),i=O.ISO8859_1;n.enableDecoding(i);let o=1,l=e[o++],c=new $o;for(;oe[0])throw L.getFormatInstance();let i=new Int32Array(P.NUMBER_OF_SEQUENCE_CODEWORDS);for(let c=0;c0){for(let C=0;C<6;++C)l.write(Number(pn(u)>>pn(8*(5-C))));u=0,c=0}break}i===t[0]&&m0){for(let b=0;b<6;++b)l.write(Number(pn(u)>>pn(8*(5-b))));u=0,c=0}}break}return o.append(re.decode(l.toByteArray(),n)),i}static numericCompaction(e,t,n){let i=0,o=!1,l=new Int32Array(P.MAX_NUMERIC_CODEWORDS);for(;t0&&(n.append(P.decodeBase900toBase10(l,i)),i=0)}return t}static decodeBase900toBase10(e,t){let n=pn(0);for(let o=0;o@[\\]_\`~!\r ,: -.$/"|*()?{}'`,P.MIXED_CHARS="0123456789&\r ,:#-.$/+%*=^",P.EXP900=na()?X1():[],P.NUMBER_OF_SEQUENCE_CODEWORDS=2;class ge{constructor(){}static decode(e,t,n,i,o,l,c){let u=new Dn(e,t,n,i,o),g=null,w=null,m;for(let S=!0;;S=!1){if(t!=null&&(g=ge.getRowIndicatorColumn(e,u,t,!0,l,c)),i!=null&&(w=ge.getRowIndicatorColumn(e,u,i,!1,l,c)),m=ge.merge(g,w),m==null)throw M.getNotFoundInstance();let T=m.getBoundingBox();if(S&&T!=null&&(T.getMinY()u.getMaxY()))u=T;else break}m.setBoundingBox(u);let C=m.getBarcodeColumnCount()+1;m.setDetectionResultColumn(0,g),m.setDetectionResultColumn(C,w);let b=g!=null;for(let S=1;S<=C;S++){let T=b?S:C-S;if(m.getDetectionResultColumn(T)!==void 0)continue;let D;T===0||T===C?D=new Jo(u,T===0):D=new Nr(u),m.setDetectionResultColumn(T,D);let F=-1,Z=F;for(let Q=u.getMinY();Q<=u.getMaxY();Q++){if(F=ge.getStartColumn(m,T,Q,b),F<0||F>u.getMaxX()){if(Z===-1)continue;F=Z}let j=ge.detectCodeword(e,u.getMinX(),u.getMaxX(),b,F,Q,l,c);j!=null&&(D.setCodeword(Q,j),Z=F,l=Math.min(l,j.getWidth()),c=Math.max(c,j.getWidth()))}}return ge.createDecoderResult(m)}static merge(e,t){if(e==null&&t==null)return null;let n=ge.getBarcodeMetadata(e,t);if(n==null)return null;let i=Dn.merge(ge.adjustBoundingBox(e),ge.adjustBoundingBox(t));return new Or(n,i)}static adjustBoundingBox(e){if(e==null)return null;let t=e.getRowHeights();if(t==null)return null;let n=ge.getMax(t),i=0;for(let c of t)if(i+=n-c,c>0)break;let o=e.getCodewords();for(let c=0;i>0&&o[c]==null;c++)i--;let l=0;for(let c=t.length-1;c>=0&&(l+=n-t[c],!(t[c]>0));c--);for(let c=o.length-1;l>0&&o[c]==null;c--)l--;return e.getBoundingBox().addMissingRows(i,l,e.isLeft())}static getMax(e){let t=-1;for(let n of e)t=Math.max(t,n);return t}static getBarcodeMetadata(e,t){let n;if(e==null||(n=e.getBarcodeMetadata())==null)return t==null?null:t.getBarcodeMetadata();let i;return t==null||(i=t.getBarcodeMetadata())==null?n:n.getColumnCount()!==i.getColumnCount()&&n.getErrorCorrectionLevel()!==i.getErrorCorrectionLevel()&&n.getRowCount()!==i.getRowCount()?null:n}static getRowIndicatorColumn(e,t,n,i,o,l){let c=new Jo(t,i);for(let u=0;u<2;u++){let g=u===0?1:-1,w=Math.trunc(Math.trunc(n.getX()));for(let m=Math.trunc(Math.trunc(n.getY()));m<=t.getMaxY()&&m>=t.getMinY();m+=g){let C=ge.detectCodeword(e,0,e.getWidth(),i,w,m,o,l);C!=null&&(c.setCodeword(m,C),i?w=C.getStartX():w=C.getEndX())}}return c}static adjustCodewordCount(e,t){let n=t[0][1],i=n.getValue(),o=e.getBarcodeColumnCount()*e.getBarcodeRowCount()-ge.getNumberOfECCodeWords(e.getBarcodeECLevel());if(i.length===0){if(o<1||o>fe.MAX_CODEWORDS_IN_BARCODE)throw M.getNotFoundInstance();n.setValue(o)}else i[0]!==o&&n.setValue(o)}static createDecoderResult(e){let t=ge.createBarcodeMatrix(e);ge.adjustCodewordCount(e,t);let n=new Array,i=new Int32Array(e.getBarcodeRowCount()*e.getBarcodeColumnCount()),o=[],l=new Array;for(let u=0;u0;){for(let u=0;unew Array(e.getBarcodeColumnCount()+2));for(let i=0;i=0){if(l>=t.length)continue;t[l][n].setValue(o.getValue())}}}n++}return t}static isValidBarcodeColumn(e,t){return t>=0&&t<=e.getBarcodeColumnCount()+1}static getStartColumn(e,t,n,i){let o=i?1:-1,l=null;if(ge.isValidBarcodeColumn(e,t-o)&&(l=e.getDetectionResultColumn(t-o).getCodeword(n)),l!=null)return i?l.getEndX():l.getStartX();if(l=e.getDetectionResultColumn(t).getCodewordNearby(n),l!=null)return i?l.getStartX():l.getEndX();if(ge.isValidBarcodeColumn(e,t-o)&&(l=e.getDetectionResultColumn(t-o).getCodewordNearby(n)),l!=null)return i?l.getEndX():l.getStartX();let c=0;for(;ge.isValidBarcodeColumn(e,t-o);){t-=o;for(let u of e.getDetectionResultColumn(t).getCodewords())if(u!=null)return(i?u.getEndX():u.getStartX())+o*c*(u.getEndX()-u.getStartX());c++}return i?e.getBoundingBox().getMinX():e.getBoundingBox().getMaxX()}static detectCodeword(e,t,n,i,o,l,c,u){o=ge.adjustCodewordStartColumn(e,t,n,i,o,l);let g=ge.getModuleBitCount(e,t,n,i,o,l);if(g==null)return null;let w,m=Ce.sum(g);if(i)w=o+m;else{for(let S=0;S=t)&&g=t:cge.CODEWORD_SKEW_SIZE)return o;c+=u}u=-u,i=!i}return c}static checkCodewordSkew(e,t,n){return t-ge.CODEWORD_SKEW_SIZE<=e&&e<=n+ge.CODEWORD_SKEW_SIZE}static decodeCodewords(e,t,n){if(e.length===0)throw L.getFormatInstance();let i=1<n/2+ge.MAX_ERRORS||n<0||n>ge.MAX_EC_CODEWORDS)throw v.getChecksumInstance();return ge.errorCorrection.decode(e,n,t)}static verifyCodewordCount(e,t){if(e.length<4)throw L.getFormatInstance();let n=e[0];if(n>e.length)throw L.getFormatInstance();if(n===0)if(t>=1;return t}static getCodewordBucketNumber(e){return e instanceof Int32Array?this.getCodewordBucketNumber_Int32Array(e):this.getCodewordBucketNumber_number(e)}static getCodewordBucketNumber_number(e){return ge.getCodewordBucketNumber(ge.getBitCountForCodeword(e))}static getCodewordBucketNumber_Int32Array(e){return(e[0]-e[2]+e[4]-e[6]+9)%9}static toString(e){let t=new Tr;for(let n=0;nl)}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?U.MAX_VALUE:Math.trunc(Math.abs(e.getX()-t.getX()))}static getMaxCodewordWidth(e){return Math.floor(Math.max(Math.max(lt.getMaxWidth(e[0],e[4]),lt.getMaxWidth(e[6],e[2])*fe.MODULES_IN_CODEWORD/fe.MODULES_IN_STOP_PATTERN),Math.max(lt.getMaxWidth(e[1],e[5]),lt.getMaxWidth(e[7],e[3])*fe.MODULES_IN_CODEWORD/fe.MODULES_IN_STOP_PATTERN)))}static getMinCodewordWidth(e){return Math.floor(Math.min(Math.min(lt.getMinWidth(e[0],e[4]),lt.getMinWidth(e[6],e[2])*fe.MODULES_IN_CODEWORD/fe.MODULES_IN_STOP_PATTERN),Math.min(lt.getMinWidth(e[1],e[5]),lt.getMinWidth(e[7],e[3])*fe.MODULES_IN_CODEWORD/fe.MODULES_IN_STOP_PATTERN)))}reset(){}}class mi extends A{}mi.kind="ReaderException";class ra{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;let t=!a(e)&&e.get(z.TRY_HARDER)===!0,n=a(e)?null:e.get(z.POSSIBLE_FORMATS),i=new Array;if(!a(n)){let o=n.some(l=>l===oe.UPC_A||l===oe.UPC_E||l===oe.EAN_13||l===oe.EAN_8||l===oe.CODABAR||l===oe.CODE_39||l===oe.CODE_93||l===oe.CODE_128||l===oe.ITF||l===oe.RSS_14||l===oe.RSS_EXPANDED);o&&!t&&i.push(new Jn(e,this.verbose)),n.includes(oe.QR_CODE)&&i.push(new wn),n.includes(oe.DATA_MATRIX)&&i.push(new xn),n.includes(oe.AZTEC)&&i.push(new gi),n.includes(oe.PDF_417)&&i.push(new lt),o&&t&&i.push(new Jn(e,this.verbose))}i.length===0&&(t||i.push(new Jn(e,this.verbose)),i.push(new wn),i.push(new xn),i.push(new gi),i.push(new lt),t&&i.push(new Jn(e,this.verbose))),this.readers=i}reset(){if(this.readers!==null)for(let e of this.readers)e.reset()}decodeInternal(e){if(this.readers===null)throw new mi("No readers where selected, nothing can be read.");for(let t of this.readers)try{return t.decode(e,this.hints)}catch(n){if(n instanceof mi)continue}throw new M("No MultiFormat Readers were able to detect the code.")}}class G1 extends Ht{constructor(e=null,t=500){let n=new ra;n.setHints(e),super(n,t)}decodeBitmap(e){return this.reader.decodeWithState(e)}}class j1 extends Ht{constructor(e=500){super(new lt,e)}}class Y1 extends Ht{constructor(e=500){super(new wn,e)}}var Cs;(function(E){E[E.ERROR_CORRECTION=0]="ERROR_CORRECTION",E[E.CHARACTER_SET=1]="CHARACTER_SET",E[E.DATA_MATRIX_SHAPE=2]="DATA_MATRIX_SHAPE",E[E.MIN_SIZE=3]="MIN_SIZE",E[E.MAX_SIZE=4]="MAX_SIZE",E[E.MARGIN=5]="MARGIN",E[E.PDF417_COMPACT=6]="PDF417_COMPACT",E[E.PDF417_COMPACTION=7]="PDF417_COMPACTION",E[E.PDF417_DIMENSIONS=8]="PDF417_DIMENSIONS",E[E.AZTEC_LAYERS=9]="AZTEC_LAYERS",E[E.QR_VERSION=10]="QR_VERSION"})(Cs||(Cs={}));var Je=Cs;class _s{constructor(e){this.field=e,this.cachedGenerators=[],this.cachedGenerators.push(new wt(e,Int32Array.from([1])))}buildGenerator(e){let t=this.cachedGenerators;if(e>=t.length){let n=t[t.length-1],i=this.field;for(let o=t.length;o<=e;o++){let l=n.multiply(new wt(i,Int32Array.from([1,i.exp(o-1+i.getGeneratorBase())])));t.push(l),n=l}}return t[e]}encode(e,t){if(t===0)throw new x("No error correction bytes");let n=e.length-t;if(n<=0)throw new x("No data bytes provided");let i=this.buildGenerator(t),o=new Int32Array(n);N.arraycopy(e,0,o,0,n);let l=new wt(this.field,o);l=l.multiplyByMonomial(t,1);let u=l.divide(i)[1].getCoefficients(),g=t-u.length;for(let w=0;w=5&&(n+=je.N1+(u-5)),u=1,g=m)}u>=5&&(n+=je.N1+(u-5))}return n}}je.N1=3,je.N2=3,je.N3=40,je.N4=10;class Ci{constructor(e,t){this.width=e,this.height=t;let n=new Array(t);for(let i=0;i!==t;i++)n[i]=new Uint8Array(e);this.bytes=n}getHeight(){return this.height}getWidth(){return this.width}get(e,t){return this.bytes[t][e]}getArray(){return this.bytes}setNumber(e,t,n){this.bytes[t][e]=n}setBoolean(e,t,n){this.bytes[t][e]=n?1:0}clear(e){for(let t of this.bytes)H.fill(t,e)}equals(e){if(!(e instanceof Ci))return!1;let t=e;if(this.width!==t.width||this.height!==t.height)return!1;for(let n=0,i=this.height;n> `),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&&e0;){for(l===6&&(l-=1);c>=0&&c=n;)e^=t<=0)for(let u=0;u!==l;u++){let g=i[u];g>=0&&ce.isEmpty(t.get(g,c))&&ce.embedPositionAdjustmentPattern(g-2,c-2,t)}}}}ce.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])]),ce.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])]),ce.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])]),ce.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])]),ce.VERSION_INFO_POLY=7973,ce.TYPE_INFO_POLY=1335,ce.TYPE_INFO_MASK_PATTERN=21522;class W1{constructor(e,t){this.dataBytes=e,this.errorCorrectionBytes=t}getDataBytes(){return this.dataBytes}getErrorCorrectionBytes(){return this.errorCorrectionBytes}}class Fe{constructor(){}static calculateMaskPenalty(e){return je.applyMaskPenaltyRule1(e)+je.applyMaskPenaltyRule2(e)+je.applyMaskPenaltyRule3(e)+je.applyMaskPenaltyRule4(e)}static encode(e,t,n=null){let i=Fe.DEFAULT_BYTE_MODE_ENCODING,o=n!==null&&n.get(Je.CHARACTER_SET)!==void 0;o&&(i=n.get(Je.CHARACTER_SET).toString());let l=this.chooseMode(e,i),c=new W;if(l===ae.BYTE&&(o||Fe.DEFAULT_BYTE_MODE_ENCODING!==i)){let Q=O.getCharacterSetECIByName(i);Q!==void 0&&this.appendECI(Q,c)}this.appendModeInfo(l,c);let u=new W;this.appendBytes(e,l,u,i);let g;if(n!==null&&n.get(Je.QR_VERSION)!==void 0){let Q=Number.parseInt(n.get(Je.QR_VERSION).toString(),10);g=se.getVersionForNumber(Q);let j=this.calculateBitsNeeded(l,c,u,g);if(!this.willFit(j,g,t))throw new ve("Data too big for requested version")}else g=this.recommendVersion(t,l,c,u);let w=new W;w.appendBitArray(c);let m=l===ae.BYTE?u.getSizeInBytes():e.length;this.appendLengthInfo(m,g,l,w),w.appendBitArray(u);let C=g.getECBlocksForLevel(t),b=g.getTotalCodewords()-C.getTotalECCodewords();this.terminateBits(b,w);let S=this.interleaveWithECBytes(w,g.getTotalCodewords(),b,C.getNumBlocks()),T=new vn;T.setECLevel(t),T.setMode(l),T.setVersion(g);let D=g.getDimensionForVersion(),F=new Ci(D,D),Z=this.chooseMaskPattern(S,t,g,F);return T.setMaskPattern(Z),ce.buildMatrix(S,t,g,Z,F),T.setMatrix(F),T}static recommendVersion(e,t,n,i){let o=this.calculateBitsNeeded(t,n,i,se.getVersionForNumber(1)),l=this.chooseVersion(o,e),c=this.calculateBitsNeeded(t,n,i,l);return this.chooseVersion(c,e)}static calculateBitsNeeded(e,t,n,i){return t.getSize()+e.getCharacterCountBits(i)+n.getSize()}static getAlphanumericCode(e){return e159)&&(o<224||o>235))return!1}return!0}static chooseMaskPattern(e,t,n,i){let o=Number.MAX_SAFE_INTEGER,l=-1;for(let c=0;c=u}static terminateBits(e,t){let n=e*8;if(t.getSize()>n)throw new ve("data bits cannot fit in the QR Code"+t.getSize()+" > "+n);for(let l=0;l<4&&t.getSize()0)for(let l=i;l<8;l++)t.appendBit(!1);let o=e-t.getSizeInBytes();for(let l=0;l=n)throw new ve("Block ID too large");let c=e%n,u=n-c,g=Math.floor(e/n),w=g+1,m=Math.floor(t/n),C=m+1,b=g-m,S=w-C;if(b!==S)throw new ve("EC bytes mismatch");if(n!==u+c)throw new ve("RS blocks mismatch");if(e!==(m+b)*u+(C+S)*c)throw new ve("Total bytes mismatch");i=1<=0&&t<=9}static appendNumericBytes(e,t){let n=e.length,i=0;for(;i=33088&&u<=40956?g=u-33088:u>=57408&&u<=60351&&(g=u-49472),g===-1)throw new ve("Invalid byte sequence");let w=(g>>8)*192+(g&255);t.appendBits(w,13)}}static appendECI(e,t){t.appendBits(ae.ECI.getBits(),4),t.appendBits(e.getValue(),8)}}Fe.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]),Fe.DEFAULT_BYTE_MODE_ENCODING=O.UTF8.getName();class Bn{write(e,t,n,i=null){if(e.length===0)throw new x("Found empty contents");if(t<0||n<0)throw new x("Requested dimensions are too small: "+t+"x"+n);let o=ke.L,l=Bn.QUIET_ZONE_SIZE;i!==null&&(i.get(Je.ERROR_CORRECTION)!==void 0&&(o=ke.fromString(i.get(Je.ERROR_CORRECTION).toString())),i.get(Je.MARGIN)!==void 0&&(l=Number.parseInt(i.get(Je.MARGIN).toString(),10)));let c=Fe.encode(e,o,i);return this.renderResult(c,t,n,l)}writeToDom(e,t,n,i,o=null){typeof e=="string"&&(e=document.querySelector(e));let l=this.write(t,n,i,o);e&&e.appendChild(l)}renderResult(e,t,n,i){let o=e.getMatrix();if(o===null)throw new Wt;let l=o.getWidth(),c=o.getHeight(),u=l+i*2,g=c+i*2,w=Math.max(t,u),m=Math.max(n,g),C=Math.min(Math.floor(w/u),Math.floor(m/g)),b=Math.floor((w-l*C)/2),S=Math.floor((m-c*C)/2),T=this.createSVGElement(w,m);for(let D=0,F=S;Dt||o+c>n)throw new x("Crop rectangle does not fit within image data.");u&&this.reverseHorizontal(l,c)}getRow(e,t){if(e<0||e>=this.getHeight())throw new x("Requested row is outside the image: "+e);let n=this.getWidth();(t==null||t.length>16&255,b=m>>7&510,S=m&255;g[w]=(C+b+S)/4&255}this.luminances=g}else this.luminances=e;if(i===void 0&&(this.dataWidth=t),o===void 0&&(this.dataHeight=n),l===void 0&&(this.left=0),c===void 0&&(this.top=0),this.left+t>this.dataWidth||this.top+n>this.dataHeight)throw new x("Crop rectangle does not fit within image data.")}getRow(e,t){if(e<0||e>=this.getHeight())throw new x("Requested row is outside the image: "+e);let n=this.getWidth();(t==null||t.length"}}class bs extends tr{constructor(e,t,n){super(e,0,0),this.binaryShiftStart=t,this.binaryShiftByteCount=n}appendTo(e,t){for(let n=0;n62?e.appendBits(this.binaryShiftByteCount-31,16):n===0?e.appendBits(Math.min(this.binaryShiftByteCount,31),5):e.appendBits(this.binaryShiftByteCount-31,5)),e.appendBits(t[this.binaryShiftStart+n],8)}addBinaryShift(e,t){return new bs(this,e,t)}toString(){return"<"+this.binaryShiftStart+"::"+(this.binaryShiftStart+this.binaryShiftByteCount-1)+">"}}function K1(E,e,t){return new bs(E,e,t)}function Dr(E,e,t){return new tr(E,e,t)}let q1=["UPPER","LOWER","DIGIT","MIXED","PUNCT"],An=0,_i=1,Bt=2,aa=3,Jt=4,J1=new tr(null,0,0),Ss=[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 $1(E){for(let e of E)H.fill(e,-1);return E[An][Jt]=0,E[_i][Jt]=0,E[_i][An]=28,E[aa][Jt]=0,E[Bt][Jt]=0,E[Bt][An]=15,E}let la=$1(H.createInt32Array(6,6));class $t{constructor(e,t,n,i){this.token=e,this.mode=t,this.binaryShiftByteCount=n,this.bitCount=i}getMode(){return this.mode}getToken(){return this.token}getBinaryShiftByteCount(){return this.binaryShiftByteCount}getBitCount(){return this.bitCount}latchAndAppend(e,t){let n=this.bitCount,i=this.token;if(e!==this.mode){let l=Ss[this.mode][e];i=Dr(i,l&65535,l>>16),n+=l>>16}let o=e===Bt?4:5;return i=Dr(i,t,o),new $t(i,e,0,n+o)}shiftAndAppend(e,t){let n=this.token,i=this.mode===Bt?4:5;return n=Dr(n,la[this.mode][e],i),n=Dr(n,t,5),new $t(n,this.mode,0,this.bitCount+i+5)}addBinaryShiftChar(e){let t=this.token,n=this.mode,i=this.bitCount;if(this.mode===Jt||this.mode===Bt){let c=Ss[n][An];t=Dr(t,c&65535,c>>16),i+=c>>16,n=An}let o=this.binaryShiftByteCount===0||this.binaryShiftByteCount===31?18:this.binaryShiftByteCount===62?9:8,l=new $t(t,n,this.binaryShiftByteCount+1,i+o);return l.binaryShiftByteCount===2078&&(l=l.endBinaryShift(e+1)),l}endBinaryShift(e){if(this.binaryShiftByteCount===0)return this;let t=this.token;return t=K1(t,e-this.binaryShiftByteCount,this.binaryShiftByteCount),new $t(t,this.mode,0,this.bitCount)}isBetterThanOrEqualTo(e){let t=this.bitCount+(Ss[this.mode][e.mode]>>16);return this.binaryShiftByteCounte.binaryShiftByteCount&&e.binaryShiftByteCount>0&&(t+=10),t<=e.bitCount}toBitArray(e){let t=[];for(let i=this.endBinaryShift(e.length).token;i!==null;i=i.getPrevious())t.unshift(i);let n=new W;for(let i of t)i.appendTo(n,e);return n}toString(){return k.format("%s bits=%d bytes=%d",q1[this.mode],this.bitCount,this.binaryShiftByteCount)}static calculateBinaryShiftCost(e){return e.binaryShiftByteCount>62?21:e.binaryShiftByteCount>31?20:e.binaryShiftByteCount>0?10:0}}$t.INITIAL_STATE=new $t(J1,An,0,0);function e0(E){let e=k.getCharCode(" "),t=k.getCharCode("."),n=k.getCharCode(",");E[An][e]=1;let i=k.getCharCode("Z"),o=k.getCharCode("A");for(let C=o;C<=i;C++)E[An][C]=C-o+2;E[_i][e]=1;let l=k.getCharCode("z"),c=k.getCharCode("a");for(let C=c;C<=l;C++)E[_i][C]=C-c+2;E[Bt][e]=1;let u=k.getCharCode("9"),g=k.getCharCode("0");for(let C=g;C<=u;C++)E[Bt][C]=C-g+2;E[Bt][n]=12,E[Bt][t]=13;let w=["\0"," ","","","","","","","\x07","\b"," ",` `,"\v","\f","\r","\x1B","","","","","@","\\","^","_","`","|","~","\x7F"];for(let C=0;C","?","[","]","{","}"];for(let C=0;C0&&(E[Jt][k.getCharCode(m[C])]=C);return E}let Ts=e0(H.createInt32Array(5,256));class vr{constructor(e){this.text=e}encode(){let e=k.getCharCode(" "),t=k.getCharCode(` `),n=oa.singletonList($t.INITIAL_STATE);for(let o=0;o0?(n=vr.updateStateListForPair(n,o,l),o++):n=this.updateStateListForChar(n,o)}return oa.min(n,(o,l)=>o.getBitCount()-l.getBitCount()).toBitArray(this.text)}updateStateListForChar(e,t){let n=[];for(let i of e)this.updateStateForChar(i,t,n);return vr.simplifyStates(n)}updateStateForChar(e,t,n){let i=this.text[t]&255,o=Ts[e.getMode()][i]>0,l=null;for(let c=0;c<=Jt;c++){let u=Ts[c][i];if(u>0){if(l==null&&(l=e.endBinaryShift(t)),!o||c===e.getMode()||c===Bt){let g=l.latchAndAppend(c,u);n.push(g)}if(!o&&la[e.getMode()][c]>=0){let g=l.shiftAndAppend(c,u);n.push(g)}}}if(e.getBinaryShiftByteCount()>0||Ts[e.getMode()][i]===0){let c=e.addBinaryShiftChar(t);n.push(c)}}static updateStateListForPair(e,t,n){let i=[];for(let o of e)this.updateStateForPair(o,t,n,i);return this.simplifyStates(i)}static updateStateForPair(e,t,n,i){let o=e.endBinaryShift(t);if(i.push(o.latchAndAppend(Jt,n)),e.getMode()!==Jt&&i.push(o.shiftAndAppend(Jt,n)),n===3||n===4){let l=o.latchAndAppend(Bt,16-n).latchAndAppend(Bt,1);i.push(l)}if(e.getBinaryShiftByteCount()>0){let l=e.addBinaryShiftChar(t).addBinaryShiftChar(t+1);i.push(l)}}static simplifyStates(e){let t=[];for(let n of e){let i=!0;for(let o of t){if(o.isBetterThanOrEqualTo(n)){i=!1;break}n.isBetterThanOrEqualTo(o)&&(t=t.filter(l=>l!==o))}i&&t.push(n)}return t}}class _e{constructor(){}static encodeBytes(e){return _e.encode(e,_e.DEFAULT_EC_PERCENT,_e.DEFAULT_AZTEC_LAYERS)}static encode(e,t,n){let i=new vr(e).encode(),o=U.truncDivision(i.getSize()*t,100)+11,l=i.getSize()+o,c,u,g,w,m;if(n!==_e.DEFAULT_AZTEC_LAYERS){if(c=n<0,u=Math.abs(n),u>(c?_e.MAX_NB_BITS_COMPACT:_e.MAX_NB_BITS))throw new x(k.format("Illegal value %s for layers",n));g=_e.totalBitsInLayer(u,c),w=_e.WORD_SIZE[u];let j=g-g%w;if(m=_e.stuffBits(i,w),m.getSize()+o>j)throw new x("Data to large for user specified layer");if(c&&m.getSize()>w*64)throw new x("Data to large for user specified layer")}else{w=0,m=null;for(let j=0;;j++){if(j>_e.MAX_NB_BITS)throw new x("Data too large for an Aztec code");if(c=j<=3,u=c?j+1:j,g=_e.totalBitsInLayer(u,c),l>g)continue;(m==null||w!==_e.WORD_SIZE[u])&&(w=_e.WORD_SIZE[u],m=_e.stuffBits(i,w));let we=g-g%w;if(!(c&&m.getSize()>w*64)&&m.getSize()+o<=we)break}}let C=_e.generateCheckWords(m,g,w),b=m.getSize()/w,S=_e.generateModeMessage(c,u,b),T=(c?11:14)+u*4,D=new Int32Array(T),F;if(c){F=T;for(let j=0;j=i||e.get(l+u))&&(c|=1<{(function(r,a){"use strict";var s=Math.pow(2,-24),f=Math.pow(2,32),d=Math.pow(2,53);function h(y){var x=new ArrayBuffer(256),_=new DataView(x),v,R=0;function N(k){for(var G=x.byteLength,$=R+k;G<$;)G*=2;if(G!==x.byteLength){var M=_;x=new ArrayBuffer(G),_=new DataView(x);for(var ue=R+3>>2,q=0;q>6),$.push(128|M&63)):M<55296?($.push(224|M>>12),$.push(128|M>>6&63),$.push(128|M&63)):(M=(M&1023)<<10,M|=k.charCodeAt(++G)&1023,M+=65536,$.push(240|M>>18),$.push(128|M>>12&63),$.push(128|M>>6&63),$.push(128|M&63))}return L(3,$.length),U($);default:var ue;if(Array.isArray(k))for(ue=k.length,L(4,ue),G=0;G>5!==$)throw"Invalid indefinite length element";return ue}function re($,M){for(var ue=0;ue>10),$.push(56320|q&1023))}}function k(){var $=W(),M=$>>5,ue=$&31,q,xe;if(M===7)switch(ue){case 25:return K();case 26:return H();case 27:return U()}if(xe=O(ue),xe<0&&(M<2||6=0;)zt+=xe,st.push(V(xe));var Cr=new Uint8Array(zt),$e=0;for(q=0;q=0;)re(Ht,xe);else re(Ht,xe);return String.fromCharCode.apply(null,Ht);case 4:var Ye;if(xe<0)for(Ye=[];!Y();)Ye.push(k());else for(Ye=new Array(xe),q=0;q{"use strict";ts.byteLength=ld;ts.toByteArray=fd;ts.fromByteArray=dd;var sn=[],Ut=[],ad=typeof Uint8Array<"u"?Uint8Array:Array,Uo="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(Yn=0,c1=Uo.length;Yn0)throw new Error("Invalid string. Length must be a multiple of 4");var s=r.indexOf("=");s===-1&&(s=a);var f=s===a?0:4-s%4;return[s,f]}function ld(r){var a=f1(r),s=a[0],f=a[1];return(s+f)*3/4-f}function cd(r,a,s){return(a+s)*3/4-s}function fd(r){var a,s=f1(r),f=s[0],d=s[1],h=new ad(cd(r,f,d)),p=0,A=d>0?f-4:f,y;for(y=0;y>16&255,h[p++]=a>>8&255,h[p++]=a&255;return d===2&&(a=Ut[r.charCodeAt(y)]<<2|Ut[r.charCodeAt(y+1)]>>4,h[p++]=a&255),d===1&&(a=Ut[r.charCodeAt(y)]<<10|Ut[r.charCodeAt(y+1)]<<4|Ut[r.charCodeAt(y+2)]>>2,h[p++]=a>>8&255,h[p++]=a&255),h}function ud(r){return sn[r>>18&63]+sn[r>>12&63]+sn[r>>6&63]+sn[r&63]}function hd(r,a,s){for(var f,d=[],h=a;hA?A:p+h));return f===1?(a=r[s-1],d.push(sn[a>>2]+sn[a<<4&63]+"==")):f===2&&(a=(r[s-2]<<8)+r[s-1],d.push(sn[a>>10]+sn[a>>4&63]+sn[a<<2&63]+"=")),d.join("")}});var m1=Br(cl());var ee;(function(r){r[r.QR_CODE=0]="QR_CODE",r[r.AZTEC=1]="AZTEC",r[r.CODABAR=2]="CODABAR",r[r.CODE_39=3]="CODE_39",r[r.CODE_93=4]="CODE_93",r[r.CODE_128=5]="CODE_128",r[r.DATA_MATRIX=6]="DATA_MATRIX",r[r.MAXICODE=7]="MAXICODE",r[r.ITF=8]="ITF",r[r.EAN_13=9]="EAN_13",r[r.EAN_8=10]="EAN_8",r[r.PDF_417=11]="PDF_417",r[r.RSS_14=12]="RSS_14",r[r.RSS_EXPANDED=13]="RSS_EXPANDED",r[r.UPC_A=14]="UPC_A",r[r.UPC_E=15]="UPC_E",r[r.UPC_EAN_EXTENSION=16]="UPC_EAN_EXTENSION"})(ee||(ee={}));var fl=new Map([[ee.QR_CODE,"QR_CODE"],[ee.AZTEC,"AZTEC"],[ee.CODABAR,"CODABAR"],[ee.CODE_39,"CODE_39"],[ee.CODE_93,"CODE_93"],[ee.CODE_128,"CODE_128"],[ee.DATA_MATRIX,"DATA_MATRIX"],[ee.MAXICODE,"MAXICODE"],[ee.ITF,"ITF"],[ee.EAN_13,"EAN_13"],[ee.EAN_8,"EAN_8"],[ee.PDF_417,"PDF_417"],[ee.RSS_14,"RSS_14"],[ee.RSS_EXPANDED,"RSS_EXPANDED"],[ee.UPC_A,"UPC_A"],[ee.UPC_E,"UPC_E"],[ee.UPC_EAN_EXTENSION,"UPC_EAN_EXTENSION"]]),ul;(function(r){r[r.UNKNOWN=0]="UNKNOWN",r[r.URL=1]="URL"})(ul||(ul={}));function hl(r){return Object.values(ee).includes(r)}var jt;(function(r){r[r.SCAN_TYPE_CAMERA=0]="SCAN_TYPE_CAMERA",r[r.SCAN_TYPE_FILE=1]="SCAN_TYPE_FILE"})(jt||(jt={}));var _t=(function(){function r(){}return r.GITHUB_PROJECT_URL="https://github.com/mebjas/html5-qrcode",r.SCAN_DEFAULT_FPS=2,r.DEFAULT_DISABLE_FLIP=!1,r.DEFAULT_REMEMBER_LAST_CAMERA_USED=!0,r.DEFAULT_SUPPORTED_SCAN_TYPE=[jt.SCAN_TYPE_CAMERA,jt.SCAN_TYPE_FILE],r})();var Li=(function(){function r(a,s){this.format=a,this.formatName=s}return r.prototype.toString=function(){return this.formatName},r.create=function(a){if(!fl.has(a))throw"".concat(a," not in html5QrcodeSupportedFormatsTextMap");return new r(a,fl.get(a))},r})();var Js=(function(){function r(){}return r.createFromText=function(a){var s={text:a};return{decodedText:a,result:s}},r.createFromQrcodeResult=function(a){return{decodedText:a.text,result:a}},r})();var qs;(function(r){r[r.UNKWOWN_ERROR=0]="UNKWOWN_ERROR",r[r.IMPLEMENTATION_ERROR=1]="IMPLEMENTATION_ERROR",r[r.NO_CODE_FOUND_ERROR=2]="NO_CODE_FOUND_ERROR"})(qs||(qs={}));var ki=(function(){function r(){}return r.createFrom=function(a){return{errorMessage:a,type:qs.UNKWOWN_ERROR}},r})();var Pi=(function(){function r(a){this.verbose=a}return r.prototype.log=function(a){this.verbose&&console.log(a)},r.prototype.warn=function(a){this.verbose&&console.warn(a)},r.prototype.logError=function(a,s){(this.verbose||s===!0)&&console.error(a)},r.prototype.logErrors=function(a){if(a.length===0)throw"Logger#logError called without arguments";this.verbose&&console.error(a)},r})();function kt(r){return typeof r>"u"||r===null}function dl(r,a,s){return r>s?s:r0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]f&&(f=A,s=p)}if(!s)throw"No largest barcode found";return s},r.prototype.createBarcodeDetectorFormats=function(a){for(var s=[],f=0,d=a;f0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]=h&&(a.isClosed=!0,a.parentElement.removeChild(a.surface),s())})})},r.prototype.getCapabilities=function(){return new lf(this.getFirstTrackOrFail())},r})(),ml=(function(){function r(a){this.mediaStream=a}return r.prototype.render=function(a,s,f){return Ui(this,void 0,void 0,function(){return zi(this,function(d){return[2,cf.create(a,this.mediaStream,s,f)]})})},r.create=function(a){return Ui(this,void 0,void 0,function(){var s,f;return zi(this,function(d){switch(d.label){case 0:if(!navigator.mediaDevices)throw"navigator.mediaDevices not supported";return s={audio:!1,video:a},[4,navigator.mediaDevices.getUserMedia(s)];case 1:return f=d.sent(),[2,new r(f)]}})})},r})();var Cl=function(r,a,s,f){function d(h){return h instanceof s?h:new s(function(p){p(h)})}return new(s||(s=Promise))(function(h,p){function A(_){try{x(f.next(_))}catch(v){p(v)}}function y(_){try{x(f.throw(_))}catch(v){p(v)}}function x(_){_.done?h(_.value):d(_.value).then(A,y)}x((f=f.apply(r,a||[])).next())})},_l=function(r,a){var s={label:0,sent:function(){if(h[0]&1)throw h[1];return h[1]},trys:[],ops:[]},f,d,h,p;return p={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function A(x){return function(_){return y([x,_])}}function y(x){if(f)throw new TypeError("Generator is already executing.");for(;p&&(p=0,x[0]&&(s=0)),s;)try{if(f=1,d&&(h=x[0]&2?d.return:x[0]?d.throw||((h=d.return)&&h.call(d),0):d.next)&&!(h=h.call(d,x[1])).done)return h;switch(d=0,h&&(x=[x[0]&2,h.value]),x[0]){case 0:case 1:h=x;break;case 4:return s.label++,{value:x[1],done:!1};case 5:s.label++,d=x[1],x=[0];continue;case 7:x=s.ops.pop(),s.trys.pop();continue;default:if(h=s.trys,!(h=h.length>0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]a&&(d.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."),x=a),x};A(p.width),A(p.height),p.width=y(p.width)},r.prototype.validateQrboxConfig=function(a){if(typeof a!="number"&&typeof a!="function"&&(a.width===void 0||a.height===void 0))throw"Invalid instance of QrDimensions passed for 'config.qrbox'. Both 'width' and 'height' should be set."},r.prototype.toQrdimensions=function(a,s,f){if(typeof f=="number")return{width:f,height:f};if(typeof f=="function")try{return f(a,s)}catch(d){throw new Error("qrbox config was passed as a function but it failed with unknown error"+d)}return f},r.prototype.setupUi=function(a,s,f){f.isShadedBoxEnabled()&&this.validateQrboxSize(a,s,f);var d=kt(f.qrbox)?{width:a,height:s}:f.qrbox;this.validateQrboxConfig(d);var h=this.toQrdimensions(a,s,d);h.height>s&&this.logger.warn("[Html5Qrcode] config.qrbox has height that isgreater than the height of the video stream. Shading will be ignored");var p=f.isShadedBoxEnabled()&&h.height<=s,A={x:0,y:0,width:a,height:s},y=p?this.getShadedRegionBounds(a,s,h):A,x=this.createCanvasElement(y.width,y.height),_={willReadFrequently:!0},v=x.getContext("2d",_);v.canvas.width=y.width,v.canvas.height=y.height,this.element.append(x),p&&this.possiblyInsertShadingElement(this.element,a,s,h),this.createScannerPausedUiElement(this.element),this.qrRegion=y,this.context=v,this.canvasElement=x},r.prototype.createScannerPausedUiElement=function(a){var s=document.createElement("div");s.innerText=yn.scannerPaused(),s.style.display="none",s.style.position="absolute",s.style.top="0px",s.style.zIndex="1",s.style.background="rgba(9, 9, 9, 0.46)",s.style.color="#FFECEC",s.style.textAlign="center",s.style.width="100%",a.appendChild(s),this.scannerPausedUiElement=s},r.prototype.scanContext=function(a,s){var f=this;return this.stateManagerProxy.isPaused()?Promise.resolve(!1):this.qrcode.decodeAsync(this.canvasElement).then(function(d){return a(d.text,Js.createFromQrcodeResult(d)),f.possiblyUpdateShaders(!0),!0}).catch(function(d){f.possiblyUpdateShaders(!1);var h=yn.codeParseError(d);return s(h,ki.createFrom(h)),!1})},r.prototype.foreverScan=function(a,s,f){var d=this;if(this.shouldScan&&this.renderedCamera){var h=this.renderedCamera.getSurface(),p=h.videoWidth/h.clientWidth,A=h.videoHeight/h.clientHeight;if(!this.qrRegion)throw"qrRegion undefined when localMediaStream is ready.";var y=this.qrRegion.width*p,x=this.qrRegion.height*A,_=this.qrRegion.x*p,v=this.qrRegion.y*A;this.context.drawImage(h,_,v,y,x,0,0,this.qrRegion.width,this.qrRegion.height);var R=function(){d.foreverScanTimeout=setTimeout(function(){d.foreverScan(a,s,f)},d.getTimeoutFps(a.fps))};this.scanContext(s,f).then(function(N){!N&&a.disableFlip!==!0?(d.context.translate(d.context.canvas.width,0),d.context.scale(-1,1),d.scanContext(s,f).finally(function(){R()})):R()}).catch(function(N){d.logger.logError("Error happend while scanning context",N),R()})}},r.prototype.createVideoConstraints=function(a){if(typeof a=="string")return{deviceId:{exact:a}};if(typeof a=="object"){var s="facingMode",f="deviceId",d={user:!0,environment:!0},h="exact",p=function(V){if(V in d)return!0;throw"config has invalid 'facingMode' value = "+"'".concat(V,"'")},A=Object.keys(a);if(A.length!==1)throw"'cameraIdOrConfig' object should have exactly 1 key,"+" if passed as an object, found ".concat(A.length," keys");var y=Object.keys(a)[0];if(y!==s&&y!==f)throw"Only '".concat(s,"' and '").concat(f,"' ")+" are supported for 'cameraIdOrConfig'";if(y===s){var x=a.facingMode;if(typeof x=="string"){if(p(x))return{facingMode:x}}else if(typeof x=="object")if(h in x){if(p(x["".concat(h)]))return{facingMode:{exact:x["".concat(h)]}}}else throw"'facingMode' should be string or object with"+" ".concat(h," as key.");else{var _=typeof x;throw"Invalid type of 'facingMode' = ".concat(_)}}else{var v=a.deviceId;if(typeof v=="string")return{deviceId:v};if(typeof v=="object"){if(h in v)return{deviceId:{exact:v["".concat(h)]}};throw"'deviceId' should be string or object with"+" ".concat(h," as key.")}else{var R=typeof v;throw"Invalid type of 'deviceId' = ".concat(R)}}}var N=typeof a;throw"Invalid type of 'cameraIdOrConfig' = ".concat(N)},r.prototype.computeCanvasDrawConfig=function(a,s,f,d){if(a<=f&&s<=d){var h=(f-a)/2,p=(d-s)/2;return{x:h,y:p,width:a,height:s}}else{var A=a,y=s;return a>f&&(s=f/a*s,a=f),s>d&&(a=d/s*a,s=d),this.logger.log("Image downsampled from "+"".concat(A,"X").concat(y)+" to ".concat(a,"X").concat(s,".")),this.computeCanvasDrawConfig(a,s,f,d)}},r.prototype.clearElement=function(){if(this.stateManagerProxy.isScanning())throw"Cannot clear while scan is ongoing, close it first.";var a=document.getElementById(this.elementId);a&&(a.innerHTML="")},r.prototype.possiblyUpdateShaders=function(a){this.qrMatch!==a&&(this.hasBorderShaders&&this.borderShaders&&this.borderShaders.length&&this.borderShaders.forEach(function(s){s.style.backgroundColor=a?St.BORDER_SHADER_MATCH_COLOR:St.BORDER_SHADER_DEFAULT_COLOR}),this.qrMatch=a)},r.prototype.possiblyCloseLastScanImageFile=function(){this.lastScanImageFile&&(URL.revokeObjectURL(this.lastScanImageFile),this.lastScanImageFile=null)},r.prototype.createCanvasElement=function(a,s,f){var d=a,h=s,p=document.createElement("canvas");return p.style.width="".concat(d,"px"),p.style.height="".concat(h,"px"),p.style.display="none",p.id=kt(f)?"qr-canvas":f,p},r.prototype.getShadedRegionBounds=function(a,s,f){if(f.width>a||f.height>s)throw"'config.qrbox' dimensions should not be greater than the dimensions of the root HTML element.";return{x:(a-f.width)/2,y:(s-f.height)/2,width:f.width,height:f.height}},r.prototype.possiblyInsertShadingElement=function(a,s,f,d){if(!(s-d.width<1||f-d.height<1)){var h=document.createElement("div");h.style.position="absolute";var p=(s-d.width)/2,A=(f-d.height)/2;if(h.style.borderLeft="".concat(p,"px solid rgba(0, 0, 0, 0.48)"),h.style.borderRight="".concat(p,"px solid rgba(0, 0, 0, 0.48)"),h.style.borderTop="".concat(A,"px solid rgba(0, 0, 0, 0.48)"),h.style.borderBottom="".concat(A,"px solid rgba(0, 0, 0, 0.48)"),h.style.boxSizing="border-box",h.style.top="0px",h.style.bottom="0px",h.style.left="0px",h.style.right="0px",h.id="".concat(St.SHADED_REGION_ELEMENT_ID),s-d.width<11||f-d.height<11)this.hasBorderShaders=!1;else{var y=5,x=40;this.insertShaderBorders(h,x,y,-y,null,0,!0),this.insertShaderBorders(h,x,y,-y,null,0,!1),this.insertShaderBorders(h,x,y,null,-y,0,!0),this.insertShaderBorders(h,x,y,null,-y,0,!1),this.insertShaderBorders(h,y,x+y,-y,null,-y,!0),this.insertShaderBorders(h,y,x+y,null,-y,-y,!0),this.insertShaderBorders(h,y,x+y,-y,null,-y,!1),this.insertShaderBorders(h,y,x+y,null,-y,-y,!1),this.hasBorderShaders=!0}a.append(h)}},r.prototype.insertShaderBorders=function(a,s,f,d,h,p,A){var y=document.createElement("div");y.style.position="absolute",y.style.backgroundColor=St.BORDER_SHADER_DEFAULT_COLOR,y.style.width="".concat(s,"px"),y.style.height="".concat(f,"px"),d!==null&&(y.style.top="".concat(d,"px")),h!==null&&(y.style.bottom="".concat(h,"px")),A?y.style.left="".concat(p,"px"):y.style.right="".concat(p,"px"),this.borderShaders||(this.borderShaders=[]),this.borderShaders.push(y),a.appendChild(y)},r.prototype.showPausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="block"},r.prototype.hidePausedState=function(){if(!this.scannerPausedUiElement)throw"[internal error] scanner paused UI element not found";this.scannerPausedUiElement.style.display="none"},r.prototype.getTimeoutFps=function(a){return 1e3/a},r})();var io="data:image/svg+xml;base64,",Sl=io+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzNzEuNjQzIDM3MS42NDMiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDM3MS42NDMgMzcxLjY0MyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+PHBhdGggZD0iTTEwNS4wODQgMzguMjcxaDE2My43Njh2MjBIMTA1LjA4NHoiLz48cGF0aCBkPSJNMzExLjU5NiAxOTAuMTg5Yy03LjQ0MS05LjM0Ny0xOC40MDMtMTYuMjA2LTMyLjc0My0yMC41MjJWMzBjMC0xNi41NDItMTMuNDU4LTMwLTMwLTMwSDEyNS4wODRjLTE2LjU0MiAwLTMwIDEzLjQ1OC0zMCAzMHYxMjAuMTQzaC04LjI5NmMtMTYuNTQyIDAtMzAgMTMuNDU4LTMwIDMwdjEuMzMzYTI5LjgwNCAyOS44MDQgMCAwIDAgNC42MDMgMTUuOTM5Yy03LjM0IDUuNDc0LTEyLjEwMyAxNC4yMjEtMTIuMTAzIDI0LjA2MXYxLjMzM2MwIDkuODQgNC43NjMgMTguNTg3IDEyLjEwMyAyNC4wNjJhMjkuODEgMjkuODEgMCAwIDAtNC42MDMgMTUuOTM4djEuMzMzYzAgMTYuNTQyIDEzLjQ1OCAzMCAzMCAzMGg4LjMyNGMuNDI3IDExLjYzMSA3LjUwMyAyMS41ODcgMTcuNTM0IDI2LjE3Ny45MzEgMTAuNTAzIDQuMDg0IDMwLjE4NyAxNC43NjggNDUuNTM3YTkuOTg4IDkuOTg4IDAgMCAwIDguMjE2IDQuMjg4IDkuOTU4IDkuOTU4IDAgMCAwIDUuNzA0LTEuNzkzYzQuNTMzLTMuMTU1IDUuNjUtOS4zODggMi40OTUtMTMuOTIxLTYuNzk4LTkuNzY3LTkuNjAyLTIyLjYwOC0xMC43Ni0zMS40aDgyLjY4NWMuMjcyLjQxNC41NDUuODE4LjgxNSAxLjIxIDMuMTQyIDQuNTQxIDkuMzcyIDUuNjc5IDEzLjkxMyAyLjUzNCA0LjU0Mi0zLjE0MiA1LjY3Ny05LjM3MSAyLjUzNS0xMy45MTMtMTEuOTE5LTE3LjIyOS04Ljc4Ny0zNS44ODQgOS41ODEtNTcuMDEyIDMuMDY3LTIuNjUyIDEyLjMwNy0xMS43MzIgMTEuMjE3LTI0LjAzMy0uODI4LTkuMzQzLTcuMTA5LTE3LjE5NC0xOC42NjktMjMuMzM3YTkuODU3IDkuODU3IDAgMCAwLTEuMDYxLS40ODZjLS40NjYtLjE4Mi0xMS40MDMtNC41NzktOS43NDEtMTUuNzA2IDEuMDA3LTYuNzM3IDE0Ljc2OC04LjI3MyAyMy43NjYtNy42NjYgMjMuMTU2IDEuNTY5IDM5LjY5OCA3LjgwMyA0Ny44MzYgMTguMDI2IDUuNzUyIDcuMjI1IDcuNjA3IDE2LjYyMyA1LjY3MyAyOC43MzMtLjQxMyAyLjU4NS0uODI0IDUuMjQxLTEuMjQ1IDcuOTU5LTUuNzU2IDM3LjE5NC0xMi45MTkgODMuNDgzLTQ5Ljg3IDExNC42NjEtNC4yMjEgMy41NjEtNC43NTYgOS44Ny0xLjE5NCAxNC4wOTJhOS45OCA5Ljk4IDAgMCAwIDcuNjQ4IDMuNTUxIDkuOTU1IDkuOTU1IDAgMCAwIDYuNDQ0LTIuMzU4YzQyLjY3Mi0zNi4wMDUgNTAuODAyLTg4LjUzMyA1Ni43MzctMTI2Ljg4OC40MTUtMi42ODQuODIxLTUuMzA5IDEuMjI5LTcuODYzIDIuODM0LTE3LjcyMS0uNDU1LTMyLjY0MS05Ljc3Mi00NC4zNDV6bS0yMzIuMzA4IDQyLjYyYy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi0xLjMzM2MwLTUuNTE0IDQuNDg2LTEwIDEwLTEwaDE1djIxLjMzM2gtMTV6bS0yLjUtNTIuNjY2YzAtNS41MTQgNC40ODYtMTAgMTAtMTBoNy41djIxLjMzM2gtNy41Yy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi0xLjMzM3ptMTcuNSA5My45OTloLTcuNWMtNS41MTQgMC0xMC00LjQ4Ni0xMC0xMHYtMS4zMzNjMC01LjUxNCA0LjQ4Ni0xMCAxMC0xMGg3LjV2MjEuMzMzem0zMC43OTYgMjguODg3Yy01LjUxNCAwLTEwLTQuNDg2LTEwLTEwdi04LjI3MWg5MS40NTdjLS44NTEgNi42NjgtLjQzNyAxMi43ODcuNzMxIDE4LjI3MWgtODIuMTg4em03OS40ODItMTEzLjY5OGMtMy4xMjQgMjAuOTA2IDEyLjQyNyAzMy4xODQgMjEuNjI1IDM3LjA0IDUuNDQxIDIuOTY4IDcuNTUxIDUuNjQ3IDcuNzAxIDcuMTg4LjIxIDIuMTUtMi41NTMgNS42ODQtNC40NzcgNy4yNTEtLjQ4Mi4zNzgtLjkyOS44LTEuMzM1IDEuMjYxLTYuOTg3IDcuOTM2LTExLjk4MiAxNS41Mi0xNS40MzIgMjIuNjg4aC05Ny41NjRWMzBjMC01LjUxNCA0LjQ4Ni0xMCAxMC0xMGgxMjMuNzY5YzUuNTE0IDAgMTAgNC40ODYgMTAgMTB2MTM1LjU3OWMtMy4wMzItLjM4MS02LjE1LS42OTQtOS4zODktLjkxNC0yNS4xNTktMS42OTQtNDIuMzcgNy43NDgtNDQuODk4IDI0LjY2NnoiLz48cGF0aCBkPSJNMTc5LjEyOSA4My4xNjdoLTI0LjA2YTUgNSAwIDAgMC01IDV2MjQuMDYxYTUgNSAwIDAgMCA1IDVoMjQuMDZhNSA1IDAgMCAwIDUtNVY4OC4xNjdhNSA1IDAgMCAwLTUtNXpNMTcyLjYyOSAxNDIuODZoLTEyLjU2VjEzMC44YTUgNSAwIDEgMC0xMCAwdjE3LjA2MWE1IDUgMCAwIDAgNSA1aDE3LjU2YTUgNSAwIDEgMCAwLTEwLjAwMXpNMjE2LjU2OCA4My4xNjdoLTI0LjA2YTUgNSAwIDAgMC01IDV2MjQuMDYxYTUgNSAwIDAgMCA1IDVoMjQuMDZhNSA1IDAgMCAwIDUtNVY4OC4xNjdhNSA1IDAgMCAwLTUtNXptLTUgMjQuMDYxaC0xNC4wNlY5My4xNjdoMTQuMDZ2MTQuMDYxek0yMTEuNjY5IDEyNS45MzZIMTk3LjQxYTUgNSAwIDAgMC01IDV2MTQuMjU3YTUgNSAwIDAgMCA1IDVoMTQuMjU5YTUgNSAwIDAgMCA1LTV2LTE0LjI1N2E1IDUgMCAwIDAtNS01eiIvPjwvc3ZnPg==",Tl=io+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA1OS4wMTggNTkuMDE4IiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA1OS4wMTggNTkuMDE4IiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJtNTguNzQxIDU0LjgwOS01Ljk2OS02LjI0NGExMC43NCAxMC43NCAwIDAgMCAyLjgyLTcuMjVjMC01Ljk1My00Ljg0My0xMC43OTYtMTAuNzk2LTEwLjc5NlMzNCAzNS4zNjEgMzQgNDEuMzE0IDM4Ljg0MyA1Mi4xMSA0NC43OTYgNTIuMTFjMi40NDEgMCA0LjY4OC0uODI0IDYuNDk5LTIuMTk2bDYuMDAxIDYuMjc3YS45OTguOTk4IDAgMCAwIDEuNDE0LjAzMiAxIDEgMCAwIDAgLjAzMS0xLjQxNHpNMzYgNDEuMzE0YzAtNC44NSAzLjk0Ni04Ljc5NiA4Ljc5Ni04Ljc5NnM4Ljc5NiAzLjk0NiA4Ljc5NiA4Ljc5Ni0zLjk0NiA4Ljc5Ni04Ljc5NiA4Ljc5NlMzNiA0Ni4xNjQgMzYgNDEuMzE0ek0xMC40MzEgMTYuMDg4YzAgMy4wNyAyLjQ5OCA1LjU2OCA1LjU2OSA1LjU2OHM1LjU2OS0yLjQ5OCA1LjU2OS01LjU2OGMwLTMuMDcxLTIuNDk4LTUuNTY5LTUuNTY5LTUuNTY5cy01LjU2OSAyLjQ5OC01LjU2OSA1LjU2OXptOS4xMzggMGMwIDEuOTY4LTEuNjAyIDMuNTY4LTMuNTY5IDMuNTY4cy0zLjU2OS0xLjYwMS0zLjU2OS0zLjU2OCAxLjYwMi0zLjU2OSAzLjU2OS0zLjU2OSAzLjU2OSAxLjYwMSAzLjU2OSAzLjU2OXoiLz48cGF0aCBkPSJtMzAuODgyIDI4Ljk4NyA5LjE4LTEwLjA1NCAxMS4yNjIgMTAuMzIzYTEgMSAwIDAgMCAxLjM1MS0xLjQ3NWwtMTItMTFhMSAxIDAgMCAwLTEuNDE0LjA2M2wtOS43OTQgMTAuNzI3LTQuNzQzLTQuNzQzYTEuMDAzIDEuMDAzIDAgMCAwLTEuMzY4LS4wNDRMNi4zMzkgMzcuNzY4YTEgMSAwIDEgMCAxLjMyMiAxLjUwMWwxNi4zMTMtMTQuMzYyIDcuMzE5IDcuMzE4YS45OTkuOTk5IDAgMSAwIDEuNDE0LTEuNDE0bC0xLjgyNS0xLjgyNHoiLz48cGF0aCBkPSJNMzAgNDYuNTE4SDJ2LTQyaDU0djI4YTEgMSAwIDEgMCAyIDB2LTI5YTEgMSAwIDAgMC0xLTFIMWExIDEgMCAwIDAtMSAxdjQ0YTEgMSAwIDAgMCAxIDFoMjlhMSAxIDAgMSAwIDAtMnoiLz48L3N2Zz4=",so=io+"PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0NjAgNDYwIiBzdHlsZT0iZW5hYmxlLWJhY2tncm91bmQ6bmV3IDAgMCA0NjAgNDYwIiB4bWw6c3BhY2U9InByZXNlcnZlIj48cGF0aCBkPSJNMjMwIDBDMTAyLjk3NSAwIDAgMTAyLjk3NSAwIDIzMHMxMDIuOTc1IDIzMCAyMzAgMjMwIDIzMC0xMDIuOTc0IDIzMC0yMzBTMzU3LjAyNSAwIDIzMCAwem0zOC4zMzMgMzc3LjM2YzAgOC42NzYtNy4wMzQgMTUuNzEtMTUuNzEgMTUuNzFoLTQzLjEwMWMtOC42NzYgMC0xNS43MS03LjAzNC0xNS43MS0xNS43MVYyMDIuNDc3YzAtOC42NzYgNy4wMzMtMTUuNzEgMTUuNzEtMTUuNzFoNDMuMTAxYzguNjc2IDAgMTUuNzEgNy4wMzMgMTUuNzEgMTUuNzFWMzc3LjM2ek0yMzAgMTU3Yy0yMS41MzkgMC0zOS0xNy40NjEtMzktMzlzMTcuNDYxLTM5IDM5LTM5IDM5IDE3LjQ2MSAzOSAzOS0xNy40NjEgMzktMzkgMzl6Ii8+PC9zdmc+",Nl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAAQgAAAEIBarqQRAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAE1SURBVDiNfdI7S0NBEAXgLya1otFgpbYSbISAgpXYi6CmiH9KCAiChaVga6OiWPgfRDQ+0itaGVNosXtluWwcuMzePfM4M3sq8lbHBubwg1dc4m1E/J/N4ghDPOIsfk/4xiEao5KX0McFljN4C9d4QTPXuY99jP3DsIoDPGM6BY5i5yI5R7O4q+ImFkJY2DCh3cAH2klyB+9J1xUMMAG7eCh1a+Mr+k48b5diXrFVwwLuS+BJ9MfR7+G0FHOHhTHhnXNWS87VDF4pcnfQK4Ep7XScNLmPTZgURNKKYENYWDpzW1BhscS1WHS8CDgURFJQrWcoF3c13KKbgg1BYQfy8xZWEzTTw1QZbAoKu8FqJnktdu5hcVSHmchiILzzuaDQvjBzV2m8yohCE1jHfPx/xhU+y4G/D75ELlRJsSYAAAAASUVORK5CYII=";var Ml=(function(){function r(){}return r.createDefault=function(){return{hasPermission:!1,lastUsedCameraId:null}},r})(),Ol=(function(){function r(){this.data=Ml.createDefault();var a=localStorage.getItem(r.LOCAL_STORAGE_KEY);a?this.data=JSON.parse(a):this.reset()}return r.prototype.hasCameraPermissions=function(){return this.data.hasPermission},r.prototype.getLastUsedCameraId=function(){return this.data.lastUsedCameraId},r.prototype.setHasPermission=function(a){this.data.hasPermission=a,this.flush()},r.prototype.setLastUsedCameraId=function(a){this.data.lastUsedCameraId=a,this.flush()},r.prototype.resetLastUsedCameraId=function(){this.data.lastUsedCameraId=null,this.flush()},r.prototype.reset=function(){this.data=Ml.createDefault(),this.flush()},r.prototype.flush=function(){localStorage.setItem(r.LOCAL_STORAGE_KEY,JSON.stringify(this.data))},r.LOCAL_STORAGE_KEY="HTML5_QRCODE_DATA",r})();var wf=(function(){function r(){this.infoDiv=document.createElement("div")}return r.prototype.renderInto=function(a){this.infoDiv.style.position="absolute",this.infoDiv.style.top="10px",this.infoDiv.style.right="10px",this.infoDiv.style.zIndex="2",this.infoDiv.style.display="none",this.infoDiv.style.padding="5pt",this.infoDiv.style.border="1px solid #171717",this.infoDiv.style.fontSize="10pt",this.infoDiv.style.background="rgb(0 0 0 / 69%)",this.infoDiv.style.borderRadius="5px",this.infoDiv.style.textAlign="center",this.infoDiv.style.fontWeight="400",this.infoDiv.style.color="white",this.infoDiv.innerText=$s.poweredBy();var s=document.createElement("a");s.innerText="ScanApp",s.href="https://scanapp.org",s.target="new",s.style.color="white",this.infoDiv.appendChild(s);var f=document.createElement("br"),d=document.createElement("br");this.infoDiv.appendChild(f),this.infoDiv.appendChild(d);var h=document.createElement("a");h.innerText=$s.reportIssues(),h.href="https://github.com/mebjas/html5-qrcode/issues",h.target="new",h.style.color="white",this.infoDiv.appendChild(h),a.appendChild(this.infoDiv)},r.prototype.show=function(){this.infoDiv.style.display="block"},r.prototype.hide=function(){this.infoDiv.style.display="none"},r})(),pf=(function(){function r(a,s){this.isShowingInfoIcon=!0,this.onTapIn=a,this.onTapOut=s,this.infoIcon=document.createElement("img")}return r.prototype.renderInto=function(a){var s=this;this.infoIcon.alt="Info icon",this.infoIcon.src=so,this.infoIcon.style.position="absolute",this.infoIcon.style.top="4px",this.infoIcon.style.right="4px",this.infoIcon.style.opacity="0.6",this.infoIcon.style.cursor="pointer",this.infoIcon.style.zIndex="2",this.infoIcon.style.width="16px",this.infoIcon.style.height="16px",this.infoIcon.onmouseover=function(f){return s.onHoverIn()},this.infoIcon.onmouseout=function(f){return s.onHoverOut()},this.infoIcon.onclick=function(f){return s.onClick()},a.appendChild(this.infoIcon)},r.prototype.onHoverIn=function(){this.isShowingInfoIcon&&(this.infoIcon.style.opacity="1")},r.prototype.onHoverOut=function(){this.isShowingInfoIcon&&(this.infoIcon.style.opacity="0.6")},r.prototype.onClick=function(){this.isShowingInfoIcon?(this.isShowingInfoIcon=!1,this.onTapIn(),this.infoIcon.src=Nl,this.infoIcon.style.opacity="1"):(this.isShowingInfoIcon=!0,this.onTapOut(),this.infoIcon.src=so,this.infoIcon.style.opacity="0.6")},r})(),Rl=(function(){function r(){var a=this;this.infoDiv=new wf,this.infoIcon=new pf(function(){a.infoDiv.show()},function(){a.infoDiv.hide()})}return r.prototype.renderInto=function(a){this.infoDiv.renderInto(a),this.infoIcon.renderInto(a)},r})();var Af=function(r,a,s,f){function d(h){return h instanceof s?h:new s(function(p){p(h)})}return new(s||(s=Promise))(function(h,p){function A(_){try{x(f.next(_))}catch(v){p(v)}}function y(_){try{x(f.throw(_))}catch(v){p(v)}}function x(_){_.done?h(_.value):d(_.value).then(A,y)}x((f=f.apply(r,a||[])).next())})},Ef=function(r,a){var s={label:0,sent:function(){if(h[0]&1)throw h[1];return h[1]},trys:[],ops:[]},f,d,h,p;return p={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(p[Symbol.iterator]=function(){return this}),p;function A(x){return function(_){return y([x,_])}}function y(x){if(f)throw new TypeError("Generator is already executing.");for(;p&&(p=0,x[0]&&(s=0)),s;)try{if(f=1,d&&(h=x[0]&2?d.return:x[0]?d.throw||((h=d.return)&&h.call(d),0):d.next)&&!(h=h.call(d,x[1])).done)return h;switch(d=0,h&&(x=[x[0]&2,h.value]),x[0]){case 0:case 1:h=x;break;case 4:return s.label++,{value:x[1],done:!1};case 5:s.label++,d=x[1],x=[0];continue;case 7:x=s.ops.pop(),s.trys.pop();continue;default:if(h=s.trys,!(h=h.length>0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]1},r.prototype.isCameraScanRequired=function(){for(var a=0,s=this.supportedScanTypes;as)throw"Max ".concat(s," values expected for ")+"supportedScanTypes";for(var f=0,d=a;f0&&h[h.length-1])&&(x[0]===6||x[0]===2)){s=0;continue}if(x[0]===3&&(!h||x[1]>h[0]&&x[1]s){var f=a.substring(0,8),d=a.length,h=a.substring(d-8,d);a="".concat(f,"....").concat(h)}var p=Ee.fileSelectionChooseAnother()+" - "+a;this.fileSelectionButton.innerText=p},r.prototype.setInitialValueToButton=function(){var a=Ee.fileSelectionChooseImage()+" - "+Ee.fileSelectionNoImageSelected();this.fileSelectionButton.innerText=a},r.prototype.getFileScanInputId=function(){return"html5-qrcode-private-filescan-input"},r.create=function(a,s,f){var d=new r(a,s,f);return d},r})();var Pl=(function(){function r(a){this.selectElement=yt.createElement("select",rt.CAMERA_SELECTION_SELECT_ID),this.cameras=a,this.options=[]}return r.prototype.render=function(a){var s=document.createElement("span");s.style.marginRight="10px";var f=this.cameras.length;if(f===0)throw new Error("No cameras found");if(f===1)s.style.display="none";else{var d=Ee.selectCamera();s.innerText="".concat(d," (").concat(this.cameras.length,") ")}for(var h=1,p=0,A=this.cameras;p0?(a.removeChild(s),d.renderCameraSelection(p)):(d.setHeaderMessage(Ee.noCameraFound(),Tt.STATUS_WARNING),h())}).catch(function(p){d.persistedDataManager.setHasPermission(!1),f?f.disabled=!1:h(),d.setHeaderMessage(p,Tt.STATUS_WARNING),d.showHideScanTypeSwapLink(!0)})},r.prototype.createPermissionButton=function(a,s){var f=this,d=yt.createElement("button",this.getCameraPermissionButtonId());d.innerText=Ee.cameraPermissionTitle(),d.addEventListener("click",function(){d.disabled=!0,f.createCameraListUi(a,s,d)}),s.appendChild(d)},r.prototype.createPermissionsUi=function(a,s){var f=this;if(ln.isCameraScanType(this.currentScanType)&&this.persistedDataManager.hasCameraPermissions()){oo.hasPermissions().then(function(d){d?f.createCameraListUi(a,s):(f.persistedDataManager.setHasPermission(!1),f.createPermissionButton(a,s))}).catch(function(d){f.persistedDataManager.setHasPermission(!1),f.createPermissionButton(a,s)});return}this.createPermissionButton(a,s)},r.prototype.createSectionControlPanel=function(){var a=document.getElementById(this.getDashboardSectionId()),s=document.createElement("div");a.appendChild(s);var f=document.createElement("div");f.id=this.getDashboardSectionCameraScanRegionId(),f.style.display=ln.isCameraScanType(this.currentScanType)?"block":"none",s.appendChild(f);var d=document.createElement("div");d.style.textAlign="center",f.appendChild(d),this.scanTypeSelector.isCameraScanRequired()&&this.createPermissionsUi(f,d),this.renderFileScanUi(s)},r.prototype.renderFileScanUi=function(a){var s=ln.isFileScanType(this.currentScanType),f=this,d=function(h){if(!f.html5Qrcode)throw"html5Qrcode not defined";ln.isFileScanType(f.currentScanType)&&(f.setHeaderMessage(Ee.loadingImage()),f.html5Qrcode.scanFileV2(h,!0).then(function(p){f.resetHeaderMessage(),f.qrCodeSuccessCallback(p.decodedText,p)}).catch(function(p){f.setHeaderMessage(p,Tt.STATUS_WARNING),f.qrCodeErrorCallback(p,ki.createFrom(p))}))};this.fileSelectionUi=kl.create(a,s,d)},r.prototype.renderCameraSelection=function(a){var s=this,f=this,d=document.getElementById(this.getDashboardSectionCameraScanRegionId());d.style.textAlign="center";var h=Fl.create(d,!1),p=function(K){var H=K.zoomFeature();if(H.isSupported()){h.setOnCameraZoomValueChangeCallback(function(W){H.apply(W)});var U=1;s.config.defaultZoomValueIfSupported&&(U=s.config.defaultZoomValueIfSupported),U=dl(U,H.min(),H.max()),h.setValues(H.min(),H.max(),U,H.step()),h.show()}},A=Pl.create(d,a),y=document.createElement("span"),x=yt.createElement("button",rt.CAMERA_START_BUTTON_ID);x.innerText=Ee.scanButtonStartScanningText(),y.appendChild(x);var _=yt.createElement("button",rt.CAMERA_STOP_BUTTON_ID);_.innerText=Ee.scanButtonStopScanningText(),_.style.display="none",_.disabled=!0,y.appendChild(_);var v,R=function(K){if(!K.torchFeature().isSupported()){v&&v.hide();return}v?v.updateTorchCapability(K.torchFeature()):v=Ll.create(y,K.torchFeature(),{display:"none",marginLeft:"5px"},function(H){f.setHeaderMessage(H,Tt.STATUS_WARNING)}),v.show()};d.appendChild(y);var N=function(K){K||(x.style.display="none"),x.innerText=Ee.scanButtonStartScanningText(),x.style.opacity="1",x.disabled=!1,K&&(x.style.display="inline-block")};if(x.addEventListener("click",function(K){x.innerText=Ee.scanButtonScanningStarting(),A.disable(),x.disabled=!0,x.style.opacity="0.5",s.scanTypeSelector.hasMoreThanOneScanType()&&f.showHideScanTypeSwapLink(!1),f.resetHeaderMessage();var H=A.getValue();f.persistedDataManager.setLastUsedCameraId(H),f.html5Qrcode.start(H,mf(f.config),f.qrCodeSuccessCallback,f.qrCodeErrorCallback).then(function(U){_.disabled=!1,_.style.display="inline-block",N(!1);var W=f.html5Qrcode.getRunningTrackCameraCapabilities();s.config.showTorchButtonIfSupported===!0&&R(W),s.config.showZoomSliderIfSupported===!0&&p(W)}).catch(function(U){f.showHideScanTypeSwapLink(!0),A.enable(),N(!0),f.setHeaderMessage(U,Tt.STATUS_WARNING)})}),A.hasSingleItem()&&x.click(),_.addEventListener("click",function(K){if(!f.html5Qrcode)throw"html5Qrcode not defined";_.disabled=!0,f.html5Qrcode.stop().then(function(H){s.scanTypeSelector.hasMoreThanOneScanType()&&f.showHideScanTypeSwapLink(!0),A.enable(),x.disabled=!1,_.style.display="none",x.style.display="inline-block",v&&(v.reset(),v.hide()),h.removeOnCameraZoomValueChangeCallback(),h.hide(),f.insertCameraScanImageToScanRegion()}).catch(function(H){_.disabled=!1,f.setHeaderMessage(H,Tt.STATUS_WARNING)})}),f.persistedDataManager.getLastUsedCameraId()){var V=f.persistedDataManager.getLastUsedCameraId();A.hasValue(V)?(A.setValue(V),x.click()):f.persistedDataManager.resetLastUsedCameraId()}},r.prototype.createSectionSwap=function(){var a=this,s=Ee.textIfCameraScanSelected(),f=Ee.textIfFileScanSelected(),d=document.getElementById(this.getDashboardSectionId()),h=document.createElement("div");h.style.textAlign="center";var p=yt.createElement("span",this.getDashboardSectionSwapLinkId());p.style.textDecoration="underline",p.style.cursor="pointer",p.innerText=ln.isCameraScanType(this.currentScanType)?s:f,p.addEventListener("click",function(){if(!a.sectionSwapAllowed){a.verbose&&a.logger.logError("Section swap called when not allowed");return}a.resetHeaderMessage(),a.fileSelectionUi.resetValue(),a.sectionSwapAllowed=!1,ln.isCameraScanType(a.currentScanType)?(a.clearScanRegion(),a.getCameraScanRegion().style.display="none",a.fileSelectionUi.show(),p.innerText=f,a.currentScanType=jt.SCAN_TYPE_FILE,a.insertFileScanImageToScanRegion()):(a.clearScanRegion(),a.getCameraScanRegion().style.display="block",a.fileSelectionUi.hide(),p.innerText=s,a.currentScanType=jt.SCAN_TYPE_CAMERA,a.insertCameraScanImageToScanRegion(),a.startCameraScanIfPermissionExistsOnSwap()),a.sectionSwapAllowed=!0}),h.appendChild(p),d.appendChild(h)},r.prototype.startCameraScanIfPermissionExistsOnSwap=function(){var a=this,s=this;if(this.persistedDataManager.hasCameraPermissions()){oo.hasPermissions().then(function(f){if(f){var d=document.getElementById(s.getCameraPermissionButtonId());if(!d)throw a.logger.logError("Permission button not found, fail;"),"Permission button not found";d.click()}else s.persistedDataManager.setHasPermission(!1)}).catch(function(f){s.persistedDataManager.setHasPermission(!1)});return}},r.prototype.resetHeaderMessage=function(){var a=document.getElementById(this.getHeaderMessageContainerId());a.style.display="none"},r.prototype.setHeaderMessage=function(a,s){s||(s=Tt.STATUS_DEFAULT);var f=this.getHeaderMessageDiv();switch(f.innerText=a,f.style.display="block",s){case Tt.STATUS_SUCCESS:f.style.background="rgba(106, 175, 80, 0.26)",f.style.color="#477735";break;case Tt.STATUS_WARNING:f.style.background="rgba(203, 36, 49, 0.14)",f.style.color="#cb2431";break;case Tt.STATUS_DEFAULT:default:f.style.background="rgba(0, 0, 0, 0)",f.style.color="rgb(17, 17, 17)";break}},r.prototype.showHideScanTypeSwapLink=function(a){this.scanTypeSelector.hasMoreThanOneScanType()&&(a!==!0&&(a=!1),this.sectionSwapAllowed=a,this.getDashboardSectionSwapLink().style.display=a?"inline-block":"none")},r.prototype.insertCameraScanImageToScanRegion=function(){var a=this,s=document.getElementById(this.getScanRegionId());if(this.cameraScanImage){s.innerHTML="
",s.appendChild(this.cameraScanImage);return}this.cameraScanImage=new Image,this.cameraScanImage.onload=function(f){s.innerHTML="
",s.appendChild(a.cameraScanImage)},this.cameraScanImage.width=64,this.cameraScanImage.style.opacity="0.8",this.cameraScanImage.src=Sl,this.cameraScanImage.alt=Ee.cameraScanAltText()},r.prototype.insertFileScanImageToScanRegion=function(){var a=this,s=document.getElementById(this.getScanRegionId());if(this.fileScanImage){s.innerHTML="
",s.appendChild(this.fileScanImage);return}this.fileScanImage=new Image,this.fileScanImage.onload=function(f){s.innerHTML="
",s.appendChild(a.fileScanImage)},this.fileScanImage.width=64,this.fileScanImage.style.opacity="0.8",this.fileScanImage.src=Tl,this.fileScanImage.alt=Ee.fileScanAltText()},r.prototype.clearScanRegion=function(){var a=document.getElementById(this.getScanRegionId());a.innerHTML=""},r.prototype.getDashboardSectionId=function(){return"".concat(this.elementId,"__dashboard_section")},r.prototype.getDashboardSectionCameraScanRegionId=function(){return"".concat(this.elementId,"__dashboard_section_csr")},r.prototype.getDashboardSectionSwapLinkId=function(){return rt.SCAN_TYPE_CHANGE_ANCHOR_ID},r.prototype.getScanRegionId=function(){return"".concat(this.elementId,"__scan_region")},r.prototype.getDashboardId=function(){return"".concat(this.elementId,"__dashboard")},r.prototype.getHeaderMessageContainerId=function(){return"".concat(this.elementId,"__header_message")},r.prototype.getCameraPermissionButtonId=function(){return rt.CAMERA_PERMISSION_BUTTON_ID},r.prototype.getCameraScanRegion=function(){return document.getElementById(this.getDashboardSectionCameraScanRegionId())},r.prototype.getDashboardSectionSwapLink=function(){return document.getElementById(this.getDashboardSectionSwapLinkId())},r.prototype.getHeaderMessageDiv=function(){return document.getElementById(this.getHeaderMessageContainerId())},r})();function xr(r){let a=r.length;for(;--a>=0;)r[a]=0}var yf=0,yc=1,If=2,bf=3,Sf=258,Ro=29,ri=256,Qr=ri+1+Ro,hr=30,Do=19,Ic=2*Qr+1,Un=15,ao=16,Tf=7,vo=256,bc=16,Sc=17,Tc=18,_o=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Yi=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),Nf=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Nc=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Mf=512,fn=new Array((Qr+2)*2);xr(fn);var Yr=new Array(hr*2);xr(Yr);var Kr=new Array(Mf);xr(Kr);var qr=new Array(Sf-bf+1);xr(qr);var Bo=new Array(Ro);xr(Bo);var Wi=new Array(hr);xr(Wi);function lo(r,a,s,f,d){this.static_tree=r,this.extra_bits=a,this.extra_base=s,this.elems=f,this.max_length=d,this.has_stree=r&&r.length}var Mc,Oc,Rc;function co(r,a){this.dyn_tree=r,this.max_code=0,this.stat_desc=a}var Dc=r=>r<256?Kr[r]:Kr[256+(r>>>7)],Jr=(r,a)=>{r.pending_buf[r.pending++]=a&255,r.pending_buf[r.pending++]=a>>>8&255},It=(r,a,s)=>{r.bi_valid>ao-s?(r.bi_buf|=a<>ao-r.bi_valid,r.bi_valid+=s-ao):(r.bi_buf|=a<{It(r,s[a*2],s[a*2+1])},vc=(r,a)=>{let s=0;do s|=r&1,r>>>=1,s<<=1;while(--a>0);return s>>>1},Of=r=>{r.bi_valid===16?(Jr(r,r.bi_buf),r.bi_buf=0,r.bi_valid=0):r.bi_valid>=8&&(r.pending_buf[r.pending++]=r.bi_buf&255,r.bi_buf>>=8,r.bi_valid-=8)},Rf=(r,a)=>{let s=a.dyn_tree,f=a.max_code,d=a.stat_desc.static_tree,h=a.stat_desc.has_stree,p=a.stat_desc.extra_bits,A=a.stat_desc.extra_base,y=a.stat_desc.max_length,x,_,v,R,N,V,K=0;for(R=0;R<=Un;R++)r.bl_count[R]=0;for(s[r.heap[r.heap_max]*2+1]=0,x=r.heap_max+1;xy&&(R=y,K++),s[_*2+1]=R,!(_>f)&&(r.bl_count[R]++,N=0,_>=A&&(N=p[_-A]),V=s[_*2],r.opt_len+=V*(R+N),h&&(r.static_len+=V*(d[_*2+1]+N)));if(K!==0){do{for(R=y-1;r.bl_count[R]===0;)R--;r.bl_count[R]--,r.bl_count[R+1]+=2,r.bl_count[y]--,K-=2}while(K>0);for(R=y;R!==0;R--)for(_=r.bl_count[R];_!==0;)v=r.heap[--x],!(v>f)&&(s[v*2+1]!==R&&(r.opt_len+=(R-s[v*2+1])*s[v*2],s[v*2+1]=R),_--)}},Bc=(r,a,s)=>{let f=new Array(Un+1),d=0,h,p;for(h=1;h<=Un;h++)d=d+s[h-1]<<1,f[h]=d;for(p=0;p<=a;p++){let A=r[p*2+1];A!==0&&(r[p*2]=vc(f[A]++,A))}},Df=()=>{let r,a,s,f,d,h=new Array(Un+1);for(s=0,f=0;f>=7;f{let a;for(a=0;a{r.bi_valid>8?Jr(r,r.bi_buf):r.bi_valid>0&&(r.pending_buf[r.pending++]=r.bi_buf),r.bi_buf=0,r.bi_valid=0},Ul=(r,a,s,f)=>{let d=a*2,h=s*2;return r[d]{let f=r.heap[s],d=s<<1;for(;d<=r.heap_len&&(d{let f,d,h=0,p,A;if(r.sym_next!==0)do f=r.pending_buf[r.sym_buf+h++]&255,f+=(r.pending_buf[r.sym_buf+h++]&255)<<8,d=r.pending_buf[r.sym_buf+h++],f===0?tn(r,d,a):(p=qr[d],tn(r,p+ri+1,a),A=_o[p],A!==0&&(d-=Bo[p],It(r,d,A)),f--,p=Dc(f),tn(r,p,s),A=Yi[p],A!==0&&(f-=Wi[p],It(r,f,A)));while(h{let s=a.dyn_tree,f=a.stat_desc.static_tree,d=a.stat_desc.has_stree,h=a.stat_desc.elems,p,A,y=-1,x;for(r.heap_len=0,r.heap_max=Ic,p=0;p>1;p>=1;p--)fo(r,s,p);x=h;do p=r.heap[1],r.heap[1]=r.heap[r.heap_len--],fo(r,s,1),A=r.heap[1],r.heap[--r.heap_max]=p,r.heap[--r.heap_max]=A,s[x*2]=s[p*2]+s[A*2],r.depth[x]=(r.depth[p]>=r.depth[A]?r.depth[p]:r.depth[A])+1,s[p*2+1]=s[A*2+1]=x,r.heap[1]=x++,fo(r,s,1);while(r.heap_len>=2);r.heap[--r.heap_max]=r.heap[1],Rf(r,a),Bc(s,y,r.bl_count)},Hl=(r,a,s)=>{let f,d=-1,h,p=a[1],A=0,y=7,x=4;for(p===0&&(y=138,x=3),a[(s+1)*2+1]=65535,f=0;f<=s;f++)h=p,p=a[(f+1)*2+1],!(++A{let f,d=-1,h,p=a[1],A=0,y=7,x=4;for(p===0&&(y=138,x=3),f=0;f<=s;f++)if(h=p,p=a[(f+1)*2+1],!(++A{let a;for(Hl(r,r.dyn_ltree,r.l_desc.max_code),Hl(r,r.dyn_dtree,r.d_desc.max_code),yo(r,r.bl_desc),a=Do-1;a>=3&&r.bl_tree[Nc[a]*2+1]===0;a--);return r.opt_len+=3*(a+1)+5+5+4,a},Bf=(r,a,s,f)=>{let d;for(It(r,a-257,5),It(r,s-1,5),It(r,f-4,4),d=0;d{let a=4093624447,s;for(s=0;s<=31;s++,a>>>=1)if(a&1&&r.dyn_ltree[s*2]!==0)return 0;if(r.dyn_ltree[18]!==0||r.dyn_ltree[20]!==0||r.dyn_ltree[26]!==0)return 1;for(s=32;s{Xl||(Df(),Xl=!0),r.l_desc=new co(r.dyn_ltree,Mc),r.d_desc=new co(r.dyn_dtree,Oc),r.bl_desc=new co(r.bl_tree,Rc),r.bi_buf=0,r.bi_valid=0,Lc(r)},Pc=(r,a,s,f)=>{It(r,(yf<<1)+(f?1:0),3),kc(r),Jr(r,s),Jr(r,~s),s&&r.pending_buf.set(r.window.subarray(a,a+s),r.pending),r.pending+=s},Pf=r=>{It(r,yc<<1,3),tn(r,vo,fn),Of(r)},Ff=(r,a,s,f)=>{let d,h,p=0;r.level>0?(r.strm.data_type===2&&(r.strm.data_type=Lf(r)),yo(r,r.l_desc),yo(r,r.d_desc),p=vf(r),d=r.opt_len+3+7>>>3,h=r.static_len+3+7>>>3,h<=d&&(d=h)):d=h=s+5,s+4<=d&&a!==-1?Pc(r,a,s,f):r.strategy===4||h===d?(It(r,(yc<<1)+(f?1:0),3),zl(r,fn,Yr)):(It(r,(If<<1)+(f?1:0),3),Bf(r,r.l_desc.max_code+1,r.d_desc.max_code+1,p+1),zl(r,r.dyn_ltree,r.dyn_dtree)),Lc(r),f&&kc(r)},Uf=(r,a,s)=>(r.pending_buf[r.sym_buf+r.sym_next++]=a,r.pending_buf[r.sym_buf+r.sym_next++]=a>>8,r.pending_buf[r.sym_buf+r.sym_next++]=s,a===0?r.dyn_ltree[s*2]++:(r.matches++,a--,r.dyn_ltree[(qr[s]+ri+1)*2]++,r.dyn_dtree[Dc(a)*2]++),r.sym_next===r.sym_end),zf=kf,Hf=Pc,Vf=Ff,Xf=Uf,Gf=Pf,jf={_tr_init:zf,_tr_stored_block:Hf,_tr_flush_block:Vf,_tr_tally:Xf,_tr_align:Gf},Yf=(r,a,s,f)=>{let d=r&65535|0,h=r>>>16&65535|0,p=0;for(;s!==0;){p=s>2e3?2e3:s,s-=p;do d=d+a[f++]|0,h=h+d|0;while(--p);d%=65521,h%=65521}return d|h<<16|0},$r=Yf,Wf=()=>{let r,a=[];for(var s=0;s<256;s++){r=s;for(var f=0;f<8;f++)r=r&1?3988292384^r>>>1:r>>>1;a[s]=r}return a},Zf=new Uint32Array(Wf()),Qf=(r,a,s,f)=>{let d=Zf,h=f+s;r^=-1;for(let p=f;p>>8^d[(r^a[p])&255];return r^-1},it=Qf,Vn={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},wr={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8},{_tr_init:Kf,_tr_stored_block:Io,_tr_flush_block:qf,_tr_tally:Sn,_tr_align:Jf}=jf,{Z_NO_FLUSH:Tn,Z_PARTIAL_FLUSH:$f,Z_FULL_FLUSH:eu,Z_FINISH:Pt,Z_BLOCK:Gl,Z_OK:ft,Z_STREAM_END:jl,Z_STREAM_ERROR:nn,Z_DATA_ERROR:tu,Z_BUF_ERROR:uo,Z_DEFAULT_COMPRESSION:nu,Z_FILTERED:ru,Z_HUFFMAN_ONLY:Hi,Z_RLE:iu,Z_FIXED:su,Z_DEFAULT_STRATEGY:ou,Z_UNKNOWN:au,Z_DEFLATED:Ki}=wr,lu=9,cu=15,fu=8,uu=29,hu=256,bo=hu+1+uu,du=30,gu=19,xu=2*bo+1,wu=15,Ae=3,bn=258,rn=bn+Ae+1,pu=32,dr=42,Lo=57,So=69,To=73,No=91,Mo=103,zn=113,Gr=666,xt=1,pr=2,Xn=3,Ar=4,Au=3,Hn=(r,a)=>(r.msg=Vn[a],a),Yl=r=>r*2-(r>4?9:0),In=r=>{let a=r.length;for(;--a>=0;)r[a]=0},Eu=r=>{let a,s,f,d=r.w_size;a=r.hash_size,f=a;do s=r.head[--f],r.head[f]=s>=d?s-d:0;while(--a);a=d,f=a;do s=r.prev[--f],r.prev[f]=s>=d?s-d:0;while(--a)},mu=(r,a,s)=>(a<{let a=r.state,s=a.pending;s>r.avail_out&&(s=r.avail_out),s!==0&&(r.output.set(a.pending_buf.subarray(a.pending_out,a.pending_out+s),r.next_out),r.next_out+=s,a.pending_out+=s,r.total_out+=s,r.avail_out-=s,a.pending-=s,a.pending===0&&(a.pending_out=0))},Mt=(r,a)=>{qf(r,r.block_start>=0?r.block_start:-1,r.strstart-r.block_start,a),r.block_start=r.strstart,Nt(r.strm)},Te=(r,a)=>{r.pending_buf[r.pending++]=a},Xr=(r,a)=>{r.pending_buf[r.pending++]=a>>>8&255,r.pending_buf[r.pending++]=a&255},Oo=(r,a,s,f)=>{let d=r.avail_in;return d>f&&(d=f),d===0?0:(r.avail_in-=d,a.set(r.input.subarray(r.next_in,r.next_in+d),s),r.state.wrap===1?r.adler=$r(r.adler,a,d,s):r.state.wrap===2&&(r.adler=it(r.adler,a,d,s)),r.next_in+=d,r.total_in+=d,d)},Fc=(r,a)=>{let s=r.max_chain_length,f=r.strstart,d,h,p=r.prev_length,A=r.nice_match,y=r.strstart>r.w_size-rn?r.strstart-(r.w_size-rn):0,x=r.window,_=r.w_mask,v=r.prev,R=r.strstart+bn,N=x[f+p-1],V=x[f+p];r.prev_length>=r.good_match&&(s>>=2),A>r.lookahead&&(A=r.lookahead);do if(d=a,!(x[d+p]!==V||x[d+p-1]!==N||x[d]!==x[f]||x[++d]!==x[f+1])){f+=2,d++;do;while(x[++f]===x[++d]&&x[++f]===x[++d]&&x[++f]===x[++d]&&x[++f]===x[++d]&&x[++f]===x[++d]&&x[++f]===x[++d]&&x[++f]===x[++d]&&x[++f]===x[++d]&&fp){if(r.match_start=a,p=h,h>=A)break;N=x[f+p-1],V=x[f+p]}}while((a=v[a&_])>y&&--s!==0);return p<=r.lookahead?p:r.lookahead},gr=r=>{let a=r.w_size,s,f,d;do{if(f=r.window_size-r.lookahead-r.strstart,r.strstart>=a+(a-rn)&&(r.window.set(r.window.subarray(a,a+a-f),0),r.match_start-=a,r.strstart-=a,r.block_start-=a,r.insert>r.strstart&&(r.insert=r.strstart),Eu(r),f+=a),r.strm.avail_in===0)break;if(s=Oo(r.strm,r.window,r.strstart+r.lookahead,f),r.lookahead+=s,r.lookahead+r.insert>=Ae)for(d=r.strstart-r.insert,r.ins_h=r.window[d],r.ins_h=Nn(r,r.ins_h,r.window[d+1]);r.insert&&(r.ins_h=Nn(r,r.ins_h,r.window[d+Ae-1]),r.prev[d&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=d,d++,r.insert--,!(r.lookahead+r.insert{let s=r.pending_buf_size-5>r.w_size?r.w_size:r.pending_buf_size-5,f,d,h,p=0,A=r.strm.avail_in;do{if(f=65535,h=r.bi_valid+42>>3,r.strm.avail_outd+r.strm.avail_in&&(f=d+r.strm.avail_in),f>h&&(f=h),f>8,r.pending_buf[r.pending-2]=~f,r.pending_buf[r.pending-1]=~f>>8,Nt(r.strm),d&&(d>f&&(d=f),r.strm.output.set(r.window.subarray(r.block_start,r.block_start+d),r.strm.next_out),r.strm.next_out+=d,r.strm.avail_out-=d,r.strm.total_out+=d,r.block_start+=d,f-=d),f&&(Oo(r.strm,r.strm.output,r.strm.next_out,f),r.strm.next_out+=f,r.strm.avail_out-=f,r.strm.total_out+=f)}while(p===0);return A-=r.strm.avail_in,A&&(A>=r.w_size?(r.matches=2,r.window.set(r.strm.input.subarray(r.strm.next_in-r.w_size,r.strm.next_in),0),r.strstart=r.w_size,r.insert=r.strstart):(r.window_size-r.strstart<=A&&(r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,r.insert>r.strstart&&(r.insert=r.strstart)),r.window.set(r.strm.input.subarray(r.strm.next_in-A,r.strm.next_in),r.strstart),r.strstart+=A,r.insert+=A>r.w_size-r.insert?r.w_size-r.insert:A),r.block_start=r.strstart),r.high_waterh&&r.block_start>=r.w_size&&(r.block_start-=r.w_size,r.strstart-=r.w_size,r.window.set(r.window.subarray(r.w_size,r.w_size+r.strstart),0),r.matches<2&&r.matches++,h+=r.w_size,r.insert>r.strstart&&(r.insert=r.strstart)),h>r.strm.avail_in&&(h=r.strm.avail_in),h&&(Oo(r.strm,r.window,r.strstart,h),r.strstart+=h,r.insert+=h>r.w_size-r.insert?r.w_size-r.insert:h),r.high_water>3,h=r.pending_buf_size-h>65535?65535:r.pending_buf_size-h,s=h>r.w_size?r.w_size:h,d=r.strstart-r.block_start,(d>=s||(d||a===Pt)&&a!==Tn&&r.strm.avail_in===0&&d<=h)&&(f=d>h?h:d,p=a===Pt&&r.strm.avail_in===0&&f===d?1:0,Io(r,r.block_start,f,p),r.block_start+=f,Nt(r.strm)),p?Xn:xt)},ho=(r,a)=>{let s,f;for(;;){if(r.lookahead=Ae&&(r.ins_h=Nn(r,r.ins_h,r.window[r.strstart+Ae-1]),s=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),s!==0&&r.strstart-s<=r.w_size-rn&&(r.match_length=Fc(r,s)),r.match_length>=Ae)if(f=Sn(r,r.strstart-r.match_start,r.match_length-Ae),r.lookahead-=r.match_length,r.match_length<=r.max_lazy_match&&r.lookahead>=Ae){r.match_length--;do r.strstart++,r.ins_h=Nn(r,r.ins_h,r.window[r.strstart+Ae-1]),s=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart;while(--r.match_length!==0);r.strstart++}else r.strstart+=r.match_length,r.match_length=0,r.ins_h=r.window[r.strstart],r.ins_h=Nn(r,r.ins_h,r.window[r.strstart+1]);else f=Sn(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++;if(f&&(Mt(r,!1),r.strm.avail_out===0))return xt}return r.insert=r.strstart{let s,f,d;for(;;){if(r.lookahead=Ae&&(r.ins_h=Nn(r,r.ins_h,r.window[r.strstart+Ae-1]),s=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart),r.prev_length=r.match_length,r.prev_match=r.match_start,r.match_length=Ae-1,s!==0&&r.prev_length4096)&&(r.match_length=Ae-1)),r.prev_length>=Ae&&r.match_length<=r.prev_length){d=r.strstart+r.lookahead-Ae,f=Sn(r,r.strstart-1-r.prev_match,r.prev_length-Ae),r.lookahead-=r.prev_length-1,r.prev_length-=2;do++r.strstart<=d&&(r.ins_h=Nn(r,r.ins_h,r.window[r.strstart+Ae-1]),s=r.prev[r.strstart&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=r.strstart);while(--r.prev_length!==0);if(r.match_available=0,r.match_length=Ae-1,r.strstart++,f&&(Mt(r,!1),r.strm.avail_out===0))return xt}else if(r.match_available){if(f=Sn(r,0,r.window[r.strstart-1]),f&&Mt(r,!1),r.strstart++,r.lookahead--,r.strm.avail_out===0)return xt}else r.match_available=1,r.strstart++,r.lookahead--}return r.match_available&&(f=Sn(r,0,r.window[r.strstart-1]),r.match_available=0),r.insert=r.strstart{let s,f,d,h,p=r.window;for(;;){if(r.lookahead<=bn){if(gr(r),r.lookahead<=bn&&a===Tn)return xt;if(r.lookahead===0)break}if(r.match_length=0,r.lookahead>=Ae&&r.strstart>0&&(d=r.strstart-1,f=p[d],f===p[++d]&&f===p[++d]&&f===p[++d])){h=r.strstart+bn;do;while(f===p[++d]&&f===p[++d]&&f===p[++d]&&f===p[++d]&&f===p[++d]&&f===p[++d]&&f===p[++d]&&f===p[++d]&&dr.lookahead&&(r.match_length=r.lookahead)}if(r.match_length>=Ae?(s=Sn(r,1,r.match_length-Ae),r.lookahead-=r.match_length,r.strstart+=r.match_length,r.match_length=0):(s=Sn(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++),s&&(Mt(r,!1),r.strm.avail_out===0))return xt}return r.insert=0,a===Pt?(Mt(r,!0),r.strm.avail_out===0?Xn:Ar):r.sym_next&&(Mt(r,!1),r.strm.avail_out===0)?xt:pr},_u=(r,a)=>{let s;for(;;){if(r.lookahead===0&&(gr(r),r.lookahead===0)){if(a===Tn)return xt;break}if(r.match_length=0,s=Sn(r,0,r.window[r.strstart]),r.lookahead--,r.strstart++,s&&(Mt(r,!1),r.strm.avail_out===0))return xt}return r.insert=0,a===Pt?(Mt(r,!0),r.strm.avail_out===0?Xn:Ar):r.sym_next&&(Mt(r,!1),r.strm.avail_out===0)?xt:pr};function en(r,a,s,f,d){this.good_length=r,this.max_lazy=a,this.nice_length=s,this.max_chain=f,this.func=d}var jr=[new en(0,0,0,0,Uc),new en(4,4,8,4,ho),new en(4,5,16,8,ho),new en(4,6,32,32,ho),new en(4,4,16,16,fr),new en(8,16,32,32,fr),new en(8,16,128,128,fr),new en(8,32,128,256,fr),new en(32,128,258,1024,fr),new en(32,258,258,4096,fr)],yu=r=>{r.window_size=2*r.w_size,In(r.head),r.max_lazy_match=jr[r.level].max_lazy,r.good_match=jr[r.level].good_length,r.nice_match=jr[r.level].nice_length,r.max_chain_length=jr[r.level].max_chain,r.strstart=0,r.block_start=0,r.lookahead=0,r.insert=0,r.match_length=r.prev_length=Ae-1,r.match_available=0,r.ins_h=0};function Iu(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ki,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(xu*2),this.dyn_dtree=new Uint16Array((2*du+1)*2),this.bl_tree=new Uint16Array((2*gu+1)*2),In(this.dyn_ltree),In(this.dyn_dtree),In(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(wu+1),this.heap=new Uint16Array(2*bo+1),In(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(2*bo+1),In(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}var ii=r=>{if(!r)return 1;let a=r.state;return!a||a.strm!==r||a.status!==dr&&a.status!==Lo&&a.status!==So&&a.status!==To&&a.status!==No&&a.status!==Mo&&a.status!==zn&&a.status!==Gr?1:0},zc=r=>{if(ii(r))return Hn(r,nn);r.total_in=r.total_out=0,r.data_type=au;let a=r.state;return a.pending=0,a.pending_out=0,a.wrap<0&&(a.wrap=-a.wrap),a.status=a.wrap===2?Lo:a.wrap?dr:zn,r.adler=a.wrap===2?0:1,a.last_flush=-2,Kf(a),ft},Hc=r=>{let a=zc(r);return a===ft&&yu(r.state),a},bu=(r,a)=>ii(r)||r.state.wrap!==2?nn:(r.state.gzhead=a,ft),Vc=(r,a,s,f,d,h)=>{if(!r)return nn;let p=1;if(a===nu&&(a=6),f<0?(p=0,f=-f):f>15&&(p=2,f-=16),d<1||d>lu||s!==Ki||f<8||f>15||a<0||a>9||h<0||h>su||f===8&&p!==1)return Hn(r,nn);f===8&&(f=9);let A=new Iu;return r.state=A,A.strm=r,A.status=dr,A.wrap=p,A.gzhead=null,A.w_bits=f,A.w_size=1<Vc(r,a,Ki,cu,fu,ou),Tu=(r,a)=>{if(ii(r)||a>Gl||a<0)return r?Hn(r,nn):nn;let s=r.state;if(!r.output||r.avail_in!==0&&!r.input||s.status===Gr&&a!==Pt)return Hn(r,r.avail_out===0?uo:nn);let f=s.last_flush;if(s.last_flush=a,s.pending!==0){if(Nt(r),r.avail_out===0)return s.last_flush=-1,ft}else if(r.avail_in===0&&Yl(a)<=Yl(f)&&a!==Pt)return Hn(r,uo);if(s.status===Gr&&r.avail_in!==0)return Hn(r,uo);if(s.status===dr&&s.wrap===0&&(s.status=zn),s.status===dr){let d=Ki+(s.w_bits-8<<4)<<8,h=-1;if(s.strategy>=Hi||s.level<2?h=0:s.level<6?h=1:s.level===6?h=2:h=3,d|=h<<6,s.strstart!==0&&(d|=pu),d+=31-d%31,Xr(s,d),s.strstart!==0&&(Xr(s,r.adler>>>16),Xr(s,r.adler&65535)),r.adler=1,s.status=zn,Nt(r),s.pending!==0)return s.last_flush=-1,ft}if(s.status===Lo){if(r.adler=0,Te(s,31),Te(s,139),Te(s,8),s.gzhead)Te(s,(s.gzhead.text?1:0)+(s.gzhead.hcrc?2:0)+(s.gzhead.extra?4:0)+(s.gzhead.name?8:0)+(s.gzhead.comment?16:0)),Te(s,s.gzhead.time&255),Te(s,s.gzhead.time>>8&255),Te(s,s.gzhead.time>>16&255),Te(s,s.gzhead.time>>24&255),Te(s,s.level===9?2:s.strategy>=Hi||s.level<2?4:0),Te(s,s.gzhead.os&255),s.gzhead.extra&&s.gzhead.extra.length&&(Te(s,s.gzhead.extra.length&255),Te(s,s.gzhead.extra.length>>8&255)),s.gzhead.hcrc&&(r.adler=it(r.adler,s.pending_buf,s.pending,0)),s.gzindex=0,s.status=So;else if(Te(s,0),Te(s,0),Te(s,0),Te(s,0),Te(s,0),Te(s,s.level===9?2:s.strategy>=Hi||s.level<2?4:0),Te(s,Au),s.status=zn,Nt(r),s.pending!==0)return s.last_flush=-1,ft}if(s.status===So){if(s.gzhead.extra){let d=s.pending,h=(s.gzhead.extra.length&65535)-s.gzindex;for(;s.pending+h>s.pending_buf_size;){let A=s.pending_buf_size-s.pending;if(s.pending_buf.set(s.gzhead.extra.subarray(s.gzindex,s.gzindex+A),s.pending),s.pending=s.pending_buf_size,s.gzhead.hcrc&&s.pending>d&&(r.adler=it(r.adler,s.pending_buf,s.pending-d,d)),s.gzindex+=A,Nt(r),s.pending!==0)return s.last_flush=-1,ft;d=0,h-=A}let p=new Uint8Array(s.gzhead.extra);s.pending_buf.set(p.subarray(s.gzindex,s.gzindex+h),s.pending),s.pending+=h,s.gzhead.hcrc&&s.pending>d&&(r.adler=it(r.adler,s.pending_buf,s.pending-d,d)),s.gzindex=0}s.status=To}if(s.status===To){if(s.gzhead.name){let d=s.pending,h;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>d&&(r.adler=it(r.adler,s.pending_buf,s.pending-d,d)),Nt(r),s.pending!==0)return s.last_flush=-1,ft;d=0}s.gzindexd&&(r.adler=it(r.adler,s.pending_buf,s.pending-d,d)),s.gzindex=0}s.status=No}if(s.status===No){if(s.gzhead.comment){let d=s.pending,h;do{if(s.pending===s.pending_buf_size){if(s.gzhead.hcrc&&s.pending>d&&(r.adler=it(r.adler,s.pending_buf,s.pending-d,d)),Nt(r),s.pending!==0)return s.last_flush=-1,ft;d=0}s.gzindexd&&(r.adler=it(r.adler,s.pending_buf,s.pending-d,d))}s.status=Mo}if(s.status===Mo){if(s.gzhead.hcrc){if(s.pending+2>s.pending_buf_size&&(Nt(r),s.pending!==0))return s.last_flush=-1,ft;Te(s,r.adler&255),Te(s,r.adler>>8&255),r.adler=0}if(s.status=zn,Nt(r),s.pending!==0)return s.last_flush=-1,ft}if(r.avail_in!==0||s.lookahead!==0||a!==Tn&&s.status!==Gr){let d=s.level===0?Uc(s,a):s.strategy===Hi?_u(s,a):s.strategy===iu?Cu(s,a):jr[s.level].func(s,a);if((d===Xn||d===Ar)&&(s.status=Gr),d===xt||d===Xn)return r.avail_out===0&&(s.last_flush=-1),ft;if(d===pr&&(a===$f?Jf(s):a!==Gl&&(Io(s,0,0,!1),a===eu&&(In(s.head),s.lookahead===0&&(s.strstart=0,s.block_start=0,s.insert=0))),Nt(r),r.avail_out===0))return s.last_flush=-1,ft}return a!==Pt?ft:s.wrap<=0?jl:(s.wrap===2?(Te(s,r.adler&255),Te(s,r.adler>>8&255),Te(s,r.adler>>16&255),Te(s,r.adler>>24&255),Te(s,r.total_in&255),Te(s,r.total_in>>8&255),Te(s,r.total_in>>16&255),Te(s,r.total_in>>24&255)):(Xr(s,r.adler>>>16),Xr(s,r.adler&65535)),Nt(r),s.wrap>0&&(s.wrap=-s.wrap),s.pending!==0?ft:jl)},Nu=r=>{if(ii(r))return nn;let a=r.state.status;return r.state=null,a===zn?Hn(r,tu):ft},Mu=(r,a)=>{let s=a.length;if(ii(r))return nn;let f=r.state,d=f.wrap;if(d===2||d===1&&f.status!==dr||f.lookahead)return nn;if(d===1&&(r.adler=$r(r.adler,a,s,0)),f.wrap=0,s>=f.w_size){d===0&&(In(f.head),f.strstart=0,f.block_start=0,f.insert=0);let y=new Uint8Array(f.w_size);y.set(a.subarray(s-f.w_size,s),0),a=y,s=f.w_size}let h=r.avail_in,p=r.next_in,A=r.input;for(r.avail_in=s,r.next_in=0,r.input=a,gr(f);f.lookahead>=Ae;){let y=f.strstart,x=f.lookahead-(Ae-1);do f.ins_h=Nn(f,f.ins_h,f.window[y+Ae-1]),f.prev[y&f.w_mask]=f.head[f.ins_h],f.head[f.ins_h]=y,y++;while(--x);f.strstart=y,f.lookahead=Ae-1,gr(f)}return f.strstart+=f.lookahead,f.block_start=f.strstart,f.insert=f.lookahead,f.lookahead=0,f.match_length=f.prev_length=Ae-1,f.match_available=0,r.next_in=p,r.input=A,r.avail_in=h,f.wrap=d,ft},Ou=Su,Ru=Vc,Du=Hc,vu=zc,Bu=bu,Lu=Tu,ku=Nu,Pu=Mu,Fu="pako deflate (from Nodeca project)",Wr={deflateInit:Ou,deflateInit2:Ru,deflateReset:Du,deflateResetKeep:vu,deflateSetHeader:Bu,deflate:Lu,deflateEnd:ku,deflateSetDictionary:Pu,deflateInfo:Fu},Uu=(r,a)=>Object.prototype.hasOwnProperty.call(r,a),zu=function(r){let a=Array.prototype.slice.call(arguments,1);for(;a.length;){let s=a.shift();if(s){if(typeof s!="object")throw new TypeError(s+"must be non-object");for(let f in s)Uu(s,f)&&(r[f]=s[f])}}return r},Hu=r=>{let a=0;for(let f=0,d=r.length;f=252?6:r>=248?5:r>=240?4:r>=224?3:r>=192?2:1;ei[254]=ei[254]=1;var Vu=r=>{if(typeof TextEncoder=="function"&&TextEncoder.prototype.encode)return new TextEncoder().encode(r);let a,s,f,d,h,p=r.length,A=0;for(d=0;d>>6,a[h++]=128|s&63):s<65536?(a[h++]=224|s>>>12,a[h++]=128|s>>>6&63,a[h++]=128|s&63):(a[h++]=240|s>>>18,a[h++]=128|s>>>12&63,a[h++]=128|s>>>6&63,a[h++]=128|s&63);return a},Xu=(r,a)=>{if(a<65534&&r.subarray&&Xc)return String.fromCharCode.apply(null,r.length===a?r:r.subarray(0,a));let s="";for(let f=0;f{let s=a||r.length;if(typeof TextDecoder=="function"&&TextDecoder.prototype.decode)return new TextDecoder().decode(r.subarray(0,a));let f,d,h=new Array(s*2);for(d=0,f=0;f4){h[d++]=65533,f+=A-1;continue}for(p&=A===2?31:A===3?15:7;A>1&&f1){h[d++]=65533;continue}p<65536?h[d++]=p:(p-=65536,h[d++]=55296|p>>10&1023,h[d++]=56320|p&1023)}return Xu(h,d)},ju=(r,a)=>{a=a||r.length,a>r.length&&(a=r.length);let s=a-1;for(;s>=0&&(r[s]&192)===128;)s--;return s<0||s===0?a:s+ei[r[s]]>a?s:a},ti={string2buf:Vu,buf2string:Gu,utf8border:ju};function Yu(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}var Gc=Yu,jc=Object.prototype.toString,{Z_NO_FLUSH:Wu,Z_SYNC_FLUSH:Zu,Z_FULL_FLUSH:Qu,Z_FINISH:Ku,Z_OK:Zi,Z_STREAM_END:qu,Z_DEFAULT_COMPRESSION:Ju,Z_DEFAULT_STRATEGY:$u,Z_DEFLATED:eh}=wr;function si(r){this.options=qi.assign({level:Ju,method:eh,chunkSize:16384,windowBits:15,memLevel:8,strategy:$u},r||{});let a=this.options;a.raw&&a.windowBits>0?a.windowBits=-a.windowBits:a.gzip&&a.windowBits>0&&a.windowBits<16&&(a.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gc,this.strm.avail_out=0;let s=Wr.deflateInit2(this.strm,a.level,a.method,a.windowBits,a.memLevel,a.strategy);if(s!==Zi)throw new Error(Vn[s]);if(a.header&&Wr.deflateSetHeader(this.strm,a.header),a.dictionary){let f;if(typeof a.dictionary=="string"?f=ti.string2buf(a.dictionary):jc.call(a.dictionary)==="[object ArrayBuffer]"?f=new Uint8Array(a.dictionary):f=a.dictionary,s=Wr.deflateSetDictionary(this.strm,f),s!==Zi)throw new Error(Vn[s]);this._dict_set=!0}}si.prototype.push=function(r,a){let s=this.strm,f=this.options.chunkSize,d,h;if(this.ended)return!1;for(a===~~a?h=a:h=a===!0?Ku:Wu,typeof r=="string"?s.input=ti.string2buf(r):jc.call(r)==="[object ArrayBuffer]"?s.input=new Uint8Array(r):s.input=r,s.next_in=0,s.avail_in=s.input.length;;){if(s.avail_out===0&&(s.output=new Uint8Array(f),s.next_out=0,s.avail_out=f),(h===Zu||h===Qu)&&s.avail_out<=6){this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;continue}if(d=Wr.deflate(s,h),d===qu)return s.next_out>0&&this.onData(s.output.subarray(0,s.next_out)),d=Wr.deflateEnd(this.strm),this.onEnd(d),this.ended=!0,d===Zi;if(s.avail_out===0){this.onData(s.output);continue}if(h>0&&s.next_out>0){this.onData(s.output.subarray(0,s.next_out)),s.avail_out=0;continue}if(s.avail_in===0)break}return!0};si.prototype.onData=function(r){this.chunks.push(r)};si.prototype.onEnd=function(r){r===Zi&&(this.result=qi.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function ko(r,a){let s=new si(a);if(s.push(r,!0),s.err)throw s.msg||Vn[s.err];return s.result}function th(r,a){return a=a||{},a.raw=!0,ko(r,a)}function nh(r,a){return a=a||{},a.gzip=!0,ko(r,a)}var rh=si,ih=ko,sh=th,oh=nh,ah=wr,lh={Deflate:rh,deflate:ih,deflateRaw:sh,gzip:oh,constants:ah},Vi=16209,ch=16191,fh=function(a,s){let f,d,h,p,A,y,x,_,v,R,N,V,K,H,U,W,te,z,L,Y,O,le,re,k,G=a.state;f=a.next_in,re=a.input,d=f+(a.avail_in-5),h=a.next_out,k=a.output,p=h-(s-a.avail_out),A=h+(a.avail_out-257),y=G.dmax,x=G.wsize,_=G.whave,v=G.wnext,R=G.window,N=G.hold,V=G.bits,K=G.lencode,H=G.distcode,U=(1<>>24,N>>>=z,V-=z,z=te>>>16&255,z===0)k[h++]=te&65535;else if(z&16){L=te&65535,z&=15,z&&(V>>=z,V-=z),V<15&&(N+=re[f++]<>>24,N>>>=z,V-=z,z=te>>>16&255,z&16){if(Y=te&65535,z&=15,Vy){a.msg="invalid distance too far back",G.mode=Vi;break e}if(N>>>=z,V-=z,z=h-p,Y>z){if(z=Y-z,z>_&&G.sane){a.msg="invalid distance too far back",G.mode=Vi;break e}if(O=0,le=R,v===0){if(O+=x-z,z2;)k[h++]=le[O++],k[h++]=le[O++],k[h++]=le[O++],L-=3;L&&(k[h++]=le[O++],L>1&&(k[h++]=le[O++]))}else{O=h-Y;do k[h++]=k[O++],k[h++]=k[O++],k[h++]=k[O++],L-=3;while(L>2);L&&(k[h++]=k[O++],L>1&&(k[h++]=k[O++]))}}else if((z&64)===0){te=H[(te&65535)+(N&(1<>3,f-=L,V-=L<<3,N&=(1<{let y=A.bits,x=0,_=0,v=0,R=0,N=0,V=0,K=0,H=0,U=0,W=0,te,z,L,Y,O,le=null,re,k=new Uint16Array(ur+1),G=new Uint16Array(ur+1),$=null,M,ue,q;for(x=0;x<=ur;x++)k[x]=0;for(_=0;_=1&&k[R]===0;R--);if(N>R&&(N=R),R===0)return d[h++]=1<<24|64<<16|0,d[h++]=1<<24|64<<16|0,A.bits=1,0;for(v=1;v0&&(r===Ql||R!==1))return-1;for(G[1]=0,x=1;xWl||r===Kl&&U>Zl)return 1;for(;;){M=x-K,p[_]+1=re?(ue=$[p[_]-re],q=le[p[_]-re]):(ue=96,q=0),te=1<>K)+z]=M<<24|ue<<16|q|0;while(z!==0);for(te=1<>=1;if(te!==0?(W&=te-1,W+=te):W=0,_++,--k[x]===0){if(x===R)break;x=a[s+p[_]]}if(x>N&&(W&Y)!==L){for(K===0&&(K=N),O+=v,V=x-K,H=1<Wl||r===Kl&&U>Zl)return 1;L=W&Y,d[L]=N<<24|V<<16|O-h|0}}return W!==0&&(d[O+W]=x-K<<24|64<<16|0),A.bits=N,0},Zr=xh,wh=0,Yc=1,Wc=2,{Z_FINISH:ql,Z_BLOCK:ph,Z_TREES:Xi,Z_OK:Gn,Z_STREAM_END:Ah,Z_NEED_DICT:Eh,Z_STREAM_ERROR:Ft,Z_DATA_ERROR:Zc,Z_MEM_ERROR:Qc,Z_BUF_ERROR:mh,Z_DEFLATED:Jl}=wr,Ji=16180,$l=16181,ec=16182,tc=16183,nc=16184,rc=16185,ic=16186,sc=16187,oc=16188,ac=16189,Qi=16190,cn=16191,xo=16192,lc=16193,wo=16194,cc=16195,fc=16196,uc=16197,hc=16198,Gi=16199,ji=16200,dc=16201,gc=16202,xc=16203,wc=16204,pc=16205,po=16206,Ac=16207,Ec=16208,He=16209,Kc=16210,qc=16211,Ch=852,_h=592,yh=15,Ih=yh,mc=r=>(r>>>24&255)+(r>>>8&65280)+((r&65280)<<8)+((r&255)<<24);function bh(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}var jn=r=>{if(!r)return 1;let a=r.state;return!a||a.strm!==r||a.modeqc?1:0},Jc=r=>{if(jn(r))return Ft;let a=r.state;return r.total_in=r.total_out=a.total=0,r.msg="",a.wrap&&(r.adler=a.wrap&1),a.mode=Ji,a.last=0,a.havedict=0,a.flags=-1,a.dmax=32768,a.head=null,a.hold=0,a.bits=0,a.lencode=a.lendyn=new Int32Array(Ch),a.distcode=a.distdyn=new Int32Array(_h),a.sane=1,a.back=-1,Gn},$c=r=>{if(jn(r))return Ft;let a=r.state;return a.wsize=0,a.whave=0,a.wnext=0,Jc(r)},e1=(r,a)=>{let s;if(jn(r))return Ft;let f=r.state;return a<0?(s=0,a=-a):(s=(a>>4)+5,a<48&&(a&=15)),a&&(a<8||a>15)?Ft:(f.window!==null&&f.wbits!==a&&(f.window=null),f.wrap=s,f.wbits=a,$c(r))},t1=(r,a)=>{if(!r)return Ft;let s=new bh;r.state=s,s.strm=r,s.window=null,s.mode=Ji;let f=e1(r,a);return f!==Gn&&(r.state=null),f},Sh=r=>t1(r,Ih),Cc=!0,Ao,Eo,Th=r=>{if(Cc){Ao=new Int32Array(512),Eo=new Int32Array(32);let a=0;for(;a<144;)r.lens[a++]=8;for(;a<256;)r.lens[a++]=9;for(;a<280;)r.lens[a++]=7;for(;a<288;)r.lens[a++]=8;for(Zr(Yc,r.lens,0,288,Ao,0,r.work,{bits:9}),a=0;a<32;)r.lens[a++]=5;Zr(Wc,r.lens,0,32,Eo,0,r.work,{bits:5}),Cc=!1}r.lencode=Ao,r.lenbits=9,r.distcode=Eo,r.distbits=5},n1=(r,a,s,f)=>{let d,h=r.state;return h.window===null&&(h.wsize=1<=h.wsize?(h.window.set(a.subarray(s-h.wsize,s),0),h.wnext=0,h.whave=h.wsize):(d=h.wsize-h.wnext,d>f&&(d=f),h.window.set(a.subarray(s-f,s-f+d),h.wnext),f-=d,f?(h.window.set(a.subarray(s-f,s),0),h.wnext=f,h.whave=h.wsize):(h.wnext+=d,h.wnext===h.wsize&&(h.wnext=0),h.whave{let s,f,d,h,p,A,y,x,_,v,R,N,V,K,H=0,U,W,te,z,L,Y,O,le,re=new Uint8Array(4),k,G,$=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(jn(r)||!r.output||!r.input&&r.avail_in!==0)return Ft;s=r.state,s.mode===cn&&(s.mode=xo),p=r.next_out,d=r.output,y=r.avail_out,h=r.next_in,f=r.input,A=r.avail_in,x=s.hold,_=s.bits,v=A,R=y,le=Gn;e:for(;;)switch(s.mode){case Ji:if(s.wrap===0){s.mode=xo;break}for(;_<16;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if(s.wrap&2&&x===35615){s.wbits===0&&(s.wbits=15),s.check=0,re[0]=x&255,re[1]=x>>>8&255,s.check=it(s.check,re,2,0),x=0,_=0,s.mode=$l;break}if(s.head&&(s.head.done=!1),!(s.wrap&1)||(((x&255)<<8)+(x>>8))%31){r.msg="incorrect header check",s.mode=He;break}if((x&15)!==Jl){r.msg="unknown compression method",s.mode=He;break}if(x>>>=4,_-=4,O=(x&15)+8,s.wbits===0&&(s.wbits=O),O>15||O>s.wbits){r.msg="invalid window size",s.mode=He;break}s.dmax=1<>8&1),s.flags&512&&s.wrap&4&&(re[0]=x&255,re[1]=x>>>8&255,s.check=it(s.check,re,2,0)),x=0,_=0,s.mode=ec;case ec:for(;_<32;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}s.head&&(s.head.time=x),s.flags&512&&s.wrap&4&&(re[0]=x&255,re[1]=x>>>8&255,re[2]=x>>>16&255,re[3]=x>>>24&255,s.check=it(s.check,re,4,0)),x=0,_=0,s.mode=tc;case tc:for(;_<16;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}s.head&&(s.head.xflags=x&255,s.head.os=x>>8),s.flags&512&&s.wrap&4&&(re[0]=x&255,re[1]=x>>>8&255,s.check=it(s.check,re,2,0)),x=0,_=0,s.mode=nc;case nc:if(s.flags&1024){for(;_<16;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}s.length=x,s.head&&(s.head.extra_len=x),s.flags&512&&s.wrap&4&&(re[0]=x&255,re[1]=x>>>8&255,s.check=it(s.check,re,2,0)),x=0,_=0}else s.head&&(s.head.extra=null);s.mode=rc;case rc:if(s.flags&1024&&(N=s.length,N>A&&(N=A),N&&(s.head&&(O=s.head.extra_len-s.length,s.head.extra||(s.head.extra=new Uint8Array(s.head.extra_len)),s.head.extra.set(f.subarray(h,h+N),O)),s.flags&512&&s.wrap&4&&(s.check=it(s.check,f,N,h)),A-=N,h+=N,s.length-=N),s.length))break e;s.length=0,s.mode=ic;case ic:if(s.flags&2048){if(A===0)break e;N=0;do O=f[h+N++],s.head&&O&&s.length<65536&&(s.head.name+=String.fromCharCode(O));while(O&&N>9&1,s.head.done=!0),r.adler=s.check=0,s.mode=cn;break;case ac:for(;_<32;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}r.adler=s.check=mc(x),x=0,_=0,s.mode=Qi;case Qi:if(s.havedict===0)return r.next_out=p,r.avail_out=y,r.next_in=h,r.avail_in=A,s.hold=x,s.bits=_,Eh;r.adler=s.check=1,s.mode=cn;case cn:if(a===ph||a===Xi)break e;case xo:if(s.last){x>>>=_&7,_-=_&7,s.mode=po;break}for(;_<3;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}switch(s.last=x&1,x>>>=1,_-=1,x&3){case 0:s.mode=lc;break;case 1:if(Th(s),s.mode=Gi,a===Xi){x>>>=2,_-=2;break e}break;case 2:s.mode=fc;break;case 3:r.msg="invalid block type",s.mode=He}x>>>=2,_-=2;break;case lc:for(x>>>=_&7,_-=_&7;_<32;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if((x&65535)!==(x>>>16^65535)){r.msg="invalid stored block lengths",s.mode=He;break}if(s.length=x&65535,x=0,_=0,s.mode=wo,a===Xi)break e;case wo:s.mode=cc;case cc:if(N=s.length,N){if(N>A&&(N=A),N>y&&(N=y),N===0)break e;d.set(f.subarray(h,h+N),p),A-=N,h+=N,y-=N,p+=N,s.length-=N;break}s.mode=cn;break;case fc:for(;_<14;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if(s.nlen=(x&31)+257,x>>>=5,_-=5,s.ndist=(x&31)+1,x>>>=5,_-=5,s.ncode=(x&15)+4,x>>>=4,_-=4,s.nlen>286||s.ndist>30){r.msg="too many length or distance symbols",s.mode=He;break}s.have=0,s.mode=uc;case uc:for(;s.have>>=3,_-=3}for(;s.have<19;)s.lens[$[s.have++]]=0;if(s.lencode=s.lendyn,s.lenbits=7,k={bits:s.lenbits},le=Zr(wh,s.lens,0,19,s.lencode,0,s.work,k),s.lenbits=k.bits,le){r.msg="invalid code lengths set",s.mode=He;break}s.have=0,s.mode=hc;case hc:for(;s.have>>24,W=H>>>16&255,te=H&65535,!(U<=_);){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if(te<16)x>>>=U,_-=U,s.lens[s.have++]=te;else{if(te===16){for(G=U+2;_>>=U,_-=U,s.have===0){r.msg="invalid bit length repeat",s.mode=He;break}O=s.lens[s.have-1],N=3+(x&3),x>>>=2,_-=2}else if(te===17){for(G=U+3;_>>=U,_-=U,O=0,N=3+(x&7),x>>>=3,_-=3}else{for(G=U+7;_>>=U,_-=U,O=0,N=11+(x&127),x>>>=7,_-=7}if(s.have+N>s.nlen+s.ndist){r.msg="invalid bit length repeat",s.mode=He;break}for(;N--;)s.lens[s.have++]=O}}if(s.mode===He)break;if(s.lens[256]===0){r.msg="invalid code -- missing end-of-block",s.mode=He;break}if(s.lenbits=9,k={bits:s.lenbits},le=Zr(Yc,s.lens,0,s.nlen,s.lencode,0,s.work,k),s.lenbits=k.bits,le){r.msg="invalid literal/lengths set",s.mode=He;break}if(s.distbits=6,s.distcode=s.distdyn,k={bits:s.distbits},le=Zr(Wc,s.lens,s.nlen,s.ndist,s.distcode,0,s.work,k),s.distbits=k.bits,le){r.msg="invalid distances set",s.mode=He;break}if(s.mode=Gi,a===Xi)break e;case Gi:s.mode=ji;case ji:if(A>=6&&y>=258){r.next_out=p,r.avail_out=y,r.next_in=h,r.avail_in=A,s.hold=x,s.bits=_,fh(r,R),p=r.next_out,d=r.output,y=r.avail_out,h=r.next_in,f=r.input,A=r.avail_in,x=s.hold,_=s.bits,s.mode===cn&&(s.back=-1);break}for(s.back=0;H=s.lencode[x&(1<>>24,W=H>>>16&255,te=H&65535,!(U<=_);){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if(W&&(W&240)===0){for(z=U,L=W,Y=te;H=s.lencode[Y+((x&(1<>z)],U=H>>>24,W=H>>>16&255,te=H&65535,!(z+U<=_);){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}x>>>=z,_-=z,s.back+=z}if(x>>>=U,_-=U,s.back+=U,s.length=te,W===0){s.mode=pc;break}if(W&32){s.back=-1,s.mode=cn;break}if(W&64){r.msg="invalid literal/length code",s.mode=He;break}s.extra=W&15,s.mode=dc;case dc:if(s.extra){for(G=s.extra;_>>=s.extra,_-=s.extra,s.back+=s.extra}s.was=s.length,s.mode=gc;case gc:for(;H=s.distcode[x&(1<>>24,W=H>>>16&255,te=H&65535,!(U<=_);){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if((W&240)===0){for(z=U,L=W,Y=te;H=s.distcode[Y+((x&(1<>z)],U=H>>>24,W=H>>>16&255,te=H&65535,!(z+U<=_);){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}x>>>=z,_-=z,s.back+=z}if(x>>>=U,_-=U,s.back+=U,W&64){r.msg="invalid distance code",s.mode=He;break}s.offset=te,s.extra=W&15,s.mode=xc;case xc:if(s.extra){for(G=s.extra;_>>=s.extra,_-=s.extra,s.back+=s.extra}if(s.offset>s.dmax){r.msg="invalid distance too far back",s.mode=He;break}s.mode=wc;case wc:if(y===0)break e;if(N=R-y,s.offset>N){if(N=s.offset-N,N>s.whave&&s.sane){r.msg="invalid distance too far back",s.mode=He;break}N>s.wnext?(N-=s.wnext,V=s.wsize-N):V=s.wnext-N,N>s.length&&(N=s.length),K=s.window}else K=d,V=p-s.offset,N=s.length;N>y&&(N=y),y-=N,s.length-=N;do d[p++]=K[V++];while(--N);s.length===0&&(s.mode=ji);break;case pc:if(y===0)break e;d[p++]=s.length,y--,s.mode=ji;break;case po:if(s.wrap){for(;_<32;){if(A===0)break e;A--,x|=f[h++]<<_,_+=8}if(R-=y,r.total_out+=R,s.total+=R,s.wrap&4&&R&&(r.adler=s.check=s.flags?it(s.check,d,R,p-R):$r(s.check,d,R,p-R)),R=y,s.wrap&4&&(s.flags?x:mc(x))!==s.check){r.msg="incorrect data check",s.mode=He;break}x=0,_=0}s.mode=Ac;case Ac:if(s.wrap&&s.flags){for(;_<32;){if(A===0)break e;A--,x+=f[h++]<<_,_+=8}if(s.wrap&4&&x!==(s.total&4294967295)){r.msg="incorrect length check",s.mode=He;break}x=0,_=0}s.mode=Ec;case Ec:le=Ah;break e;case He:le=Zc;break e;case Kc:return Qc;case qc:default:return Ft}return r.next_out=p,r.avail_out=y,r.next_in=h,r.avail_in=A,s.hold=x,s.bits=_,(s.wsize||R!==r.avail_out&&s.mode{if(jn(r))return Ft;let a=r.state;return a.window&&(a.window=null),r.state=null,Gn},Oh=(r,a)=>{if(jn(r))return Ft;let s=r.state;return(s.wrap&2)===0?Ft:(s.head=a,a.done=!1,Gn)},Rh=(r,a)=>{let s=a.length,f,d,h;return jn(r)||(f=r.state,f.wrap!==0&&f.mode!==Qi)?Ft:f.mode===Qi&&(d=1,d=$r(d,a,s,0),d!==f.check)?Zc:(h=n1(r,a,s,s),h?(f.mode=Kc,Qc):(f.havedict=1,Gn))},Dh=$c,vh=e1,Bh=Jc,Lh=Sh,kh=t1,Ph=Nh,Fh=Mh,Uh=Oh,zh=Rh,Hh="pako inflate (from Nodeca project)",un={inflateReset:Dh,inflateReset2:vh,inflateResetKeep:Bh,inflateInit:Lh,inflateInit2:kh,inflate:Ph,inflateEnd:Fh,inflateGetHeader:Uh,inflateSetDictionary:zh,inflateInfo:Hh};function Vh(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Xh=Vh,r1=Object.prototype.toString,{Z_NO_FLUSH:Gh,Z_FINISH:jh,Z_OK:ni,Z_STREAM_END:mo,Z_NEED_DICT:Co,Z_STREAM_ERROR:Yh,Z_DATA_ERROR:_c,Z_MEM_ERROR:Wh}=wr;function oi(r){this.options=qi.assign({chunkSize:1024*64,windowBits:15,to:""},r||{});let a=this.options;a.raw&&a.windowBits>=0&&a.windowBits<16&&(a.windowBits=-a.windowBits,a.windowBits===0&&(a.windowBits=-15)),a.windowBits>=0&&a.windowBits<16&&!(r&&r.windowBits)&&(a.windowBits+=32),a.windowBits>15&&a.windowBits<48&&(a.windowBits&15)===0&&(a.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Gc,this.strm.avail_out=0;let s=un.inflateInit2(this.strm,a.windowBits);if(s!==ni)throw new Error(Vn[s]);if(this.header=new Xh,un.inflateGetHeader(this.strm,this.header),a.dictionary&&(typeof a.dictionary=="string"?a.dictionary=ti.string2buf(a.dictionary):r1.call(a.dictionary)==="[object ArrayBuffer]"&&(a.dictionary=new Uint8Array(a.dictionary)),a.raw&&(s=un.inflateSetDictionary(this.strm,a.dictionary),s!==ni)))throw new Error(Vn[s])}oi.prototype.push=function(r,a){let s=this.strm,f=this.options.chunkSize,d=this.options.dictionary,h,p,A;if(this.ended)return!1;for(a===~~a?p=a:p=a===!0?jh:Gh,r1.call(r)==="[object ArrayBuffer]"?s.input=new Uint8Array(r):s.input=r,s.next_in=0,s.avail_in=s.input.length;;){for(s.avail_out===0&&(s.output=new Uint8Array(f),s.next_out=0,s.avail_out=f),h=un.inflate(s,p),h===Co&&d&&(h=un.inflateSetDictionary(s,d),h===ni?h=un.inflate(s,p):h===_c&&(h=Co));s.avail_in>0&&h===mo&&s.state.wrap>0&&r[s.next_in]!==0;)un.inflateReset(s),h=un.inflate(s,p);switch(h){case Yh:case _c:case Co:case Wh:return this.onEnd(h),this.ended=!0,!1}if(A=s.avail_out,s.next_out&&(s.avail_out===0||h===mo))if(this.options.to==="string"){let y=ti.utf8border(s.output,s.next_out),x=s.next_out-y,_=ti.buf2string(s.output,y);s.next_out=x,s.avail_out=f-x,x&&s.output.set(s.output.subarray(y,y+x),0),this.onData(_)}else this.onData(s.output.length===s.next_out?s.output:s.output.subarray(0,s.next_out));if(!(h===ni&&A===0)){if(h===mo)return h=un.inflateEnd(this.strm),this.onEnd(h),this.ended=!0,!0;if(s.avail_in===0)break}}return!0};oi.prototype.onData=function(r){this.chunks.push(r)};oi.prototype.onEnd=function(r){r===ni&&(this.options.to==="string"?this.result=this.chunks.join(""):this.result=qi.flattenChunks(this.chunks)),this.chunks=[],this.err=r,this.msg=this.strm.msg};function Po(r,a){let s=new oi(a);if(s.push(r),s.err)throw s.msg||Vn[s.err];return s.result}function Zh(r,a){return a=a||{},a.raw=!0,Po(r,a)}var Qh=oi,Kh=Po,qh=Zh,Jh=Po,$h=wr,ed={Inflate:Qh,inflate:Kh,inflateRaw:qh,ungzip:Jh,constants:$h},{Deflate:wg,deflate:td,deflateRaw:pg,gzip:nd}=lh,{Inflate:rd,inflate:id,inflateRaw:Ag,ungzip:sd}=ed;var $i=td;var i1=nd,s1=rd,o1=id;var a1=sd;var os=Br(Fo());var Yt=Br(Fo());var ns=Br(u1());function gd(r){return ns.fromByteArray(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function h1(r){for(r=r.replace(/-/g,"+").replace(/_/g,"/");r.length%4;)r+="=";return ns.toByteArray(r)}var d1=256*1024,xd=16*1024;function g1(r,a){let s=new s1({chunkSize:xd}),f=[],d=0;if(s.onData=A=>{if(d+=A.length,d>d1)throw new Error(`QR payload expands beyond the ${d1/1024} KB limit (${a})`);f.push(A)},s.push(r,!0),s.err)throw new Error(`QR payload could not be decompressed (${a}): ${s.msg||s.err}`);let h=new Uint8Array(d),p=0;for(let A of f)h.set(A,p),p+=A.length;return h}function x1(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{let a=Math.random()*16|0;return(r==="x"?a:a&3|8).toString(16)})}async function rs(r,a=null,s=null){try{console.log("\u{1F510} Starting COSE packing...");let f=JSON.stringify(r);console.log(`\u{1F4CA} Original payload size: ${f.length} characters`);let d,h=null;if(s){console.log("\u{1F510} Encrypting for specific recipient...");let V=await crypto.subtle.generateKey({name:"ECDH",namedCurve:"P-384"},!0,["deriveKey","deriveBits"]);h=new Uint8Array(await crypto.subtle.exportKey("raw",V.publicKey));let K=await crypto.subtle.deriveBits({name:"ECDH",public:s},V.privateKey,384),H=await crypto.subtle.importKey("raw",K,"HKDF",!1,["deriveKey"]),U=await crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-384",salt:new Uint8Array(0),info:new TextEncoder().encode("SecureBit QR ECDH AES key")},H,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]),W=crypto.getRandomValues(new Uint8Array(12)),te=await crypto.subtle.encrypt({name:"AES-GCM",iv:W},U,new TextEncoder().encode(f));d={protected:{alg:"A256GCM"},unprotected:{epk:h},ciphertext:new Uint8Array(te),iv:W}}else console.log("\u{1F510} Using broadcast mode (no encryption)..."),h=crypto.getRandomValues(new Uint8Array(97)),d={plaintext:new TextEncoder().encode(f),epk:h};let p,A=Yt.encode(d);if(a){console.log("\u{1F510} Signing payload...");let V=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-384"},a,A));p=[Yt.encode({alg:"ES384"}),{kid:"securebit-sender"},A,V]}else console.log("\u{1F510} No signing key provided, using unsigned structure..."),p=[Yt.encode({alg:"none"}),{},A,new Uint8Array(0)];let y=Yt.encode(p),x=$i(y),_=gd(x);console.log(`\u{1F4CA} Compressed size: ${_.length} characters (${Math.round((1-_.length/f.length)*100)}% reduction)`);let R=Math.max(200,Math.floor(_.length/10)),N=[];if(_.length<=R)N.push(JSON.stringify({hdr:{v:1,id:x1(),seq:1,total:1},body:_}));else{let V=x1(),K=Math.ceil(_.length/R);console.log(`\u{1F4CA} COSE: Splitting ${_.length} chars into ${K} chunks (max ${R} chars per chunk)`);for(let H=0,U=1;H<_.length;H+=R,U++){let W=_.slice(H,H+R);N.push(JSON.stringify({hdr:{v:1,id:V,seq:U,total:K},body:W}))}}return console.log(`\u{1F4CA} Generated ${N.length} QR chunk(s)`),N}catch(f){throw console.error("\u274C Error in packSecurePayload:",f),f}}async function zo(r,a=null,s=null){try{console.log("\u{1F513} Starting COSE processing..."),console.log(`\u{1F4CA} Processing ${r.length} QR string(s)`);let f=await wd(r);if(!f.length)throw console.error("\u274C No complete packets found after assembly"),new Error("No complete packets found");console.log(`\u{1F4CA} Assembled ${f.length} complete packet(s)`),console.log("\u{1F4CA} First assembled packet:",f[0]);let d=[];for(let h of f)try{let p=h.jsonObj,A=h1(p.body||p),y=g1(A,"primary");console.log("\u{1F513} Decompressed CBOR bytes length:",y.length),console.log("\u{1F513} CBOR bytes type:",typeof y,y.constructor.name);let x=y.buffer.slice(y.byteOffset,y.byteOffset+y.byteLength);console.log("\u{1F513} Converted to ArrayBuffer, length:",x.byteLength);let _=Yt.decode(x);console.log("\u{1F513} Decoded COSE structure");let v,R,N,V;if(Array.isArray(_)?([v,R,N,V]=_,console.log("\u{1F513} COSE structure is array format")):(v=_.protected,R=_.unprotected,N=_.payload,V=_.signature,console.log("\u{1F513} COSE structure is object format (legacy)")),s&&V&&V.length>0){let U=Yt.encode([v,R,N]);if(!await crypto.subtle.verify({name:"ECDSA",hash:"SHA-384"},s,V,U)){console.warn("\u26A0\uFE0F Signature verification failed");continue}console.log("\u2705 Signature verified")}let K;if(N instanceof Uint8Array){let U=N.buffer.slice(N.byteOffset,N.byteOffset+N.byteLength);K=Yt.decode(U)}else K=N;console.log("\u{1F513} Inner payload type:",typeof K,K.constructor.name),console.log("\u{1F513} Inner payload keys:",Object.keys(K)),console.log("\u{1F513} Inner payload full object:",K);let H;if(K.ciphertext&&a){console.log("\u{1F513} Decrypting encrypted payload...");let U=K.unprotected?.epk||K.epk,W=await crypto.subtle.importKey("raw",U,{name:"ECDH",namedCurve:"P-384"},!0,[]),te=await crypto.subtle.deriveBits({name:"ECDH",public:W},a,384),z=await crypto.subtle.importKey("raw",te,"HKDF",!1,["deriveKey"]),L=await crypto.subtle.deriveKey({name:"HKDF",hash:"SHA-384",salt:new Uint8Array(0),info:new TextEncoder().encode("SecureBit QR ECDH AES key")},z,{name:"AES-GCM",length:256},!0,["decrypt"]),Y=await crypto.subtle.decrypt({name:"AES-GCM",iv:K.iv},L,K.ciphertext),O=new TextDecoder().decode(Y);H=JSON.parse(O)}else if(K.plaintext)console.log("\u{1F513} Processing plaintext payload..."),H=JSON.parse(new TextDecoder().decode(K.plaintext));else if(Object.keys(K).length===0){console.log("\u{1F513} Empty inner payload, using alternative approach...");try{let U=p.body||p;console.log("\u{1F513} Trying to decode original body:",U.substring(0,50)+"...");let W=h1(U),te=g1(W,"fallback");console.log("\u{1F513} Decompressed length:",te.length);let z=te.buffer.slice(te.byteOffset,te.byteOffset+te.byteLength),L=Yt.decode(z);console.log("\u{1F513} CBOR decoded structure:",L);let Y;if(Array.isArray(L)?(console.log("\u{1F513} Alternative: COSE structure is array format"),console.log("\u{1F513} Array length:",L.length),console.log("\u{1F513} Array elements:",L.map((O,le)=>`${le}: ${typeof O} ${O.constructor.name}`)),Y=L[2],console.log("\u{1F513} Payload at index 2:",Y)):(Y=L.payload,console.log("\u{1F513} Alternative: COSE structure is object format (legacy)")),Y&&Y instanceof Uint8Array){let O=Y.buffer.slice(Y.byteOffset,Y.byteOffset+Y.byteLength),le=Yt.decode(O);if(console.log("\u{1F513} Inner CBOR structure:",le),le.plaintext){let re=new TextDecoder().decode(le.plaintext);H=JSON.parse(re),console.log("\u{1F513} Successfully decoded via alternative approach"),console.log("\u{1F513} Alternative payloadObj:",H)}else{console.error("\u274C No plaintext found in inner CBOR structure");continue}}else if(Y&&typeof Y=="object"&&Object.keys(Y).length>0)if(console.log("\u{1F513} Payload is already decoded object:",Y),Y.plaintext){let O=new TextDecoder().decode(Y.plaintext);H=JSON.parse(O),console.log("\u{1F513} Successfully decoded from payload object"),console.log("\u{1F513} Alternative payloadObj:",H)}else{console.error("\u274C No plaintext found in payload object");continue}else{console.error("\u274C No payload found in CBOR structure"),console.log("\u{1F513} CBOR structure keys:",Object.keys(L)),console.log("\u{1F513} Payload type:",typeof Y),console.log("\u{1F513} Payload value:",Y);continue}}catch(U){console.error("\u274C Alternative approach failed:",U);continue}}else{console.warn("\u26A0\uFE0F Unknown payload format:",K);continue}d.push({payloadObj:H,senderVerified:!!s,encrypted:!!K.ciphertext})}catch(p){console.error("\u274C Error processing packet:",p);continue}return console.log(`\u2705 Successfully processed ${d.length} payload(s)`),d}catch(f){throw console.error("\u274C Error in receiveAndProcess:",f),f}}async function wd(r){let a=new Map;console.log("\u{1F527} Starting assembly of QR strings...");for(let f of r)try{console.log("\u{1F527} Parsing QR string:",f.substring(0,100)+"...");let d=JSON.parse(f);if(console.log("\u{1F527} Parsed structure:",d),d.hdr&&d.body){let h=d.hdr.id;console.log(`\u{1F527} Processing packet ID: ${h}, seq: ${d.hdr.seq}, total: ${d.hdr.total}`),a.has(h)||(a.set(h,{id:h,chunks:new Map,total:d.hdr.total}),console.log(`\u{1F527} Created new packet for ID: ${h}`));let p=a.get(h);if(p.chunks.set(d.hdr.seq,d.body),console.log(`\u{1F527} Added chunk ${d.hdr.seq} to packet ${h}. Current chunks: ${p.chunks.size}/${p.total}`),p.chunks.size===p.total){console.log(`\u{1F527} Packet ${h} is complete! Assembling body...`);let A="";for(let y=1;y<=p.total;y++)A+=p.chunks.get(y);p.jsonObj={body:A},p.complete=!0,console.log(`\u{1F527} Assembled body length: ${A.length} characters`)}}else console.warn("\u26A0\uFE0F QR string missing hdr or body:",d)}catch(d){console.warn("\u26A0\uFE0F Failed to parse QR string:",d);continue}let s=Array.from(a.values()).filter(f=>f.complete);return console.log(`\u{1F527} Assembly complete. Found ${s.length} complete packets`),s}window.packSecurePayload=rs;window.receiveAndProcess=zo;var Ot=Object.freeze({MAX_PAYLOAD_BYTES:512,MAX_CANDIDATES:8,MIN_UFRAG:4,MAX_UFRAG:64,MIN_PWD:22,MAX_PWD:64,FINGERPRINT_BYTES:32,COMMITMENT_BYTES:16,BINDING_BYTES:8,MAX_LIFETIME_MINUTES:60,MAX_EXT_BYTES:255,SURPLUS_CANDIDATE_BYTES:48,CLOCK_SKEW_MS:12e4}),pd=Date.UTC(2024,0,1);var Er=Object.freeze({OFFER:0,ANSWER:1}),Cg=Object.freeze(["actpass","active","passive"]),p1=Object.freeze([262144,1073741823,65536,null]),Ad=3,is=Object.freeze({MAX_MESSAGE_SIZE:1}),_g=Object.freeze({HOST_V4:0,HOST_MDNS:1,SRFLX_V4:2,RELAY_V4:3,HOST_V6:4,SRFLX_V6:5,RELAY_V6:6}),Ed=Object.freeze({0:4,1:16,2:4,3:4,4:16,5:16,6:16}),yg=Object.freeze({0:"host",1:"host",2:"srflx",3:"relay",4:"host",5:"srflx",6:"relay"}),Ig=Object.freeze({0:"v4",1:"mdns",2:"v4",3:"v4",4:"v6",5:"v6",6:"v6"}),md=Object.freeze([null,"passive","active","so"]),bg=Object.freeze({host:126,srflx:100,relay:0}),w1=/^[A-Za-z0-9+/]+$/,Ho=class extends Error{constructor(a,s="malformed"){super(a),this.name="DescriptorError",this.code=s}},me=(r,a)=>{throw new Ho(r,a)};var li=class{constructor(a){this.buf=a,this.i=0}need(a){this.i+a>this.buf.length&&me("descriptor is truncated")}u8(){return this.need(1),this.buf[this.i++]}u16(){this.need(2);let a=this.buf[this.i]<<8|this.buf[this.i+1];return this.i+=2,a}u24(){this.need(3);let a=this.buf[this.i]<<16|this.buf[this.i+1]<<8|this.buf[this.i+2];return this.i+=3,a}u32(){this.need(4);let a=(this.buf[this.i]<<24>>>0)+(this.buf[this.i+1]<<16)+(this.buf[this.i+2]<<8)+this.buf[this.i+3];return this.i+=4,a>>>0}bytes(a){return this.need(a),this.buf.slice(this.i,this.i+=a)}ascii(a){this.need(a);let s="";for(let f=0;f126)&&me("non-printable byte in a text field"),s+=String.fromCharCode(d)}return this.i+=a,s}get rest(){return this.buf.length-this.i}};function Cd(r){let a=new li(r),s=new Map,f=-1;for(;a.rest>0;){let d=a.u8(),h=a.u8(),p=a.bytes(h);if(d<=f&&me("extension records must be in ascending type order without duplicates"),f=d,d===is.MAX_MESSAGE_SIZE){h!==4&&me("extension 0x01 must be 4 bytes");let A=new li(p).u32();(A<1024||A>2147483647)&&me("extension 0x01 value is out of range"),p1.includes(A)&&me("extension 0x01 duplicates a value the flags already encode"),s.set(d,A)}else me(`unknown extension type 0x${d.toString(16).padStart(2,"0")}`,"unknown_extension")}return s}function Vo(r,{nowMs:a=Date.now()}={}){r instanceof Uint8Array||me("descriptor must be a Uint8Array"),r.length===0&&me("descriptor is empty"),r.length>Ot.MAX_PAYLOAD_BYTES&&me("descriptor exceeds the payload limit");let s=new li(r),f=s.u8();f!==2&&me(`unsupported descriptor version 0x${f.toString(16)}`,"version");let d=s.u8(),h=d&3;h!==Er.OFFER&&h!==Er.ANSWER&&me("reserved descriptor type");let p=d>>2&3;p>2&&me("reserved DTLS setup role");let A=d>>4&3,y=(d&64)!==0,x=(d&128)!==0,_=s.u24(),v=pd+_*6e4;if(a-Ot.CLOCK_SKEW_MS>v){let O=Math.round((a-v)/6e4);me(`this code expired ${O} minute(s) ago. If it was just created, this device's clock or time zone is probably wrong \u2014 check the date and time settings.`,"expired")}v-a>Ot.MAX_LIFETIME_MINUTES*6e4+Ot.CLOCK_SKEW_MS&&me("descriptor lifetime is implausibly long","lifetime");let R=h===Er.ANSWER?s.bytes(Ot.BINDING_BYTES):null,N=s.bytes(Ot.FINGERPRINT_BYTES),V=s.u8();(VOt.MAX_UFRAG)&&me("ice-ufrag length out of range");let K=s.ascii(V);w1.test(K)||me("ice-ufrag contains characters outside the ICE alphabet");let H=s.u8();(HOt.MAX_PWD)&&me("ice-pwd length out of range");let U=s.ascii(H);w1.test(U)||me("ice-pwd contains characters outside the ICE alphabet");let W=s.u8();W>Ot.MAX_CANDIDATES&&me("too many candidates");let te=[];for(let O=0;O>4&15,k=le&15,G=Ed[re];G===void 0&&me(`reserved candidate kind ${re}`),k>=md.length&&me("reserved TCP candidate type");let $=s.bytes(G),M=s.u16();M<1&&me("candidate port must be non-zero"),te.push({kind:re,tcptype:k,addr:$,port:M})}let z=null;y&&(z=s.bytes(Ot.COMMITMENT_BYTES));let L=new Map;if(x){let O=s.u8();O===0&&me("extension area is flagged but empty"),L=Cd(s.bytes(O))}s.rest!==0&&me(`${s.rest} trailing byte(s) after the descriptor`);let Y;return A===Ad?(L.has(is.MAX_MESSAGE_SIZE)||me("flags promise an explicit max-message-size but no extension carries it"),Y=L.get(is.MAX_MESSAGE_SIZE)):(L.has(is.MAX_MESSAGE_SIZE)&&me("extension 0x01 present but the flags do not select it"),Y=p1[A]),{version:f,type:h,setup:p,maxMessageSize:Y,expiresAtMs:v,bindingTag:R,fingerprint:N,ufrag:K,pwd:U,candidates:te,commitment:z,extensions:L}}var Sg=new TextEncoder;var ai="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function _d(r){let a="";for(let s=0;s>2],a+=ai[(f&3)<<4|(d??0)>>4],d===void 0||(a+=ai[(d&15)<<2|(h??0)>>6],h===void 0))break;a+=ai[h&63]}return a}function yd(r){typeof r!="string"&&me("payload must be a string");let a=r.replace(/\s+/g,"");a.length>Math.ceil(Ot.MAX_PAYLOAD_BYTES*4/3)+4&&me("payload is too long"),/^[A-Za-z0-9_-]*$/.test(a)||me("payload contains characters outside base64url"),a.length%4===1&&me("payload has an impossible length");let s=new Uint8Array(Math.floor(a.length*3/4)),f=0,d=0,h=0;for(let p of a)d=d<<6|ai.indexOf(p),h+=6,h>=8&&(h-=8,s[f++]=d>>h&255);return d&(1<d.charCodeAt(0)&255);return{t:Vo(s).type===Er.OFFER?"offer":"answer",sbq2:A1(s)}}let a=/^SB(\d+):/.exec(r);if(a&&a[1]!=="1"&&a[1]!=="2")throw new Error("This invitation was created by a newer version of SecureBit. Please update the app to connect.");if(r.startsWith(ss)){let s=r.slice(ss.length);return Td(s)}return r.startsWith(ci)?window.decompressIfNeeded(r):r}}catch(a){if(typeof r=="string"&&(r.startsWith(mr)||r.charCodeAt(0)===2||/^SB(\d+):/.test(r)))throw a;console.warn("decodeAnyPayload failed:",a?.message||a)}return r};console.log("QR libraries loaded: generateQRCode, generateCompressedQRCode, generateBinaryQRCodeFromObject, Html5Qrcode, COSE functions"); /*! Bundled license information: pako/dist/pako.esm.mjs: (*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) *) */ //# sourceMappingURL=qr-local.js.map