(()=>{var V5=Object.create;var Dg=Object.defineProperty;var G5=Object.getOwnPropertyDescriptor;var z5=Object.getOwnPropertyNames;var Y5=Object.getPrototypeOf,W5=Object.prototype.hasOwnProperty;var ja=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var Ce=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var X5=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of z5(t))!W5.call(e,i)&&i!==r&&Dg(e,i,{get:()=>t[i],enumerable:!(n=G5(t,i))||n.enumerable});return e};var ei=(e,t,r)=>(r=e!=null?V5(Y5(e)):{},X5(t||!e||!e.__esModule?Dg(r,"default",{value:e,enumerable:!0}):r,e));var Np=Ce(Zu=>{"use strict";Object.defineProperty(Zu,"__esModule",{value:!0});Zu.isCorrect=Zu.isInSubnet=void 0;function a3(e){return this.subnetMask{"use strict";Object.defineProperty(Pi,"__esModule",{value:!0});Pi.RE_SUBNET_STRING=Pi.RE_ADDRESS=Pi.GROUPS=Pi.BITS=void 0;Pi.BITS=32;Pi.GROUPS=4;Pi.RE_ADDRESS=/^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/g;Pi.RE_SUBNET_STRING=/\/\d{1,2}$/});var rf=Ce(tf=>{"use strict";Object.defineProperty(tf,"__esModule",{value:!0});tf.AddressError=void 0;var Lp=class extends Error{constructor(t,r){super(t),this.name="AddressError",r!==null&&(this.parseMessage=r)}};tf.AddressError=Lp});var Up=Ce((nf,xg)=>{(function(){var e,t=0xdeadbeefcafe,r=(t&16777215)==15715070;function n(R,x,j){R!=null&&(typeof R=="number"?this.fromNumber(R,x,j):x==null&&typeof R!="string"?this.fromString(R,256):this.fromString(R,x))}function i(){return new n(null)}function a(R,x,j,Q,de,ve){for(;--ve>=0;){var Fe=x*this[R++]+j[Q]+de;de=Math.floor(Fe/67108864),j[Q++]=Fe&67108863}return de}function s(R,x,j,Q,de,ve){for(var Fe=x&32767,$e=x>>15;--ve>=0;){var _t=this[R]&32767,zt=this[R++]>>15,_r=$e*_t+zt*Fe;_t=Fe*_t+((_r&32767)<<15)+j[Q]+(de&1073741823),de=(_t>>>30)+(_r>>>15)+$e*zt+(de>>>30),j[Q++]=_t&1073741823}return de}function c(R,x,j,Q,de,ve){for(var Fe=x&16383,$e=x>>14;--ve>=0;){var _t=this[R]&16383,zt=this[R++]>>14,_r=$e*_t+zt*Fe;_t=Fe*_t+((_r&16383)<<14)+j[Q]+de,de=(_t>>28)+(_r>>14)+$e*zt,j[Q++]=_t&268435455}return de}var l=typeof navigator<"u";l&&r&&navigator.appName=="Microsoft Internet Explorer"?(n.prototype.am=s,e=30):l&&r&&navigator.appName!="Netscape"?(n.prototype.am=a,e=26):(n.prototype.am=c,e=28),n.prototype.DB=e,n.prototype.DM=(1<=0;--x)R[x]=this[x];R.t=this.t,R.s=this.s}function w(R){this.t=1,this.s=R<0?-1:0,R>0?this[0]=R:R<-1?this[0]=R+this.DV:this.t=0}function S(R){var x=i();return x.fromInt(R),x}function _(R,x){var j;if(x==16)j=4;else if(x==8)j=3;else if(x==256)j=8;else if(x==2)j=1;else if(x==32)j=5;else if(x==4)j=2;else{this.fromRadix(R,x);return}this.t=0,this.s=0;for(var Q=R.length,de=!1,ve=0;--Q>=0;){var Fe=j==8?R[Q]&255:g(R,Q);if(Fe<0){R.charAt(Q)=="-"&&(de=!0);continue}de=!1,ve==0?this[this.t++]=Fe:ve+j>this.DB?(this[this.t-1]|=(Fe&(1<>this.DB-ve):this[this.t-1]|=Fe<=this.DB&&(ve-=this.DB)}j==8&&R[0]&128&&(this.s=-1,ve>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==R;)--this.t}function B(R){if(this.s<0)return"-"+this.negate().toString(R);var x;if(R==16)x=4;else if(R==8)x=3;else if(R==2)x=1;else if(R==32)x=5;else if(R==4)x=2;else return this.toRadix(R);var j=(1<0)for($e>$e)>0&&(de=!0,ve=A(Q));Fe>=0;)$e>($e+=this.DB-x)):(Q=this[Fe]>>($e-=x)&j,$e<=0&&($e+=this.DB,--Fe)),Q>0&&(de=!0),de&&(ve+=A(Q));return de?ve:"0"}function q(){var R=i();return n.ZERO.subTo(this,R),R}function z(){return this.s<0?this.negate():this}function F(R){var x=this.s-R.s;if(x!=0)return x;var j=this.t;if(x=j-R.t,x!=0)return this.s<0?-x:x;for(;--j>=0;)if((x=this[j]-R[j])!=0)return x;return 0}function P(R){var x=1,j;return(j=R>>>16)!=0&&(R=j,x+=16),(j=R>>8)!=0&&(R=j,x+=8),(j=R>>4)!=0&&(R=j,x+=4),(j=R>>2)!=0&&(R=j,x+=2),(j=R>>1)!=0&&(R=j,x+=1),x}function L(){return this.t<=0?0:this.DB*(this.t-1)+P(this[this.t-1]^this.s&this.DM)}function H(R,x){var j;for(j=this.t-1;j>=0;--j)x[j+R]=this[j];for(j=R-1;j>=0;--j)x[j]=0;x.t=this.t+R,x.s=this.s}function K(R,x){for(var j=R;j=0;--$e)x[$e+ve+1]=this[$e]>>Q|Fe,Fe=(this[$e]&de)<=0;--$e)x[$e]=0;x[ve]=Fe,x.t=this.t+ve+1,x.s=this.s,x.clamp()}function G(R,x){x.s=this.s;var j=Math.floor(R/this.DB);if(j>=this.t){x.t=0;return}var Q=R%this.DB,de=this.DB-Q,ve=(1<>Q;for(var Fe=j+1;Fe>Q;Q>0&&(x[this.t-j-1]|=(this.s&ve)<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;j>=this.DB;Q-=R.s}x.s=Q<0?-1:0,Q<-1?x[j++]=this.DV+Q:Q>0&&(x[j++]=Q),x.t=j,x.clamp()}function X(R,x){var j=this.abs(),Q=R.abs(),de=j.t;for(x.t=de+Q.t;--de>=0;)x[de]=0;for(de=0;de=0;)R[j]=0;for(j=0;j=x.DV&&(R[j+x.t]-=x.DV,R[j+x.t+1]=1)}R.t>0&&(R[R.t-1]+=x.am(j,x[j],R,2*j,0,1)),R.s=0,R.clamp()}function Se(R,x,j){var Q=R.abs();if(!(Q.t<=0)){var de=this.abs();if(de.t0?(Q.lShiftTo(_t,ve),de.lShiftTo(_t,j)):(Q.copyTo(ve),de.copyTo(j));var zt=ve.t,_r=ve[zt-1];if(_r!=0){var Ir=_r*(1<1?ve[zt-2]>>this.F2:0),Cn=this.FV/Ir,qs=(1<=0&&(j[j.t++]=1,j.subTo(Gn,j)),n.ONE.dlShiftTo(zt,Gn),Gn.subTo(ve,ve);ve.t=0;){var Pa=j[--Dr]==_r?this.DM:Math.floor(j[Dr]*Cn+(j[Dr-1]+Wr)*qs);if((j[Dr]+=ve.am(0,Pa,j,Ks,0,zt))0&&j.rShiftTo(_t,j),Fe<0&&n.ZERO.subTo(j,j)}}}function Ee(R){var x=i();return this.abs().divRemTo(R,null,x),this.s<0&&x.compareTo(n.ZERO)>0&&R.subTo(x,x),x}function Pe(R){this.m=R}function qe(R){return R.s<0||R.compareTo(this.m)>=0?R.mod(this.m):R}function ce(R){return R}function _e(R){R.divRemTo(this.m,null,R)}function ke(R,x,j){R.multiplyTo(x,j),this.reduce(j)}function mr(R,x){R.squareTo(x),this.reduce(x)}Pe.prototype.convert=qe,Pe.prototype.revert=ce,Pe.prototype.reduce=_e,Pe.prototype.mulTo=ke,Pe.prototype.sqrTo=mr;function xt(){if(this.t<1)return 0;var R=this[0];if(!(R&1))return 0;var x=R&3;return x=x*(2-(R&15)*x)&15,x=x*(2-(R&255)*x)&255,x=x*(2-((R&65535)*x&65535))&65535,x=x*(2-R*x%this.DV)%this.DV,x>0?this.DV-x:-x}function ht(R){this.m=R,this.mp=R.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(x,x),x}function Ut(R){var x=i();return R.copyTo(x),this.reduce(x),x}function rt(R){for(;R.t<=this.mt2;)R[R.t++]=0;for(var x=0;x>15)*this.mpl&this.um)<<15)&R.DM;for(j=x+this.m.t,R[j]+=this.m.am(0,Q,R,x,0,this.m.t);R[j]>=R.DV;)R[j]-=R.DV,R[++j]++}R.clamp(),R.drShiftTo(this.m.t,R),R.compareTo(this.m)>=0&&R.subTo(this.m,R)}function $t(R,x){R.squareTo(x),this.reduce(x)}function et(R,x,j){R.multiplyTo(x,j),this.reduce(j)}ht.prototype.convert=Zt,ht.prototype.revert=Ut,ht.prototype.reduce=rt,ht.prototype.mulTo=et,ht.prototype.sqrTo=$t;function vt(){return(this.t>0?this[0]&1:this.s)==0}function Qt(R,x){if(R>4294967295||R<1)return n.ONE;var j=i(),Q=i(),de=x.convert(this),ve=P(R)-1;for(de.copyTo(j);--ve>=0;)if(x.sqrTo(j,Q),(R&1<0)x.mulTo(Q,de,j);else{var Fe=j;j=Q,Q=Fe}return x.revert(j)}function Xe(R,x){var j;return R<256||x.isEven()?j=new Pe(x):j=new ht(x),this.exp(R,j)}n.prototype.copyTo=y,n.prototype.fromInt=w,n.prototype.fromString=_,n.prototype.clamp=I,n.prototype.dlShiftTo=H,n.prototype.drShiftTo=K,n.prototype.lShiftTo=Z,n.prototype.rShiftTo=G,n.prototype.subTo=V,n.prototype.multiplyTo=X,n.prototype.squareTo=ie,n.prototype.divRemTo=Se,n.prototype.invDigit=xt,n.prototype.isEven=vt,n.prototype.exp=Qt,n.prototype.toString=B,n.prototype.negate=q,n.prototype.abs=z,n.prototype.compareTo=F,n.prototype.bitLength=L,n.prototype.mod=Ee,n.prototype.modPowInt=Xe,n.ZERO=S(0),n.ONE=S(1);function Vt(){var R=i();return this.copyTo(R),R}function Vn(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function Fr(){return this.t==0?this.s:this[0]<<16>>16}function rr(R){return Math.floor(Math.LN2*this.DB/Math.log(R))}function Or(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function ma(R){if(R==null&&(R=10),this.signum()==0||R<2||R>36)return"0";var x=this.chunkSize(R),j=Math.pow(R,x),Q=S(j),de=i(),ve=i(),Fe="";for(this.divRemTo(Q,de,ve);de.signum()>0;)Fe=(j+ve.intValue()).toString(R).substr(1)+Fe,de.divRemTo(Q,de,ve);return ve.intValue().toString(R)+Fe}function zr(R,x){this.fromInt(0),x==null&&(x=10);for(var j=this.chunkSize(x),Q=Math.pow(x,j),de=!1,ve=0,Fe=0,$e=0;$e=j&&(this.dMultiply(Q),this.dAddOffset(Fe,0),ve=0,Fe=0)}ve>0&&(this.dMultiply(Math.pow(x,ve)),this.dAddOffset(Fe,0)),de&&n.ZERO.subTo(this,this)}function wt(R,x,j){if(typeof x=="number")if(R<2)this.fromInt(1);else for(this.fromNumber(R,j),this.testBit(R-1)||this.bitwiseTo(n.ONE.shiftLeft(R-1),Xi,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(x);)this.dAddOffset(2,0),this.bitLength()>R&&this.subTo(n.ONE.shiftLeft(R-1),this);else{var Q=new Array,de=R&7;Q.length=(R>>3)+1,x.nextBytes(Q),de>0?Q[0]&=(1<0)for(j>j)!=(this.s&this.DM)>>j&&(x[de++]=Q|this.s<=0;)j<8?(Q=(this[R]&(1<>(j+=this.DB-8)):(Q=this[R]>>(j-=8)&255,j<=0&&(j+=this.DB,--R)),Q&128&&(Q|=-256),de==0&&(this.s&128)!=(Q&128)&&++de,(de>0||Q!=this.s)&&(x[de++]=Q);return x}function Je(R){return this.compareTo(R)==0}function Nr(R){return this.compareTo(R)<0?this:R}function va(R){return this.compareTo(R)>0?this:R}function wa(R,x,j){var Q,de,ve=Math.min(R.t,this.t);for(Q=0;Q>=16,x+=16),R&255||(R>>=8,x+=8),R&15||(R>>=4,x+=4),R&3||(R>>=2,x+=2),R&1||++x,x}function wu(){for(var R=0;R=this.t?this.s!=0:(this[x]&1<>=this.DB;if(R.t>=this.DB;Q+=this.s}else{for(Q+=this.s;j>=this.DB;Q+=R.s}x.s=Q<0?-1:0,Q>0?x[j++]=Q:Q<-1&&(x[j++]=this.DV+Q),x.t=j,x.clamp()}function Sa(R){var x=i();return this.addTo(R,x),x}function ko(R){var x=i();return this.subTo(R,x),x}function Lo(R){var x=i();return this.multiplyTo(R,x),x}function Uo(){var R=i();return this.squareTo(R),R}function Ho(R){var x=i();return this.divRemTo(R,x,null),x}function jo(R){var x=i();return this.divRemTo(R,null,x),x}function Mo(R){var x=i(),j=i();return this.divRemTo(R,x,j),new Array(x,j)}function qo(R){this[this.t]=this.am(0,R-1,this,0,0,this.t),++this.t,this.clamp()}function Ko(R,x){if(R!=0){for(;this.t<=x;)this[this.t++]=0;for(this[x]+=R;this[x]>=this.DV;)this[x]-=this.DV,++x>=this.t&&(this[this.t++]=0),++this[x]}}function yi(){}function yu(R){return R}function Vo(R,x,j){R.multiplyTo(x,j)}function Go(R,x){R.squareTo(x)}yi.prototype.convert=yu,yi.prototype.revert=yu,yi.prototype.mulTo=Vo,yi.prototype.sqrTo=Go;function zo(R){return this.exp(R,new yi)}function Su(R,x,j){var Q=Math.min(this.t+R.t,x);for(j.s=0,j.t=Q;Q>0;)j[--Q]=0;var de;for(de=j.t-this.t;Q=0;)j[Q]=0;for(Q=Math.max(x-this.t,0);Q2*this.m.t)return R.mod(this.m);if(R.compareTo(this.m)<0)return R;var x=i();return R.copyTo(x),this.reduce(x),x}function js(R){return R}function bn(R){for(R.drShiftTo(this.m.t-1,this.r2),R.t>this.m.t+1&&(R.t=this.m.t+1,R.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);R.compareTo(this.r2)<0;)R.dAddOffset(1,this.m.t+1);for(R.subTo(this.r2,R);R.compareTo(this.m)>=0;)R.subTo(this.m,R)}function Wo(R,x){R.squareTo(x),this.reduce(x)}function Xo(R,x,j){R.multiplyTo(x,j),this.reduce(j)}an.prototype.convert=Yo,an.prototype.revert=js,an.prototype.reduce=bn,an.prototype.mulTo=Xo,an.prototype.sqrTo=Wo;function bu(R,x){var j=R.bitLength(),Q,de=S(1),ve;if(j<=0)return de;j<18?Q=1:j<48?Q=3:j<144?Q=4:j<768?Q=5:Q=6,j<8?ve=new Pe(x):x.isEven()?ve=new an(x):ve=new ht(x);var Fe=new Array,$e=3,_t=Q-1,zt=(1<1){var _r=i();for(ve.sqrTo(Fe[1],_r);$e<=zt;)Fe[$e]=i(),ve.mulTo(_r,Fe[$e-2],Fe[$e]),$e+=2}var Ir=R.t-1,Cn,qs=!0,Wr=i(),Dr;for(j=P(R[Ir])-1;Ir>=0;){for(j>=_t?Cn=R[Ir]>>j-_t&zt:(Cn=(R[Ir]&(1<0&&(Cn|=R[Ir-1]>>this.DB+j-_t)),$e=Q;!(Cn&1);)Cn>>=1,--$e;if((j-=$e)<0&&(j+=this.DB,--Ir),qs)Fe[Cn].copyTo(de),qs=!1;else{for(;$e>1;)ve.sqrTo(de,Wr),ve.sqrTo(Wr,de),$e-=2;$e>0?ve.sqrTo(de,Wr):(Dr=de,de=Wr,Wr=Dr),ve.mulTo(Wr,Fe[Cn],de)}for(;Ir>=0&&!(R[Ir]&1<0&&(x.rShiftTo(ve,x),j.rShiftTo(ve,j));x.signum()>0;)(de=x.getLowestSetBit())>0&&x.rShiftTo(de,x),(de=j.getLowestSetBit())>0&&j.rShiftTo(de,j),x.compareTo(j)>=0?(x.subTo(j,x),x.rShiftTo(1,x)):(j.subTo(x,j),j.rShiftTo(1,j));return ve>0&&j.lShiftTo(ve,j),j}function Cu(R){if(R<=0)return 0;var x=this.DV%R,j=this.s<0?R-1:0;if(this.t>0)if(x==0)j=this[0]%R;else for(var Q=this.t-1;Q>=0;--Q)j=(x*j+this[Q])%R;return j}function Ms(R){var x=R.isEven();if(this.isEven()&&x||R.signum()==0)return n.ZERO;for(var j=R.clone(),Q=this.clone(),de=S(1),ve=S(0),Fe=S(0),$e=S(1);j.signum()!=0;){for(;j.isEven();)j.rShiftTo(1,j),x?((!de.isEven()||!ve.isEven())&&(de.addTo(this,de),ve.subTo(R,ve)),de.rShiftTo(1,de)):ve.isEven()||ve.subTo(R,ve),ve.rShiftTo(1,ve);for(;Q.isEven();)Q.rShiftTo(1,Q),x?((!Fe.isEven()||!$e.isEven())&&(Fe.addTo(this,Fe),$e.subTo(R,$e)),Fe.rShiftTo(1,Fe)):$e.isEven()||$e.subTo(R,$e),$e.rShiftTo(1,$e);j.compareTo(Q)>=0?(j.subTo(Q,j),x&&de.subTo(Fe,de),ve.subTo($e,ve)):(Q.subTo(j,Q),x&&Fe.subTo(de,Fe),$e.subTo(ve,$e))}if(Q.compareTo(n.ONE)!=0)return n.ZERO;if($e.compareTo(R)>=0)return $e.subtract(R);if($e.signum()<0)$e.addTo(R,$e);else return $e;return $e.signum()<0?$e.add(R):$e}var Gt=[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],Jo=(1<<26)/Gt[Gt.length-1];function Zo(R){var x,j=this.abs();if(j.t==1&&j[0]<=Gt[Gt.length-1]){for(x=0;x>1,R>Gt.length&&(R=Gt.length);for(var de=i(),ve=0;ve>8&255,wr[kt++]^=R>>16&255,wr[kt++]^=R>>24&255,kt>=Yr&&(kt-=Yr)}function Ca(){Qo(new Date().getTime())}if(wr==null){wr=new Array,kt=0;var Ar;if(typeof window<"u"&&window.crypto){if(window.crypto.getRandomValues){var Fa=new Uint8Array(32);for(window.crypto.getRandomValues(Fa),Ar=0;Ar<32;++Ar)wr[kt++]=Fa[Ar]}else if(navigator.appName=="Netscape"&&navigator.appVersion<"5"){var _u=window.crypto.random(32);for(Ar=0;Ar<_u.length;++Ar)wr[kt++]=_u.charCodeAt(Ar)&255}}for(;kt>>8,wr[kt++]=Ar&255;kt=0,Ca()}function Iu(){if(bi==null){for(Ca(),bi=Ba(),bi.init(wr),kt=0;kt{(function(){"use strict";var e={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function t(s){return n(a(s),arguments)}function r(s,c){return t.apply(null,[s].concat(c||[]))}function n(s,c){var l=1,h=s.length,v,E="",p,f,A,g,y,w,S,_;for(p=0;p=0),A.type){case"b":v=parseInt(v,10).toString(2);break;case"c":v=String.fromCharCode(parseInt(v,10));break;case"d":case"i":v=parseInt(v,10);break;case"j":v=JSON.stringify(v,null,A.width?parseInt(A.width):0);break;case"e":v=A.precision?parseFloat(v).toExponential(A.precision):parseFloat(v).toExponential();break;case"f":v=A.precision?parseFloat(v).toFixed(A.precision):parseFloat(v);break;case"g":v=A.precision?String(Number(v.toPrecision(A.precision))):parseFloat(v);break;case"o":v=(parseInt(v,10)>>>0).toString(8);break;case"s":v=String(v),v=A.precision?v.substring(0,A.precision):v;break;case"t":v=String(!!v),v=A.precision?v.substring(0,A.precision):v;break;case"T":v=Object.prototype.toString.call(v).slice(8,-1).toLowerCase(),v=A.precision?v.substring(0,A.precision):v;break;case"u":v=parseInt(v,10)>>>0;break;case"v":v=v.valueOf(),v=A.precision?v.substring(0,A.precision):v;break;case"x":v=(parseInt(v,10)>>>0).toString(16);break;case"X":v=(parseInt(v,10)>>>0).toString(16).toUpperCase();break}e.json.test(A.type)?E+=v:(e.number.test(A.type)&&(!S||A.sign)?(_=S?"+":"-",v=v.toString().replace(e.sign,"")):_="",y=A.pad_char?A.pad_char==="0"?"0":A.pad_char.charAt(1):" ",w=A.width-(_+v).length,g=A.width&&w>0?y.repeat(w):"",E+=A.align?_+v+g:y==="0"?_+g+v:g+_+v)}return E}var i=Object.create(null);function a(s){if(i[s])return i[s];for(var c=s,l,h=[],v=0;c;){if((l=e.text.exec(c))!==null)h.push(l[0]);else if((l=e.modulo.exec(c))!==null)h.push("%");else if((l=e.placeholder.exec(c))!==null){if(l[2]){v|=1;var E=[],p=l[2],f=[];if((f=e.key.exec(p))!==null)for(E.push(f[1]);(p=p.substring(f[0].length))!=="";)if((f=e.key_access.exec(p))!==null)E.push(f[1]);else if((f=e.index_access.exec(p))!==null)E.push(f[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=E}else v|=2;if(v===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");h.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(l[0].length)}return i[s]=h}typeof sf<"u"&&(sf.sprintf=t,sf.vsprintf=r),typeof window<"u"&&(window.sprintf=t,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:t,vsprintf:r}}))})()});var jp=Ce($i=>{"use strict";var o3=$i&&$i.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),c3=$i&&$i.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),kg=$i&&$i.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&o3(t,e,r);return c3(t,e),t};Object.defineProperty($i,"__esModule",{value:!0});$i.Address4=void 0;var Og=kg(Np()),gi=kg(kp()),Ng=rf(),Cc=Up(),Qu=bc(),Hp=class e{constructor(t){this.groups=gi.GROUPS,this.parsedAddress=[],this.parsedSubnet="",this.subnet="/32",this.subnetMask=32,this.v4=!0,this.isCorrect=Og.isCorrect(gi.BITS),this.isInSubnet=Og.isInSubnet,this.address=t;let r=gi.RE_SUBNET_STRING.exec(t);if(r){if(this.parsedSubnet=r[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,this.subnetMask<0||this.subnetMask>gi.BITS)throw new Ng.AddressError("Invalid subnet mask.");t=t.replace(gi.RE_SUBNET_STRING,"")}this.addressMinusSuffix=t,this.parsedAddress=this.parse(t)}static isValid(t){try{return new e(t),!0}catch{return!1}}parse(t){let r=t.split(".");if(!t.match(gi.RE_ADDRESS))throw new Ng.AddressError("Invalid IPv4 address.");return r}correctForm(){return this.parsedAddress.map(t=>parseInt(t,10)).join(".")}static fromHex(t){let r=t.replace(/:/g,"").padStart(8,"0"),n=[],i;for(i=0;i<8;i+=2){let a=r.slice(i,i+2);n.push(parseInt(a,16))}return new e(n.join("."))}static fromInteger(t){return e.fromHex(t.toString(16))}static fromArpa(t){let n=t.replace(/(\.in-addr\.arpa)?\.$/,"").split(".").reverse().join(".");return new e(n)}toHex(){return this.parsedAddress.map(t=>(0,Qu.sprintf)("%02x",parseInt(t,10))).join(":")}toArray(){return this.parsedAddress.map(t=>parseInt(t,10))}toGroup6(){let t=[],r;for(r=0;r(0,Qu.sprintf)("%02x",parseInt(t,10))).join(""),16)}_startAddress(){return new Cc.BigInteger(this.mask()+"0".repeat(gi.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new Cc.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new Cc.BigInteger(this.mask()+"1".repeat(gi.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new Cc.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}static fromBigInteger(t){return e.fromInteger(parseInt(t.toString(),10))}mask(t){return t===void 0&&(t=this.subnetMask),this.getBitsBase2(0,t)}getBitsBase2(t,r){return this.binaryZeroPad().slice(t,r)}reverseForm(t){t||(t={});let r=this.correctForm().split(".").reverse().join(".");return t.omitSuffix?r:(0,Qu.sprintf)("%s.in-addr.arpa.",r)}isMulticast(){return this.isInSubnet(new e("224.0.0.0/4"))}binaryZeroPad(){return this.bigInteger().toString(2).padStart(gi.BITS,"0")}groupForV6(){let t=this.parsedAddress;return this.address.replace(gi.RE_ADDRESS,(0,Qu.sprintf)('%s.%s',t.slice(0,2).join("."),t.slice(2,4).join(".")))}};$i.Address4=Hp});var Mp=Ce(Xt=>{"use strict";Object.defineProperty(Xt,"__esModule",{value:!0});Xt.RE_URL_WITH_PORT=Xt.RE_URL=Xt.RE_ZONE_STRING=Xt.RE_SUBNET_STRING=Xt.RE_BAD_ADDRESS=Xt.RE_BAD_CHARACTERS=Xt.TYPES=Xt.SCOPES=Xt.GROUPS=Xt.BITS=void 0;Xt.BITS=128;Xt.GROUPS=8;Xt.SCOPES={0:"Reserved",1:"Interface local",2:"Link local",4:"Admin local",5:"Site local",8:"Organization local",14:"Global",15:"Reserved"};Xt.TYPES={"ff01::1/128":"Multicast (All nodes on this interface)","ff01::2/128":"Multicast (All routers on this interface)","ff02::1/128":"Multicast (All nodes on this link)","ff02::2/128":"Multicast (All routers on this link)","ff05::2/128":"Multicast (All routers in this site)","ff02::5/128":"Multicast (OSPFv3 AllSPF routers)","ff02::6/128":"Multicast (OSPFv3 AllDR routers)","ff02::9/128":"Multicast (RIP routers)","ff02::a/128":"Multicast (EIGRP routers)","ff02::d/128":"Multicast (PIM routers)","ff02::16/128":"Multicast (MLDv2 reports)","ff01::fb/128":"Multicast (mDNSv6)","ff02::fb/128":"Multicast (mDNSv6)","ff05::fb/128":"Multicast (mDNSv6)","ff02::1:2/128":"Multicast (All DHCP servers and relay agents on this link)","ff05::1:2/128":"Multicast (All DHCP servers and relay agents in this site)","ff02::1:3/128":"Multicast (All DHCP servers on this link)","ff05::1:3/128":"Multicast (All DHCP servers in this site)","::/128":"Unspecified","::1/128":"Loopback","ff00::/8":"Multicast","fe80::/10":"Link-local unicast"};Xt.RE_BAD_CHARACTERS=/([^0-9a-f:/%])/gi;Xt.RE_BAD_ADDRESS=/([0-9a-f]{5,}|:{3,}|[^:]:$|^:[^:]|\/$)/gi;Xt.RE_SUBNET_STRING=/\/\d{1,3}(?=%|$)/;Xt.RE_ZONE_STRING=/%.*$/;Xt.RE_URL=new RegExp(/^\[{0,1}([0-9a-f:]+)\]{0,1}/);Xt.RE_URL_WITH_PORT=new RegExp(/\[([0-9a-f:]+)\]:([0-9]{1,5})/)});var qp=Ce(Ri=>{"use strict";Object.defineProperty(Ri,"__esModule",{value:!0});Ri.simpleGroup=Ri.spanLeadingZeroes=Ri.spanAll=Ri.spanAllZeroes=void 0;var Lg=bc();function Ug(e){return e.replace(/(0+)/g,'$1')}Ri.spanAllZeroes=Ug;function l3(e,t=0){return e.split("").map((n,i)=>(0,Lg.sprintf)('%s',n,i+t,Ug(n))).join("")}Ri.spanAll=l3;function Hg(e){return e.replace(/^(0+)/,'$1')}function f3(e){return e.split(":").map(r=>Hg(r)).join(":")}Ri.spanLeadingZeroes=f3;function h3(e,t=0){return e.split(":").map((n,i)=>/group-v4/.test(n)?n:(0,Lg.sprintf)('%s',i+t,Hg(n)))}Ri.simpleGroup=h3});var jg=Ce(yr=>{"use strict";var p3=yr&&yr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),d3=yr&&yr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),g3=yr&&yr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&p3(t,e,r);return d3(t,e),t};Object.defineProperty(yr,"__esModule",{value:!0});yr.possibleElisions=yr.simpleRegularExpression=yr.ADDRESS_BOUNDARY=yr.padGroup=yr.groupPossibilities=void 0;var m3=g3(Mp()),eo=bc();function uf(e){return(0,eo.sprintf)("(%s)",e.join("|"))}yr.groupPossibilities=uf;function af(e){return e.length<4?(0,eo.sprintf)("0{0,%d}%s",4-e.length,e):e}yr.padGroup=af;yr.ADDRESS_BOUNDARY="[^A-Fa-f0-9:]";function v3(e){let t=[];e.forEach((n,i)=>{parseInt(n,16)===0&&t.push(i)});let r=t.map(n=>e.map((i,a)=>{if(a===n){let s=a===0||a===m3.GROUPS-1?":":"";return uf([af(i),s])}return af(i)}).join(":"));return r.push(e.map(af).join(":")),uf(r)}yr.simpleRegularExpression=v3;function w3(e,t,r){let n=t?"":":",i=r?"":":",a=[];!t&&!r&&a.push("::"),t&&r&&a.push(""),(r&&!t||!r&&t)&&a.push(":"),a.push((0,eo.sprintf)("%s(:0{1,4}){1,%d}",n,e-1)),a.push((0,eo.sprintf)("(0{1,4}:){1,%d}%s",e-1,i)),a.push((0,eo.sprintf)("(0{1,4}:){%d}0{1,4}",e-1));for(let s=1;s{"use strict";var A3=Ti&&Ti.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),E3=Ti&&Ti.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),cf=Ti&&Ti.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&A3(t,e,r);return E3(t,e),t};Object.defineProperty(Ti,"__esModule",{value:!0});Ti.Address6=void 0;var Mg=cf(Np()),Kp=cf(kp()),Ot=cf(Mp()),Vp=cf(qp()),Ga=jp(),za=jg(),ws=rf(),tn=Up(),rn=bc();function of(e){if(!e)throw new Error("Assertion failed.")}function y3(e){let t=/(\d+)(\d{3})/;for(;t.test(e);)e=e.replace(t,"$1,$2");return e}function S3(e){return e=e.replace(/^(0{1,})([1-9]+)$/,'$1$2'),e=e.replace(/^(0{1,})(0)$/,'$1$2'),e}function b3(e,t){let r=[],n=[],i;for(i=0;it[1]&&n.push(e[i]);return r.concat(["compact"]).concat(n)}function qg(e){return(0,rn.sprintf)("%04x",parseInt(e,16))}function Kg(e){return e&255}var Gp=class e{constructor(t,r){this.addressMinusSuffix="",this.parsedSubnet="",this.subnet="/128",this.subnetMask=128,this.v4=!1,this.zone="",this.isInSubnet=Mg.isInSubnet,this.isCorrect=Mg.isCorrect(Ot.BITS),r===void 0?this.groups=Ot.GROUPS:this.groups=r,this.address=t;let n=Ot.RE_SUBNET_STRING.exec(t);if(n){if(this.parsedSubnet=n[0].replace("/",""),this.subnetMask=parseInt(this.parsedSubnet,10),this.subnet=`/${this.subnetMask}`,Number.isNaN(this.subnetMask)||this.subnetMask<0||this.subnetMask>Ot.BITS)throw new ws.AddressError("Invalid subnet mask.");t=t.replace(Ot.RE_SUBNET_STRING,"")}else if(/\//.test(t))throw new ws.AddressError("Invalid subnet mask.");let i=Ot.RE_ZONE_STRING.exec(t);i&&(this.zone=i[0],t=t.replace(Ot.RE_ZONE_STRING,"")),this.addressMinusSuffix=t,this.parsedAddress=this.parse(this.addressMinusSuffix)}static isValid(t){try{return new e(t),!0}catch{return!1}}static fromBigInteger(t){let r=t.toString(16).padStart(32,"0"),n=[],i;for(i=0;i65536)&&(n=null)):n=null,{address:new e(r),port:n}}static fromAddress4(t){let r=new Ga.Address4(t),n=Ot.BITS-(Kp.BITS-r.subnetMask);return new e(`::ffff:${r.correctForm()}/${n}`)}static fromArpa(t){let r=t.replace(/(\.ip6\.arpa)?\.$/,""),n=7;if(r.length!==63)throw new ws.AddressError("Invalid 'ip6.arpa' form.");let i=r.split(".").reverse();for(let a=n;a>0;a--){let s=a*4;i.splice(s,0,":")}return r=i.join(""),new e(r)}microsoftTranscription(){return(0,rn.sprintf)("%s.ipv6-literal.net",this.correctForm().replace(/:/g,"-"))}mask(t=this.subnetMask){return this.getBitsBase2(0,t)}possibleSubnets(t=128){let r=Ot.BITS-this.subnetMask,n=Math.abs(t-Ot.BITS),i=r-n;return i<0?"0":y3(new tn.BigInteger("2",10).pow(i).toString(10))}_startAddress(){return new tn.BigInteger(this.mask()+"0".repeat(Ot.BITS-this.subnetMask),2)}startAddress(){return e.fromBigInteger(this._startAddress())}startAddressExclusive(){let t=new tn.BigInteger("1");return e.fromBigInteger(this._startAddress().add(t))}_endAddress(){return new tn.BigInteger(this.mask()+"1".repeat(Ot.BITS-this.subnetMask),2)}endAddress(){return e.fromBigInteger(this._endAddress())}endAddressExclusive(){let t=new tn.BigInteger("1");return e.fromBigInteger(this._endAddress().subtract(t))}getScope(){let t=Ot.SCOPES[this.getBits(12,16).intValue()];return this.getType()==="Global unicast"&&t!=="Link local"&&(t="Global"),t||"Unknown"}getType(){for(let t of Object.keys(Ot.TYPES))if(this.isInSubnet(new e(t)))return Ot.TYPES[t];return"Global unicast"}getBits(t,r){return new tn.BigInteger(this.getBitsBase2(t,r),2)}getBitsBase2(t,r){return this.binaryZeroPad().slice(t,r)}getBitsBase16(t,r){let n=r-t;if(n%4!==0)throw new Error("Length of bits to retrieve must be divisible by four");return this.getBits(t,r).toString(16).padStart(n/4,"0")}getBitsPastSubnet(){return this.getBitsBase2(this.subnetMask,Ot.BITS)}reverseForm(t){t||(t={});let r=Math.floor(this.subnetMask/4),n=this.canonicalForm().replace(/:/g,"").split("").slice(0,r).reverse().join(".");return r>0?t.omitSuffix?n:(0,rn.sprintf)("%s.ip6.arpa.",n):t.omitSuffix?"":"ip6.arpa."}correctForm(){let t,r=[],n=0,i=[];for(t=0;t0&&(n>1&&i.push([t-n,t-1]),n=0)}n>1&&i.push([this.parsedAddress.length-n,this.parsedAddress.length-1]);let a=i.map(c=>c[1]-c[0]+1);if(i.length>0){let c=a.indexOf(Math.max(...a));r=b3(this.parsedAddress,i[c])}else r=this.parsedAddress;for(t=0;t1?"s":"",r.join("")),t.replace(Ot.RE_BAD_CHARACTERS,'$1'));let n=t.match(Ot.RE_BAD_ADDRESS);if(n)throw new ws.AddressError((0,rn.sprintf)("Address failed regex: %s",n.join("")),t.replace(Ot.RE_BAD_ADDRESS,'$1'));let i=[],a=t.split("::");if(a.length===2){let s=a[0].split(":"),c=a[1].split(":");s.length===1&&s[0]===""&&(s=[]),c.length===1&&c[0]===""&&(c=[]);let l=this.groups-(s.length+c.length);if(!l)throw new ws.AddressError("Error parsing groups");this.elidedGroups=l,this.elisionBegin=s.length,this.elisionEnd=s.length+this.elidedGroups,i=i.concat(s);for(let h=0;h(0,rn.sprintf)("%x",parseInt(s,16))),i.length!==this.groups)throw new ws.AddressError("Incorrect number of groups found");return i}canonicalForm(){return this.parsedAddress.map(qg).join(":")}decimal(){return this.parsedAddress.map(t=>(0,rn.sprintf)("%05d",parseInt(t,16))).join(":")}bigInteger(){return new tn.BigInteger(this.parsedAddress.map(qg).join(""),16)}to4(){let t=this.binaryZeroPad().split("");return Ga.Address4.fromHex(new tn.BigInteger(t.slice(96,128).join(""),2).toString(16))}to4in6(){let t=this.to4(),n=new e(this.parsedAddress.slice(0,6).join(":"),6).correctForm(),i="";return/:$/.test(n)||(i=":"),n+i+t.address}inspectTeredo(){let t=this.getBitsBase16(0,32),r=this.getBits(80,96).xor(new tn.BigInteger("ffff",16)).toString(),n=Ga.Address4.fromHex(this.getBitsBase16(32,64)),i=Ga.Address4.fromHex(this.getBits(96,128).xor(new tn.BigInteger("ffffffff",16)).toString(16)),a=this.getBits(64,80),s=this.getBitsBase2(64,80),c=a.testBit(15),l=a.testBit(14),h=a.testBit(8),v=a.testBit(9),E=new tn.BigInteger(s.slice(2,6)+s.slice(8,16),2).toString(10);return{prefix:(0,rn.sprintf)("%s:%s",t.slice(0,4),t.slice(4,8)),server4:n.address,client4:i.address,flags:s,coneNat:c,microsoft:{reserved:l,universalLocal:v,groupIndividual:h,nonce:E},udpPort:r}}inspect6to4(){let t=this.getBitsBase16(0,16),r=Ga.Address4.fromHex(this.getBitsBase16(16,48));return{prefix:(0,rn.sprintf)("%s",t.slice(0,4)),gateway:r.address}}to6to4(){if(!this.is4())return null;let t=["2002",this.getBitsBase16(96,112),this.getBitsBase16(112,128),"","/16"].join(":");return new e(t)}toByteArray(){let t=this.bigInteger().toByteArray();return t.length===17&&t[0]===0?t.slice(1):t}toUnsignedByteArray(){return this.toByteArray().map(Kg)}static fromByteArray(t){return this.fromUnsignedByteArray(t.map(Kg))}static fromUnsignedByteArray(t){let r=new tn.BigInteger("256",10),n=new tn.BigInteger("0",10),i=new tn.BigInteger("1",10);for(let a=t.length-1;a>=0;a--)n=n.add(i.multiply(new tn.BigInteger(t[a].toString(10),10))),i=i.multiply(r);return e.fromBigInteger(n)}isCanonical(){return this.addressMinusSuffix===this.canonicalForm()}isLinkLocal(){return this.getBitsBase2(0,64)==="1111111010000000000000000000000000000000000000000000000000000000"}isMulticast(){return this.getType()==="Multicast"}is4(){return this.v4}isTeredo(){return this.isInSubnet(new e("2001::/32"))}is6to4(){return this.isInSubnet(new e("2002::/16"))}isLoopback(){return this.getType()==="Loopback"}href(t){return t===void 0?t="":t=(0,rn.sprintf)(":%s",t),(0,rn.sprintf)("http://[%s]%s/",this.correctForm(),t)}link(t){t||(t={}),t.className===void 0&&(t.className=""),t.prefix===void 0&&(t.prefix="/#address="),t.v4===void 0&&(t.v4=!1);let r=this.correctForm;return t.v4&&(r=this.to4in6),t.className?(0,rn.sprintf)('%2$s',t.prefix,r.call(this),t.className):(0,rn.sprintf)('%2$s',t.prefix,r.call(this))}group(){if(this.elidedGroups===0)return Vp.simpleGroup(this.address).join(":");of(typeof this.elidedGroups=="number"),of(typeof this.elisionBegin=="number");let t=[],[r,n]=this.address.split("::");r.length?t.push(...Vp.simpleGroup(r)):t.push("");let i=["hover-group"];for(let a=this.elisionBegin;a',i.join(" "))),n.length?t.push(...Vp.simpleGroup(n,this.elisionEnd)):t.push(""),this.is4()&&(of(this.address4 instanceof Ga.Address4),t.pop(),t.push(this.address4.groupForV6())),t.join(":")}regularExpressionString(t=!1){let r=[],n=new e(this.correctForm());if(n.elidedGroups===0)r.push((0,za.simpleRegularExpression)(n.parsedAddress));else if(n.elidedGroups===Ot.GROUPS)r.push((0,za.possibleElisions)(Ot.GROUPS));else{let i=n.address.split("::");i[0].length&&r.push((0,za.simpleRegularExpression)(i[0].split(":"))),of(typeof n.elidedGroups=="number"),r.push((0,za.possibleElisions)(n.elidedGroups,i[0].length!==0,i[1].length!==0)),i[1].length&&r.push((0,za.simpleRegularExpression)(i[1].split(":"))),r=[r.join(":")]}return t||(r=["(?=^|",za.ADDRESS_BOUNDARY,"|[^\\w\\:])(",...r,")(?=[^\\w\\:]|",za.ADDRESS_BOUNDARY,"|$)"]),r.join("")}regularExpression(t=!1){return new RegExp(this.regularExpressionString(t),"i")}};Ti.Address6=Gp});var Gg=Ce(Hr=>{"use strict";var C3=Hr&&Hr.__createBinding||(Object.create?function(e,t,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(t,r);(!i||("get"in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,n,i)}:function(e,t,r,n){n===void 0&&(n=r),e[n]=t[r]}),F3=Hr&&Hr.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),_3=Hr&&Hr.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)r!=="default"&&Object.prototype.hasOwnProperty.call(e,r)&&C3(t,e,r);return F3(t,e),t};Object.defineProperty(Hr,"__esModule",{value:!0});Hr.v6=Hr.AddressError=Hr.Address6=Hr.Address4=void 0;var I3=jp();Object.defineProperty(Hr,"Address4",{enumerable:!0,get:function(){return I3.Address4}});var D3=Vg();Object.defineProperty(Hr,"Address6",{enumerable:!0,get:function(){return D3.Address6}});var B3=rf();Object.defineProperty(Hr,"AddressError",{enumerable:!0,get:function(){return B3.AddressError}});var P3=_3(qp());Hr.v6={helpers:P3}});var Qa=Ce((HR,Za)=>{"use strict";function Zg(e){return typeof e>"u"||e===null}function Bb(e){return typeof e=="object"&&e!==null}function Pb(e){return Array.isArray(e)?e:Zg(e)?[]:[e]}function $b(e,t){var r,n,i,a;if(t)for(a=Object.keys(t),r=0,n=a.length;r{"use strict";function Dc(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=(this.reason||"(unknown reason)")+(this.mark?" "+this.mark.toString():""),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Dc.prototype=Object.create(Error.prototype);Dc.prototype.constructor=Dc;Dc.prototype.toString=function(t){var r=this.name+": ";return r+=this.reason||"(unknown reason)",!t&&this.mark&&(r+=" "+this.mark.toString()),r};Qg.exports=Dc});var rm=Ce((MR,tm)=>{"use strict";var em=Qa();function nd(e,t,r,n,i){this.name=e,this.buffer=t,this.position=r,this.line=n,this.column=i}nd.prototype.getSnippet=function(t,r){var n,i,a,s,c;if(!this.buffer)return null;for(t=t||4,r=r||75,n="",i=this.position;i>0&&`\0\r \x85\u2028\u2029`.indexOf(this.buffer.charAt(i-1))===-1;)if(i-=1,this.position-i>r/2-1){n=" ... ",i+=5;break}for(a="",s=this.position;sr/2-1){a=" ... ",s-=5;break}return c=this.buffer.slice(i,s),em.repeat(" ",t)+n+c+a+` `+em.repeat(" ",t+this.position-i+n.length)+"^"};nd.prototype.toString=function(t){var r,n="";return this.name&&(n+='in "'+this.name+'" '),n+="at line "+(this.line+1)+", column "+(this.column+1),t||(r=this.getSnippet(),r&&(n+=`: `+r)),n};tm.exports=nd});var pr=Ce((qR,im)=>{"use strict";var nm=no(),xb=["kind","resolve","construct","instanceOf","predicate","represent","defaultStyle","styleAliases"],Ob=["scalar","sequence","mapping"];function Nb(e){var t={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(n){t[String(n)]=r})}),t}function kb(e,t){if(t=t||{},Object.keys(t).forEach(function(r){if(xb.indexOf(r)===-1)throw new nm('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(r){return r},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.defaultStyle=t.defaultStyle||null,this.styleAliases=Nb(t.styleAliases||null),Ob.indexOf(this.kind)===-1)throw new nm('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}im.exports=kb});var eu=Ce((KR,am)=>{"use strict";var sm=Qa(),wf=no(),Lb=pr();function sd(e,t,r){var n=[];return e.include.forEach(function(i){r=sd(i,t,r)}),e[t].forEach(function(i){r.forEach(function(a,s){a.tag===i.tag&&a.kind===i.kind&&n.push(s)}),r.push(i)}),r.filter(function(i,a){return n.indexOf(a)===-1})}function Ub(){var e={scalar:{},sequence:{},mapping:{},fallback:{}},t,r;function n(i){e[i.kind][i.tag]=e.fallback[i.tag]=i}for(t=0,r=arguments.length;t{"use strict";var Hb=pr();um.exports=new Hb("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}})});var lm=Ce((GR,cm)=>{"use strict";var jb=pr();cm.exports=new jb("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}})});var hm=Ce((zR,fm)=>{"use strict";var Mb=pr();fm.exports=new Mb("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}})});var Af=Ce((YR,pm)=>{"use strict";var qb=eu();pm.exports=new qb({explicit:[om(),lm(),hm()]})});var gm=Ce((WR,dm)=>{"use strict";var Kb=pr();function Vb(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function Gb(){return null}function zb(e){return e===null}dm.exports=new Kb("tag:yaml.org,2002:null",{kind:"scalar",resolve:Vb,construct:Gb,predicate:zb,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"}},defaultStyle:"lowercase"})});var vm=Ce((XR,mm)=>{"use strict";var Yb=pr();function Wb(e){if(e===null)return!1;var t=e.length;return t===4&&(e==="true"||e==="True"||e==="TRUE")||t===5&&(e==="false"||e==="False"||e==="FALSE")}function Xb(e){return e==="true"||e==="True"||e==="TRUE"}function Jb(e){return Object.prototype.toString.call(e)==="[object Boolean]"}mm.exports=new Yb("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Wb,construct:Xb,predicate:Jb,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"})});var Am=Ce((JR,wm)=>{"use strict";var Zb=Qa(),Qb=pr();function eC(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function tC(e){return 48<=e&&e<=55}function rC(e){return 48<=e&&e<=57}function nC(e){if(e===null)return!1;var t=e.length,r=0,n=!1,i;if(!t)return!1;if(i=e[r],(i==="-"||i==="+")&&(i=e[++r]),i==="0"){if(r+1===t)return!0;if(i=e[++r],i==="b"){for(r++;r=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0"+e.toString(8):"-0"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}})});var Sm=Ce((ZR,ym)=>{"use strict";var Em=Qa(),aC=pr(),uC=new RegExp("^(?:[-+]?(?:0|[1-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\\.[0-9_]*|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function oC(e){return!(e===null||!uC.test(e)||e[e.length-1]==="_")}function cC(e){var t,r,n,i;return t=e.replace(/_/g,"").toLowerCase(),r=t[0]==="-"?-1:1,i=[],"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:t.indexOf(":")>=0?(t.split(":").forEach(function(a){i.unshift(parseFloat(a,10))}),t=0,n=1,i.forEach(function(a){t+=a*n,n*=60}),r*t):r*parseFloat(t,10)}var lC=/^[-+]?[0-9]+e/;function fC(e,t){var r;if(isNaN(e))switch(t){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(t){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(t){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(Em.isNegativeZero(e))return"-0.0";return r=e.toString(10),lC.test(r)?r.replace("e",".e"):r}function hC(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Em.isNegativeZero(e))}ym.exports=new aC("tag:yaml.org,2002:float",{kind:"scalar",resolve:oC,construct:cC,predicate:hC,represent:fC,defaultStyle:"lowercase"})});var ad=Ce((QR,bm)=>{"use strict";var pC=eu();bm.exports=new pC({include:[Af()],implicit:[gm(),vm(),Am(),Sm()]})});var ud=Ce((eT,Cm)=>{"use strict";var dC=eu();Cm.exports=new dC({include:[ad()]})});var Dm=Ce((tT,Im)=>{"use strict";var gC=pr(),Fm=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),_m=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function mC(e){return e===null?!1:Fm.exec(e)!==null||_m.exec(e)!==null}function vC(e){var t,r,n,i,a,s,c,l=0,h=null,v,E,p;if(t=Fm.exec(e),t===null&&(t=_m.exec(e)),t===null)throw new Error("Date resolve error");if(r=+t[1],n=+t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(r,n,i));if(a=+t[4],s=+t[5],c=+t[6],t[7]){for(l=t[7].slice(0,3);l.length<3;)l+="0";l=+l}return t[9]&&(v=+t[10],E=+(t[11]||0),h=(v*60+E)*6e4,t[9]==="-"&&(h=-h)),p=new Date(Date.UTC(r,n,i,a,s,c,l)),h&&p.setTime(p.getTime()-h),p}function wC(e){return e.toISOString()}Im.exports=new gC("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:mC,construct:vC,instanceOf:Date,represent:wC})});var Pm=Ce((rT,Bm)=>{"use strict";var AC=pr();function EC(e){return e==="<<"||e===null}Bm.exports=new AC("tag:yaml.org,2002:merge",{kind:"scalar",resolve:EC})});var Tm=Ce((nT,Rm)=>{"use strict";var tu;try{$m=ja,tu=$m("buffer").Buffer}catch{}var $m,yC=pr(),od=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/= \r`;function SC(e){if(e===null)return!1;var t,r,n=0,i=e.length,a=od;for(r=0;r64)){if(t<0)return!1;n+=6}return n%8===0}function bC(e){var t,r,n=e.replace(/[\r\n=]/g,""),i=n.length,a=od,s=0,c=[];for(t=0;t>16&255),c.push(s>>8&255),c.push(s&255)),s=s<<6|a.indexOf(n.charAt(t));return r=i%4*6,r===0?(c.push(s>>16&255),c.push(s>>8&255),c.push(s&255)):r===18?(c.push(s>>10&255),c.push(s>>2&255)):r===12&&c.push(s>>4&255),tu?tu.from?tu.from(c):new tu(c):c}function CC(e){var t="",r=0,n,i,a=e.length,s=od;for(n=0;n>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]),r=(r<<8)+e[n];return i=a%3,i===0?(t+=s[r>>18&63],t+=s[r>>12&63],t+=s[r>>6&63],t+=s[r&63]):i===2?(t+=s[r>>10&63],t+=s[r>>4&63],t+=s[r<<2&63],t+=s[64]):i===1&&(t+=s[r>>2&63],t+=s[r<<4&63],t+=s[64],t+=s[64]),t}function FC(e){return tu&&tu.isBuffer(e)}Rm.exports=new yC("tag:yaml.org,2002:binary",{kind:"scalar",resolve:SC,construct:bC,predicate:FC,represent:CC})});var Om=Ce((sT,xm)=>{"use strict";var _C=pr(),IC=Object.prototype.hasOwnProperty,DC=Object.prototype.toString;function BC(e){if(e===null)return!0;var t=[],r,n,i,a,s,c=e;for(r=0,n=c.length;r{"use strict";var $C=pr(),RC=Object.prototype.toString;function TC(e){if(e===null)return!0;var t,r,n,i,a,s=e;for(a=new Array(s.length),t=0,r=s.length;t{"use strict";var OC=pr(),NC=Object.prototype.hasOwnProperty;function kC(e){if(e===null)return!0;var t,r=e;for(t in r)if(NC.call(r,t)&&r[t]!==null)return!1;return!0}function LC(e){return e!==null?e:{}}Lm.exports=new OC("tag:yaml.org,2002:set",{kind:"mapping",resolve:kC,construct:LC})});var so=Ce((oT,Hm)=>{"use strict";var UC=eu();Hm.exports=new UC({include:[ud()],implicit:[Dm(),Pm()],explicit:[Tm(),Om(),km(),Um()]})});var Mm=Ce((cT,jm)=>{"use strict";var HC=pr();function jC(){return!0}function MC(){}function qC(){return""}function KC(e){return typeof e>"u"}jm.exports=new HC("tag:yaml.org,2002:js/undefined",{kind:"scalar",resolve:jC,construct:MC,predicate:KC,represent:qC})});var Km=Ce((lT,qm)=>{"use strict";var VC=pr();function GC(e){if(e===null||e.length===0)return!1;var t=e,r=/\/([gim]*)$/.exec(e),n="";return!(t[0]==="/"&&(r&&(n=r[1]),n.length>3||t[t.length-n.length-1]!=="/"))}function zC(e){var t=e,r=/\/([gim]*)$/.exec(e),n="";return t[0]==="/"&&(r&&(n=r[1]),t=t.slice(1,t.length-n.length-1)),new RegExp(t,n)}function YC(e){var t="/"+e.source+"/";return e.global&&(t+="g"),e.multiline&&(t+="m"),e.ignoreCase&&(t+="i"),t}function WC(e){return Object.prototype.toString.call(e)==="[object RegExp]"}qm.exports=new VC("tag:yaml.org,2002:js/regexp",{kind:"scalar",resolve:GC,construct:zC,predicate:WC,represent:YC})});var zm=Ce((fT,Gm)=>{"use strict";var Ef;try{Vm=ja,Ef=Vm("esprima")}catch{typeof window<"u"&&(Ef=window.esprima)}var Vm,XC=pr();function JC(e){if(e===null)return!1;try{var t="("+e+")",r=Ef.parse(t,{range:!0});return!(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")}catch{return!1}}function ZC(e){var t="("+e+")",r=Ef.parse(t,{range:!0}),n=[],i;if(r.type!=="Program"||r.body.length!==1||r.body[0].type!=="ExpressionStatement"||r.body[0].expression.type!=="ArrowFunctionExpression"&&r.body[0].expression.type!=="FunctionExpression")throw new Error("Failed to resolve function");return r.body[0].expression.params.forEach(function(a){n.push(a.name)}),i=r.body[0].expression.body.range,r.body[0].expression.body.type==="BlockStatement"?new Function(n,t.slice(i[0]+1,i[1]-1)):new Function(n,"return "+t.slice(i[0],i[1]))}function QC(e){return e.toString()}function eF(e){return Object.prototype.toString.call(e)==="[object Function]"}Gm.exports=new XC("tag:yaml.org,2002:js/function",{kind:"scalar",resolve:JC,construct:ZC,predicate:eF,represent:QC})});var Bc=Ce((pT,Wm)=>{"use strict";var Ym=eu();Wm.exports=Ym.DEFAULT=new Ym({include:[so()],explicit:[Mm(),Km(),zm()]})});var dv=Ce((dT,Pc)=>{"use strict";var Es=Qa(),rv=no(),tF=rm(),nv=so(),rF=Bc(),ia=Object.prototype.hasOwnProperty,yf=1,iv=2,sv=3,Sf=4,cd=1,nF=2,Xm=3,iF=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,sF=/[\x85\u2028\u2029]/,aF=/[,\[\]\{\}]/,av=/^(?:!|!!|![a-z\-]+!)$/i,uv=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Jm(e){return Object.prototype.toString.call(e)}function ki(e){return e===10||e===13}function nu(e){return e===9||e===32}function mn(e){return e===9||e===32||e===10||e===13}function ao(e){return e===44||e===91||e===93||e===123||e===125}function uF(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function oF(e){return e===120?2:e===117?4:e===85?8:0}function cF(e){return 48<=e&&e<=57?e-48:-1}function Zm(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?` `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function lF(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}var ov=new Array(256),cv=new Array(256);for(ru=0;ru<256;ru++)ov[ru]=Zm(ru)?1:0,cv[ru]=Zm(ru);var ru;function fF(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||rF,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.documents=[]}function lv(e,t){return new rv(t,new tF(e.filename,e.input,e.position,e.line,e.position-e.lineStart))}function Me(e,t){throw lv(e,t)}function bf(e,t){e.onWarning&&e.onWarning.call(null,lv(e,t))}var Qm={YAML:function(t,r,n){var i,a,s;t.version!==null&&Me(t,"duplication of %YAML directive"),n.length!==1&&Me(t,"YAML directive accepts exactly one argument"),i=/^([0-9]+)\.([0-9]+)$/.exec(n[0]),i===null&&Me(t,"ill-formed argument of the YAML directive"),a=parseInt(i[1],10),s=parseInt(i[2],10),a!==1&&Me(t,"unacceptable YAML version of the document"),t.version=n[0],t.checkLineBreaks=s<2,s!==1&&s!==2&&bf(t,"unsupported YAML version of the document")},TAG:function(t,r,n){var i,a;n.length!==2&&Me(t,"TAG directive accepts exactly two arguments"),i=n[0],a=n[1],av.test(i)||Me(t,"ill-formed tag handle (first argument) of the TAG directive"),ia.call(t.tagMap,i)&&Me(t,'there is a previously declared suffix for "'+i+'" tag handle'),uv.test(a)||Me(t,"ill-formed tag prefix (second argument) of the TAG directive"),t.tagMap[i]=a}};function na(e,t,r,n){var i,a,s,c;if(t1&&(e.result+=Es.repeat(` `,t-1))}function hF(e,t,r){var n,i,a,s,c,l,h,v,E=e.kind,p=e.result,f;if(f=e.input.charCodeAt(e.position),mn(f)||ao(f)||f===35||f===38||f===42||f===33||f===124||f===62||f===39||f===34||f===37||f===64||f===96||(f===63||f===45)&&(i=e.input.charCodeAt(e.position+1),mn(i)||r&&ao(i)))return!1;for(e.kind="scalar",e.result="",a=s=e.position,c=!1;f!==0;){if(f===58){if(i=e.input.charCodeAt(e.position+1),mn(i)||r&&ao(i))break}else if(f===35){if(n=e.input.charCodeAt(e.position-1),mn(n))break}else{if(e.position===e.lineStart&&Cf(e)||r&&ao(f))break;if(ki(f))if(l=e.line,h=e.lineStart,v=e.lineIndent,ur(e,!1,-1),e.lineIndent>=t){c=!0,f=e.input.charCodeAt(e.position);continue}else{e.position=s,e.line=l,e.lineStart=h,e.lineIndent=v;break}}c&&(na(e,a,s,!1),fd(e,e.line-l),a=s=e.position,c=!1),nu(f)||(s=e.position+1),f=e.input.charCodeAt(++e.position)}return na(e,a,s,!1),e.result?!0:(e.kind=E,e.result=p,!1)}function pF(e,t){var r,n,i;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,n=i=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(na(e,n,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)n=e.position,e.position++,i=e.position;else return!0;else ki(r)?(na(e,n,i,!0),fd(e,ur(e,!1,t)),n=i=e.position):e.position===e.lineStart&&Cf(e)?Me(e,"unexpected end of the document within a single quoted scalar"):(e.position++,i=e.position);Me(e,"unexpected end of the stream within a single quoted scalar")}function dF(e,t){var r,n,i,a,s,c;if(c=e.input.charCodeAt(e.position),c!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=n=e.position;(c=e.input.charCodeAt(e.position))!==0;){if(c===34)return na(e,r,e.position,!0),e.position++,!0;if(c===92){if(na(e,r,e.position,!0),c=e.input.charCodeAt(++e.position),ki(c))ur(e,!1,t);else if(c<256&&ov[c])e.result+=cv[c],e.position++;else if((s=oF(c))>0){for(i=s,a=0;i>0;i--)c=e.input.charCodeAt(++e.position),(s=uF(c))>=0?a=(a<<4)+s:Me(e,"expected hexadecimal character");e.result+=lF(a),e.position++}else Me(e,"unknown escape sequence");r=n=e.position}else ki(c)?(na(e,r,n,!0),fd(e,ur(e,!1,t)),r=n=e.position):e.position===e.lineStart&&Cf(e)?Me(e,"unexpected end of the document within a double quoted scalar"):(e.position++,n=e.position)}Me(e,"unexpected end of the stream within a double quoted scalar")}function gF(e,t){var r=!0,n,i=e.tag,a,s=e.anchor,c,l,h,v,E,p={},f,A,g,y;if(y=e.input.charCodeAt(e.position),y===91)l=93,E=!1,a=[];else if(y===123)l=125,E=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),y=e.input.charCodeAt(++e.position);y!==0;){if(ur(e,!0,t),y=e.input.charCodeAt(e.position),y===l)return e.position++,e.tag=i,e.anchor=s,e.kind=E?"mapping":"sequence",e.result=a,!0;r||Me(e,"missed comma between flow collection entries"),A=f=g=null,h=v=!1,y===63&&(c=e.input.charCodeAt(e.position+1),mn(c)&&(h=v=!0,e.position++,ur(e,!0,t))),n=e.line,oo(e,t,yf,!1,!0),A=e.tag,f=e.result,ur(e,!0,t),y=e.input.charCodeAt(e.position),(v||e.line===n)&&y===58&&(h=!0,y=e.input.charCodeAt(++e.position),ur(e,!0,t),oo(e,t,yf,!1,!0),g=e.result),E?uo(e,a,p,A,f,g):h?a.push(uo(e,null,p,A,f,g)):a.push(f),ur(e,!0,t),y=e.input.charCodeAt(e.position),y===44?(r=!0,y=e.input.charCodeAt(++e.position)):r=!1}Me(e,"unexpected end of the stream within a flow collection")}function mF(e,t){var r,n,i=cd,a=!1,s=!1,c=t,l=0,h=!1,v,E;if(E=e.input.charCodeAt(e.position),E===124)n=!1;else if(E===62)n=!0;else return!1;for(e.kind="scalar",e.result="";E!==0;)if(E=e.input.charCodeAt(++e.position),E===43||E===45)cd===i?i=E===43?Xm:nF:Me(e,"repeat of a chomping mode identifier");else if((v=cF(E))>=0)v===0?Me(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):s?Me(e,"repeat of an indentation width identifier"):(c=t+v-1,s=!0);else break;if(nu(E)){do E=e.input.charCodeAt(++e.position);while(nu(E));if(E===35)do E=e.input.charCodeAt(++e.position);while(!ki(E)&&E!==0)}for(;E!==0;){for(ld(e),e.lineIndent=0,E=e.input.charCodeAt(e.position);(!s||e.lineIndentc&&(c=e.lineIndent),ki(E)){l++;continue}if(e.lineIndentt)&&l!==0)Me(e,"bad indentation of a sequence entry");else if(e.lineIndentt)&&(oo(e,t,Sf,!0,i)&&(A?p=e.result:f=e.result),A||(uo(e,h,v,E,p,f,a,s),E=p=f=null),ur(e,!0,-1),y=e.input.charCodeAt(e.position)),e.lineIndent>t&&y!==0)Me(e,"bad indentation of a mapping entry");else if(e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndentt?l=1:e.lineIndent===t?l=0:e.lineIndent tag; it should be "scalar", not "'+e.kind+'"'),E=0,p=e.implicitTypes.length;E tag; it should be "'+f.kind+'", not "'+e.kind+'"'),f.resolve(e.result)?(e.result=f.construct(e.result),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):Me(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")):Me(e,"unknown tag !<"+e.tag+">");return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||v}function yF(e){var t=e.position,r,n,i,a=!1,s;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap={},e.anchorMap={};(s=e.input.charCodeAt(e.position))!==0&&(ur(e,!0,-1),s=e.input.charCodeAt(e.position),!(e.lineIndent>0||s!==37));){for(a=!0,s=e.input.charCodeAt(++e.position),r=e.position;s!==0&&!mn(s);)s=e.input.charCodeAt(++e.position);for(n=e.input.slice(r,e.position),i=[],n.length<1&&Me(e,"directive name must not be less than one character in length");s!==0;){for(;nu(s);)s=e.input.charCodeAt(++e.position);if(s===35){do s=e.input.charCodeAt(++e.position);while(s!==0&&!ki(s));break}if(ki(s))break;for(r=e.position;s!==0&&!mn(s);)s=e.input.charCodeAt(++e.position);i.push(e.input.slice(r,e.position))}s!==0&&ld(e),ia.call(Qm,n)?Qm[n](e,n,i):bf(e,'unknown document directive "'+n+'"')}if(ur(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,ur(e,!0,-1)):a&&Me(e,"directives end mark is expected"),oo(e,e.lineIndent-1,Sf,!1,!0),ur(e,!0,-1),e.checkLineBreaks&&sF.test(e.input.slice(t,e.position))&&bf(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&Cf(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,ur(e,!0,-1));return}if(e.position"u"&&(r=t,t=null);var n=fv(e,r);if(typeof t!="function")return n;for(var i=0,a=n.length;i"u"&&(r=t,t=null),hv(e,t,Es.extend({schema:nv},r))}function bF(e,t){return pv(e,Es.extend({schema:nv},t))}Pc.exports.loadAll=hv;Pc.exports.load=pv;Pc.exports.safeLoadAll=SF;Pc.exports.safeLoad=bF});var kv=Ce((gT,gd)=>{"use strict";var Rc=Qa(),Tc=no(),CF=Bc(),FF=so(),Sv=Object.prototype.toString,bv=Object.prototype.hasOwnProperty,_F=9,$c=10,IF=13,DF=32,BF=33,PF=34,Cv=35,$F=37,RF=38,TF=39,xF=42,Fv=44,OF=45,_v=58,NF=61,kF=62,LF=63,UF=64,Iv=91,Dv=93,HF=96,Bv=123,jF=124,Pv=125,Vr={};Vr[0]="\\0";Vr[7]="\\a";Vr[8]="\\b";Vr[9]="\\t";Vr[10]="\\n";Vr[11]="\\v";Vr[12]="\\f";Vr[13]="\\r";Vr[27]="\\e";Vr[34]='\\"';Vr[92]="\\\\";Vr[133]="\\N";Vr[160]="\\_";Vr[8232]="\\L";Vr[8233]="\\P";var MF=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"];function qF(e,t){var r,n,i,a,s,c,l;if(t===null)return{};for(r={},n=Object.keys(t),i=0,a=n.length;i0?e.charCodeAt(a-1):null,p=p&&vv(s,c)}else{for(a=0;an&&e[E+1]!==" ",E=a);else if(!co(s))return Ff;c=a>0?e.charCodeAt(a-1):null,p=p&&vv(s,c)}h=h||v&&a-E-1>n&&e[E+1]!==" "}return!l&&!h?p&&!i(e)?Rv:Tv:r>9&&$v(e)?Ff:h?Ov:xv}function WF(e,t,r,n){e.dump=function(){if(t.length===0)return"''";if(!e.noCompatMode&&MF.indexOf(t)!==-1)return"'"+t+"'";var i=e.indent*Math.max(1,r),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),s=n||e.flowLevel>-1&&r>=e.flowLevel;function c(l){return VF(e,l)}switch(YF(t,s,e.indent,a,c)){case Rv:return t;case Tv:return"'"+t.replace(/'/g,"''")+"'";case xv:return"|"+wv(t,e.indent)+Av(mv(t,i));case Ov:return">"+wv(t,e.indent)+Av(mv(XF(t,a),i));case Ff:return'"'+JF(t,a)+'"';default:throw new Tc("impossible error: invalid scalar style")}}()}function wv(e,t){var r=$v(e)?String(t):"",n=e[e.length-1]===` `,i=n&&(e[e.length-2]===` `||e===` `),a=i?"+":n?"":"-";return r+a+` `}function Av(e){return e[e.length-1]===` `?e.slice(0,-1):e}function XF(e,t){for(var r=/(\n+)([^\n]*)/g,n=function(){var h=e.indexOf(` `);return h=h!==-1?h:e.length,r.lastIndex=h,Ev(e.slice(0,h),t)}(),i=e[0]===` `||e[0]===" ",a,s;s=r.exec(e);){var c=s[1],l=s[2];a=l[0]===" ",n+=c+(!i&&!a&&l!==""?` `:"")+Ev(l,t),i=a}return n}function Ev(e,t){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,n,i=0,a,s=0,c=0,l="";n=r.exec(e);)c=n.index,c-i>t&&(a=s>i?s:c,l+=` `+e.slice(i,a),i=a+1),s=c;return l+=` `,e.length-i>t&&s>i?l+=e.slice(i,s)+` `+e.slice(s+1):l+=e.slice(i),l.slice(1)}function JF(e){for(var t="",r,n,i,a=0;a=55296&&r<=56319&&(n=e.charCodeAt(a+1),n>=56320&&n<=57343)){t+=gv((r-55296)*1024+n-56320+65536),a++;continue}i=Vr[r],t+=!i&&co(r)?e[a]:i||gv(r)}return t}function ZF(e,t,r){var n="",i=e.tag,a,s;for(a=0,s=r.length;a1024&&(v+="? "),v+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),iu(e,t,h,!1,!1)&&(v+=e.dump,n+=v));e.tag=i,e.dump="{"+n+"}"}function t_(e,t,r,n){var i="",a=e.tag,s=Object.keys(r),c,l,h,v,E,p;if(e.sortKeys===!0)s.sort();else if(typeof e.sortKeys=="function")s.sort(e.sortKeys);else if(e.sortKeys)throw new Tc("sortKeys must be a boolean or a function");for(c=0,l=s.length;c1024,E&&(e.dump&&$c===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,E&&(p+=hd(e,t)),iu(e,t+1,v,!0,E)&&(e.dump&&$c===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,i+=p));e.tag=a,e.dump=i||"{}"}function yv(e,t,r){var n,i,a,s,c,l;for(i=r?e.explicitTypes:e.implicitTypes,a=0,s=i.length;a tag resolver accepts not "'+l+'" style');e.dump=n}return!0}return!1}function iu(e,t,r,n,i,a){e.tag=null,e.dump=r,yv(e,r,!1)||yv(e,r,!0);var s=Sv.call(e.dump);n&&(n=e.flowLevel<0||e.flowLevel>t);var c=s==="[object Object]"||s==="[object Array]",l,h;if(c&&(l=e.duplicates.indexOf(r),h=l!==-1),(e.tag!==null&&e.tag!=="?"||h||e.indent!==2&&t>0)&&(i=!1),h&&e.usedDuplicates[l])e.dump="*ref_"+l;else{if(c&&h&&!e.usedDuplicates[l]&&(e.usedDuplicates[l]=!0),s==="[object Object]")n&&Object.keys(e.dump).length!==0?(t_(e,t,e.dump,i),h&&(e.dump="&ref_"+l+e.dump)):(e_(e,t,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump));else if(s==="[object Array]"){var v=e.noArrayIndent&&t>0?t-1:t;n&&e.dump.length!==0?(QF(e,v,e.dump,i),h&&(e.dump="&ref_"+l+e.dump)):(ZF(e,v,e.dump),h&&(e.dump="&ref_"+l+" "+e.dump))}else if(s==="[object String]")e.tag!=="?"&&WF(e,e.dump,t,a);else{if(e.skipInvalid)return!1;throw new Tc("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(e.dump="!<"+e.tag+"> "+e.dump)}return!0}function r_(e,t){var r=[],n=[],i,a;for(pd(e,r,n),i=0,a=n.length;i{"use strict";var _f=dv(),Lv=kv();function If(e){return function(){throw new Error("Function "+e+" is deprecated and cannot be used.")}}Jt.exports.Type=pr();Jt.exports.Schema=eu();Jt.exports.FAILSAFE_SCHEMA=Af();Jt.exports.JSON_SCHEMA=ad();Jt.exports.CORE_SCHEMA=ud();Jt.exports.DEFAULT_SAFE_SCHEMA=so();Jt.exports.DEFAULT_FULL_SCHEMA=Bc();Jt.exports.load=_f.load;Jt.exports.loadAll=_f.loadAll;Jt.exports.safeLoad=_f.safeLoad;Jt.exports.safeLoadAll=_f.safeLoadAll;Jt.exports.dump=Lv.dump;Jt.exports.safeDump=Lv.safeDump;Jt.exports.YAMLException=no();Jt.exports.MINIMAL_SCHEMA=Af();Jt.exports.SAFE_SCHEMA=so();Jt.exports.DEFAULT_SCHEMA=Bc();Jt.exports.scan=If("scan");Jt.exports.parse=If("parse");Jt.exports.compose=If("compose");Jt.exports.addConstructor=If("addConstructor")});var jv=Ce((vT,Hv)=>{"use strict";var i_=Uv();Hv.exports=i_});var qv=Ce((wT,Mv)=>{"use strict";var Df=jv();Mv.exports={safeLoad:Df.safeLoad,load:Df.load,safeDump:Df.safeDump,dump:Df.dump}});var p2=Ce(Tf=>{"use strict";Tf.byteLength=b_;Tf.toByteArray=F_;Tf.fromByteArray=D_;var Li=[],ii=[],S_=typeof Uint8Array<"u"?Uint8Array:Array,yd="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(au=0,f2=yd.length;au0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var n=r===t?0:4-r%4;return[r,n]}function b_(e){var t=h2(e),r=t[0],n=t[1];return(r+n)*3/4-n}function C_(e,t,r){return(t+r)*3/4-r}function F_(e){var t,r=h2(e),n=r[0],i=r[1],a=new S_(C_(e,n,i)),s=0,c=i>0?n-4:n,l;for(l=0;l>16&255,a[s++]=t>>8&255,a[s++]=t&255;return i===2&&(t=ii[e.charCodeAt(l)]<<2|ii[e.charCodeAt(l+1)]>>4,a[s++]=t&255),i===1&&(t=ii[e.charCodeAt(l)]<<10|ii[e.charCodeAt(l+1)]<<4|ii[e.charCodeAt(l+2)]>>2,a[s++]=t>>8&255,a[s++]=t&255),a}function __(e){return Li[e>>18&63]+Li[e>>12&63]+Li[e>>6&63]+Li[e&63]}function I_(e,t,r){for(var n,i=[],a=t;ac?c:s+a));return n===1?(t=e[r-1],i.push(Li[t>>2]+Li[t<<4&63]+"==")):n===2&&(t=(e[r-2]<<8)+e[r-1],i.push(Li[t>>10]+Li[t>>4&63]+Li[t<<2&63]+"=")),i.join("")}});var d2=Ce(Sd=>{Sd.read=function(e,t,r,n,i){var a,s,c=i*8-n-1,l=(1<>1,v=-7,E=r?i-1:0,p=r?-1:1,f=e[t+E];for(E+=p,a=f&(1<<-v)-1,f>>=-v,v+=c;v>0;a=a*256+e[t+E],E+=p,v-=8);for(s=a&(1<<-v)-1,a>>=-v,v+=n;v>0;s=s*256+e[t+E],E+=p,v-=8);if(a===0)a=1-h;else{if(a===l)return s?NaN:(f?-1:1)*(1/0);s=s+Math.pow(2,n),a=a-h}return(f?-1:1)*s*Math.pow(2,a-n)};Sd.write=function(e,t,r,n,i,a){var s,c,l,h=a*8-i-1,v=(1<>1,p=i===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=n?0:a-1,A=n?1:-1,g=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(c=isNaN(t)?1:0,s=v):(s=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-s))<1&&(s--,l*=2),s+E>=1?t+=p/l:t+=p*Math.pow(2,1-E),t*l>=2&&(s++,l/=2),s+E>=v?(c=0,s=v):s+E>=1?(c=(t*l-1)*Math.pow(2,i),s=s+E):(c=t*Math.pow(2,E-1)*Math.pow(2,i),s=0));i>=8;e[r+f]=c&255,f+=A,c/=256,i-=8);for(s=s<0;e[r+f]=s&255,f+=A,s/=256,h-=8);e[r+f-A]|=g*128}});var Nf=Ce(mo=>{"use strict";var bd=p2(),po=d2(),g2=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;mo.Buffer=fe;mo.SlowBuffer=x_;mo.INSPECT_MAX_BYTES=50;var xf=2147483647;mo.kMaxLength=xf;fe.TYPED_ARRAY_SUPPORT=B_();!fe.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function B_(){try{let e=new Uint8Array(1),t={foo:function(){return 42}};return Object.setPrototypeOf(t,Uint8Array.prototype),Object.setPrototypeOf(e,t),e.foo()===42}catch{return!1}}Object.defineProperty(fe.prototype,"parent",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.buffer}});Object.defineProperty(fe.prototype,"offset",{enumerable:!0,get:function(){if(fe.isBuffer(this))return this.byteOffset}});function ys(e){if(e>xf)throw new RangeError('The value "'+e+'" is invalid for option "size"');let t=new Uint8Array(e);return Object.setPrototypeOf(t,fe.prototype),t}function fe(e,t,r){if(typeof e=="number"){if(typeof t=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return Id(e)}return A2(e,t,r)}fe.poolSize=8192;function A2(e,t,r){if(typeof e=="string")return $_(e,t);if(ArrayBuffer.isView(e))return R_(e);if(e==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);if(Ui(e,ArrayBuffer)||e&&Ui(e.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ui(e,SharedArrayBuffer)||e&&Ui(e.buffer,SharedArrayBuffer)))return Fd(e,t,r);if(typeof e=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');let n=e.valueOf&&e.valueOf();if(n!=null&&n!==e)return fe.from(n,t,r);let i=T_(e);if(i)return i;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof e[Symbol.toPrimitive]=="function")return fe.from(e[Symbol.toPrimitive]("string"),t,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e)}fe.from=function(e,t,r){return A2(e,t,r)};Object.setPrototypeOf(fe.prototype,Uint8Array.prototype);Object.setPrototypeOf(fe,Uint8Array);function E2(e){if(typeof e!="number")throw new TypeError('"size" argument must be of type number');if(e<0)throw new RangeError('The value "'+e+'" is invalid for option "size"')}function P_(e,t,r){return E2(e),e<=0?ys(e):t!==void 0?typeof r=="string"?ys(e).fill(t,r):ys(e).fill(t):ys(e)}fe.alloc=function(e,t,r){return P_(e,t,r)};function Id(e){return E2(e),ys(e<0?0:Dd(e)|0)}fe.allocUnsafe=function(e){return Id(e)};fe.allocUnsafeSlow=function(e){return Id(e)};function $_(e,t){if((typeof t!="string"||t==="")&&(t="utf8"),!fe.isEncoding(t))throw new TypeError("Unknown encoding: "+t);let r=y2(e,t)|0,n=ys(r),i=n.write(e,t);return i!==r&&(n=n.slice(0,i)),n}function Cd(e){let t=e.length<0?0:Dd(e.length)|0,r=ys(t);for(let n=0;n=xf)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+xf.toString(16)+" bytes");return e|0}function x_(e){return+e!=e&&(e=0),fe.alloc(+e)}fe.isBuffer=function(t){return t!=null&&t._isBuffer===!0&&t!==fe.prototype};fe.compare=function(t,r){if(Ui(t,Uint8Array)&&(t=fe.from(t,t.offset,t.byteLength)),Ui(r,Uint8Array)&&(r=fe.from(r,r.offset,r.byteLength)),!fe.isBuffer(t)||!fe.isBuffer(r))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===r)return 0;let n=t.length,i=r.length;for(let a=0,s=Math.min(n,i);ai.length?(fe.isBuffer(s)||(s=fe.from(s)),s.copy(i,a)):Uint8Array.prototype.set.call(i,s,a);else if(fe.isBuffer(s))s.copy(i,a);else throw new TypeError('"list" argument must be an Array of Buffers');a+=s.length}return i};function y2(e,t){if(fe.isBuffer(e))return e.length;if(ArrayBuffer.isView(e)||Ui(e,ArrayBuffer))return e.byteLength;if(typeof e!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof e);let r=e.length,n=arguments.length>2&&arguments[2]===!0;if(!n&&r===0)return 0;let i=!1;for(;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return _d(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return r*2;case"hex":return r>>>1;case"base64":return P2(e).length;default:if(i)return n?-1:_d(e).length;t=(""+t).toLowerCase(),i=!0}}fe.byteLength=y2;function O_(e,t,r){let n=!1;if((t===void 0||t<0)&&(t=0),t>this.length||((r===void 0||r>this.length)&&(r=this.length),r<=0)||(r>>>=0,t>>>=0,r<=t))return"";for(e||(e="utf8");;)switch(e){case"hex":return V_(this,t,r);case"utf8":case"utf-8":return b2(this,t,r);case"ascii":return q_(this,t,r);case"latin1":case"binary":return K_(this,t,r);case"base64":return j_(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return G_(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}fe.prototype._isBuffer=!0;function uu(e,t,r){let n=e[t];e[t]=e[r],e[r]=n}fe.prototype.swap16=function(){let t=this.length;if(t%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let r=0;rr&&(t+=" ... "),""};g2&&(fe.prototype[g2]=fe.prototype.inspect);fe.prototype.compare=function(t,r,n,i,a){if(Ui(t,Uint8Array)&&(t=fe.from(t,t.offset,t.byteLength)),!fe.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(r===void 0&&(r=0),n===void 0&&(n=t?t.length:0),i===void 0&&(i=0),a===void 0&&(a=this.length),r<0||n>t.length||i<0||a>this.length)throw new RangeError("out of range index");if(i>=a&&r>=n)return 0;if(i>=a)return-1;if(r>=n)return 1;if(r>>>=0,n>>>=0,i>>>=0,a>>>=0,this===t)return 0;let s=a-i,c=n-r,l=Math.min(s,c),h=this.slice(i,a),v=t.slice(r,n);for(let E=0;E2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,Pd(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0)if(i)r=0;else return-1;if(typeof t=="string"&&(t=fe.from(t,n)),fe.isBuffer(t))return t.length===0?-1:m2(e,t,r,n,i);if(typeof t=="number")return t=t&255,typeof Uint8Array.prototype.indexOf=="function"?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m2(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m2(e,t,r,n,i){let a=1,s=e.length,c=t.length;if(n!==void 0&&(n=String(n).toLowerCase(),n==="ucs2"||n==="ucs-2"||n==="utf16le"||n==="utf-16le")){if(e.length<2||t.length<2)return-1;a=2,s/=2,c/=2,r/=2}function l(v,E){return a===1?v[E]:v.readUInt16BE(E*a)}let h;if(i){let v=-1;for(h=r;hs&&(r=s-c),h=r;h>=0;h--){let v=!0;for(let E=0;Ei&&(n=i)):n=i;let a=t.length;n>a/2&&(n=a/2);let s;for(s=0;s>>0,isFinite(n)?(n=n>>>0,i===void 0&&(i="utf8")):(i=n,n=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");let a=this.length-r;if((n===void 0||n>a)&&(n=a),t.length>0&&(n<0||r<0)||r>this.length)throw new RangeError("Attempt to write outside buffer bounds");i||(i="utf8");let s=!1;for(;;)switch(i){case"hex":return N_(this,t,r,n);case"utf8":case"utf-8":return k_(this,t,r,n);case"ascii":case"latin1":case"binary":return L_(this,t,r,n);case"base64":return U_(this,t,r,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return H_(this,t,r,n);default:if(s)throw new TypeError("Unknown encoding: "+i);i=(""+i).toLowerCase(),s=!0}};fe.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function j_(e,t,r){return t===0&&r===e.length?bd.fromByteArray(e):bd.fromByteArray(e.slice(t,r))}function b2(e,t,r){r=Math.min(e.length,r);let n=[],i=t;for(;i239?4:a>223?3:a>191?2:1;if(i+c<=r){let l,h,v,E;switch(c){case 1:a<128&&(s=a);break;case 2:l=e[i+1],(l&192)===128&&(E=(a&31)<<6|l&63,E>127&&(s=E));break;case 3:l=e[i+1],h=e[i+2],(l&192)===128&&(h&192)===128&&(E=(a&15)<<12|(l&63)<<6|h&63,E>2047&&(E<55296||E>57343)&&(s=E));break;case 4:l=e[i+1],h=e[i+2],v=e[i+3],(l&192)===128&&(h&192)===128&&(v&192)===128&&(E=(a&15)<<18|(l&63)<<12|(h&63)<<6|v&63,E>65535&&E<1114112&&(s=E))}}s===null?(s=65533,c=1):s>65535&&(s-=65536,n.push(s>>>10&1023|55296),s=56320|s&1023),n.push(s),i+=c}return M_(n)}var v2=4096;function M_(e){let t=e.length;if(t<=v2)return String.fromCharCode.apply(String,e);let r="",n=0;for(;nn)&&(r=n);let i="";for(let a=t;an&&(t=n),r<0?(r+=n,r<0&&(r=0)):r>n&&(r=n),rr)throw new RangeError("Trying to access beyond buffer length")}fe.prototype.readUintLE=fe.prototype.readUIntLE=function(t,r,n){t=t>>>0,r=r>>>0,n||Sr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s>>0,r=r>>>0,n||Sr(t,r,this.length);let i=this[t+--r],a=1;for(;r>0&&(a*=256);)i+=this[t+--r]*a;return i};fe.prototype.readUint8=fe.prototype.readUInt8=function(t,r){return t=t>>>0,r||Sr(t,1,this.length),this[t]};fe.prototype.readUint16LE=fe.prototype.readUInt16LE=function(t,r){return t=t>>>0,r||Sr(t,2,this.length),this[t]|this[t+1]<<8};fe.prototype.readUint16BE=fe.prototype.readUInt16BE=function(t,r){return t=t>>>0,r||Sr(t,2,this.length),this[t]<<8|this[t+1]};fe.prototype.readUint32LE=fe.prototype.readUInt32LE=function(t,r){return t=t>>>0,r||Sr(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+this[t+3]*16777216};fe.prototype.readUint32BE=fe.prototype.readUInt32BE=function(t,r){return t=t>>>0,r||Sr(t,4,this.length),this[t]*16777216+(this[t+1]<<16|this[t+2]<<8|this[t+3])};fe.prototype.readBigUInt64LE=sa(function(t){t=t>>>0,go(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Nc(t,this.length-8);let i=r+this[++t]*2**8+this[++t]*2**16+this[++t]*2**24,a=this[++t]+this[++t]*2**8+this[++t]*2**16+n*2**24;return BigInt(i)+(BigInt(a)<>>0,go(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Nc(t,this.length-8);let i=r*2**24+this[++t]*2**16+this[++t]*2**8+this[++t],a=this[++t]*2**24+this[++t]*2**16+this[++t]*2**8+n;return(BigInt(i)<>>0,r=r>>>0,n||Sr(t,r,this.length);let i=this[t],a=1,s=0;for(;++s=a&&(i-=Math.pow(2,8*r)),i};fe.prototype.readIntBE=function(t,r,n){t=t>>>0,r=r>>>0,n||Sr(t,r,this.length);let i=r,a=1,s=this[t+--i];for(;i>0&&(a*=256);)s+=this[t+--i]*a;return a*=128,s>=a&&(s-=Math.pow(2,8*r)),s};fe.prototype.readInt8=function(t,r){return t=t>>>0,r||Sr(t,1,this.length),this[t]&128?(255-this[t]+1)*-1:this[t]};fe.prototype.readInt16LE=function(t,r){t=t>>>0,r||Sr(t,2,this.length);let n=this[t]|this[t+1]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt16BE=function(t,r){t=t>>>0,r||Sr(t,2,this.length);let n=this[t+1]|this[t]<<8;return n&32768?n|4294901760:n};fe.prototype.readInt32LE=function(t,r){return t=t>>>0,r||Sr(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24};fe.prototype.readInt32BE=function(t,r){return t=t>>>0,r||Sr(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]};fe.prototype.readBigInt64LE=sa(function(t){t=t>>>0,go(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Nc(t,this.length-8);let i=this[t+4]+this[t+5]*2**8+this[t+6]*2**16+(n<<24);return(BigInt(i)<>>0,go(t,"offset");let r=this[t],n=this[t+7];(r===void 0||n===void 0)&&Nc(t,this.length-8);let i=(r<<24)+this[++t]*2**16+this[++t]*2**8+this[++t];return(BigInt(i)<>>0,r||Sr(t,4,this.length),po.read(this,t,!0,23,4)};fe.prototype.readFloatBE=function(t,r){return t=t>>>0,r||Sr(t,4,this.length),po.read(this,t,!1,23,4)};fe.prototype.readDoubleLE=function(t,r){return t=t>>>0,r||Sr(t,8,this.length),po.read(this,t,!0,52,8)};fe.prototype.readDoubleBE=function(t,r){return t=t>>>0,r||Sr(t,8,this.length),po.read(this,t,!1,52,8)};function vn(e,t,r,n,i,a){if(!fe.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}fe.prototype.writeUintLE=fe.prototype.writeUIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;vn(this,t,r,n,c,0)}let a=1,s=0;for(this[r]=t&255;++s>>0,n=n>>>0,!i){let c=Math.pow(2,8*n)-1;vn(this,t,r,n,c,0)}let a=n-1,s=1;for(this[r+a]=t&255;--a>=0&&(s*=256);)this[r+a]=t/s&255;return r+n};fe.prototype.writeUint8=fe.prototype.writeUInt8=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,1,255,0),this[r]=t&255,r+1};fe.prototype.writeUint16LE=fe.prototype.writeUInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,2,65535,0),this[r]=t&255,this[r+1]=t>>>8,r+2};fe.prototype.writeUint16BE=fe.prototype.writeUInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,2,65535,0),this[r]=t>>>8,this[r+1]=t&255,r+2};fe.prototype.writeUint32LE=fe.prototype.writeUInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,4,4294967295,0),this[r+3]=t>>>24,this[r+2]=t>>>16,this[r+1]=t>>>8,this[r]=t&255,r+4};fe.prototype.writeUint32BE=fe.prototype.writeUInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,4,4294967295,0),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};function C2(e,t,r,n,i){B2(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a,a=a>>8,e[r++]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,s=s>>8,e[r++]=s,r}function F2(e,t,r,n,i){B2(t,n,i,e,r,7);let a=Number(t&BigInt(4294967295));e[r+7]=a,a=a>>8,e[r+6]=a,a=a>>8,e[r+5]=a,a=a>>8,e[r+4]=a;let s=Number(t>>BigInt(32)&BigInt(4294967295));return e[r+3]=s,s=s>>8,e[r+2]=s,s=s>>8,e[r+1]=s,s=s>>8,e[r]=s,r+8}fe.prototype.writeBigUInt64LE=sa(function(t,r=0){return C2(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeBigUInt64BE=sa(function(t,r=0){return F2(this,t,r,BigInt(0),BigInt("0xffffffffffffffff"))});fe.prototype.writeIntLE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);vn(this,t,r,n,l-1,-l)}let a=0,s=1,c=0;for(this[r]=t&255;++a>0)-c&255;return r+n};fe.prototype.writeIntBE=function(t,r,n,i){if(t=+t,r=r>>>0,!i){let l=Math.pow(2,8*n-1);vn(this,t,r,n,l-1,-l)}let a=n-1,s=1,c=0;for(this[r+a]=t&255;--a>=0&&(s*=256);)t<0&&c===0&&this[r+a+1]!==0&&(c=1),this[r+a]=(t/s>>0)-c&255;return r+n};fe.prototype.writeInt8=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,1,127,-128),t<0&&(t=255+t+1),this[r]=t&255,r+1};fe.prototype.writeInt16LE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,2,32767,-32768),this[r]=t&255,this[r+1]=t>>>8,r+2};fe.prototype.writeInt16BE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,2,32767,-32768),this[r]=t>>>8,this[r+1]=t&255,r+2};fe.prototype.writeInt32LE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,4,2147483647,-2147483648),this[r]=t&255,this[r+1]=t>>>8,this[r+2]=t>>>16,this[r+3]=t>>>24,r+4};fe.prototype.writeInt32BE=function(t,r,n){return t=+t,r=r>>>0,n||vn(this,t,r,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[r]=t>>>24,this[r+1]=t>>>16,this[r+2]=t>>>8,this[r+3]=t&255,r+4};fe.prototype.writeBigInt64LE=sa(function(t,r=0){return C2(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});fe.prototype.writeBigInt64BE=sa(function(t,r=0){return F2(this,t,r,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function _2(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function I2(e,t,r,n,i){return t=+t,r=r>>>0,i||_2(e,t,r,4,34028234663852886e22,-34028234663852886e22),po.write(e,t,r,n,23,4),r+4}fe.prototype.writeFloatLE=function(t,r,n){return I2(this,t,r,!0,n)};fe.prototype.writeFloatBE=function(t,r,n){return I2(this,t,r,!1,n)};function D2(e,t,r,n,i){return t=+t,r=r>>>0,i||_2(e,t,r,8,17976931348623157e292,-17976931348623157e292),po.write(e,t,r,n,52,8),r+8}fe.prototype.writeDoubleLE=function(t,r,n){return D2(this,t,r,!0,n)};fe.prototype.writeDoubleBE=function(t,r,n){return D2(this,t,r,!1,n)};fe.prototype.copy=function(t,r,n,i){if(!fe.isBuffer(t))throw new TypeError("argument should be a Buffer");if(n||(n=0),!i&&i!==0&&(i=this.length),r>=t.length&&(r=t.length),r||(r=0),i>0&&i=this.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("sourceEnd out of bounds");i>this.length&&(i=this.length),t.length-r>>0,n=n===void 0?this.length:n>>>0,t||(t=0);let a;if(typeof t=="number")for(a=r;a2**32?i=w2(String(r)):typeof r=="bigint"&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=w2(i)),i+="n"),n+=` It must be ${t}. Received ${i}`,n},RangeError);function w2(e){let t="",r=e.length,n=e[0]==="-"?1:0;for(;r>=n+4;r-=3)t=`_${e.slice(r-3,r)}${t}`;return`${e.slice(0,r)}${t}`}function z_(e,t,r){go(t,"offset"),(e[t]===void 0||e[t+r]===void 0)&&Nc(t,e.length-(r+1))}function B2(e,t,r,n,i,a){if(e>r||e3?t===0||t===BigInt(0)?c=`>= 0${s} and < 2${s} ** ${(a+1)*8}${s}`:c=`>= -(2${s} ** ${(a+1)*8-1}${s}) and < 2 ** ${(a+1)*8-1}${s}`:c=`>= ${t}${s} and <= ${r}${s}`,new ho.ERR_OUT_OF_RANGE("value",c,e)}z_(n,i,a)}function go(e,t){if(typeof e!="number")throw new ho.ERR_INVALID_ARG_TYPE(t,"number",e)}function Nc(e,t,r){throw Math.floor(e)!==e?(go(e,r),new ho.ERR_OUT_OF_RANGE(r||"offset","an integer",e)):t<0?new ho.ERR_BUFFER_OUT_OF_BOUNDS:new ho.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${t}`,e)}var Y_=/[^+/0-9A-Za-z-_]/g;function W_(e){if(e=e.split("=")[0],e=e.trim().replace(Y_,""),e.length<2)return"";for(;e.length%4!==0;)e=e+"=";return e}function _d(e,t){t=t||1/0;let r,n=e.length,i=null,a=[];for(let s=0;s55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}else if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=(i-55296<<10|r-56320)+65536}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,r&63|128)}else if(r<65536){if((t-=3)<0)break;a.push(r>>12|224,r>>6&63|128,r&63|128)}else if(r<1114112){if((t-=4)<0)break;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,r&63|128)}else throw new Error("Invalid code point")}return a}function X_(e){let t=[];for(let r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function P2(e){return bd.toByteArray(W_(e))}function Of(e,t,r,n){let i;for(i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function Ui(e,t){return e instanceof t||e!=null&&e.constructor!=null&&e.constructor.name!=null&&e.constructor.name===t.name}function Pd(e){return e!==e}var Z_=function(){let e="0123456789abcdef",t=new Array(256);for(let r=0;r<16;++r){let n=r*16;for(let i=0;i<16;++i)t[n+i]=e[r]+e[i]}return t}();function sa(e){return typeof BigInt>"u"?Q_:e}function Q_(){throw new Error("BigInt not supported")}});var ew=Ce(ye=>{var kc={};kc.userAgent=!1;var vo={},e8="11.1.0",t8="jsrsasign(all) 11.1.0 (2024-02-01) (c) 2010-2023 Kenji Urushima | kjur.github.io/jsrsasign/license";var be=be||function(e,t){var r={},n=r.lib={},i=n.Base=function(){function f(){}return{extend:function(A){f.prototype=this;var g=new f;return A&&g.mixIn(A),g.hasOwnProperty("init")||(g.init=function(){g.$super.init.apply(this,arguments)}),g.init.prototype=g,g.$super=this,g},create:function(){var A=this.extend();return A.init.apply(A,arguments),A},init:function(){},mixIn:function(A){for(var g in A)A.hasOwnProperty(g)&&(this[g]=A[g]);A.hasOwnProperty("toString")&&(this.toString=A.toString)},clone:function(){return this.init.prototype.extend(this)}}}(),a=n.WordArray=i.extend({init:function(f,A){f=this.words=f||[],A!=t?this.sigBytes=A:this.sigBytes=f.length*4},toString:function(f){return(f||c).stringify(this)},concat:function(f){var A=this.words,g=f.words,y=this.sigBytes,w=f.sigBytes;if(this.clamp(),y%4)for(var S=0;S>>2]>>>24-S%4*8&255;A[y+S>>>2]|=_<<24-(y+S)%4*8}else for(var S=0;S>>2]=g[S>>>2];return this.sigBytes+=w,this},clamp:function(){var f=this.words,A=this.sigBytes;f[A>>>2]&=4294967295<<32-A%4*8,f.length=e.ceil(A/4)},clone:function(){var f=i.clone.call(this);return f.words=this.words.slice(0),f},random:function(f){for(var A=[],g=0;g>>2]>>>24-w%4*8&255;y.push((S>>>4).toString(16)),y.push((S&15).toString(16))}return y.join("")},parse:function(f){for(var A=f.length,g=[],y=0;y>>3]|=parseInt(f.substr(y,2),16)<<24-y%8*4;return new a.init(g,A/2)}},l=s.Latin1={stringify:function(f){for(var A=f.words,g=f.sigBytes,y=[],w=0;w>>2]>>>24-w%4*8&255;y.push(String.fromCharCode(S))}return y.join("")},parse:function(f){for(var A=f.length,g=[],y=0;y>>2]|=(f.charCodeAt(y)&255)<<24-y%4*8;return new a.init(g,A)}},h=s.Utf8={stringify:function(f){try{return decodeURIComponent(escape(l.stringify(f)))}catch{throw new Error("Malformed UTF-8 data")}},parse:function(f){return l.parse(unescape(encodeURIComponent(f)))}},v=n.BufferedBlockAlgorithm=i.extend({reset:function(){this._data=new a.init,this._nDataBytes=0},_append:function(f){typeof f=="string"&&(f=h.parse(f)),this._data.concat(f),this._nDataBytes+=f.sigBytes},_process:function(f){var A=this._data,g=A.words,y=A.sigBytes,w=this.blockSize,S=w*4,_=y/S;f?_=e.ceil(_):_=e.max((_|0)-this._minBufferSize,0);var I=_*w,B=e.min(I*4,y);if(I){for(var q=0;q>>2]&255}},t.BlockCipher=c.extend({cfg:c.cfg.extend({mode:E,padding:h}),reset:function(){c.reset.call(this);var y=this.cfg,g=y.iv,y=y.mode;if(this._xformMode==this._ENC_XFORM_MODE)var w=y.createEncryptor;else w=y.createDecryptor,this._minBufferSize=1;this._mode=w.call(y,this,g&&g.words)},_doProcessBlock:function(g,y){this._mode.processBlock(g,y)},_doFinalize:function(){var g=this.cfg.padding;if(this._xformMode==this._ENC_XFORM_MODE){g.pad(this._data,this.blockSize);var y=this._process(!0)}else y=this._process(!0),g.unpad(y);return y},blockSize:4});var v=t.CipherParams=r.extend({init:function(g){this.mixIn(g)},toString:function(g){return(g||this.formatter).stringify(this)}}),E=(f.format={}).OpenSSL={stringify:function(g){var y=g.ciphertext;return g=g.salt,(g?n.create([1398893684,1701076831]).concat(g).concat(y):y).toString(a)},parse:function(g){g=a.parse(g);var y=g.words;if(y[0]==1398893684&&y[1]==1701076831){var w=n.create(y.slice(2,4));y.splice(0,4),g.sigBytes-=16}return v.create({ciphertext:g,salt:w})}},p=t.SerializableCipher=r.extend({cfg:r.extend({format:E}),encrypt:function(g,y,w,S){S=this.cfg.extend(S);var _=g.createEncryptor(w,S);return y=_.finalize(y),_=_.cfg,v.create({ciphertext:y,key:w,iv:_.iv,algorithm:g,mode:_.mode,padding:_.padding,blockSize:g.blockSize,formatter:S.format})},decrypt:function(g,y,w,S){return S=this.cfg.extend(S),y=this._parse(y,S.format),g.createDecryptor(w,S).finalize(y.ciphertext)},_parse:function(g,y){return typeof g=="string"?y.parse(g,this):g}}),f=(f.kdf={}).OpenSSL={execute:function(g,y,w,S){return S||(S=n.random(8)),g=s.create({keySize:y+w}).compute(g,S),w=n.create(g.words.slice(y),4*w),g.sigBytes=4*y,v.create({key:g,iv:w,salt:S})}},A=t.PasswordBasedCipher=p.extend({cfg:p.cfg.extend({kdf:f}),encrypt:function(g,y,w,S){return S=this.cfg.extend(S),w=S.kdf.execute(w,g.keySize,g.ivSize),S.iv=w.iv,g=p.encrypt.call(this,g,y,w.key,S),g.mixIn(w),g},decrypt:function(g,y,w,S){return S=this.cfg.extend(S),y=this._parse(y,S.format),w=S.kdf.execute(w,g.keySize,g.ivSize,y.salt),S.iv=w.iv,p.decrypt.call(this,g,y,w.key,S)}})}();(function(){for(var e=be,t=e.lib.BlockCipher,q=e.algo,r=[],n=[],i=[],a=[],s=[],c=[],l=[],h=[],v=[],E=[],p=[],f=0;256>f;f++)p[f]=128>f?f<<1:f<<1^283;for(var A=0,g=0,f=0;256>f;f++){var y=g^g<<1^g<<2^g<<3^g<<4,y=y>>>8^y&255^99;r[A]=y,n[y]=A;var w=p[A],S=p[w],_=p[S],I=257*p[y]^16843008*y;i[A]=I<<24|I>>>8,a[A]=I<<16|I>>>16,s[A]=I<<8|I>>>24,c[A]=I,I=16843009*_^65537*S^257*w^16843008*A,l[y]=I<<24|I>>>8,h[y]=I<<16|I>>>16,v[y]=I<<8|I>>>24,E[y]=I,A?(A=w^p[p[p[_^w]]],g^=p[p[g]]):A=g=1}var B=[0,1,2,4,8,16,32,64,128,27,54],q=q.AES=t.extend({_doReset:function(){for(var P=this._key,z=P.words,F=P.sigBytes/4,P=4*((this._nRounds=F+6)+1),L=this._keySchedule=[],H=0;H>>24]<<24|r[K>>>16&255]<<16|r[K>>>8&255]<<8|r[K&255]):(K=K<<8|K>>>24,K=r[K>>>24]<<24|r[K>>>16&255]<<16|r[K>>>8&255]<<8|r[K&255],K^=B[H/F|0]<<24),L[H]=L[H-F]^K}for(z=this._invKeySchedule=[],F=0;FF||4>=H?K:l[r[K>>>24]]^h[r[K>>>16&255]]^v[r[K>>>8&255]]^E[r[K&255]]},encryptBlock:function(z,F){this._doCryptBlock(z,F,this._keySchedule,i,a,s,c,r)},decryptBlock:function(z,F){var P=z[F+1];z[F+1]=z[F+3],z[F+3]=P,this._doCryptBlock(z,F,this._invKeySchedule,l,h,v,E,n),P=z[F+1],z[F+1]=z[F+3],z[F+3]=P},_doCryptBlock:function(z,F,P,L,H,K,Z,G){for(var V=this._nRounds,ce=z[F]^P[0],_e=z[F+1]^P[1],ke=z[F+2]^P[2],qe=z[F+3]^P[3],X=4,ie=1;ie>>24]^H[_e>>>16&255]^K[ke>>>8&255]^Z[qe&255]^P[X++],Ee=L[_e>>>24]^H[ke>>>16&255]^K[qe>>>8&255]^Z[ce&255]^P[X++],Pe=L[ke>>>24]^H[qe>>>16&255]^K[ce>>>8&255]^Z[_e&255]^P[X++],qe=L[qe>>>24]^H[ce>>>16&255]^K[_e>>>8&255]^Z[ke&255]^P[X++],ce=Se,_e=Ee,ke=Pe;Se=(G[ce>>>24]<<24|G[_e>>>16&255]<<16|G[ke>>>8&255]<<8|G[qe&255])^P[X++],Ee=(G[_e>>>24]<<24|G[ke>>>16&255]<<16|G[qe>>>8&255]<<8|G[ce&255])^P[X++],Pe=(G[ke>>>24]<<24|G[qe>>>16&255]<<16|G[ce>>>8&255]<<8|G[_e&255])^P[X++],qe=(G[qe>>>24]<<24|G[ce>>>16&255]<<16|G[_e>>>8&255]<<8|G[ke&255])^P[X++],z[F]=Se,z[F+1]=Ee,z[F+2]=Pe,z[F+3]=qe},keySize:8});e.AES=t._createHelper(q)})();(function(){function e(p,f){var A=(this._lBlock>>>p^this._rBlock)&f;this._rBlock^=A,this._lBlock^=A<>>p^this._lBlock)&f;this._lBlock^=A,this._rBlock^=A<A;A++){var g=s[A]-1;f[A]=p[g>>>5]>>>31-g%32&1}for(p=this._subKeys=[],g=0;16>g;g++){for(var y=p[g]=[],w=l[g],A=0;24>A;A++)y[A/6|0]|=f[(c[A]-1+w)%28]<<31-A%6,y[4+(A/6|0)]|=f[28+(c[A+24]-1+w)%28]<<31-A%6;for(y[0]=y[0]<<1|y[0]>>>31,A=1;7>A;A++)y[A]>>>=4*(A-1)+3;y[7]=y[7]<<5|y[7]>>>27}for(f=this._invSubKeys=[],A=0;16>A;A++)f[A]=p[15-A]},encryptBlock:function(p,f){this._doCryptBlock(p,f,this._subKeys)},decryptBlock:function(p,f){this._doCryptBlock(p,f,this._invSubKeys)},_doCryptBlock:function(p,f,A){this._lBlock=p[f],this._rBlock=p[f+1],e.call(this,4,252645135),e.call(this,16,65535),t.call(this,2,858993459),t.call(this,8,16711935),e.call(this,1,1431655765);for(var g=0;16>g;g++){for(var y=A[g],w=this._lBlock,S=this._rBlock,_=0,I=0;8>I;I++)_|=h[I][((S^y[I])&v[I])>>>0];this._lBlock=S,this._rBlock=w^_}A=this._lBlock,this._lBlock=this._rBlock,this._rBlock=A,e.call(this,1,1431655765),t.call(this,8,16711935),t.call(this,2,858993459),e.call(this,16,65535),e.call(this,4,252645135),p[f]=this._lBlock,p[f+1]=this._rBlock},keySize:2,ivSize:2,blockSize:2});r.DES=i._createHelper(E),a=a.TripleDES=i.extend({_doReset:function(){var p=this._key.words;this._des1=E.createEncryptor(n.create(p.slice(0,2))),this._des2=E.createEncryptor(n.create(p.slice(2,4))),this._des3=E.createEncryptor(n.create(p.slice(4,6)))},encryptBlock:function(p,f){this._des1.encryptBlock(p,f),this._des2.decryptBlock(p,f),this._des3.encryptBlock(p,f)},decryptBlock:function(p,f){this._des3.decryptBlock(p,f),this._des2.encryptBlock(p,f),this._des1.decryptBlock(p,f)},keySize:6,ivSize:2,blockSize:2}),r.TripleDES=i._createHelper(a)})();(function(){var e=be,t=e.lib.WordArray;e.enc.Base64={stringify:function(r){var n=r.words,i=r.sigBytes,a=this._map;r.clamp(),r=[];for(var s=0;s>>2]>>>24-8*(s%4)&255)<<16|(n[s+1>>>2]>>>24-8*((s+1)%4)&255)<<8|n[s+2>>>2]>>>24-8*((s+2)%4)&255,l=0;4>l&&s+.75*l>>6*(3-l)&63));if(n=a.charAt(64))for(;r.length%4;)r.push(n);return r.join("")},parse:function(r){var n=r.length,i=this._map,a=i.charAt(64);a&&(a=r.indexOf(a),a!=-1&&(n=a));for(var a=[],s=0,c=0;c>>6-2*(c%4);a[s>>>2]|=(l|h)<<24-8*(s%4),s++}return t.create(a,s)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="}})();(function(e){function t(E,p,f,A,g,y,w){return E=E+(p&f|~p&A)+g+w,(E<>>32-y)+p}function r(E,p,f,A,g,y,w){return E=E+(p&A|f&~A)+g+w,(E<>>32-y)+p}function n(E,p,f,A,g,y,w){return E=E+(p^f^A)+g+w,(E<>>32-y)+p}function i(E,p,f,A,g,y,w){return E=E+(f^(p|~A))+g+w,(E<>>32-y)+p}for(var a=be,l=a.lib,s=l.WordArray,c=l.Hasher,l=a.algo,h=[],v=0;64>v;v++)h[v]=4294967296*e.abs(e.sin(v+1))|0;l=l.MD5=c.extend({_doReset:function(){this._hash=new s.init([1732584193,4023233417,2562383102,271733878])},_doProcessBlock:function(E,p){for(var f=0;16>f;f++){var A=p+f,g=E[A];E[A]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360}var f=this._hash.words,A=E[p+0],g=E[p+1],y=E[p+2],w=E[p+3],S=E[p+4],_=E[p+5],I=E[p+6],B=E[p+7],q=E[p+8],z=E[p+9],F=E[p+10],P=E[p+11],L=E[p+12],H=E[p+13],K=E[p+14],Z=E[p+15],G=f[0],ie=f[1],X=f[2],V=f[3],G=t(G,ie,X,V,A,7,h[0]),V=t(V,G,ie,X,g,12,h[1]),X=t(X,V,G,ie,y,17,h[2]),ie=t(ie,X,V,G,w,22,h[3]),G=t(G,ie,X,V,S,7,h[4]),V=t(V,G,ie,X,_,12,h[5]),X=t(X,V,G,ie,I,17,h[6]),ie=t(ie,X,V,G,B,22,h[7]),G=t(G,ie,X,V,q,7,h[8]),V=t(V,G,ie,X,z,12,h[9]),X=t(X,V,G,ie,F,17,h[10]),ie=t(ie,X,V,G,P,22,h[11]),G=t(G,ie,X,V,L,7,h[12]),V=t(V,G,ie,X,H,12,h[13]),X=t(X,V,G,ie,K,17,h[14]),ie=t(ie,X,V,G,Z,22,h[15]),G=r(G,ie,X,V,g,5,h[16]),V=r(V,G,ie,X,I,9,h[17]),X=r(X,V,G,ie,P,14,h[18]),ie=r(ie,X,V,G,A,20,h[19]),G=r(G,ie,X,V,_,5,h[20]),V=r(V,G,ie,X,F,9,h[21]),X=r(X,V,G,ie,Z,14,h[22]),ie=r(ie,X,V,G,S,20,h[23]),G=r(G,ie,X,V,z,5,h[24]),V=r(V,G,ie,X,K,9,h[25]),X=r(X,V,G,ie,w,14,h[26]),ie=r(ie,X,V,G,q,20,h[27]),G=r(G,ie,X,V,H,5,h[28]),V=r(V,G,ie,X,y,9,h[29]),X=r(X,V,G,ie,B,14,h[30]),ie=r(ie,X,V,G,L,20,h[31]),G=n(G,ie,X,V,_,4,h[32]),V=n(V,G,ie,X,q,11,h[33]),X=n(X,V,G,ie,P,16,h[34]),ie=n(ie,X,V,G,K,23,h[35]),G=n(G,ie,X,V,g,4,h[36]),V=n(V,G,ie,X,S,11,h[37]),X=n(X,V,G,ie,B,16,h[38]),ie=n(ie,X,V,G,F,23,h[39]),G=n(G,ie,X,V,H,4,h[40]),V=n(V,G,ie,X,A,11,h[41]),X=n(X,V,G,ie,w,16,h[42]),ie=n(ie,X,V,G,I,23,h[43]),G=n(G,ie,X,V,z,4,h[44]),V=n(V,G,ie,X,L,11,h[45]),X=n(X,V,G,ie,Z,16,h[46]),ie=n(ie,X,V,G,y,23,h[47]),G=i(G,ie,X,V,A,6,h[48]),V=i(V,G,ie,X,B,10,h[49]),X=i(X,V,G,ie,K,15,h[50]),ie=i(ie,X,V,G,_,21,h[51]),G=i(G,ie,X,V,L,6,h[52]),V=i(V,G,ie,X,w,10,h[53]),X=i(X,V,G,ie,F,15,h[54]),ie=i(ie,X,V,G,g,21,h[55]),G=i(G,ie,X,V,q,6,h[56]),V=i(V,G,ie,X,Z,10,h[57]),X=i(X,V,G,ie,I,15,h[58]),ie=i(ie,X,V,G,H,21,h[59]),G=i(G,ie,X,V,S,6,h[60]),V=i(V,G,ie,X,P,10,h[61]),X=i(X,V,G,ie,y,15,h[62]),ie=i(ie,X,V,G,z,21,h[63]);f[0]=f[0]+G|0,f[1]=f[1]+ie|0,f[2]=f[2]+X|0,f[3]=f[3]+V|0},_doFinalize:function(){var E=this._data,p=E.words,f=8*this._nDataBytes,A=8*E.sigBytes;p[A>>>5]|=128<<24-A%32;var g=e.floor(f/4294967296);for(p[(A+64>>>9<<4)+15]=(g<<8|g>>>24)&16711935|(g<<24|g>>>8)&4278255360,p[(A+64>>>9<<4)+14]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360,E.sigBytes=4*(p.length+1),this._process(),E=this._hash,p=E.words,f=0;4>f;f++)A=p[f],p[f]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360;return E},clone:function(){var E=c.clone.call(this);return E._hash=this._hash.clone(),E}}),a.MD5=c._createHelper(l),a.HmacMD5=c._createHmacHelper(l)})(Math);(function(){var e=be,i=e.lib,t=i.WordArray,r=i.Hasher,n=[],i=e.algo.SHA1=r.extend({_doReset:function(){this._hash=new t.init([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(a,s){for(var c=this._hash.words,l=c[0],h=c[1],v=c[2],E=c[3],p=c[4],f=0;80>f;f++){if(16>f)n[f]=a[s+f]|0;else{var A=n[f-3]^n[f-8]^n[f-14]^n[f-16];n[f]=A<<1|A>>>31}A=(l<<5|l>>>27)+p+n[f],A=20>f?A+((h&v|~h&E)+1518500249):40>f?A+((h^v^E)+1859775393):60>f?A+((h&v|h&E|v&E)-1894007588):A+((h^v^E)-899497514),p=E,E=v,v=h<<30|h>>>2,h=l,l=A}c[0]=c[0]+l|0,c[1]=c[1]+h|0,c[2]=c[2]+v|0,c[3]=c[3]+E|0,c[4]=c[4]+p|0},_doFinalize:function(){var a=this._data,s=a.words,c=8*this._nDataBytes,l=8*a.sigBytes;return s[l>>>5]|=128<<24-l%32,s[(l+64>>>9<<4)+14]=Math.floor(c/4294967296),s[(l+64>>>9<<4)+15]=c,a.sigBytes=4*s.length,this._process(),this._hash},clone:function(){var a=r.clone.call(this);return a._hash=this._hash.clone(),a}});e.SHA1=r._createHelper(i),e.HmacSHA1=r._createHmacHelper(i)})();(function(e){for(var t=be,f=t.lib,r=f.WordArray,n=f.Hasher,f=t.algo,i=[],a=[],s=function(g){return 4294967296*(g-(g|0))|0},c=2,l=0;64>l;){var h;e:{h=c;for(var v=e.sqrt(h),E=2;E<=v;E++)if(!(h%E)){h=!1;break e}h=!0}h&&(8>l&&(i[l]=s(e.pow(c,.5))),a[l]=s(e.pow(c,1/3)),l++),c++}var p=[],f=f.SHA256=n.extend({_doReset:function(){this._hash=new r.init(i.slice(0))},_doProcessBlock:function(A,g){for(var y=this._hash.words,w=y[0],S=y[1],_=y[2],I=y[3],B=y[4],q=y[5],z=y[6],F=y[7],P=0;64>P;P++){if(16>P)p[P]=A[g+P]|0;else{var L=p[P-15],H=p[P-2];p[P]=((L<<25|L>>>7)^(L<<14|L>>>18)^L>>>3)+p[P-7]+((H<<15|H>>>17)^(H<<13|H>>>19)^H>>>10)+p[P-16]}L=F+((B<<26|B>>>6)^(B<<21|B>>>11)^(B<<7|B>>>25))+(B&q^~B&z)+a[P]+p[P],H=((w<<30|w>>>2)^(w<<19|w>>>13)^(w<<10|w>>>22))+(w&S^w&_^S&_),F=z,z=q,q=B,B=I+L|0,I=_,_=S,S=w,w=L+H|0}y[0]=y[0]+w|0,y[1]=y[1]+S|0,y[2]=y[2]+_|0,y[3]=y[3]+I|0,y[4]=y[4]+B|0,y[5]=y[5]+q|0,y[6]=y[6]+z|0,y[7]=y[7]+F|0},_doFinalize:function(){var A=this._data,g=A.words,y=8*this._nDataBytes,w=8*A.sigBytes;return g[w>>>5]|=128<<24-w%32,g[(w+64>>>9<<4)+14]=e.floor(y/4294967296),g[(w+64>>>9<<4)+15]=y,A.sigBytes=4*g.length,this._process(),this._hash},clone:function(){var A=n.clone.call(this);return A._hash=this._hash.clone(),A}});t.SHA256=n._createHelper(f),t.HmacSHA256=n._createHmacHelper(f)})(Math);(function(){var e=be,t=e.lib.WordArray,n=e.algo,r=n.SHA256,n=n.SHA224=r.extend({_doReset:function(){this._hash=new t.init([3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428])},_doFinalize:function(){var i=r._doFinalize.call(this);return i.sigBytes-=4,i}});e.SHA224=r._createHelper(n),e.HmacSHA224=r._createHmacHelper(n)})();(function(){function e(){return n.create.apply(n,arguments)}for(var t=be,r=t.lib.Hasher,a=t.x64,n=a.Word,i=a.WordArray,a=t.algo,s=[e(1116352408,3609767458),e(1899447441,602891725),e(3049323471,3964484399),e(3921009573,2173295548),e(961987163,4081628472),e(1508970993,3053834265),e(2453635748,2937671579),e(2870763221,3664609560),e(3624381080,2734883394),e(310598401,1164996542),e(607225278,1323610764),e(1426881987,3590304994),e(1925078388,4068182383),e(2162078206,991336113),e(2614888103,633803317),e(3248222580,3479774868),e(3835390401,2666613458),e(4022224774,944711139),e(264347078,2341262773),e(604807628,2007800933),e(770255983,1495990901),e(1249150122,1856431235),e(1555081692,3175218132),e(1996064986,2198950837),e(2554220882,3999719339),e(2821834349,766784016),e(2952996808,2566594879),e(3210313671,3203337956),e(3336571891,1034457026),e(3584528711,2466948901),e(113926993,3758326383),e(338241895,168717936),e(666307205,1188179964),e(773529912,1546045734),e(1294757372,1522805485),e(1396182291,2643833823),e(1695183700,2343527390),e(1986661051,1014477480),e(2177026350,1206759142),e(2456956037,344077627),e(2730485921,1290863460),e(2820302411,3158454273),e(3259730800,3505952657),e(3345764771,106217008),e(3516065817,3606008344),e(3600352804,1432725776),e(4094571909,1467031594),e(275423344,851169720),e(430227734,3100823752),e(506948616,1363258195),e(659060556,3750685593),e(883997877,3785050280),e(958139571,3318307427),e(1322822218,3812723403),e(1537002063,2003034995),e(1747873779,3602036899),e(1955562222,1575990012),e(2024104815,1125592928),e(2227730452,2716904306),e(2361852424,442776044),e(2428436474,593698344),e(2756734187,3733110249),e(3204031479,2999351573),e(3329325298,3815920427),e(3391569614,3928383900),e(3515267271,566280711),e(3940187606,3454069534),e(4118630271,4000239992),e(116418474,1914138554),e(174292421,2731055270),e(289380356,3203993006),e(460393269,320620315),e(685471733,587496836),e(852142971,1086792851),e(1017036298,365543100),e(1126000580,2618297676),e(1288033470,3409855158),e(1501505948,4234509866),e(1607167915,987167468),e(1816402316,1246189591)],c=[],l=0;80>l;l++)c[l]=e();a=a.SHA512=r.extend({_doReset:function(){this._hash=new i.init([new n.init(1779033703,4089235720),new n.init(3144134277,2227873595),new n.init(1013904242,4271175723),new n.init(2773480762,1595750129),new n.init(1359893119,2917565137),new n.init(2600822924,725511199),new n.init(528734635,4215389547),new n.init(1541459225,327033209)])},_doProcessBlock:function(h,v){for(var S=this._hash.words,E=S[0],p=S[1],f=S[2],A=S[3],g=S[4],y=S[5],w=S[6],S=S[7],_=E.high,I=E.low,B=p.high,q=p.low,z=f.high,F=f.low,P=A.high,L=A.low,H=g.high,K=g.low,Z=y.high,G=y.low,V=w.high,X=w.low,ie=S.high,Se=S.low,Ee=_,Pe=I,qe=B,ce=q,_e=z,ke=F,mr=P,xt=L,ht=H,Zt=K,Ut=Z,rt=G,$t=V,et=X,vt=ie,Qt=Se,Xe=0;80>Xe;Xe++){var Nr=c[Xe];if(16>Xe)var Vt=Nr.high=h[v+2*Xe]|0,Je=Nr.low=h[v+2*Xe+1]|0;else{var Vt=c[Xe-15],Je=Vt.high,rr=Vt.low,Vt=(Je>>>1|rr<<31)^(Je>>>8|rr<<24)^Je>>>7,rr=(rr>>>1|Je<<31)^(rr>>>8|Je<<24)^(rr>>>7|Je<<25),Or=c[Xe-2],Je=Or.high,wt=Or.low,Or=(Je>>>19|wt<<13)^(Je<<3|wt>>>29)^Je>>>6,wt=(wt>>>19|Je<<13)^(wt<<3|Je>>>29)^(wt>>>6|Je<<26),Je=c[Xe-7],Vn=Je.high,vr=c[Xe-16],nr=vr.high,vr=vr.low,Je=rr+Je.low,Vt=Vt+Vn+(Je>>>0>>0?1:0),Je=Je+wt,Vt=Vt+Or+(Je>>>0>>0?1:0),Je=Je+vr,Vt=Vt+nr+(Je>>>0>>0?1:0);Nr.high=Vt,Nr.low=Je}var Vn=ht&Ut^~ht&$t,vr=Zt&rt^~Zt&et,Nr=Ee&qe^Ee&_e^qe&_e,Fr=Pe&ce^Pe&ke^ce&ke,rr=(Ee>>>28|Pe<<4)^(Ee<<30|Pe>>>2)^(Ee<<25|Pe>>>7),Or=(Pe>>>28|Ee<<4)^(Pe<<30|Ee>>>2)^(Pe<<25|Ee>>>7),wt=s[Xe],ma=wt.high,zr=wt.low,wt=Qt+((Zt>>>14|ht<<18)^(Zt>>>18|ht<<14)^(Zt<<23|ht>>>9)),nr=vt+((ht>>>14|Zt<<18)^(ht>>>18|Zt<<14)^(ht<<23|Zt>>>9))+(wt>>>0>>0?1:0),wt=wt+vr,nr=nr+Vn+(wt>>>0>>0?1:0),wt=wt+zr,nr=nr+ma+(wt>>>0>>0?1:0),wt=wt+Je,nr=nr+Vt+(wt>>>0>>0?1:0),Je=Or+Fr,Nr=rr+Nr+(Je>>>0>>0?1:0),vt=$t,Qt=et,$t=Ut,et=rt,Ut=ht,rt=Zt,Zt=xt+wt|0,ht=mr+nr+(Zt>>>0>>0?1:0)|0,mr=_e,xt=ke,_e=qe,ke=ce,qe=Ee,ce=Pe,Pe=wt+Je|0,Ee=nr+Nr+(Pe>>>0>>0?1:0)|0}I=E.low=I+Pe,E.high=_+Ee+(I>>>0>>0?1:0),q=p.low=q+ce,p.high=B+qe+(q>>>0>>0?1:0),F=f.low=F+ke,f.high=z+_e+(F>>>0>>0?1:0),L=A.low=L+xt,A.high=P+mr+(L>>>0>>0?1:0),K=g.low=K+Zt,g.high=H+ht+(K>>>0>>0?1:0),G=y.low=G+rt,y.high=Z+Ut+(G>>>0>>0?1:0),X=w.low=X+et,w.high=V+$t+(X>>>0>>0?1:0),Se=S.low=Se+Qt,S.high=ie+vt+(Se>>>0>>0?1:0)},_doFinalize:function(){var h=this._data,v=h.words,E=8*this._nDataBytes,p=8*h.sigBytes;return v[p>>>5]|=128<<24-p%32,v[(p+128>>>10<<5)+30]=Math.floor(E/4294967296),v[(p+128>>>10<<5)+31]=E,h.sigBytes=4*v.length,this._process(),this._hash.toX32()},clone:function(){var h=r.clone.call(this);return h._hash=this._hash.clone(),h},blockSize:32}),t.SHA512=r._createHelper(a),t.HmacSHA512=r._createHmacHelper(a)})();(function(){var e=be,i=e.x64,t=i.Word,r=i.WordArray,i=e.algo,n=i.SHA512,i=i.SHA384=n.extend({_doReset:function(){this._hash=new r.init([new t.init(3418070365,3238371032),new t.init(1654270250,914150663),new t.init(2438529370,812702999),new t.init(355462360,4144912697),new t.init(1731405415,4290775857),new t.init(2394180231,1750603025),new t.init(3675008525,1694076839),new t.init(1203062813,3204075428)])},_doFinalize:function(){var a=n._doFinalize.call(this);return a.sigBytes-=16,a}});e.SHA384=n._createHelper(i),e.HmacSHA384=n._createHmacHelper(i)})();(function(){var e=be,h=e.lib,t=h.WordArray,r=h.Hasher,h=e.algo,n=t.create([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13]),i=t.create([5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11]),a=t.create([11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6]),s=t.create([8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]),c=t.create([0,1518500249,1859775393,2400959708,2840853838]),l=t.create([1352829926,1548603684,1836072691,2053994217,0]),h=h.RIPEMD160=r.extend({_doReset:function(){this._hash=t.create([1732584193,4023233417,2562383102,271733878,3285377520])},_doProcessBlock:function(v,E){for(var p=0;16>p;p++){var f=E+p,A=v[f];v[f]=(A<<8|A>>>24)&16711935|(A<<24|A>>>8)&4278255360}var f=this._hash.words,A=c.words,g=l.words,y=n.words,w=i.words,S=a.words,_=s.words,I,B,q,z,F,P,L,H,K,Z;P=I=f[0],L=B=f[1],H=q=f[2],K=z=f[3],Z=F=f[4];for(var G,p=0;80>p;p+=1)G=I+v[E+y[p]]|0,G=16>p?G+((B^q^z)+A[0]):32>p?G+((B&q|~B&z)+A[1]):48>p?G+(((B|~q)^z)+A[2]):64>p?G+((B&z|q&~z)+A[3]):G+((B^(q|~z))+A[4]),G|=0,G=G<>>32-S[p],G=G+F|0,I=F,F=z,z=q<<10|q>>>22,q=B,B=G,G=P+v[E+w[p]]|0,G=16>p?G+((L^(H|~K))+g[0]):32>p?G+((L&K|H&~K)+g[1]):48>p?G+(((L|~H)^K)+g[2]):64>p?G+((L&H|~L&K)+g[3]):G+((L^H^K)+g[4]),G|=0,G=G<<_[p]|G>>>32-_[p],G=G+Z|0,P=Z,Z=K,K=H<<10|H>>>22,H=L,L=G;G=f[1]+q+K|0,f[1]=f[2]+z+Z|0,f[2]=f[3]+F+P|0,f[3]=f[4]+I+L|0,f[4]=f[0]+B+H|0,f[0]=G},_doFinalize:function(){var v=this._data,E=v.words,p=8*this._nDataBytes,f=8*v.sigBytes;for(E[f>>>5]|=128<<24-f%32,E[(f+64>>>9<<4)+14]=(p<<8|p>>>24)&16711935|(p<<24|p>>>8)&4278255360,v.sigBytes=4*(E.length+1),this._process(),v=this._hash,E=v.words,p=0;5>p;p++)f=E[p],E[p]=(f<<8|f>>>24)&16711935|(f<<24|f>>>8)&4278255360;return v},clone:function(){var v=r.clone.call(this);return v._hash=this._hash.clone(),v}});e.RIPEMD160=r._createHelper(h),e.HmacRIPEMD160=r._createHmacHelper(h)})(Math);(function(){var e=be,t=e.enc.Utf8;e.algo.HMAC=e.lib.Base.extend({init:function(r,n){r=this._hasher=new r.init,typeof n=="string"&&(n=t.parse(n));var i=r.blockSize,a=4*i;n.sigBytes>a&&(n=r.finalize(n)),n.clamp();for(var s=this._oKey=n.clone(),c=this._iKey=n.clone(),l=s.words,h=c.words,v=0;v>6)+wo.charAt(r&63);if(t+1==e.length?(r=parseInt(e.substring(t,t+1),16),n+=wo.charAt(r<<2)):t+2==e.length&&(r=parseInt(e.substring(t,t+2),16),n+=wo.charAt(r>>2)+wo.charAt((r&3)<<4)),xd)for(;(n.length&3)>0;)n+=xd;return n}function Eo(e){var t="",r,n=0,i,a;for(r=0;r>2),i=a&3,n=1):n==1?(t+=Ss(i<<2|a>>4),i=a&15,n=2):n==2?(t+=Ss(i),t+=Ss(a>>2),i=a&3,n=3):(t+=Ss(i<<2|a>>4),t+=Ss(a&15),n=0));return n==1&&(t+=Ss(i<<2)),t}function x2(e){var t=Eo(e),r,n=new Array;for(r=0;2*r=0;){var s=t*this[e++]+r[n]+i;i=Math.floor(s/67108864),r[n++]=s&67108863}return i}function i8(e,t,r,n,i,a){for(var s=t&32767,c=t>>15;--a>=0;){var l=this[e]&32767,h=this[e++]>>15,v=c*l+h*s;l=s*l+((v&32767)<<15)+r[n]+(i&1073741823),i=(l>>>30)+(v>>>15)+c*h+(i>>>30),r[n++]=l&1073741823}return i}function s8(e,t,r,n,i,a){for(var s=t&16383,c=t>>14;--a>=0;){var l=this[e]&16383,h=this[e++]>>14,v=c*l+h*s;l=s*l+((v&16383)<<14)+r[n]+i,i=(l>>28)+(v>>14)+c*h,r[n++]=l&268435455}return i}$2&&kc.appName=="Microsoft Internet Explorer"?(ee.prototype.am=i8,oa=30):$2&&kc.appName!="Netscape"?(ee.prototype.am=n8,oa=26):(ee.prototype.am=s8,oa=28);ee.prototype.DB=oa;ee.prototype.DM=(1<=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s}function o8(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}function aa(e){var t=lt();return t.fromInt(e),t}function c8(e,t){var r;if(t==16)r=4;else if(t==8)r=3;else if(t==256)r=8;else if(t==2)r=1;else if(t==32)r=5;else if(t==4)r=2;else{this.fromRadix(e,t);return}this.t=0,this.s=0;for(var n=e.length,i=!1,a=0;--n>=0;){var s=r==8?e[n]&255:O2(e,n);if(s<0){e.charAt(n)=="-"&&(i=!0);continue}i=!1,a==0?this[this.t++]=s:a+r>this.DB?(this[this.t-1]|=(s&(1<>this.DB-a):this[this.t-1]|=s<=this.DB&&(a-=this.DB)}r==8&&e[0]&128&&(this.s=-1,a>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t}function f8(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(e==16)t=4;else if(e==8)t=3;else if(e==2)t=1;else if(e==32)t=5;else if(e==4)t=2;else return this.toRadix(e);var r=(1<0)for(c>c)>0&&(i=!0,a=Ss(n));s>=0;)c>(c+=this.DB-t)):(n=this[s]>>(c-=t)&r,c<=0&&(c+=this.DB,--s)),n>0&&(i=!0),i&&(a+=Ss(n));return i?a:"0"}function h8(){var e=lt();return ee.ZERO.subTo(this,e),e}function p8(){return this.s<0?this.negate():this}function d8(e){var t=this.s-e.s;if(t!=0)return t;var r=this.t;if(t=r-e.t,t!=0)return this.s<0?-t:t;for(;--r>=0;)if((t=this[r]-e[r])!=0)return t;return 0}function Mf(e){var t=1,r;return(r=e>>>16)!=0&&(e=r,t+=16),(r=e>>8)!=0&&(e=r,t+=8),(r=e>>4)!=0&&(e=r,t+=4),(r=e>>2)!=0&&(e=r,t+=2),(r=e>>1)!=0&&(e=r,t+=1),t}function g8(){return this.t<=0?0:this.DB*(this.t-1)+Mf(this[this.t-1]^this.s&this.DM)}function m8(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s}function v8(e,t){for(var r=e;r=0;--c)t[c+a+1]=this[c]>>n|s,s=(this[c]&i)<=0;--c)t[c]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()}function A8(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t){t.t=0;return}var n=e%this.DB,i=this.DB-n,a=(1<>n;for(var s=r+1;s>n;n>0&&(t[this.t-r-1]|=(this.s&a)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()}function y8(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()}function b8(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(l,a),i.lShiftTo(l,r)):(n.copyTo(a),i.copyTo(r));var h=a.t,v=a[h-1];if(v!=0){var E=v*(1<1?a[h-2]>>this.F2:0),p=this.FV/E,f=(1<=0&&(r[r.t++]=1,r.subTo(w,r)),ee.ONE.dlShiftTo(h,w),w.subTo(a,a);a.t=0;){var S=r[--g]==v?this.DM:Math.floor(r[g]*p+(r[g-1]+A)*f);if((r[g]+=a.am(0,S,r,y,0,h))0&&r.rShiftTo(l,r),s<0&&ee.ZERO.subTo(r,r)}}}function C8(e){var t=lt();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(ee.ZERO)>0&&e.subTo(t,t),t}function ou(e){this.m=e}function F8(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e}function _8(e){return e}function I8(e){e.divRemTo(this.m,null,e)}function D8(e,t,r){e.multiplyTo(t,r),this.reduce(r)}function B8(e,t){e.squareTo(t),this.reduce(t)}ou.prototype.convert=F8;ou.prototype.revert=_8;ou.prototype.reduce=I8;ou.prototype.mulTo=D8;ou.prototype.sqrTo=B8;function P8(){if(this.t<1)return 0;var e=this[0];if(!(e&1))return 0;var t=e&3;return t=t*(2-(e&15)*t)&15,t=t*(2-(e&255)*t)&255,t=t*(2-((e&65535)*t&65535))&65535,t=t*(2-e*t%this.DV)%this.DV,t>0?this.DV-t:-t}function cu(e){this.m=e,this.mp=e.invDigit(),this.mpl=this.mp&32767,this.mph=this.mp>>15,this.um=(1<0&&this.m.subTo(t,t),t}function R8(e){var t=lt();return e.copyTo(t),this.reduce(t),t}function T8(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(r=t+this.m.t,e[r]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)}function x8(e,t){e.squareTo(t),this.reduce(t)}function O8(e,t,r){e.multiplyTo(t,r),this.reduce(r)}cu.prototype.convert=$8;cu.prototype.revert=R8;cu.prototype.reduce=T8;cu.prototype.mulTo=O8;cu.prototype.sqrTo=x8;function N8(){return(this.t>0?this[0]&1:this.s)==0}function k8(e,t){if(e>4294967295||e<1)return ee.ONE;var r=lt(),n=lt(),i=t.convert(this),a=Mf(e)-1;for(i.copyTo(r);--a>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var s=r;r=n,n=s}return t.revert(r)}function L8(e,t){var r;return e<256||t.isEven()?r=new ou(t):r=new cu(t),this.exp(e,r)}ee.prototype.copyTo=u8;ee.prototype.fromInt=o8;ee.prototype.fromString=c8;ee.prototype.clamp=l8;ee.prototype.dlShiftTo=m8;ee.prototype.drShiftTo=v8;ee.prototype.lShiftTo=w8;ee.prototype.rShiftTo=A8;ee.prototype.subTo=E8;ee.prototype.multiplyTo=y8;ee.prototype.squareTo=S8;ee.prototype.divRemTo=b8;ee.prototype.invDigit=P8;ee.prototype.isEven=N8;ee.prototype.exp=k8;ee.prototype.toString=f8;ee.prototype.negate=h8;ee.prototype.abs=p8;ee.prototype.compareTo=d8;ee.prototype.bitLength=g8;ee.prototype.mod=C8;ee.prototype.modPowInt=L8;ee.ZERO=aa(0);ee.ONE=aa(1);function U8(){var e=lt();return this.copyTo(e),e}function H8(){if(this.s<0){if(this.t==1)return this[0]-this.DV;if(this.t==0)return-1}else{if(this.t==1)return this[0];if(this.t==0)return 0}return(this[1]&(1<<32-this.DB)-1)<>24}function M8(){return this.t==0?this.s:this[0]<<16>>16}function q8(e){return Math.floor(Math.LN2*this.DB/Math.log(e))}function K8(){return this.s<0?-1:this.t<=0||this.t==1&&this[0]<=0?0:1}function V8(e){if(e==null&&(e=10),this.signum()==0||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=aa(r),i=lt(),a=lt(),s="";for(this.divRemTo(n,i,a);i.signum()>0;)s=(r+a.intValue()).toString(e).substr(1)+s,i.divRemTo(n,i,a);return a.intValue().toString(e)+s}function G8(e,t){this.fromInt(0),t==null&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,a=0,s=0,c=0;c=r&&(this.dMultiply(n),this.dAddOffset(s,0),a=0,s=0)}a>0&&(this.dMultiply(Math.pow(t,a)),this.dAddOffset(s,0)),i&&ee.ZERO.subTo(this,this)}function z8(e,t,r){if(typeof t=="number")if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(ee.ONE.shiftLeft(e-1),Hd,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(ee.ONE.shiftLeft(e-1),this);else{var n=new Array,i=e&7;n.length=(e>>3)+1,t.nextBytes(n),i>0?n[0]&=(1<0)for(r>r)!=(this.s&this.DM)>>r&&(t[i++]=n|this.s<=0;)r<8?(n=(this[e]&(1<>(r+=this.DB-8)):(n=this[e]>>(r-=8)&255,r<=0&&(r+=this.DB,--e)),n&128&&(n|=-256),i==0&&(this.s&128)!=(n&128)&&++i,(i>0||n!=this.s)&&(t[i++]=n);return t}function W8(e){return this.compareTo(e)==0}function X8(e){return this.compareTo(e)<0?this:e}function J8(e){return this.compareTo(e)>0?this:e}function Z8(e,t,r){var n,i,a=Math.min(e.t,this.t);for(n=0;n>=16,t+=16),e&255||(e>>=8,t+=8),e&15||(e>>=4,t+=4),e&3||(e>>=2,t+=2),e&1||++t,t}function oI(){for(var e=0;e=this.t?this.s!=0:(this[t]&1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()}function vI(e){var t=lt();return this.addTo(e,t),t}function wI(e){var t=lt();return this.subTo(e,t),t}function AI(e){var t=lt();return this.multiplyTo(e,t),t}function EI(){var e=lt();return this.squareTo(e),e}function yI(e){var t=lt();return this.divRemTo(e,t,null),t}function SI(e){var t=lt();return this.divRemTo(e,null,t),t}function bI(e){var t=lt(),r=lt();return this.divRemTo(e,t,r),new Array(t,r)}function CI(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()}function FI(e,t){if(e!=0){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]}}function Uc(){}function L2(e){return e}function _I(e,t,r){e.multiplyTo(t,r)}function II(e,t){e.squareTo(t)}Uc.prototype.convert=L2;Uc.prototype.revert=L2;Uc.prototype.mulTo=_I;Uc.prototype.sqrTo=II;function DI(e){return this.exp(e,new Uc)}function BI(e,t,r){var n=Math.min(this.t+e.t,t);for(r.s=0,r.t=n;n>0;)r[--n]=0;var i;for(i=r.t-this.t;n=0;)r[n]=0;for(n=Math.max(t-this.t,0);n2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=lt();return e.copyTo(t),this.reduce(t),t}function RI(e){return e}function TI(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)}function xI(e,t){e.squareTo(t),this.reduce(t)}function OI(e,t,r){e.multiplyTo(t,r),this.reduce(r)}So.prototype.convert=$I;So.prototype.revert=RI;So.prototype.reduce=TI;So.prototype.mulTo=OI;So.prototype.sqrTo=xI;function NI(e,t){var r=e.bitLength(),n,i=aa(1),a;if(r<=0)return i;r<18?n=1:r<48?n=3:r<144?n=4:r<768?n=5:n=6,r<8?a=new ou(t):t.isEven()?a=new So(t):a=new cu(t);var s=new Array,c=3,l=n-1,h=(1<1){var v=lt();for(a.sqrTo(s[1],v);c<=h;)s[c]=lt(),a.mulTo(v,s[c-2],s[c]),c+=2}var E=e.t-1,p,f=!0,A=lt(),g;for(r=Mf(e[E])-1;E>=0;){for(r>=l?p=e[E]>>r-l&h:(p=(e[E]&(1<0&&(p|=e[E-1]>>this.DB+r-l)),c=n;!(p&1);)p>>=1,--c;if((r-=c)<0&&(r+=this.DB,--E),f)s[p].copyTo(i),f=!1;else{for(;c>1;)a.sqrTo(i,A),a.sqrTo(A,i),c-=2;c>0?a.sqrTo(i,A):(g=i,i=A,A=g),a.mulTo(A,s[p],i)}for(;E>=0&&!(e[E]&1<0&&(t.rShiftTo(a,t),r.rShiftTo(a,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return a>0&&r.lShiftTo(a,r),r}function LI(e){if(e<=0)return 0;var t=this.DV%e,r=this.s<0?e-1:0;if(this.t>0)if(t==0)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r}function UI(e){var t=e.isEven();if(this.isEven()&&t||e.signum()==0)return ee.ZERO;for(var r=e.clone(),n=this.clone(),i=aa(1),a=aa(0),s=aa(0),c=aa(1);r.signum()!=0;){for(;r.isEven();)r.rShiftTo(1,r),t?((!i.isEven()||!a.isEven())&&(i.addTo(this,i),a.subTo(e,a)),i.rShiftTo(1,i)):a.isEven()||a.subTo(e,a),a.rShiftTo(1,a);for(;n.isEven();)n.rShiftTo(1,n),t?((!s.isEven()||!c.isEven())&&(s.addTo(this,s),c.subTo(e,c)),s.rShiftTo(1,s)):c.isEven()||c.subTo(e,c),c.rShiftTo(1,c);r.compareTo(n)>=0?(r.subTo(n,r),t&&i.subTo(s,i),a.subTo(c,a)):(n.subTo(r,n),t&&s.subTo(i,s),c.subTo(a,c))}if(n.compareTo(ee.ONE)!=0)return ee.ZERO;if(c.compareTo(e)>=0)return c.subtract(e);if(c.signum()<0)c.addTo(e,c);else return c;return c.signum()<0?c.add(e):c}var nn=[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],HI=(1<<26)/nn[nn.length-1];function jI(e){var t,r=this.abs();if(r.t==1&&r[0]<=nn[nn.length-1]){for(t=0;t>1,e>nn.length&&(e=nn.length);for(var i=lt(),a=0;a>8&255,On[br++]^=e>>16&255,On[br++]^=e>>24&255,br>=Od&&(br-=Od)}function Md(){GI(new Date().getTime())}if(On==null){if(On=new Array,br=0,vo!==void 0&&(vo.crypto!==void 0||vo.msCrypto!==void 0)){if($d=vo.crypto||vo.msCrypto,$d.getRandomValues)for(Rd=new Uint8Array(32),$d.getRandomValues(Rd),si=0;si<32;++si)On[br++]=Rd[si];else if(kc.appName=="Netscape"&&kc.appVersion<"5")for(Td=vo.crypto.random(32),si=0;si>>8,On[br++]=si&255;br=0,Md()}var si,$d,Rd,Td;function zI(){if(kf==null){for(Md(),kf=VI(),kf.init(On),br=0;br0&&t.length>0)this.n=wn(e,16),this.e=parseInt(t,16);else throw"Invalid RSA public key"}function XI(e){return e.modPowInt(this.e,this.n)}ze.prototype.doPublic=XI;ze.prototype.setPublic=WI;ze.prototype.type="RSA";function JI(e,t,r){if(this.isPrivate=!0,typeof e!="string")this.n=e,this.e=t,this.d=r;else if(e!=null&&t!=null&&e.length>0&&t.length>0)this.n=wn(e,16),this.e=parseInt(t,16),this.d=wn(r,16);else throw"Invalid RSA private key"}function ZI(e,t,r,n,i,a,s,c){if(this.isPrivate=!0,this.isPublic=!1,e==null)throw"RSASetPrivateEx N == null";if(t==null)throw"RSASetPrivateEx E == null";if(e.length==0)throw"RSASetPrivateEx N.length == 0";if(t.length==0)throw"RSASetPrivateEx E.length == 0";if(e!=null&&t!=null&&e.length>0&&t.length>0)this.n=wn(e,16),this.e=parseInt(t,16),this.d=wn(r,16),this.p=wn(n,16),this.q=wn(i,16),this.dmp1=wn(a,16),this.dmq1=wn(s,16),this.coeff=wn(c,16);else throw"Invalid RSA private key in RSASetPrivateEx"}function QI(e,t){var r=new bo,n=e>>1;this.e=parseInt(t,16);for(var i=new ee(t,16),a=e/2-100,s=ee.ONE.shiftLeft(a);;){for(;this.p=new ee(e-n,1,r),!(this.p.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.p.isProbablePrime(10)););for(;this.q=new ee(n,1,r),!(this.q.subtract(ee.ONE).gcd(i).compareTo(ee.ONE)==0&&this.q.isProbablePrime(10)););if(this.p.compareTo(this.q)<=0){var c=this.p;this.p=this.q,this.q=c}var l=this.q.subtract(this.p).abs();if(!(l.bitLength()0;--h){i=i.twice();var v=r.testBit(h),E=t.testBit(h);v!=E&&(i=i.add(v?this:n))}for(h=s.bitLength()-2;h>0;--h){c=c.twice();var p=s.testBit(h),f=a.testBit(h);p!=f&&(c=c.add(p?c:l))}return i}function v9(e,t,r){var n;e.bitLength()>r.bitLength()?n=e.bitLength()-1:n=r.bitLength()-1;for(var i=this.curve.getInfinity(),a=this.add(t);n>=0;)i=i.twice(),e.testBit(n)?r.testBit(n)?i=i.add(a):i=i.add(this):r.testBit(n)&&(i=i.add(t)),--n;return i}mt.prototype.getX=c9;mt.prototype.getY=l9;mt.prototype.equals=f9;mt.prototype.isInfinity=h9;mt.prototype.negate=p9;mt.prototype.add=d9;mt.prototype.twice=g9;mt.prototype.multiply=m9;mt.prototype.multiplyTwo=v9;function Cs(e,t,r){this.q=e,this.a=this.fromBigInteger(t),this.b=this.fromBigInteger(r),this.infinity=new mt(this,null,null)}function w9(){return this.q}function A9(){return this.a}function E9(){return this.b}function y9(e){return e==this?!0:this.q.equals(e.q)&&this.a.equals(e.a)&&this.b.equals(e.b)}function S9(){return this.infinity}function b9(e){return new gr(this.q,e)}function C9(e){switch(parseInt(e.substr(0,2),16)){case 0:return this.infinity;case 2:case 3:var t=e.substr(0,2),r=e.substr(2),n=this.fromBigInteger(new ee(h,16)),i=this.getA(),a=this.getB(),s=n.square().add(i).multiply(n).add(a),c=s.sqrt();return t=="03"&&(c=c.negate()),new mt(this,n,c);case 4:case 6:case 7:var l=(e.length-2)/2,h=e.substr(2,l),v=e.substr(l+2,l);return new mt(this,this.fromBigInteger(new ee(h,16)),this.fromBigInteger(new ee(v,16)));default:return null}}Cs.prototype.getQ=w9;Cs.prototype.getA=A9;Cs.prototype.getB=E9;Cs.prototype.equals=y9;Cs.prototype.getInfinity=S9;Cs.prototype.fromBigInteger=b9;Cs.prototype.decodePointHex=C9;gr.prototype.getByteLength=function(){return Math.floor((this.toBigInteger().bitLength()+7)/8)};mt.prototype.getEncoded=function(e){var t=function(a,s){var c=a.toByteArrayUnsigned();if(sc.length;)c.unshift(0);return c},r=this.getX().toBigInteger(),n=this.getY().toBigInteger(),i=t(r,32);return e?n.isEven()?i.unshift(2):i.unshift(3):(i.unshift(4),i=i.concat(t(n,32))),i};mt.decodeFrom=function(e,t){var r=t[0],n=t.length-1,i=t.slice(1,1+n/2),a=t.slice(1+n/2,1+n);i.unshift(0),a.unshift(0);var s=new ee(i),c=new ee(a);return new mt(e,e.fromBigInteger(s),e.fromBigInteger(c))};mt.decodeFromHex=function(e,t){var r=t.substr(0,2),n=t.length-2,i=t.substr(2,n/2),a=t.substr(2+n/2,n/2),s=new ee(i,16),c=new ee(a,16);return new mt(e,e.fromBigInteger(s),e.fromBigInteger(c))};mt.prototype.add2D=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;if(this.x.equals(e.x))return this.y.equals(e.y)?this.twice():this.curve.getInfinity();var t=e.x.subtract(this.x),r=e.y.subtract(this.y),n=r.divide(t),i=n.square().subtract(this.x).subtract(e.x),a=n.multiply(this.x.subtract(i)).subtract(this.y);return new mt(this.curve,i,a)};mt.prototype.twice2D=function(){if(this.isInfinity())return this;if(this.y.toBigInteger().signum()==0)return this.curve.getInfinity();var e=this.curve.fromBigInteger(ee.valueOf(2)),t=this.curve.fromBigInteger(ee.valueOf(3)),r=this.x.square().multiply(t).add(this.curve.a).divide(this.y.multiply(e)),n=r.square().subtract(this.x.multiply(e)),i=r.multiply(this.x.subtract(n)).subtract(this.y);return new mt(this.curve,n,i)};mt.prototype.multiply2D=function(e){if(this.isInfinity())return this;if(e.signum()==0)return this.curve.getInfinity();var t=e,r=t.multiply(new ee("3")),n=this.negate(),i=this,a;for(a=r.bitLength()-2;a>0;--a){i=i.twice();var s=r.testBit(a),c=t.testBit(a);s!=c&&(i=i.add2D(s?this:n))}return i};mt.prototype.isOnCurve=function(){var e=this.getX().toBigInteger(),t=this.getY().toBigInteger(),r=this.curve.getA().toBigInteger(),n=this.curve.getB().toBigInteger(),i=this.curve.getQ(),a=t.multiply(t).mod(i),s=e.multiply(e).multiply(e).add(r.multiply(e)).add(n).mod(i);return a.equals(s)};mt.prototype.toString=function(){return"("+this.getX().toBigInteger().toString()+","+this.getY().toBigInteger().toString()+")"};mt.prototype.validate=function(){var e=this.curve.getQ();if(this.isInfinity())throw new Error("Point is at infinity.");var t=this.getX().toBigInteger(),r=this.getY().toBigInteger();if(t.compareTo(ee.ONE)<0||t.compareTo(e.subtract(ee.ONE))>0)throw new Error("x coordinate out of bounds");if(r.compareTo(ee.ONE)<0||r.compareTo(e.subtract(ee.ONE))>0)throw new Error("y coordinate out of bounds");if(!this.isOnCurve())throw new Error("Point is not on the curve.");if(this.multiply(e).isInfinity())throw new Error("Point is not a scalar multiple of G.");return!0};var U2=function(){var e="(?:-?\\b(?:0|[1-9][0-9]*)(?:\\.[0-9]+)?(?:[eE][+-]?[0-9]+)?\\b)",t='(?:[^\\0-\\x08\\x0a-\\x1f"\\\\]|\\\\(?:["/\\\\bfnrt]|u[0-9A-Fa-f]{4}))',r='(?:"'+t+'*")',n=new RegExp("(?:false|true|null|[\\{\\}\\[\\]]|"+e+"|"+r+")","g"),i=new RegExp("\\\\(?:([^u])|u(.{4}))","g"),a={'"':'"',"/":"/","\\":"\\",b:"\b",f:"\f",n:` `,r:"\r",t:" "};function s(E,p,f){return p?a[p]:String.fromCharCode(parseInt(f,16))}var c=new String(""),l="\\",h={"{":Object,"[":Array},v=Object.hasOwnProperty;return function(E,p){var f=E.match(n),A,g=f[0],y=!1;g==="{"?A={}:g==="["?A=[]:(A=[],y=!0);for(var w,S=[A],_=1-y,I=f.length;_=0;)delete P[L[Z]]}return p.call(z,F,P)};A=q({"":A},"")}return A}}();(typeof d>"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});d.asn1.ASN1Util=new function(){this.integerToByteHex=function(e){var t=e.toString(16);return t.length%2==1&&(t="0"+t),t},this.bigIntToMinTwosComplementsHex=function(e){return jc(e)},this.getPEMStringFromHex=function(e,t){return Gr(e,t)},this.newObject=function(e){var t=d,r=t.asn1,n=r.ASN1Object,i=r.DERBoolean,a=r.DERInteger,s=r.DERBitString,c=r.DEROctetString,l=r.DERNull,h=r.DERObjectIdentifier,v=r.DEREnumerated,E=r.DERUTF8String,p=r.DERNumericString,f=r.DERPrintableString,A=r.DERTeletexString,g=r.DERIA5String,y=r.DERUTCTime,w=r.DERGeneralizedTime,S=r.DERVisibleString,_=r.DERBMPString,I=r.DERSequence,B=r.DERSet,q=r.DERTaggedObject,z=r.ASN1Util.newObject;if(e instanceof r.ASN1Object)return e;var F=Object.keys(e);if(F.length!=1)throw new Error("key of param shall be only one.");var P=F[0];if(":asn1:bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:visstr:bmpstr:seq:set:tag:".indexOf(":"+P+":")==-1)throw new Error("undefined key: "+P);if(P=="bool")return new i(e[P]);if(P=="int")return new a(e[P]);if(P=="bitstr")return new s(e[P]);if(P=="octstr")return new c(e[P]);if(P=="null")return new l(e[P]);if(P=="oid")return new h(e[P]);if(P=="enum")return new v(e[P]);if(P=="utf8str")return new E(e[P]);if(P=="numstr")return new p(e[P]);if(P=="prnstr")return new f(e[P]);if(P=="telstr")return new A(e[P]);if(P=="ia5str")return new g(e[P]);if(P=="utctime")return new y(e[P]);if(P=="gentime")return new w(e[P]);if(P=="visstr")return new S(e[P]);if(P=="bmpstr")return new _(e[P]);if(P=="asn1")return new n(e[P]);if(P=="seq"){for(var L=e[P],H=[],K=0;K"u"||this.hV==null)throw new Error("this.hV is null or undefined");if(this.hV.length%2==1)throw new Error("value hex must be even length: n="+a.length+",v="+this.hV);var s=this.hV.length/2,c=s.toString(16);if(c.length%2==1&&(c="0"+c),s<128)return c;var l=c.length/2;if(l>15)throw new Error("ASN.1 length too long to represent by 8x: n = "+s.toString(16));var h=128+l;return h.toString(16)+c},this.tohex=function(){return(this.hTLV==null||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.getValueHex=function(){return this.tohex(),this.hV},this.getFreshValueHex=function(){return""},this.setByParam=function(s){this.params=s},e!=null&&e.tlv!=null&&(this.hTLV=e.tlv,this.isModified=!1)};d.asn1.DERAbstractString=function(e){d.asn1.DERAbstractString.superclass.constructor.call(this);var t=null,r=null;this.getString=function(){return this.s},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.s=n,this.hV=Kf(this.s).toLowerCase()},this.setStringHex=function(n){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=n},this.getFreshValueHex=function(){return this.hV},typeof e<"u"&&(typeof e=="string"?this.setString(e):typeof e.str<"u"?this.setString(e.str):typeof e.hex<"u"&&this.setStringHex(e.hex))};he(d.asn1.DERAbstractString,d.asn1.ASN1Object);d.asn1.DERAbstractTime=function(e){d.asn1.DERAbstractTime.superclass.constructor.call(this);var t=null,r=null;this.localDateToUTC=function(n){var i=n.getTime()+n.getTimezoneOffset()*6e4,a=new Date(i);return a},this.formatDate=function(n,i,a){var s=this.zeroPadding,c=this.localDateToUTC(n),l=String(c.getFullYear());i=="utc"&&(l=l.substr(2,2));var h=s(String(c.getMonth()+1),2),v=s(String(c.getDate()),2),E=s(String(c.getHours()),2),p=s(String(c.getMinutes()),2),f=s(String(c.getSeconds()),2),A=l+h+v+E+p+f;if(a===!0){var g=c.getMilliseconds();if(g!=0){var y=s(String(g),3);y=y.replace(/[0]+$/,""),A=A+"."+y}}return A+"Z"},this.zeroPadding=function(n,i){return n.length>=i?n:new Array(i-n.length+1).join("0")+n},this.setByParam=function(n){this.hV=null,this.hTLV=null,this.params=n},this.getString=function(){},this.setString=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.str=n},this.setByDate=function(n){this.hTLV=null,this.isModified=!0,this.params==null&&(this.params={}),this.params.date=n},this.setByDateValue=function(n,i,a,s,c,l){var h=new Date(Date.UTC(n,i-1,a,s,c,l,0));this.setByDate(h)},this.getFreshValueHex=function(){return this.hV}};he(d.asn1.DERAbstractTime,d.asn1.ASN1Object);d.asn1.DERAbstractStructured=function(e){d.asn1.DERAbstractString.superclass.constructor.call(this);var t=null;this.setByASN1ObjectArray=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array=r},this.appendASN1Object=function(r){this.hTLV=null,this.isModified=!0,this.asn1Array.push(r)},this.asn1Array=new Array,typeof e<"u"&&typeof e.array<"u"&&(this.asn1Array=e.array)};he(d.asn1.DERAbstractStructured,d.asn1.ASN1Object);d.asn1.DERBoolean=function(e){d.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",e==!1?this.hTLV="010100":this.hTLV="0101ff"};he(d.asn1.DERBoolean,d.asn1.ASN1Object);d.asn1.DERInteger=function(e){d.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.params=null;var t=jc;this.setByBigInteger=function(r){this.isModified=!0,this.params={bigint:r}},this.setByInteger=function(r){this.isModified=!0,this.params=r},this.setValueHex=function(r){this.isModified=!0,this.params={hex:r}},this.getFreshValueHex=function(){var r=this.params,n=null;if(r==null)throw new Error("value not set");if(typeof r=="object"&&r.hex!=null)return this.hV=r.hex,this.hV;if(typeof r=="number")n=new ee(String(r),10);else if(r.int!=null)n=new ee(String(r.int),10);else if(r.bigint!=null)n=r.bigint;else throw new Error("wrong parameter");return this.hV=t(n),this.hV},e!=null&&(this.params=e)};he(d.asn1.DERInteger,d.asn1.ASN1Object);d.asn1.DERBitString=function(e){if(e!==void 0&&typeof e.obj<"u"){var t=d.asn1.ASN1Util.newObject(e.obj);e.hex="00"+t.tohex()}d.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(r){this.hTLV=null,this.isModified=!0,this.hV=r},this.setUnusedBitsAndHexValue=function(r,n){if(r<0||7=a)break}return n};Ae.getNthChildIdx=function(e,t,r){var n=Ae.getChildIdx(e,t);return n[r]};Ae.getIdxbyList=function(e,t,r,n){var i=Ae,a,s;return r.length==0?n!==void 0&&e.substr(t,2)!==n?-1:t:(a=r.shift(),s=i.getChildIdx(e,t),a>=s.length?-1:i.getIdxbyList(e,s[a],r,n))};Ae.getIdxbyListEx=function(e,t,r,n){var i=Ae,a,s;if(r.length==0)return n!==void 0&&e.substr(t,2)!==n?-1:t;a=r.shift(),s=i.getChildIdx(e,t);for(var c=0,l=0;l=e.length?null:i.getTLV(e,a)};Ae.getTLVbyListEx=function(e,t,r,n){var i=Ae,a=i.getIdxbyListEx(e,t,r,n);return a==-1?null:i.getTLV(e,a)};Ae.getVbyList=function(e,t,r,n,i){var a=Ae,s,c;return s=a.getIdxbyList(e,t,r,n),s==-1||s>=e.length?null:(c=a.getV(e,s),i===!0&&(c=c.substr(2)),c)};Ae.getVbyListEx=function(e,t,r,n,i){var a=Ae,s,c,l;return s=a.getIdxbyListEx(e,t,r,n),s==-1?null:(l=a.getV(e,s),e.substr(s,2)=="03"&&i!==!1&&(l=l.substr(2)),l)};Ae.getInt=function(e,t,r){r==null&&(r=-1);try{var n=e.substr(t,2);if(n!="02"&&n!="03")return r;var i=Ae.getV(e,t);return n=="02"?parseInt(i,16):Y2(i)}catch{return r}};Ae.getOID=function(e,t,r){r==null&&(r=null);try{if(e.substr(t,2)!="06")return r;var n=Ae.getV(e,t);return Wf(n)}catch{return r}};Ae.getOIDName=function(e,t,r){r==null&&(r=null);try{var n=Ae.getOID(e,t,r);if(n==r)return r;var i=d.asn1.x509.OID.oid2name(n);return i==""?n:i}catch{return r}};Ae.getString=function(e,t,r){r==null&&(r=null);try{var n=Ae.getV(e,t);return En(n)}catch{return r}};Ae.hextooidstr=function(e){var t=function(E,p){return E.length>=p?E:new Array(p-E.length+1).join("0")+E},r=[],n=e.substr(0,2),i=parseInt(n,16);r[0]=new String(Math.floor(i/40)),r[1]=new String(i%40);for(var a=e.substr(2),s=[],c=0;c0&&(v=v+"."+l.join(".")),v};Ae.dump=function(e,t,r,n){var i=Ae,a=i.getV,s=i.dump,c=i.getChildIdx,l=e;e instanceof d.asn1.ASN1Object&&(l=e.tohex());var h=function(z,F){if(z.length<=F*2)return z;var P=z.substr(0,F)+"..(total "+z.length/2+"bytes).."+z.substr(z.length-F,F);return P};t===void 0&&(t={ommit_long_octet:32}),r===void 0&&(r=0),n===void 0&&(n="");var v=t.ommit_long_octet,B=l.substr(r,2);if(B=="01"){var E=a(l,r);return E=="00"?n+`BOOLEAN FALSE `:n+`BOOLEAN TRUE `}if(B=="02"){var E=a(l,r);return n+"INTEGER "+h(E,v)+` `}if(B=="03"){var E=a(l,r);if(i.isASN1HEX(E.substr(2))){var p=n+`BITSTRING, encapsulates `;return p=p+s(E.substr(2),t,0,n+" "),p}else return n+"BITSTRING "+h(E,v)+` `}if(B=="04"){var E=a(l,r);if(i.isASN1HEX(E)){var p=n+`OCTETSTRING, encapsulates `;return p=p+s(E,t,0,n+" "),p}else return n+"OCTETSTRING "+h(E,v)+` `}if(B=="05")return n+`NULL `;if(B=="06"){var f=a(l,r),A=d.asn1.ASN1Util.oidHexToInt(f),g=d.asn1.x509.OID.oid2name(A),y=A.replace(/\./g," ");return g!=""?n+"ObjectIdentifier "+g+" ("+y+`) `:n+"ObjectIdentifier ("+y+`) `}if(B=="0a")return n+"ENUMERATED "+parseInt(a(l,r))+` `;if(B=="0c")return n+"UTF8String '"+Ft(a(l,r))+`' `;if(B=="13")return n+"PrintableString '"+Ft(a(l,r))+`' `;if(B=="14")return n+"TeletexString '"+Ft(a(l,r))+`' `;if(B=="16")return n+"IA5String '"+Ft(a(l,r))+`' `;if(B=="17")return n+"UTCTime "+Ft(a(l,r))+` `;if(B=="18")return n+"GeneralizedTime "+Ft(a(l,r))+` `;if(B=="1a")return n+"VisualString '"+Ft(a(l,r))+`' `;if(B=="1e")return n+"BMPString '"+Gd(a(l,r))+`' `;if(B=="30"){if(l.substr(r,4)=="3000")return n+`SEQUENCE {} `;var p=n+`SEQUENCE `,w=c(l,r),S=t;if((w.length==2||w.length==3)&&l.substr(w[0],2)=="06"&&l.substr(w[w.length-1],2)=="04"){var g=i.oidname(a(l,w[0])),_=JSON.parse(JSON.stringify(t));_.x509ExtName=g,S=_}for(var I=0;I4?{enum:{hex:w}}:{enum:parseInt(w,16)};if(g=="30"||g=="31")return y[f[g]]=A(e),y;if(g=="14"){var q=p(w);return y[f[g]]={str:q},y}else if(g=="1e"){var q=E(w);return y[f[g]]={str:q},y}else if(":0c:12:13:16:17:18:1a:".indexOf(g)!=-1){var q=v(w);return y[f[g]]={str:q},y}else if(g.match(/^8[0-9]$/)){var q=v(w);return q==null|q==""?{tag:{tag:g,explicit:!1,hex:w}}:q.match(/[\x00-\x1F\x7F-\x9F]/)!=null||q.match(/[\u0000-\u001F\u0080–\u009F]/)!=null?{tag:{tag:g,explicit:!1,hex:w}}:{tag:{tag:g,explicit:!1,str:q}}}else if(g.match(/^a[0-9]$/))try{if(!n(w))throw new Error("not encap");return{tag:{tag:g,explicit:!0,obj:r(w)}}}catch{return{tag:{tag:g,explicit:!0,hex:w}}}else{var z=new d.asn1.ASN1Object;z.hV=w;var F=z.getLengthHexFromValue();return{asn1:{tlv:g+F+w}}}}}};Ae.isContextTag=function(e,t){e=e.toLowerCase();var r,n;try{r=parseInt(e,16)}catch{return-1}if(t===void 0)return(r&192)==128;try{var i=t.match(/^\[[0-9]+\]$/);return i==null||(n=parseInt(t.substr(1,t.length-1),10),n>31)?!1:(r&192)==128&&(r&31)==n}catch{return!1}};Ae.isASN1HEX=function(e){var t=Ae;if(e.length%2==1)return!1;var r=t.getVblen(e,0),n=e.substr(0,2),i=t.getL(e,0),a=e.length-n.length-i.length;return a==r*2};Ae.checkStrictDER=function(e,t,r,n,i){var a=Ae;if(r===void 0){if(typeof e!="string")throw new Error("not hex string");if(e=e.toLowerCase(),!d.lang.String.isHex(e))throw new Error("not hex string");r=e.length,n=e.length/2,n<128?i=1:i=Math.ceil(n.toString(16))+1}var s=a.getL(e,t);if(s.length>i*2)throw new Error("L of TLV too long: idx="+t);var c=a.getVblen(e,t);if(c>n)throw new Error("value of L too long than hex: idx="+t);var l=a.getTLV(e,t),h=l.length-2-a.getL(e,t).length;if(h!==c*2)throw new Error("V string length and L's value not the same:"+h+"/"+c*2);if(t===0&&e.length!=l.length)throw new Error("total length and TLV length unmatch:"+e.length+"!="+l.length);var v=e.substr(t,2);if(v==="02"){var E=a.getVidx(e,t);if(e.substr(E,2)=="00"&&e.charCodeAt(E+2)<56)throw new Error("not least zeros for DER INTEGER")}if(parseInt(v,16)&32){for(var p=a.getVblen(e,t),f=0,A=a.getChildIdx(e,t),g=0;g"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.x509>"u"||!d.asn1.x509)&&(d.asn1.x509={});d.asn1.x509.Certificate=function(e){d.asn1.x509.Certificate.superclass.constructor.call(this);var t=d,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.x509,s=a.TBSCertificate,c=a.AlgorithmIdentifier;this.params=void 0,this.setByParam=function(l){this.params=l},this.sign=function(){var l=this.params,h=l.sigalg;l.sigalg.name!=null&&(h=l.sigalg.name);var v=l.tbsobj.tohex(),E=new d.crypto.Signature({alg:h});E.init(l.cakey),E.updateHex(v),l.sighex=E.sign()},this.getPEM=function(){return Gr(this.tohex(),"CERTIFICATE")},this.tohex=function(){var l=this.params;if((l.tbsobj==null||l.tbsobj==null)&&(l.tbsobj=new s(l)),l.sighex==null&&l.cakey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or cakey parameter not defined");var h=[];h.push(l.tbsobj),h.push(new c({name:l.sigalg})),h.push(new n({hex:"00"+l.sighex}));var v=new i({array:h});return v.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&(this.params=e)};he(d.asn1.x509.Certificate,d.asn1.ASN1Object);d.asn1.x509.TBSCertificate=function(e){d.asn1.x509.TBSCertificate.superclass.constructor.call(this);var t=d,r=t.asn1,n=r.x509,i=r.DERTaggedObject,a=r.DERInteger,s=r.DERSequence,c=n.AlgorithmIdentifier,l=n.Time,h=n.X500Name,v=n.Extensions,E=n.SubjectPublicKeyInfo;this.params=null,this.setByParam=function(p){this.params=p},this.tohex=function(){var p=[],f=this.params;if(f.version!=null||f.version!=1){var A=2;f.version!=null&&(A=f.version-1);var g=new i({obj:new a({int:A})});p.push(g)}p.push(new a(f.serial)),p.push(new c({name:f.sigalg})),p.push(new h(f.issuer)),p.push(new s({array:[new l(f.notbefore),new l(f.notafter)]})),p.push(new h(f.subject)),p.push(new E(st.getKey(f.sbjpubkey))),f.ext!==void 0&&f.ext.length>0&&p.push(new i({tag:"a3",obj:new v(f.ext)}));var y=new d.asn1.DERSequence({array:p});return y.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.x509.TBSCertificate,d.asn1.ASN1Object);d.asn1.x509.Extensions=function(e){d.asn1.x509.Extensions.superclass.constructor.call(this);var t=d,r=t.asn1,n=r.DERSequence,i=r.x509;this.aParam=[],this.setByParam=function(a){this.aParam=a},this.tohex=function(){for(var a=[],s=0;s-1&&c.push(new n({int:this.pathLen}));var l=new i({array:c});return this.asn1ExtnValue=l,this.asn1ExtnValue.tohex()},this.oid="2.5.29.19",this.cA=!1,this.pathLen=-1,e!==void 0&&(e.cA!==void 0&&(this.cA=e.cA),e.pathLen!==void 0&&(this.pathLen=e.pathLen))};he(d.asn1.x509.BasicConstraints,d.asn1.x509.Extension);d.asn1.x509.CRLDistributionPoints=function(e){d.asn1.x509.CRLDistributionPoints.superclass.constructor.call(this,e);var t=d,r=t.asn1,n=r.x509;this.getExtnValueHex=function(){return this.asn1ExtnValue.tohex()},this.setByDPArray=function(i){for(var a=[],s=0;s0&&a.push(new r({array:s}))}var l=new r({array:a});return l.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(d.asn1.x509.PolicyInformation,d.asn1.ASN1Object);d.asn1.x509.PolicyQualifierInfo=function(e){d.asn1.x509.PolicyQualifierInfo.superclass.constructor.call(this,e);var t=d.asn1,r=t.DERSequence,n=t.DERIA5String,i=t.DERObjectIdentifier,a=t.x509.UserNotice;this.params=null,this.tohex=function(){if(this.params.cps!==void 0){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.1"}),new n({str:this.params.cps})]});return s.tohex()}if(this.params.unotice!=null){var s=new r({array:[new i({oid:"1.3.6.1.5.5.7.2.2"}),new a(this.params.unotice)]});return s.tohex()}},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(d.asn1.x509.PolicyQualifierInfo,d.asn1.ASN1Object);d.asn1.x509.UserNotice=function(e){d.asn1.x509.UserNotice.superclass.constructor.call(this,e);var t=d.asn1.DERSequence,r=d.asn1.DERInteger,n=d.asn1.x509.DisplayText,i=d.asn1.x509.NoticeReference;this.params=null,this.tohex=function(){var a=[];this.params.noticeref!==void 0&&a.push(new i(this.params.noticeref)),this.params.exptext!==void 0&&a.push(new n(this.params.exptext));var s=new t({array:a});return s.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(this.params=e)};he(d.asn1.x509.UserNotice,d.asn1.ASN1Object);d.asn1.x509.NoticeReference=function(e){d.asn1.x509.NoticeReference.superclass.constructor.call(this,e);var t=d.asn1.DERSequence,r=d.asn1.DERInteger,n=d.asn1.x509.DisplayText;this.params=null,this.tohex=function(){var i=[];if(this.params.org!==void 0&&i.push(new n(this.params.org)),this.params.noticenum!==void 0){for(var a=[],s=this.params.noticenum,c=0;c0)for(var s=0;s0;i++){var a=t.shift();if(r===!0){var s=n.pop(),c=(s+","+a).replace(/\\,/g,",");n.push(c),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}return n=n.map(function(l){return l.replace("/","\\/")}),n.reverse(),"/"+n.join("/")};d.asn1.x509.X500Name.ldapToOneline=function(e){return d.asn1.x509.X500Name.ldapToCompat(e)};d.asn1.x509.RDN=function(e){d.asn1.x509.RDN.superclass.constructor.call(this),this.asn1Array=[],this.paramArray=[],this.sRule="utf8";var t=d.asn1.x509.AttributeTypeAndValue;this.setByParam=function(r){r.rule!==void 0&&(this.sRule=r.rule),r.str!==void 0&&this.addByMultiValuedString(r.str),r.array!==void 0&&(this.paramArray=r.array)},this.addByString=function(r){this.asn1Array.push(new d.asn1.x509.AttributeTypeAndValue({str:r,rule:this.sRule}))},this.addByMultiValuedString=function(r){for(var n=d.asn1.x509.RDN.parseString(r),i=0;i0)for(var r=0;r0;i++){var a=t.shift();if(r===!0){var s=n.pop(),c=(s+"+"+a).replace(/\\\+/g,"+");n.push(c),r=!1}else n.push(a);a.substr(-1,1)==="\\"&&(r=!0)}for(var l=!1,h=[],i=0;n.length>0;i++){var a=n.shift();if(l===!0){var v=h.pop();if(a.match(/"$/)){var c=(v+"+"+a).replace(/^([^=]+)="(.*)"$/,"$1=$2");h.push(c),l=!1}else h.push(v+"+"+a)}else h.push(a);a.match(/^[^=]+="/)&&(l=!0)}return h};d.asn1.x509.AttributeTypeAndValue=function(e){d.asn1.x509.AttributeTypeAndValue.superclass.constructor.call(this),this.sRule="utf8",this.sType=null,this.sValue=null,this.dsType=null;var t=d,r=t.asn1,n=r.DERSequence,i=r.DERUTF8String,a=r.DERPrintableString,s=r.DERTeletexString,c=r.DERIA5String,l=r.DERVisibleString,h=r.DERBMPString,v=t.lang.String.isMail,E=t.lang.String.isPrintable;this.setByParam=function(p){if(p.rule!==void 0&&(this.sRule=p.rule),p.ds!==void 0&&(this.dsType=p.ds),p.value===void 0&&p.str!==void 0){var f=p.str,A=f.match(/^([^=]+)=(.+)$/);if(A)this.sType=A[1],this.sValue=A[2];else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)}else this.sType=p.type,this.sValue=p.value},this.setByString=function(p,f){f!==void 0&&(this.sRule=f);var A=p.match(/^([^=]+)=(.+)$/);if(A)this.setByAttrTypeAndValueStr(A[1],A[2]);else throw new Error("malformed attrTypeAndValueStr: "+attrTypeAndValueStr)},this._getDsType=function(){var p=this.sType,f=this.sValue,A=this.sRule;return A==="prn"?p=="CN"&&v(f)?"ia5":E(f)?"prn":"utf8":A==="utf8"?p=="CN"&&v(f)?"ia5":p=="C"?"prn":"utf8":"utf8"},this.setByAttrTypeAndValueStr=function(p,f,A){A!==void 0&&(this.sRule=A),this.sType=p,this.sValue=f},this.getValueObj=function(p,f){if(p=="utf8")return new i({str:f});if(p=="prn")return new a({str:f});if(p=="tel")return new s({str:f});if(p=="ia5")return new c({str:f});if(p=="vis")return new l({str:f});if(p=="bmp")return new h({str:f});throw new Error("unsupported directory string type: type="+p+" value="+f)},this.tohex=function(){this.dsType==null&&(this.dsType=this._getDsType());var p=d.asn1.x509.OID.atype2obj(this.sType),f=this.getValueObj(this.dsType,this.sValue),A=new n({array:[p,f]});return this.TLV=A.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.x509.AttributeTypeAndValue,d.asn1.ASN1Object);d.asn1.x509.SubjectPublicKeyInfo=function(e){d.asn1.x509.SubjectPublicKeyInfo.superclass.constructor.call(this);var t=null,r=null,n=d,i=n.asn1,a=i.DERInteger,s=i.DERBitString,c=i.DERObjectIdentifier,l=i.DERSequence,h=i.ASN1Util.newObject,v=i.x509,E=v.AlgorithmIdentifier,p=n.crypto,f=p.ECDSA,A=p.DSA;this.getASN1Object=function(){if(this.asn1AlgId==null||this.asn1SubjPKey==null)throw"algId and/or subjPubKey not set";var g=new l({array:[this.asn1AlgId,this.asn1SubjPKey]});return g},this.tohex=function(){var g=this.getASN1Object();return this.hTLV=g.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},this.setPubKey=function(g){try{if(g instanceof ze){var y=h({seq:[{int:{bigint:g.n}},{int:{int:g.e}}]}),w=y.tohex();this.asn1AlgId=new E({name:"rsaEncryption"}),this.asn1SubjPKey=new s({hex:"00"+w})}}catch{}try{if(g instanceof d.crypto.ECDSA){var S=new c({name:g.curveName});this.asn1AlgId=new E({name:"ecPublicKey",asn1params:S}),this.asn1SubjPKey=new s({hex:"00"+g.pubKeyHex})}}catch{}try{if(g instanceof d.crypto.DSA){var S=new h({seq:[{int:{bigint:g.p}},{int:{bigint:g.q}},{int:{bigint:g.g}}]});this.asn1AlgId=new E({name:"dsa",asn1params:S});var _=new a({bigint:g.y});this.asn1SubjPKey=new s({hex:"00"+_.tohex()})}}catch{}},e!==void 0&&this.setPubKey(e)};he(d.asn1.x509.SubjectPublicKeyInfo,d.asn1.ASN1Object);d.asn1.x509.Time=function(e){d.asn1.x509.Time.superclass.constructor.call(this);var t=null,r=null,n=d,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.params=null,this.type=null,this.setTimeParams=function(c){this.timeParams=c},this.setByParam=function(c){this.params=c},this.getType=function(c){return c.match(/^[0-9]{12}Z$/)?"utc":c.match(/^[0-9]{14}Z$/)?"gen":c.match(/^[0-9]{12}\.[0-9]+Z$/)?"utc":c.match(/^[0-9]{14}\.[0-9]+Z$/)?"gen":null},this.tohex=function(){var c=this.params,l=null;if(typeof c=="string"&&(c={str:c}),c!=null&&c.str&&(c.type==null||c.type==null)&&(c.type=this.getType(c.str)),c!=null&&c.str?(c.type=="utc"&&(l=new a(c.str)),c.type=="gen"&&(l=new s(c.str))):this.type=="gen"?l=new s:l=new a,l==null)throw new Error("wrong setting for Time");return this.TLV=l.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};d.asn1.x509.Time_bak=function(e){d.asn1.x509.Time_bak.superclass.constructor.call(this);var t=null,r=null,n=d,i=n.asn1,a=i.DERUTCTime,s=i.DERGeneralizedTime;this.setTimeParams=function(c){this.timeParams=c},this.tohex=function(){var c=null;return this.timeParams!=null?this.type=="utc"?c=new a(this.timeParams):c=new s(this.timeParams):this.type=="utc"?c=new a:c=new s,this.TLV=c.tohex(),this.TLV},this.getEncodedHex=function(){return this.tohex()},this.type="utc",e!==void 0&&(e.type!==void 0?this.type=e.type:e.str!==void 0&&(e.str.match(/^[0-9]{12}Z$/)&&(this.type="utc"),e.str.match(/^[0-9]{14}Z$/)&&(this.type="gen")),this.timeParams=e)};he(d.asn1.x509.Time,d.asn1.ASN1Object);d.asn1.x509.AlgorithmIdentifier=function(e){d.asn1.x509.AlgorithmIdentifier.superclass.constructor.call(this),this.nameAlg=null,this.asn1Alg=null,this.asn1Params=null,this.paramEmpty=!1;var t=d,r=t.asn1,n=r.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV;if(this.tohex=function(){if(this.nameAlg===null&&this.asn1Alg===null)throw new Error("algorithm not specified");if(this.nameAlg!==null){var a=null;for(var s in n)s===this.nameAlg&&(a=n[s]);if(a!==null)return this.hTLV=a,this.hTLV}this.nameAlg!==null&&this.asn1Alg===null&&(this.asn1Alg=r.x509.OID.name2obj(this.nameAlg));var c=[this.asn1Alg];this.asn1Params!==null&&c.push(this.asn1Params);var l=new r.DERSequence({array:c});return this.hTLV=l.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&(e.name!==void 0&&(this.nameAlg=e.name),e.asn1params!==void 0&&(this.asn1Params=e.asn1params),e.paramempty!==void 0&&(this.paramEmpty=e.paramempty)),this.asn1Params===null&&this.paramEmpty===!1&&this.nameAlg!==null){this.nameAlg.name!==void 0&&(this.nameAlg=this.nameAlg.name);var i=this.nameAlg.toLowerCase();i.substr(-7,7)!=="withdsa"&&i.substr(-9,9)!=="withecdsa"&&(this.asn1Params=new r.DERNull)}};he(d.asn1.x509.AlgorithmIdentifier,d.asn1.ASN1Object);d.asn1.x509.AlgorithmIdentifier.PSSNAME2ASN1TLV={SHAwithRSAandMGF1:"300d06092a864886f70d01010a3000",SHA256withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040201a11a301806092a864886f70d010108300b0609608648016503040201a203020120",SHA384withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040202a11a301806092a864886f70d010108300b0609608648016503040202a203020130",SHA512withRSAandMGF1:"303d06092a864886f70d01010a3030a00d300b0609608648016503040203a11a301806092a864886f70d010108300b0609608648016503040203a203020140"};d.asn1.x509.GeneralName=function(e){d.asn1.x509.GeneralName.superclass.constructor.call(this);var t={rfc822:"81",dns:"82",dn:"a4",uri:"86",ip:"87",otherName:"a0"},r=d,n=r.asn1,i=n.x509,a=i.X500Name,s=i.OtherName,c=n.DERIA5String,l=n.DERPrintableString,h=n.DEROctetString,v=n.DERTaggedObject,E=n.ASN1Object,p=Error;this.params=null,this.setByParam=function(f){this.params=f},this.tohex=function(){var f=this.params,A,y,g,y=!1;if(f.other!==void 0)A="a0",g=new s(f.other);else if(f.rfc822!==void 0)A="81",g=new c({str:f.rfc822});else if(f.dns!==void 0)A="82",g=new c({str:f.dns});else if(f.dn!==void 0)A="a4",y=!0,typeof f.dn=="string"?g=new a({str:f.dn}):f.dn instanceof d.asn1.x509.X500Name?g=f.dn:g=new a(f.dn);else if(f.ldapdn!==void 0)A="a4",y=!0,g=new a({ldapstr:f.ldapdn});else if(f.certissuer!==void 0||f.certsubj!==void 0){A="a4",y=!0;var w,S,_=null;if(f.certsubj!==void 0?(w=!1,S=f.certsubj):(w=!0,S=f.certissuer),S.match(/^[0-9A-Fa-f]+$/)&&_==S,S.indexOf("-----BEGIN ")!=-1&&(_=Kt(S)),_==null)throw new Error("certsubj/certissuer not cert");var I=new He;I.hex=_;var B;w?B=I.getIssuerHex():B=I.getSubjectHex(),g=new E,g.hTLV=B}else if(f.uri!==void 0)A="86",g=new c({str:f.uri});else if(f.ip!==void 0){A="87";var q,z=f.ip;try{if(z.match(/^[0-9a-f]+$/)){var F=z.length;if(F==8||F==16||F==32||F==64)q=z;else throw"err"}else q=Vd(z)}catch(L){throw new p("malformed IP address: "+f.ip+":"+L.message)}g=new h({hex:q})}else throw new p("improper params");var P=new v({tag:A,explicit:y,obj:g});return P.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.x509.GeneralName,d.asn1.ASN1Object);d.asn1.x509.GeneralNames=function(e){d.asn1.x509.GeneralNames.superclass.constructor.call(this);var t=null,r=d,n=r.asn1;this.setByParamArray=function(i){for(var a=0;a"u")throw"Name of ObjectIdentifier not defined: "+t;var r=this.name2oidList[t],n=new e({oid:r});return this.objCache[t]=n,n},this.atype2obj=function(t){if(this.objCache[t]!==void 0)return this.objCache[t];var r;if(t.match(/^\d+\.\d+\.[0-9.]+$/))r=t;else if(this.atype2oidList[t]!==void 0)r=this.atype2oidList[t];else if(this.name2oidList[t]!==void 0)r=this.name2oidList[t];else throw new Error("AttributeType name undefined: "+t);var n=new e({oid:r});return this.objCache[t]=n,n},this.registerOIDs=function(t){if(this.checkOIDs(t))for(var r in t)this.name2oidList[r]=t[r]},this.checkOIDs=function(t){try{var r=Object.keys(t);return r.length==0?!1:(r.map(function(n,i,a){var s=this[n];if(!s.match(/^[0-2]\.[0-9.]+$/))throw new Error("value is not OID")},t),!0)}catch{return!1}}};d.asn1.x509.OID.oid2name=function(e){var t=d.asn1.x509.OID.name2oidList;for(var r in t)if(t[r]==e)return r;return""};d.asn1.x509.OID.oid2atype=function(e){var t=d.asn1.x509.OID.atype2oidList;for(var r in t)if(t[r]==e)return r;return e};d.asn1.x509.OID.name2oid=function(e){if(e.match(/^[0-9.]+$/))return e;var t=d.asn1.x509.OID.name2oidList;return t[e]===void 0?"":t[e]};d.asn1.x509.X509Util={};d.asn1.x509.X509Util.newCertPEM=function(e){var t=d.asn1.x509,r=t.TBSCertificate,n=t.Certificate,i=new n(e);return i.getPEM()};(typeof d>"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.cms>"u"||!d.asn1.cms)&&(d.asn1.cms={});d.asn1.cms.Attribute=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.DERSet,s=n.DERObjectIdentifier;this.params=null,this.typeOid=null,this.setByParam=function(c){this.params=c},this.getValueArray=function(){throw new t("not yet implemented abstract")},this.tohex=function(){var c=new s({oid:this.typeOid}),l=new a({array:this.getValueArray()}),h=new i({array:[c,l]});return h.tohex()},this.getEncodedHex=function(){return this.tohex()}};he(d.asn1.cms.Attribute,d.asn1.ASN1Object);d.asn1.cms.ContentType=function(e){var t=d,r=t.asn1;r.cms.ContentType.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.3",this.getValueArray=function(){var n=new r.DERObjectIdentifier(this.params.type);return[n]},e!=null&&this.setByParam(e)};he(d.asn1.cms.ContentType,d.asn1.cms.Attribute);d.asn1.cms.MessageDigest=function(e){var t=d,r=t.asn1,n=r.DEROctetString,i=r.cms;i.MessageDigest.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.4",this.getValueArray=function(){var a=new n(this.params);return[a]},e!=null&&this.setByParam(e)};he(d.asn1.cms.MessageDigest,d.asn1.cms.Attribute);d.asn1.cms.SigningTime=function(e){var t=d,r=t.asn1;r.cms.SigningTime.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.5",this.getValueArray=function(){var n=new r.x509.Time(this.params);return[n]},e!=null&&this.setByParam(e)};he(d.asn1.cms.SigningTime,d.asn1.cms.Attribute);d.asn1.cms.SigningCertificate=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.cms,s=a.ESSCertID,c=r.crypto;a.SigningCertificate.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.12",this.getValueArray=function(){if(this.params==null||this.params==null||this.params.array==null)throw new t("parameter 'array' not specified");for(var l=this.params.array,h=[],v=0;v0){for(var A=a(p.valhex,f[0]),g=E(A,0),y=[],w=0;w1){var I=a(p.valhex,f[1]);p.polhex=I}delete p.valhex},this.setSignaturePolicyIdentifier=function(p){var f=E(p.valhex,0);if(f.length>0){var A=n.getOID(p.valhex,f[0]);p.oid=A}if(f.length>1){var g=new t,y=E(p.valhex,f[1]),w=a(p.valhex,y[0]),S=g.getAlgorithmIdentifierName(w);p.alg=S;var _=i(p.valhex,y[1]);p.hash=_}delete p.valhex},this.setSigningCertificateV2=function(p){var f=E(p.valhex,0);if(f.length>0){for(var A=a(p.valhex,f[0]),g=E(A,0),y=[],w=0;w1){var I=a(p.valhex,f[1]);p.polhex=I}delete p.valhex},this.getESSCertID=function(p){var f={},A=E(p,0);if(A.length>0){var g=i(p,A[0]);f.hash=g}if(A.length>1){var y=a(p,A[1]),w=this.getIssuerSerial(y);w.serial!=null&&(f.serial=w.serial),w.issuer!=null&&(f.issuer=w.issuer)}return f},this.getESSCertIDv2=function(p){var f={},A=E(p,0);if(A.length<1||3g+1){var S=a(p,A[g+1]),_=this.getIssuerSerial(S);f.issuer=_.issuer,f.serial=_.serial}return f},this.getIssuerSerial=function(p){var f={},A=E(p,0),g=a(p,A[0]),y=r.getGeneralNames(g),w=y[0].dn;f.issuer=w;var S=i(p,A[1]);return f.serial={hex:S},f},this.getCertificateSet=function(p){for(var f=E(p,0),A=[],g=0;g"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.tsp>"u"||!d.asn1.tsp)&&(d.asn1.tsp={});d.asn1.tsp.TimeStampToken=function(e){var t=d,r=t.asn1,n=r.tsp;n.TimeStampToken.superclass.constructor.call(this),this.params=null,this.getEncodedHexPrepare=function(){var i=new n.TSTInfo(this.params.econtent.content);this.params.econtent.content.hex=i.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.TimeStampToken,d.asn1.cms.SignedData);d.asn1.tsp.TSTInfo=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.DERInteger,s=n.DERBoolean,c=n.DERGeneralizedTime,l=n.DERObjectIdentifier,h=n.DERTaggedObject,v=n.tsp,E=v.MessageImprint,p=v.Accuracy,f=n.x509.X500Name,A=n.x509.GeneralName;if(v.TSTInfo.superclass.constructor.call(this),this.dVersion=new a({int:1}),this.dPolicy=null,this.dMessageImprint=null,this.dSerial=null,this.dGenTime=null,this.dAccuracy=null,this.dOrdering=null,this.dNonce=null,this.dTsa=null,this.tohex=function(){var g=[this.dVersion];if(this.dPolicy==null)throw new Error("policy shall be specified.");if(g.push(this.dPolicy),this.dMessageImprint==null)throw new Error("messageImprint shall be specified.");if(g.push(this.dMessageImprint),this.dSerial==null)throw new Error("serialNumber shall be specified.");if(g.push(this.dSerial),this.dGenTime==null)throw new Error("genTime shall be specified.");g.push(this.dGenTime),this.dAccuracy!=null&&g.push(this.dAccuracy),this.dOrdering!=null&&g.push(this.dOrdering),this.dNonce!=null&&g.push(this.dNonce),this.dTsa!=null&&g.push(this.dTsa);var y=new i({array:g});return this.hTLV=y.tohex(),this.hTLV},this.getEncodedHex=function(){return this.tohex()},e!==void 0){if(typeof e.policy=="string"){if(!e.policy.match(/^[0-9.]+$/))throw"policy shall be oid like 0.1.4.134";this.dPolicy=new l({oid:e.policy})}e.messageImprint!==void 0&&(this.dMessageImprint=new E(e.messageImprint)),e.serial!==void 0&&(this.dSerial=new a(e.serial)),e.genTime!==void 0&&(this.dGenTime=new c(e.genTime)),e.accuracy!==void 0&&(this.dAccuracy=new p(e.accuracy)),e.ordering!==void 0&&e.ordering==!0&&(this.dOrdering=new s),e.nonce!==void 0&&(this.dNonce=new a(e.nonce)),e.tsa!==void 0&&(this.dTsa=new h({tag:"a0",explicit:!0,obj:new A({dn:e.tsa})}))}};he(d.asn1.tsp.TSTInfo,d.asn1.ASN1Object);d.asn1.tsp.Accuracy=function(e){var t=d,r=t.asn1,n=r.ASN1Util.newObject;r.tsp.Accuracy.superclass.constructor.call(this),this.params=null,this.tohex=function(){var i=this.params,a=[];return i.seconds!=null&&typeof i.seconds=="number"&&a.push({int:i.seconds}),i.millis!=null&&typeof i.millis=="number"&&a.push({tag:{tagi:"80",obj:{int:i.millis}}}),i.micros!=null&&typeof i.micros=="number"&&a.push({tag:{tagi:"81",obj:{int:i.micros}}}),n({seq:a}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.Accuracy,d.asn1.ASN1Object);d.asn1.tsp.MessageImprint=function(e){var t=d,r=t.asn1,n=r.DERSequence,i=r.DEROctetString,a=r.x509,s=a.AlgorithmIdentifier;r.tsp.MessageImprint.superclass.constructor.call(this),this.params=null,this.tohex=function(){var c=this.params,l=new s({name:c.alg}),h=new i({hex:c.hash}),v=new n({array:[l,h]});return v.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.tsp.MessageImprint,d.asn1.ASN1Object);d.asn1.tsp.TimeStampReq=function(e){var t=d,r=t.asn1,n=r.DERSequence,i=r.DERInteger,a=r.DERBoolean,s=r.ASN1Object,c=r.DERObjectIdentifier,l=r.tsp,h=l.MessageImprint;l.TimeStampReq.superclass.constructor.call(this),this.params=null,this.tohex=function(){var v=this.params,E=[];E.push(new i({int:1})),v.messageImprint instanceof d.asn1.ASN1Object?E.push(v.messageImprint):E.push(new h(v.messageImprint)),v.policy!=null&&E.push(new c(v.policy)),v.nonce!=null&&E.push(new i(v.nonce)),v.certreq==!0&&E.push(new a);var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.TimeStampReq,d.asn1.ASN1Object);d.asn1.tsp.TimeStampResp=function(e){var t=d,r=t.asn1,n=r.DERSequence,i=r.ASN1Object,a=r.tsp,s=a.PKIStatusInfo;a.TimeStampResp.superclass.constructor.call(this),this.params=null,this.tohex=function(){var c=this.params,l=[];if(c.econtent!=null||c.tst!=null)if(c.statusinfo!=null?l.push(new s(c.statusinfo)):l.push(new s("granted")),c.econtent!=null)l.push(new a.TimeStampToken(c).getContentInfo());else if(c.tst instanceof r.ASN1Object)l.push(c.tst);else throw new Error("improper member tst value");else if(c.statusinfo!=null)l.push(new s(c.statusinfo));else throw new Error("parameter for token nor statusinfo not specified");var h=new n({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.TimeStampResp,d.asn1.ASN1Object);d.asn1.tsp.PKIStatusInfo=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.tsp,s=a.PKIStatus,c=a.PKIFreeText,l=a.PKIFailureInfo;a.PKIStatusInfo.superclass.constructor.call(this),this.params=null,this.tohex=function(){var h=this.params,v=[];if(typeof h=="string")v.push(new s(h));else{if(h.status==null)throw new t("property 'status' unspecified");v.push(new s(h.status)),h.statusstr!=null&&v.push(new c(h.statusstr)),h.failinfo!=null&&v.push(new l(h.failinfo))}var E=new i({array:v});return E.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.PKIStatusInfo,d.asn1.ASN1Object);d.asn1.tsp.PKIStatus=function(e){var t=Error,r=d,n=r.asn1,i=n.DERInteger,a=n.tsp;a.PKIStatus.superclass.constructor.call(this);var s={granted:0,grantedWithMods:1,rejection:2,waiting:3,revocationWarning:4,revocationNotification:5};this.params=null,this.tohex=function(){var c=this.params,l,h;if(typeof c=="string")try{h=s[c]}catch{throw new t("undefined name: "+c)}else if(typeof c=="number")h=c;else throw new t("unsupported params");return new i({int:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.PKIStatus,d.asn1.ASN1Object);d.asn1.tsp.PKIFreeText=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.DERUTF8String,s=n.tsp;s.PKIFreeText.superclass.constructor.call(this),this.params=null,this.tohex=function(){var c=this.params;if(!c instanceof Array)throw new t("wrong params: not array");for(var l=[],h=0;h=0;p--)E+=v[p];return E}else{if(typeof l=="string"&&c[l]!=null)return Hf([l],c);if(typeof l=="object"&&l.length!=null)return Hf(l,c);throw new t("wrong params")}},this.tohex=function(){var l=this.params,h=this.getBinValue();return new i({bin:h}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.tsp.PKIFailureInfo,d.asn1.ASN1Object);d.asn1.tsp.AbstractTSAAdapter=function(e){this.getTSTHex=function(t,r){throw"not implemented yet"}};d.asn1.tsp.SimpleTSAAdapter=function(e){var t=d,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.SimpleTSAAdapter.superclass.constructor.call(this),this.params=null,this.serial=0,this.getTSTHex=function(a,s){var c=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:c},this.params.econtent.content.serial={int:this.serial++};var l=Math.floor(Math.random()*1e9);this.params.econtent.content.nonce={int:l};var h=new n.TimeStampToken(this.params);return h.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};he(d.asn1.tsp.SimpleTSAAdapter,d.asn1.tsp.AbstractTSAAdapter);d.asn1.tsp.FixedTSAAdapter=function(e){var t=d,r=t.asn1,n=r.tsp,i=t.crypto.Util.hashHex;n.FixedTSAAdapter.superclass.constructor.call(this),this.params=null,this.getTSTHex=function(a,s){var c=i(a,s);this.params.econtent.content.messageImprint={alg:s,hash:c};var l=new n.TimeStampToken(this.params);return l.getContentInfoEncodedHex()},e!==void 0&&(this.params=e)};he(d.asn1.tsp.FixedTSAAdapter,d.asn1.tsp.AbstractTSAAdapter);d.asn1.tsp.TSPUtil=new function(){};d.asn1.tsp.TSPUtil.newTimeStampToken=function(e){return new d.asn1.tsp.TimeStampToken(e)};d.asn1.tsp.TSPUtil.parseTimeStampReq=function(e){var t=new d.asn1.tsp.TSPParser;return t.getTimeStampReq(e)};d.asn1.tsp.TSPUtil.parseMessageImprint=function(e){var t=new d.asn1.tsp.TSPParser;return t.getMessageImprint(e)};d.asn1.tsp.TSPParser=function(){var e=Error,t=He,r=new t,n=Ae,i=n.getV,a=n.getTLV,s=n.getIdxbyList,c=n.getTLVbyListEx,l=n.getChildIdx,h=["granted","grantedWithMods","rejection","waiting","revocationWarning","revocationNotification"],v={0:"badAlg",2:"badRequest",5:"badDataFormat",14:"timeNotAvailable",15:"unacceptedPolicy",16:"unacceptedExtension",17:"addInfoNotAvailable",25:"systemFailure"};this.getResponse=function(E){var p=l(E,0);if(p.length==1)return this.getPKIStatusInfo(a(E,p[0]));if(p.length>1){var f=this.getPKIStatusInfo(a(E,p[0])),A=a(E,p[1]),g=this.getToken(A);return g.statusinfo=f,g}},this.getToken=function(E){var p=new d.asn1.cms.CMSParser,f=p.getCMSSignedData(E);return this.setTSTInfo(f),f},this.setTSTInfo=function(E){var p=E.econtent;if(p.type=="tstinfo"){var f=p.content.hex,A=this.getTSTInfo(f);p.content=A}},this.getTSTInfo=function(E){var p={},f=l(E,0),A=i(E,f[1]);p.policy=Wf(A);var g=a(E,f[2]);p.messageImprint=this.getMessageImprint(g);var y=i(E,f[3]);p.serial={hex:y};var w=i(E,f[4]);p.genTime={str:Ft(w)};var S=0;if(f.length>5&&E.substr(f[5],2)=="30"){var _=a(E,f[5]);p.accuracy=this.getAccuracy(_),S++}if(f.length>5+S&&E.substr(f[5+S],2)=="01"){var I=i(E,f[5+S]);I=="ff"&&(p.ordering=!0),S++}if(f.length>5+S&&E.substr(f[5+S],2)=="02"){var B=i(E,f[5+S]);p.nonce={hex:B},S++}if(f.length>5+S&&E.substr(f[5+S],2)=="a0"){var q=a(E,f[5+S]);q="30"+q.substr(2),pGeneralNames=r.getGeneralNames(q);var z=pGeneralNames[0].dn;p.tsa=z,S++}if(f.length>5+S&&E.substr(f[5+S],2)=="a1"){var F=a(E,f[5+S]);F="30"+F.substr(2);var P=r.getExtParamArray(F);p.ext=P,S++}return p},this.getAccuracy=function(E){for(var p={},f=l(E,0),A=0;A1&&E.substr(f[1],2)=="30"){var w=a(E,f[1]);p.statusstr=this.getPKIFreeText(w),A++}if(f.length>A&&E.substr(f[1+A],2)=="03"){var S=a(E,f[1+A]);p.failinfo=this.getPKIFailureInfo(S)}return p},this.getPKIFreeText=function(E){for(var p=[],f=l(E,0),A=0;A"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.cades>"u"||!d.asn1.cades)&&(d.asn1.cades={});d.asn1.cades.SignaturePolicyIdentifier=function(e){var t=d,r=t.asn1,n=r.cades,i=n.SignaturePolicyId;n.SignaturePolicyIdentifier.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.15",this.params=null,this.getValueArray=function(){return[new i(this.params)]},this.setByParam=function(a){this.params=a},e!=null&&this.setByParam(e)};he(d.asn1.cades.SignaturePolicyIdentifier,d.asn1.cms.Attribute);d.asn1.cades.SignaturePolicyId=function(e){var t=d,r=t.asn1,n=r.DERSequence,i=r.DERObjectIdentifier,a=r.x509,s=a.AlgorithmIdentifier,c=r.cades,l=c.SignaturePolicyId,h=c.OtherHashAlgAndValue;l.superclass.constructor.call(this),this.params=null,this.tohex=function(){var v=this.params,E=[];E.push(new i(v.oid)),E.push(new h(v));var p=new n({array:E});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},this.setByParam=function(v){this.params=v},e!=null&&this.setByParam(e)};he(d.asn1.cades.SignaturePolicyId,d.asn1.ASN1Object);d.asn1.cades.OtherHashAlgAndValue=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.DEROctetString,s=n.x509,c=s.AlgorithmIdentifier,l=n.cades,h=l.OtherHashAlgAndValue;h.superclass.constructor.call(this),this.params=null,this.tohex=function(){var v=this.params;if(v.alg==null)throw new t("property 'alg' not specified");if(v.hash==null&&v.cert==null)throw new t("property 'hash' nor 'cert' not specified");var E=null;if(v.hash!=null)E=v.hash;else if(v.cert!=null){if(typeof v.cert!="string")throw new t("cert not string");var p=v.cert;v.cert.indexOf("-----BEGIN")!=-1&&(p=Kt(v.cert)),E=d.crypto.Util.hashHex(p,v.alg)}var f=[];f.push(new c({name:v.alg})),f.push(new a({hex:E}));var A=new i({array:f});return A.tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.cades.OtherHashAlgAndValue,d.asn1.ASN1Object);d.asn1.cades.OtherHashValue=function(e){d.asn1.cades.OtherHashValue.superclass.constructor.call(this);var t=Error,r=d,n=r.lang.String.isHex,i=r.asn1,a=i.DEROctetString,s=r.crypto.Util.hashHex;this.params=null,this.tohex=function(){var c=this.params;if(c.hash==null&&c.cert==null)throw new t("hash or cert not specified");var l=null;if(c.hash!=null)l=c.hash;else if(c.cert!=null){if(typeof c.cert!="string")throw new t("cert not string");var h=c.cert;c.cert.indexOf("-----BEGIN")!=-1&&(h=Kt(c.cert)),l=d.crypto.Util.hashHex(h,"sha1")}return new a({hex:l}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!=null&&this.setByParam(e)};he(d.asn1.cades.OtherHashValue,d.asn1.ASN1Object);d.asn1.cades.SignatureTimeStamp=function(e){var t=Error,r=d,n=r.lang.String.isHex,i=r.asn1,a=i.ASN1Object,s=i.x509,c=i.cades;c.SignatureTimeStamp.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.14",this.params=null,this.getValueArray=function(){var l=this.params;if(l.tst!=null)if(n(l.tst)){var h=new a;return h.hTLV=l.tst,[h]}else{if(l.tst instanceof a)return[l.tst];throw new t("params.tst has wrong value")}else if(l.res!=null){var v=l.res;if(v instanceof a&&(v=v.tohex()),typeof v!="string"||!n(v))throw new t("params.res has wrong value");var E=Ae.getTLVbyList(v,0,[1]),h=new a;return h.hTLV=l.tst,[h]}},e!=null&&this.setByParam(e)};he(d.asn1.cades.SignatureTimeStamp,d.asn1.cms.Attribute);d.asn1.cades.CompleteCertificateRefs=function(e){var t=Error,r=d,n=r.asn1,i=n.DERSequence,a=n.cades,s=a.OtherCertID,c=r.lang.String.isHex;a.CompleteCertificateRefs.superclass.constructor.call(this),this.typeOid="1.2.840.113549.1.9.16.2.21",this.params=null,this.getValueArray=function(){for(var l=this.params,h=[],v=0;v"u"||!d.asn1.csr)&&(d.asn1.csr={});d.asn1.csr.CertificationRequest=function(e){var t=d,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.csr,s=r.x509,c=a.CertificationRequestInfo;a.CertificationRequest.superclass.constructor.call(this),this.setByParam=function(l){this.params=l},this.sign=function(){var l=new c(this.params).tohex(),h=new d.crypto.Signature({alg:this.params.sigalg});h.init(this.params.sbjprvkey),h.updateHex(l);var v=h.sign();this.params.sighex=v},this.getPEM=function(){return Gr(this.tohex(),"CERTIFICATE REQUEST")},this.tohex=function(){var l=this.params,h=new d.asn1.csr.CertificationRequestInfo(this.params),v=new d.asn1.x509.AlgorithmIdentifier({name:l.sigalg});if(l.sighex==null&&l.sbjprvkey!=null&&this.sign(),l.sighex==null)throw new Error("sighex or sbjprvkey parameter not defined");var E=new n({hex:"00"+l.sighex}),p=new i({array:[h,v,E]});return p.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.csr.CertificationRequest,d.asn1.ASN1Object);d.asn1.csr.CertificationRequestInfo=function(e){var t=d,r=t.asn1,n=r.DERBitString,i=r.DERSequence,a=r.DERInteger,s=r.DERUTF8String,c=r.DERTaggedObject,l=r.ASN1Util.newObject,h=r.csr,v=r.x509,E=v.X500Name,p=v.Extensions,f=v.SubjectPublicKeyInfo,A=h.AttributeList;h.CertificationRequestInfo.superclass.constructor.call(this),this.params=null,this.setByParam=function(y){y!=null&&(this.params=y)},this.tohex=function(){var y=this.params,w=[];if(w.push(new a({int:0})),w.push(new E(y.subject)),w.push(new f(st.getKey(y.sbjpubkey))),y.attrs!=null){var S=g(y.attrs),_=l({tag:{tage:"a0",obj:S}});w.push(_)}else if(y.extreq!=null){var I=new p(y.extreq),_=l({tag:{tage:"a0",obj:{seq:[{oid:"1.2.840.113549.1.9.14"},{set:[I]}]}}});w.push(_)}else w.push(new c({tag:"a0",explicit:!1,obj:new s({str:""})}));var B=new i({array:w});return B.tohex()},this.getEncodedHex=function(){return this.tohex()};function g(y){for(var w=Error,S=d.asn1.x509.Extensions,_=[],I=0;I"u"||!d)&&(d={});(typeof d.asn1>"u"||!d.asn1)&&(d.asn1={});(typeof d.asn1.ocsp>"u"||!d.asn1.ocsp)&&(d.asn1.ocsp={});d.asn1.ocsp.DEFAULT_HASH="sha1";d.asn1.ocsp.OCSPResponse=function(e){d.asn1.ocsp.OCSPResponse.superclass.constructor.call(this);var t=d.asn1.DEREnumerated,r=d.asn1.ASN1Util.newObject,n=d.asn1.ocsp.ResponseBytes,i=["successful","malformedRequest","internalError","tryLater","_not_used_","sigRequired","unauthorized"];this.params=null,this._getStatusCode=function(){var a=this.params.resstatus;return typeof a=="number"?a:typeof a!="string"?-1:i.indexOf(a)},this.setByParam=function(a){this.params=a},this.tohex=function(){var a=this.params,s=this._getStatusCode();if(s==-1)throw new Error("responseStatus not supported: "+a.resstatus);if(s!=0)return r({seq:[{enum:{int:s}}]}).tohex();var c=new n(a);return r({seq:[{enum:{int:0}},{tag:{tag:"a0",explicit:!0,obj:c}}]}).tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.ocsp.OCSPResponse,d.asn1.ASN1Object);d.asn1.ocsp.ResponseBytes=function(e){d.asn1.ocsp.ResponseBytes.superclass.constructor.call(this);var t=d.asn1,r=t.DERSequence,n=t.DERObjectIdentifier,i=t.DEROctetString,a=t.ocsp.BasicOCSPResponse;this.params=null,this.setByParam=function(s){this.params=s},this.tohex=function(){var s=this.params;if(s.restype!="ocspBasic")throw new Error("not supported responseType: "+s.restype);var c=new a(s),l=[];l.push(new n({name:"ocspBasic"})),l.push(new i({hex:c.tohex()}));var h=new r({array:l});return h.tohex()},this.getEncodedHex=function(){return this.tohex()},e!==void 0&&this.setByParam(e)};he(d.asn1.ocsp.ResponseBytes,d.asn1.ASN1Object);d.asn1.ocsp.BasicOCSPResponse=function(e){d.asn1.ocsp.BasicOCSPResponse.superclass.constructor.call(this);var t=Error,r=d.asn1,n=r.ASN1Object,i=r.DERSequence,a=r.DERGeneralizedTime,s=r.DERTaggedObject,c=r.DERBitString,l=r.x509.Extensions,h=r.x509.AlgorithmIdentifier,v=r.ocsp,E=v.ResponderID;_SingleResponseList=v.SingleResponseList,_ResponseData=v.ResponseData,this.params=null,this.setByParam=function(p){this.params=p},this.sign=function(){var p=this.params,f=p.tbsresp.tohex(),A=new d.crypto.Signature({alg:p.sigalg});A.init(p.reskey),A.updateHex(f),p.sighex=A.sign()},this.tohex=function(){var p=this.params;p.tbsresp==null&&(p.tbsresp=new _ResponseData(p)),p.sighex==null&&p.reskey!=null&&this.sign();var f=[];if(f.push(p.tbsresp),f.push(new h({name:p.sigalg})),f.push(new c({hex:"00"+p.sighex})),p.certs!=null&&p.certs.length!=null){for(var A=[],g=0;g"u"||!d)&&(d={});(typeof d.lang>"u"||!d.lang)&&(d.lang={});d.lang.String=function(){};function H2(e){for(var t=new Array,r=0;r>6,l=128|s&63;return Ft(c.toString(16)+l.toString(16))}var c=224|(a&240)>>4,l=128|(a&15)<<2|(s&192)>>6,h=128|s&63;return Ft(c.toString(16)+l.toString(16)+h.toString(16))}var r=e.match(/.{4}/g),n=r.map(t);return n.join("")}function Yf(e){for(var t=encodeURIComponent(e),r="",n=0;n"7"?"00"+e:e}function M9(e){e=e.replace(/^\s*\[\s*/,""),e=e.replace(/\s*\]\s*$/,""),e=e.replace(/\s*/g,"");try{var t=e.split(/,/).map(function(r,n,i){var a=parseInt(r);if(a<0||255t.length&&(r=t.length);for(var n=0;n0&&(h=h+"."+c.join(".")),h}catch{return null}}function z2(e){var t=new ee(String(e),10);return jc(t)}function jc(e){var t=e.toString(16);if(t.substr(0,1)!="-")return t.length%2==1?t="0"+t:t.match(/^[0-7]/)||(t="00"+t),t;var r=t.substr(1),n=r.length;n%2==1?n+=1:t.match(/^[0-7]/)||(n+=2);for(var i="",a=0;a=t?e:new Array(t-e.length+1).join(r)+e};function Y2(e){if(e.length%2!=0||(e=e.toLowerCase(),e.match(/^[0-9a-f]+$/)==null))return-1;try{var t=e.substr(0,2);if(t=="00")return parseInt(e.substr(2),16);var r=parseInt(t,16);if(r>7)return-1;var n=e.substr(2),i=parseInt(n,16).toString(2);i=="0"&&(i="00000000"),i=i.slice(0,0-r);var a=parseInt(i,2);return a==NaN?-1:a}catch{return-1}}function W2(e){if(typeof e!="number"||e<0)return null;var t=Number(e).toString(2),r=8-t.length%8;r==8&&(r=0),t=t+Uf("",r,"0");var n=parseInt(t,2).toString(16);n.length%2==1&&(n="0"+n);var i="0"+r;return i+n}function X2(e){if(typeof e!="string"||e.length%2!=0||!e.match(/^[0-9a-f]+$/))return null;try{var t=parseInt(e.substr(0,2),16);if(t<0||7=0;n--)a+=i[n];return a}function Pt(e,n,r){if(typeof e=="object"){for(var n=String(n).split("."),i=0;i"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.Util=new function(){this.DIGESTINFOHEAD={sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",ripemd160:"3021300906052b2403020105000414"},this.DEFAULTPROVIDER={md5:"cryptojs",sha1:"cryptojs",sha224:"cryptojs",sha256:"cryptojs",sha384:"cryptojs",sha512:"cryptojs",ripemd160:"cryptojs",hmacmd5:"cryptojs",hmacsha1:"cryptojs",hmacsha224:"cryptojs",hmacsha256:"cryptojs",hmacsha384:"cryptojs",hmacsha512:"cryptojs",hmacripemd160:"cryptojs",MD5withRSA:"cryptojs/jsrsa",SHA1withRSA:"cryptojs/jsrsa",SHA224withRSA:"cryptojs/jsrsa",SHA256withRSA:"cryptojs/jsrsa",SHA384withRSA:"cryptojs/jsrsa",SHA512withRSA:"cryptojs/jsrsa",RIPEMD160withRSA:"cryptojs/jsrsa",MD5withECDSA:"cryptojs/jsrsa",SHA1withECDSA:"cryptojs/jsrsa",SHA224withECDSA:"cryptojs/jsrsa",SHA256withECDSA:"cryptojs/jsrsa",SHA384withECDSA:"cryptojs/jsrsa",SHA512withECDSA:"cryptojs/jsrsa",RIPEMD160withECDSA:"cryptojs/jsrsa",SHA1withDSA:"cryptojs/jsrsa",SHA224withDSA:"cryptojs/jsrsa",SHA256withDSA:"cryptojs/jsrsa",MD5withRSAandMGF1:"cryptojs/jsrsa",SHAwithRSAandMGF1:"cryptojs/jsrsa",SHA1withRSAandMGF1:"cryptojs/jsrsa",SHA224withRSAandMGF1:"cryptojs/jsrsa",SHA256withRSAandMGF1:"cryptojs/jsrsa",SHA384withRSAandMGF1:"cryptojs/jsrsa",SHA512withRSAandMGF1:"cryptojs/jsrsa",RIPEMD160withRSAandMGF1:"cryptojs/jsrsa"},this.CRYPTOJSMESSAGEDIGESTNAME={md5:be.algo.MD5,sha1:be.algo.SHA1,sha224:be.algo.SHA224,sha256:be.algo.SHA256,sha384:be.algo.SHA384,sha512:be.algo.SHA512,ripemd160:be.algo.RIPEMD160},this.getDigestInfoHex=function(e,t){if(typeof this.DIGESTINFOHEAD[t]>"u")throw"alg not supported in Util.DIGESTINFOHEAD: "+t;return this.DIGESTINFOHEAD[t]+e},this.getPaddedDigestInfoHex=function(e,t,r){var n=this.getDigestInfoHex(e,t),i=r/4;if(n.length+22>i)throw"key is too short for SigAlg: keylen="+r+","+t;for(var a="0001",s="00"+n,c="",l=i-a.length-s.length,h=0;h"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.ECDSA=function(e){var t="secp256r1",r=null,n=null,i=null,a=Error,s=ee,c=mt,l=d.crypto.ECDSA,h=d.crypto.ECParameterDB,v=l.getName,E=Ae,p=E.getVbyListEx,f=E.isASN1HEX,A=new bo,g=null;this.type="EC",this.isPrivate=!1,this.isPublic=!1;function y(w,S,_,I){for(var B=Math.max(S.bitLength(),I.bitLength()),q=w.add2D(_),z=w.curve.getInfinity(),F=B-1;F>=0;--F)z=z.twice2D(),z.z=s.ONE,S.testBit(F)?I.testBit(F)?z=z.add2D(q):z=z.add2D(w):I.testBit(F)&&(z=z.add2D(_));return z}this.getBigRandom=function(w){return new s(w.bitLength(),A).mod(w.subtract(s.ONE)).add(s.ONE)},this.setNamedCurve=function(w){this.ecparams=h.getByName(w),this.prvKeyHex=null,this.pubKeyHex=null,this.curveName=w},this.setPrivateKeyHex=function(w){this.isPrivate=!0,this.prvKeyHex=w},this.setPublicKeyHex=function(w){this.isPublic=!0,this.pubKeyHex=w},this.getPublicKeyXYHex=function(){var w=this.pubKeyHex;if(w.substr(0,2)!=="04")throw"this method supports uncompressed format(04) only";var S=this.ecparams.keycharlen;if(w.length!==2+S*2)throw"malformed public key hex length";var _={};return _.x=w.substr(2,S),_.y=w.substr(2+S),_},this.getShortNISTPCurveName=function(){var w=this.curveName;return w==="secp256r1"||w==="NIST P-256"||w==="P-256"||w==="prime256v1"?"P-256":w==="secp384r1"||w==="NIST P-384"||w==="P-384"?"P-384":w==="secp521r1"||w==="NIST P-521"||w==="P-521"?"P-521":null},this.generateKeyPairHex=function(){var w=this.ecparams.n,S=this.getBigRandom(w),_=this.ecparams.keycharlen,I=("0000000000"+S.toString(16)).slice(-_);this.setPrivateKeyHex(I);var B=this.generatePublicKeyHex();return{ecprvhex:I,ecpubhex:B}},this.generatePublicKeyHex=function(){var w=new s(this.prvKeyHex,16),S=this.ecparams.G.multiply(w),_=S.getX().toBigInteger(),I=S.getY().toBigInteger(),B=this.ecparams.keycharlen,q=("0000000000"+_.toString(16)).slice(-B),z=("0000000000"+I.toString(16)).slice(-B),F="04"+q+z;return this.setPublicKeyHex(F),F},this.signWithMessageHash=function(w){return this.signHex(w,this.prvKeyHex)},this.signHex=function(w,S){var _=new s(S,16),I=this.ecparams.n,B=new s(w.substring(0,this.ecparams.keycharlen),16);do var q=this.getBigRandom(I),z=this.ecparams.G,F=z.multiply(q),P=F.getX().toBigInteger().mod(I);while(P.compareTo(s.ZERO)<=0);var L=q.modInverse(I).multiply(B.add(_.multiply(P))).mod(I);return l.biRSSigToASN1Sig(P,L)},this.sign=function(w,S){var _=S,I=this.ecparams.n,B=s.fromByteArrayUnsigned(w);do var q=this.getBigRandom(I),z=this.ecparams.G,F=z.multiply(q),P=F.getX().toBigInteger().mod(I);while(P.compareTo(ee.ZERO)<=0);var L=q.modInverse(I).multiply(B.add(_.multiply(P))).mod(I);return this.serializeSig(P,L)},this.verifyWithMessageHash=function(w,S){return this.verifyHex(w,S,this.pubKeyHex)},this.verifyHex=function(w,S,_){try{var I,B,q=l.parseSigHex(S);I=q.r,B=q.s;var z=c.decodeFromHex(this.ecparams.curve,_),F=new s(w.substring(0,this.ecparams.keycharlen),16);return this.verifyRaw(F,I,B,z)}catch{return!1}},this.verify=function(w,S,_){var I,B;if(Bitcoin.Util.isArray(S)){var q=this.parseSig(S);I=q.r,B=q.s}else if(typeof S=="object"&&S.r&&S.s)I=S.r,B=S.s;else throw"Invalid value for signature";var z;if(_ instanceof mt)z=_;else if(Bitcoin.Util.isArray(_))z=c.decodeFrom(this.ecparams.curve,_);else throw"Invalid format for pubkey value, must be byte array or ECPointFp";var F=s.fromByteArrayUnsigned(w);return this.verifyRaw(F,I,B,z)},this.verifyRaw=function(w,S,_,I){var B=this.ecparams.n,q=this.ecparams.G;if(S.compareTo(s.ONE)<0||S.compareTo(B)>=0||_.compareTo(s.ONE)<0||_.compareTo(B)>=0)return!1;var z=_.modInverse(B),F=w.multiply(z).mod(B),P=S.multiply(z).mod(B),L=q.multiply(F).add(I.multiply(P)),H=L.getX().toBigInteger().mod(B);return H.equals(S)},this.serializeSig=function(w,S){var _=w.toByteArraySigned(),I=S.toByteArraySigned(),B=[];return B.push(2),B.push(_.length),B=B.concat(_),B.push(2),B.push(I.length),B=B.concat(I),B.unshift(B.length),B.unshift(48),B},this.parseSig=function(w){var S;if(w[0]!=48)throw new Error("Signature not a valid DERSequence");if(S=2,w[S]!=2)throw new Error("First element in signature must be a DERInteger");var _=w.slice(S+2,S+2+w[S+1]);if(S+=2+w[S+1],w[S]!=2)throw new Error("Second element in signature must be a DERInteger");var I=w.slice(S+2,S+2+w[S+1]);S+=2+w[S+1];var B=s.fromByteArrayUnsigned(_),q=s.fromByteArrayUnsigned(I);return{r:B,s:q}},this.parseSigCompact=function(w){if(w.length!==65)throw"Signature has the wrong length";var S=w[0]-27;if(S<0||S>7)throw"Invalid signature type";var _=this.ecparams.n,I=s.fromByteArrayUnsigned(w.slice(1,33)).mod(_),B=s.fromByteArrayUnsigned(w.slice(33,65)).mod(_);return{r:I,s:B,i:S}},this.readPKCS5PrvKeyHex=function(w){if(f(w)===!1)throw new Error("not ASN.1 hex string");var S,_,I;try{S=p(w,0,["[0]",0],"06"),_=p(w,0,[1],"04");try{I=p(w,0,["[1]",0],"03")}catch{}}catch{throw new Error("malformed PKCS#1/5 plain ECC private key")}if(this.curveName=v(S),this.curveName===void 0)throw"unsupported curve name";this.setNamedCurve(this.curveName),this.setPublicKeyHex(I),this.setPrivateKeyHex(_),this.isPublic=!1},this.readPKCS8PrvKeyHex=function(w){if(f(w)===!1)throw new a("not ASN.1 hex string");var S,_,I,B;try{S=p(w,0,[1,0],"06"),_=p(w,0,[1,1],"06"),I=p(w,0,[2,0,1],"04");try{B=p(w,0,[2,0,"[1]",0],"03")}catch{}}catch{throw new a("malformed PKCS#8 plain ECC private key")}if(this.curveName=v(_),this.curveName===void 0)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(B),this.setPrivateKeyHex(I),this.isPublic=!1},this.readPKCS8PubKeyHex=function(w){if(f(w)===!1)throw new a("not ASN.1 hex string");var S,_,I;try{S=p(w,0,[0,0],"06"),_=p(w,0,[0,1],"06"),I=p(w,0,[1],"03")}catch{throw new a("malformed PKCS#8 ECC public key")}if(this.curveName=v(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},this.readCertPubKeyHex=function(w,S){if(f(w)===!1)throw new a("not ASN.1 hex string");var _,I;try{_=p(w,0,[0,5,0,1],"06"),I=p(w,0,[0,5,1],"03")}catch{throw new a("malformed X.509 certificate ECC public key")}if(this.curveName=v(_),this.curveName===null)throw new a("unsupported curve name");this.setNamedCurve(this.curveName),this.setPublicKeyHex(I)},e!==void 0&&e.curve!==void 0&&(this.curveName=e.curve),this.curveName===void 0&&(this.curveName=t),this.setNamedCurve(this.curveName),e!==void 0&&(e.prv!==void 0&&this.setPrivateKeyHex(e.prv),e.pub!==void 0&&this.setPublicKeyHex(e.pub))};d.crypto.ECDSA.parseSigHex=function(e){var t=d.crypto.ECDSA.parseSigHexInHexRS(e),r=new ee(t.r,16),n=new ee(t.s,16);return{r,s:n}};d.crypto.ECDSA.parseSigHexInHexRS=function(e){var t=Ae,r=t.getChildIdx,n=t.getV;if(t.checkStrictDER(e,0),e.substr(0,2)!="30")throw new Error("signature is not a ASN.1 sequence");var i=r(e,0);if(i.length!=2)throw new Error("signature shall have two elements");var a=i[0],s=i[1];if(e.substr(a,2)!="02")throw new Error("1st item not ASN.1 integer");if(e.substr(s,2)!="02")throw new Error("2nd item not ASN.1 integer");var c=n(e,a),l=n(e,s);return{r:c,s:l}};d.crypto.ECDSA.asn1SigToConcatSig=function(e){var t=d.crypto.ECDSA.parseSigHexInHexRS(e),r=t.r,n=t.s;if(r.length>=130&&r.length<=134){if(r.length%2!=0)throw Error("unknown ECDSA sig r length error");if(n.length%2!=0)throw Error("unknown ECDSA sig s length error");r.substr(0,2)=="00"&&(r=r.substr(2)),n.substr(0,2)=="00"&&(n=n.substr(2));var i=Math.max(r.length,n.length);return r=("000000"+r).slice(-i),n=("000000"+n).slice(-i),r+n}if(r.substr(0,2)=="00"&&r.length%32==2&&(r=r.substr(2)),n.substr(0,2)=="00"&&n.length%32==2&&(n=n.substr(2)),r.length%32==30&&(r="00"+r),n.length%32==30&&(n="00"+n),r.length%32!=0)throw Error("unknown ECDSA sig r length error");if(n.length%32!=0)throw Error("unknown ECDSA sig s length error");return r+n};d.crypto.ECDSA.concatSigToASN1Sig=function(e){if(e.length%4!=0)throw Error("unknown ECDSA concatinated r-s sig length error");var t=e.substr(0,e.length/2),r=e.substr(e.length/2);return d.crypto.ECDSA.hexRSSigToASN1Sig(t,r)};d.crypto.ECDSA.hexRSSigToASN1Sig=function(e,t){var r=new ee(e,16),n=new ee(t,16);return d.crypto.ECDSA.biRSSigToASN1Sig(r,n)};d.crypto.ECDSA.biRSSigToASN1Sig=function(e,t){var r=d.asn1,n=new r.DERInteger({bigint:e}),i=new r.DERInteger({bigint:t}),a=new r.DERSequence({array:[n,i]});return a.tohex()};d.crypto.ECDSA.getName=function(e){return e==="2b8104001f"?"secp192k1":e==="2a8648ce3d030107"?"secp256r1":e==="2b8104000a"?"secp256k1":e==="2b81040021"?"secp224r1":e==="2b81040022"?"secp384r1":e==="2b81040023"?"secp521r1":"|secp256r1|NIST P-256|P-256|prime256v1|".indexOf(e)!==-1?"secp256r1":"|secp256k1|".indexOf(e)!==-1?"secp256k1":"|secp224r1|NIST P-224|P-224|".indexOf(e)!==-1?"secp224r1":"|secp384r1|NIST P-384|P-384|".indexOf(e)!==-1?"secp384r1":"|secp521r1|NIST P-521|P-521|".indexOf(e)!==-1?"secp521r1":null};(typeof d>"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.ECParameterDB=new function(){var e={},t={};function r(n){return new ee(n,16)}this.getByName=function(n){var i=n;if(typeof t[i]<"u"&&(i=t[n]),typeof e[i]<"u")return e[i];throw"unregistered EC curve name: "+i},this.regist=function(n,i,a,s,c,l,h,v,E,p,f,A){e[n]={};var g=r(a),y=r(s),w=r(c),S=r(l),_=r(h),I=new Cs(g,y,w),B=I.decodePointHex("04"+v+E);e[n].name=n,e[n].keylen=i,e[n].keycharlen=Math.ceil(i/8)*2,e[n].curve=I,e[n].G=B,e[n].n=S,e[n].h=_,e[n].oid=f,e[n].info=A;for(var q=0;q"u"||!d)&&(d={});(typeof d.crypto>"u"||!d.crypto)&&(d.crypto={});d.crypto.DSA=function(){var e=Ae,t=e.getVbyList,r=e.getVbyListEx,n=e.isASN1HEX,i=ee;this.p=null,this.q=null,this.g=null,this.y=null,this.x=null,this.type="DSA",this.isPrivate=!1,this.isPublic=!1,this.setPrivate=function(a,s,c,l,h){this.isPrivate=!0,this.p=a,this.q=s,this.g=c,this.y=l,this.x=h},this.setPrivateHex=function(a,s,c,l,h){var v,E,p,f,A;v=new ee(a,16),E=new ee(s,16),p=new ee(c,16),typeof l=="string"&&l.length>1?f=new ee(l,16):f=null,A=new ee(h,16),this.setPrivate(v,E,p,f,A)},this.setPublic=function(a,s,c,l){this.isPublic=!0,this.p=a,this.q=s,this.g=c,this.y=l,this.x=null},this.setPublicHex=function(a,s,c,l){var h,v,E,p;h=new ee(a,16),v=new ee(s,16),E=new ee(c,16),p=new ee(l,16),this.setPublic(h,v,E,p)},this.signWithMessageHash=function(a){var s=this.p,c=this.q,l=this.g,h=this.y,v=this.x,E=d.crypto.Util.getRandomBigIntegerMinToMax(ee.ONE.add(ee.ONE),c.subtract(ee.ONE)),p=a.substr(0,c.bitLength()/4),f=new ee(p,16),A=l.modPow(E,s).mod(c),g=E.modInverse(c).multiply(f.add(v.multiply(A))).mod(c),y=d.asn1.ASN1Util.jsonToASN1HEX({seq:[{int:{bigint:A}},{int:{bigint:g}}]});return y},this.verifyWithMessageHash=function(a,s){var c=this.p,l=this.q,h=this.g,v=this.y,E=this.parseASN1Signature(s),p=E[0],f=E[1],A=a.substr(0,l.bitLength()/4),g=new ee(A,16);if(ee.ZERO.compareTo(p)>0||p.compareTo(l)>0||ee.ZERO.compareTo(f)>=0||f.compareTo(l)>0)throw"invalid DSA signature";var y=f.modInverse(l),w=g.multiply(y).mod(l),S=p.multiply(y).mod(l),_=h.modPow(w,c).multiply(v.modPow(S,c)).mod(c).mod(l);return _.compareTo(p)==0},this.parseASN1Signature=function(a){try{var s=new i(r(a,0,[0],"02"),16),c=new i(r(a,0,[1],"02"),16);return[s,c]}catch{throw new Error("malformed ASN.1 DSA signature")}},this.readPKCS5PrvKeyHex=function(a){var s,c,l,h,v;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1],"02"),c=r(a,0,[2],"02"),l=r(a,0,[3],"02"),h=r(a,0,[4],"02"),v=r(a,0,[5],"02")}catch{throw new Error("malformed PKCS#1/5 plain DSA private key")}this.setPrivateHex(s,c,l,h,v)},this.readPKCS8PrvKeyHex=function(a){var s,c,l,h;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[1,1,0],"02"),c=r(a,0,[1,1,1],"02"),l=r(a,0,[1,1,2],"02"),h=r(a,0,[2,0],"02")}catch{throw new Error("malformed PKCS#8 plain DSA private key")}this.setPrivateHex(s,c,l,null,h)},this.readPKCS8PubKeyHex=function(a){var s,c,l,h;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{s=r(a,0,[0,1,0],"02"),c=r(a,0,[0,1,1],"02"),l=r(a,0,[0,1,2],"02"),h=r(a,0,[1,0],"02")}catch{throw new Error("malformed PKCS#8 DSA public key")}this.setPublicHex(s,c,l,h)},this.readCertPubKeyHex=function(a,s){var c,l,h,v;if(n(a)===!1)throw new Error("not ASN.1 hex string");try{c=r(a,0,[0,5,0,1,0],"02"),l=r(a,0,[0,5,0,1,1],"02"),h=r(a,0,[0,5,0,1,2],"02"),v=r(a,0,[0,5,1,0],"02")}catch{throw new Error("malformed X.509 certificate DSA public key")}this.setPublicHex(c,l,h,v)}};var st=function(){var e=function(g,y,w){return n(be.AES,g,y,w)},t=function(g,y,w){return n(be.TripleDES,g,y,w)},r=function(g,y,w){return n(be.DES,g,y,w)},n=function(g,y,w,S){var _=be.enc.Hex.parse(y),I=be.enc.Hex.parse(w),B=be.enc.Hex.parse(S),q={};q.key=I,q.iv=B,q.ciphertext=_;var z=g.decrypt(q,I,{iv:B});return be.enc.Hex.stringify(z)},i=function(g,y,w){return c(be.AES,g,y,w)},a=function(g,y,w){return c(be.TripleDES,g,y,w)},s=function(g,y,w){return c(be.DES,g,y,w)},c=function(g,y,w,S){var _=be.enc.Hex.parse(y),I=be.enc.Hex.parse(w),B=be.enc.Hex.parse(S),q=g.encrypt(_,I,{iv:B}),z=be.enc.Hex.parse(q.toString()),F=be.enc.Base64.stringify(z);return F},l={"AES-256-CBC":{proc:e,eproc:i,keylen:32,ivlen:16},"AES-192-CBC":{proc:e,eproc:i,keylen:24,ivlen:16},"AES-128-CBC":{proc:e,eproc:i,keylen:16,ivlen:16},"DES-EDE3-CBC":{proc:t,eproc:a,keylen:24,ivlen:8},"DES-CBC":{proc:r,eproc:s,keylen:8,ivlen:8}},h=function(g){return l[g].proc},v=function(g){var y=be.lib.WordArray.random(g),w=be.enc.Hex.stringify(y);return w},E=function(g){var y={},w=g.match(new RegExp("DEK-Info: ([^,]+),([0-9A-Fa-f]+)","m"));w&&(y.cipher=w[1],y.ivsalt=w[2]);var S=g.match(new RegExp("-----BEGIN ([A-Z]+) PRIVATE KEY-----"));S&&(y.type=S[1]);var _=-1,I=0;g.indexOf(`\r \r `)!=-1&&(_=g.indexOf(`\r \r `),I=2),g.indexOf(` `)!=-1&&(_=g.indexOf(` `),I=1);var B=g.indexOf("-----END");if(_!=-1&&B!=-1){var q=g.substring(_+I*2,B-I);q=q.replace(/\s+/g,""),y.data=q}return y},p=function(g,y,w){for(var S=w.substring(0,16),_=be.enc.Hex.parse(S),I=be.enc.Utf8.parse(y),B=l[g].keylen+l[g].ivlen,q="",z=null;;){var F=be.algo.MD5.create();if(z!=null&&F.update(z),F.update(I),F.update(_),z=F.finalize(),q=q+be.enc.Hex.stringify(z),q.length>=B*2)break}var P={};return P.keyhex=q.substr(0,l[g].keylen*2),P.ivhex=q.substr(l[g].keylen*2,l[g].ivlen*2),P},f=function(g,y,w,S){var _=be.enc.Base64.parse(g),I=be.enc.Hex.stringify(_),B=l[y].proc,q=B(I,w,S);return q},A=function(g,y,w,S){var _=l[y].eproc,I=_(g,w,S);return I};return{version:"1.0.0",parsePKCS5PEM:function(g){return E(g)},getKeyAndUnusedIvByPasscodeAndIvsalt:function(g,y,w){return p(g,y,w)},decryptKeyB64:function(g,y,w,S){return f(g,y,w,S)},getDecryptedKeyHex:function(g,y){var w=E(g),S=w.type,_=w.cipher,I=w.ivsalt,B=w.data,q=p(_,y,I),z=q.keyhex,F=f(B,_,z,I);return F},getEncryptedPKCS5PEMFromPrvKeyHex:function(g,y,w,S,_){var L="";if((typeof S>"u"||S==null)&&(S="AES-256-CBC"),typeof l[S]>"u")throw new Error("KEYUTIL unsupported algorithm: "+S);if(typeof _>"u"||_==null){var I=l[S].ivlen,B=v(I);_=B.toUpperCase()}var q=p(S,w,_),z=q.keyhex,F=A(y,S,z,_),P=F.replace(/(.{64})/g,`$1\r `),L="-----BEGIN "+g+` PRIVATE KEY-----\r `;return L+=`Proc-Type: 4,ENCRYPTED\r `,L+="DEK-Info: "+S+","+_+`\r `,L+=`\r `,L+=P,L+=`\r -----END `+g+` PRIVATE KEY-----\r `,L},getEncryptedPKCS8PEM:function(g,y,w){var S=this.getEncryptedPKCS8Hex(g,y,w);return Gr(S,"ENCRYPTED PRIVATE KEY")},getEncryptedPKCS8Hex:function(g,y,w){var S;w==null||w==null?S={}:S=JSON.parse(JSON.stringify(w)),S.plain=g,this.initPBES2Param(S),this.encryptPBES2Param(S,y);var _=this.generatePBES2ASN1Param(S);return d.asn1.ASN1Util.newObject(_).tohex()},initPBES2Param:function(g){if(Pt(g,"encalg")==null&&(g.encalg="aes256-CBC"),Pt(g,"iter")==null&&(g.iter=2048),Pt(g,"prf")==null&&(g.prf="hmacWithSHA256"),Pt(g,"salt")==null&&(g.salt=be.enc.Hex.stringify(be.lib.WordArray.random(8))),Pt(g,"enciv")==null){var y;g.encalg=="des-EDE3-CBC"&&(y=8),g.encalg=="aes128-CBC"&&(y=16),g.encalg=="aes256-CBC"&&(y=16),g.enciv=be.enc.Hex.stringify(be.lib.WordArray.random(y))}},encryptPBES2Param:function(g,y){var w=st.getDKFromPBES2Param(g,y);try{var S=d.crypto.Cipher.encrypt(g.plain,w,g.encalg,{iv:g.enciv})}catch{throw new Error("encrypt error: "+g.plain+" "+w+" "+g.encalg+" "+g.enciv)}g.enc=S},generatePBES2ASN1Param:function(g){var y={seq:[{seq:[{oid:"pkcs5PBES2"},{seq:[{seq:[{oid:"pkcs5PBKDF2"},{seq:[{octstr:{hex:g.salt}},{int:{hex:z2(g.iter)}}]}]},{seq:[{oid:g.encalg},{octstr:{hex:g.enciv}}]}]}]},{octstr:{hex:g.enc}}]};return g.prf!="hmacWithSHA1"&&y.seq[0].seq[1].seq[0].seq[1].seq.push({seq:[{oid:g.prf},{null:""}]}),y},parseHexOfEncryptedPKCS8:function(g){var y=Ae,w=y.getChildIdx,S=y.getV,_={},I=w(g,0);if(I.length!=2)throw new Error("malformed format: SEQUENCE(0).items != 2: "+I.length);_.ciphertext=S(g,I[1]);var B=w(g,I[0]);if(B.length!=2)throw new Error("malformed format: SEQUENCE(0.0).items != 2: "+B.length);if(S(g,B[0])!="2a864886f70d01050d")throw new Error("this only supports pkcs5PBES2");var q=w(g,B[1]);if(B.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1).items != 2: "+q.length);var z=w(g,q[1]);if(z.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.1).items != 2: "+z.length);if(S(g,z[0])!="2a864886f70d0307")throw"this only supports TripleDES";_.encryptionSchemeAlg="TripleDES",_.encryptionSchemeIV=S(g,z[1]);var F=w(g,q[0]);if(F.length!=2)throw new Error("malformed format: SEQUENCE(0.0.1.0).items != 2: "+F.length);if(S(g,F[0])!="2a864886f70d01050c")throw new Error("this only supports pkcs5PBKDF2");var P=w(g,F[1]);if(P.length<2)throw new Error("malformed format: SEQUENCE(0.0.1.0.1).items < 2: "+P.length);_.pbkdf2Salt=S(g,P[0]);var L=S(g,P[1]);try{_.pbkdf2Iter=parseInt(L,16)}catch{throw new Error("malformed format pbkdf2Iter: "+L)}return _},getPBKDF2KeyHexFromParam:function(g,y){var w=be.enc.Hex.parse(g.pbkdf2Salt),S=g.pbkdf2Iter,_=be.PBKDF2(y,w,{keySize:192/32,iterations:S}),I=be.enc.Hex.stringify(_);return I},_getPlainPKCS8HexFromEncryptedPKCS8PEM:function(g,y){var w=Kt(g,"ENCRYPTED PRIVATE KEY"),S=this.parseHexOfEncryptedPKCS8(w),_=st.getPBKDF2KeyHexFromParam(S,y),I={};I.ciphertext=be.enc.Hex.parse(S.ciphertext);var B=be.enc.Hex.parse(_),q=be.enc.Hex.parse(S.encryptionSchemeIV),z=be.TripleDES.decrypt(I,B,{iv:q}),F=be.enc.Hex.stringify(z);return F},parsePBES2:function(g){var y=Ae.parse(g);if(Pt(y,"seq.0.seq.0.oid")!="pkcs5PBES2"||Pt(y,"seq.0.seq.1.seq.0.seq.0.oid")!="pkcs5PBKDF2")throw new Error("not pkcs5PBES2 and pkcs5PBKDF2 used");var w=Pt(y,"seq.0.seq.1.seq.0.seq.1.seq");if(w==null)throw new Error("PBKDF2 parameter not found");var S=Pt(w,"0.octstr.hex"),_=Pt(w,"1.int.hex"),I=Pt(w,"2.seq.0.oid","hmacWithSHA1"),B=-1;try{B=parseInt(_,16)}catch{throw new Error("iter not proper value")}var q=Pt(y,"seq.0.seq.1.seq.1.seq.0.oid"),z=Pt(y,"seq.0.seq.1.seq.1.seq.1.octstr.hex"),F=Pt(y,"seq.1.octstr.hex");if(q==null||z==null||F==null)throw new Error("encalg, enciv or enc is undefined");var P={salt:S,iter:B,prf:I,encalg:q,enciv:z,enc:F};return P},getDKFromPBES2Param:function(g,y){var w={hmacWithSHA1:be.algo.SHA1,hmacWithSHA224:be.algo.SHA224,hmacWithSHA256:be.algo.SHA256,hmacWithSHA384:be.algo.SHA384,hmacWithSHA512:be.algo.SHA512},S={"des-EDE3-CBC":192/32,"aes128-CBC":128/32,"aes256-CBC":256/32},_=w[g.prf];if(_==null)throw new Error("unsupported prf");var I=S[g.encalg];if(I==null)throw new Error("unsupported encalg");var B=be.enc.Hex.parse(g.salt),q=g.iter;try{var z=be.PBKDF2(y,B,{keySize:I,iterations:q,hasher:_});return be.enc.Hex.stringify(z)}catch(F){throw new Error("PBKDF2 error: "+F+" "+JSON.stringify(g)+" "+y)}},getPlainHexFromEncryptedPKCS8PEM:function(g,y){if(g.indexOf("BEGIN ENCRYPTED PRIVATE KEY")==-1)throw new Error("not Encrypted PKCS#8 PEM string");var w=Kt(g),S;try{S=st.parsePBES2(w)}catch(I){throw new Error("malformed PBES2 format: "+I.message)}var _=st.getDKFromPBES2Param(S,y);return d.crypto.Cipher.decrypt(S.enc,_,S.encalg,{iv:S.enciv})},getKeyFromEncryptedPKCS8PEM:function(g,y){var w=this.getPlainHexFromEncryptedPKCS8PEM(g,y),S=this.getKeyFromPlainPrivatePKCS8Hex(w);return S},parsePlainPrivatePKCS8Hex:function(g){var y=Ae,w=y.getChildIdx,S=y.getV,_={};if(_.algparam=null,g.substr(0,2)!="30")throw new Error("malformed plain PKCS8 private key(code:001)");var I=w(g,0);if(I.length<3)throw new Error("malformed plain PKCS8 private key(code:002)");if(g.substr(I[1],2)!="30")throw new Error("malformed PKCS8 private key(code:003)");var B=w(g,I[1]);if(B.length!=2)throw new Error("malformed PKCS8 private key(code:004)");if(g.substr(B[0],2)!="06")throw new Error("malformed PKCS8 private key(code:005)");if(_.algoid=S(g,B[0]),g.substr(B[1],2)=="06"&&(_.algparam=S(g,B[1])),g.substr(I[2],2)!="04")throw new Error("malformed PKCS8 private key(code:006)");return _.keyidx=y.getVidx(g,I[2]),_},getKeyFromPlainPrivatePKCS8PEM:function(g){var y=Kt(g,"PRIVATE KEY"),w=this.getKeyFromPlainPrivatePKCS8Hex(y);return w},getKeyFromPlainPrivatePKCS8Hex:function(g){var y=this.parsePlainPrivatePKCS8Hex(g),w;if(y.algoid=="2a864886f70d010101")w=new ze;else if(y.algoid=="2a8648ce380401")w=new d.crypto.DSA;else if(y.algoid=="2a8648ce3d0201")w=new d.crypto.ECDSA;else throw new Error("unsupported private key algorithm");return w.readPKCS8PrvKeyHex(g),w},_getKeyFromPublicPKCS8Hex:function(g){var y,w=Ae.getVbyList(g,0,[0,0],"06");if(w==="2a864886f70d010101")y=new ze;else if(w==="2a8648ce380401")y=new d.crypto.DSA;else if(w==="2a8648ce3d0201")y=new d.crypto.ECDSA;else throw new Error("unsupported PKCS#8 public key hex");return y.readPKCS8PubKeyHex(g),y},parsePublicRawRSAKeyHex:function(g){var y=Ae,w=y.getChildIdx,S=y.getV,_={};if(g.substr(0,2)!="30")throw new Error("malformed RSA key(code:001)");var I=w(g,0);if(I.length!=2)throw new Error("malformed RSA key(code:002)");if(g.substr(I[0],2)!="02")throw new Error("malformed RSA key(code:003)");if(_.n=S(g,I[0]),g.substr(I[1],2)!="02")throw new Error("malformed RSA key(code:004)");return _.e=S(g,I[1]),_},parsePublicPKCS8Hex:function(g){var y=Ae,w=y.getChildIdx,S=y.getV,_={};_.algparam=null;var I=w(g,0);if(I.length!=2)throw new Error("outer DERSequence shall have 2 elements: "+I.length);var B=I[0];if(g.substr(B,2)!="30")throw new Error("malformed PKCS8 public key(code:001)");var q=w(g,B);if(q.length!=2)throw new Error("malformed PKCS8 public key(code:002)");if(g.substr(q[0],2)!="06")throw new Error("malformed PKCS8 public key(code:003)");if(_.algoid=S(g,q[0]),g.substr(q[1],2)=="06"?_.algparam=S(g,q[1]):g.substr(q[1],2)=="30"&&(_.algparam={},_.algparam.p=y.getVbyList(g,q[1],[0],"02"),_.algparam.q=y.getVbyList(g,q[1],[1],"02"),_.algparam.g=y.getVbyList(g,q[1],[2],"02")),g.substr(I[1],2)!="03")throw new Error("malformed PKCS8 public key(code:004)");return _.key=S(g,I[1]).substr(2),_}}}();st.getKey=function(e,t,r){var n=Ae,i=n.getChildIdx,a=n.getV,s=n.getVbyList,c=d.crypto,l=c.ECDSA,h=c.DSA,v=ze,E=Kt,p=st;if(typeof v<"u"&&e instanceof v||typeof l<"u"&&e instanceof l||typeof h<"u"&&e instanceof h)return e;if(e.curve!==void 0&&e.xy!==void 0&&e.d===void 0)return new l({pub:e.xy,curve:e.curve});if(e.curve!==void 0&&e.d!==void 0)return new l({prv:e.d,curve:e.curve});if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var f=new v;return f.setPublic(e.n,e.e),f}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.co!==void 0&&e.qi===void 0){var f=new v;return f.setPrivateEx(e.n,e.e,e.d,e.p,e.q,e.dp,e.dq,e.co),f}if(e.kty===void 0&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p===void 0){var f=new v;return f.setPrivate(e.n,e.e,e.d),f}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x===void 0){var f=new h;return f.setPublic(e.p,e.q,e.g,e.y),f}if(e.p!==void 0&&e.q!==void 0&&e.g!==void 0&&e.y!==void 0&&e.x!==void 0){var f=new h;return f.setPrivate(e.p,e.q,e.g,e.y,e.x),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d===void 0){var f=new v;return f.setPublic(Nt(e.n),Nt(e.e)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0&&e.p!==void 0&&e.q!==void 0&&e.dp!==void 0&&e.dq!==void 0&&e.qi!==void 0){var f=new v;return f.setPrivateEx(Nt(e.n),Nt(e.e),Nt(e.d),Nt(e.p),Nt(e.q),Nt(e.dp),Nt(e.dq),Nt(e.qi)),f}if(e.kty==="RSA"&&e.n!==void 0&&e.e!==void 0&&e.d!==void 0){var f=new v;return f.setPrivate(Nt(e.n),Nt(e.e),Nt(e.d)),f}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d===void 0){var A=new l({curve:e.crv}),g=A.ecparams.keycharlen,y=("0000000000"+Nt(e.x)).slice(-g),w=("0000000000"+Nt(e.y)).slice(-g),S="04"+y+w;return A.setPublicKeyHex(S),A}if(e.kty==="EC"&&e.crv!==void 0&&e.x!==void 0&&e.y!==void 0&&e.d!==void 0){var A=new l({curve:e.crv}),g=A.ecparams.keycharlen,y=("0000000000"+Nt(e.x)).slice(-g),w=("0000000000"+Nt(e.y)).slice(-g),S="04"+y+w,_=("0000000000"+Nt(e.d)).slice(-g);return A.setPublicKeyHex(S),A.setPrivateKeyHex(_),A}if(r==="pkcs5prv"){var I=e,n=Ae,B,f;if(B=i(I,0),B.length===9)f=new v,f.readPKCS5PrvKeyHex(I);else if(B.length===6)f=new h,f.readPKCS5PrvKeyHex(I);else if(B.length>2&&I.substr(B[1],2)==="04")f=new l,f.readPKCS5PrvKeyHex(I);else throw new Error("unsupported PKCS#1/5 hexadecimal key");return f}if(r==="pkcs8prv"){var f=p.getKeyFromPlainPrivatePKCS8Hex(e);return f}if(r==="pkcs8pub")return p._getKeyFromPublicPKCS8Hex(e);if(r==="x509pub")return He.getPublicKeyFromCertHex(e);if(e.indexOf("-END CERTIFICATE-",0)!=-1||e.indexOf("-END X509 CERTIFICATE-",0)!=-1||e.indexOf("-END TRUSTED CERTIFICATE-",0)!=-1)return He.getPublicKeyFromCertPEM(e);if(e.indexOf("-END PUBLIC KEY-")!=-1){var q=Kt(e,"PUBLIC KEY");return p._getKeyFromPublicPKCS8Hex(q)}if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var z=E(e,"RSA PRIVATE KEY");return p.getKey(z,null,"pkcs5prv")}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var F=E(e,"DSA PRIVATE KEY"),P=s(F,0,[1],"02"),L=s(F,0,[2],"02"),H=s(F,0,[3],"02"),K=s(F,0,[4],"02"),Z=s(F,0,[5],"02"),f=new h;return f.setPrivate(new ee(P,16),new ee(L,16),new ee(H,16),new ee(K,16),new ee(Z,16)),f}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")==-1){var z=E(e,"EC PRIVATE KEY");return p.getKey(z,null,"pkcs5prv")}if(e.indexOf("-END PRIVATE KEY-")!=-1)return p.getKeyFromPlainPrivatePKCS8PEM(e);if(e.indexOf("-END RSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var G=p.getDecryptedKeyHex(e,t),V=new ze;return V.readPKCS5PrvKeyHex(G),V}if(e.indexOf("-END EC PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),f=s(F,0,[1],"04"),X=s(F,0,[2,0],"06"),ie=s(F,0,[3,0],"03").substr(2),Se="";if(d.crypto.OID.oidhex2name[X]!==void 0)Se=d.crypto.OID.oidhex2name[X];else throw new Error("undefined OID(hex) in KJUR.crypto.OID: "+X);var A=new l({curve:Se});return A.setPublicKeyHex(ie),A.setPrivateKeyHex(f),A.isPublic=!1,A}if(e.indexOf("-END DSA PRIVATE KEY-")!=-1&&e.indexOf("4,ENCRYPTED")!=-1){var F=p.getDecryptedKeyHex(e,t),P=s(F,0,[1],"02"),L=s(F,0,[2],"02"),H=s(F,0,[3],"02"),K=s(F,0,[4],"02"),Z=s(F,0,[5],"02"),f=new h;return f.setPrivate(new ee(P,16),new ee(L,16),new ee(H,16),new ee(K,16),new ee(Z,16)),f}if(e.indexOf("-END ENCRYPTED PRIVATE KEY-")!=-1)return p.getKeyFromEncryptedPKCS8PEM(e,t);throw new Error("not supported argument")};st.generateKeypair=function(e,t){if(e=="RSA"){var r=t,n=new ze;n.generate(r,"10001"),n.isPrivate=!0,n.isPublic=!0;var i=new ze,a=n.n.toString(16),s=n.e.toString(16);i.setPublic(a,s),i.isPrivate=!1,i.isPublic=!0;var c={};return c.prvKeyObj=n,c.pubKeyObj=i,c}else if(e=="EC"){var l=t,h=new d.crypto.ECDSA({curve:l}),v=h.generateKeyPairHex(),n=new d.crypto.ECDSA({curve:l});n.setPublicKeyHex(v.ecpubhex),n.setPrivateKeyHex(v.ecprvhex),n.isPrivate=!0,n.isPublic=!1;var i=new d.crypto.ECDSA({curve:l});i.setPublicKeyHex(v.ecpubhex),i.isPrivate=!1,i.isPublic=!0;var c={};return c.prvKeyObj=n,c.pubKeyObj=i,c}else throw new Error("unknown algorithm: "+e)};st.getPEM=function(e,t,r,n,i,a){var s=d,c=s.asn1,l=c.DERObjectIdentifier,h=c.DERInteger,v=c.ASN1Util.newObject,E=c.x509,p=E.SubjectPublicKeyInfo,f=s.crypto,A=f.DSA,g=f.ECDSA,y=ze;function w(V){var X=v({seq:[{int:0},{int:{bigint:V.n}},{int:V.e},{int:{bigint:V.d}},{int:{bigint:V.p}},{int:{bigint:V.q}},{int:{bigint:V.dmp1}},{int:{bigint:V.dmq1}},{int:{bigint:V.coeff}}]});return X}function S(V){var X=v({seq:[{int:1},{octstr:{hex:V.prvKeyHex}},{tag:["a0",!0,{oid:{name:V.curveName}}]},{tag:["a1",!0,{bitstr:{hex:"00"+V.pubKeyHex}}]}]});return X}function _(V){var X=v({seq:[{int:0},{int:{bigint:V.p}},{int:{bigint:V.q}},{int:{bigint:V.g}},{int:{bigint:V.y}},{int:{bigint:V.x}}]});return X}if((y!==void 0&&e instanceof y||A!==void 0&&e instanceof A||g!==void 0&&e instanceof g)&&e.isPublic==!0&&(t===void 0||t=="PKCS8PUB")){var I=new p(e),B=I.tohex();return Gr(B,"PUBLIC KEY")}if(t=="PKCS1PRV"&&y!==void 0&&e instanceof y&&(r===void 0||r==null)&&e.isPrivate==!0){var I=w(e),B=I.tohex();return Gr(B,"RSA PRIVATE KEY")}if(t=="PKCS1PRV"&&g!==void 0&&e instanceof g&&(r===void 0||r==null)&&e.isPrivate==!0){var q=new l({name:e.curveName}),z=q.tohex(),F=S(e),P=F.tohex(),L="";return L+=Gr(z,"EC PARAMETERS"),L+=Gr(P,"EC PRIVATE KEY"),L}if(t=="PKCS1PRV"&&A!==void 0&&e instanceof A&&(r===void 0||r==null)&&e.isPrivate==!0){var I=_(e),B=I.tohex();return Gr(B,"DSA PRIVATE KEY")}if(t=="PKCS5PRV"&&y!==void 0&&e instanceof y&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=w(e),B=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("RSA",B,r,n,a)}if(t=="PKCS5PRV"&&g!==void 0&&e instanceof g&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=S(e),B=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("EC",B,r,n,a)}if(t=="PKCS5PRV"&&A!==void 0&&e instanceof A&&r!==void 0&&r!=null&&e.isPrivate==!0){var I=_(e),B=I.tohex();return n===void 0&&(n="DES-EDE3-CBC"),this.getEncryptedPKCS5PEMFromPrvKeyHex("DSA",B,r,n,a)}var H=function(V,X){if(typeof X=="string")return st.getEncryptedPKCS8PEM(V,X);if(typeof X=="object"&&Pt(X,"passcode")!=null){var ie=JSON.parse(JSON.stringify(X)),Se=ie.passcode;return delete ie.passcode,st.getEncryptedPKCS8PEM(V,Se,ie)}};if(t=="PKCS8PRV"&&y!=null&&e instanceof y&&e.isPrivate==!0){var K=w(e),Z=K.tohex(),I=v({seq:[{int:0},{seq:[{oid:{name:"rsaEncryption"}},{null:!0}]},{octstr:{hex:Z}}]}),B=I.tohex();return r===void 0||r==null?Gr(B,"PRIVATE KEY"):H(B,r)}if(t=="PKCS8PRV"&&g!==void 0&&e instanceof g&&e.isPrivate==!0){var G={seq:[{int:1},{octstr:{hex:e.prvKeyHex}}]};typeof e.pubKeyHex=="string"&&G.seq.push({tag:["a1",!0,{bitstr:{hex:"00"+e.pubKeyHex}}]});var K=new v(G),Z=K.tohex(),I=v({seq:[{int:0},{seq:[{oid:{name:"ecPublicKey"}},{oid:{name:e.curveName}}]},{octstr:{hex:Z}}]}),B=I.tohex();return r===void 0||r==null?Gr(B,"PRIVATE KEY"):H(B,r)}if(t=="PKCS8PRV"&&A!==void 0&&e instanceof A&&e.isPrivate==!0){var K=new h({bigint:e.x}),Z=K.tohex(),I=v({seq:[{int:0},{seq:[{oid:{name:"dsa"}},{seq:[{int:{bigint:e.p}},{int:{bigint:e.q}},{int:{bigint:e.g}}]}]},{octstr:{hex:Z}}]}),B=I.tohex();return r===void 0||r==null?Gr(B,"PRIVATE KEY"):H(B,r)}throw new Error("unsupported object nor format")};st.getKeyFromCSRPEM=function(e){var t=Kt(e,"CERTIFICATE REQUEST"),r=st.getKeyFromCSRHex(t);return r};st.getKeyFromCSRHex=function(e){var t=st.parseCSRHex(e),r=st.getKey(t.p8pubkeyhex,null,"pkcs8pub");return r};st.parseCSRHex=function(e){var t=Ae,r=t.getChildIdx,n=t.getTLV,i={},a=e;if(a.substr(0,2)!="30")throw new Error("malformed CSR(code:001)");var s=r(a,0);if(s.length<1)throw new Error("malformed CSR(code:002)");if(a.substr(s[0],2)!="30")throw new Error("malformed CSR(code:003)");var c=r(a,s[0]);if(c.length<3)throw new Error("malformed CSR(code:004)");return i.p8pubkeyhex=n(a,c[2]),i};st.getKeyID=function(e){var t=st,r=Ae;typeof e=="string"&&e.indexOf("BEGIN ")!=-1&&(e=t.getKey(e));var n=Kt(t.getPEM(e)),i=r.getIdxbyList(n,0,[1]),a=r.getV(n,i).substring(2);return d.crypto.Util.hashHex(a,"sha1")};st.getJWK=function(e,t,r,n,i){var a,s={},c,l=d.crypto.Util.hashHex;if(typeof e=="string")a=st.getKey(e),e.indexOf("CERTIFICATE")!=-1&&(c=Kt(e));else if(typeof e=="object")e instanceof He?(a=e.getPublicKey(),c=e.hex):a=e;else throw new Error("unsupported keyinfo type");if(a instanceof ze&&a.isPrivate)s.kty="RSA",s.n=dr(a.n.toString(16)),s.e=dr(a.e.toString(16)),s.d=dr(a.d.toString(16)),s.p=dr(a.p.toString(16)),s.q=dr(a.q.toString(16)),s.dp=dr(a.dmp1.toString(16)),s.dq=dr(a.dmq1.toString(16)),s.qi=dr(a.coeff.toString(16));else if(a instanceof ze&&a.isPublic)s.kty="RSA",s.n=dr(a.n.toString(16)),s.e=dr(a.e.toString(16));else if(a instanceof d.crypto.ECDSA&&a.isPrivate){var h=a.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var v=a.getPublicKeyXYHex();s.kty="EC",s.crv=h,s.x=dr(v.x),s.y=dr(v.y),s.d=dr(a.prvKeyHex)}else if(a instanceof d.crypto.ECDSA&&a.isPublic){var h=a.getShortNISTPCurveName();if(h!=="P-256"&&h!=="P-384"&&h!=="P-521")throw new Error("unsupported curve name for JWT: "+h);var v=a.getPublicKeyXYHex();s.kty="EC",s.crv=h,s.x=dr(v.x),s.y=dr(v.y)}if(s.kty==null)throw new Error("unsupported keyinfo");return!a.isPrivate&&t!=!0&&(s.kid=d.jws.JWS.getJWKthumbprint(s)),c!=null&&r!=!0&&(s.x5c=[bs(c)]),c!=null&&n!=!0&&(s.x5t=Ao(bs(l(c,"sha1")))),c!=null&&i!=!0&&(s["x5t#S256"]=Ao(bs(l(c,"sha256")))),s};st.getJWKFromKey=function(e){return st.getJWK(e,!0,!0,!0,!0)};ze.getPosArrayOfChildrenFromHex=function(e){return Ae.getChildIdx(e,0)};ze.getHexValueArrayOfChildrenFromHex=function(e){var t=Ae,r=t.getV,p=ze.getPosArrayOfChildrenFromHex(e),n=r(e,p[0]),i=r(e,p[1]),a=r(e,p[2]),s=r(e,p[3]),c=r(e,p[4]),l=r(e,p[5]),h=r(e,p[6]),v=r(e,p[7]),E=r(e,p[8]),p=new Array;return p.push(n,i,a,s,c,l,h,v,E),p};ze.prototype.readPrivateKeyFromPEMString=function(e){var t=Kt(e),r=ze.getHexValueArrayOfChildrenFromHex(t);this.setPrivateEx(r[1],r[2],r[3],r[4],r[5],r[6],r[7],r[8])};ze.prototype.readPKCS5PrvKeyHex=function(e){var t=ze.getHexValueArrayOfChildrenFromHex(e);this.setPrivateEx(t[1],t[2],t[3],t[4],t[5],t[6],t[7],t[8])};ze.prototype.readPKCS8PrvKeyHex=function(e){var t,r,n,i,a,s,c,l,h=Ae,v=h.getVbyListEx;if(h.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");try{t=v(e,0,[2,0,1],"02"),r=v(e,0,[2,0,2],"02"),n=v(e,0,[2,0,3],"02"),i=v(e,0,[2,0,4],"02"),a=v(e,0,[2,0,5],"02"),s=v(e,0,[2,0,6],"02"),c=v(e,0,[2,0,7],"02"),l=v(e,0,[2,0,8],"02")}catch{throw new Error("malformed PKCS#8 plain RSA private key")}this.setPrivateEx(t,r,n,i,a,s,c,l)};ze.prototype.readPKCS5PubKeyHex=function(e){var t=Ae,r=t.getV;if(t.isASN1HEX(e)===!1)throw new Error("keyHex is not ASN.1 hex string");var n=t.getChildIdx(e,0);if(n.length!==2||e.substr(n[0],2)!=="02"||e.substr(n[1],2)!=="02")throw new Error("wrong hex for PKCS#5 public key");var i=r(e,n[0]),a=r(e,n[1]);this.setPublic(i,a)};ze.prototype.readPKCS8PubKeyHex=function(e){var t=Ae;if(t.isASN1HEX(e)===!1)throw new Error("not ASN.1 hex string");if(t.getTLVbyListEx(e,0,[0,0])!=="06092a864886f70d010101")throw new Error("not PKCS8 RSA public key");var r=t.getTLVbyListEx(e,0,[1,0]);this.readPKCS5PubKeyHex(r)};ze.prototype.readCertPubKeyHex=function(e,t){var r,n;r=new He,r.readCertHex(e),n=r.getPublicKeyHex(),this.readPKCS8PubKeyHex(n)};var UT=new RegExp("[^0-9a-f]","gi");function J2(e,t){for(var r="",n=t/4-e.length,i=0;i>24,(i&16711680)>>16,(i&65280)>>8,i&255])))),i+=1;return n}ze.prototype.signPSS=function(e,t,r){var n=function(a){return d.crypto.Util.hashHex(a,t)},i=n(Hi(e));return r===void 0&&(r=-1),this.signWithMessageHashPSS(i,t,r)};ze.prototype.signWithMessageHashPSS=function(e,t,r){var n=En(e),i=n.length,a=this.n.bitLength()-1,s=Math.ceil(a/8),c,l=function(y){return d.crypto.Util.hashHex(y,t)};if(r===-1||r===void 0)r=i;else if(r===-2)r=s-i-2;else if(r<-2)throw new Error("invalid salt length");if(s0&&(h=new Array(r),new bo().nextBytes(h),h=String.fromCharCode.apply(String,h));var v=En(l(Hi("\0\0\0\0\0\0\0\0"+n+h))),E=[];for(c=0;c>8*s-a&255;for(A[0]&=~g,c=0;cn)return!1;var i=this.doPublic(r),a=i.toString(16);if(a.length+3!=n/4)return!1;var s=a.replace(/^1f+00/,""),c=Q2(s);if(c.length==0)return!1;var l=c[0],h=c[1],v=function(p){return d.crypto.Util.hashString(p,l)},E=v(e);return h==E};ze.prototype.verifyWithMessageHash=function(e,t){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var r=wn(t,16);if(r.bitLength()>this.n.bitLength())return 0;var n=this.doPublic(r),i=n.toString(16).replace(/^1f+00/,""),a=Q2(i);if(a.length==0)return!1;var s=a[0],c=a[1];return c==e};ze.prototype.verifyPSS=function(e,t,r,n){var i=function(s){return d.crypto.Util.hashHex(s,r)},a=i(Hi(e));return n===void 0&&(n=-1),this.verifyWithMessageHashPSS(a,t,r,n)};ze.prototype.verifyWithMessageHashPSS=function(e,t,r,n){if(t.length!=Math.ceil(this.n.bitLength()/4))return!1;var i=new ee(t,16),a=function(S){return d.crypto.Util.hashHex(S,r)},s=En(e),c=s.length,l=this.n.bitLength()-1,h=Math.ceil(l/8),v;if(n===-1||n===void 0)n=c;else if(n===-2)n=h-c-2;else if(n<-2)throw new Error("invalid salt length");if(h>8*h-l&255;if(p.charCodeAt(0)&A)throw new Error("bits beyond keysize not zero");var g=Z2(f,p.length,a),y=[];for(v=0;v0?P:void 0}catch{return}},this._asn1ToNoticeRef=function(F){try{for(var P={},L=Pt(F,"seq"),H=0;H0?P:void 0}catch{return}},this._asn1ToNoticeNum=function(F){try{for(var P=Pt(F,"seq"),L=[],H=0;H1){var Z=s(F,K[1]),G=this.getGeneralName(Z);G.uri!=null&&(H.uri=G.uri)}if(K.length>2){var V=s(F,K[2]);V=="0101ff"&&(H.reqauth=!0),V=="010100"&&(H.reqauth=!1)}return H},this.getExtSubjectDirectoryAttributes=function(F,P){if(F===void 0&&P===void 0){var L=this.getExtInfo("subjectDirectoryAttributes");if(L===void 0)return;F=s(this.hex,L.vidx),P=L.critical}var H={extname:"subjectDirectoryAttributes"};P&&(H.critical=!0);try{for(var K=a(F),Z=[],G=0;G0&&(P.ext=this.getExtParamArray()),P.sighex=this.getSignatureValueHex(),F.tbshex==!0&&(P.tbshex=h(this.hex,0,[0])),F.nodnarray==!0&&(delete P.issuer.array,delete P.subject.array),P},this.getExtParamArray=function(F){if(F==null){var P=p(this.hex,0,[0,"[3]"]);P!=-1&&(F=v(this.hex,0,[0,"[3]",0],"30"))}for(var L=[],H=r(F,0),K=0;K"u"||!d)&&(d={});(typeof d.jws>"u"||!d.jws)&&(d.jws={});d.jws.JWS=function(){var e=d,t=e.jws.JWS,r=t.isSafeJSONString;this.parseJWS=function(n,i){if(!(this.parsedJWS!==void 0&&(i||this.parsedJWS.sigvalH!==void 0))){var a=n.match(/^([^.]+)\.([^.]+)\.([^.]+)$/);if(a==null)throw"JWS signature is not a form of 'Head.Payload.SigValue'.";var s=a[1],c=a[2],l=a[3],h=s+"."+c;if(this.parsedJWS={},this.parsedJWS.headB64U=s,this.parsedJWS.payloadB64U=c,this.parsedJWS.sigvalB64U=l,this.parsedJWS.si=h,!i){var v=Nt(l),E=wn(v,16);this.parsedJWS.sigvalH=v,this.parsedJWS.sigvalBI=E}var p=mi(s),f=mi(c);if(this.parsedJWS.headS=p,this.parsedJWS.payloadS=f,!r(p,this.parsedJWS,"headP"))throw"malformed JSON string for JWS Head: "+p}}};d.jws.JWS.sign=function(e,t,r,n,i){var a=d,s=a.jws,c=s.JWS,l=c.readSafeJSONString,h=c.isSafeJSONString,v=a.crypto,E=v.ECDSA,p=v.Mac,f=v.Signature,A=JSON,g,y,w;if(typeof t!="string"&&typeof t!="object")throw"spHeader must be JSON string or object: "+t;if(typeof t=="object"&&(y=t,g=A.stringify(y)),typeof t=="string"){if(g=t,!h(g))throw"JWS Head is not safe JSON string: "+g;y=l(g)}if(w=r,typeof r=="object"&&(w=A.stringify(r)),(e==""||e==null)&&y.alg!==void 0&&(e=y.alg),e!=""&&e!=null&&y.alg===void 0&&(y.alg=e,g=A.stringify(y)),e!==y.alg)throw"alg and sHeader.alg doesn't match: "+e+"!="+y.alg;var S=null;if(c.jwsalg2sigalg[e]===void 0)throw"unsupported alg name: "+e;S=c.jwsalg2sigalg[e];var _=Lc(g),I=Lc(w),B=_+"."+I,q="";if(S.substr(0,4)=="Hmac"){if(n===void 0)throw"mac key shall be specified for HS* alg";var z=new p({alg:S,prov:"cryptojs",pass:n});z.updateString(B),q=z.doFinal()}else if(S.indexOf("withECDSA")!=-1){var F=new f({alg:S});F.init(n,i),F.updateString(B);var P=F.sign();q=d.crypto.ECDSA.asn1SigToConcatSig(P)}else if(S!="none"){var F=new f({alg:S});F.init(n,i),F.updateString(B),q=F.sign()}var L=dr(q);return B+"."+L};d.jws.JWS.verify=function(e,t,r){var n=d,i=n.jws,a=i.JWS,s=a.readSafeJSONString,c=n.crypto,l=c.ECDSA,h=c.Mac,v=c.Signature,E;if(typeof ze!==void 0&&(E=ze),!zd(e))return!1;var p=e.split(".");if(p.length!==3)return!1;var f=p[0],A=p[1],g=f+"."+A,y=Nt(p[2]),w=s(mi(p[0])),S=null,_=null;if(w.alg===void 0)throw"algorithm not specified in header";if(S=w.alg,_=S.substr(0,2),r!=null&&Object.prototype.toString.call(r)==="[object Array]"&&r.length>0){var I=":"+r.join(":")+":";if(I.indexOf(":"+S+":")==-1)throw"algorithm '"+S+"' not accepted in the list"}if(S!="none"&&t===null)throw"key shall be specified to verify.";if(typeof t=="string"&&t.indexOf("-----BEGIN ")!=-1&&(t=st.getKey(t)),(_=="RS"||_=="PS")&&!(t instanceof E))throw"key shall be a RSAKey obj for RS* and PS* algs";if(_=="ES"&&!(t instanceof l))throw"key shall be a ECDSA obj for ES* algs";S=="none";var B=null;if(a.jwsalg2sigalg[w.alg]===void 0)throw"unsupported alg name: "+S;if(B=a.jwsalg2sigalg[S],B=="none")throw"not supported";if(B.substr(0,4)=="Hmac"){var q=null;if(t===void 0)throw"hexadecimal key shall be specified for HMAC";var z=new h({alg:B,pass:t});return z.updateString(g),q=z.doFinal(),y==q}else if(B.indexOf("withECDSA")!=-1){var F=null;try{F=l.concatSigToASN1Sig(y)}catch{return!1}var P=new v({alg:B});return P.init(t),P.updateString(g),P.verify(F)}else{var P=new v({alg:B});return P.init(t),P.updateString(g),P.verify(y)}};d.jws.JWS.parse=function(e){var t=e.split("."),r={},n,i,a;if(t.length!=2&&t.length!=3)throw"malformed sJWS: wrong number of '.' splitted elements";return n=t[0],i=t[1],t.length==3&&(a=t[2]),r.headerObj=d.jws.JWS.readSafeJSONString(mi(n)),r.payloadObj=d.jws.JWS.readSafeJSONString(mi(i)),r.headerPP=JSON.stringify(r.headerObj,null," "),r.payloadObj==null?r.payloadPP=mi(i):r.payloadPP=JSON.stringify(r.payloadObj,null," "),a!==void 0&&(r.sigHex=Nt(a)),r};d.jws.JWS.verifyJWT=function(e,t,r){var n=d,i=n.jws,a=i.JWS,s=a.readSafeJSONString,c=a.inArray,l=a.includedArray;if(!zd(e))return!1;var h=e.split(".");if(h.length!=3)return!1;var v=h[0],E=h[1],p=v+"."+E,f=Nt(h[2]),A=s(mi(v)),g=s(mi(E));if(A.alg===void 0)return!1;if(r.alg===void 0)throw"acceptField.alg shall be specified";if(!c(A.alg,r.alg)||g.iss!==void 0&&typeof r.iss=="object"&&!c(g.iss,r.iss)||g.sub!==void 0&&typeof r.sub=="object"&&!c(g.sub,r.sub))return!1;if(g.aud!==void 0&&typeof r.aud=="object"){if(typeof g.aud=="string"){if(!c(g.aud,r.aud))return!1}else if(typeof g.aud=="object"&&!l(g.aud,r.aud))return!1}var y=i.IntDate.getNow();return r.verifyAt!==void 0&&typeof r.verifyAt=="number"&&(y=r.verifyAt),(r.gracePeriod===void 0||typeof r.gracePeriod!="number")&&(r.gracePeriod=0),!(g.exp!==void 0&&typeof g.exp=="number"&&g.exp+r.gracePeriod"u"||!d)&&(d={});(typeof d.jws>"u"||!d.jws)&&(d.jws={});d.jws.JWSJS=function(){var e=d,t=e.jws,r=t.JWS,n=r.readSafeJSONString;this.aHeader=[],this.sPayload="",this.aSignature=[],this.init=function(){this.aHeader=[],this.sPayload=void 0,this.aSignature=[]},this.initWithJWS=function(i){this.init();var a=i.split(".");if(a.length!=3)throw"malformed input JWS";this.aHeader.push(a[0]),this.sPayload=a[1],this.aSignature.push(a[2])},this.addSignature=function(i,a,s,c){if(this.sPayload===void 0||this.sPayload===null)throw"there's no JSON-JS signature to add.";var l=this.aHeader.length;if(this.aHeader.length!=this.aSignature.length)throw"aHeader.length != aSignature.length";try{var h=d.jws.JWS.sign(i,a,this.sPayload,s,c),v=h.split("."),E=v[0],p=v[2];this.aHeader.push(v[0]),this.aSignature.push(v[2])}catch(f){throw this.aHeader.length>l&&this.aHeader.pop(),this.aSignature.length>l&&this.aSignature.pop(),"addSignature failed: "+f}},this.verifyAll=function(i){if(this.aHeader.length!==i.length||this.aSignature.length!==i.length)return!1;for(var a=0;a0)this.aHeader=i.headers;else throw"malformed header";if(typeof i.payload=="string")this.sPayload=i.payload;else throw"malformed signatures";if(i.signatures.length>0)this.aSignature=i.signatures;else throw"malformed signatures"}catch(s){throw"malformed JWS-JS JSON object: "+s}},this.getJSON=function(){return{headers:this.aHeader,payload:this.sPayload,signatures:this.aSignature}},this.isEmpty=function(){return this.aHeader.length==0?1:0}};ye.SecureRandom=bo;ye.rng_seed_time=Md;ye.BigInteger=ee;ye.RSAKey=ze;ye.ECDSA=d.crypto.ECDSA;ye.DSA=d.crypto.DSA;ye.Signature=d.crypto.Signature;ye.MessageDigest=d.crypto.MessageDigest;ye.Mac=d.crypto.Mac;ye.KEYUTIL=st;ye.ASN1HEX=Ae;ye.X509=He;ye.X509CRL=V9;ye.CryptoJS=be;ye.b64tohex=Eo;ye.b64toBA=x2;ye.ECFieldElementFp=gr;ye.ECPointFp=mt;ye.ECCurveFp=Cs;ye.stoBA=H2;ye.BAtos=j2;ye.BAtohex=qf;ye.stohex=An;ye.stob64=F9;ye.stob64u=_9;ye.b64utos=I9;ye.b64tob64u=Ao;ye.b64utob64=Hc;ye.hex2b64=bs;ye.hextob64u=dr;ye.b64utohex=Nt;ye.utf8tob64u=Lc;ye.b64utoutf8=mi;ye.utf8tob64=D9;ye.b64toutf8=B9;ye.utf8tohex=Kf;ye.hextoutf8=Ft;ye.hextorstr=En;ye.rstrtohex=Hi;ye.hextob64=qd;ye.hextob64nl=R9;ye.b64nltohex=M2;ye.hextopem=Gr;ye.pemtohex=Kt;ye.hextoArrayBuffer=O9;ye.ArrayBuffertohex=N9;ye.zulutomsec=Kd;ye.msectozulu=k9;ye.zulutosec=q2;ye.zulutodate=L9;ye.datetozulu=U9;ye.uricmptohex=Gf;ye.hextouricmp=zf;ye.ipv6tohex=Nd;ye.hextoipv6=kd;ye.hextoip=Lf;ye.iptohex=Vd;ye.ucs2hextoutf8=Gd;ye.encodeURIComponentAll=Yf;ye.newline_toUnix=H9;ye.newline_toDos=j9;ye.hextoposhex=Ld;ye.intarystrtohex=M9;ye.strdiffidx=q9;ye.oidtohex=G2;ye.hextooid=Wf;ye.strpad=Uf;ye.bitstrtoint=Y2;ye.inttobitstr=W2;ye.bitstrtobinstr=X2;ye.binstrtobitstr=K9;ye.isBase64URLDot=zd;ye.namearraytobinstr=Hf;ye.extendClass=he;ye.foldnl=Vf;ye.b64topem=T9;ye.pemtob64=x9;ye.timeogen=K2;ye.aryval=Pt;ye.inttohex=z2;ye.twoscompl=jc;ye.KJUR=d;ye.crypto=d.crypto;ye.asn1=d.asn1;ye.jws=d.jws;ye.lang=d.lang;ye.VERSION=e8;ye.VERSION_FULL=t8});var nw=Ce(Xd=>{"use strict";Xd.toString=function(e){switch(e){case 1:return"A";case 10:return"NULL";case 28:return"AAAA";case 18:return"AFSDB";case 42:return"APL";case 257:return"CAA";case 60:return"CDNSKEY";case 59:return"CDS";case 37:return"CERT";case 5:return"CNAME";case 49:return"DHCID";case 32769:return"DLV";case 39:return"DNAME";case 48:return"DNSKEY";case 43:return"DS";case 55:return"HIP";case 13:return"HINFO";case 45:return"IPSECKEY";case 25:return"KEY";case 36:return"KX";case 29:return"LOC";case 15:return"MX";case 35:return"NAPTR";case 2:return"NS";case 47:return"NSEC";case 50:return"NSEC3";case 51:return"NSEC3PARAM";case 12:return"PTR";case 46:return"RRSIG";case 17:return"RP";case 24:return"SIG";case 6:return"SOA";case 99:return"SPF";case 33:return"SRV";case 44:return"SSHFP";case 32768:return"TA";case 249:return"TKEY";case 52:return"TLSA";case 250:return"TSIG";case 16:return"TXT";case 252:return"AXFR";case 251:return"IXFR";case 41:return"OPT";case 255:return"ANY"}return"UNKNOWN_"+e};Xd.toType=function(e){switch(e.toUpperCase()){case"A":return 1;case"NULL":return 10;case"AAAA":return 28;case"AFSDB":return 18;case"APL":return 42;case"CAA":return 257;case"CDNSKEY":return 60;case"CDS":return 59;case"CERT":return 37;case"CNAME":return 5;case"DHCID":return 49;case"DLV":return 32769;case"DNAME":return 39;case"DNSKEY":return 48;case"DS":return 43;case"HIP":return 55;case"HINFO":return 13;case"IPSECKEY":return 45;case"KEY":return 25;case"KX":return 36;case"LOC":return 29;case"MX":return 15;case"NAPTR":return 35;case"NS":return 2;case"NSEC":return 47;case"NSEC3":return 50;case"NSEC3PARAM":return 51;case"PTR":return 12;case"RRSIG":return 46;case"RP":return 17;case"SIG":return 24;case"SOA":return 6;case"SPF":return 99;case"SRV":return 33;case"SSHFP":return 44;case"TA":return 32768;case"TKEY":return 249;case"TLSA":return 52;case"TSIG":return 250;case"TXT":return 16;case"AXFR":return 252;case"IXFR":return 251;case"OPT":return 41;case"ANY":return 255;case"*":return 255}return e.toUpperCase().startsWith("UNKNOWN_")?parseInt(e.slice(8)):0}});var iw=Ce(Jd=>{"use strict";Jd.toString=function(e){switch(e){case 0:return"NOERROR";case 1:return"FORMERR";case 2:return"SERVFAIL";case 3:return"NXDOMAIN";case 4:return"NOTIMP";case 5:return"REFUSED";case 6:return"YXDOMAIN";case 7:return"YXRRSET";case 8:return"NXRRSET";case 9:return"NOTAUTH";case 10:return"NOTZONE";case 11:return"RCODE_11";case 12:return"RCODE_12";case 13:return"RCODE_13";case 14:return"RCODE_14";case 15:return"RCODE_15"}return"RCODE_"+e};Jd.toRcode=function(e){switch(e.toUpperCase()){case"NOERROR":return 0;case"FORMERR":return 1;case"SERVFAIL":return 2;case"NXDOMAIN":return 3;case"NOTIMP":return 4;case"REFUSED":return 5;case"YXDOMAIN":return 6;case"YXRRSET":return 7;case"NXRRSET":return 8;case"NOTAUTH":return 9;case"NOTZONE":return 10;case"RCODE_11":return 11;case"RCODE_12":return 12;case"RCODE_13":return 13;case"RCODE_14":return 14;case"RCODE_15":return 15}return 0}});var sw=Ce(Zd=>{"use strict";Zd.toString=function(e){switch(e){case 0:return"QUERY";case 1:return"IQUERY";case 2:return"STATUS";case 3:return"OPCODE_3";case 4:return"NOTIFY";case 5:return"UPDATE";case 6:return"OPCODE_6";case 7:return"OPCODE_7";case 8:return"OPCODE_8";case 9:return"OPCODE_9";case 10:return"OPCODE_10";case 11:return"OPCODE_11";case 12:return"OPCODE_12";case 13:return"OPCODE_13";case 14:return"OPCODE_14";case 15:return"OPCODE_15"}return"OPCODE_"+e};Zd.toOpcode=function(e){switch(e.toUpperCase()){case"QUERY":return 0;case"IQUERY":return 1;case"STATUS":return 2;case"OPCODE_3":return 3;case"NOTIFY":return 4;case"UPDATE":return 5;case"OPCODE_6":return 6;case"OPCODE_7":return 7;case"OPCODE_8":return 8;case"OPCODE_9":return 9;case"OPCODE_10":return 10;case"OPCODE_11":return 11;case"OPCODE_12":return 12;case"OPCODE_13":return 13;case"OPCODE_14":return 14;case"OPCODE_15":return 15}return 0}});var aw=Ce(Qd=>{"use strict";Qd.toString=function(e){switch(e){case 1:return"IN";case 2:return"CS";case 3:return"CH";case 4:return"HS";case 255:return"ANY"}return"UNKNOWN_"+e};Qd.toClass=function(e){switch(e.toUpperCase()){case"IN":return 1;case"CS":return 2;case"CH":return 3;case"HS":return 4;case"ANY":return 255}return 0}});var uw=Ce(e0=>{"use strict";e0.toString=function(e){switch(e){case 1:return"LLQ";case 2:return"UL";case 3:return"NSID";case 5:return"DAU";case 6:return"DHU";case 7:return"N3U";case 8:return"CLIENT_SUBNET";case 9:return"EXPIRE";case 10:return"COOKIE";case 11:return"TCP_KEEPALIVE";case 12:return"PADDING";case 13:return"CHAIN";case 14:return"KEY_TAG";case 26946:return"DEVICEID"}return e<0?null:`OPTION_${e}`};e0.toCode=function(e){if(typeof e=="number")return e;if(!e)return-1;switch(e.toUpperCase()){case"OPTION_0":return 0;case"LLQ":return 1;case"UL":return 2;case"NSID":return 3;case"OPTION_4":return 4;case"DAU":return 5;case"DHU":return 6;case"N3U":return 7;case"CLIENT_SUBNET":return 8;case"EXPIRE":return 9;case"COOKIE":return 10;case"TCP_KEEPALIVE":return 11;case"PADDING":return 12;case"CHAIN":return 13;case"KEY_TAG":return 14;case"DEVICEID":return 26946;case"OPTION_65535":return 65535}let t=e.match(/_(\d+)$/);return t?parseInt(t[1],10):-1}});var lw=Ce((cw,t0)=>{var ow=function(e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.decode=E,e.encode=v,e.familyOf=h,e.name=void 0,e.sizeOf=l,e.v6=e.v4=void 0;let t=/^(\d{1,3}\.){3,3}\d{1,3}$/,r=4,n=/^(::)?(((\d{1,3}\.){3}(\d{1,3}){1})?([0-9a-f]){0,4}:{0,2}){1,8}(::)?$/i,i=16,a={name:"v4",size:r,isFormat:p=>t.test(p),encode(p,f,A){A=~~A,f=f||new Uint8Array(A+r);let g=p.length,y=0;for(let w=0;wp.length>0&&n.test(p),encode(p,f,A){A=~~A;let g=A+i,y=-1,w=0,S=0,_=!0,I=!1;f=f||new Uint8Array(A+i);for(let B=0;B>8),A=97?q-=87:q>=65?q-=55:(q-=48,S=S*10+q),w=(w<<4)+q)}if(_===!1)I===!0?(A>8),A=y+2;B--)f[B]=f[B-2];f[y]=0,f[y+1]=0,y=A}if(y!==A&&y!==-1)for(A>g-2&&(A=g-2);g>y;)f[--g]=Ay?f[--A]:0;else for(;A{"use strict";var Ne=Nf().Buffer,xs=nw(),z9=iw(),Y9=sw(),Qf=aw(),r0=uw(),lu=lw(),W9=0,fw=32768,n0=32768,X9=~n0,hw=32768,J9=~hw,De=Oe.name={};De.encode=function(e,t,r,{mail:n=!1}={}){t||(t=Ne.alloc(De.encodingLength(e))),r||(r=0);let i=r,a=e.replace(/^\.|\.$/gm,"");if(a.length){let s=[];if(n){let c="";a.split(".").forEach(l=>{l.endsWith("\\")?c+=(c.length?".":"")+l.slice(0,-1):s.length===0&&c.length?s.push(c+"."+l):s.push(l)})}else s=a.split(".");for(let c=0;c=e.length)throw new Error("Cannot decode name (buffer overflow)");let l=e[t++];if(s+=c?0:1,l===0)break;if(l&192)if((l&192)===192){if(t+1>e.length)throw new Error("Cannot decode name (buffer overflow)");let h=e.readUInt16BE(t-1)-49152;if(h>=i)throw new Error("Cannot decode name (bad pointer)");t=h,i=h,s+=c?0:1,c=!0}else throw new Error("Cannot decode name (bad label)");else{if(t+l>e.length)throw new Error("Cannot decode name (buffer overflow)");if(a+=l+1,a>254)throw new Error("Cannot decode name (name too long)");let h=e.toString("utf-8",t,t+l);r&&(h=h.replace(/\./g,"\\.")),n.push(h),t+=l,s+=c?0:l}}return De.decode.bytes=s,n.length===0?".":n.join(".")};De.decode.bytes=0;De.encodingLength=function(e){return e==="."||e===".."?1:Ne.byteLength(e.replace(/^\.|\.$/gm,""))+2};var it={};it.encode=function(e,t,r){t||(t=Ne.alloc(it.encodingLength(e))),r||(r=0);let n=t.write(e,r+1);return t[r]=n,it.encode.bytes=n+1,t};it.encode.bytes=0;it.decode=function(e,t){t||(t=0);let r=e[t],n=e.toString("utf-8",t+1,t+1+r);return it.decode.bytes=r+1,n};it.decode.bytes=0;it.encodingLength=function(e){return Ne.byteLength(e)+1};var Ai={};Ai.encode=function(e,t,r){t||(t=Ai.encodingLength(e)),r||(r=0);let n=(e.flags||0)&32767,i=e.type==="response"?fw:W9;return t.writeUInt16BE(e.id||0,r),t.writeUInt16BE(n|i,r+2),t.writeUInt16BE(e.questions.length,r+4),t.writeUInt16BE(e.answers.length,r+6),t.writeUInt16BE(e.authorities.length,r+8),t.writeUInt16BE(e.additionals.length,r+10),t};Ai.encode.bytes=12;Ai.decode=function(e,t){if(t||(t=0),e.length<12)throw new Error("Header must be 12 bytes");let r=e.readUInt16BE(t+2);return{id:e.readUInt16BE(t),type:r&fw?"response":"query",flags:r&32767,flag_qr:(r>>15&1)===1,opcode:Y9.toString(r>>11&15),flag_aa:(r>>10&1)===1,flag_tc:(r>>9&1)===1,flag_rd:(r>>8&1)===1,flag_ra:(r>>7&1)===1,flag_z:(r>>6&1)===1,flag_ad:(r>>5&1)===1,flag_cd:(r>>4&1)===1,rcode:z9.toString(r&15),questions:new Array(e.readUInt16BE(t+4)),answers:new Array(e.readUInt16BE(t+6)),authorities:new Array(e.readUInt16BE(t+8)),additionals:new Array(e.readUInt16BE(t+10))}};Ai.decode.bytes=12;Ai.encodingLength=function(){return 12};var Fs=Oe.unknown={};Fs.encode=function(e,t,r){return t||(t=Ne.alloc(Fs.encodingLength(e))),r||(r=0),t.writeUInt16BE(e.length,r),e.copy(t,r+2),Fs.encode.bytes=e.length+2,t};Fs.encode.bytes=0;Fs.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=e.slice(t+2,t+2+r);return Fs.decode.bytes=r+2,n};Fs.decode.bytes=0;Fs.encodingLength=function(e){return e.length+2};var _s=Oe.ns={};_s.encode=function(e,t,r){return t||(t=Ne.alloc(_s.encodingLength(e))),r||(r=0),De.encode(e,t,r+2),t.writeUInt16BE(De.encode.bytes,r),_s.encode.bytes=De.encode.bytes+2,t};_s.encode.bytes=0;_s.decode=function(e,t){t||(t=0);let r=e.readUInt16BE(t),n=De.decode(e,t+2);return _s.decode.bytes=r+2,n};_s.decode.bytes=0;_s.encodingLength=function(e){return De.encodingLength(e)+2};var Is=Oe.soa={};Is.encode=function(e,t,r){t||(t=Ne.alloc(Is.encodingLength(e))),r||(r=0);let n=r;return r+=2,De.encode(e.mname,t,r),r+=De.encode.bytes,De.encode(e.rname,t,r,{mail:!0}),r+=De.encode.bytes,t.writeUInt32BE(e.serial||0,r),r+=4,t.writeUInt32BE(e.refresh||0,r),r+=4,t.writeUInt32BE(e.retry||0,r),r+=4,t.writeUInt32BE(e.expire||0,r),r+=4,t.writeUInt32BE(e.minimum||0,r),r+=4,t.writeUInt16BE(r-n-2,n),Is.encode.bytes=r-n,t};Is.encode.bytes=0;Is.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mname=De.decode(e,t),t+=De.decode.bytes,n.rname=De.decode(e,t,{mail:!0}),t+=De.decode.bytes,n.serial=e.readUInt32BE(t),t+=4,n.refresh=e.readUInt32BE(t),t+=4,n.retry=e.readUInt32BE(t),t+=4,n.expire=e.readUInt32BE(t),t+=4,n.minimum=e.readUInt32BE(t),t+=4,Is.decode.bytes=t-r,n};Is.decode.bytes=0;Is.encodingLength=function(e){return 22+De.encodingLength(e.mname)+De.encodingLength(e.rname)};var Ds=Oe.txt={};Ds.encode=function(e,t,r){Array.isArray(e)||(e=[e]);for(let i=0;i0;){let a=e[t++];if(--n,n0&&(r.timeout=e.readUInt16BE(t),t+=2);break;case 14:r.tags=[];for(let a=0;a0;)n[a++]=yn.decode(e,t),t+=yn.decode.bytes,i-=yn.decode.bytes;return Ln.decode.bytes=t-r,n};Ln.decode.bytes=0;Ln.encodingLength=function(e){return 2+Fo(e||[],yn)};var sn=Oe.dnskey={};sn.PROTOCOL_DNSSEC=3;sn.ZONE_KEY=128;sn.SECURE_ENTRYPOINT=32768;sn.encode=function(e,t,r){t||(t=Ne.alloc(sn.encodingLength(e))),r||(r=0);let n=r,i=e.key;if(!Ne.isBuffer(i))throw new Error("Key must be a Buffer");return r+=2,t.writeUInt16BE(e.flags,r),r+=2,t.writeUInt8(sn.PROTOCOL_DNSSEC,r),r+=1,t.writeUInt8(e.algorithm,r),r+=1,i.copy(t,r,0,i.length),r+=i.length,sn.encode.bytes=r-n,t.writeUInt16BE(sn.encode.bytes-2,n),t};sn.encode.bytes=0;sn.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);if(t+=2,n.flags=e.readUInt16BE(t),t+=2,e.readUInt8(t)!==sn.PROTOCOL_DNSSEC)throw new Error("Protocol must be 3");return t+=1,n.algorithm=e.readUInt8(t),t+=1,n.key=e.slice(t,r+i+2),t+=n.key.length,sn.decode.bytes=t-r,n};sn.decode.bytes=0;sn.encodingLength=function(e){return 6+Ne.byteLength(e.key)};var ji=Oe.rrsig={};ji.encode=function(e,t,r){t||(t=Ne.alloc(ji.encodingLength(e))),r||(r=0);let n=r,i=e.signature;if(!Ne.isBuffer(i))throw new Error("Signature must be a Buffer");return r+=2,t.writeUInt16BE(xs.toType(e.typeCovered),r),r+=2,t.writeUInt8(e.algorithm,r),r+=1,t.writeUInt8(e.labels,r),r+=1,t.writeUInt32BE(e.originalTTL,r),r+=4,t.writeUInt32BE(e.expiration,r),r+=4,t.writeUInt32BE(e.inception,r),r+=4,t.writeUInt16BE(e.keyTag,r),r+=2,De.encode(e.signersName,t,r),r+=De.encode.bytes,i.copy(t,r,0,i.length),r+=i.length,ji.encode.bytes=r-n,t.writeUInt16BE(ji.encode.bytes-2,n),t};ji.encode.bytes=0;ji.decode=function(e,t){t||(t=0);let r=t;var n={},i=e.readUInt16BE(t);return t+=2,n.typeCovered=xs.toString(e.readUInt16BE(t)),t+=2,n.algorithm=e.readUInt8(t),t+=1,n.labels=e.readUInt8(t),t+=1,n.originalTTL=e.readUInt32BE(t),t+=4,n.expiration=e.readUInt32BE(t),t+=4,n.inception=e.readUInt32BE(t),t+=4,n.keyTag=e.readUInt16BE(t),t+=2,n.signersName=De.decode(e,t),t+=De.decode.bytes,n.signature=e.slice(t,r+i+2),t+=n.signature.length,ji.decode.bytes=t-r,n};ji.decode.bytes=0;ji.encodingLength=function(e){return 20+De.encodingLength(e.signersName)+Ne.byteLength(e.signature)};var Mi=Oe.rp={};Mi.encode=function(e,t,r){t||(t=Ne.alloc(Mi.encodingLength(e))),r||(r=0);let n=r;return r+=2,De.encode(e.mbox||".",t,r,{mail:!0}),r+=De.encode.bytes,De.encode(e.txt||".",t,r),r+=De.encode.bytes,Mi.encode.bytes=r-n,t.writeUInt16BE(Mi.encode.bytes-2,n),t};Mi.encode.bytes=0;Mi.decode=function(e,t){t||(t=0);let r=t,n={};return t+=2,n.mbox=De.decode(e,t,{mail:!0})||".",t+=De.decode.bytes,n.txt=De.decode(e,t)||".",t+=De.decode.bytes,Mi.decode.bytes=t-r,n};Mi.decode.bytes=0;Mi.encodingLength=function(e){return 2+De.encodingLength(e.mbox||".")+De.encodingLength(e.txt||".")};var Cr={};Cr.encode=function(e,t,r){t||(t=Ne.alloc(Cr.encodingLength(e))),r||(r=0);let n=r;for(var i=[],a=0;a>8]===void 0&&(i[s>>8]=[]),i[s>>8][s>>3&31]|=1<<7-(s&7)}for(a=0;a>8]=Math.max(t[n>>8]||0,n&255)}var i=0;for(r=0;r>15&1)===1,r.options=Ln.decode(e,t+8),t+=8+Ln.decode.bytes;else{let i=e.readUInt16BE(t+2);r.ttl=e.readUInt32BE(t+4),r.class=Qf.toString(i&X9),r.flush=!!(i&n0);let a=i0(r.type);r.data=a.decode(e,t+8),t+=8+a.decode.bytes}return xr.decode.bytes=t-n,r};xr.decode.bytes=0;xr.encodingLength=function(e){let t=e.data!==null&&e.data!==void 0?e.data:e.options;return De.encodingLength(e.name)+8+i0(e.type).encodingLength(t)};var wi=Oe.question={};wi.encode=function(e,t,r){t||(t=Ne.alloc(wi.encodingLength(e))),r||(r=0);let n=r;return De.encode(e.name,t,r),r+=De.encode.bytes,t.writeUInt16BE(xs.toType(e.type),r),r+=2,t.writeUInt16BE(Qf.toClass(e.class===void 0?"IN":e.class),r),r+=2,wi.encode.bytes=r-n,e};wi.encode.bytes=0;wi.decode=function(e,t){t||(t=0);let r=t,n={};return n.name=De.decode(e,t),t+=De.decode.bytes,n.type=xs.toString(e.readUInt16BE(t)),t+=2,n.class=Qf.toString(e.readUInt16BE(t)),t+=2,!!(n.class&hw)&&(n.class&=J9),wi.decode.bytes=t-r,n};wi.decode.bytes=0;wi.encodingLength=function(e){return De.encodingLength(e.name)+4};Oe.AUTHORITATIVE_ANSWER=1024;Oe.TRUNCATED_RESPONSE=512;Oe.RECURSION_DESIRED=256;Oe.RECURSION_AVAILABLE=128;Oe.AUTHENTIC_DATA=32;Oe.CHECKING_DISABLED=16;Oe.DNSSEC_OK=32768;Oe.encode=function(e,t,r){let n=!t;n&&(t=Ne.alloc(Oe.encodingLength(e))),r||(r=0);let i=r;return e.questions||(e.questions=[]),e.answers||(e.answers=[]),e.authorities||(e.authorities=[]),e.additionals||(e.additionals=[]),Ai.encode(e,t,r),r+=Ai.encode.bytes,r=qc(e.questions,wi,t,r),r=qc(e.answers,xr,t,r),r=qc(e.authorities,xr,t,r),r=qc(e.additionals,xr,t,r),Oe.encode.bytes=r-i,n&&Oe.encode.bytes!==t.length?t.slice(0,Oe.encode.bytes):t};Oe.encode.bytes=0;Oe.decode=function(e,t){t||(t=0);let r=t,n=Ai.decode(e,t);return t+=Ai.decode.bytes,t=Zf(n.questions,wi,e,t),t=Zf(n.answers,xr,e,t),t=Zf(n.authorities,xr,e,t),t=Zf(n.additionals,xr,e,t),Oe.decode.bytes=t-r,n};Oe.decode.bytes=0;Oe.encodingLength=function(e){return Ai.encodingLength(e)+Fo(e.questions||[],wi)+Fo(e.answers||[],xr)+Fo(e.authorities||[],xr)+Fo(e.additionals||[],xr)};Oe.streamEncode=function(e){let t=Oe.encode(e),r=Ne.alloc(2);r.writeUInt16BE(t.byteLength);let n=Ne.concat([r,t]);return Oe.streamEncode.bytes=n.byteLength,n};Oe.streamEncode.bytes=0;Oe.streamDecode=function(e){let t=e.readUInt16BE(0);if(e.byteLength{(function(){var e,t="4.17.21",r=200,n="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",i="Expected a function",a="Invalid `variable` option passed into `_.template`",s="__lodash_hash_undefined__",c=500,l="__lodash_placeholder__",h=1,v=2,E=4,p=1,f=2,A=1,g=2,y=4,w=8,S=16,_=32,I=64,B=128,q=256,z=512,F=30,P="...",L=800,H=16,K=1,Z=2,G=3,V=1/0,X=9007199254740991,ie=17976931348623157e292,Se=NaN,Ee=4294967295,Pe=Ee-1,qe=Ee>>>1,ce=[["ary",B],["bind",A],["bindKey",g],["curry",w],["curryRight",S],["flip",z],["partial",_],["partialRight",I],["rearg",q]],_e="[object Arguments]",ke="[object Array]",mr="[object AsyncFunction]",xt="[object Boolean]",ht="[object Date]",Zt="[object DOMException]",Ut="[object Error]",rt="[object Function]",$t="[object GeneratorFunction]",et="[object Map]",vt="[object Number]",Qt="[object Null]",Xe="[object Object]",Vt="[object Promise]",Vn="[object Proxy]",vr="[object RegExp]",Fr="[object Set]",rr="[object String]",Or="[object Symbol]",ma="[object Undefined]",zr="[object WeakMap]",wt="[object WeakSet]",nr="[object ArrayBuffer]",Je="[object DataView]",Nr="[object Float32Array]",va="[object Float64Array]",wa="[object Int8Array]",Aa="[object Int16Array]",Ea="[object Int32Array]",Xi="[object Uint8Array]",ya="[object Uint8ClampedArray]",Us="[object Uint16Array]",Ei="[object Uint32Array]",Ji=/\b__p \+= '';/g,pu=/\b(__p \+=) '' \+/g,du=/(__e\(.*?\)|\b__t\)) \+\n'';/g,gu=/&(?:amp|lt|gt|quot|#39);/g,mu=/[&<>"']/g,vu=RegExp(gu.source),wu=RegExp(mu.source),Au=/<%-([\s\S]+?)%>/g,Ro=/<%([\s\S]+?)%>/g,Eu=/<%=([\s\S]+?)%>/g,To=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xo=/^\w*$/,Oo=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Hs=/[\\^$.*+?()[\]{}|]/g,No=RegExp(Hs.source),Sa=/^\s+/,ko=/\s/,Lo=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Uo=/\{\n\/\* \[wrapped with (.+)\] \*/,Ho=/,? & /,jo=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Mo=/[()=,{}\[\]\/\s]/,qo=/\\(\\)?/g,Ko=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,yi=/\w*$/,yu=/^[-+]0x[0-9a-f]+$/i,Vo=/^0b[01]+$/i,Go=/^\[object .+?Constructor\]$/,zo=/^0o[0-7]+$/i,Su=/^(?:0|[1-9]\d*)$/,Si=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,an=/($^)/,Yo=/['\n\r\u2028\u2029\\]/g,js="\\ud800-\\udfff",bn="\\u0300-\\u036f",Wo="\\ufe20-\\ufe2f",Xo="\\u20d0-\\u20ff",bu=bn+Wo+Xo,ba="\\u2700-\\u27bf",Cu="a-z\\xdf-\\xf6\\xf8-\\xff",Ms="\\xac\\xb1\\xd7\\xf7",Gt="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Jo="\\u2000-\\u206f",Zo=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Fu="A-Z\\xc0-\\xd6\\xd8-\\xde",bi="\\ufe0e\\ufe0f",wr=Ms+Gt+Jo+Zo,kt="['\u2019]",Qo="["+js+"]",Ca="["+wr+"]",Ar="["+bu+"]",Fa="\\d+",_u="["+ba+"]",Iu="["+Cu+"]",_a="[^"+js+wr+Fa+ba+Cu+Fu+"]",Ci="\\ud83c[\\udffb-\\udfff]",Ia="(?:"+Ar+"|"+Ci+")",Du="[^"+js+"]",Da="(?:\\ud83c[\\udde6-\\uddff]){2}",Ba="[\\ud800-\\udbff][\\udc00-\\udfff]",Yr="["+Fu+"]",R="\\u200d",x="(?:"+Iu+"|"+_a+")",j="(?:"+Yr+"|"+_a+")",Q="(?:"+kt+"(?:d|ll|m|re|s|t|ve))?",de="(?:"+kt+"(?:D|LL|M|RE|S|T|VE))?",ve=Ia+"?",Fe="["+bi+"]?",$e="(?:"+R+"(?:"+[Du,Da,Ba].join("|")+")"+Fe+ve+")*",_t="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",zt="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",_r=Fe+ve+$e,Ir="(?:"+[_u,Da,Ba].join("|")+")"+_r,Cn="(?:"+[Du+Ar+"?",Ar,Da,Ba,Qo].join("|")+")",qs=RegExp(kt,"g"),Wr=RegExp(Ar,"g"),Dr=RegExp(Ci+"(?="+Ci+")|"+Cn+_r,"g"),Ks=RegExp([Yr+"?"+Iu+"+"+Q+"(?="+[Ca,Yr,"$"].join("|")+")",j+"+"+de+"(?="+[Ca,Yr+x,"$"].join("|")+")",Yr+"?"+x+"+"+Q,Yr+"+"+de,zt,_t,Fa,Ir].join("|"),"g"),Gn=RegExp("["+R+js+bu+bi+"]"),Pa=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,vh=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],wh=-1,Rt={};Rt[Nr]=Rt[va]=Rt[wa]=Rt[Aa]=Rt[Ea]=Rt[Xi]=Rt[ya]=Rt[Us]=Rt[Ei]=!0,Rt[_e]=Rt[ke]=Rt[nr]=Rt[xt]=Rt[Je]=Rt[ht]=Rt[Ut]=Rt[rt]=Rt[et]=Rt[vt]=Rt[Xe]=Rt[vr]=Rt[Fr]=Rt[rr]=Rt[zr]=!1;var Bt={};Bt[_e]=Bt[ke]=Bt[nr]=Bt[Je]=Bt[xt]=Bt[ht]=Bt[Nr]=Bt[va]=Bt[wa]=Bt[Aa]=Bt[Ea]=Bt[et]=Bt[vt]=Bt[Xe]=Bt[vr]=Bt[Fr]=Bt[rr]=Bt[Or]=Bt[Xi]=Bt[ya]=Bt[Us]=Bt[Ei]=!0,Bt[Ut]=Bt[rt]=Bt[zr]=!1;var Ah={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},Eh={"&":"&","<":"<",">":">",'"':""","'":"'"},yh={"&":"&","<":"<",">":">",""":'"',"'":"'"},Sh={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},bh=parseFloat,Ch=parseInt,rl=typeof global=="object"&&global&&global.Object===Object&&global,Fh=typeof self=="object"&&self&&self.Object===Object&&self,ir=rl||Fh||Function("return this")(),ec=typeof Io=="object"&&Io&&!Io.nodeType&&Io,Zi=ec&&typeof Kc=="object"&&Kc&&!Kc.nodeType&&Kc,nl=Zi&&Zi.exports===ec,tc=nl&&rl.process,un=function(){try{var re=Zi&&Zi.require&&Zi.require("util").types;return re||tc&&tc.binding&&tc.binding("util")}catch{}}(),il=un&&un.isArrayBuffer,sl=un&&un.isDate,al=un&&un.isMap,ul=un&&un.isRegExp,ol=un&&un.isSet,cl=un&&un.isTypedArray;function Xr(re,le,ue){switch(ue.length){case 0:return re.call(le);case 1:return re.call(le,ue[0]);case 2:return re.call(le,ue[0],ue[1]);case 3:return re.call(le,ue[0],ue[1],ue[2])}return re.apply(le,ue)}function _h(re,le,ue,Re){for(var Ge=-1,ot=re==null?0:re.length;++Ge-1}function $a(re,le,ue){for(var Re=-1,Ge=re==null?0:re.length;++Re-1;);return ue}function pl(re,le){for(var ue=re.length;ue--&&Vs(le,re[ue],0)>-1;);return ue}function dl(re,le){for(var ue=re.length,Re=0;ue--;)re[ue]===le&&++Re;return Re}var uc=pe(Ah),Bh=pe(Eh);function gl(re){return"\\"+Sh[re]}function Ph(re,le){return re==null?e:re[le]}function es(re){return Gn.test(re)}function $h(re){return Pa.test(re)}function Rh(re){for(var le,ue=[];!(le=re.next()).done;)ue.push(le.value);return ue}function oc(re){var le=-1,ue=Array(re.size);return re.forEach(function(Re,Ge){ue[++le]=[Ge,Re]}),ue}function Br(re,le){return function(ue){return re(le(ue))}}function In(re,le){for(var ue=-1,Re=re.length,Ge=0,ot=[];++ue-1}function mE(u,o){var m=this.__data__,C=Il(m,u);return C<0?(++this.size,m.push([u,o])):m[C][1]=o,this}ss.prototype.clear=hE,ss.prototype.delete=pE,ss.prototype.get=dE,ss.prototype.has=gE,ss.prototype.set=mE;function as(u){var o=-1,m=u==null?0:u.length;for(this.clear();++o=o?u:o)),u}function Xn(u,o,m,C,T,U){var Y,J=o&h,ne=o&v,ge=o&E;if(m&&(Y=T?m(u,C,T,U):m(u)),Y!==e)return Y;if(!Mt(u))return u;var me=We(u);if(me){if(Y=Ey(u),!J)return fn(u,Y)}else{var we=Ur(u),Ie=we==rt||we==$t;if(Xs(u))return A1(u,J);if(we==Xe||we==_e||Ie&&!T){if(Y=ne||Ie?{}:L1(u),!J)return ne?cy(u,RE(Y,u)):oy(u,W0(Y,u))}else{if(!Bt[we])return T?u:{};Y=yy(u,we,J)}}U||(U=new fi);var Te=U.get(u);if(Te)return Te;U.set(u,Y),pg(u)?u.forEach(function(Ve){Y.add(Xn(Ve,o,m,Ve,u,U))}):fg(u)&&u.forEach(function(Ve,at){Y.set(at,Xn(Ve,o,m,at,u,U))});var Ke=ge?ne?fp:lp:ne?pn:Er,tt=me?e:Ke(u);return on(tt||u,function(Ve,at){tt&&(at=Ve,Ve=u[at]),pc(Y,at,Xn(Ve,o,m,at,u,U))}),Y}function TE(u){var o=Er(u);return function(m){return X0(m,u,o)}}function X0(u,o,m){var C=m.length;if(u==null)return!C;for(u=It(u);C--;){var T=m[C],U=o[T],Y=u[T];if(Y===e&&!(T in u)||!U(Y))return!1}return!0}function J0(u,o,m){if(typeof u!="function")throw new ln(i);return Ec(function(){u.apply(e,m)},o)}function dc(u,o,m,C){var T=-1,U=Jr,Y=!0,J=u.length,ne=[],ge=o.length;if(!J)return ne;m&&(o=te(o,kr(m))),C?(U=$a,Y=!1):o.length>=r&&(U=Ta,Y=!1,o=new Oa(o));e:for(;++TT?0:T+m),C=C===e||C>T?T:Qe(C),C<0&&(C+=T),C=m>C?0:gg(C);m0&&m(J)?o>1?Pr(J,o-1,m,C,T):_n(T,J):C||(T[T.length]=J)}return T}var Gh=F1(),e1=F1(!0);function _i(u,o){return u&&Gh(u,o,Er)}function zh(u,o){return u&&e1(u,o,Er)}function Bl(u,o){return Fn(o,function(m){return hs(u[m])})}function ka(u,o){o=Ys(o,u);for(var m=0,C=o.length;u!=null&&mo}function NE(u,o){return u!=null&&ft.call(u,o)}function kE(u,o){return u!=null&&o in It(u)}function LE(u,o,m){return u>=Lr(o,m)&&u=120&&me.length>=120)?new Oa(Y&&me):e}me=u[0];var we=-1,Ie=J[0];e:for(;++we-1;)J!==u&&At.call(J,ne,1),At.call(u,ne,1);return u}function f1(u,o){for(var m=u?o.length:0,C=m-1;m--;){var T=o[m];if(m==C||T!==U){var U=T;ls(T)?At.call(u,T,1):np(u,T)}}return u}function ep(u,o){return u+se(V0()*(o-u+1))}function JE(u,o,m,C){for(var T=-1,U=cr(M((o-u)/(m||1)),0),Y=ue(U);U--;)Y[C?U:++T]=u,u+=m;return Y}function tp(u,o){var m="";if(!u||o<1||o>X)return m;do o%2&&(m+=u),o=se(o/2),o&&(u+=u);while(o);return m}function nt(u,o){return wp(j1(u,o,dn),u+"")}function ZE(u){return Y0(Wu(u))}function QE(u,o){var m=Wu(u);return Hl(m,Na(o,0,m.length))}function vc(u,o,m,C){if(!Mt(u))return u;o=Ys(o,u);for(var T=-1,U=o.length,Y=U-1,J=u;J!=null&&++TT?0:T+o),m=m>T?T:m,m<0&&(m+=T),T=o>m?0:m-o>>>0,o>>>=0;for(var U=ue(T);++C>>1,Y=u[U];Y!==null&&!Pn(Y)&&(m?Y<=o:Y=r){var ge=o?null:py(u);if(ge)return Dn(ge);Y=!1,T=Ta,ne=new Oa}else ne=o?[]:J;e:for(;++C=C?u:Jn(u,o,m)}var w1=b||function(u){return ir.clearTimeout(u)};function A1(u,o){if(o)return u.slice();var m=u.length,C=El?El(m):new u.constructor(m);return u.copy(C),C}function up(u){var o=new u.constructor(u.byteLength);return new Uu(o).set(new Uu(u)),o}function iy(u,o){var m=o?up(u.buffer):u.buffer;return new u.constructor(m,u.byteOffset,u.byteLength)}function sy(u){var o=new u.constructor(u.source,yi.exec(u));return o.lastIndex=u.lastIndex,o}function ay(u){return hc?It(hc.call(u)):{}}function E1(u,o){var m=o?up(u.buffer):u.buffer;return new u.constructor(m,u.byteOffset,u.length)}function y1(u,o){if(u!==o){var m=u!==e,C=u===null,T=u===u,U=Pn(u),Y=o!==e,J=o===null,ne=o===o,ge=Pn(o);if(!J&&!ge&&!U&&u>o||U&&Y&&ne&&!J&&!ge||C&&Y&&ne||!m&&ne||!T)return 1;if(!C&&!U&&!ge&&u=J)return ne;var ge=m[C];return ne*(ge=="desc"?-1:1)}}return u.index-o.index}function S1(u,o,m,C){for(var T=-1,U=u.length,Y=m.length,J=-1,ne=o.length,ge=cr(U-Y,0),me=ue(ne+ge),we=!C;++J1?m[T-1]:e,Y=T>2?m[2]:e;for(U=u.length>3&&typeof U=="function"?(T--,U):e,Y&&Qr(m[0],m[1],Y)&&(U=T<3?e:U,T=1),o=It(o);++C-1?T[U?o[Y]:Y]:e}}function D1(u){return cs(function(o){var m=o.length,C=m,T=Wn.prototype.thru;for(u&&o.reverse();C--;){var U=o[C];if(typeof U!="function")throw new ln(i);if(T&&!Y&&Ll(U)=="wrapper")var Y=new Wn([],!0)}for(C=Y?C:m;++C1&&ct.reverse(),me&&neJ))return!1;var ge=U.get(u),me=U.get(o);if(ge&&me)return ge==o&&me==u;var we=-1,Ie=!0,Te=m&f?new Oa:e;for(U.set(u,o),U.set(o,u);++we1?"& ":"")+o[C],o=o.join(m>2?", ":" "),u.replace(Lo,`{ /* [wrapped with `+o+`] */ `)}function by(u){return We(u)||Ha(u)||!!(bl&&u&&u[bl])}function ls(u,o){var m=typeof u;return o=o??X,!!o&&(m=="number"||m!="symbol"&&Su.test(u))&&u>-1&&u%1==0&&u0){if(++o>=L)return arguments[0]}else o=0;return u.apply(e,arguments)}}function Hl(u,o){var m=-1,C=u.length,T=C-1;for(o=o===e?C:o;++m1?u[o-1]:e;return m=typeof m=="function"?(u.pop(),m):e,Q1(u,m)});function eg(u){var o=k(u);return o.__chain__=!0,o}function x4(u,o){return o(u),u}function jl(u,o){return o(u)}var O4=cs(function(u){var o=u.length,m=o?u[0]:0,C=this.__wrapped__,T=function(U){return Vh(U,u)};return o>1||this.__actions__.length||!(C instanceof ut)||!ls(m)?this.thru(T):(C=C.slice(m,+m+(o?1:0)),C.__actions__.push({func:jl,args:[T],thisArg:e}),new Wn(C,this.__chain__).thru(function(U){return o&&!U.length&&U.push(e),U}))});function N4(){return eg(this)}function k4(){return new Wn(this.value(),this.__chain__)}function L4(){this.__values__===e&&(this.__values__=dg(this.value()));var u=this.__index__>=this.__values__.length,o=u?e:this.__values__[this.__index__++];return{done:u,value:o}}function U4(){return this}function H4(u){for(var o,m=this;m instanceof _l;){var C=z1(m);C.__index__=0,C.__values__=e,o?T.__wrapped__=C:o=C;var T=C;m=m.__wrapped__}return T.__wrapped__=u,o}function j4(){var u=this.__wrapped__;if(u instanceof ut){var o=u;return this.__actions__.length&&(o=new ut(this)),o=o.reverse(),o.__actions__.push({func:jl,args:[Ap],thisArg:e}),new Wn(o,this.__chain__)}return this.thru(Ap)}function M4(){return m1(this.__wrapped__,this.__actions__)}var q4=Tl(function(u,o,m){ft.call(u,m)?++u[m]:us(u,m,1)});function K4(u,o,m){var C=We(u)?Ye:xE;return m&&Qr(u,o,m)&&(o=e),C(u,je(o,3))}function V4(u,o){var m=We(u)?Fn:Q0;return m(u,je(o,3))}var G4=I1(Y1),z4=I1(W1);function Y4(u,o){return Pr(Ml(u,o),1)}function W4(u,o){return Pr(Ml(u,o),V)}function X4(u,o,m){return m=m===e?1:Qe(m),Pr(Ml(u,o),m)}function tg(u,o){var m=We(u)?on:Gs;return m(u,je(o,3))}function rg(u,o){var m=We(u)?D:Z0;return m(u,je(o,3))}var J4=Tl(function(u,o,m){ft.call(u,m)?u[m].push(o):us(u,m,[o])});function Z4(u,o,m,C){u=hn(u)?u:Wu(u),m=m&&!C?Qe(m):0;var T=u.length;return m<0&&(m=cr(T+m,0)),zl(u)?m<=T&&u.indexOf(o,m)>-1:!!T&&Vs(u,o,m)>-1}var Q4=nt(function(u,o,m){var C=-1,T=typeof o=="function",U=hn(u)?ue(u.length):[];return Gs(u,function(Y){U[++C]=T?Xr(o,Y,m):gc(Y,o,m)}),U}),e6=Tl(function(u,o,m){us(u,m,o)});function Ml(u,o){var m=We(u)?te:s1;return m(u,je(o,3))}function t6(u,o,m,C){return u==null?[]:(We(o)||(o=o==null?[]:[o]),m=C?e:m,We(m)||(m=m==null?[]:[m]),c1(u,o,m))}var r6=Tl(function(u,o,m){u[m?0:1].push(o)},function(){return[[],[]]});function n6(u,o,m){var C=We(u)?rc:fl,T=arguments.length<3;return C(u,je(o,4),m,T,Gs)}function i6(u,o,m){var C=We(u)?q0:fl,T=arguments.length<3;return C(u,je(o,4),m,T,Z0)}function s6(u,o){var m=We(u)?Fn:Q0;return m(u,Vl(je(o,3)))}function a6(u){var o=We(u)?Y0:ZE;return o(u)}function u6(u,o,m){(m?Qr(u,o,m):o===e)?o=1:o=Qe(o);var C=We(u)?BE:QE;return C(u,o)}function o6(u){var o=We(u)?PE:ty;return o(u)}function c6(u){if(u==null)return 0;if(hn(u))return zl(u)?ts(u):u.length;var o=Ur(u);return o==et||o==Fr?u.size:Jh(u).length}function l6(u,o,m){var C=We(u)?ll:ry;return m&&Qr(u,o,m)&&(o=e),C(u,je(o,3))}var f6=nt(function(u,o){if(u==null)return[];var m=o.length;return m>1&&Qr(u,o[0],o[1])?o=[]:m>2&&Qr(o[0],o[1],o[2])&&(o=[o[0]]),c1(u,Pr(o,1),[])}),ql=N||function(){return ir.Date.now()};function h6(u,o){if(typeof o!="function")throw new ln(i);return u=Qe(u),function(){if(--u<1)return o.apply(this,arguments)}}function ng(u,o,m){return o=m?e:o,o=u&&o==null?u.length:o,os(u,B,e,e,e,e,o)}function ig(u,o){var m;if(typeof o!="function")throw new ln(i);return u=Qe(u),function(){return--u>0&&(m=o.apply(this,arguments)),u<=1&&(o=e),m}}var yp=nt(function(u,o,m){var C=A;if(m.length){var T=In(m,zu(yp));C|=_}return os(u,C,o,m,T)}),sg=nt(function(u,o,m){var C=A|g;if(m.length){var T=In(m,zu(sg));C|=_}return os(o,C,u,m,T)});function ag(u,o,m){o=m?e:o;var C=os(u,w,e,e,e,e,e,o);return C.placeholder=ag.placeholder,C}function ug(u,o,m){o=m?e:o;var C=os(u,S,e,e,e,e,e,o);return C.placeholder=ug.placeholder,C}function og(u,o,m){var C,T,U,Y,J,ne,ge=0,me=!1,we=!1,Ie=!0;if(typeof u!="function")throw new ln(i);o=Qn(o)||0,Mt(m)&&(me=!!m.leading,we="maxWait"in m,U=we?cr(Qn(m.maxWait)||0,o):U,Ie="trailing"in m?!!m.trailing:Ie);function Te(tr){var pi=C,ds=T;return C=T=e,ge=tr,Y=u.apply(ds,pi),Y}function Ke(tr){return ge=tr,J=Ec(at,o),me?Te(tr):Y}function tt(tr){var pi=tr-ne,ds=tr-ge,Ig=o-pi;return we?Lr(Ig,U-ds):Ig}function Ve(tr){var pi=tr-ne,ds=tr-ge;return ne===e||pi>=o||pi<0||we&&ds>=U}function at(){var tr=ql();if(Ve(tr))return ct(tr);J=Ec(at,tt(tr))}function ct(tr){return J=e,Ie&&C?Te(tr):(C=T=e,Y)}function $n(){J!==e&&w1(J),ge=0,C=ne=T=J=e}function en(){return J===e?Y:ct(ql())}function Rn(){var tr=ql(),pi=Ve(tr);if(C=arguments,T=this,ne=tr,pi){if(J===e)return Ke(ne);if(we)return w1(J),J=Ec(at,o),Te(ne)}return J===e&&(J=Ec(at,o)),Y}return Rn.cancel=$n,Rn.flush=en,Rn}var p6=nt(function(u,o){return J0(u,1,o)}),d6=nt(function(u,o,m){return J0(u,Qn(o)||0,m)});function g6(u){return os(u,z)}function Kl(u,o){if(typeof u!="function"||o!=null&&typeof o!="function")throw new ln(i);var m=function(){var C=arguments,T=o?o.apply(this,C):C[0],U=m.cache;if(U.has(T))return U.get(T);var Y=u.apply(this,C);return m.cache=U.set(T,Y)||U,Y};return m.cache=new(Kl.Cache||as),m}Kl.Cache=as;function Vl(u){if(typeof u!="function")throw new ln(i);return function(){var o=arguments;switch(o.length){case 0:return!u.call(this);case 1:return!u.call(this,o[0]);case 2:return!u.call(this,o[0],o[1]);case 3:return!u.call(this,o[0],o[1],o[2])}return!u.apply(this,o)}}function m6(u){return ig(2,u)}var v6=ny(function(u,o){o=o.length==1&&We(o[0])?te(o[0],kr(je())):te(Pr(o,1),kr(je()));var m=o.length;return nt(function(C){for(var T=-1,U=Lr(C.length,m);++T=o}),Ha=r1(function(){return arguments}())?r1:function(u){return Wt(u)&&ft.call(u,"callee")&&!Sl.call(u,"callee")},We=ue.isArray,R6=il?kr(il):HE;function hn(u){return u!=null&&Gl(u.length)&&!hs(u)}function er(u){return Wt(u)&&hn(u)}function T6(u){return u===!0||u===!1||Wt(u)&&Zr(u)==xt}var Xs=Dt||Tp,x6=sl?kr(sl):jE;function O6(u){return Wt(u)&&u.nodeType===1&&!yc(u)}function N6(u){if(u==null)return!0;if(hn(u)&&(We(u)||typeof u=="string"||typeof u.splice=="function"||Xs(u)||Yu(u)||Ha(u)))return!u.length;var o=Ur(u);if(o==et||o==Fr)return!u.size;if(Ac(u))return!Jh(u).length;for(var m in u)if(ft.call(u,m))return!1;return!0}function k6(u,o){return mc(u,o)}function L6(u,o,m){m=typeof m=="function"?m:e;var C=m?m(u,o):e;return C===e?mc(u,o,e,m):!!C}function bp(u){if(!Wt(u))return!1;var o=Zr(u);return o==Ut||o==Zt||typeof u.message=="string"&&typeof u.name=="string"&&!yc(u)}function U6(u){return typeof u=="number"&&Yt(u)}function hs(u){if(!Mt(u))return!1;var o=Zr(u);return o==rt||o==$t||o==mr||o==Vn}function lg(u){return typeof u=="number"&&u==Qe(u)}function Gl(u){return typeof u=="number"&&u>-1&&u%1==0&&u<=X}function Mt(u){var o=typeof u;return u!=null&&(o=="object"||o=="function")}function Wt(u){return u!=null&&typeof u=="object"}var fg=al?kr(al):qE;function H6(u,o){return u===o||Xh(u,o,pp(o))}function j6(u,o,m){return m=typeof m=="function"?m:e,Xh(u,o,pp(o),m)}function M6(u){return hg(u)&&u!=+u}function q6(u){if(_y(u))throw new Ge(n);return n1(u)}function K6(u){return u===null}function V6(u){return u==null}function hg(u){return typeof u=="number"||Wt(u)&&Zr(u)==vt}function yc(u){if(!Wt(u)||Zr(u)!=Xe)return!1;var o=Hu(u);if(o===null)return!0;var m=ft.call(o,"constructor")&&o.constructor;return typeof m=="function"&&m instanceof m&&Ou.call(m)==Uh}var Cp=ul?kr(ul):KE;function G6(u){return lg(u)&&u>=-X&&u<=X}var pg=ol?kr(ol):VE;function zl(u){return typeof u=="string"||!We(u)&&Wt(u)&&Zr(u)==rr}function Pn(u){return typeof u=="symbol"||Wt(u)&&Zr(u)==Or}var Yu=cl?kr(cl):GE;function z6(u){return u===e}function Y6(u){return Wt(u)&&Ur(u)==zr}function W6(u){return Wt(u)&&Zr(u)==wt}var X6=kl(Zh),J6=kl(function(u,o){return u<=o});function dg(u){if(!u)return[];if(hn(u))return zl(u)?cn(u):fn(u);if(ns&&u[ns])return Rh(u[ns]());var o=Ur(u),m=o==et?oc:o==Fr?Dn:Wu;return m(u)}function ps(u){if(!u)return u===0?u:0;if(u=Qn(u),u===V||u===-V){var o=u<0?-1:1;return o*ie}return u===u?u:0}function Qe(u){var o=ps(u),m=o%1;return o===o?m?o-m:o:0}function gg(u){return u?Na(Qe(u),0,Ee):0}function Qn(u){if(typeof u=="number")return u;if(Pn(u))return Se;if(Mt(u)){var o=typeof u.valueOf=="function"?u.valueOf():u;u=Mt(o)?o+"":o}if(typeof u!="string")return u===0?u:+u;u=ac(u);var m=Vo.test(u);return m||zo.test(u)?Ch(u.slice(2),m?2:8):yu.test(u)?Se:+u}function mg(u){return Ii(u,pn(u))}function Z6(u){return u?Na(Qe(u),-X,X):u===0?u:0}function bt(u){return u==null?"":Bn(u)}var Q6=Vu(function(u,o){if(Ac(o)||hn(o)){Ii(o,Er(o),u);return}for(var m in o)ft.call(o,m)&&pc(u,m,o[m])}),vg=Vu(function(u,o){Ii(o,pn(o),u)}),Yl=Vu(function(u,o,m,C){Ii(o,pn(o),u,C)}),eS=Vu(function(u,o,m,C){Ii(o,Er(o),u,C)}),tS=cs(Vh);function rS(u,o){var m=Ku(u);return o==null?m:W0(m,o)}var nS=nt(function(u,o){u=It(u);var m=-1,C=o.length,T=C>2?o[2]:e;for(T&&Qr(o[0],o[1],T)&&(C=1);++m1),U}),Ii(u,fp(u),m),C&&(m=Xn(m,h|v|E,dy));for(var T=o.length;T--;)np(m,o[T]);return m});function yS(u,o){return Ag(u,Vl(je(o)))}var SS=cs(function(u,o){return u==null?{}:WE(u,o)});function Ag(u,o){if(u==null)return{};var m=te(fp(u),function(C){return[C]});return o=je(o),l1(u,m,function(C,T){return o(C,T[0])})}function bS(u,o,m){o=Ys(o,u);var C=-1,T=o.length;for(T||(T=1,u=e);++Co){var C=u;u=o,o=C}if(m||u%1||o%1){var T=V0();return Lr(u+T*(o-u+bh("1e-"+((T+"").length-1))),o)}return ep(u,o)}var xS=Gu(function(u,o,m){return o=o.toLowerCase(),u+(m?Sg(o):o)});function Sg(u){return Ip(bt(u).toLowerCase())}function bg(u){return u=bt(u),u&&u.replace(Si,uc).replace(Wr,"")}function OS(u,o,m){u=bt(u),o=Bn(o);var C=u.length;m=m===e?C:Na(Qe(m),0,C);var T=m;return m-=o.length,m>=0&&u.slice(m,T)==o}function NS(u){return u=bt(u),u&&wu.test(u)?u.replace(mu,Bh):u}function kS(u){return u=bt(u),u&&No.test(u)?u.replace(Hs,"\\$&"):u}var LS=Gu(function(u,o,m){return u+(m?"-":"")+o.toLowerCase()}),US=Gu(function(u,o,m){return u+(m?" ":"")+o.toLowerCase()}),HS=_1("toLowerCase");function jS(u,o,m){u=bt(u),o=Qe(o);var C=o?ts(u):0;if(!o||C>=o)return u;var T=(o-C)/2;return Nl(se(T),m)+u+Nl(M(T),m)}function MS(u,o,m){u=bt(u),o=Qe(o);var C=o?ts(u):0;return o&&C>>0,m?(u=bt(u),u&&(typeof o=="string"||o!=null&&!Cp(o))&&(o=Bn(o),!o&&es(u))?Ws(cn(u),0,m):u.split(o,m)):[]}var WS=Gu(function(u,o,m){return u+(m?" ":"")+Ip(o)});function XS(u,o,m){return u=bt(u),m=m==null?0:Na(Qe(m),0,u.length),o=Bn(o),u.slice(m,m+o.length)==o}function JS(u,o,m){var C=k.templateSettings;m&&Qr(u,o,m)&&(o=e),u=bt(u),o=Yl({},o,C,T1);var T=Yl({},o.imports,C.imports,T1),U=Er(T),Y=Ra(T,U),J,ne,ge=0,me=o.interpolate||an,we="__p += '",Ie=Tu((o.escape||an).source+"|"+me.source+"|"+(me===Eu?Ko:an).source+"|"+(o.evaluate||an).source+"|$","g"),Te="//# sourceURL="+(ft.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++wh+"]")+` `;u.replace(Ie,function(Ve,at,ct,$n,en,Rn){return ct||(ct=$n),we+=u.slice(ge,Rn).replace(Yo,gl),at&&(J=!0,we+=`' + __e(`+at+`) + '`),en&&(ne=!0,we+=`'; `+en+`; __p += '`),ct&&(we+=`' + ((__t = (`+ct+`)) == null ? '' : __t) + '`),ge=Rn+Ve.length,Ve}),we+=`'; `;var Ke=ft.call(o,"variable")&&o.variable;if(!Ke)we=`with (obj) { `+we+` } `;else if(Mo.test(Ke))throw new Ge(a);we=(ne?we.replace(Ji,""):we).replace(pu,"$1").replace(du,"$1;"),we="function("+(Ke||"obj")+`) { `+(Ke?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(J?", __e = _.escape":"")+(ne?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+we+`return __p }`;var tt=Fg(function(){return ot(U,Te+"return "+we).apply(e,Y)});if(tt.source=we,bp(tt))throw tt;return tt}function ZS(u){return bt(u).toLowerCase()}function QS(u){return bt(u).toUpperCase()}function e5(u,o,m){if(u=bt(u),u&&(m||o===e))return ac(u);if(!u||!(o=Bn(o)))return u;var C=cn(u),T=cn(o),U=Pu(C,T),Y=pl(C,T)+1;return Ws(C,U,Y).join("")}function t5(u,o,m){if(u=bt(u),u&&(m||o===e))return u.slice(0,Ru(u)+1);if(!u||!(o=Bn(o)))return u;var C=cn(u),T=pl(C,cn(o))+1;return Ws(C,0,T).join("")}function r5(u,o,m){if(u=bt(u),u&&(m||o===e))return u.replace(Sa,"");if(!u||!(o=Bn(o)))return u;var C=cn(u),T=Pu(C,cn(o));return Ws(C,T).join("")}function n5(u,o){var m=F,C=P;if(Mt(o)){var T="separator"in o?o.separator:T;m="length"in o?Qe(o.length):m,C="omission"in o?Bn(o.omission):C}u=bt(u);var U=u.length;if(es(u)){var Y=cn(u);U=Y.length}if(m>=U)return u;var J=m-ts(C);if(J<1)return C;var ne=Y?Ws(Y,0,J).join(""):u.slice(0,J);if(T===e)return ne+C;if(Y&&(J+=ne.length-J),Cp(T)){if(u.slice(J).search(T)){var ge,me=ne;for(T.global||(T=Tu(T.source,bt(yi.exec(T))+"g")),T.lastIndex=0;ge=T.exec(me);)var we=ge.index;ne=ne.slice(0,we===e?J:we)}}else if(u.indexOf(Bn(T),J)!=J){var Ie=ne.lastIndexOf(T);Ie>-1&&(ne=ne.slice(0,Ie))}return ne+C}function i5(u){return u=bt(u),u&&vu.test(u)?u.replace(gu,vl):u}var s5=Gu(function(u,o,m){return u+(m?" ":"")+o.toUpperCase()}),Ip=_1("toUpperCase");function Cg(u,o,m){return u=bt(u),o=m?e:o,o===e?$h(u)?Oh(u):nc(u):u.match(o)||[]}var Fg=nt(function(u,o){try{return Xr(u,e,o)}catch(m){return bp(m)?m:new Ge(m)}}),a5=cs(function(u,o){return on(o,function(m){m=Di(m),us(u,m,yp(u[m],u))}),u});function u5(u){var o=u==null?0:u.length,m=je();return u=o?te(u,function(C){if(typeof C[1]!="function")throw new ln(i);return[m(C[0]),C[1]]}):[],nt(function(C){for(var T=-1;++TX)return[];var m=Ee,C=Lr(u,Ee);o=je(o),u-=Ee;for(var T=sc(C,o);++m0||o<0)?new ut(m):(u<0?m=m.takeRight(-u):u&&(m=m.drop(u)),o!==e&&(o=Qe(o),m=o<0?m.dropRight(-o):m.take(o-u)),m)},ut.prototype.takeRightWhile=function(u){return this.reverse().takeWhile(u).reverse()},ut.prototype.toArray=function(){return this.take(Ee)},_i(ut.prototype,function(u,o){var m=/^(?:filter|find|map|reject)|While$/.test(o),C=/^(?:head|last)$/.test(o),T=k[C?"take"+(o=="last"?"Right":""):o],U=C||/^find/.test(o);T&&(k.prototype[o]=function(){var Y=this.__wrapped__,J=C?[1]:arguments,ne=Y instanceof ut,ge=J[0],me=ne||We(Y),we=function(at){var ct=T.apply(k,_n([at],J));return C&&Ie?ct[0]:ct};me&&m&&typeof ge=="function"&&ge.length!=1&&(ne=me=!1);var Ie=this.__chain__,Te=!!this.__actions__.length,Ke=U&&!Ie,tt=ne&&!Te;if(!U&&me){Y=tt?Y:new ut(this);var Ve=u.apply(Y,J);return Ve.__actions__.push({func:jl,args:[we],thisArg:e}),new Wn(Ve,Ie)}return Ke&&tt?u.apply(this,J):(Ve=this.thru(we),Ke?C?Ve.value()[0]:Ve.value():Ve)})}),on(["pop","push","shift","sort","splice","unshift"],function(u){var o=xu[u],m=/^(?:push|sort|unshift)$/.test(u)?"tap":"thru",C=/^(?:pop|shift)$/.test(u);k.prototype[u]=function(){var T=arguments;if(C&&!this.__chain__){var U=this.value();return o.apply(We(U)?U:[],T)}return this[m](function(Y){return o.apply(We(Y)?Y:[],T)})}}),_i(ut.prototype,function(u,o){var m=k[o];if(m){var C=m.name+"";ft.call(qu,C)||(qu[C]=[]),qu[C].push({name:o,func:m})}}),qu[xl(e,g).name]=[{name:"wrapper",func:e}],ut.prototype.clone=iE,ut.prototype.reverse=sE,ut.prototype.value=aE,k.prototype.at=O4,k.prototype.chain=N4,k.prototype.commit=k4,k.prototype.next=L4,k.prototype.plant=H4,k.prototype.reverse=j4,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=M4,k.prototype.first=k.prototype.head,ns&&(k.prototype[ns]=U4),k},Yn=Nh();typeof define=="function"&&typeof define.amd=="object"&&define.amd?(ir._=Yn,define(function(){return Yn})):Zi?((Zi.exports=Yn)._=Yn,ec._=Yn):ir._=Yn}).call(Io)});var oh=Ce((vO,Bw)=>{"use strict";var SB=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(let r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},d0=class e extends Error{constructor(t,r,n){super(t),SB(this,e.prototype),this.name="GrammarError",this.location=r,n===void 0&&(n=[]),this.diagnostics=n,this.stage=null,this.problems=[["error",t,r,n]]}toString(){let t=super.toString();this.location&&(t+=` at `,this.location.source!==void 0&&this.location.source!==null&&(t+=`${this.location.source}:`),t+=`${this.location.start.line}:${this.location.start.column}`);for(let r of this.diagnostics)t+=` from `,r.location.source!==void 0&&r.location.source!==null&&(t+=`${r.location.source}:`),t+=`${r.location.start.line}:${r.location.start.column}: ${r.message}`;return t}format(t){let r=t.map(({source:a,text:s})=>({source:a,text:s.split(/\r\n|\n|\r/g)}));function n(a,s,c=""){let l="",h=r.find(({source:E})=>E===a.source),v=a.start;if(h){let E=a.end,p=h.text[v.line-1],A=(v.line===E.line?E.column:p.length+1)-v.column||1;c&&(l+=` note: ${c}`),l+=` --> ${a.source}:${v.line}:${v.column} ${"".padEnd(s)} | ${v.line.toString().padStart(s)} | ${p} ${"".padEnd(s)} | ${"".padEnd(v.column-1)}${"".padEnd(A,"^")}`}else l+=` at ${a.source}:${v.line}:${v.column}`,c&&(l+=`: ${c}`);return l}function i(a,s,c,l=[]){let h;c?h=l.reduce((E,{location:p})=>Math.max(E,p.start.line),c.start.line):h=Math.max.apply(null,l.map(E=>E.location.start.line)),h=h.toString().length;let v=`${a}: ${s}`;c&&(v+=n(c,h));for(let E of l)v+=n(E.location,h,E.message);return v}return this.problems.filter(a=>a[0]!=="info").map(a=>i(...a)).join(` `)}};Bw.exports=d0});var oi=Ce((wO,Pw)=>{"use strict";var bB={build(e){function t(s,...c){return e[s.type](s,...c)}function r(){}function n(s,...c){return t(s.expression,...c)}function i(s){return function(c,...l){c[s].forEach(h=>t(h,...l))}}let a={grammar(s,...c){s.topLevelInitializer&&t(s.topLevelInitializer,...c),s.initializer&&t(s.initializer,...c),s.rules.forEach(l=>t(l,...c))},top_level_initializer:r,initializer:r,rule:n,named:n,choice:i("alternatives"),action:n,sequence:i("elements"),labeled:n,text:n,simple_and:n,simple_not:n,optional:n,zero_or_more:n,one_or_more:n,group:n,semantic_and:r,semantic_not:r,rule_ref:r,literal:r,class:r,any:r};return Object.keys(a).forEach(s=>{Object.prototype.hasOwnProperty.call(e,s)||(e[s]=a[s])}),t}};Pw.exports=bB});var ha=Ce((AO,Rw)=>{"use strict";var CB=oi(),$w={findRule(e,t){for(let r=0;r{"use strict";var FB={PUSH:0,PUSH_EMPTY_STRING:35,PUSH_UNDEFINED:1,PUSH_NULL:2,PUSH_FAILED:3,PUSH_EMPTY_ARRAY:4,PUSH_CURR_POS:5,POP:6,POP_CURR_POS:7,POP_N:8,NIP:9,APPEND:10,WRAP:11,TEXT:12,PLUCK:36,IF:13,IF_ERROR:14,IF_NOT_ERROR:15,WHILE_NOT_ERROR:16,MATCH_ANY:17,MATCH_STRING:18,MATCH_STRING_IC:19,MATCH_CHAR_CLASS:20,MATCH_REGEXP:20,ACCEPT_N:21,ACCEPT_STRING:22,FAIL:23,LOAD_SAVED_POS:24,UPDATE_SAVED_POS:25,CALL:26,RULE:27,SILENT_FAILS_ON:28,SILENT_FAILS_OFF:29};Tw.exports=FB});var m0=Ce((yO,xw)=>{"use strict";var _B=oi(),IB=ha(),DB=oh(),Wc=1,hu=0,Xc=-1;function ch(e){function t(s){return s.match=hu}function r(s){return a(s.expression),s.match=Wc}function n(s){return s.match=a(s.expression)}function i(s,c){let l=s.length,h=0,v=0;for(let E=0;E0?Xc:hu}let a=_B.build({rule(s){let c,l=0;if(typeof s.match>"u"){s.match=hu;do if(c=s.match,s.match=a(s.expression),++l>6)throw new DB("Infinity cycle detected when trying to evaluate node match result",s.location);while(c!==s.match)}return s.match},named:n,choice(s){return s.match=i(s.alternatives,!0)},action:n,sequence(s){return s.match=i(s.elements,!1)},labeled:n,text:n,simple_and:n,simple_not(s){return s.match=-a(s.expression)},optional:r,zero_or_more:r,one_or_more:n,group:n,semantic_and:t,semantic_not:t,rule_ref(s){let c=IB.findRule(e,s.name);return s.match=a(c)},literal(s){let c=s.value.length===0?Wc:hu;return s.match=c},class(s){let c=s.parts.length===0?Xc:hu;return s.match=c},any:t});a(e)}ch.ALWAYS_MATCH=Wc;ch.SOMETIMES_MATCH=hu;ch.NEVER_MATCH=Xc;xw.exports=ch});var Nw=Ce((SO,Ow)=>{"use strict";var BB=ha(),Be=g0(),PB=oi(),{ALWAYS_MATCH:Po,SOMETIMES_MATCH:v0,NEVER_MATCH:w0}=m0();function $B(e){let t=[],r=[],n=[],i=[];function a(S){let _=t.indexOf(S);return _===-1?t.push(S)-1:_}function s(S){let _={value:S.parts,inverted:S.inverted,ignoreCase:S.ignoreCase},I=JSON.stringify(_),B=r.findIndex(q=>JSON.stringify(q)===I);return B===-1?r.push(_)-1:B}function c(S){let _=JSON.stringify(S),I=n.findIndex(B=>JSON.stringify(B)===_);return I===-1?n.push(S)-1:I}function l(S,_,I){let B={predicate:S,params:_,body:I.code,location:I.codeLocation},q=JSON.stringify(B),z=i.findIndex(F=>JSON.stringify(F)===q);return z===-1?i.push(B)-1:z}function h(S){let _={};return Object.keys(S).forEach(I=>{_[I]=S[I]}),_}function v(S,..._){return S.concat(..._)}function E(S,_,I,B){return S===Po?I:S===w0?B:_.concat([I.length,B.length],I,B)}function p(S,_){return S.concat([_.length],_)}function f(S,_,I,B){let q=Object.keys(I).map(z=>B-I[z]);return[Be.CALL,S,_,q.length].concat(q)}function A(S,_,I){let B=S.match|0;return v([Be.PUSH_CURR_POS],[Be.SILENT_FAILS_ON],w(S,{sp:I.sp+1,env:h(I.env),action:null}),[Be.SILENT_FAILS_OFF],E(_?-B:B,[_?Be.IF_ERROR:Be.IF_NOT_ERROR],v([Be.POP],[_?Be.POP:Be.POP_CURR_POS],[Be.PUSH_UNDEFINED]),v([Be.POP],[_?Be.POP_CURR_POS:Be.POP],[Be.PUSH_FAILED])))}function g(S,_,I){let B=l(!0,Object.keys(I.env),S);return v([Be.UPDATE_SAVED_POS],f(B,0,I.env,I.sp),E(S.match|0,[Be.IF],v([Be.POP],_?[Be.PUSH_FAILED]:[Be.PUSH_UNDEFINED]),v([Be.POP],_?[Be.PUSH_UNDEFINED]:[Be.PUSH_FAILED])))}function y(S){return p([Be.WHILE_NOT_ERROR],v([Be.APPEND],S))}let w=PB.build({grammar(S){S.rules.forEach(w),S.literals=t,S.classes=r,S.expectations=n,S.functions=i},rule(S){S.bytecode=w(S.expression,{sp:-1,env:{},pluck:[],action:null})},named(S,_){let I=S.match|0,B=I===w0?null:c({type:"rule",value:S.name});return v([Be.SILENT_FAILS_ON],w(S.expression,_),[Be.SILENT_FAILS_OFF],E(I,[Be.IF_ERROR],[Be.FAIL,B],[]))},choice(S,_){function I(B,q){let z=B[0].match|0,F=w(B[0],{sp:q.sp,env:h(q.env),action:null});return z===Po?F:v(F,B.length>1?E(v0,[Be.IF_ERROR],v([Be.POP],I(B.slice(1),q)),[]):[])}return I(S.alternatives,_)},action(S,_){let I=h(_.env),B=S.expression.type!=="sequence"||S.expression.elements.length===0,q=w(S.expression,{sp:_.sp+(B?1:0),env:I,action:S}),z=S.expression.match|0,F=B&&z!==w0?l(!1,Object.keys(I),S):null;return B?v([Be.PUSH_CURR_POS],q,E(z,[Be.IF_NOT_ERROR],v([Be.LOAD_SAVED_POS,1],f(F,1,I,_.sp+2)),[]),[Be.NIP]):q},sequence(S,_){function I(B,q){if(B.length>0){let z=S.elements.length-B.length+1;return v(w(B[0],{sp:q.sp,env:q.env,pluck:q.pluck,action:null}),E(B[0].match|0,[Be.IF_NOT_ERROR],I(B.slice(1),{sp:q.sp+1,env:q.env,pluck:q.pluck,action:q.action}),v(z>1?[Be.POP_N,z]:[Be.POP],[Be.POP_CURR_POS],[Be.PUSH_FAILED])))}else{if(q.pluck.length>0)return v([Be.PLUCK,S.elements.length+1,q.pluck.length],q.pluck.map(z=>q.sp-z));if(q.action){let z=l(!1,Object.keys(q.env),q.action);return v([Be.LOAD_SAVED_POS,S.elements.length],f(z,S.elements.length+1,q.env,q.sp))}else return v([Be.WRAP,S.elements.length],[Be.NIP])}}return v([Be.PUSH_CURR_POS],I(S.elements,{sp:_.sp+1,env:_.env,pluck:[],action:_.action}))},labeled(S,_){let I=_.env,B=S.label,q=_.sp+1;return B&&(I=h(_.env),_.env[S.label]=q),S.pick&&_.pluck.push(q),w(S.expression,{sp:_.sp,env:I,action:null})},text(S,_){return v([Be.PUSH_CURR_POS],w(S.expression,{sp:_.sp+1,env:h(_.env),action:null}),E(S.match|0,[Be.IF_NOT_ERROR],v([Be.POP],[Be.TEXT]),[Be.NIP]))},simple_and(S,_){return A(S.expression,!1,_)},simple_not(S,_){return A(S.expression,!0,_)},optional(S,_){return v(w(S.expression,{sp:_.sp,env:h(_.env),action:null}),E(-(S.expression.match|0),[Be.IF_ERROR],v([Be.POP],[Be.PUSH_NULL]),[]))},zero_or_more(S,_){let I=w(S.expression,{sp:_.sp+1,env:h(_.env),action:null});return v([Be.PUSH_EMPTY_ARRAY],I,y(I),[Be.POP])},one_or_more(S,_){let I=w(S.expression,{sp:_.sp+1,env:h(_.env),action:null});return v([Be.PUSH_EMPTY_ARRAY],I,E(S.expression.match|0,[Be.IF_NOT_ERROR],v(y(I),[Be.POP]),v([Be.POP],[Be.POP],[Be.PUSH_FAILED])))},group(S,_){return w(S.expression,{sp:_.sp,env:h(_.env),action:null})},semantic_and(S,_){return g(S,!1,_)},semantic_not(S,_){return g(S,!0,_)},rule_ref(S){return[Be.RULE,BB.indexOfRule(e,S.name)]},literal(S){if(S.value.length>0){let _=S.match|0,B=_===v0||_===Po&&!S.ignoreCase?a(S.ignoreCase?S.value.toLowerCase():S.value):null,q=_!==Po?c({type:"literal",value:S.value,ignoreCase:S.ignoreCase}):null;return E(_,S.ignoreCase?[Be.MATCH_STRING_IC,B]:[Be.MATCH_STRING,B],S.ignoreCase?[Be.ACCEPT_N,S.value.length]:[Be.ACCEPT_STRING,B],[Be.FAIL,q])}return[Be.PUSH_EMPTY_STRING]},class(S){let _=S.match|0,I=_===v0?s(S):null,B=_!==Po?c({type:"class",value:S.parts,inverted:S.inverted,ignoreCase:S.ignoreCase}):null;return E(_,[Be.MATCH_CHAR_CLASS,I],[Be.ACCEPT_N,1],[Be.FAIL,B])},any(S){let _=S.match|0,I=_!==Po?c({type:"any"}):null;return E(_,[Be.MATCH_ANY],[Be.ACCEPT_N,1],[Be.FAIL,I])}});w(e)}Ow.exports=$B});var Lw=Ce((bO,kw)=>{"use strict";var A0=class{constructor(t,r,n){this.sp=-1,this.maxSp=-1,this.varName=r,this.ruleName=t,this.type=n}name(t){if(t<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack underflow: attempt to use a variable '${this.varName}' at an index ${t}`);return this.varName+t}push(t){let r=this.name(++this.sp)+" = "+t+";";return this.sp>this.maxSp&&(this.maxSp=this.sp),r}pop(t){return t!==void 0?(this.sp-=t,Array.from({length:t},(r,n)=>this.name(this.sp+1+n))):this.name(this.sp--)}top(){return this.name(this.sp)}index(t){if(t<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack overflow: attempt to get a variable at a negative index ${t}`);return this.name(this.sp-t)}result(){if(this.maxSp<0)throw new RangeError(`Rule '${this.ruleName}': The variable stack is empty, can't get the result'`);return this.name(0)}defines(){return this.maxSp<0?"":this.type+" "+Array.from({length:this.maxSp+1},(t,r)=>this.name(r)).join(", ")+";"}checkedIf(t,r,n){let i=this.sp;if(r(),n){let a=this.sp;if(this.sp=i,n(),a!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Branches of a condition can't move the stack pointer differently (before: "+i+", after then: "+a+", after else: "+this.sp+").")}}checkedLoop(t,r){let n=this.sp;if(r(),n!==this.sp)throw new Error("Rule '"+this.ruleName+"', position "+t+": Body of a loop can't move the stack pointer (before: "+n+", after: "+this.sp+").")}};kw.exports=A0});var E0=Ce((CO,Uw)=>{"use strict";Uw.exports="2.0.1"});var Hw=Ce(lh=>{"use strict";function ks(e){return e.charCodeAt(0).toString(16).toUpperCase()}lh.hex=ks;function RB(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+ks(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+ks(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+ks(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+ks(t))}lh.stringEscape=RB;function TB(e){return e.replace(/\\/g,"\\\\").replace(/\//g,"\\/").replace(/]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\x08/g,"\\b").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\v/g,"\\v").replace(/\f/g,"\\f").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,t=>"\\x0"+ks(t)).replace(/[\x10-\x1F\x7F-\xFF]/g,t=>"\\x"+ks(t)).replace(/[\u0100-\u0FFF]/g,t=>"\\u0"+ks(t)).replace(/[\u1000-\uFFFF]/g,t=>"\\u"+ks(t))}lh.regexpClassEscape=TB});var qw=Ce(Mw=>{var jw="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split("");Mw.encode=function(e){if(0<=e&&e{var xB=qw(),Kw=5,Vw=1<>>=Kw,i>0&&(n|=NB),r+=xB.encode(n);while(i>0);return r}});var hh=Ce(da=>{function LB(e,t,r){if(t in e)return e[t];if(arguments.length===3)return r;throw new Error('"'+t+'" is a required argument.')}da.getArg=LB;var Ww=function(){return!("__proto__"in Object.create(null))}();function Xw(e){return e}function UB(e){return Jw(e)?"$"+e:e}da.toSetString=Ww?Xw:UB;function HB(e){return Jw(e)?e.slice(1):e}da.fromSetString=Ww?Xw:HB;function Jw(e){if(!e)return!1;let t=e.length;if(t<9||e.charCodeAt(t-1)!==95||e.charCodeAt(t-2)!==95||e.charCodeAt(t-3)!==111||e.charCodeAt(t-4)!==116||e.charCodeAt(t-5)!==111||e.charCodeAt(t-6)!==114||e.charCodeAt(t-7)!==112||e.charCodeAt(t-8)!==95||e.charCodeAt(t-9)!==95)return!1;for(let r=t-10;r>=0;r--)if(e.charCodeAt(r)!==36)return!1;return!0}function Yw(e,t){return e===t?0:e===null?1:t===null?-1:e>t?1:-1}function jB(e,t){let r=e.generatedLine-t.generatedLine;return r!==0||(r=e.generatedColumn-t.generatedColumn,r!==0)||(r=Yw(e.source,t.source),r!==0)||(r=e.originalLine-t.originalLine,r!==0)||(r=e.originalColumn-t.originalColumn,r!==0)?r:Yw(e.name,t.name)}da.compareByGeneratedPositionsInflated=jB;var y0="http:",Jc=`${y0}//host`;function Zw(e){return t=>{let r=Zc(t),n=S0(t),i=new URL(t,n);e(i);let a=i.toString();return r==="absolute"?a:r==="scheme-relative"?a.slice(y0.length):r==="path-absolute"?a.slice(Jc.length):b0(n,a)}}function pa(e,t){return new URL(e,t).toString()}function MB(e,t){let r=0;do{let n=e+r++;if(t.indexOf(n)===-1)return n}while(!0)}function S0(e){let t=e.split("..").length-1,r=MB("p",e),n=`${Jc}/`;for(let i=0;i0&&!n[n.length-1]&&n.pop();r.length>0&&n.length>0&&r[0]===n[0];)r.shift(),n.shift();return n.map(()=>"..").concat(r).join("/")+t.search+t.hash}var KB=Zw(e=>{e.pathname=e.pathname.replace(/\/?$/,"/")}),fh=Zw(e=>{});da.normalize=fh;function VB(e,t){let r=Zc(t),n=Zc(e);if(e=KB(e),r==="absolute")return pa(t,void 0);if(n==="absolute")return pa(t,e);if(r==="scheme-relative")return fh(t);if(n==="scheme-relative")return pa(t,pa(e,Jc)).slice(y0.length);if(r==="path-absolute")return fh(t);if(n==="path-absolute")return pa(t,pa(e,Jc)).slice(Jc.length);let i=S0(t+e),a=pa(t,pa(e,i));return b0(i,a)}da.join=VB;function GB(e,t){let r=zB(e,t);return typeof r=="string"?r:fh(t)}da.relative=GB;function zB(e,t){if(Zc(e)!==Zc(t))return null;let n=S0(e+t),i=new URL(e,n),a=new URL(t,n);try{new URL("",a.toString())}catch{return null}return a.protocol!==i.protocol||a.user!==i.user||a.password!==i.password||a.hostname!==i.hostname||a.port!==i.port?null:b0(i,a)}});var eA=Ce(Qw=>{var C0=class e{constructor(){this._array=[],this._set=new Map}static fromArray(t,r){let n=new e;for(let i=0,a=t.length;i=0)return r;throw new Error('"'+t+'" is not in the set.')}at(t){if(t>=0&&t{var tA=hh();function YB(e,t){let r=e.generatedLine,n=t.generatedLine,i=e.generatedColumn,a=t.generatedColumn;return n>r||n==r&&a>=i||tA.compareByGeneratedPositionsInflated(e,t)<=0}var F0=class{constructor(){this._array=[],this._sorted=!0,this._last={generatedLine:-1,generatedColumn:0}}unsortedForEach(t,r){this._array.forEach(t,r)}add(t){YB(this._last,t)?(this._last=t,this._array.push(t)):(this._sorted=!1,this._array.push(t))}toArray(){return this._sorted||(this._array.sort(tA.compareByGeneratedPositionsInflated),this._sorted=!0),this._array}};rA.MappingList=F0});var _0=Ce(iA=>{var Qc=zw(),or=hh(),ph=eA().ArraySet,WB=nA().MappingList,dh=class e{constructor(t){t||(t={}),this._file=or.getArg(t,"file",null),this._sourceRoot=or.getArg(t,"sourceRoot",null),this._skipValidation=or.getArg(t,"skipValidation",!1),this._sources=new ph,this._names=new ph,this._mappings=new WB,this._sourcesContents=null}static fromSourceMap(t){let r=t.sourceRoot,n=new e({file:t.file,sourceRoot:r});return t.eachMapping(function(i){let a={generated:{line:i.generatedLine,column:i.generatedColumn}};i.source!=null&&(a.source=i.source,r!=null&&(a.source=or.relative(r,a.source)),a.original={line:i.originalLine,column:i.originalColumn},i.name!=null&&(a.name=i.name)),n.addMapping(a)}),t.sources.forEach(function(i){let a=i;r!=null&&(a=or.relative(r,i)),n._sources.has(a)||n._sources.add(a);let s=t.sourceContentFor(i);s!=null&&n.setSourceContent(i,s)}),n}addMapping(t){let r=or.getArg(t,"generated"),n=or.getArg(t,"original",null),i=or.getArg(t,"source",null),a=or.getArg(t,"name",null);this._skipValidation||this._validateMapping(r,n,i,a),i!=null&&(i=String(i),this._sources.has(i)||this._sources.add(i)),a!=null&&(a=String(a),this._names.has(a)||this._names.add(a)),this._mappings.add({generatedLine:r.line,generatedColumn:r.column,originalLine:n&&n.line,originalColumn:n&&n.column,source:i,name:a})}setSourceContent(t,r){let n=t;this._sourceRoot!=null&&(n=or.relative(this._sourceRoot,n)),r!=null?(this._sourcesContents||(this._sourcesContents=Object.create(null)),this._sourcesContents[or.toSetString(n)]=r):this._sourcesContents&&(delete this._sourcesContents[or.toSetString(n)],Object.keys(this._sourcesContents).length===0&&(this._sourcesContents=null))}applySourceMap(t,r,n){let i=r;if(r==null){if(t.file==null)throw new Error(`SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, or the source map's "file" property. Both were omitted.`);i=t.file}let a=this._sourceRoot;a!=null&&(i=or.relative(a,i));let s=this._mappings.toArray().length>0?new ph:this._sources,c=new ph;this._mappings.unsortedForEach(function(l){if(l.source===i&&l.originalLine!=null){let E=t.originalPositionFor({line:l.originalLine,column:l.originalColumn});E.source!=null&&(l.source=E.source,n!=null&&(l.source=or.join(n,l.source)),a!=null&&(l.source=or.relative(a,l.source)),l.originalLine=E.line,l.originalColumn=E.column,E.name!=null&&(l.name=E.name))}let h=l.source;h!=null&&!s.has(h)&&s.add(h);let v=l.name;v!=null&&!c.has(v)&&c.add(v)},this),this._sources=s,this._names=c,t.sources.forEach(function(l){let h=t.sourceContentFor(l);h!=null&&(n!=null&&(l=or.join(n,l)),a!=null&&(l=or.relative(a,l)),this.setSourceContent(l,h))},this)}_validateMapping(t,r,n,i){if(r&&typeof r.line!="number"&&typeof r.column!="number")throw new Error("original.line and original.column are not numbers -- you probably meant to omit the original mapping entirely and only map the generated position. If so, pass null for the original mapping instead of an object with empty or null values.");if(!(t&&"line"in t&&"column"in t&&t.line>0&&t.column>=0&&!r&&!n&&!i)){if(!(t&&"line"in t&&"column"in t&&r&&"line"in r&&"column"in r&&t.line>0&&t.column>=0&&r.line>0&&r.column>=0&&n))throw new Error("Invalid mapping: "+JSON.stringify({generated:t,source:n,original:r,name:i}))}}_serializeMappings(){let t=0,r=1,n=0,i=0,a=0,s=0,c="",l,h,v,E,p=this._mappings.toArray();for(let f=0,A=p.length;f0){if(!or.compareByGeneratedPositionsInflated(h,p[f-1]))continue;l+=","}l+=Qc.encode(h.generatedColumn-t),t=h.generatedColumn,h.source!=null&&(E=this._sources.indexOf(h.source),l+=Qc.encode(E-s),s=E,l+=Qc.encode(h.originalLine-1-i),i=h.originalLine-1,l+=Qc.encode(h.originalColumn-n),n=h.originalColumn,h.name!=null&&(v=this._names.indexOf(h.name),l+=Qc.encode(v-a),a=v)),c+=l}return c}_generateSourcesContent(t,r){return t.map(function(n){if(!this._sourcesContents)return null;r!=null&&(n=or.relative(r,n));let i=or.toSetString(n);return Object.prototype.hasOwnProperty.call(this._sourcesContents,i)?this._sourcesContents[i]:null},this)}toJSON(){let t={version:this._version,sources:this._sources.toArray(),names:this._names.toArray(),mappings:this._serializeMappings()};return this._file!=null&&(t.file=this._file),this._sourceRoot!=null&&(t.sourceRoot=this._sourceRoot),this._sourcesContents&&(t.sourcesContent=this._generateSourcesContent(t.sources,t.sourceRoot)),t}toString(){return JSON.stringify(this.toJSON())}};dh.prototype._version=3;iA.SourceMapGenerator=dh});var aA=Ce(sA=>{var XB=_0().SourceMapGenerator,gh=hh(),JB=/(\r?\n)/,ZB=10,$o="$$$isSourceNode$$$",I0=class e{constructor(t,r,n,i,a){this.children=[],this.sourceContents={},this.line=t??null,this.column=r??null,this.source=n??null,this.name=a??null,this[$o]=!0,i!=null&&this.add(i)}static fromStringWithSourceMap(t,r,n){let i=new e,a=t.split(JB),s=0,c=function(){let f=g(),A=g()||"";return f+A;function g(){return s=0;r--)this.prepend(t[r]);else if(t[$o]||typeof t=="string")this.children.unshift(t);else throw new TypeError("Expected a SourceNode, string, or an array of SourceNodes and strings. Got "+t);return this}walk(t){let r;for(let n=0,i=this.children.length;n0){for(r=[],n=0;n{D0.SourceMapGenerator=_0().SourceMapGenerator;D0.SourceNode=aA().SourceNode});var fA=Ce((xO,lA)=>{"use strict";var QB=ha(),St=g0(),e7=Lw(),t7=E0(),{stringEscape:qn,regexpClassEscape:B0}=Hw(),{SourceNode:ci}=uA();function cA(e,t,r){let n=t.start.line,i=t.start.column-1,a=e.split(` `);return a.length===1?new ci(n,i,t.source,e,r):new ci(null,null,t.source,a.map((s,c)=>new ci(n+c,c===0?i:0,t.source,c===a.length-1?s:[s,` `],r)))}function oA(e,t,r,n,i){return r?new ci(null,null,r.source,[e,cA(t,r,i),new ci(r.end.line,r.end.column-1,r.source,n)]):new ci(null,null,null,[e,t,n])}function r7(e,t){function r(g){return g instanceof ci?g:g.replace(/^(.+)$/gm," $1")}function n(g){return"peg$c"+g}function i(g){return"peg$r"+g}function a(g){return"peg$e"+g}function s(g){return"peg$f"+g}function c(g){return"peg$parse"+g}function l(){function g(_){return'"'+qn(_)+'"'}function y(_){return"/^["+(_.inverted?"^":"")+_.value.map(I=>Array.isArray(I)?B0(I[0])+"-"+B0(I[1]):B0(I)).join("")+"]/"+(_.ignoreCase?"i":"")}function w(_){switch(_.type){case"rule":return'peg$otherExpectation("'+qn(_.value)+'")';case"literal":return'peg$literalExpectation("'+qn(_.value)+'", '+_.ignoreCase+")";case"class":return"peg$classExpectation(["+_.value.map(B=>Array.isArray(B)?'["'+qn(B[0])+'", "'+qn(B[1])+'"]':'"'+qn(B)+'"').join(", ")+"], "+_.inverted+", "+_.ignoreCase+")";case"any":return"peg$anyExpectation()";default:throw new Error("Unknown expectation type ("+JSON.stringify(_)+")")}}function S(_,I){return oA(` var ${s(I)} = function(${_.params.join(", ")}) {`,_.body,_.location,"};")}return new ci(null,null,t.grammarSource,[e.literals.map((_,I)=>" var "+n(I)+" = "+g(_)+";").concat("",e.classes.map((_,I)=>" var "+i(I)+" = "+y(_)+";")).concat("",e.expectations.map((_,I)=>" var "+a(I)+" = "+w(_)+";")).concat("").join(` `),e.functions.map(S)])}function h(g,y){let w=[];return w.push(""),t.trace&&w.push("peg$tracer.trace({",' type: "rule.enter",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)","});",""),t.cache&&(w.push("var key = peg$currPos * "+e.rules.length+" + "+y+";","var cached = peg$resultsCache[key];","","if (cached) {"," peg$currPos = cached.nextPos;",""),t.trace&&w.push("if (cached.result !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+g+","," result: cached.result,"," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}",""),w.push(" return cached.result;","}","")),w}function v(g,y){let w=[];return t.cache&&w.push("","peg$resultsCache[key] = { nextPos: peg$currPos, result: "+y+" };"),t.trace&&w.push("","if ("+y+" !== peg$FAILED) {"," peg$tracer.trace({",' type: "rule.match",'," rule: "+g+","," result: "+y+","," location: peg$computeLocation(startPos, peg$currPos)"," });","} else {"," peg$tracer.trace({",' type: "rule.fail",'," rule: "+g+","," location: peg$computeLocation(startPos, startPos)"," });","}"),w.push("","return "+y+";"),w}function E(g){let y=[],w=new e7(g.name,"s","var");function S(I){let B=0,q=I.length,z=[],F;function P(K,Z){let G=Z+3,V=I[B+G-2],X=I[B+G-1],ie,Se;w.checkedIf(B,()=>{B+=G,ie=S(I.slice(B,B+V)),B+=V},X>0?()=>{Se=S(I.slice(B,B+X)),B+=X}:null),z.push("if ("+K+") {"),z.push(...ie.map(r)),X>0&&(z.push("} else {"),z.push(...Se.map(r))),z.push("}")}function L(K){let G=I[B+2-1],V;w.checkedLoop(B,()=>{B+=2,V=S(I.slice(B,B+G)),B+=G}),z.push("while ("+K+") {"),z.push(...V.map(r)),z.push("}")}function H(){let Z=I[B+4-1],G=s(I[B+1])+"("+I.slice(B+4,B+4+Z).map(V=>w.index(V)).join(", ")+")";w.pop(I[B+2]),z.push(w.push(G)),B+=4+Z}for(;Bw.index(V)).join(", ")} ]`,w.pop(I[B+1]),z.push(w.push(F)),B+=G;break}case St.IF:P(w.top(),0);break;case St.IF_ERROR:P(w.top()+" === peg$FAILED",0);break;case St.IF_NOT_ERROR:P(w.top()+" !== peg$FAILED",0);break;case St.WHILE_NOT_ERROR:L(w.top()+" !== peg$FAILED");break;case St.MATCH_ANY:P("input.length > peg$currPos",0);break;case St.MATCH_STRING:P(e.literals[I[B+1]].length>1?"input.substr(peg$currPos, "+e.literals[I[B+1]].length+") === "+n(I[B+1]):"input.charCodeAt(peg$currPos) === "+e.literals[I[B+1]].charCodeAt(0),1);break;case St.MATCH_STRING_IC:P("input.substr(peg$currPos, "+e.literals[I[B+1]].length+").toLowerCase() === "+n(I[B+1]),1);break;case St.MATCH_CHAR_CLASS:P(i(I[B+1])+".test(input.charAt(peg$currPos))",1);break;case St.ACCEPT_N:z.push(w.push(I[B+1]>1?"input.substr(peg$currPos, "+I[B+1]+")":"input.charAt(peg$currPos)")),z.push(I[B+1]>1?"peg$currPos += "+I[B+1]+";":"peg$currPos++;"),B+=2;break;case St.ACCEPT_STRING:z.push(w.push(n(I[B+1]))),z.push(e.literals[I[B+1]].length>1?"peg$currPos += "+e.literals[I[B+1]].length+";":"peg$currPos++;"),B+=2;break;case St.FAIL:z.push(w.push("peg$FAILED")),z.push("if (peg$silentFails === 0) { peg$fail("+a(I[B+1])+"); }"),B+=2;break;case St.LOAD_SAVED_POS:z.push("peg$savedPos = "+w.index(I[B+1])+";"),B+=2;break;case St.UPDATE_SAVED_POS:z.push("peg$savedPos = peg$currPos;"),B++;break;case St.CALL:H();break;case St.RULE:z.push(w.push(c(e.rules[I[B+1]].name)+"()")),B+=2;break;case St.SILENT_FAILS_ON:z.push("peg$silentFails++;"),B++;break;case St.SILENT_FAILS_OFF:z.push("peg$silentFails--;"),B++;break;default:throw new Error("Invalid opcode: "+I[B]+".")}return z}let _=S(g.bytecode);return y.push(oA(" function ",c(g.name),g.nameLocation,`() { `,g.name)),t.trace&&y.push(" var startPos = peg$currPos;"),y.push(r(w.defines())),y.push(...h('"'+qn(g.name)+'"',QB.indexOfRule(e,g.name)).map(r)),y.push(..._.map(r)),y.push(...v('"'+qn(g.name)+'"',w.result()).map(r)),y.push("}"),y}function p(g){return g.codeLocation?cA(g.code,g.codeLocation,"$"+g.type):g.code}function f(){let g=[];e.topLevelInitializer&&(g.push(p(e.topLevelInitializer)),g.push("")),g.push("function peg$subclass(child, parent) {"," function C() { this.constructor = child; }"," C.prototype = parent.prototype;"," child.prototype = new C();","}","","function peg$SyntaxError(message, expected, found, location) {"," var self = Error.call(this, message);"," // istanbul ignore next Check is a necessary evil to support older environments"," if (Object.setPrototypeOf) {"," Object.setPrototypeOf(self, peg$SyntaxError.prototype);"," }"," self.expected = expected;"," self.found = found;"," self.location = location;",' self.name = "SyntaxError";'," return self;","}","","peg$subclass(peg$SyntaxError, Error);","","function peg$padEnd(str, targetLength, padString) {",' padString = padString || " ";'," if (str.length > targetLength) { return str; }"," targetLength -= str.length;"," padString += padString.repeat(targetLength);"," return str + padString.slice(0, targetLength);","}","","peg$SyntaxError.prototype.format = function(sources) {",' var str = "Error: " + this.message;'," if (this.location) {"," var src = null;"," var k;"," for (k = 0; k < sources.length; k++) {"," if (sources[k].source === this.location.source) {"," src = sources[k].text.split(/\\r\\n|\\n|\\r/g);"," break;"," }"," }"," var s = this.location.start;",' var loc = this.location.source + ":" + s.line + ":" + s.column;'," if (src) {"," var e = this.location.end;",` var filler = peg$padEnd("", s.line.toString().length, ' ');`," var line = src[s.line - 1];"," var last = s.line === e.line ? e.column : line.length + 1;"," var hatLen = (last - s.column) || 1;",' str += "\\n --> " + loc + "\\n"',' + filler + " |\\n"',' + s.line + " | " + line + "\\n"',` + filler + " | " + peg$padEnd("", s.column - 1, ' ')`,' + peg$padEnd("", hatLen, "^");'," } else {",' str += "\\n at " + loc;'," }"," }"," return str;","};","","peg$SyntaxError.buildMessage = function(expected, found) {"," var DESCRIBE_EXPECTATION_FNS = {"," literal: function(expectation) {",' return "\\"" + literalEscape(expectation.text) + "\\"";'," },",""," class: function(expectation) {"," var escapedParts = expectation.parts.map(function(part) {"," return Array.isArray(part)",' ? classEscape(part[0]) + "-" + classEscape(part[1])'," : classEscape(part);"," });","",' return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]";'," },",""," any: function() {",' return "any character";'," },",""," end: function() {",' return "end of input";'," },",""," other: function(expectation) {"," return expectation.description;"," }"," };",""," function hex(ch) {"," return ch.charCodeAt(0).toString(16).toUpperCase();"," }",""," function literalEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/"/g, "\\\\\\"")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function classEscape(s) {"," return s",' .replace(/\\\\/g, "\\\\\\\\")',' .replace(/\\]/g, "\\\\]")',' .replace(/\\^/g, "\\\\^")',' .replace(/-/g, "\\\\-")',' .replace(/\\0/g, "\\\\0")',' .replace(/\\t/g, "\\\\t")',' .replace(/\\n/g, "\\\\n")',' .replace(/\\r/g, "\\\\r")',' .replace(/[\\x00-\\x0F]/g, function(ch) { return "\\\\x0" + hex(ch); })',' .replace(/[\\x10-\\x1F\\x7F-\\x9F]/g, function(ch) { return "\\\\x" + hex(ch); });'," }",""," function describeExpectation(expectation) {"," return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation);"," }",""," function describeExpected(expected) {"," var descriptions = expected.map(describeExpectation);"," var i, j;",""," descriptions.sort();",""," if (descriptions.length > 0) {"," for (i = 1, j = 1; i < descriptions.length; i++) {"," if (descriptions[i - 1] !== descriptions[i]) {"," descriptions[j] = descriptions[i];"," j++;"," }"," }"," descriptions.length = j;"," }",""," switch (descriptions.length) {"," case 1:"," return descriptions[0];",""," case 2:",' return descriptions[0] + " or " + descriptions[1];',""," default:",' return descriptions.slice(0, -1).join(", ")',' + ", or "'," + descriptions[descriptions.length - 1];"," }"," }",""," function describeFound(found) {",' return found ? "\\"" + literalEscape(found) + "\\"" : "end of input";'," }","",' return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found.";',"};",""),t.trace&&g.push("function peg$DefaultTracer() {"," this.indentLevel = 0;","}","","peg$DefaultTracer.prototype.trace = function(event) {"," var that = this;",""," function log(event) {"," function repeat(string, n) {",' var result = "", i;',""," for (i = 0; i < n; i++) {"," result += string;"," }",""," return result;"," }",""," function pad(string, length) {",' return string + repeat(" ", length - string.length);'," }","",' if (typeof console === "object") {'," console.log(",' event.location.start.line + ":" + event.location.start.column + "-"',' + event.location.end.line + ":" + event.location.end.column + " "',' + pad(event.type, 10) + " "',' + repeat(" ", that.indentLevel) + event.rule'," );"," }"," }",""," switch (event.type) {",' case "rule.enter":'," log(event);"," this.indentLevel++;"," break;","",' case "rule.match":'," this.indentLevel--;"," log(event);"," break;","",' case "rule.fail":'," this.indentLevel--;"," log(event);"," break;",""," default:",' throw new Error("Invalid event type: " + event.type + ".");'," }","};","");let y="{ "+t.allowedStartRules.map(S=>S+": "+c(S)).join(", ")+" }",w=c(t.allowedStartRules[0]);return g.push("function peg$parse(input, options) {"," options = options !== undefined ? options : {};",""," var peg$FAILED = {};"," var peg$source = options.grammarSource;",""," var peg$startRuleFunctions = "+y+";"," var peg$startRuleFunction = "+w+";","",l(),""," var peg$currPos = 0;"," var peg$savedPos = 0;"," var peg$posDetailsCache = [{ line: 1, column: 1 }];"," var peg$maxFailPos = 0;"," var peg$maxFailExpected = [];"," var peg$silentFails = 0;",""),t.cache&&g.push(" var peg$resultsCache = {};",""),t.trace&&g.push(' var peg$tracer = "tracer" in options ? options.tracer : new peg$DefaultTracer();',""),g.push(" var peg$result;","",' if ("startRule" in options) {'," if (!(options.startRule in peg$startRuleFunctions)) {",` throw new Error("Can't start parsing from rule \\"" + options.startRule + "\\".");`," }",""," peg$startRuleFunction = peg$startRuleFunctions[options.startRule];"," }",""," function text() {"," return input.substring(peg$savedPos, peg$currPos);"," }",""," function offset() {"," return peg$savedPos;"," }",""," function range() {"," return {"," source: peg$source,"," start: peg$savedPos,"," end: peg$currPos"," };"," }",""," function location() {"," return peg$computeLocation(peg$savedPos, peg$currPos);"," }",""," function expected(description, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildStructuredError("," [peg$otherExpectation(description)],"," input.substring(peg$savedPos, peg$currPos),"," location"," );"," }",""," function error(message, location) {"," location = location !== undefined"," ? location"," : peg$computeLocation(peg$savedPos, peg$currPos);",""," throw peg$buildSimpleError(message, location);"," }",""," function peg$literalExpectation(text, ignoreCase) {",' return { type: "literal", text: text, ignoreCase: ignoreCase };'," }",""," function peg$classExpectation(parts, inverted, ignoreCase) {",' return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase };'," }",""," function peg$anyExpectation() {",' return { type: "any" };'," }",""," function peg$endExpectation() {",' return { type: "end" };'," }",""," function peg$otherExpectation(description) {",' return { type: "other", description: description };'," }",""," function peg$computePosDetails(pos) {"," var details = peg$posDetailsCache[pos];"," var p;",""," if (details) {"," return details;"," } else {"," p = pos - 1;"," while (!peg$posDetailsCache[p]) {"," p--;"," }",""," details = peg$posDetailsCache[p];"," details = {"," line: details.line,"," column: details.column"," };",""," while (p < pos) {"," if (input.charCodeAt(p) === 10) {"," details.line++;"," details.column = 1;"," } else {"," details.column++;"," }",""," p++;"," }",""," peg$posDetailsCache[pos] = details;",""," return details;"," }"," }",""," function peg$computeLocation(startPos, endPos) {"," var startPosDetails = peg$computePosDetails(startPos);"," var endPosDetails = peg$computePosDetails(endPos);",""," return {"," source: peg$source,"," start: {"," offset: startPos,"," line: startPosDetails.line,"," column: startPosDetails.column"," },"," end: {"," offset: endPos,"," line: endPosDetails.line,"," column: endPosDetails.column"," }"," };"," }",""," function peg$fail(expected) {"," if (peg$currPos < peg$maxFailPos) { return; }",""," if (peg$currPos > peg$maxFailPos) {"," peg$maxFailPos = peg$currPos;"," peg$maxFailExpected = [];"," }",""," peg$maxFailExpected.push(expected);"," }",""," function peg$buildSimpleError(message, location) {"," return new peg$SyntaxError(message, null, null, location);"," }",""," function peg$buildStructuredError(expected, found, location) {"," return new peg$SyntaxError("," peg$SyntaxError.buildMessage(expected, found),"," expected,"," found,"," location"," );"," }",""),e.rules.forEach(S=>{g.push(...E(S).map(r)),g.push("")}),e.initializer&&(g.push(p(e.initializer)),g.push("")),g.push(" peg$result = peg$startRuleFunction();",""," if (peg$result !== peg$FAILED && peg$currPos === input.length) {"," return peg$result;"," } else {"," if (peg$result !== peg$FAILED && peg$currPos < input.length) {"," peg$fail(peg$endExpectation());"," }",""," throw peg$buildStructuredError("," peg$maxFailExpected,"," peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null,"," peg$maxFailPos < input.length"," ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1)"," : peg$computeLocation(peg$maxFailPos, peg$maxFailPos)"," );"," }","}"),new ci(null,null,t.grammarSource,g.map(S=>S instanceof ci?S:S+` `))}function A(g){function y(){return[`// Generated by Peggy ${t7}.`,"//","// https://peggyjs.org/"]}function w(){return t.trace?["{"," SyntaxError: peg$SyntaxError,"," DefaultTracer: peg$DefaultTracer,"," parse: peg$parse","}"].join(` `):["{"," SyntaxError: peg$SyntaxError,"," parse: peg$parse","}"].join(` `)}let _={bare(){return[...y(),"(function() {",' "use strict";',"",g,"",r("return "+w()+";"),"})()"]},commonjs(){let I=Object.keys(t.dependencies),B=y();return B.push("",'"use strict";',""),I.length>0&&(I.forEach(q=>{B.push("var "+q+' = require("'+qn(t.dependencies[q])+'");')}),B.push("")),B.push(g,"","module.exports = "+w()+";"),B},es(){let I=Object.keys(t.dependencies),B=y();return B.push(""),I.length>0&&(I.forEach(q=>{B.push("import "+q+' from "'+qn(t.dependencies[q])+'";')}),B.push("")),B.push(g,"","export {"," peg$SyntaxError as SyntaxError,",t.trace?" peg$DefaultTracer as DefaultTracer,":""," peg$parse as parse","};"),B},amd(){let I=Object.keys(t.dependencies),q="["+I.map(F=>t.dependencies[F]).map(F=>'"'+qn(F)+'"').join(", ")+"]",z=I.join(", ");return[...y(),"define("+q+", function("+z+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"]},globals(){return[...y(),"(function(root) {",' "use strict";',"",g,"",r("root."+t.exportVar+" = "+w()+";"),"})(this);"]},umd(){let I=Object.keys(t.dependencies),B=I.map(L=>t.dependencies[L]),q="["+B.map(L=>'"'+qn(L)+'"').join(", ")+"]",z=B.map(L=>'require("'+qn(L)+'")').join(", "),F=I.join(", "),P=y();return P.push("(function(root, factory) {",' if (typeof define === "function" && define.amd) {'," define("+q+", factory);",' } else if (typeof module === "object" && module.exports) {'," module.exports = factory("+z+");"),t.exportVar!==null&&P.push(" } else {"," root."+t.exportVar+" = factory();"),P.push(" }","})(this, function("+F+") {",' "use strict";',"",g,"",r("return "+w()+";"),"});"),P}}[t.format]();return new ci(null,null,t.grammarSource,_.map(I=>I instanceof ci?I:I+` `))}e.code=A(f())}lA.exports=r7});var pA=Ce((OO,hA)=>{"use strict";var n7=ha(),i7=oi();function s7(e,t,r){function n(s){return s.type==="rule"&&s.expression.type==="rule_ref"}function i(s,c,l){i7.build({rule_ref(v){v.name===c&&(v.name=l,r.info(`Proxy rule "${c}" replaced by the rule "${l}"`,v.location,[{message:"This rule will be used",location:n7.findRule(s,l).nameLocation}]))}})(s)}let a=[];e.rules.forEach((s,c)=>{n(s)&&(i(e,s.name,s.expression.name),t.allowedStartRules.indexOf(s.name)===-1&&a.push(c))}),a.reverse(),a.forEach(s=>{e.rules.splice(s,1)})}hA.exports=s7});var gA=Ce((NO,dA)=>{"use strict";var a7=oi();function u7(e,t,r){function n(s){let c={};return Object.keys(s).forEach(l=>{c[l]=s[l]}),c}function i(s,c){a(s.expression,n(c))}let a=a7.build({rule(s){a(s.expression,{})},choice(s,c){s.alternatives.forEach(l=>{a(l,n(c))})},action:i,labeled(s,c){let l=s.label;l&&Object.prototype.hasOwnProperty.call(c,l)&&r.error(`Label "${s.label}" is already defined`,s.labelLocation,[{message:"Original label location",location:c[l]}]),a(s.expression,c),c[s.label]=s.labelLocation},text:i,simple_and:i,simple_not:i,optional:i,zero_or_more:i,one_or_more:i,group:i});a(e)}dA.exports=u7});var vA=Ce((kO,mA)=>{"use strict";var o7=oi();function c7(e,t,r){let n={};o7.build({rule(a){if(Object.prototype.hasOwnProperty.call(n,a.name)){r.error(`Rule "${a.name}" is already defined`,a.nameLocation,[{message:"Original rule location",location:n[a.name]}]);return}n[a.name]=a.nameLocation}})(e)}mA.exports=c7});var EA=Ce((LO,AA)=>{"use strict";var wA=ha(),l7=oi();function f7(e,t,r){let n=[],i=[],a=l7.build({rule(s){n.push(s.name),a(s.expression),n.pop()},sequence(s){s.elements.every(c=>(a(c),!wA.alwaysConsumesOnSuccess(e,c)))},rule_ref(s){i.push(s);let c=wA.findRule(e,s.name);if(n.indexOf(s.name)!==-1){n.push(s.name),r.error("Possible infinite loop when parsing (left recursion: "+n.join(" -> ")+")",c.nameLocation,i.map((l,h,v)=>({message:h+1!==v.length?`Step ${h+1}: call of the rule "${l.name}" without input consumption`:`Step ${h+1}: call itself without input consumption - left recursion`,location:l.location})));return}c&&a(c),i.pop()}});a(e)}AA.exports=f7});var bA=Ce((UO,SA)=>{"use strict";var yA=ha(),h7=oi();function p7(e,t,r){h7.build({zero_or_more(i){yA.alwaysConsumesOnSuccess(e,i.expression)||r.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",i.location)},one_or_more(i){yA.alwaysConsumesOnSuccess(e,i.expression)||r.error("Possible infinite loop when parsing (repetition used with an expression that may not consume any input)",i.location)}})(e)}SA.exports=p7});var FA=Ce((HO,CA)=>{"use strict";var d7=ha(),g7=oi();function m7(e,t,r){g7.build({rule_ref(i){d7.findRule(e,i.name)||r.error(`Rule "${i.name}" is not defined`,i.location)}})(e)}CA.exports=m7});var IA=Ce((jO,_A)=>{"use strict";var v7=oi();function w7(e,t,r){let n=v7.build({action(i){n(i.expression,i)},labeled(i,a){i.pick&&a&&r.error('"@" cannot be used with an action block',i.labelLocation,[{message:"Action block location",location:a.codeLocation}]),n(i.expression)}});n(e)}_A.exports=w7});var BA=Ce((MO,DA)=>{"use strict";var A7=oh(),P0=class{constructor(t){t=typeof t<"u"?t:{},typeof t.error=="function"&&(this.error=t.error),typeof t.warning=="function"&&(this.warning=t.warning),typeof t.info=="function"&&(this.info=t.info)}error(){}warning(){}info(){}},$0=class{constructor(t){this._callbacks=new P0(t),this._firstError=null,this.errors=0,this.problems=[],this.stage=null}error(...t){++this.errors,this._firstError===null&&(this._firstError=new A7(...t),this._firstError.stage=this.stage,this._firstError.problems=this.problems),this.problems.push(["error",...t]),this._callbacks.error(this.stage,...t)}warning(...t){this.problems.push(["warning",...t]),this._callbacks.warning(this.stage,...t)}info(...t){this.problems.push(["info",...t]),this._callbacks.info(this.stage,...t)}checkErrors(){if(this.errors!==0)throw this._firstError}};DA.exports=$0});var PA=Ce((exports,module)=>{"use strict";var generateBytecode=Nw(),generateJS=fA(),inferenceMatchResult=m0(),removeProxyRules=pA(),reportDuplicateLabels=gA(),reportDuplicateRules=vA(),reportInfiniteRecursion=EA(),reportInfiniteRepetition=bA(),reportUndefinedRules=FA(),reportIncorrectPlucking=IA(),Session=BA(),visitor=oi();function processOptions(e,t){let r={};return Object.keys(e).forEach(n=>{r[n]=e[n]}),Object.keys(t).forEach(n=>{Object.prototype.hasOwnProperty.call(r,n)||(r[n]=t[n])}),r}var compiler={visitor,passes:{check:[reportUndefinedRules,reportDuplicateRules,reportDuplicateLabels,reportInfiniteRecursion,reportInfiniteRepetition,reportIncorrectPlucking],transform:[removeProxyRules,inferenceMatchResult],generate:[generateBytecode,generateJS]},compile(ast,passes,options){if(options=options!==void 0?options:{},options=processOptions(options,{allowedStartRules:[ast.rules[0].name],cache:!1,dependencies:{},exportVar:null,format:"bare",output:"parser",trace:!1}),!Array.isArray(options.allowedStartRules))throw new Error("allowedStartRules must be an array");if(options.allowedStartRules.length===0)throw new Error("Must have at least one start rule");let allRules=ast.rules.map(e=>e.name);for(let e of options.allowedStartRules)if(allRules.indexOf(e)===-1)throw new Error(`Unknown start rule "${e}"`);let session=new Session(options);switch(Object.keys(passes).forEach(e=>{session.stage=e,session.info(`Process stage ${e}`),passes[e].forEach(t=>{session.info(`Process pass ${e}.${t.name}`),t(ast,options,session)}),session.checkErrors()}),options.output){case"parser":return eval(ast.code.toString());case"source":return ast.code.toString();case"source-and-map":return ast.code;default:throw new Error("Invalid output format: "+options.output+".")}}};module.exports=compiler});var RA=Ce((qO,$A)=>{"use strict";var E7={$:"text","&":"simple_and","!":"simple_not"},y7={"?":"optional","*":"zero_or_more","+":"one_or_more"},S7={"&":"semantic_and","!":"semantic_not"};function b7(e,t){function r(){this.constructor=e}r.prototype=t.prototype,e.prototype=new r}function ga(e,t,r,n){var i=Error.call(this,e);return Object.setPrototypeOf&&Object.setPrototypeOf(i,ga.prototype),i.expected=t,i.found=r,i.location=n,i.name="SyntaxError",i}b7(ga,Error);function R0(e,t,r){return r=r||" ",e.length>t?e:(t-=e.length,r+=r.repeat(t),e+r.slice(0,t))}ga.prototype.format=function(e){var t="Error: "+this.message;if(this.location){var r=null,n;for(n=0;n `+a+` `+c+` | `+i.line+" | "+l+` `+c+" | "+R0("",i.column-1," ")+R0("",v,"^")}else t+=` at `+a}return t};ga.buildMessage=function(e,t){var r={literal:function(h){return'"'+i(h.text)+'"'},class:function(h){var v=h.parts.map(function(E){return Array.isArray(E)?a(E[0])+"-"+a(E[1]):a(E)});return"["+(h.inverted?"^":"")+v.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(h){return h.description}};function n(h){return h.charCodeAt(0).toString(16).toUpperCase()}function i(h){return h.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(v){return"\\x0"+n(v)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(v){return"\\x"+n(v)})}function a(h){return h.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(v){return"\\x0"+n(v)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(v){return"\\x"+n(v)})}function s(h){return r[h.type](h)}function c(h){var v=h.map(s),E,p;if(v.sort(),v.length>0){for(E=1,p=1;E0?{type:"choice",alternatives:[b].concat(N),location:Ht()}:b},Gn=function(b,N){return N!==null?{type:"action",expression:b,code:N[0],codeLocation:N[1],location:Ht()}:b},Pa=function(b,N){return N.length>0||b.type==="labeled"&&b.pick?{type:"sequence",elements:[b].concat(N),location:Ht()}:b},vh=function(b,N,W){return W.type.startsWith("semantic_")&&nc('"@" cannot be used on a semantic predicate',b),{type:"labeled",label:N!==null?N[0]:null,labelLocation:N!==null?N[1]:b,pick:!0,expression:W,location:Ht()}},wh=function(b,N){return{type:"labeled",label:b[0],labelLocation:b[1],expression:N,location:Ht()}},Rt=function(){return Ht()},Bt=function(b){return ju.indexOf(b[0])>=0&&nc(`Label can't be a reserved word "${b[0]}"`,b[1]),b},Ah=function(b,N){return{type:E7[b],expression:N,location:Ht()}},Eh=function(b,N){return{type:y7[N],expression:b,location:Ht()}},yh=function(b){return b.type==="labeled"||b.type==="sequence"?{type:"group",expression:b,location:Ht()}:b},Sh=function(b){return{type:"rule_ref",name:b[0],location:Ht()}},bh=function(b,N){return{type:S7[b],code:N[0],codeLocation:N[1],location:Ht()}},Ch=function(b,N){return[b+N.join(""),Ht()]},rl=function(b,N){return{type:"literal",value:b,ignoreCase:N!==null,location:Ht()}},Fh=function(b){return b.join("")},ir=function(b){return b.join("")},ec=function(b,N,W){return{type:"class",parts:N.filter(M=>M!==""),inverted:b!==null,ignoreCase:W!==null,location:Ht()}},Zi=function(b,N){return b.charCodeAt(0)>N.charCodeAt(0)&&nc("Invalid character range: "+rc()+"."),[b,N]},nl=function(){return""},tc=function(){return"\0"},un=function(){return"\b"},il=function(){return"\f"},sl=function(){return` `},al=function(){return"\r"},ul=function(){return" "},ol=function(){return"\v"},cl=function(b){return String.fromCharCode(parseInt(b,16))},Xr=function(b){return String.fromCharCode(parseInt(b,16))},_h=function(){return{type:"any",location:Ht()}},on=function(b){return[b,Ht()]},D=0,Ye=0,Fn=[{line:1,column:1}],Jr=0,$a=[],te=0,_n;if("startRule"in t){if(!(t.startRule in i))throw new Error(`Can't start parsing from rule "`+t.startRule+'".');a=i[t.startRule]}function rc(){return e.substring(Ye,D)}function q0(){return Ye}function ll(){return{source:n,start:Ye,end:D}}function Ht(){return Qi(Ye,D)}function K0(b,N){throw N=N!==void 0?N:Qi(Ye,D),hl([zn(b)],e.substring(Ye,D),N)}function nc(b,N){throw N=N!==void 0?N:Qi(Ye,D),fl(b,N)}function Le(b,N){return{type:"literal",text:b,ignoreCase:N}}function sr(b,N,W){return{type:"class",parts:b,inverted:N,ignoreCase:W}}function Vs(){return{type:"any"}}function Ih(){return{type:"end"}}function zn(b){return{type:"other",description:b}}function ic(b){var N=Fn[b],W;if(N)return N;for(W=b-1;!Fn[W];)W--;for(N=Fn[W],N={line:N.line,column:N.column};WJr&&(Jr=D,$a=[]),$a.push(b))}function fl(b,N){return new ga(b,null,null,N)}function hl(b,N,W){return new ga(ga.buildMessage(b,N),b,N,W)}function Bu(){var b,N,W,M,se,oe,Dt,Yt;if(b=D,N=At(),W=D,M=sc(),M!==r?(se=At(),W=M):(D=W,W=r),W===r&&(W=null),M=D,se=Dh(),se!==r?(oe=At(),M=se):(D=M,M=r),M===r&&(M=null),se=[],oe=D,Dt=ac(),Dt!==r?(Yt=At(),oe=Dt):(D=oe,oe=r),oe!==r)for(;oe!==r;)se.push(oe),oe=D,Dt=ac(),Dt!==r?(Yt=At(),oe=Dt):(D=oe,oe=r);else se=r;return se!==r?(Ye=b,b=Cn(W,M,se)):(D=b,b=r),b}function sc(){var b,N,W,M,se;return b=D,e.charCodeAt(D)===123?(N=s,D++):(N=r,te===0&&pe(Ei)),N!==r?(W=ft(),W!==r?(e.charCodeAt(D)===125?(M=c,D++):(M=r,te===0&&pe(Ji)),M!==r?(se=ns(),se!==r?(Ye=b,b=qs(W)):(D=b,b=r)):(D=b,b=r)):(D=b,b=r)):(D=b,b=r),b}function Dh(){var b,N,W;return b=D,N=ft(),N!==r?(W=ns(),W!==r?(Ye=b,b=Wr(N)):(D=b,b=r)):(D=b,b=r),b}function ac(){var b,N,W,M,se,oe,Dt,Yt;return b=D,N=Ru(),N!==r?(W=At(),M=D,se=Yn(),se!==r?(oe=At(),M=se):(D=M,M=r),M===r&&(M=null),e.charCodeAt(D)===61?(se=l,D++):(se=r,te===0&&pe(pu)),se!==r?(oe=At(),Dt=kr(),Dt!==r?(Yt=ns(),Yt!==r?(Ye=b,b=Dr(N,M,Dt)):(D=b,b=r)):(D=b,b=r)):(D=b,b=r)):(D=b,b=r),b}function kr(){var b,N,W,M,se,oe,Dt,Yt;if(b=D,N=Ra(),N!==r){for(W=[],M=D,se=At(),e.charCodeAt(D)===47?(oe=h,D++):(oe=r,te===0&&pe(du)),oe!==r?(Dt=At(),Yt=Ra(),Yt!==r?M=Yt:(D=M,M=r)):(D=M,M=r);M!==r;)W.push(M),M=D,se=At(),e.charCodeAt(D)===47?(oe=h,D++):(oe=r,te===0&&pe(du)),oe!==r?(Dt=At(),Yt=Ra(),Yt!==r?M=Yt:(D=M,M=r)):(D=M,M=r);Ye=b,b=Ks(N,W)}else D=b,b=r;return b}function Ra(){var b,N,W,M,se;return b=D,N=Ta(),N!==r?(W=D,M=At(),se=ft(),se!==r?W=se:(D=W,W=r),W===r&&(W=null),Ye=b,b=Gn(N,W)):(D=b,b=r),b}function Ta(){var b,N,W,M,se,oe;if(b=D,N=Pu(),N!==r){for(W=[],M=D,se=At(),oe=Pu(),oe!==r?M=oe:(D=M,M=r);M!==r;)W.push(M),M=D,se=At(),oe=Pu(),oe!==r?M=oe:(D=M,M=r);Ye=b,b=Pa(N,W)}else D=b,b=r;return b}function Pu(){var b,N,W,M;return b=D,N=pl(),N!==r?(W=dl(),W===r&&(W=null),M=uc(),M!==r?(Ye=b,b=vh(N,W,M)):(D=b,b=r)):(D=b,b=r),b===r&&(b=D,N=dl(),N!==r?(W=At(),M=uc(),M!==r?(Ye=b,b=wh(N,M)):(D=b,b=r)):(D=b,b=r),b===r&&(b=uc())),b}function pl(){var b,N;return b=D,e.charCodeAt(D)===64?(N=v,D++):(N=r,te===0&&pe(gu)),N!==r&&(Ye=b,N=Rt()),b=N,b}function dl(){var b,N,W,M;return b=D,N=Ru(),N!==r?(W=At(),e.charCodeAt(D)===58?(M=E,D++):(M=r,te===0&&pe(mu)),M!==r?(Ye=b,b=Bt(N)):(D=b,b=r)):(D=b,b=r),b}function uc(){var b,N,W,M;return b=D,N=Bh(),N!==r?(W=At(),M=gl(),M!==r?(Ye=b,b=Ah(N,M)):(D=b,b=r)):(D=b,b=r),b===r&&(b=gl()),b}function Bh(){var b;return e.charCodeAt(D)===36?(b=p,D++):(b=r,te===0&&pe(vu)),b===r&&(e.charCodeAt(D)===38?(b=f,D++):(b=r,te===0&&pe(wu)),b===r&&(e.charCodeAt(D)===33?(b=A,D++):(b=r,te===0&&pe(Au)))),b}function gl(){var b,N,W,M;return b=D,N=es(),N!==r?(W=At(),M=Ph(),M!==r?(Ye=b,b=Eh(N,M)):(D=b,b=r)):(D=b,b=r),b===r&&(b=es()),b}function Ph(){var b;return e.charCodeAt(D)===63?(b=g,D++):(b=r,te===0&&pe(Ro)),b===r&&(e.charCodeAt(D)===42?(b=y,D++):(b=r,te===0&&pe(Eu)),b===r&&(e.charCodeAt(D)===43?(b=w,D++):(b=r,te===0&&pe(To)))),b}function es(){var b,N,W,M,se,oe;return b=Nh(),b===r&&(b=ue(),b===r&&(b=Ou(),b===r&&(b=$h(),b===r&&(b=Rh(),b===r&&(b=D,e.charCodeAt(D)===40?(N=S,D++):(N=r,te===0&&pe(xo)),N!==r?(W=At(),M=kr(),M!==r?(se=At(),e.charCodeAt(D)===41?(oe=_,D++):(oe=r,te===0&&pe(Oo)),oe!==r?(Ye=b,b=yh(M)):(D=b,b=r)):(D=b,b=r)):(D=b,b=r)))))),b}function $h(){var b,N,W,M,se,oe,Dt,Yt;return b=D,N=Ru(),N!==r?(W=D,te++,M=D,se=At(),oe=D,Dt=Yn(),Dt!==r?(Yt=At(),Dt=[Dt,Yt],oe=Dt):(D=oe,oe=r),oe===r&&(oe=null),e.charCodeAt(D)===61?(Dt=l,D++):(Dt=r,te===0&&pe(pu)),Dt!==r?(se=[se,oe,Dt],M=se):(D=M,M=r),te--,M===r?W=void 0:(D=W,W=r),W!==r?(Ye=b,b=Sh(N)):(D=b,b=r)):(D=b,b=r),b}function Rh(){var b,N,W,M;return b=D,N=oc(),N!==r?(W=At(),M=ft(),M!==r?(Ye=b,b=bh(N,M)):(D=b,b=r)):(D=b,b=r),b}function oc(){var b;return e.charCodeAt(D)===38?(b=f,D++):(b=r,te===0&&pe(wu)),b===r&&(e.charCodeAt(D)===33?(b=A,D++):(b=r,te===0&&pe(Au))),b}function Br(){var b;return e.length>D?(b=e.charAt(D),D++):(b=r,te===0&&pe(Hs)),b}function In(){var b,N;return te++,e.charCodeAt(D)===9?(b=I,D++):(b=r,te===0&&pe(Sa)),b===r&&(e.charCodeAt(D)===11?(b=B,D++):(b=r,te===0&&pe(ko)),b===r&&(e.charCodeAt(D)===12?(b=q,D++):(b=r,te===0&&pe(Lo)),b===r&&(e.charCodeAt(D)===32?(b=z,D++):(b=r,te===0&&pe(Uo)),b===r&&(e.charCodeAt(D)===160?(b=F,D++):(b=r,te===0&&pe(Ho)),b===r&&(e.charCodeAt(D)===65279?(b=P,D++):(b=r,te===0&&pe(jo)),b===r&&(b=Sl())))))),te--,b===r&&(N=r,te===0&&pe(No)),b}function Dn(){var b;return rr.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(Mo)),b}function $u(){var b,N;return te++,e.charCodeAt(D)===10?(b=L,D++):(b=r,te===0&&pe(Ko)),b===r&&(e.substr(D,2)===H?(b=H,D+=2):(b=r,te===0&&pe(yi)),b===r&&(e.charCodeAt(D)===13?(b=K,D++):(b=r,te===0&&pe(yu)),b===r&&(e.charCodeAt(D)===8232?(b=Z,D++):(b=r,te===0&&pe(Vo)),b===r&&(e.charCodeAt(D)===8233?(b=G,D++):(b=r,te===0&&pe(Go)))))),te--,b===r&&(N=r,te===0&&pe(qo)),b}function ml(){var b,N;return te++,b=Th(),b===r&&(b=cn()),te--,b===r&&(N=r,te===0&&pe(zo)),b}function Th(){var b,N,W,M,se,oe;if(b=D,e.substr(D,2)===V?(N=V,D+=2):(N=r,te===0&&pe(Su)),N!==r){for(W=[],M=D,se=D,te++,e.substr(D,2)===X?(oe=X,D+=2):(oe=r,te===0&&pe(Si)),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);M!==r;)W.push(M),M=D,se=D,te++,e.substr(D,2)===X?(oe=X,D+=2):(oe=r,te===0&&pe(Si)),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);e.substr(D,2)===X?(M=X,D+=2):(M=r,te===0&&pe(Si)),M!==r?(N=[N,W,M],b=N):(D=b,b=r)}else D=b,b=r;return b}function ts(){var b,N,W,M,se,oe;if(b=D,e.substr(D,2)===V?(N=V,D+=2):(N=r,te===0&&pe(Su)),N!==r){for(W=[],M=D,se=D,te++,e.substr(D,2)===X?(oe=X,D+=2):(oe=r,te===0&&pe(Si)),oe===r&&(oe=Dn()),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);M!==r;)W.push(M),M=D,se=D,te++,e.substr(D,2)===X?(oe=X,D+=2):(oe=r,te===0&&pe(Si)),oe===r&&(oe=Dn()),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);e.substr(D,2)===X?(M=X,D+=2):(M=r,te===0&&pe(Si)),M!==r?(N=[N,W,M],b=N):(D=b,b=r)}else D=b,b=r;return b}function cn(){var b,N,W,M,se,oe;if(b=D,e.substr(D,2)===ie?(N=ie,D+=2):(N=r,te===0&&pe(an)),N!==r){for(W=[],M=D,se=D,te++,oe=Dn(),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);M!==r;)W.push(M),M=D,se=D,te++,oe=Dn(),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);N=[N,W],b=N}else D=b,b=r;return b}function Ru(){var b,N,W,M;if(te++,b=D,N=vl(),N!==r){for(W=[],M=wl();M!==r;)W.push(M),M=wl();Ye=b,b=Ch(N,W)}else D=b,b=r;return te--,b===r&&(N=r,te===0&&pe(Yo)),b}function vl(){var b,N,W;return b=xh(),b===r&&(e.charCodeAt(D)===36?(b=p,D++):(b=r,te===0&&pe(vu)),b===r&&(e.charCodeAt(D)===95?(b=Se,D++):(b=r,te===0&&pe(js)),b===r&&(b=D,e.charCodeAt(D)===92?(N=Ee,D++):(N=r,te===0&&pe(bn)),N!==r?(W=Al(),W!==r?b=W:(D=b,b=r)):(D=b,b=r)))),b}function wl(){var b;return b=vl(),b===r&&(b=Oh(),b===r&&(b=El(),b===r&&(b=yl(),b===r&&(e.charCodeAt(D)===8204?(b=Pe,D++):(b=r,te===0&&pe(Wo)),b===r&&(e.charCodeAt(D)===8205?(b=qe,D++):(b=r,te===0&&pe(Xo))))))),b}function xh(){var b;return b=Lu(),b===r&&(b=ku(),b===r&&(b=jh(),b===r&&(b=Uh(),b===r&&(b=Hh(),b===r&&(b=Hu()))))),b}function Oh(){var b;return b=Uu(),b===r&&(b=Fi()),b}function Nh(){var b,N,W;return te++,b=D,N=Yn(),N!==r?(e.charCodeAt(D)===105?(W=ce,D++):(W=r,te===0&&pe(ba)),W===r&&(W=null),Ye=b,b=rl(N,W)):(D=b,b=r),te--,b===r&&(N=r,te===0&&pe(bu)),b}function Yn(){var b,N,W,M;if(te++,b=D,e.charCodeAt(D)===34?(N=_e,D++):(N=r,te===0&&pe(Ms)),N!==r){for(W=[],M=re();M!==r;)W.push(M),M=re();e.charCodeAt(D)===34?(M=_e,D++):(M=r,te===0&&pe(Ms)),M!==r?(Ye=b,b=Fh(W)):(D=b,b=r)}else D=b,b=r;if(b===r)if(b=D,e.charCodeAt(D)===39?(N=ke,D++):(N=r,te===0&&pe(Gt)),N!==r){for(W=[],M=le();M!==r;)W.push(M),M=le();e.charCodeAt(D)===39?(M=ke,D++):(M=r,te===0&&pe(Gt)),M!==r?(Ye=b,b=ir(W)):(D=b,b=r)}else D=b,b=r;return te--,b===r&&(N=r,te===0&&pe(Cu)),b}function re(){var b,N,W,M;return b=D,N=D,W=D,te++,e.charCodeAt(D)===34?(M=_e,D++):(M=r,te===0&&pe(Ms)),M===r&&(e.charCodeAt(D)===92?(M=Ee,D++):(M=r,te===0&&pe(bn)),M===r&&(M=Dn())),te--,M===r?W=void 0:(D=W,W=r),W!==r?(M=Br(),M!==r?(W=[W,M],N=W):(D=N,N=r)):(D=N,N=r),N!==r?b=e.substring(b,D):b=N,b===r&&(b=D,e.charCodeAt(D)===92?(N=Ee,D++):(N=r,te===0&&pe(bn)),N!==r?(W=jt(),W!==r?b=W:(D=b,b=r)):(D=b,b=r),b===r&&(b=ot())),b}function le(){var b,N,W,M;return b=D,N=D,W=D,te++,e.charCodeAt(D)===39?(M=ke,D++):(M=r,te===0&&pe(Gt)),M===r&&(e.charCodeAt(D)===92?(M=Ee,D++):(M=r,te===0&&pe(bn)),M===r&&(M=Dn())),te--,M===r?W=void 0:(D=W,W=r),W!==r?(M=Br(),M!==r?(W=[W,M],N=W):(D=N,N=r)):(D=N,N=r),N!==r?b=e.substring(b,D):b=N,b===r&&(b=D,e.charCodeAt(D)===92?(N=Ee,D++):(N=r,te===0&&pe(bn)),N!==r?(W=jt(),W!==r?b=W:(D=b,b=r)):(D=b,b=r),b===r&&(b=ot())),b}function ue(){var b,N,W,M,se,oe;if(te++,b=D,e.charCodeAt(D)===91?(N=mr,D++):(N=r,te===0&&pe(Zo)),N!==r){for(e.charCodeAt(D)===94?(W=xt,D++):(W=r,te===0&&pe(Fu)),W===r&&(W=null),M=[],se=Re(),se===r&&(se=Ge());se!==r;)M.push(se),se=Re(),se===r&&(se=Ge());e.charCodeAt(D)===93?(se=ht,D++):(se=r,te===0&&pe(bi)),se!==r?(e.charCodeAt(D)===105?(oe=ce,D++):(oe=r,te===0&&pe(ba)),oe===r&&(oe=null),Ye=b,b=ec(W,M,oe)):(D=b,b=r)}else D=b,b=r;return te--,b===r&&(N=r,te===0&&pe(Jo)),b}function Re(){var b,N,W,M;return b=D,N=Ge(),N!==r?(e.charCodeAt(D)===45?(W=Zt,D++):(W=r,te===0&&pe(wr)),W!==r?(M=Ge(),M!==r?(Ye=b,b=Zi(N,M)):(D=b,b=r)):(D=b,b=r)):(D=b,b=r),b}function Ge(){var b,N,W,M;return b=D,N=D,W=D,te++,e.charCodeAt(D)===93?(M=ht,D++):(M=r,te===0&&pe(bi)),M===r&&(e.charCodeAt(D)===92?(M=Ee,D++):(M=r,te===0&&pe(bn)),M===r&&(M=Dn())),te--,M===r?W=void 0:(D=W,W=r),W!==r?(M=Br(),M!==r?(W=[W,M],N=W):(D=N,N=r)):(D=N,N=r),N!==r?b=e.substring(b,D):b=N,b===r&&(b=D,e.charCodeAt(D)===92?(N=Ee,D++):(N=r,te===0&&pe(bn)),N!==r?(W=jt(),W!==r?b=W:(D=b,b=r)):(D=b,b=r),b===r&&(b=ot())),b}function ot(){var b,N,W;return b=D,e.charCodeAt(D)===92?(N=Ee,D++):(N=r,te===0&&pe(bn)),N!==r?(W=$u(),W!==r?(Ye=b,b=nl()):(D=b,b=r)):(D=b,b=r),b}function jt(){var b,N,W,M;return b=It(),b===r&&(b=D,e.charCodeAt(D)===48?(N=Ut,D++):(N=r,te===0&&pe(kt)),N!==r?(W=D,te++,M=rs(),te--,M===r?W=void 0:(D=W,W=r),W!==r?(Ye=b,b=tc()):(D=b,b=r)):(D=b,b=r),b===r&&(b=xu(),b===r&&(b=Al()))),b}function It(){var b;return b=Tu(),b===r&&(b=kh()),b}function Tu(){var b,N;return e.charCodeAt(D)===39?(b=ke,D++):(b=r,te===0&&pe(Gt)),b===r&&(e.charCodeAt(D)===34?(b=_e,D++):(b=r,te===0&&pe(Ms)),b===r&&(e.charCodeAt(D)===92?(b=Ee,D++):(b=r,te===0&&pe(bn)),b===r&&(b=D,e.charCodeAt(D)===98?(N=rt,D++):(N=r,te===0&&pe(Qo)),N!==r&&(Ye=b,N=un()),b=N,b===r&&(b=D,e.charCodeAt(D)===102?(N=$t,D++):(N=r,te===0&&pe(Ca)),N!==r&&(Ye=b,N=il()),b=N,b===r&&(b=D,e.charCodeAt(D)===110?(N=et,D++):(N=r,te===0&&pe(Ar)),N!==r&&(Ye=b,N=sl()),b=N,b===r&&(b=D,e.charCodeAt(D)===114?(N=vt,D++):(N=r,te===0&&pe(Fa)),N!==r&&(Ye=b,N=al()),b=N,b===r&&(b=D,e.charCodeAt(D)===116?(N=Qt,D++):(N=r,te===0&&pe(_u)),N!==r&&(Ye=b,N=ul()),b=N,b===r&&(b=D,e.charCodeAt(D)===118?(N=Xe,D++):(N=r,te===0&&pe(Iu)),N!==r&&(Ye=b,N=ol()),b=N)))))))),b}function kh(){var b,N,W,M;return b=D,N=D,W=D,te++,M=ln(),M===r&&(M=Dn()),te--,M===r?W=void 0:(D=W,W=r),W!==r?(M=Br(),M!==r?(W=[W,M],N=W):(D=N,N=r)):(D=N,N=r),N!==r?b=e.substring(b,D):b=N,b}function ln(){var b;return b=Tu(),b===r&&(b=rs(),b===r&&(e.charCodeAt(D)===120?(b=Vt,D++):(b=r,te===0&&pe(_a)),b===r&&(e.charCodeAt(D)===117?(b=Vn,D++):(b=r,te===0&&pe(Ci))))),b}function xu(){var b,N,W,M,se,oe;return b=D,e.charCodeAt(D)===120?(N=Vt,D++):(N=r,te===0&&pe(_a)),N!==r?(W=D,M=D,se=li(),se!==r?(oe=li(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r),M!==r?W=e.substring(W,D):W=M,W!==r?(Ye=b,b=cl(W)):(D=b,b=r)):(D=b,b=r),b}function Al(){var b,N,W,M,se,oe,Dt,Yt;return b=D,e.charCodeAt(D)===117?(N=Vn,D++):(N=r,te===0&&pe(Ci)),N!==r?(W=D,M=D,se=li(),se!==r?(oe=li(),oe!==r?(Dt=li(),Dt!==r?(Yt=li(),Yt!==r?(se=[se,oe,Dt,Yt],M=se):(D=M,M=r)):(D=M,M=r)):(D=M,M=r)):(D=M,M=r),M!==r?W=e.substring(W,D):W=M,W!==r?(Ye=b,b=Xr(W)):(D=b,b=r)):(D=b,b=r),b}function rs(){var b;return Or.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(Ia)),b}function li(){var b;return ma.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(Du)),b}function Ou(){var b,N;return b=D,e.charCodeAt(D)===46?(N=vr,D++):(N=r,te===0&&pe(Da)),N!==r&&(Ye=b,N=_h()),b=N,b}function ft(){var b,N,W,M;return te++,b=D,e.charCodeAt(D)===123?(N=s,D++):(N=r,te===0&&pe(Ei)),N!==r?(W=Lh(),e.charCodeAt(D)===125?(M=c,D++):(M=r,te===0&&pe(Ji)),M!==r?b=W:(D=b,b=r)):(D=b,b=r),te--,b===r&&(N=r,te===0&&pe(Ba)),b}function Lh(){var b,N;return b=D,N=Nu(),Ye=b,N=on(N),b=N,b}function Nu(){var b,N,W,M,se,oe;if(b=D,N=[],W=[],M=D,se=D,te++,zr.test(e.charAt(D))?(oe=e.charAt(D),D++):(oe=r,te===0&&pe(Yr)),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r),M!==r)for(;M!==r;)W.push(M),M=D,se=D,te++,zr.test(e.charAt(D))?(oe=e.charAt(D),D++):(oe=r,te===0&&pe(Yr)),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);else W=r;for(W===r&&(W=D,e.charCodeAt(D)===123?(M=s,D++):(M=r,te===0&&pe(Ei)),M!==r?(se=Nu(),e.charCodeAt(D)===125?(oe=c,D++):(oe=r,te===0&&pe(Ji)),oe!==r?(M=[M,se,oe],W=M):(D=W,W=r)):(D=W,W=r));W!==r;){if(N.push(W),W=[],M=D,se=D,te++,zr.test(e.charAt(D))?(oe=e.charAt(D),D++):(oe=r,te===0&&pe(Yr)),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r),M!==r)for(;M!==r;)W.push(M),M=D,se=D,te++,zr.test(e.charAt(D))?(oe=e.charAt(D),D++):(oe=r,te===0&&pe(Yr)),te--,oe===r?se=void 0:(D=se,se=r),se!==r?(oe=Br(),oe!==r?(se=[se,oe],M=se):(D=M,M=r)):(D=M,M=r);else W=r;W===r&&(W=D,e.charCodeAt(D)===123?(M=s,D++):(M=r,te===0&&pe(Ei)),M!==r?(se=Nu(),e.charCodeAt(D)===125?(oe=c,D++):(oe=r,te===0&&pe(Ji)),oe!==r?(M=[M,se,oe],W=M):(D=W,W=r)):(D=W,W=r))}return b=e.substring(b,D),b}function ku(){var b;return wt.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(R)),b}function Uh(){var b;return nr.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(x)),b}function Hh(){var b;return Je.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(j)),b}function jh(){var b;return Nr.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(Q)),b}function Lu(){var b;return va.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(de)),b}function Fi(){var b;return wa.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(ve)),b}function Uu(){var b;return Aa.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(Fe)),b}function El(){var b;return Ea.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe($e)),b}function Hu(){var b;return Xi.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(_t)),b}function yl(){var b;return ya.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(zt)),b}function Sl(){var b;return Us.test(e.charAt(D))?(b=e.charAt(D),D++):(b=r,te===0&&pe(_r)),b}function At(){var b,N;for(b=[],N=In(),N===r&&(N=$u(),N===r&&(N=ml()));N!==r;)b.push(N),N=In(),N===r&&(N=$u(),N===r&&(N=ml()));return b}function bl(){var b,N;for(b=[],N=In(),N===r&&(N=ts());N!==r;)b.push(N),N=In(),N===r&&(N=ts());return b}function ns(){var b,N,W,M;return b=D,N=At(),e.charCodeAt(D)===59?(W=Fr,D++):(W=r,te===0&&pe(Ir)),W!==r?(N=[N,W],b=N):(D=b,b=r),b===r&&(b=D,N=bl(),W=cn(),W===r&&(W=null),M=$u(),M!==r?(N=[N,W,M],b=N):(D=b,b=r),b===r&&(b=D,N=At(),W=is(),W!==r?(N=[N,W],b=N):(D=b,b=r))),b}function is(){var b,N;return b=D,te++,e.length>D?(N=e.charAt(D),D++):(N=r,te===0&&pe(Hs)),te--,N===r?b=void 0:(D=b,b=r),b}let ju=t.reservedWords||[];if(_n=a(),_n!==r&&D===e.length)return _n;throw _n!==r&&D{"use strict";var F7=oh(),_7=PA(),I7=RA(),D7=E0(),B7=["break","case","catch","class","const","continue","debugger","default","delete","do","else","export","extends","finally","for","function","if","import","in","instanceof","new","return","super","switch","this","throw","try","typeof","var","void","while","with","null","true","false","enum","implements","interface","let","package","private","protected","public","static","yield","await"],el={VERSION:D7,RESERVED_WORDS:B7,GrammarError:F7,parser:I7,compiler:_7,generate(e,t){t=t!==void 0?t:{};function r(a){let s={};return Object.keys(a).forEach(c=>{s[c]=a[c].slice()}),s}let n="plugins"in t?t.plugins:[],i={parser:el.parser,passes:r(el.compiler.passes),reservedWords:el.RESERVED_WORDS.slice()};return n.forEach(a=>{a.use(i,t)}),el.compiler.compile(i.parser.parse(e,{grammarSource:t.grammarSource,reservedWords:i.reservedWords}),i.passes,t)}};TA.exports=el});var Wl="2.19.18";var xp="schemaVersion",Et="settings",Lt="subs",Tt="collections",dt="files",gn="modules",Ct="artifacts",Sc="rules",ti="tokens",Bg="Auto Generated Sub-Store Backup",Xl="Sub-Store",Ma="Sub-Store Artifacts Repository",qa="#sub-store-cached-resource",Ka="#sub-store-cached-headers-resource",Jl="#sub-store-chr-expiration-time";var Va="#sub-store-cached-script-resource",Zl="#sub-store-csr-expiration-time";var Js=typeof $task<"u",gs=typeof $loon<"u",Zs=typeof $httpClient<"u"&&!gs,Bi=eval('typeof process !== "undefined"'),Pg=typeof $environment<"u"&&$environment["stash-version"],$g=typeof $rocket<"u",Z5=typeof egern=="object",Q5=typeof $native<"u",Qs=typeof $Plugins<"u",Ql=class{constructor(name="untitled",debug=!1){if(this.name=name,this.debug=debug,this.http=vs(),this.env=$r(),Bi){let dotenv=eval('require("dotenv")');dotenv.config()}this.node=(()=>{if(Bi){let fs=eval("require('fs')");return{fs}}else return null})(),this.initCache();let delay=(e,t)=>new Promise(function(r){setTimeout(r.bind(null,t),e)});Promise.prototype.delay=async function(e){let t=await this;return await delay(e,t)}}initCache(){if(Js&&(this.cache=JSON.parse($prefs.valueForKey(this.name)||"{}")),(gs||Zs)&&(this.cache=JSON.parse($persistentStore.read(this.name)||"{}")),Qs&&(this.cache=JSON.parse($Plugins.SubStoreCache.get(this.name)||"{}")),Bi){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".",rootPath=`${basePath}/root.json`;this.log(`Root path: ${rootPath}`),this.node.fs.existsSync(rootPath)?this.root=JSON.parse(this.node.fs.readFileSync(`${rootPath}`)):(this.node.fs.writeFileSync(rootPath,JSON.stringify({}),{flag:"wx"}),this.root={});let fpath=`${basePath}/${this.name}.json`;this.log(`Data path: ${fpath}`),this.node.fs.existsSync(fpath)?this.cache=JSON.parse(this.node.fs.readFileSync(`${fpath}`)):(this.node.fs.writeFileSync(fpath,JSON.stringify({}),{flag:"wx"}),this.cache={})}}persistCache(){let data=JSON.stringify(this.cache,null,2);if(Js&&$prefs.setValueForKey(data,this.name),(gs||Zs)&&$persistentStore.write(data,this.name),Qs&&$Plugins.SubStoreCache.set(this.name,data),Bi){let basePath=eval("process.env.SUB_STORE_DATA_BASE_PATH")||".";this.node.fs.writeFileSync(`${basePath}/${this.name}.json`,data,{flag:"w"},e=>console.log(e)),this.node.fs.writeFileSync(`${basePath}/root.json`,JSON.stringify(this.root,null,2),{flag:"w"},e=>console.log(e))}}write(e,t){if(this.log(`SET ${t}`),t.indexOf("#")!==-1){if(t=t.substr(1),Zs||gs)return $persistentStore.write(e,t);if(Js)return $prefs.setValueForKey(e,t);if(Bi&&(this.root[t]=e),Qs)return $Plugins.SubStoreCache.set(t,e)}else this.cache[t]=e;this.persistCache()}read(e){if(this.log(`READ ${e}`),e.indexOf("#")!==-1){if(e=e.substr(1),Zs||gs)return $persistentStore.read(e);if(Js)return $prefs.valueForKey(e);if(Bi)return this.root[e];if(Qs)return $Plugins.SubStoreCache.get(e)}else return this.cache[e]}delete(e){if(this.log(`DELETE ${e}`),e.indexOf("#")!==-1){if(e=e.substr(1),Zs||gs)return $persistentStore.write(null,e);if(Js)return $prefs.removeValueForKey(e);if(Bi&&delete this.root[e],Qs)return $Plugins.SubStoreCache.remove(e)}else delete this.cache[e];this.persistCache()}notify(title,subtitle="",content="",options={}){let openURL=options["open-url"],mediaURL=options["media-url"];if(Js&&$notify(title,subtitle,content,options),Zs&&$notification.post(title,subtitle,content+`${mediaURL?` \u591A\u5A92\u4F53:`+mediaURL:""}`,{url:openURL}),gs){let e={};openURL&&(e.openUrl=openURL),mediaURL&&(e.mediaUrl=mediaURL),JSON.stringify(e)==="{}"?$notification.post(title,subtitle,content):$notification.post(title,subtitle,content,e)}if(Bi){let content_=content+(openURL?` \u70B9\u51FB\u8DF3\u8F6C: ${openURL}`:"")+(mediaURL?` \u591A\u5A92\u4F53: ${mediaURL}`:"");console.log(`${title} ${subtitle} ${content_} `);let push=eval("process.env.SUB_STORE_PUSH_SERVICE");if(push){let e=push.replace("[\u63A8\u9001\u6807\u9898]",encodeURIComponent(title||"Sub-Store")).replace("[\u63A8\u9001\u5185\u5BB9]",encodeURIComponent([subtitle,content_].map(r=>r).join(` `)));vs().get({url:e}).then(r=>{console.log(`[Push Service] URL: ${e} RES: ${r.statusCode} ${r.body}`)}).catch(r=>{console.log(`[Push Service] URL: ${e} ERROR: ${r}`)})}}Qs&&$Plugins.Notify(title,subtitle+` `+content)}log(e){this.debug&&console.log(`[${this.name}] LOG: ${e}`)}info(e){console.log(`[${this.name}] INFO: ${e}`)}error(e){console.log(`[${this.name}] ERROR: ${e}`)}wait(e){return new Promise(t=>setTimeout(t,e))}done(e={}){Js||gs||Zs||Qs?$done(e):Bi&&typeof $context<"u"&&($context.headers=e.headers,$context.statusCode=e.statusCode,$context.body=e.body)}};function $r(){return{isQX:Js,isLoon:gs,isSurge:Zs,isNode:Bi,isStash:Pg,isShadowRocket:$g,isEgern:Z5,isLanceX:Q5,isGUIforCores:Qs}}function vs(defaultOptions={baseURL:""}){let{isQX,isLoon,isSurge,isNode,isGUIforCores}=$r(),methods=["GET","POST","PUT","DELETE","HEAD","OPTIONS","PATCH"],URL_REGEX=/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/;function send(method,options){options=typeof options=="string"?{url:options}:options;let baseURL=defaultOptions.baseURL;baseURL&&!URL_REGEX.test(options.url||"")&&(options.url=baseURL?baseURL+options.url:options.url),options={...defaultOptions,...options};let timeout=options.timeout,events={onRequest:()=>{},onResponse:e=>e,onTimeout:()=>{},...options.events};if(events.onRequest(method,options),options.node&&isSurge){let e=$environment["surge-build"];e&&parseInt(e)>=2407&&(options["policy-descriptor"]=options.node,delete options.node)}let worker;isQX?worker=$task.fetch({method,url:options.url,headers:options.headers,body:options.body,opts:options.opts}):isLoon||isSurge||isNode?worker=new Promise(async(resolve,reject)=>{let body=options.body,opts=JSON.parse(JSON.stringify(options));if(opts.body=body,opts.timeout=opts.timeout||8e3,opts.timeout&&(opts.timeout++,isNaN(opts.timeout)&&(opts.timeout=8e3),!isNode)){let e="ms";(isSurge||Pg||$g)&&(opts.timeout=Math.ceil(opts.timeout/1e3),e="s")}if(isNode){let undici=eval("require('undici')"),{ProxyAgent,EnvHttpProxyAgent,request,interceptors}=undici,agentOpts={connect:{rejectUnauthorized:!(opts.strictSSL===!1||opts.insecure===!0)},bodyTimeout:opts.timeout,headersTimeout:opts.timeout};try{let e=new URL(opts.url);(e.username||e.password)&&(opts.headers={...opts.headers||{},Authorization:`Basic ${Buffer.from(`${e.username||""}:${e.password||""}`).toString("base64")}`});let t=await request(opts.url,{...opts,method:method.toUpperCase(),dispatcher:(opts.proxy?new ProxyAgent({...agentOpts,uri:opts.proxy}):new EnvHttpProxyAgent(agentOpts)).compose(interceptors.redirect({maxRedirections:3,throwOnMaxRedirects:!0}))});resolve({statusCode:t.statusCode,headers:t.headers,body:opts.encoding===null?await t.body.arrayBuffer():await t.body.text()})}catch(e){reject(e)}}else $httpClient[method.toLowerCase()](opts,(e,t,r)=>{e?reject(e):resolve({statusCode:t.status||t.statusCode,headers:t.headers,body:r})})}):isGUIforCores&&(worker=new Promise(async(e,t)=>{try{let r=await $Plugins.Requests({method,url:options.url,headers:options.headers,body:options.body,options:{Proxy:options.proxy,Timeout:options.timeout?options.timeout/1e3:15}});e({statusCode:r.status,headers:r.headers,body:r.body})}catch(r){t(r)}}));let timeoutid,timer=timeout?new Promise((e,t)=>{timeoutid=setTimeout(()=>(events.onTimeout(),t(`${method} URL: ${options.url} exceeds the timeout ${timeout} ms`)),timeout)}):null;return(timer?Promise.race([timer,worker]).then(e=>(typeof clearTimeout<"u"&&clearTimeout(timeoutid),e)):worker).then(e=>events.onResponse(e))}let http={};return methods.forEach(e=>http[e.toLowerCase()]=t=>send(e,t)),http}var e3=new Ql("sub-store"),O=e3;function Xu(){t3()}function t3(){let e=O.read(xp);e||r3(),e!=="2.0"&&O.write("2.0",xp)}function r3(){O.info("Start migrating...");let e=O.read(Lt)||{},t=Object.values(e).map(A=>(A.source=A.source||"remote",p(A),f(A),A));O.write(t,Lt);let r=O.read(Tt)||{},n=Object.values(r).map(A=>(delete A.ua,p(A),f(A),A));O.write(n,Tt);let i=O.read(Ct)||{},a=Object.values(i);O.write(a,Ct);let s=O.read(Sc)||{},c=Object.values(s);O.write(c,Sc);let l=O.read(dt)||{},h=Object.values(l);O.write(h,dt);let v=O.read(ti)||{},E=Object.values(v);O.write(E,ti),delete O.cache.builtin,O.info("Migration complete!");function p(A){let g=A["display-name"];g&&(A.displayName=g,delete A["display-name"])}function f(A){let g=A.process;if(!g||g.length===0)return;let y=[],w={type:"Quick Setting Operator",args:{udp:"DEFAULT",tfo:"DEFAULT",scert:"DEFAULT","vmess aead":"DEFAULT",useless:"DEFAULT"}};for(let S of g)if(S.type){if(S.type==="Useless Filter")w.args.useless="ENABLED";else if(S.type==="Set Property Operator"){let{key:_,value:I}=S.args;switch(_){case"udp":w.args.udp=I?"ENABLED":"DISABLED";break;case"tfo":w.args.tfo=I?"ENABLED":"DISABLED";break;case"skip-cert-verify":w.args.scert=I?"ENABLED":"DISABLED";break;case"aead":w.args["vmess aead"]=I?"ENABLED":"DISABLED";break}}else if(S.type.indexOf("Keyword")===-1)if(S.type==="Flag Operator"){let _=typeof S.args>"u"?!0:S.args;S.args={mode:_?"add":"remove"},y.push(S)}else y.push(S)}y.unshift(w),A.process=y}}function Op({substore:$,port,host}){let{isNode}=$r(),DEFAULT_HEADERS={"Content-Type":"text/plain;charset=UTF-8","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST,GET,OPTIONS,PATCH,PUT,DELETE","Access-Control-Allow-Headers":"Origin, X-Requested-With, Content-Type, Accept","X-Powered-By":"Sub-Store"};if(isNode){let express_=eval('require("express")'),bodyParser=eval('require("body-parser")'),app=express_();return app.use(bodyParser.json({verify:rawBodySaver,limit:eval("process.env.SUB_STORE_BODY_JSON_LIMIT")||"1mb"})),app.use(bodyParser.urlencoded({verify:rawBodySaver,extended:!0})),app.use(bodyParser.raw({verify:rawBodySaver,type:"*/*"})),app.use((e,t,r)=>{t.set(DEFAULT_HEADERS),r()}),app.start=()=>{let e=app.listen(port,host,()=>{let{address:t,port:r}=e.address();$.info(`[BACKEND] ${t}:${r}`)})},app}let handlers=[],METHODS_NAMES=["GET","POST","PUT","DELETE","PATCH","OPTIONS","HEAD'","ALL"],dispatch=(e,t=0)=>{let{method:r,url:n,headers:i,body:a}=e;i=n3(i),/json/i.test(i["content-type"])&&(a=JSON.parse(a)),r=r.toUpperCase();let{path:s,query:c}=s3(n),l=null,h,v=0;for(h=t;hv&&(l=handlers[h],v=E.split("/").length)}if(l){let E=()=>{dispatch(r,n,h)},p={method:r,url:n,path:s,query:c,params:Rg(l.pattern,s),headers:i,body:a},f=Response(),A=l.callback,g=y=>{f.status(500).json({status:"failed",message:`Internal Server Error: ${y}`})};if(A.constructor.name==="AsyncFunction")A(p,f,E).catch(g);else try{A(p,f,E)}catch(y){g(y)}}else Response().status(404).json({status:"failed",message:"ERROR: 404 not found"})},app={};return METHODS_NAMES.forEach(e=>{app[e.toLowerCase()]=(t,r)=>{handlers.push({method:e,pattern:t,callback:r})}}),app.route=e=>{let t={};return METHODS_NAMES.forEach(r=>{t[r.toLowerCase()]=n=>(handlers.push({method:r,pattern:e,callback:n}),t)}),t},app.start=()=>{dispatch($request)},app;function rawBodySaver(e,t,r,n){r&&r.length&&(e.rawBody=r.toString(n||"utf8"))}function Response(){let e=200,{isQX:t,isLoon:r,isSurge:n,isGUIforCores:i}=$r(),a=DEFAULT_HEADERS,s={200:"HTTP/1.1 200 OK",201:"HTTP/1.1 201 Created",302:"HTTP/1.1 302 Found",307:"HTTP/1.1 307 Temporary Redirect",308:"HTTP/1.1 308 Permanent Redirect",404:"HTTP/1.1 404 Not Found",500:"HTTP/1.1 500 Internal Server Error"};return new class{status(c){return e=c,this}send(c=""){let l={status:t?s[e]:e,body:c,headers:a};t||i?$done(l):(r||n)&&$done({response:l})}end(){this.send()}html(c){this.set("Content-Type","text/html;charset=UTF-8"),this.send(c)}json(c){this.set("Content-Type","application/json;charset=UTF-8"),this.send(JSON.stringify(c))}set(c,l){return a[c]=l,this}}}}function n3(e){let t={};for(let r of Object.keys(e))t[r.toLowerCase()]=e[r];return t}function i3(e,t){if(e instanceof RegExp&&e.test(t))return!0;if(e==="/")return!0;if(e.indexOf(":")===-1){let r=t.split("/"),n=e.split("/");for(let i=0;in[r]===t)}function Tg(e,t,r="name"){return e.findIndex(n=>n[r]===t)}function ri(e,t,r="name"){let n=Tg(e,t,r);e.splice(n,1)}function di(e,t,r,n="name"){let i=Tg(e,t,n);e[i]=r}function xe(e,t,r){e.status(r||200).json({status:"success",data:t})}function Ue(e,t,r){e.status(r||500).json({status:"failed",error:{code:t.code,type:t.type,message:t.message,details:t.details}})}var Ju=class{constructor(t,r,n){this.code=t,this.message=r,this.details=n}},Rr=class extends Ju{constructor(t,r,n){super(t,r,n),this.type="InternalServerError"}},pt=class extends Ju{constructor(t,r,n){super(t,r,n),this.type="RequestInvalidError"}},lr=class extends Ju{constructor(t,r,n){super(t,r,n),this.type="ResourceNotFoundError"}},ef=class extends Ju{constructor(t,r,n){super(t,r,n),this.type="NetworkError"}};var lf=ei(Gg()),$3=/^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/,R3=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;function fr(e){return $3.test(e)}function hr(e){return R3.test(e)}function zg(e){return/^((6553[0-5])|(655[0-2][0-9])|(65[0-4][0-9]{2})|(6[0-4][0-9]{3})|([1-5][0-9]{4})|([0-5]{0,5})|([0-9]{1,4}))$/.test(e)}function xi(e){return typeof e=="string"&&e.trim().length>0}function qt(e,t){return xi(e)?e:t}function to(e){return typeof e<"u"&&e!==null}function Ya(e,t){return to(e)?e:t}function As(e){return e?/^.+?\s*?=\s*?.+?\s*?,.+?/.test(e)?{"policy-descriptor":e}:{policy:e}:{}}function T3(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function Fc(e){let t=e.split(/,|\//),r=t[Math.floor(Math.random()*t.length)];if(r.includes("-")){let[n,i]=r.split("-").map(Number);return T3(n,i)}else return Number(r)}function Yg(e){return Number.isSafeInteger(e)?String(e):BigInt(e).toString()}function ff(e){return typeof e=="string"&&/^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(e)}function ea(e,t="YYYY-MM-DD_HH-mm-ss"){let r=e instanceof Date?e:new Date(e);if(isNaN(r.getTime()))return"";let n=a=>String(a).padStart(2,"0"),i={YYYY:r.getFullYear(),MM:n(r.getMonth()+1),DD:n(r.getDate()),HH:n(r.getHours()),mm:n(r.getMinutes()),ss:n(r.getSeconds())};return t.replace(/YYYY|MM|DD|HH|mm|ss/g,a=>i[a])}function zp(e){O.read(Tt)||O.write({},Tt),e.route("/api/collection/:name").get(O3).patch(N3).delete(k3),e.route("/api/collections").get(L3).post(x3).put(U3)}function x3(e,t){let r=e.body;if(O.info(`\u6B63\u5728\u521B\u5EFA\u7EC4\u5408\u8BA2\u9605\uFF1A${r.name}`),/\//.test(r.name)){Ue(t,new pt("INVALID_NAME",`Collection ${r.name} is invalid`));return}let n=O.read(Tt);if(gt(n,r.name)){Ue(t,new pt("DUPLICATE_KEY",`Collection ${r.name} already exists.`));return}n.push(r),O.write(n,Tt),xe(t,r,201)}function O3(e,t){let{name:r}=e.params,{raw:n}=e.query;r=decodeURIComponent(r);let i=O.read(Tt),a=gt(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_collection_${r}_${ea(new Date)}.json`)}"`).send(JSON.stringify(a)):xe(t,a):Ue(t,new lr("SUBSCRIPTION_NOT_FOUND",`Collection ${r} does not exist`,404))}function N3(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=O.read(Tt),a=gt(i,r);if(a){let s={...a,...n};if(O.info(`\u6B63\u5728\u66F4\u65B0\u7EC4\u5408\u8BA2\u9605\uFF1A${r}...`),r!==s.name){let c=O.read(Ct)||[];for(let h of c)h.type==="collection"&&h.source===a.name&&(h.source=s.name);let l=O.read(dt)||[];for(let h of l)h.sourceType==="collection"&&h.sourceName===a.name&&(h.sourceName=s.name);O.write(c,Ct),O.write(l,dt)}di(i,r,s),O.write(i,Tt),xe(t,s)}else Ue(t,new lr("RESOURCE_NOT_FOUND",`Collection ${r} does not exist!`),404)}function k3(e,t){let{name:r}=e.params;r=decodeURIComponent(r),O.info(`\u6B63\u5728\u5220\u9664\u7EC4\u5408\u8BA2\u9605\uFF1A${r}`);let n=O.read(Tt);ri(n,r),O.write(n,Tt),xe(t)}function L3(e,t){let r=O.read(Tt);xe(t,r)}function U3(e,t){let r=e.body;O.write(r,Tt),xe(t)}var Yp=0;function Tn(e){return j3(H3(M3(e)))}function H3(e){return K3(V3(q3(e),e.length*8))}function j3(e){try{}catch{Yp=0}for(var t=Yp?"0123456789ABCDEF":"0123456789abcdef",r="",n,i=0;i>>4&15)+t.charAt(n&15);return r}function M3(e){for(var t="",r=-1,n,i;++r>>6&31,128|n&63):n<=65535?t+=String.fromCharCode(224|n>>>12&15,128|n>>>6&63,128|n&63):n<=2097151&&(t+=String.fromCharCode(240|n>>>18&7,128|n>>>12&63,128|n>>>6&63,128|n&63));return t}function q3(e){for(var t=Array(e.length>>2),r=0;r>5]|=(e.charCodeAt(r/8)&255)<>5]>>>r%32&255);return t}function V3(e,t){e[t>>5]|=128<>>9<<4)+14]=t;for(var r=1732584193,n=-271733879,i=-1732584194,a=271733878,s=0;s>16)+(t>>16)+(r>>16);return n<<16|r&65535}function G3(e,t){return e<>>32-t}var Wp=class{constructor(){this.expires=z3(),O.read(Ka)||O.write("{}",Ka);try{this.resourceCache=JSON.parse(O.read(Ka))}catch(t){O.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Ka} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},O.write("{}",Ka)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],O.delete(`#${n}`),t=!0),new Date().getTime()-i.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){O.write(JSON.stringify(this.resourceCache),Ka)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function z3(){O.read(Jl)||O.write("6e4",Jl);let e=6e4;if(O.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=O.read("#\u54CD\u5E94\u5934\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=O.read(Jl),e}var Wa=new Wp;function ro(e){let t=Object.keys(e),r="",n="";for(let i of t){let a=i.toLowerCase();a==="subscription-userinfo"?r=e[i]:a==="profile-web-page-url"&&(n=e[i])}return`${r||""}${n?`; app_url=${encodeURIComponent(n)}`:""}`}async function Oi(rawUrl,ua,timeout,customProxy,flowUrl){let url=flowUrl||rawUrl||"",$arguments={},rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}if($arguments?.noFlow)return;let{isStash,isLoon,isShadowRocket,isQX}=$r(),insecure=$arguments?.insecure?O.env.isNode?{strictSSL:!1}:{insecure:!0}:void 0,{defaultProxy,defaultFlowUserAgent,defaultTimeout}=O.read(Et),proxy=customProxy||defaultProxy;O.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultFlowUserAgent||"clash",requestTimeout=timeout||defaultTimeout||8e3,id=Tn(userAgent+url),cached=Wa.get(id),flowInfo;if(!$arguments?.noCache&&cached)O.info(`\u4F7F\u7528\u7F13\u5B58\u7684\u6D41\u91CF\u4FE1\u606F: ${url}, ${userAgent}`),flowInfo=cached;else{let e=vs();if(flowUrl){O.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u4ECE\u54CD\u5E94\u4F53\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${flowUrl}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{body:t}=await e.get({url:flowUrl,headers:{"User-Agent":userAgent},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...insecure||{}});flowInfo=t}else{try{O.info(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.head({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...insecure||{}});flowInfo=ro(t)}catch(t){O.error(`\u4F7F\u7528 HEAD \u65B9\u6CD5\u4ECE\u54CD\u5E94\u5934\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u5931\u8D25: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}: ${t.message??t}`)}if(!flowInfo){O.info(`\u4F7F\u7528 GET \u65B9\u6CD5\u83B7\u53D6\u6D41\u91CF\u4FE1\u606F: ${url}, User-Agent: ${userAgent||""}, Insecure: ${!!insecure}, Proxy: ${proxy}`);let{headers:t}=await e.get({url:url.split(/[\r\n]+/).map(r=>r.trim()).filter(r=>r.length)[0],headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...insecure||{}});flowInfo=ro(t)}}flowInfo&&(flowInfo=flowInfo.trim()),flowInfo&&Wa.set(id,flowInfo)}return flowInfo}function Xa(e){if(!e)return;let t=e.match(/upload=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),r=Number(t[1]+t[2]),n=e.match(/download=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),i=Number(n[1]+n[2]),a=e.match(/total=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),s=Number(a[1]+a[2]),c=e.match(/expire=([-+]?)([0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)/),l=c?Number(c[1]+c[2]):void 0,h=e.match(/reset_day=([0-9]+)/),v=h?Number(h[1]):void 0,E=e.match(/app_url=(.*?)\s*?(;|$)/),p=E?decodeURIComponent(E[1]):void 0,f=e.match(/plan_name=(.*?)\s*?(;|$)/),A=f?decodeURIComponent(f[1]):void 0;return{expires:l,total:s,usage:{upload:r,download:i},remainingDays:v,appUrl:p,planName:A}}function _c(e,t="B"){let r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=r.indexOf(t);return e<1024||n===r.length-1?{value:e.toFixed(1),unit:t}:_c(e/1024,r[++n])}function pf(e){if(!e)throw new Error("\u6CA1\u6709\u6D41\u91CF\u4FE1\u606F");if(e?.expires&&e.expires*1e3a.getTime())throw new Error("\u5F00\u59CB\u65E5\u671F\u5E94\u65E9\u4E8E\u73B0\u5728");let s=new Date(r);for(s.setDate(s.getDate()+n);s31)throw new Error("\u6708\u91CD\u7F6E\u65E5\u5E94\u4E3A 1-31 \u4E4B\u95F4\u7684\u6574\u6570");let i=new Date,a=i.getDate(),s=i.getMonth(),c=i.getFullYear(),l;return t>a?l=0:l=new Date(c,s+1,0).getDate(),l-a+t}}catch(t){O.error(`getRmainingDays failed: ${t.message??t}`)}}function gf(e){try{let t=new Map;return e.split(";").map(r=>r.trim()).filter(Boolean).forEach(r=>{let n=r.indexOf("=");if(n===-1)return;let i=r.slice(0,n).trim(),a=r.slice(n+1).trim();if(!t.has(i))try{let s=decodeURIComponent(a);t.set(i,s)}catch{t.set(i,a)}}),Array.from(t.entries()).map(([r,n])=>`${r}=${encodeURIComponent(n)}`).join("; ")}catch(t){return O.error(`normalizeFlowHeader failed: ${t.message??t}`),e}}O.read(Lt)||O.write({},Lt);function Xp(e){e.get("/api/sub/flow/:name",Y3),e.route("/api/sub/:name").get(X3).patch(J3).delete(Z3),e.route("/api/subs").get(Q3).post(W3).put(eb)}async function Y3(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let{url:n}=e.query;n&&(n=decodeURIComponent(n),O.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605 URL: ${n}`));let i=O.read(Lt),a=gt(i,r);if(!a){Ue(t,new lr("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404);return}if(a.source==="local"&&!["localFirst","remoteFirst"].includes(a.mergeSources)){if(a.subUserinfo){let s;if(/^https?:\/\//.test(a.subUserinfo))try{s=await Oi(void 0,void 0,void 0,a.proxy,a.subUserinfo)}catch(c){O.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${a.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(c)}`)}else s=a.subUserinfo;try{xe(t,{...Xa(s)})}catch(c){O.error(`Failed to parse flow info for local subscription ${r}: ${c.message??c}`),Ue(t,new pt("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}else Ue(t,new pt("NO_FLOW_INFO","N/A",`Local subscription ${r} has no flow information!`));return}try{n=`${n||a.url}`.split(/[\r\n]+/).map(h=>h.trim()).filter(h=>h.length)?.[0]||"";let s={},c=n.split("#");if(n=n.split("#")[0],c.length>1)try{s=JSON.parse(decodeURIComponent(c[1]))}catch{for(let v of c[1].split("&")){let E=v.split("=")[0],p=v.split("=")[1];s[E]=p==null||p===""?!0:decodeURIComponent(p)}}if(s.noFlow){Ue(t,new pt("NO_FLOW_INFO","N/A",`Subscription ${r}: noFlow`));return}let l=await Oi(s?.insecure?`${n}#insecure`:n,s.flowUserAgent,void 0,a.proxy,s.flowUrl);if(!l&&!a.subUserinfo){Ue(t,new Rr("NO_FLOW_INFO","No flow info","Failed to fetch flow headers"));return}try{let h=df({resetDay:s.resetDay,startDate:s.startDate,cycleDays:s.cycleDays}),v;if(/^https?:\/\//.test(a.subUserinfo))try{v=await Oi(void 0,void 0,void 0,a.proxy,a.subUserinfo)}catch(p){O.error(`\u8BA2\u9605 ${r} \u4F7F\u7528\u81EA\u5B9A\u4E49\u6D41\u91CF\u94FE\u63A5 ${a.subUserinfo} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(p)}`)}else v=a.subUserinfo;let E={...Xa([v,l].filter(p=>p).join("; "))};h!=null&&(E.remainingDays=h),xe(t,E)}catch(h){O.error(`Failed to parse flow info for local subscription ${r}: ${h.message??h}`),Ue(t,new pt("NO_FLOW_INFO","N/A","Failed to parse flow info"))}}catch{Ue(t,new ef("URL_NOT_ACCESSIBLE",`The URL for subscription ${r} is inaccessible.`))}}function W3(e,t){let r=e.body;if(O.info(`\u6B63\u5728\u521B\u5EFA\u8BA2\u9605\uFF1A ${r.name}`),/\//.test(r.name)){Ue(t,new pt("INVALID_NAME",`Subscription ${r.name} is invalid`));return}let n=O.read(Lt);if(gt(n,r.name)){Ue(t,new pt("DUPLICATE_KEY",`Subscription ${r.name} already exists.`));return}n.push(r),O.write(n,Lt),xe(t,r,201)}function X3(e,t){let{name:r}=e.params,{raw:n}=e.query;r=decodeURIComponent(r);let i=O.read(Lt),a=gt(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_subscription_${r}_${ea(new Date)}.json`)}"`).send(JSON.stringify(a)):xe(t,a):Ue(t,new lr("SUBSCRIPTION_NOT_FOUND",`Subscription ${r} does not exist`,404))}function J3(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=O.read(Lt),a=gt(i,r);if(a){let s={...a,...n};if(O.info(`\u6B63\u5728\u66F4\u65B0\u8BA2\u9605\uFF1A ${r}`),r!==n.name){let c=O.read(Tt)||[];for(let v of c){let E=v.subscriptions.indexOf(r);E!==-1&&(v.subscriptions[E]=n.name)}let l=O.read(Ct)||[];for(let v of l)v.type==="subscription"&&v.source==r&&(v.source=n.name);let h=O.read(dt)||[];for(let v of h)v.sourceType==="subscription"&&v.sourceName==r&&(v.sourceName=n.name);O.write(c,Tt),O.write(l,Ct),O.write(h,dt)}di(i,r,s),O.write(i,Lt),xe(t,s)}else Ue(t,new lr("RESOURCE_NOT_FOUND",`Subscription ${r} does not exist!`),404)}function Z3(e,t){let{name:r}=e.params;r=decodeURIComponent(r),O.info(`\u5220\u9664\u8BA2\u9605\uFF1A${r}...`);let n=O.read(Lt);ri(n,r),O.write(n,Lt);let i=O.read(Tt);for(let a of i)a.subscriptions=a.subscriptions.filter(s=>s!==r);O.write(i,Tt),xe(t)}function Q3(e,t){let r=O.read(Lt);xe(t,r)}function eb(e,t){let r=e.body;O.write(r,Lt),xe(t)}var ni=class{constructor({token,key,syncPlatform}){let{isStash,isLoon,isShadowRocket,isQX}=$r(),{defaultProxy,defaultTimeout:timeout}=O.read(Et),proxy=defaultProxy;O.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY")),syncPlatform==="gitlab"?(this.headers={"PRIVATE-TOKEN":`${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=vs({baseURL:"https://gitlab.com/api/v4",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>{if(/^[45]/.test(String(e.statusCode))){let t=JSON.parse(e.body);return Promise.reject(`ERROR: ${t.message?.error??t.message}`)}else return e}}})):(this.headers={Authorization:`token ${token}`,"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"},this.http=vs({baseURL:"https://api.github.com",headers:{...this.headers,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},timeout:timeout||8e3,events:{onResponse:e=>/^[45]/.test(String(e.statusCode))?Promise.reject(`ERROR: ${JSON.parse(e.body).message}`):e}})),this.key=key,this.syncPlatform=syncPlatform}async locate(){return this.syncPlatform==="gitlab"?this.http.get("/snippets").then(e=>{let t=JSON.parse(e.body);for(let r of t)if(r.title===this.key)return r}):this.http.get("/gists?per_page=100&page=1").then(e=>{let t=JSON.parse(e.body);O.info(`\u83B7\u53D6\u5230\u5F53\u524D GitHub \u7528\u6237\u7684 gist: ${t.length} \u4E2A`);for(let r of t)if(r.description===this.key)return r})}async upload(e){if(Object.keys(e).length===0)return Promise.reject("\u672A\u63D0\u4F9B\u9700\u4E0A\u4F20\u7684\u6587\u4EF6");let t=await this.locate(),r=e;if(t?.id){this.syncPlatform==="gitlab"&&(t.files=t.files.reduce((a,s)=>(a[s.path]=s,a),{}));let n=[],i={...t.files};return Object.keys(r).map(a=>{i[a]?r[a].content==null||r[a].content===""?(delete i[a],n.push({action:"delete",file_path:a})):(i[a]=r[a],n.push({action:"update",file_path:a,content:r[a].content})):r[a].content==null||r[a].content===""?(delete i[a],delete r[a]):(i[a]=r[a],n.push({action:"create",file_path:a,content:r[a].content}))}),this.syncPlatform==="gitlab"?Object.keys(i).length===0?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u66F4\u65B0 snippet"):Object.keys(i).length>10?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4 snippet \u7684\u6587\u4EF6\u6570\u8D85\u8FC7 10, \u65E0\u6CD5\u66F4\u65B0 snippet"):(r=n,this.http.put({headers:{...this.headers,"Content-Type":"application/json"},url:`/snippets/${t.id}`,body:JSON.stringify({files:r})})):Object.keys(i).length===0?Promise.reject("\u672C\u6B21\u64CD\u4F5C\u5C06\u5BFC\u81F4\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u66F4\u65B0 gist"):this.http.patch({url:`/gists/${t.id}`,body:JSON.stringify({files:r})})}else return r=Object.entries(r).reduce((n,[i,a])=>(a.content!==null&&a.content!==""&&(n[i]=a),n),{}),this.syncPlatform==="gitlab"?Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA snippet"):(r=Object.keys(r).map(n=>({file_path:n,content:r[n].content})),this.http.post({headers:{...this.headers,"Content-Type":"application/json"},url:"/snippets",body:JSON.stringify({title:this.key,visibility:"private",files:r})})):Object.keys(r).length===0?Promise.reject("\u6240\u6709\u6587\u4EF6\u7684\u5185\u5BB9\u90FD\u4E3A\u7A7A, \u65E0\u6CD5\u521B\u5EFA gist"):this.http.post({url:"/gists",body:JSON.stringify({description:this.key,public:!1,files:r})})}async download(e){let t=await this.locate();if(t?.id)try{let{files:r}=await this.http.get(`/gists/${t.id}`).then(i=>JSON.parse(i.body)),n=r[e].raw_url;return await this.http.get(n).then(i=>i.body)}catch(r){return Promise.reject(r)}else return Promise.reject(`\u627E\u4E0D\u5230 Sub-Store Gist (${this.key})`)}};function Jp(e){O.read(Ct)||O.write({},Ct),e.get("/api/artifacts/restore",tb),e.route("/api/artifacts").get(rb).post(sb).put(nb),e.route("/api/artifact/:name").get(ib).patch(ab).delete(ub)}async function tb(e,t){O.info("\u5F00\u59CB\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E...");try{let{gistToken:r,syncPlatform:n}=O.read(Et);if(!r)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=new ni({token:r,key:Ma,syncPlatform:n});try{let a=await i.locate();if(!a?.files)throw new Error("\u627E\u4E0D\u5230 Sub-Store Gist \u6587\u4EF6\u5217\u8868");let s=O.read(Ct),c=[];Object.keys(a.files).map(l=>{let h=a.files[l]?.filename;if(h)if(encodeURIComponent(h)!==h)O.error(`\u6587\u4EF6\u540D ${h} \u672A\u7F16\u7801 \u4E0D\u4FDD\u5B58`),c.push(h);else{let v=gt(s,h);v?di(s,h,{...v,url:a.files[l]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")}):s.push({name:`${h}`,url:a.files[l]?.raw_url.replace(/\/raw\/[^/]*\/(.*)/,"/raw/$1")})}}),O.write(s,Ct)}catch(a){throw O.error(`\u67E5\u627E Sub-Store Gist \u65F6\u53D1\u751F\u9519\u8BEF: ${a.message??a}`),a}xe(t)}catch(r){O.error(`\u6062\u590D\u8FDC\u7A0B\u914D\u7F6E\u5931\u8D25\uFF0C\u539F\u56E0\uFF1A${r.message??r}`),Ue(t,new Rr("FAILED_TO_RESTORE_ARTIFACTS","Failed to restore artifacts",`Reason: ${r.message??r}`))}}function rb(e,t){let r=O.read(Ct);xe(t,r)}function nb(e,t){let r=e.body;O.write(r,Ct),xe(t)}async function ib(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=O.read(Ct),i=gt(n,r);i?xe(t,i):Ue(t,new lr("RESOURCE_NOT_FOUND",`Artifact ${r} does not exist!`),404)}function sb(e,t){let r=e.body;if(!Wg(r.name)){Ue(t,new pt("INVALID_ARTIFACT_NAME",`Artifact name ${r.name} is invalid.`));return}O.info(`\u6B63\u5728\u521B\u5EFA\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r.name}`);let n=O.read(Ct);gt(n,r.name)?Ue(t,new pt("DUPLICATE_KEY",`Artifact ${r.name} already exists.`)):(n.push(r),O.write(n,Ct),xe(t,r,201))}function ab(e,t){let r=O.read(Ct),n=e.params.name;n=decodeURIComponent(n);let i=gt(r,n);if(i){O.info(`\u6B63\u5728\u66F4\u65B0\u8FDC\u7A0B\u914D\u7F6E\uFF1A${i.name}`);let a={...i,...e.body};if(!Wg(a.name)){Ue(t,new pt("INVALID_ARTIFACT_NAME",`Artifact name ${a.name} is invalid.`));return}di(r,n,a),O.write(r,Ct),xe(t,a)}else Ue(t,new pt("DUPLICATE_KEY",`Artifact ${n} already exists.`))}async function ub(e,t){let{name:r}=e.params;r=decodeURIComponent(r),O.info(`\u6B63\u5728\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}`);let n=O.read(Ct);try{let i=gt(n,r);if(!i)throw new Error(`\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}\u4E0D\u5B58\u5728\uFF01`);if(i.updated){let a={};a[encodeURIComponent(i.name)]={content:""},encodeURIComponent(i.name)!==i.name&&(a[i.name]={content:""});try{await Xg(a)}catch(s){O.error(`Function syncToGist: ${r} : ${s}`)}}ri(n,r),O.write(n,Ct),xe(t)}catch(i){O.error(`\u65E0\u6CD5\u5220\u9664\u8FDC\u7A0B\u914D\u7F6E\uFF1A${r}\uFF0C\u539F\u56E0\uFF1A${i}`),Ue(t,new Rr("FAILED_TO_DELETE_ARTIFACT",`Failed to delete artifact ${r}`,`Reason: ${i}`))}}function Wg(e){return/^[a-zA-Z0-9._-]*$/.test(e)}async function Xg(e){let{gistToken:t,syncPlatform:r}=O.read(Et);if(!t)return Promise.reject("\u672A\u8BBE\u7F6E GitHub Token\uFF01");let i=await new ni({token:t,key:Ma,syncPlatform:r}).upload(e),a={};try{a=JSON.parse(i.body)}catch{}let s=a?.html_url??a?.web_url,c=O.read(Et);return s?(O.log(`\u540C\u6B65 Gist \u540E, \u627E\u5230 Sub-Store Gist: ${s}`),c.artifactStore=s,c.artifactStoreStatus="VALID"):(O.error("\u540C\u6B65 Gist \u540E, \u627E\u4E0D\u5230 Sub-Store Gist"),c.artifactStoreStatus="NOT FOUND"),O.write(c,Et),i}function Zp(e){O.read(Et)||O.write({},Et),e.route("/api/settings").get(ob).patch(cb)}async function ob(e,t){try{let r=O.read(Et);r||(r={},O.write(r,Et)),r.avatarUrl||await mf(),r.artifactStore||await vf(),xe(t,r)}catch(r){O.error(`Failed to get settings: ${r.message??r}`),Ue(t,new Rr("FAILED_TO_GET_SETTINGS","Failed to get settings",`Reason: ${r.message??r}`))}}async function cb(e,t){try{let n={...O.read(Et),...e.body};O.write(n,Et),await mf(),await vf(),xe(t,n)}catch(r){O.error(`Failed to update settings: ${r.message??r}`),Ue(t,new Rr("FAILED_TO_UPDATE_SETTINGS","Failed to update settings",`Reason: ${r.message??r}`))}}async function mf(){let e=O.read(Et),{githubUser:t,syncPlatform:r}=e;if(t)if(r==="gitlab")try{let n=await O.http.get({url:`https://gitlab.com/api/v4/users?username=${encodeURIComponent(t)}`,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"}}).then(i=>JSON.parse(i.body));e.avatarUrl=n[0].avatar_url.replace(/(\?|&)s=\d+(&|$)/,"$1s=160$2"),O.write(e,Et)}catch(n){O.error(`Failed to fetch GitLab avatar for User: ${t}. Reason: ${n.message??n}`)}else try{let n=await O.http.get({url:`https://api.github.com/users/${encodeURIComponent(t)}`,headers:{"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.141 Safari/537.36"}}).then(i=>JSON.parse(i.body));e.avatarUrl=n.avatar_url,O.write(e,Et)}catch(n){O.error(`Failed to fetch GitHub avatar for User: ${t}. Reason: ${n.message??n}`)}}async function vf(){O.log("Updating artifact store");let e=O.read(Et),{gistToken:t,syncPlatform:r}=e;if(t){let n=new ni({token:t,key:Ma,syncPlatform:r});try{let i=await n.locate(),a=i?.html_url??i?.web_url;a?(O.log(`\u627E\u5230 Sub-Store Gist: ${a}`),e.artifactStore=a,e.artifactStoreStatus="VALID"):(O.error(`\u627E\u4E0D\u5230 Sub-Store Gist (${Ma})`),e.artifactStoreStatus="NOT FOUND")}catch(i){O.error(`\u67E5\u627E Sub-Store Gist (${Ma}) \u65F6\u53D1\u751F\u9519\u8BEF: ${i.message??i}`),e.artifactStoreStatus="ERROR"}O.write(e,Et)}}var Qp=class{constructor(t){this.expires=t,O.read(qa)||O.write("{}",qa);try{this.resourceCache=JSON.parse(O.read(qa))}catch(r){O.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${qa} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${r?.message??r}`),this.resourceCache={},O.write("{}",qa)}this._cleanup()}_cleanup(){let t=!1;Object.entries(this.resourceCache).forEach(r=>{let[n,i]=r;i.time||(delete this.resourceCache[n],O.delete(`#${n}`),t=!0),new Date().getTime()-i.time>this.expires&&(delete this.resourceCache[n],t=!0)}),t&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){O.write(JSON.stringify(this.resourceCache),qa)}get(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].data:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}},ar=new Qp(36e5);var ed=class{constructor(){this.expires=fb(),O.read(Va)||O.write("{}",Va);try{this.resourceCache=JSON.parse(O.read(Va))}catch(t){O.error(`\u89E3\u6790\u6301\u4E45\u5316\u7F13\u5B58\u4E2D\u7684 ${Va} \u5931\u8D25, \u91CD\u7F6E\u4E3A {}, \u9519\u8BEF: ${t?.message??t}`),this.resourceCache={},O.write("{}",Va)}this._cleanup()}_cleanup(t,r){let n=!1;Object.entries(this.resourceCache).forEach(i=>{let[a,s]=i;s.time||(delete this.resourceCache[a],O.delete(`#${a}`),n=!0),(new Date().getTime()-s.time>(r??this.expires)||t&&a.startsWith(t))&&(delete this.resourceCache[a],n=!0)}),n&&this._persist()}revokeAll(){this.resourceCache={},this._persist()}_persist(){O.write(JSON.stringify(this.resourceCache),Va)}get(t,r,n){let i=this.resourceCache[t]&&this.resourceCache[t].time;if(i){if(new Date().getTime()-i<=(r??this.expires))return this.resourceCache[t].data;n&&(delete this.resourceCache[t],this._persist())}return null}gettime(t){let r=this.resourceCache[t]&&this.resourceCache[t].time;return r&&new Date().getTime()-r<=this.expires?this.resourceCache[t].time:null}set(t,r){this.resourceCache[t]={time:new Date().getTime(),data:r},this._persist()}};function fb(){O.read(Zl)||O.write("1728e5",Zl);let e=1728e5;if(O.env.isLoon){let t={"1\u5206\u949F":6e4,"5\u5206\u949F":3e5,"10\u5206\u949F":6e5,"30\u5206\u949F":18e5,"1\u5C0F\u65F6":36e5,"2\u5C0F\u65F6":72e5,"3\u5C0F\u65F6":108e5,"6\u5C0F\u65F6":216e5,"12\u5C0F\u65F6":432e5,"24\u5C0F\u65F6":864e5,"48\u5C0F\u65F6":1728e5,"72\u5C0F\u65F6":2592e5,\u53C2\u6570\u4F20\u5165:"readcachets"},r=O.read("#\u8282\u70B9\u7F13\u5B58\u6709\u6548\u671F");return r in t&&(e=t[r],e==="readcachets"&&(e=r)),e}else return e=O.read(Zl),e}var Ic=new ed;var{isNode:Jg,isQX:hb,isLoon:pb,isSurge:db,isStash:gb,isShadowRocket:mb,isLanceX:vb,isEgern:wb,isGUIforCores:Ab}=$r(),Ni="Node";Jg&&(Ni="Node");hb&&(Ni="QX");pb&&(Ni="Loon");db&&(Ni="Surge");gb&&(Ni="Stash");mb&&(Ni="ShadowRocket");wb&&(Ni="Egern");vb&&(Ni="LanceX");Ab&&(Ni="GUI.for.Cores");var Ja={},Eb={};try{if(typeof $environment<"u"&&(Ja.env=$environment),typeof $loon<"u"&&(Ja.loon=$loon),typeof $script<"u"&&(Ja.script=$script),typeof $Plugin<"u"&&(Ja.plugin=$Plugin),Jg){Ja.node={version:eval("process.version"),argv:eval("process.argv"),filename:eval("__filename"),dirname:eval("__dirname"),env:{}};let env=eval("process.env");for(let e in env)/^SUB_STORE_/.test(e)&&(Ja.node.env[e]=env[e])}}catch(e){}var ra={backend:Ni,version:Wl,feature:Eb,meta:Ja};function td(e){e.get("/api/utils/env",yb),e.get("/api/utils/backup",Cb),e.get("/api/utils/refresh",Sb),e.route("/api/storage").get((t,r)=>{r.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_data_${ea(new Date)}.json`)}"`).send(O.env.isNode?JSON.stringify(O.cache):O.read("#sub-store"))}).post((t,r)=>{let{content:n}=t.body;O.write(n,"#sub-store"),O.env.isNode&&(O.cache=JSON.parse(n),O.persistCache()),Xu(),xe(r)}),e.get("/",async(t,r)=>{r.set("location","https://sub-store.vercel.app/").status(302).end()}),$r().isQX&&e.options("/",async(t,r)=>{r.status(200).end()}),e.all("/",(t,r)=>{r.send("Hello from sub-store, made with \u2764\uFE0F by Peng-YM")})}function yb(e,t){e.query.share&&(ra.feature.share=!0),xe(t,ra)}async function Sb(e,t){await mf(),await vf(),ar.revokeAll(),Ic.revokeAll(),Wa.revokeAll(),xe(t)}async function bb(e){let{gistToken:t,syncPlatform:r}=O.read(Et);if(!t)throw new Error("GitHub Token is required for backup!");let n=new ni({token:t,key:Bg,syncPlatform:r}),i,a=O.read(Et),s=a.syncTime;switch(e){case"upload":try{if(i=O.read("#sub-store"),O.env.isNode&&(i=JSON.stringify(O.cache,null," ")),O.info("\u4E0B\u8F7D\u5907\u4EFD, \u4E0E\u672C\u5730\u5185\u5BB9\u5BF9\u6BD4..."),await n.download(Xl)===i){O.info("\u5185\u5BB9\u4E00\u81F4, \u65E0\u9700\u4E0A\u4F20\u5907\u4EFD");return}}catch(c){O.error(`${c.message??c}`)}a.syncTime=new Date().getTime(),O.write(a,Et),i=O.read("#sub-store"),O.env.isNode&&(i=JSON.stringify(O.cache,null," ")),O.info("\u4E0A\u4F20\u5907\u4EFD\u4E2D...");try{await n.upload({[Xl]:{content:i}}),O.info("\u4E0A\u4F20\u5907\u4EFD\u5B8C\u6210")}catch(c){throw a.syncTime=s,O.write(a,Et),c}break;case"download":O.info("\u8FD8\u539F\u5907\u4EFD\u4E2D..."),i=await n.download(Xl);try{if(Object.keys(JSON.parse(i).settings).length===0)throw new Error("\u5907\u4EFD\u6587\u4EF6\u5E94\u8BE5\u81F3\u5C11\u5305\u542B settings \u5B57\u6BB5")}catch(c){throw O.error(`Gist \u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F Reason: ${c.message??c}`),new Error("Gist \u5907\u4EFD\u6587\u4EF6\u6821\u9A8C\u5931\u8D25, \u65E0\u6CD5\u8FD8\u539F")}O.write(i,"#sub-store"),O.env.isNode&&(i=JSON.parse(i),O.cache=i,O.persistCache()),O.info("perform migration after restoring from gist..."),Xu(),O.info("migration completed"),O.info("\u8FD8\u539F\u5907\u4EFD\u5B8C\u6210");break}}async function Cb(e,t){let{action:r}=e.query,{gistToken:n}=O.read(Et);if(!n)Ue(t,new pt("GIST_TOKEN_NOT_FOUND","GitHub Token is required for backup!"));else try{await bb(r),xe(t)}catch(i){O.error(`Failed to ${r} gist data. Reason: ${i.message??i}`),Ue(t,new Rr("BACKUP_FAILED",`Failed to ${r} gist data!`,`Reason: ${i.message??i}`))}}function rd(e){e.post("/api/sort/subs",Fb),e.post("/api/sort/collections",_b),e.post("/api/sort/artifacts",Ib),e.post("/api/sort/files",Db)}function Fb(e,t){let r=e.body,n=O.read(Lt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),O.write(n,Lt),xe(t,n)}function _b(e,t){let r=e.body,n=O.read(Tt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),O.write(n,Tt),xe(t,n)}function Ib(e,t){let r=e.body,n=O.read(Ct);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),O.write(n,Ct),xe(t,n)}function Db(e,t){let r=e.body,n=O.read(dt);n.sort((i,a)=>r.indexOf(i.name)-r.indexOf(a.name)),O.write(n,dt),xe(t,n)}var xc=ei(qv());function Kv(e,t,...r){try{return e(t,...r)}catch{return e(Vv(e(t.replace(/!\s*/g,"__SubStoreJSYAMLString__"),...r)).replace(/__SubStoreJSYAMLString__/g,""),...r)}}function Bf(e,...t){return Kv(xc.default.safeLoad,JSON.parse(JSON.stringify(e)),...t)}function s_(e,...t){return Kv(xc.default.load,JSON.parse(JSON.stringify(e)),...t)}function a_(e,...t){return xc.default.safeDump(JSON.parse(JSON.stringify(e)),...t)}function Vv(e,...t){return xc.default.dump(JSON.parse(JSON.stringify(e)),...t)}var su={safeLoad:Bf,load:s_,safeDump:a_,dump:Vv};var Jv="3.7.7",u_=Jv,fo=typeof Buffer=="function",Gv=typeof TextDecoder=="function"?new TextDecoder:void 0,zv=typeof TextEncoder=="function"?new TextEncoder:void 0,o_="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",Oc=Array.prototype.slice.call(o_),Pf=(e=>{let t={};return e.forEach((r,n)=>t[r]=n),t})(Oc),c_=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,Tr=String.fromCharCode.bind(String),Yv=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):e=>new Uint8Array(Array.prototype.slice.call(e,0)),Zv=e=>e.replace(/=/g,"").replace(/[+\/]/g,t=>t=="+"?"-":"_"),Qv=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),e2=e=>{let t,r,n,i,a="",s=e.length%3;for(let c=0;c255||(n=e.charCodeAt(c++))>255||(i=e.charCodeAt(c++))>255)throw new TypeError("invalid character found");t=r<<16|n<<8|i,a+=Oc[t>>18&63]+Oc[t>>12&63]+Oc[t>>6&63]+Oc[t&63]}return s?a.slice(0,s-3)+"===".substring(s):a},wd=typeof btoa=="function"?e=>btoa(e):fo?e=>Buffer.from(e,"binary").toString("base64"):e2,md=fo?e=>Buffer.from(e).toString("base64"):e=>{let r=[];for(let n=0,i=e.length;nt?Zv(md(e)):md(e),l_=e=>{if(e.length<2){var t=e.charCodeAt(0);return t<128?e:t<2048?Tr(192|t>>>6)+Tr(128|t&63):Tr(224|t>>>12&15)+Tr(128|t>>>6&63)+Tr(128|t&63)}else{var t=65536+(e.charCodeAt(0)-55296)*1024+(e.charCodeAt(1)-56320);return Tr(240|t>>>18&7)+Tr(128|t>>>12&63)+Tr(128|t>>>6&63)+Tr(128|t&63)}},f_=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,t2=e=>e.replace(f_,l_),Wv=fo?e=>Buffer.from(e,"utf8").toString("base64"):zv?e=>md(zv.encode(e)):e=>wd(t2(e)),lo=(e,t=!1)=>t?Zv(Wv(e)):Wv(e),Xv=e=>lo(e,!0),h_=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,p_=e=>{switch(e.length){case 4:var t=(7&e.charCodeAt(0))<<18|(63&e.charCodeAt(1))<<12|(63&e.charCodeAt(2))<<6|63&e.charCodeAt(3),r=t-65536;return Tr((r>>>10)+55296)+Tr((r&1023)+56320);case 3:return Tr((15&e.charCodeAt(0))<<12|(63&e.charCodeAt(1))<<6|63&e.charCodeAt(2));default:return Tr((31&e.charCodeAt(0))<<6|63&e.charCodeAt(1))}},r2=e=>e.replace(h_,p_),n2=e=>{if(e=e.replace(/\s+/g,""),!c_.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(e.length&3));let t,r="",n,i;for(let a=0;a>16&255):i===64?Tr(t>>16&255,t>>8&255):Tr(t>>16&255,t>>8&255,t&255);return r},Ad=typeof atob=="function"?e=>atob(Qv(e)):fo?e=>Buffer.from(e,"base64").toString("binary"):n2,i2=fo?e=>Yv(Buffer.from(e,"base64")):e=>Yv(Ad(e).split("").map(t=>t.charCodeAt(0))),s2=e=>i2(a2(e)),d_=fo?e=>Buffer.from(e,"base64").toString("utf8"):Gv?e=>Gv.decode(i2(e)):e=>r2(Ad(e)),a2=e=>Qv(e.replace(/[-_]/g,t=>t=="-"?"+":"/")),vd=e=>d_(a2(e)),g_=e=>{if(typeof e!="string")return!1;let t=e.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(t)||!/[^\s0-9a-zA-Z\-_]/.test(t)},u2=e=>({value:e,enumerable:!1,writable:!0,configurable:!0}),o2=function(){let e=(t,r)=>Object.defineProperty(String.prototype,t,u2(r));e("fromBase64",function(){return vd(this)}),e("toBase64",function(t){return lo(this,t)}),e("toBase64URI",function(){return lo(this,!0)}),e("toBase64URL",function(){return lo(this,!0)}),e("toUint8Array",function(){return s2(this)})},c2=function(){let e=(t,r)=>Object.defineProperty(Uint8Array.prototype,t,u2(r));e("toBase64",function(t){return $f(this,t)}),e("toBase64URI",function(){return $f(this,!0)}),e("toBase64URL",function(){return $f(this,!0)})},m_=()=>{o2(),c2()},yt={version:Jv,VERSION:u_,atob:Ad,atobPolyfill:n2,btoa:wd,btoaPolyfill:e2,fromBase64:vd,toBase64:lo,encode:lo,encodeURI:Xv,encodeURL:Xv,utob:t2,btou:r2,decode:vd,isValid:g_,fromUint8Array:$f,toUint8Array:s2,extendString:o2,extendUint8Array:c2,extendBuiltins:m_};function v_(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function w_(){let e="Base64 Pre-processor",t=["dm1lc3M","c3NyOi8v","c29ja3M6Ly","dHJvamFu","c3M6Ly","c3NkOi8v","c2hhZG93","aHR0c","dmxlc3M=","aHlzdGVyaWEy","aHkyOi8v","d2lyZWd1YXJkOi8v","d2c6Ly8=","dHVpYzovLw=="];return{name:e,test:function(i){return!/^\w+:\/\/\w+/im.test(i)&&t.some(a=>i.indexOf(a)!==-1)},parse:function(i){let a=yt.decode(i);return/^\w+(:\/\/|\s*?=\s*?)\w+/m.test(a)?a:(O.error("Base64 Pre-processor error: decoded line does not start with protocol"),i)}}}function A_(){return{name:"Clash Pre-processor",test:function(n){if(!/proxies/.test(n))return!1;let i=Bf(n);return i.proxies&&Array.isArray(i.proxies)},parse:function(n,i){let a=n.replace(/short-id:([ \t]*[^#\n,}]*)/g,(l,h)=>{let v=h.trim();return!v||v===""?'short-id: ""':/^(['"]).*\1$/.test(v)?`short-id: ${v}`:["null"].includes(v)?`short-id: ${v}`:`short-id: "${v}"`}),{proxies:s,"global-client-fingerprint":c}=Bf(a);return(i?`proxies: `:"")+s.map(l=>(c&&!l["client-fingerprint"]&&(l["client-fingerprint"]=c),`${i?" - ":""}${JSON.stringify(l)} `)).join("")}}}function E_(){return{name:"SSD Pre-processor",test:function(n){return n.indexOf("ssd://")===0},parse:function(n){let i=[],a=JSON.parse(yt.decode(n.split("ssd://")[1])),s=a.port,c=a.encryption,l=a.password,h=a.servers;for(let v=0;ve.name==="Clash Pre-processor"),Ed=new Map;async function xn(rawUrl="",ua,timeout,customProxy,skipCustomCache,awaitCustomCache,noCache,preprocess){let $arguments={},url=rawUrl.replace(/#noFlow$/,""),rawArgs=url.split("#");if(url=url.split("#")[0],rawArgs.length>1)try{$arguments=JSON.parse(decodeURIComponent(rawArgs[1]))}catch{for(let t of rawArgs[1].split("&")){let r=t.split("=")[0],n=t.split("=")[1];$arguments[r]=n==null||n===""?!0:decodeURIComponent(n)}}let{isNode,isStash,isLoon,isShadowRocket,isQX}=$r(),{defaultProxy,defaultUserAgent,defaultTimeout,cacheThreshold:defaultCacheThreshold}=O.read(Et),cacheThreshold=defaultCacheThreshold||1024,proxy=customProxy||defaultProxy;O.env.isNode&&(proxy=proxy||eval("process.env.SUB_STORE_BACKEND_DEFAULT_PROXY"));let userAgent=ua||defaultUserAgent||"clash.meta",requestTimeout=timeout||defaultTimeout||8e3,id=Tn(userAgent+url);$arguments?.cacheKey===!0&&(O.error("\u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58\u65F6 cacheKey \u7684\u503C\u4E0D\u80FD\u4E3A\u7A7A"),$arguments.cacheKey=void 0);let customCacheKey=$arguments?.cacheKey?`#sub-store-cached-custom-${$arguments?.cacheKey}`:void 0;if(customCacheKey&&!skipCustomCache){let e=O.read(customCacheKey),t=ar.get(id);if(!noCache&&!$arguments?.noCache&&t)return O.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5B58\u5728\u6709\u6548\u7684\u5E38\u89C4\u7F13\u5B58 \u4F7F\u7528\u5E38\u89C4\u7F13\u5B58\u4EE5\u907F\u514D\u91CD\u590D\u8BF7\u6C42`),t;if(e){if(awaitCustomCache){O.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u66F4\u65B0\u7F13\u5B58`);try{await xn(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess)}catch(r){O.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`),O.info("\u4F7F\u7528\u4E50\u89C2\u7F13\u5B58\u7684\u6570\u636E\u5237\u65B0\u7F13\u5B58, \u9632\u6B62\u540E\u7EED\u8BF7\u6C42"),ar.set(id,e)}}else O.info(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u672C\u6B21\u8FD4\u56DE\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey} \u5E76\u8FDB\u884C\u8BF7\u6C42 \u5C1D\u8BD5\u5F02\u6B65\u66F4\u65B0\u7F13\u5B58`),xn(rawUrl.replace(/(\?|&)cacheKey=.*?(&|$)/,""),ua,timeout,proxy,!0,void 0,void 0,preprocess).catch(r=>{O.error(`\u4E50\u89C2\u7F13\u5B58: URL ${url} \u5F02\u6B65\u66F4\u65B0\u7F13\u5B58\u53D1\u751F\u9519\u8BEF ${r.message??r}`)});return e}}if(!isNode&&Ed.has(id))return Ed.get(id);let http=vs({headers:{"User-Agent":userAgent,...isStash&&proxy?{"X-Stash-Selected-Proxy":encodeURIComponent(proxy)}:{},...isShadowRocket&&proxy?{"X-Surge-Policy":proxy}:{}},timeout:requestTimeout}),result,cached=ar.get(id);if(!noCache&&!$arguments?.noCache&&cached)O.info(`\u4F7F\u7528\u7F13\u5B58: ${url}, ${userAgent}`),result=cached,customCacheKey&&(O.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),O.write(cached,customCacheKey));else{let e=$arguments?.insecure?isNode?{strictSSL:!1}:{insecure:!0}:void 0;O.info(`Downloading... User-Agent: ${userAgent} Timeout: ${requestTimeout} Proxy: ${proxy} Insecure: ${!!e} Preprocess: ${preprocess} URL: ${url}`);try{let{body:t,headers:r,statusCode:n}=await http.get({url,...proxy?{proxy}:{},...isLoon&&proxy?{node:proxy}:{},...isQX&&proxy?{opts:{policy:proxy}}:{},...proxy?As(proxy):{},...e||{}});if(O.info(`statusCode: ${n}`),n<200||n>=400)throw new Error(`statusCode: ${n}`);if(r){let a=ro(r);a&&Wa.set(id,a)}if(t.replace(/\s/g,"").length===0)throw new Error(new Error("\u8FDC\u7A0B\u8D44\u6E90\u5185\u5BB9\u4E3A\u7A7A"));if(preprocess)try{l2.test(t)&&(t=l2.parse(t,!0))}catch(a){O.error(`Clash Pre-processor error: ${a}`)}let i=!0;if(cacheThreshold){let a=t.length/1024;a>cacheThreshold&&(O.info(`\u8D44\u6E90\u5927\u5C0F ${a.toFixed(2)} KB \u8D85\u8FC7\u4E86 ${cacheThreshold} KB, \u4E0D\u7F13\u5B58`),i=!1)}i&&(ar.set(id,t),customCacheKey&&(O.info(`URL ${url} \u5199\u5165\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),O.write(t,customCacheKey))),result=t}catch(t){if(customCacheKey){let r=O.read(customCacheKey);if(r)return O.info(`\u65E0\u6CD5\u4E0B\u8F7D URL ${url}: ${t.message??t} \u4F7F\u7528\u81EA\u5B9A\u4E49\u7F13\u5B58 ${$arguments?.cacheKey}`),r}throw new Error(`\u65E0\u6CD5\u4E0B\u8F7D URL ${url}: ${t.message??t}`)}}return $arguments?.validCheck&&await pf(Xa(await Oi(url,$arguments.flowUserAgent,void 0,proxy,$arguments.flowUrl))),isNode||Ed.set(id,result),result}var L0=ei(Nf());var Yd=ei(ew());function G9(e){let t=Yd.default.pemtohex(e);return Yd.default.KJUR.crypto.Util.hashHex(t,"sha256").match(/.{2}/g).join(":").toUpperCase()}var tw={generateFingerprint:G9};function Xf(e,t){return[...Array(e).keys()].map(()=>t)}var Wd={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["EXP","BAND"],"\u{1F1F8}\u{1F1F1}":["TEST","SOS"],"\u{1F1E6}\u{1F1E9}":["AD","AND"],"\u{1F1E6}\u{1F1EA}":["AE","ARE"],"\u{1F1E6}\u{1F1EB}":["AF","AFG"],"\u{1F1E6}\u{1F1F1}":["AL","ALB"],"\u{1F1E6}\u{1F1F2}":["AM","ARM"],"\u{1F1E6}\u{1F1F7}":["AR","ARG"],"\u{1F1E6}\u{1F1F9}":["AT","AUT"],"\u{1F1E6}\u{1F1FA}":["AU","AUS"],"\u{1F1E6}\u{1F1FF}":["AZ","AZE"],"\u{1F1E7}\u{1F1E6}":["BA","BIH"],"\u{1F1E7}\u{1F1E9}":["BD","BGD"],"\u{1F1E7}\u{1F1EA}":["BE","BEL"],"\u{1F1E7}\u{1F1EC}":["BG","BGR"],"\u{1F1E7}\u{1F1ED}":["BH","BHR"],"\u{1F1E7}\u{1F1F4}":["BO","BOL"],"\u{1F1E7}\u{1F1F3}":["BN","BRN"],"\u{1F1E7}\u{1F1F7}":["BR","BRA"],"\u{1F1E7}\u{1F1F9}":["BT","BTN"],"\u{1F1E7}\u{1F1FE}":["BY","BLR"],"\u{1F1E8}\u{1F1E6}":["CA","CAN"],"\u{1F1E8}\u{1F1ED}":["CH","CHE"],"\u{1F1E8}\u{1F1F1}":["CL","CHL"],"\u{1F1E8}\u{1F1F4}":["CO","COL"],"\u{1F1E8}\u{1F1F7}":["CR","CRI"],"\u{1F1E8}\u{1F1FE}":["CY","CYP"],"\u{1F1E8}\u{1F1FF}":["CZ","CZE"],"\u{1F1E9}\u{1F1EA}":["DE","DEU"],"\u{1F1E9}\u{1F1F0}":["DK","DNK"],"\u{1F1EA}\u{1F1E8}":["EC","ECU"],"\u{1F1EA}\u{1F1EA}":["EE","EST"],"\u{1F1EA}\u{1F1EC}":["EG","EGY"],"\u{1F1EA}\u{1F1F8}":["ES","ESP"],"\u{1F1EA}\u{1F1FA}":["EU"],"\u{1F1EB}\u{1F1EE}":["FI","FIN"],"\u{1F1EB}\u{1F1F7}":["FR","FRA"],"\u{1F1EC}\u{1F1E7}":["GB","GBR","UK"],"\u{1F1EC}\u{1F1EA}":["GE","GEO"],"\u{1F1EC}\u{1F1F7}":["GR","GRC"],"\u{1F1EC}\u{1F1F9}":["GT","GTM"],"\u{1F1EC}\u{1F1FA}":["GU","GUM"],"\u{1F1ED}\u{1F1F0}":["HK","HKG","HKT","HKBN","HGC","WTT","CMI"],"\u{1F1ED}\u{1F1F7}":["HR","HRV"],"\u{1F1ED}\u{1F1FA}":["HU","HUN"],"\u{1F1EF}\u{1F1F4}":["JO","JOR"],"\u{1F1EF}\u{1F1F5}":["JP","JPN","TYO"],"\u{1F1F0}\u{1F1EA}":["KE","KEN"],"\u{1F1F0}\u{1F1EC}":["KG","KGZ"],"\u{1F1F0}\u{1F1ED}":["KH","KGZ"],"\u{1F1F0}\u{1F1F5}":["KP","PRK"],"\u{1F1F0}\u{1F1F7}":["KR","KOR","SEL"],"\u{1F1F0}\u{1F1FF}":["KZ","KAZ"],"\u{1F1EE}\u{1F1E9}":["ID","IDN"],"\u{1F1EE}\u{1F1EA}":["IE","IRL"],"\u{1F1EE}\u{1F1F1}":["IL","ISR"],"\u{1F1EE}\u{1F1F2}":["IM","IMN"],"\u{1F1EE}\u{1F1F3}":["IN","IND"],"\u{1F1EE}\u{1F1F7}":["IR","IRN"],"\u{1F1EE}\u{1F1F8}":["IS","ISL"],"\u{1F1EE}\u{1F1F9}":["IT","ITA"],"\u{1F1F1}\u{1F1E6}":["LA","LAO"],"\u{1F1F1}\u{1F1F0}":["LK","LKA"],"\u{1F1F1}\u{1F1F9}":["LT","LTU"],"\u{1F1F1}\u{1F1FA}":["LU","LUX"],"\u{1F1F1}\u{1F1FB}":["LV","LVA"],"\u{1F1F2}\u{1F1E6}":["MA","MAR"],"\u{1F1F2}\u{1F1E9}":["MD","MDA"],"\u{1F1F3}\u{1F1EC}":["NG","NGA"],"\u{1F1F2}\u{1F1F2}":["MM","MMR"],"\u{1F1F2}\u{1F1F0}":["MK","MKD"],"\u{1F1F2}\u{1F1F3}":["MN","MNG"],"\u{1F1F2}\u{1F1F4}":["MO","MAC","CTM"],"\u{1F1F2}\u{1F1F9}":["MT","MLT"],"\u{1F1F2}\u{1F1FD}":["MX","MEX"],"\u{1F1F2}\u{1F1FE}":["MY","MYS"],"\u{1F1F3}\u{1F1F1}":["NL","NLD","AMS"],"\u{1F1F3}\u{1F1F4}":["NO","NOR"],"\u{1F1F3}\u{1F1F5}":["NP","NPL"],"\u{1F1F3}\u{1F1FF}":["NZ","NZL"],"\u{1F1F5}\u{1F1E6}":["PA","PAN"],"\u{1F1F5}\u{1F1EA}":["PE","PER"],"\u{1F1F5}\u{1F1ED}":["PH","PHL"],"\u{1F1F5}\u{1F1F0}":["PK","PAK"],"\u{1F1F5}\u{1F1F1}":["PL","POL"],"\u{1F1F5}\u{1F1F7}":["PR","PRI"],"\u{1F1F5}\u{1F1F9}":["PT","PRT"],"\u{1F1F5}\u{1F1FE}":["PY","PRY"],"\u{1F1F5}\u{1F1EC}":["PG","PNG"],"\u{1F1F7}\u{1F1F4}":["RO","ROU"],"\u{1F1F7}\u{1F1F8}":["RS","SRB"],"\u{1F1F7}\u{1F1EA}":["RE","REU"],"\u{1F1F7}\u{1F1FA}":["RU","RUS"],"\u{1F1F8}\u{1F1E6}":["SA","SAU"],"\u{1F1F8}\u{1F1EA}":["SE","SWE"],"\u{1F1F8}\u{1F1EC}":["SG","SGP"],"\u{1F1F8}\u{1F1EE}":["SI","SVN"],"\u{1F1F8}\u{1F1F0}":["SK","SVK"],"\u{1F1F9}\u{1F1ED}":["TH","THA"],"\u{1F1F9}\u{1F1F3}":["TN","TUN"],"\u{1F1F9}\u{1F1F7}":["TR","TUR"],"\u{1F1F9}\u{1F1FC}":["TW","TWN","CHT","HINET","ROC"],"\u{1F1FA}\u{1F1E6}":["UA","UKR"],"\u{1F1FA}\u{1F1F8}":["US","USA","LAX","SFO","SJC"],"\u{1F1FA}\u{1F1FE}":["UY","URY"],"\u{1F1FB}\u{1F1EA}":["VE","VEN"],"\u{1F1FB}\u{1F1F3}":["VN","VNM"],"\u{1F1FF}\u{1F1E6}":["ZA","ZAF","JNB"],"\u{1F1E8}\u{1F1F3}":["CN","CHN","BACK"]};function Co(e){let t={"\u{1F3F3}\uFE0F\u200D\u{1F308}":["\u6D41\u91CF","\u65F6\u95F4","\u8FC7\u671F","Bandwidth","Expire"],"\u{1F1F8}\u{1F1F1}":["\u5E94\u6025","\u6D4B\u8BD5\u8282\u70B9"],"\u{1F1E6}\u{1F1E9}":["Andorra","\u5B89\u9053\u5C14"],"\u{1F1E6}\u{1F1EA}":["United Arab Emirates","\u963F\u8054\u914B","\u8FEA\u62DC"],"\u{1F1E6}\u{1F1EB}":["Afghanistan","\u963F\u5BCC\u6C57"],"\u{1F1E6}\u{1F1F1}":["Albania","\u963F\u5C14\u5DF4\u5C3C\u4E9A","\u963F\u723E\u5DF4\u5C3C\u4E9E"],"\u{1F1E6}\u{1F1F2}":["Armenia","\u4E9A\u7F8E\u5C3C\u4E9A"],"\u{1F1E6}\u{1F1F7}":["Argentina","\u963F\u6839\u5EF7"],"\u{1F1E6}\u{1F1F9}":["Austria","\u5965\u5730\u5229","\u5967\u5730\u5229","\u7EF4\u4E5F\u7EB3"],"\u{1F1E6}\u{1F1FA}":["Australia","\u6FB3\u5927\u5229\u4E9A","\u6FB3\u6D32","\u58A8\u5C14\u672C","\u6089\u5C3C","\u571F\u6FB3","\u4EAC\u6FB3","\u5EE3\u6FB3","\u6EEC\u6FB3","\u6CAA\u6FB3","\u5E7F\u6FB3","Sydney"],"\u{1F1E6}\u{1F1FF}":["Azerbaijan","\u963F\u585E\u62DC\u7586"],"\u{1F1E7}\u{1F1E6}":["Bosnia and Herzegovina","\u6CE2\u9ED1\u5171\u548C\u56FD","\u6CE2\u9ED1"],"\u{1F1E7}\u{1F1E9}":["Bangladesh","\u5B5F\u52A0\u62C9\u56FD","\u5B5F\u52A0\u62C9"],"\u{1F1E7}\u{1F1EA}":["Belgium","\u6BD4\u5229\u65F6","\u6BD4\u5229\u6642"],"\u{1F1E7}\u{1F1EC}":["Bulgaria","\u4FDD\u52A0\u5229\u4E9A","\u4FDD\u52A0\u5229\u4E9E"],"\u{1F1E7}\u{1F1ED}":["Bahrain","\u5DF4\u6797"],"\u{1F1E7}\u{1F1F7}":["Brazil","\u5DF4\u897F","\u5723\u4FDD\u7F57"],"\u{1F1E7}\u{1F1F3}":["Brunei","\u6587\u83B1","\u6C76\u840A"],"\u{1F1E7}\u{1F1FE}":["Belarus","\u767D\u4FC4\u7F57\u65AF","\u767D\u4FC4"],"\u{1F1E7}\u{1F1F4}":["Bolivia","\u73BB\u5229\u7EF4\u4E9A"],"\u{1F1E7}\u{1F1F9}":["Bhutan","\u4E0D\u4E39","\u4E0D\u4E39\u738B\u56FD"],"\u{1F1E8}\u{1F1E6}":["Canada","\u52A0\u62FF\u5927","\u8499\u7279\u5229\u5C14","\u6E29\u54E5\u534E","\u6953\u8449","\u67AB\u53F6","\u6ED1\u94C1\u5362","\u591A\u4F26\u591A","Waterloo","Toronto"],"\u{1F1E8}\u{1F1ED}":["Switzerland","\u745E\u58EB","\u82CF\u9ECE\u4E16","Zurich"],"\u{1F1E8}\u{1F1F1}":["Chile","\u667A\u5229"],"\u{1F1E8}\u{1F1F4}":["Colombia","\u54E5\u4F26\u6BD4\u4E9A"],"\u{1F1E8}\u{1F1F7}":["Costa Rica","\u54E5\u65AF\u8FBE\u9ECE\u52A0"],"\u{1F1E8}\u{1F1FE}":["Cyprus","\u585E\u6D66\u8DEF\u65AF"],"\u{1F1E8}\u{1F1FF}":["Czechia","\u6377\u514B"],"\u{1F1E9}\u{1F1EA}":["German","\u5FB7\u56FD","\u5FB7\u570B","\u4EAC\u5FB7","\u6EEC\u5FB7","\u5EE3\u5FB7","\u6CAA\u5FB7","\u5E7F\u5FB7","\u6CD5\u5170\u514B\u798F","Frankfurt","\u5FB7\u610F\u5FD7"],"\u{1F1E9}\u{1F1F0}":["Denmark","\u4E39\u9EA6","\u4E39\u9EA5"],"\u{1F1EA}\u{1F1E8}":["Ecuador","\u5384\u74DC\u591A\u5C14"],"\u{1F1EA}\u{1F1EA}":["Estonia","\u7231\u6C99\u5C3C\u4E9A"],"\u{1F1EA}\u{1F1EC}":["Egypt","\u57C3\u53CA"],"\u{1F1EA}\u{1F1F8}":["Spain","\u897F\u73ED\u7259"],"\u{1F1EA}\u{1F1FA}":["European Union","\u6B27\u76DF","\u6B27\u7F57\u5DF4"],"\u{1F1EB}\u{1F1EE}":["Finland","\u82AC\u5170","\u82AC\u862D","\u8D6B\u5C14\u8F9B\u57FA"],"\u{1F1EB}\u{1F1F7}":["France","\u6CD5\u56FD","\u6CD5\u570B","\u5DF4\u9ECE"],"\u{1F1EC}\u{1F1E7}":["Great Britain","\u82F1\u56FD","England","United Kingdom","\u4F26\u6566","\u82F1","London"],"\u{1F1EC}\u{1F1EA}":["Georgia","\u683C\u9C81\u5409\u4E9A","\u683C\u9B6F\u5409\u4E9E"],"\u{1F1EC}\u{1F1F7}":["Greece","\u5E0C\u814A","\u5E0C\u81D8"],"\u{1F1EC}\u{1F1FA}":["Guam","\u5173\u5C9B","\u95DC\u5CF6"],"\u{1F1EC}\u{1F1F9}":["Guatemala","\u5371\u5730\u9A6C\u62C9"],"\u{1F1ED}\u{1F1F0}":["Hongkong","\u9999\u6E2F","Hong Kong","HongKong","HONG KONG","\u6DF1\u6E2F","\u6CAA\u6E2F","\u547C\u6E2F","\u7A57\u6E2F","\u4EAC\u6E2F","\u6E2F"],"\u{1F1ED}\u{1F1F7}":["Croatia","\u514B\u7F57\u5730\u4E9A","\u514B\u7F85\u5730\u4E9E"],"\u{1F1ED}\u{1F1FA}":["Hungary","\u5308\u7259\u5229"],"\u{1F1EF}\u{1F1F4}":["Jordan","\u7EA6\u65E6"],"\u{1F1EF}\u{1F1F5}":["Japan","\u65E5\u672C","\u4E1C\u4EAC","\u5927\u962A","\u57FC\u7389","\u6CAA\u65E5","\u7A57\u65E5","\u5DDD\u65E5","\u4E2D\u65E5","\u6CC9\u65E5","\u676D\u65E5","\u6DF1\u65E5","\u8FBD\u65E5","\u5E7F\u65E5","\u5927\u5742","Osaka","Tokyo"],"\u{1F1F0}\u{1F1EA}":["Kenya","\u80AF\u5C3C\u4E9A"],"\u{1F1F0}\u{1F1EC}":["Kyrgyzstan","\u5409\u5C14\u5409\u65AF\u65AF\u5766"],"\u{1F1F0}\u{1F1ED}":["Cambodia","\u67EC\u57D4\u5BE8"],"\u{1F1F0}\u{1F1F5}":["North Korea","\u671D\u9C9C"],"\u{1F1F0}\u{1F1F7}":["Korea","\u97E9\u56FD","\u97D3\u570B","\u97E9","\u97D3","\u9996\u5C14","\u6625\u5DDD","Chuncheon","Seoul"],"\u{1F1F0}\u{1F1FF}":["Kazakhstan","\u54C8\u8428\u514B\u65AF\u5766","\u54C8\u8428\u514B"],"\u{1F1EE}\u{1F1E9}":["Indonesia","\u5370\u5C3C","\u5370\u5EA6\u5C3C\u897F\u4E9A","\u96C5\u52A0\u8FBE"],"\u{1F1EE}\u{1F1EA}":["Ireland","\u7231\u5C14\u5170","\u611B\u723E\u862D","\u90FD\u67CF\u6797"],"\u{1F1EE}\u{1F1F1}":["Israel","\u4EE5\u8272\u5217"],"\u{1F1EE}\u{1F1F2}":["Isle of Man","\u9A6C\u6069\u5C9B","\u99AC\u6069\u5CF6"],"\u{1F1EE}\u{1F1F3}":["India","\u5370\u5EA6","\u5B5F\u4E70","MFumbai","Mumbai"],"\u{1F1EE}\u{1F1F7}":["Iran","\u4F0A\u6717"],"\u{1F1EE}\u{1F1F8}":["Iceland","\u51B0\u5C9B","\u51B0\u5CF6"],"\u{1F1EE}\u{1F1F9}":["Italy","\u610F\u5927\u5229","\u7FA9\u5927\u5229","\u7C73\u5170","Nachash"],"\u{1F1F1}\u{1F1F0}":["Sri Lanka","\u65AF\u91CC\u5170\u5361","\u65AF\u91CC\u862D\u5361"],"\u{1F1F1}\u{1F1E6}":["Laos","\u8001\u631D","\u8001\u64BE"],"\u{1F1F1}\u{1F1F9}":["Lithuania","\u7ACB\u9676\u5B9B"],"\u{1F1F1}\u{1F1FA}":["Luxembourg","\u5362\u68EE\u5821"],"\u{1F1F1}\u{1F1FB}":["Latvia","\u62C9\u8131\u7EF4\u4E9A","Latvija"],"\u{1F1F2}\u{1F1E6}":["Morocco","\u6469\u6D1B\u54E5"],"\u{1F1F2}\u{1F1E9}":["Moldova","\u6469\u5C14\u591A\u74E6","\u6469\u723E\u591A\u74E6"],"\u{1F1F2}\u{1F1F2}":["Myanmar","\u7F05\u7538","\u7DEC\u7538"],"\u{1F1F3}\u{1F1EC}":["Nigeria","\u5C3C\u65E5\u5229\u4E9A","\u5C3C\u65E5\u5229\u4E9E"],"\u{1F1F2}\u{1F1F0}":["Macedonia","\u9A6C\u5176\u987F","\u99AC\u5176\u9813"],"\u{1F1F2}\u{1F1F3}":["Mongolia","\u8499\u53E4"],"\u{1F1F2}\u{1F1F4}":["Macao","\u6FB3\u95E8","\u6FB3\u9580","CTM"],"\u{1F1F2}\u{1F1F9}":["Malta","\u9A6C\u8033\u4ED6"],"\u{1F1F2}\u{1F1FD}":["Mexico","\u58A8\u897F\u54E5"],"\u{1F1F2}\u{1F1FE}":["Malaysia","\u9A6C\u6765","\u99AC\u4F86","\u5409\u9686\u5761","\u5927\u99AC"],"\u{1F1F3}\u{1F1F1}":["Netherlands","\u8377\u5170","\u8377\u862D","\u5C3C\u5FB7\u862D","\u963F\u59C6\u65AF\u7279\u4E39","Amsterdam"],"\u{1F1F3}\u{1F1F4}":["Norway","\u632A\u5A01"],"\u{1F1F3}\u{1F1F5}":["Nepal","\u5C3C\u6CCA\u5C14"],"\u{1F1F3}\u{1F1FF}":["New Zealand","\u65B0\u897F\u5170","\u65B0\u897F\u862D"],"\u{1F1F5}\u{1F1E6}":["Panama","\u5DF4\u62FF\u9A6C"],"\u{1F1F5}\u{1F1EA}":["Peru","\u79D8\u9C81","\u7955\u9B6F"],"\u{1F1F5}\u{1F1ED}":["Philippines","\u83F2\u5F8B\u5BBE","\u83F2\u5F8B\u8CD3"],"\u{1F1F5}\u{1F1F0}":["Pakistan","\u5DF4\u57FA\u65AF\u5766"],"\u{1F1F5}\u{1F1F1}":["Poland","\u6CE2\u5170","\u6CE2\u862D","\u534E\u6C99","Warsaw"],"\u{1F1F5}\u{1F1F7}":["Puerto Rico","\u6CE2\u591A\u9ECE\u5404"],"\u{1F1F5}\u{1F1F9}":["Portugal","\u8461\u8404\u7259"],"\u{1F1F5}\u{1F1EC}":["Papua New Guinea","\u5DF4\u5E03\u4E9A\u65B0\u51E0\u5185\u4E9A"],"\u{1F1F5}\u{1F1FE}":["Paraguay","\u5DF4\u62C9\u572D"],"\u{1F1F7}\u{1F1F4}":["Romania","\u7F57\u9A6C\u5C3C\u4E9A"],"\u{1F1F7}\u{1F1F8}":["Serbia","\u585E\u5C14\u7EF4\u4E9A"],"\u{1F1F7}\u{1F1EA}":["R\xE9union","\u7559\u5C3C\u6C6A","\u6CD5\u5C5E\u7559\u5C3C\u6C6A"],"\u{1F1F7}\u{1F1FA}":["Russia","\u4FC4\u7F57\u65AF","\u4FC4\u56FD","\u4FC4\u7F85\u65AF","\u4F2F\u529B","\u83AB\u65AF\u79D1","\u5723\u5F7C\u5F97\u5821","\u897F\u4F2F\u5229\u4E9A","\u4EAC\u4FC4","\u676D\u4FC4","\u5EE3\u4FC4","\u6EEC\u4FC4","\u5E7F\u4FC4","\u6CAA\u4FC4","Moscow"],"\u{1F1F8}\u{1F1E6}":["Saudi","\u6C99\u7279\u963F\u62C9\u4F2F","\u6C99\u7279","Riyadh","\u5229\u96C5\u5F97"],"\u{1F1F8}\u{1F1EA}":["Sweden","\u745E\u5178","\u65AF\u5FB7\u54E5\u5C14\u6469","Stockholm"],"\u{1F1F8}\u{1F1EC}":["Singapore","\u65B0\u52A0\u5761","\u72EE\u57CE","\u6CAA\u65B0","\u4EAC\u65B0","\u4E2D\u65B0","\u6CC9\u65B0","\u7A57\u65B0","\u6DF1\u65B0","\u676D\u65B0","\u5E7F\u65B0","\u5EE3\u65B0","\u6EEC\u65B0"],"\u{1F1F8}\u{1F1EE}":["Slovenia","\u65AF\u6D1B\u6587\u5C3C\u4E9A"],"\u{1F1F8}\u{1F1F0}":["Slovakia","\u65AF\u6D1B\u4F10\u514B"],"\u{1F1F9}\u{1F1ED}":["Thailand","\u6CF0\u56FD","\u6CF0\u570B","\u66FC\u8C37"],"\u{1F1F9}\u{1F1F3}":["Tunisia","\u7A81\u5C3C\u65AF"],"\u{1F1F9}\u{1F1F7}":["Turkey","\u571F\u8033\u5176","\u4F0A\u65AF\u5766\u5E03\u5C14","Istanbul"],"\u{1F1F9}\u{1F1FC}":["Taiwan","\u53F0\u6E7E","\u81FA\u7063","\u53F0\u7063","\u4E2D\u83EF\u6C11\u570B","\u4E2D\u534E\u6C11\u56FD","\u53F0\u5317","\u53F0\u4E2D","\u65B0\u5317","\u5F70\u5316","\u53F0","\u81FA","Taipei","Tai Wan"],"\u{1F1FA}\u{1F1E6}":["Ukraine","\u4E4C\u514B\u5170","\u70CF\u514B\u862D"],"\u{1F1FA}\u{1F1F8}":["United States","\u7F8E\u56FD","America","\u7F8E","\u4EAC\u7F8E","\u6CE2\u7279\u5170","\u8FBE\u62C9\u65AF","\u4FC4\u52D2\u5188","Oregon","\u51E4\u51F0\u57CE","\u8D39\u5229\u8499","\u7845\u8C37","\u77FD\u8C37","\u62C9\u65AF\u7EF4\u52A0\u65AF","\u6D1B\u6749\u77F6","\u5723\u4F55\u585E","\u5723\u514B\u62C9\u62C9","\u897F\u96C5\u56FE","\u829D\u52A0\u54E5","\u6CAA\u7F8E","\u54E5\u4F26\u5E03","\u7EBD\u7EA6","New York","Los Angeles","San Jose","Sillicon Valley","Michigan","\u4FC4\u4EA5\u4FC4","Ohio","\u9A6C\u7EB3\u8428\u65AF","Manassas","\u5F17\u5409\u5C3C\u4E9A","Virginia"],"\u{1F1FA}\u{1F1FE}":["Uruguay","\u4E4C\u62C9\u572D"],"\u{1F1FB}\u{1F1EA}":["Venezuela","\u59D4\u5185\u745E\u62C9"],"\u{1F1FB}\u{1F1F3}":["Vietnam","\u8D8A\u5357","\u80E1\u5FD7\u660E"],"\u{1F1FF}\u{1F1E6}":["South Africa","\u5357\u975E"],"\u{1F1E8}\u{1F1F3}":["China","\u4E2D\u56FD","\u4E2D\u570B","\u56DE\u56FD","\u56DE\u570B","\u56FD\u5185","\u570B\u5167","\u534E\u4E1C","\u534E\u897F","\u534E\u5357","\u534E\u5317","\u534E\u4E2D","\u6C5F\u82CF","\u5317\u4EAC","\u4E0A\u6D77","\u5E7F\u5DDE","\u6DF1\u5733","\u676D\u5DDE","\u5F90\u5DDE","\u9752\u5C9B","\u5B81\u6CE2","\u9547\u6C5F"]},r=e.match(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]/)?.[0]||"\u{1F3F4}\u200D\u2620\uFE0F";for(let n of Object.keys(t))if(t[n].some(a=>RegExp(`${a}`,"i").test(e)))return/内蒙古/.test(e)&&["\u{1F1F2}\u{1F1F3}"].includes(n)?r="\u{1F1E8}\u{1F1F3}":r=n;for(let n of Object.keys(Wd))if(Wd[n].some(a=>RegExp(`(^|[^a-zA-Z])${a}([^a-zA-Z]|$)`).test(e))&&!(n=="\u{1F1E8}\u{1F1F3}"&&RegExp("(^|[^a-zA-Z])CN2([^a-zA-Z]|$)").test(e)))return r=n;return r}function rw(e){return Wd[Co(e)]?.[0]}function Mc(e){return e.replace(/[\uD83C][\uDDE6-\uDDFF][\uD83C][\uDDE6-\uDDFF]|🏴‍☠️|🏳️‍🌈/g,"").trim()}var Jf=class{constructor({country,asn}={}){if(O.env.isNode){let Reader=eval('require("@maxmind/geoip2-node")').Reader,fs=eval("require('fs')"),countryFile=country||eval("process.env.SUB_STORE_MMDB_COUNTRY_PATH"),asnFile=asn||eval("process.env.SUB_STORE_MMDB_ASN_PATH");if(countryFile&&(this.countryReader=Reader.openBuffer(fs.readFileSync(countryFile))),asnFile){if(!fs.existsSync(asnFile))throw new Error("GeoLite2 ASN MMDB does not exist");this.asnReader=Reader.openBuffer(fs.readFileSync(asnFile))}}}geoip(e){return this.countryReader?.country(e)?.country?.isoCode}ipaso(e){return this.asnReader?.asn(e)?.autonomousSystemOrganization}ipasn(e){return this.asnReader?.asn(e)?.autonomousSystemNumber}};var eh=ei(pw()),dw=ei(Nf());async function _o({url:e,domain:t,type:r="A",timeout:n,edns:i}){let a=eh.default.encode({type:"query",id:0,flags:eh.default.RECURSION_DESIRED,questions:[{type:r,name:t}],additionals:[{type:"OPT",name:".",udpPayloadSize:4096,flags:0,options:[{code:"CLIENT_SUBNET",ip:i,sourcePrefixLength:fr(i)?24:56,scopePrefixLength:0}]}]}),s=await O.http.get({url:`${e}?dns=${a.toString("base64").toString("utf-8").replace(/=/g,"")}`,headers:{Accept:"application/dns-message"},"binary-mode":!0,encoding:null,timeout:n});return eh.default.decode(dw.Buffer.from(O.env.isQX?s.bodyBytes:s.body))}var u0=ei(s0());function eD(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Vc(e){return e.startsWith("<")&&e.endsWith(">")?e.slice(1,-1):e}function mw(e,t){let r=typeof t=="string"?JSON.parse(t):t;for(let n in r)if(eD(r[n]))if(n.endsWith("!")){let i=Vc(n.slice(0,-1));e[i]=r[n]}else{let i=Vc(n);e[i]||Object.assign(e,{[i]:{}}),mw(e[i],r[i])}else if(Array.isArray(r[n]))if(n.startsWith("+")){let i=Vc(n.slice(1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...r[n],...e[i]]}else if(n.endsWith("+")){let i=Vc(n.slice(0,-1));e[i]||Object.assign(e,{[i]:[]}),e[i]=[...e[i],...r[n]]}else{let i=Vc(n);Object.assign(e,{[i]:r[n]})}else Object.assign(e,{[n]:r[n]});return e}function tD({rule:e}){return{name:"Conditional Filter",func:t=>t.map(r=>th(e,r))}}function th(e,t){if(!e.operator)switch(e.proposition){case"IN":return e.value.indexOf(t[e.attr])!==-1;case"CONTAINS":return typeof t[e.attr]!="string"?!1:t[e.attr].indexOf(e.value)!==-1;case"EQUALS":return t[e.attr]===e.value;case"EXISTS":return t[e.attr]!==null||typeof t[e.attr]<"u";default:throw new Error(`Unknown proposition: ${e.proposition}`)}switch(e.operator){case"AND":return e.child.every(r=>th(r,t));case"OR":return e.child.some(r=>th(r,t));case"NOT":return!th(e.child,t);default:throw new Error(`Unknown operator: ${e.operator}`)}}function rD(e){return{name:"Quick Setting Operator",func:r=>{if(t(e.useless)){let i=Ew().func(r);r=r.filter((a,s)=>i[s]&&a.port>0&&a.port<=65535)}return r.map(n=>(n.udp=t(e.udp,n.udp),n.tfo=t(e.tfo,n.tfo),n["fast-open"]=t(e.tfo,n["fast-open"]),n["skip-cert-verify"]=t(e.scert,n["skip-cert-verify"]),n.type==="vmess"&&(n.aead=t(e["vmess aead"],n.aead)),n))}};function t(r,n){switch(r){case"ENABLED":return!0;case"DISABLED":return!1;default:return n}}}function nD({mode:e,tw:t}){return{name:"Flag Operator",func:r=>r.map(n=>{if(e==="remove")n.name=Mc(n.name);else{let i=Co(n.name);n.name=Mc(n.name),n.name=i+" "+n.name,t=="ws"?n.name=n.name.replace(/🇹🇼/g,"\u{1F1FC}\u{1F1F8}"):t=="tw"||(n.name=n.name.replace(/🇹🇼/g,"\u{1F1E8}\u{1F1F3}"))}return n})}}function iD(e){let{action:t,template:r,link:n,position:i}={action:"rename",template:"0 1 2 3 4 5 6 7 8 9",link:"-",position:"back",...e};return{name:"Handle Duplicate Operator",func:a=>{if(t==="delete"){let s={};return a.filter(c=>s[c.name]?!1:(s[c.name]=!0,!0))}else if(t==="rename"){let s=r.split(" "),c={},l=0;a.forEach(v=>{typeof c[v.name]>"u"?c[v.name]=1:c[v.name]++,l=Math.max(c[v.name].toString().length,l)});let h={};return a.map(v=>{if(c[v.name]>1){typeof h[v.name]>"u"&&(h[v.name]=1);let E="",p=h[v.name]++,f=0;for(;p>0;)E=s[p%10]+E,p=parseInt(p/10),f++;for(;f++{switch(e){case"asc":case"desc":return t.sort((r,n)=>{let i=r.name>n.name?1:-1;return i*=e==="desc"?-1:1,i});case"random":return mD(t);default:throw new Error("Unknown sort option: "+e)}}}}function aD(e){let t=e.order||"asc",r=e.expressions;return Array.isArray(e)&&(r=e),Array.isArray(r)||(r=[]),{name:"Regex Sort Operator",func:n=>(r=r.map(i=>o0(i)),n.sort((i,a)=>{let s=gw(r,i.name),c=gw(r,a.name);return s&&!c?-1:c&&!s?1:s&&c?st.map(r=>{for(let{expr:n,now:i}of e)r.name=r.name.replace(o0(n,"g"),i).trim();return r})}}function uD(e){let t=e.map(r=>({expr:r,now:""}));return{name:"Regex Delete Operator",func:vw(t).func}}function oD(e,t,r,n,i){return{name:"Script Operator",func:async a=>{let s=a;if(s?.$file?.type==="mihomoProfile")try{let c=su.safeLoad(e),l;if(s?.$content)try{l=su.safeLoad(s?.$content)}catch(h){O.error(h.message??h)}if(typeof c!="object")throw new Error("patch is not an object");return s.$content=Un.yaml.safeDump(mw(l||(s?.$file?.sourceType==="none"?{}:{proxies:await la({type:s?.$file?.sourceType||"collection",name:s?.$file?.sourceName,platform:"mihomo",produceType:"internal",produceOpts:{"delete-underscore-fields":!0}})}),c)),s}catch{}return await async function(){s=rh("operator",e,r,i)(a,t,{source:n,...ra})}(),s},nodeFunc:async a=>{let s=a;return await async function(){s=rh("operator",`async function operator(input = []) { if (input && (input.$files || input.$content)) { let { $content, $files, $options, $file } = input if($file.type === 'mihomoProfile') { ${e} if(typeof main === 'function') { let config; if ($content) { try { config = ProxyUtils.yaml.safeLoad($content); } catch (e) { console.log(e.message ?? e); } } $content = ProxyUtils.yaml.safeDump(await main(config || ($file.sourceType === 'none' ? {} : { proxies: await produceArtifact({ type: $file.sourceType || 'collection', name: $file.sourceName, platform: 'mihomo', produceType: 'internal', produceOpts: { 'delete-underscore-fields': true } }), }))) } } else { ${e} } return { $content, $files, $options, $file } } else { let proxies = input let list = [] for await (let $server of proxies) { ${e} list.push($server) } return list } }`,r,i)(a,t,{source:n,...ra})}(),s}}}function cD(e){let t,r;try{let n=e.split(":");r=parseInt(n[2],16);let i=parseInt(n[3],16),a=parseInt(n[4],16),s=i>>8,c=i&255,l=a>>8,h=a&255;if(t=`${s}.${c}.${l}.${h}`,r<=0||r>65535)throw new Error(`Invalid port number: ${r}`);if(!fr(t))throw new Error(`Invalid IP address: ${t}`)}catch(n){O.error(`IP4P \u89E3\u6790\u5931\u8D25: ${n}`)}return{server:t,port:r}}var ww={Custom:async function(e,t,r,n,i,a){let s=Tn(`CUSTOM:${a}:${e}:${t}`),c=ar.get(s);if(!r&&c)return c;let l=t==="IPv6"?"AAAA":"A",h=await _o({url:a,domain:e,type:l,timeout:n,edns:i}),{answers:v}=h;if(!Array.isArray(v)||v.length===0)throw new Error("No answers");let E=v.filter(p=>p?.type===l).map(p=>p?.data).filter(p=>p);if(E.length===0)throw new Error("No answers");return ar.set(s,E),E},Google:async function(e,t,r,n,i){let a=Tn(`GOOGLE:${e}:${t}`),s=ar.get(a);if(!r&&s)return s;let c=t==="IPv6"?"AAAA":"A",l=await _o({url:"https://8.8.4.4/dns-query",domain:e,type:c,timeout:n,edns:i}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let v=h.filter(E=>E?.type===c).map(E=>E?.data).filter(E=>E);if(v.length===0)throw new Error("No answers");return ar.set(a,v),v},"IP-API":async function(e,t,r,n){if(["IPv6"].includes(t))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 IP-API \u4E0D\u652F\u6301 ${t}`);let i=Tn(`IP-API:${e}`),a=ar.get(i);if(!r&&a)return a;let s=await O.http.get({url:`http://ip-api.com/json/${encodeURIComponent(e)}?lang=zh-CN`,timeout:n}),c=JSON.parse(s.body);if(c.status!=="success")throw new Error(`Status is ${c.status}`);if(!c.query||c.query===0)throw new Error("No answers");let l=[c.query];if(l.length===0)throw new Error("No answers");return ar.set(i,l),l},Cloudflare:async function(e,t,r,n,i){let a=Tn(`CLOUDFLARE:${e}:${t}`),s=ar.get(a);if(!r&&s)return s;let c=t==="IPv6"?"AAAA":"A",l=await _o({url:"https://1.0.0.1/dns-query",domain:e,type:c,timeout:n,edns:i}),{answers:h}=l;if(!Array.isArray(h)||h.length===0)throw new Error("No answers");let v=h.filter(E=>E?.type===c).map(E=>E?.data).filter(E=>E);if(v.length===0)throw new Error("No answers");return ar.set(a,v),v},Ali:async function(e,t,r,n,i){let a=Tn(`ALI:${e}:${t}`),s=ar.get(a);if(!r&&s)return s;let c=await O.http.get({url:`http://223.6.6.6/resolve?edns_client_subnet=${i}/24&name=${encodeURIComponent(e)}&type=${t==="IPv6"?"AAAA":"A"}&short=1`,headers:{accept:"application/dns-json"},timeout:n}),l=JSON.parse(c.body);if(!Array.isArray(l)||l.length===0)throw new Error("No answers");let h=l;if(h.length===0)throw new Error("No answers");return ar.set(a,h),h},Tencent:async function(e,t,r,n,i){let a=Tn(`TENCENT:${e}:${t}`),s=ar.get(a);if(!r&&s)return s;let l=(await O.http.get({url:`http://119.28.28.28/d?ip=${i}&type=${t==="IPv6"?"AAAA":"A"}&dn=${encodeURIComponent(e)}`,headers:{accept:"application/dns-json"},timeout:n})).body.split(";").map(v=>v.split(",")[0]);if(l.length===0||String(l)==="0")throw new Error("No answers");let h=l;if(h.length===0)throw new Error("No answers");return ar.set(a,h),h}};function Aw({provider:e,type:t,filter:r,cache:n,url:i,timeout:a,edns:s}){if(["IPv6","IP4P"].includes(t)&&["IP-API"].includes(e))throw new Error(`\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9 ${e} \u4E0D\u652F\u6301 ${t}`);let{defaultTimeout:c}=O.read(Et),l=a||c||8e3,h=["IPv6","IP4P"].includes(t)?"IPv6":"IPv4",v=ww[e];if(!v)throw new Error(`\u627E\u4E0D\u5230\u57DF\u540D\u89E3\u6790\u670D\u52A1\u63D0\u4F9B\u65B9: ${e}`);let E=s||"223.6.6.6";if(!fu(E))throw new Error("\u57DF\u540D\u89E3\u6790 EDNS \u5E94\u4E3A IP");return O.info(`Domain Resolver: [${t}] ${e} ${E||""} ${i||""}`),{name:"Resolve Domain Operator",func:async p=>{p.forEach((w,S)=>{!w["_no-resolve"]&&w["no-resolve"]&&(p[S]["_no-resolve"]=w["no-resolve"])});let f={},A=15,g=[...new Set(p.filter(w=>!fu(w.server)&&!w["_no-resolve"]).map(w=>w.server))],y=Math.ceil(g.length/A);for(let w=0;w{f[_]=I,O.info(`Successfully resolved domain: ${_} \u279F ${I}`)}).catch(I=>{O.error(`Failed to resolve domain: ${_} with resolver [${e}]: ${I}`)}));await Promise.all(S)}return p.forEach(w=>{if(!w["_no-resolve"])if(f[w.server]){w._resolved_ips=f[w.server];let S=Array.isArray(f[w.server])?f[w.server][Math.floor(Math.random()*f[w.server].length)]:f[w.server];if(h==="IPv6"&&hr(S)){try{S=new lf.Address6(S).correctForm()}catch(_){O.error(`Failed to parse IPv6 address: ${S}: ${_}`)}if(/^2001::[^:]+:[^:]+:[^:]+$/.test(S)){w._IP4P=S;let{server:_,port:I}=cD(S);_&&I?(w._domain=w.server,w.server=_,w.port=I,w.resolved=!0,w._IPv4=w.server,fu(w._IP)||(w._IP=w.server)):w.resolved||(w.resolved=!1)}else w._domain=w.server,w.server=S,w.resolved=!0,w[`_${h}`]=w.server,fu(w._IP)||(w._IP=w.server)}else w._domain=w.server,w.server=S,w.resolved=!0,w[`_${h}`]=w.server,fu(w._IP)||(w._IP=w.server)}else w.resolved||(w.resolved=!1)}),p.filter(w=>r==="removeFailed"?fu(w.server)||w["_no-resolve"]||w.resolved:r==="IPOnly"?fu(w.server):r==="IPv4Only"?fr(w.server):r==="IPv6Only"?hr(w.server):!0)}}}function fu(e){return fr(e)||hr(e)}Aw.resolver=ww;function a0(e){var t=/^[\x00-\x7F]+$/;return t.test(e)}function Ew(){return{name:"Useless Filter",func:e=>e.map(t=>{if(t.cipher&&!a0(t.cipher))return!1;if(t.password&&!a0(t.password))return!1;if(t.network){let r=t[`${t.network}-opts`]?.headers?.Host||t[`${t.network}-opts`]?.headers?.host;if(r=Array.isArray(r)?r:[r],r.some(n=>n&&!a0(n)))return!1}return!/网址|流量|时间|应急|过期|Bandwidth|expire/.test(t.name)})}}function lD(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0,n={HK:"\u{1F1ED}\u{1F1F0}",TW:"\u{1F1F9}\u{1F1FC}",US:"\u{1F1FA}\u{1F1F8}",SG:"\u{1F1F8}\u{1F1EC}",JP:"\u{1F1EF}\u{1F1F5}",UK:"\u{1F1EC}\u{1F1E7}",DE:"\u{1F1E9}\u{1F1EA}",KR:"\u{1F1F0}\u{1F1F7}"};return{name:"Region Filter",func:i=>i.map(a=>{let s=Co(a.name),c=t.some(l=>n[l]===s);return r?c:!c})}}function fD({regex:e=[],keep:t=!0}){return{name:"Regex Filter",func:r=>r.map(n=>{let i=e.some(a=>o0(a).test(n.name));return t?i:!i})}}function o0(e,...t){return t=t.join(""),e.startsWith("(?i)")?(e=e.substring(4),new RegExp(e,"i"+t)):new RegExp(e,t)}function hD(e){let t=e?.value||e;Array.isArray(t)||(t=[]);let r=e?.keep??!0;return{name:"Type Filter",func:n=>n.map(i=>{let a=t.some(s=>i.type===s);return r?a:!a})}}function pD(e,t,r,n,i){return{name:"Script Filter",func:async a=>{let s=Xf(a.length,!0);return await async function(){s=rh("filter",e,r,i)(a,t,{source:n,...ra})}(),s},nodeFunc:async a=>{let s=Xf(a.length,!0);return await async function(){s=rh("filter",`async function filter(input = []) { let proxies = input let list = [] const fn = async ($server) => { ${e} } for await (let $server of proxies) { list.push(await fn($server)) } return list }`,r,i)(a,t,{source:n,...ra})}(),s}}}var nh={"Useless Filter":Ew,"Region Filter":lD,"Regex Filter":fD,"Type Filter":hD,"Script Filter":pD,"Conditional Filter":tD,"Quick Setting Operator":rD,"Flag Operator":nD,"Sort Operator":sD,"Regex Sort Operator":aD,"Regex Rename Operator":vw,"Regex Delete Operator":uD,"Script Operator":oD,"Handle Duplicate Operator":iD,"Resolve Domain Operator":Aw};async function dD(e,t){let r=Xf(t.length,!0);try{r=await e.func(t)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")?i="":(O.error(`Cannot apply filter ${e.name}(function filter)! Reason: ${n}`),i=`\u6267\u884C function filter \u5931\u8D25 ${a}; `);try{r=await e.nodeFunc(t)}catch(s){O.error(`Cannot apply filter ${e.name}(shortcut script)! Reason: ${s}`);let c="",l=`${s.message??s}`;throw i&&l===a?(c="",i=`\u6267\u884C\u5931\u8D25 ${a}`):c=`\u6267\u884C\u5FEB\u6377\u8FC7\u6EE4\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u8FC7\u6EE4 ${i}${c}`)}}return t.filter((n,i)=>r[i])}async function gD(e,t){let r=vD(t);try{let n=await e.func(r);n&&(r=n)}catch(n){let i="",a=`${n.message??n}`;a.includes("$server is not defined")||a.includes("$content is not defined")||a.includes("$files is not defined")||r?.$files||r?.$content?i="":(O.error(`Cannot apply operator ${e.name}(function operator)! Reason: ${n}`),i=`\u6267\u884C function operator \u5931\u8D25 ${a}; `);try{let s=await e.nodeFunc(r);s&&(r=s)}catch(s){O.error(`Cannot apply operator ${e.name}(shortcut script)! Reason: ${s}`);let c="",l=`${s.message??s}`;throw i&&l===a?(c="",i=`\u6267\u884C\u5931\u8D25 ${a}`):c=`\u6267\u884C\u5FEB\u6377\u811A\u672C \u5931\u8D25 ${l}`,new Error(`\u811A\u672C\u64CD\u4F5C ${i}${c}`)}}return r}async function yw(e,t){if(e.name.indexOf("Filter")!==-1)return dD(e,t);if(e.name.indexOf("Operator")!==-1)return gD(e,t)}function mD(e){let t=e.length,r,n;for(;t!==0;)n=Math.floor(Math.random()*t),t-=1,r=e[t],e[t]=e[n],e[n]=r;return e}function vD(e){return JSON.parse(JSON.stringify(e))}function rh(name,script,$arguments,$options){let flowUtils={getFlowField:ro,getFlowHeaders:Oi,parseFlowHeaders:Xa,flowTransfer:_c,validCheck:pf,getRmainingDays:df,normalizeFlowHeader:gf};return O.env.isLoon?new Function("$arguments","$options","$substore","lodash","$persistentStore","$httpClient","$notification","ProxyUtils","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,O,u0.default,$persistentStore,$httpClient,$notification,Un,Ic,flowUtils,la,eval('typeof require !== "undefined"')?ja:void 0):new Function("$arguments","$options","$substore","lodash","ProxyUtils","scriptResourceCache","flowUtils","produceArtifact","require",`${script} return ${name}`)($arguments,$options,O,u0.default,Un,Ic,flowUtils,la,eval('typeof require !== "undefined"')?ja:void 0)}var Sw=ei(s0()),Ze=class{constructor(t){this.proxy=t,this.output=[]}append(t){if(typeof t>"u")throw new Error("required field is missing");this.output.push(t)}appendIfPresent(t,r){ae(this.proxy,r)&&this.append(t)}toString(){return this.output.join("")}};function ae(e,t){let r=Sw.default.get(e,t);return typeof r<"u"&&r!==null}var wD="Surge",ui={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function Do(){return{produce:(t,r,n={})=>{switch(t.name=t.name.replace(/=|,/g,""),t.ports&&(t.ports=String(t.ports)),t.type){case"ss":return AD(t,n["include-unsupported-proxy"]);case"trojan":return ED(t);case"vmess":return yD(t,n["include-unsupported-proxy"]);case"http":return bD(t);case"direct":return CD(t);case"socks5":return FD(t);case"snell":return _D(t);case"tuic":return ID(t);case"wireguard-surge":return BD(t);case"hysteria2":return PD(t);case"ssh":return SD(t)}if(n["include-unsupported-proxy"]&&t.type==="wireguard")return DD(t);throw new Error(`Platform ${wD} does not support proxy type: ${t.type}`)}}}function AD(e){let t=new Ze(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),e.cipher||(e.cipher="none"),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","none","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ui[e["ip-version"]]||e["ip-version"];if(t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),ae(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}return t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function ED(e){let t=new Ze(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password");let r=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),bw(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function yD(e,t){let r=new Ze(e);r.append(`${e.name}=${e.type},${e.server},${e.port}`),r.appendIfPresent(`,username=${e.uuid}`,"uuid");let n=ui[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-version=${n}`,"ip-version"),r.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),bw(r,e,t),ae(e,"aead")?r.append(`,vmess-aead=${e.aead}`):r.append(`,vmess-aead=${e.alterId===0}`),r.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),r.appendIfPresent(`,tls=${e.tls}`,"tls"),r.appendIfPresent(`,sni=${e.sni}`,"sni"),r.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),r.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),r.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),r.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),r.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),r.appendIfPresent(`,tos=${e.tos}`,"tos"),r.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),r.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),r.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),r.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),r.toString()}function SD(e){let t=new Ze(e);t.append(`${e.name}=ssh,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,private-key=${e["keystore-private-key"]}`,"keystore-private-key"),t.appendIfPresent(`,idle-timeout=${e["idle-timeout"]}`,"idle-timeout"),t.appendIfPresent(`,server-fingerprint="${e["server-fingerprint"]}"`,"server-fingerprint");let r=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function bD(e){if(e.headers&&Object.keys(e.headers).length>0)throw new Error("headers is unsupported");let t=new Ze(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function CD(e){let t=new Ze(e);t.append(`${e.name}=direct`);let n=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function FD(e){let t=new Ze(e),r=e.tls?"socks5-tls":"socks5";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password");let n=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e.tfo&&O.info("Option tfo is not supported by Surge, thus omitted"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function _D(e){let t=new Ze(e);t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,version=${e.version}`,"version"),t.appendIfPresent(`,psk=${e.psk}`,"psk");let r=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,obfs=${e["obfs-opts"]?.mode}`,"obfs-opts.mode"),t.appendIfPresent(`,obfs-host=${e["obfs-opts"]?.host}`,"obfs-opts.host"),t.appendIfPresent(`,obfs-uri=${e["obfs-opts"]?.path}`,"obfs-opts.path"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,reuse=${e.reuse}`,"reuse"),t.toString()}function ID(e){let t=new Ze(e),r=e.type;(!e.token||e.token.length===0)&&(r="tuic-v5"),t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,uuid=${e.uuid}`,"uuid"),t.appendIfPresent(`,password="${e.password}"`,"password"),t.appendIfPresent(`,token=${e.token}`,"token"),t.appendIfPresent(`,alpn=${Array.isArray(e.alpn)?e.alpn[0]:e.alpn}`,"alpn"),ae(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let n=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${n}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function DD(e){Array.isArray(e.peers)&&e.peers.length>0&&(e.server=e.peers[0].server,e.port=e.peers[0].port,e.ip=e.peers[0].ip,e.ipv6=e.peers[0].ipv6,e["public-key"]=e.peers[0]["public-key"],e["preshared-key"]=e.peers[0]["pre-shared-key"],e["allowed-ips"]=e.peers[0]["allowed-ips"],e.reserved=e.peers[0].reserved);let t=new Ze(e);t.append(`# > WireGuard Proxy ${e.name} # ${e.name}=wireguard`),e["section-name"]=qt(e["section-name"],e.name),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert");let r=ui[e["ip-version"]]||e["ip-version"];t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.append(` # > WireGuard Section ${e.name} [WireGuard ${e["section-name"]}] private-key = ${e["private-key"]}`),t.appendIfPresent(` self-ip = ${e.ip}`,"ip"),t.appendIfPresent(` self-ip-v6 = ${e.ipv6}`,"ipv6"),e.dns&&(Array.isArray(e.dns)&&(e.dns=e.dns.join(", ")),t.append(` dns-server = ${e.dns}`)),t.appendIfPresent(` mtu = ${e.mtu}`,"mtu"),r==="prefer-v6"&&t.append(` prefer-ipv6 = true`);let n=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],i=Array.isArray(e.reserved)?e.reserved.join("/"):e.reserved,a=e["preshared-key"]??e["pre-shared-key"];a&&(a=`,preshared-key="${a}"`);let s={"public-key":e["public-key"],"allowed-ips":n?`"${n}"`:void 0,endpoint:`${e.server}:${e.port}`,keepalive:e["persistent-keepalive"]||e.keepalive,"client-id":i,"preshared-key":a};return t.append(` peer = (${Object.keys(s).filter(c=>s[c]!=null).map(c=>`${c} = ${s[c]}`).join(", ")})`),t.toString()}function BD(e){let t=new Ze(e);t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert");let r=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.toString()}function PD(e){if(e.obfs||e["obfs-password"])throw new Error("obfs is unsupported");let t=new Ze(e);t.append(`${e.name}=hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,password="${e.password}"`,"password"),ae(e,"ports")&&t.append(`,port-hopping="${e.ports.replace(/,/g,";")}"`),t.appendIfPresent(`,port-hopping-interval=${e["hop-interval"]}`,"hop-interval");let r=ui[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-version=${r}`,"ip-version"),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,server-cert-fingerprint-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,test-timeout=${e["test-timeout"]}`,"test-timeout"),t.appendIfPresent(`,test-udp=${e["test-udp"]}`,"test-udp"),t.appendIfPresent(`,hybrid=${e.hybrid}`,"hybrid"),t.appendIfPresent(`,tos=${e.tos}`,"tos"),t.appendIfPresent(`,allow-other-interface=${e["allow-other-interface"]}`,"allow-other-interface"),t.appendIfPresent(`,interface=${e["interface-name"]}`,"interface-name"),ae(e,"shadow-tls-password")&&(t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni")),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.appendIfPresent(`,underlying-proxy=${e["underlying-proxy"]}`,"underlying-proxy"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn"),t.toString()}function bw(e,t,r){if(ae(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ae(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ae(t,"ws-opts.headers"))){let n=t["ws-opts"].headers,i=Object.keys(n).map(a=>{let s=n[a];return["Host"].includes(a)&&(s=`"${s}"`),`${a}:${s}`}).join("|");xi(i)&&e.append(`,ws-headers=${i}`)}}else if(r&&["http"].includes(t.network))O.info(`Include Unsupported Proxy: nework ${t.network} -> tcp`);else throw new Error(`network ${t.network} is unsupported`)}function Hn(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&String(s.version)==="4"||["juicity"].includes(s.type)?!1:!(["ss"].includes(s.type)&&!["aes-128-ctr","aes-192-ctr","aes-256-ctr","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-ccm","aes-192-ccm","aes-256-ccm","aes-128-gcm-siv","aes-256-gcm-siv","chacha20-ietf","chacha20","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","chacha8-ietf-poly1305","xchacha8-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm","2022-blake3-chacha20-poly1305","lea-128-gcm","lea-192-gcm","lea-256-gcm","rabbit128-poly1305","aegis-128l","aegis-256","aez-384","deoxys-ii-256-128","rc4-md5","none"].includes(s.cipher))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ae(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ae(s,"shadow-tls-password")&&!ae(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let c=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(c)&&(s["http-opts"].path=[c]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let c=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(c)&&(s["h2-opts"].path=c[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal"||i["delete-underscore-fields"])for(let c in s)(s[c]==null||/^_/i.test(c))&&delete s[c];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var Cw="SurgeMac",$D=Do();function c0(){return{produce:(t,r,n={})=>{switch(t.type){case"external":return Fw(t);default:try{return $D.produce(t,r,n)}catch{if(n.useMihomoExternal)return O.log(`${t.name} is not supported on ${Cw}, try to use Mihomo(SurgeMac - External Proxy Program) instead`),RD(t,r,n);throw new Error("Surge for macOS \u53EF\u624B\u52A8\u6307\u5B9A\u94FE\u63A5\u53C2\u6570 target=SurgeMac \u6216\u5728 \u540C\u6B65\u914D\u7F6E \u4E2D\u6307\u5B9A SurgeMac \u6765\u542F\u7528 mihomo \u652F\u63F4 Surge \u672C\u8EAB\u4E0D\u652F\u6301\u7684\u534F\u8BAE")}}}}}function Fw(e){let t=new Ze(e);if(!e.exec||!e["local-port"])throw new Error(`${e.type}: exec and local-port are required`);return t.append(`${e.name}=external,exec="${e.exec}",local-port=${e["local-port"]}`),Array.isArray(e.args)&&e.args.map(r=>{t.append(`,args="${r}"`)}),Array.isArray(e.addresses)&&e.addresses.map(r=>{t.append(`,addresses=${r}`)}),t.appendIfPresent(`,no-error-alert=${e["no-error-alert"]}`,"no-error-alert"),ae(e,"tfo")?t.append(`,tfo=${e.tfo}`):ae(e,"fast-open")&&t.append(`,tfo=${e["fast-open"]}`),t.appendIfPresent(`,test-url=${e["test-url"]}`,"test-url"),t.appendIfPresent(`,block-quic=${e["block-quic"]}`,"block-quic"),t.toString()}function RD(e,t,r){let n=Hn().produce([e],"internal")?.[0];if(n){let i=r?.localPort||e._localPort||65535,a=!["ipv4","v4-only"].includes(e["ip-version"]),s={name:e.name,type:"external",exec:e._exec||"/usr/local/bin/mihomo","local-port":i,args:["-config",yt.encode(JSON.stringify({"mixed-port":i,ipv6:a,mode:"global",dns:{enable:!0,ipv6:a,"default-nameserver":r?.defaultNameserver||e._defaultNameserver||["180.76.76.76","52.80.52.52","119.28.28.28","223.6.6.6"],nameserver:r?.nameserver||e._nameserver||["https://doh.pub/dns-query","https://dns.alidns.com/dns-query","https://doh-pure.onedns.net/dns-query"]},proxies:[{...n,name:"proxy"}],"proxy-groups":[{name:"GLOBAL",type:"select",proxies:["proxy"]}]}))],addresses:[]};return TD(e.server)?s.addresses.push(e.server):O.log(`Platform ${Cw}, proxy type ${e.type}: addresses should be an IP address, but got ${e.server}`),r.localPort=i-1,Fw(s)}}function TD(e){return fr(e)||hr(e)}function l0(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:!(!["ss","ssr","vmess","vless","socks5","http","snell","trojan","wireguard"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305"].includes(s.cipher)||s.type==="snell"&&String(s.version)==="4"||s.type==="vless"&&(typeof s.flow<"u"||s["reality-opts"]))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ae(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let c=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(c)&&(s["http-opts"].path=[c]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let c=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(c)&&(s["h2-opts"].path=c[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let c in s)(s[c]==null||/^_/i.test(c))&&delete s[c];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}function ih(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>!(!["ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","wireguard","hysteria","hysteria2","ssh","juicity"].includes(s.type)||s.type==="ss"&&!["aes-128-gcm","aes-192-gcm","aes-256-gcm","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","rc4-md5","chacha20-ietf","xchacha20","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(s.cipher)||s.type==="snell"&&String(s.version)==="4"||(i["include-unsupported-proxy"]?s.type==="vless"&&s["reality-opts"]&&!["xtls-rprx-vision"].includes(s.flow):s.type==="vless"&&s["reality-opts"]))).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","aes-128-gcm","chacha20-poly1305","none"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ae(s,"down")&&!ae(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ae(s,"up")&&!ae(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ae(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ae(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="hysteria2"?(ae(s,"password")&&!ae(s,"auth")&&(s.auth=s.password,delete s.password),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo,delete s.tfo),ae(s,"down")&&!ae(s,"down-speed")&&(s["down-speed"]=s.down,delete s.down),ae(s,"up")&&!ae(s,"up-speed")&&(s["up-speed"]=s.up,delete s.up),ae(s,"down-speed")&&(s["down-speed"]=`${s["down-speed"]}`.match(/\d+/)?.[0]||0),ae(s,"up-speed")&&(s["up-speed"]=`${s["up-speed"]}`.match(/\d+/)?.[0]||0)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"&&ae(s,"sni")&&(s.servername=s.sni,delete s.sni),["vmess","vless"].includes(s.type)&&s.network==="http"){let c=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(c)&&(s["http-opts"].path=[c]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let c=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(c)&&(s["h2-opts"].path=c[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s["server-cert-fingerprint"]=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,s["test-url"]&&(s["benchmark-url"]=s["test-url"],delete s["test-url"]),s["test-timeout"]&&(s["benchmark-timeout"]=s["test-timeout"],delete s["test-timeout"]),delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let c in s)(s[c]==null||/^_/i.test(c))&&delete s[c];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var xD="Loon",Os={dual:"dual",ipv4:"v4-only",ipv6:"v6-only","ipv4-prefer":"prefer-v4","ipv6-prefer":"prefer-v6"};function f0(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return OD(t);case"ssr":return ND(t);case"trojan":return kD(t);case"vmess":return LD(t,n["include-unsupported-proxy"]);case"vless":return UD(t,n["include-unsupported-proxy"]);case"http":return HD(t);case"socks5":return jD(t);case"wireguard":return MD(t);case"hysteria2":return qD(t)}throw new Error(`Platform ${xD} does not support proxy type: ${t.type}`)}}}function OD(e){let t=new Ze(e);if(!["rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`${e.name}=shadowsocks,${e.server},${e.port},${e.cipher},"${e.password}"`),ae(e,"plugin")){if(e.plugin==="obfs")t.append(`,obfs-name=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else if(!["shadow-tls"].includes(e.plugin))throw new Error(`plugin ${e.plugin} is not supported`)}if(ae(e,"shadow-tls-password"))t.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),t.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),t.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let n=e["plugin-opts"].password,i=e["plugin-opts"].host,a=e["plugin-opts"].version;if(n){if(t.append(`,shadow-tls-password=${n}`),i&&t.append(`,shadow-tls-sni=${i}`),a){if(a<2)throw new Error(`shadow-tls version ${a} is not supported`);t.append(`,shadow-tls-version=${a}`)}t.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Os[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function ND(e,t){let r=new Ze(e);if(r.append(`${e.name}=shadowsocksr,${e.server},${e.port},${e.cipher},"${e.password}"`),r.append(`,protocol=${e.protocol}`),r.appendIfPresent(`,protocol-param=${e["protocol-param"]}`,"protocol-param"),r.appendIfPresent(`,obfs=${e.obfs}`,"obfs"),r.appendIfPresent(`,obfs-param=${e["obfs-param"]}`,"obfs-param"),ae(e,"shadow-tls-password"))r.append(`,shadow-tls-password=${e["shadow-tls-password"]}`),r.appendIfPresent(`,shadow-tls-version=${e["shadow-tls-version"]}`,"shadow-tls-version"),r.appendIfPresent(`,shadow-tls-sni=${e["shadow-tls-sni"]}`,"shadow-tls-sni"),r.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port");else if(["shadow-tls"].includes(e.plugin)&&e["plugin-opts"]){let i=e["plugin-opts"].password,a=e["plugin-opts"].host,s=e["plugin-opts"].version;if(i){if(r.append(`,shadow-tls-password=${i}`),a&&r.append(`,shadow-tls-sni=${a}`),s){if(s<2)throw new Error(`shadow-tls version ${s} is not supported`);r.append(`,shadow-tls-version=${s}`)}r.appendIfPresent(`,udp-port=${e["udp-port"]}`,"udp-port")}}r.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&r.append(",udp=true");let n=Os[e["ip-version"]]||e["ip-version"];return r.appendIfPresent(`,ip-mode=${n}`,"ip-version"),r.toString()}function kD(e){let t=new Ze(e);if(t.append(`${e.name}=trojan,${e.server},${e.port},"${e.password}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")t.append(",transport=ws"),t.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),t.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Os[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function LD(e,t){if(!t&&e["reality-opts"])throw new Error("VMess REALITY is not supported");let r=!1;t&&e["reality-opts"]&&(r=!0);let n=new Ze(e);if(n.append(`${e.name}=vmess,${e.server},${e.port},${e.cipher},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")n.append(",transport=ws"),n.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),n.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){n.append(",transport=http");let a=e["http-opts"]?.path,s=e["http-opts"]?.headers?.Host;n.appendIfPresent(`,path=${Array.isArray(a)?a[0]:a}`,"http-opts.path"),n.appendIfPresent(`,host=${Array.isArray(s)?s[0]:s}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else n.append(",transport=tcp");n.appendIfPresent(`,over-tls=${e.tls}`,"tls"),n.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r?(n.appendIfPresent(`,sni=${e.sni}`,"sni"),n.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),n.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(n.appendIfPresent(`,tls-name=${e.sni}`,"sni"),n.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),ae(e,"aead")?n.append(",alterId=0"):n.append(`,alterId=${e.alterId}`),n.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&n.append(",udp=true");let i=Os[e["ip-version"]]||e["ip-version"];return n.appendIfPresent(`,ip-mode=${i}`,"ip-version"),n.toString()}function UD(e,t){if(!t&&(typeof e.flow<"u"||e["reality-opts"]))throw new Error("VLESS XTLS/REALITY is not supported");let r=!1,n=!1;if(t&&(e["reality-opts"]&&(n=!0),typeof e.flow<"u"))if(["xtls-rprx-vision"].includes(e.flow))r=!0;else throw new Error(`VLESS flow(${e.flow}) is not supported`);let i=new Ze(e);if(i.append(`${e.name}=vless,${e.server},${e.port},"${e.uuid}"`),e.network==="tcp"&&delete e.network,ae(e,"network"))if(e.network==="ws")i.append(",transport=ws"),i.appendIfPresent(`,path=${e["ws-opts"]?.path}`,"ws-opts.path"),i.appendIfPresent(`,host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else if(e.network==="http"){i.append(",transport=http");let s=e["http-opts"]?.path,c=e["http-opts"]?.headers?.Host;i.appendIfPresent(`,path=${Array.isArray(s)?s[0]:s}`,"http-opts.path"),i.appendIfPresent(`,host=${Array.isArray(c)?c[0]:c}`,"http-opts.headers.Host")}else throw new Error(`network ${e.network} is unsupported`);else i.append(",transport=tcp");i.appendIfPresent(`,over-tls=${e.tls}`,"tls"),i.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),r&&i.appendIfPresent(`,flow=${e.flow}`,"flow"),n?(i.appendIfPresent(`,sni=${e.sni}`,"sni"),i.appendIfPresent(`,public-key="${e["reality-opts"]["public-key"]}"`,"reality-opts.public-key"),i.appendIfPresent(`,short-id=${e["reality-opts"]["short-id"]}`,"reality-opts.short-id")):(i.appendIfPresent(`,tls-name=${e.sni}`,"sni"),i.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),i.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256")),i.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&i.append(",udp=true");let a=Os[e["ip-version"]]||e["ip-version"];return i.appendIfPresent(`,ip-mode=${a}`,"ip-version"),i.toString()}function HD(e){let t=new Ze(e),r=e.tls?"https":"http";t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo");let n=Os[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${n}`,"ip-version"),t.toString()}function jD(e){let t=new Ze(e);t.append(`${e.name}=socks5,${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,over-tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true");let r=Os[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function MD(e){Array.isArray(e.peers)&&e.peers.length>0&&(e.server=e.peers[0].server,e.port=e.peers[0].port,e.ip=e.peers[0].ip,e.ipv6=e.peers[0].ipv6,e["public-key"]=e.peers[0]["public-key"],e["preshared-key"]=e.peers[0]["pre-shared-key"],e["allowed-ips"]=e.peers[0]["allowed-ips"],e.reserved=e.peers[0].reserved);let t=new Ze(e);if(t.append(`${e.name}=wireguard`),t.appendIfPresent(`,interface-ip=${e.ip}`,"ip"),t.appendIfPresent(`,interface-ipv6=${e.ipv6}`,"ipv6"),t.appendIfPresent(`,private-key="${e["private-key"]}"`,"private-key"),t.appendIfPresent(`,mtu=${e.mtu}`,"mtu"),e.dns&&Array.isArray(e.dns)){e.dnsv6=e.dns.find(c=>hr(c));let s=e.dns.find(c=>fr(c));s||(s=e.dns.find(c=>!fr(c)&&!hr(c))),e.dns=s}t.appendIfPresent(`,dns=${e.dns}`,"dns"),t.appendIfPresent(`,dnsv6=${e.dnsv6}`,"dnsv6"),t.appendIfPresent(`,keepalive=${e["persistent-keepalive"]}`,"persistent-keepalive"),t.appendIfPresent(`,keepalive=${e.keepalive}`,"keepalive");let r=Array.isArray(e["allowed-ips"])?e["allowed-ips"].join(","):e["allowed-ips"],n=Array.isArray(e.reserved)?e.reserved.join(","):e.reserved;n&&(n=`,reserved=[${n}]`);let i=e["preshared-key"]??e["pre-shared-key"];i&&(i=`,preshared-key="${i}"`),t.append(`,peers=[{public-key="${e["public-key"]}",allowed-ips="${r??"0.0.0.0/0,::/0"}",endpoint=${e.server}:${e.port}${n??""}${i??""}}]`);let a=Os[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${a}`,"ip-version"),t.toString()}function qD(e){if(e["obfs-password"]&&e.obfs!="salamander")throw new Error("only salamander obfs is supported");let t=new Ze(e);t.append(`${e.name}=Hysteria2,${e.server},${e.port}`),t.appendIfPresent(`,"${e.password}"`,"password"),t.appendIfPresent(`,tls-name=${e.sni}`,"sni"),t.appendIfPresent(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),t.appendIfPresent(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),e["obfs-password"]&&e.obfs=="salamander"&&t.append(`,salamander-password=${e["obfs-password"]}`),t.appendIfPresent(`,fast-open=${e.tfo}`,"tfo"),e.udp&&t.append(",udp=true"),t.appendIfPresent(`,download-bandwidth=${`${e.down}`.match(/\d+/)?.[0]||0}`,"down"),t.appendIfPresent(`,ecn=${e.ecn}`,"ecn");let r=Os[e["ip-version"]]||e["ip-version"];return t.appendIfPresent(`,ip-mode=${r}`,"ip-version"),t.toString()}function Bo(){return{type:"SINGLE",produce:r=>{let n="";delete r.subName,delete r.collectionName,delete r.id,delete r.resolved,delete r["no-resolve"];for(let i in r)(r[i]==null||/^_/i.test(i))&&delete r[i];switch(["trojan","tuic","hysteria","hysteria2","juicity"].includes(r.type)&&delete r.tls,!["vmess"].includes(r.type)&&r.server&&hr(r.server)&&(r.server=`[${r.server}]`),r.type){case"socks5":n=`socks://${encodeURIComponent(yt.encode(`${r.username}:${r.password}`))}@${r.server}:${r.port}#${r.name}`;break;case"ss":let i=`${r.cipher}:${r.password}`;if(n=`ss://${r.cipher?.startsWith("2022-blake3-")?`${encodeURIComponent(r.cipher)}:${encodeURIComponent(r.password)}`:yt.encode(i)}@${r.server}:${r.port}${r.plugin?"/":""}`,r.plugin){n+="?plugin=";let ce=r["plugin-opts"];switch(r.plugin){case"obfs":n+=encodeURIComponent(`simple-obfs;obfs=${ce.mode}${ce.host?";obfs-host="+ce.host:""}`);break;case"v2ray-plugin":n+=encodeURIComponent(`v2ray-plugin;obfs=${ce.mode}${ce.host?";obfs-host"+ce.host:""}${ce.tls?";tls":""}`);break;case"shadow-tls":n+=encodeURIComponent(`shadow-tls;host=${ce.host};password=${ce.password};version=${ce.version}`);break;default:throw new Error(`Unsupported plugin option: ${r.plugin}`)}}r["udp-over-tcp"]&&(n=`${n}${r.plugin?"&":"?"}uot=1`),r.tfo&&(n=`${n}${r.plugin||r["udp-over-tcp"]?"&":"?"}tfo=1`),n+=`#${encodeURIComponent(r.name)}`;break;case"ssr":n=`${r.server}:${r.port}:${r.protocol}:${r.cipher}:${r.obfs}:${yt.encode(r.password)}/`,n+=`?remarks=${yt.encode(r.name)}${r["obfs-param"]?"&obfsparam="+yt.encode(r["obfs-param"]):""}${r["protocol-param"]?"&protocolparam="+yt.encode(r["protocol-param"]):""}`,n="ssr://"+yt.encode(n);break;case"vmess":let a="",s=r.network||"tcp";if(r.network==="http"?(s="tcp",a="http"):r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(s="httpupgrade"),n={v:"2",ps:r.name,add:r.server,port:r.port,id:r.uuid,type:a,aid:r.alterId||0,net:s,tls:r.tls?"tls":""},r.tls&&r.sni&&(n.sni=r.sni),r.network){let ce=r[`${r.network}-opts`]?.path,_e=r[`${r.network}-opts`]?.headers?.Host;ce&&(n.path=Array.isArray(ce)?ce[0]:ce),_e&&(n.host=Array.isArray(_e)?_e[0]:_e),["grpc"].includes(r.network)&&(n.path=r[`${r.network}-opts`]?.["grpc-service-name"],n.type=r[`${r.network}-opts`]?.["_grpc-type"]||"gun",n.host=r[`${r.network}-opts`]?.["_grpc-authority"])}n="vmess://"+yt.encode(JSON.stringify(n));break;case"vless":let c="none",l=r["reality-opts"],h="",v="",E="";if(l){c="reality";let ce=r["reality-opts"]?.["public-key"];ce&&(v=`&pbk=${encodeURIComponent(ce)}`);let _e=r["reality-opts"]?.["short-id"];_e&&(h=`&sid=${encodeURIComponent(_e)}`);let ke=r["reality-opts"]?.["_spider-x"];ke&&(E=`&spx=${encodeURIComponent(ke)}`)}else r.tls&&(c="tls");let p="";r.alpn&&(p=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let f="";r["skip-cert-verify"]&&(f="&allowInsecure=1");let A="";r.sni&&(A=`&sni=${encodeURIComponent(r.sni)}`);let g="";r["client-fingerprint"]&&(g=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let y="";r.flow&&(y=`&flow=${encodeURIComponent(r.flow)}`);let w="";r._extra&&(w=`&extra=${encodeURIComponent(r._extra)}`);let S="";r._mode&&(S=`&mode=${encodeURIComponent(r._mode)}`);let _=r.network;r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(_="httpupgrade");let I=`&type=${encodeURIComponent(_)}`;if(["grpc"].includes(r.network)){I+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`;let ce=r[`${r.network}-opts`]?.["_grpc-authority"];ce&&(I+=`&authority=${encodeURIComponent(ce)}`)}let B=r[`${r.network}-opts`]?.[`${r.network}-service-name`],q=r[`${r.network}-opts`]?.path,z=r[`${r.network}-opts`]?.headers?.Host;q&&(I+=`&path=${encodeURIComponent(Array.isArray(q)?q[0]:q)}`),z&&(I+=`&host=${encodeURIComponent(Array.isArray(z)?z[0]:z)}`),B&&(I+=`&serviceName=${encodeURIComponent(B)}`),r.network==="kcp"&&(r.seed&&(I+=`&seed=${encodeURIComponent(r.seed)}`),r.headerType&&(I+=`&headerType=${encodeURIComponent(r.headerType)}`)),n=`vless://${r.uuid}@${r.server}:${r.port}?security=${encodeURIComponent(c)}${I}${p}${f}${A}${g}${y}${h}${E}${v}${S}${w}#${encodeURIComponent(r.name)}`;break;case"trojan":let F="";if(r.network){let ce=r.network;if(r.network==="ws"&&r["ws-opts"]?.["v2ray-http-upgrade"]&&(ce="httpupgrade"),F=`&type=${encodeURIComponent(ce)}`,["grpc"].includes(r.network)){let mr=r[`${r.network}-opts`]?.[`${r.network}-service-name`],xt=r[`${r.network}-opts`]?.["_grpc-authority"];mr&&(F+=`&serviceName=${encodeURIComponent(mr)}`),xt&&(F+=`&authority=${encodeURIComponent(xt)}`),F+=`&mode=${encodeURIComponent(r[`${r.network}-opts`]?.["_grpc-type"]||"gun")}`}let _e=r[`${r.network}-opts`]?.path,ke=r[`${r.network}-opts`]?.headers?.Host;_e&&(F+=`&path=${encodeURIComponent(Array.isArray(_e)?_e[0]:_e)}`),ke&&(F+=`&host=${encodeURIComponent(Array.isArray(ke)?ke[0]:ke)}`)}let P="";r["client-fingerprint"]&&(P=`&fp=${encodeURIComponent(r["client-fingerprint"])}`);let L="";r.alpn&&(L=`&alpn=${encodeURIComponent(Array.isArray(r.alpn)?r.alpn:r.alpn.join(","))}`);let H=r["reality-opts"],K="",Z="",G="",V="",X="",ie="";if(H){V="&security=reality";let ce=r["reality-opts"]?.["public-key"];ce&&(Z=`&pbk=${encodeURIComponent(ce)}`);let _e=r["reality-opts"]?.["short-id"];_e&&(K=`&sid=${encodeURIComponent(_e)}`);let ke=r["reality-opts"]?.["_spider-x"];ke&&(G=`&spx=${encodeURIComponent(ke)}`),r._extra&&(ie=`&extra=${encodeURIComponent(r._extra)}`),r._mode&&(X=`&mode=${encodeURIComponent(r._mode)}`)}n=`trojan://${r.password}@${r.server}:${r.port}?sni=${encodeURIComponent(r.sni||r.server)}${r["skip-cert-verify"]?"&allowInsecure=1":""}${F}${L}${P}${V}${K}${Z}${G}${X}${ie}#${encodeURIComponent(r.name)}`;break;case"hysteria2":let Se=[];r["hop-interval"]&&Se.push(`hop-interval=${r["hop-interval"]}`),r.keepalive&&Se.push(`keepalive=${r.keepalive}`),r["skip-cert-verify"]&&Se.push("insecure=1"),r.obfs&&(Se.push(`obfs=${encodeURIComponent(r.obfs)}`),r["obfs-password"]&&Se.push(`obfs-password=${encodeURIComponent(r["obfs-password"])}`)),r.sni&&Se.push(`sni=${encodeURIComponent(r.sni)}`),r.ports&&Se.push(`mport=${r.ports}`),r["tls-fingerprint"]&&Se.push(`pinSHA256=${encodeURIComponent(r["tls-fingerprint"])}`),r.tfo&&Se.push("fastopen=1"),n=`hysteria2://${encodeURIComponent(r.password)}@${r.server}:${r.port}?${Se.join("&")}#${encodeURIComponent(r.name)}`;break;case"hysteria":let Ee=[];Object.keys(r).forEach(ce=>{if(!["name","type","server","port"].includes(ce)){let _e=ce.replace(/-/,"_");["alpn"].includes(ce)?r[ce]&&Ee.push(`${_e}=${encodeURIComponent(Array.isArray(r[ce])?r[ce][0]:r[ce])}`):["skip-cert-verify"].includes(ce)?r[ce]&&Ee.push("insecure=1"):["tfo","fast-open"].includes(ce)?r[ce]&&!Ee.includes("fastopen=1")&&Ee.push("fastopen=1"):["ports"].includes(ce)?Ee.push(`mport=${r[ce]}`):["auth-str"].includes(ce)?Ee.push(`auth=${r[ce]}`):["up"].includes(ce)?Ee.push(`upmbps=${r[ce]}`):["down"].includes(ce)?Ee.push(`downmbps=${r[ce]}`):["_obfs"].includes(ce)?Ee.push(`obfs=${r[ce]}`):["obfs"].includes(ce)?Ee.push(`obfsParam=${r[ce]}`):["sni"].includes(ce)?Ee.push(`peer=${r[ce]}`):r[ce]&&Ee.push(`${_e}=${encodeURIComponent(r[ce])}`)}}),n=`hysteria://${r.server}:${r.port}?${Ee.join("&")}#${encodeURIComponent(r.name)}`;break;case"tuic":if(!r.token||r.token.length===0){let ce=[];Object.keys(r).forEach(_e=>{if(!["name","type","uuid","password","server","port","tls"].includes(_e)){let ke=_e.replace(/-/,"_");["alpn"].includes(_e)?r[_e]&&ce.push(`${ke}=${encodeURIComponent(Array.isArray(r[_e])?r[_e][0]:r[_e])}`):["skip-cert-verify"].includes(_e)?r[_e]&&ce.push("allow_insecure=1"):["tfo","fast-open"].includes(_e)?r[_e]&&!ce.includes("fast_open=1")&&ce.push("fast_open=1"):["disable-sni","reduce-rtt"].includes(_e)&&r[_e]?ce.push(`${ke.replace(/-/g,"_")}=1`):r[_e]&&ce.push(`${ke.replace(/-/g,"_")}=${encodeURIComponent(r[_e])}`)}}),n=`tuic://${encodeURIComponent(r.uuid)}:${encodeURIComponent(r.password)}@${r.server}:${r.port}?${ce.join("&")}#${encodeURIComponent(r.name)}`}break;case"anytls":let Pe=[];Object.keys(r).forEach(ce=>{if(!["name","type","password","server","port","tls"].includes(ce)){let _e=ce.replace(/-/,"_");["alpn"].includes(ce)?r[ce]&&Pe.push(`${_e}=${encodeURIComponent(Array.isArray(r[ce])?r[ce][0]:r[ce])}`):["skip-cert-verify"].includes(ce)?r[ce]&&Pe.push("insecure=1"):r[ce]&&Pe.push(`${_e.replace(/-/g,"_")}=${encodeURIComponent(r[ce])}`)}}),n=`anytls://${encodeURIComponent(r.password)}@${r.server}:${r.port}/?${Pe.join("&")}#${encodeURIComponent(r.name)}`;break;case"wireguard":let qe=[];Object.keys(r).forEach(ce=>{["name","type","server","port","ip","ipv6","private-key"].includes(ce)||(["public-key"].includes(ce)?qe.push(`publickey=${r[ce]}`):["udp"].includes(ce)?r[ce]&&qe.push(`${ce}=1`):r[ce]&&qe.push(`${ce}=${encodeURIComponent(r[ce])}`))}),r.ip&&r.ipv6?qe.push(`address=${r.ip}/32,${r.ipv6}/128`):r.ip?qe.push(`address=${r.ip}/32`):r.ipv6&&qe.push(`address=${r.ipv6}/128`),n=`wireguard://${encodeURIComponent(r["private-key"])}@${r.server}:${r.port}/?${qe.join("&")}#${encodeURIComponent(r.name)}`;break}return n}}}var KD=Bo();function Gc(){return{type:"ALL",produce:r=>{let n=[];return r.map(i=>{try{n.push(KD.produce(i))}catch(a){O.error(`Cannot produce proxy: ${JSON.stringify(i,null,2)} Reason: ${a}`)}}),yt.encode(n.join(` `))}}}var VD="QX";function zc(){return{produce:(t,r,n={})=>{switch(t.type){case"ss":return GD(t,n["include-unsupported-proxy"]);case"ssr":return zD(t);case"trojan":return YD(t);case"vmess":return WD(t);case"http":return JD(t);case"socks5":return ZD(t);case"vless":return XD(t)}throw new Error(`Platform ${VD} does not support proxy type: ${t.type}`)}}}function GD(e,t){let r=new Ze(e),n=r.append.bind(r),i=r.appendIfPresent.bind(r);if(e.cipher||(e.cipher="none"),!["none","rc4-md5","rc4-md5-6","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","cast5-cfb","des-cfb","rc2-cfb","salsa20","chacha20","chacha20-ietf","aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305",...t?["2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"]:[]].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(n(`shadowsocks=${e.server}:${e.port}`),n(`,method=${e.cipher}`),n(`,password=${e.password}`),jn(e)&&(e.tls=!0),ae(e,"plugin")){if(e.plugin==="obfs"){let a=e["plugin-opts"];n(`,obfs=${a.mode}`)}else if(e.plugin==="v2ray-plugin"&&e["plugin-opts"].mode==="websocket")e["plugin-opts"].tls?n(",obfs=wss"):n(",obfs=ws");else throw new Error("plugin is not supported");i(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),i(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path")}return jn(e)&&(i(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),i(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),i(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),i(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),i(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),i(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),i(`,tls-host=${e.sni}`,"sni")),i(`,fast-open=${e.tfo}`,"tfo"),i(`,udp-relay=${e.udp}`,"udp"),r.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),n(`,tag=${e.name}`),r.toString()}function zD(e){let t=new Ze(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);return r(`shadowsocks=${e.server}:${e.port}`),r(`,method=${e.cipher}`),r(`,password=${e.password}`),r(`,ssr-protocol=${e.protocol}`),n(`,ssr-protocol-param=${e["protocol-param"]}`,"protocol-param"),n(`,obfs=${e.obfs}`,"obfs"),n(`,obfs-host=${e["obfs-param"]}`,"obfs-param"),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function YD(e){let t=new Ze(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`trojan=${e.server}:${e.port}`),r(`,password=${e.password}`),ae(e,"network"))if(e.network==="ws")jn(e)?r(",obfs=wss"):r(",obfs=ws"),n(`,obfs-uri=${e["ws-opts"]?.path}`,"ws-opts.path"),n(`,obfs-host=${e["ws-opts"]?.headers?.Host}`,"ws-opts.headers.Host");else throw new Error(`network ${e.network} is unsupported`);return e.network!=="ws"&&jn(e)&&r(",over-tls=true"),jn(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function WD(e){let t=new Ze(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);r(`vmess=${e.server}:${e.port}`);let i;if(e.cipher==="auto"?i="chacha20-ietf-poly1305":i=e.cipher,r(`,method=${i}`),r(`,password=${e.uuid}`),jn(e)&&(e.tls=!0),ae(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return jn(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),ae(e,"aead")?r(`,aead=${e.aead}`):r(`,aead=${e.alterId===0}`),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function XD(e){if(typeof e.flow<"u"||e["reality-opts"])throw new Error("VLESS XTLS/REALITY is not supported");let t=new Ze(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);if(r(`vless=${e.server}:${e.port}`),r(",method=none"),r(`,password=${e.uuid}`),jn(e)&&(e.tls=!0),ae(e,"network")){if(e.network==="ws")e.tls?r(",obfs=wss"):r(",obfs=ws");else if(e.network==="http")r(",obfs=http");else if(!["tcp"].includes(e.network))throw new Error(`network ${e.network} is unsupported`);let a=e[`${e.network}-opts`]?.path,s=e[`${e.network}-opts`]?.headers?.Host;n(`,obfs-uri=${Array.isArray(a)?a[0]:a}`,`${e.network}-opts.path`),n(`,obfs-host=${Array.isArray(s)?s[0]:s}`,`${e.network}-opts.headers.Host`)}else e.tls&&r(",obfs=over-tls");return jn(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function JD(e){let t=new Ze(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);return r(`http=${e.server}:${e.port}`),n(`,username=${e.username}`,"username"),n(`,password=${e.password}`,"password"),jn(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),jn(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function ZD(e){let t=new Ze(e),r=t.append.bind(t),n=t.appendIfPresent.bind(t);return r(`socks5=${e.server}:${e.port}`),n(`,username=${e.username}`,"username"),n(`,password=${e.password}`,"password"),jn(e)&&(e.tls=!0),n(`,over-tls=${e.tls}`,"tls"),jn(e)&&(n(`,tls-pubkey-sha256=${e["tls-pubkey-sha256"]}`,"tls-pubkey-sha256"),n(`,tls-alpn=${e["tls-alpn"]}`,"tls-alpn"),n(`,tls-no-session-ticket=${e["tls-no-session-ticket"]}`,"tls-no-session-ticket"),n(`,tls-no-session-reuse=${e["tls-no-session-reuse"]}`,"tls-no-session-reuse"),n(`,tls-cert-sha256=${e["tls-fingerprint"]}`,"tls-fingerprint"),n(`,tls-verification=${!e["skip-cert-verify"]}`,"skip-cert-verify"),n(`,tls-host=${e.sni}`,"sni")),n(`,fast-open=${e.tfo}`,"tfo"),n(`,udp-relay=${e.udp}`,"udp"),t.appendIfPresent(`,server_check_url=${e["test-url"]}`,"test-url"),r(`,tag=${e.name}`),t.toString()}function jn(e){return e.tls}function Yc(){return{type:"ALL",produce:(r,n,i={})=>{let a=r.filter(s=>i["include-unsupported-proxy"]?!0:s.type==="snell"&&String(s.version)==="4"?!1:!["mieru","anytls"].includes(s.type)).map(s=>{if(s.type==="vmess"?(ae(s,"aead")&&(s.aead&&(s.alterId=0),delete s.aead),ae(s,"sni")&&(s.servername=s.sni,delete s.sni),ae(s,"cipher")&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(s.cipher)&&(s.cipher="auto")):s.type==="tuic"?(ae(s,"alpn")?s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]:s.alpn=["h3"],ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo),(!s.token||s.token.length===0)&&!ae(s,"version")&&(s.version=5)):s.type==="hysteria"?(ae(s,"auth_str")&&!ae(s,"auth-str")&&(s["auth-str"]=s.auth_str),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="hysteria2"?(s["obfs-password"]&&s.obfs=="salamander"&&(s.obfs=s["obfs-password"],delete s["obfs-password"]),ae(s,"alpn")&&(s.alpn=Array.isArray(s.alpn)?s.alpn:[s.alpn]),ae(s,"tfo")&&!ae(s,"fast-open")&&(s["fast-open"]=s.tfo)):s.type==="wireguard"?(s.keepalive=s.keepalive??s["persistent-keepalive"],s["persistent-keepalive"]=s.keepalive,s["preshared-key"]=s["preshared-key"]??s["pre-shared-key"],s["pre-shared-key"]=s["preshared-key"]):s.type==="snell"&&s.version<3?delete s.udp:s.type==="vless"?ae(s,"sni")&&(s.servername=s.sni,delete s.sni):s.type==="ss"&&ae(s,"shadow-tls-password")&&!ae(s,"plugin")&&(s.plugin="shadow-tls",s["plugin-opts"]={host:s["shadow-tls-sni"],password:s["shadow-tls-password"],version:s["shadow-tls-version"]},delete s["shadow-tls-password"],delete s["shadow-tls-sni"],delete s["shadow-tls-version"]),["vmess","vless"].includes(s.type)&&s.network==="http"){let c=s["http-opts"]?.path;ae(s,"http-opts.path")&&!Array.isArray(c)&&(s["http-opts"].path=[c]);let l=s["http-opts"]?.headers?.Host;ae(s,"http-opts.headers.Host")&&!Array.isArray(l)&&(s["http-opts"].headers.Host=[l])}if(["vmess","vless"].includes(s.type)&&s.network==="h2"){let c=s["h2-opts"]?.path;ae(s,"h2-opts.path")&&Array.isArray(c)&&(s["h2-opts"].path=c[0]);let l=s["h2-opts"]?.headers?.host;ae(s,"h2-opts.headers.Host")&&!Array.isArray(l)&&(s["h2-opts"].headers.host=[l])}if(s["plugin-opts"]?.tls&&ae(s,"skip-cert-verify")&&(s["plugin-opts"]["skip-cert-verify"]=s["skip-cert-verify"]),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(s.type)&&delete s.tls,s["tls-fingerprint"]&&(s.fingerprint=s["tls-fingerprint"]),delete s["tls-fingerprint"],s["underlying-proxy"]&&(s["dialer-proxy"]=s["underlying-proxy"]),delete s["underlying-proxy"],ae(s,"tls")&&typeof s.tls!="boolean"&&delete s.tls,delete s.subName,delete s.collectionName,delete s.id,delete s.resolved,delete s["no-resolve"],n!=="internal")for(let c in s)(s[c]==null||/^_/i.test(c))&&delete s[c];return["grpc"].includes(s.network)&&s[`${s.network}-opts`]&&(delete s[`${s.network}-opts`]["_grpc-type"],delete s[`${s.network}-opts`]["_grpc-authority"]),s});return n==="internal"?a:`proxies: `+a.map(s=>" - "+JSON.stringify(s)+` `).join("")}}}var QD="Surfboard";function sh(){return{produce:t=>{switch(t.name=t.name.replace(/=|,/g,""),t.type){case"ss":return eB(t);case"trojan":return tB(t);case"vmess":return rB(t);case"http":return nB(t);case"socks5":return iB(t);case"wireguard-surge":return sB(t)}throw new Error(`Platform ${QD} does not support proxy type: ${t.type}`)}}}function eB(e){let t=new Ze(e);if(t.append(`${e.name}=${e.type},${e.server},${e.port}`),!["aes-128-gcm","aes-192-gcm","aes-256-gcm","chacha20-ietf-poly1305","xchacha20-ietf-poly1305","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","salsa20","chacha20","chacha20-ietf"].includes(e.cipher))throw new Error(`cipher ${e.cipher} is not supported`);if(t.append(`,encrypt-method=${e.cipher}`),t.appendIfPresent(`,password=${e.password}`,"password"),ae(e,"plugin"))if(e.plugin==="obfs")t.append(`,obfs=${e["plugin-opts"].mode}`),t.appendIfPresent(`,obfs-host=${e["plugin-opts"].host}`,"plugin-opts.host"),t.appendIfPresent(`,obfs-uri=${e["plugin-opts"].path}`,"plugin-opts.path");else throw new Error(`plugin ${e.plugin} is not supported`);return t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function tB(e){let t=new Ze(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,password=${e.password}`,"password"),_w(t,e),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,tfo=${e.tfo}`,"tfo"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function rB(e){let t=new Ze(e);return t.append(`${e.name}=${e.type},${e.server},${e.port}`),t.appendIfPresent(`,username=${e.uuid}`,"uuid"),_w(t,e),ae(e,"aead")?t.append(`,vmess-aead=${e.aead}`):t.append(`,vmess-aead=${e.alterId===0}`),t.appendIfPresent(`,tls=${e.tls}`,"tls"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function nB(e){let t=new Ze(e),r=e.tls?"https":"http";return t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,${e.password}`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function iB(e){let t=new Ze(e),r=e.tls?"socks5-tls":"socks5";return t.append(`${e.name}=${r},${e.server},${e.port}`),t.appendIfPresent(`,${e.username}`,"username"),t.appendIfPresent(`,${e.password}`,"password"),t.appendIfPresent(`,sni=${e.sni}`,"sni"),t.appendIfPresent(`,skip-cert-verify=${e["skip-cert-verify"]}`,"skip-cert-verify"),t.appendIfPresent(`,udp-relay=${e.udp}`,"udp"),t.toString()}function sB(e){let t=new Ze(e);return t.append(`${e.name}=wireguard`),t.appendIfPresent(`,section-name=${e["section-name"]}`,"section-name"),t.toString()}function _w(e,t){if(ae(t,"network"))if(t.network==="ws"){if(e.append(",ws=true"),ae(t,"ws-opts")&&(e.appendIfPresent(`,ws-path=${t["ws-opts"].path}`,"ws-opts.path"),ae(t,"ws-opts.headers"))){let r=t["ws-opts"].headers,n=Object.keys(r).map(i=>{let a=r[i];return["Host"].includes(i)&&(a=`"${a}"`),`${i}:${a}`}).join("|");xi(n)&&e.append(`,ws-headers=${n}`)}}else throw new Error(`network ${t.network} is unsupported`)}var Sn=(e,t)=>{t.detour=e["dialer-proxy"]||e.detour},Ns=(e,t)=>{["tcp","udp"].includes(e._network)&&(t.network=e._network)},Mn=(e,t)=>{t.tcp_fast_open=!1,e.tfo&&(t.tcp_fast_open=!0),e.tcp_fast_open&&(t.tcp_fast_open=!0),e["tcp-fast-open"]&&(t.tcp_fast_open=!0),t.tcp_fast_open||delete t.tcp_fast_open},Yi=(e,t)=>{!e||!e.enabled||(t.multiplex={enabled:!0},t.multiplex.protocol=e.protocol,e["max-connections"]&&(t.multiplex.max_connections=parseInt(`${e["max-connections"]}`,10)),e["max-streams"]&&(t.multiplex.max_streams=parseInt(`${e["max-streams"]}`,10)),e["min-streams"]&&(t.multiplex.min_streams=parseInt(`${e["min-streams"]}`,10)),e.padding&&(t.multiplex.padding=!0))},h0=(e,t)=>{let r={type:"ws",headers:{}};if(e["ws-opts"]){let{path:n="",headers:i={}}=e["ws-opts"];if(n!==""&&(r.path=`${n}`),Object.keys(i).length>0){let a={};for(let c of Object.keys(i)){let l=i[c];l!==""&&(Array.isArray(l)||(l=[`${l}`]),l.length>0&&(a[c]=l))}let{Host:s}=a;if(s.length===1)for(let c of`Host:${s[0]}`.split(` `)){let[l,h]=c.split(":");h.trim()!==""&&(a[l.trim()]=h.trim().split(","))}r.headers=a}}if(e["ws-headers"]){let n={};for(let a of Object.keys(e["ws-headers"])){let s=e["ws-headers"][a];s!==""&&(Array.isArray(s)||(s=[`${s}`]),s.length>0&&(n[a]=s))}let{Host:i}=n;if(i.length===1)for(let a of`Host:${i[0]}`.split(` `)){let[s,c]=a.split(":");c.trim()!==""&&(n[s.trim()]=c.trim().split(","))}for(let a of Object.keys(n))r.headers[a]=n[a]}if(e["ws-path"]&&e["ws-path"]!==""&&(r.path=`${e["ws-path"]}`),r.path){let n=/^(.*?)(?:\?ed=(\d+))?$/,[i,a="",s=""]=n.exec(r.path);r.path=a,s!==""&&(r.early_data_header_name="Sec-WebSocket-Protocol",r.max_early_data=parseInt(s,10))}t.tls.insecure&&(t.tls.server_name=r.headers.Host[0]),e["ws-opts"]&&e["ws-opts"]["v2ray-http-upgrade"]&&(r.type="httpupgrade",r.headers.Host&&(r.host=r.headers.Host[0],delete r.headers.Host),r.max_early_data&&delete r.max_early_data,r.early_data_header_name&&delete r.early_data_header_name);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r},aB=(e,t)=>{let r={type:"http",headers:{}};if(e["http-opts"]){let{method:n="",path:i="",headers:a={}}=e["http-opts"];n!==""&&(r.method=n),Array.isArray(i)?r.path=`${i[0]}`:i!==""&&(r.path=`${i}`);for(let s of Object.keys(a)){let c=a[s];if(c!==""){if(s.toLowerCase()==="host"){let l=c;Array.isArray(l)||(l=`${l}`.split(",").map(h=>h.trim())),l.length>0&&(r.host=l);continue}Array.isArray(c)||(c=`${c}`.split(",").map(l=>l.trim())),c.length>0&&(r.headers[s]=c)}}}if(e["http-host"]&&e["http-host"]!==""){let n=e["http-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.trim())),n.length>0&&(r.host=n)}if(r.host){if(e["http-path"]&&e["http-path"]!==""){let n=e["http-path"];Array.isArray(n)?r.path=`${n[0]}`:n!==""&&(r.path=`${n}`)}t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]);for(let n of Object.keys(r.headers)){let i=r.headers[n];i.length===1&&(r.headers[n]=i[0])}t.transport=r}},uB=(e,t)=>{let r={type:"http"};if(e["h2-opts"]){let{host:n="",path:i=""}=e["h2-opts"];i!==""&&(r.path=`${i}`),n!==""&&(Array.isArray(n)||(n=`${n}`.split(",").map(a=>a.trim())),n.length>0&&(r.host=n))}if(e["h2-host"]&&e["h2-host"]!==""){let n=e["h2-host"];Array.isArray(n)||(n=`${n}`.split(",").map(i=>i.trim())),n.length>0&&(r.host=n)}e["h2-path"]&&e["h2-path"]!==""&&(r.path=`${e["h2-path"]}`),t.tls.enabled=!0,t.tls.insecure&&(t.tls.server_name=r.host[0]),r.host.length===1&&(r.host=r.host[0]),t.transport=r},p0=(e,t)=>{let r={type:"grpc"};if(e["grpc-opts"]){let n=e["grpc-opts"]["grpc-service-name"];n!=null&&n!==""&&(r.service_name=`${n}`)}t.transport=r},fa=(e,t)=>{e.tls&&(t.tls.enabled=!0),e.servername&&e.servername!==""&&(t.tls.server_name=e.servername),e.peer&&e.peer!==""&&(t.tls.server_name=e.peer),e.sni&&e.sni!==""&&(t.tls.server_name=e.sni),e["skip-cert-verify"]&&(t.tls.insecure=!0),e.insecure&&(t.tls.insecure=!0),e["disable-sni"]&&(t.tls.disable_sni=!0),typeof e.alpn=="string"?t.tls.alpn=[e.alpn]:Array.isArray(e.alpn)&&(t.tls.alpn=e.alpn),e.ca&&(t.tls.certificate_path=`${e.ca}`),e.ca_str&&(t.tls.certificate=[e.ca_str]),e["ca-str"]&&(t.tls.certificate=[e["ca-str"]]),e["reality-opts"]&&(t.tls.reality={enabled:!0},e["reality-opts"]["public-key"]&&(t.tls.reality.public_key=e["reality-opts"]["public-key"]),e["reality-opts"]["short-id"]&&(t.tls.reality.short_id=e["reality-opts"]["short-id"]),t.tls.utls={enabled:!0}),!["hysteria","hysteria2","tuic"].includes(e.type)&&e["client-fingerprint"]&&e["client-fingerprint"]!==""&&(t.tls.utls={enabled:!0,fingerprint:e["client-fingerprint"]}),t.tls.enabled||delete t.tls},oB=(e={})=>{let t={tag:e.name,type:"ssh",server:e.server,server_port:parseInt(`${e.port}`,10)};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.user=e.username),e.password&&(t.password=e.password),e.privateKey&&(t.private_key_path=e.privateKey),e["private-key"]&&(t.private_key_path=e["private-key"]),e["private-key-passphrase"]&&(t.private_key_passphrase=e["private-key-passphrase"]),e["server-fingerprint"]&&(t.host_key=[e["server-fingerprint"]],t.host_key_algorithms=[e["server-fingerprint"].split(" ")[0]]),e["host-key"]&&(t.host_key=e["host-key"]),e["host-key-algorithms"]&&(t.host_key_algorithms=e["host-key-algorithms"]),e["fast-open"]&&(t.udp_fragment=!0),Mn(e,t),Sn(e,t),t},cB=(e={})=>{let t={tag:e.name,type:"http",server:e.server,server_port:parseInt(`${e.port}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.headers){t.headers={};for(let r of Object.keys(e.headers))t.headers[r]=`${e.headers[r]}`;Object.keys(t.headers).length===0&&delete t.headers}return e["fast-open"]&&(t.udp_fragment=!0),Mn(e,t),Sn(e,t),fa(e,t),t},lB=(e={})=>{let t={tag:e.name,type:"socks",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,version:"5"};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e.username&&(t.username=e.username),e.password&&(t.password=e.password),e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),Ns(e,t),Mn(e,t),Sn(e,t),t},fB=(e={})=>{let t={tag:e.name,type:"shadowsocks",method:e.cipher,password:e.password,detour:`${e.name}_shadowtls`},r={tag:`${e.name}_shadowtls`,type:"shadowtls",server:e.server,server_port:parseInt(`${e.port}`,10),version:e["plugin-opts"].version,password:e["plugin-opts"].password,tls:{enabled:!0,server_name:e["plugin-opts"].host,utls:{enabled:!0,fingerprint:e["client-fingerprint"]}}};if(r.server_port<0||r.server_port>65535)throw"\u7AEF\u53E3\u503C\u975E\u6CD5";return e["fast-open"]===!0&&(r.udp_fragment=!0),Mn(e,r),Sn(e,r),Yi(e.smux,t),{type:"ss-with-st",ssPart:t,stPart:r}},hB=(e={})=>{let t={tag:e.name,type:"shadowsocks",server:e.server,server_port:parseInt(`${e.port}`,10),method:e.cipher,password:e.password};if(t.server_port<0||t.server_port>65535)throw"invalid port";if(e.uot&&(t.udp_over_tcp=!0),e["udp-over-tcp"]&&(t.udp_over_tcp=!0),e["fast-open"]&&(t.udp_fragment=!0),Ns(e,t),Mn(e,t),Sn(e,t),Yi(e.smux,t),e.plugin){let r=[];e.plugin==="obfs"&&(t.plugin="obfs-local",t.plugin_opts="",e["obfs-host"]&&(e["plugin-opts"].host=e["obfs-host"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"mode":r.push(`obfs=${e["plugin-opts"].mode}`);break;case"host":r.push(`obfs-host=${e["plugin-opts"].host}`);break;default:r.push(`${n}=${e["plugin-opts"][n]}`);break}})),e.plugin==="v2ray-plugin"&&(t.plugin="v2ray-plugin",e["ws-host"]&&(e["plugin-opts"].host=e["ws-host"]),e["ws-path"]&&(e["plugin-opts"].path=e["ws-path"]),Object.keys(e["plugin-opts"]).forEach(n=>{switch(n){case"tls":e["plugin-opts"].tls&&r.push("tls");break;case"host":r.push(`host=${e["plugin-opts"].host}`);break;case"path":r.push(`path=${e["plugin-opts"].path}`);break;case"headers":r.push(`headers=${JSON.stringify(e["plugin-opts"].headers)}`);break;case"mux":e["plugin-opts"].mux&&(t.multiplex={enabled:!0});break;default:r.push(`${n}=${e["plugin-opts"][n]}`)}})),t.plugin_opts=r.join(";")}return t},pB=(e={})=>{let t={tag:e.name,type:"shadowsocksr",server:e.server,server_port:parseInt(`${e.port}`,10),method:e.cipher,password:e.password,obfs:e.obfs,protocol:e.protocol};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["obfs-param"]&&(t.obfs_param=e["obfs-param"]),e["protocol-param"]&&e["protocol-param"]!==""&&(t.protocol_param=e["protocol-param"]),e["fast-open"]&&(t.udp_fragment=!0),Mn(e,t),Sn(e,t),Yi(e.smux,t),t},dB=(e={})=>{let t={tag:e.name,type:"vmess",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,security:e.cipher,alter_id:parseInt(`${e.alterId}`,10),tls:{enabled:!1,server_name:e.server,insecure:!1}};if(["auto","none","zero","aes-128-gcm","chacha20-poly1305","aes-128-ctr"].indexOf(t.security)===-1&&(t.security="auto"),t.server_port<0||t.server_port>65535)throw"invalid port";return e.xudp&&(t.packet_encoding="xudp"),e["fast-open"]&&(t.udp_fragment=!0),e.network==="ws"&&h0(e,t),e.network==="h2"&&uB(e,t),e.network==="http"&&aB(e,t),e.network==="grpc"&&p0(e,t),Ns(e,t),Mn(e,t),Sn(e,t),fa(e,t),Yi(e.smux,t),t},gB=(e={})=>{let t={tag:e.name,type:"vless",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,tls:{enabled:!1,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e.flow==="xtls-rprx-vision"&&(t.flow=e.flow),e.network==="ws"&&h0(e,t),e.network==="grpc"&&p0(e,t),Ns(e,t),Mn(e,t),Sn(e,t),Yi(e.smux,t),fa(e,t),t},mB=(e={})=>{let t={tag:e.name,type:"trojan",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e.network==="grpc"&&p0(e,t),e.network==="ws"&&h0(e,t),Ns(e,t),Mn(e,t),Sn(e,t),fa(e,t),Yi(e.smux,t),t},vB=(e={})=>{let t={tag:e.name,type:"hysteria",server:e.server,server_port:parseInt(`${e.port}`,10),disable_mtu_discovery:!1,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";e.auth_str&&(t.auth_str=`${e.auth_str}`),e["auth-str"]&&(t.auth_str=`${e["auth-str"]}`),e["fast-open"]&&(t.udp_fragment=!0);let r=new RegExp("^[0-9]+[ ]*[KMGT]*[Bb]ps$");return r.test(`${e.up}`)?t.up=`${e.up}`:t.up_mbps=parseInt(`${e.up}`,10),r.test(`${e.down}`)?t.down=`${e.down}`:t.down_mbps=parseInt(`${e.down}`,10),e.obfs&&(t.obfs=e.obfs),e.recv_window_conn&&(t.recv_window_conn=e.recv_window_conn),e["recv-window-conn"]&&(t.recv_window_conn=e["recv-window-conn"]),e.recv_window&&(t.recv_window=e.recv_window),e["recv-window"]&&(t.recv_window=e["recv-window"]),e.disable_mtu_discovery&&(typeof e.disable_mtu_discovery=="boolean"?t.disable_mtu_discovery=e.disable_mtu_discovery:e.disable_mtu_discovery===1&&(t.disable_mtu_discovery=!0)),Ns(e,t),fa(e,t),Sn(e,t),Mn(e,t),Yi(e.smux,t),t},wB=(e={})=>{let t={tag:e.name,type:"hysteria2",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,obfs:{},tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["hop-interval"]&&(t.hop_interval=/^\d+$/.test(e["hop-interval"])?`${e["hop-interval"]}s`:e["hop-interval"]),e.ports&&(t.server_ports=e.ports.split(/\s*,\s*/).map(r=>r.replace(/\s*-\s*/g,":"))),e.up&&(t.up_mbps=parseInt(`${e.up}`,10)),e.down&&(t.down_mbps=parseInt(`${e.down}`,10)),e.obfs==="salamander"&&(t.obfs.type="salamander"),e["obfs-password"]&&(t.obfs.password=e["obfs-password"]),t.obfs.type||delete t.obfs,Ns(e,t),fa(e,t),Mn(e,t),Sn(e,t),Yi(e.smux,t),t},AB=(e={})=>{let t={tag:e.name,type:"tuic",server:e.server,server_port:parseInt(`${e.port}`,10),uuid:e.uuid,password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};if(t.server_port<0||t.server_port>65535)throw"invalid port";return e["fast-open"]&&(t.udp_fragment=!0),e["congestion-controller"]&&e["congestion-controller"]!=="cubic"&&(t.congestion_control=e["congestion-controller"]),e["udp-relay-mode"]&&e["udp-relay-mode"]!=="native"&&(t.udp_relay_mode=e["udp-relay-mode"]),e["reduce-rtt"]&&(t.zero_rtt_handshake=!0),e["udp-over-stream"]&&(t.udp_over_stream=!0),e["heartbeat-interval"]&&(t.heartbeat=`${e["heartbeat-interval"]}ms`),Ns(e,t),Mn(e,t),Sn(e,t),fa(e,t),Yi(e.smux,t),t},EB=(e={})=>{let t={tag:e.name,type:"anytls",server:e.server,server_port:parseInt(`${e.port}`,10),password:e.password,tls:{enabled:!0,server_name:e.server,insecure:!1}};return/^\d+$/.test(e["idle-session-check-interval"])&&(t.idle_session_check_interval=`${e["idle-session-check-interval"]}s`),/^\d+$/.test(e["idle-session-timeout"])&&(t.idle_session_timeout=`${e["idle-session-timeout"]}s`),Sn(e,t),fa(e,t),t},yB=(e={})=>{let t=["ip","ipv6"].map(n=>e[n]).map(n=>{if(fr(n))return`${n}/32`;if(hr(n))return`${n}/128`}).filter(n=>n),r={tag:e.name,type:"wireguard",server:e.server,server_port:parseInt(`${e.port}`,10),local_address:t,private_key:e["private-key"],peer_public_key:e["public-key"],pre_shared_key:e["pre-shared-key"],reserved:[]};if(r.server_port<0||r.server_port>65535)throw"invalid port";if(e["fast-open"]&&(r.udp_fragment=!0),typeof e.reserved=="string")r.reserved=e.reserved;else if(Array.isArray(e.reserved))for(let n of e.reserved)r.reserved.push(n);else delete r.reserved;if(e.peers&&e.peers.length>0){r.peers=[];for(let n of e.peers){let i={server:n.server,server_port:parseInt(`${n.port}`,10),public_key:n["public-key"],allowed_ips:n["allowed-ips"]||n.allowed_ips,reserved:[]};if(typeof n.reserved=="string")i.reserved.push(n.reserved);else if(Array.isArray(n.reserved))for(let a of n.reserved)i.reserved.push(a);else delete i.reserved;n["pre-shared-key"]&&(i.pre_shared_key=n["pre-shared-key"]),r.peers.push(i)}}return Ns(e,r),Mn(e,r),Sn(e,r),Yi(e.smux,r),r};function ah(){return{type:"ALL",produce:(r,n,i={})=>{let a=[];return Hn().produce(r,"internal",{"include-unsupported-proxy":!0}).map(s=>{try{switch(s.type){case"ssh":a.push(oB(s));break;case"http":a.push(cB(s));break;case"socks5":if(s.tls)throw new Error(`Platform sing-box does not support proxy type: ${s.type} with tls`);a.push(lB(s));break;case"ss":if(s.plugin==="shadow-tls"){let{ssPart:c,stPart:l}=fB(s);a.push(c),a.push(l)}else a.push(hB(s));break;case"ssr":if(i["include-unsupported-proxy"])a.push(pB(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type}`);break;case"vmess":if(!s.network||["ws","grpc","h2","http"].includes(s.network))a.push(dB(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with network ${s.network}`);break;case"vless":if(!s.flow||["xtls-rprx-vision"].includes(s.flow))a.push(gB(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"trojan":if(!s.flow)a.push(mB(s));else throw new Error(`Platform sing-box does not support proxy type: ${s.type} with flow ${s.flow}`);break;case"hysteria":a.push(vB(s));break;case"hysteria2":a.push(wB(s,i["include-unsupported-proxy"]));break;case"tuic":if(!s.token||s.token.length===0)a.push(AB(s));else throw new Error("Platform sing-box does not support proxy type: TUIC v4");break;case"wireguard":a.push(yB(s));break;case"anytls":a.push(EB(s));break;default:throw new Error(`Platform sing-box does not support proxy type: ${s.type}`)}}catch(c){O.error(c.message??c)}}),n==="internal"?a:JSON.stringify({outbounds:a},null,2)}}}function uh(){return{type:"ALL",produce:(r,n)=>{let i=r.filter(a=>!(!["http","socks5","ss","trojan","hysteria2","vless","vmess","tuic"].includes(a.type)||a.type==="ss"&&(a.plugin==="obfs"&&!["http","tls"].includes(a["plugin-opts"]?.mode)||!["chacha20-ietf-poly1305","chacha20-poly1305","aes-256-gcm","aes-128-gcm","none","tbale","rc4","rc4-md5","aes-128-cfb","aes-192-cfb","aes-256-cfb","aes-128-ctr","aes-192-ctr","aes-256-ctr","bf-cfb","camellia-128-cfb","camellia-192-cfb","camellia-256-cfb","cast5-cfb","des-cfb","idea-cfb","rc2-cfb","seed-cfb","salsa20","chacha20","chacha20-ietf","2022-blake3-aes-128-gcm","2022-blake3-aes-256-gcm"].includes(a.cipher))||a.type==="vmess"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="trojan"&&!["http","ws","tcp"].includes(a.network)&&a.network||a.type==="vless"&&(typeof a.flow<"u"||a["reality-opts"]||!["http","ws","tcp"].includes(a.network)&&a.network)||a.type==="tuic"&&a.token&&a.token.length!==0)).map(a=>{let s={...a};a.tls&&!a.sni&&(a.sni=a.server);let c=a.prev_hop||a["underlying-proxy"]||a["dialer-proxy"]||a.detour;if(a.type==="http")a={type:"http",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],next_hop:a.next_hop};else if(a.type==="socks5")a={type:"socks5",name:a.name,server:a.server,port:a.port,username:a.username,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop};else if(a.type==="ss")a={type:"shadowsocks",name:a.name,method:a.cipher==="chacha20-ietf-poly1305"?"chacha20-poly1305":a.cipher,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop},s.plugin==="obfs"&&(a.obfs=s["plugin-opts"].mode,a.obfs_host=s["plugin-opts"].host,a.obfs_uri=s["plugin-opts"].path);else if(a.type==="hysteria2")a={type:"hysteria2",name:a.name,server:a.server,port:a.port,auth:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]},s["obfs-password"]&&s.obfs=="salamander"&&(a.obfs="salamander",a.obfs_password=s["obfs-password"]);else if(a.type==="tuic")a={type:"tuic",name:a.name,server:a.server,port:a.port,uuid:a.uuid,password:a.password,next_hop:a.next_hop,sni:a.sni,alpn:Array.isArray(a.alpn)?a.alpn:[a.alpn||"h3"],skip_tls_verify:a["skip-cert-verify"],port_hopping:a.ports,port_hopping_interval:a["hop-interval"]};else if(a.type==="trojan")a.network==="ws"&&(a.websocket={path:a["ws-opts"]?.path,host:a["ws-opts"]?.headers?.Host}),a={type:"trojan",name:a.name,server:a.server,port:a.port,password:a.password,tfo:a.tfo||a["fast-open"],udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,sni:a.sni,skip_tls_verify:a["skip-cert-verify"],websocket:a.websocket};else if(a.type==="vmess"){let l=a.cipher;l&&!["auto","none","zero","aes-128-gcm","chacha20-poly1305"].includes(l)&&(l="auto"),a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http1:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:a.network==="h2"?a.transport={http2:{method:a["h2-opts"]?.method,path:Array.isArray(a["h2-opts"]?.path)?a["h2-opts"]?.path[0]:a["h2-opts"]?.path,headers:{Host:Array.isArray(a["h2-opts"]?.headers?.Host)?a["h2-opts"]?.headers?.Host[0]:a["h2-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&a.tls&&(a.transport={tls:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vmess",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:l,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport}}else a.type==="vless"&&(a.network==="ws"?a.transport={[a.tls?"wss":"ws"]:{path:a["ws-opts"]?.path,headers:{Host:a["ws-opts"]?.headers?.Host},sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}:a.network==="http"?a.transport={http:{method:a["http-opts"]?.method,path:Array.isArray(a["http-opts"]?.path)?a["http-opts"]?.path[0]:a["http-opts"]?.path,headers:{Host:Array.isArray(a["http-opts"]?.headers?.Host)?a["http-opts"]?.headers?.Host[0]:a["http-opts"]?.headers?.Host},skip_tls_verify:a["skip-cert-verify"]}}:(a.network==="tcp"||!a.network)&&(a.transport={[a.tls?"tls":"tcp"]:{sni:a.tls?a.sni:void 0,skip_tls_verify:a.tls?a["skip-cert-verify"]:void 0}}),a={type:"vless",name:a.name,server:a.server,port:a.port,user_id:a.uuid,security:a.cipher,tfo:a.tfo||a["fast-open"],legacy:a.legacy,udp_relay:a.udp||a.udp_relay||a.udp_relay,next_hop:a.next_hop,transport:a.transport});if(["http","socks5","ss","trojan","vless","vmess"].includes(s.type)){if(ae(s,"shadow-tls-password")){if(s["shadow-tls-version"]!=3)throw new Error(`shadow-tls version ${s["shadow-tls-version"]} is not supported`);a.shadow_tls={password:s["shadow-tls-password"],sni:s["shadow-tls-sni"]}}else if(["shadow-tls"].includes(s.plugin)&&s["plugin-opts"]){if(s["plugin-opts"].version!=3)throw new Error(`shadow-tls version ${s["plugin-opts"].version} is not supported`);a.shadow_tls={password:s["plugin-opts"].password,sni:s["plugin-opts"].host}}}if(delete a.subName,delete a.collectionName,delete a.id,delete a.resolved,delete a["no-resolve"],n!=="internal")for(let l in a)(a[l]==null||/^_/i.test(l))&&delete a[l];return{[a.type]:{...a,type:void 0,prev_hop:c}}});return n==="internal"?i:`proxies: `+i.map(a=>" - "+JSON.stringify(a)+` `).join("")}}}function Iw(){return{type:"ALL",produce:(r,n)=>n==="internal"?r:JSON.stringify(r,null,2)}}var Dw={qx:zc(),QX:zc(),QuantumultX:zc(),surge:Do(),Surge:Do(),SurgeMac:c0(),Loon:f0(),Clash:l0(),meta:Hn(),clashmeta:Hn(),"clash.meta":Hn(),"Clash.Meta":Hn(),ClashMeta:Hn(),mihomo:Hn(),Mihomo:Hn(),uri:Bo(),URI:Bo(),v2:Gc(),v2ray:Gc(),V2Ray:Gc(),json:Iw(),JSON:Iw(),stash:ih(),Stash:ih(),shadowrocket:Yc(),Shadowrocket:Yc(),ShadowRocket:Yc(),surfboard:sh(),Surfboard:sh(),singbox:ah(),"sing-box":ah(),egern:uh(),Egern:uh()};var xA=ei(tl()),P7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleWebsocket() { if (obfs.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers", obfs['ws-headers']); if (proxy['ws-opts'] && proxy['ws-opts']['headers'] && proxy['ws-opts']['headers'].Host) { proxy['ws-opts']['headers'].Host = proxy['ws-opts']['headers'].Host.replace(/^"(.*)"$/, '$1') } } } function handleShadowTLS() { if (proxy['shadow-tls-password'] && !proxy['shadow-tls-version']) { proxy['shadow-tls-version'] = 2; } } } start = (shadowsocks/vmess/trojan/https/http/snell/socks5/socks5_tls/tuic/tuic_v5/wireguard/hysteria2/ssh/direct) { return proxy; } shadowsocks = tag equals "ss" address (method/passwordk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/udp_port/others)* { proxy.type = "ss"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } handleShadowTLS(); } vmess = tag equals "vmess" address (vmess_uuid/vmess_aead/ws/ws_path/ws_headers/method/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls/sni/tls_fingerprint/tls_verification/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = proxy.alterId || 0; } handleWebsocket(); handleShadowTLS(); } trojan = tag equals "trojan" address (passwordk/ws/ws_path/ws_headers/tls/sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "trojan"; handleWebsocket(); handleShadowTLS(); } https = tag equals "https" address (username password)? (usernamek passwordk)? (sni/tls_fingerprint/tls_verification/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; proxy.tls = true; handleShadowTLS(); } http = tag equals "http" address (username password)? (usernamek passwordk)? (ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "http"; handleShadowTLS(); } ssh = tag equals "ssh" address (username password)? (usernamek passwordk)? (server_fingerprint/idle_timeout/private_key/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "ssh"; handleShadowTLS(); } snell = tag equals "snell" address (snell_version/snell_psk/obfs/obfs_host/obfs_uri/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/udp_relay/reuse/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "snell"; // handle obfs if (obfs.type == "http" || obfs.type === "tls") { $set(proxy, "obfs-opts.mode", obfs.type); $set(proxy, "obfs-opts.host", obfs.host); $set(proxy, "obfs-opts.path", obfs.path); } handleShadowTLS(); } tuic = tag equals "tuic" address (alpn/token/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; handleShadowTLS(); } tuic_v5 = tag equals "tuic-v5" address (alpn/passwordk/uuidk/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/tls_fingerprint/tls_verification/sni/fast_open/tfo/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "tuic"; proxy.version = 5; handleShadowTLS(); } wireguard = tag equals "wireguard" (section_name/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "wireguard-surge"; handleShadowTLS(); } hysteria2 = tag equals "hysteria2" address (no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/fast_open/tfo/tls_verification/passwordk/tls_fingerprint/download_bandwidth/ecn/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/port_hopping_interval/others)* { proxy.type = "hysteria2"; handleShadowTLS(); } socks5 = tag equals "socks5" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; handleShadowTLS(); } socks5_tls = tag equals "socks5-tls" address (username password)? (usernamek passwordk)? (udp_relay/no_error_alert/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/sni/tls_fingerprint/tls_verification/fast_open/tfo/shadow_tls_version/shadow_tls_sni/shadow_tls_password/block_quic/others)* { proxy.type = "socks5"; proxy.tls = true; handleShadowTLS(); } direct = tag equals "direct" (udp_relay/ip_version/underlying_proxy/tos/allow_other_interface/interface/test_url/test_udp/test_timeout/hybrid/no_error_alert/fast_open/tfo/block_quic/others)* { proxy.type = "direct"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } port_hopping_interval = comma "port-hopping-interval" equals match:$[0-9]+ { proxy["hop-interval"] = parseInt(match.trim()); } username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma match:[^,]+ { proxy.password = match.join(""); } tls = comma "tls" equals flag:bool { proxy.tls = flag; } sni = comma "sni" equals sni:("off"/domain) { if (sni === "off") { proxy["disable-sni"] = true; } else { proxy.sni = sni; } } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_fingerprint = comma "server-cert-fingerprint-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } snell_psk = comma "psk" equals match:[^,]+ { proxy.psk = match.join(""); } snell_version = comma "version" equals match:$[0-9]+ { proxy.version = parseInt(match.trim()); } usernamek = comma "username" equals match:[^,]+ { proxy.username = match.join(""); } passwordk = comma "password" equals match:[^,]+ { proxy.password = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } vmess_uuid = comma "username" equals match:[^,]+ { proxy.uuid = match.join(""); } vmess_aead = comma "vmess-aead" equals flag:bool { proxy.aead = flag; } method = comma "encrypt-method" equals cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"idea-cfb"/"none"/"rc2-cfb"/"rc4-md5"/"rc4"/"salsa20"/"seed-cfb"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); ws = comma "ws" equals flag:bool { obfs.type = "ws"; } ws_headers = comma "ws-headers" equals headers:$[^,]+ { const pairs = headers.split("|"); const result = {}; pairs.forEach(pair => { const [key, value] = pair.trim().split(":"); result[key.trim()] = value.trim(); }) obfs["ws-headers"] = result; } ws_path = comma "ws-path" equals path:uri { obfs.path = path; } obfs = comma "obfs" equals type:("http"/"tls") { obfs.type = type; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; }; obfs_uri = comma "obfs-uri" equals path:uri { obfs.path = path } uri = $[^,]+ udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } reuse = comma "reuse" equals flag:bool { proxy.reuse = flag; } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } tfo = comma "tfo" equals flag:bool { proxy.tfo = flag; } ip_version = comma "ip-version" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } section_name = comma "section-name" equals match:[^,]+ { proxy["section-name"] = match.join(""); } no_error_alert = comma "no-error-alert" equals match:[^,]+ { proxy["no-error-alert"] = match.join(""); } underlying_proxy = comma "underlying-proxy" equals match:[^,]+ { proxy["underlying-proxy"] = match.join(""); } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } test_url = comma "test-url" equals match:[^,]+ { proxy["test-url"] = match.join(""); } test_udp = comma "test-udp" equals match:[^,]+ { proxy["test-udp"] = match.join(""); } test_timeout = comma "test-timeout" equals match:$[0-9]+ { proxy["test-timeout"] = parseInt(match.trim()); } tos = comma "tos" equals match:$[0-9]+ { proxy.tos = parseInt(match.trim()); } interface = comma "interface" equals match:[^,]+ { proxy.interface = match.join(""); } allow_other_interface = comma "allow-other-interface" equals flag:bool { proxy["allow-other-interface"] = flag; } hybrid = comma "hybrid" equals flag:bool { proxy.hybrid = flag; } idle_timeout = comma "idle-timeout" equals match:$[0-9]+ { proxy["idle-timeout"] = parseInt(match.trim()); } private_key = comma "private-key" equals match:[^,]+ { proxy["keystore-private-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } server_fingerprint = comma "server-fingerprint" equals match:[^,]+ { proxy["server-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } block_quic = comma "block-quic" equals match:[^,]+ { proxy["block-quic"] = match.join(""); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join("").replace(/^"(.*?)"$/, '$1').replace(/^'(.*?)'$/, '$1'); } token = comma "token" equals match:[^,]+ { proxy.token = match.join(""); } alpn = comma "alpn" equals match:[^,]+ { proxy.alpn = match.join(""); } uuidk = comma "uuid" equals match:[^,]+ { proxy.uuid = match.join(""); } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,T0;function Kn(){return T0||(T0=xA.generate(P7)),T0}var OA=ei(tl()),$7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parser initializer { const proxy = {}; const obfs = {}; const transport = {}; const $ = {}; function handleTransport() { if (transport.type === "tcp") { /* do nothing */ } else if (transport.type === "ws") { proxy.network = "ws"; $set(proxy, "ws-opts.path", transport.path); $set(proxy, "ws-opts.headers.Host", transport.host); } else if (transport.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", transport.path); $set(proxy, "http-opts.headers.Host", transport.host); } } } start = (shadowsocksr/shadowsocks/vmess/vless/trojan/https/http/socks5/hysteria2) { return proxy; } shadowsocksr = tag equals "shadowsocksr"i address method password (ssr_protocol/ssr_protocol_param/obfs_ssr/obfs_ssr_param/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/others)*{ proxy.type = "ssr"; // handle ssr obfs proxy.obfs = obfs.type; } shadowsocks = tag equals "shadowsocks"i address method password (obfs_typev obfs_hostv)? (obfs_ss/obfs_host/obfs_uri/fast_open/udp_relay/udp_port/shadow_tls_version/shadow_tls_sni/shadow_tls_password/ip_mode/others)* { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts.mode", obfs.type); $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } vmess = tag equals "vmess"i address method uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/vmess_alterId/fast_open/udp_relay/ip_mode/public_key/short_id/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; proxy.alterId = proxy.alterId || 0; handleTransport(); } vless = tag equals "vless"i address uuid (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/flow/public_key/short_id/others)* { proxy.type = "vless"; handleTransport(); } trojan = tag equals "trojan"i address password (transport/transport_host/transport_path/over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "trojan"; handleTransport(); } hysteria2 = tag equals "hysteria2"i address password (tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/udp_relay/fast_open/download_bandwidth/salamander_password/ecn/ip_mode/others)* { proxy.type = "hysteria2"; } https = tag equals "https"i address (username password)? (tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "http"; proxy.tls = true; } http = tag equals "http"i address (username password)? (fast_open/udp_relay/ip_mode/others)* { proxy.type = "http"; } socks5 = tag equals "socks5"i address (username password)? (over_tls/tls_host/tls_verification/tls_cert_sha256/tls_pubkey_sha256/fast_open/udp_relay/ip_mode/others)* { proxy.type = "socks5"; } address = comma server:server comma port:port { proxy.server = server; proxy.port = port; } server = ip/domain ip = & { const start = peg$currPos; let j = start; while (j < input.length) { if (input[j] === ",") break; j++; } peg$currPos = j; $.ip = input.substring(start, j).trim(); return true; } { return $.ip; } domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } throw new Error("Invalid domain: " + domain); } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } throw new Error("Invalid port number: " + port); } method = comma cipher:cipher { proxy.cipher = cipher; } cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"auto"/"bf-cfb"/"camellia-128-cfb"/"camellia-192-cfb"/"camellia-256-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"none"/"rc4-md5"/"rc4"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); username = & { let j = peg$currPos; let start, end; let first = true; while (j < input.length) { if (input[j] === ',') { if (first) { start = j + 1; first = false; } else { end = j; break; } } j++; } const match = input.substring(start, end); if (match.indexOf("=") === -1) { $.username = match; peg$currPos = end; return true; } } { proxy.username = $.username; } password = comma '"' match:[^"]* '"' { proxy.password = match.join(""); } uuid = comma '"' match:[^"]+ '"' { proxy.uuid = match.join(""); } obfs_typev = comma type:("http"/"tls") { obfs.type = type; } obfs_hostv = comma match:[^,]+ { obfs.host = match.join(""); } obfs_ss = comma "obfs-name" equals type:("http"/"tls") { obfs.type = type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { obfs.type = type; } obfs_ssr_param = comma "obfs-param" equals match:$[^,]+ { proxy["obfs-param"] = match; } obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } uri = $[^,]+ transport = comma "transport" equals type:("tcp"/"ws"/"http") { transport.type = type; } transport_host = comma "host" equals host:domain { transport.host = host; } transport_path = comma "path" equals path:uri { transport.path = path; } ssr_protocol = comma "protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; } ssr_protocol_param = comma "protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } vmess_alterId = comma "alterId" equals alterId:$[0-9]+ { proxy.alterId = parseInt(alterId); } udp_port = comma "udp-port" equals match:$[0-9]+ { proxy["udp-port"] = parseInt(match.trim()); } shadow_tls_version = comma "shadow-tls-version" equals match:$[0-9]+ { proxy["shadow-tls-version"] = parseInt(match.trim()); } shadow_tls_sni = comma "shadow-tls-sni" equals match:[^,]+ { proxy["shadow-tls-sni"] = match.join(""); } shadow_tls_password = comma "shadow-tls-password" equals match:[^,]+ { proxy["shadow-tls-password"] = match.join(""); } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma sni:("tls-name"/"sni") equals host:domain { proxy.sni = host; } tls_verification = comma "skip-cert-verify" equals flag:bool { proxy["skip-cert-verify"] = flag; } tls_cert_sha256 = comma "tls-cert-sha256" equals match:[^,]+ { proxy["tls-fingerprint"] = match.join("").replace(/^"(.*)"$/, '$1'); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals match:[^,]+ { proxy["tls-pubkey-sha256"] = match.join("").replace(/^"(.*)"$/, '$1'); } flow = comma "flow" equals match:[^,]+ { proxy["flow"] = match.join("").replace(/^"(.*)"$/, '$1'); } public_key = comma "public-key" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["public-key"] = match.join("").replace(/^"(.*)"$/, '$1'); } short_id = comma "short-id" equals match:[^,]+ { proxy["reality-opts"] = proxy["reality-opts"] || {}; proxy["reality-opts"]["short-id"] = match.join("").replace(/^"(.*)"$/, '$1'); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } udp_relay = comma "udp" equals flag:bool { proxy.udp = flag; } ip_mode = comma "ip-mode" equals match:[^,]+ { proxy["ip-version"] = match.join(""); } ecn = comma "ecn" equals flag:bool { proxy.ecn = flag; } download_bandwidth = comma "download-bandwidth" equals match:[^,]+ { proxy.down = match.join(""); } salamander_password = comma "salamander-password" equals match:[^,]+ { proxy['obfs-password'] = match.join(""); proxy.obfs = 'salamander'; } tag = match:[^=,]* { proxy.name = match.join("").trim(); } comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } others = comma [^=,]+ equals [^=,]+ `,x0;function Wi(){return x0||(x0=OA.generate($7)),x0}var NA=ei(tl()),R7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } }} // per-parse initializer { const proxy = {}; const obfs = {}; const $ = {}; function handleObfs() { if (obfs.type === "ws" || obfs.type === "wss") { proxy.network = "ws"; if (obfs.type === 'wss') { proxy.tls = true; } $set(proxy, "ws-opts.path", obfs.path); $set(proxy, "ws-opts.headers.Host", obfs.host); } else if (obfs.type === "over-tls") { proxy.tls = true; } else if (obfs.type === "http") { proxy.network = "http"; $set(proxy, "http-opts.path", obfs.path); $set(proxy, "http-opts.headers.Host", obfs.host); } } } start = (trojan/shadowsocks/vmess/vless/http/socks5) { return proxy } trojan = "trojan" equals address (password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/obfs/obfs_host/obfs_uri/tag/udp_relay/udp_over_tcp/fast_open/server_check_url/others)* { proxy.type = "trojan"; handleObfs(); } shadowsocks = "shadowsocks" equals address (password/method/obfs_ssr/obfs_ss/obfs_host/obfs_uri/ssr_protocol/ssr_protocol_param/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/udp_relay/udp_over_tcp/fast_open/tag/server_check_url/others)* { if (proxy.protocol || proxy.type === "ssr") { proxy.type = "ssr"; if (!proxy.protocol) { proxy.protocol = "origin"; } // handle ssr obfs if (obfs.host) proxy["obfs-param"] = obfs.host; if (obfs.type) proxy.obfs = obfs.type; } else { proxy.type = "ss"; // handle ss obfs if (obfs.type == "http" || obfs.type === "tls") { proxy.plugin = "obfs"; $set(proxy, "plugin-opts", { mode: obfs.type }); } else if (obfs.type === "ws" || obfs.type === "wss") { proxy.plugin = "v2ray-plugin"; $set(proxy, "plugin-opts.mode", "websocket"); if (obfs.type === "wss") { $set(proxy, "plugin-opts.tls", true); } } else if (obfs.type === 'over-tls') { throw new Error('ss over-tls is not supported'); } if (obfs.type) { $set(proxy, "plugin-opts.host", obfs.host); $set(proxy, "plugin-opts.path", obfs.path); } } } vmess = "vmess" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vmess"; proxy.cipher = proxy.cipher || "none"; if (proxy.aead) { proxy.alterId = 0; } else { proxy.alterId = proxy.alterId || 0; } handleObfs(); } vless = "vless" equals address (uuid/method/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/obfs/obfs_host/obfs_uri/udp_relay/udp_over_tcp/fast_open/aead/server_check_url/others)* { proxy.type = "vless"; proxy.cipher = proxy.cipher || "none"; handleObfs(); } http = "http" equals address (username/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)*{ proxy.type = "http"; } socks5 = "socks5" equals address (username/password/password/over_tls/tls_host/tls_pubkey_sha256/tls_alpn/tls_no_session_ticket/tls_no_session_reuse/tls_fingerprint/tls_verification/tag/fast_open/udp_relay/udp_over_tcp/server_check_url/others)* { proxy.type = "socks5"; } address = server:server ":" port:port { proxy.server = server; proxy.port = port; } server = ip/domain domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } } username = comma "username" equals username:[^,]+ { proxy.username = username.join("").trim(); } password = comma "password" equals password:[^,]+ { proxy.password = password.join("").trim(); } uuid = comma "password" equals uuid:[^,]+ { proxy.uuid = uuid.join("").trim(); } method = comma "method" equals cipher:cipher { proxy.cipher = cipher; }; cipher = ("aes-128-cfb"/"aes-128-ctr"/"aes-128-gcm"/"aes-192-cfb"/"aes-192-ctr"/"aes-192-gcm"/"aes-256-cfb"/"aes-256-ctr"/"aes-256-gcm"/"bf-cfb"/"cast5-cfb"/"chacha20-ietf-poly1305"/"chacha20-ietf"/"chacha20-poly1305"/"chacha20"/"des-cfb"/"none"/"rc2-cfb"/"rc4-md5-6"/"rc4-md5"/"salsa20"/"xchacha20-ietf-poly1305"/"2022-blake3-aes-128-gcm"/"2022-blake3-aes-256-gcm"); aead = comma "aead" equals flag:bool { proxy.aead = flag; } udp_relay = comma "udp-relay" equals flag:bool { proxy.udp = flag; } udp_over_tcp = comma "udp-over-tcp" equals flag:bool { throw new Error("UDP over TCP is not supported"); } fast_open = comma "fast-open" equals flag:bool { proxy.tfo = flag; } over_tls = comma "over-tls" equals flag:bool { proxy.tls = flag; } tls_host = comma "tls-host" equals sni:domain { proxy.sni = sni; } tls_verification = comma "tls-verification" equals flag:bool { proxy["skip-cert-verify"] = !flag; } tls_fingerprint = comma "tls-cert-sha256" equals tls_fingerprint:$[^,]+ { proxy["tls-fingerprint"] = tls_fingerprint.trim(); } tls_pubkey_sha256 = comma "tls-pubkey-sha256" equals param:$[^=,]+ { proxy["tls-pubkey-sha256"] = param; } tls_alpn = comma "tls-alpn" equals param:$[^=,]+ { proxy["tls-alpn"] = param; } tls_no_session_ticket = comma "tls-no-session-ticket" equals flag:bool { proxy["tls-no-session-ticket"] = flag; } tls_no_session_reuse = comma "tls-no-session-reuse" equals flag:bool { proxy["tls-no-session-reuse"] = flag; } obfs_ss = comma "obfs" equals type:("http"/"tls"/"wss"/"ws"/"over-tls") { obfs.type = type; return type; } obfs_ssr = comma "obfs" equals type:("plain"/"http_simple"/"http_post"/"random_head"/"tls1.2_ticket_auth"/"tls1.2_ticket_fastauth") { proxy.type = "ssr"; obfs.type = type; return type; } obfs = comma "obfs" equals type:("wss"/"ws"/"over-tls"/"http") { obfs.type = type; return type; }; obfs_host = comma "obfs-host" equals host:domain { obfs.host = host; } obfs_uri = comma "obfs-uri" equals uri:uri { obfs.path = uri; } ssr_protocol = comma "ssr-protocol" equals protocol:("origin"/"auth_sha1_v4"/"auth_aes128_md5"/"auth_aes128_sha1"/"auth_chain_a"/"auth_chain_b") { proxy.protocol = protocol; return protocol; } ssr_protocol_param = comma "ssr-protocol-param" equals param:$[^=,]+ { proxy["protocol-param"] = param; } server_check_url = comma "server_check_url" equals param:$[^=,]+ { proxy["test-url"] = param; } uri = $[^,]+ tag = comma "tag" equals tag:[^=,]+ { proxy.name = tag.join(""); } others = comma [^=,]+ equals [^=,]+ comma = _ "," _ equals = _ "=" _ _ = [ \r\t]* bool = b:("true"/"false") { return b === "true" } `,O0;function Ls(){return O0||(O0=NA.generate(R7)),O0}var kA=ei(tl()),T7=String.raw` // global initializer {{ function $set(obj, path, value) { if (Object(obj) !== obj) return obj; if (!Array.isArray(path)) path = path.toString().match(/[^.[\]]+/g) || []; path .slice(0, -1) .reduce((a, c, i) => (Object(a[c]) === a[c] ? a[c] : (a[c] = Math.abs(path[i + 1]) >> 0 === +path[i + 1] ? [] : {})), obj)[ path[path.length - 1] ] = value; return obj; } function toBool(str) { if (typeof str === 'undefined' || str === null) return undefined; return /(TRUE)|1/i.test(str); } }} { const proxy = {}; const obfs = {}; const $ = {}; const params = {}; } start = (trojan) { return proxy } trojan = "trojan://" password:password "@" server:server ":" port:port "/"? params? name:name?{ proxy.type = "trojan"; proxy.password = password; proxy.server = server; proxy.port = port; proxy.name = name; // name may be empty if (!proxy.name) { proxy.name = server + ":" + port; } }; password = match:$[^@]+ { return decodeURIComponent(match); }; server = ip/domain; domain = match:[0-9a-zA-z-_.]+ { const domain = match.join(""); if (/(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z0-9][a-z0-9-]{0,61}[a-z0-9]/.test(domain)) { return domain; } } ip = & { const start = peg$currPos; let end; let j = start; while (j < input.length) { if (input[j] === ",") break; if (input[j] === ":") end = j; j++; } peg$currPos = end || j; $.ip = input.substring(start, end).trim(); return true; } { return $.ip; } port = digits:[0-9]+ { const port = parseInt(digits.join(""), 10); if (port >= 0 && port <= 65535) { return port; } else { throw new Error("Invalid port: " + port); } } params = "?" head:param tail:("&"@param)* { for (const [key, value] of Object.entries(params)) { params[key] = decodeURIComponent(value); } proxy["skip-cert-verify"] = toBool(params["allowInsecure"]); proxy.sni = params["sni"] || params["peer"]; proxy['client-fingerprint'] = params.fp; proxy.alpn = params.alpn ? decodeURIComponent(params.alpn).split(',') : undefined; if (toBool(params["ws"])) { proxy.network = "ws"; $set(proxy, "ws-opts.path", params["wspath"]); } if (params["type"]) { let httpupgrade proxy.network = params["type"] if(proxy.network === 'httpupgrade') { proxy.network = 'ws' httpupgrade = true } if (['grpc'].includes(proxy.network)) { proxy[proxy.network + '-opts'] = { 'grpc-service-name': params["serviceName"], '_grpc-type': params["mode"], '_grpc-authority': params["authority"], }; } else { if (params["path"]) { $set(proxy, proxy.network+"-opts.path", decodeURIComponent(params["path"])); } if (params["host"]) { $set(proxy, proxy.network+"-opts.headers.Host", decodeURIComponent(params["host"])); } if (httpupgrade) { $set(proxy, proxy.network+"-opts.v2ray-http-upgrade", true); $set(proxy, proxy.network+"-opts.v2ray-http-upgrade-fast-open", true); } } if (['reality'].includes(params.security)) { const opts = {}; if (params.pbk) { opts['public-key'] = params.pbk; } if (params.sid) { opts['short-id'] = params.sid; } if (params.spx) { opts['_spider-x'] = params.spx; } if (params.mode) { proxy._mode = params.mode; } if (params.extra) { proxy._extra = params.extra; } if (Object.keys(opts).length > 0) { $set(proxy, params.security+"-opts", opts); } } } proxy.udp = toBool(params["udp"]); proxy.tfo = toBool(params["tfo"]); } param = kv/single; kv = key:$[a-z]i+ "=" value:$[^&#]i* { params[key] = value; } single = key:$[a-z]i+ { params[key] = true; }; name = "#" + match:$.* { return decodeURIComponent(match); } `,N0;function k0(){return N0||(N0=kA.generate(T7)),N0}function LA(e){let[t,r]=e.match(/,\s*?port-hopping\s*?=\s*?["']?\s*?((\d+(-\d+)?)([,;]\d+(-\d+)?)*)\s*?["']?\s*?/)||[];return{port_hopping:r?r.replace(/;/g,","):void 0,line:t?e.replace(t,""):e}}function x7(){return{name:"URI PROXY Parser",test:n=>/^(socks5\+tls|socks5|http|https):\/\//.test(n),parse:n=>{let[i,a,s,c,l,h,v,E,p]=n.match(/^(socks5|http|http)(\+tls|s)?:\/\/(?:(.*?):(.*?)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(v)v=parseInt(v,10);else{if(s)v=443;else if(a==="http")v=80;else throw O.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);O.info(`port is not present in line: ${n}, set to ${v}`)}return{name:p!=null?decodeURIComponent(p):`${a} ${h}:${v}`,type:a,tls:!!s,server:h,port:v,username:c!=null?decodeURIComponent(c):void 0,password:l!=null?decodeURIComponent(l):void 0}}}}function O7(){return{name:"URI SOCKS Parser",test:n=>/^socks:\/\//.test(n),parse:n=>{let[i,a,s,c,l,h,v]=n.match(/^(socks)?:\/\/(?:(.*)@)?(.*?)(?::(\d+?))?(\?.*?)?(?:#(.*?))?$/);if(l)l=parseInt(l,10);else throw O.error(`port is not present in line: ${n}`),new Error(`port is not present in line: ${n}`);let E,p;if(s){let A=yt.decode(decodeURIComponent(s)).split(":");E=A[0],p=A[1]}return{name:v!=null?decodeURIComponent(v):`${a} ${c}:${l}`,type:"socks5",server:c,port:l,username:E,password:p}}}}function N7(){return{name:"URI SS Parser",test:n=>/^ss:\/\//.test(n),parse:n=>{let i=n.split("ss://")[1],a={name:decodeURIComponent(n.split("#")[1]),type:"ss"};i=i.split("#")[0];let s=i.match(/@([^/]*)(\/|$)/),c=decodeURIComponent(i.split("@")[0]),l;c?.startsWith("2022-blake3-")?l=c:l=yt.decode(c);let h="";if(s)i.includes("?")&&(h=i.match(/(\?.*)$/)[1]);else{if(i.includes("?")){let g=i.match(/^(.*)(\?.*)$/);i=g[1],h=g[2]}if(i=yt.decode(i),h){if(/(&|\?)v2ray-plugin=/.test(h)){let y=h.match(/(&|\?)v2ray-plugin=(.*?)(&|$)/)[2];y&&(a.plugin="v2ray-plugin",a["plugin-opts"]=JSON.parse(yt.decode(y)))}i=`${i}${h}`}l=i.match(/(^.*)@/)?.[1],s=i.match(/@([^/@]*)(\/|$)/)}let v=s[1],E=v.lastIndexOf(":");a.server=v.substring(0,E),a.port=`${v.substring(E+1)}`.match(/\d+/)?.[0];let p=l.match(/(^.*?):(.*$)/);a.cipher=p?.[1],a.password=p?.[2];let f=i.match(/[?&]plugin=([^&]+)/),A=i.match(/[?&]shadow-tls=([^&]+)/);if(f){let g=("plugin="+decodeURIComponent(f[1])).split(";"),y={};for(let w of g){let[S,_]=w.split("=");S&&(y[S]=_||!0)}switch(y.plugin){case"obfs-local":case"simple-obfs":a.plugin="obfs",a["plugin-opts"]={mode:y.obfs,host:qt(y["obfs-host"])};break;case"v2ray-plugin":a.plugin="v2ray-plugin",a["plugin-opts"]={mode:"websocket",host:qt(y["obfs-host"]),path:qt(y.path),tls:Ya(y.tls)};break;case"shadow-tls":{a.plugin="shadow-tls";let w=qt(y.version);a["plugin-opts"]={host:qt(y.host),password:qt(y.password),version:w?parseInt(w,10):void 0};break}default:throw new Error(`Unsupported plugin option: ${y.plugin}`)}}if(A){let g=JSON.parse(yt.decode(A[1])),y=qt(g.version),w=qt(g.address),S=qt(g.port);a.plugin="shadow-tls",a["plugin-opts"]={host:qt(g.host),password:qt(g.password),version:y?parseInt(y,10):void 0},w&&(a.server=w),S&&(a.port=parseInt(S,10))}return/(&|\?)uot=(1|true)/i.test(h)&&(a["udp-over-tcp"]=!0),/(&|\?)tfo=(1|true)/i.test(h)&&(a.tfo=!0),a}}}function k7(){return{name:"URI SSR Parser",test:n=>/^ssr:\/\//.test(n),parse:n=>{n=yt.decode(n.split("ssr://")[1]);let i=n.indexOf(":origin");i===-1&&(i=n.indexOf(":auth_"));let a=n.substring(0,i),s=a.substring(0,a.lastIndexOf(":")),c=a.substring(a.lastIndexOf(":")+1),l=n.substring(i+1).split("/?")[0].split(":"),h={type:"ssr",server:s,port:c,protocol:l[0],cipher:l[1],obfs:l[2],password:yt.decode(l[3])},v={};if(n=n.split("/?")[1].split("&"),n.length>1)for(let E of n){let[p,f]=E.split("=");f=f.trim(),f.length>0&&f!=="(null)"&&(v[p]=f)}return h={...h,name:v.remarks?yt.decode(v.remarks):h.server,"protocol-param":qt(yt.decode(v.protoparam||"").replace(/\s/g,"")),"obfs-param":qt(yt.decode(v.obfsparam||"").replace(/\s/g,""))},h}}}function L7(){return{name:"URI VMess Parser",test:n=>/^vmess:\/\//.test(n),parse:n=>{n=n.split("vmess://")[1];let i=yt.decode(n.replace(/\?.*?$/,""));if(/=\s*vmess/.test(i)){let a=i.split(",").map(l=>l.trim()),s={};for(let l of a)if(l.indexOf("=")!==-1){let[h,v]=l.split("=");s[h.trim()]=v.trim()}let c={name:a[0].split("=")[0].trim(),type:"vmess",server:a[1],port:a[2],cipher:qt(a[3],"auto"),uuid:a[4].match(/^"(.*)"$/)[1],tls:s.obfs==="wss",udp:Ya(s["udp-relay"]),tfo:Ya(s["fast-open"]),"skip-cert-verify":to(s["tls-verification"])?!s["tls-verification"]:void 0};if(to(s.obfs))if(s.obfs==="ws"||s.obfs==="wss"){c.network="ws",c["ws-opts"].path=(qt(s["obfs-path"])||'"/"').match(/^"(.*)"$/)[1];let l=s["obfs-header"];l&&l.indexOf("Host")!==-1&&(l=l.match(/Host:\s*([a-zA-Z0-9-.]*)/)[1]),xi(l)&&(c["ws-opts"].headers={Host:l})}else throw new Error(`Unsupported obfs: ${s.obfs}`);return c}else{let a={};try{a=JSON.parse(i)}catch{let[E,p,f]=/(^[^?]+?)\/?\?(.*)$/.exec(n);i=yt.decode(p);for(let _ of f.split("&")){let[I,B]=_.split("="),q=B;q=decodeURIComponent(B),q.indexOf(",")===-1?a[I]=q:a[I]=q.split(",")}let[A,g,y,w,S]=/(^[^:]+?):([^:]+?)@(.*):(\d+)$/.exec(i);a.scy=g,a.id=y,a.port=S,a.add=w}let s=a.add,c=parseInt(Ya(a.port),10),l={name:a.ps??a.remarks??a.remark??`VMess ${s}:${c}`,type:"vmess",server:s,port:c,cipher:Ya(a.scy,"auto"),uuid:a.id,alterId:parseInt(Ya(a.aid??a.alterId,0),10),tls:["tls",!0,1,"1"].includes(a.tls),"skip-cert-verify":to(a.verify_cert)?!a.verify_cert:void 0};!l["skip-cert-verify"]&&to(a.allowInsecure)&&(l["skip-cert-verify"]=/(TRUE)|1/i.test(a.allowInsecure)),l.tls&&a.sni&&a.sni!==""&&(l.sni=a.sni);let h=!1;if(a.net==="ws"||a.obfs==="websocket"?l.network="ws":["http"].includes(a.net)||["http"].includes(a.obfs)||["http"].includes(a.type)?l.network="http":["grpc"].includes(a.net)?l.network="grpc":a.net==="httpupgrade"||l.network==="httpupgrade"?(l.network="ws",h=!0):(a.net==="h2"||l.network==="h2")&&(l.network="h2"),l.network){let v=a.host??a.obfsParam;try{let f=JSON.parse(v)?.Host;f&&(v=f)}catch{}let E=a.path;if(["ws"].includes(l.network)&&(E=E||"/"),l.network==="http"&&(v&&(v=v.split(",").map(p=>p.trim()),v=Array.isArray(v)?v[0]:v),E?E=Array.isArray(E)?E[0]:E:E="/"),E||v)if(["grpc"].includes(l.network))l[`${l.network}-opts`]={"grpc-service-name":qt(E),"_grpc-type":qt(a.type),"_grpc-authority":qt(a.authority)};else{let p={path:qt(E),headers:{Host:qt(v)}};h&&(p["v2ray-http-upgrade"]=!0,p["v2ray-http-upgrade-fast-open"]=!0),l[`${l.network}-opts`]=p}else delete l.network}return l}}}}function U7(){return{name:"URI VLESS Parser",test:n=>/^vless:\/\//.test(n),parse:n=>{n=n.split("vless://")[1];let i,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);if(!a){let[y,w,S]=/^(.*?)(\?.*?$)/.exec(n);n=`${yt.decode(w)}${S}`,a=/^(.*?)@(.*?):(\d+)\/?(\?(.*?))?(?:#(.*?))?$/.exec(n),i=!0}let[s,c,l,h,v,E="",p]=a;i&&(c=c.replace(/^.*?:/g,"")),h=parseInt(`${h}`,10),c=decodeURIComponent(c),p!=null&&(p=decodeURIComponent(p));let f={type:"vless",name:p,server:l,port:h,uuid:c},A={};for(let y of E.split("&")){let[w,S]=y.split("="),_=S;_=decodeURIComponent(S),A[w]=_}if(f.name=p??A.remarks??A.remark??`VLESS ${l}:${h}`,f.tls=A.security&&A.security!=="none",i&&/TRUE|1/i.test(A.tls)&&(f.tls=!0,A.security=A.security??"reality"),f.sni=A.sni||A.peer,f.flow=A.flow,!f.flow&&i&&A.xtls){let y=[void 0,"xtls-rprx-direct","xtls-rprx-vision"][A.xtls];y&&(f.flow=y)}if(f["client-fingerprint"]=A.fp,f.alpn=A.alpn?A.alpn.split(","):void 0,f["skip-cert-verify"]=/(TRUE)|1/i.test(A.allowInsecure),["reality"].includes(A.security)){let y={};A.pbk&&(y["public-key"]=A.pbk),A.sid&&(y["short-id"]=A.sid),A.spx&&(y["_spider-x"]=A.spx),Object.keys(y).length>0&&(f[`${A.security}-opts`]=y)}let g=!1;if(f.network=A.type,f.network==="tcp"&&A.headerType==="http"?f.network="http":f.network==="httpupgrade"&&(f.network="ws",g=!0),!f.network&&i&&A.obfs&&(f.network=A.obfs,["none"].includes(f.network)&&(f.network="tcp")),["websocket"].includes(f.network)&&(f.network="ws"),f.network&&!["tcp","none"].includes(f.network)){let y={},w=A.host??A.obfsParam;if(w)if(A.obfsParam)try{let S=JSON.parse(w);y.headers=S}catch{y.headers={Host:w}}else y.headers={Host:w};A.serviceName?(y[`${f.network}-service-name`]=A.serviceName,["grpc"].includes(f.network)&&A.authority&&(y["_grpc-authority"]=A.authority)):i&&A.path&&(["ws","http","h2"].includes(f.network)||(y[`${f.network}-service-name`]=A.path,delete A.path)),A.path&&(y.path=A.path),["grpc"].includes(f.network)&&(y["_grpc-type"]=A.mode||"gun"),g&&(y["v2ray-http-upgrade"]=!0,y["v2ray-http-upgrade-fast-open"]=!0),Object.keys(y).length>0&&(f[`${f.network}-opts`]=y),f.network==="kcp"&&(A.seed&&(f.seed=A.seed),f.headerType=A.headerType||"none"),A.mode&&(f._mode=A.mode),A.extra&&(f._extra=A.extra)}return f}}}function H7(){return{name:"URI AnyTLS Parser",test:n=>/^anytls:\/\//.test(n),parse:n=>{n=n.split(/anytls:\/\//)[1];let[i,a,s,c,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a),c=parseInt(`${c}`,10),isNaN(c)&&(c=443),a=decodeURIComponent(a),h!=null&&(h=decodeURIComponent(h)),h=h??`AnyTLS ${s}:${c}`;let v={type:"anytls",name:h,server:s,port:c,password:a};for(let E of l.split("&")){let[p,f]=E.split("=");p=p.replace(/_/g,"-"),f=decodeURIComponent(f),["alpn"].includes(p)?v[p]=f?f.split(","):void 0:["insecure"].includes(p)?v["skip-cert-verify"]=/(TRUE)|1/i.test(f):v[p]=f}return v}}}function j7(){return{name:"URI Hysteria2 Parser",test:n=>/^(hysteria2|hy2):\/\//.test(n),parse:n=>{n=n.split(/(hysteria2|hy2):\/\//)[2];let i,[a,s,c,l,h,v,E,p,f,A,g="",y]=/^(.*?)@(.*?)(:((\d+(-\d+)?)([,;]\d+(-\d+)?)*))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);/^\d+$/.test(h)?(h=parseInt(`${h}`,10),isNaN(h)&&(h=443)):h?(i=h,h=Fc(i)):h=443,s=decodeURIComponent(s),y!=null&&(y=decodeURIComponent(y)),y=y??`Hysteria2 ${c}:${h}`;let w={type:"hysteria2",name:y,server:c,port:h,ports:i,password:s},S={};for(let B of g.split("&")){let[q,z]=B.split("="),F=z;F=decodeURIComponent(z),S[q]=F}w.sni=S.sni,!w.sni&&S.peer&&(w.sni=S.peer),S.obfs&&S.obfs!=="none"&&(w.obfs=S.obfs),S.mport&&(w.ports=S.mport),w["obfs-password"]=S["obfs-password"],w["skip-cert-verify"]=/(TRUE)|1/i.test(S.insecure),w.tfo=/(TRUE)|1/i.test(S.fastopen),w["tls-fingerprint"]=S.pinSHA256;let _=S["hop-interval"]||S.hop_interval;/^\d+$/.test(_)&&(w["hop-interval"]=parseInt(`${_}`,10));let I=S.keepalive;return/^\d+$/.test(I)&&(w.keepalive=parseInt(`${I}`,10)),w}}}function M7(){return{name:"URI Hysteria Parser",test:n=>/^(hysteria|hy):\/\//.test(n),parse:n=>{n=n.split(/(hysteria|hy):\/\//)[2];let[i,a,s,c,l,h="",v]=/^(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);c=parseInt(`${c}`,10),isNaN(c)&&(c=443),v!=null&&(v=decodeURIComponent(v)),v=v??`Hysteria ${a}:${c}`;let E={type:"hysteria",name:v,server:a,port:c},p={};for(let f of h.split("&")){let[A,g]=f.split("=");A=A.replace(/_/,"-"),g=decodeURIComponent(g),["alpn"].includes(A)?E[A]=g?g.split(","):void 0:["insecure"].includes(A)?E["skip-cert-verify"]=/(TRUE)|1/i.test(g):["auth"].includes(A)?E["auth-str"]=g:["mport"].includes(A)?E.ports=g:["obfsParam"].includes(A)?E.obfs=g:["upmbps"].includes(A)?E.up=g:["downmbps"].includes(A)?E.down=g:["obfs"].includes(A)?E._obfs=g||"":["fast-open","peer"].includes(A)?p[A]=g:E[A]=g}return!E.sni&&p.peer&&(E.sni=p.peer),!E["fast-open"]&&p.fastopen&&(E["fast-open"]=!0),E.protocol||(E.protocol="udp"),E}}}function q7(){return{name:"URI TUIC Parser",test:n=>/^tuic:\/\//.test(n),parse:n=>{n=n.split(/tuic:\/\//)[1];let[i,a,s,c,l="",h]=/^(.*?)@(.*?)(?::(\d+))?\/?(?:\?(.*?))?(?:#(.*?))?$/.exec(n);a=decodeURIComponent(a);let[v,...E]=a.split(":"),p=E.join(":");c=parseInt(`${c}`,10),isNaN(c)&&(c=443),p=decodeURIComponent(p),h!=null&&(h=decodeURIComponent(h)),h=h??`TUIC ${s}:${c}`;let f={type:"tuic",name:h,server:s,port:c,password:p,uuid:v};for(let A of l.split("&")){let[g,y]=A.split("=");g=g.replace(/_/g,"-"),y=decodeURIComponent(y),["alpn"].includes(g)?f[g]=y?y.split(","):void 0:["allow-insecure"].includes(g)?f["skip-cert-verify"]=/(TRUE)|1/i.test(y):["fast-open"].includes(g)?f.tfo=!0:["disable-sni","reduce-rtt"].includes(g)?f[g]=/(TRUE)|1/i.test(y):f[g]=y}return f}}}function K7(){return{name:"URI WireGuard Parser",test:n=>/^(wireguard|wg):\/\//.test(n),parse:n=>{n=n.split(/(wireguard|wg):\/\//)[2];let[i,a,s,c,l,h,v,E="",p]=/^((.*?)@)?(.*?)(:(\d+))?\/?(\?(.*?))?(?:#(.*?))?$/.exec(n);h=parseInt(`${h}`,10),isNaN(h)&&(h=51820),s=decodeURIComponent(s),p!=null&&(p=decodeURIComponent(p)),p=p??`WireGuard ${c}:${h}`;let f={type:"wireguard",name:p,server:c,port:h,"private-key":s,udp:!0};for(let A of E.split("&")){let[g,y]=A.split("=");if(g=g.replace(/_/,"-"),y=decodeURIComponent(y),["reserved"].includes(g)){let w=y.split(",").map(S=>parseInt(S.trim(),10)).filter(S=>Number.isInteger(S));w.length===3&&(f[g]=w)}else if(["address","ip"].includes(g))y.split(",").map(w=>{let S=w.trim().replace(/\/\d+$/,"").replace(/^\[/,"").replace(/\]$/,"");fr(S)?f.ip=S:hr(S)&&(f.ipv6=S)});else if(["mtu"].includes(g)){let w=parseInt(y.trim(),10);Number.isInteger(w)&&(f[g]=w)}else/publickey/i.test(g)?f["public-key"]=y:/privatekey/i.test(g)?f["private-key"]=y:["udp"].includes(g)?f[g]=/(TRUE)|1/i.test(y):["flag"].includes(g)||(f[g]=y)}return f}}}function V7(){return{name:"URI Trojan Parser",test:n=>/^trojan:\/\//.test(n),parse:n=>{let i=/^(trojan:\/\/.*?@.*?)(:(\d+))?\/?(\?.*?)?$/.exec(n);i?.[2]||(n=n.replace(i[1],`${i[1]}:443`));let[s,c]=n.split(/#(.+)/,2),h=k0().parse(s);if(xi(c))try{h.name=decodeURIComponent(c)}catch(v){console.log(v)}return h}}}function G7(){return{name:"Clash Parser",test:n=>{try{JSON.parse(n)}catch{return!1}return!0},parse:n=>{let i=JSON.parse(n);if(!["anytls","mieru","juicity","ss","ssr","vmess","socks5","http","snell","trojan","tuic","vless","hysteria","hysteria2","wireguard","ssh","direct"].includes(i.type))throw new Error(`Clash does not support proxy with type: ${i.type}`);return["vmess","vless"].includes(i.type)&&(i.sni=i.servername,delete i.servername),i["server-cert-fingerprint"]&&(i["tls-fingerprint"]=i["server-cert-fingerprint"]),i.fingerprint&&(i["tls-fingerprint"]=i.fingerprint),i["dialer-proxy"]&&(i["underlying-proxy"]=i["dialer-proxy"]),i["benchmark-url"]&&(i["test-url"]=i["benchmark-url"]),i["benchmark-timeout"]&&(i["test-timeout"]=i["benchmark-timeout"]),i}}}function z7(){return{name:"QX SS Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")===-1,parse:n=>Ls().parse(n)}}function Y7(){return{name:"QX SSR Parser",test:n=>/^shadowsocks\s*=/.test(n.split(",")[0].trim())&&n.indexOf("ssr-protocol")!==-1,parse:n=>Ls().parse(n)}}function W7(){return{name:"QX VMess Parser",test:n=>/^vmess\s*=/.test(n.split(",")[0].trim()),parse:n=>Ls().parse(n)}}function X7(){return{name:"QX VLESS Parser",test:n=>/^vless\s*=/.test(n.split(",")[0].trim()),parse:n=>Ls().parse(n)}}function J7(){return{name:"QX Trojan Parser",test:n=>/^trojan\s*=/.test(n.split(",")[0].trim()),parse:n=>Ls().parse(n)}}function Z7(){return{name:"QX HTTP Parser",test:n=>/^http\s*=/.test(n.split(",")[0].trim()),parse:n=>Ls().parse(n)}}function Q7(){return{name:"QX Socks5 Parser",test:n=>/^socks5\s*=/.test(n.split(",")[0].trim()),parse:n=>Ls().parse(n)}}function eP(){return{name:"Loon SS Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocks",parse:n=>Wi().parse(n)}}function tP(){return{name:"Loon SSR Parser",test:n=>n.split(",")[0].split("=")[1].trim().toLowerCase()==="shadowsocksr",parse:n=>Wi().parse(n)}}function rP(){return{name:"Loon VMess Parser",test:n=>/^.*=\s*vmess/i.test(n.split(",")[0])&&n.indexOf("username")===-1,parse:n=>Wi().parse(n)}}function nP(){return{name:"Loon Vless Parser",test:n=>/^.*=\s*vless/i.test(n.split(",")[0]),parse:n=>Wi().parse(n)}}function iP(){return{name:"Loon Trojan Parser",test:n=>/^.*=\s*trojan/i.test(n.split(",")[0]),parse:n=>Wi().parse(n)}}function sP(){return{name:"Loon Hysteria2 Parser",test:n=>/^.*=\s*Hysteria2/i.test(n.split(",")[0]),parse:n=>Wi().parse(n)}}function aP(){return{name:"Loon HTTP Parser",test:n=>/^.*=\s*http/i.test(n.split(",")[0]),parse:n=>Wi().parse(n)}}function uP(){return{name:"Loon SOCKS5 Parser",test:n=>/^.*=\s*socks5/i.test(n.split(",")[0]),parse:n=>Wi().parse(n)}}function oP(){return{name:"Loon WireGuard Parser",test:n=>/^.*=\s*wireguard/i.test(n.split(",")[0]),parse:n=>{let i=n.match(/(^.*?)\s*?=\s*?wireguard\s*?,.+?\s*?=\s*?.+?/i)?.[1];n=n.replace(i,"").replace(/^\s*?=\s*?wireguard\s*/i,"");let a=n.match(/,\s*?peers\s*?=\s*?\[\s*?\{\s*?(.+?)\s*?\}\s*?\]/i)?.[1],s=a.match(/(,|^)\s*?endpoint\s*?=\s*?"?(.+?):(\d+)"?\s*?(,|$)/i),c=s?.[2],l=parseInt(s?.[3],10),h=n.match(/(,|^)\s*?mtu\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];h&&(h=parseInt(h,10));let v=n.match(/(,|^)\s*?keepalive\s*?=\s*?"?(\d+?)"?\s*?(,|$)/i)?.[2];v&&(v=parseInt(v,10));let E=a.match(/(,|^)\s*?reserved\s*?=\s*?"?(\[\s*?.+?\s*?\])"?\s*?(,|$)/i)?.[2];E&&(E=JSON.parse(E));let p,f=n.match(/(,|^)\s*?dns\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],A=n.match(/(,|^)\s*?dnsv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2];(f||A)&&(p=[],f&&p.push(f),A&&p.push(A));let g=a.match(/(,|^)\s*?allowed-ips\s*?=\s*?"(.+?)"\s*?(,|$)/i)?.[2]?.split(",").map(B=>B.trim()),y=a.match(/(,|^)\s*?preshared-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],w=n.match(/(,|^)\s*?interface-ip\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],S=n.match(/(,|^)\s*?interface-ipv6\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],_=a.match(/(,|^)\s*?public-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],I={type:"wireguard",name:i,server:c,port:l,ip:w,ipv6:S,"private-key":n.match(/(,|^)\s*?private-key\s*?=\s*?"?(.+?)"?\s*?(,|$)/i)?.[2],"public-key":_,mtu:h,keepalive:v,reserved:E,"allowed-ips":g,"preshared-key":y,dns:p,udp:!0,peers:[{server:c,port:l,ip:w,ipv6:S,"public-key":_,"pre-shared-key":y,"allowed-ips":g,reserved:E}]};return Array.isArray(I.dns)&&I.dns.length>0&&(I["remote-dns-resolve"]=!0),I}}}function cP(){return{name:"Surge Direct Parser",test:n=>/^.*=\s*direct/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function lP(){return{name:"Surge SSH Parser",test:n=>/^.*=\s*ssh/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function fP(){return{name:"Surge SS Parser",test:n=>/^.*=\s*ss/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function hP(){return{name:"Surge VMess Parser",test:n=>/^.*=\s*vmess/.test(n.split(",")[0])&&n.indexOf("username")!==-1,parse:n=>Kn().parse(n)}}function pP(){return{name:"Surge Trojan Parser",test:n=>/^.*=\s*trojan/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function dP(){return{name:"Surge HTTP Parser",test:n=>/^.*=\s*https?/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function gP(){return{name:"Surge Socks5 Parser",test:n=>/^.*=\s*socks5(-tls)?/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function mP(){return{name:"Surge External Parser",test:n=>/^.*=\s*external/.test(n.split(",")[0]),parse:n=>{let i=/^\s*(.*?)\s*?=\s*?external\s*?,\s*(.*?)\s*$/.exec(n),[a,s,c]=i;n=c;let l=/(,|^)\s*?exec\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];l||(l=/(,|^)\s*?exec\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let h=/(,|^)\s*?local-port\s*?=\s*"(.*?)"\s*?(,|$)/.exec(n)?.[2];h||(h=/(,|^)\s*?local-port\s*?=\s*(.*?)\s*?(,|$)/.exec(n)?.[2]);let v=/(,|^)\s*?args\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,E,p=[];for(;(E=v.exec(n))!==null;)E[3]!=null?p.push(E[3]):E[4]!=null&&p.push(E[4]);let f=/(,|^)\s*?addresses\s*?=\s*("(.*?)"|(.*?))(?=\s*?(,|$))/g,A,g=[];for(;(A=f.exec(n))!==null;){let w;A[3]!=null?w=A[3]:A[4]!=null&&(w=A[4]),w!=null&&(w=`${w}`.trim().replace(/^\[/,"").replace(/\]$/,"")),yP(w)&&g.push(w)}return{type:"external",name:s,exec:l,"local-port":h,args:p,addresses:g}}}}function vP(){return{name:"Surge Snell Parser",test:n=>/^.*=\s*snell/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function wP(){return{name:"Surge Tuic Parser",test:n=>/^.*=\s*tuic(-v5)?/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=LA(n),s=Kn().parse(a);return s.ports=i,s}}}function AP(){return{name:"Surge WireGuard Parser",test:n=>/^.*=\s*wireguard/.test(n.split(",")[0]),parse:n=>Kn().parse(n)}}function EP(){return{name:"Surge Hysteria2 Parser",test:n=>/^.*=\s*hysteria2/.test(n.split(",")[0]),parse:n=>{let{port_hopping:i,line:a}=LA(n),s=Kn().parse(a);return s.ports=i,s}}}function yP(e){return fr(e)||hr(e)}var UA=[x7(),O7(),N7(),k7(),L7(),U7(),q7(),K7(),M7(),j7(),V7(),H7(),G7(),cP(),lP(),fP(),hP(),pP(),dP(),vP(),wP(),AP(),EP(),gP(),mP(),eP(),tP(),rP(),nP(),sP(),iP(),aP(),uP(),oP(),z7(),Y7(),W7(),X7(),J7(),Z7(),Q7()];function SP(e){for(let t of Rf)try{if(t.test(e))return O.info(`Pre-processor [${t.name}] activated`),t.parse(e)}catch(r){O.error(`Parser [${t.name}] failed Reason: ${r}`)}return e}function bP(e){e=SP(e);let t=e.split(` `),r=[],n;for(let i of t){if(i=i.trim(),i.length===0)continue;let a=!1;if(n){let[s,c]=HA(n,i);c||(r.push(MA(s)),a=!0)}if(!a)for(let s of UA){let[c,l]=HA(s,i);if(!l){r.push(MA(c)),n=s,a=!0,O.info(`${s.name} is activated`);break}}a||O.error(`Failed to parse line: ${i}`)}return r.filter(i=>(["vless","vmess"].includes(i.type)&&(ff(i.uuid)||O.error(`UUID may be invalid: ${i.name} ${i.uuid}`)),!0))}async function CP(e,t=[],r,n,i){for(let a of t){if(a.disabled){O.log(`Skipping disabled operator: "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);continue}let s,c={};if(a.type.indexOf("Script")!==-1){let{mode:h,content:v}=a.args;if(h==="link"){let E=v||"",p=E.split("#");if(p.length>1)try{c=JSON.parse(decodeURIComponent(p[1]))}catch{for(let g of p[1].split("&")){let y=g.split("=")[0],w=g.split("=")[1];c[y]=w==null||w===""?!0:decodeURIComponent(w)}}E=`${E.split("#")[0]}${p[2]?`#${p[2]}`:c?.noCache!=null||c?.insecure!=null?`#${p[1]}`:""}`;let f=E.match(/^\/api\/(file|module)\/(.+)/);if(f){let A="";try{A=f?.[1];let g=f?.[2];if(g==null)throw new Error(`\u672C\u5730 ${A} URL \u65E0\u6548: ${E}`);g=decodeURIComponent(g);let y=A==="module"?gn:dt,w=gt(O.read(y),g);if(!w)throw new Error(`\u627E\u4E0D\u5230 ${A}: ${g}`);A==="module"?s=w.content:s=await la({type:"file",name:g})}catch(g){throw O.error(`Error when loading ${A}: ${a.args.content}. Reason: ${g}`),new Error(`\u65E0\u6CD5\u52A0\u8F7D ${A}: ${E}`)}}else try{s=await xn(E)}catch(A){throw O.error(`Error when downloading remote script: ${a.args.content}. Reason: ${A}`),new Error(`\u65E0\u6CD5\u4E0B\u8F7D\u811A\u672C: ${E}`)}}else s=v,c=a.args.arguments||{}}if(!nh[a.type]){O.error(`Unknown operator: "${a.type}"`);continue}O.log(`Applying "${a.type}" with arguments: >>> ${JSON.stringify(a.args,null,2)||"None"}`);let l;a.type.indexOf("Script")!==-1?l=nh[a.type](s,r,c,n,i):l=nh[a.type](a.args||{}),e=await yw(l,e)}return e}function FP(e,t,r,n={}){let i=Dw[t];if(!i)throw new Error(`Target platform: ${t} is not supported!`);let a=/Surge|SurgeMac|Shadowrocket/i.test(t);if(e=e.filter(s=>s.supported&&s.supported[t]===!1?!1:(["vless","vmess"].includes(s.type)&&(ff(s.uuid)||O.error(`UUID may be invalid: ${s.name} ${s.uuid}`)),!0)),e=e.map(s=>(s._resolved=s.resolved,xi(s.name)||(s.name=`${s.type} ${s.server}:${s.port}`),s["disable-sni"]&&(a?s.sni="off":["tuic"].includes(s.type)||(O.error(`Target platform ${t} does not support sni off. Proxy's fields (sni, tls-fingerprint and skip-cert-verify) will be modified.`),s.sni="",s["skip-cert-verify"]=!0,delete s["tls-fingerprint"])),s.ports&&(s.ports=String(s.ports),["ClashMeta"].includes(t)||(s.ports=s.ports.replace(/\//g,",")),s.port||(s.port=Fc(s.ports))),s)),O.log(`Producing proxies for target: ${t}`),typeof i.type>"u"||i.type==="SINGLE"){let s=e.map(c=>{try{return i.produce(c,r,n)}catch(l){return O.error(`Cannot produce proxy: ${JSON.stringify(c,null,2)} Reason: ${l}`),""}}).filter(c=>c.length>0);return s=r==="internal"?s:s.join(` `),t.startsWith("Surge")&&e.length>0&&e.every(c=>c.type==="wireguard")&&(s=`#!name=${e[0]?._subName} #!desc=${e[0]?._desc??""} #!category=${e[0]?._category??""} ${s}`),s}else if(i.type==="ALL")return i.produce(e,r,n)}var Un={parse:bP,process:CP,produce:FP,ipAddress:lf,getRandomPort:Fc,isIPv4:fr,isIPv6:hr,isIP:U0,yaml:su,getFlag:Co,removeFlag:Mc,getISO:rw,MMDB:Jf,Gist:ni,download:xn,isValidUUID:ff,doh:_o};function HA(e,t){if(!_P(e,t))return[null,new Error("Parser mismatch")];try{return[e.parse(t),null]}catch(r){return[null,r]}}function _P(e,t){try{return e.test(t)}catch{return!1}}function jA(e){if(typeof e=="string"||typeof e=="number"){if(e=String(e).trim(),e==="")return"/";if(!e.startsWith("/"))return"/"+e}return e}function MA(e){typeof e.cipher=="string"&&(e.cipher=e.cipher.toLowerCase()),typeof e.password=="number"&&(e.password=Yg(e.password)),["ss"].includes(e.type)&&e.cipher==="none"&&!e.password&&(e.password=""),e.interface&&(e["interface-name"]=e.interface,delete e.interface),zg(e.port)&&(e.port=parseInt(e.port,10)),e.server&&(e.server=`${e.server}`.trim().replace(/^\[/,"").replace(/\]$/,"")),e.network==="ws"&&(!e["ws-opts"]&&(e["ws-path"]||e["ws-headers"])&&(e["ws-opts"]={},e["ws-path"]&&(e["ws-opts"].path=e["ws-path"]),e["ws-headers"]&&(e["ws-opts"].headers=e["ws-headers"])),delete e["ws-path"],delete e["ws-headers"]);let t=e[`${e.network}-opts`]?.path;if(Array.isArray(t)?e[`${e.network}-opts`].path=t.map(n=>jA(n)):t!=null&&(e[`${e.network}-opts`].path=jA(t)),e.type==="trojan"&&e.network==="tcp"&&delete e.network,["vless"].includes(e.type)&&(e.network||(e.network="tcp")),["trojan","tuic","hysteria","hysteria2","juicity","anytls"].includes(e.type)&&(e.tls=!0),e.network){let n=e[`${e.network}-opts`]?.headers?.Host,i=e[`${e.network}-opts`]?.headers?.host;e.network==="h2"?!i&&n&&(e[`${e.network}-opts`].headers.host=n,delete e[`${e.network}-opts`].headers.Host):i&&!n&&(e[`${e.network}-opts`].headers.Host=i,delete e[`${e.network}-opts`].headers.host)}if(e.network==="h2"){let n=e["h2-opts"]?.headers?.host,i=e["h2-opts"]?.path;n&&!Array.isArray(n)&&(e["h2-opts"].headers.host=[n]),Array.isArray(i)&&(e["h2-opts"].path=i[0])}if(!e.tls&&["ws","http"].includes(e.network)&&!e[`${e.network}-opts`]?.headers?.Host&&!U0(e.server)&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].headers=e[`${e.network}-opts`].headers||{},e[`${e.network}-opts`].headers.Host=["vmess","vless"].includes(e.type)&&e.network==="http"?[e.server]:e.server),["vmess","vless"].includes(e.type)&&e.network==="http"){let n=e[`${e.network}-opts`]?.path,i=e[`${e.network}-opts`]?.headers?.Host;i&&!Array.isArray(i)&&(e[`${e.network}-opts`].headers.Host=[i]),n&&!Array.isArray(n)&&(e[`${e.network}-opts`].path=[n])}if(e.tls&&!e.sni&&(U0(e.server)||(e.sni=e.server),!e.sni&&e.network)){let n=e[`${e.network}-opts`]?.headers?.Host;n=Array.isArray(n)?n[0]:n,n&&(e.sni=n)}if(e.ports?e.ports=String(e.ports).replace(/\//g,","):delete e.ports,["hysteria2"].includes(e.type)&&e.obfs&&!["salamander"].includes(e.obfs)&&!e["obfs-password"]&&(e["obfs-password"]=e.obfs,e.obfs="salamander"),["hysteria2"].includes(e.type)&&!e["obfs-password"]&&e.obfs_password&&(e["obfs-password"]=e.obfs_password,delete e.obfs_password),["vless"].includes(e.type)&&(e["reality-opts"]&&Object.keys(e["reality-opts"]).length===0&&delete e["reality-opts"],e["grpc-opts"]&&Object.keys(e["grpc-opts"]).length===0&&delete e["grpc-opts"],!e["reality-opts"]&&!e.flow&&delete e.flow,["http"].includes(e.network)&&(e[`${e.network}-opts`]?.path||(e[`${e.network}-opts`]||(e[`${e.network}-opts`]={}),e[`${e.network}-opts`].path=["/"]))),typeof e.name!="string")if(/^\d+$/.test(e.name))e.name=`${e.name}`;else try{e.name?.data?e.name=L0.Buffer.from(e.name.data).toString("utf8"):e.name=L0.Buffer.from(e.name).toString("utf8")}catch(n){O.error(`proxy.name decode failed Reason: ${n}`),e.name=`${e.type} ${e.server}:${e.port}`}["ws","http","h2"].includes(e.network)&&(["ws","h2"].includes(e.network)&&!e[`${e.network}-opts`]?.path?(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path="/"):e.network==="http"&&(!Array.isArray(e[`${e.network}-opts`]?.path)||e[`${e.network}-opts`]?.path.every(n=>!n))&&(e[`${e.network}-opts`]=e[`${e.network}-opts`]||{},e[`${e.network}-opts`].path=["/"])),["","off"].includes(e.sni)&&(e["disable-sni"]=!0);let r=e.ca_str;e["ca-str"]?r=e["ca-str"]:r&&(delete e.ca_str,e["ca-str"]=r);try{O.env.isNode&&!r&&e._ca&&(r=O.node.fs.readFileSync(e._ca,{encoding:"utf8"}))}catch(n){O.error(`Read ca file failed Reason: ${n}`)}return!e["tls-fingerprint"]&&r&&(e["tls-fingerprint"]=tw.generateFingerprint(r)),["ss"].includes(e.type)&&ae(e,"shadow-tls-password")&&(e.plugin="shadow-tls",e["plugin-opts"]={host:e["shadow-tls-sni"],password:e["shadow-tls-password"],version:e["shadow-tls-version"]},delete e["shadow-tls-sni"],delete e["shadow-tls-password"],delete e["shadow-tls-version"]),e}function U0(e){return fr(e)||hr(e)}function IP(){return{name:"HTML",test:n=>/^/.test(n),parse:()=>""}}function DP(){return{name:"Clash Provider",test:n=>/^payload:/gm.exec(n).index>=0,parse:n=>n.replace("payload:","").replace(/^\s*-\s*/gm,"")}}var qA=[IP(),DP()];function BP(){return{type:"SINGLE",func:r=>["URL-REGEX","DEST-PORT","SRC-IP","IN-PORT","PROTOCOL","GEOSITE","GEOIP"].indexOf(r.type)!==-1?null:`${{"DOMAIN-KEYWORD":"HOST-KEYWORD","DOMAIN-SUFFIX":"HOST-SUFFIX",DOMAIN:"HOST","IP-CIDR6":"IP6-CIDR"}[r.type]||r.type},${r.content},SUB-STORE`}}function KA(){return{type:"SINGLE",func:r=>{if(["GEOSITE","GEOIP"].indexOf(r.type)!==-1)return null;let i=`${r.type},${r.content}`;return["IP-CIDR","IP-CIDR6"].includes(r.type)&&(i+=r.options?.length>0?`,${r.options.join(",")}`:""),i}}}function PP(){return{type:"SINGLE",func:r=>["SRC-IP","GEOSITE","GEOIP"].indexOf(r.type)!==-1?null:(["IP-CIDR","IP-CIDR6"].includes(r.type)&&r.options&&(r.options=r.options.filter(i=>["no-resolve"].includes(i))),KA().func(r))}}function $P(){return{type:"ALL",func:r=>{let n={"DEST-PORT":"DST-PORT","SRC-IP":"SRC-IP-CIDR","IN-PORT":"SRC-PORT"},i={payload:r.map(a=>{let s=`${n[a.type]||a.type},${a.content}`;return["IP-CIDR","IP-CIDR6","GEOIP"].includes(a.type)&&(a.options&&(a.options=a.options.filter(c=>["no-resolve"].includes(c))),s+=a.options?.length>0?`,${a.options.join(",")}`:""),s})};return su.dump(i)}}}var VA={QX:BP(),Surge:KA(),Loon:PP(),Clash:$P()};var RP=[[/^(DOMAIN|host|HOST)$/,"DOMAIN"],[/^(DOMAIN-KEYWORD|host-keyword|HOST-KEYWORD)$/,"DOMAIN-KEYWORD"],[/^(DOMAIN-SUFFIX|host-suffix|HOST-SUFFIX)$/,"DOMAIN-SUFFIX"],[/^USER-AGENT$/i,"USER-AGENT"],[/^PROCESS-NAME$/,"PROCESS-NAME"],[/^(DEST-PORT|DST-PORT)$/,"DST-PORT"],[/^SRC-IP(-CIDR)?$/,"SRC-IP"],[/^(IN|SRC)-PORT$/,"IN-PORT"],[/^PROTOCOL$/,"PROTOCOL"],[/^IP-CIDR$/i,"IP-CIDR"],[/^(IP-CIDR6|ip6-cidr|IP6-CIDR)$/,"IP-CIDR6"],[/^GEOIP$/i,"GEOIP"],[/^GEOSITE$/i,"GEOSITE"]];function TP(){return{name:"Universal Rule Parser",test:()=>!0,parse:n=>{let i=n.split(` `),a=[];for(let s of i)if(s=s.trim(),s.length!==0&&!/\s*#/.test(s))try{let c=s.split(",").map(v=>v.trim()),l=c[0],h=!1;for(let v of RP)if(v[0].test(l)){h=!0;let p={type:v[1],content:c[1]};["IP-CIDR","IP-CIDR6","GEOIP"].includes(p.type)&&(p.options=c.slice(2)),a.push(p)}if(!h)throw new Error("Invalid rule type: "+l)}catch(c){console.log(`Failed to parse line: ${s} Reason: ${c}`)}return a}}}var GA=[TP()];var mh=function(){function e(n){for(let i of qA)try{if(i.test(n))return O.info(`Pre-processor [${i.name}] activated`),i.parse(n)}catch(a){O.error(`Parser [${i.name}] failed Reason: ${a}`)}return n}function t(n){n=e(n);for(let i of GA){let a;try{a=i.test(n)}catch{a=!1}if(a)return O.info(`Rule parser [${i.name}] is activated!`),i.parse(n)}}function r(n,i){let a=VA[i];if(!a)throw new Error(`Target platform: ${i} is not supported!`);if(typeof a.type>"u"||a.type==="SINGLE")return n.map(s=>{try{return a.func(s)}catch(c){return console.log(`ERROR: cannot produce rule: ${JSON.stringify(s)} Reason: ${c}`),""}}).filter(s=>s.length>0).join(` `);if(a.type==="ALL")return a.func(n)}return{parse:t,produce:r}}();async function la({type:e,name:t,platform:r,url:n,ua:i,content:a,mergeSources:s,ignoreFailedRemoteSub:c,ignoreFailedRemoteFile:l,produceType:h,produceOpts:v={},subscription:E,awaitCustomCache:p,$options:f,proxy:A,noCache:g}){if(r=r||"JSON",["subscription","sub"].includes(e)){let y;if(t){let I=O.read(Lt);if(y=gt(I,t),!y)throw new Error(`\u627E\u4E0D\u5230\u8BA2\u9605 ${t}`)}else if(E)y=E;else throw new Error("\u672A\u63D0\u4F9B\u8BA2\u9605\u540D\u79F0\u6216\u8BA2\u9605\u6570\u636E");let w;if(a&&!["localFirst","remoteFirst"].includes(s))w=a;else if(n){let I={};w=await Promise.all(n.split(/[\r\n]+/).map(q=>q.trim()).filter(q=>q.length).map(async q=>{try{return await xn(q,i||y.ua,void 0,A||y.proxy,void 0,p,g||y.noCache,!0)}catch(z){return I[q]=z,O.error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${q} \u53D1\u751F\u9519\u8BEF: ${z}`),""}}));let B=y.ignoreFailedRemoteSub;if(c!=null&&c!==""&&(B=c),!B&&Object.keys(I).length>0)throw new Error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?w.unshift(a):s==="remoteFirst"&&w.push(a)}else if(y.source==="local"&&!["localFirst","remoteFirst"].includes(y.mergeSources))w=y.content;else{let I={};w=await Promise.all(y.url.split(/[\r\n]+/).map(q=>q.trim()).filter(q=>q.length).map(async q=>{try{return await xn(q,i||y.ua,void 0,A||y.proxy,void 0,p,g||y.noCache,!0)}catch(z){return I[q]=z,O.error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${q} \u53D1\u751F\u9519\u8BEF: ${z}`),""}}));let B=y.ignoreFailedRemoteSub;if(c!=null&&c!==""&&(B=c),!B&&Object.keys(I).length>0)throw new Error(`\u8BA2\u9605 ${y.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(I).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);y.mergeSources==="localFirst"?w.unshift(y.content):y.mergeSources==="remoteFirst"&&w.push(y.content)}let S=(Array.isArray(w)?w:[w]).map(I=>Un.parse(I)).flat();if(S.forEach(I=>{I._subName=y.name,I._subDisplayName=y.displayName}),S=await Un.process(S,y.process||[],r,{[y.name]:y},f),S.length===0)throw new Error(`\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let _={};for(let I of S){if(_[I.name]){O.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${I.name}\uFF01`,"\u8BF7\u4ED4\u7EC6\u68C0\u6D4B\u914D\u7F6E\uFF01",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"});break}_[I.name]=!0}return Un.produce(S,r,h,v)}else if(["collection","col"].includes(e)){let y=O.read(Lt),w=O.read(Tt),S=gt(w,t);if(!S)throw new Error(`\u627E\u4E0D\u5230\u7EC4\u5408\u8BA2\u9605 ${t}`);let _=[...S.subscriptions],I=S.subscriptionTags;Array.isArray(I)&&I.length>0&&y.forEach(H=>{Array.isArray(H.tag)&&H.tag.length>0&&!_.includes(H.name)&&H.tag.some(K=>I.includes(K))&&_.push(H.name)});let B={},q={},z=0;await Promise.all(_.map(async H=>{let K=gt(y,H),Z=K.passThroughUA,G=K.ua;Z&&(O.info(`\u8BA2\u9605\u5F00\u542F\u4E86\u900F\u4F20 User-Agent, \u4F7F\u7528\u8BF7\u6C42\u7684 User-Agent: ${i}`),G=i);try{O.info(`\u6B63\u5728\u5904\u7406\u5B50\u8BA2\u9605\uFF1A${K.name}...`);let V;if(K.source==="local"&&!["localFirst","remoteFirst"].includes(K.mergeSources))V=K.content;else{let ie={};if(V=await await Promise.all(K.url.split(/[\r\n]+/).map(Se=>Se.trim()).filter(Se=>Se.length).map(async Se=>{try{return await xn(Se,G,void 0,A||K.proxy||S.proxy,void 0,void 0,g||K.noCache,!0)}catch(Ee){return ie[Se]=Ee,O.error(`\u8BA2\u9605 ${K.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Se} \u53D1\u751F\u9519\u8BEF: ${Ee}`),""}})),!K.ignoreFailedRemoteSub&&Object.keys(ie).length>0)throw new Error(`\u8BA2\u9605 ${K.name} \u7684\u8FDC\u7A0B\u8BA2\u9605 ${Object.keys(ie).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);K.mergeSources==="localFirst"?V.unshift(K.content):K.mergeSources==="remoteFirst"&&V.push(K.content)}let X=(Array.isArray(V)?V:[V]).map(ie=>Un.parse(ie)).flat();X.forEach(ie=>{ie._subName=K.name,ie._subDisplayName=K.displayName,ie._collectionName=S.name,ie._collectionDisplayName=S.displayName}),X=await Un.process(X,K.process||[],r,{[K.name]:K,_collection:S,$options:f}),B[H]=X,z++,O.info(`\u2705 \u5B50\u8BA2\u9605\uFF1A${K.name}\u52A0\u8F7D\u6210\u529F\uFF0C\u8FDB\u5EA6--${100*(z/_.length).toFixed(1)}% `)}catch(V){z++,q[H]=V,O.error(`\u274C \u5904\u7406\u7EC4\u5408\u8BA2\u9605\u4E2D\u7684\u5B50\u8BA2\u9605: ${K.name}\u65F6\u51FA\u73B0\u9519\u8BEF\uFF1A${V}\uFF01\u8FDB\u5EA6--${100*(z/_.length).toFixed(1)}%`)}}));let F=S.ignoreFailedRemoteSub;if(c!=null&&c!==""&&(F=c),!F&&Object.keys(q).length>0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u7684\u5B50\u8BA2\u9605 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);let P=Array.prototype.concat.apply([],_.map(H=>B[H]||[]));if(P.forEach(H=>{H._collectionName=S.name,H._collectionDisplayName=S.displayName}),P=await Un.process(P,S.process||[],r,{_collection:S},f),P.length===0)throw new Error(`\u7EC4\u5408\u8BA2\u9605 ${t} \u4E2D\u4E0D\u542B\u6709\u6548\u8282\u70B9`);let L={};for(let H of P){if(L[H.name]){O.notify("\u{1F30D} Sub-Store",`\u26A0\uFE0F \u7EC4\u5408\u8BA2\u9605 ${t} \u5305\u542B\u91CD\u590D\u8282\u70B9 ${H.name}\uFF01`,"\u8BF7\u4ED4\u7EC6\u68C0\u6D4B\u914D\u7F6E\uFF01",{"media-url":"https://cdn3.iconfinder.com/data/icons/seo-outline-1/512/25_code_program_programming_develop_bug_search_developer-512.png"});break}L[H.name]=!0}return Un.produce(P,r,h,v)}else if(e==="rule"){let y=O.read(Sc),w=gt(y,t);if(!w)throw new Error(`\u627E\u4E0D\u5230\u89C4\u5219 ${t}`);let S=[];for(let _=0;_F.trim()).filter(F=>F.length).map(async F=>{try{return await xn(F,i||w.ua,void 0,w.proxy||A,void 0,void 0,g)}catch(P){return q[F]=P,O.error(`\u6587\u4EF6 ${w.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${F} \u53D1\u751F\u9519\u8BEF: ${P}`),""}}));let z=w.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(z=l),!z&&Object.keys(q).length>0)throw new Error(`\u6587\u4EF6 ${w.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);s==="localFirst"?S.unshift(a):s==="remoteFirst"&&S.push(a)}else if(w.source==="local"&&!["localFirst","remoteFirst"].includes(w.mergeSources))S=w.content;else{let q={};S=await Promise.all(w.url.split(/[\r\n]+/).map(F=>F.trim()).filter(F=>F.length).map(async F=>{try{return await xn(F,i||w.ua,void 0,w.proxy||A,void 0,void 0,g)}catch(P){return q[F]=P,O.error(`\u6587\u4EF6 ${w.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${F} \u53D1\u751F\u9519\u8BEF: ${P}`),""}}));let z=w.ignoreFailedRemoteFile;if(l!=null&&l!==""&&(z=l),!z&&Object.keys(q).length>0)throw new Error(`\u6587\u4EF6 ${w.name} \u7684\u8FDC\u7A0B\u6587\u4EF6 ${Object.keys(q).join(", ")} \u53D1\u751F\u9519\u8BEF, \u8BF7\u67E5\u770B\u65E5\u5FD7`);w.mergeSources==="localFirst"?S.unshift(w.content):w.mergeSources==="remoteFirst"&&S.push(w.content)}let _=(Array.isArray(S)?S:[S]).flat(),I=_.filter(q=>q!=null&&q!=="").join(` `);return(Array.isArray(w.process)&&w.process.length>0?await Un.process({$files:_,$content:I,$options:f,$file:w},w.process):{$content:I,$files:_,$options:f})?.$content??""}}function H0(e){O.read(dt)||O.write([],dt),e.get("/share/file/:name",zA),e.route("/api/file/:name").get(zA).patch(NP).delete(kP),e.route("/api/wholeFile/:name").get(OP),e.route("/api/files").get(LP).post(xP).put(HP),e.route("/api/wholeFiles").get(UP)}function xP(e,t){let r=e.body;r.name=`${r.name??Date.now()}`,O.info(`\u6B63\u5728\u521B\u5EFA\u6587\u4EF6\uFF1A${r.name}`);let n=O.read(dt);if(gt(n,r.name))return Ue(t,new pt("DUPLICATE_KEY",e.body.name?`\u5DF2\u5B58\u5728 name \u4E3A ${r.name} \u7684\u6587\u4EF6`:"\u65E0\u6CD5\u540C\u65F6\u521B\u5EFA\u76F8\u540C\u7684\u6587\u4EF6 \u53EF\u7A0D\u540E\u91CD\u8BD5"));n.push(r),O.write(n,dt),xe(t,r,201)}async function zA(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.headers["user-agent"]||e.headers["User-Agent"];O.info(`\u6B63\u5728\u4E0B\u8F7D\u6587\u4EF6\uFF1A${r} \u8BF7\u6C42 User-Agent: ${n}`);let{url:i,subInfoUrl:a,subInfoUserAgent:s,ua:c,content:l,mergeSources:h,ignoreFailedRemoteFile:v,proxy:E,noCache:p}=e.query,f={_req:{method:e.method,url:e.url,path:e.path,query:e.query,params:e.params,headers:e.headers,body:e.body}};if(e.query.$options){try{f=JSON.parse(decodeURIComponent(e.query.$options))}catch{for(let w of e.query.$options.split("&")){let S=w.split("=")[0],_=w.split("=")[1];f[S]=_==null||_===""?!0:decodeURIComponent(_)}}O.info(`\u4F20\u5165 $options: ${JSON.stringify(f)}`)}i&&(i=decodeURIComponent(i),O.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 URL: ${i}`)),E&&(E=decodeURIComponent(E),O.info(`\u6307\u5B9A\u8FDC\u7A0B\u8BA2\u9605\u4F7F\u7528\u4EE3\u7406/\u7B56\u7565 proxy: ${E}`)),c&&(c=decodeURIComponent(c),O.info(`\u6307\u5B9A\u8FDC\u7A0B\u6587\u4EF6 User-Agent: ${c}`)),a&&(a=decodeURIComponent(a),O.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUrl: ${a}`)),s&&(s=decodeURIComponent(s),O.info(`\u6307\u5B9A\u83B7\u53D6\u6D41\u91CF\u7684 subInfoUserAgent: ${s}`)),l&&(l=decodeURIComponent(l),O.info(`\u6307\u5B9A\u672C\u5730\u6587\u4EF6: ${l}`)),h&&(h=decodeURIComponent(h),O.info(`\u6307\u5B9A\u5408\u5E76\u6765\u6E90: ${h}`)),v!=null&&v!==""&&(v=decodeURIComponent(v),O.info(`\u6307\u5B9A\u5FFD\u7565\u5931\u8D25\u7684\u8FDC\u7A0B\u6587\u4EF6: ${v}`)),p&&O.info(`\u6307\u5B9A\u4E0D\u4F7F\u7528\u7F13\u5B58: ${p}`);let A=O.read(dt),g=gt(A,r);if(g)try{let y=await la({type:"file",name:r,url:i,ua:c,content:l,mergeSources:h,ignoreFailedRemoteFile:v,$options:f,proxy:E,noCache:p});try{if(a=a||g.subInfoUrl,a){let w=await Oi(a,s||g.subInfoUserAgent,void 0,E||g.proxy);w&&t.set("subscription-userinfo",gf(w))}}catch(w){O.error(`\u6587\u4EF6 ${r} \u83B7\u53D6\u6D41\u91CF\u4FE1\u606F\u65F6\u53D1\u751F\u9519\u8BEF: ${JSON.stringify(w)}`)}g.download&&t.set("Content-Disposition",`attachment; filename*=UTF-8''${encodeURIComponent(g.displayName||g.name)}`),t.set("Content-Type","text/plain; charset=utf-8").send(y??"")}catch(y){O.notify("\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25",`\u274C \u65E0\u6CD5\u4E0B\u8F7D\u6587\u4EF6\uFF1A${r}\uFF01`,`\u{1F914} \u539F\u56E0\uFF1A${y.message??y}`),O.error(y.message??y),Ue(t,new Rr("INTERNAL_SERVER_ERROR",`Failed to download file: ${r}`,`Reason: ${y.message??y}`))}else O.error(`\u{1F30D} Sub-Store \u4E0B\u8F7D\u6587\u4EF6\u5931\u8D25 \u274C \u672A\u627E\u5230\u6587\u4EF6\uFF1A${r}\uFF01`),Ue(t,new lr("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function OP(e,t){let{name:r}=e.params,{raw:n}=e.query;r=decodeURIComponent(r);let i=O.read(dt),a=gt(i,r);a?n?t.set("content-type","application/json").set("content-disposition",`attachment; filename="${encodeURIComponent(`sub-store_file_${r}_${ea(new Date)}.json`)}"`).send(JSON.stringify(a)):xe(t,a):Ue(t,new lr("FILE_NOT_FOUND",`File ${r} does not exist`,404))}function NP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=O.read(dt),a=gt(i,r);if(a){let s={...a,...n};if(O.info(`\u6B63\u5728\u66F4\u65B0\u6587\u4EF6\uFF1A${r}...`),r!==s.name){let c=O.read(Ct)||[];for(let l of c)l.type==="file"&&l.source===a.name&&(l.source=s.name);O.write(c,Ct)}di(i,r,s),O.write(i,dt),xe(t,s)}else Ue(t,new lr("RESOURCE_NOT_FOUND",`File ${r} does not exist!`),404)}function kP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),O.info(`\u6B63\u5728\u5220\u9664\u6587\u4EF6\uFF1A${r}`);let n=O.read(dt);ri(n,r),O.write(n,dt),xe(t)}function LP(e,t){let r=O.read(dt);xe(t,r.map(({content:n,...i})=>i))}function UP(e,t){let r=O.read(dt);xe(t,r)}function HP(e,t){let r=e.body;O.write(r,dt),xe(t)}function j0(e){O.read(ti)||O.write([],ti),e.post("/api/token",qP),e.route("/api/token/:token").delete(jP),e.route("/api/tokens").get(MP)}function jP(e,t){let{token:r}=e.params;r=decodeURIComponent(r),O.info(`\u6B63\u5728\u5220\u9664\uFF1A${r}`);let n=O.read(ti);ri(n,r,"token"),O.write(n,ti),xe(t)}function MP(e,t){let{type:r,name:n}=e.query,i=O.read(ti)||[];xe(t,r||n?i.filter(a=>(r?a.type===r:!0)&&(n?a.name===n:!0)):i)}async function qP(req,res){if(!$r().isNode)return Ue(res,new pt("INVALID_ENV","This endpoint is only available in Node.js environment"));try{let{payload,options}=req.body,ms=eval('require("ms")'),token=payload?.token;if(token!=null){if(typeof token!="string"||token.length<1)return Ue(res,new pt("INVALID_CUSTOM_TOKEN",`Invalid custom token: ${token}`));if((O.read(ti)||[]).find(t=>t.token===token))return Ue(res,new pt("DUPLICATE_TOKEN",`Token ${token} already exists`))}let type=payload?.type,name=payload?.name;if(!type||!name)return Ue(res,new pt("INVALID_PAYLOAD","payload type and name are required"));if(type==="col"){if(!(O.read(Tt)||[]).find(r=>r.name===name))return Ue(res,new pt("INVALID_COLLECTION",`collection ${name} not found`))}else if(type==="file"){if(!(O.read(dt)||[]).find(r=>r.name===name))return Ue(res,new pt("INVALID_FILE",`file ${name} not found`))}else if(type==="sub"){if(!(O.read(Lt)||[]).find(r=>r.name===name))return Ue(res,new pt("INVALID_SUB",`sub ${name} not found`))}else return Ue(res,new pt("INVALID_TYPE",`type ${name} not supported`));let expiresIn=options?.expiresIn;if(options?.expiresIn!=null&&(expiresIn=ms(options.expiresIn),expiresIn==null||isNaN(expiresIn)||expiresIn<=0))return Ue(res,new pt("INVALID_EXPIRES_IN",`Invalid expiresIn option: ${options.expiresIn}`));let nanoid=eval('require("nanoid")'),tokens=O.read(ti)||[];if(!token)do token=nanoid.customAlphabet(nanoid.urlAlphabet)();while(tokens.find(e=>e.token===token));return tokens.push({...payload,token,createdAt:Date.now(),expiresIn:expiresIn>0?options?.expiresIn:void 0,exp:expiresIn>0?Date.now()+expiresIn:void 0}),O.write(tokens,ti),xe(res,{token})}catch(e){return Ue(res,new Rr("TOKEN_SIGN_FAILED","Failed to sign token",`Reason: ${e.message??e}`))}}function M0(e){O.read(gn)||O.write([],gn),e.route("/api/module/:name").get(VP).patch(GP).delete(zP),e.route("/api/modules").get(YP).post(KP).put(WP)}function KP(e,t){let r=e.body;r.name=`${r.name??Tn(JSON.stringify(r))}`,O.info(`\u6B63\u5728\u521B\u5EFA\u6A21\u5757\uFF1A${r.name}`);let n=O.read(gn);if(gt(n,r.name))return Ue(t,new pt("DUPLICATE_KEY",e.body.name?`\u5DF2\u5B58\u5728 name \u4E3A ${r.name} \u7684\u6A21\u5757`:"\u5DF2\u5B58\u5728\u76F8\u540C\u7684\u6A21\u5757 \u8BF7\u52FF\u91CD\u590D\u6DFB\u52A0"));n.push(r),O.write(n,gn),xe(t,r,201)}function VP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=O.read(gn),i=gt(n,r);i?t.set("Content-Type","text/plain; charset=utf-8").send(i.content):Ue(t,new lr("MODULE_NOT_FOUND",`Module ${r} does not exist`,404))}function GP(e,t){let{name:r}=e.params;r=decodeURIComponent(r);let n=e.body,i=O.read(gn),a=gt(i,r);if(a){let s={...a,...n};O.info(`\u6B63\u5728\u66F4\u65B0\u6A21\u5757\uFF1A${r}...`),di(i,r,s),O.write(i,gn),xe(t,s)}else Ue(t,new lr("RESOURCE_NOT_FOUND",`Module ${r} does not exist!`),404)}function zP(e,t){let{name:r}=e.params;r=decodeURIComponent(r),O.info(`\u6B63\u5728\u5220\u9664\u6A21\u5757\uFF1A${r}`);let n=O.read(gn);ri(n,r),O.write(n,gn),xe(t)}function YP(e,t){let r=O.read(gn);xe(t,r.map(({content:n,...i})=>i))}function WP(e,t){let r=e.body;O.write(r,gn),xe(t)}console.log(` \u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505 Sub-Store -- v${Wl} \u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505\u2505 `);Xu();XP();function XP(){let e=Op({substore:O});zp(e),Xp(e),j0(e),H0(e),M0(e),Jp(e),Zp(e),rd(e),td(e),e.start()}})(); /*! Bundled license information: ieee754/index.js: (*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh *) buffer/index.js: (*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT *) jsrsasign/lib/jsrsasign.js: (*! CryptoJS v3.1.2 core-fix.js * code.google.com/p/crypto-js * (c) 2009-2013 by Jeff Mott. All rights reserved. * code.google.com/p/crypto-js/wiki/License * THIS IS FIX of 'core.js' to fix Hmac issue. * https://code.google.com/p/crypto-js/issues/detail?id=84 * https://crypto-js.googlecode.com/svn-history/r667/branches/3.x/src/core.js *) (*! (c) Tom Wu | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Tom Wu, Kenji Urushima | http://www-cs-students.stanford.edu/~tjw/jsbn/ *) (*! (c) Stefan Thomas | https://github.com/bitcoinjs/bitcoinjs-lib *) (*! Mike Samuel (c) 2009 | code.google.com/p/json-sans-eval *) lodash/lodash.js: (** * @license * Lodash * Copyright OpenJS Foundation and other contributors * Released under MIT license * Based on Underscore.js 1.8.3 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors *) */