solidus_nexio 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d42e6c9bd11c430df53a34790fb27135858dfe7778993d92ac498852c4c644c
4
- data.tar.gz: 42f80e061a67fe362189b09574a088c00dca9a9c955d2b81d60185642a8604cb
3
+ metadata.gz: ac1f7200e780dffe91ae02cce2f13168762d6a917a380633ee4c668173dbb426
4
+ data.tar.gz: 80b9cad00e2311cc3a6708b8aff4ccf78402d7dd8ba17ddd1312dfea4ab46e44
5
5
  SHA512:
6
- metadata.gz: a5f82c368b378841a8e8e5fe9aa7471a53ad6d09d79ba34a6a76441fccfb0286ef3581b449da21db5bcb3756e54744c810706fa18e56774cf1ade446be4a6213
7
- data.tar.gz: 3c9c578fc6846c9add3f4e8d68c063fa2fa57eec71a362f3d5c1e0d343572c9adb3b59d07a6d6c6d19972af09dd5a95b83484ef48872a57172df3306751846b7
6
+ metadata.gz: cc3f7b25a70bc4a35a8f432c299234dd036641e9e2ff34eaa78d05dfe0df6ff86cbc494595c98f9652621f4d42dcad869b2135a2ed506dc738114c9e6d519f31
7
+ data.tar.gz: a54f579c9fd6a92a2564155b6b12c35b9e83e97154ca05ab609dedacb630f42474013913414214fcd13d466ee7834bec1510f4aa45201dd0f27968ec6f662e72
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see checkout.js.LICENSE.txt */
2
- (()=>{"use strict";(()=>{function t(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function e(t,e){return t&e}function r(t,e){return t|e}function i(t,e){return t^e}function n(t,e){return t&~e}function s(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function o(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var h,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function u(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=a.charAt(r>>6)+a.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=a.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=a.charAt(r>>2)+a.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function c(e){var r,i="",n=0,s=0;for(r=0;r<e.length&&"="!=e.charAt(r);++r){var o=a.indexOf(e.charAt(r));o<0||(0==n?(i+=t(o>>2),s=3&o,n=1):1==n?(i+=t(s<<2|o>>4),s=15&o,n=2):2==n?(i+=t(s),i+=t(o>>2),s=3&o,n=3):(i+=t(s<<2|o>>4),i+=t(15&o),n=0))}return 1==n&&(i+=t(s<<2)),i}var f,l={decode:function(t){var e;if(void 0===f){var r="= \f\n\r\t \u2028\u2029";for(f=Object.create(null),e=0;e<64;++e)f["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(f["-"]=62,f._=63,e=0;e<r.length;++e)f[r.charAt(e)]=-1}var i=[],n=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=f[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,++s>=4?(i[i.length]=n>>16,i[i.length]=n>>8&255,i[i.length]=255&n,n=0,s=0):n<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=n>>10;break;case 3:i[i.length]=n>>16,i[i.length]=n>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=l.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return l.decode(t)}},p=1e13,g=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var r,i,n=this.buf,s=n.length;for(r=0;r<s;++r)(i=n[r]*t+e)<p?e=0:i-=(e=0|i/p)*p,n[r]=i;e>0&&(n[r]=e)},t.prototype.sub=function(t){var e,r,i=this.buf,n=i.length;for(e=0;e<n;++e)(r=i[e]-t)<0?(r+=p,t=1):t=0,i[e]=r;for(;0===i[i.length-1];)i.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),i=e.length-2;i>=0;--i)r+=(p+e[i]).toString().substring(1);return r},t.prototype.valueOf=function(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*p+t[r];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),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)?)?$/,v=/^(\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 m(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}var y,b=function(){function t(e,r){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=r)}return t.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},t.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},t.prototype.hexDump=function(t,e,r){for(var i="",n=t;n<e;++n)if(i+=this.hexByte(this.get(n)),!0!==r)switch(15&n){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i},t.prototype.isASCII=function(t,e){for(var r=t;r<e;++r){var i=this.get(r);if(i<32||i>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var r="",i=t;i<e;++i)r+=String.fromCharCode(this.get(i));return r},t.prototype.parseStringUTF=function(t,e){for(var r="",i=t;i<e;){var n=this.get(i++);r+=n<128?String.fromCharCode(n):n>191&&n<224?String.fromCharCode((31&n)<<6|63&this.get(i++)):String.fromCharCode((15&n)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return r},t.prototype.parseStringBMP=function(t,e){for(var r,i,n="",s=t;s<e;)r=this.get(s++),i=this.get(s++),n+=String.fromCharCode(r<<8|i);return n},t.prototype.parseTime=function(t,e,r){var i=this.parseStringISO(t,e),n=(r?d:v).exec(i);return n?(r&&(n[1]=+n[1],n[1]+=+n[1]<70?2e3:1900),i=n[1]+"-"+n[2]+"-"+n[3]+" "+n[4],n[5]&&(i+=":"+n[5],n[6]&&(i+=":"+n[6],n[7]&&(i+="."+n[7]))),n[8]&&(i+=" UTC","Z"!=n[8]&&(i+=n[8],n[9]&&(i+=":"+n[9]))),i):"Unrecognized time: "+i},t.prototype.parseInteger=function(t,e){for(var r,i=this.get(t),n=i>127,s=n?255:0,o="";i==s&&++t<e;)i=this.get(t);if(0==(r=e-t))return n?-1:0;if(r>4){for(o=i,r<<=3;0==(128&(+o^s));)o=+o<<1,--r;o="("+r+" bit)\n"}n&&(i-=256);for(var h=new g(i),a=t+1;a<e;++a)h.mulAdd(256,this.get(a));return o+h.toString()},t.prototype.parseBitString=function(t,e,r){for(var i=this.get(t),n="("+((e-t-1<<3)-i)+" bit)\n",s="",o=t+1;o<e;++o){for(var h=this.get(o),a=o==e-1?i:0,u=7;u>=a;--u)s+=h>>u&1?"1":"0";if(s.length>r)return n+m(s,r)}return n+s},t.prototype.parseOctetString=function(t,e,r){if(this.isASCII(t,e))return m(this.parseStringISO(t,e),r);var i=e-t,n="("+i+" byte)\n";i>(r/=2)&&(e=t+r);for(var s=t;s<e;++s)n+=this.hexByte(this.get(s));return i>r&&(n+="…"),n},t.prototype.parseOID=function(t,e,r){for(var i="",n=new g,s=0,o=t;o<e;++o){var h=this.get(o);if(n.mulAdd(128,127&h),s+=7,!(128&h)){if(""===i)if((n=n.simplify())instanceof g)n.sub(80),i="2."+n.toString();else{var a=n<80?n<40?0:1:2;i=a+"."+(n-40*a)}else i+="."+n.toString();if(i.length>r)return m(i,r);n=new g,s=0}}return s>0&&(i+=".incomplete"),i},t}(),T=function(){function t(t,e,r,i,n){if(!(i instanceof S))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=i,this.sub=n}return t.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()}},t.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return m(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return m(this.stream.parseStringISO(e,e+r),t);case 30:return m(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null},t.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},t.prototype.toPrettyString=function(t){void 0===t&&(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()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,i=this.sub.length;r<i;++r)e+=this.sub[r].toPrettyString(t)}return e},t.prototype.posStart=function(){return this.stream.pos},t.prototype.posContent=function(){return this.stream.pos+this.header},t.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},t.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},t.decodeLength=function(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var i=0;i<r;++i)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)},t.decode=function(e){var r;r=e instanceof b?e:new b(e,0);var i=new b(r),n=new S(r),s=t.decodeLength(r),o=r.pos,h=o-i.pos,a=null,u=function(){var e=[];if(null!==s){for(var i=o+s;r.pos<i;)e[e.length]=t.decode(r);if(r.pos!=i)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=t.decode(r);if(n.tag.isEOC())break;e[e.length]=n}s=o-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(n.tagConstructed)a=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");a=u();for(var c=0;c<a.length;++c)if(a[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){a=null}if(null===a){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);r.pos=o+Math.abs(s)}return new t(i,h,s,n,a)},t}(),S=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new g;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),E=[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],w=(1<<26)/E[E.length-1],D=function(){function h(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return h.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var r;if(16==e)r=4;else if(8==e)r=3;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return this.toRadix(e);r=2}var i,n=(1<<r)-1,s=!1,o="",h=this.t,a=this.DB-h*this.DB%r;if(h-- >0)for(a<this.DB&&(i=this[h]>>a)>0&&(s=!0,o=t(i));h>=0;)a<r?(i=(this[h]&(1<<a)-1)<<r-a,i|=this[--h]>>(a+=this.DB-r)):(i=this[h]>>(a-=r)&n,a<=0&&(a+=this.DB,--h)),i>0&&(s=!0),s&&(o+=t(i));return s?o:"0"},h.prototype.negate=function(){var t=A();return h.ZERO.subTo(this,t),t},h.prototype.abs=function(){return this.s<0?this.negate():this},h.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},h.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+C(this[this.t-1]^this.s&this.DM)},h.prototype.mod=function(t){var e=A();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(h.ZERO)>0&&t.subTo(e,e),e},h.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new O(e):new R(e),this.exp(t,r)},h.prototype.clone=function(){var t=A();return this.copyTo(t),t},h.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},h.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},h.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},h.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},h.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[n++]=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)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},h.prototype.equals=function(t){return 0==this.compareTo(t)},h.prototype.min=function(t){return this.compareTo(t)<0?this:t},h.prototype.max=function(t){return this.compareTo(t)>0?this:t},h.prototype.and=function(t){var r=A();return this.bitwiseTo(t,e,r),r},h.prototype.or=function(t){var e=A();return this.bitwiseTo(t,r,e),e},h.prototype.xor=function(t){var e=A();return this.bitwiseTo(t,i,e),e},h.prototype.andNot=function(t){var e=A();return this.bitwiseTo(t,n,e),e},h.prototype.not=function(){for(var t=A(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},h.prototype.shiftLeft=function(t){var e=A();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},h.prototype.shiftRight=function(t){var e=A();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},h.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+s(this[t]);return this.s<0?this.t*this.DB:-1},h.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=o(this[r]^e);return t},h.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},h.prototype.setBit=function(t){return this.changeBit(t,r)},h.prototype.clearBit=function(t){return this.changeBit(t,n)},h.prototype.flipBit=function(t){return this.changeBit(t,i)},h.prototype.add=function(t){var e=A();return this.addTo(t,e),e},h.prototype.subtract=function(t){var e=A();return this.subTo(t,e),e},h.prototype.multiply=function(t){var e=A();return this.multiplyTo(t,e),e},h.prototype.divide=function(t){var e=A();return this.divRemTo(t,e,null),e},h.prototype.remainder=function(t){var e=A();return this.divRemTo(t,null,e),e},h.prototype.divideAndRemainder=function(t){var e=A(),r=A();return this.divRemTo(t,e,r),[e,r]},h.prototype.modPow=function(t,e){var r,i,n=t.bitLength(),s=q(1);if(n<=0)return s;r=n<18?1:n<48?3:n<144?4:n<768?5:6,i=n<8?new O(e):e.isEven()?new B(e):new R(e);var o=[],h=3,a=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var c=A();for(i.sqrTo(o[1],c);h<=u;)o[h]=A(),i.mulTo(c,o[h-2],o[h]),h+=2}var f,l,p=t.t-1,g=!0,d=A();for(n=C(t[p])-1;p>=0;){for(n>=a?f=t[p]>>n-a&u:(f=(t[p]&(1<<n+1)-1)<<a-n,p>0&&(f|=t[p-1]>>this.DB+n-a)),h=r;0==(1&f);)f>>=1,--h;if((n-=h)<0&&(n+=this.DB,--p),g)o[f].copyTo(s),g=!1;else{for(;h>1;)i.sqrTo(s,d),i.sqrTo(d,s),h-=2;h>0?i.sqrTo(s,d):(l=s,s=d,d=l),i.mulTo(d,o[f],s)}for(;p>=0&&0==(t[p]&1<<n);)i.sqrTo(s,d),l=s,s=d,d=l,--n<0&&(n=this.DB-1,--p)}return i.revert(s)},h.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return h.ZERO;for(var r=t.clone(),i=this.clone(),n=q(1),s=q(0),o=q(0),a=q(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&a.isEven()||(o.addTo(this,o),a.subTo(t,a)),o.rShiftTo(1,o)):a.isEven()||a.subTo(t,a),a.rShiftTo(1,a);r.compareTo(i)>=0?(r.subTo(i,r),e&&n.subTo(o,n),s.subTo(a,s)):(i.subTo(r,i),e&&o.subTo(n,o),a.subTo(s,a))}return 0!=i.compareTo(h.ONE)?h.ZERO:a.compareTo(t)>=0?a.subtract(t):a.signum()<0?(a.addTo(t,a),a.signum()<0?a.add(t):a):a},h.prototype.pow=function(t){return this.exp(t,new x)},h.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},h.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=E[E.length-1]){for(e=0;e<E.length;++e)if(r[0]==E[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<E.length;){for(var i=E[e],n=e+1;n<E.length&&i<w;)i*=E[n++];for(i=r.modInt(i);e<n;)if(i%E[e++]==0)return!1}return r.millerRabin(t)},h.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},h.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},h.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,n=!1,s=0;--i>=0;){var o=8==r?255&+t[i]:M(t,i);o<0?"-"==t.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&+t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&h.ZERO.subTo(this,this)},h.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},h.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},h.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},h.prototype.lShiftTo=function(t,e){for(var r=t%this.DB,i=this.DB-r,n=(1<<i)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,h=this.t-1;h>=0;--h)e[h+s+1]=this[h]>>i|o,o=(this[h]&n)<<r;for(h=s-1;h>=0;--h)e[h]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},h.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,s=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<n,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&s)<<n),e.t=this.t-r,e.clamp()}},h.prototype.subTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},h.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n<i.t;++n)e[n+r.t]=r.am(0,i[n],e,n,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&h.ZERO.subTo(e,e)},h.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},h.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var n=this.abs();if(n.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=A());var s=A(),o=this.s,a=t.s,u=this.DB-C(i[i.t-1]);u>0?(i.lShiftTo(u,s),n.lShiftTo(u,r)):(i.copyTo(s),n.copyTo(r));var c=s.t,f=s[c-1];if(0!=f){var l=f*(1<<this.F1)+(c>1?s[c-2]>>this.F2:0),p=this.FV/l,g=(1<<this.F1)/l,d=1<<this.F2,v=r.t,m=v-c,y=null==e?A():e;for(s.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),h.ONE.dlShiftTo(c,y),y.subTo(s,s);s.t<c;)s[s.t++]=0;for(;--m>=0;){var b=r[--v]==f?this.DM:Math.floor(r[v]*p+(r[v-1]+d)*g);if((r[v]+=s.am(0,b,r,m,0,c))<b)for(s.dlShiftTo(m,y),r.subTo(y,r);r[v]<--b;)r.subTo(y,r)}null!=e&&(r.drShiftTo(c,e),o!=a&&h.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&h.ZERO.subTo(r,r)}}},h.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},h.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},h.prototype.exp=function(t,e){if(t>4294967295||t<1)return h.ONE;var r=A(),i=A(),n=e.convert(this),s=C(t)-1;for(n.copyTo(r);--s>=0;)if(e.sqrTo(r,i),(t&1<<s)>0)e.mulTo(i,n,r);else{var o=r;r=i,i=o}return e.revert(r)},h.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},h.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=q(r),n=A(),s=A(),o="";for(this.divRemTo(i,n,s);n.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,n.divRemTo(i,n,s);return s.intValue().toString(t)+o},h.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),n=!1,s=0,o=0,a=0;a<t.length;++a){var u=M(t,a);u<0?"-"==t.charAt(a)&&0==this.signum()&&(n=!0):(o=e*o+u,++s>=r&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&h.ZERO.subTo(this,this)},h.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(h.ONE.shiftLeft(t-1),r,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(h.ONE.shiftLeft(t-1),this);else{var n=[],s=7&t;n.length=1+(t>>3),e.nextBytes(n),s>0?n[0]&=(1<<s)-1:n[0]=0,this.fromString(n,256)}},h.prototype.bitwiseTo=function(t,e,r){var i,n,s=Math.min(t.t,this.t);for(i=0;i<s;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=s;i<this.t;++i)r[i]=e(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=s;i<t.t;++i)r[i]=e(n,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},h.prototype.changeBit=function(t,e){var r=h.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},h.prototype.addTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},h.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},h.prototype.dAddOffset=function(t,e){if(0!=t){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]}},h.prototype.multiplyLowerTo=function(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(var n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);i<n;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()},h.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},h.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},h.prototype.millerRabin=function(t){var e=this.subtract(h.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>E.length&&(t=E.length);for(var n=A(),s=0;s<t;++s){n.fromInt(E[Math.floor(Math.random()*E.length)]);var o=n.modPow(i,this);if(0!=o.compareTo(h.ONE)&&0!=o.compareTo(e)){for(var a=1;a++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(h.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},h.prototype.square=function(){var t=A();return this.squareTo(t),t},h.prototype.gcda=function(t,e){var r=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(r.compareTo(i)<0){var n=r;r=i,i=n}var s=r.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)e(r);else{s<o&&(o=s),o>0&&(r.rShiftTo(o,r),i.rShiftTo(o,i));var h=function(){(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),r.compareTo(i)>=0?(r.subTo(i,r),r.rShiftTo(1,r)):(i.subTo(r,i),i.rShiftTo(1,i)),r.signum()>0?setTimeout(h,0):(o>0&&i.lShiftTo(o,i),setTimeout((function(){e(i)}),0))};setTimeout(h,10)}},h.prototype.fromNumberAsync=function(t,e,i,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(h.ONE.shiftLeft(t-1),r,this),this.isEven()&&this.dAddOffset(1,0);var s=this,o=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(h.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout((function(){n()}),0):setTimeout(o,0)};setTimeout(o,0)}else{var a=[],u=7&t;a.length=1+(t>>3),e.nextBytes(a),u>0?a[0]&=(1<<u)-1:a[0]=0,this.fromString(a,256)}},h}(),x=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),O=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),R=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=A();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(D.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=A();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),B=function(){function t(t){this.m=t,this.r2=A(),this.q3=A(),D.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.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=A();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.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)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function A(){return new D(null)}function V(t,e){return new D(t,e)}var I="undefined"!=typeof navigator;I&&"Microsoft Internet Explorer"==navigator.appName?(D.prototype.am=function(t,e,r,i,n,s){for(var o=32767&e,h=e>>15;--s>=0;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+r[i]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),r[i++]=1073741823&a}return n},y=30):I&&"Netscape"!=navigator.appName?(D.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var o=e*this[t++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n},y=26):(D.prototype.am=function(t,e,r,i,n,s){for(var o=16383&e,h=e>>14;--s>=0;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+r[i]+n)>>28)+(c>>14)+h*u,r[i++]=268435455&a}return n},y=28),D.prototype.DB=y,D.prototype.DM=(1<<y)-1,D.prototype.DV=1<<y,D.prototype.FV=Math.pow(2,52),D.prototype.F1=52-y,D.prototype.F2=2*y-52;var N,P,j=[];for(N="0".charCodeAt(0),P=0;P<=9;++P)j[N++]=P;for(N="a".charCodeAt(0),P=10;P<36;++P)j[N++]=P;for(N="A".charCodeAt(0),P=10;P<36;++P)j[N++]=P;function M(t,e){var r=j[t.charCodeAt(e)];return null==r?-1:r}function q(t){var e=A();return e.fromInt(t),e}function C(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}D.ZERO=q(0),D.ONE=q(1);var L,H,_=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},t.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]},t}(),k=null;if(null==k){k=[],H=0;var F=void 0;if(window.crypto&&window.crypto.getRandomValues){var K=new Uint32Array(256);for(window.crypto.getRandomValues(K),F=0;F<K.length;++F)k[H++]=255&K[F]}var U=0,z=function(t){if((U=U||0)>=256||H>=256)window.removeEventListener?window.removeEventListener("mousemove",z,!1):window.detachEvent&&window.detachEvent("onmousemove",z);else try{var e=t.x+t.y;k[H++]=255&e,U+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",z,!1):window.attachEvent&&window.attachEvent("onmousemove",z)}function Z(){if(null==L){for(L=new _;H<256;){var t=Math.floor(65536*Math.random());k[H++]=255&t}for(L.init(k),H=0;H<k.length;++H)k[H]=0;H=0}return L.next()}var $=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Z()},t}(),G=function(){function t(){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 t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=this.n.bitLength()+7>>3,r=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],i=t.length-1;i>=0&&e>0;){var n=t.charCodeAt(i--);n<128?r[--e]=n:n>127&&n<2048?(r[--e]=63&n|128,r[--e]=n>>6|192):(r[--e]=63&n|128,r[--e]=n>>6&63|128,r[--e]=n>>12|224)}r[--e]=0;for(var s=new $,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new D(r)}(t,e);if(null==r)return null;var i=this.doPublic(r);if(null==i)return null;for(var n=i.toString(16),s=n.length,o=0;o<2*e-s;o++)n="0"+n;return n},t.prototype.setPrivate=function(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16),this.d=V(r,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,r,i,n,s,o,h){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16),this.d=V(r,16),this.p=V(i,16),this.q=V(n,16),this.dmp1=V(s,16),this.dmq1=V(o,16),this.coeff=V(h,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var r=new $,i=t>>1;this.e=parseInt(e,16);for(var n=new D(e,16);;){for(;this.p=new D(t-i,1,r),0!=this.p.subtract(D.ONE).gcd(n).compareTo(D.ONE)||!this.p.isProbablePrime(10););for(;this.q=new D(i,1,r),0!=this.q.subtract(D.ONE).gcd(n).compareTo(D.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(D.ONE),h=this.q.subtract(D.ONE),a=o.multiply(h);if(0==a.gcd(n).compareTo(D.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(a),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=V(t,16),r=this.doPrivate(e);return null==r?null:function(t,e){for(var r=t.toByteArray(),i=0;i<r.length&&0==r[i];)++i;if(r.length-i!=e-1||2!=r[i])return null;for(++i;0!=r[i];)if(++i>=r.length)return null;for(var n="";++i<r.length;){var s=255&r[i];s<128?n+=String.fromCharCode(s):s>191&&s<224?(n+=String.fromCharCode((31&s)<<6|63&r[i+1]),++i):(n+=String.fromCharCode((15&s)<<12|(63&r[i+1])<<6|63&r[i+2]),i+=2)}return n}(r,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,r){var i=new $,n=t>>1;this.e=parseInt(e,16);var s=new D(e,16),o=this,h=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(D.ONE),i=o.q.subtract(D.ONE),n=e.multiply(i);0==n.gcd(s).compareTo(D.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(n),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(i),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(h,0)},a=function(){o.q=A(),o.q.fromNumberAsync(n,1,i,(function(){o.q.subtract(D.ONE).gcda(s,(function(t){0==t.compareTo(D.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(a,0)}))}))},u=function(){o.p=A(),o.p.fromNumberAsync(t-n,1,i,(function(){o.p.subtract(D.ONE).gcda(s,(function(t){0==t.compareTo(D.ONE)&&o.p.isProbablePrime(10)?setTimeout(a,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(h,0)},t.prototype.sign=function(t,e,r){var i=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var r=e-t.length-6,i="",n=0;n<r;n+=2)i+="ff";return V("0001"+i+"00"+t,16)}((Y[r]||"")+e(t).toString(),this.n.bitLength()/4);if(null==i)return null;var n=this.doPrivate(i);if(null==n)return null;var s=n.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,r){var i=V(e,16),n=this.doPublic(i);return null==n?null:function(t){for(var e in Y)if(Y.hasOwnProperty(e)){var r=Y[e],i=r.length;if(t.substr(0,i)==r)return t.substr(i)}return t}(n.toString(16).replace(/^1f+00/,""))==r(t).toString()},t}(),Y={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},X={};X.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var i=function(){};if(i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var n;for(n in r)t.prototype[n]=r[n];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(n=0;n<o.length;n+=1){var r=o[n],i=e[r];"function"==typeof i&&i!=Object.prototype[r]&&(t[r]=i)}})}catch(t){}s(t.prototype,r)}}};var J={};void 0!==J.asn1&&J.asn1||(J.asn1={}),J.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",n=0;n<r;n++)i+="f";e=new D(i,16).xor(t).add(D.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=J.asn1,r=e.DERBoolean,i=e.DERInteger,n=e.DERBitString,s=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,a=e.DEREnumerated,u=e.DERUTF8String,c=e.DERNumericString,f=e.DERPrintableString,l=e.DERTeletexString,p=e.DERIA5String,g=e.DERUTCTime,d=e.DERGeneralizedTime,v=e.DERSequence,m=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,T=Object.keys(t);if(1!=T.length)throw"key of param shall be only one.";var S=T[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new r(t[S]);if("int"==S)return new i(t[S]);if("bitstr"==S)return new n(t[S]);if("octstr"==S)return new s(t[S]);if("null"==S)return new o(t[S]);if("oid"==S)return new h(t[S]);if("enum"==S)return new a(t[S]);if("utf8str"==S)return new u(t[S]);if("numstr"==S)return new c(t[S]);if("prnstr"==S)return new f(t[S]);if("telstr"==S)return new l(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new g(t[S]);if("gentime"==S)return new d(t[S]);if("seq"==S){for(var E=t[S],w=[],D=0;D<E.length;D++){var x=b(E[D]);w.push(x)}return new v({array:w})}if("set"==S){for(E=t[S],w=[],D=0;D<E.length;D++)x=b(E[D]),w.push(x);return new m({array:w})}if("tag"==S){var O=t[S];if("[object Array]"===Object.prototype.toString.call(O)&&3==O.length){var R=b(O[2]);return new y({tag:O[0],explicit:O[1],obj:R})}var B={};if(void 0!==O.explicit&&(B.explicit=O.explicit),void 0!==O.tag&&(B.tag=O.tag),void 0===O.obj)throw"obj shall be specified for 'tag'.";return B.obj=b(O.obj),new y(B)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},J.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);i+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new D(i,2).toString(10),i="")}return e},J.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new D(t,10).toString(2),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+i,o=0;o<i.length-1;o+=7){var h=i.substr(o,7);o!=i.length-7&&(h="1"+h),r+=e(parseInt(h,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[o]);return i},J.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: 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 r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||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""}},J.asn1.DERAbstractString=function(t){J.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},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},X.lang.extend(J.asn1.DERAbstractString,J.asn1.ASN1Object),J.asn1.DERAbstractTime=function(t){J.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,r){var i=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+i(String(n.getMonth()+1),2)+i(String(n.getDate()),2)+i(String(n.getHours()),2)+i(String(n.getMinutes()),2)+i(String(n.getSeconds()),2);if(!0===r){var h=n.getMilliseconds();if(0!=h){var a=i(String(h),3);o=o+"."+(a=a.replace(/[0]+$/,""))}}return o+"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,r,i,n,s){var o=new Date(Date.UTC(t,e-1,r,i,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},X.lang.extend(J.asn1.DERAbstractTime,J.asn1.ASN1Object),J.asn1.DERAbstractStructured=function(t){J.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,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},X.lang.extend(J.asn1.DERAbstractStructured,J.asn1.ASN1Object),J.asn1.DERBoolean=function(){J.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},X.lang.extend(J.asn1.DERBoolean,J.asn1.ASN1Object),J.asn1.DERInteger=function(t){J.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=J.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new D(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},X.lang.extend(J.asn1.DERInteger,J.asn1.ASN1Object),J.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=J.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}J.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var i="";for(r=0;r<t.length-1;r+=8){var n=t.substr(r,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),i+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+i},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},X.lang.extend(J.asn1.DERBitString,J.asn1.ASN1Object),J.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=J.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}J.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},X.lang.extend(J.asn1.DEROctetString,J.asn1.DERAbstractString),J.asn1.DERNull=function(){J.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},X.lang.extend(J.asn1.DERNull,J.asn1.ASN1Object),J.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new D(t,10).toString(2),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+i,o=0;o<i.length-1;o+=7){var h=i.substr(o,7);o!=i.length-7&&(h="1"+h),r+=e(parseInt(h,2))}return r};J.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(t){var e=J.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},X.lang.extend(J.asn1.DERObjectIdentifier,J.asn1.ASN1Object),J.asn1.DEREnumerated=function(t){J.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=J.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new D(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},X.lang.extend(J.asn1.DEREnumerated,J.asn1.ASN1Object),J.asn1.DERUTF8String=function(t){J.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},X.lang.extend(J.asn1.DERUTF8String,J.asn1.DERAbstractString),J.asn1.DERNumericString=function(t){J.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},X.lang.extend(J.asn1.DERNumericString,J.asn1.DERAbstractString),J.asn1.DERPrintableString=function(t){J.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},X.lang.extend(J.asn1.DERPrintableString,J.asn1.DERAbstractString),J.asn1.DERTeletexString=function(t){J.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},X.lang.extend(J.asn1.DERTeletexString,J.asn1.DERAbstractString),J.asn1.DERIA5String=function(t){J.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},X.lang.extend(J.asn1.DERIA5String,J.asn1.DERAbstractString),J.asn1.DERUTCTime=function(t){J.asn1.DERUTCTime.superclass.constructor.call(this,t),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 void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},X.lang.extend(J.asn1.DERUTCTime,J.asn1.DERAbstractTime),J.asn1.DERGeneralizedTime=function(t){J.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),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 void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},X.lang.extend(J.asn1.DERGeneralizedTime,J.asn1.DERAbstractTime),J.asn1.DERSequence=function(t){J.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},X.lang.extend(J.asn1.DERSequence,J.asn1.DERAbstractStructured),J.asn1.DERSet=function(t){J.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},X.lang.extend(J.asn1.DERSet,J.asn1.DERAbstractStructured),J.asn1.DERTaggedObject=function(t){J.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},X.lang.extend(J.asn1.DERTaggedObject,J.asn1.ASN1Object);var Q,W=(Q=function(t,e){return(Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Q(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),tt=function(t){function e(r){var i=t.call(this)||this;return r&&("string"==typeof r?i.parseKey(r):(e.hasPrivateKeyProperty(r)||e.hasPublicKeyProperty(r))&&i.parsePropertiesFrom(r)),i}return W(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===h){var r="0123456789ABCDEF",i=" \f\n\r\t \u2028\u2029";for(h={},e=0;e<16;++e)h[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)h[r.charAt(e)]=e;for(e=0;e<i.length;++e)h[i.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=h[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);s|=a,++o>=2?(n[n.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}(t):l.unarmor(t),n=T.decode(i);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=V(e,16),r=n.sub[2].getHexStringValue(),this.e=parseInt(r,16);var s=n.sub[3].getHexStringValue();this.d=V(s,16);var o=n.sub[4].getHexStringValue();this.p=V(o,16);var a=n.sub[5].getHexStringValue();this.q=V(a,16);var u=n.sub[6].getHexStringValue();this.dmp1=V(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=V(c,16);var f=n.sub[8].getHexStringValue();this.coeff=V(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1].sub[0];e=p.sub[0].getHexStringValue(),this.n=V(e,16),r=p.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new J.asn1.DERInteger({int:0}),new J.asn1.DERInteger({bigint:this.n}),new J.asn1.DERInteger({int:this.e}),new J.asn1.DERInteger({bigint:this.d}),new J.asn1.DERInteger({bigint:this.p}),new J.asn1.DERInteger({bigint:this.q}),new J.asn1.DERInteger({bigint:this.dmp1}),new J.asn1.DERInteger({bigint:this.dmq1}),new J.asn1.DERInteger({bigint:this.coeff})]};return new J.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return u(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new J.asn1.DERSequence({array:[new J.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new J.asn1.DERNull]}),e=new J.asn1.DERSequence({array:[new J.asn1.DERInteger({bigint:this.n}),new J.asn1.DERInteger({int:this.e})]}),r=new J.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new J.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return u(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return(t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n")+"-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return(t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n")+"-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(G);const et=function(){function t(t){t=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=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new tt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(c(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return u(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return u(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,c(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new tt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.2.0",t}(),rt=window.Rails||window.$.rails;var it=function(t){var e=t.headers,r=t.status;return 404===r||500<=r?Promise.reject({headers:e,status:r}):-1!==(t.headers.get("Content-Type")+"").indexOf("json")&&204!==t.status?t.json().then((function(t){return{headers:e,status:r,json:t}}),(function(){return{headers:e,status:r,json:null}})):{headers:e,status:r,json:null}};const nt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={method:e,credentials:"same-origin",headers:new Headers};return i.headers.append("X-CSRF-Token",rt.csrfToken()),i.headers.append("accept","application/json"),r.body&&(r.body instanceof FormData?i.body=r.body:(i.body=JSON.stringify(r.body),i.headers.append("content-type","application/json"))),window.fetch(t,i).then(it,(function(t){return Promise.reject(t)}))};var st,ot,ht,at=function(t){return t&&t.trim().length};window.$&&window.$.payment?(st=window.$.payment.validateCardNumber,ot=window.$.payment.validateCardCVC,ht=window.$.payment.validateCardExpiry):(ot=at,ht=function(t,e){return at(t)&&at(e)});var ut=function(t,e,r){t[e]||(t[e]=[]),t[e].push(r)},ct=["number"];function ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function lt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function pt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?lt(Object(r),!0).forEach((function(e){gt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):lt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function gt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var dt={},vt=function(t){var e=t.slice(0,6),r=t.slice(t.length-4),i="*".repeat(t.length-10);return"".concat(e).concat(i).concat(r)},mt=function(t,e){},yt=function(t,e){},bt={number:"nexio_card_number",cc_type:"nexio_card_type",name:"nexio_card_name",month:"nexio_card_month",year:"nexio_card_year",verification_value:"nexio_verification_value"},Tt=function(){Object.keys(dt).forEach((function(t){var e=document.querySelector('[data-nexio-own-form-id="'.concat(t,'"]'));if(null!==e){var r=e.closest("form");if(null!==r){var i=function(){e.removeAttribute("disabled");var t=r.querySelector(rt.formEnableSelector);rt.enableElement(t),t.classList.remove("disabled")};e.setAttribute("disabled","disabled"),function(t){var e=dt[t],r=e.paths,i=e.data;return nt(r.oneTimeToken,"POST",{body:{data:i}}).then((function(e){if(201===e.status){var r=e.json.data;return dt[t].token=r.token,r}return Promise.reject(e)}),(function(t){return Promise.reject(t)}))}(t).then((function(n){return function(t,e){return new Promise((function(r){var i=document.createElement("script");i.onload=r,i.src=e,t.appendChild(i)}))}(e,n.fraud_url).then((function(){e.removeAttribute("disabled"),r.addEventListener("submit",(function(n){if(0!==e.clientHeight){n.preventDefault();var s=function(t){return Object.entries(bt).reduce((function(e,r){var i,n,s=(n=2,function(t){if(Array.isArray(t))return t}(i=r)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,s=[],o=!0,h=!1;try{for(r=r.call(t);!(o=(i=r.next()).done)&&(s.push(i.value),!e||s.length!==e);o=!0);}catch(t){h=!0,n=t}finally{try{o||null==r.return||r.return()}finally{if(h)throw n}}return s}}(i,n)||function(t,e){if(t){if("string"==typeof t)return ft(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ft(t,e):void 0}}(i,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=s[0],h=s[1],a=t.querySelector('[data-hook="'.concat(h,'"]'));return a&&(e[o]=a.value),e}),{})}(e),o=function(t){var e={};return["number","cc_type","name","month","year","verification_value"].forEach((function(r){return at(t[r])?null:ut(e,r,"blank")})),st(t.number)||ut(e,"number","blank"),ot(t.verification_value,t.cc_type)||ut(e,"verification_value","invalid"),ht(t.month,t.year)||(ut(e,"month","invalid"),ut(e,"year","invalid")),e}(s);if(0<Object.keys(o).length)return i(),function(t,e,r){var i=new CustomEvent("invalid_nexio_fields");i.data={errors:e,card:r},t.dispatchEvent(i)}(e,o,s);e.setAttribute("disabled","disabled"),function(t,e){var r=dt[t],i=e.number,n=function(t,e){if(null==t)return{};var r,i,n=function(t,e){if(null==t)return{};var r,i,n={},s=Object.keys(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}(e,ct);i=i.replace(/\D+/g,"");var s=new et;s.setPublicKey(r.publicKey);var o=pt(pt({},r.data),{},{one_time_token:r.token,card:pt(pt({},n),{},{encrypted_number:s.encrypt(i),number:vt(i)})});return nt(r.paths.creditCard,"POST",{body:{data:o}}).then((function(t){return 201===t.status?t.json.data:Promise.reject(t)}),(function(t){return Promise.reject(t)}))}(t,s).then((function(t){e.querySelector('[data-hook="nexio_card_gateway_payment_profile_id"]').value=t.token,e.removeAttribute("disabled"),r.submit()}),yt.bind(null,e)).catch((function(){i()}))}}))}))}),mt.bind(null,e))}}}))};window.addNexioOwnForm=function(t,e){dt[t]=e},window.jQuery((function(){Tt()}))})()})();
2
+ (()=>{"use strict";(()=>{function t(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function e(t,e){return t&e}function r(t,e){return t|e}function i(t,e){return t^e}function n(t,e){return t&~e}function s(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function o(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var a,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function u(t){var e,r,i="";for(e=0;e+3<=t.length;e+=3)r=parseInt(t.substring(e,e+3),16),i+=h.charAt(r>>6)+h.charAt(63&r);for(e+1==t.length?(r=parseInt(t.substring(e,e+1),16),i+=h.charAt(r<<2)):e+2==t.length&&(r=parseInt(t.substring(e,e+2),16),i+=h.charAt(r>>2)+h.charAt((3&r)<<4));(3&i.length)>0;)i+="=";return i}function c(e){var r,i="",n=0,s=0;for(r=0;r<e.length&&"="!=e.charAt(r);++r){var o=h.indexOf(e.charAt(r));o<0||(0==n?(i+=t(o>>2),s=3&o,n=1):1==n?(i+=t(s<<2|o>>4),s=15&o,n=2):2==n?(i+=t(s),i+=t(o>>2),s=3&o,n=3):(i+=t(s<<2|o>>4),i+=t(15&o),n=0))}return 1==n&&(i+=t(s<<2)),i}var f,l={decode:function(t){var e;if(void 0===f){var r="= \f\n\r\t \u2028\u2029";for(f=Object.create(null),e=0;e<64;++e)f["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(f["-"]=62,f._=63,e=0;e<r.length;++e)f[r.charAt(e)]=-1}var i=[],n=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=f[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,++s>=4?(i[i.length]=n>>16,i[i.length]=n>>8&255,i[i.length]=255&n,n=0,s=0):n<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=n>>10;break;case 3:i[i.length]=n>>16,i[i.length]=n>>8&255}return i},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=l.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return l.decode(t)}},p=1e13,d=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var r,i,n=this.buf,s=n.length;for(r=0;r<s;++r)(i=n[r]*t+e)<p?e=0:i-=(e=0|i/p)*p,n[r]=i;e>0&&(n[r]=e)},t.prototype.sub=function(t){var e,r,i=this.buf,n=i.length;for(e=0;e<n;++e)(r=i[e]-t)<0?(r+=p,t=1):t=0,i[e]=r;for(;0===i[i.length-1];)i.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,r=e[e.length-1].toString(),i=e.length-2;i>=0;--i)r+=(p+e[i]).toString().substring(1);return r},t.prototype.valueOf=function(){for(var t=this.buf,e=0,r=t.length-1;r>=0;--r)e=e*p+t[r];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),g=/^(\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)?)?$/,v=/^(\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 m(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}var y,b=function(){function t(e,r){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=r)}return t.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},t.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},t.prototype.hexDump=function(t,e,r){for(var i="",n=t;n<e;++n)if(i+=this.hexByte(this.get(n)),!0!==r)switch(15&n){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i},t.prototype.isASCII=function(t,e){for(var r=t;r<e;++r){var i=this.get(r);if(i<32||i>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var r="",i=t;i<e;++i)r+=String.fromCharCode(this.get(i));return r},t.prototype.parseStringUTF=function(t,e){for(var r="",i=t;i<e;){var n=this.get(i++);r+=n<128?String.fromCharCode(n):n>191&&n<224?String.fromCharCode((31&n)<<6|63&this.get(i++)):String.fromCharCode((15&n)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return r},t.prototype.parseStringBMP=function(t,e){for(var r,i,n="",s=t;s<e;)r=this.get(s++),i=this.get(s++),n+=String.fromCharCode(r<<8|i);return n},t.prototype.parseTime=function(t,e,r){var i=this.parseStringISO(t,e),n=(r?g:v).exec(i);return n?(r&&(n[1]=+n[1],n[1]+=+n[1]<70?2e3:1900),i=n[1]+"-"+n[2]+"-"+n[3]+" "+n[4],n[5]&&(i+=":"+n[5],n[6]&&(i+=":"+n[6],n[7]&&(i+="."+n[7]))),n[8]&&(i+=" UTC","Z"!=n[8]&&(i+=n[8],n[9]&&(i+=":"+n[9]))),i):"Unrecognized time: "+i},t.prototype.parseInteger=function(t,e){for(var r,i=this.get(t),n=i>127,s=n?255:0,o="";i==s&&++t<e;)i=this.get(t);if(0==(r=e-t))return n?-1:0;if(r>4){for(o=i,r<<=3;0==(128&(+o^s));)o=+o<<1,--r;o="("+r+" bit)\n"}n&&(i-=256);for(var a=new d(i),h=t+1;h<e;++h)a.mulAdd(256,this.get(h));return o+a.toString()},t.prototype.parseBitString=function(t,e,r){for(var i=this.get(t),n="("+((e-t-1<<3)-i)+" bit)\n",s="",o=t+1;o<e;++o){for(var a=this.get(o),h=o==e-1?i:0,u=7;u>=h;--u)s+=a>>u&1?"1":"0";if(s.length>r)return n+m(s,r)}return n+s},t.prototype.parseOctetString=function(t,e,r){if(this.isASCII(t,e))return m(this.parseStringISO(t,e),r);var i=e-t,n="("+i+" byte)\n";i>(r/=2)&&(e=t+r);for(var s=t;s<e;++s)n+=this.hexByte(this.get(s));return i>r&&(n+="…"),n},t.prototype.parseOID=function(t,e,r){for(var i="",n=new d,s=0,o=t;o<e;++o){var a=this.get(o);if(n.mulAdd(128,127&a),s+=7,!(128&a)){if(""===i)if((n=n.simplify())instanceof d)n.sub(80),i="2."+n.toString();else{var h=n<80?n<40?0:1:2;i=h+"."+(n-40*h)}else i+="."+n.toString();if(i.length>r)return m(i,r);n=new d,s=0}}return s>0&&(i+=".incomplete"),i},t}(),S=function(){function t(t,e,r,i,n){if(!(i instanceof T))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=r,this.tag=i,this.sub=n}return t.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()}},t.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),r=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+r);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+r,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+r,t);case 6:return this.stream.parseOID(e,e+r,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return m(this.stream.parseStringUTF(e,e+r),t);case 18:case 19:case 20:case 21:case 22:case 26:return m(this.stream.parseStringISO(e,e+r),t);case 30:return m(this.stream.parseStringBMP(e,e+r),t);case 23:case 24:return this.stream.parseTime(e,e+r,23==this.tag.tagNumber)}return null},t.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},t.prototype.toPrettyString=function(t){void 0===t&&(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()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+=" ";for(var r=0,i=this.sub.length;r<i;++r)e+=this.sub[r].toPrettyString(t)}return e},t.prototype.posStart=function(){return this.stream.pos},t.prototype.posContent=function(){return this.stream.pos+this.header},t.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},t.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},t.decodeLength=function(t){var e=t.get(),r=127&e;if(r==e)return r;if(r>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===r)return null;e=0;for(var i=0;i<r;++i)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,r=2*this.length;return t.substr(e,r)},t.decode=function(e){var r;r=e instanceof b?e:new b(e,0);var i=new b(r),n=new T(r),s=t.decodeLength(r),o=r.pos,a=o-i.pos,h=null,u=function(){var e=[];if(null!==s){for(var i=o+s;r.pos<i;)e[e.length]=t.decode(r);if(r.pos!=i)throw new Error("Content size is not correct for container starting at offset "+o)}else try{for(;;){var n=t.decode(r);if(n.tag.isEOC())break;e[e.length]=n}s=o-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(n.tagConstructed)h=u();else if(n.isUniversal()&&(3==n.tagNumber||4==n.tagNumber))try{if(3==n.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");h=u();for(var c=0;c<h.length;++c)if(h[c].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){h=null}if(null===h){if(null===s)throw new Error("We can't skip over an invalid tag with undefined length at offset "+o);r.pos=o+Math.abs(s)}return new t(i,a,s,n,h)},t}(),T=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){var r=new d;do{e=t.get(),r.mulAdd(128,127&e)}while(128&e);this.tagNumber=r.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),w=[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],E=(1<<26)/w[w.length-1],D=function(){function a(t,e,r){null!=t&&("number"==typeof t?this.fromNumber(t,e,r):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return a.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var r;if(16==e)r=4;else if(8==e)r=3;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return this.toRadix(e);r=2}var i,n=(1<<r)-1,s=!1,o="",a=this.t,h=this.DB-a*this.DB%r;if(a-- >0)for(h<this.DB&&(i=this[a]>>h)>0&&(s=!0,o=t(i));a>=0;)h<r?(i=(this[a]&(1<<h)-1)<<r-h,i|=this[--a]>>(h+=this.DB-r)):(i=this[a]>>(h-=r)&n,h<=0&&(h+=this.DB,--a)),i>0&&(s=!0),s&&(o+=t(i));return s?o:"0"},a.prototype.negate=function(){var t=B();return a.ZERO.subTo(this,t),t},a.prototype.abs=function(){return this.s<0?this.negate():this},a.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var r=this.t;if(0!=(e=r-t.t))return this.s<0?-e:e;for(;--r>=0;)if(0!=(e=this[r]-t[r]))return e;return 0},a.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+C(this[this.t-1]^this.s&this.DM)},a.prototype.mod=function(t){var e=B();return this.abs().divRemTo(t,null,e),this.s<0&&e.compareTo(a.ZERO)>0&&t.subTo(e,e),e},a.prototype.modPowInt=function(t,e){var r;return r=t<256||e.isEven()?new O(e):new A(e),this.exp(t,r)},a.prototype.clone=function(){var t=B();return this.copyTo(t),t},a.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},a.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},a.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},a.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},a.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var r,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(r=this[t]>>i)!=(this.s&this.DM)>>i&&(e[n++]=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)),0!=(128&r)&&(r|=-256),0==n&&(128&this.s)!=(128&r)&&++n,(n>0||r!=this.s)&&(e[n++]=r);return e},a.prototype.equals=function(t){return 0==this.compareTo(t)},a.prototype.min=function(t){return this.compareTo(t)<0?this:t},a.prototype.max=function(t){return this.compareTo(t)>0?this:t},a.prototype.and=function(t){var r=B();return this.bitwiseTo(t,e,r),r},a.prototype.or=function(t){var e=B();return this.bitwiseTo(t,r,e),e},a.prototype.xor=function(t){var e=B();return this.bitwiseTo(t,i,e),e},a.prototype.andNot=function(t){var e=B();return this.bitwiseTo(t,n,e),e},a.prototype.not=function(){for(var t=B(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},a.prototype.shiftLeft=function(t){var e=B();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},a.prototype.shiftRight=function(t){var e=B();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},a.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+s(this[t]);return this.s<0?this.t*this.DB:-1},a.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,r=0;r<this.t;++r)t+=o(this[r]^e);return t},a.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},a.prototype.setBit=function(t){return this.changeBit(t,r)},a.prototype.clearBit=function(t){return this.changeBit(t,n)},a.prototype.flipBit=function(t){return this.changeBit(t,i)},a.prototype.add=function(t){var e=B();return this.addTo(t,e),e},a.prototype.subtract=function(t){var e=B();return this.subTo(t,e),e},a.prototype.multiply=function(t){var e=B();return this.multiplyTo(t,e),e},a.prototype.divide=function(t){var e=B();return this.divRemTo(t,e,null),e},a.prototype.remainder=function(t){var e=B();return this.divRemTo(t,null,e),e},a.prototype.divideAndRemainder=function(t){var e=B(),r=B();return this.divRemTo(t,e,r),[e,r]},a.prototype.modPow=function(t,e){var r,i,n=t.bitLength(),s=q(1);if(n<=0)return s;r=n<18?1:n<48?3:n<144?4:n<768?5:6,i=n<8?new O(e):e.isEven()?new R(e):new A(e);var o=[],a=3,h=r-1,u=(1<<r)-1;if(o[1]=i.convert(this),r>1){var c=B();for(i.sqrTo(o[1],c);a<=u;)o[a]=B(),i.mulTo(c,o[a-2],o[a]),a+=2}var f,l,p=t.t-1,d=!0,g=B();for(n=C(t[p])-1;p>=0;){for(n>=h?f=t[p]>>n-h&u:(f=(t[p]&(1<<n+1)-1)<<h-n,p>0&&(f|=t[p-1]>>this.DB+n-h)),a=r;0==(1&f);)f>>=1,--a;if((n-=a)<0&&(n+=this.DB,--p),d)o[f].copyTo(s),d=!1;else{for(;a>1;)i.sqrTo(s,g),i.sqrTo(g,s),a-=2;a>0?i.sqrTo(s,g):(l=s,s=g,g=l),i.mulTo(g,o[f],s)}for(;p>=0&&0==(t[p]&1<<n);)i.sqrTo(s,g),l=s,s=g,g=l,--n<0&&(n=this.DB-1,--p)}return i.revert(s)},a.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return a.ZERO;for(var r=t.clone(),i=this.clone(),n=q(1),s=q(0),o=q(0),h=q(1);0!=r.signum();){for(;r.isEven();)r.rShiftTo(1,r),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&h.isEven()||(o.addTo(this,o),h.subTo(t,h)),o.rShiftTo(1,o)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);r.compareTo(i)>=0?(r.subTo(i,r),e&&n.subTo(o,n),s.subTo(h,s)):(i.subTo(r,i),e&&o.subTo(n,o),h.subTo(s,h))}return 0!=i.compareTo(a.ONE)?a.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},a.prototype.pow=function(t){return this.exp(t,new x)},a.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(e.compareTo(r)<0){var i=e;e=r,r=i}var n=e.getLowestSetBit(),s=r.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),s>0&&(e.rShiftTo(s,e),r.rShiftTo(s,r));e.signum()>0;)(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),e.compareTo(r)>=0?(e.subTo(r,e),e.rShiftTo(1,e)):(r.subTo(e,r),r.rShiftTo(1,r));return s>0&&r.lShiftTo(s,r),r},a.prototype.isProbablePrime=function(t){var e,r=this.abs();if(1==r.t&&r[0]<=w[w.length-1]){for(e=0;e<w.length;++e)if(r[0]==w[e])return!0;return!1}if(r.isEven())return!1;for(e=1;e<w.length;){for(var i=w[e],n=e+1;n<w.length&&i<E;)i*=w[n++];for(i=r.modInt(i);e<n;)if(i%w[e++]==0)return!1}return r.millerRabin(t)},a.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},a.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},a.prototype.fromString=function(t,e){var r;if(16==e)r=4;else if(8==e)r=3;else if(256==e)r=8;else if(2==e)r=1;else if(32==e)r=5;else{if(4!=e)return void this.fromRadix(t,e);r=2}this.t=0,this.s=0;for(var i=t.length,n=!1,s=0;--i>=0;){var o=8==r?255&+t[i]:M(t,i);o<0?"-"==t.charAt(i)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}8==r&&0!=(128&+t[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&a.ZERO.subTo(this,this)},a.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},a.prototype.dlShiftTo=function(t,e){var r;for(r=this.t-1;r>=0;--r)e[r+t]=this[r];for(r=t-1;r>=0;--r)e[r]=0;e.t=this.t+t,e.s=this.s},a.prototype.drShiftTo=function(t,e){for(var r=t;r<this.t;++r)e[r-t]=this[r];e.t=Math.max(this.t-t,0),e.s=this.s},a.prototype.lShiftTo=function(t,e){for(var r=t%this.DB,i=this.DB-r,n=(1<<i)-1,s=Math.floor(t/this.DB),o=this.s<<r&this.DM,a=this.t-1;a>=0;--a)e[a+s+1]=this[a]>>i|o,o=(this[a]&n)<<r;for(a=s-1;a>=0;--a)e[a]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},a.prototype.rShiftTo=function(t,e){e.s=this.s;var r=Math.floor(t/this.DB);if(r>=this.t)e.t=0;else{var i=t%this.DB,n=this.DB-i,s=(1<<i)-1;e[0]=this[r]>>i;for(var o=r+1;o<this.t;++o)e[o-r-1]|=(this[o]&s)<<n,e[o-r]=this[o]>>i;i>0&&(e[this.t-r-1]|=(this.s&s)<<n),e.t=this.t-r,e.clamp()}},a.prototype.subTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]-t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i-=t[r],e[r++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[r++]=this.DV+i:i>0&&(e[r++]=i),e.t=r,e.clamp()},a.prototype.multiplyTo=function(t,e){var r=this.abs(),i=t.abs(),n=r.t;for(e.t=n+i.t;--n>=0;)e[n]=0;for(n=0;n<i.t;++n)e[n+r.t]=r.am(0,i[n],e,n,0,r.t);e.s=0,e.clamp(),this.s!=t.s&&a.ZERO.subTo(e,e)},a.prototype.squareTo=function(t){for(var e=this.abs(),r=t.t=2*e.t;--r>=0;)t[r]=0;for(r=0;r<e.t-1;++r){var i=e.am(r,e[r],t,2*r,0,1);(t[r+e.t]+=e.am(r+1,2*e[r],t,2*r+1,i,e.t-r-1))>=e.DV&&(t[r+e.t]-=e.DV,t[r+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(r,e[r],t,2*r,0,1)),t.s=0,t.clamp()},a.prototype.divRemTo=function(t,e,r){var i=t.abs();if(!(i.t<=0)){var n=this.abs();if(n.t<i.t)return null!=e&&e.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=B());var s=B(),o=this.s,h=t.s,u=this.DB-C(i[i.t-1]);u>0?(i.lShiftTo(u,s),n.lShiftTo(u,r)):(i.copyTo(s),n.copyTo(r));var c=s.t,f=s[c-1];if(0!=f){var l=f*(1<<this.F1)+(c>1?s[c-2]>>this.F2:0),p=this.FV/l,d=(1<<this.F1)/l,g=1<<this.F2,v=r.t,m=v-c,y=null==e?B():e;for(s.dlShiftTo(m,y),r.compareTo(y)>=0&&(r[r.t++]=1,r.subTo(y,r)),a.ONE.dlShiftTo(c,y),y.subTo(s,s);s.t<c;)s[s.t++]=0;for(;--m>=0;){var b=r[--v]==f?this.DM:Math.floor(r[v]*p+(r[v-1]+g)*d);if((r[v]+=s.am(0,b,r,m,0,c))<b)for(s.dlShiftTo(m,y),r.subTo(y,r);r[v]<--b;)r.subTo(y,r)}null!=e&&(r.drShiftTo(c,e),o!=h&&a.ZERO.subTo(e,e)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&a.ZERO.subTo(r,r)}}},a.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)>0?this.DV-e:-e},a.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},a.prototype.exp=function(t,e){if(t>4294967295||t<1)return a.ONE;var r=B(),i=B(),n=e.convert(this),s=C(t)-1;for(n.copyTo(r);--s>=0;)if(e.sqrTo(r,i),(t&1<<s)>0)e.mulTo(i,n,r);else{var o=r;r=i,i=o}return e.revert(r)},a.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},a.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),r=Math.pow(t,e),i=q(r),n=B(),s=B(),o="";for(this.divRemTo(i,n,s);n.signum()>0;)o=(r+s.intValue()).toString(t).substr(1)+o,n.divRemTo(i,n,s);return s.intValue().toString(t)+o},a.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var r=this.chunkSize(e),i=Math.pow(e,r),n=!1,s=0,o=0,h=0;h<t.length;++h){var u=M(t,h);u<0?"-"==t.charAt(h)&&0==this.signum()&&(n=!0):(o=e*o+u,++s>=r&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&a.ZERO.subTo(this,this)},a.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(a.ONE.shiftLeft(t-1),r,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(a.ONE.shiftLeft(t-1),this);else{var n=[],s=7&t;n.length=1+(t>>3),e.nextBytes(n),s>0?n[0]&=(1<<s)-1:n[0]=0,this.fromString(n,256)}},a.prototype.bitwiseTo=function(t,e,r){var i,n,s=Math.min(t.t,this.t);for(i=0;i<s;++i)r[i]=e(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=s;i<this.t;++i)r[i]=e(this[i],n);r.t=this.t}else{for(n=this.s&this.DM,i=s;i<t.t;++i)r[i]=e(n,t[i]);r.t=t.t}r.s=e(this.s,t.s),r.clamp()},a.prototype.changeBit=function(t,e){var r=a.ONE.shiftLeft(t);return this.bitwiseTo(r,e,r),r},a.prototype.addTo=function(t,e){for(var r=0,i=0,n=Math.min(t.t,this.t);r<n;)i+=this[r]+t[r],e[r++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;r<this.t;)i+=this[r],e[r++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;r<t.t;)i+=t[r],e[r++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[r++]=i:i<-1&&(e[r++]=this.DV+i),e.t=r,e.clamp()},a.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},a.prototype.dAddOffset=function(t,e){if(0!=t){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]}},a.prototype.multiplyLowerTo=function(t,e,r){var i=Math.min(this.t+t.t,e);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(var n=r.t-this.t;i<n;++i)r[i+this.t]=this.am(0,t[i],r,i,0,this.t);for(n=Math.min(t.t,e);i<n;++i)this.am(0,t[i],r,i,0,e-i);r.clamp()},a.prototype.multiplyUpperTo=function(t,e,r){--e;var i=r.t=this.t+t.t-e;for(r.s=0;--i>=0;)r[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)r[this.t+i-e]=this.am(e-i,t[i],r,0,0,this.t+i-e);r.clamp(),r.drShiftTo(1,r)},a.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,r=this.s<0?t-1:0;if(this.t>0)if(0==e)r=this[0]%t;else for(var i=this.t-1;i>=0;--i)r=(e*r+this[i])%t;return r},a.prototype.millerRabin=function(t){var e=this.subtract(a.ONE),r=e.getLowestSetBit();if(r<=0)return!1;var i=e.shiftRight(r);(t=t+1>>1)>w.length&&(t=w.length);for(var n=B(),s=0;s<t;++s){n.fromInt(w[Math.floor(Math.random()*w.length)]);var o=n.modPow(i,this);if(0!=o.compareTo(a.ONE)&&0!=o.compareTo(e)){for(var h=1;h++<r&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(a.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},a.prototype.square=function(){var t=B();return this.squareTo(t),t},a.prototype.gcda=function(t,e){var r=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(r.compareTo(i)<0){var n=r;r=i,i=n}var s=r.getLowestSetBit(),o=i.getLowestSetBit();if(o<0)e(r);else{s<o&&(o=s),o>0&&(r.rShiftTo(o,r),i.rShiftTo(o,i));var a=function(){(s=r.getLowestSetBit())>0&&r.rShiftTo(s,r),(s=i.getLowestSetBit())>0&&i.rShiftTo(s,i),r.compareTo(i)>=0?(r.subTo(i,r),r.rShiftTo(1,r)):(i.subTo(r,i),i.rShiftTo(1,i)),r.signum()>0?setTimeout(a,0):(o>0&&i.lShiftTo(o,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}},a.prototype.fromNumberAsync=function(t,e,i,n){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(a.ONE.shiftLeft(t-1),r,this),this.isEven()&&this.dAddOffset(1,0);var s=this,o=function(){s.dAddOffset(2,0),s.bitLength()>t&&s.subTo(a.ONE.shiftLeft(t-1),s),s.isProbablePrime(e)?setTimeout((function(){n()}),0):setTimeout(o,0)};setTimeout(o,0)}else{var h=[],u=7&t;h.length=1+(t>>3),e.nextBytes(h),u>0?h[0]&=(1<<u)-1:h[0]=0,this.fromString(h,256)}},a}(),x=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),O=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),A=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=B();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(D.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=B();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var r=32767&t[e],i=r*this.mpl+((r*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[r=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[r]>=t.DV;)t[r]-=t.DV,t[++r]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),R=function(){function t(t){this.m=t,this.r2=B(),this.q3=B(),D.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.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=B();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.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)},t.prototype.mulTo=function(t,e,r){t.multiplyTo(e,r),this.reduce(r)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function B(){return new D(null)}function V(t,e){return new D(t,e)}var I="undefined"!=typeof navigator;I&&"Microsoft Internet Explorer"==navigator.appName?(D.prototype.am=function(t,e,r,i,n,s){for(var o=32767&e,a=e>>15;--s>=0;){var h=32767&this[t],u=this[t++]>>15,c=a*h+u*o;n=((h=o*h+((32767&c)<<15)+r[i]+(1073741823&n))>>>30)+(c>>>15)+a*u+(n>>>30),r[i++]=1073741823&h}return n},y=30):I&&"Netscape"!=navigator.appName?(D.prototype.am=function(t,e,r,i,n,s){for(;--s>=0;){var o=e*this[t++]+r[i]+n;n=Math.floor(o/67108864),r[i++]=67108863&o}return n},y=26):(D.prototype.am=function(t,e,r,i,n,s){for(var o=16383&e,a=e>>14;--s>=0;){var h=16383&this[t],u=this[t++]>>14,c=a*h+u*o;n=((h=o*h+((16383&c)<<14)+r[i]+n)>>28)+(c>>14)+a*u,r[i++]=268435455&h}return n},y=28),D.prototype.DB=y,D.prototype.DM=(1<<y)-1,D.prototype.DV=1<<y,D.prototype.FV=Math.pow(2,52),D.prototype.F1=52-y,D.prototype.F2=2*y-52;var N,P,j=[];for(N="0".charCodeAt(0),P=0;P<=9;++P)j[N++]=P;for(N="a".charCodeAt(0),P=10;P<36;++P)j[N++]=P;for(N="A".charCodeAt(0),P=10;P<36;++P)j[N++]=P;function M(t,e){var r=j[t.charCodeAt(e)];return null==r?-1:r}function q(t){var e=B();return e.fromInt(t),e}function C(t){var e,r=1;return 0!=(e=t>>>16)&&(t=e,r+=16),0!=(e=t>>8)&&(t=e,r+=8),0!=(e=t>>4)&&(t=e,r+=4),0!=(e=t>>2)&&(t=e,r+=2),0!=(e=t>>1)&&(t=e,r+=1),r}D.ZERO=q(0),D.ONE=q(1);var L,_,H=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,r,i;for(e=0;e<256;++e)this.S[e]=e;for(r=0,e=0;e<256;++e)r=r+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[r],this.S[r]=i;this.i=0,this.j=0},t.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]},t}(),k=null;if(null==k){k=[],_=0;var F=void 0;if(window.crypto&&window.crypto.getRandomValues){var U=new Uint32Array(256);for(window.crypto.getRandomValues(U),F=0;F<U.length;++F)k[_++]=255&U[F]}var K=0,z=function(t){if((K=K||0)>=256||_>=256)window.removeEventListener?window.removeEventListener("mousemove",z,!1):window.detachEvent&&window.detachEvent("onmousemove",z);else try{var e=t.x+t.y;k[_++]=255&e,K+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",z,!1):window.attachEvent&&window.attachEvent("onmousemove",z)}function Z(){if(null==L){for(L=new H;_<256;){var t=Math.floor(65536*Math.random());k[_++]=255&t}for(L.init(k),_=0;_<k.length;++_)k[_]=0;_=0}return L.next()}var $=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=Z()},t}(),G=function(){function t(){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 t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),r=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(r)<0;)e=e.add(this.p);return e.subtract(r).multiply(this.coeff).mod(this.p).multiply(this.q).add(r)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=this.n.bitLength()+7>>3,r=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var r=[],i=t.length-1;i>=0&&e>0;){var n=t.charCodeAt(i--);n<128?r[--e]=n:n>127&&n<2048?(r[--e]=63&n|128,r[--e]=n>>6|192):(r[--e]=63&n|128,r[--e]=n>>6&63|128,r[--e]=n>>12|224)}r[--e]=0;for(var s=new $,o=[];e>2;){for(o[0]=0;0==o[0];)s.nextBytes(o);r[--e]=o[0]}return r[--e]=2,r[--e]=0,new D(r)}(t,e);if(null==r)return null;var i=this.doPublic(r);if(null==i)return null;for(var n=i.toString(16),s=n.length,o=0;o<2*e-s;o++)n="0"+n;return n},t.prototype.setPrivate=function(t,e,r){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16),this.d=V(r,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,r,i,n,s,o,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=V(t,16),this.e=parseInt(e,16),this.d=V(r,16),this.p=V(i,16),this.q=V(n,16),this.dmp1=V(s,16),this.dmq1=V(o,16),this.coeff=V(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var r=new $,i=t>>1;this.e=parseInt(e,16);for(var n=new D(e,16);;){for(;this.p=new D(t-i,1,r),0!=this.p.subtract(D.ONE).gcd(n).compareTo(D.ONE)||!this.p.isProbablePrime(10););for(;this.q=new D(i,1,r),0!=this.q.subtract(D.ONE).gcd(n).compareTo(D.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(D.ONE),a=this.q.subtract(D.ONE),h=o.multiply(a);if(0==h.gcd(n).compareTo(D.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(h),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=V(t,16),r=this.doPrivate(e);return null==r?null:function(t,e){for(var r=t.toByteArray(),i=0;i<r.length&&0==r[i];)++i;if(r.length-i!=e-1||2!=r[i])return null;for(++i;0!=r[i];)if(++i>=r.length)return null;for(var n="";++i<r.length;){var s=255&r[i];s<128?n+=String.fromCharCode(s):s>191&&s<224?(n+=String.fromCharCode((31&s)<<6|63&r[i+1]),++i):(n+=String.fromCharCode((15&s)<<12|(63&r[i+1])<<6|63&r[i+2]),i+=2)}return n}(r,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,r){var i=new $,n=t>>1;this.e=parseInt(e,16);var s=new D(e,16),o=this,a=function(){var e=function(){if(o.p.compareTo(o.q)<=0){var t=o.p;o.p=o.q,o.q=t}var e=o.p.subtract(D.ONE),i=o.q.subtract(D.ONE),n=e.multiply(i);0==n.gcd(s).compareTo(D.ONE)?(o.n=o.p.multiply(o.q),o.d=s.modInverse(n),o.dmp1=o.d.mod(e),o.dmq1=o.d.mod(i),o.coeff=o.q.modInverse(o.p),setTimeout((function(){r()}),0)):setTimeout(a,0)},h=function(){o.q=B(),o.q.fromNumberAsync(n,1,i,(function(){o.q.subtract(D.ONE).gcda(s,(function(t){0==t.compareTo(D.ONE)&&o.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=function(){o.p=B(),o.p.fromNumberAsync(t-n,1,i,(function(){o.p.subtract(D.ONE).gcda(s,(function(t){0==t.compareTo(D.ONE)&&o.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,r){var i=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var r=e-t.length-6,i="",n=0;n<r;n+=2)i+="ff";return V("0001"+i+"00"+t,16)}((Y[r]||"")+e(t).toString(),this.n.bitLength()/4);if(null==i)return null;var n=this.doPrivate(i);if(null==n)return null;var s=n.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,r){var i=V(e,16),n=this.doPublic(i);return null==n?null:function(t){for(var e in Y)if(Y.hasOwnProperty(e)){var r=Y[e],i=r.length;if(t.substr(0,i)==r)return t.substr(i)}return t}(n.toString(16).replace(/^1f+00/,""))==r(t).toString()},t}(),Y={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},X={};X.lang={extend:function(t,e,r){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var i=function(){};if(i.prototype=e.prototype,t.prototype=new i,t.prototype.constructor=t,t.superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),r){var n;for(n in r)t.prototype[n]=r[n];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(n=0;n<o.length;n+=1){var r=o[n],i=e[r];"function"==typeof i&&i!=Object.prototype[r]&&(t[r]=i)}})}catch(t){}s(t.prototype,r)}}};var J={};void 0!==J.asn1&&J.asn1||(J.asn1={}),J.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var r=e.substr(1).length;r%2==1?r+=1:e.match(/^[0-7]/)||(r+=2);for(var i="",n=0;n<r;n++)i+="f";e=new D(i,16).xor(t).add(D.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=J.asn1,r=e.DERBoolean,i=e.DERInteger,n=e.DERBitString,s=e.DEROctetString,o=e.DERNull,a=e.DERObjectIdentifier,h=e.DEREnumerated,u=e.DERUTF8String,c=e.DERNumericString,f=e.DERPrintableString,l=e.DERTeletexString,p=e.DERIA5String,d=e.DERUTCTime,g=e.DERGeneralizedTime,v=e.DERSequence,m=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,S=Object.keys(t);if(1!=S.length)throw"key of param shall be only one.";var T=S[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+T+":"))throw"undefined key: "+T;if("bool"==T)return new r(t[T]);if("int"==T)return new i(t[T]);if("bitstr"==T)return new n(t[T]);if("octstr"==T)return new s(t[T]);if("null"==T)return new o(t[T]);if("oid"==T)return new a(t[T]);if("enum"==T)return new h(t[T]);if("utf8str"==T)return new u(t[T]);if("numstr"==T)return new c(t[T]);if("prnstr"==T)return new f(t[T]);if("telstr"==T)return new l(t[T]);if("ia5str"==T)return new p(t[T]);if("utctime"==T)return new d(t[T]);if("gentime"==T)return new g(t[T]);if("seq"==T){for(var w=t[T],E=[],D=0;D<w.length;D++){var x=b(w[D]);E.push(x)}return new v({array:E})}if("set"==T){for(w=t[T],E=[],D=0;D<w.length;D++)x=b(w[D]),E.push(x);return new m({array:E})}if("tag"==T){var O=t[T];if("[object Array]"===Object.prototype.toString.call(O)&&3==O.length){var A=b(O[2]);return new y({tag:O[0],explicit:O[1],obj:A})}var R={};if(void 0!==O.explicit&&(R.explicit=O.explicit),void 0!==O.tag&&(R.tag=O.tag),void 0===O.obj)throw"obj shall be specified for 'tag'.";return R.obj=b(O.obj),new y(R)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},J.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",r=parseInt(t.substr(0,2),16),i=(e=Math.floor(r/40)+"."+r%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);i+=s.substr(1,7),"0"==s.substr(0,1)&&(e=e+"."+new D(i,2).toString(10),i="")}return e},J.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new D(t,10).toString(2),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+i,o=0;o<i.length-1;o+=7){var a=i.substr(o,7);o!=i.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[o]);return i},J.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: 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 r=e.length/2;if(r>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+r).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||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""}},J.asn1.DERAbstractString=function(t){J.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},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},X.lang.extend(J.asn1.DERAbstractString,J.asn1.ASN1Object),J.asn1.DERAbstractTime=function(t){J.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,r){var i=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+i(String(n.getMonth()+1),2)+i(String(n.getDate()),2)+i(String(n.getHours()),2)+i(String(n.getMinutes()),2)+i(String(n.getSeconds()),2);if(!0===r){var a=n.getMilliseconds();if(0!=a){var h=i(String(a),3);o=o+"."+(h=h.replace(/[0]+$/,""))}}return o+"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,r,i,n,s){var o=new Date(Date.UTC(t,e-1,r,i,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},X.lang.extend(J.asn1.DERAbstractTime,J.asn1.ASN1Object),J.asn1.DERAbstractStructured=function(t){J.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,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},X.lang.extend(J.asn1.DERAbstractStructured,J.asn1.ASN1Object),J.asn1.DERBoolean=function(){J.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},X.lang.extend(J.asn1.DERBoolean,J.asn1.ASN1Object),J.asn1.DERInteger=function(t){J.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=J.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new D(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},X.lang.extend(J.asn1.DERInteger,J.asn1.ASN1Object),J.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=J.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}J.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var r="0"+t;this.hTLV=null,this.isModified=!0,this.hV=r+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var r=0;r<=e;r++)t+="0";var i="";for(r=0;r<t.length-1;r+=8){var n=t.substr(r,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),i+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+i},this.setByBooleanArray=function(t){for(var e="",r=0;r<t.length;r++)1==t[r]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),r=0;r<t;r++)e[r]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},X.lang.extend(J.asn1.DERBitString,J.asn1.ASN1Object),J.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=J.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}J.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},X.lang.extend(J.asn1.DEROctetString,J.asn1.DERAbstractString),J.asn1.DERNull=function(){J.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},X.lang.extend(J.asn1.DERNull,J.asn1.ASN1Object),J.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},r=function(t){var r="",i=new D(t,10).toString(2),n=7-i.length%7;7==n&&(n=0);for(var s="",o=0;o<n;o++)s+="0";for(i=s+i,o=0;o<i.length-1;o+=7){var a=i.substr(o,7);o!=i.length-7&&(a="1"+a),r+=e(parseInt(a,2))}return r};J.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",n=t.split("."),s=40*parseInt(n[0])+parseInt(n[1]);i+=e(s),n.splice(0,2);for(var o=0;o<n.length;o++)i+=r(n[o]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(t){var e=J.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},X.lang.extend(J.asn1.DERObjectIdentifier,J.asn1.ASN1Object),J.asn1.DEREnumerated=function(t){J.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=J.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new D(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},X.lang.extend(J.asn1.DEREnumerated,J.asn1.ASN1Object),J.asn1.DERUTF8String=function(t){J.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},X.lang.extend(J.asn1.DERUTF8String,J.asn1.DERAbstractString),J.asn1.DERNumericString=function(t){J.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},X.lang.extend(J.asn1.DERNumericString,J.asn1.DERAbstractString),J.asn1.DERPrintableString=function(t){J.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},X.lang.extend(J.asn1.DERPrintableString,J.asn1.DERAbstractString),J.asn1.DERTeletexString=function(t){J.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},X.lang.extend(J.asn1.DERTeletexString,J.asn1.DERAbstractString),J.asn1.DERIA5String=function(t){J.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},X.lang.extend(J.asn1.DERIA5String,J.asn1.DERAbstractString),J.asn1.DERUTCTime=function(t){J.asn1.DERUTCTime.superclass.constructor.call(this,t),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 void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},X.lang.extend(J.asn1.DERUTCTime,J.asn1.DERAbstractTime),J.asn1.DERGeneralizedTime=function(t){J.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),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 void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},X.lang.extend(J.asn1.DERGeneralizedTime,J.asn1.DERAbstractTime),J.asn1.DERSequence=function(t){J.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++)t+=this.asn1Array[e].getEncodedHex();return this.hV=t,this.hV}},X.lang.extend(J.asn1.DERSequence,J.asn1.DERAbstractStructured),J.asn1.DERSet=function(t){J.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var r=this.asn1Array[e];t.push(r.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},X.lang.extend(J.asn1.DERSet,J.asn1.DERAbstractStructured),J.asn1.DERTaggedObject=function(t){J.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,r){this.hT=e,this.isExplicit=t,this.asn1Object=r,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=r.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},X.lang.extend(J.asn1.DERTaggedObject,J.asn1.ASN1Object);var Q,W=(Q=function(t,e){return(Q=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])})(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}Q(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),tt=function(t){function e(r){var i=t.call(this)||this;return r&&("string"==typeof r?i.parseKey(r):(e.hasPrivateKeyProperty(r)||e.hasPublicKeyProperty(r))&&i.parsePropertiesFrom(r)),i}return W(e,t),e.prototype.parseKey=function(t){try{var e=0,r=0,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===a){var r="0123456789ABCDEF",i=" \f\n\r\t \u2028\u2029";for(a={},e=0;e<16;++e)a[r.charAt(e)]=e;for(r=r.toLowerCase(),e=10;e<16;++e)a[r.charAt(e)]=e;for(e=0;e<i.length;++e)a[i.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<t.length;++e){var h=t.charAt(e);if("="==h)break;if(-1!=(h=a[h])){if(void 0===h)throw new Error("Illegal character at offset "+e);s|=h,++o>=2?(n[n.length]=s,s=0,o=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n}(t):l.unarmor(t),n=S.decode(i);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=V(e,16),r=n.sub[2].getHexStringValue(),this.e=parseInt(r,16);var s=n.sub[3].getHexStringValue();this.d=V(s,16);var o=n.sub[4].getHexStringValue();this.p=V(o,16);var h=n.sub[5].getHexStringValue();this.q=V(h,16);var u=n.sub[6].getHexStringValue();this.dmp1=V(u,16);var c=n.sub[7].getHexStringValue();this.dmq1=V(c,16);var f=n.sub[8].getHexStringValue();this.coeff=V(f,16)}else{if(2!==n.sub.length)return!1;var p=n.sub[1].sub[0];e=p.sub[0].getHexStringValue(),this.n=V(e,16),r=p.sub[1].getHexStringValue(),this.e=parseInt(r,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new J.asn1.DERInteger({int:0}),new J.asn1.DERInteger({bigint:this.n}),new J.asn1.DERInteger({int:this.e}),new J.asn1.DERInteger({bigint:this.d}),new J.asn1.DERInteger({bigint:this.p}),new J.asn1.DERInteger({bigint:this.q}),new J.asn1.DERInteger({bigint:this.dmp1}),new J.asn1.DERInteger({bigint:this.dmq1}),new J.asn1.DERInteger({bigint:this.coeff})]};return new J.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return u(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new J.asn1.DERSequence({array:[new J.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new J.asn1.DERNull]}),e=new J.asn1.DERSequence({array:[new J.asn1.DERInteger({bigint:this.n}),new J.asn1.DERInteger({int:this.e})]}),r=new J.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new J.asn1.DERSequence({array:[t,r]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return u(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var r="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(r,"g")).join("\n")},e.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return(t+=e.wordwrap(this.getPrivateBaseKeyB64())+"\n")+"-----END RSA PRIVATE KEY-----"},e.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return(t+=e.wordwrap(this.getPublicBaseKeyB64())+"\n")+"-----END PUBLIC KEY-----"},e.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},e.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},e.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},e}(G);const et=function(){function t(t){t=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=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new tt(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(c(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return u(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,r){try{return u(this.getKey().sign(t,e,r))}catch(t){return!1}},t.prototype.verify=function(t,e,r){try{return this.getKey().verify(t,c(e),r)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new tt,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.2.0",t}(),rt=window.Rails||window.$.rails;var it=function(t){var e=t.headers,r=t.status;return 404===r||500<=r?Promise.reject({headers:e,status:r}):-1!==(t.headers.get("Content-Type")+"").indexOf("json")&&204!==t.status?t.json().then((function(t){return{headers:e,status:r,json:t}}),(function(){return{headers:e,status:r,json:null}})):{headers:e,status:r,json:null}};const nt=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={method:e,credentials:"same-origin",headers:new Headers};return i.headers.append("X-CSRF-Token",rt.csrfToken()),i.headers.append("accept","application/json"),r.body&&(r.body instanceof FormData?i.body=r.body:(i.body=JSON.stringify(r.body),i.headers.append("content-type","application/json"))),window.fetch(t,i).then(it,(function(t){return Promise.reject(t)}))};var st,ot,at,ht,ut=function(t){return t&&t.trim().length};window.$&&window.$.payment?(st=window.$.payment.validateCardNumber,ot=window.$.payment.validateCardCVC,at=window.$.payment.validateCardExpiry,ht=window.$.payment.cardExpiryVal):(ot=ut,at=function(t,e){return ut(t)&&ut(e)},ht=function(t){var e=(t||"").split("/");return{month:(e[0]||"").trim(),year:(e[1]||"").trim()}});var ct=ht,ft=function(t,e,r){t[e]||(t[e]=[]),t[e].push(r)};function lt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}var pt=function(t){return document.querySelector('[data-nexio-own-form-id="'.concat(t,'"]'))},dt=window.nexioErrorMessages||{default_error:"Something bad happened!"},gt=function(t,e,r){var i=pt(r),n=function(t,e){var r=document.createElement("label");return r.setAttribute("data-nexio-error",t),r.classList.add("error","nexio-error"),r.innerHTML=function(t,e){return dt[t]&&dt[t][e]||dt.base&&dt.base[e]||dt.default_error}(t,e),r}(t,e);if("base"===t)i.prepend(n);else{var s=i.querySelector('[name="payment_source['.concat(r,"][").concat(t,']"]'));s&&(s.classList.add("error"),s.parentNode.appendChild(n))}},vt={number:"card_number",cc_type:"card_type",name:"card_name",expiry:"card_expiration",verification_value:"card_code"},mt=["number"];function yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,i=new Array(e);r<e;r++)i[r]=t[r];return i}function bt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function St(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?bt(Object(r),!0).forEach((function(e){Tt(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):bt(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Tt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var wt={},Et=function(t){var e=t.slice(0,6),r=t.slice(t.length-4),i="*".repeat(t.length-10);return"".concat(e).concat(i).concat(r)},Dt=function(t){return gt("base","token_generation_failed",t),Promise.reject()},xt=function(t,e){e.setAttribute("disabled","disabled");var r=Dt.bind(null,t);return function(t){var e=wt[t],r=e.paths,i=e.data;return nt(r.oneTimeToken,"POST",{body:{data:i}}).then((function(e){if(201===e.status){var r=e.json.data;return wt[t].token=r.token,r}return Promise.reject()}),(function(){return Promise.reject()}))}(t).then((function(t){return function(t,e){return new Promise((function(r){var i=document.createElement("script");i.onload=r,i.src=e,t.appendChild(i)}))}(e,t.fraud_url).then((function(){return e.removeAttribute("disabled")}),r)}),r)},Ot=function(t,e){return xt(t,pt(t)).then((function(){return gt("base","card_save_failed",t),Promise.reject()}))},At=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r=pt(t);r.removeAttribute("disabled");var i=r.closest("form").querySelector(rt.formEnableSelector);i&&setTimeout((function(){i.removeAttribute("disabled"),i.classList.remove("disabled")}),100),e&&gt("base","default_error",t)},Rt=function(t){t.querySelectorAll('fieldset#payment, fieldset[data-hook="payment"]').forEach((function(t){return t.setAttribute("disabled","disabled")}));var e=document.createElement("input");e.setAttribute("type","hidden"),e.setAttribute("name","order[nexio_placeholder]"),e.setAttribute("value","1"),t.appendChild(e),t.submit()},Bt=function(t,e){var r=new FormData(t);r.delete("_method");var i={body:r};return nt(wt[e].paths.payment,"POST",i).then((function(r){if(200===r.status)switch(r.json.state){case"success":return Rt(t);case"three_d_secure":return function(t,e){var r=window.open(e,"_blank","resizable, width=400, height=600");r.onmessage=function(e){"three_d_secure_result"===e.data.type&&("success"===e.data.state?Rt(t):console.error(e.data))},r.onclose=console.error}(t,r.json.data);default:At(e,!0)}else At(e,!0)}))},Vt=function(t,e,r){var i=function(t){var e=pt(t);return Object.entries(vt).reduce((function(t,r){var i,n,s=(n=2,function(t){if(Array.isArray(t))return t}(i=r)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,s=[],o=!0,a=!1;try{for(r=r.call(t);!(o=(i=r.next()).done)&&(s.push(i.value),!e||s.length!==e);o=!0);}catch(t){a=!0,n=t}finally{try{o||null==r.return||r.return()}finally{if(a)throw n}}return s}}(i,n)||function(t,e){if(t){if("string"==typeof t)return lt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?lt(t,e):void 0}}(i,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=s[0],a=s[1],h=e.querySelector('[data-hook="'.concat(a,'"]'));if(h)if(["INPUT","SELECT"].includes(h.nodeName))t[o]=h.value;else{var u=h.querySelector("input[name], select[name]");u&&(t[o]=u.value)}return t}),{})}(t);Object.assign(i,ct(i.expiry));var n=function(t){var e={};return["number","name","expiry","verification_value"].forEach((function(r){return ut(t[r])?null:ft(e,r,"blank")})),ut(t.number)&&!st(t.number)&&ft(e,"number","invalid"),ut(t.verification_value)&&!ot(t.verification_value,t.cc_type)&&ft(e,"verification_value","invalid"),ut(t.expiry)&&!at(t.month,t.year)&&ft(e,"expiry","invalid"),e}(i);if(0<Object.keys(n).length)return At(t),function(t,e,r){Object.entries(e).forEach((function(e){var r,i,n=(i=2,function(t){if(Array.isArray(t))return t}(r=e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var i,n,s=[],o=!0,a=!1;try{for(r=r.call(t);!(o=(i=r.next()).done)&&(s.push(i.value),!e||s.length!==e);o=!0);}catch(t){a=!0,n=t}finally{try{o||null==r.return||r.return()}finally{if(a)throw n}}return s}}(r,i)||function(t,e){if(t){if("string"==typeof t)return yt(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?yt(t,e):void 0}}(r,i)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),s=n[0];n[1].forEach((function(e){return gt(s,e,t)}))}))}(t,n);e.setAttribute("disabled","disabled"),function(t,e){var r=wt[t],i=e.number,n=function(t,e){if(null==t)return{};var r,i,n=function(t,e){if(null==t)return{};var r,i,n={},s=Object.keys(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||(n[r]=t[r]);return n}(t,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(t);for(i=0;i<s.length;i++)r=s[i],e.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}(e,mt);i=i.replace(/\D+/g,"");var s=new et;s.setPublicKey(r.publicKey);var o=St(St({},r.data),{},{one_time_token:r.token,card:St(St({},n),{},{encrypted_number:s.encrypt(i),number:Et(i)})});return nt(r.paths.creditCard,"POST",{body:{data:o}}).then((function(t){return 201===t.status?t.json.data:Promise.reject(t)}),(function(t){return Promise.reject(t)}))}(t,i).then((function(i){e.querySelector('[data-hook="card_gateway_payment_profile_id"]').value=i.token,e.removeAttribute("disabled"),Bt(r,t)}),Ot.bind(null,t,e)).catch((function(){return At(t,!0)}))};window.addNexioOwnForm=function(t,e){wt[t]=e},window.jQuery((function(){window.onNexioError&&(onError=window.onNexioError),Object.keys(wt).forEach((function(t){var e=pt(t);xt(t,e).then((function(){var r=e.closest("form");r.addEventListener("submit",(function(i){!function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=pt(t);null==r&&(e=i.querySelectorAll("[data-nexio-error]")),e.forEach((function(t){var e=t.parentNode;e.removeChild(t);var r=e.querySelector("[name].error");r&&r.classList.remove("error")}))}(t),0<e.clientHeight?(i.preventDefault(),Vt(t,e,r)):function(t,e){var r=wt[e].walletCardIds;if(Array.isArray(r))return!1;var i=new FormData(t).get("order[wallet_payment_source_id]");return i&&r.includes(parseInt(i))}(r,t)&&(i.preventDefault(),Bt(r,t))}))}))}))}))})()})();
@@ -9,7 +9,7 @@ module SolidusNexio
9
9
  private
10
10
 
11
11
  def payment_method
12
- @payment_method ||= SolidusNexio::PaymentMethod.find(params[:payment_method_id])
12
+ @payment_method ||= PaymentMethod.find(params[:payment_method_id])
13
13
  end
14
14
  end
15
15
  end
@@ -4,6 +4,7 @@ module SolidusNexio
4
4
  class CreditCardsController < BasePaymentController
5
5
  def create
6
6
  token = payment_method.store(credit_card_params)
7
+
7
8
  if token
8
9
  render json: { data: { token: token } }, status: 201
9
10
  else
@@ -0,0 +1,25 @@
1
+ module SolidusNexio
2
+ class PaymentsController < Spree::CheckoutController
3
+ def create
4
+ if update_order
5
+ payment_method = PaymentMethod.find(params[:payment_method_id])
6
+ result = payment_method.process_order_payment(@order)
7
+ render json: result
8
+ else
9
+ render json: { error: :invalid_order, details: @order.errors.to_h }, status: 422
10
+ end
11
+ end
12
+
13
+ def capture
14
+ payment_method = PaymentMethod.find(params[:payment_method_id])
15
+ payment = payment_method.payments.find(params[:payment_id])
16
+ @result = payment_method.capture_order_payment(payment, params[:id], params[:status])
17
+ end
18
+
19
+ private
20
+
21
+ def update_params
22
+ massaged_params.require(:order).permit(permitted_checkout_payment_attributes)
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ module SolidusNexio
2
+ class WebhooksController < ActionController::API
3
+ before_action :authorize_request
4
+
5
+ def create
6
+ Webhook.process(params[:eventType], params[:data])
7
+ end
8
+
9
+ private
10
+
11
+ def authorize_request
12
+ headers['Nexio-signature']
13
+ end
14
+ end
15
+ end
@@ -5,7 +5,10 @@ module SolidusNexio
5
5
  def setup_nexio_own_form(payment_method, user:, order:)
6
6
  # include js script only once per request
7
7
  unless @__nexio_checkout_script
8
- content_for(:head) { javascript_include_tag('solidus_nexio/checkout.js') }
8
+ content_for(:head) {
9
+ javascript_tag("window.nexioErrorMessages = #{I18n.t('nexio.errors').to_json};") +
10
+ javascript_include_tag('solidus_nexio/checkout.js')
11
+ }
9
12
  @__nexio_checkout_script = true
10
13
  end
11
14
 
@@ -13,10 +16,18 @@ module SolidusNexio
13
16
  publicKey: payment_method.preferred_public_key,
14
17
  paths: {
15
18
  oneTimeToken: solidus_nexio.payment_method_one_time_tokens_path(payment_method),
16
- creditCard: solidus_nexio.payment_method_credit_cards_path(payment_method)
19
+ creditCard: solidus_nexio.payment_method_credit_cards_path(payment_method),
20
+ payment: solidus_nexio.payment_method_payments_path(payment_method)
17
21
  },
18
22
  data: NexioData.one_time_token(user: user, order: order)
19
23
  }
24
+
25
+ if @wallet_payment_sources
26
+ config[:walletCardIds] = @wallet_payment_sources.each_with_object([]) do |wps, acc|
27
+ acc.push(wps.id) if wps.payment_source && wps.payment_source.payment_method_id == payment_method.id
28
+ end
29
+ end
30
+
20
31
  javascript_tag("window.addNexioOwnForm(#{payment_method.id}, #{config.to_json});")
21
32
  end
22
33
  end
@@ -2,6 +2,8 @@
2
2
 
3
3
  module SolidusNexio
4
4
  class PaymentMethod < SolidusSupport.payment_method_parent_class(credit_card: true)
5
+ ProcessResult = Struct.new(:state, :data)
6
+
5
7
  # Preferences for configuration of Braintree credentials
6
8
  preference(:server, :string, default: 'test')
7
9
  preference(:merchant_id, :string, default: nil)
@@ -9,6 +11,41 @@ module SolidusNexio
9
11
  preference(:public_key, :string, default: nil)
10
12
  preference(:ui, :boolean, default: 'own_form') # in future add iframe
11
13
 
14
+ def process_order_payment(order)
15
+ payment = payments.merge(order.payments).checkout.last
16
+ # nothing needed to be done, as other payments cover order
17
+ return ProcessResult.new(:success, :absent) unless payment
18
+
19
+ callback_url = Engine.routes.url_helpers.capture_payment_method_payment_url(self, payment)
20
+ payment.instance_variable_set(:@nexio_callback_url, callback_url)
21
+ begin
22
+ payment.process!
23
+ ProcessResult.new(:success, nil)
24
+ rescue Spree::Core::GatewayError => error
25
+ redirect_url = nexio_three_d_secure_redirect_url(payment)
26
+ return ProcessResult.new(:error, error: :fail_process) unless redirect_url
27
+
28
+ payment.state = :checkout
29
+ payment.save!
30
+ ProcessResult.new(:three_d_secure, redirect_url)
31
+ ensure
32
+ payment.remove_instance_variable(:@nexio_callback_url)
33
+ end
34
+ end
35
+
36
+ def capture_order_payment(payment, id, status)
37
+ return ProcessResult.new(:invalid, nil) unless payment.checkout?
38
+
39
+ if id.present? && %w[pending authOnly].include?(status)
40
+ payment.response_code = id
41
+ auto_capture? ? payment.complete! : payment.pend!
42
+ ProcessResult.new(:success, nil)
43
+ else
44
+ payment.invalidate!
45
+ ProcessResult.new(:invalid, nil)
46
+ end
47
+ end
48
+
12
49
  def partial_name
13
50
  "nexio_#{preferred_ui}"
14
51
  end
@@ -49,9 +86,24 @@ module SolidusNexio
49
86
  def add_transaction_options(options)
50
87
  result = options.slice(:currency, :billing_address, :shipping_address)
51
88
  if options[:originator].is_a?(::Spree::Payment) && options[:originator].order
52
- result.merge!(SolidusNexio::NexioData.purchase(options[:originator].order))
89
+ payment = options[:originator]
90
+ result.merge!(SolidusNexio::NexioData.purchase(payment.order))
91
+ # called from customer checkout page
92
+ if payment.instance_variable_get(:@nexio_callback_url)
93
+ result[:three_d_callback_url] = payment.instance_variable_get(:@nexio_callback_url)
94
+ result[:three_d_secure] = true
95
+ else
96
+ result[:three_d_secure] = false
97
+ end
53
98
  end
54
99
  result
55
100
  end
101
+
102
+ def nexio_three_d_secure_redirect_url(payment)
103
+ resp = payment.log_entries.last.try(:parsed_details)
104
+ return unless resp.is_a?(ActiveMerchant::Billing::Response)
105
+
106
+ resp.params['redirectUrl'] if resp.params['status'] == 'redirect'
107
+ end
56
108
  end
57
109
  end
@@ -0,0 +1,4 @@
1
+ module SolidusNexio
2
+ class Webhook < ApplicationRecord
3
+ end
4
+ end
@@ -0,0 +1,3 @@
1
+ <script>
2
+ window.parent.postMessage({ type: 'three_d_secure_result', state: '<%= @result.state %>' });
3
+ </script>
@@ -1,10 +1 @@
1
- <tr id="<%= dom_id(wallet_payment_source, 'spree')%>" class="<%= cycle('even', 'odd') %>">
2
- <td>
3
- <%= radio_button_tag "order[wallet_payment_source_id]",
4
- wallet_payment_source.id,
5
- default,
6
- class: "existing-cc-radio" %>
7
- </td>
8
- <td><%= wallet_payment_source.payment_source.cc_type %></td>
9
- <td><%= wallet_payment_source.payment_source.display_number %></td>
10
- </tr>
1
+ <%= render partial: 'spree/checkout/existing_payment/gateway', locals: local_assigns %>
@@ -1,7 +1,6 @@
1
- <%= setup_nexio_own_form(payment_method, order: current_order, user: current_spree_user) %>
2
-
3
- <h1><%= payment_method.name %></h1>
4
-
5
1
  <fieldset class="nexio-own-form" data-hook="nexio_own_form" data-nexio-own-form-id="<%= payment_method.id %>">
6
- <%= render "spree/shared/nexio_own_form", payment_method: payment_method %>
2
+ <%= render 'spree/checkout/payment/gateway', payment_method: payment_method %>
3
+ <input name="payment_source[<%= payment_method.id %>][gateway_payment_profile_id]" type="hidden" data-hook="card_gateway_payment_profile_id" />
4
+ <input name="payment_source[<%= payment_method.id %>][cc_type]" type="hidden" data-hook="card_type" class="ccType" />
7
5
  </fieldset>
6
+ <%= setup_nexio_own_form(payment_method, order: current_order, user: current_spree_user) %>
@@ -2,3 +2,11 @@ en:
2
2
  activerecord:
3
3
  models:
4
4
  solidus_nexio/payment_method: Nexio
5
+ nexio:
6
+ errors:
7
+ default_error: Something bad happened!
8
+ base:
9
+ card_save_failed: Can't process the credit card
10
+ token_generation_failed: Can't initialize Nexio form
11
+ blank: is blank
12
+ invalid: is invalid
data/config/routes.rb CHANGED
@@ -4,5 +4,9 @@ SolidusNexio::Engine.routes.draw do
4
4
  resources :payment_methods, only: [] do
5
5
  resources :one_time_tokens, only: %i[create]
6
6
  resources :credit_cards, only: %i[create]
7
+ resources :payments, only: %i[create], param: :payment_id do
8
+ get :capture, on: :member
9
+ end
7
10
  end
11
+ resources :webhooks, only: :create
8
12
  end
@@ -0,0 +1,9 @@
1
+ class CreateSolidusNexioSolidusNexioWebhooks < ActiveRecord::Migration[6.1]
2
+ def change
3
+ create_table :solidus_nexio_solidus_nexio_webhooks do |t|
4
+ t.text :data
5
+
6
+ t.timestamps
7
+ end
8
+ end
9
+ end
data/lib/solidus_nexio.rb CHANGED
@@ -6,4 +6,15 @@ require 'solidus_nexio/engine'
6
6
 
7
7
  module SolidusNexio
8
8
  class Error < StandardError; end
9
+
10
+ def self.table_name_prefix
11
+ 'solidus_nexio_solidus_nexio_'
12
+ end
13
+
14
+ @config = OpenStruct.new(merchant_secrets: [], save_webhooks: false)
15
+
16
+ def self.config
17
+ yield @config if block_given?
18
+ @config
19
+ end
9
20
  end
@@ -23,6 +23,7 @@ module SolidusNexio
23
23
  config.after_initialize do |app|
24
24
  app.config.spree.payment_methods << SolidusNexio::PaymentMethod
25
25
  ::Spree::PermittedAttributes.source_attributes.push(:encrypted_number)
26
+ SolidusNexio::Engine.routes.default_url_options = app.routes.default_url_options
26
27
  end
27
28
  end
28
29
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusNexio
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
@@ -33,5 +33,5 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'solidus_api', '>= 2.0'
34
34
  spec.add_dependency 'solidus_core', '>= 2.0'
35
35
  spec.add_dependency 'solidus_support', '~> 0.6'
36
- spec.add_dependency 'nexio_activemerchant', '~> 0.1'
36
+ spec.add_dependency 'nexio_activemerchant', '~> 0.2'
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_nexio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Whitespectre
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-07-20 00:00:00.000000000 Z
11
+ date: 2021-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.1'
75
+ version: '0.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.1'
82
+ version: '0.2'
83
83
  description:
84
84
  email:
85
85
  - hello@whitespectre.com
@@ -97,16 +97,20 @@ files:
97
97
  - app/controllers/solidus_nexio/base_payment_controller.rb
98
98
  - app/controllers/solidus_nexio/credit_cards_controller.rb
99
99
  - app/controllers/solidus_nexio/one_time_tokens_controller.rb
100
+ - app/controllers/solidus_nexio/payments_controller.rb
101
+ - app/controllers/solidus_nexio/webhooks_controller.rb
100
102
  - app/helpers/solidus_nexio/checkout_helper.rb
101
103
  - app/models/solidus_nexio/payment_method.rb
104
+ - app/models/solidus_nexio/webhook.rb
102
105
  - app/services/solidus_nexio/nexio_data.rb
106
+ - app/views/solidus_nexio/payments/capture.html.erb
103
107
  - app/views/spree/admin/payments/source_forms/_nexio_own_form.html.erb
104
108
  - app/views/spree/admin/payments/source_views/_nexio_own_form.html.erb
105
109
  - app/views/spree/checkout/existing_payment/_nexio_own_form.html.erb
106
110
  - app/views/spree/checkout/payment/_nexio_own_form.html.erb
107
- - app/views/spree/shared/_nexio_own_form.html.erb
108
111
  - config/locales/en.yml
109
112
  - config/routes.rb
113
+ - db/migrate/20210723155452_create_solidus_nexio_solidus_nexio_webhooks.rb
110
114
  - lib/solidus_nexio.rb
111
115
  - lib/solidus_nexio/engine.rb
112
116
  - lib/solidus_nexio/version.rb
@@ -1,34 +0,0 @@
1
- <% id = payment_method.id %>
2
-
3
- <div class="field field-required field--nexio-number" data-hook="nexio_card_number_field">
4
- <label><%= t('spree.card_number') %></label>
5
- <input name="payment_source[<%= id %>][number]" type="text" data-hook="nexio_card_number" class="cardNumber" />
6
- <input name="payment_source[<%= id %>][gateway_payment_profile_id]" type="hidden" data-hook="nexio_card_gateway_payment_profile_id" />
7
- </div>
8
- <input name="payment_source[<%= id %>][cc_type]" type="hidden" data-hook="nexio_card_type" class="ccType" />
9
-
10
- <div class="field field-required field--nexio-name" data-hook="nexio_card_name_field">
11
- <label><%= t('spree.name_on_card') %></label>
12
- <input name="payment_source[<%= id %>][name]" type="text" data-hook="nexio_card_name" />
13
- </div>
14
-
15
- <div class="fieldset fieldset--expirity">
16
- <div class="field field-required field--nexio-month" data-hook="nexio_card_month_field">
17
- <label><%= Spree::CreditCard.human_attribute_name(:month) %></label>
18
- <input name="payment_source[<%= id %>][month]" type="text" data-hook="nexio_card_month" />
19
- </div>
20
-
21
- <div class="field field-required field--nexio-year" data-hook="nexio_card_year_field">
22
- <label><%= Spree::CreditCard.human_attribute_name(:year) %></label>
23
- <input name="payment_source[<%= id %>][year]" type="text" data-hook="nexio_card_year" />
24
- </div>
25
-
26
- <div class="field field-required field--nexio-verification_value" data-hook="nexio_verification_value_field">
27
- <label><%= t('spree.card_code') %></label>
28
- <input name="payment_source[<%= id %>][verification_value]" type="password" data-hook="nexio_verification_value" />
29
-
30
- <a href="/content/cvv" class="info cvvLink" target="_blank">
31
- (<%= I18n.t("spree.what_is_this") %>)
32
- </a>
33
- </div>
34
- </div>