UNPKG

bytefun-js

Version:

ByteFun JavaScript SDK

26 lines 1.08 MB
/* * Copyright 2025-2101 广州莱聚信息科技有限公司. * * This software is part of the bytefun Library. * * Licensed under the GNU Lesser General Public License, Version 3.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * https://www.gnu.org/licenses/lgpl-3.0.html * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * This software includes third-party libraries: * - jss (https://github.com/cssinjs/jss) * Licensed under the MIT License. * - sm-crypto (https://github.com/JuneAndGreen/sm-crypto) * Licensed under the MIT License. * - DOMPurify (https://github.com/cure53/DOMPurify) * Licensed under the MPL-2.0 OR Apache-2.0 License. */ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).ByteFunJS={})}(this,(function(e){"use strict";var t,i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n={exports:{}};t=n,function(){var e;function i(e,t,i){null!=e&&("number"==typeof e?this.fromNumber(e,t,i):null==t&&"string"!=typeof e?this.fromString(e,256):this.fromString(e,t))}function n(){return new i(null)}var r="undefined"!=typeof navigator;r&&"Microsoft Internet Explorer"==navigator.appName?(i.prototype.am=function(e,t,i,n,r,s){for(var a=32767&t,o=t>>15;--s>=0;){var l=32767&this[e],c=this[e++]>>15,d=o*l+c*a;r=((l=a*l+((32767&d)<<15)+i[n]+(1073741823&r))>>>30)+(d>>>15)+o*c+(r>>>30),i[n++]=1073741823&l}return r},e=30):r&&"Netscape"!=navigator.appName?(i.prototype.am=function(e,t,i,n,r,s){for(;--s>=0;){var a=t*this[e++]+i[n]+r;r=Math.floor(a/67108864),i[n++]=67108863&a}return r},e=26):(i.prototype.am=function(e,t,i,n,r,s){for(var a=16383&t,o=t>>14;--s>=0;){var l=16383&this[e],c=this[e++]>>14,d=o*l+c*a;r=((l=a*l+((16383&d)<<14)+i[n]+r)>>28)+(d>>14)+o*c,i[n++]=268435455&l}return r},e=28),i.prototype.DB=e,i.prototype.DM=(1<<e)-1,i.prototype.DV=1<<e,i.prototype.FV=Math.pow(2,52),i.prototype.F1=52-e,i.prototype.F2=2*e-52;var s,a,o=new Array;for(s="0".charCodeAt(0),a=0;a<=9;++a)o[s++]=a;for(s="a".charCodeAt(0),a=10;a<36;++a)o[s++]=a;for(s="A".charCodeAt(0),a=10;a<36;++a)o[s++]=a;function l(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function c(e,t){var i=o[e.charCodeAt(t)];return null==i?-1:i}function d(e){var t=n();return t.fromInt(e),t}function h(e){var t,i=1;return 0!=(t=e>>>16)&&(e=t,i+=16),0!=(t=e>>8)&&(e=t,i+=8),0!=(t=e>>4)&&(e=t,i+=4),0!=(t=e>>2)&&(e=t,i+=2),0!=(t=e>>1)&&(e=t,i+=1),i}function u(e){this.m=e}function p(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function g(e,t){return e&t}function T(e,t){return e|t}function f(e,t){return e^t}function m(e,t){return e&~t}function E(e){if(0==e)return-1;var t=0;return 65535&e||(e>>=16,t+=16),255&e||(e>>=8,t+=8),15&e||(e>>=4,t+=4),3&e||(e>>=2,t+=2),1&e||++t,t}function C(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function w(){}function S(e){return e}function _(e){this.r2=n(),this.q3=n(),i.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}u.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},u.prototype.revert=function(e){return e},u.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},u.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},u.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.convert=function(e){var t=n();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(i.ZERO)>0&&this.m.subTo(t,t),t},p.prototype.revert=function(e){var t=n();return e.copyTo(t),this.reduce(t),t},p.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var i=32767&e[t],n=i*this.mpl+((i*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[i=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[i]>=e.DV;)e[i]-=e.DV,e[++i]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},p.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},p.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},i.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},i.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},i.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(256==t)n=8;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)return void this.fromRadix(e,t);n=2}this.t=0,this.s=0;for(var r=e.length,s=!1,a=0;--r>=0;){var o=8==n?255&e[r]:c(e,r);o<0?"-"==e.charAt(r)&&(s=!0):(s=!1,0==a?this[this.t++]=o:a+n>this.DB?(this[this.t-1]|=(o&(1<<this.DB-a)-1)<<a,this[this.t++]=o>>this.DB-a):this[this.t-1]|=o<<a,(a+=n)>=this.DB&&(a-=this.DB))}8==n&&128&e[0]&&(this.s=-1,a>0&&(this[this.t-1]|=(1<<this.DB-a)-1<<a)),this.clamp(),s&&i.ZERO.subTo(this,this)},i.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},i.prototype.dlShiftTo=function(e,t){var i;for(i=this.t-1;i>=0;--i)t[i+e]=this[i];for(i=e-1;i>=0;--i)t[i]=0;t.t=this.t+e,t.s=this.s},i.prototype.drShiftTo=function(e,t){for(var i=e;i<this.t;++i)t[i-e]=this[i];t.t=Math.max(this.t-e,0),t.s=this.s},i.prototype.lShiftTo=function(e,t){var i,n=e%this.DB,r=this.DB-n,s=(1<<r)-1,a=Math.floor(e/this.DB),o=this.s<<n&this.DM;for(i=this.t-1;i>=0;--i)t[i+a+1]=this[i]>>r|o,o=(this[i]&s)<<n;for(i=a-1;i>=0;--i)t[i]=0;t[a]=o,t.t=this.t+a+1,t.s=this.s,t.clamp()},i.prototype.rShiftTo=function(e,t){t.s=this.s;var i=Math.floor(e/this.DB);if(i>=this.t)t.t=0;else{var n=e%this.DB,r=this.DB-n,s=(1<<n)-1;t[0]=this[i]>>n;for(var a=i+1;a<this.t;++a)t[a-i-1]|=(this[a]&s)<<r,t[a-i]=this[a]>>n;n>0&&(t[this.t-i-1]|=(this.s&s)<<r),t.t=this.t-i,t.clamp()}},i.prototype.subTo=function(e,t){for(var i=0,n=0,r=Math.min(e.t,this.t);i<r;)n+=this[i]-e[i],t[i++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;i<this.t;)n+=this[i],t[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<e.t;)n-=e[i],t[i++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[i++]=this.DV+n:n>0&&(t[i++]=n),t.t=i,t.clamp()},i.prototype.multiplyTo=function(e,t){var n=this.abs(),r=e.abs(),s=n.t;for(t.t=s+r.t;--s>=0;)t[s]=0;for(s=0;s<r.t;++s)t[s+n.t]=n.am(0,r[s],t,s,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&i.ZERO.subTo(t,t)},i.prototype.squareTo=function(e){for(var t=this.abs(),i=e.t=2*t.t;--i>=0;)e[i]=0;for(i=0;i<t.t-1;++i){var n=t.am(i,t[i],e,2*i,0,1);(e[i+t.t]+=t.am(i+1,2*t[i],e,2*i+1,n,t.t-i-1))>=t.DV&&(e[i+t.t]-=t.DV,e[i+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(i,t[i],e,2*i,0,1)),e.s=0,e.clamp()},i.prototype.divRemTo=function(e,t,r){var s=e.abs();if(!(s.t<=0)){var a=this.abs();if(a.t<s.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=n());var o=n(),l=this.s,c=e.s,d=this.DB-h(s[s.t-1]);d>0?(s.lShiftTo(d,o),a.lShiftTo(d,r)):(s.copyTo(o),a.copyTo(r));var u=o.t,p=o[u-1];if(0!=p){var g=p*(1<<this.F1)+(u>1?o[u-2]>>this.F2:0),T=this.FV/g,f=(1<<this.F1)/g,m=1<<this.F2,E=r.t,C=E-u,w=null==t?n():t;for(o.dlShiftTo(C,w),r.compareTo(w)>=0&&(r[r.t++]=1,r.subTo(w,r)),i.ONE.dlShiftTo(u,w),w.subTo(o,o);o.t<u;)o[o.t++]=0;for(;--C>=0;){var S=r[--E]==p?this.DM:Math.floor(r[E]*T+(r[E-1]+m)*f);if((r[E]+=o.am(0,S,r,C,0,u))<S)for(o.dlShiftTo(C,w),r.subTo(w,r);r[E]<--S;)r.subTo(w,r)}null!=t&&(r.drShiftTo(u,t),l!=c&&i.ZERO.subTo(t,t)),r.t=u,r.clamp(),d>0&&r.rShiftTo(d,r),l<0&&i.ZERO.subTo(r,r)}}},i.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(!(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},i.prototype.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},i.prototype.exp=function(e,t){if(e>4294967295||e<1)return i.ONE;var r=n(),s=n(),a=t.convert(this),o=h(e)-1;for(a.copyTo(r);--o>=0;)if(t.sqrTo(r,s),(e&1<<o)>0)t.mulTo(s,a,r);else{var l=r;r=s,s=l}return t.revert(r)},i.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var i,n=(1<<t)-1,r=!1,s="",a=this.t,o=this.DB-a*this.DB%t;if(a-- >0)for(o<this.DB&&(i=this[a]>>o)>0&&(r=!0,s=l(i));a>=0;)o<t?(i=(this[a]&(1<<o)-1)<<t-o,i|=this[--a]>>(o+=this.DB-t)):(i=this[a]>>(o-=t)&n,o<=0&&(o+=this.DB,--a)),i>0&&(r=!0),r&&(s+=l(i));return r?s:"0"},i.prototype.negate=function(){var e=n();return i.ZERO.subTo(this,e),e},i.prototype.abs=function(){return this.s<0?this.negate():this},i.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var i=this.t;if(0!=(t=i-e.t))return this.s<0?-t:t;for(;--i>=0;)if(0!=(t=this[i]-e[i]))return t;return 0},i.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+h(this[this.t-1]^this.s&this.DM)},i.prototype.mod=function(e){var t=n();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(i.ZERO)>0&&e.subTo(t,t),t},i.prototype.modPowInt=function(e,t){var i;return i=e<256||t.isEven()?new u(t):new p(t),this.exp(e,i)},i.ZERO=d(0),i.ONE=d(1),w.prototype.convert=S,w.prototype.revert=S,w.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i)},w.prototype.sqrTo=function(e,t){e.squareTo(t)},_.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=n();return e.copyTo(t),this.reduce(t),t},_.prototype.revert=function(e){return e},_.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},_.prototype.mulTo=function(e,t,i){e.multiplyTo(t,i),this.reduce(i)},_.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var O,N,v,y=[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],M=(1<<26)/y[y.length-1];function L(){var e;e=(new Date).getTime(),N[v++]^=255&e,N[v++]^=e>>8&255,N[v++]^=e>>16&255,N[v++]^=e>>24&255,v>=D&&(v-=D)}if(i.prototype.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},i.prototype.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),i=Math.pow(e,t),r=d(i),s=n(),a=n(),o="";for(this.divRemTo(r,s,a);s.signum()>0;)o=(i+a.intValue()).toString(e).substr(1)+o,s.divRemTo(r,s,a);return a.intValue().toString(e)+o},i.prototype.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var n=this.chunkSize(t),r=Math.pow(t,n),s=!1,a=0,o=0,l=0;l<e.length;++l){var d=c(e,l);d<0?"-"==e.charAt(l)&&0==this.signum()&&(s=!0):(o=t*o+d,++a>=n&&(this.dMultiply(r),this.dAddOffset(o,0),a=0,o=0))}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(o,0)),s&&i.ZERO.subTo(this,this)},i.prototype.fromNumber=function(e,t,n){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,n),this.testBit(e-1)||this.bitwiseTo(i.ONE.shiftLeft(e-1),T,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(i.ONE.shiftLeft(e-1),this);else{var r=new Array,s=7&e;r.length=1+(e>>3),t.nextBytes(r),s>0?r[0]&=(1<<s)-1:r[0]=0,this.fromString(r,256)}},i.prototype.bitwiseTo=function(e,t,i){var n,r,s=Math.min(e.t,this.t);for(n=0;n<s;++n)i[n]=t(this[n],e[n]);if(e.t<this.t){for(r=e.s&this.DM,n=s;n<this.t;++n)i[n]=t(this[n],r);i.t=this.t}else{for(r=this.s&this.DM,n=s;n<e.t;++n)i[n]=t(r,e[n]);i.t=e.t}i.s=t(this.s,e.s),i.clamp()},i.prototype.changeBit=function(e,t){var n=i.ONE.shiftLeft(e);return this.bitwiseTo(n,t,n),n},i.prototype.addTo=function(e,t){for(var i=0,n=0,r=Math.min(e.t,this.t);i<r;)n+=this[i]+e[i],t[i++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;i<this.t;)n+=this[i],t[i++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;i<e.t;)n+=e[i],t[i++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[i++]=n:n<-1&&(t[i++]=this.DV+n),t.t=i,t.clamp()},i.prototype.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},i.prototype.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},i.prototype.multiplyLowerTo=function(e,t,i){var n,r=Math.min(this.t+e.t,t);for(i.s=0,i.t=r;r>0;)i[--r]=0;for(n=i.t-this.t;r<n;++r)i[r+this.t]=this.am(0,e[r],i,r,0,this.t);for(n=Math.min(e.t,t);r<n;++r)this.am(0,e[r],i,r,0,t-r);i.clamp()},i.prototype.multiplyUpperTo=function(e,t,i){--t;var n=i.t=this.t+e.t-t;for(i.s=0;--n>=0;)i[n]=0;for(n=Math.max(t-this.t,0);n<e.t;++n)i[this.t+n-t]=this.am(t-n,e[n],i,0,0,this.t+n-t);i.clamp(),i.drShiftTo(1,i)},i.prototype.modInt=function(e){if(e<=0)return 0;var t=this.DV%e,i=this.s<0?e-1:0;if(this.t>0)if(0==t)i=this[0]%e;else for(var n=this.t-1;n>=0;--n)i=(t*i+this[n])%e;return i},i.prototype.millerRabin=function(e){var t=this.subtract(i.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var s=t.shiftRight(r);(e=e+1>>1)>y.length&&(e=y.length);for(var a=n(),o=0;o<e;++o){a.fromInt(y[Math.floor(Math.random()*y.length)]);var l=a.modPow(s,this);if(0!=l.compareTo(i.ONE)&&0!=l.compareTo(t)){for(var c=1;c++<r&&0!=l.compareTo(t);)if(0==(l=l.modPowInt(2,this)).compareTo(i.ONE))return!1;if(0!=l.compareTo(t))return!1}}return!0},i.prototype.clone=function(){var e=n();return this.copyTo(e),e},i.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]},i.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},i.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},i.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},i.prototype.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var i,n=this.DB-e*this.DB%8,r=0;if(e-- >0)for(n<this.DB&&(i=this[e]>>n)!=(this.s&this.DM)>>n&&(t[r++]=i|this.s<<this.DB-n);e>=0;)n<8?(i=(this[e]&(1<<n)-1)<<8-n,i|=this[--e]>>(n+=this.DB-8)):(i=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),128&i&&(i|=-256),0==r&&(128&this.s)!=(128&i)&&++r,(r>0||i!=this.s)&&(t[r++]=i);return t},i.prototype.equals=function(e){return 0==this.compareTo(e)},i.prototype.min=function(e){return this.compareTo(e)<0?this:e},i.prototype.max=function(e){return this.compareTo(e)>0?this:e},i.prototype.and=function(e){var t=n();return this.bitwiseTo(e,g,t),t},i.prototype.or=function(e){var t=n();return this.bitwiseTo(e,T,t),t},i.prototype.xor=function(e){var t=n();return this.bitwiseTo(e,f,t),t},i.prototype.andNot=function(e){var t=n();return this.bitwiseTo(e,m,t),t},i.prototype.not=function(){for(var e=n(),t=0;t<this.t;++t)e[t]=this.DM&~this[t];return e.t=this.t,e.s=~this.s,e},i.prototype.shiftLeft=function(e){var t=n();return e<0?this.rShiftTo(-e,t):this.lShiftTo(e,t),t},i.prototype.shiftRight=function(e){var t=n();return e<0?this.lShiftTo(-e,t):this.rShiftTo(e,t),t},i.prototype.getLowestSetBit=function(){for(var e=0;e<this.t;++e)if(0!=this[e])return e*this.DB+E(this[e]);return this.s<0?this.t*this.DB:-1},i.prototype.bitCount=function(){for(var e=0,t=this.s&this.DM,i=0;i<this.t;++i)e+=C(this[i]^t);return e},i.prototype.testBit=function(e){var t=Math.floor(e/this.DB);return t>=this.t?0!=this.s:!!(this[t]&1<<e%this.DB)},i.prototype.setBit=function(e){return this.changeBit(e,T)},i.prototype.clearBit=function(e){return this.changeBit(e,m)},i.prototype.flipBit=function(e){return this.changeBit(e,f)},i.prototype.add=function(e){var t=n();return this.addTo(e,t),t},i.prototype.subtract=function(e){var t=n();return this.subTo(e,t),t},i.prototype.multiply=function(e){var t=n();return this.multiplyTo(e,t),t},i.prototype.divide=function(e){var t=n();return this.divRemTo(e,t,null),t},i.prototype.remainder=function(e){var t=n();return this.divRemTo(e,null,t),t},i.prototype.divideAndRemainder=function(e){var t=n(),i=n();return this.divRemTo(e,t,i),new Array(t,i)},i.prototype.modPow=function(e,t){var i,r,s=e.bitLength(),a=d(1);if(s<=0)return a;i=s<18?1:s<48?3:s<144?4:s<768?5:6,r=s<8?new u(t):t.isEven()?new _(t):new p(t);var o=new Array,l=3,c=i-1,g=(1<<i)-1;if(o[1]=r.convert(this),i>1){var T=n();for(r.sqrTo(o[1],T);l<=g;)o[l]=n(),r.mulTo(T,o[l-2],o[l]),l+=2}var f,m,E=e.t-1,C=!0,w=n();for(s=h(e[E])-1;E>=0;){for(s>=c?f=e[E]>>s-c&g:(f=(e[E]&(1<<s+1)-1)<<c-s,E>0&&(f|=e[E-1]>>this.DB+s-c)),l=i;!(1&f);)f>>=1,--l;if((s-=l)<0&&(s+=this.DB,--E),C)o[f].copyTo(a),C=!1;else{for(;l>1;)r.sqrTo(a,w),r.sqrTo(w,a),l-=2;l>0?r.sqrTo(a,w):(m=a,a=w,w=m),r.mulTo(w,o[f],a)}for(;E>=0&&!(e[E]&1<<s);)r.sqrTo(a,w),m=a,a=w,w=m,--s<0&&(s=this.DB-1,--E)}return r.revert(a)},i.prototype.modInverse=function(e){var t=e.isEven();if(this.isEven()&&t||0==e.signum())return i.ZERO;for(var n=e.clone(),r=this.clone(),s=d(1),a=d(0),o=d(0),l=d(1);0!=n.signum();){for(;n.isEven();)n.rShiftTo(1,n),t?(s.isEven()&&a.isEven()||(s.addTo(this,s),a.subTo(e,a)),s.rShiftTo(1,s)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;r.isEven();)r.rShiftTo(1,r),t?(o.isEven()&&l.isEven()||(o.addTo(this,o),l.subTo(e,l)),o.rShiftTo(1,o)):l.isEven()||l.subTo(e,l),l.rShiftTo(1,l);n.compareTo(r)>=0?(n.subTo(r,n),t&&s.subTo(o,s),a.subTo(l,a)):(r.subTo(n,r),t&&o.subTo(s,o),l.subTo(a,l))}return 0!=r.compareTo(i.ONE)?i.ZERO:l.compareTo(e)>=0?l.subtract(e):l.signum()<0?(l.addTo(e,l),l.signum()<0?l.add(e):l):l},i.prototype.pow=function(e){return this.exp(e,new w)},i.prototype.gcd=function(e){var t=this.s<0?this.negate():this.clone(),i=e.s<0?e.negate():e.clone();if(t.compareTo(i)<0){var n=t;t=i,i=n}var r=t.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return t;for(r<s&&(s=r),s>0&&(t.rShiftTo(s,t),i.rShiftTo(s,i));t.signum()>0;)(r=t.getLowestSetBit())>0&&t.rShiftTo(r,t),(r=i.getLowestSetBit())>0&&i.rShiftTo(r,i),t.compareTo(i)>=0?(t.subTo(i,t),t.rShiftTo(1,t)):(i.subTo(t,i),i.rShiftTo(1,i));return s>0&&i.lShiftTo(s,i),i},i.prototype.isProbablePrime=function(e){var t,i=this.abs();if(1==i.t&&i[0]<=y[y.length-1]){for(t=0;t<y.length;++t)if(i[0]==y[t])return!0;return!1}if(i.isEven())return!1;for(t=1;t<y.length;){for(var n=y[t],r=t+1;r<y.length&&n<M;)n*=y[r++];for(n=i.modInt(n);t<r;)if(n%y[t++]==0)return!1}return i.millerRabin(e)},i.prototype.square=function(){var e=n();return this.squareTo(e),e},i.prototype.Barrett=_,null==N){var I;if(N=new Array,v=0,"undefined"!=typeof window&&window.crypto)if(window.crypto.getRandomValues){var P=new Uint8Array(32);for(window.crypto.getRandomValues(P),I=0;I<32;++I)N[v++]=P[I]}else if("Netscape"==navigator.appName&&navigator.appVersion<"5"){var A=window.crypto.random(32);for(I=0;I<A.length;++I)N[v++]=255&A.charCodeAt(I)}for(;v<D;)I=Math.floor(65536*Math.random()),N[v++]=I>>>8,N[v++]=255&I;v=0,L()}function b(){if(null==O){for(L(),(O=new R).init(N),v=0;v<N.length;++v)N[v]=0;v=0}return O.next()}function V(){}function R(){this.i=0,this.j=0,this.S=new Array}V.prototype.nextBytes=function(e){var t;for(t=0;t<e.length;++t)e[t]=b()},R.prototype.init=function(e){var t,i,n;for(t=0;t<256;++t)this.S[t]=t;for(i=0,t=0;t<256;++t)i=i+this.S[t]+e[t%e.length]&255,n=this.S[t],this.S[t]=this.S[i],this.S[i]=n;this.i=0,this.j=0},R.prototype.next=function(){var e;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,e=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=e,this.S[e+this.S[this.i]&255]};var D=256;t.exports={default:i,BigInteger:i,SecureRandom:V}}.call(i);var r=n.exports;const{BigInteger:s}=r;class a{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 e=this.v.length/2;let t=e.toString(16);return t.length%2==1&&(t="0"+t),e<128?t:(128+t.length/2).toString(16)+t}getValue(){return""}}class o extends a{constructor(e){super(),this.t="02",e&&(this.v=function(e){let t=e.toString(16);if("-"!==t[0])t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t);else{t=t.substr(1);let i=t.length;i%2==1?i+=1:t.match(/^[0-7]/)||(i+=2);let n="";for(let e=0;e<i;e++)n+="f";n=new s(n,16),t=n.xor(e).add(s.ONE),t=t.toString(16).replace(/^-/,"")}return t}(e))}getValue(){return this.v}}class l extends a{constructor(e){super(),this.t="30",this.asn1Array=e}getValue(){return this.v=this.asn1Array.map((e=>e.getEncodedHex())).join(""),this.v}}function c(e,t){return+e[t+2]<8?1:128&+e.substr(t+2,2)}function d(e,t){const i=c(e,t),n=e.substr(t+2,2*i);return n?(+n[0]<8?new s(n,16):new s(n.substr(2),16)).intValue():-1}function h(e,t){return t+2*(c(e,t)+1)}var u={encodeDer(e,t){const i=new o(e),n=new o(t);return new l([i,n]).getEncodedHex()},decodeDer(e){const t=h(e,0),i=h(e,t),n=d(e,t),r=e.substr(i,2*n),a=i+r.length,o=h(e,a),l=d(e,a),c=e.substr(o,2*l);return{r:new s(r,16),s:new s(c,16)}}};const{BigInteger:p}=r,g=new p("2"),T=new p("3");class f{constructor(e,t){this.x=t,this.q=e}equals(e){return e===this||this.q.equals(e.q)&&this.x.equals(e.x)}toBigInteger(){return this.x}negate(){return new f(this.q,this.x.negate().mod(this.q))}add(e){return new f(this.q,this.x.add(e.toBigInteger()).mod(this.q))}subtract(e){return new f(this.q,this.x.subtract(e.toBigInteger()).mod(this.q))}multiply(e){return new f(this.q,this.x.multiply(e.toBigInteger()).mod(this.q))}divide(e){return new f(this.q,this.x.multiply(e.toBigInteger().modInverse(this.q)).mod(this.q))}square(){return new f(this.q,this.x.square().mod(this.q))}}class m{constructor(e,t,i,n){this.curve=e,this.x=t,this.y=i,this.z=null==n?p.ONE:n,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(e){return e===this||(this.isInfinity()?e.isInfinity():e.isInfinity()?this.isInfinity():!!e.y.toBigInteger().multiply(this.z).subtract(this.y.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(p.ZERO)&&e.x.toBigInteger().multiply(this.z).subtract(this.x.toBigInteger().multiply(e.z)).mod(this.curve.q).equals(p.ZERO))}isInfinity(){return null===this.x&&null===this.y||this.z.equals(p.ZERO)&&!this.y.toBigInteger().equals(p.ZERO)}negate(){return new m(this.curve,this.x,this.y.negate(),this.z)}add(e){if(this.isInfinity())return e;if(e.isInfinity())return this;const t=this.x.toBigInteger(),i=this.y.toBigInteger(),n=this.z,r=e.x.toBigInteger(),s=e.y.toBigInteger(),a=e.z,o=this.curve.q,l=t.multiply(a).mod(o),c=r.multiply(n).mod(o),d=l.subtract(c),h=i.multiply(a).mod(o),u=s.multiply(n).mod(o),g=h.subtract(u);if(p.ZERO.equals(d))return p.ZERO.equals(g)?this.twice():this.curve.infinity;const T=l.add(c),f=n.multiply(a).mod(o),E=d.square().mod(o),C=d.multiply(E).mod(o),w=f.multiply(g.square()).subtract(T.multiply(E)).mod(o),S=d.multiply(w).mod(o),_=g.multiply(E.multiply(l).subtract(w)).subtract(h.multiply(C)).mod(o),O=C.multiply(f).mod(o);return new m(this.curve,this.curve.fromBigInteger(S),this.curve.fromBigInteger(_),O)}twice(){if(this.isInfinity())return this;if(!this.y.toBigInteger().signum())return this.curve.infinity;const e=this.x.toBigInteger(),t=this.y.toBigInteger(),i=this.z,n=this.curve.q,r=this.curve.a.toBigInteger(),s=e.square().multiply(T).add(r.multiply(i.square())).mod(n),a=t.shiftLeft(1).multiply(i).mod(n),o=t.square().mod(n),l=o.multiply(e).multiply(i).mod(n),c=a.square().mod(n),d=s.square().subtract(l.shiftLeft(3)).mod(n),h=a.multiply(d).mod(n),u=s.multiply(l.shiftLeft(2).subtract(d)).subtract(c.shiftLeft(1).multiply(o)).mod(n),p=a.multiply(c).mod(n);return new m(this.curve,this.curve.fromBigInteger(h),this.curve.fromBigInteger(u),p)}multiply(e){if(this.isInfinity())return this;if(!e.signum())return this.curve.infinity;const t=e.multiply(T),i=this.negate();let n=this;for(let r=t.bitLength()-2;r>0;r--){n=n.twice();const s=t.testBit(r);s!==e.testBit(r)&&(n=n.add(s?this:i))}return n}}var E={ECPointFp:m,ECCurveFp:class{constructor(e,t,i){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(i),this.infinity=new m(this,null,null)}equals(e){return e===this||this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}fromBigInteger(e){return new f(this.q,e)}decodePointHex(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:const t=this.fromBigInteger(new p(e.substr(2),16));let i=this.fromBigInteger(t.multiply(t.square()).add(t.multiply(this.a)).add(this.b).toBigInteger().modPow(this.q.divide(new p("4")).add(p.ONE),this.q));return i.toBigInteger().mod(g).equals(new p(e.substr(0,2),16).subtract(g))||(i=i.negate()),new m(this,t,i);case 4:case 6:case 7:const n=(e.length-2)/2,r=e.substr(2,n),s=e.substr(n+2,n);return new m(this,this.fromBigInteger(new p(r,16)),this.fromBigInteger(new p(s,16)));default:return null}}}};const{BigInteger:C,SecureRandom:w}=r,{ECCurveFp:S}=E,_=new w,{curve:O,G:N,n:v}=y();function y(){const e=new C("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFF",16),t=new C("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF00000000FFFFFFFFFFFFFFFC",16),i=new C("28E9FA9E9D9F5E344D5A9E4BCF6509A7F39789F515AB8F92DDBCBD414D940E93",16),n=new S(e,t,i),r=n.decodePointHex("0432C4AE2C1F1981195F9904466A39C9948FE30BBFF2660BE1715A4589334C74C7BC3736A2F4F6779C59BDCEE36B692153D0A9877CC62A474002DF32E52139F0A0");return{curve:n,G:r,n:new C("FFFFFFFEFFFFFFFFFFFFFFFFFFFFFFFF7203DF6B21C6052B53BBF40939D54123",16)}}function M(e,t){return e.length>=t?e:new Array(t-e.length+1).join("0")+e}var L={getGlobalCurve:function(){return O},generateEcparam:y,generateKeyPairHex:function(e,t,i){const n=(e?new C(e,t,i):new C(v.bitLength(),_)).mod(v.subtract(C.ONE)).add(C.ONE),r=M(n.toString(16),64),s=N.multiply(n);return{privateKey:r,publicKey:"04"+M(s.getX().toBigInteger().toString(16),64)+M(s.getY().toBigInteger().toString(16),64)}},compressPublicKeyHex:function(e){if(130!==e.length)throw new Error("Invalid public key to compress");const t=(e.length-2)/2,i=e.substr(2,t);let n="03";return new C(e.substr(t+2,t),16).mod(new C("2")).equals(C.ZERO)&&(n="02"),n+i},utf8ToHex:function(e){const t=(e=unescape(encodeURIComponent(e))).length,i=[];for(let n=0;n<t;n++)i[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;const n=[];for(let e=0;e<t;e++){const t=i[e>>>2]>>>24-e%4*8&255;n.push((t>>>4).toString(16)),n.push((15&t).toString(16))}return n.join("")},leftPad:M,arrayToHex:function(e){return e.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join("")},arrayToUtf8:function(e){const t=[];let i=0;for(let n=0;n<2*e.length;n+=2)t[n>>>3]|=parseInt(e[i],10)<<24-n%8*4,i++;try{const i=[];for(let n=0;n<e.length;n++){const e=t[n>>>2]>>>24-n%4*8&255;i.push(String.fromCharCode(e))}return decodeURIComponent(escape(i.join("")))}catch(e){throw new Error("Malformed UTF-8 data")}},hexToArray:function(e){const t=[];let i=e.length;i%2!=0&&(e=M(e,i+1)),i=e.length;for(let n=0;n<i;n+=2)t.push(parseInt(e.substr(n,2),16));return t},verifyPublicKey:function(e){const t=O.decodePointHex(e);if(!t)return!1;const i=t.getX();return t.getY().square().equals(i.multiply(i.square()).add(i.multiply(O.a)).add(O.b))},comparePublicKeyHex:function(e,t){const i=O.decodePointHex(e);if(!i)return!1;const n=O.decodePointHex(t);return!!n&&i.equals(n)}};const I=new Uint32Array(68),P=new Uint32Array(64);function A(e,t){const i=31&t;return e<<i|e>>>32-i}function b(e,t){const i=[];for(let n=e.length-1;n>=0;n--)i[n]=255&(e[n]^t[n]);return i}function V(e){return e^A(e,9)^A(e,17)}function R(e){let t=8*e.length,i=t%512;i=i>=448?512-i%448-1:448-i-1;const n=new Array((i-7)/8),r=new Array(8);for(let e=0,t=n.length;e<t;e++)n[e]=0;for(let e=0,t=r.length;e<t;e++)r[e]=0;t=t.toString(2);for(let e=7;e>=0;e--)if(t.length>8){const i=t.length-8;r[e]=parseInt(t.substr(i),2),t=t.substr(0,i)}else t.length>0&&(r[e]=parseInt(t,2),t="");const s=new Uint8Array([...e,128,...n,...r]),a=new DataView(s.buffer,0),o=s.length/64,l=new Uint32Array([1937774191,1226093241,388252375,3666478592,2842636476,372324522,3817729613,2969243214]);for(let e=0;e<o;e++){I.fill(0),P.fill(0);const t=16*e;for(let e=0;e<16;e++)I[e]=a.getUint32(4*(t+e),!1);for(let e=16;e<68;e++)I[e]=(c=I[e-16]^I[e-9]^A(I[e-3],15))^A(c,15)^A(c,23)^A(I[e-13],7)^I[e-6];for(let e=0;e<64;e++)P[e]=I[e]^I[e+4];const i=2043430169,n=2055708042;let r,s,o,d,h,u=l[0],p=l[1],g=l[2],T=l[3],f=l[4],m=l[5],E=l[6],C=l[7];for(let e=0;e<64;e++)h=e>=0&&e<=15?i:n,r=A(A(u,12)+f+A(h,e),7),s=r^A(u,12),o=(e>=0&&e<=15?u^p^g:u&p|u&g|p&g)+T+s+P[e],d=(e>=0&&e<=15?f^m^E:f&m|~f&E)+C+r+I[e],T=g,g=A(p,9),p=u,u=o,C=E,E=A(m,19),m=f,f=V(d);l[0]^=u,l[1]^=p,l[2]^=g,l[3]^=T,l[4]^=f,l[5]^=m,l[6]^=E,l[7]^=C}var c;const d=[];for(let e=0,t=l.length;e<t;e++){const t=l[e];d.push((4278190080&t)>>>24,(16711680&t)>>>16,(65280&t)>>>8,255&t)}return d}const D=new Uint8Array(64),x=new Uint8Array(64);for(let e=0;e<64;e++)D[e]=54,x[e]=92;var U={sm3:R,hmac:function(e,t){for(t.length>64&&(t=R(t));t.length<64;)t.push(0);const i=b(t,D),n=b(t,x),r=R([...i,...e]);return R([...n,...r])}};const{BigInteger:B}=r,{encodeDer:k,decodeDer:Y}=u,F=L,H=U.sm3,{G:W,curve:G,n:K}=F.generateEcparam();function j(e,t,i="1234567812345678"){i=F.utf8ToHex(i);const n=F.leftPad(W.curve.a.toBigInteger().toRadix(16),64),r=F.leftPad(W.curve.b.toBigInteger().toRadix(16),64),s=F.leftPad(W.getX().toBigInteger().toRadix(16),64),a=F.leftPad(W.getY().toBigInteger().toRadix(16),64);let o,l;if(128===t.length)o=t.substr(0,64),l=t.substr(64,64);else{const e=W.curve.decodePointHex(t);o=F.leftPad(e.getX().toBigInteger().toRadix(16),64),l=F.leftPad(e.getY().toBigInteger().toRadix(16),64)}const c=F.hexToArray(i+n+r+s+a+o+l),d=4*i.length;c.unshift(255&d),c.unshift(d>>8&255);const h=H(c);return F.arrayToHex(H(h.concat(F.hexToArray(e))))}function X(e){const t=W.multiply(new B(e,16));return"04"+F.leftPad(t.getX().toBigInteger().toString(16),64)+F.leftPad(t.getY().toBigInteger().toString(16),64)}function J(){const e=F.generateKeyPairHex(),t=G.decodePointHex(e.publicKey);return e.k=new B(e.privateKey,16),e.x1=t.getX().toBigInteger(),e}var z={generateKeyPairHex:F.generateKeyPairHex,compressPublicKeyHex:F.compressPublicKeyHex,comparePublicKeyHex:F.comparePublicKeyHex,doEncrypt:function(e,t,i=1){e="string"==typeof e?F.hexToArray(F.utf8ToHex(e)):Array.prototype.slice.call(e),t=F.getGlobalCurve().decodePointHex(t);const n=F.generateKeyPairHex(),r=new B(n.privateKey,16);let s=n.publicKey;s.length>128&&(s=s.substr(s.length-128));const a=t.multiply(r),o=F.hexToArray(F.leftPad(a.getX().toBigInteger().toRadix(16),64)),l=F.hexToArray(F.leftPad(a.getY().toBigInteger().toRadix(16),64)),c=F.arrayToHex(H([].concat(o,e,l)));let d=1,h=0,u=[];const p=[].concat(o,l),g=()=>{u=H([...p,d>>24&255,d>>16&255,d>>8&255,255&d]),d++,h=0};g();for(let t=0,i=e.length;t<i;t++)h===u.length&&g(),e[t]^=255&u[h++];const T=F.arrayToHex(e);return 0===i?s+T+c:s+c+T},doDecrypt:function(e,t,i=1,{output:n="string"}={}){t=new B(t,16);let r=e.substr(128,64),s=e.substr(192);0===i&&(r=e.substr(e.length-64),s=e.substr(128,e.length-128-64));const a=F.hexToArray(s),o=F.getGlobalCurve().decodePointHex("04"+e.substr(0,128)).multiply(t),l=F.hexToArray(F.leftPad(o.getX().toBigInteger().toRadix(16),64)),c=F.hexToArray(F.leftPad(o.getY().toBigInteger().toRadix(16),64));let d=1,h=0,u=[];const p=[].concat(l,c),g=()=>{u=H([...p,d>>24&255,d>>16&255,d>>8&255,255&d]),d++,h=0};g();for(let e=0,t=a.length;e<t;e++)h===u.length&&g(),a[e]^=255&u[h++];return F.arrayToHex(H([].concat(l,a,c)))===r.toLowerCase()?"array"===n?a:F.arrayToUtf8(a):"array"===n?[]:""},doSignature:function(e,t,{pointPool:i,der:n,hash:r,publicKey:s,userId:a}={}){let o="string"==typeof e?F.utf8ToHex(e):F.arrayToHex(e);r&&(o=j(o,s=s||X(t),a));const l=new B(t,16),c=new B(o,16);let d=null,h=null,u=null;do{do{let e;e=i&&i.length?i.pop():J(),d=e.k,h=c.add(e.x1).mod(K)}while(h.equals(B.ZERO)||h.add(d).equals(K));u=l.add(B.ONE).modInverse(K).multiply(d.subtract(h.multiply(l))).mod(K)}while(u.equals(B.ZERO));return n?k(h,u):F.leftPad(h.toString(16),64)+F.leftPad(u.toString(16),64)},doVerifySignature:function(e,t,i,{der:n,hash:r,userId:s}={}){let a,o,l="string"==typeof e?F.utf8ToHex(e):F.arrayToHex(e);if(r&&(l=j(l,i,s)),n){const e=Y(t);a=e.r,o=e.s}else a=new B(t.substring(0,64),16),o=new B(t.substring(64),16);const c=G.decodePointHex(i),d=new B(l,16),h=a.add(o).mod(K);if(h.equals(B.ZERO))return!1;const u=W.multiply(o).add(c.multiply(h)),p=d.add(u.getX().toBigInteger()).mod(K);return a.equals(p)},getPublicKeyFromPrivateKey:X,getPoint:J,verifyPublicKey:F.verifyPublicKey};const{sm3:q,hmac:Z}=U;function Q(e){return e.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join("")}const $=16,ee=[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],te=[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 ie(e){const t=[];for(let i=0,n=e.length;i<n;i+=2)t.push(parseInt(e.substr(i,2),16));return t}function ne(e,t){const i=31&t;return e<<i|e>>>32-i}function re(e){return(255&ee[e>>>24&255])<<24|(255&ee[e>>>16&255])<<16|(255&ee[e>>>8&255])<<8|255&ee[255&e]}function se(e){return e^ne(e,2)^ne(e,10)^ne(e,18)^ne(e,24)}function ae(e){return e^ne(e,13)^ne(e,23)}function oe(e,t,i){const n=new Array(4),r=new Array(4);for(let t=0;t<4;t++)r[0]=255&e[4*t],r[1]=255&e[4*t+1],r[2]=255&e[4*t+2],r[3]=255&e[4*t+3],n[t]=r[0]<<24|r[1]<<16|r[2]<<8|r[3];for(let e,t=0;t<32;t+=4)e=n[1]^n[2]^n[3]^i[t+0],n[0]^=se(re(e)),e=n[2]^n[3]^n[0]^i[t+1],n[1]^=se(re(e)),e=n[3]^n[0]^n[1]^i[t+2],n[2]^=se(re(e)),e=n[0]^n[1]^n[2]^i[t+3],n[3]^=se(re(e));for(let e=0;e<16;e+=4)t[e]=n[3-e/4]>>>24&255,t[e+1]=n[3-e/4]>>>16&255,t[e+2]=n[3-e/4]>>>8&255,t[e+3]=255&n[3-e/4]}function le(e,t,i,{padding:n="pkcs#7",mode:r,iv:s=[],output:a="string"}={}){if("cbc"===r&&("string"==typeof s&&(s=ie(s)),16!==s.length))throw new Error("iv is invalid");if("string"==typeof t&&(t=ie(t)),16!==t.length)throw new Error("key is invalid");if(e="string"==typeof e?0!==i?function(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e.codePointAt(i);if(n<=127)t.push(n);else if(n<=2047)t.push(192|n>>>6),t.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)t.push(224|n>>>12),t.push(128|n>>>6&63),t.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw t.push(n),new Error("input is not supported");i++,t.push(240|n>>>18&28),t.push(128|n>>>12&63),t.push(128|n>>>6&63),t.push(128|63&n)}}return t}(e):ie(e):[...e],("pkcs#5"===n||"pkcs#7"===n)&&0!==i){const t=$-e.length%$;for(let i=0;i<t;i++)e.push(t)}const o=new Array(32);!function(e,t,i){const n=new Array(4),r=new Array(4);for(let t=0;t<4;t++)r[0]=255&e[0+4*t],r[1]=255&e[1+4*t],r[2]=255&e[2+4*t],r[3]=255&e[3+4*t],n[t]=r[0]<<24|r[1]<<16|r[2]<<8|r[3];n[0]^=2746333894,n[1]^=1453994832,n[2]^=1736282519,n[3]^=2993693404;for(let e,i=0;i<32;i+=4)e=n[1]^n[2]^n[3]^te[i+0],t[i+0]=n[0]^=ae(re(e)),e=n[2]^n[3]^n[0]^te[i+1],t[i+1]=n[1]^=ae(re(e)),e=n[3]^n[0]^n[1]^te[i+2],t[i+2]=n[2]^=ae(re(e)),e=n[0]^n[1]^n[2]^te[i+3],t[i+3]=n[3]^=ae(re(e));if(0===i)for(let e,i=0;i<16;i++)e=t[i],t[i]=t[31-i],t[31-i]=e}(t,o,i);const l=[];let c=s,d=e.length,h=0;for(;d>=$;){const t=e.slice(h,h+16),n=new Array(16);if("cbc"===r)for(let e=0;e<$;e++)0!==i&&(t[e]^=c[e]);oe(t,n,o);for(let e=0;e<$;e++)"cbc"===r&&0===i&&(n[e]^=c[e]),l[h+e]=n[e];"cbc"===r&&(c=0!==i?n:t),d-=$,h+=$}if(("pkcs#5"===n||"pkcs#7"===n)&&0===i){const e=l.length,t=l[e-1];for(let i=1;i<=t;i++)if(l[e-i]!==t)throw new Error("padding is invalid");l.splice(e-t,t)}return"array"!==a?0!==i?l.map((e=>1===(e=e.toString(16)).length?"0"+e:e)).join(""):function(e){const t=[];for(let i=0,n=e.length;i<n;i++)e[i]>=240&&e[i]<=247?(t.push(String.fromCodePoint(((7&e[i])<<18)+((63&e[i+1])<<12)+((63&e[i+2])<<6)+(63&e[i+3]))),i+=3):e[i]>=224&&e[i]<=239?(t.push(String.fromCodePoint(((15&e[i])<<12)+((63&e[i+1])<<6)+(63&e[i+2]))),i+=2):e[i]>=192&&e[i]<=223?(t.push(String.fromCodePoint(((31&e[i])<<6)+(63&e[i+1]))),i++):t.push(String.fromCodePoint(e[i]));return t.join("")}(l):l}var ce={encrypt:(e,t,i)=>le(e,t,1,i),decrypt:(e,t,i)=>le(e,t,0,i)},de={sm2:z,sm3:function(e,t){if(e="string"==typeof e?function(e){const t=[];for(let i=0,n=e.length;i<n;i++){const n=e.codePointAt(i);if(n<=127)t.push(n);else if(n<=2047)t.push(192|n>>>6),t.push(128|63&n);else if(n<=55295||n>=57344&&n<=65535)t.push(224|n>>>12),t.push(128|n>>>6&63),t.push(128|63&n);else{if(!(n>=65536&&n<=1114111))throw t.push(n),new Error("input is not supported");i++,t.push(240|n>>>18&28),t.push(128|n>>>12&63),t.push(128|n>>>6&63),t.push(128|63&n)}}return t}(e):Array.prototype.slice.call(e),t){if("hmac"!==(t.mode||"hmac"))throw new Error("invalid mode");let i=t.key;if(!i)throw new Error("invalid key");return i="string"==typeof i?function(e){const t=[];let i=e.length;var n,r;i%2!=0&&(r=i+1,e=(n=e).length>=r?n:new Array(r-n.length+1).join("0")+n),i=e.length;for(let n=0;n<i;n+=2)t.push(parseInt(e.substr(n,2),16));return t}(i):Array.prototype.slice.call(i),Q(Z(e,i))}return Q(q(e))},sm4:ce};const he=(e,t)=>e<<t|e>>>32-t,ue=(e,t)=>{const i=2147483648&e,n=2147483648&t,r=1073741824&e,s=1073741824&t,a=(1073741823&e)+(1073741823&t);return r&s?2147483648^a^i^n:r|s?1073741824&a?3221225472^a^i^n:1073741824^a^i^n:a^i^n},pe=(e,t,i,n,r,s,a)=>{return e=ue(e,ue(ue((o=t)&i|~o&n,r),a)),ue(he(e,s),t);var o},ge=(e,t,i,n,r,s,a)=>{return e=ue(e,ue(ue(t&(o=n)|i&~o,r),a)),ue(he(e,s),t);var o},Te=(e,t,i,n,r,s,a)=>(e=ue(e,ue(ue(t^i^n,r),a)),ue(he(e,s),t)),fe=(e,t,i,n,r,s,a)=>(e=ue(e,ue(ue(i^(t|~n),r),a)),ue(he(e,s),t)),me=e=>{let t,i="",n="";for(let r=0;r<=3;r++)t=e>>>8*r&255,n="0"+t.toString(16),i+=n.substr(n.length-2,2);return i},Ee=e=>{let t,i,n,r,s,a,o,l,c,d;for(t=(e=>{let t;const i=e.length,n=i+8,r=16*((n-n%64)/64+1),s=new Array(r-1);let a=0,o=0;for(;o<i;)t=(o-o%4)/4,a=o%4*8,s[t]=s[t]|e.charCodeAt(o)<<a,o++;return t=(o-o%4)/4,a=o%4*8,s[t]=s[t]|128<<a,s[r-2]=i<<3,s[r-1]=i>>>29,s})(e=(e=>{e=e.replace(/\r\n/g,"\n");let t="";for(let i=0;i<e.length;i++){const n=e.charCodeAt(i);n<128?t+=String.fromCharCode(n):n>127&&n<2048?(t+=String.fromCharCode(n>>6|192),t+=String.fromCharCode(63&n|128)):(t+=String.fromCharCode(n>>12|224),t+=String.fromCharCode(n>>6&63|128),t+=String.fromCharCode(63&n|128))}return t})(e)),o=1732584193,l=4023233417,c=2562383102,d=271733878,i=0;i<t.length;i+=16)n=o,r=l,s=c,a=d,o=pe(o,l,c,d,t[i+0],7,3614090360),d=pe(d,o,l,c,t[i+1],12,3905402710),c=pe(c,d,o,l,t[i+2],17,606105819),l=pe(l,c,d,o,t[i+3],22,3250441966),o=pe(o,l,c,d,t[i+4],7,4118548399),d=pe(d,o,l,c,t[i+5],12,1200080426),c=pe(c,d,o,l,t[i+6],17,2821735955),l=pe(l,c,d,o,t[i+7],22,4249261313),o=pe(o,l,c,d,t[i+8],7,1770035416),d=pe(d,o,l,c,t[i+9],12,2336552879),c=pe(c,d,o,l,t[i+10],17,4294925233),l=pe(l,c,d,o,t[i+11],22,2304563134),o=pe(o,l,c,d,t[i+12],7,1804603682),d=pe(d,o,l,c,t[i+13],12,4254626195),c=pe(c,d,o,l,t[i+14],17,2792965006),l=pe(l,c,d,o,t[i+15],22,1236535329),o=ge(o,l,c,d,t[i+1],5,4129170786),d=ge(d,o,l,c,t[i+6],9,3225465664),c=ge(c,d,o,l,t[i+11],14,643717713),l=ge(l,c,d,o,t[i+0],20,3921069994),o=ge(o,l,c,d,t[i+5],5,3593408605),d=ge(d,o,l,c,t[i+10],9,38016083),c=ge(c,d,o,l,t[i+15],14,3634488961),l=ge(l,c,d,o,t[i+4],20,3889429448),o=ge(o,l,c,d,t[i+9],5,568446438),d=ge(d,o,l,c,t[i+14],9,3275163606),c=ge(c,d,o,l,t[i+3],14,4107603335),l=ge(l,c,d,o,t[i+8],20,1163531501),o=ge(o,l,c,d,t[i+13],5,2850285829),d=ge(d,o,l,c,t[i+2],9,4243563512),c=ge(c,d,o,l,t[i+7],14,1735328473),l=ge(l,c,d,o,t[i+12],20,2368359562),o=Te(o,l,c,d,t[i+5],4,4294588738),d=Te(d,o,l,c,t[i+8],11,2272392833),c=Te(c,d,o,l,t[i+11],16,1839030562),l=Te(l,c,d,o,t[i+14],23,4259657740),o=Te(o,l,c,d,t[i+1],4,2763975236),d=Te(d,o,l,c,t[i+4],11,1272893353),c=Te(c,d,o,l,t[i+7],16,4139469664),l=Te(l,c,d,o,t[i+10],23,3200236656),o=Te(o,l,c,d,t[i+13],4,681279174),d=Te(d,o,l,c,t[i+0],11,3936430074),c=Te(c,d,o,l,t[i+3],16,3572445317),l=Te(l,c,d,o,t[i+6],23,76029189),o=Te(o,l,c,d,t[i+9],4,3654602809),d=Te(d,o,l,c,t[i+12],11,3873151461),c=Te(c,d,o,l,t[i+15],16,530742520),l=Te(l,c,d,o,t[i+2],23,3299628645),o=fe(o,l,c,d,t[i+0],6,4096336452),d=fe(d,o,l,c,t[i+7],10,1126891415),c=fe(c,d,o,l,t[i+14],15,2878612391),l=fe(l,c,d,o,t[i+5],21,4237533241),o=fe(o,l,c,d,t[i+12],6,1700485571),d=fe(d,o,l,c,t[i+3],10,2399980690),c=fe(c,d,o,l,t[i+10],15,4293915773),l=fe(l,c,d,o,t[i+1],21,2240044497),o=fe(o,l,c,d,t[i+8],6,1873313359),d=fe(d,o,l,c,t[i+15],10,4264355552),c=fe(c,d,o,l,t[i+6],15,2734768916),l=fe(l,c,d,o,t[i+13],21,1309151649),o=fe(o,l,c,d,t[i+4],6,4149444226),d=fe(d,o,l,c,t[i+11],10,3174756917),c=fe(c,d,o,l,t[i+2],15,718787259),l=fe(l,c,d,o,t[i+9],21,3951481745),o=ue(o,n),l=ue(l,r),c=ue(c,s),d=ue(d,a);return(me(o)+me(l)+me(c)+me(d)).toLowerCase()};class Ce{static getCanvasShowH(){return this.canvasH-this.bottomBarH-this.statusBarH}}class we{constructor(){this.layoutX=0,this.layoutY=0,this.layoutW=0,this.layoutH=0,this.minW=0,this.minH=0,this.maxW=0,this.maxH=0,this.alignParent=100,this.padding=0,this.paddingLeft=0,this.paddingRight=0,this.paddingTop=0,this.paddingBottom=0,this.margin=0,this.marginLeft=0,this.marginRight=0,this.marginTop=0,this.marginBottom=0,this.border=0,this.borderLeft=0,this.borderRight=0,this.borderTop=0,this.borderBottom=0}cloneModelLayoutParam(e){this.alignParent=e.alignParent,this.padding=e.padding,this.paddingLeft=e.paddingLeft,this.paddingRight=e.paddingRight,this.paddingTop=e.paddingTop,this.paddingBottom=e.paddingBottom,this.margin=e.margin,this.marginLeft=e.marginLeft,this.marginRight=e.marginRight,this.marginTop=e.marginTop,this.marginBottom=e.marginBottom,this.border=e.border,this.borderLeft=e.borderLeft,this.borderRight=e.borderRight,this.borderTop=e.borderTop,this.borderBottom=e.borderBottom}}class Se{constructor(e){this.valueList=[],e&&this.valueList.push(e)}append(e){return this.valueList.push(e),this}toString(){return this.valueList.join("")}}var _e,Oe=((_e=Oe||{})[_e.LEFT_CENTER=0]="LEFT_CENTER",_e[_e.LEFT_TOP=1]="LEFT_TOP",_e[_e.LEFT_BOTTOM=2]="LEFT_BOTTOM",_e[_e.RIGHT_CENTER=3]="RIGHT_CENTER",_e[_e.RIGHT_TOP=4]="RIGHT_TOP",_e[_e.RIGHT_BOTTOM=5]="RIGHT_BOTTOM",_e[_e.CENTER=6]="CENTER",_e[_e.TOP_CENTER=7]="TOP_CENTER",_e[_e.BOTTOM_CENTER=8]="BOTTOM_CENTER",_e[_e.HORIZONTAL_CENTER=9]="HORIZONTAL_CENTER",_e[_e.VERTICAL_CENTER=10]="VERTICAL_CENTER",_e[_e.NONE=100]="NONE",_e);class Ne{static getVarName(e){return""+this.var+e.substring(0,1).toUpperCase()+e.substring(1)}}Ne.FAIL="fail",Ne.SUC="suc",Ne.ALICE_HAO="$alice_",Ne.FUN_HAO="$fun_",Ne.VAR_HAO="$var_",Ne.ALICE_EID_INPUT="$eid_",Ne.KONG_GE=" ",Ne.NONE="",Ne.ASSETS_FILE=".ap",Ne.noCache=0,Ne.verUpdateCache=1,Ne.WENHAO="?",Ne.DENG="=",Ne.HE="&",Ne.key="key",Ne.val="val",Ne.type="type",Ne.var="var",Ne.varKey="varKey",Ne.DATA_TYPE_OBJECT=1,Ne.DATA_TYPE_ARRAY=2,Ne.UNUSE_COLOR="",Ne.UNUSE_INT=-923582351,Ne.TRANSPARENT_COLOR="#00000000",Ne.DEF_COLOR="#000000",Ne.EX_MODIFY_AFTER_ADD=1,Ne.EX_MODIFY_BEFORE_ADD=2,Ne.EX_MODIFY_AFTER_SUB=3,Ne.EX_MODIFY_BEFORE_SUB=4,Ne.DEF_NUMBER=0,Ne.SHARE_SCENE_HY=0,Ne.SHARE_SCENE_PYQ=1,Ne.SHARE_SCENE_SC=2;class ve{constructor(e){if(this.keys=[],this.values=[],e){const t=Object.keys(e);for(const i of t)this.keys.push(i),this.values.push(e[i])}}put(e,t){const i=this.keys.indexOf(e);-1===i?(this.keys.push(e),this.values.push(t)):this.values[i]=t}get(e){const t=this.keys.indexOf(e);return-1===t?void 0:this.values[t]}getKey(e){return this.keys[e]}getVal(e){return this.values[e]}has(e){return this.keys.includes(e)}remove(e){const t=this.keys.indexOf(e);-1!==t&&(this.keys.splice(t,1),this.values.splice(t,1))}putAll(e){const t=e.getKeys(),i=e.getValues();for(let e=0;e<t.length;e++)this.put(t[e],i[e])}size(){return this.keys.length}clear(){this.keys=[],this.values=[]}getKeys(){return this.keys}getValues(){return this.values}clone(){const e=new ve;for(let t=0;t<this.keys.length;t++)e.put(this.keys[t],this.values[t]);return e}containsKey(e){return this.keys.includes(e)}isEmpty(){return 0==this.keys.length&&0===this.values.length}forEach(e){for(let t=0;t<this.keys.length;t++){const i=e(this.values[t],this.keys[t]);if(!1===i)break;if(!0!==i&&void 0!==i)return i}}toObject(){const e={};for(let t=0;t<this.keys.length;t++)e[this.keys[t]]=this.values[t];return e}toJSONString(){const e={};return this.forEach(((t,i)=>{e[i]=t})),JSON.stringify(e)}*[Symbol.iterator](){for(let e=0;e<this.keys.length;e++)yield[this.keys[e],this.values[e]]}toUrlParams(){const e=new Se;if(this.size()>0){let t=0;this.forEach(((i,n)=>{t++,e.append(n),e.append(Ne.DENG),e.append(i),t<this.size()&&e.append(Ne.HE)}))}return e.toString()}}const ye=class e{static encrypt(t){return de.sm4.encrypt(t,e.key,{mode:"cbc",iv:e.iv,padding:"pkcs#7"})}static decrypt(t){return de.sm4.decrypt(t,e.key,{mode:"cbc",iv:e.iv,padding:"pkcs#7"})}};ye.key="8e57ceb3d52f37ba5caee980377958a2",ye.iv="fedcba98765432100123456789abcdef";let Me=ye;const Le=class e{static toParams(t){let i=t;return e.notNullOrUndefined(t)&&(t instanceof ve?i=t.toObject():Array.isArray(t)?i=t:"string"==typeof t&&(i=String(t))),i}static isNumber(e){return"number"==typeof e||/^(-?[1-9]\d*\.\d+|-?0\.\d*[1-9])$/.test(e)}static isEmpty(e){return null==e||"string"==typeof e&&""===e&&void 0!==e}static notEmpty(e){return!this.isEmpty(e)}static notNullOrUndefined(e){return null!=e&&void 0!==e}static isNullOrUndefined(e){return null==e||void 0===e}static throttle(e,t){let i=0,n=null;return function(...r){const s=this;function a(){const n=Date.now();n-i>t&&(e.apply(s,r),i=n)}n&&clearTimeout(n),n=setTimeout(a,t),a()}}static debounce(e,t){let i=null;return function(...n){const r=this;i&&clearTimeout(i),i=setTimeout((()=>{e.apply(r,n)}),t)}}static asyncRun(e){if("undefined"!=typeof Promise)Promise.resolve().then(e);else if("undefined"!=typeof MutationObserver){const t=new MutationObserver(e),i=document.createTextNode("0");t.observe(i,{characterData:!0}),i.data="1"}else setTimeout(e)}static doCheckRendered(){if(this.renderedDomList.length>0){for(let t=this.renderedDomList.length-1;t>=0;t--){const i=this.renderedDomList[t],{isFatherNotRender:n,isFatherGone:r}=this.checkFatherStatus(i.el);if(0===i.status||n){this.renderedDomList.splice(this.renderedDomList.findIndex((e=>e.el===i.el)),1);continue}if(2===i.status||r||i.el.classList.contains("bytefun-v-hide")||"none"===i.el.style.display){this.stopRenderedDomList.push(...this.renderedDomList.splice(this.renderedDomList.findIndex((e=>e.el===i.el)),1));continue}const s=i.el;s&&e.asyncRun((()=>{const{x:e,y:t,left:n,top:r,right:a,bottom:o,width:l,height:c}=s.getBoundingClientRect();if(0!==e||0!==t||0!==n||0!==r||0!==a||0!==o||0!==l||0!==c){this.renderedDomList.splice(this.renderedDomList.findIndex((e=>e.el===i.el)),1);const e=this.stopRenderedDomList.findIndex((e=>e.el===i.el));e>=0&&this.stopRenderedDomList.splice(e,1),i.fn&&i.fn()}}))}this.renderedDomList.length>0?requestAnimationFrame((()=>this.doCheckRendered())):(this.isIsRunning=this.renderedDomList.length>0,this.isIsRunning&&requestAnimationFrame((()=>this.doCheckRendered())))}else this.isIsRunning=this.renderedDomList.length>0,this.isIsRunning&&requestAnimationFrame((()=>this.doCheckRendered()))}static checkRendered(e,t){let i=e.getAttribute("id");i?i="#"+i:(i=e.getAttributeNames().find((e=>e.startsWith("bytefun-v"))),i=e.tagName.toLowerCase()+"["+i+"]");const{x:n,y:r,left:s,top:a,right:o,bottom:l,width:c,height:d}=e.getBoundingClientRect();0===n&&0===r&&0===s&&0===a&&0===o&&0===l&&0===c&&0===d?(this.renderedDomList.unshift({el:e,key:i,fn:t,status:1}),!this.isIsRunning&&(this.isIsRunning=!0,this.doCheckRendered())):t&&requestAnimationFrame(t)}static waitCheckRendered(e,t){let i=e.getAttribute("id");i?i="#"+i:(i=e.getAttributeNames().find((e=>e.startsWith("bytefun-v"))),i=e.tagName.toLowerCase()+"["+i+"]"),this.stopRenderedDomList.unshift({el:e,key:i,fn:t,status:1})}static removeCheckRendered(e){for(let t=this.renderedDomList.length-1;t>=0;t--)this.renderedDomList[t].el===e&&(this.renderedDomList[t].status=0);for(let t=this.stopRenderedDomList.length-1;t>=0;t--)this.stopRenderedDomList[t].el===e&&this.stopRenderedDomList.splice(t,1)}static stopCheckRendered(e){for(let t=this.renderedDomList.length-1;t>=0;t--)this.renderedDomList[t].el===e&&(this.renderedDomList[t].status=2)}static restartCheckRendered(e){for(l