zkfold-smart-wallet-api
Version:
Smart Wallet API - Browser and extension compatible
2 lines • 359 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@emurgo/cardano-serialization-lib-browser")):"function"==typeof define&&define.amd?define(["exports","@emurgo/cardano-serialization-lib-browser"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ZkFoldSmartWalletApi={},e.CardanoWasm)}(this,function(e,t){"use strict";function r(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e)for(const r in e)if("default"!==r){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}return t.default=e,Object.freeze(t)}const n=r(t);function i(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function a(e){if(Object.prototype.hasOwnProperty.call(e,"__esModule"))return e;var t=e.default;if("function"==typeof t){var r=function e(){var r=!1;try{r=this instanceof e}catch{}return r?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}),r}var s,o,c,u,l,f={exports:{}},p={exports:{}},h={exports:{}},d=h.exports;function g(){return s||(s=1,e=h,function(t){var r,n=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,i=Math.ceil,a=Math.floor,s="[BigNumber Error] ",o=s+"Number primitive has more than 15 significant digits: ",c=1e14,u=14,l=9007199254740991,f=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],p=1e7,h=1e9;function d(e){var t=0|e;return e>0||e===t?t:t-1}function g(e){for(var t,r,n=1,i=e.length,a=e[0]+"";n<i;){for(t=e[n++]+"",r=u-t.length;r--;t="0"+t);a+=t}for(i=a.length;48===a.charCodeAt(--i););return a.slice(0,i+1||1)}function y(e,t){var r,n,i=e.c,a=t.c,s=e.s,o=t.s,c=e.e,u=t.e;if(!s||!o)return null;if(r=i&&!i[0],n=a&&!a[0],r||n)return r?n?0:-o:s;if(s!=o)return s;if(r=s<0,n=c==u,!i||!a)return n?0:!i^r?1:-1;if(!n)return c>u^r?1:-1;for(o=(c=i.length)<(u=a.length)?c:u,s=0;s<o;s++)if(i[s]!=a[s])return i[s]>a[s]^r?1:-1;return c==u?0:c>u^r?1:-1}function m(e,t,r,n){if(e<t||e>r||e!==a(e))throw Error(s+(n||"Argument")+("number"==typeof e?e<t||e>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function v(e){var t=e.c.length-1;return d(e.e/u)==t&&e.c[t]%2!=0}function C(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function E(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else t<n&&(e=e.slice(0,t)+"."+e.slice(t));return e}r=function e(t){var r,S,T,b,A,I=K.prototype={constructor:K,toString:null,valueOf:null},B=new K(1),w=20,N=4,_=-7,R=21,k=-1e7,L=1e7,U=!1,D=1,O=0,P={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},x="0123456789abcdefghijklmnopqrstuvwxyz",V=!0;function K(e,t){var r,i,s,c,f,p,h,d,g=this;if(!(g instanceof K))return new K(e,t);if(null==t){if(e&&!0===e._isBigNumber)return g.s=e.s,void(!e.c||e.e>L?g.c=g.e=null:e.e<k?g.c=[g.e=0]:(g.e=e.e,g.c=e.c.slice()));if((p="number"==typeof e)&&0*e==0){if(g.s=1/e<0?(e=-e,-1):1,e===~~e){for(c=0,f=e;f>=10;f/=10,c++);return void(c>L?g.c=g.e=null:(g.e=c,g.c=[e]))}d=String(e)}else{if(!n.test(d=String(e)))return T(g,d,p);g.s=45==d.charCodeAt(0)?(d=d.slice(1),-1):1}(c=d.indexOf("."))>-1&&(d=d.replace(".","")),(f=d.search(/e/i))>0?(c<0&&(c=f),c+=+d.slice(f+1),d=d.substring(0,f)):c<0&&(c=d.length)}else{if(m(t,2,x.length,"Base"),10==t&&V)return q(g=new K(e),w+g.e+1,N);if(d=String(e),p="number"==typeof e){if(0*e!=0)return T(g,d,p,t);if(g.s=1/e<0?(d=d.slice(1),-1):1,K.DEBUG&&d.replace(/^0\.0*|\./,"").length>15)throw Error(o+e)}else g.s=45===d.charCodeAt(0)?(d=d.slice(1),-1):1;for(r=x.slice(0,t),c=f=0,h=d.length;f<h;f++)if(r.indexOf(i=d.charAt(f))<0){if("."==i){if(f>c){c=h;continue}}else if(!s&&(d==d.toUpperCase()&&(d=d.toLowerCase())||d==d.toLowerCase()&&(d=d.toUpperCase()))){s=!0,f=-1,c=0;continue}return T(g,String(e),p,t)}p=!1,(c=(d=S(d,t,10,g.s)).indexOf("."))>-1?d=d.replace(".",""):c=d.length}for(f=0;48===d.charCodeAt(f);f++);for(h=d.length;48===d.charCodeAt(--h););if(d=d.slice(f,++h)){if(h-=f,p&&K.DEBUG&&h>15&&(e>l||e!==a(e)))throw Error(o+g.s*e);if((c=c-f-1)>L)g.c=g.e=null;else if(c<k)g.c=[g.e=0];else{if(g.e=c,g.c=[],f=(c+1)%u,c<0&&(f+=u),f<h){for(f&&g.c.push(+d.slice(0,f)),h-=u;f<h;)g.c.push(+d.slice(f,f+=u));f=u-(d=d.slice(f)).length}else f-=h;for(;f--;d+="0");g.c.push(+d)}}else g.c=[g.e=0]}function M(e,t,r,n){var i,a,s,o,c;if(null==r?r=N:m(r,0,8),!e.c)return e.toString();if(i=e.c[0],s=e.e,null==t)c=g(e.c),c=1==n||2==n&&(s<=_||s>=R)?C(c,s):E(c,s,"0");else if(a=(e=q(new K(e),t,r)).e,o=(c=g(e.c)).length,1==n||2==n&&(t<=a||a<=_)){for(;o<t;c+="0",o++);c=C(c,a)}else if(t-=s+(2===n&&a>s),c=E(c,a,"0"),a+1>o){if(--t>0)for(c+=".";t--;c+="0");}else if((t+=a-o)>0)for(a+1==o&&(c+=".");t--;c+="0");return e.s<0&&i?"-"+c:c}function F(e,t){for(var r,n,i=1,a=new K(e[0]);i<e.length;i++)(!(n=new K(e[i])).s||(r=y(a,n))===t||0===r&&a.s===t)&&(a=n);return a}function j(e,t,r){for(var n=1,i=t.length;!t[--i];t.pop());for(i=t[0];i>=10;i/=10,n++);return(r=n+r*u-1)>L?e.c=e.e=null:r<k?e.c=[e.e=0]:(e.e=r,e.c=t),e}function q(e,t,r,n){var s,o,l,p,h,d,g,y=e.c,m=f;if(y){e:{for(s=1,p=y[0];p>=10;p/=10,s++);if((o=t-s)<0)o+=u,l=t,h=y[d=0],g=a(h/m[s-l-1]%10);else if((d=i((o+1)/u))>=y.length){if(!n)break e;for(;y.length<=d;y.push(0));h=g=0,s=1,l=(o%=u)-u+1}else{for(h=p=y[d],s=1;p>=10;p/=10,s++);g=(l=(o%=u)-u+s)<0?0:a(h/m[s-l-1]%10)}if(n=n||t<0||null!=y[d+1]||(l<0?h:h%m[s-l-1]),n=r<4?(g||n)&&(0==r||r==(e.s<0?3:2)):g>5||5==g&&(4==r||n||6==r&&(o>0?l>0?h/m[s-l]:0:y[d-1])%10&1||r==(e.s<0?8:7)),t<1||!y[0])return y.length=0,n?(t-=e.e+1,y[0]=m[(u-t%u)%u],e.e=-t||0):y[0]=e.e=0,e;if(0==o?(y.length=d,p=1,d--):(y.length=d+1,p=m[u-o],y[d]=l>0?a(h/m[s-l]%m[l])*p:0),n)for(;;){if(0==d){for(o=1,l=y[0];l>=10;l/=10,o++);for(l=y[0]+=p,p=1;l>=10;l/=10,p++);o!=p&&(e.e++,y[0]==c&&(y[0]=1));break}if(y[d]+=p,y[d]!=c)break;y[d--]=0,p=1}for(o=y.length;0===y[--o];y.pop());}e.e>L?e.c=e.e=null:e.e<k&&(e.c=[e.e=0])}return e}function H(e){var t,r=e.e;return null===r?e.toString():(t=g(e.c),t=r<=_||r>=R?C(t,r):E(t,r,"0"),e.s<0?"-"+t:t)}return K.clone=e,K.ROUND_UP=0,K.ROUND_DOWN=1,K.ROUND_CEIL=2,K.ROUND_FLOOR=3,K.ROUND_HALF_UP=4,K.ROUND_HALF_DOWN=5,K.ROUND_HALF_EVEN=6,K.ROUND_HALF_CEIL=7,K.ROUND_HALF_FLOOR=8,K.EUCLID=9,K.config=K.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(s+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(r=e[t],0,h,t),w=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(r=e[t],0,8,t),N=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(m(r[0],-h,0,t),m(r[1],0,h,t),_=r[0],R=r[1]):(m(r,-h,h,t),_=-(R=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)m(r[0],-h,-1,t),m(r[1],1,h,t),k=r[0],L=r[1];else{if(m(r,-h,h,t),!r)throw Error(s+t+" cannot be zero: "+r);k=-(L=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(s+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw U=!r,Error(s+"crypto unavailable");U=r}else U=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(r=e[t],0,9,t),D=r),e.hasOwnProperty(t="POW_PRECISION")&&(m(r=e[t],0,h,t),O=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(s+t+" not an object: "+r);P=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(s+t+" invalid: "+r);V="0123456789"==r.slice(0,10),x=r}}return{DECIMAL_PLACES:w,ROUNDING_MODE:N,EXPONENTIAL_AT:[_,R],RANGE:[k,L],CRYPTO:U,MODULO_MODE:D,POW_PRECISION:O,FORMAT:P,ALPHABET:x}},K.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!K.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-h&&i<=h&&i===a(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%u)<1&&(t+=u),String(n[0]).length==t){for(t=0;t<n.length;t++)if((r=n[t])<0||r>=c||r!==a(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(s+"Invalid BigNumber: "+e)},K.maximum=K.max=function(){return F(arguments,-1)},K.minimum=K.min=function(){return F(arguments,1)},K.random=(b=9007199254740992,A=Math.random()*b&2097151?function(){return a(Math.random()*b)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,o,c,l=0,p=[],d=new K(B);if(null==e?e=w:m(e,0,h),o=i(e/u),U)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(o*=2));l<o;)(c=131072*t[l]+(t[l+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[l]=r[0],t[l+1]=r[1]):(p.push(c%1e14),l+=2);l=o/2}else{if(!crypto.randomBytes)throw U=!1,Error(s+"crypto unavailable");for(t=crypto.randomBytes(o*=7);l<o;)(c=281474976710656*(31&t[l])+1099511627776*t[l+1]+4294967296*t[l+2]+16777216*t[l+3]+(t[l+4]<<16)+(t[l+5]<<8)+t[l+6])>=9e15?crypto.randomBytes(7).copy(t,l):(p.push(c%1e14),l+=7);l=o/7}if(!U)for(;l<o;)(c=A())<9e15&&(p[l++]=c%1e14);for(o=p[--l],e%=u,o&&e&&(c=f[u-e],p[l]=a(o/c)*c);0===p[l];p.pop(),l--);if(l<0)p=[n=0];else{for(n=-1;0===p[0];p.splice(0,1),n-=u);for(l=1,c=p[0];c>=10;c/=10,l++);l<u&&(n-=u-l)}return d.e=n,d.c=p,d}),K.sum=function(){for(var e=1,t=arguments,r=new K(t[0]);e<t.length;)r=r.plus(t[e++]);return r},S=function(){var e="0123456789";function t(e,t,r,n){for(var i,a,s=[0],o=0,c=e.length;o<c;){for(a=s.length;a--;s[a]*=t);for(s[0]+=n.indexOf(e.charAt(o++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,a,s,o){var c,u,l,f,p,h,d,y,m=n.indexOf("."),v=w,C=N;for(m>=0&&(f=O,O=0,n=n.replace(".",""),h=(y=new K(i)).pow(n.length-m),O=f,y.c=t(E(g(h.c),h.e,"0"),10,a,e),y.e=y.c.length),l=f=(d=t(n,i,a,o?(c=x,e):(c=e,x))).length;0==d[--f];d.pop());if(!d[0])return c.charAt(0);if(m<0?--l:(h.c=d,h.e=l,h.s=s,d=(h=r(h,y,v,C,a)).c,p=h.r,l=h.e),m=d[u=l+v+1],f=a/2,p=p||u<0||null!=d[u+1],p=C<4?(null!=m||p)&&(0==C||C==(h.s<0?3:2)):m>f||m==f&&(4==C||p||6==C&&1&d[u-1]||C==(h.s<0?8:7)),u<1||!d[0])n=p?E(c.charAt(1),-v,c.charAt(0)):c.charAt(0);else{if(d.length=u,p)for(--a;++d[--u]>a;)d[u]=0,u||(++l,d=[1].concat(d));for(f=d.length;!d[--f];);for(m=0,n="";m<=f;n+=c.charAt(d[m++]));n=E(n,l,c.charAt(0))}return n}}(),r=function(){function e(e,t,r){var n,i,a,s,o=0,c=e.length,u=t%p,l=t/p|0;for(e=e.slice();c--;)o=((i=u*(a=e[c]%p)+(n=l*a+(s=e[c]/p|0)*u)%p*p+o)/r|0)+(n/p|0)+l*s,e[c]=i%r;return o&&(e=[o].concat(e)),e}function t(e,t,r,n){var i,a;if(r!=n)a=r>n?1:-1;else for(i=a=0;i<r;i++)if(e[i]!=t[i]){a=e[i]>t[i]?1:-1;break}return a}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]<t[r]?1:0,e[r]=i*n+e[r]-t[r];for(;!e[0]&&e.length>1;e.splice(0,1));}return function(n,i,s,o,l){var f,p,h,g,y,m,v,C,E,S,T,b,A,I,B,w,N,_=n.s==i.s?1:-1,R=n.c,k=i.c;if(!(R&&R[0]&&k&&k[0]))return new K(n.s&&i.s&&(R?!k||R[0]!=k[0]:k)?R&&0==R[0]||!k?0*_:_/0:NaN);for(E=(C=new K(_)).c=[],_=s+(p=n.e-i.e)+1,l||(l=c,p=d(n.e/u)-d(i.e/u),_=_/u|0),h=0;k[h]==(R[h]||0);h++);if(k[h]>(R[h]||0)&&p--,_<0)E.push(1),g=!0;else{for(I=R.length,w=k.length,h=0,_+=2,(y=a(l/(k[0]+1)))>1&&(k=e(k,y,l),R=e(R,y,l),w=k.length,I=R.length),A=w,T=(S=R.slice(0,w)).length;T<w;S[T++]=0);N=k.slice(),N=[0].concat(N),B=k[0],k[1]>=l/2&&B++;do{if(y=0,(f=t(k,S,w,T))<0){if(b=S[0],w!=T&&(b=b*l+(S[1]||0)),(y=a(b/B))>1)for(y>=l&&(y=l-1),v=(m=e(k,y,l)).length,T=S.length;1==t(m,S,v,T);)y--,r(m,w<v?N:k,v,l),v=m.length,f=1;else 0==y&&(f=y=1),v=(m=k.slice()).length;if(v<T&&(m=[0].concat(m)),r(S,m,T,l),T=S.length,-1==f)for(;t(k,S,w,T)<1;)y++,r(S,w<T?N:k,T,l),T=S.length}else 0===f&&(y++,S=[0]);E[h++]=y,S[0]?S[T++]=R[A]||0:(S=[R[A]],T=1)}while((A++<I||null!=S[0])&&_--);g=null!=S[0],E[0]||E.splice(0,1)}if(l==c){for(h=1,_=E[0];_>=10;_/=10,h++);q(C,s+(C.e=h+p*u-1)+1,o,g)}else C.e=p,C.r=+g;return C}}(),T=function(){var e=/^(-?)0([xbo])(?=\w[\w.]*$)/i,t=/^([^.]+)\.$/,r=/^\.([^.]+)$/,n=/^-?(Infinity|NaN)$/,i=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(a,o,c,u){var l,f=c?o:o.replace(i,"");if(n.test(f))a.s=isNaN(f)?null:f<0?-1:1;else{if(!c&&(f=f.replace(e,function(e,t,r){return l="x"==(r=r.toLowerCase())?16:"b"==r?2:8,u&&u!=l?e:t}),u&&(l=u,f=f.replace(t,"$1").replace(r,"0.$1")),o!=f))return new K(f,l);if(K.DEBUG)throw Error(s+"Not a"+(u?" base "+u:"")+" number: "+o);a.s=null}a.c=a.e=null}}(),I.absoluteValue=I.abs=function(){var e=new K(this);return e.s<0&&(e.s=1),e},I.comparedTo=function(e,t){return y(this,new K(e,t))},I.decimalPlaces=I.dp=function(e,t){var r,n,i,a=this;if(null!=e)return m(e,0,h),null==t?t=N:m(t,0,8),q(new K(a),e+a.e+1,t);if(!(r=a.c))return null;if(n=((i=r.length-1)-d(this.e/u))*u,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},I.dividedBy=I.div=function(e,t){return r(this,new K(e,t),w,N)},I.dividedToIntegerBy=I.idiv=function(e,t){return r(this,new K(e,t),0,1)},I.exponentiatedBy=I.pow=function(e,t){var r,n,o,c,l,f,p,h,d=this;if((e=new K(e)).c&&!e.isInteger())throw Error(s+"Exponent not an integer: "+H(e));if(null!=t&&(t=new K(t)),l=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return h=new K(Math.pow(+H(d),l?e.s*(2-v(e)):+H(e))),t?h.mod(t):h;if(f=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new K(NaN);(n=!f&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||l&&d.c[1]>=24e7:d.c[0]<8e13||l&&d.c[0]<=9999975e7)))return c=d.s<0&&v(e)?-0:0,d.e>-1&&(c=1/c),new K(f?1/c:c);O&&(c=i(O/u+2))}for(l?(r=new K(.5),f&&(e.s=1),p=v(e)):p=(o=Math.abs(+H(e)))%2,h=new K(B);;){if(p){if(!(h=h.times(d)).c)break;c?h.c.length>c&&(h.c.length=c):n&&(h=h.mod(t))}if(o){if(0===(o=a(o/2)))break;p=o%2}else if(q(e=e.times(r),e.e+1,1),e.e>14)p=v(e);else{if(0===(o=+H(e)))break;p=o%2}d=d.times(d),c?d.c&&d.c.length>c&&(d.c.length=c):n&&(d=d.mod(t))}return n?h:(f&&(h=B.div(h)),t?h.mod(t):c?q(h,O,N,void 0):h)},I.integerValue=function(e){var t=new K(this);return null==e?e=N:m(e,0,8),q(t,t.e+1,e)},I.isEqualTo=I.eq=function(e,t){return 0===y(this,new K(e,t))},I.isFinite=function(){return!!this.c},I.isGreaterThan=I.gt=function(e,t){return y(this,new K(e,t))>0},I.isGreaterThanOrEqualTo=I.gte=function(e,t){return 1===(t=y(this,new K(e,t)))||0===t},I.isInteger=function(){return!!this.c&&d(this.e/u)>this.c.length-2},I.isLessThan=I.lt=function(e,t){return y(this,new K(e,t))<0},I.isLessThanOrEqualTo=I.lte=function(e,t){return-1===(t=y(this,new K(e,t)))||0===t},I.isNaN=function(){return!this.s},I.isNegative=function(){return this.s<0},I.isPositive=function(){return this.s>0},I.isZero=function(){return!!this.c&&0==this.c[0]},I.minus=function(e,t){var r,n,i,a,s=this,o=s.s;if(t=(e=new K(e,t)).s,!o||!t)return new K(NaN);if(o!=t)return e.s=-t,s.plus(e);var l=s.e/u,f=e.e/u,p=s.c,h=e.c;if(!l||!f){if(!p||!h)return p?(e.s=-t,e):new K(h?s:NaN);if(!p[0]||!h[0])return h[0]?(e.s=-t,e):new K(p[0]?s:3==N?-0:0)}if(l=d(l),f=d(f),p=p.slice(),o=l-f){for((a=o<0)?(o=-o,i=p):(f=l,i=h),i.reverse(),t=o;t--;i.push(0));i.reverse()}else for(n=(a=(o=p.length)<(t=h.length))?o:t,o=t=0;t<n;t++)if(p[t]!=h[t]){a=p[t]<h[t];break}if(a&&(i=p,p=h,h=i,e.s=-e.s),(t=(n=h.length)-(r=p.length))>0)for(;t--;p[r++]=0);for(t=c-1;n>o;){if(p[--n]<h[n]){for(r=n;r&&!p[--r];p[r]=t);--p[r],p[n]+=c}p[n]-=h[n]}for(;0==p[0];p.splice(0,1),--f);return p[0]?j(e,p,f):(e.s=3==N?-1:1,e.c=[e.e=0],e)},I.modulo=I.mod=function(e,t){var n,i,a=this;return e=new K(e,t),!a.c||!e.s||e.c&&!e.c[0]?new K(NaN):!e.c||a.c&&!a.c[0]?new K(a):(9==D?(i=e.s,e.s=1,n=r(a,e,0,3),e.s=i,n.s*=i):n=r(a,e,0,D),(e=a.minus(n.times(e))).c[0]||1!=D||(e.s=a.s),e)},I.multipliedBy=I.times=function(e,t){var r,n,i,a,s,o,l,f,h,g,y,m,v,C,E,S=this,T=S.c,b=(e=new K(e,t)).c;if(!(T&&b&&T[0]&&b[0]))return!S.s||!e.s||T&&!T[0]&&!b||b&&!b[0]&&!T?e.c=e.e=e.s=null:(e.s*=S.s,T&&b?(e.c=[0],e.e=0):e.c=e.e=null),e;for(n=d(S.e/u)+d(e.e/u),e.s*=S.s,(l=T.length)<(g=b.length)&&(v=T,T=b,b=v,i=l,l=g,g=i),i=l+g,v=[];i--;v.push(0));for(C=c,E=p,i=g;--i>=0;){for(r=0,y=b[i]%E,m=b[i]/E|0,a=i+(s=l);a>i;)r=((f=y*(f=T[--s]%E)+(o=m*f+(h=T[s]/E|0)*y)%E*E+v[a]+r)/C|0)+(o/E|0)+m*h,v[a--]=f%C;v[a]=r}return r?++n:v.splice(0,1),j(e,v,n)},I.negated=function(){var e=new K(this);return e.s=-e.s||null,e},I.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new K(e,t)).s,!i||!t)return new K(NaN);if(i!=t)return e.s=-t,n.minus(e);var a=n.e/u,s=e.e/u,o=n.c,l=e.c;if(!a||!s){if(!o||!l)return new K(i/0);if(!o[0]||!l[0])return l[0]?e:new K(o[0]?n:0*i)}if(a=d(a),s=d(s),o=o.slice(),i=a-s){for(i>0?(s=a,r=l):(i=-i,r=o),r.reverse();i--;r.push(0));r.reverse()}for((i=o.length)-(t=l.length)<0&&(r=l,l=o,o=r,t=i),i=0;t;)i=(o[--t]=o[t]+l[t]+i)/c|0,o[t]=c===o[t]?0:o[t]%c;return i&&(o=[i].concat(o),++s),j(e,o,s)},I.precision=I.sd=function(e,t){var r,n,i,a=this;if(null!=e&&e!==!!e)return m(e,1,h),null==t?t=N:m(t,0,8),q(new K(a),e,t);if(!(r=a.c))return null;if(n=(i=r.length-1)*u+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&a.e+1>n&&(n=a.e+1),n},I.shiftedBy=function(e){return m(e,-9007199254740991,l),this.times("1e"+e)},I.squareRoot=I.sqrt=function(){var e,t,n,i,a,s=this,o=s.c,c=s.s,u=s.e,l=w+4,f=new K("0.5");if(1!==c||!o||!o[0])return new K(!c||c<0&&(!o||o[0])?NaN:o?s:1/0);if(0==(c=Math.sqrt(+H(s)))||c==1/0?(((t=g(o)).length+u)%2==0&&(t+="0"),c=Math.sqrt(+t),u=d((u+1)/2)-(u<0||u%2),n=new K(t=c==1/0?"5e"+u:(t=c.toExponential()).slice(0,t.indexOf("e")+1)+u)):n=new K(c+""),n.c[0])for((c=(u=n.e)+l)<3&&(c=0);;)if(a=n,n=f.times(a.plus(r(s,a,l,1))),g(a.c).slice(0,c)===(t=g(n.c)).slice(0,c)){if(n.e<u&&--c,"9999"!=(t=t.slice(c-3,c+1))&&(i||"4999"!=t)){+t&&(+t.slice(1)||"5"!=t.charAt(0))||(q(n,n.e+w+2,1),e=!n.times(n).eq(s));break}if(!i&&(q(a,a.e+w+2,0),a.times(a).eq(s))){n=a;break}l+=4,c+=4,i=1}return q(n,n.e+w+1,N,e)},I.toExponential=function(e,t){return null!=e&&(m(e,0,h),e++),M(this,e,t,1)},I.toFixed=function(e,t){return null!=e&&(m(e,0,h),e=e+this.e+1),M(this,e,t)},I.toFormat=function(e,t,r){var n,i=this;if(null==r)null!=e&&t&&"object"==typeof t?(r=t,t=null):e&&"object"==typeof e?(r=e,e=t=null):r=P;else if("object"!=typeof r)throw Error(s+"Argument not an object: "+r);if(n=i.toFixed(e,t),i.c){var a,o=n.split("."),c=+r.groupSize,u=+r.secondaryGroupSize,l=r.groupSeparator||"",f=o[0],p=o[1],h=i.s<0,d=h?f.slice(1):f,g=d.length;if(u&&(a=c,c=u,u=a,g-=a),c>0&&g>0){for(a=g%c||c,f=d.substr(0,a);a<g;a+=c)f+=l+d.substr(a,c);u>0&&(f+=l+d.slice(a)),h&&(f="-"+f)}n=p?f+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?p.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):p):f}return(r.prefix||"")+n+(r.suffix||"")},I.toFraction=function(e){var t,n,i,a,o,c,l,p,h,d,y,m,v=this,C=v.c;if(null!=e&&(!(l=new K(e)).isInteger()&&(l.c||1!==l.s)||l.lt(B)))throw Error(s+"Argument "+(l.isInteger()?"out of range: ":"not an integer: ")+H(l));if(!C)return new K(v);for(t=new K(B),h=n=new K(B),i=p=new K(B),m=g(C),o=t.e=m.length-v.e-1,t.c[0]=f[(c=o%u)<0?u+c:c],e=!e||l.comparedTo(t)>0?o>0?t:h:l,c=L,L=1/0,l=new K(m),p.c[0]=0;d=r(l,t,0,1),1!=(a=n.plus(d.times(i))).comparedTo(e);)n=i,i=a,h=p.plus(d.times(a=h)),p=a,t=l.minus(d.times(a=t)),l=a;return a=r(e.minus(n),i,0,1),p=p.plus(a.times(h)),n=n.plus(a.times(i)),p.s=h.s=v.s,y=r(h,i,o*=2,N).minus(v).abs().comparedTo(r(p,n,o,N).minus(v).abs())<1?[h,i]:[p,n],L=c,y},I.toNumber=function(){return+H(this)},I.toPrecision=function(e,t){return null!=e&&m(e,1,h),M(this,e,t,2)},I.toString=function(e){var t,r=this,n=r.s,i=r.e;return null===i?n?(t="Infinity",n<0&&(t="-"+t)):t="NaN":(null==e?t=i<=_||i>=R?C(g(r.c),i):E(g(r.c),i,"0"):10===e&&V?t=E(g((r=q(new K(r),w+i+1,N)).c),r.e,"0"):(m(e,2,x.length,"Base"),t=S(E(g(r.c),i,"0"),10,e,n,!0)),n<0&&r.c[0]&&(t="-"+t)),t},I.valueOf=I.toJSON=function(){return H(this)},I._isBigNumber=!0,null!=t&&K.set(t),K}(),r.default=r.BigNumber=r,e.exports?e.exports=r:(t||(t="undefined"!=typeof self&&self?self:window),t.BigNumber=r)}(d)),h.exports;var e}function y(){return o||(o=1,e=p,t=g(),r=e.exports,function(){var e,n,i,a=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,s={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function o(e){return a.lastIndex=0,a.test(e)?'"'+e.replace(a,function(e){var t=s[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function c(r,a){var s,u,l,f,p,h=e,d=a[r],g=null!=d&&(d instanceof t||t.isBigNumber(d));switch(d&&"object"==typeof d&&"function"==typeof d.toJSON&&(d=d.toJSON(r)),"function"==typeof i&&(d=i.call(a,r,d)),typeof d){case"string":return g?d:o(d);case"number":return isFinite(d)?String(d):"null";case"boolean":case"null":case"bigint":return String(d);case"object":if(!d)return"null";if(e+=n,p=[],"[object Array]"===Object.prototype.toString.apply(d)){for(f=d.length,s=0;s<f;s+=1)p[s]=c(s,d)||"null";return l=0===p.length?"[]":e?"[\n"+e+p.join(",\n"+e)+"\n"+h+"]":"["+p.join(",")+"]",e=h,l}if(i&&"object"==typeof i)for(f=i.length,s=0;s<f;s+=1)"string"==typeof i[s]&&(l=c(u=i[s],d))&&p.push(o(u)+(e?": ":":")+l);else Object.keys(d).forEach(function(t){var r=c(t,d);r&&p.push(o(t)+(e?": ":":")+r)});return l=0===p.length?"{}":e?"{\n"+e+p.join(",\n"+e)+"\n"+h+"}":"{"+p.join(",")+"}",e=h,l}}"function"!=typeof r.stringify&&(r.stringify=function(t,r,a){var s;if(e="",n="","number"==typeof a)for(s=0;s<a;s+=1)n+=" ";else"string"==typeof a&&(n=a);if(i=r,r&&"function"!=typeof r&&("object"!=typeof r||"number"!=typeof r.length))throw new Error("JSON.stringify");return c("",{"":t})})}()),p.exports;var e,t,r}function m(){if(u)return c;u=1;var e=null;const t=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,r=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;return c=function(n){var i={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(null!=n){if(!0===n.strict&&(i.strict=!0),!0===n.storeAsString&&(i.storeAsString=!0),i.alwaysParseAsBig=!0===n.alwaysParseAsBig&&n.alwaysParseAsBig,i.useNativeBigInt=!0===n.useNativeBigInt&&n.useNativeBigInt,void 0!==n.constructorAction){if("error"!==n.constructorAction&&"ignore"!==n.constructorAction&&"preserve"!==n.constructorAction)throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${n.constructorAction}`);i.constructorAction=n.constructorAction}if(void 0!==n.protoAction){if("error"!==n.protoAction&&"ignore"!==n.protoAction&&"preserve"!==n.protoAction)throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${n.protoAction}`);i.protoAction=n.protoAction}}var a,s,o,c,u={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:"\n",r:"\r",t:"\t"},l=function(e){throw{name:"SyntaxError",message:e,at:a,text:o}},f=function(e){return e&&e!==s&&l("Expected '"+e+"' instead of '"+s+"'"),s=o.charAt(a),a+=1,s},p=function(){var t,r="";for("-"===s&&(r="-",f("-"));s>="0"&&s<="9";)r+=s,f();if("."===s)for(r+=".";f()&&s>="0"&&s<="9";)r+=s;if("e"===s||"E"===s)for(r+=s,f(),"-"!==s&&"+"!==s||(r+=s,f());s>="0"&&s<="9";)r+=s,f();if(t=+r,isFinite(t))return null==e&&(e=g()),r.length>15?i.storeAsString?r:i.useNativeBigInt?BigInt(r):new e(r):i.alwaysParseAsBig?i.useNativeBigInt?BigInt(t):new e(t):t;l("Bad number")},h=function(){var e,t,r,n="";if('"'===s)for(var i=a;f();){if('"'===s)return a-1>i&&(n+=o.substring(i,a-1)),f(),n;if("\\"===s){if(a-1>i&&(n+=o.substring(i,a-1)),f(),"u"===s){for(r=0,t=0;t<4&&(e=parseInt(f(),16),isFinite(e));t+=1)r=16*r+e;n+=String.fromCharCode(r)}else{if("string"!=typeof u[s])break;n+=u[s]}i=a}}l("Bad string")},d=function(){for(;s&&s<=" ";)f()};return c=function(){switch(d(),s){case"{":return function(){var e,n=Object.create(null);if("{"===s){if(f("{"),d(),"}"===s)return f("}"),n;for(;s;){if(e=h(),d(),f(":"),!0===i.strict&&Object.hasOwnProperty.call(n,e)&&l('Duplicate key "'+e+'"'),!0===t.test(e)?"error"===i.protoAction?l("Object contains forbidden prototype property"):"ignore"===i.protoAction?c():n[e]=c():!0===r.test(e)?"error"===i.constructorAction?l("Object contains forbidden constructor property"):"ignore"===i.constructorAction?c():n[e]=c():n[e]=c(),d(),"}"===s)return f("}"),n;f(","),d()}}l("Bad object")}();case"[":return function(){var e=[];if("["===s){if(f("["),d(),"]"===s)return f("]"),e;for(;s;){if(e.push(c()),d(),"]"===s)return f("]"),e;f(","),d()}}l("Bad array")}();case'"':return h();case"-":return p();default:return s>="0"&&s<="9"?p():function(){switch(s){case"t":return f("t"),f("r"),f("u"),f("e"),!0;case"f":return f("f"),f("a"),f("l"),f("s"),f("e"),!1;case"n":return f("n"),f("u"),f("l"),f("l"),null}l("Unexpected '"+s+"'")}()}},function(e,t){var r;return o=e+"",a=0,s=" ",r=c(),d(),s&&l("Syntax error"),"function"==typeof t?function e(r,n){var i,a=r[n];return a&&"object"==typeof a&&Object.keys(a).forEach(function(t){void 0!==(i=e(a,t))?a[t]=i:delete a[t]}),t.call(r,n,a)}({"":r},""):r}}}const v=i(function(){if(l)return f.exports;l=1;var e=y().stringify,t=m();return f.exports=function(r){return{parse:t(r),stringify:e}},f.exports.parse=t(),f.exports.stringify=e,f.exports}())({storeAsString:!1,useNativeBigInt:!0});function C(e){return v.stringify(e)}function E(e){try{return v.parse(e)}catch(t){return console.error("Failed to parse JSON:",t),null}}function S(e,t){return function(){return e.apply(t,arguments)}}const{toString:T}=Object.prototype,{getPrototypeOf:b}=Object,{iterator:A,toStringTag:I}=Symbol,B=(e=>t=>{const r=T.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),w=e=>(e=e.toLowerCase(),t=>B(t)===e),N=e=>t=>typeof t===e,{isArray:_}=Array,R=N("undefined");function k(e){return null!==e&&!R(e)&&null!==e.constructor&&!R(e.constructor)&&D(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const L=w("ArrayBuffer");const U=N("string"),D=N("function"),O=N("number"),P=e=>null!==e&&"object"==typeof e,x=e=>{if("object"!==B(e))return!1;const t=b(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||I in e||A in e)},V=w("Date"),K=w("File"),M=w("Blob"),F=w("FileList"),j=w("URLSearchParams"),[q,H,G,z]=["ReadableStream","Request","Response","Headers"].map(w);function Q(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,i;if("object"!=typeof e&&(e=[e]),_(e))for(n=0,i=e.length;n<i;n++)t.call(null,e[n],n,e);else{if(k(e))return;const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let s;for(n=0;n<a;n++)s=i[n],t.call(null,e[s],s,e)}}function W(e,t){if(k(e))return null;t=t.toLowerCase();const r=Object.keys(e);let n,i=r.length;for(;i-- >0;)if(n=r[i],t===n.toLowerCase())return n;return null}const Y="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:globalThis,X=e=>!R(e)&&e!==Y;const $=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&b(Uint8Array)),J=w("HTMLFormElement"),Z=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ee=w("RegExp"),te=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Q(r,(r,i)=>{let a;!1!==(a=t(r,i,e))&&(n[i]=a||r)}),Object.defineProperties(e,n)};const re=w("AsyncFunction"),ne=(ie="function"==typeof setImmediate,ae=D(Y.postMessage),ie?setImmediate:ae?(se=`axios@${Math.random()}`,oe=[],Y.addEventListener("message",({source:e,data:t})=>{e===Y&&t===se&&oe.length&&oe.shift()()},!1),e=>{oe.push(e),Y.postMessage(se,"*")}):e=>setTimeout(e));var ie,ae,se,oe;const ce="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Y):"undefined"!=typeof process&&process.nextTick||ne,ue={isArray:_,isArrayBuffer:L,isBuffer:k,isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||D(e.append)&&("formdata"===(t=B(e))||"object"===t&&D(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&L(e.buffer),t},isString:U,isNumber:O,isBoolean:e=>!0===e||!1===e,isObject:P,isPlainObject:x,isEmptyObject:e=>{if(!P(e)||k(e))return!1;try{return 0===Object.keys(e).length&&Object.getPrototypeOf(e)===Object.prototype}catch(t){return!1}},isReadableStream:q,isRequest:H,isResponse:G,isHeaders:z,isUndefined:R,isDate:V,isFile:K,isBlob:M,isRegExp:ee,isFunction:D,isStream:e=>P(e)&&D(e.pipe),isURLSearchParams:j,isTypedArray:$,isFileList:F,forEach:Q,merge:function e(){const{caseless:t,skipUndefined:r}=X(this)&&this||{},n={},i=(i,a)=>{const s=t&&W(n,a)||a;x(n[s])&&x(i)?n[s]=e(n[s],i):x(i)?n[s]=e({},i):_(i)?n[s]=i.slice():r&&R(i)||(n[s]=i)};for(let a=0,s=arguments.length;a<s;a++)arguments[a]&&Q(arguments[a],i);return n},extend:(e,t,r,{allOwnKeys:n}={})=>(Q(t,(t,n)=>{r&&D(t)?e[n]=S(t,r):e[n]=t},{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},toFlatObject:(e,t,r,n)=>{let i,a,s;const o={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),a=i.length;a-- >0;)s=i[a],n&&!n(s,e,t)||o[s]||(t[s]=e[s],o[s]=!0);e=!1!==r&&b(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:B,kindOfTest:w,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(_(e))return e;let t=e.length;if(!O(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[A]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:J,hasOwnProperty:Z,hasOwnProp:Z,reduceDescriptors:te,freezeMethods:e=>{te(e,(t,r)=>{if(D(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];D(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))})},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach(e=>{r[e]=!0})};return _(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(e,t,r){return t.toUpperCase()+r}),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:W,global:Y,isContextDefined:X,isSpecCompliantForm:function(e){return!!(e&&D(e.append)&&"FormData"===e[I]&&e[A])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(P(e)){if(t.indexOf(e)>=0)return;if(k(e))return e;if(!("toJSON"in e)){t[n]=e;const i=_(e)?[]:{};return Q(e,(e,t)=>{const a=r(e,n+1);!R(a)&&(i[t]=a)}),t[n]=void 0,i}}return e};return r(e,0)},isAsyncFn:re,isThenable:e=>e&&(P(e)||D(e))&&D(e.then)&&D(e.catch),setImmediate:ne,asap:ce,isIterable:e=>null!=e&&D(e[A])};function le(e,t,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i,this.status=i.status?i.status:null)}ue.inherits(le,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:ue.toJSONObject(this.config),code:this.code,status:this.status}}});const fe=le.prototype,pe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{pe[e]={value:e}}),Object.defineProperties(le,pe),Object.defineProperty(fe,"isAxiosError",{value:!0}),le.from=(e,t,r,n,i,a)=>{const s=Object.create(fe);ue.toFlatObject(e,s,function(e){return e!==Error.prototype},e=>"isAxiosError"!==e);const o=e&&e.message?e.message:"Error",c=null==t&&e?e.code:t;return le.call(s,o,c,r,n,i),e&&null==s.cause&&Object.defineProperty(s,"cause",{value:e,configurable:!0}),s.name=e&&e.name||"Error",a&&Object.assign(s,a),s};function he(e){return ue.isPlainObject(e)||ue.isArray(e)}function de(e){return ue.endsWith(e,"[]")?e.slice(0,-2):e}function ge(e,t,r){return e?e.concat(t).map(function(e,t){return e=de(e),!r&&t?"["+e+"]":e}).join(r?".":""):t}const ye=ue.toFlatObject(ue,{},null,function(e){return/^is[A-Z]/.test(e)});function me(e,t,r){if(!ue.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=ue.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(e,t){return!ue.isUndefined(t[e])})).metaTokens,i=r.visitor||u,a=r.dots,s=r.indexes,o=(r.Blob||"undefined"!=typeof Blob&&Blob)&&ue.isSpecCompliantForm(t);if(!ue.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(ue.isDate(e))return e.toISOString();if(ue.isBoolean(e))return e.toString();if(!o&&ue.isBlob(e))throw new le("Blob is not supported. Use a Buffer instead.");return ue.isArrayBuffer(e)||ue.isTypedArray(e)?o&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function u(e,r,i){let o=e;if(e&&!i&&"object"==typeof e)if(ue.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(ue.isArray(e)&&function(e){return ue.isArray(e)&&!e.some(he)}(e)||(ue.isFileList(e)||ue.endsWith(r,"[]"))&&(o=ue.toArray(e)))return r=de(r),o.forEach(function(e,n){!ue.isUndefined(e)&&null!==e&&t.append(!0===s?ge([r],n,a):null===s?r:r+"[]",c(e))}),!1;return!!he(e)||(t.append(ge(i,r,a),c(e)),!1)}const l=[],f=Object.assign(ye,{defaultVisitor:u,convertValue:c,isVisitable:he});if(!ue.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!ue.isUndefined(r)){if(-1!==l.indexOf(r))throw Error("Circular reference detected in "+n.join("."));l.push(r),ue.forEach(r,function(r,a){!0===(!(ue.isUndefined(r)||null===r)&&i.call(t,r,ue.isString(a)?a.trim():a,n,f))&&e(r,n?n.concat(a):[a])}),l.pop()}}(e),t}function ve(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(e){return t[e]})}function Ce(e,t){this._pairs=[],e&&me(e,this,t)}const Ee=Ce.prototype;function Se(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function Te(e,t,r){if(!t)return e;const n=r&&r.encode||Se;ue.isFunction(r)&&(r={serialize:r});const i=r&&r.serialize;let a;if(a=i?i(t,r):ue.isURLSearchParams(t)?t.toString():new Ce(t,r).toString(n),a){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+a}return e}Ee.append=function(e,t){this._pairs.push([e,t])},Ee.toString=function(e){const t=e?function(t){return e.call(this,t,ve)}:ve;return this._pairs.map(function(e){return t(e[0])+"="+t(e[1])},"").join("&")};class be{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){ue.forEach(this.handlers,function(t){null!==t&&e(t)})}}const Ae={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ie={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Ce,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},Be="undefined"!=typeof window&&"undefined"!=typeof document,we="object"==typeof navigator&&navigator||void 0,Ne=Be&&(!we||["ReactNative","NativeScript","NS"].indexOf(we.product)<0),_e="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Re=Be&&window.location.href||"http://localhost",ke={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Be,hasStandardBrowserEnv:Ne,hasStandardBrowserWebWorkerEnv:_e,navigator:we,origin:Re},Symbol.toStringTag,{value:"Module"})),...Ie};function Le(e){function t(e,r,n,i){let a=e[i++];if("__proto__"===a)return!0;const s=Number.isFinite(+a),o=i>=e.length;if(a=!a&&ue.isArray(n)?n.length:a,o)return ue.hasOwnProp(n,a)?n[a]=[n[a],r]:n[a]=r,!s;n[a]&&ue.isObject(n[a])||(n[a]=[]);return t(e,r,n[a],i)&&ue.isArray(n[a])&&(n[a]=function(e){const t={},r=Object.keys(e);let n;const i=r.length;let a;for(n=0;n<i;n++)a=r[n],t[a]=e[a];return t}(n[a])),!s}if(ue.isFormData(e)&&ue.isFunction(e.entries)){const r={};return ue.forEachEntry(e,(e,n)=>{t(function(e){return ue.matchAll(/\w+|\[(\w*)]/g,e).map(e=>"[]"===e[0]?"":e[1]||e[0])}(e),n,r,0)}),r}return null}const Ue={transitional:Ae,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,i=ue.isObject(e);i&&ue.isHTMLForm(e)&&(e=new FormData(e));if(ue.isFormData(e))return n?JSON.stringify(Le(e)):e;if(ue.isArrayBuffer(e)||ue.isBuffer(e)||ue.isStream(e)||ue.isFile(e)||ue.isBlob(e)||ue.isReadableStream(e))return e;if(ue.isArrayBufferView(e))return e.buffer;if(ue.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return me(e,new ke.classes.URLSearchParams,{visitor:function(e,t,r,n){return ke.isNode&&ue.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)},...t})}(e,this.formSerializer).toString();if((a=ue.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return me(a?{"files[]":e}:e,t&&new t,this.formSerializer)}}return i||n?(t.setContentType("application/json",!1),function(e,t,r){if(ue.isString(e))try{return(t||JSON.parse)(e),ue.trim(e)}catch(n){if("SyntaxError"!==n.name)throw n}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Ue.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(ue.isResponse(e)||ue.isReadableStream(e))return e;if(e&&ue.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e,this.parseReviver)}catch(i){if(r){if("SyntaxError"===i.name)throw le.from(i,le.ERR_BAD_RESPONSE,this,null,this.response);throw i}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ke.classes.FormData,Blob:ke.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};ue.forEach(["delete","get","head","post","put","patch"],e=>{Ue.headers[e]={}});const De=ue.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Oe=Symbol("internals");function Pe(e){return e&&String(e).trim().toLowerCase()}function xe(e){return!1===e||null==e?e:ue.isArray(e)?e.map(xe):String(e)}function Ve(e,t,r,n,i){return ue.isFunction(n)?n.call(this,t,r):(i&&(t=r),ue.isString(t)?ue.isString(n)?-1!==t.indexOf(n):ue.isRegExp(n)?n.test(t):void 0:void 0)}let Ke=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function i(e,t,r){const i=Pe(t);if(!i)throw new Error("header name must be a non-empty string");const a=ue.findKey(n,i);(!a||void 0===n[a]||!0===r||void 0===r&&!1!==n[a])&&(n[a||t]=xe(e))}const a=(e,t)=>ue.forEach(e,(e,r)=>i(e,r,t));if(ue.isPlainObject(e)||e instanceof this.constructor)a(e,t);else if(ue.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))a((e=>{const t={};let r,n,i;return e&&e.split("\n").forEach(function(e){i=e.indexOf(":"),r=e.substring(0,i).trim().toLowerCase(),n=e.substring(i+1).trim(),!r||t[r]&&De[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t})(e),t);else if(ue.isObject(e)&&ue.isIterable(e)){let r,n,i={};for(const t of e){if(!ue.isArray(t))throw TypeError("Object iterator must return a key-value pair");i[n=t[0]]=(r=i[n])?ue.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}a(i,t)}else null!=e&&i(t,e,r);return this}get(e,t){if(e=Pe(e)){const r=ue.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}(e);if(ue.isFunction(t))return t.call(this,e,r);if(ue.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=Pe(e)){const r=ue.findKey(this,e);return!(!r||void 0===this[r]||t&&!Ve(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function i(e){if(e=Pe(e)){const i=ue.findKey(r,e);!i||t&&!Ve(0,r[i],i,t)||(delete r[i],n=!0)}}return ue.isArray(e)?e.forEach(i):i(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const i=t[r];e&&!Ve(0,this[i],i,e,!0)||(delete this[i],n=!0)}return n}normalize(e){const t=this,r={};return ue.forEach(this,(n,i)=>{const a=ue.findKey(r,i);if(a)return t[a]=xe(n),void delete t[i];const s=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,t,r)=>t.toUpperCase()+r)}(i):String(i).trim();s!==i&&delete t[i],t[s]=xe(n),r[s]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return ue.forEach(this,(r,n)=>{null!=r&&!1!==r&&(t[n]=e&&ue.isArray(r)?r.join(", "):r)}),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,t])=>e+": "+t).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach(e=>r.set(e)),r}static accessor(e){const t=(this[Oe]=this[Oe]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=Pe(e);t[n]||(!function(e,t){const r=ue.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(e,r,i){return this[n].call(this,t,e,r,i)},configurable:!0})})}(r,e),t[n]=!0)}return ue.isArray(e)?e.forEach(n):n(e),this}};function Me(e,t){const r=this||Ue,n=t||r,i=Ke.from(n.headers);let a=n.data;return ue.forEach(e,function(e){a=e.call(r,a,i.normalize(),t?t.status:void 0)}),i.normalize(),a}function Fe(e){return!(!e||!e.__CANCEL__)}function je(e,t,r){le.call(this,null==e?"canceled":e,le.ERR_CANCELED,t,r),this.name="CanceledError"}function qe(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new le("Request failed with status code "+r.status,[le.ERR_BAD_REQUEST,le.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}Ke.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),ue.reduceDescriptors(Ke.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}}),ue.freezeMethods(Ke),ue.inherits(je,le,{__CANCEL__:!0});const He=(e,t,r=3)=>{let n=0;const i=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let i,a=0,s=0;return t=void 0!==t?t:1e3,function(o){const c=Date.now(),u=n[s];i||(i=c),r[a]=o,n[a]=c;let l=s,f=0;for(;l!==a;)f+=r[l++],l%=e;if(a=(a+1)%e,a===s&&(s=(s+1)%e),c-i<t)return;const p=u&&c-u;return p?Math.round(1e3*f/p):void 0}}(50,250);return function(e,t){let r,n,i=0,a=1e3/t;const s=(t,a=Date.now())=>{i=a,r=null,n&&(clearTimeout(n),n=null),e(...t)};return[(...e)=>{const t=Date.now(),o=t-i;o>=a?s(e,t):(r=e,n||(n=setTimeout(()=>{n=null,s(r)},a-o)))},()=>r&&s(r)]}(r=>{const a=r.loaded,s=r.lengthComputable?r.total:void 0,o=a-n,c=i(o);n=a;e({loaded:a,total:s,progress:s?a/s:void 0,bytes:o,rate:c||void 0,estimated:c&&s&&a<=s?(s-a)/c:void 0,event:r,lengthComputable:null!=s,[t?"download":"upload"]:!0})},r)},Ge=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ze=e=>(...t)=>ue.asap(()=>e(...t)),Qe=ke.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ke.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ke.origin),ke.navigator&&/(msie|trident)/i.test(ke.navigator.userAgent)):()=>!0,We=ke.hasStandardBrowserEnv?{write(e,t,r,n,i,a){const s=[e+"="+encodeURIComponent(t)];ue.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),ue.isString(n)&&s.push("path="+n),ue.isString(i)&&s.push("domain="+i),!0===a&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Ye(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Xe=e=>e instanceof Ke?{...e}:e;function $e(e,t){t=t||{};const r={};function n(e,t,r,n){return ue.isPlainObject(e)&&ue.isPlainObject(t)?ue.merge.call({caseless:n},e,t):ue.isPlainObject(t)?ue.merge({},t):ue.isArray(t)?t.slice():t}function i(e,t,r,i){return ue.isUndefined(t)?ue.isUndefined(e)?void 0:n(void 0,e,0,i):n(e,t,0,i)}function a(e,t){if(!ue.isUndefined(t))return n(void 0,t)}function s(e,t){return ue.isUndefined(t)?ue.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function o(r,i,a){return a in t?n(r,i):a in e?n(void 0,r):void 0}const c={url:a,method:a,data:a,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:o,headers:(e,t,r)=>i(Xe(e),Xe(t),0,!0)};return ue.forEach(Object.keys({...e,...t}),function(n){const a=c[n]||i,s=a(e[n],t[n],n);ue.isUndefined(s)&&a!==o||(r[n]=s)}),r}const Je=e=>{const t=$e({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:i,xsrfCookieName:a,headers:s,auth:o}=t;if(t.headers=s=Ke.from(s),t.url=Te(Ye(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),o&&s.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):""))),ue.isFormData(r))if(ke.hasStandardBrowserEnv||ke.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if(ue.isFunction(r.getHeaders)){const e=r.getHeaders(),t=["content-type","content-length"];Object.entries(e).forEach(([e,r])=>{t.includes(e.toLowerCase())&&s.set(e,r)})}if(ke.hasStandardBrowserEnv&&(n&&ue.isFunction(n)&&(n=n(t)),n||!1!==n&&Qe(t.url))){const e=i&&a&&We.read(a);e&&s.set(i,e)}return t},Ze="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise(function(t,r){const n=Je(e);let i=n.data;const a=Ke.from(n.headers).normalize();let s,o,c,u,l,{responseType:f,onUploadProgress:p,onDownloadProgress:h}=n;function d(){u&&u(),l&&l(),n.cancelToken&&n.cancelToken.unsubscribe(s),n.signal&&n.signal.removeEventListener("abort",s)}let g=new XMLHttpRequest;function y(){if(!g)return;const n=Ke.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());qe(function(e){t(e),d()},function(e){r(e),d()},{data:f&&"text"!==f&&"json"!==f?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:e,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=y:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(y)},g.onabort=function(){g&&(r(new le("Request aborted",le.ECONNABORTED,e,g)),g=null)},g.onerror=function(t){const n=new le(t&&t.message?t.message:"Network Error",le.ERR_NETWORK,e,g);n.event=t||null,r(n),g=null},g.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const i=n.transitional||Ae;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new le(t,i.clarifyTimeoutError?le.ETIMEDOUT:le.ECONNABORTED,e,g)),g=null},void 0===i&&a.setContentType(null),"setRequestHeader"in g&&ue.forEach(a.toJSON(),function(e,t){g.setRequestHeader(t,e)}),ue.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),f&&"json"!==f&&(g.responseType=n.responseType),h&&([c,l]=He(h,!0),g.addEventListener("progress",c)),p&&g.upload&&([o,u]=He(p),g.upload.addEventListener("progress",o),g.upload.addEventListener("loadend",u)),(n.cancelToken||n.signal)&&(s=t=>{g&&(r(!t||t.type?new je(null,e,g):t),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(s),n.signal&&(n.signal.aborted?s():n.signal.addEventListener("abort",s)));const m=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);m&&-1===ke.protocols.indexOf(m)?r(new le("Unsupported protocol "+m+":",le.ERR_BAD_REQUEST,e)):g.send(i||null)})},et=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const i=function(e){if(!r){r=!0,s();const t=e instanceof Error?e:this.reason;n.abort(t instanceof le?t:new je(t instanceof Error?t.message:t))}};let a=t&&setTimeout(()=>{a=null,i(new le(`timeout ${t} of ms exceeded`,le.ETIMEDOUT))},t);const s=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(e=>{e.unsubscribe?e.unsubscribe(i):e.removeEventListener("abort",i)}),e=null)};e.forEach(e=>e.addEventListener("abort",i));const{signal:o}=n;return o.unsubscribe=()=>ue.asap(s),o}},tt=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,i=0;for(;i<r;)n=i+t,yield e.slice(i,n),i=n},rt=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},nt=(e,t,r,n)=>{const i=async function*(e,t){for await(const r of rt(e))yield*tt(r,t)}(e,t);let a,s=0,o=e=>{a||(a=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await i.next();if(t)return o(),void e.close();let a=n.byteLength;if(r){let e=s+=a;r(e)}e.enqueue(new Uint8Array(n))}catch(t){throw o(t),t}},cancel:e=>(o(e),i.return())},{highWaterMark:2})},{isFunction:it}=ue,at=(({Request:e,Response:t})=>({Request:e,Response:t}))(ue.global),{ReadableStream:st,TextEncoder:ot}=ue.global,ct=(e,...t)=>{try{return!!e(...t)}catch(r){return!1}},ut=e=>{e=ue.merge.call({skipUndefined:!0},at,e);const{fetch:t,Request:r,Response:n}=e,i=t?it(t):"function"==typeof fetch,a=it(r),s=it(n);if(!i)return!1;const o=i&&it(st),c=i&&("function"==typeof ot?(e=>t=>e.encode(t))(new ot):async e=>new Uint8Array(await new r(e).arrayBuffer())),u=a&&o&&ct(()=>{let e=!1;const t=new r(ke.origin,{body:new st,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),l=s&&o&&ct(()=>ue.isReadableStream(new n("").body)),f={stream:l&&(e=>e.body)};i&&["text","arrayBuffer","blob","formData","stream"].forEach(e=>{!f[e]&&(f[e]=(t,r)=>{let n=t&&t[e];if(n)return n.call(t);throw new le(`Response type '${e}' is not supported`,le.ERR_NOT_SUPPORT,r)})});const p=async(e,t)=>{const n=ue.toFiniteNumber(e.getContentLength());return null==n?(async e=>{if(null==e)return 0;if(ue.isBlob(e))return e.size;if(ue.isSpecCompliantForm(e)){const t=new r(ke.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return ue.isArrayBufferView(e)||ue.isArrayBuffer(e)?e.byteLength:(ue.isURLSearchParams(e)&&(e+=""),ue.isString(e)?(await c(e)).byteLength:void 0)})(t):n};return async e=>{let{url:i,method:s,data:o,signal:c,cancelToken:h,timeout:d,onDownloadProgress:g,onUploadProgress:y,responseType:m,headers:v,withCredentials:C="same-origin",fetchOptions:E}=Je(e),S=t||fetch;m=m?(m+"").toLowerCase():"text";let T=et([c,h&&h.toAbortSignal()],d),b=null;const A=T&&T.unsubscribe&&(()=>{T.unsubscribe()});let I;try{if(y&&u&&"get"!==s&&"head"!==s&&0!==(I=await p(v,o))){let e,t=new r(i,{method:"POST",body:o,duplex:"half"});if(ue.isFormData(o)&&(e=t.headers.get("content-type"))&&v.setContentType(e),t.body){const[e,r]=Ge(I,He(ze(y)));o=nt(t.body,65536,e,r)}}ue.isString(C)||(C=C?"include":"omit");const t=a&&"credentials"in r.prototype,c={...E,signal:T,method:s.toUpperCase(),headers:v.normalize().toJSON(),body:o,duplex:"half",credentials:t?C:void 0};b=a&&new r(i,c);let h=await(a?S(b,E):S(i,c));const d=l&&("stream"===m||"response"===m);if(l&&(g||d&&A)){const e={};["status","statusText","headers"].forEach(t=>{e[t]=h[t]});const t=ue.toFiniteNumber(h.headers.get("content-length")),[r,i]=g&&Ge(t,He(ze(g),!0))||[];h=new n(nt(h.body,65536,r,()=>{i&&i(),A&&A()}),e)}m=m||"text";let B=await f[ue.findKey(f,m)||"text"](h,e);return!d&&A&&A(),await new Promise((t,r)=>{qe(t,r,{data:B,headers:Ke.from(h.headers),status:h.status,statusText:h.statusText,config:e,request:b})})}catch(B){if(A&&A(),B&&"TypeError"===B.name&&/Load failed|fetch/i.test(B.message))throw Object.assign(new le("Network Error",le.ERR_NETWORK,e,b),{cause:B.cause||B});throw le.from(B,B&&B.code,e,b)}}},lt=new Map,ft=e=>{let t=e?e.env:{};const{fetch:r,Request:n,Response:i}=t,a=[n,i,r];let s,o,c=a.length,u=lt;for(;c--;)s=a[c],o=u.get(s),void 0===o&&u.set(s,o=c?new Map:ut(t)),u=o;return o};ft();const pt={http:null,xhr:Ze,fetch:{get:ft}};ue.forEach(pt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(r){}Object.defineProperty(e,"adapterName",{value:t})}});const ht=e=>`- ${e}`,dt=e=>ue.isFunction(e)||null===e||!1===e,gt=(e,t)=>{e=ue.isArray(e)?e:[e];const{length:r}=e;let n,i;const a={};for(let s=0;s<r;s++){let r;if(n=e[s],i=n,!dt(n)&&(i=pt[(r=String(n)).toLowerCase()],void 0===i))throw new le(`Unknown adapter '${r}'`);if(i&&(ue.isFunction(i)||(i=i.get(t))))break;a[r||"#"+s]=i}if(!i){const e=Object.entries(a).map(([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build"));throw new le("There is no suitable adapter to dispatch the request "+(r?e.length>1?"since :\n"+e.map(ht).join("\n"):" "+ht(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return i};function yt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new je(null,e)}function mt(e){yt(e),e.headers=Ke.from(e.headers),e.data=Me.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return gt(e.adapter||Ue.adapter,e)(e).then(function(t){return yt(e),t.data=Me.call(e,e.transformResponse,t),t.headers=Ke.from(t.headers),t},function(t){return Fe(t)||(yt(e),t&&t.response&&(t.response.data=Me.call(e,e.transformResponse,t.response),t.response.headers=Ke.from(t.response.headers))),Promise.reject(t)})}const vt="1.12.2",Ct={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{Ct[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Et={};Ct.transitional=function(e,t,r){function n(e,t){return"[Axios v"+vt+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,i,a)=>{if(!1===e)throw new le(n(i," has been removed"+(t?" in "+t:"")),le.ERR_DEPRECATED);return t&&!Et[i]&&(Et[i]=!0,console.warn(n(i," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,i,a)}},Ct.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};const St={assertOptions:function(e,t,r){if("object"!=typeof e)throw new le("options must be an object",le.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let i=n.length;for(;i-- >0;){const a=n[i],s=t[a];if(s){const t=e[a],r=void 0===t||s(t,a,e);if(!0!==r)throw new le("option "+a+" must be "+r,le.ERR_BAD_OPTION_VALUE);continue}if(!0!==r)throw new le("Unknown option "+a,le.ERR_BAD_OPTION)}},validators:Ct},Tt=St.validators;let bt=class{constructor(e){this.defaults=e||{},this.interceptors={request:new be,response:new be}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const t=e.stack?e.stack.replace(/^.+\n/,""):"";try{r.stack?t&&!String(r.stack).endsWith(t.replace(/^.+\n.+\n/,""))&&(r.stack+="\n"+t):r.stack=t}catch(n){}}throw r}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=$e(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:i}=t;void 0!==r&&St.assertOptions(r,{silentJSONParsing:Tt.transitional(Tt.boolean),forcedJSONParsing:Tt.transitional(Tt.boolean),clarifyTimeoutError:Tt.transitional(Tt.boolean)},!1),null!=n&&(ue.isFunction(n)?t.paramsSerializer={serialize:n}:St.assertOptions(n,{encode:Tt.function,serialize:Tt.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),St.assertOptions(t,{baseUrl:Tt.spelling("baseURL"),withXsrfToken:Tt.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let a=i&&ue.merge(i.common,i[t.method]);i&&ue.forEach(["delete","get","head","post","put","patch","common"],e=>{delete i[e]}),t.headers=Ke.concat(a,i);const s=[];let o=!0;this.interceptors.request.forEach(function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,s.unshift(e.fulfilled,e.rejected))});const c=[];let u;this.interceptors.response.forEach(function(e){c.push(e.fulfilled,e.rejected)});let l,f=0;if(!o){const e=[mt.bind(this),void 0];for(e.unshift(...s),e.push(...c),l=e.length,u=Promise.resolve(t);f<l;)u=u.then(e[f++],e[f++]);return u}l=s.length;let p=t;for(;f<l;){const e=s[f++],t=s[f++];try{p=e(p)}catch(h){t.call(this,h);break}}try{u=mt.call(this,p)}catch(h){return Promise.reject(h)}for(f=0,l=c.length;f<l;)u=u.then(c[f++],c[f++]);return u}getUri(e){return Te(Ye((e=$e(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};ue.forEach(["delete","get","head","options"],function(e){bt.prototype[e]=function(t,r){return this.request($e(r||{},{method:e,url:t,data:(r||{}).data}))}}),ue.forEach(["post","put","patch"],function(e){function t(t){return function(r,n,i){return this.request($e(i||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}bt.prototype[e]=t(),bt.prototype[e+"Form"]=t(!0)});const At={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(At).forEach(([e,t])=>{At[t]=e});const It=function e(t){const r=new bt(t),n=S(bt.prototype.request,r);return ue.extend(n,bt.prototype,r,{allOwnKeys:!0}),ue.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e($e(t,r))},n}(Ue);It.Axios=bt,It.CanceledError=je,It.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise(function(e){t=e});const r=this;this.promise.then(e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null}),this.promise.then=e=>{let t;const n=new Promise(e=>{r.subscribe(e),t=e}).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e(function(e,n,i){r.reason||(r.reason=new je(e,n,i),t(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e(function(e){t=e}),cancel:t}}},It.isCancel=Fe,It.VERSION=vt,It.toFormData=me,It.AxiosError=le,It.Cancel=It.CanceledError,It.all=function(e){return Promise.all(e)},It.spread=function(e){return function(t){return e.apply(null,t)}},It.isAxiosError=function(e){return ue.isObject(e)&&!0===e.isAxiosError},It.mergeConfig=$e,It.AxiosHeaders=Ke,It.formToJSON=e=>Le(ue.isHTMLForm(e)?new FormData(e):e),It.getAdapter=gt,It.HttpStatusCode=At,It.default=It;const{Axios:Bt,AxiosError:wt,CanceledError:Nt,isCancel:_t,CancelToken:Rt,VERSION:kt,all:Lt,Cancel:Ut,isAxiosError:Dt,spread:Ot,toFormData:Pt,AxiosHeaders:xt,HttpStatusCode:Vt,formToJSON:Kt,getAdapter:Mt,mergeConfig:Ft}=It;class jt{constructor(e){this.int="string"==typeof e||"number"==typeof e||"bigint"==typeof e?BigInt(e):BigInt(e.toString())}add(e){return new jt(this.int+e.int)}increase(e){this.int+=e.int}toString(){return this.int.toString()}toNumber(){return Number(this.int)}toBigInt(){return this.int}toBigNum(){return n.BigNum.from_str(this.int.toString())}toJSON(){return this.int}}var qt,Ht,Gt=(e=>(e[e.Bech32=0]="Bech32",e[e.Email=1]="Email",e))(Gt||{});function zt(){return Ht?qt:(Ht=1,qt={options:{usePureJavaScript:!1}})}var Qt,Wt,Yt,Xt,$t,Jt={exports:{}};function Zt(){if(Yt)return Jt.exports;Yt=1;var e=zt(),t=function(){if(Wt)return Qt;Wt=1;var e={};Qt=e;var t={};return e.encode=function(e,t,r){if("string"!=typeof t)throw new TypeError('"alphabet" must be a string.');if(void 0!==r&&"number"!=typeof r)throw new TypeError('"maxline" must be a number.');var n="";if(e instanceof Uint8Array){var i=0,a=t.length,s=t.charAt(0),o=[0];for(i=0;i<e.length;++i){for(var c=0,u=e[i];c<o.length;++c)u+=o[c]<<8,o[c]=u%a,u=u/a|0;for(;u>0;)o.push(u%a),u=u/a|0}for(i=0;0===e[i]&&i<e.length-1;++i)n+=s;for(i=o.length-1;i>=0;--i)n+=t[o[i]]}else n=function(e,t){var r=0,n=t.length,i=t.charAt(0),a=[0];for(r=0;r<e.length();++r){for(var s=0,o=e.at(r);s<a.length;++s)o+=a[s]<<8,a[s]=o%n,o=o/n|0;for(;o>0;)a.push(o%n),o=o/n|0}var c="";for(r=0;0===e.at(r)&&r<e.length()-1;++r)c+=i;for(r=a.length-1;r>=0;--r)c+=t[a[r]];return c}(e,t);if(r){var l=new RegExp(".{1,"+r+"}","g");n=n.match(l).join("\r\n")}return n},e.decode=function(e,r){if("string"!=typeof e)throw new TypeError('"input" must be a string.');if("string"!=typeof r)throw new TypeError('"alphabet" must be a string.');var n=t[r];if(!n){n=t[r]=[];for(var i=0;i<r.length;++i)n[r.charCodeAt(i)]=i}e=e.replace(/\s/g,"");var a=r.length,s=r.charAt(0),o=[0];for(i=0;i<e.length;i++){var c=n[e.charCodeAt(i)];if(void 0===c)return;for(var u=0,l=c;u<o.length;++u)l+=o[u]*a,o[u]=255&l,l>>=8;for(;l>0;)o.push(255&l),l>>=8}for(var f=0;e[f]===s&&f<e.length-1;++f)o.push(0);return"undefined"!=typeof Buffer?Buffer.from(o.reverse()):new Uint8Array(o.reverse())},Qt}(),r=Jt.exports=e.util=e.util||{};function n(e){if(8!==e&&16!==e&&24!==e&&32!==e)throw new Error("Only 8, 16, 24, or 32 bits supported: "+e)}function i(e){if(this.data="",this.read=0,"string"==typeof e)this.data=e;else if(r.isArrayBuffer(e)||r.isArrayBufferView(e))if("undefined"!=typeof Buffer&&e instanceof Buffer)this.data=e.toString("binary");else{var t=new Uint8Array(e);try{this.data=String.fromCharCode.apply(null,t)}catch(a){for(var n=0;n<t.length;++n)this.putByte(t[n])}}else(e instanceof i||"object"==typeof e&&"string"==typeof e.data&&"number"==typeof e.read)&&(this.data=e.data,this.read=e.read);this._constructedStringLength=0}!function(){if("undefined"!=typeof process&&process.nextTick&&!process.browser)return r.nextTick=process.nextTick,void("function"==typeof setImmediate?r.setImmediate=setImmediate:r.setImmediate=r.nextTick);if("function"==typeof setImmediate)return r.setImmediate=function(){return setImmediate.apply(void 0,arguments)},void(r.nextTick=function(e){return setImmediate(e)});if(r.setImmediate=function(e){setTimeout(e,0)},"undefined"!=typeof window&&"function"==typeof window.postMessage){let n=function(r){if(r.source===window&&r.data===e){r.stopPropagation();var n=t.slice();t.length=0,n.forEach(function(e){e()})}};var e="forge.setImmediate",t=[];r.setImmediate=function(r){t.push(r),1===t.length&&window.postMessage(e,"*")},window.addEventListener("message",n,!0)}if("undefined"!=typeof MutationObserver){var n=Date.now(),i=!0,a=document.createElement("div");t=[];new MutationObserver(function(){var e=t.slice();t.length=0,e.forEach(function(e){e()})}).observe(a,{attributes:!0});var s=r.setImmediate;r.setImmediate=function(e){Date.now()-n>15?(n=Date.now(),s(e)):(t.push(e),1===t.length&&a.setAttribute("a",i=!i))}}r.nextTick=r.setImmediate}(),r.isNodejs="undefined"!=typeof process&&process.versions&&process.versions.node,r.globalScope=r.isNodejs?globalThis:"undefined"==typeof self?window:self,r.isArray=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},r.isArrayBuffer=function(e){return"undefined"!=typeof ArrayBuffer&&e instanceof ArrayBuffer},r.isArrayBufferView=function(e){return e&&r.isArrayBuffer(e.buffer)&&void 0!==e.byteLength},r.ByteBuffer=i,r.ByteStringBuffer=i;r.ByteStringBuffer.prototype._optimizeConstructedString=function(e){this._constructedStringLength+=e,this._constructedStringLength>4096&&(this.data.substr(0,1),this._constructedStringLength=0)},r.ByteStringBuffer.prototype.length=function(){return this.data.length-this.read},r.ByteStringBuffer.prototype.isEmpty=function(){return this.length()<=0},r.ByteStringBuffer.prototype.putByte=function(e){return this.putBytes(String.fromCharCode(e))},r.ByteStringBuffer.prototype.fillWithByte=function(e,t){e=String.fromCharCode(e);for(var r=this.data;t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return this.data=r,this._optimizeConstructedString(t),this},r.ByteStringBuffer.prototype.putBytes=function(e){return this.data+=e,this._optimizeConstructedString(e.length),this},r.ByteStringBuffer.prototype.putString=function(e){return this.putBytes(r.encodeUtf8(e))},r.ByteStringBuffer.prototype.putInt16=function(e){return this.putBytes(String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},r.ByteStringBuffer.prototype.putInt24=function(e){return this.putBytes(String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},r.ByteStringBuffer.prototype.putInt32=function(e){return this.putBytes(String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e))},r.ByteStringBuffer.prototype.putInt16Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255))},r.ByteStringBuffer.prototype.putInt24Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255))},r.ByteStringBuffer.prototype.putInt32Le=function(e){return this.putBytes(String.fromCharCode(255&e)+String.fromCharCode(e>>8&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>24&255))},r.ByteStringBuffer.prototype.putInt=function(e,t){n(t);var r="";do{t-=8,r+=String.fromCharCode(e>>t&255)}while(t>0);return this.putBytes(r)},r.ByteStringBuffer.prototype.putSignedInt=function(e,t){return e<0&&(e+=2<<t-1),this.putInt(e,t)},r.ByteStringBuffer.prototype.putBuffer=function(e){return this.putBytes(e.getBytes())},r.ByteStringBuffer.prototype.getByte=function(){return this.data.charCodeAt(this.read++)},r.ByteStringBuffer.prototype.getInt16=function(){var e=this.data.charCodeAt(this.read)<<8^this.data.charCodeAt(this.read+1);return this.read+=2,e},r.ByteStringBuffer.prototype.getInt24=function(){var e=this.data.charCodeAt(this.read)<<16^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2);return this.read+=3,e},r.ByteStringBuffer.prototype.getInt32=function(){var e=this.data.charCodeAt(this.read)<<24^this.data.charCodeAt(this.read+1)<<16^this.data.charCodeAt(this.read+2)<<8^this.data.charCodeAt(this.read+3);return this.read+=4,e},r.ByteStringBuffer.prototype.getInt16Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8;return this.read+=2,e},r.ByteStringBuffer.prototype.getInt24Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16;return this.read+=3,e},r.ByteStringBuffer.prototype.getInt32Le=function(){var e=this.data.charCodeAt(this.read)^this.data.charCodeAt(this.read+1)<<8^this.data.charCodeAt(this.read+2)<<16^this.data.charCodeAt(this.read+3)<<24;return this.read+=4,e},r.ByteStringBuffer.prototype.getInt=function(e){n(e);var t=0;do{t=(t<<8)+this.data.charCodeAt(this.read++),e-=8}while(e>0);return t},r.ByteStringBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},r.ByteStringBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},r.ByteStringBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},r.ByteStringBuffer.prototype.at=function(e){return this.data.charCodeAt(this.read+e)},r.ByteStringBuffer.prototype.setAt=function(e,t){return this.data=this.data.substr(0,this.read+e)+String.fromCharCode(t)+this.data.substr(this.read+e+1),this},r.ByteStringBuffer.prototype.last=function(){return this.data.charCodeAt(this.data.length-1)},r.ByteStringBuffer.prototype.copy=function(){var e=r.createBuffer(this.data);return e.read=this.read,e},r.ByteStringBuffer.prototype.compact=function(){return this.read>0&&(this.data=this.data.slice(this.read),this.read=0),this},r.ByteStringBuffer.prototype.clear=function(){return this.data="",this.read=0,this},r.ByteStringBuffer.prototype.truncate=function(e){var t=Math.max(0,this.length()-e);return this.data=this.data.substr(this.read,t),this.read=0,this},r.ByteStringBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.length;++t){var r=this.data.charCodeAt(t);r<16&&(e+="0"),e+=r.toString(16)}return e},r.ByteStringBuffer.prototype.toString=function(){return r.decodeUtf8(this.bytes())},r.DataBuffer=function(e,t){t=t||{},this.read=t.readOffset||0,this.growSize=t.growSize||1024;var n=r.isArrayBuffer(e),i=r.isArrayBufferView(e);if(n||i)return this.data=n?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),void(this.write="writeOffset"in t?t.writeOffset:this.data.byteLength);this.data=new DataView(new ArrayBuffer(0)),this.write=0,null!=e&&this.putBytes(e),"writeOffset"in t&&(this.write=t.writeOffset)},r.DataBuffer.prototype.length=function(){return this.write-this.read},r.DataBuffer.prototype.isEmpty=function(){return this.length()<=0},r.DataBuffer.prototype.accommodate=function(e,t){if(this.length()>=e)return this;t=Math.max(t||this.growSize,e);var r=new Uint8Array(this.data.buffer,this.data.byteOffset,this.data.byteLength),n=new Uint8Array(this.length()+t);return n.set(r),this.data=new DataView(n.buffer),this},r.DataBuffer.prototype.putByte=function(e){return this.accommodate(1),this.data.setUint8(this.write++,e),this},r.DataBuffer.prototype.fillWithByte=function(e,t){this.accommodate(t);for(var r=0;r<t;++r)this.data.setUint8(e);return this},r.DataBuffer.prototype.putBytes=function(e,t){if(r.isArrayBufferView(e)){var n=(i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)).byteLength-i.byteOffset;return this.accommodate(n),new Uint8Array(this.data.buffer,this.write).set(i),this.write+=n,this}if(r.isArrayBuffer(e)){var i=new Uint8Array(e);return this.accommodate(i.byteLength),new Uint8Array(this.data.buffer).set(i,this.write),this.write+=i.byteLength,this}if(e instanceof r.DataBuffer||"object"==typeof e&&"number"==typeof e.read&&"number"==typeof e.write&&r.isArrayBufferView(e.data)){i=new Uint8Array(e.data.byteLength,e.read,e.length());return this.accommodate(i.byteLength),new Uint8Array(e.data.byteLength,this.write).set(i),this.write+=i.byteLength,this}if(e instanceof r.ByteStringBuffer&&(e=e.data,t="binary"),t=t||"binary","string"==typeof e){var a;if("hex"===t)return this.accommodate(Math.ceil(e.length/2)),a=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.hex.decode(e,a,this.write),this;if("base64"===t)return this.accommodate(3*Math.ceil(e.length/4)),a=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.base64.decode(e,a,this.write),this;if("utf8"===t&&(e=r.encodeUtf8(e),t="binary"),"binary"===t||"raw"===t)return this.accommodate(e.length),a=new Uint8Array(this.data.buffer,this.write),this.write+=r.binary.raw.decode(a),this;if("utf16"===t)return this.accommodate(2*e.length),a=new Uint16Array(this.data.buffer,this.write),this.write+=r.text.utf16.encode(a),this;throw new Error("Invalid encoding: "+t)}throw Error("Invalid parameter: "+e)},r.DataBuffer.prototype.putBuffer=function(e){return this.putBytes(e),e.clear(),this},r.DataBuffer.prototype.putString=function(e){return this.putBytes(e,"utf16")},r.DataBuffer.prototype.putInt16=function(e){return this.accommodate(2),this.data.setInt16(this.write,e),this.write+=2,this},r.DataBuffer.prototype.putInt24=function(e){return this.accommodate(3),this.data.setInt16(this.write,e>>8&65535),this.data.setInt8(this.write,e>>16&255),this.write+=3,this},r.DataBuffer.prototype.putInt32=function(e){return this.accommodate(4),this.data.setInt32(this.write,e),this.write+=4,this},r.DataBuffer.prototype.putInt16Le=function(e){return this.accommodate(2),this.data.setInt16(this.write,e,!0),this.write+=2,this},r.DataBuffer.prototype.putInt24Le=function(e){return this.accommodate(3),this.data.setInt8(this.write,e>>16&255),this.data.setInt16(this.write,e>>8&65535,!0),this.write+=3,this},r.DataBuffer.prototype.putInt32Le=function(e){return this.accommodate(4),this.data.setInt32(this.write,e,!0),this.write+=4,this},r.DataBuffer.prototype.putInt=function(e,t){n(t),this.accommodate(t/8);do{t-=8,this.data.setInt8(this.write++,e>>t&255)}while(t>0);return this},r.DataBuffer.prototype.putSignedInt=function(e,t){return n(t),this.accommodate(t/8),e<0&&(e+=2<<t-1),this.putInt(e,t)},r.DataBuffer.prototype.getByte=function(){return this.data.getInt8(this.read++)},r.DataBuffer.prototype.getInt16=function(){var e=this.data.getInt16(this.read);return this.read+=2,e},r.DataBuffer.prototype.getInt24=function(){var e=this.data.getInt16(this.read)<<8^this.data.getInt8(this.read+2);return this.read+=3,e},r.DataBuffer.prototype.getInt32=function(){var e=this.data.getInt32(this.read);return this.read+=4,e},r.DataBuffer.prototype.getInt16Le=function(){var e=this.data.getInt16(this.read,!0);return this.read+=2,e},r.DataBuffer.prototype.getInt24Le=function(){var e=this.data.getInt8(this.read)^this.data.getInt16(this.read+1,!0)<<8;return this.read+=3,e},r.DataBuffer.prototype.getInt32Le=function(){var e=this.data.getInt32(this.read,!0);return this.read+=4,e},r.DataBuffer.prototype.getInt=function(e){n(e);var t=0;do{t=(t<<8)+this.data.getInt8(this.read++),e-=8}while(e>0);return t},r.DataBuffer.prototype.getSignedInt=function(e){var t=this.getInt(e),r=2<<e-2;return t>=r&&(t-=r<<1),t},r.DataBuffer.prototype.getBytes=function(e){var t;return e?(e=Math.min(this.length(),e),t=this.data.slice(this.read,this.read+e),this.read+=e):0===e?t="":(t=0===this.read?this.data:this.data.slice(this.read),this.clear()),t},r.DataBuffer.prototype.bytes=function(e){return void 0===e?this.data.slice(this.read):this.data.slice(this.read,this.read+e)},r.DataBuffer.prototype.at=function(e){return this.data.getUint8(this.read+e)},r.DataBuffer.prototype.setAt=function(e,t){return this.data.setUint8(e,t),this},r.DataBuffer.prototype.last=function(){return this.data.getUint8(this.write-1)},r.DataBuffer.prototype.copy=function(){return new r.DataBuffer(this)},r.DataBuffer.prototype.compact=function(){if(this.read>0){var e=new Uint8Array(this.data.buffer,this.read),t=new Uint8Array(e.byteLength);t.set(e),this.data=new DataView(t),this.write-=this.read,this.read=0}return this},r.DataBuffer.prototype.clear=function(){return this.data=new DataView(new ArrayBuffer(0)),this.read=this.write=0,this},r.DataBuffer.prototype.truncate=function(e){return this.write=Math.max(0,this.length()-e),this.read=Math.min(this.read,this.write),this},r.DataBuffer.prototype.toHex=function(){for(var e="",t=this.read;t<this.data.byteLength;++t){var r=this.data.getUint8(t);r<16&&(e+="0"),e+=r.toString(16)}return e},r.DataBuffer.prototype.toString=function(e){var t=new Uint8Array(this.data,this.read,this.length());if("binary"===(e=e||"utf8")||"raw"===e)return r.binary.raw.encode(t);if("hex"===e)return r.binary.hex.encode(t);if("base64"===e)return r.binary.base64.encode(t);if("utf8"===e)return r.text.utf8.decode(t);if("utf16"===e)return r.text.utf16.decode(t);throw new Error("Invalid encoding: "+e)},r.createBuffer=function(e,t){return t=t||"raw",void 0!==e&&"utf8"===t&&(e=r.encodeUtf8(e)),new r.ByteBuffer(e)},r.fillString=function(e,t){for(var r="";t>0;)1&t&&(r+=e),(t>>>=1)>0&&(e+=e);return r},r.xorBytes=function(e,t,r){for(var n="",i="",a="",s=0,o=0;r>0;--r,++s)i=e.charCodeAt(s)^t.charCodeAt(s),o>=10&&(n+=a,a="",o=0),a+=String.fromCharCode(i),++o;return n+=a},r.hexToBytes=function(e){var t="",r=0;for(!0&e.length&&(r=1,t+=String.fromCharCode(parseInt(e[0],16)));r<e.length;r+=2)t+=String.fromCharCode(parseInt(e.substr(r,2),16));return t},r.bytesToHex=function(e){return r.createBuffer(e).toHex()},r.int32ToBytes=function(e){return String.fromCharCode(e>>24&255)+String.fromCharCode(e>>16&255)+String.fromCharCode(e>>8&255)+String.fromCharCode(255&e)};var a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",s=[62,-1,-1,-1,63,52,53,54,55,56,57,58,59,60,61,-1,-1,-1,64,-1,-1,-1,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1,-1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51],o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";r.encode64=function(e,t){for(var r,n,i,s="",o="",c=0;c<e.length;)r=e.charCodeAt(c++),n=e.charCodeAt(c++),i=e.charCodeAt(c++),s+=a.charAt(r>>2),s+=a.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=a.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":a.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},r.decode64=function(e){e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var t,r,n,i,a="",o=0;o<e.length;)t=s[e.charCodeAt(o++)-43],r=s[e.charCodeAt(o++)-43],n=s[e.charCodeAt(o++)-43],i=s[e.charCodeAt(o++)-43],a+=String.fromCharCode(t<<2|r>>4),64!==n&&(a+=String.fromCharCode((15&r)<<4|n>>2),64!==i&&(a+=String.fromCharCode((3&n)<<6|i)));return a},r.encodeUtf8=function(e){return unescape(encodeURIComponent(e))},r.decodeUtf8=function(e){return decodeURIComponent(escape(e))},r.binary={raw:{},hex:{},base64:{},base58:{},baseN:{encode:t.encode,decode:t.decode}},r.binary.raw.encode=function(e){return String.fromCharCode.apply(null,e)},r.binary.raw.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(e.length));for(var i=r=r||0,a=0;a<e.length;++a)n[i++]=e.charCodeAt(a);return t?i-r:n},r.binary.hex.encode=r.bytesToHex,r.binary.hex.decode=function(e,t,r){var n=t;n||(n=new Uint8Array(Math.ceil(e.length/2)));var i=0,a=r=r||0;for(1&e.length&&(i=1,n[a++]=parseInt(e[0],16));i<e.length;i+=2)n[a++]=parseInt(e.substr(i,2),16);return t?a-r:n},r.binary.base64.encode=function(e,t){for(var r,n,i,s="",o="",c=0;c<e.byteLength;)r=e[c++],n=e[c++],i=e[c++],s+=a.charAt(r>>2),s+=a.charAt((3&r)<<4|n>>4),isNaN(n)?s+="==":(s+=a.charAt((15&n)<<2|i>>6),s+=isNaN(i)?"=":a.charAt(63&i)),t&&s.length>t&&(o+=s.substr(0,t)+"\r\n",s=s.substr(t));return o+=s},r.binary.base64.decode=function(e,t,r){var n,i,a,o,c=t;c||(c=new Uint8Array(3*Math.ceil(e.length/4))),e=e.replace(/[^A-Za-z0-9\+\/\=]/g,"");for(var u=0,l=r=r||0;u<e.length;)n=s[e.charCodeAt(u++)-43],i=s[e.charCodeAt(u++)-43],a=s[e.charCodeAt(u++)-43],o=s[e.charCodeAt(u++)-43],c[l++]=n<<2|i>>4,64!==a&&(c[l++]=(15&i)<<4|a>>2,64!==o&&(c[l++]=(3&a)<<6|o));return t?l-r:c.subarray(0,l)},r.binary.base58.encode=function(e,t){return r.binary.baseN.encode(e,o,t)},r.binary.base58.decode=function(e,t){return r.binary.baseN.decode(e,o,t)},r.text={utf8:{},utf16:{}},r.text.utf8.encode=function(e,t,n){e=r.encodeUtf8(e);var i=t;i||(i=new Uint8Array(e.length));for(var a=n=n||0,s=0;s<e.length;++s)i[a++]=e.charCodeAt(s);return t?a-n:i},r.text.utf8.decode=function(e){return r.decodeUtf8(String.fromCharCode.apply(null,e))},r.text.utf16.encode=function(e,t,r){var n=t;n||(n=new Uint8Array(2*e.length));for(var i=new Uint16Array(n.buffer),a=r=r||0,s=r,o=0;o<e.length;++o)i[s++]=e.charCodeAt(o),a+=2;return t?a-r:n},r.text.utf16.decode=function(e){return String.fromCharCode.apply(null,new Uint16Array(e.buffer))},r.deflate=function(e,t,n){if(t=r.decode64(e.deflate(r.encode64(t)).rval),n){var i=2;32&t.charCodeAt(1)&&(i=6),t=t.substring(i,t.length-4)}return t},r.inflate=function(e,t,n){var i=e.inflate(r.encode64(t)).rval;return null===i?null:r.decode64(i)};var c=function(e,t,n){if(!e)throw new Error("WebStorage not available.");var i;if(null===n?i=e.removeItem(t):(n=r.encode64(JSON.stringify(n)),i=e.setItem(t,n)),void 0!==i&&!0!==i.rval){var a=new Error(i.error.message);throw a.id=i.error.id,a.name=i.error.name,a}},u=function(e,t){if(!e)throw new Error("WebStorage not available.");var n=e.getItem(t);if(e.init)if(null===n.rval){if(n.error){var i=new Error(n.error.message);throw i.id=n.error.id,i.name=n.error.name,i}n=null}else n=n.rval;return null!==n&&(n=JSON.parse(r.decode64(n))),n},l=function(e,t,r,n){var i=u(e,t);null===i&&(i={}),i[r]=n,c(e,t,i)},f=function(e,t,r){var n=u(e,t);return null!==n&&(n=r in n?n[r]:null),n},p=function(e,t,r){var n=u(e,t);if(null!==n&&r in n){delete n[r];var i=!0;for(var a in n){i=!1;break}i&&(n=null),c(e,t,n)}},h=function(e,t){c(e,t,null)},d=function(e,t,r){var n,i=null;void 0===r&&(r=["web","flash"]);var a=!1,s=null;for(var o in r){n=r[o];try{if("flash"===n||"both"===n){if(null===t[0])throw new Error("Flash local storage not available.");i=e.apply(this,t),a="flash"===n}"web"!==n&&"both"!==n||(t[0]=localStorage,i=e.apply(this,t),a=!0)}catch(c){s=c}if(a)break}if(!a)throw s;return i};return r.setItem=function(e,t,r,n,i){d(l,arguments,i)},r.getItem=function(e,t,r,n){return d(f,arguments,n)},r.removeItem=function(e,t,r,n){d(p,arguments,n)},r.clearItems=function(e,t,r){d(h,arguments,r)},r.isEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},r.format=function(e){for(var t,r,n=/%./g,i=0,a=[],s=0;t=n.exec(e);){(r=e.substring(s,n.lastIndex-2)).length>0&&a.push(r),s=n.lastIndex;var o=t[0][1];switch(o){case"s":case"o":i<arguments.length?a.push(arguments[1+i++]):a.push("<?>");break;case"%":a.push("%");break;default:a.push("<%"+o+"?>")}}return a.push(e.substring(s)),a.join("")},r.formatNumber=function(e,t,r,n){var i=e,a=isNaN(t=Math.abs(t))?2:t,s=void 0===r?",":r,o=void 0===n?".":n,c=i<0?"-":"",u=parseInt(i=Math.abs(+i||0).toFixed(a),10)+"",l=u.length>3?u.length%3:0;return c+(l?u.substr(0,l)+o:"")+u.substr(l).replace(/(\d{3})(?=\d)/g,"$1"+o)+(a?s+Math.abs(i-u).toFixed(a).slice(2):"")},r.formatSize=function(e){return e=e>=1073741824?r.formatNumber(e/1073741824,2,".","")+" GiB":e>=1048576?r.formatNumber(e/1048576,2,".","")+" MiB":e>=1024?r.formatNumber(e/1024,0)+" KiB":r.formatNumber(e,0)+" bytes"},r.bytesFromIP=function(e){return-1!==e.indexOf(".")?r.bytesFromIPv4(e):-1!==e.indexOf(":")?r.bytesFromIPv6(e):null},r.bytesFromIPv4=function(e){if(4!==(e=e.split(".")).length)return null;for(var t=r.createBuffer(),n=0;n<e.length;++n){var i=parseInt(e[n],10);if(isNaN(i))return null;t.putByte(i)}return t.getBytes()},r.bytesFromIPv6=function(e){for(var t=0,n=2*(8-(e=e.split(":").filter(function(e){return 0===e.length&&++t,!0})).length+t),i=r.createBuffer(),a=0;a<8;++a)if(e[a]&&0!==e[a].length){var s=r.hexToBytes(e[a]);s.length<2&&i.putByte(0),i.putBytes(s)}else i.fillWithByte(0,n),n=0;return i.getBytes()},r.bytesToIP=function(e){return 4===e.length?r.bytesToIPv4(e):16===e.length?r.bytesToIPv6(e):null},r.bytesToIPv4=function(e){if(4!==e.length)return null;for(var t=[],r=0;r<e.length;++r)t.push(e.charCodeAt(r));return t.join(".")},r.bytesToIPv6=function(e){if(16!==e.length)return null;for(var t=[],n=[],i=0,a=0;a<e.length;a+=2){for(var s=r.bytesToHex(e[a]+e[a+1]);"0"===s[0]&&"0"!==s;)s=s.substr(1);if("0"===s){var o=n[n.length-1],c=t.length;o&&c===o.end+1?(o.end=c,o.end-o.start>n[i].end-n[i].start&&(i=n.length-1)):n.push({start:c,end:c})}t.push(s)}if(n.length>0){var u=n[i];u.end-u.start>0&&(t.splice(u.start,u.end-u.start+1,""),0===u.start&&t.unshift(""),7===u.end&&t.push(""))}return t.join(":")},r.estimateCores=function(e,t){if("function"==typeof e&&(t=e,e={}),e=e||{},"cores"in r&&!e.update)return t(null,r.cores);if("undefined"!=typeof navigator&&"hardwareConcurrency"in navigator&&navigator.hardwareConcurrency>0)return r.cores=navigator.hardwareConcurrency,t(null,r.cores);if("undefined"==typeof Worker)return r.cores=1,t(null,r.cores);if("undefined"==typeof Blob)return r.cores=2,t(null,r.cores);var n=URL.createObjectURL(new Blob(["(",function(){self.addEventListener("message",function(e){var t=Date.now(),r=t+4;self.postMessage({st:t,et:r})})}.toString(),")()"],{type:"application/javascript"}));!function e(i,a,s){if(0===a){var o=Math.floor(i.reduce(function(e,t){return e+t},0)/i.length);return r.cores=Math.max(1,o),URL.revokeObjectURL(n),t(null,r.cores)}!function(e,t){for(var r=[],i=[],a=0;a<e;++a){var s=new Worker(n);s.addEventListener("message",function(n){if(i.push(n.data),i.length===e){for(var a=0;a<e;++a)r[a].terminate();t(null,i)}}),r.push(s)}for(a=0;a<e;++a)r[a].postMessage(a)}(s,function(t,r){i.push(function(e,t){for(var r=[],n=0;n<e;++n)for(var i=t[n],a=r[n]=[],s=0;s<e;++s)if(n!==s){var o=t[s];(i.st>o.st&&i.st<o.et||o.st>i.st&&o.st<i.et)&&a.push(s)}return r.reduce(function(e,t){return Math.max(e,t.length)},0)}(s,r)),e(i,a-1,s)})}([],5,16)},Jt.exports}function er(){if($t)return Xt;$t=1;var e=zt();Zt(),Xt=e.cipher=e.cipher||{},e.cipher.algorithms=e.cipher.algorithms||{},e.cipher.createCipher=function(t,r){var n=t;if("string"==typeof n&&(n=e.cipher.getAlgorithm(n))&&(n=n()),!n)throw new Error("Unsupported algorithm: "+t);return new e.cipher.BlockCipher({algorithm:n,key:r,decrypt:!1})},e.cipher.createDecipher=function(t,r){var n=t;if("string"==typeof n&&(n=e.cipher.getAlgorithm(n))&&(n=n()),!n)throw new Error("Unsupported algorithm: "+t);return new e.cipher.BlockCipher({algorithm:n,key:r,decrypt:!0})},e.cipher.registerAlgorithm=function(t,r){t=t.toUpperCase(),e.cipher.algorithms[t]=r},e.cipher.getAlgorithm=function(t){return(t=t.toUpperCase())in e.cipher.algorithms?e.cipher.algorithms[t]:null};var t=e.cipher.BlockCipher=function(e){this.algorithm=e.algorithm,this.mode=this.algorithm.mode,this.blockSize=this.mode.blockSize,this._finish=!1,this._input=null,this.output=null,this._op=e.decrypt?this.mode.decrypt:this.mode.encrypt,this._decrypt=e.decrypt,this.algorithm.initialize(e)};return t.prototype.start=function(t){t=t||{};var r={};for(var n in t)r[n]=t[n];r.decrypt=this._decrypt,this._finish=!1,this._input=e.util.createBuffer(),this.output=t.output||e.util.createBuffer(),this.mode.start(r)},t.prototype.update=function(e){for(e&&this._input.putBuffer(e);!this._op.call(this.mode,this._input,this.output,this._finish)&&!this._finish;);this._input.compact()},t.prototype.finish=function(e){!e||"ECB"!==this.mode.name&&"CBC"!==this.mode.name||(this.mode.pad=function(t){return e(this.blockSize,t,!1)},this.mode.unpad=function(t){return e(this.blockSize,t,!0)});var t={};return t.decrypt=this._decrypt,t.overflow=this._input.length()%this.blockSize,!(!this._decrypt&&this.mode.pad&&!this.mode.pad(this._input,t))&&(this._finish=!0,this.update(),!(this._decrypt&&this.mode.unpad&&!this.mode.unpad(this.output,t))&&!(this.mode.afterFinish&&!this.mode.afterFinish(this.output,t)))},Xt}var tr,rr,nr,ir={exports:{}};function ar(){if(tr)return ir.exports;tr=1;var e=zt();Zt(),e.cipher=e.cipher||{};var t=ir.exports=e.cipher.modes=e.cipher.modes||{};function r(t,r){if("string"==typeof t&&(t=e.util.createBuffer(t)),e.util.isArray(t)&&t.length>4){var n=t;t=e.util.createBuffer();for(var i=0;i<n.length;++i)t.putByte(n[i])}if(t.length()<r)throw new Error("Invalid IV length; got "+t.length()+" bytes and expected "+r+" bytes.");if(!e.util.isArray(t)){var a=[],s=r/4;for(i=0;i<s;++i)a.push(t.getInt32());t=a}return t}function n(e){e[e.length-1]=e[e.length-1]+1&4294967295}function i(e){return[e/4294967296|0,4294967295&e]}return t.ecb=function(e){e=e||{},this.name="ECB",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.ecb.prototype.start=function(e){},t.ecb.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n])},t.ecb.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.ecb.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},t.cbc=function(e){e=e||{},this.name="CBC",this.cipher=e.cipher,this.blockSize=e.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints)},t.cbc.prototype.start=function(e){if(null===e.iv){if(!this._prev)throw new Error("Invalid IV parameter.");this._iv=this._prev.slice(0)}else{if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._prev=this._iv.slice(0)}},t.cbc.prototype.encrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=this._prev[n]^e.getInt32();this.cipher.encrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._outBlock[n]);this._prev=this._outBlock},t.cbc.prototype.decrypt=function(e,t,r){if(e.length()<this.blockSize&&!(r&&e.length()>0))return!0;for(var n=0;n<this._ints;++n)this._inBlock[n]=e.getInt32();this.cipher.decrypt(this._inBlock,this._outBlock);for(n=0;n<this._ints;++n)t.putInt32(this._prev[n]^this._outBlock[n]);this._prev=this._inBlock.slice(0)},t.cbc.prototype.pad=function(e,t){var r=e.length()===this.blockSize?this.blockSize:this.blockSize-e.length();return e.fillWithByte(r,r),!0},t.cbc.prototype.unpad=function(e,t){if(t.overflow>0)return!1;var r=e.length(),n=e.at(r-1);return!(n>this.blockSize<<2)&&(e.truncate(n),!0)},t.cfb=function(t){t=t||{},this.name="CFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialBlock=new Array(this._ints),this._partialOutput=e.util.createBuffer(),this._partialBytes=0},t.cfb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.cfb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32()^this._outBlock[i],t.putInt32(this._inBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32()^this._outBlock[i],this._partialOutput.putInt32(this._partialBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.cfb.prototype.decrypt=function(e,t,r){var n=e.length();if(0===n)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)this._inBlock[i]=e.getInt32(),t.putInt32(this._inBlock[i]^this._outBlock[i]);else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialBlock[i]=e.getInt32(),this._partialOutput.putInt32(this._partialBlock[i]^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._partialBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb=function(t){t=t||{},this.name="OFB",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=e.util.createBuffer(),this._partialBytes=0},t.ofb.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ofb.prototype.encrypt=function(e,t,r){var n=e.length();if(0===e.length())return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&n>=this.blockSize)for(var i=0;i<this._ints;++i)t.putInt32(e.getInt32()^this._outBlock[i]),this._inBlock[i]=this._outBlock[i];else{var a=(this.blockSize-n)%this.blockSize;a>0&&(a=this.blockSize-a),this._partialOutput.clear();for(i=0;i<this._ints;++i)this._partialOutput.putInt32(e.getInt32()^this._outBlock[i]);if(a>0)e.read-=this.blockSize;else for(i=0;i<this._ints;++i)this._inBlock[i]=this._outBlock[i];if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),a>0&&!r)return t.putBytes(this._partialOutput.getBytes(a-this._partialBytes)),this._partialBytes=a,!0;t.putBytes(this._partialOutput.getBytes(n-this._partialBytes)),this._partialBytes=0}},t.ofb.prototype.decrypt=t.ofb.prototype.encrypt,t.ctr=function(t){t=t||{},this.name="CTR",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=null,this._outBlock=new Array(this._ints),this._partialOutput=e.util.createBuffer(),this._partialBytes=0},t.ctr.prototype.start=function(e){if(!("iv"in e))throw new Error("Invalid IV parameter.");this._iv=r(e.iv,this.blockSize),this._inBlock=this._iv.slice(0),this._partialBytes=0},t.ctr.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize)for(var a=0;a<this._ints;++a)t.putInt32(e.getInt32()^this._outBlock[a]);else{var s=(this.blockSize-i)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(s>0&&(e.read-=this.blockSize),this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}n(this._inBlock)},t.ctr.prototype.decrypt=t.ctr.prototype.encrypt,t.gcm=function(t){t=t||{},this.name="GCM",this.cipher=t.cipher,this.blockSize=t.blockSize||16,this._ints=this.blockSize/4,this._inBlock=new Array(this._ints),this._outBlock=new Array(this._ints),this._partialOutput=e.util.createBuffer(),this._partialBytes=0,this._R=3774873600},t.gcm.prototype.start=function(t){if(!("iv"in t))throw new Error("Invalid IV parameter.");var r,a=e.util.createBuffer(t.iv);if(this._cipherLength=0,r="additionalData"in t?e.util.createBuffer(t.additionalData):e.util.createBuffer(),this._tagLength="tagLength"in t?t.tagLength:128,this._tag=null,t.decrypt&&(this._tag=e.util.createBuffer(t.tag).getBytes(),this._tag.length!==this._tagLength/8))throw new Error("Authentication tag does not match tag length.");this._hashBlock=new Array(this._ints),this.tag=null,this._hashSubkey=new Array(this._ints),this.cipher.encrypt([0,0,0,0],this._hashSubkey),this.componentBits=4,this._m=this.generateHashTable(this._hashSubkey,this.componentBits);var s=a.length();if(12===s)this._j0=[a.getInt32(),a.getInt32(),a.getInt32(),1];else{for(this._j0=[0,0,0,0];a.length()>0;)this._j0=this.ghash(this._hashSubkey,this._j0,[a.getInt32(),a.getInt32(),a.getInt32(),a.getInt32()]);this._j0=this.ghash(this._hashSubkey,this._j0,[0,0].concat(i(8*s)))}this._inBlock=this._j0.slice(0),n(this._inBlock),this._partialBytes=0,r=e.util.createBuffer(r),this._aDataLength=i(8*r.length());var o=r.length()%this.blockSize;for(o&&r.fillWithByte(0,this.blockSize-o),this._s=[0,0,0,0];r.length()>0;)this._s=this.ghash(this._hashSubkey,this._s,[r.getInt32(),r.getInt32(),r.getInt32(),r.getInt32()])},t.gcm.prototype.encrypt=function(e,t,r){var i=e.length();if(0===i)return!0;if(this.cipher.encrypt(this._inBlock,this._outBlock),0===this._partialBytes&&i>=this.blockSize){for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^=e.getInt32());this._cipherLength+=this.blockSize}else{var s=(this.blockSize-i)%this.blockSize;s>0&&(s=this.blockSize-s),this._partialOutput.clear();for(a=0;a<this._ints;++a)this._partialOutput.putInt32(e.getInt32()^this._outBlock[a]);if(s<=0||r){if(r){var o=i%this.blockSize;this._cipherLength+=o,this._partialOutput.truncate(this.blockSize-o)}else this._cipherLength+=this.blockSize;for(a=0;a<this._ints;++a)this._outBlock[a]=this._partialOutput.getInt32();this._partialOutput.read-=this.blockSize}if(this._partialBytes>0&&this._partialOutput.getBytes(this._partialBytes),s>0&&!r)return e.read-=this.blockSize,t.putBytes(this._partialOutput.getBytes(s-this._partialBytes)),this._partialBytes=s,!0;t.putBytes(this._partialOutput.getBytes(i-this._partialBytes)),this._partialBytes=0}this._s=this.ghash(this._hashSubkey,this._s,this._outBlock),n(this._inBlock)},t.gcm.prototype.decrypt=function(e,t,r){var i=e.length();if(i<this.blockSize&&!(r&&i>0))return!0;this.cipher.encrypt(this._inBlock,this._outBlock),n(this._inBlock),this._hashBlock[0]=e.getInt32(),this._hashBlock[1]=e.getInt32(),this._hashBlock[2]=e.getInt32(),this._hashBlock[3]=e.getInt32(),this._s=this.ghash(this._hashSubkey,this._s,this._hashBlock);for(var a=0;a<this._ints;++a)t.putInt32(this._outBlock[a]^this._hashBlock[a]);i<this.blockSize?this._cipherLength+=i%this.blockSize:this._cipherLength+=this.blockSize},t.gcm.prototype.afterFinish=function(t,r){var n=!0;r.decrypt&&r.overflow&&t.truncate(this.blockSize-r.overflow),this.tag=e.util.createBuffer();var a=this._aDataLength.concat(i(8*this._cipherLength));this._s=this.ghash(this._hashSubkey,this._s,a);var s=[];this.cipher.encrypt(this._j0,s);for(var o=0;o<this._ints;++o)this.tag.putInt32(this._s[o]^s[o]);return this.tag.truncate(this.tag.length()%(this._tagLength/8)),r.decrypt&&this.tag.bytes()!==this._tag&&(n=!1),n},t.gcm.prototype.multiply=function(e,t){for(var r=[0,0,0,0],n=t.slice(0),i=0;i<128;++i){e[i/32|0]&1<<31-i%32&&(r[0]^=n[0],r[1]^=n[1],r[2]^=n[2],r[3]^=n[3]),this.pow(n,n)}return r},t.gcm.prototype.pow=function(e,t){for(var r=1&e[3],n=3;n>0;--n)t[n]=e[n]>>>1|(1&e[n-1])<<31;t[0]=e[0]>>>1,r&&(t[0]^=this._R)},t.gcm.prototype.tableMultiply=function(e){for(var t=[0,0,0,0],r=0;r<32;++r){var n=e[r/8|0]>>>4*(7-r%8)&15,i=this._m[r][n];t[0]^=i[0],t[1]^=i[1],t[2]^=i[2],t[3]^=i[3]}return t},t.gcm.prototype.ghash=function(e,t,r){return t[0]^=r[0],t[1]^=r[1],t[2]^=r[2],t[3]^=r[3],this.tableMultiply(t)},t.gcm.prototype.generateHashTable=function(e,t){for(var r=8/t,n=4*r,i=16*r,a=new Array(i),s=0;s<i;++s){var o=[0,0,0,0],c=(n-1-s%n)*t;o[s/n|0]=1<<t-1<<c,a[s]=this.generateSubHashTable(this.multiply(o,e),t)}return a},t.gcm.prototype.generateSubHashTable=function(e,t){var r=1<<t,n=r>>>1,i=new Array(r);i[n]=e.slice(0);for(var a=n>>>1;a>0;)this.pow(i[2*a],i[a]=[]),a>>=1;for(a=2;a<n;){for(var s=1;s<a;++s){var o=i[a],c=i[s];i[a+s]=[o[0]^c[0],o[1]^c[1],o[2]^c[2],o[3]^c[3]]}a*=2}for(i[0]=[0,0,0,0],a=n+1;a<r;++a){var u=i[a^n];i[a]=[e[0]^u[0],e[1]^u[1],e[2]^u[2],e[3]^u[3]]}return i},ir.exports}function sr(){if(nr)return rr;nr=1;var e=zt();function t(t,r){e.cipher.registerAlgorithm(t,function(){return new e.aes.Algorithm(t,r)})}er(),ar(),Zt(),rr=e.aes=e.aes||{},e.aes.startEncrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!1,mode:n});return i.start(t),i},e.aes.createEncryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!1,mode:t})},e.aes.startDecrypting=function(e,t,r,n){var i=p({key:e,output:r,decrypt:!0,mode:n});return i.start(t),i},e.aes.createDecryptionCipher=function(e,t){return p({key:e,output:null,decrypt:!0,mode:t})},e.aes.Algorithm=function(e,t){o||u();var r=this;r.name=e,r.mode=new t({blockSize:16,cipher:{encrypt:function(e,t){return f(r._w,e,t,!1)},decrypt:function(e,t){return f(r._w,e,t,!0)}}}),r._init=!1},e.aes.Algorithm.prototype.initialize=function(t){if(!this._init){var r,n=t.key;if("string"!=typeof n||16!==n.length&&24!==n.length&&32!==n.length){if(e.util.isArray(n)&&(16===n.length||24===n.length||32===n.length)){r=n,n=e.util.createBuffer();for(var i=0;i<r.length;++i)n.putByte(r[i])}}else n=e.util.createBuffer(n);if(!e.util.isArray(n)){r=n,n=[];var a=r.length();if(16===a||24===a||32===a){a>>>=2;for(i=0;i<a;++i)n.push(r.getInt32())}}if(!e.util.isArray(n)||4!==n.length&&6!==n.length&&8!==n.length)throw new Error("Invalid key parameter.");var s=this.mode.name,o=-1!==["CFB","OFB","CTR","GCM"].indexOf(s);this._w=l(n,t.decrypt&&!o),this._init=!0}},e.aes._expandKey=function(e,t){return o||u(),l(e,t)},e.aes._updateBlock=f,t("AES-ECB",e.cipher.modes.ecb),t("AES-CBC",e.cipher.modes.cbc),t("AES-CFB",e.cipher.modes.cfb),t("AES-OFB",e.cipher.modes.ofb),t("AES-CTR",e.cipher.modes.ctr),t("AES-GCM",e.cipher.modes.gcm);var r,n,i,a,s,o=!1,c=4;function u(){o=!0,i=[0,1,2,4,8,16,32,64,128,27,54];for(var e=new Array(256),t=0;t<128;++t)e[t]=t<<1,e[t+128]=t+128<<1^283;r=new Array(256),n=new Array(256),a=new Array(4),s=new Array(4);for(t=0;t<4;++t)a[t]=new Array(256),s[t]=new Array(256);var c,u,l,f,p,h,d,g=0,y=0;for(t=0;t<256;++t){f=(f=y^y<<1^y<<2^y<<3^y<<4)>>8^255&f^99,r[g]=f,n[f]=g,h=(p=e[f])<<24^f<<16^f<<8^f^p,d=((c=e[g])^(u=e[c])^(l=e[u]))<<24^(g^l)<<16^(g^u^l)<<8^g^c^l;for(var m=0;m<4;++m)a[m][g]=h,s[m][f]=d,h=h<<24|h>>>8,d=d<<24|d>>>8;0===g?g=y=1:(g=c^e[e[e[c^l]]],y^=e[e[y]])}}function l(e,t){for(var n,a=e.slice(0),o=1,u=a.length,l=c*(u+6+1),f=u;f<l;++f)n=a[f-1],f%u===0?(n=r[n>>>16&255]<<24^r[n>>>8&255]<<16^r[255&n]<<8^r[n>>>24]^i[o]<<24,o++):u>6&&f%u===4&&(n=r[n>>>24]<<24^r[n>>>16&255]<<16^r[n>>>8&255]<<8^r[255&n]),a[f]=a[f-u]^n;if(t){for(var p,h=s[0],d=s[1],g=s[2],y=s[3],m=a.slice(0),v=(f=0,(l=a.length)-c);f<l;f+=c,v-=c)if(0===f||f===l-c)m[f]=a[v],m[f+1]=a[v+3],m[f+2]=a[v+2],m[f+3]=a[v+1];else for(var C=0;C<c;++C)p=a[v+C],m[f+(3&-C)]=h[r[p>>>24]]^d[r[p>>>16&255]]^g[r[p>>>8&255]]^y[r[255&p]];a=m}return a}function f(e,t,i,o){var c,u,l,f,p,h,d,g,y,m,v,C,E=e.length/4-1;o?(c=s[0],u=s[1],l=s[2],f=s[3],p=n):(c=a[0],u=a[1],l=a[2],f=a[3],p=r),h=t[0]^e[0],d=t[o?3:1]^e[1],g=t[2]^e[2],y=t[o?1:3]^e[3];for(var S=3,T=1;T<E;++T)m=c[h>>>24]^u[d>>>16&255]^l[g>>>8&255]^f[255&y]^e[++S],v=c[d>>>24]^u[g>>>16&255]^l[y>>>8&255]^f[255&h]^e[++S],C=c[g>>>24]^u[y>>>16&255]^l[h>>>8&255]^f[255&d]^e[++S],y=c[y>>>24]^u[h>>>16&255]^l[d>>>8&255]^f[255&g]^e[++S],h=m,d=v,g=C;i[0]=p[h>>>24]<<24^p[d>>>16&255]<<16^p[g>>>8&255]<<8^p[255&y]^e[++S],i[o?3:1]=p[d>>>24]<<24^p[g>>>16&255]<<16^p[y>>>8&255]<<8^p[255&h]^e[++S],i[2]=p[g>>>24]<<24^p[y>>>16&255]<<16^p[h>>>8&255]<<8^p[255&d]^e[++S],i[o?1:3]=p[y>>>24]<<24^p[h>>>16&255]<<16^p[d>>>8&255]<<8^p[255&g]^e[++S]}function p(t){var r,n="AES-"+((t=t||{}).mode||"CBC").toUpperCase(),i=(r=t.decrypt?e.cipher.createDecipher(n,t.key):e.cipher.createCipher(n,t.key)).start;return r.start=function(t,n){var a=null;n instanceof e.util.ByteBuffer&&(a=n,n={}),(n=n||{}).output=a,n.iv=t,i.call(r,n)},r}return rr}var or,cr,ur={exports:{}},lr={exports:{}},fr={exports:{}};function pr(){if(or)return fr.exports;or=1;var e=zt();e.pki=e.pki||{};var t=fr.exports=e.pki.oids=e.oids=e.oids||{};function r(e,r){t[e]=r,t[r]=e}function n(e,r){t[e]=r}return r("1.2.840.113549.1.1.1","rsaEncryption"),r("1.2.840.113549.1.1.4","md5WithRSAEncryption"),r("1.2.840.113549.1.1.5","sha1WithRSAEncryption"),r("1.2.840.113549.1.1.7","RSAES-OAEP"),r("1.2.840.113549.1.1.8","mgf1"),r("1.2.840.113549.1.1.9","pSpecified"),r("1.2.840.113549.1.1.10","RSASSA-PSS"),r("1.2.840.113549.1.1.11","sha256WithRSAEncryption"),r("1.2.840.113549.1.1.12","sha384WithRSAEncryption"),r("1.2.840.113549.1.1.13","sha512WithRSAEncryption"),r("1.3.101.112","EdDSA25519"),r("1.2.840.10040.4.3","dsa-with-sha1"),r("1.3.14.3.2.7","desCBC"),r("1.3.14.3.2.26","sha1"),r("1.3.14.3.2.29","sha1WithRSASignature"),r("2.16.840.1.101.3.4.2.1","sha256"),r("2.16.840.1.101.3.4.2.2","sha384"),r("2.16.840.1.101.3.4.2.3","sha512"),r("2.16.840.1.101.3.4.2.4","sha224"),r("2.16.840.1.101.3.4.2.5","sha512-224"),r("2.16.840.1.101.3.4.2.6","sha512-256"),r("1.2.840.113549.2.2","md2"),r("1.2.840.113549.2.5","md5"),r("1.2.840.113549.1.7.1","data"),r("1.2.840.113549.1.7.2","signedData"),r("1.2.840.113549.1.7.3","envelopedData"),r("1.2.840.113549.1.7.4","signedAndEnvelopedData"),r("1.2.840.113549.1.7.5","digestedData"),r("1.2.840.113549.1.7.6","encryptedData"),r("1.2.840.113549.1.9.1","emailAddress"),r("1.2.840.113549.1.9.2","unstructuredName"),r("1.2.840.113549.1.9.3","contentType"),r("1.2.840.113549.1.9.4","messageDigest"),r("1.2.840.113549.1.9.5","signingTime"),r("1.2.840.113549.1.9.6","counterSignature"),r("1.2.840.113549.1.9.7","challengePassword"),r("1.2.840.113549.1.9.8","unstructuredAddress"),r("1.2.840.113549.1.9.14","extensionRequest"),r("1.2.840.113549.1.9.20","friendlyName"),r("1.2.840.113549.1.9.21","localKeyId"),r("1.2.840.113549.1.9.22.1","x509Certificate"),r("1.2.840.113549.1.12.10.1.1","keyBag"),r("1.2.840.113549.1.12.10.1.2","pkcs8ShroudedKeyBag"),r("1.2.840.113549.1.12.10.1.3","certBag"),r("1.2.840.113549.1.12.10.1.4","crlBag"),r("1.2.840.113549.1.12.10.1.5","secretBag"),r("1.2.840.113549.1.12.10.1.6","safeContentsBag"),r("1.2.840.113549.1.5.13","pkcs5PBES2"),r("1.2.840.113549.1.5.12","pkcs5PBKDF2"),r("1.2.840.113549.1.12.1.1","pbeWithSHAAnd128BitRC4"),r("1.2.840.113549.1.12.1.2","pbeWithSHAAnd40BitRC4"),r("1.2.840.113549.1.12.1.3","pbeWithSHAAnd3-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.4","pbeWithSHAAnd2-KeyTripleDES-CBC"),r("1.2.840.113549.1.12.1.5","pbeWithSHAAnd128BitRC2-CBC"),r("1.2.840.113549.1.12.1.6","pbewithSHAAnd40BitRC2-CBC"),r("1.2.840.113549.2.7","hmacWithSHA1"),r("1.2.840.113549.2.8","hmacWithSHA224"),r("1.2.840.113549.2.9","hmacWithSHA256"),r("1.2.840.113549.2.10","hmacWithSHA384"),r("1.2.840.113549.2.11","hmacWithSHA512"),r("1.2.840.113549.3.7","des-EDE3-CBC"),r("2.16.840.1.101.3.4.1.2","aes128-CBC"),r("2.16.840.1.101.3.4.1.22","aes192-CBC"),r("2.16.840.1.101.3.4.1.42","aes256-CBC"),r("2.5.4.3","commonName"),r("2.5.4.4","surname"),r("2.5.4.5","serialNumber"),r("2.5.4.6","countryName"),r("2.5.4.7","localityName"),r("2.5.4.8","stateOrProvinceName"),r("2.5.4.9","streetAddress"),r("2.5.4.10","organizationName"),r("2.5.4.11","organizationalUnitName"),r("2.5.4.12","title"),r("2.5.4.13","description"),r("2.5.4.15","businessCategory"),r("2.5.4.17","postalCode"),r("2.5.4.42","givenName"),r("1.3.6.1.4.1.311.60.2.1.2","jurisdictionOfIncorporationStateOrProvinceName"),r("1.3.6.1.4.1.311.60.2.1.3","jurisdictionOfIncorporationCountryName"),r("2.16.840.1.113730.1.1","nsCertType"),r("2.16.840.1.113730.1.13","nsComment"),n("2.5.29.1","authorityKeyIdentifier"),n("2.5.29.2","keyAttributes"),n("2.5.29.3","certificatePolicies"),n("2.5.29.4","keyUsageRestriction"),n("2.5.29.5","policyMapping"),n("2.5.29.6","subtreesConstraint"),n("2.5.29.7","subjectAltName"),n("2.5.29.8","issuerAltName"),n("2.5.29.9","subjectDirectoryAttributes"),n("2.5.29.10","basicConstraints"),n("2.5.29.11","nameConstraints"),n("2.5.29.12","policyConstraints"),n("2.5.29.13","basicConstraints"),r("2.5.29.14","subjectKeyIdentifier"),r("2.5.29.15","keyUsage"),n("2.5.29.16","privateKeyUsagePeriod"),r("2.5.29.17","subjectAltName"),r("2.5.29.18","issuerAltName"),r("2.5.29.19","basicConstraints"),n("2.5.29.20","cRLNumber"),n("2.5.29.21","cRLReason"),n("2.5.29.22","expirationDate"),n("2.5.29.23","instructionCode"),n("2.5.29.24","invalidityDate"),n("2.5.29.25","cRLDistributionPoints"),n("2.5.29.26","issuingDistributionPoint"),n("2.5.29.27","deltaCRLIndicator"),n("2.5.29.28","issuingDistributionPoint"),n("2.5.29.29","certificateIssuer"),n("2.5.29.30","nameConstraints"),r("2.5.29.31","cRLDistributionPoints"),r("2.5.29.32","certificatePolicies"),n("2.5.29.33","policyMappings"),n("2.5.29.34","policyConstraints"),r("2.5.29.35","authorityKeyIdentifier"),n("2.5.29.36","policyConstraints"),r("2.5.29.37","extKeyUsage"),n("2.5.29.46","freshestCRL"),n("2.5.29.54","inhibitAnyPolicy"),r("1.3.6.1.4.1.11129.2.4.2","timestampList"),r("1.3.6.1.5.5.7.1.1","authorityInfoAccess"),r("1.3.6.1.5.5.7.3.1","serverAuth"),r("1.3.6.1.5.5.7.3.2","clientAuth"),r("1.3.6.1.5.5.7.3.3","codeSigning"),r("1.3.6.1.5.5.7.3.4","emailProtection"),r("1.3.6.1.5.5.7.3.8","timeStamping"),fr.exports}function hr(){if(cr)return lr.exports;cr=1;var e=zt();Zt(),pr();var t=lr.exports=e.asn1=e.asn1||{};function r(e,t,r){if(r>t){var n=new Error("Too few bytes to parse DER.");throw n.available=e.length(),n.remaining=t,n.requested=r,n}}t.Class={UNIVERSAL:0,APPLICATION:64,CONTEXT_SPECIFIC:128,PRIVATE:192},t.Type={NONE:0,BOOLEAN:1,INTEGER:2,BITSTRING:3,OCTETSTRING:4,NULL:5,OID:6,ODESC:7,EXTERNAL:8,REAL:9,ENUMERATED:10,EMBEDDED:11,UTF8:12,ROID:13,SEQUENCE:16,SET:17,PRINTABLESTRING:19,IA5STRING:22,UTCTIME:23,GENERALIZEDTIME:24,BMPSTRING:30},t.create=function(r,n,i,a,s){if(e.util.isArray(a)){for(var o=[],c=0;c<a.length;++c)void 0!==a[c]&&o.push(a[c]);a=o}var u={tagClass:r,type:n,constructed:i,composed:i||e.util.isArray(a),value:a};return s&&"bitStringContents"in s&&(u.bitStringContents=s.bitStringContents,u.original=t.copy(u)),u},t.copy=function(r,n){var i;if(e.util.isArray(r)){i=[];for(var a=0;a<r.length;++a)i.push(t.copy(r[a],n));return i}return"string"==typeof r?r:(i={tagClass:r.tagClass,type:r.type,constructed:r.constructed,composed:r.composed,value:t.copy(r.value,n)},n&&!n.excludeBitStringContents&&(i.bitStringContents=r.bitStringContents),i)},t.equals=function(r,n,i){if(e.util.isArray(r)){if(!e.util.isArray(n))return!1;if(r.length!==n.length)return!1;for(var a=0;a<r.length;++a)if(!t.equals(r[a],n[a]))return!1;return!0}if(typeof r!=typeof n)return!1;if("string"==typeof r)return r===n;var s=r.tagClass===n.tagClass&&r.type===n.type&&r.constructed===n.constructed&&r.composed===n.composed&&t.equals(r.value,n.value);return i&&i.includeBitStringContents&&(s=s&&r.bitStringContents===n.bitStringContents),s},t.getBerValueLength=function(e){var t=e.getByte();if(128!==t)return 128&t?e.getInt((127&t)<<3):t};function n(e,i,a,s){var o;r(e,i,2);var c=e.getByte();i--;var u=192&c,l=31&c;o=e.length();var f,p,h=function(e,t){var n=e.getByte();if(t--,128!==n){var i;if(128&n){var a=127&n;r(e,t,a),i=e.getInt(a<<3)}else i=n;if(i<0)throw new Error("Negative length: "+i);return i}}(e,i);if(i-=o-e.length(),void 0!==h&&h>i){if(s.strict){var d=new Error("Too few bytes to read ASN.1 value.");throw d.available=e.length(),d.remaining=i,d.requested=h,d}h=i}var g=!(32&~c);if(g)if(f=[],void 0===h)for(;;){if(r(e,i,2),e.bytes(2)===String.fromCharCode(0,0)){e.getBytes(2),i-=2;break}o=e.length(),f.push(n(e,i,a+1,s)),i-=o-e.length()}else for(;h>0;)o=e.length(),f.push(n(e,h,a+1,s)),i-=o-e.length(),h-=o-e.length();if(void 0===f&&u===t.Class.UNIVERSAL&&l===t.Type.BITSTRING&&(p=e.bytes(h)),void 0===f&&s.decodeBitStrings&&u===t.Class.UNIVERSAL&&l===t.Type.BITSTRING&&h>1){var y=e.read,m=i,v=0;if(l===t.Type.BITSTRING&&(r(e,i,1),v=e.getByte(),i--),0===v)try{o=e.length();var C=n(e,i,a+1,{strict:!0,decodeBitStrings:!0}),E=o-e.length();i-=E,l==t.Type.BITSTRING&&E++;var S=C.tagClass;E!==h||S!==t.Class.UNIVERSAL&&S!==t.Class.CONTEXT_SPECIFIC||(f=[C])}catch(b){}void 0===f&&(e.read=y,i=m)}if(void 0===f){if(void 0===h){if(s.strict)throw new Error("Non-constructed ASN.1 object of indefinite length.");h=i}if(l===t.Type.BMPSTRING)for(f="";h>0;h-=2)r(e,i,2),f+=String.fromCharCode(e.getInt16()),i-=2;else f=e.getBytes(h),i-=h}var T=void 0===p?null:{bitStringContents:p};return t.create(u,l,g,f,T)}t.fromDer=function(t,r){void 0===r&&(r={strict:!0,parseAllBytes:!0,decodeBitStrings:!0}),"boolean"==typeof r&&(r={strict:r,parseAllBytes:!0,decodeBitStrings:!0}),"strict"in r||(r.strict=!0),"parseAllBytes"in r||(r.parseAllBytes=!0),"decodeBitStrings"in r||(r.decodeBitStrings=!0),"string"==typeof t&&(t=e.util.createBuffer(t));var i=t.length(),a=n(t,t.length(),0,r);if(r.parseAllBytes&&0!==t.length()){var s=new Error("Unparsed DER bytes remain after ASN.1 parsing.");throw s.byteCount=i,s.remaining=t.length(),s}return a},t.toDer=function(r){var n=e.util.createBuffer(),i=r.tagClass|r.type,a=e.util.createBuffer(),s=!1;if("bitStringContents"in r&&(s=!0,r.original&&(s=t.equals(r,r.original))),s)a.putBytes(r.bitStringContents);else if(r.composed){r.constructed?i|=32:a.putByte(0);for(var o=0;o<r.value.length;++o)void 0!==r.value[o]&&a.putBuffer(t.toDer(r.value[o]))}else if(r.type===t.Type.BMPSTRING)for(o=0;o<r.value.length;++o)a.putInt16(r.value.charCodeAt(o));else!(r.type===t.Type.INTEGER&&r.value.length>1)||(0!==r.value.charCodeAt(0)||128&r.value.charCodeAt(1))&&(255!==r.value.charCodeAt(0)||128&~r.value.charCodeAt(1))?a.putBytes(r.value):a.putBytes(r.value.substr(1));if(n.putByte(i),a.length()<=127)n.putByte(127&a.length());else{var c=a.length(),u="";do{u+=String.fromCharCode(255&c),c>>>=8}while(c>0);n.putByte(128|u.length);for(o=u.length-1;o>=0;--o)n.putByte(u.charCodeAt(o))}return n.putBuffer(a),n},t.oidToDer=function(t){var r,n,i,a,s=t.split("."),o=e.util.createBuffer();o.putByte(40*parseInt(s[0],10)+parseInt(s[1],10));for(var c=2;c<s.length;++c){r=!0,n=[],i=parseInt(s[c],10);do{a=127&i,i>>>=7,r||(a|=128),n.push(a),r=!1}while(i>0);for(var u=n.length-1;u>=0;--u)o.putByte(n[u])}return o},t.derToOid=function(t){var r;"string"==typeof t&&(t=e.util.createBuffer(t));var n=t.getByte();r=Math.floor(n/40)+"."+n%40;for(var i=0;t.length()>0;)i<<=7,128&(n=t.getByte())?i+=127&n:(r+="."+(i+n),i=0);return r},t.utcTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,2),10);r=r>=50?1900+r:2e3+r;var n=parseInt(e.substr(2,2),10)-1,i=parseInt(e.substr(4,2),10),a=parseInt(e.substr(6,2),10),s=parseInt(e.substr(8,2),10),o=0;if(e.length>11){var c=e.charAt(10),u=10;"+"!==c&&"-"!==c&&(o=parseInt(e.substr(10,2),10),u+=2)}if(t.setUTCFullYear(r,n,i),t.setUTCHours(a,s,o,0),u&&("+"===(c=e.charAt(u))||"-"===c)){var l=60*parseInt(e.substr(u+1,2),10)+parseInt(e.substr(u+4,2),10);l*=6e4,"+"===c?t.setTime(+t-l):t.setTime(+t+l)}return t},t.generalizedTimeToDate=function(e){var t=new Date,r=parseInt(e.substr(0,4),10),n=parseInt(e.substr(4,2),10)-1,i=parseInt(e.substr(6,2),10),a=parseInt(e.substr(8,2),10),s=parseInt(e.substr(10,2),10),o=parseInt(e.substr(12,2),10),c=0,u=0,l=!1;"Z"===e.charAt(e.length-1)&&(l=!0);var f=e.length-5,p=e.charAt(f);"+"!==p&&"-"!==p||(u=60*parseInt(e.substr(f+1,2),10)+parseInt(e.substr(f+4,2),10),u*=6e4,"+"===p&&(u*=-1),l=!0);return"."===e.charAt(14)&&(c=1e3*parseFloat(e.substr(14),10)),l?(t.setUTCFullYear(r,n,i),t.setUTCHours(a,s,o,c),t.setTime(+t+u)):(t.setFullYear(r,n,i),t.setHours(a,s,o,c)),t},t.dateToUtcTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push((""+e.getUTCFullYear()).substr(2)),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},t.dateToGeneralizedTime=function(e){if("string"==typeof e)return e;var t="",r=[];r.push(""+e.getUTCFullYear()),r.push(""+(e.getUTCMonth()+1)),r.push(""+e.getUTCDate()),r.push(""+e.getUTCHours()),r.push(""+e.getUTCMinutes()),r.push(""+e.getUTCSeconds());for(var n=0;n<r.length;++n)r[n].length<2&&(t+="0"),t+=r[n];return t+="Z"},t.integerToDer=function(t){var r=e.util.createBuffer();if(t>=-128&&t<128)return r.putSignedInt(t,8);if(t>=-32768&&t<32768)return r.putSignedInt(t,16);if(t>=-8388608&&t<8388608)return r.putSignedInt(t,24);if(t>=-2147483648&&t<2147483648)return r.putSignedInt(t,32);var n=new Error("Integer too large; max is 32-bits.");throw n.integer=t,n},t.derToInteger=function(t){"string"==typeof t&&(t=e.util.createBuffer(t));var r=8*t.length();if(r>32)throw new Error("Integer too large; max is 32-bits.");return t.getSignedInt(r)},t.validate=function(r,n,i,a){var s=!1;if(r.tagClass!==n.tagClass&&void 0!==n.tagClass||r.type!==n.type&&void 0!==n.type)a&&(r.tagClass!==n.tagClass&&a.push("["+n.name+'] Expected tag class "'+n.tagClass+'", got "'+r.tagClass+'"'),r.type!==n.type&&a.push("["+n.name+'] Expected type "'+n.type+'", got "'+r.type+'"'));else if(r.constructed===n.constructed||void 0===n.constructed){if(s=!0,n.value&&e.util.isArray(n.value))for(var o=0,c=0;s&&c<n.value.length;++c)s=n.value[c].optional||!1,r.value[o]&&((s=t.validate(r.value[o],n.value[c],i,a))?++o:n.value[c].optional&&(s=!0)),!s&&a&&a.push("["+n.name+'] Tag class "'+n.tagClass+'", type "'+n.type+'" expected value length "'+n.value.length+'", got "'+r.value.length+'"');if(s&&i&&(n.capture&&(i[n.capture]=r.value),n.captureAsn1&&(i[n.captureAsn1]=r),n.captureBitStringContents&&"bitStringContents"in r&&(i[n.captureBitStringContents]=r.bitStringContents),n.captureBitStringValue&&"bitStringContents"in r))if(r.bitStringContents.length<2)i[n.captureBitStringValue]="";else{if(0!==r.bitStringContents.charCodeAt(0))throw new Error("captureBitStringValue only supported for zero unused bits");i[n.captureBitStringValue]=r.bitStringContents.slice(1)}}else a&&a.push("["+n.name+'] Expected constructed "'+n.constructed+'", got "'+r.constructed+'"');return s};var i=/[^\\u0000-\\u00ff]/;return t.prettyPrint=function(r,n,a){var s="";a=a||2,(n=n||0)>0&&(s+="\n");for(var o="",c=0;c<n*a;++c)o+=" ";switch(s+=o+"Tag: ",r.tagClass){case t.Class.UNIVERSAL:s+="Universal:";break;case t.Class.APPLICATION:s+="Application:";break;case t.Class.CONTEXT_SPECIFIC:s+="Context-Specific:";break;case t.Class.PRIVATE:s+="Private:"}if(r.tagClass===t.Class.UNIVERSAL)switch(s+=r.type,r.type){case t.Type.NONE:s+=" (None)";break;case t.Type.BOOLEAN:s+=" (Boolean)";break;case t.Type.INTEGER:s+=" (Integer)";break;case t.Type.BITSTRING:s+=" (Bit string)";break;case t.Type.OCTETSTRING:s+=" (Octet string)";break;case t.Type.NULL:s+=" (Null)";break;case t.Type.OID:s+=" (Object Identifier)";break;case t.Type.ODESC:s+=" (Object Descriptor)";break;case t.Type.EXTERNAL:s+=" (External or Instance of)";break;case t.Type.REAL:s+=" (Real)";break;case t.Type.ENUMERATED:s+=" (Enumerated)";break;case t.Type.EMBEDDED:s+=" (Embedded PDV)";break;case t.Type.UTF8:s+=" (UTF8)";break;case t.Type.ROID:s+=" (Relative Object Identifier)";break;case t.Type.SEQUENCE:s+=" (Sequence)";break;case t.Type.SET:s+=" (Set)";break;case t.Type.PRINTABLESTRING:s+=" (Printable String)";break;case t.Type.IA5String:s+=" (IA5String (ASCII))";break;case t.Type.UTCTIME:s+=" (UTC time)";break;case t.Type.GENERALIZEDTIME:s+=" (Generalized time)";break;case t.Type.BMPSTRING:s+=" (BMP String)"}else s+=r.type;if(s+="\n",s+=o+"Constructed: "+r.constructed+"\n",r.composed){var u=0,l="";for(c=0;c<r.value.length;++c)void 0!==r.value[c]&&(u+=1,l+=t.prettyPrint(r.value[c],n+1,a),c+1<r.value.length&&(l+=","));s+=o+"Sub values: "+u+l}else{if(s+=o+"Value: ",r.type===t.Type.OID){var f=t.derToOid(r.value);s+=f,e.pki&&e.pki.oids&&f in e.pki.oids&&(s+=" ("+e.pki.oids[f]+") ")}if(r.type===t.Type.INTEGER)try{s+=t.derToInteger(r.value)}catch(h){s+="0x"+e.util.bytesToHex(r.value)}else if(r.type===t.Type.BITSTRING){if(r.value.length>1?s+="0x"+e.util.bytesToHex(r.value.slice(1)):s+="(none)",r.value.length>0){var p=r.value.charCodeAt(0);1==p?s+=" (1 unused bit shown)":p>1&&(s+=" ("+p+" unused bits shown)")}}else if(r.type===t.Type.OCTETSTRING)i.test(r.value)||(s+="("+r.value+") "),s+="0x"+e.util.bytesToHex(r.value);else if(r.type===t.Type.UTF8)try{s+=e.util.decodeUtf8(r.value)}catch(d){if("URI malformed"!==d.message)throw d;s+="0x"+e.util.bytesToHex(r.value)+" (malformed UTF8)"}else r.type===t.Type.PRINTABLESTRING||r.type===t.Type.IA5String?s+=r.value:i.test(r.value)?s+="0x"+e.util.bytesToHex(r.value):0===r.value.length?s+="[null]":s+=r.value}return s},lr.exports}var dr,gr,yr,mr={exports:{}};function vr(){if(gr)return dr;gr=1;var e=zt();return dr=e.md=e.md||{},e.md.algorithms=e.md.algorithms||{},dr}function Cr(){if(yr)return mr.exports;yr=1;var e=zt();return vr(),Zt(),(mr.exports=e.hmac=e.hmac||{}).create=function(){var t=null,r=null,n=null,i=null,a={start:function(a,s){if(null!==a)if("string"==typeof a){if(!((a=a.toLowerCase())in e.md.algorithms))throw new Error('Unknown hash algorithm "'+a+'"');r=e.md.algorithms[a].create()}else r=a;if(null===s)s=t;else{if("string"==typeof s)s=e.util.createBuffer(s);else if(e.util.isArray(s)){var o=s;s=e.util.createBuffer();for(var c=0;c<o.length;++c)s.putByte(o[c])}var u=s.length();u>r.blockLength&&(r.start(),r.update(s.bytes()),s=r.digest()),n=e.util.createBuffer(),i=e.util.createBuffer(),u=s.length();for(c=0;c<u;++c){o=s.at(c);n.putByte(54^o),i.putByte(92^o)}if(u<r.blockLength)for(o=r.blockLength-u,c=0;c<o;++c)n.putByte(54),i.putByte(92);t=s,n=n.bytes(),i=i.bytes()}r.start(),r.update(n)},update:function(e){r.update(e)},getMac:function(){var e=r.digest().bytes();return r.start(),r.update(i),r.update(e),r.digest()}};return a.digest=a.getMac,a},mr.exports}var Er,Sr={exports:{}};function Tr(){if(Er)return Sr.exports;Er=1;var e=zt();vr(),Zt();var t=Sr.exports=e.md5=e.md5||{};e.md.md5=e.md.algorithms.md5=t,t.create=function(){s||function(){r=String.fromCharCode(128),r+=e.util.fillString(String.fromCharCode(0),64),n=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,1,6,11,0,5,10,15,4,9,14,3,8,13,2,7,12,5,8,11,14,1,4,7,10,13,0,3,6,9,12,15,2,0,7,14,5,12,3,10,1,8,15,6,13,4,11,2,9],i=[7,12,17,22,7,12,17,22,7,12,17,22,7,12,17,22,5,9,14,20,5,9,14,20,5,9,14,20,5,9,14,20,4,11,16,23,4,11,16,23,4,11,16,23,4,11,16,23,6,10,15,21,6,10,15,21,6,10,15,21,6,10,15,21],a=new Array(64);for(var t=0;t<64;++t)a[t]=Math.floor(4294967296*Math.abs(Math.sin(t+1)));s=!0}();var t=null,c=e.util.createBuffer(),u=new Array(16),l={algorithm:"md5",blockLength:64,digestLength:16,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){l.messageLength=0,l.fullMessageLength=l.messageLength64=[];for(var r=l.messageLengthSize/4,n=0;n<r;++n)l.fullMessageLength.push(0);return c=e.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878},l}};return l.start(),l.update=function(r,n){"utf8"===n&&(r=e.util.encodeUtf8(r));var i=r.length;l.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var a=l.fullMessageLength.length-1;a>=0;--a)l.fullMessageLength[a]+=i[1],i[1]=i[0]+(l.fullMessageLength[a]/4294967296>>>0),l.fullMessageLength[a]=l.fullMessageLength[a]>>>0,i[0]=i[1]/4294967296>>>0;return c.putBytes(r),o(t,u,c),(c.read>2048||0===c.length())&&c.compact(),l},l.digest=function(){var n=e.util.createBuffer();n.putBytes(c.bytes());var i=l.fullMessageLength[l.fullMessageLength.length-1]+l.messageLengthSize&l.blockLength-1;n.putBytes(r.substr(0,l.blockLength-i));for(var a,s=0,f=l.fullMessageLength.length-1;f>=0;--f)s=(a=8*l.fullMessageLength[f]+s)/4294967296>>>0,n.putInt32Le(a>>>0);var p={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3};o(p,u,n);var h=e.util.createBuffer();return h.putInt32Le(p.h0),h.putInt32Le(p.h1),h.putInt32Le(p.h2),h.putInt32Le(p.h3),h},l};var r=null,n=null,i=null,a=null,s=!1;function o(e,t,r){for(var s,o,c,u,l,f,p,h=r.length();h>=64;){for(o=e.h0,c=e.h1,u=e.h2,l=e.h3,p=0;p<16;++p)t[p]=r.getInt32Le(),s=o+(l^c&(u^l))+a[p]+t[p],o=l,l=u,u=c,c+=s<<(f=i[p])|s>>>32-f;for(;p<32;++p)s=o+(u^l&(c^u))+a[p]+t[n[p]],o=l,l=u,u=c,c+=s<<(f=i[p])|s>>>32-f;for(;p<48;++p)s=o+(c^u^l)+a[p]+t[n[p]],o=l,l=u,u=c,c+=s<<(f=i[p])|s>>>32-f;for(;p<64;++p)s=o+(u^(c|~l))+a[p]+t[n[p]],o=l,l=u,u=c,c+=s<<(f=i[p])|s>>>32-f;e.h0=e.h0+o|0,e.h1=e.h1+c|0,e.h2=e.h2+u|0,e.h3=e.h3+l|0,h-=64}}return Sr.exports}var br,Ar={exports:{}};function Ir(){if(br)return Ar.exports;br=1;var e=zt();Zt();var t=Ar.exports=e.pem=e.pem||{};function r(e){for(var t=e.name+": ",r=[],n=function(e,t){return" "+t},i=0;i<e.values.length;++i)r.push(e.values[i].replace(/^(\S+\r\n)/,n));t+=r.join(",")+"\r\n";var a=0,s=-1;for(i=0;i<t.length;++i,++a)if(a>65&&-1!==s){var o=t[s];","===o?(++s,t=t.substr(0,s)+"\r\n "+t.substr(s)):t=t.substr(0,s)+"\r\n"+o+t.substr(s+1),a=i-s-1,s=-1,++i}else" "!==t[i]&&"\t"!==t[i]&&","!==t[i]||(s=i);return t}function n(e){return e.replace(/^\s+/,"")}return t.encode=function(t,n){n=n||{};var i,a="-----BEGIN "+t.type+"-----\r\n";if(t.procType&&(a+=r(i={name:"Proc-Type",values:[String(t.procType.version),t.procType.type]})),t.contentDomain&&(a+=r(i={name:"Content-Domain",values:[t.contentDomain]})),t.dekInfo&&(i={name:"DEK-Info",values:[t.dekInfo.algorithm]},t.dekInfo.parameters&&i.values.push(t.dekInfo.parameters),a+=r(i)),t.headers)for(var s=0;s<t.headers.length;++s)a+=r(t.headers[s]);return t.procType&&(a+="\r\n"),a+=e.util.encode64(t.body,n.maxline||64)+"\r\n",a+="-----END "+t.type+"-----\r\n"},t.decode=function(t){for(var r,i=[],a=/\s*-----BEGIN ([A-Z0-9- ]+)-----\r?\n?([\x21-\x7e\s]+?(?:\r?\n\r?\n))?([:A-Za-z0-9+\/=\s]+?)-----END \1-----/g,s=/([\x21-\x7e]+):\s*([\x21-\x7e\s^:]+)/,o=/\r?\n/;r=a.exec(t);){var c=r[1];"NEW CERTIFICATE REQUEST"===c&&(c="CERTIFICATE REQUEST");var u={type:c,procType:null,contentDomain:null,dekInfo:null,headers:[],body:e.util.decode64(r[3])};if(i.push(u),r[2]){for(var l=r[2].split(o),f=0;r&&f<l.length;){for(var p=l[f].replace(/\s+$/,""),h=f+1;h<l.length;++h){var d=l[h];if(!/\s/.test(d[0]))break;p+=d,f=h}if(r=p.match(s)){for(var g={name:r[1],values:[]},y=r[2].split(","),m=0;m<y.length;++m)g.values.push(n(y[m]));if(u.procType)if(u.contentDomain||"Content-Domain"!==g.name)if(u.dekInfo||"DEK-Info"!==g.name)u.headers.push(g);else{if(0===g.values.length)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must have at least one subfield.');u.dekInfo={algorithm:y[0],parameters:y[1]||null}}else u.contentDomain=y[0]||"";else{if("Proc-Type"!==g.name)throw new Error('Invalid PEM formatted message. The first encapsulated header must be "Proc-Type".');if(2!==g.values.length)throw new Error('Invalid PEM formatted message. The "Proc-Type" header must have two subfields.');u.procType={version:y[0],type:y[1]}}}++f}if("ENCRYPTED"===u.procType&&!u.dekInfo)throw new Error('Invalid PEM formatted message. The "DEK-Info" header must be present if "Proc-Type" is "ENCRYPTED".')}}if(0===i.length)throw new Error("Invalid PEM formatted message.");return i},Ar.exports}var Br,wr,Nr={exports:{}};function _r(){if(wr)return Br;wr=1;var e=zt();function t(t,r){e.cipher.registerAlgorithm(t,function(){return new e.des.Algorithm(t,r)})}er(),ar(),Zt(),Br=e.des=e.des||{},e.des.startEncrypting=function(e,t,r,n){var i=f({key:e,output:r,decrypt:!1,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},e.des.createEncryptionCipher=function(e,t){return f({key:e,output:null,decrypt:!1,mode:t})},e.des.startDecrypting=function(e,t,r,n){var i=f({key:e,output:r,decrypt:!0,mode:n||(null===t?"ECB":"CBC")});return i.start(t),i},e.des.createDecryptionCipher=function(e,t){return f({key:e,output:null,decrypt:!0,mode:t})},e.des.Algorithm=function(e,t){var r=this;r.name=e,r.mode=new t({blockSize:8,cipher:{encrypt:function(e,t){return l(r._keys,e,t,!1)},decrypt:function(e,t){return l(r._keys,e,t,!0)}}}),r._init=!1},e.des.Algorithm.prototype.initialize=function(t){if(!this._init){var r=e.util.createBuffer(t.key);if(0===this.name.indexOf("3DES")&&24!==r.length())throw new Error("Invalid Triple-DES key size: "+8*r.length());this._keys=function(e){for(var t,r=[0,4,536870912,536870916,65536,65540,536936448,536936452,512,516,536871424,536871428,66048,66052,536936960,536936964],n=[0,1,1048576,1048577,67108864,67108865,68157440,68157441,256,257,1048832,1048833,67109120,67109121,68157696,68157697],i=[0,8,2048,2056,16777216,16777224,16779264,16779272,0,8,2048,2056,16777216,16777224,16779264,16779272],a=[0,2097152,134217728,136314880,8192,2105344,134225920,136323072,131072,2228224,134348800,136445952,139264,2236416,134356992,136454144],s=[0,262144,16,262160,0,262144,16,262160,4096,266240,4112,266256,4096,266240,4112,266256],o=[0,1024,32,1056,0,1024,32,1056,33554432,33555456,33554464,33555488,33554432,33555456,33554464,33555488],c=[0,268435456,524288,268959744,2,268435458,524290,268959746,0,268435456,524288,268959744,2,268435458,524290,268959746],u=[0,65536,2048,67584,536870912,536936448,536872960,536938496,131072,196608,133120,198656,537001984,537067520,537004032,537069568],l=[0,262144,0,262144,2,262146,2,262146,33554432,33816576,33554432,33816576,33554434,33816578,33554434,33816578],f=[0,268435456,8,268435464,0,268435456,8,268435464,1024,268436480,1032,268436488,1024,268436480,1032,268436488],p=[0,32,0,32,1048576,1048608,1048576,1048608,8192,8224,8192,8224,1056768,1056800,1056768,1056800],h=[0,16777216,512,16777728,2097152,18874368,2097664,18874880,67108864,83886080,67109376,83886592,69206016,85983232,69206528,85983744],d=[0,4096,134217728,134221824,524288,528384,134742016,134746112,16,4112,134217744,134221840,524304,528400,134742032,134746128],g=[0,4,256,260,0,4,256,260,1,5,257,261,1,5,257,261],y=e.length()>8?3:1,m=[],v=[0,0,1,1,1,1,1,1,0,1,1,1,1,1,1,0],C=0,E=0;E<y;E++){var S=e.getInt32(),T=e.getInt32();S^=(t=252645135&(S>>>4^T))<<4,S^=t=65535&((T^=t)>>>-16^S),S^=(t=858993459&(S>>>2^(T^=t<<-16)))<<2,S^=t=65535&((T^=t)>>>-16^S),S^=(t=1431655765&(S>>>1^(T^=t<<-16)))<<1,S^=t=16711935&((T^=t)>>>8^S),t=(S^=(t=1431655765&(S>>>1^(T^=t<<8)))<<1)<<8|(T^=t)>>>20&240,S=T<<24|T<<8&16711680|T>>>8&65280|T>>>24&240,T=t;for(var b=0;b<v.length;++b){v[b]?(S=S<<2|S>>>26,T=T<<2|T>>>26):(S=S<<1|S>>>27,T=T<<1|T>>>27),T&=-15;var A=r[(S&=-15)>>>28]|n[S>>>24&15]|i[S>>>20&15]|a[S>>>16&15]|s[S>>>12&15]|o[S>>>8&15]|c[S>>>4&15],I=u[T>>>28]|l[T>>>24&15]|f[T>>>20&15]|p[T>>>16&15]|h[T>>>12&15]|d[T>>>8&15]|g[T>>>4&15];t=65535&(I>>>16^A),m[C++]=A^t,m[C++]=I^t<<16}}return m}(r),this._init=!0}},t("DES-ECB",e.cipher.modes.ecb),t("DES-CBC",e.cipher.modes.cbc),t("DES-CFB",e.cipher.modes.cfb),t("DES-OFB",e.cipher.modes.ofb),t("DES-CTR",e.cipher.modes.ctr),t("3DES-ECB",e.cipher.modes.ecb),t("3DES-CBC",e.cipher.modes.cbc),t("3DES-CFB",e.cipher.modes.cfb),t("3DES-OFB",e.cipher.modes.ofb),t("3DES-CTR",e.cipher.modes.ctr);var r=[16843776,0,65536,16843780,16842756,66564,4,65536,1024,16843776,16843780,1024,16778244,16842756,16777216,4,1028,16778240,16778240,66560,66560,16842752,16842752,16778244,65540,16777220,16777220,65540,0,1028,66564,16777216,65536,16843780,4,16842752,16843776,16777216,16777216,1024,16842756,65536,66560,16777220,1024,4,16778244,66564,16843780,65540,16842752,16778244,16777220,1028,66564,16843776,1028,16778240,16778240,0,65540,66560,0,16842756],n=[-2146402272,-2147450880,32768,1081376,1048576,32,-2146435040,-2147450848,-2147483616,-2146402272,-2146402304,-2147483648,-2147450880,1048576,32,-2146435040,1081344,1048608,-2147450848,0,-2147483648,32768,1081376,-2146435072,1048608,-2147483616,0,1081344,32800,-2146402304,-2146435072,32800,0,1081376,-2146435040,1048576,-2147450848,-2146435072,-2146402304,32768,-2146435072,-2147450880,32,-2146402272,1081376,32,32768,-2147483648,32800,-2146402304,1048576,-2147483616,1048608,-2147450848,-2147483616,1048608,1081344,0,-2147450880,32800,-2147483648,-2146435040,-2146402272,1081344],i=[520,134349312,0,134348808,134218240,0,131592,134218240,131080,134217736,134217736,131072,134349320,131080,134348800,520,134217728,8,134349312,512,131584,134348800,134348808,131592,134218248,131584,131072,134218248,8,134349320,512,134217728,134349312,134217728,131080,520,131072,134349312,134218240,0,512,131080,134349320,134218240,134217736,512,0,134348808,134218248,131072,134217728,134349320,8,131592,131584,134217736,134348800,134218248,520,134348800,131592,8,134348808,131584],a=[8396801,8321,8321,128,8396928,8388737,8388609,8193,0,8396800,8396800,8396929,129,0,8388736,8388609,1,8192,8388608,8396801,128,8388608,8193,8320,8388737,1,8320,8388736,8192,8396928,8396929,129,8388736,8388609,8396800,8396929,129,0,0,8396800,8320,8388736,8388737,1,8396801,8321,8321,128,8396929,129,1,8192,8388609,8193,8396928,8388737,8193,8320,8388608,8396801,128,8388608,8192,8396928],s=[256,34078976,34078720,1107296512,524288,256,1073741824,34078720,1074266368,524288,33554688,1074266368,1107296512,1107820544,524544,1073741824,33554432,1074266112,1074266112,0,1073742080,1107820800,1107820800,33554688,1107820544,1073742080,0,1107296256,34078976,33554432,1107296256,524544,524288,1107296512,256,33554432,1073741824,34078720,1107296512,1074266368,33554688,1073741824,1107820544,34078976,1074266368,256,33554432,1107820544,1107820800,524544,1107296256,1107820800,34078720,0,1074266112,1107296256,524544,33554688,1073742080,524288,0,1074266112,34078976,1073742080],o=[536870928,541065216,16384,541081616,541065216,16,541081616,4194304,536887296,4210704,4194304,536870928,4194320,536887296,536870912,16400,0,4194320,536887312,16384,4210688,536887312,16,541065232,541065232,0,4210704,541081600,16400,4210688,541081600,536870912,536887296,16,541065232,4210688,541081616,4194304,16400,536870928,4194304,536887296,536870912,16400,536870928,541081616,4210688,541065216,4210704,541081600,0,541065232,16,16384,541065216,4210704,16384,4194320,536887312,0,541081600,536870912,4194320,536887312],c=[2097152,69206018,67110914,0,2048,67110914,2099202,69208064,69208066,2097152,0,67108866,2,67108864,69206018,2050,67110912,2099202,2097154,67110912,67108866,69206016,69208064,2097154,69206016,2048,2050,69208066,2099200,2,67108864,2099200,67108864,2099200,2097152,67110914,67110914,69206018,69206018,2,2097154,67108864,67110912,2097152,69208064,2050,2099202,69208064,2050,67108866,69208066,69206016,2099200,0,2,69208066,0,2099202,69206016,2048,67108866,67110912,2048,2097154],u=[268439616,4096,262144,268701760,268435456,268439616,64,268435456,262208,268697600,268701760,266240,268701696,266304,4096,64,268697600,268435520,268439552,4160,266240,262208,268697664,268701696,4160,0,0,268697664,268435520,268439552,266304,262144,266304,262144,268701696,4096,64,268697664,4096,266304,268439552,64,268435520,268697600,268697664,268435456,262144,268439616,0,268701760,262208,268435520,268697600,268439552,268439616,0,268701760,266240,266240,4160,4160,262208,268435456,268701696];function l(e,t,l,f){var p,h,d=32===e.length?3:9;p=3===d?f?[30,-2,-2]:[0,32,2]:f?[94,62,-2,32,64,2,30,-2,-2]:[0,32,2,62,30,-2,64,96,2];var g=t[0],y=t[1];g^=(h=252645135&(g>>>4^y))<<4,g^=(h=65535&(g>>>16^(y^=h)))<<16,g^=h=858993459&((y^=h)>>>2^g),g^=h=16711935&((y^=h<<2)>>>8^g),g=(g^=(h=1431655765&(g>>>1^(y^=h<<8)))<<1)<<1|g>>>31,y=(y^=h)<<1|y>>>31;for(var m=0;m<d;m+=3){for(var v=p[m+1],C=p[m+2],E=p[m];E!=v;E+=C){var S=y^e[E],T=(y>>>4|y<<28)^e[E+1];h=g,g=y,y=h^(n[S>>>24&63]|a[S>>>16&63]|o[S>>>8&63]|u[63&S]|r[T>>>24&63]|i[T>>>16&63]|s[T>>>8&63]|c[63&T])}h=g,g=y,y=h}y=y>>>1|y<<31,y^=h=1431655765&((g=g>>>1|g<<31)>>>1^y),y^=(h=16711935&(y>>>8^(g^=h<<1)))<<8,y^=(h=858993459&(y>>>2^(g^=h)))<<2,y^=h=65535&((g^=h)>>>16^y),y^=h=252645135&((g^=h<<16)>>>4^y),g^=h<<4,l[0]=g,l[1]=y}function f(t){var r,n="DES-"+((t=t||{}).mode||"CBC").toUpperCase(),i=(r=t.decrypt?e.cipher.createDecipher(n,t.key):e.cipher.createCipher(n,t.key)).start;return r.start=function(t,n){var a=null;n instanceof e.util.ByteBuffer&&(a=n,n={}),(n=n||{}).output=a,n.iv=t,i.call(r,n)},r}return Br}const Rr=a(Object.freeze(Object.defineProperty({__proto__:null,default:{}},Symbol.toStringTag,{value:"Module"})));var kr,Lr;function Ur(){if(Lr)return kr;Lr=1;var e=zt();Cr(),vr(),Zt();var t,r=e.pkcs5=e.pkcs5||{};return e.util.isNodejs&&!e.options.usePureJavaScript&&(t=Rr),kr=e.pbkdf2=r.pbkdf2=function(r,n,i,a,s,o){if("function"==typeof s&&(o=s,s=null),e.util.isNodejs&&!e.options.usePureJavaScript&&t.pbkdf2&&(null===s||"object"!=typeof s)&&(t.pbkdf2Sync.length>4||!s||"sha1"===s))return"string"!=typeof s&&(s="sha1"),r=Buffer.from(r,"binary"),n=Buffer.from(n,"binary"),o?4===t.pbkdf2Sync.length?t.pbkdf2(r,n,i,a,function(e,t){if(e)return o(e);o(null,t.toString("binary"))}):t.pbkdf2(r,n,i,a,s,function(e,t){if(e)return o(e);o(null,t.toString("binary"))}):4===t.pbkdf2Sync.length?t.pbkdf2Sync(r,n,i,a).toString("binary"):t.pbkdf2Sync(r,n,i,a,s).toString("binary");if(null==s&&(s="sha1"),"string"==typeof s){if(!(s in e.md.algorithms))throw new Error("Unknown hash algorithm: "+s);s=e.md[s].create()}var c=s.digestLength;if(a>4294967295*c){var u=new Error("Derived key is too long.");if(o)return o(u);throw u}var l=Math.ceil(a/c),f=a-(l-1)*c,p=e.hmac.create();p.start(s,r);var h,d,g,y="";if(!o){for(var m=1;m<=l;++m){p.start(null,null),p.update(n),p.update(e.util.int32ToBytes(m)),h=g=p.digest().getBytes();for(var v=2;v<=i;++v)p.start(null,null),p.update(g),d=p.digest().getBytes(),h=e.util.xorBytes(h,d,c),g=d;y+=m<l?h:h.substr(0,f)}return y}m=1;function C(){if(m>l)return o(null,y);p.start(null,null),p.update(n),p.update(e.util.int32ToBytes(m)),h=g=p.digest().getBytes(),v=2,E()}function E(){if(v<=i)return p.start(null,null),p.update(g),d=p.digest().getBytes(),h=e.util.xorBytes(h,d,c),g=d,++v,e.util.setImmediate(E);y+=m<l?h:h.substr(0,f),++m,C()}C()}}var Dr,Or={exports:{}},Pr={exports:{}};function xr(){if(Dr)return Pr.exports;Dr=1;var e=zt();vr(),Zt();var t=Pr.exports=e.sha256=e.sha256||{};e.md.sha256=e.md.algorithms.sha256=t,t.create=function(){n||(r=String.fromCharCode(128),r+=e.util.fillString(String.fromCharCode(0),64),i=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=!0);var t=null,s=e.util.createBuffer(),o=new Array(64),c={algorithm:"sha256",blockLength:64,digestLength:32,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){c.messageLength=0,c.fullMessageLength=c.messageLength64=[];for(var r=c.messageLengthSize/4,n=0;n<r;++n)c.fullMessageLength.push(0);return s=e.util.createBuffer(),t={h0:1779033703,h1:3144134277,h2:1013904242,h3:2773480762,h4:1359893119,h5:2600822924,h6:528734635,h7:1541459225},c}};return c.start(),c.update=function(r,n){"utf8"===n&&(r=e.util.encodeUtf8(r));var i=r.length;c.messageLength+=i,i=[i/4294967296>>>0,i>>>0];for(var u=c.fullMessageLength.length-1;u>=0;--u)c.fullMessageLength[u]+=i[1],i[1]=i[0]+(c.fullMessageLength[u]/4294967296>>>0),c.fullMessageLength[u]=c.fullMessageLength[u]>>>0,i[0]=i[1]/4294967296>>>0;return s.putBytes(r),a(t,o,s),(s.read>2048||0===s.length())&&s.compact(),c},c.digest=function(){var n=e.util.createBuffer();n.putBytes(s.bytes());var i,u=c.fullMessageLength[c.fullMessageLength.length-1]+c.messageLengthSize&c.blockLength-1;n.putBytes(r.substr(0,c.blockLength-u));for(var l=8*c.fullMessageLength[0],f=0;f<c.fullMessageLength.length-1;++f)l+=(i=8*c.fullMessageLength[f+1])/4294967296>>>0,n.putInt32(l>>>0),l=i>>>0;n.putInt32(l);var p={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4,h5:t.h5,h6:t.h6,h7:t.h7};a(p,o,n);var h=e.util.createBuffer();return h.putInt32(p.h0),h.putInt32(p.h1),h.putInt32(p.h2),h.putInt32(p.h3),h.putInt32(p.h4),h.putInt32(p.h5),h.putInt32(p.h6),h.putInt32(p.h7),h},c};var r=null,n=!1,i=null;function a(e,t,r){for(var n,a,s,o,c,u,l,f,p,h,d,g,y,m=r.length();m>=64;){for(c=0;c<16;++c)t[c]=r.getInt32();for(;c<64;++c)n=((n=t[c-2])>>>17|n<<15)^(n>>>19|n<<13)^n>>>10,a=((a=t[c-15])>>>7|a<<25)^(a>>>18|a<<14)^a>>>3,t[c]=n+t[c-7]+a+t[c-16]|0;for(u=e.h0,l=e.h1,f=e.h2,p=e.h3,h=e.h4,d=e.h5,g=e.h6,y=e.h7,c=0;c<64;++c)s=(u>>>2|u<<30)^(u>>>13|u<<19)^(u>>>22|u<<10),o=u&l|f&(u^l),n=y+((h>>>6|h<<26)^(h>>>11|h<<21)^(h>>>25|h<<7))+(g^h&(d^g))+i[c]+t[c],y=g,g=d,d=h,h=p+n>>>0,p=f,f=l,l=u,u=n+(a=s+o)>>>0;e.h0=e.h0+u|0,e.h1=e.h1+l|0,e.h2=e.h2+f|0,e.h3=e.h3+p|0,e.h4=e.h4+h|0,e.h5=e.h5+d|0,e.h6=e.h6+g|0,e.h7=e.h7+y|0,m-=64}}return Pr.exports}var Vr,Kr,Mr,Fr,jr,qr,Hr={exports:{}};function Gr(){if(Vr)return Hr.exports;Vr=1;var e=zt();Zt();var t=null;return!e.util.isNodejs||e.options.usePureJavaScript||process.versions["node-webkit"]||(t=Rr),(Hr.exports=e.prng=e.prng||{}).create=function(r){for(var n={plugin:r,key:null,seed:null,time:null,reseeds:0,generated:0,keyBytes:""},i=r.md,a=new Array(32),s=0;s<32;++s)a[s]=i.create();function o(){if(n.pools[0].messageLength>=32)return c();var e=32-n.pools[0].messageLength<<5;n.collect(n.seedFileSync(e)),c()}function c(){n.reseeds=4294967295===n.reseeds?0:n.reseeds+1;var e=n.plugin.md.create();e.update(n.keyBytes);for(var t=1,r=0;r<32;++r)n.reseeds%t===0&&(e.update(n.pools[r].digest().getBytes()),n.pools[r].start()),t<<=1;n.keyBytes=e.digest().getBytes(),e.start(),e.update(n.keyBytes);var i=e.digest().getBytes();n.key=n.plugin.formatKey(n.keyBytes),n.seed=n.plugin.formatSeed(i),n.generated=0}function u(t){var r=null,n=e.util.globalScope,i=n.crypto||n.msCrypto;i&&i.getRandomValues&&(r=function(e){return i.getRandomValues(e)});var a=e.util.createBuffer();if(r)for(;a.length()<t;){var s=Math.max(1,Math.min(t-a.length(),65536)/4),o=new Uint32Array(Math.floor(s));try{r(o);for(var c=0;c<o.length;++c)a.putInt32(o[c])}catch(h){if(!("undefined"!=typeof QuotaExceededError&&h instanceof QuotaExceededError))throw h}}if(a.length()<t)for(var u,l,f,p=Math.floor(65536*Math.random());a.length()<t;){l=16807*(65535&p),l+=(32767&(u=16807*(p>>16)))<<16,p=4294967295&(l=(2147483647&(l+=u>>15))+(l>>31));for(c=0;c<3;++c)f=p>>>(c<<3),f^=Math.floor(256*Math.random()),a.putByte(255&f)}return a.getBytes(t)}return n.pools=a,n.pool=0,n.generate=function(t,r){if(!r)return n.generateSync(t);var i=n.plugin.cipher,a=n.plugin.increment,s=n.plugin.formatKey,o=n.plugin.formatSeed,u=e.util.createBuffer();n.key=null,function l(f){if(f)return r(f);if(u.length()>=t)return r(null,u.getBytes(t));n.generated>1048575&&(n.key=null);if(null===n.key)return e.util.nextTick(function(){!function(e){if(n.pools[0].messageLength>=32)return c(),e();var t=32-n.pools[0].messageLength<<5;n.seedFile(t,function(t,r){if(t)return e(t);n.collect(r),c(),e()})}(l)});var p=i(n.key,n.seed);n.generated+=p.length,u.putBytes(p),n.key=s(i(n.key,a(n.seed))),n.seed=o(i(n.key,n.seed)),e.util.setImmediate(l)}()},n.generateSync=function(t){var r=n.plugin.cipher,i=n.plugin.increment,a=n.plugin.formatKey,s=n.plugin.formatSeed;n.key=null;for(var c=e.util.createBuffer();c.length()<t;){n.generated>1048575&&(n.key=null),null===n.key&&o();var u=r(n.key,n.seed);n.generated+=u.length,c.putBytes(u),n.key=a(r(n.key,i(n.seed))),n.seed=s(r(n.key,n.seed))}return c.getBytes(t)},t?(n.seedFile=function(e,r){t.randomBytes(e,function(e,t){if(e)return r(e);r(null,t.toString())})},n.seedFileSync=function(e){return t.randomBytes(e).toString()}):(n.seedFile=function(e,t){try{t(null,u(e))}catch(r){t(r)}},n.seedFileSync=u),n.collect=function(e){for(var t=e.length,r=0;r<t;++r)n.pools[n.pool].update(e.substr(r,1)),n.pool=31===n.pool?0:n.pool+1},n.collectInt=function(e,t){for(var r="",i=0;i<t;i+=8)r+=String.fromCharCode(e>>i&255);n.collect(r)},n.registerWorker=function(e){if(e===self)n.seedFile=function(e,t){self.addEventListener("message",function e(r){var n=r.data;n.forge&&n.forge.prng&&(self.removeEventListener("message",e),t(n.forge.prng.err,n.forge.prng.bytes))}),self.postMessage({forge:{prng:{needed:e}}})};else{e.addEventListener("message",function(t){var r=t.data;r.forge&&r.forge.prng&&n.seedFile(r.forge.prng.needed,function(t,r){e.postMessage({forge:{prng:{err:t,bytes:r}}})})})}},n},Hr.exports}function zr(){if(Kr)return Or.exports;Kr=1;var e=zt();return sr(),xr(),Gr(),Zt(),e.random&&e.random.getBytes?Or.exports=e.random:function(t){var r={},n=new Array(4),i=e.util.createBuffer();function a(){var t=e.prng.create(r);return t.getBytes=function(e,r){return t.generate(e,r)},t.getBytesSync=function(e){return t.generate(e)},t}r.formatKey=function(t){var r=e.util.createBuffer(t);return(t=new Array(4))[0]=r.getInt32(),t[1]=r.getInt32(),t[2]=r.getInt32(),t[3]=r.getInt32(),e.aes._expandKey(t,!1)},r.formatSeed=function(t){var r=e.util.createBuffer(t);return(t=new Array(4))[0]=r.getInt32(),t[1]=r.getInt32(),t[2]=r.getInt32(),t[3]=r.getInt32(),t},r.cipher=function(t,r){return e.aes._updateBlock(t,r,n,!1),i.putInt32(n[0]),i.putInt32(n[1]),i.putInt32(n[2]),i.putInt32(n[3]),i.getBytes()},r.increment=function(e){return++e[3],e},r.md=e.md.sha256;var s=a(),o=null,c=e.util.globalScope,u=c.crypto||c.msCrypto;if(u&&u.getRandomValues&&(o=function(e){return u.getRandomValues(e)}),e.options.usePureJavaScript||!e.util.isNodejs&&!o){if(s.collectInt(+new Date,32),"undefined"!=typeof navigator){var l="";for(var f in navigator)try{"string"==typeof navigator[f]&&(l+=navigator[f])}catch(p){}s.collect(l),l=null}t&&(t().mousemove(function(e){s.collectInt(e.clientX,16),s.collectInt(e.clientY,16)}),t().keypress(function(e){s.collectInt(e.charCode,8)}))}if(e.random)for(var f in s)e.random[f]=s[f];else e.random=s;e.random.createInstance=a,Or.exports=e.random}("undefined"!=typeof jQuery?jQuery:null),Or.exports}function Qr(){if(Fr)return Mr;Fr=1;var e=zt();Zt();var t=[217,120,249,196,25,221,181,237,40,233,253,121,74,160,216,157,198,126,55,131,43,118,83,142,98,76,100,136,68,139,251,162,23,154,89,245,135,179,79,19,97,69,109,141,9,129,125,50,189,143,64,235,134,183,123,11,240,149,33,34,92,107,78,130,84,214,101,147,206,96,178,28,115,86,192,20,167,140,241,220,18,117,202,31,59,190,228,209,66,61,212,48,163,60,182,38,111,191,14,218,70,105,7,87,39,242,29,155,188,148,67,3,248,17,199,246,144,239,62,231,6,195,213,47,200,102,30,215,8,232,234,222,128,82,238,247,132,170,114,172,53,77,106,42,150,26,210,113,90,21,73,116,75,159,208,94,4,24,164,236,194,224,65,110,15,81,203,204,36,145,175,80,161,244,112,57,153,124,58,133,35,184,180,122,252,2,54,91,37,85,151,49,45,93,250,152,227,138,146,174,5,223,41,16,103,108,186,201,211,0,230,207,225,158,168,44,99,22,1,63,88,226,137,169,13,56,52,27,171,51,255,176,187,72,12,95,185,177,205,46,197,243,219,71,229,165,156,119,10,166,32,104,254,127,193,173],r=[1,2,3,5],n=function(e,t){return e<<t&65535|(65535&e)>>16-t},i=function(e,t){return(65535&e)>>t|e<<16-t&65535};Mr=e.rc2=e.rc2||{},e.rc2.expandKey=function(r,n){"string"==typeof r&&(r=e.util.createBuffer(r)),n=n||128;var i,a=r,s=r.length(),o=n,c=Math.ceil(o/8),u=255>>(7&o);for(i=s;i<128;i++)a.putByte(t[a.at(i-1)+a.at(i-s)&255]);for(a.setAt(128-c,t[a.at(128-c)&u]),i=127-c;i>=0;i--)a.setAt(i,t[a.at(i+1)^a.at(i+c)]);return a};var a=function(t,a,s){var o,c,u,l,f=!1,p=null,h=null,d=null,g=[];for(t=e.rc2.expandKey(t,a),u=0;u<64;u++)g.push(t.getInt16Le());s?(o=function(e){for(u=0;u<4;u++)e[u]+=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),e[u]=n(e[u],r[u]),l++},c=function(e){for(u=0;u<4;u++)e[u]+=g[63&e[(u+3)%4]]}):(o=function(e){for(u=3;u>=0;u--)e[u]=i(e[u],r[u]),e[u]-=g[l]+(e[(u+3)%4]&e[(u+2)%4])+(~e[(u+3)%4]&e[(u+1)%4]),l--},c=function(e){for(u=3;u>=0;u--)e[u]-=g[63&e[(u+3)%4]]});var y=function(e){var t=[];for(u=0;u<4;u++){var r=p.getInt16Le();null!==d&&(s?r^=d.getInt16Le():d.putInt16Le(r)),t.push(65535&r)}l=s?0:63;for(var n=0;n<e.length;n++)for(var i=0;i<e[n][0];i++)e[n][1](t);for(u=0;u<4;u++)null!==d&&(s?d.putInt16Le(t[u]):t[u]^=d.getInt16Le()),h.putInt16Le(t[u])},m=null;return m={start:function(t,r){t&&"string"==typeof t&&(t=e.util.createBuffer(t)),f=!1,p=e.util.createBuffer(),h=r||new e.util.createBuffer,d=t,m.output=h},update:function(e){for(f||p.putBuffer(e);p.length()>=8;)y([[5,o],[1,c],[6,o],[1,c],[5,o]])},finish:function(e){var t=!0;if(s)if(e)t=e(8,p,!s);else{var r=8===p.length()?8:8-p.length();p.fillWithByte(r,r)}if(t&&(f=!0,m.update()),!s&&(t=0===p.length()))if(e)t=e(8,h,!s);else{var n=h.length(),i=h.at(n-1);i>n?t=!1:h.truncate(i)}return t}}};return e.rc2.startEncrypting=function(t,r,n){var i=e.rc2.createEncryptionCipher(t,128);return i.start(r,n),i},e.rc2.createEncryptionCipher=function(e,t){return a(e,t,!0)},e.rc2.startDecrypting=function(t,r,n){var i=e.rc2.createDecryptionCipher(t,128);return i.start(r,n),i},e.rc2.createDecryptionCipher=function(e,t){return a(e,t,!1)},Mr}function Wr(){if(qr)return jr;qr=1;var e,t=zt();function r(e,t,r){this.data=[],null!=e&&("number"==typeof e?this.fromNumber(e,t,r):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function n(){return new r(null)}function i(e,t,r,n,i,a){for(var s=16383&t,o=t>>14;--a>=0;){var c=16383&this.data[e],u=this.data[e++]>>14,l=o*c+u*s;i=((c=s*c+((16383&l)<<14)+r.data[n]+i)>>28)+(l>>14)+o*u,r.data[n++]=268435455&c}return i}jr=t.jsbn=t.jsbn||{},t.jsbn.BigInteger=r,"undefined"==typeof navigator?(r.prototype.am=i,e=28):"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(e,t,r,n,i,a){for(var s=32767&t,o=t>>15;--a>=0;){var c=32767&this.data[e],u=this.data[e++]>>15,l=o*c+u*s;i=((c=s*c+((32767&l)<<15)+r.data[n]+(1073741823&i))>>>30)+(l>>>15)+o*u+(i>>>30),r.data[n++]=1073741823&c}return i},e=30):"Netscape"!=navigator.appName?(r.prototype.am=function(e,t,r,n,i,a){for(;--a>=0;){var s=t*this.data[e++]+r.data[n]+i;i=Math.floor(s/67108864),r.data[n++]=67108863&s}return i},e=26):(r.prototype.am=i,e=28),r.prototype.DB=e,r.prototype.DM=(1<<e)-1,r.prototype.DV=1<<e;r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-e,r.prototype.F2=2*e-52;var a,s,o=new Array;for(a="0".charCodeAt(0),s=0;s<=9;++s)o[a++]=s;for(a="a".charCodeAt(0),s=10;s<36;++s)o[a++]=s;for(a="A".charCodeAt(0),s=10;s<36;++s)o[a++]=s;function c(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function u(e,t){var r=o[e.charCodeAt(t)];return null==r?-1:r}function l(e){var t=n();return t.fromInt(e),t}function f(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function p(e){this.m=e}function h(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function d(e,t){return e&t}function g(e,t){return e|t}function y(e,t){return e^t}function m(e,t){return e&~t}function v(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function C(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function E(){}function S(e){return e}function T(e){this.r2=n(),this.q3=n(),r.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}p.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},p.prototype.revert=function(e){return e},p.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},p.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},h.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(r.ZERO)>0&&this.m.subTo(t,t),t},h.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},h.prototype.reduce=function(e){for(;e.t<=this.mt2;)e.data[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e.data[t],n=r*this.mpl+((r*this.mph+(e.data[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e.data[r]+=this.m.am(0,n,e,t,0,this.m.t);e.data[r]>=e.DV;)e.data[r]-=e.DV,e.data[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},h.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},h.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},r.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e.data[t]=this.data[t];e.t=this.t,e.s=this.s},r.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this.data[0]=e:e<-1?this.data[0]=e+this.DV:this.t=0},r.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var i=e.length,a=!1,s=0;--i>=0;){var o=8==n?255&e[i]:u(e,i);o<0?"-"==e.charAt(i)&&(a=!0):(a=!1,0==s?this.data[this.t++]=o:s+n>this.DB?(this.data[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this.data[this.t++]=o>>this.DB-s):this.data[this.t-1]|=o<<s,(s+=n)>=this.DB&&(s-=this.DB))}8==n&&128&e[0]&&(this.s=-1,s>0&&(this.data[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),a&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this.data[this.t-1]==e;)--this.t},r.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t.data[r+e]=this.data[r];for(r=e-1;r>=0;--r)t.data[r]=0;t.t=this.t+e,t.s=this.s},r.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t.data[r-e]=this.data[r];t.t=Math.max(this.t-e,0),t.s=this.s},r.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,a=(1<<i)-1,s=Math.floor(e/this.DB),o=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t.data[r+s+1]=this.data[r]>>i|o,o=(this.data[r]&a)<<n;for(r=s-1;r>=0;--r)t.data[r]=0;t.data[s]=o,t.t=this.t+s+1,t.s=this.s,t.clamp()},r.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,a=(1<<n)-1;t.data[0]=this.data[r]>>n;for(var s=r+1;s<this.t;++s)t.data[s-r-1]|=(this.data[s]&a)<<i,t.data[s-r]=this.data[s]>>n;n>0&&(t.data[this.t-r-1]|=(this.s&a)<<i),t.t=this.t-r,t.clamp()}},r.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]-e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t.data[r++]=this.DV+n:n>0&&(t.data[r++]=n),t.t=r,t.clamp()},r.prototype.multiplyTo=function(e,t){var n=this.abs(),i=e.abs(),a=n.t;for(t.t=a+i.t;--a>=0;)t.data[a]=0;for(a=0;a<i.t;++a)t.data[a+n.t]=n.am(0,i.data[a],t,a,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&r.ZERO.subTo(t,t)},r.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e.data[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t.data[r],e,2*r,0,1);(e.data[r+t.t]+=t.am(r+1,2*t.data[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e.data[r+t.t]-=t.DV,e.data[r+t.t+1]=1)}e.t>0&&(e.data[e.t-1]+=t.am(r,t.data[r],e,2*r,0,1)),e.s=0,e.clamp()},r.prototype.divRemTo=function(e,t,i){var a=e.abs();if(!(a.t<=0)){var s=this.abs();if(s.t<a.t)return null!=t&&t.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=n());var o=n(),c=this.s,u=e.s,l=this.DB-f(a.data[a.t-1]);l>0?(a.lShiftTo(l,o),s.lShiftTo(l,i)):(a.copyTo(o),s.copyTo(i));var p=o.t,h=o.data[p-1];if(0!=h){var d=h*(1<<this.F1)+(p>1?o.data[p-2]>>this.F2:0),g=this.FV/d,y=(1<<this.F1)/d,m=1<<this.F2,v=i.t,C=v-p,E=null==t?n():t;for(o.dlShiftTo(C,E),i.compareTo(E)>=0&&(i.data[i.t++]=1,i.subTo(E,i)),r.ONE.dlShiftTo(p,E),E.subTo(o,o);o.t<p;)o.data[o.t++]=0;for(;--C>=0;){var S=i.data[--v]==h?this.DM:Math.floor(i.data[v]*g+(i.data[v-1]+m)*y);if((i.data[v]+=o.am(0,S,i,C,0,p))<S)for(o.dlShiftTo(C,E),i.subTo(E,i);i.data[v]<--S;)i.subTo(E,i)}null!=t&&(i.drShiftTo(p,t),c!=u&&r.ZERO.subTo(t,t)),i.t=p,i.clamp(),l>0&&i.rShiftTo(l,i),c<0&&r.ZERO.subTo(i,i)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var e=this.data[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},r.prototype.isEven=function(){return 0==(this.t>0?1&this.data[0]:this.s)},r.prototype.exp=function(e,t){if(e>4294967295||e<1)return r.ONE;var i=n(),a=n(),s=t.convert(this),o=f(e)-1;for(s.copyTo(i);--o>=0;)if(t.sqrTo(i,a),(e&1<<o)>0)t.mulTo(a,s,i);else{var c=i;i=a,a=c}return t.revert(i)},r.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<<t)-1,i=!1,a="",s=this.t,o=this.DB-s*this.DB%t;if(s-- >0)for(o<this.DB&&(r=this.data[s]>>o)>0&&(i=!0,a=c(r));s>=0;)o<t?(r=(this.data[s]&(1<<o)-1)<<t-o,r|=this.data[--s]>>(o+=this.DB-t)):(r=this.data[s]>>(o-=t)&n,o<=0&&(o+=this.DB,--s)),r>0&&(i=!0),i&&(a+=c(r));return i?a:"0"},r.prototype.negate=function(){var e=n();return r.ZERO.subTo(this,e),e},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this.data[r]-e.data[r]))return t;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+f(this.data[this.t-1]^this.s&this.DM)},r.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(r.ZERO)>0&&e.subTo(t,t),t},r.prototype.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new p(t):new h(t),this.exp(e,r)},r.ZERO=l(0),r.ONE=l(1),E.prototype.convert=S,E.prototype.revert=S,E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},E.prototype.sqrTo=function(e,t){e.squareTo(t)},T.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=n();return e.copyTo(t),this.reduce(t),t},T.prototype.revert=function(e){return e},T.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},T.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},T.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var b=[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],A=(1<<26)/b[b.length-1];return r.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},r.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),i=l(r),a=n(),s=n(),o="";for(this.divRemTo(i,a,s);a.signum()>0;)o=(r+s.intValue()).toString(e).substr(1)+o,a.divRemTo(i,a,s);return s.intValue().toString(e)+o},r.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),i=Math.pow(t,n),a=!1,s=0,o=0,c=0;c<e.length;++c){var l=u(e,c);l<0?"-"==e.charAt(c)&&0==this.signum()&&(a=!0):(o=t*o+l,++s>=n&&(this.dMultiply(i),this.dAddOffset(o,0),s=0,o=0))}s>0&&(this.dMultiply(Math.pow(t,s)),this.dAddOffset(o,0)),a&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(r.ONE.shiftLeft(e-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(r.ONE.shiftLeft(e-1),this);else{var i=new Array,a=7&e;i.length=1+(e>>3),t.nextBytes(i),a>0?i[0]&=(1<<a)-1:i[0]=0,this.fromString(i,256)}},r.prototype.bitwiseTo=function(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n<a;++n)r.data[n]=t(this.data[n],e.data[n]);if(e.t<this.t){for(i=e.s&this.DM,n=a;n<this.t;++n)r.data[n]=t(this.data[n],i);r.t=this.t}else{for(i=this.s&this.DM,n=a;n<e.t;++n)r.data[n]=t(i,e.data[n]);r.t=e.t}r.s=t(this.s,e.s),r.clamp()},r.prototype.changeBit=function(e,t){var n=r.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n},r.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this.data[r]+e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e.data[r],t.data[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t.data[r++]=n:n<-1&&(t.data[r++]=this.DV+n),t.t=r,t.clamp()},r.prototype.dMultiply=function(e){this.data[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this.data[this.t++]=0;for(this.data[t]+=e;this.data[t]>=this.DV;)this.data[t]-=this.DV,++t>=this.t&&(this.data[this.t++]=0),++this.data[t]}},r.prototype.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r.data[--i]=0;for(n=r.t-this.t;i<n;++i)r.data[i+this.t]=this.am(0,e.data[i],r,i,0,this.t);for(n=Math.min(e.t,t);i<n;++i)this.am(0,e.data[i],r,i,0,t-i);r.clamp()},r.prototype.multiplyUpperTo=function(e,t,r){--t;var n=r.t=this.t+e.t-t;for(r.s=0;--n>=0;)r.data[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)r.data[this.t+n-t]=this.am(t-n,e.data[n],r,0,0,this.t+n-t);r.clamp(),r.drShiftTo(1,r)},r.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(0==t)r=this.data[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this.data[n])%e;return r},r.prototype.millerRabin=function(e){var t=this.subtract(r.ONE),n=t.getLowestSetBit();if(n<=0)return!1;for(var i,a=t.shiftRight(n),s={nextBytes:function(e){for(var t=0;t<e.length;++t)e[t]=Math.floor(256*Math.random())}},o=0;o<e;++o){do{i=new r(this.bitLength(),s)}while(i.compareTo(r.ONE)<=0||i.compareTo(t)>=0);var c=i.modPow(a,this);if(0!=c.compareTo(r.ONE)&&0!=c.compareTo(t)){for(var u=1;u++<n&&0!=c.compareTo(t);)if(0==(c=c.modPowInt(2,this)).compareTo(r.ONE))return!1;if(0!=c.compareTo(t))return!1}}return!0},r.prototype.clone=function(){var e=n();return this.copyTo(e),e},r.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this.data[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this.data[0];if(0==this.t)return 0}return(this.data[1]&(1<<32-this.DB)-1)<<this.DB|this.data[0]},r.prototype.byteValue=function(){return 0==this.t?this.s:this.data[0]<<24>>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this.data[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this.data[0]<=0?0:1},r.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n<this.DB&&(r=this.data[e]>>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<<this.DB-n);e>=0;)n<8?(r=(this.data[e]&(1<<n)-1)<<8-n,r|=this.data[--e]>>(n+=this.DB-8)):(r=this.data[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&r&&(r|=-256),0==i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},r.prototype.equals=function(e){return 0==this.compareTo(e)},r.prototype.min=function(e){return this.compareTo(e)<0?this:e},r.prototype.max=function(e){return this.compareTo(e)>0?this:e},r.prototype.and=function(e){var t=n();return this.bitwiseTo(e,d,t),t},r.prototype.or=function(e){var t=n();return this.bitwiseTo(e,g,t),t},r.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,y,t),t},r.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,m,t),t},r.prototype.not=function(){for(var e=n(),t=0;t<this.t;++t)e.data[t]=this.DM&~this.data[t];return e.t=this.t,e.s=~this.s,e},r.prototype.shiftLeft=function(e){var t=n();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},r.prototype.shiftRight=function(e){var t=n();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},r.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this.data[e])return e*this.DB+v(this.data[e]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,r=0;r<this.t;++r)e+=C(this.data[r]^t);return e},r.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this.data[t]&1<<e%this.DB)},r.prototype.setBit=function(e){return this.changeBit(e,g)},r.prototype.clearBit=function(e){return this.changeBit(e,m)},r.prototype.flipBit=function(e){return this.changeBit(e,y)},r.prototype.add=function(e){var t=n();return this.addTo(e,t),t},r.prototype.subtract=function(e){var t=n();return this.subTo(e,t),t},r.prototype.multiply=function(e){var t=n();return this.multiplyTo(e,t),t},r.prototype.divide=function(e){var t=n();return this.divRemTo(e,t,null),t},r.prototype.remainder=function(e){var t=n();return this.divRemTo(e,null,t),t},r.prototype.divideAndRemainder=function(e){var t=n(),r=n();return this.divRemTo(e,t,r),new Array(t,r)},r.prototype.modPow=function(e,t){var r,i,a=e.bitLength(),s=l(1);if(a<=0)return s;r=a<18?1:a<48?3:a<144?4:a<768?5:6,i=a<8?new p(t):t.isEven()?new T(t):new h(t);var o=new Array,c=3,u=r-1,d=(1<<r)-1;if(o[1]=i.convert(this),r>1){var g=n();for(i.sqrTo(o[1],g);c<=d;)o[c]=n(),i.mulTo(g,o[c-2],o[c]),c+=2}var y,m,v=e.t-1,C=!0,E=n();for(a=f(e.data[v])-1;v>=0;){for(a>=u?y=e.data[v]>>a-u&d:(y=(e.data[v]&(1<<a+1)-1)<<u-a,v>0&&(y|=e.data[v-1]>>this.DB+a-u)),c=r;!(1&y);)y>>=1,--c;if((a-=c)<0&&(a+=this.DB,--v),C)o[y].copyTo(s),C=!1;else{for(;c>1;)i.sqrTo(s,E),i.sqrTo(E,s),c-=2;c>0?i.sqrTo(s,E):(m=s,s=E,E=m),i.mulTo(E,o[y],s)}for(;v>=0&&!(e.data[v]&1<<a);)i.sqrTo(s,E),m=s,s=E,E=m,--a<0&&(a=this.DB-1,--v)}return i.revert(s)},r.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return r.ZERO;for(var n=e.clone(),i=this.clone(),a=l(1),s=l(0),o=l(0),c=l(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?(a.isEven()&&s.isEven()||(a.addTo(this,a),s.subTo(e,s)),a.rShiftTo(1,a)):s.isEven()||s.subTo(e,s),s.rShiftTo(1,s);for(;i.isEven();)i.rShiftTo(1,i),t?(o.isEven()&&c.isEven()||(o.addTo(this,o),c.subTo(e,c)),o.rShiftTo(1,o)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);n.compareTo(i)>=0?(n.subTo(i,n),t&&a.subTo(o,a),s.subTo(c,s)):(i.subTo(n,i),t&&o.subTo(a,o),c.subTo(s,c))}return 0!=i.compareTo(r.ONE)?r.ZERO:c.compareTo(e)>=0?c.subtract(e):c.signum()<0?(c.addTo(e,c),c.signum()<0?c.add(e):c):c},r.prototype.pow=function(e){return this.exp(e,new E)},r.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),a=r.getLowestSetBit();if(a<0)return t;for(i<a&&(a=i),a>0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r},r.prototype.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r.data[0]<=b[b.length-1]){for(t=0;t<b.length;++t)if(r.data[0]==b[t])return!0;return!1}if(r.isEven())return!1;for(t=1;t<b.length;){for(var n=b[t],i=t+1;i<b.length&&n<A;)n*=b[i++];for(n=r.modInt(n);t<i;)if(n%b[t++]==0)return!1}return r.millerRabin(e)},jr}var Yr,Xr,$r={exports:{}},Jr={exports:{}};function Zr(){if(Yr)return Jr.exports;Yr=1;var e=zt();vr(),Zt();var t=Jr.exports=e.sha1=e.sha1||{};e.md.sha1=e.md.algorithms.sha1=t,t.create=function(){n||(r=String.fromCharCode(128),r+=e.util.fillString(String.fromCharCode(0),64),n=!0);var t=null,a=e.util.createBuffer(),s=new Array(80),o={algorithm:"sha1",blockLength:64,digestLength:20,messageLength:0,fullMessageLength:null,messageLengthSize:8,start:function(){o.messageLength=0,o.fullMessageLength=o.messageLength64=[];for(var r=o.messageLengthSize/4,n=0;n<r;++n)o.fullMessageLength.push(0);return a=e.util.createBuffer(),t={h0:1732584193,h1:4023233417,h2:2562383102,h3:271733878,h4:3285377520},o}};return o.start(),o.update=function(r,n){"utf8"===n&&(r=e.util.encodeUtf8(r));var c=r.length;o.messageLength+=c,c=[c/4294967296>>>0,c>>>0];for(var u=o.fullMessageLength.length-1;u>=0;--u)o.fullMessageLength[u]+=c[1],c[1]=c[0]+(o.fullMessageLength[u]/4294967296>>>0),o.fullMessageLength[u]=o.fullMessageLength[u]>>>0,c[0]=c[1]/4294967296>>>0;return a.putBytes(r),i(t,s,a),(a.read>2048||0===a.length())&&a.compact(),o},o.digest=function(){var n=e.util.createBuffer();n.putBytes(a.bytes());var c,u=o.fullMessageLength[o.fullMessageLength.length-1]+o.messageLengthSize&o.blockLength-1;n.putBytes(r.substr(0,o.blockLength-u));for(var l=8*o.fullMessageLength[0],f=0;f<o.fullMessageLength.length-1;++f)l+=(c=8*o.fullMessageLength[f+1])/4294967296>>>0,n.putInt32(l>>>0),l=c>>>0;n.putInt32(l);var p={h0:t.h0,h1:t.h1,h2:t.h2,h3:t.h3,h4:t.h4};i(p,s,n);var h=e.util.createBuffer();return h.putInt32(p.h0),h.putInt32(p.h1),h.putInt32(p.h2),h.putInt32(p.h3),h.putInt32(p.h4),h},o};var r=null,n=!1;function i(e,t,r){for(var n,i,a,s,o,c,u,l=r.length();l>=64;){for(i=e.h0,a=e.h1,s=e.h2,o=e.h3,c=e.h4,u=0;u<16;++u)n=r.getInt32(),t[u]=n,n=(i<<5|i>>>27)+(o^a&(s^o))+c+1518500249+n,c=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<20;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(o^a&(s^o))+c+1518500249+n,c=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<32;++u)n=(n=t[u-3]^t[u-8]^t[u-14]^t[u-16])<<1|n>>>31,t[u]=n,n=(i<<5|i>>>27)+(a^s^o)+c+1859775393+n,c=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<40;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a^s^o)+c+1859775393+n,c=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<60;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a&s|o&(a^s))+c+2400959708+n,c=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;for(;u<80;++u)n=(n=t[u-6]^t[u-16]^t[u-28]^t[u-32])<<2|n>>>30,t[u]=n,n=(i<<5|i>>>27)+(a^s^o)+c+3395469782+n,c=o,o=s,s=(a<<30|a>>>2)>>>0,a=i,i=n;e.h0=e.h0+i|0,e.h1=e.h1+a|0,e.h2=e.h2+s|0,e.h3=e.h3+o|0,e.h4=e.h4+c|0,l-=64}}return Jr.exports}function en(){if(Xr)return $r.exports;Xr=1;var e=zt();Zt(),zr(),Zr();var t=$r.exports=e.pkcs1=e.pkcs1||{};function r(t,r,n){n||(n=e.md.sha1.create());for(var i="",a=Math.ceil(r/n.digestLength),s=0;s<a;++s){var o=String.fromCharCode(s>>24&255,s>>16&255,s>>8&255,255&s);n.start(),n.update(t+o),i+=n.digest().getBytes()}return i.substring(0,r)}return t.encode_rsa_oaep=function(t,n,i){var a,s,o,c;"string"==typeof i?(a=i,s=arguments[3]||void 0,o=arguments[4]||void 0):i&&(a=i.label||void 0,s=i.seed||void 0,o=i.md||void 0,i.mgf1&&i.mgf1.md&&(c=i.mgf1.md)),o?o.start():o=e.md.sha1.create(),c||(c=o);var u=Math.ceil(t.n.bitLength()/8),l=u-2*o.digestLength-2;if(n.length>l)throw(y=new Error("RSAES-OAEP input message length is too long.")).length=n.length,y.maxLength=l,y;a||(a=""),o.update(a,"raw");for(var f=o.digest(),p="",h=l-n.length,d=0;d<h;d++)p+="\0";var g=f.getBytes()+p+""+n;if(s){if(s.length!==o.digestLength){var y;throw(y=new Error("Invalid RSAES-OAEP seed. The seed length must match the digest length.")).seedLength=s.length,y.digestLength=o.digestLength,y}}else s=e.random.getBytes(o.digestLength);var m=r(s,u-o.digestLength-1,c),v=e.util.xorBytes(g,m,g.length),C=r(v,o.digestLength,c);return"\0"+e.util.xorBytes(s,C,s.length)+v},t.decode_rsa_oaep=function(t,n,i){var a,s,o;"string"==typeof i?(a=i,s=arguments[3]||void 0):i&&(a=i.label||void 0,s=i.md||void 0,i.mgf1&&i.mgf1.md&&(o=i.mgf1.md));var c=Math.ceil(t.n.bitLength()/8);if(n.length!==c)throw(m=new Error("RSAES-OAEP encoded message length is invalid.")).length=n.length,m.expectedLength=c,m;if(void 0===s?s=e.md.sha1.create():s.start(),o||(o=s),c<2*s.digestLength+2)throw new Error("RSAES-OAEP key is too short for the hash function.");a||(a=""),s.update(a,"raw");for(var u=s.digest().getBytes(),l=n.charAt(0),f=n.substring(1,s.digestLength+1),p=n.substring(1+s.digestLength),h=r(p,s.digestLength,o),d=r(e.util.xorBytes(f,h,f.length),c-s.digestLength-1,o),g=e.util.xorBytes(p,d,p.length),y=g.substring(0,s.digestLength),m="\0"!==l,v=0;v<s.digestLength;++v)m|=u.charAt(v)!==y.charAt(v);for(var C=1,E=s.digestLength,S=s.digestLength;S<g.length;S++){var T=g.charCodeAt(S);m|=T&(C?65534:0),E+=C&=1&T^1}if(m||1!==g.charCodeAt(E))throw new Error("Invalid RSAES-OAEP padding.");return g.substring(E+1)},$r.exports}var tn,rn,nn,an,sn,on={exports:{}};function cn(){if(tn)return on.exports;tn=1;var e=zt();return Zt(),Wr(),zr(),function(){if(e.prime)on.exports=e.prime;else{var t=on.exports=e.prime=e.prime||{},r=e.jsbn.BigInteger,n=[6,4,2,4,2,4,6,2],i=new r(null);i.fromInt(30);var a=function(e,t){return e|t};t.generateProbablePrime=function(t,n,i){"function"==typeof n&&(i=n,n={});var a=(n=n||{}).algorithm||"PRIMEINC";"string"==typeof a&&(a={name:a}),a.options=a.options||{};var o=n.prng||e.random,u={nextBytes:function(e){for(var t=o.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}};if("PRIMEINC"===a.name)return function(t,n,i,a){if("workers"in i)return function(t,n,i,a){if("undefined"==typeof Worker)return s(t,n,i,a);var o=c(t,n),u=i.workers,l=i.workLoad||100,f=30*l/8,p=i.workerScript||"forge/prime.worker.js";if(-1===u)return e.util.estimateCores(function(e,t){e&&(t=2),u=t-1,h()});function h(){u=Math.max(1,u);for(var e=[],i=0;i<u;++i)e[i]=new Worker(p);for(i=0;i<u;++i)e[i].addEventListener("message",h);var s=!1;function h(i){if(!s){var u=i.data;if(u.found){for(var p=0;p<e.length;++p)e[p].terminate();return s=!0,a(null,new r(u.prime,16))}o.bitLength()>t&&(o=c(t,n));var h=o.toString(16);i.target.postMessage({hex:h,workLoad:l}),o.dAddOffset(f,0)}}}h()}(t,n,i,a);return s(t,n,i,a)}(t,u,a.options,i);throw new Error("Invalid prime generation algorithm: "+a.name)}}function s(e,t,r,n){var i=c(e,t),a=function(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}(i.bitLength());"millerRabinTests"in r&&(a=r.millerRabinTests);var s=10;"maxBlockTime"in r&&(s=r.maxBlockTime),o(i,e,t,0,a,s,n)}function o(t,r,i,a,s,u,l){var f=+new Date;do{if(t.bitLength()>r&&(t=c(r,i)),t.isProbablePrime(s))return l(null,t);t.dAddOffset(n[a++%8],0)}while(u<0||+new Date-f<u);e.util.setImmediate(function(){o(t,r,i,a,s,u,l)})}function c(e,t){var n=new r(e,t),s=e-1;return n.testBit(s)||n.bitwiseTo(r.ONE.shiftLeft(s),a,n),n.dAddOffset(31-n.mod(i).byteValue(),0),n}}(),on.exports}function un(){if(nn)return rn;nn=1;var e=zt();if(hr(),Wr(),pr(),en(),cn(),zr(),Zt(),void 0===t)var t=e.jsbn.BigInteger;var r=e.util.isNodejs?Rr:null,n=e.asn1,i=e.util;e.pki=e.pki||{},rn=e.pki.rsa=e.rsa=e.rsa||{};var a=e.pki,s=[6,4,2,4,2,4,6,2],o={name:"PrivateKeyInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},c={name:"RSAPrivateKey",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPrivateKey.version",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"RSAPrivateKey.modulus",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyModulus"},{name:"RSAPrivateKey.publicExponent",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyPublicExponent"},{name:"RSAPrivateKey.privateExponent",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyPrivateExponent"},{name:"RSAPrivateKey.prime1",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyPrime1"},{name:"RSAPrivateKey.prime2",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyPrime2"},{name:"RSAPrivateKey.exponent1",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyExponent1"},{name:"RSAPrivateKey.exponent2",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyExponent2"},{name:"RSAPrivateKey.coefficient",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"privateKeyCoefficient"}]},u={name:"RSAPublicKey",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"RSAPublicKey.modulus",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"publicKeyModulus"},{name:"RSAPublicKey.exponent",tagClass:n.Class.UNIVERSAL,type:n.Type.INTEGER,constructed:!1,capture:"publicKeyExponent"}]},l=e.pki.rsa.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{name:"SubjectPublicKeyInfo.subjectPublicKey",tagClass:n.Class.UNIVERSAL,type:n.Type.BITSTRING,constructed:!1,value:[{name:"SubjectPublicKeyInfo.subjectPublicKey.RSAPublicKey",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"rsaPublicKey"}]}]},f={name:"DigestInfo",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm",tagClass:n.Class.UNIVERSAL,type:n.Type.SEQUENCE,constructed:!0,value:[{name:"DigestInfo.DigestAlgorithm.algorithmIdentifier",tagClass:n.Class.UNIVERSAL,type:n.Type.OID,constructed:!1,capture:"algorithmIdentifier"},{name:"DigestInfo.DigestAlgorithm.parameters",tagClass:n.Class.UNIVERSAL,type:n.Type.NULL,capture:"parameters",optional:!0,constructed:!1}]},{name:"DigestInfo.digest",tagClass:n.Class.UNIVERSAL,type:n.Type.OCTETSTRING,constructed:!1,capture:"digest"}]},p=function(e){var t;if(!(e.algorithm in a.oids)){var r=new Error("Unknown message digest algorithm.");throw r.algorithm=e.algorithm,r}t=a.oids[e.algorithm];var i=n.oidToDer(t).getBytes(),s=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]),o=n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[]);o.value.push(n.create(n.Class.UNIVERSAL,n.Type.OID,!1,i)),o.value.push(n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,""));var c=n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,e.digest().getBytes());return s.value.push(o),s.value.push(c),n.toDer(s).getBytes()},h=function(r,n,i){if(i)return r.modPow(n.e,n.n);if(!n.p||!n.q)return r.modPow(n.d,n.n);var a;n.dP||(n.dP=n.d.mod(n.p.subtract(t.ONE))),n.dQ||(n.dQ=n.d.mod(n.q.subtract(t.ONE))),n.qInv||(n.qInv=n.q.modInverse(n.p));do{a=new t(e.util.bytesToHex(e.random.getBytes(n.n.bitLength()/8)),16)}while(a.compareTo(n.n)>=0||!a.gcd(n.n).equals(t.ONE));for(var s=(r=r.multiply(a.modPow(n.e,n.n)).mod(n.n)).mod(n.p).modPow(n.dP,n.p),o=r.mod(n.q).modPow(n.dQ,n.q);s.compareTo(o)<0;)s=s.add(n.p);var c=s.subtract(o).multiply(n.qInv).mod(n.p).multiply(n.q).add(o);return c=c.multiply(a.modInverse(n.n)).mod(n.n)};function d(t,r,n){var i=e.util.createBuffer(),a=Math.ceil(r.n.bitLength()/8);if(t.length>a-11){var s=new Error("Message is too long for PKCS#1 v1.5 padding.");throw s.length=t.length,s.max=a-11,s}i.putByte(0),i.putByte(n);var o,c=a-3-t.length;if(0===n||1===n){o=0===n?0:255;for(var u=0;u<c;++u)i.putByte(o)}else for(;c>0;){var l=0,f=e.random.getBytes(c);for(u=0;u<c;++u)0===(o=f.charCodeAt(u))?++l:i.putByte(o);c=l}return i.putByte(0),i.putBytes(t),i}function g(t,r,n,i){var a=Math.ceil(r.n.bitLength()/8),s=e.util.createBuffer(t),o=s.getByte(),c=s.getByte();if(0!==o||n&&0!==c&&1!==c||!n&&2!=c||n&&0===c&&void 0===i)throw new Error("Encryption block is invalid.");var u=0;if(0===c){u=a-3-i;for(var l=0;l<u;++l)if(0!==s.getByte())throw new Error("Encryption block is invalid.")}else if(1===c)for(u=0;s.length()>1;){if(255!==s.getByte()){--s.read;break}++u}else if(2===c)for(u=0;s.length()>1;){if(0===s.getByte()){--s.read;break}++u}if(0!==s.getByte()||u!==a-3-s.length())throw new Error("Encryption block is invalid.");return s.getBytes()}function y(t){var r=t.toString(16);r[0]>="8"&&(r="00"+r);var n=e.util.hexToBytes(r);return!(n.length>1)||(0!==n.charCodeAt(0)||128&n.charCodeAt(1))&&(255!==n.charCodeAt(0)||128&~n.charCodeAt(1))?n:n.substr(1)}function m(e){return e<=100?27:e<=150?18:e<=200?15:e<=250?12:e<=300?9:e<=350?8:e<=400?7:e<=500?6:e<=600?5:e<=800?4:e<=1250?3:2}function v(t){return e.util.isNodejs&&"function"==typeof r[t]}function C(e){return void 0!==i.globalScope&&"object"==typeof i.globalScope.crypto&&"object"==typeof i.globalScope.crypto.subtle&&"function"==typeof i.globalScope.crypto.subtle[e]}function E(e){return void 0!==i.globalScope&&"object"==typeof i.globalScope.msCrypto&&"object"==typeof i.globalScope.msCrypto.subtle&&"function"==typeof i.globalScope.msCrypto.subtle[e]}function S(t){for(var r=e.util.hexToBytes(t.toString(16)),n=new Uint8Array(r.length),i=0;i<r.length;++i)n[i]=r.charCodeAt(i);return n}return a.rsa.encrypt=function(r,n,i){var a,s=i,o=Math.ceil(n.n.bitLength()/8);!1!==i&&!0!==i?(s=2===i,a=d(r,n,i)):(a=e.util.createBuffer()).putBytes(r);for(var c=new t(a.toHex(),16),u=h(c,n,s).toString(16),l=e.util.createBuffer(),f=o-Math.ceil(u.length/2);f>0;)l.putByte(0),--f;return l.putBytes(e.util.hexToBytes(u)),l.getBytes()},a.rsa.decrypt=function(r,n,i,a){var s=Math.ceil(n.n.bitLength()/8);if(r.length!==s){var o=new Error("Encrypted message length is invalid.");throw o.length=r.length,o.expected=s,o}var c=new t(e.util.createBuffer(r).toHex(),16);if(c.compareTo(n.n)>=0)throw new Error("Encrypted message is invalid.");for(var u=h(c,n,i).toString(16),l=e.util.createBuffer(),f=s-Math.ceil(u.length/2);f>0;)l.putByte(0),--f;return l.putBytes(e.util.hexToBytes(u)),!1!==a?g(l.getBytes(),n,i):l.getBytes()},a.rsa.createKeyPairGenerationState=function(r,n,i){"string"==typeof r&&(r=parseInt(r,10)),r=r||2048;var a,s=(i=i||{}).prng||e.random,o={nextBytes:function(e){for(var t=s.getBytesSync(e.length),r=0;r<e.length;++r)e[r]=t.charCodeAt(r)}},c=i.algorithm||"PRIMEINC";if("PRIMEINC"!==c)throw new Error("Invalid key generation algorithm: "+c);return(a={algorithm:c,state:0,bits:r,rng:o,eInt:n||65537,e:new t(null),p:null,q:null,qBits:r>>1,pBits:r-(r>>1),pqState:0,num:null,keys:null}).e.fromInt(a.eInt),a},a.rsa.stepKeyPairGenerationState=function(e,r){"algorithm"in e||(e.algorithm="PRIMEINC");var n=new t(null);n.fromInt(30);for(var i,o=0,c=function(e,t){return e|t},u=+new Date,l=0;null===e.keys&&(r<=0||l<r);){if(0===e.state){var f=null===e.p?e.pBits:e.qBits,p=f-1;0===e.pqState?(e.num=new t(f,e.rng),e.num.testBit(p)||e.num.bitwiseTo(t.ONE.shiftLeft(p),c,e.num),e.num.dAddOffset(31-e.num.mod(n).byteValue(),0),o=0,++e.pqState):1===e.pqState?e.num.bitLength()>f?e.pqState=0:e.num.isProbablePrime(m(e.num.bitLength()))?++e.pqState:e.num.dAddOffset(s[o++%8],0):2===e.pqState?e.pqState=0===e.num.subtract(t.ONE).gcd(e.e).compareTo(t.ONE)?3:0:3===e.pqState&&(e.pqState=0,null===e.p?e.p=e.num:e.q=e.num,null!==e.p&&null!==e.q&&++e.state,e.num=null)}else if(1===e.state)e.p.compareTo(e.q)<0&&(e.num=e.p,e.p=e.q,e.q=e.num),++e.state;else if(2===e.state)e.p1=e.p.subtract(t.ONE),e.q1=e.q.subtract(t.ONE),e.phi=e.p1.multiply(e.q1),++e.state;else if(3===e.state)0===e.phi.gcd(e.e).compareTo(t.ONE)?++e.state:(e.p=null,e.q=null,e.state=0);else if(4===e.state)e.n=e.p.multiply(e.q),e.n.bitLength()===e.bits?++e.state:(e.q=null,e.state=0);else if(5===e.state){var h=e.e.modInverse(e.phi);e.keys={privateKey:a.rsa.setPrivateKey(e.n,e.e,h,e.p,e.q,h.mod(e.p1),h.mod(e.q1),e.q.modInverse(e.p)),publicKey:a.rsa.setPublicKey(e.n,e.e)}}l+=(i=+new Date)-u,u=i}return null!==e.keys},a.rsa.generateKeyPair=function(s,o,c,u){if(1===arguments.length?"object"==typeof s?(c=s,s=void 0):"function"==typeof s&&(u=s,s=void 0):2===arguments.length?"number"==typeof s?"function"==typeof o?(u=o,o=void 0):"number"!=typeof o&&(c=o,o=void 0):(c=s,u=o,s=void 0,o=void 0):3===arguments.length&&("number"==typeof o?"function"==typeof c&&(u=c,c=void 0):(u=c,c=o,o=void 0)),c=c||{},void 0===s&&(s=c.bits||2048),void 0===o&&(o=c.e||65537),!e.options.usePureJavaScript&&!c.prng&&s>=256&&s<=16384&&(65537===o||3===o))if(u){if(v("generateKeyPair"))return r.generateKeyPair("rsa",{modulusLength:s,publicExponent:o,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}},function(e,t,r){if(e)return u(e);u(null,{privateKey:a.privateKeyFromPem(r),publicKey:a.publicKeyFromPem(t)})});if(C("generateKey")&&C("exportKey"))return i.globalScope.crypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:S(o),hash:{name:"SHA-256"}},!0,["sign","verify"]).then(function(e){return i.globalScope.crypto.subtle.exportKey("pkcs8",e.privateKey)}).then(void 0,function(e){u(e)}).then(function(t){if(t){var r=a.privateKeyFromAsn1(n.fromDer(e.util.createBuffer(t)));u(null,{privateKey:r,publicKey:a.setRsaPublicKey(r.n,r.e)})}});if(E("generateKey")&&E("exportKey")){var l=i.globalScope.msCrypto.subtle.generateKey({name:"RSASSA-PKCS1-v1_5",modulusLength:s,publicExponent:S(o),hash:{name:"SHA-256"}},!0,["sign","verify"]);return l.oncomplete=function(t){var r=t.target.result,s=i.globalScope.msCrypto.subtle.exportKey("pkcs8",r.privateKey);s.oncomplete=function(t){var r=t.target.result,i=a.privateKeyFromAsn1(n.fromDer(e.util.createBuffer(r)));u(null,{privateKey:i,publicKey:a.setRsaPublicKey(i.n,i.e)})},s.onerror=function(e){u(e)}},void(l.onerror=function(e){u(e)})}}else if(v("generateKeyPairSync")){var f=r.generateKeyPairSync("rsa",{modulusLength:s,publicExponent:o,publicKeyEncoding:{type:"spki",format:"pem"},privateKeyEncoding:{type:"pkcs8",format:"pem"}});return{privateKey:a.privateKeyFromPem(f.privateKey),publicKey:a.publicKeyFromPem(f.publicKey)}}var p=a.rsa.createKeyPairGenerationState(s,o,c);if(!u)return a.rsa.stepKeyPairGenerationState(p,0),p.keys;!function(r,n,i){"function"==typeof n&&(i=n,n={});n=n||{};var s={algorithm:{name:n.algorithm||"PRIMEINC",options:{workers:n.workers||2,workLoad:n.workLoad||100,workerScript:n.workerScript}}};"prng"in n&&(s.prng=n.prng);function o(){c(r.pBits,function(e,t){return e?i(e):(r.p=t,null!==r.q?u(e,r.q):void c(r.qBits,u))})}function c(t,r){e.prime.generateProbablePrime(t,s,r)}function u(e,n){if(e)return i(e);if(r.q=n,r.p.compareTo(r.q)<0){var s=r.p;r.p=r.q,r.q=s}if(0!==r.p.subtract(t.ONE).gcd(r.e).compareTo(t.ONE))return r.p=null,void o();if(0!==r.q.subtract(t.ONE).gcd(r.e).compareTo(t.ONE))return r.q=null,void c(r.qBits,u);if(r.p1=r.p.subtract(t.ONE),r.q1=r.q.subtract(t.ONE),r.phi=r.p1.multiply(r.q1),0!==r.phi.gcd(r.e).compareTo(t.ONE))return r.p=r.q=null,void o();if(r.n=r.p.multiply(r.q),r.n.bitLength()!==r.bits)return r.q=null,void c(r.qBits,u);var l=r.e.modInverse(r.phi);r.keys={privateKey:a.rsa.setPrivateKey(r.n,r.e,l,r.p,r.q,l.mod(r.p1),l.mod(r.q1),r.q.modInverse(r.p)),publicKey:a.rsa.setPublicKey(r.n,r.e)},i(null,r.keys)}o()}(p,c,u)},a.setRsaPublicKey=a.rsa.setPublicKey=function(t,r){var i={n:t,e:r,encrypt:function(t,r,n){if("string"==typeof r?r=r.toUpperCase():void 0===r&&(r="RSAES-PKCS1-V1_5"),"RSAES-PKCS1-V1_5"===r)r={encode:function(e,t,r){return d(e,t,2).getBytes()}};else if("RSA-OAEP"===r||"RSAES-OAEP"===r)r={encode:function(t,r){return e.pkcs1.encode_rsa_oaep(r,t,n)}};else if(-1!==["RAW","NONE","NULL",null].indexOf(r))r={encode:function(e){return e}};else if("string"==typeof r)throw new Error('Unsupported encryption scheme: "'+r+'".');var s=r.encode(t,i,!0);return a.rsa.encrypt(s,i,!0)},verify:function(t,r,s,o){"string"==typeof s?s=s.toUpperCase():void 0===s&&(s="RSASSA-PKCS1-V1_5"),void 0===o&&(o={_parseAllDigestBytes:!0}),"_parseAllDigestBytes"in o||(o._parseAllDigestBytes=!0),"RSASSA-PKCS1-V1_5"===s?s={verify:function(t,r){r=g(r,i,!0);var a=n.fromDer(r,{parseAllBytes:o._parseAllDigestBytes}),s={},c=[];if(!n.validate(a,f,s,c))throw(u=new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value.")).errors=c,u;var u,l=n.derToOid(s.algorithmIdentifier);if(l!==e.oids.md2&&l!==e.oids.md5&&l!==e.oids.sha1&&l!==e.oids.sha224&&l!==e.oids.sha256&&l!==e.oids.sha384&&l!==e.oids.sha512&&l!==e.oids["sha512-224"]&&l!==e.oids["sha512-256"])throw(u=new Error("Unknown RSASSA-PKCS1-v1_5 DigestAlgorithm identifier.")).oid=l,u;if((l===e.oids.md2||l===e.oids.md5)&&!("parameters"in s))throw new Error("ASN.1 object does not contain a valid RSASSA-PKCS1-v1_5 DigestInfo value. Missing algorithm identifer NULL parameters.");return t===s.digest}}:"NONE"!==s&&"NULL"!==s&&null!==s||(s={verify:function(e,t){return e===(t=g(t,i,!0))}});var c=a.rsa.decrypt(r,i,!0,!1);return s.verify(t,c,i.n.bitLength())}};return i},a.setRsaPrivateKey=a.rsa.setPrivateKey=function(t,r,n,i,s,o,c,u){var l={n:t,e:r,d:n,p:i,q:s,dP:o,dQ:c,qInv:u,decrypt:function(t,r,n){"string"==typeof r?r=r.toUpperCase():void 0===r&&(r="RSAES-PKCS1-V1_5");var i=a.rsa.decrypt(t,l,!1,!1);if("RSAES-PKCS1-V1_5"===r)r={decode:g};else if("RSA-OAEP"===r||"RSAES-OAEP"===r)r={decode:function(t,r){return e.pkcs1.decode_rsa_oaep(r,t,n)}};else{if(-1===["RAW","NONE","NULL",null].indexOf(r))throw new Error('Unsupported encryption scheme: "'+r+'".');r={decode:function(e){return e}}}return r.decode(i,l,!1)},sign:function(e,t){var r=!1;"string"==typeof t&&(t=t.toUpperCase()),void 0===t||"RSASSA-PKCS1-V1_5"===t?(t={encode:p},r=1):"NONE"!==t&&"NULL"!==t&&null!==t||(t={encode:function(){return e}},r=1);var n=t.encode(e,l.n.bitLength());return a.rsa.encrypt(n,l,r)}};return l},a.wrapRsaPrivateKey=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(0).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(a.oids.rsaEncryption).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,"")]),n.create(n.Class.UNIVERSAL,n.Type.OCTETSTRING,!1,n.toDer(e).getBytes())])},a.privateKeyFromAsn1=function(r){var i,s,u,l,f,p,h,d,g={},y=[];if(n.validate(r,o,g,y)&&(r=n.fromDer(e.util.createBuffer(g.privateKey))),g={},y=[],!n.validate(r,c,g,y)){var m=new Error("Cannot read private key. ASN.1 object does not contain an RSAPrivateKey.");throw m.errors=y,m}return i=e.util.createBuffer(g.privateKeyModulus).toHex(),s=e.util.createBuffer(g.privateKeyPublicExponent).toHex(),u=e.util.createBuffer(g.privateKeyPrivateExponent).toHex(),l=e.util.createBuffer(g.privateKeyPrime1).toHex(),f=e.util.createBuffer(g.privateKeyPrime2).toHex(),p=e.util.createBuffer(g.privateKeyExponent1).toHex(),h=e.util.createBuffer(g.privateKeyExponent2).toHex(),d=e.util.createBuffer(g.privateKeyCoefficient).toHex(),a.setRsaPrivateKey(new t(i,16),new t(s,16),new t(u,16),new t(l,16),new t(f,16),new t(p,16),new t(h,16),new t(d,16))},a.privateKeyToAsn1=a.privateKeyToRSAPrivateKey=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,n.integerToDer(0).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.n)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.e)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.d)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.p)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.q)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.dP)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.dQ)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.qInv))])},a.publicKeyFromAsn1=function(r){var i={},s=[];if(n.validate(r,l,i,s)){var o,c=n.derToOid(i.publicKeyOid);if(c!==a.oids.rsaEncryption)throw(o=new Error("Cannot read public key. Unknown OID.")).oid=c,o;r=i.rsaPublicKey}if(s=[],!n.validate(r,u,i,s))throw(o=new Error("Cannot read public key. ASN.1 object does not contain an RSAPublicKey.")).errors=s,o;var f=e.util.createBuffer(i.publicKeyModulus).toHex(),p=e.util.createBuffer(i.publicKeyExponent).toHex();return a.setRsaPublicKey(new t(f,16),new t(p,16))},a.publicKeyToAsn1=a.publicKeyToSubjectPublicKeyInfo=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.OID,!1,n.oidToDer(a.oids.rsaEncryption).getBytes()),n.create(n.Class.UNIVERSAL,n.Type.NULL,!1,"")]),n.create(n.Class.UNIVERSAL,n.Type.BITSTRING,!1,[a.publicKeyToRSAPublicKey(e)])])},a.publicKeyToRSAPublicKey=function(e){return n.create(n.Class.UNIVERSAL,n.Type.SEQUENCE,!0,[n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.n)),n.create(n.Class.UNIVERSAL,n.Type.INTEGER,!1,y(e.e))])},rn}function ln(){if(sn)return an;sn=1;var e=zt();if(sr(),hr(),_r(),vr(),pr(),Ur(),Ir(),zr(),Qr(),un(),Zt(),void 0===t)var t=e.jsbn.BigInteger;var r=e.asn1,n=e.pki=e.pki||{};an=n.pbe=e.pbe=e.pbe||{};var i=n.oids,a={name:"EncryptedPrivateKeyInfo",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedPrivateKeyInfo.encryptionAlgorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"encryptionOid"},{name:"AlgorithmIdentifier.parameters",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,captureAsn1:"encryptionParams"}]},{name:"EncryptedPrivateKeyInfo.encryptedData",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"encryptedData"}]},s={name:"PBES2Algorithms",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.keyDerivationFunc.oid",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"kdfOid"},{name:"PBES2Algorithms.params",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.params.salt",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"kdfSalt"},{name:"PBES2Algorithms.params.iterationCount",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"kdfIterationCount"},{name:"PBES2Algorithms.params.keyLength",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,optional:!0,capture:"keyLength"},{name:"PBES2Algorithms.params.prf",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,optional:!0,value:[{name:"PBES2Algorithms.params.prf.algorithm",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"prfOid"}]}]}]},{name:"PBES2Algorithms.encryptionScheme",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"PBES2Algorithms.encryptionScheme.oid",tagClass:r.Class.UNIVERSAL,type:r.Type.OID,constructed:!1,capture:"encOid"},{name:"PBES2Algorithms.encryptionScheme.iv",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"encIv"}]}]},o={name:"pkcs-12PbeParams",tagClass:r.Class.UNIVERSAL,type:r.Type.SEQUENCE,constructed:!0,value:[{name:"pkcs-12PbeParams.salt",tagClass:r.Class.UNIVERSAL,type:r.Type.OCTETSTRING,constructed:!1,capture:"salt"},{name:"pkcs-12PbeParams.iterations",tagClass:r.Class.UNIVERSAL,type:r.Type.INTEGER,constructed:!1,capture:"iterations"}]};function c(e,t){return e.start().update(t).digest().getBytes()}function u(e){var t;if(e){if(!(t=n.oids[r.derToOid(e)])){var i=new Error("Unsupported PRF OID.");throw i.oid=e,i.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],i}}else t="hmacWithSHA1";return l(t)}function l(t){var r=e.md;switch(t){case"hmacWithSHA224":r=e.md.sha512;case"hmacWithSHA1":case"hmacWithSHA256":case"hmacWithSHA384":case"hmacWithSHA512":t=t.substr(8).toLowerCase();break;default:var n=new Error("Unsupported PRF algorithm.");throw n.algorithm=t,n.supported=["hmacWithSHA1","hmacWithSHA224","hmacWithSHA256","hmacWithSHA384","hmacWithSHA512"],n}if(!r||!(t in r))throw new Error("Unknown hash algorithm: "+t);return r[t].create()}return n.encryptPrivateKeyInfo=function(t,a,s){(s=s||{}).saltSize=s.saltSize||8,s.count=s.count||2048,s.algorithm=s.algorithm||"aes128",s.prfAlgorithm=s.prfAlgorithm||"sha1";var o,c,u,f=e.random.getBytesSync(s.saltSize),p=s.count,h=r.integerToDer(p);if(0===s.algorithm.indexOf("aes")||"des"===s.algorithm){var d,g,y;switch(s.algorithm){case"aes128":o=16,d=16,g=i["aes128-CBC"],y=e.aes.createEncryptionCipher;break;case"aes192":o=24,d=16,g=i["aes192-CBC"],y=e.aes.createEncryptionCipher;break;case"aes256":o=32,d=16,g=i["aes256-CBC"],y=e.aes.createEncryptionCipher;break;case"des":o=8,d=8,g=i.desCBC,y=e.des.createEncryptionCipher;break;default:throw(T=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=s.algorithm,T}var m="hmacWith"+s.prfAlgorithm.toUpperCase(),v=l(m),C=e.pkcs5.pbkdf2(a,f,p,o,v),E=e.random.getBytesSync(d);(b=y(C)).start(E),b.update(r.toDer(t)),b.finish(),u=b.output.getBytes();var S=function(t,i,a,s){var o=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,t),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,i.getBytes())]);"hmacWithSHA1"!==s&&o.value.push(r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,e.util.hexToBytes(a.toString(16))),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(n.oids[s]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.NULL,!1,"")]));return o}(f,h,o,m);c=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.pkcs5PBES2).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i.pkcs5PBKDF2).getBytes()),S]),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(g).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,E)])])])}else{var T;if("3des"!==s.algorithm)throw(T=new Error("Cannot encrypt private key. Unknown encryption algorithm.")).algorithm=s.algorithm,T;o=24;var b,A=new e.util.ByteBuffer(f);C=n.pbe.generatePkcs12Key(a,A,1,p,o),E=n.pbe.generatePkcs12Key(a,A,2,p,o);(b=e.des.createEncryptionCipher(C)).start(E),b.update(r.toDer(t)),b.finish(),u=b.output.getBytes(),c=r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OID,!1,r.oidToDer(i["pbeWithSHAAnd3-KeyTripleDES-CBC"]).getBytes()),r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,f),r.create(r.Class.UNIVERSAL,r.Type.INTEGER,!1,h.getBytes())])])}return r.create(r.Class.UNIVERSAL,r.Type.SEQUENCE,!0,[c,r.create(r.Class.UNIVERSAL,r.Type.OCTETSTRING,!1,u)])},n.decryptPrivateKeyInfo=function(t,i){var s=null,o={},c=[];if(!r.validate(t,a,o,c)){var u=new Error("Cannot read encrypted private key. ASN.1 object is not a supported EncryptedPrivateKeyInfo.");throw u.errors=c,u}var l=r.derToOid(o.encryptionOid),f=n.pbe.getCipher(l,o.encryptionParams,i),p=e.util.createBuffer(o.encryptedData);return f.update(p),f.finish()&&(s=r.fromDer(f.output)),s},n.encryptedPrivateKeyToPem=function(t,n){var i={type:"ENCRYPTED PRIVATE KEY",body:r.toDer(t).getBytes()};return e.pem.encode(i,{maxline:n})},n.encryptedPrivateKeyFromPem=function(t){var n=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==n.type){var i=new Error('Could not convert encrypted private key from PEM; PEM header type is "ENCRYPTED PRIVATE KEY".');throw i.headerType=n.type,i}if(n.procType&&"ENCRYPTED"===n.procType.type)throw new Error("Could not convert encrypted private key from PEM; PEM is encrypted.");return r.fromDer(n.body)},n.encryptRsaPrivateKey=function(t,i,a){if(!(a=a||{}).legacy){var s=n.wrapRsaPrivateKey(n.privateKeyToAsn1(t));return s=n.encryptPrivateKeyInfo(s,i,a),n.encryptedPrivateKeyToPem(s)}var o,c,u,l;switch(a.algorithm){case"aes128":o="AES-128-CBC",u=16,c=e.random.getBytesSync(16),l=e.aes.createEncryptionCipher;break;case"aes192":o="AES-192-CBC",u=24,c=e.random.getBytesSync(16),l=e.aes.createEncryptionCipher;break;case"aes256":o="AES-256-CBC",u=32,c=e.random.getBytesSync(16),l=e.aes.createEncryptionCipher;break;case"3des":o="DES-EDE3-CBC",u=24,c=e.random.getBytesSync(8),l=e.des.createEncryptionCipher;break;case"des":o="DES-CBC",u=8,c=e.random.getBytesSync(8),l=e.des.createEncryptionCipher;break;default:var f=new Error('Could not encrypt RSA private key; unsupported encryption algorithm "'+a.algorithm+'".');throw f.algorithm=a.algorithm,f}var p=l(e.pbe.opensslDeriveBytes(i,c.substr(0,8),u));p.start(c),p.update(r.toDer(n.privateKeyToAsn1(t))),p.finish();var h={type:"RSA PRIVATE KEY",procType:{version:"4",type:"ENCRYPTED"},dekInfo:{algorithm:o,parameters:e.util.bytesToHex(c).toUpperCase()},body:p.output.getBytes()};return e.pem.encode(h)},n.decryptRsaPrivateKey=function(t,i){var a=null,s=e.pem.decode(t)[0];if("ENCRYPTED PRIVATE KEY"!==s.type&&"PRIVATE KEY"!==s.type&&"RSA PRIVATE KEY"!==s.type)throw(u=new Error('Could not convert private key from PEM; PEM header type is not "ENCRYPTED PRIVATE KEY", "PRIVATE KEY", or "RSA PRIVATE KEY".')).headerType=u,u;if(s.procType&&"ENCRYPTED"===s.procType.type){var o,c;switch(s.dekInfo.algorithm){case"DES-CBC":o=8,c=e.des.createDecryptionCipher;break;case"DES-EDE3-CBC":o=24,c=e.des.createDecryptionCipher;break;case"AES-128-CBC":o=16,c=e.aes.createDecryptionCipher;break;case"AES-192-CBC":o=24,c=e.aes.createDecryptionCipher;break;case"AES-256-CBC":o=32,c=e.aes.createDecryptionCipher;break;case"RC2-40-CBC":o=5,c=function(t){return e.rc2.createDecryptionCipher(t,40)};break;case"RC2-64-CBC":o=8,c=function(t){return e.rc2.createDecryptionCipher(t,64)};break;case"RC2-128-CBC":o=16,c=function(t){return e.rc2.createDecryptionCipher(t,128)};break;default:var u;throw(u=new Error('Could not decrypt private key; unsupported encryption algorithm "'+s.dekInfo.algorithm+'".')).algorithm=s.dekInfo.algorithm,u}var l=e.util.hexToBytes(s.dekInfo.parameters),f=c(e.pbe.opensslDeriveBytes(i,l.substr(0,8),o));if(f.start(l),f.update(e.util.createBuffer(s.body)),!f.finish())return a;a=f.output.getBytes()}else a=s.body;return null!==(a="ENCRYPTED PRIVATE KEY"===s.type?n.decryptPrivateKeyInfo(r.fromDer(a),i):r.fromDer(a))&&(a=n.privateKeyFromAsn1(a)),a},n.pbe.generatePkcs12Key=function(t,r,n,i,a,s){var o,c;if(null==s){if(!("sha1"in e.md))throw new Error('"sha1" hash algorithm unavailable.');s=e.md.sha1.create()}var u=s.digestLength,l=s.blockLength,f=new e.util.ByteBuffer,p=new e.util.ByteBuffer;if(null!=t){for(c=0;c<t.length;c++)p.putInt16(t.charCodeAt(c));p.putInt16(0)}var h=p.length(),d=r.length(),g=new e.util.ByteBuffer;g.fillWithByte(n,l);var y=l*Math.ceil(d/l),m=new e.util.ByteBuffer;for(c=0;c<y;c++)m.putByte(r.at(c%d));var v=l*Math.ceil(h/l),C=new e.util.ByteBuffer;for(c=0;c<v;c++)C.putByte(p.at(c%h));var E=m;E.putBuffer(C);for(var S=Math.ceil(a/u),T=1;T<=S;T++){var b=new e.util.ByteBuffer;b.putBytes(g.bytes()),b.putBytes(E.bytes());for(var A=0;A<i;A++)s.start(),s.update(b.getBytes()),b=s.digest();var I=new e.util.ByteBuffer;for(c=0;c<l;c++)I.putByte(b.at(c%u));var B=Math.ceil(d/l)+Math.ceil(h/l),w=new e.util.ByteBuffer;for(o=0;o<B;o++){var N=new e.util.ByteBuffer(E.getBytes(l)),_=511;for(c=I.length()-1;c>=0;c--)_>>=8,_+=I.at(c)+N.at(c),N.setAt(c,255&_);w.putBuffer(N)}E=w,f.putBuffer(b)}return f.truncate(f.length()-a),f},n.pbe.getCipher=function(e,t,r){switch(e){case n.oids.pkcs5PBES2:return n.pbe.getCipherForPBES2(e,t,r);case n.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:case n.oids["pbewithSHAAnd40BitRC2-CBC"]:return n.pbe.getCipherForPKCS12PBE(e,t,r);default:var i=new Error("Cannot read encrypted PBE data block. Unsupported OID.");throw i.oid=e,i.supportedOids=["pkcs5PBES2","pbeWithSHAAnd3-KeyTripleDES-CBC","pbewithSHAAnd40BitRC2-CBC"],i}},n.pbe.getCipherForPBES2=function(t,i,a){var o,c={},l=[];if(!r.validate(i,s,c,l))throw(o=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=l,o;if((t=r.derToOid(c.kdfOid))!==n.oids.pkcs5PBKDF2)throw(o=new Error("Cannot read encrypted private key. Unsupported key derivation function OID.")).oid=t,o.supportedOids=["pkcs5PBKDF2"],o;if((t=r.derToOid(c.encOid))!==n.oids["aes128-CBC"]&&t!==n.oids["aes192-CBC"]&&t!==n.oids["aes256-CBC"]&&t!==n.oids["des-EDE3-CBC"]&&t!==n.oids.desCBC)throw(o=new Error("Cannot read encrypted private key. Unsupported encryption scheme OID.")).oid=t,o.supportedOids=["aes128-CBC","aes192-CBC","aes256-CBC","des-EDE3-CBC","desCBC"],o;var f,p,h=c.kdfSalt,d=e.util.createBuffer(c.kdfIterationCount);switch(d=d.getInt(d.length()<<3),n.oids[t]){case"aes128-CBC":f=16,p=e.aes.createDecryptionCipher;break;case"aes192-CBC":f=24,p=e.aes.createDecryptionCipher;break;case"aes256-CBC":f=32,p=e.aes.createDecryptionCipher;break;case"des-EDE3-CBC":f=24,p=e.des.createDecryptionCipher;break;case"desCBC":f=8,p=e.des.createDecryptionCipher}var g=u(c.prfOid),y=e.pkcs5.pbkdf2(a,h,d,f,g),m=c.encIv,v=p(y);return v.start(m),v},n.pbe.getCipherForPKCS12PBE=function(t,i,a){var s={},c=[];if(!r.validate(i,o,s,c))throw(g=new Error("Cannot read password-based-encryption algorithm parameters. ASN.1 object is not a supported EncryptedPrivateKeyInfo.")).errors=c,g;var l,f,p,h=e.util.createBuffer(s.salt),d=e.util.createBuffer(s.iterations);switch(d=d.getInt(d.length()<<3),t){case n.oids["pbeWithSHAAnd3-KeyTripleDES-CBC"]:l=24,f=8,p=e.des.startDecrypting;break;case n.oids["pbewithSHAAnd40BitRC2-CBC"]:l=5,f=8,p=function(t,r){var n=e.rc2.createDecryptionCipher(t,40);return n.start(r,null),n};break;default:var g;throw(g=new Error("Cannot read PKCS #12 PBE data block. Unsupported OID.")).oid=t,g}var y=u(s.prfOid),m=n.pbe.generatePkcs12Key(a,h,1,d,l,y);return y.start(),p(m,n.pbe.generatePkcs12Key(a,h,2,d,f,y))},n.pbe.opensslDeriveBytes=function(t,r,n,i){if(null==i){if(!("md5"in e.md))throw new Error('"md5" hash algorithm unavailable.');i=e.md.md5.create()}null===r&&(r="");for(var a=[c(i,t+r)],s=16,o=1;s<n;++o,s+=16)a.push(c(i,a[o-1]+t+r));return a.join("").substr(0,n)},an}var fn,pn={exports:{}},hn={exports:{}};function dn(){if(fn)return hn.exports;fn=1;var e=zt();hr(),Zt();var t=e.asn1,r=hn.exports=e.pkcs7asn1=e.pkcs7asn1||{};e.pkcs7=e.pkcs7||{},e.pkcs7.asn1=r;var n={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.ContentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,captureAsn1:"content"}]};r.contentInfoValidator=n;var i={name:"EncryptedContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedContentInfo.contentEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"EncryptedContentInfo.contentEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,captureAsn1:"encParameter"}]},{name:"EncryptedContentInfo.encryptedContent",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,capture:"encryptedContent",captureAsn1:"encryptedContentAsn1"}]};r.envelopedDataValidator={name:"EnvelopedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EnvelopedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"EnvelopedData.RecipientInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"recipientInfos"}].concat(i)},r.encryptedDataValidator={name:"EncryptedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"EncryptedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"}].concat(i)};var a={name:"SignerInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1},{name:"SignerInfo.issuerAndSerialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.issuerAndSerialNumber.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"SignerInfo.issuerAndSerialNumber.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"SignerInfo.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignerInfo.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"digestAlgorithm"},{name:"SignerInfo.digestAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"digestParameter",optional:!0}]},{name:"SignerInfo.authenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"authenticatedAttributes"},{name:"SignerInfo.digestEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,capture:"signatureAlgorithm"},{name:"SignerInfo.encryptedDigest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"signature"},{name:"SignerInfo.unauthenticatedAttributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,capture:"unauthenticatedAttributes"}]};return r.signedDataValidator={name:"SignedData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SignedData.Version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"SignedData.DigestAlgorithms",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,captureAsn1:"digestAlgorithms"},n,{name:"SignedData.Certificates",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,optional:!0,captureAsn1:"certificates"},{name:"SignedData.CertificateRevocationLists",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,optional:!0,captureAsn1:"crls"},{name:"SignedData.SignerInfos",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,capture:"signerInfos",optional:!0,value:[a]}]},r.recipientInfoValidator={name:"RecipientInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},{name:"RecipientInfo.issuerAndSerial",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.issuerAndSerial.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"issuer"},{name:"RecipientInfo.issuerAndSerial.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"serial"}]},{name:"RecipientInfo.keyEncryptionAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"RecipientInfo.keyEncryptionAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"encAlgorithm"},{name:"RecipientInfo.keyEncryptionAlgorithm.parameter",tagClass:t.Class.UNIVERSAL,constructed:!1,captureAsn1:"encParameter",optional:!0}]},{name:"RecipientInfo.encryptedKey",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"encKey"}]},hn.exports}var gn,yn,mn,vn={exports:{}},Cn={exports:{}};function En(){if(gn)return Cn.exports;gn=1;var e=zt();return Zt(),e.mgf=e.mgf||{},(Cn.exports=e.mgf.mgf1=e.mgf1=e.mgf1||{}).create=function(t){return{generate:function(r,n){for(var i=new e.util.ByteBuffer,a=Math.ceil(n/t.digestLength),s=0;s<a;s++){var o=new e.util.ByteBuffer;o.putInt32(s),t.start(),t.update(r+o.getBytes()),i.putBuffer(t.digest())}return i.truncate(i.length()-n),i.getBytes()}}},Cn.exports}var Sn,Tn,bn,An,In,Bn,wn,Nn={exports:{}};function _n(){if(Sn)return Nn.exports;Sn=1;var e=zt();return zr(),Zt(),(Nn.exports=e.pss=e.pss||{}).create=function(t){3===arguments.length&&(t={md:arguments[0],mgf:arguments[1],saltLength:arguments[2]});var r,n=t.md,i=t.mgf,a=n.digestLength,s=t.salt||null;if("string"==typeof s&&(s=e.util.createBuffer(s)),"saltLength"in t)r=t.saltLength;else{if(null===s)throw new Error("Salt length not specified or specific salt not given.");r=s.length()}if(null!==s&&s.length()!==r)throw new Error("Given salt length does not match length of given salt.");var o=t.prng||e.random,c={encode:function(t,c){var u,l,f=c-1,p=Math.ceil(f/8),h=t.digest().getBytes();if(p<a+r+2)throw new Error("Message is too long to encrypt.");l=null===s?o.getBytesSync(r):s.bytes();var d=new e.util.ByteBuffer;d.fillWithByte(0,8),d.putBytes(h),d.putBytes(l),n.start(),n.update(d.getBytes());var g=n.digest().getBytes(),y=new e.util.ByteBuffer;y.fillWithByte(0,p-r-a-2),y.putByte(1),y.putBytes(l);var m=y.getBytes(),v=p-a-1,C=i.generate(g,v),E="";for(u=0;u<v;u++)E+=String.fromCharCode(m.charCodeAt(u)^C.charCodeAt(u));var S=65280>>8*p-f&255;return(E=String.fromCharCode(E.charCodeAt(0)&~S)+E.substr(1))+g+String.fromCharCode(188)},verify:function(t,s,o){var c,u=o-1,l=Math.ceil(u/8);if(s=s.substr(-l),l<a+r+2)throw new Error("Inconsistent parameters to PSS signature verification.");if(188!==s.charCodeAt(l-1))throw new Error("Encoded message does not end in 0xBC.");var f=l-a-1,p=s.substr(0,f),h=s.substr(f,a),d=65280>>8*l-u&255;if(0!==(p.charCodeAt(0)&d))throw new Error("Bits beyond keysize not zero as expected.");var g=i.generate(h,f),y="";for(c=0;c<f;c++)y+=String.fromCharCode(p.charCodeAt(c)^g.charCodeAt(c));y=String.fromCharCode(y.charCodeAt(0)&~d)+y.substr(1);var m=l-a-r-2;for(c=0;c<m;c++)if(0!==y.charCodeAt(c))throw new Error("Leftmost octets not zero as expected");if(1!==y.charCodeAt(m))throw new Error("Inconsistent PSS signature, 0x01 marker not found");var v=y.substr(-r),C=new e.util.ByteBuffer;return C.fillWithByte(0,8),C.putBytes(t),C.putBytes(v),n.start(),n.update(C.getBytes()),h===n.digest().getBytes()}};return c},Nn.exports}function Rn(){if(Tn)return vn.exports;Tn=1;var e=zt();sr(),hr(),_r(),vr(),function(){if(mn)return yn;mn=1;var e=zt();En(),yn=e.mgf=e.mgf||{},e.mgf.mgf1=e.mgf1}(),pr(),Ir(),_n(),un(),Zt();var t=e.asn1,r=vn.exports=e.pki=e.pki||{},n=r.oids,i={};i.CN=n.commonName,i.commonName="CN",i.C=n.countryName,i.countryName="C",i.L=n.localityName,i.localityName="L",i.ST=n.stateOrProvinceName,i.stateOrProvinceName="ST",i.O=n.organizationName,i.organizationName="O",i.OU=n.organizationalUnitName,i.organizationalUnitName="OU",i.E=n.emailAddress,i.emailAddress="E";var a=e.pki.rsa.publicKeyValidator,s={name:"Certificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"tbsCertificate",value:[{name:"Certificate.TBSCertificate.version",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.version.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certVersion"}]},{name:"Certificate.TBSCertificate.serialNumber",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certSerialNumber"},{name:"Certificate.TBSCertificate.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.signature.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certinfoSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certinfoSignatureParams"}]},{name:"Certificate.TBSCertificate.issuer",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certIssuer"},{name:"Certificate.TBSCertificate.validity",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.TBSCertificate.validity.notBefore (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity1UTCTime"},{name:"Certificate.TBSCertificate.validity.notBefore (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity2GeneralizedTime"},{name:"Certificate.TBSCertificate.validity.notAfter (utc)",tagClass:t.Class.UNIVERSAL,type:t.Type.UTCTIME,constructed:!1,optional:!0,capture:"certValidity3UTCTime"},{name:"Certificate.TBSCertificate.validity.notAfter (generalized)",tagClass:t.Class.UNIVERSAL,type:t.Type.GENERALIZEDTIME,constructed:!1,optional:!0,capture:"certValidity4GeneralizedTime"}]},{name:"Certificate.TBSCertificate.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certSubject"},a,{name:"Certificate.TBSCertificate.issuerUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.issuerUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certIssuerUniqueId"}]},{name:"Certificate.TBSCertificate.subjectUniqueID",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,constructed:!0,optional:!0,value:[{name:"Certificate.TBSCertificate.subjectUniqueID.id",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSubjectUniqueId"}]},{name:"Certificate.TBSCertificate.extensions",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,constructed:!0,captureAsn1:"certExtensions",optional:!0}]},{name:"Certificate.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Certificate.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certSignatureOid"},{name:"Certificate.TBSCertificate.signature.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"certSignatureParams"}]},{name:"Certificate.signatureValue",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"certSignature"}]},o={name:"rsapss",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.hashAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.hashAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"hashOid"}]}]},{name:"rsapss.maskGenAlgorithm",tagClass:t.Class.CONTEXT_SPECIFIC,type:1,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Class.SEQUENCE,constructed:!0,optional:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenOid"},{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"rsapss.maskGenAlgorithm.AlgorithmIdentifier.params.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"maskGenHashOid"}]}]}]},{name:"rsapss.saltLength",tagClass:t.Class.CONTEXT_SPECIFIC,type:2,optional:!0,value:[{name:"rsapss.saltLength.saltLength",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"saltLength"}]},{name:"rsapss.trailerField",tagClass:t.Class.CONTEXT_SPECIFIC,type:3,optional:!0,value:[{name:"rsapss.trailer.trailer",tagClass:t.Class.UNIVERSAL,type:t.Class.INTEGER,constructed:!1,capture:"trailer"}]}]},c={name:"CertificationRequestInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfo",value:[{name:"CertificationRequestInfo.integer",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"certificationRequestInfoVersion"},{name:"CertificationRequestInfo.subject",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"certificationRequestInfoSubject"},a,{name:"CertificationRequestInfo.attributes",tagClass:t.Class.CONTEXT_SPECIFIC,type:0,constructed:!0,optional:!0,capture:"certificationRequestInfoAttributes",value:[{name:"CertificationRequestInfo.attributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequestInfo.attributes.type",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1},{name:"CertificationRequestInfo.attributes.value",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0}]}]}]},u={name:"CertificationRequest",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"csr",value:[c,{name:"CertificationRequest.signatureAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertificationRequest.signatureAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"csrSignatureOid"},{name:"CertificationRequest.signatureAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,optional:!0,captureAsn1:"csrSignatureParams"}]},{name:"CertificationRequest.signature",tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,captureBitStringValue:"csrSignature"}]};function l(e,t){"string"==typeof t&&(t={shortName:t});for(var r,n=null,i=0;null===n&&i<e.attributes.length;++i)r=e.attributes[i],(t.type&&t.type===r.type||t.name&&t.name===r.name||t.shortName&&t.shortName===r.shortName)&&(n=r);return n}r.RDNAttributesAsArray=function(e,r){for(var a,s,o,c=[],u=0;u<e.value.length;++u){a=e.value[u];for(var l=0;l<a.value.length;++l)o={},s=a.value[l],o.type=t.derToOid(s.value[0].value),o.value=s.value[1].value,o.valueTagClass=s.value[1].type,o.type in n&&(o.name=n[o.type],o.name in i&&(o.shortName=i[o.name])),r&&(r.update(o.type),r.update(o.value)),c.push(o)}return c},r.CRIAttributesAsArray=function(e){for(var a=[],s=0;s<e.length;++s)for(var o=e[s],c=t.derToOid(o.value[0].value),u=o.value[1].value,l=0;l<u.length;++l){var f={};if(f.type=c,f.value=u[l].value,f.valueTagClass=u[l].type,f.type in n&&(f.name=n[f.type],f.name in i&&(f.shortName=i[f.name])),f.type===n.extensionRequest){f.extensions=[];for(var p=0;p<f.value.length;++p)f.extensions.push(r.certificateExtensionFromAsn1(f.value[p]))}a.push(f)}return a};var f=function(e,r,i){var a={};if(e!==n["RSASSA-PSS"])return a;i&&(a={hash:{algorithmOid:n.sha1},mgf:{algorithmOid:n.mgf1,hash:{algorithmOid:n.sha1}},saltLength:20});var s={},c=[];if(!t.validate(r,o,s,c)){var u=new Error("Cannot read RSASSA-PSS parameter block.");throw u.errors=c,u}return void 0!==s.hashOid&&(a.hash=a.hash||{},a.hash.algorithmOid=t.derToOid(s.hashOid)),void 0!==s.maskGenOid&&(a.mgf=a.mgf||{},a.mgf.algorithmOid=t.derToOid(s.maskGenOid),a.mgf.hash=a.mgf.hash||{},a.mgf.hash.algorithmOid=t.derToOid(s.maskGenHashOid)),void 0!==s.saltLength&&(a.saltLength=s.saltLength.charCodeAt(0)),a},p=function(t){switch(n[t.signatureOid]){case"sha1WithRSAEncryption":case"sha1WithRSASignature":return e.md.sha1.create();case"md5WithRSAEncryption":return e.md.md5.create();case"sha256WithRSAEncryption":case"RSASSA-PSS":return e.md.sha256.create();case"sha384WithRSAEncryption":return e.md.sha384.create();case"sha512WithRSAEncryption":return e.md.sha512.create();default:var r=new Error("Could not compute "+t.type+" digest. Unknown signature OID.");throw r.signatureOid=t.signatureOid,r}},h=function(t){var r,i=t.certificate;switch(i.signatureOid){case n.sha1WithRSAEncryption:case n.sha1WithRSASignature:break;case n["RSASSA-PSS"]:var a,s,o;if(void 0===(a=n[i.signatureParameters.mgf.hash.algorithmOid])||void 0===e.md[a])throw(o=new Error("Unsupported MGF hash function.")).oid=i.signatureParameters.mgf.hash.algorithmOid,o.name=a,o;if(void 0===(s=n[i.signatureParameters.mgf.algorithmOid])||void 0===e.mgf[s])throw(o=new Error("Unsupported MGF function.")).oid=i.signatureParameters.mgf.algorithmOid,o.name=s,o;if(s=e.mgf[s].create(e.md[a].create()),void 0===(a=n[i.signatureParameters.hash.algorithmOid])||void 0===e.md[a])throw(o=new Error("Unsupported RSASSA-PSS hash function.")).oid=i.signatureParameters.hash.algorithmOid,o.name=a,o;r=e.pss.create(e.md[a].create(),s,i.signatureParameters.saltLength)}return i.publicKey.verify(t.md.digest().getBytes(),t.signature,r)};function d(r){for(var n,i,a=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),s=r.attributes,o=0;o<s.length;++o){var c=(n=s[o]).value,u=t.Type.PRINTABLESTRING;"valueTagClass"in n&&(u=n.valueTagClass)===t.Type.UTF8&&(c=e.util.encodeUtf8(c)),i=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.type).getBytes()),t.create(t.Class.UNIVERSAL,u,!1,c)])]),a.value.push(i)}return a}function g(e){for(var a,s=0;s<e.length;++s){if(void 0===(a=e[s]).name&&(a.type&&a.type in r.oids?a.name=r.oids[a.type]:a.shortName&&a.shortName in i&&(a.name=r.oids[i[a.shortName]])),void 0===a.type){if(!a.name||!(a.name in r.oids))throw(c=new Error("Attribute type not specified.")).attribute=a,c;a.type=r.oids[a.name]}if(void 0===a.shortName&&a.name&&a.name in i&&(a.shortName=i[a.name]),a.type===n.extensionRequest&&(a.valueConstructed=!0,a.valueTagClass=t.Type.SEQUENCE,!a.value&&a.extensions)){a.value=[];for(var o=0;o<a.extensions.length;++o)a.value.push(r.certificateExtensionToAsn1(y(a.extensions[o])))}var c;if(void 0===a.value)throw(c=new Error("Attribute value not specified.")).attribute=a,c}}function y(i,a){if(a=a||{},void 0===i.name&&i.id&&i.id in r.oids&&(i.name=r.oids[i.id]),void 0===i.id){if(!i.name||!(i.name in r.oids))throw(S=new Error("Extension ID not specified.")).extension=i,S;i.id=r.oids[i.name]}if(void 0!==i.value)return i;if("keyUsage"===i.name){var s=0,o=0,c=0;i.digitalSignature&&(o|=128,s=7),i.nonRepudiation&&(o|=64,s=6),i.keyEncipherment&&(o|=32,s=5),i.dataEncipherment&&(o|=16,s=4),i.keyAgreement&&(o|=8,s=3),i.keyCertSign&&(o|=4,s=2),i.cRLSign&&(o|=2,s=1),i.encipherOnly&&(o|=1,s=0),i.decipherOnly&&(c|=128,s=7);var u=String.fromCharCode(s);0!==c?u+=String.fromCharCode(o)+String.fromCharCode(c):0!==o&&(u+=String.fromCharCode(o)),i.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,u)}else if("basicConstraints"===i.name)i.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),i.cA&&i.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255))),"pathLenConstraint"in i&&i.value.value.push(t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(i.pathLenConstraint).getBytes()));else if("extKeyUsage"===i.name){i.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);var l=i.value.value;for(var f in i)!0===i[f]&&(f in n?l.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n[f]).getBytes())):-1!==f.indexOf(".")&&l.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(f).getBytes())))}else if("nsCertType"===i.name){s=0,o=0;i.client&&(o|=128,s=7),i.server&&(o|=64,s=6),i.email&&(o|=32,s=5),i.objsign&&(o|=16,s=4),i.reserved&&(o|=8,s=3),i.sslCA&&(o|=4,s=2),i.emailCA&&(o|=2,s=1),i.objCA&&(o|=1,s=0);u=String.fromCharCode(s);0!==o&&(u+=String.fromCharCode(o)),i.value=t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,u)}else if("subjectAltName"===i.name||"issuerAltName"===i.name){i.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);for(var p=0;p<i.altNames.length;++p){u=(v=i.altNames[p]).value;if(7===v.type&&v.ip){if(null===(u=e.util.bytesFromIP(v.ip)))throw(S=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=i,S}else 8===v.type&&(u=v.oid?t.oidToDer(t.oidToDer(v.oid)):t.oidToDer(u));i.value.value.push(t.create(t.Class.CONTEXT_SPECIFIC,v.type,!1,u))}}else if("nsComment"===i.name&&a.cert){if(!/^[\x00-\x7F]*$/.test(i.comment)||i.comment.length<1||i.comment.length>128)throw new Error('Invalid "nsComment" content.');i.value=t.create(t.Class.UNIVERSAL,t.Type.IA5STRING,!1,i.comment)}else if("subjectKeyIdentifier"===i.name&&a.cert){var h=a.cert.generateSubjectKeyIdentifier();i.subjectKeyIdentifier=h.toHex(),i.value=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,h.getBytes())}else if("authorityKeyIdentifier"===i.name&&a.cert){i.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);l=i.value.value;if(i.keyIdentifier){var g=!0===i.keyIdentifier?a.cert.generateSubjectKeyIdentifier().getBytes():i.keyIdentifier;l.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!1,g))}if(i.authorityCertIssuer){var y=[t.create(t.Class.CONTEXT_SPECIFIC,4,!0,[d(!0===i.authorityCertIssuer?a.cert.issuer:i.authorityCertIssuer)])];l.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,y))}if(i.serialNumber){var m=e.util.hexToBytes(!0===i.serialNumber?a.cert.serialNumber:i.serialNumber);l.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!1,m))}}else if("cRLDistributionPoints"===i.name){i.value=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);l=i.value.value;var v,C=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]),E=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(p=0;p<i.altNames.length;++p){u=(v=i.altNames[p]).value;if(7===v.type&&v.ip){if(null===(u=e.util.bytesFromIP(v.ip)))throw(S=new Error('Extension "ip" value is not a valid IPv4 or IPv6 address.')).extension=i,S}else 8===v.type&&(u=v.oid?t.oidToDer(t.oidToDer(v.oid)):t.oidToDer(u));E.value.push(t.create(t.Class.CONTEXT_SPECIFIC,v.type,!1,u))}C.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[E])),l.push(C)}var S;if(void 0===i.value)throw(S=new Error("Extension value not specified.")).extension=i,S;return i}function m(e,r){if(e===n["RSASSA-PSS"]){var i=[];return void 0!==r.hash.algorithmOid&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])),void 0!==r.mgf.algorithmOid&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.mgf.hash.algorithmOid).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])])])),void 0!==r.saltLength&&i.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.saltLength).getBytes())])),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,i)}return t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")}function v(r){var n=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);if(0===r.attributes.length)return n;for(var i=r.attributes,a=0;a<i.length;++a){var s=i[a],o=s.value,c=t.Type.UTF8;"valueTagClass"in s&&(c=s.valueTagClass),c===t.Type.UTF8&&(o=e.util.encodeUtf8(o));var u=!1;"valueConstructed"in s&&(u=s.valueConstructed);var l=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(s.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,c,u,o)])]);n.value.push(l)}return n}r.certificateFromPem=function(n,i,a){var s=e.pem.decode(n)[0];if("CERTIFICATE"!==s.type&&"X509 CERTIFICATE"!==s.type&&"TRUSTED CERTIFICATE"!==s.type){var o=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw o.headerType=s.type,o}if(s.procType&&"ENCRYPTED"===s.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var c=t.fromDer(s.body,a);return r.certificateFromAsn1(c,i)},r.certificateToPem=function(n,i){var a={type:"CERTIFICATE",body:t.toDer(r.certificateToAsn1(n)).getBytes()};return e.pem.encode(a,{maxline:i})},r.publicKeyFromPem=function(n){var i=e.pem.decode(n)[0];if("PUBLIC KEY"!==i.type&&"RSA PUBLIC KEY"!==i.type){var a=new Error('Could not convert public key from PEM; PEM header type is not "PUBLIC KEY" or "RSA PUBLIC KEY".');throw a.headerType=i.type,a}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert public key from PEM; PEM is encrypted.");var s=t.fromDer(i.body);return r.publicKeyFromAsn1(s)},r.publicKeyToPem=function(n,i){var a={type:"PUBLIC KEY",body:t.toDer(r.publicKeyToAsn1(n)).getBytes()};return e.pem.encode(a,{maxline:i})},r.publicKeyToRSAPublicKeyPem=function(n,i){var a={type:"RSA PUBLIC KEY",body:t.toDer(r.publicKeyToRSAPublicKey(n)).getBytes()};return e.pem.encode(a,{maxline:i})},r.getPublicKeyFingerprint=function(n,i){var a,s=(i=i||{}).md||e.md.sha1.create();switch(i.type||"RSAPublicKey"){case"RSAPublicKey":a=t.toDer(r.publicKeyToRSAPublicKey(n)).getBytes();break;case"SubjectPublicKeyInfo":a=t.toDer(r.publicKeyToAsn1(n)).getBytes();break;default:throw new Error('Unknown fingerprint type "'+i.type+'".')}s.start(),s.update(a);var o=s.digest();if("hex"===i.encoding){var c=o.toHex();return i.delimiter?c.match(/.{2}/g).join(i.delimiter):c}if("binary"===i.encoding)return o.getBytes();if(i.encoding)throw new Error('Unknown encoding "'+i.encoding+'".');return o},r.certificationRequestFromPem=function(n,i,a){var s=e.pem.decode(n)[0];if("CERTIFICATE REQUEST"!==s.type){var o=new Error('Could not convert certification request from PEM; PEM header type is not "CERTIFICATE REQUEST".');throw o.headerType=s.type,o}if(s.procType&&"ENCRYPTED"===s.procType.type)throw new Error("Could not convert certification request from PEM; PEM is encrypted.");var c=t.fromDer(s.body,a);return r.certificationRequestFromAsn1(c,i)},r.certificationRequestToPem=function(n,i){var a={type:"CERTIFICATE REQUEST",body:t.toDer(r.certificationRequestToAsn1(n)).getBytes()};return e.pem.encode(a,{maxline:i})},r.createCertificate=function(){var i={version:2,serialNumber:"00",signatureOid:null,signature:null,siginfo:{}};return i.siginfo.algorithmOid=null,i.validity={},i.validity.notBefore=new Date,i.validity.notAfter=new Date,i.issuer={},i.issuer.getField=function(e){return l(i.issuer,e)},i.issuer.addField=function(e){g([e]),i.issuer.attributes.push(e)},i.issuer.attributes=[],i.issuer.hash=null,i.subject={},i.subject.getField=function(e){return l(i.subject,e)},i.subject.addField=function(e){g([e]),i.subject.attributes.push(e)},i.subject.attributes=[],i.subject.hash=null,i.extensions=[],i.publicKey=null,i.md=null,i.setSubject=function(e,t){g(e),i.subject.attributes=e,delete i.subject.uniqueId,t&&(i.subject.uniqueId=t),i.subject.hash=null},i.setIssuer=function(e,t){g(e),i.issuer.attributes=e,delete i.issuer.uniqueId,t&&(i.issuer.uniqueId=t),i.issuer.hash=null},i.setExtensions=function(e){for(var t=0;t<e.length;++t)y(e[t],{cert:i});i.extensions=e},i.getExtension=function(e){"string"==typeof e&&(e={name:e});for(var t,r=null,n=0;null===r&&n<i.extensions.length;++n)t=i.extensions[n],(e.id&&t.id===e.id||e.name&&t.name===e.name)&&(r=t);return r},i.sign=function(a,s){i.md=s||e.md.sha1.create();var o=n[i.md.algorithm+"WithRSAEncryption"];if(!o){var c=new Error("Could not compute certificate digest. Unknown message digest algorithm OID.");throw c.algorithm=i.md.algorithm,c}i.signatureOid=i.siginfo.algorithmOid=o,i.tbsCertificate=r.getTBSCertificate(i);var u=t.toDer(i.tbsCertificate);i.md.update(u.getBytes()),i.signature=a.sign(i.md)},i.verify=function(e){var n=!1;if(!i.issued(e)){var a=e.issuer,s=i.subject,o=new Error("The parent certificate did not issue the given child certificate; the child certificate's issuer does not match the parent's subject.");throw o.expectedIssuer=s.attributes,o.actualIssuer=a.attributes,o}var c=e.md;if(null===c){c=p({signatureOid:e.signatureOid,type:"certificate"});var u=e.tbsCertificate||r.getTBSCertificate(e),l=t.toDer(u);c.update(l.getBytes())}return null!==c&&(n=h({certificate:i,md:c,signature:e.signature})),n},i.isIssuer=function(e){var t=!1,r=i.issuer,n=e.subject;if(r.hash&&n.hash)t=r.hash===n.hash;else if(r.attributes.length===n.attributes.length){var a,s;t=!0;for(var o=0;t&&o<r.attributes.length;++o)a=r.attributes[o],s=n.attributes[o],a.type===s.type&&a.value===s.value||(t=!1)}return t},i.issued=function(e){return e.isIssuer(i)},i.generateSubjectKeyIdentifier=function(){return r.getPublicKeyFingerprint(i.publicKey,{type:"RSAPublicKey"})},i.verifySubjectKeyIdentifier=function(){for(var t=n.subjectKeyIdentifier,r=0;r<i.extensions.length;++r){var a=i.extensions[r];if(a.id===t){var s=i.generateSubjectKeyIdentifier().getBytes();return e.util.hexToBytes(a.subjectKeyIdentifier)===s}}return!1},i},r.certificateFromAsn1=function(n,i){var a={},o=[];if(!t.validate(n,s,a,o)){var c=new Error("Cannot read X.509 certificate. ASN.1 object is not an X509v3 Certificate.");throw c.errors=o,c}if(t.derToOid(a.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var u=r.createCertificate();u.version=a.certVersion?a.certVersion.charCodeAt(0):0;var h=e.util.createBuffer(a.certSerialNumber);u.serialNumber=h.toHex(),u.signatureOid=e.asn1.derToOid(a.certSignatureOid),u.signatureParameters=f(u.signatureOid,a.certSignatureParams,!0),u.siginfo.algorithmOid=e.asn1.derToOid(a.certinfoSignatureOid),u.siginfo.parameters=f(u.siginfo.algorithmOid,a.certinfoSignatureParams,!1),u.signature=a.certSignature;var d=[];if(void 0!==a.certValidity1UTCTime&&d.push(t.utcTimeToDate(a.certValidity1UTCTime)),void 0!==a.certValidity2GeneralizedTime&&d.push(t.generalizedTimeToDate(a.certValidity2GeneralizedTime)),void 0!==a.certValidity3UTCTime&&d.push(t.utcTimeToDate(a.certValidity3UTCTime)),void 0!==a.certValidity4GeneralizedTime&&d.push(t.generalizedTimeToDate(a.certValidity4GeneralizedTime)),d.length>2)throw new Error("Cannot read notBefore/notAfter validity times; more than two times were provided in the certificate.");if(d.length<2)throw new Error("Cannot read notBefore/notAfter validity times; they were not provided as either UTCTime or GeneralizedTime.");if(u.validity.notBefore=d[0],u.validity.notAfter=d[1],u.tbsCertificate=a.tbsCertificate,i){u.md=p({signatureOid:u.signatureOid,type:"certificate"});var y=t.toDer(u.tbsCertificate);u.md.update(y.getBytes())}var m=e.md.sha1.create(),v=t.toDer(a.certIssuer);m.update(v.getBytes()),u.issuer.getField=function(e){return l(u.issuer,e)},u.issuer.addField=function(e){g([e]),u.issuer.attributes.push(e)},u.issuer.attributes=r.RDNAttributesAsArray(a.certIssuer),a.certIssuerUniqueId&&(u.issuer.uniqueId=a.certIssuerUniqueId),u.issuer.hash=m.digest().toHex();var C=e.md.sha1.create(),E=t.toDer(a.certSubject);return C.update(E.getBytes()),u.subject.getField=function(e){return l(u.subject,e)},u.subject.addField=function(e){g([e]),u.subject.attributes.push(e)},u.subject.attributes=r.RDNAttributesAsArray(a.certSubject),a.certSubjectUniqueId&&(u.subject.uniqueId=a.certSubjectUniqueId),u.subject.hash=C.digest().toHex(),a.certExtensions?u.extensions=r.certificateExtensionsFromAsn1(a.certExtensions):u.extensions=[],u.publicKey=r.publicKeyFromAsn1(a.subjectPublicKeyInfo),u},r.certificateExtensionsFromAsn1=function(e){for(var t=[],n=0;n<e.value.length;++n)for(var i=e.value[n],a=0;a<i.value.length;++a)t.push(r.certificateExtensionFromAsn1(i.value[a]));return t},r.certificateExtensionFromAsn1=function(r){var i={};if(i.id=t.derToOid(r.value[0].value),i.critical=!1,r.value[1].type===t.Type.BOOLEAN?(i.critical=0!==r.value[1].value.charCodeAt(0),i.value=r.value[2].value):i.value=r.value[1].value,i.id in n)if(i.name=n[i.id],"keyUsage"===i.name){var a=0,s=0;(c=t.fromDer(i.value)).value.length>1&&(a=c.value.charCodeAt(1),s=c.value.length>2?c.value.charCodeAt(2):0),i.digitalSignature=!(128&~a),i.nonRepudiation=!(64&~a),i.keyEncipherment=!(32&~a),i.dataEncipherment=!(16&~a),i.keyAgreement=!(8&~a),i.keyCertSign=!(4&~a),i.cRLSign=!(2&~a),i.encipherOnly=!(1&~a),i.decipherOnly=!(128&~s)}else if("basicConstraints"===i.name){(c=t.fromDer(i.value)).value.length>0&&c.value[0].type===t.Type.BOOLEAN?i.cA=0!==c.value[0].value.charCodeAt(0):i.cA=!1;var o=null;c.value.length>0&&c.value[0].type===t.Type.INTEGER?o=c.value[0].value:c.value.length>1&&(o=c.value[1].value),null!==o&&(i.pathLenConstraint=t.derToInteger(o))}else if("extKeyUsage"===i.name)for(var c=t.fromDer(i.value),u=0;u<c.value.length;++u){var l=t.derToOid(c.value[u].value);l in n?i[n[l]]=!0:i[l]=!0}else if("nsCertType"===i.name){a=0;(c=t.fromDer(i.value)).value.length>1&&(a=c.value.charCodeAt(1)),i.client=!(128&~a),i.server=!(64&~a),i.email=!(32&~a),i.objsign=!(16&~a),i.reserved=!(8&~a),i.sslCA=!(4&~a),i.emailCA=!(2&~a),i.objCA=!(1&~a)}else if("subjectAltName"===i.name||"issuerAltName"===i.name){var f;i.altNames=[];c=t.fromDer(i.value);for(var p=0;p<c.value.length;++p){var h={type:(f=c.value[p]).type,value:f.value};switch(i.altNames.push(h),f.type){case 1:case 2:case 6:break;case 7:h.ip=e.util.bytesToIP(f.value);break;case 8:h.oid=t.derToOid(f.value)}}}else if("subjectKeyIdentifier"===i.name){c=t.fromDer(i.value);i.subjectKeyIdentifier=e.util.bytesToHex(c.value)}return i},r.certificationRequestFromAsn1=function(n,i){var a={},s=[];if(!t.validate(n,u,a,s)){var o=new Error("Cannot read PKCS#10 certificate request. ASN.1 object is not a PKCS#10 CertificationRequest.");throw o.errors=s,o}if(t.derToOid(a.publicKeyOid)!==r.oids.rsaEncryption)throw new Error("Cannot read public key. OID is not RSA.");var c=r.createCertificationRequest();if(c.version=a.csrVersion?a.csrVersion.charCodeAt(0):0,c.signatureOid=e.asn1.derToOid(a.csrSignatureOid),c.signatureParameters=f(c.signatureOid,a.csrSignatureParams,!0),c.siginfo.algorithmOid=e.asn1.derToOid(a.csrSignatureOid),c.siginfo.parameters=f(c.siginfo.algorithmOid,a.csrSignatureParams,!1),c.signature=a.csrSignature,c.certificationRequestInfo=a.certificationRequestInfo,i){c.md=p({signatureOid:c.signatureOid,type:"certification request"});var h=t.toDer(c.certificationRequestInfo);c.md.update(h.getBytes())}var d=e.md.sha1.create();return c.subject.getField=function(e){return l(c.subject,e)},c.subject.addField=function(e){g([e]),c.subject.attributes.push(e)},c.subject.attributes=r.RDNAttributesAsArray(a.certificationRequestInfoSubject,d),c.subject.hash=d.digest().toHex(),c.publicKey=r.publicKeyFromAsn1(a.subjectPublicKeyInfo),c.getAttribute=function(e){return l(c,e)},c.addAttribute=function(e){g([e]),c.attributes.push(e)},c.attributes=r.CRIAttributesAsArray(a.certificationRequestInfoAttributes||[]),c},r.createCertificationRequest=function(){var i={version:0,signatureOid:null,signature:null,siginfo:{}};return i.siginfo.algorithmOid=null,i.subject={},i.subject.getField=function(e){return l(i.subject,e)},i.subject.addField=function(e){g([e]),i.subject.attributes.push(e)},i.subject.attributes=[],i.subject.hash=null,i.publicKey=null,i.attributes=[],i.getAttribute=function(e){return l(i,e)},i.addAttribute=function(e){g([e]),i.attributes.push(e)},i.md=null,i.setSubject=function(e){g(e),i.subject.attributes=e,i.subject.hash=null},i.setAttributes=function(e){g(e),i.attributes=e},i.sign=function(a,s){i.md=s||e.md.sha1.create();var o=n[i.md.algorithm+"WithRSAEncryption"];if(!o){var c=new Error("Could not compute certification request digest. Unknown message digest algorithm OID.");throw c.algorithm=i.md.algorithm,c}i.signatureOid=i.siginfo.algorithmOid=o,i.certificationRequestInfo=r.getCertificationRequestInfo(i);var u=t.toDer(i.certificationRequestInfo);i.md.update(u.getBytes()),i.signature=a.sign(i.md)},i.verify=function(){var e=!1,n=i.md;if(null===n){n=p({signatureOid:i.signatureOid,type:"certification request"});var a=i.certificationRequestInfo||r.getCertificationRequestInfo(i),s=t.toDer(a);n.update(s.getBytes())}return null!==n&&(e=h({certificate:i,md:n,signature:i.signature})),e},i};var C=new Date("1950-01-01T00:00:00Z"),E=new Date("2050-01-01T00:00:00Z");function S(e){return e>=C&&e<E?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(e)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(e))}return r.getTBSCertificate=function(n){var i=S(n.validity.notBefore),a=S(n.validity.notAfter),s=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(n.version).getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,e.util.hexToBytes(n.serialNumber)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.siginfo.algorithmOid).getBytes()),m(n.siginfo.algorithmOid,n.siginfo.parameters)]),d(n.issuer),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[i,a]),d(n.subject),r.publicKeyToAsn1(n.publicKey)]);return n.issuer.uniqueId&&s.value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+n.issuer.uniqueId)])),n.subject.uniqueId&&s.value.push(t.create(t.Class.CONTEXT_SPECIFIC,2,!0,[t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+n.subject.uniqueId)])),n.extensions.length>0&&s.value.push(r.certificateExtensionsToAsn1(n.extensions)),s},r.getCertificationRequestInfo=function(e){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(e.version).getBytes()),d(e.subject),r.publicKeyToAsn1(e.publicKey),v(e)])},r.distinguishedNameToAsn1=function(e){return d(e)},r.certificateToAsn1=function(e){var n=e.tbsCertificate||r.getTBSCertificate(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),m(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.certificateExtensionsToAsn1=function(e){var n=t.create(t.Class.CONTEXT_SPECIFIC,3,!0,[]),i=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);n.value.push(i);for(var a=0;a<e.length;++a)i.value.push(r.certificateExtensionToAsn1(e[a]));return n},r.certificateExtensionToAsn1=function(e){var r=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[]);r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.id).getBytes())),e.critical&&r.value.push(t.create(t.Class.UNIVERSAL,t.Type.BOOLEAN,!1,String.fromCharCode(255)));var n=e.value;return"string"!=typeof e.value&&(n=t.toDer(n).getBytes()),r.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,n)),r},r.certificationRequestToAsn1=function(e){var n=e.certificationRequestInfo||r.getCertificationRequestInfo(e);return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[n,t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.signatureOid).getBytes()),m(e.signatureOid,e.signatureParameters)]),t.create(t.Class.UNIVERSAL,t.Type.BITSTRING,!1,String.fromCharCode(0)+e.signature)])},r.createCaStore=function(n){var i={certs:{}};function a(e){return s(e),i.certs[e.hash]||null}function s(t){if(!t.hash){var n=e.md.sha1.create();t.attributes=r.RDNAttributesAsArray(d(t),n),t.hash=n.digest().toHex()}}if(i.getIssuer=function(e){return a(e.issuer)},i.addCertificate=function(t){if("string"==typeof t&&(t=e.pki.certificateFromPem(t)),s(t.subject),!i.hasCertificate(t))if(t.subject.hash in i.certs){var r=i.certs[t.subject.hash];e.util.isArray(r)||(r=[r]),r.push(t),i.certs[t.subject.hash]=r}else i.certs[t.subject.hash]=t},i.hasCertificate=function(n){"string"==typeof n&&(n=e.pki.certificateFromPem(n));var i=a(n.subject);if(!i)return!1;e.util.isArray(i)||(i=[i]);for(var s=t.toDer(r.certificateToAsn1(n)).getBytes(),o=0;o<i.length;++o){if(s===t.toDer(r.certificateToAsn1(i[o])).getBytes())return!0}return!1},i.listAllCertificates=function(){var t=[];for(var r in i.certs)if(i.certs.hasOwnProperty(r)){var n=i.certs[r];if(e.util.isArray(n))for(var a=0;a<n.length;++a)t.push(n[a]);else t.push(n)}return t},i.removeCertificate=function(n){var o;if("string"==typeof n&&(n=e.pki.certificateFromPem(n)),s(n.subject),!i.hasCertificate(n))return null;var c=a(n.subject);if(!e.util.isArray(c))return o=i.certs[n.subject.hash],delete i.certs[n.subject.hash],o;for(var u=t.toDer(r.certificateToAsn1(n)).getBytes(),l=0;l<c.length;++l){u===t.toDer(r.certificateToAsn1(c[l])).getBytes()&&(o=c[l],c.splice(l,1))}return 0===c.length&&delete i.certs[n.subject.hash],o},n)for(var o=0;o<n.length;++o){var c=n[o];i.addCertificate(c)}return i},r.certificateError={bad_certificate:"forge.pki.BadCertificate",unsupported_certificate:"forge.pki.UnsupportedCertificate",certificate_revoked:"forge.pki.CertificateRevoked",certificate_expired:"forge.pki.CertificateExpired",certificate_unknown:"forge.pki.CertificateUnknown",unknown_ca:"forge.pki.UnknownCertificateAuthority"},r.verifyCertificateChain=function(t,n,i){"function"==typeof i&&(i={verify:i}),i=i||{};var a=(n=n.slice(0)).slice(0),s=i.validityCheckDate;void 0===s&&(s=new Date);var o=!0,c=null,u=0;do{var l=n.shift(),f=null,p=!1;if(s&&(s<l.validity.notBefore||s>l.validity.notAfter)&&(c={message:"Certificate is not valid yet or has expired.",error:r.certificateError.certificate_expired,notBefore:l.validity.notBefore,notAfter:l.validity.notAfter,now:s}),null===c){if(null===(f=n[0]||t.getIssuer(l))&&l.isIssuer(l)&&(p=!0,f=l),f){var h=f;e.util.isArray(h)||(h=[h]);for(var d=!1;!d&&h.length>0;){f=h.shift();try{d=f.verify(l)}catch(T){}}d||(c={message:"Certificate signature is invalid.",error:r.certificateError.bad_certificate})}null!==c||f&&!p||t.hasCertificate(l)||(c={message:"Certificate is not trusted.",error:r.certificateError.unknown_ca})}if(null===c&&f&&!l.isIssuer(f)&&(c={message:"Certificate issuer is invalid.",error:r.certificateError.bad_certificate}),null===c)for(var g={keyUsage:!0,basicConstraints:!0},y=0;null===c&&y<l.extensions.length;++y){var m=l.extensions[y];m.critical&&!(m.name in g)&&(c={message:"Certificate has an unsupported critical extension.",error:r.certificateError.unsupported_certificate})}if(null===c&&(!o||0===n.length&&(!f||p))){var v=l.getExtension("basicConstraints"),C=l.getExtension("keyUsage");if(null!==C&&(C.keyCertSign&&null!==v||(c={message:"Certificate keyUsage or basicConstraints conflict or indicate that the certificate is not a CA. If the certificate is the only one in the chain or isn't the first then the certificate must be a valid CA.",error:r.certificateError.bad_certificate})),null!==c||null===v||v.cA||(c={message:"Certificate basicConstraints indicates the certificate is not a CA.",error:r.certificateError.bad_certificate}),null===c&&null!==C&&"pathLenConstraint"in v)u-1>v.pathLenConstraint&&(c={message:"Certificate basicConstraints pathLenConstraint violated.",error:r.certificateError.bad_certificate})}var E=null===c||c.error,S=i.verify?i.verify(E,u,a):E;if(!0!==S)throw!0===E&&(c={message:"The application rejected the certificate.",error:r.certificateError.bad_certificate}),(S||0===S)&&("object"!=typeof S||e.util.isArray(S)?"string"==typeof S&&(c.error=S):(S.message&&(c.message=S.message),S.error&&(c.error=S.error))),c;c=null,o=!1,++u}while(n.length>0);return!0},vn.exports}function kn(){if(bn)return pn.exports;bn=1;var e=zt();hr(),Cr(),pr(),dn(),ln(),zr(),un(),Zr(),Zt(),Rn();var t=e.asn1,r=e.pki,n=pn.exports=e.pkcs12=e.pkcs12||{},i={name:"ContentInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"ContentInfo.contentType",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"contentType"},{name:"ContentInfo.content",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"content"}]},a={name:"PFX",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"version"},i,{name:"PFX.macData",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,optional:!0,captureAsn1:"mac",value:[{name:"PFX.macData.mac",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PFX.macData.mac.digestAlgorithm.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"macAlgorithm"},{name:"PFX.macData.mac.digestAlgorithm.parameters",tagClass:t.Class.UNIVERSAL,captureAsn1:"macAlgorithmParameters"}]},{name:"PFX.macData.mac.digest",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macDigest"}]},{name:"PFX.macData.macSalt",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"macSalt"},{name:"PFX.macData.iterations",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,optional:!0,capture:"macIterations"}]}]},s={name:"SafeBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"SafeBag.bagId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"bagId"},{name:"SafeBag.bagValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,captureAsn1:"bagValue"},{name:"SafeBag.bagAttributes",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,optional:!0,capture:"bagAttributes"}]},o={name:"Attribute",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"Attribute.attrId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"oid"},{name:"Attribute.attrValues",tagClass:t.Class.UNIVERSAL,type:t.Type.SET,constructed:!0,capture:"values"}]},c={name:"CertBag",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"CertBag.certId",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"certId"},{name:"CertBag.certValue",tagClass:t.Class.CONTEXT_SPECIFIC,constructed:!0,value:[{name:"CertBag.certValue[0]",tagClass:t.Class.UNIVERSAL,type:t.Class.OCTETSTRING,constructed:!1,capture:"cert"}]}]};function u(e,t,r,n){for(var i=[],a=0;a<e.length;a++)for(var s=0;s<e[a].safeBags.length;s++){var o=e[a].safeBags[s];void 0!==n&&o.type!==n||(null!==t?void 0!==o.attributes[t]&&o.attributes[t].indexOf(r)>=0&&i.push(o):i.push(o))}return i}function l(t){if(t.composed||t.constructed){for(var r=e.util.createBuffer(),n=0;n<t.value.length;++n)r.putBytes(t.value[n].value);t.composed=t.constructed=!1,t.value=r.getBytes()}return t}function f(n,i){var a={},s=[];if(!t.validate(n,e.pkcs7.asn1.encryptedDataValidator,a,s))throw(o=new Error("Cannot read EncryptedContentInfo.")).errors=s,o;var o,c=t.derToOid(a.contentType);if(c!==r.oids.data)throw(o=new Error("PKCS#12 EncryptedContentInfo ContentType is not Data.")).oid=c,o;c=t.derToOid(a.encAlgorithm);var u=r.pbe.getCipher(c,a.encParameter,i),f=l(a.encryptedContentAsn1),p=e.util.createBuffer(f.value);if(u.update(p),!u.finish())throw new Error("Failed to decrypt PKCS#12 SafeContents.");return u.output.getBytes()}function p(e,n,i){if(!n&&0===e.length)return[];if((e=t.fromDer(e,n)).tagClass!==t.Class.UNIVERSAL||e.type!==t.Type.SEQUENCE||!0!==e.constructed)throw new Error("PKCS#12 SafeContents expected to be a SEQUENCE OF SafeBag.");for(var a=[],o=0;o<e.value.length;o++){var u=e.value[o],l={},f=[];if(!t.validate(u,s,l,f))throw(m=new Error("Cannot read SafeBag.")).errors=f,m;var p,d,g={type:t.derToOid(l.bagId),attributes:h(l.bagAttributes)};a.push(g);var y=l.bagValue.value[0];switch(g.type){case r.oids.pkcs8ShroudedKeyBag:if(null===(y=r.decryptPrivateKeyInfo(y,i)))throw new Error("Unable to decrypt PKCS#8 ShroudedKeyBag, wrong password?");case r.oids.keyBag:try{g.key=r.privateKeyFromAsn1(y)}catch(v){g.key=null,g.asn1=y}continue;case r.oids.certBag:p=c,d=function(){if(t.derToOid(l.certId)!==r.oids.x509Certificate){var e=new Error("Unsupported certificate type, only X.509 supported.");throw e.oid=t.derToOid(l.certId),e}var i=t.fromDer(l.cert,n);try{g.cert=r.certificateFromAsn1(i,!0)}catch(v){g.cert=null,g.asn1=i}};break;default:var m;throw(m=new Error("Unsupported PKCS#12 SafeBag type.")).oid=g.type,m}if(void 0!==p&&!t.validate(y,p,l,f))throw(m=new Error("Cannot read PKCS#12 "+p.name)).errors=f,m;d()}return a}function h(e){var n={};if(void 0!==e)for(var i=0;i<e.length;++i){var a={},s=[];if(!t.validate(e[i],o,a,s)){var c=new Error("Cannot read PKCS#12 BagAttribute.");throw c.errors=s,c}var u=t.derToOid(a.oid);if(void 0!==r.oids[u]){n[r.oids[u]]=[];for(var l=0;l<a.values.length;++l)n[r.oids[u]].push(a.values[l].value)}}return n}return n.pkcs12FromAsn1=function(s,o,c){"string"==typeof o?(c=o,o=!0):void 0===o&&(o=!0);var h={};if(!t.validate(s,a,h,[]))throw(d=new Error("Cannot read PKCS#12 PFX. ASN.1 object is not an PKCS#12 PFX.")).errors=d,d;var d,g={version:h.version.charCodeAt(0),safeContents:[],getBags:function(t){var r,n={};return"localKeyId"in t?r=t.localKeyId:"localKeyIdHex"in t&&(r=e.util.hexToBytes(t.localKeyIdHex)),void 0===r&&!("friendlyName"in t)&&"bagType"in t&&(n[t.bagType]=u(g.safeContents,null,null,t.bagType)),void 0!==r&&(n.localKeyId=u(g.safeContents,"localKeyId",r,t.bagType)),"friendlyName"in t&&(n.friendlyName=u(g.safeContents,"friendlyName",t.friendlyName,t.bagType)),n},getBagsByFriendlyName:function(e,t){return u(g.safeContents,"friendlyName",e,t)},getBagsByLocalKeyId:function(e,t){return u(g.safeContents,"localKeyId",e,t)}};if(3!==h.version.charCodeAt(0))throw(d=new Error("PKCS#12 PFX of version other than 3 not supported.")).version=h.version.charCodeAt(0),d;if(t.derToOid(h.contentType)!==r.oids.data)throw(d=new Error("Only PKCS#12 PFX in password integrity mode supported.")).oid=t.derToOid(h.contentType),d;var y=h.content.value[0];if(y.tagClass!==t.Class.UNIVERSAL||y.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 authSafe content data is not an OCTET STRING.");if(y=l(y),h.mac){var m=null,v=0,C=t.derToOid(h.macAlgorithm);switch(C){case r.oids.sha1:m=e.md.sha1.create(),v=20;break;case r.oids.sha256:m=e.md.sha256.create(),v=32;break;case r.oids.sha384:m=e.md.sha384.create(),v=48;break;case r.oids.sha512:m=e.md.sha512.create(),v=64;break;case r.oids.md5:m=e.md.md5.create(),v=16}if(null===m)throw new Error("PKCS#12 uses unsupported MAC algorithm: "+C);var E=new e.util.ByteBuffer(h.macSalt),S="macIterations"in h?parseInt(e.util.bytesToHex(h.macIterations),16):1,T=n.generateKey(c,E,3,S,v,m),b=e.hmac.create();if(b.start(m,T),b.update(y.value),b.getMac().getBytes()!==h.macDigest)throw new Error("PKCS#12 MAC could not be verified. Invalid password?")}return function(e,n,a,s){if(n=t.fromDer(n,a),n.tagClass!==t.Class.UNIVERSAL||n.type!==t.Type.SEQUENCE||!0!==n.constructed)throw new Error("PKCS#12 AuthenticatedSafe expected to be a SEQUENCE OF ContentInfo");for(var o=0;o<n.value.length;o++){var c=n.value[o],u={},h=[];if(!t.validate(c,i,u,h))throw(m=new Error("Cannot read ContentInfo.")).errors=h,m;var d={encrypted:!1},g=null,y=u.content.value[0];switch(t.derToOid(u.contentType)){case r.oids.data:if(y.tagClass!==t.Class.UNIVERSAL||y.type!==t.Type.OCTETSTRING)throw new Error("PKCS#12 SafeContents Data is not an OCTET STRING.");g=l(y).value;break;case r.oids.encryptedData:g=f(y,s),d.encrypted=!0;break;default:var m;throw(m=new Error("Unsupported PKCS#12 contentType.")).contentType=t.derToOid(u.contentType),m}d.safeBags=p(g,a,s),e.safeContents.push(d)}}(g,y.value,o,c),g},n.toPkcs12Asn1=function(i,a,s,o){(o=o||{}).saltSize=o.saltSize||8,o.count=o.count||2048,o.algorithm=o.algorithm||o.encAlgorithm||"aes128","useMac"in o||(o.useMac=!0),"localKeyId"in o||(o.localKeyId=null),"generateLocalKeyId"in o||(o.generateLocalKeyId=!0);var c,u=o.localKeyId;if(null!==u)u=e.util.hexToBytes(u);else if(o.generateLocalKeyId)if(a){var l=e.util.isArray(a)?a[0]:a;"string"==typeof l&&(l=r.certificateFromPem(l)),(w=e.md.sha1.create()).update(t.toDer(r.certificateToAsn1(l)).getBytes()),u=w.digest().getBytes()}else u=e.random.getBytes(20);var f=[];null!==u&&f.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.localKeyId).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,u)])])),"friendlyName"in o&&f.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.friendlyName).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[t.create(t.Class.UNIVERSAL,t.Type.BMPSTRING,!1,o.friendlyName)])])),f.length>0&&(c=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,f));var p=[],h=[];null!==a&&(h=e.util.isArray(a)?a:[a]);for(var d=[],g=0;g<h.length;++g){"string"==typeof(a=h[g])&&(a=r.certificateFromPem(a));var y=0===g?c:void 0,m=r.certificateToAsn1(a),v=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.certBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.x509Certificate).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(m).getBytes())])])]),y]);d.push(v)}if(d.length>0){var C=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,d),E=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(C).getBytes())])]);p.push(E)}var S=null;if(null!==i){var T=r.wrapRsaPrivateKey(r.privateKeyToAsn1(i));S=null===s?t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.keyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[T]),c]):t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.pkcs8ShroudedKeyBag).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[r.encryptPrivateKeyInfo(T,s,o)]),c]);var b=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[S]),A=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(b).getBytes())])]);p.push(A)}var I,B=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,p);if(o.useMac){var w=e.md.sha1.create(),N=new e.util.ByteBuffer(e.random.getBytes(o.saltSize)),_=o.count,R=(i=n.generateKey(s,N,3,_,20),e.hmac.create());R.start(w,i),R.update(t.toDer(B).getBytes());var k=R.getMac();I=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.sha1).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,k.getBytes())]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,N.getBytes()),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(_).getBytes())])}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(3).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.oids.data).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,t.toDer(B).getBytes())])]),I])},n.generateKey=e.pbe.generatePkcs12Key,pn.exports}function Ln(){if(An)return Nr.exports;An=1;var e=zt();hr(),pr(),ln(),Ir(),Ur(),kn(),_n(),un(),Zt(),Rn();var t=e.asn1,r=Nr.exports=e.pki=e.pki||{};return r.pemToDer=function(t){var r=e.pem.decode(t)[0];if(r.procType&&"ENCRYPTED"===r.procType.type)throw new Error("Could not convert PEM to DER; PEM is encrypted.");return e.util.createBuffer(r.body)},r.privateKeyFromPem=function(n){var i=e.pem.decode(n)[0];if("PRIVATE KEY"!==i.type&&"RSA PRIVATE KEY"!==i.type){var a=new Error('Could not convert private key from PEM; PEM header type is not "PRIVATE KEY" or "RSA PRIVATE KEY".');throw a.headerType=i.type,a}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert private key from PEM; PEM is encrypted.");var s=t.fromDer(i.body);return r.privateKeyFromAsn1(s)},r.privateKeyToPem=function(n,i){var a={type:"RSA PRIVATE KEY",body:t.toDer(r.privateKeyToAsn1(n)).getBytes()};return e.pem.encode(a,{maxline:i})},r.privateKeyInfoToPem=function(r,n){var i={type:"PRIVATE KEY",body:t.toDer(r).getBytes()};return e.pem.encode(i,{maxline:n})},Nr.exports}function Un(){if(Bn)return In;Bn=1;var e=zt();hr(),Cr(),Tr(),Ir(),Ln(),zr(),Zr(),Zt();var t=function(t,r,n,i){var a=e.util.createBuffer(),s=t.length>>1,o=s+(1&t.length),c=t.substr(0,o),u=t.substr(s,o),l=e.util.createBuffer(),f=e.hmac.create();n=r+n;var p=Math.ceil(i/16),h=Math.ceil(i/20);f.start("MD5",c);var d=e.util.createBuffer();l.putBytes(n);for(var g=0;g<p;++g)f.start(null,null),f.update(l.getBytes()),l.putBuffer(f.digest()),f.start(null,null),f.update(l.bytes()+n),d.putBuffer(f.digest());f.start("SHA1",u);var y=e.util.createBuffer();l.clear(),l.putBytes(n);for(g=0;g<h;++g)f.start(null,null),f.update(l.getBytes()),l.putBuffer(f.digest()),f.start(null,null),f.update(l.bytes()+n),y.putBuffer(f.digest());return a.putBytes(e.util.xorBytes(d.getBytes(),y.getBytes(),i)),a},r=function(t,r,n){var i=!1;try{var a=t.deflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(a),r.length=a.length,i=!0}catch(s){}return i},n=function(t,r,n){var i=!1;try{var a=t.inflate(r.fragment.getBytes());r.fragment=e.util.createBuffer(a),r.length=a.length,i=!0}catch(s){}return i},i=function(t,r){var n=0;switch(r){case 1:n=t.getByte();break;case 2:n=t.getInt16();break;case 3:n=t.getInt24();break;case 4:n=t.getInt32()}return e.util.createBuffer(t.getBytes(n))},a=function(e,t,r){e.putInt(r.length(),t<<3),e.putBuffer(r)},s={Versions:{TLS_1_0:{major:3,minor:1},TLS_1_1:{major:3,minor:2},TLS_1_2:{major:3,minor:3}}};s.SupportedVersions=[s.Versions.TLS_1_1,s.Versions.TLS_1_0],s.Version=s.SupportedVersions[0],s.MaxFragment=15360,s.ConnectionEnd={server:0,client:1},s.PRFAlgorithm={tls_prf_sha256:0},s.BulkCipherAlgorithm={none:null,rc4:0,des3:1,aes:2},s.CipherType={stream:0,block:1,aead:2},s.MACAlgorithm={none:null,hmac_md5:0,hmac_sha1:1,hmac_sha256:2,hmac_sha384:3,hmac_sha512:4},s.CompressionMethod={none:0,deflate:1},s.ContentType={change_cipher_spec:20,alert:21,handshake:22,application_data:23,heartbeat:24},s.HandshakeType={hello_request:0,client_hello:1,server_hello:2,certificate:11,server_key_exchange:12,certificate_request:13,server_hello_done:14,certificate_verify:15,client_key_exchange:16,finished:20},s.Alert={},s.Alert.Level={warning:1,fatal:2},s.Alert.Description={close_notify:0,unexpected_message:10,bad_record_mac:20,decryption_failed:21,record_overflow:22,decompression_failure:30,handshake_failure:40,bad_certificate:42,unsupported_certificate:43,certificate_revoked:44,certificate_expired:45,certificate_unknown:46,illegal_parameter:47,unknown_ca:48,access_denied:49,decode_error:50,decrypt_error:51,export_restriction:60,protocol_version:70,insufficient_security:71,internal_error:80,user_canceled:90,no_renegotiation:100},s.HeartbeatMessageType={heartbeat_request:1,heartbeat_response:2},s.CipherSuites={},s.getCipherSuite=function(e){var t=null;for(var r in s.CipherSuites){var n=s.CipherSuites[r];if(n.id[0]===e.charCodeAt(0)&&n.id[1]===e.charCodeAt(1)){t=n;break}}return t},s.handleUnexpected=function(e,t){!e.open&&e.entity===s.ConnectionEnd.client||e.error(e,{message:"Unexpected message. Received TLS record out of order.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.unexpected_message}})},s.handleHelloRequest=function(e,t,r){!e.handshaking&&e.handshakes>0&&(s.queue(e,s.createAlert(e,{level:s.Alert.Level.warning,description:s.Alert.Description.no_renegotiation})),s.flush(e)),e.process()},s.parseHelloMessage=function(t,r,n){var a=null,o=t.entity===s.ConnectionEnd.client;if(n<38)t.error(t,{message:o?"Invalid ServerHello message. Message too short.":"Invalid ClientHello message. Message too short.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.illegal_parameter}});else{var c=r.fragment,u=c.length();if(a={version:{major:c.getByte(),minor:c.getByte()},random:e.util.createBuffer(c.getBytes(32)),session_id:i(c,1),extensions:[]},o?(a.cipher_suite=c.getBytes(2),a.compression_method=c.getByte()):(a.cipher_suites=i(c,2),a.compression_methods=i(c,1)),(u=n-(u-c.length()))>0){for(var l=i(c,2);l.length()>0;)a.extensions.push({type:[l.getByte(),l.getByte()],data:i(l,2)});if(!o)for(var f=0;f<a.extensions.length;++f){var p=a.extensions[f];if(0===p.type[0]&&0===p.type[1])for(var h=i(p.data,2);h.length()>0;){if(0!==h.getByte())break;t.session.extensions.server_name.serverNameList.push(i(h,2).getBytes())}}}if(t.session.version&&(a.version.major!==t.session.version.major||a.version.minor!==t.session.version.minor))return t.error(t,{message:"TLS version change is disallowed during renegotiation.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.protocol_version}});if(o)t.session.cipherSuite=s.getCipherSuite(a.cipher_suite);else for(var d=e.util.createBuffer(a.cipher_suites.bytes());d.length()>0&&(t.session.cipherSuite=s.getCipherSuite(d.getBytes(2)),null===t.session.cipherSuite););if(null===t.session.cipherSuite)return t.error(t,{message:"No cipher suites in common.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.handshake_failure},cipherSuite:e.util.bytesToHex(a.cipher_suite)});t.session.compressionMethod=o?a.compression_method:s.CompressionMethod.none}return a},s.createSecurityParameters=function(e,t){var r=e.entity===s.ConnectionEnd.client,n=t.random.bytes(),i=r?e.session.sp.client_random:n,a=r?n:s.createRandom().getBytes();e.session.sp={entity:e.entity,prf_algorithm:s.PRFAlgorithm.tls_prf_sha256,bulk_cipher_algorithm:null,cipher_type:null,enc_key_length:null,block_length:null,fixed_iv_length:null,record_iv_length:null,mac_algorithm:null,mac_length:null,mac_key_length:null,compression_algorithm:e.session.compressionMethod,pre_master_secret:null,master_secret:null,client_random:i,server_random:a}},s.handleServerHello=function(e,t,r){var n=s.parseHelloMessage(e,t,r);if(!e.fail){if(!(n.version.minor<=e.version.minor))return e.error(e,{message:"Incompatible TLS version.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.protocol_version}});e.version.minor=n.version.minor,e.session.version=e.version;var i=n.session_id.bytes();i.length>0&&i===e.session.id?(e.expect=f,e.session.resuming=!0,e.session.sp.server_random=n.random.bytes()):(e.expect=o,e.session.resuming=!1,s.createSecurityParameters(e,n)),e.session.id=i,e.process()}},s.handleClientHello=function(t,r,n){var i=s.parseHelloMessage(t,r,n);if(!t.fail){var a=i.session_id.bytes(),o=null;if(t.sessionCache&&(null===(o=t.sessionCache.getSession(a))?a="":(o.version.major!==i.version.major||o.version.minor>i.version.minor)&&(o=null,a="")),0===a.length&&(a=e.random.getBytes(32)),t.session.id=a,t.session.clientHelloVersion=i.version,t.session.sp={},o)t.version=t.session.version=o.version,t.session.sp=o.sp;else{for(var c,u=1;u<s.SupportedVersions.length&&!((c=s.SupportedVersions[u]).minor<=i.version.minor);++u);t.version={major:c.major,minor:c.minor},t.session.version=t.version}null!==o?(t.expect=v,t.session.resuming=!0,t.session.sp.client_random=i.random.bytes()):(t.expect=!1!==t.verifyClient?g:y,t.session.resuming=!1,s.createSecurityParameters(t,i)),t.open=!0,s.queue(t,s.createRecord(t,{type:s.ContentType.handshake,data:s.createServerHello(t)})),t.session.resuming?(s.queue(t,s.createRecord(t,{type:s.ContentType.change_cipher_spec,data:s.createChangeCipherSpec()})),t.state.pending=s.createConnectionState(t),t.state.current.write=t.state.pending.write,s.queue(t,s.createRecord(t,{type:s.ContentType.handshake,data:s.createFinished(t)}))):(s.queue(t,s.createRecord(t,{type:s.ContentType.handshake,data:s.createCertificate(t)})),t.fail||(s.queue(t,s.createRecord(t,{type:s.ContentType.handshake,data:s.createServerKeyExchange(t)})),!1!==t.verifyClient&&s.queue(t,s.createRecord(t,{type:s.ContentType.handshake,data:s.createCertificateRequest(t)})),s.queue(t,s.createRecord(t,{type:s.ContentType.handshake,data:s.createServerHelloDone(t)})))),s.flush(t),t.process()}},s.handleCertificate=function(t,r,n){if(n<3)return t.error(t,{message:"Invalid Certificate message. Message too short.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.illegal_parameter}});var a,o,u=r.fragment,l={certificate_list:i(u,3)},f=[];try{for(;l.certificate_list.length()>0;)a=i(l.certificate_list,3),o=e.asn1.fromDer(a),a=e.pki.certificateFromAsn1(o,!0),f.push(a)}catch(h){return t.error(t,{message:"Could not parse certificate list.",cause:h,send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.bad_certificate}})}var p=t.entity===s.ConnectionEnd.client;!p&&!0!==t.verifyClient||0!==f.length?0===f.length?t.expect=p?c:y:(p?t.session.serverCertificate=f[0]:t.session.clientCertificate=f[0],s.verifyCertificateChain(t,f)&&(t.expect=p?c:y)):t.error(t,{message:p?"No server certificate provided.":"No client certificate provided.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.illegal_parameter}}),t.process()},s.handleServerKeyExchange=function(e,t,r){if(r>0)return e.error(e,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.unsupported_certificate}});e.expect=u,e.process()},s.handleClientKeyExchange=function(t,r,n){if(n<48)return t.error(t,{message:"Invalid key parameters. Only RSA is supported.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.unsupported_certificate}});var a=r.fragment,o={enc_pre_master_secret:i(a,2).getBytes()},c=null;if(t.getPrivateKey)try{c=t.getPrivateKey(t,t.session.serverCertificate),c=e.pki.privateKeyFromPem(c)}catch(f){t.error(t,{message:"Could not get private key.",cause:f,send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.internal_error}})}if(null===c)return t.error(t,{message:"No private key set.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.internal_error}});try{var u=t.session.sp;u.pre_master_secret=c.decrypt(o.enc_pre_master_secret);var l=t.session.clientHelloVersion;if(l.major!==u.pre_master_secret.charCodeAt(0)||l.minor!==u.pre_master_secret.charCodeAt(1))throw new Error("TLS version rollback attack detected.")}catch(f){u.pre_master_secret=e.random.getBytes(48)}t.expect=v,null!==t.session.clientCertificate&&(t.expect=m),t.process()},s.handleCertificateRequest=function(e,t,r){if(r<3)return e.error(e,{message:"Invalid CertificateRequest. Message too short.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.illegal_parameter}});var n=t.fragment,a={certificate_types:i(n,1),certificate_authorities:i(n,2)};e.session.certificateRequest=a,e.expect=l,e.process()},s.handleCertificateVerify=function(t,r,n){if(n<2)return t.error(t,{message:"Invalid CertificateVerify. Message too short.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.illegal_parameter}});var a=r.fragment;a.read-=4;var o=a.bytes();a.read+=4;var c={signature:i(a,2).getBytes()},u=e.util.createBuffer();u.putBuffer(t.session.md5.digest()),u.putBuffer(t.session.sha1.digest()),u=u.getBytes();try{if(!t.session.clientCertificate.publicKey.verify(u,c.signature,"NONE"))throw new Error("CertificateVerify signature does not match.");t.session.md5.update(o),t.session.sha1.update(o)}catch(l){return t.error(t,{message:"Bad signature in CertificateVerify.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.handshake_failure}})}t.expect=v,t.process()},s.handleServerHelloDone=function(t,r,n){if(n>0)return t.error(t,{message:"Invalid ServerHelloDone message. Invalid length.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.record_overflow}});if(null===t.serverCertificate){var i={message:"No server certificate provided. Not enough security.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.insufficient_security}},a=t.verify(t,i.alert.description,0,[]);if(!0!==a)return(a||0===a)&&("object"!=typeof a||e.util.isArray(a)?"number"==typeof a&&(i.alert.description=a):(a.message&&(i.message=a.message),a.alert&&(i.alert.description=a.alert))),t.error(t,i)}null!==t.session.certificateRequest&&(r=s.createRecord(t,{type:s.ContentType.handshake,data:s.createCertificate(t)}),s.queue(t,r)),r=s.createRecord(t,{type:s.ContentType.handshake,data:s.createClientKeyExchange(t)}),s.queue(t,r),t.expect=d;var o=function(e,t){null!==e.session.certificateRequest&&null!==e.session.clientCertificate&&s.queue(e,s.createRecord(e,{type:s.ContentType.handshake,data:s.createCertificateVerify(e,t)})),s.queue(e,s.createRecord(e,{type:s.ContentType.change_cipher_spec,data:s.createChangeCipherSpec()})),e.state.pending=s.createConnectionState(e),e.state.current.write=e.state.pending.write,s.queue(e,s.createRecord(e,{type:s.ContentType.handshake,data:s.createFinished(e)})),e.expect=f,s.flush(e),e.process()};if(null===t.session.certificateRequest||null===t.session.clientCertificate)return o(t,null);s.getClientSignature(t,o)},s.handleChangeCipherSpec=function(e,t){if(1!==t.fragment.getByte())return e.error(e,{message:"Invalid ChangeCipherSpec message received.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.illegal_parameter}});var r=e.entity===s.ConnectionEnd.client;(e.session.resuming&&r||!e.session.resuming&&!r)&&(e.state.pending=s.createConnectionState(e)),e.state.current.read=e.state.pending.read,(!e.session.resuming&&r||e.session.resuming&&!r)&&(e.state.pending=null),e.expect=r?p:C,e.process()},s.handleFinished=function(r,n,i){var a=n.fragment;a.read-=4;var o=a.bytes();a.read+=4;var c=n.fragment.getBytes();(a=e.util.createBuffer()).putBuffer(r.session.md5.digest()),a.putBuffer(r.session.sha1.digest());var u=r.entity===s.ConnectionEnd.client,l=u?"server finished":"client finished",f=r.session.sp;if((a=t(f.master_secret,l,a.getBytes(),12)).getBytes()!==c)return r.error(r,{message:"Invalid verify_data in Finished message.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.decrypt_error}});r.session.md5.update(o),r.session.sha1.update(o),(r.session.resuming&&u||!r.session.resuming&&!u)&&(s.queue(r,s.createRecord(r,{type:s.ContentType.change_cipher_spec,data:s.createChangeCipherSpec()})),r.state.current.write=r.state.pending.write,r.state.pending=null,s.queue(r,s.createRecord(r,{type:s.ContentType.handshake,data:s.createFinished(r)}))),r.expect=u?h:E,r.handshaking=!1,++r.handshakes,r.peerCertificate=u?r.session.serverCertificate:r.session.clientCertificate,s.flush(r),r.isConnected=!0,r.connected(r),r.process()},s.handleAlert=function(e,t){var r,n=t.fragment,i={level:n.getByte(),description:n.getByte()};switch(i.description){case s.Alert.Description.close_notify:r="Connection closed.";break;case s.Alert.Description.unexpected_message:r="Unexpected message.";break;case s.Alert.Description.bad_record_mac:r="Bad record MAC.";break;case s.Alert.Description.decryption_failed:r="Decryption failed.";break;case s.Alert.Description.record_overflow:r="Record overflow.";break;case s.Alert.Description.decompression_failure:r="Decompression failed.";break;case s.Alert.Description.handshake_failure:r="Handshake failure.";break;case s.Alert.Description.bad_certificate:r="Bad certificate.";break;case s.Alert.Description.unsupported_certificate:r="Unsupported certificate.";break;case s.Alert.Description.certificate_revoked:r="Certificate revoked.";break;case s.Alert.Description.certificate_expired:r="Certificate expired.";break;case s.Alert.Description.certificate_unknown:r="Certificate unknown.";break;case s.Alert.Description.illegal_parameter:r="Illegal parameter.";break;case s.Alert.Description.unknown_ca:r="Unknown certificate authority.";break;case s.Alert.Description.access_denied:r="Access denied.";break;case s.Alert.Description.decode_error:r="Decode error.";break;case s.Alert.Description.decrypt_error:r="Decrypt error.";break;case s.Alert.Description.export_restriction:r="Export restriction.";break;case s.Alert.Description.protocol_version:r="Unsupported protocol version.";break;case s.Alert.Description.insufficient_security:r="Insufficient security.";break;case s.Alert.Description.internal_error:r="Internal error.";break;case s.Alert.Description.user_canceled:r="User canceled.";break;case s.Alert.Description.no_renegotiation:r="Renegotiation not supported.";break;default:r="Unknown error."}if(i.description===s.Alert.Description.close_notify)return e.close();e.error(e,{message:r,send:!1,origin:e.entity===s.ConnectionEnd.client?"server":"client",alert:i}),e.process()},s.handleHandshake=function(t,r){var n=r.fragment,i=n.getByte(),a=n.getInt24();if(a>n.length())return t.fragmented=r,r.fragment=e.util.createBuffer(),n.read-=4,t.process();t.fragmented=null,n.read-=4;var o=n.bytes(a+4);n.read+=4,i in O[t.entity][t.expect]?(t.entity!==s.ConnectionEnd.server||t.open||t.fail||(t.handshaking=!0,t.session={version:null,extensions:{server_name:{serverNameList:[]}},cipherSuite:null,compressionMethod:null,serverCertificate:null,clientCertificate:null,md5:e.md.md5.create(),sha1:e.md.sha1.create()}),i!==s.HandshakeType.hello_request&&i!==s.HandshakeType.certificate_verify&&i!==s.HandshakeType.finished&&(t.session.md5.update(o),t.session.sha1.update(o)),O[t.entity][t.expect][i](t,r,a)):s.handleUnexpected(t,r)},s.handleApplicationData=function(e,t){e.data.putBuffer(t.fragment),e.dataReady(e),e.process()},s.handleHeartbeat=function(t,r){var n=r.fragment,i=n.getByte(),a=n.getInt16(),o=n.getBytes(a);if(i===s.HeartbeatMessageType.heartbeat_request){if(t.handshaking||a>o.length)return t.process();s.queue(t,s.createRecord(t,{type:s.ContentType.heartbeat,data:s.createHeartbeat(s.HeartbeatMessageType.heartbeat_response,o)})),s.flush(t)}else if(i===s.HeartbeatMessageType.heartbeat_response){if(o!==t.expectedHeartbeatPayload)return t.process();t.heartbeatReceived&&t.heartbeatReceived(t,e.util.createBuffer(o))}t.process()};var o=1,c=2,u=3,l=4,f=5,p=6,h=7,d=8,g=1,y=2,m=3,v=4,C=5,E=6,S=s.handleUnexpected,T=s.handleChangeCipherSpec,b=s.handleAlert,A=s.handleHandshake,I=s.handleApplicationData,B=s.handleHeartbeat,w=[];w[s.ConnectionEnd.client]=[[S,b,A,S,B],[S,b,A,S,B],[S,b,A,S,B],[S,b,A,S,B],[S,b,A,S,B],[T,b,S,S,B],[S,b,A,S,B],[S,b,A,I,B],[S,b,A,S,B]],w[s.ConnectionEnd.server]=[[S,b,A,S,B],[S,b,A,S,B],[S,b,A,S,B],[S,b,A,S,B],[T,b,S,S,B],[S,b,A,S,B],[S,b,A,I,B],[S,b,A,S,B]];var N=s.handleHelloRequest,_=s.handleServerHello,R=s.handleCertificate,k=s.handleServerKeyExchange,L=s.handleCertificateRequest,U=s.handleServerHelloDone,D=s.handleFinished,O=[];O[s.ConnectionEnd.client]=[[S,S,_,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,R,k,L,U,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,S,k,L,U,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,S,S,L,U,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,S,S,S,U,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,D],[N,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S],[N,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S]];var P=s.handleClientHello,x=s.handleClientKeyExchange,V=s.handleCertificateVerify;O[s.ConnectionEnd.server]=[[S,P,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S],[S,S,S,S,S,S,S,S,S,S,S,R,S,S,S,S,S,S,S,S,S],[S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,x,S,S,S,S],[S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,V,S,S,S,S,S],[S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S],[S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,D],[S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S],[S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S,S]],s.generateKeys=function(e,r){var n=t,i=r.client_random+r.server_random;e.session.resuming||(r.master_secret=n(r.pre_master_secret,"master secret",i,48).bytes(),r.pre_master_secret=null),i=r.server_random+r.client_random;var a=2*r.mac_key_length+2*r.enc_key_length,o=e.version.major===s.Versions.TLS_1_0.major&&e.version.minor===s.Versions.TLS_1_0.minor;o&&(a+=2*r.fixed_iv_length);var c=n(r.master_secret,"key expansion",i,a),u={client_write_MAC_key:c.getBytes(r.mac_key_length),server_write_MAC_key:c.getBytes(r.mac_key_length),client_write_key:c.getBytes(r.enc_key_length),server_write_key:c.getBytes(r.enc_key_length)};return o&&(u.client_write_IV=c.getBytes(r.fixed_iv_length),u.server_write_IV=c.getBytes(r.fixed_iv_length)),u},s.createConnectionState=function(e){var t=e.entity===s.ConnectionEnd.client,i=function(){var e={sequenceNumber:[0,0],macKey:null,macLength:0,macFunction:null,cipherState:null,cipherFunction:function(e){return!0},compressionState:null,compressFunction:function(e){return!0},updateSequenceNumber:function(){4294967295===e.sequenceNumber[1]?(e.sequenceNumber[1]=0,++e.sequenceNumber[0]):++e.sequenceNumber[1]}};return e},a={read:i(),write:i()};if(a.read.update=function(e,t){return a.read.cipherFunction(t,a.read)?a.read.compressFunction(e,t,a.read)||e.error(e,{message:"Could not decompress record.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.decompression_failure}}):e.error(e,{message:"Could not decrypt record or bad MAC.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.bad_record_mac}}),!e.fail},a.write.update=function(e,t){return a.write.compressFunction(e,t,a.write)?a.write.cipherFunction(t,a.write)||e.error(e,{message:"Could not encrypt record.",send:!1,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.internal_error}}):e.error(e,{message:"Could not compress record.",send:!1,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.internal_error}}),!e.fail},e.session){var o=e.session.sp;switch(e.session.cipherSuite.initSecurityParameters(o),o.keys=s.generateKeys(e,o),a.read.macKey=t?o.keys.server_write_MAC_key:o.keys.client_write_MAC_key,a.write.macKey=t?o.keys.client_write_MAC_key:o.keys.server_write_MAC_key,e.session.cipherSuite.initConnectionState(a,e,o),o.compression_algorithm){case s.CompressionMethod.none:break;case s.CompressionMethod.deflate:a.read.compressFunction=n,a.write.compressFunction=r;break;default:throw new Error("Unsupported compression algorithm.")}}return a},s.createRandom=function(){var t=new Date,r=+t+6e4*t.getTimezoneOffset(),n=e.util.createBuffer();return n.putInt32(r),n.putBytes(e.random.getBytes(28)),n},s.createRecord=function(e,t){return t.data?{type:t.type,version:{major:e.version.major,minor:e.version.minor},length:t.data.length(),fragment:t.data}:null},s.createAlert=function(t,r){var n=e.util.createBuffer();return n.putByte(r.level),n.putByte(r.description),s.createRecord(t,{type:s.ContentType.alert,data:n})},s.createClientHello=function(t){t.session.clientHelloVersion={major:t.version.major,minor:t.version.minor};for(var r=e.util.createBuffer(),n=0;n<t.cipherSuites.length;++n){var i=t.cipherSuites[n];r.putByte(i.id[0]),r.putByte(i.id[1])}var o=r.length(),c=e.util.createBuffer();c.putByte(s.CompressionMethod.none);var u=c.length(),l=e.util.createBuffer();if(t.virtualHost){var f=e.util.createBuffer();f.putByte(0),f.putByte(0);var p=e.util.createBuffer();p.putByte(0),a(p,2,e.util.createBuffer(t.virtualHost));var h=e.util.createBuffer();a(h,2,p),a(f,2,h),l.putBuffer(f)}var d=l.length();d>0&&(d+=2);var g=t.session.id,y=g.length+1+2+4+28+2+o+1+u+d,m=e.util.createBuffer();return m.putByte(s.HandshakeType.client_hello),m.putInt24(y),m.putByte(t.version.major),m.putByte(t.version.minor),m.putBytes(t.session.sp.client_random),a(m,1,e.util.createBuffer(g)),a(m,2,r),a(m,1,c),d>0&&a(m,2,l),m},s.createServerHello=function(t){var r=t.session.id,n=r.length+1+2+4+28+2+1,i=e.util.createBuffer();return i.putByte(s.HandshakeType.server_hello),i.putInt24(n),i.putByte(t.version.major),i.putByte(t.version.minor),i.putBytes(t.session.sp.server_random),a(i,1,e.util.createBuffer(r)),i.putByte(t.session.cipherSuite.id[0]),i.putByte(t.session.cipherSuite.id[1]),i.putByte(t.session.compressionMethod),i},s.createCertificate=function(t){var r,n=t.entity===s.ConnectionEnd.client,i=null;t.getCertificate&&(r=n?t.session.certificateRequest:t.session.extensions.server_name.serverNameList,i=t.getCertificate(t,r));var o=e.util.createBuffer();if(null!==i)try{e.util.isArray(i)||(i=[i]);for(var c=null,u=0;u<i.length;++u){var l=e.pem.decode(i[u])[0];if("CERTIFICATE"!==l.type&&"X509 CERTIFICATE"!==l.type&&"TRUSTED CERTIFICATE"!==l.type){var f=new Error('Could not convert certificate from PEM; PEM header type is not "CERTIFICATE", "X509 CERTIFICATE", or "TRUSTED CERTIFICATE".');throw f.headerType=l.type,f}if(l.procType&&"ENCRYPTED"===l.procType.type)throw new Error("Could not convert certificate from PEM; PEM is encrypted.");var p=e.util.createBuffer(l.body);null===c&&(c=e.asn1.fromDer(p.bytes(),!1));var h=e.util.createBuffer();a(h,3,p),o.putBuffer(h)}i=e.pki.certificateFromAsn1(c),n?t.session.clientCertificate=i:t.session.serverCertificate=i}catch(y){return t.error(t,{message:"Could not send certificate list.",cause:y,send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.bad_certificate}})}var d=3+o.length(),g=e.util.createBuffer();return g.putByte(s.HandshakeType.certificate),g.putInt24(d),a(g,3,o),g},s.createClientKeyExchange=function(t){var r=e.util.createBuffer();r.putByte(t.session.clientHelloVersion.major),r.putByte(t.session.clientHelloVersion.minor),r.putBytes(e.random.getBytes(46));var n=t.session.sp;n.pre_master_secret=r.getBytes();var i=(r=t.session.serverCertificate.publicKey.encrypt(n.pre_master_secret)).length+2,a=e.util.createBuffer();return a.putByte(s.HandshakeType.client_key_exchange),a.putInt24(i),a.putInt16(r.length),a.putBytes(r),a},s.createServerKeyExchange=function(t){return e.util.createBuffer()},s.getClientSignature=function(t,r){var n=e.util.createBuffer();n.putBuffer(t.session.md5.digest()),n.putBuffer(t.session.sha1.digest()),n=n.getBytes(),t.getSignature=t.getSignature||function(t,r,n){var i=null;if(t.getPrivateKey)try{i=t.getPrivateKey(t,t.session.clientCertificate),i=e.pki.privateKeyFromPem(i)}catch(a){t.error(t,{message:"Could not get private key.",cause:a,send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.internal_error}})}null===i?t.error(t,{message:"No private key set.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.internal_error}}):r=i.sign(r,null),n(t,r)},t.getSignature(t,n,r)},s.createCertificateVerify=function(t,r){var n=r.length+2,i=e.util.createBuffer();return i.putByte(s.HandshakeType.certificate_verify),i.putInt24(n),i.putInt16(r.length),i.putBytes(r),i},s.createCertificateRequest=function(t){var r=e.util.createBuffer();r.putByte(1);var n=e.util.createBuffer();for(var i in t.caStore.certs){var o=t.caStore.certs[i],c=e.pki.distinguishedNameToAsn1(o.subject),u=e.asn1.toDer(c);n.putInt16(u.length()),n.putBuffer(u)}var l=1+r.length()+2+n.length(),f=e.util.createBuffer();return f.putByte(s.HandshakeType.certificate_request),f.putInt24(l),a(f,1,r),a(f,2,n),f},s.createServerHelloDone=function(t){var r=e.util.createBuffer();return r.putByte(s.HandshakeType.server_hello_done),r.putInt24(0),r},s.createChangeCipherSpec=function(){var t=e.util.createBuffer();return t.putByte(1),t},s.createFinished=function(r){var n=e.util.createBuffer();n.putBuffer(r.session.md5.digest()),n.putBuffer(r.session.sha1.digest());var i=r.entity===s.ConnectionEnd.client,a=r.session.sp,o=i?"client finished":"server finished";n=t(a.master_secret,o,n.getBytes(),12);var c=e.util.createBuffer();return c.putByte(s.HandshakeType.finished),c.putInt24(n.length()),c.putBuffer(n),c},s.createHeartbeat=function(t,r,n){void 0===n&&(n=r.length);var i=e.util.createBuffer();i.putByte(t),i.putInt16(n),i.putBytes(r);var a=i.length(),s=Math.max(16,a-n-3);return i.putBytes(e.random.getBytes(s)),i},s.queue=function(t,r){if(r&&(0!==r.fragment.length()||r.type!==s.ContentType.handshake&&r.type!==s.ContentType.alert&&r.type!==s.ContentType.change_cipher_spec)){if(r.type===s.ContentType.handshake){var n=r.fragment.bytes();t.session.md5.update(n),t.session.sha1.update(n),n=null}var i;if(r.fragment.length()<=s.MaxFragment)i=[r];else{i=[];for(var a=r.fragment.bytes();a.length>s.MaxFragment;)i.push(s.createRecord(t,{type:r.type,data:e.util.createBuffer(a.slice(0,s.MaxFragment))})),a=a.slice(s.MaxFragment);a.length>0&&i.push(s.createRecord(t,{type:r.type,data:e.util.createBuffer(a)}))}for(var o=0;o<i.length&&!t.fail;++o){var c=i[o];t.state.current.write.update(t,c)&&t.records.push(c)}}},s.flush=function(e){for(var t=0;t<e.records.length;++t){var r=e.records[t];e.tlsData.putByte(r.type),e.tlsData.putByte(r.version.major),e.tlsData.putByte(r.version.minor),e.tlsData.putInt16(r.fragment.length()),e.tlsData.putBuffer(e.records[t].fragment)}return e.records=[],e.tlsDataReady(e)};var K=function(t){switch(t){case!0:return!0;case e.pki.certificateError.bad_certificate:return s.Alert.Description.bad_certificate;case e.pki.certificateError.unsupported_certificate:return s.Alert.Description.unsupported_certificate;case e.pki.certificateError.certificate_revoked:return s.Alert.Description.certificate_revoked;case e.pki.certificateError.certificate_expired:return s.Alert.Description.certificate_expired;case e.pki.certificateError.certificate_unknown:return s.Alert.Description.certificate_unknown;case e.pki.certificateError.unknown_ca:return s.Alert.Description.unknown_ca;default:return s.Alert.Description.bad_certificate}};for(var M in s.verifyCertificateChain=function(t,r){try{var n={};for(var i in t.verifyOptions)n[i]=t.verifyOptions[i];n.verify=function(r,n,i){K(r);var a=t.verify(t,r,n,i);if(!0!==a){if("object"==typeof a&&!e.util.isArray(a)){var o=new Error("The application rejected the certificate.");throw o.send=!0,o.alert={level:s.Alert.Level.fatal,description:s.Alert.Description.bad_certificate},a.message&&(o.message=a.message),a.alert&&(o.alert.description=a.alert),o}a!==r&&(a=function(t){switch(t){case!0:return!0;case s.Alert.Description.bad_certificate:return e.pki.certificateError.bad_certificate;case s.Alert.Description.unsupported_certificate:return e.pki.certificateError.unsupported_certificate;case s.Alert.Description.certificate_revoked:return e.pki.certificateError.certificate_revoked;case s.Alert.Description.certificate_expired:return e.pki.certificateError.certificate_expired;case s.Alert.Description.certificate_unknown:return e.pki.certificateError.certificate_unknown;case s.Alert.Description.unknown_ca:return e.pki.certificateError.unknown_ca;default:return e.pki.certificateError.bad_certificate}}(a))}return a},e.pki.verifyCertificateChain(t.caStore,r,n)}catch(o){var a=o;("object"!=typeof a||e.util.isArray(a))&&(a={send:!0,alert:{level:s.Alert.Level.fatal,description:K(o)}}),"send"in a||(a.send=!0),"alert"in a||(a.alert={level:s.Alert.Level.fatal,description:K(a.error)}),t.error(t,a)}return!t.fail},s.createSessionCache=function(t,r){var n=null;if(t&&t.getSession&&t.setSession&&t.order)n=t;else{for(var i in(n={}).cache=t||{},n.capacity=Math.max(r||100,1),n.order=[],t)n.order.length<=r?n.order.push(i):delete t[i];n.getSession=function(t){var r=null,i=null;if(t?i=e.util.bytesToHex(t):n.order.length>0&&(i=n.order[0]),null!==i&&i in n.cache)for(var a in r=n.cache[i],delete n.cache[i],n.order)if(n.order[a]===i){n.order.splice(a,1);break}return r},n.setSession=function(t,r){if(n.order.length===n.capacity){var i=n.order.shift();delete n.cache[i]}i=e.util.bytesToHex(t);n.order.push(i),n.cache[i]=r}}return n},s.createConnection=function(t){var r=null;r=t.caStore?e.util.isArray(t.caStore)?e.pki.createCaStore(t.caStore):t.caStore:e.pki.createCaStore();var n=t.cipherSuites||null;if(null===n)for(var i in n=[],s.CipherSuites)n.push(s.CipherSuites[i]);var a=t.server?s.ConnectionEnd.server:s.ConnectionEnd.client,o=t.sessionCache?s.createSessionCache(t.sessionCache):null,c={version:{major:s.Version.major,minor:s.Version.minor},entity:a,sessionId:t.sessionId,caStore:r,sessionCache:o,cipherSuites:n,connected:t.connected,virtualHost:t.virtualHost||null,verifyClient:t.verifyClient||!1,verify:t.verify||function(e,t,r,n){return t},verifyOptions:t.verifyOptions||{},getCertificate:t.getCertificate||null,getPrivateKey:t.getPrivateKey||null,getSignature:t.getSignature||null,input:e.util.createBuffer(),tlsData:e.util.createBuffer(),data:e.util.createBuffer(),tlsDataReady:t.tlsDataReady,dataReady:t.dataReady,heartbeatReceived:t.heartbeatReceived,closed:t.closed,error:function(e,r){r.origin=r.origin||(e.entity===s.ConnectionEnd.client?"client":"server"),r.send&&(s.queue(e,s.createAlert(e,r.alert)),s.flush(e));var n=!1!==r.fatal;n&&(e.fail=!0),t.error(e,r),n&&e.close(!1)},deflate:t.deflate||null,inflate:t.inflate||null,reset:function(e){c.version={major:s.Version.major,minor:s.Version.minor},c.record=null,c.session=null,c.peerCertificate=null,c.state={pending:null,current:null},c.expect=(c.entity,s.ConnectionEnd.client,0),c.fragmented=null,c.records=[],c.open=!1,c.handshakes=0,c.handshaking=!1,c.isConnected=!1,c.fail=!(e||void 0===e),c.input.clear(),c.tlsData.clear(),c.data.clear(),c.state.current=s.createConnectionState(c)}};c.reset();return c.handshake=function(t){if(c.entity!==s.ConnectionEnd.client)c.error(c,{message:"Cannot initiate handshake as a server.",fatal:!1});else if(c.handshaking)c.error(c,{message:"Handshake already in progress.",fatal:!1});else{c.fail&&!c.open&&0===c.handshakes&&(c.fail=!1),c.handshaking=!0;var r=null;(t=t||"").length>0&&(c.sessionCache&&(r=c.sessionCache.getSession(t)),null===r&&(t="")),0===t.length&&c.sessionCache&&null!==(r=c.sessionCache.getSession())&&(t=r.id),c.session={id:t,version:null,cipherSuite:null,compressionMethod:null,serverCertificate:null,certificateRequest:null,clientCertificate:null,sp:{},md5:e.md.md5.create(),sha1:e.md.sha1.create()},r&&(c.version=r.version,c.session.sp=r.sp),c.session.sp.client_random=s.createRandom().getBytes(),c.open=!0,s.queue(c,s.createRecord(c,{type:s.ContentType.handshake,data:s.createClientHello(c)})),s.flush(c)}},c.process=function(t){var r,n,i,a,o=0;return t&&c.input.putBytes(t),c.fail||(null!==c.record&&c.record.ready&&c.record.fragment.isEmpty()&&(c.record=null),null===c.record&&(o=function(t){var r=0,n=t.input,i=n.length();if(i<5)r=5-i;else{t.record={type:n.getByte(),version:{major:n.getByte(),minor:n.getByte()},length:n.getInt16(),fragment:e.util.createBuffer(),ready:!1};var a=t.record.version.major===t.version.major;a&&t.session&&t.session.version&&(a=t.record.version.minor===t.version.minor),a||t.error(t,{message:"Incompatible TLS version.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.protocol_version}})}return r}(c)),c.fail||null===c.record||c.record.ready||(o=function(e){var t=0,r=e.input,n=r.length();return n<e.record.length?t=e.record.length-n:(e.record.fragment.putBytes(r.getBytes(e.record.length)),r.compact(),e.state.current.read.update(e,e.record)&&(null!==e.fragmented&&(e.fragmented.type===e.record.type?(e.fragmented.fragment.putBuffer(e.record.fragment),e.record=e.fragmented):e.error(e,{message:"Invalid fragmented record.",send:!0,alert:{level:s.Alert.Level.fatal,description:s.Alert.Description.unexpected_message}})),e.record.ready=!0)),t}(c)),!c.fail&&null!==c.record&&c.record.ready&&(r=c,n=c.record,i=n.type-s.ContentType.change_cipher_spec,a=w[r.entity][r.expect],i in a?a[i](r,n):s.handleUnexpected(r,n))),o},c.prepare=function(t){return s.queue(c,s.createRecord(c,{type:s.ContentType.application_data,data:e.util.createBuffer(t)})),s.flush(c)},c.prepareHeartbeatRequest=function(t,r){return t instanceof e.util.ByteBuffer&&(t=t.bytes()),void 0===r&&(r=t.length),c.expectedHeartbeatPayload=t,s.queue(c,s.createRecord(c,{type:s.ContentType.heartbeat,data:s.createHeartbeat(s.HeartbeatMessageType.heartbeat_request,t,r)})),s.flush(c)},c.close=function(e){if(!c.fail&&c.sessionCache&&c.session){var t={id:c.session.id,version:c.session.version,sp:c.session.sp};t.sp.keys=null,c.sessionCache.setSession(t.id,t)}c.open&&(c.open=!1,c.input.clear(),(c.isConnected||c.handshaking)&&(c.isConnected=c.handshaking=!1,s.queue(c,s.createAlert(c,{level:s.Alert.Level.warning,description:s.Alert.Description.close_notify})),s.flush(c)),c.closed(c)),c.reset(e)},c},In=e.tls=e.tls||{},s)"function"!=typeof s[M]&&(e.tls[M]=s[M]);return e.tls.prf_tls1=t,e.tls.hmac_sha1=function(t,r,n){var i=e.hmac.create();i.start("SHA1",t);var a=e.util.createBuffer();return a.putInt32(r[0]),a.putInt32(r[1]),a.putByte(n.type),a.putByte(n.version.major),a.putByte(n.version.minor),a.putInt16(n.length),a.putBytes(n.fragment.bytes()),i.update(a.getBytes()),i.digest().getBytes()},e.tls.createSessionCache=s.createSessionCache,e.tls.createConnection=s.createConnection,In}function Dn(){if(wn)return ur.exports;wn=1;var e=zt();sr(),Un();var t=ur.exports=e.tls;function r(r,i,a){var o=i.entity===e.tls.ConnectionEnd.client;r.read.cipherState={init:!1,cipher:e.cipher.createDecipher("AES-CBC",o?a.keys.server_write_key:a.keys.client_write_key),iv:o?a.keys.server_write_IV:a.keys.client_write_IV},r.write.cipherState={init:!1,cipher:e.cipher.createCipher("AES-CBC",o?a.keys.client_write_key:a.keys.server_write_key),iv:o?a.keys.client_write_IV:a.keys.server_write_IV},r.read.cipherFunction=s,r.write.cipherFunction=n,r.read.macLength=r.write.macLength=a.mac_length,r.read.macFunction=r.write.macFunction=t.hmac_sha1}function n(r,n){var a,s=!1,o=n.macFunction(n.macKey,n.sequenceNumber,r);r.fragment.putBytes(o),n.updateSequenceNumber(),a=r.version.minor===t.Versions.TLS_1_0.minor?n.cipherState.init?null:n.cipherState.iv:e.random.getBytesSync(16),n.cipherState.init=!0;var c=n.cipherState.cipher;return c.start({iv:a}),r.version.minor>=t.Versions.TLS_1_1.minor&&c.output.putBytes(a),c.update(r.fragment),c.finish(i)&&(r.fragment=c.output,r.length=r.fragment.length(),s=!0),s}function i(e,t,r){if(!r){var n=e-t.length()%e;t.fillWithByte(n-1,n)}return!0}function a(e,t,r){var n=!0;if(r){for(var i=t.length(),a=t.last(),s=i-1-a;s<i-1;++s)n=n&&t.at(s)==a;n&&t.truncate(a+1)}return n}function s(r,n){var i,s=!1;i=r.version.minor===t.Versions.TLS_1_0.minor?n.cipherState.init?null:n.cipherState.iv:r.fragment.getBytes(16),n.cipherState.init=!0;var o=n.cipherState.cipher;o.start({iv:i}),o.update(r.fragment),s=o.finish(a);var c=n.macLength,u=e.random.getBytesSync(c),l=o.output.length();l>=c?(r.fragment=o.output.getBytes(l-c),u=o.output.getBytes(c)):r.fragment=o.output.getBytes(),r.fragment=e.util.createBuffer(r.fragment),r.length=r.fragment.length();var f=n.macFunction(n.macKey,n.sequenceNumber,r);return n.updateSequenceNumber(),s=function(t,r,n){var i=e.hmac.create();return i.start("SHA1",t),i.update(r),r=i.digest().getBytes(),i.start(null,null),i.update(n),n=i.digest().getBytes(),r===n}(n.macKey,u,f)&&s,s}return t.CipherSuites.TLS_RSA_WITH_AES_128_CBC_SHA={id:[0,47],name:"TLS_RSA_WITH_AES_128_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=16,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r},t.CipherSuites.TLS_RSA_WITH_AES_256_CBC_SHA={id:[0,53],name:"TLS_RSA_WITH_AES_256_CBC_SHA",initSecurityParameters:function(e){e.bulk_cipher_algorithm=t.BulkCipherAlgorithm.aes,e.cipher_type=t.CipherType.block,e.enc_key_length=32,e.block_length=16,e.fixed_iv_length=16,e.record_iv_length=16,e.mac_algorithm=t.MACAlgorithm.hmac_sha1,e.mac_length=20,e.mac_key_length=20},initConnectionState:r},ur.exports}var On,Pn={exports:{}};function xn(){if(On)return Pn.exports;On=1;var e=zt();vr(),Zt();var t=Pn.exports=e.sha512=e.sha512||{};e.md.sha512=e.md.algorithms.sha512=t;var r=e.sha384=e.sha512.sha384=e.sha512.sha384||{};r.create=function(){return t.create("SHA-384")},e.md.sha384=e.md.algorithms.sha384=r,e.sha512.sha256=e.sha512.sha256||{create:function(){return t.create("SHA-512/256")}},e.md["sha512/256"]=e.md.algorithms["sha512/256"]=e.sha512.sha256,e.sha512.sha224=e.sha512.sha224||{create:function(){return t.create("SHA-512/224")}},e.md["sha512/224"]=e.md.algorithms["sha512/224"]=e.sha512.sha224,t.create=function(t){if(i||(n=String.fromCharCode(128),n+=e.util.fillString(String.fromCharCode(0),128),a=[[1116352408,3609767458],[1899447441,602891725],[3049323471,3964484399],[3921009573,2173295548],[961987163,4081628472],[1508970993,3053834265],[2453635748,2937671579],[2870763221,3664609560],[3624381080,2734883394],[310598401,1164996542],[607225278,1323610764],[1426881987,3590304994],[1925078388,4068182383],[2162078206,991336113],[2614888103,633803317],[3248222580,3479774868],[3835390401,2666613458],[4022224774,944711139],[264347078,2341262773],[604807628,2007800933],[770255983,1495990901],[1249150122,1856431235],[1555081692,3175218132],[1996064986,2198950837],[2554220882,3999719339],[2821834349,766784016],[2952996808,2566594879],[3210313671,3203337956],[3336571891,1034457026],[3584528711,2466948901],[113926993,3758326383],[338241895,168717936],[666307205,1188179964],[773529912,1546045734],[1294757372,1522805485],[1396182291,2643833823],[1695183700,2343527390],[1986661051,1014477480],[2177026350,1206759142],[2456956037,344077627],[2730485921,1290863460],[2820302411,3158454273],[3259730800,3505952657],[3345764771,106217008],[3516065817,3606008344],[3600352804,1432725776],[4094571909,1467031594],[275423344,851169720],[430227734,3100823752],[506948616,1363258195],[659060556,3750685593],[883997877,3785050280],[958139571,3318307427],[1322822218,3812723403],[1537002063,2003034995],[1747873779,3602036899],[1955562222,1575990012],[2024104815,1125592928],[2227730452,2716904306],[2361852424,442776044],[2428436474,593698344],[2756734187,3733110249],[3204031479,2999351573],[3329325298,3815920427],[3391569614,3928383900],[3515267271,566280711],[3940187606,3454069534],[4118630271,4000239992],[116418474,1914138554],[174292421,2731055270],[289380356,3203993006],[460393269,320620315],[685471733,587496836],[852142971,1086792851],[1017036298,365543100],[1126000580,2618297676],[1288033470,3409855158],[1501505948,4234509866],[1607167915,987167468],[1816402316,1246189591]],(s={})["SHA-512"]=[[1779033703,4089235720],[3144134277,2227873595],[1013904242,4271175723],[2773480762,1595750129],[1359893119,2917565137],[2600822924,725511199],[528734635,4215389547],[1541459225,327033209]],s["SHA-384"]=[[3418070365,3238371032],[1654270250,914150663],[2438529370,812702999],[355462360,4144912697],[1731405415,4290775857],[2394180231,1750603025],[3675008525,1694076839],[1203062813,3204075428]],s["SHA-512/256"]=[[573645204,4230739756],[2673172387,3360449730],[596883563,1867755857],[2520282905,1497426621],[2519219938,2827943907],[3193839141,1401305490],[721525244,746961066],[246885852,2177182882]],s["SHA-512/224"]=[[2352822216,424955298],[1944164710,2312950998],[502970286,855612546],[1738396948,1479516111],[258812777,2077511080],[2011393907,79989058],[1067287976,1780299464],[286451373,2446758561]],i=!0),void 0===t&&(t="SHA-512"),!(t in s))throw new Error("Invalid SHA-512 algorithm: "+t);for(var r=s[t],c=null,u=e.util.createBuffer(),l=new Array(80),f=0;f<80;++f)l[f]=new Array(2);var p=64;switch(t){case"SHA-384":p=48;break;case"SHA-512/256":p=32;break;case"SHA-512/224":p=28}var h={algorithm:t.replace("-","").toLowerCase(),blockLength:128,digestLength:p,messageLength:0,fullMessageLength:null,messageLengthSize:16,start:function(){h.messageLength=0,h.fullMessageLength=h.messageLength128=[];for(var t=h.messageLengthSize/4,n=0;n<t;++n)h.fullMessageLength.push(0);u=e.util.createBuffer(),c=new Array(r.length);for(n=0;n<r.length;++n)c[n]=r[n].slice(0);return h}};return h.start(),h.update=function(t,r){"utf8"===r&&(t=e.util.encodeUtf8(t));var n=t.length;h.messageLength+=n,n=[n/4294967296>>>0,n>>>0];for(var i=h.fullMessageLength.length-1;i>=0;--i)h.fullMessageLength[i]+=n[1],n[1]=n[0]+(h.fullMessageLength[i]/4294967296>>>0),h.fullMessageLength[i]=h.fullMessageLength[i]>>>0,n[0]=n[1]/4294967296>>>0;return u.putBytes(t),o(c,l,u),(u.read>2048||0===u.length())&&u.compact(),h},h.digest=function(){var r=e.util.createBuffer();r.putBytes(u.bytes());var i,a=h.fullMessageLength[h.fullMessageLength.length-1]+h.messageLengthSize&h.blockLength-1;r.putBytes(n.substr(0,h.blockLength-a));for(var s=8*h.fullMessageLength[0],f=0;f<h.fullMessageLength.length-1;++f)s+=(i=8*h.fullMessageLength[f+1])/4294967296>>>0,r.putInt32(s>>>0),s=i>>>0;r.putInt32(s);var p=new Array(c.length);for(f=0;f<c.length;++f)p[f]=c[f].slice(0);o(p,l,r);var d,g=e.util.createBuffer();d="SHA-512"===t?p.length:"SHA-384"===t?p.length-2:p.length-4;for(f=0;f<d;++f)g.putInt32(p[f][0]),f===d-1&&"SHA-512/224"===t||g.putInt32(p[f][1]);return g},h};var n=null,i=!1,a=null,s=null;function o(e,t,r){for(var n,i,s,o,c,u,l,f,p,h,d,g,y,m,v,C,E,S,T,b,A,I,B,w,N,_,R,k,L,U,D,O,P,x=r.length();x>=128;){for(R=0;R<16;++R)t[R][0]=r.getInt32()>>>0,t[R][1]=r.getInt32()>>>0;for(;R<80;++R)n=(((k=(U=t[R-2])[0])>>>19|(L=U[1])<<13)^(L>>>29|k<<3)^k>>>6)>>>0,i=((k<<13|L>>>19)^(L<<3|k>>>29)^(k<<26|L>>>6))>>>0,s=(((k=(O=t[R-15])[0])>>>1|(L=O[1])<<31)^(k>>>8|L<<24)^k>>>7)>>>0,o=((k<<31|L>>>1)^(k<<24|L>>>8)^(k<<25|L>>>7))>>>0,D=t[R-7],P=t[R-16],L=i+D[1]+o+P[1],t[R][0]=n+D[0]+s+P[0]+(L/4294967296>>>0)>>>0,t[R][1]=L>>>0;for(d=e[0][0],g=e[0][1],y=e[1][0],m=e[1][1],v=e[2][0],C=e[2][1],E=e[3][0],S=e[3][1],T=e[4][0],b=e[4][1],A=e[5][0],I=e[5][1],B=e[6][0],w=e[6][1],N=e[7][0],_=e[7][1],R=0;R<80;++R)l=((T>>>14|b<<18)^(T>>>18|b<<14)^(b>>>9|T<<23))>>>0,f=(B^T&(A^B))>>>0,c=((d>>>28|g<<4)^(g>>>2|d<<30)^(g>>>7|d<<25))>>>0,u=((d<<4|g>>>28)^(g<<30|d>>>2)^(g<<25|d>>>7))>>>0,p=(d&y|v&(d^y))>>>0,h=(g&m|C&(g^m))>>>0,L=_+(((T<<18|b>>>14)^(T<<14|b>>>18)^(b<<23|T>>>9))>>>0)+((w^b&(I^w))>>>0)+a[R][1]+t[R][1],n=N+l+f+a[R][0]+t[R][0]+(L/4294967296>>>0)>>>0,i=L>>>0,s=c+p+((L=u+h)/4294967296>>>0)>>>0,o=L>>>0,N=B,_=w,B=A,w=I,A=T,I=b,T=E+n+((L=S+i)/4294967296>>>0)>>>0,b=L>>>0,E=v,S=C,v=y,C=m,y=d,m=g,d=n+s+((L=i+o)/4294967296>>>0)>>>0,g=L>>>0;L=e[0][1]+g,e[0][0]=e[0][0]+d+(L/4294967296>>>0)>>>0,e[0][1]=L>>>0,L=e[1][1]+m,e[1][0]=e[1][0]+y+(L/4294967296>>>0)>>>0,e[1][1]=L>>>0,L=e[2][1]+C,e[2][0]=e[2][0]+v+(L/4294967296>>>0)>>>0,e[2][1]=L>>>0,L=e[3][1]+S,e[3][0]=e[3][0]+E+(L/4294967296>>>0)>>>0,e[3][1]=L>>>0,L=e[4][1]+b,e[4][0]=e[4][0]+T+(L/4294967296>>>0)>>>0,e[4][1]=L>>>0,L=e[5][1]+I,e[5][0]=e[5][0]+A+(L/4294967296>>>0)>>>0,e[5][1]=L>>>0,L=e[6][1]+w,e[6][0]=e[6][0]+B+(L/4294967296>>>0)>>>0,e[6][1]=L>>>0,L=e[7][1]+_,e[7][0]=e[7][0]+N+(L/4294967296>>>0)>>>0,e[7][1]=L>>>0,x-=128}}return Pn.exports}var Vn,Kn,Mn,Fn,jn,qn,Hn,Gn,zn={};function Qn(){if(Mn)return Kn;Mn=1;var e=zt();Wr(),zr(),xn(),Zt();var t=function(){if(Vn)return zn;Vn=1;var e=zt();hr();var t=e.asn1;return zn.privateKeyValidator={name:"PrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"PrivateKeyInfo.version",tagClass:t.Class.UNIVERSAL,type:t.Type.INTEGER,constructed:!1,capture:"privateKeyVersion"},{name:"PrivateKeyInfo.privateKeyAlgorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"privateKeyOid"}]},{name:"PrivateKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.OCTETSTRING,constructed:!1,capture:"privateKey"}]},zn.publicKeyValidator={name:"SubjectPublicKeyInfo",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,captureAsn1:"subjectPublicKeyInfo",value:[{name:"SubjectPublicKeyInfo.AlgorithmIdentifier",tagClass:t.Class.UNIVERSAL,type:t.Type.SEQUENCE,constructed:!0,value:[{name:"AlgorithmIdentifier.algorithm",tagClass:t.Class.UNIVERSAL,type:t.Type.OID,constructed:!1,capture:"publicKeyOid"}]},{tagClass:t.Class.UNIVERSAL,type:t.Type.BITSTRING,constructed:!1,composed:!0,captureBitStringValue:"ed25519PublicKey"}]},zn}(),r=t.publicKeyValidator,n=t.privateKeyValidator;if(void 0===i)var i=e.jsbn.BigInteger;var a=e.util.ByteBuffer,s="undefined"==typeof Buffer?Uint8Array:Buffer;e.pki=e.pki||{},Kn=e.pki.ed25519=e.ed25519=e.ed25519||{};var o=e.ed25519;function c(e){var t=e.message;if(t instanceof Uint8Array||t instanceof s)return t;var r=e.encoding;if(void 0===t){if(!e.md)throw new TypeError('"options.message" or "options.md" not specified.');t=e.md.digest().getBytes(),r="binary"}if("string"==typeof t&&!r)throw new TypeError('"options.encoding" must be "binary" or "utf8".');if("string"==typeof t){if("undefined"!=typeof Buffer)return Buffer.from(t,r);t=new a(t,r)}else if(!(t instanceof a))throw new TypeError('"options.message" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a string with "options.encoding" specifying its encoding.');for(var n=new s(t.length()),i=0;i<n.length;++i)n[i]=t.at(i);return n}o.constants={},o.constants.PUBLIC_KEY_BYTE_LENGTH=32,o.constants.PRIVATE_KEY_BYTE_LENGTH=64,o.constants.SEED_BYTE_LENGTH=32,o.constants.SIGN_BYTE_LENGTH=64,o.constants.HASH_BYTE_LENGTH=64,o.generateKeyPair=function(t){var r=(t=t||{}).seed;if(void 0===r)r=e.random.getBytesSync(o.constants.SEED_BYTE_LENGTH);else if("string"==typeof r){if(r.length!==o.constants.SEED_BYTE_LENGTH)throw new TypeError('"seed" must be '+o.constants.SEED_BYTE_LENGTH+" bytes in length.")}else if(!(r instanceof Uint8Array))throw new TypeError('"seed" must be a node.js Buffer, Uint8Array, or a binary string.');r=c({message:r,encoding:"binary"});for(var n=new s(o.constants.PUBLIC_KEY_BYTE_LENGTH),i=new s(o.constants.PRIVATE_KEY_BYTE_LENGTH),a=0;a<32;++a)i[a]=r[a];return function(e,t){var r,n=[L(),L(),L(),L()],i=m(t,32);for(i[0]&=248,i[31]&=127,i[31]|=64,N(n,i),T(e,n),r=0;r<32;++r)t[r+32]=e[r]}(n,i),{publicKey:n,privateKey:i}},o.privateKeyFromAsn1=function(t){var r={},i=[];if(!e.asn1.validate(t,n,r,i)){var a=new Error("Invalid Key.");throw a.errors=i,a}var s=e.asn1.derToOid(r.privateKeyOid),o=e.oids.EdDSA25519;if(s!==o)throw new Error('Invalid OID "'+s+'"; OID must be "'+o+'".');var u=r.privateKey;return{privateKeyBytes:c({message:e.asn1.fromDer(u).value,encoding:"binary"})}},o.publicKeyFromAsn1=function(t){var n={},i=[];if(!e.asn1.validate(t,r,n,i)){var a=new Error("Invalid Key.");throw a.errors=i,a}var s=e.asn1.derToOid(n.publicKeyOid),u=e.oids.EdDSA25519;if(s!==u)throw new Error('Invalid OID "'+s+'"; OID must be "'+u+'".');var l=n.ed25519PublicKey;if(l.length!==o.constants.PUBLIC_KEY_BYTE_LENGTH)throw new Error("Key length is invalid.");return c({message:l,encoding:"binary"})},o.publicKeyFromPrivateKey=function(e){var t=c({message:(e=e||{}).privateKey,encoding:"binary"});if(t.length!==o.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+o.constants.PRIVATE_KEY_BYTE_LENGTH);for(var r=new s(o.constants.PUBLIC_KEY_BYTE_LENGTH),n=0;n<r.length;++n)r[n]=t[32+n];return r},o.sign=function(e){var t=c(e=e||{}),r=c({message:e.privateKey,encoding:"binary"});if(r.length===o.constants.SEED_BYTE_LENGTH)r=o.generateKeyPair({seed:r}).privateKey;else if(r.length!==o.constants.PRIVATE_KEY_BYTE_LENGTH)throw new TypeError('"options.privateKey" must have a byte length of '+o.constants.SEED_BYTE_LENGTH+" or "+o.constants.PRIVATE_KEY_BYTE_LENGTH);var n=new s(o.constants.SIGN_BYTE_LENGTH+t.length);!function(e,t,r,n){var i,a,s=new Float64Array(64),o=[L(),L(),L(),L()],c=m(n,32);c[0]&=248,c[31]&=127,c[31]|=64;var u=r+64;for(i=0;i<r;++i)e[64+i]=t[i];for(i=0;i<32;++i)e[32+i]=c[32+i];var l=m(e.subarray(32),r+32);for(C(l),N(o,l),T(e,o),i=32;i<64;++i)e[i]=n[i];var f=m(e,r+64);for(C(f),i=32;i<64;++i)s[i]=0;for(i=0;i<32;++i)s[i]=l[i];for(i=0;i<32;++i)for(a=0;a<32;a++)s[i+a]+=f[i]*c[a];v(e.subarray(32),s)}(n,t,t.length,r);for(var i=new s(o.constants.SIGN_BYTE_LENGTH),a=0;a<i.length;++a)i[a]=n[a];return i},o.verify=function(e){var t=c(e=e||{});if(void 0===e.signature)throw new TypeError('"options.signature" must be a node.js Buffer, a Uint8Array, a forge ByteBuffer, or a binary string.');var r=c({message:e.signature,encoding:"binary"});if(r.length!==o.constants.SIGN_BYTE_LENGTH)throw new TypeError('"options.signature" must have a byte length of '+o.constants.SIGN_BYTE_LENGTH);var n=c({message:e.publicKey,encoding:"binary"});if(n.length!==o.constants.PUBLIC_KEY_BYTE_LENGTH)throw new TypeError('"options.publicKey" must have a byte length of '+o.constants.PUBLIC_KEY_BYTE_LENGTH);var i,a=new s(o.constants.SIGN_BYTE_LENGTH+t.length),p=new s(o.constants.SIGN_BYTE_LENGTH+t.length);for(i=0;i<o.constants.SIGN_BYTE_LENGTH;++i)a[i]=r[i];for(i=0;i<t.length;++i)a[i+o.constants.SIGN_BYTE_LENGTH]=t[i];return function(e,t,r,n){var i,a=new s(32),o=[L(),L(),L(),L()],c=[L(),L(),L(),L()];if(r<64)return-1;if(function(e,t){var r=L(),n=L(),i=L(),a=L(),s=L(),o=L(),c=L();_(e[2],l),function(e,t){var r;for(r=0;r<16;++r)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767}(e[1],t),O(i,e[1]),P(a,i,f),D(i,i,e[2]),U(a,e[2],a),O(s,a),O(o,s),P(c,o,s),P(r,c,i),P(r,r,a),function(e,t){var r,n=L();for(r=0;r<16;++r)n[r]=t[r];for(r=250;r>=0;--r)O(n,n),1!==r&&P(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(r,r),P(r,r,i),P(r,r,a),P(r,r,a),P(e[0],r,a),O(n,e[0]),P(n,n,a),A(n,i)&&P(e[0],e[0],y);if(O(n,e[0]),P(n,n,a),A(n,i))return-1;B(e[0])===t[31]>>7&&D(e[0],u,e[0]);return P(e[3],e[0],e[1]),0}(c,n))return-1;for(i=0;i<r;++i)e[i]=t[i];for(i=0;i<32;++i)e[i+32]=n[i];var p=m(e,r);if(C(p),w(o,c,p),N(c,t.subarray(32)),E(o,c),T(a,o),r-=64,I(t,0,a,0)){for(i=0;i<r;++i)e[i]=0;return-1}for(i=0;i<r;++i)e[i]=t[i+64];return r}(p,a,a.length,n)>=0};var u=L(),l=L([1]),f=L([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),p=L([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),h=L([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),d=L([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),g=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]),y=L([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function m(t,r){var n=e.md.sha512.create(),i=new a(t);n.update(i.getBytes(r),"binary");var c=n.digest().getBytes();if("undefined"!=typeof Buffer)return Buffer.from(c,"binary");for(var u=new s(o.constants.HASH_BYTE_LENGTH),l=0;l<64;++l)u[l]=c.charCodeAt(l);return u}function v(e,t){var r,n,i,a;for(n=63;n>=32;--n){for(r=0,i=n-32,a=n-12;i<a;++i)t[i]+=r-16*t[n]*g[i-(n-32)],r=t[i]+128>>8,t[i]-=256*r;t[i]+=r,t[n]=0}for(r=0,i=0;i<32;++i)t[i]+=r-(t[31]>>4)*g[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;++i)t[i]-=r*g[i];for(n=0;n<32;++n)t[n+1]+=t[n]>>8,e[n]=255&t[n]}function C(e){for(var t=new Float64Array(64),r=0;r<64;++r)t[r]=e[r],e[r]=0;v(e,t)}function E(e,t){var r=L(),n=L(),i=L(),a=L(),s=L(),o=L(),c=L(),u=L(),l=L();D(r,e[1],e[0]),D(l,t[1],t[0]),P(r,r,l),U(n,e[0],e[1]),U(l,t[0],t[1]),P(n,n,l),P(i,e[3],t[3]),P(i,i,p),P(a,e[2],t[2]),U(a,a,a),D(s,n,r),D(o,a,i),U(c,a,i),U(u,n,r),P(e[0],s,o),P(e[1],u,c),P(e[2],c,o),P(e[3],s,u)}function S(e,t,r){for(var n=0;n<4;++n)k(e[n],t[n],r)}function T(e,t){var r=L(),n=L(),i=L();!function(e,t){var r,n=L();for(r=0;r<16;++r)n[r]=t[r];for(r=253;r>=0;--r)O(n,n),2!==r&&4!==r&&P(n,n,t);for(r=0;r<16;++r)e[r]=n[r]}(i,t[2]),P(r,t[0],i),P(n,t[1],i),b(e,n),e[31]^=B(r)<<7}function b(e,t){var r,n,i,a=L(),s=L();for(r=0;r<16;++r)s[r]=t[r];for(R(s),R(s),R(s),n=0;n<2;++n){for(a[0]=s[0]-65517,r=1;r<15;++r)a[r]=s[r]-65535-(a[r-1]>>16&1),a[r-1]&=65535;a[15]=s[15]-32767-(a[14]>>16&1),i=a[15]>>16&1,a[14]&=65535,k(s,a,1-i)}for(r=0;r<16;r++)e[2*r]=255&s[r],e[2*r+1]=s[r]>>8}function A(e,t){var r=new s(32),n=new s(32);return b(r,e),b(n,t),I(r,0,n,0)}function I(e,t,r,n){return function(e,t,r,n,i){var a,s=0;for(a=0;a<i;++a)s|=e[t+a]^r[n+a];return(1&s-1>>>8)-1}(e,t,r,n,32)}function B(e){var t=new s(32);return b(t,e),1&t[0]}function w(e,t,r){var n,i;for(_(e[0],u),_(e[1],l),_(e[2],l),_(e[3],u),i=255;i>=0;--i)S(e,t,n=r[i/8|0]>>(7&i)&1),E(t,e),E(e,e),S(e,t,n)}function N(e,t){var r=[L(),L(),L(),L()];_(r[0],h),_(r[1],d),_(r[2],l),P(r[3],h,d),w(e,r,t)}function _(e,t){var r;for(r=0;r<16;r++)e[r]=0|t[r]}function R(e){var t,r,n=1;for(t=0;t<16;++t)r=e[t]+n+65535,n=Math.floor(r/65536),e[t]=r-65536*n;e[0]+=n-1+37*(n-1)}function k(e,t,r){for(var n,i=~(r-1),a=0;a<16;++a)n=i&(e[a]^t[a]),e[a]^=n,t[a]^=n}function L(e){var t,r=new Float64Array(16);if(e)for(t=0;t<e.length;++t)r[t]=e[t];return r}function U(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]+r[n]}function D(e,t,r){for(var n=0;n<16;++n)e[n]=t[n]-r[n]}function O(e,t){P(e,t,t)}function P(e,t,r){var n,i,a=0,s=0,o=0,c=0,u=0,l=0,f=0,p=0,h=0,d=0,g=0,y=0,m=0,v=0,C=0,E=0,S=0,T=0,b=0,A=0,I=0,B=0,w=0,N=0,_=0,R=0,k=0,L=0,U=0,D=0,O=0,P=r[0],x=r[1],V=r[2],K=r[3],M=r[4],F=r[5],j=r[6],q=r[7],H=r[8],G=r[9],z=r[10],Q=r[11],W=r[12],Y=r[13],X=r[14],$=r[15];a+=(n=t[0])*P,s+=n*x,o+=n*V,c+=n*K,u+=n*M,l+=n*F,f+=n*j,p+=n*q,h+=n*H,d+=n*G,g+=n*z,y+=n*Q,m+=n*W,v+=n*Y,C+=n*X,E+=n*$,s+=(n=t[1])*P,o+=n*x,c+=n*V,u+=n*K,l+=n*M,f+=n*F,p+=n*j,h+=n*q,d+=n*H,g+=n*G,y+=n*z,m+=n*Q,v+=n*W,C+=n*Y,E+=n*X,S+=n*$,o+=(n=t[2])*P,c+=n*x,u+=n*V,l+=n*K,f+=n*M,p+=n*F,h+=n*j,d+=n*q,g+=n*H,y+=n*G,m+=n*z,v+=n*Q,C+=n*W,E+=n*Y,S+=n*X,T+=n*$,c+=(n=t[3])*P,u+=n*x,l+=n*V,f+=n*K,p+=n*M,h+=n*F,d+=n*j,g+=n*q,y+=n*H,m+=n*G,v+=n*z,C+=n*Q,E+=n*W,S+=n*Y,T+=n*X,b+=n*$,u+=(n=t[4])*P,l+=n*x,f+=n*V,p+=n*K,h+=n*M,d+=n*F,g+=n*j,y+=n*q,m+=n*H,v+=n*G,C+=n*z,E+=n*Q,S+=n*W,T+=n*Y,b+=n*X,A+=n*$,l+=(n=t[5])*P,f+=n*x,p+=n*V,h+=n*K,d+=n*M,g+=n*F,y+=n*j,m+=n*q,v+=n*H,C+=n*G,E+=n*z,S+=n*Q,T+=n*W,b+=n*Y,A+=n*X,I+=n*$,f+=(n=t[6])*P,p+=n*x,h+=n*V,d+=n*K,g+=n*M,y+=n*F,m+=n*j,v+=n*q,C+=n*H,E+=n*G,S+=n*z,T+=n*Q,b+=n*W,A+=n*Y,I+=n*X,B+=n*$,p+=(n=t[7])*P,h+=n*x,d+=n*V,g+=n*K,y+=n*M,m+=n*F,v+=n*j,C+=n*q,E+=n*H,S+=n*G,T+=n*z,b+=n*Q,A+=n*W,I+=n*Y,B+=n*X,w+=n*$,h+=(n=t[8])*P,d+=n*x,g+=n*V,y+=n*K,m+=n*M,v+=n*F,C+=n*j,E+=n*q,S+=n*H,T+=n*G,b+=n*z,A+=n*Q,I+=n*W,B+=n*Y,w+=n*X,N+=n*$,d+=(n=t[9])*P,g+=n*x,y+=n*V,m+=n*K,v+=n*M,C+=n*F,E+=n*j,S+=n*q,T+=n*H,b+=n*G,A+=n*z,I+=n*Q,B+=n*W,w+=n*Y,N+=n*X,_+=n*$,g+=(n=t[10])*P,y+=n*x,m+=n*V,v+=n*K,C+=n*M,E+=n*F,S+=n*j,T+=n*q,b+=n*H,A+=n*G,I+=n*z,B+=n*Q,w+=n*W,N+=n*Y,_+=n*X,R+=n*$,y+=(n=t[11])*P,m+=n*x,v+=n*V,C+=n*K,E+=n*M,S+=n*F,T+=n*j,b+=n*q,A+=n*H,I+=n*G,B+=n*z,w+=n*Q,N+=n*W,_+=n*Y,R+=n*X,k+=n*$,m+=(n=t[12])*P,v+=n*x,C+=n*V,E+=n*K,S+=n*M,T+=n*F,b+=n*j,A+=n*q,I+=n*H,B+=n*G,w+=n*z,N+=n*Q,_+=n*W,R+=n*Y,k+=n*X,L+=n*$,v+=(n=t[13])*P,C+=n*x,E+=n*V,S+=n*K,T+=n*M,b+=n*F,A+=n*j,I+=n*q,B+=n*H,w+=n*G,N+=n*z,_+=n*Q,R+=n*W,k+=n*Y,L+=n*X,U+=n*$,C+=(n=t[14])*P,E+=n*x,S+=n*V,T+=n*K,b+=n*M,A+=n*F,I+=n*j,B+=n*q,w+=n*H,N+=n*G,_+=n*z,R+=n*Q,k+=n*W,L+=n*Y,U+=n*X,D+=n*$,E+=(n=t[15])*P,s+=38*(T+=n*V),o+=38*(b+=n*K),c+=38*(A+=n*M),u+=38*(I+=n*F),l+=38*(B+=n*j),f+=38*(w+=n*q),p+=38*(N+=n*H),h+=38*(_+=n*G),d+=38*(R+=n*z),g+=38*(k+=n*Q),y+=38*(L+=n*W),m+=38*(U+=n*Y),v+=38*(D+=n*X),C+=38*(O+=n*$),a=(n=(a+=38*(S+=n*x))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),E=(n=E+i+65535)-65536*(i=Math.floor(n/65536)),a=(n=(a+=i-1+37*(i-1))+(i=1)+65535)-65536*(i=Math.floor(n/65536)),s=(n=s+i+65535)-65536*(i=Math.floor(n/65536)),o=(n=o+i+65535)-65536*(i=Math.floor(n/65536)),c=(n=c+i+65535)-65536*(i=Math.floor(n/65536)),u=(n=u+i+65535)-65536*(i=Math.floor(n/65536)),l=(n=l+i+65535)-65536*(i=Math.floor(n/65536)),f=(n=f+i+65535)-65536*(i=Math.floor(n/65536)),p=(n=p+i+65535)-65536*(i=Math.floor(n/65536)),h=(n=h+i+65535)-65536*(i=Math.floor(n/65536)),d=(n=d+i+65535)-65536*(i=Math.floor(n/65536)),g=(n=g+i+65535)-65536*(i=Math.floor(n/65536)),y=(n=y+i+65535)-65536*(i=Math.floor(n/65536)),m=(n=m+i+65535)-65536*(i=Math.floor(n/65536)),v=(n=v+i+65535)-65536*(i=Math.floor(n/65536)),C=(n=C+i+65535)-65536*(i=Math.floor(n/65536)),E=(n=E+i+65535)-65536*(i=Math.floor(n/65536)),a+=i-1+37*(i-1),e[0]=a,e[1]=s,e[2]=o,e[3]=c,e[4]=u,e[5]=l,e[6]=f,e[7]=p,e[8]=h,e[9]=d,e[10]=g,e[11]=y,e[12]=m,e[13]=v,e[14]=C,e[15]=E}return Kn}var Wn,Yn={exports:{}};function Xn(){if(Wn)return Yn.exports;Wn=1;var e=zt();sr(),hr(),_r(),pr(),Ir(),dn(),zr(),Zt(),Rn();var t=e.asn1,r=Yn.exports=e.pkcs7=e.pkcs7||{};function n(n){var i={},a=[];if(!t.validate(n,r.asn1.recipientInfoValidator,i,a)){var s=new Error("Cannot read PKCS#7 RecipientInfo. ASN.1 object is not an PKCS#7 RecipientInfo.");throw s.errors=a,s}return{version:i.version.charCodeAt(0),issuer:e.pki.RDNAttributesAsArray(i.issuer),serialNumber:e.util.createBuffer(i.serial).toHex(),encryptedContent:{algorithm:t.derToOid(i.encAlgorithm),parameter:i.encParameter?i.encParameter.value:void 0,content:i.encKey}}}function i(r){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[e.pki.distinguishedNameToAsn1({attributes:r.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,e.util.hexToBytes(r.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.encryptedContent.algorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]),t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.encryptedContent.content)])}function a(e){for(var t=[],r=0;r<e.length;++r)t.push(i(e[r]));return t}function s(r){var n=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(r.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[e.pki.distinguishedNameToAsn1({attributes:r.issuer}),t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,e.util.hexToBytes(r.serialNumber))]),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.digestAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])]);if(r.authenticatedAttributesAsn1&&n.value.push(r.authenticatedAttributesAsn1),n.value.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.signatureAlgorithm).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")])),n.value.push(t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.signature)),r.unauthenticatedAttributes.length>0){for(var i=t.create(t.Class.CONTEXT_SPECIFIC,1,!0,[]),a=0;a<r.unauthenticatedAttributes.length;++a){var s=r.unauthenticatedAttributes[a];i.values.push(o(s))}n.value.push(i)}return n}function o(r){var n;if(r.type===e.pki.oids.contentType)n=t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.value).getBytes());else if(r.type===e.pki.oids.messageDigest)n=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.value.bytes());else if(r.type===e.pki.oids.signingTime){var i=new Date("1950-01-01T00:00:00Z"),a=new Date("2050-01-01T00:00:00Z"),s=r.value;if("string"==typeof s){var o=Date.parse(s);s=isNaN(o)?13===s.length?t.utcTimeToDate(s):t.generalizedTimeToDate(s):new Date(o)}n=s>=i&&s<a?t.create(t.Class.UNIVERSAL,t.Type.UTCTIME,!1,t.dateToUtcTime(s)):t.create(t.Class.UNIVERSAL,t.Type.GENERALIZEDTIME,!1,t.dateToGeneralizedTime(s))}return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.type).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[n])])}function c(r,n,i){var a={};if(!t.validate(n,i,a,[])){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not a supported PKCS#7 message.");throw s.errors=s,s}if(t.derToOid(a.contentType)!==e.pki.oids.data)throw new Error("Unsupported PKCS#7 message. Only wrapped ContentType Data supported.");if(a.encryptedContent){var o="";if(e.util.isArray(a.encryptedContent))for(var c=0;c<a.encryptedContent.length;++c){if(a.encryptedContent[c].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting encrypted content constructed of only OCTET STRING objects.");o+=a.encryptedContent[c].value}else o=a.encryptedContent;r.encryptedContent={algorithm:t.derToOid(a.encAlgorithm),parameter:e.util.createBuffer(a.encParameter.value),content:e.util.createBuffer(o)}}if(a.content){o="";if(e.util.isArray(a.content))for(c=0;c<a.content.length;++c){if(a.content[c].type!==t.Type.OCTETSTRING)throw new Error("Malformed PKCS#7 message, expecting content constructed of only OCTET STRING objects.");o+=a.content[c].value}else o=a.content;r.content=e.util.createBuffer(o)}return r.version=a.version.charCodeAt(0),r.rawCapture=a,a}function u(t){if(void 0===t.encryptedContent.key)throw new Error("Symmetric key not available.");if(void 0===t.content){var r;switch(t.encryptedContent.algorithm){case e.pki.oids["aes128-CBC"]:case e.pki.oids["aes192-CBC"]:case e.pki.oids["aes256-CBC"]:r=e.aes.createDecryptionCipher(t.encryptedContent.key);break;case e.pki.oids.desCBC:case e.pki.oids["des-EDE3-CBC"]:r=e.des.createDecryptionCipher(t.encryptedContent.key);break;default:throw new Error("Unsupported symmetric cipher, OID "+t.encryptedContent.algorithm)}if(r.start(t.encryptedContent.parameter),r.update(t.encryptedContent.content),!r.finish())throw new Error("Symmetric decryption failed.");t.content=r.output}}return r.messageFromPem=function(n){var i=e.pem.decode(n)[0];if("PKCS7"!==i.type){var a=new Error('Could not convert PKCS#7 message from PEM; PEM header type is not "PKCS#7".');throw a.headerType=i.type,a}if(i.procType&&"ENCRYPTED"===i.procType.type)throw new Error("Could not convert PKCS#7 message from PEM; PEM is encrypted.");var s=t.fromDer(i.body);return r.messageFromAsn1(s)},r.messageToPem=function(r,n){var i={type:"PKCS7",body:t.toDer(r.toAsn1()).getBytes()};return e.pem.encode(i,{maxline:n})},r.messageFromAsn1=function(n){var i={},a=[];if(!t.validate(n,r.asn1.contentInfoValidator,i,a)){var s=new Error("Cannot read PKCS#7 message. ASN.1 object is not an PKCS#7 ContentInfo.");throw s.errors=a,s}var o,c=t.derToOid(i.contentType);switch(c){case e.pki.oids.envelopedData:o=r.createEnvelopedData();break;case e.pki.oids.encryptedData:o=r.createEncryptedData();break;case e.pki.oids.signedData:o=r.createSignedData();break;default:throw new Error("Cannot read PKCS#7 message. ContentType with OID "+c+" is not (yet) supported.")}return o.fromAsn1(i.content.value[0]),o},r.createSignedData=function(){var n=null;return n={type:e.pki.oids.signedData,version:1,certificates:[],crls:[],signers:[],digestAlgorithmIdentifiers:[],contentInfo:null,signerInfos:[],fromAsn1:function(t){if(c(n,t,r.asn1.signedDataValidator),n.certificates=[],n.crls=[],n.digestAlgorithmIdentifiers=[],n.contentInfo=null,n.signerInfos=[],n.rawCapture.certificates)for(var i=n.rawCapture.certificates.value,a=0;a<i.length;++a)n.certificates.push(e.pki.certificateFromAsn1(i[a]))},toAsn1:function(){n.contentInfo||n.sign();for(var r=[],i=0;i<n.certificates.length;++i)r.push(e.pki.certificateToAsn1(n.certificates[i]));var a=[],s=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(n.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,n.digestAlgorithmIdentifiers),n.contentInfo])]);return r.length>0&&s.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,r)),a.length>0&&s.value[0].value.push(t.create(t.Class.CONTEXT_SPECIFIC,1,!0,a)),s.value[0].value.push(t.create(t.Class.UNIVERSAL,t.Type.SET,!0,n.signerInfos)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(n.type).getBytes()),s])},addSigner:function(t){var r=t.issuer,i=t.serialNumber;if(t.certificate){var a=t.certificate;"string"==typeof a&&(a=e.pki.certificateFromPem(a)),r=a.issuer.attributes,i=a.serialNumber}var s=t.key;if(!s)throw new Error("Could not add PKCS#7 signer; no private key specified.");"string"==typeof s&&(s=e.pki.privateKeyFromPem(s));var o=t.digestAlgorithm||e.pki.oids.sha1;switch(o){case e.pki.oids.sha1:case e.pki.oids.sha256:case e.pki.oids.sha384:case e.pki.oids.sha512:case e.pki.oids.md5:break;default:throw new Error("Could not add PKCS#7 signer; unknown message digest algorithm: "+o)}var c=t.authenticatedAttributes||[];if(c.length>0){for(var u=!1,l=!1,f=0;f<c.length;++f){var p=c[f];if(u||p.type!==e.pki.oids.contentType){if(l||p.type!==e.pki.oids.messageDigest);else if(l=!0,u)break}else if(u=!0,l)break}if(!u||!l)throw new Error("Invalid signer.authenticatedAttributes. If signer.authenticatedAttributes is specified, then it must contain at least two attributes, PKCS #9 content-type and PKCS #9 message-digest.")}n.signers.push({key:s,version:1,issuer:r,serialNumber:i,digestAlgorithm:o,signatureAlgorithm:e.pki.oids.rsaEncryption,signature:null,authenticatedAttributes:c,unauthenticatedAttributes:[]})},sign:function(r){var i;(r=r||{},"object"!=typeof n.content||null===n.contentInfo)&&(n.contentInfo=t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.pki.oids.data).getBytes())]),"content"in n&&(n.content instanceof e.util.ByteBuffer?i=n.content.bytes():"string"==typeof n.content&&(i=e.util.encodeUtf8(n.content)),r.detached?n.detachedContent=t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i):n.contentInfo.value.push(t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,i)]))));0!==n.signers.length&&function(r){var i;i=n.detachedContent?n.detachedContent:(i=n.contentInfo.value[1]).value[0];if(!i)throw new Error("Could not sign PKCS#7 message; there is no content to sign.");var a=t.derToOid(n.contentInfo.value[0].value),c=t.toDer(i);for(var u in c.getByte(),t.getBerValueLength(c),c=c.getBytes(),r)r[u].start().update(c);for(var l=new Date,f=0;f<n.signers.length;++f){var p=n.signers[f];if(0===p.authenticatedAttributes.length){if(a!==e.pki.oids.data)throw new Error("Invalid signer; authenticatedAttributes must be present when the ContentInfo content type is not PKCS#7 Data.")}else{p.authenticatedAttributesAsn1=t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[]);for(var h=t.create(t.Class.UNIVERSAL,t.Type.SET,!0,[]),d=0;d<p.authenticatedAttributes.length;++d){var g=p.authenticatedAttributes[d];g.type===e.pki.oids.messageDigest?g.value=r[p.digestAlgorithm].digest():g.type===e.pki.oids.signingTime&&(g.value||(g.value=l)),h.value.push(o(g)),p.authenticatedAttributesAsn1.value.push(o(g))}c=t.toDer(h).getBytes(),p.md.start().update(c)}p.signature=p.key.sign(p.md,"RSASSA-PKCS1-V1_5")}n.signerInfos=function(e){for(var t=[],r=0;r<e.length;++r)t.push(s(e[r]));return t}(n.signers)}(function(){for(var r={},i=0;i<n.signers.length;++i){var a=n.signers[i];(s=a.digestAlgorithm)in r||(r[s]=e.md[e.pki.oids[s]].create()),0===a.authenticatedAttributes.length?a.md=r[s]:a.md=e.md[e.pki.oids[s]].create()}for(var s in n.digestAlgorithmIdentifiers=[],r)n.digestAlgorithmIdentifiers.push(t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(s).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.NULL,!1,"")]));return r}())},verify:function(){throw new Error("PKCS#7 signature verification not yet implemented.")},addCertificate:function(t){"string"==typeof t&&(t=e.pki.certificateFromPem(t)),n.certificates.push(t)},addCertificateRevokationList:function(e){throw new Error("PKCS#7 CRL support not yet implemented.")}}},r.createEncryptedData=function(){var t=null;return t={type:e.pki.oids.encryptedData,version:0,encryptedContent:{algorithm:e.pki.oids["aes256-CBC"]},fromAsn1:function(e){c(t,e,r.asn1.encryptedDataValidator)},decrypt:function(e){void 0!==e&&(t.encryptedContent.key=e),u(t)}}},r.createEnvelopedData=function(){var i=null;return i={type:e.pki.oids.envelopedData,version:0,recipients:[],encryptedContent:{algorithm:e.pki.oids["aes256-CBC"]},fromAsn1:function(e){var t=c(i,e,r.asn1.envelopedDataValidator);i.recipients=function(e){for(var t=[],r=0;r<e.length;++r)t.push(n(e[r]));return t}(t.recipientInfos.value)},toAsn1:function(){return t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(i.type).getBytes()),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.INTEGER,!1,t.integerToDer(i.version).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SET,!0,a(i.recipients)),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,(r=i.encryptedContent,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(e.pki.oids.data).getBytes()),t.create(t.Class.UNIVERSAL,t.Type.SEQUENCE,!0,[t.create(t.Class.UNIVERSAL,t.Type.OID,!1,t.oidToDer(r.algorithm).getBytes()),r.parameter?t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.parameter.getBytes()):void 0]),t.create(t.Class.CONTEXT_SPECIFIC,0,!0,[t.create(t.Class.UNIVERSAL,t.Type.OCTETSTRING,!1,r.content.getBytes())])]))])])]);var r},findRecipient:function(e){for(var t=e.issuer.attributes,r=0;r<i.recipients.length;++r){var n=i.recipients[r],a=n.issuer;if(n.serialNumber===e.serialNumber&&a.length===t.length){for(var s=!0,o=0;o<t.length;++o)if(a[o].type!==t[o].type||a[o].value!==t[o].value){s=!1;break}if(s)return n}}return null},decrypt:function(t,r){if(void 0===i.encryptedContent.key&&void 0!==t&&void 0!==r)switch(t.encryptedContent.algorithm){case e.pki.oids.rsaEncryption:case e.pki.oids.desCBC:var n=r.decrypt(t.encryptedContent.content);i.encryptedContent.key=e.util.createBuffer(n);break;default:throw new Error("Unsupported asymmetric cipher, OID "+t.encryptedContent.algorithm)}u(i)},addRecipient:function(t){i.recipients.push({version:0,issuer:t.issuer.attributes,serialNumber:t.serialNumber,encryptedContent:{algorithm:e.pki.oids.rsaEncryption,key:t.publicKey}})},encrypt:function(t,r){if(void 0===i.encryptedContent.content){var n,a,s;switch(r=r||i.encryptedContent.algorithm,t=t||i.encryptedContent.key,r){case e.pki.oids["aes128-CBC"]:n=16,a=16,s=e.aes.createEncryptionCipher;break;case e.pki.oids["aes192-CBC"]:n=24,a=16,s=e.aes.createEncryptionCipher;break;case e.pki.oids["aes256-CBC"]:n=32,a=16,s=e.aes.createEncryptionCipher;break;case e.pki.oids["des-EDE3-CBC"]:n=24,a=8,s=e.des.createEncryptionCipher;break;default:throw new Error("Unsupported symmetric cipher, OID "+r)}if(void 0===t)t=e.util.createBuffer(e.random.getBytes(n));else if(t.length()!=n)throw new Error("Symmetric key has wrong length; got "+t.length()+" bytes, expected "+n+".");i.encryptedContent.algorithm=r,i.encryptedContent.key=t,i.encryptedContent.parameter=e.util.createBuffer(e.random.getBytes(a));var o=s(t);if(o.start(i.encryptedContent.parameter.copy()),o.update(i.content),!o.finish())throw new Error("Symmetric encryption failed.");i.encryptedContent.content=o.output}for(var c=0;c<i.recipients.length;++c){var u=i.recipients[c];if(void 0===u.encryptedContent.content){if(u.encryptedContent.algorithm!==e.pki.oids.rsaEncryption)throw new Error("Unsupported asymmetric cipher, OID "+u.encryptedContent.algorithm);u.encryptedContent.content=u.encryptedContent.key.encrypt(i.encryptedContent.key.data)}}}}},Yn.exports}var $n,Jn,Zn,ei={exports:{}};var ti=(Zn||(Zn=1,Jn=zt(),sr(),Dn(),hr(),er(),_r(),Qn(),Cr(),function(){if(jn)return Fn;jn=1;var e=zt();Zt(),zr(),Wr(),Fn=e.kem=e.kem||{};var t=e.jsbn.BigInteger;function r(t,r,n,i){t.generate=function(t,a){for(var s=new e.util.ByteBuffer,o=Math.ceil(a/i)+n,c=new e.util.ByteBuffer,u=n;u<o;++u){c.putInt32(u),r.start(),r.update(t+c.getBytes());var l=r.digest();s.putBytes(l.getBytes(i))}return s.truncate(s.length()-a),s.getBytes()}}e.kem.rsa={},e.kem.rsa.create=function(r,n){var i=(n=n||{}).prng||e.random;return{encrypt:function(n,a){var s,o=Math.ceil(n.n.bitLength()/8);do{s=new t(e.util.bytesToHex(i.getBytesSync(o)),16).mod(n.n)}while(s.compareTo(t.ONE)<=0);var c=o-(s=e.util.hexToBytes(s.toString(16))).length;return c>0&&(s=e.util.fillString(String.fromCharCode(0),c)+s),{encapsulation:n.encrypt(s,"NONE"),key:r.generate(s,a)}},decrypt:function(e,t,n){var i=e.decrypt(t,"NONE");return r.generate(i,n)}}},e.kem.kdf1=function(e,t){r(this,e,0,t||e.digestLength)},e.kem.kdf2=function(e,t){r(this,e,1,t||e.digestLength)}}(),function(){if(Hn)return qn;Hn=1;var e=zt();Zt(),qn=e.log=e.log||{},e.log.levels=["none","error","warning","info","debug","verbose","max"];var t={},r=[],n=null;e.log.LEVEL_LOCKED=2,e.log.NO_LEVEL_CHECK=4,e.log.INTERPOLATE=8;for(var i=0;i<e.log.levels.length;++i){var a=e.log.levels[i];t[a]={index:i,name:a.toUpperCase()}}e.log.logMessage=function(n){for(var i=t[n.level].index,a=0;a<r.length;++a){var s=r[a];s.flags&e.log.NO_LEVEL_CHECK?s.f(n):i<=t[s.level].index&&s.f(s,n)}},e.log.prepareStandard=function(e){"standard"in e||(e.standard=t[e.level].name+" ["+e.category+"] "+e.message)},e.log.prepareFull=function(t){if(!("full"in t)){var r=[t.message];r=r.concat([]),t.full=e.util.format.apply(this,r)}},e.log.prepareStandardFull=function(t){"standardFull"in t||(e.log.prepareStandard(t),t.standardFull=t.standard)};var s=["error","warning","info","debug","verbose"];for(i=0;i<s.length;++i)(function(t){e.log[t]=function(r,n){var i=Array.prototype.slice.call(arguments).slice(2),a={timestamp:new Date,level:t,category:r,message:n,arguments:i};e.log.logMessage(a)}})(s[i]);if(e.log.makeLogger=function(t){var r={flags:0,f:t};return e.log.setLevel(r,"none"),r},e.log.setLevel=function(t,r){var n=!1;if(t&&!(t.flags&e.log.LEVEL_LOCKED))for(var i=0;i<e.log.levels.length;++i)if(r==e.log.levels[i]){t.level=r,n=!0;break}return n},e.log.lock=function(t,r){void 0===r||r?t.flags|=e.log.LEVEL_LOCKED:t.flags&=~e.log.LEVEL_LOCKED},e.log.addLogger=function(e){r.push(e)},"undefined"!=typeof console&&"log"in console){var o;if(console.error&&console.warn&&console.info&&console.debug){var c={error:console.error,warning:console.warn,info:console.info,debug:console.debug,verbose:console.debug},u=function(t,r){e.log.prepareStandard(r);var n=c[r.level],i=[r.standard];i=i.concat(r.arguments.slice()),n.apply(console,i)};o=e.log.makeLogger(u)}else u=function(t,r){e.log.prepareStandardFull(r),console.log(r.standardFull)},o=e.log.makeLogger(u);e.log.setLevel(o,"debug"),e.log.addLogger(o),n=o}else console={log:function(){}};if(null!==n&&"undefined"!=typeof window&&window.location){var l=new URL(window.location.href).searchParams;l.has("console.level")&&e.log.setLevel(n,l.get("console.level").slice(-1)[0]),l.has("console.lock")&&"true"==l.get("console.lock").slice(-1)[0]&&e.log.lock(n)}e.log.consoleLogger=n}(),Gn||(Gn=1,vr(),Tr(),Zr(),xr(),xn()),En(),Ur(),Ir(),en(),kn(),Xn(),Ln(),cn(),Gr(),_n(),zr(),Qr(),function(){if($n)return ei.exports;$n=1;var e=zt();sr(),Cr(),Tr(),Zr(),Zt();var t=ei.exports=e.ssh=e.ssh||{};function r(t,r){var n=r.toString(16);n[0]>="8"&&(n="00"+n);var i=e.util.hexToBytes(n);t.putInt32(i.length),t.putBytes(i)}function n(e,t){e.putInt32(t.length),e.putString(t)}function i(){for(var t=e.md.sha1.create(),r=arguments.length,n=0;n<r;++n)t.update(arguments[n]);return t.digest()}t.privateKeyToPutty=function(t,a,s){var o="ssh-rsa",c=""===(a=a||"")?"none":"aes256-cbc",u="PuTTY-User-Key-File-2: "+o+"\r\n";u+="Encryption: "+c+"\r\n",u+="Comment: "+(s=s||"")+"\r\n";var l=e.util.createBuffer();n(l,o),r(l,t.e),r(l,t.n);var f=e.util.encode64(l.bytes(),64),p=Math.floor(f.length/66)+1;u+="Public-Lines: "+p+"\r\n",u+=f;var h,d=e.util.createBuffer();if(r(d,t.d),r(d,t.p),r(d,t.q),r(d,t.qInv),a){var g=d.length()+16-1;g-=g%16;var y=i(d.bytes());y.truncate(y.length()-g+d.length()),d.putBuffer(y);var m=e.util.createBuffer();m.putBuffer(i("\0\0\0\0",a)),m.putBuffer(i("\0\0\0",a));var v=e.aes.createEncryptionCipher(m.truncate(8),"CBC");v.start(e.util.createBuffer().fillWithByte(0,16)),v.update(d.copy()),v.finish();var C=v.output;C.truncate(16),h=e.util.encode64(C.bytes(),64)}else h=e.util.encode64(d.bytes(),64);u+="\r\nPrivate-Lines: "+(p=Math.floor(h.length/66)+1)+"\r\n",u+=h;var E=i("putty-private-key-file-mac-key",a),S=e.util.createBuffer();n(S,o),n(S,c),n(S,s),S.putInt32(l.length()),S.putBuffer(l),S.putInt32(d.length()),S.putBuffer(d);var T=e.hmac.create();return T.start("sha1",E),T.update(S.bytes()),u+"\r\nPrivate-MAC: "+T.digest().toHex()+"\r\n"},t.publicKeyToOpenSSH=function(t,i){var a="ssh-rsa";i=i||"";var s=e.util.createBuffer();return n(s,a),r(s,t.e),r(s,t.n),a+" "+e.util.encode64(s.bytes())+" "+i},t.privateKeyToOpenSSH=function(t,r){return r?e.pki.encryptRsaPrivateKey(t,r,{legacy:!0,algorithm:"aes128"}):e.pki.privateKeyToPem(t)},t.getPublicKeyFingerprint=function(t,i){var a=(i=i||{}).md||e.md.md5.create(),s=e.util.createBuffer();n(s,"ssh-rsa"),r(s,t.e),r(s,t.n),a.start(),a.update(s.getBytes());var o=a.digest();if("hex"===i.encoding){var c=o.toHex();return i.delimiter?c.match(/.{2}/g).join(i.delimiter):c}if("binary"===i.encoding)return o.getBytes();if(i.encoding)throw new Error('Unknown encoding "'+i.encoding+'".');return o},ei.exports}(),Un(),Zt()),Jn);const ri=i(ti);function ni(e){const t=[];for(let r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return Uint8Array.from(t)}function ii(e){return 2147483648+e}function ai(e){const t=atob(e),r=[];return t.split("").forEach(function(e){let t=e.charCodeAt(0).toString(16);t.length%2&&(t="0"+t),r.push(t)}),new jt(BigInt("0x"+r.join("")))}class si{constructor(){this.STORAGE_KEY="zkfold-smart-wallet"}saveWallet(e,t){const r=this.getStorage();r.wallets[e]=t,localStorage.setItem(this.STORAGE_KEY,C(r))}getWallet(e){return this.getStorage().wallets[e]??null}getStorage(){const e=localStorage.getItem(this.STORAGE_KEY);if(e){const t=E(e);if(t)return t}const t={version:"v0",wallets:{}};return localStorage.setItem(this.STORAGE_KEY,C(t)),t}}class oi{constructor(){this.SESSION_KEY="zkfold-smart-wallet"}saveState(e){const t=this.getSession();t.oauth_state=e,sessionStorage.setItem(this.SESSION_KEY,C(t))}getState(){return this.getSession().oauth_state??null}removeState(){const e=this.getSession();e.oauth_state=null,sessionStorage.setItem(this.SESSION_KEY,C(e))}getSession(){const e=sessionStorage.getItem(this.SESSION_KEY);if(e){const t=E(e);if(t)return t}const t={oauth_state:null};return sessionStorage.setItem(this.SESSION_KEY,C(t)),t}}class ci extends EventTarget{constructor(e,t,r){super(),this.activated=!1,this.proof=null,this.storage=new si,this.session=new oi,this.googleApi=r,this.backend=e,this.prover=t}login(){const e=new Uint8Array(32);crypto.getRandomValues(e);const t=Array.from(e,e=>e.toString(16).padStart(2,"0")).join("");this.session.saveState(t);const r=this.googleApi.getAuthUrl(t);window.location.href=r}isActivated(){return this.activated}isLoggedIn(){return void 0!==this.jwt&&void 0!==this.tokenSKey&&void 0!==this.userId}hasProof(){return this.activated||null!==this.proof}logout(){this.jwt=void 0,this.tokenSKey=void 0,this.userId=void 0,this.activated=!1,this.proof=null,sessionStorage.clear(),this.dispatchEvent(new CustomEvent("logged_out"))}async oauthCallback(e){window.history.replaceState({},"","/");const t=this.session.getState();this.session.removeState();const r=new URLSearchParams(e);if(r.get("state")!==t)throw new Error("State mismatch. Possible CSRF attack");const i=r.get("code");if(!i)throw new Error("Missing authorization code");const a=await this.googleApi.getJWTFromCode(i);if(!a)throw new Error("Failed to get JWT from authorization code");this.userId=this.googleApi.getUserId(a);const s=await this.addressForGmail(this.userId).then(e=>e.to_bech32()),o=this.storage.getWallet(s);if(o)this.jwt=o.jwt,this.tokenSKey=n.Bip32PrivateKey.from_hex(o.tokenSKey),this.activated=!0;else{this.jwt=a;const e=n.Bip32PrivateKey.generate_ed25519_bip32().derive(ii(1852)).derive(ii(1815)).derive(ii(0)).derive(0).derive(0);this.tokenSKey=e,this.activated=!1,this.getProof()}this.dispatchEvent(new CustomEvent("initialized"))}async getProof(){if(!this.jwt||!this.tokenSKey)throw new Error("Wallet is not initialised");const e=this.tokenSKey.to_public().to_raw_key().hash().to_hex(),t=this.googleApi.getKeyId(this.jwt),r=await this.googleApi.getMatchingKey(t);if(!r)throw new Error(`Failed to find matching Google cert for key ${t}`);const n=this.googleApi.getSignature(this.jwt),i={piPubE:ai(r.e),piPubN:ai(r.n),piSignature:ai(n),piTokenName:new jt("0x"+e)};this.jwt=this.googleApi.stripSignature(this.jwt),this.proof=await this.prover.prove(i),this.dispatchEvent(new CustomEvent("proof_computed"))}getUserId(){if(!this.userId)throw new Error("Wallet is not initialised");return this.userId}async addressForGmail(e){return await this.backend.walletAddress(e)}async getAddress(){if(!this.userId)throw new Error("Wallet is not initialised");return await this.addressForGmail(this.userId)}async getBalance(){const e=await this.getAddress();return await this.backend.balance(e)}async getUSDValue(){return(await this.getBalance()).usd}async getTxHistory(){if(!this.userId)throw new Error("Wallet is not initialised");return await this.backend.txHistory(this.userId)}getExtensions(){return[]}async getUtxos(){const e=await this.getAddress();let t=[];try{t=await this.backend.addressUtxo(e)}catch(r){console.log("getUtxos()"),console.log(r),t=[]}return t}async getUsedAddresses(){const e=await this.getUtxos(),t=await this.getAddress();return 0==e.length?[]:[t]}async getUnusedAddresses(){const e=await this.getUtxos(),t=await this.getAddress();return 0==e.length?[t]:[]}async getRewardAddresses(){return[]}async getChangeAddress(){return await this.getAddress()}async sendTransaction(e){this.dispatchEvent(new CustomEvent("transaction_initiated",{detail:this.hasProof()}));try{if(!this.jwt||!this.tokenSKey||!this.userId)throw new Error("There is no active wallet when sending transaction");console.log(`Sending ${e.amount} ${e.asset} to ${e.recipient} using ${e.recipientType}`);const t={};let r;switch(t[e.asset]=new jt(e.amount),e.recipientType){case Gt.Bech32:r={recipientType:Gt.Bech32,address:e.recipient,assets:t};break;case Gt.Email:r={recipientType:Gt.Email,address:e.recipient,assets:t};break;default:throw new Error(`Unsupported recipient type: ${e.recipientType}`)}const n=await this.sendTo(r),i=n.transaction_id,a=n.notifier_errors;if(console.log(`Transaction ID: ${i}`),a&&a.length>0){console.error("Notifier errors occurred:");for(let e=0;e<a.length;e++){const t=a[e];console.error(`Failed to notify recipient ${t.email}: ${t.error}`)}}let s;this.dispatchEvent(new CustomEvent("transaction_pending",{detail:e})),this.storage.saveWallet(await this.getAddress().then(e=>e.to_bech32()),{jwt:this.jwt,tokenSKey:this.tokenSKey.to_hex()}),s=e.recipientType===Gt.Email?await this.addressForGmail(e.recipient).then(e=>e.to_bech32()):e.recipient,this.awaitTxConfirmed(i,s)}catch(t){throw console.error("Transaction failed:",t),this.dispatchEvent(new CustomEvent("transaction_failed",{detail:t.message})),t}}async awaitTxConfirmed(e,t){const r=e=>new Promise(t=>setTimeout(t,e));for(;;){const n=await this.checkTransactionStatus(e,t);if("success"===n.outcome)return void this.dispatchEvent(new CustomEvent("transaction_confirmed",{detail:n.data}));if("failure"===n.outcome)return void this.dispatchEvent(new CustomEvent("transaction_failed",{detail:n.reason}));await r(3e4)}}async checkTransactionStatus(e,t){try{const r=n.Address.from_bech32(t),i=await this.backend.addressUtxo(r);for(const t of i)if(t.ref.transaction_id===e)return{outcome:"success",data:e};return{outcome:"pending"}}catch(r){return console.error("Failed to check transaction status:",r),{outcome:"failure",reason:r}}}async sendTo(e){if(!this.userId||!this.tokenSKey||!this.jwt)throw new Error("Wallet is not initialised");let t;console.log(e.recipientType),console.log(e.address),console.log(e.assets),t=this.activated?e.assets.lovelace.toNumber()/1e6+2:e.assets.lovelace.toNumber()/1e6+8;if((await this.getBalance()).lovelace/1e6<t)throw new Error("Insufficient ADA to perform this transaction. You need at least "+t+" ADA.");let r;r=e.recipientType==Gt.Email?await this.addressForGmail(e.address):n.Address.from_bech32(e.address);const i=[];let a;e.recipientType==Gt.Email&&i.push(e.address);const s=[{address:r.to_bech32(),value:e.assets}];if(this.activated){a=(await this.backend.sendFunds(this.userId,s,this.tokenSKey.to_public().to_raw_key().hash().to_hex())).transaction}else{const e=this.tokenSKey.to_public().to_raw_key().hash().to_hex(),t=this.jwt.split("."),r=atob(t[0].replace(/-/g,"+").replace(/_/g,"/")),n=atob(t[1].replace(/-/g,"+").replace(/_/g,"/")),i=e=>new Promise(t=>setTimeout(t,e));for(;!this.hasProof();)await i(5e3);a=(await this.backend.activateAndSendFunds(r+"."+n,e,this.proof,s)).transaction}const o=n.FixedTransaction.from_bytes(ni(a));o.sign_and_add_vkey_signature(this.tokenSKey.to_raw_key());const c=Array.from(new Uint8Array(o.to_bytes())).map(e=>e.toString(16).padStart(2,"0")).join(""),u=await this.backend.submitTx(c,i,this.userId);return this.activated=!0,u}}e.AddressType=Gt,e.Backend=class{constructor(e,t=null){this.url=e,this.secret=t}headers(e={}){if(0===Object.keys(e).length&&!this.secret)return{};const t={headers:e};return this.secret&&(t.headers["api-key"]=this.secret),t}async settings(){const{data:e}=await It.get(`${this.url}/v0/settings`,this.headers());return e}async credentials(){const{data:e}=await It.get(`${this.url}/v0/oauth/credentials`,this.headers());return e}async walletAddress(e){const{data:t}=await It.post(`${this.url}/v0/wallet/address`,{email:e},this.headers());return n.Address.from_bech32(t.address)}async activateWallet(e,t,r){const i=C({jwt:e,payment_key_hash:t,proof_bytes:r}),{data:a}=await It.post(`${this.url}/v0/wallet/activate`,i,this.headers({"Content-Type":"application/json"}));return{address:n.Address.from_bech32(a.address),transaction:a.transaction,transaction_fee:a.transaction_fee,transaction_id:a.transaction_id}}async activateAndSendFunds(e,t,r,i){const a=C({jwt:e,payment_key_hash:t,proof_bytes:r,outs:i}),{data:s}=await It.post(`${this.url}/v0/wallet/activate-and-send-funds`,a,this.headers({"Content-Type":"application/json"}));return{address:n.Address.from_bech32(s.address),transaction:s.transaction,transaction_fee:s.transaction_fee,transaction_id:s.transaction_id}}async sendFunds(e,t,r){const n=C({email:e,outs:t,payment_key_hash:r}),{data:i}=await It.post(`${this.url}/v0/wallet/send-funds`,n,this.headers({"Content-Type":"application/json"}));return{transaction:i.transaction,transaction_fee:i.transaction_fee,transaction_id:i.transaction_id}}async submitTx(e,t=[],r){const{data:n}=await It.post(`${this.url}/v0/tx/submit`,{email_recipients:t,sender:r,transaction:e},this.headers());return{notifier_errors:n.notifier_errors,transaction_id:n.transaction_id}}async addVkeyAndSubmitTx(e,t,r=[],n){const{data:i}=await It.post(`${this.url}/v0/tx/add-vkey-and-submit`,{unsigned_transaction:e,vkey_witness:t,email_recipients:r,sender:n},this.headers());return{notifier_errors:i.notifier_errors,transaction_id:i.transaction_id}}async addressUtxo(e){const{data:t}=await It.post(`${this.url}/v0/address/utxos`,[e.to_bech32()],this.headers()),r=[];for(let i=0;i<t.length;i++){const e=t[i].ref.split("#"),a={transaction_id:e[0],output_index:Number(e[1])},s={};for(const r in t[i].value)s[r]=new jt(t[i].value[r]);const o={ref:a,address:n.Address.from_bech32(t[i].address),value:s};r.push(o)}return r}async balance(e){const{data:t}=await It.post(`${this.url}/v0/address/balance`,e.to_bech32(),this.headers({"Content-Type":"application/json"}));return t}async txHistory(e){const{data:t}=await It.post(`${this.url}/v0/wallet/txs`,{email:e},this.headers());return console.log(t),t.map(e=>(e.from_addrs=e.from_addrs.map(e=>n.Address.from_bech32(e)),e.to_addrs=e.to_addrs.map(e=>n.Address.from_bech32(e)),e))}},e.BigIntWrap=jt,e.GoogleApi=class{constructor(e,t,r){this.clientId=e,this.clientSecret=t,this.redirectURL=r}getAuthUrl(e){return`https://accounts.google.com/o/oauth2/v2/auth?${new URLSearchParams({client_id:this.clientId,redirect_uri:this.redirectURL,response_type:"code",scope:["https://www.googleapis.com/auth/userinfo.email","openid"].join(" "),access_type:"offline",include_granted_scopes:"true",state:e}).toString()}`}async getJWTFromCode(e){const t=new URLSearchParams({client_id:this.clientId,client_secret:this.clientSecret,code:e,grant_type:"authorization_code",redirect_uri:this.redirectURL}),{data:r}=await It.post("https://oauth2.googleapis.com/token",t.toString(),{headers:{"Content-Type":"application/x-www-form-urlencoded"}});return r.id_token||null}async getMatchingKey(e){const{data:t}=await It.get("https://www.googleapis.com/oauth2/v3/certs");for(const r of t.keys)if(r.kid===e)return r.e=r.e.replace(/-/g,"+").replace(/_/g,"/"),r.n=r.n.replace(/-/g,"+").replace(/_/g,"/"),r;return null}getKeyId(e){const t=e.split("."),r=atob(t[0].replace(/-/g,"+").replace(/_/g,"/"));return JSON.parse(r).kid}getUserId(e){const t=e.split(".");return JSON.parse(atob(t[1].replace(/-/g,"+").replace(/_/g,"/"))).email}getSignature(e){return e.split(".")[2].replace(/-/g,"+").replace(/_/g,"/")}stripSignature(e){const t=e.split(".");return`${t[0]}.${t[1]}`}},e.Prover=class{constructor(e){this.url=e}headers(e={}){if(0===Object.keys(e).length)return{};return{headers:e}}async serverKeys(){const{data:e}=await It.get(`${this.url}/v0/keys`,this.headers());return this.parseProverKeys(e)}async requestProof(e){const t=(await this.serverKeys())[0],r=C(e),n=ri.random.getBytesSync(32),i=ri.random.getBytesSync(16),a=ri.cipher.createCipher("AES-CBC",n);a.start({iv:i}),a.update(ri.util.createBuffer(r)),a.finish();const s=i+a.output.getBytes(),o=new ri.jsbn.BigInteger(t.pkbPublic.public_n.toString(),10),c=new ri.jsbn.BigInteger(t.pkbPublic.public_e.toString(),10),u=ri.pki.setRsaPublicKey(o,c),l={md:ri.md.sha256.create(),mgf1:{md:ri.md.sha256.create()},label:""},f=u.encrypt(n,"RSA-OAEP",l),p={server_key_id:t.pkbId,aes_encryption_key:ri.util.bytesToHex(f),encrypted_payload:ri.util.bytesToHex(s)},{data:h}=await It.post(`${this.url}/v0/prove-encrypted`,p,this.headers());return h}async proofStatus(e){const{data:t}=await It.post(`${this.url}/v0/proof-status`,e,{...this.headers({"Content-Type":"application/json"}),responseType:"text"});return this.parseProofStatus(t)}async prove(e){const t=e=>new Promise(t=>setTimeout(t,e)),r=await this.requestProof(e);for(;;){try{const e=await this.proofStatus(r);if(console.log(`Status: ${e}`),"object"==typeof e&&null!==e)return e}catch(n){console.error("Error checking status:",n)}await t(3e4)}}parseProverKeys(e){const t=[],r=e.length;for(let n=0;n<r;n++){const r={pkbId:e[n].id,pkbPublic:{public_e:new jt(e[n].public.public_e),public_n:new jt(e[n].public.public_n),public_size:new jt(e[n].public.public_size)}};t.push(r)}return t}parseProofStatus(e){const t=E(e);return"Completed"==t.tag?this.parseProofBytes(t.contents.bytes):t.tag}parseProofBytes(e){let t;if(console.log(e),"string"==typeof e)t=E(e);else{if("object"!=typeof e)return null;t=e}const r=[];for(let n=0;n<t.l_xi.length;++n)r.push(new jt(t.l_xi[n]));return{a_xi_int:new jt(t.a_xi_int),b_xi_int:new jt(t.b_xi_int),c_xi_int:new jt(t.c_xi_int),cmA_bytes:t.cmA_bytes,cmB_bytes:t.cmB_bytes,cmC_bytes:t.cmC_bytes,cmF_bytes:t.cmF_bytes,cmH1_bytes:t.cmH1_bytes,cmH2_bytes:t.cmH2_bytes,cmQhigh_bytes:t.cmQhigh_bytes,cmQlow_bytes:t.cmQlow_bytes,cmQmid_bytes:t.cmQmid_bytes,cmZ1_bytes:t.cmZ1_bytes,cmZ2_bytes:t.cmZ2_bytes,f_xi_int:new jt(t.f_xi_int),"h1_xi'_int":new jt(t["h1_xi'_int"]),h2_xi_int:new jt(t.h2_xi_int),l1_xi:new jt(t.l1_xi),l_xi:r,proof1_bytes:t.proof1_bytes,proof2_bytes:t.proof2_bytes,s1_xi_int:new jt(t.s1_xi_int),s2_xi_int:new jt(t.s2_xi_int),"t_xi'_int":new jt(t["t_xi'_int"]),t_xi_int:new jt(t.t_xi_int),"z1_xi'_int":new jt(t["z1_xi'_int"]),"z2_xi'_int":new jt(t["z2_xi'_int"])}}},e.Wallet=ci,e.b64ToBn=ai,e.bigIntToBytes=function(e){const t=e.toString(16),r=t.length%2?"0"+t:t,n=new Uint8Array(r.length/2);for(let i=0;i<r.length;i+=2)n[i/2]=parseInt(r.substr(i,2),16);return n},e.bytesToBase64Url=function(e){return btoa(String.fromCharCode(...e)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")},e.bytesToHex=function(e){return Array.from(e).map(e=>e.toString(16).padStart(2,"0")).join("")},e.deserialize=E,e.harden=ii,e.hexToBytes=ni,e.serialize=C,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})});