@danidoble/webserial 4.5.0-beta.4 → 4.5.0-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/pinpad.cjs CHANGED
@@ -1,19 +1,22 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("./kernel-c6KuKgQ5.cjs"),pe=require("./devices-CcYKrJpP.cjs");var gi="0123456789abcdefghijklmnopqrstuvwxyz";function G(n){return gi.charAt(n)}function mi(n,t){return n&t}function St(n,t){return n|t}function de(n,t){return n^t}function _e(n,t){return n&~t}function yi(n){if(n==0)return-1;var t=0;return(n&65535)==0&&(n>>=16,t+=16),(n&255)==0&&(n>>=8,t+=8),(n&15)==0&&(n>>=4,t+=4),(n&3)==0&&(n>>=2,t+=2),(n&1)==0&&++t,t}function bi(n){for(var t=0;n!=0;)n&=n-1,++t;return t}var ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ke="=";function mt(n){var t,e,i="";for(t=0;t+3<=n.length;t+=3)e=parseInt(n.substring(t,t+3),16),i+=ht.charAt(e>>6)+ht.charAt(e&63);for(t+1==n.length?(e=parseInt(n.substring(t,t+1),16),i+=ht.charAt(e<<2)):t+2==n.length&&(e=parseInt(n.substring(t,t+2),16),i+=ht.charAt(e>>2)+ht.charAt((e&3)<<4));(i.length&3)>0;)i+=Ke;return i}function ge(n){var t="",e,i=0,r=0;for(e=0;e<n.length&&n.charAt(e)!=Ke;++e){var s=ht.indexOf(n.charAt(e));s<0||(i==0?(t+=G(s>>2),r=s&3,i=1):i==1?(t+=G(r<<2|s>>4),r=s&15,i=2):i==2?(t+=G(r),t+=G(s>>2),r=s&3,i=3):(t+=G(r<<2|s>>4),t+=G(s&15),i=0))}return i==1&&(t+=G(r<<2)),t}var ct,Pi={decode:function(n){var t;if(ct===void 0){var e="0123456789ABCDEF",i=` \f
2
- \r  \u2028\u2029`;for(ct={},t=0;t<16;++t)ct[e.charAt(t)]=t;for(e=e.toLowerCase(),t=10;t<16;++t)ct[e.charAt(t)]=t;for(t=0;t<i.length;++t)ct[i.charAt(t)]=-1}var r=[],s=0,a=0;for(t=0;t<n.length;++t){var o=n.charAt(t);if(o=="=")break;if(o=ct[o],o!=-1){if(o===void 0)throw new Error("Illegal character at offset "+t);s|=o,++a>=2?(r[r.length]=s,s=0,a=0):s<<=4}}if(a)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},et,Qt={decode:function(n){var t;if(et===void 0){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=`= \f
3
- \r  \u2028\u2029`;for(et=Object.create(null),t=0;t<64;++t)et[e.charAt(t)]=t;for(et["-"]=62,et._=63,t=0;t<i.length;++t)et[i.charAt(t)]=-1}var r=[],s=0,a=0;for(t=0;t<n.length;++t){var o=n.charAt(t);if(o=="=")break;if(o=et[o],o!=-1){if(o===void 0)throw new Error("Illegal character at offset "+t);s|=o,++a>=4?(r[r.length]=s>>16,r[r.length]=s>>8&255,r[r.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=s>>10;break;case 3:r[r.length]=s>>16,r[r.length]=s>>8&255;break}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(n){var t=Qt.re.exec(n);if(t)if(t[1])n=t[1];else if(t[2])n=t[2];else throw new Error("RegExp out of sync");return Qt.decode(n)}},ut=1e13,gt=(function(){function n(t){this.buf=[+t||0]}return n.prototype.mulAdd=function(t,e){var i=this.buf,r=i.length,s,a;for(s=0;s<r;++s)a=i[s]*t+e,a<ut?e=0:(e=0|a/ut,a-=e*ut),i[s]=a;e>0&&(i[s]=e)},n.prototype.sub=function(t){var e=this.buf,i=e.length,r,s;for(r=0;r<i;++r)s=e[r]-t,s<0?(s+=ut,t=1):t=0,e[r]=s;for(;e[e.length-1]===0;)e.pop()},n.prototype.toString=function(t){if((t||10)!=10)throw new Error("only base 10 is supported");for(var e=this.buf,i=e[e.length-1].toString(),r=e.length-2;r>=0;--r)i+=(ut+e[r]).toString().substring(1);return i},n.prototype.valueOf=function(){for(var t=this.buf,e=0,i=t.length-1;i>=0;--i)e=e*ut+t[i];return e},n.prototype.simplify=function(){var t=this.buf;return t.length==1?t[0]:this},n})(),He="…",vi=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,Ei=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function lt(n,t){return n.length>t&&(n=n.substring(0,t)+He),n}var Ht=(function(){function n(t,e){this.hexDigits="0123456789ABCDEF",t instanceof n?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}return n.prototype.get=function(t){if(t===void 0&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset ".concat(t," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(t):this.enc[t]},n.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(t&15)},n.prototype.hexDump=function(t,e,i){for(var r="",s=t;s<e;++s)if(r+=this.hexByte(this.get(s)),i!==!0)switch(s&15){case 7:r+=" ";break;case 15:r+=`
4
- `;break;default:r+=" "}return r},n.prototype.isASCII=function(t,e){for(var i=t;i<e;++i){var r=this.get(i);if(r<32||r>176)return!1}return!0},n.prototype.parseStringISO=function(t,e){for(var i="",r=t;r<e;++r)i+=String.fromCharCode(this.get(r));return i},n.prototype.parseStringUTF=function(t,e){for(var i="",r=t;r<e;){var s=this.get(r++);s<128?i+=String.fromCharCode(s):s>191&&s<224?i+=String.fromCharCode((s&31)<<6|this.get(r++)&63):i+=String.fromCharCode((s&15)<<12|(this.get(r++)&63)<<6|this.get(r++)&63)}return i},n.prototype.parseStringBMP=function(t,e){for(var i="",r,s,a=t;a<e;)r=this.get(a++),s=this.get(a++),i+=String.fromCharCode(r<<8|s);return i},n.prototype.parseTime=function(t,e,i){var r=this.parseStringISO(t,e),s=(i?vi:Ei).exec(r);return s?(i&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),r=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(r+=":"+s[5],s[6]&&(r+=":"+s[6],s[7]&&(r+="."+s[7]))),s[8]&&(r+=" UTC",s[8]!="Z"&&(r+=s[8],s[9]&&(r+=":"+s[9]))),r):"Unrecognized time: "+r},n.prototype.parseInteger=function(t,e){for(var i=this.get(t),r=i>127,s=r?255:0,a,o="";i==s&&++t<e;)i=this.get(t);if(a=e-t,a===0)return r?-1:0;if(a>4){for(o=i,a<<=3;((+o^s)&128)==0;)o=+o<<1,--a;o="("+a+` bit)
5
- `}r&&(i=i-256);for(var c=new gt(i),h=t+1;h<e;++h)c.mulAdd(256,this.get(h));return o+c.toString()},n.prototype.parseBitString=function(t,e,i){for(var r=this.get(t),s=(e-t-1<<3)-r,a="("+s+` bit)
6
- `,o="",c=t+1;c<e;++c){for(var h=this.get(c),u=c==e-1?r:0,f=7;f>=u;--f)o+=h>>f&1?"1":"0";if(o.length>i)return a+lt(o,i)}return a+o},n.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return lt(this.parseStringISO(t,e),i);var r=e-t,s="("+r+` byte)
7
- `;i/=2,r>i&&(e=t+i);for(var a=t;a<e;++a)s+=this.hexByte(this.get(a));return r>i&&(s+=He),s},n.prototype.parseOID=function(t,e,i){for(var r="",s=new gt,a=0,o=t;o<e;++o){var c=this.get(o);if(s.mulAdd(128,c&127),a+=7,!(c&128)){if(r==="")if(s=s.simplify(),s instanceof gt)s.sub(80),r="2."+s.toString();else{var h=s<80?s<40?0:1:2;r=h+"."+(s-h*40)}else r+="."+s.toString();if(r.length>i)return lt(r,i);s=new gt,a=0}}return a>0&&(r+=".incomplete"),r},n})(),wi=(function(){function n(t,e,i,r,s){if(!(r instanceof me))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=s}return n.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},n.prototype.content=function(t){if(this.tag===void 0)return null;t===void 0&&(t=1/0);var e=this.posContent(),i=Math.abs(this.length);if(!this.tag.isUniversal())return this.sub!==null?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);switch(this.tag.tagNumber){case 1:return this.stream.get(e)===0?"false":"true";case 2:return this.stream.parseInteger(e,e+i);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+i,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);case 6:return this.stream.parseOID(e,e+i,t);case 16:case 17:return this.sub!==null?"("+this.sub.length+" elem)":"(no elem)";case 12:return lt(this.stream.parseStringUTF(e,e+i),t);case 18:case 19:case 20:case 21:case 22:case 26:return lt(this.stream.parseStringISO(e,e+i),t);case 30:return lt(this.stream.parseStringBMP(e,e+i),t);case 23:case 24:return this.stream.parseTime(e,e+i,this.tag.tagNumber==23)}return null},n.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"},n.prototype.toPrettyString=function(t){t===void 0&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":this.tag.isUniversal()&&(this.tag.tagNumber==3||this.tag.tagNumber==4)&&this.sub!==null&&(e+=" (encapsulates)"),e+=`
8
- `,this.sub!==null){t+=" ";for(var i=0,r=this.sub.length;i<r;++i)e+=this.sub[i].toPrettyString(t)}return e},n.prototype.posStart=function(){return this.stream.pos},n.prototype.posContent=function(){return this.stream.pos+this.header},n.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},n.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},n.decodeLength=function(t){var e=t.get(),i=e&127;if(i==e)return i;if(i>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(i===0)return null;e=0;for(var r=0;r<i;++r)e=e*256+t.get();return e},n.prototype.getHexStringValue=function(){var t=this.toHexString(),e=this.header*2,i=this.length*2;return t.substring(e,e+i)},n.decode=function(t){var e;t instanceof Ht?e=t:e=new Ht(t,0);var i=new Ht(e),r=new me(e),s=n.decodeLength(e),a=e.pos,o=a-i.pos,c=null,h=function(){var f=[];if(s!==null){for(var _=a+s;e.pos<_;)f[f.length]=n.decode(e);if(e.pos!=_)throw new Error("Content size is not correct for container starting at offset "+a)}else try{for(;;){var y=n.decode(e);if(y.tag.isEOC())break;f[f.length]=y}s=a-e.pos}catch(p){throw new Error("Exception while decoding undefined length content: "+p)}return f};if(r.tagConstructed)c=h();else if(r.isUniversal()&&(r.tagNumber==3||r.tagNumber==4))try{if(r.tagNumber==3&&e.get()!=0)throw new Error("BIT STRINGs with unused bits cannot encapsulate.");c=h();for(var u=0;u<c.length;++u)if(c[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch{c=null}if(c===null){if(s===null)throw new Error("We can't skip over an invalid tag with undefined length at offset "+a);e.pos=a+Math.abs(s)}return new n(i,o,s,r,c)},n})(),me=(function(){function n(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=(e&32)!==0,this.tagNumber=e&31,this.tagNumber==31){var i=new gt;do e=t.get(),i.mulAdd(128,e&127);while(e&128);this.tagNumber=i.simplify()}}return n.prototype.isUniversal=function(){return this.tagClass===0},n.prototype.isEOC=function(){return this.tagClass===0&&this.tagNumber===0},n})(),Y,Si=0xdeadbeefcafe,ye=(Si&16777215)==15715070,x=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Ti=(1<<26)/x[x.length-1],v=(function(){function n(t,e,i){t!=null&&(typeof t=="number"?this.fromNumber(t,e,i):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}return n.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var i=(1<<e)-1,r,s=!1,a="",o=this.t,c=this.DB-o*this.DB%e;if(o-- >0)for(c<this.DB&&(r=this[o]>>c)>0&&(s=!0,a=G(r));o>=0;)c<e?(r=(this[o]&(1<<c)-1)<<e-c,r|=this[--o]>>(c+=this.DB-e)):(r=this[o]>>(c-=e)&i,c<=0&&(c+=this.DB,--o)),r>0&&(s=!0),s&&(a+=G(r));return s?a:"0"},n.prototype.negate=function(){var t=E();return n.ZERO.subTo(this,t),t},n.prototype.abs=function(){return this.s<0?this.negate():this},n.prototype.compareTo=function(t){var e=this.s-t.s;if(e!=0)return e;var i=this.t;if(e=i-t.t,e!=0)return this.s<0?-e:e;for(;--i>=0;)if((e=this[i]-t[i])!=0)return e;return 0},n.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+Tt(this[this.t-1]^this.s&this.DM)},n.prototype.mod=function(t){var e=E();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(n.ZERO)>0&&t.subTo(e,e),e},n.prototype.modPowInt=function(t,e){var i;return t<256||e.isEven()?i=new be(e):i=new Pe(e),this.exp(t,i)},n.prototype.clone=function(){var t=E();return this.copyTo(t),t},n.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},n.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},n.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},n.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},n.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var i=this.DB-t*this.DB%8,r,s=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[s++]=r|this.s<<this.DB-i);t>=0;)i<8?(r=(this[t]&(1<<i)-1)<<8-i,r|=this[--t]>>(i+=this.DB-8)):(r=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),(r&128)!=0&&(r|=-256),s==0&&(this.s&128)!=(r&128)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e},n.prototype.equals=function(t){return this.compareTo(t)==0},n.prototype.min=function(t){return this.compareTo(t)<0?this:t},n.prototype.max=function(t){return this.compareTo(t)>0?this:t},n.prototype.and=function(t){var e=E();return this.bitwiseTo(t,mi,e),e},n.prototype.or=function(t){var e=E();return this.bitwiseTo(t,St,e),e},n.prototype.xor=function(t){var e=E();return this.bitwiseTo(t,de,e),e},n.prototype.andNot=function(t){var e=E();return this.bitwiseTo(t,_e,e),e},n.prototype.not=function(){for(var t=E(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},n.prototype.shiftLeft=function(t){var e=E();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},n.prototype.shiftRight=function(t){var e=E();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},n.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(this[t]!=0)return t*this.DB+yi(this[t]);return this.s<0?this.t*this.DB:-1},n.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=bi(this[i]^e);return t},n.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this[e]&1<<t%this.DB)!=0},n.prototype.setBit=function(t){return this.changeBit(t,St)},n.prototype.clearBit=function(t){return this.changeBit(t,_e)},n.prototype.flipBit=function(t){return this.changeBit(t,de)},n.prototype.add=function(t){var e=E();return this.addTo(t,e),e},n.prototype.subtract=function(t){var e=E();return this.subTo(t,e),e},n.prototype.multiply=function(t){var e=E();return this.multiplyTo(t,e),e},n.prototype.divide=function(t){var e=E();return this.divRemTo(t,e,null),e},n.prototype.remainder=function(t){var e=E();return this.divRemTo(t,null,e),e},n.prototype.divideAndRemainder=function(t){var e=E(),i=E();return this.divRemTo(t,e,i),[e,i]},n.prototype.modPow=function(t,e){var i=t.bitLength(),r,s=Q(1),a;if(i<=0)return s;i<18?r=1:i<48?r=3:i<144?r=4:i<768?r=5:r=6,i<8?a=new be(e):e.isEven()?a=new Ci(e):a=new Pe(e);var o=[],c=3,h=r-1,u=(1<<r)-1;if(o[1]=a.convert(this),r>1){var f=E();for(a.sqrTo(o[1],f);c<=u;)o[c]=E(),a.mulTo(f,o[c-2],o[c]),c+=2}var _=t.t-1,y,p=!0,m=E(),g;for(i=Tt(t[_])-1;_>=0;){for(i>=h?y=t[_]>>i-h&u:(y=(t[_]&(1<<i+1)-1)<<h-i,_>0&&(y|=t[_-1]>>this.DB+i-h)),c=r;(y&1)==0;)y>>=1,--c;if((i-=c)<0&&(i+=this.DB,--_),p)o[y].copyTo(s),p=!1;else{for(;c>1;)a.sqrTo(s,m),a.sqrTo(m,s),c-=2;c>0?a.sqrTo(s,m):(g=s,s=m,m=g),a.mulTo(m,o[y],s)}for(;_>=0&&(t[_]&1<<i)==0;)a.sqrTo(s,m),g=s,s=m,m=g,--i<0&&(i=this.DB-1,--_)}return a.revert(s)},n.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return n.ZERO;for(var i=t.clone(),r=this.clone(),s=Q(1),a=Q(0),o=Q(0),c=Q(1);i.signum()!=0;){for(;i.isEven();)i.rShiftTo(1,i),e?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);for(;r.isEven();)r.rShiftTo(1,r),e?((!o.isEven()||!c.isEven())&&(o.addTo(this,o),c.subTo(t,c)),o.rShiftTo(1,o)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);i.compareTo(r)>=0?(i.subTo(r,i),e&&s.subTo(o,s),a.subTo(c,a)):(r.subTo(i,r),e&&o.subTo(s,o),c.subTo(a,c))}if(r.compareTo(n.ONE)!=0)return n.ZERO;if(c.compareTo(t)>=0)return c.subtract(t);if(c.signum()<0)c.addTo(t,c);else return c;return c.signum()<0?c.add(t):c},n.prototype.pow=function(t){return this.exp(t,new Ai)},n.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var s=e.getLowestSetBit(),a=i.getLowestSetBit();if(a<0)return e;for(s<a&&(a=s),a>0&&(e.rShiftTo(a,e),i.rShiftTo(a,i));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),e.compareTo(i)>=0?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return a>0&&i.lShiftTo(a,i),i},n.prototype.isProbablePrime=function(t){var e,i=this.abs();if(i.t==1&&i[0]<=x[x.length-1]){for(e=0;e<x.length;++e)if(i[0]==x[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<x.length;){for(var r=x[e],s=e+1;s<x.length&&r<Ti;)r*=x[s++];for(r=i.modInt(r);e<s;)if(r%x[e++]==0)return!1}return i.millerRabin(t)},n.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},n.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},n.prototype.fromString=function(t,e){var i;if(e==16)i=4;else if(e==8)i=3;else if(e==256)i=8;else if(e==2)i=1;else if(e==32)i=5;else if(e==4)i=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var r=t.length,s=!1,a=0;--r>=0;){var o=i==8?+t[r]&255:Ee(t,r);if(o<0){t.charAt(r)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=o:a+i>this.DB?(this[this.t-1]|=(o&(1<<this.DB-a)-1)<<a,this[this.t++]=o>>this.DB-a):this[this.t-1]|=o<<a,a+=i,a>=this.DB&&(a-=this.DB)}i==8&&(+t[0]&128)!=0&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&n.ZERO.subTo(this,this)},n.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},n.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;i>=0;--i)e[i+t]=this[i];for(i=t-1;i>=0;--i)e[i]=0;e.t=this.t+t,e.s=this.s},n.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},n.prototype.lShiftTo=function(t,e){for(var i=t%this.DB,r=this.DB-i,s=(1<<r)-1,a=Math.floor(t/this.DB),o=this.s<<i&this.DM,c=this.t-1;c>=0;--c)e[c+a+1]=this[c]>>r|o,o=(this[c]&s)<<i;for(var c=a-1;c>=0;--c)e[c]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},n.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t){e.t=0;return}var r=t%this.DB,s=this.DB-r,a=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&a)<<s,e[o-i]=this[o]>>r;r>0&&(e[this.t-i-1]|=(this.s&a)<<s),e.t=this.t-i,e.clamp()},n.prototype.subTo=function(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);i<s;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:r>0&&(e[i++]=r),e.t=i,e.clamp()},n.prototype.multiplyTo=function(t,e){var i=this.abs(),r=t.abs(),s=i.t;for(e.t=s+r.t;--s>=0;)e[s]=0;for(s=0;s<r.t;++s)e[s+i.t]=i.am(0,r[s],e,s,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&n.ZERO.subTo(e,e)},n.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;--i>=0;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},n.prototype.divRemTo=function(t,e,i){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t){e?.fromInt(0),i!=null&&this.copyTo(i);return}i==null&&(i=E());var a=E(),o=this.s,c=t.s,h=this.DB-Tt(r[r.t-1]);h>0?(r.lShiftTo(h,a),s.lShiftTo(h,i)):(r.copyTo(a),s.copyTo(i));var u=a.t,f=a[u-1];if(f!=0){var _=f*(1<<this.F1)+(u>1?a[u-2]>>this.F2:0),y=this.FV/_,p=(1<<this.F1)/_,m=1<<this.F2,g=i.t,w=g-u,A=e??E();for(a.dlShiftTo(w,A),i.compareTo(A)>=0&&(i[i.t++]=1,i.subTo(A,i)),n.ONE.dlShiftTo(u,A),A.subTo(a,a);a.t<u;)a[a.t++]=0;for(;--w>=0;){var T=i[--g]==f?this.DM:Math.floor(i[g]*y+(i[g-1]+m)*p);if((i[g]+=a.am(0,T,i,w,0,u))<T)for(a.dlShiftTo(w,A),i.subTo(A,i);i[g]<--T;)i.subTo(A,i)}e!=null&&(i.drShiftTo(u,e),o!=c&&n.ZERO.subTo(e,e)),i.t=u,i.clamp(),h>0&&i.rShiftTo(h,i),o<0&&n.ZERO.subTo(i,i)}}},n.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e},n.prototype.isEven=function(){return(this.t>0?this[0]&1:this.s)==0},n.prototype.exp=function(t,e){if(t>4294967295||t<1)return n.ONE;var i=E(),r=E(),s=e.convert(this),a=Tt(t)-1;for(s.copyTo(i);--a>=0;)if(e.sqrTo(i,r),(t&1<<a)>0)e.mulTo(r,s,i);else{var o=i;i=r,r=o}return e.revert(i)},n.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},n.prototype.toRadix=function(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=Q(i),s=E(),a=E(),o="";for(this.divRemTo(r,s,a);s.signum()>0;)o=(i+a.intValue()).toString(t).substring(1)+o,s.divRemTo(r,s,a);return a.intValue().toString(t)+o},n.prototype.fromRadix=function(t,e){this.fromInt(0),e==null&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),s=!1,a=0,o=0,c=0;c<t.length;++c){var h=Ee(t,c);if(h<0){t.charAt(c)=="-"&&this.signum()==0&&(s=!0);continue}o=e*o+h,++a>=i&&(this.dMultiply(r),this.dAddOffset(o,0),a=0,o=0)}a>0&&(this.dMultiply(Math.pow(e,a)),this.dAddOffset(o,0)),s&&n.ZERO.subTo(this,this)},n.prototype.fromNumber=function(t,e,i){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(n.ONE.shiftLeft(t-1),St,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(n.ONE.shiftLeft(t-1),this);else{var r=[],s=t&7;r.length=(t>>3)+1,e.nextBytes(r),s>0?r[0]&=(1<<s)-1:r[0]=0,this.fromString(r,256)}},n.prototype.bitwiseTo=function(t,e,i){var r,s,a=Math.min(t.t,this.t);for(r=0;r<a;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=a;r<this.t;++r)i[r]=e(this[r],s);i.t=this.t}else{for(s=this.s&this.DM,r=a;r<t.t;++r)i[r]=e(s,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},n.prototype.changeBit=function(t,e){var i=n.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},n.prototype.addTo=function(t,e){for(var i=0,r=0,s=Math.min(t.t,this.t);i<s;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()},n.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},n.prototype.dAddOffset=function(t,e){if(t!=0){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},n.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(var s=i.t-this.t;r<s;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(var s=Math.min(t.t,e);r<s;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()},n.prototype.multiplyUpperTo=function(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;--r>=0;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)},n.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(this.t>0)if(e==0)i=this[0]%t;else for(var r=this.t-1;r>=0;--r)i=(e*i+this[r])%t;return i},n.prototype.millerRabin=function(t){var e=this.subtract(n.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var r=e.shiftRight(i);t=t+1>>1,t>x.length&&(t=x.length);for(var s=E(),a=0;a<t;++a){s.fromInt(x[Math.floor(Math.random()*x.length)]);var o=s.modPow(r,this);if(o.compareTo(n.ONE)!=0&&o.compareTo(e)!=0){for(var c=1;c++<i&&o.compareTo(e)!=0;)if(o=o.modPowInt(2,this),o.compareTo(n.ONE)==0)return!1;if(o.compareTo(e)!=0)return!1}}return!0},n.prototype.square=function(){var t=E();return this.squareTo(t),t},n.prototype.gcda=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var s=i;i=r,r=s}var a=i.getLowestSetBit(),o=r.getLowestSetBit();if(o<0){e(i);return}a<o&&(o=a),o>0&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var c=function(){(a=i.getLowestSetBit())>0&&i.rShiftTo(a,i),(a=r.getLowestSetBit())>0&&r.rShiftTo(a,r),i.compareTo(r)>=0?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),i.signum()>0?setTimeout(c,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(c,10)},n.prototype.fromNumberAsync=function(t,e,i,r){if(typeof e=="number")if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(n.ONE.shiftLeft(t-1),St,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(n.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(a,0)};setTimeout(a,0)}else{var o=[],c=t&7;o.length=(t>>3)+1,e.nextBytes(o),c>0?o[0]&=(1<<c)-1:o[0]=0,this.fromString(o,256)}},n})(),Ai=(function(){function n(){}return n.prototype.convert=function(t){return t},n.prototype.revert=function(t){return t},n.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},n.prototype.sqrTo=function(t,e){t.squareTo(e)},n})(),be=(function(){function n(t){this.m=t}return n.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},n.prototype.revert=function(t){return t},n.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},n.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},n.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n})(),Pe=(function(){function n(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return n.prototype.convert=function(t){var e=E();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(v.ZERO)>0&&this.m.subTo(e,e),e},n.prototype.revert=function(t){var e=E();return t.copyTo(e),this.reduce(e),e},n.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=t[e]&32767,r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(i=e+this.m.t,t[i]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},n.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},n.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n})(),Ci=(function(){function n(t){this.m=t,this.r2=E(),this.q3=E(),v.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return n.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=E();return t.copyTo(e),this.reduce(e),e},n.prototype.revert=function(t){return t},n.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},n.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},n.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},n})();function E(){return new v(null)}function C(n,t){return new v(n,t)}var ve=typeof navigator<"u";ve&&ye&&navigator.appName=="Microsoft Internet Explorer"?(v.prototype.am=function(t,e,i,r,s,a){for(var o=e&32767,c=e>>15;--a>=0;){var h=this[t]&32767,u=this[t++]>>15,f=c*h+u*o;h=o*h+((f&32767)<<15)+i[r]+(s&1073741823),s=(h>>>30)+(f>>>15)+c*u+(s>>>30),i[r++]=h&1073741823}return s},Y=30):ve&&ye&&navigator.appName!="Netscape"?(v.prototype.am=function(t,e,i,r,s,a){for(;--a>=0;){var o=e*this[t++]+i[r]+s;s=Math.floor(o/67108864),i[r++]=o&67108863}return s},Y=26):(v.prototype.am=function(t,e,i,r,s,a){for(var o=e&16383,c=e>>14;--a>=0;){var h=this[t]&16383,u=this[t++]>>14,f=c*h+u*o;h=o*h+((f&16383)<<14)+i[r]+s,s=(h>>28)+(f>>14)+c*u,i[r++]=h&268435455}return s},Y=28);v.prototype.DB=Y;v.prototype.DM=(1<<Y)-1;v.prototype.DV=1<<Y;var ne=52;v.prototype.FV=Math.pow(2,ne);v.prototype.F1=ne-Y;v.prototype.F2=2*Y-ne;var Lt=[],pt,q;pt=48;for(q=0;q<=9;++q)Lt[pt++]=q;pt=97;for(q=10;q<36;++q)Lt[pt++]=q;pt=65;for(q=10;q<36;++q)Lt[pt++]=q;function Ee(n,t){var e=Lt[n.charCodeAt(t)];return e??-1}function Q(n){var t=E();return t.fromInt(n),t}function Tt(n){var t=1,e;return(e=n>>>16)!=0&&(n=e,t+=16),(e=n>>8)!=0&&(n=e,t+=8),(e=n>>4)!=0&&(n=e,t+=4),(e=n>>2)!=0&&(n=e,t+=2),(e=n>>1)!=0&&(n=e,t+=1),t}v.ZERO=Q(0);v.ONE=Q(1);var Ri=(function(){function n(){this.i=0,this.j=0,this.S=[]}return n.prototype.init=function(t){var e,i,r;for(e=0;e<256;++e)this.S[e]=e;for(i=0,e=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0},n.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},n})();function Oi(){return new Ri}var We=256,At,Z=null,K;if(Z==null){Z=[],K=0;var Ct=void 0;if(typeof window<"u"&&self.crypto&&self.crypto.getRandomValues){var Wt=new Uint32Array(256);for(self.crypto.getRandomValues(Wt),Ct=0;Ct<Wt.length;++Ct)Z[K++]=Wt[Ct]&255}var Rt=0,Ot=function(n){if(Rt=Rt||0,Rt>=256||K>=We){self.removeEventListener?self.removeEventListener("mousemove",Ot,!1):self.detachEvent&&self.detachEvent("onmousemove",Ot);return}try{var t=n.x+n.y;Z[K++]=t&255,Rt+=1}catch{}};typeof window<"u"&&(self.addEventListener?self.addEventListener("mousemove",Ot,!1):self.attachEvent&&self.attachEvent("onmousemove",Ot))}function Di(){if(At==null){for(At=Oi();K<We;){var n=Math.floor(65536*Math.random());Z[K++]=n&255}for(At.init(Z),K=0;K<Z.length;++K)Z[K]=0;K=0}return At.next()}var Vt=(function(){function n(){}return n.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Di()},n})();function Zt(n){return Ni(ki(Ii(n),n.length*8))}function we(n){for(var t="0123456789abcdef",e="",i=0;i<n.length;i++){var r=n.charCodeAt(i);e+=t.charAt(r>>>4&15)+t.charAt(r&15)}return e}function Ii(n){for(var t=Array(n.length>>2),e=0;e<t.length;e++)t[e]=0;for(var e=0;e<n.length*8;e+=8)t[e>>5]|=(n.charCodeAt(e/8)&255)<<24-e%32;return t}function Ni(n){for(var t="",e=0;e<n.length*32;e+=8)t+=String.fromCharCode(n[e>>5]>>>24-e%32&255);return t}function X(n,t){return n>>>t|n<<32-t}function Xe(n,t){return n>>>t}function Bi(n,t,e){return n&t^~n&e}function xi(n,t,e){return n&t^n&e^t&e}function Vi(n){return X(n,2)^X(n,13)^X(n,22)}function Ui(n){return X(n,6)^X(n,11)^X(n,25)}function Li(n){return X(n,7)^X(n,18)^Xe(n,3)}function Mi(n){return X(n,17)^X(n,19)^Xe(n,10)}var Fi=new Array(1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998);function ki(n,t){var e=new Array(1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225),i=new Array(64),r,s,a,o,c,h,u,f,_,y,p,m;for(n[t>>5]|=128<<24-t%32,n[(t+64>>9<<4)+15]=t,_=0;_<n.length;_+=16){for(r=e[0],s=e[1],a=e[2],o=e[3],c=e[4],h=e[5],u=e[6],f=e[7],y=0;y<64;y++)y<16?i[y]=n[y+_]:i[y]=I(I(I(Mi(i[y-2]),i[y-7]),Li(i[y-15])),i[y-16]),p=I(I(I(I(f,Ui(c)),Bi(c,h,u)),Fi[y]),i[y]),m=I(Vi(r),xi(r,s,a)),f=u,u=h,h=c,c=I(o,p),o=a,a=s,s=r,r=I(p,m);e[0]=I(r,e[0]),e[1]=I(s,e[1]),e[2]=I(a,e[2]),e[3]=I(o,e[3]),e[4]=I(c,e[4]),e[5]=I(h,e[5]),e[6]=I(u,e[6]),e[7]=I(f,e[7])}return e}function I(n,t){var e=(n&65535)+(t&65535),i=(n>>16)+(t>>16)+(e>>16);return i<<16|e&65535}function ji(n,t){if(t<n.length+22)return console.error("Message too long for RSA"),null;for(var e=t-n.length-6,i="",r=0;r<e;r+=2)i+="ff";var s="0001"+i+"00"+n;return C(s,16)}function qi(n,t){if(t<n.length+11)return console.error("Message too long for RSA"),null;for(var e=[],i=n.length-1;i>=0&&t>0;){var r=n.charCodeAt(i--);r<128?e[--t]=r:r>127&&r<2048?(e[--t]=r&63|128,e[--t]=r>>6|192):(e[--t]=r&63|128,e[--t]=r>>6&63|128,e[--t]=r>>12|224)}e[--t]=0;for(var s=new Vt,a=[];t>2;){for(a[0]=0;a[0]==0;)s.nextBytes(a);e[--t]=a[0]}return e[--t]=2,e[--t]=0,new v(e)}function Se(n,t,e){for(var i="",r=0;i.length<t;)i+=e(String.fromCharCode.apply(String,n.concat([(r&4278190080)>>24,(r&16711680)>>16,(r&65280)>>8,r&255]))),r+=1;return i}var Ki=32;function Hi(n,t){var e=Ki,i=Zt;if(n.length+2*e+2>t)throw"Message too long for RSA";var r="",s;for(s=0;s<t-n.length-2*e-2;s+=1)r+="\0";var a=i("")+r+""+n,o=new Array(e);new Vt().nextBytes(o);var c=Se(o,a.length,i),h=[];for(s=0;s<a.length;s+=1)h[s]=a.charCodeAt(s)^c.charCodeAt(s);var u=Se(h,o.length,i),f=[0];for(s=0;s<o.length;s+=1)f[s+1]=o[s]^u.charCodeAt(s);return new v(f.concat(h))}var Wi=(function(){function n(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return n.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},n.prototype.doPrivate=function(t){if(this.p==null||this.q==null)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},n.prototype.setPublic=function(t,e){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=C(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},n.prototype.encrypt=function(t,e){typeof e>"u"&&(e=qi);var i=this.n.bitLength()+7>>3,r=e(t,i);if(r==null)return null;var s=this.doPublic(r);if(s==null)return null;for(var a=s.toString(16),o=a.length,c=0;c<i*2-o;c++)a="0"+a;return a},n.prototype.setPrivate=function(t,e,i){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=C(t,16),this.e=parseInt(e,16),this.d=C(i,16)):console.error("Invalid RSA private key")},n.prototype.setPrivateEx=function(t,e,i,r,s,a,o,c){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=C(t,16),this.e=parseInt(e,16),this.d=C(i,16),this.p=C(r,16),this.q=C(s,16),this.dmp1=C(a,16),this.dmq1=C(o,16),this.coeff=C(c,16)):console.error("Invalid RSA private key")},n.prototype.generate=function(t,e){var i=new Vt,r=t>>1;this.e=parseInt(e,16);for(var s=new v(e,16);;){for(;this.p=new v(t-r,1,i),!(this.p.subtract(v.ONE).gcd(s).compareTo(v.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new v(r,1,i),!(this.q.subtract(v.ONE).gcd(s).compareTo(v.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var o=this.p.subtract(v.ONE),c=this.q.subtract(v.ONE),h=o.multiply(c);if(h.gcd(s).compareTo(v.ONE)==0){this.n=this.p.multiply(this.q),this.d=s.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(c),this.coeff=this.q.modInverse(this.p);break}}},n.prototype.decrypt=function(t){var e=C(t,16),i=this.doPrivate(e);return i==null?null:Xi(i,this.n.bitLength()+7>>3)},n.prototype.generateAsync=function(t,e,i){var r=new Vt,s=t>>1;this.e=parseInt(e,16);var a=new v(e,16),o=this,c=function(){var h=function(){if(o.p.compareTo(o.q)<=0){var _=o.p;o.p=o.q,o.q=_}var y=o.p.subtract(v.ONE),p=o.q.subtract(v.ONE),m=y.multiply(p);m.gcd(a).compareTo(v.ONE)==0?(o.n=o.p.multiply(o.q),o.d=a.modInverse(m),o.dmp1=o.d.mod(y),o.dmq1=o.d.mod(p),o.coeff=o.q.modInverse(o.p),setTimeout(function(){i()},0)):setTimeout(c,0)},u=function(){o.q=E(),o.q.fromNumberAsync(s,1,r,function(){o.q.subtract(v.ONE).gcda(a,function(_){_.compareTo(v.ONE)==0&&o.q.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)})})},f=function(){o.p=E(),o.p.fromNumberAsync(t-s,1,r,function(){o.p.subtract(v.ONE).gcda(a,function(_){_.compareTo(v.ONE)==0&&o.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(c,0)},n.prototype.sign=function(t,e,i){var r=zi(i),s=r+e(t).toString(),a=this.n.bitLength()/4,o=ji(s,a);if(o==null)return null;var c=this.doPrivate(o);if(c==null)return null;for(var h=c.toString(16),u=h.length,f=0;f<a-u;f++)h="0"+h;return h},n.prototype.verify=function(t,e,i){var r=C(e,16),s=this.doPublic(r);if(s==null)return null;var a=s.toString(16).replace(/^1f+00/,""),o=Gi(a);return o==i(t).toString()},n})();function Xi(n,t){for(var e=n.toByteArray(),i=0;i<e.length&&e[i]==0;)++i;if(e.length-i!=t-1||e[i]!=2)return null;for(++i;e[i]!=0;)if(++i>=e.length)return null;for(var r="";++i<e.length;){var s=e[i]&255;s<128?r+=String.fromCharCode(s):s>191&&s<224?(r+=String.fromCharCode((s&31)<<6|e[i+1]&63),++i):(r+=String.fromCharCode((s&15)<<12|(e[i+1]&63)<<6|e[i+2]&63),i+=2)}return r}var It={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};function zi(n){return It[n]||""}function Gi(n){for(var t in It)if(It.hasOwnProperty(t)){var e=It[t],i=e.length;if(n.substring(0,i)==e)return n.substring(i)}return n}function R(n,t,e){if(!t||!n)throw new Error("extend failed, please check that all dependencies are included.");var i=function(){};i.prototype=t.prototype,n.prototype=new i,n.prototype.constructor=n,n.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}var d={};(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});d.asn1.ASN1Util=new function(){this.integerToByteHex=function(n){var t=n.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(n){var t=n.toString(16);if(t.substring(0,1)!="-")t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var e=t.substring(1),i=e.length;i%2==1?i+=1:t.match(/^[0-7]/)||(i+=2);for(var r="",s=0;s<i;s++)r+="f";var a=new v(r,16),o=a.xor(n).add(v.ONE);t=o.toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(n,t){return hextopem(n,t)},this.newObject=function(n){var t=d,e=t.asn1,i=e.DERBoolean,r=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,c=e.DERObjectIdentifier,h=e.DEREnumerated,u=e.DERUTF8String,f=e.DERNumericString,_=e.DERPrintableString,y=e.DERTeletexString,p=e.DERIA5String,m=e.DERUTCTime,g=e.DERGeneralizedTime,w=e.DERSequence,A=e.DERSet,T=e.DERTaggedObject,O=e.ASN1Util.newObject,V=Object.keys(n);if(V.length!=1)throw"key of param shall be only one.";var P=V[0];if(":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+P+":")==-1)throw"undefined key: "+P;if(P=="bool")return new i(n[P]);if(P=="int")return new r(n[P]);if(P=="bitstr")return new s(n[P]);if(P=="octstr")return new a(n[P]);if(P=="null")return new o(n[P]);if(P=="oid")return new c(n[P]);if(P=="enum")return new h(n[P]);if(P=="utf8str")return new u(n[P]);if(P=="numstr")return new f(n[P]);if(P=="prnstr")return new _(n[P]);if(P=="telstr")return new y(n[P]);if(P=="ia5str")return new p(n[P]);if(P=="utctime")return new m(n[P]);if(P=="gentime")return new g(n[P]);if(P=="seq"){for(var D=n[P],z=[],k=0;k<D.length;k++){var st=O(D[k]);z.push(st)}return new w({array:z})}if(P=="set"){for(var D=n[P],z=[],k=0;k<D.length;k++){var st=O(D[k]);z.push(st)}return new A({array:z})}if(P=="tag"){var U=n[P];if(Object.prototype.toString.call(U)==="[object Array]"&&U.length==3){var at=O(U[2]);return new T({tag:U[0],explicit:U[1],obj:at})}else{var W={};if(U.explicit!==void 0&&(W.explicit=U.explicit),U.tag!==void 0&&(W.tag=U.tag),U.obj===void 0)throw"obj shall be specified for 'tag'.";return W.obj=O(U.obj),new T(W)}}},this.jsonToASN1HEX=function(n){var t=this.newObject(n);return t.getEncodedHex()}};d.asn1.ASN1Util.oidHexToInt=function(n){for(var r="",t=parseInt(n.substring(0,2),16),e=Math.floor(t/40),i=t%40,r=e+"."+i,s="",a=2;a<n.length;a+=2){var o=parseInt(n.substring(a,a+2),16),c=("00000000"+o.toString(2)).slice(-8);if(s=s+c.substring(1,8),c.substring(0,1)=="0"){var h=new v(s,2);r=r+"."+h.toString(10),s=""}}return r};d.asn1.ASN1Util.oidIntToHex=function(n){var t=function(o){var c=o.toString(16);return c.length==1&&(c="0"+c),c},e=function(o){var c="",h=new v(o,10),u=h.toString(2),f=7-u.length%7;f==7&&(f=0);for(var _="",y=0;y<f;y++)_+="0";u=_+u;for(var y=0;y<u.length-1;y+=7){var p=u.substring(y,y+7);y!=u.length-7&&(p="1"+p),c+=t(parseInt(p,2))}return c};if(!n.match(/^[0-9.]+$/))throw"malformed oid string: "+n;var i="",r=n.split("."),s=parseInt(r[0])*40+parseInt(r[1]);i+=t(s),r.splice(0,2);for(var a=0;a<r.length;a++)i+=e(r[a]);return i};d.asn1.ASN1Object=function(){var n="";this.getLengthHexFromValue=function(){if(typeof this.hV>"u"||this.hV==null)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+n.length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var i=e.length/2;if(i>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);var r=128+i;return r.toString(16)+e},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}};d.asn1.DERAbstractString=function(n){d.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},typeof n<"u"&&(typeof n=="string"?this.setString(n):typeof n.str<"u"?this.setString(n.str):typeof n.hex<"u"&&this.setStringHex(n.hex))};R(d.asn1.DERAbstractString,d.asn1.ASN1Object);d.asn1.DERAbstractTime=function(n){d.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){utc=t.getTime()+t.getTimezoneOffset()*6e4;var e=new Date(utc);return e},this.formatDate=function(t,e,i){var r=this.zeroPadding,s=this.localDateToUTC(t),a=String(s.getFullYear());e=="utc"&&(a=a.substring(2,4));var o=r(String(s.getMonth()+1),2),c=r(String(s.getDate()),2),h=r(String(s.getHours()),2),u=r(String(s.getMinutes()),2),f=r(String(s.getSeconds()),2),_=a+o+c+h+u+f;if(i===!0){var y=s.getMilliseconds();if(y!=0){var p=r(String(y),3);p=p.replace(/[0]+$/,""),_=_+"."+p}}return _+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,s,a){var o=new Date(Date.UTC(t,e-1,i,r,s,a,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}};R(d.asn1.DERAbstractTime,d.asn1.ASN1Object);d.asn1.DERAbstractStructured=function(n){d.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,typeof n<"u"&&typeof n.array<"u"&&(this.asn1Array=n.array)};R(d.asn1.DERAbstractStructured,d.asn1.ASN1Object);d.asn1.DERBoolean=function(){d.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"};R(d.asn1.DERBoolean,d.asn1.ASN1Object);d.asn1.DERInteger=function(n){d.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=d.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},typeof n<"u"&&(typeof n.bigint<"u"?this.setByBigInteger(n.bigint):typeof n.int<"u"?this.setByInteger(n.int):typeof n=="number"?this.setByInteger(n):typeof n.hex<"u"&&this.setValueHex(n.hex))};R(d.asn1.DERInteger,d.asn1.ASN1Object);d.asn1.DERBitString=function(n){if(n!==void 0&&typeof n.obj<"u"){var t=d.asn1.ASN1Util.newObject(n.obj);n.hex="00"+t.getEncodedHex()}d.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,i){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var r="0"+e;this.hTLV=null,this.isModified=!0,this.hV=r+i},this.setByBinaryString=function(e){e=e.replace(/0+$/,"");var i=8-e.length%8;i==8&&(i=0);for(var r=0;r<=i;r++)e+="0";for(var s="",r=0;r<e.length-1;r+=8){var a=e.substring(r,r+8),o=parseInt(a,2).toString(16);o.length==1&&(o="0"+o),s+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+i+s},this.setByBooleanArray=function(e){for(var i="",r=0;r<e.length;r++)e[r]==!0?i+="1":i+="0";this.setByBinaryString(i)},this.newFalseArray=function(e){for(var i=new Array(e),r=0;r<e;r++)i[r]=!1;return i},this.getFreshValueHex=function(){return this.hV},typeof n<"u"&&(typeof n=="string"&&n.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(n):typeof n.hex<"u"?this.setHexValueIncludingUnusedBits(n.hex):typeof n.bin<"u"?this.setByBinaryString(n.bin):typeof n.array<"u"&&this.setByBooleanArray(n.array))};R(d.asn1.DERBitString,d.asn1.ASN1Object);d.asn1.DEROctetString=function(n){if(n!==void 0&&typeof n.obj<"u"){var t=d.asn1.ASN1Util.newObject(n.obj);n.hex=t.getEncodedHex()}d.asn1.DEROctetString.superclass.constructor.call(this,n),this.hT="04"};R(d.asn1.DEROctetString,d.asn1.DERAbstractString);d.asn1.DERNull=function(){d.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"};R(d.asn1.DERNull,d.asn1.ASN1Object);d.asn1.DERObjectIdentifier=function(n){var t=function(i){var r=i.toString(16);return r.length==1&&(r="0"+r),r},e=function(i){var r="",s=new v(i,10),a=s.toString(2),o=7-a.length%7;o==7&&(o=0);for(var c="",h=0;h<o;h++)c+="0";a=c+a;for(var h=0;h<a.length-1;h+=7){var u=a.substring(h,h+7);h!=a.length-7&&(u="1"+u),r+=t(parseInt(u,2))}return r};d.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(i){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueOidString=function(i){if(!i.match(/^[0-9.]+$/))throw"malformed oid string: "+i;var r="",s=i.split("."),a=parseInt(s[0])*40+parseInt(s[1]);r+=t(a),s.splice(0,2);for(var o=0;o<s.length;o++)r+=e(s[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(i){var r=d.asn1.x509.OID.name2oid(i);if(r!=="")this.setValueOidString(r);else throw"DERObjectIdentifier oidName undefined: "+i},this.getFreshValueHex=function(){return this.hV},n!==void 0&&(typeof n=="string"?n.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(n):this.setValueName(n):n.oid!==void 0?this.setValueOidString(n.oid):n.hex!==void 0?this.setValueHex(n.hex):n.name!==void 0&&this.setValueName(n.name))};R(d.asn1.DERObjectIdentifier,d.asn1.ASN1Object);d.asn1.DEREnumerated=function(n){d.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=d.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},typeof n<"u"&&(typeof n.int<"u"?this.setByInteger(n.int):typeof n=="number"?this.setByInteger(n):typeof n.hex<"u"&&this.setValueHex(n.hex))};R(d.asn1.DEREnumerated,d.asn1.ASN1Object);d.asn1.DERUTF8String=function(n){d.asn1.DERUTF8String.superclass.constructor.call(this,n),this.hT="0c"};R(d.asn1.DERUTF8String,d.asn1.DERAbstractString);d.asn1.DERNumericString=function(n){d.asn1.DERNumericString.superclass.constructor.call(this,n),this.hT="12"};R(d.asn1.DERNumericString,d.asn1.DERAbstractString);d.asn1.DERPrintableString=function(n){d.asn1.DERPrintableString.superclass.constructor.call(this,n),this.hT="13"};R(d.asn1.DERPrintableString,d.asn1.DERAbstractString);d.asn1.DERTeletexString=function(n){d.asn1.DERTeletexString.superclass.constructor.call(this,n),this.hT="14"};R(d.asn1.DERTeletexString,d.asn1.DERAbstractString);d.asn1.DERIA5String=function(n){d.asn1.DERIA5String.superclass.constructor.call(this,n),this.hT="16"};R(d.asn1.DERIA5String,d.asn1.DERAbstractString);d.asn1.DERUTCTime=function(n){d.asn1.DERUTCTime.superclass.constructor.call(this,n),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return typeof this.date>"u"&&typeof this.s>"u"&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},n!==void 0&&(n.str!==void 0?this.setString(n.str):typeof n=="string"&&n.match(/^[0-9]{12}Z$/)?this.setString(n):n.hex!==void 0?this.setStringHex(n.hex):n.date!==void 0&&this.setByDate(n.date))};R(d.asn1.DERUTCTime,d.asn1.DERAbstractTime);d.asn1.DERGeneralizedTime=function(n){d.asn1.DERGeneralizedTime.superclass.constructor.call(this,n),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},n!==void 0&&(n.str!==void 0?this.setString(n.str):typeof n=="string"&&n.match(/^[0-9]{14}Z$/)?this.setString(n):n.hex!==void 0?this.setStringHex(n.hex):n.date!==void 0&&this.setByDate(n.date),n.millis===!0&&(this.withMillis=!0))};R(d.asn1.DERGeneralizedTime,d.asn1.DERAbstractTime);d.asn1.DERSequence=function(n){d.asn1.DERSequence.superclass.constructor.call(this,n),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t+=i.getEncodedHex()}return this.hV=t,this.hV}};R(d.asn1.DERSequence,d.asn1.DERAbstractStructured);d.asn1.DERSet=function(n){d.asn1.DERSet.superclass.constructor.call(this,n),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return this.sortFlag==!0&&t.sort(),this.hV=t.join(""),this.hV},typeof n<"u"&&typeof n.sortflag<"u"&&n.sortflag==!1&&(this.sortFlag=!1)};R(d.asn1.DERSet,d.asn1.DERAbstractStructured);d.asn1.DERTaggedObject=function(n){d.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},typeof n<"u"&&(typeof n.tag<"u"&&(this.hT=n.tag),typeof n.explicit<"u"&&(this.isExplicit=n.explicit),typeof n.obj<"u"&&(this.asn1Object=n.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))};R(d.asn1.DERTaggedObject,d.asn1.ASN1Object);var $i=(function(){var n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(i,r){i.__proto__=r}||function(i,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(i[s]=r[s])},n(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");n(t,e);function i(){this.constructor=t}t.prototype=e===null?Object.create(e):(i.prototype=e.prototype,new i)}})(),Te=(function(n){$i(t,n);function t(e){var i=n.call(this)||this;return e&&(typeof e=="string"?i.parseKey(e):(t.hasPrivateKeyProperty(e)||t.hasPublicKeyProperty(e))&&i.parsePropertiesFrom(e)),i}return t.prototype.parseKey=function(e){try{var i=0,r=0,s=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,a=s.test(e)?Pi.decode(e):Qt.unarmor(e),o=wi.decode(a);if(o.sub.length===3&&(o=o.sub[2].sub[0]),o.sub.length===9){i=o.sub[1].getHexStringValue(),this.n=C(i,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var c=o.sub[3].getHexStringValue();this.d=C(c,16);var h=o.sub[4].getHexStringValue();this.p=C(h,16);var u=o.sub[5].getHexStringValue();this.q=C(u,16);var f=o.sub[6].getHexStringValue();this.dmp1=C(f,16);var _=o.sub[7].getHexStringValue();this.dmq1=C(_,16);var y=o.sub[8].getHexStringValue();this.coeff=C(y,16)}else if(o.sub.length===2)if(o.sub[0].sub){var p=o.sub[1],m=p.sub[0];i=m.sub[0].getHexStringValue(),this.n=C(i,16),r=m.sub[1].getHexStringValue(),this.e=parseInt(r,16)}else i=o.sub[0].getHexStringValue(),this.n=C(i,16),r=o.sub[1].getHexStringValue(),this.e=parseInt(r,16);else return!1;return!0}catch{return!1}},t.prototype.getPrivateBaseKey=function(){var e={array:[new d.asn1.DERInteger({int:0}),new d.asn1.DERInteger({bigint:this.n}),new d.asn1.DERInteger({int:this.e}),new d.asn1.DERInteger({bigint:this.d}),new d.asn1.DERInteger({bigint:this.p}),new d.asn1.DERInteger({bigint:this.q}),new d.asn1.DERInteger({bigint:this.dmp1}),new d.asn1.DERInteger({bigint:this.dmq1}),new d.asn1.DERInteger({bigint:this.coeff})]},i=new d.asn1.DERSequence(e);return i.getEncodedHex()},t.prototype.getPrivateBaseKeyB64=function(){return mt(this.getPrivateBaseKey())},t.prototype.getPublicBaseKey=function(){var e=new d.asn1.DERSequence({array:[new d.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new d.asn1.DERNull]}),i=new d.asn1.DERSequence({array:[new d.asn1.DERInteger({bigint:this.n}),new d.asn1.DERInteger({int:this.e})]}),r=new d.asn1.DERBitString({hex:"00"+i.getEncodedHex()}),s=new d.asn1.DERSequence({array:[e,r]});return s.getEncodedHex()},t.prototype.getPublicBaseKeyB64=function(){return mt(this.getPublicBaseKey())},t.wordwrap=function(e,i){if(i=i||64,!e)return e;var r="(.{1,"+i+`})( +|$
9
- ?)|(.{1,`+i+"})";return e.match(RegExp(r,"g")).join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const x=require("./kernel-BEA0hNWZ.cjs"),de=require("./devices-Be3Fj7uv.cjs");var yn="0123456789abcdefghijklmnopqrstuvwxyz";function $(i){return yn.charAt(i)}function bn(i,t){return i&t}function Tt(i,t){return i|t}function _e(i,t){return i^t}function ge(i,t){return i&~t}function Pn(i){if(i==0)return-1;var t=0;return(i&65535)==0&&(i>>=16,t+=16),(i&255)==0&&(i>>=8,t+=8),(i&15)==0&&(i>>=4,t+=4),(i&3)==0&&(i>>=2,t+=2),(i&1)==0&&++t,t}function vn(i){for(var t=0;i!=0;)i&=i-1,++t;return t}var ht="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",He="=";function yt(i){var t,e,n="";for(t=0;t+3<=i.length;t+=3)e=parseInt(i.substring(t,t+3),16),n+=ht.charAt(e>>6)+ht.charAt(e&63);for(t+1==i.length?(e=parseInt(i.substring(t,t+1),16),n+=ht.charAt(e<<2)):t+2==i.length&&(e=parseInt(i.substring(t,t+2),16),n+=ht.charAt(e>>2)+ht.charAt((e&3)<<4));(n.length&3)>0;)n+=He;return n}function me(i){var t="",e,n=0,r=0;for(e=0;e<i.length&&i.charAt(e)!=He;++e){var s=ht.indexOf(i.charAt(e));s<0||(n==0?(t+=$(s>>2),r=s&3,n=1):n==1?(t+=$(r<<2|s>>4),r=s&15,n=2):n==2?(t+=$(r),t+=$(s>>2),r=s&3,n=3):(t+=$(r<<2|s>>4),t+=$(s&15),n=0))}return n==1&&(t+=$(r<<2)),t}var ct,En={decode:function(i){var t;if(ct===void 0){var e="0123456789ABCDEF",n=` \f
2
+ \r  \u2028\u2029`;for(ct={},t=0;t<16;++t)ct[e.charAt(t)]=t;for(e=e.toLowerCase(),t=10;t<16;++t)ct[e.charAt(t)]=t;for(t=0;t<n.length;++t)ct[n.charAt(t)]=-1}var r=[],s=0,a=0;for(t=0;t<i.length;++t){var o=i.charAt(t);if(o=="=")break;if(o=ct[o],o!=-1){if(o===void 0)throw new Error("Illegal character at offset "+t);s|=o,++a>=2?(r[r.length]=s,s=0,a=0):s<<=4}}if(a)throw new Error("Hex encoding incomplete: 4 bits missing");return r}},et,Yt={decode:function(i){var t;if(et===void 0){var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=`= \f
3
+ \r  \u2028\u2029`;for(et=Object.create(null),t=0;t<64;++t)et[e.charAt(t)]=t;for(et["-"]=62,et._=63,t=0;t<n.length;++t)et[n.charAt(t)]=-1}var r=[],s=0,a=0;for(t=0;t<i.length;++t){var o=i.charAt(t);if(o=="=")break;if(o=et[o],o!=-1){if(o===void 0)throw new Error("Illegal character at offset "+t);s|=o,++a>=4?(r[r.length]=s>>16,r[r.length]=s>>8&255,r[r.length]=s&255,s=0,a=0):s<<=6}}switch(a){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=s>>10;break;case 3:r[r.length]=s>>16,r[r.length]=s>>8&255;break}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(i){var t=Yt.re.exec(i);if(t)if(t[1])i=t[1];else if(t[2])i=t[2];else throw new Error("RegExp out of sync");return Yt.decode(i)}},ut=1e13,mt=(function(){function i(t){this.buf=[+t||0]}return i.prototype.mulAdd=function(t,e){var n=this.buf,r=n.length,s,a;for(s=0;s<r;++s)a=n[s]*t+e,a<ut?e=0:(e=0|a/ut,a-=e*ut),n[s]=a;e>0&&(n[s]=e)},i.prototype.sub=function(t){var e=this.buf,n=e.length,r,s;for(r=0;r<n;++r)s=e[r]-t,s<0?(s+=ut,t=1):t=0,e[r]=s;for(;e[e.length-1]===0;)e.pop()},i.prototype.toString=function(t){if((t||10)!=10)throw new Error("only base 10 is supported");for(var e=this.buf,n=e[e.length-1].toString(),r=e.length-2;r>=0;--r)n+=(ut+e[r]).toString().substring(1);return n},i.prototype.valueOf=function(){for(var t=this.buf,e=0,n=t.length-1;n>=0;--n)e=e*ut+t[n];return e},i.prototype.simplify=function(){var t=this.buf;return t.length==1?t[0]:this},i})(),We="…",wn=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,Sn=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function ft(i,t){return i.length>t&&(i=i.substring(0,t)+We),i}var Xt=(function(){function i(t,e){this.hexDigits="0123456789ABCDEF",t instanceof i?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}return i.prototype.get=function(t){if(t===void 0&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset ".concat(t," on a stream of length ").concat(this.enc.length));return typeof this.enc=="string"?this.enc.charCodeAt(t):this.enc[t]},i.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(t&15)},i.prototype.hexDump=function(t,e,n){for(var r="",s=t;s<e;++s)if(r+=this.hexByte(this.get(s)),n!==!0)switch(s&15){case 7:r+=" ";break;case 15:r+=`
4
+ `;break;default:r+=" "}return r},i.prototype.isASCII=function(t,e){for(var n=t;n<e;++n){var r=this.get(n);if(r<32||r>176)return!1}return!0},i.prototype.parseStringISO=function(t,e){for(var n="",r=t;r<e;++r)n+=String.fromCharCode(this.get(r));return n},i.prototype.parseStringUTF=function(t,e){for(var n="",r=t;r<e;){var s=this.get(r++);s<128?n+=String.fromCharCode(s):s>191&&s<224?n+=String.fromCharCode((s&31)<<6|this.get(r++)&63):n+=String.fromCharCode((s&15)<<12|(this.get(r++)&63)<<6|this.get(r++)&63)}return n},i.prototype.parseStringBMP=function(t,e){for(var n="",r,s,a=t;a<e;)r=this.get(a++),s=this.get(a++),n+=String.fromCharCode(r<<8|s);return n},i.prototype.parseTime=function(t,e,n){var r=this.parseStringISO(t,e),s=(n?wn:Sn).exec(r);return s?(n&&(s[1]=+s[1],s[1]+=+s[1]<70?2e3:1900),r=s[1]+"-"+s[2]+"-"+s[3]+" "+s[4],s[5]&&(r+=":"+s[5],s[6]&&(r+=":"+s[6],s[7]&&(r+="."+s[7]))),s[8]&&(r+=" UTC",s[8]!="Z"&&(r+=s[8],s[9]&&(r+=":"+s[9]))),r):"Unrecognized time: "+r},i.prototype.parseInteger=function(t,e){for(var n=this.get(t),r=n>127,s=r?255:0,a,o="";n==s&&++t<e;)n=this.get(t);if(a=e-t,a===0)return r?-1:0;if(a>4){for(o=n,a<<=3;((+o^s)&128)==0;)o=+o<<1,--a;o="("+a+` bit)
5
+ `}r&&(n=n-256);for(var c=new mt(n),l=t+1;l<e;++l)c.mulAdd(256,this.get(l));return o+c.toString()},i.prototype.parseBitString=function(t,e,n){for(var r=this.get(t),s=(e-t-1<<3)-r,a="("+s+` bit)
6
+ `,o="",c=t+1;c<e;++c){for(var l=this.get(c),u=c==e-1?r:0,f=7;f>=u;--f)o+=l>>f&1?"1":"0";if(o.length>n)return a+ft(o,n)}return a+o},i.prototype.parseOctetString=function(t,e,n){if(this.isASCII(t,e))return ft(this.parseStringISO(t,e),n);var r=e-t,s="("+r+` byte)
7
+ `;n/=2,r>n&&(e=t+n);for(var a=t;a<e;++a)s+=this.hexByte(this.get(a));return r>n&&(s+=We),s},i.prototype.parseOID=function(t,e,n){for(var r="",s=new mt,a=0,o=t;o<e;++o){var c=this.get(o);if(s.mulAdd(128,c&127),a+=7,!(c&128)){if(r==="")if(s=s.simplify(),s instanceof mt)s.sub(80),r="2."+s.toString();else{var l=s<80?s<40?0:1:2;r=l+"."+(s-l*40)}else r+="."+s.toString();if(r.length>n)return ft(r,n);s=new mt,a=0}}return a>0&&(r+=".incomplete"),r},i})(),Tn=(function(){function i(t,e,n,r,s){if(!(r instanceof ye))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=n,this.tag=r,this.sub=s}return i.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},i.prototype.content=function(t){if(this.tag===void 0)return null;t===void 0&&(t=1/0);var e=this.posContent(),n=Math.abs(this.length);if(!this.tag.isUniversal())return this.sub!==null?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);switch(this.tag.tagNumber){case 1:return this.stream.get(e)===0?"false":"true";case 2:return this.stream.parseInteger(e,e+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+n,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);case 6:return this.stream.parseOID(e,e+n,t);case 16:case 17:return this.sub!==null?"("+this.sub.length+" elem)":"(no elem)";case 12:return ft(this.stream.parseStringUTF(e,e+n),t);case 18:case 19:case 20:case 21:case 22:case 26:return ft(this.stream.parseStringISO(e,e+n),t);case 30:return ft(this.stream.parseStringBMP(e,e+n),t);case 23:case 24:return this.stream.parseTime(e,e+n,this.tag.tagNumber==23)}return null},i.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(this.sub===null?"null":this.sub.length)+"]"},i.prototype.toPrettyString=function(t){t===void 0&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(this.length>=0&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":this.tag.isUniversal()&&(this.tag.tagNumber==3||this.tag.tagNumber==4)&&this.sub!==null&&(e+=" (encapsulates)"),e+=`
8
+ `,this.sub!==null){t+=" ";for(var n=0,r=this.sub.length;n<r;++n)e+=this.sub[n].toPrettyString(t)}return e},i.prototype.posStart=function(){return this.stream.pos},i.prototype.posContent=function(){return this.stream.pos+this.header},i.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},i.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},i.decodeLength=function(t){var e=t.get(),n=e&127;if(n==e)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(n===0)return null;e=0;for(var r=0;r<n;++r)e=e*256+t.get();return e},i.prototype.getHexStringValue=function(){var t=this.toHexString(),e=this.header*2,n=this.length*2;return t.substring(e,e+n)},i.decode=function(t){var e;t instanceof Xt?e=t:e=new Xt(t,0);var n=new Xt(e),r=new ye(e),s=i.decodeLength(e),a=e.pos,o=a-n.pos,c=null,l=function(){var f=[];if(s!==null){for(var _=a+s;e.pos<_;)f[f.length]=i.decode(e);if(e.pos!=_)throw new Error("Content size is not correct for container starting at offset "+a)}else try{for(;;){var y=i.decode(e);if(y.tag.isEOC())break;f[f.length]=y}s=a-e.pos}catch(m){throw new Error("Exception while decoding undefined length content: "+m)}return f};if(r.tagConstructed)c=l();else if(r.isUniversal()&&(r.tagNumber==3||r.tagNumber==4))try{if(r.tagNumber==3&&e.get()!=0)throw new Error("BIT STRINGs with unused bits cannot encapsulate.");c=l();for(var u=0;u<c.length;++u)if(c[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch{c=null}if(c===null){if(s===null)throw new Error("We can't skip over an invalid tag with undefined length at offset "+a);e.pos=a+Math.abs(s)}return new i(n,o,s,r,c)},i})(),ye=(function(){function i(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=(e&32)!==0,this.tagNumber=e&31,this.tagNumber==31){var n=new mt;do e=t.get(),n.mulAdd(128,e&127);while(e&128);this.tagNumber=n.simplify()}}return i.prototype.isUniversal=function(){return this.tagClass===0},i.prototype.isEOC=function(){return this.tagClass===0&&this.tagNumber===0},i})(),Y,An=0xdeadbeefcafe,be=(An&16777215)==15715070,V=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],Rn=(1<<26)/V[V.length-1],v=(function(){function i(t,e,n){t!=null&&(typeof t=="number"?this.fromNumber(t,e,n):e==null&&typeof t!="string"?this.fromString(t,256):this.fromString(t,e))}return i.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(t==16)e=4;else if(t==8)e=3;else if(t==2)e=1;else if(t==32)e=5;else if(t==4)e=2;else return this.toRadix(t);var n=(1<<e)-1,r,s=!1,a="",o=this.t,c=this.DB-o*this.DB%e;if(o-- >0)for(c<this.DB&&(r=this[o]>>c)>0&&(s=!0,a=$(r));o>=0;)c<e?(r=(this[o]&(1<<c)-1)<<e-c,r|=this[--o]>>(c+=this.DB-e)):(r=this[o]>>(c-=e)&n,c<=0&&(c+=this.DB,--o)),r>0&&(s=!0),s&&(a+=$(r));return s?a:"0"},i.prototype.negate=function(){var t=E();return i.ZERO.subTo(this,t),t},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(t){var e=this.s-t.s;if(e!=0)return e;var n=this.t;if(e=n-t.t,e!=0)return this.s<0?-e:e;for(;--n>=0;)if((e=this[n]-t[n])!=0)return e;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+At(this[this.t-1]^this.s&this.DM)},i.prototype.mod=function(t){var e=E();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(i.ZERO)>0&&t.subTo(e,e),e},i.prototype.modPowInt=function(t,e){var n;return t<256||e.isEven()?n=new Pe(e):n=new ve(e),this.exp(t,n)},i.prototype.clone=function(){var t=E();return this.copyTo(t),t},i.prototype.intValue=function(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},i.prototype.byteValue=function(){return this.t==0?this.s:this[0]<<24>>24},i.prototype.shortValue=function(){return this.t==0?this.s:this[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1},i.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var n=this.DB-t*this.DB%8,r,s=0;if(t-- >0)for(n<this.DB&&(r=this[t]>>n)!=(this.s&this.DM)>>n&&(e[s++]=r|this.s<<this.DB-n);t>=0;)n<8?(r=(this[t]&(1<<n)-1)<<8-n,r|=this[--t]>>(n+=this.DB-8)):(r=this[t]>>(n-=8)&255,n<=0&&(n+=this.DB,--t)),(r&128)!=0&&(r|=-256),s==0&&(this.s&128)!=(r&128)&&++s,(s>0||r!=this.s)&&(e[s++]=r);return e},i.prototype.equals=function(t){return this.compareTo(t)==0},i.prototype.min=function(t){return this.compareTo(t)<0?this:t},i.prototype.max=function(t){return this.compareTo(t)>0?this:t},i.prototype.and=function(t){var e=E();return this.bitwiseTo(t,bn,e),e},i.prototype.or=function(t){var e=E();return this.bitwiseTo(t,Tt,e),e},i.prototype.xor=function(t){var e=E();return this.bitwiseTo(t,_e,e),e},i.prototype.andNot=function(t){var e=E();return this.bitwiseTo(t,ge,e),e},i.prototype.not=function(){for(var t=E(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},i.prototype.shiftLeft=function(t){var e=E();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},i.prototype.shiftRight=function(t){var e=E();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},i.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(this[t]!=0)return t*this.DB+Pn(this[t]);return this.s<0?this.t*this.DB:-1},i.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=vn(this[n]^e);return t},i.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?this.s!=0:(this[e]&1<<t%this.DB)!=0},i.prototype.setBit=function(t){return this.changeBit(t,Tt)},i.prototype.clearBit=function(t){return this.changeBit(t,ge)},i.prototype.flipBit=function(t){return this.changeBit(t,_e)},i.prototype.add=function(t){var e=E();return this.addTo(t,e),e},i.prototype.subtract=function(t){var e=E();return this.subTo(t,e),e},i.prototype.multiply=function(t){var e=E();return this.multiplyTo(t,e),e},i.prototype.divide=function(t){var e=E();return this.divRemTo(t,e,null),e},i.prototype.remainder=function(t){var e=E();return this.divRemTo(t,null,e),e},i.prototype.divideAndRemainder=function(t){var e=E(),n=E();return this.divRemTo(t,e,n),[e,n]},i.prototype.modPow=function(t,e){var n=t.bitLength(),r,s=Q(1),a;if(n<=0)return s;n<18?r=1:n<48?r=3:n<144?r=4:n<768?r=5:r=6,n<8?a=new Pe(e):e.isEven()?a=new On(e):a=new ve(e);var o=[],c=3,l=r-1,u=(1<<r)-1;if(o[1]=a.convert(this),r>1){var f=E();for(a.sqrTo(o[1],f);c<=u;)o[c]=E(),a.mulTo(f,o[c-2],o[c]),c+=2}var _=t.t-1,y,m=!0,g=E(),d;for(n=At(t[_])-1;_>=0;){for(n>=l?y=t[_]>>n-l&u:(y=(t[_]&(1<<n+1)-1)<<l-n,_>0&&(y|=t[_-1]>>this.DB+n-l)),c=r;(y&1)==0;)y>>=1,--c;if((n-=c)<0&&(n+=this.DB,--_),m)o[y].copyTo(s),m=!1;else{for(;c>1;)a.sqrTo(s,g),a.sqrTo(g,s),c-=2;c>0?a.sqrTo(s,g):(d=s,s=g,g=d),a.mulTo(g,o[y],s)}for(;_>=0&&(t[_]&1<<n)==0;)a.sqrTo(s,g),d=s,s=g,g=d,--n<0&&(n=this.DB-1,--_)}return a.revert(s)},i.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||t.signum()==0)return i.ZERO;for(var n=t.clone(),r=this.clone(),s=Q(1),a=Q(0),o=Q(0),c=Q(1);n.signum()!=0;){for(;n.isEven();)n.rShiftTo(1,n),e?((!s.isEven()||!a.isEven())&&(s.addTo(this,s),a.subTo(t,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);for(;r.isEven();)r.rShiftTo(1,r),e?((!o.isEven()||!c.isEven())&&(o.addTo(this,o),c.subTo(t,c)),o.rShiftTo(1,o)):c.isEven()||c.subTo(t,c),c.rShiftTo(1,c);n.compareTo(r)>=0?(n.subTo(r,n),e&&s.subTo(o,s),a.subTo(c,a)):(r.subTo(n,r),e&&o.subTo(s,o),c.subTo(a,c))}if(r.compareTo(i.ONE)!=0)return i.ZERO;if(c.compareTo(t)>=0)return c.subtract(t);if(c.signum()<0)c.addTo(t,c);else return c;return c.signum()<0?c.add(t):c},i.prototype.pow=function(t){return this.exp(t,new Cn)},i.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var r=e;e=n,n=r}var s=e.getLowestSetBit(),a=n.getLowestSetBit();if(a<0)return e;for(s<a&&(a=s),a>0&&(e.rShiftTo(a,e),n.rShiftTo(a,n));e.signum()>0;)(s=e.getLowestSetBit())>0&&e.rShiftTo(s,e),(s=n.getLowestSetBit())>0&&n.rShiftTo(s,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return a>0&&n.lShiftTo(a,n),n},i.prototype.isProbablePrime=function(t){var e,n=this.abs();if(n.t==1&&n[0]<=V[V.length-1]){for(e=0;e<V.length;++e)if(n[0]==V[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<V.length;){for(var r=V[e],s=e+1;s<V.length&&r<Rn;)r*=V[s++];for(r=n.modInt(r);e<s;)if(r%V[e++]==0)return!1}return n.millerRabin(t)},i.prototype.copyTo=function(t){for(var e=this.t-1;e>=0;--e)t[e]=this[e];t.t=this.t,t.s=this.s},i.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},i.prototype.fromString=function(t,e){var n;if(e==16)n=4;else if(e==8)n=3;else if(e==256)n=8;else if(e==2)n=1;else if(e==32)n=5;else if(e==4)n=2;else{this.fromRadix(t,e);return}this.t=0,this.s=0;for(var r=t.length,s=!1,a=0;--r>=0;){var o=n==8?+t[r]&255:we(t,r);if(o<0){t.charAt(r)=="-"&&(s=!0);continue}s=!1,a==0?this[this.t++]=o:a+n>this.DB?(this[this.t-1]|=(o&(1<<this.DB-a)-1)<<a,this[this.t++]=o>>this.DB-a):this[this.t-1]|=o<<a,a+=n,a>=this.DB&&(a-=this.DB)}n==8&&(+t[0]&128)!=0&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&i.ZERO.subTo(this,this)},i.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},i.prototype.dlShiftTo=function(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s},i.prototype.drShiftTo=function(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},i.prototype.lShiftTo=function(t,e){for(var n=t%this.DB,r=this.DB-n,s=(1<<r)-1,a=Math.floor(t/this.DB),o=this.s<<n&this.DM,c=this.t-1;c>=0;--c)e[c+a+1]=this[c]>>r|o,o=(this[c]&s)<<n;for(var c=a-1;c>=0;--c)e[c]=0;e[a]=o,e.t=this.t+a+1,e.s=this.s,e.clamp()},i.prototype.rShiftTo=function(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t){e.t=0;return}var r=t%this.DB,s=this.DB-r,a=(1<<r)-1;e[0]=this[n]>>r;for(var o=n+1;o<this.t;++o)e[o-n-1]|=(this[o]&a)<<s,e[o-n]=this[o]>>r;r>0&&(e[this.t-n-1]|=(this.s&a)<<s),e.t=this.t-n,e.clamp()},i.prototype.subTo=function(t,e){for(var n=0,r=0,s=Math.min(t.t,this.t);n<s;)r+=this[n]-t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r-=t[n],e[n++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[n++]=this.DV+r:r>0&&(e[n++]=r),e.t=n,e.clamp()},i.prototype.multiplyTo=function(t,e){var n=this.abs(),r=t.abs(),s=n.t;for(e.t=s+r.t;--s>=0;)e[s]=0;for(s=0;s<r.t;++s)e[s+n.t]=n.am(0,r[s],e,s,0,n.t);e.s=0,e.clamp(),this.s!=t.s&&i.ZERO.subTo(e,e)},i.prototype.squareTo=function(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var r=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,r,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},i.prototype.divRemTo=function(t,e,n){var r=t.abs();if(!(r.t<=0)){var s=this.abs();if(s.t<r.t){e?.fromInt(0),n!=null&&this.copyTo(n);return}n==null&&(n=E());var a=E(),o=this.s,c=t.s,l=this.DB-At(r[r.t-1]);l>0?(r.lShiftTo(l,a),s.lShiftTo(l,n)):(r.copyTo(a),s.copyTo(n));var u=a.t,f=a[u-1];if(f!=0){var _=f*(1<<this.F1)+(u>1?a[u-2]>>this.F2:0),y=this.FV/_,m=(1<<this.F1)/_,g=1<<this.F2,d=n.t,w=d-u,C=e??E();for(a.dlShiftTo(w,C),n.compareTo(C)>=0&&(n[n.t++]=1,n.subTo(C,n)),i.ONE.dlShiftTo(u,C),C.subTo(a,a);a.t<u;)a[a.t++]=0;for(;--w>=0;){var T=n[--d]==f?this.DM:Math.floor(n[d]*y+(n[d-1]+g)*m);if((n[d]+=a.am(0,T,n,w,0,u))<T)for(a.dlShiftTo(w,C),n.subTo(C,n);n[d]<--T;)n.subTo(C,n)}e!=null&&(n.drShiftTo(u,e),o!=c&&i.ZERO.subTo(e,e)),n.t=u,n.clamp(),l>0&&n.rShiftTo(l,n),o<0&&i.ZERO.subTo(n,n)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if((t&1)==0)return 0;var e=t&3;return e=e*(2-(t&15)*e)&15,e=e*(2-(t&255)*e)&255,e=e*(2-((t&65535)*e&65535))&65535,e=e*(2-t*e%this.DV)%this.DV,e>0?this.DV-e:-e},i.prototype.isEven=function(){return(this.t>0?this[0]&1:this.s)==0},i.prototype.exp=function(t,e){if(t>4294967295||t<1)return i.ONE;var n=E(),r=E(),s=e.convert(this),a=At(t)-1;for(s.copyTo(n);--a>=0;)if(e.sqrTo(n,r),(t&1<<a)>0)e.mulTo(r,s,n);else{var o=n;n=r,r=o}return e.revert(n)},i.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},i.prototype.toRadix=function(t){if(t==null&&(t=10),this.signum()==0||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),r=Q(n),s=E(),a=E(),o="";for(this.divRemTo(r,s,a);s.signum()>0;)o=(n+a.intValue()).toString(t).substring(1)+o,s.divRemTo(r,s,a);return a.intValue().toString(t)+o},i.prototype.fromRadix=function(t,e){this.fromInt(0),e==null&&(e=10);for(var n=this.chunkSize(e),r=Math.pow(e,n),s=!1,a=0,o=0,c=0;c<t.length;++c){var l=we(t,c);if(l<0){t.charAt(c)=="-"&&this.signum()==0&&(s=!0);continue}o=e*o+l,++a>=n&&(this.dMultiply(r),this.dAddOffset(o,0),a=0,o=0)}a>0&&(this.dMultiply(Math.pow(e,a)),this.dAddOffset(o,0)),s&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(t,e,n){if(typeof e=="number")if(t<2)this.fromInt(1);else for(this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),Tt,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(i.ONE.shiftLeft(t-1),this);else{var r=[],s=t&7;r.length=(t>>3)+1,e.nextBytes(r),s>0?r[0]&=(1<<s)-1:r[0]=0,this.fromString(r,256)}},i.prototype.bitwiseTo=function(t,e,n){var r,s,a=Math.min(t.t,this.t);for(r=0;r<a;++r)n[r]=e(this[r],t[r]);if(t.t<this.t){for(s=t.s&this.DM,r=a;r<this.t;++r)n[r]=e(this[r],s);n.t=this.t}else{for(s=this.s&this.DM,r=a;r<t.t;++r)n[r]=e(s,t[r]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()},i.prototype.changeBit=function(t,e){var n=i.ONE.shiftLeft(t);return this.bitwiseTo(n,e,n),n},i.prototype.addTo=function(t,e){for(var n=0,r=0,s=Math.min(t.t,this.t);n<s;)r+=this[n]+t[n],e[n++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;n<this.t;)r+=this[n],e[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<t.t;)r+=t[n],e[n++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,r>0?e[n++]=r:r<-1&&(e[n++]=this.DV+r),e.t=n,e.clamp()},i.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(t,e){if(t!=0){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},i.prototype.multiplyLowerTo=function(t,e,n){var r=Math.min(this.t+t.t,e);for(n.s=0,n.t=r;r>0;)n[--r]=0;for(var s=n.t-this.t;r<s;++r)n[r+this.t]=this.am(0,t[r],n,r,0,this.t);for(var s=Math.min(t.t,e);r<s;++r)this.am(0,t[r],n,r,0,e-r);n.clamp()},i.prototype.multiplyUpperTo=function(t,e,n){--e;var r=n.t=this.t+t.t-e;for(n.s=0;--r>=0;)n[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)n[this.t+r-e]=this.am(e-r,t[r],n,0,0,this.t+r-e);n.clamp(),n.drShiftTo(1,n)},i.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(e==0)n=this[0]%t;else for(var r=this.t-1;r>=0;--r)n=(e*n+this[r])%t;return n},i.prototype.millerRabin=function(t){var e=this.subtract(i.ONE),n=e.getLowestSetBit();if(n<=0)return!1;var r=e.shiftRight(n);t=t+1>>1,t>V.length&&(t=V.length);for(var s=E(),a=0;a<t;++a){s.fromInt(V[Math.floor(Math.random()*V.length)]);var o=s.modPow(r,this);if(o.compareTo(i.ONE)!=0&&o.compareTo(e)!=0){for(var c=1;c++<n&&o.compareTo(e)!=0;)if(o=o.modPowInt(2,this),o.compareTo(i.ONE)==0)return!1;if(o.compareTo(e)!=0)return!1}}return!0},i.prototype.square=function(){var t=E();return this.squareTo(t),t},i.prototype.gcda=function(t,e){var n=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(n.compareTo(r)<0){var s=n;n=r,r=s}var a=n.getLowestSetBit(),o=r.getLowestSetBit();if(o<0){e(n);return}a<o&&(o=a),o>0&&(n.rShiftTo(o,n),r.rShiftTo(o,r));var c=function(){(a=n.getLowestSetBit())>0&&n.rShiftTo(a,n),(a=r.getLowestSetBit())>0&&r.rShiftTo(a,r),n.compareTo(r)>=0?(n.subTo(r,n),n.rShiftTo(1,n)):(r.subTo(n,r),r.rShiftTo(1,r)),n.signum()>0?setTimeout(c,0):(o>0&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(c,10)},i.prototype.fromNumberAsync=function(t,e,n,r){if(typeof e=="number")if(t<2)this.fromInt(1);else{this.fromNumber(t,n),this.testBit(t-1)||this.bitwiseTo(i.ONE.shiftLeft(t-1),Tt,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(i.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(a,0)};setTimeout(a,0)}else{var o=[],c=t&7;o.length=(t>>3)+1,e.nextBytes(o),c>0?o[0]&=(1<<c)-1:o[0]=0,this.fromString(o,256)}},i})(),Cn=(function(){function i(){}return i.prototype.convert=function(t){return t},i.prototype.revert=function(t){return t},i.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},i.prototype.sqrTo=function(t,e){t.squareTo(e)},i})(),Pe=(function(){function i(t){this.m=t}return i.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},i.prototype.revert=function(t){return t},i.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},i.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},i.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i})(),ve=(function(){function i(t){this.m=t,this.mp=t.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return i.prototype.convert=function(t){var e=E();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(v.ZERO)>0&&this.m.subTo(e,e),e},i.prototype.revert=function(t){var e=E();return t.copyTo(e),this.reduce(e),e},i.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var n=t[e]&32767,r=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(n=e+this.m.t,t[n]+=this.m.am(0,r,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},i.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},i.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i})(),On=(function(){function i(t){this.m=t,this.r2=E(),this.q3=E(),v.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return i.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=E();return t.copyTo(e),this.reduce(e),e},i.prototype.revert=function(t){return t},i.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},i.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},i.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},i})();function E(){return new v(null)}function R(i,t){return new v(i,t)}var Ee=typeof navigator<"u";Ee&&be&&navigator.appName=="Microsoft Internet Explorer"?(v.prototype.am=function(t,e,n,r,s,a){for(var o=e&32767,c=e>>15;--a>=0;){var l=this[t]&32767,u=this[t++]>>15,f=c*l+u*o;l=o*l+((f&32767)<<15)+n[r]+(s&1073741823),s=(l>>>30)+(f>>>15)+c*u+(s>>>30),n[r++]=l&1073741823}return s},Y=30):Ee&&be&&navigator.appName!="Netscape"?(v.prototype.am=function(t,e,n,r,s,a){for(;--a>=0;){var o=e*this[t++]+n[r]+s;s=Math.floor(o/67108864),n[r++]=o&67108863}return s},Y=26):(v.prototype.am=function(t,e,n,r,s,a){for(var o=e&16383,c=e>>14;--a>=0;){var l=this[t]&16383,u=this[t++]>>14,f=c*l+u*o;l=o*l+((f&16383)<<14)+n[r]+s,s=(l>>28)+(f>>14)+c*u,n[r++]=l&268435455}return s},Y=28);v.prototype.DB=Y;v.prototype.DM=(1<<Y)-1;v.prototype.DV=1<<Y;var se=52;v.prototype.FV=Math.pow(2,se);v.prototype.F1=se-Y;v.prototype.F2=2*Y-se;var Mt=[],dt,K;dt=48;for(K=0;K<=9;++K)Mt[dt++]=K;dt=97;for(K=10;K<36;++K)Mt[dt++]=K;dt=65;for(K=10;K<36;++K)Mt[dt++]=K;function we(i,t){var e=Mt[i.charCodeAt(t)];return e??-1}function Q(i){var t=E();return t.fromInt(i),t}function At(i){var t=1,e;return(e=i>>>16)!=0&&(i=e,t+=16),(e=i>>8)!=0&&(i=e,t+=8),(e=i>>4)!=0&&(i=e,t+=4),(e=i>>2)!=0&&(i=e,t+=2),(e=i>>1)!=0&&(i=e,t+=1),t}v.ZERO=Q(0);v.ONE=Q(1);var Dn=(function(){function i(){this.i=0,this.j=0,this.S=[]}return i.prototype.init=function(t){var e,n,r;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[n],this.S[n]=r;this.i=0,this.j=0},i.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},i})();function In(){return new Dn}var Xe=256,Rt,Z=null,W;if(Z==null){Z=[],W=0;var Ct=void 0;if(typeof window<"u"&&self.crypto&&self.crypto.getRandomValues){var zt=new Uint32Array(256);for(self.crypto.getRandomValues(zt),Ct=0;Ct<zt.length;++Ct)Z[W++]=zt[Ct]&255}var Ot=0,Dt=function(i){if(Ot=Ot||0,Ot>=256||W>=Xe){self.removeEventListener?self.removeEventListener("mousemove",Dt,!1):self.detachEvent&&self.detachEvent("onmousemove",Dt);return}try{var t=i.x+i.y;Z[W++]=t&255,Ot+=1}catch{}};typeof window<"u"&&(self.addEventListener?self.addEventListener("mousemove",Dt,!1):self.attachEvent&&self.attachEvent("onmousemove",Dt))}function Nn(){if(Rt==null){for(Rt=In();W<Xe;){var i=Math.floor(65536*Math.random());Z[W++]=i&255}for(Rt.init(Z),W=0;W<Z.length;++W)Z[W]=0;W=0}return Rt.next()}var Ut=(function(){function i(){}return i.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Nn()},i})();function te(i){return xn(qn(Bn(i),i.length*8))}function Se(i){for(var t="0123456789abcdef",e="",n=0;n<i.length;n++){var r=i.charCodeAt(n);e+=t.charAt(r>>>4&15)+t.charAt(r&15)}return e}function Bn(i){for(var t=Array(i.length>>2),e=0;e<t.length;e++)t[e]=0;for(var e=0;e<i.length*8;e+=8)t[e>>5]|=(i.charCodeAt(e/8)&255)<<24-e%32;return t}function xn(i){for(var t="",e=0;e<i.length*32;e+=8)t+=String.fromCharCode(i[e>>5]>>>24-e%32&255);return t}function G(i,t){return i>>>t|i<<32-t}function ze(i,t){return i>>>t}function Vn(i,t,e){return i&t^~i&e}function Un(i,t,e){return i&t^i&e^t&e}function Ln(i){return G(i,2)^G(i,13)^G(i,22)}function Mn(i){return G(i,6)^G(i,11)^G(i,25)}function Fn(i){return G(i,7)^G(i,18)^ze(i,3)}function kn(i){return G(i,17)^G(i,19)^ze(i,10)}var jn=new Array(1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998);function qn(i,t){var e=new Array(1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225),n=new Array(64),r,s,a,o,c,l,u,f,_,y,m,g;for(i[t>>5]|=128<<24-t%32,i[(t+64>>9<<4)+15]=t,_=0;_<i.length;_+=16){for(r=e[0],s=e[1],a=e[2],o=e[3],c=e[4],l=e[5],u=e[6],f=e[7],y=0;y<64;y++)y<16?n[y]=i[y+_]:n[y]=I(I(I(kn(n[y-2]),n[y-7]),Fn(n[y-15])),n[y-16]),m=I(I(I(I(f,Mn(c)),Vn(c,l,u)),jn[y]),n[y]),g=I(Ln(r),Un(r,s,a)),f=u,u=l,l=c,c=I(o,m),o=a,a=s,s=r,r=I(m,g);e[0]=I(r,e[0]),e[1]=I(s,e[1]),e[2]=I(a,e[2]),e[3]=I(o,e[3]),e[4]=I(c,e[4]),e[5]=I(l,e[5]),e[6]=I(u,e[6]),e[7]=I(f,e[7])}return e}function I(i,t){var e=(i&65535)+(t&65535),n=(i>>16)+(t>>16)+(e>>16);return n<<16|e&65535}function Kn(i,t){if(t<i.length+22)return console.error("Message too long for RSA"),null;for(var e=t-i.length-6,n="",r=0;r<e;r+=2)n+="ff";var s="0001"+n+"00"+i;return R(s,16)}function Hn(i,t){if(t<i.length+11)return console.error("Message too long for RSA"),null;for(var e=[],n=i.length-1;n>=0&&t>0;){var r=i.charCodeAt(n--);r<128?e[--t]=r:r>127&&r<2048?(e[--t]=r&63|128,e[--t]=r>>6|192):(e[--t]=r&63|128,e[--t]=r>>6&63|128,e[--t]=r>>12|224)}e[--t]=0;for(var s=new Ut,a=[];t>2;){for(a[0]=0;a[0]==0;)s.nextBytes(a);e[--t]=a[0]}return e[--t]=2,e[--t]=0,new v(e)}function Te(i,t,e){for(var n="",r=0;n.length<t;)n+=e(String.fromCharCode.apply(String,i.concat([(r&4278190080)>>24,(r&16711680)>>16,(r&65280)>>8,r&255]))),r+=1;return n}var Wn=32;function Xn(i,t){var e=Wn,n=te;if(i.length+2*e+2>t)throw"Message too long for RSA";var r="",s;for(s=0;s<t-i.length-2*e-2;s+=1)r+="\0";var a=n("")+r+""+i,o=new Array(e);new Ut().nextBytes(o);var c=Te(o,a.length,n),l=[];for(s=0;s<a.length;s+=1)l[s]=a.charCodeAt(s)^c.charCodeAt(s);var u=Te(l,o.length,n),f=[0];for(s=0;s<o.length;s+=1)f[s+1]=o[s]^u.charCodeAt(s);return new v(f.concat(l))}var zn=(function(){function i(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return i.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},i.prototype.doPrivate=function(t){if(this.p==null||this.q==null)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)},i.prototype.setPublic=function(t,e){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=R(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},i.prototype.encrypt=function(t,e){typeof e>"u"&&(e=Hn);var n=this.n.bitLength()+7>>3,r=e(t,n);if(r==null)return null;var s=this.doPublic(r);if(s==null)return null;for(var a=s.toString(16),o=a.length,c=0;c<n*2-o;c++)a="0"+a;return a},i.prototype.setPrivate=function(t,e,n){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=R(t,16),this.e=parseInt(e,16),this.d=R(n,16)):console.error("Invalid RSA private key")},i.prototype.setPrivateEx=function(t,e,n,r,s,a,o,c){t!=null&&e!=null&&t.length>0&&e.length>0?(this.n=R(t,16),this.e=parseInt(e,16),this.d=R(n,16),this.p=R(r,16),this.q=R(s,16),this.dmp1=R(a,16),this.dmq1=R(o,16),this.coeff=R(c,16)):console.error("Invalid RSA private key")},i.prototype.generate=function(t,e){var n=new Ut,r=t>>1;this.e=parseInt(e,16);for(var s=new v(e,16);;){for(;this.p=new v(t-r,1,n),!(this.p.subtract(v.ONE).gcd(s).compareTo(v.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new v(r,1,n),!(this.q.subtract(v.ONE).gcd(s).compareTo(v.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var a=this.p;this.p=this.q,this.q=a}var o=this.p.subtract(v.ONE),c=this.q.subtract(v.ONE),l=o.multiply(c);if(l.gcd(s).compareTo(v.ONE)==0){this.n=this.p.multiply(this.q),this.d=s.modInverse(l),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(c),this.coeff=this.q.modInverse(this.p);break}}},i.prototype.decrypt=function(t){var e=R(t,16),n=this.doPrivate(e);return n==null?null:Gn(n,this.n.bitLength()+7>>3)},i.prototype.generateAsync=function(t,e,n){var r=new Ut,s=t>>1;this.e=parseInt(e,16);var a=new v(e,16),o=this,c=function(){var l=function(){if(o.p.compareTo(o.q)<=0){var _=o.p;o.p=o.q,o.q=_}var y=o.p.subtract(v.ONE),m=o.q.subtract(v.ONE),g=y.multiply(m);g.gcd(a).compareTo(v.ONE)==0?(o.n=o.p.multiply(o.q),o.d=a.modInverse(g),o.dmp1=o.d.mod(y),o.dmq1=o.d.mod(m),o.coeff=o.q.modInverse(o.p),setTimeout(function(){n()},0)):setTimeout(c,0)},u=function(){o.q=E(),o.q.fromNumberAsync(s,1,r,function(){o.q.subtract(v.ONE).gcda(a,function(_){_.compareTo(v.ONE)==0&&o.q.isProbablePrime(10)?setTimeout(l,0):setTimeout(u,0)})})},f=function(){o.p=E(),o.p.fromNumberAsync(t-s,1,r,function(){o.p.subtract(v.ONE).gcda(a,function(_){_.compareTo(v.ONE)==0&&o.p.isProbablePrime(10)?setTimeout(u,0):setTimeout(f,0)})})};setTimeout(f,0)};setTimeout(c,0)},i.prototype.sign=function(t,e,n){var r=$n(n),s=r+e(t).toString(),a=this.n.bitLength()/4,o=Kn(s,a);if(o==null)return null;var c=this.doPrivate(o);if(c==null)return null;for(var l=c.toString(16),u=l.length,f=0;f<a-u;f++)l="0"+l;return l},i.prototype.verify=function(t,e,n){var r=R(e,16),s=this.doPublic(r);if(s==null)return null;var a=s.toString(16).replace(/^1f+00/,""),o=Jn(a);return o==n(t).toString()},i})();function Gn(i,t){for(var e=i.toByteArray(),n=0;n<e.length&&e[n]==0;)++n;if(e.length-n!=t-1||e[n]!=2)return null;for(++n;e[n]!=0;)if(++n>=e.length)return null;for(var r="";++n<e.length;){var s=e[n]&255;s<128?r+=String.fromCharCode(s):s>191&&s<224?(r+=String.fromCharCode((s&31)<<6|e[n+1]&63),++n):(r+=String.fromCharCode((s&15)<<12|(e[n+1]&63)<<6|e[n+2]&63),n+=2)}return r}var Nt={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};function $n(i){return Nt[i]||""}function Jn(i){for(var t in Nt)if(Nt.hasOwnProperty(t)){var e=Nt[t],n=e.length;if(i.substring(0,n)==e)return i.substring(n)}return i}function O(i,t,e){if(!t||!i)throw new Error("extend failed, please check that all dependencies are included.");var n=function(){};n.prototype=t.prototype,i.prototype=new n,i.prototype.constructor=i,i.superclass=t.prototype,t.prototype.constructor==Object.prototype.constructor&&(t.prototype.constructor=t)}var p={};(typeof p.asn1>"u"||!p.asn1)&&(p.asn1={});p.asn1.ASN1Util=new function(){this.integerToByteHex=function(i){var t=i.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(i){var t=i.toString(16);if(t.substring(0,1)!="-")t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{var e=t.substring(1),n=e.length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var r="",s=0;s<n;s++)r+="f";var a=new v(r,16),o=a.xor(i).add(v.ONE);t=o.toString(16).replace(/^-/,"")}return t},this.getPEMStringFromHex=function(i,t){return hextopem(i,t)},this.newObject=function(i){var t=p,e=t.asn1,n=e.DERBoolean,r=e.DERInteger,s=e.DERBitString,a=e.DEROctetString,o=e.DERNull,c=e.DERObjectIdentifier,l=e.DEREnumerated,u=e.DERUTF8String,f=e.DERNumericString,_=e.DERPrintableString,y=e.DERTeletexString,m=e.DERIA5String,g=e.DERUTCTime,d=e.DERGeneralizedTime,w=e.DERSequence,C=e.DERSet,T=e.DERTaggedObject,S=e.ASN1Util.newObject,N=Object.keys(i);if(N.length!=1)throw"key of param shall be only one.";var P=N[0];if(":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+P+":")==-1)throw"undefined key: "+P;if(P=="bool")return new n(i[P]);if(P=="int")return new r(i[P]);if(P=="bitstr")return new s(i[P]);if(P=="octstr")return new a(i[P]);if(P=="null")return new o(i[P]);if(P=="oid")return new c(i[P]);if(P=="enum")return new l(i[P]);if(P=="utf8str")return new u(i[P]);if(P=="numstr")return new f(i[P]);if(P=="prnstr")return new _(i[P]);if(P=="telstr")return new y(i[P]);if(P=="ia5str")return new m(i[P]);if(P=="utctime")return new g(i[P]);if(P=="gentime")return new d(i[P]);if(P=="seq"){for(var D=i[P],H=[],k=0;k<D.length;k++){var st=S(D[k]);H.push(st)}return new w({array:H})}if(P=="set"){for(var D=i[P],H=[],k=0;k<D.length;k++){var st=S(D[k]);H.push(st)}return new C({array:H})}if(P=="tag"){var U=i[P];if(Object.prototype.toString.call(U)==="[object Array]"&&U.length==3){var at=S(U[2]);return new T({tag:U[0],explicit:U[1],obj:at})}else{var z={};if(U.explicit!==void 0&&(z.explicit=U.explicit),U.tag!==void 0&&(z.tag=U.tag),U.obj===void 0)throw"obj shall be specified for 'tag'.";return z.obj=S(U.obj),new T(z)}}},this.jsonToASN1HEX=function(i){var t=this.newObject(i);return t.getEncodedHex()}};p.asn1.ASN1Util.oidHexToInt=function(i){for(var r="",t=parseInt(i.substring(0,2),16),e=Math.floor(t/40),n=t%40,r=e+"."+n,s="",a=2;a<i.length;a+=2){var o=parseInt(i.substring(a,a+2),16),c=("00000000"+o.toString(2)).slice(-8);if(s=s+c.substring(1,8),c.substring(0,1)=="0"){var l=new v(s,2);r=r+"."+l.toString(10),s=""}}return r};p.asn1.ASN1Util.oidIntToHex=function(i){var t=function(o){var c=o.toString(16);return c.length==1&&(c="0"+c),c},e=function(o){var c="",l=new v(o,10),u=l.toString(2),f=7-u.length%7;f==7&&(f=0);for(var _="",y=0;y<f;y++)_+="0";u=_+u;for(var y=0;y<u.length-1;y+=7){var m=u.substring(y,y+7);y!=u.length-7&&(m="1"+m),c+=t(parseInt(m,2))}return c};if(!i.match(/^[0-9.]+$/))throw"malformed oid string: "+i;var n="",r=i.split("."),s=parseInt(r[0])*40+parseInt(r[1]);n+=t(s),r.splice(0,2);for(var a=0;a<r.length;a++)n+=e(r[a]);return n};p.asn1.ASN1Object=function(){var i="";this.getLengthHexFromValue=function(){if(typeof this.hV>"u"||this.hV==null)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+i.length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var n=e.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);var r=128+n;return r.toString(16)+e},this.getEncodedHex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}};p.asn1.DERAbstractString=function(i){p.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},typeof i<"u"&&(typeof i=="string"?this.setString(i):typeof i.str<"u"?this.setString(i.str):typeof i.hex<"u"&&this.setStringHex(i.hex))};O(p.asn1.DERAbstractString,p.asn1.ASN1Object);p.asn1.DERAbstractTime=function(i){p.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){utc=t.getTime()+t.getTimezoneOffset()*6e4;var e=new Date(utc);return e},this.formatDate=function(t,e,n){var r=this.zeroPadding,s=this.localDateToUTC(t),a=String(s.getFullYear());e=="utc"&&(a=a.substring(2,4));var o=r(String(s.getMonth()+1),2),c=r(String(s.getDate()),2),l=r(String(s.getHours()),2),u=r(String(s.getMinutes()),2),f=r(String(s.getSeconds()),2),_=a+o+c+l+u+f;if(n===!0){var y=s.getMilliseconds();if(y!=0){var m=r(String(y),3);m=m.replace(/[0]+$/,""),_=_+"."+m}}return _+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,n,r,s,a){var o=new Date(Date.UTC(t,e-1,n,r,s,a,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}};O(p.asn1.DERAbstractTime,p.asn1.ASN1Object);p.asn1.DERAbstractStructured=function(i){p.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,typeof i<"u"&&typeof i.array<"u"&&(this.asn1Array=i.array)};O(p.asn1.DERAbstractStructured,p.asn1.ASN1Object);p.asn1.DERBoolean=function(){p.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"};O(p.asn1.DERBoolean,p.asn1.ASN1Object);p.asn1.DERInteger=function(i){p.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=p.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},typeof i<"u"&&(typeof i.bigint<"u"?this.setByBigInteger(i.bigint):typeof i.int<"u"?this.setByInteger(i.int):typeof i=="number"?this.setByInteger(i):typeof i.hex<"u"&&this.setValueHex(i.hex))};O(p.asn1.DERInteger,p.asn1.ASN1Object);p.asn1.DERBitString=function(i){if(i!==void 0&&typeof i.obj<"u"){var t=p.asn1.ASN1Util.newObject(i.obj);i.hex="00"+t.getEncodedHex()}p.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(e){this.hTLV=null,this.isModified=!0,this.hV=e},this.setUnusedBitsAndHexValue=function(e,n){if(e<0||7<e)throw"unused bits shall be from 0 to 7: u = "+e;var r="0"+e;this.hTLV=null,this.isModified=!0,this.hV=r+n},this.setByBinaryString=function(e){e=e.replace(/0+$/,"");var n=8-e.length%8;n==8&&(n=0);for(var r=0;r<=n;r++)e+="0";for(var s="",r=0;r<e.length-1;r+=8){var a=e.substring(r,r+8),o=parseInt(a,2).toString(16);o.length==1&&(o="0"+o),s+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+n+s},this.setByBooleanArray=function(e){for(var n="",r=0;r<e.length;r++)e[r]==!0?n+="1":n+="0";this.setByBinaryString(n)},this.newFalseArray=function(e){for(var n=new Array(e),r=0;r<e;r++)n[r]=!1;return n},this.getFreshValueHex=function(){return this.hV},typeof i<"u"&&(typeof i=="string"&&i.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(i):typeof i.hex<"u"?this.setHexValueIncludingUnusedBits(i.hex):typeof i.bin<"u"?this.setByBinaryString(i.bin):typeof i.array<"u"&&this.setByBooleanArray(i.array))};O(p.asn1.DERBitString,p.asn1.ASN1Object);p.asn1.DEROctetString=function(i){if(i!==void 0&&typeof i.obj<"u"){var t=p.asn1.ASN1Util.newObject(i.obj);i.hex=t.getEncodedHex()}p.asn1.DEROctetString.superclass.constructor.call(this,i),this.hT="04"};O(p.asn1.DEROctetString,p.asn1.DERAbstractString);p.asn1.DERNull=function(){p.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"};O(p.asn1.DERNull,p.asn1.ASN1Object);p.asn1.DERObjectIdentifier=function(i){var t=function(n){var r=n.toString(16);return r.length==1&&(r="0"+r),r},e=function(n){var r="",s=new v(n,10),a=s.toString(2),o=7-a.length%7;o==7&&(o=0);for(var c="",l=0;l<o;l++)c+="0";a=c+a;for(var l=0;l<a.length-1;l+=7){var u=a.substring(l,l+7);l!=a.length-7&&(u="1"+u),r+=t(parseInt(u,2))}return r};p.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.setValueOidString=function(n){if(!n.match(/^[0-9.]+$/))throw"malformed oid string: "+n;var r="",s=n.split("."),a=parseInt(s[0])*40+parseInt(s[1]);r+=t(a),s.splice(0,2);for(var o=0;o<s.length;o++)r+=e(s[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=r},this.setValueName=function(n){var r=p.asn1.x509.OID.name2oid(n);if(r!=="")this.setValueOidString(r);else throw"DERObjectIdentifier oidName undefined: "+n},this.getFreshValueHex=function(){return this.hV},i!==void 0&&(typeof i=="string"?i.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(i):this.setValueName(i):i.oid!==void 0?this.setValueOidString(i.oid):i.hex!==void 0?this.setValueHex(i.hex):i.name!==void 0&&this.setValueName(i.name))};O(p.asn1.DERObjectIdentifier,p.asn1.ASN1Object);p.asn1.DEREnumerated=function(i){p.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=p.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new v(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},typeof i<"u"&&(typeof i.int<"u"?this.setByInteger(i.int):typeof i=="number"?this.setByInteger(i):typeof i.hex<"u"&&this.setValueHex(i.hex))};O(p.asn1.DEREnumerated,p.asn1.ASN1Object);p.asn1.DERUTF8String=function(i){p.asn1.DERUTF8String.superclass.constructor.call(this,i),this.hT="0c"};O(p.asn1.DERUTF8String,p.asn1.DERAbstractString);p.asn1.DERNumericString=function(i){p.asn1.DERNumericString.superclass.constructor.call(this,i),this.hT="12"};O(p.asn1.DERNumericString,p.asn1.DERAbstractString);p.asn1.DERPrintableString=function(i){p.asn1.DERPrintableString.superclass.constructor.call(this,i),this.hT="13"};O(p.asn1.DERPrintableString,p.asn1.DERAbstractString);p.asn1.DERTeletexString=function(i){p.asn1.DERTeletexString.superclass.constructor.call(this,i),this.hT="14"};O(p.asn1.DERTeletexString,p.asn1.DERAbstractString);p.asn1.DERIA5String=function(i){p.asn1.DERIA5String.superclass.constructor.call(this,i),this.hT="16"};O(p.asn1.DERIA5String,p.asn1.DERAbstractString);p.asn1.DERUTCTime=function(i){p.asn1.DERUTCTime.superclass.constructor.call(this,i),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return typeof this.date>"u"&&typeof this.s>"u"&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},i!==void 0&&(i.str!==void 0?this.setString(i.str):typeof i=="string"&&i.match(/^[0-9]{12}Z$/)?this.setString(i):i.hex!==void 0?this.setStringHex(i.hex):i.date!==void 0&&this.setByDate(i.date))};O(p.asn1.DERUTCTime,p.asn1.DERAbstractTime);p.asn1.DERGeneralizedTime=function(i){p.asn1.DERGeneralizedTime.superclass.constructor.call(this,i),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return this.date===void 0&&this.s===void 0&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},i!==void 0&&(i.str!==void 0?this.setString(i.str):typeof i=="string"&&i.match(/^[0-9]{14}Z$/)?this.setString(i):i.hex!==void 0?this.setStringHex(i.hex):i.date!==void 0&&this.setByDate(i.date),i.millis===!0&&(this.withMillis=!0))};O(p.asn1.DERGeneralizedTime,p.asn1.DERAbstractTime);p.asn1.DERSequence=function(i){p.asn1.DERSequence.superclass.constructor.call(this,i),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t+=n.getEncodedHex()}return this.hV=t,this.hV}};O(p.asn1.DERSequence,p.asn1.DERAbstractStructured);p.asn1.DERSet=function(i){p.asn1.DERSet.superclass.constructor.call(this,i),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var n=this.asn1Array[e];t.push(n.getEncodedHex())}return this.sortFlag==!0&&t.sort(),this.hV=t.join(""),this.hV},typeof i<"u"&&typeof i.sortflag<"u"&&i.sortflag==!1&&(this.sortFlag=!1)};O(p.asn1.DERSet,p.asn1.DERAbstractStructured);p.asn1.DERTaggedObject=function(i){p.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},typeof i<"u"&&(typeof i.tag<"u"&&(this.hT=i.tag),typeof i.explicit<"u"&&(this.isExplicit=i.explicit),typeof i.obj<"u"&&(this.asn1Object=i.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))};O(p.asn1.DERTaggedObject,p.asn1.ASN1Object);var Qn=(function(){var i=function(t,e){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,r){n.__proto__=r}||function(n,r){for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(n[s]=r[s])},i(t,e)};return function(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");i(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}})(),Ae=(function(i){Qn(t,i);function t(e){var n=i.call(this)||this;return e&&(typeof e=="string"?n.parseKey(e):(t.hasPrivateKeyProperty(e)||t.hasPublicKeyProperty(e))&&n.parsePropertiesFrom(e)),n}return t.prototype.parseKey=function(e){try{var n=0,r=0,s=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/,a=s.test(e)?En.decode(e):Yt.unarmor(e),o=Tn.decode(a);if(o.sub.length===3&&(o=o.sub[2].sub[0]),o.sub.length===9){n=o.sub[1].getHexStringValue(),this.n=R(n,16),r=o.sub[2].getHexStringValue(),this.e=parseInt(r,16);var c=o.sub[3].getHexStringValue();this.d=R(c,16);var l=o.sub[4].getHexStringValue();this.p=R(l,16);var u=o.sub[5].getHexStringValue();this.q=R(u,16);var f=o.sub[6].getHexStringValue();this.dmp1=R(f,16);var _=o.sub[7].getHexStringValue();this.dmq1=R(_,16);var y=o.sub[8].getHexStringValue();this.coeff=R(y,16)}else if(o.sub.length===2)if(o.sub[0].sub){var m=o.sub[1],g=m.sub[0];n=g.sub[0].getHexStringValue(),this.n=R(n,16),r=g.sub[1].getHexStringValue(),this.e=parseInt(r,16)}else n=o.sub[0].getHexStringValue(),this.n=R(n,16),r=o.sub[1].getHexStringValue(),this.e=parseInt(r,16);else return!1;return!0}catch{return!1}},t.prototype.getPrivateBaseKey=function(){var e={array:[new p.asn1.DERInteger({int:0}),new p.asn1.DERInteger({bigint:this.n}),new p.asn1.DERInteger({int:this.e}),new p.asn1.DERInteger({bigint:this.d}),new p.asn1.DERInteger({bigint:this.p}),new p.asn1.DERInteger({bigint:this.q}),new p.asn1.DERInteger({bigint:this.dmp1}),new p.asn1.DERInteger({bigint:this.dmq1}),new p.asn1.DERInteger({bigint:this.coeff})]},n=new p.asn1.DERSequence(e);return n.getEncodedHex()},t.prototype.getPrivateBaseKeyB64=function(){return yt(this.getPrivateBaseKey())},t.prototype.getPublicBaseKey=function(){var e=new p.asn1.DERSequence({array:[new p.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new p.asn1.DERNull]}),n=new p.asn1.DERSequence({array:[new p.asn1.DERInteger({bigint:this.n}),new p.asn1.DERInteger({int:this.e})]}),r=new p.asn1.DERBitString({hex:"00"+n.getEncodedHex()}),s=new p.asn1.DERSequence({array:[e,r]});return s.getEncodedHex()},t.prototype.getPublicBaseKeyB64=function(){return yt(this.getPublicBaseKey())},t.wordwrap=function(e,n){if(n=n||64,!e)return e;var r="(.{1,"+n+`})( +|$
9
+ ?)|(.{1,`+n+"})";return e.match(RegExp(r,"g")).join(`
10
10
  `)},t.prototype.getPrivateKey=function(){var e=`-----BEGIN RSA PRIVATE KEY-----
11
11
  `;return e+=t.wordwrap(this.getPrivateBaseKeyB64())+`
12
12
  `,e+="-----END RSA PRIVATE KEY-----",e},t.prototype.getPublicKey=function(){var e=`-----BEGIN PUBLIC KEY-----
13
13
  `;return e+=t.wordwrap(this.getPublicBaseKeyB64())+`
14
- `,e+="-----END PUBLIC KEY-----",e},t.hasPublicKeyProperty=function(e){return e=e||{},e.hasOwnProperty("n")&&e.hasOwnProperty("e")},t.hasPrivateKeyProperty=function(e){return e=e||{},e.hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t})(Wi),Xt,Ji=typeof process<"u"?(Xt=process.env)===null||Xt===void 0?void 0:Xt.npm_package_version:void 0,Qi=(function(){function n(t){t===void 0&&(t={}),this.default_key_size=t.default_key_size?parseInt(t.default_key_size,10):1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=t.key||null}return n.prototype.setKey=function(t){t?(this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new Te(t)):!this.key&&this.log&&console.error("A key was not set.")},n.prototype.setPrivateKey=function(t){this.setKey(t)},n.prototype.setPublicKey=function(t){this.setKey(t)},n.prototype.decrypt=function(t){try{return this.getKey().decrypt(ge(t))}catch{return!1}},n.prototype.encrypt=function(t){try{return mt(this.getKey().encrypt(t))}catch{return!1}},n.prototype.encryptOAEP=function(t){try{return mt(this.getKey().encrypt(t,Hi))}catch{return!1}},n.prototype.sign=function(t,e,i){e===void 0&&(e=function(r){return r}),i===void 0&&(i="");try{return mt(this.getKey().sign(t,e,i))}catch{return!1}},n.prototype.signSha256=function(t){return this.sign(t,function(e){return we(Zt(e))},"sha256")},n.prototype.verify=function(t,e,i){i===void 0&&(i=function(r){return r});try{return this.getKey().verify(t,ge(e),i)}catch{return!1}},n.prototype.verifySha256=function(t,e){return this.verify(t,e,function(i){return we(Zt(i))})},n.prototype.getKey=function(t){if(!this.key){if(this.key=new Te,t&&{}.toString.call(t)==="[object Function]"){this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},n.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},n.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},n.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},n.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},n.version=Ji,n})();function ze(n,t){return function(){return n.apply(t,arguments)}}const{toString:Zi}=Object.prototype,{getPrototypeOf:re}=Object,{iterator:Mt,toStringTag:Ge}=Symbol,Ft=(n=>t=>{const e=Zi.call(t);return n[e]||(n[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),H=n=>(n=n.toLowerCase(),t=>Ft(t)===n),kt=n=>t=>typeof t===n,{isArray:dt}=Array,ft=kt("undefined");function yt(n){return n!==null&&!ft(n)&&n.constructor!==null&&!ft(n.constructor)&&M(n.constructor.isBuffer)&&n.constructor.isBuffer(n)}const $e=H("ArrayBuffer");function Yi(n){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(n):t=n&&n.buffer&&$e(n.buffer),t}const tn=kt("string"),M=kt("function"),Je=kt("number"),bt=n=>n!==null&&typeof n=="object",en=n=>n===!0||n===!1,Nt=n=>{if(Ft(n)!=="object")return!1;const t=re(n);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Ge in n)&&!(Mt in n)},nn=n=>{if(!bt(n)||yt(n))return!1;try{return Object.keys(n).length===0&&Object.getPrototypeOf(n)===Object.prototype}catch{return!1}},rn=H("Date"),sn=H("File"),an=n=>!!(n&&typeof n.uri<"u"),on=n=>n&&typeof n.getParts<"u",cn=H("Blob"),un=H("FileList"),hn=n=>bt(n)&&M(n.pipe);function ln(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Ae=ln(),Ce=typeof Ae.FormData<"u"?Ae.FormData:void 0,fn=n=>{let t;return n&&(Ce&&n instanceof Ce||M(n.append)&&((t=Ft(n))==="formdata"||t==="object"&&M(n.toString)&&n.toString()==="[object FormData]"))},pn=H("URLSearchParams"),[dn,_n,gn,mn]=["ReadableStream","Request","Response","Headers"].map(H),yn=n=>n.trim?n.trim():n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Pt(n,t,{allOwnKeys:e=!1}={}){if(n===null||typeof n>"u")return;let i,r;if(typeof n!="object"&&(n=[n]),dt(n))for(i=0,r=n.length;i<r;i++)t.call(null,n[i],i,n);else{if(yt(n))return;const s=e?Object.getOwnPropertyNames(n):Object.keys(n),a=s.length;let o;for(i=0;i<a;i++)o=s[i],t.call(null,n[o],o,n)}}function Qe(n,t){if(yt(n))return null;t=t.toLowerCase();const e=Object.keys(n);let i=e.length,r;for(;i-- >0;)if(r=e[i],t===r.toLowerCase())return r;return null}const it=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ze=n=>!ft(n)&&n!==it;function Yt(){const{caseless:n,skipUndefined:t}=Ze(this)&&this||{},e={},i=(r,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const a=n&&Qe(e,s)||s;Nt(e[a])&&Nt(r)?e[a]=Yt(e[a],r):Nt(r)?e[a]=Yt({},r):dt(r)?e[a]=r.slice():(!t||!ft(r))&&(e[a]=r)};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&Pt(arguments[r],i);return e}const bn=(n,t,e,{allOwnKeys:i}={})=>(Pt(t,(r,s)=>{e&&M(r)?Object.defineProperty(n,s,{value:ze(r,e),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(n,s,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:i}),n),Pn=n=>(n.charCodeAt(0)===65279&&(n=n.slice(1)),n),vn=(n,t,e,i)=>{n.prototype=Object.create(t.prototype,i),Object.defineProperty(n.prototype,"constructor",{value:n,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(n,"super",{value:t.prototype}),e&&Object.assign(n.prototype,e)},En=(n,t,e,i)=>{let r,s,a;const o={};if(t=t||{},n==null)return t;do{for(r=Object.getOwnPropertyNames(n),s=r.length;s-- >0;)a=r[s],(!i||i(a,n,t))&&!o[a]&&(t[a]=n[a],o[a]=!0);n=e!==!1&&re(n)}while(n&&(!e||e(n,t))&&n!==Object.prototype);return t},wn=(n,t,e)=>{n=String(n),(e===void 0||e>n.length)&&(e=n.length),e-=t.length;const i=n.indexOf(t,e);return i!==-1&&i===e},Sn=n=>{if(!n)return null;if(dt(n))return n;let t=n.length;if(!Je(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=n[t];return e},Tn=(n=>t=>n&&t instanceof n)(typeof Uint8Array<"u"&&re(Uint8Array)),An=(n,t)=>{const i=(n&&n[Mt]).call(n);let r;for(;(r=i.next())&&!r.done;){const s=r.value;t.call(n,s[0],s[1])}},Cn=(n,t)=>{let e;const i=[];for(;(e=n.exec(t))!==null;)i.push(e);return i},Rn=H("HTMLFormElement"),On=n=>n.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,i,r){return i.toUpperCase()+r}),Re=(({hasOwnProperty:n})=>(t,e)=>n.call(t,e))(Object.prototype),Dn=H("RegExp"),Ye=(n,t)=>{const e=Object.getOwnPropertyDescriptors(n),i={};Pt(e,(r,s)=>{let a;(a=t(r,s,n))!==!1&&(i[s]=a||r)}),Object.defineProperties(n,i)},In=n=>{Ye(n,(t,e)=>{if(M(n)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const i=n[e];if(M(i)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},Nn=(n,t)=>{const e={},i=r=>{r.forEach(s=>{e[s]=!0})};return dt(n)?i(n):i(String(n).split(t)),e},Bn=()=>{},xn=(n,t)=>n!=null&&Number.isFinite(n=+n)?n:t;function Vn(n){return!!(n&&M(n.append)&&n[Ge]==="FormData"&&n[Mt])}const Un=n=>{const t=new Array(10),e=(i,r)=>{if(bt(i)){if(t.indexOf(i)>=0)return;if(yt(i))return i;if(!("toJSON"in i)){t[r]=i;const s=dt(i)?[]:{};return Pt(i,(a,o)=>{const c=e(a,r+1);!ft(c)&&(s[o]=c)}),t[r]=void 0,s}}return i};return e(n,0)},Ln=H("AsyncFunction"),Mn=n=>n&&(bt(n)||M(n))&&M(n.then)&&M(n.catch),ti=((n,t)=>n?setImmediate:t?((e,i)=>(it.addEventListener("message",({source:r,data:s})=>{r===it&&s===e&&i.length&&i.shift()()},!1),r=>{i.push(r),it.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",M(it.postMessage)),Fn=typeof queueMicrotask<"u"?queueMicrotask.bind(it):typeof process<"u"&&process.nextTick||ti,kn=n=>n!=null&&M(n[Mt]),l={isArray:dt,isArrayBuffer:$e,isBuffer:yt,isFormData:fn,isArrayBufferView:Yi,isString:tn,isNumber:Je,isBoolean:en,isObject:bt,isPlainObject:Nt,isEmptyObject:nn,isReadableStream:dn,isRequest:_n,isResponse:gn,isHeaders:mn,isUndefined:ft,isDate:rn,isFile:sn,isReactNativeBlob:an,isReactNative:on,isBlob:cn,isRegExp:Dn,isFunction:M,isStream:hn,isURLSearchParams:pn,isTypedArray:Tn,isFileList:un,forEach:Pt,merge:Yt,extend:bn,trim:yn,stripBOM:Pn,inherits:vn,toFlatObject:En,kindOf:Ft,kindOfTest:H,endsWith:wn,toArray:Sn,forEachEntry:An,matchAll:Cn,isHTMLForm:Rn,hasOwnProperty:Re,hasOwnProp:Re,reduceDescriptors:Ye,freezeMethods:In,toObjectSet:Nn,toCamelCase:On,noop:Bn,toFiniteNumber:xn,findKey:Qe,global:it,isContextDefined:Ze,isSpecCompliantForm:Vn,toJSONObject:Un,isAsyncFn:Ln,isThenable:Mn,setImmediate:ti,asap:Fn,isIterable:kn};let b=class ei extends Error{static from(t,e,i,r,s,a){const o=new ei(t.message,e||t.code,i,r,s);return o.cause=t,o.name=t.name,t.status!=null&&o.status==null&&(o.status=t.status),a&&Object.assign(o,a),o}constructor(t,e,i,r,s){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,e&&(this.code=e),i&&(this.config=i),r&&(this.request=r),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:l.toJSONObject(this.config),code:this.code,status:this.status}}};b.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";b.ERR_BAD_OPTION="ERR_BAD_OPTION";b.ECONNABORTED="ECONNABORTED";b.ETIMEDOUT="ETIMEDOUT";b.ERR_NETWORK="ERR_NETWORK";b.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";b.ERR_DEPRECATED="ERR_DEPRECATED";b.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";b.ERR_BAD_REQUEST="ERR_BAD_REQUEST";b.ERR_CANCELED="ERR_CANCELED";b.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";b.ERR_INVALID_URL="ERR_INVALID_URL";const jn=null;function te(n){return l.isPlainObject(n)||l.isArray(n)}function ii(n){return l.endsWith(n,"[]")?n.slice(0,-2):n}function zt(n,t,e){return n?n.concat(t).map(function(r,s){return r=ii(r),!e&&s?"["+r+"]":r}).join(e?".":""):t}function qn(n){return l.isArray(n)&&!n.some(te)}const Kn=l.toFlatObject(l,{},null,function(t){return/^is[A-Z]/.test(t)});function jt(n,t,e){if(!l.isObject(n))throw new TypeError("target must be an object");t=t||new FormData,e=l.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(m,g){return!l.isUndefined(g[m])});const i=e.metaTokens,r=e.visitor||u,s=e.dots,a=e.indexes,c=(e.Blob||typeof Blob<"u"&&Blob)&&l.isSpecCompliantForm(t);if(!l.isFunction(r))throw new TypeError("visitor must be a function");function h(p){if(p===null)return"";if(l.isDate(p))return p.toISOString();if(l.isBoolean(p))return p.toString();if(!c&&l.isBlob(p))throw new b("Blob is not supported. Use a Buffer instead.");return l.isArrayBuffer(p)||l.isTypedArray(p)?c&&typeof Blob=="function"?new Blob([p]):Buffer.from(p):p}function u(p,m,g){let w=p;if(l.isReactNative(t)&&l.isReactNativeBlob(p))return t.append(zt(g,m,s),h(p)),!1;if(p&&!g&&typeof p=="object"){if(l.endsWith(m,"{}"))m=i?m:m.slice(0,-2),p=JSON.stringify(p);else if(l.isArray(p)&&qn(p)||(l.isFileList(p)||l.endsWith(m,"[]"))&&(w=l.toArray(p)))return m=ii(m),w.forEach(function(T,O){!(l.isUndefined(T)||T===null)&&t.append(a===!0?zt([m],O,s):a===null?m:m+"[]",h(T))}),!1}return te(p)?!0:(t.append(zt(g,m,s),h(p)),!1)}const f=[],_=Object.assign(Kn,{defaultVisitor:u,convertValue:h,isVisitable:te});function y(p,m){if(!l.isUndefined(p)){if(f.indexOf(p)!==-1)throw Error("Circular reference detected in "+m.join("."));f.push(p),l.forEach(p,function(w,A){(!(l.isUndefined(w)||w===null)&&r.call(t,w,l.isString(A)?A.trim():A,m,_))===!0&&y(w,m?m.concat(A):[A])}),f.pop()}}if(!l.isObject(n))throw new TypeError("data must be an object");return y(n),t}function Oe(n){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(n).replace(/[!'()~]|%20|%00/g,function(i){return t[i]})}function se(n,t){this._pairs=[],n&&jt(n,this,t)}const ni=se.prototype;ni.append=function(t,e){this._pairs.push([t,e])};ni.toString=function(t){const e=t?function(i){return t.call(this,i,Oe)}:Oe;return this._pairs.map(function(r){return e(r[0])+"="+e(r[1])},"").join("&")};function Hn(n){return encodeURIComponent(n).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ri(n,t,e){if(!t)return n;const i=e&&e.encode||Hn,r=l.isFunction(e)?{serialize:e}:e,s=r&&r.serialize;let a;if(s?a=s(t,r):a=l.isURLSearchParams(t)?t.toString():new se(t,r).toString(i),a){const o=n.indexOf("#");o!==-1&&(n=n.slice(0,o)),n+=(n.indexOf("?")===-1?"?":"&")+a}return n}class De{constructor(){this.handlers=[]}use(t,e,i){return this.handlers.push({fulfilled:t,rejected:e,synchronous:i?i.synchronous:!1,runWhen:i?i.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){l.forEach(this.handlers,function(i){i!==null&&t(i)})}}const ae={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Wn=typeof URLSearchParams<"u"?URLSearchParams:se,Xn=typeof FormData<"u"?FormData:null,zn=typeof Blob<"u"?Blob:null,Gn={isBrowser:!0,classes:{URLSearchParams:Wn,FormData:Xn,Blob:zn},protocols:["http","https","file","blob","url","data"]},oe=typeof window<"u"&&typeof document<"u",ee=typeof navigator=="object"&&navigator||void 0,$n=oe&&(!ee||["ReactNative","NativeScript","NS"].indexOf(ee.product)<0),Jn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Qn=oe&&window.location.href||"http://localhost",Zn=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:oe,hasStandardBrowserEnv:$n,hasStandardBrowserWebWorkerEnv:Jn,navigator:ee,origin:Qn},Symbol.toStringTag,{value:"Module"})),N={...Zn,...Gn};function Yn(n,t){return jt(n,new N.classes.URLSearchParams,{visitor:function(e,i,r,s){return N.isNode&&l.isBuffer(e)?(this.append(i,e.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function tr(n){return l.matchAll(/\w+|\[(\w*)]/g,n).map(t=>t[0]==="[]"?"":t[1]||t[0])}function er(n){const t={},e=Object.keys(n);let i;const r=e.length;let s;for(i=0;i<r;i++)s=e[i],t[s]=n[s];return t}function si(n){function t(e,i,r,s){let a=e[s++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),c=s>=e.length;return a=!a&&l.isArray(r)?r.length:a,c?(l.hasOwnProp(r,a)?r[a]=[r[a],i]:r[a]=i,!o):((!r[a]||!l.isObject(r[a]))&&(r[a]=[]),t(e,i,r[a],s)&&l.isArray(r[a])&&(r[a]=er(r[a])),!o)}if(l.isFormData(n)&&l.isFunction(n.entries)){const e={};return l.forEachEntry(n,(i,r)=>{t(tr(i),r,e,0)}),e}return null}function ir(n,t,e){if(l.isString(n))try{return(t||JSON.parse)(n),l.trim(n)}catch(i){if(i.name!=="SyntaxError")throw i}return(e||JSON.stringify)(n)}const vt={transitional:ae,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const i=e.getContentType()||"",r=i.indexOf("application/json")>-1,s=l.isObject(t);if(s&&l.isHTMLForm(t)&&(t=new FormData(t)),l.isFormData(t))return r?JSON.stringify(si(t)):t;if(l.isArrayBuffer(t)||l.isBuffer(t)||l.isStream(t)||l.isFile(t)||l.isBlob(t)||l.isReadableStream(t))return t;if(l.isArrayBufferView(t))return t.buffer;if(l.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(s){if(i.indexOf("application/x-www-form-urlencoded")>-1)return Yn(t,this.formSerializer).toString();if((o=l.isFileList(t))||i.indexOf("multipart/form-data")>-1){const c=this.env&&this.env.FormData;return jt(o?{"files[]":t}:t,c&&new c,this.formSerializer)}}return s||r?(e.setContentType("application/json",!1),ir(t)):t}],transformResponse:[function(t){const e=this.transitional||vt.transitional,i=e&&e.forcedJSONParsing,r=this.responseType==="json";if(l.isResponse(t)||l.isReadableStream(t))return t;if(t&&l.isString(t)&&(i&&!this.responseType||r)){const a=!(e&&e.silentJSONParsing)&&r;try{return JSON.parse(t,this.parseReviver)}catch(o){if(a)throw o.name==="SyntaxError"?b.from(o,b.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:N.classes.FormData,Blob:N.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};l.forEach(["delete","get","head","post","put","patch"],n=>{vt.headers[n]={}});const nr=l.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),rr=n=>{const t={};let e,i,r;return n&&n.split(`
15
- `).forEach(function(a){r=a.indexOf(":"),e=a.substring(0,r).trim().toLowerCase(),i=a.substring(r+1).trim(),!(!e||t[e]&&nr[e])&&(e==="set-cookie"?t[e]?t[e].push(i):t[e]=[i]:t[e]=t[e]?t[e]+", "+i:i)}),t},Ie=Symbol("internals");function _t(n){return n&&String(n).trim().toLowerCase()}function Bt(n){return n===!1||n==null?n:l.isArray(n)?n.map(Bt):String(n)}function sr(n){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let i;for(;i=e.exec(n);)t[i[1]]=i[2];return t}const ar=n=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(n.trim());function Gt(n,t,e,i,r){if(l.isFunction(i))return i.call(this,t,e);if(r&&(t=e),!!l.isString(t)){if(l.isString(i))return t.indexOf(i)!==-1;if(l.isRegExp(i))return i.test(t)}}function or(n){return n.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,i)=>e.toUpperCase()+i)}function cr(n,t){const e=l.toCamelCase(" "+t);["get","set","has"].forEach(i=>{Object.defineProperty(n,i+e,{value:function(r,s,a){return this[i].call(this,t,r,s,a)},configurable:!0})})}let F=class{constructor(t){t&&this.set(t)}set(t,e,i){const r=this;function s(o,c,h){const u=_t(c);if(!u)throw new Error("header name must be a non-empty string");const f=l.findKey(r,u);(!f||r[f]===void 0||h===!0||h===void 0&&r[f]!==!1)&&(r[f||c]=Bt(o))}const a=(o,c)=>l.forEach(o,(h,u)=>s(h,u,c));if(l.isPlainObject(t)||t instanceof this.constructor)a(t,e);else if(l.isString(t)&&(t=t.trim())&&!ar(t))a(rr(t),e);else if(l.isObject(t)&&l.isIterable(t)){let o={},c,h;for(const u of t){if(!l.isArray(u))throw TypeError("Object iterator must return a key-value pair");o[h=u[0]]=(c=o[h])?l.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}a(o,e)}else t!=null&&s(e,t,i);return this}get(t,e){if(t=_t(t),t){const i=l.findKey(this,t);if(i){const r=this[i];if(!e)return r;if(e===!0)return sr(r);if(l.isFunction(e))return e.call(this,r,i);if(l.isRegExp(e))return e.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=_t(t),t){const i=l.findKey(this,t);return!!(i&&this[i]!==void 0&&(!e||Gt(this,this[i],i,e)))}return!1}delete(t,e){const i=this;let r=!1;function s(a){if(a=_t(a),a){const o=l.findKey(i,a);o&&(!e||Gt(i,i[o],o,e))&&(delete i[o],r=!0)}}return l.isArray(t)?t.forEach(s):s(t),r}clear(t){const e=Object.keys(this);let i=e.length,r=!1;for(;i--;){const s=e[i];(!t||Gt(this,this[s],s,t,!0))&&(delete this[s],r=!0)}return r}normalize(t){const e=this,i={};return l.forEach(this,(r,s)=>{const a=l.findKey(i,s);if(a){e[a]=Bt(r),delete e[s];return}const o=t?or(s):String(s).trim();o!==s&&delete e[s],e[o]=Bt(r),i[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return l.forEach(this,(i,r)=>{i!=null&&i!==!1&&(e[r]=t&&l.isArray(i)?i.join(", "):i)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join(`
16
- `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const i=new this(t);return e.forEach(r=>i.set(r)),i}static accessor(t){const i=(this[Ie]=this[Ie]={accessors:{}}).accessors,r=this.prototype;function s(a){const o=_t(a);i[o]||(cr(r,a),i[o]=!0)}return l.isArray(t)?t.forEach(s):s(t),this}};F.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);l.reduceDescriptors(F.prototype,({value:n},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>n,set(i){this[e]=i}}});l.freezeMethods(F);function $t(n,t){const e=this||vt,i=t||e,r=F.from(i.headers);let s=i.data;return l.forEach(n,function(o){s=o.call(e,s,r.normalize(),t?t.status:void 0)}),r.normalize(),s}function ai(n){return!!(n&&n.__CANCEL__)}let Et=class extends b{constructor(t,e,i){super(t??"canceled",b.ERR_CANCELED,e,i),this.name="CanceledError",this.__CANCEL__=!0}};function oi(n,t,e){const i=e.config.validateStatus;!e.status||!i||i(e.status)?n(e):t(new b("Request failed with status code "+e.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function ur(n){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(n);return t&&t[1]||""}function hr(n,t){n=n||10;const e=new Array(n),i=new Array(n);let r=0,s=0,a;return t=t!==void 0?t:1e3,function(c){const h=Date.now(),u=i[s];a||(a=h),e[r]=c,i[r]=h;let f=s,_=0;for(;f!==r;)_+=e[f++],f=f%n;if(r=(r+1)%n,r===s&&(s=(s+1)%n),h-a<t)return;const y=u&&h-u;return y?Math.round(_*1e3/y):void 0}}function lr(n,t){let e=0,i=1e3/t,r,s;const a=(h,u=Date.now())=>{e=u,r=null,s&&(clearTimeout(s),s=null),n(...h)};return[(...h)=>{const u=Date.now(),f=u-e;f>=i?a(h,u):(r=h,s||(s=setTimeout(()=>{s=null,a(r)},i-f)))},()=>r&&a(r)]}const Ut=(n,t,e=3)=>{let i=0;const r=hr(50,250);return lr(s=>{const a=s.loaded,o=s.lengthComputable?s.total:void 0,c=a-i,h=r(c),u=a<=o;i=a;const f={loaded:a,total:o,progress:o?a/o:void 0,bytes:c,rate:h||void 0,estimated:h&&o&&u?(o-a)/h:void 0,event:s,lengthComputable:o!=null,[t?"download":"upload"]:!0};n(f)},e)},Ne=(n,t)=>{const e=n!=null;return[i=>t[0]({lengthComputable:e,total:n,loaded:i}),t[1]]},Be=n=>(...t)=>l.asap(()=>n(...t)),fr=N.hasStandardBrowserEnv?((n,t)=>e=>(e=new URL(e,N.origin),n.protocol===e.protocol&&n.host===e.host&&(t||n.port===e.port)))(new URL(N.origin),N.navigator&&/(msie|trident)/i.test(N.navigator.userAgent)):()=>!0,pr=N.hasStandardBrowserEnv?{write(n,t,e,i,r,s,a){if(typeof document>"u")return;const o=[`${n}=${encodeURIComponent(t)}`];l.isNumber(e)&&o.push(`expires=${new Date(e).toUTCString()}`),l.isString(i)&&o.push(`path=${i}`),l.isString(r)&&o.push(`domain=${r}`),s===!0&&o.push("secure"),l.isString(a)&&o.push(`SameSite=${a}`),document.cookie=o.join("; ")},read(n){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+n+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(n){this.write(n,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function dr(n){return typeof n!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(n)}function _r(n,t){return t?n.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):n}function ci(n,t,e){let i=!dr(t);return n&&(i||e==!1)?_r(n,t):t}const xe=n=>n instanceof F?{...n}:n;function rt(n,t){t=t||{};const e={};function i(h,u,f,_){return l.isPlainObject(h)&&l.isPlainObject(u)?l.merge.call({caseless:_},h,u):l.isPlainObject(u)?l.merge({},u):l.isArray(u)?u.slice():u}function r(h,u,f,_){if(l.isUndefined(u)){if(!l.isUndefined(h))return i(void 0,h,f,_)}else return i(h,u,f,_)}function s(h,u){if(!l.isUndefined(u))return i(void 0,u)}function a(h,u){if(l.isUndefined(u)){if(!l.isUndefined(h))return i(void 0,h)}else return i(void 0,u)}function o(h,u,f){if(f in t)return i(h,u);if(f in n)return i(void 0,h)}const c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(h,u,f)=>r(xe(h),xe(u),f,!0)};return l.forEach(Object.keys({...n,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const f=l.hasOwnProp(c,u)?c[u]:r,_=f(n[u],t[u],u);l.isUndefined(_)&&f!==o||(e[u]=_)}),e}const ui=n=>{const t=rt({},n);let{data:e,withXSRFToken:i,xsrfHeaderName:r,xsrfCookieName:s,headers:a,auth:o}=t;if(t.headers=a=F.from(a),t.url=ri(ci(t.baseURL,t.url,t.allowAbsoluteUrls),n.params,n.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),l.isFormData(e)){if(N.hasStandardBrowserEnv||N.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(l.isFunction(e.getHeaders)){const c=e.getHeaders(),h=["content-type","content-length"];Object.entries(c).forEach(([u,f])=>{h.includes(u.toLowerCase())&&a.set(u,f)})}}if(N.hasStandardBrowserEnv&&(i&&l.isFunction(i)&&(i=i(t)),i||i!==!1&&fr(t.url))){const c=r&&s&&pr.read(s);c&&a.set(r,c)}return t},gr=typeof XMLHttpRequest<"u",mr=gr&&function(n){return new Promise(function(e,i){const r=ui(n);let s=r.data;const a=F.from(r.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:h}=r,u,f,_,y,p;function m(){y&&y(),p&&p(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let g=new XMLHttpRequest;g.open(r.method.toUpperCase(),r.url,!0),g.timeout=r.timeout;function w(){if(!g)return;const T=F.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders()),V={data:!o||o==="text"||o==="json"?g.responseText:g.response,status:g.status,statusText:g.statusText,headers:T,config:n,request:g};oi(function(D){e(D),m()},function(D){i(D),m()},V),g=null}"onloadend"in g?g.onloadend=w:g.onreadystatechange=function(){!g||g.readyState!==4||g.status===0&&!(g.responseURL&&g.responseURL.indexOf("file:")===0)||setTimeout(w)},g.onabort=function(){g&&(i(new b("Request aborted",b.ECONNABORTED,n,g)),g=null)},g.onerror=function(O){const V=O&&O.message?O.message:"Network Error",P=new b(V,b.ERR_NETWORK,n,g);P.event=O||null,i(P),g=null},g.ontimeout=function(){let O=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const V=r.transitional||ae;r.timeoutErrorMessage&&(O=r.timeoutErrorMessage),i(new b(O,V.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,n,g)),g=null},s===void 0&&a.setContentType(null),"setRequestHeader"in g&&l.forEach(a.toJSON(),function(O,V){g.setRequestHeader(V,O)}),l.isUndefined(r.withCredentials)||(g.withCredentials=!!r.withCredentials),o&&o!=="json"&&(g.responseType=r.responseType),h&&([_,p]=Ut(h,!0),g.addEventListener("progress",_)),c&&g.upload&&([f,y]=Ut(c),g.upload.addEventListener("progress",f),g.upload.addEventListener("loadend",y)),(r.cancelToken||r.signal)&&(u=T=>{g&&(i(!T||T.type?new Et(null,n,g):T),g.abort(),g=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const A=ur(r.url);if(A&&N.protocols.indexOf(A)===-1){i(new b("Unsupported protocol "+A+":",b.ERR_BAD_REQUEST,n));return}g.send(s||null)})},yr=(n,t)=>{const{length:e}=n=n?n.filter(Boolean):[];if(t||e){let i=new AbortController,r;const s=function(h){if(!r){r=!0,o();const u=h instanceof Error?h:this.reason;i.abort(u instanceof b?u:new Et(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new b(`timeout of ${t}ms exceeded`,b.ETIMEDOUT))},t);const o=()=>{n&&(a&&clearTimeout(a),a=null,n.forEach(h=>{h.unsubscribe?h.unsubscribe(s):h.removeEventListener("abort",s)}),n=null)};n.forEach(h=>h.addEventListener("abort",s));const{signal:c}=i;return c.unsubscribe=()=>l.asap(o),c}},br=function*(n,t){let e=n.byteLength;if(e<t){yield n;return}let i=0,r;for(;i<e;)r=i+t,yield n.slice(i,r),i=r},Pr=async function*(n,t){for await(const e of vr(n))yield*br(e,t)},vr=async function*(n){if(n[Symbol.asyncIterator]){yield*n;return}const t=n.getReader();try{for(;;){const{done:e,value:i}=await t.read();if(e)break;yield i}}finally{await t.cancel()}},Ve=(n,t,e,i)=>{const r=Pr(n,t);let s=0,a,o=c=>{a||(a=!0,i&&i(c))};return new ReadableStream({async pull(c){try{const{done:h,value:u}=await r.next();if(h){o(),c.close();return}let f=u.byteLength;if(e){let _=s+=f;e(_)}c.enqueue(new Uint8Array(u))}catch(h){throw o(h),h}},cancel(c){return o(c),r.return()}},{highWaterMark:2})},Ue=64*1024,{isFunction:Dt}=l,Er=(({Request:n,Response:t})=>({Request:n,Response:t}))(l.global),{ReadableStream:Le,TextEncoder:Me}=l.global,Fe=(n,...t)=>{try{return!!n(...t)}catch{return!1}},wr=n=>{n=l.merge.call({skipUndefined:!0},Er,n);const{fetch:t,Request:e,Response:i}=n,r=t?Dt(t):typeof fetch=="function",s=Dt(e),a=Dt(i);if(!r)return!1;const o=r&&Dt(Le),c=r&&(typeof Me=="function"?(p=>m=>p.encode(m))(new Me):async p=>new Uint8Array(await new e(p).arrayBuffer())),h=s&&o&&Fe(()=>{let p=!1;const m=new e(N.origin,{body:new Le,method:"POST",get duplex(){return p=!0,"half"}}).headers.has("Content-Type");return p&&!m}),u=a&&o&&Fe(()=>l.isReadableStream(new i("").body)),f={stream:u&&(p=>p.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!f[p]&&(f[p]=(m,g)=>{let w=m&&m[p];if(w)return w.call(m);throw new b(`Response type '${p}' is not supported`,b.ERR_NOT_SUPPORT,g)})});const _=async p=>{if(p==null)return 0;if(l.isBlob(p))return p.size;if(l.isSpecCompliantForm(p))return(await new e(N.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(l.isArrayBufferView(p)||l.isArrayBuffer(p))return p.byteLength;if(l.isURLSearchParams(p)&&(p=p+""),l.isString(p))return(await c(p)).byteLength},y=async(p,m)=>{const g=l.toFiniteNumber(p.getContentLength());return g??_(m)};return async p=>{let{url:m,method:g,data:w,signal:A,cancelToken:T,timeout:O,onDownloadProgress:V,onUploadProgress:P,responseType:D,headers:z,withCredentials:k="same-origin",fetchOptions:st}=ui(p),U=t||fetch;D=D?(D+"").toLowerCase():"text";let at=yr([A,T&&T.toAbortSignal()],O),W=null;const tt=at&&at.unsubscribe&&(()=>{at.unsubscribe()});let ue;try{if(P&&h&&g!=="get"&&g!=="head"&&(ue=await y(z,w))!==0){let J=new e(m,{method:"POST",body:w,duplex:"half"}),ot;if(l.isFormData(w)&&(ot=J.headers.get("content-type"))&&z.setContentType(ot),J.body){const[Kt,wt]=Ne(ue,Ut(Be(P)));w=Ve(J.body,Ue,Kt,wt)}}l.isString(k)||(k=k?"include":"omit");const L=s&&"credentials"in e.prototype,he={...st,signal:at,method:g.toUpperCase(),headers:z.normalize().toJSON(),body:w,duplex:"half",credentials:L?k:void 0};W=s&&new e(m,he);let $=await(s?U(W,st):U(m,he));const le=u&&(D==="stream"||D==="response");if(u&&(V||le&&tt)){const J={};["status","statusText","headers"].forEach(fe=>{J[fe]=$[fe]});const ot=l.toFiniteNumber($.headers.get("content-length")),[Kt,wt]=V&&Ne(ot,Ut(Be(V),!0))||[];$=new i(Ve($.body,Ue,Kt,()=>{wt&&wt(),tt&&tt()}),J)}D=D||"text";let _i=await f[l.findKey(f,D)||"text"]($,p);return!le&&tt&&tt(),await new Promise((J,ot)=>{oi(J,ot,{data:_i,headers:F.from($.headers),status:$.status,statusText:$.statusText,config:p,request:W})})}catch(L){throw tt&&tt(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new b("Network Error",b.ERR_NETWORK,p,W,L&&L.response),{cause:L.cause||L}):b.from(L,L&&L.code,p,W,L&&L.response)}}},Sr=new Map,hi=n=>{let t=n&&n.env||{};const{fetch:e,Request:i,Response:r}=t,s=[i,r,e];let a=s.length,o=a,c,h,u=Sr;for(;o--;)c=s[o],h=u.get(c),h===void 0&&u.set(c,h=o?new Map:wr(t)),u=h;return h};hi();const ce={http:jn,xhr:mr,fetch:{get:hi}};l.forEach(ce,(n,t)=>{if(n){try{Object.defineProperty(n,"name",{value:t})}catch{}Object.defineProperty(n,"adapterName",{value:t})}});const ke=n=>`- ${n}`,Tr=n=>l.isFunction(n)||n===null||n===!1;function Ar(n,t){n=l.isArray(n)?n:[n];const{length:e}=n;let i,r;const s={};for(let a=0;a<e;a++){i=n[a];let o;if(r=i,!Tr(i)&&(r=ce[(o=String(i)).toLowerCase()],r===void 0))throw new b(`Unknown adapter '${o}'`);if(r&&(l.isFunction(r)||(r=r.get(t))))break;s[o||"#"+a]=r}if(!r){const a=Object.entries(s).map(([c,h])=>`adapter ${c} `+(h===!1?"is not supported by the environment":"is not available in the build"));let o=e?a.length>1?`since :
17
- `+a.map(ke).join(`
18
- `):" "+ke(a[0]):"as no adapter specified";throw new b("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r}const li={getAdapter:Ar,adapters:ce};function Jt(n){if(n.cancelToken&&n.cancelToken.throwIfRequested(),n.signal&&n.signal.aborted)throw new Et(null,n)}function je(n){return Jt(n),n.headers=F.from(n.headers),n.data=$t.call(n,n.transformRequest),["post","put","patch"].indexOf(n.method)!==-1&&n.headers.setContentType("application/x-www-form-urlencoded",!1),li.getAdapter(n.adapter||vt.adapter,n)(n).then(function(i){return Jt(n),i.data=$t.call(n,n.transformResponse,i),i.headers=F.from(i.headers),i},function(i){return ai(i)||(Jt(n),i&&i.response&&(i.response.data=$t.call(n,n.transformResponse,i.response),i.response.headers=F.from(i.response.headers))),Promise.reject(i)})}const fi="1.13.6",qt={};["object","boolean","number","function","string","symbol"].forEach((n,t)=>{qt[n]=function(i){return typeof i===n||"a"+(t<1?"n ":" ")+n}});const qe={};qt.transitional=function(t,e,i){function r(s,a){return"[Axios v"+fi+"] Transitional option '"+s+"'"+a+(i?". "+i:"")}return(s,a,o)=>{if(t===!1)throw new b(r(a," has been removed"+(e?" in "+e:"")),b.ERR_DEPRECATED);return e&&!qe[a]&&(qe[a]=!0,console.warn(r(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,a,o):!0}};qt.spelling=function(t){return(e,i)=>(console.warn(`${i} is likely a misspelling of ${t}`),!0)};function Cr(n,t,e){if(typeof n!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const i=Object.keys(n);let r=i.length;for(;r-- >0;){const s=i[r],a=t[s];if(a){const o=n[s],c=o===void 0||a(o,s,n);if(c!==!0)throw new b("option "+s+" must be "+c,b.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new b("Unknown option "+s,b.ERR_BAD_OPTION)}}const xt={assertOptions:Cr,validators:qt},j=xt.validators;let nt=class{constructor(t){this.defaults=t||{},this.interceptors={request:new De,response:new De}}async request(t,e){try{return await this._request(t,e)}catch(i){if(i instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const s=r.stack?r.stack.replace(/^.+\n/,""):"";try{i.stack?s&&!String(i.stack).endsWith(s.replace(/^.+\n.+\n/,""))&&(i.stack+=`
19
- `+s):i.stack=s}catch{}}throw i}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=rt(this.defaults,e);const{transitional:i,paramsSerializer:r,headers:s}=e;i!==void 0&&xt.assertOptions(i,{silentJSONParsing:j.transitional(j.boolean),forcedJSONParsing:j.transitional(j.boolean),clarifyTimeoutError:j.transitional(j.boolean),legacyInterceptorReqResOrdering:j.transitional(j.boolean)},!1),r!=null&&(l.isFunction(r)?e.paramsSerializer={serialize:r}:xt.assertOptions(r,{encode:j.function,serialize:j.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),xt.assertOptions(e,{baseUrl:j.spelling("baseURL"),withXsrfToken:j.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&l.merge(s.common,s[e.method]);s&&l.forEach(["delete","get","head","post","put","patch","common"],p=>{delete s[p]}),e.headers=F.concat(a,s);const o=[];let c=!0;this.interceptors.request.forEach(function(m){if(typeof m.runWhen=="function"&&m.runWhen(e)===!1)return;c=c&&m.synchronous;const g=e.transitional||ae;g&&g.legacyInterceptorReqResOrdering?o.unshift(m.fulfilled,m.rejected):o.push(m.fulfilled,m.rejected)});const h=[];this.interceptors.response.forEach(function(m){h.push(m.fulfilled,m.rejected)});let u,f=0,_;if(!c){const p=[je.bind(this),void 0];for(p.unshift(...o),p.push(...h),_=p.length,u=Promise.resolve(e);f<_;)u=u.then(p[f++],p[f++]);return u}_=o.length;let y=e;for(;f<_;){const p=o[f++],m=o[f++];try{y=p(y)}catch(g){m.call(this,g);break}}try{u=je.call(this,y)}catch(p){return Promise.reject(p)}for(f=0,_=h.length;f<_;)u=u.then(h[f++],h[f++]);return u}getUri(t){t=rt(this.defaults,t);const e=ci(t.baseURL,t.url,t.allowAbsoluteUrls);return ri(e,t.params,t.paramsSerializer)}};l.forEach(["delete","get","head","options"],function(t){nt.prototype[t]=function(e,i){return this.request(rt(i||{},{method:t,url:e,data:(i||{}).data}))}});l.forEach(["post","put","patch"],function(t){function e(i){return function(s,a,o){return this.request(rt(o||{},{method:t,headers:i?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}nt.prototype[t]=e(),nt.prototype[t+"Form"]=e(!0)});let Rr=class pi{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});const i=this;this.promise.then(r=>{if(!i._listeners)return;let s=i._listeners.length;for(;s-- >0;)i._listeners[s](r);i._listeners=null}),this.promise.then=r=>{let s;const a=new Promise(o=>{i.subscribe(o),s=o}).then(r);return a.cancel=function(){i.unsubscribe(s)},a},t(function(s,a,o){i.reason||(i.reason=new Et(s,a,o),e(i.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=i=>{t.abort(i)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new pi(function(r){t=r}),cancel:t}}};function Or(n){return function(e){return n.apply(null,e)}}function Dr(n){return l.isObject(n)&&n.isAxiosError===!0}const ie={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(ie).forEach(([n,t])=>{ie[t]=n});function di(n){const t=new nt(n),e=ze(nt.prototype.request,t);return l.extend(e,nt.prototype,t,{allOwnKeys:!0}),l.extend(e,t,null,{allOwnKeys:!0}),e.create=function(r){return di(rt(n,r))},e}const S=di(vt);S.Axios=nt;S.CanceledError=Et;S.CancelToken=Rr;S.isCancel=ai;S.VERSION=fi;S.toFormData=jt;S.AxiosError=b;S.Cancel=S.CanceledError;S.all=function(t){return Promise.all(t)};S.spread=Or;S.isAxiosError=Dr;S.mergeConfig=rt;S.AxiosHeaders=F;S.formToJSON=n=>si(l.isHTMLForm(n)?new FormData(n):n);S.getAdapter=li.getAdapter;S.HttpStatusCode=ie;S.default=S;const{Axios:Vr,AxiosError:Ur,CanceledError:Lr,isCancel:Mr,CancelToken:Fr,VERSION:kr,all:jr,Cancel:qr,isAxiosError:Kr,spread:Hr,toFormData:Wr,AxiosHeaders:Xr,HttpStatusCode:zr,formToJSON:Gr,getAdapter:$r,mergeConfig:Jr}=S;class Ir extends B.Kernel{__pinPad__={buffer:null,about:{EMV:null,model:null,serial:null,brand:null,appVersion:null,printer:null,hasCashback:!1,supportInjection:!1,supportSign:!1,supportContactlessCollisionCard:!1,supportContactless:!1,supportDUKPT:"",injectedValues:!1,pp:null},config:{defaultEnvironment:"production",environment:"production",currency:"MXN",currencyCode:"0484",timeoutPinPad:"100",signSupport:"1",CTLSSupport:"1",userTRX:"userPinpadWeb",tp_operation:"29",requireCVVAmex:"1",forceOnline:"00",emvCard:"0",validateQPS:"1",username:null,password:null,country:null,idBranch:null,idCompany:null,latitude:null,longitude:null,publicKeyRSA:null,publicIP:null,internal:{stTokenization:!1,qpsDomestic:"",qpsInternational:"",cvmlVMCDomestic:"",cvmlVMCInternational:"",cvmlAmex:"",translimitCTLSVMC:"",translimitCTLSAmex:"",emv:{}},terminal:{},loginResponse:null,otherLogin:{},RC4Key:"KEY CREDIT CARD KEY",read:{EMV:"",PIN:"",POSEM:"",AppId:"",AppIdLabel:"",Arqc:"",Chip:"",ChipName:"",ChipNameEnc:"",ReadCTLS:"",NB_Data:"",NB_ksn:"",Tags:"",Type:""},tokenizeTRX:!1},constants:{appVersion:"1.0.16",appName:"pinpapWebApp ",STX:"",ETX:"",FS:"",getNULL:"\0",appChannel:"3",typeChannel:"11",urls:{development:"https://fcdev.mitec.com.mx",qa:"https://fcqa.mitec.com.mx",production:"https://m.mit.com.mx",productionAlternative:"https://m2.mit.com.mx"},uris:{login:"/pinpadWeb/login",RSAKey:"/pinpadWeb/getDataCrypt",merchant:"/pinpadWeb/getAfiliaciones",consult:"/pinpadWeb/queryTrx",keysDUKPT:"/pinpadWeb/getKeysDUKPT",reverse:"/pinpadWeb/executeBackSale",rePrint:"/pinpadWeb/reprint",checkInMoto:"/pinpadWeb/checkin",checkOutMoto:"/pinpadWeb/checkout",reAuthorizationMoto:"/pinpadWeb/reAuthorization",cancellation:"/pinpadWeb/executeVoid",sale:"/pinpadWeb/executeSale"}},operation:{amount:"0",reference:null,folio:null,authorization:null,errors:0,last_error:null,commerceVoucher:"",clientVoucher:"",consultDate:null,ignore:{responseGlobal:{},counter:!1,counterSale:!1,isError92TRX:!1,C93Global:!1,error:""},finalResult:{},moto:{ccType:"",ccName:"",ccNumber:"",ccExpMonth:"",ccExpYear:"",ccCvvCsc:"",txRoom:""},bin:"",bin8:"",hasQPS:!1,onlyMerchant:"",merchant:null,typeOperation:"29",typeResponse:"",responseMit:{},applyReverse:!1},finishCommand:{A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:""},waiting:{statusAboutWaiting:null,statusInjectWaiting:null,statusReadCardWaiting:null,statusSecondGenerateWaiting:null,statusinitDUKPTWaiting:null,statuswritingDUKPTWaiting:null}};constructor({filters:t=null,config_port:e={baudRate:19200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:i=1,device_listen_on_channel:r=1,username:s=null,password:a=null,environment:o="production",socket:c=!1}={filters:null,config_port:{baudRate:19200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,username:null,password:null,environment:"production",socket:!1}){if(super({filters:t,config_port:e,no_device:i,device_listen_on_channel:r,socket:c}),this.__internal__.device.type="pinpad",!B.supportCrypto())throw new Error("Crypto not supported in this browser");if(pe.Devices.getCustom(this.typeDevice,i))throw new Error(`Device ${this.typeDevice} ${i} already exists`);this.__internal__.time.response_connection=3e3,this.__internal__.time.response_general=5e3,this.__internal__.serial.delay_first_connection=1e3,this.environment=o,s&&(this.username=s),a&&(this.password=a),this.#A(),pe.Devices.add(this)}#A(){const t=["pp:processing-card","pp:read-card","pp:error","pp:print","pp:merchant-moto","pp:dukpt","pp:finish-emv","pp:response"];for(const e of t)this.serialRegisterAvailableListener(e)}async timeout(t,e){await super.timeout(t,e),this.__pinPad__.waiting.statusAboutWaiting&&e==="about"?this.__pinPad__.waiting.statusAboutWaiting="rejected":this.__pinPad__.waiting.statusInjectWaiting&&e==="inject"?this.__pinPad__.waiting.statusInjectWaiting="rejected":this.__pinPad__.waiting.statusinitDUKPTWaiting&&e==="init-dukpt"?this.__pinPad__.waiting.statusinitDUKPTWaiting="rejected":this.__pinPad__.waiting.statuswritingDUKPTWaiting&&e==="dukpt"?this.__pinPad__.waiting.statuswritingDUKPTWaiting="rejected":this.__pinPad__.waiting.statusReadCardWaiting&&e==="read-card"?this.__pinPad__.waiting.statusReadCardWaiting="rejected":this.__pinPad__.waiting.statusSecondGenerateWaiting&&e==="second-generate"&&(this.__pinPad__.waiting.statusSecondGenerateWaiting="rejected")}#C(t){const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX,r=this.__pinPad__.constants.FS,s=this.__pinPad__.constants.getNULL;t=t.replace(new RegExp(e,"g"),"");const a=t.split(i);t=a[0];const o=t.split(r);o.push(...a[1].split(r));const c={};return o.map((h,u)=>{const f=u>0?h.substring(0,1):"A",_=u>0?h.substring(1):h;return{[f]:_.replace(new RegExp(s,"g"),"")}}).forEach(h=>Object.assign(c,h)),c}#f(t,e){const i=this.__pinPad__.constants.ETX,r=e.substring(e.indexOf("D")+2,e.indexOf("E"));let s=0;const a=e.indexOf("N")>0,o=e.substring(e.indexOf("A00")+3,e.indexOf("B"));if(o&&o!=="undefined"&&o.toUpperCase()==="VERIFONE"){const h=r.replace("MITP_1.00.","").replace("MITP_01.00.","").replace("MITD_1.00.","").replace("MITD_01.00.","");s=parseInt(h),s>=15&&(this.__pinPad__.about.hasCashback=!0)}this.__pinPad__.about.supportInjection=a,e.indexOf("M")>0?(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf("M"))=="1",this.__pinPad__.about.supportInjection?this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf("N"))==="1":(this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf(i))=="1",this.__pinPad__.about.supportContactless=!0)):(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf(i))=="1",this.__pinPad__.about.supportContactless=!1),this.__pinPad__.about.supportDUKPT=e.substring(e.indexOf("J")+2,e.indexOf("K")),this.__pinPad__.about.EMV=e.substring(e.indexOf("E")+2,e.indexOf("F")),this.__pinPad__.about.serial=e.substring(e.indexOf("C")+2,e.indexOf("D")),this.__pinPad__.about.printer=e.substring(e.indexOf("F")+2,e.indexOf("G")),this.__pinPad__.about.model=e.substring(e.indexOf("B")+2,e.indexOf("C")),this.__pinPad__.about.brand=o,this.__pinPad__.about.appVersion=r;const c=e.substring(e.indexOf("K")+2,e.indexOf("L"))=="1";this.__pinPad__.about.pp={brand:o,appVersion:r,versionInt:s,hasCashback:this.__pinPad__.about.hasCashback,supportInjection:this.__pinPad__.about.supportInjection,supportSign:this.__pinPad__.about.supportSign,supportContactlessCollisionCard:this.__pinPad__.about.supportContactlessCollisionCard,supportContactless:this.__pinPad__.about.supportContactless,supportDUKPT:this.__pinPad__.about.supportDUKPT=="1",hasDUKPTKeys:c,EMV:this.__pinPad__.about.EMV,serial:this.__pinPad__.about.serial,printer:this.__pinPad__.about.printer,model:this.__pinPad__.about.model},this.__pinPad__.waiting.statusAboutWaiting&&(this.__pinPad__.waiting.statusAboutWaiting="resolved")}#R(){this.__pinPad__.waiting.statusInjectWaiting="resolved"}#O(t,e){e=e.replace("010P93A00B01t036P81AACERQUE, INSERTE CHIP O DESLICE*",""),this.__pinPad__.config.terminal={nb_kcv:e.substring(e.indexOf("E")+2,e.indexOf("F")),nb_marca_terminal:e.substring(e.indexOf("P91A")+4,e.indexOf("B")),nb_modelo_terminal:e.substring(e.indexOf("B")+2,e.indexOf("C")),nb_serie_lector:e.substring(e.indexOf("C")+2,e.indexOf("D")),nb_tk:e.substring(e.indexOf("F")+2,e.length-2),nb_version_terminal:e.substring(e.indexOf("D")+2,e.indexOf("E"))},this.__pinPad__.waiting.statusinitDUKPTWaiting="resolved"}#D(){this.__pinPad__.waiting.statuswritingDUKPTWaiting="resolved"}#I(t,e){const i=this.__pinPad__.about?.brand?.toLowerCase(),r=this.__pinPad__.about?.model?.toLowerCase(),s=i==="ingenico"&&r==="ipp320"?500:350;if(e.length<s){e=e.replace("006P93A00.","").replace("006P93A00,",""),e.includes("E93")?this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E93")+3,e.indexOf("E93")+6):e.includes("E71")&&(this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E71")+3,e.indexOf("E71")+6)),this.__pinPad__.operation.ignore.error!==""&&e.indexOf("OPERACION CANCELADA")===-1&&e.indexOf("TIEMPO EXCEDIDO")===-1&&this.__pinPad__.operation.ignore.error.length===3&&(this.__pinPad__.operation.last_error=this.#T(this.__pinPad__.operation.ignore.error),this.__pinPad__.waiting.statusReadCardWaiting="rejected");return}if(e.includes("M1")||e.includes("M0")||e.includes("M1")||e.includes("N1")||e.includes("N1")||e.includes("P93A022")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A800")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A022")&&e.length>=406&&r==="vx820"||e.includes("P93A022")&&e.length>=406&&r==="vx520"||e.includes("P93A800")&&e.length>=406&&r==="vx520"||e.includes("P93A800")&&e.length>=406&&r==="vx820"||e.includes("P93A022")&&e.length>=406&&r==="p400"||e.includes("P93A800")&&e.length>=406&&r==="p400"||e.includes("P93A022")&&e.length>=406&&r==="v205c"||e.includes("P93A800")&&e.length>=406&&r==="v205c"||e.includes("P93A022")&&e.length>=406&&r==="move2500"||e.includes("P93A800")&&e.length>=406&&r==="move2500"||e.includes("P93A022")&&e.length>=406&&r==="lane3000"||e.includes("P93A800")&&e.length>=406&&r==="lane3000"){let a=e;i==="verifone"&&(a=e.replace("006P93A00.","").substring(e.indexOf("P93A"),e.indexOf("P93A")+7)),e.includes("P81APROCESANDO, NO RETIRE TARJETA")||e.includes("P81APROCESANDO TARJETA")||a.includes("P93A022")||a.includes("P81AINSERTE CHIP O DESLICE TARJETA")||a.includes("ACERQUE, INSERTE CHIP O DESLICE")||a.includes("P81AACERQUE, INSERTE CHIP O DESLICE TARJETA")?this.dispatch("pp:processing-card",{waiting:!0}):e.length>s&&this.#B(e)}}#N(t,e){const i=this.__pinPad__.constants.ETX;let r=e.replace("023P81AFAVOR RETIRAR TARJ.","").replace("020P81A DECLINADA EMV ","").replace("020P81A DECLINADA EMV ","");r=r.substring(r.indexOf("B")+2,r.indexOf(i)),r.includes("006E93A16")&&(r="01"),this.__pinPad__.operation.applyReverse=r==="01"&&this.__pinPad__.operation.responseMit._approved&&this.__pinPad__.config.otherLogin.executeReverse==="1",this.__pinPad__.waiting.statusSecondGenerateWaiting="resolved"}#B(t){const e=this.__pinPad__.constants.ETX,i=this.__pinPad__.about?.brand?.toLowerCase();let r,s,a,o,c;i==="verifone"?t=t.replace("006P93A00.","").replace("009P93A00","").replace("010P93A00B01v",""):t=t.replace("006P93A00,",""),this.__pinPad__.config.read.POSEM=t.substring(t.indexOf("P93A")+4,t.indexOf("B"));const h=this.__pinPad__.config.read.POSEM;if(h==="051"||h==="071"){if(this.__pinPad__.config.read.Chip="1",this.__pinPad__.config.read.PIN=t.substring(t.indexOf("C")+2,t.indexOf("D")),this.__pinPad__.config.read.AppId=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Arqc=t.substring(t.indexOf("F")+2,t.indexOf("G")),t.includes("O")){const u=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=u.substring(u.indexOf("M")+2,u.indexOf("N")),this.__pinPad__.operation.hasQPS=u.substring(u.indexOf("N")+2,u.indexOf("O"))==="1",this.__pinPad__.operation.bin8=u.substring(u.indexOf("O")+2,u.indexOf(e))}else if(t.includes("N")){const u=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=u.substring(u.indexOf("M")+2,u.indexOf("N")),this.__pinPad__.operation.hasQPS=u.substring(u.indexOf("N")+2,u.indexOf(e))==="1"}else{const u=t.substring(t.indexOf("P93A"),t.indexOf("M")+5);this.__pinPad__.config.read.ReadCTLS=u.substring(u.indexOf("M")+2,u.indexOf(e)),this.__pinPad__.operation.hasQPS=!1}this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),this.__pinPad__.config.read.NB_ksn=t.substring(t.indexOf("K")+2,t.indexOf("M")),this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("D")+2,t.indexOf("E")),s=t.substring(t.indexOf("I")+2,t.indexOf("J")),a=t.substring(t.indexOf("E")+2,t.indexOf("F")),this.__pinPad__.config.read.ChipName=a,r=t.substring(t.indexOf("J")+2,t.indexOf("K"))}else{let u;if(this.__pinPad__.config.read.Chip="0",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ReadCTLS="0",this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),h==="022")if(t.includes("O")){const f=t.substring(t.indexOf("P93A"));this.__pinPad__.operation.bin8=f.substring(f.indexOf("O")+2,f.indexOf(e)),u=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),u=u.substring(u.indexOf("I")+2,u.lastIndexOf(""))}else u=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),u=u.substring(u.indexOf("I")+2,u.indexOf(e));else u=t.substring(t.indexOf("P93A800"),t.indexOf("I")+23),u=u.substring(u.indexOf("I")+2,u.indexOf(e));this.__pinPad__.config.read.NB_ksn=u,this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("B")+2,t.indexOf("C")),s=t.substring(t.indexOf("F")+2,t.indexOf("G")),r=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.about.model?.toLowerCase()==="vx520"?(a=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=a):(a=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=a)}r.includes("/")&&(r=r.replace("/","")),r.toString().length===4?(c=r.toString().substring(0,2),o=r.toString().substring(2)):(c="",o=""),this.__pinPad__.config.read.Chip==="1"?(this.__pinPad__.config.read.EMV="3",this.__pinPad__.config.read.ChipNameEnc="1"):(this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.config.read.EMV="2"),this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("american")||this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("amex")?this.__pinPad__.config.read.Type="AMEX":this.__pinPad__.config.read.Type="V/MC",this.__pinPad__.operation.bin=s,s.length>6&&(this.__pinPad__.operation.bin=s.substring(0,6)),this.__pinPad__.waiting.statusReadCardWaiting="resolved",this.dispatch("pp:read-card",{ERROR:"",maskPan:s,name:a,month:c,year:o})}#x(t,e){e.length>10&&e.includes("E93A10")&&(this.__pinPad__.waiting.statusReadCardWaiting==="pending"&&(this.__pinPad__.waiting.statusReadCardWaiting="rejected"),this.dispatch("pp:error",{message:"Operation cancelled by user."}))}#V(t,e){if(this.__pinPad__.about.model?.toLowerCase()==="vx520"){if(e.length>11)if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(()=>{this.print("client").then(()=>{}).catch(i=>{console.error(i)})},1e3):this.dispatch("pp:print",{type:"success"});else{const i=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",i)}}else if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(()=>{this.print("client").then(()=>{}).catch(i=>{console.error(i)})},1e3):this.dispatch("pp:print",{type:"success"});else{const i=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",i)}}#U(t,e){console.log(t,e)}#L(t,e){console.log(t,e)}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:this.lastAction,no_code:0,parsed:null},i=this.parseHexToUint8(t),r=this.parseUint8ArrayToString(i),s=this.#C(r);switch(this.__pinPad__.buffer=r,e.parsed=s,e.code=r,e.request){case"connect":e.name="connected",e.description="Connection established",e.no_code=100,this.#f(s,r);break;case"about":e.name="About PinPad",e.description="Response of about",e.no_code=101,this.#f(s,r);break;case"inject":e.name="Inject",e.description="Response of inject values",e.no_code=102,this.#R();break;case"init-dukpt":e.name="Init DUKPT",e.description="Response of init DUKPT",e.no_code=103,this.#O(s,r);break;case"dukpt":e.name="Write DUKPT",e.description="Response of write DUKPT",e.no_code=104,this.#D();break;case"read-card":e.name="read card",e.description="response of read card",e.no_code=105,this.#I(s,r);break;case"second-generate":e.name="second generate",e.description="response of second generate",e.no_code=106,this.#N(s,r);break;case"cancel":e.name="cancel pinpad",e.description="response of cancel",e.no_code=107;break;case"print":this.#V(s,r),e.name="print voucher",e.description="response of print",e.no_code=108;break;case"cancel-read-card":this.#x(s,r),e.name="cancel read card",e.description="response of cancel read card",e.no_code=109;break;case"code93":this.#U(s,r),e.name="code 93",e.description="response of code 93",e.no_code=110;break;case"finish-emv-end":this.#L(s,r),e.name="Finish EMV End",e.description="response of finish EMV End",e.no_code=111;break;default:e.name="unknown",e.description="Unknown command",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(){let i="C56AABOUT";i=""+i.length.toString().padStart(3,"0")+i+"";let r=0;for(let a=0;a<i.length;a++)r^=i.charCodeAt(a);i=i+String.fromCharCode(r);const s=this.parseStringToBytes(i,"");return this.add0x(s)}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}set username(t){this.__pinPad__.config.username=t}get username(){return this.__pinPad__.config.username}set password(t){if(typeof t!="string")throw new Error("Invalid password");this.__pinPad__.config.password=t.toUpperCase()}get password(){return this.__pinPad__.config.password}set amount(t){if(t=parseFloat(t),isNaN(t)||t<=0)throw new Error("Invalid amount");this.__pinPad__.operation.amount=t.toFixed(2).toString()}get amount(){return parseFloat(this.__pinPad__.operation.amount)||0}set reference(t){if(!this.#g(t.trim()))throw new Error("Invalid reference");this.__pinPad__.operation.reference=t.trim().toString().replaceAll(" ","").toUpperCase()}get reference(){return this.__pinPad__.operation.reference||""}get url(){const t=this.environment;return this.__pinPad__.constants.urls[t]}get version(){return{name:this.__pinPad__.constants.appName,version:this.__pinPad__.constants.appVersion,environment:this.environment,type:this.typeDevice}}set environment(t){const e=["development","qa","production","productionAlternative"];if(typeof t!="string"||!e.includes(t.toLowerCase()))throw new Error("The environment must be a string, in: "+e.join(", "));this.__pinPad__.config.defaultEnvironment=t.toLowerCase(),this.__pinPad__.config.environment=t.toLowerCase()}get defaultEnvironment(){return this.__pinPad__.config.defaultEnvironment}get environment(){return this.__pinPad__.config.environment}get latitudeLongitude(){return{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude}}set timeoutPinPad(t){if(t=parseInt(t),isNaN(t)||t<=10||t>=300)throw new Error("Invalid timeout please use a number between 10 and 300 seconds");this.__pinPad__.config.timeoutPinPad=t.toString()}get timeoutPinPad(){return parseInt(this.__pinPad__.config.timeoutPinPad)}#s(t,e){const i=new Qi;return i.setPublicKey(t),i.encrypt(e)}#a(t){const e="0123456789ABCDEF";let i="";for(let r=0;r<t;r++){const s=Math.floor(Math.random()*e.length);i+=e.substring(s,s+1)}return i}#M(t){const e="0123456789abcdef",i=[],r=[];for(let s=0;s<256;s++)i[s]=e.charAt(s>>4)+e.charAt(s&15);for(let s=0;s<t.length;s++)r[s]=i[t.charCodeAt(s)];return r.join("")}async#o(t,e){const i=t.match(/.{1,2}/g)||[],r=new Uint8Array(i.map(_=>parseInt(_,16))),s=crypto.getRandomValues(new Uint8Array(16)),o=new TextEncoder().encode(e),c=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),h=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},c,o),u=btoa(String.fromCharCode(...s)),f=btoa(String.fromCharCode(...new Uint8Array(h)));return u+f}#F(t,e,i=!1){const r=[];for(let h=0;h<256;h++)r[h]=h;let s=0;for(let h=0;h<256;h++)s=(s+r[h]+t.charCodeAt(h%t.length))%256,[r[h],r[s]]=[r[s],r[h]];let a=0,o=0,c="";for(const h of e){a=(a+1)%256,o=(o+r[a])%256,[r[a],r[o]]=[r[o],r[a]];const u=r[(r[a]+r[o])%256];c+=String.fromCharCode(h.charCodeAt(0)^u)}return i?this.#M(c).toUpperCase():c}#n(t,e){return this.#F(t,this.hexToAscii(e))}#k(t){return t.replaceAll("Á","A"),t.replaceAll("É","E"),t.replaceAll("Í","I"),t.replaceAll("Ó","O"),t.replaceAll("Ú","U"),t.replaceAll("á","a"),t.replaceAll("é","e"),t.replaceAll("í","i"),t.replaceAll("ó","o"),t.replaceAll("ú","u"),t.replaceAll("ñ","n"),t.replaceAll("Ñ","N"),t.replaceAll('Electr?a"',"Electronica"),t}#t(t,e,i){if(t=t.replace("@cnb logo_cpagos",e),t=t.replace("@cnn ver_app",i),t=t.replace(/@/g," @"),t=t.replace(/ {2}@/g," @"),t=t.replace(/ {3}@/g," @"),t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t.includes("@lsn POR ESTE PAGARE ME OBLIGO INCONDI")){const r=t.indexOf("@lsn POR ESTE PAGARE ME OBLIGO INCONDI");t=t.substring(0,r)}return t.trim()+"@br @br @br @br @br"}#j(t,e){const i="@logo3 @br",r="@cnn "+e;return t.includes("@cnb Santander")?(t=t.replace("@cnb Santander","@logo1@br"),this.#t(t,i,r)):t.includes("@cnb American Express")?(t=t.replace("@cnb American Express","@logo2@br"),this.#t(t,i,r)):t.includes("@cnb HSBC")?(t=t.replace("@cnb HSBC","@logo7@br"),this.#t(t,i,r)):t.includes("@cnb IXE")?(t=t.replace("@cnb IXE","@logo11@br"),this.#t(t,i,r)):t.includes("@cnb MULTIVA")?(t=t.replace("@cnb MULTIVA","@logo15@br"),this.#t(t,i,r)):t.includes("@cnb Multiva")?(t=t.replace("@cnb Multiva","@logo15@br"),this.#t(t,i,r)):t.includes("@cnb SCOTIA BANK")?(t=t.replace("@cnb SCOTIA BANK","@logo16@br"),this.#t(t,i,r)):t.includes("@cnb SCOTIABANK")?(t=t.replace("@cnb SCOTIABANK","@logo16@br"),this.#t(t,i,r)):t.includes("@cnb BANCOMER")?(t=t.replace("@cnb BANCOMER","@logo17@br"),this.#t(t,i,r)):t.includes("@cnb Bancomer")?(t=t.replace("@cnb Bancomer","@logo17@br"),this.#t(t,i,r)):t.includes("@cnb BBVA")?(t=t.replace("@cnb BBVA","@logo17@br"),this.#t(t,i,r)):t.includes("@cnb BANORTE")?(t=t.replace("@cnb BANORTE","@logo18@br"),this.#t(t,i,r)):t.includes("@cnb Banorte")?(t=t.replace("@cnb Banorte","@logo18@br"),this.#t(t,i,r)):t.includes("@cnb BANREGIO")?(t=t.replace("@cnb BANREGIO","@logo19@br"),this.#t(t,i,r)):t.includes("@cnb Banregio")?(t=t.replace("@cnb Banregio","@logo19@br"),this.#t(t,i,r)):t.includes("@cnb GETNET")?(t=t.replace("@cnb GETNET","@logo20@br"),this.#t(t,i,r)):t.includes("@cnb GetNET")?(t=t.replace("@cnb GetNET","@logo20@br"),this.#t(t,i,r)):this.#t(t,i,r)}async#q(t=!1){if(this.#H(),this.__pinPad__.config.loginResponse&&!t)return await this.#p();const e=this.url+this.__pinPad__.constants.uris.login,i={usuario:this.username,password:this.password,crypto:"",version:this.__pinPad__.constants.appVersion,serieLector:"",canal:this.__pinPad__.constants.appChannel};if(await this.#c(),this.#d())throw new Error("Empty RSA Key");const r=this.#a(32),s=this.#s(this.__pinPad__.config.publicKeyRSA||"",r),a=await this.#o(r,JSON.stringify(i)),o=await S.post(e,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0",data:s||""}}).catch(u=>{throw new Error(`Error in request, verify internet connection: ${u.response?.status} ${u.message}`)}),c=this.#b(JSON.stringify(o.data));let h=c;if(typeof c=="string"&&(h=JSON.parse(c)),!h)throw new Error("Invalid response JSON");if(h.RESPUESTA==="error")throw new Error(h);return this.__pinPad__.config.loginResponse=h,localStorage.setItem("ppLoginResponse",JSON.stringify({timestamp:new Date().getTime(),data:h})),await this.#p()}async#p(){await this.#G();try{await this.getPosition()}catch(t){console.log("Error getting position",t)}return this.__pinPad__.config.otherLogin={},this.#K(this.__pinPad__.config.loginResponse),this.__pinPad__.config.otherLogin}#K(t){let e="",i="";t.xml?.ventaspropias?.merchant_currencyb&&(e=t.xml.ventaspropias.merchant_currencyb),t.xml?.ventaspropias?.merchant_currencym&&(i=t.xml.ventaspropias.merchant_currencym);let r=t.xml?.emvReverso;r||(r="0");const s=t.xml?.st_tokenizacion;!s||s==="false"||s==="0"?this.__pinPad__.config.internal.stTokenization=!1:this.__pinPad__.config.internal.stTokenization&&(this.__pinPad__.config.internal.stTokenization=!0),this.__pinPad__.config.internal.emv=t.xml.importesPGS,this.__pinPad__.config.internal.qpsDomestic=this.__pinPad__.config.internal.emv.qps_dom,this.__pinPad__.config.internal.qpsInternational=this.__pinPad__.config.internal.emv.qps_il,this.__pinPad__.config.internal.cvmlVMCDomestic=this.__pinPad__.config.internal.emv.cvml_vm_dom,this.__pinPad__.config.internal.cvmlVMCInternational=this.__pinPad__.config.internal.emv.cvml_vm_il,this.__pinPad__.config.internal.cvmlAmex=this.__pinPad__.config.internal.emv.cvml_amex,this.__pinPad__.config.internal.translimitCTLSVMC=this.__pinPad__.config.internal.emv.tl_mc,this.__pinPad__.config.internal.translimitCTLSAmex=this.__pinPad__.config.internal.emv.tl_amex,this.__pinPad__.config.country=t.country.toUpperCase(),this.__pinPad__.config.idBranch=t.id_branch.toUpperCase(),this.__pinPad__.config.idCompany=t.id_company.toUpperCase(),this.__pinPad__.config.otherLogin={bsUser:t.user,nbUser:t.nb_user,bsCompany:t.id_company,nbCompany:t.nb_company,nbStreetCompany:t.nb_companystreet,bsBranch:t.id_branch,nbBranch:t.nb_branch,bsCountry:t.country,coins:e,coinsMOTO:i,executeReverse:r}}#H(){const t=localStorage.getItem("ppLoginResponse");let e=null;t&&(e=JSON.parse(t),this.__pinPad__.config.loginResponse||(this.__pinPad__.config.loginResponse=e?.data),new Date().getTime()-e?.timestamp>=864e5&&(this.__pinPad__.config.loginResponse=null))}async login({force:t=!1}={}){return await this.#q(t)}async#W(){const t=this.url+this.__pinPad__.constants.uris.RSAKey,e=await S.get(t).catch(r=>{throw new Error(`Error in request, verify internet connection: ${r.response.status} ${r.message}`)});if(!e)return"";const i=e.headers;if(!i)return"";if(i.get("content-type").indexOf("application/json")===-1)throw new Error("Fail to fetch RSA public key");return this.__pinPad__.config.publicKeyRSA=e.data.key_public,localStorage.setItem("ppRSAKey",JSON.stringify({timestamp:new Date().getTime(),data:e.data.key_public})),this.__pinPad__.config.publicKeyRSA}clearSession(){localStorage.removeItem("ppLoginResponse"),localStorage.removeItem("ppRSAKey"),localStorage.removeItem("ppPublicIP")}#d(){const t=localStorage.getItem("ppRSAKey");if(!t)return!0;const e=JSON.parse(t);return!e.data||(this.__pinPad__.config.publicKeyRSA=e.data,new Date().getTime()-e.timestamp>=864e5)?!0:!this.__pinPad__.config.publicKeyRSA}async#_(){return this.#d()?await this.#W():this.__pinPad__.config.publicKeyRSA}async#c(){if(!await this.#_())throw new Error("RSA public key is empty")}#g(t){return/^[A-Z-a-z0-9\s]+$/g.test(t)}#X(t){if(B.isEmpty(t))return!0;const e=/^[A-Z-a-z0-9\s]+$/g.test(t)===!0;if(!e)throw new Error("Invalid reference");return e}#e(t){return t.length.toString().padStart(3,"0")}#i(t){let e=0;for(let i=0;i<t.length;i++)e^=t.charCodeAt(i);return String.fromCharCode(e)}#h(t,e=0){return t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)?0 .toFixed(e):t.toFixed(e).replace(/,/g,"")}#m(t){return t=parseFloat(t.toString()),!(isNaN(t)||t<0)}async#u(t){for(const e in t)if(typeof t[e]>"u"||t[e]===null||t[e]==="")throw new Error("Object incomplete to process");return t}#y(t){if(!t||isNaN(parseInt(t))||t.toString().length!==9)throw new Error("Number of operation must be number of 9 digits");return t}#b(t){if(typeof t!="string")throw new Error("Invalid string");return!t||/<html(?:\s+lang=["'][^"']*["'])?>/i.test(t)||(t=t.replace(/aaa/g,"á"),t=t.replace(/eee/g,"é"),t=t.replace(/iii/g,"í"),t=t.replace(/ooo/g,"ó"),t=t.replace(/uuu/g,"ú"),t=t.replace(/NNN/g,"Ñ"),t=t.replace(/nnn/g,"ñ"),t=t.replace(/á/g,"á")),t}async#z(){const t=this.__pinPad__.constants.STX,e=this.__pinPad__.constants.ETX;let i="C55ACANCEL";i=t+this.#e(i)+i+e,i=i+this.#i(i);const r=this.parseStringToBytes(i,"");await this.appendToQueue(r,"cancel")}#P(){const t=new Date,e=t.getDate().toString().padStart(2,"0"),i=(t.getMonth()+1).toString().padStart(2,"0"),r=t.getFullYear().toString().substring(2);return e+i+r}#v(){const t=new Date,e=t.getHours().toString().padStart(2,"0"),i=t.getMinutes().toString().padStart(2,"0");return e+i}async checkPositionPermission(){if(!B.supportGeolocation())throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.permissions.query({name:"geolocation"}).then(i=>{i.state==="granted"?t(!0):t(!1)}).catch(()=>e(!1))})}async getPosition(){return this.__pinPad__.config.latitude&&this.__pinPad__.config.longitude?this.latitudeLongitude:(this.__pinPad__.config.latitude=null,this.__pinPad__.config.longitude=null,B.supportGeolocation()?new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{this.__pinPad__.config.latitude=e.coords.latitude,this.__pinPad__.config.longitude=e.coords.longitude,t(this.latitudeLongitude)},()=>{t(this.latitudeLongitude)})}):this.latitudeLongitude)}async#G(){const t=localStorage.getItem("ppPublicIP");if(t){const s=JSON.parse(t);this.__pinPad__.config.publicIP=s.data,new Date().getTime()-s.timestamp>=864e5&&(this.__pinPad__.config.publicIP=null)}if(this.__pinPad__.config.publicIP)return this.__pinPad__.config.publicIP;this.__pinPad__.config.publicIP=null;let e=!1;const i=await S.get("https://api.ipify.org?format=json").catch(()=>e=!0);if(e||typeof i!="object"||!i||!i.data)return null;const r=i.data||{};return this.__pinPad__.config.publicIP=r.ip||null,localStorage.setItem("ppPublicIP",JSON.stringify({timestamp:new Date().getTime(),data:r.ip})),this.__pinPad__.config.publicIP}async cancelReadCard(){let t="012VXVCANCELl";this.__pinPad__.about.model?.toLowerCase()==="ingenico"&&(t="029C50AOPERACION CANCELADA");const e=this.parseStringToBytes(t,"");await this.appendToQueue(e,"cancel-read-card")}async print(t="client"){this.__pinPad__.operation.errors=0;const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX;this.__pinPad__.operation.commerceVoucher.includes(":")||(this.__pinPad__.operation.commerceVoucher=this.#n(this.__pinPad__.config.RC4Key,this.__pinPad__.operation.commerceVoucher)),this.__pinPad__.operation.clientVoucher.includes(":")||(this.__pinPad__.operation.clientVoucher=this.#n(this.__pinPad__.config.RC4Key,this.__pinPad__.operation.clientVoucher));let r=t==="client"?this.__pinPad__.operation.clientVoucher:this.__pinPad__.operation.commerceVoucher;if(r.length===0){this.dispatch("pp:print",{error:!0,code:"001",message:"Without information to print"});return}r=this.#k(r),r=this.#j(r,this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion);let s="C59A"+r;s=e+this.#e(s)+s+i,s=s+this.#i(s),t==="client"?this.__pinPad__.operation.clientVoucher="":t==="commerce"&&(this.__pinPad__.operation.commerceVoucher="");const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"print")}async#r(t,e){await this.#c();const i=this.#a(32),r=this.#s(this.__pinPad__.config.publicKeyRSA||"",i),s=await this.#o(i,JSON.stringify(e));return(await S.post(t,s,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:r||""}}).catch(o=>{throw o.response.data.includes("Ha ocurrido un error al procesar su solicitud.")?new Error("It was not possible to obtain the affiliations."):o.response.status>=500&&o.response.status<=599?new Error(`Service Temporarily Unavailable ${o.message}`):new Error(`Error in request, verify internet connection: ${o.response?.status} ${o.message}`)})).data}async#E({data:t,url:e,cancelable:i=!1}={data:null,url:"",cancelable:!1}){await this.#c();const r=this.#a(32),s=this.#s(this.__pinPad__.config.publicKeyRSA||"",r),a=await this.#o(r,JSON.stringify(t)),o=this;return(await S.post(e,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:s||""}}).catch(async h=>{let u=`Error in request, verify internet connection: ${h.status} ${h.message}`;throw h.response.status>=500&&h.response.status<=599?u="Service Temporarily Unavailable":h.response.status>=400&&h.response.status<=499&&(u="Bad Request"),i&&await o.#z(),new Error(u)})).data}async#$(){const t=this.__pinPad__.constants.FS,e=this.__pinPad__.constants.ETX,i=this.__pinPad__.constants.STX;let r="C57A"+this.__pinPad__.config.internal.qpsDomestic;if(r=r+t+"B"+this.__pinPad__.config.internal.qpsInternational,r=r+t+"C"+this.__pinPad__.config.internal.cvmlVMCDomestic,r=r+t+"D"+this.__pinPad__.config.internal.cvmlVMCInternational,r=r+t+"E"+this.__pinPad__.config.internal.cvmlAmex,r=r+t+"F"+this.__pinPad__.config.internal.translimitCTLSVMC,r=r+t+"G"+this.__pinPad__.config.internal.translimitCTLSAmex,r=i+this.#e(r)+r+e,r=r+this.#i(r),!this.__pinPad__.about.injectedValues){const s=this.parseStringToBytes(r,"");await this.appendToQueue(s,"inject")}}async#J(){this.__pinPad__.operation.bin8&&(this.__pinPad__.operation.bin=this.__pinPad__.operation.bin8),this.__pinPad__.operation.bin8="";const t=await this.#E({data:{accion:"tipoPagoInfo",cc_num:this.__pinPad__.operation.bin,usuario:this.username?.toUpperCase(),canal:this.__pinPad__.constants.typeChannel,tp_canal:"1",tp_moneda:this.__pinPad__.config.currency.toUpperCase()},url:this.url+this.__pinPad__.constants.uris.merchant,cancelable:!0});if(!t.respuesta||t.respuesta==="0"){let e="C55ACANCEL";const i=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;e=i+this.#e(e)+e+r,e=e+this.#i(e);const s=this.parseStringToBytes(e,"");return await this.appendToQueue(s,"cancel"),!1}return this.__pinPad__.operation.merchant=t,this.__pinPad__.operation.onlyMerchant=t.contado.af.length>1?t.contado.af[0].merchant:t.contado.af.merchant,!0}async#Q(t=null){if(this.__pinPad__.waiting.statusAboutWaiting)throw new Error("AboutPP is already running");const e=this.__pinPad__.constants.STX,i=this.__pinPad__.constants.ETX;let r="C56AABOUT";if(r=e+this.#e(r)+r+i,r=r+this.#i(r),B.isEmpty(this.__pinPad__.about.pp)){this.__pinPad__.waiting.statusAboutWaiting="pending";const a=this.parseStringToBytes(r,"");await this.appendToQueue(a,"about")}else return t?t(this.__pinPad__.about.pp?.supportDUKPT||!1,this.__pinPad__.about.pp?.hasDUKPTKeys||!1):!0;let s=0;return new Promise((a,o)=>{s=setInterval(()=>{if(this.__pinPad__.waiting.statusAboutWaiting==="resolved"){if(clearInterval(s),this.__pinPad__.waiting.statusAboutWaiting=null,B.isEmpty(this.__pinPad__.about.pp))return;if(!t||typeof t!="function"){a(!0);return}const c=t(this.__pinPad__.about.pp?.supportDUKPT||!1,this.__pinPad__.about.pp?.hasDUKPTKeys||!1);a(c)}else this.__pinPad__.waiting.statusAboutWaiting==="rejected"&&(clearInterval(s),this.__pinPad__.waiting.statusAboutWaiting=null,o("Error"))},500)})}async#l(t,e){if(t=t?t.toString():"",e=e?e.toString():"",B.isEmpty(t)||t==="0"){this.dispatch("pp:dukpt",{status:"unsupported",already:!1});return}if(B.isEmpty(e)||e==="1"){this.dispatch("pp:dukpt",{status:"charged",already:!0});return}const i=this.#P(),r=this.#v(),s=this.__pinPad__.constants.FS,a=this.__pinPad__.constants.ETX,o=this.__pinPad__.constants.STX;let c="C91A"+i+s+"B"+r;c=o+this.#e(c)+c+a,c=c+this.#i(c);const h=this.parseStringToBytes(c,"");await this.appendToQueue(h,"init-dukpt");let u=0;return this.__pinPad__.waiting.statusinitDUKPTWaiting="pending",new Promise((f,_)=>{u=setInterval(async()=>{this.__pinPad__.waiting.statusinitDUKPTWaiting==="resolved"?(clearInterval(u),this.__pinPad__.waiting.statusinitDUKPTWaiting=null,this.dispatch("pp:dukpt",{status:"charged",already:!1}),await this.#Z(),f(!0)):this.__pinPad__.waiting.statusinitDUKPTWaiting==="rejected"&&(clearInterval(u),this.__pinPad__.waiting.statusinitDUKPTWaiting=null,_("Error"))},500)})}async#Z(){const t={IPEK_REQUESTType:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},terminal:this.__pinPad__.config.terminal}},e=await this.#E({data:t,url:this.url+this.__pinPad__.constants.uris.keysDUKPT});await this.#ht(e)}async#Y(){if(!await this.#_())throw new Error("RSA public key is empty");const e=this;await this.#Q(async function(r,s){if(e.__pinPad__.about.supportInjection&&e.__pinPad__.config.internal.emv&&e.__pinPad__.about.injectedValues)return await e.#l(r,s),!0;let a=0;return e.__pinPad__.waiting.statusInjectWaiting="pending",await e.#$(),new Promise((o,c)=>{a=setInterval(async()=>{e.__pinPad__.waiting.statusInjectWaiting==="resolved"?(clearInterval(a),e.__pinPad__.waiting.statusInjectWaiting=null,await e.#l(r,s),o(!0)):e.__pinPad__.waiting.statusInjectWaiting==="rejected"&&(clearInterval(a),e.__pinPad__.waiting.statusInjectWaiting=null,c("Error"))},500)})})}#w(t,e=0){if(t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)||t===0)return parseFloat("0").toFixed(e);t=t.toFixed(e);const i=t.split(".");return i[0]=i[0].replace(/\B(?=(\d{3})+(?!\d))/g,""),i.join(".")}getClientVoucher(){return this.__pinPad__.operation.clientVoucher}getCommerceVoucher(){return this.__pinPad__.operation.commerceVoucher}async#tt(){this.__pinPad__.operation.errors=0;let t="ACERQUE, INSERTE CHIP O DESLICE TARJETA";if(this.__pinPad__.about.supportContactless||(t="INSERTE CHIP O DESLICE TARJETA"),this.__pinPad__.about.model?.toUpperCase().includes("UX300")&&(t="ACERQUE O INSERTE TARJETA"),B.isEmpty(this.amount)||isNaN(parseFloat(this.amount)))throw new Error("Amount required");if(parseFloat(this.amount)<=0)throw new Error("Amount must be greater than 0");if(this.#m(this.amount)===!1)throw new Error("Invalid amount required");if(parseFloat(this.#h(this.amount,2))<=0)throw new Error("Amount must be greater than 0");const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;let s="C93A"+t;s=s+e+"B"+this.#P(),s=s+e+"C"+this.#v(),s=s+e+"D"+this.#h(this.amount,2),s=s+e+"E0.00",s=s+e+"F"+this.__pinPad__.config.currencyCode,this.__pinPad__.about.supportDUKPT&&this.__pinPad__.about.supportDUKPT!=="0"&&this.__pinPad__.about.supportDUKPT!=="false"&&(this.__pinPad__.about.supportContactless?(s=s+e+"G"+this.timeoutPinPad,s=s+e+"HTAGS",s=s+e+"I"+this.__pinPad__.config.requireCVVAmex,s=s+e+"J"+this.__pinPad__.config.forceOnline,s=s+e+"K"+this.__pinPad__.about.supportContactless,s=s+e+"L"+this.__pinPad__.config.emvCard,this.__pinPad__.about.hasCashback&&(s=s+e+"M0",s=s+e+"N00")):(s=s+e+"G"+this.timeoutPinPad,s=s+e+"HTAGS",s=s+e+"I"+this.__pinPad__.config.requireCVVAmex,s=s+e+"L"+this.__pinPad__.config.emvCard),this.__pinPad__.about.supportInjection&&(s=s+e+"O"+this.__pinPad__.config.validateQPS)),s=i+this.#e(s)+s+r,s=s+this.#i(s),this.#lt();const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"read-card");let o=0;return this.__pinPad__.waiting.statusReadCardWaiting="pending",new Promise((c,h)=>{o=setInterval(()=>{if(this.__pinPad__.waiting.statusReadCardWaiting==="resolved")clearInterval(o),this.__pinPad__.waiting.statusReadCardWaiting=null,c(!0);else if(this.__pinPad__.waiting.statusReadCardWaiting==="rejected"){clearInterval(o),this.__pinPad__.waiting.statusReadCardWaiting=null;const u=this.__pinPad__.operation.last_error;h(u??"Error reading card")}},500)})}async#et(t){return await B.wait(t*1e3)}async consult({reference:t=null}={reference:null}){return t||(t=this.reference),B.isEmpty(t)&&(t="--",this.reference=t),this.#X(this.reference),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await this.#u({Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_Date:this.__pinPad__.operation.consultDate}),this.#r(this.url+this.__pinPad__.constants.uris.consult,{user:this.username?.toUpperCase(),pwd:this.password?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async#it(t){let e=this.url+this.__pinPad__.constants.uris.consult;return t>1&&this.environment==="production"&&(e=e.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative)),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await this.#r(e,{user:this.username?.toUpperCase(),pwd:this.password?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async#nt(t="",e={}){let i=1,r=null;do{i>1&&this.environment==="production"&&(t=t.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative),await this.#et(5)),await this.#c();const s=this.#a(32),a=this.#s(this.__pinPad__.config.publicKeyRSA||"",s),o=await this.#o(s,JSON.stringify(e));let c=!1;const h=await S.post(t,o,{headers:{"Content-Type":"application/json",data:a||""}}).catch(async u=>{let f=`Error in request, verify internet connection: ${u.status} ${u.message}`;u.response.status>=500&&u.response.status<=599?f="Service Temporarily Unavailable":u.response.status>=400&&u.response.status<=499&&(f="Bad Request"),console.warn(u),r=f;const _=await this.#it(i);_&&_!=="{}"&&!_.includes('"transacciones":""')&&_.includes("nu_operaion")&&(i=5,r="EE32"),c=!0});if(!c){if(!h||typeof h!="object"||!h.data){r="It was not possible to obtain the affiliations.";continue}return h.data}}while(i++<=3);return r?Promise.reject(r):Promise.reject("Communication error with CDP. IL/MTY")}#rt(t){if(B.isEmpty(t))throw new Error("Number of authorization invalid");if(/^[A-Za-z0-9]+$/g.test(t)!==!0)throw new Error("Number of authorization invalid");if(t.length!==6)throw new Error("Number of authorization invalid");return!0}async rePrint({folio:t=null}={}){let e="";t===null&&(e=this.__pinPad__.operation.folio||""),this.#y(e),await this.#u({Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_OperationNumber:e});const i=await this.#r(this.url+this.__pinPad__.constants.uris.rePrint,{REPRINTVOUCHER:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},no_operacion:t,crypto:"2"}});let r=i.voucher_comercio;return this.__pinPad__.operation.commerceVoucher="",r&&(i.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=i.voucher_comercio:this.__pinPad__.operation.commerceVoucher=this.#n(this.__pinPad__.config.RC4Key,i.voucher_comercio)),r=i.voucher_cliente,this.__pinPad__.operation.clientVoucher="",r&&(i.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=i.voucher_cliente:this.__pinPad__.operation.clientVoucher=this.#n(this.__pinPad__.config.RC4Key,i.voucher_cliente)),i}#st(t){this.__pinPad__.operation.responseMit._approved=t.response==="approved",this.__pinPad__.operation.responseMit._status=t.response,this.__pinPad__.operation.responseMit._originalToken=t.number_tkn??"",this.__pinPad__.operation.folio=t.foliocpagos,this.__pinPad__.operation.authorization=t.auth;let e=t.cd_response?.toUpperCase();return e.toUpperCase()==="0C"||this.__pinPad__.operation.responseMit._approved?e="00":(e!=="Z3"&&e!=="05"||t.cd_error==="92")&&(e="01"),this.__pinPad__.operation.responseMit._cdResponse=e,this.__pinPad__.finishCommand.A=e,this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E=t.emv_key_date?t.emv_key_date:"",this.__pinPad__.finishCommand.F=t.icc_csn?t.icc_csn:"",this.__pinPad__.finishCommand.G=t.icc_atc?t.icc_atc:"",this.__pinPad__.finishCommand.H=t.icc_arpc?t.icc_arpc:"",this.__pinPad__.finishCommand.I=t.icc_issuer_script?t.icc_issuer_script:"",this.__pinPad__.finishCommand.J=t.authorized_amount?t.authorized_amount:"",this.__pinPad__.finishCommand.K=t.account_balance_1?t.account_balance_1:"",{reference:t.reference,response:t.response,foliocpagos:t.foliocpagos,auth:t.auth,cd_response:e,cd_error:t.cd_error,nb_error:this.#b(t.nb_error??""),time:t.time,date:t.date,nb_company:t.nb_company,nb_merchant:t.nb_merchant,nb_street:t.nb_street,cc_type:t.cc_type,tp_operation:t.tp_operation,cc_name:t.cc_name,cc_number:t.cc_number,cc_expmonth:t.cc_expmonth,cc_expyear:t.cc_expyear,amount:t.amount,voucher_comercio:t.voucher_comercio,voucher_cliente:t.voucher_cliente,friendly_response:t.friendly_response,appid:t.appid,appidlabel:t.appidlabel,arqc:t.arqc}}async cancelPurchase({amount:t=0,authorization:e="",folio:i=""}={}){if(!this.#m(t))throw new Error("Invalid amount");if(!this.#rt(e))throw new Error("Invalid authorization");if(!this.#y(i))throw new Error("Invalid folio");const r=this.#w(t,2),s={Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,UserTRX:"userPinpadWeb",Tx_OperationNumber:i,Tx_Auth:e,Amount:r};await this.#u(s);const a=await this.#r(this.url+this.__pinPad__.constants.uris.cancellation,{VMCAMEXMCANCELACION:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},transacction:{amount:t,auth:e.toUpperCase(),crypto:"2",no_operacion:i,usrtransacction:this.username?.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}});return this.__pinPad__.operation.commerceVoucher="",a.voucher_comercio&&(a.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=a.voucher_comercio:this.__pinPad__.operation.commerceVoucher=this.#n(this.__pinPad__.config.RC4Key,a.voucher_comercio)),this.__pinPad__.operation.clientVoucher="",a.voucher_cliente&&(a.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=a.voucher_cliente:this.__pinPad__.operation.clientVoucher=this.#n(this.__pinPad__.config.RC4Key,a.voucher_cliente)),JSON.stringify(a)}async#at(){this.__pinPad__.operation.errors=0,this.__pinPad__.operation.ignore.counterSale=!1;const t=this.__pinPad__.operation.onlyMerchant;if(/^[0-9]+$/.test(t)===!1)throw new Error("Invalid merchant");this.__pinPad__.operation.typeOperation="29";const e={error:!1,message:null,approved:!1,object:{}};try{const i=await this.#w(this.amount,2);await this.#u({Ambiente:this.environment,Country:this.__pinPad__.config.country,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,pwd:this.password,User:this.username,UserTRX:"userPinpadWeb",EMV:this.__pinPad__.config.read.EMV,ModeloTerminal:this.__pinPad__.about.model,SerieTerminal:this.__pinPad__.about.serial,Contactless:this.__pinPad__.about.supportContactless,Printer:this.__pinPad__.about.printer,VersionTerminal:this.__pinPad__.about.appVersion,TpOperation:this.__pinPad__.operation.typeOperation,Reference:this.reference,Amount:i,Currency:this.__pinPad__.config.currency,Merchant:t,Reverse:this.__pinPad__.config.otherLogin.executeReverse});let r=this.__pinPad__.about.supportContactless;typeof r=="string"&&(r=r!=="0");const s=this.__pinPad__.about.supportContactless&&r,a=await this.#nt(this.url+this.__pinPad__.constants.uris.sale,{VMCAMEXB:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},dcc:{dcc_amount:"0",dcc_status:"0"},transacction:{amount:i,creditcard:{appid:this.__pinPad__.config.read.AppId,appidlabel:this.__pinPad__.config.read.AppIdLabel,arqc:this.__pinPad__.config.read.Arqc,chip:this.__pinPad__.config.read.Chip,chipname:this.__pinPad__.config.read.ChipName,chipnameenc:this.__pinPad__.config.read.ChipNameEnc,contactless:this.__pinPad__.config.read.ReadCTLS,crypto:"4",dukpt:{nb_data:this.__pinPad__.config.read.NB_Data,nb_ksn:this.__pinPad__.config.read.NB_ksn,tp_dukpt:"1"},pin:this.__pinPad__.config.read.PIN,posentrymode:this.__pinPad__.config.read.POSEM,tags:this.__pinPad__.config.read.Tags,type:this.__pinPad__.config.read.Type},currency:this.__pinPad__.config.currency.toUpperCase(),emv:this.__pinPad__.config.read.EMV,merchant:this.__pinPad__.operation.onlyMerchant,modelo_terminal:this.__pinPad__.about.model,reference:this.reference,serie:this.__pinPad__.about.serial,terminal:{display:"1",is_contactless:s,is_mobile:"0",printer:this.__pinPad__.about.printer},tp_operation:this.__pinPad__.operation.typeOperation,tp_resp:this.__pinPad__.operation.typeResponse,usrtransacction:this.username?.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion,version_terminal:this.__pinPad__.about.appVersion},geolocation:{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude,ip:this.__pinPad__.config.publicIP}}});a.response==="error"&&(e.error=!0,e.message=a.nb_error||"Error in response");const o=this.#st(a);return e.object=o,await this.#ot(o),e.approved=this.__pinPad__.operation.responseMit._approved,this.__pinPad__.operation.finalResult=o,e}catch(i){throw this.__pinPad__.finishCommand.A="01",this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E="",this.__pinPad__.finishCommand.F="",this.__pinPad__.finishCommand.G="",this.__pinPad__.finishCommand.H="",this.__pinPad__.finishCommand.I="",this.__pinPad__.finishCommand.J="",this.__pinPad__.finishCommand.K="",await this.#ut(this.#T(i)),i}}async#ot(t){if(this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")return this.dispatch("pp:finish-emv",t),!0;const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;let s="C93A"+this.__pinPad__.finishCommand.A;s=s+e+"B"+this.__pinPad__.finishCommand.B,s=s+e+"C"+this.__pinPad__.finishCommand.C,s=s+e+"D"+this.__pinPad__.finishCommand.D,s=s+e+"E"+this.__pinPad__.finishCommand.E,s=s+e+"F"+this.__pinPad__.finishCommand.F,s=s+e+"G"+this.__pinPad__.finishCommand.G,s=s+e+"H"+this.__pinPad__.finishCommand.H,s=s+e+"I"+this.__pinPad__.finishCommand.I,s=s+e+"J"+this.__pinPad__.finishCommand.J,s=s+e+"K"+this.__pinPad__.finishCommand.K,s=i+this.#e(s)+s+r,s=s+this.#i(s);const a=this.parseStringToBytes(s,"");this.__pinPad__.waiting.statusSecondGenerateWaiting="pending",await this.appendToQueue(a,"second-generate");let o=0;return new Promise((c,h)=>{o=setInterval(async()=>{if(this.__pinPad__.waiting.statusSecondGenerateWaiting==="resolved"){if(clearInterval(o),this.__pinPad__.waiting.statusSecondGenerateWaiting=null,this.__pinPad__.operation.applyReverse){const u=await this.#r(this.url+this.__pinPad__.constants.uris.reverse,{VMCAMEXMREVERSO:{business:{id_company:this.__pinPad__.config.idCompany?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),country:this.__pinPad__.config.country?.toUpperCase(),user:this.username?.toUpperCase(),pwd:this.password?.toUpperCase()},transacction:{amount:this.#h(this.amount,2),no_operacion:this.__pinPad__.operation.folio,auth:this.__pinPad__.operation.authorization?.toUpperCase(),tracks:"",usrtransacction:this.username?.toUpperCase(),crypto:"2",version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}}),f=JSON.parse(u);let _;f.response==="approved"?_={message:"Transaction rejected by PinPad."}:_={message:"No communication, please check your report."},this.__pinPad__.operation.ignore.counterSale||(this.dispatch("pp:finish-emv",_),this.__pinPad__.operation.ignore.counterSale=!0)}else this.__pinPad__.operation.ignore.counterSale||(this.dispatch("pp:finish-emv",t),this.__pinPad__.operation.ignore.counterSale=!0);t.cd_error==="92"&&await this.#ct(t,s),c(!0)}else this.__pinPad__.waiting.statusSecondGenerateWaiting==="rejected"&&(clearInterval(o),this.__pinPad__.waiting.statusSecondGenerateWaiting=null,h("There is no response from the reader, check that it is connected."))},500)})}async#ct(t,e){this.__pinPad__.operation.ignore.responseGlobal=t,this.__pinPad__.operation.ignore.C93Global=e,this.__pinPad__.operation.ignore.isError92TRX=!0,await this.#l(!0,!1)}async#S(){if(this.__pinPad__.operation.ignore.isError92TRX=!1,this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal);else{const t=this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global,"");await this.appendToQueue(t,"code93"),await B.wait(1400),this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal)}}#T(t){const e={PPE02:"Importe Incorrecto.",A02:"Importe Incorrecto.",PPE03:"No hay respuesta del lector, verifique que se encuentra conectado.",A03:"No hay respuesta del lector, verifique que se encuentra conectado.",PP18:"Sin comunicación, por favor verifique su reporte.",PP24:"Transacción declinada por la PinPad.",A01:"Tarjeta Ilegible.",A04:"No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.",A10:"Operación cancelada por el usuario.",A11:"Proceso cancelado por timeout.",A12:"Lectura errónea de banda/chip.",A13:"Carga de llave fallida.",A14:"Error de lectura de PIN.",A15:"Tarjeta Vencida.",A16:"Problemas al leer el chip.",A17:"Impresora sin Papel.",E17:"Impresora sin Papel.",A21:"Información no almacenada correctamente.",A22:"Tarjeta bloqueada.",A23:"Sin llave de cifrado DUKPT.",A28:"Fallback no soportado.",EE19:"Error de conexión, verifique su reporte.",EE21:"Ha ocurrido un error al procesar su solicitud.",EE22:"Ha ocurrido un error de conexión al servidor.",EE23:"El número de operación no puede ir vacío.",EE24:"El número de operación debe ser de 9 dígitos.",EE25:"El número de operación debe ser numérico.",EE26:"La información enviada al servicio está incompleta.",EE27:"La referencia contiene caracteres inválidos o está vacía.",EE28:"Número de autorización inválido.",EE29:"Importe inválido.",EE30:"La información enviada al servicio no es válida.",EE31:"No fue posible obtener las afiliaciones.",EE32:"Error de conexión, existe una o más transacciones en el servidor , Favor de validar su reporte y en su caso reimprimir el voucher.",EE33:"Error de comunicacion con CDP. IL/MTY",EE20:"La Referencia contiene caracteres inválidos",EE99:"Error código 99."},i=e[t]?{error:t,message:e[t]}:{error:t,message:"Error desconocido"};return this.dispatch("pp:error",i),i}async#ut(t){const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;let s="C93A"+this.__pinPad__.finishCommand.A;if(s=s+e+"B"+this.__pinPad__.finishCommand.B,s=s+e+"C"+this.__pinPad__.finishCommand.C,s=s+e+"D"+this.__pinPad__.finishCommand.D,s=s+e+"E"+this.__pinPad__.finishCommand.E,s=s+e+"F"+this.__pinPad__.finishCommand.F,s=s+e+"G"+this.__pinPad__.finishCommand.G,s=s+e+"H"+this.__pinPad__.finishCommand.H,s=s+e+"I"+this.__pinPad__.finishCommand.I,s=s+e+"J"+this.__pinPad__.finishCommand.J,s=s+e+"K"+this.__pinPad__.finishCommand.K,s=i+this.#e(s)+s+r,s=s+this.#i(s),this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1"){this.dispatch("pp:finish-emv",t);return}const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"finish-emv-end")}async#ht(t){if(t.cd_estatus=t.cd_estatus?t.cd_estatus:"0",t.cd_estatus!=="1"){this.__pinPad__.operation.ignore.isError92TRX&&await this.#S();return}const e=this.__pinPad__.constants.FS,i=this.__pinPad__.constants.ETX,r=this.__pinPad__.constants.STX,s=t.nb_ksn,a=t.nb_kcv||"",o=t.nb_ipek||"";let c="C92A"+s+e+"B"+a+e+"C"+o;c=r+this.#e(c)+c+i,c=c+this.#i(c);const h=this.parseStringToBytes(c,"");await this.appendToQueue(h,"dukpt");let u=0;return this.__pinPad__.waiting.statuswritingDUKPTWaiting="pending",new Promise((f,_)=>{u=setInterval(async()=>{this.__pinPad__.waiting.statuswritingDUKPTWaiting==="resolved"?(clearInterval(u),this.__pinPad__.waiting.statuswritingDUKPTWaiting=null,this.__pinPad__.operation.ignore.isError92TRX&&await this.#S(),f(!0)):this.__pinPad__.waiting.statuswritingDUKPTWaiting==="rejected"&&(clearInterval(u),this.__pinPad__.waiting.statuswritingDUKPTWaiting=null,_("Error writing DUKPT keys"))},500)})}#lt(){this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.AppIdLabel="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ChipName="",this.__pinPad__.config.read.ReadCTLS="",this.__pinPad__.config.read.NB_Data="",this.__pinPad__.config.read.NB_ksn="",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.POSEM="",this.__pinPad__.config.read.Tags="",this.__pinPad__.config.read.Type="",this.__pinPad__.config.read.Chip="",this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.operation.ignore.error="",this.__pinPad__.operation.ignore.C93Global="",this.__pinPad__.operation.folio="",this.__pinPad__.operation.authorization="",this.__pinPad__.config.tokenizeTRX=!1}async makeSale({amount:t=0,reference:e=null}={}){if(t=parseFloat(t.toString()),isNaN(t)||t<=0)throw new Error("Amount is required and must be greater than 0");if(this.amount=t,!e||B.isEmpty(e)||!this.#g(e))throw new Error("Reference is required and must be alphanumeric");if(this.reference=e,/^[A-Z-a-z\s]+$/g.test(this.__pinPad__.config.currency)===!1)throw new Error("Invalid currency");const i={error:!1,message:null,approved:!1,object:{}};try{return await this.login(),await this.#Y(),!await this.#tt()||!await this.#J()?i:await this.#at()}catch(r){console.warn(r),i.error=!0,i.message=r.message,i.approved=!1,i.object=r}return i}}exports.PinPad=Ir;
14
+ `,e+="-----END PUBLIC KEY-----",e},t.hasPublicKeyProperty=function(e){return e=e||{},e.hasOwnProperty("n")&&e.hasOwnProperty("e")},t.hasPrivateKeyProperty=function(e){return e=e||{},e.hasOwnProperty("n")&&e.hasOwnProperty("e")&&e.hasOwnProperty("d")&&e.hasOwnProperty("p")&&e.hasOwnProperty("q")&&e.hasOwnProperty("dmp1")&&e.hasOwnProperty("dmq1")&&e.hasOwnProperty("coeff")},t.prototype.parsePropertiesFrom=function(e){this.n=e.n,this.e=e.e,e.hasOwnProperty("d")&&(this.d=e.d,this.p=e.p,this.q=e.q,this.dmp1=e.dmp1,this.dmq1=e.dmq1,this.coeff=e.coeff)},t})(zn),Gt,Zn=typeof process<"u"?(Gt=process.env)===null||Gt===void 0?void 0:Gt.npm_package_version:void 0,Yn=(function(){function i(t){t===void 0&&(t={}),this.default_key_size=t.default_key_size?parseInt(t.default_key_size,10):1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=t.key||null}return i.prototype.setKey=function(t){t?(this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new Ae(t)):!this.key&&this.log&&console.error("A key was not set.")},i.prototype.setPrivateKey=function(t){this.setKey(t)},i.prototype.setPublicKey=function(t){this.setKey(t)},i.prototype.decrypt=function(t){try{return this.getKey().decrypt(me(t))}catch{return!1}},i.prototype.encrypt=function(t){try{return yt(this.getKey().encrypt(t))}catch{return!1}},i.prototype.encryptOAEP=function(t){try{return yt(this.getKey().encrypt(t,Xn))}catch{return!1}},i.prototype.sign=function(t,e,n){e===void 0&&(e=function(r){return r}),n===void 0&&(n="");try{return yt(this.getKey().sign(t,e,n))}catch{return!1}},i.prototype.signSha256=function(t){return this.sign(t,function(e){return Se(te(e))},"sha256")},i.prototype.verify=function(t,e,n){n===void 0&&(n=function(r){return r});try{return this.getKey().verify(t,me(e),n)}catch{return!1}},i.prototype.verifySha256=function(t,e){return this.verify(t,e,function(n){return Se(te(n))})},i.prototype.getKey=function(t){if(!this.key){if(this.key=new Ae,t&&{}.toString.call(t)==="[object Function]"){this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);return}this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},i.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},i.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},i.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},i.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},i.version=Zn,i})();function Ge(i,t){return function(){return i.apply(t,arguments)}}const{toString:ti}=Object.prototype,{getPrototypeOf:Ft}=Object,{iterator:kt,toStringTag:$e}=Symbol,jt=(i=>t=>{const e=ti.call(t);return i[e]||(i[e]=e.slice(8,-1).toLowerCase())})(Object.create(null)),X=i=>(i=i.toLowerCase(),t=>jt(t)===i),qt=i=>t=>typeof t===i,{isArray:_t}=Array,pt=qt("undefined");function bt(i){return i!==null&&!pt(i)&&i.constructor!==null&&!pt(i.constructor)&&M(i.constructor.isBuffer)&&i.constructor.isBuffer(i)}const Je=X("ArrayBuffer");function ei(i){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(i):t=i&&i.buffer&&Je(i.buffer),t}const ni=qt("string"),M=qt("function"),Qe=qt("number"),Pt=i=>i!==null&&typeof i=="object",ii=i=>i===!0||i===!1,Bt=i=>{if(jt(i)!=="object")return!1;const t=Ft(i);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!($e in i)&&!(kt in i)},ri=i=>{if(!Pt(i)||bt(i))return!1;try{return Object.keys(i).length===0&&Object.getPrototypeOf(i)===Object.prototype}catch{return!1}},si=X("Date"),ai=X("File"),oi=i=>!!(i&&typeof i.uri<"u"),ci=i=>i&&typeof i.getParts<"u",ui=X("Blob"),li=X("FileList"),hi=i=>Pt(i)&&M(i.pipe);function fi(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Re=fi(),Ce=typeof Re.FormData<"u"?Re.FormData:void 0,pi=i=>{if(!i)return!1;if(Ce&&i instanceof Ce)return!0;const t=Ft(i);if(!t||t===Object.prototype||!M(i.append))return!1;const e=jt(i);return e==="formdata"||e==="object"&&M(i.toString)&&i.toString()==="[object FormData]"},di=X("URLSearchParams"),[_i,gi,mi,yi]=["ReadableStream","Request","Response","Headers"].map(X),bi=i=>i.trim?i.trim():i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function vt(i,t,{allOwnKeys:e=!1}={}){if(i===null||typeof i>"u")return;let n,r;if(typeof i!="object"&&(i=[i]),_t(i))for(n=0,r=i.length;n<r;n++)t.call(null,i[n],n,i);else{if(bt(i))return;const s=e?Object.getOwnPropertyNames(i):Object.keys(i),a=s.length;let o;for(n=0;n<a;n++)o=s[n],t.call(null,i[o],o,i)}}function Ze(i,t){if(bt(i))return null;t=t.toLowerCase();const e=Object.keys(i);let n=e.length,r;for(;n-- >0;)if(r=e[n],t===r.toLowerCase())return r;return null}const nt=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ye=i=>!pt(i)&&i!==nt;function ee(){const{caseless:i,skipUndefined:t}=Ye(this)&&this||{},e={},n=(r,s)=>{if(s==="__proto__"||s==="constructor"||s==="prototype")return;const a=i&&Ze(e,s)||s;Bt(e[a])&&Bt(r)?e[a]=ee(e[a],r):Bt(r)?e[a]=ee({},r):_t(r)?e[a]=r.slice():(!t||!pt(r))&&(e[a]=r)};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&vt(arguments[r],n);return e}const Pi=(i,t,e,{allOwnKeys:n}={})=>(vt(t,(r,s)=>{e&&M(r)?Object.defineProperty(i,s,{value:Ge(r,e),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(i,s,{value:r,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:n}),i),vi=i=>(i.charCodeAt(0)===65279&&(i=i.slice(1)),i),Ei=(i,t,e,n)=>{i.prototype=Object.create(t.prototype,n),Object.defineProperty(i.prototype,"constructor",{value:i,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(i,"super",{value:t.prototype}),e&&Object.assign(i.prototype,e)},wi=(i,t,e,n)=>{let r,s,a;const o={};if(t=t||{},i==null)return t;do{for(r=Object.getOwnPropertyNames(i),s=r.length;s-- >0;)a=r[s],(!n||n(a,i,t))&&!o[a]&&(t[a]=i[a],o[a]=!0);i=e!==!1&&Ft(i)}while(i&&(!e||e(i,t))&&i!==Object.prototype);return t},Si=(i,t,e)=>{i=String(i),(e===void 0||e>i.length)&&(e=i.length),e-=t.length;const n=i.indexOf(t,e);return n!==-1&&n===e},Ti=i=>{if(!i)return null;if(_t(i))return i;let t=i.length;if(!Qe(t))return null;const e=new Array(t);for(;t-- >0;)e[t]=i[t];return e},Ai=(i=>t=>i&&t instanceof i)(typeof Uint8Array<"u"&&Ft(Uint8Array)),Ri=(i,t)=>{const n=(i&&i[kt]).call(i);let r;for(;(r=n.next())&&!r.done;){const s=r.value;t.call(i,s[0],s[1])}},Ci=(i,t)=>{let e;const n=[];for(;(e=i.exec(t))!==null;)n.push(e);return n},Oi=X("HTMLFormElement"),Di=i=>i.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,n,r){return n.toUpperCase()+r}),Oe=(({hasOwnProperty:i})=>(t,e)=>i.call(t,e))(Object.prototype),Ii=X("RegExp"),tn=(i,t)=>{const e=Object.getOwnPropertyDescriptors(i),n={};vt(e,(r,s)=>{let a;(a=t(r,s,i))!==!1&&(n[s]=a||r)}),Object.defineProperties(i,n)},Ni=i=>{tn(i,(t,e)=>{if(M(i)&&["arguments","caller","callee"].indexOf(e)!==-1)return!1;const n=i[e];if(M(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+e+"'")})}})},Bi=(i,t)=>{const e={},n=r=>{r.forEach(s=>{e[s]=!0})};return _t(i)?n(i):n(String(i).split(t)),e},xi=()=>{},Vi=(i,t)=>i!=null&&Number.isFinite(i=+i)?i:t;function Ui(i){return!!(i&&M(i.append)&&i[$e]==="FormData"&&i[kt])}const Li=i=>{const t=new Array(10),e=(n,r)=>{if(Pt(n)){if(t.indexOf(n)>=0)return;if(bt(n))return n;if(!("toJSON"in n)){t[r]=n;const s=_t(n)?[]:{};return vt(n,(a,o)=>{const c=e(a,r+1);!pt(c)&&(s[o]=c)}),t[r]=void 0,s}}return n};return e(i,0)},Mi=X("AsyncFunction"),Fi=i=>i&&(Pt(i)||M(i))&&M(i.then)&&M(i.catch),en=((i,t)=>i?setImmediate:t?((e,n)=>(nt.addEventListener("message",({source:r,data:s})=>{r===nt&&s===e&&n.length&&n.shift()()},!1),r=>{n.push(r),nt.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))(typeof setImmediate=="function",M(nt.postMessage)),ki=typeof queueMicrotask<"u"?queueMicrotask.bind(nt):typeof process<"u"&&process.nextTick||en,ji=i=>i!=null&&M(i[kt]),h={isArray:_t,isArrayBuffer:Je,isBuffer:bt,isFormData:pi,isArrayBufferView:ei,isString:ni,isNumber:Qe,isBoolean:ii,isObject:Pt,isPlainObject:Bt,isEmptyObject:ri,isReadableStream:_i,isRequest:gi,isResponse:mi,isHeaders:yi,isUndefined:pt,isDate:si,isFile:ai,isReactNativeBlob:oi,isReactNative:ci,isBlob:ui,isRegExp:Ii,isFunction:M,isStream:hi,isURLSearchParams:di,isTypedArray:Ai,isFileList:li,forEach:vt,merge:ee,extend:Pi,trim:bi,stripBOM:vi,inherits:Ei,toFlatObject:wi,kindOf:jt,kindOfTest:X,endsWith:Si,toArray:Ti,forEachEntry:Ri,matchAll:Ci,isHTMLForm:Oi,hasOwnProperty:Oe,hasOwnProp:Oe,reduceDescriptors:tn,freezeMethods:Ni,toObjectSet:Bi,toCamelCase:Di,noop:xi,toFiniteNumber:Vi,findKey:Ze,global:nt,isContextDefined:Ye,isSpecCompliantForm:Ui,toJSONObject:Li,isAsyncFn:Mi,isThenable:Fi,setImmediate:en,asap:ki,isIterable:ji};let b=class nn extends Error{static from(t,e,n,r,s,a){const o=new nn(t.message,e||t.code,n,r,s);return o.cause=t,o.name=t.name,t.status!=null&&o.status==null&&(o.status=t.status),a&&Object.assign(o,a),o}constructor(t,e,n,r,s){super(t),Object.defineProperty(this,"message",{value:t,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,e&&(this.code=e),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s,this.status=s.status)}toJSON(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:h.toJSONObject(this.config),code:this.code,status:this.status}}};b.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE";b.ERR_BAD_OPTION="ERR_BAD_OPTION";b.ECONNABORTED="ECONNABORTED";b.ETIMEDOUT="ETIMEDOUT";b.ERR_NETWORK="ERR_NETWORK";b.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS";b.ERR_DEPRECATED="ERR_DEPRECATED";b.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE";b.ERR_BAD_REQUEST="ERR_BAD_REQUEST";b.ERR_CANCELED="ERR_CANCELED";b.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT";b.ERR_INVALID_URL="ERR_INVALID_URL";b.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const qi=null;function ne(i){return h.isPlainObject(i)||h.isArray(i)}function rn(i){return h.endsWith(i,"[]")?i.slice(0,-2):i}function $t(i,t,e){return i?i.concat(t).map(function(r,s){return r=rn(r),!e&&s?"["+r+"]":r}).join(e?".":""):t}function Ki(i){return h.isArray(i)&&!i.some(ne)}const Hi=h.toFlatObject(h,{},null,function(t){return/^is[A-Z]/.test(t)});function Kt(i,t,e){if(!h.isObject(i))throw new TypeError("target must be an object");t=t||new FormData,e=h.toFlatObject(e,{metaTokens:!0,dots:!1,indexes:!1},!1,function(d,w){return!h.isUndefined(w[d])});const n=e.metaTokens,r=e.visitor||f,s=e.dots,a=e.indexes,o=e.Blob||typeof Blob<"u"&&Blob,c=e.maxDepth===void 0?100:e.maxDepth,l=o&&h.isSpecCompliantForm(t);if(!h.isFunction(r))throw new TypeError("visitor must be a function");function u(g){if(g===null)return"";if(h.isDate(g))return g.toISOString();if(h.isBoolean(g))return g.toString();if(!l&&h.isBlob(g))throw new b("Blob is not supported. Use a Buffer instead.");return h.isArrayBuffer(g)||h.isTypedArray(g)?l&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function f(g,d,w){let C=g;if(h.isReactNative(t)&&h.isReactNativeBlob(g))return t.append($t(w,d,s),u(g)),!1;if(g&&!w&&typeof g=="object"){if(h.endsWith(d,"{}"))d=n?d:d.slice(0,-2),g=JSON.stringify(g);else if(h.isArray(g)&&Ki(g)||(h.isFileList(g)||h.endsWith(d,"[]"))&&(C=h.toArray(g)))return d=rn(d),C.forEach(function(S,N){!(h.isUndefined(S)||S===null)&&t.append(a===!0?$t([d],N,s):a===null?d:d+"[]",u(S))}),!1}return ne(g)?!0:(t.append($t(w,d,s),u(g)),!1)}const _=[],y=Object.assign(Hi,{defaultVisitor:f,convertValue:u,isVisitable:ne});function m(g,d,w=0){if(!h.isUndefined(g)){if(w>c)throw new b("Object is too deeply nested ("+w+" levels). Max depth: "+c,b.ERR_FORM_DATA_DEPTH_EXCEEDED);if(_.indexOf(g)!==-1)throw Error("Circular reference detected in "+d.join("."));_.push(g),h.forEach(g,function(T,S){(!(h.isUndefined(T)||T===null)&&r.call(t,T,h.isString(S)?S.trim():S,d,y))===!0&&m(T,d?d.concat(S):[S],w+1)}),_.pop()}}if(!h.isObject(i))throw new TypeError("data must be an object");return m(i),t}function De(i){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(i).replace(/[!'()~]|%20/g,function(n){return t[n]})}function ae(i,t){this._pairs=[],i&&Kt(i,this,t)}const sn=ae.prototype;sn.append=function(t,e){this._pairs.push([t,e])};sn.toString=function(t){const e=t?function(n){return t.call(this,n,De)}:De;return this._pairs.map(function(r){return e(r[0])+"="+e(r[1])},"").join("&")};function Wi(i){return encodeURIComponent(i).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function an(i,t,e){if(!t)return i;const n=e&&e.encode||Wi,r=h.isFunction(e)?{serialize:e}:e,s=r&&r.serialize;let a;if(s?a=s(t,r):a=h.isURLSearchParams(t)?t.toString():new ae(t,r).toString(n),a){const o=i.indexOf("#");o!==-1&&(i=i.slice(0,o)),i+=(i.indexOf("?")===-1?"?":"&")+a}return i}class Ie{constructor(){this.handlers=[]}use(t,e,n){return this.handlers.push({fulfilled:t,rejected:e,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){h.forEach(this.handlers,function(n){n!==null&&t(n)})}}const oe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Xi=typeof URLSearchParams<"u"?URLSearchParams:ae,zi=typeof FormData<"u"?FormData:null,Gi=typeof Blob<"u"?Blob:null,$i={isBrowser:!0,classes:{URLSearchParams:Xi,FormData:zi,Blob:Gi},protocols:["http","https","file","blob","url","data"]},ce=typeof window<"u"&&typeof document<"u",ie=typeof navigator=="object"&&navigator||void 0,Ji=ce&&(!ie||["ReactNative","NativeScript","NS"].indexOf(ie.product)<0),Qi=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Zi=ce&&window.location.href||"http://localhost",Yi=Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:ce,hasStandardBrowserEnv:Ji,hasStandardBrowserWebWorkerEnv:Qi,navigator:ie,origin:Zi},Symbol.toStringTag,{value:"Module"})),B={...Yi,...$i};function tr(i,t){return Kt(i,new B.classes.URLSearchParams,{visitor:function(e,n,r,s){return B.isNode&&h.isBuffer(e)?(this.append(n,e.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)},...t})}function er(i){return h.matchAll(/\w+|\[(\w*)]/g,i).map(t=>t[0]==="[]"?"":t[1]||t[0])}function nr(i){const t={},e=Object.keys(i);let n;const r=e.length;let s;for(n=0;n<r;n++)s=e[n],t[s]=i[s];return t}function on(i){function t(e,n,r,s){let a=e[s++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),c=s>=e.length;return a=!a&&h.isArray(r)?r.length:a,c?(h.hasOwnProp(r,a)?r[a]=h.isArray(r[a])?r[a].concat(n):[r[a],n]:r[a]=n,!o):((!r[a]||!h.isObject(r[a]))&&(r[a]=[]),t(e,n,r[a],s)&&h.isArray(r[a])&&(r[a]=nr(r[a])),!o)}if(h.isFormData(i)&&h.isFunction(i.entries)){const e={};return h.forEachEntry(i,(n,r)=>{t(er(n),r,e,0)}),e}return null}const lt=(i,t)=>i!=null&&h.hasOwnProp(i,t)?i[t]:void 0;function ir(i,t,e){if(h.isString(i))try{return(t||JSON.parse)(i),h.trim(i)}catch(n){if(n.name!=="SyntaxError")throw n}return(e||JSON.stringify)(i)}const Et={transitional:oe,adapter:["xhr","http","fetch"],transformRequest:[function(t,e){const n=e.getContentType()||"",r=n.indexOf("application/json")>-1,s=h.isObject(t);if(s&&h.isHTMLForm(t)&&(t=new FormData(t)),h.isFormData(t))return r?JSON.stringify(on(t)):t;if(h.isArrayBuffer(t)||h.isBuffer(t)||h.isStream(t)||h.isFile(t)||h.isBlob(t)||h.isReadableStream(t))return t;if(h.isArrayBufferView(t))return t.buffer;if(h.isURLSearchParams(t))return e.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(s){const c=lt(this,"formSerializer");if(n.indexOf("application/x-www-form-urlencoded")>-1)return tr(t,c).toString();if((o=h.isFileList(t))||n.indexOf("multipart/form-data")>-1){const l=lt(this,"env"),u=l&&l.FormData;return Kt(o?{"files[]":t}:t,u&&new u,c)}}return s||r?(e.setContentType("application/json",!1),ir(t)):t}],transformResponse:[function(t){const e=lt(this,"transitional")||Et.transitional,n=e&&e.forcedJSONParsing,r=lt(this,"responseType"),s=r==="json";if(h.isResponse(t)||h.isReadableStream(t))return t;if(t&&h.isString(t)&&(n&&!r||s)){const o=!(e&&e.silentJSONParsing)&&s;try{return JSON.parse(t,lt(this,"parseReviver"))}catch(c){if(o)throw c.name==="SyntaxError"?b.from(c,b.ERR_BAD_RESPONSE,this,null,lt(this,"response")):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:B.classes.FormData,Blob:B.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};h.forEach(["delete","get","head","post","put","patch"],i=>{Et.headers[i]={}});const rr=h.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),sr=i=>{const t={};let e,n,r;return i&&i.split(`
15
+ `).forEach(function(a){r=a.indexOf(":"),e=a.substring(0,r).trim().toLowerCase(),n=a.substring(r+1).trim(),!(!e||t[e]&&rr[e])&&(e==="set-cookie"?t[e]?t[e].push(n):t[e]=[n]:t[e]=t[e]?t[e]+", "+n:n)}),t},Ne=Symbol("internals"),ar=/[^\x09\x20-\x7E\x80-\xFF]/g;function or(i){let t=0,e=i.length;for(;t<e;){const n=i.charCodeAt(t);if(n!==9&&n!==32)break;t+=1}for(;e>t;){const n=i.charCodeAt(e-1);if(n!==9&&n!==32)break;e-=1}return t===0&&e===i.length?i:i.slice(t,e)}function gt(i){return i&&String(i).trim().toLowerCase()}function cr(i){return or(i.replace(ar,""))}function xt(i){return i===!1||i==null?i:h.isArray(i)?i.map(xt):cr(String(i))}function ur(i){const t=Object.create(null),e=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=e.exec(i);)t[n[1]]=n[2];return t}const lr=i=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(i.trim());function Jt(i,t,e,n,r){if(h.isFunction(n))return n.call(this,t,e);if(r&&(t=e),!!h.isString(t)){if(h.isString(n))return t.indexOf(n)!==-1;if(h.isRegExp(n))return n.test(t)}}function hr(i){return i.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,e,n)=>e.toUpperCase()+n)}function fr(i,t){const e=h.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(i,n+e,{value:function(r,s,a){return this[n].call(this,t,r,s,a)},configurable:!0})})}let F=class{constructor(t){t&&this.set(t)}set(t,e,n){const r=this;function s(o,c,l){const u=gt(c);if(!u)throw new Error("header name must be a non-empty string");const f=h.findKey(r,u);(!f||r[f]===void 0||l===!0||l===void 0&&r[f]!==!1)&&(r[f||c]=xt(o))}const a=(o,c)=>h.forEach(o,(l,u)=>s(l,u,c));if(h.isPlainObject(t)||t instanceof this.constructor)a(t,e);else if(h.isString(t)&&(t=t.trim())&&!lr(t))a(sr(t),e);else if(h.isObject(t)&&h.isIterable(t)){let o={},c,l;for(const u of t){if(!h.isArray(u))throw TypeError("Object iterator must return a key-value pair");o[l=u[0]]=(c=o[l])?h.isArray(c)?[...c,u[1]]:[c,u[1]]:u[1]}a(o,e)}else t!=null&&s(e,t,n);return this}get(t,e){if(t=gt(t),t){const n=h.findKey(this,t);if(n){const r=this[n];if(!e)return r;if(e===!0)return ur(r);if(h.isFunction(e))return e.call(this,r,n);if(h.isRegExp(e))return e.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,e){if(t=gt(t),t){const n=h.findKey(this,t);return!!(n&&this[n]!==void 0&&(!e||Jt(this,this[n],n,e)))}return!1}delete(t,e){const n=this;let r=!1;function s(a){if(a=gt(a),a){const o=h.findKey(n,a);o&&(!e||Jt(n,n[o],o,e))&&(delete n[o],r=!0)}}return h.isArray(t)?t.forEach(s):s(t),r}clear(t){const e=Object.keys(this);let n=e.length,r=!1;for(;n--;){const s=e[n];(!t||Jt(this,this[s],s,t,!0))&&(delete this[s],r=!0)}return r}normalize(t){const e=this,n={};return h.forEach(this,(r,s)=>{const a=h.findKey(n,s);if(a){e[a]=xt(r),delete e[s];return}const o=t?hr(s):String(s).trim();o!==s&&delete e[s],e[o]=xt(r),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const e=Object.create(null);return h.forEach(this,(n,r)=>{n!=null&&n!==!1&&(e[r]=t&&h.isArray(n)?n.join(", "):n)}),e}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,e])=>t+": "+e).join(`
16
+ `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...e){const n=new this(t);return e.forEach(r=>n.set(r)),n}static accessor(t){const n=(this[Ne]=this[Ne]={accessors:{}}).accessors,r=this.prototype;function s(a){const o=gt(a);n[o]||(fr(r,a),n[o]=!0)}return h.isArray(t)?t.forEach(s):s(t),this}};F.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);h.reduceDescriptors(F.prototype,({value:i},t)=>{let e=t[0].toUpperCase()+t.slice(1);return{get:()=>i,set(n){this[e]=n}}});h.freezeMethods(F);function Qt(i,t){const e=this||Et,n=t||e,r=F.from(n.headers);let s=n.data;return h.forEach(i,function(o){s=o.call(e,s,r.normalize(),t?t.status:void 0)}),r.normalize(),s}function cn(i){return!!(i&&i.__CANCEL__)}let wt=class extends b{constructor(t,e,n){super(t??"canceled",b.ERR_CANCELED,e,n),this.name="CanceledError",this.__CANCEL__=!0}};function un(i,t,e){const n=e.config.validateStatus;!e.status||!n||n(e.status)?i(e):t(new b("Request failed with status code "+e.status,[b.ERR_BAD_REQUEST,b.ERR_BAD_RESPONSE][Math.floor(e.status/100)-4],e.config,e.request,e))}function pr(i){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(i);return t&&t[1]||""}function dr(i,t){i=i||10;const e=new Array(i),n=new Array(i);let r=0,s=0,a;return t=t!==void 0?t:1e3,function(c){const l=Date.now(),u=n[s];a||(a=l),e[r]=c,n[r]=l;let f=s,_=0;for(;f!==r;)_+=e[f++],f=f%i;if(r=(r+1)%i,r===s&&(s=(s+1)%i),l-a<t)return;const y=u&&l-u;return y?Math.round(_*1e3/y):void 0}}function _r(i,t){let e=0,n=1e3/t,r,s;const a=(l,u=Date.now())=>{e=u,r=null,s&&(clearTimeout(s),s=null),i(...l)};return[(...l)=>{const u=Date.now(),f=u-e;f>=n?a(l,u):(r=l,s||(s=setTimeout(()=>{s=null,a(r)},n-f)))},()=>r&&a(r)]}const Lt=(i,t,e=3)=>{let n=0;const r=dr(50,250);return _r(s=>{const a=s.loaded,o=s.lengthComputable?s.total:void 0,c=o!=null?Math.min(a,o):a,l=Math.max(0,c-n),u=r(l);n=Math.max(n,c);const f={loaded:c,total:o,progress:o?c/o:void 0,bytes:l,rate:u||void 0,estimated:u&&o?(o-c)/u:void 0,event:s,lengthComputable:o!=null,[t?"download":"upload"]:!0};i(f)},e)},Be=(i,t)=>{const e=i!=null;return[n=>t[0]({lengthComputable:e,total:i,loaded:n}),t[1]]},xe=i=>(...t)=>h.asap(()=>i(...t)),gr=B.hasStandardBrowserEnv?((i,t)=>e=>(e=new URL(e,B.origin),i.protocol===e.protocol&&i.host===e.host&&(t||i.port===e.port)))(new URL(B.origin),B.navigator&&/(msie|trident)/i.test(B.navigator.userAgent)):()=>!0,mr=B.hasStandardBrowserEnv?{write(i,t,e,n,r,s,a){if(typeof document>"u")return;const o=[`${i}=${encodeURIComponent(t)}`];h.isNumber(e)&&o.push(`expires=${new Date(e).toUTCString()}`),h.isString(n)&&o.push(`path=${n}`),h.isString(r)&&o.push(`domain=${r}`),s===!0&&o.push("secure"),h.isString(a)&&o.push(`SameSite=${a}`),document.cookie=o.join("; ")},read(i){if(typeof document>"u")return null;const t=document.cookie.match(new RegExp("(?:^|; )"+i+"=([^;]*)"));return t?decodeURIComponent(t[1]):null},remove(i){this.write(i,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function yr(i){return typeof i!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(i)}function br(i,t){return t?i.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):i}function ln(i,t,e){let n=!yr(t);return i&&(n||e===!1)?br(i,t):t}const Ve=i=>i instanceof F?{...i}:i;function rt(i,t){t=t||{};const e=Object.create(null);Object.defineProperty(e,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function n(l,u,f,_){return h.isPlainObject(l)&&h.isPlainObject(u)?h.merge.call({caseless:_},l,u):h.isPlainObject(u)?h.merge({},u):h.isArray(u)?u.slice():u}function r(l,u,f,_){if(h.isUndefined(u)){if(!h.isUndefined(l))return n(void 0,l,f,_)}else return n(l,u,f,_)}function s(l,u){if(!h.isUndefined(u))return n(void 0,u)}function a(l,u){if(h.isUndefined(u)){if(!h.isUndefined(l))return n(void 0,l)}else return n(void 0,u)}function o(l,u,f){if(h.hasOwnProp(t,f))return n(l,u);if(h.hasOwnProp(i,f))return n(void 0,l)}const c={url:s,method:s,data:s,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,allowedSocketPaths:a,responseEncoding:a,validateStatus:o,headers:(l,u,f)=>r(Ve(l),Ve(u),f,!0)};return h.forEach(Object.keys({...i,...t}),function(u){if(u==="__proto__"||u==="constructor"||u==="prototype")return;const f=h.hasOwnProp(c,u)?c[u]:r,_=h.hasOwnProp(i,u)?i[u]:void 0,y=h.hasOwnProp(t,u)?t[u]:void 0,m=f(_,y,u);h.isUndefined(m)&&f!==o||(e[u]=m)}),e}const hn=i=>{const t=rt({},i),e=_=>h.hasOwnProp(t,_)?t[_]:void 0,n=e("data");let r=e("withXSRFToken");const s=e("xsrfHeaderName"),a=e("xsrfCookieName");let o=e("headers");const c=e("auth"),l=e("baseURL"),u=e("allowAbsoluteUrls"),f=e("url");if(t.headers=o=F.from(o),t.url=an(ln(l,f,u),i.params,i.paramsSerializer),c&&o.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),h.isFormData(n)){if(B.hasStandardBrowserEnv||B.hasStandardBrowserWebWorkerEnv)o.setContentType(void 0);else if(h.isFunction(n.getHeaders)){const _=n.getHeaders(),y=["content-type","content-length"];Object.entries(_).forEach(([m,g])=>{y.includes(m.toLowerCase())&&o.set(m,g)})}}if(B.hasStandardBrowserEnv&&(h.isFunction(r)&&(r=r(t)),r===!0||r==null&&gr(t.url))){const y=s&&a&&mr.read(a);y&&o.set(s,y)}return t},Pr=typeof XMLHttpRequest<"u",vr=Pr&&function(i){return new Promise(function(e,n){const r=hn(i);let s=r.data;const a=F.from(r.headers).normalize();let{responseType:o,onUploadProgress:c,onDownloadProgress:l}=r,u,f,_,y,m;function g(){y&&y(),m&&m(),r.cancelToken&&r.cancelToken.unsubscribe(u),r.signal&&r.signal.removeEventListener("abort",u)}let d=new XMLHttpRequest;d.open(r.method.toUpperCase(),r.url,!0),d.timeout=r.timeout;function w(){if(!d)return;const T=F.from("getAllResponseHeaders"in d&&d.getAllResponseHeaders()),N={data:!o||o==="text"||o==="json"?d.responseText:d.response,status:d.status,statusText:d.statusText,headers:T,config:i,request:d};un(function(D){e(D),g()},function(D){n(D),g()},N),d=null}"onloadend"in d?d.onloadend=w:d.onreadystatechange=function(){!d||d.readyState!==4||d.status===0&&!(d.responseURL&&d.responseURL.indexOf("file:")===0)||setTimeout(w)},d.onabort=function(){d&&(n(new b("Request aborted",b.ECONNABORTED,i,d)),d=null)},d.onerror=function(S){const N=S&&S.message?S.message:"Network Error",P=new b(N,b.ERR_NETWORK,i,d);P.event=S||null,n(P),d=null},d.ontimeout=function(){let S=r.timeout?"timeout of "+r.timeout+"ms exceeded":"timeout exceeded";const N=r.transitional||oe;r.timeoutErrorMessage&&(S=r.timeoutErrorMessage),n(new b(S,N.clarifyTimeoutError?b.ETIMEDOUT:b.ECONNABORTED,i,d)),d=null},s===void 0&&a.setContentType(null),"setRequestHeader"in d&&h.forEach(a.toJSON(),function(S,N){d.setRequestHeader(N,S)}),h.isUndefined(r.withCredentials)||(d.withCredentials=!!r.withCredentials),o&&o!=="json"&&(d.responseType=r.responseType),l&&([_,m]=Lt(l,!0),d.addEventListener("progress",_)),c&&d.upload&&([f,y]=Lt(c),d.upload.addEventListener("progress",f),d.upload.addEventListener("loadend",y)),(r.cancelToken||r.signal)&&(u=T=>{d&&(n(!T||T.type?new wt(null,i,d):T),d.abort(),d=null)},r.cancelToken&&r.cancelToken.subscribe(u),r.signal&&(r.signal.aborted?u():r.signal.addEventListener("abort",u)));const C=pr(r.url);if(C&&B.protocols.indexOf(C)===-1){n(new b("Unsupported protocol "+C+":",b.ERR_BAD_REQUEST,i));return}d.send(s||null)})},Er=(i,t)=>{const{length:e}=i=i?i.filter(Boolean):[];if(t||e){let n=new AbortController,r;const s=function(l){if(!r){r=!0,o();const u=l instanceof Error?l:this.reason;n.abort(u instanceof b?u:new wt(u instanceof Error?u.message:u))}};let a=t&&setTimeout(()=>{a=null,s(new b(`timeout of ${t}ms exceeded`,b.ETIMEDOUT))},t);const o=()=>{i&&(a&&clearTimeout(a),a=null,i.forEach(l=>{l.unsubscribe?l.unsubscribe(s):l.removeEventListener("abort",s)}),i=null)};i.forEach(l=>l.addEventListener("abort",s));const{signal:c}=n;return c.unsubscribe=()=>h.asap(o),c}},wr=function*(i,t){let e=i.byteLength;if(e<t){yield i;return}let n=0,r;for(;n<e;)r=n+t,yield i.slice(n,r),n=r},Sr=async function*(i,t){for await(const e of Tr(i))yield*wr(e,t)},Tr=async function*(i){if(i[Symbol.asyncIterator]){yield*i;return}const t=i.getReader();try{for(;;){const{done:e,value:n}=await t.read();if(e)break;yield n}}finally{await t.cancel()}},Ue=(i,t,e,n)=>{const r=Sr(i,t);let s=0,a,o=c=>{a||(a=!0,n&&n(c))};return new ReadableStream({async pull(c){try{const{done:l,value:u}=await r.next();if(l){o(),c.close();return}let f=u.byteLength;if(e){let _=s+=f;e(_)}c.enqueue(new Uint8Array(u))}catch(l){throw o(l),l}},cancel(c){return o(c),r.return()}},{highWaterMark:2})},Le=64*1024,{isFunction:It}=h,Ar=(({Request:i,Response:t})=>({Request:i,Response:t}))(h.global),{ReadableStream:Me,TextEncoder:Fe}=h.global,ke=(i,...t)=>{try{return!!i(...t)}catch{return!1}},Rr=i=>{i=h.merge.call({skipUndefined:!0},Ar,i);const{fetch:t,Request:e,Response:n}=i,r=t?It(t):typeof fetch=="function",s=It(e),a=It(n);if(!r)return!1;const o=r&&It(Me),c=r&&(typeof Fe=="function"?(m=>g=>m.encode(g))(new Fe):async m=>new Uint8Array(await new e(m).arrayBuffer())),l=s&&o&&ke(()=>{let m=!1;const g=new e(B.origin,{body:new Me,method:"POST",get duplex(){return m=!0,"half"}}),d=g.headers.has("Content-Type");return g.body!=null&&g.body.cancel(),m&&!d}),u=a&&o&&ke(()=>h.isReadableStream(new n("").body)),f={stream:u&&(m=>m.body)};r&&["text","arrayBuffer","blob","formData","stream"].forEach(m=>{!f[m]&&(f[m]=(g,d)=>{let w=g&&g[m];if(w)return w.call(g);throw new b(`Response type '${m}' is not supported`,b.ERR_NOT_SUPPORT,d)})});const _=async m=>{if(m==null)return 0;if(h.isBlob(m))return m.size;if(h.isSpecCompliantForm(m))return(await new e(B.origin,{method:"POST",body:m}).arrayBuffer()).byteLength;if(h.isArrayBufferView(m)||h.isArrayBuffer(m))return m.byteLength;if(h.isURLSearchParams(m)&&(m=m+""),h.isString(m))return(await c(m)).byteLength},y=async(m,g)=>{const d=h.toFiniteNumber(m.getContentLength());return d??_(g)};return async m=>{let{url:g,method:d,data:w,signal:C,cancelToken:T,timeout:S,onDownloadProgress:N,onUploadProgress:P,responseType:D,headers:H,withCredentials:k="same-origin",fetchOptions:st}=hn(m),U=t||fetch;D=D?(D+"").toLowerCase():"text";let at=Er([C,T&&T.toAbortSignal()],S),z=null;const tt=at&&at.unsubscribe&&(()=>{at.unsubscribe()});let le;try{if(P&&l&&d!=="get"&&d!=="head"&&(le=await y(H,w))!==0){let j=new e(g,{method:"POST",body:w,duplex:"half"}),ot;if(h.isFormData(w)&&(ot=j.headers.get("content-type"))&&H.setContentType(ot),j.body){const[Wt,St]=Be(le,Lt(xe(P)));w=Ue(j.body,Le,Wt,St)}}h.isString(k)||(k=k?"include":"omit");const L=s&&"credentials"in e.prototype;if(h.isFormData(w)){const j=H.getContentType();j&&/^multipart\/form-data/i.test(j)&&!/boundary=/i.test(j)&&H.delete("content-type")}const he={...st,signal:at,method:d.toUpperCase(),headers:H.normalize().toJSON(),body:w,duplex:"half",credentials:L?k:void 0};z=s&&new e(g,he);let J=await(s?U(z,st):U(g,he));const fe=u&&(D==="stream"||D==="response");if(u&&(N||fe&&tt)){const j={};["status","statusText","headers"].forEach(pe=>{j[pe]=J[pe]});const ot=h.toFiniteNumber(J.headers.get("content-length")),[Wt,St]=N&&Be(ot,Lt(xe(N),!0))||[];J=new n(Ue(J.body,Le,Wt,()=>{St&&St(),tt&&tt()}),j)}D=D||"text";let mn=await f[h.findKey(f,D)||"text"](J,m);return!fe&&tt&&tt(),await new Promise((j,ot)=>{un(j,ot,{data:mn,headers:F.from(J.headers),status:J.status,statusText:J.statusText,config:m,request:z})})}catch(L){throw tt&&tt(),L&&L.name==="TypeError"&&/Load failed|fetch/i.test(L.message)?Object.assign(new b("Network Error",b.ERR_NETWORK,m,z,L&&L.response),{cause:L.cause||L}):b.from(L,L&&L.code,m,z,L&&L.response)}}},Cr=new Map,fn=i=>{let t=i&&i.env||{};const{fetch:e,Request:n,Response:r}=t,s=[n,r,e];let a=s.length,o=a,c,l,u=Cr;for(;o--;)c=s[o],l=u.get(c),l===void 0&&u.set(c,l=o?new Map:Rr(t)),u=l;return l};fn();const ue={http:qi,xhr:vr,fetch:{get:fn}};h.forEach(ue,(i,t)=>{if(i){try{Object.defineProperty(i,"name",{value:t})}catch{}Object.defineProperty(i,"adapterName",{value:t})}});const je=i=>`- ${i}`,Or=i=>h.isFunction(i)||i===null||i===!1;function Dr(i,t){i=h.isArray(i)?i:[i];const{length:e}=i;let n,r;const s={};for(let a=0;a<e;a++){n=i[a];let o;if(r=n,!Or(n)&&(r=ue[(o=String(n)).toLowerCase()],r===void 0))throw new b(`Unknown adapter '${o}'`);if(r&&(h.isFunction(r)||(r=r.get(t))))break;s[o||"#"+a]=r}if(!r){const a=Object.entries(s).map(([c,l])=>`adapter ${c} `+(l===!1?"is not supported by the environment":"is not available in the build"));let o=e?a.length>1?`since :
17
+ `+a.map(je).join(`
18
+ `):" "+je(a[0]):"as no adapter specified";throw new b("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r}const pn={getAdapter:Dr,adapters:ue};function Zt(i){if(i.cancelToken&&i.cancelToken.throwIfRequested(),i.signal&&i.signal.aborted)throw new wt(null,i)}function qe(i){return Zt(i),i.headers=F.from(i.headers),i.data=Qt.call(i,i.transformRequest),["post","put","patch"].indexOf(i.method)!==-1&&i.headers.setContentType("application/x-www-form-urlencoded",!1),pn.getAdapter(i.adapter||Et.adapter,i)(i).then(function(n){return Zt(i),n.data=Qt.call(i,i.transformResponse,n),n.headers=F.from(n.headers),n},function(n){return cn(n)||(Zt(i),n&&n.response&&(n.response.data=Qt.call(i,i.transformResponse,n.response),n.response.headers=F.from(n.response.headers))),Promise.reject(n)})}const dn="1.15.2",Ht={};["object","boolean","number","function","string","symbol"].forEach((i,t)=>{Ht[i]=function(n){return typeof n===i||"a"+(t<1?"n ":" ")+i}});const Ke={};Ht.transitional=function(t,e,n){function r(s,a){return"[Axios v"+dn+"] Transitional option '"+s+"'"+a+(n?". "+n:"")}return(s,a,o)=>{if(t===!1)throw new b(r(a," has been removed"+(e?" in "+e:"")),b.ERR_DEPRECATED);return e&&!Ke[a]&&(Ke[a]=!0,console.warn(r(a," has been deprecated since v"+e+" and will be removed in the near future"))),t?t(s,a,o):!0}};Ht.spelling=function(t){return(e,n)=>(console.warn(`${n} is likely a misspelling of ${t}`),!0)};function Ir(i,t,e){if(typeof i!="object")throw new b("options must be an object",b.ERR_BAD_OPTION_VALUE);const n=Object.keys(i);let r=n.length;for(;r-- >0;){const s=n[r],a=Object.prototype.hasOwnProperty.call(t,s)?t[s]:void 0;if(a){const o=i[s],c=o===void 0||a(o,s,i);if(c!==!0)throw new b("option "+s+" must be "+c,b.ERR_BAD_OPTION_VALUE);continue}if(e!==!0)throw new b("Unknown option "+s,b.ERR_BAD_OPTION)}}const Vt={assertOptions:Ir,validators:Ht},q=Vt.validators;let it=class{constructor(t){this.defaults=t||{},this.interceptors={request:new Ie,response:new Ie}}async request(t,e){try{return await this._request(t,e)}catch(n){if(n instanceof Error){let r={};Error.captureStackTrace?Error.captureStackTrace(r):r=new Error;const s=(()=>{if(!r.stack)return"";const a=r.stack.indexOf(`
19
+ `);return a===-1?"":r.stack.slice(a+1)})();try{if(!n.stack)n.stack=s;else if(s){const a=s.indexOf(`
20
+ `),o=a===-1?-1:s.indexOf(`
21
+ `,a+1),c=o===-1?"":s.slice(o+1);String(n.stack).endsWith(c)||(n.stack+=`
22
+ `+s)}}catch{}}throw n}}_request(t,e){typeof t=="string"?(e=e||{},e.url=t):e=t||{},e=rt(this.defaults,e);const{transitional:n,paramsSerializer:r,headers:s}=e;n!==void 0&&Vt.assertOptions(n,{silentJSONParsing:q.transitional(q.boolean),forcedJSONParsing:q.transitional(q.boolean),clarifyTimeoutError:q.transitional(q.boolean),legacyInterceptorReqResOrdering:q.transitional(q.boolean)},!1),r!=null&&(h.isFunction(r)?e.paramsSerializer={serialize:r}:Vt.assertOptions(r,{encode:q.function,serialize:q.function},!0)),e.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?e.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:e.allowAbsoluteUrls=!0),Vt.assertOptions(e,{baseUrl:q.spelling("baseURL"),withXsrfToken:q.spelling("withXSRFToken")},!0),e.method=(e.method||this.defaults.method||"get").toLowerCase();let a=s&&h.merge(s.common,s[e.method]);s&&h.forEach(["delete","get","head","post","put","patch","common"],m=>{delete s[m]}),e.headers=F.concat(a,s);const o=[];let c=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(e)===!1)return;c=c&&g.synchronous;const d=e.transitional||oe;d&&d.legacyInterceptorReqResOrdering?o.unshift(g.fulfilled,g.rejected):o.push(g.fulfilled,g.rejected)});const l=[];this.interceptors.response.forEach(function(g){l.push(g.fulfilled,g.rejected)});let u,f=0,_;if(!c){const m=[qe.bind(this),void 0];for(m.unshift(...o),m.push(...l),_=m.length,u=Promise.resolve(e);f<_;)u=u.then(m[f++],m[f++]);return u}_=o.length;let y=e;for(;f<_;){const m=o[f++],g=o[f++];try{y=m(y)}catch(d){g.call(this,d);break}}try{u=qe.call(this,y)}catch(m){return Promise.reject(m)}for(f=0,_=l.length;f<_;)u=u.then(l[f++],l[f++]);return u}getUri(t){t=rt(this.defaults,t);const e=ln(t.baseURL,t.url,t.allowAbsoluteUrls);return an(e,t.params,t.paramsSerializer)}};h.forEach(["delete","get","head","options"],function(t){it.prototype[t]=function(e,n){return this.request(rt(n||{},{method:t,url:e,data:(n||{}).data}))}});h.forEach(["post","put","patch"],function(t){function e(n){return function(s,a,o){return this.request(rt(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:a}))}}it.prototype[t]=e(),it.prototype[t+"Form"]=e(!0)});let Nr=class _n{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let e;this.promise=new Promise(function(s){e=s});const n=this;this.promise.then(r=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](r);n._listeners=null}),this.promise.then=r=>{let s;const a=new Promise(o=>{n.subscribe(o),s=o}).then(r);return a.cancel=function(){n.unsubscribe(s)},a},t(function(s,a,o){n.reason||(n.reason=new wt(s,a,o),e(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const e=this._listeners.indexOf(t);e!==-1&&this._listeners.splice(e,1)}toAbortSignal(){const t=new AbortController,e=n=>{t.abort(n)};return this.subscribe(e),t.signal.unsubscribe=()=>this.unsubscribe(e),t.signal}static source(){let t;return{token:new _n(function(r){t=r}),cancel:t}}};function Br(i){return function(e){return i.apply(null,e)}}function xr(i){return h.isObject(i)&&i.isAxiosError===!0}const re={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(re).forEach(([i,t])=>{re[t]=i});function gn(i){const t=new it(i),e=Ge(it.prototype.request,t);return h.extend(e,it.prototype,t,{allOwnKeys:!0}),h.extend(e,t,null,{allOwnKeys:!0}),e.create=function(r){return gn(rt(i,r))},e}const A=gn(Et);A.Axios=it;A.CanceledError=wt;A.CancelToken=Nr;A.isCancel=cn;A.VERSION=dn;A.toFormData=Kt;A.AxiosError=b;A.Cancel=A.CanceledError;A.all=function(t){return Promise.all(t)};A.spread=Br;A.isAxiosError=xr;A.mergeConfig=rt;A.AxiosHeaders=F;A.formToJSON=i=>on(h.isHTMLForm(i)?new FormData(i):i);A.getAdapter=pn.getAdapter;A.HttpStatusCode=re;A.default=A;const{Axios:Fr,AxiosError:kr,CanceledError:jr,isCancel:qr,CancelToken:Kr,VERSION:Hr,all:Wr,Cancel:Xr,isAxiosError:zr,spread:Gr,toFormData:$r,AxiosHeaders:Jr,HttpStatusCode:Qr,formToJSON:Zr,getAdapter:Yr,mergeConfig:ts}=A;class Vr extends x.Kernel{__pinPad__={buffer:null,about:{EMV:null,model:null,serial:null,brand:null,appVersion:null,printer:null,hasCashback:!1,supportInjection:!1,supportSign:!1,supportContactlessCollisionCard:!1,supportContactless:!1,supportDUKPT:"",injectedValues:!1,pp:null},config:{defaultEnvironment:"production",environment:"production",currency:"MXN",currencyCode:"0484",timeoutPinPad:"100",signSupport:"1",CTLSSupport:"1",userTRX:"userPinpadWeb",tp_operation:"29",requireCVVAmex:"1",forceOnline:"00",emvCard:"0",validateQPS:"1",username:null,password:null,country:null,idBranch:null,idCompany:null,latitude:null,longitude:null,publicKeyRSA:null,publicIP:null,internal:{stTokenization:!1,qpsDomestic:"",qpsInternational:"",cvmlVMCDomestic:"",cvmlVMCInternational:"",cvmlAmex:"",translimitCTLSVMC:"",translimitCTLSAmex:"",emv:{}},terminal:{},loginResponse:null,otherLogin:{},RC4Key:"KEY CREDIT CARD KEY",read:{EMV:"",PIN:"",POSEM:"",AppId:"",AppIdLabel:"",Arqc:"",Chip:"",ChipName:"",ChipNameEnc:"",ReadCTLS:"",NB_Data:"",NB_ksn:"",Tags:"",Type:""},tokenizeTRX:!1},constants:{appVersion:"1.0.16",appName:"pinpapWebApp ",STX:"",ETX:"",FS:"",getNULL:"\0",appChannel:"3",typeChannel:"11",urls:{development:"https://fcdev.mitec.com.mx",qa:"https://fcqa.mitec.com.mx",production:"https://m.mit.com.mx",productionAlternative:"https://m2.mit.com.mx"},uris:{login:"/pinpadWeb/login",RSAKey:"/pinpadWeb/getDataCrypt",merchant:"/pinpadWeb/getAfiliaciones",consult:"/pinpadWeb/queryTrx",keysDUKPT:"/pinpadWeb/getKeysDUKPT",reverse:"/pinpadWeb/executeBackSale",rePrint:"/pinpadWeb/reprint",checkInMoto:"/pinpadWeb/checkin",checkOutMoto:"/pinpadWeb/checkout",reAuthorizationMoto:"/pinpadWeb/reAuthorization",cancellation:"/pinpadWeb/executeVoid",sale:"/pinpadWeb/executeSale"}},operation:{amount:"0",reference:null,folio:null,authorization:null,errors:0,last_error:null,commerceVoucher:"",clientVoucher:"",consultDate:null,ignore:{responseGlobal:{},counter:!1,counterSale:!1,isError92TRX:!1,C93Global:!1,error:""},finalResult:{},moto:{ccType:"",ccName:"",ccNumber:"",ccExpMonth:"",ccExpYear:"",ccCvvCsc:"",txRoom:""},bin:"",bin8:"",hasQPS:!1,onlyMerchant:"",merchant:null,typeOperation:"29",typeResponse:"",responseMit:{},applyReverse:!1},finishCommand:{A:"",B:"",C:"",D:"",E:"",F:"",G:"",H:"",I:"",J:"",K:""},waiting:{statusAboutWaiting:null,statusInjectWaiting:null,statusReadCardWaiting:null,statusSecondGenerateWaiting:null,statusinitDUKPTWaiting:null,statuswritingDUKPTWaiting:null}};constructor({filters:t=null,config_port:e={baudRate:19200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:n=1,device_listen_on_channel:r=1,username:s=null,password:a=null,environment:o="production",socket:c=!1}={filters:null,config_port:{baudRate:19200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,device_listen_on_channel:1,username:null,password:null,environment:"production",socket:!1}){if(super({filters:t,config_port:e,no_device:n,device_listen_on_channel:r,socket:c}),this.__internal__.device.type="pinpad",!x.supportCrypto())throw new Error("Crypto not supported in this browser");if(de.Devices.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);this.__internal__.time.response_connection=3e3,this.__internal__.time.response_general=5e3,this.__internal__.serial.delay_first_connection=1e3,this.environment=o,s&&(this.username=s),a&&(this.password=a),this.#A(),de.Devices.add(this)}#A(){const t=["pp:processing-card","pp:read-card","pp:error","pp:print","pp:merchant-moto","pp:dukpt","pp:finish-emv","pp:response"];for(const e of t)this.serialRegisterAvailableListener(e)}async timeout(t,e){await super.timeout(t,e),this.__pinPad__.waiting.statusAboutWaiting&&e==="about"?this.__pinPad__.waiting.statusAboutWaiting="rejected":this.__pinPad__.waiting.statusInjectWaiting&&e==="inject"?this.__pinPad__.waiting.statusInjectWaiting="rejected":this.__pinPad__.waiting.statusinitDUKPTWaiting&&e==="init-dukpt"?this.__pinPad__.waiting.statusinitDUKPTWaiting="rejected":this.__pinPad__.waiting.statuswritingDUKPTWaiting&&e==="dukpt"?this.__pinPad__.waiting.statuswritingDUKPTWaiting="rejected":this.__pinPad__.waiting.statusReadCardWaiting&&e==="read-card"?this.__pinPad__.waiting.statusReadCardWaiting="rejected":this.__pinPad__.waiting.statusSecondGenerateWaiting&&e==="second-generate"&&(this.__pinPad__.waiting.statusSecondGenerateWaiting="rejected")}#R(t){const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX,r=this.__pinPad__.constants.FS,s=this.__pinPad__.constants.getNULL;t=t.replace(new RegExp(e,"g"),"");const a=t.split(n);t=a[0];const o=t.split(r);o.push(...a[1].split(r));const c={};return o.map((l,u)=>{const f=u>0?l.substring(0,1):"A",_=u>0?l.substring(1):l;return{[f]:_.replace(new RegExp(s,"g"),"")}}).forEach(l=>Object.assign(c,l)),c}#f(t,e){const n=this.__pinPad__.constants.ETX,r=e.substring(e.indexOf("D")+2,e.indexOf("E"));let s=0;const a=e.indexOf("N")>0,o=e.substring(e.indexOf("A00")+3,e.indexOf("B"));if(o&&o!=="undefined"&&o.toUpperCase()==="VERIFONE"){const l=r.replace("MITP_1.00.","").replace("MITP_01.00.","").replace("MITD_1.00.","").replace("MITD_01.00.","");s=parseInt(l),s>=15&&(this.__pinPad__.about.hasCashback=!0)}this.__pinPad__.about.supportInjection=a,e.indexOf("M")>0?(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf("M"))=="1",this.__pinPad__.about.supportInjection?this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf("N"))==="1":(this.__pinPad__.about.supportContactlessCollisionCard=e.substring(e.indexOf("M")+2,e.indexOf(n))=="1",this.__pinPad__.about.supportContactless=!0)):(this.__pinPad__.about.supportSign=e.substring(e.indexOf("L")+2,e.indexOf(n))=="1",this.__pinPad__.about.supportContactless=!1),this.__pinPad__.about.supportDUKPT=e.substring(e.indexOf("J")+2,e.indexOf("K")),this.__pinPad__.about.EMV=e.substring(e.indexOf("E")+2,e.indexOf("F")),this.__pinPad__.about.serial=e.substring(e.indexOf("C")+2,e.indexOf("D")),this.__pinPad__.about.printer=e.substring(e.indexOf("F")+2,e.indexOf("G")),this.__pinPad__.about.model=e.substring(e.indexOf("B")+2,e.indexOf("C")),this.__pinPad__.about.brand=o,this.__pinPad__.about.appVersion=r;const c=e.substring(e.indexOf("K")+2,e.indexOf("L"))=="1";this.__pinPad__.about.pp={brand:o,appVersion:r,versionInt:s,hasCashback:this.__pinPad__.about.hasCashback,supportInjection:this.__pinPad__.about.supportInjection,supportSign:this.__pinPad__.about.supportSign,supportContactlessCollisionCard:this.__pinPad__.about.supportContactlessCollisionCard,supportContactless:this.__pinPad__.about.supportContactless,supportDUKPT:this.__pinPad__.about.supportDUKPT=="1",hasDUKPTKeys:c,EMV:this.__pinPad__.about.EMV,serial:this.__pinPad__.about.serial,printer:this.__pinPad__.about.printer,model:this.__pinPad__.about.model},this.__pinPad__.waiting.statusAboutWaiting&&(this.__pinPad__.waiting.statusAboutWaiting="resolved")}#C(){this.__pinPad__.waiting.statusInjectWaiting="resolved"}#O(t,e){e=e.replace("010P93A00B01t036P81AACERQUE, INSERTE CHIP O DESLICE*",""),this.__pinPad__.config.terminal={nb_kcv:e.substring(e.indexOf("E")+2,e.indexOf("F")),nb_marca_terminal:e.substring(e.indexOf("P91A")+4,e.indexOf("B")),nb_modelo_terminal:e.substring(e.indexOf("B")+2,e.indexOf("C")),nb_serie_lector:e.substring(e.indexOf("C")+2,e.indexOf("D")),nb_tk:e.substring(e.indexOf("F")+2,e.length-2),nb_version_terminal:e.substring(e.indexOf("D")+2,e.indexOf("E"))},this.__pinPad__.waiting.statusinitDUKPTWaiting="resolved"}#D(){this.__pinPad__.waiting.statuswritingDUKPTWaiting="resolved"}#I(t,e){const n=this.__pinPad__.about?.brand?.toLowerCase(),r=this.__pinPad__.about?.model?.toLowerCase(),s=n==="ingenico"&&r==="ipp320"?500:350;if(e.length<s){e=e.replace("006P93A00.","").replace("006P93A00,",""),e.includes("E93")?this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E93")+3,e.indexOf("E93")+6):e.includes("E71")&&(this.__pinPad__.operation.ignore.error=e.substring(e.indexOf("E71")+3,e.indexOf("E71")+6)),this.__pinPad__.operation.ignore.error!==""&&e.indexOf("OPERACION CANCELADA")===-1&&e.indexOf("TIEMPO EXCEDIDO")===-1&&this.__pinPad__.operation.ignore.error.length===3&&(this.__pinPad__.operation.last_error=this.#T(this.__pinPad__.operation.ignore.error),this.__pinPad__.waiting.statusReadCardWaiting="rejected");return}if(e.includes("M1")||e.includes("M0")||e.includes("M1")||e.includes("N1")||e.includes("N1")||e.includes("P93A022")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A800")&&e.substring(e.length-24).includes("I")&&e.substring(e.length-1).includes("")||e.includes("P93A022")&&e.length>=406&&r==="vx820"||e.includes("P93A022")&&e.length>=406&&r==="vx520"||e.includes("P93A800")&&e.length>=406&&r==="vx520"||e.includes("P93A800")&&e.length>=406&&r==="vx820"||e.includes("P93A022")&&e.length>=406&&r==="p400"||e.includes("P93A800")&&e.length>=406&&r==="p400"||e.includes("P93A022")&&e.length>=406&&r==="v205c"||e.includes("P93A800")&&e.length>=406&&r==="v205c"||e.includes("P93A022")&&e.length>=406&&r==="move2500"||e.includes("P93A800")&&e.length>=406&&r==="move2500"||e.includes("P93A022")&&e.length>=406&&r==="lane3000"||e.includes("P93A800")&&e.length>=406&&r==="lane3000"){let a=e;n==="verifone"&&(a=e.replace("006P93A00.","").substring(e.indexOf("P93A"),e.indexOf("P93A")+7)),e.includes("P81APROCESANDO, NO RETIRE TARJETA")||e.includes("P81APROCESANDO TARJETA")||a.includes("P93A022")||a.includes("P81AINSERTE CHIP O DESLICE TARJETA")||a.includes("ACERQUE, INSERTE CHIP O DESLICE")||a.includes("P81AACERQUE, INSERTE CHIP O DESLICE TARJETA")?this.dispatch("pp:processing-card",{waiting:!0}):e.length>s&&this.#B(e)}}#N(t,e){const n=this.__pinPad__.constants.ETX;let r=e.replace("023P81AFAVOR RETIRAR TARJ.","").replace("020P81A DECLINADA EMV ","").replace("020P81A DECLINADA EMV ","");r=r.substring(r.indexOf("B")+2,r.indexOf(n)),r.includes("006E93A16")&&(r="01"),this.__pinPad__.operation.applyReverse=r==="01"&&this.__pinPad__.operation.responseMit._approved&&this.__pinPad__.config.otherLogin.executeReverse==="1",this.__pinPad__.waiting.statusSecondGenerateWaiting="resolved"}#B(t){const e=this.__pinPad__.constants.ETX,n=this.__pinPad__.about?.brand?.toLowerCase();let r,s,a,o,c;n==="verifone"?t=t.replace("006P93A00.","").replace("009P93A00","").replace("010P93A00B01v",""):t=t.replace("006P93A00,",""),this.__pinPad__.config.read.POSEM=t.substring(t.indexOf("P93A")+4,t.indexOf("B"));const l=this.__pinPad__.config.read.POSEM;if(l==="051"||l==="071"){if(this.__pinPad__.config.read.Chip="1",this.__pinPad__.config.read.PIN=t.substring(t.indexOf("C")+2,t.indexOf("D")),this.__pinPad__.config.read.AppId=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Arqc=t.substring(t.indexOf("F")+2,t.indexOf("G")),t.includes("O")){const u=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=u.substring(u.indexOf("M")+2,u.indexOf("N")),this.__pinPad__.operation.hasQPS=u.substring(u.indexOf("N")+2,u.indexOf("O"))==="1",this.__pinPad__.operation.bin8=u.substring(u.indexOf("O")+2,u.indexOf(e))}else if(t.includes("N")){const u=t.substring(t.indexOf("P93A"));this.__pinPad__.config.read.ReadCTLS=u.substring(u.indexOf("M")+2,u.indexOf("N")),this.__pinPad__.operation.hasQPS=u.substring(u.indexOf("N")+2,u.indexOf(e))==="1"}else{const u=t.substring(t.indexOf("P93A"),t.indexOf("M")+5);this.__pinPad__.config.read.ReadCTLS=u.substring(u.indexOf("M")+2,u.indexOf(e)),this.__pinPad__.operation.hasQPS=!1}this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),this.__pinPad__.config.read.NB_ksn=t.substring(t.indexOf("K")+2,t.indexOf("M")),this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("D")+2,t.indexOf("E")),s=t.substring(t.indexOf("I")+2,t.indexOf("J")),a=t.substring(t.indexOf("E")+2,t.indexOf("F")),this.__pinPad__.config.read.ChipName=a,r=t.substring(t.indexOf("J")+2,t.indexOf("K"))}else{let u;if(this.__pinPad__.config.read.Chip="0",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ReadCTLS="0",this.__pinPad__.config.read.AppIdLabel=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.Tags=t.substring(t.indexOf("B")+2,t.indexOf("C")),l==="022")if(t.includes("O")){const f=t.substring(t.indexOf("P93A"));this.__pinPad__.operation.bin8=f.substring(f.indexOf("O")+2,f.indexOf(e)),u=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),u=u.substring(u.indexOf("I")+2,u.lastIndexOf(""))}else u=t.substring(t.indexOf("P93A022"),t.indexOf("I")+23),u=u.substring(u.indexOf("I")+2,u.indexOf(e));else u=t.substring(t.indexOf("P93A800"),t.indexOf("I")+23),u=u.substring(u.indexOf("I")+2,u.indexOf(e));this.__pinPad__.config.read.NB_ksn=u,this.__pinPad__.config.read.NB_Data=t.substring(t.indexOf("B")+2,t.indexOf("C")),s=t.substring(t.indexOf("F")+2,t.indexOf("G")),r=t.substring(t.indexOf("G")+2,t.indexOf("H")),this.__pinPad__.about.model?.toLowerCase()==="vx520"?(a=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=a):(a=t.substring(t.indexOf("H")+2,t.indexOf("I")),this.__pinPad__.config.read.ChipName=a)}r.includes("/")&&(r=r.replace("/","")),r.toString().length===4?(c=r.toString().substring(0,2),o=r.toString().substring(2)):(c="",o=""),this.__pinPad__.config.read.Chip==="1"?(this.__pinPad__.config.read.EMV="3",this.__pinPad__.config.read.ChipNameEnc="1"):(this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.config.read.EMV="2"),this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("american")||this.__pinPad__.config.read.AppIdLabel.toLowerCase().includes("amex")?this.__pinPad__.config.read.Type="AMEX":this.__pinPad__.config.read.Type="V/MC",this.__pinPad__.operation.bin=s,s.length>6&&(this.__pinPad__.operation.bin=s.substring(0,6)),this.__pinPad__.waiting.statusReadCardWaiting="resolved",this.dispatch("pp:read-card",{ERROR:"",maskPan:s,name:a,month:c,year:o})}#x(t,e){e.length>10&&e.includes("E93A10")&&(this.__pinPad__.waiting.statusReadCardWaiting==="pending"&&(this.__pinPad__.waiting.statusReadCardWaiting="rejected"),this.dispatch("pp:error",{message:"Operation cancelled by user."}))}#V(t,e){if(this.__pinPad__.about.model?.toLowerCase()==="vx520"){if(e.length>11)if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(()=>{this.print("client").then(()=>{}).catch(n=>{console.error(n)})},1e3):this.dispatch("pp:print",{type:"success"});else{const n=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",n)}}else if(e.includes("P59A00"))this.__pinPad__.operation.clientVoucher!==""?setTimeout(()=>{this.print("client").then(()=>{}).catch(n=>{console.error(n)})},1e3):this.dispatch("pp:print",{type:"success"});else{const n=e.includes("E17")||e.includes("A17")?{type:"warning",message:"printer without paper"}:{type:"error",message:"The voucher could not be printed"};this.dispatch("pp:print",n)}}#U(t,e){console.log(t,e)}#L(t,e){console.log(t,e)}serialMessage(t){const e={original_code:t,code:null,name:null,description:null,request:this.lastAction,no_code:0,parsed:null},n=this.parseHexToUint8(t),r=this.parseUint8ArrayToString(n),s=this.#R(r);switch(this.__pinPad__.buffer=r,e.parsed=s,e.code=r,e.request){case"connect":e.name="connected",e.description="Connection established",e.no_code=100,this.#f(s,r);break;case"about":e.name="About PinPad",e.description="Response of about",e.no_code=101,this.#f(s,r);break;case"inject":e.name="Inject",e.description="Response of inject values",e.no_code=102,this.#C();break;case"init-dukpt":e.name="Init DUKPT",e.description="Response of init DUKPT",e.no_code=103,this.#O(s,r);break;case"dukpt":e.name="Write DUKPT",e.description="Response of write DUKPT",e.no_code=104,this.#D();break;case"read-card":e.name="read card",e.description="response of read card",e.no_code=105,this.#I(s,r);break;case"second-generate":e.name="second generate",e.description="response of second generate",e.no_code=106,this.#N(s,r);break;case"cancel":e.name="cancel pinpad",e.description="response of cancel",e.no_code=107;break;case"print":this.#V(s,r),e.name="print voucher",e.description="response of print",e.no_code=108;break;case"cancel-read-card":this.#x(s,r),e.name="cancel read card",e.description="response of cancel read card",e.no_code=109;break;case"code93":this.#U(s,r),e.name="code 93",e.description="response of code 93",e.no_code=110;break;case"finish-emv-end":this.#L(s,r),e.name="Finish EMV End",e.description="response of finish EMV End",e.no_code=111;break;default:e.name="unknown",e.description="Unknown command",e.no_code=400;break}this.dispatch("serial:message",e)}serialSetConnectionConstant(){let n="C56AABOUT";n=""+n.length.toString().padStart(3,"0")+n+"";let r=0;for(let a=0;a<n.length;a++)r^=n.charCodeAt(a);n=n+String.fromCharCode(r);const s=this.parseStringToBytes(n,"");return this.add0x(s)}async sendCustomCode({code:t=""}={}){if(typeof t!="string")throw new Error("Invalid string");const e=this.parseStringToBytes(t);await this.appendToQueue(e,"custom")}set username(t){this.__pinPad__.config.username=t}get username(){return this.__pinPad__.config.username}set password(t){if(typeof t!="string")throw new Error("Invalid password");this.__pinPad__.config.password=t.toUpperCase()}get password(){return this.__pinPad__.config.password}set amount(t){if(t=parseFloat(t),isNaN(t)||t<=0)throw new Error("Invalid amount");this.__pinPad__.operation.amount=t.toFixed(2).toString()}get amount(){return parseFloat(this.__pinPad__.operation.amount)||0}set reference(t){if(!this.#g(t.trim()))throw new Error("Invalid reference");this.__pinPad__.operation.reference=t.trim().toString().replaceAll(" ","").toUpperCase()}get reference(){return this.__pinPad__.operation.reference||""}get url(){const t=this.environment;return this.__pinPad__.constants.urls[t]}get version(){return{name:this.__pinPad__.constants.appName,version:this.__pinPad__.constants.appVersion,environment:this.environment,type:this.typeDevice}}set environment(t){const e=["development","qa","production","productionAlternative"];if(typeof t!="string"||!e.includes(t.toLowerCase()))throw new Error("The environment must be a string, in: "+e.join(", "));this.__pinPad__.config.defaultEnvironment=t.toLowerCase(),this.__pinPad__.config.environment=t.toLowerCase()}get defaultEnvironment(){return this.__pinPad__.config.defaultEnvironment}get environment(){return this.__pinPad__.config.environment}get latitudeLongitude(){return{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude}}set timeoutPinPad(t){if(t=parseInt(t),isNaN(t)||t<=10||t>=300)throw new Error("Invalid timeout please use a number between 10 and 300 seconds");this.__pinPad__.config.timeoutPinPad=t.toString()}get timeoutPinPad(){return parseInt(this.__pinPad__.config.timeoutPinPad)}#s(t,e){const n=new Yn;return n.setPublicKey(t),n.encrypt(e)}#a(t){const e="0123456789ABCDEF";let n="";for(let r=0;r<t;r++){const s=Math.floor(Math.random()*e.length);n+=e.substring(s,s+1)}return n}#M(t){const e="0123456789abcdef",n=[],r=[];for(let s=0;s<256;s++)n[s]=e.charAt(s>>4)+e.charAt(s&15);for(let s=0;s<t.length;s++)r[s]=n[t.charCodeAt(s)];return r.join("")}async#o(t,e){const n=t.match(/.{1,2}/g)||[],r=new Uint8Array(n.map(_=>parseInt(_,16))),s=crypto.getRandomValues(new Uint8Array(16)),o=new TextEncoder().encode(e),c=await crypto.subtle.importKey("raw",r,{name:"AES-CBC"},!1,["encrypt"]),l=await crypto.subtle.encrypt({name:"AES-CBC",iv:s},c,o),u=btoa(String.fromCharCode(...s)),f=btoa(String.fromCharCode(...new Uint8Array(l)));return u+f}#F(t,e,n=!1){const r=[];for(let l=0;l<256;l++)r[l]=l;let s=0;for(let l=0;l<256;l++)s=(s+r[l]+t.charCodeAt(l%t.length))%256,[r[l],r[s]]=[r[s],r[l]];let a=0,o=0,c="";for(const l of e){a=(a+1)%256,o=(o+r[a])%256,[r[a],r[o]]=[r[o],r[a]];const u=r[(r[a]+r[o])%256];c+=String.fromCharCode(l.charCodeAt(0)^u)}return n?this.#M(c).toUpperCase():c}#i(t,e){return this.#F(t,this.hexToAscii(e))}#k(t){return t.replaceAll("Á","A"),t.replaceAll("É","E"),t.replaceAll("Í","I"),t.replaceAll("Ó","O"),t.replaceAll("Ú","U"),t.replaceAll("á","a"),t.replaceAll("é","e"),t.replaceAll("í","i"),t.replaceAll("ó","o"),t.replaceAll("ú","u"),t.replaceAll("ñ","n"),t.replaceAll("Ñ","N"),t.replaceAll('Electr?a"',"Electronica"),t}#t(t,e,n){if(t=t.replace("@cnb logo_cpagos",e),t=t.replace("@cnn ver_app",n),t=t.replace(/@/g," @"),t=t.replace(/ {2}@/g," @"),t=t.replace(/ {3}@/g," @"),t=t.replace(/\r/g,""),t=t.replace(/\n/g,""),t.includes("@lsn POR ESTE PAGARE ME OBLIGO INCONDI")){const r=t.indexOf("@lsn POR ESTE PAGARE ME OBLIGO INCONDI");t=t.substring(0,r)}return t.trim()+"@br @br @br @br @br"}#j(t,e){const n="@logo3 @br",r="@cnn "+e;return t.includes("@cnb Santander")?(t=t.replace("@cnb Santander","@logo1@br"),this.#t(t,n,r)):t.includes("@cnb American Express")?(t=t.replace("@cnb American Express","@logo2@br"),this.#t(t,n,r)):t.includes("@cnb HSBC")?(t=t.replace("@cnb HSBC","@logo7@br"),this.#t(t,n,r)):t.includes("@cnb IXE")?(t=t.replace("@cnb IXE","@logo11@br"),this.#t(t,n,r)):t.includes("@cnb MULTIVA")?(t=t.replace("@cnb MULTIVA","@logo15@br"),this.#t(t,n,r)):t.includes("@cnb Multiva")?(t=t.replace("@cnb Multiva","@logo15@br"),this.#t(t,n,r)):t.includes("@cnb SCOTIA BANK")?(t=t.replace("@cnb SCOTIA BANK","@logo16@br"),this.#t(t,n,r)):t.includes("@cnb SCOTIABANK")?(t=t.replace("@cnb SCOTIABANK","@logo16@br"),this.#t(t,n,r)):t.includes("@cnb BANCOMER")?(t=t.replace("@cnb BANCOMER","@logo17@br"),this.#t(t,n,r)):t.includes("@cnb Bancomer")?(t=t.replace("@cnb Bancomer","@logo17@br"),this.#t(t,n,r)):t.includes("@cnb BBVA")?(t=t.replace("@cnb BBVA","@logo17@br"),this.#t(t,n,r)):t.includes("@cnb BANORTE")?(t=t.replace("@cnb BANORTE","@logo18@br"),this.#t(t,n,r)):t.includes("@cnb Banorte")?(t=t.replace("@cnb Banorte","@logo18@br"),this.#t(t,n,r)):t.includes("@cnb BANREGIO")?(t=t.replace("@cnb BANREGIO","@logo19@br"),this.#t(t,n,r)):t.includes("@cnb Banregio")?(t=t.replace("@cnb Banregio","@logo19@br"),this.#t(t,n,r)):t.includes("@cnb GETNET")?(t=t.replace("@cnb GETNET","@logo20@br"),this.#t(t,n,r)):t.includes("@cnb GetNET")?(t=t.replace("@cnb GetNET","@logo20@br"),this.#t(t,n,r)):this.#t(t,n,r)}async#q(t=!1){if(this.#H(),this.__pinPad__.config.loginResponse&&!t)return await this.#p();const e=this.url+this.__pinPad__.constants.uris.login,n={usuario:this.username,password:this.password,crypto:"",version:this.__pinPad__.constants.appVersion,serieLector:"",canal:this.__pinPad__.constants.appChannel};if(await this.#c(),this.#d())throw new Error("Empty RSA Key");const r=this.#a(32),s=this.#s(this.__pinPad__.config.publicKeyRSA||"",r),a=await this.#o(r,JSON.stringify(n)),o=await A.post(e,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0",data:s||""}}).catch(u=>{throw new Error(`Error in request, verify internet connection: ${u.response?.status} ${u.message}`)}),c=this.#b(JSON.stringify(o.data));let l=c;if(typeof c=="string"&&(l=JSON.parse(c)),!l)throw new Error("Invalid response JSON");if(l.RESPUESTA==="error")throw new Error(l);return this.__pinPad__.config.loginResponse=l,localStorage.setItem("ppLoginResponse",JSON.stringify({timestamp:new Date().getTime(),data:l})),await this.#p()}async#p(){await this.#G();try{await this.getPosition()}catch(t){console.log("Error getting position",t)}return this.__pinPad__.config.otherLogin={},this.#K(this.__pinPad__.config.loginResponse),this.__pinPad__.config.otherLogin}#K(t){let e="",n="";t.xml?.ventaspropias?.merchant_currencyb&&(e=t.xml.ventaspropias.merchant_currencyb),t.xml?.ventaspropias?.merchant_currencym&&(n=t.xml.ventaspropias.merchant_currencym);let r=t.xml?.emvReverso;r||(r="0");const s=t.xml?.st_tokenizacion;!s||s==="false"||s==="0"?this.__pinPad__.config.internal.stTokenization=!1:this.__pinPad__.config.internal.stTokenization&&(this.__pinPad__.config.internal.stTokenization=!0),this.__pinPad__.config.internal.emv=t.xml.importesPGS,this.__pinPad__.config.internal.qpsDomestic=this.__pinPad__.config.internal.emv.qps_dom,this.__pinPad__.config.internal.qpsInternational=this.__pinPad__.config.internal.emv.qps_il,this.__pinPad__.config.internal.cvmlVMCDomestic=this.__pinPad__.config.internal.emv.cvml_vm_dom,this.__pinPad__.config.internal.cvmlVMCInternational=this.__pinPad__.config.internal.emv.cvml_vm_il,this.__pinPad__.config.internal.cvmlAmex=this.__pinPad__.config.internal.emv.cvml_amex,this.__pinPad__.config.internal.translimitCTLSVMC=this.__pinPad__.config.internal.emv.tl_mc,this.__pinPad__.config.internal.translimitCTLSAmex=this.__pinPad__.config.internal.emv.tl_amex,this.__pinPad__.config.country=t.country.toUpperCase(),this.__pinPad__.config.idBranch=t.id_branch.toUpperCase(),this.__pinPad__.config.idCompany=t.id_company.toUpperCase(),this.__pinPad__.config.otherLogin={bsUser:t.user,nbUser:t.nb_user,bsCompany:t.id_company,nbCompany:t.nb_company,nbStreetCompany:t.nb_companystreet,bsBranch:t.id_branch,nbBranch:t.nb_branch,bsCountry:t.country,coins:e,coinsMOTO:n,executeReverse:r}}#H(){const t=localStorage.getItem("ppLoginResponse");let e=null;t&&(e=JSON.parse(t),this.__pinPad__.config.loginResponse||(this.__pinPad__.config.loginResponse=e?.data),new Date().getTime()-e?.timestamp>=864e5&&(this.__pinPad__.config.loginResponse=null))}async login({force:t=!1}={}){return await this.#q(t)}async#W(){const t=this.url+this.__pinPad__.constants.uris.RSAKey,e=await A.get(t).catch(r=>{throw new Error(`Error in request, verify internet connection: ${r.response.status} ${r.message}`)});if(!e)return"";const n=e.headers;if(!n)return"";if(n.get("content-type").indexOf("application/json")===-1)throw new Error("Fail to fetch RSA public key");return this.__pinPad__.config.publicKeyRSA=e.data.key_public,localStorage.setItem("ppRSAKey",JSON.stringify({timestamp:new Date().getTime(),data:e.data.key_public})),this.__pinPad__.config.publicKeyRSA}clearSession(){localStorage.removeItem("ppLoginResponse"),localStorage.removeItem("ppRSAKey"),localStorage.removeItem("ppPublicIP")}#d(){const t=localStorage.getItem("ppRSAKey");if(!t)return!0;const e=JSON.parse(t);return!e.data||(this.__pinPad__.config.publicKeyRSA=e.data,new Date().getTime()-e.timestamp>=864e5)?!0:!this.__pinPad__.config.publicKeyRSA}async#_(){return this.#d()?await this.#W():this.__pinPad__.config.publicKeyRSA}async#c(){if(!await this.#_())throw new Error("RSA public key is empty")}#g(t){return/^[A-Z-a-z0-9\s]+$/g.test(t)}#X(t){if(x.isEmpty(t))return!0;const e=/^[A-Z-a-z0-9\s]+$/g.test(t)===!0;if(!e)throw new Error("Invalid reference");return e}#e(t){return t.length.toString().padStart(3,"0")}#n(t){let e=0;for(let n=0;n<t.length;n++)e^=t.charCodeAt(n);return String.fromCharCode(e)}#l(t,e=0){return t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)?0 .toFixed(e):t.toFixed(e).replace(/,/g,"")}#m(t){return t=parseFloat(t.toString()),!(isNaN(t)||t<0)}async#u(t){for(const e in t)if(typeof t[e]>"u"||t[e]===null||t[e]==="")throw new Error("Object incomplete to process");return t}#y(t){if(!t||isNaN(parseInt(t))||t.toString().length!==9)throw new Error("Number of operation must be number of 9 digits");return t}#b(t){if(typeof t!="string")throw new Error("Invalid string");return!t||/<html(?:\s+lang=["'][^"']*["'])?>/i.test(t)||(t=t.replace(/aaa/g,"á"),t=t.replace(/eee/g,"é"),t=t.replace(/iii/g,"í"),t=t.replace(/ooo/g,"ó"),t=t.replace(/uuu/g,"ú"),t=t.replace(/NNN/g,"Ñ"),t=t.replace(/nnn/g,"ñ"),t=t.replace(/á/g,"á")),t}async#z(){const t=this.__pinPad__.constants.STX,e=this.__pinPad__.constants.ETX;let n="C55ACANCEL";n=t+this.#e(n)+n+e,n=n+this.#n(n);const r=this.parseStringToBytes(n,"");await this.appendToQueue(r,"cancel")}#P(){const t=new Date,e=t.getDate().toString().padStart(2,"0"),n=(t.getMonth()+1).toString().padStart(2,"0"),r=t.getFullYear().toString().substring(2);return e+n+r}#v(){const t=new Date,e=t.getHours().toString().padStart(2,"0"),n=t.getMinutes().toString().padStart(2,"0");return e+n}async checkPositionPermission(){if(!x.supportGeolocation())throw new Error("Geolocation not supported");return new Promise((t,e)=>{navigator.permissions.query({name:"geolocation"}).then(n=>{n.state==="granted"?t(!0):t(!1)}).catch(()=>e(!1))})}async getPosition(){return this.__pinPad__.config.latitude&&this.__pinPad__.config.longitude?this.latitudeLongitude:(this.__pinPad__.config.latitude=null,this.__pinPad__.config.longitude=null,x.supportGeolocation()?new Promise(t=>{navigator.geolocation.getCurrentPosition(e=>{this.__pinPad__.config.latitude=e.coords.latitude,this.__pinPad__.config.longitude=e.coords.longitude,t(this.latitudeLongitude)},()=>{t(this.latitudeLongitude)})}):this.latitudeLongitude)}async#G(){const t=localStorage.getItem("ppPublicIP");if(t){const s=JSON.parse(t);this.__pinPad__.config.publicIP=s.data,new Date().getTime()-s.timestamp>=864e5&&(this.__pinPad__.config.publicIP=null)}if(this.__pinPad__.config.publicIP)return this.__pinPad__.config.publicIP;this.__pinPad__.config.publicIP=null;let e=!1;const n=await A.get("https://api.ipify.org?format=json").catch(()=>e=!0);if(e||typeof n!="object"||!n||!n.data)return null;const r=n.data||{};return this.__pinPad__.config.publicIP=r.ip||null,localStorage.setItem("ppPublicIP",JSON.stringify({timestamp:new Date().getTime(),data:r.ip})),this.__pinPad__.config.publicIP}async cancelReadCard(){let t="012VXVCANCELl";this.__pinPad__.about.model?.toLowerCase()==="ingenico"&&(t="029C50AOPERACION CANCELADA");const e=this.parseStringToBytes(t,"");await this.appendToQueue(e,"cancel-read-card")}async print(t="client"){this.__pinPad__.operation.errors=0;const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX;this.__pinPad__.operation.commerceVoucher.includes(":")||(this.__pinPad__.operation.commerceVoucher=this.#i(this.__pinPad__.config.RC4Key,this.__pinPad__.operation.commerceVoucher)),this.__pinPad__.operation.clientVoucher.includes(":")||(this.__pinPad__.operation.clientVoucher=this.#i(this.__pinPad__.config.RC4Key,this.__pinPad__.operation.clientVoucher));let r=t==="client"?this.__pinPad__.operation.clientVoucher:this.__pinPad__.operation.commerceVoucher;if(r.length===0){this.dispatch("pp:print",{error:!0,code:"001",message:"Without information to print"});return}r=this.#k(r),r=this.#j(r,this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion);let s="C59A"+r;s=e+this.#e(s)+s+n,s=s+this.#n(s),t==="client"?this.__pinPad__.operation.clientVoucher="":t==="commerce"&&(this.__pinPad__.operation.commerceVoucher="");const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"print")}async#r(t,e){await this.#c();const n=this.#a(32),r=this.#s(this.__pinPad__.config.publicKeyRSA||"",n),s=await this.#o(n,JSON.stringify(e));return(await A.post(t,s,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:r||""}}).catch(o=>{throw o.response.data.includes("Ha ocurrido un error al procesar su solicitud.")?new Error("It was not possible to obtain the affiliations."):o.response.status>=500&&o.response.status<=599?new Error(`Service Temporarily Unavailable ${o.message}`):new Error(`Error in request, verify internet connection: ${o.response?.status} ${o.message}`)})).data}async#E({data:t,url:e,cancelable:n=!1}={data:null,url:"",cancelable:!1}){await this.#c();const r=this.#a(32),s=this.#s(this.__pinPad__.config.publicKeyRSA||"",r),a=await this.#o(r,JSON.stringify(t)),o=this;return(await A.post(e,a,{headers:{"Content-Type":"application/json","cache-control":"no-cache",data:s||""}}).catch(async l=>{let u=`Error in request, verify internet connection: ${l.status} ${l.message}`;throw l.response.status>=500&&l.response.status<=599?u="Service Temporarily Unavailable":l.response.status>=400&&l.response.status<=499&&(u="Bad Request"),n&&await o.#z(),new Error(u)})).data}async#$(){const t=this.__pinPad__.constants.FS,e=this.__pinPad__.constants.ETX,n=this.__pinPad__.constants.STX;let r="C57A"+this.__pinPad__.config.internal.qpsDomestic;if(r=r+t+"B"+this.__pinPad__.config.internal.qpsInternational,r=r+t+"C"+this.__pinPad__.config.internal.cvmlVMCDomestic,r=r+t+"D"+this.__pinPad__.config.internal.cvmlVMCInternational,r=r+t+"E"+this.__pinPad__.config.internal.cvmlAmex,r=r+t+"F"+this.__pinPad__.config.internal.translimitCTLSVMC,r=r+t+"G"+this.__pinPad__.config.internal.translimitCTLSAmex,r=n+this.#e(r)+r+e,r=r+this.#n(r),!this.__pinPad__.about.injectedValues){const s=this.parseStringToBytes(r,"");await this.appendToQueue(s,"inject")}}async#J(){this.__pinPad__.operation.bin8&&(this.__pinPad__.operation.bin=this.__pinPad__.operation.bin8),this.__pinPad__.operation.bin8="";const t=await this.#E({data:{accion:"tipoPagoInfo",cc_num:this.__pinPad__.operation.bin,usuario:this.username?.toUpperCase(),canal:this.__pinPad__.constants.typeChannel,tp_canal:"1",tp_moneda:this.__pinPad__.config.currency.toUpperCase()},url:this.url+this.__pinPad__.constants.uris.merchant,cancelable:!0});if(!t.respuesta||t.respuesta==="0"){let e="C55ACANCEL";const n=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;e=n+this.#e(e)+e+r,e=e+this.#n(e);const s=this.parseStringToBytes(e,"");return await this.appendToQueue(s,"cancel"),!1}return this.__pinPad__.operation.merchant=t,this.__pinPad__.operation.onlyMerchant=t.contado.af.length>1?t.contado.af[0].merchant:t.contado.af.merchant,!0}async#Q(t=null){if(this.__pinPad__.waiting.statusAboutWaiting)throw new Error("AboutPP is already running");const e=this.__pinPad__.constants.STX,n=this.__pinPad__.constants.ETX;let r="C56AABOUT";if(r=e+this.#e(r)+r+n,r=r+this.#n(r),x.isEmpty(this.__pinPad__.about.pp)){this.__pinPad__.waiting.statusAboutWaiting="pending";const a=this.parseStringToBytes(r,"");await this.appendToQueue(a,"about")}else return t?t(this.__pinPad__.about.pp?.supportDUKPT||!1,this.__pinPad__.about.pp?.hasDUKPTKeys||!1):!0;let s=0;return new Promise((a,o)=>{s=setInterval(()=>{if(this.__pinPad__.waiting.statusAboutWaiting==="resolved"){if(clearInterval(s),this.__pinPad__.waiting.statusAboutWaiting=null,x.isEmpty(this.__pinPad__.about.pp))return;if(!t||typeof t!="function"){a(!0);return}const c=t(this.__pinPad__.about.pp?.supportDUKPT||!1,this.__pinPad__.about.pp?.hasDUKPTKeys||!1);a(c)}else this.__pinPad__.waiting.statusAboutWaiting==="rejected"&&(clearInterval(s),this.__pinPad__.waiting.statusAboutWaiting=null,o("Error"))},500)})}async#h(t,e){if(t=t?t.toString():"",e=e?e.toString():"",x.isEmpty(t)||t==="0"){this.dispatch("pp:dukpt",{status:"unsupported",already:!1});return}if(x.isEmpty(e)||e==="1"){this.dispatch("pp:dukpt",{status:"charged",already:!0});return}const n=this.#P(),r=this.#v(),s=this.__pinPad__.constants.FS,a=this.__pinPad__.constants.ETX,o=this.__pinPad__.constants.STX;let c="C91A"+n+s+"B"+r;c=o+this.#e(c)+c+a,c=c+this.#n(c);const l=this.parseStringToBytes(c,"");await this.appendToQueue(l,"init-dukpt");let u=0;return this.__pinPad__.waiting.statusinitDUKPTWaiting="pending",new Promise((f,_)=>{u=setInterval(async()=>{this.__pinPad__.waiting.statusinitDUKPTWaiting==="resolved"?(clearInterval(u),this.__pinPad__.waiting.statusinitDUKPTWaiting=null,this.dispatch("pp:dukpt",{status:"charged",already:!1}),await this.#Z(),f(!0)):this.__pinPad__.waiting.statusinitDUKPTWaiting==="rejected"&&(clearInterval(u),this.__pinPad__.waiting.statusinitDUKPTWaiting=null,_("Error"))},500)})}async#Z(){const t={IPEK_REQUESTType:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},terminal:this.__pinPad__.config.terminal}},e=await this.#E({data:t,url:this.url+this.__pinPad__.constants.uris.keysDUKPT});await this.#lt(e)}async#Y(){if(!await this.#_())throw new Error("RSA public key is empty");const e=this;await this.#Q(async function(r,s){if(e.__pinPad__.about.supportInjection&&e.__pinPad__.config.internal.emv&&e.__pinPad__.about.injectedValues)return await e.#h(r,s),!0;let a=0;return e.__pinPad__.waiting.statusInjectWaiting="pending",await e.#$(),new Promise((o,c)=>{a=setInterval(async()=>{e.__pinPad__.waiting.statusInjectWaiting==="resolved"?(clearInterval(a),e.__pinPad__.waiting.statusInjectWaiting=null,await e.#h(r,s),o(!0)):e.__pinPad__.waiting.statusInjectWaiting==="rejected"&&(clearInterval(a),e.__pinPad__.waiting.statusInjectWaiting=null,c("Error"))},500)})})}#w(t,e=0){if(t=parseFloat(t.toString().replace(/[^0-9.-]/g,"")),isNaN(t)||t===0)return parseFloat("0").toFixed(e);t=t.toFixed(e);const n=t.split(".");return n[0]=n[0].replace(/\B(?=(\d{3})+(?!\d))/g,""),n.join(".")}getClientVoucher(){return this.__pinPad__.operation.clientVoucher}getCommerceVoucher(){return this.__pinPad__.operation.commerceVoucher}async#tt(){this.__pinPad__.operation.errors=0;let t="ACERQUE, INSERTE CHIP O DESLICE TARJETA";if(this.__pinPad__.about.supportContactless||(t="INSERTE CHIP O DESLICE TARJETA"),this.__pinPad__.about.model?.toUpperCase().includes("UX300")&&(t="ACERQUE O INSERTE TARJETA"),x.isEmpty(this.amount)||isNaN(parseFloat(this.amount)))throw new Error("Amount required");if(parseFloat(this.amount)<=0)throw new Error("Amount must be greater than 0");if(this.#m(this.amount)===!1)throw new Error("Invalid amount required");if(parseFloat(this.#l(this.amount,2))<=0)throw new Error("Amount must be greater than 0");const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;let s="C93A"+t;s=s+e+"B"+this.#P(),s=s+e+"C"+this.#v(),s=s+e+"D"+this.#l(this.amount,2),s=s+e+"E0.00",s=s+e+"F"+this.__pinPad__.config.currencyCode,this.__pinPad__.about.supportDUKPT&&this.__pinPad__.about.supportDUKPT!=="0"&&this.__pinPad__.about.supportDUKPT!=="false"&&(this.__pinPad__.about.supportContactless?(s=s+e+"G"+this.timeoutPinPad,s=s+e+"HTAGS",s=s+e+"I"+this.__pinPad__.config.requireCVVAmex,s=s+e+"J"+this.__pinPad__.config.forceOnline,s=s+e+"K"+this.__pinPad__.about.supportContactless,s=s+e+"L"+this.__pinPad__.config.emvCard,this.__pinPad__.about.hasCashback&&(s=s+e+"M0",s=s+e+"N00")):(s=s+e+"G"+this.timeoutPinPad,s=s+e+"HTAGS",s=s+e+"I"+this.__pinPad__.config.requireCVVAmex,s=s+e+"L"+this.__pinPad__.config.emvCard),this.__pinPad__.about.supportInjection&&(s=s+e+"O"+this.__pinPad__.config.validateQPS)),s=n+this.#e(s)+s+r,s=s+this.#n(s),this.#ht();const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"read-card");let o=0;return this.__pinPad__.waiting.statusReadCardWaiting="pending",new Promise((c,l)=>{o=setInterval(()=>{if(this.__pinPad__.waiting.statusReadCardWaiting==="resolved")clearInterval(o),this.__pinPad__.waiting.statusReadCardWaiting=null,c(!0);else if(this.__pinPad__.waiting.statusReadCardWaiting==="rejected"){clearInterval(o),this.__pinPad__.waiting.statusReadCardWaiting=null;const u=this.__pinPad__.operation.last_error;l(u??"Error reading card")}},500)})}async#et(t){return await x.wait(t*1e3)}async consult({reference:t=null}={reference:null}){return t||(t=this.reference),x.isEmpty(t)&&(t="--",this.reference=t),this.#X(this.reference),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await this.#u({Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_Date:this.__pinPad__.operation.consultDate}),this.#r(this.url+this.__pinPad__.constants.uris.consult,{user:this.username?.toUpperCase(),pwd:this.password?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async#nt(t){let e=this.url+this.__pinPad__.constants.uris.consult;return t>1&&this.environment==="production"&&(e=e.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative)),this.__pinPad__.operation.consultDate=new Date().toLocaleDateString("en-GB"),await this.#r(e,{user:this.username?.toUpperCase(),pwd:this.password?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),date:this.__pinPad__.operation.consultDate,reference:this.reference})}async#it(t="",e={}){let n=1,r=null;do{n>1&&this.environment==="production"&&(t=t.replace(this.__pinPad__.constants.urls.production,this.__pinPad__.constants.urls.productionAlternative),await this.#et(5)),await this.#c();const s=this.#a(32),a=this.#s(this.__pinPad__.config.publicKeyRSA||"",s),o=await this.#o(s,JSON.stringify(e));let c=!1;const l=await A.post(t,o,{headers:{"Content-Type":"application/json",data:a||""}}).catch(async u=>{let f=`Error in request, verify internet connection: ${u.status} ${u.message}`;u.response.status>=500&&u.response.status<=599?f="Service Temporarily Unavailable":u.response.status>=400&&u.response.status<=499&&(f="Bad Request"),console.warn(u),r=f;const _=await this.#nt(n);_&&_!=="{}"&&!_.includes('"transacciones":""')&&_.includes("nu_operaion")&&(n=5,r="EE32"),c=!0});if(!c){if(!l||typeof l!="object"||!l.data){r="It was not possible to obtain the affiliations.";continue}return l.data}}while(n++<=3);return r?Promise.reject(r):Promise.reject("Communication error with CDP. IL/MTY")}#rt(t){if(x.isEmpty(t))throw new Error("Number of authorization invalid");if(/^[A-Za-z0-9]+$/g.test(t)!==!0)throw new Error("Number of authorization invalid");if(t.length!==6)throw new Error("Number of authorization invalid");return!0}async rePrint({folio:t=null}={}){let e="";t===null&&(e=this.__pinPad__.operation.folio||""),this.#y(e),await this.#u({Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,Tx_OperationNumber:e});const n=await this.#r(this.url+this.__pinPad__.constants.uris.rePrint,{REPRINTVOUCHER:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},no_operacion:t,crypto:"2"}});let r=n.voucher_comercio;return this.__pinPad__.operation.commerceVoucher="",r&&(n.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=n.voucher_comercio:this.__pinPad__.operation.commerceVoucher=this.#i(this.__pinPad__.config.RC4Key,n.voucher_comercio)),r=n.voucher_cliente,this.__pinPad__.operation.clientVoucher="",r&&(n.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=n.voucher_cliente:this.__pinPad__.operation.clientVoucher=this.#i(this.__pinPad__.config.RC4Key,n.voucher_cliente)),n}#st(t){this.__pinPad__.operation.responseMit._approved=t.response==="approved",this.__pinPad__.operation.responseMit._status=t.response,this.__pinPad__.operation.responseMit._originalToken=t.number_tkn??"",this.__pinPad__.operation.folio=t.foliocpagos,this.__pinPad__.operation.authorization=t.auth;let e=t.cd_response?.toUpperCase();return e.toUpperCase()==="0C"||this.__pinPad__.operation.responseMit._approved?e="00":(e!=="Z3"&&e!=="05"||t.cd_error==="92")&&(e="01"),this.__pinPad__.operation.responseMit._cdResponse=e,this.__pinPad__.finishCommand.A=e,this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E=t.emv_key_date?t.emv_key_date:"",this.__pinPad__.finishCommand.F=t.icc_csn?t.icc_csn:"",this.__pinPad__.finishCommand.G=t.icc_atc?t.icc_atc:"",this.__pinPad__.finishCommand.H=t.icc_arpc?t.icc_arpc:"",this.__pinPad__.finishCommand.I=t.icc_issuer_script?t.icc_issuer_script:"",this.__pinPad__.finishCommand.J=t.authorized_amount?t.authorized_amount:"",this.__pinPad__.finishCommand.K=t.account_balance_1?t.account_balance_1:"",{reference:t.reference,response:t.response,foliocpagos:t.foliocpagos,auth:t.auth,cd_response:e,cd_error:t.cd_error,nb_error:this.#b(t.nb_error??""),time:t.time,date:t.date,nb_company:t.nb_company,nb_merchant:t.nb_merchant,nb_street:t.nb_street,cc_type:t.cc_type,tp_operation:t.tp_operation,cc_name:t.cc_name,cc_number:t.cc_number,cc_expmonth:t.cc_expmonth,cc_expyear:t.cc_expyear,amount:t.amount,voucher_comercio:t.voucher_comercio,voucher_cliente:t.voucher_cliente,friendly_response:t.friendly_response,appid:t.appid,appidlabel:t.appidlabel,arqc:t.arqc}}async cancelPurchase({amount:t=0,authorization:e="",folio:n=""}={}){if(!this.#m(t))throw new Error("Invalid amount");if(!this.#rt(e))throw new Error("Invalid authorization");if(!this.#y(n))throw new Error("Invalid folio");const r=this.#w(t,2),s={Ambiente:this.environment,User:this.username,Pwd:this.password,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,Country:this.__pinPad__.config.country,UserTRX:"userPinpadWeb",Tx_OperationNumber:n,Tx_Auth:e,Amount:r};await this.#u(s);const a=await this.#r(this.url+this.__pinPad__.constants.uris.cancellation,{VMCAMEXMCANCELACION:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},transacction:{amount:t,auth:e.toUpperCase(),crypto:"2",no_operacion:n,usrtransacction:this.username?.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}});return this.__pinPad__.operation.commerceVoucher="",a.voucher_comercio&&(a.voucher_comercio.includes(":")?this.__pinPad__.operation.commerceVoucher=a.voucher_comercio:this.__pinPad__.operation.commerceVoucher=this.#i(this.__pinPad__.config.RC4Key,a.voucher_comercio)),this.__pinPad__.operation.clientVoucher="",a.voucher_cliente&&(a.voucher_cliente.includes(":")?this.__pinPad__.operation.clientVoucher=a.voucher_cliente:this.__pinPad__.operation.clientVoucher=this.#i(this.__pinPad__.config.RC4Key,a.voucher_cliente)),JSON.stringify(a)}async#at(){this.__pinPad__.operation.errors=0,this.__pinPad__.operation.ignore.counterSale=!1;const t=this.__pinPad__.operation.onlyMerchant;if(/^[0-9]+$/.test(t)===!1)throw new Error("Invalid merchant");this.__pinPad__.operation.typeOperation="29";const e={error:!1,message:null,approved:!1,object:{}};try{const n=await this.#w(this.amount,2);await this.#u({Ambiente:this.environment,Country:this.__pinPad__.config.country,IdBranch:this.__pinPad__.config.idBranch,IdCompany:this.__pinPad__.config.idCompany,pwd:this.password,User:this.username,UserTRX:"userPinpadWeb",EMV:this.__pinPad__.config.read.EMV,ModeloTerminal:this.__pinPad__.about.model,SerieTerminal:this.__pinPad__.about.serial,Contactless:this.__pinPad__.about.supportContactless,Printer:this.__pinPad__.about.printer,VersionTerminal:this.__pinPad__.about.appVersion,TpOperation:this.__pinPad__.operation.typeOperation,Reference:this.reference,Amount:n,Currency:this.__pinPad__.config.currency,Merchant:t,Reverse:this.__pinPad__.config.otherLogin.executeReverse});let r=this.__pinPad__.about.supportContactless;typeof r=="string"&&(r=r!=="0");const s=this.__pinPad__.about.supportContactless&&r,a=await this.#it(this.url+this.__pinPad__.constants.uris.sale,{VMCAMEXB:{business:{country:this.__pinPad__.config.country?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),id_company:this.__pinPad__.config.idCompany?.toUpperCase(),pwd:this.password?.toUpperCase(),user:this.username?.toUpperCase()},dcc:{dcc_amount:"0",dcc_status:"0"},transacction:{amount:n,creditcard:{appid:this.__pinPad__.config.read.AppId,appidlabel:this.__pinPad__.config.read.AppIdLabel,arqc:this.__pinPad__.config.read.Arqc,chip:this.__pinPad__.config.read.Chip,chipname:this.__pinPad__.config.read.ChipName,chipnameenc:this.__pinPad__.config.read.ChipNameEnc,contactless:this.__pinPad__.config.read.ReadCTLS,crypto:"4",dukpt:{nb_data:this.__pinPad__.config.read.NB_Data,nb_ksn:this.__pinPad__.config.read.NB_ksn,tp_dukpt:"1"},pin:this.__pinPad__.config.read.PIN,posentrymode:this.__pinPad__.config.read.POSEM,tags:this.__pinPad__.config.read.Tags,type:this.__pinPad__.config.read.Type},currency:this.__pinPad__.config.currency.toUpperCase(),emv:this.__pinPad__.config.read.EMV,merchant:this.__pinPad__.operation.onlyMerchant,modelo_terminal:this.__pinPad__.about.model,reference:this.reference,serie:this.__pinPad__.about.serial,terminal:{display:"1",is_contactless:s,is_mobile:"0",printer:this.__pinPad__.about.printer},tp_operation:this.__pinPad__.operation.typeOperation,tp_resp:this.__pinPad__.operation.typeResponse,usrtransacction:this.username?.toUpperCase(),version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion,version_terminal:this.__pinPad__.about.appVersion},geolocation:{latitude:this.__pinPad__.config.latitude,longitude:this.__pinPad__.config.longitude,ip:this.__pinPad__.config.publicIP}}});a.response==="error"&&(e.error=!0,e.message=a.nb_error||"Error in response");const o=this.#st(a);return e.object=o,await this.#ot(o),e.approved=this.__pinPad__.operation.responseMit._approved,this.__pinPad__.operation.finalResult=o,e}catch(n){throw this.__pinPad__.finishCommand.A="01",this.__pinPad__.finishCommand.B="",this.__pinPad__.finishCommand.C="",this.__pinPad__.finishCommand.D="",this.__pinPad__.finishCommand.E="",this.__pinPad__.finishCommand.F="",this.__pinPad__.finishCommand.G="",this.__pinPad__.finishCommand.H="",this.__pinPad__.finishCommand.I="",this.__pinPad__.finishCommand.J="",this.__pinPad__.finishCommand.K="",await this.#ut(this.#T(n)),n}}async#ot(t){if(this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")return this.dispatch("pp:finish-emv",t),!0;const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;let s="C93A"+this.__pinPad__.finishCommand.A;s=s+e+"B"+this.__pinPad__.finishCommand.B,s=s+e+"C"+this.__pinPad__.finishCommand.C,s=s+e+"D"+this.__pinPad__.finishCommand.D,s=s+e+"E"+this.__pinPad__.finishCommand.E,s=s+e+"F"+this.__pinPad__.finishCommand.F,s=s+e+"G"+this.__pinPad__.finishCommand.G,s=s+e+"H"+this.__pinPad__.finishCommand.H,s=s+e+"I"+this.__pinPad__.finishCommand.I,s=s+e+"J"+this.__pinPad__.finishCommand.J,s=s+e+"K"+this.__pinPad__.finishCommand.K,s=n+this.#e(s)+s+r,s=s+this.#n(s);const a=this.parseStringToBytes(s,"");this.__pinPad__.waiting.statusSecondGenerateWaiting="pending",await this.appendToQueue(a,"second-generate");let o=0;return new Promise((c,l)=>{o=setInterval(async()=>{if(this.__pinPad__.waiting.statusSecondGenerateWaiting==="resolved"){if(clearInterval(o),this.__pinPad__.waiting.statusSecondGenerateWaiting=null,this.__pinPad__.operation.applyReverse){const u=await this.#r(this.url+this.__pinPad__.constants.uris.reverse,{VMCAMEXMREVERSO:{business:{id_company:this.__pinPad__.config.idCompany?.toUpperCase(),id_branch:this.__pinPad__.config.idBranch?.toUpperCase(),country:this.__pinPad__.config.country?.toUpperCase(),user:this.username?.toUpperCase(),pwd:this.password?.toUpperCase()},transacction:{amount:this.#l(this.amount,2),no_operacion:this.__pinPad__.operation.folio,auth:this.__pinPad__.operation.authorization?.toUpperCase(),tracks:"",usrtransacction:this.username?.toUpperCase(),crypto:"2",version:this.__pinPad__.constants.appName+this.__pinPad__.constants.appVersion}}}),f=JSON.parse(u);let _;f.response==="approved"?_={message:"Transaction rejected by PinPad."}:_={message:"No communication, please check your report."},this.__pinPad__.operation.ignore.counterSale||(this.dispatch("pp:finish-emv",_),this.__pinPad__.operation.ignore.counterSale=!0)}else this.__pinPad__.operation.ignore.counterSale||(this.dispatch("pp:finish-emv",t),this.__pinPad__.operation.ignore.counterSale=!0);t.cd_error==="92"&&await this.#ct(t,s),c(!0)}else this.__pinPad__.waiting.statusSecondGenerateWaiting==="rejected"&&(clearInterval(o),this.__pinPad__.waiting.statusSecondGenerateWaiting=null,l("There is no response from the reader, check that it is connected."))},500)})}async#ct(t,e){this.__pinPad__.operation.ignore.responseGlobal=t,this.__pinPad__.operation.ignore.C93Global=e,this.__pinPad__.operation.ignore.isError92TRX=!0,await this.#h(!0,!1)}async#S(){if(this.__pinPad__.operation.ignore.isError92TRX=!1,this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1")this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal);else{const t=this.parseStringToBytes(this.__pinPad__.operation.ignore.C93Global,"");await this.appendToQueue(t,"code93"),await x.wait(1400),this.dispatch("pp:response",this.__pinPad__.operation.ignore.responseGlobal)}}#T(t){const e={PPE02:"Importe Incorrecto.",A02:"Importe Incorrecto.",PPE03:"No hay respuesta del lector, verifique que se encuentra conectado.",A03:"No hay respuesta del lector, verifique que se encuentra conectado.",PP18:"Sin comunicación, por favor verifique su reporte.",PP24:"Transacción declinada por la PinPad.",A01:"Tarjeta Ilegible.",A04:"No hay planes de pago para esta tarjeta, por favor cambie la tarjeta.",A10:"Operación cancelada por el usuario.",A11:"Proceso cancelado por timeout.",A12:"Lectura errónea de banda/chip.",A13:"Carga de llave fallida.",A14:"Error de lectura de PIN.",A15:"Tarjeta Vencida.",A16:"Problemas al leer el chip.",A17:"Impresora sin Papel.",E17:"Impresora sin Papel.",A21:"Información no almacenada correctamente.",A22:"Tarjeta bloqueada.",A23:"Sin llave de cifrado DUKPT.",A28:"Fallback no soportado.",EE19:"Error de conexión, verifique su reporte.",EE21:"Ha ocurrido un error al procesar su solicitud.",EE22:"Ha ocurrido un error de conexión al servidor.",EE23:"El número de operación no puede ir vacío.",EE24:"El número de operación debe ser de 9 dígitos.",EE25:"El número de operación debe ser numérico.",EE26:"La información enviada al servicio está incompleta.",EE27:"La referencia contiene caracteres inválidos o está vacía.",EE28:"Número de autorización inválido.",EE29:"Importe inválido.",EE30:"La información enviada al servicio no es válida.",EE31:"No fue posible obtener las afiliaciones.",EE32:"Error de conexión, existe una o más transacciones en el servidor , Favor de validar su reporte y en su caso reimprimir el voucher.",EE33:"Error de comunicacion con CDP. IL/MTY",EE20:"La Referencia contiene caracteres inválidos",EE99:"Error código 99."},n=e[t]?{error:t,message:e[t]}:{error:t,message:"Error desconocido"};return this.dispatch("pp:error",n),n}async#ut(t){const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.STX,r=this.__pinPad__.constants.ETX;let s="C93A"+this.__pinPad__.finishCommand.A;if(s=s+e+"B"+this.__pinPad__.finishCommand.B,s=s+e+"C"+this.__pinPad__.finishCommand.C,s=s+e+"D"+this.__pinPad__.finishCommand.D,s=s+e+"E"+this.__pinPad__.finishCommand.E,s=s+e+"F"+this.__pinPad__.finishCommand.F,s=s+e+"G"+this.__pinPad__.finishCommand.G,s=s+e+"H"+this.__pinPad__.finishCommand.H,s=s+e+"I"+this.__pinPad__.finishCommand.I,s=s+e+"J"+this.__pinPad__.finishCommand.J,s=s+e+"K"+this.__pinPad__.finishCommand.K,s=n+this.#e(s)+s+r,s=s+this.#n(s),this.__pinPad__.config.read.POSEM==="022"||this.__pinPad__.config.read.POSEM==="800"||this.__pinPad__.config.read.ReadCTLS==="1"){this.dispatch("pp:finish-emv",t);return}const a=this.parseStringToBytes(s,"");await this.appendToQueue(a,"finish-emv-end")}async#lt(t){if(t.cd_estatus=t.cd_estatus?t.cd_estatus:"0",t.cd_estatus!=="1"){this.__pinPad__.operation.ignore.isError92TRX&&await this.#S();return}const e=this.__pinPad__.constants.FS,n=this.__pinPad__.constants.ETX,r=this.__pinPad__.constants.STX,s=t.nb_ksn,a=t.nb_kcv||"",o=t.nb_ipek||"";let c="C92A"+s+e+"B"+a+e+"C"+o;c=r+this.#e(c)+c+n,c=c+this.#n(c);const l=this.parseStringToBytes(c,"");await this.appendToQueue(l,"dukpt");let u=0;return this.__pinPad__.waiting.statuswritingDUKPTWaiting="pending",new Promise((f,_)=>{u=setInterval(async()=>{this.__pinPad__.waiting.statuswritingDUKPTWaiting==="resolved"?(clearInterval(u),this.__pinPad__.waiting.statuswritingDUKPTWaiting=null,this.__pinPad__.operation.ignore.isError92TRX&&await this.#S(),f(!0)):this.__pinPad__.waiting.statuswritingDUKPTWaiting==="rejected"&&(clearInterval(u),this.__pinPad__.waiting.statuswritingDUKPTWaiting=null,_("Error writing DUKPT keys"))},500)})}#ht(){this.__pinPad__.config.read.AppId="",this.__pinPad__.config.read.AppIdLabel="",this.__pinPad__.config.read.Arqc="",this.__pinPad__.config.read.ChipName="",this.__pinPad__.config.read.ReadCTLS="",this.__pinPad__.config.read.NB_Data="",this.__pinPad__.config.read.NB_ksn="",this.__pinPad__.config.read.PIN="",this.__pinPad__.config.read.POSEM="",this.__pinPad__.config.read.Tags="",this.__pinPad__.config.read.Type="",this.__pinPad__.config.read.Chip="",this.__pinPad__.config.read.ChipNameEnc="",this.__pinPad__.operation.ignore.error="",this.__pinPad__.operation.ignore.C93Global="",this.__pinPad__.operation.folio="",this.__pinPad__.operation.authorization="",this.__pinPad__.config.tokenizeTRX=!1}async makeSale({amount:t=0,reference:e=null}={}){if(t=parseFloat(t.toString()),isNaN(t)||t<=0)throw new Error("Amount is required and must be greater than 0");if(this.amount=t,!e||x.isEmpty(e)||!this.#g(e))throw new Error("Reference is required and must be alphanumeric");if(this.reference=e,/^[A-Z-a-z\s]+$/g.test(this.__pinPad__.config.currency)===!1)throw new Error("Invalid currency");const n={error:!1,message:null,approved:!1,object:{}};try{return await this.login(),await this.#Y(),!await this.#tt()||!await this.#J()?n:await this.#at()}catch(r){console.warn(r),n.error=!0,n.message=r.message,n.approved=!1,n.object=r}return n}}exports.PinPad=Vr;