request-crypto
Advanced tools
Comparing version 1.7.7 to 1.7.9
@@ -1,1 +0,1 @@ | ||
"use strict";var t=require("axios"),r=require("buffer");const e=(t=16,r="high")=>{const e=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],i=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=[0,1,2,3,4,5,6,7,8,9],o=["!","@","-","_","=","<",">","#","*","%","+","&","^","$"],s=[];let u="";const h=function(...t){let r="";return t.forEach((t=>{r+=t[Math.floor(Math.random()*t.length)]})),r};switch(r){case"high":u+=h(e,i,n,o),s.push(...e,...i,...n,...o);break;case"medium":u+=h(e,i,n),s.push(...e,...i,...n);break;default:u+=h(e,n),s.push(...e,...n)}const a=t-u.length;for(let t=0;t<a;t++)u+=h(s);return u},i="X-Encrypt-With";function n(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){throw console.error("error",t),t}if(t instanceof ArrayBuffer){const r=function(t,r="utf-8"){return new TextDecoder(r).decode(t)}(t);try{return JSON.parse(r)}catch(t){return console.error("尝试转换失败",t),r}}return t}function o(t){try{return"string"==typeof t?JSON.parse(t):t}catch(r){return console.error("transform string to JSON data",{data:t,e:r}),t}}const s=t=>{let r=!0;return!(t=>/^\/bi-api\/api/.test(t))(t)&&(t.startsWith("/api")&&(r=!1,(t=>/^\/(api\/logmanage|api\/data-source|api\/enterpriseadmin|api\/componentmanager|api\/spacemanager|api\/filemanager)/.test(t))(t)&&(r=!0)),r)},u=t=>({...{key:e(16,"high"),algorithm:t||"SM4"}}),h=()=>({mode:"ecb",padding:"pkcs#5",output:"array"});var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c,l={exports:{}};c=l,function(){var t;function r(t,r,e){null!=t&&("number"==typeof t?this.fromNumber(t,r,e):null==r&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,r))}function e(){return new r(null)}var i="undefined"!=typeof navigator;i&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(var s=32767&r,u=r>>15;--o>=0;){var h=32767&this[t],a=this[t++]>>15,f=u*h+a*s;n=((h=s*h+((32767&f)<<15)+e[i]+(1073741823&n))>>>30)+(f>>>15)+u*a+(n>>>30),e[i++]=1073741823&h}return n},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(;--o>=0;){var s=r*this[t++]+e[i]+n;n=Math.floor(s/67108864),e[i++]=67108863&s}return n},t=26):(r.prototype.am=function(t,r,e,i,n,o){for(var s=16383&r,u=r>>14;--o>=0;){var h=16383&this[t],a=this[t++]>>14,f=u*h+a*s;n=((h=s*h+((16383&f)<<14)+e[i]+n)>>28)+(f>>14)+u*a,e[i++]=268435455&h}return n},t=28),r.prototype.DB=t,r.prototype.DM=(1<<t)-1,r.prototype.DV=1<<t,r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-t,r.prototype.F2=2*t-52;var n,o,s="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(n="0".charCodeAt(0),o=0;o<=9;++o)u[n++]=o;for(n="a".charCodeAt(0),o=10;o<36;++o)u[n++]=o;for(n="A".charCodeAt(0),o=10;o<36;++o)u[n++]=o;function h(t){return s.charAt(t)}function a(t,r){var e=u[t.charCodeAt(r)];return null==e?-1:e}function f(t){var r=e();return r.fromInt(t),r}function l(t){var r,e=1;return 0!=(r=t>>>16)&&(t=r,e+=16),0!=(r=t>>8)&&(t=r,e+=8),0!=(r=t>>4)&&(t=r,e+=4),0!=(r=t>>2)&&(t=r,e+=2),0!=(r=t>>1)&&(t=r,e+=1),e}function p(t){this.m=t}function y(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function g(t,r){return t&r}function d(t,r){return t|r}function m(t,r){return t^r}function v(t,r){return t&~r}function T(t){if(0==t)return-1;var r=0;return 65535&t||(t>>=16,r+=16),255&t||(t>>=8,r+=8),15&t||(t>>=4,r+=4),3&t||(t>>=2,r+=2),1&t||++r,r}function w(t){for(var r=0;0!=t;)t&=t-1,++r;return r}function b(){}function F(t){return t}function B(t){this.r2=e(),this.q3=e(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},p.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},p.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},y.prototype.convert=function(t){var i=e();return t.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),t.s<0&&i.compareTo(r.ZERO)>0&&this.m.subTo(i,i),i},y.prototype.revert=function(t){var r=e();return t.copyTo(r),this.reduce(r),r},y.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var r=0;r<this.m.t;++r){var e=32767&t[r],i=e*this.mpl+((e*this.mph+(t[r]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[e=r+this.m.t]+=this.m.am(0,i,t,r,0,this.m.t);t[e]>=t.DV;)t[e]-=t.DV,t[++e]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},y.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},y.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},r.prototype.copyTo=function(t){for(var r=this.t-1;r>=0;--r)t[r]=this[r];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var u=8==i?255&t[n]:a(t,n);u<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=u:s+i>this.DB?(this[this.t-1]|=(u&(1<<this.DB-s)-1)<<s,this[this.t++]=u>>this.DB-s):this[this.t-1]|=u<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,r){var e;for(e=this.t-1;e>=0;--e)r[e+t]=this[e];for(e=t-1;e>=0;--e)r[e]=0;r.t=this.t+t,r.s=this.s},r.prototype.drShiftTo=function(t,r){for(var e=t;e<this.t;++e)r[e-t]=this[e];r.t=Math.max(this.t-t,0),r.s=this.s},r.prototype.lShiftTo=function(t,r){var e,i=t%this.DB,n=this.DB-i,o=(1<<n)-1,s=Math.floor(t/this.DB),u=this.s<<i&this.DM;for(e=this.t-1;e>=0;--e)r[e+s+1]=this[e]>>n|u,u=(this[e]&o)<<i;for(e=s-1;e>=0;--e)r[e]=0;r[s]=u,r.t=this.t+s+1,r.s=this.s,r.clamp()},r.prototype.rShiftTo=function(t,r){r.s=this.s;var e=Math.floor(t/this.DB);if(e>=this.t)r.t=0;else{var i=t%this.DB,n=this.DB-i,o=(1<<i)-1;r[0]=this[e]>>i;for(var s=e+1;s<this.t;++s)r[s-e-1]|=(this[s]&o)<<n,r[s-e]=this[s]>>i;i>0&&(r[this.t-e-1]|=(this.s&o)<<n),r.t=this.t-e,r.clamp()}},r.prototype.subTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]-t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i-=t[e],r[e++]=i&this.DM,i>>=this.DB;i-=t.s}r.s=i<0?-1:0,i<-1?r[e++]=this.DV+i:i>0&&(r[e++]=i),r.t=e,r.clamp()},r.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),o=i.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+i.t]=i.am(0,n[o],e,o,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)},r.prototype.squareTo=function(t){for(var r=this.abs(),e=t.t=2*r.t;--e>=0;)t[e]=0;for(e=0;e<r.t-1;++e){var i=r.am(e,r[e],t,2*e,0,1);(t[e+r.t]+=r.am(e+1,2*r[e],t,2*e+1,i,r.t-e-1))>=r.DV&&(t[e+r.t]-=r.DV,t[e+r.t+1]=1)}t.t>0&&(t[t.t-1]+=r.am(e,r[e],t,2*e,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,i,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=i&&i.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=e());var u=e(),h=this.s,a=t.s,f=this.DB-l(o[o.t-1]);f>0?(o.lShiftTo(f,u),s.lShiftTo(f,n)):(o.copyTo(u),s.copyTo(n));var c=u.t,p=u[c-1];if(0!=p){var y=p*(1<<this.F1)+(c>1?u[c-2]>>this.F2:0),g=this.FV/y,d=(1<<this.F1)/y,m=1<<this.F2,v=n.t,T=v-c,w=null==i?e():i;for(u.dlShiftTo(T,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),r.ONE.dlShiftTo(c,w),w.subTo(u,u);u.t<c;)u[u.t++]=0;for(;--T>=0;){var b=n[--v]==p?this.DM:Math.floor(n[v]*g+(n[v-1]+m)*d);if((n[v]+=u.am(0,b,n,T,0,c))<b)for(u.dlShiftTo(T,w),n.subTo(w,n);n[v]<--b;)n.subTo(w,n)}null!=i&&(n.drShiftTo(c,i),h!=a&&r.ZERO.subTo(i,i)),n.t=c,n.clamp(),f>0&&n.rShiftTo(f,n),h<0&&r.ZERO.subTo(n,n)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var r=3&t;return(r=(r=(r=(r=r*(2-(15&t)*r)&15)*(2-(255&t)*r)&255)*(2-((65535&t)*r&65535))&65535)*(2-t*r%this.DV)%this.DV)>0?this.DV-r:-r},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,i){if(t>4294967295||t<1)return r.ONE;var n=e(),o=e(),s=i.convert(this),u=l(t)-1;for(s.copyTo(n);--u>=0;)if(i.sqrTo(n,o),(t&1<<u)>0)i.mulTo(o,s,n);else{var h=n;n=o,o=h}return i.revert(n)},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.toRadix(t);r=2}var e,i=(1<<r)-1,n=!1,o="",s=this.t,u=this.DB-s*this.DB%r;if(s-- >0)for(u<this.DB&&(e=this[s]>>u)>0&&(n=!0,o=h(e));s>=0;)u<r?(e=(this[s]&(1<<u)-1)<<r-u,e|=this[--s]>>(u+=this.DB-r)):(e=this[s]>>(u-=r)&i,u<=0&&(u+=this.DB,--s)),e>0&&(n=!0),n&&(o+=h(e));return n?o:"0"},r.prototype.negate=function(){var t=e();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var r=this.s-t.s;if(0!=r)return r;var e=this.t;if(0!=(r=e-t.t))return this.s<0?-r:r;for(;--e>=0;)if(0!=(r=this[e]-t[e]))return r;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var i=e();return this.abs().divRemTo(t,null,i),this.s<0&&i.compareTo(r.ZERO)>0&&t.subTo(i,i),i},r.prototype.modPowInt=function(t,r){var e;return e=t<256||r.isEven()?new p(r):new y(r),this.exp(t,e)},r.ZERO=f(0),r.ONE=f(1),b.prototype.convert=F,b.prototype.revert=F,b.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e)},b.prototype.sqrTo=function(t,r){t.squareTo(r)},B.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var r=e();return t.copyTo(r),this.reduce(r),r},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},B.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},B.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)};var x,q,S,E=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],I=(1<<26)/E[E.length-1];function D(){var t;t=(new Date).getTime(),q[S++]^=255&t,q[S++]^=t>>8&255,q[S++]^=t>>16&255,q[S++]^=t>>24&255,S>=H&&(S-=H)}if(r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var r=this.chunkSize(t),i=Math.pow(t,r),n=f(i),o=e(),s=e(),u="";for(this.divRemTo(n,o,s);o.signum()>0;)u=(i+s.intValue()).toString(t).substr(1)+u,o.divRemTo(n,o,s);return s.intValue().toString(t)+u},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),o=!1,s=0,u=0,h=0;h<t.length;++h){var f=a(t,h);f<0?"-"==t.charAt(h)&&0==this.signum()&&(o=!0):(u=e*u+f,++s>=i&&(this.dMultiply(n),this.dAddOffset(u,0),s=0,u=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(u,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),d,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var n=new Array,o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},r.prototype.bitwiseTo=function(t,r,e){var i,n,o=Math.min(t.t,this.t);for(i=0;i<o;++i)e[i]=r(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=o;i<this.t;++i)e[i]=r(this[i],n);e.t=this.t}else{for(n=this.s&this.DM,i=o;i<t.t;++i)e[i]=r(n,t[i]);e.t=t.t}e.s=r(this.s,t.s),e.clamp()},r.prototype.changeBit=function(t,e){var i=r.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},r.prototype.addTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]+t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i+=t[e],r[e++]=i&this.DM,i>>=this.DB;i+=t.s}r.s=i<0?-1:0,i>0?r[e++]=i:i<-1&&(r[e++]=this.DV+i),r.t=e,r.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,r){if(0!=t){for(;this.t<=r;)this[this.t++]=0;for(this[r]+=t;this[r]>=this.DV;)this[r]-=this.DV,++r>=this.t&&(this[this.t++]=0),++this[r]}},r.prototype.multiplyLowerTo=function(t,r,e){var i,n=Math.min(this.t+t.t,r);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(i=e.t-this.t;n<i;++n)e[n+this.t]=this.am(0,t[n],e,n,0,this.t);for(i=Math.min(t.t,r);n<i;++n)this.am(0,t[n],e,n,0,r-n);e.clamp()},r.prototype.multiplyUpperTo=function(t,r,e){--r;var i=e.t=this.t+t.t-r;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(r-this.t,0);i<t.t;++i)e[this.t+i-r]=this.am(r-i,t[i],e,0,0,this.t+i-r);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(t){if(t<=0)return 0;var r=this.DV%t,e=this.s<0?t-1:0;if(this.t>0)if(0==r)e=this[0]%t;else for(var i=this.t-1;i>=0;--i)e=(r*e+this[i])%t;return e},r.prototype.millerRabin=function(t){var i=this.subtract(r.ONE),n=i.getLowestSetBit();if(n<=0)return!1;var o=i.shiftRight(n);(t=t+1>>1)>E.length&&(t=E.length);for(var s=e(),u=0;u<t;++u){s.fromInt(E[Math.floor(Math.random()*E.length)]);var h=s.modPow(o,this);if(0!=h.compareTo(r.ONE)&&0!=h.compareTo(i)){for(var a=1;a++<n&&0!=h.compareTo(i);)if(0==(h=h.modPowInt(2,this)).compareTo(r.ONE))return!1;if(0!=h.compareTo(i))return!1}}return!0},r.prototype.clone=function(){var t=e();return this.copyTo(t),t},r.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,r=new Array;r[0]=this.s;var e,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(e=this[t]>>i)!=(this.s&this.DM)>>i&&(r[n++]=e|this.s<<this.DB-i);t>=0;)i<8?(e=(this[t]&(1<<i)-1)<<8-i,e|=this[--t]>>(i+=this.DB-8)):(e=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&e&&(e|=-256),0==n&&(128&this.s)!=(128&e)&&++n,(n>0||e!=this.s)&&(r[n++]=e);return r},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var r=e();return this.bitwiseTo(t,g,r),r},r.prototype.or=function(t){var r=e();return this.bitwiseTo(t,d,r),r},r.prototype.xor=function(t){var r=e();return this.bitwiseTo(t,m,r),r},r.prototype.andNot=function(t){var r=e();return this.bitwiseTo(t,v,r),r},r.prototype.not=function(){for(var t=e(),r=0;r<this.t;++r)t[r]=this.DM&~this[r];return t.t=this.t,t.s=~this.s,t},r.prototype.shiftLeft=function(t){var r=e();return t<0?this.rShiftTo(-t,r):this.lShiftTo(t,r),r},r.prototype.shiftRight=function(t){var r=e();return t<0?this.lShiftTo(-t,r):this.rShiftTo(t,r),r},r.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+T(this[t]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var t=0,r=this.s&this.DM,e=0;e<this.t;++e)t+=w(this[e]^r);return t},r.prototype.testBit=function(t){var r=Math.floor(t/this.DB);return r>=this.t?0!=this.s:!!(this[r]&1<<t%this.DB)},r.prototype.setBit=function(t){return this.changeBit(t,d)},r.prototype.clearBit=function(t){return this.changeBit(t,v)},r.prototype.flipBit=function(t){return this.changeBit(t,m)},r.prototype.add=function(t){var r=e();return this.addTo(t,r),r},r.prototype.subtract=function(t){var r=e();return this.subTo(t,r),r},r.prototype.multiply=function(t){var r=e();return this.multiplyTo(t,r),r},r.prototype.divide=function(t){var r=e();return this.divRemTo(t,r,null),r},r.prototype.remainder=function(t){var r=e();return this.divRemTo(t,null,r),r},r.prototype.divideAndRemainder=function(t){var r=e(),i=e();return this.divRemTo(t,r,i),new Array(r,i)},r.prototype.modPow=function(t,r){var i,n,o=t.bitLength(),s=f(1);if(o<=0)return s;i=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new p(r):r.isEven()?new B(r):new y(r);var u=new Array,h=3,a=i-1,c=(1<<i)-1;if(u[1]=n.convert(this),i>1){var g=e();for(n.sqrTo(u[1],g);h<=c;)u[h]=e(),n.mulTo(g,u[h-2],u[h]),h+=2}var d,m,v=t.t-1,T=!0,w=e();for(o=l(t[v])-1;v>=0;){for(o>=a?d=t[v]>>o-a&c:(d=(t[v]&(1<<o+1)-1)<<a-o,v>0&&(d|=t[v-1]>>this.DB+o-a)),h=i;!(1&d);)d>>=1,--h;if((o-=h)<0&&(o+=this.DB,--v),T)u[d].copyTo(s),T=!1;else{for(;h>1;)n.sqrTo(s,w),n.sqrTo(w,s),h-=2;h>0?n.sqrTo(s,w):(m=s,s=w,w=m),n.mulTo(w,u[d],s)}for(;v>=0&&!(t[v]&1<<o);)n.sqrTo(s,w),m=s,s=w,w=m,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},r.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var i=t.clone(),n=this.clone(),o=f(1),s=f(0),u=f(0),h=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?(u.isEven()&&h.isEven()||(u.addTo(this,u),h.subTo(t,h)),u.rShiftTo(1,u)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);i.compareTo(n)>=0?(i.subTo(n,i),e&&o.subTo(u,o),s.subTo(h,s)):(n.subTo(i,n),e&&u.subTo(o,u),h.subTo(s,h))}return 0!=n.compareTo(r.ONE)?r.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},r.prototype.pow=function(t){return this.exp(t,new b)},r.prototype.gcd=function(t){var r=this.s<0?this.negate():this.clone(),e=t.s<0?t.negate():t.clone();if(r.compareTo(e)<0){var i=r;r=e,e=i}var n=r.getLowestSetBit(),o=e.getLowestSetBit();if(o<0)return r;for(n<o&&(o=n),o>0&&(r.rShiftTo(o,r),e.rShiftTo(o,e));r.signum()>0;)(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),r.compareTo(e)>=0?(r.subTo(e,r),r.rShiftTo(1,r)):(e.subTo(r,e),e.rShiftTo(1,e));return o>0&&e.lShiftTo(o,e),e},r.prototype.isProbablePrime=function(t){var r,e=this.abs();if(1==e.t&&e[0]<=E[E.length-1]){for(r=0;r<E.length;++r)if(e[0]==E[r])return!0;return!1}if(e.isEven())return!1;for(r=1;r<E.length;){for(var i=E[r],n=r+1;n<E.length&&i<I;)i*=E[n++];for(i=e.modInt(i);r<n;)if(i%E[r++]==0)return!1}return e.millerRabin(t)},r.prototype.square=function(){var t=e();return this.squareTo(t),t},r.prototype.Barrett=B,null==q){var A;if(q=new Array,S=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var R=new Uint8Array(32);for(window.crypto.getRandomValues(R),A=0;A<32;++A)q[S++]=R[A]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var P=window.crypto.random(32);for(A=0;A<P.length;++A)q[S++]=255&P.charCodeAt(A)}for(;S<H;)A=Math.floor(65536*Math.random()),q[S++]=A>>>8,q[S++]=255&A;S=0,D()}function O(){if(null==x){for(D(),(x=new M).init(q),S=0;S<q.length;++S)q[S]=0;S=0}return x.next()}function C(){}function M(){this.i=0,this.j=0,this.S=new Array}C.prototype.nextBytes=function(t){var r;for(r=0;r<t.length;++r)t[r]=O()},M.prototype.init=function(t){var r,e,i;for(r=0;r<256;++r)this.S[r]=r;for(e=0,r=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},M.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var H=256;c.exports={default:r,BigInteger:r,SecureRandom:C}}.call(a);var p=l.exports;const{BigInteger:y}=p;class g{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let r=t.toString(16);if(r.length%2==1&&(r="0"+r),t<128)return r;return(128+r.length/2).toString(16)+r}getValue(){return""}}class d extends g{constructor(t){super(),this.t="02",t&&(this.v=function(t){let r=t.toString(16);if("-"!==r[0])r.length%2==1?r="0"+r:r.match(/^[0-7]/)||(r="00"+r);else{r=r.substr(1);let e=r.length;e%2==1?e+=1:r.match(/^[0-7]/)||(e+=2);let i="";for(let t=0;t<e;t++)i+="f";i=new y(i,16),r=i.xor(t).add(y.ONE),r=r.toString(16).replace(/^-/,"")}return r}(t))}getValue(){return this.v}}class m extends g{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map((t=>t.getEncodedHex())).join(""),this.v}}function v(t,r){return+t[r+2]<8?1:128&+t.substr(r+2,2)}function T(t,r){const e=v(t,r),i=t.substr(r+2,2*e);if(!i)return-1;return(+i[0]<8?new y(i,16):new y(i.substr(2),16)).intValue()}function w(t,r){return r+2*(v(t,r)+1)}var b={encodeDer(t,r){const e=new d(t),i=new d(r);return new m([e,i]).getEncodedHex()},decodeDer(t){const r=w(t,0),e=w(t,r),i=T(t,r),n=t.substr(e,2*i),o=e+n.length,s=w(t,o),u=T(t,o),h=t.substr(s,2*u);return{r:new y(n,16),s:new y(h,16)}}};const{BigInteger:F}=p,B=new F("2"),x=new F("3");class q{constructor(t,r){this.x=r,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new q(this.q,this.x.negate().mod(this.q))}add(t){return new q(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new q(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new q(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new q(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new q(this.q,this.x.square().mod(this.q))}}class S{constructor(t,r,e,i){this.curve=t,this.x=r,this.y=e,this.z=null==i?F.ONE:i,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(F.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(F.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(F.ZERO)&&!this.y.toBigInteger().equals(F.ZERO)}negate(){return new S(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const r=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=t.x.toBigInteger(),o=t.y.toBigInteger(),s=t.z,u=this.curve.q,h=r.multiply(s).mod(u),a=n.multiply(i).mod(u),f=h.subtract(a),c=e.multiply(s).mod(u),l=o.multiply(i).mod(u),p=c.subtract(l);if(F.ZERO.equals(f))return F.ZERO.equals(p)?this.twice():this.curve.infinity;const y=h.add(a),g=i.multiply(s).mod(u),d=f.square().mod(u),m=f.multiply(d).mod(u),v=g.multiply(p.square()).subtract(y.multiply(d)).mod(u),T=f.multiply(v).mod(u),w=p.multiply(d.multiply(h).subtract(v)).subtract(c.multiply(m)).mod(u),b=m.multiply(g).mod(u);return new S(this.curve,this.curve.fromBigInteger(T),this.curve.fromBigInteger(w),b)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),r=this.y.toBigInteger(),e=this.z,i=this.curve.q,n=this.curve.a.toBigInteger(),o=t.square().multiply(x).add(n.multiply(e.square())).mod(i),s=r.shiftLeft(1).multiply(e).mod(i),u=r.square().mod(i),h=u.multiply(t).multiply(e).mod(i),a=s.square().mod(i),f=o.square().subtract(h.shiftLeft(3)).mod(i),c=s.multiply(f).mod(i),l=o.multiply(h.shiftLeft(2).subtract(f)).subtract(a.shiftLeft(1).multiply(u)).mod(i),p=s.multiply(a).mod(i);return new S(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),p)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const r=t.multiply(x),e=this.negate();let i=this;for(let n=r.bitLength()-2;n>0;n--){i=i.twice();const o=r.testBit(n);o!==t.testBit(n)&&(i=i.add(o?this:e))}return i}}var E={ECPointFp:S,ECCurveFp:class{constructor(t,r,e){this.q=t,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(e),this.infinity=new S(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new q(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const r=this.fromBigInteger(new F(t.substr(2),16));let e=this.fromBigInteger(r.multiply(r.square()).add(r.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new F("4")).add(F.ONE),this.q));return e.toBigInteger().mod(B).equals(new F(t.substr(0,2),16).subtract(B))||(e=e.negate()),new S(this,r,e);case 4:case 6:case 7:const i=(t.length-2)/2,n=t.substr(2,i),o=t.substr(i+2,i);return new S(this,this.fromBigInteger(new F(n,16)),this.fromBigInteger(new F(o,16)));default:return null}}}};const{BigInteger:I,SecureRandom:D}=p,{ECCurveFp:A}=E,R=new D,{curve:P,G:O,n:C}=M();function M(){const t=new I("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),r=new I("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),e=new I("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),i=new A(t,r,e),n=i.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:i,G:n,n:new I("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function H(t,r){return t.length>=r?t:new Array(r-t.length+1).join("0")+t}var N={getGlobalCurve:function(){return P},generateEcparam:M,generateKeyPairHex:function(t,r,e){const i=(t?new I(t,r,e):new I(C.bitLength(),R)).mod(C.subtract(I.ONE)).add(I.ONE),n=H(i.toString(16),64),o=O.multiply(i);return{privateKey:n,publicKey:"04"+H(o.getX().toBigInteger().toString(16),64)+H(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const r=(t.length-2)/2,e=t.substr(2,r);let i="03";return new I(t.substr(r+2,r),16).mod(new I("2")).equals(I.ZERO)&&(i="02"),i+e},utf8ToHex:function(t){const r=(t=unescape(encodeURIComponent(t))).length,e=[];for(let i=0;i<r;i++)e[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;t<r;t++){const r=e[t>>>2]>>>24-t%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},leftPad:H,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const r=[];let e=0;for(let i=0;i<2*t.length;i+=2)r[i>>>3]|=parseInt(t[e],10)<<24-i%8*4,e++;try{const e=[];for(let i=0;i<t.length;i++){const t=r[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(t))}return decodeURIComponent(escape(e.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const r=[];let e=t.length;e%2!=0&&(t=H(t,e+1)),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r},verifyPublicKey:function(t){const r=P.decodePointHex(t);if(!r)return!1;const e=r.getX();return r.getY().square().equals(e.multiply(e.square()).add(e.multiply(P.a)).add(P.b))},comparePublicKeyHex:function(t,r){const e=P.decodePointHex(t);if(!e)return!1;const i=P.decodePointHex(r);return!!i&&e.equals(i)}};const K=new Uint32Array(68),V=new Uint32Array(64);function L(t,r){const e=31&r;return t<<e|t>>>32-e}function z(t,r){const e=[];for(let i=t.length-1;i>=0;i--)e[i]=255&(t[i]^r[i]);return e}function k(t){return t^L(t,9)^L(t,17)}function Z(t){let r=8*t.length,e=r%512;e=e>=448?512-e%448-1:448-e-1;const i=new Array((e-7)/8),n=new Array(8);for(let t=0,r=i.length;t<r;t++)i[t]=0;for(let t=0,r=n.length;t<r;t++)n[t]=0;r=r.toString(2);for(let t=7;t>=0;t--)if(r.length>8){const e=r.length-8;n[t]=parseInt(r.substr(e),2),r=r.substr(0,e)}else r.length>0&&(n[t]=parseInt(r,2),r="");const o=new Uint8Array([...t,128,...i,...n]),s=new DataView(o.buffer,0),u=o.length/64,h=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<u;t++){K.fill(0),V.fill(0);const r=16*t;for(let t=0;t<16;t++)K[t]=s.getUint32(4*(r+t),!1);for(let t=16;t<68;t++)K[t]=(a=K[t-16]^K[t-9]^L(K[t-3],15))^L(a,15)^L(a,23)^L(K[t-13],7)^K[t-6];for(let t=0;t<64;t++)V[t]=K[t]^K[t+4];const e=2043430169,i=2055708042;let n,o,u,f,c,l=h[0],p=h[1],y=h[2],g=h[3],d=h[4],m=h[5],v=h[6],T=h[7];for(let t=0;t<64;t++)c=t>=0&&t<=15?e:i,n=L(L(l,12)+d+L(c,t),7),o=n^L(l,12),u=(t>=0&&t<=15?l^p^y:l&p|l&y|p&y)+g+o+V[t],f=(t>=0&&t<=15?d^m^v:d&m|~d&v)+T+n+K[t],g=y,y=L(p,9),p=l,l=u,T=v,v=L(m,19),m=d,d=k(f);h[0]^=l,h[1]^=p,h[2]^=y,h[3]^=g,h[4]^=d,h[5]^=m,h[6]^=v,h[7]^=T}var a;const f=[];for(let t=0,r=h.length;t<r;t++){const r=h[t];f.push((4278190080&r)>>>24,(16711680&r)>>>16,(65280&r)>>>8,255&r)}return f}const j=new Uint8Array(64),U=new Uint8Array(64);for(let t=0;t<64;t++)j[t]=54,U[t]=92;var _={sm3:Z,hmac:function(t,r){for(r.length>64&&(r=Z(r));r.length<64;)r.push(0);const e=z(r,j),i=z(r,U),n=Z([...e,...t]);return Z([...i,...n])}};const{BigInteger:$}=p,{encodeDer:X,decodeDer:J}=b,Y=N,G=_.sm3,{G:W,curve:Q,n:tt}=Y.generateEcparam();function rt(t,r,e="1234567812345678"){e=Y.utf8ToHex(e);const i=Y.leftPad(W.curve.a.toBigInteger().toRadix(16),64),n=Y.leftPad(W.curve.b.toBigInteger().toRadix(16),64),o=Y.leftPad(W.getX().toBigInteger().toRadix(16),64),s=Y.leftPad(W.getY().toBigInteger().toRadix(16),64);let u,h;if(128===r.length)u=r.substr(0,64),h=r.substr(64,64);else{const t=W.curve.decodePointHex(r);u=Y.leftPad(t.getX().toBigInteger().toRadix(16),64),h=Y.leftPad(t.getY().toBigInteger().toRadix(16),64)}const a=Y.hexToArray(e+i+n+o+s+u+h),f=4*e.length;a.unshift(255&f),a.unshift(f>>8&255);const c=G(a);return Y.arrayToHex(G(c.concat(Y.hexToArray(t))))}function et(t){const r=W.multiply(new $(t,16));return"04"+Y.leftPad(r.getX().toBigInteger().toString(16),64)+Y.leftPad(r.getY().toBigInteger().toString(16),64)}function it(){const t=Y.generateKeyPairHex(),r=Q.decodePointHex(t.publicKey);return t.k=new $(t.privateKey,16),t.x1=r.getX().toBigInteger(),t}var nt={generateKeyPairHex:Y.generateKeyPairHex,compressPublicKeyHex:Y.compressPublicKeyHex,comparePublicKeyHex:Y.comparePublicKeyHex,doEncrypt:function(t,r,e=1){t="string"==typeof t?Y.hexToArray(Y.utf8ToHex(t)):Array.prototype.slice.call(t),r=Y.getGlobalCurve().decodePointHex(r);const i=Y.generateKeyPairHex(),n=new $(i.privateKey,16);let o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));const s=r.multiply(n),u=Y.hexToArray(Y.leftPad(s.getX().toBigInteger().toRadix(16),64)),h=Y.hexToArray(Y.leftPad(s.getY().toBigInteger().toRadix(16),64)),a=Y.arrayToHex(G([].concat(u,t,h)));let f=1,c=0,l=[];const p=[].concat(u,h),y=()=>{l=G([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let r=0,e=t.length;r<e;r++)c===l.length&&y(),t[r]^=255&l[c++];const g=Y.arrayToHex(t);return 0===e?o+g+a:o+a+g},doDecrypt:function(t,r,e=1,{output:i="string"}={}){r=new $(r,16);let n=t.substr(128,64),o=t.substr(192);0===e&&(n=t.substr(t.length-64),o=t.substr(128,t.length-128-64));const s=Y.hexToArray(o),u=Y.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(r),h=Y.hexToArray(Y.leftPad(u.getX().toBigInteger().toRadix(16),64)),a=Y.hexToArray(Y.leftPad(u.getY().toBigInteger().toRadix(16),64));let f=1,c=0,l=[];const p=[].concat(h,a),y=()=>{l=G([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let t=0,r=s.length;t<r;t++)c===l.length&&y(),s[t]^=255&l[c++];return Y.arrayToHex(G([].concat(h,s,a)))===n.toLowerCase()?"array"===i?s:Y.arrayToUtf8(s):"array"===i?[]:""},doSignature:function(t,r,{pointPool:e,der:i,hash:n,publicKey:o,userId:s}={}){let u="string"==typeof t?Y.utf8ToHex(t):Y.arrayToHex(t);n&&(u=rt(u,o=o||et(r),s));const h=new $(r,16),a=new $(u,16);let f=null,c=null,l=null;do{do{let t;t=e&&e.length?e.pop():it(),f=t.k,c=a.add(t.x1).mod(tt)}while(c.equals($.ZERO)||c.add(f).equals(tt));l=h.add($.ONE).modInverse(tt).multiply(f.subtract(c.multiply(h))).mod(tt)}while(l.equals($.ZERO));return i?X(c,l):Y.leftPad(c.toString(16),64)+Y.leftPad(l.toString(16),64)},doVerifySignature:function(t,r,e,{der:i,hash:n,userId:o}={}){let s,u,h="string"==typeof t?Y.utf8ToHex(t):Y.arrayToHex(t);if(n&&(h=rt(h,e,o)),i){const t=J(r);s=t.r,u=t.s}else s=new $(r.substring(0,64),16),u=new $(r.substring(64),16);const a=Q.decodePointHex(e),f=new $(h,16),c=s.add(u).mod(tt);if(c.equals($.ZERO))return!1;const l=W.multiply(u).add(a.multiply(c)),p=f.add(l.getX().toBigInteger()).mod(tt);return s.equals(p)},getPublicKeyFromPrivateKey:et,getPoint:it,verifyPublicKey:Y.verifyPublicKey};const{sm3:ot,hmac:st}=_;function ut(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}function ht(t){const r=[];let e=t.length;var i,n;e%2!=0&&(n=e+1,t=(i=t).length>=n?i:new Array(n-i.length+1).join("0")+i),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r}const at=0,ft=16,ct=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],lt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function pt(t){const r=[];for(let e=0,i=t.length;e<i;e+=2)r.push(parseInt(t.substr(e,2),16));return r}function yt(t,r){const e=31&r;return t<<e|t>>>32-e}function gt(t){return(255&ct[t>>>24&255])<<24|(255&ct[t>>>16&255])<<16|(255&ct[t>>>8&255])<<8|255&ct[255&t]}function dt(t){return t^yt(t,2)^yt(t,10)^yt(t,18)^yt(t,24)}function mt(t){return t^yt(t,13)^yt(t,23)}function vt(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[4*r],n[1]=255&t[4*r+1],n[2]=255&t[4*r+2],n[3]=255&t[4*r+3],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,r=0;r<32;r+=4)t=i[1]^i[2]^i[3]^e[r+0],i[0]^=dt(gt(t)),t=i[2]^i[3]^i[0]^e[r+1],i[1]^=dt(gt(t)),t=i[3]^i[0]^i[1]^e[r+2],i[2]^=dt(gt(t)),t=i[0]^i[1]^i[2]^e[r+3],i[3]^=dt(gt(t));for(let t=0;t<16;t+=4)r[t]=i[3-t/4]>>>24&255,r[t+1]=i[3-t/4]>>>16&255,r[t+2]=i[3-t/4]>>>8&255,r[t+3]=255&i[3-t/4]}function Tt(t,r,e,{padding:i="pkcs#7",mode:n,iv:o=[],output:s="string"}={}){if("cbc"===n&&("string"==typeof o&&(o=pt(o)),16!==o.length))throw new Error("iv is invalid");if("string"==typeof r&&(r=pt(r)),16!==r.length)throw new Error("key is invalid");if(t="string"==typeof t?e!==at?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):pt(t):[...t],("pkcs#5"===i||"pkcs#7"===i)&&e!==at){const r=ft-t.length%ft;for(let e=0;e<r;e++)t.push(r)}const u=new Array(32);!function(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[0+4*r],n[1]=255&t[1+4*r],n[2]=255&t[2+4*r],n[3]=255&t[3+4*r],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];i[0]^=2746333894,i[1]^=1453994832,i[2]^=1736282519,i[3]^=2993693404;for(let t,e=0;e<32;e+=4)t=i[1]^i[2]^i[3]^lt[e+0],r[e+0]=i[0]^=mt(gt(t)),t=i[2]^i[3]^i[0]^lt[e+1],r[e+1]=i[1]^=mt(gt(t)),t=i[3]^i[0]^i[1]^lt[e+2],r[e+2]=i[2]^=mt(gt(t)),t=i[0]^i[1]^i[2]^lt[e+3],r[e+3]=i[3]^=mt(gt(t));if(e===at)for(let t,e=0;e<16;e++)t=r[e],r[e]=r[31-e],r[31-e]=t}(r,u,e);const h=[];let a=o,f=t.length,c=0;for(;f>=ft;){const r=t.slice(c,c+16),i=new Array(16);if("cbc"===n)for(let t=0;t<ft;t++)e!==at&&(r[t]^=a[t]);vt(r,i,u);for(let t=0;t<ft;t++)"cbc"===n&&e===at&&(i[t]^=a[t]),h[c+t]=i[t];"cbc"===n&&(a=e!==at?i:r),f-=ft,c+=ft}if(("pkcs#5"===i||"pkcs#7"===i)&&e===at){const t=h.length,r=h[t-1];for(let e=1;e<=r;e++)if(h[t-e]!==r)throw new Error("padding is invalid");h.splice(t-r,r)}return"array"!==s?e!==at?h.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const r=[];for(let e=0,i=t.length;e<i;e++)t[e]>=240&&t[e]<=247?(r.push(String.fromCodePoint(((7&t[e])<<18)+((63&t[e+1])<<12)+((63&t[e+2])<<6)+(63&t[e+3]))),e+=3):t[e]>=224&&t[e]<=239?(r.push(String.fromCodePoint(((15&t[e])<<12)+((63&t[e+1])<<6)+(63&t[e+2]))),e+=2):t[e]>=192&&t[e]<=223?(r.push(String.fromCodePoint(((31&t[e])<<6)+(63&t[e+1]))),e++):r.push(String.fromCodePoint(t[e]));return r.join("")}(h):h}var wt={sm2:nt,sm3:function(t,r){if(t="string"==typeof t?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):Array.prototype.slice.call(t),r){if("hmac"!==(r.mode||"hmac"))throw new Error("invalid mode");let e=r.key;if(!e)throw new Error("invalid key");return e="string"==typeof e?ht(e):Array.prototype.slice.call(e),ut(st(t,e))}return ut(ot(t))},sm4:{encrypt:(t,r,e)=>Tt(t,r,1,e),decrypt:(t,r,e)=>Tt(t,r,0,e)}};const bt={mode:"ecb",padding:"pkcs#5",output:"array"},Ft=r.Buffer,Bt=function(t,r,e,i){return(n,o)=>{try{if(o.closeCrypto)return n;t.info=u(),t.publicKey=[...Ft.from(t.info.key)];const s=wt.sm2.doEncrypt(JSON.stringify(t.info),r,1);if(e.set(i,function(t){if("string"==typeof t)return String(t);return JSON.parse(JSON.stringify(t))}(s)),((t,r)=>{t.set("X-Encrypt-Key",r)})(o,"04"+s),n){"string"!=typeof n&&(n=JSON.stringify(n));const r=wt.sm4.encrypt(n,t.publicKey,bt);return n=Ft.from(r)}return n}catch(t){console.error("encrypt error",t,n,o)}}},xt=function(t){return(r,e)=>{try{if((t=>{const r=t.get(i);return r&&"string"==typeof r&&"sm4"===r.toLowerCase()})(e)){const e=Ft.from(r);return o(wt.sm4.decrypt(e,t.publicKey,{mode:"ecb",padding:"pkcs#5"}))}return r}catch(t){console.error("decrypt error",t,r,e)}}};var qt,St,Et={exports:{}},It={exports:{}};qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",St={rotl:function(t,r){return t<<r|t>>>32-r},rotr:function(t,r){return t<<32-r|t>>>r},endian:function(t){if(t.constructor==Number)return 16711935&St.rotl(t,8)|4278255360&St.rotl(t,24);for(var r=0;r<t.length;r++)t[r]=St.endian(t[r]);return t},randomBytes:function(t){for(var r=[];t>0;t--)r.push(Math.floor(256*Math.random()));return r},bytesToWords:function(t){for(var r=[],e=0,i=0;e<t.length;e++,i+=8)r[i>>>5]|=t[e]<<24-i%32;return r},wordsToBytes:function(t){for(var r=[],e=0;e<32*t.length;e+=8)r.push(t[e>>>5]>>>24-e%32&255);return r},bytesToHex:function(t){for(var r=[],e=0;e<t.length;e++)r.push((t[e]>>>4).toString(16)),r.push((15&t[e]).toString(16));return r.join("")},hexToBytes:function(t){for(var r=[],e=0;e<t.length;e+=2)r.push(parseInt(t.substr(e,2),16));return r},bytesToBase64:function(t){for(var r=[],e=0;e<t.length;e+=3)for(var i=t[e]<<16|t[e+1]<<8|t[e+2],n=0;n<4;n++)8*e+6*n<=8*t.length?r.push(qt.charAt(i>>>6*(3-n)&63)):r.push("=");return r.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var r=[],e=0,i=0;e<t.length;i=++e%4)0!=i&&r.push((qt.indexOf(t.charAt(e-1))&Math.pow(2,-2*i+8)-1)<<2*i|qt.indexOf(t.charAt(e))>>>6-2*i);return r}},It.exports=St;var Dt=It.exports,At={utf8:{stringToBytes:function(t){return At.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(At.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var r=[],e=0;e<t.length;e++)r.push(255&t.charCodeAt(e));return r},bytesToString:function(t){for(var r=[],e=0;e<t.length;e++)r.push(String.fromCharCode(t[e]));return r.join("")}}},Rt=At,Pt=function(t){return null!=t&&(Ot(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Ot(t.slice(0,0))}(t)||!!t._isBuffer)};function Ot(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(){var t=Dt,r=Rt.utf8,e=Pt,i=Rt.bin,n=function(o,s){o.constructor==String?o=s&&"binary"===s.encoding?i.stringToBytes(o):r.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):Array.isArray(o)||o.constructor===Uint8Array||(o=o.toString());for(var u=t.bytesToWords(o),h=8*o.length,a=1732584193,f=-271733879,c=-1732584194,l=271733878,p=0;p<u.length;p++)u[p]=16711935&(u[p]<<8|u[p]>>>24)|4278255360&(u[p]<<24|u[p]>>>8);u[h>>>5]|=128<<h%32,u[14+(h+64>>>9<<4)]=h;var y=n._ff,g=n._gg,d=n._hh,m=n._ii;for(p=0;p<u.length;p+=16){var v=a,T=f,w=c,b=l;a=y(a,f,c,l,u[p+0],7,-680876936),l=y(l,a,f,c,u[p+1],12,-389564586),c=y(c,l,a,f,u[p+2],17,606105819),f=y(f,c,l,a,u[p+3],22,-1044525330),a=y(a,f,c,l,u[p+4],7,-176418897),l=y(l,a,f,c,u[p+5],12,1200080426),c=y(c,l,a,f,u[p+6],17,-1473231341),f=y(f,c,l,a,u[p+7],22,-45705983),a=y(a,f,c,l,u[p+8],7,1770035416),l=y(l,a,f,c,u[p+9],12,-1958414417),c=y(c,l,a,f,u[p+10],17,-42063),f=y(f,c,l,a,u[p+11],22,-1990404162),a=y(a,f,c,l,u[p+12],7,1804603682),l=y(l,a,f,c,u[p+13],12,-40341101),c=y(c,l,a,f,u[p+14],17,-1502002290),a=g(a,f=y(f,c,l,a,u[p+15],22,1236535329),c,l,u[p+1],5,-165796510),l=g(l,a,f,c,u[p+6],9,-1069501632),c=g(c,l,a,f,u[p+11],14,643717713),f=g(f,c,l,a,u[p+0],20,-373897302),a=g(a,f,c,l,u[p+5],5,-701558691),l=g(l,a,f,c,u[p+10],9,38016083),c=g(c,l,a,f,u[p+15],14,-660478335),f=g(f,c,l,a,u[p+4],20,-405537848),a=g(a,f,c,l,u[p+9],5,568446438),l=g(l,a,f,c,u[p+14],9,-1019803690),c=g(c,l,a,f,u[p+3],14,-187363961),f=g(f,c,l,a,u[p+8],20,1163531501),a=g(a,f,c,l,u[p+13],5,-1444681467),l=g(l,a,f,c,u[p+2],9,-51403784),c=g(c,l,a,f,u[p+7],14,1735328473),a=d(a,f=g(f,c,l,a,u[p+12],20,-1926607734),c,l,u[p+5],4,-378558),l=d(l,a,f,c,u[p+8],11,-2022574463),c=d(c,l,a,f,u[p+11],16,1839030562),f=d(f,c,l,a,u[p+14],23,-35309556),a=d(a,f,c,l,u[p+1],4,-1530992060),l=d(l,a,f,c,u[p+4],11,1272893353),c=d(c,l,a,f,u[p+7],16,-155497632),f=d(f,c,l,a,u[p+10],23,-1094730640),a=d(a,f,c,l,u[p+13],4,681279174),l=d(l,a,f,c,u[p+0],11,-358537222),c=d(c,l,a,f,u[p+3],16,-722521979),f=d(f,c,l,a,u[p+6],23,76029189),a=d(a,f,c,l,u[p+9],4,-640364487),l=d(l,a,f,c,u[p+12],11,-421815835),c=d(c,l,a,f,u[p+15],16,530742520),a=m(a,f=d(f,c,l,a,u[p+2],23,-995338651),c,l,u[p+0],6,-198630844),l=m(l,a,f,c,u[p+7],10,1126891415),c=m(c,l,a,f,u[p+14],15,-1416354905),f=m(f,c,l,a,u[p+5],21,-57434055),a=m(a,f,c,l,u[p+12],6,1700485571),l=m(l,a,f,c,u[p+3],10,-1894986606),c=m(c,l,a,f,u[p+10],15,-1051523),f=m(f,c,l,a,u[p+1],21,-2054922799),a=m(a,f,c,l,u[p+8],6,1873313359),l=m(l,a,f,c,u[p+15],10,-30611744),c=m(c,l,a,f,u[p+6],15,-1560198380),f=m(f,c,l,a,u[p+13],21,1309151649),a=m(a,f,c,l,u[p+4],6,-145523070),l=m(l,a,f,c,u[p+11],10,-1120210379),c=m(c,l,a,f,u[p+2],15,718787259),f=m(f,c,l,a,u[p+9],21,-343485551),a=a+v>>>0,f=f+T>>>0,c=c+w>>>0,l=l+b>>>0}return t.endian([a,f,c,l])};n._ff=function(t,r,e,i,n,o,s){var u=t+(r&e|~r&i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._gg=function(t,r,e,i,n,o,s){var u=t+(r&i|e&~i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._hh=function(t,r,e,i,n,o,s){var u=t+(r^e^i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._ii=function(t,r,e,i,n,o,s){var u=t+(e^(r|~i))+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._blocksize=16,n._digestsize=16,Et.exports=function(r,e){if(null==r)throw new Error("Illegal argument "+r);var o=t.wordsToBytes(n(r,e));return e&&e.asBytes?o:e&&e.asString?i.bytesToString(o):t.bytesToHex(o)}}();var Ct=f(Et.exports);const Mt=function(){const t=new Map;return{get:function(r){return t.get(r)},generateKey:function(t,r){try{const e="e0c7ff",i=((t,r)=>{const e=new URL(window.location.origin+t);for(const t in r)e.searchParams.append(t,r[t]);return e.toString()})(t,r??{});return`${Ct(i+e)}-/${t}`}catch(r){return`${e(10)}-/${t}`}},set:function(r,e){t.set(r,e)},clear:function(r){t.delete(r)}}}();window.__buffer=r;const Ht=wt.sm2.doDecrypt;exports.createCryptoAxiosInstance=(r,e,u)=>{const h=t.create(r);return h.interceptors.request.use((t=>{const r=localStorage.getItem("cps_lang"),e={en:"en-US",ko:"ko-KR",zh:"zh-CN"};if(r&&Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];t.headers.set({"Accept-Language":`${i},zh;q=0.9,en;q=0.8`})}return t})),u||function(t,r){if(!r||"string"!=typeof r)throw new Error(`publicKey is required and must be a string ${r}`);t.interceptors.request.use((t=>{const e=t.transformRequest,i=t?.headers?.__requestKey,n={info:null,publicKey:[]};if(!e)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(e))throw new Error(`transformRequest ${e} is not an array`);e.push(Bt(n,r,Mt,i));const o=xt(n);if(!o)return t;const s=t.transformResponse;if(!s)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof o)throw new Error(`decryptFn ${o} is not a function`);if(!Array.isArray(s))throw new Error(`transformResponse ${s} is not an array`);return s.unshift(o),t})),t.interceptors.request.use((t=>{try{const r=encodeURI(t?.url??""),e=t.headers;return r?(e.__requestKey=Mt.generateKey(r,t?.params),t):t}catch(r){return console.error("error",r),t}})),t.interceptors.request.use((t=>(t.headers.closeCrypto||(t.responseType="arraybuffer"),t))),t.interceptors.request.use((t=>{const r=t.data,e=t.headers;return r?((r instanceof FormData||r instanceof File)&&(e.closeCrypto=!0),t):t})),t.interceptors.request.use((t=>{const r=t.url,e=t.headers;if(!r)throw new Error("url is required");return{}.hasOwnProperty.call(e,"closeCrypto")||s(r)||(e.closeCrypto=!0),t})),t.interceptors.response.use((t=>{const{request:r,headers:e}=t;return e&&e.get(i)||"arraybuffer"===r?.responseType?.toLowerCase()||"blob"===r?.responseType?.toLowerCase()||(t.data=o(t.data)),t}),(t=>{const r=t.response;throw r?.data&&(r.data=n(r.data)),t}))}(h,e),h},exports.createRequestInstance=(r,e)=>{const i=t.create(r);return function(t,r){if(!r)return t;const{encryptFn:e,decryptFn:i}=r();e&&t.interceptors.request.use((t=>{const r=t.transformRequest;if(!r)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(r))throw new Error(`transformRequest ${r} is not an array`);if(r.push(e),!i)return t;const n=t.transformResponse;if(!n)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof i)throw new Error(`decryptFn ${i} is not a function`);if(!Array.isArray(n))throw new Error(`transformResponse ${n} is not an array`);return n.unshift(i),t}))}(i,e),i},exports.decryptHeadersInfo=Ht,exports.getCryptoInfo=u,exports.getSm4EncryptConfig=h,exports.randomPassword=e,exports.shouldEncrypt=s; | ||
"use strict";var t=require("axios"),r=require("buffer");const e=(t=16,r="high")=>{const e=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],i=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=[0,1,2,3,4,5,6,7,8,9],o=["!","@","-","_","=","<",">","#","*","%","+","&","^","$"],s=[];let u="";const h=function(...t){let r="";return t.forEach((t=>{r+=t[Math.floor(Math.random()*t.length)]})),r};switch(r){case"high":u+=h(e,i,n,o),s.push(...e,...i,...n,...o);break;case"medium":u+=h(e,i,n),s.push(...e,...i,...n);break;default:u+=h(e,n),s.push(...e,...n)}const a=t-u.length;for(let t=0;t<a;t++)u+=h(s);return u},i="X-Encrypt-With";function n(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){throw console.error("error",t),t}if(t instanceof ArrayBuffer){const r=function(t,r="utf-8"){return new TextDecoder(r).decode(t)}(t);try{return JSON.parse(r)}catch(t){return console.error("尝试转换失败",t),r}}return t}function o(t){try{return"string"==typeof t?JSON.parse(t):t}catch(r){return console.error("transform string to JSON data",{data:t,e:r}),t}}const s=t=>{let r=!0;return!(t=>/^\/bi-api\/api/.test(t))(t)&&(t.startsWith("/api")&&(r=!1,(t=>/^\/(api\/logmanage|api\/data-source|api\/enterpriseadmin|api\/componentmanager|api\/spacemanager|api\/filemanager)/.test(t))(t)&&(r=!0)),r)},u=t=>({...{key:e(16,"high"),algorithm:t||"SM4"}}),h=()=>({mode:"ecb",padding:"pkcs#5",output:"array"});var a="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var c,l={exports:{}};c=l,function(){var t;function r(t,r,e){null!=t&&("number"==typeof t?this.fromNumber(t,r,e):null==r&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,r))}function e(){return new r(null)}var i="undefined"!=typeof navigator;i&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(var s=32767&r,u=r>>15;--o>=0;){var h=32767&this[t],a=this[t++]>>15,f=u*h+a*s;n=((h=s*h+((32767&f)<<15)+e[i]+(1073741823&n))>>>30)+(f>>>15)+u*a+(n>>>30),e[i++]=1073741823&h}return n},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(;--o>=0;){var s=r*this[t++]+e[i]+n;n=Math.floor(s/67108864),e[i++]=67108863&s}return n},t=26):(r.prototype.am=function(t,r,e,i,n,o){for(var s=16383&r,u=r>>14;--o>=0;){var h=16383&this[t],a=this[t++]>>14,f=u*h+a*s;n=((h=s*h+((16383&f)<<14)+e[i]+n)>>28)+(f>>14)+u*a,e[i++]=268435455&h}return n},t=28),r.prototype.DB=t,r.prototype.DM=(1<<t)-1,r.prototype.DV=1<<t,r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-t,r.prototype.F2=2*t-52;var n,o,s="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(n="0".charCodeAt(0),o=0;o<=9;++o)u[n++]=o;for(n="a".charCodeAt(0),o=10;o<36;++o)u[n++]=o;for(n="A".charCodeAt(0),o=10;o<36;++o)u[n++]=o;function h(t){return s.charAt(t)}function a(t,r){var e=u[t.charCodeAt(r)];return null==e?-1:e}function f(t){var r=e();return r.fromInt(t),r}function l(t){var r,e=1;return 0!=(r=t>>>16)&&(t=r,e+=16),0!=(r=t>>8)&&(t=r,e+=8),0!=(r=t>>4)&&(t=r,e+=4),0!=(r=t>>2)&&(t=r,e+=2),0!=(r=t>>1)&&(t=r,e+=1),e}function p(t){this.m=t}function y(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function g(t,r){return t&r}function d(t,r){return t|r}function m(t,r){return t^r}function v(t,r){return t&~r}function T(t){if(0==t)return-1;var r=0;return 65535&t||(t>>=16,r+=16),255&t||(t>>=8,r+=8),15&t||(t>>=4,r+=4),3&t||(t>>=2,r+=2),1&t||++r,r}function w(t){for(var r=0;0!=t;)t&=t-1,++r;return r}function b(){}function F(t){return t}function B(t){this.r2=e(),this.q3=e(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},p.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},p.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},y.prototype.convert=function(t){var i=e();return t.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),t.s<0&&i.compareTo(r.ZERO)>0&&this.m.subTo(i,i),i},y.prototype.revert=function(t){var r=e();return t.copyTo(r),this.reduce(r),r},y.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var r=0;r<this.m.t;++r){var e=32767&t[r],i=e*this.mpl+((e*this.mph+(t[r]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[e=r+this.m.t]+=this.m.am(0,i,t,r,0,this.m.t);t[e]>=t.DV;)t[e]-=t.DV,t[++e]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},y.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},y.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},r.prototype.copyTo=function(t){for(var r=this.t-1;r>=0;--r)t[r]=this[r];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var u=8==i?255&t[n]:a(t,n);u<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=u:s+i>this.DB?(this[this.t-1]|=(u&(1<<this.DB-s)-1)<<s,this[this.t++]=u>>this.DB-s):this[this.t-1]|=u<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,r){var e;for(e=this.t-1;e>=0;--e)r[e+t]=this[e];for(e=t-1;e>=0;--e)r[e]=0;r.t=this.t+t,r.s=this.s},r.prototype.drShiftTo=function(t,r){for(var e=t;e<this.t;++e)r[e-t]=this[e];r.t=Math.max(this.t-t,0),r.s=this.s},r.prototype.lShiftTo=function(t,r){var e,i=t%this.DB,n=this.DB-i,o=(1<<n)-1,s=Math.floor(t/this.DB),u=this.s<<i&this.DM;for(e=this.t-1;e>=0;--e)r[e+s+1]=this[e]>>n|u,u=(this[e]&o)<<i;for(e=s-1;e>=0;--e)r[e]=0;r[s]=u,r.t=this.t+s+1,r.s=this.s,r.clamp()},r.prototype.rShiftTo=function(t,r){r.s=this.s;var e=Math.floor(t/this.DB);if(e>=this.t)r.t=0;else{var i=t%this.DB,n=this.DB-i,o=(1<<i)-1;r[0]=this[e]>>i;for(var s=e+1;s<this.t;++s)r[s-e-1]|=(this[s]&o)<<n,r[s-e]=this[s]>>i;i>0&&(r[this.t-e-1]|=(this.s&o)<<n),r.t=this.t-e,r.clamp()}},r.prototype.subTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]-t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i-=t[e],r[e++]=i&this.DM,i>>=this.DB;i-=t.s}r.s=i<0?-1:0,i<-1?r[e++]=this.DV+i:i>0&&(r[e++]=i),r.t=e,r.clamp()},r.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),o=i.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+i.t]=i.am(0,n[o],e,o,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)},r.prototype.squareTo=function(t){for(var r=this.abs(),e=t.t=2*r.t;--e>=0;)t[e]=0;for(e=0;e<r.t-1;++e){var i=r.am(e,r[e],t,2*e,0,1);(t[e+r.t]+=r.am(e+1,2*r[e],t,2*e+1,i,r.t-e-1))>=r.DV&&(t[e+r.t]-=r.DV,t[e+r.t+1]=1)}t.t>0&&(t[t.t-1]+=r.am(e,r[e],t,2*e,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,i,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=i&&i.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=e());var u=e(),h=this.s,a=t.s,f=this.DB-l(o[o.t-1]);f>0?(o.lShiftTo(f,u),s.lShiftTo(f,n)):(o.copyTo(u),s.copyTo(n));var c=u.t,p=u[c-1];if(0!=p){var y=p*(1<<this.F1)+(c>1?u[c-2]>>this.F2:0),g=this.FV/y,d=(1<<this.F1)/y,m=1<<this.F2,v=n.t,T=v-c,w=null==i?e():i;for(u.dlShiftTo(T,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),r.ONE.dlShiftTo(c,w),w.subTo(u,u);u.t<c;)u[u.t++]=0;for(;--T>=0;){var b=n[--v]==p?this.DM:Math.floor(n[v]*g+(n[v-1]+m)*d);if((n[v]+=u.am(0,b,n,T,0,c))<b)for(u.dlShiftTo(T,w),n.subTo(w,n);n[v]<--b;)n.subTo(w,n)}null!=i&&(n.drShiftTo(c,i),h!=a&&r.ZERO.subTo(i,i)),n.t=c,n.clamp(),f>0&&n.rShiftTo(f,n),h<0&&r.ZERO.subTo(n,n)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var r=3&t;return(r=(r=(r=(r=r*(2-(15&t)*r)&15)*(2-(255&t)*r)&255)*(2-((65535&t)*r&65535))&65535)*(2-t*r%this.DV)%this.DV)>0?this.DV-r:-r},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,i){if(t>4294967295||t<1)return r.ONE;var n=e(),o=e(),s=i.convert(this),u=l(t)-1;for(s.copyTo(n);--u>=0;)if(i.sqrTo(n,o),(t&1<<u)>0)i.mulTo(o,s,n);else{var h=n;n=o,o=h}return i.revert(n)},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.toRadix(t);r=2}var e,i=(1<<r)-1,n=!1,o="",s=this.t,u=this.DB-s*this.DB%r;if(s-- >0)for(u<this.DB&&(e=this[s]>>u)>0&&(n=!0,o=h(e));s>=0;)u<r?(e=(this[s]&(1<<u)-1)<<r-u,e|=this[--s]>>(u+=this.DB-r)):(e=this[s]>>(u-=r)&i,u<=0&&(u+=this.DB,--s)),e>0&&(n=!0),n&&(o+=h(e));return n?o:"0"},r.prototype.negate=function(){var t=e();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var r=this.s-t.s;if(0!=r)return r;var e=this.t;if(0!=(r=e-t.t))return this.s<0?-r:r;for(;--e>=0;)if(0!=(r=this[e]-t[e]))return r;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var i=e();return this.abs().divRemTo(t,null,i),this.s<0&&i.compareTo(r.ZERO)>0&&t.subTo(i,i),i},r.prototype.modPowInt=function(t,r){var e;return e=t<256||r.isEven()?new p(r):new y(r),this.exp(t,e)},r.ZERO=f(0),r.ONE=f(1),b.prototype.convert=F,b.prototype.revert=F,b.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e)},b.prototype.sqrTo=function(t,r){t.squareTo(r)},B.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var r=e();return t.copyTo(r),this.reduce(r),r},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},B.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},B.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)};var x,q,S,E=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],I=(1<<26)/E[E.length-1];function D(){var t;t=(new Date).getTime(),q[S++]^=255&t,q[S++]^=t>>8&255,q[S++]^=t>>16&255,q[S++]^=t>>24&255,S>=H&&(S-=H)}if(r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var r=this.chunkSize(t),i=Math.pow(t,r),n=f(i),o=e(),s=e(),u="";for(this.divRemTo(n,o,s);o.signum()>0;)u=(i+s.intValue()).toString(t).substr(1)+u,o.divRemTo(n,o,s);return s.intValue().toString(t)+u},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),o=!1,s=0,u=0,h=0;h<t.length;++h){var f=a(t,h);f<0?"-"==t.charAt(h)&&0==this.signum()&&(o=!0):(u=e*u+f,++s>=i&&(this.dMultiply(n),this.dAddOffset(u,0),s=0,u=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(u,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),d,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var n=new Array,o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},r.prototype.bitwiseTo=function(t,r,e){var i,n,o=Math.min(t.t,this.t);for(i=0;i<o;++i)e[i]=r(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=o;i<this.t;++i)e[i]=r(this[i],n);e.t=this.t}else{for(n=this.s&this.DM,i=o;i<t.t;++i)e[i]=r(n,t[i]);e.t=t.t}e.s=r(this.s,t.s),e.clamp()},r.prototype.changeBit=function(t,e){var i=r.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},r.prototype.addTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]+t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i+=t[e],r[e++]=i&this.DM,i>>=this.DB;i+=t.s}r.s=i<0?-1:0,i>0?r[e++]=i:i<-1&&(r[e++]=this.DV+i),r.t=e,r.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,r){if(0!=t){for(;this.t<=r;)this[this.t++]=0;for(this[r]+=t;this[r]>=this.DV;)this[r]-=this.DV,++r>=this.t&&(this[this.t++]=0),++this[r]}},r.prototype.multiplyLowerTo=function(t,r,e){var i,n=Math.min(this.t+t.t,r);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(i=e.t-this.t;n<i;++n)e[n+this.t]=this.am(0,t[n],e,n,0,this.t);for(i=Math.min(t.t,r);n<i;++n)this.am(0,t[n],e,n,0,r-n);e.clamp()},r.prototype.multiplyUpperTo=function(t,r,e){--r;var i=e.t=this.t+t.t-r;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(r-this.t,0);i<t.t;++i)e[this.t+i-r]=this.am(r-i,t[i],e,0,0,this.t+i-r);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(t){if(t<=0)return 0;var r=this.DV%t,e=this.s<0?t-1:0;if(this.t>0)if(0==r)e=this[0]%t;else for(var i=this.t-1;i>=0;--i)e=(r*e+this[i])%t;return e},r.prototype.millerRabin=function(t){var i=this.subtract(r.ONE),n=i.getLowestSetBit();if(n<=0)return!1;var o=i.shiftRight(n);(t=t+1>>1)>E.length&&(t=E.length);for(var s=e(),u=0;u<t;++u){s.fromInt(E[Math.floor(Math.random()*E.length)]);var h=s.modPow(o,this);if(0!=h.compareTo(r.ONE)&&0!=h.compareTo(i)){for(var a=1;a++<n&&0!=h.compareTo(i);)if(0==(h=h.modPowInt(2,this)).compareTo(r.ONE))return!1;if(0!=h.compareTo(i))return!1}}return!0},r.prototype.clone=function(){var t=e();return this.copyTo(t),t},r.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,r=new Array;r[0]=this.s;var e,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(e=this[t]>>i)!=(this.s&this.DM)>>i&&(r[n++]=e|this.s<<this.DB-i);t>=0;)i<8?(e=(this[t]&(1<<i)-1)<<8-i,e|=this[--t]>>(i+=this.DB-8)):(e=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&e&&(e|=-256),0==n&&(128&this.s)!=(128&e)&&++n,(n>0||e!=this.s)&&(r[n++]=e);return r},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var r=e();return this.bitwiseTo(t,g,r),r},r.prototype.or=function(t){var r=e();return this.bitwiseTo(t,d,r),r},r.prototype.xor=function(t){var r=e();return this.bitwiseTo(t,m,r),r},r.prototype.andNot=function(t){var r=e();return this.bitwiseTo(t,v,r),r},r.prototype.not=function(){for(var t=e(),r=0;r<this.t;++r)t[r]=this.DM&~this[r];return t.t=this.t,t.s=~this.s,t},r.prototype.shiftLeft=function(t){var r=e();return t<0?this.rShiftTo(-t,r):this.lShiftTo(t,r),r},r.prototype.shiftRight=function(t){var r=e();return t<0?this.lShiftTo(-t,r):this.rShiftTo(t,r),r},r.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+T(this[t]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var t=0,r=this.s&this.DM,e=0;e<this.t;++e)t+=w(this[e]^r);return t},r.prototype.testBit=function(t){var r=Math.floor(t/this.DB);return r>=this.t?0!=this.s:!!(this[r]&1<<t%this.DB)},r.prototype.setBit=function(t){return this.changeBit(t,d)},r.prototype.clearBit=function(t){return this.changeBit(t,v)},r.prototype.flipBit=function(t){return this.changeBit(t,m)},r.prototype.add=function(t){var r=e();return this.addTo(t,r),r},r.prototype.subtract=function(t){var r=e();return this.subTo(t,r),r},r.prototype.multiply=function(t){var r=e();return this.multiplyTo(t,r),r},r.prototype.divide=function(t){var r=e();return this.divRemTo(t,r,null),r},r.prototype.remainder=function(t){var r=e();return this.divRemTo(t,null,r),r},r.prototype.divideAndRemainder=function(t){var r=e(),i=e();return this.divRemTo(t,r,i),new Array(r,i)},r.prototype.modPow=function(t,r){var i,n,o=t.bitLength(),s=f(1);if(o<=0)return s;i=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new p(r):r.isEven()?new B(r):new y(r);var u=new Array,h=3,a=i-1,c=(1<<i)-1;if(u[1]=n.convert(this),i>1){var g=e();for(n.sqrTo(u[1],g);h<=c;)u[h]=e(),n.mulTo(g,u[h-2],u[h]),h+=2}var d,m,v=t.t-1,T=!0,w=e();for(o=l(t[v])-1;v>=0;){for(o>=a?d=t[v]>>o-a&c:(d=(t[v]&(1<<o+1)-1)<<a-o,v>0&&(d|=t[v-1]>>this.DB+o-a)),h=i;!(1&d);)d>>=1,--h;if((o-=h)<0&&(o+=this.DB,--v),T)u[d].copyTo(s),T=!1;else{for(;h>1;)n.sqrTo(s,w),n.sqrTo(w,s),h-=2;h>0?n.sqrTo(s,w):(m=s,s=w,w=m),n.mulTo(w,u[d],s)}for(;v>=0&&!(t[v]&1<<o);)n.sqrTo(s,w),m=s,s=w,w=m,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},r.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var i=t.clone(),n=this.clone(),o=f(1),s=f(0),u=f(0),h=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?(u.isEven()&&h.isEven()||(u.addTo(this,u),h.subTo(t,h)),u.rShiftTo(1,u)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);i.compareTo(n)>=0?(i.subTo(n,i),e&&o.subTo(u,o),s.subTo(h,s)):(n.subTo(i,n),e&&u.subTo(o,u),h.subTo(s,h))}return 0!=n.compareTo(r.ONE)?r.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},r.prototype.pow=function(t){return this.exp(t,new b)},r.prototype.gcd=function(t){var r=this.s<0?this.negate():this.clone(),e=t.s<0?t.negate():t.clone();if(r.compareTo(e)<0){var i=r;r=e,e=i}var n=r.getLowestSetBit(),o=e.getLowestSetBit();if(o<0)return r;for(n<o&&(o=n),o>0&&(r.rShiftTo(o,r),e.rShiftTo(o,e));r.signum()>0;)(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),r.compareTo(e)>=0?(r.subTo(e,r),r.rShiftTo(1,r)):(e.subTo(r,e),e.rShiftTo(1,e));return o>0&&e.lShiftTo(o,e),e},r.prototype.isProbablePrime=function(t){var r,e=this.abs();if(1==e.t&&e[0]<=E[E.length-1]){for(r=0;r<E.length;++r)if(e[0]==E[r])return!0;return!1}if(e.isEven())return!1;for(r=1;r<E.length;){for(var i=E[r],n=r+1;n<E.length&&i<I;)i*=E[n++];for(i=e.modInt(i);r<n;)if(i%E[r++]==0)return!1}return e.millerRabin(t)},r.prototype.square=function(){var t=e();return this.squareTo(t),t},r.prototype.Barrett=B,null==q){var A;if(q=new Array,S=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var R=new Uint8Array(32);for(window.crypto.getRandomValues(R),A=0;A<32;++A)q[S++]=R[A]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var P=window.crypto.random(32);for(A=0;A<P.length;++A)q[S++]=255&P.charCodeAt(A)}for(;S<H;)A=Math.floor(65536*Math.random()),q[S++]=A>>>8,q[S++]=255&A;S=0,D()}function O(){if(null==x){for(D(),(x=new M).init(q),S=0;S<q.length;++S)q[S]=0;S=0}return x.next()}function C(){}function M(){this.i=0,this.j=0,this.S=new Array}C.prototype.nextBytes=function(t){var r;for(r=0;r<t.length;++r)t[r]=O()},M.prototype.init=function(t){var r,e,i;for(r=0;r<256;++r)this.S[r]=r;for(e=0,r=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},M.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var H=256;c.exports={default:r,BigInteger:r,SecureRandom:C}}.call(a);var p=l.exports;const{BigInteger:y}=p;class g{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let r=t.toString(16);if(r.length%2==1&&(r="0"+r),t<128)return r;return(128+r.length/2).toString(16)+r}getValue(){return""}}class d extends g{constructor(t){super(),this.t="02",t&&(this.v=function(t){let r=t.toString(16);if("-"!==r[0])r.length%2==1?r="0"+r:r.match(/^[0-7]/)||(r="00"+r);else{r=r.substr(1);let e=r.length;e%2==1?e+=1:r.match(/^[0-7]/)||(e+=2);let i="";for(let t=0;t<e;t++)i+="f";i=new y(i,16),r=i.xor(t).add(y.ONE),r=r.toString(16).replace(/^-/,"")}return r}(t))}getValue(){return this.v}}class m extends g{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map((t=>t.getEncodedHex())).join(""),this.v}}function v(t,r){return+t[r+2]<8?1:128&+t.substr(r+2,2)}function T(t,r){const e=v(t,r),i=t.substr(r+2,2*e);if(!i)return-1;return(+i[0]<8?new y(i,16):new y(i.substr(2),16)).intValue()}function w(t,r){return r+2*(v(t,r)+1)}var b={encodeDer(t,r){const e=new d(t),i=new d(r);return new m([e,i]).getEncodedHex()},decodeDer(t){const r=w(t,0),e=w(t,r),i=T(t,r),n=t.substr(e,2*i),o=e+n.length,s=w(t,o),u=T(t,o),h=t.substr(s,2*u);return{r:new y(n,16),s:new y(h,16)}}};const{BigInteger:F}=p,B=new F("2"),x=new F("3");class q{constructor(t,r){this.x=r,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new q(this.q,this.x.negate().mod(this.q))}add(t){return new q(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new q(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new q(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new q(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new q(this.q,this.x.square().mod(this.q))}}class S{constructor(t,r,e,i){this.curve=t,this.x=r,this.y=e,this.z=null==i?F.ONE:i,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(F.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(F.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(F.ZERO)&&!this.y.toBigInteger().equals(F.ZERO)}negate(){return new S(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const r=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=t.x.toBigInteger(),o=t.y.toBigInteger(),s=t.z,u=this.curve.q,h=r.multiply(s).mod(u),a=n.multiply(i).mod(u),f=h.subtract(a),c=e.multiply(s).mod(u),l=o.multiply(i).mod(u),p=c.subtract(l);if(F.ZERO.equals(f))return F.ZERO.equals(p)?this.twice():this.curve.infinity;const y=h.add(a),g=i.multiply(s).mod(u),d=f.square().mod(u),m=f.multiply(d).mod(u),v=g.multiply(p.square()).subtract(y.multiply(d)).mod(u),T=f.multiply(v).mod(u),w=p.multiply(d.multiply(h).subtract(v)).subtract(c.multiply(m)).mod(u),b=m.multiply(g).mod(u);return new S(this.curve,this.curve.fromBigInteger(T),this.curve.fromBigInteger(w),b)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),r=this.y.toBigInteger(),e=this.z,i=this.curve.q,n=this.curve.a.toBigInteger(),o=t.square().multiply(x).add(n.multiply(e.square())).mod(i),s=r.shiftLeft(1).multiply(e).mod(i),u=r.square().mod(i),h=u.multiply(t).multiply(e).mod(i),a=s.square().mod(i),f=o.square().subtract(h.shiftLeft(3)).mod(i),c=s.multiply(f).mod(i),l=o.multiply(h.shiftLeft(2).subtract(f)).subtract(a.shiftLeft(1).multiply(u)).mod(i),p=s.multiply(a).mod(i);return new S(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),p)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const r=t.multiply(x),e=this.negate();let i=this;for(let n=r.bitLength()-2;n>0;n--){i=i.twice();const o=r.testBit(n);o!==t.testBit(n)&&(i=i.add(o?this:e))}return i}}var E={ECPointFp:S,ECCurveFp:class{constructor(t,r,e){this.q=t,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(e),this.infinity=new S(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new q(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const r=this.fromBigInteger(new F(t.substr(2),16));let e=this.fromBigInteger(r.multiply(r.square()).add(r.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new F("4")).add(F.ONE),this.q));return e.toBigInteger().mod(B).equals(new F(t.substr(0,2),16).subtract(B))||(e=e.negate()),new S(this,r,e);case 4:case 6:case 7:const i=(t.length-2)/2,n=t.substr(2,i),o=t.substr(i+2,i);return new S(this,this.fromBigInteger(new F(n,16)),this.fromBigInteger(new F(o,16)));default:return null}}}};const{BigInteger:I,SecureRandom:D}=p,{ECCurveFp:A}=E,R=new D,{curve:P,G:O,n:C}=M();function M(){const t=new I("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),r=new I("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),e=new I("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),i=new A(t,r,e),n=i.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:i,G:n,n:new I("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function H(t,r){return t.length>=r?t:new Array(r-t.length+1).join("0")+t}var N={getGlobalCurve:function(){return P},generateEcparam:M,generateKeyPairHex:function(t,r,e){const i=(t?new I(t,r,e):new I(C.bitLength(),R)).mod(C.subtract(I.ONE)).add(I.ONE),n=H(i.toString(16),64),o=O.multiply(i);return{privateKey:n,publicKey:"04"+H(o.getX().toBigInteger().toString(16),64)+H(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const r=(t.length-2)/2,e=t.substr(2,r);let i="03";return new I(t.substr(r+2,r),16).mod(new I("2")).equals(I.ZERO)&&(i="02"),i+e},utf8ToHex:function(t){const r=(t=unescape(encodeURIComponent(t))).length,e=[];for(let i=0;i<r;i++)e[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;t<r;t++){const r=e[t>>>2]>>>24-t%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},leftPad:H,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const r=[];let e=0;for(let i=0;i<2*t.length;i+=2)r[i>>>3]|=parseInt(t[e],10)<<24-i%8*4,e++;try{const e=[];for(let i=0;i<t.length;i++){const t=r[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(t))}return decodeURIComponent(escape(e.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const r=[];let e=t.length;e%2!=0&&(t=H(t,e+1)),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r},verifyPublicKey:function(t){const r=P.decodePointHex(t);if(!r)return!1;const e=r.getX();return r.getY().square().equals(e.multiply(e.square()).add(e.multiply(P.a)).add(P.b))},comparePublicKeyHex:function(t,r){const e=P.decodePointHex(t);if(!e)return!1;const i=P.decodePointHex(r);return!!i&&e.equals(i)}};const K=new Uint32Array(68),V=new Uint32Array(64);function L(t,r){const e=31&r;return t<<e|t>>>32-e}function z(t,r){const e=[];for(let i=t.length-1;i>=0;i--)e[i]=255&(t[i]^r[i]);return e}function k(t){return t^L(t,9)^L(t,17)}function Z(t){let r=8*t.length,e=r%512;e=e>=448?512-e%448-1:448-e-1;const i=new Array((e-7)/8),n=new Array(8);for(let t=0,r=i.length;t<r;t++)i[t]=0;for(let t=0,r=n.length;t<r;t++)n[t]=0;r=r.toString(2);for(let t=7;t>=0;t--)if(r.length>8){const e=r.length-8;n[t]=parseInt(r.substr(e),2),r=r.substr(0,e)}else r.length>0&&(n[t]=parseInt(r,2),r="");const o=new Uint8Array([...t,128,...i,...n]),s=new DataView(o.buffer,0),u=o.length/64,h=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<u;t++){K.fill(0),V.fill(0);const r=16*t;for(let t=0;t<16;t++)K[t]=s.getUint32(4*(r+t),!1);for(let t=16;t<68;t++)K[t]=(a=K[t-16]^K[t-9]^L(K[t-3],15))^L(a,15)^L(a,23)^L(K[t-13],7)^K[t-6];for(let t=0;t<64;t++)V[t]=K[t]^K[t+4];const e=2043430169,i=2055708042;let n,o,u,f,c,l=h[0],p=h[1],y=h[2],g=h[3],d=h[4],m=h[5],v=h[6],T=h[7];for(let t=0;t<64;t++)c=t>=0&&t<=15?e:i,n=L(L(l,12)+d+L(c,t),7),o=n^L(l,12),u=(t>=0&&t<=15?l^p^y:l&p|l&y|p&y)+g+o+V[t],f=(t>=0&&t<=15?d^m^v:d&m|~d&v)+T+n+K[t],g=y,y=L(p,9),p=l,l=u,T=v,v=L(m,19),m=d,d=k(f);h[0]^=l,h[1]^=p,h[2]^=y,h[3]^=g,h[4]^=d,h[5]^=m,h[6]^=v,h[7]^=T}var a;const f=[];for(let t=0,r=h.length;t<r;t++){const r=h[t];f.push((4278190080&r)>>>24,(16711680&r)>>>16,(65280&r)>>>8,255&r)}return f}const j=new Uint8Array(64),U=new Uint8Array(64);for(let t=0;t<64;t++)j[t]=54,U[t]=92;var _={sm3:Z,hmac:function(t,r){for(r.length>64&&(r=Z(r));r.length<64;)r.push(0);const e=z(r,j),i=z(r,U),n=Z([...e,...t]);return Z([...i,...n])}};const{BigInteger:$}=p,{encodeDer:X,decodeDer:J}=b,Y=N,G=_.sm3,{G:W,curve:Q,n:tt}=Y.generateEcparam();function rt(t,r,e="1234567812345678"){e=Y.utf8ToHex(e);const i=Y.leftPad(W.curve.a.toBigInteger().toRadix(16),64),n=Y.leftPad(W.curve.b.toBigInteger().toRadix(16),64),o=Y.leftPad(W.getX().toBigInteger().toRadix(16),64),s=Y.leftPad(W.getY().toBigInteger().toRadix(16),64);let u,h;if(128===r.length)u=r.substr(0,64),h=r.substr(64,64);else{const t=W.curve.decodePointHex(r);u=Y.leftPad(t.getX().toBigInteger().toRadix(16),64),h=Y.leftPad(t.getY().toBigInteger().toRadix(16),64)}const a=Y.hexToArray(e+i+n+o+s+u+h),f=4*e.length;a.unshift(255&f),a.unshift(f>>8&255);const c=G(a);return Y.arrayToHex(G(c.concat(Y.hexToArray(t))))}function et(t){const r=W.multiply(new $(t,16));return"04"+Y.leftPad(r.getX().toBigInteger().toString(16),64)+Y.leftPad(r.getY().toBigInteger().toString(16),64)}function it(){const t=Y.generateKeyPairHex(),r=Q.decodePointHex(t.publicKey);return t.k=new $(t.privateKey,16),t.x1=r.getX().toBigInteger(),t}var nt={generateKeyPairHex:Y.generateKeyPairHex,compressPublicKeyHex:Y.compressPublicKeyHex,comparePublicKeyHex:Y.comparePublicKeyHex,doEncrypt:function(t,r,e=1){t="string"==typeof t?Y.hexToArray(Y.utf8ToHex(t)):Array.prototype.slice.call(t),r=Y.getGlobalCurve().decodePointHex(r);const i=Y.generateKeyPairHex(),n=new $(i.privateKey,16);let o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));const s=r.multiply(n),u=Y.hexToArray(Y.leftPad(s.getX().toBigInteger().toRadix(16),64)),h=Y.hexToArray(Y.leftPad(s.getY().toBigInteger().toRadix(16),64)),a=Y.arrayToHex(G([].concat(u,t,h)));let f=1,c=0,l=[];const p=[].concat(u,h),y=()=>{l=G([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let r=0,e=t.length;r<e;r++)c===l.length&&y(),t[r]^=255&l[c++];const g=Y.arrayToHex(t);return 0===e?o+g+a:o+a+g},doDecrypt:function(t,r,e=1,{output:i="string"}={}){r=new $(r,16);let n=t.substr(128,64),o=t.substr(192);0===e&&(n=t.substr(t.length-64),o=t.substr(128,t.length-128-64));const s=Y.hexToArray(o),u=Y.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(r),h=Y.hexToArray(Y.leftPad(u.getX().toBigInteger().toRadix(16),64)),a=Y.hexToArray(Y.leftPad(u.getY().toBigInteger().toRadix(16),64));let f=1,c=0,l=[];const p=[].concat(h,a),y=()=>{l=G([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let t=0,r=s.length;t<r;t++)c===l.length&&y(),s[t]^=255&l[c++];return Y.arrayToHex(G([].concat(h,s,a)))===n.toLowerCase()?"array"===i?s:Y.arrayToUtf8(s):"array"===i?[]:""},doSignature:function(t,r,{pointPool:e,der:i,hash:n,publicKey:o,userId:s}={}){let u="string"==typeof t?Y.utf8ToHex(t):Y.arrayToHex(t);n&&(u=rt(u,o=o||et(r),s));const h=new $(r,16),a=new $(u,16);let f=null,c=null,l=null;do{do{let t;t=e&&e.length?e.pop():it(),f=t.k,c=a.add(t.x1).mod(tt)}while(c.equals($.ZERO)||c.add(f).equals(tt));l=h.add($.ONE).modInverse(tt).multiply(f.subtract(c.multiply(h))).mod(tt)}while(l.equals($.ZERO));return i?X(c,l):Y.leftPad(c.toString(16),64)+Y.leftPad(l.toString(16),64)},doVerifySignature:function(t,r,e,{der:i,hash:n,userId:o}={}){let s,u,h="string"==typeof t?Y.utf8ToHex(t):Y.arrayToHex(t);if(n&&(h=rt(h,e,o)),i){const t=J(r);s=t.r,u=t.s}else s=new $(r.substring(0,64),16),u=new $(r.substring(64),16);const a=Q.decodePointHex(e),f=new $(h,16),c=s.add(u).mod(tt);if(c.equals($.ZERO))return!1;const l=W.multiply(u).add(a.multiply(c)),p=f.add(l.getX().toBigInteger()).mod(tt);return s.equals(p)},getPublicKeyFromPrivateKey:et,getPoint:it,verifyPublicKey:Y.verifyPublicKey};const{sm3:ot,hmac:st}=_;function ut(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}function ht(t){const r=[];let e=t.length;var i,n;e%2!=0&&(n=e+1,t=(i=t).length>=n?i:new Array(n-i.length+1).join("0")+i),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r}const at=0,ft=16,ct=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],lt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function pt(t){const r=[];for(let e=0,i=t.length;e<i;e+=2)r.push(parseInt(t.substr(e,2),16));return r}function yt(t,r){const e=31&r;return t<<e|t>>>32-e}function gt(t){return(255&ct[t>>>24&255])<<24|(255&ct[t>>>16&255])<<16|(255&ct[t>>>8&255])<<8|255&ct[255&t]}function dt(t){return t^yt(t,2)^yt(t,10)^yt(t,18)^yt(t,24)}function mt(t){return t^yt(t,13)^yt(t,23)}function vt(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[4*r],n[1]=255&t[4*r+1],n[2]=255&t[4*r+2],n[3]=255&t[4*r+3],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,r=0;r<32;r+=4)t=i[1]^i[2]^i[3]^e[r+0],i[0]^=dt(gt(t)),t=i[2]^i[3]^i[0]^e[r+1],i[1]^=dt(gt(t)),t=i[3]^i[0]^i[1]^e[r+2],i[2]^=dt(gt(t)),t=i[0]^i[1]^i[2]^e[r+3],i[3]^=dt(gt(t));for(let t=0;t<16;t+=4)r[t]=i[3-t/4]>>>24&255,r[t+1]=i[3-t/4]>>>16&255,r[t+2]=i[3-t/4]>>>8&255,r[t+3]=255&i[3-t/4]}function Tt(t,r,e,{padding:i="pkcs#7",mode:n,iv:o=[],output:s="string"}={}){if("cbc"===n&&("string"==typeof o&&(o=pt(o)),16!==o.length))throw new Error("iv is invalid");if("string"==typeof r&&(r=pt(r)),16!==r.length)throw new Error("key is invalid");if(t="string"==typeof t?e!==at?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):pt(t):[...t],("pkcs#5"===i||"pkcs#7"===i)&&e!==at){const r=ft-t.length%ft;for(let e=0;e<r;e++)t.push(r)}const u=new Array(32);!function(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[0+4*r],n[1]=255&t[1+4*r],n[2]=255&t[2+4*r],n[3]=255&t[3+4*r],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];i[0]^=2746333894,i[1]^=1453994832,i[2]^=1736282519,i[3]^=2993693404;for(let t,e=0;e<32;e+=4)t=i[1]^i[2]^i[3]^lt[e+0],r[e+0]=i[0]^=mt(gt(t)),t=i[2]^i[3]^i[0]^lt[e+1],r[e+1]=i[1]^=mt(gt(t)),t=i[3]^i[0]^i[1]^lt[e+2],r[e+2]=i[2]^=mt(gt(t)),t=i[0]^i[1]^i[2]^lt[e+3],r[e+3]=i[3]^=mt(gt(t));if(e===at)for(let t,e=0;e<16;e++)t=r[e],r[e]=r[31-e],r[31-e]=t}(r,u,e);const h=[];let a=o,f=t.length,c=0;for(;f>=ft;){const r=t.slice(c,c+16),i=new Array(16);if("cbc"===n)for(let t=0;t<ft;t++)e!==at&&(r[t]^=a[t]);vt(r,i,u);for(let t=0;t<ft;t++)"cbc"===n&&e===at&&(i[t]^=a[t]),h[c+t]=i[t];"cbc"===n&&(a=e!==at?i:r),f-=ft,c+=ft}if(("pkcs#5"===i||"pkcs#7"===i)&&e===at){const t=h.length,r=h[t-1];for(let e=1;e<=r;e++)if(h[t-e]!==r)throw new Error("padding is invalid");h.splice(t-r,r)}return"array"!==s?e!==at?h.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const r=[];for(let e=0,i=t.length;e<i;e++)t[e]>=240&&t[e]<=247?(r.push(String.fromCodePoint(((7&t[e])<<18)+((63&t[e+1])<<12)+((63&t[e+2])<<6)+(63&t[e+3]))),e+=3):t[e]>=224&&t[e]<=239?(r.push(String.fromCodePoint(((15&t[e])<<12)+((63&t[e+1])<<6)+(63&t[e+2]))),e+=2):t[e]>=192&&t[e]<=223?(r.push(String.fromCodePoint(((31&t[e])<<6)+(63&t[e+1]))),e++):r.push(String.fromCodePoint(t[e]));return r.join("")}(h):h}var wt={sm2:nt,sm3:function(t,r){if(t="string"==typeof t?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):Array.prototype.slice.call(t),r){if("hmac"!==(r.mode||"hmac"))throw new Error("invalid mode");let e=r.key;if(!e)throw new Error("invalid key");return e="string"==typeof e?ht(e):Array.prototype.slice.call(e),ut(st(t,e))}return ut(ot(t))},sm4:{encrypt:(t,r,e)=>Tt(t,r,1,e),decrypt:(t,r,e)=>Tt(t,r,0,e)}};const bt={mode:"ecb",padding:"pkcs#5",output:"array"},Ft=r.Buffer,Bt=function(t,r,e,i){return(n,o)=>{try{if(o.closeCrypto)return n;t.info=u(),t.publicKey=[...Ft.from(t.info.key)];const s=wt.sm2.doEncrypt(JSON.stringify(t.info),r,1);if(e.set(i,function(t){if("string"==typeof t)return String(t);return JSON.parse(JSON.stringify(t))}(s)),((t,r)=>{t.set("X-Encrypt-Key",r)})(o,"04"+s),n){"string"!=typeof n&&(n=JSON.stringify(n));const r=wt.sm4.encrypt(n,t.publicKey,bt);return n=Ft.from(r)}return n}catch(t){console.error("encrypt error",t,n,o)}}},xt=function(t){return(r,e)=>{try{if((t=>{const r=t.get(i);return r&&"string"==typeof r&&"sm4"===r.toLowerCase()})(e)){const e=Ft.from(r);return o(wt.sm4.decrypt(e,t.publicKey,{mode:"ecb",padding:"pkcs#5"}))}return r}catch(t){console.error("decrypt error",t,r,e)}}};var qt,St,Et={exports:{}},It={exports:{}};qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",St={rotl:function(t,r){return t<<r|t>>>32-r},rotr:function(t,r){return t<<32-r|t>>>r},endian:function(t){if(t.constructor==Number)return 16711935&St.rotl(t,8)|4278255360&St.rotl(t,24);for(var r=0;r<t.length;r++)t[r]=St.endian(t[r]);return t},randomBytes:function(t){for(var r=[];t>0;t--)r.push(Math.floor(256*Math.random()));return r},bytesToWords:function(t){for(var r=[],e=0,i=0;e<t.length;e++,i+=8)r[i>>>5]|=t[e]<<24-i%32;return r},wordsToBytes:function(t){for(var r=[],e=0;e<32*t.length;e+=8)r.push(t[e>>>5]>>>24-e%32&255);return r},bytesToHex:function(t){for(var r=[],e=0;e<t.length;e++)r.push((t[e]>>>4).toString(16)),r.push((15&t[e]).toString(16));return r.join("")},hexToBytes:function(t){for(var r=[],e=0;e<t.length;e+=2)r.push(parseInt(t.substr(e,2),16));return r},bytesToBase64:function(t){for(var r=[],e=0;e<t.length;e+=3)for(var i=t[e]<<16|t[e+1]<<8|t[e+2],n=0;n<4;n++)8*e+6*n<=8*t.length?r.push(qt.charAt(i>>>6*(3-n)&63)):r.push("=");return r.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var r=[],e=0,i=0;e<t.length;i=++e%4)0!=i&&r.push((qt.indexOf(t.charAt(e-1))&Math.pow(2,-2*i+8)-1)<<2*i|qt.indexOf(t.charAt(e))>>>6-2*i);return r}},It.exports=St;var Dt=It.exports,At={utf8:{stringToBytes:function(t){return At.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(At.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var r=[],e=0;e<t.length;e++)r.push(255&t.charCodeAt(e));return r},bytesToString:function(t){for(var r=[],e=0;e<t.length;e++)r.push(String.fromCharCode(t[e]));return r.join("")}}},Rt=At,Pt=function(t){return null!=t&&(Ot(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Ot(t.slice(0,0))}(t)||!!t._isBuffer)};function Ot(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(){var t=Dt,r=Rt.utf8,e=Pt,i=Rt.bin,n=function(o,s){o.constructor==String?o=s&&"binary"===s.encoding?i.stringToBytes(o):r.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):Array.isArray(o)||o.constructor===Uint8Array||(o=o.toString());for(var u=t.bytesToWords(o),h=8*o.length,a=1732584193,f=-271733879,c=-1732584194,l=271733878,p=0;p<u.length;p++)u[p]=16711935&(u[p]<<8|u[p]>>>24)|4278255360&(u[p]<<24|u[p]>>>8);u[h>>>5]|=128<<h%32,u[14+(h+64>>>9<<4)]=h;var y=n._ff,g=n._gg,d=n._hh,m=n._ii;for(p=0;p<u.length;p+=16){var v=a,T=f,w=c,b=l;a=y(a,f,c,l,u[p+0],7,-680876936),l=y(l,a,f,c,u[p+1],12,-389564586),c=y(c,l,a,f,u[p+2],17,606105819),f=y(f,c,l,a,u[p+3],22,-1044525330),a=y(a,f,c,l,u[p+4],7,-176418897),l=y(l,a,f,c,u[p+5],12,1200080426),c=y(c,l,a,f,u[p+6],17,-1473231341),f=y(f,c,l,a,u[p+7],22,-45705983),a=y(a,f,c,l,u[p+8],7,1770035416),l=y(l,a,f,c,u[p+9],12,-1958414417),c=y(c,l,a,f,u[p+10],17,-42063),f=y(f,c,l,a,u[p+11],22,-1990404162),a=y(a,f,c,l,u[p+12],7,1804603682),l=y(l,a,f,c,u[p+13],12,-40341101),c=y(c,l,a,f,u[p+14],17,-1502002290),a=g(a,f=y(f,c,l,a,u[p+15],22,1236535329),c,l,u[p+1],5,-165796510),l=g(l,a,f,c,u[p+6],9,-1069501632),c=g(c,l,a,f,u[p+11],14,643717713),f=g(f,c,l,a,u[p+0],20,-373897302),a=g(a,f,c,l,u[p+5],5,-701558691),l=g(l,a,f,c,u[p+10],9,38016083),c=g(c,l,a,f,u[p+15],14,-660478335),f=g(f,c,l,a,u[p+4],20,-405537848),a=g(a,f,c,l,u[p+9],5,568446438),l=g(l,a,f,c,u[p+14],9,-1019803690),c=g(c,l,a,f,u[p+3],14,-187363961),f=g(f,c,l,a,u[p+8],20,1163531501),a=g(a,f,c,l,u[p+13],5,-1444681467),l=g(l,a,f,c,u[p+2],9,-51403784),c=g(c,l,a,f,u[p+7],14,1735328473),a=d(a,f=g(f,c,l,a,u[p+12],20,-1926607734),c,l,u[p+5],4,-378558),l=d(l,a,f,c,u[p+8],11,-2022574463),c=d(c,l,a,f,u[p+11],16,1839030562),f=d(f,c,l,a,u[p+14],23,-35309556),a=d(a,f,c,l,u[p+1],4,-1530992060),l=d(l,a,f,c,u[p+4],11,1272893353),c=d(c,l,a,f,u[p+7],16,-155497632),f=d(f,c,l,a,u[p+10],23,-1094730640),a=d(a,f,c,l,u[p+13],4,681279174),l=d(l,a,f,c,u[p+0],11,-358537222),c=d(c,l,a,f,u[p+3],16,-722521979),f=d(f,c,l,a,u[p+6],23,76029189),a=d(a,f,c,l,u[p+9],4,-640364487),l=d(l,a,f,c,u[p+12],11,-421815835),c=d(c,l,a,f,u[p+15],16,530742520),a=m(a,f=d(f,c,l,a,u[p+2],23,-995338651),c,l,u[p+0],6,-198630844),l=m(l,a,f,c,u[p+7],10,1126891415),c=m(c,l,a,f,u[p+14],15,-1416354905),f=m(f,c,l,a,u[p+5],21,-57434055),a=m(a,f,c,l,u[p+12],6,1700485571),l=m(l,a,f,c,u[p+3],10,-1894986606),c=m(c,l,a,f,u[p+10],15,-1051523),f=m(f,c,l,a,u[p+1],21,-2054922799),a=m(a,f,c,l,u[p+8],6,1873313359),l=m(l,a,f,c,u[p+15],10,-30611744),c=m(c,l,a,f,u[p+6],15,-1560198380),f=m(f,c,l,a,u[p+13],21,1309151649),a=m(a,f,c,l,u[p+4],6,-145523070),l=m(l,a,f,c,u[p+11],10,-1120210379),c=m(c,l,a,f,u[p+2],15,718787259),f=m(f,c,l,a,u[p+9],21,-343485551),a=a+v>>>0,f=f+T>>>0,c=c+w>>>0,l=l+b>>>0}return t.endian([a,f,c,l])};n._ff=function(t,r,e,i,n,o,s){var u=t+(r&e|~r&i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._gg=function(t,r,e,i,n,o,s){var u=t+(r&i|e&~i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._hh=function(t,r,e,i,n,o,s){var u=t+(r^e^i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._ii=function(t,r,e,i,n,o,s){var u=t+(e^(r|~i))+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._blocksize=16,n._digestsize=16,Et.exports=function(r,e){if(null==r)throw new Error("Illegal argument "+r);var o=t.wordsToBytes(n(r,e));return e&&e.asBytes?o:e&&e.asString?i.bytesToString(o):t.bytesToHex(o)}}();var Ct=f(Et.exports);const Mt=function(){const t=new Map;return{get:function(r){return t.get(r)},generateKey:function(t,r,i){try{const e="e0c7ff",n=((t,r)=>{const e=window.location.origin,i=new URL(e+t);for(const t in r)i.searchParams.append(t,r[t]);return i.toString()})(t,r??{}),o=`${n}-${e}-${i??""}`;return`${Ct(o)}-/${t}`}catch(r){return`${e(10)}-/${t}`}},set:function(r,e){t.set(r,e)},clear:function(r){t.delete(r)}}}();window.__buffer=r;const Ht=wt.sm2.doDecrypt;exports.createCryptoAxiosInstance=(r,e,u)=>{const h=t.create(r);return h.interceptors.request.use((t=>{const r=localStorage.getItem("cps_lang"),e={en:"en-US",ko:"ko-KR",zh:"zh-CN"};if(r&&Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];t.headers.set({"Accept-Language":`${i},zh;q=0.9,en;q=0.8`})}return t})),u||function(t,r){if(!r||"string"!=typeof r)throw new Error(`publicKey is required and must be a string ${r}`);t.interceptors.request.use((t=>{const e=t.transformRequest,i=t?.headers?.__requestKey,n={info:null,publicKey:[]};if(!e)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(e))throw new Error(`transformRequest ${e} is not an array`);e.push(Bt(n,r,Mt,i));const o=xt(n);if(!o)return t;const s=t.transformResponse;if(!s)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof o)throw new Error(`decryptFn ${o} is not a function`);if(!Array.isArray(s))throw new Error(`transformResponse ${s} is not an array`);return s.unshift(o),t})),t.interceptors.request.use((t=>{try{const r=encodeURI(t?.url??""),e=t.headers;return r?(e.__requestKey=Mt.generateKey(r,t?.params,e?.get("Authorization")),t):t}catch(r){return console.error("error",r),t}})),t.interceptors.request.use((t=>(t.headers.closeCrypto||(t.responseType="arraybuffer"),t))),t.interceptors.request.use((t=>{const r=t.data,e=t.headers;return r?((r instanceof FormData||r instanceof File)&&(e.closeCrypto=!0),t):t})),t.interceptors.request.use((t=>{const r=t.url,e=t.headers;if(!r)throw new Error("url is required");return{}.hasOwnProperty.call(e,"closeCrypto")||s(r)||(e.closeCrypto=!0),t})),t.interceptors.response.use((t=>{const{request:r,headers:e}=t;return e&&e.get(i)||"arraybuffer"===r?.responseType?.toLowerCase()||"blob"===r?.responseType?.toLowerCase()||(t.data=o(t.data)),t}),(t=>{const r=t.response;throw r?.data&&(r.data=n(r.data)),t}))}(h,e),h},exports.createRequestInstance=(r,e)=>{const i=t.create(r);return function(t,r){if(!r)return t;const{encryptFn:e,decryptFn:i}=r();e&&t.interceptors.request.use((t=>{const r=t.transformRequest;if(!r)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(r))throw new Error(`transformRequest ${r} is not an array`);if(r.push(e),!i)return t;const n=t.transformResponse;if(!n)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof i)throw new Error(`decryptFn ${i} is not a function`);if(!Array.isArray(n))throw new Error(`transformResponse ${n} is not an array`);return n.unshift(i),t}))}(i,e),i},exports.decryptHeadersInfo=Ht,exports.getCryptoInfo=u,exports.getSm4EncryptConfig=h,exports.randomPassword=e,exports.shouldEncrypt=s; |
@@ -1,1 +0,1 @@ | ||
import t from"axios";import r from"buffer";const e=(r,e)=>{const i=t.create(r);return function(t,r){if(!r)return t;const{encryptFn:e,decryptFn:i}=r();e&&t.interceptors.request.use((t=>{const r=t.transformRequest;if(!r)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(r))throw new Error(`transformRequest ${r} is not an array`);if(r.push(e),!i)return t;const n=t.transformResponse;if(!n)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof i)throw new Error(`decryptFn ${i} is not a function`);if(!Array.isArray(n))throw new Error(`transformResponse ${n} is not an array`);return n.unshift(i),t}))}(i,e),i};const i=(t=16,r="high")=>{const e=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],i=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=[0,1,2,3,4,5,6,7,8,9],o=["!","@","-","_","=","<",">","#","*","%","+","&","^","$"],s=[];let u="";const h=function(...t){let r="";return t.forEach((t=>{r+=t[Math.floor(Math.random()*t.length)]})),r};switch(r){case"high":u+=h(e,i,n,o),s.push(...e,...i,...n,...o);break;case"medium":u+=h(e,i,n),s.push(...e,...i,...n);break;default:u+=h(e,n),s.push(...e,...n)}const a=t-u.length;for(let t=0;t<a;t++)u+=h(s);return u},n="X-Encrypt-With";function o(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){throw console.error("error",t),t}if(t instanceof ArrayBuffer){const r=function(t,r="utf-8"){return new TextDecoder(r).decode(t)}(t);try{return JSON.parse(r)}catch(t){return console.error("尝试转换失败",t),r}}return t}function s(t){try{return"string"==typeof t?JSON.parse(t):t}catch(r){return console.error("transform string to JSON data",{data:t,e:r}),t}}const u=t=>{let r=!0;return!(t=>/^\/bi-api\/api/.test(t))(t)&&(t.startsWith("/api")&&(r=!1,(t=>/^\/(api\/logmanage|api\/data-source|api\/enterpriseadmin|api\/componentmanager|api\/spacemanager|api\/filemanager)/.test(t))(t)&&(r=!0)),r)},h=t=>({...{key:i(16,"high"),algorithm:t||"SM4"}}),a=()=>({mode:"ecb",padding:"pkcs#5",output:"array"});var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var l,p={exports:{}};l=p,function(){var t;function r(t,r,e){null!=t&&("number"==typeof t?this.fromNumber(t,r,e):null==r&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,r))}function e(){return new r(null)}var i="undefined"!=typeof navigator;i&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(var s=32767&r,u=r>>15;--o>=0;){var h=32767&this[t],a=this[t++]>>15,f=u*h+a*s;n=((h=s*h+((32767&f)<<15)+e[i]+(1073741823&n))>>>30)+(f>>>15)+u*a+(n>>>30),e[i++]=1073741823&h}return n},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(;--o>=0;){var s=r*this[t++]+e[i]+n;n=Math.floor(s/67108864),e[i++]=67108863&s}return n},t=26):(r.prototype.am=function(t,r,e,i,n,o){for(var s=16383&r,u=r>>14;--o>=0;){var h=16383&this[t],a=this[t++]>>14,f=u*h+a*s;n=((h=s*h+((16383&f)<<14)+e[i]+n)>>28)+(f>>14)+u*a,e[i++]=268435455&h}return n},t=28),r.prototype.DB=t,r.prototype.DM=(1<<t)-1,r.prototype.DV=1<<t,r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-t,r.prototype.F2=2*t-52;var n,o,s="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(n="0".charCodeAt(0),o=0;o<=9;++o)u[n++]=o;for(n="a".charCodeAt(0),o=10;o<36;++o)u[n++]=o;for(n="A".charCodeAt(0),o=10;o<36;++o)u[n++]=o;function h(t){return s.charAt(t)}function a(t,r){var e=u[t.charCodeAt(r)];return null==e?-1:e}function f(t){var r=e();return r.fromInt(t),r}function c(t){var r,e=1;return 0!=(r=t>>>16)&&(t=r,e+=16),0!=(r=t>>8)&&(t=r,e+=8),0!=(r=t>>4)&&(t=r,e+=4),0!=(r=t>>2)&&(t=r,e+=2),0!=(r=t>>1)&&(t=r,e+=1),e}function p(t){this.m=t}function y(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function g(t,r){return t&r}function d(t,r){return t|r}function m(t,r){return t^r}function v(t,r){return t&~r}function T(t){if(0==t)return-1;var r=0;return 65535&t||(t>>=16,r+=16),255&t||(t>>=8,r+=8),15&t||(t>>=4,r+=4),3&t||(t>>=2,r+=2),1&t||++r,r}function w(t){for(var r=0;0!=t;)t&=t-1,++r;return r}function b(){}function F(t){return t}function B(t){this.r2=e(),this.q3=e(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},p.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},p.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},y.prototype.convert=function(t){var i=e();return t.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),t.s<0&&i.compareTo(r.ZERO)>0&&this.m.subTo(i,i),i},y.prototype.revert=function(t){var r=e();return t.copyTo(r),this.reduce(r),r},y.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var r=0;r<this.m.t;++r){var e=32767&t[r],i=e*this.mpl+((e*this.mph+(t[r]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[e=r+this.m.t]+=this.m.am(0,i,t,r,0,this.m.t);t[e]>=t.DV;)t[e]-=t.DV,t[++e]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},y.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},y.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},r.prototype.copyTo=function(t){for(var r=this.t-1;r>=0;--r)t[r]=this[r];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var u=8==i?255&t[n]:a(t,n);u<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=u:s+i>this.DB?(this[this.t-1]|=(u&(1<<this.DB-s)-1)<<s,this[this.t++]=u>>this.DB-s):this[this.t-1]|=u<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,r){var e;for(e=this.t-1;e>=0;--e)r[e+t]=this[e];for(e=t-1;e>=0;--e)r[e]=0;r.t=this.t+t,r.s=this.s},r.prototype.drShiftTo=function(t,r){for(var e=t;e<this.t;++e)r[e-t]=this[e];r.t=Math.max(this.t-t,0),r.s=this.s},r.prototype.lShiftTo=function(t,r){var e,i=t%this.DB,n=this.DB-i,o=(1<<n)-1,s=Math.floor(t/this.DB),u=this.s<<i&this.DM;for(e=this.t-1;e>=0;--e)r[e+s+1]=this[e]>>n|u,u=(this[e]&o)<<i;for(e=s-1;e>=0;--e)r[e]=0;r[s]=u,r.t=this.t+s+1,r.s=this.s,r.clamp()},r.prototype.rShiftTo=function(t,r){r.s=this.s;var e=Math.floor(t/this.DB);if(e>=this.t)r.t=0;else{var i=t%this.DB,n=this.DB-i,o=(1<<i)-1;r[0]=this[e]>>i;for(var s=e+1;s<this.t;++s)r[s-e-1]|=(this[s]&o)<<n,r[s-e]=this[s]>>i;i>0&&(r[this.t-e-1]|=(this.s&o)<<n),r.t=this.t-e,r.clamp()}},r.prototype.subTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]-t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i-=t[e],r[e++]=i&this.DM,i>>=this.DB;i-=t.s}r.s=i<0?-1:0,i<-1?r[e++]=this.DV+i:i>0&&(r[e++]=i),r.t=e,r.clamp()},r.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),o=i.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+i.t]=i.am(0,n[o],e,o,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)},r.prototype.squareTo=function(t){for(var r=this.abs(),e=t.t=2*r.t;--e>=0;)t[e]=0;for(e=0;e<r.t-1;++e){var i=r.am(e,r[e],t,2*e,0,1);(t[e+r.t]+=r.am(e+1,2*r[e],t,2*e+1,i,r.t-e-1))>=r.DV&&(t[e+r.t]-=r.DV,t[e+r.t+1]=1)}t.t>0&&(t[t.t-1]+=r.am(e,r[e],t,2*e,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,i,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=i&&i.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=e());var u=e(),h=this.s,a=t.s,f=this.DB-c(o[o.t-1]);f>0?(o.lShiftTo(f,u),s.lShiftTo(f,n)):(o.copyTo(u),s.copyTo(n));var l=u.t,p=u[l-1];if(0!=p){var y=p*(1<<this.F1)+(l>1?u[l-2]>>this.F2:0),g=this.FV/y,d=(1<<this.F1)/y,m=1<<this.F2,v=n.t,T=v-l,w=null==i?e():i;for(u.dlShiftTo(T,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),r.ONE.dlShiftTo(l,w),w.subTo(u,u);u.t<l;)u[u.t++]=0;for(;--T>=0;){var b=n[--v]==p?this.DM:Math.floor(n[v]*g+(n[v-1]+m)*d);if((n[v]+=u.am(0,b,n,T,0,l))<b)for(u.dlShiftTo(T,w),n.subTo(w,n);n[v]<--b;)n.subTo(w,n)}null!=i&&(n.drShiftTo(l,i),h!=a&&r.ZERO.subTo(i,i)),n.t=l,n.clamp(),f>0&&n.rShiftTo(f,n),h<0&&r.ZERO.subTo(n,n)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var r=3&t;return(r=(r=(r=(r=r*(2-(15&t)*r)&15)*(2-(255&t)*r)&255)*(2-((65535&t)*r&65535))&65535)*(2-t*r%this.DV)%this.DV)>0?this.DV-r:-r},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,i){if(t>4294967295||t<1)return r.ONE;var n=e(),o=e(),s=i.convert(this),u=c(t)-1;for(s.copyTo(n);--u>=0;)if(i.sqrTo(n,o),(t&1<<u)>0)i.mulTo(o,s,n);else{var h=n;n=o,o=h}return i.revert(n)},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.toRadix(t);r=2}var e,i=(1<<r)-1,n=!1,o="",s=this.t,u=this.DB-s*this.DB%r;if(s-- >0)for(u<this.DB&&(e=this[s]>>u)>0&&(n=!0,o=h(e));s>=0;)u<r?(e=(this[s]&(1<<u)-1)<<r-u,e|=this[--s]>>(u+=this.DB-r)):(e=this[s]>>(u-=r)&i,u<=0&&(u+=this.DB,--s)),e>0&&(n=!0),n&&(o+=h(e));return n?o:"0"},r.prototype.negate=function(){var t=e();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var r=this.s-t.s;if(0!=r)return r;var e=this.t;if(0!=(r=e-t.t))return this.s<0?-r:r;for(;--e>=0;)if(0!=(r=this[e]-t[e]))return r;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+c(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var i=e();return this.abs().divRemTo(t,null,i),this.s<0&&i.compareTo(r.ZERO)>0&&t.subTo(i,i),i},r.prototype.modPowInt=function(t,r){var e;return e=t<256||r.isEven()?new p(r):new y(r),this.exp(t,e)},r.ZERO=f(0),r.ONE=f(1),b.prototype.convert=F,b.prototype.revert=F,b.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e)},b.prototype.sqrTo=function(t,r){t.squareTo(r)},B.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var r=e();return t.copyTo(r),this.reduce(r),r},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},B.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},B.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)};var x,S,q,E=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],I=(1<<26)/E[E.length-1];function D(){var t;t=(new Date).getTime(),S[q++]^=255&t,S[q++]^=t>>8&255,S[q++]^=t>>16&255,S[q++]^=t>>24&255,q>=H&&(q-=H)}if(r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var r=this.chunkSize(t),i=Math.pow(t,r),n=f(i),o=e(),s=e(),u="";for(this.divRemTo(n,o,s);o.signum()>0;)u=(i+s.intValue()).toString(t).substr(1)+u,o.divRemTo(n,o,s);return s.intValue().toString(t)+u},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),o=!1,s=0,u=0,h=0;h<t.length;++h){var f=a(t,h);f<0?"-"==t.charAt(h)&&0==this.signum()&&(o=!0):(u=e*u+f,++s>=i&&(this.dMultiply(n),this.dAddOffset(u,0),s=0,u=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(u,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),d,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var n=new Array,o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},r.prototype.bitwiseTo=function(t,r,e){var i,n,o=Math.min(t.t,this.t);for(i=0;i<o;++i)e[i]=r(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=o;i<this.t;++i)e[i]=r(this[i],n);e.t=this.t}else{for(n=this.s&this.DM,i=o;i<t.t;++i)e[i]=r(n,t[i]);e.t=t.t}e.s=r(this.s,t.s),e.clamp()},r.prototype.changeBit=function(t,e){var i=r.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},r.prototype.addTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]+t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i+=t[e],r[e++]=i&this.DM,i>>=this.DB;i+=t.s}r.s=i<0?-1:0,i>0?r[e++]=i:i<-1&&(r[e++]=this.DV+i),r.t=e,r.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,r){if(0!=t){for(;this.t<=r;)this[this.t++]=0;for(this[r]+=t;this[r]>=this.DV;)this[r]-=this.DV,++r>=this.t&&(this[this.t++]=0),++this[r]}},r.prototype.multiplyLowerTo=function(t,r,e){var i,n=Math.min(this.t+t.t,r);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(i=e.t-this.t;n<i;++n)e[n+this.t]=this.am(0,t[n],e,n,0,this.t);for(i=Math.min(t.t,r);n<i;++n)this.am(0,t[n],e,n,0,r-n);e.clamp()},r.prototype.multiplyUpperTo=function(t,r,e){--r;var i=e.t=this.t+t.t-r;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(r-this.t,0);i<t.t;++i)e[this.t+i-r]=this.am(r-i,t[i],e,0,0,this.t+i-r);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(t){if(t<=0)return 0;var r=this.DV%t,e=this.s<0?t-1:0;if(this.t>0)if(0==r)e=this[0]%t;else for(var i=this.t-1;i>=0;--i)e=(r*e+this[i])%t;return e},r.prototype.millerRabin=function(t){var i=this.subtract(r.ONE),n=i.getLowestSetBit();if(n<=0)return!1;var o=i.shiftRight(n);(t=t+1>>1)>E.length&&(t=E.length);for(var s=e(),u=0;u<t;++u){s.fromInt(E[Math.floor(Math.random()*E.length)]);var h=s.modPow(o,this);if(0!=h.compareTo(r.ONE)&&0!=h.compareTo(i)){for(var a=1;a++<n&&0!=h.compareTo(i);)if(0==(h=h.modPowInt(2,this)).compareTo(r.ONE))return!1;if(0!=h.compareTo(i))return!1}}return!0},r.prototype.clone=function(){var t=e();return this.copyTo(t),t},r.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,r=new Array;r[0]=this.s;var e,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(e=this[t]>>i)!=(this.s&this.DM)>>i&&(r[n++]=e|this.s<<this.DB-i);t>=0;)i<8?(e=(this[t]&(1<<i)-1)<<8-i,e|=this[--t]>>(i+=this.DB-8)):(e=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&e&&(e|=-256),0==n&&(128&this.s)!=(128&e)&&++n,(n>0||e!=this.s)&&(r[n++]=e);return r},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var r=e();return this.bitwiseTo(t,g,r),r},r.prototype.or=function(t){var r=e();return this.bitwiseTo(t,d,r),r},r.prototype.xor=function(t){var r=e();return this.bitwiseTo(t,m,r),r},r.prototype.andNot=function(t){var r=e();return this.bitwiseTo(t,v,r),r},r.prototype.not=function(){for(var t=e(),r=0;r<this.t;++r)t[r]=this.DM&~this[r];return t.t=this.t,t.s=~this.s,t},r.prototype.shiftLeft=function(t){var r=e();return t<0?this.rShiftTo(-t,r):this.lShiftTo(t,r),r},r.prototype.shiftRight=function(t){var r=e();return t<0?this.lShiftTo(-t,r):this.rShiftTo(t,r),r},r.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+T(this[t]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var t=0,r=this.s&this.DM,e=0;e<this.t;++e)t+=w(this[e]^r);return t},r.prototype.testBit=function(t){var r=Math.floor(t/this.DB);return r>=this.t?0!=this.s:!!(this[r]&1<<t%this.DB)},r.prototype.setBit=function(t){return this.changeBit(t,d)},r.prototype.clearBit=function(t){return this.changeBit(t,v)},r.prototype.flipBit=function(t){return this.changeBit(t,m)},r.prototype.add=function(t){var r=e();return this.addTo(t,r),r},r.prototype.subtract=function(t){var r=e();return this.subTo(t,r),r},r.prototype.multiply=function(t){var r=e();return this.multiplyTo(t,r),r},r.prototype.divide=function(t){var r=e();return this.divRemTo(t,r,null),r},r.prototype.remainder=function(t){var r=e();return this.divRemTo(t,null,r),r},r.prototype.divideAndRemainder=function(t){var r=e(),i=e();return this.divRemTo(t,r,i),new Array(r,i)},r.prototype.modPow=function(t,r){var i,n,o=t.bitLength(),s=f(1);if(o<=0)return s;i=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new p(r):r.isEven()?new B(r):new y(r);var u=new Array,h=3,a=i-1,l=(1<<i)-1;if(u[1]=n.convert(this),i>1){var g=e();for(n.sqrTo(u[1],g);h<=l;)u[h]=e(),n.mulTo(g,u[h-2],u[h]),h+=2}var d,m,v=t.t-1,T=!0,w=e();for(o=c(t[v])-1;v>=0;){for(o>=a?d=t[v]>>o-a&l:(d=(t[v]&(1<<o+1)-1)<<a-o,v>0&&(d|=t[v-1]>>this.DB+o-a)),h=i;!(1&d);)d>>=1,--h;if((o-=h)<0&&(o+=this.DB,--v),T)u[d].copyTo(s),T=!1;else{for(;h>1;)n.sqrTo(s,w),n.sqrTo(w,s),h-=2;h>0?n.sqrTo(s,w):(m=s,s=w,w=m),n.mulTo(w,u[d],s)}for(;v>=0&&!(t[v]&1<<o);)n.sqrTo(s,w),m=s,s=w,w=m,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},r.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var i=t.clone(),n=this.clone(),o=f(1),s=f(0),u=f(0),h=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?(u.isEven()&&h.isEven()||(u.addTo(this,u),h.subTo(t,h)),u.rShiftTo(1,u)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);i.compareTo(n)>=0?(i.subTo(n,i),e&&o.subTo(u,o),s.subTo(h,s)):(n.subTo(i,n),e&&u.subTo(o,u),h.subTo(s,h))}return 0!=n.compareTo(r.ONE)?r.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},r.prototype.pow=function(t){return this.exp(t,new b)},r.prototype.gcd=function(t){var r=this.s<0?this.negate():this.clone(),e=t.s<0?t.negate():t.clone();if(r.compareTo(e)<0){var i=r;r=e,e=i}var n=r.getLowestSetBit(),o=e.getLowestSetBit();if(o<0)return r;for(n<o&&(o=n),o>0&&(r.rShiftTo(o,r),e.rShiftTo(o,e));r.signum()>0;)(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),r.compareTo(e)>=0?(r.subTo(e,r),r.rShiftTo(1,r)):(e.subTo(r,e),e.rShiftTo(1,e));return o>0&&e.lShiftTo(o,e),e},r.prototype.isProbablePrime=function(t){var r,e=this.abs();if(1==e.t&&e[0]<=E[E.length-1]){for(r=0;r<E.length;++r)if(e[0]==E[r])return!0;return!1}if(e.isEven())return!1;for(r=1;r<E.length;){for(var i=E[r],n=r+1;n<E.length&&i<I;)i*=E[n++];for(i=e.modInt(i);r<n;)if(i%E[r++]==0)return!1}return e.millerRabin(t)},r.prototype.square=function(){var t=e();return this.squareTo(t),t},r.prototype.Barrett=B,null==S){var A;if(S=new Array,q=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var R=new Uint8Array(32);for(window.crypto.getRandomValues(R),A=0;A<32;++A)S[q++]=R[A]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var P=window.crypto.random(32);for(A=0;A<P.length;++A)S[q++]=255&P.charCodeAt(A)}for(;q<H;)A=Math.floor(65536*Math.random()),S[q++]=A>>>8,S[q++]=255&A;q=0,D()}function O(){if(null==x){for(D(),(x=new C).init(S),q=0;q<S.length;++q)S[q]=0;q=0}return x.next()}function M(){}function C(){this.i=0,this.j=0,this.S=new Array}M.prototype.nextBytes=function(t){var r;for(r=0;r<t.length;++r)t[r]=O()},C.prototype.init=function(t){var r,e,i;for(r=0;r<256;++r)this.S[r]=r;for(e=0,r=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},C.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var H=256;l.exports={default:r,BigInteger:r,SecureRandom:M}}.call(f);var y=p.exports;const{BigInteger:g}=y;class d{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let r=t.toString(16);if(r.length%2==1&&(r="0"+r),t<128)return r;return(128+r.length/2).toString(16)+r}getValue(){return""}}class m extends d{constructor(t){super(),this.t="02",t&&(this.v=function(t){let r=t.toString(16);if("-"!==r[0])r.length%2==1?r="0"+r:r.match(/^[0-7]/)||(r="00"+r);else{r=r.substr(1);let e=r.length;e%2==1?e+=1:r.match(/^[0-7]/)||(e+=2);let i="";for(let t=0;t<e;t++)i+="f";i=new g(i,16),r=i.xor(t).add(g.ONE),r=r.toString(16).replace(/^-/,"")}return r}(t))}getValue(){return this.v}}class v extends d{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map((t=>t.getEncodedHex())).join(""),this.v}}function T(t,r){return+t[r+2]<8?1:128&+t.substr(r+2,2)}function w(t,r){const e=T(t,r),i=t.substr(r+2,2*e);if(!i)return-1;return(+i[0]<8?new g(i,16):new g(i.substr(2),16)).intValue()}function b(t,r){return r+2*(T(t,r)+1)}var F={encodeDer(t,r){const e=new m(t),i=new m(r);return new v([e,i]).getEncodedHex()},decodeDer(t){const r=b(t,0),e=b(t,r),i=w(t,r),n=t.substr(e,2*i),o=e+n.length,s=b(t,o),u=w(t,o),h=t.substr(s,2*u);return{r:new g(n,16),s:new g(h,16)}}};const{BigInteger:B}=y,x=new B("2"),S=new B("3");class q{constructor(t,r){this.x=r,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new q(this.q,this.x.negate().mod(this.q))}add(t){return new q(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new q(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new q(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new q(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new q(this.q,this.x.square().mod(this.q))}}class E{constructor(t,r,e,i){this.curve=t,this.x=r,this.y=e,this.z=null==i?B.ONE:i,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(B.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(B.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(B.ZERO)&&!this.y.toBigInteger().equals(B.ZERO)}negate(){return new E(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const r=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=t.x.toBigInteger(),o=t.y.toBigInteger(),s=t.z,u=this.curve.q,h=r.multiply(s).mod(u),a=n.multiply(i).mod(u),f=h.subtract(a),c=e.multiply(s).mod(u),l=o.multiply(i).mod(u),p=c.subtract(l);if(B.ZERO.equals(f))return B.ZERO.equals(p)?this.twice():this.curve.infinity;const y=h.add(a),g=i.multiply(s).mod(u),d=f.square().mod(u),m=f.multiply(d).mod(u),v=g.multiply(p.square()).subtract(y.multiply(d)).mod(u),T=f.multiply(v).mod(u),w=p.multiply(d.multiply(h).subtract(v)).subtract(c.multiply(m)).mod(u),b=m.multiply(g).mod(u);return new E(this.curve,this.curve.fromBigInteger(T),this.curve.fromBigInteger(w),b)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),r=this.y.toBigInteger(),e=this.z,i=this.curve.q,n=this.curve.a.toBigInteger(),o=t.square().multiply(S).add(n.multiply(e.square())).mod(i),s=r.shiftLeft(1).multiply(e).mod(i),u=r.square().mod(i),h=u.multiply(t).multiply(e).mod(i),a=s.square().mod(i),f=o.square().subtract(h.shiftLeft(3)).mod(i),c=s.multiply(f).mod(i),l=o.multiply(h.shiftLeft(2).subtract(f)).subtract(a.shiftLeft(1).multiply(u)).mod(i),p=s.multiply(a).mod(i);return new E(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),p)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const r=t.multiply(S),e=this.negate();let i=this;for(let n=r.bitLength()-2;n>0;n--){i=i.twice();const o=r.testBit(n);o!==t.testBit(n)&&(i=i.add(o?this:e))}return i}}var I={ECPointFp:E,ECCurveFp:class{constructor(t,r,e){this.q=t,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(e),this.infinity=new E(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new q(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const r=this.fromBigInteger(new B(t.substr(2),16));let e=this.fromBigInteger(r.multiply(r.square()).add(r.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new B("4")).add(B.ONE),this.q));return e.toBigInteger().mod(x).equals(new B(t.substr(0,2),16).subtract(x))||(e=e.negate()),new E(this,r,e);case 4:case 6:case 7:const i=(t.length-2)/2,n=t.substr(2,i),o=t.substr(i+2,i);return new E(this,this.fromBigInteger(new B(n,16)),this.fromBigInteger(new B(o,16)));default:return null}}}};const{BigInteger:D,SecureRandom:A}=y,{ECCurveFp:R}=I,P=new A,{curve:O,G:M,n:C}=H();function H(){const t=new D("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),r=new D("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),e=new D("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),i=new R(t,r,e),n=i.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:i,G:n,n:new D("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function N(t,r){return t.length>=r?t:new Array(r-t.length+1).join("0")+t}var K={getGlobalCurve:function(){return O},generateEcparam:H,generateKeyPairHex:function(t,r,e){const i=(t?new D(t,r,e):new D(C.bitLength(),P)).mod(C.subtract(D.ONE)).add(D.ONE),n=N(i.toString(16),64),o=M.multiply(i);return{privateKey:n,publicKey:"04"+N(o.getX().toBigInteger().toString(16),64)+N(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const r=(t.length-2)/2,e=t.substr(2,r);let i="03";return new D(t.substr(r+2,r),16).mod(new D("2")).equals(D.ZERO)&&(i="02"),i+e},utf8ToHex:function(t){const r=(t=unescape(encodeURIComponent(t))).length,e=[];for(let i=0;i<r;i++)e[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;t<r;t++){const r=e[t>>>2]>>>24-t%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},leftPad:N,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const r=[];let e=0;for(let i=0;i<2*t.length;i+=2)r[i>>>3]|=parseInt(t[e],10)<<24-i%8*4,e++;try{const e=[];for(let i=0;i<t.length;i++){const t=r[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(t))}return decodeURIComponent(escape(e.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const r=[];let e=t.length;e%2!=0&&(t=N(t,e+1)),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r},verifyPublicKey:function(t){const r=O.decodePointHex(t);if(!r)return!1;const e=r.getX();return r.getY().square().equals(e.multiply(e.square()).add(e.multiply(O.a)).add(O.b))},comparePublicKeyHex:function(t,r){const e=O.decodePointHex(t);if(!e)return!1;const i=O.decodePointHex(r);return!!i&&e.equals(i)}};const V=new Uint32Array(68),L=new Uint32Array(64);function z(t,r){const e=31&r;return t<<e|t>>>32-e}function k(t,r){const e=[];for(let i=t.length-1;i>=0;i--)e[i]=255&(t[i]^r[i]);return e}function Z(t){return t^z(t,9)^z(t,17)}function j(t){let r=8*t.length,e=r%512;e=e>=448?512-e%448-1:448-e-1;const i=new Array((e-7)/8),n=new Array(8);for(let t=0,r=i.length;t<r;t++)i[t]=0;for(let t=0,r=n.length;t<r;t++)n[t]=0;r=r.toString(2);for(let t=7;t>=0;t--)if(r.length>8){const e=r.length-8;n[t]=parseInt(r.substr(e),2),r=r.substr(0,e)}else r.length>0&&(n[t]=parseInt(r,2),r="");const o=new Uint8Array([...t,128,...i,...n]),s=new DataView(o.buffer,0),u=o.length/64,h=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<u;t++){V.fill(0),L.fill(0);const r=16*t;for(let t=0;t<16;t++)V[t]=s.getUint32(4*(r+t),!1);for(let t=16;t<68;t++)V[t]=(a=V[t-16]^V[t-9]^z(V[t-3],15))^z(a,15)^z(a,23)^z(V[t-13],7)^V[t-6];for(let t=0;t<64;t++)L[t]=V[t]^V[t+4];const e=2043430169,i=2055708042;let n,o,u,f,c,l=h[0],p=h[1],y=h[2],g=h[3],d=h[4],m=h[5],v=h[6],T=h[7];for(let t=0;t<64;t++)c=t>=0&&t<=15?e:i,n=z(z(l,12)+d+z(c,t),7),o=n^z(l,12),u=(t>=0&&t<=15?l^p^y:l&p|l&y|p&y)+g+o+L[t],f=(t>=0&&t<=15?d^m^v:d&m|~d&v)+T+n+V[t],g=y,y=z(p,9),p=l,l=u,T=v,v=z(m,19),m=d,d=Z(f);h[0]^=l,h[1]^=p,h[2]^=y,h[3]^=g,h[4]^=d,h[5]^=m,h[6]^=v,h[7]^=T}var a;const f=[];for(let t=0,r=h.length;t<r;t++){const r=h[t];f.push((4278190080&r)>>>24,(16711680&r)>>>16,(65280&r)>>>8,255&r)}return f}const U=new Uint8Array(64),_=new Uint8Array(64);for(let t=0;t<64;t++)U[t]=54,_[t]=92;var $={sm3:j,hmac:function(t,r){for(r.length>64&&(r=j(r));r.length<64;)r.push(0);const e=k(r,U),i=k(r,_),n=j([...e,...t]);return j([...i,...n])}};const{BigInteger:X}=y,{encodeDer:J,decodeDer:Y}=F,G=K,W=$.sm3,{G:Q,curve:tt,n:rt}=G.generateEcparam();function et(t,r,e="1234567812345678"){e=G.utf8ToHex(e);const i=G.leftPad(Q.curve.a.toBigInteger().toRadix(16),64),n=G.leftPad(Q.curve.b.toBigInteger().toRadix(16),64),o=G.leftPad(Q.getX().toBigInteger().toRadix(16),64),s=G.leftPad(Q.getY().toBigInteger().toRadix(16),64);let u,h;if(128===r.length)u=r.substr(0,64),h=r.substr(64,64);else{const t=Q.curve.decodePointHex(r);u=G.leftPad(t.getX().toBigInteger().toRadix(16),64),h=G.leftPad(t.getY().toBigInteger().toRadix(16),64)}const a=G.hexToArray(e+i+n+o+s+u+h),f=4*e.length;a.unshift(255&f),a.unshift(f>>8&255);const c=W(a);return G.arrayToHex(W(c.concat(G.hexToArray(t))))}function it(t){const r=Q.multiply(new X(t,16));return"04"+G.leftPad(r.getX().toBigInteger().toString(16),64)+G.leftPad(r.getY().toBigInteger().toString(16),64)}function nt(){const t=G.generateKeyPairHex(),r=tt.decodePointHex(t.publicKey);return t.k=new X(t.privateKey,16),t.x1=r.getX().toBigInteger(),t}var ot={generateKeyPairHex:G.generateKeyPairHex,compressPublicKeyHex:G.compressPublicKeyHex,comparePublicKeyHex:G.comparePublicKeyHex,doEncrypt:function(t,r,e=1){t="string"==typeof t?G.hexToArray(G.utf8ToHex(t)):Array.prototype.slice.call(t),r=G.getGlobalCurve().decodePointHex(r);const i=G.generateKeyPairHex(),n=new X(i.privateKey,16);let o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));const s=r.multiply(n),u=G.hexToArray(G.leftPad(s.getX().toBigInteger().toRadix(16),64)),h=G.hexToArray(G.leftPad(s.getY().toBigInteger().toRadix(16),64)),a=G.arrayToHex(W([].concat(u,t,h)));let f=1,c=0,l=[];const p=[].concat(u,h),y=()=>{l=W([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let r=0,e=t.length;r<e;r++)c===l.length&&y(),t[r]^=255&l[c++];const g=G.arrayToHex(t);return 0===e?o+g+a:o+a+g},doDecrypt:function(t,r,e=1,{output:i="string"}={}){r=new X(r,16);let n=t.substr(128,64),o=t.substr(192);0===e&&(n=t.substr(t.length-64),o=t.substr(128,t.length-128-64));const s=G.hexToArray(o),u=G.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(r),h=G.hexToArray(G.leftPad(u.getX().toBigInteger().toRadix(16),64)),a=G.hexToArray(G.leftPad(u.getY().toBigInteger().toRadix(16),64));let f=1,c=0,l=[];const p=[].concat(h,a),y=()=>{l=W([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let t=0,r=s.length;t<r;t++)c===l.length&&y(),s[t]^=255&l[c++];return G.arrayToHex(W([].concat(h,s,a)))===n.toLowerCase()?"array"===i?s:G.arrayToUtf8(s):"array"===i?[]:""},doSignature:function(t,r,{pointPool:e,der:i,hash:n,publicKey:o,userId:s}={}){let u="string"==typeof t?G.utf8ToHex(t):G.arrayToHex(t);n&&(u=et(u,o=o||it(r),s));const h=new X(r,16),a=new X(u,16);let f=null,c=null,l=null;do{do{let t;t=e&&e.length?e.pop():nt(),f=t.k,c=a.add(t.x1).mod(rt)}while(c.equals(X.ZERO)||c.add(f).equals(rt));l=h.add(X.ONE).modInverse(rt).multiply(f.subtract(c.multiply(h))).mod(rt)}while(l.equals(X.ZERO));return i?J(c,l):G.leftPad(c.toString(16),64)+G.leftPad(l.toString(16),64)},doVerifySignature:function(t,r,e,{der:i,hash:n,userId:o}={}){let s,u,h="string"==typeof t?G.utf8ToHex(t):G.arrayToHex(t);if(n&&(h=et(h,e,o)),i){const t=Y(r);s=t.r,u=t.s}else s=new X(r.substring(0,64),16),u=new X(r.substring(64),16);const a=tt.decodePointHex(e),f=new X(h,16),c=s.add(u).mod(rt);if(c.equals(X.ZERO))return!1;const l=Q.multiply(u).add(a.multiply(c)),p=f.add(l.getX().toBigInteger()).mod(rt);return s.equals(p)},getPublicKeyFromPrivateKey:it,getPoint:nt,verifyPublicKey:G.verifyPublicKey};const{sm3:st,hmac:ut}=$;function ht(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}function at(t){const r=[];let e=t.length;var i,n;e%2!=0&&(n=e+1,t=(i=t).length>=n?i:new Array(n-i.length+1).join("0")+i),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r}const ft=0,ct=16,lt=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],pt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function yt(t){const r=[];for(let e=0,i=t.length;e<i;e+=2)r.push(parseInt(t.substr(e,2),16));return r}function gt(t,r){const e=31&r;return t<<e|t>>>32-e}function dt(t){return(255<[t>>>24&255])<<24|(255<[t>>>16&255])<<16|(255<[t>>>8&255])<<8|255<[255&t]}function mt(t){return t^gt(t,2)^gt(t,10)^gt(t,18)^gt(t,24)}function vt(t){return t^gt(t,13)^gt(t,23)}function Tt(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[4*r],n[1]=255&t[4*r+1],n[2]=255&t[4*r+2],n[3]=255&t[4*r+3],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,r=0;r<32;r+=4)t=i[1]^i[2]^i[3]^e[r+0],i[0]^=mt(dt(t)),t=i[2]^i[3]^i[0]^e[r+1],i[1]^=mt(dt(t)),t=i[3]^i[0]^i[1]^e[r+2],i[2]^=mt(dt(t)),t=i[0]^i[1]^i[2]^e[r+3],i[3]^=mt(dt(t));for(let t=0;t<16;t+=4)r[t]=i[3-t/4]>>>24&255,r[t+1]=i[3-t/4]>>>16&255,r[t+2]=i[3-t/4]>>>8&255,r[t+3]=255&i[3-t/4]}function wt(t,r,e,{padding:i="pkcs#7",mode:n,iv:o=[],output:s="string"}={}){if("cbc"===n&&("string"==typeof o&&(o=yt(o)),16!==o.length))throw new Error("iv is invalid");if("string"==typeof r&&(r=yt(r)),16!==r.length)throw new Error("key is invalid");if(t="string"==typeof t?e!==ft?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):yt(t):[...t],("pkcs#5"===i||"pkcs#7"===i)&&e!==ft){const r=ct-t.length%ct;for(let e=0;e<r;e++)t.push(r)}const u=new Array(32);!function(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[0+4*r],n[1]=255&t[1+4*r],n[2]=255&t[2+4*r],n[3]=255&t[3+4*r],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];i[0]^=2746333894,i[1]^=1453994832,i[2]^=1736282519,i[3]^=2993693404;for(let t,e=0;e<32;e+=4)t=i[1]^i[2]^i[3]^pt[e+0],r[e+0]=i[0]^=vt(dt(t)),t=i[2]^i[3]^i[0]^pt[e+1],r[e+1]=i[1]^=vt(dt(t)),t=i[3]^i[0]^i[1]^pt[e+2],r[e+2]=i[2]^=vt(dt(t)),t=i[0]^i[1]^i[2]^pt[e+3],r[e+3]=i[3]^=vt(dt(t));if(e===ft)for(let t,e=0;e<16;e++)t=r[e],r[e]=r[31-e],r[31-e]=t}(r,u,e);const h=[];let a=o,f=t.length,c=0;for(;f>=ct;){const r=t.slice(c,c+16),i=new Array(16);if("cbc"===n)for(let t=0;t<ct;t++)e!==ft&&(r[t]^=a[t]);Tt(r,i,u);for(let t=0;t<ct;t++)"cbc"===n&&e===ft&&(i[t]^=a[t]),h[c+t]=i[t];"cbc"===n&&(a=e!==ft?i:r),f-=ct,c+=ct}if(("pkcs#5"===i||"pkcs#7"===i)&&e===ft){const t=h.length,r=h[t-1];for(let e=1;e<=r;e++)if(h[t-e]!==r)throw new Error("padding is invalid");h.splice(t-r,r)}return"array"!==s?e!==ft?h.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const r=[];for(let e=0,i=t.length;e<i;e++)t[e]>=240&&t[e]<=247?(r.push(String.fromCodePoint(((7&t[e])<<18)+((63&t[e+1])<<12)+((63&t[e+2])<<6)+(63&t[e+3]))),e+=3):t[e]>=224&&t[e]<=239?(r.push(String.fromCodePoint(((15&t[e])<<12)+((63&t[e+1])<<6)+(63&t[e+2]))),e+=2):t[e]>=192&&t[e]<=223?(r.push(String.fromCodePoint(((31&t[e])<<6)+(63&t[e+1]))),e++):r.push(String.fromCodePoint(t[e]));return r.join("")}(h):h}var bt={sm2:ot,sm3:function(t,r){if(t="string"==typeof t?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):Array.prototype.slice.call(t),r){if("hmac"!==(r.mode||"hmac"))throw new Error("invalid mode");let e=r.key;if(!e)throw new Error("invalid key");return e="string"==typeof e?at(e):Array.prototype.slice.call(e),ht(ut(t,e))}return ht(st(t))},sm4:{encrypt:(t,r,e)=>wt(t,r,1,e),decrypt:(t,r,e)=>wt(t,r,0,e)}};const Ft={mode:"ecb",padding:"pkcs#5",output:"array"},Bt=r.Buffer,xt=function(t,r,e,i){return(n,o)=>{try{if(o.closeCrypto)return n;t.info=h(),t.publicKey=[...Bt.from(t.info.key)];const s=bt.sm2.doEncrypt(JSON.stringify(t.info),r,1);if(e.set(i,function(t){if("string"==typeof t)return String(t);return JSON.parse(JSON.stringify(t))}(s)),((t,r)=>{t.set("X-Encrypt-Key",r)})(o,"04"+s),n){"string"!=typeof n&&(n=JSON.stringify(n));const r=bt.sm4.encrypt(n,t.publicKey,Ft);return n=Bt.from(r)}return n}catch(t){console.error("encrypt error",t,n,o)}}},St=function(t){return(r,e)=>{try{if((t=>{const r=t.get(n);return r&&"string"==typeof r&&"sm4"===r.toLowerCase()})(e)){const e=Bt.from(r);return s(bt.sm4.decrypt(e,t.publicKey,{mode:"ecb",padding:"pkcs#5"}))}return r}catch(t){console.error("decrypt error",t,r,e)}}};var qt,Et,It={exports:{}},Dt={exports:{}};qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et={rotl:function(t,r){return t<<r|t>>>32-r},rotr:function(t,r){return t<<32-r|t>>>r},endian:function(t){if(t.constructor==Number)return 16711935&Et.rotl(t,8)|4278255360&Et.rotl(t,24);for(var r=0;r<t.length;r++)t[r]=Et.endian(t[r]);return t},randomBytes:function(t){for(var r=[];t>0;t--)r.push(Math.floor(256*Math.random()));return r},bytesToWords:function(t){for(var r=[],e=0,i=0;e<t.length;e++,i+=8)r[i>>>5]|=t[e]<<24-i%32;return r},wordsToBytes:function(t){for(var r=[],e=0;e<32*t.length;e+=8)r.push(t[e>>>5]>>>24-e%32&255);return r},bytesToHex:function(t){for(var r=[],e=0;e<t.length;e++)r.push((t[e]>>>4).toString(16)),r.push((15&t[e]).toString(16));return r.join("")},hexToBytes:function(t){for(var r=[],e=0;e<t.length;e+=2)r.push(parseInt(t.substr(e,2),16));return r},bytesToBase64:function(t){for(var r=[],e=0;e<t.length;e+=3)for(var i=t[e]<<16|t[e+1]<<8|t[e+2],n=0;n<4;n++)8*e+6*n<=8*t.length?r.push(qt.charAt(i>>>6*(3-n)&63)):r.push("=");return r.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var r=[],e=0,i=0;e<t.length;i=++e%4)0!=i&&r.push((qt.indexOf(t.charAt(e-1))&Math.pow(2,-2*i+8)-1)<<2*i|qt.indexOf(t.charAt(e))>>>6-2*i);return r}},Dt.exports=Et;var At=Dt.exports,Rt={utf8:{stringToBytes:function(t){return Rt.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(Rt.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var r=[],e=0;e<t.length;e++)r.push(255&t.charCodeAt(e));return r},bytesToString:function(t){for(var r=[],e=0;e<t.length;e++)r.push(String.fromCharCode(t[e]));return r.join("")}}},Pt=Rt,Ot=function(t){return null!=t&&(Mt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Mt(t.slice(0,0))}(t)||!!t._isBuffer)};function Mt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(){var t=At,r=Pt.utf8,e=Ot,i=Pt.bin,n=function(o,s){o.constructor==String?o=s&&"binary"===s.encoding?i.stringToBytes(o):r.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):Array.isArray(o)||o.constructor===Uint8Array||(o=o.toString());for(var u=t.bytesToWords(o),h=8*o.length,a=1732584193,f=-271733879,c=-1732584194,l=271733878,p=0;p<u.length;p++)u[p]=16711935&(u[p]<<8|u[p]>>>24)|4278255360&(u[p]<<24|u[p]>>>8);u[h>>>5]|=128<<h%32,u[14+(h+64>>>9<<4)]=h;var y=n._ff,g=n._gg,d=n._hh,m=n._ii;for(p=0;p<u.length;p+=16){var v=a,T=f,w=c,b=l;a=y(a,f,c,l,u[p+0],7,-680876936),l=y(l,a,f,c,u[p+1],12,-389564586),c=y(c,l,a,f,u[p+2],17,606105819),f=y(f,c,l,a,u[p+3],22,-1044525330),a=y(a,f,c,l,u[p+4],7,-176418897),l=y(l,a,f,c,u[p+5],12,1200080426),c=y(c,l,a,f,u[p+6],17,-1473231341),f=y(f,c,l,a,u[p+7],22,-45705983),a=y(a,f,c,l,u[p+8],7,1770035416),l=y(l,a,f,c,u[p+9],12,-1958414417),c=y(c,l,a,f,u[p+10],17,-42063),f=y(f,c,l,a,u[p+11],22,-1990404162),a=y(a,f,c,l,u[p+12],7,1804603682),l=y(l,a,f,c,u[p+13],12,-40341101),c=y(c,l,a,f,u[p+14],17,-1502002290),a=g(a,f=y(f,c,l,a,u[p+15],22,1236535329),c,l,u[p+1],5,-165796510),l=g(l,a,f,c,u[p+6],9,-1069501632),c=g(c,l,a,f,u[p+11],14,643717713),f=g(f,c,l,a,u[p+0],20,-373897302),a=g(a,f,c,l,u[p+5],5,-701558691),l=g(l,a,f,c,u[p+10],9,38016083),c=g(c,l,a,f,u[p+15],14,-660478335),f=g(f,c,l,a,u[p+4],20,-405537848),a=g(a,f,c,l,u[p+9],5,568446438),l=g(l,a,f,c,u[p+14],9,-1019803690),c=g(c,l,a,f,u[p+3],14,-187363961),f=g(f,c,l,a,u[p+8],20,1163531501),a=g(a,f,c,l,u[p+13],5,-1444681467),l=g(l,a,f,c,u[p+2],9,-51403784),c=g(c,l,a,f,u[p+7],14,1735328473),a=d(a,f=g(f,c,l,a,u[p+12],20,-1926607734),c,l,u[p+5],4,-378558),l=d(l,a,f,c,u[p+8],11,-2022574463),c=d(c,l,a,f,u[p+11],16,1839030562),f=d(f,c,l,a,u[p+14],23,-35309556),a=d(a,f,c,l,u[p+1],4,-1530992060),l=d(l,a,f,c,u[p+4],11,1272893353),c=d(c,l,a,f,u[p+7],16,-155497632),f=d(f,c,l,a,u[p+10],23,-1094730640),a=d(a,f,c,l,u[p+13],4,681279174),l=d(l,a,f,c,u[p+0],11,-358537222),c=d(c,l,a,f,u[p+3],16,-722521979),f=d(f,c,l,a,u[p+6],23,76029189),a=d(a,f,c,l,u[p+9],4,-640364487),l=d(l,a,f,c,u[p+12],11,-421815835),c=d(c,l,a,f,u[p+15],16,530742520),a=m(a,f=d(f,c,l,a,u[p+2],23,-995338651),c,l,u[p+0],6,-198630844),l=m(l,a,f,c,u[p+7],10,1126891415),c=m(c,l,a,f,u[p+14],15,-1416354905),f=m(f,c,l,a,u[p+5],21,-57434055),a=m(a,f,c,l,u[p+12],6,1700485571),l=m(l,a,f,c,u[p+3],10,-1894986606),c=m(c,l,a,f,u[p+10],15,-1051523),f=m(f,c,l,a,u[p+1],21,-2054922799),a=m(a,f,c,l,u[p+8],6,1873313359),l=m(l,a,f,c,u[p+15],10,-30611744),c=m(c,l,a,f,u[p+6],15,-1560198380),f=m(f,c,l,a,u[p+13],21,1309151649),a=m(a,f,c,l,u[p+4],6,-145523070),l=m(l,a,f,c,u[p+11],10,-1120210379),c=m(c,l,a,f,u[p+2],15,718787259),f=m(f,c,l,a,u[p+9],21,-343485551),a=a+v>>>0,f=f+T>>>0,c=c+w>>>0,l=l+b>>>0}return t.endian([a,f,c,l])};n._ff=function(t,r,e,i,n,o,s){var u=t+(r&e|~r&i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._gg=function(t,r,e,i,n,o,s){var u=t+(r&i|e&~i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._hh=function(t,r,e,i,n,o,s){var u=t+(r^e^i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._ii=function(t,r,e,i,n,o,s){var u=t+(e^(r|~i))+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._blocksize=16,n._digestsize=16,It.exports=function(r,e){if(null==r)throw new Error("Illegal argument "+r);var o=t.wordsToBytes(n(r,e));return e&&e.asBytes?o:e&&e.asString?i.bytesToString(o):t.bytesToHex(o)}}();var Ct=c(It.exports);const Ht=function(){const t=new Map;return{get:function(r){return t.get(r)},generateKey:function(t,r){try{const e="e0c7ff",i=((t,r)=>{const e=new URL(window.location.origin+t);for(const t in r)e.searchParams.append(t,r[t]);return e.toString()})(t,r??{});return`${Ct(i+e)}-/${t}`}catch(r){return`${i(10)}-/${t}`}},set:function(r,e){t.set(r,e)},clear:function(r){t.delete(r)}}}();window.__buffer=r;const Nt=(r,e,i)=>{const h=t.create(r);return h.interceptors.request.use((t=>{const r=localStorage.getItem("cps_lang"),e={en:"en-US",ko:"ko-KR",zh:"zh-CN"};if(r&&Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];t.headers.set({"Accept-Language":`${i},zh;q=0.9,en;q=0.8`})}return t})),i||function(t,r){if(!r||"string"!=typeof r)throw new Error(`publicKey is required and must be a string ${r}`);t.interceptors.request.use((t=>{const e=t.transformRequest,i=t?.headers?.__requestKey,n={info:null,publicKey:[]};if(!e)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(e))throw new Error(`transformRequest ${e} is not an array`);e.push(xt(n,r,Ht,i));const o=St(n);if(!o)return t;const s=t.transformResponse;if(!s)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof o)throw new Error(`decryptFn ${o} is not a function`);if(!Array.isArray(s))throw new Error(`transformResponse ${s} is not an array`);return s.unshift(o),t})),t.interceptors.request.use((t=>{try{const r=encodeURI(t?.url??""),e=t.headers;return r?(e.__requestKey=Ht.generateKey(r,t?.params),t):t}catch(r){return console.error("error",r),t}})),t.interceptors.request.use((t=>(t.headers.closeCrypto||(t.responseType="arraybuffer"),t))),t.interceptors.request.use((t=>{const r=t.data,e=t.headers;return r?((r instanceof FormData||r instanceof File)&&(e.closeCrypto=!0),t):t})),t.interceptors.request.use((t=>{const r=t.url,e=t.headers;if(!r)throw new Error("url is required");return{}.hasOwnProperty.call(e,"closeCrypto")||u(r)||(e.closeCrypto=!0),t})),t.interceptors.response.use((t=>{const{request:r,headers:e}=t;return e&&e.get(n)||"arraybuffer"===r?.responseType?.toLowerCase()||"blob"===r?.responseType?.toLowerCase()||(t.data=s(t.data)),t}),(t=>{const r=t.response;throw r?.data&&(r.data=o(r.data)),t}))}(h,e),h},Kt=bt.sm2.doDecrypt;export{Nt as createCryptoAxiosInstance,e as createRequestInstance,Kt as decryptHeadersInfo,h as getCryptoInfo,a as getSm4EncryptConfig,i as randomPassword,u as shouldEncrypt}; | ||
import t from"axios";import r from"buffer";const e=(r,e)=>{const i=t.create(r);return function(t,r){if(!r)return t;const{encryptFn:e,decryptFn:i}=r();e&&t.interceptors.request.use((t=>{const r=t.transformRequest;if(!r)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(r))throw new Error(`transformRequest ${r} is not an array`);if(r.push(e),!i)return t;const n=t.transformResponse;if(!n)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof i)throw new Error(`decryptFn ${i} is not a function`);if(!Array.isArray(n))throw new Error(`transformResponse ${n} is not an array`);return n.unshift(i),t}))}(i,e),i};const i=(t=16,r="high")=>{const e=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"],i=["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"],n=[0,1,2,3,4,5,6,7,8,9],o=["!","@","-","_","=","<",">","#","*","%","+","&","^","$"],s=[];let u="";const h=function(...t){let r="";return t.forEach((t=>{r+=t[Math.floor(Math.random()*t.length)]})),r};switch(r){case"high":u+=h(e,i,n,o),s.push(...e,...i,...n,...o);break;case"medium":u+=h(e,i,n),s.push(...e,...i,...n);break;default:u+=h(e,n),s.push(...e,...n)}const a=t-u.length;for(let t=0;t<a;t++)u+=h(s);return u},n="X-Encrypt-With";function o(t){if("string"==typeof t)try{t=JSON.parse(t)}catch(t){throw console.error("error",t),t}if(t instanceof ArrayBuffer){const r=function(t,r="utf-8"){return new TextDecoder(r).decode(t)}(t);try{return JSON.parse(r)}catch(t){return console.error("尝试转换失败",t),r}}return t}function s(t){try{return"string"==typeof t?JSON.parse(t):t}catch(r){return console.error("transform string to JSON data",{data:t,e:r}),t}}const u=t=>{let r=!0;return!(t=>/^\/bi-api\/api/.test(t))(t)&&(t.startsWith("/api")&&(r=!1,(t=>/^\/(api\/logmanage|api\/data-source|api\/enterpriseadmin|api\/componentmanager|api\/spacemanager|api\/filemanager)/.test(t))(t)&&(r=!0)),r)},h=t=>({...{key:i(16,"high"),algorithm:t||"SM4"}}),a=()=>({mode:"ecb",padding:"pkcs#5",output:"array"});var f="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function c(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var l,p={exports:{}};l=p,function(){var t;function r(t,r,e){null!=t&&("number"==typeof t?this.fromNumber(t,r,e):null==r&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,r))}function e(){return new r(null)}var i="undefined"!=typeof navigator;i&&"Microsoft Internet Explorer"==navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(var s=32767&r,u=r>>15;--o>=0;){var h=32767&this[t],a=this[t++]>>15,f=u*h+a*s;n=((h=s*h+((32767&f)<<15)+e[i]+(1073741823&n))>>>30)+(f>>>15)+u*a+(n>>>30),e[i++]=1073741823&h}return n},t=30):i&&"Netscape"!=navigator.appName?(r.prototype.am=function(t,r,e,i,n,o){for(;--o>=0;){var s=r*this[t++]+e[i]+n;n=Math.floor(s/67108864),e[i++]=67108863&s}return n},t=26):(r.prototype.am=function(t,r,e,i,n,o){for(var s=16383&r,u=r>>14;--o>=0;){var h=16383&this[t],a=this[t++]>>14,f=u*h+a*s;n=((h=s*h+((16383&f)<<14)+e[i]+n)>>28)+(f>>14)+u*a,e[i++]=268435455&h}return n},t=28),r.prototype.DB=t,r.prototype.DM=(1<<t)-1,r.prototype.DV=1<<t,r.prototype.FV=Math.pow(2,52),r.prototype.F1=52-t,r.prototype.F2=2*t-52;var n,o,s="0123456789abcdefghijklmnopqrstuvwxyz",u=new Array;for(n="0".charCodeAt(0),o=0;o<=9;++o)u[n++]=o;for(n="a".charCodeAt(0),o=10;o<36;++o)u[n++]=o;for(n="A".charCodeAt(0),o=10;o<36;++o)u[n++]=o;function h(t){return s.charAt(t)}function a(t,r){var e=u[t.charCodeAt(r)];return null==e?-1:e}function f(t){var r=e();return r.fromInt(t),r}function c(t){var r,e=1;return 0!=(r=t>>>16)&&(t=r,e+=16),0!=(r=t>>8)&&(t=r,e+=8),0!=(r=t>>4)&&(t=r,e+=4),0!=(r=t>>2)&&(t=r,e+=2),0!=(r=t>>1)&&(t=r,e+=1),e}function p(t){this.m=t}function y(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}function g(t,r){return t&r}function d(t,r){return t|r}function m(t,r){return t^r}function v(t,r){return t&~r}function T(t){if(0==t)return-1;var r=0;return 65535&t||(t>>=16,r+=16),255&t||(t>>=8,r+=8),15&t||(t>>=4,r+=4),3&t||(t>>=2,r+=2),1&t||++r,r}function w(t){for(var r=0;0!=t;)t&=t-1,++r;return r}function b(){}function F(t){return t}function B(t){this.r2=e(),this.q3=e(),r.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t),this.m=t}p.prototype.convert=function(t){return t.s<0||t.compareTo(this.m)>=0?t.mod(this.m):t},p.prototype.revert=function(t){return t},p.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},p.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},p.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},y.prototype.convert=function(t){var i=e();return t.abs().dlShiftTo(this.m.t,i),i.divRemTo(this.m,null,i),t.s<0&&i.compareTo(r.ZERO)>0&&this.m.subTo(i,i),i},y.prototype.revert=function(t){var r=e();return t.copyTo(r),this.reduce(r),r},y.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var r=0;r<this.m.t;++r){var e=32767&t[r],i=e*this.mpl+((e*this.mph+(t[r]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[e=r+this.m.t]+=this.m.am(0,i,t,r,0,this.m.t);t[e]>=t.DV;)t[e]-=t.DV,t[++e]++}t.clamp(),t.drShiftTo(this.m.t,t),t.compareTo(this.m)>=0&&t.subTo(this.m,t)},y.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},y.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)},r.prototype.copyTo=function(t){for(var r=this.t-1;r>=0;--r)t[r]=this[r];t.t=this.t,t.s=this.s},r.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,t>0?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},r.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var n=t.length,o=!1,s=0;--n>=0;){var u=8==i?255&t[n]:a(t,n);u<0?"-"==t.charAt(n)&&(o=!0):(o=!1,0==s?this[this.t++]=u:s+i>this.DB?(this[this.t-1]|=(u&(1<<this.DB-s)-1)<<s,this[this.t++]=u>>this.DB-s):this[this.t-1]|=u<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&128&t[0]&&(this.s=-1,s>0&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),o&&r.ZERO.subTo(this,this)},r.prototype.clamp=function(){for(var t=this.s&this.DM;this.t>0&&this[this.t-1]==t;)--this.t},r.prototype.dlShiftTo=function(t,r){var e;for(e=this.t-1;e>=0;--e)r[e+t]=this[e];for(e=t-1;e>=0;--e)r[e]=0;r.t=this.t+t,r.s=this.s},r.prototype.drShiftTo=function(t,r){for(var e=t;e<this.t;++e)r[e-t]=this[e];r.t=Math.max(this.t-t,0),r.s=this.s},r.prototype.lShiftTo=function(t,r){var e,i=t%this.DB,n=this.DB-i,o=(1<<n)-1,s=Math.floor(t/this.DB),u=this.s<<i&this.DM;for(e=this.t-1;e>=0;--e)r[e+s+1]=this[e]>>n|u,u=(this[e]&o)<<i;for(e=s-1;e>=0;--e)r[e]=0;r[s]=u,r.t=this.t+s+1,r.s=this.s,r.clamp()},r.prototype.rShiftTo=function(t,r){r.s=this.s;var e=Math.floor(t/this.DB);if(e>=this.t)r.t=0;else{var i=t%this.DB,n=this.DB-i,o=(1<<i)-1;r[0]=this[e]>>i;for(var s=e+1;s<this.t;++s)r[s-e-1]|=(this[s]&o)<<n,r[s-e]=this[s]>>i;i>0&&(r[this.t-e-1]|=(this.s&o)<<n),r.t=this.t-e,r.clamp()}},r.prototype.subTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]-t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i-=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i-=t[e],r[e++]=i&this.DM,i>>=this.DB;i-=t.s}r.s=i<0?-1:0,i<-1?r[e++]=this.DV+i:i>0&&(r[e++]=i),r.t=e,r.clamp()},r.prototype.multiplyTo=function(t,e){var i=this.abs(),n=t.abs(),o=i.t;for(e.t=o+n.t;--o>=0;)e[o]=0;for(o=0;o<n.t;++o)e[o+i.t]=i.am(0,n[o],e,o,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&r.ZERO.subTo(e,e)},r.prototype.squareTo=function(t){for(var r=this.abs(),e=t.t=2*r.t;--e>=0;)t[e]=0;for(e=0;e<r.t-1;++e){var i=r.am(e,r[e],t,2*e,0,1);(t[e+r.t]+=r.am(e+1,2*r[e],t,2*e+1,i,r.t-e-1))>=r.DV&&(t[e+r.t]-=r.DV,t[e+r.t+1]=1)}t.t>0&&(t[t.t-1]+=r.am(e,r[e],t,2*e,0,1)),t.s=0,t.clamp()},r.prototype.divRemTo=function(t,i,n){var o=t.abs();if(!(o.t<=0)){var s=this.abs();if(s.t<o.t)return null!=i&&i.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=e());var u=e(),h=this.s,a=t.s,f=this.DB-c(o[o.t-1]);f>0?(o.lShiftTo(f,u),s.lShiftTo(f,n)):(o.copyTo(u),s.copyTo(n));var l=u.t,p=u[l-1];if(0!=p){var y=p*(1<<this.F1)+(l>1?u[l-2]>>this.F2:0),g=this.FV/y,d=(1<<this.F1)/y,m=1<<this.F2,v=n.t,T=v-l,w=null==i?e():i;for(u.dlShiftTo(T,w),n.compareTo(w)>=0&&(n[n.t++]=1,n.subTo(w,n)),r.ONE.dlShiftTo(l,w),w.subTo(u,u);u.t<l;)u[u.t++]=0;for(;--T>=0;){var b=n[--v]==p?this.DM:Math.floor(n[v]*g+(n[v-1]+m)*d);if((n[v]+=u.am(0,b,n,T,0,l))<b)for(u.dlShiftTo(T,w),n.subTo(w,n);n[v]<--b;)n.subTo(w,n)}null!=i&&(n.drShiftTo(l,i),h!=a&&r.ZERO.subTo(i,i)),n.t=l,n.clamp(),f>0&&n.rShiftTo(f,n),h<0&&r.ZERO.subTo(n,n)}}},r.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(!(1&t))return 0;var r=3&t;return(r=(r=(r=(r=r*(2-(15&t)*r)&15)*(2-(255&t)*r)&255)*(2-((65535&t)*r&65535))&65535)*(2-t*r%this.DV)%this.DV)>0?this.DV-r:-r},r.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},r.prototype.exp=function(t,i){if(t>4294967295||t<1)return r.ONE;var n=e(),o=e(),s=i.convert(this),u=c(t)-1;for(s.copyTo(n);--u>=0;)if(i.sqrTo(n,o),(t&1<<u)>0)i.mulTo(o,s,n);else{var h=n;n=o,o=h}return i.revert(n)},r.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return this.toRadix(t);r=2}var e,i=(1<<r)-1,n=!1,o="",s=this.t,u=this.DB-s*this.DB%r;if(s-- >0)for(u<this.DB&&(e=this[s]>>u)>0&&(n=!0,o=h(e));s>=0;)u<r?(e=(this[s]&(1<<u)-1)<<r-u,e|=this[--s]>>(u+=this.DB-r)):(e=this[s]>>(u-=r)&i,u<=0&&(u+=this.DB,--s)),e>0&&(n=!0),n&&(o+=h(e));return n?o:"0"},r.prototype.negate=function(){var t=e();return r.ZERO.subTo(this,t),t},r.prototype.abs=function(){return this.s<0?this.negate():this},r.prototype.compareTo=function(t){var r=this.s-t.s;if(0!=r)return r;var e=this.t;if(0!=(r=e-t.t))return this.s<0?-r:r;for(;--e>=0;)if(0!=(r=this[e]-t[e]))return r;return 0},r.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+c(this[this.t-1]^this.s&this.DM)},r.prototype.mod=function(t){var i=e();return this.abs().divRemTo(t,null,i),this.s<0&&i.compareTo(r.ZERO)>0&&t.subTo(i,i),i},r.prototype.modPowInt=function(t,r){var e;return e=t<256||r.isEven()?new p(r):new y(r),this.exp(t,e)},r.ZERO=f(0),r.ONE=f(1),b.prototype.convert=F,b.prototype.revert=F,b.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e)},b.prototype.sqrTo=function(t,r){t.squareTo(r)},B.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var r=e();return t.copyTo(r),this.reduce(r),r},B.prototype.revert=function(t){return t},B.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);t.compareTo(this.m)>=0;)t.subTo(this.m,t)},B.prototype.mulTo=function(t,r,e){t.multiplyTo(r,e),this.reduce(e)},B.prototype.sqrTo=function(t,r){t.squareTo(r),this.reduce(r)};var x,S,q,E=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],I=(1<<26)/E[E.length-1];function D(){var t;t=(new Date).getTime(),S[q++]^=255&t,S[q++]^=t>>8&255,S[q++]^=t>>16&255,S[q++]^=t>>24&255,q>=H&&(q-=H)}if(r.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},r.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||t>36)return"0";var r=this.chunkSize(t),i=Math.pow(t,r),n=f(i),o=e(),s=e(),u="";for(this.divRemTo(n,o,s);o.signum()>0;)u=(i+s.intValue()).toString(t).substr(1)+u,o.divRemTo(n,o,s);return s.intValue().toString(t)+u},r.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),n=Math.pow(e,i),o=!1,s=0,u=0,h=0;h<t.length;++h){var f=a(t,h);f<0?"-"==t.charAt(h)&&0==this.signum()&&(o=!0):(u=e*u+f,++s>=i&&(this.dMultiply(n),this.dAddOffset(u,0),s=0,u=0))}s>0&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(u,0)),o&&r.ZERO.subTo(this,this)},r.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(r.ONE.shiftLeft(t-1),d,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(r.ONE.shiftLeft(t-1),this);else{var n=new Array,o=7&t;n.length=1+(t>>3),e.nextBytes(n),o>0?n[0]&=(1<<o)-1:n[0]=0,this.fromString(n,256)}},r.prototype.bitwiseTo=function(t,r,e){var i,n,o=Math.min(t.t,this.t);for(i=0;i<o;++i)e[i]=r(this[i],t[i]);if(t.t<this.t){for(n=t.s&this.DM,i=o;i<this.t;++i)e[i]=r(this[i],n);e.t=this.t}else{for(n=this.s&this.DM,i=o;i<t.t;++i)e[i]=r(n,t[i]);e.t=t.t}e.s=r(this.s,t.s),e.clamp()},r.prototype.changeBit=function(t,e){var i=r.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},r.prototype.addTo=function(t,r){for(var e=0,i=0,n=Math.min(t.t,this.t);e<n;)i+=this[e]+t[e],r[e++]=i&this.DM,i>>=this.DB;if(t.t<this.t){for(i+=t.s;e<this.t;)i+=this[e],r[e++]=i&this.DM,i>>=this.DB;i+=this.s}else{for(i+=this.s;e<t.t;)i+=t[e],r[e++]=i&this.DM,i>>=this.DB;i+=t.s}r.s=i<0?-1:0,i>0?r[e++]=i:i<-1&&(r[e++]=this.DV+i),r.t=e,r.clamp()},r.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},r.prototype.dAddOffset=function(t,r){if(0!=t){for(;this.t<=r;)this[this.t++]=0;for(this[r]+=t;this[r]>=this.DV;)this[r]-=this.DV,++r>=this.t&&(this[this.t++]=0),++this[r]}},r.prototype.multiplyLowerTo=function(t,r,e){var i,n=Math.min(this.t+t.t,r);for(e.s=0,e.t=n;n>0;)e[--n]=0;for(i=e.t-this.t;n<i;++n)e[n+this.t]=this.am(0,t[n],e,n,0,this.t);for(i=Math.min(t.t,r);n<i;++n)this.am(0,t[n],e,n,0,r-n);e.clamp()},r.prototype.multiplyUpperTo=function(t,r,e){--r;var i=e.t=this.t+t.t-r;for(e.s=0;--i>=0;)e[i]=0;for(i=Math.max(r-this.t,0);i<t.t;++i)e[this.t+i-r]=this.am(r-i,t[i],e,0,0,this.t+i-r);e.clamp(),e.drShiftTo(1,e)},r.prototype.modInt=function(t){if(t<=0)return 0;var r=this.DV%t,e=this.s<0?t-1:0;if(this.t>0)if(0==r)e=this[0]%t;else for(var i=this.t-1;i>=0;--i)e=(r*e+this[i])%t;return e},r.prototype.millerRabin=function(t){var i=this.subtract(r.ONE),n=i.getLowestSetBit();if(n<=0)return!1;var o=i.shiftRight(n);(t=t+1>>1)>E.length&&(t=E.length);for(var s=e(),u=0;u<t;++u){s.fromInt(E[Math.floor(Math.random()*E.length)]);var h=s.modPow(o,this);if(0!=h.compareTo(r.ONE)&&0!=h.compareTo(i)){for(var a=1;a++<n&&0!=h.compareTo(i);)if(0==(h=h.modPowInt(2,this)).compareTo(r.ONE))return!1;if(0!=h.compareTo(i))return!1}}return!0},r.prototype.clone=function(){var t=e();return this.copyTo(t),t},r.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},r.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},r.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},r.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},r.prototype.toByteArray=function(){var t=this.t,r=new Array;r[0]=this.s;var e,i=this.DB-t*this.DB%8,n=0;if(t-- >0)for(i<this.DB&&(e=this[t]>>i)!=(this.s&this.DM)>>i&&(r[n++]=e|this.s<<this.DB-i);t>=0;)i<8?(e=(this[t]&(1<<i)-1)<<8-i,e|=this[--t]>>(i+=this.DB-8)):(e=this[t]>>(i-=8)&255,i<=0&&(i+=this.DB,--t)),128&e&&(e|=-256),0==n&&(128&this.s)!=(128&e)&&++n,(n>0||e!=this.s)&&(r[n++]=e);return r},r.prototype.equals=function(t){return 0==this.compareTo(t)},r.prototype.min=function(t){return this.compareTo(t)<0?this:t},r.prototype.max=function(t){return this.compareTo(t)>0?this:t},r.prototype.and=function(t){var r=e();return this.bitwiseTo(t,g,r),r},r.prototype.or=function(t){var r=e();return this.bitwiseTo(t,d,r),r},r.prototype.xor=function(t){var r=e();return this.bitwiseTo(t,m,r),r},r.prototype.andNot=function(t){var r=e();return this.bitwiseTo(t,v,r),r},r.prototype.not=function(){for(var t=e(),r=0;r<this.t;++r)t[r]=this.DM&~this[r];return t.t=this.t,t.s=~this.s,t},r.prototype.shiftLeft=function(t){var r=e();return t<0?this.rShiftTo(-t,r):this.lShiftTo(t,r),r},r.prototype.shiftRight=function(t){var r=e();return t<0?this.lShiftTo(-t,r):this.rShiftTo(t,r),r},r.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+T(this[t]);return this.s<0?this.t*this.DB:-1},r.prototype.bitCount=function(){for(var t=0,r=this.s&this.DM,e=0;e<this.t;++e)t+=w(this[e]^r);return t},r.prototype.testBit=function(t){var r=Math.floor(t/this.DB);return r>=this.t?0!=this.s:!!(this[r]&1<<t%this.DB)},r.prototype.setBit=function(t){return this.changeBit(t,d)},r.prototype.clearBit=function(t){return this.changeBit(t,v)},r.prototype.flipBit=function(t){return this.changeBit(t,m)},r.prototype.add=function(t){var r=e();return this.addTo(t,r),r},r.prototype.subtract=function(t){var r=e();return this.subTo(t,r),r},r.prototype.multiply=function(t){var r=e();return this.multiplyTo(t,r),r},r.prototype.divide=function(t){var r=e();return this.divRemTo(t,r,null),r},r.prototype.remainder=function(t){var r=e();return this.divRemTo(t,null,r),r},r.prototype.divideAndRemainder=function(t){var r=e(),i=e();return this.divRemTo(t,r,i),new Array(r,i)},r.prototype.modPow=function(t,r){var i,n,o=t.bitLength(),s=f(1);if(o<=0)return s;i=o<18?1:o<48?3:o<144?4:o<768?5:6,n=o<8?new p(r):r.isEven()?new B(r):new y(r);var u=new Array,h=3,a=i-1,l=(1<<i)-1;if(u[1]=n.convert(this),i>1){var g=e();for(n.sqrTo(u[1],g);h<=l;)u[h]=e(),n.mulTo(g,u[h-2],u[h]),h+=2}var d,m,v=t.t-1,T=!0,w=e();for(o=c(t[v])-1;v>=0;){for(o>=a?d=t[v]>>o-a&l:(d=(t[v]&(1<<o+1)-1)<<a-o,v>0&&(d|=t[v-1]>>this.DB+o-a)),h=i;!(1&d);)d>>=1,--h;if((o-=h)<0&&(o+=this.DB,--v),T)u[d].copyTo(s),T=!1;else{for(;h>1;)n.sqrTo(s,w),n.sqrTo(w,s),h-=2;h>0?n.sqrTo(s,w):(m=s,s=w,w=m),n.mulTo(w,u[d],s)}for(;v>=0&&!(t[v]&1<<o);)n.sqrTo(s,w),m=s,s=w,w=m,--o<0&&(o=this.DB-1,--v)}return n.revert(s)},r.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return r.ZERO;for(var i=t.clone(),n=this.clone(),o=f(1),s=f(0),u=f(0),h=f(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(o.isEven()&&s.isEven()||(o.addTo(this,o),s.subTo(t,s)),o.rShiftTo(1,o)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;n.isEven();)n.rShiftTo(1,n),e?(u.isEven()&&h.isEven()||(u.addTo(this,u),h.subTo(t,h)),u.rShiftTo(1,u)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);i.compareTo(n)>=0?(i.subTo(n,i),e&&o.subTo(u,o),s.subTo(h,s)):(n.subTo(i,n),e&&u.subTo(o,u),h.subTo(s,h))}return 0!=n.compareTo(r.ONE)?r.ZERO:h.compareTo(t)>=0?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},r.prototype.pow=function(t){return this.exp(t,new b)},r.prototype.gcd=function(t){var r=this.s<0?this.negate():this.clone(),e=t.s<0?t.negate():t.clone();if(r.compareTo(e)<0){var i=r;r=e,e=i}var n=r.getLowestSetBit(),o=e.getLowestSetBit();if(o<0)return r;for(n<o&&(o=n),o>0&&(r.rShiftTo(o,r),e.rShiftTo(o,e));r.signum()>0;)(n=r.getLowestSetBit())>0&&r.rShiftTo(n,r),(n=e.getLowestSetBit())>0&&e.rShiftTo(n,e),r.compareTo(e)>=0?(r.subTo(e,r),r.rShiftTo(1,r)):(e.subTo(r,e),e.rShiftTo(1,e));return o>0&&e.lShiftTo(o,e),e},r.prototype.isProbablePrime=function(t){var r,e=this.abs();if(1==e.t&&e[0]<=E[E.length-1]){for(r=0;r<E.length;++r)if(e[0]==E[r])return!0;return!1}if(e.isEven())return!1;for(r=1;r<E.length;){for(var i=E[r],n=r+1;n<E.length&&i<I;)i*=E[n++];for(i=e.modInt(i);r<n;)if(i%E[r++]==0)return!1}return e.millerRabin(t)},r.prototype.square=function(){var t=e();return this.squareTo(t),t},r.prototype.Barrett=B,null==S){var A;if(S=new Array,q=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var R=new Uint8Array(32);for(window.crypto.getRandomValues(R),A=0;A<32;++A)S[q++]=R[A]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var P=window.crypto.random(32);for(A=0;A<P.length;++A)S[q++]=255&P.charCodeAt(A)}for(;q<H;)A=Math.floor(65536*Math.random()),S[q++]=A>>>8,S[q++]=255&A;q=0,D()}function O(){if(null==x){for(D(),(x=new C).init(S),q=0;q<S.length;++q)S[q]=0;q=0}return x.next()}function M(){}function C(){this.i=0,this.j=0,this.S=new Array}M.prototype.nextBytes=function(t){var r;for(r=0;r<t.length;++r)t[r]=O()},C.prototype.init=function(t){var r,e,i;for(r=0;r<256;++r)this.S[r]=r;for(e=0,r=0;r<256;++r)e=e+this.S[r]+t[r%t.length]&255,i=this.S[r],this.S[r]=this.S[e],this.S[e]=i;this.i=0,this.j=0},C.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]};var H=256;l.exports={default:r,BigInteger:r,SecureRandom:M}}.call(f);var y=p.exports;const{BigInteger:g}=y;class d{constructor(){this.tlv=null,this.t="00",this.l="00",this.v=""}getEncodedHex(){return this.tlv||(this.v=this.getValue(),this.l=this.getLength(),this.tlv=this.t+this.l+this.v),this.tlv}getLength(){const t=this.v.length/2;let r=t.toString(16);if(r.length%2==1&&(r="0"+r),t<128)return r;return(128+r.length/2).toString(16)+r}getValue(){return""}}class m extends d{constructor(t){super(),this.t="02",t&&(this.v=function(t){let r=t.toString(16);if("-"!==r[0])r.length%2==1?r="0"+r:r.match(/^[0-7]/)||(r="00"+r);else{r=r.substr(1);let e=r.length;e%2==1?e+=1:r.match(/^[0-7]/)||(e+=2);let i="";for(let t=0;t<e;t++)i+="f";i=new g(i,16),r=i.xor(t).add(g.ONE),r=r.toString(16).replace(/^-/,"")}return r}(t))}getValue(){return this.v}}class v extends d{constructor(t){super(),this.t="30",this.asn1Array=t}getValue(){return this.v=this.asn1Array.map((t=>t.getEncodedHex())).join(""),this.v}}function T(t,r){return+t[r+2]<8?1:128&+t.substr(r+2,2)}function w(t,r){const e=T(t,r),i=t.substr(r+2,2*e);if(!i)return-1;return(+i[0]<8?new g(i,16):new g(i.substr(2),16)).intValue()}function b(t,r){return r+2*(T(t,r)+1)}var F={encodeDer(t,r){const e=new m(t),i=new m(r);return new v([e,i]).getEncodedHex()},decodeDer(t){const r=b(t,0),e=b(t,r),i=w(t,r),n=t.substr(e,2*i),o=e+n.length,s=b(t,o),u=w(t,o),h=t.substr(s,2*u);return{r:new g(n,16),s:new g(h,16)}}};const{BigInteger:B}=y,x=new B("2"),S=new B("3");class q{constructor(t,r){this.x=r,this.q=t}equals(t){return t===this||this.q.equals(t.q)&&this.x.equals(t.x)}toBigInteger(){return this.x}negate(){return new q(this.q,this.x.negate().mod(this.q))}add(t){return new q(this.q,this.x.add(t.toBigInteger()).mod(this.q))}subtract(t){return new q(this.q,this.x.subtract(t.toBigInteger()).mod(this.q))}multiply(t){return new q(this.q,this.x.multiply(t.toBigInteger()).mod(this.q))}divide(t){return new q(this.q,this.x.multiply(t.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new q(this.q,this.x.square().mod(this.q))}}class E{constructor(t,r,e,i){this.curve=t,this.x=r,this.y=e,this.z=null==i?B.ONE:i,this.zinv=null}getX(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.x.toBigInteger().multiply(this.zinv).mod(this.curve.q))}getY(){return null===this.zinv&&(this.zinv=this.z.modInverse(this.curve.q)),this.curve.fromBigInteger(this.y.toBigInteger().multiply(this.zinv).mod(this.curve.q))}equals(t){if(t===this)return!0;if(this.isInfinity())return t.isInfinity();if(t.isInfinity())return this.isInfinity();if(!t.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(B.ZERO))return!1;return t.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(t.z)).mod(this.curve.q).equals(B.ZERO)}isInfinity(){return null===this.x&&null===this.y||this.z.equals(B.ZERO)&&!this.y.toBigInteger().equals(B.ZERO)}negate(){return new E(this.curve,this.x,this.y.negate(),this.z)}add(t){if(this.isInfinity())return t;if(t.isInfinity())return this;const r=this.x.toBigInteger(),e=this.y.toBigInteger(),i=this.z,n=t.x.toBigInteger(),o=t.y.toBigInteger(),s=t.z,u=this.curve.q,h=r.multiply(s).mod(u),a=n.multiply(i).mod(u),f=h.subtract(a),c=e.multiply(s).mod(u),l=o.multiply(i).mod(u),p=c.subtract(l);if(B.ZERO.equals(f))return B.ZERO.equals(p)?this.twice():this.curve.infinity;const y=h.add(a),g=i.multiply(s).mod(u),d=f.square().mod(u),m=f.multiply(d).mod(u),v=g.multiply(p.square()).subtract(y.multiply(d)).mod(u),T=f.multiply(v).mod(u),w=p.multiply(d.multiply(h).subtract(v)).subtract(c.multiply(m)).mod(u),b=m.multiply(g).mod(u);return new E(this.curve,this.curve.fromBigInteger(T),this.curve.fromBigInteger(w),b)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const t=this.x.toBigInteger(),r=this.y.toBigInteger(),e=this.z,i=this.curve.q,n=this.curve.a.toBigInteger(),o=t.square().multiply(S).add(n.multiply(e.square())).mod(i),s=r.shiftLeft(1).multiply(e).mod(i),u=r.square().mod(i),h=u.multiply(t).multiply(e).mod(i),a=s.square().mod(i),f=o.square().subtract(h.shiftLeft(3)).mod(i),c=s.multiply(f).mod(i),l=o.multiply(h.shiftLeft(2).subtract(f)).subtract(a.shiftLeft(1).multiply(u)).mod(i),p=s.multiply(a).mod(i);return new E(this.curve,this.curve.fromBigInteger(c),this.curve.fromBigInteger(l),p)}multiply(t){if(this.isInfinity())return this;if(!t.signum())return this.curve.infinity;const r=t.multiply(S),e=this.negate();let i=this;for(let n=r.bitLength()-2;n>0;n--){i=i.twice();const o=r.testBit(n);o!==t.testBit(n)&&(i=i.add(o?this:e))}return i}}var I={ECPointFp:E,ECCurveFp:class{constructor(t,r,e){this.q=t,this.a=this.fromBigInteger(r),this.b=this.fromBigInteger(e),this.infinity=new E(this,null,null)}equals(t){return t===this||this.q.equals(t.q)&&this.a.equals(t.a)&&this.b.equals(t.b)}fromBigInteger(t){return new q(this.q,t)}decodePointHex(t){switch(parseInt(t.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const r=this.fromBigInteger(new B(t.substr(2),16));let e=this.fromBigInteger(r.multiply(r.square()).add(r.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new B("4")).add(B.ONE),this.q));return e.toBigInteger().mod(x).equals(new B(t.substr(0,2),16).subtract(x))||(e=e.negate()),new E(this,r,e);case 4:case 6:case 7:const i=(t.length-2)/2,n=t.substr(2,i),o=t.substr(i+2,i);return new E(this,this.fromBigInteger(new B(n,16)),this.fromBigInteger(new B(o,16)));default:return null}}}};const{BigInteger:D,SecureRandom:A}=y,{ECCurveFp:R}=I,P=new A,{curve:O,G:M,n:C}=H();function H(){const t=new D("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),r=new D("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),e=new D("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),i=new R(t,r,e),n=i.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:i,G:n,n:new D("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function N(t,r){return t.length>=r?t:new Array(r-t.length+1).join("0")+t}var K={getGlobalCurve:function(){return O},generateEcparam:H,generateKeyPairHex:function(t,r,e){const i=(t?new D(t,r,e):new D(C.bitLength(),P)).mod(C.subtract(D.ONE)).add(D.ONE),n=N(i.toString(16),64),o=M.multiply(i);return{privateKey:n,publicKey:"04"+N(o.getX().toBigInteger().toString(16),64)+N(o.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(t){if(130!==t.length)throw new Error("Invalid public key to compress");const r=(t.length-2)/2,e=t.substr(2,r);let i="03";return new D(t.substr(r+2,r),16).mod(new D("2")).equals(D.ZERO)&&(i="02"),i+e},utf8ToHex:function(t){const r=(t=unescape(encodeURIComponent(t))).length,e=[];for(let i=0;i<r;i++)e[i>>>2]|=(255&t.charCodeAt(i))<<24-i%4*8;const i=[];for(let t=0;t<r;t++){const r=e[t>>>2]>>>24-t%4*8&255;i.push((r>>>4).toString(16)),i.push((15&r).toString(16))}return i.join("")},leftPad:N,arrayToHex:function(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")},arrayToUtf8:function(t){const r=[];let e=0;for(let i=0;i<2*t.length;i+=2)r[i>>>3]|=parseInt(t[e],10)<<24-i%8*4,e++;try{const e=[];for(let i=0;i<t.length;i++){const t=r[i>>>2]>>>24-i%4*8&255;e.push(String.fromCharCode(t))}return decodeURIComponent(escape(e.join("")))}catch(t){throw new Error("Malformed UTF-8 data")}},hexToArray:function(t){const r=[];let e=t.length;e%2!=0&&(t=N(t,e+1)),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r},verifyPublicKey:function(t){const r=O.decodePointHex(t);if(!r)return!1;const e=r.getX();return r.getY().square().equals(e.multiply(e.square()).add(e.multiply(O.a)).add(O.b))},comparePublicKeyHex:function(t,r){const e=O.decodePointHex(t);if(!e)return!1;const i=O.decodePointHex(r);return!!i&&e.equals(i)}};const V=new Uint32Array(68),L=new Uint32Array(64);function z(t,r){const e=31&r;return t<<e|t>>>32-e}function k(t,r){const e=[];for(let i=t.length-1;i>=0;i--)e[i]=255&(t[i]^r[i]);return e}function Z(t){return t^z(t,9)^z(t,17)}function j(t){let r=8*t.length,e=r%512;e=e>=448?512-e%448-1:448-e-1;const i=new Array((e-7)/8),n=new Array(8);for(let t=0,r=i.length;t<r;t++)i[t]=0;for(let t=0,r=n.length;t<r;t++)n[t]=0;r=r.toString(2);for(let t=7;t>=0;t--)if(r.length>8){const e=r.length-8;n[t]=parseInt(r.substr(e),2),r=r.substr(0,e)}else r.length>0&&(n[t]=parseInt(r,2),r="");const o=new Uint8Array([...t,128,...i,...n]),s=new DataView(o.buffer,0),u=o.length/64,h=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let t=0;t<u;t++){V.fill(0),L.fill(0);const r=16*t;for(let t=0;t<16;t++)V[t]=s.getUint32(4*(r+t),!1);for(let t=16;t<68;t++)V[t]=(a=V[t-16]^V[t-9]^z(V[t-3],15))^z(a,15)^z(a,23)^z(V[t-13],7)^V[t-6];for(let t=0;t<64;t++)L[t]=V[t]^V[t+4];const e=2043430169,i=2055708042;let n,o,u,f,c,l=h[0],p=h[1],y=h[2],g=h[3],d=h[4],m=h[5],v=h[6],T=h[7];for(let t=0;t<64;t++)c=t>=0&&t<=15?e:i,n=z(z(l,12)+d+z(c,t),7),o=n^z(l,12),u=(t>=0&&t<=15?l^p^y:l&p|l&y|p&y)+g+o+L[t],f=(t>=0&&t<=15?d^m^v:d&m|~d&v)+T+n+V[t],g=y,y=z(p,9),p=l,l=u,T=v,v=z(m,19),m=d,d=Z(f);h[0]^=l,h[1]^=p,h[2]^=y,h[3]^=g,h[4]^=d,h[5]^=m,h[6]^=v,h[7]^=T}var a;const f=[];for(let t=0,r=h.length;t<r;t++){const r=h[t];f.push((4278190080&r)>>>24,(16711680&r)>>>16,(65280&r)>>>8,255&r)}return f}const U=new Uint8Array(64),_=new Uint8Array(64);for(let t=0;t<64;t++)U[t]=54,_[t]=92;var $={sm3:j,hmac:function(t,r){for(r.length>64&&(r=j(r));r.length<64;)r.push(0);const e=k(r,U),i=k(r,_),n=j([...e,...t]);return j([...i,...n])}};const{BigInteger:X}=y,{encodeDer:J,decodeDer:Y}=F,G=K,W=$.sm3,{G:Q,curve:tt,n:rt}=G.generateEcparam();function et(t,r,e="1234567812345678"){e=G.utf8ToHex(e);const i=G.leftPad(Q.curve.a.toBigInteger().toRadix(16),64),n=G.leftPad(Q.curve.b.toBigInteger().toRadix(16),64),o=G.leftPad(Q.getX().toBigInteger().toRadix(16),64),s=G.leftPad(Q.getY().toBigInteger().toRadix(16),64);let u,h;if(128===r.length)u=r.substr(0,64),h=r.substr(64,64);else{const t=Q.curve.decodePointHex(r);u=G.leftPad(t.getX().toBigInteger().toRadix(16),64),h=G.leftPad(t.getY().toBigInteger().toRadix(16),64)}const a=G.hexToArray(e+i+n+o+s+u+h),f=4*e.length;a.unshift(255&f),a.unshift(f>>8&255);const c=W(a);return G.arrayToHex(W(c.concat(G.hexToArray(t))))}function it(t){const r=Q.multiply(new X(t,16));return"04"+G.leftPad(r.getX().toBigInteger().toString(16),64)+G.leftPad(r.getY().toBigInteger().toString(16),64)}function nt(){const t=G.generateKeyPairHex(),r=tt.decodePointHex(t.publicKey);return t.k=new X(t.privateKey,16),t.x1=r.getX().toBigInteger(),t}var ot={generateKeyPairHex:G.generateKeyPairHex,compressPublicKeyHex:G.compressPublicKeyHex,comparePublicKeyHex:G.comparePublicKeyHex,doEncrypt:function(t,r,e=1){t="string"==typeof t?G.hexToArray(G.utf8ToHex(t)):Array.prototype.slice.call(t),r=G.getGlobalCurve().decodePointHex(r);const i=G.generateKeyPairHex(),n=new X(i.privateKey,16);let o=i.publicKey;o.length>128&&(o=o.substr(o.length-128));const s=r.multiply(n),u=G.hexToArray(G.leftPad(s.getX().toBigInteger().toRadix(16),64)),h=G.hexToArray(G.leftPad(s.getY().toBigInteger().toRadix(16),64)),a=G.arrayToHex(W([].concat(u,t,h)));let f=1,c=0,l=[];const p=[].concat(u,h),y=()=>{l=W([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let r=0,e=t.length;r<e;r++)c===l.length&&y(),t[r]^=255&l[c++];const g=G.arrayToHex(t);return 0===e?o+g+a:o+a+g},doDecrypt:function(t,r,e=1,{output:i="string"}={}){r=new X(r,16);let n=t.substr(128,64),o=t.substr(192);0===e&&(n=t.substr(t.length-64),o=t.substr(128,t.length-128-64));const s=G.hexToArray(o),u=G.getGlobalCurve().decodePointHex("04"+t.substr(0,128)).multiply(r),h=G.hexToArray(G.leftPad(u.getX().toBigInteger().toRadix(16),64)),a=G.hexToArray(G.leftPad(u.getY().toBigInteger().toRadix(16),64));let f=1,c=0,l=[];const p=[].concat(h,a),y=()=>{l=W([...p,f>>24&255,f>>16&255,f>>8&255,255&f]),f++,c=0};y();for(let t=0,r=s.length;t<r;t++)c===l.length&&y(),s[t]^=255&l[c++];return G.arrayToHex(W([].concat(h,s,a)))===n.toLowerCase()?"array"===i?s:G.arrayToUtf8(s):"array"===i?[]:""},doSignature:function(t,r,{pointPool:e,der:i,hash:n,publicKey:o,userId:s}={}){let u="string"==typeof t?G.utf8ToHex(t):G.arrayToHex(t);n&&(u=et(u,o=o||it(r),s));const h=new X(r,16),a=new X(u,16);let f=null,c=null,l=null;do{do{let t;t=e&&e.length?e.pop():nt(),f=t.k,c=a.add(t.x1).mod(rt)}while(c.equals(X.ZERO)||c.add(f).equals(rt));l=h.add(X.ONE).modInverse(rt).multiply(f.subtract(c.multiply(h))).mod(rt)}while(l.equals(X.ZERO));return i?J(c,l):G.leftPad(c.toString(16),64)+G.leftPad(l.toString(16),64)},doVerifySignature:function(t,r,e,{der:i,hash:n,userId:o}={}){let s,u,h="string"==typeof t?G.utf8ToHex(t):G.arrayToHex(t);if(n&&(h=et(h,e,o)),i){const t=Y(r);s=t.r,u=t.s}else s=new X(r.substring(0,64),16),u=new X(r.substring(64),16);const a=tt.decodePointHex(e),f=new X(h,16),c=s.add(u).mod(rt);if(c.equals(X.ZERO))return!1;const l=Q.multiply(u).add(a.multiply(c)),p=f.add(l.getX().toBigInteger()).mod(rt);return s.equals(p)},getPublicKeyFromPrivateKey:it,getPoint:nt,verifyPublicKey:G.verifyPublicKey};const{sm3:st,hmac:ut}=$;function ht(t){return t.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join("")}function at(t){const r=[];let e=t.length;var i,n;e%2!=0&&(n=e+1,t=(i=t).length>=n?i:new Array(n-i.length+1).join("0")+i),e=t.length;for(let i=0;i<e;i+=2)r.push(parseInt(t.substr(i,2),16));return r}const ft=0,ct=16,lt=[214,144,233,254,204,225,61,183,22,182,20,194,40,251,44,5,43,103,154,118,42,190,4,195,170,68,19,38,73,134,6,153,156,66,80,244,145,239,152,122,51,84,11,67,237,207,172,98,228,179,28,169,201,8,232,149,128,223,148,250,117,143,63,166,71,7,167,252,243,115,23,186,131,89,60,25,230,133,79,168,104,107,129,178,113,100,218,139,248,235,15,75,112,86,157,53,30,36,14,94,99,88,209,162,37,34,124,59,1,33,120,135,212,0,70,87,159,211,39,82,76,54,2,231,160,196,200,158,234,191,138,210,64,199,56,181,163,247,242,206,249,97,21,161,224,174,93,164,155,52,26,85,173,147,50,48,245,140,177,227,29,246,226,46,130,102,202,96,192,41,35,171,13,83,78,111,213,219,55,69,222,253,142,47,3,255,106,114,109,108,91,81,141,27,175,146,187,221,188,127,17,217,92,65,31,16,90,216,10,193,49,136,165,205,123,189,45,116,208,18,184,229,180,176,137,105,151,74,12,150,119,126,101,185,241,9,197,110,198,132,24,240,125,236,58,220,77,32,121,238,95,62,215,203,57,72],pt=[462357,472066609,943670861,1415275113,1886879365,2358483617,2830087869,3301692121,3773296373,4228057617,404694573,876298825,1347903077,1819507329,2291111581,2762715833,3234320085,3705924337,4177462797,337322537,808926789,1280531041,1752135293,2223739545,2695343797,3166948049,3638552301,4110090761,269950501,741554753,1213159005,1684763257];function yt(t){const r=[];for(let e=0,i=t.length;e<i;e+=2)r.push(parseInt(t.substr(e,2),16));return r}function gt(t,r){const e=31&r;return t<<e|t>>>32-e}function dt(t){return(255<[t>>>24&255])<<24|(255<[t>>>16&255])<<16|(255<[t>>>8&255])<<8|255<[255&t]}function mt(t){return t^gt(t,2)^gt(t,10)^gt(t,18)^gt(t,24)}function vt(t){return t^gt(t,13)^gt(t,23)}function Tt(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[4*r],n[1]=255&t[4*r+1],n[2]=255&t[4*r+2],n[3]=255&t[4*r+3],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];for(let t,r=0;r<32;r+=4)t=i[1]^i[2]^i[3]^e[r+0],i[0]^=mt(dt(t)),t=i[2]^i[3]^i[0]^e[r+1],i[1]^=mt(dt(t)),t=i[3]^i[0]^i[1]^e[r+2],i[2]^=mt(dt(t)),t=i[0]^i[1]^i[2]^e[r+3],i[3]^=mt(dt(t));for(let t=0;t<16;t+=4)r[t]=i[3-t/4]>>>24&255,r[t+1]=i[3-t/4]>>>16&255,r[t+2]=i[3-t/4]>>>8&255,r[t+3]=255&i[3-t/4]}function wt(t,r,e,{padding:i="pkcs#7",mode:n,iv:o=[],output:s="string"}={}){if("cbc"===n&&("string"==typeof o&&(o=yt(o)),16!==o.length))throw new Error("iv is invalid");if("string"==typeof r&&(r=yt(r)),16!==r.length)throw new Error("key is invalid");if(t="string"==typeof t?e!==ft?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):yt(t):[...t],("pkcs#5"===i||"pkcs#7"===i)&&e!==ft){const r=ct-t.length%ct;for(let e=0;e<r;e++)t.push(r)}const u=new Array(32);!function(t,r,e){const i=new Array(4),n=new Array(4);for(let r=0;r<4;r++)n[0]=255&t[0+4*r],n[1]=255&t[1+4*r],n[2]=255&t[2+4*r],n[3]=255&t[3+4*r],i[r]=n[0]<<24|n[1]<<16|n[2]<<8|n[3];i[0]^=2746333894,i[1]^=1453994832,i[2]^=1736282519,i[3]^=2993693404;for(let t,e=0;e<32;e+=4)t=i[1]^i[2]^i[3]^pt[e+0],r[e+0]=i[0]^=vt(dt(t)),t=i[2]^i[3]^i[0]^pt[e+1],r[e+1]=i[1]^=vt(dt(t)),t=i[3]^i[0]^i[1]^pt[e+2],r[e+2]=i[2]^=vt(dt(t)),t=i[0]^i[1]^i[2]^pt[e+3],r[e+3]=i[3]^=vt(dt(t));if(e===ft)for(let t,e=0;e<16;e++)t=r[e],r[e]=r[31-e],r[31-e]=t}(r,u,e);const h=[];let a=o,f=t.length,c=0;for(;f>=ct;){const r=t.slice(c,c+16),i=new Array(16);if("cbc"===n)for(let t=0;t<ct;t++)e!==ft&&(r[t]^=a[t]);Tt(r,i,u);for(let t=0;t<ct;t++)"cbc"===n&&e===ft&&(i[t]^=a[t]),h[c+t]=i[t];"cbc"===n&&(a=e!==ft?i:r),f-=ct,c+=ct}if(("pkcs#5"===i||"pkcs#7"===i)&&e===ft){const t=h.length,r=h[t-1];for(let e=1;e<=r;e++)if(h[t-e]!==r)throw new Error("padding is invalid");h.splice(t-r,r)}return"array"!==s?e!==ft?h.map((t=>1===(t=t.toString(16)).length?"0"+t:t)).join(""):function(t){const r=[];for(let e=0,i=t.length;e<i;e++)t[e]>=240&&t[e]<=247?(r.push(String.fromCodePoint(((7&t[e])<<18)+((63&t[e+1])<<12)+((63&t[e+2])<<6)+(63&t[e+3]))),e+=3):t[e]>=224&&t[e]<=239?(r.push(String.fromCodePoint(((15&t[e])<<12)+((63&t[e+1])<<6)+(63&t[e+2]))),e+=2):t[e]>=192&&t[e]<=223?(r.push(String.fromCodePoint(((31&t[e])<<6)+(63&t[e+1]))),e++):r.push(String.fromCodePoint(t[e]));return r.join("")}(h):h}var bt={sm2:ot,sm3:function(t,r){if(t="string"==typeof t?function(t){const r=[];for(let e=0,i=t.length;e<i;e++){const i=t.codePointAt(e);if(i<=127)r.push(i);else if(i<=2047)r.push(192|i>>>6),r.push(128|63&i);else if(i<=55295||i>=57344&&i<=65535)r.push(224|i>>>12),r.push(128|i>>>6&63),r.push(128|63&i);else{if(!(i>=65536&&i<=1114111))throw r.push(i),new Error("input is not supported");e++,r.push(240|i>>>18&28),r.push(128|i>>>12&63),r.push(128|i>>>6&63),r.push(128|63&i)}}return r}(t):Array.prototype.slice.call(t),r){if("hmac"!==(r.mode||"hmac"))throw new Error("invalid mode");let e=r.key;if(!e)throw new Error("invalid key");return e="string"==typeof e?at(e):Array.prototype.slice.call(e),ht(ut(t,e))}return ht(st(t))},sm4:{encrypt:(t,r,e)=>wt(t,r,1,e),decrypt:(t,r,e)=>wt(t,r,0,e)}};const Ft={mode:"ecb",padding:"pkcs#5",output:"array"},Bt=r.Buffer,xt=function(t,r,e,i){return(n,o)=>{try{if(o.closeCrypto)return n;t.info=h(),t.publicKey=[...Bt.from(t.info.key)];const s=bt.sm2.doEncrypt(JSON.stringify(t.info),r,1);if(e.set(i,function(t){if("string"==typeof t)return String(t);return JSON.parse(JSON.stringify(t))}(s)),((t,r)=>{t.set("X-Encrypt-Key",r)})(o,"04"+s),n){"string"!=typeof n&&(n=JSON.stringify(n));const r=bt.sm4.encrypt(n,t.publicKey,Ft);return n=Bt.from(r)}return n}catch(t){console.error("encrypt error",t,n,o)}}},St=function(t){return(r,e)=>{try{if((t=>{const r=t.get(n);return r&&"string"==typeof r&&"sm4"===r.toLowerCase()})(e)){const e=Bt.from(r);return s(bt.sm4.decrypt(e,t.publicKey,{mode:"ecb",padding:"pkcs#5"}))}return r}catch(t){console.error("decrypt error",t,r,e)}}};var qt,Et,It={exports:{}},Dt={exports:{}};qt="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Et={rotl:function(t,r){return t<<r|t>>>32-r},rotr:function(t,r){return t<<32-r|t>>>r},endian:function(t){if(t.constructor==Number)return 16711935&Et.rotl(t,8)|4278255360&Et.rotl(t,24);for(var r=0;r<t.length;r++)t[r]=Et.endian(t[r]);return t},randomBytes:function(t){for(var r=[];t>0;t--)r.push(Math.floor(256*Math.random()));return r},bytesToWords:function(t){for(var r=[],e=0,i=0;e<t.length;e++,i+=8)r[i>>>5]|=t[e]<<24-i%32;return r},wordsToBytes:function(t){for(var r=[],e=0;e<32*t.length;e+=8)r.push(t[e>>>5]>>>24-e%32&255);return r},bytesToHex:function(t){for(var r=[],e=0;e<t.length;e++)r.push((t[e]>>>4).toString(16)),r.push((15&t[e]).toString(16));return r.join("")},hexToBytes:function(t){for(var r=[],e=0;e<t.length;e+=2)r.push(parseInt(t.substr(e,2),16));return r},bytesToBase64:function(t){for(var r=[],e=0;e<t.length;e+=3)for(var i=t[e]<<16|t[e+1]<<8|t[e+2],n=0;n<4;n++)8*e+6*n<=8*t.length?r.push(qt.charAt(i>>>6*(3-n)&63)):r.push("=");return r.join("")},base64ToBytes:function(t){t=t.replace(/[^A-Z0-9+\/]/gi,"");for(var r=[],e=0,i=0;e<t.length;i=++e%4)0!=i&&r.push((qt.indexOf(t.charAt(e-1))&Math.pow(2,-2*i+8)-1)<<2*i|qt.indexOf(t.charAt(e))>>>6-2*i);return r}},Dt.exports=Et;var At=Dt.exports,Rt={utf8:{stringToBytes:function(t){return Rt.bin.stringToBytes(unescape(encodeURIComponent(t)))},bytesToString:function(t){return decodeURIComponent(escape(Rt.bin.bytesToString(t)))}},bin:{stringToBytes:function(t){for(var r=[],e=0;e<t.length;e++)r.push(255&t.charCodeAt(e));return r},bytesToString:function(t){for(var r=[],e=0;e<t.length;e++)r.push(String.fromCharCode(t[e]));return r.join("")}}},Pt=Rt,Ot=function(t){return null!=t&&(Mt(t)||function(t){return"function"==typeof t.readFloatLE&&"function"==typeof t.slice&&Mt(t.slice(0,0))}(t)||!!t._isBuffer)};function Mt(t){return!!t.constructor&&"function"==typeof t.constructor.isBuffer&&t.constructor.isBuffer(t)}!function(){var t=At,r=Pt.utf8,e=Ot,i=Pt.bin,n=function(o,s){o.constructor==String?o=s&&"binary"===s.encoding?i.stringToBytes(o):r.stringToBytes(o):e(o)?o=Array.prototype.slice.call(o,0):Array.isArray(o)||o.constructor===Uint8Array||(o=o.toString());for(var u=t.bytesToWords(o),h=8*o.length,a=1732584193,f=-271733879,c=-1732584194,l=271733878,p=0;p<u.length;p++)u[p]=16711935&(u[p]<<8|u[p]>>>24)|4278255360&(u[p]<<24|u[p]>>>8);u[h>>>5]|=128<<h%32,u[14+(h+64>>>9<<4)]=h;var y=n._ff,g=n._gg,d=n._hh,m=n._ii;for(p=0;p<u.length;p+=16){var v=a,T=f,w=c,b=l;a=y(a,f,c,l,u[p+0],7,-680876936),l=y(l,a,f,c,u[p+1],12,-389564586),c=y(c,l,a,f,u[p+2],17,606105819),f=y(f,c,l,a,u[p+3],22,-1044525330),a=y(a,f,c,l,u[p+4],7,-176418897),l=y(l,a,f,c,u[p+5],12,1200080426),c=y(c,l,a,f,u[p+6],17,-1473231341),f=y(f,c,l,a,u[p+7],22,-45705983),a=y(a,f,c,l,u[p+8],7,1770035416),l=y(l,a,f,c,u[p+9],12,-1958414417),c=y(c,l,a,f,u[p+10],17,-42063),f=y(f,c,l,a,u[p+11],22,-1990404162),a=y(a,f,c,l,u[p+12],7,1804603682),l=y(l,a,f,c,u[p+13],12,-40341101),c=y(c,l,a,f,u[p+14],17,-1502002290),a=g(a,f=y(f,c,l,a,u[p+15],22,1236535329),c,l,u[p+1],5,-165796510),l=g(l,a,f,c,u[p+6],9,-1069501632),c=g(c,l,a,f,u[p+11],14,643717713),f=g(f,c,l,a,u[p+0],20,-373897302),a=g(a,f,c,l,u[p+5],5,-701558691),l=g(l,a,f,c,u[p+10],9,38016083),c=g(c,l,a,f,u[p+15],14,-660478335),f=g(f,c,l,a,u[p+4],20,-405537848),a=g(a,f,c,l,u[p+9],5,568446438),l=g(l,a,f,c,u[p+14],9,-1019803690),c=g(c,l,a,f,u[p+3],14,-187363961),f=g(f,c,l,a,u[p+8],20,1163531501),a=g(a,f,c,l,u[p+13],5,-1444681467),l=g(l,a,f,c,u[p+2],9,-51403784),c=g(c,l,a,f,u[p+7],14,1735328473),a=d(a,f=g(f,c,l,a,u[p+12],20,-1926607734),c,l,u[p+5],4,-378558),l=d(l,a,f,c,u[p+8],11,-2022574463),c=d(c,l,a,f,u[p+11],16,1839030562),f=d(f,c,l,a,u[p+14],23,-35309556),a=d(a,f,c,l,u[p+1],4,-1530992060),l=d(l,a,f,c,u[p+4],11,1272893353),c=d(c,l,a,f,u[p+7],16,-155497632),f=d(f,c,l,a,u[p+10],23,-1094730640),a=d(a,f,c,l,u[p+13],4,681279174),l=d(l,a,f,c,u[p+0],11,-358537222),c=d(c,l,a,f,u[p+3],16,-722521979),f=d(f,c,l,a,u[p+6],23,76029189),a=d(a,f,c,l,u[p+9],4,-640364487),l=d(l,a,f,c,u[p+12],11,-421815835),c=d(c,l,a,f,u[p+15],16,530742520),a=m(a,f=d(f,c,l,a,u[p+2],23,-995338651),c,l,u[p+0],6,-198630844),l=m(l,a,f,c,u[p+7],10,1126891415),c=m(c,l,a,f,u[p+14],15,-1416354905),f=m(f,c,l,a,u[p+5],21,-57434055),a=m(a,f,c,l,u[p+12],6,1700485571),l=m(l,a,f,c,u[p+3],10,-1894986606),c=m(c,l,a,f,u[p+10],15,-1051523),f=m(f,c,l,a,u[p+1],21,-2054922799),a=m(a,f,c,l,u[p+8],6,1873313359),l=m(l,a,f,c,u[p+15],10,-30611744),c=m(c,l,a,f,u[p+6],15,-1560198380),f=m(f,c,l,a,u[p+13],21,1309151649),a=m(a,f,c,l,u[p+4],6,-145523070),l=m(l,a,f,c,u[p+11],10,-1120210379),c=m(c,l,a,f,u[p+2],15,718787259),f=m(f,c,l,a,u[p+9],21,-343485551),a=a+v>>>0,f=f+T>>>0,c=c+w>>>0,l=l+b>>>0}return t.endian([a,f,c,l])};n._ff=function(t,r,e,i,n,o,s){var u=t+(r&e|~r&i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._gg=function(t,r,e,i,n,o,s){var u=t+(r&i|e&~i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._hh=function(t,r,e,i,n,o,s){var u=t+(r^e^i)+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._ii=function(t,r,e,i,n,o,s){var u=t+(e^(r|~i))+(n>>>0)+s;return(u<<o|u>>>32-o)+r},n._blocksize=16,n._digestsize=16,It.exports=function(r,e){if(null==r)throw new Error("Illegal argument "+r);var o=t.wordsToBytes(n(r,e));return e&&e.asBytes?o:e&&e.asString?i.bytesToString(o):t.bytesToHex(o)}}();var Ct=c(It.exports);const Ht=function(){const t=new Map;return{get:function(r){return t.get(r)},generateKey:function(t,r,e){try{const i="e0c7ff",n=((t,r)=>{const e=window.location.origin,i=new URL(e+t);for(const t in r)i.searchParams.append(t,r[t]);return i.toString()})(t,r??{}),o=`${n}-${i}-${e??""}`;return`${Ct(o)}-/${t}`}catch(r){return`${i(10)}-/${t}`}},set:function(r,e){t.set(r,e)},clear:function(r){t.delete(r)}}}();window.__buffer=r;const Nt=(r,e,i)=>{const h=t.create(r);return h.interceptors.request.use((t=>{const r=localStorage.getItem("cps_lang"),e={en:"en-US",ko:"ko-KR",zh:"zh-CN"};if(r&&Object.prototype.hasOwnProperty.call(e,r)){const i=e[r];t.headers.set({"Accept-Language":`${i},zh;q=0.9,en;q=0.8`})}return t})),i||function(t,r){if(!r||"string"!=typeof r)throw new Error(`publicKey is required and must be a string ${r}`);t.interceptors.request.use((t=>{const e=t.transformRequest,i=t?.headers?.__requestKey,n={info:null,publicKey:[]};if(!e)throw new Error(`request ${t} has no transformRequest`);if(!Array.isArray(e))throw new Error(`transformRequest ${e} is not an array`);e.push(xt(n,r,Ht,i));const o=St(n);if(!o)return t;const s=t.transformResponse;if(!s)throw new Error(`request ${t} has no transformResponse`);if("function"!=typeof o)throw new Error(`decryptFn ${o} is not a function`);if(!Array.isArray(s))throw new Error(`transformResponse ${s} is not an array`);return s.unshift(o),t})),t.interceptors.request.use((t=>{try{const r=encodeURI(t?.url??""),e=t.headers;return r?(e.__requestKey=Ht.generateKey(r,t?.params,e?.get("Authorization")),t):t}catch(r){return console.error("error",r),t}})),t.interceptors.request.use((t=>(t.headers.closeCrypto||(t.responseType="arraybuffer"),t))),t.interceptors.request.use((t=>{const r=t.data,e=t.headers;return r?((r instanceof FormData||r instanceof File)&&(e.closeCrypto=!0),t):t})),t.interceptors.request.use((t=>{const r=t.url,e=t.headers;if(!r)throw new Error("url is required");return{}.hasOwnProperty.call(e,"closeCrypto")||u(r)||(e.closeCrypto=!0),t})),t.interceptors.response.use((t=>{const{request:r,headers:e}=t;return e&&e.get(n)||"arraybuffer"===r?.responseType?.toLowerCase()||"blob"===r?.responseType?.toLowerCase()||(t.data=s(t.data)),t}),(t=>{const r=t.response;throw r?.data&&(r.data=o(r.data)),t}))}(h,e),h},Kt=bt.sm2.doDecrypt;export{Nt as createCryptoAxiosInstance,e as createRequestInstance,Kt as decryptHeadersInfo,h as getCryptoInfo,a as getSm4EncryptConfig,i as randomPassword,u as shouldEncrypt}; |
{ | ||
"name": "request-crypto", | ||
"description": "axios with crypto callback", | ||
"version": "1.7.7", | ||
"version": "1.7.9", | ||
"main": "index.cjs.js", | ||
@@ -6,0 +6,0 @@ "module": "index.esm.js", |
@@ -67,2 +67,3 @@ import { AxiosRequestTransformer, AxiosResponseTransformer, CreateAxiosDefaults, AxiosInstance } from 'axios'; | ||
params: null | undefined | Record<string, string>, | ||
token: number | string | undefined | null, | ||
) => string | ||
@@ -69,0 +70,0 @@ set: (key: string, value: T) => void |
{ | ||
"name": "request-crypto", | ||
"version": "1.7.7", | ||
"version": "1.7.9", | ||
"description": "axios with crypto callback", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
104059
500