solidus_nexio 0.4.5 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/solidus_nexio/checkout.js +1 -1
  3. data/app/controllers/solidus_nexio/alternative_payments_controller.rb +9 -0
  4. data/app/controllers/solidus_nexio/base_payment_controller.rb +1 -1
  5. data/app/controllers/solidus_nexio/credit_cards_controller.rb +0 -1
  6. data/app/controllers/solidus_nexio/one_time_tokens_controller.rb +11 -5
  7. data/app/controllers/solidus_nexio/payment_states_controller.rb +14 -4
  8. data/app/controllers/solidus_nexio/payments_controller.rb +5 -3
  9. data/app/controllers/solidus_nexio/webhooks_controller.rb +2 -0
  10. data/app/decorators/models/solidus_nexio/payment_decorator.rb +45 -0
  11. data/app/helpers/solidus_nexio/checkout_helper.rb +15 -3
  12. data/app/models/solidus_nexio/alternative_payment_method.rb +41 -0
  13. data/app/models/solidus_nexio/apm_source.rb +19 -0
  14. data/app/models/solidus_nexio/nexio_payment_commons.rb +37 -0
  15. data/app/models/solidus_nexio/payment_method.rb +9 -31
  16. data/app/models/solidus_nexio/webhook.rb +3 -2
  17. data/app/services/solidus_nexio/mappings.rb +27 -0
  18. data/app/views/spree/admin/payments/source_forms/_nexio_apm.html.erb +0 -0
  19. data/app/views/spree/admin/payments/source_views/_nexio_apm.html.erb +0 -0
  20. data/app/views/spree/api/payments/source_views/_nexio_own_form.json.jbuilder +3 -5
  21. data/app/views/spree/checkout/existing_payment/_nexio_apm.html.erb +9 -0
  22. data/app/views/spree/checkout/payment/_nexio_apm.html.erb +5 -0
  23. data/config/locales/en.yml +4 -0
  24. data/config/routes.rb +3 -0
  25. data/db/migrate/20210723155452_create_solidus_nexio_solidus_nexio_webhooks.rb +2 -0
  26. data/db/migrate/20211109171335_add_solidus_nexio_apm_source.rb +15 -0
  27. data/lib/solidus_nexio/engine.rb +2 -0
  28. data/lib/solidus_nexio/version.rb +1 -1
  29. data/solidus_nexio.gemspec +1 -1
  30. metadata +27 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4f32f942482ab71b677fe06a8c00e9c464ea74e9e83ec92958d40a4eb0ba7ce
4
- data.tar.gz: fec0dcf3f189afb377b5caf19299c34e30d4c7c79258ae86ece6719bdfebdca4
3
+ metadata.gz: 263ffd9afec22237ae2185133699eb70c8fe1185300127e376ca08f9b83ca292
4
+ data.tar.gz: 3e59087d7ae46fe109cd186f74fbbb81d6f0ee0258399f8e68f3b6e28bfef172
5
5
  SHA512:
6
- metadata.gz: 867b62c3d119bf846226c4e0bd4c1e32dc5250239645763f339a7b9e61e38f65216101f140f6a8e5d85889cb5c14d88db3287e8f20d21c025d2c4e17ca9e1a87
7
- data.tar.gz: 859a74fe74eb4a88b78f557c13349864510abfc8f5aca95213ad2ef989d337f42d109b1a4367baf9226dd04d144af3b32360ff21b3ce40f26ce2a6cc3f5a493e
6
+ metadata.gz: 902d8f7424af0890bb27ef2d45078a3cbfa29d7eb5cf1af62a00807909db621ad93e2829e6d32e0e86eeb67c4236b1d83ecf94a4f51880b70b8c34f6b36c05ca
7
+ data.tar.gz: 0a8fe1df363b59964b056105a434d77fd023966d20e574e63e518e93d7b9a2c3732fba80c56797bcc4ee8e613a6b2c8d3e45da2ba487b1e708176dc6f633770f
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see checkout.js.LICENSE.txt */
2
- (()=>{var t={597:(t,e,n)=>{"use strict";function i(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function r(t,e){return t&e}function o(t,e){return t|e}function s(t,e){return t^e}function a(t,e){return t&~e}function h(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 u(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var l,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function f(t){var e,n,i="";for(e=0;e+3<=t.length;e+=3)n=parseInt(t.substring(e,e+3),16),i+=c.charAt(n>>6)+c.charAt(63&n);for(e+1==t.length?(n=parseInt(t.substring(e,e+1),16),i+=c.charAt(n<<2)):e+2==t.length&&(n=parseInt(t.substring(e,e+2),16),i+=c.charAt(n>>2)+c.charAt((3&n)<<4));(3&i.length)>0;)i+="=";return i}function d(t){var e,n="",r=0,o=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var s=c.indexOf(t.charAt(e));s<0||(0==r?(n+=i(s>>2),o=3&s,r=1):1==r?(n+=i(o<<2|s>>4),o=15&s,r=2):2==r?(n+=i(o),n+=i(s>>2),o=3&s,r=3):(n+=i(o<<2|s>>4),n+=i(15&s),r=0))}return 1==r&&(n+=i(o<<2)),n}var p,g={decode:function(t){var e;if(void 0===p){var n="= \f\n\r\t \u2028\u2029";for(p=Object.create(null),e=0;e<64;++e)p["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(p["-"]=62,p._=63,e=0;e<n.length;++e)p[n.charAt(e)]=-1}var i=[],r=0,o=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=p[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);r|=s,++o>=4?(i[i.length]=r>>16,i[i.length]=r>>8&255,i[i.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=r>>10;break;case 3:i[i.length]=r>>16,i[i.length]=r>>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=g.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 g.decode(t)}},m=1e13,y=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var n,i,r=this.buf,o=r.length;for(n=0;n<o;++n)(i=r[n]*t+e)<m?e=0:i-=(e=0|i/m)*m,r[n]=i;e>0&&(r[n]=e)},t.prototype.sub=function(t){var e,n,i=this.buf,r=i.length;for(e=0;e<r;++e)(n=i[e]-t)<0?(n+=m,t=1):t=0,i[e]=n;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,n=e[e.length-1].toString(),i=e.length-2;i>=0;--i)n+=(m+e[i]).toString().substring(1);return n},t.prototype.valueOf=function(){for(var t=this.buf,e=0,n=t.length-1;n>=0;--n)e=e*m+t[n];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),v=/^(\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)?)?$/,b=/^(\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 w(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}var T,S=function(){function t(e,n){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=n)}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,n){for(var i="",r=t;r<e;++r)if(i+=this.hexByte(this.get(r)),!0!==n)switch(15&r){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i},t.prototype.isASCII=function(t,e){for(var n=t;n<e;++n){var i=this.get(n);if(i<32||i>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var n="",i=t;i<e;++i)n+=String.fromCharCode(this.get(i));return n},t.prototype.parseStringUTF=function(t,e){for(var n="",i=t;i<e;){var r=this.get(i++);n+=r<128?String.fromCharCode(r):r>191&&r<224?String.fromCharCode((31&r)<<6|63&this.get(i++)):String.fromCharCode((15&r)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return n},t.prototype.parseStringBMP=function(t,e){for(var n,i,r="",o=t;o<e;)n=this.get(o++),i=this.get(o++),r+=String.fromCharCode(n<<8|i);return r},t.prototype.parseTime=function(t,e,n){var i=this.parseStringISO(t,e),r=(n?v:b).exec(i);return r?(n&&(r[1]=+r[1],r[1]+=+r[1]<70?2e3:1900),i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},t.prototype.parseInteger=function(t,e){for(var n,i=this.get(t),r=i>127,o=r?255:0,s="";i==o&&++t<e;)i=this.get(t);if(0==(n=e-t))return r?-1:0;if(n>4){for(s=i,n<<=3;0==(128&(+s^o));)s=+s<<1,--n;s="("+n+" bit)\n"}r&&(i-=256);for(var a=new y(i),h=t+1;h<e;++h)a.mulAdd(256,this.get(h));return s+a.toString()},t.prototype.parseBitString=function(t,e,n){for(var i=this.get(t),r="("+((e-t-1<<3)-i)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),h=s==e-1?i:0,u=7;u>=h;--u)o+=a>>u&1?"1":"0";if(o.length>n)return r+w(o,n)}return r+o},t.prototype.parseOctetString=function(t,e,n){if(this.isASCII(t,e))return w(this.parseStringISO(t,e),n);var i=e-t,r="("+i+" byte)\n";i>(n/=2)&&(e=t+n);for(var o=t;o<e;++o)r+=this.hexByte(this.get(o));return i>n&&(r+="…"),r},t.prototype.parseOID=function(t,e,n){for(var i="",r=new y,o=0,s=t;s<e;++s){var a=this.get(s);if(r.mulAdd(128,127&a),o+=7,!(128&a)){if(""===i)if((r=r.simplify())instanceof y)r.sub(80),i="2."+r.toString();else{var h=r<80?r<40?0:1:2;i=h+"."+(r-40*h)}else i+="."+r.toString();if(i.length>n)return w(i,n);r=new y,o=0}}return o>0&&(i+=".incomplete"),i},t}(),E=function(){function t(t,e,n,i,r){if(!(i instanceof x))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=n,this.tag=i,this.sub=r}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(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+n,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);case 6:return this.stream.parseOID(e,e+n,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return w(this.stream.parseStringUTF(e,e+n),t);case 18:case 19:case 20:case 21:case 22:case 26:return w(this.stream.parseStringISO(e,e+n),t);case 30:return w(this.stream.parseStringBMP(e,e+n),t);case 23:case 24:return this.stream.parseTime(e,e+n,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 n=0,i=this.sub.length;n<i;++n)e+=this.sub[n].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(),n=127&e;if(n==e)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===n)return null;e=0;for(var i=0;i<n;++i)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,n=2*this.length;return t.substr(e,n)},t.decode=function(e){var n;n=e instanceof S?e:new S(e,0);var i=new S(n),r=new x(n),o=t.decodeLength(n),s=n.pos,a=s-i.pos,h=null,u=function(){var e=[];if(null!==o){for(var i=s+o;n.pos<i;)e[e.length]=t.decode(n);if(n.pos!=i)throw new Error("Content size is not correct for container starting at offset "+s)}else try{for(;;){var r=t.decode(n);if(r.tag.isEOC())break;e[e.length]=r}o=s-n.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(r.tagConstructed)h=u();else if(r.isUniversal()&&(3==r.tagNumber||4==r.tagNumber))try{if(3==r.tagNumber&&0!=n.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");h=u();for(var l=0;l<h.length;++l)if(h[l].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){h=null}if(null===h){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+s);n.pos=s+Math.abs(o)}return new t(i,a,o,r,h)},t}(),x=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 n=new y;do{e=t.get(),n.mulAdd(128,127&e)}while(128&e);this.tagNumber=n.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),D=[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],O=(1<<26)/D[D.length-1],B=function(){function t(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return t.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var n,r=(1<<e)-1,o=!1,s="",a=this.t,h=this.DB-a*this.DB%e;if(a-- >0)for(h<this.DB&&(n=this[a]>>h)>0&&(o=!0,s=i(n));a>=0;)h<e?(n=(this[a]&(1<<h)-1)<<e-h,n|=this[--a]>>(h+=this.DB-e)):(n=this[a]>>(h-=e)&r,h<=0&&(h+=this.DB,--a)),n>0&&(o=!0),o&&(s+=i(n));return o?s:"0"},t.prototype.negate=function(){var e=V();return t.ZERO.subTo(this,e),e},t.prototype.abs=function(){return this.s<0?this.negate():this},t.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))return e;return 0},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+M(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var n=V();return this.abs().divRemTo(e,null,n),this.s<0&&n.compareTo(t.ZERO)>0&&e.subTo(n,n),n},t.prototype.modPowInt=function(t,e){var n;return n=t<256||e.isEven()?new A(e):new R(e),this.exp(t,n)},t.prototype.clone=function(){var t=V();return this.copyTo(t),t},t.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]},t.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},t.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},t.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},t.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var n,i=this.DB-t*this.DB%8,r=0;if(t-- >0)for(i<this.DB&&(n=this[t]>>i)!=(this.s&this.DM)>>i&&(e[r++]=n|this.s<<this.DB-i);t>=0;)i<8?(n=(this[t]&(1<<i)-1)<<8-i,n|=this[--t]>>(i+=this.DB-8)):(n=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&n)&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(e[r++]=n);return e},t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.min=function(t){return this.compareTo(t)<0?this:t},t.prototype.max=function(t){return this.compareTo(t)>0?this:t},t.prototype.and=function(t){var e=V();return this.bitwiseTo(t,r,e),e},t.prototype.or=function(t){var e=V();return this.bitwiseTo(t,o,e),e},t.prototype.xor=function(t){var e=V();return this.bitwiseTo(t,s,e),e},t.prototype.andNot=function(t){var e=V();return this.bitwiseTo(t,a,e),e},t.prototype.not=function(){for(var t=V(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},t.prototype.shiftLeft=function(t){var e=V();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=V();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},t.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+h(this[t]);return this.s<0?this.t*this.DB:-1},t.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=u(this[n]^e);return t},t.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)},t.prototype.setBit=function(t){return this.changeBit(t,o)},t.prototype.clearBit=function(t){return this.changeBit(t,a)},t.prototype.flipBit=function(t){return this.changeBit(t,s)},t.prototype.add=function(t){var e=V();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=V();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=V();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=V();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=V();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=V(),n=V();return this.divRemTo(t,e,n),[e,n]},t.prototype.modPow=function(t,e){var n,i,r=t.bitLength(),o=F(1);if(r<=0)return o;n=r<18?1:r<48?3:r<144?4:r<768?5:6,i=r<8?new A(e):e.isEven()?new _(e):new R(e);var s=[],a=3,h=n-1,u=(1<<n)-1;if(s[1]=i.convert(this),n>1){var l=V();for(i.sqrTo(s[1],l);a<=u;)s[a]=V(),i.mulTo(l,s[a-2],s[a]),a+=2}var c,f,d=t.t-1,p=!0,g=V();for(r=M(t[d])-1;d>=0;){for(r>=h?c=t[d]>>r-h&u:(c=(t[d]&(1<<r+1)-1)<<h-r,d>0&&(c|=t[d-1]>>this.DB+r-h)),a=n;0==(1&c);)c>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),p)s[c].copyTo(o),p=!1;else{for(;a>1;)i.sqrTo(o,g),i.sqrTo(g,o),a-=2;a>0?i.sqrTo(o,g):(f=o,o=g,g=f),i.mulTo(g,s[c],o)}for(;d>=0&&0==(t[d]&1<<r);)i.sqrTo(o,g),f=o,o=g,g=f,--r<0&&(r=this.DB-1,--d)}return i.revert(o)},t.prototype.modInverse=function(e){var n=e.isEven();if(this.isEven()&&n||0==e.signum())return t.ZERO;for(var i=e.clone(),r=this.clone(),o=F(1),s=F(0),a=F(0),h=F(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),n?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),n?(a.isEven()&&h.isEven()||(a.addTo(this,a),h.subTo(e,h)),a.rShiftTo(1,a)):h.isEven()||h.subTo(e,h),h.rShiftTo(1,h);i.compareTo(r)>=0?(i.subTo(r,i),n&&o.subTo(a,o),s.subTo(h,s)):(r.subTo(i,r),n&&a.subTo(o,a),h.subTo(s,h))}return 0!=r.compareTo(t.ONE)?t.ZERO:h.compareTo(e)>=0?h.subtract(e):h.signum()<0?(h.addTo(e,h),h.signum()<0?h.add(e):h):h},t.prototype.pow=function(t){return this.exp(t,new C)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var i=e;e=n,n=i}var r=e.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)return e;for(r<o&&(o=r),o>0&&(e.rShiftTo(o,e),n.rShiftTo(o,n));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return o>0&&n.lShiftTo(o,n),n},t.prototype.isProbablePrime=function(t){var e,n=this.abs();if(1==n.t&&n[0]<=D[D.length-1]){for(e=0;e<D.length;++e)if(n[0]==D[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<D.length;){for(var i=D[e],r=e+1;r<D.length&&i<O;)i*=D[r++];for(i=n.modInt(i);e<r;)if(i%D[e++]==0)return!1}return n.millerRabin(t)},t.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},t.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},t.prototype.fromString=function(e,n){var i;if(16==n)i=4;else if(8==n)i=3;else if(256==n)i=8;else if(2==n)i=1;else if(32==n)i=5;else{if(4!=n)return void this.fromRadix(e,n);i=2}this.t=0,this.s=0;for(var r=e.length,o=!1,s=0;--r>=0;){var a=8==i?255&+e[r]:j(e,r);a<0?"-"==e.charAt(r)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+i>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&0!=(128&+e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&t.ZERO.subTo(this,this)},t.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},t.prototype.dlShiftTo=function(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s},t.prototype.drShiftTo=function(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},t.prototype.lShiftTo=function(t,e){for(var n=t%this.DB,i=this.DB-n,r=(1<<i)-1,o=Math.floor(t/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>i|s,s=(this[a]&r)<<n;for(a=o-1;a>=0;--a)e[a]=0;e[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var i=t%this.DB,r=this.DB-i,o=(1<<i)-1;e[0]=this[n]>>i;for(var s=n+1;s<this.t;++s)e[s-n-1]|=(this[s]&o)<<r,e[s-n]=this[s]>>i;i>0&&(e[this.t-n-1]|=(this.s&o)<<r),e.t=this.t-n,e.clamp()}},t.prototype.subTo=function(t,e){for(var n=0,i=0,r=Math.min(t.t,this.t);n<r;)i+=this[n]-t[n],e[n++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;n<this.t;)i+=this[n],e[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<t.t;)i-=t[n],e[n++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[n++]=this.DV+i:i>0&&(e[n++]=i),e.t=n,e.clamp()},t.prototype.multiplyTo=function(e,n){var i=this.abs(),r=e.abs(),o=i.t;for(n.t=o+r.t;--o>=0;)n[o]=0;for(o=0;o<r.t;++o)n[o+i.t]=i.am(0,r[o],n,o,0,i.t);n.s=0,n.clamp(),this.s!=e.s&&t.ZERO.subTo(n,n)},t.prototype.squareTo=function(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var i=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,i,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},t.prototype.divRemTo=function(e,n,i){var r=e.abs();if(!(r.t<=0)){var o=this.abs();if(o.t<r.t)return null!=n&&n.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=V());var s=V(),a=this.s,h=e.s,u=this.DB-M(r[r.t-1]);u>0?(r.lShiftTo(u,s),o.lShiftTo(u,i)):(r.copyTo(s),o.copyTo(i));var l=s.t,c=s[l-1];if(0!=c){var f=c*(1<<this.F1)+(l>1?s[l-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,g=1<<this.F2,m=i.t,y=m-l,v=null==n?V():n;for(s.dlShiftTo(y,v),i.compareTo(v)>=0&&(i[i.t++]=1,i.subTo(v,i)),t.ONE.dlShiftTo(l,v),v.subTo(s,s);s.t<l;)s[s.t++]=0;for(;--y>=0;){var b=i[--m]==c?this.DM:Math.floor(i[m]*d+(i[m-1]+g)*p);if((i[m]+=s.am(0,b,i,y,0,l))<b)for(s.dlShiftTo(y,v),i.subTo(v,i);i[m]<--b;)i.subTo(v,i)}null!=n&&(i.drShiftTo(l,n),a!=h&&t.ZERO.subTo(n,n)),i.t=l,i.clamp(),u>0&&i.rShiftTo(u,i),a<0&&t.ZERO.subTo(i,i)}}},t.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},t.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},t.prototype.exp=function(e,n){if(e>4294967295||e<1)return t.ONE;var i=V(),r=V(),o=n.convert(this),s=M(e)-1;for(o.copyTo(i);--s>=0;)if(n.sqrTo(i,r),(e&1<<s)>0)n.mulTo(r,o,i);else{var a=i;i=r,r=a}return n.revert(i)},t.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},t.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),i=F(n),r=V(),o=V(),s="";for(this.divRemTo(i,r,o);r.signum()>0;)s=(n+o.intValue()).toString(t).substr(1)+s,r.divRemTo(i,r,o);return o.intValue().toString(t)+s},t.prototype.fromRadix=function(e,n){this.fromInt(0),null==n&&(n=10);for(var i=this.chunkSize(n),r=Math.pow(n,i),o=!1,s=0,a=0,h=0;h<e.length;++h){var u=j(e,h);u<0?"-"==e.charAt(h)&&0==this.signum()&&(o=!0):(a=n*a+u,++s>=i&&(this.dMultiply(r),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(n,s)),this.dAddOffset(a,0)),o&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,n,i){if("number"==typeof n)if(e<2)this.fromInt(1);else for(this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),o,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(n);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var r=[],s=7&e;r.length=1+(e>>3),n.nextBytes(r),s>0?r[0]&=(1<<s)-1:r[0]=0,this.fromString(r,256)}},t.prototype.bitwiseTo=function(t,e,n){var i,r,o=Math.min(t.t,this.t);for(i=0;i<o;++i)n[i]=e(this[i],t[i]);if(t.t<this.t){for(r=t.s&this.DM,i=o;i<this.t;++i)n[i]=e(this[i],r);n.t=this.t}else{for(r=this.s&this.DM,i=o;i<t.t;++i)n[i]=e(r,t[i]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()},t.prototype.changeBit=function(e,n){var i=t.ONE.shiftLeft(e);return this.bitwiseTo(i,n,i),i},t.prototype.addTo=function(t,e){for(var n=0,i=0,r=Math.min(t.t,this.t);n<r;)i+=this[n]+t[n],e[n++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;n<this.t;)i+=this[n],e[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<t.t;)i+=t[n],e[n++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[n++]=i:i<-1&&(e[n++]=this.DV+i),e.t=n,e.clamp()},t.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},t.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]}},t.prototype.multiplyLowerTo=function(t,e,n){var i=Math.min(this.t+t.t,e);for(n.s=0,n.t=i;i>0;)n[--i]=0;for(var r=n.t-this.t;i<r;++i)n[i+this.t]=this.am(0,t[i],n,i,0,this.t);for(r=Math.min(t.t,e);i<r;++i)this.am(0,t[i],n,i,0,e-i);n.clamp()},t.prototype.multiplyUpperTo=function(t,e,n){--e;var i=n.t=this.t+t.t-e;for(n.s=0;--i>=0;)n[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)n[this.t+i-e]=this.am(e-i,t[i],n,0,0,this.t+i-e);n.clamp(),n.drShiftTo(1,n)},t.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(0==e)n=this[0]%t;else for(var i=this.t-1;i>=0;--i)n=(e*n+this[i])%t;return n},t.prototype.millerRabin=function(e){var n=this.subtract(t.ONE),i=n.getLowestSetBit();if(i<=0)return!1;var r=n.shiftRight(i);(e=e+1>>1)>D.length&&(e=D.length);for(var o=V(),s=0;s<e;++s){o.fromInt(D[Math.floor(Math.random()*D.length)]);var a=o.modPow(r,this);if(0!=a.compareTo(t.ONE)&&0!=a.compareTo(n)){for(var h=1;h++<i&&0!=a.compareTo(n);)if(0==(a=a.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=a.compareTo(n))return!1}}return!0},t.prototype.square=function(){var t=V();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var n=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(n.compareTo(i)<0){var r=n;n=i,i=r}var o=n.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)e(n);else{o<s&&(s=o),s>0&&(n.rShiftTo(s,n),i.rShiftTo(s,i));var a=function(){(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),(o=i.getLowestSetBit())>0&&i.rShiftTo(o,i),n.compareTo(i)>=0?(n.subTo(i,n),n.rShiftTo(1,n)):(i.subTo(n,i),i.rShiftTo(1,i)),n.signum()>0?setTimeout(a,0):(s>0&&i.lShiftTo(s,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}},t.prototype.fromNumberAsync=function(e,n,i,r){if("number"==typeof n)if(e<2)this.fromInt(1);else{this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),o,this),this.isEven()&&this.dAddOffset(1,0);var s=this,a=function(){s.dAddOffset(2,0),s.bitLength()>e&&s.subTo(t.ONE.shiftLeft(e-1),s),s.isProbablePrime(n)?setTimeout((function(){r()}),0):setTimeout(a,0)};setTimeout(a,0)}else{var h=[],u=7&e;h.length=1+(e>>3),n.nextBytes(h),u>0?h[0]&=(1<<u)-1:h[0]=0,this.fromString(h,256)}},t}(),C=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),A=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,n){t.multiplyTo(e,n),this.reduce(n)},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=V();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(B.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=V();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 n=32767&t[e],i=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),_=function(){function t(t){this.m=t,this.r2=V(),this.q3=V(),B.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=V();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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function V(){return new B(null)}function k(t,e){return new B(t,e)}var I="undefined"!=typeof navigator;I&&"Microsoft Internet Explorer"==navigator.appName?(B.prototype.am=function(t,e,n,i,r,o){for(var s=32767&e,a=e>>15;--o>=0;){var h=32767&this[t],u=this[t++]>>15,l=a*h+u*s;r=((h=s*h+((32767&l)<<15)+n[i]+(1073741823&r))>>>30)+(l>>>15)+a*u+(r>>>30),n[i++]=1073741823&h}return r},T=30):I&&"Netscape"!=navigator.appName?(B.prototype.am=function(t,e,n,i,r,o){for(;--o>=0;){var s=e*this[t++]+n[i]+r;r=Math.floor(s/67108864),n[i++]=67108863&s}return r},T=26):(B.prototype.am=function(t,e,n,i,r,o){for(var s=16383&e,a=e>>14;--o>=0;){var h=16383&this[t],u=this[t++]>>14,l=a*h+u*s;r=((h=s*h+((16383&l)<<14)+n[i]+r)>>28)+(l>>14)+a*u,n[i++]=268435455&h}return r},T=28),B.prototype.DB=T,B.prototype.DM=(1<<T)-1,B.prototype.DV=1<<T,B.prototype.FV=Math.pow(2,52),B.prototype.F1=52-T,B.prototype.F2=2*T-52;var P,N,L=[];for(P="0".charCodeAt(0),N=0;N<=9;++N)L[P++]=N;for(P="a".charCodeAt(0),N=10;N<36;++N)L[P++]=N;for(P="A".charCodeAt(0),N=10;N<36;++N)L[P++]=N;function j(t,e){var n=L[t.charCodeAt(e)];return null==n?-1:n}function F(t){var e=V();return e.fromInt(t),e}function M(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}B.ZERO=F(0),B.ONE=F(1);var q,H,U=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,n,i;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[n],this.S[n]=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 z=void 0;if(window.crypto&&window.crypto.getRandomValues){var G=new Uint32Array(256);for(window.crypto.getRandomValues(G),z=0;z<G.length;++z)K[H++]=255&G[z]}var $=0,Z=function(t){if(($=$||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,$+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",Z,!1):window.attachEvent&&window.attachEvent("onmousemove",Z)}function W(){if(null==q){for(q=new U;H<256;){var t=Math.floor(65536*Math.random());K[H++]=255&t}for(q.init(K),H=0;H<K.length;++H)K[H]=0;H=0}return q.next()}var Y=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=W()},t}(),X=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),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=k(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,n=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var n=[],i=t.length-1;i>=0&&e>0;){var r=t.charCodeAt(i--);r<128?n[--e]=r:r>127&&r<2048?(n[--e]=63&r|128,n[--e]=r>>6|192):(n[--e]=63&r|128,n[--e]=r>>6&63|128,n[--e]=r>>12|224)}n[--e]=0;for(var o=new Y,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);n[--e]=s[0]}return n[--e]=2,n[--e]=0,new B(n)}(t,e);if(null==n)return null;var i=this.doPublic(n);if(null==i)return null;for(var r=i.toString(16),o=r.length,s=0;s<2*e-o;s++)r="0"+r;return r},t.prototype.setPrivate=function(t,e,n){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=k(t,16),this.e=parseInt(e,16),this.d=k(n,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,n,i,r,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=k(t,16),this.e=parseInt(e,16),this.d=k(n,16),this.p=k(i,16),this.q=k(r,16),this.dmp1=k(o,16),this.dmq1=k(s,16),this.coeff=k(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var n=new Y,i=t>>1;this.e=parseInt(e,16);for(var r=new B(e,16);;){for(;this.p=new B(t-i,1,n),0!=this.p.subtract(B.ONE).gcd(r).compareTo(B.ONE)||!this.p.isProbablePrime(10););for(;this.q=new B(i,1,n),0!=this.q.subtract(B.ONE).gcd(r).compareTo(B.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract(B.ONE),a=this.q.subtract(B.ONE),h=s.multiply(a);if(0==h.gcd(r).compareTo(B.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=k(t,16),n=this.doPrivate(e);return null==n?null:function(t,e){for(var n=t.toByteArray(),i=0;i<n.length&&0==n[i];)++i;if(n.length-i!=e-1||2!=n[i])return null;for(++i;0!=n[i];)if(++i>=n.length)return null;for(var r="";++i<n.length;){var o=255&n[i];o<128?r+=String.fromCharCode(o):o>191&&o<224?(r+=String.fromCharCode((31&o)<<6|63&n[i+1]),++i):(r+=String.fromCharCode((15&o)<<12|(63&n[i+1])<<6|63&n[i+2]),i+=2)}return r}(n,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,n){var i=new Y,r=t>>1;this.e=parseInt(e,16);var o=new B(e,16),s=this,a=function(){var e=function(){if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(B.ONE),i=s.q.subtract(B.ONE),r=e.multiply(i);0==r.gcd(o).compareTo(B.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(r),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(i),s.coeff=s.q.modInverse(s.p),setTimeout((function(){n()}),0)):setTimeout(a,0)},h=function(){s.q=V(),s.q.fromNumberAsync(r,1,i,(function(){s.q.subtract(B.ONE).gcda(o,(function(t){0==t.compareTo(B.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=function(){s.p=V(),s.p.fromNumberAsync(t-r,1,i,(function(){s.p.subtract(B.ONE).gcda(o,(function(t){0==t.compareTo(B.ONE)&&s.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,n){var i=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var n=e-t.length-6,i="",r=0;r<n;r+=2)i+="ff";return k("0001"+i+"00"+t,16)}((J[n]||"")+e(t).toString(),this.n.bitLength()/4);if(null==i)return null;var r=this.doPrivate(i);if(null==r)return null;var o=r.toString(16);return 0==(1&o.length)?o:"0"+o},t.prototype.verify=function(t,e,n){var i=k(e,16),r=this.doPublic(i);return null==r?null:function(t){for(var e in J)if(J.hasOwnProperty(e)){var n=J[e],i=n.length;if(t.substr(0,i)==n)return t.substr(i)}return t}(r.toString(16).replace(/^1f+00/,""))==n(t).toString()},t}(),J={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},Q={};Q.lang={extend:function(t,e,n){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),n){var r;for(r in n)t.prototype[r]=n[r];var o=function(){},s=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(o=function(t,e){for(r=0;r<s.length;r+=1){var n=s[r],i=e[n];"function"==typeof i&&i!=Object.prototype[n]&&(t[n]=i)}})}catch(t){}o(t.prototype,n)}}};var tt={};void 0!==tt.asn1&&tt.asn1||(tt.asn1={}),tt.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 n=e.substr(1).length;n%2==1?n+=1:e.match(/^[0-7]/)||(n+=2);for(var i="",r=0;r<n;r++)i+="f";e=new B(i,16).xor(t).add(B.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=tt.asn1,n=e.DERBoolean,i=e.DERInteger,r=e.DERBitString,o=e.DEROctetString,s=e.DERNull,a=e.DERObjectIdentifier,h=e.DEREnumerated,u=e.DERUTF8String,l=e.DERNumericString,c=e.DERPrintableString,f=e.DERTeletexString,d=e.DERIA5String,p=e.DERUTCTime,g=e.DERGeneralizedTime,m=e.DERSequence,y=e.DERSet,v=e.DERTaggedObject,b=e.ASN1Util.newObject,w=Object.keys(t);if(1!=w.length)throw"key of param shall be only one.";var T=w[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 n(t[T]);if("int"==T)return new i(t[T]);if("bitstr"==T)return new r(t[T]);if("octstr"==T)return new o(t[T]);if("null"==T)return new s(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 l(t[T]);if("prnstr"==T)return new c(t[T]);if("telstr"==T)return new f(t[T]);if("ia5str"==T)return new d(t[T]);if("utctime"==T)return new p(t[T]);if("gentime"==T)return new g(t[T]);if("seq"==T){for(var S=t[T],E=[],x=0;x<S.length;x++){var D=b(S[x]);E.push(D)}return new m({array:E})}if("set"==T){for(S=t[T],E=[],x=0;x<S.length;x++)D=b(S[x]),E.push(D);return new y({array:E})}if("tag"==T){var O=t[T];if("[object Array]"===Object.prototype.toString.call(O)&&3==O.length){var B=b(O[2]);return new v({tag:O[0],explicit:O[1],obj:B})}var C={};if(void 0!==O.explicit&&(C.explicit=O.explicit),void 0!==O.tag&&(C.tag=O.tag),void 0===O.obj)throw"obj shall be specified for 'tag'.";return C.obj=b(O.obj),new v(C)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},tt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),i=(e=Math.floor(n/40)+"."+n%40,""),r=2;r<t.length;r+=2){var o=("00000000"+parseInt(t.substr(r,2),16).toString(2)).slice(-8);i+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new B(i,2).toString(10),i="")}return e},tt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",i=new B(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";for(i=o+i,s=0;s<i.length-1;s+=7){var a=i.substr(s,7);s!=i.length-7&&(a="1"+a),n+=e(parseInt(a,2))}return n};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",r=t.split("."),o=40*parseInt(r[0])+parseInt(r[1]);i+=e(o),r.splice(0,2);for(var s=0;s<r.length;s++)i+=n(r[s]);return i},tt.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 n=e.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+n).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""}},tt.asn1.DERAbstractString=function(t){tt.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))},Q.lang.extend(tt.asn1.DERAbstractString,tt.asn1.ASN1Object),tt.asn1.DERAbstractTime=function(t){tt.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,n){var i=this.zeroPadding,r=this.localDateToUTC(t),o=String(r.getFullYear());"utc"==e&&(o=o.substr(2,2));var s=o+i(String(r.getMonth()+1),2)+i(String(r.getDate()),2)+i(String(r.getHours()),2)+i(String(r.getMinutes()),2)+i(String(r.getSeconds()),2);if(!0===n){var a=r.getMilliseconds();if(0!=a){var h=i(String(a),3);s=s+"."+(h=h.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,n,i,r,o){var s=new Date(Date.UTC(t,e-1,n,i,r,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},Q.lang.extend(tt.asn1.DERAbstractTime,tt.asn1.ASN1Object),tt.asn1.DERAbstractStructured=function(t){tt.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)},Q.lang.extend(tt.asn1.DERAbstractStructured,tt.asn1.ASN1Object),tt.asn1.DERBoolean=function(){tt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},Q.lang.extend(tt.asn1.DERBoolean,tt.asn1.ASN1Object),tt.asn1.DERInteger=function(t){tt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=tt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(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))},Q.lang.extend(tt.asn1.DERInteger,tt.asn1.ASN1Object),tt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=tt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}tt.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 n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var n=0;n<=e;n++)t+="0";var i="";for(n=0;n<t.length-1;n+=8){var r=t.substr(n,8),o=parseInt(r,2).toString(16);1==o.length&&(o="0"+o),i+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+i},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!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))},Q.lang.extend(tt.asn1.DERBitString,tt.asn1.ASN1Object),tt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=tt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}tt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},Q.lang.extend(tt.asn1.DEROctetString,tt.asn1.DERAbstractString),tt.asn1.DERNull=function(){tt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},Q.lang.extend(tt.asn1.DERNull,tt.asn1.ASN1Object),tt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",i=new B(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";for(i=o+i,s=0;s<i.length-1;s+=7){var a=i.substr(s,7);s!=i.length-7&&(a="1"+a),n+=e(parseInt(a,2))}return n};tt.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="",r=t.split("."),o=40*parseInt(r[0])+parseInt(r[1]);i+=e(o),r.splice(0,2);for(var s=0;s<r.length;s++)i+=n(r[s]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(t){var e=tt.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))},Q.lang.extend(tt.asn1.DERObjectIdentifier,tt.asn1.ASN1Object),tt.asn1.DEREnumerated=function(t){tt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=tt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new B(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))},Q.lang.extend(tt.asn1.DEREnumerated,tt.asn1.ASN1Object),tt.asn1.DERUTF8String=function(t){tt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},Q.lang.extend(tt.asn1.DERUTF8String,tt.asn1.DERAbstractString),tt.asn1.DERNumericString=function(t){tt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},Q.lang.extend(tt.asn1.DERNumericString,tt.asn1.DERAbstractString),tt.asn1.DERPrintableString=function(t){tt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},Q.lang.extend(tt.asn1.DERPrintableString,tt.asn1.DERAbstractString),tt.asn1.DERTeletexString=function(t){tt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},Q.lang.extend(tt.asn1.DERTeletexString,tt.asn1.DERAbstractString),tt.asn1.DERIA5String=function(t){tt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},Q.lang.extend(tt.asn1.DERIA5String,tt.asn1.DERAbstractString),tt.asn1.DERUTCTime=function(t){tt.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))},Q.lang.extend(tt.asn1.DERUTCTime,tt.asn1.DERAbstractTime),tt.asn1.DERGeneralizedTime=function(t){tt.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))},Q.lang.extend(tt.asn1.DERGeneralizedTime,tt.asn1.DERAbstractTime),tt.asn1.DERSequence=function(t){tt.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}},Q.lang.extend(tt.asn1.DERSequence,tt.asn1.DERAbstractStructured),tt.asn1.DERSet=function(t){tt.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 n=this.asn1Array[e];t.push(n.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)},Q.lang.extend(tt.asn1.DERSet,tt.asn1.DERAbstractStructured),tt.asn1.DERTaggedObject=function(t){tt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},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)))},Q.lang.extend(tt.asn1.DERTaggedObject,tt.asn1.ASN1Object);var et,nt=(et=function(t,e){return(et=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}et(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),it=function(t){function e(n){var i=t.call(this)||this;return n&&("string"==typeof n?i.parseKey(n):(e.hasPrivateKeyProperty(n)||e.hasPublicKeyProperty(n))&&i.parsePropertiesFrom(n)),i}return nt(e,t),e.prototype.parseKey=function(t){try{var e=0,n=0,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===l){var n="0123456789ABCDEF",i=" \f\n\r\t \u2028\u2029";for(l={},e=0;e<16;++e)l[n.charAt(e)]=e;for(n=n.toLowerCase(),e=10;e<16;++e)l[n.charAt(e)]=e;for(e=0;e<i.length;++e)l[i.charAt(e)]=-1}var r=[],o=0,s=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=l[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);o|=a,++s>=2?(r[r.length]=o,o=0,s=0):o<<=4}}if(s)throw new Error("Hex encoding incomplete: 4 bits missing");return r}(t):g.unarmor(t),r=E.decode(i);if(3===r.sub.length&&(r=r.sub[2].sub[0]),9===r.sub.length){e=r.sub[1].getHexStringValue(),this.n=k(e,16),n=r.sub[2].getHexStringValue(),this.e=parseInt(n,16);var o=r.sub[3].getHexStringValue();this.d=k(o,16);var s=r.sub[4].getHexStringValue();this.p=k(s,16);var a=r.sub[5].getHexStringValue();this.q=k(a,16);var h=r.sub[6].getHexStringValue();this.dmp1=k(h,16);var u=r.sub[7].getHexStringValue();this.dmq1=k(u,16);var c=r.sub[8].getHexStringValue();this.coeff=k(c,16)}else{if(2!==r.sub.length)return!1;var f=r.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=k(e,16),n=f.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new tt.asn1.DERInteger({int:0}),new tt.asn1.DERInteger({bigint:this.n}),new tt.asn1.DERInteger({int:this.e}),new tt.asn1.DERInteger({bigint:this.d}),new tt.asn1.DERInteger({bigint:this.p}),new tt.asn1.DERInteger({bigint:this.q}),new tt.asn1.DERInteger({bigint:this.dmp1}),new tt.asn1.DERInteger({bigint:this.dmq1}),new tt.asn1.DERInteger({bigint:this.coeff})]};return new tt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return f(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new tt.asn1.DERSequence({array:[new tt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new tt.asn1.DERNull]}),e=new tt.asn1.DERSequence({array:[new tt.asn1.DERInteger({bigint:this.n}),new tt.asn1.DERInteger({int:this.e})]}),n=new tt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new tt.asn1.DERSequence({array:[t,n]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return f(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var n="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(n,"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}(X);const rt=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 it(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(d(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return f(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,n){try{return f(this.getKey().sign(t,e,n))}catch(t){return!1}},t.prototype.verify=function(t,e,n){try{return this.getKey().verify(t,d(e),n)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new it,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}(),ot=window.Rails||window.$.rails;var st=function(t){var e=t.headers,n=t.status;return 404===n||500<=n?Promise.reject({headers:e,status:n}):-1!==(t.headers.get("Content-Type")+"").indexOf("json")&&204!==t.status?t.json().then((function(t){return{headers:e,status:n,json:t}}),(function(){return{headers:e,status:n,json:null}})):{headers:e,status:n,json:null}};const at=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i={method:e,credentials:"include",headers:new Headers};return i.headers.append("X-CSRF-Token",ot.csrfToken()),i.headers.append("accept","application/json"),n.body&&(n.body instanceof FormData?i.body=n.body:(i.body=JSON.stringify(n.body),i.headers.append("content-type","application/json"))),window.fetch(t,i).then(st,(function(t){return Promise.reject(t)}))};var ht=n(584),ut=n.n(ht),lt=document.createElement("style");lt.setAttribute("type","text/css"),lt.innerHTML='.tingle-modal * {\n box-sizing: border-box;\n}\n\n.tingle-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1000;\n display: flex;\n visibility: hidden;\n flex-direction: column;\n align-items: center;\n overflow: hidden;\n -webkit-overflow-scrolling: touch;\n background: rgba(0, 0, 0, .2);\n opacity: 0;\n}\n\n@supports (backdrop-filter: blur(12px)) {\n .tingle-modal {\n backdrop-filter: blur(12px);\n }\n}\n\n/* confirm and alerts\n-------------------------------------------------------------- */\n\n.tingle-modal--confirm .tingle-modal-box {\n text-align: center;\n}\n\n/* modal\n-------------------------------------------------------------- */\n\n.tingle-modal--noOverlayClose {\n cursor: default;\n}\n\n.tingle-modal--noClose .tingle-modal__close {\n display: none;\n}\n\n.tingle-modal__close {\n position: fixed;\n top: 2.5rem;\n right: 2.5rem;\n z-index: 1000;\n padding: 0;\n width: 2rem;\n height: 2rem;\n border: none;\n background-color: transparent;\n color: #fff;\n cursor: pointer;\n}\n\n.tingle-modal__close svg * {\n fill: currentColor;\n}\n\n.tingle-modal__closeLabel {\n display: none;\n}\n\n.tingle-modal__close:hover {\n color: #fff;\n}\n\n.tingle-modal-box {\n position: relative;\n flex-shrink: 0;\n margin-top: auto;\n margin-bottom: auto;\n width: 60%;\n border-radius: 4px;\n background: #fff;\n opacity: 1;\n cursor: auto;\n will-change: transform, opacity;\n}\n\n.tingle-modal-box__content {\n padding: 0;\n}\n\n.tingle-modal-box__footer {\n padding: 1.5rem 2rem;\n width: auto;\n border-bottom-right-radius: 4px;\n border-bottom-left-radius: 4px;\n background-color: #f5f5f5;\n cursor: auto;\n}\n\n.tingle-modal-box__footer::after {\n display: table;\n clear: both;\n content: "";\n}\n\n.tingle-modal-box__footer--sticky {\n position: fixed;\n bottom: -200px; /* TODO : find a better way */\n z-index: 10001;\n opacity: 1;\n transition: bottom .3s ease-in-out .3s;\n}\n\n/* state\n-------------------------------------------------------------- */\n\n.tingle-enabled {\n position: fixed;\n right: 0;\n left: 0;\n overflow: hidden;\n}\n\n.tingle-modal--visible .tingle-modal-box__footer {\n bottom: 0;\n}\n\n.tingle-modal--visible {\n visibility: visible;\n opacity: 1;\n}\n\n.tingle-modal--visible .tingle-modal-box {\n animation: scale .2s cubic-bezier(.68, -.55, .265, 1.55) forwards;\n}\n\n.tingle-modal--overflow {\n overflow-y: scroll;\n padding-top: 8vh;\n}\n\n/* btn\n-------------------------------------------------------------- */\n\n.tingle-btn {\n display: inline-block;\n margin: 0 .5rem;\n padding: 1rem 2rem;\n border: none;\n background-color: grey;\n box-shadow: none;\n color: #fff;\n vertical-align: middle;\n text-decoration: none;\n font-size: inherit;\n font-family: inherit;\n line-height: normal;\n cursor: pointer;\n transition: background-color .4s ease;\n}\n\n.tingle-btn--primary {\n background-color: #3498db;\n}\n\n.tingle-btn--danger {\n background-color: #e74c3c;\n}\n\n.tingle-btn--default {\n background-color: #34495e;\n}\n\n.tingle-btn--pull-left {\n float: left;\n}\n\n.tingle-btn--pull-right {\n float: right;\n}\n\n/* responsive\n-------------------------------------------------------------- */\n\n@media (max-width : 540px) {\n .tingle-modal {\n top: 0px;\n display: block;\n padding-top: 60px;\n width: 100%;\n }\n\n .tingle-modal-box {\n width: auto;\n border-radius: 0;\n }\n\n .tingle-modal-box__content {\n overflow-y: scroll;\n }\n\n .tingle-modal--noClose {\n top: 0;\n }\n\n .tingle-modal--noOverlayClose {\n padding-top: 0;\n }\n\n .tingle-modal-box__footer .tingle-btn {\n display: block;\n float: none;\n margin-bottom: 1rem;\n width: 100%;\n }\n\n .tingle-modal__close {\n top: 0;\n right: 0;\n left: 0;\n display: block;\n width: 100%;\n height: 60px;\n border: none;\n background-color: #2c3e50;\n box-shadow: none;\n color: #fff;\n }\n\n .tingle-modal__closeLabel {\n display: inline-block;\n vertical-align: middle;\n font-size: 1.6rem;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n }\n\n .tingle-modal__closeIcon {\n display: inline-block;\n margin-right: .8rem;\n width: 1.6rem;\n vertical-align: middle;\n font-size: 0;\n }\n}\n\n/* animations\n-------------------------------------------------------------- */\n\n@keyframes scale {\n 0% {\n opacity: 0;\n transform: scale(.9);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.tingle-modal-box__iframe {\n border: 0;\n height: 500px;\n width: 100%;\n}\n',document.head.appendChild(lt);var ct,ft,dt,pt,gt=function(t){return 200!==t.status||"checkout"===t.json.data.state?null:t.json.data.state},mt=function t(e,n,i){at(e).then(gt).then((function(r){r?(n.isOpen()&&n.close(),i(r)):n.isOpen()?setTimeout(t.bind(null,e,n,i),2e3):at(e).then(gt).then((function(t){return i(t||"invalid")}))}))},yt=function(t,e){var n=new(ut().modal)({closeMethods:["overlay","button","escape"],closeLabel:"Close",onOpen:function(){setTimeout((function(){return mt(t.check_path,n,e)}),3e3)},onClose:function(){n.$closed=!0}});n.setContent('<iframe src="'.concat(t.redirect_url,'" class="tingle-modal-box__iframe" />')),n.open()},vt=function(t){return t&&t.trim().length};window.$&&window.$.payment?(ct=window.$.payment.validateCardNumber,ft=window.$.payment.validateCardCVC,dt=window.$.payment.validateCardExpiry,pt=window.$.payment.cardExpiryVal):(ft=vt,dt=function(t,e){return vt(t)&&vt(e)},pt=function(t){var e=(t||"").split("/");return{month:(e[0]||"").trim(),year:(e[1]||"").trim()}});var bt=pt,wt=function(t,e,n){t[e]||(t[e]=[]),t[e].push(n)};function Tt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}var St=window.nexioErrorMessages||{default_error:"Something went wrong"},Et=function(t){return t.querySelectorAll("[data-nexio-error]").forEach((function(t){var e=t.parentNode;e.removeChild(t);var n=e.querySelector("[name].error");n&&n.classList.remove("error")}))},xt={number:"card_number",cc_type:"card_type",name:"card_name",expiry:"card_expiration",verification_value:"card_code"},Dt=function(t,e,n){var i=xt[e];t.querySelector('[data-hook="'.concat(i,'"]')).value=n},Ot=["number"];function Bt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function Ct(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function At(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function Rt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?At(Object(n),!0).forEach((function(e){_t(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):At(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function _t(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Vt=function(t){var e=t.slice(0,6),n=t.slice(t.length-4),i="*".repeat(t.length-10);return"".concat(e).concat(i).concat(n)},kt=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=e,this.token=null,this.config=n,this.onTokenGenerationFail=this.onTokenGenerationFail.bind(this),this.onCardTokenGenerationFail=this.onCardTokenGenerationFail.bind(this)}var e,n;return e=t,(n=[{key:"setup",value:function(t,e){var n=this;this.form=t,this.fields=e,this.baseErrorContainer=t.querySelector('[data-hook="checkout_payment_step"]')||t,e&&(e.nexioOwnForm=this),this.refreshToken().then((function(){n.form.addEventListener("submit",(function(t){n.withNewCardForm()&&0<n.fields.clientHeight?(Et(n.form),t.preventDefault(),n.addNewCardFlow()):n.config.threeDSecure&&n.isNexioCardSelected()&&(Et(n.form),t.preventDefault(),n.submitFormToProcess())}))}))}},{key:"withNewCardForm",value:function(){return["default","newCard","addWalletCard"].includes(this.config.type)}},{key:"showError",value:function(t,e){!function(t,e,n,i){var r=function(t,e){var n=document.createElement("label");return n.setAttribute("data-nexio-error",t),n.classList.add("error","nexio-error"),n.innerHTML=function(t,e){return St[t]&&St[t][e]||St.base&&St.base[e]||St.default_error}(t,e),n}(e,n);if("base"===e)t.appendChild(r);else{var o=t.querySelector('[name="payment_source['.concat(i,"][").concat(e,']"]'));o&&(o.classList.add("error"),o.parentNode.appendChild(r))}}("base"===t?this.baseErrorContainer:this.fields||this.baseErrorContainer,t,e,this.id)}},{key:"refreshToken",value:function(){var t,e,n,i=this;return this.withNewCardForm()&&null===this.token?(t=this.config,e=t.paths,n=t.data,at(e.oneTimeToken,"POST",{body:{data:n}}).then((function(t){return 201===t.status?t.json.data:Promise.reject(t)}),(function(t){return Promise.reject(t)}))).then((function(t){return i.token=t.token,e=t.fraud_url,new Promise((function(t){var n=document.createElement("script");n.onload=t,n.src=e,document.body.appendChild(n)}));var e}),this.onTokenGenerationFail):new Promise((function(t){return t()}))}},{key:"addNewCardFlow",value:function(){var t,e=this,n=(t=this.fields,Object.entries(xt).reduce((function(e,n){var i,r,o=(r=2,function(t){if(Array.isArray(t))return t}(i=n)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(i,r)||function(t,e){if(t){if("string"==typeof t)return Tt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Tt(t,e):void 0}}(i,r)||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=o[0],a=o[1],h=t.querySelector('[data-hook="'.concat(a,'"]'));if(h)if(["INPUT","SELECT"].includes(h.nodeName))e[s]=h.value;else{var u=h.querySelector("input[name], select[name]");u&&(e[s]=u.value)}return e}),{}));Object.assign(n,bt(n.expiry));var i=function(t){var e={};return["number","name","expiry","verification_value"].forEach((function(n){return vt(t[n])?null:wt(e,n,"blank")})),vt(t.number)&&!ct(t.number)&&wt(e,"number","invalid"),vt(t.verification_value)&&!ft(t.verification_value,t.cc_type)&&wt(e,"verification_value","invalid"),vt(t.expiry)&&!dt(t.month,t.year)&&wt(e,"expiry","invalid"),e}(n);if(0<Object.keys(i).length)return this.onCardValidationFail(i);this.fields.setAttribute("disabled","disabled");var r,o,s=function(t,e,n){var i=e.number,r=function(t,e){if(null==t)return{};var n,i,r=function(t,e){if(null==t)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}(e,Ot);i=i.replace(/\D+/g,"");var o=new rt;return o.setPublicKey(t.publicKey),Rt(Rt({},t.data),{},{one_time_token:n,card:Rt(Rt({},r),{},{encrypted_number:o.encrypt(i),number:Vt(i)})})}(this.config,n,this.token);return this.token=null,(r=this.config,o=s,at(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)}))).then((function(t){if(e.fields.querySelector('[data-hook="card_gateway_payment_profile_id"]').value=t.token,e.fields.removeAttribute("disabled"),e.config.threeDSecure&&"addWalletCard"!==e.config.type)return e.submitFormToProcess();"addWalletCard"===e.config.type&&(Dt(e.fields,"number",s.card.number),Dt(e.fields,"verification_value","")),e.form.submit()}),this.onCardTokenGenerationFail).catch((function(){return e.resetFormOnError()}))}},{key:"submitFormToProcess",value:function(){var t=this,e=new FormData(this.form);e.delete("_method");var n={body:e};return function(t,e){return at(t,"POST",e).then((function(t){return 200===t.status?t.json:Promise.reject(t)}),(function(t){return Promise.reject(t)}))}(this.config.paths.payment,n).then((function(e){switch(e.state){case"success":return t.submitForm();case"three_d_secure":return t.onThreeDSecureRedirect(e.data);case"error":return t.resetFormOnError(e.data&&e.data.error||"fail_process_payment");default:t.resetFormOnError()}}),(function(){return t.resetFormOnError()}))}},{key:"isNexioCardSelected",value:function(){if(!this.config.threeDSecure)return!1;var t=this.config.walletCardIds;if(!Array.isArray(t))return!1;var e=new FormData(this.form).get("order[wallet_payment_source_id]");return e&&t.includes(parseInt(e))}},{key:"onThreeDSecureRedirect",value:function(t){var e=this;yt(t,(function(t){["invalid","failed"].includes(t)?e.resetFormOnError("fail_three_d_secure_check"):e.submitForm()}))}},{key:"submitForm",value:function(){this.form.querySelectorAll('fieldset#payment, fieldset[data-hook="payment"], [data-nexio-3ds-disable]').forEach((function(t){return t.setAttribute("disabled","disabled")}));var t=document.createElement("input");t.setAttribute("type","hidden"),t.setAttribute("name","order[nexio_placeholder]"),t.setAttribute("value","1"),this.form.appendChild(t),this.form.submit()}},{key:"unlockForm",value:function(){var t=this;return new Promise((function(e){setTimeout((function(){t.fields&&t.fields.removeAttribute("disabled");var n=t.form.querySelector(ot.formEnableSelector);n&&(n.removeAttribute("disabled"),n.classList.remove("disabled"));var i=new Error("nexio_fail");e(i)}),100)}))}},{key:"resetFormOnError",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default_error";return this.showError("base",e),this.refreshToken().then((function(){return t.unlockForm()}))}},{key:"onCardValidationFail",value:function(t){var e=this;return Object.entries(t).forEach((function(t){var n,i,r=(i=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(n,i)||function(t,e){if(t){if("string"==typeof t)return Bt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Bt(t,e):void 0}}(n,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.")}()),o=r[0];return r[1].forEach((function(t){return e.showError(o,t)}))})),this.unlockForm()}},{key:"onTokenGenerationFail",value:function(){return this.showError("base","token_generation_failed"),Promise.reject()}},{key:"onCardTokenGenerationFail",value:function(){var t=this;return this.refreshToken().then((function(){return t.showError("base","fail_process_card"),Promise.reject()}))}}])&&Ct(e.prototype,n),t}(),It=[],Pt=function(){It.forEach((function(t){var e;switch(t.config.type){case"walletCards":e=document.querySelector('[data-nexio-wallet-cards="'.concat(t.id,'"]'));break;default:e=document.querySelector('[data-nexio-own-form-id="'.concat(t.id,'"]'))}if(e){var n=e.closest("form");t.setup(n,e)}})),It.length=0};window.addNexioOwnForm=function(t,e){return It.push(new kt(t,e))},window.setupNexioOwnForms=Pt,window.jQuery((function(){Pt()}))},584:function(t,e,n){var i,r;void 0===(r="function"==typeof(i=function(){var t=!1;function e(t){this.opts=function(){for(var t=1;t<arguments.length;t++)for(var e in arguments[t])arguments[t].hasOwnProperty(e)&&(arguments[0][e]=arguments[t][e]);return arguments[0]}({},{onClose:null,onOpen:null,beforeOpen:null,beforeClose:null,stickyFooter:!1,footer:!1,cssClass:[],closeLabel:"Close",closeMethods:["overlay","button","escape"]},t),this.init()}function n(){this.modalBoxFooter&&(this.modalBoxFooter.style.width=this.modalBox.clientWidth+"px",this.modalBoxFooter.style.left=this.modalBox.offsetLeft+"px")}return e.prototype.init=function(){if(!this.modal)return function(){this.modal=document.createElement("div"),this.modal.classList.add("tingle-modal"),0!==this.opts.closeMethods.length&&-1!==this.opts.closeMethods.indexOf("overlay")||this.modal.classList.add("tingle-modal--noOverlayClose"),this.modal.style.display="none",this.opts.cssClass.forEach((function(t){"string"==typeof t&&this.modal.classList.add(t)}),this),-1!==this.opts.closeMethods.indexOf("button")&&(this.modalCloseBtn=document.createElement("button"),this.modalCloseBtn.type="button",this.modalCloseBtn.classList.add("tingle-modal__close"),this.modalCloseBtnIcon=document.createElement("span"),this.modalCloseBtnIcon.classList.add("tingle-modal__closeIcon"),this.modalCloseBtnIcon.innerHTML='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.3 9.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3L5 6.4l3.3 3.3c.2.2.5.3.7.3.2 0 .5-.1.7-.3.4-.4.4-1 0-1.4L6.4 5l3.3-3.3c.4-.4.4-1 0-1.4-.4-.4-1-.4-1.4 0L5 3.6 1.7.3C1.3-.1.7-.1.3.3c-.4.4-.4 1 0 1.4L3.6 5 .3 8.3c-.4.4-.4 1 0 1.4z" fill="#000" fill-rule="nonzero"/></svg>',this.modalCloseBtnLabel=document.createElement("span"),this.modalCloseBtnLabel.classList.add("tingle-modal__closeLabel"),this.modalCloseBtnLabel.innerHTML=this.opts.closeLabel,this.modalCloseBtn.appendChild(this.modalCloseBtnIcon),this.modalCloseBtn.appendChild(this.modalCloseBtnLabel)),this.modalBox=document.createElement("div"),this.modalBox.classList.add("tingle-modal-box"),this.modalBoxContent=document.createElement("div"),this.modalBoxContent.classList.add("tingle-modal-box__content"),this.modalBox.appendChild(this.modalBoxContent),-1!==this.opts.closeMethods.indexOf("button")&&this.modal.appendChild(this.modalCloseBtn),this.modal.appendChild(this.modalBox)}.call(this),function(){this._events={clickCloseBtn:this.close.bind(this),clickOverlay:function(t){var e=this.modal.offsetWidth-this.modal.clientWidth,n=t.clientX>=this.modal.offsetWidth-15,i=this.modal.scrollHeight!==this.modal.offsetHeight;"MacIntel"===navigator.platform&&0==e&&n&&i||-1!==this.opts.closeMethods.indexOf("overlay")&&!function(t,e){for(;(t=t.parentElement)&&!t.classList.contains("tingle-modal"););return t}(t.target)&&t.clientX<this.modal.clientWidth&&this.close()}.bind(this),resize:this.checkOverflow.bind(this),keyboardNav:function(t){-1!==this.opts.closeMethods.indexOf("escape")&&27===t.which&&this.isOpen()&&this.close()}.bind(this)},-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.addEventListener("click",this._events.clickCloseBtn),this.modal.addEventListener("mousedown",this._events.clickOverlay),window.addEventListener("resize",this._events.resize),document.addEventListener("keydown",this._events.keyboardNav)}.call(this),document.body.appendChild(this.modal,document.body.firstChild),this.opts.footer&&this.addFooter(),this},e.prototype._busy=function(e){t=e},e.prototype._isBusy=function(){return t},e.prototype.destroy=function(){null!==this.modal&&(this.isOpen()&&this.close(!0),function(){-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.removeEventListener("click",this._events.clickCloseBtn),this.modal.removeEventListener("mousedown",this._events.clickOverlay),window.removeEventListener("resize",this._events.resize),document.removeEventListener("keydown",this._events.keyboardNav)}.call(this),this.modal.parentNode.removeChild(this.modal),this.modal=null)},e.prototype.isOpen=function(){return!!this.modal.classList.contains("tingle-modal--visible")},e.prototype.open=function(){if(!this._isBusy()){this._busy(!0);var t=this;return"function"==typeof t.opts.beforeOpen&&t.opts.beforeOpen(),this.modal.style.removeProperty?this.modal.style.removeProperty("display"):this.modal.style.removeAttribute("display"),document.getSelection().removeAllRanges(),this._scrollPosition=window.pageYOffset,document.body.classList.add("tingle-enabled"),document.body.style.top=-this._scrollPosition+"px",this.setStickyFooter(this.opts.stickyFooter),this.modal.classList.add("tingle-modal--visible"),"function"==typeof t.opts.onOpen&&t.opts.onOpen.call(t),t._busy(!1),this.checkOverflow(),this}},e.prototype.close=function(t){if(!this._isBusy()){if(this._busy(!0),"function"==typeof this.opts.beforeClose&&!this.opts.beforeClose.call(this))return void this._busy(!1);document.body.classList.remove("tingle-enabled"),document.body.style.top=null,window.scrollTo({top:this._scrollPosition,behavior:"instant"}),this.modal.classList.remove("tingle-modal--visible");var e=this;e.modal.style.display="none","function"==typeof e.opts.onClose&&e.opts.onClose.call(this),e._busy(!1)}},e.prototype.setContent=function(t){return"string"==typeof t?this.modalBoxContent.innerHTML=t:(this.modalBoxContent.innerHTML="",this.modalBoxContent.appendChild(t)),this.isOpen()&&this.checkOverflow(),this},e.prototype.getContent=function(){return this.modalBoxContent},e.prototype.addFooter=function(){return function(){this.modalBoxFooter=document.createElement("div"),this.modalBoxFooter.classList.add("tingle-modal-box__footer"),this.modalBox.appendChild(this.modalBoxFooter)}.call(this),this},e.prototype.setFooterContent=function(t){return this.modalBoxFooter.innerHTML=t,this},e.prototype.getFooterContent=function(){return this.modalBoxFooter},e.prototype.setStickyFooter=function(t){return this.isOverflow()||(t=!1),t?this.modalBox.contains(this.modalBoxFooter)&&(this.modalBox.removeChild(this.modalBoxFooter),this.modal.appendChild(this.modalBoxFooter),this.modalBoxFooter.classList.add("tingle-modal-box__footer--sticky"),n.call(this),this.modalBoxContent.style["padding-bottom"]=this.modalBoxFooter.clientHeight+20+"px"):this.modalBoxFooter&&(this.modalBox.contains(this.modalBoxFooter)||(this.modal.removeChild(this.modalBoxFooter),this.modalBox.appendChild(this.modalBoxFooter),this.modalBoxFooter.style.width="auto",this.modalBoxFooter.style.left="",this.modalBoxContent.style["padding-bottom"]="",this.modalBoxFooter.classList.remove("tingle-modal-box__footer--sticky"))),this},e.prototype.addFooterBtn=function(t,e,n){var i=document.createElement("button");return i.innerHTML=t,i.addEventListener("click",n),"string"==typeof e&&e.length&&e.split(" ").forEach((function(t){i.classList.add(t)})),this.modalBoxFooter.appendChild(i),i},e.prototype.resize=function(){console.warn("Resize is deprecated and will be removed in version 1.0")},e.prototype.isOverflow=function(){return window.innerHeight<=this.modalBox.clientHeight},e.prototype.checkOverflow=function(){this.modal.classList.contains("tingle-modal--visible")&&(this.isOverflow()?this.modal.classList.add("tingle-modal--overflow"):this.modal.classList.remove("tingle-modal--overflow"),!this.isOverflow()&&this.opts.stickyFooter?this.setStickyFooter(!1):this.isOverflow()&&this.opts.stickyFooter&&(n.call(this),this.setStickyFooter(!0)))},{modal:e}})?i.call(e,n,e,t):i)||(t.exports=r)}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n(597)})();
2
+ (()=>{var t={498:(t,e,n)=>{"use strict";const i=window.Rails||window.$.rails;var r=function(t){var e=t.headers,n=t.status;return 404===n||500<=n?Promise.reject({headers:e,status:n}):-1!==(t.headers.get("Content-Type")+"").indexOf("json")&&204!==t.status?t.json().then((function(t){return{headers:e,status:n,json:t}}),(function(){return{headers:e,status:n,json:null}})):{headers:e,status:n,json:null}};const o=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},o={method:e,credentials:"include",headers:new Headers};return o.headers.append("X-CSRF-Token",i.csrfToken()),o.headers.append("accept","application/json"),n.body&&(n.body instanceof FormData?o.body=n.body:(o.body=JSON.stringify(n.body),o.headers.append("content-type","application/json"))),window.fetch(t,o).then(r,(function(t){return Promise.reject(t)}))};var s=function(t){var e=t.paths,n=t.data;return o(e.oneTimeToken,"POST",{body:{data:n}}).then((function(t){return 201===t.status?t.json.data:Promise.reject(t)}),(function(t){return Promise.reject(t)}))},a=function(t){return 200!==t.status||"checkout"===t.json.data.state?null:t.json.data.state},h=function(t){return o(t).then(a,(function(){return"failed"}))};function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}var l=window.nexioErrorMessages||{default_error:"Something went wrong"},c=function(t,e,n,i){var r=function(t,e){var n=document.createElement("label");return n.setAttribute("data-nexio-error",t),n.classList.add("error","nexio-error"),n.innerHTML=function(t,e){return e&&e.includes(" ")?e:l[t]&&l[t][e]||l.base&&l.base[e]||l.default_error}(t,e),n}(e,n);if("base"===e)t.appendChild(r);else{var o=t.querySelector('[name="payment_source['.concat(i,"][").concat(e,']"]'));o&&(o.classList.add("error"),o.parentNode.appendChild(r))}},f=function(t){return t.querySelectorAll("[data-nexio-error]").forEach((function(t){var e=t.parentNode;e.removeChild(t);var n=e.querySelector("[name].error");n&&n.classList.remove("error")}))},d={number:"card_number",cc_type:"card_type",name:"card_name",expiry:"card_expiration",verification_value:"card_code"},p=function(t,e,n){var i=d[e]||e,r=t.querySelector('[data-hook="'.concat(i,'"]'));return!!r&&(r.value=n,!0)};function m(t){return(m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function g(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var y=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=e,this.config=n}var e,n;return e=t,(n=[{key:"setup",value:function(t,e){s(this.config).then((function(n){var i=document.createElement("iframe");window.addEventListener("message",(function(n){if(i.contentWindow===n.source){var r=n.data;if(r&&"object"===m(r))switch(r.event){case"success":!function(t,e,n){p(e,"nexio_apm_transaction_id",n.id),n.apm&&p(e,"gateway_payment_profile_id",n.apm.token),t.submit()}(t,e,r.data);break;case"error":f(e),c(e,"base",r.data.message||"nexio_apm_payment_failed")}}})),i.setAttribute("src",n.iframe_url),i.classList.add("solidus-nexio-apm-iframe"),e.appendChild(i)}))}}])&&g(e.prototype,n),t}();function v(t){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(t)}function b(t,e){return t&e}function w(t,e){return t|e}function S(t,e){return t^e}function T(t,e){return t&~e}function E(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 x(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var D,O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function B(t){var e,n,i="";for(e=0;e+3<=t.length;e+=3)n=parseInt(t.substring(e,e+3),16),i+=O.charAt(n>>6)+O.charAt(63&n);for(e+1==t.length?(n=parseInt(t.substring(e,e+1),16),i+=O.charAt(n<<2)):e+2==t.length&&(n=parseInt(t.substring(e,e+2),16),i+=O.charAt(n>>2)+O.charAt((3&n)<<4));(3&i.length)>0;)i+="=";return i}function A(t){var e,n="",i=0,r=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var o=O.indexOf(t.charAt(e));o<0||(0==i?(n+=v(o>>2),r=3&o,i=1):1==i?(n+=v(r<<2|o>>4),r=15&o,i=2):2==i?(n+=v(r),n+=v(o>>2),r=3&o,i=3):(n+=v(r<<2|o>>4),n+=v(15&o),i=0))}return 1==i&&(n+=v(r<<2)),n}var C,R={decode:function(t){var e;if(void 0===C){var n="= \f\n\r\t \u2028\u2029";for(C=Object.create(null),e=0;e<64;++e)C["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(C["-"]=62,C._=63,e=0;e<n.length;++e)C[n.charAt(e)]=-1}var i=[],r=0,o=0;for(e=0;e<t.length;++e){var s=t.charAt(e);if("="==s)break;if(-1!=(s=C[s])){if(void 0===s)throw new Error("Illegal character at offset "+e);r|=s,++o>=4?(i[i.length]=r>>16,i[i.length]=r>>8&255,i[i.length]=255&r,r=0,o=0):r<<=6}}switch(o){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:i[i.length]=r>>10;break;case 3:i[i.length]=r>>16,i[i.length]=r>>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=R.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 R.decode(t)}},_=1e13,k=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var n,i,r=this.buf,o=r.length;for(n=0;n<o;++n)(i=r[n]*t+e)<_?e=0:i-=(e=0|i/_)*_,r[n]=i;e>0&&(r[n]=e)},t.prototype.sub=function(t){var e,n,i=this.buf,r=i.length;for(e=0;e<r;++e)(n=i[e]-t)<0?(n+=_,t=1):t=0,i[e]=n;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,n=e[e.length-1].toString(),i=e.length-2;i>=0;--i)n+=(_+e[i]).toString().substring(1);return n},t.prototype.valueOf=function(){for(var t=this.buf,e=0,n=t.length-1;n>=0;--n)e=e*_+t[n];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),V=/^(\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)?)?$/,I=/^(\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 P(t,e){return t.length>e&&(t=t.substring(0,e)+"…"),t}var N,L=function(){function t(e,n){this.hexDigits="0123456789ABCDEF",e instanceof t?(this.enc=e.enc,this.pos=e.pos):(this.enc=e,this.pos=n)}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,n){for(var i="",r=t;r<e;++r)if(i+=this.hexByte(this.get(r)),!0!==n)switch(15&r){case 7:i+=" ";break;case 15:i+="\n";break;default:i+=" "}return i},t.prototype.isASCII=function(t,e){for(var n=t;n<e;++n){var i=this.get(n);if(i<32||i>176)return!1}return!0},t.prototype.parseStringISO=function(t,e){for(var n="",i=t;i<e;++i)n+=String.fromCharCode(this.get(i));return n},t.prototype.parseStringUTF=function(t,e){for(var n="",i=t;i<e;){var r=this.get(i++);n+=r<128?String.fromCharCode(r):r>191&&r<224?String.fromCharCode((31&r)<<6|63&this.get(i++)):String.fromCharCode((15&r)<<12|(63&this.get(i++))<<6|63&this.get(i++))}return n},t.prototype.parseStringBMP=function(t,e){for(var n,i,r="",o=t;o<e;)n=this.get(o++),i=this.get(o++),r+=String.fromCharCode(n<<8|i);return r},t.prototype.parseTime=function(t,e,n){var i=this.parseStringISO(t,e),r=(n?V:I).exec(i);return r?(n&&(r[1]=+r[1],r[1]+=+r[1]<70?2e3:1900),i=r[1]+"-"+r[2]+"-"+r[3]+" "+r[4],r[5]&&(i+=":"+r[5],r[6]&&(i+=":"+r[6],r[7]&&(i+="."+r[7]))),r[8]&&(i+=" UTC","Z"!=r[8]&&(i+=r[8],r[9]&&(i+=":"+r[9]))),i):"Unrecognized time: "+i},t.prototype.parseInteger=function(t,e){for(var n,i=this.get(t),r=i>127,o=r?255:0,s="";i==o&&++t<e;)i=this.get(t);if(0==(n=e-t))return r?-1:0;if(n>4){for(s=i,n<<=3;0==(128&(+s^o));)s=+s<<1,--n;s="("+n+" bit)\n"}r&&(i-=256);for(var a=new k(i),h=t+1;h<e;++h)a.mulAdd(256,this.get(h));return s+a.toString()},t.prototype.parseBitString=function(t,e,n){for(var i=this.get(t),r="("+((e-t-1<<3)-i)+" bit)\n",o="",s=t+1;s<e;++s){for(var a=this.get(s),h=s==e-1?i:0,u=7;u>=h;--u)o+=a>>u&1?"1":"0";if(o.length>n)return r+P(o,n)}return r+o},t.prototype.parseOctetString=function(t,e,n){if(this.isASCII(t,e))return P(this.parseStringISO(t,e),n);var i=e-t,r="("+i+" byte)\n";i>(n/=2)&&(e=t+n);for(var o=t;o<e;++o)r+=this.hexByte(this.get(o));return i>n&&(r+="…"),r},t.prototype.parseOID=function(t,e,n){for(var i="",r=new k,o=0,s=t;s<e;++s){var a=this.get(s);if(r.mulAdd(128,127&a),o+=7,!(128&a)){if(""===i)if((r=r.simplify())instanceof k)r.sub(80),i="2."+r.toString();else{var h=r<80?r<40?0:1:2;i=h+"."+(r-40*h)}else i+="."+r.toString();if(i.length>n)return P(i,n);r=new k,o=0}}return o>0&&(i+=".incomplete"),i},t}(),j=function(){function t(t,e,n,i,r){if(!(i instanceof F))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=n,this.tag=i,this.sub=r}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(),n=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+n);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+n,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+n,t);case 6:return this.stream.parseOID(e,e+n,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return P(this.stream.parseStringUTF(e,e+n),t);case 18:case 19:case 20:case 21:case 22:case 26:return P(this.stream.parseStringISO(e,e+n),t);case 30:return P(this.stream.parseStringBMP(e,e+n),t);case 23:case 24:return this.stream.parseTime(e,e+n,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 n=0,i=this.sub.length;n<i;++n)e+=this.sub[n].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(),n=127&e;if(n==e)return n;if(n>6)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===n)return null;e=0;for(var i=0;i<n;++i)e=256*e+t.get();return e},t.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,n=2*this.length;return t.substr(e,n)},t.decode=function(e){var n;n=e instanceof L?e:new L(e,0);var i=new L(n),r=new F(n),o=t.decodeLength(n),s=n.pos,a=s-i.pos,h=null,u=function(){var e=[];if(null!==o){for(var i=s+o;n.pos<i;)e[e.length]=t.decode(n);if(n.pos!=i)throw new Error("Content size is not correct for container starting at offset "+s)}else try{for(;;){var r=t.decode(n);if(r.tag.isEOC())break;e[e.length]=r}o=s-n.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return e};if(r.tagConstructed)h=u();else if(r.isUniversal()&&(3==r.tagNumber||4==r.tagNumber))try{if(3==r.tagNumber&&0!=n.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");h=u();for(var l=0;l<h.length;++l)if(h[l].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){h=null}if(null===h){if(null===o)throw new Error("We can't skip over an invalid tag with undefined length at offset "+s);n.pos=s+Math.abs(o)}return new t(i,a,o,r,h)},t}(),F=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 n=new k;do{e=t.get(),n.mulAdd(128,127&e)}while(128&e);this.tagNumber=n.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),M=[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],q=(1<<26)/M[M.length-1],H=function(){function t(t,e,n){null!=t&&("number"==typeof t?this.fromNumber(t,e,n):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return t.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var n,i=(1<<e)-1,r=!1,o="",s=this.t,a=this.DB-s*this.DB%e;if(s-- >0)for(a<this.DB&&(n=this[s]>>a)>0&&(r=!0,o=v(n));s>=0;)a<e?(n=(this[s]&(1<<a)-1)<<e-a,n|=this[--s]>>(a+=this.DB-e)):(n=this[s]>>(a-=e)&i,a<=0&&(a+=this.DB,--s)),n>0&&(r=!0),r&&(o+=v(n));return r?o:"0"},t.prototype.negate=function(){var e=$();return t.ZERO.subTo(this,e),e},t.prototype.abs=function(){return this.s<0?this.negate():this},t.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var n=this.t;if(0!=(e=n-t.t))return this.s<0?-e:e;for(;--n>=0;)if(0!=(e=this[n]-t[n]))return e;return 0},t.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+et(this[this.t-1]^this.s&this.DM)},t.prototype.mod=function(e){var n=$();return this.abs().divRemTo(e,null,n),this.s<0&&n.compareTo(t.ZERO)>0&&e.subTo(n,n),n},t.prototype.modPowInt=function(t,e){var n;return n=t<256||e.isEven()?new K(e):new z(e),this.exp(t,n)},t.prototype.clone=function(){var t=$();return this.copyTo(t),t},t.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]},t.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},t.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},t.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},t.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var n,i=this.DB-t*this.DB%8,r=0;if(t-- >0)for(i<this.DB&&(n=this[t]>>i)!=(this.s&this.DM)>>i&&(e[r++]=n|this.s<<this.DB-i);t>=0;)i<8?(n=(this[t]&(1<<i)-1)<<8-i,n|=this[--t]>>(i+=this.DB-8)):(n=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),0!=(128&n)&&(n|=-256),0==r&&(128&this.s)!=(128&n)&&++r,(r>0||n!=this.s)&&(e[r++]=n);return e},t.prototype.equals=function(t){return 0==this.compareTo(t)},t.prototype.min=function(t){return this.compareTo(t)<0?this:t},t.prototype.max=function(t){return this.compareTo(t)>0?this:t},t.prototype.and=function(t){var e=$();return this.bitwiseTo(t,b,e),e},t.prototype.or=function(t){var e=$();return this.bitwiseTo(t,w,e),e},t.prototype.xor=function(t){var e=$();return this.bitwiseTo(t,S,e),e},t.prototype.andNot=function(t){var e=$();return this.bitwiseTo(t,T,e),e},t.prototype.not=function(){for(var t=$(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},t.prototype.shiftLeft=function(t){var e=$();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},t.prototype.shiftRight=function(t){var e=$();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},t.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+E(this[t]);return this.s<0?this.t*this.DB:-1},t.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,n=0;n<this.t;++n)t+=x(this[n]^e);return t},t.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)},t.prototype.setBit=function(t){return this.changeBit(t,w)},t.prototype.clearBit=function(t){return this.changeBit(t,T)},t.prototype.flipBit=function(t){return this.changeBit(t,S)},t.prototype.add=function(t){var e=$();return this.addTo(t,e),e},t.prototype.subtract=function(t){var e=$();return this.subTo(t,e),e},t.prototype.multiply=function(t){var e=$();return this.multiplyTo(t,e),e},t.prototype.divide=function(t){var e=$();return this.divRemTo(t,e,null),e},t.prototype.remainder=function(t){var e=$();return this.divRemTo(t,null,e),e},t.prototype.divideAndRemainder=function(t){var e=$(),n=$();return this.divRemTo(t,e,n),[e,n]},t.prototype.modPow=function(t,e){var n,i,r=t.bitLength(),o=tt(1);if(r<=0)return o;n=r<18?1:r<48?3:r<144?4:r<768?5:6,i=r<8?new K(e):e.isEven()?new G(e):new z(e);var s=[],a=3,h=n-1,u=(1<<n)-1;if(s[1]=i.convert(this),n>1){var l=$();for(i.sqrTo(s[1],l);a<=u;)s[a]=$(),i.mulTo(l,s[a-2],s[a]),a+=2}var c,f,d=t.t-1,p=!0,m=$();for(r=et(t[d])-1;d>=0;){for(r>=h?c=t[d]>>r-h&u:(c=(t[d]&(1<<r+1)-1)<<h-r,d>0&&(c|=t[d-1]>>this.DB+r-h)),a=n;0==(1&c);)c>>=1,--a;if((r-=a)<0&&(r+=this.DB,--d),p)s[c].copyTo(o),p=!1;else{for(;a>1;)i.sqrTo(o,m),i.sqrTo(m,o),a-=2;a>0?i.sqrTo(o,m):(f=o,o=m,m=f),i.mulTo(m,s[c],o)}for(;d>=0&&0==(t[d]&1<<r);)i.sqrTo(o,m),f=o,o=m,m=f,--r<0&&(r=this.DB-1,--d)}return i.revert(o)},t.prototype.modInverse=function(e){var n=e.isEven();if(this.isEven()&&n||0==e.signum())return t.ZERO;for(var i=e.clone(),r=this.clone(),o=tt(1),s=tt(0),a=tt(0),h=tt(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),n?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(e,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),n?(a.isEven()&&h.isEven()||(a.addTo(this,a),h.subTo(e,h)),a.rShiftTo(1,a)):h.isEven()||h.subTo(e,h),h.rShiftTo(1,h);i.compareTo(r)>=0?(i.subTo(r,i),n&&o.subTo(a,o),s.subTo(h,s)):(r.subTo(i,r),n&&a.subTo(o,a),h.subTo(s,h))}return 0!=r.compareTo(t.ONE)?t.ZERO:h.compareTo(e)>=0?h.subtract(e):h.signum()<0?(h.addTo(e,h),h.signum()<0?h.add(e):h):h},t.prototype.pow=function(t){return this.exp(t,new U)},t.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),n=t.s<0?t.negate():t.clone();if(e.compareTo(n)<0){var i=e;e=n,n=i}var r=e.getLowestSetBit(),o=n.getLowestSetBit();if(o<0)return e;for(r<o&&(o=r),o>0&&(e.rShiftTo(o,e),n.rShiftTo(o,n));e.signum()>0;)(r=e.getLowestSetBit())>0&&e.rShiftTo(r,e),(r=n.getLowestSetBit())>0&&n.rShiftTo(r,n),e.compareTo(n)>=0?(e.subTo(n,e),e.rShiftTo(1,e)):(n.subTo(e,n),n.rShiftTo(1,n));return o>0&&n.lShiftTo(o,n),n},t.prototype.isProbablePrime=function(t){var e,n=this.abs();if(1==n.t&&n[0]<=M[M.length-1]){for(e=0;e<M.length;++e)if(n[0]==M[e])return!0;return!1}if(n.isEven())return!1;for(e=1;e<M.length;){for(var i=M[e],r=e+1;r<M.length&&i<q;)i*=M[r++];for(i=n.modInt(i);e<r;)if(i%M[e++]==0)return!1}return n.millerRabin(t)},t.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},t.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},t.prototype.fromString=function(e,n){var i;if(16==n)i=4;else if(8==n)i=3;else if(256==n)i=8;else if(2==n)i=1;else if(32==n)i=5;else{if(4!=n)return void this.fromRadix(e,n);i=2}this.t=0,this.s=0;for(var r=e.length,o=!1,s=0;--r>=0;){var a=8==i?255&+e[r]:Q(e,r);a<0?"-"==e.charAt(r)&&(o=!0):(o=!1,0==s?this[this.t++]=a:s+i>this.DB?(this[this.t-1]|=(a&(1<<this.DB-s)-1)<<s,this[this.t++]=a>>this.DB-s):this[this.t-1]|=a<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&0!=(128&+e[0])&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&t.ZERO.subTo(this,this)},t.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},t.prototype.dlShiftTo=function(t,e){var n;for(n=this.t-1;n>=0;--n)e[n+t]=this[n];for(n=t-1;n>=0;--n)e[n]=0;e.t=this.t+t,e.s=this.s},t.prototype.drShiftTo=function(t,e){for(var n=t;n<this.t;++n)e[n-t]=this[n];e.t=Math.max(this.t-t,0),e.s=this.s},t.prototype.lShiftTo=function(t,e){for(var n=t%this.DB,i=this.DB-n,r=(1<<i)-1,o=Math.floor(t/this.DB),s=this.s<<n&this.DM,a=this.t-1;a>=0;--a)e[a+o+1]=this[a]>>i|s,s=(this[a]&r)<<n;for(a=o-1;a>=0;--a)e[a]=0;e[o]=s,e.t=this.t+o+1,e.s=this.s,e.clamp()},t.prototype.rShiftTo=function(t,e){e.s=this.s;var n=Math.floor(t/this.DB);if(n>=this.t)e.t=0;else{var i=t%this.DB,r=this.DB-i,o=(1<<i)-1;e[0]=this[n]>>i;for(var s=n+1;s<this.t;++s)e[s-n-1]|=(this[s]&o)<<r,e[s-n]=this[s]>>i;i>0&&(e[this.t-n-1]|=(this.s&o)<<r),e.t=this.t-n,e.clamp()}},t.prototype.subTo=function(t,e){for(var n=0,i=0,r=Math.min(t.t,this.t);n<r;)i+=this[n]-t[n],e[n++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;n<this.t;)i+=this[n],e[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<t.t;)i-=t[n],e[n++]=i&this.DM,i>>=this.DB;i-=t.s}e.s=i<0?-1:0,i<-1?e[n++]=this.DV+i:i>0&&(e[n++]=i),e.t=n,e.clamp()},t.prototype.multiplyTo=function(e,n){var i=this.abs(),r=e.abs(),o=i.t;for(n.t=o+r.t;--o>=0;)n[o]=0;for(o=0;o<r.t;++o)n[o+i.t]=i.am(0,r[o],n,o,0,i.t);n.s=0,n.clamp(),this.s!=e.s&&t.ZERO.subTo(n,n)},t.prototype.squareTo=function(t){for(var e=this.abs(),n=t.t=2*e.t;--n>=0;)t[n]=0;for(n=0;n<e.t-1;++n){var i=e.am(n,e[n],t,2*n,0,1);(t[n+e.t]+=e.am(n+1,2*e[n],t,2*n+1,i,e.t-n-1))>=e.DV&&(t[n+e.t]-=e.DV,t[n+e.t+1]=1)}t.t>0&&(t[t.t-1]+=e.am(n,e[n],t,2*n,0,1)),t.s=0,t.clamp()},t.prototype.divRemTo=function(e,n,i){var r=e.abs();if(!(r.t<=0)){var o=this.abs();if(o.t<r.t)return null!=n&&n.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=$());var s=$(),a=this.s,h=e.s,u=this.DB-et(r[r.t-1]);u>0?(r.lShiftTo(u,s),o.lShiftTo(u,i)):(r.copyTo(s),o.copyTo(i));var l=s.t,c=s[l-1];if(0!=c){var f=c*(1<<this.F1)+(l>1?s[l-2]>>this.F2:0),d=this.FV/f,p=(1<<this.F1)/f,m=1<<this.F2,g=i.t,y=g-l,v=null==n?$():n;for(s.dlShiftTo(y,v),i.compareTo(v)>=0&&(i[i.t++]=1,i.subTo(v,i)),t.ONE.dlShiftTo(l,v),v.subTo(s,s);s.t<l;)s[s.t++]=0;for(;--y>=0;){var b=i[--g]==c?this.DM:Math.floor(i[g]*d+(i[g-1]+m)*p);if((i[g]+=s.am(0,b,i,y,0,l))<b)for(s.dlShiftTo(y,v),i.subTo(v,i);i[g]<--b;)i.subTo(v,i)}null!=n&&(i.drShiftTo(l,n),a!=h&&t.ZERO.subTo(n,n)),i.t=l,i.clamp(),u>0&&i.rShiftTo(u,i),a<0&&t.ZERO.subTo(i,i)}}},t.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},t.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},t.prototype.exp=function(e,n){if(e>4294967295||e<1)return t.ONE;var i=$(),r=$(),o=n.convert(this),s=et(e)-1;for(o.copyTo(i);--s>=0;)if(n.sqrTo(i,r),(e&1<<s)>0)n.mulTo(r,o,i);else{var a=i;i=r,r=a}return n.revert(i)},t.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},t.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var e=this.chunkSize(t),n=Math.pow(t,e),i=tt(n),r=$(),o=$(),s="";for(this.divRemTo(i,r,o);r.signum()>0;)s=(n+o.intValue()).toString(t).substr(1)+s,r.divRemTo(i,r,o);return o.intValue().toString(t)+s},t.prototype.fromRadix=function(e,n){this.fromInt(0),null==n&&(n=10);for(var i=this.chunkSize(n),r=Math.pow(n,i),o=!1,s=0,a=0,h=0;h<e.length;++h){var u=Q(e,h);u<0?"-"==e.charAt(h)&&0==this.signum()&&(o=!0):(a=n*a+u,++s>=i&&(this.dMultiply(r),this.dAddOffset(a,0),s=0,a=0))}s>0&&(this.dMultiply(Math.pow(n,s)),this.dAddOffset(a,0)),o&&t.ZERO.subTo(this,this)},t.prototype.fromNumber=function(e,n,i){if("number"==typeof n)if(e<2)this.fromInt(1);else for(this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),w,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(n);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(t.ONE.shiftLeft(e-1),this);else{var r=[],o=7&e;r.length=1+(e>>3),n.nextBytes(r),o>0?r[0]&=(1<<o)-1:r[0]=0,this.fromString(r,256)}},t.prototype.bitwiseTo=function(t,e,n){var i,r,o=Math.min(t.t,this.t);for(i=0;i<o;++i)n[i]=e(this[i],t[i]);if(t.t<this.t){for(r=t.s&this.DM,i=o;i<this.t;++i)n[i]=e(this[i],r);n.t=this.t}else{for(r=this.s&this.DM,i=o;i<t.t;++i)n[i]=e(r,t[i]);n.t=t.t}n.s=e(this.s,t.s),n.clamp()},t.prototype.changeBit=function(e,n){var i=t.ONE.shiftLeft(e);return this.bitwiseTo(i,n,i),i},t.prototype.addTo=function(t,e){for(var n=0,i=0,r=Math.min(t.t,this.t);n<r;)i+=this[n]+t[n],e[n++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;n<this.t;)i+=this[n],e[n++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;n<t.t;)i+=t[n],e[n++]=i&this.DM,i>>=this.DB;i+=t.s}e.s=i<0?-1:0,i>0?e[n++]=i:i<-1&&(e[n++]=this.DV+i),e.t=n,e.clamp()},t.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},t.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]}},t.prototype.multiplyLowerTo=function(t,e,n){var i=Math.min(this.t+t.t,e);for(n.s=0,n.t=i;i>0;)n[--i]=0;for(var r=n.t-this.t;i<r;++i)n[i+this.t]=this.am(0,t[i],n,i,0,this.t);for(r=Math.min(t.t,e);i<r;++i)this.am(0,t[i],n,i,0,e-i);n.clamp()},t.prototype.multiplyUpperTo=function(t,e,n){--e;var i=n.t=this.t+t.t-e;for(n.s=0;--i>=0;)n[i]=0;for(i=Math.max(e-this.t,0);i<t.t;++i)n[this.t+i-e]=this.am(e-i,t[i],n,0,0,this.t+i-e);n.clamp(),n.drShiftTo(1,n)},t.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,n=this.s<0?t-1:0;if(this.t>0)if(0==e)n=this[0]%t;else for(var i=this.t-1;i>=0;--i)n=(e*n+this[i])%t;return n},t.prototype.millerRabin=function(e){var n=this.subtract(t.ONE),i=n.getLowestSetBit();if(i<=0)return!1;var r=n.shiftRight(i);(e=e+1>>1)>M.length&&(e=M.length);for(var o=$(),s=0;s<e;++s){o.fromInt(M[Math.floor(Math.random()*M.length)]);var a=o.modPow(r,this);if(0!=a.compareTo(t.ONE)&&0!=a.compareTo(n)){for(var h=1;h++<i&&0!=a.compareTo(n);)if(0==(a=a.modPowInt(2,this)).compareTo(t.ONE))return!1;if(0!=a.compareTo(n))return!1}}return!0},t.prototype.square=function(){var t=$();return this.squareTo(t),t},t.prototype.gcda=function(t,e){var n=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(n.compareTo(i)<0){var r=n;n=i,i=r}var o=n.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)e(n);else{o<s&&(s=o),s>0&&(n.rShiftTo(s,n),i.rShiftTo(s,i));var a=function(){(o=n.getLowestSetBit())>0&&n.rShiftTo(o,n),(o=i.getLowestSetBit())>0&&i.rShiftTo(o,i),n.compareTo(i)>=0?(n.subTo(i,n),n.rShiftTo(1,n)):(i.subTo(n,i),i.rShiftTo(1,i)),n.signum()>0?setTimeout(a,0):(s>0&&i.lShiftTo(s,i),setTimeout((function(){e(i)}),0))};setTimeout(a,10)}},t.prototype.fromNumberAsync=function(e,n,i,r){if("number"==typeof n)if(e<2)this.fromInt(1);else{this.fromNumber(e,i),this.testBit(e-1)||this.bitwiseTo(t.ONE.shiftLeft(e-1),w,this),this.isEven()&&this.dAddOffset(1,0);var o=this,s=function(){o.dAddOffset(2,0),o.bitLength()>e&&o.subTo(t.ONE.shiftLeft(e-1),o),o.isProbablePrime(n)?setTimeout((function(){r()}),0):setTimeout(s,0)};setTimeout(s,0)}else{var a=[],h=7&e;a.length=1+(e>>3),n.nextBytes(a),h>0?a[0]&=(1<<h)-1:a[0]=0,this.fromString(a,256)}},t}(),U=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),K=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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),z=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=$();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&e.compareTo(H.ZERO)>0&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=$();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 n=32767&t[e],i=n*this.mpl+((n*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[n=e+this.m.t]+=this.m.am(0,i,t,e,0,this.m.t);t[n]>=t.DV;)t[n]-=t.DV,t[++n]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),G=function(){function t(t){this.m=t,this.r2=$(),this.q3=$(),H.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=$();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,n){t.multiplyTo(e,n),this.reduce(n)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function $(){return new H(null)}function Z(t,e){return new H(t,e)}var W="undefined"!=typeof navigator;W&&"Microsoft Internet Explorer"==navigator.appName?(H.prototype.am=function(t,e,n,i,r,o){for(var s=32767&e,a=e>>15;--o>=0;){var h=32767&this[t],u=this[t++]>>15,l=a*h+u*s;r=((h=s*h+((32767&l)<<15)+n[i]+(1073741823&r))>>>30)+(l>>>15)+a*u+(r>>>30),n[i++]=1073741823&h}return r},N=30):W&&"Netscape"!=navigator.appName?(H.prototype.am=function(t,e,n,i,r,o){for(;--o>=0;){var s=e*this[t++]+n[i]+r;r=Math.floor(s/67108864),n[i++]=67108863&s}return r},N=26):(H.prototype.am=function(t,e,n,i,r,o){for(var s=16383&e,a=e>>14;--o>=0;){var h=16383&this[t],u=this[t++]>>14,l=a*h+u*s;r=((h=s*h+((16383&l)<<14)+n[i]+r)>>28)+(l>>14)+a*u,n[i++]=268435455&h}return r},N=28),H.prototype.DB=N,H.prototype.DM=(1<<N)-1,H.prototype.DV=1<<N,H.prototype.FV=Math.pow(2,52),H.prototype.F1=52-N,H.prototype.F2=2*N-52;var Y,X,J=[];for(Y="0".charCodeAt(0),X=0;X<=9;++X)J[Y++]=X;for(Y="a".charCodeAt(0),X=10;X<36;++X)J[Y++]=X;for(Y="A".charCodeAt(0),X=10;X<36;++X)J[Y++]=X;function Q(t,e){var n=J[t.charCodeAt(e)];return null==n?-1:n}function tt(t){var e=$();return e.fromInt(t),e}function et(t){var e,n=1;return 0!=(e=t>>>16)&&(t=e,n+=16),0!=(e=t>>8)&&(t=e,n+=8),0!=(e=t>>4)&&(t=e,n+=4),0!=(e=t>>2)&&(t=e,n+=2),0!=(e=t>>1)&&(t=e,n+=1),n}H.ZERO=tt(0),H.ONE=tt(1);var nt,it,rt=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,n,i;for(e=0;e<256;++e)this.S[e]=e;for(n=0,e=0;e<256;++e)n=n+this.S[e]+t[e%t.length]&255,i=this.S[e],this.S[e]=this.S[n],this.S[n]=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}(),ot=null;if(null==ot){ot=[],it=0;var st=void 0;if(window.crypto&&window.crypto.getRandomValues){var at=new Uint32Array(256);for(window.crypto.getRandomValues(at),st=0;st<at.length;++st)ot[it++]=255&at[st]}var ht=0,ut=function(t){if((ht=ht||0)>=256||it>=256)window.removeEventListener?window.removeEventListener("mousemove",ut,!1):window.detachEvent&&window.detachEvent("onmousemove",ut);else try{var e=t.x+t.y;ot[it++]=255&e,ht+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",ut,!1):window.attachEvent&&window.attachEvent("onmousemove",ut)}function lt(){if(null==nt){for(nt=new rt;it<256;){var t=Math.floor(65536*Math.random());ot[it++]=255&t}for(nt.init(ot),it=0;it<ot.length;++it)ot[it]=0;it=0}return nt.next()}var ct=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=lt()},t}(),ft=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),n=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(n)<0;)e=e.add(this.p);return e.subtract(n).multiply(this.coeff).mod(this.p).multiply(this.q).add(n)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=Z(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,n=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var n=[],i=t.length-1;i>=0&&e>0;){var r=t.charCodeAt(i--);r<128?n[--e]=r:r>127&&r<2048?(n[--e]=63&r|128,n[--e]=r>>6|192):(n[--e]=63&r|128,n[--e]=r>>6&63|128,n[--e]=r>>12|224)}n[--e]=0;for(var o=new ct,s=[];e>2;){for(s[0]=0;0==s[0];)o.nextBytes(s);n[--e]=s[0]}return n[--e]=2,n[--e]=0,new H(n)}(t,e);if(null==n)return null;var i=this.doPublic(n);if(null==i)return null;for(var r=i.toString(16),o=r.length,s=0;s<2*e-o;s++)r="0"+r;return r},t.prototype.setPrivate=function(t,e,n){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(n,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,n,i,r,o,s,a){null!=t&&null!=e&&t.length>0&&e.length>0?(this.n=Z(t,16),this.e=parseInt(e,16),this.d=Z(n,16),this.p=Z(i,16),this.q=Z(r,16),this.dmp1=Z(o,16),this.dmq1=Z(s,16),this.coeff=Z(a,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var n=new ct,i=t>>1;this.e=parseInt(e,16);for(var r=new H(e,16);;){for(;this.p=new H(t-i,1,n),0!=this.p.subtract(H.ONE).gcd(r).compareTo(H.ONE)||!this.p.isProbablePrime(10););for(;this.q=new H(i,1,n),0!=this.q.subtract(H.ONE).gcd(r).compareTo(H.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var o=this.p;this.p=this.q,this.q=o}var s=this.p.subtract(H.ONE),a=this.q.subtract(H.ONE),h=s.multiply(a);if(0==h.gcd(r).compareTo(H.ONE)){this.n=this.p.multiply(this.q),this.d=r.modInverse(h),this.dmp1=this.d.mod(s),this.dmq1=this.d.mod(a),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=Z(t,16),n=this.doPrivate(e);return null==n?null:function(t,e){for(var n=t.toByteArray(),i=0;i<n.length&&0==n[i];)++i;if(n.length-i!=e-1||2!=n[i])return null;for(++i;0!=n[i];)if(++i>=n.length)return null;for(var r="";++i<n.length;){var o=255&n[i];o<128?r+=String.fromCharCode(o):o>191&&o<224?(r+=String.fromCharCode((31&o)<<6|63&n[i+1]),++i):(r+=String.fromCharCode((15&o)<<12|(63&n[i+1])<<6|63&n[i+2]),i+=2)}return r}(n,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,n){var i=new ct,r=t>>1;this.e=parseInt(e,16);var o=new H(e,16),s=this,a=function(){var e=function(){if(s.p.compareTo(s.q)<=0){var t=s.p;s.p=s.q,s.q=t}var e=s.p.subtract(H.ONE),i=s.q.subtract(H.ONE),r=e.multiply(i);0==r.gcd(o).compareTo(H.ONE)?(s.n=s.p.multiply(s.q),s.d=o.modInverse(r),s.dmp1=s.d.mod(e),s.dmq1=s.d.mod(i),s.coeff=s.q.modInverse(s.p),setTimeout((function(){n()}),0)):setTimeout(a,0)},h=function(){s.q=$(),s.q.fromNumberAsync(r,1,i,(function(){s.q.subtract(H.ONE).gcda(o,(function(t){0==t.compareTo(H.ONE)&&s.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(h,0)}))}))},u=function(){s.p=$(),s.p.fromNumberAsync(t-r,1,i,(function(){s.p.subtract(H.ONE).gcda(o,(function(t){0==t.compareTo(H.ONE)&&s.p.isProbablePrime(10)?setTimeout(h,0):setTimeout(u,0)}))}))};setTimeout(u,0)};setTimeout(a,0)},t.prototype.sign=function(t,e,n){var i=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var n=e-t.length-6,i="",r=0;r<n;r+=2)i+="ff";return Z("0001"+i+"00"+t,16)}((dt[n]||"")+e(t).toString(),this.n.bitLength()/4);if(null==i)return null;var r=this.doPrivate(i);if(null==r)return null;var o=r.toString(16);return 0==(1&o.length)?o:"0"+o},t.prototype.verify=function(t,e,n){var i=Z(e,16),r=this.doPublic(i);return null==r?null:function(t){for(var e in dt)if(dt.hasOwnProperty(e)){var n=dt[e],i=n.length;if(t.substr(0,i)==n)return t.substr(i)}return t}(r.toString(16).replace(/^1f+00/,""))==n(t).toString()},t}(),dt={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"},pt={};pt.lang={extend:function(t,e,n){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),n){var r;for(r in n)t.prototype[r]=n[r];var o=function(){},s=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(o=function(t,e){for(r=0;r<s.length;r+=1){var n=s[r],i=e[n];"function"==typeof i&&i!=Object.prototype[n]&&(t[n]=i)}})}catch(t){}o(t.prototype,n)}}};var mt={};void 0!==mt.asn1&&mt.asn1||(mt.asn1={}),mt.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 n=e.substr(1).length;n%2==1?n+=1:e.match(/^[0-7]/)||(n+=2);for(var i="",r=0;r<n;r++)i+="f";e=new H(i,16).xor(t).add(H.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=mt.asn1,n=e.DERBoolean,i=e.DERInteger,r=e.DERBitString,o=e.DEROctetString,s=e.DERNull,a=e.DERObjectIdentifier,h=e.DEREnumerated,u=e.DERUTF8String,l=e.DERNumericString,c=e.DERPrintableString,f=e.DERTeletexString,d=e.DERIA5String,p=e.DERUTCTime,m=e.DERGeneralizedTime,g=e.DERSequence,y=e.DERSet,v=e.DERTaggedObject,b=e.ASN1Util.newObject,w=Object.keys(t);if(1!=w.length)throw"key of param shall be only one.";var S=w[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 n(t[S]);if("int"==S)return new i(t[S]);if("bitstr"==S)return new r(t[S]);if("octstr"==S)return new o(t[S]);if("null"==S)return new s(t[S]);if("oid"==S)return new a(t[S]);if("enum"==S)return new h(t[S]);if("utf8str"==S)return new u(t[S]);if("numstr"==S)return new l(t[S]);if("prnstr"==S)return new c(t[S]);if("telstr"==S)return new f(t[S]);if("ia5str"==S)return new d(t[S]);if("utctime"==S)return new p(t[S]);if("gentime"==S)return new m(t[S]);if("seq"==S){for(var T=t[S],E=[],x=0;x<T.length;x++){var D=b(T[x]);E.push(D)}return new g({array:E})}if("set"==S){for(T=t[S],E=[],x=0;x<T.length;x++)D=b(T[x]),E.push(D);return new y({array:E})}if("tag"==S){var O=t[S];if("[object Array]"===Object.prototype.toString.call(O)&&3==O.length){var B=b(O[2]);return new v({tag:O[0],explicit:O[1],obj:B})}var A={};if(void 0!==O.explicit&&(A.explicit=O.explicit),void 0!==O.tag&&(A.tag=O.tag),void 0===O.obj)throw"obj shall be specified for 'tag'.";return A.obj=b(O.obj),new v(A)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},mt.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",n=parseInt(t.substr(0,2),16),i=(e=Math.floor(n/40)+"."+n%40,""),r=2;r<t.length;r+=2){var o=("00000000"+parseInt(t.substr(r,2),16).toString(2)).slice(-8);i+=o.substr(1,7),"0"==o.substr(0,1)&&(e=e+"."+new H(i,2).toString(10),i="")}return e},mt.asn1.ASN1Util.oidIntToHex=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",i=new H(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";for(i=o+i,s=0;s<i.length-1;s+=7){var a=i.substr(s,7);s!=i.length-7&&(a="1"+a),n+=e(parseInt(a,2))}return n};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",r=t.split("."),o=40*parseInt(r[0])+parseInt(r[1]);i+=e(o),r.splice(0,2);for(var s=0;s<r.length;s++)i+=n(r[s]);return i},mt.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 n=e.length/2;if(n>15)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+n).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""}},mt.asn1.DERAbstractString=function(t){mt.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))},pt.lang.extend(mt.asn1.DERAbstractString,mt.asn1.ASN1Object),mt.asn1.DERAbstractTime=function(t){mt.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,n){var i=this.zeroPadding,r=this.localDateToUTC(t),o=String(r.getFullYear());"utc"==e&&(o=o.substr(2,2));var s=o+i(String(r.getMonth()+1),2)+i(String(r.getDate()),2)+i(String(r.getHours()),2)+i(String(r.getMinutes()),2)+i(String(r.getSeconds()),2);if(!0===n){var a=r.getMilliseconds();if(0!=a){var h=i(String(a),3);s=s+"."+(h=h.replace(/[0]+$/,""))}}return s+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,n,i,r,o){var s=new Date(Date.UTC(t,e-1,n,i,r,o,0));this.setByDate(s)},this.getFreshValueHex=function(){return this.hV}},pt.lang.extend(mt.asn1.DERAbstractTime,mt.asn1.ASN1Object),mt.asn1.DERAbstractStructured=function(t){mt.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)},pt.lang.extend(mt.asn1.DERAbstractStructured,mt.asn1.ASN1Object),mt.asn1.DERBoolean=function(){mt.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},pt.lang.extend(mt.asn1.DERBoolean,mt.asn1.ASN1Object),mt.asn1.DERInteger=function(t){mt.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=mt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new H(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))},pt.lang.extend(mt.asn1.DERInteger,mt.asn1.ASN1Object),mt.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=mt.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}mt.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 n="0"+t;this.hTLV=null,this.isModified=!0,this.hV=n+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var n=0;n<=e;n++)t+="0";var i="";for(n=0;n<t.length-1;n+=8){var r=t.substr(n,8),o=parseInt(r,2).toString(16);1==o.length&&(o="0"+o),i+=o}this.hTLV=null,this.isModified=!0,this.hV="0"+e+i},this.setByBooleanArray=function(t){for(var e="",n=0;n<t.length;n++)1==t[n]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=!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))},pt.lang.extend(mt.asn1.DERBitString,mt.asn1.ASN1Object),mt.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=mt.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}mt.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},pt.lang.extend(mt.asn1.DEROctetString,mt.asn1.DERAbstractString),mt.asn1.DERNull=function(){mt.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},pt.lang.extend(mt.asn1.DERNull,mt.asn1.ASN1Object),mt.asn1.DERObjectIdentifier=function(t){var e=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},n=function(t){var n="",i=new H(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var o="",s=0;s<r;s++)o+="0";for(i=o+i,s=0;s<i.length-1;s+=7){var a=i.substr(s,7);s!=i.length-7&&(a="1"+a),n+=e(parseInt(a,2))}return n};mt.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="",r=t.split("."),o=40*parseInt(r[0])+parseInt(r[1]);i+=e(o),r.splice(0,2);for(var s=0;s<r.length;s++)i+=n(r[s]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=i},this.setValueName=function(t){var e=mt.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))},pt.lang.extend(mt.asn1.DERObjectIdentifier,mt.asn1.ASN1Object),mt.asn1.DEREnumerated=function(t){mt.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=mt.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new H(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))},pt.lang.extend(mt.asn1.DEREnumerated,mt.asn1.ASN1Object),mt.asn1.DERUTF8String=function(t){mt.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},pt.lang.extend(mt.asn1.DERUTF8String,mt.asn1.DERAbstractString),mt.asn1.DERNumericString=function(t){mt.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},pt.lang.extend(mt.asn1.DERNumericString,mt.asn1.DERAbstractString),mt.asn1.DERPrintableString=function(t){mt.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},pt.lang.extend(mt.asn1.DERPrintableString,mt.asn1.DERAbstractString),mt.asn1.DERTeletexString=function(t){mt.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},pt.lang.extend(mt.asn1.DERTeletexString,mt.asn1.DERAbstractString),mt.asn1.DERIA5String=function(t){mt.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},pt.lang.extend(mt.asn1.DERIA5String,mt.asn1.DERAbstractString),mt.asn1.DERUTCTime=function(t){mt.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))},pt.lang.extend(mt.asn1.DERUTCTime,mt.asn1.DERAbstractTime),mt.asn1.DERGeneralizedTime=function(t){mt.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))},pt.lang.extend(mt.asn1.DERGeneralizedTime,mt.asn1.DERAbstractTime),mt.asn1.DERSequence=function(t){mt.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}},pt.lang.extend(mt.asn1.DERSequence,mt.asn1.DERAbstractStructured),mt.asn1.DERSet=function(t){mt.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 n=this.asn1Array[e];t.push(n.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)},pt.lang.extend(mt.asn1.DERSet,mt.asn1.DERAbstractStructured),mt.asn1.DERTaggedObject=function(t){mt.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,n){this.hT=e,this.isExplicit=t,this.asn1Object=n,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=n.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},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)))},pt.lang.extend(mt.asn1.DERTaggedObject,mt.asn1.ASN1Object);var gt,yt=(gt=function(t,e){return(gt=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(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 n(){this.constructor=t}gt(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),vt=function(t){function e(n){var i=t.call(this)||this;return n&&("string"==typeof n?i.parseKey(n):(e.hasPrivateKeyProperty(n)||e.hasPublicKeyProperty(n))&&i.parsePropertiesFrom(n)),i}return yt(e,t),e.prototype.parseKey=function(t){try{var e=0,n=0,i=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?function(t){var e;if(void 0===D){var n="0123456789ABCDEF",i=" \f\n\r\t \u2028\u2029";for(D={},e=0;e<16;++e)D[n.charAt(e)]=e;for(n=n.toLowerCase(),e=10;e<16;++e)D[n.charAt(e)]=e;for(e=0;e<i.length;++e)D[i.charAt(e)]=-1}var r=[],o=0,s=0;for(e=0;e<t.length;++e){var a=t.charAt(e);if("="==a)break;if(-1!=(a=D[a])){if(void 0===a)throw new Error("Illegal character at offset "+e);o|=a,++s>=2?(r[r.length]=o,o=0,s=0):o<<=4}}if(s)throw new Error("Hex encoding incomplete: 4 bits missing");return r}(t):R.unarmor(t),r=j.decode(i);if(3===r.sub.length&&(r=r.sub[2].sub[0]),9===r.sub.length){e=r.sub[1].getHexStringValue(),this.n=Z(e,16),n=r.sub[2].getHexStringValue(),this.e=parseInt(n,16);var o=r.sub[3].getHexStringValue();this.d=Z(o,16);var s=r.sub[4].getHexStringValue();this.p=Z(s,16);var a=r.sub[5].getHexStringValue();this.q=Z(a,16);var h=r.sub[6].getHexStringValue();this.dmp1=Z(h,16);var u=r.sub[7].getHexStringValue();this.dmq1=Z(u,16);var l=r.sub[8].getHexStringValue();this.coeff=Z(l,16)}else{if(2!==r.sub.length)return!1;var c=r.sub[1].sub[0];e=c.sub[0].getHexStringValue(),this.n=Z(e,16),n=c.sub[1].getHexStringValue(),this.e=parseInt(n,16)}return!0}catch(t){return!1}},e.prototype.getPrivateBaseKey=function(){var t={array:[new mt.asn1.DERInteger({int:0}),new mt.asn1.DERInteger({bigint:this.n}),new mt.asn1.DERInteger({int:this.e}),new mt.asn1.DERInteger({bigint:this.d}),new mt.asn1.DERInteger({bigint:this.p}),new mt.asn1.DERInteger({bigint:this.q}),new mt.asn1.DERInteger({bigint:this.dmp1}),new mt.asn1.DERInteger({bigint:this.dmq1}),new mt.asn1.DERInteger({bigint:this.coeff})]};return new mt.asn1.DERSequence(t).getEncodedHex()},e.prototype.getPrivateBaseKeyB64=function(){return B(this.getPrivateBaseKey())},e.prototype.getPublicBaseKey=function(){var t=new mt.asn1.DERSequence({array:[new mt.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new mt.asn1.DERNull]}),e=new mt.asn1.DERSequence({array:[new mt.asn1.DERInteger({bigint:this.n}),new mt.asn1.DERInteger({int:this.e})]}),n=new mt.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new mt.asn1.DERSequence({array:[t,n]}).getEncodedHex()},e.prototype.getPublicBaseKeyB64=function(){return B(this.getPublicBaseKey())},e.wordwrap=function(t,e){if(!t)return t;var n="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(n,"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}(ft);const bt=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 vt(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(A(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return B(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,n){try{return B(this.getKey().sign(t,e,n))}catch(t){return!1}},t.prototype.verify=function(t,e,n){try{return this.getKey().verify(t,A(e),n)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new vt,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}();var wt=n(584),St=n.n(wt),Tt=document.createElement("style");Tt.setAttribute("type","text/css"),Tt.innerHTML='.tingle-modal * {\n box-sizing: border-box;\n}\n\n.tingle-modal {\n position: fixed;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n z-index: 1000;\n display: flex;\n visibility: hidden;\n flex-direction: column;\n align-items: center;\n overflow: hidden;\n -webkit-overflow-scrolling: touch;\n background: rgba(0, 0, 0, .2);\n opacity: 0;\n}\n\n@supports (backdrop-filter: blur(12px)) {\n .tingle-modal {\n backdrop-filter: blur(12px);\n }\n}\n\n/* confirm and alerts\n-------------------------------------------------------------- */\n\n.tingle-modal--confirm .tingle-modal-box {\n text-align: center;\n}\n\n/* modal\n-------------------------------------------------------------- */\n\n.tingle-modal--noOverlayClose {\n cursor: default;\n}\n\n.tingle-modal--noClose .tingle-modal__close {\n display: none;\n}\n\n.tingle-modal__close {\n position: fixed;\n top: 2.5rem;\n right: 2.5rem;\n z-index: 1000;\n padding: 0;\n width: 2rem;\n height: 2rem;\n border: none;\n background-color: transparent;\n color: #fff;\n cursor: pointer;\n}\n\n.tingle-modal__close svg * {\n fill: currentColor;\n}\n\n.tingle-modal__closeLabel {\n display: none;\n}\n\n.tingle-modal__close:hover {\n color: #fff;\n}\n\n.tingle-modal-box {\n position: relative;\n flex-shrink: 0;\n margin-top: auto;\n margin-bottom: auto;\n width: 60%;\n border-radius: 4px;\n background: #fff;\n opacity: 1;\n cursor: auto;\n will-change: transform, opacity;\n}\n\n.tingle-modal-box__content {\n padding: 0;\n}\n\n.tingle-modal-box__footer {\n padding: 1.5rem 2rem;\n width: auto;\n border-bottom-right-radius: 4px;\n border-bottom-left-radius: 4px;\n background-color: #f5f5f5;\n cursor: auto;\n}\n\n.tingle-modal-box__footer::after {\n display: table;\n clear: both;\n content: "";\n}\n\n.tingle-modal-box__footer--sticky {\n position: fixed;\n bottom: -200px; /* TODO : find a better way */\n z-index: 10001;\n opacity: 1;\n transition: bottom .3s ease-in-out .3s;\n}\n\n/* state\n-------------------------------------------------------------- */\n\n.tingle-enabled {\n position: fixed;\n right: 0;\n left: 0;\n overflow: hidden;\n}\n\n.tingle-modal--visible .tingle-modal-box__footer {\n bottom: 0;\n}\n\n.tingle-modal--visible {\n visibility: visible;\n opacity: 1;\n}\n\n.tingle-modal--visible .tingle-modal-box {\n animation: scale .2s cubic-bezier(.68, -.55, .265, 1.55) forwards;\n}\n\n.tingle-modal--overflow {\n overflow-y: scroll;\n padding-top: 8vh;\n}\n\n/* btn\n-------------------------------------------------------------- */\n\n.tingle-btn {\n display: inline-block;\n margin: 0 .5rem;\n padding: 1rem 2rem;\n border: none;\n background-color: grey;\n box-shadow: none;\n color: #fff;\n vertical-align: middle;\n text-decoration: none;\n font-size: inherit;\n font-family: inherit;\n line-height: normal;\n cursor: pointer;\n transition: background-color .4s ease;\n}\n\n.tingle-btn--primary {\n background-color: #3498db;\n}\n\n.tingle-btn--danger {\n background-color: #e74c3c;\n}\n\n.tingle-btn--default {\n background-color: #34495e;\n}\n\n.tingle-btn--pull-left {\n float: left;\n}\n\n.tingle-btn--pull-right {\n float: right;\n}\n\n/* responsive\n-------------------------------------------------------------- */\n\n@media (max-width : 540px) {\n .tingle-modal {\n top: 0px;\n display: block;\n padding-top: 60px;\n width: 100%;\n }\n\n .tingle-modal-box {\n width: auto;\n border-radius: 0;\n }\n\n .tingle-modal-box__content {\n overflow-y: scroll;\n }\n\n .tingle-modal--noClose {\n top: 0;\n }\n\n .tingle-modal--noOverlayClose {\n padding-top: 0;\n }\n\n .tingle-modal-box__footer .tingle-btn {\n display: block;\n float: none;\n margin-bottom: 1rem;\n width: 100%;\n }\n\n .tingle-modal__close {\n top: 0;\n right: 0;\n left: 0;\n display: block;\n width: 100%;\n height: 60px;\n border: none;\n background-color: #2c3e50;\n box-shadow: none;\n color: #fff;\n }\n\n .tingle-modal__closeLabel {\n display: inline-block;\n vertical-align: middle;\n font-size: 1.6rem;\n font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;\n }\n\n .tingle-modal__closeIcon {\n display: inline-block;\n margin-right: .8rem;\n width: 1.6rem;\n vertical-align: middle;\n font-size: 0;\n }\n}\n\n/* animations\n-------------------------------------------------------------- */\n\n@keyframes scale {\n 0% {\n opacity: 0;\n transform: scale(.9);\n }\n 100% {\n opacity: 1;\n transform: scale(1);\n }\n}\n\n.tingle-modal-box__iframe {\n border: 0;\n height: 500px;\n width: 100%;\n}\n',document.head.appendChild(Tt);var Et=function t(e,n,i){h(e).then((function(r){r?(n.isOpen()&&n.close(),i(r)):n.isOpen()?setTimeout(t.bind(null,e,n,i),2e3):h(e).then((function(t){return i(t||"invalid")}))}))};const xt=function(t,e){var n=new(St().modal)({closeMethods:["overlay","button","escape"],closeLabel:"Close",onOpen:function(){setTimeout((function(){return Et(t.check_path,n,e)}),3e3)},onClose:function(){n.$closed=!0}});n.setContent('<iframe src="'.concat(t.redirect_url,'" class="tingle-modal-box__iframe" />')),n.open()};var Dt,Ot,Bt,At,Ct=function(t){return t&&t.trim().length};window.$&&window.$.payment?(Dt=window.$.payment.validateCardNumber,Ot=window.$.payment.validateCardCVC,Bt=window.$.payment.validateCardExpiry,At=window.$.payment.cardExpiryVal):(Ot=Ct,Bt=function(t,e){return Ct(t)&&Ct(e)},At=function(t){var e=(t||"").split("/");return{month:(e[0]||"").trim(),year:(e[1]||"").trim()}});var Rt=At,_t=function(t,e,n){t[e]||(t[e]=[]),t[e].push(n)},kt=["number"];function Vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}function It(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}function Pt(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,i)}return n}function Nt(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?Pt(Object(n),!0).forEach((function(e){Lt(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pt(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function Lt(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var jt=function(t){var e=t.slice(0,6),n=t.slice(t.length-4),i="*".repeat(t.length-10);return"".concat(e).concat(i).concat(n)},Ft=function(){function t(e,n){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=e,this.token=null,this.config=n,this.onTokenGenerationFail=this.onTokenGenerationFail.bind(this),this.onCardTokenGenerationFail=this.onCardTokenGenerationFail.bind(this)}var e,n;return e=t,(n=[{key:"setup",value:function(t,e){var n=this;this.form=t,this.fields=e,this.baseErrorContainer=t.querySelector('[data-hook="checkout_payment_step"]')||t,e&&(e.nexioOwnForm=this),this.refreshToken().then((function(){t.addEventListener("submit",(function(i){n.withNewCardForm()&&0<e.clientHeight?(f(t),i.preventDefault(),n.addNewCardFlow()):n.config.threeDSecure&&n.isNexioCardSelected()&&(f(t),i.preventDefault(),n.submitFormToProcess())}))}))}},{key:"withNewCardForm",value:function(){return["default","newCard","addWalletCard"].includes(this.config.type)}},{key:"showError",value:function(t,e){var n="base"===t?this.baseErrorContainer:this.fields||this.baseErrorContainer;c(n,t,e,this.id)}},{key:"refreshToken",value:function(){var t=this;return this.withNewCardForm()&&null===this.token?s(this.config).then((function(e){return t.token=e.token,n=e.fraud_url,new Promise((function(t){var e=document.createElement("script");e.onload=t,e.src=n,document.body.appendChild(e)}));var n}),this.onTokenGenerationFail):new Promise((function(t){return t()}))}},{key:"addNewCardFlow",value:function(){var t,e=this,n=(t=this.fields,Object.entries(d).reduce((function(e,n){var i,r,o=(r=2,function(t){if(Array.isArray(t))return t}(i=n)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(i,r)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}(i,r)||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=o[0],a=o[1],h=t.querySelector('[data-hook="'.concat(a,'"]'));if(h)if(["INPUT","SELECT"].includes(h.nodeName))e[s]=h.value;else{var l=h.querySelector("input[name], select[name]");l&&(e[s]=l.value)}return e}),{}));Object.assign(n,Rt(n.expiry));var i=function(t){var e={};return["number","name","expiry","verification_value"].forEach((function(n){return Ct(t[n])?null:_t(e,n,"blank")})),Ct(t.number)&&!Dt(t.number)&&_t(e,"number","invalid"),Ct(t.verification_value)&&!Ot(t.verification_value,t.cc_type)&&_t(e,"verification_value","invalid"),Ct(t.expiry)&&!Bt(t.month,t.year)&&_t(e,"expiry","invalid"),e}(n);if(0<Object.keys(i).length)return this.onCardValidationFail(i);this.fields.setAttribute("disabled","disabled");var r,s,a=function(t,e,n){var i=e.number,r=function(t,e){if(null==t)return{};var n,i,r=function(t,e){if(null==t)return{};var n,i,r={},o=Object.keys(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||(r[n]=t[n]);return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(i=0;i<o.length;i++)n=o[i],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}(e,kt);i=i.replace(/\D+/g,"");var o=new bt;return o.setPublicKey(t.publicKey),Nt(Nt({},t.data),{},{one_time_token:n,card:Nt(Nt({},r),{},{encrypted_number:o.encrypt(i),number:jt(i)})})}(this.config,n,this.token);return this.token=null,(r=this.config,s=a,o(r.paths.creditCard,"POST",{body:{data:s}}).then((function(t){return 201===t.status?t.json.data:Promise.reject(t)}),(function(t){return Promise.reject(t)}))).then((function(t){if(p(e.fields,"card_gateway_payment_profile_id",t.token),e.fields.removeAttribute("disabled"),e.config.threeDSecure&&"addWalletCard"!==e.config.type)return e.submitFormToProcess();"addWalletCard"===e.config.type&&(p(e.fields,"number",a.card.number),p(e.fields,"verification_value","")),e.form.submit()}),this.onCardTokenGenerationFail).catch((function(){return e.resetFormOnError()}))}},{key:"submitFormToProcess",value:function(){var t=this,e=new FormData(this.form);e.delete("_method");var n={body:e};return function(t,e){return o(t,"POST",e).then((function(t){return 200===t.status?t.json:Promise.reject(t)}),(function(t){return Promise.reject(t)}))}(this.config.paths.payment,n).then((function(e){switch(e.state){case"success":return t.submitForm();case"three_d_secure":return t.onThreeDSecureRedirect(e.data);case"error":return t.resetFormOnError(e.data&&e.data.error||"fail_process_payment");default:t.resetFormOnError()}}),(function(){return t.resetFormOnError()}))}},{key:"isNexioCardSelected",value:function(){if(!this.config.threeDSecure)return!1;var t=this.config.walletCardIds;if(!Array.isArray(t))return!1;var e=new FormData(this.form).get("order[wallet_payment_source_id]");return e&&t.includes(parseInt(e))}},{key:"onThreeDSecureRedirect",value:function(t){var e=this;xt(t,(function(t){["invalid","failed"].includes(t)?e.resetFormOnError("fail_three_d_secure_check"):e.submitForm()}))}},{key:"submitForm",value:function(){this.form.querySelectorAll('fieldset#payment, fieldset[data-hook="payment"], [data-nexio-3ds-disable]').forEach((function(t){return t.setAttribute("disabled","disabled")}));var t=document.createElement("input");t.setAttribute("type","hidden"),t.setAttribute("name","order[nexio_placeholder]"),t.setAttribute("value","1"),this.form.appendChild(t),this.form.submit()}},{key:"unlockForm",value:function(){var t=this;return new Promise((function(e){setTimeout((function(){t.fields&&t.fields.removeAttribute("disabled");var n=t.form.querySelector(i.formEnableSelector);n&&(n.removeAttribute("disabled"),n.classList.remove("disabled"));var r=new Error("nexio_fail");e(r)}),100)}))}},{key:"resetFormOnError",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"default_error";return this.showError("base",e),this.refreshToken().then((function(){return t.unlockForm()}))}},{key:"onCardValidationFail",value:function(t){var e=this;return Object.entries(t).forEach((function(t){var n,i,r=(i=2,function(t){if(Array.isArray(t))return t}(n=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(n,i)||function(t,e){if(t){if("string"==typeof t)return Vt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Vt(t,e):void 0}}(n,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.")}()),o=r[0];return r[1].forEach((function(t){return e.showError(o,t)}))})),this.unlockForm()}},{key:"onTokenGenerationFail",value:function(){return this.showError("base","token_generation_failed"),Promise.reject()}},{key:"onCardTokenGenerationFail",value:function(){var t=this;return this.refreshToken().then((function(){return t.showError("base","fail_process_card"),Promise.reject()}))}}])&&It(e.prototype,n),t}();function Mt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}var qt=[],Ht=function(){qt.forEach((function(t){var e,n,i=(n=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var i,r,o=[],s=!0,a=!1;try{for(n=n.call(t);!(s=(i=n.next()).done)&&(o.push(i.value),!e||o.length!==e);s=!0);}catch(t){a=!0,r=t}finally{try{s||null==n.return||n.return()}finally{if(a)throw r}}return o}}(e,n)||function(t,e){if(t){if("string"==typeof t)return Mt(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Mt(t,e):void 0}}(e,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.")}()),r=i[0],o=i[1],s=document.querySelector(r);if(s){var a=s.closest("form");o.setup(a,s)}else console.warn("SolidusNexio: ".concat(r," is not found, the payment method ").concat(o.id," is not initialized."))})),qt.length=0};window.addNexioOwnForm=function(t,e){var n;n="walletCards"==e.type?'[data-nexio-wallet-cards="'.concat(t,'"]'):'[data-nexio-own-form-id="'.concat(t,'"]'),qt.push([n,new Ft(t,e)])},window.addNexioAPM=function(t,e){return qt.push(['[data-nexio-apm="'.concat(t,'"]'),new y(t,e)])},window.setupNexio=Ht,window.jQuery((function(){Ht()}))},584:function(t,e,n){var i,r;void 0===(r="function"==typeof(i=function(){var t=!1;function e(t){this.opts=function(){for(var t=1;t<arguments.length;t++)for(var e in arguments[t])arguments[t].hasOwnProperty(e)&&(arguments[0][e]=arguments[t][e]);return arguments[0]}({},{onClose:null,onOpen:null,beforeOpen:null,beforeClose:null,stickyFooter:!1,footer:!1,cssClass:[],closeLabel:"Close",closeMethods:["overlay","button","escape"]},t),this.init()}function n(){this.modalBoxFooter&&(this.modalBoxFooter.style.width=this.modalBox.clientWidth+"px",this.modalBoxFooter.style.left=this.modalBox.offsetLeft+"px")}return e.prototype.init=function(){if(!this.modal)return function(){this.modal=document.createElement("div"),this.modal.classList.add("tingle-modal"),0!==this.opts.closeMethods.length&&-1!==this.opts.closeMethods.indexOf("overlay")||this.modal.classList.add("tingle-modal--noOverlayClose"),this.modal.style.display="none",this.opts.cssClass.forEach((function(t){"string"==typeof t&&this.modal.classList.add(t)}),this),-1!==this.opts.closeMethods.indexOf("button")&&(this.modalCloseBtn=document.createElement("button"),this.modalCloseBtn.type="button",this.modalCloseBtn.classList.add("tingle-modal__close"),this.modalCloseBtnIcon=document.createElement("span"),this.modalCloseBtnIcon.classList.add("tingle-modal__closeIcon"),this.modalCloseBtnIcon.innerHTML='<svg viewBox="0 0 10 10" xmlns="http://www.w3.org/2000/svg"><path d="M.3 9.7c.2.2.4.3.7.3.3 0 .5-.1.7-.3L5 6.4l3.3 3.3c.2.2.5.3.7.3.2 0 .5-.1.7-.3.4-.4.4-1 0-1.4L6.4 5l3.3-3.3c.4-.4.4-1 0-1.4-.4-.4-1-.4-1.4 0L5 3.6 1.7.3C1.3-.1.7-.1.3.3c-.4.4-.4 1 0 1.4L3.6 5 .3 8.3c-.4.4-.4 1 0 1.4z" fill="#000" fill-rule="nonzero"/></svg>',this.modalCloseBtnLabel=document.createElement("span"),this.modalCloseBtnLabel.classList.add("tingle-modal__closeLabel"),this.modalCloseBtnLabel.innerHTML=this.opts.closeLabel,this.modalCloseBtn.appendChild(this.modalCloseBtnIcon),this.modalCloseBtn.appendChild(this.modalCloseBtnLabel)),this.modalBox=document.createElement("div"),this.modalBox.classList.add("tingle-modal-box"),this.modalBoxContent=document.createElement("div"),this.modalBoxContent.classList.add("tingle-modal-box__content"),this.modalBox.appendChild(this.modalBoxContent),-1!==this.opts.closeMethods.indexOf("button")&&this.modal.appendChild(this.modalCloseBtn),this.modal.appendChild(this.modalBox)}.call(this),function(){this._events={clickCloseBtn:this.close.bind(this),clickOverlay:function(t){var e=this.modal.offsetWidth-this.modal.clientWidth,n=t.clientX>=this.modal.offsetWidth-15,i=this.modal.scrollHeight!==this.modal.offsetHeight;"MacIntel"===navigator.platform&&0==e&&n&&i||-1!==this.opts.closeMethods.indexOf("overlay")&&!function(t,e){for(;(t=t.parentElement)&&!t.classList.contains("tingle-modal"););return t}(t.target)&&t.clientX<this.modal.clientWidth&&this.close()}.bind(this),resize:this.checkOverflow.bind(this),keyboardNav:function(t){-1!==this.opts.closeMethods.indexOf("escape")&&27===t.which&&this.isOpen()&&this.close()}.bind(this)},-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.addEventListener("click",this._events.clickCloseBtn),this.modal.addEventListener("mousedown",this._events.clickOverlay),window.addEventListener("resize",this._events.resize),document.addEventListener("keydown",this._events.keyboardNav)}.call(this),document.body.appendChild(this.modal,document.body.firstChild),this.opts.footer&&this.addFooter(),this},e.prototype._busy=function(e){t=e},e.prototype._isBusy=function(){return t},e.prototype.destroy=function(){null!==this.modal&&(this.isOpen()&&this.close(!0),function(){-1!==this.opts.closeMethods.indexOf("button")&&this.modalCloseBtn.removeEventListener("click",this._events.clickCloseBtn),this.modal.removeEventListener("mousedown",this._events.clickOverlay),window.removeEventListener("resize",this._events.resize),document.removeEventListener("keydown",this._events.keyboardNav)}.call(this),this.modal.parentNode.removeChild(this.modal),this.modal=null)},e.prototype.isOpen=function(){return!!this.modal.classList.contains("tingle-modal--visible")},e.prototype.open=function(){if(!this._isBusy()){this._busy(!0);var t=this;return"function"==typeof t.opts.beforeOpen&&t.opts.beforeOpen(),this.modal.style.removeProperty?this.modal.style.removeProperty("display"):this.modal.style.removeAttribute("display"),document.getSelection().removeAllRanges(),this._scrollPosition=window.pageYOffset,document.body.classList.add("tingle-enabled"),document.body.style.top=-this._scrollPosition+"px",this.setStickyFooter(this.opts.stickyFooter),this.modal.classList.add("tingle-modal--visible"),"function"==typeof t.opts.onOpen&&t.opts.onOpen.call(t),t._busy(!1),this.checkOverflow(),this}},e.prototype.close=function(t){if(!this._isBusy()){if(this._busy(!0),"function"==typeof this.opts.beforeClose&&!this.opts.beforeClose.call(this))return void this._busy(!1);document.body.classList.remove("tingle-enabled"),document.body.style.top=null,window.scrollTo({top:this._scrollPosition,behavior:"instant"}),this.modal.classList.remove("tingle-modal--visible");var e=this;e.modal.style.display="none","function"==typeof e.opts.onClose&&e.opts.onClose.call(this),e._busy(!1)}},e.prototype.setContent=function(t){return"string"==typeof t?this.modalBoxContent.innerHTML=t:(this.modalBoxContent.innerHTML="",this.modalBoxContent.appendChild(t)),this.isOpen()&&this.checkOverflow(),this},e.prototype.getContent=function(){return this.modalBoxContent},e.prototype.addFooter=function(){return function(){this.modalBoxFooter=document.createElement("div"),this.modalBoxFooter.classList.add("tingle-modal-box__footer"),this.modalBox.appendChild(this.modalBoxFooter)}.call(this),this},e.prototype.setFooterContent=function(t){return this.modalBoxFooter.innerHTML=t,this},e.prototype.getFooterContent=function(){return this.modalBoxFooter},e.prototype.setStickyFooter=function(t){return this.isOverflow()||(t=!1),t?this.modalBox.contains(this.modalBoxFooter)&&(this.modalBox.removeChild(this.modalBoxFooter),this.modal.appendChild(this.modalBoxFooter),this.modalBoxFooter.classList.add("tingle-modal-box__footer--sticky"),n.call(this),this.modalBoxContent.style["padding-bottom"]=this.modalBoxFooter.clientHeight+20+"px"):this.modalBoxFooter&&(this.modalBox.contains(this.modalBoxFooter)||(this.modal.removeChild(this.modalBoxFooter),this.modalBox.appendChild(this.modalBoxFooter),this.modalBoxFooter.style.width="auto",this.modalBoxFooter.style.left="",this.modalBoxContent.style["padding-bottom"]="",this.modalBoxFooter.classList.remove("tingle-modal-box__footer--sticky"))),this},e.prototype.addFooterBtn=function(t,e,n){var i=document.createElement("button");return i.innerHTML=t,i.addEventListener("click",n),"string"==typeof e&&e.length&&e.split(" ").forEach((function(t){i.classList.add(t)})),this.modalBoxFooter.appendChild(i),i},e.prototype.resize=function(){console.warn("Resize is deprecated and will be removed in version 1.0")},e.prototype.isOverflow=function(){return window.innerHeight<=this.modalBox.clientHeight},e.prototype.checkOverflow=function(){this.modal.classList.contains("tingle-modal--visible")&&(this.isOverflow()?this.modal.classList.add("tingle-modal--overflow"):this.modal.classList.remove("tingle-modal--overflow"),!this.isOverflow()&&this.opts.stickyFooter?this.setStickyFooter(!1):this.isOverflow()&&this.opts.stickyFooter&&(n.call(this),this.setStickyFooter(!0)))},{modal:e}})?i.call(e,n,e,t):i)||(t.exports=r)}},e={};function n(i){var r=e[i];if(void 0!==r)return r.exports;var o=e[i]={exports:{}};return t[i].call(o.exports,o,o.exports,n),o.exports}n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n(498)})();
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusNexio
4
+ class AlternativePaymentsController < Spree::StoreController
5
+ def capture
6
+ render text: 'ok'
7
+ end
8
+ end
9
+ end
@@ -9,7 +9,7 @@ module SolidusNexio
9
9
  private
10
10
 
11
11
  def payment_method
12
- @payment_method ||= PaymentMethod.find(params[:payment_method_id])
12
+ @payment_method ||= ::Spree::PaymentMethod.active.available_to_users.find(params[:payment_method_id])
13
13
  end
14
14
  end
15
15
  end
@@ -4,7 +4,6 @@ module SolidusNexio
4
4
  class CreditCardsController < BasePaymentController
5
5
  def create
6
6
  token = payment_method.store(credit_card_params)
7
-
8
7
  if token
9
8
  render json: { data: { token: token } }, status: 201
10
9
  else
@@ -14,11 +14,17 @@ module SolidusNexio
14
14
  private
15
15
 
16
16
  def one_time_token_params
17
- params.require(:data).permit(:currency,
18
- address: %i[address1 address2 city country phone zip state],
19
- billing_address: %i[address1 address2 city country phone zip state],
20
- customer: %i[first_name last_name email],
21
- order: %i[number date]).to_h.deep_symbolize_keys
17
+ result = params.require(:data).permit(:currency,
18
+ address: %i[address1 address2 city country phone zip state],
19
+ billing_address: %i[address1 address2 city country phone zip state],
20
+ customer: %i[first_name last_name email],
21
+ order: %i[number date]).to_h.deep_symbolize_keys
22
+
23
+ if payment_method.is_a?(AlternativePaymentMethod)
24
+ callback_url = capture_payment_method_alternative_payment_url(payment_method, result.dig(:order, :number))
25
+ result[:callback_url] = callback_url
26
+ end
27
+ result
22
28
  end
23
29
  end
24
30
  end
@@ -1,14 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusNexio
2
4
  class PaymentStatesController < Spree::StoreController
3
5
  def show
4
- payment_method = PaymentMethod.find(params[:payment_method_id])
5
- payment = payment_method.payments.find(params[:payment_id])
6
+ payment = payments_scope.find(params[:payment_id])
6
7
  render json: { data: { state: payment.state } }
7
8
  end
8
9
 
9
10
  def capture
10
- payment_method = PaymentMethod.find(params[:payment_method_id])
11
- payment = payment_method.payments.find_by(number: params[:payment_id])
11
+ payment = payments_scope.find_by(number: params[:payment_id])
12
12
  if payment
13
13
  @result = payment_method.capture_order_payment(payment, params[:id], params[:status])
14
14
  render :capture, layout: false
@@ -16,5 +16,15 @@ module SolidusNexio
16
16
  head 404
17
17
  end
18
18
  end
19
+
20
+ private
21
+
22
+ def payments_scope
23
+ current_order.payments.merge(payment_method.payments)
24
+ end
25
+
26
+ def payment_method
27
+ @payment_method ||= PaymentMethod.active.available_to_users.find(params[:payment_method_id])
28
+ end
19
29
  end
20
30
  end
@@ -1,14 +1,16 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusNexio
2
4
  class PaymentsController < Spree::CheckoutController
3
5
  def create
4
6
  if update_order
5
- payment_method = PaymentMethod.find(params[:payment_method_id])
6
- result = payment_method.process_order_payment(@order) do |payment|
7
+ payment_method = PaymentMethod.active.available_to_users.find(params[:payment_method_id])
8
+ result = payment_method.process_order_payment(current_order) do |payment|
7
9
  capture_payment_method_payment_state_url(payment_method, payment.number)
8
10
  end
9
11
  render json: result
10
12
  else
11
- render json: { error: :invalid_order, details: @order.errors.to_h }, status: 422
13
+ render json: { error: :invalid_order, details: current_order.errors.to_h }, status: 422
12
14
  end
13
15
  end
14
16
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusNexio
2
4
  class WebhooksController < ActionController::API
3
5
  before_action :authorize_request
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusNexio
4
+ module PaymentDecorator
5
+ attr_accessor :nexio_apm_transaction_id
6
+
7
+ def nexio_apm?
8
+ source.is_a?(::SolidusNexio::ApmSource)
9
+ end
10
+
11
+ def authorize!
12
+ fetch_nexio_amp_transaction or super
13
+ end
14
+
15
+ def purchase!
16
+ fetch_nexio_amp_transaction or super
17
+ end
18
+
19
+ private
20
+
21
+ def save_nexio_amp_id
22
+ self.response_code = nexio_apm_transaction_id if nexio_apm_transaction_id.present?
23
+ end
24
+
25
+ def fetch_nexio_amp_transaction
26
+ return unless response_code.present? && nexio_apm?
27
+
28
+ transaction = payment_method.gateway.get_transaction(response_code)
29
+ if transaction
30
+ self.amount = transaction.amount
31
+ self.state = SolidusNexio::Mappings.payment_state(transaction.status)
32
+ save!
33
+ return true if completed? || pending?
34
+ else
35
+ invalidate!
36
+ end
37
+
38
+ raise Core::GatewayError, I18n.t('spree.payment_processing_failed')
39
+ end
40
+
41
+ Spree::Payment.include self
42
+ # source set after other attribute assignments
43
+ Spree::Payment.before_validation :save_nexio_amp_id, on: :create, if: :nexio_apm?
44
+ end
45
+ end
@@ -26,14 +26,26 @@ module SolidusNexio
26
26
  javascript_tag("window.addNexioOwnForm(#{payment_method.id}, #{config.to_json});")
27
27
  end
28
28
 
29
+ def setup_nexio_apm(payment_method, order, user: nil)
30
+ setup_nexio_checkout
31
+
32
+ config = {
33
+ data: NexioData.one_time_token(user: user, order: order),
34
+ paths: {
35
+ oneTimeToken: solidus_nexio.payment_method_one_time_tokens_path(payment_method)
36
+ }
37
+ }
38
+ javascript_tag("window.addNexioAPM(#{payment_method.id}, #{config.to_json});")
39
+ end
40
+
29
41
  def setup_nexio_checkout
30
42
  # include js script only once per request
31
43
  return if @__nexio_checkout_script
32
44
 
33
- content_for(:head) {
45
+ content_for(:head) do
34
46
  javascript_tag("window.nexioErrorMessages = #{I18n.t('nexio.errors').to_json};") +
35
- javascript_include_tag('solidus_nexio/checkout.js')
36
- }
47
+ javascript_include_tag('solidus_nexio/checkout.js')
48
+ end
37
49
  @__nexio_checkout_script = true
38
50
 
39
51
  nil
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusNexio
4
+ class AlternativePaymentMethod < SolidusSupport.payment_method_parent_class
5
+ include NexioPaymentCommons
6
+
7
+ preference(:server, :string, default: 'test')
8
+ preference(:merchant_id, :string, default: nil)
9
+ preference(:auth_token, :string, default: nil)
10
+ preference(:payment_method, :string, default: nil)
11
+ preference(:save_token, :boolean, default: false)
12
+
13
+ def partial_name
14
+ 'nexio_apm'
15
+ end
16
+ alias method_type partial_name
17
+
18
+ def generate_token(options)
19
+ order = Spree::Order.find_by(number: options.dig(:order, :number))
20
+ return unless order
21
+
22
+ amount = order.respond_to?(:order_total_after_store_credit) ? order.order_total_after_store_credit : order.total
23
+ params = {
24
+ payment_method: preferred_payment_method,
25
+ save_token: preferred_save_token,
26
+ is_auth_only: !auto_capture?
27
+ }.merge!(options)
28
+ gateway.generate_token(amount.to_money.cents, params)
29
+ end
30
+
31
+ def payment_source_class
32
+ ApmSource
33
+ end
34
+
35
+ private
36
+
37
+ def gateway_class
38
+ ActiveMerchant::Billing::NexioApmGateway
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusNexio
4
+ class ApmSource < SolidusSupport.payment_source_parent_class
5
+ self.table_name = 'solidus_nexio_apm_sources'
6
+
7
+ belongs_to :user, class_name: Spree::UserClassHandle.new, foreign_key: 'user_id', optional: true
8
+
9
+ enum kind: { braintreePayPal: 0 }
10
+
11
+ def reusable?
12
+ gateway_payment_profile_id.present?
13
+ end
14
+
15
+ def name
16
+ I18n.t("nexio.apms.#{kind.underscore}.name")
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusNexio
4
+ module NexioPaymentCommons
5
+ def purchase(money, payment, options = {})
6
+ super(money, payment, add_transaction_options(options))
7
+ end
8
+
9
+ def authorize(money, payment, options = {})
10
+ super(money, payment, add_transaction_options(options))
11
+ end
12
+
13
+ def cancel(id)
14
+ transaction = gateway.get_transaction(id)
15
+ return unless transaction
16
+
17
+ if Mappings.settled?(transaction.status)
18
+ credit(transaction.amount.to_money.cents, id)
19
+ else
20
+ void(id)
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def add_transaction_options(options)
27
+ result = %i[currency billing_address].each_with_object({}) do |key, acc|
28
+ acc[key] = options[key] if options[key].present?
29
+ end
30
+ result[:address] = options[:shipping_address] if options[:shipping_address].present?
31
+ if options[:originator].respond_to?(:order)
32
+ result.merge!(SolidusNexio::NexioData.purchase(options[:originator].order))
33
+ end
34
+ result
35
+ end
36
+ end
37
+ end
@@ -2,9 +2,10 @@
2
2
 
3
3
  module SolidusNexio
4
4
  class PaymentMethod < SolidusSupport.payment_method_parent_class(credit_card: true)
5
+ include NexioPaymentCommons
6
+
5
7
  ProcessResult = Struct.new(:state, :data)
6
8
 
7
- # Preferences for configuration of Braintree credentials
8
9
  preference(:server, :string, default: 'test')
9
10
  preference(:merchant_id, :string, default: nil)
10
11
  preference(:auth_token, :string, default: nil)
@@ -23,16 +24,16 @@ module SolidusNexio
23
24
  begin
24
25
  payment.process!
25
26
  ProcessResult.new(:success, nil)
26
- rescue Spree::Core::GatewayError => error
27
+ rescue Spree::Core::GatewayError
27
28
  redirect_url = nexio_three_d_secure_redirect_url(payment)
28
29
  return ProcessResult.new(:error, error: :fail_process_payment) unless redirect_url
29
30
 
30
31
  payment.state = :checkout
31
32
  payment.save!
32
33
  ProcessResult.new(:three_d_secure, {
33
- redirect_url: redirect_url,
34
- check_path: Engine.routes.url_helpers.payment_method_payment_state_path(self, payment)
35
- })
34
+ redirect_url: redirect_url,
35
+ check_path: Engine.routes.url_helpers.payment_method_payment_state_path(self, payment)
36
+ })
36
37
  ensure
37
38
  payment.remove_instance_variable(:@nexio_callback_url)
38
39
  end
@@ -60,14 +61,6 @@ module SolidusNexio
60
61
  gateway.generate_token(options)
61
62
  end
62
63
 
63
- def purchase(money, payment, options = {})
64
- super(money, payment, add_transaction_options(options))
65
- end
66
-
67
- def authorize(money, payment, options = {})
68
- super(money, payment, add_transaction_options(options))
69
- end
70
-
71
64
  def store(options)
72
65
  card_attrs = options[:card]
73
66
  .slice(:encrypted_number, :number, :name, :month, :year)
@@ -82,31 +75,16 @@ module SolidusNexio
82
75
  gateway.store(card, options.except(:card, :one_time_token))
83
76
  end
84
77
 
85
- def cancel(id)
86
- transaction = gateway.get_transaction(id)
87
- return unless transaction
88
-
89
- if transaction['transactionStatus'] == 20
90
- credit(transaction['amount'].to_money.cents, id)
91
- else
92
- void(id)
93
- end
94
- end
95
-
96
- protected
78
+ private
97
79
 
98
80
  def gateway_class
99
81
  ActiveMerchant::Billing::NexioGateway
100
82
  end
101
83
 
102
84
  def add_transaction_options(options)
103
- result = %i(currency billing_address).each_with_object({}) do |key, acc|
104
- acc[key] = options[key] if options[key].present?
105
- end
106
- result[:address] = options[:shipping_address] if options[:shipping_address].present?
107
- if options[:originator].is_a?(::Spree::Payment) && options[:originator].order
85
+ result = super
86
+ if options[:originator].is_a?(::Spree::Payment)
108
87
  payment = options[:originator]
109
- result.merge!(SolidusNexio::NexioData.purchase(payment.order))
110
88
  # called from customer checkout page
111
89
  if payment.instance_variable_get(:@nexio_callback_url)
112
90
  result[:three_d_callback_url] = payment.instance_variable_get(:@nexio_callback_url)
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SolidusNexio
2
4
  class Webhook < ApplicationRecord
3
- def self.process(event_type, data)
4
- end
5
+ def self.process(event_type, data); end
5
6
  end
6
7
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusNexio
4
+ module Mappings
5
+ extend self
6
+
7
+ TRANSACTION_STATUS_TO_STATE = {
8
+ 3 => 'pending',
9
+ 9 => 'completed',
10
+ 10 => 'completed',
11
+ 11 => 'pending',
12
+ 20 => 'completed',
13
+ 30 => 'failed',
14
+ 32 => 'failed',
15
+ 39 => 'void',
16
+ 40 => 'void'
17
+ }.freeze
18
+
19
+ def payment_state(status)
20
+ TRANSACTION_STATUS_TO_STATE.fetch(status, 'invalid')
21
+ end
22
+
23
+ def settled?(status)
24
+ status == 20
25
+ end
26
+ end
27
+ end
@@ -1,8 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- attrs = [:id, :month, :year, :cc_type, :last_digits, :name]
4
- if @current_user_roles.include?("admin")
5
- attrs += [:gateway_customer_profile_id, :gateway_payment_profile_id]
6
- end
3
+ attrs = %i[id month year cc_type last_digits name]
4
+ attrs += %i[gateway_customer_profile_id gateway_payment_profile_id] if @current_user_roles.include?('admin')
7
5
 
8
- json.(payment_source, *attrs)
6
+ json.call(payment_source, *attrs)
@@ -0,0 +1,9 @@
1
+ <tr id="<%= dom_id(wallet_payment_source, 'spree')%>" class="<%= cycle('even', 'odd') %>">
2
+ <td><%= wallet_payment_source.payment_source.name %></td>
3
+ <td></td>
4
+ <td></td>
5
+ <td></td>
6
+ <td>
7
+ <%= radio_button_tag "order[wallet_payment_source_id]", wallet_payment_source.id, default, class: "existing-cc-radio" %>
8
+ </td>
9
+ </tr>
@@ -0,0 +1,5 @@
1
+ <fieldset data-nexio-apm="<%= payment_method.id %>" data-hook="nexio_apm">
2
+ <input name="order[payments_attributes][][nexio_apm_transaction_id]" type="hidden" data-hook="nexio_apm_transaction_id" />
3
+ <input name="payment_source[<%= payment_method.id %>][gateway_payment_profile_id]" type="hidden" data-hook="gateway_payment_profile_id" />
4
+ </fieldset>
5
+ <%= setup_nexio_apm(payment_method, current_order, user: current_spree_user) %>
@@ -2,7 +2,11 @@ en:
2
2
  activerecord:
3
3
  models:
4
4
  solidus_nexio/payment_method: Nexio
5
+ solidus_nexio/alternative_payment_method: Nexio APM
5
6
  nexio:
7
+ apms:
8
+ braintree_pay_pal:
9
+ name: PayPal
6
10
  errors:
7
11
  default_error: Something went wrong
8
12
  base:
data/config/routes.rb CHANGED
@@ -9,6 +9,9 @@ SolidusNexio::Engine.routes.draw do
9
9
  get :capture
10
10
  end
11
11
  end
12
+ resources :alternative_payments, only: [] do
13
+ get :state, :capture, on: :member
14
+ end
12
15
  end
13
16
  resources :webhooks, only: :create
14
17
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class CreateSolidusNexioSolidusNexioWebhooks < ActiveRecord::Migration[6.1]
2
4
  def change
3
5
  create_table :solidus_nexio_solidus_nexio_webhooks do |t|
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddSolidusNexioApmSource < ActiveRecord::Migration[6.1]
4
+ def change
5
+ create_table :solidus_nexio_apm_sources do |t|
6
+ t.integer :kind, default: 0, null: false
7
+ t.string :gateway_payment_profile_id
8
+
9
+ t.references :user, index: true
10
+ t.references :payment_method, index: true
11
+ end
12
+
13
+ add_foreign_key :solidus_nexio_apm_sources, :spree_payment_methods, column: :payment_method_id
14
+ end
15
+ end
@@ -23,6 +23,8 @@ 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
+ app.config.spree.payment_methods << SolidusNexio::AlternativePaymentMethod
27
+ ::Spree::PermittedAttributes.checkout_payment_attributes[0][:payments_attributes].push(:nexio_apm_transaction_id)
26
28
  SolidusNexio::Engine.routes.default_url_options = app.routes.default_url_options
27
29
  end
28
30
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusNexio
4
- VERSION = '0.4.5'
4
+ VERSION = '0.5.0'
5
5
  end
@@ -29,9 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
+ spec.add_dependency 'nexio_activemerchant', '>= 0.2.5'
32
33
  spec.add_dependency 'rails'
33
34
  spec.add_dependency 'solidus_api', '>= 2.0'
34
35
  spec.add_dependency 'solidus_core', '>= 2.0'
35
36
  spec.add_dependency 'solidus_support', '~> 0.6'
36
- spec.add_dependency 'nexio_activemerchant', '>= 0.2.5'
37
37
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_nexio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.5.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-10-19 00:00:00.000000000 Z
11
+ date: 2021-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nexio_activemerchant
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.5
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.2.5
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: rails
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,20 +80,6 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0.6'
69
- - !ruby/object:Gem::Dependency
70
- name: nexio_activemerchant
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: 0.2.5
76
- type: :runtime
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: 0.2.5
83
83
  description:
84
84
  email:
85
85
  - hello@whitespectre.com
@@ -94,26 +94,37 @@ files:
94
94
  - Rakefile
95
95
  - app/assets/javascripts/solidus_nexio/checkout.js
96
96
  - app/assets/javascripts/solidus_nexio/checkout.js.LICENSE.txt
97
+ - app/controllers/solidus_nexio/alternative_payments_controller.rb
97
98
  - app/controllers/solidus_nexio/base_payment_controller.rb
98
99
  - app/controllers/solidus_nexio/credit_cards_controller.rb
99
100
  - app/controllers/solidus_nexio/one_time_tokens_controller.rb
100
101
  - app/controllers/solidus_nexio/payment_states_controller.rb
101
102
  - app/controllers/solidus_nexio/payments_controller.rb
102
103
  - app/controllers/solidus_nexio/webhooks_controller.rb
104
+ - app/decorators/models/solidus_nexio/payment_decorator.rb
103
105
  - app/helpers/solidus_nexio/checkout_helper.rb
106
+ - app/models/solidus_nexio/alternative_payment_method.rb
107
+ - app/models/solidus_nexio/apm_source.rb
108
+ - app/models/solidus_nexio/nexio_payment_commons.rb
104
109
  - app/models/solidus_nexio/payment_method.rb
105
110
  - app/models/solidus_nexio/webhook.rb
111
+ - app/services/solidus_nexio/mappings.rb
106
112
  - app/services/solidus_nexio/nexio_data.rb
107
113
  - app/views/solidus_nexio/payment_states/capture.html.erb
114
+ - app/views/spree/admin/payments/source_forms/_nexio_apm.html.erb
108
115
  - app/views/spree/admin/payments/source_forms/_nexio_own_form.html.erb
116
+ - app/views/spree/admin/payments/source_views/_nexio_apm.html.erb
109
117
  - app/views/spree/admin/payments/source_views/_nexio_own_form.html.erb
110
118
  - app/views/spree/api/payments/source_views/_nexio_own_form.json.jbuilder
111
119
  - app/views/spree/api/source_views/_nexio_own_form.json.jbuilder
120
+ - app/views/spree/checkout/existing_payment/_nexio_apm.html.erb
112
121
  - app/views/spree/checkout/existing_payment/_nexio_own_form.html.erb
122
+ - app/views/spree/checkout/payment/_nexio_apm.html.erb
113
123
  - app/views/spree/checkout/payment/_nexio_own_form.html.erb
114
124
  - config/locales/en.yml
115
125
  - config/routes.rb
116
126
  - db/migrate/20210723155452_create_solidus_nexio_solidus_nexio_webhooks.rb
127
+ - db/migrate/20211109171335_add_solidus_nexio_apm_source.rb
117
128
  - lib/solidus_nexio.rb
118
129
  - lib/solidus_nexio/engine.rb
119
130
  - lib/solidus_nexio/version.rb